@ibyar/expressions 0.8.6 → 1.1.0

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 (251) hide show
  1. package/README.md +48 -1
  2. package/api/abstract.d.ts +1 -0
  3. package/api/abstract.d.ts.map +1 -0
  4. package/api/abstract.js +12 -0
  5. package/api/abstract.js.map +1 -1
  6. package/api/class/class.d.ts +1 -0
  7. package/api/class/class.d.ts.map +1 -0
  8. package/api/class/class.js +603 -472
  9. package/api/class/class.js.map +1 -1
  10. package/api/class/decorator.d.ts +1 -0
  11. package/api/class/decorator.d.ts.map +1 -0
  12. package/api/class/decorator.js +53 -41
  13. package/api/class/decorator.js.map +1 -1
  14. package/api/computing/call.d.ts +1 -0
  15. package/api/computing/call.d.ts.map +1 -0
  16. package/api/computing/call.js +83 -69
  17. package/api/computing/call.js.map +1 -1
  18. package/api/computing/debugger.d.ts +1 -0
  19. package/api/computing/debugger.d.ts.map +1 -0
  20. package/api/computing/debugger.js +40 -28
  21. package/api/computing/debugger.js.map +1 -1
  22. package/api/computing/new.d.ts +1 -0
  23. package/api/computing/new.d.ts.map +1 -0
  24. package/api/computing/new.js +81 -68
  25. package/api/computing/new.js.map +1 -1
  26. package/api/computing/rest.d.ts +1 -0
  27. package/api/computing/rest.d.ts.map +1 -0
  28. package/api/computing/rest.js +54 -42
  29. package/api/computing/rest.js.map +1 -1
  30. package/api/computing/return.d.ts +1 -0
  31. package/api/computing/return.d.ts.map +1 -0
  32. package/api/computing/return.js +52 -40
  33. package/api/computing/return.js.map +1 -1
  34. package/api/computing/spread.d.ts +1 -0
  35. package/api/computing/spread.d.ts.map +1 -0
  36. package/api/computing/spread.js +70 -58
  37. package/api/computing/spread.js.map +1 -1
  38. package/api/computing/throw.d.ts +1 -0
  39. package/api/computing/throw.d.ts.map +1 -0
  40. package/api/computing/throw.js +216 -175
  41. package/api/computing/throw.js.map +1 -1
  42. package/api/computing/yield.d.ts +1 -0
  43. package/api/computing/yield.d.ts.map +1 -0
  44. package/api/computing/yield.js +60 -47
  45. package/api/computing/yield.js.map +1 -1
  46. package/api/definition/array.d.ts +1 -0
  47. package/api/definition/array.d.ts.map +1 -0
  48. package/api/definition/array.js +147 -122
  49. package/api/definition/array.js.map +1 -1
  50. package/api/definition/bind.d.ts +1 -0
  51. package/api/definition/bind.d.ts.map +1 -0
  52. package/api/definition/bind.js +85 -70
  53. package/api/definition/bind.js.map +1 -1
  54. package/api/definition/comment.d.ts +1 -0
  55. package/api/definition/comment.d.ts.map +1 -0
  56. package/api/definition/comment.js +44 -32
  57. package/api/definition/comment.js.map +1 -1
  58. package/api/definition/function.d.ts +1 -0
  59. package/api/definition/function.d.ts.map +1 -0
  60. package/api/definition/function.js +500 -443
  61. package/api/definition/function.js.map +1 -1
  62. package/api/definition/member.d.ts +1 -0
  63. package/api/definition/member.d.ts.map +1 -0
  64. package/api/definition/member.js +104 -89
  65. package/api/definition/member.js.map +1 -1
  66. package/api/definition/object.d.ts +1 -0
  67. package/api/definition/object.d.ts.map +1 -0
  68. package/api/definition/object.js +243 -200
  69. package/api/definition/object.js.map +1 -1
  70. package/api/definition/statement.d.ts +1 -0
  71. package/api/definition/statement.d.ts.map +1 -0
  72. package/api/definition/statement.js +56 -44
  73. package/api/definition/statement.js.map +1 -1
  74. package/api/definition/values.d.ts +1 -0
  75. package/api/definition/values.d.ts.map +1 -0
  76. package/api/definition/values.js +228 -160
  77. package/api/definition/values.js.map +1 -1
  78. package/api/deserialize/deserialize.d.ts +2 -1
  79. package/api/deserialize/deserialize.d.ts.map +1 -0
  80. package/api/deserialize/deserialize.js +5 -7
  81. package/api/deserialize/deserialize.js.map +1 -1
  82. package/api/deserialize/type-store.d.ts +1 -0
  83. package/api/deserialize/type-store.d.ts.map +1 -0
  84. package/api/expression.d.ts +1 -0
  85. package/api/expression.d.ts.map +1 -0
  86. package/api/index.d.ts +1 -0
  87. package/api/index.d.ts.map +1 -0
  88. package/api/module/common.d.ts +1 -0
  89. package/api/module/common.d.ts.map +1 -0
  90. package/api/module/common.js +63 -50
  91. package/api/module/common.js.map +1 -1
  92. package/api/module/export.d.ts +1 -0
  93. package/api/module/export.d.ts.map +1 -0
  94. package/api/module/export.js +343 -290
  95. package/api/module/export.js.map +1 -1
  96. package/api/module/import.d.ts +1 -0
  97. package/api/module/import.d.ts.map +1 -0
  98. package/api/module/import.js +318 -253
  99. package/api/module/import.js.map +1 -1
  100. package/api/operators/assignment.d.ts +1 -0
  101. package/api/operators/assignment.d.ts.map +1 -0
  102. package/api/operators/assignment.js +88 -75
  103. package/api/operators/assignment.js.map +1 -1
  104. package/api/operators/await.d.ts +1 -0
  105. package/api/operators/await.d.ts.map +1 -0
  106. package/api/operators/await.js +54 -42
  107. package/api/operators/await.js.map +1 -1
  108. package/api/operators/binary.d.ts +1 -0
  109. package/api/operators/binary.d.ts.map +1 -0
  110. package/api/operators/binary.js +78 -64
  111. package/api/operators/binary.js.map +1 -1
  112. package/api/operators/chaining.d.ts +1 -0
  113. package/api/operators/chaining.d.ts.map +1 -0
  114. package/api/operators/chaining.js +56 -44
  115. package/api/operators/chaining.js.map +1 -1
  116. package/api/operators/comma.d.ts +1 -0
  117. package/api/operators/comma.d.ts.map +1 -0
  118. package/api/operators/comma.js +53 -41
  119. package/api/operators/comma.js.map +1 -1
  120. package/api/operators/grouping.d.ts +1 -0
  121. package/api/operators/grouping.d.ts.map +1 -0
  122. package/api/operators/grouping.js +51 -39
  123. package/api/operators/grouping.js.map +1 -1
  124. package/api/operators/logical.d.ts +1 -0
  125. package/api/operators/logical.d.ts.map +1 -0
  126. package/api/operators/logical.js +51 -37
  127. package/api/operators/logical.js.map +1 -1
  128. package/api/operators/pipeline.d.ts +1 -0
  129. package/api/operators/pipeline.d.ts.map +1 -0
  130. package/api/operators/pipeline.js +95 -81
  131. package/api/operators/pipeline.js.map +1 -1
  132. package/api/operators/ternary.d.ts +1 -0
  133. package/api/operators/ternary.d.ts.map +1 -0
  134. package/api/operators/ternary.js +69 -55
  135. package/api/operators/ternary.js.map +1 -1
  136. package/api/operators/types.d.ts +1 -0
  137. package/api/operators/types.d.ts.map +1 -0
  138. package/api/operators/unary.d.ts +1 -0
  139. package/api/operators/unary.d.ts.map +1 -0
  140. package/api/operators/unary.js +97 -82
  141. package/api/operators/unary.js.map +1 -1
  142. package/api/operators/update.d.ts +1 -0
  143. package/api/operators/update.d.ts.map +1 -0
  144. package/api/operators/update.js +78 -62
  145. package/api/operators/update.js.map +1 -1
  146. package/api/program.d.ts +1 -0
  147. package/api/program.d.ts.map +1 -0
  148. package/api/program.js +53 -40
  149. package/api/program.js.map +1 -1
  150. package/api/statement/control/block.d.ts +1 -0
  151. package/api/statement/control/block.d.ts.map +1 -0
  152. package/api/statement/control/block.js +65 -53
  153. package/api/statement/control/block.js.map +1 -1
  154. package/api/statement/control/empty.d.ts +1 -1
  155. package/api/statement/control/empty.d.ts.map +1 -0
  156. package/api/statement/control/empty.js +43 -33
  157. package/api/statement/control/empty.js.map +1 -1
  158. package/api/statement/control/if.d.ts +1 -0
  159. package/api/statement/control/if.d.ts.map +1 -0
  160. package/api/statement/control/if.js +79 -65
  161. package/api/statement/control/if.js.map +1 -1
  162. package/api/statement/control/switch.d.ts +1 -0
  163. package/api/statement/control/switch.d.ts.map +1 -0
  164. package/api/statement/control/switch.js +180 -141
  165. package/api/statement/control/switch.js.map +1 -1
  166. package/api/statement/control/terminate.d.ts +1 -2
  167. package/api/statement/control/terminate.d.ts.map +1 -0
  168. package/api/statement/control/terminate.js +117 -78
  169. package/api/statement/control/terminate.js.map +1 -1
  170. package/api/statement/control/with.d.ts +1 -0
  171. package/api/statement/control/with.d.ts.map +1 -0
  172. package/api/statement/control/with.js +72 -59
  173. package/api/statement/control/with.js.map +1 -1
  174. package/api/statement/declarations/declares.d.ts +1 -0
  175. package/api/statement/declarations/declares.d.ts.map +1 -0
  176. package/api/statement/declarations/declares.js +148 -121
  177. package/api/statement/declarations/declares.js.map +1 -1
  178. package/api/statement/iterations/for.d.ts +1 -0
  179. package/api/statement/iterations/for.d.ts.map +1 -0
  180. package/api/statement/iterations/for.js +337 -277
  181. package/api/statement/iterations/for.js.map +1 -1
  182. package/api/statement/iterations/while.d.ts +1 -0
  183. package/api/statement/iterations/while.d.ts.map +1 -0
  184. package/api/statement/iterations/while.js +152 -125
  185. package/api/statement/iterations/while.js.map +1 -1
  186. package/api/utils.d.ts +1 -0
  187. package/api/utils.d.ts.map +1 -0
  188. package/index.d.ts +1 -0
  189. package/index.d.ts.map +1 -0
  190. package/package.json +5 -5
  191. package/scope/builder.d.ts +27 -0
  192. package/scope/builder.d.ts.map +1 -0
  193. package/scope/builder.js +73 -0
  194. package/scope/builder.js.map +1 -0
  195. package/scope/event.d.ts +1 -0
  196. package/scope/event.d.ts.map +1 -0
  197. package/scope/finalizer.d.ts +1 -0
  198. package/scope/finalizer.d.ts.map +1 -0
  199. package/scope/index.d.ts +1 -0
  200. package/scope/index.d.ts.map +1 -0
  201. package/scope/pool.d.ts +1 -0
  202. package/scope/pool.d.ts.map +1 -0
  203. package/scope/proxy.d.ts +1 -0
  204. package/scope/proxy.d.ts.map +1 -0
  205. package/scope/proxy.js +1 -0
  206. package/scope/proxy.js.map +1 -1
  207. package/scope/scope.d.ts +1 -0
  208. package/scope/scope.d.ts.map +1 -0
  209. package/scope/scope.js +17 -11
  210. package/scope/scope.js.map +1 -1
  211. package/scope/stack.d.ts +1 -0
  212. package/scope/stack.d.ts.map +1 -0
  213. package/scope/stack.js +22 -14
  214. package/scope/stack.js.map +1 -1
  215. package/v8/enums.d.ts +1 -0
  216. package/v8/enums.d.ts.map +1 -0
  217. package/v8/enums.js +11 -11
  218. package/v8/enums.js.map +1 -1
  219. package/v8/factory.d.ts +1 -0
  220. package/v8/factory.d.ts.map +1 -0
  221. package/v8/factory.js +3 -1
  222. package/v8/factory.js.map +1 -1
  223. package/v8/index.d.ts +1 -0
  224. package/v8/index.d.ts.map +1 -0
  225. package/v8/inline.d.ts +1 -0
  226. package/v8/inline.d.ts.map +1 -0
  227. package/v8/inline.js +9 -5
  228. package/v8/inline.js.map +1 -1
  229. package/v8/language.d.ts +1 -0
  230. package/v8/language.d.ts.map +1 -0
  231. package/v8/node.d.ts +1 -0
  232. package/v8/node.d.ts.map +1 -0
  233. package/v8/parser.d.ts +1 -0
  234. package/v8/parser.d.ts.map +1 -0
  235. package/v8/parser.js +5 -5
  236. package/v8/parser.js.map +1 -1
  237. package/v8/stream.d.ts +1 -0
  238. package/v8/stream.d.ts.map +1 -0
  239. package/v8/stream.js +17 -7
  240. package/v8/stream.js.map +1 -1
  241. package/v8/token.d.ts +1 -0
  242. package/v8/token.d.ts.map +1 -0
  243. package/v8/token.js +363 -358
  244. package/v8/token.js.map +1 -1
  245. package/visit/index.d.ts +1 -0
  246. package/visit/index.d.ts.map +1 -0
  247. package/visit/visitor.d.ts +1 -0
  248. package/visit/visitor.d.ts.map +1 -0
  249. package/v8/nodes.d.ts +0 -0
  250. package/v8/nodes.js +0 -2
  251. package/v8/nodes.js.map +0 -1
@@ -31,12 +31,10 @@
31
31
  * export { import1 as name1, import2 as name2, …, nameN } from …;
32
32
  * export { default, … } from …;
33
33
  */
34
- var ExportSpecifier_1, ExportNamedDeclaration_1, ExportDefaultDeclaration_1, ExportAllDeclaration_1;
35
- import { __decorate, __metadata } from "tslib";
34
+ import { __esDecorate, __runInitializers } from "tslib";
36
35
  import { ReactiveScope } from '../../scope/scope.js';
37
36
  import { AbstractExpressionNode } from '../abstract.js';
38
37
  import { Deserializer } from '../deserialize/deserialize.js';
39
- import { Identifier, Literal } from '../definition/values.js';
40
38
  import { ModuleSpecifier } from './common.js';
41
39
  /**
42
40
  * An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`.
@@ -52,53 +50,65 @@ import { ModuleSpecifier } from './common.js';
52
50
  * such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`,
53
51
  * and the `local` field is an `Identifier` node representing `bar`.
54
52
  */
55
- let ExportSpecifier = ExportSpecifier_1 = class ExportSpecifier extends ModuleSpecifier {
56
- static fromJSON(node, deserializer) {
57
- return new ExportSpecifier_1(deserializer(node.local), deserializer(node.exported), node.range, node.loc);
58
- }
59
- static visit(node, visitNode) {
60
- visitNode(node.local);
61
- visitNode(node.exported);
62
- }
63
- constructor(local, exported, range, loc) {
64
- super(local, range, loc);
65
- this.exported = exported;
66
- }
67
- getExported() {
68
- return this.exported;
69
- }
70
- set(stack, value) {
71
- throw new Error('Method not implemented.');
72
- }
73
- get(stack, thisContext) {
74
- throw new Error('Method not implemented.');
75
- }
76
- dependency(computed) {
77
- return [];
78
- }
79
- dependencyPath(computed) {
80
- return [];
81
- }
82
- toString() {
83
- const local = this.local.toString();
84
- const exported = this.exported.toString();
85
- if (local == exported) {
86
- return local;
87
- }
88
- return `${local} as ${exported}`;
89
- }
90
- toJson() {
91
- return {
92
- local: this.local.toJSON(),
93
- exported: this.exported.toJSON()
94
- };
95
- }
96
- };
97
- ExportSpecifier = ExportSpecifier_1 = __decorate([
98
- Deserializer('ExportSpecifier'),
99
- __metadata("design:paramtypes", [Identifier,
100
- Identifier, Array, Object])
101
- ], ExportSpecifier);
53
+ let ExportSpecifier = (() => {
54
+ let _classDecorators = [Deserializer('ExportSpecifier')];
55
+ let _classDescriptor;
56
+ let _classExtraInitializers = [];
57
+ let _classThis;
58
+ let _classSuper = ModuleSpecifier;
59
+ var ExportSpecifier = class extends _classSuper {
60
+ static { _classThis = this; }
61
+ static {
62
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
63
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
64
+ ExportSpecifier = _classThis = _classDescriptor.value;
65
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
66
+ __runInitializers(_classThis, _classExtraInitializers);
67
+ }
68
+ exported;
69
+ static fromJSON(node, deserializer) {
70
+ return new ExportSpecifier(deserializer(node.local), deserializer(node.exported), node.range, node.loc);
71
+ }
72
+ static visit(node, visitNode) {
73
+ visitNode(node.local);
74
+ visitNode(node.exported);
75
+ }
76
+ constructor(local, exported, range, loc) {
77
+ super(local, range, loc);
78
+ this.exported = exported;
79
+ }
80
+ getExported() {
81
+ return this.exported;
82
+ }
83
+ set(stack, value) {
84
+ throw new Error('Method not implemented.');
85
+ }
86
+ get(stack, thisContext) {
87
+ throw new Error('Method not implemented.');
88
+ }
89
+ dependency(computed) {
90
+ return [];
91
+ }
92
+ dependencyPath(computed) {
93
+ return [];
94
+ }
95
+ toString() {
96
+ const local = this.local.toString();
97
+ const exported = this.exported.toString();
98
+ if (local == exported) {
99
+ return local;
100
+ }
101
+ return `${local} as ${exported}`;
102
+ }
103
+ toJson() {
104
+ return {
105
+ local: this.local.toJSON(),
106
+ exported: this.exported.toJSON()
107
+ };
108
+ }
109
+ };
110
+ return ExportSpecifier = _classThis;
111
+ })();
102
112
  export { ExportSpecifier };
103
113
  /**
104
114
  * An export named declaration, e.g.,
@@ -108,267 +118,310 @@ export { ExportSpecifier };
108
118
  *
109
119
  * Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state.
110
120
  */
111
- let ExportNamedDeclaration = ExportNamedDeclaration_1 = class ExportNamedDeclaration extends AbstractExpressionNode {
112
- static fromJSON(node, deserializer) {
113
- return new ExportNamedDeclaration_1(node.specifiers.map(deserializer), node.declaration ? deserializer(node.declaration) : void 0, node.source ? deserializer(node.source) : void 0, node.assertions ? node.assertions.map(deserializer) : void 0, node.range, node.loc);
114
- }
115
- static visit(node, visitNode) {
116
- node.specifiers.map(visitNode);
117
- node.source && visitNode(node.source);
118
- node.declaration && visitNode(node.declaration);
119
- node.assertions?.forEach(visitNode);
120
- }
121
- constructor(specifiers, declaration, source, assertions, range, loc) {
122
- super(range, loc);
123
- this.specifiers = specifiers;
124
- this.declaration = declaration;
125
- this.source = source;
126
- this.assertions = assertions;
127
- }
128
- getSource() {
129
- return this.source;
130
- }
131
- getSpecifiers() {
132
- return this.specifiers;
133
- }
134
- getDeclaration() {
135
- return this.declaration;
136
- }
137
- getAssertions() {
138
- return this.assertions;
139
- }
140
- set(stack) {
141
- throw new Error(`ExportNamedDeclaration.#set() has no implementation.`);
142
- }
143
- get(stack) {
144
- if (this.declaration) {
145
- this.exportDeclaration(stack);
146
- }
147
- else if (this.source) {
148
- this.exportFromSource(stack);
149
- }
150
- else {
151
- this.exportLocal(stack);
152
- }
153
- }
154
- exportDeclaration(stack) {
155
- if (!this.declaration) {
156
- return;
157
- }
158
- this.declaration.get(stack);
159
- const declaredName = this.declaration.getDeclarationName?.();
160
- if (!declaredName) {
161
- throw new Error(`Name is not defined for ${this.declaration.toString()}`);
162
- }
163
- const value = stack.get(declaredName);
164
- stack.getModule().set(declaredName, value);
165
- }
166
- exportFromSource(stack) {
167
- if (!this.source) {
168
- return;
169
- }
170
- let importCallOptions;
171
- if (this.assertions) {
172
- const importAssertions = this.assertions
173
- .map(assertion => assertion.get(stack))
174
- .reduce((p, c) => Object.assign(p, c), {});
175
- if (importAssertions) {
176
- importCallOptions = { assert: importAssertions };
121
+ let ExportNamedDeclaration = (() => {
122
+ let _classDecorators = [Deserializer('ExportNamedDeclaration')];
123
+ let _classDescriptor;
124
+ let _classExtraInitializers = [];
125
+ let _classThis;
126
+ let _classSuper = AbstractExpressionNode;
127
+ var ExportNamedDeclaration = class extends _classSuper {
128
+ static { _classThis = this; }
129
+ static {
130
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
131
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
132
+ ExportNamedDeclaration = _classThis = _classDescriptor.value;
133
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
134
+ __runInitializers(_classThis, _classExtraInitializers);
135
+ }
136
+ specifiers;
137
+ declaration;
138
+ source;
139
+ assertions;
140
+ static fromJSON(node, deserializer) {
141
+ return new ExportNamedDeclaration(node.specifiers.map(deserializer), node.declaration ? deserializer(node.declaration) : void 0, node.source ? deserializer(node.source) : void 0, node.assertions ? node.assertions.map(deserializer) : void 0, node.range, node.loc);
142
+ }
143
+ static visit(node, visitNode) {
144
+ node.specifiers.map(visitNode);
145
+ node.source && visitNode(node.source);
146
+ node.declaration && visitNode(node.declaration);
147
+ node.assertions?.forEach(visitNode);
148
+ }
149
+ constructor(specifiers, declaration, source, assertions, range, loc) {
150
+ super(range, loc);
151
+ this.specifiers = specifiers;
152
+ this.declaration = declaration;
153
+ this.source = source;
154
+ this.assertions = assertions;
155
+ }
156
+ getSource() {
157
+ return this.source;
158
+ }
159
+ getSpecifiers() {
160
+ return this.specifiers;
161
+ }
162
+ getDeclaration() {
163
+ return this.declaration;
164
+ }
165
+ getAssertions() {
166
+ return this.assertions;
167
+ }
168
+ set(stack) {
169
+ throw new Error(`ExportNamedDeclaration.#set() has no implementation.`);
170
+ }
171
+ get(stack) {
172
+ if (this.declaration) {
173
+ this.exportDeclaration(stack);
174
+ }
175
+ else if (this.source) {
176
+ this.exportFromSource(stack);
177
+ }
178
+ else {
179
+ this.exportLocal(stack);
177
180
  }
178
181
  }
179
- const sourceModule = stack.importModule(this.source.get(), importCallOptions);
180
- const localModule = stack.getModule();
181
- this.specifiers.forEach(specifier => {
182
- const localName = specifier.getLocal().get(stack);
183
- const exportedName = specifier.getExported().get(stack);
184
- const localValue = sourceModule.get(localName);
185
- localModule.set(exportedName, localValue);
186
- const scopeSubscription = sourceModule.subscribe(localName, (newLocalValue, oldLocalValue) => {
187
- if (newLocalValue !== oldLocalValue) {
188
- localModule.set(exportedName, newLocalValue);
182
+ exportDeclaration(stack) {
183
+ if (!this.declaration) {
184
+ return;
185
+ }
186
+ this.declaration.get(stack);
187
+ const declaredName = this.declaration.getDeclarationName?.();
188
+ if (!declaredName) {
189
+ throw new Error(`Name is not defined for ${this.declaration.toString()}`);
190
+ }
191
+ const value = stack.get(declaredName);
192
+ stack.getModule().set(declaredName, value);
193
+ }
194
+ exportFromSource(stack) {
195
+ if (!this.source) {
196
+ return;
197
+ }
198
+ let importCallOptions;
199
+ if (this.assertions) {
200
+ const importAssertions = this.assertions
201
+ .map(assertion => assertion.get(stack))
202
+ .reduce((p, c) => Object.assign(p, c), {});
203
+ if (importAssertions) {
204
+ importCallOptions = { assert: importAssertions };
189
205
  }
190
- });
191
- stack.onDestroy(() => scopeSubscription.unsubscribe());
192
- });
193
- }
194
- exportLocal(stack, importCallOptions) {
195
- const localModule = stack.getModule();
196
- this.specifiers.forEach(specifier => {
197
- const localName = specifier.getLocal().get(stack);
198
- const exportedName = specifier.getExported().get(stack);
199
- const localValue = stack.get(localName);
200
- localModule.set(exportedName, localValue);
201
- const scope = stack.findScope(localName);
202
- if (scope instanceof ReactiveScope) {
203
- const scopeSubscription = scope.subscribe(localName, (newLocalValue, oldLocalValue) => {
206
+ }
207
+ const sourceModule = stack.importModule(this.source.get(), importCallOptions);
208
+ const localModule = stack.getModule();
209
+ this.specifiers.forEach(specifier => {
210
+ const localName = specifier.getLocal().get(stack);
211
+ const exportedName = specifier.getExported().get(stack);
212
+ const localValue = sourceModule.get(localName);
213
+ localModule.set(exportedName, localValue);
214
+ const scopeSubscription = sourceModule.subscribe(localName, (newLocalValue, oldLocalValue) => {
204
215
  if (newLocalValue !== oldLocalValue) {
205
216
  localModule.set(exportedName, newLocalValue);
206
217
  }
207
218
  });
208
219
  stack.onDestroy(() => scopeSubscription.unsubscribe());
220
+ });
221
+ }
222
+ exportLocal(stack, importCallOptions) {
223
+ const localModule = stack.getModule();
224
+ this.specifiers.forEach(specifier => {
225
+ const localName = specifier.getLocal().get(stack);
226
+ const exportedName = specifier.getExported().get(stack);
227
+ const localValue = stack.get(localName);
228
+ localModule.set(exportedName, localValue);
229
+ const scope = stack.findScope(localName);
230
+ if (scope instanceof ReactiveScope) {
231
+ const scopeSubscription = scope.subscribe(localName, (newLocalValue, oldLocalValue) => {
232
+ if (newLocalValue !== oldLocalValue) {
233
+ localModule.set(exportedName, newLocalValue);
234
+ }
235
+ });
236
+ stack.onDestroy(() => scopeSubscription.unsubscribe());
237
+ }
238
+ });
239
+ }
240
+ dependency(computed) {
241
+ return [];
242
+ }
243
+ dependencyPath(computed) {
244
+ return [];
245
+ }
246
+ toString() {
247
+ if (this.declaration) {
248
+ const declaration = this.declaration.toString();
249
+ return `export ${declaration}`;
209
250
  }
210
- });
211
- }
212
- dependency(computed) {
213
- return [];
214
- }
215
- dependencyPath(computed) {
216
- return [];
217
- }
218
- toString() {
219
- if (this.declaration) {
220
- const declaration = this.declaration.toString();
221
- return `export ${declaration}`;
222
- }
223
- const specifiers = this.specifiers.map(specifier => specifier.toString()).join(',');
224
- let exportStr = `export {${specifiers}}`;
225
- if (!this.source) {
226
- return `${exportStr};`;
227
- }
228
- const source = this.source.toString();
229
- return `${exportStr} from ${source}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;
230
- }
231
- toJson() {
232
- return {
233
- specifiers: this.specifiers.map(specifier => specifier.toJSON()),
234
- source: this.source?.toJSON(),
235
- declaration: this.declaration?.toJSON(),
236
- assertions: this.assertions?.map(assertion => assertion.toJSON()),
237
- };
238
- }
239
- };
240
- ExportNamedDeclaration = ExportNamedDeclaration_1 = __decorate([
241
- Deserializer('ExportNamedDeclaration'),
242
- __metadata("design:paramtypes", [Array, Object, Literal, Array, Array, Object])
243
- ], ExportNamedDeclaration);
251
+ const specifiers = this.specifiers.map(specifier => specifier.toString()).join(',');
252
+ let exportStr = `export {${specifiers}}`;
253
+ if (!this.source) {
254
+ return `${exportStr};`;
255
+ }
256
+ const source = this.source.toString();
257
+ return `${exportStr} from ${source}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;
258
+ }
259
+ toJson() {
260
+ return {
261
+ specifiers: this.specifiers.map(specifier => specifier.toJSON()),
262
+ source: this.source?.toJSON(),
263
+ declaration: this.declaration?.toJSON(),
264
+ assertions: this.assertions?.map(assertion => assertion.toJSON()),
265
+ };
266
+ }
267
+ };
268
+ return ExportNamedDeclaration = _classThis;
269
+ })();
244
270
  export { ExportNamedDeclaration };
245
271
  /**
246
272
  * An export default declaration, e.g.,
247
273
  * `export default function () {};`
248
274
  * or `export default 1;`.
249
275
  */
250
- let ExportDefaultDeclaration = ExportDefaultDeclaration_1 = class ExportDefaultDeclaration extends AbstractExpressionNode {
251
- static fromJSON(node, deserializer) {
252
- return new ExportDefaultDeclaration_1(deserializer(node.declaration), node.range, node.loc);
253
- }
254
- static visit(node, visitNode) {
255
- visitNode(node.declaration);
256
- }
257
- constructor(declaration, range, loc) {
258
- super(range, loc);
259
- this.declaration = declaration;
260
- }
261
- getDeclaration() {
262
- return this.declaration;
263
- }
264
- set(stack) {
265
- throw new Error(`ExportDefaultDeclaration.#set() has no implementation.`);
266
- }
267
- get(stack) {
268
- const declaration = this.declaration.get(stack);
269
- stack.getModule().set('default', declaration);
270
- }
271
- dependency(computed) {
272
- return [];
273
- }
274
- dependencyPath(computed) {
275
- return [];
276
- }
277
- toString() {
278
- const declaration = this.declaration.toString();
279
- return `export default ${declaration}`;
280
- }
281
- toJson() {
282
- return {
283
- declaration: this.declaration.toJSON(),
284
- };
285
- }
286
- };
287
- ExportDefaultDeclaration = ExportDefaultDeclaration_1 = __decorate([
288
- Deserializer('ExportDefaultDeclaration'),
289
- __metadata("design:paramtypes", [Object, Array, Object])
290
- ], ExportDefaultDeclaration);
276
+ let ExportDefaultDeclaration = (() => {
277
+ let _classDecorators = [Deserializer('ExportDefaultDeclaration')];
278
+ let _classDescriptor;
279
+ let _classExtraInitializers = [];
280
+ let _classThis;
281
+ let _classSuper = AbstractExpressionNode;
282
+ var ExportDefaultDeclaration = class extends _classSuper {
283
+ static { _classThis = this; }
284
+ static {
285
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
286
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
287
+ ExportDefaultDeclaration = _classThis = _classDescriptor.value;
288
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
289
+ __runInitializers(_classThis, _classExtraInitializers);
290
+ }
291
+ declaration;
292
+ static fromJSON(node, deserializer) {
293
+ return new ExportDefaultDeclaration(deserializer(node.declaration), node.range, node.loc);
294
+ }
295
+ static visit(node, visitNode) {
296
+ visitNode(node.declaration);
297
+ }
298
+ constructor(declaration, range, loc) {
299
+ super(range, loc);
300
+ this.declaration = declaration;
301
+ }
302
+ getDeclaration() {
303
+ return this.declaration;
304
+ }
305
+ set(stack) {
306
+ throw new Error(`ExportDefaultDeclaration.#set() has no implementation.`);
307
+ }
308
+ get(stack) {
309
+ const declaration = this.declaration.get(stack);
310
+ stack.getModule().set('default', declaration);
311
+ }
312
+ dependency(computed) {
313
+ return [];
314
+ }
315
+ dependencyPath(computed) {
316
+ return [];
317
+ }
318
+ toString() {
319
+ const declaration = this.declaration.toString();
320
+ return `export default ${declaration}`;
321
+ }
322
+ toJson() {
323
+ return {
324
+ declaration: this.declaration.toJSON(),
325
+ };
326
+ }
327
+ };
328
+ return ExportDefaultDeclaration = _classThis;
329
+ })();
291
330
  export { ExportDefaultDeclaration };
292
331
  /**
293
332
  * An export batch declaration, e.g., `export * from "mod";`.
294
333
  */
295
- let ExportAllDeclaration = ExportAllDeclaration_1 = class ExportAllDeclaration extends AbstractExpressionNode {
296
- static fromJSON(node, deserializer) {
297
- return new ExportAllDeclaration_1(deserializer(node.source), node.exported ? deserializer(node.exported) : void 0, node.assertions?.map(deserializer), node.range, node.loc);
298
- }
299
- static visit(node, visitNode) {
300
- visitNode(node.source);
301
- node.exported && visitNode(node.exported);
302
- node.assertions?.forEach(visitNode);
303
- }
304
- constructor(source, exported, assertions, range, loc) {
305
- super(range, loc);
306
- this.source = source;
307
- this.exported = exported;
308
- this.assertions = assertions;
309
- }
310
- getSource() {
311
- return this.source;
312
- }
313
- getExported() {
314
- return this.exported;
315
- }
316
- getAssertions() {
317
- return this.assertions;
318
- }
319
- set(stack) {
320
- throw new Error(`ExportDefaultDeclaration.#set() has no implementation.`);
321
- }
322
- get(stack) {
323
- let importCallOptions;
324
- if (this.assertions) {
325
- const importAssertions = this.assertions
326
- .map(assertion => assertion.get(stack))
327
- .reduce((p, c) => Object.assign(p, c), {});
328
- if (importAssertions) {
329
- importCallOptions = { assert: importAssertions };
330
- }
334
+ let ExportAllDeclaration = (() => {
335
+ let _classDecorators = [Deserializer('ExportAllDeclaration')];
336
+ let _classDescriptor;
337
+ let _classExtraInitializers = [];
338
+ let _classThis;
339
+ let _classSuper = AbstractExpressionNode;
340
+ var ExportAllDeclaration = class extends _classSuper {
341
+ static { _classThis = this; }
342
+ static {
343
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
344
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
345
+ ExportAllDeclaration = _classThis = _classDescriptor.value;
346
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
347
+ __runInitializers(_classThis, _classExtraInitializers);
348
+ }
349
+ source;
350
+ exported;
351
+ assertions;
352
+ static fromJSON(node, deserializer) {
353
+ return new ExportAllDeclaration(deserializer(node.source), node.exported ? deserializer(node.exported) : void 0, node.assertions?.map(deserializer), node.range, node.loc);
331
354
  }
332
- let localModule = stack.getModule();
333
- const sourceModule = stack.importModule(this.source.get(), importCallOptions);
334
- if (this.exported) {
335
- const exportedName = this.exported.get(stack);
336
- localModule.set(exportedName, {});
337
- localModule = localModule.getInnerScope(exportedName);
338
- }
339
- const properties = Object.keys(sourceModule.getContext());
340
- properties.forEach(property => {
341
- const localValue = sourceModule.get(property);
342
- localModule.set(property, localValue);
343
- const scopeSubscription = sourceModule.subscribe(property, (newLocalValue, oldLocalValue) => {
344
- if (newLocalValue !== oldLocalValue) {
345
- localModule.set(property, newLocalValue);
355
+ static visit(node, visitNode) {
356
+ visitNode(node.source);
357
+ node.exported && visitNode(node.exported);
358
+ node.assertions?.forEach(visitNode);
359
+ }
360
+ constructor(source, exported, assertions, range, loc) {
361
+ super(range, loc);
362
+ this.source = source;
363
+ this.exported = exported;
364
+ this.assertions = assertions;
365
+ }
366
+ getSource() {
367
+ return this.source;
368
+ }
369
+ getExported() {
370
+ return this.exported;
371
+ }
372
+ getAssertions() {
373
+ return this.assertions;
374
+ }
375
+ set(stack) {
376
+ throw new Error(`ExportDefaultDeclaration.#set() has no implementation.`);
377
+ }
378
+ get(stack) {
379
+ let importCallOptions;
380
+ if (this.assertions) {
381
+ const importAssertions = this.assertions
382
+ .map(assertion => assertion.get(stack))
383
+ .reduce((p, c) => Object.assign(p, c), {});
384
+ if (importAssertions) {
385
+ importCallOptions = { assert: importAssertions };
346
386
  }
387
+ }
388
+ let localModule = stack.getModule();
389
+ const sourceModule = stack.importModule(this.source.get(), importCallOptions);
390
+ if (this.exported) {
391
+ const exportedName = this.exported.get(stack);
392
+ localModule.set(exportedName, {});
393
+ localModule = localModule.getInnerScope(exportedName);
394
+ }
395
+ const properties = Object.keys(sourceModule.getContext());
396
+ properties.forEach(property => {
397
+ const localValue = sourceModule.get(property);
398
+ localModule.set(property, localValue);
399
+ const scopeSubscription = sourceModule.subscribe(property, (newLocalValue, oldLocalValue) => {
400
+ if (newLocalValue !== oldLocalValue) {
401
+ localModule.set(property, newLocalValue);
402
+ }
403
+ });
404
+ stack.onDestroy(() => scopeSubscription.unsubscribe());
347
405
  });
348
- stack.onDestroy(() => scopeSubscription.unsubscribe());
349
- });
350
- }
351
- dependency(computed) {
352
- return [];
353
- }
354
- dependencyPath(computed) {
355
- return [];
356
- }
357
- toString() {
358
- return `export *${this.exported ? ` as ${this.exported.toString()}` : ''} from ${this.source.toString()}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;
359
- }
360
- toJson() {
361
- return {
362
- source: this.source.toJSON(),
363
- exported: this.exported?.toJSON(),
364
- assertions: this.assertions?.map(assertion => assertion.toJSON()),
365
- };
366
- }
367
- };
368
- ExportAllDeclaration = ExportAllDeclaration_1 = __decorate([
369
- Deserializer('ExportAllDeclaration'),
370
- __metadata("design:paramtypes", [Literal,
371
- Identifier, Array, Array, Object])
372
- ], ExportAllDeclaration);
406
+ }
407
+ dependency(computed) {
408
+ return [];
409
+ }
410
+ dependencyPath(computed) {
411
+ return [];
412
+ }
413
+ toString() {
414
+ return `export *${this.exported ? ` as ${this.exported.toString()}` : ''} from ${this.source.toString()}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;
415
+ }
416
+ toJson() {
417
+ return {
418
+ source: this.source.toJSON(),
419
+ exported: this.exported?.toJSON(),
420
+ assertions: this.assertions?.map(assertion => assertion.toJSON()),
421
+ };
422
+ }
423
+ };
424
+ return ExportAllDeclaration = _classThis;
425
+ })();
373
426
  export { ExportAllDeclaration };
374
427
  //# sourceMappingURL=export.js.map