Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9db00f4
chore: mave central
farfromrefug Mar 3, 2022
10bbe5d
feat: add aar support
farfromrefug Mar 3, 2022
8b9cdcd
Merge branch 'master' of github.com:NativeScript/android-dts-generator
farfromrefug Mar 3, 2022
9761582
fix: only warn once for each class
farfromrefug Mar 3, 2022
9b769bd
feat: default generics if no -input-generics passed
farfromrefug Mar 3, 2022
a2680d2
chore: updated readme for aar support
farfromrefug Mar 3, 2022
078a940
chore: gradle update
farfromrefug Mar 3, 2022
c4530da
feat: optional `-ignore-obfuscated 3` parameter to obfuscated classes…
farfromrefug Mar 4, 2022
48754db
Merge remote-tracking branch 'nativescript/main'
farfromrefug Sep 20, 2023
50d3046
chore: cleanup
farfromrefug Sep 20, 2023
eedc110
fix: fix eslint warnings
farfromrefug Sep 20, 2023
5e3d284
feat: const field value is now part of the typings
farfromrefug Oct 13, 2023
aa76cff
Merge remote-tracking branch 'nativescript/main'
farfromrefug Oct 13, 2023
a749971
chore: revert 7659d265
farfromrefug Mar 27, 2024
614a1b1
Merge branch 'NativeScript:main' into main
farfromrefug Jul 4, 2024
7fc0b66
Merge remote-tracking branch 'origin/main'
farfromrefug Jul 4, 2024
fd0ed64
Merge remote-tracking branch 'nativescript/main'
farfromrefug Aug 29, 2025
437a22c
chore: update
farfromrefug Aug 29, 2025
737926e
Merge remote-tracking branch 'origin/main'
farfromrefug Aug 29, 2025
072d94f
Updates to tackle Kotlin compatibility issues (#84)
dangrima90 Oct 18, 2025
cf4f25d
Merge pull request #1 from dangrima90/fix/kotlin-compatibility-issues
farfromrefug Oct 21, 2025
db47037
fix: many dts generation fixes:
farfromrefug Oct 25, 2025
888d56a
chore: cleanup
farfromrefug Oct 25, 2025
f94f3b8
chore: fixes
farfromrefug Oct 25, 2025
6635b48
fix: constant values real value is now exported as jsdoc
farfromrefug Oct 25, 2025
e88599a
fix: duplicated namespace and variable names
farfromrefug Nov 14, 2025
542a68c
feat: new -per-library option to separate generated typings
farfromrefug Nov 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dts-generator/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
9 changes: 9 additions & 0 deletions dts-generator/src/main/java/com/telerik/InputParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class InputParameters {
private boolean allGenericImplements;
private boolean skipDeclarations;
private boolean classMode;
private boolean perLibrary;
private int ignoreObfuscatedNameLength;

public InputParameters() {
Expand All @@ -25,6 +26,7 @@ public InputParameters() {
this.allGenericImplements = false;
this.skipDeclarations = false;
this.classMode = false;
this.perLibrary = false;
this.ignoreObfuscatedNameLength = 0;
}

Expand Down Expand Up @@ -70,4 +72,11 @@ public boolean isAllGenericImplementsEnabled() {

public void setIgnoreObfuscatedNameLength(int nameLength) { this.ignoreObfuscatedNameLength = nameLength; }

public boolean getPerLibrary() {
return perLibrary;
}

public void setPerLibrary(boolean perLibrary) {
this.perLibrary = perLibrary;
}
}
8 changes: 8 additions & 0 deletions dts-generator/src/main/java/com/telerik/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class Main {
// the parameter defines the length of obfuscated names to detect
private static final String IGNORE_OBFUSCATED = "-ignore-obfuscated";

private static final String PER_LIBRARY = "-per-library";


private static final String HELP = "-help";

public static void main(String[] args) {
Expand Down Expand Up @@ -117,6 +120,10 @@ public static InputParameters parseCommand(String[] args) throws Exception {
inputParameters.getSuperJars().add(new File(currentArgument));
}
}

if (commandArg.equals(PER_LIBRARY)) {
inputParameters.setPerLibrary(true);
}
}

inputParameters.getOutputDir().mkdir();
Expand All @@ -138,6 +145,7 @@ private static void printHelpMessage() {
helpMessage.appendln("\t\t[-all-generic-implements]:\t\tAdd this flag to generate implements for all interfaces implemented by the generic types." +
" It is not enabled by default as when there are more than one implementation most probably one of them needs to be changed to extends, but this have to be made manually");
helpMessage.appendln("\t\t[-skip-declarations]:\t\tProvide this flag if you don't want android-declarations.d.ts file to be generated and referenced.");
helpMessage.appendln("\t\t[-per-library]:\t\tGenerate separate .android.d.ts file per input jar/aar library.");
helpMessage.appendln("\t\t[--class-mode]:\t\tPass this argument if you want folders to be processed as class folders.");
helpMessage.appendln("\t\t[-help]:\t\tPrints this help message.");

Expand Down
86 changes: 44 additions & 42 deletions dts-generator/src/main/java/com/telerik/dts/ClassDirectrory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,48 @@
import java.util.Map;

public class ClassDirectrory implements ClassMapProvider {
private final String path;
private final Map<String, JavaClass> classMap;
private static final String CLASS_EXT = ".class";

private ClassDirectrory(String path) {
this.path = path;
this.classMap = new HashMap<String, JavaClass>();
}

public Map<String, JavaClass> getClassMap() {
return classMap;
}

public String getPath() {
return path;
}

public static ClassDirectrory readDirectory(String path) throws IOException {
ClassDirectrory dir = new ClassDirectrory(path);
readDirectory(dir, path);
return dir;
}

public static void readDirectory(ClassDirectrory dir, String path) throws IOException {
List<File> subDirs = new ArrayList<File>();
File currentDir = new File(path);
for (File file : currentDir.listFiles()) {
if (file.isFile()) {
String name = file.getName();
if (name.endsWith(CLASS_EXT)) {
ClassParser cp = new ClassParser(file.getAbsolutePath());
JavaClass clazz = cp.parse();
dir.classMap.put(clazz.getClassName(), clazz);
}
} else if (file.isDirectory()) {
subDirs.add(file);
}
}
for (File sd: subDirs) {
readDirectory(dir, sd.getAbsolutePath());
}
}
private Map<String, JavaClass> classes;
private String libraryName;
private static final String CLASS_EXT = ".class";

private ClassDirectrory() {
this.classes = new HashMap<String, JavaClass>();
}

public static ClassDirectrory readDirectory(String directoryPath) throws IOException {
ClassDirectrory dir = new ClassDirectrory();
readDirectory(dir, directoryPath);
return dir;
}

public static void readDirectory(ClassDirectrory dir, String path) throws IOException {
List<File> subDirs = new ArrayList<File>();
File currentDir = new File(path);
for (File file : currentDir.listFiles()) {
if (file.isFile()) {
String name = file.getName();
if (name.endsWith(CLASS_EXT)) {
ClassParser cp = new ClassParser(file.getAbsolutePath());
JavaClass clazz = cp.parse();
dir.classes.put(clazz.getClassName(), clazz);
}
} else if (file.isDirectory()) {
subDirs.add(file);
}
}
for (File sd: subDirs) {
readDirectory(dir, sd.getAbsolutePath());
}
dir.libraryName = new File(path).getName();
}

@Override
public Map<String, JavaClass> getClassMap() {
return classes;
}

@Override
public String getLibraryName() {
return libraryName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
public interface ClassMapProvider {
Map<String, JavaClass> getClassMap();

String getPath();
String getLibraryName();
}
13 changes: 13 additions & 0 deletions dts-generator/src/main/java/com/telerik/dts/ClassRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,17 @@ private static boolean keepGoing(boolean first) {
boolean res = first ? !isNestedClass : isNestedClass;
return res;
}

public static List<ClassMapProvider> getCachedProviders() {
return new ArrayList<>(cachedProviders);
}

public static String getLibraryNameForClass(String className) {
for (ClassMapProvider provider : cachedProviders) {
if (provider.getClassMap().containsKey(className)) {
return provider.getLibraryName();
}
}
return null;
}
}
Loading