@idlizer/core 2.1.10-arktscgen-4 → 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 (122) hide show
  1. package/build/lib/src/Language.d.ts +0 -1
  2. package/build/lib/src/Language.js +1 -3
  3. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +18 -7
  4. package/build/lib/src/LanguageWriters/ArgConvertors.js +95 -103
  5. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +13 -7
  6. package/build/lib/src/LanguageWriters/LanguageWriter.js +10 -2
  7. package/build/lib/src/LanguageWriters/common.d.ts +1 -0
  8. package/build/lib/src/LanguageWriters/common.js +2 -1
  9. package/build/lib/src/LanguageWriters/convertors/CJConvertors.d.ts +0 -1
  10. package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +1 -3
  11. package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +14 -8
  12. package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +88 -36
  13. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +1 -0
  14. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +10 -8
  15. package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +1 -1
  16. package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.js +9 -5
  17. package/build/lib/src/LanguageWriters/convertors/TSConvertors.d.ts +4 -4
  18. package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +98 -44
  19. package/build/lib/src/LanguageWriters/index.d.ts +5 -4
  20. package/build/lib/src/LanguageWriters/index.js +8 -15
  21. package/build/lib/src/LanguageWriters/nameConvertor.d.ts +2 -0
  22. package/build/lib/src/LanguageWriters/nameConvertor.js +11 -0
  23. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +2 -0
  24. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +13 -1
  25. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +2 -0
  26. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +8 -2
  27. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +2 -10
  28. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +52 -92
  29. package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.d.ts +8 -0
  30. package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.js +75 -27
  31. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +5 -0
  32. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +58 -18
  33. package/build/lib/src/LibraryInterface.d.ts +0 -1
  34. package/build/lib/src/config.d.ts +2 -1461
  35. package/build/lib/src/config.js +16 -32
  36. package/build/lib/src/configMerge.d.ts +3 -0
  37. package/build/lib/src/configMerge.js +63 -0
  38. package/build/lib/src/diagnostictypes.d.ts +1 -5
  39. package/build/lib/src/diagnostictypes.js +1 -27
  40. package/build/lib/src/from-idl/DtsPrinter.js +13 -6
  41. package/build/lib/src/from-idl/IDLLinter.d.ts +3 -4
  42. package/build/lib/src/from-idl/IDLLinter.js +30 -32
  43. package/build/lib/src/from-idl/deserialize.d.ts +3 -4
  44. package/build/lib/src/from-idl/deserialize.js +30 -642
  45. package/build/lib/src/from-idl/parser.d.ts +20 -2
  46. package/build/lib/src/from-idl/parser.js +97 -29
  47. package/build/lib/src/idl/builders.d.ts +43 -0
  48. package/build/lib/src/idl/builders.js +135 -0
  49. package/build/lib/src/idl/discriminators.d.ts +53 -0
  50. package/build/lib/src/idl/discriminators.js +232 -0
  51. package/build/lib/src/idl/dump.d.ts +48 -0
  52. package/build/lib/src/idl/dump.js +327 -0
  53. package/build/lib/src/idl/index.d.ts +9 -0
  54. package/build/lib/src/idl/index.js +23 -0
  55. package/build/lib/src/idl/keywords.d.ts +2 -0
  56. package/build/lib/src/{options.js → idl/keywords.js} +7 -3
  57. package/build/lib/src/idl/node.d.ts +233 -0
  58. package/build/lib/src/idl/node.js +103 -0
  59. package/build/lib/src/idl/stdlib.d.ts +34 -0
  60. package/build/lib/src/idl/stdlib.js +54 -0
  61. package/build/lib/src/idl/utils.d.ts +44 -0
  62. package/build/lib/src/idl/utils.js +215 -0
  63. package/build/lib/src/idl/visitors.d.ts +15 -0
  64. package/build/lib/src/idl/visitors.js +593 -0
  65. package/build/lib/src/index.d.ts +5 -6
  66. package/build/lib/src/index.js +6 -7
  67. package/build/lib/src/inheritance.d.ts +0 -2
  68. package/build/lib/src/inheritance.js +0 -17
  69. package/build/lib/src/inputPaths.d.ts +11 -0
  70. package/build/lib/src/inputPaths.js +81 -0
  71. package/build/lib/src/languageSpecificKeywords.d.ts +0 -1
  72. package/build/lib/src/languageSpecificKeywords.js +0 -5
  73. package/build/lib/src/peer-generation/ConflictingDeclarations.d.ts +6 -0
  74. package/build/lib/src/peer-generation/ConflictingDeclarations.js +43 -0
  75. package/build/lib/src/peer-generation/LayoutManager.d.ts +3 -1
  76. package/build/lib/src/peer-generation/LayoutManager.js +15 -0
  77. package/build/lib/src/peer-generation/Materialized.d.ts +8 -0
  78. package/build/lib/src/peer-generation/Materialized.js +26 -1
  79. package/build/lib/src/peer-generation/PeerLibrary.d.ts +10 -18
  80. package/build/lib/src/peer-generation/PeerLibrary.js +63 -227
  81. package/build/lib/src/peer-generation/ReferenceResolver.d.ts +6 -1
  82. package/build/lib/src/peer-generation/ReferenceResolver.js +93 -2
  83. package/build/lib/src/peer-generation/idl/IdlNameConvertor.d.ts +6 -0
  84. package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +15 -3
  85. package/build/lib/src/peer-generation/idl/common.d.ts +6 -2
  86. package/build/lib/src/peer-generation/idl/common.js +7 -7
  87. package/build/lib/src/peer-generation/isMaterialized.js +2 -3
  88. package/build/lib/src/peer-generation/modules.js +2 -0
  89. package/build/lib/src/peer-generation/toDeclaration.d.ts +4 -0
  90. package/build/lib/src/peer-generation/toDeclaration.js +53 -0
  91. package/build/lib/src/peer-generation/unions.d.ts +1 -1
  92. package/build/lib/src/peer-generation/unions.js +15 -7
  93. package/build/lib/src/resolveNamedNode.d.ts +1 -0
  94. package/build/lib/src/resolveNamedNode.js +7 -0
  95. package/build/lib/src/transformers/FqnTransformer.d.ts +1 -1
  96. package/build/lib/src/transformers/FqnTransformer.js +20 -12
  97. package/build/lib/src/transformers/GenericTransformer.d.ts +4 -3
  98. package/build/lib/src/transformers/GenericTransformer.js +252 -158
  99. package/build/lib/src/transformers/IdlTransformer.d.ts +6 -0
  100. package/build/lib/src/transformers/IdlTransformer.js +7 -0
  101. package/build/lib/src/transformers/NullTransformer.d.ts +1 -1
  102. package/build/lib/src/transformers/NullTransformer.js +27 -21
  103. package/build/lib/src/transformers/OnSerializeTransformer.d.ts +1 -1
  104. package/build/lib/src/transformers/OnSerializeTransformer.js +28 -13
  105. package/build/lib/src/util.d.ts +9 -39
  106. package/build/lib/src/util.js +65 -369
  107. package/package.json +44 -49
  108. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.d.ts +0 -37
  109. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +0 -210
  110. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +0 -83
  111. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +0 -295
  112. package/build/lib/src/from-idl/webidl2-utils.d.ts +0 -21
  113. package/build/lib/src/from-idl/webidl2-utils.js +0 -87
  114. package/build/lib/src/idl.d.ts +0 -439
  115. package/build/lib/src/idl.js +0 -1367
  116. package/build/lib/src/idlize.d.ts +0 -25
  117. package/build/lib/src/idlize.js +0 -198
  118. package/build/lib/src/options.d.ts +0 -13
  119. package/build/lib/src/peer-generation/BuilderClass.d.ts +0 -20
  120. package/build/lib/src/peer-generation/BuilderClass.js +0 -68
  121. package/webidl2.js/dist/webidl2.js +0 -4622
  122. package/webidl2.js/package.json +0 -55
@@ -12,8 +12,10 @@
12
12
  * See the License for the specific language governing permissions and
13
13
  * limitations under the License.
14
14
  */
15
+ import * as fs from "fs";
16
+ import * as path from "path";
15
17
  import { D } from "./configDescriber";
16
- import { capitalize } from "./util";
18
+ import { mergeJSONs } from "./configMerge";
17
19
  const T = {
18
20
  stringArray: () => D.array(D.string())
19
21
  };
@@ -24,34 +26,21 @@ export const ModuleConfigurationSchema = D.object({
24
26
  useFoldersLayout: D.maybe(D.boolean()),
25
27
  tsLikePackage: D.maybe(D.string()),
26
28
  });
27
- export const HookMethodSchema = D.object({
28
- hookName: D.string(),
29
- replaceImplementation: D.boolean()
30
- });
31
- export const TransformOnSerializeSchema = D.object({
32
- from: D.string(),
33
- to: D.string(),
34
- });
35
29
  export const CoreConfigurationSchema = D.object({
36
30
  ApiKind: D.number(),
37
31
  TypePrefix: D.string(),
38
32
  LibraryPrefix: D.string(),
39
33
  OptionalPrefix: D.string(),
40
- transformOnSerialize: D.array(TransformOnSerializeSchema),
41
34
  rootComponents: T.stringArray(),
42
35
  standaloneComponents: T.stringArray(),
43
36
  parameterized: T.stringArray(),
44
37
  ignoreMaterialized: T.stringArray(),
45
- ignoreGenerics: T.stringArray(),
46
38
  builderClasses: T.stringArray(),
47
39
  forceMaterialized: T.stringArray(),
48
40
  forceCallback: D.map(D.string(), T.stringArray()).onMerge('replace'),
49
41
  forceResource: T.stringArray(),
50
- forceContext: T.stringArray(),
51
- hooks: D.map(D.string(), D.map(D.string(), HookMethodSchema)).onMerge('replace'),
52
42
  moduleName: D.string(),
53
43
  modules: D.map(D.string(), ModuleConfigurationSchema).onMerge('replace'),
54
- libraryNameMapping: D.maybe(D.map(D.string(), D.map(D.string(), D.string())).onMerge('replace')),
55
44
  globalPackages: T.stringArray()
56
45
  });
57
46
  export const defaultCoreConfiguration = {
@@ -59,21 +48,16 @@ export const defaultCoreConfiguration = {
59
48
  TypePrefix: "",
60
49
  LibraryPrefix: "",
61
50
  OptionalPrefix: "",
62
- transformOnSerialize: [],
63
51
  rootComponents: [],
64
52
  standaloneComponents: [],
65
53
  parameterized: [],
66
54
  ignoreMaterialized: [],
67
- ignoreGenerics: [],
68
55
  builderClasses: [],
69
56
  forceMaterialized: [],
70
57
  forceCallback: new Map(),
71
58
  forceResource: [],
72
- forceContext: [],
73
- hooks: new Map(),
74
59
  moduleName: "",
75
60
  modules: new Map(),
76
- libraryNameMapping: new Map(),
77
61
  globalPackages: []
78
62
  };
79
63
  let currentConfig = defaultCoreConfiguration;
@@ -90,18 +74,18 @@ export function generatorTypePrefix() {
90
74
  const conf = generatorConfiguration();
91
75
  return `${conf.TypePrefix}${conf.LibraryPrefix}`;
92
76
  }
93
- export function getHookMethod(className, methodName) {
94
- var _a, _b;
95
- const hookMethods = generatorConfiguration().hooks.get(className);
96
- if (!hookMethods)
97
- return undefined;
98
- const hook = hookMethods.get(methodName);
99
- if (!hook)
100
- return undefined;
101
- const method = {
102
- hookName: (_a = hook.hookName) !== null && _a !== void 0 ? _a : `hook${className}${capitalize(methodName)}`,
103
- replaceImplementation: (_b = hook.replaceImplementation) !== null && _b !== void 0 ? _b : true
104
- };
105
- return method;
77
+ function parseConfigFile(configurationFile) {
78
+ if (!fs.existsSync(configurationFile))
79
+ throw new Error(`Configuration file ${configurationFile} does not exist!`);
80
+ const data = fs.readFileSync(path.resolve(configurationFile)).toString();
81
+ return JSON.parse(data);
82
+ }
83
+ export function parseConfigFiles(schema, configurationFiles) {
84
+ const json = mergeJSONs(configurationFiles.map(parseConfigFile), schema);
85
+ const result = schema.validate(json);
86
+ if (!result.success()) {
87
+ throw new Error("Configuration is not valid!\n" + result.error() + '\n');
88
+ }
89
+ return result.unwrap();
106
90
  }
107
91
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,3 @@
1
+ import { ConfigSchema } from "./configDescriber";
2
+ export declare function mergeJSONs(objects: unknown[], schema: ConfigSchema<any>): unknown;
3
+ //# sourceMappingURL=configMerge.d.ts.map
@@ -0,0 +1,63 @@
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 { inspectSchema } from "./configDescriber";
16
+ function mergeJSON(a, b, path, schema) {
17
+ if (a === undefined && b !== undefined) {
18
+ return b;
19
+ }
20
+ if (b === undefined && a !== undefined) {
21
+ return a;
22
+ }
23
+ const inspector = inspectSchema(schema);
24
+ const info = inspector.inspectPath(path.join('.'));
25
+ if (!info || info.mergeStrategy !== 'replace') {
26
+ if (Array.isArray(a) && Array.isArray(b)) {
27
+ return a.concat(b);
28
+ }
29
+ if (typeof a === 'object' && typeof b === 'object') {
30
+ if (a !== null && b !== null) {
31
+ const aObj = a;
32
+ const bObj = b;
33
+ const result = {};
34
+ for (const key in a) {
35
+ if (key in b) {
36
+ result[key] = mergeJSON(aObj[key], bObj[key], path.concat([key]), schema);
37
+ }
38
+ else {
39
+ result[key] = aObj[key];
40
+ }
41
+ }
42
+ for (const key in b) {
43
+ if (key in a) {
44
+ result[key] = mergeJSON(aObj[key], bObj[key], path.concat([key]), schema);
45
+ }
46
+ else {
47
+ result[key] = bObj[key];
48
+ }
49
+ }
50
+ return result;
51
+ }
52
+ }
53
+ }
54
+ return b;
55
+ }
56
+ export function mergeJSONs(objects, schema) {
57
+ let result = undefined;
58
+ for (const obj of objects) {
59
+ result = mergeJSON(result, obj, [], schema);
60
+ }
61
+ return result;
62
+ }
63
+ //# sourceMappingURL=configMerge.js.map
@@ -6,7 +6,7 @@ export type MessageSeverity = "fatal" | "error" | "warning" | "information" | "h
6
6
  /**
7
7
  * Diagnostic message severity values.
8
8
  */
9
- export declare let MessageSeverityList: MessageSeverity[];
9
+ export declare const MessageSeverityList: MessageSeverity[];
10
10
  /**
11
11
  * Message that reports specific error/warning, contains multiple parts and fixes.
12
12
  * LSP note:
@@ -84,7 +84,6 @@ export interface Range {
84
84
  */
85
85
  end: Position;
86
86
  }
87
- export declare function commonRange(range1: Range, range2: Range): Range;
88
87
  /**
89
88
  * Position in a document.
90
89
  * LSP note: In LSP positions are zero-based (that needs conversion) and UTF-16 by default.
@@ -99,9 +98,6 @@ export interface Position {
99
98
  */
100
99
  character: number;
101
100
  }
102
- export declare function comparePositions(a: Position, b: Position): number;
103
- export declare function minPosition(a: Position, b: Position): Position;
104
- export declare function maxPosition(a: Position, b: Position): Position;
105
101
  /**
106
102
  * Diff component of diagnostic message related to specific file/location.
107
103
  */
@@ -15,33 +15,7 @@
15
15
  /**
16
16
  * Diagnostic message severity values.
17
17
  */
18
- export let MessageSeverityList = ["fatal", "error", "warning", "information", "hint"];
19
- export function commonRange(range1, range2) {
20
- let start = minPosition(range1.start, range2.start);
21
- let end = maxPosition(range1.end, range2.end);
22
- return { start, end };
23
- }
24
- export function comparePositions(a, b) {
25
- if (a.line < b.line) {
26
- return -1;
27
- }
28
- if (a.line > b.line) {
29
- return 1;
30
- }
31
- if (a.character < b.character) {
32
- return -1;
33
- }
34
- if (a.character > b.character) {
35
- return 1;
36
- }
37
- return 0;
38
- }
39
- export function minPosition(a, b) {
40
- return comparePositions(a, b) == -1 ? a : b;
41
- }
42
- export function maxPosition(a, b) {
43
- return comparePositions(a, b) == 1 ? a : b;
44
- }
18
+ export const MessageSeverityList = ["fatal", "error", "warning", "information", "hint"];
45
19
  /**
46
20
  * Collection of diagnostic messages with calculated statistics.
47
21
  */
@@ -13,11 +13,11 @@
13
13
  * limitations under the License.
14
14
  */
15
15
  import { indentedBy, isInNamespace } from "../util";
16
- import { IDLEntity, IDLKind, getExtAttribute, getVerbatimDts, hasExtAttribute, isCallback, isConstructor, isContainerType, isEnum, isInterface, isMethod, isPrimitiveType, isProperty, isReferenceType, isSyntheticEntry, isTypeParameterType, isTypedef, isUnionType, isImport, isVersion, isNamespace, IDLExtendedAttributes, IDLAccessorAttribute, IDLVoidType, IDLStringType, IDLUndefinedType, isCallable, IDLAnyType, IDLContainerUtils, DebugUtils, mixMethodParametersAndTags, createReferenceType, transformMethodsAsync2ReturnPromise, linearizeNamespaceMembers, isNamedNode, IDLThisType, isOptionalType, IDLI8Type, IDLU8Type, IDLI16Type, IDLU16Type, IDLI32Type, IDLU32Type, IDLI64Type, IDLU64Type, IDLF16Type, IDLF32Type, IDLF64Type, IDLBufferType, isUnspecifiedGenericType, IDLUnknownType, IDLBooleanType, IDLNumberType, IDLPointerType, IDLInterfaceSubkind, escapeIDLKeyword, getNamespacesPathFor, IDLBigintType, IDLDate, IDLFunctionType, getQualifiedName, IDLObjectType } from "../idl";
16
+ import { IDLEntity, IDLKind, getExtAttribute, getVerbatimDts, hasExtAttribute, isCallback, isConstructor, isContainerType, isEnum, isInterface, isMethod, isPrimitiveType, isProperty, isReferenceType, isSyntheticEntry, isTypeParameterType, isTypedef, isUnionType, isImport, isVersion, isNamespace, IDLExtendedAttributes, IDLAccessorAttribute, IDLVoidType, IDLStringType, IDLUndefinedType, isCallable, IDLAnyType, IDLContainerUtils, DebugUtils, mixMethodParametersAndTags, createReferenceType, transformMethodsAsync2ReturnPromise, linearizeNamespaceMembers, isNamedNode, IDLThisType, isOptionalType, IDLI8Type, IDLU8Type, IDLI16Type, IDLU16Type, IDLI32Type, IDLU32Type, IDLI64Type, IDLU64Type, IDLF16Type, IDLF32Type, IDLF64Type, IDLBufferType, IDLUnknownType, IDLBooleanType, IDLNumberType, IDLPointerType, IDLInterfaceSubkind, escapeIDLKeyword, getNamespacesPathFor, IDLBigintType, IDLDate, IDLFunctionType, getQualifiedName, IDLObjectType, isConstant, } from "../idl";
17
17
  import { resolveSyntheticType, parseIDLFile } from "./deserialize";
18
18
  import { Language } from "../Language";
19
19
  import { warn } from "../util";
20
- import { isInIdlize } from "../idlize";
20
+ import { isInIdlize } from "../idl";
21
21
  export class CustomPrintVisitor {
22
22
  constructor(resolver, language) {
23
23
  this.resolver = resolver;
@@ -61,6 +61,9 @@ export class CustomPrintVisitor {
61
61
  else if (isNamespace(node)) {
62
62
  this.printNamespace(node);
63
63
  }
64
+ else if (isConstant(node)) {
65
+ this.printConstant(node);
66
+ }
64
67
  else {
65
68
  throw new Error(`Unexpected node kind: ${IDLKind[node.kind]}`);
66
69
  }
@@ -306,8 +309,6 @@ export class CustomPrintVisitor {
306
309
  return `${type.elementType.map(it => this.printTypeForTS(it)).join(",")}[]`;
307
310
  return `${mapContainerType(type)}<${type.elementType.map(it => this.printTypeForTS(it)).join(",")}>`;
308
311
  }
309
- if (isUnspecifiedGenericType(type))
310
- return `${type.name}<${type.typeArguments.map(it => this.printTypeForTS(it)).join(",")}>`;
311
312
  if (isReferenceType(type))
312
313
  return this.toTypeName(type);
313
314
  if (isUnionType(type))
@@ -331,8 +332,14 @@ export class CustomPrintVisitor {
331
332
  }
332
333
  }
333
334
  let typeSpec = getQualifiedName(decl, "namespace.name");
334
- if (node.typeArguments)
335
- typeSpec = `${typeSpec}<${node.typeArguments.map(it => this.printTypeForTS(it))}>`;
335
+ if (node.typeArguments) {
336
+ let typeArguments = node.typeArguments;
337
+ if (node.name.endsWith(".Callback")) {
338
+ console.log("Removing second type arguments for Callback type. Reason: in .d.ts declarations will be only callback with one type argument from ohos.base");
339
+ typeArguments = [typeArguments[0]];
340
+ }
341
+ typeSpec = `${typeSpec}<${typeArguments.map(it => this.printTypeForTS(it))}>`;
342
+ }
336
343
  return typeSpec;
337
344
  }
338
345
  }
@@ -1,6 +1,5 @@
1
1
  import * as idl from "../idl";
2
2
  import { ReferenceResolver } from "../peer-generation/ReferenceResolver";
3
- import { IDLTokenInfoMap } from "./deserialize";
4
3
  export declare enum IDLValidationDiagnosticsCode {
5
4
  INVALID_EXTENDED_ATTRIBUTE = 1000,
6
5
  ENUM_IS_NOT_CONSISTENT = 1001,
@@ -15,6 +14,7 @@ export interface IDLLinterOptions {
15
14
  checkEnumsConsistency: boolean;
16
15
  checkReferencesResolved: boolean;
17
16
  }
17
+ export declare const DefaultIDLLinterOptions: IDLLinterOptions;
18
18
  interface IDLLinterContextRecord {
19
19
  typeParameters: Set<string>;
20
20
  }
@@ -30,10 +30,9 @@ export declare class IDLLinter {
30
30
  protected file: idl.IDLFile;
31
31
  protected resolver: ReferenceResolver;
32
32
  protected options: IDLLinterOptions;
33
- protected info?: IDLTokenInfoMap | undefined;
34
33
  protected context: IDLLinterContext;
35
34
  diagnostics: IDLLinterDiagnosticsSummary[];
36
- constructor(file: idl.IDLFile, resolver: ReferenceResolver, options: IDLLinterOptions, info?: IDLTokenInfoMap | undefined);
35
+ constructor(file: idl.IDLFile, resolver: ReferenceResolver, options: IDLLinterOptions);
37
36
  visit(): IDLLinterDiagnosticsSummary[];
38
37
  protected enter(node: idl.IDLNode): (() => void) | undefined;
39
38
  protected check(node: idl.IDLNode): void;
@@ -51,6 +50,6 @@ export declare class IDLLinterError extends Error {
51
50
  size: number;
52
51
  constructor(message: string, size: number);
53
52
  }
54
- export declare function verifyIDLLinter(file: idl.IDLFile, resolver: ReferenceResolver, options: IDLLinterOptions, info?: IDLTokenInfoMap): true;
53
+ export declare function verifyIDLLinter(file: idl.IDLFile, resolver: ReferenceResolver, options: IDLLinterOptions): true;
55
54
  export {};
56
55
  //# sourceMappingURL=IDLLinter.d.ts.map
@@ -14,6 +14,24 @@ const ENG_ErrorDescription = {
14
14
  export const IDLValidationErrorDescription = {
15
15
  en_EN: ENG_ErrorDescription
16
16
  };
17
+ export const DefaultIDLLinterOptions = {
18
+ validEntryAttributes: new Map([
19
+ [idl.IDLKind.Import, ["Deprecated", "Documentation"]],
20
+ [idl.IDLKind.Namespace, ["DefaultExport", "Deprecated", "Documentation", "VerbatimDts"]],
21
+ [idl.IDLKind.Const, ["DefaultExport", "Deprecated", "Documentation"]],
22
+ [idl.IDLKind.Property, ["DefaultExport", "Optional", "Accessor", "Deprecated", "CommonMethod", "Protected", "DtsName", "Documentation"]],
23
+ [idl.IDLKind.Interface, ["DefaultExport", "Predefined", "TSType", "CPPType", "Entity", "Interfaces", "ParentTypeArguments", "Component", "Synthetic", "Deprecated", "HandWrittenImplementation", "Documentation", "TypeParameters", "ComponentInterface"]],
24
+ [idl.IDLKind.Callback, ["DefaultExport", "Deprecated", "Async", "Synthetic", "Documentation", "TypeParameters"]],
25
+ [idl.IDLKind.Method, ["DefaultExport", "Optional", "DtsTag", "DtsName", "Throws", "Deprecated", "IndexSignature", "Protected", "Documentation", "CallSignature", "TypeParameters"]],
26
+ [idl.IDLKind.Callable, ["DefaultExport", "CallSignature", "Deprecated", "Documentation", "CallSignature"]],
27
+ [idl.IDLKind.Typedef, ["DefaultExport", "Deprecated", "Import", "Documentation", "TypeParameters"]],
28
+ [idl.IDLKind.Enum, ["DefaultExport", "Deprecated", "Documentation"]],
29
+ [idl.IDLKind.EnumMember, ["OriginalEnumMemberName", "Deprecated", "Documentation"]],
30
+ [idl.IDLKind.Constructor, ["Deprecated", "Documentation"]]
31
+ ]),
32
+ checkEnumsConsistency: true,
33
+ checkReferencesResolved: false,
34
+ };
17
35
  class IDLLinterContext {
18
36
  constructor() {
19
37
  this.stack = [{ typeParameters: new Set() }];
@@ -48,11 +66,10 @@ function parseTypeParameter(param) {
48
66
  return param;
49
67
  }
50
68
  export class IDLLinter {
51
- constructor(file, resolver, options, info) {
69
+ constructor(file, resolver, options) {
52
70
  this.file = file;
53
71
  this.resolver = resolver;
54
72
  this.options = options;
55
- this.info = info;
56
73
  this.context = new IDLLinterContext();
57
74
  this.diagnostics = [];
58
75
  }
@@ -85,25 +102,23 @@ export class IDLLinter {
85
102
  }
86
103
  }
87
104
  checkValidAttributes(entry, validAttributes) {
88
- var _a, _b, _c;
105
+ var _a;
89
106
  if (!entry.extendedAttributes)
90
107
  return;
91
108
  for (const attr of entry.extendedAttributes) {
92
109
  if (!validAttributes.includes(attr.name)) {
93
- const tokens = (_a = this.info) === null || _a === void 0 ? void 0 : _a.get(attr);
94
- const ident = tokens === null || tokens === void 0 ? void 0 : tokens.name;
95
110
  const file = idl.getFileFor(entry);
96
111
  this.diagnostics.push({
97
112
  code: IDLValidationDiagnosticsCode.INVALID_EXTENDED_ATTRIBUTE,
98
- file: (_b = file === null || file === void 0 ? void 0 : file.fileName) !== null && _b !== void 0 ? _b : '',
113
+ file: (_a = file === null || file === void 0 ? void 0 : file.fileName) !== null && _a !== void 0 ? _a : '',
99
114
  message: `Invalid attribute '${attr.name}'`,
100
- position: [(_c = ident === null || ident === void 0 ? void 0 : ident.position) !== null && _c !== void 0 ? _c : 0, attr.name.length]
115
+ position: [0, attr.name.length]
101
116
  });
102
117
  }
103
118
  }
104
119
  }
105
120
  checkEnumConsistency(entry) {
106
- var _a, _b, _c, _d;
121
+ var _a;
107
122
  const fileName = (_a = idl.getFileFor(entry)) === null || _a === void 0 ? void 0 : _a.fileName;
108
123
  let hasNumber = false;
109
124
  let hasString = false;
@@ -114,21 +129,16 @@ export class IDLLinter {
114
129
  hasNumber = true;
115
130
  }
116
131
  if (hasNumber && hasString) {
117
- const tokens = (_b = this.info) === null || _b === void 0 ? void 0 : _b.get(entry);
118
- const ident = tokens === null || tokens === void 0 ? void 0 : tokens.name;
119
132
  this.diagnostics.push({
120
133
  code: IDLValidationDiagnosticsCode.ENUM_IS_NOT_CONSISTENT,
121
134
  file: fileName !== null && fileName !== void 0 ? fileName : '',
122
135
  message: "Enum includes both string and number values",
123
- position: [
124
- (_c = ident === null || ident === void 0 ? void 0 : ident.position) !== null && _c !== void 0 ? _c : 0,
125
- (_d = ident === null || ident === void 0 ? void 0 : ident.value.length) !== null && _d !== void 0 ? _d : 0
126
- ]
136
+ position: [0, 0]
127
137
  });
128
138
  }
129
139
  }
130
140
  checkReferenceResolved(reference) {
131
- var _a, _b, _c, _d, _e, _f;
141
+ var _a;
132
142
  if (this.context.hasTypeParameter(reference.name)) {
133
143
  return;
134
144
  }
@@ -137,19 +147,11 @@ export class IDLLinter {
137
147
  const parentFile = idl.getFileFor(reference);
138
148
  const parentNamespace = idl.fetchNamespaceFrom(reference);
139
149
  const scopeName = parentNamespace ? idl.getFQName(parentNamespace) : idl.getPackageName(parentFile);
140
- let current = reference;
141
- let tokens = (_a = this.info) === null || _a === void 0 ? void 0 : _a.get(current);
142
- let location = tokens === null || tokens === void 0 ? void 0 : tokens.base;
143
- while (current !== undefined && tokens === undefined) {
144
- current = current.parent;
145
- tokens = (_b = this.info) === null || _b === void 0 ? void 0 : _b.get(current);
146
- location = tokens === null || tokens === void 0 ? void 0 : tokens.name;
147
- }
148
150
  this.diagnostics.push({
149
151
  code: IDLValidationDiagnosticsCode.REFERENCE_IS_NOT_RESOLVED,
150
- file: (_c = parentFile.fileName) !== null && _c !== void 0 ? _c : '',
152
+ file: (_a = parentFile.fileName) !== null && _a !== void 0 ? _a : '',
151
153
  message: `Can not resolve reference '${reference.name}' defined in scope '${scopeName}'`,
152
- position: [(_d = location === null || location === void 0 ? void 0 : location.position) !== null && _d !== void 0 ? _d : 0, (_f = (_e = location === null || location === void 0 ? void 0 : location.value) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0]
154
+ position: [0, 0]
153
155
  });
154
156
  }
155
157
  }
@@ -246,14 +248,10 @@ function prettyPrintErrors(errors, text) {
246
248
  return errorText;
247
249
  }).join(EOL);
248
250
  }
249
- export function verifyIDLLinter(file, resolver, options, info) {
250
- var _a, _b;
251
- const result = new IDLLinter(file, resolver, options, info).visit();
251
+ export function verifyIDLLinter(file, resolver, options) {
252
+ const result = new IDLLinter(file, resolver, options).visit();
252
253
  if (result.length) {
253
- const isTTY = Boolean(process.stdout.isTTY);
254
- const errorMessage = info
255
- ? isTTY ? prettyPrintErrors(result, (_a = file.text) !== null && _a !== void 0 ? _a : '') : printErrors(result, (_b = file.text) !== null && _b !== void 0 ? _b : '')
256
- : printErrorWithoutLocation(result);
254
+ const errorMessage = printErrorWithoutLocation(result);
257
255
  throw new IDLLinterError(errorMessage, result.length);
258
256
  }
259
257
  return true;
@@ -1,11 +1,10 @@
1
- import * as webidl2 from "webidl2";
2
1
  import * as idl from "../idl";
3
- export type WebIDLTokenCollection = Record<string, webidl2.Token | null | undefined>;
4
- export type IDLTokenInfoMap = Map<unknown, WebIDLTokenCollection>;
5
2
  export declare function addSyntheticType(name: string, type: idl.IDLEntry): void;
6
3
  export declare function resolveSyntheticType(type: idl.IDLReferenceType): idl.IDLEntry | undefined;
7
4
  export declare function toIdlType(fileName: string, content: string): idl.IDLType;
5
+ export declare function toIdlTypeList(fileName: string, content: string): idl.IDLType[];
6
+ export declare function compareNodes(a: idl.IDLNode, b: idl.IDLNode): boolean;
8
7
  export declare function compareParsingResults(oldFile: idl.IDLFile, newFile: idl.IDLFile): boolean;
9
8
  export declare function parseIDLFile(fileName: string, content?: string, quiet?: boolean): idl.IDLFile;
10
- export declare function parseIDLFileNew(fileName: string, content?: string, registerSynthetics?: boolean): idl.IDLFile;
9
+ export declare function parseIDLFileNew(fileName: string, content?: string): idl.IDLFile;
11
10
  //# sourceMappingURL=deserialize.d.ts.map