@ibyar/expressions 0.5.4 → 0.6.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.
- package/LICENSE +1 -1
- package/README.md +1 -0
- package/api/abstract.d.ts +3 -3
- package/api/abstract.js +7 -2
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +45 -24
- package/api/class/class.js +158 -112
- package/api/class/class.js.map +1 -1
- package/api/computing/debugger.d.ts +15 -0
- package/api/computing/debugger.js +35 -0
- package/api/computing/debugger.js.map +1 -0
- package/api/computing/rest.d.ts +4 -4
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +4 -0
- package/api/computing/return.js +5 -0
- package/api/computing/return.js.map +1 -1
- package/api/computing/throw.d.ts +4 -0
- package/api/computing/throw.js +4 -0
- package/api/computing/throw.js.map +1 -1
- package/api/definition/array.d.ts +7 -6
- package/api/definition/array.js +20 -14
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +6 -0
- package/api/definition/bind.js +6 -0
- package/api/definition/bind.js.map +1 -1
- package/api/definition/function.d.ts +35 -46
- package/api/definition/function.js +282 -299
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +9 -6
- package/api/definition/object.js +35 -5
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.js +5 -1
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +43 -50
- package/api/definition/values.js +84 -149
- package/api/definition/values.js.map +1 -1
- package/api/deserialize/deserialize.d.ts +7 -1
- package/api/deserialize/deserialize.js +9 -1
- package/api/deserialize/deserialize.js.map +1 -1
- package/api/deserialize/type-store.d.ts +2 -2
- package/api/deserialize/type-store.js.map +1 -1
- package/api/expression.d.ts +156 -12
- package/api/expression.js.map +1 -1
- package/api/index.d.ts +2 -0
- package/api/index.js +2 -0
- package/api/index.js.map +1 -1
- package/api/module/common.d.ts +29 -0
- package/api/module/common.js +71 -0
- package/api/module/common.js.map +1 -0
- package/api/module/export.d.ts +78 -9
- package/api/module/export.js +120 -15
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +56 -8
- package/api/module/import.js +62 -19
- package/api/module/import.js.map +1 -1
- package/api/operators/grouping.d.ts +7 -0
- package/api/operators/grouping.js +7 -0
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/pipeline.d.ts +12 -0
- package/api/operators/pipeline.js +12 -0
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/unary.js +3 -0
- package/api/operators/unary.js.map +1 -1
- package/api/{module/app/program.d.ts → program.d.ts} +5 -5
- package/api/{module/app/program.js → program.js} +3 -3
- package/api/program.js.map +1 -0
- package/api/statement/control/block.d.ts +5 -2
- package/api/statement/control/block.js +24 -21
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +7 -0
- package/api/statement/control/empty.js +7 -0
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +5 -0
- package/api/statement/control/if.js +5 -0
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +6 -0
- package/api/statement/control/switch.js +17 -3
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +44 -11
- package/api/statement/control/terminate.js +87 -18
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +7 -7
- package/api/statement/declarations/declares.js +1 -1
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +5 -0
- package/api/statement/iterations/for.js +35 -16
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +6 -0
- package/api/statement/iterations/while.js +25 -11
- package/api/statement/iterations/while.js.map +1 -1
- package/api/utils.d.ts +2 -0
- package/api/utils.js +3 -1
- package/api/utils.js.map +1 -1
- package/package.json +7 -5
- package/scope/event.d.ts +3 -3
- package/scope/event.js +2 -2
- package/scope/event.js.map +1 -1
- package/scope/pool.d.ts +7 -0
- package/scope/pool.js +29 -0
- package/scope/pool.js.map +1 -0
- package/scope/proxy.d.ts +6 -11
- package/scope/proxy.js +23 -52
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +161 -38
- package/scope/scope.js +260 -106
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +97 -21
- package/scope/stack.js +13 -0
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +204 -0
- package/v8/enums.js +406 -0
- package/v8/enums.js.map +1 -0
- package/v8/index.d.ts +2 -1
- package/v8/index.js +2 -1
- package/v8/index.js.map +1 -1
- package/v8/inline.d.ts +213 -0
- package/v8/inline.js +2375 -0
- package/v8/inline.js.map +1 -0
- package/v8/nodes.d.ts +8 -7
- package/v8/nodes.js +39 -64
- package/v8/nodes.js.map +1 -1
- package/v8/parser.d.ts +49 -151
- package/v8/parser.js +839 -1608
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +39 -3
- package/v8/stream.js +685 -171
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +244 -9
- package/v8/token.js +315 -47
- package/v8/token.js.map +1 -1
- package/visit/visitor.d.ts +3 -0
- package/visit/visitor.js.map +1 -1
- package/api/module/app/program.js.map +0 -1
- package/v8/app.d.ts +0 -0
- package/v8/app.js +0 -2
- package/v8/app.js.map +0 -1
package/api/module/export.js
CHANGED
|
@@ -1,10 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* There are two types of exports:
|
|
3
|
+
* 1- Named Exports (Zero or more exports per module)
|
|
4
|
+
* 2- Default Exports (One per module)
|
|
5
|
+
*
|
|
6
|
+
* // Exporting individual features
|
|
7
|
+
* export let name1, name2, …, nameN; // also var, const
|
|
8
|
+
* export let name1 = …, name2 = …, …, nameN; // also var, const
|
|
9
|
+
* export function functionName(){...}
|
|
10
|
+
* export class ClassName {...}
|
|
11
|
+
*
|
|
12
|
+
* // Export list
|
|
13
|
+
* export { name1, name2, …, nameN };
|
|
14
|
+
*
|
|
15
|
+
* // Renaming exports
|
|
16
|
+
* export { variable1 as name1, variable2 as name2, …, nameN };
|
|
17
|
+
*
|
|
18
|
+
* // Exporting destructed assignments with renaming
|
|
19
|
+
* export const { name1, name2: bar } = o;
|
|
20
|
+
*
|
|
21
|
+
* // Default exports
|
|
22
|
+
* export default expression;
|
|
23
|
+
* export default function (…) { … } // also class, function*
|
|
24
|
+
* export default function name1(…) { … } // also class, function*
|
|
25
|
+
* export { name1 as default, … };
|
|
26
|
+
*
|
|
27
|
+
* // Aggregating modules
|
|
28
|
+
* export * from …; // does not set the default export
|
|
29
|
+
* export * as name1 from …; // Draft ECMAScript® 2O21
|
|
30
|
+
* export { name1, name2, …, nameN } from …;
|
|
31
|
+
* export { import1 as name1, import2 as name2, …, nameN } from …;
|
|
32
|
+
* export { default, … } from …;
|
|
33
|
+
*/
|
|
1
34
|
var ExportSpecifier_1, ExportNamedDeclaration_1, ExportDefaultDeclaration_1, ExportAllDeclaration_1;
|
|
2
35
|
import { __decorate, __metadata } from "tslib";
|
|
3
36
|
import { ReactiveScope } from '../../scope/scope.js';
|
|
4
37
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
38
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
6
|
-
import { Identifier,
|
|
7
|
-
import { ModuleSpecifier } from './
|
|
39
|
+
import { Identifier, Literal } from '../definition/values.js';
|
|
40
|
+
import { ModuleSpecifier } from './common.js';
|
|
41
|
+
/**
|
|
42
|
+
* An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`.
|
|
43
|
+
*
|
|
44
|
+
* The `exported` field refers to the name exported in the module.
|
|
45
|
+
*
|
|
46
|
+
* The `local` field refers to the binding into the local module scope.
|
|
47
|
+
*
|
|
48
|
+
* If it is a basic named export, such as in `export {foo}`, both `exported` and `local` are equivalent `Identifier` nodes;
|
|
49
|
+
* in this case an Identifier node representing `foo`.
|
|
50
|
+
*
|
|
51
|
+
* If it is an aliased export,
|
|
52
|
+
* such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`,
|
|
53
|
+
* and the `local` field is an `Identifier` node representing `bar`.
|
|
54
|
+
*/
|
|
8
55
|
let ExportSpecifier = ExportSpecifier_1 = class ExportSpecifier extends ModuleSpecifier {
|
|
9
56
|
constructor(local, exported) {
|
|
10
57
|
super(local);
|
|
@@ -54,20 +101,30 @@ ExportSpecifier = ExportSpecifier_1 = __decorate([
|
|
|
54
101
|
__metadata("design:paramtypes", [Identifier, Identifier])
|
|
55
102
|
], ExportSpecifier);
|
|
56
103
|
export { ExportSpecifier };
|
|
104
|
+
/**
|
|
105
|
+
* An export named declaration, e.g.,
|
|
106
|
+
* `export {foo, bar};`,
|
|
107
|
+
* `export {foo} from "mod";`
|
|
108
|
+
* or `export var foo = 1;`.
|
|
109
|
+
*
|
|
110
|
+
* Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state.
|
|
111
|
+
*/
|
|
57
112
|
let ExportNamedDeclaration = ExportNamedDeclaration_1 = class ExportNamedDeclaration extends AbstractExpressionNode {
|
|
58
|
-
constructor(specifiers, source,
|
|
113
|
+
constructor(specifiers, declaration, source, assertions) {
|
|
59
114
|
super();
|
|
60
115
|
this.specifiers = specifiers;
|
|
61
|
-
this.source = source;
|
|
62
116
|
this.declaration = declaration;
|
|
117
|
+
this.source = source;
|
|
118
|
+
this.assertions = assertions;
|
|
63
119
|
}
|
|
64
120
|
static fromJSON(node, deserializer) {
|
|
65
|
-
return new ExportNamedDeclaration_1(node.specifiers.map(deserializer), node.
|
|
121
|
+
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);
|
|
66
122
|
}
|
|
67
123
|
static visit(node, visitNode) {
|
|
68
124
|
node.specifiers.map(visitNode);
|
|
69
125
|
node.source && visitNode(node.source);
|
|
70
126
|
node.declaration && visitNode(node.declaration);
|
|
127
|
+
node.assertions?.forEach(visitNode);
|
|
71
128
|
}
|
|
72
129
|
getSource() {
|
|
73
130
|
return this.source;
|
|
@@ -78,6 +135,9 @@ let ExportNamedDeclaration = ExportNamedDeclaration_1 = class ExportNamedDeclara
|
|
|
78
135
|
getDeclaration() {
|
|
79
136
|
return this.declaration;
|
|
80
137
|
}
|
|
138
|
+
getAssertions() {
|
|
139
|
+
return this.assertions;
|
|
140
|
+
}
|
|
81
141
|
shareVariables(scopeList) { }
|
|
82
142
|
set(stack) {
|
|
83
143
|
throw new Error(`ExportNamedDeclaration.#set() has no implementation.`);
|
|
@@ -108,7 +168,16 @@ let ExportNamedDeclaration = ExportNamedDeclaration_1 = class ExportNamedDeclara
|
|
|
108
168
|
if (!this.source) {
|
|
109
169
|
return;
|
|
110
170
|
}
|
|
111
|
-
|
|
171
|
+
let importCallOptions;
|
|
172
|
+
if (this.assertions) {
|
|
173
|
+
const importAssertions = this.assertions
|
|
174
|
+
.map(assertion => assertion.get(stack))
|
|
175
|
+
.reduce((p, c) => Object.assign(p, c), {});
|
|
176
|
+
if (importAssertions) {
|
|
177
|
+
importCallOptions = { assert: importAssertions };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const sourceModule = stack.importModule(this.source.get(), importCallOptions);
|
|
112
181
|
const localModule = stack.getModule();
|
|
113
182
|
this.specifiers.forEach(specifier => {
|
|
114
183
|
const localName = specifier.getLocal().get(stack);
|
|
@@ -123,7 +192,7 @@ let ExportNamedDeclaration = ExportNamedDeclaration_1 = class ExportNamedDeclara
|
|
|
123
192
|
stack.onDestroy(() => scopeSubscription.unsubscribe());
|
|
124
193
|
});
|
|
125
194
|
}
|
|
126
|
-
exportLocal(stack) {
|
|
195
|
+
exportLocal(stack, importCallOptions) {
|
|
127
196
|
const localModule = stack.getModule();
|
|
128
197
|
this.specifiers.forEach(specifier => {
|
|
129
198
|
const localName = specifier.getLocal().get(stack);
|
|
@@ -158,21 +227,27 @@ let ExportNamedDeclaration = ExportNamedDeclaration_1 = class ExportNamedDeclara
|
|
|
158
227
|
return `${exportStr};`;
|
|
159
228
|
}
|
|
160
229
|
const source = this.source.toString();
|
|
161
|
-
return `${exportStr} from ${source};`;
|
|
230
|
+
return `${exportStr} from ${source}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;
|
|
162
231
|
}
|
|
163
232
|
toJson() {
|
|
164
233
|
return {
|
|
165
234
|
specifiers: this.specifiers.map(specifier => specifier.toJSON()),
|
|
166
235
|
source: this.source?.toJSON(),
|
|
167
236
|
declaration: this.declaration?.toJSON(),
|
|
237
|
+
assertions: this.assertions?.map(assertion => assertion.toJSON()),
|
|
168
238
|
};
|
|
169
239
|
}
|
|
170
240
|
};
|
|
171
241
|
ExportNamedDeclaration = ExportNamedDeclaration_1 = __decorate([
|
|
172
242
|
Deserializer('ExportNamedDeclaration'),
|
|
173
|
-
__metadata("design:paramtypes", [Array,
|
|
243
|
+
__metadata("design:paramtypes", [Array, Object, Literal, Array])
|
|
174
244
|
], ExportNamedDeclaration);
|
|
175
245
|
export { ExportNamedDeclaration };
|
|
246
|
+
/**
|
|
247
|
+
* An export default declaration, e.g.,
|
|
248
|
+
* `export default function () {};`
|
|
249
|
+
* or `export default 1;`.
|
|
250
|
+
*/
|
|
176
251
|
let ExportDefaultDeclaration = ExportDefaultDeclaration_1 = class ExportDefaultDeclaration extends AbstractExpressionNode {
|
|
177
252
|
constructor(declaration) {
|
|
178
253
|
super();
|
|
@@ -216,27 +291,54 @@ ExportDefaultDeclaration = ExportDefaultDeclaration_1 = __decorate([
|
|
|
216
291
|
__metadata("design:paramtypes", [Object])
|
|
217
292
|
], ExportDefaultDeclaration);
|
|
218
293
|
export { ExportDefaultDeclaration };
|
|
294
|
+
/**
|
|
295
|
+
* An export batch declaration, e.g., `export * from "mod";`.
|
|
296
|
+
*/
|
|
219
297
|
let ExportAllDeclaration = ExportAllDeclaration_1 = class ExportAllDeclaration extends AbstractExpressionNode {
|
|
220
|
-
constructor(source) {
|
|
298
|
+
constructor(source, exported, assertions) {
|
|
221
299
|
super();
|
|
222
300
|
this.source = source;
|
|
301
|
+
this.exported = exported;
|
|
302
|
+
this.assertions = assertions;
|
|
223
303
|
}
|
|
224
304
|
static fromJSON(node, deserializer) {
|
|
225
|
-
return new ExportAllDeclaration_1(deserializer(node.source));
|
|
305
|
+
return new ExportAllDeclaration_1(deserializer(node.source), node.exported ? deserializer(node.exported) : void 0, node.assertions?.map(deserializer));
|
|
226
306
|
}
|
|
227
307
|
static visit(node, visitNode) {
|
|
228
308
|
visitNode(node.source);
|
|
309
|
+
node.exported && visitNode(node.exported);
|
|
310
|
+
node.assertions?.forEach(visitNode);
|
|
229
311
|
}
|
|
230
312
|
getSource() {
|
|
231
313
|
return this.source;
|
|
232
314
|
}
|
|
315
|
+
getExported() {
|
|
316
|
+
return this.exported;
|
|
317
|
+
}
|
|
318
|
+
getAssertions() {
|
|
319
|
+
return this.assertions;
|
|
320
|
+
}
|
|
233
321
|
shareVariables(scopeList) { }
|
|
234
322
|
set(stack) {
|
|
235
323
|
throw new Error(`ExportDefaultDeclaration.#set() has no implementation.`);
|
|
236
324
|
}
|
|
237
325
|
get(stack) {
|
|
238
|
-
|
|
239
|
-
|
|
326
|
+
let importCallOptions;
|
|
327
|
+
if (this.assertions) {
|
|
328
|
+
const importAssertions = this.assertions
|
|
329
|
+
.map(assertion => assertion.get(stack))
|
|
330
|
+
.reduce((p, c) => Object.assign(p, c), {});
|
|
331
|
+
if (importAssertions) {
|
|
332
|
+
importCallOptions = { assert: importAssertions };
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
let localModule = stack.getModule();
|
|
336
|
+
const sourceModule = stack.importModule(this.source.get(), importCallOptions);
|
|
337
|
+
if (this.exported) {
|
|
338
|
+
const exportedName = this.exported.get(stack);
|
|
339
|
+
localModule.set(exportedName, {});
|
|
340
|
+
localModule = localModule.getInnerScope(exportedName);
|
|
341
|
+
}
|
|
240
342
|
const properties = Object.keys(sourceModule.getContext());
|
|
241
343
|
properties.forEach(property => {
|
|
242
344
|
const localValue = sourceModule.get(property);
|
|
@@ -256,17 +358,20 @@ let ExportAllDeclaration = ExportAllDeclaration_1 = class ExportAllDeclaration e
|
|
|
256
358
|
return [];
|
|
257
359
|
}
|
|
258
360
|
toString() {
|
|
259
|
-
return `export
|
|
361
|
+
return `export *${this.exported ? ` as ${this.exported.toString()}` : ''} from ${this.source.toString()}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;
|
|
260
362
|
}
|
|
261
363
|
toJson() {
|
|
262
364
|
return {
|
|
263
365
|
source: this.source.toJSON(),
|
|
366
|
+
exported: this.exported?.toJSON(),
|
|
367
|
+
assertions: this.assertions?.map(assertion => assertion.toJSON()),
|
|
264
368
|
};
|
|
265
369
|
}
|
|
266
370
|
};
|
|
267
371
|
ExportAllDeclaration = ExportAllDeclaration_1 = __decorate([
|
|
268
372
|
Deserializer('ExportAllDeclaration'),
|
|
269
|
-
__metadata("design:paramtypes", [
|
|
373
|
+
__metadata("design:paramtypes", [Literal,
|
|
374
|
+
Identifier, Array])
|
|
270
375
|
], ExportAllDeclaration);
|
|
271
376
|
export { ExportAllDeclaration };
|
|
272
377
|
//# sourceMappingURL=export.js.map
|
package/api/module/export.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../../../src/expressions/api/module/export.ts"],"names":[],"mappings":";;AAuCA,OAAO,EAAiB,aAAa,EAAS,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoB9C,IAAa,eAAe,uBAA5B,MAAa,eAAgB,SAAQ,eAAe;IAWnD,YAAY,KA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AQ,EAAE,aAAa,CAAC,CAAC;iBACzC;YACF,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,UAAU,CAAC,QAAe;QACzB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,cAAc,CAAC,QAAe;QAC7B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,QAAQ;QACP,OAAO,iBAAiB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;IAClD,CAAC;IACD,MAAM;QACL,OAAO;YACN,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;SAC5B,CAAC;IACH,CAAC;CACD,CAAA;AAjDY,oBAAoB;IADhC,YAAY,CAAC,sBAAsB,CAAC;qCASnB,aAAa;GARlB,oBAAoB,CAiDhC;SAjDY,oBAAoB","sourcesContent":["\n/**\n * There are two types of exports:\n * 1- Named Exports (Zero or more exports per module)\n * 2- Default Exports (One per module)\n * \n * // Exporting individual features\n * export let name1, name2, …, nameN; // also var, const\n * export let name1 = …, name2 = …, …, nameN; // also var, const\n * export function functionName(){...}\n * export class ClassName {...}\n * \n * // Export list\n * export { name1, name2, …, nameN };\n * \n * // Renaming exports\n * export { variable1 as name1, variable2 as name2, …, nameN };\n * \n * // Exporting destructed assignments with renaming\n * export const { name1, name2: bar } = o;\n * \n * // Default exports\n * export default expression;\n * export default function (…) { … } // also class, function*\n * export default function name1(…) { … } // also class, function*\n * export { name1 as default, … };\n * \n * // Aggregating modules\n * export * from …; // does not set the default export\n * export * as name1 from …; // Draft ECMAScript® 2O21\n * export { name1, name2, …, nameN } from …;\n * export { import1 as name1, import2 as name2, …, nameN } from …;\n * export { default, … } from …;\n */\n\nimport type {\n\tNodeDeserializer, ExpressionNode,\n\tExpressionEventPath, VisitNodeType, CanDeclareExpression\n} from '../expression.js';\nimport { ModuleContext, ReactiveScope, Scope } from '../../scope/scope.js';\nimport { Stack } from '../../scope/stack.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { Identifier, StringLiteral } from '../definition/values.js';\nimport { ModuleSpecifier } from './import.js';\nimport { FunctionDeclaration } from '../definition/function.js';\nimport { ClassDeclaration } from '../class/class.js';\n\n\n/**\n * An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`.\n * \n * The `exported` field refers to the name exported in the module.\n * \n * The `local` field refers to the binding into the local module scope.\n * \n * If it is a basic named export, such as in `export {foo}`, both `exported` and `local` are equivalent `Identifier` nodes;\n * in this case an Identifier node representing `foo`.\n * \n * If it is an aliased export,\n * such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`,\n * and the `local` field is an `Identifier` node representing `bar`.\n */\n@Deserializer('ExportSpecifier')\nexport class ExportSpecifier extends ModuleSpecifier {\n\tstatic fromJSON(node: ExportSpecifier, deserializer: NodeDeserializer): ExportSpecifier {\n\t\treturn new ExportSpecifier(\n\t\t\tdeserializer(node.local) as Identifier,\n\t\t\tdeserializer(node.exported) as Identifier\n\t\t);\n\t}\n\tstatic visit(node: ExportSpecifier, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.local);\n\t\tvisitNode(node.exported);\n\t}\n\tconstructor(local: Identifier, private exported: Identifier) {\n\t\tsuper(local);\n\t}\n\tgetExported() {\n\t\treturn this.exported;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn [];\n\t}\n\ttoString(): string {\n\t\tconst local = this.local.toString();\n\t\tconst exported = this.exported.toString();\n\t\tif (local == exported) {\n\t\t\treturn local;\n\t\t}\n\t\treturn `${local} as ${exported}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tlocal: this.local.toJSON(),\n\t\t\texported: this.exported.toJSON()\n\t\t};\n\t}\n}\n\n\n/**\n * An export named declaration, e.g.,\n * `export {foo, bar};`,\n * `export {foo} from \"mod\";`\n * or `export var foo = 1;`.\n * \n * Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state.\n */\n@Deserializer('ExportNamedDeclaration')\nexport class ExportNamedDeclaration extends AbstractExpressionNode {\n\tstatic fromJSON(node: ExportNamedDeclaration, deserializer: NodeDeserializer): ExportNamedDeclaration {\n\t\treturn new ExportNamedDeclaration(\n\t\t\tnode.specifiers.map(deserializer) as ExportSpecifier[],\n\t\t\tnode.source ? deserializer(node.source) as StringLiteral : void 0,\n\t\t\tnode.declaration ? deserializer(node.declaration) as CanDeclareExpression : void 0,\n\t\t);\n\t}\n\tstatic visit(node: ExportNamedDeclaration, visitNode: VisitNodeType): void {\n\t\tnode.specifiers.map(visitNode);\n\t\tnode.source && visitNode(node.source);\n\t\tnode.declaration && visitNode(node.declaration);\n\t}\n\tconstructor(\n\t\tprivate specifiers: ExportSpecifier[],\n\t\tprivate source?: StringLiteral,\n\t\tprivate declaration?: CanDeclareExpression) {\n\t\tsuper();\n\t}\n\tgetSource() {\n\t\treturn this.source;\n\t}\n\tgetSpecifiers() {\n\t\treturn this.specifiers;\n\t}\n\tgetDeclaration() {\n\t\treturn this.declaration;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack) {\n\t\tthrow new Error(`ExportNamedDeclaration.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tif (this.declaration) {\n\t\t\tthis.exportDeclaration(stack);\n\t\t}\n\t\telse if (this.source) {\n\t\t\tthis.exportFromSource(stack);\n\t\t} else {\n\t\t\tthis.exportLocal(stack);\n\t\t}\n\t}\n\n\tprivate exportDeclaration(stack: Stack) {\n\t\tif (!this.declaration) {\n\t\t\treturn\n\t\t}\n\t\tconst declaration = this.declaration.get(stack);\n\t\tconst declaredName = this.declaration.getDeclarationName!();\n\t\tif (!declaredName) {\n\t\t\tthrow new Error(`Name is not defined for ${declaration.toString()}`);\n\t\t}\n\t\tstack.getModule()!.set(declaredName, declaration);\n\t}\n\tprivate exportFromSource(stack: Stack) {\n\t\tif (!this.source) {\n\t\t\treturn;\n\t\t}\n\t\tconst sourceModule = stack.importModule(this.source.get());\n\t\tconst localModule = stack.getModule()!;\n\t\tthis.specifiers.forEach(specifier => {\n\t\t\tconst localName = specifier.getLocal().get(stack);\n\t\t\tconst exportedName = specifier.getExported().get(stack);\n\t\t\tconst localValue = sourceModule.get(localName);\n\t\t\tlocalModule.set(exportedName, localValue);\n\t\t\tconst scopeSubscription = sourceModule.subscribe(localName, (newLocalValue, oldLocalValue) => {\n\t\t\t\tif (newLocalValue !== oldLocalValue) {\n\t\t\t\t\tlocalModule.set(exportedName, newLocalValue);\n\t\t\t\t}\n\t\t\t});\n\t\t\tstack.onDestroy(() => scopeSubscription.unsubscribe());\n\t\t});\n\t}\n\tprivate exportLocal(stack: Stack) {\n\t\tconst localModule = stack.getModule()!;\n\t\tthis.specifiers.forEach(specifier => {\n\t\t\tconst localName = specifier.getLocal().get(stack);\n\t\t\tconst exportedName = specifier.getExported().get(stack);\n\t\t\tconst localValue = stack.get(localName);\n\t\t\tlocalModule.set(exportedName, localValue);\n\t\t\tconst scope = stack.findScope(localName);\n\t\t\tif (scope instanceof ReactiveScope) {\n\t\t\t\tconst scopeSubscription = scope.subscribe(localName, (newLocalValue, oldLocalValue) => {\n\t\t\t\t\tif (newLocalValue !== oldLocalValue) {\n\t\t\t\t\t\tlocalModule.set(exportedName, newLocalValue);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tstack.onDestroy(() => scopeSubscription.unsubscribe());\n\t\t\t}\n\t\t});\n\t}\n\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn [];\n\t}\n\ttoString() {\n\t\tif (this.declaration) {\n\t\t\tconst declaration = this.declaration.toString();\n\t\t\treturn `export ${declaration}`;\n\t\t}\n\t\tconst specifiers = this.specifiers.map(specifier => specifier.toString()).join(',');\n\t\tlet exportStr = `export {${specifiers}}`;\n\t\tif (!this.source) {\n\t\t\treturn `${exportStr};`;\n\t\t}\n\t\tconst source = this.source.toString();\n\t\treturn `${exportStr} from ${source};`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tspecifiers: this.specifiers.map(specifier => specifier.toJSON()),\n\t\t\tsource: this.source?.toJSON(),\n\t\t\tdeclaration: this.declaration?.toJSON(),\n\t\t};\n\t}\n}\n\n\n/**\n * An export default declaration, e.g., \n * `export default function () {};`\n * or `export default 1;`.\n */\n@Deserializer('ExportDefaultDeclaration')\nexport class ExportDefaultDeclaration extends AbstractExpressionNode {\n\tstatic fromJSON(node: ExportDefaultDeclaration, deserializer: NodeDeserializer): ExportDefaultDeclaration {\n\t\treturn new ExportDefaultDeclaration(deserializer(node.declaration));\n\t}\n\tstatic visit(node: ExportDefaultDeclaration, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.declaration);\n\t}\n\tconstructor(\n\t\tprivate declaration: FunctionDeclaration | ClassDeclaration | ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetDeclaration() {\n\t\treturn this.declaration;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack) {\n\t\tthrow new Error(`ExportDefaultDeclaration.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst declaration = this.declaration.get(stack);\n\t\tstack.getModule()!.set('default', declaration);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn [];\n\t}\n\ttoString() {\n\t\tconst declaration = this.declaration.toString();\n\t\treturn `export default ${declaration}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tdeclaration: this.declaration.toJSON(),\n\t\t};\n\t}\n}\n\n/**\n * An export batch declaration, e.g., `export * from \"mod\";`.\n */\n@Deserializer('ExportAllDeclaration')\nexport class ExportAllDeclaration extends AbstractExpressionNode {\n\tstatic fromJSON(node: ExportAllDeclaration, deserializer: NodeDeserializer): ExportAllDeclaration {\n\t\treturn new ExportAllDeclaration(deserializer(node.source) as StringLiteral);\n\t}\n\tstatic visit(node: ExportAllDeclaration, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.source);\n\t}\n\tconstructor(\n\t\tprivate source: StringLiteral) {\n\t\tsuper();\n\t}\n\tgetSource() {\n\t\treturn this.source;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack) {\n\t\tthrow new Error(`ExportDefaultDeclaration.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst localModule = stack.getModule()!;\n\t\tconst sourceModule = stack.importModule(this.source.get());\n\t\tconst properties = Object.keys(sourceModule.getContext()) as (keyof ModuleContext)[];\n\n\t\tproperties.forEach(property => {\n\n\t\t\tconst localValue = sourceModule.get(property);\n\t\t\tlocalModule.set(property, localValue);\n\t\t\tconst scopeSubscription = sourceModule.subscribe(property, (newLocalValue, oldLocalValue) => {\n\t\t\t\tif (newLocalValue !== oldLocalValue) {\n\t\t\t\t\tlocalModule.set(property, newLocalValue);\n\t\t\t\t}\n\t\t\t});\n\t\t\tstack.onDestroy(() => scopeSubscription.unsubscribe());\n\t\t});\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn [];\n\t}\n\ttoString() {\n\t\treturn `export * from ${this.source.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tsource: this.source.toJSON(),\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"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SACjE,CAAC;IACH,CAAC;CACD,CAAA;AAhFY,oBAAoB;IADhC,YAAY,CAAC,sBAAsB,CAAC;qCAenB,OAAO;QACJ,UAAU;GAflB,oBAAoB,CAgFhC;SAhFY,oBAAoB","sourcesContent":["\n/**\n * There are two types of exports:\n * 1- Named Exports (Zero or more exports per module)\n * 2- Default Exports (One per module)\n * \n * // Exporting individual features\n * export let name1, name2, …, nameN; // also var, const\n * export let name1 = …, name2 = …, …, nameN; // also var, const\n * export function functionName(){...}\n * export class ClassName {...}\n * \n * // Export list\n * export { name1, name2, …, nameN };\n * \n * // Renaming exports\n * export { variable1 as name1, variable2 as name2, …, nameN };\n * \n * // Exporting destructed assignments with renaming\n * export const { name1, name2: bar } = o;\n * \n * // Default exports\n * export default expression;\n * export default function (…) { … } // also class, function*\n * export default function name1(…) { … } // also class, function*\n * export { name1 as default, … };\n * \n * // Aggregating modules\n * export * from …; // does not set the default export\n * export * as name1 from …; // Draft ECMAScript® 2O21\n * export { name1, name2, …, nameN } from …;\n * export { import1 as name1, import2 as name2, …, nameN } from …;\n * export { default, … } from …;\n */\n\nimport type {\n\tNodeDeserializer, ExpressionNode,\n\tExpressionEventPath, VisitNodeType, DeclarationExpression\n} from '../expression.js';\nimport { ModuleContext, ReactiveScope, Scope } from '../../scope/scope.js';\nimport { Stack } from '../../scope/stack.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { Identifier, Literal } from '../definition/values.js';\nimport { ImportAttribute, ModuleSpecifier } from './common.js';\nimport { FunctionDeclaration } from '../definition/function.js';\nimport { ClassDeclaration } from '../class/class.js';\n\n\n/**\n * An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`.\n * \n * The `exported` field refers to the name exported in the module.\n * \n * The `local` field refers to the binding into the local module scope.\n * \n * If it is a basic named export, such as in `export {foo}`, both `exported` and `local` are equivalent `Identifier` nodes;\n * in this case an Identifier node representing `foo`.\n * \n * If it is an aliased export,\n * such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`,\n * and the `local` field is an `Identifier` node representing `bar`.\n */\n@Deserializer('ExportSpecifier')\nexport class ExportSpecifier extends ModuleSpecifier {\n\tstatic fromJSON(node: ExportSpecifier, deserializer: NodeDeserializer): ExportSpecifier {\n\t\treturn new ExportSpecifier(\n\t\t\tdeserializer(node.local) as Identifier,\n\t\t\tdeserializer(node.exported) as Identifier\n\t\t);\n\t}\n\tstatic visit(node: ExportSpecifier, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.local);\n\t\tvisitNode(node.exported);\n\t}\n\tconstructor(local: Identifier, private exported: Identifier) {\n\t\tsuper(local);\n\t}\n\tgetExported() {\n\t\treturn this.exported;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn [];\n\t}\n\ttoString(): string {\n\t\tconst local = this.local.toString();\n\t\tconst exported = this.exported.toString();\n\t\tif (local == exported) {\n\t\t\treturn local;\n\t\t}\n\t\treturn `${local} as ${exported}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tlocal: this.local.toJSON(),\n\t\t\texported: this.exported.toJSON()\n\t\t};\n\t}\n}\n\n\n/**\n * An export named declaration, e.g.,\n * `export {foo, bar};`,\n * `export {foo} from \"mod\";`\n * or `export var foo = 1;`.\n * \n * Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state.\n */\n@Deserializer('ExportNamedDeclaration')\nexport class ExportNamedDeclaration extends AbstractExpressionNode {\n\tstatic fromJSON(node: ExportNamedDeclaration, deserializer: NodeDeserializer): ExportNamedDeclaration {\n\t\treturn new ExportNamedDeclaration(\n\t\t\tnode.specifiers.map(deserializer) as ExportSpecifier[],\n\t\t\tnode.declaration ? deserializer(node.declaration) as DeclarationExpression : void 0,\n\t\t\tnode.source ? deserializer(node.source) as Literal<string> : void 0,\n\t\t\tnode.assertions ? node.assertions.map(deserializer) as ImportAttribute[] : void 0,\n\t\t);\n\t}\n\tstatic visit(node: ExportNamedDeclaration, visitNode: VisitNodeType): void {\n\t\tnode.specifiers.map(visitNode);\n\t\tnode.source && visitNode(node.source);\n\t\tnode.declaration && visitNode(node.declaration);\n\t\tnode.assertions?.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate specifiers: ExportSpecifier[],\n\t\tprivate declaration?: DeclarationExpression,\n\t\tprivate source?: Literal<string>,\n\t\tprivate assertions?: ImportAttribute[],) {\n\t\tsuper();\n\t}\n\tgetSource() {\n\t\treturn this.source;\n\t}\n\tgetSpecifiers() {\n\t\treturn this.specifiers;\n\t}\n\tgetDeclaration() {\n\t\treturn this.declaration;\n\t}\n\tgetAssertions() {\n\t\treturn this.assertions;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack) {\n\t\tthrow new Error(`ExportNamedDeclaration.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tif (this.declaration) {\n\t\t\tthis.exportDeclaration(stack);\n\t\t}\n\t\telse if (this.source) {\n\t\t\tthis.exportFromSource(stack);\n\t\t} else {\n\t\t\tthis.exportLocal(stack);\n\t\t}\n\t}\n\n\tprivate exportDeclaration(stack: Stack) {\n\t\tif (!this.declaration) {\n\t\t\treturn\n\t\t}\n\t\tconst declaration = this.declaration.get(stack);\n\t\tconst declaredName = this.declaration.getDeclarationName!();\n\t\tif (!declaredName) {\n\t\t\tthrow new Error(`Name is not defined for ${declaration.toString()}`);\n\t\t}\n\t\tstack.getModule()!.set(declaredName, declaration);\n\t}\n\tprivate exportFromSource(stack: Stack) {\n\t\tif (!this.source) {\n\t\t\treturn;\n\t\t}\n\t\tlet importCallOptions: ImportCallOptions | undefined;\n\t\tif (this.assertions) {\n\t\t\tconst importAssertions: ImportAssertions = this.assertions\n\t\t\t\t.map(assertion => assertion.get(stack))\n\t\t\t\t.reduce((p, c) => Object.assign(p, c), {});\n\t\t\tif (importAssertions) {\n\t\t\t\timportCallOptions = { assert: importAssertions };\n\t\t\t}\n\t\t}\n\t\tconst sourceModule = stack.importModule(this.source.get(), importCallOptions);\n\t\tconst localModule = stack.getModule()!;\n\t\tthis.specifiers.forEach(specifier => {\n\t\t\tconst localName = specifier.getLocal().get(stack);\n\t\t\tconst exportedName = specifier.getExported().get(stack);\n\t\t\tconst localValue = sourceModule.get(localName);\n\t\t\tlocalModule.set(exportedName, localValue);\n\t\t\tconst scopeSubscription = sourceModule.subscribe(localName, (newLocalValue, oldLocalValue) => {\n\t\t\t\tif (newLocalValue !== oldLocalValue) {\n\t\t\t\t\tlocalModule.set(exportedName, newLocalValue);\n\t\t\t\t}\n\t\t\t});\n\t\t\tstack.onDestroy(() => scopeSubscription.unsubscribe());\n\t\t});\n\t}\n\tprivate exportLocal(stack: Stack, importCallOptions?: ImportCallOptions) {\n\t\tconst localModule = stack.getModule()!;\n\t\tthis.specifiers.forEach(specifier => {\n\t\t\tconst localName = specifier.getLocal().get(stack);\n\t\t\tconst exportedName = specifier.getExported().get(stack);\n\t\t\tconst localValue = stack.get(localName);\n\t\t\tlocalModule.set(exportedName, localValue);\n\t\t\tconst scope = stack.findScope(localName);\n\t\t\tif (scope instanceof ReactiveScope) {\n\t\t\t\tconst scopeSubscription = scope.subscribe(localName, (newLocalValue, oldLocalValue) => {\n\t\t\t\t\tif (newLocalValue !== oldLocalValue) {\n\t\t\t\t\t\tlocalModule.set(exportedName, newLocalValue);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tstack.onDestroy(() => scopeSubscription.unsubscribe());\n\t\t\t}\n\t\t});\n\t}\n\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn [];\n\t}\n\ttoString() {\n\t\tif (this.declaration) {\n\t\t\tconst declaration = this.declaration.toString();\n\t\t\treturn `export ${declaration}`;\n\t\t}\n\t\tconst specifiers = this.specifiers.map(specifier => specifier.toString()).join(',');\n\t\tlet exportStr = `export {${specifiers}}`;\n\t\tif (!this.source) {\n\t\t\treturn `${exportStr};`;\n\t\t}\n\t\tconst source = this.source.toString();\n\t\treturn `${exportStr} from ${source}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tspecifiers: this.specifiers.map(specifier => specifier.toJSON()),\n\t\t\tsource: this.source?.toJSON(),\n\t\t\tdeclaration: this.declaration?.toJSON(),\n\t\t\tassertions: this.assertions?.map(assertion => assertion.toJSON()),\n\t\t};\n\t}\n}\n\n\n/**\n * An export default declaration, e.g., \n * `export default function () {};`\n * or `export default 1;`.\n */\n@Deserializer('ExportDefaultDeclaration')\nexport class ExportDefaultDeclaration extends AbstractExpressionNode {\n\tstatic fromJSON(node: ExportDefaultDeclaration, deserializer: NodeDeserializer): ExportDefaultDeclaration {\n\t\treturn new ExportDefaultDeclaration(deserializer(node.declaration));\n\t}\n\tstatic visit(node: ExportDefaultDeclaration, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.declaration);\n\t}\n\tconstructor(\n\t\tprivate declaration: FunctionDeclaration | ClassDeclaration | ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetDeclaration() {\n\t\treturn this.declaration;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack) {\n\t\tthrow new Error(`ExportDefaultDeclaration.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst declaration = this.declaration.get(stack);\n\t\tstack.getModule()!.set('default', declaration);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn [];\n\t}\n\ttoString() {\n\t\tconst declaration = this.declaration.toString();\n\t\treturn `export default ${declaration}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tdeclaration: this.declaration.toJSON(),\n\t\t};\n\t}\n}\n\n/**\n * An export batch declaration, e.g., `export * from \"mod\";`.\n */\n@Deserializer('ExportAllDeclaration')\nexport class ExportAllDeclaration extends AbstractExpressionNode {\n\tstatic fromJSON(node: ExportAllDeclaration, deserializer: NodeDeserializer): ExportAllDeclaration {\n\t\treturn new ExportAllDeclaration(\n\t\t\tdeserializer(node.source) as Literal<string>,\n\t\t\tnode.exported ? deserializer(node.exported) as Identifier : void 0,\n\t\t\tnode.assertions?.map(deserializer) as ImportAttribute[],\n\t\t);\n\t}\n\tstatic visit(node: ExportAllDeclaration, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.source);\n\t\tnode.exported && visitNode(node.exported);\n\t\tnode.assertions?.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate source: Literal<string>,\n\t\tprivate exported?: Identifier,\n\t\tprivate assertions?: ImportAttribute[],) {\n\t\tsuper();\n\t}\n\tgetSource() {\n\t\treturn this.source;\n\t}\n\tgetExported() {\n\t\treturn this.exported;\n\t}\n\tgetAssertions() {\n\t\treturn this.assertions;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack) {\n\t\tthrow new Error(`ExportDefaultDeclaration.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tlet importCallOptions: ImportCallOptions | undefined;\n\t\tif (this.assertions) {\n\t\t\tconst importAssertions: ImportAssertions = this.assertions\n\t\t\t\t.map(assertion => assertion.get(stack))\n\t\t\t\t.reduce((p, c) => Object.assign(p, c), {});\n\t\t\tif (importAssertions) {\n\t\t\t\timportCallOptions = { assert: importAssertions };\n\t\t\t}\n\t\t}\n\t\tlet localModule: ReactiveScope<ModuleContext> = stack.getModule()!;\n\t\tconst sourceModule = stack.importModule(this.source.get(), importCallOptions);\n\n\t\tif (this.exported) {\n\t\t\tconst exportedName = this.exported.get(stack);\n\t\t\tlocalModule.set(exportedName, {});\n\t\t\tlocalModule = localModule.getInnerScope(exportedName)!;\n\t\t}\n\n\t\tconst properties = Object.keys(sourceModule.getContext()) as (keyof ModuleContext)[];\n\t\tproperties.forEach(property => {\n\n\t\t\tconst localValue = sourceModule.get(property);\n\t\t\tlocalModule.set(property, localValue);\n\t\t\tconst scopeSubscription = sourceModule.subscribe(property, (newLocalValue, oldLocalValue) => {\n\t\t\t\tif (newLocalValue !== oldLocalValue) {\n\t\t\t\t\tlocalModule.set(property, newLocalValue);\n\t\t\t\t}\n\t\t\t});\n\t\t\tstack.onDestroy(() => scopeSubscription.unsubscribe());\n\t\t});\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn [];\n\t}\n\ttoString() {\n\t\treturn `export *${this.exported ? ` as ${this.exported.toString()}` : ''} from ${this.source.toString()}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tsource: this.source.toJSON(),\n\t\t\texported: this.exported?.toJSON(),\n\t\t\tassertions: this.assertions?.map(assertion => assertion.toJSON()),\n\t\t};\n\t}\n}\n"]}
|
package/api/module/import.d.ts
CHANGED
|
@@ -3,12 +3,24 @@ import type { ModuleScope, Scope } from '../../scope/scope.js';
|
|
|
3
3
|
import type { Stack } from '../../scope/stack.js';
|
|
4
4
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
5
|
import { Identifier, Literal } from '../definition/values.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
6
|
+
import { ImportAttribute, ModuleSpecifier } from './common.js';
|
|
7
|
+
/**
|
|
8
|
+
* An imported variable binding,
|
|
9
|
+
*
|
|
10
|
+
* e.g., {foo} in import {foo} from "mod"
|
|
11
|
+
* or {foo as bar} in import {foo as bar} from "mod".
|
|
12
|
+
*
|
|
13
|
+
* The imported field refers to the name of the export imported from the module.
|
|
14
|
+
*
|
|
15
|
+
* The local field refers to the binding imported into the local module scope.
|
|
16
|
+
*
|
|
17
|
+
* If it is a basic named import, such as in import {foo} from "mod",
|
|
18
|
+
* both imported and local are equivalent Identifier nodes; in this case an Identifier node representing foo.
|
|
19
|
+
*
|
|
20
|
+
* If it is an aliased import, such as in import {foo as bar} from "mod",
|
|
21
|
+
* the imported field is an Identifier node representing foo,
|
|
22
|
+
* and the local field is an Identifier node representing bar.
|
|
23
|
+
*/
|
|
12
24
|
export declare class ImportSpecifier extends ModuleSpecifier {
|
|
13
25
|
private imported;
|
|
14
26
|
static fromJSON(node: ImportSpecifier, deserializer: NodeDeserializer): ImportSpecifier;
|
|
@@ -23,6 +35,9 @@ export declare class ImportSpecifier extends ModuleSpecifier {
|
|
|
23
35
|
toString(): string;
|
|
24
36
|
toJson(): object;
|
|
25
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A default import specifier, e.g., `foo` in `import foo from "mod.js";`.
|
|
40
|
+
*/
|
|
26
41
|
export declare class ImportDefaultSpecifier extends ModuleSpecifier {
|
|
27
42
|
static fromJSON(node: ImportDefaultSpecifier, deserializer: NodeDeserializer): ImportDefaultSpecifier;
|
|
28
43
|
static visit(node: ImportDefaultSpecifier, visitNode: VisitNodeType): void;
|
|
@@ -33,6 +48,9 @@ export declare class ImportDefaultSpecifier extends ModuleSpecifier {
|
|
|
33
48
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
34
49
|
toString(): string;
|
|
35
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* A namespace import specifier, e.g., `* as foo` in `import * as foo from "mod.js";`.
|
|
53
|
+
*/
|
|
36
54
|
export declare class ImportNamespaceSpecifier extends ModuleSpecifier {
|
|
37
55
|
static fromJSON(node: ImportNamespaceSpecifier, deserializer: NodeDeserializer): ImportNamespaceSpecifier;
|
|
38
56
|
static visit(node: ImportNamespaceSpecifier, visitNode: VisitNodeType): void;
|
|
@@ -43,16 +61,40 @@ export declare class ImportNamespaceSpecifier extends ModuleSpecifier {
|
|
|
43
61
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
44
62
|
toString(): string;
|
|
45
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* An import declaration, e.g., import foo from "mod";.
|
|
66
|
+
*
|
|
67
|
+
* import defaultExport from "module-name";
|
|
68
|
+
*
|
|
69
|
+
* import * as name from "module-name";
|
|
70
|
+
*
|
|
71
|
+
* import { export1 } from "module-name";
|
|
72
|
+
*
|
|
73
|
+
* import { export1 as alias1 } from "module-name";
|
|
74
|
+
*
|
|
75
|
+
* import { export1 , export2 } from "module-name";
|
|
76
|
+
*
|
|
77
|
+
* import { foo , bar } from "module-name/path/to/specific/un-exported/file";
|
|
78
|
+
*
|
|
79
|
+
* import { export1 , export2 as alias2 , [...] } from "module-name";
|
|
80
|
+
*
|
|
81
|
+
* import defaultExport, { export1 [ , [...] ] } from "module-name";
|
|
82
|
+
*
|
|
83
|
+
* import defaultExport, * as name from "module-name";
|
|
84
|
+
*
|
|
85
|
+
* import "module-name";
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
46
88
|
export declare class ImportDeclaration extends AbstractExpressionNode {
|
|
47
89
|
private source;
|
|
48
90
|
private specifiers?;
|
|
49
91
|
private assertions?;
|
|
50
92
|
static fromJSON(node: ImportDeclaration, deserializer: NodeDeserializer): ImportDeclaration;
|
|
51
93
|
static visit(node: ImportDeclaration, visitNode: VisitNodeType): void;
|
|
52
|
-
constructor(source: Literal<string>, specifiers?: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] | undefined, assertions?:
|
|
94
|
+
constructor(source: Literal<string>, specifiers?: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] | undefined, assertions?: ImportAttribute[] | undefined);
|
|
53
95
|
getSource(): Literal<string>;
|
|
54
96
|
getSpecifiers(): (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] | undefined;
|
|
55
|
-
getAssertions():
|
|
97
|
+
getAssertions(): ImportAttribute[] | undefined;
|
|
56
98
|
shareVariables(scopeList: Scope<any>[]): void;
|
|
57
99
|
set(stack: Stack): void;
|
|
58
100
|
get(stack: Stack): void;
|
|
@@ -61,6 +103,12 @@ export declare class ImportDeclaration extends AbstractExpressionNode {
|
|
|
61
103
|
toString(): string;
|
|
62
104
|
toJson(): object;
|
|
63
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* `ImportExpression` node represents Dynamic Imports such as `import(source)`.
|
|
108
|
+
* The `source` property is the importing source as similar to ImportDeclaration node,
|
|
109
|
+
* but it can be an arbitrary expression node.
|
|
110
|
+
* var promise = import("module-name");
|
|
111
|
+
*/
|
|
64
112
|
export declare class ImportExpression extends AbstractExpressionNode {
|
|
65
113
|
private source;
|
|
66
114
|
private attributes?;
|
package/api/module/import.js
CHANGED
|
@@ -3,20 +3,24 @@ import { __decorate, __metadata } from "tslib";
|
|
|
3
3
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
4
4
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
5
5
|
import { Identifier, Literal } from '../definition/values.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
import { ModuleSpecifier } from './common.js';
|
|
7
|
+
/**
|
|
8
|
+
* An imported variable binding,
|
|
9
|
+
*
|
|
10
|
+
* e.g., {foo} in import {foo} from "mod"
|
|
11
|
+
* or {foo as bar} in import {foo as bar} from "mod".
|
|
12
|
+
*
|
|
13
|
+
* The imported field refers to the name of the export imported from the module.
|
|
14
|
+
*
|
|
15
|
+
* The local field refers to the binding imported into the local module scope.
|
|
16
|
+
*
|
|
17
|
+
* If it is a basic named import, such as in import {foo} from "mod",
|
|
18
|
+
* both imported and local are equivalent Identifier nodes; in this case an Identifier node representing foo.
|
|
19
|
+
*
|
|
20
|
+
* If it is an aliased import, such as in import {foo as bar} from "mod",
|
|
21
|
+
* the imported field is an Identifier node representing foo,
|
|
22
|
+
* and the local field is an Identifier node representing bar.
|
|
23
|
+
*/
|
|
20
24
|
let ImportSpecifier = ImportSpecifier_1 = class ImportSpecifier extends ModuleSpecifier {
|
|
21
25
|
constructor(local, imported) {
|
|
22
26
|
super(local);
|
|
@@ -66,6 +70,9 @@ ImportSpecifier = ImportSpecifier_1 = __decorate([
|
|
|
66
70
|
__metadata("design:paramtypes", [Identifier, Identifier])
|
|
67
71
|
], ImportSpecifier);
|
|
68
72
|
export { ImportSpecifier };
|
|
73
|
+
/**
|
|
74
|
+
* A default import specifier, e.g., `foo` in `import foo from "mod.js";`.
|
|
75
|
+
*/
|
|
69
76
|
let ImportDefaultSpecifier = ImportDefaultSpecifier_1 = class ImportDefaultSpecifier extends ModuleSpecifier {
|
|
70
77
|
static fromJSON(node, deserializer) {
|
|
71
78
|
return new ImportDefaultSpecifier_1(deserializer(node.local));
|
|
@@ -95,6 +102,9 @@ ImportDefaultSpecifier = ImportDefaultSpecifier_1 = __decorate([
|
|
|
95
102
|
Deserializer('ImportDefaultSpecifier')
|
|
96
103
|
], ImportDefaultSpecifier);
|
|
97
104
|
export { ImportDefaultSpecifier };
|
|
105
|
+
/**
|
|
106
|
+
* A namespace import specifier, e.g., `* as foo` in `import * as foo from "mod.js";`.
|
|
107
|
+
*/
|
|
98
108
|
let ImportNamespaceSpecifier = ImportNamespaceSpecifier_1 = class ImportNamespaceSpecifier extends ModuleSpecifier {
|
|
99
109
|
static fromJSON(node, deserializer) {
|
|
100
110
|
return new ImportNamespaceSpecifier_1(deserializer(node.local));
|
|
@@ -124,6 +134,30 @@ ImportNamespaceSpecifier = ImportNamespaceSpecifier_1 = __decorate([
|
|
|
124
134
|
Deserializer('ImportNamespaceSpecifier')
|
|
125
135
|
], ImportNamespaceSpecifier);
|
|
126
136
|
export { ImportNamespaceSpecifier };
|
|
137
|
+
/**
|
|
138
|
+
* An import declaration, e.g., import foo from "mod";.
|
|
139
|
+
*
|
|
140
|
+
* import defaultExport from "module-name";
|
|
141
|
+
*
|
|
142
|
+
* import * as name from "module-name";
|
|
143
|
+
*
|
|
144
|
+
* import { export1 } from "module-name";
|
|
145
|
+
*
|
|
146
|
+
* import { export1 as alias1 } from "module-name";
|
|
147
|
+
*
|
|
148
|
+
* import { export1 , export2 } from "module-name";
|
|
149
|
+
*
|
|
150
|
+
* import { foo , bar } from "module-name/path/to/specific/un-exported/file";
|
|
151
|
+
*
|
|
152
|
+
* import { export1 , export2 as alias2 , [...] } from "module-name";
|
|
153
|
+
*
|
|
154
|
+
* import defaultExport, { export1 [ , [...] ] } from "module-name";
|
|
155
|
+
*
|
|
156
|
+
* import defaultExport, * as name from "module-name";
|
|
157
|
+
*
|
|
158
|
+
* import "module-name";
|
|
159
|
+
*
|
|
160
|
+
*/
|
|
127
161
|
let ImportDeclaration = ImportDeclaration_1 = class ImportDeclaration extends AbstractExpressionNode {
|
|
128
162
|
constructor(source, specifiers, assertions) {
|
|
129
163
|
super();
|
|
@@ -132,12 +166,12 @@ let ImportDeclaration = ImportDeclaration_1 = class ImportDeclaration extends Ab
|
|
|
132
166
|
this.assertions = assertions;
|
|
133
167
|
}
|
|
134
168
|
static fromJSON(node, deserializer) {
|
|
135
|
-
return new ImportDeclaration_1(deserializer(node.source), node.specifiers?.map(deserializer),
|
|
169
|
+
return new ImportDeclaration_1(deserializer(node.source), node.specifiers?.map(deserializer), node.assertions?.map(deserializer));
|
|
136
170
|
}
|
|
137
171
|
static visit(node, visitNode) {
|
|
138
172
|
visitNode(node.source);
|
|
139
173
|
node.specifiers?.forEach(visitNode);
|
|
140
|
-
node.assertions
|
|
174
|
+
node.assertions?.forEach(visitNode);
|
|
141
175
|
}
|
|
142
176
|
getSource() {
|
|
143
177
|
return this.source;
|
|
@@ -155,7 +189,9 @@ let ImportDeclaration = ImportDeclaration_1 = class ImportDeclaration extends Ab
|
|
|
155
189
|
get(stack) {
|
|
156
190
|
let importCallOptions;
|
|
157
191
|
if (this.assertions) {
|
|
158
|
-
const importAssertions = this.assertions
|
|
192
|
+
const importAssertions = this.assertions
|
|
193
|
+
.map(assertion => assertion.get(stack))
|
|
194
|
+
.reduce((p, c) => Object.assign(p, c), {});
|
|
159
195
|
if (importAssertions) {
|
|
160
196
|
importCallOptions = { assert: importAssertions };
|
|
161
197
|
}
|
|
@@ -216,20 +252,27 @@ let ImportDeclaration = ImportDeclaration_1 = class ImportDeclaration extends Ab
|
|
|
216
252
|
const importSpecifiersString = importSpecifiers.map(importSpecifier => importSpecifier.toString()).join(',');
|
|
217
253
|
parts.push(`{ ${importSpecifiersString} }`);
|
|
218
254
|
}
|
|
219
|
-
return `import ${parts.join(', ')}
|
|
255
|
+
return `import ${parts.join(', ')} from ${this.source.toString()}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;
|
|
220
256
|
}
|
|
221
257
|
toJson() {
|
|
222
258
|
return {
|
|
223
259
|
source: this.source.toJSON(),
|
|
224
260
|
specifiers: this.specifiers?.map(specifier => specifier.toJSON()),
|
|
261
|
+
assertions: this.assertions?.map(assertion => assertion.toJSON()),
|
|
225
262
|
};
|
|
226
263
|
}
|
|
227
264
|
};
|
|
228
265
|
ImportDeclaration = ImportDeclaration_1 = __decorate([
|
|
229
266
|
Deserializer('ImportDeclaration'),
|
|
230
|
-
__metadata("design:paramtypes", [Literal, Array,
|
|
267
|
+
__metadata("design:paramtypes", [Literal, Array, Array])
|
|
231
268
|
], ImportDeclaration);
|
|
232
269
|
export { ImportDeclaration };
|
|
270
|
+
/**
|
|
271
|
+
* `ImportExpression` node represents Dynamic Imports such as `import(source)`.
|
|
272
|
+
* The `source` property is the importing source as similar to ImportDeclaration node,
|
|
273
|
+
* but it can be an arbitrary expression node.
|
|
274
|
+
* var promise = import("module-name");
|
|
275
|
+
*/
|
|
233
276
|
let ImportExpression = ImportExpression_1 = class ImportExpression extends AbstractExpressionNode {
|
|
234
277
|
constructor(source, attributes) {
|
|
235
278
|
super();
|