@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.
Files changed (186) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -3
  3. package/api/abstract.d.ts +5 -6
  4. package/api/abstract.js +8 -3
  5. package/api/abstract.js.map +1 -1
  6. package/api/class/class.d.ts +227 -0
  7. package/api/class/class.js +662 -0
  8. package/api/class/class.js.map +1 -0
  9. package/api/class/decorator.d.ts +20 -0
  10. package/api/class/decorator.js +48 -0
  11. package/api/class/decorator.js.map +1 -0
  12. package/api/computing/call.d.ts +3 -1
  13. package/api/computing/call.js +16 -4
  14. package/api/computing/call.js.map +1 -1
  15. package/api/computing/debugger.d.ts +15 -0
  16. package/api/computing/debugger.js +35 -0
  17. package/api/computing/debugger.js.map +1 -0
  18. package/api/computing/new.d.ts +2 -1
  19. package/api/computing/new.js +4 -0
  20. package/api/computing/new.js.map +1 -1
  21. package/api/computing/rest.d.ts +6 -6
  22. package/api/computing/rest.js +5 -2
  23. package/api/computing/rest.js.map +1 -1
  24. package/api/computing/return.d.ts +6 -1
  25. package/api/computing/return.js +8 -0
  26. package/api/computing/return.js.map +1 -1
  27. package/api/computing/spread.d.ts +2 -1
  28. package/api/computing/spread.js +5 -2
  29. package/api/computing/spread.js.map +1 -1
  30. package/api/computing/throw.d.ts +6 -1
  31. package/api/computing/throw.js +7 -0
  32. package/api/computing/throw.js.map +1 -1
  33. package/api/computing/yield.d.ts +2 -1
  34. package/api/computing/yield.js +3 -0
  35. package/api/computing/yield.js.map +1 -1
  36. package/api/definition/array.d.ts +12 -12
  37. package/api/definition/array.js +31 -25
  38. package/api/definition/array.js.map +1 -1
  39. package/api/definition/bind.d.ts +8 -2
  40. package/api/definition/bind.js +7 -1
  41. package/api/definition/bind.js.map +1 -1
  42. package/api/definition/function.d.ts +40 -51
  43. package/api/definition/function.js +292 -309
  44. package/api/definition/function.js.map +1 -1
  45. package/api/definition/member.d.ts +2 -2
  46. package/api/definition/member.js +1 -1
  47. package/api/definition/member.js.map +1 -1
  48. package/api/definition/object.d.ts +15 -12
  49. package/api/definition/object.js +43 -13
  50. package/api/definition/object.js.map +1 -1
  51. package/api/definition/statement.d.ts +2 -2
  52. package/api/definition/statement.js +7 -3
  53. package/api/definition/statement.js.map +1 -1
  54. package/api/definition/values.d.ts +44 -50
  55. package/api/definition/values.js +87 -149
  56. package/api/definition/values.js.map +1 -1
  57. package/api/deserialize/deserialize.d.ts +7 -1
  58. package/api/deserialize/deserialize.js +9 -1
  59. package/api/deserialize/deserialize.js.map +1 -1
  60. package/api/deserialize/type-store.d.ts +2 -2
  61. package/api/deserialize/type-store.js.map +1 -1
  62. package/api/expression.d.ts +159 -18
  63. package/api/expression.js.map +1 -1
  64. package/api/index.d.ts +2 -0
  65. package/api/index.js +2 -0
  66. package/api/index.js.map +1 -1
  67. package/api/module/common.d.ts +29 -0
  68. package/api/module/common.js +71 -0
  69. package/api/module/common.js.map +1 -0
  70. package/api/module/export.d.ts +129 -25
  71. package/api/module/export.js +333 -58
  72. package/api/module/export.js.map +1 -1
  73. package/api/module/import.d.ts +114 -25
  74. package/api/module/import.js +279 -68
  75. package/api/module/import.js.map +1 -1
  76. package/api/operators/assignment.d.ts +2 -2
  77. package/api/operators/assignment.js +1 -1
  78. package/api/operators/assignment.js.map +1 -1
  79. package/api/operators/await.d.ts +2 -2
  80. package/api/operators/await.js +1 -1
  81. package/api/operators/await.js.map +1 -1
  82. package/api/operators/binary.d.ts +2 -2
  83. package/api/operators/binary.js +1 -1
  84. package/api/operators/binary.js.map +1 -1
  85. package/api/operators/chaining.d.ts +2 -2
  86. package/api/operators/chaining.js +1 -1
  87. package/api/operators/chaining.js.map +1 -1
  88. package/api/operators/comma.d.ts +2 -2
  89. package/api/operators/comma.js +2 -2
  90. package/api/operators/comma.js.map +1 -1
  91. package/api/operators/grouping.d.ts +9 -2
  92. package/api/operators/grouping.js +8 -1
  93. package/api/operators/grouping.js.map +1 -1
  94. package/api/operators/logical.d.ts +2 -2
  95. package/api/operators/logical.js +1 -1
  96. package/api/operators/logical.js.map +1 -1
  97. package/api/operators/pipeline.d.ts +14 -2
  98. package/api/operators/pipeline.js +13 -1
  99. package/api/operators/pipeline.js.map +1 -1
  100. package/api/operators/ternary.d.ts +2 -2
  101. package/api/operators/ternary.js +1 -1
  102. package/api/operators/ternary.js.map +1 -1
  103. package/api/operators/unary.d.ts +3 -3
  104. package/api/operators/unary.js +7 -3
  105. package/api/operators/unary.js.map +1 -1
  106. package/api/operators/update.d.ts +2 -2
  107. package/api/operators/update.js +1 -1
  108. package/api/operators/update.js.map +1 -1
  109. package/api/{app/program.d.ts → program.d.ts} +8 -9
  110. package/api/program.js +45 -0
  111. package/api/program.js.map +1 -0
  112. package/api/statement/control/block.d.ts +8 -5
  113. package/api/statement/control/block.js +26 -23
  114. package/api/statement/control/block.js.map +1 -1
  115. package/api/statement/control/empty.d.ts +8 -1
  116. package/api/statement/control/empty.js +7 -0
  117. package/api/statement/control/empty.js.map +1 -1
  118. package/api/statement/control/if.d.ts +7 -2
  119. package/api/statement/control/if.js +6 -1
  120. package/api/statement/control/if.js.map +1 -1
  121. package/api/statement/control/switch.d.ts +10 -5
  122. package/api/statement/control/switch.js +22 -9
  123. package/api/statement/control/switch.js.map +1 -1
  124. package/api/statement/control/terminate.d.ts +46 -13
  125. package/api/statement/control/terminate.js +89 -20
  126. package/api/statement/control/terminate.js.map +1 -1
  127. package/api/statement/declarations/declares.d.ts +17 -16
  128. package/api/statement/declarations/declares.js +24 -19
  129. package/api/statement/declarations/declares.js.map +1 -1
  130. package/api/statement/iterations/for.d.ts +10 -5
  131. package/api/statement/iterations/for.js +42 -23
  132. package/api/statement/iterations/for.js.map +1 -1
  133. package/api/statement/iterations/while.d.ts +9 -3
  134. package/api/statement/iterations/while.js +27 -13
  135. package/api/statement/iterations/while.js.map +1 -1
  136. package/api/utils.d.ts +5 -0
  137. package/api/utils.js +4 -0
  138. package/api/utils.js.map +1 -0
  139. package/package.json +5 -5
  140. package/scope/finalizer.d.ts +4 -0
  141. package/scope/finalizer.js +11 -0
  142. package/scope/finalizer.js.map +1 -0
  143. package/scope/proxy.d.ts +5 -3
  144. package/scope/proxy.js +26 -26
  145. package/scope/proxy.js.map +1 -1
  146. package/scope/scope.d.ts +108 -51
  147. package/scope/scope.js +72 -134
  148. package/scope/scope.js.map +1 -1
  149. package/scope/stack.d.ts +117 -26
  150. package/scope/stack.js +154 -102
  151. package/scope/stack.js.map +1 -1
  152. package/v8/enums.d.ts +204 -0
  153. package/v8/enums.js +406 -0
  154. package/v8/enums.js.map +1 -0
  155. package/v8/index.d.ts +2 -1
  156. package/v8/index.js +2 -1
  157. package/v8/index.js.map +1 -1
  158. package/v8/inline.d.ts +213 -0
  159. package/v8/inline.js +2375 -0
  160. package/v8/inline.js.map +1 -0
  161. package/v8/nodes.d.ts +8 -7
  162. package/v8/nodes.js +39 -64
  163. package/v8/nodes.js.map +1 -1
  164. package/v8/parser.d.ts +49 -151
  165. package/v8/parser.js +839 -1607
  166. package/v8/parser.js.map +1 -1
  167. package/v8/stream.d.ts +39 -3
  168. package/v8/stream.js +685 -171
  169. package/v8/stream.js.map +1 -1
  170. package/v8/token.d.ts +244 -9
  171. package/v8/token.js +315 -47
  172. package/v8/token.js.map +1 -1
  173. package/visit/visitor.d.ts +3 -0
  174. package/visit/visitor.js +4 -7
  175. package/visit/visitor.js.map +1 -1
  176. package/api/app/class.d.ts +0 -117
  177. package/api/app/class.js +0 -292
  178. package/api/app/class.js.map +0 -1
  179. package/api/app/program.js +0 -39
  180. package/api/app/program.js.map +0 -1
  181. package/api/module/module.d.ts +0 -26
  182. package/api/module/module.js +0 -63
  183. package/api/module/module.js.map +0 -1
  184. package/v8/app.d.ts +0 -0
  185. package/v8/app.js +0 -2
  186. package/v8/app.js.map +0 -1
@@ -1,5 +1,6 @@
1
- import type { Scope, ScopeType } from '../scope/scope.js';
1
+ import type { Scope, ScopeContext } from '../scope/scope.js';
2
2
  import type { Stack } from '../scope/stack.js';
3
+ import { TypeOf } from './utils.js';
3
4
  export declare type NodeType = {
4
5
  type: string;
5
6
  };
@@ -20,35 +21,175 @@ export declare type ExpressionEventMap = {
20
21
  [key: string]: ExpressionEventMap;
21
22
  };
22
23
  export interface ExpressionNode {
23
- shareVariables(scopeList: Scope<any>[]): void;
24
+ /**
25
+ * pass scope list from outer function to inner function,
26
+ *
27
+ * all other end point expression should do nothing,
28
+ * if this function executed.
29
+ *
30
+ * @param scopeList all outer function scopes given to the inner function,
31
+ * this solution ignore the fact that some inner function has no need to
32
+ * get shared variables, as its implementation never say that
33
+ * ```js
34
+ * function f(d) {
35
+ * function g() {
36
+ * const a = ({ d }) => d;
37
+ * return a;
38
+ * }
39
+ * return [d, g];
40
+ * }
41
+ * ```
42
+ */
43
+ shareVariables(scopeList: Scope<ScopeContext>[]): void;
44
+ /**
45
+ * assign the value to this expression in stack.
46
+ *
47
+ * most ExpressionNode will not implement this method, and will throw an exception.
48
+ * @param stack
49
+ * @param value
50
+ */
24
51
  set(stack: Stack, value: any): any;
52
+ /**
53
+ * execute/get the code for this expression and return the result value.
54
+ * @param stack
55
+ * @param thisContext
56
+ */
25
57
  get(stack: Stack, thisContext?: any): any;
58
+ /**
59
+ * get all dependencies form an expression node
60
+ *
61
+ * tha return from this method, is represent an answer for what identifiers this expression depends-on.
62
+ *
63
+ *
64
+ * ex:
65
+ * ```js
66
+ * x + y;
67
+ * ```
68
+ *
69
+ * - for `+` operator : the answer should be `lhs` and `rhs`,
70
+ * - for `x` identifier: the answer should be node `x`,
71
+ * - for `y` identifier: the answer should be node `y`.
72
+ *
73
+ * so, the return from `+` will be `[ node 'x', node 'y']`
74
+ *
75
+ * and:
76
+ * - `x.y.z * a` ==> `[ member node `x.y.z`, identifier 'a']`
77
+ * @param computed
78
+ */
26
79
  dependency(computed?: true): ExpressionNode[];
80
+ /**
81
+ * ex:
82
+ * ```js
83
+ * x + y;
84
+ * ```
85
+ *
86
+ * - for `+` operator : the answer should be `lhs` and `rhs`,
87
+ * - for `x` identifier: the answer should be node `x`,
88
+ * - for `y` identifier: the answer should be node `y`.
89
+ *
90
+ * so, the return from `+` will be `['x', 'y']`
91
+ *
92
+ * and:
93
+ * - `x.y.z` ==> `['x', 'y', 'z']`
94
+ * - `x[y].z` ==> ['x', ]
95
+ * @param computed required for member and chaining operators
96
+ */
27
97
  dependencyPath(computed?: true): ExpressionEventPath[];
98
+ /**
99
+ * get all the events form this expression
100
+ *
101
+ * tha return from this method, is represent an answer for what is this expression depends-on as identifier name
102
+ *
103
+ * ex:
104
+ * ```js
105
+ * x + y;
106
+ * ```
107
+ *
108
+ * - for `+` operator : the answer should be `lhs` and `rhs`,
109
+ * - for `x` identifier: the answer should be `x`
110
+ * - for `y` identifier: the answer should be `y`
111
+ * the final output will be
112
+ *
113
+ * so, the return from `+` will be `{ x: undefined, y: undefined }`
114
+ *
115
+ * and:
116
+ * - `x.y.z * a` ==> `{ x: { y: { z: undefined }, a: undefined } }`
117
+ * - `x.y.z > x.y.h.g` ==> `{ x: { y: { z: undefined, h: { g: undefined} } } }`
118
+ * - `x[Symbol.toStringTag] + 'Class' + classType + array[3]` ==> `{ x: { 'Symbol.toStringTag': undefined }, classType: undefined, array: { 3: undefined } }`
119
+ * - `'name'` ==> {}
120
+ * - ```js
121
+ * user[firstName + `son of ${fatherName}`]
122
+ * ``` ==> `{ user: { 'firstName:fatherName': undefined }, firstName: undefined, fatherName: undefined }`
123
+ * @param parent
124
+ */
28
125
  events(): ExpressionEventMap;
126
+ /**
127
+ * re-write this expression as a javascript source
128
+ */
29
129
  toString(): string;
130
+ /**
131
+ * used to map this object to represent an [ESTree](https://github.com/estree/estree) json object
132
+ * @param key
133
+ */
30
134
  toJSON(): NodeJsonType;
31
- getClass(): NodeExpressionClass<ExpressionNode>;
32
- }
33
- interface TypeOf<T> {
34
- new (...params: any[]): T;
135
+ /**
136
+ * just a helper method to force class that implement this interface to
137
+ * have a static method `fromJSON` to help reconstruct this ExpressionNode
138
+ * from an [ESTree](https://github.com/estree/estree) json object,
139
+ * with all necessary implementation to execute the code
140
+ */
141
+ getClass(): ExpressionNodConstructor<ExpressionNode>;
35
142
  }
36
143
  export declare type NodeDeserializer<N = ExpressionNode> = (node: N) => N;
37
144
  export declare type VisitNodeType = (expression: ExpressionNode) => void;
38
- export declare type VisitNodeListType = (expressions: ExpressionNode[]) => void;
39
- export interface NodeExpressionClass<N extends ExpressionNode> extends TypeOf<N> {
40
- fromJSON(node: N, deserializer: NodeDeserializer): N;
41
- visit?(node: N, visitNode: VisitNodeType, visitNodeList: VisitNodeListType): void;
42
- }
43
- export interface NodeExpressionWithType<N extends ExpressionNode> extends NodeExpressionClass<N> {
145
+ /**
146
+ * this is how to:
147
+ * describe a class with it's static functions and properties
148
+ * in the interface add getClass method
149
+ */
150
+ export interface ExpressionNodConstructor<N extends ExpressionNode> extends TypeOf<N> {
151
+ /**
152
+ * the type of an expression
153
+ */
44
154
  type: string;
155
+ /**
156
+ * build expression node from [ESTree](https://github.com/estree/estree) json object
157
+ * @param node
158
+ * @param deserializer
159
+ */
160
+ fromJSON(node: N, deserializer: NodeDeserializer): N;
161
+ /**
162
+ * visit nodes inside expression
163
+ * @param expression
164
+ * @param callback
165
+ */
166
+ visit?(node: N, visitNode: Object): void;
45
167
  }
46
- export interface CanDeclareExpression extends ExpressionNode {
47
- declareVariable(stack: Stack, scopeType: ScopeType, propertyValue?: any): any;
168
+ export interface DeclarationExpression extends ExpressionNode {
169
+ /**
170
+ * declare variable in the current local scope (block),
171
+ * or closest function scope (global) scop,
172
+ * the propertyName will be calculated at runtime
173
+ * @param stack the stack which an identifier will be declared
174
+ * @param propertyValue the initial value of identifier
175
+ * @param scope which scop to declare this identifier
176
+ */
177
+ declareVariable(stack: Stack, propertyValue?: any): any;
178
+ /**
179
+ * get the variable declaration name
180
+ */
181
+ getDeclarationName?(): string;
48
182
  }
183
+ /**
184
+ * An interface meant to be implemented by MemberExpression,
185
+ * Identifier and ChainExpression and all Literal expressions
186
+ */
49
187
  export interface CanFindScope {
50
- findScope<T extends object>(stack: Stack): Scope<T>;
51
- findScope<T extends object>(stack: Stack, scope: Scope<any>): Scope<T>;
52
- findScope<T extends object>(stack: Stack, scope?: Scope<any>): Scope<T> | undefined;
188
+ /**
189
+ * try to search for scope of this expression
190
+ * @param stack
191
+ */
192
+ findScope<T extends ScopeContext>(stack: Stack): Scope<T>;
193
+ findScope<T extends ScopeContext>(stack: Stack, scope: Scope<ScopeContext>): Scope<T>;
194
+ findScope<T extends ScopeContext>(stack: Stack, scope?: Scope<ScopeContext>): Scope<T> | undefined;
53
195
  }
54
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/expressions/api/expression.ts"],"names":[],"mappings":"","sourcesContent":["import type { Scope, ScopeType } from '../scope/scope.js';\nimport type { Stack } from '../scope/stack.js';\n\nexport type NodeType = { type: string };\nexport type NodeJsonType = { [key: string]: any } & NodeType;\n\nexport type ExpressionEventPathDotNotation = { computed: false, path: string };\nexport type ExpressionEventPathBracketNotation = { computed: true, path: string, computedPath: ExpressionEventPath[][] };\nexport type ExpressionEventPath = ExpressionEventPathDotNotation | ExpressionEventPathBracketNotation;\nexport type ExpressionEventMap = { [key: string]: ExpressionEventMap };\n\nexport interface ExpressionNode {\n\n\t/**\n\t * pass scope list from outer function to inner function,\n\t * \n\t * all other end point expression should do nothing,\n\t * if this function executed.\n\t * \n\t * @param scopeList all outer function scopes given to the inner function,\n\t * this solution ignore the fact that some inner function has no need to\n\t * get shared variables, as its implementation never say that\n\t * ```js\n\t * function f(d) {\n\t * \t\tfunction g() {\n\t * \t\t\tconst a = ({ d }) => d;\n\t * \t\t\treturn a;\n\t * \t\t}\n\t * \t\treturn [d, g];\n\t * }\n\t * ```\n\t */\n\tshareVariables(scopeList: Scope<any>[]): void;\n\n\t/**\n\t * assign the value to this expression in stack.\n\t * \n\t * most ExpressionNode will not implement this method, and will throw an exception.\n\t * @param stack \n\t * @param value \n\t */\n\tset(stack: Stack, value: any): any;\n\n\t/**\n\t * execute/get the code for this expression and return the result value.\n\t * @param stack \n\t * @param thisContext \n\t */\n\tget(stack: Stack, thisContext?: any): any;\n\n\t/**\n\t * get all dependencies form an expression node\n\t *\n\t * tha return from this method, is represent an answer for what identifiers this expression depends-on.\n\t * \n\t *\n\t * ex:\n\t * ```js\n\t * x + y;\n\t * ```\n\t *\n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier:\tthe answer should be node `x`,\n\t * - for `y` identifier:\tthe answer should be node `y`.\n\t *\n\t * so, the return from `+` will be `[ node 'x', node 'y']`\n\t *\n\t * and:\n\t * - `x.y.z * a` ==> `[ member node `x.y.z`, identifier 'a']`\n\t * @param computed\n\t */\n\tdependency(computed?: true): ExpressionNode[];\n\n\t/**\n\t * ex:\n\t * ```js\n\t * x + y;\n\t * ```\n\t *\n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier:\tthe answer should be node `x`,\n\t * - for `y` identifier:\tthe answer should be node `y`.\n\t *\n\t * so, the return from `+` will be `['x', 'y']`\n\t *\n\t * and:\n\t * - `x.y.z` ==> `['x', 'y', 'z']`\n\t * - `x[y].z` ==> ['x', ]\n\t * @param computed required for member and chaining operators\n\t */\n\tdependencyPath(computed?: true): ExpressionEventPath[];\n\n\t/**\n\t * get all the events form this expression\n\t * \n\t * tha return from this method, is represent an answer for what is this expression depends-on as identifier name\n\t * \n\t * ex: \n\t * ```js\n\t * x + y;\n\t * ```\n\t * \n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier: the answer should be `x`\n\t * - for `y` identifier: the answer should be `y`\n\t * the final output will be \n\t * \n\t * so, the return from `+` will be `{ x: undefined, y: undefined }`\n\t * \n\t * and:\n\t * - `x.y.z * a` ==> `{ x: { y: { z: undefined }, a: undefined } }`\n\t * - `x.y.z > x.y.h.g` ==> `{ x: { y: { z: undefined, h: { g: undefined} } } }`\n\t * - `x[Symbol.toStringTag] + 'Class' + classType + array[3]` ==> `{ x: { 'Symbol.toStringTag': undefined }, classType: undefined, array: { 3: undefined } }`\n\t * - `'name'` ==> {}\n\t * - ```js\n\t * user[firstName + `son of ${fatherName}`]\n\t * ``` ==> `{ user: { 'firstName:fatherName': undefined }, firstName: undefined, fatherName: undefined }`\n\t * @param parent \n\t */\n\tevents(): ExpressionEventMap;\n\n\n\t/**\n\t * re-write this expression as a javascript source \n\t */\n\ttoString(): string;\n\n\t/**\n\t * used to map this object to represent an [ESTree](https://github.com/estree/estree) json object\n\t * @param key \n\t */\n\ttoJSON(): NodeJsonType;\n\n\t/**\n\t * just a helper method to force class that implement this interface to\n\t * have a static method `fromJSON` to help reconstruct this ExpressionNode\n\t * from an [ESTree](https://github.com/estree/estree) json object,\n\t * with all necessary implementation to execute the code\n\t */\n\tgetClass(): NodeExpressionClass<ExpressionNode>;\n}\n\ninterface TypeOf<T> {\n\tnew(...params: any[]): T;\n}\n\nexport type NodeDeserializer<N = ExpressionNode> = (node: N) => N;\n\nexport type VisitNodeType = (expression: ExpressionNode) => void;\nexport type VisitNodeListType = (expressions: ExpressionNode[]) => void;\n\n/**\n * this is how to:\n * describe a class with it's static functions and properties\n * in the interface add getClass method\n */\nexport interface NodeExpressionClass<N extends ExpressionNode> extends TypeOf<N> {\n\n\t/**\n\t * build expression node from [ESTree](https://github.com/estree/estree) json object\n\t * @param node \n\t * @param deserializer \n\t */\n\tfromJSON(node: N, deserializer: NodeDeserializer): N;\n\n\t/**\n\t * visit nodes inside expression\n\t * @param expression \n\t * @param callback \n\t */\n\tvisit?(node: N, visitNode: VisitNodeType, visitNodeList: VisitNodeListType): void;\n}\n\nexport interface NodeExpressionWithType<N extends ExpressionNode> extends NodeExpressionClass<N> {\n\n\t/**\n\t * the type of an expression\n\t */\n\ttype: string;\n}\n\nexport interface CanDeclareExpression extends ExpressionNode {\n\t/**\n\t * declare variable in the current local scope (block),\n\t * or closest function scope (global) scop,\n\t * the propertyName will be calculated at runtime\n\t * @param stack the stack which an identifier will be declared\n\t * @param propertyValue the initial value of identifier\n\t * @param scope which scop to declare this identifier\n\t */\n\tdeclareVariable(stack: Stack, scopeType: ScopeType, propertyValue?: any): any;\n}\n\n\n/**\n * An interface meant to be implemented by MemberExpression,\n * Identifier and ChainExpression and all Literal expressions\n */\nexport interface CanFindScope {\n\t/**\n\t * try to search for scope of this expression\n\t * @param stack \n\t */\n\tfindScope<T extends object>(stack: Stack): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope: Scope<any>): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope?: Scope<any>): Scope<T> | undefined;\n}\n"]}
1
+ {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/expressions/api/expression.ts"],"names":[],"mappings":"","sourcesContent":["import type { Scope, ScopeContext } from '../scope/scope.js';\nimport type { Stack } from '../scope/stack.js';\nimport { TypeOf } from './utils.js';\n\nexport type NodeType = { type: string };\nexport type NodeJsonType = { [key: string]: any } & NodeType;\n\nexport type ExpressionEventPathDotNotation = { computed: false, path: string };\nexport type ExpressionEventPathBracketNotation = { computed: true, path: string, computedPath: ExpressionEventPath[][] };\nexport type ExpressionEventPath = ExpressionEventPathDotNotation | ExpressionEventPathBracketNotation;\nexport type ExpressionEventMap = { [key: string]: ExpressionEventMap };\n\nexport interface ExpressionNode {\n\n\t/**\n\t * pass scope list from outer function to inner function,\n\t * \n\t * all other end point expression should do nothing,\n\t * if this function executed.\n\t * \n\t * @param scopeList all outer function scopes given to the inner function,\n\t * this solution ignore the fact that some inner function has no need to\n\t * get shared variables, as its implementation never say that\n\t * ```js\n\t * function f(d) {\n\t * \t\tfunction g() {\n\t * \t\t\tconst a = ({ d }) => d;\n\t * \t\t\treturn a;\n\t * \t\t}\n\t * \t\treturn [d, g];\n\t * }\n\t * ```\n\t */\n\tshareVariables(scopeList: Scope<ScopeContext>[]): void;\n\n\t/**\n\t * assign the value to this expression in stack.\n\t * \n\t * most ExpressionNode will not implement this method, and will throw an exception.\n\t * @param stack \n\t * @param value \n\t */\n\tset(stack: Stack, value: any): any;\n\n\t/**\n\t * execute/get the code for this expression and return the result value.\n\t * @param stack \n\t * @param thisContext \n\t */\n\tget(stack: Stack, thisContext?: any): any;\n\n\t/**\n\t * get all dependencies form an expression node\n\t *\n\t * tha return from this method, is represent an answer for what identifiers this expression depends-on.\n\t * \n\t *\n\t * ex:\n\t * ```js\n\t * x + y;\n\t * ```\n\t *\n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier:\tthe answer should be node `x`,\n\t * - for `y` identifier:\tthe answer should be node `y`.\n\t *\n\t * so, the return from `+` will be `[ node 'x', node 'y']`\n\t *\n\t * and:\n\t * - `x.y.z * a` ==> `[ member node `x.y.z`, identifier 'a']`\n\t * @param computed\n\t */\n\tdependency(computed?: true): ExpressionNode[];\n\n\t/**\n\t * ex:\n\t * ```js\n\t * x + y;\n\t * ```\n\t *\n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier:\tthe answer should be node `x`,\n\t * - for `y` identifier:\tthe answer should be node `y`.\n\t *\n\t * so, the return from `+` will be `['x', 'y']`\n\t *\n\t * and:\n\t * - `x.y.z` ==> `['x', 'y', 'z']`\n\t * - `x[y].z` ==> ['x', ]\n\t * @param computed required for member and chaining operators\n\t */\n\tdependencyPath(computed?: true): ExpressionEventPath[];\n\n\t/**\n\t * get all the events form this expression\n\t * \n\t * tha return from this method, is represent an answer for what is this expression depends-on as identifier name\n\t * \n\t * ex: \n\t * ```js\n\t * x + y;\n\t * ```\n\t * \n\t * - for `+` operator :\tthe answer should be `lhs` and `rhs`,\n\t * - for `x` identifier: the answer should be `x`\n\t * - for `y` identifier: the answer should be `y`\n\t * the final output will be \n\t * \n\t * so, the return from `+` will be `{ x: undefined, y: undefined }`\n\t * \n\t * and:\n\t * - `x.y.z * a` ==> `{ x: { y: { z: undefined }, a: undefined } }`\n\t * - `x.y.z > x.y.h.g` ==> `{ x: { y: { z: undefined, h: { g: undefined} } } }`\n\t * - `x[Symbol.toStringTag] + 'Class' + classType + array[3]` ==> `{ x: { 'Symbol.toStringTag': undefined }, classType: undefined, array: { 3: undefined } }`\n\t * - `'name'` ==> {}\n\t * - ```js\n\t * user[firstName + `son of ${fatherName}`]\n\t * ``` ==> `{ user: { 'firstName:fatherName': undefined }, firstName: undefined, fatherName: undefined }`\n\t * @param parent \n\t */\n\tevents(): ExpressionEventMap;\n\n\n\t/**\n\t * re-write this expression as a javascript source \n\t */\n\ttoString(): string;\n\n\t/**\n\t * used to map this object to represent an [ESTree](https://github.com/estree/estree) json object\n\t * @param key \n\t */\n\ttoJSON(): NodeJsonType;\n\n\t/**\n\t * just a helper method to force class that implement this interface to\n\t * have a static method `fromJSON` to help reconstruct this ExpressionNode\n\t * from an [ESTree](https://github.com/estree/estree) json object,\n\t * with all necessary implementation to execute the code\n\t */\n\tgetClass(): ExpressionNodConstructor<ExpressionNode>;\n}\n\nexport type NodeDeserializer<N = ExpressionNode> = (node: N) => N;\n\nexport type VisitNodeType = (expression: ExpressionNode) => void;\n\n/**\n * this is how to:\n * describe a class with it's static functions and properties\n * in the interface add getClass method\n */\nexport interface ExpressionNodConstructor<N extends ExpressionNode> extends TypeOf<N> {\n\n\t/**\n\t * the type of an expression\n\t */\n\ttype: string;\n\n\t/**\n\t * build expression node from [ESTree](https://github.com/estree/estree) json object\n\t * @param node \n\t * @param deserializer \n\t */\n\tfromJSON(node: N, deserializer: NodeDeserializer): N;\n\n\t/**\n\t * visit nodes inside expression\n\t * @param expression \n\t * @param callback \n\t */\n\tvisit?(node: N, visitNode: Object): void;\n}\n\nexport interface DeclarationExpression extends ExpressionNode {\n\t/**\n\t * declare variable in the current local scope (block),\n\t * or closest function scope (global) scop,\n\t * the propertyName will be calculated at runtime\n\t * @param stack the stack which an identifier will be declared\n\t * @param propertyValue the initial value of identifier\n\t * @param scope which scop to declare this identifier\n\t */\n\tdeclareVariable(stack: Stack, propertyValue?: any): any;\n\n\t/**\n\t * get the variable declaration name\n\t */\n\tgetDeclarationName?(): string;\n}\n\n\n/**\n * An interface meant to be implemented by MemberExpression,\n * Identifier and ChainExpression and all Literal expressions\n */\nexport interface CanFindScope {\n\t/**\n\t * try to search for scope of this expression\n\t * @param stack \n\t */\n\tfindScope<T extends ScopeContext>(stack: Stack): Scope<T>;\n\tfindScope<T extends ScopeContext>(stack: Stack, scope: Scope<ScopeContext>): Scope<T>;\n\tfindScope<T extends ScopeContext>(stack: Stack, scope?: Scope<ScopeContext>): Scope<T> | undefined;\n}\n"]}
package/api/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './expression.js';
2
2
  export * from './abstract.js';
3
3
  export * from './deserialize/deserialize.js';
4
+ export * from './program.js';
4
5
  export * from './definition/values.js';
5
6
  export * from './definition/array.js';
6
7
  export * from './definition/comment.js';
@@ -10,6 +11,7 @@ export * from './definition/bind.js';
10
11
  export * from './definition/object.js';
11
12
  export * from './definition/statement.js';
12
13
  export * from './computing/call.js';
14
+ export * from './computing/debugger.js';
13
15
  export * from './computing/new.js';
14
16
  export * from './computing/return.js';
15
17
  export * from './computing/spread.js';
package/api/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './expression.js';
2
2
  export * from './abstract.js';
3
3
  export * from './deserialize/deserialize.js';
4
+ export * from './program.js';
4
5
  export * from './definition/values.js';
5
6
  export * from './definition/array.js';
6
7
  export * from './definition/comment.js';
@@ -10,6 +11,7 @@ export * from './definition/bind.js';
10
11
  export * from './definition/object.js';
11
12
  export * from './definition/statement.js';
12
13
  export * from './computing/call.js';
14
+ export * from './computing/debugger.js';
13
15
  export * from './computing/new.js';
14
16
  export * from './computing/return.js';
15
17
  export * from './computing/spread.js';
package/api/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/expressions/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAE9B,cAAc,8BAA8B,CAAC;AAE7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AAErC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AAEjD,cAAc,sCAAsC,CAAC;AAErD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './expression.js';\nexport * from './abstract.js';\n\nexport * from './deserialize/deserialize.js';\n\nexport * from './definition/values.js';\nexport * from './definition/array.js';\nexport * from './definition/comment.js';\nexport * from './definition/function.js';\nexport * from './definition/member.js';\nexport * from './definition/bind.js';\nexport * from './definition/object.js';\nexport * from './definition/statement.js';\n\nexport * from './computing/call.js';\nexport * from './computing/new.js';\nexport * from './computing/return.js';\nexport * from './computing/spread.js';\nexport * from './computing/rest.js';\nexport * from './computing/throw.js';\nexport * from './computing/yield.js';\n\nexport * from './operators/assignment.js';\nexport * from './operators/await.js';\nexport * from './operators/binary.js';\nexport * from './operators/chaining.js';\nexport * from './operators/comma.js';\nexport * from './operators/grouping.js';\nexport * from './operators/logical.js';\nexport * from './operators/pipeline.js';\nexport * from './operators/ternary.js';\nexport * from './operators/types.js';\nexport * from './operators/unary.js';\nexport * from './operators/update.js';\n\nexport * from './statement/control/block.js';\nexport * from './statement/control/empty.js';\nexport * from './statement/control/if.js';\nexport * from './statement/control/switch.js';\nexport * from './statement/control/terminate.js';\n\nexport * from './statement/declarations/declares.js';\n\nexport * from './statement/iterations/for.js';\nexport * from './statement/iterations/while.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/expressions/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAE9B,cAAc,8BAA8B,CAAC;AAE7C,cAAc,cAAc,CAAC;AAE7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AAErC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AAEjD,cAAc,sCAAsC,CAAC;AAErD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './expression.js';\nexport * from './abstract.js';\n\nexport * from './deserialize/deserialize.js';\n\nexport * from './program.js';\n\nexport * from './definition/values.js';\nexport * from './definition/array.js';\nexport * from './definition/comment.js';\nexport * from './definition/function.js';\nexport * from './definition/member.js';\nexport * from './definition/bind.js';\nexport * from './definition/object.js';\nexport * from './definition/statement.js';\n\nexport * from './computing/call.js';\nexport * from './computing/debugger.js';\nexport * from './computing/new.js';\nexport * from './computing/return.js';\nexport * from './computing/spread.js';\nexport * from './computing/rest.js';\nexport * from './computing/throw.js';\nexport * from './computing/yield.js';\n\nexport * from './operators/assignment.js';\nexport * from './operators/await.js';\nexport * from './operators/binary.js';\nexport * from './operators/chaining.js';\nexport * from './operators/comma.js';\nexport * from './operators/grouping.js';\nexport * from './operators/logical.js';\nexport * from './operators/pipeline.js';\nexport * from './operators/ternary.js';\nexport * from './operators/types.js';\nexport * from './operators/unary.js';\nexport * from './operators/update.js';\n\nexport * from './statement/control/block.js';\nexport * from './statement/control/empty.js';\nexport * from './statement/control/if.js';\nexport * from './statement/control/switch.js';\nexport * from './statement/control/terminate.js';\n\nexport * from './statement/declarations/declares.js';\n\nexport * from './statement/iterations/for.js';\nexport * from './statement/iterations/while.js';\n"]}
@@ -0,0 +1,29 @@
1
+ import { Scope } from '../../scope/scope.js';
2
+ import { Stack } from '../../scope/stack.js';
3
+ import { AbstractExpressionNode } from '../abstract.js';
4
+ import { Identifier, Literal } from '../definition/values.js';
5
+ import { ExpressionEventPath, ExpressionNode, NodeDeserializer, VisitNodeType } from '../expression.js';
6
+ export declare abstract class ModuleSpecifier extends AbstractExpressionNode {
7
+ protected local: Identifier;
8
+ constructor(local: Identifier);
9
+ getLocal(): Identifier;
10
+ toJson(): object;
11
+ }
12
+ export declare class ImportAttribute extends AbstractExpressionNode {
13
+ private key;
14
+ private value;
15
+ static fromJSON(node: ImportAttribute, deserializer: NodeDeserializer): ImportAttribute;
16
+ static visit(node: ImportAttribute, visitNode: VisitNodeType): void;
17
+ constructor(key: Identifier | Literal<string>, value: Literal<string>);
18
+ getKey(): Identifier | Literal<string>;
19
+ getValue(): Literal<string>;
20
+ shareVariables(scopeList: Scope<any>[]): void;
21
+ set(stack: Stack, value: any): void;
22
+ get(stack: Stack, thisContext?: any): {
23
+ [key: string]: string;
24
+ };
25
+ dependency(computed?: true): ExpressionNode[];
26
+ dependencyPath(computed?: true): ExpressionEventPath[];
27
+ toString(): string;
28
+ toJson(): object;
29
+ }
@@ -0,0 +1,71 @@
1
+ var ImportAttribute_1;
2
+ import { __decorate, __metadata } from "tslib";
3
+ import { AbstractExpressionNode } from '../abstract.js';
4
+ import { Literal } from '../definition/values.js';
5
+ import { Deserializer } from '../deserialize/deserialize.js';
6
+ export class ModuleSpecifier extends AbstractExpressionNode {
7
+ constructor(local) {
8
+ super();
9
+ this.local = local;
10
+ }
11
+ getLocal() {
12
+ return this.local;
13
+ }
14
+ toJson() {
15
+ return {
16
+ local: this.local.toJSON()
17
+ };
18
+ }
19
+ }
20
+ let ImportAttribute = ImportAttribute_1 = class ImportAttribute extends AbstractExpressionNode {
21
+ constructor(key, value) {
22
+ super();
23
+ this.key = key;
24
+ this.value = value;
25
+ }
26
+ static fromJSON(node, deserializer) {
27
+ return new ImportAttribute_1(deserializer(node.key), deserializer(node.value));
28
+ }
29
+ static visit(node, visitNode) {
30
+ visitNode(node.key);
31
+ visitNode(node.value);
32
+ }
33
+ getKey() {
34
+ return this.key;
35
+ }
36
+ getValue() {
37
+ return this.value;
38
+ }
39
+ shareVariables(scopeList) {
40
+ throw new Error('Method not implemented.');
41
+ }
42
+ set(stack, value) {
43
+ throw new Error('Method not implemented.');
44
+ }
45
+ get(stack, thisContext) {
46
+ const key = this.key.get(stack);
47
+ const value = this.value.get();
48
+ return { [key]: value };
49
+ }
50
+ dependency(computed) {
51
+ return [];
52
+ }
53
+ dependencyPath(computed) {
54
+ return [];
55
+ }
56
+ toString() {
57
+ return `${this.key.toString()}: ${this.value.toString()}`;
58
+ }
59
+ toJson() {
60
+ return {
61
+ key: this.key.toJSON(),
62
+ value: this.value.toJSON(),
63
+ };
64
+ }
65
+ };
66
+ ImportAttribute = ImportAttribute_1 = __decorate([
67
+ Deserializer('ImportAttribute'),
68
+ __metadata("design:paramtypes", [Object, Literal])
69
+ ], ImportAttribute);
70
+ export { ImportAttribute };
71
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/expressions/api/module/common.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAc,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,MAAM,OAAgB,eAAgB,SAAQ,sBAAsB;IACnE,YAAsB,KAAiB;QACtC,KAAK,EAAE,CAAC;QADa,UAAK,GAAL,KAAK,CAAY;IAEvC,CAAC;IACD,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,MAAM;QACL,OAAO;YACN,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;SAC1B,CAAC;IACH,CAAC;CACD;AAKD,IAAa,eAAe,uBAA5B,MAAa,eAAgB,SAAQ,sBAAsB;IAY1D,YAAoB,GAAiC,EAAU,KAAsB;QACpF,KAAK,EAAE,CAAC;QADW,QAAG,GAAH,GAAG,CAA8B;QAAU,UAAK,GAAL,KAAK,CAAiB;IAErF,CAAC;IAbD,MAAM,CAAC,QAAQ,CAAC,IAAqB,EAAE,YAA8B;QACpE,OAAO,IAAI,iBAAe,CACzB,YAAY,CAAC,IAAI,CAAC,GAAG,CAAe,EACpC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAoB,CAC3C,CAAC;IACH,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,IAAqB,EAAE,SAAwB;QAC3D,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAKD,MAAM;QACL,OAAO,IAAI,CAAC,GAAG,CAAC;IACjB,CAAC;IACD,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,cAAc,CAAC,SAAuB;QACrC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,GAAG,CAAC,KAAY,EAAE,KAAU;QAC3B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IACD,GAAG,CAAC,KAAY,EAAE,WAAiB;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;IACzB,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,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC3D,CAAC;IACD,MAAM;QACL,OAAO;YACN,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;YACtB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;SAC1B,CAAC;IACH,CAAC;CACD,CAAA;AA/CY,eAAe;IAD3B,YAAY,CAAC,iBAAiB,CAAC;6CAauC,OAAO;GAZjE,eAAe,CA+C3B;SA/CY,eAAe","sourcesContent":["import { Scope } from '../../scope/scope.js';\nimport { Stack } from '../../scope/stack.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Identifier, Literal } from '../definition/values.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { ExpressionEventPath, ExpressionNode, NodeDeserializer, VisitNodeType } from '../expression.js';\n\nexport abstract class ModuleSpecifier extends AbstractExpressionNode {\n\tconstructor(protected local: Identifier) {\n\t\tsuper();\n\t}\n\tgetLocal() {\n\t\treturn this.local;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tlocal: this.local.toJSON()\n\t\t};\n\t}\n}\n\n\n\n@Deserializer('ImportAttribute')\nexport class ImportAttribute extends AbstractExpressionNode {\n\tstatic fromJSON(node: ImportAttribute, deserializer: NodeDeserializer): ImportAttribute {\n\t\treturn new ImportAttribute(\n\t\t\tdeserializer(node.key) as Identifier,\n\t\t\tdeserializer(node.value) as Literal<string>\n\t\t);\n\t}\n\tstatic visit(node: ImportAttribute, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.key);\n\t\tvisitNode(node.value);\n\t}\n\n\tconstructor(private key: Identifier | Literal<string>, private value: Literal<string>) {\n\t\tsuper();\n\t}\n\tgetKey() {\n\t\treturn this.key;\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tget(stack: Stack, thisContext?: any): { [key: string]: string } {\n\t\tconst key = this.key.get(stack);\n\t\tconst value = this.value.get();\n\t\treturn { [key]: value };\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.key.toString()}: ${this.value.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tkey: this.key.toJSON(),\n\t\t\tvalue: this.value.toJSON(),\n\t\t};\n\t}\n}\n"]}
@@ -1,31 +1,135 @@
1
- import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType, VisitNodeListType } from '../expression.js';
2
- import type { Scope } from '../../scope/scope.js';
3
- import type { Stack } from '../../scope/stack.js';
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
+ */
34
+ import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType, DeclarationExpression } from '../expression.js';
35
+ import { Scope } from '../../scope/scope.js';
36
+ import { Stack } from '../../scope/stack.js';
4
37
  import { AbstractExpressionNode } from '../abstract.js';
5
- export declare class ExportAliasName {
6
- exportName: ExpressionNode;
7
- protected _aliasName?: ExpressionNode | undefined;
8
- static visit(node: ExportAliasName, visitNode: VisitNodeType, visitNodeList: VisitNodeListType): void;
9
- constructor(exportName: ExpressionNode, _aliasName?: ExpressionNode | undefined);
10
- get aliasName(): ExpressionNode;
11
- set aliasName(_aliasName: ExpressionNode);
38
+ import { Identifier, Literal } from '../definition/values.js';
39
+ import { ImportAttribute, ModuleSpecifier } from './common.js';
40
+ import { FunctionDeclaration } from '../definition/function.js';
41
+ import { ClassDeclaration } from '../class/class.js';
42
+ /**
43
+ * An exported variable binding, e.g., `{foo}` in `export {foo}` or `{bar as foo}` in `export {bar as foo}`.
44
+ *
45
+ * The `exported` field refers to the name exported in the module.
46
+ *
47
+ * The `local` field refers to the binding into the local module scope.
48
+ *
49
+ * If it is a basic named export, such as in `export {foo}`, both `exported` and `local` are equivalent `Identifier` nodes;
50
+ * in this case an Identifier node representing `foo`.
51
+ *
52
+ * If it is an aliased export,
53
+ * such as in `export {bar as foo}`, the `exported` field is an `Identifier` node representing `foo`,
54
+ * and the `local` field is an `Identifier` node representing `bar`.
55
+ */
56
+ export declare class ExportSpecifier extends ModuleSpecifier {
57
+ private exported;
58
+ static fromJSON(node: ExportSpecifier, deserializer: NodeDeserializer): ExportSpecifier;
59
+ static visit(node: ExportSpecifier, visitNode: VisitNodeType): void;
60
+ constructor(local: Identifier, exported: Identifier);
61
+ getExported(): Identifier;
62
+ shareVariables(scopeList: Scope<any>[]): void;
63
+ set(stack: Stack, value: any): void;
64
+ get(stack: Stack, thisContext?: any): void;
65
+ dependency(computed?: true): ExpressionNode[];
66
+ dependencyPath(computed?: true): ExpressionEventPath[];
67
+ toString(): string;
68
+ toJson(): object;
69
+ }
70
+ /**
71
+ * An export named declaration, e.g.,
72
+ * `export {foo, bar};`,
73
+ * `export {foo} from "mod";`
74
+ * or `export var foo = 1;`.
75
+ *
76
+ * Note: Having `declaration` populated with non-empty `specifiers` or non-null `source` results in an invalid state.
77
+ */
78
+ export declare class ExportNamedDeclaration extends AbstractExpressionNode {
79
+ private specifiers;
80
+ private declaration?;
81
+ private source?;
82
+ private assertions?;
83
+ static fromJSON(node: ExportNamedDeclaration, deserializer: NodeDeserializer): ExportNamedDeclaration;
84
+ static visit(node: ExportNamedDeclaration, visitNode: VisitNodeType): void;
85
+ constructor(specifiers: ExportSpecifier[], declaration?: DeclarationExpression | undefined, source?: Literal<string> | undefined, assertions?: ImportAttribute[] | undefined);
86
+ getSource(): Literal<string> | undefined;
87
+ getSpecifiers(): ExportSpecifier[];
88
+ getDeclaration(): DeclarationExpression | undefined;
89
+ getAssertions(): ImportAttribute[] | undefined;
90
+ shareVariables(scopeList: Scope<any>[]): void;
91
+ set(stack: Stack): void;
92
+ get(stack: Stack): void;
93
+ private exportDeclaration;
94
+ private exportFromSource;
95
+ private exportLocal;
96
+ dependency(computed?: true): ExpressionNode[];
97
+ dependencyPath(computed?: true): ExpressionEventPath[];
98
+ toString(): string;
99
+ toJson(): object;
100
+ }
101
+ /**
102
+ * An export default declaration, e.g.,
103
+ * `export default function () {};`
104
+ * or `export default 1;`.
105
+ */
106
+ export declare class ExportDefaultDeclaration extends AbstractExpressionNode {
107
+ private declaration;
108
+ static fromJSON(node: ExportDefaultDeclaration, deserializer: NodeDeserializer): ExportDefaultDeclaration;
109
+ static visit(node: ExportDefaultDeclaration, visitNode: VisitNodeType): void;
110
+ constructor(declaration: FunctionDeclaration | ClassDeclaration | ExpressionNode);
111
+ getDeclaration(): ExpressionNode | FunctionDeclaration | ClassDeclaration;
112
+ shareVariables(scopeList: Scope<any>[]): void;
113
+ set(stack: Stack): void;
114
+ get(stack: Stack): void;
115
+ dependency(computed?: true): ExpressionNode[];
116
+ dependencyPath(computed?: true): ExpressionEventPath[];
12
117
  toString(): string;
13
- toJSON(): {
14
- exportName: import("../expression.js").NodeJsonType;
15
- aliasName: import("../expression.js").NodeJsonType | undefined;
16
- };
118
+ toJson(): object;
17
119
  }
18
- export declare class ExportNode extends AbstractExpressionNode {
19
- private exportList?;
20
- private starExport?;
21
- private exportExpression?;
22
- private moduleName?;
23
- static fromJSON(node: ExportNode, deserializer: NodeDeserializer): ExportNode;
24
- static visit(node: ExportNode, visitNode: VisitNodeType, visitNodeList: VisitNodeListType): void;
25
- constructor(exportList?: ExportAliasName[] | undefined, starExport?: ExportAliasName | undefined, exportExpression?: ExportAliasName | undefined, moduleName?: ExpressionNode | undefined);
26
- getModuleName(): ExpressionNode | undefined;
27
- getExportExpression(): ExportAliasName | undefined;
28
- getExportList(): ExportAliasName[] | undefined;
120
+ /**
121
+ * An export batch declaration, e.g., `export * from "mod";`.
122
+ */
123
+ export declare class ExportAllDeclaration extends AbstractExpressionNode {
124
+ private source;
125
+ private exported?;
126
+ private assertions?;
127
+ static fromJSON(node: ExportAllDeclaration, deserializer: NodeDeserializer): ExportAllDeclaration;
128
+ static visit(node: ExportAllDeclaration, visitNode: VisitNodeType): void;
129
+ constructor(source: Literal<string>, exported?: Identifier | undefined, assertions?: ImportAttribute[] | undefined);
130
+ getSource(): Literal<string>;
131
+ getExported(): Identifier | undefined;
132
+ getAssertions(): ImportAttribute[] | undefined;
29
133
  shareVariables(scopeList: Scope<any>[]): void;
30
134
  set(stack: Stack): void;
31
135
  get(stack: Stack): void;