@tsonic/emitter 0.0.6 → 0.0.13

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 (223) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/array.test.js +5 -5
  3. package/dist/array.test.js.map +1 -1
  4. package/dist/core/attributes.d.ts +43 -0
  5. package/dist/core/attributes.d.ts.map +1 -0
  6. package/dist/core/attributes.js +128 -0
  7. package/dist/core/attributes.js.map +1 -0
  8. package/dist/core/attributes.test.d.ts +5 -0
  9. package/dist/core/attributes.test.d.ts.map +1 -0
  10. package/dist/core/attributes.test.js +296 -0
  11. package/dist/core/attributes.test.js.map +1 -0
  12. package/dist/core/imports.test.js +6 -3
  13. package/dist/core/imports.test.js.map +1 -1
  14. package/dist/core/index.d.ts +2 -0
  15. package/dist/core/index.d.ts.map +1 -1
  16. package/dist/core/index.js +2 -0
  17. package/dist/core/index.js.map +1 -1
  18. package/dist/core/module-emitter/static-container.d.ts.map +1 -1
  19. package/dist/core/module-emitter/static-container.js +50 -1
  20. package/dist/core/module-emitter/static-container.js.map +1 -1
  21. package/dist/core/module-emitter.test.js +2 -1
  22. package/dist/core/module-emitter.test.js.map +1 -1
  23. package/dist/core/module-map.d.ts.map +1 -1
  24. package/dist/core/module-map.js +5 -1
  25. package/dist/core/module-map.js.map +1 -1
  26. package/dist/core/module-map.test.d.ts +8 -0
  27. package/dist/core/module-map.test.d.ts.map +1 -0
  28. package/dist/core/module-map.test.js +94 -0
  29. package/dist/core/module-map.test.js.map +1 -0
  30. package/dist/core/type-compatibility.d.ts +31 -0
  31. package/dist/core/type-compatibility.d.ts.map +1 -0
  32. package/dist/core/type-compatibility.js +99 -0
  33. package/dist/core/type-compatibility.js.map +1 -0
  34. package/dist/core/type-resolution.d.ts +83 -3
  35. package/dist/core/type-resolution.d.ts.map +1 -1
  36. package/dist/core/type-resolution.js +262 -4
  37. package/dist/core/type-resolution.js.map +1 -1
  38. package/dist/core/type-resolution.test.js +110 -1
  39. package/dist/core/type-resolution.test.js.map +1 -1
  40. package/dist/emitter-types/context.d.ts.map +1 -1
  41. package/dist/emitter-types/context.js +21 -1
  42. package/dist/emitter-types/context.js.map +1 -1
  43. package/dist/emitter-types/core.d.ts +26 -0
  44. package/dist/emitter-types/core.d.ts.map +1 -1
  45. package/dist/emitter-types/identifiers.d.ts.map +1 -1
  46. package/dist/emitter-types/identifiers.js +4 -43
  47. package/dist/emitter-types/identifiers.js.map +1 -1
  48. package/dist/emitter-types/index.d.ts +1 -1
  49. package/dist/emitter-types/index.d.ts.map +1 -1
  50. package/dist/emitter-types/index.js.map +1 -1
  51. package/dist/emitter.d.ts.map +1 -1
  52. package/dist/emitter.js +47 -1
  53. package/dist/emitter.js.map +1 -1
  54. package/dist/expression-emitter.d.ts.map +1 -1
  55. package/dist/expression-emitter.js +51 -3
  56. package/dist/expression-emitter.js.map +1 -1
  57. package/dist/expressions/access.d.ts.map +1 -1
  58. package/dist/expressions/access.js +138 -23
  59. package/dist/expressions/access.js.map +1 -1
  60. package/dist/expressions/calls.d.ts.map +1 -1
  61. package/dist/expressions/calls.js +90 -13
  62. package/dist/expressions/calls.js.map +1 -1
  63. package/dist/expressions/collections.d.ts +3 -2
  64. package/dist/expressions/collections.d.ts.map +1 -1
  65. package/dist/expressions/collections.js +251 -52
  66. package/dist/expressions/collections.js.map +1 -1
  67. package/dist/expressions/functions.d.ts +2 -2
  68. package/dist/expressions/functions.d.ts.map +1 -1
  69. package/dist/expressions/functions.js +81 -38
  70. package/dist/expressions/functions.js.map +1 -1
  71. package/dist/expressions/identifiers.d.ts.map +1 -1
  72. package/dist/expressions/identifiers.js +28 -7
  73. package/dist/expressions/identifiers.js.map +1 -1
  74. package/dist/expressions/index.test.js +191 -4
  75. package/dist/expressions/index.test.js.map +1 -1
  76. package/dist/expressions/literals.d.ts +7 -17
  77. package/dist/expressions/literals.d.ts.map +1 -1
  78. package/dist/expressions/literals.js +27 -87
  79. package/dist/expressions/literals.js.map +1 -1
  80. package/dist/expressions/literals.test.js +52 -2
  81. package/dist/expressions/literals.test.js.map +1 -1
  82. package/dist/expressions/operators.d.ts +29 -11
  83. package/dist/expressions/operators.d.ts.map +1 -1
  84. package/dist/expressions/operators.js +244 -67
  85. package/dist/expressions/operators.js.map +1 -1
  86. package/dist/expressions/other.d.ts +3 -0
  87. package/dist/expressions/other.d.ts.map +1 -1
  88. package/dist/expressions/other.js +27 -3
  89. package/dist/expressions/other.js.map +1 -1
  90. package/dist/generator-exchange.d.ts +1 -1
  91. package/dist/generator-exchange.d.ts.map +1 -1
  92. package/dist/generator-exchange.js +15 -4
  93. package/dist/generator-exchange.js.map +1 -1
  94. package/dist/generator-wrapper.d.ts +84 -0
  95. package/dist/generator-wrapper.d.ts.map +1 -0
  96. package/dist/generator-wrapper.js +312 -0
  97. package/dist/generator-wrapper.js.map +1 -0
  98. package/dist/generator-wrapper.test.d.ts +12 -0
  99. package/dist/generator-wrapper.test.d.ts.map +1 -0
  100. package/dist/generator-wrapper.test.js +179 -0
  101. package/dist/generator-wrapper.test.js.map +1 -0
  102. package/dist/generator.test.js +596 -6
  103. package/dist/generator.test.js.map +1 -1
  104. package/dist/golden-tests/config-parser.d.ts.map +1 -1
  105. package/dist/golden-tests/config-parser.js +81 -11
  106. package/dist/golden-tests/config-parser.js.map +1 -1
  107. package/dist/golden-tests/discovery.d.ts +14 -3
  108. package/dist/golden-tests/discovery.d.ts.map +1 -1
  109. package/dist/golden-tests/discovery.js +105 -12
  110. package/dist/golden-tests/discovery.js.map +1 -1
  111. package/dist/golden-tests/index.d.ts +1 -1
  112. package/dist/golden-tests/index.d.ts.map +1 -1
  113. package/dist/golden-tests/index.js.map +1 -1
  114. package/dist/golden-tests/runner.d.ts +1 -0
  115. package/dist/golden-tests/runner.d.ts.map +1 -1
  116. package/dist/golden-tests/runner.js +83 -25
  117. package/dist/golden-tests/runner.js.map +1 -1
  118. package/dist/golden-tests/types.d.ts +18 -1
  119. package/dist/golden-tests/types.d.ts.map +1 -1
  120. package/dist/golden.test.d.ts +12 -5
  121. package/dist/golden.test.d.ts.map +1 -1
  122. package/dist/golden.test.js +40 -21
  123. package/dist/golden.test.js.map +1 -1
  124. package/dist/hierarchical-bindings.test.js +2 -2
  125. package/dist/hierarchical-bindings.test.js.map +1 -1
  126. package/dist/integration.test.js +57 -10
  127. package/dist/integration.test.js.map +1 -1
  128. package/dist/invariants/emitter-globals-subset.test.d.ts +15 -0
  129. package/dist/invariants/emitter-globals-subset.test.d.ts.map +1 -0
  130. package/dist/invariants/emitter-globals-subset.test.js +137 -0
  131. package/dist/invariants/emitter-globals-subset.test.js.map +1 -0
  132. package/dist/invariants/numeric-proof-contract.test.d.ts +19 -0
  133. package/dist/invariants/numeric-proof-contract.test.d.ts.map +1 -0
  134. package/dist/invariants/numeric-proof-contract.test.js +565 -0
  135. package/dist/invariants/numeric-proof-contract.test.js.map +1 -0
  136. package/dist/specialization/generic-functions.test.js +376 -0
  137. package/dist/specialization/generic-functions.test.js.map +1 -1
  138. package/dist/specialization/interfaces.test.js +6 -6
  139. package/dist/specialization/interfaces.test.js.map +1 -1
  140. package/dist/specialization/substitution.d.ts.map +1 -1
  141. package/dist/specialization/substitution.js +7 -0
  142. package/dist/specialization/substitution.js.map +1 -1
  143. package/dist/specialization/type-aliases.test.js +88 -5
  144. package/dist/specialization/type-aliases.test.js.map +1 -1
  145. package/dist/statement-emitter.d.ts.map +1 -1
  146. package/dist/statement-emitter.js +5 -1
  147. package/dist/statement-emitter.js.map +1 -1
  148. package/dist/statements/blocks.d.ts +39 -1
  149. package/dist/statements/blocks.d.ts.map +1 -1
  150. package/dist/statements/blocks.js +129 -3
  151. package/dist/statements/blocks.js.map +1 -1
  152. package/dist/statements/classes/members/methods.d.ts.map +1 -1
  153. package/dist/statements/classes/members/methods.js +16 -5
  154. package/dist/statements/classes/members/methods.js.map +1 -1
  155. package/dist/statements/classes/members/properties.d.ts.map +1 -1
  156. package/dist/statements/classes/members/properties.js +10 -1
  157. package/dist/statements/classes/members/properties.js.map +1 -1
  158. package/dist/statements/classes/properties.d.ts.map +1 -1
  159. package/dist/statements/classes/properties.js +4 -0
  160. package/dist/statements/classes/properties.js.map +1 -1
  161. package/dist/statements/control/conditionals.d.ts.map +1 -1
  162. package/dist/statements/control/conditionals.js +352 -1
  163. package/dist/statements/control/conditionals.js.map +1 -1
  164. package/dist/statements/control/loops.d.ts +6 -0
  165. package/dist/statements/control/loops.d.ts.map +1 -1
  166. package/dist/statements/control/loops.js +9 -2
  167. package/dist/statements/control/loops.js.map +1 -1
  168. package/dist/statements/declarations/classes.d.ts.map +1 -1
  169. package/dist/statements/declarations/classes.js +20 -6
  170. package/dist/statements/declarations/classes.js.map +1 -1
  171. package/dist/statements/declarations/functions.d.ts.map +1 -1
  172. package/dist/statements/declarations/functions.js +98 -26
  173. package/dist/statements/declarations/functions.js.map +1 -1
  174. package/dist/statements/declarations/interfaces.d.ts.map +1 -1
  175. package/dist/statements/declarations/interfaces.js +11 -1
  176. package/dist/statements/declarations/interfaces.js.map +1 -1
  177. package/dist/statements/declarations/structs.test.js +7 -5
  178. package/dist/statements/declarations/structs.test.js.map +1 -1
  179. package/dist/statements/declarations/type-aliases.d.ts.map +1 -1
  180. package/dist/statements/declarations/type-aliases.js +18 -9
  181. package/dist/statements/declarations/type-aliases.js.map +1 -1
  182. package/dist/statements/declarations/variables.d.ts.map +1 -1
  183. package/dist/statements/declarations/variables.js +54 -2
  184. package/dist/statements/declarations/variables.js.map +1 -1
  185. package/dist/statements/index.test.js +164 -3
  186. package/dist/statements/index.test.js.map +1 -1
  187. package/dist/types/arrays.d.ts +10 -1
  188. package/dist/types/arrays.d.ts.map +1 -1
  189. package/dist/types/arrays.js +16 -1
  190. package/dist/types/arrays.js.map +1 -1
  191. package/dist/types/dictionaries.d.ts +3 -2
  192. package/dist/types/dictionaries.d.ts.map +1 -1
  193. package/dist/types/dictionaries.js +14 -8
  194. package/dist/types/dictionaries.js.map +1 -1
  195. package/dist/types/emitter.d.ts.map +1 -1
  196. package/dist/types/emitter.js +3 -0
  197. package/dist/types/emitter.js.map +1 -1
  198. package/dist/types/index.test.js +5 -2
  199. package/dist/types/index.test.js.map +1 -1
  200. package/dist/types/parameters.d.ts.map +1 -1
  201. package/dist/types/parameters.js +29 -0
  202. package/dist/types/parameters.js.map +1 -1
  203. package/dist/types/primitives.d.ts +12 -1
  204. package/dist/types/primitives.d.ts.map +1 -1
  205. package/dist/types/primitives.js +14 -1
  206. package/dist/types/primitives.js.map +1 -1
  207. package/dist/types/references.d.ts.map +1 -1
  208. package/dist/types/references.js +136 -30
  209. package/dist/types/references.js.map +1 -1
  210. package/dist/types/references.test.d.ts +11 -0
  211. package/dist/types/references.test.d.ts.map +1 -0
  212. package/dist/types/references.test.js +382 -0
  213. package/dist/types/references.test.js.map +1 -0
  214. package/dist/types/tuples.d.ts +23 -0
  215. package/dist/types/tuples.d.ts.map +1 -0
  216. package/dist/types/tuples.js +54 -0
  217. package/dist/types/tuples.js.map +1 -0
  218. package/dist/types/unions.test.js +62 -15
  219. package/dist/types/unions.test.js.map +1 -1
  220. package/dist/types.d.ts +1 -1
  221. package/dist/types.d.ts.map +1 -1
  222. package/dist/types.js.map +1 -1
  223. package/package.json +7 -3
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Generator Wrapper Class Generator
3
+ * Per spec/13-generators.md - Generate wrapper classes for bidirectional communication
4
+ *
5
+ * For TypeScript: function* accumulator(start = 0): Generator<number, void, number> { }
6
+ *
7
+ * Generates:
8
+ * 1. Exchange class: accumulator_exchange { Input?, Output }
9
+ * 2. Wrapper class: accumulator_Generator { next(), return(), throw() }
10
+ * 3. Core method: accumulator_core(exchange) returning IEnumerable<exchange>
11
+ * 4. Public method: accumulator(start = 0) returning accumulator_Generator
12
+ */
13
+ import { IrFunctionDeclaration, IrType } from "@tsonic/frontend";
14
+ import { EmitterContext } from "./types.js";
15
+ /**
16
+ * Extract Generator type arguments from a return type
17
+ * Generator<T, TReturn, TNext> -> { yieldType: T, returnType: TReturn, nextType: TNext }
18
+ */
19
+ export declare const extractGeneratorTypeArgs: (returnType: IrType | undefined, context: EmitterContext) => {
20
+ yieldType: string;
21
+ returnType: string;
22
+ nextType: string;
23
+ hasNextType: boolean;
24
+ newContext: EmitterContext;
25
+ };
26
+ /**
27
+ * Generate wrapper class for a generator function
28
+ *
29
+ * Example for: function* accumulator(start = 0): Generator<number, void, number>
30
+ *
31
+ * public sealed class accumulator_Generator
32
+ * {
33
+ * private readonly global::System.Collections.Generic.IEnumerator<accumulator_exchange> _enumerator;
34
+ * private readonly accumulator_exchange _exchange;
35
+ * private bool _done = false;
36
+ *
37
+ * public accumulator_Generator(global::System.Collections.Generic.IEnumerable<accumulator_exchange> enumerable, accumulator_exchange exchange)
38
+ * {
39
+ * _enumerator = enumerable.GetEnumerator();
40
+ * _exchange = exchange;
41
+ * }
42
+ *
43
+ * public global::Tsonic.Runtime.IteratorResult<double> next(double? value = default)
44
+ * {
45
+ * if (_done) return new global::Tsonic.Runtime.IteratorResult<double>(default!, true);
46
+ * _exchange.Input = value;
47
+ * if (_enumerator.MoveNext())
48
+ * {
49
+ * return new global::Tsonic.Runtime.IteratorResult<double>(_exchange.Output, false);
50
+ * }
51
+ * _done = true;
52
+ * return new global::Tsonic.Runtime.IteratorResult<double>(default!, true);
53
+ * }
54
+ *
55
+ * public global::Tsonic.Runtime.IteratorResult<double> @return(TReturn value = default!)
56
+ * {
57
+ * _done = true;
58
+ * _returnValue = value;
59
+ * _wasExternallyTerminated = true;
60
+ * _enumerator.Dispose();
61
+ * return new global::Tsonic.Runtime.IteratorResult<double>(default!, true);
62
+ * }
63
+ *
64
+ * public global::Tsonic.Runtime.IteratorResult<double> @throw(object e)
65
+ * {
66
+ * _done = true;
67
+ * _enumerator.Dispose();
68
+ * if (e is global::System.Exception ex) throw ex;
69
+ * throw new global::System.Exception(e?.ToString() ?? "Unknown error");
70
+ * }
71
+ * }
72
+ */
73
+ export declare const generateWrapperClass: (func: IrFunctionDeclaration, context: EmitterContext) => [string, EmitterContext];
74
+ /**
75
+ * Check if a generator function needs bidirectional support
76
+ * (i.e., has TNext type parameter that isn't undefined)
77
+ */
78
+ export declare const needsBidirectionalSupport: (func: IrFunctionDeclaration) => boolean;
79
+ /**
80
+ * Check if a generator function has a return type (TReturn is not void/undefined)
81
+ * This determines whether we need to capture the return value via closure
82
+ */
83
+ export declare const hasGeneratorReturnType: (func: IrFunctionDeclaration) => boolean;
84
+ //# sourceMappingURL=generator-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-wrapper.d.ts","sourceRoot":"","sources":["../src/generator-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAqB,MAAM,YAAY,CAAC;AAG/D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,YAAY,MAAM,GAAG,SAAS,EAC9B,SAAS,cAAc,KACtB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,cAAc,CAAC;CA4D5B,CAAC;AAKF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,qBAAqB,EAC3B,SAAS,cAAc,KACtB,CAAC,MAAM,EAAE,cAAc,CAwNzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GACpC,MAAM,qBAAqB,KAC1B,OAqBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,qBAAqB,KAC1B,OAuBF,CAAC"}
@@ -0,0 +1,312 @@
1
+ /**
2
+ * Generator Wrapper Class Generator
3
+ * Per spec/13-generators.md - Generate wrapper classes for bidirectional communication
4
+ *
5
+ * For TypeScript: function* accumulator(start = 0): Generator<number, void, number> { }
6
+ *
7
+ * Generates:
8
+ * 1. Exchange class: accumulator_exchange { Input?, Output }
9
+ * 2. Wrapper class: accumulator_Generator { next(), return(), throw() }
10
+ * 3. Core method: accumulator_core(exchange) returning IEnumerable<exchange>
11
+ * 4. Public method: accumulator(start = 0) returning accumulator_Generator
12
+ */
13
+ import { getIndent, indent } from "./types.js";
14
+ import { emitType } from "./type-emitter.js";
15
+ /**
16
+ * Extract Generator type arguments from a return type
17
+ * Generator<T, TReturn, TNext> -> { yieldType: T, returnType: TReturn, nextType: TNext }
18
+ */
19
+ export const extractGeneratorTypeArgs = (returnType, context) => {
20
+ let yieldType = "object";
21
+ let retType = "void";
22
+ let nextType = "object";
23
+ let hasNextType = false;
24
+ let currentContext = context;
25
+ if (returnType?.kind === "referenceType") {
26
+ const typeRef = returnType;
27
+ // Generator<Yield, Return, Next> or AsyncGenerator<Yield, Return, Next>
28
+ if (typeRef.typeArguments && typeRef.typeArguments.length > 0) {
29
+ const yieldTypeArg = typeRef.typeArguments[0];
30
+ if (yieldTypeArg) {
31
+ const [yt, ctx1] = emitType(yieldTypeArg, currentContext);
32
+ currentContext = ctx1;
33
+ yieldType = yt;
34
+ }
35
+ if (typeRef.typeArguments.length > 1) {
36
+ const returnTypeArg = typeRef.typeArguments[1];
37
+ if (returnTypeArg &&
38
+ returnTypeArg.kind !== "voidType" &&
39
+ !(returnTypeArg.kind === "primitiveType" &&
40
+ returnTypeArg.name === "undefined")) {
41
+ const [rt, ctx2] = emitType(returnTypeArg, currentContext);
42
+ currentContext = ctx2;
43
+ retType = rt;
44
+ }
45
+ }
46
+ if (typeRef.typeArguments.length > 2) {
47
+ const nextTypeArg = typeRef.typeArguments[2];
48
+ if (nextTypeArg &&
49
+ !(nextTypeArg.kind === "primitiveType" &&
50
+ nextTypeArg.name === "undefined")) {
51
+ const [nt, ctx3] = emitType(nextTypeArg, currentContext);
52
+ currentContext = ctx3;
53
+ nextType = nt;
54
+ hasNextType = true;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ return {
60
+ yieldType,
61
+ returnType: retType,
62
+ nextType,
63
+ hasNextType,
64
+ newContext: currentContext,
65
+ };
66
+ };
67
+ // Note: IteratorResult<T> is now defined in Tsonic.Runtime.Generators
68
+ // Use global::Tsonic.Runtime.IteratorResult<T> in generated code
69
+ /**
70
+ * Generate wrapper class for a generator function
71
+ *
72
+ * Example for: function* accumulator(start = 0): Generator<number, void, number>
73
+ *
74
+ * public sealed class accumulator_Generator
75
+ * {
76
+ * private readonly global::System.Collections.Generic.IEnumerator<accumulator_exchange> _enumerator;
77
+ * private readonly accumulator_exchange _exchange;
78
+ * private bool _done = false;
79
+ *
80
+ * public accumulator_Generator(global::System.Collections.Generic.IEnumerable<accumulator_exchange> enumerable, accumulator_exchange exchange)
81
+ * {
82
+ * _enumerator = enumerable.GetEnumerator();
83
+ * _exchange = exchange;
84
+ * }
85
+ *
86
+ * public global::Tsonic.Runtime.IteratorResult<double> next(double? value = default)
87
+ * {
88
+ * if (_done) return new global::Tsonic.Runtime.IteratorResult<double>(default!, true);
89
+ * _exchange.Input = value;
90
+ * if (_enumerator.MoveNext())
91
+ * {
92
+ * return new global::Tsonic.Runtime.IteratorResult<double>(_exchange.Output, false);
93
+ * }
94
+ * _done = true;
95
+ * return new global::Tsonic.Runtime.IteratorResult<double>(default!, true);
96
+ * }
97
+ *
98
+ * public global::Tsonic.Runtime.IteratorResult<double> @return(TReturn value = default!)
99
+ * {
100
+ * _done = true;
101
+ * _returnValue = value;
102
+ * _wasExternallyTerminated = true;
103
+ * _enumerator.Dispose();
104
+ * return new global::Tsonic.Runtime.IteratorResult<double>(default!, true);
105
+ * }
106
+ *
107
+ * public global::Tsonic.Runtime.IteratorResult<double> @throw(object e)
108
+ * {
109
+ * _done = true;
110
+ * _enumerator.Dispose();
111
+ * if (e is global::System.Exception ex) throw ex;
112
+ * throw new global::System.Exception(e?.ToString() ?? "Unknown error");
113
+ * }
114
+ * }
115
+ */
116
+ export const generateWrapperClass = (func, context) => {
117
+ const ind = getIndent(context);
118
+ const bodyInd = getIndent(indent(context));
119
+ const innerInd = getIndent(indent(indent(context)));
120
+ const parts = [];
121
+ let currentContext = context;
122
+ const wrapperName = `${func.name}_Generator`;
123
+ const exchangeName = `${func.name}_exchange`;
124
+ // Extract type arguments
125
+ const { yieldType, returnType, nextType, hasNextType, newContext } = extractGeneratorTypeArgs(func.returnType, currentContext);
126
+ currentContext = newContext;
127
+ // Use yieldType for IteratorResult
128
+ const resultType = yieldType;
129
+ parts.push(`${ind}public sealed class ${wrapperName}`);
130
+ parts.push(`${ind}{`);
131
+ // Private fields
132
+ const enumeratorType = func.isAsync
133
+ ? `global::System.Collections.Generic.IAsyncEnumerator<${exchangeName}>`
134
+ : `global::System.Collections.Generic.IEnumerator<${exchangeName}>`;
135
+ parts.push(`${bodyInd}private readonly ${enumeratorType} _enumerator;`);
136
+ parts.push(`${bodyInd}private readonly ${exchangeName} _exchange;`);
137
+ // Return value getter - captures TReturn from generator return statements (natural completion)
138
+ const hasReturnType = returnType !== "void";
139
+ if (hasReturnType) {
140
+ parts.push(`${bodyInd}private readonly global::System.Func<${returnType}> _getReturnValue;`);
141
+ // Field for external termination via @return(value)
142
+ parts.push(`${bodyInd}private ${returnType} _returnValue = default!;`);
143
+ parts.push(`${bodyInd}private bool _wasExternallyTerminated = false;`);
144
+ }
145
+ parts.push(`${bodyInd}private bool _done = false;`);
146
+ parts.push("");
147
+ // Constructor
148
+ const enumerableType = func.isAsync
149
+ ? `global::System.Collections.Generic.IAsyncEnumerable<${exchangeName}>`
150
+ : `global::System.Collections.Generic.IEnumerable<${exchangeName}>`;
151
+ // Constructor signature includes return value getter if TReturn is not void
152
+ const constructorParams = hasReturnType
153
+ ? `${enumerableType} enumerable, ${exchangeName} exchange, global::System.Func<${returnType}> getReturnValue`
154
+ : `${enumerableType} enumerable, ${exchangeName} exchange`;
155
+ parts.push(`${bodyInd}public ${wrapperName}(${constructorParams})`);
156
+ parts.push(`${bodyInd}{`);
157
+ parts.push(`${innerInd}_enumerator = enumerable.${func.isAsync ? "GetAsyncEnumerator()" : "GetEnumerator()"};`);
158
+ parts.push(`${innerInd}_exchange = exchange;`);
159
+ if (hasReturnType) {
160
+ parts.push(`${innerInd}_getReturnValue = getReturnValue;`);
161
+ }
162
+ parts.push(`${bodyInd}}`);
163
+ parts.push("");
164
+ // next() method
165
+ const nextReturnType = func.isAsync
166
+ ? `global::System.Threading.Tasks.Task<global::Tsonic.Runtime.IteratorResult<${resultType}>>`
167
+ : `global::Tsonic.Runtime.IteratorResult<${resultType}>`;
168
+ const nextParamType = hasNextType ? `${nextType}?` : "object?";
169
+ const asyncKeyword = func.isAsync ? "async " : "";
170
+ const awaitKeyword = func.isAsync ? "await " : "";
171
+ const moveNextMethod = func.isAsync ? "MoveNextAsync()" : "MoveNext()";
172
+ parts.push(`${bodyInd}public ${asyncKeyword}${nextReturnType} next(${nextParamType} value = default)`);
173
+ parts.push(`${bodyInd}{`);
174
+ // When already done, return cached result (with TReturn value if available)
175
+ // Note: JS IteratorResult has value: TYield | TReturn on completion
176
+ // We use default! for the value since the consumer should check done first
177
+ parts.push(`${innerInd}if (_done) return new global::Tsonic.Runtime.IteratorResult<${resultType}>(default!, true);`);
178
+ parts.push(`${innerInd}_exchange.Input = value;`);
179
+ parts.push(`${innerInd}if (${awaitKeyword}_enumerator.${moveNextMethod})`);
180
+ parts.push(`${innerInd}{`);
181
+ parts.push(`${innerInd} return new global::Tsonic.Runtime.IteratorResult<${resultType}>(_exchange.Output, false);`);
182
+ parts.push(`${innerInd}}`);
183
+ parts.push(`${innerInd}_done = true;`);
184
+ // When iterator completes, return default! for the value
185
+ // The return value can be accessed via the returnValue property if TReturn is not void
186
+ // Note: JavaScript IteratorResult has value: TYield | TReturn, but C# can't represent this union
187
+ parts.push(`${innerInd}return new global::Tsonic.Runtime.IteratorResult<${resultType}>(default!, true);`);
188
+ parts.push(`${bodyInd}}`);
189
+ parts.push("");
190
+ // returnValue property - provides access to TReturn when generator completes
191
+ if (hasReturnType) {
192
+ parts.push(`${bodyInd}/// <summary>`);
193
+ parts.push(`${bodyInd}/// Gets the return value of the generator after it completes.`);
194
+ parts.push(`${bodyInd}/// Only valid after the generator is done (next() returned done=true).`);
195
+ parts.push(`${bodyInd}/// If terminated via @return(value), returns that value.`);
196
+ parts.push(`${bodyInd}/// Otherwise, returns the value from the generator's return statement.`);
197
+ parts.push(`${bodyInd}/// </summary>`);
198
+ parts.push(`${bodyInd}public ${returnType} returnValue => _wasExternallyTerminated ? _returnValue : _getReturnValue();`);
199
+ parts.push("");
200
+ }
201
+ // return() method - use @ prefix since 'return' is a C# keyword
202
+ // Per JS spec: return(value) takes TReturn, not TYield
203
+ // The returned IteratorResult still uses TYield for type consistency with next()
204
+ const returnReturnType = func.isAsync
205
+ ? `global::System.Threading.Tasks.Task<global::Tsonic.Runtime.IteratorResult<${resultType}>>`
206
+ : `global::Tsonic.Runtime.IteratorResult<${resultType}>`;
207
+ // Parameter type is TReturn (returnType), not TYield (resultType)
208
+ // For void-return generators, use object? since return() can be called with no argument
209
+ const returnParamType = returnType !== "void" ? returnType : "object?";
210
+ parts.push(`${bodyInd}/// <summary>`);
211
+ parts.push(`${bodyInd}/// Terminates the generator and sets the return value.`);
212
+ parts.push(`${bodyInd}/// </summary>`);
213
+ parts.push(`${bodyInd}/// <param name="value">The return value (TReturn type)</param>`);
214
+ parts.push(`${bodyInd}/// <returns>IteratorResult with done=true and default TYield value</returns>`);
215
+ parts.push(`${bodyInd}/// <remarks>`);
216
+ parts.push(`${bodyInd}/// NOTE: The passed value does NOT appear in the returned IteratorResult.value.`);
217
+ parts.push(`${bodyInd}/// C# cannot represent JavaScript's TYield | TReturn union type.`);
218
+ parts.push(`${bodyInd}/// Access the return value via the 'returnValue' property after calling this method.`);
219
+ parts.push(`${bodyInd}/// </remarks>`);
220
+ parts.push(`${bodyInd}public ${asyncKeyword}${returnReturnType} @return(${returnParamType} value = default!)`);
221
+ parts.push(`${bodyInd}{`);
222
+ parts.push(`${innerInd}_done = true;`);
223
+ // If TReturn is not void, capture the return value for the returnValue property
224
+ if (hasReturnType) {
225
+ parts.push(`${innerInd}_returnValue = value;`);
226
+ parts.push(`${innerInd}_wasExternallyTerminated = true;`);
227
+ }
228
+ if (func.isAsync) {
229
+ parts.push(`${innerInd}await _enumerator.DisposeAsync();`);
230
+ }
231
+ else {
232
+ parts.push(`${innerInd}_enumerator.Dispose();`);
233
+ }
234
+ // Return IteratorResult with default TYield (since we're returning TReturn via returnValue property)
235
+ parts.push(`${innerInd}return new global::Tsonic.Runtime.IteratorResult<${resultType}>(default!, true);`);
236
+ parts.push(`${bodyInd}}`);
237
+ parts.push("");
238
+ // throw() method - use @ prefix since 'throw' is a C# keyword
239
+ // NOTE: Unlike JavaScript, this does NOT inject the exception at the suspended
240
+ // yield point. C# iterators don't support resumption with exceptions.
241
+ // This method terminates the generator and throws the exception externally.
242
+ // This is a semantic limitation - JS generators can catch thrown exceptions
243
+ // inside try/catch around yield, but our C# implementation cannot.
244
+ const throwReturnType = func.isAsync
245
+ ? `global::System.Threading.Tasks.Task<global::Tsonic.Runtime.IteratorResult<${resultType}>>`
246
+ : `global::Tsonic.Runtime.IteratorResult<${resultType}>`;
247
+ parts.push(`${bodyInd}/// <summary>`);
248
+ parts.push(`${bodyInd}/// Terminates the generator and throws the provided exception.`);
249
+ parts.push(`${bodyInd}/// NOTE: Unlike JavaScript, this does NOT inject the exception at the`);
250
+ parts.push(`${bodyInd}/// suspended yield point. The exception is thrown externally after`);
251
+ parts.push(`${bodyInd}/// disposing the enumerator. This is a limitation of C# iterators.`);
252
+ parts.push(`${bodyInd}/// </summary>`);
253
+ parts.push(`${bodyInd}public ${throwReturnType} @throw(object e)`);
254
+ parts.push(`${bodyInd}{`);
255
+ parts.push(`${innerInd}_done = true;`);
256
+ if (func.isAsync) {
257
+ parts.push(`${innerInd}_enumerator.DisposeAsync().AsTask().Wait();`);
258
+ }
259
+ else {
260
+ parts.push(`${innerInd}_enumerator.Dispose();`);
261
+ }
262
+ parts.push(`${innerInd}if (e is global::System.Exception ex) throw ex;`);
263
+ parts.push(`${innerInd}throw new global::System.Exception(e?.ToString() ?? "Unknown error");`);
264
+ parts.push(`${bodyInd}}`);
265
+ parts.push(`${ind}}`);
266
+ return [parts.join("\n"), currentContext];
267
+ };
268
+ /**
269
+ * Check if a generator function needs bidirectional support
270
+ * (i.e., has TNext type parameter that isn't undefined)
271
+ */
272
+ export const needsBidirectionalSupport = (func) => {
273
+ if (!func.isGenerator)
274
+ return false;
275
+ if (func.returnType?.kind === "referenceType") {
276
+ const typeRef = func.returnType;
277
+ if (typeRef.typeArguments && typeRef.typeArguments.length > 2) {
278
+ const nextTypeArg = typeRef.typeArguments[2];
279
+ // Check if TNext is not undefined
280
+ if (nextTypeArg &&
281
+ !(nextTypeArg.kind === "primitiveType" &&
282
+ nextTypeArg.name === "undefined")) {
283
+ return true;
284
+ }
285
+ }
286
+ }
287
+ return false;
288
+ };
289
+ /**
290
+ * Check if a generator function has a return type (TReturn is not void/undefined)
291
+ * This determines whether we need to capture the return value via closure
292
+ */
293
+ export const hasGeneratorReturnType = (func) => {
294
+ if (!func.isGenerator)
295
+ return false;
296
+ if (func.returnType?.kind === "referenceType") {
297
+ const typeRef = func.returnType;
298
+ // TReturn is the second type argument: Generator<Yield, Return, Next>
299
+ if (typeRef.typeArguments && typeRef.typeArguments.length > 1) {
300
+ const returnTypeArg = typeRef.typeArguments[1];
301
+ // Check if TReturn is not void/undefined
302
+ if (returnTypeArg &&
303
+ returnTypeArg.kind !== "voidType" &&
304
+ !(returnTypeArg.kind === "primitiveType" &&
305
+ returnTypeArg.name === "undefined")) {
306
+ return true;
307
+ }
308
+ }
309
+ }
310
+ return false;
311
+ };
312
+ //# sourceMappingURL=generator-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-wrapper.js","sourceRoot":"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I,CAAC,UAAU,CAAC;QAChC,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YAC7C,kCAAkC;YAClC,IACE,WAAW;gBACX,CAAC,CACC,WAAW,CAAC,IAAI,KAAK,eAAe;oBACpC,WAAW,CAAC,IAAI,KAAK,WAAW,CACjC,EACD,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,IAA2B,EAClB,EAAE;IACX,IAAI,CAAC,IAAI,CAAC,WAAW;QAAE,OAAO,KAAK,CAAC;IAEpC,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,KAAK,eAAe,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC;QAChC,sEAAsE;QACtE,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9D,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YAC/C,yCAAyC;YACzC,IACE,aAAa;gBACb,aAAa,CAAC,IAAI,KAAK,UAAU;gBACjC,CAAC,CACC,aAAa,CAAC,IAAI,KAAK,eAAe;oBACtC,aAAa,CAAC,IAAI,KAAK,WAAW,CACnC,EACD,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Tests for Generator Wrapper emission
3
+ *
4
+ * Tests:
5
+ * - extractGeneratorTypeArgs type extraction
6
+ * - needsBidirectionalSupport detection
7
+ * - generateWrapperClass output
8
+ *
9
+ * Note: IteratorResult<T> is now in Tsonic.Runtime, not emitted per-module
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=generator-wrapper.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-wrapper.test.d.ts","sourceRoot":"","sources":["../src/generator-wrapper.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Tests for Generator Wrapper emission
3
+ *
4
+ * Tests:
5
+ * - extractGeneratorTypeArgs type extraction
6
+ * - needsBidirectionalSupport detection
7
+ * - generateWrapperClass output
8
+ *
9
+ * Note: IteratorResult<T> is now in Tsonic.Runtime, not emitted per-module
10
+ */
11
+ import { describe, it } from "mocha";
12
+ import { expect } from "chai";
13
+ import { extractGeneratorTypeArgs, needsBidirectionalSupport, generateWrapperClass, } from "./generator-wrapper.js";
14
+ import { createContext } from "./types.js";
15
+ /**
16
+ * Helper to create a generator function declaration
17
+ */
18
+ const createGeneratorFunc = (name, returnType, options = {}) => ({
19
+ kind: "functionDeclaration",
20
+ name,
21
+ parameters: [],
22
+ returnType,
23
+ body: { kind: "blockStatement", statements: [] },
24
+ isAsync: options.isAsync ?? false,
25
+ isGenerator: true,
26
+ isExported: true,
27
+ });
28
+ /**
29
+ * Helper to create a Generator<Y, R, N> type
30
+ */
31
+ const createGeneratorType = (yieldType, returnType, nextType) => ({
32
+ kind: "referenceType",
33
+ name: "Generator",
34
+ typeArguments: [yieldType, returnType, nextType],
35
+ });
36
+ describe("Generator Wrapper", () => {
37
+ describe("extractGeneratorTypeArgs", () => {
38
+ it("should extract yield type from Generator<number, void, undefined>", () => {
39
+ const returnType = createGeneratorType({ kind: "primitiveType", name: "number" }, { kind: "voidType" }, { kind: "primitiveType", name: "undefined" });
40
+ const context = createContext({ rootNamespace: "Test" });
41
+ const result = extractGeneratorTypeArgs(returnType, context);
42
+ expect(result.yieldType).to.equal("double");
43
+ expect(result.returnType).to.equal("void");
44
+ expect(result.hasNextType).to.be.false;
45
+ });
46
+ it("should extract all types from Generator<string, number, boolean>", () => {
47
+ const returnType = createGeneratorType({ kind: "primitiveType", name: "string" }, { kind: "primitiveType", name: "number" }, { kind: "primitiveType", name: "boolean" });
48
+ const context = createContext({ rootNamespace: "Test" });
49
+ const result = extractGeneratorTypeArgs(returnType, context);
50
+ expect(result.yieldType).to.equal("string");
51
+ expect(result.returnType).to.equal("double");
52
+ expect(result.nextType).to.equal("bool");
53
+ expect(result.hasNextType).to.be.true;
54
+ });
55
+ it("should handle Generator with only yield type", () => {
56
+ const returnType = {
57
+ kind: "referenceType",
58
+ name: "Generator",
59
+ typeArguments: [{ kind: "primitiveType", name: "number" }],
60
+ };
61
+ const context = createContext({ rootNamespace: "Test" });
62
+ const result = extractGeneratorTypeArgs(returnType, context);
63
+ expect(result.yieldType).to.equal("double");
64
+ expect(result.returnType).to.equal("void");
65
+ expect(result.hasNextType).to.be.false;
66
+ });
67
+ it("should handle non-Generator return type", () => {
68
+ const returnType = { kind: "primitiveType", name: "number" };
69
+ const context = createContext({ rootNamespace: "Test" });
70
+ const result = extractGeneratorTypeArgs(returnType, context);
71
+ expect(result.yieldType).to.equal("object");
72
+ expect(result.returnType).to.equal("void");
73
+ expect(result.hasNextType).to.be.false;
74
+ });
75
+ it("should handle undefined return type", () => {
76
+ const context = createContext({ rootNamespace: "Test" });
77
+ const result = extractGeneratorTypeArgs(undefined, context);
78
+ expect(result.yieldType).to.equal("object");
79
+ expect(result.returnType).to.equal("void");
80
+ expect(result.hasNextType).to.be.false;
81
+ });
82
+ });
83
+ describe("needsBidirectionalSupport", () => {
84
+ it("should return true for Generator<number, void, number>", () => {
85
+ const func = createGeneratorFunc("test", createGeneratorType({ kind: "primitiveType", name: "number" }, { kind: "voidType" }, { kind: "primitiveType", name: "number" }));
86
+ expect(needsBidirectionalSupport(func)).to.be.true;
87
+ });
88
+ it("should return false for Generator<number, void, undefined>", () => {
89
+ const func = createGeneratorFunc("test", createGeneratorType({ kind: "primitiveType", name: "number" }, { kind: "voidType" }, { kind: "primitiveType", name: "undefined" }));
90
+ expect(needsBidirectionalSupport(func)).to.be.false;
91
+ });
92
+ it("should return false for Generator with only yield type", () => {
93
+ const func = createGeneratorFunc("test", {
94
+ kind: "referenceType",
95
+ name: "Generator",
96
+ typeArguments: [{ kind: "primitiveType", name: "number" }],
97
+ });
98
+ expect(needsBidirectionalSupport(func)).to.be.false;
99
+ });
100
+ it("should return false for non-generator functions", () => {
101
+ const func = {
102
+ kind: "functionDeclaration",
103
+ name: "test",
104
+ parameters: [],
105
+ returnType: { kind: "primitiveType", name: "number" },
106
+ body: { kind: "blockStatement", statements: [] },
107
+ isAsync: false,
108
+ isGenerator: false,
109
+ isExported: true,
110
+ };
111
+ expect(needsBidirectionalSupport(func)).to.be.false;
112
+ });
113
+ });
114
+ // Note: generateIteratorResultStruct tests removed - IteratorResult<T> is now in Tsonic.Runtime
115
+ describe("generateWrapperClass", () => {
116
+ it("should generate wrapper class for sync generator", () => {
117
+ const func = createGeneratorFunc("counter", createGeneratorType({ kind: "primitiveType", name: "number" }, { kind: "voidType" }, { kind: "primitiveType", name: "number" }));
118
+ const context = createContext({ rootNamespace: "Test" });
119
+ const [code] = generateWrapperClass(func, context);
120
+ // Class declaration
121
+ expect(code).to.include("public sealed class counter_Generator");
122
+ // Private fields
123
+ expect(code).to.include("private readonly");
124
+ expect(code).to.include("IEnumerator<counter_exchange>");
125
+ expect(code).to.include("_enumerator");
126
+ expect(code).to.include("counter_exchange _exchange");
127
+ expect(code).to.include("bool _done = false");
128
+ // Constructor
129
+ expect(code).to.include("public counter_Generator(");
130
+ expect(code).to.include("IEnumerable<counter_exchange> enumerable");
131
+ expect(code).to.include("GetEnumerator()");
132
+ // next() method
133
+ expect(code).to.include("public global::Tsonic.Runtime.IteratorResult<double> next(");
134
+ expect(code).to.include("double? value = default");
135
+ expect(code).to.include("_exchange.Input = value");
136
+ expect(code).to.include("MoveNext()");
137
+ expect(code).to.include("_exchange.Output");
138
+ // return() method - takes object when TReturn is void
139
+ expect(code).to.include("public global::Tsonic.Runtime.IteratorResult<double> @return(");
140
+ expect(code).to.include("Dispose()");
141
+ // throw() method
142
+ expect(code).to.include("public global::Tsonic.Runtime.IteratorResult<double> @throw(object e)");
143
+ expect(code).to.include("System.Exception");
144
+ });
145
+ it("should generate async wrapper class for async generator", () => {
146
+ const func = createGeneratorFunc("asyncCounter", {
147
+ kind: "referenceType",
148
+ name: "AsyncGenerator",
149
+ typeArguments: [
150
+ { kind: "primitiveType", name: "number" },
151
+ { kind: "voidType" },
152
+ { kind: "primitiveType", name: "number" },
153
+ ],
154
+ }, { isAsync: true });
155
+ const context = createContext({ rootNamespace: "Test" });
156
+ const [code] = generateWrapperClass(func, context);
157
+ // Async class
158
+ expect(code).to.include("public sealed class asyncCounter_Generator");
159
+ // Async enumerator
160
+ expect(code).to.include("IAsyncEnumerator<asyncCounter_exchange>");
161
+ expect(code).to.include("IAsyncEnumerable<asyncCounter_exchange>");
162
+ expect(code).to.include("GetAsyncEnumerator()");
163
+ // Async next() method
164
+ expect(code).to.include("public async global::System.Threading.Tasks.Task<global::Tsonic.Runtime.IteratorResult<double>> next(");
165
+ expect(code).to.include("await _enumerator.MoveNextAsync()");
166
+ // Async return() method
167
+ expect(code).to.include("public async");
168
+ expect(code).to.include("DisposeAsync()");
169
+ });
170
+ it("should use correct type for non-number yield type", () => {
171
+ const func = createGeneratorFunc("stringGen", createGeneratorType({ kind: "primitiveType", name: "string" }, { kind: "voidType" }, { kind: "primitiveType", name: "string" }));
172
+ const context = createContext({ rootNamespace: "Test" });
173
+ const [code] = generateWrapperClass(func, context);
174
+ expect(code).to.include("global::Tsonic.Runtime.IteratorResult<string>");
175
+ expect(code).to.include("string? value = default");
176
+ });
177
+ });
178
+ });
179
+ //# sourceMappingURL=generator-wrapper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-wrapper.test.js","sourceRoot":"","sources":["../src/generator-wrapper.test.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