@ibyar/expressions 0.5.2 → 0.5.62
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 +4 -3
- package/api/abstract.d.ts +5 -6
- package/api/abstract.js +8 -3
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +227 -0
- package/api/class/class.js +662 -0
- package/api/class/class.js.map +1 -0
- package/api/class/decorator.d.ts +20 -0
- package/api/class/decorator.js +48 -0
- package/api/class/decorator.js.map +1 -0
- package/api/computing/call.d.ts +3 -1
- package/api/computing/call.js +16 -4
- package/api/computing/call.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/new.d.ts +2 -1
- package/api/computing/new.js +4 -0
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +6 -6
- package/api/computing/rest.js +5 -2
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +6 -1
- package/api/computing/return.js +8 -0
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +2 -1
- package/api/computing/spread.js +5 -2
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +6 -1
- package/api/computing/throw.js +7 -0
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +2 -1
- package/api/computing/yield.js +3 -0
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +12 -12
- package/api/definition/array.js +31 -25
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +8 -2
- package/api/definition/bind.js +7 -1
- package/api/definition/bind.js.map +1 -1
- package/api/definition/function.d.ts +40 -51
- package/api/definition/function.js +292 -309
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +2 -2
- package/api/definition/member.js +1 -1
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +15 -12
- package/api/definition/object.js +43 -13
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +2 -2
- package/api/definition/statement.js +7 -3
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +44 -50
- package/api/definition/values.js +87 -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 +159 -18
- 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 +129 -25
- package/api/module/export.js +333 -58
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +114 -25
- package/api/module/import.js +279 -68
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.d.ts +2 -2
- package/api/operators/assignment.js +1 -1
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +2 -2
- package/api/operators/await.js +1 -1
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.d.ts +2 -2
- package/api/operators/binary.js +1 -1
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +2 -2
- package/api/operators/chaining.js +1 -1
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +2 -2
- package/api/operators/comma.js +2 -2
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +9 -2
- package/api/operators/grouping.js +8 -1
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.d.ts +2 -2
- package/api/operators/logical.js +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +14 -2
- package/api/operators/pipeline.js +13 -1
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +2 -2
- package/api/operators/ternary.js +1 -1
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/unary.d.ts +3 -3
- package/api/operators/unary.js +7 -3
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +2 -2
- package/api/operators/update.js +1 -1
- package/api/operators/update.js.map +1 -1
- package/api/{app/program.d.ts → program.d.ts} +8 -9
- package/api/program.js +45 -0
- package/api/program.js.map +1 -0
- package/api/statement/control/block.d.ts +8 -5
- package/api/statement/control/block.js +26 -23
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +8 -1
- package/api/statement/control/empty.js +7 -0
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +7 -2
- package/api/statement/control/if.js +6 -1
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +10 -5
- package/api/statement/control/switch.js +22 -9
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +46 -13
- package/api/statement/control/terminate.js +89 -20
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +17 -16
- package/api/statement/declarations/declares.js +24 -19
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +10 -5
- package/api/statement/iterations/for.js +42 -23
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +9 -3
- package/api/statement/iterations/while.js +27 -13
- package/api/statement/iterations/while.js.map +1 -1
- package/api/utils.d.ts +5 -0
- package/api/utils.js +4 -0
- package/api/utils.js.map +1 -0
- package/package.json +5 -5
- package/scope/finalizer.d.ts +4 -0
- package/scope/finalizer.js +11 -0
- package/scope/finalizer.js.map +1 -0
- package/scope/proxy.d.ts +5 -3
- package/scope/proxy.js +26 -26
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +108 -51
- package/scope/scope.js +72 -134
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +117 -26
- package/scope/stack.js +154 -102
- 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 -1607
- 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 +4 -7
- package/visit/visitor.js.map +1 -1
- package/api/app/class.d.ts +0 -117
- package/api/app/class.js +0 -292
- package/api/app/class.js.map +0 -1
- package/api/app/program.js +0 -39
- package/api/app/program.js.map +0 -1
- package/api/module/module.d.ts +0 -26
- package/api/module/module.js +0 -63
- package/api/module/module.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/import.d.ts
CHANGED
|
@@ -1,32 +1,100 @@
|
|
|
1
|
-
import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType
|
|
2
|
-
import type { Scope } from '../../scope/scope.js';
|
|
1
|
+
import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType } from '../expression.js';
|
|
2
|
+
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
import { Identifier, Literal } from '../definition/values.js';
|
|
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
|
+
*/
|
|
24
|
+
export declare class ImportSpecifier extends ModuleSpecifier {
|
|
25
|
+
private imported;
|
|
26
|
+
static fromJSON(node: ImportSpecifier, deserializer: NodeDeserializer): ImportSpecifier;
|
|
27
|
+
static visit(node: ImportSpecifier, visitNode: VisitNodeType): void;
|
|
28
|
+
constructor(local: Identifier, imported: Identifier);
|
|
29
|
+
getImported(): Identifier;
|
|
30
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
31
|
+
set(stack: Stack, value: any): void;
|
|
32
|
+
get(stack: Stack, thisContext?: any): void;
|
|
33
|
+
dependency(computed?: true): ExpressionNode[];
|
|
34
|
+
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
12
35
|
toString(): string;
|
|
13
|
-
|
|
14
|
-
exportName: import("../expression.js").NodeJsonType;
|
|
15
|
-
aliasName: import("../expression.js").NodeJsonType | undefined;
|
|
16
|
-
};
|
|
36
|
+
toJson(): object;
|
|
17
37
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
/**
|
|
39
|
+
* A default import specifier, e.g., `foo` in `import foo from "mod.js";`.
|
|
40
|
+
*/
|
|
41
|
+
export declare class ImportDefaultSpecifier extends ModuleSpecifier {
|
|
42
|
+
static fromJSON(node: ImportDefaultSpecifier, deserializer: NodeDeserializer): ImportDefaultSpecifier;
|
|
43
|
+
static visit(node: ImportDefaultSpecifier, visitNode: VisitNodeType): void;
|
|
44
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
45
|
+
set(stack: Stack, value: any): void;
|
|
46
|
+
get(stack: Stack, thisContext?: any): void;
|
|
47
|
+
dependency(computed?: true): ExpressionNode[];
|
|
48
|
+
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
49
|
+
toString(): string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A namespace import specifier, e.g., `* as foo` in `import * as foo from "mod.js";`.
|
|
53
|
+
*/
|
|
54
|
+
export declare class ImportNamespaceSpecifier extends ModuleSpecifier {
|
|
55
|
+
static fromJSON(node: ImportNamespaceSpecifier, deserializer: NodeDeserializer): ImportNamespaceSpecifier;
|
|
56
|
+
static visit(node: ImportNamespaceSpecifier, visitNode: VisitNodeType): void;
|
|
57
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
58
|
+
set(stack: Stack, value: any): void;
|
|
59
|
+
get(stack: Stack, thisContext?: any): void;
|
|
60
|
+
dependency(computed?: true): ExpressionNode[];
|
|
61
|
+
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
62
|
+
toString(): string;
|
|
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
|
+
*/
|
|
88
|
+
export declare class ImportDeclaration extends AbstractExpressionNode {
|
|
89
|
+
private source;
|
|
90
|
+
private specifiers?;
|
|
91
|
+
private assertions?;
|
|
92
|
+
static fromJSON(node: ImportDeclaration, deserializer: NodeDeserializer): ImportDeclaration;
|
|
93
|
+
static visit(node: ImportDeclaration, visitNode: VisitNodeType): void;
|
|
94
|
+
constructor(source: Literal<string>, specifiers?: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] | undefined, assertions?: ImportAttribute[] | undefined);
|
|
95
|
+
getSource(): Literal<string>;
|
|
96
|
+
getSpecifiers(): (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] | undefined;
|
|
97
|
+
getAssertions(): ImportAttribute[] | undefined;
|
|
30
98
|
shareVariables(scopeList: Scope<any>[]): void;
|
|
31
99
|
set(stack: Stack): void;
|
|
32
100
|
get(stack: Stack): void;
|
|
@@ -35,3 +103,24 @@ export declare class ImportNode extends AbstractExpressionNode {
|
|
|
35
103
|
toString(): string;
|
|
36
104
|
toJson(): object;
|
|
37
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
|
+
*/
|
|
112
|
+
export declare class ImportExpression extends AbstractExpressionNode {
|
|
113
|
+
private source;
|
|
114
|
+
private attributes?;
|
|
115
|
+
static fromJSON(node: ImportExpression, deserializer: NodeDeserializer): ImportExpression;
|
|
116
|
+
static visit(node: ImportExpression, visitNode: VisitNodeType): void;
|
|
117
|
+
constructor(source: Literal<string>, attributes?: ExpressionNode | undefined);
|
|
118
|
+
getSource(): Literal<string>;
|
|
119
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
120
|
+
set(stack: Stack): void;
|
|
121
|
+
get(stack: Stack): Promise<ModuleScope>;
|
|
122
|
+
dependency(computed?: true): ExpressionNode[];
|
|
123
|
+
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
124
|
+
toString(): string;
|
|
125
|
+
toJson(): object;
|
|
126
|
+
}
|
package/api/module/import.js
CHANGED
|
@@ -1,70 +1,232 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ImportSpecifier_1, ImportDefaultSpecifier_1, ImportNamespaceSpecifier_1, ImportDeclaration_1, ImportExpression_1;
|
|
2
2
|
import { __decorate, __metadata } from "tslib";
|
|
3
3
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
4
4
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { Identifier, Literal } from '../definition/values.js';
|
|
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
|
+
*/
|
|
24
|
+
let ImportSpecifier = ImportSpecifier_1 = class ImportSpecifier extends ModuleSpecifier {
|
|
25
|
+
constructor(local, imported) {
|
|
26
|
+
super(local);
|
|
27
|
+
this.imported = imported;
|
|
9
28
|
}
|
|
10
|
-
static
|
|
11
|
-
|
|
12
|
-
|
|
29
|
+
static fromJSON(node, deserializer) {
|
|
30
|
+
return new ImportSpecifier_1(deserializer(node.local), deserializer(node.imported));
|
|
31
|
+
}
|
|
32
|
+
static visit(node, visitNode) {
|
|
33
|
+
visitNode(node.local);
|
|
34
|
+
visitNode(node.imported);
|
|
35
|
+
}
|
|
36
|
+
getImported() {
|
|
37
|
+
return this.imported;
|
|
38
|
+
}
|
|
39
|
+
shareVariables(scopeList) {
|
|
40
|
+
}
|
|
41
|
+
set(stack, value) {
|
|
42
|
+
throw new Error('Method not implemented.');
|
|
13
43
|
}
|
|
14
|
-
get
|
|
15
|
-
|
|
44
|
+
get(stack, thisContext) {
|
|
45
|
+
throw new Error('Method not implemented.');
|
|
16
46
|
}
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
dependency(computed) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
dependencyPath(computed) {
|
|
51
|
+
return [];
|
|
19
52
|
}
|
|
20
53
|
toString() {
|
|
21
|
-
|
|
22
|
-
|
|
54
|
+
const local = this.local.toString();
|
|
55
|
+
const imported = this.imported.toString();
|
|
56
|
+
if (local == imported) {
|
|
57
|
+
return local;
|
|
23
58
|
}
|
|
24
|
-
return
|
|
59
|
+
return `${imported} as ${local}`;
|
|
25
60
|
}
|
|
26
|
-
|
|
61
|
+
toJson() {
|
|
27
62
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
63
|
+
local: this.local.toJSON(),
|
|
64
|
+
imported: this.imported.toJSON()
|
|
30
65
|
};
|
|
31
66
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
67
|
+
};
|
|
68
|
+
ImportSpecifier = ImportSpecifier_1 = __decorate([
|
|
69
|
+
Deserializer('ImportSpecifier'),
|
|
70
|
+
__metadata("design:paramtypes", [Identifier, Identifier])
|
|
71
|
+
], ImportSpecifier);
|
|
72
|
+
export { ImportSpecifier };
|
|
73
|
+
/**
|
|
74
|
+
* A default import specifier, e.g., `foo` in `import foo from "mod.js";`.
|
|
75
|
+
*/
|
|
76
|
+
let ImportDefaultSpecifier = ImportDefaultSpecifier_1 = class ImportDefaultSpecifier extends ModuleSpecifier {
|
|
77
|
+
static fromJSON(node, deserializer) {
|
|
78
|
+
return new ImportDefaultSpecifier_1(deserializer(node.local));
|
|
79
|
+
}
|
|
80
|
+
static visit(node, visitNode) {
|
|
81
|
+
visitNode(node.local);
|
|
82
|
+
}
|
|
83
|
+
shareVariables(scopeList) {
|
|
84
|
+
}
|
|
85
|
+
set(stack, value) {
|
|
86
|
+
throw new Error('Method not implemented.');
|
|
87
|
+
}
|
|
88
|
+
get(stack, thisContext) {
|
|
89
|
+
throw new Error('Method not implemented.');
|
|
40
90
|
}
|
|
91
|
+
dependency(computed) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
dependencyPath(computed) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
toString() {
|
|
98
|
+
return this.local.toString();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
ImportDefaultSpecifier = ImportDefaultSpecifier_1 = __decorate([
|
|
102
|
+
Deserializer('ImportDefaultSpecifier')
|
|
103
|
+
], ImportDefaultSpecifier);
|
|
104
|
+
export { ImportDefaultSpecifier };
|
|
105
|
+
/**
|
|
106
|
+
* A namespace import specifier, e.g., `* as foo` in `import * as foo from "mod.js";`.
|
|
107
|
+
*/
|
|
108
|
+
let ImportNamespaceSpecifier = ImportNamespaceSpecifier_1 = class ImportNamespaceSpecifier extends ModuleSpecifier {
|
|
41
109
|
static fromJSON(node, deserializer) {
|
|
42
|
-
return new
|
|
110
|
+
return new ImportNamespaceSpecifier_1(deserializer(node.local));
|
|
43
111
|
}
|
|
44
|
-
static visit(node, visitNode
|
|
45
|
-
visitNode(node.
|
|
46
|
-
node.defaultExport && visitNode(node.defaultExport);
|
|
47
|
-
node.namespace && visitNode(node.namespace);
|
|
48
|
-
node.importAliasNames?.map(expo => ImportAliasName.visit(expo, visitNode, visitNodeList));
|
|
112
|
+
static visit(node, visitNode) {
|
|
113
|
+
visitNode(node.local);
|
|
49
114
|
}
|
|
50
|
-
|
|
51
|
-
return this.moduleName;
|
|
115
|
+
shareVariables(scopeList) {
|
|
52
116
|
}
|
|
53
|
-
|
|
54
|
-
|
|
117
|
+
set(stack, value) {
|
|
118
|
+
throw new Error('Method not implemented.');
|
|
55
119
|
}
|
|
56
|
-
|
|
57
|
-
|
|
120
|
+
get(stack, thisContext) {
|
|
121
|
+
throw new Error('Method not implemented.');
|
|
58
122
|
}
|
|
59
|
-
|
|
60
|
-
return
|
|
123
|
+
dependency(computed) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
dependencyPath(computed) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
toString() {
|
|
130
|
+
return `* as ${this.local.toString()}`;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
ImportNamespaceSpecifier = ImportNamespaceSpecifier_1 = __decorate([
|
|
134
|
+
Deserializer('ImportNamespaceSpecifier')
|
|
135
|
+
], ImportNamespaceSpecifier);
|
|
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
|
+
*/
|
|
161
|
+
let ImportDeclaration = ImportDeclaration_1 = class ImportDeclaration extends AbstractExpressionNode {
|
|
162
|
+
constructor(source, specifiers, assertions) {
|
|
163
|
+
super();
|
|
164
|
+
this.source = source;
|
|
165
|
+
this.specifiers = specifiers;
|
|
166
|
+
this.assertions = assertions;
|
|
167
|
+
}
|
|
168
|
+
static fromJSON(node, deserializer) {
|
|
169
|
+
return new ImportDeclaration_1(deserializer(node.source), node.specifiers?.map(deserializer), node.assertions?.map(deserializer));
|
|
170
|
+
}
|
|
171
|
+
static visit(node, visitNode) {
|
|
172
|
+
visitNode(node.source);
|
|
173
|
+
node.specifiers?.forEach(visitNode);
|
|
174
|
+
node.assertions?.forEach(visitNode);
|
|
175
|
+
}
|
|
176
|
+
getSource() {
|
|
177
|
+
return this.source;
|
|
178
|
+
}
|
|
179
|
+
getSpecifiers() {
|
|
180
|
+
return this.specifiers;
|
|
181
|
+
}
|
|
182
|
+
getAssertions() {
|
|
183
|
+
return this.assertions;
|
|
61
184
|
}
|
|
62
185
|
shareVariables(scopeList) { }
|
|
63
186
|
set(stack) {
|
|
64
|
-
throw new Error(`
|
|
187
|
+
throw new Error(`ImportDeclaration.#set() has no implementation.`);
|
|
65
188
|
}
|
|
66
189
|
get(stack) {
|
|
67
|
-
|
|
190
|
+
let importCallOptions;
|
|
191
|
+
if (this.assertions) {
|
|
192
|
+
const importAssertions = this.assertions
|
|
193
|
+
.map(assertion => assertion.get(stack))
|
|
194
|
+
.reduce((p, c) => Object.assign(p, c), {});
|
|
195
|
+
if (importAssertions) {
|
|
196
|
+
importCallOptions = { assert: importAssertions };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const module = stack.importModule(this.source.get(), importCallOptions);
|
|
200
|
+
if (!this.specifiers) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.specifiers.forEach(specifier => {
|
|
204
|
+
const local = specifier.getLocal().get(stack);
|
|
205
|
+
if (specifier instanceof ImportSpecifier) {
|
|
206
|
+
const imported = specifier.getImported().get(stack);
|
|
207
|
+
const importedValue = module.get(imported);
|
|
208
|
+
stack.getModule()?.set(local, importedValue);
|
|
209
|
+
const scopeSubscription = module.subscribe(local, (newValue, oldValue) => {
|
|
210
|
+
if (newValue !== oldValue) {
|
|
211
|
+
stack.getModule()?.set(local, newValue);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
stack.onDestroy(() => scopeSubscription.unsubscribe());
|
|
215
|
+
}
|
|
216
|
+
else if (specifier instanceof ImportDefaultSpecifier) {
|
|
217
|
+
const defaultValue = module.get('default');
|
|
218
|
+
stack.getModule()?.set(local, defaultValue);
|
|
219
|
+
const scopeSubscription = module.subscribe('default', (newValue, oldValue) => {
|
|
220
|
+
if (newValue !== oldValue) {
|
|
221
|
+
stack.getModule()?.set(local, newValue);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
stack.onDestroy(() => scopeSubscription.unsubscribe());
|
|
225
|
+
}
|
|
226
|
+
else if (specifier instanceof ImportNamespaceSpecifier) {
|
|
227
|
+
stack.getModule()?.importModule(local, module);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
68
230
|
}
|
|
69
231
|
dependency(computed) {
|
|
70
232
|
return [];
|
|
@@ -73,41 +235,90 @@ let ImportNode = ImportNode_1 = class ImportNode extends AbstractExpressionNode
|
|
|
73
235
|
return [];
|
|
74
236
|
}
|
|
75
237
|
toString() {
|
|
76
|
-
if (this.
|
|
77
|
-
return `import
|
|
238
|
+
if (!this.specifiers) {
|
|
239
|
+
return `import '${this.source.toString()}'`;
|
|
78
240
|
}
|
|
79
|
-
|
|
80
|
-
|
|
241
|
+
const parts = [];
|
|
242
|
+
const importDefaultSpecifiers = this.specifiers.filter(specifier => specifier instanceof ImportDefaultSpecifier);
|
|
243
|
+
if (importDefaultSpecifiers?.length) {
|
|
244
|
+
parts.push(importDefaultSpecifiers[0].toString());
|
|
81
245
|
}
|
|
82
|
-
|
|
83
|
-
|
|
246
|
+
const importNamespaceSpecifiers = this.specifiers.filter(specifier => specifier instanceof ImportNamespaceSpecifier);
|
|
247
|
+
if (importNamespaceSpecifiers?.length) {
|
|
248
|
+
parts.push(importNamespaceSpecifiers[0].toString());
|
|
84
249
|
}
|
|
85
|
-
|
|
86
|
-
|
|
250
|
+
const importSpecifiers = this.specifiers.filter(specifier => specifier instanceof ImportSpecifier);
|
|
251
|
+
if (importSpecifiers?.length) {
|
|
252
|
+
const importSpecifiersString = importSpecifiers.map(importSpecifier => importSpecifier.toString()).join(',');
|
|
253
|
+
parts.push(`{ ${importSpecifiersString} }`);
|
|
87
254
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
255
|
+
return `import ${parts.join(', ')} from ${this.source.toString()}${this.assertions ? ` assert { ${this.assertions.map(assertion => assertion.toString()).join(', ')} }` : ''};`;
|
|
256
|
+
}
|
|
257
|
+
toJson() {
|
|
258
|
+
return {
|
|
259
|
+
source: this.source.toJSON(),
|
|
260
|
+
specifiers: this.specifiers?.map(specifier => specifier.toJSON()),
|
|
261
|
+
assertions: this.assertions?.map(assertion => assertion.toJSON()),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
ImportDeclaration = ImportDeclaration_1 = __decorate([
|
|
266
|
+
Deserializer('ImportDeclaration'),
|
|
267
|
+
__metadata("design:paramtypes", [Literal, Array, Array])
|
|
268
|
+
], ImportDeclaration);
|
|
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
|
+
*/
|
|
276
|
+
let ImportExpression = ImportExpression_1 = class ImportExpression extends AbstractExpressionNode {
|
|
277
|
+
constructor(source, attributes) {
|
|
278
|
+
super();
|
|
279
|
+
this.source = source;
|
|
280
|
+
this.attributes = attributes;
|
|
281
|
+
}
|
|
282
|
+
static fromJSON(node, deserializer) {
|
|
283
|
+
return new ImportExpression_1(deserializer(node.source), (node.attributes && deserializer(node.attributes)) || undefined);
|
|
284
|
+
}
|
|
285
|
+
static visit(node, visitNode) {
|
|
286
|
+
visitNode(node.source);
|
|
287
|
+
node.attributes && visitNode(node.attributes);
|
|
288
|
+
}
|
|
289
|
+
getSource() {
|
|
290
|
+
return this.source;
|
|
291
|
+
}
|
|
292
|
+
shareVariables(scopeList) { }
|
|
293
|
+
set(stack) {
|
|
294
|
+
throw new Error(`ImportDeclaration.#set() has no implementation.`);
|
|
295
|
+
}
|
|
296
|
+
get(stack) {
|
|
297
|
+
let importCallOptions;
|
|
298
|
+
if (this.attributes) {
|
|
299
|
+
importCallOptions = this.attributes.get(stack);
|
|
96
300
|
}
|
|
97
|
-
|
|
301
|
+
const module = stack.importModule(this.source.get(), importCallOptions);
|
|
302
|
+
return Promise.resolve(module);
|
|
303
|
+
}
|
|
304
|
+
dependency(computed) {
|
|
305
|
+
return [];
|
|
306
|
+
}
|
|
307
|
+
dependencyPath(computed) {
|
|
308
|
+
return [];
|
|
309
|
+
}
|
|
310
|
+
toString() {
|
|
311
|
+
return `import(${this.source.toString()}${this.attributes ? `, ${this.attributes.toString()}` : ''})`;
|
|
98
312
|
}
|
|
99
313
|
toJson() {
|
|
100
314
|
return {
|
|
101
|
-
|
|
102
|
-
defaultExport: this.defaultExport?.toJSON(),
|
|
103
|
-
namespace: this.namespace?.toJSON(),
|
|
104
|
-
exportAliasNames: this.importAliasNames?.map(expression => expression.toJSON()),
|
|
315
|
+
source: this.source.toJSON(),
|
|
105
316
|
};
|
|
106
317
|
}
|
|
107
318
|
};
|
|
108
|
-
|
|
109
|
-
Deserializer('
|
|
110
|
-
__metadata("design:paramtypes", [
|
|
111
|
-
],
|
|
112
|
-
export {
|
|
319
|
+
ImportExpression = ImportExpression_1 = __decorate([
|
|
320
|
+
Deserializer('ImportExpression'),
|
|
321
|
+
__metadata("design:paramtypes", [Literal, Object])
|
|
322
|
+
], ImportExpression);
|
|
323
|
+
export { ImportExpression };
|
|
113
324
|
//# sourceMappingURL=import.js.map
|
package/api/module/import.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../../../src/expressions/api/module/import.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,OAAO,eAAe;IAK3B,YAAmB,UAA0B,EAAY,UAA2B;QAAjE,eAAU,GAAV,UAAU,CAAgB;QAAY,eAAU,GAAV,UAAU,CAAiB;IAAI,CAAC;IAJzF,MAAM,CAAC,KAAK,CAAC,IAAqB,EAAE,SAAwB,EAAE,aAAgC;QAC7F,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3B,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAGD,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED,IAAW,SAAS,CAAC,UAA0B;QAC9C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,QAAQ;QACP,IAAI,IAAI,CAAC,UAAU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aAAa,CAAC,QAAQ,EAAE,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC;SACvF;QACD,IAAI,IAAI,CAAC,SAAS,EAAE;YAGnB,OAAO,gBAAgB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC;SACzF;QAED,OAAO,WAAW,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC;IACjD,CAAC;IACD,MAAM;QACL,OAAO;YACN,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YACpC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YAC3C,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE;YACnC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;SAC/E,CAAC;IACH,CAAC;CACD,CAAA;AA/FY,UAAU;IADtB,YAAY,CAAC,QAAQ,CAAC;;GACV,UAAU,CA+FtB;SA/FY,UAAU","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode, ExpressionEventPath,\n\tVisitNodeType, VisitNodeListType,\n} from '../expression.js';\nimport type { Scope } from '../../scope/scope.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\n\nexport class ImportAliasName {\n\tstatic visit(node: ImportAliasName, visitNode: VisitNodeType, visitNodeList: VisitNodeListType): void {\n\t\tvisitNode(node.importName);\n\t\tnode.aliasName && visitNode(node.aliasName);\n\t}\n\tconstructor(public importName: ExpressionNode, protected _aliasName?: ExpressionNode) { }\n\n\tpublic get aliasName(): ExpressionNode {\n\t\treturn this._aliasName || this.importName;\n\t}\n\n\tpublic set aliasName(_aliasName: ExpressionNode) {\n\t\tthis._aliasName = _aliasName;\n\t}\n\n\ttoString() {\n\t\tif (this._aliasName) {\n\t\t\treturn `${this.importName.toString()} as ${this._aliasName.toString()}`;\n\t\t}\n\t\treturn this.importName.toString();\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\texportName: this.importName.toJSON(),\n\t\t\taliasName: this._aliasName?.toJSON()\n\t\t};\n\t}\n}\n\n\n/**\n * import defaultExport from \"module-name\";\\n\n * import * as name from \"module-name\";\\n\n * import { export1 } from \"module-name\";\n * import { export1 as alias1 } from \"module-name\";\n * import { export1 , export2 } from \"module-name\";\n * import { foo , bar } from \"module-name/path/to/specific/un-exported/file\";\n * import { export1 , export2 as alias2 , [...] } from \"module-name\";\n * import defaultExport, { export1 [ , [...] ] } from \"module-name\";\n * import defaultExport, * as name from \"module-name\";\n * import \"module-name\";\n * var promise = import(\"module-name\");\n */\n@Deserializer('import')\nexport class ImportNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ImportNode, deserializer: NodeDeserializer): ImportNode {\n\t\treturn new ImportNode(\n\t\t\tdeserializer(node.moduleName),\n\t\t\tnode.defaultExport ? deserializer(node.defaultExport) : void 0,\n\t\t\tnode.namespace ? deserializer(node.namespace) : void 0,\n\t\t\tnode.importAliasNames?.map(expo => new ImportAliasName(deserializer(expo.importName), deserializer(expo.aliasName))),\n\t\t);\n\t}\n\tstatic visit(node: ImportNode, visitNode: VisitNodeType, visitNodeList: VisitNodeListType): void {\n\t\tvisitNode(node.moduleName);\n\t\tnode.defaultExport && visitNode(node.defaultExport);\n\t\tnode.namespace && visitNode(node.namespace);\n\t\tnode.importAliasNames?.map(expo => ImportAliasName.visit(expo, visitNode, visitNodeList));\n\t}\n\tconstructor(\n\t\tprivate moduleName: ExpressionNode,\n\t\tprivate defaultExport?: ExpressionNode,\n\t\tprivate namespace?: ExpressionNode,\n\t\tprivate importAliasNames?: ImportAliasName[]) {\n\t\tsuper();\n\t}\n\tgetModuleName() {\n\t\treturn this.moduleName;\n\t}\n\tgetDefaultExport() {\n\t\treturn this.defaultExport;\n\t}\n\tgetNamespace() {\n\t\treturn this.namespace;\n\t}\n\tgetImportAliasNames() {\n\t\treturn this.importAliasNames;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack) {\n\t\tthrow new Error(`ImportNode.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tthrow new Error(`ImportNode.#get() has no implementation.`);\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\tif (this.defaultExport && this.namespace && this.importAliasNames) {\n\t\t\t// import defaultExport, * as name, { export1 , export2 as alias2 , [...] } from \"module-name;\n\t\t\treturn `import ${this.defaultExport.toString()}, * as ${this.namespace.toString()}, { ${this.importAliasNames.map(expo => expo.toString()).join(', ')} } from '${this.moduleName.toString()}';`;\n\t\t}\n\n\t\tif (this.defaultExport && this.importAliasNames) {\n\t\t\t// import defaultExport, { export1 , export2 as alias2 , [...] } from \"module-name;\n\t\t\treturn `import ${this.defaultExport.toString()}, { ${this.importAliasNames.map(expo => expo.toString()).join(', ')} } from '${this.moduleName.toString()}';`;\n\n\t\t}\n\t\tif (this.namespace && this.importAliasNames) {\n\n\t\t\t// import * as name, { export1 , export2 as alias2 , [...] } from \"module-name;\n\t\t\treturn `import * as ${this.namespace.toString()}, { ${this.importAliasNames.map(expo => expo.toString()).join(', ')} } from '${this.moduleName.toString()}';`;\n\t\t}\n\t\tif (this.namespace && this.defaultExport) {\n\n\t\t\t// import defaultExport, * as name from \"module-name;\n\t\t\treturn `import ${this.defaultExport.toString()}, * as ${this.namespace.toString()} from '${this.moduleName.toString()}';`;\n\t\t}\n\n\t\tif (this.importAliasNames) {\n\n\t\t\t// import { export1 , export2 as alias2 , [...] } from \"module-name;\n\t\t\treturn `import { ${this.importAliasNames.map(expo => expo.toString()).join(', ')} } from '${this.moduleName.toString()}';`;\n\t\t}\n\t\tif (this.defaultExport) {\n\n\t\t\t// import defaultExport from \"module-name;\n\t\t\treturn `import ${this.defaultExport.toString()} from '${this.moduleName.toString()}';`;\n\t\t}\n\t\tif (this.namespace) {\n\n\t\t\t// import * as name from \"module-name;\n\t\t\treturn `import * as ${this.namespace.toString()} from '${this.moduleName.toString()}';`;\n\t\t}\n\n\t\treturn `import '${this.moduleName.toString()}'`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tmoduleName: this.moduleName.toJSON(),\n\t\t\tdefaultExport: this.defaultExport?.toJSON(),\n\t\t\tnamespace: this.namespace?.toJSON(),\n\t\t\texportAliasNames: this.importAliasNames?.map(expression => expression.toJSON()),\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../../../src/expressions/api/module/import.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAmB,eAAe,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;;;;;;;;;;;;;GAgBG;AAEH,IAAa,eAAe,uBAA5B,MAAa,eAAgB,SAAQ,eAAe;IAWnD,YAAY,KAAiB,EAAU,QAAoB;QAC1D,KAAK,CAAC,KAAK,CAAC,CAAC;QADyB,aAAQ,GAAR,QAAQ,CAAY;IAE3D,CAAC;IAZD,MAAM,CAAC,QAAQ,CAAC,IAAqB,EAAE,YAA8B;QACpE,OAAO,IAAI,iBAAe,CACzB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAe,EACtC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAe,CACzC,CAAC;IACH,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,IAAqB,EAAE,SAAwB;QAC3D,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,C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CAAC;IACD,GAAG,CAAC,KAAY;QACf,IAAI,iBAAgD,CAAC;QACrD,IAAI,IAAI,CAAC,UAAU,EAAE;YACpB,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC/C;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC;QACxE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,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,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;IACvG,CAAC;IACD,MAAM;QACL,OAAO;YACN,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;SAC5B,CAAC;IACH,CAAC;CACD,CAAA;AA3CY,gBAAgB;IAD5B,YAAY,CAAC,kBAAkB,CAAC;qCAYJ,OAAO;GAXvB,gBAAgB,CA2C5B;SA3CY,gBAAgB","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode,\n\tExpressionEventPath, VisitNodeType,\n} from '../expression.js';\nimport type { ModuleScope, Scope } from '../../scope/scope.js';\nimport type { 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';\n\n/**\n * An imported variable binding,\n * \n * e.g., {foo} in import {foo} from \"mod\"\n * or {foo as bar} in import {foo as bar} from \"mod\".\n * \n * The imported field refers to the name of the export imported from the module.\n * \n * The local field refers to the binding imported into the local module scope.\n * \n * If it is a basic named import, such as in import {foo} from \"mod\",\n * both imported and local are equivalent Identifier nodes; in this case an Identifier node representing foo.\n * \n * If it is an aliased import, such as in import {foo as bar} from \"mod\",\n * the imported field is an Identifier node representing foo,\n * and the local field is an Identifier node representing bar.\n */\n@Deserializer('ImportSpecifier')\nexport class ImportSpecifier extends ModuleSpecifier {\n\tstatic fromJSON(node: ImportSpecifier, deserializer: NodeDeserializer): ImportSpecifier {\n\t\treturn new ImportSpecifier(\n\t\t\tdeserializer(node.local) as Identifier,\n\t\t\tdeserializer(node.imported) as Identifier\n\t\t);\n\t}\n\tstatic visit(node: ImportSpecifier, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.local);\n\t\tvisitNode(node.imported);\n\t}\n\tconstructor(local: Identifier, private imported: Identifier) {\n\t\tsuper(local);\n\t}\n\tgetImported() {\n\t\treturn this.imported;\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 imported = this.imported.toString();\n\t\tif (local == imported) {\n\t\t\treturn local;\n\t\t}\n\t\treturn `${imported} as ${local}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tlocal: this.local.toJSON(),\n\t\t\timported: this.imported.toJSON()\n\t\t};\n\t}\n}\n\n/**\n * A default import specifier, e.g., `foo` in `import foo from \"mod.js\";`.\n */\n@Deserializer('ImportDefaultSpecifier')\nexport class ImportDefaultSpecifier extends ModuleSpecifier {\n\tstatic fromJSON(node: ImportDefaultSpecifier, deserializer: NodeDeserializer): ImportDefaultSpecifier {\n\t\treturn new ImportDefaultSpecifier(\n\t\t\tdeserializer(node.local) as Identifier\n\t\t);\n\t}\n\tstatic visit(node: ImportDefaultSpecifier, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.local);\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\treturn this.local.toString();\n\t}\n}\n\n/**\n * A namespace import specifier, e.g., `* as foo` in `import * as foo from \"mod.js\";`.\n */\n@Deserializer('ImportNamespaceSpecifier')\nexport class ImportNamespaceSpecifier extends ModuleSpecifier {\n\tstatic fromJSON(node: ImportNamespaceSpecifier, deserializer: NodeDeserializer): ImportNamespaceSpecifier {\n\t\treturn new ImportNamespaceSpecifier(\n\t\t\tdeserializer(node.local) as Identifier\n\t\t);\n\t}\n\tstatic visit(node: ImportNamespaceSpecifier, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.local);\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\treturn `* as ${this.local.toString()}`;\n\t}\n}\n\n/**\n * An import declaration, e.g., import foo from \"mod\";.\n * \n * import defaultExport from \"module-name\";\n * \n * import * as name from \"module-name\";\n * \n * import { export1 } from \"module-name\";\n * \n * import { export1 as alias1 } from \"module-name\";\n * \n * import { export1 , export2 } from \"module-name\";\n * \n * import { foo , bar } from \"module-name/path/to/specific/un-exported/file\";\n * \n * import { export1 , export2 as alias2 , [...] } from \"module-name\";\n * \n * import defaultExport, { export1 [ , [...] ] } from \"module-name\";\n * \n * import defaultExport, * as name from \"module-name\";\n * \n * import \"module-name\";\n * \n */\n@Deserializer('ImportDeclaration')\nexport class ImportDeclaration extends AbstractExpressionNode {\n\tstatic fromJSON(node: ImportDeclaration, deserializer: NodeDeserializer): ImportDeclaration {\n\t\treturn new ImportDeclaration(\n\t\t\tdeserializer(node.source) as Literal<string>,\n\t\t\tnode.specifiers?.map(deserializer) as (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[],\n\t\t\tnode.assertions?.map(deserializer) as (ImportAttribute)[],\n\t\t);\n\t}\n\tstatic visit(node: ImportDeclaration, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.source);\n\t\tnode.specifiers?.forEach(visitNode);\n\t\tnode.assertions?.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate source: Literal<string>,\n\t\tprivate specifiers?: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[],\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\tgetAssertions() {\n\t\treturn this.assertions;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack) {\n\t\tthrow new Error(`ImportDeclaration.#set() has no implementation.`);\n\t}\n\tget(stack: Stack): void {\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 module = stack.importModule(this.source.get(), importCallOptions);\n\t\tif (!this.specifiers) {\n\t\t\treturn;\n\t\t}\n\t\tthis.specifiers.forEach(specifier => {\n\t\t\tconst local = specifier.getLocal().get(stack);\n\t\t\tif (specifier instanceof ImportSpecifier) {\n\t\t\t\tconst imported = specifier.getImported().get(stack);\n\t\t\t\tconst importedValue = module.get(imported);\n\t\t\t\tstack.getModule()?.set(local, importedValue);\n\t\t\t\tconst scopeSubscription = module.subscribe(local, (newValue, oldValue) => {\n\t\t\t\t\tif (newValue !== oldValue) {\n\t\t\t\t\t\tstack.getModule()?.set(local, newValue);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tstack.onDestroy(() => scopeSubscription.unsubscribe());\n\t\t\t} else if (specifier instanceof ImportDefaultSpecifier) {\n\t\t\t\tconst defaultValue = module.get('default');\n\t\t\t\tstack.getModule()?.set(local, defaultValue);\n\t\t\t\tconst scopeSubscription = module.subscribe('default', (newValue, oldValue) => {\n\t\t\t\t\tif (newValue !== oldValue) {\n\t\t\t\t\t\tstack.getModule()?.set(local, newValue);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tstack.onDestroy(() => scopeSubscription.unsubscribe());\n\t\t\t} else if (specifier instanceof ImportNamespaceSpecifier) {\n\t\t\t\tstack.getModule()?.importModule(local, module);\n\t\t\t}\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(): string {\n\t\tif (!this.specifiers) {\n\t\t\treturn `import '${this.source.toString()}'`;\n\t\t}\n\t\tconst parts: string[] = [];\n\t\tconst importDefaultSpecifiers = this.specifiers.filter(specifier => specifier instanceof ImportDefaultSpecifier) as ImportDefaultSpecifier[];\n\t\tif (importDefaultSpecifiers?.length) {\n\t\t\tparts.push(importDefaultSpecifiers[0].toString());\n\t\t}\n\t\tconst importNamespaceSpecifiers = this.specifiers.filter(specifier => specifier instanceof ImportNamespaceSpecifier) as ImportNamespaceSpecifier[];\n\t\tif (importNamespaceSpecifiers?.length) {\n\t\t\tparts.push(importNamespaceSpecifiers[0].toString());\n\t\t}\n\t\tconst importSpecifiers = this.specifiers.filter(specifier => specifier instanceof ImportSpecifier) as ImportSpecifier[];\n\t\tif (importSpecifiers?.length) {\n\t\t\tconst importSpecifiersString = importSpecifiers.map(importSpecifier => importSpecifier.toString()).join(',');\n\t\t\tparts.push(`{ ${importSpecifiersString} }`);\n\t\t}\n\t\treturn `import ${parts.join(', ')} 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\tspecifiers: this.specifiers?.map(specifier => specifier.toJSON()),\n\t\t\tassertions: this.assertions?.map(assertion => assertion.toJSON()),\n\t\t};\n\t}\n}\n\n\n/**\n * `ImportExpression` node represents Dynamic Imports such as `import(source)`.\n * The `source` property is the importing source as similar to ImportDeclaration node,\n * but it can be an arbitrary expression node.\n * var promise = import(\"module-name\");\n */\n@Deserializer('ImportExpression')\nexport class ImportExpression extends AbstractExpressionNode {\n\tstatic fromJSON(node: ImportExpression, deserializer: NodeDeserializer): ImportExpression {\n\t\treturn new ImportExpression(\n\t\t\tdeserializer(node.source) as Literal<string>,\n\t\t\t(node.attributes && deserializer(node.attributes)) || undefined\n\t\t);\n\t}\n\tstatic visit(node: ImportExpression, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.source);\n\t\tnode.attributes && visitNode(node.attributes);\n\t}\n\tconstructor(private source: Literal<string>, private attributes?: ExpressionNode) {\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(`ImportDeclaration.#set() has no implementation.`);\n\t}\n\tget(stack: Stack): Promise<ModuleScope> {\n\t\tlet importCallOptions: ImportCallOptions | undefined;\n\t\tif (this.attributes) {\n\t\t\timportCallOptions = this.attributes.get(stack);\n\t\t}\n\t\tconst module = stack.importModule(this.source.get(), importCallOptions);\n\t\treturn Promise.resolve(module);\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\treturn `import(${this.source.toString()}${this.attributes ? `, ${this.attributes.toString()}` : ''})`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tsource: this.source.toJSON(),\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { EvaluateType } from './types.js';
|
|
2
|
-
import type { NodeDeserializer, ExpressionNode, VisitNodeType
|
|
2
|
+
import type { NodeDeserializer, ExpressionNode, VisitNodeType } from '../expression.js';
|
|
3
3
|
import type { Stack } from '../../scope/stack.js';
|
|
4
4
|
import { InfixExpressionNode } from '../abstract.js';
|
|
5
5
|
export declare type AssignmentOperator = '=' | '+=' | '-=' | '*=' | '**=' | '/=' | '%=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&=' | '||=' | '&&=' | '??=' | '%%=' | '>?=' | '<?=';
|
|
6
6
|
export declare class AssignmentExpression extends InfixExpressionNode<AssignmentOperator> {
|
|
7
7
|
static fromJSON(node: AssignmentExpression, deserializer: NodeDeserializer): AssignmentExpression;
|
|
8
|
-
static visit(node: AssignmentExpression, visitNode: VisitNodeType
|
|
8
|
+
static visit(node: AssignmentExpression, visitNode: VisitNodeType): void;
|
|
9
9
|
static Evaluations: EvaluateType;
|
|
10
10
|
static LogicalEvaluations: {
|
|
11
11
|
[key: string]: (exp: AssignmentExpression, context: any) => any;
|
|
@@ -9,7 +9,7 @@ let AssignmentExpression = AssignmentExpression_1 = class AssignmentExpression e
|
|
|
9
9
|
static fromJSON(node, deserializer) {
|
|
10
10
|
return new AssignmentExpression_1(node.operator, deserializer(node.left), deserializer(node.right));
|
|
11
11
|
}
|
|
12
|
-
static visit(node, visitNode
|
|
12
|
+
static visit(node, visitNode) {
|
|
13
13
|
visitNode(node.left);
|
|
14
14
|
visitNode(node.right);
|
|
15
15
|
}
|