@idlizer/core 2.1.0 → 2.1.2
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.
- package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +13 -0
- package/build/lib/src/LanguageWriters/ArgConvertors.js +66 -12
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +8 -1
- package/build/lib/src/LanguageWriters/LanguageWriter.js +3 -0
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +5 -3
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +0 -1
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +4 -0
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +2 -1
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +9 -1
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +46 -28
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +7 -1
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +3 -3
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +0 -1
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +0 -3
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +8 -2
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +29 -6
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +7 -1
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +31 -5
- package/build/lib/src/LibraryInterface.d.ts +0 -1
- package/build/lib/src/config.d.ts +823 -0
- package/build/lib/src/config.js +9 -0
- package/build/lib/src/from-idl/DtsPrinter.js +2 -2
- package/build/lib/src/idl.d.ts +4 -2
- package/build/lib/src/idl.js +13 -2
- package/build/lib/src/idlize.d.ts +1 -0
- package/build/lib/src/idlize.js +3 -2
- package/build/lib/src/index.d.ts +2 -0
- package/build/lib/src/index.js +2 -0
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +1 -3
- package/build/lib/src/peer-generation/PeerLibrary.js +10 -9
- package/build/lib/src/peer-generation/isEnumType.d.ts +5 -0
- package/build/lib/src/peer-generation/isEnumType.js +29 -0
- package/build/lib/src/peer-generation/modules.d.ts +10 -0
- package/build/lib/src/peer-generation/modules.js +38 -0
- package/build/lib/src/util.d.ts +1 -0
- package/build/lib/src/util.js +6 -0
- package/package.json +2 -2
- package/build/lib/src/configMerge.d.ts +0 -2
- package/build/lib/src/configMerge.js +0 -42
- package/webidl2.js/LICENSE +0 -21
- package/webidl2.js/README.md +0 -827
- package/webidl2.js/dist/package.json +0 -3
package/build/lib/src/config.js
CHANGED
|
@@ -16,6 +16,11 @@ import { D } from "./configDescriber";
|
|
|
16
16
|
const T = {
|
|
17
17
|
stringArray: () => D.array(D.string())
|
|
18
18
|
};
|
|
19
|
+
export const ModuleConfigurationSchema = D.object({
|
|
20
|
+
name: D.string(),
|
|
21
|
+
packages: T.stringArray(),
|
|
22
|
+
useFoldersLayout: D.maybe(D.boolean()),
|
|
23
|
+
});
|
|
19
24
|
export const CoreConfigurationSchema = D.object({
|
|
20
25
|
TypePrefix: D.string(),
|
|
21
26
|
LibraryPrefix: D.string(),
|
|
@@ -28,6 +33,8 @@ export const CoreConfigurationSchema = D.object({
|
|
|
28
33
|
forceMaterialized: T.stringArray(),
|
|
29
34
|
forceCallback: T.stringArray(),
|
|
30
35
|
forceContext: T.stringArray(),
|
|
36
|
+
moduleName: D.string(),
|
|
37
|
+
modules: D.map(D.string(), ModuleConfigurationSchema)
|
|
31
38
|
});
|
|
32
39
|
export const defaultCoreConfiguration = {
|
|
33
40
|
TypePrefix: "",
|
|
@@ -41,6 +48,8 @@ export const defaultCoreConfiguration = {
|
|
|
41
48
|
forceMaterialized: [],
|
|
42
49
|
forceCallback: [],
|
|
43
50
|
forceContext: [],
|
|
51
|
+
moduleName: "",
|
|
52
|
+
modules: new Map(),
|
|
44
53
|
};
|
|
45
54
|
let currentConfig = defaultCoreConfiguration;
|
|
46
55
|
export function setDefaultConfiguration(config) {
|
|
@@ -115,8 +115,8 @@ export class CustomPrintVisitor {
|
|
|
115
115
|
this.currentInterface = node;
|
|
116
116
|
this.pushIndent();
|
|
117
117
|
node.constructors.map(it => this.visit(it));
|
|
118
|
-
node.properties.
|
|
119
|
-
node.methods.
|
|
118
|
+
node.properties.map(it => this.visit(it));
|
|
119
|
+
node.methods.map(it => this.visit(it));
|
|
120
120
|
node.callables.map(it => this.visit(it));
|
|
121
121
|
let verbatim = getVerbatimDts(node);
|
|
122
122
|
if (verbatim) {
|
package/build/lib/src/idl.d.ts
CHANGED
|
@@ -280,6 +280,7 @@ export declare const IDLThisType: IDLPrimitiveType;
|
|
|
280
280
|
export declare const IDLDate: IDLPrimitiveType;
|
|
281
281
|
export declare const IDLBufferType: IDLPrimitiveType;
|
|
282
282
|
export declare const IDLUint8ArrayType: IDLContainerType;
|
|
283
|
+
export declare const IDLSerializerBuffer: IDLPrimitiveType;
|
|
283
284
|
export declare const IDLFunctionType: IDLPrimitiveType;
|
|
284
285
|
export declare const IDLLengthType: IDLPrimitiveType;
|
|
285
286
|
export declare const IDLCustomObjectType: IDLPrimitiveType;
|
|
@@ -294,8 +295,8 @@ export declare function linkParentBack<T extends IDLNode>(node: T): T;
|
|
|
294
295
|
export declare function getNamespacesPathFor(entry: IDLEntry): IDLNamespace[];
|
|
295
296
|
export declare function getFileFor(entry: IDLNode): IDLFile | undefined;
|
|
296
297
|
export declare function isEqualByQualifedName(a?: IDLEntry, b?: IDLEntry): boolean;
|
|
297
|
-
export declare function getPackageClause(entry:
|
|
298
|
-
export declare function getPackageName(
|
|
298
|
+
export declare function getPackageClause(entry: IDLNode): string[];
|
|
299
|
+
export declare function getPackageName(node: IDLNode): string;
|
|
299
300
|
export declare function isInPackage(entry: IDLEntry | IDLFile, packageName: string, exactMatch?: boolean): boolean;
|
|
300
301
|
export declare function getNamespaceName(a: IDLEntry): string;
|
|
301
302
|
export declare function getFQName(a: IDLEntry): string;
|
|
@@ -357,6 +358,7 @@ export declare function printCallback(idl: IDLCallback): PrintedLine[];
|
|
|
357
358
|
export declare function printScoped(idl: IDLEntry): PrintedLine[];
|
|
358
359
|
export declare function printInterface(idl: IDLInterface): PrintedLine[];
|
|
359
360
|
export declare function getSuperType(idl: IDLInterface): IDLReferenceType | undefined;
|
|
361
|
+
export declare function getSuperTypes(idl: IDLInterface): IDLReferenceType[] | undefined;
|
|
360
362
|
export declare function hasSuperType(idl: IDLInterface): boolean;
|
|
361
363
|
export declare function printEnumMember(idl: IDLEnumMember): PrintedLine[];
|
|
362
364
|
export declare function printEnum(idl: IDLEnum, skipInitializers: boolean): PrintedLine[];
|
package/build/lib/src/idl.js
CHANGED
|
@@ -326,6 +326,7 @@ export const IDLThisType = createPrimitiveType('this');
|
|
|
326
326
|
export const IDLDate = createPrimitiveType('date');
|
|
327
327
|
export const IDLBufferType = createPrimitiveType('buffer');
|
|
328
328
|
export const IDLUint8ArrayType = createContainerType('sequence', [IDLU8Type]);
|
|
329
|
+
export const IDLSerializerBuffer = createPrimitiveType('SerializerBuffer');
|
|
329
330
|
// Stub for IdlPeerLibrary
|
|
330
331
|
export const IDLFunctionType = createPrimitiveType('Function');
|
|
331
332
|
export const IDLLengthType = createPrimitiveType('Length');
|
|
@@ -391,8 +392,8 @@ export function getPackageClause(entry) {
|
|
|
391
392
|
let file = getFileFor(entry);
|
|
392
393
|
return (file === null || file === void 0 ? void 0 : file.packageClause) || [];
|
|
393
394
|
}
|
|
394
|
-
export function getPackageName(
|
|
395
|
-
return getPackageClause(
|
|
395
|
+
export function getPackageName(node) {
|
|
396
|
+
return getPackageClause(node).join(".");
|
|
396
397
|
}
|
|
397
398
|
export function isInPackage(entry, packageName, exactMatch = false) {
|
|
398
399
|
const entryPackageName = getPackageName(entry);
|
|
@@ -789,6 +790,16 @@ export function getSuperType(idl) {
|
|
|
789
790
|
const parent = idl.inheritance[0];
|
|
790
791
|
return parent && parent !== IDLTopType ? parent : undefined;
|
|
791
792
|
}
|
|
793
|
+
export function getSuperTypes(idl) {
|
|
794
|
+
if (!idl.inheritance)
|
|
795
|
+
return undefined;
|
|
796
|
+
if (idl.inheritance[0] == IDLTopType) {
|
|
797
|
+
return idl.inheritance.length == 1 ? undefined : idl.inheritance.slice(1);
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
return idl.inheritance.length == 0 ? undefined : idl.inheritance;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
792
803
|
export function hasSuperType(idl) {
|
|
793
804
|
return isDefined(getSuperType(idl));
|
|
794
805
|
}
|
|
@@ -16,6 +16,7 @@ export interface GenerateVisitor<T> {
|
|
|
16
16
|
}): T;
|
|
17
17
|
}
|
|
18
18
|
export declare function generate<T>(inputFiles: string[], outputDir: string, visitorFactory: (sourceFile: ts.SourceFile, program: ts.Program, compilerHost: ts.CompilerHost) => GenerateVisitor<T>, options: GenerateOptions<T>): void;
|
|
19
|
+
export declare const PACKAGE_IDLIZE_INTERNAL = "idlize.internal";
|
|
19
20
|
export declare function isInIdlize(entry: idl.IDLEntry | idl.IDLFile): boolean;
|
|
20
21
|
export declare function isInIdlizeInterop(entry: idl.IDLEntry | idl.IDLFile): boolean;
|
|
21
22
|
export declare function isInIdlizeInternal(entry: idl.IDLEntry | idl.IDLFile): boolean;
|
package/build/lib/src/idlize.js
CHANGED
|
@@ -124,14 +124,15 @@ export function generate(inputFiles, outputDir, visitorFactory, options) {
|
|
|
124
124
|
console.log("Generation completed.");
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
export const PACKAGE_IDLIZE_INTERNAL = "idlize.internal";
|
|
127
128
|
export function isInIdlize(entry) {
|
|
128
129
|
return idl.isInPackage(entry, "idlize");
|
|
129
130
|
}
|
|
130
131
|
export function isInIdlizeInterop(entry) {
|
|
131
|
-
return idl.isInPackage(entry,
|
|
132
|
+
return idl.isInPackage(entry, `${PACKAGE_IDLIZE_INTERNAL}.interop`);
|
|
132
133
|
}
|
|
133
134
|
export function isInIdlizeInternal(entry) {
|
|
134
|
-
return idl.isInPackage(entry,
|
|
135
|
+
return idl.isInPackage(entry, PACKAGE_IDLIZE_INTERNAL);
|
|
135
136
|
}
|
|
136
137
|
export function isInIdlizeStdlib(entry) {
|
|
137
138
|
return idl.isInPackage(entry, "idlize.stdlib");
|
package/build/lib/src/index.d.ts
CHANGED
|
@@ -37,8 +37,10 @@ export * from "./peer-generation/PeerClass";
|
|
|
37
37
|
export * from "./peer-generation/PeerMethod";
|
|
38
38
|
export * from "./peer-generation/BuilderClass";
|
|
39
39
|
export * from "./peer-generation/Materialized";
|
|
40
|
+
export * from "./peer-generation/modules";
|
|
40
41
|
export * from "./peer-generation/isMaterialized";
|
|
41
42
|
export * from "./peer-generation/isStructureType";
|
|
43
|
+
export * from "./peer-generation/isEnumType";
|
|
42
44
|
export * from "./peer-generation/unions";
|
|
43
45
|
export * from "./LanguageWriters";
|
|
44
46
|
export * from "./peer-generation/ReferenceResolver";
|
package/build/lib/src/index.js
CHANGED
|
@@ -51,8 +51,10 @@ export * from "./peer-generation/PeerClass";
|
|
|
51
51
|
export * from "./peer-generation/PeerMethod";
|
|
52
52
|
export * from "./peer-generation/BuilderClass";
|
|
53
53
|
export * from "./peer-generation/Materialized";
|
|
54
|
+
export * from "./peer-generation/modules";
|
|
54
55
|
export * from "./peer-generation/isMaterialized";
|
|
55
56
|
export * from "./peer-generation/isStructureType";
|
|
57
|
+
export * from "./peer-generation/isEnumType";
|
|
56
58
|
export * from "./peer-generation/unions";
|
|
57
59
|
export * from "./LanguageWriters";
|
|
58
60
|
export * from "./peer-generation/ReferenceResolver";
|
|
@@ -10253,7 +10253,6 @@ export declare const lenses: {
|
|
|
10253
10253
|
};
|
|
10254
10254
|
export declare class PeerLibrary implements LibraryInterface {
|
|
10255
10255
|
language: Language;
|
|
10256
|
-
libraryPackages: string[] | undefined;
|
|
10257
10256
|
private _cachedIdlLibrary?;
|
|
10258
10257
|
asIDLLibrary(): IDLLibrary;
|
|
10259
10258
|
get globals(): GlobalScopeDeclarations[];
|
|
@@ -10266,7 +10265,7 @@ export declare class PeerLibrary implements LibraryInterface {
|
|
|
10266
10265
|
get buildersToGenerate(): BuilderClass[];
|
|
10267
10266
|
readonly materializedClasses: Map<string, MaterializedClass>;
|
|
10268
10267
|
get materializedToGenerate(): MaterializedClass[];
|
|
10269
|
-
constructor(language: Language
|
|
10268
|
+
constructor(language: Language);
|
|
10270
10269
|
name: string;
|
|
10271
10270
|
readonly customComponentMethods: string[];
|
|
10272
10271
|
createLanguageWriter(language?: Language): LanguageWriter;
|
|
@@ -10283,7 +10282,6 @@ export declare class PeerLibrary implements LibraryInterface {
|
|
|
10283
10282
|
mapType(type: idl.IDLType): string;
|
|
10284
10283
|
resolveTypeReference(type: idl.IDLReferenceType): idl.IDLEntry | undefined;
|
|
10285
10284
|
private resolveTypeReferenceScoped;
|
|
10286
|
-
hasInLibrary(entry: idl.IDLEntry): boolean;
|
|
10287
10285
|
typeConvertor(param: string, type: idl.IDLType, isOptionalParam?: boolean): ArgConvertor;
|
|
10288
10286
|
declarationConvertor(param: string, type: idl.IDLReferenceType, declaration: idl.IDLEntry | undefined): ArgConvertor;
|
|
10289
10287
|
private customConvertor;
|
|
@@ -16,7 +16,7 @@ import { warn } from 'console';
|
|
|
16
16
|
import * as idl from '../idl';
|
|
17
17
|
import { Language } from '../Language';
|
|
18
18
|
import { createLanguageWriter } from '../LanguageWriters';
|
|
19
|
-
import { BufferConvertor, CallbackConvertor, DateConvertor, MapConvertor, PointerConvertor, TupleConvertor, TypeAliasConvertor, AggregateConvertor, StringConvertor, ClassConvertor, ArrayConvertor, FunctionConvertor, OptionConvertor, NumberConvertor, NumericConvertor, CustomTypeConvertor, UnionConvertor, MaterializedClassConvertor, BooleanConvertor, EnumConvertor, UndefinedConvertor, VoidConvertor, ImportTypeConvertor, InterfaceConvertor, BigIntToU64Convertor, } from "../LanguageWriters/ArgConvertors";
|
|
19
|
+
import { BufferConvertor, CallbackConvertor, DateConvertor, MapConvertor, PointerConvertor, TupleConvertor, TypeAliasConvertor, AggregateConvertor, StringConvertor, ClassConvertor, ArrayConvertor, FunctionConvertor, OptionConvertor, NumberConvertor, NumericConvertor, CustomTypeConvertor, UnionConvertor, MaterializedClassConvertor, BooleanConvertor, EnumConvertor, UndefinedConvertor, VoidConvertor, ImportTypeConvertor, InterfaceConvertor, BigIntToU64Convertor, ObjectConvertor, } from "../LanguageWriters/ArgConvertors";
|
|
20
20
|
import { CppNameConvertor } from '../LanguageWriters/convertors/CppConvertors';
|
|
21
21
|
import { CJTypeNameConvertor } from '../LanguageWriters/convertors/CJConvertors';
|
|
22
22
|
import { CppConvertor } from '../LanguageWriters/convertors/CppConvertors';
|
|
@@ -29,6 +29,7 @@ import { LayoutManager } from './LayoutManager';
|
|
|
29
29
|
import { lib, query } from '../library';
|
|
30
30
|
import { isMaterialized } from './isMaterialized';
|
|
31
31
|
import { isInIdlizeInternal } from '../idlize';
|
|
32
|
+
import { isInCurrentModule } from './modules';
|
|
32
33
|
export const lenses = {
|
|
33
34
|
globals: lib.lens(lib.select.files())
|
|
34
35
|
.pipe(lib.select.nodes())
|
|
@@ -42,6 +43,8 @@ export const lenses = {
|
|
|
42
43
|
};
|
|
43
44
|
const next = queue.pop();
|
|
44
45
|
next.forEach(node => {
|
|
46
|
+
if (!isInCurrentModule(node))
|
|
47
|
+
return;
|
|
45
48
|
if (idl.isNamespace(node)) {
|
|
46
49
|
queue.push(node.members);
|
|
47
50
|
}
|
|
@@ -69,7 +72,9 @@ export class PeerLibrary {
|
|
|
69
72
|
};
|
|
70
73
|
return this._cachedIdlLibrary;
|
|
71
74
|
}
|
|
72
|
-
get globals() {
|
|
75
|
+
get globals() {
|
|
76
|
+
return query(this.asIDLLibrary(), lenses.globals);
|
|
77
|
+
}
|
|
73
78
|
initSyntheticEntries(file) {
|
|
74
79
|
this._syntheticFile = file;
|
|
75
80
|
}
|
|
@@ -82,9 +87,8 @@ export class PeerLibrary {
|
|
|
82
87
|
get materializedToGenerate() {
|
|
83
88
|
return Array.from(this.materializedClasses.values()).filter(it => it.needBeGenerated);
|
|
84
89
|
}
|
|
85
|
-
constructor(language
|
|
90
|
+
constructor(language) {
|
|
86
91
|
this.language = language;
|
|
87
|
-
this.libraryPackages = libraryPackages;
|
|
88
92
|
this.layout = LayoutManager.Empty();
|
|
89
93
|
this._syntheticFile = idl.createFile([]);
|
|
90
94
|
this.files = [];
|
|
@@ -209,10 +213,6 @@ export class PeerLibrary {
|
|
|
209
213
|
} // end of block to remove
|
|
210
214
|
return undefined; // empty result
|
|
211
215
|
}
|
|
212
|
-
hasInLibrary(entry) {
|
|
213
|
-
var _a, _b;
|
|
214
|
-
return !((_a = this.libraryPackages) === null || _a === void 0 ? void 0 : _a.length) || ((_b = this.libraryPackages) === null || _b === void 0 ? void 0 : _b.includes(idl.getPackageName(entry)));
|
|
215
|
-
}
|
|
216
216
|
typeConvertor(param, type, isOptionalParam = false) {
|
|
217
217
|
if (isOptionalParam) {
|
|
218
218
|
return new OptionConvertor(this, param, idl.maybeUnwrapOptionalType(type));
|
|
@@ -234,6 +234,7 @@ export class PeerLibrary {
|
|
|
234
234
|
case idl.IDLF32Type: return new NumericConvertor(param, type);
|
|
235
235
|
case idl.IDLF64Type: return new NumericConvertor(param, type);
|
|
236
236
|
case idl.IDLBigintType: return new BigIntToU64Convertor(param);
|
|
237
|
+
case idl.IDLSerializerBuffer: new PointerConvertor(param);
|
|
237
238
|
case idl.IDLPointerType: return new PointerConvertor(param);
|
|
238
239
|
case idl.IDLBufferType: return new BufferConvertor(param);
|
|
239
240
|
case idl.IDLBooleanType: return new BooleanConvertor(param);
|
|
@@ -242,7 +243,7 @@ export class PeerLibrary {
|
|
|
242
243
|
case idl.IDLUndefinedType: return new UndefinedConvertor(param);
|
|
243
244
|
case idl.IDLVoidType: return new VoidConvertor(param);
|
|
244
245
|
case idl.IDLUnknownType:
|
|
245
|
-
case idl.IDLAnyType: return new
|
|
246
|
+
case idl.IDLAnyType: return new ObjectConvertor(param);
|
|
246
247
|
case idl.IDLDate: return new DateConvertor(param);
|
|
247
248
|
default: throw new Error(`Unconverted primitive ${idl.DebugUtils.debugPrintType(type)}`);
|
|
248
249
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReferenceResolver } from './ReferenceResolver';
|
|
2
|
+
import { IDLType } from "../idl";
|
|
3
|
+
export declare function isEnumType(type: IDLType, resolver: ReferenceResolver): boolean;
|
|
4
|
+
export declare function isStringEnumType(type: IDLType, resolver: ReferenceResolver): boolean;
|
|
5
|
+
//# sourceMappingURL=isEnumType.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 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 { isReferenceType, isEnum, isStringEnum } from "../idl";
|
|
16
|
+
export function isEnumType(type, resolver) {
|
|
17
|
+
return toEnum(type, resolver) != undefined;
|
|
18
|
+
}
|
|
19
|
+
export function isStringEnumType(type, resolver) {
|
|
20
|
+
const enumNode = toEnum(type, resolver);
|
|
21
|
+
return enumNode ? isStringEnum(enumNode) : false;
|
|
22
|
+
}
|
|
23
|
+
function toEnum(type, resolver) {
|
|
24
|
+
if (!isReferenceType(type))
|
|
25
|
+
return undefined;
|
|
26
|
+
const resolved = resolver.resolveTypeReference(type);
|
|
27
|
+
return resolved && isEnum(resolved) ? resolved : undefined;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=isEnumType.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModuleConfiguration } from "../config";
|
|
2
|
+
import * as idl from "../idl";
|
|
3
|
+
export declare function isInModule(node: idl.IDLNode, module: ModuleConfiguration): boolean;
|
|
4
|
+
export declare function isInModule(packageName: string, module: ModuleConfiguration): boolean;
|
|
5
|
+
export declare function getModuleFor(node: idl.IDLNode): ModuleConfiguration;
|
|
6
|
+
export declare function getModuleFor(packageName: string): ModuleConfiguration;
|
|
7
|
+
export declare function currentModule(): ModuleConfiguration;
|
|
8
|
+
export declare function isInCurrentModule(node: idl.IDLNode): boolean;
|
|
9
|
+
export declare function isInCurrentModule(packageName: string): boolean;
|
|
10
|
+
//# sourceMappingURL=modules.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { generatorConfiguration } from "../config";
|
|
2
|
+
import * as idl from "../idl";
|
|
3
|
+
export function isInModule(nodeOrPackage, module) {
|
|
4
|
+
if (typeof nodeOrPackage === 'object')
|
|
5
|
+
return isInModule(idl.getPackageName(nodeOrPackage), module);
|
|
6
|
+
return module.packages.some(modulePackage => nodeOrPackage.startsWith(modulePackage));
|
|
7
|
+
}
|
|
8
|
+
export function getModuleFor(nodeOrPackage) {
|
|
9
|
+
if (typeof nodeOrPackage === "object")
|
|
10
|
+
return getModuleFor(idl.getPackageName(nodeOrPackage));
|
|
11
|
+
const packageName = nodeOrPackage;
|
|
12
|
+
const config = generatorConfiguration();
|
|
13
|
+
const applicableModules = [...config.modules.values()].filter(module => isInModule(packageName, module));
|
|
14
|
+
if (applicableModules.length === 0) {
|
|
15
|
+
if (nodeOrPackage === '') {
|
|
16
|
+
console.error("WARNING: use current module for empty package");
|
|
17
|
+
return currentModule();
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`Package ${packageName} is not listed in any module`);
|
|
20
|
+
}
|
|
21
|
+
if (applicableModules.length > 1)
|
|
22
|
+
throw new Error(`Package ${packageName} listed in ${applicableModules.length} packages: ${applicableModules.map(it => it.name).join(", ")}`);
|
|
23
|
+
return applicableModules[0];
|
|
24
|
+
}
|
|
25
|
+
export function currentModule() {
|
|
26
|
+
const conf = generatorConfiguration();
|
|
27
|
+
const result = conf.modules.get(conf.moduleName);
|
|
28
|
+
if (!result)
|
|
29
|
+
throw new Error(`Can not determine current module configuration ${conf.moduleName}`);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
export function isInCurrentModule(nodeOrPackage) {
|
|
33
|
+
if (typeof nodeOrPackage === 'string')
|
|
34
|
+
return isInModule(nodeOrPackage, currentModule());
|
|
35
|
+
else
|
|
36
|
+
return isInModule(nodeOrPackage, currentModule());
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=modules.js.map
|
package/build/lib/src/util.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export declare function className(node: ts.ClassDeclaration | ts.InterfaceDeclar
|
|
|
67
67
|
*/
|
|
68
68
|
export declare function nameEnumValues(enumTarget: ts.EnumDeclaration): string[];
|
|
69
69
|
export declare function groupBy<K, V>(values: V[], selector: (value: V) => K): Map<K, V[]>;
|
|
70
|
+
export declare function groupByIndexed<K, V>(values: V[], selector: (value: V) => K): Map<K, [V, number][]>;
|
|
70
71
|
export declare function removeExt(filename: string): string;
|
|
71
72
|
export declare function warn(message: string): void;
|
|
72
73
|
export declare function hashCodeFromString(value: string): number;
|
package/build/lib/src/util.js
CHANGED
|
@@ -569,6 +569,12 @@ export function groupBy(values, selector) {
|
|
|
569
569
|
});
|
|
570
570
|
return map;
|
|
571
571
|
}
|
|
572
|
+
export function groupByIndexed(values, selector) {
|
|
573
|
+
const map = new Map();
|
|
574
|
+
values.forEach((it, index) => getOrPut(map, selector(it), () => [])
|
|
575
|
+
.push([it, index]));
|
|
576
|
+
return map;
|
|
577
|
+
}
|
|
572
578
|
export function removeExt(filename) {
|
|
573
579
|
return filename.replaceAll(path.extname(filename), '');
|
|
574
580
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlizer/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "build/lib/src/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"keywords": [],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@koalaui/interop": "1.5.
|
|
37
|
+
"@koalaui/interop": "1.5.12",
|
|
38
38
|
"typescript": "4.9.5",
|
|
39
39
|
"@types/node": "^18.0.0"
|
|
40
40
|
},
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 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
|
-
function isObject(i) {
|
|
16
|
-
if (typeof i !== 'object')
|
|
17
|
-
return false;
|
|
18
|
-
if (Array.isArray(i))
|
|
19
|
-
return false;
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
export function deepMergeConfig(defaults, custom) {
|
|
23
|
-
if (custom === undefined)
|
|
24
|
-
return defaults;
|
|
25
|
-
const result = Object.assign({}, defaults);
|
|
26
|
-
for (const key in custom) {
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(custom, key)) {
|
|
28
|
-
const defaultValue = result[key];
|
|
29
|
-
const customValue = custom[key];
|
|
30
|
-
if (isObject(defaultValue) && isObject(customValue)) {
|
|
31
|
-
Object.assign(result, { [key]: deepMergeConfig(defaultValue, customValue) });
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
if (isObject(defaultValue))
|
|
35
|
-
throw new Error("Replacing default object value with custom non-object");
|
|
36
|
-
Object.assign(result, { [key]: customValue });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=configMerge.js.map
|
package/webidl2.js/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014 Robin Berjon
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|