@ibyar/expressions 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -0
  3. package/api/abstract.d.ts +3 -3
  4. package/api/abstract.js +7 -2
  5. package/api/abstract.js.map +1 -1
  6. package/api/class/class.d.ts +45 -24
  7. package/api/class/class.js +158 -112
  8. package/api/class/class.js.map +1 -1
  9. package/api/computing/debugger.d.ts +15 -0
  10. package/api/computing/debugger.js +35 -0
  11. package/api/computing/debugger.js.map +1 -0
  12. package/api/computing/rest.d.ts +4 -4
  13. package/api/computing/rest.js.map +1 -1
  14. package/api/computing/return.d.ts +4 -0
  15. package/api/computing/return.js +5 -0
  16. package/api/computing/return.js.map +1 -1
  17. package/api/computing/throw.d.ts +4 -0
  18. package/api/computing/throw.js +4 -0
  19. package/api/computing/throw.js.map +1 -1
  20. package/api/definition/array.d.ts +7 -6
  21. package/api/definition/array.js +20 -14
  22. package/api/definition/array.js.map +1 -1
  23. package/api/definition/bind.d.ts +6 -0
  24. package/api/definition/bind.js +6 -0
  25. package/api/definition/bind.js.map +1 -1
  26. package/api/definition/function.d.ts +35 -46
  27. package/api/definition/function.js +282 -299
  28. package/api/definition/function.js.map +1 -1
  29. package/api/definition/member.js.map +1 -1
  30. package/api/definition/object.d.ts +9 -6
  31. package/api/definition/object.js +35 -5
  32. package/api/definition/object.js.map +1 -1
  33. package/api/definition/statement.js +5 -1
  34. package/api/definition/statement.js.map +1 -1
  35. package/api/definition/values.d.ts +43 -50
  36. package/api/definition/values.js +84 -149
  37. package/api/definition/values.js.map +1 -1
  38. package/api/deserialize/deserialize.d.ts +7 -1
  39. package/api/deserialize/deserialize.js +9 -1
  40. package/api/deserialize/deserialize.js.map +1 -1
  41. package/api/deserialize/type-store.d.ts +2 -2
  42. package/api/deserialize/type-store.js.map +1 -1
  43. package/api/expression.d.ts +156 -12
  44. package/api/expression.js.map +1 -1
  45. package/api/index.d.ts +2 -0
  46. package/api/index.js +2 -0
  47. package/api/index.js.map +1 -1
  48. package/api/module/common.d.ts +29 -0
  49. package/api/module/common.js +71 -0
  50. package/api/module/common.js.map +1 -0
  51. package/api/module/export.d.ts +78 -9
  52. package/api/module/export.js +120 -15
  53. package/api/module/export.js.map +1 -1
  54. package/api/module/import.d.ts +56 -8
  55. package/api/module/import.js +62 -19
  56. package/api/module/import.js.map +1 -1
  57. package/api/operators/grouping.d.ts +7 -0
  58. package/api/operators/grouping.js +7 -0
  59. package/api/operators/grouping.js.map +1 -1
  60. package/api/operators/pipeline.d.ts +12 -0
  61. package/api/operators/pipeline.js +12 -0
  62. package/api/operators/pipeline.js.map +1 -1
  63. package/api/operators/unary.js +3 -0
  64. package/api/operators/unary.js.map +1 -1
  65. package/api/{module/app/program.d.ts → program.d.ts} +5 -5
  66. package/api/{module/app/program.js → program.js} +3 -3
  67. package/api/program.js.map +1 -0
  68. package/api/statement/control/block.d.ts +5 -2
  69. package/api/statement/control/block.js +24 -21
  70. package/api/statement/control/block.js.map +1 -1
  71. package/api/statement/control/empty.d.ts +7 -0
  72. package/api/statement/control/empty.js +7 -0
  73. package/api/statement/control/empty.js.map +1 -1
  74. package/api/statement/control/if.d.ts +5 -0
  75. package/api/statement/control/if.js +5 -0
  76. package/api/statement/control/if.js.map +1 -1
  77. package/api/statement/control/switch.d.ts +6 -0
  78. package/api/statement/control/switch.js +17 -3
  79. package/api/statement/control/switch.js.map +1 -1
  80. package/api/statement/control/terminate.d.ts +44 -11
  81. package/api/statement/control/terminate.js +87 -18
  82. package/api/statement/control/terminate.js.map +1 -1
  83. package/api/statement/declarations/declares.d.ts +7 -7
  84. package/api/statement/declarations/declares.js +1 -1
  85. package/api/statement/declarations/declares.js.map +1 -1
  86. package/api/statement/iterations/for.d.ts +5 -0
  87. package/api/statement/iterations/for.js +35 -16
  88. package/api/statement/iterations/for.js.map +1 -1
  89. package/api/statement/iterations/while.d.ts +6 -0
  90. package/api/statement/iterations/while.js +25 -11
  91. package/api/statement/iterations/while.js.map +1 -1
  92. package/api/utils.d.ts +2 -0
  93. package/api/utils.js +3 -1
  94. package/api/utils.js.map +1 -1
  95. package/package.json +7 -5
  96. package/scope/event.d.ts +3 -3
  97. package/scope/event.js +2 -2
  98. package/scope/event.js.map +1 -1
  99. package/scope/pool.d.ts +7 -0
  100. package/scope/pool.js +29 -0
  101. package/scope/pool.js.map +1 -0
  102. package/scope/proxy.d.ts +6 -11
  103. package/scope/proxy.js +23 -52
  104. package/scope/proxy.js.map +1 -1
  105. package/scope/scope.d.ts +161 -38
  106. package/scope/scope.js +260 -106
  107. package/scope/scope.js.map +1 -1
  108. package/scope/stack.d.ts +97 -21
  109. package/scope/stack.js +13 -0
  110. package/scope/stack.js.map +1 -1
  111. package/v8/enums.d.ts +204 -0
  112. package/v8/enums.js +406 -0
  113. package/v8/enums.js.map +1 -0
  114. package/v8/index.d.ts +2 -1
  115. package/v8/index.js +2 -1
  116. package/v8/index.js.map +1 -1
  117. package/v8/inline.d.ts +213 -0
  118. package/v8/inline.js +2375 -0
  119. package/v8/inline.js.map +1 -0
  120. package/v8/nodes.d.ts +8 -7
  121. package/v8/nodes.js +39 -64
  122. package/v8/nodes.js.map +1 -1
  123. package/v8/parser.d.ts +49 -151
  124. package/v8/parser.js +839 -1608
  125. package/v8/parser.js.map +1 -1
  126. package/v8/stream.d.ts +39 -3
  127. package/v8/stream.js +685 -171
  128. package/v8/stream.js.map +1 -1
  129. package/v8/token.d.ts +244 -9
  130. package/v8/token.js +315 -47
  131. package/v8/token.js.map +1 -1
  132. package/visit/visitor.d.ts +3 -0
  133. package/visit/visitor.js.map +1 -1
  134. package/api/module/app/program.js.map +0 -1
  135. package/v8/app.d.ts +0 -0
  136. package/v8/app.js +0 -2
  137. package/v8/app.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { Scope, ScopeContext } from '../scope/scope.js';
1
+ import type { Scope, Context } from '../scope/scope.js';
2
2
  import type { Stack } from '../scope/stack.js';
3
3
  import { TypeOf } from './utils.js';
4
4
  export declare type NodeType = {
@@ -21,31 +21,175 @@ export declare type ExpressionEventMap = {
21
21
  [key: string]: ExpressionEventMap;
22
22
  };
23
23
  export interface ExpressionNode {
24
- shareVariables(scopeList: Scope<ScopeContext>[]): 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<Context>[]): 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
+ */
25
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
+ */
26
57
  get(stack: Stack, thisContext?: any): any;
58
+ /**
59
+ * get all dependencies form an expression node
60
+ *
61
+ * the 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
+ */
27
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
+ */
28
97
  dependencyPath(computed?: true): ExpressionEventPath[];
98
+ /**
99
+ * get all the events form this expression
100
+ *
101
+ * the 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
+ */
29
125
  events(): ExpressionEventMap;
126
+ /**
127
+ * re-write this expression as a javascript source
128
+ */
30
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
+ */
31
134
  toJSON(): NodeJsonType;
32
- getClass(): NodeExpressionClass<ExpressionNode>;
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>;
33
142
  }
34
143
  export declare type NodeDeserializer<N = ExpressionNode> = (node: N) => N;
35
144
  export declare type VisitNodeType = (expression: ExpressionNode) => void;
36
- export interface NodeExpressionClass<N extends ExpressionNode> extends TypeOf<N> {
37
- fromJSON(node: N, deserializer: NodeDeserializer): N;
38
- visit?(node: N, visitNode: VisitNodeType): void;
39
- }
40
- 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
+ */
41
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;
42
167
  }
43
- export interface CanDeclareExpression extends ExpressionNode {
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
+ */
44
177
  declareVariable(stack: Stack, propertyValue?: any): any;
178
+ /**
179
+ * get the variable declaration name
180
+ */
45
181
  getDeclarationName?(): string;
46
182
  }
183
+ /**
184
+ * An interface meant to be implemented by MemberExpression,
185
+ * Identifier and ChainExpression and all Literal expressions
186
+ */
47
187
  export interface CanFindScope {
48
- findScope<T extends ScopeContext>(stack: Stack): Scope<T>;
49
- findScope<T extends ScopeContext>(stack: Stack, scope: Scope<ScopeContext>): Scope<T>;
50
- findScope<T extends ScopeContext>(stack: Stack, scope?: Scope<ScopeContext>): Scope<T> | undefined;
188
+ /**
189
+ * try to search for scope of this expression
190
+ * @param stack
191
+ */
192
+ findScope<V extends Context>(stack: Stack): Scope<V>;
193
+ findScope<V extends Context>(stack: Stack, scope: Scope<Record<PropertyKey, V>>): Scope<V>;
194
+ findScope<V extends Context>(stack: Stack, scope?: Scope<Record<PropertyKey, V>>): Scope<V> | undefined;
51
195
  }
@@ -1 +1 @@
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(): NodeExpressionClass<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 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): 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, 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"]}
1
+ {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/expressions/api/expression.ts"],"names":[],"mappings":"","sourcesContent":["import type { Scope, Context } 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<Context>[]): 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 * the 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 * the 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<V extends Context>(stack: Stack): Scope<V>;\n\tfindScope<V extends Context>(stack: Stack, scope: Scope<Record<PropertyKey, V>>): Scope<V>;\n\tfindScope<V extends Context>(stack: Stack, scope?: Scope<Record<PropertyKey, V>>): Scope<V> | 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,11 +1,58 @@
1
- import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType, CanDeclareExpression } from '../expression.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';
2
35
  import { Scope } from '../../scope/scope.js';
3
36
  import { Stack } from '../../scope/stack.js';
4
37
  import { AbstractExpressionNode } from '../abstract.js';
5
- import { Identifier, StringLiteral } from '../definition/values.js';
6
- import { ModuleSpecifier } from './import.js';
38
+ import { Identifier, Literal } from '../definition/values.js';
39
+ import { ImportAttribute, ModuleSpecifier } from './common.js';
7
40
  import { FunctionDeclaration } from '../definition/function.js';
8
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
+ */
9
56
  export declare class ExportSpecifier extends ModuleSpecifier {
10
57
  private exported;
11
58
  static fromJSON(node: ExportSpecifier, deserializer: NodeDeserializer): ExportSpecifier;
@@ -20,16 +67,26 @@ export declare class ExportSpecifier extends ModuleSpecifier {
20
67
  toString(): string;
21
68
  toJson(): object;
22
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
+ */
23
78
  export declare class ExportNamedDeclaration extends AbstractExpressionNode {
24
79
  private specifiers;
25
- private source?;
26
80
  private declaration?;
81
+ private source?;
82
+ private assertions?;
27
83
  static fromJSON(node: ExportNamedDeclaration, deserializer: NodeDeserializer): ExportNamedDeclaration;
28
84
  static visit(node: ExportNamedDeclaration, visitNode: VisitNodeType): void;
29
- constructor(specifiers: ExportSpecifier[], source?: StringLiteral | undefined, declaration?: CanDeclareExpression | undefined);
30
- getSource(): StringLiteral | undefined;
85
+ constructor(specifiers: ExportSpecifier[], declaration?: DeclarationExpression | undefined, source?: Literal<string> | undefined, assertions?: ImportAttribute[] | undefined);
86
+ getSource(): Literal<string> | undefined;
31
87
  getSpecifiers(): ExportSpecifier[];
32
- getDeclaration(): CanDeclareExpression | undefined;
88
+ getDeclaration(): DeclarationExpression | undefined;
89
+ getAssertions(): ImportAttribute[] | undefined;
33
90
  shareVariables(scopeList: Scope<any>[]): void;
34
91
  set(stack: Stack): void;
35
92
  get(stack: Stack): void;
@@ -41,6 +98,11 @@ export declare class ExportNamedDeclaration extends AbstractExpressionNode {
41
98
  toString(): string;
42
99
  toJson(): object;
43
100
  }
101
+ /**
102
+ * An export default declaration, e.g.,
103
+ * `export default function () {};`
104
+ * or `export default 1;`.
105
+ */
44
106
  export declare class ExportDefaultDeclaration extends AbstractExpressionNode {
45
107
  private declaration;
46
108
  static fromJSON(node: ExportDefaultDeclaration, deserializer: NodeDeserializer): ExportDefaultDeclaration;
@@ -55,12 +117,19 @@ export declare class ExportDefaultDeclaration extends AbstractExpressionNode {
55
117
  toString(): string;
56
118
  toJson(): object;
57
119
  }
120
+ /**
121
+ * An export batch declaration, e.g., `export * from "mod";`.
122
+ */
58
123
  export declare class ExportAllDeclaration extends AbstractExpressionNode {
59
124
  private source;
125
+ private exported?;
126
+ private assertions?;
60
127
  static fromJSON(node: ExportAllDeclaration, deserializer: NodeDeserializer): ExportAllDeclaration;
61
128
  static visit(node: ExportAllDeclaration, visitNode: VisitNodeType): void;
62
- constructor(source: StringLiteral);
63
- getSource(): StringLiteral;
129
+ constructor(source: Literal<string>, exported?: Identifier | undefined, assertions?: ImportAttribute[] | undefined);
130
+ getSource(): Literal<string>;
131
+ getExported(): Identifier | undefined;
132
+ getAssertions(): ImportAttribute[] | undefined;
64
133
  shareVariables(scopeList: Scope<any>[]): void;
65
134
  set(stack: Stack): void;
66
135
  get(stack: Stack): void;