@idlizer/core 2.1.10-arktscgen-5 → 2.1.10-arktscgen-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/build/lib/src/Language.js +1 -1
  2. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +16 -6
  3. package/build/lib/src/LanguageWriters/ArgConvertors.js +80 -92
  4. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +8 -6
  5. package/build/lib/src/LanguageWriters/LanguageWriter.js +8 -2
  6. package/build/lib/src/LanguageWriters/common.d.ts +1 -0
  7. package/build/lib/src/LanguageWriters/common.js +2 -1
  8. package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +7 -1
  9. package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +53 -15
  10. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +1 -0
  11. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +10 -8
  12. package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +1 -1
  13. package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +25 -14
  14. package/build/lib/src/LanguageWriters/index.d.ts +4 -3
  15. package/build/lib/src/LanguageWriters/index.js +9 -11
  16. package/build/lib/src/LanguageWriters/nameConvertor.d.ts +2 -0
  17. package/build/lib/src/LanguageWriters/nameConvertor.js +11 -0
  18. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +1 -1
  19. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +1 -8
  20. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +52 -89
  21. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +3 -0
  22. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +24 -7
  23. package/build/lib/src/config.d.ts +2 -1461
  24. package/build/lib/src/config.js +16 -32
  25. package/build/lib/src/configMerge.d.ts +3 -0
  26. package/build/lib/src/configMerge.js +63 -0
  27. package/build/lib/src/diagnostictypes.d.ts +1 -5
  28. package/build/lib/src/diagnostictypes.js +1 -27
  29. package/build/lib/src/from-idl/DtsPrinter.js +12 -5
  30. package/build/lib/src/from-idl/IDLLinter.d.ts +3 -4
  31. package/build/lib/src/from-idl/IDLLinter.js +30 -32
  32. package/build/lib/src/from-idl/deserialize.d.ts +3 -4
  33. package/build/lib/src/from-idl/deserialize.js +29 -641
  34. package/build/lib/src/from-idl/parser.d.ts +20 -2
  35. package/build/lib/src/from-idl/parser.js +97 -29
  36. package/build/lib/src/idl/builders.d.ts +43 -0
  37. package/build/lib/src/idl/builders.js +135 -0
  38. package/build/lib/src/idl/discriminators.d.ts +53 -0
  39. package/build/lib/src/idl/discriminators.js +232 -0
  40. package/build/lib/src/idl/dump.d.ts +48 -0
  41. package/build/lib/src/idl/dump.js +327 -0
  42. package/build/lib/src/idl/index.d.ts +9 -0
  43. package/build/lib/src/idl/index.js +23 -0
  44. package/build/lib/src/idl/keywords.d.ts +2 -0
  45. package/build/lib/src/{options.js → idl/keywords.js} +7 -3
  46. package/build/lib/src/idl/node.d.ts +233 -0
  47. package/build/lib/src/idl/node.js +103 -0
  48. package/build/lib/src/idl/stdlib.d.ts +34 -0
  49. package/build/lib/src/idl/stdlib.js +54 -0
  50. package/build/lib/src/idl/utils.d.ts +44 -0
  51. package/build/lib/src/idl/utils.js +215 -0
  52. package/build/lib/src/idl/visitors.d.ts +15 -0
  53. package/build/lib/src/idl/visitors.js +593 -0
  54. package/build/lib/src/index.d.ts +4 -2
  55. package/build/lib/src/index.js +5 -3
  56. package/build/lib/src/inputPaths.d.ts +11 -0
  57. package/build/lib/src/inputPaths.js +81 -0
  58. package/build/lib/src/languageSpecificKeywords.d.ts +0 -1
  59. package/build/lib/src/languageSpecificKeywords.js +0 -5
  60. package/build/lib/src/peer-generation/LayoutManager.d.ts +1 -1
  61. package/build/lib/src/peer-generation/Materialized.d.ts +8 -2
  62. package/build/lib/src/peer-generation/Materialized.js +24 -12
  63. package/build/lib/src/peer-generation/PeerLibrary.d.ts +10 -15
  64. package/build/lib/src/peer-generation/PeerLibrary.js +35 -215
  65. package/build/lib/src/peer-generation/ReferenceResolver.d.ts +6 -1
  66. package/build/lib/src/peer-generation/ReferenceResolver.js +93 -2
  67. package/build/lib/src/peer-generation/idl/common.d.ts +6 -2
  68. package/build/lib/src/peer-generation/idl/common.js +7 -7
  69. package/build/lib/src/peer-generation/isMaterialized.js +2 -3
  70. package/build/lib/src/peer-generation/modules.js +2 -0
  71. package/build/lib/src/peer-generation/toDeclaration.d.ts +4 -0
  72. package/build/lib/src/peer-generation/toDeclaration.js +53 -0
  73. package/build/lib/src/peer-generation/unions.d.ts +1 -1
  74. package/build/lib/src/peer-generation/unions.js +15 -7
  75. package/build/lib/src/resolveNamedNode.d.ts +1 -0
  76. package/build/lib/src/resolveNamedNode.js +7 -0
  77. package/build/lib/src/transformers/FqnTransformer.d.ts +1 -1
  78. package/build/lib/src/transformers/FqnTransformer.js +20 -12
  79. package/build/lib/src/transformers/GenericTransformer.d.ts +4 -3
  80. package/build/lib/src/transformers/GenericTransformer.js +252 -158
  81. package/build/lib/src/transformers/IdlTransformer.d.ts +6 -0
  82. package/build/lib/src/transformers/IdlTransformer.js +7 -0
  83. package/build/lib/src/transformers/NullTransformer.d.ts +1 -1
  84. package/build/lib/src/transformers/NullTransformer.js +27 -21
  85. package/build/lib/src/transformers/OnSerializeTransformer.d.ts +1 -1
  86. package/build/lib/src/transformers/OnSerializeTransformer.js +28 -13
  87. package/build/lib/src/util.d.ts +4 -0
  88. package/build/lib/src/util.js +22 -0
  89. package/package.json +6 -7
  90. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.d.ts +0 -37
  91. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +0 -210
  92. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +0 -85
  93. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +0 -306
  94. package/build/lib/src/from-idl/webidl2-utils.d.ts +0 -21
  95. package/build/lib/src/from-idl/webidl2-utils.js +0 -87
  96. package/build/lib/src/idl.d.ts +0 -444
  97. package/build/lib/src/idl.js +0 -1385
  98. package/build/lib/src/idlize.d.ts +0 -25
  99. package/build/lib/src/idlize.js +0 -198
  100. package/build/lib/src/options.d.ts +0 -13
  101. package/build/lib/src/peer-generation/BuilderClass.d.ts +0 -20
  102. package/build/lib/src/peer-generation/BuilderClass.js +0 -68
  103. package/webidl2.js/dist/webidl2.js +0 -4622
  104. package/webidl2.js/package.json +0 -55
@@ -1,25 +0,0 @@
1
- import * as ts from "typescript";
2
- import * as idl from "./idl";
3
- import { GenerateOptions } from "./options";
4
- export declare function scanDirectory(dir: string, fileFilter: (file: string) => boolean, recursive?: boolean): string[];
5
- export declare function scanInputDirs(inputDirs: string[]): string[];
6
- export declare function scanInputDirs(inputDirs: string[], fileExtension: string): string[];
7
- export declare function scanInputDirs(inputDirs: string[], fileFilter: (file: string) => boolean, recursive: boolean): string[];
8
- export interface GenerateVisitor<T> {
9
- visitPhase1(): T;
10
- visitPhase2?(siblings: {
11
- [key in string]: {
12
- tsSourceFile: ts.SourceFile;
13
- visitor: GenerateVisitor<T>;
14
- result: T;
15
- isAux: boolean;
16
- };
17
- }): T;
18
- }
19
- export declare function generate<T>(baseDirs: string[], lookupDirs: string[], inputFiles: string[], auxInputFiles: string[], outputDir: string, stdlibFile: string, visitorFactory: (sourceFile: ts.SourceFile, program: ts.Program, compilerHost: ts.CompilerHost) => GenerateVisitor<T>, options: GenerateOptions<T>): void;
20
- export declare const PACKAGE_IDLIZE_INTERNAL = "idlize.internal";
21
- export declare function isInIdlize(entry: idl.IDLEntry | idl.IDLFile): boolean;
22
- export declare function isInIdlizeInterop(entry: idl.IDLEntry | idl.IDLFile): boolean;
23
- export declare function isInIdlizeInternal(entry: idl.IDLEntry | idl.IDLFile): boolean;
24
- export declare function isInIdlizeStdlib(entry: idl.IDLEntry | idl.IDLFile): boolean;
25
- //# sourceMappingURL=idlize.d.ts.map
@@ -1,198 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
- import * as ts from "typescript";
16
- import * as fs from "fs";
17
- import * as path from "path";
18
- import * as idl from "./idl";
19
- import { isDefined } from "./util";
20
- export function scanDirectory(dir, fileFilter, recursive = false) {
21
- const dirsToVisit = [path.resolve(dir)];
22
- const result = [];
23
- while (dirsToVisit.length > 0) {
24
- let dir = dirsToVisit.pop();
25
- let dirents = fs.readdirSync(dir, { withFileTypes: true });
26
- for (const entry of dirents) {
27
- const fullPath = path.join(dir, entry.name);
28
- if (entry.isFile()) {
29
- if (fileFilter(fullPath)) {
30
- result.push(fullPath);
31
- }
32
- }
33
- else if (recursive && entry.isDirectory()) {
34
- dirsToVisit.push(fullPath);
35
- }
36
- }
37
- }
38
- return result;
39
- }
40
- export function scanInputDirs(inputDirs, fileFilter = undefined, recursive = false) {
41
- if (typeof fileFilter === 'undefined')
42
- return scanInputDirs(inputDirs, (_) => true, recursive);
43
- if (typeof fileFilter === 'string')
44
- return scanInputDirs(inputDirs, (file) => file.endsWith(fileFilter), recursive);
45
- const resolvedInputDirs = inputDirs.map(dir => path.resolve(dir));
46
- console.log("Resolved input directories:", resolvedInputDirs);
47
- return resolvedInputDirs.flatMap(dir => {
48
- if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
49
- console.log(`Processing all definitions from directory: ${dir}`);
50
- return scanDirectory(dir, fileFilter, recursive);
51
- }
52
- else {
53
- console.warn(`Warning: Directory does not exist or is not a directory: ${dir}`);
54
- return [];
55
- }
56
- }).sort((a, b) => {
57
- return path.basename(a).localeCompare(path.basename(b));
58
- });
59
- }
60
- function fileExists(fileName) {
61
- return ts.sys.fileExists(fileName);
62
- }
63
- export function generate(baseDirs, lookupDirs, inputFiles, auxInputFiles, outputDir, stdlibFile, visitorFactory, options) {
64
- var _a, _b, _c;
65
- if (options.enableLog) {
66
- console.log("Starting generation process...");
67
- }
68
- if (inputFiles.length === 0) {
69
- console.error("Error: No input files specified.");
70
- process.exit(1);
71
- }
72
- let input = new Set;
73
- let auxInput = new Set;
74
- {
75
- const resolveOne = (file, tag) => {
76
- const fullPath = path.resolve(file);
77
- if (fs.existsSync(fullPath)) {
78
- if (options.enableLog)
79
- console.log(`Including ${tag} file: ${fullPath}`);
80
- return fullPath;
81
- }
82
- else
83
- console.warn(`Warning: ${tag} file does not exist: ${fullPath}`);
84
- };
85
- inputFiles.map(file => resolveOne(file, "file")).filter(isDefined).sort().map(file => input.add(file));
86
- auxInputFiles.map(file => resolveOne(file, "aux file")).filter(isDefined).sort().map(file => auxInput.add(file));
87
- }
88
- const compilerHostBase = ts.createCompilerHost(options.compilerOptions);
89
- const compilerHost = Object.assign(Object.assign({}, compilerHostBase), { resolveModuleNames: (moduleNames, containingFile, reusedNames, redirectedReference, options, containingSourceFile) => {
90
- const resolvedModules = [];
91
- for (let moduleName of moduleNames) {
92
- // TODO: move this replacement table to some external config...
93
- {
94
- const replacement = {
95
- "../component/navigation": "@internal/component/ets/navigation",
96
- "wrappedBuilderObject": "@internal/component/ets/common",
97
- };
98
- moduleName = replacement[moduleName] || moduleName;
99
- }
100
- let result = ts.resolveModuleName(moduleName, containingFile, options, compilerHostBase).resolvedModule;
101
- if (result)
102
- resolvedModules.push(result);
103
- else {
104
- // as a some fallback - try to resolve from parents of containingFile, lookupDirs
105
- for (let pov of [path.dirname(containingFile), ...lookupDirs]) {
106
- while (!result) {
107
- for (const extension of ["", ".d.ts", ".d.ets"]) {
108
- const candidate = `${moduleName}${extension}`;
109
- if (path.isAbsolute(candidate) && fileExists(candidate)) {
110
- result = { resolvedFileName: candidate, extension: ts.Extension.Dts, isExternalLibraryImport: false };
111
- break;
112
- }
113
- const povCandidate = path.join(pov, candidate);
114
- if (fileExists(povCandidate)) {
115
- result = { resolvedFileName: povCandidate, extension: ts.Extension.Dts, isExternalLibraryImport: false };
116
- break;
117
- }
118
- }
119
- if (result)
120
- break;
121
- result = ts.resolveModuleName(path.join(pov, moduleName), containingFile, options, compilerHostBase).resolvedModule;
122
- if (result)
123
- break;
124
- result = ts.resolveModuleName(moduleName, pov, options, compilerHostBase).resolvedModule;
125
- if (result)
126
- break;
127
- const nextPov = path.resolve(pov, "..");
128
- if (nextPov == pov)
129
- break;
130
- if (baseDirs.every(baseDir => path.relative(baseDir, nextPov).startsWith("..")))
131
- break;
132
- pov = nextPov;
133
- }
134
- if (result)
135
- break;
136
- }
137
- if (!result)
138
- console.warn(`Dts import at '${containingFile}', module '${moduleName}': unable to resolve source file path`);
139
- resolvedModules.push(result);
140
- }
141
- }
142
- return resolvedModules;
143
- } });
144
- if (!fs.existsSync(stdlibFile))
145
- throw new Error("Unable to find stdlib.d.ts");
146
- const program = ts.createProgram([...input.values(), ...auxInput.values(), stdlibFile], options.compilerOptions, compilerHost);
147
- if (options.enableLog) {
148
- console.log("Initialized TypeScript program with input files:", input);
149
- }
150
- if (outputDir && !fs.existsSync(outputDir))
151
- fs.mkdirSync(outputDir, { recursive: true });
152
- const typeChecker = program.getTypeChecker();
153
- (_a = options.onBegin) === null || _a === void 0 ? void 0 : _a.call(options, outputDir, typeChecker);
154
- const dtsFileName2Visitor = {};
155
- for (const sourceFile of program.getSourceFiles()) {
156
- const resolvedSourceFileName = path.resolve(sourceFile.fileName);
157
- const isAux = !input.has(resolvedSourceFileName);
158
- if (options.enableLog) {
159
- console.log(`Processing ${isAux ? "aux " : ""}file: ${resolvedSourceFileName}`);
160
- }
161
- // Walk the tree to search for classes
162
- const visitor = visitorFactory(sourceFile, program, compilerHost);
163
- const result = visitor.visitPhase1();
164
- dtsFileName2Visitor[sourceFile.fileName] = {
165
- tsSourceFile: sourceFile,
166
- visitor,
167
- result,
168
- isAux: isAux
169
- };
170
- }
171
- for (const resolvedSourceFileName in dtsFileName2Visitor) {
172
- const visitorStaff = dtsFileName2Visitor[resolvedSourceFileName];
173
- if (visitorStaff.visitor.visitPhase2)
174
- visitorStaff.result = visitorStaff.visitor.visitPhase2(dtsFileName2Visitor);
175
- }
176
- for (const resolvedSourceFileName in dtsFileName2Visitor) {
177
- const visitorStaff = dtsFileName2Visitor[resolvedSourceFileName];
178
- (_b = options.onSingleFile) === null || _b === void 0 ? void 0 : _b.call(options, visitorStaff.result, outputDir, visitorStaff.tsSourceFile, visitorStaff.isAux);
179
- }
180
- (_c = options.onEnd) === null || _c === void 0 ? void 0 : _c.call(options, outputDir);
181
- if (options.enableLog) {
182
- console.log("Generation completed.");
183
- }
184
- }
185
- export const PACKAGE_IDLIZE_INTERNAL = "idlize.internal";
186
- export function isInIdlize(entry) {
187
- return idl.isInPackage(entry, "idlize");
188
- }
189
- export function isInIdlizeInterop(entry) {
190
- return idl.isInPackage(entry, `${PACKAGE_IDLIZE_INTERNAL}.interop`);
191
- }
192
- export function isInIdlizeInternal(entry) {
193
- return idl.isInPackage(entry, PACKAGE_IDLIZE_INTERNAL);
194
- }
195
- export function isInIdlizeStdlib(entry) {
196
- return idl.isInPackage(entry, "idlize.stdlib");
197
- }
198
- //# sourceMappingURL=idlize.js.map
@@ -1,13 +0,0 @@
1
- import * as ts from "typescript";
2
- export interface GenerateOptions<T> {
3
- compilerOptions: ts.CompilerOptions;
4
- onBegin?: (outDir: string, typeChecker: ts.TypeChecker) => void;
5
- onSingleFile?: (entries: T, outDir: string, inputFile: ts.SourceFile, isAux: boolean) => void;
6
- onEnd?: (outDir: string) => void;
7
- enableLog?: boolean;
8
- recursive?: boolean;
9
- }
10
- export interface GenericVisitor<T> {
11
- visitWholeFile(): T;
12
- }
13
- //# sourceMappingURL=options.d.ts.map
@@ -1,20 +0,0 @@
1
- import { IDLInterface, IDLReferenceType } from "../idl";
2
- import { Field, Method } from "../LanguageWriters/LanguageWriter";
3
- export declare class BuilderClass {
4
- readonly declaration: IDLInterface;
5
- readonly name: string;
6
- readonly generics: string[] | undefined;
7
- readonly isInterface: boolean;
8
- readonly superClass: IDLReferenceType | undefined;
9
- readonly fields: Field[];
10
- readonly constructors: Method[];
11
- readonly methods: Method[];
12
- readonly needBeGenerated: boolean;
13
- constructor(declaration: IDLInterface, name: string, generics: string[] | undefined, isInterface: boolean, superClass: IDLReferenceType | undefined, fields: Field[], constructors: Method[], methods: Method[], needBeGenerated?: boolean);
14
- }
15
- /**
16
- * Builder classes are classes with methods which have only one parameter and return only itself
17
- */
18
- export declare function isBuilderClass(declaration: IDLInterface): boolean;
19
- export declare function methodsGroupOverloads(methods: Method[]): Method[][];
20
- //# sourceMappingURL=BuilderClass.d.ts.map
@@ -1,68 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
- import { generatorConfiguration } from "../config";
16
- export class BuilderClass {
17
- constructor(declaration, name, generics, isInterface, superClass, fields, constructors, methods, needBeGenerated = true) {
18
- this.declaration = declaration;
19
- this.name = name;
20
- this.generics = generics;
21
- this.isInterface = isInterface;
22
- this.superClass = superClass;
23
- this.fields = fields;
24
- this.constructors = constructors;
25
- this.methods = methods;
26
- this.needBeGenerated = needBeGenerated;
27
- }
28
- }
29
- /**
30
- * Builder classes are classes with methods which have only one parameter and return only itself
31
- */
32
- export function isBuilderClass(declaration) {
33
- const className = declaration.name;
34
- if (generatorConfiguration().builderClasses.includes(className)) {
35
- return true;
36
- }
37
- // TBD: update builder class check condition.
38
- // Only SubTabBarStyle, BottomTabBarStyle, DotIndicator, and DigitIndicator classes
39
- // are used for now.
40
- return false;
41
- /*
42
- if (peerGeneratorConfiguration().isStandardNameIgnored(className)) {
43
- return false
44
- }
45
-
46
- const methods: (ts.MethodSignature | ts.MethodDeclaration)[] = [
47
- ...ts.isClassDeclaration(declaration) ? declaration.members.filter(ts.isMethodDeclaration) : [],
48
- ]
49
-
50
- if (methods.length === 0) {
51
- return false
52
- }
53
-
54
- return methods.every(it => it.type && className == it.type.getText() && it.parameters.length === 1)
55
- */
56
- }
57
- export function methodsGroupOverloads(methods) {
58
- const seenNames = new Set();
59
- const groups = [];
60
- for (const method of methods) {
61
- if (seenNames.has(method.name))
62
- continue;
63
- seenNames.add(method.name);
64
- groups.push(methods.filter(it => it.name === method.name));
65
- }
66
- return groups;
67
- }
68
- //# sourceMappingURL=BuilderClass.js.map