@idlizer/core 2.1.5 → 2.1.9-arktscgen-4

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 (75) hide show
  1. package/build/lib/src/IndentedPrinter.js +2 -0
  2. package/build/lib/src/Language.d.ts +1 -0
  3. package/build/lib/src/Language.js +3 -0
  4. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +18 -4
  5. package/build/lib/src/LanguageWriters/ArgConvertors.js +162 -26
  6. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +38 -8
  7. package/build/lib/src/LanguageWriters/LanguageWriter.js +46 -4
  8. package/build/lib/src/LanguageWriters/convertors/CJConvertors.d.ts +1 -0
  9. package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +37 -14
  10. package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +1 -0
  11. package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +55 -54
  12. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +1 -1
  13. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +2 -2
  14. package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +1 -0
  15. package/build/lib/src/LanguageWriters/convertors/KotlinConvertor.d.ts +24 -0
  16. package/build/lib/src/LanguageWriters/convertors/KotlinConvertor.js +69 -0
  17. package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.d.ts +25 -0
  18. package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.js +128 -0
  19. package/build/lib/src/LanguageWriters/convertors/TSConvertors.d.ts +4 -2
  20. package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +44 -9
  21. package/build/lib/src/LanguageWriters/index.js +4 -0
  22. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +12 -7
  23. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +43 -27
  24. package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.d.ts +1 -1
  25. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +11 -2
  26. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +43 -10
  27. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +5 -2
  28. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +45 -11
  29. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +2 -2
  30. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +3 -3
  31. package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.d.ts +149 -0
  32. package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.js +495 -0
  33. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +8 -5
  34. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +17 -13
  35. package/build/lib/src/LibraryInterface.d.ts +2 -0
  36. package/build/lib/src/config.d.ts +673 -44
  37. package/build/lib/src/config.js +20 -0
  38. package/build/lib/src/configDescriber.d.ts +2 -2
  39. package/build/lib/src/configDescriber.js +3 -3
  40. package/build/lib/src/from-idl/DtsPrinter.js +12 -8
  41. package/build/lib/src/from-idl/IDLLinter.d.ts +0 -1
  42. package/build/lib/src/from-idl/IDLLinter.js +1 -7
  43. package/build/lib/src/from-idl/deserialize.d.ts +7 -1
  44. package/build/lib/src/from-idl/deserialize.js +72 -40
  45. package/build/lib/src/idl.d.ts +8 -15
  46. package/build/lib/src/idl.js +69 -72
  47. package/build/lib/src/idlize.js +2 -0
  48. package/build/lib/src/index.d.ts +2 -0
  49. package/build/lib/src/index.js +2 -0
  50. package/build/lib/src/peer-generation/LayoutManager.d.ts +4 -1
  51. package/build/lib/src/peer-generation/LayoutManager.js +5 -1
  52. package/build/lib/src/peer-generation/Materialized.d.ts +7 -3
  53. package/build/lib/src/peer-generation/Materialized.js +18 -4
  54. package/build/lib/src/peer-generation/PeerLibrary.d.ts +5 -2
  55. package/build/lib/src/peer-generation/PeerLibrary.js +30 -10
  56. package/build/lib/src/peer-generation/PeerMethod.d.ts +1 -1
  57. package/build/lib/src/peer-generation/getSuperType.d.ts +5 -0
  58. package/build/lib/src/peer-generation/getSuperType.js +55 -0
  59. package/build/lib/src/peer-generation/idl/IdlNameConvertor.d.ts +4 -0
  60. package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +7 -0
  61. package/build/lib/src/peer-generation/idl/common.d.ts +1 -0
  62. package/build/lib/src/peer-generation/idl/common.js +9 -3
  63. package/build/lib/src/peer-generation/isExternalType.d.ts +4 -0
  64. package/build/lib/src/peer-generation/isExternalType.js +15 -0
  65. package/build/lib/src/peer-generation/isMaterialized.js +18 -6
  66. package/build/lib/src/peer-generation/unions.js +1 -1
  67. package/build/lib/src/util.d.ts +4 -1
  68. package/build/lib/src/util.js +25 -10
  69. package/build/lib/src/visitor.d.ts +2 -0
  70. package/build/lib/src/visitor.js +108 -1
  71. package/package.json +2 -2
  72. package/webidl2.js/dist/webidl2.js +62 -16
  73. package/webidl2.js/LICENSE +0 -21
  74. package/webidl2.js/README.md +0 -827
  75. package/webidl2.js/dist/package.json +0 -3
@@ -64,6 +64,7 @@ export var IDLExtendedAttributes;
64
64
  IDLExtendedAttributes["DtsName"] = "DtsName";
65
65
  IDLExtendedAttributes["DtsTag"] = "DtsTag";
66
66
  IDLExtendedAttributes["Entity"] = "Entity";
67
+ IDLExtendedAttributes["Extends"] = "Extends";
67
68
  IDLExtendedAttributes["Import"] = "Import";
68
69
  IDLExtendedAttributes["DefaultExport"] = "DefaultExport";
69
70
  IDLExtendedAttributes["IndexSignature"] = "IndexSignature";
@@ -75,10 +76,12 @@ export var IDLExtendedAttributes;
75
76
  IDLExtendedAttributes["Protected"] = "Protected";
76
77
  IDLExtendedAttributes["Synthetic"] = "Synthetic";
77
78
  IDLExtendedAttributes["Throws"] = "Throws";
79
+ IDLExtendedAttributes["TraceKey"] = "TraceKey";
78
80
  IDLExtendedAttributes["TypeArguments"] = "TypeArguments";
79
81
  IDLExtendedAttributes["TypeParameters"] = "TypeParameters";
80
82
  IDLExtendedAttributes["VerbatimDts"] = "VerbatimDts";
81
83
  IDLExtendedAttributes["HandWrittenImplementation"] = "HandWrittenImplementation";
84
+ IDLExtendedAttributes["ExtraMethod"] = "ExtraMethod";
82
85
  })(IDLExtendedAttributes || (IDLExtendedAttributes = {}));
83
86
  export var IDLAccessorAttribute;
84
87
  (function (IDLAccessorAttribute) {
@@ -94,7 +97,7 @@ export var IDLInterfaceSubkind;
94
97
  IDLInterfaceSubkind[IDLInterfaceSubkind["Tuple"] = 3] = "Tuple";
95
98
  })(IDLInterfaceSubkind || (IDLInterfaceSubkind = {}));
96
99
  export function forEachChild(node, cbEnter, cbLeave) {
97
- var _a, _b;
100
+ var _a, _b, _c;
98
101
  const cleanup = cbEnter(node);
99
102
  switch (node.kind) {
100
103
  case IDLKind.File:
@@ -162,7 +165,10 @@ export function forEachChild(node, cbEnter, cbLeave) {
162
165
  node.typeArguments.forEach((value) => forEachChild(value, cbEnter, cbLeave));
163
166
  break;
164
167
  }
165
- case IDLKind.ReferenceType:
168
+ case IDLKind.ReferenceType: {
169
+ (_c = node.typeArguments) === null || _c === void 0 ? void 0 : _c.forEach((value) => forEachChild(value, cbEnter, cbLeave));
170
+ break;
171
+ }
166
172
  case IDLKind.TypeParameterType:
167
173
  case IDLKind.EnumMember:
168
174
  case IDLKind.Import:
@@ -178,6 +184,7 @@ export function forEachChild(node, cbEnter, cbLeave) {
178
184
  }
179
185
  /** Updates tree in place! */
180
186
  function updateEachChild(node, op, cbLeave) {
187
+ var _a;
181
188
  const old = node;
182
189
  node = op(old);
183
190
  if (node.kind !== old.kind) {
@@ -260,7 +267,11 @@ function updateEachChild(node, op, cbLeave) {
260
267
  concrete.typeArguments = concrete.typeArguments.map(it => updateEachChild(it, op, cbLeave));
261
268
  break;
262
269
  }
263
- case IDLKind.ReferenceType:
270
+ case IDLKind.ReferenceType: {
271
+ const concrete = node;
272
+ concrete.typeArguments = (_a = concrete.typeArguments) === null || _a === void 0 ? void 0 : _a.map(it => updateEachChild(it, op, cbLeave));
273
+ break;
274
+ }
264
275
  case IDLKind.TypeParameterType:
265
276
  case IDLKind.EnumMember:
266
277
  case IDLKind.Import:
@@ -386,17 +397,11 @@ export function createOptionalType(element, nodeInitializer) {
386
397
  if (isOptionalType(element) && !nodeInitializer) {
387
398
  return element;
388
399
  }
400
+ if (isOptionalType(element)) {
401
+ return Object.assign(Object.assign({ kind: IDLKind.OptionalType, type: element.type }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol });
402
+ }
389
403
  return Object.assign(Object.assign({ kind: IDLKind.OptionalType, type: element }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol });
390
404
  }
391
- /**
392
- * This placeholder is used when a class has no superclass.
393
- * Examples:
394
- * class definition: inheritance:
395
- * `C extends T` : [T]
396
- * `C implements T` : [Top, T]
397
- * `C extends T implements I, J` : [T, I, J]
398
- */
399
- export const IDLTopType = createReferenceType("__TOP__");
400
405
  // must match with toIDLType in deserialize.ts
401
406
  export const IDLPointerType = createPrimitiveType('pointer');
402
407
  export const IDLVoidType = createPrimitiveType('void');
@@ -418,7 +423,7 @@ export const IDLStringType = createPrimitiveType('String');
418
423
  export const IDLAnyType = createPrimitiveType('any');
419
424
  export const IDLUndefinedType = createPrimitiveType('undefined');
420
425
  export const IDLUnknownType = createPrimitiveType('unknown');
421
- export const IDLObjectType = createReferenceType('Object');
426
+ export const IDLObjectType = createPrimitiveType('Object');
422
427
  export const IDLThisType = createPrimitiveType('this');
423
428
  export const IDLDate = createPrimitiveType('date');
424
429
  export const IDLBufferType = createPrimitiveType('buffer');
@@ -431,15 +436,10 @@ export const IDLInteropReturnBufferType = createPrimitiveType('InteropReturnBuff
431
436
  export function createNamespace(name, members, nodeInitializer) {
432
437
  return Object.assign(Object.assign({ kind: IDLKind.Namespace, members: members !== null && members !== void 0 ? members : [], name: name }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
433
438
  }
434
- function isSpecialNodes(node) {
435
- return node === IDLTopType
436
- || node === IDLObjectType
437
- || isPrimitiveType(node);
438
- }
439
439
  export function linkParentBack(node) {
440
440
  const parentStack = [];
441
441
  updateEachChild(node, (node) => {
442
- if (isSpecialNodes(node)) {
442
+ if (isPrimitiveType(node)) {
443
443
  return node;
444
444
  }
445
445
  if (parentStack.length) {
@@ -452,7 +452,7 @@ export function linkParentBack(node) {
452
452
  parentStack.push(node);
453
453
  return node;
454
454
  }, (node) => {
455
- if (isSpecialNodes(node)) {
455
+ if (isPrimitiveType(node)) {
456
456
  return;
457
457
  }
458
458
  parentStack.pop();
@@ -505,6 +505,9 @@ export function isInPackage(entry, packageName, exactMatch = false) {
505
505
  export function getNamespaceName(a) {
506
506
  return getNamespacesPathFor(a).map(it => it.name).join('.');
507
507
  }
508
+ export function deriveQualifiedNameFrom(name, from) {
509
+ return [...getPackageClause(from), ...getNamespacesPathFor(from).map(it => it.name), name].join(".");
510
+ }
508
511
  export function getQualifiedName(a, pattern) {
509
512
  const result = [];
510
513
  if ("package.namespace.name" === pattern)
@@ -568,7 +571,7 @@ export function createFile(entries, fileName, packageClause = [], nodeInitialize
568
571
  return Object.assign(Object.assign({ kind: IDLKind.File, packageClause, entries: entries, fileName }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol });
569
572
  }
570
573
  export function createImport(clause, name, nodeInitializer) {
571
- return Object.assign(Object.assign({ kind: IDLKind.Import, name: name || "", clause }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
574
+ return Object.assign(Object.assign({ kind: IDLKind.Import, name: name !== null && name !== void 0 ? name : "", clause }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
572
575
  }
573
576
  export function createEnum(name, elements, nodeInitializer) {
574
577
  return Object.assign(Object.assign({ kind: IDLKind.Enum, name: name, elements: elements }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
@@ -622,13 +625,6 @@ export function createConstructor(parameters, returnType, nodeInitializer = {})
622
625
  returnType }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
623
626
  }
624
627
  export function createCallback(name, parameters, returnType, nodeInitializer = {}, typeParameters = []) {
625
- if (returnType === IDLThisType || isReferenceType(returnType) && returnType.name === "this")
626
- returnType = IDLAnyType;
627
- parameters = parameters.map(it => {
628
- if (it.type && isNamedNode(it.type) && (it.type.name === "T" || it.type.name === "this"))
629
- return createParameter(it.name, IDLAnyType, it.isOptional, it.isVariadic, { fileName: it.fileName });
630
- return it;
631
- });
632
628
  return Object.assign(Object.assign({ kind: IDLKind.Callback, name, parameters, returnType, typeParameters }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
633
629
  }
634
630
  export function createTypeParameterReference(name, nodeInitializer) {
@@ -643,7 +639,7 @@ export function createConstant(name, type, value, nodeInitializer = {}) {
643
639
  value }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
644
640
  }
645
641
  export function clone(node) {
646
- var _a, _b, _c, _d;
642
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
647
643
  const make = (node) => node;
648
644
  const get = (node) => node;
649
645
  switch (node.kind) {
@@ -651,7 +647,7 @@ export function clone(node) {
651
647
  const entry = get(node);
652
648
  return make(createInterface(entry.name, entry.subkind, (_a = entry.inheritance) === null || _a === void 0 ? void 0 : _a.map(clone), (_b = entry.constructors) === null || _b === void 0 ? void 0 : _b.map(clone), entry.constants.map(clone), entry.properties.map(clone), entry.methods.map(clone), entry.callables.map(clone), (_c = entry.typeParameters) === null || _c === void 0 ? void 0 : _c.map(it => it), {
653
649
  documentation: node.documentation,
654
- extendedAttributes: node.extendedAttributes,
650
+ extendedAttributes: (_d = node.extendedAttributes) === null || _d === void 0 ? void 0 : _d.slice(),
655
651
  fileName: node.fileName
656
652
  }));
657
653
  }
@@ -659,7 +655,7 @@ export function clone(node) {
659
655
  const entry = get(node);
660
656
  return make(createImport(entry.clause, entry.name, {
661
657
  documentation: entry.documentation,
662
- extendedAttributes: entry.extendedAttributes,
658
+ extendedAttributes: (_e = entry.extendedAttributes) === null || _e === void 0 ? void 0 : _e.slice(),
663
659
  fileName: entry.fileName
664
660
  }));
665
661
  }
@@ -667,7 +663,7 @@ export function clone(node) {
667
663
  const entry = get(node);
668
664
  return make(createCallback(entry.name, entry.parameters.map(clone), clone(entry.returnType), {
669
665
  documentation: entry.documentation,
670
- extendedAttributes: entry.extendedAttributes,
666
+ extendedAttributes: (_f = entry.extendedAttributes) === null || _f === void 0 ? void 0 : _f.slice(),
671
667
  fileName: entry.fileName
672
668
  }, entry.typeParameters));
673
669
  }
@@ -675,7 +671,7 @@ export function clone(node) {
675
671
  const entry = get(node);
676
672
  return make(createConstant(entry.name, clone(entry.type), entry.value, {
677
673
  documentation: entry.documentation,
678
- extendedAttributes: entry.extendedAttributes,
674
+ extendedAttributes: (_g = entry.extendedAttributes) === null || _g === void 0 ? void 0 : _g.slice(),
679
675
  fileName: entry.fileName
680
676
  }));
681
677
  }
@@ -683,7 +679,7 @@ export function clone(node) {
683
679
  const entry = get(node);
684
680
  return make(createProperty(entry.name, clone(entry.type), entry.isReadonly, entry.isStatic, entry.isOptional, {
685
681
  documentation: entry.documentation,
686
- extendedAttributes: entry.extendedAttributes,
682
+ extendedAttributes: (_h = entry.extendedAttributes) === null || _h === void 0 ? void 0 : _h.slice(),
687
683
  fileName: entry.fileName
688
684
  }));
689
685
  }
@@ -691,7 +687,7 @@ export function clone(node) {
691
687
  const entry = get(node);
692
688
  return make(createParameter(entry.name, clone(entry.type), entry.isOptional, entry.isVariadic, {
693
689
  documentation: entry.documentation,
694
- extendedAttributes: entry.extendedAttributes,
690
+ extendedAttributes: (_j = entry.extendedAttributes) === null || _j === void 0 ? void 0 : _j.slice(),
695
691
  fileName: entry.fileName
696
692
  }));
697
693
  }
@@ -704,7 +700,7 @@ export function clone(node) {
704
700
  isStatic: entry.isStatic
705
701
  }, {
706
702
  documentation: entry.documentation,
707
- extendedAttributes: entry.extendedAttributes,
703
+ extendedAttributes: (_k = entry.extendedAttributes) === null || _k === void 0 ? void 0 : _k.slice(),
708
704
  fileName: entry.fileName
709
705
  }, entry.typeParameters));
710
706
  }
@@ -715,7 +711,7 @@ export function clone(node) {
715
711
  isStatic: entry.isStatic
716
712
  }, {
717
713
  documentation: entry.documentation,
718
- extendedAttributes: entry.extendedAttributes,
714
+ extendedAttributes: (_l = entry.extendedAttributes) === null || _l === void 0 ? void 0 : _l.slice(),
719
715
  fileName: entry.documentation
720
716
  }, entry.typeParameters));
721
717
  }
@@ -723,7 +719,7 @@ export function clone(node) {
723
719
  const entry = get(node);
724
720
  return make(createConstructor(entry.parameters.map(clone), entry.returnType ? clone(entry.returnType) : undefined, {
725
721
  documentation: entry.documentation,
726
- extendedAttributes: entry.extendedAttributes,
722
+ extendedAttributes: (_m = entry.extendedAttributes) === null || _m === void 0 ? void 0 : _m.slice(),
727
723
  fileName: entry.fileName
728
724
  }));
729
725
  }
@@ -731,7 +727,7 @@ export function clone(node) {
731
727
  const entry = get(node);
732
728
  const cloned = createEnum(entry.name, entry.elements.map(clone), {
733
729
  documentation: entry.documentation,
734
- extendedAttributes: entry.extendedAttributes,
730
+ extendedAttributes: (_o = entry.extendedAttributes) === null || _o === void 0 ? void 0 : _o.slice(),
735
731
  fileName: entry.fileName
736
732
  });
737
733
  cloned.elements.forEach(it => {
@@ -743,7 +739,7 @@ export function clone(node) {
743
739
  const entry = get(node);
744
740
  return make(createEnumMember(entry.name, entry.parent, clone(entry.type), entry.initializer, {
745
741
  documentation: entry.documentation,
746
- extendedAttributes: entry.extendedAttributes,
742
+ extendedAttributes: (_p = entry.extendedAttributes) === null || _p === void 0 ? void 0 : _p.slice(),
747
743
  fileName: entry.fileName
748
744
  }));
749
745
  }
@@ -751,7 +747,7 @@ export function clone(node) {
751
747
  const entry = get(node);
752
748
  return make(createTypedef(entry.name, clone(entry.type), entry.typeParameters, {
753
749
  documentation: entry.documentation,
754
- extendedAttributes: entry.extendedAttributes,
750
+ extendedAttributes: (_q = entry.extendedAttributes) === null || _q === void 0 ? void 0 : _q.slice(),
755
751
  fileName: entry.fileName
756
752
  }));
757
753
  }
@@ -762,7 +758,7 @@ export function clone(node) {
762
758
  const type = get(node);
763
759
  return make(createContainerType(type.containerKind, type.elementType.map(clone), {
764
760
  documentation: type.documentation,
765
- extendedAttributes: type.extendedAttributes,
761
+ extendedAttributes: (_r = type.extendedAttributes) === null || _r === void 0 ? void 0 : _r.slice(),
766
762
  fileName: type.fileName
767
763
  }));
768
764
  }
@@ -770,15 +766,15 @@ export function clone(node) {
770
766
  const type = get(node);
771
767
  return make(createUnspecifiedGenericType(type.name, type.typeArguments.map(clone), {
772
768
  documentation: type.documentation,
773
- extendedAttributes: type.extendedAttributes,
769
+ extendedAttributes: (_s = type.extendedAttributes) === null || _s === void 0 ? void 0 : _s.slice(),
774
770
  fileName: type.fileName
775
771
  }));
776
772
  }
777
773
  case IDLKind.ReferenceType: {
778
774
  const type = get(node);
779
- return make(createReferenceType(type.name, (_d = type.typeArguments) === null || _d === void 0 ? void 0 : _d.map(clone), {
775
+ return make(createReferenceType(type.name, (_t = type.typeArguments) === null || _t === void 0 ? void 0 : _t.map(clone), {
780
776
  documentation: type.documentation,
781
- extendedAttributes: type.extendedAttributes,
777
+ extendedAttributes: (_u = type.extendedAttributes) === null || _u === void 0 ? void 0 : _u.slice(),
782
778
  fileName: type.fileName
783
779
  }));
784
780
  }
@@ -786,7 +782,7 @@ export function clone(node) {
786
782
  const type = get(node);
787
783
  return make(createUnionType(type.types.map(clone), type.name, {
788
784
  documentation: type.documentation,
789
- extendedAttributes: type.extendedAttributes,
785
+ extendedAttributes: (_v = type.extendedAttributes) === null || _v === void 0 ? void 0 : _v.slice(),
790
786
  fileName: type.fileName
791
787
  }));
792
788
  }
@@ -794,7 +790,7 @@ export function clone(node) {
794
790
  const type = get(node);
795
791
  return make(createTypeParameterReference(type.name, {
796
792
  documentation: type.documentation,
797
- extendedAttributes: type.extendedAttributes,
793
+ extendedAttributes: (_w = type.extendedAttributes) === null || _w === void 0 ? void 0 : _w.slice(),
798
794
  fileName: type.fileName
799
795
  }));
800
796
  }
@@ -802,7 +798,7 @@ export function clone(node) {
802
798
  const type = get(node);
803
799
  return make(createOptionalType(clone(type.type), {
804
800
  documentation: type.documentation,
805
- extendedAttributes: type.extendedAttributes,
801
+ extendedAttributes: (_x = type.extendedAttributes) === null || _x === void 0 ? void 0 : _x.slice(),
806
802
  fileName: type.fileName
807
803
  }));
808
804
  }
@@ -810,7 +806,7 @@ export function clone(node) {
810
806
  const entry = get(node);
811
807
  return make(createVersion(entry.value, {
812
808
  documentation: entry.documentation,
813
- extendedAttributes: entry.extendedAttributes,
809
+ extendedAttributes: (_y = entry.extendedAttributes) === null || _y === void 0 ? void 0 : _y.slice(),
814
810
  fileName: entry.fileName
815
811
  }));
816
812
  }
@@ -818,7 +814,7 @@ export function clone(node) {
818
814
  const ns = get(node);
819
815
  return make(createNamespace(ns.name, ns.members.map(clone), {
820
816
  documentation: ns.documentation,
821
- extendedAttributes: ns.extendedAttributes,
817
+ extendedAttributes: (_z = ns.extendedAttributes) === null || _z === void 0 ? void 0 : _z.slice(),
822
818
  fileName: ns.fileName
823
819
  }));
824
820
  }
@@ -826,12 +822,21 @@ export function clone(node) {
826
822
  const file = get(node);
827
823
  return make(createFile(file.entries.map(clone), file.fileName, file.packageClause, {
828
824
  documentation: file.documentation,
829
- extendedAttributes: file.extendedAttributes,
825
+ extendedAttributes: (_0 = file.extendedAttributes) === null || _0 === void 0 ? void 0 : _0.slice(),
830
826
  fileName: file.fileName
831
827
  }));
832
828
  }
833
829
  }
834
830
  }
831
+ export function hasTypeParameters(entry) {
832
+ let foundTypeParameter = false;
833
+ forEachChild(entry, n => {
834
+ if (isTypeParameterType(n)) {
835
+ foundTypeParameter = true;
836
+ }
837
+ });
838
+ return foundTypeParameter;
839
+ }
835
840
  export function escapeIDLKeyword(name) {
836
841
  return name + (IDLKeywords.has(name) ? "_" : "");
837
842
  }
@@ -883,7 +888,10 @@ export function printParameters(parameters) {
883
888
  return (_b = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.map(it => nameWithType(it, it.isVariadic, it.isOptional))) === null || _a === void 0 ? void 0 : _a.join(", ")) !== null && _b !== void 0 ? _b : "";
884
889
  }
885
890
  export function printConstructor(idl) {
886
- return [`constructor(${printParameters(idl.parameters)});`];
891
+ return [
892
+ ...printExtendedAttributes(idl, 1),
893
+ `constructor(${printParameters(idl.parameters)});`
894
+ ];
887
895
  }
888
896
  export function nameWithType(idl, isVariadic = false, isOptional = false) {
889
897
  const type = printType(idl.type);
@@ -949,6 +957,7 @@ export const attributesToQuote = new Set([
949
957
  IDLExtendedAttributes.DtsTag,
950
958
  IDLExtendedAttributes.Import,
951
959
  IDLExtendedAttributes.Interfaces,
960
+ IDLExtendedAttributes.TraceKey,
952
961
  IDLExtendedAttributes.TypeArguments,
953
962
  IDLExtendedAttributes.TypeParameters,
954
963
  ]);
@@ -1024,10 +1033,17 @@ export function printScoped(idl) {
1024
1033
  return printInterface(idl);
1025
1034
  throw new Error(`Unexpected scoped: ${idl.kind} ${idl.name}`);
1026
1035
  }
1036
+ function printInterfaceInherit(idl) {
1037
+ if (idl.inheritance.length === 0) {
1038
+ return "";
1039
+ }
1040
+ const types = idl.inheritance.map(type => printType(type));
1041
+ return ": " + types.join(', ');
1042
+ }
1027
1043
  export function printInterface(idl) {
1028
1044
  return [
1029
1045
  ...printExtendedAttributes(idl, 0),
1030
- `interface ${idl.name}${hasSuperType(idl) ? ": " + printType(idl.inheritance[0]) : ""} {`,
1046
+ `interface ${idl.name}${printInterfaceInherit(idl)} {`,
1031
1047
  // TODO: type system hack!
1032
1048
  ]
1033
1049
  .concat(printedIndentInc)
@@ -1039,25 +1055,6 @@ export function printInterface(idl) {
1039
1055
  .concat(printedIndentDec)
1040
1056
  .concat(["};"]);
1041
1057
  }
1042
- export function getSuperType(idl) {
1043
- if (!idl.inheritance)
1044
- return undefined;
1045
- const parent = idl.inheritance[0];
1046
- return parent && parent !== IDLTopType ? parent : undefined;
1047
- }
1048
- export function getSuperTypes(idl) {
1049
- if (!idl.inheritance)
1050
- return undefined;
1051
- if (idl.inheritance[0] == IDLTopType) {
1052
- return idl.inheritance.length == 1 ? undefined : idl.inheritance.slice(1);
1053
- }
1054
- else {
1055
- return idl.inheritance.length == 0 ? undefined : idl.inheritance;
1056
- }
1057
- }
1058
- export function hasSuperType(idl) {
1059
- return isDefined(getSuperType(idl));
1060
- }
1061
1058
  export function printEnumMember(idl) {
1062
1059
  const type = printType(idl.type);
1063
1060
  const initializer = idl.initializer === undefined
@@ -53,6 +53,8 @@ export function scanInputDirs(inputDirs, fileFilter = undefined, recursive = fal
53
53
  console.warn(`Warning: Directory does not exist or is not a directory: ${dir}`);
54
54
  return [];
55
55
  }
56
+ }).sort((a, b) => {
57
+ return path.basename(a).localeCompare(path.basename(b));
56
58
  });
57
59
  }
58
60
  function fileExists(fileName) {
@@ -40,9 +40,11 @@ export * from "./peer-generation/BuilderClass";
40
40
  export * from "./peer-generation/Materialized";
41
41
  export * from "./peer-generation/modules";
42
42
  export * from "./peer-generation/isMaterialized";
43
+ export * from "./peer-generation/isExternalType";
43
44
  export * from "./peer-generation/isStructureType";
44
45
  export * from "./peer-generation/isEnumType";
45
46
  export * from "./peer-generation/unions";
47
+ export * from "./peer-generation/getSuperType";
46
48
  export * from "./LanguageWriters";
47
49
  export * from "./peer-generation/ReferenceResolver";
48
50
  export * from "./peer-generation/idl/common";
@@ -54,9 +54,11 @@ export * from "./peer-generation/BuilderClass";
54
54
  export * from "./peer-generation/Materialized";
55
55
  export * from "./peer-generation/modules";
56
56
  export * from "./peer-generation/isMaterialized";
57
+ export * from "./peer-generation/isExternalType";
57
58
  export * from "./peer-generation/isStructureType";
58
59
  export * from "./peer-generation/isEnumType";
59
60
  export * from "./peer-generation/unions";
61
+ export * from "./peer-generation/getSuperType";
60
62
  export * from "./LanguageWriters";
61
63
  export * from "./peer-generation/ReferenceResolver";
62
64
  export * from "./peer-generation/idl/common";
@@ -3,7 +3,8 @@ export declare enum LayoutNodeRole {
3
3
  PEER = 0,
4
4
  INTERFACE = 1,
5
5
  GLOBAL = 2,
6
- COMPONENT = 3
6
+ COMPONENT = 3,
7
+ SERIALIZER = 4
7
8
  }
8
9
  export type LayoutTargetDescriptionHint = 'component.implementation' | 'component.interface' | 'component.function';
9
10
  export interface LayoutTargetDescription {
@@ -13,11 +14,13 @@ export interface LayoutTargetDescription {
13
14
  }
14
15
  export interface LayoutManagerStrategy {
15
16
  resolve(target: LayoutTargetDescription): string;
17
+ handwrittenPackage(): string;
16
18
  }
17
19
  export declare class LayoutManager {
18
20
  private strategy;
19
21
  constructor(strategy: LayoutManagerStrategy);
20
22
  resolve(target: LayoutTargetDescription): string;
23
+ handwrittenPackage(): string;
21
24
  static Empty(): LayoutManager;
22
25
  }
23
26
  //# sourceMappingURL=LayoutManager.d.ts.map
@@ -18,6 +18,7 @@ export var LayoutNodeRole;
18
18
  LayoutNodeRole[LayoutNodeRole["INTERFACE"] = 1] = "INTERFACE";
19
19
  LayoutNodeRole[LayoutNodeRole["GLOBAL"] = 2] = "GLOBAL";
20
20
  LayoutNodeRole[LayoutNodeRole["COMPONENT"] = 3] = "COMPONENT";
21
+ LayoutNodeRole[LayoutNodeRole["SERIALIZER"] = 4] = "SERIALIZER";
21
22
  })(LayoutNodeRole || (LayoutNodeRole = {}));
22
23
  export class LayoutManager {
23
24
  constructor(strategy) {
@@ -26,9 +27,12 @@ export class LayoutManager {
26
27
  resolve(target) {
27
28
  return this.strategy.resolve(target);
28
29
  }
30
+ handwrittenPackage() {
31
+ return this.strategy.handwrittenPackage();
32
+ }
29
33
  ////////////////////////////////////////////////////////////////////
30
34
  static Empty() {
31
- return new LayoutManager({ resolve: () => '' });
35
+ return new LayoutManager({ resolve: () => '', handwrittenPackage: () => '' });
32
36
  }
33
37
  }
34
38
  //# sourceMappingURL=LayoutManager.js.map
@@ -9,7 +9,8 @@ export declare class MaterializedField {
9
9
  argConvertor: ArgConvertor;
10
10
  outArgConvertor?: ArgConvertor | undefined;
11
11
  isNullableOriginalTypeField?: boolean | undefined;
12
- constructor(field: Field, argConvertor: ArgConvertor, outArgConvertor?: ArgConvertor | undefined, isNullableOriginalTypeField?: boolean | undefined);
12
+ extraMethodName: string | undefined;
13
+ constructor(field: Field, argConvertor: ArgConvertor, outArgConvertor?: ArgConvertor | undefined, isNullableOriginalTypeField?: boolean | undefined, extraMethodName?: string | undefined);
13
14
  }
14
15
  export declare class MaterializedMethod extends PeerMethod {
15
16
  implementationParentName: string;
@@ -29,6 +30,9 @@ export declare class MaterializedMethod extends PeerMethod {
29
30
  getImplementationName(): string;
30
31
  tsReturnType(): idl.IDLType | undefined;
31
32
  getPrivateMethod(): MaterializedMethod;
33
+ withReturnType(returnType: idl.IDLType): MaterializedMethod;
34
+ setOverloadIndex(index: number): void;
35
+ getOverloadPostfix(): string;
32
36
  }
33
37
  export declare function copyMaterializedMethod(method: MaterializedMethod, overrides: {
34
38
  method?: Method;
@@ -42,12 +46,12 @@ export declare class MaterializedClass implements PeerClassBase {
42
46
  readonly interfaces: idl.IDLReferenceType[] | undefined;
43
47
  readonly generics: string[] | undefined;
44
48
  readonly fields: MaterializedField[];
45
- readonly ctor: MaterializedMethod | undefined;
49
+ readonly ctors: MaterializedMethod[];
46
50
  readonly finalizer: MaterializedMethod | undefined;
47
51
  readonly methods: MaterializedMethod[];
48
52
  readonly needBeGenerated: boolean;
49
53
  readonly taggedMethods: idl.IDLMethod[];
50
- constructor(decl: idl.IDLInterface, className: string, isInterface: boolean, isStaticMaterialized: boolean, superClass: idl.IDLReferenceType | undefined, interfaces: idl.IDLReferenceType[] | undefined, generics: string[] | undefined, fields: MaterializedField[], ctor: MaterializedMethod | undefined, // undefined when used for global functions
54
+ constructor(decl: idl.IDLInterface, className: string, isInterface: boolean, isStaticMaterialized: boolean, superClass: idl.IDLReferenceType | undefined, interfaces: idl.IDLReferenceType[] | undefined, generics: string[] | undefined, fields: MaterializedField[], ctors: MaterializedMethod[], // zero size when used for global functions
51
55
  finalizer: MaterializedMethod | undefined, // undefined when used for global functions
52
56
  methods: MaterializedMethod[], needBeGenerated?: boolean, taggedMethods?: idl.IDLMethod[]);
53
57
  getComponentName(): string;
@@ -18,11 +18,12 @@ import { capitalize } from '../util';
18
18
  import { qualifiedName } from './idl/common';
19
19
  import { PeerMethod } from './PeerMethod';
20
20
  export class MaterializedField {
21
- constructor(field, argConvertor, outArgConvertor, isNullableOriginalTypeField) {
21
+ constructor(field, argConvertor, outArgConvertor, isNullableOriginalTypeField, extraMethodName = undefined) {
22
22
  this.field = field;
23
23
  this.argConvertor = argConvertor;
24
24
  this.outArgConvertor = outArgConvertor;
25
25
  this.isNullableOriginalTypeField = isNullableOriginalTypeField;
26
+ this.extraMethodName = extraMethodName;
26
27
  }
27
28
  }
28
29
  export class MaterializedMethod extends PeerMethod {
@@ -88,6 +89,19 @@ export class MaterializedMethod extends PeerMethod {
88
89
  }
89
90
  return privateMethod;
90
91
  }
92
+ withReturnType(returnType) {
93
+ const s = this.method.signature;
94
+ const argNames = s.args.map((_, i) => s.argName(i));
95
+ const signature = new NamedMethodSignature(returnType, s.args, argNames, s.defaults, s.argsModifiers, s.printHints);
96
+ const method = copyMethod(this.method, { signature: signature });
97
+ return copyMaterializedMethod(this, { method: method });
98
+ }
99
+ setOverloadIndex(index) {
100
+ this.overloadIndex = index;
101
+ }
102
+ getOverloadPostfix() {
103
+ return this.overloadIndex == undefined ? "" : `${this.overloadIndex}`;
104
+ }
91
105
  }
92
106
  export function copyMaterializedMethod(method, overrides) {
93
107
  var _a;
@@ -96,7 +110,7 @@ export function copyMaterializedMethod(method, overrides) {
96
110
  return copied;
97
111
  }
98
112
  export class MaterializedClass {
99
- constructor(decl, className, isInterface, isStaticMaterialized, superClass, interfaces, generics, fields, ctor, // undefined when used for global functions
113
+ constructor(decl, className, isInterface, isStaticMaterialized, superClass, interfaces, generics, fields, ctors, // zero size when used for global functions
100
114
  finalizer, // undefined when used for global functions
101
115
  methods, needBeGenerated = true, taggedMethods = []) {
102
116
  this.decl = decl;
@@ -107,7 +121,7 @@ export class MaterializedClass {
107
121
  this.interfaces = interfaces;
108
122
  this.generics = generics;
109
123
  this.fields = fields;
110
- this.ctor = ctor;
124
+ this.ctors = ctors;
111
125
  this.finalizer = finalizer;
112
126
  this.methods = methods;
113
127
  this.needBeGenerated = needBeGenerated;
@@ -135,7 +149,7 @@ export function createDestroyPeerMethod(clazz) {
135
149
  if (clazz.isGlobalScope() || clazz.isStaticMaterialized) {
136
150
  return undefined;
137
151
  }
138
- return new MaterializedMethod(clazz.className, clazz.getImplementationName(), [], idl.IDLVoidType, false, new Method('destroyPeer', new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.className)], ['peer'])));
152
+ return new MaterializedMethod(idl.getQualifiedName(clazz.decl, "namespace.name").split('.').join('_'), clazz.getImplementationName(), [], idl.IDLVoidType, false, new Method('destroyPeer', new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.decl)], ['peer'])));
139
153
  }
140
154
  export function getInternalClassName(name) {
141
155
  return `${name}Internal`;
@@ -8,6 +8,7 @@ import { BuilderClass } from './BuilderClass';
8
8
  import { MaterializedClass } from './Materialized';
9
9
  import { LayoutManager, LayoutManagerStrategy } from './LayoutManager';
10
10
  import { IDLLibrary } from '../library';
11
+ import { NativeModuleType } from '../LanguageWriters/common';
11
12
  export interface GlobalScopeDeclarations {
12
13
  methods: idl.IDLMethod[];
13
14
  constants: idl.IDLConstant[];
@@ -10252,6 +10253,7 @@ export declare const lenses: {
10252
10253
  };
10253
10254
  export declare class PeerLibrary implements LibraryInterface {
10254
10255
  language: Language;
10256
+ interopNativeModule: NativeModuleType;
10255
10257
  readonly useMemoM3: boolean;
10256
10258
  private _cachedIdlLibrary?;
10257
10259
  asIDLLibrary(): IDLLibrary;
@@ -10265,8 +10267,8 @@ export declare class PeerLibrary implements LibraryInterface {
10265
10267
  readonly builderClasses: Map<string, BuilderClass>;
10266
10268
  get buildersToGenerate(): BuilderClass[];
10267
10269
  readonly materializedClasses: Map<string, MaterializedClass>;
10268
- get materializedToGenerate(): MaterializedClass[];
10269
- constructor(language: Language, useMemoM3?: boolean);
10270
+ get orderedMaterialized(): MaterializedClass[];
10271
+ constructor(language: Language, interopNativeModule: NativeModuleType, useMemoM3?: boolean);
10270
10272
  name: string;
10271
10273
  readonly customComponentMethods: string[];
10272
10274
  createLanguageWriter(language?: Language): LanguageWriter;
@@ -10284,6 +10286,7 @@ export declare class PeerLibrary implements LibraryInterface {
10284
10286
  private referenceCache;
10285
10287
  enableCache(): void;
10286
10288
  resolveTypeReference(type: idl.IDLReferenceType, singleStep?: boolean): idl.IDLEntry | undefined;
10289
+ private resolveTypeReferenceUncached;
10287
10290
  private _useFallback;
10288
10291
  disableFallback(): void;
10289
10292
  resolveNamedNode(target: string[], pov?: idl.IDLNode | undefined): idl.IDLEntry | undefined;