@idlizer/core 2.1.0 → 2.1.5
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 +15 -2
- package/build/lib/src/LanguageWriters/ArgConvertors.js +93 -33
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +34 -14
- package/build/lib/src/LanguageWriters/LanguageWriter.js +29 -52
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.d.ts +2 -1
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +16 -5
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +4 -2
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +25 -15
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +7 -18
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.d.ts +4 -2
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +13 -3
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.d.ts +2 -1
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +24 -4
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.d.ts +4 -2
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +49 -29
- package/build/lib/src/LanguageWriters/nameConvertor.d.ts +3 -1
- package/build/lib/src/LanguageWriters/nameConvertor.js +5 -1
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +21 -10
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +56 -65
- package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.d.ts +4 -1
- package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.js +1 -1
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +16 -10
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +18 -27
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +14 -9
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +18 -21
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +11 -7
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +42 -18
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +14 -6
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +49 -44
- package/build/lib/src/LibraryInterface.d.ts +1 -5
- package/build/lib/src/config.d.ts +1029 -66
- package/build/lib/src/config.js +15 -2
- package/build/lib/src/configDescriber.d.ts +30 -3
- package/build/lib/src/configDescriber.js +99 -1
- package/build/lib/src/from-idl/DtsPrinter.js +32 -20
- package/build/lib/src/from-idl/IDLLinter.d.ts +40 -7
- package/build/lib/src/from-idl/IDLLinter.js +211 -25
- package/build/lib/src/from-idl/common.js +1 -1
- package/build/lib/src/from-idl/deserialize.d.ts +4 -1
- package/build/lib/src/from-idl/deserialize.js +434 -346
- package/build/lib/src/idl.d.ts +28 -18
- package/build/lib/src/idl.js +376 -111
- package/build/lib/src/idlize.d.ts +3 -1
- package/build/lib/src/idlize.js +85 -28
- package/build/lib/src/index.d.ts +6 -3
- package/build/lib/src/index.js +5 -2
- package/build/lib/src/options.d.ts +1 -1
- package/build/lib/src/peer-generation/BuilderClass.d.ts +0 -2
- package/build/lib/src/peer-generation/BuilderClass.js +0 -8
- package/build/lib/src/peer-generation/LayoutManager.d.ts +10 -3
- package/build/lib/src/peer-generation/LayoutManager.js +3 -2
- package/build/lib/src/peer-generation/Materialized.d.ts +1 -1
- package/build/lib/src/peer-generation/Materialized.js +2 -2
- package/build/lib/src/peer-generation/PeerClass.d.ts +3 -8
- package/build/lib/src/peer-generation/PeerClass.js +0 -1
- package/build/lib/src/peer-generation/PeerFile.d.ts +1 -2
- package/build/lib/src/peer-generation/PeerFile.js +1 -1
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +12 -9
- package/build/lib/src/peer-generation/PeerLibrary.js +136 -71
- package/build/lib/src/peer-generation/ReferenceResolver.d.ts +1 -1
- package/build/lib/src/peer-generation/ReferenceResolver.js +2 -2
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.d.ts +1 -0
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +6 -2
- package/build/lib/src/peer-generation/idl/common.d.ts +2 -1
- package/build/lib/src/peer-generation/idl/common.js +13 -2
- 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/isMaterialized.js +25 -8
- 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/peer-generation/unions.d.ts +3 -2
- package/build/lib/src/peer-generation/unions.js +6 -2
- package/build/lib/src/resolveNamedNode.d.ts +3 -0
- package/build/lib/src/resolveNamedNode.js +105 -0
- package/build/lib/src/util.d.ts +7 -0
- package/build/lib/src/util.js +39 -0
- package/build/lib/src/visitor.d.ts +0 -1
- package/build/lib/src/visitor.js +1 -7
- package/package.json +2 -2
- package/webidl2.js/dist/webidl2.js +35 -7
- package/build/lib/src/configMerge.d.ts +0 -2
- package/build/lib/src/configMerge.js +0 -42
|
@@ -21,6 +21,10 @@ export class UnionFlattener {
|
|
|
21
21
|
constructor(resolver) {
|
|
22
22
|
this.resolver = resolver;
|
|
23
23
|
}
|
|
24
|
+
convertImport(type) {
|
|
25
|
+
console.warn("Imports are not implemented yet");
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
24
28
|
convertUnion(type) {
|
|
25
29
|
return type.types.flatMap(it => convertType(this, it));
|
|
26
30
|
}
|
|
@@ -34,7 +38,7 @@ export class UnionFlattener {
|
|
|
34
38
|
convertContainer(type) {
|
|
35
39
|
return [type];
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
convertTypeReferenceAsImport(type, importClause) {
|
|
38
42
|
return [type];
|
|
39
43
|
}
|
|
40
44
|
convertPrimitiveType(type) {
|
|
@@ -111,8 +115,8 @@ export class UnionRuntimeTypeChecker {
|
|
|
111
115
|
}
|
|
112
116
|
}
|
|
113
117
|
export function flattenUnionType(library, type) {
|
|
114
|
-
const unionFlattener = new UnionFlattener(library);
|
|
115
118
|
if (isUnionType(type)) {
|
|
119
|
+
const unionFlattener = new UnionFlattener(library);
|
|
116
120
|
const allTypes = type.types.flatMap(it => convertType(unionFlattener, it));
|
|
117
121
|
const uniqueTypes = new Set(allTypes);
|
|
118
122
|
return uniqueTypes.size === allTypes.length ? type : collapseTypes(Array.from(uniqueTypes));
|
|
@@ -0,0 +1,105 @@
|
|
|
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 { isReferenceType, hasExtAttribute, IDLExtendedAttributes } from "./idl";
|
|
16
|
+
import { isFile, isNamedNode, isNamespace, isEnum, isInterface, isImport } from "./idl";
|
|
17
|
+
export function resolveNamedNode(target, pov, corpus) {
|
|
18
|
+
let result;
|
|
19
|
+
let povScope = [];
|
|
20
|
+
while (pov) {
|
|
21
|
+
if (isFile(pov)) {
|
|
22
|
+
if (result = resolveDownFromFile(target, pov, corpus))
|
|
23
|
+
return result;
|
|
24
|
+
const importUsings = pov.entries.filter(it => isImport(it) && !it.name).map(it => it);
|
|
25
|
+
for (const importUsing of importUsings)
|
|
26
|
+
if (result = resolveDownFromRoot([...importUsing.clause, ...target], corpus))
|
|
27
|
+
return result;
|
|
28
|
+
povScope = pov.packageClause.slice();
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (result = resolveDownFromNode(target, pov, false, corpus))
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
pov = pov.parent;
|
|
36
|
+
}
|
|
37
|
+
for (;;) {
|
|
38
|
+
if (result = resolveDownFromRoot([...povScope, ...target], corpus))
|
|
39
|
+
return result;
|
|
40
|
+
if (povScope.length)
|
|
41
|
+
povScope.pop();
|
|
42
|
+
else
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
function resolveDownFromNode(target, pov, withSelf, corpus) {
|
|
48
|
+
if (withSelf && isNamedNode(pov)) {
|
|
49
|
+
if (isReferenceType(pov) || !pov.name.length)
|
|
50
|
+
return undefined;
|
|
51
|
+
let nameMatched = target[0] === pov.name;
|
|
52
|
+
if (!nameMatched)
|
|
53
|
+
nameMatched = target[0] === "default" && hasExtAttribute(pov, IDLExtendedAttributes.DefaultExport);
|
|
54
|
+
if (!nameMatched)
|
|
55
|
+
return undefined;
|
|
56
|
+
target = target.slice(1);
|
|
57
|
+
if (isImport(pov)) {
|
|
58
|
+
return resolveDownFromRoot([...pov.clause, ...target], corpus);
|
|
59
|
+
}
|
|
60
|
+
if (!target.length)
|
|
61
|
+
return pov;
|
|
62
|
+
}
|
|
63
|
+
let candidates;
|
|
64
|
+
if (isNamespace(pov))
|
|
65
|
+
candidates = pov.members;
|
|
66
|
+
else if (isEnum(pov))
|
|
67
|
+
candidates = pov.elements;
|
|
68
|
+
else if (isInterface(pov))
|
|
69
|
+
candidates = pov.constants;
|
|
70
|
+
else
|
|
71
|
+
return undefined;
|
|
72
|
+
let result;
|
|
73
|
+
for (const candidate of candidates) {
|
|
74
|
+
if (result = resolveDownFromNode(target, candidate, true, corpus))
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
function resolveDownFromFile(target, pov, corpus) {
|
|
80
|
+
let result;
|
|
81
|
+
for (const candidate of pov.entries) {
|
|
82
|
+
if (result = resolveDownFromNode(target, candidate, true, corpus))
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
function resolveDownFromRoot(target, corpus) {
|
|
88
|
+
let result;
|
|
89
|
+
for (const file of corpus) {
|
|
90
|
+
if (file.packageClause.length >= target.length)
|
|
91
|
+
continue;
|
|
92
|
+
let match = true;
|
|
93
|
+
for (let index = 0; index < file.packageClause.length; ++index)
|
|
94
|
+
if (file.packageClause[index] !== target[index]) {
|
|
95
|
+
match = false;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (!match)
|
|
99
|
+
continue;
|
|
100
|
+
if (result = resolveDownFromFile(target.slice(file.packageClause.length), file, corpus))
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=resolveNamedNode.js.map
|
package/build/lib/src/util.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare function snakeCaseToCamelCase(input: string, tailToLowerCase?: bo
|
|
|
53
53
|
export declare function toCamelCase(input: string): string;
|
|
54
54
|
export declare function isUpperCase(s: string): boolean;
|
|
55
55
|
export declare function camelCaseToUpperSnakeCase(input: string): string;
|
|
56
|
+
export declare function snakeToLowCamelNode(node: idl.IDLEntry): string;
|
|
56
57
|
export declare function renameDtsToPeer(fileName: string, language: Language, withFileExtension?: boolean): string;
|
|
57
58
|
export declare function renameDtsToComponent(fileName: string, language: Language, withFileExtension?: boolean): string;
|
|
58
59
|
export declare function renameDtsToInterfaces(fileName: string, language: Language, withFileExtension?: boolean): string;
|
|
@@ -67,6 +68,7 @@ export declare function className(node: ts.ClassDeclaration | ts.InterfaceDeclar
|
|
|
67
68
|
*/
|
|
68
69
|
export declare function nameEnumValues(enumTarget: ts.EnumDeclaration): string[];
|
|
69
70
|
export declare function groupBy<K, V>(values: V[], selector: (value: V) => K): Map<K, V[]>;
|
|
71
|
+
export declare function groupByIndexed<K, V>(values: V[], selector: (value: V) => K): Map<K, [V, number][]>;
|
|
70
72
|
export declare function removeExt(filename: string): string;
|
|
71
73
|
export declare function warn(message: string): void;
|
|
72
74
|
export declare function hashCodeFromString(value: string): number;
|
|
@@ -83,4 +85,9 @@ export declare class Lazy<T> {
|
|
|
83
85
|
export declare function lazy<T>(factory: () => T): Lazy<T>;
|
|
84
86
|
export declare function isInNamespace(node: idl.IDLEntry): boolean;
|
|
85
87
|
export declare function rightmostIndexOf<T>(array: T[], predicate: (value: T) => boolean): number;
|
|
88
|
+
type StringProperties<T> = {
|
|
89
|
+
[Property in keyof T as (T[Property] extends string ? Property : never)]: T[Property];
|
|
90
|
+
};
|
|
91
|
+
export declare function sorted<T, N extends keyof StringProperties<T>>(array: T[], key: ((value: T) => string) | N): T[];
|
|
92
|
+
export {};
|
|
86
93
|
//# sourceMappingURL=util.d.ts.map
|
package/build/lib/src/util.js
CHANGED
|
@@ -300,6 +300,9 @@ export function identName(node) {
|
|
|
300
300
|
return `void`;
|
|
301
301
|
if (node.kind == ts.SyntaxKind.UndefinedKeyword)
|
|
302
302
|
return `undefined`;
|
|
303
|
+
if (ts.isThisTypeNode(node)) {
|
|
304
|
+
return 'this';
|
|
305
|
+
}
|
|
303
306
|
if (ts.isVariableDeclaration(node)) {
|
|
304
307
|
return identString(node.name);
|
|
305
308
|
}
|
|
@@ -340,6 +343,9 @@ export function identName(node) {
|
|
|
340
343
|
if (ts.isComputedPropertyName(node)) {
|
|
341
344
|
return identString(node);
|
|
342
345
|
}
|
|
346
|
+
if (ts.isExportAssignment(node)) {
|
|
347
|
+
return node.expression.getText();
|
|
348
|
+
}
|
|
343
349
|
if (ts.isUnionTypeNode(node)) {
|
|
344
350
|
return `UnionType`;
|
|
345
351
|
}
|
|
@@ -469,6 +475,22 @@ export function camelCaseToUpperSnakeCase(input) {
|
|
|
469
475
|
.map(s => toUpperSnakeCase(s))
|
|
470
476
|
.join('_');
|
|
471
477
|
}
|
|
478
|
+
export function snakeToLowCamelNode(node) {
|
|
479
|
+
if (!node.fileName) {
|
|
480
|
+
throw new Error("Invalid Convert");
|
|
481
|
+
}
|
|
482
|
+
const classname = path.basename(node.fileName).replace(".idl", "").replace(".d.ts", "");
|
|
483
|
+
return classname
|
|
484
|
+
.split('_')
|
|
485
|
+
.filter(word => word !== '')
|
|
486
|
+
.map((word, index) => {
|
|
487
|
+
if (index === 0) {
|
|
488
|
+
return word.toLowerCase();
|
|
489
|
+
}
|
|
490
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
491
|
+
})
|
|
492
|
+
.join('');
|
|
493
|
+
}
|
|
472
494
|
export function renameDtsToPeer(fileName, language, withFileExtension = true) {
|
|
473
495
|
const renamed = "Ark"
|
|
474
496
|
.concat(snakeCaseToCamelCase(fileName))
|
|
@@ -569,6 +591,12 @@ export function groupBy(values, selector) {
|
|
|
569
591
|
});
|
|
570
592
|
return map;
|
|
571
593
|
}
|
|
594
|
+
export function groupByIndexed(values, selector) {
|
|
595
|
+
const map = new Map();
|
|
596
|
+
values.forEach((it, index) => getOrPut(map, selector(it), () => [])
|
|
597
|
+
.push([it, index]));
|
|
598
|
+
return map;
|
|
599
|
+
}
|
|
572
600
|
export function removeExt(filename) {
|
|
573
601
|
return filename.replaceAll(path.extname(filename), '');
|
|
574
602
|
}
|
|
@@ -648,4 +676,15 @@ export function rightmostIndexOf(array, predicate) {
|
|
|
648
676
|
});
|
|
649
677
|
return result;
|
|
650
678
|
}
|
|
679
|
+
// sort array using external key function or internal string property
|
|
680
|
+
export function sorted(array, key) {
|
|
681
|
+
const comparator = new Intl.Collator();
|
|
682
|
+
if (typeof key === "function") {
|
|
683
|
+
return array.map(it => { return { sortKey: key(it), value: it }; })
|
|
684
|
+
.sort((a, b) => comparator.compare(a.sortKey, b.sortKey))
|
|
685
|
+
.map(it => it.value);
|
|
686
|
+
}
|
|
687
|
+
return array.map(it => it)
|
|
688
|
+
.sort((a, b) => comparator.compare(a[key], b[key]));
|
|
689
|
+
}
|
|
651
690
|
//# sourceMappingURL=util.js.map
|
|
@@ -30,7 +30,6 @@ export declare class IDLDependencyCollector implements IDLConverter<idl.IDLNode[
|
|
|
30
30
|
visitPrimitiveType(): idl.IDLNode[];
|
|
31
31
|
visitNamespace(decl: idl.IDLNamespace): idl.IDLNode[];
|
|
32
32
|
visitInterface(decl: idl.IDLInterface): idl.IDLNode[];
|
|
33
|
-
protected visitSupertype(type: idl.IDLType | idl.IDLInterface): idl.IDLNode[];
|
|
34
33
|
visitEnum(): idl.IDLNode[];
|
|
35
34
|
visitTypedef(decl: idl.IDLTypedef): idl.IDLNode[];
|
|
36
35
|
visitCallback(decl: idl.IDLCallback): idl.IDLNode[];
|
package/build/lib/src/visitor.js
CHANGED
|
@@ -90,7 +90,7 @@ export class IDLDependencyCollector {
|
|
|
90
90
|
return [
|
|
91
91
|
...decl.inheritance
|
|
92
92
|
.filter(it => it !== idl.IDLTopType)
|
|
93
|
-
.flatMap(it => this.
|
|
93
|
+
.flatMap(it => this.walk(it)),
|
|
94
94
|
...decl.properties
|
|
95
95
|
.filter(it => !it.isStatic)
|
|
96
96
|
.flatMap(it => this.walk(it.type)),
|
|
@@ -101,12 +101,6 @@ export class IDLDependencyCollector {
|
|
|
101
101
|
])
|
|
102
102
|
];
|
|
103
103
|
}
|
|
104
|
-
visitSupertype(type) {
|
|
105
|
-
if (idl.isInterface(type)) {
|
|
106
|
-
return this.walk(idl.createReferenceType(type));
|
|
107
|
-
}
|
|
108
|
-
return this.walk(type);
|
|
109
|
-
}
|
|
110
104
|
visitEnum() {
|
|
111
105
|
return [];
|
|
112
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlizer/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
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.15",
|
|
38
38
|
"typescript": "4.9.5",
|
|
39
39
|
"@types/node": "^18.0.0"
|
|
40
40
|
},
|
|
@@ -1661,7 +1661,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1661
1661
|
* @param {string} identifier
|
|
1662
1662
|
*/
|
|
1663
1663
|
function unescape(identifier) {
|
|
1664
|
-
return identifier
|
|
1664
|
+
return identifier;
|
|
1665
1665
|
}
|
|
1666
1666
|
|
|
1667
1667
|
/** @typedef {'callbackInterface'|'dictionary'|'interface'|'mixin'|'namespace'} ExtendableInterfaces */
|
|
@@ -1829,13 +1829,13 @@ function return_type(tokeniser, typeName) {
|
|
|
1829
1829
|
typ.tokens.closeRT = closeRT;
|
|
1830
1830
|
return typ;
|
|
1831
1831
|
} while (false);
|
|
1832
|
-
const typ =
|
|
1832
|
+
const typ = Type.parse(tokeniser, typeName || "return-type");
|
|
1833
1833
|
if (typ) {
|
|
1834
1834
|
return typ;
|
|
1835
1835
|
}
|
|
1836
1836
|
const voidToken = tokeniser.consume("void");
|
|
1837
1837
|
if (voidToken) {
|
|
1838
|
-
const ret = new
|
|
1838
|
+
const ret = new Type({
|
|
1839
1839
|
source: tokeniser.source,
|
|
1840
1840
|
tokens: { base: voidToken },
|
|
1841
1841
|
});
|
|
@@ -3109,9 +3109,8 @@ function generic_type(tokeniser, typeName) {
|
|
|
3109
3109
|
tokeniser.error(`No opening bracket after ${base.value}`);
|
|
3110
3110
|
switch (base.value) {
|
|
3111
3111
|
case "Promise": {
|
|
3112
|
-
if (tokeniser.probe("["))
|
|
3113
|
-
tokeniser.error("Promise type cannot have extended attribute");
|
|
3114
3112
|
const subtype =
|
|
3113
|
+
(0,_helpers_js__WEBPACK_IMPORTED_MODULE_1__.type_with_extended_attributes)(tokeniser, typeName) ||
|
|
3115
3114
|
(0,_helpers_js__WEBPACK_IMPORTED_MODULE_1__.return_type)(tokeniser, typeName) ||
|
|
3116
3115
|
tokeniser.error("Missing Promise subtype");
|
|
3117
3116
|
ret.subtype.push(subtype);
|
|
@@ -3757,6 +3756,7 @@ function tokenise(str) {
|
|
|
3757
3756
|
trivia,
|
|
3758
3757
|
line,
|
|
3759
3758
|
index,
|
|
3759
|
+
position: lastCharIndex,
|
|
3760
3760
|
});
|
|
3761
3761
|
trivia = "";
|
|
3762
3762
|
lastCharIndex += punctuation.length;
|
|
@@ -3783,6 +3783,7 @@ function tokenise(str) {
|
|
|
3783
3783
|
trivia,
|
|
3784
3784
|
line,
|
|
3785
3785
|
index,
|
|
3786
|
+
position: lastCharIndex,
|
|
3786
3787
|
});
|
|
3787
3788
|
|
|
3788
3789
|
return tokens;
|
|
@@ -3797,7 +3798,14 @@ function tokenise(str) {
|
|
|
3797
3798
|
re.lastIndex = lastCharIndex;
|
|
3798
3799
|
const result = re.exec(str);
|
|
3799
3800
|
if (result) {
|
|
3800
|
-
tokens.push({
|
|
3801
|
+
tokens.push({
|
|
3802
|
+
type,
|
|
3803
|
+
value: result[0],
|
|
3804
|
+
trivia,
|
|
3805
|
+
line,
|
|
3806
|
+
index,
|
|
3807
|
+
position: lastCharIndex,
|
|
3808
|
+
});
|
|
3801
3809
|
if (!noFlushTrivia) {
|
|
3802
3810
|
trivia = "";
|
|
3803
3811
|
}
|
|
@@ -4251,7 +4259,8 @@ function* checkInterfaceMemberDuplication(defs, i) {
|
|
|
4251
4259
|
|
|
4252
4260
|
__webpack_require__.r(__webpack_exports__);
|
|
4253
4261
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4254
|
-
/* harmony export */ parse: () => (/* binding */ parse)
|
|
4262
|
+
/* harmony export */ parse: () => (/* binding */ parse),
|
|
4263
|
+
/* harmony export */ parseType: () => (/* binding */ parseType)
|
|
4255
4264
|
/* harmony export */ });
|
|
4256
4265
|
/* harmony import */ var _tokeniser_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tokeniser.js */ "./lib/tokeniser.js");
|
|
4257
4266
|
/* harmony import */ var _productions_enum_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./productions/enum.js */ "./lib/productions/enum.js");
|
|
@@ -4367,6 +4376,20 @@ function parse(str, options = {}) {
|
|
|
4367
4376
|
return parseByTokens(tokeniser, options);
|
|
4368
4377
|
}
|
|
4369
4378
|
|
|
4379
|
+
/**
|
|
4380
|
+
* @param {string} str
|
|
4381
|
+
* @param {string} fileName
|
|
4382
|
+
*/
|
|
4383
|
+
function parseType(str, fileName) {
|
|
4384
|
+
const tokeniser = new _tokeniser_js__WEBPACK_IMPORTED_MODULE_0__.Tokeniser(str);
|
|
4385
|
+
// @ts-ignore (See Tokeniser.source in supplement.d.ts)
|
|
4386
|
+
tokeniser.source.name = fileName;
|
|
4387
|
+
return (
|
|
4388
|
+
(0,_productions_helpers_js__WEBPACK_IMPORTED_MODULE_15__.type_with_extended_attributes)(tokeniser, "type") ||
|
|
4389
|
+
(0,_productions_helpers_js__WEBPACK_IMPORTED_MODULE_15__.return_type)(tokeniser, "return-type")
|
|
4390
|
+
);
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4370
4393
|
|
|
4371
4394
|
/***/ }),
|
|
4372
4395
|
|
|
@@ -4516,6 +4539,8 @@ function write(ast, { templates: ts = templates } = {}) {
|
|
|
4516
4539
|
/******/
|
|
4517
4540
|
/************************************************************************/
|
|
4518
4541
|
var __webpack_exports__ = {};
|
|
4542
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
4543
|
+
(() => {
|
|
4519
4544
|
/*!******************!*\
|
|
4520
4545
|
!*** ./index.js ***!
|
|
4521
4546
|
\******************/
|
|
@@ -4523,6 +4548,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4523
4548
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4524
4549
|
/* harmony export */ WebIDLParseError: () => (/* reexport safe */ _lib_tokeniser_js__WEBPACK_IMPORTED_MODULE_3__.WebIDLParseError),
|
|
4525
4550
|
/* harmony export */ parse: () => (/* reexport safe */ _lib_webidl2_js__WEBPACK_IMPORTED_MODULE_0__.parse),
|
|
4551
|
+
/* harmony export */ parseType: () => (/* reexport safe */ _lib_webidl2_js__WEBPACK_IMPORTED_MODULE_0__.parseType),
|
|
4526
4552
|
/* harmony export */ validate: () => (/* reexport safe */ _lib_validator_js__WEBPACK_IMPORTED_MODULE_2__.validate),
|
|
4527
4553
|
/* harmony export */ write: () => (/* reexport safe */ _lib_writer_js__WEBPACK_IMPORTED_MODULE_1__.write)
|
|
4528
4554
|
/* harmony export */ });
|
|
@@ -4541,6 +4567,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4541
4567
|
|
|
4542
4568
|
if (false) {}
|
|
4543
4569
|
|
|
4570
|
+
})();
|
|
4571
|
+
|
|
4544
4572
|
/******/ return __webpack_exports__;
|
|
4545
4573
|
/******/ })()
|
|
4546
4574
|
;
|
|
@@ -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
|