@ibyar/expressions 0.8.3 → 0.8.5

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 (171) hide show
  1. package/README.md +0 -3
  2. package/api/abstract.d.ts +6 -2
  3. package/api/abstract.js +15 -8
  4. package/api/abstract.js.map +1 -1
  5. package/api/class/class.d.ts +15 -18
  6. package/api/class/class.js +49 -61
  7. package/api/class/class.js.map +1 -1
  8. package/api/class/decorator.d.ts +2 -2
  9. package/api/class/decorator.js +6 -6
  10. package/api/class/decorator.js.map +1 -1
  11. package/api/computing/call.d.ts +2 -2
  12. package/api/computing/call.js +8 -8
  13. package/api/computing/call.js.map +1 -1
  14. package/api/computing/debugger.d.ts +1 -2
  15. package/api/computing/debugger.js +2 -3
  16. package/api/computing/debugger.js.map +1 -1
  17. package/api/computing/new.d.ts +2 -2
  18. package/api/computing/new.js +7 -7
  19. package/api/computing/new.js.map +1 -1
  20. package/api/computing/rest.d.ts +2 -2
  21. package/api/computing/rest.js +6 -6
  22. package/api/computing/rest.js.map +1 -1
  23. package/api/computing/return.d.ts +2 -2
  24. package/api/computing/return.js +6 -6
  25. package/api/computing/return.js.map +1 -1
  26. package/api/computing/spread.d.ts +2 -2
  27. package/api/computing/spread.js +6 -6
  28. package/api/computing/spread.js.map +1 -1
  29. package/api/computing/throw.d.ts +4 -4
  30. package/api/computing/throw.js +18 -18
  31. package/api/computing/throw.js.map +1 -1
  32. package/api/computing/yield.d.ts +2 -2
  33. package/api/computing/yield.js +7 -7
  34. package/api/computing/yield.js.map +1 -1
  35. package/api/definition/array.d.ts +3 -3
  36. package/api/definition/array.js +14 -14
  37. package/api/definition/array.js.map +1 -1
  38. package/api/definition/bind.d.ts +2 -2
  39. package/api/definition/bind.js +9 -9
  40. package/api/definition/bind.js.map +1 -1
  41. package/api/definition/comment.d.ts +3 -3
  42. package/api/definition/comment.js +6 -6
  43. package/api/definition/comment.js.map +1 -1
  44. package/api/definition/function.d.ts +17 -16
  45. package/api/definition/function.js +60 -55
  46. package/api/definition/function.js.map +1 -1
  47. package/api/definition/member.d.ts +2 -2
  48. package/api/definition/member.js +13 -9
  49. package/api/definition/member.js.map +1 -1
  50. package/api/definition/object.d.ts +4 -4
  51. package/api/definition/object.js +22 -22
  52. package/api/definition/object.js.map +1 -1
  53. package/api/definition/statement.d.ts +2 -2
  54. package/api/definition/statement.js +6 -6
  55. package/api/definition/statement.js.map +1 -1
  56. package/api/definition/values.d.ts +15 -37
  57. package/api/definition/values.js +49 -74
  58. package/api/definition/values.js.map +1 -1
  59. package/api/expression.d.ts +42 -8
  60. package/api/expression.js.map +1 -1
  61. package/api/index.d.ts +1 -0
  62. package/api/index.js +1 -0
  63. package/api/index.js.map +1 -1
  64. package/api/module/common.d.ts +3 -3
  65. package/api/module/common.js +9 -9
  66. package/api/module/common.js.map +1 -1
  67. package/api/module/export.d.ts +5 -5
  68. package/api/module/export.js +30 -29
  69. package/api/module/export.js.map +1 -1
  70. package/api/module/import.d.ts +4 -4
  71. package/api/module/import.js +24 -23
  72. package/api/module/import.js.map +1 -1
  73. package/api/operators/assignment.d.ts +3 -3
  74. package/api/operators/assignment.js +5 -5
  75. package/api/operators/assignment.js.map +1 -1
  76. package/api/operators/await.d.ts +3 -3
  77. package/api/operators/await.js +7 -7
  78. package/api/operators/await.js.map +1 -1
  79. package/api/operators/binary.d.ts +1 -1
  80. package/api/operators/binary.js +1 -1
  81. package/api/operators/binary.js.map +1 -1
  82. package/api/operators/chaining.d.ts +2 -2
  83. package/api/operators/chaining.js +6 -6
  84. package/api/operators/chaining.js.map +1 -1
  85. package/api/operators/comma.d.ts +2 -2
  86. package/api/operators/comma.js +6 -6
  87. package/api/operators/comma.js.map +1 -1
  88. package/api/operators/grouping.d.ts +2 -2
  89. package/api/operators/grouping.js +6 -6
  90. package/api/operators/grouping.js.map +1 -1
  91. package/api/operators/logical.d.ts +1 -1
  92. package/api/operators/logical.js +1 -1
  93. package/api/operators/logical.js.map +1 -1
  94. package/api/operators/pipeline.d.ts +3 -3
  95. package/api/operators/pipeline.js +8 -8
  96. package/api/operators/pipeline.js.map +1 -1
  97. package/api/operators/ternary.d.ts +2 -2
  98. package/api/operators/ternary.js +8 -8
  99. package/api/operators/ternary.js.map +1 -1
  100. package/api/operators/types.d.ts +1 -1
  101. package/api/operators/unary.d.ts +3 -3
  102. package/api/operators/unary.js +7 -7
  103. package/api/operators/unary.js.map +1 -1
  104. package/api/operators/update.d.ts +3 -3
  105. package/api/operators/update.js +8 -8
  106. package/api/operators/update.js.map +1 -1
  107. package/api/program.d.ts +3 -3
  108. package/api/program.js +7 -7
  109. package/api/program.js.map +1 -1
  110. package/api/statement/control/block.d.ts +2 -2
  111. package/api/statement/control/block.js +6 -6
  112. package/api/statement/control/block.js.map +1 -1
  113. package/api/statement/control/empty.d.ts +2 -3
  114. package/api/statement/control/empty.js +6 -7
  115. package/api/statement/control/empty.js.map +1 -1
  116. package/api/statement/control/if.d.ts +2 -2
  117. package/api/statement/control/if.js +8 -8
  118. package/api/statement/control/if.js.map +1 -1
  119. package/api/statement/control/switch.d.ts +4 -6
  120. package/api/statement/control/switch.js +19 -20
  121. package/api/statement/control/switch.js.map +1 -1
  122. package/api/statement/control/terminate.d.ts +4 -4
  123. package/api/statement/control/terminate.js +11 -15
  124. package/api/statement/control/terminate.js.map +1 -1
  125. package/api/statement/control/with.d.ts +21 -0
  126. package/api/statement/control/with.js +67 -0
  127. package/api/statement/control/with.js.map +1 -0
  128. package/api/statement/declarations/declares.d.ts +4 -4
  129. package/api/statement/declarations/declares.js +14 -14
  130. package/api/statement/declarations/declares.js.map +1 -1
  131. package/api/statement/iterations/for.d.ts +7 -7
  132. package/api/statement/iterations/for.js +35 -35
  133. package/api/statement/iterations/for.js.map +1 -1
  134. package/api/statement/iterations/while.d.ts +3 -3
  135. package/api/statement/iterations/while.js +14 -14
  136. package/api/statement/iterations/while.js.map +1 -1
  137. package/package.json +14 -4
  138. package/scope/finalizer.d.ts +1 -1
  139. package/scope/pool.d.ts +1 -1
  140. package/scope/proxy.d.ts +1 -1
  141. package/scope/proxy.js +1 -0
  142. package/scope/proxy.js.map +1 -1
  143. package/scope/scope.d.ts +2 -2
  144. package/scope/scope.js +13 -16
  145. package/scope/scope.js.map +1 -1
  146. package/scope/stack.js +23 -23
  147. package/scope/stack.js.map +1 -1
  148. package/v8/enums.d.ts +4 -2
  149. package/v8/enums.js.map +1 -1
  150. package/v8/factory.d.ts +148 -0
  151. package/v8/factory.js +499 -0
  152. package/v8/factory.js.map +1 -0
  153. package/v8/inline.d.ts +49 -49
  154. package/v8/inline.js +317 -307
  155. package/v8/inline.js.map +1 -1
  156. package/v8/node.d.ts +141 -0
  157. package/v8/node.js +2 -0
  158. package/v8/node.js.map +1 -0
  159. package/v8/nodes.d.ts +0 -14
  160. package/v8/nodes.js +1 -152
  161. package/v8/nodes.js.map +1 -1
  162. package/v8/parser.d.ts +21 -18
  163. package/v8/parser.js +97 -84
  164. package/v8/parser.js.map +1 -1
  165. package/v8/stream.d.ts +2 -1
  166. package/v8/stream.js +221 -311
  167. package/v8/stream.js.map +1 -1
  168. package/v8/token.d.ts +3 -1
  169. package/v8/token.js +7 -5
  170. package/v8/token.js.map +1 -1
  171. package/visit/visitor.d.ts +1 -1
package/scope/scope.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TypeOf } from '../api/utils.js';
2
- export declare type Context = Record<PropertyKey, any>;
2
+ export type Context = Record<PropertyKey, any>;
3
3
  export interface Scope<T = Context> {
4
4
  /**
5
5
  * get value of `propertyKey` in current context
@@ -73,7 +73,7 @@ export declare class ScopeSubscription<T> {
73
73
  resume(): void;
74
74
  unsubscribe(): void;
75
75
  }
76
- export declare type ValueChangedCallback = (newValue: any, oldValue?: any) => void;
76
+ export type ValueChangedCallback = (newValue: any, oldValue?: any) => void;
77
77
  export declare class ValueChangeObserver<T> {
78
78
  private _subscribers;
79
79
  private _lock;
package/scope/scope.js CHANGED
@@ -1,15 +1,15 @@
1
1
  export class Scope {
2
- constructor(_ctx, _keys) {
3
- this._ctx = _ctx;
4
- this._keys = _keys;
5
- this._inners = new Map();
6
- }
7
2
  static for(ctx, propertyKeys) {
8
3
  return new Scope(ctx, propertyKeys);
9
4
  }
10
5
  static blockScope(propertyKeys) {
11
6
  return new Scope({}, propertyKeys);
12
7
  }
8
+ constructor(_ctx, _keys) {
9
+ this._ctx = _ctx;
10
+ this._keys = _keys;
11
+ this._inners = new Map();
12
+ }
13
13
  get(key) {
14
14
  return Reflect.get(this._ctx, key);
15
15
  }
@@ -157,16 +157,6 @@ export class ValueChangeObserver {
157
157
  }
158
158
  }
159
159
  export class ReactiveScope extends Scope {
160
- constructor(context, propertyKeys, _name, _parent) {
161
- super(context, propertyKeys);
162
- this._name = _name;
163
- this._parent = _parent;
164
- this._observer = new ValueChangeObserver();
165
- this._clone = Object.assign({}, context);
166
- if (HTMLElement && context instanceof HTMLElement) {
167
- this._keys = [];
168
- }
169
- }
170
160
  static for(context, propertyKeys) {
171
161
  return new ReactiveScope(context, propertyKeys);
172
162
  }
@@ -191,6 +181,13 @@ export class ReactiveScope extends Scope {
191
181
  rootScope.setInnerScope('this', thisScope);
192
182
  return rootScope;
193
183
  }
184
+ constructor(context, propertyKeys, _name, _parent) {
185
+ super(context, propertyKeys);
186
+ this._name = _name;
187
+ this._parent = _parent;
188
+ this._observer = new ValueChangeObserver();
189
+ this._clone = Object.assign({}, context);
190
+ }
194
191
  set(propertyKey, newValue, receiver) {
195
192
  const oldValue = Reflect.get(this._ctx, propertyKey);
196
193
  const result = Reflect.set(this._ctx, propertyKey, newValue);
@@ -239,7 +236,7 @@ export class ReactiveScope extends Scope {
239
236
  const pt = typeof pv;
240
237
  const ct = typeof cv;
241
238
  if (pt === 'object') {
242
- if (ct === 'object') {
239
+ if (ct === 'object' && pv == cv) {
243
240
  this.getInnerScope(key)?.detectChanges();
244
241
  }
245
242
  else if (cv != pv) {
@@ -1 +1 @@
1
- {"version":3,"file":"scope.js","sourceRo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CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvF,CAAC;IACO,aAAa,CAAC,OAAY;QACjC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACpB,IAAI,CAAC,aAAa,EAAE,CAAC;IACtB,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD","sourcesContent":["import { TypeOf } from '../api/utils.js';\n\nexport type Context = Record<PropertyKey, any>;\nexport interface Scope<T = Context> {\n\n\t/**\n\t * get value of `propertyKey` in current context\n\t * @param propertyKey \n\t */\n\tget(propertyKey: keyof T): any;\n\n\t/**\n\t * set the value of `propertyKey` in current context, could be instilled with `value`.\n\t * @param propertyKey \n\t * @param value \n\t * @param receiver \n\t */\n\tset(propertyKey: keyof T, value?: any, receiver?: any): boolean;\n\n\t/**\n\t * is current context has `propertyKey` in hash map keys\n\t * @param propertyKey \n\t */\n\thas(propertyKey: keyof T): boolean;\n\n\t/**\n\t * delete property from context\n\t * @param propertyKey \n\t */\n\tdelete(propertyKey: keyof T): boolean;\n\n\t/**\n\t * get current context object of this scope\n\t */\n\tgetContext(): T;\n\n\t/**\n\t * get a proxy of the current context object if exists. \n\t */\n\tgetContextProxy?(): T;\n\n\t/**\n\t * get a scope for an object named as `propertyKey` from cache map,\n\t * \n\t * if the current value is not type od `object`, will return `undefined`.\n\t * @param propertyKey the name of the property\n\t */\n\tgetInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S | undefined;\n\n\t/**\n\t * create a scope with the same type of this scope\n\t */\n\tsetInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S;\n\n\t/**\n\t * sc\n\t * @param propertyKey \n\t * @param scope \n\t */\n\tsetInnerScope<S extends Scope<Context>>(propertyKey: keyof T, scope?: S): S;\n\n\tgetClass(): TypeOf<Scope<Context>>;\n}\n\nexport class Scope<T extends Context> implements Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope(ctx, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope({} as T, propertyKeys);\n\t}\n\n\tprotected _inners = new Map<keyof T, Scope<any>>();\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[]);\n\tconstructor(protected _ctx: T, protected _keys?: (keyof T)[]) { }\n\tget(key: keyof T): any {\n\t\treturn Reflect.get(this._ctx, key);\n\t}\n\tset(key: keyof T, value: any, receiver?: any): boolean {\n\t\treturn Reflect.set(this._ctx, key, value);\n\t}\n\thas(key: keyof T): boolean {\n\t\treturn this._keys?.includes(key) ?? key in this._ctx;\n\t}\n\tdelete(key: keyof T): boolean {\n\t\treturn Reflect.deleteProperty(this._ctx, key);\n\t}\n\tgetContext(): T {\n\t\treturn this._ctx;\n\t}\n\tgetInnerScope<S extends Scope<Context>>(key: keyof T): S | undefined {\n\t\tconst ctx = this.get(key);\n\t\tlet scope = this._inners.get(key);\n\t\tif (scope) {\n\t\t\tscope._ctx = ctx;\n\t\t\treturn scope as S;\n\t\t}\n\t\tif (!(ctx && typeof ctx === 'object')) {\n\t\t\treturn;\n\t\t}\n\t\tscope = new (this.getClass())(ctx, undefined, key, this);\n\t\tthis._inners.set(key, scope);\n\t\treturn scope as S;\n\t}\n\tsetInnerScope<S extends Scope<Context>>(key: keyof T, scope?: S): S {\n\t\tif (scope) {\n\t\t\tthis._inners.set(key, scope);\n\t\t\treturn scope;\n\t\t}\n\t\tconst ctx = this.get(key);\n\t\tscope = new (this.getClass())(ctx, undefined, key, this) as S;\n\t\tthis._inners.set(key, scope);\n\t\treturn scope;\n\t}\n\tgetClass(): TypeOf<Scope<Context>> {\n\t\treturn Scope;\n\t}\n}\n\nexport class ReadOnlyScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope(ctx, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope({} as T, propertyKeys);\n\t}\n\tset(propertyKey: keyof T, value: any, receiver?: any): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ReadOnlyScope<Context>> {\n\t\treturn ReadOnlyScope;\n\t}\n}\n\nexport class ScopeSubscription<T> {\n\tconstructor(private propertyKey: keyof T, private observer: ValueChangeObserver<T>) { }\n\tpause() {\n\t\tthis.observer.pause(this.propertyKey, this);\n\t}\n\tresume() {\n\t\tthis.observer.resume(this.propertyKey, this);\n\t}\n\tunsubscribe(): void {\n\t\tthis.observer.unsubscribe(this.propertyKey, this);\n\t}\n}\n\nexport type ValueChangedCallback = (newValue: any, oldValue?: any) => void;\n\ntype SubscriptionInfo = { callback: ValueChangedCallback, enable: boolean };\n\nexport class ValueChangeObserver<T> {\n\tprivate _subscribers: Map<keyof T, Map<ScopeSubscription<T>, SubscriptionInfo>> = new Map();\n\tprivate _lock: (keyof T)[] = [];\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this._lock.includes(propertyKey)) {\n\t\t\treturn;\n\t\t}\n\t\tconst subscribers = this._subscribers.get(propertyKey);\n\t\tif (!subscribers || subscribers.size == 0) {\n\t\t\treturn;\n\t\t}\n\t\tthis._lock.push(propertyKey);\n\t\tsubscribers?.forEach(subscriptionInfo => {\n\t\t\tif (!subscriptionInfo.enable) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tsubscriptionInfo.callback(newValue, oldValue);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t}\n\t\t});\n\t\tif (this._lock.pop() !== propertyKey) {\n\t\t\tconsole.error('lock error');\n\t\t};\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\tconst subscription: ScopeSubscription<T> = new ScopeSubscription(propertyKey, this);\n\t\tlet propertySubscribers = this._subscribers.get(propertyKey);\n\t\tif (!propertySubscribers) {\n\t\t\tpropertySubscribers = new Map();\n\t\t\tthis._subscribers.set(propertyKey, propertySubscribers);\n\t\t}\n\t\tpropertySubscribers.set(subscription, { callback, enable: true });\n\t\treturn subscription;\n\t}\n\n\tunsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (subscription) {\n\t\t\tthis._subscribers.get(propertyKey)?.delete(subscription);\n\t\t} else {\n\t\t\tthis._subscribers.delete(propertyKey);\n\t\t}\n\t}\n\n\tpause(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this._subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = false);\n\t}\n\n\tresume(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this._subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = true);\n\t}\n\n\t/**\n\t * check if this Observer has any subscribers\n\t */\n\thasSubscribers(): boolean;\n\n\t/**\n\t * check if there is any subscribers registered by the propertyKey.\n\t * \n\t * @param propertyKey\n\t */\n\thasSubscribers(propertyKey: keyof T): boolean;\n\thasSubscribers(propertyKey?: keyof T): boolean {\n\t\tif (propertyKey) {\n\t\t\treturn (this._subscribers.get(propertyKey)?.size ?? 0) > 0;\n\t\t}\n\t\treturn this._subscribers.size > 0;\n\t}\n\n\t/**\n\t * clear subscription maps\n\t */\n\tdestroy() {\n\t\tthis._subscribers.clear();\n\t}\n}\n\nexport class ReactiveScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope({} as T, propertyKeys);\n\t}\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tprotected _clone: T;\n\tdeclare protected _inners: Map<keyof T, ReactiveScope<any>>;\n\tprotected _observer: ValueChangeObserver<T> = new ValueChangeObserver<T>();\n\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[], protected _name?: keyof T, protected _parent?: ReactiveScope<any>) {\n\t\tsuper(context, propertyKeys);\n\t\tthis._clone = Object.assign({}, context);\n\t\tif (HTMLElement && context instanceof HTMLElement) {\n\t\t\tthis._keys = [];\n\t\t}\n\t}\n\n\tset(propertyKey: keyof T, newValue: any, receiver?: any): boolean {\n\t\tconst oldValue = Reflect.get(this._ctx, propertyKey);\n\t\tconst result = Reflect.set(this._ctx, propertyKey, newValue);\n\t\tif (result) {\n\t\t\tthis.emit(propertyKey, newValue, oldValue);\n\t\t}\n\t\treturn result;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\tconst oldValue = Reflect.get(this._ctx, propertyKey);\n\t\tconst isDelete = Reflect.deleteProperty(this._ctx, propertyKey);\n\t\tif (isDelete && oldValue !== undefined) {\n\t\t\tthis.emit(propertyKey, undefined, oldValue);\n\t\t}\n\t\treturn isDelete;\n\t}\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tthis._observer.emit(propertyKey, newValue, oldValue);\n\t\tthis._parent?.emit(this._name!, this._ctx);\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\treturn this._observer.subscribe(propertyKey, callback);\n\t}\n\tunsubscribe(propertyKey?: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (propertyKey && subscription) {\n\t\t\tthis._observer.unsubscribe(propertyKey, subscription);\n\t\t} else if (propertyKey) {\n\t\t\tthis._observer.unsubscribe(propertyKey);\n\t\t} else {\n\t\t\tthis._observer.destroy();\n\t\t}\n\t}\n\tdetectChanges() {\n\t\tconst previous = this._clone;\n\t\tconst current = this._ctx;\n\t\tif ((!!!previous && !!current) || (!!previous && !!!current)) {\n\t\t\tthis._parent?.emit(this._name!, current);\n\t\t\treturn;\n\t\t}\n\t\tconst keys = this._keys ?? this.getPropertyKeys(previous, current);\n\t\tkeys.forEach(key => {\n\t\t\tconst pv = previous[key];\n\t\t\tconst cv = current[key];\n\t\t\tconst pt = typeof pv;\n\t\t\tconst ct = typeof cv;\n\t\t\tif (pt === 'object') {\n\t\t\t\tif (ct === 'object') {\n\t\t\t\t\tthis.getInnerScope<ReactiveScope<Context>>(key)?.detectChanges();\n\t\t\t\t} else if (cv != pv) {\n\t\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t\t}\n\t\t\t} else if (ct === 'object') {\n\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t} else if (pv != cv) {\n\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t}\n\t\t});\n\t\tthis._clone = Object.assign({}, this._ctx);\n\t}\n\tprotected getPropertyKeys<V extends Record<PropertyKey, any>>(...objs: V[]) {\n\t\tlet keys: (keyof V)[] = [];\n\t\tobjs.forEach(obj => {\n\t\t\tkeys.push(...Object.keys(obj));\n\t\t\tkeys.push(...Object.getOwnPropertySymbols(obj));\n\t\t});\n\t\tkeys = Array.from(new Set(keys));\n\t\tkeys = keys.filter(key => {\n\t\t\tswitch (typeof key) {\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn !key.startsWith('_');\n\t\t\t\tcase 'symbol':\n\t\t\t\t\treturn !key.toString().startsWith('Symbol(_');\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn keys;\n\t}\n\tgetClass(): TypeOf<ReactiveScope<Context>> {\n\t\treturn ReactiveScope;\n\t}\n}\n\n/**\n * used control/notify/pause scope about changes in current context\n */\nexport interface ScopeControl<T extends Context> {\n\n\t/**\n\t * get current stacte of applying change detection.\n\t */\n\tisAttached(): boolean;\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tdetach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit in time.\n\t */\n\treattach(): void;\n\n\t/**\n\t * apply changes now,\n\t * will not effect the state of the detector wither if attached ot not.\n\t * \n\t * if a propertyKey is provided, will emit this property only \n\t * @param propertyKey \n\t */\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void;\n\n\t/**\n\t * throw error if any changes has been made\n\t */\n\tcheckNoChanges(): void;\n}\n\nexport class ReactiveScopeControl<T extends Context> extends ReactiveScope<T> implements ScopeControl<T> {\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl({} as T, propertyKeys);\n\t}\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScopeControl.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScopeControl.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic reactiveScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\n\tprotected _attached: boolean = true;\n\tprotected _marked: { [key: keyof Context]: [any, any] } = {};\n\n\toverride emit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this._attached) {\n\t\t\tsuper.emit(propertyKey, newValue, oldValue);\n\t\t} else if (this._marked[propertyKey as string]) {\n\t\t\tif (newValue == this._marked[propertyKey as string][1]) {\n\t\t\t\tdelete this._marked[propertyKey as string];\n\t\t\t} else {\n\t\t\t\tthis._marked[propertyKey as string][0] = newValue;\n\t\t\t}\n\t\t} else {\n\t\t\tthis._marked[propertyKey as string] = [newValue, oldValue];\n\t\t}\n\t}\n\tisAttached(): boolean {\n\t\treturn this._attached;\n\t}\n\tdetach(): void {\n\t\tthis._attached = false;\n\t}\n\treattach(): void {\n\t\tthis._attached = true;\n\t\tthis.emitChanges();\n\t}\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void {\n\t\tif (propertyKey) {\n\t\t\tsuper.emit(propertyKey, propertyValue);\n\t\t\tReflect.deleteProperty(this._marked, propertyKey);\n\t\t\treturn;\n\t\t}\n\t\tconst latestChanges = this._marked;\n\t\tthis._marked = {};\n\t\tconst keys = this._keys ?? this.getPropertyKeys(latestChanges);\n\t\tkeys.forEach(propertyKey => {\n\t\t\tthis._observer.emit(propertyKey, latestChanges[propertyKey][0], latestChanges[propertyKey][1]);\n\t\t});\n\t\tkeys.length && this._parent?.emit(this._name!, this._ctx);\n\t}\n\tdetectChanges() {\n\t\tthis.detach();\n\t\tsuper.detectChanges();\n\t\tthis.reattach();\n\t}\n\tcheckNoChanges() {\n\t\tthis.detach();\n\t\tsuper.detectChanges();\n\t\tconst keys = Object.keys(this._marked);\n\t\tif (keys.length > 0) {\n\t\t\tthrow new Error(`Some Changes had been detected`);\n\t\t}\n\t}\n\tgetClass(): TypeOf<ReactiveScopeControl<Context>> {\n\t\treturn ReactiveScopeControl;\n\t}\n}\n\n\ninterface ImportMeta {\n\turl: URL;\n\t/**\n\t *\n\t * Provides a module-relative resolution function scoped to each module, returning\n\t * the URL string.\n\t *\n\t * @param specified The module specifier to resolve relative to `parent`.\n\t * @param parent The absolute parent module URL to resolve from. If none\n\t * is specified, the value of `import.meta.url` is used as the default.\n\t */\n\tresolve?(specified: string, parent?: string | URL): Promise<string>;\n}\n\nexport interface ModuleImport {\n\tmeta: ImportMeta\n}\n\nexport interface ModuleContext extends Context {\n\timport: ModuleImport & ((path: string) => Promise<any>);\n}\n\nexport class ModuleScope extends ReactiveScope<ModuleContext> {\n\tconstructor(context: ModuleContext, propertyKeys?: (keyof ModuleContext)[]) {\n\t\tsuper(context, propertyKeys);\n\t}\n\timportModule(propertyKey: keyof ModuleContext, scope: ModuleScope): void {\n\t\tthis._ctx[propertyKey] = scope._ctx;\n\t\tthis._inners.set(propertyKey, scope);\n\t\tthis.detectChanges();\n\t}\n}\nexport class WebModuleScope extends ModuleScope {\n\n\t// private loaded = false;\n\tprivate import: Promise<any>;\n\tconstructor(private source: string, private importCallOptions?: ImportCallOptions) {\n\t\tsuper({} as ModuleContext);\n\t\tthis.import = import(\n\t\t\tsource\n\t\t\t/*, { assert: importCallOptions?.assert } */ // TODO: update in future, node16, ESNEXT,ES2022, ES2023, ES2024\n\t\t).then(module => (this.updateContext(module))).then(() => this._ctx, () => this._ctx);\n\t}\n\tprivate updateContext(context: any) {\n\t\tthis._ctx = context;\n\t\tthis.detectChanges();\n\t}\n\n\tresolveImport() {\n\t\treturn this.import;\n\t}\n}\n"]}
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/expressions/scope/scope.ts"],"names":[],"mappings":"AAgEA,MAAM,OAAO,KAAK;IACjB,MAAM,CAAC,GAAG,CAAoB,GAAM,EAAE,YAA0B;QAC/D,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACrC,CAAC;IACD,MAAM,CAAC,UAAU,CAAoB,YAA0B;QAC9D,OAAO,IAAI,KAAK,CAAC,EAAO,EAAE,YAAY,CAAC,CAAC;IACzC,CAAC;IAKD,YAAsB,IAAO,EAAY,KAAmB;QAAtC,SAAI,GAAJ,IAAI,CAAG;QAAY,UAAK,GAAL,KAAK,CAAc;QAHlD,YAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAGa,CAAC;IACjE,GAAG,CAAC,GAAY;QACf,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IACD,GAAG,CAAC,GAAY,EAAE,KAAU,EAAE,QAAc;QAC3C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,GAAG,CAAC,GAAY;QACf,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;IACtD,CAAC;IACD,MAAM,CAAC,GAAY;QAClB,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;IACD,UAAU;QACT,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,aAAa,CAA2B,GAAY;QACnD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,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AAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvF,CAAC;IACO,aAAa,CAAC,OAAY;QACjC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACpB,IAAI,CAAC,aAAa,EAAE,CAAC;IACtB,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD","sourcesContent":["import { TypeOf } from '../api/utils.js';\n\nexport type Context = Record<PropertyKey, any>;\nexport interface Scope<T = Context> {\n\n\t/**\n\t * get value of `propertyKey` in current context\n\t * @param propertyKey \n\t */\n\tget(propertyKey: keyof T): any;\n\n\t/**\n\t * set the value of `propertyKey` in current context, could be instilled with `value`.\n\t * @param propertyKey \n\t * @param value \n\t * @param receiver \n\t */\n\tset(propertyKey: keyof T, value?: any, receiver?: any): boolean;\n\n\t/**\n\t * is current context has `propertyKey` in hash map keys\n\t * @param propertyKey \n\t */\n\thas(propertyKey: keyof T): boolean;\n\n\t/**\n\t * delete property from context\n\t * @param propertyKey \n\t */\n\tdelete(propertyKey: keyof T): boolean;\n\n\t/**\n\t * get current context object of this scope\n\t */\n\tgetContext(): T;\n\n\t/**\n\t * get a proxy of the current context object if exists. \n\t */\n\tgetContextProxy?(): T;\n\n\t/**\n\t * get a scope for an object named as `propertyKey` from cache map,\n\t * \n\t * if the current value is not type od `object`, will return `undefined`.\n\t * @param propertyKey the name of the property\n\t */\n\tgetInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S | undefined;\n\n\t/**\n\t * create a scope with the same type of this scope\n\t */\n\tsetInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S;\n\n\t/**\n\t * sc\n\t * @param propertyKey \n\t * @param scope \n\t */\n\tsetInnerScope<S extends Scope<Context>>(propertyKey: keyof T, scope?: S): S;\n\n\tgetClass(): TypeOf<Scope<Context>>;\n}\n\nexport class Scope<T extends Context> implements Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope(ctx, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope({} as T, propertyKeys);\n\t}\n\n\tprotected _inners = new Map<keyof T, Scope<any>>();\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[]);\n\tconstructor(protected _ctx: T, protected _keys?: (keyof T)[]) { }\n\tget(key: keyof T): any {\n\t\treturn Reflect.get(this._ctx, key);\n\t}\n\tset(key: keyof T, value: any, receiver?: any): boolean {\n\t\treturn Reflect.set(this._ctx, key, value);\n\t}\n\thas(key: keyof T): boolean {\n\t\treturn this._keys?.includes(key) ?? key in this._ctx;\n\t}\n\tdelete(key: keyof T): boolean {\n\t\treturn Reflect.deleteProperty(this._ctx, key);\n\t}\n\tgetContext(): T {\n\t\treturn this._ctx;\n\t}\n\tgetInnerScope<S extends Scope<Context>>(key: keyof T): S | undefined {\n\t\tconst ctx = this.get(key);\n\t\tlet scope = this._inners.get(key);\n\t\tif (scope) {\n\t\t\tscope._ctx = ctx;\n\t\t\treturn scope as S;\n\t\t}\n\t\tif (!(ctx && typeof ctx === 'object')) {\n\t\t\treturn;\n\t\t}\n\t\tscope = new (this.getClass())(ctx, undefined, key, this);\n\t\tthis._inners.set(key, scope);\n\t\treturn scope as S;\n\t}\n\tsetInnerScope<S extends Scope<Context>>(key: keyof T, scope?: S): S {\n\t\tif (scope) {\n\t\t\tthis._inners.set(key, scope);\n\t\t\treturn scope;\n\t\t}\n\t\tconst ctx = this.get(key);\n\t\tscope = new (this.getClass())(ctx, undefined, key, this) as S;\n\t\tthis._inners.set(key, scope);\n\t\treturn scope;\n\t}\n\tgetClass(): TypeOf<Scope<Context>> {\n\t\treturn Scope;\n\t}\n}\n\nexport class ReadOnlyScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope(ctx, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope({} as T, propertyKeys);\n\t}\n\tset(propertyKey: keyof T, value: any, receiver?: any): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ReadOnlyScope<Context>> {\n\t\treturn ReadOnlyScope;\n\t}\n}\n\nexport class ScopeSubscription<T> {\n\tconstructor(private propertyKey: keyof T, private observer: ValueChangeObserver<T>) { }\n\tpause() {\n\t\tthis.observer.pause(this.propertyKey, this);\n\t}\n\tresume() {\n\t\tthis.observer.resume(this.propertyKey, this);\n\t}\n\tunsubscribe(): void {\n\t\tthis.observer.unsubscribe(this.propertyKey, this);\n\t}\n}\n\nexport type ValueChangedCallback = (newValue: any, oldValue?: any) => void;\n\ntype SubscriptionInfo = { callback: ValueChangedCallback, enable: boolean };\n\nexport class ValueChangeObserver<T> {\n\tprivate _subscribers: Map<keyof T, Map<ScopeSubscription<T>, SubscriptionInfo>> = new Map();\n\tprivate _lock: (keyof T)[] = [];\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this._lock.includes(propertyKey)) {\n\t\t\treturn;\n\t\t}\n\t\tconst subscribers = this._subscribers.get(propertyKey);\n\t\tif (!subscribers || subscribers.size == 0) {\n\t\t\treturn;\n\t\t}\n\t\tthis._lock.push(propertyKey);\n\t\tsubscribers?.forEach(subscriptionInfo => {\n\t\t\tif (!subscriptionInfo.enable) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tsubscriptionInfo.callback(newValue, oldValue);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t}\n\t\t});\n\t\tif (this._lock.pop() !== propertyKey) {\n\t\t\tconsole.error('lock error');\n\t\t};\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\tconst subscription: ScopeSubscription<T> = new ScopeSubscription(propertyKey, this);\n\t\tlet propertySubscribers = this._subscribers.get(propertyKey);\n\t\tif (!propertySubscribers) {\n\t\t\tpropertySubscribers = new Map();\n\t\t\tthis._subscribers.set(propertyKey, propertySubscribers);\n\t\t}\n\t\tpropertySubscribers.set(subscription, { callback, enable: true });\n\t\treturn subscription;\n\t}\n\n\tunsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (subscription) {\n\t\t\tthis._subscribers.get(propertyKey)?.delete(subscription);\n\t\t} else {\n\t\t\tthis._subscribers.delete(propertyKey);\n\t\t}\n\t}\n\n\tpause(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this._subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = false);\n\t}\n\n\tresume(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this._subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = true);\n\t}\n\n\t/**\n\t * check if this Observer has any subscribers\n\t */\n\thasSubscribers(): boolean;\n\n\t/**\n\t * check if there is any subscribers registered by the propertyKey.\n\t * \n\t * @param propertyKey\n\t */\n\thasSubscribers(propertyKey: keyof T): boolean;\n\thasSubscribers(propertyKey?: keyof T): boolean {\n\t\tif (propertyKey) {\n\t\t\treturn (this._subscribers.get(propertyKey)?.size ?? 0) > 0;\n\t\t}\n\t\treturn this._subscribers.size > 0;\n\t}\n\n\t/**\n\t * clear subscription maps\n\t */\n\tdestroy() {\n\t\tthis._subscribers.clear();\n\t}\n}\n\nexport class ReactiveScope<T extends Context> extends Scope<T> {\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope({} as T, propertyKeys);\n\t}\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tprotected _clone: T;\n\tdeclare protected _inners: Map<keyof T, ReactiveScope<any>>;\n\tprotected _observer: ValueChangeObserver<T> = new ValueChangeObserver<T>();\n\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[], protected _name?: keyof T, protected _parent?: ReactiveScope<any>) {\n\t\tsuper(context, propertyKeys);\n\t\tthis._clone = Object.assign({}, context);\n\t}\n\n\tset(propertyKey: keyof T, newValue: any, receiver?: any): boolean {\n\t\tconst oldValue = Reflect.get(this._ctx, propertyKey);\n\t\tconst result = Reflect.set(this._ctx, propertyKey, newValue);\n\t\tif (result) {\n\t\t\tthis.emit(propertyKey, newValue, oldValue);\n\t\t}\n\t\treturn result;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\tconst oldValue = Reflect.get(this._ctx, propertyKey);\n\t\tconst isDelete = Reflect.deleteProperty(this._ctx, propertyKey);\n\t\tif (isDelete && oldValue !== undefined) {\n\t\t\tthis.emit(propertyKey, undefined, oldValue);\n\t\t}\n\t\treturn isDelete;\n\t}\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tthis._observer.emit(propertyKey, newValue, oldValue);\n\t\tthis._parent?.emit(this._name!, this._ctx);\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\treturn this._observer.subscribe(propertyKey, callback);\n\t}\n\tunsubscribe(propertyKey?: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (propertyKey && subscription) {\n\t\t\tthis._observer.unsubscribe(propertyKey, subscription);\n\t\t} else if (propertyKey) {\n\t\t\tthis._observer.unsubscribe(propertyKey);\n\t\t} else {\n\t\t\tthis._observer.destroy();\n\t\t}\n\t}\n\tdetectChanges() {\n\t\tconst previous = this._clone;\n\t\tconst current = this._ctx;\n\t\tif ((!!!previous && !!current) || (!!previous && !!!current)) {\n\t\t\tthis._parent?.emit(this._name!, current);\n\t\t\treturn;\n\t\t}\n\t\tconst keys = this._keys ?? this.getPropertyKeys(previous, current);\n\t\tkeys.forEach(key => {\n\t\t\tconst pv = previous[key];\n\t\t\tconst cv = current[key];\n\t\t\tconst pt = typeof pv;\n\t\t\tconst ct = typeof cv;\n\t\t\tif (pt === 'object') {\n\t\t\t\tif (ct === 'object' && pv == cv) {\n\t\t\t\t\tthis.getInnerScope<ReactiveScope<Context>>(key)?.detectChanges();\n\t\t\t\t} else if (cv != pv) {\n\t\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t\t}\n\t\t\t} else if (ct === 'object') {\n\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t} else if (pv != cv) {\n\t\t\t\tthis.emit(key, cv, pv);\n\t\t\t}\n\t\t});\n\t\tthis._clone = Object.assign({}, this._ctx);\n\t}\n\tprotected getPropertyKeys<V extends Record<PropertyKey, any>>(...objs: V[]) {\n\t\tlet keys: (keyof V)[] = [];\n\t\tobjs.forEach(obj => {\n\t\t\tkeys.push(...Object.keys(obj));\n\t\t\tkeys.push(...Object.getOwnPropertySymbols(obj));\n\t\t});\n\t\tkeys = Array.from(new Set(keys));\n\t\tkeys = keys.filter(key => {\n\t\t\tswitch (typeof key) {\n\t\t\t\tcase 'string':\n\t\t\t\t\treturn !key.startsWith('_');\n\t\t\t\tcase 'symbol':\n\t\t\t\t\treturn !key.toString().startsWith('Symbol(_');\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn keys;\n\t}\n\tgetClass(): TypeOf<ReactiveScope<Context>> {\n\t\treturn ReactiveScope;\n\t}\n}\n\n/**\n * used control/notify/pause scope about changes in current context\n */\nexport interface ScopeControl<T extends Context> {\n\n\t/**\n\t * get current stacte of applying change detection.\n\t */\n\tisAttached(): boolean;\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tdetach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit in time.\n\t */\n\treattach(): void;\n\n\t/**\n\t * apply changes now,\n\t * will not effect the state of the detector wither if attached ot not.\n\t * \n\t * if a propertyKey is provided, will emit this property only \n\t * @param propertyKey \n\t */\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void;\n\n\t/**\n\t * throw error if any changes has been made\n\t */\n\tcheckNoChanges(): void;\n}\n\nexport class ReactiveScopeControl<T extends Context> extends ReactiveScope<T> implements ScopeControl<T> {\n\tstatic for<T extends Context>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends Context>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl({} as T, propertyKeys);\n\t}\n\tstatic scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScopeControl.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScopeControl.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = ReadOnlyScope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\tstatic reactiveScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]) {\n\t\tconst thisScope = ReactiveScope.for(ctx, propertyKeys);\n\t\tconst thisCtx = {\n\t\t\t'this': ctx,\n\t\t};\n\t\tconst rootScope = Scope.for(thisCtx, ['this']);\n\t\trootScope.setInnerScope('this', thisScope);\n\t\treturn rootScope;\n\t}\n\n\tprotected _attached: boolean = true;\n\tprotected _marked: { [key: keyof Context]: [any, any] } = {};\n\n\toverride emit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this._attached) {\n\t\t\tsuper.emit(propertyKey, newValue, oldValue);\n\t\t} else if (this._marked[propertyKey as string]) {\n\t\t\tif (newValue == this._marked[propertyKey as string][1]) {\n\t\t\t\tdelete this._marked[propertyKey as string];\n\t\t\t} else {\n\t\t\t\tthis._marked[propertyKey as string][0] = newValue;\n\t\t\t}\n\t\t} else {\n\t\t\tthis._marked[propertyKey as string] = [newValue, oldValue];\n\t\t}\n\t}\n\tisAttached(): boolean {\n\t\treturn this._attached;\n\t}\n\tdetach(): void {\n\t\tthis._attached = false;\n\t}\n\treattach(): void {\n\t\tthis._attached = true;\n\t\tthis.emitChanges();\n\t}\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void {\n\t\tif (propertyKey) {\n\t\t\tsuper.emit(propertyKey, propertyValue);\n\t\t\tReflect.deleteProperty(this._marked, propertyKey);\n\t\t\treturn;\n\t\t}\n\t\tconst latestChanges = this._marked;\n\t\tthis._marked = {};\n\t\tconst keys = this._keys ?? this.getPropertyKeys(latestChanges);\n\t\tkeys.forEach(propertyKey => {\n\t\t\tthis._observer.emit(propertyKey, latestChanges[propertyKey][0], latestChanges[propertyKey][1]);\n\t\t});\n\t\tkeys.length && this._parent?.emit(this._name!, this._ctx);\n\t}\n\tdetectChanges() {\n\t\tthis.detach();\n\t\tsuper.detectChanges();\n\t\tthis.reattach();\n\t}\n\tcheckNoChanges() {\n\t\tthis.detach();\n\t\tsuper.detectChanges();\n\t\tconst keys = Object.keys(this._marked);\n\t\tif (keys.length > 0) {\n\t\t\tthrow new Error(`Some Changes had been detected`);\n\t\t}\n\t}\n\tgetClass(): TypeOf<ReactiveScopeControl<Context>> {\n\t\treturn ReactiveScopeControl;\n\t}\n}\n\n\ninterface ImportMeta {\n\turl: URL;\n\t/**\n\t *\n\t * Provides a module-relative resolution function scoped to each module, returning\n\t * the URL string.\n\t *\n\t * @param specified The module specifier to resolve relative to `parent`.\n\t * @param parent The absolute parent module URL to resolve from. If none\n\t * is specified, the value of `import.meta.url` is used as the default.\n\t */\n\tresolve?(specified: string, parent?: string | URL): Promise<string>;\n}\n\nexport interface ModuleImport {\n\tmeta: ImportMeta\n}\n\nexport interface ModuleContext extends Context {\n\timport: ModuleImport & ((path: string) => Promise<any>);\n}\n\nexport class ModuleScope extends ReactiveScope<ModuleContext> {\n\tconstructor(context: ModuleContext, propertyKeys?: (keyof ModuleContext)[]) {\n\t\tsuper(context, propertyKeys);\n\t}\n\timportModule(propertyKey: keyof ModuleContext, scope: ModuleScope): void {\n\t\tthis._ctx[propertyKey] = scope._ctx;\n\t\tthis._inners.set(propertyKey, scope);\n\t\tthis.detectChanges();\n\t}\n}\nexport class WebModuleScope extends ModuleScope {\n\n\t// private loaded = false;\n\tprivate import: Promise<any>;\n\tconstructor(private source: string, private importCallOptions?: ImportCallOptions) {\n\t\tsuper({} as ModuleContext);\n\t\tthis.import = import(\n\t\t\tsource\n\t\t\t/*, { assert: importCallOptions?.assert } */ // TODO: update in future, node16, ESNEXT,ES2022, ES2023, ES2024\n\t\t).then(module => (this.updateContext(module))).then(() => this._ctx, () => this._ctx);\n\t}\n\tprivate updateContext(context: any) {\n\t\tthis._ctx = context;\n\t\tthis.detectChanges();\n\t}\n\n\tresolveImport() {\n\t\treturn this.import;\n\t}\n}\n"]}
package/scope/stack.js CHANGED
@@ -3,6 +3,21 @@ import { JavaScriptParser } from '../v8/parser.js';
3
3
  import { finalizerRegister } from './finalizer.js';
4
4
  import { ModuleScope, ReactiveScope, ReactiveScopeControl, Scope, WebModuleScope } from './scope.js';
5
5
  export class Stack {
6
+ static for(...contexts) {
7
+ if (contexts.length === 0) {
8
+ return new Stack();
9
+ }
10
+ return new Stack(contexts.map(context => new Scope(context)));
11
+ }
12
+ static forScopes(...scopes) {
13
+ if (scopes.length === 0) {
14
+ scopes.push(Scope.blockScope());
15
+ }
16
+ return new Stack(scopes);
17
+ }
18
+ static moduleScope(resolver, moduleSource, ...globalScopes) {
19
+ return new Stack(globalScopes, resolver, moduleSource);
20
+ }
6
21
  constructor(globals, resolver, moduleSource) {
7
22
  this.awaitPromise = [];
8
23
  this.onDestroyActions = [];
@@ -33,21 +48,6 @@ export class Stack {
33
48
  }
34
49
  finalizerRegister(this, this.onDestroyActions, this);
35
50
  }
36
- static for(...contexts) {
37
- if (contexts.length === 0) {
38
- return new Stack();
39
- }
40
- return new Stack(contexts.map(context => new Scope(context)));
41
- }
42
- static forScopes(...scopes) {
43
- if (scopes.length === 0) {
44
- scopes.push(Scope.blockScope());
45
- }
46
- return new Stack(scopes);
47
- }
48
- static moduleScope(resolver, moduleSource, ...globalScopes) {
49
- return new Stack(globalScopes, resolver, moduleSource);
50
- }
51
51
  initModuleContext() {
52
52
  const importFunc = (path) => {
53
53
  const module = this.importModule(path);
@@ -100,23 +100,23 @@ export class Stack {
100
100
  pushScope(scope) {
101
101
  this.stack.push(scope);
102
102
  }
103
- pushBlockScope() {
104
- const scope = Scope.blockScope();
103
+ pushBlockScope(propertyKeys) {
104
+ const scope = Scope.blockScope(propertyKeys);
105
105
  this.stack.push(scope);
106
106
  return scope;
107
107
  }
108
- pushBlockScopeFor(context) {
109
- const scope = Scope.for(context);
108
+ pushBlockScopeFor(context, propertyKeys) {
109
+ const scope = Scope.for(context, propertyKeys);
110
110
  this.stack.push(scope);
111
111
  return scope;
112
112
  }
113
- pushReactiveScope() {
114
- const scope = ReactiveScope.blockScope();
113
+ pushReactiveScope(propertyKeys) {
114
+ const scope = ReactiveScope.blockScope(propertyKeys);
115
115
  this.stack.push(scope);
116
116
  return scope;
117
117
  }
118
- pushReactiveScopeFor(context) {
119
- const scope = ReactiveScope.for(context);
118
+ pushReactiveScopeFor(context, propertyKeys) {
119
+ const scope = ReactiveScope.for(context, propertyKeys);
120
120
  this.stack.push(scope);
121
121
  return scope;
122
122
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/expressions/scope/stack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACuB,WAAW,EAAE,aAAa,EACvD,oBAAoB,EAAE,KAAK,EAAW,cAAc,EACpD,MAAM,YAAY,CAAC;AAyIpB,MAAM,OAAO,KAAK;IAoCjB,YAAY,OAAwD,EAAE,QAA8B,EAAE,YAAqB;QApB3H,iBAAY,GAAuB,EAAE,CAAC;QAQnB,qBAAgB,GAAmB,EAAE,CAAC;QAaxD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;SAC7B;aAAM,IAAI,OAAO,YAAY,KAAK,EAAE;YACpC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;SACnC;aAAM,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE;YACtC,IAAI,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,CA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\nimport { JavaScriptParser } from '../v8/parser.js';\nimport { finalizerRegister } from './finalizer.js';\nimport {\n\tModuleContext, ModuleImport, ModuleScope, ReactiveScope,\n\tReactiveScopeControl, Scope, Context, WebModuleScope\n} from './scope.js';\n\n\nexport interface AwaitPromiseInfo {\n\tpromise: Promise<any>;\n\tnode: DeclarationExpression;\n\n\tdeclareVariable: boolean;\n}\n\nexport interface AsyncIterableInfo {\n\titerable: AsyncIterable<any>;\n\tforAwaitBody: (iterator: any) => any;\n}\n\nexport interface Stack {\n\t/**\n\t * a list of promises to resolve in an 'async' scope as 'async function'\n\t */\n\tawaitPromise: Array<AwaitPromiseInfo>;\n\n\t/**\n\t * resolve await promise in 'await for in' scope\n\t */\n\tforAwaitAsyncIterable?: AsyncIterableInfo;\n\n\t/**\n\t * is this stack has a propertyKey\n\t * @param propertyKey \n\t */\n\thas(propertyKey: PropertyKey): boolean;\n\n\t/**\n\t * get the first value for provided property key,\n\t * \n\t * will search current stack in all scope till find the first key, else undefined\n\t * @param propertyKey \n\t */\n\tget(propertyKey: PropertyKey): any;\n\n\t/**\n\t * set the value of `propertyKey` in its context provider with `value`.\n\t * else define it in the first scope 'local scope'\n\t * @param propertyKey \n\t * @param value \n\t * @param receiver \n\t */\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean;\n\n\t/**\n\t * declare variable at last scope in the stack,\n\t * \n\t * @param propertyKey the name of property mey be string | number | symbol, \n\t * @param propertyValue if not exist will be initialize with 'undefined' value\n\t */\n\tdeclareVariable(propertyKey: PropertyKey, propertyValue?: any): any;\n\n\n\t/**\n\t * get context object of this provider,\n\t * search for the first context object that has `propertyKey`.\n\t * \n\t * search for the first context that have property key,\n\t * if not found will return the stack local scop as a default value\n\t * @param propertyKey the property key\n\t */\n\tfindScope<T extends Context>(propertyKey: PropertyKey): Scope<T>;\n\n\tresolveAwait(value: AwaitPromiseInfo): void;\n\n\t/**\n\t * get a reference to the last scope in this stack\n\t */\n\tlastScope<T extends Context>(): Scope<T>;\n\n\t/**\n\t * clear every thing after this scope, and even this scope\n\t * @param scope \n\t */\n\tclearTo<T extends Context>(scope: Scope<T>): boolean;\n\n\t/**\n\t * clear every thing after this scope, but not this scope\n\t * @param scope \n\t */\n\tclearTill<T extends Context>(scope: Scope<T>): boolean;\n\n\tpopScope<T extends Context>(): Scope<T>;\n\n\tremoveScope<T extends Context>(scope: Scope<T>): void;\n\n\tpushScope<T extends Context>(scope: Scope<T>): void;\n\n\tpushBlockScope<T extends Context>(): Scope<T>;\n\n\tpushBlockScopeFor<T extends Context>(context: T): Scope<T>;\n\n\tpushReactiveScope<T extends Context>(): ReactiveScope<T>;\n\n\tpushReactiveScopeFor<T extends Context>(context: T): ReactiveScope<T>;\n\n\t/**\n\t * create new stack instance with the same reference to the current scope array\n\t */\n\tcopyStack(): Stack;\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tdetach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit in time.\n\t */\n\treattach(): void;\n\n\t/**\n\t * import module scope from another stack, by the help of ModuleScopeResolver.\n\t * \n\t * used with import statement\n\t */\n\timportModule(source: string, importCallOptions?: ImportCallOptions): ModuleScope;\n\n\t/**\n\t * get the current module for this stack.\n\t * \n\t * used with export statement\n\t */\n\tgetModule(): ModuleScope | undefined;\n\n\t/**\n\t * register action to do on destroy this stack\n\t */\n\tonDestroy(action: () => void): void;\n}\n\nexport class Stack implements Stack {\n\tstatic for(...contexts: Scope<Context>[]): Stack {\n\t\tif (contexts.length === 0) {\n\t\t\treturn new Stack();\n\t\t}\n\t\treturn new Stack(contexts.map(context => new Scope<Context>(context)));\n\t}\n\tstatic forScopes(...scopes: Scope<Context>[]): Stack {\n\t\tif (scopes.length === 0) {\n\t\t\tscopes.push(Scope.blockScope());\n\t\t}\n\t\treturn new Stack(scopes);\n\t}\n\tstatic moduleScope(resolver: ModuleScopeResolver, moduleSource: string, ...globalScopes: Scope<Context>[]) {\n\t\treturn new Stack(globalScopes, resolver, moduleSource);\n\t}\n\tawaitPromise: AwaitPromiseInfo[] = [];\n\tforAwaitAsyncIterable?: AsyncIterableInfo | undefined;\n\n\tprotected readonly stack: Array<Scope<any>>;\n\tprotected readonly moduleScope?: ModuleScope;\n\tprotected readonly moduleSource?: string;\n\tprotected readonly resolver?: ModuleScopeResolver;\n\n\tprotected readonly onDestroyActions: (() => void)[] = [];\n\n\tconstructor();\n\tconstructor(globalScope: Scope<Context>);\n\tconstructor(globalScope: Scope<Context>, resolver: ModuleScopeResolver, moduleSource: string);\n\n\tconstructor(stack: Array<Scope<Context>>);\n\tconstructor(stack: Array<Scope<Context>>, resolver: ModuleScopeResolver, moduleSource: string);\n\n\tconstructor(stack: Stack);\n\tconstructor(stack: Stack, resolver: ModuleScopeResolver, moduleSource: string);\n\n\tconstructor(globals?: Stack | Array<Scope<Context>> | Scope<Context>, resolver?: ModuleScopeResolver, moduleSource?: string) {\n\t\tif (Array.isArray(globals)) {\n\t\t\tthis.stack = globals.slice();\n\t\t} else if (globals instanceof Stack) {\n\t\t\tthis.stack = globals.stack.slice();\n\t\t} else if (typeof globals == 'object') {\n\t\t\tthis.stack = [globals];\n\t\t} else {\n\t\t\tthis.stack = [];\n\t\t}\n\t\tif (resolver && moduleSource) {\n\t\t\tthis.resolver = resolver;\n\t\t\tthis.moduleSource = moduleSource;\n\t\t\t// init module scope for import and export\n\t\t\tthis.moduleScope = new ModuleScope(this.initModuleContext());\n\t\t\tthis.pushScope(this.moduleScope);\n\t\t\t// for the rest of module body\n\t\t\tthis.pushReactiveScope();\n\t\t} else {\n\t\t\t// not a module scope\n\t\t\tthis.pushBlockScope();\n\t\t}\n\t\tfinalizerRegister(this, this.onDestroyActions, this);\n\t}\n\tprivate initModuleContext(): ModuleContext {\n\t\tconst importFunc = (path: string) => {\n\t\t\tconst module = this.importModule(path);\n\t\t\tif (module instanceof WebModuleScope) {\n\t\t\t\treturn module.resolveImport();\n\t\t\t}\n\t\t\treturn Promise.resolve(module.getContext());\n\t\t};\n\t\timportFunc.meta = {\n\t\t\turl: createRootURL(this.moduleSource!),\n\t\t\tresolve: (specified: string, parent?: string | URL): Promise<string> => {\n\t\t\t\treturn Promise.resolve(this.resolver!.resolveURL(specified, parent ?? importFunc.meta.url));\n\t\t\t}\n\t\t};\n\t\tconst im: ModuleImport & ((path: string) => Promise<any>) = importFunc as any;\n\t\treturn { import: im };\n\t}\n\thas(propertyKey: PropertyKey): boolean {\n\t\treturn this.stack.find(context => context.has(propertyKey)) ? true : false;\n\t}\n\tget(propertyKey: PropertyKey) {\n\t\treturn this.findScope<Context>(propertyKey).get(propertyKey);\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\treturn this.findScope<Context>(propertyKey).set(propertyKey, value, receiver);\n\t}\n\tdeclareVariable(propertyKey: PropertyKey, propertyValue?: any) {\n\t\treturn this.lastScope<Context>().set(propertyKey, propertyValue);\n\t}\n\tfindScope<T extends Context>(propertyKey: PropertyKey): Scope<T> {\n\t\tlet lastIndex = this.stack.length;\n\t\twhile (lastIndex--) {\n\t\t\tconst scope = this.stack[lastIndex];\n\t\t\tif (scope.has(propertyKey)) {\n\t\t\t\treturn scope;\n\t\t\t}\n\t\t}\n\t\treturn this.lastScope();\n\t}\n\tresolveAwait(value: AwaitPromiseInfo): void {\n\t\tthis.awaitPromise.push(value);\n\t}\n\tpopScope<T extends Context>(): Scope<T> {\n\t\treturn this.stack.pop()!;\n\t}\n\tremoveScope<T extends Context>(scope: Scope<T>): void {\n\t\tconst index = this.stack.lastIndexOf(scope);\n\t\tthis.stack.splice(index, 1);\n\t}\n\tpushScope<T extends Context>(scope: Scope<T>): void {\n\t\tthis.stack.push(scope);\n\t}\n\tpushBlockScope<T extends Context>(): Scope<T> {\n\t\tconst scope = Scope.blockScope<T>();\n\t\tthis.stack.push(scope);\n\t\treturn scope;\n\t}\n\tpushBlockScopeFor<T extends Context>(context: T): Scope<T> {\n\t\tconst scope = Scope.for<T>(context);\n\t\tthis.stack.push(scope);\n\t\treturn scope;\n\t}\n\tpushReactiveScope<T extends Context>(): ReactiveScope<T> {\n\t\tconst scope = ReactiveScope.blockScope<T>();\n\t\tthis.stack.push(scope);\n\t\treturn scope;\n\t}\n\tpushReactiveScopeFor<T extends Context>(context: T): ReactiveScope<T> {\n\t\tconst scope = ReactiveScope.for(context);\n\t\tthis.stack.push(scope);\n\t\treturn scope;\n\t}\n\tlastScope<T extends Context>(): Scope<T> {\n\t\treturn this.stack[this.stack.length - 1];\n\t}\n\tclearTo<T extends Context>(scope: Scope<T>): boolean {\n\t\tconst index = this.stack.lastIndexOf(scope);\n\t\tif (index === -1) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.stack.splice(index);\n\t\treturn true;\n\t}\n\tclearTill<T extends Context>(scope: Scope<T>): boolean {\n\t\tconst index = this.stack.lastIndexOf(scope);\n\t\tif (index === -1) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.stack.splice(index + 1);\n\t\treturn true;\n\t}\n\tcopyStack(): Stack {\n\t\treturn new Stack(this.stack.slice(), this.resolver!, this.moduleSource!);\n\t}\n\tdetach(): void {\n\t\tthis.getReactiveScopeControls().forEach(scope => scope.detach());\n\t}\n\treattach(): void {\n\t\tthis.getReactiveScopeControls().forEach(scope => scope.reattach());\n\t}\n\tdetectChanges() {\n\t\tthis.getReactiveScope().forEach(scope => scope.detectChanges());\n\t}\n\tprivate getReactiveScopeControls(): ReactiveScopeControl<any>[] {\n\t\treturn this.stack.filter(scope => scope instanceof ReactiveScopeControl) as ReactiveScopeControl<any>[];\n\t}\n\tprivate getReactiveScope(): ReactiveScope<any>[] {\n\t\treturn this.stack.filter(scope => scope instanceof ReactiveScope) as ReactiveScope<any>[];\n\t}\n\timportModule(source: string, importCallOptions?: ImportCallOptions): ModuleScope {\n\t\tif (!this.resolver || !this.moduleScope) {\n\t\t\t// should o the parse and import the module\n\t\t\tthrow new Error('Module Resolver is undefined');\n\t\t}\n\t\treturn this.resolver.resolve(source, this.moduleScope, importCallOptions);\n\t}\n\tgetModule(): ModuleScope | undefined {\n\t\treturn this.moduleScope;\n\t}\n\n\tonDestroy(action: () => void): void {\n\t\tthis.onDestroyActions.push(action);\n\t}\n}\n\n\nexport interface ModuleScopeResolver {\n\tresolve(source: string, moduleScope: ModuleScope, importCallOptions?: ImportCallOptions): ModuleScope;\n\tresolveURL(specified: string, parent: string | URL): string;\n}\n\nconst ROOT_URL = 'https://root';\nexport function createRootURL(source: string): URL {\n\treturn new URL(source, ROOT_URL);\n}\n\n\nexport interface ResolverConfig {\n\t/**\n\t * allow import modules from external http(s) module\n\t */\n\tallowImportExternal?: boolean;\n\n};\n\n/**\n * file system provider\n */\nexport interface ModuleSourceProvider {\n\t[url: string]: string;\n}\n\nexport class ModuleScopeResolver implements ModuleScopeResolver {\n\tprotected modules: [string, ModuleScope][] = [];\n\n\tconstructor(protected globalStack: Stack, protected provider: ModuleSourceProvider, protected config?: ResolverConfig) { }\n\tprivate register(source: string, moduleScope: ModuleScope) {\n\t\tconst stackInfo = this.modules.find(tuple => tuple[0] == source && tuple[1] == moduleScope);\n\t\tif (stackInfo) {\n\t\t\tstackInfo[1] = moduleScope;\n\t\t} else {\n\t\t\tthis.modules.push([source, moduleScope]);\n\t\t}\n\t}\n\tresolve(source: keyof ModuleSourceProvider): ModuleScope;\n\tresolve(source: keyof ModuleSourceProvider, moduleScope: ModuleScope, importCallOptions?: ImportCallOptions): ModuleScope;\n\tresolve(source: string, moduleScope?: ModuleScope, importCallOptions?: ImportCallOptions): ModuleScope {\n\t\tif (this.isValidHTTPUrl(source)) {\n\t\t\treturn this.resolveExternalModule(source, importCallOptions);\n\t\t}\n\t\tif (source.startsWith('/')) {\n\t\t\treturn this.findScopeBySource(source, importCallOptions);\n\t\t}\n\t\tconst currentSource = this.findSourceByScope(moduleScope!);\n\t\tconst absoluteUrl = this.resolveURL(source, currentSource);\n\t\treturn this.findScopeBySource(absoluteUrl, importCallOptions);\n\t}\n\tresolveURL(specified: string, parent: string | URL): string {\n\t\tconst currentUrl = parent instanceof URL ? parent.href : createRootURL(parent).href;\n\t\tconst importedUrl = new URL(specified, currentUrl).href;\n\t\tconst absoluteUrl = importedUrl.replace(ROOT_URL, '');\n\t\treturn absoluteUrl;\n\t}\n\tprotected findScopeBySource(source: string, importCallOptions?: ImportCallOptions): ModuleScope {\n\t\tif (importCallOptions?.assert?.type) {\n\t\t\tconst type = importCallOptions.assert.type;\n\t\t\tif (!source.endsWith(`.${type}`)) {\n\t\t\t\tthrow new Error(`Can't find module scope`);\n\t\t\t}\n\t\t}\n\t\tconst importedScope = this.modules.find(tuple => tuple[0] == source)?.[1];\n\t\tif (!importedScope) {\n\t\t\t// search in the file system provider\n\t\t\tconst javascriptSource = this.provider[source];\n\t\t\tif (javascriptSource || javascriptSource == '') {\n\t\t\t\t// module exists\n\t\t\t\tconst moduleProgram = JavaScriptParser.parse(javascriptSource, { mode: LanguageMode.Strict });\n\t\t\t\tconst stack = new Stack(this.globalStack, this, source);\n\t\t\t\t// register with absoluteUrl\n\t\t\t\tthis.register(source, stack.getModule()!);\n\t\t\t\tmoduleProgram.get(stack);\n\t\t\t\treturn stack.getModule()!;\n\t\t\t}\n\t\t\tthrow new Error(`Can't find module scope`);\n\t\t}\n\t\treturn importedScope;\n\t}\n\tprotected findSourceByScope(moduleScope: ModuleScope): string {\n\t\tconst importedSource = this.modules.find(tuple => tuple[1] == moduleScope)?.[0];\n\t\tif (!importedSource) {\n\t\t\tthrow new Error(`Can't resolve scope source`);\n\t\t}\n\t\treturn importedSource;\n\t}\n\tprotected resolveExternalModule(source: string, importCallOptions?: ImportCallOptions): WebModuleScope {\n\t\tif (!this.config?.allowImportExternal) {\n\t\t\tthrow new Error(`Error: Import External Module is not allowed.`);\n\t\t}\n\t\tconst webScope = new WebModuleScope(source, importCallOptions);\n\t\tthis.modules.push([source, webScope]);\n\t\treturn webScope;\n\t}\n\tprotected readonly isValidHTTPUrl = (string: string) => {\n\t\tlet url: URL;\n\t\ttry {\n\t\t\turl = new URL(string);\n\t\t} catch (e) {\n\t\t\treturn false;\n\t\t}\n\t\treturn url.protocol === 'http:' || url.protocol === 'https:';\n\t}\n}\n"]}
1
+ {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/expressions/scope/stack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACuB,WAAW,EAAE,aAAa,EACvD,oBAAoB,EAAE,KAAK,EAAW,cAAc,EACpD,MAAM,YAAY,CAAC;AAyIpB,MAAM,OAAO,KAAK;IACjB,MAAM,CAAC,GAAG,CAAC,GAAG,QAA0B;QACvC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,OAAO,IAAI,KAAK,EAAE,CAAC;SACnB;QACD,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,KAAK,CAAU,OAAO,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,CAAC,SAAS,CAAC,GAAG,MAAwB;QAC3C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;SAChC;QACD,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,MAAM,CAAC,WAAW,CAAC,QAA6B,EAAE,YAAoB,EAAE,GAAG,YAA8B;QACxG,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACxD,CAAC;IAqBD,YAAY,OAAwD,EAAE,QAA8B,EAAE,YAAqB;QApB3H,iBAAY,GAAuB,EAAE,CAAC;QAQnB,qBAAgB,GAAmB,E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AAC,CAAC;gBACxD,4BAA4B;gBAC5B,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,EAAG,CAAC,CAAC;gBAC1C,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACzB,OAAO,KAAK,CAAC,SAAS,EAAG,CAAC;aAC1B;YACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC3C;QACD,OAAO,aAAa,CAAC;IACtB,CAAC;IACS,iBAAiB,CAAC,WAAwB;QACnD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAChF,IAAI,CAAC,cAAc,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC9C;QACD,OAAO,cAAc,CAAC;IACvB,CAAC;IACS,qBAAqB,CAAC,MAAc,EAAE,iBAAqC;QACpF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,mBAAmB,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;SACjE;QACD,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC;IACjB,CAAC;CAUD","sourcesContent":["import type { DeclarationExpression } from '../api/expression.js';\nimport { LanguageMode } from '../v8/language.js';\nimport { JavaScriptParser } from '../v8/parser.js';\nimport { finalizerRegister } from './finalizer.js';\nimport {\n\tModuleContext, ModuleImport, ModuleScope, ReactiveScope,\n\tReactiveScopeControl, Scope, Context, WebModuleScope\n} from './scope.js';\n\n\nexport interface AwaitPromiseInfo {\n\tpromise: Promise<any>;\n\tnode: DeclarationExpression;\n\n\tdeclareVariable: boolean;\n}\n\nexport interface AsyncIterableInfo {\n\titerable: AsyncIterable<any>;\n\tforAwaitBody: (iterator: any) => any;\n}\n\nexport interface Stack {\n\t/**\n\t * a list of promises to resolve in an 'async' scope as 'async function'\n\t */\n\tawaitPromise: Array<AwaitPromiseInfo>;\n\n\t/**\n\t * resolve await promise in 'await for in' scope\n\t */\n\tforAwaitAsyncIterable?: AsyncIterableInfo;\n\n\t/**\n\t * is this stack has a propertyKey\n\t * @param propertyKey \n\t */\n\thas(propertyKey: PropertyKey): boolean;\n\n\t/**\n\t * get the first value for provided property key,\n\t * \n\t * will search current stack in all scope till find the first key, else undefined\n\t * @param propertyKey \n\t */\n\tget(propertyKey: PropertyKey): any;\n\n\t/**\n\t * set the value of `propertyKey` in its context provider with `value`.\n\t * else define it in the first scope 'local scope'\n\t * @param propertyKey \n\t * @param value \n\t * @param receiver \n\t */\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean;\n\n\t/**\n\t * declare variable at last scope in the stack,\n\t * \n\t * @param propertyKey the name of property mey be string | number | symbol, \n\t * @param propertyValue if not exist will be initialize with 'undefined' value\n\t */\n\tdeclareVariable(propertyKey: PropertyKey, propertyValue?: any): any;\n\n\n\t/**\n\t * get context object of this provider,\n\t * search for the first context object that has `propertyKey`.\n\t * \n\t * search for the first context that have property key,\n\t * if not found will return the stack local scop as a default value\n\t * @param propertyKey the property key\n\t */\n\tfindScope<T extends Context>(propertyKey: PropertyKey): Scope<T>;\n\n\tresolveAwait(value: AwaitPromiseInfo): void;\n\n\t/**\n\t * get a reference to the last scope in this stack\n\t */\n\tlastScope<T extends Context>(): Scope<T>;\n\n\t/**\n\t * clear every thing after this scope, and even this scope\n\t * @param scope \n\t */\n\tclearTo<T extends Context>(scope: Scope<T>): boolean;\n\n\t/**\n\t * clear every thing after this scope, but not this scope\n\t * @param scope \n\t */\n\tclearTill<T extends Context>(scope: Scope<T>): boolean;\n\n\tpopScope<T extends Context>(): Scope<T>;\n\n\tremoveScope<T extends Context>(scope: Scope<T>): void;\n\n\tpushScope<T extends Context>(scope: Scope<T>): void;\n\n\tpushBlockScope<T extends Context>(): Scope<T>;\n\n\tpushBlockScopeFor<T extends Context>(context: T): Scope<T>;\n\n\tpushReactiveScope<T extends Context>(): ReactiveScope<T>;\n\n\tpushReactiveScopeFor<T extends Context>(context: T): ReactiveScope<T>;\n\n\t/**\n\t * create new stack instance with the same reference to the current scope array\n\t */\n\tcopyStack(): Stack;\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tdetach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit in time.\n\t */\n\treattach(): void;\n\n\t/**\n\t * import module scope from another stack, by the help of ModuleScopeResolver.\n\t * \n\t * used with import statement\n\t */\n\timportModule(source: string, importCallOptions?: ImportCallOptions): ModuleScope;\n\n\t/**\n\t * get the current module for this stack.\n\t * \n\t * used with export statement\n\t */\n\tgetModule(): ModuleScope | undefined;\n\n\t/**\n\t * register action to do on destroy this stack\n\t */\n\tonDestroy(action: () => void): void;\n}\n\nexport class Stack implements Stack {\n\tstatic for(...contexts: Scope<Context>[]): Stack {\n\t\tif (contexts.length === 0) {\n\t\t\treturn new Stack();\n\t\t}\n\t\treturn new Stack(contexts.map(context => new Scope<Context>(context)));\n\t}\n\tstatic forScopes(...scopes: Scope<Context>[]): Stack {\n\t\tif (scopes.length === 0) {\n\t\t\tscopes.push(Scope.blockScope());\n\t\t}\n\t\treturn new Stack(scopes);\n\t}\n\tstatic moduleScope(resolver: ModuleScopeResolver, moduleSource: string, ...globalScopes: Scope<Context>[]) {\n\t\treturn new Stack(globalScopes, resolver, moduleSource);\n\t}\n\tawaitPromise: AwaitPromiseInfo[] = [];\n\tforAwaitAsyncIterable?: AsyncIterableInfo | undefined;\n\n\tprotected readonly stack: Array<Scope<any>>;\n\tprotected readonly moduleScope?: ModuleScope;\n\tprotected readonly moduleSource?: string;\n\tprotected readonly resolver?: ModuleScopeResolver;\n\n\tprotected readonly onDestroyActions: (() => void)[] = [];\n\n\tconstructor();\n\tconstructor(globalScope: Scope<Context>);\n\tconstructor(globalScope: Scope<Context>, resolver: ModuleScopeResolver, moduleSource: string);\n\n\tconstructor(stack: Array<Scope<Context>>);\n\tconstructor(stack: Array<Scope<Context>>, resolver: ModuleScopeResolver, moduleSource: string);\n\n\tconstructor(stack: Stack);\n\tconstructor(stack: Stack, resolver: ModuleScopeResolver, moduleSource: string);\n\n\tconstructor(globals?: Stack | Array<Scope<Context>> | Scope<Context>, resolver?: ModuleScopeResolver, moduleSource?: string) {\n\t\tif (Array.isArray(globals)) {\n\t\t\tthis.stack = globals.slice();\n\t\t} else if (globals instanceof Stack) {\n\t\t\tthis.stack = globals.stack.slice();\n\t\t} else if (typeof globals == 'object') {\n\t\t\tthis.stack = [globals];\n\t\t} else {\n\t\t\tthis.stack = [];\n\t\t}\n\t\tif (resolver && moduleSource) {\n\t\t\tthis.resolver = resolver;\n\t\t\tthis.moduleSource = moduleSource;\n\t\t\t// init module scope for import and export\n\t\t\tthis.moduleScope = new ModuleScope(this.initModuleContext());\n\t\t\tthis.pushScope(this.moduleScope);\n\t\t\t// for the rest of module body\n\t\t\tthis.pushReactiveScope();\n\t\t} else {\n\t\t\t// not a module scope\n\t\t\tthis.pushBlockScope();\n\t\t}\n\t\tfinalizerRegister(this, this.onDestroyActions, this);\n\t}\n\tprivate initModuleContext(): ModuleContext {\n\t\tconst importFunc = (path: string) => {\n\t\t\tconst module = this.importModule(path);\n\t\t\tif (module instanceof WebModuleScope) {\n\t\t\t\treturn module.resolveImport();\n\t\t\t}\n\t\t\treturn Promise.resolve(module.getContext());\n\t\t};\n\t\timportFunc.meta = {\n\t\t\turl: createRootURL(this.moduleSource!),\n\t\t\tresolve: (specified: string, parent?: string | URL): Promise<string> => {\n\t\t\t\treturn Promise.resolve(this.resolver!.resolveURL(specified, parent ?? importFunc.meta.url));\n\t\t\t}\n\t\t};\n\t\tconst im: ModuleImport & ((path: string) => Promise<any>) = importFunc as any;\n\t\treturn { import: im };\n\t}\n\thas(propertyKey: PropertyKey): boolean {\n\t\treturn this.stack.find(context => context.has(propertyKey)) ? true : false;\n\t}\n\tget(propertyKey: PropertyKey) {\n\t\treturn this.findScope<Context>(propertyKey).get(propertyKey);\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\treturn this.findScope<Context>(propertyKey).set(propertyKey, value, receiver);\n\t}\n\tdeclareVariable(propertyKey: PropertyKey, propertyValue?: any) {\n\t\treturn this.lastScope<Context>().set(propertyKey, propertyValue);\n\t}\n\tfindScope<T extends Context>(propertyKey: PropertyKey): Scope<T> {\n\t\tlet lastIndex = this.stack.length;\n\t\twhile (lastIndex--) {\n\t\t\tconst scope = this.stack[lastIndex];\n\t\t\tif (scope.has(propertyKey)) {\n\t\t\t\treturn scope;\n\t\t\t}\n\t\t}\n\t\treturn this.lastScope();\n\t}\n\tresolveAwait(value: AwaitPromiseInfo): void {\n\t\tthis.awaitPromise.push(value);\n\t}\n\tpopScope<T extends Context>(): Scope<T> {\n\t\treturn this.stack.pop()!;\n\t}\n\tremoveScope<T extends Context>(scope: Scope<T>): void {\n\t\tconst index = this.stack.lastIndexOf(scope);\n\t\tthis.stack.splice(index, 1);\n\t}\n\tpushScope<T extends Context>(scope: Scope<T>): void {\n\t\tthis.stack.push(scope);\n\t}\n\tpushBlockScope<T extends Context>(propertyKeys?: (keyof T)[]): Scope<T> {\n\t\tconst scope = Scope.blockScope<T>(propertyKeys);\n\t\tthis.stack.push(scope);\n\t\treturn scope;\n\t}\n\tpushBlockScopeFor<T extends Context>(context: T, propertyKeys?: (keyof T)[]): Scope<T> {\n\t\tconst scope = Scope.for<T>(context, propertyKeys);\n\t\tthis.stack.push(scope);\n\t\treturn scope;\n\t}\n\tpushReactiveScope<T extends Context>(propertyKeys?: (keyof T)[]): ReactiveScope<T> {\n\t\tconst scope = ReactiveScope.blockScope<T>(propertyKeys);\n\t\tthis.stack.push(scope);\n\t\treturn scope;\n\t}\n\tpushReactiveScopeFor<T extends Context>(context: T, propertyKeys?: (keyof T)[]): ReactiveScope<T> {\n\t\tconst scope = ReactiveScope.for(context, propertyKeys);\n\t\tthis.stack.push(scope);\n\t\treturn scope;\n\t}\n\tlastScope<T extends Context>(): Scope<T> {\n\t\treturn this.stack[this.stack.length - 1];\n\t}\n\tclearTo<T extends Context>(scope: Scope<T>): boolean {\n\t\tconst index = this.stack.lastIndexOf(scope);\n\t\tif (index === -1) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.stack.splice(index);\n\t\treturn true;\n\t}\n\tclearTill<T extends Context>(scope: Scope<T>): boolean {\n\t\tconst index = this.stack.lastIndexOf(scope);\n\t\tif (index === -1) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.stack.splice(index + 1);\n\t\treturn true;\n\t}\n\tcopyStack(): Stack {\n\t\treturn new Stack(this.stack.slice(), this.resolver!, this.moduleSource!);\n\t}\n\tdetach(): void {\n\t\tthis.getReactiveScopeControls().forEach(scope => scope.detach());\n\t}\n\treattach(): void {\n\t\tthis.getReactiveScopeControls().forEach(scope => scope.reattach());\n\t}\n\tdetectChanges() {\n\t\tthis.getReactiveScope().forEach(scope => scope.detectChanges());\n\t}\n\tprivate getReactiveScopeControls(): ReactiveScopeControl<any>[] {\n\t\treturn this.stack.filter(scope => scope instanceof ReactiveScopeControl) as ReactiveScopeControl<any>[];\n\t}\n\tprivate getReactiveScope(): ReactiveScope<any>[] {\n\t\treturn this.stack.filter(scope => scope instanceof ReactiveScope) as ReactiveScope<any>[];\n\t}\n\timportModule(source: string, importCallOptions?: ImportCallOptions): ModuleScope {\n\t\tif (!this.resolver || !this.moduleScope) {\n\t\t\t// should o the parse and import the module\n\t\t\tthrow new Error('Module Resolver is undefined');\n\t\t}\n\t\treturn this.resolver.resolve(source, this.moduleScope, importCallOptions);\n\t}\n\tgetModule(): ModuleScope | undefined {\n\t\treturn this.moduleScope;\n\t}\n\n\tonDestroy(action: () => void): void {\n\t\tthis.onDestroyActions.push(action);\n\t}\n}\n\n\nexport interface ModuleScopeResolver {\n\tresolve(source: string, moduleScope: ModuleScope, importCallOptions?: ImportCallOptions): ModuleScope;\n\tresolveURL(specified: string, parent: string | URL): string;\n}\n\nconst ROOT_URL = 'https://root';\nexport function createRootURL(source: string): URL {\n\treturn new URL(source, ROOT_URL);\n}\n\n\nexport interface ResolverConfig {\n\t/**\n\t * allow import modules from external http(s) module\n\t */\n\tallowImportExternal?: boolean;\n\n};\n\n/**\n * file system provider\n */\nexport interface ModuleSourceProvider {\n\t[url: string]: string;\n}\n\nexport class ModuleScopeResolver implements ModuleScopeResolver {\n\tprotected modules: [string, ModuleScope][] = [];\n\n\tconstructor(protected globalStack: Stack, protected provider: ModuleSourceProvider, protected config?: ResolverConfig) { }\n\tprivate register(source: string, moduleScope: ModuleScope) {\n\t\tconst stackInfo = this.modules.find(tuple => tuple[0] == source && tuple[1] == moduleScope);\n\t\tif (stackInfo) {\n\t\t\tstackInfo[1] = moduleScope;\n\t\t} else {\n\t\t\tthis.modules.push([source, moduleScope]);\n\t\t}\n\t}\n\tresolve(source: keyof ModuleSourceProvider): ModuleScope;\n\tresolve(source: keyof ModuleSourceProvider, moduleScope: ModuleScope, importCallOptions?: ImportCallOptions): ModuleScope;\n\tresolve(source: string, moduleScope?: ModuleScope, importCallOptions?: ImportCallOptions): ModuleScope {\n\t\tif (this.isValidHTTPUrl(source)) {\n\t\t\treturn this.resolveExternalModule(source, importCallOptions);\n\t\t}\n\t\tif (source.startsWith('/')) {\n\t\t\treturn this.findScopeBySource(source, importCallOptions);\n\t\t}\n\t\tconst currentSource = this.findSourceByScope(moduleScope!);\n\t\tconst absoluteUrl = this.resolveURL(source, currentSource);\n\t\treturn this.findScopeBySource(absoluteUrl, importCallOptions);\n\t}\n\tresolveURL(specified: string, parent: string | URL): string {\n\t\tconst currentUrl = parent instanceof URL ? parent.href : createRootURL(parent).href;\n\t\tconst importedUrl = new URL(specified, currentUrl).href;\n\t\tconst absoluteUrl = importedUrl.replace(ROOT_URL, '');\n\t\treturn absoluteUrl;\n\t}\n\tprotected findScopeBySource(source: string, importCallOptions?: ImportCallOptions): ModuleScope {\n\t\tif (importCallOptions?.assert?.type) {\n\t\t\tconst type = importCallOptions.assert.type;\n\t\t\tif (!source.endsWith(`.${type}`)) {\n\t\t\t\tthrow new Error(`Can't find module scope`);\n\t\t\t}\n\t\t}\n\t\tconst importedScope = this.modules.find(tuple => tuple[0] == source)?.[1];\n\t\tif (!importedScope) {\n\t\t\t// search in the file system provider\n\t\t\tconst javascriptSource = this.provider[source];\n\t\t\tif (javascriptSource || javascriptSource == '') {\n\t\t\t\t// module exists\n\t\t\t\tconst moduleProgram = JavaScriptParser.parse(javascriptSource, { mode: LanguageMode.Strict });\n\t\t\t\tconst stack = new Stack(this.globalStack, this, source);\n\t\t\t\t// register with absoluteUrl\n\t\t\t\tthis.register(source, stack.getModule()!);\n\t\t\t\tmoduleProgram.get(stack);\n\t\t\t\treturn stack.getModule()!;\n\t\t\t}\n\t\t\tthrow new Error(`Can't find module scope`);\n\t\t}\n\t\treturn importedScope;\n\t}\n\tprotected findSourceByScope(moduleScope: ModuleScope): string {\n\t\tconst importedSource = this.modules.find(tuple => tuple[1] == moduleScope)?.[0];\n\t\tif (!importedSource) {\n\t\t\tthrow new Error(`Can't resolve scope source`);\n\t\t}\n\t\treturn importedSource;\n\t}\n\tprotected resolveExternalModule(source: string, importCallOptions?: ImportCallOptions): WebModuleScope {\n\t\tif (!this.config?.allowImportExternal) {\n\t\t\tthrow new Error(`Error: Import External Module is not allowed.`);\n\t\t}\n\t\tconst webScope = new WebModuleScope(source, importCallOptions);\n\t\tthis.modules.push([source, webScope]);\n\t\treturn webScope;\n\t}\n\tprotected readonly isValidHTTPUrl = (string: string) => {\n\t\tlet url: URL;\n\t\ttry {\n\t\t\turl = new URL(string);\n\t\t} catch (e) {\n\t\t\treturn false;\n\t\t}\n\t\treturn url.protocol === 'http:' || url.protocol === 'https:';\n\t}\n}\n"]}
package/v8/enums.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AccessorProperty, MethodDefinition, PropertyDefinition, StaticBlock } from '../api/class/class.js';
2
2
  import { ExpressionNode } from '../api/expression.js';
3
3
  import { VariableDeclarator } from '../api/statement/declarations/declares.js';
4
+ import { PositionMark } from './inline.js';
4
5
  import { Token } from './token.js';
5
6
  export declare function isInRange(num: number, start: number, end: number): boolean;
6
7
  export declare enum ParsingArrowHeadFlag {
@@ -34,9 +35,10 @@ export declare class PropertyKindInfo {
34
35
  isPrivate: boolean;
35
36
  isStatic: boolean;
36
37
  isRest: boolean;
38
+ rangeStart: PositionMark;
37
39
  parsePropertyKindFromToken(token: Token): boolean;
38
40
  }
39
- export declare type FunctionInfo = {
41
+ export type FunctionInfo = {
40
42
  rest?: boolean;
41
43
  };
42
44
  export declare enum PreParserIdentifierType {
@@ -131,7 +133,7 @@ export declare function isStatic(kind: FunctionKind): boolean;
131
133
  export declare function bindsSuper(kind: FunctionKind): boolean;
132
134
  export declare function isAwaitAsIdentifierDisallowed(kind: FunctionKind): boolean;
133
135
  export declare function functionKind2String(kind: FunctionKind): string;
134
- export declare type ClassInfo = {
136
+ export type ClassInfo = {
135
137
  extends?: ExpressionNode;
136
138
  publicMembers: (MethodDefinition | PropertyDefinition)[];
137
139
  privateMembers: (MethodDefinition | PropertyDefinition)[];
package/v8/enums.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/expressions/v8/enums.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,KAAa,EAAE,GAAW;IAChE,OAAO,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,CAAC;AACnC,CAAC;AAED,MAAM,CAAN,IAAY,oBAAkF;AAA9F,WAAY,oBAAoB;IAAG,iGAAqB,CAAA;IA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WAAY,0BAA0B;IACrC,qGAAiB,CAAA;IACjB,qFAAS,CAAA;IACT,2FAAY,CAAA;AACb,CAAC,EAJW,0BAA0B,KAA1B,0BAA0B,QAIrC;AAAA,CAAC;AAEF,MAAM,CAAN,IAAY,8BAGX;AAHD,WAAY,8BAA8B;IACzC,uIAA8B,CAAA;IAC9B,6IAAiC,CAAA;AAClC,CAAC,EAHW,8BAA8B,KAA9B,8BAA8B,QAGzC;AAAA,CAAC","sourcesContent":["import { AccessorProperty, MethodDefinition, PropertyDefinition, StaticBlock } from '../api/class/class.js';\nimport { ExpressionNode } from '../api/expression.js';\nimport { VariableDeclarator } from '../api/statement/declarations/declares.js';\nimport { Token } from './token.js';\n\nexport function isInRange(num: number, start: number, end: number) {\n\treturn num >= start && num <= end;\n}\n\nexport enum ParsingArrowHeadFlag { CertainlyNotArrowHead, MaybeArrowHead, AsyncArrowFunction }\nexport enum PropertyKind {\n\tValue, Shorthand, ShorthandOrClassField,\n\tAssign, Method, ClassField, AccessorGetter, AccessorSetter,\n\tSpread, NotSet\n}\nexport function isAccessor(kind: PropertyKind) {\n\treturn kind === PropertyKind.AccessorGetter || kind === PropertyKind.AccessorSetter;\n}\n\nexport enum PropertyPosition {\n\tObjectLiteral,\n\tClassLiteral\n}\n\nexport class PropertyKindInfo {\n\tname: string;\n\tposition = PropertyPosition.ClassLiteral;\n\tfuncFlag = ParseFunctionFlag.IsNormal;\n\tkind = PropertyKind.NotSet;\n\tisComputedName = false;\n\tisPrivate = false;\n\tisStatic = false;\n\tisRest = false;\n\n\tparsePropertyKindFromToken(token: Token): boolean {\n\t\t// This returns true, setting the property kind, iff the given token is\n\t\t// one which must occur after a property name, indicating that the\n\t\t// previous token was in fact a name and not a modifier (like the \"get\" in\n\t\t// \"get x\").\n\t\tswitch (token) {\n\t\t\tcase Token.COLON:\n\t\t\t\tthis.kind = PropertyKind.Value;\n\t\t\t\treturn true;\n\t\t\tcase Token.COMMA:\n\t\t\t\tthis.kind = PropertyKind.Shorthand;\n\t\t\t\treturn true;\n\t\t\tcase Token.RBRACE:\n\t\t\t\tthis.kind = PropertyKind.ShorthandOrClassField;\n\t\t\t\treturn true;\n\t\t\tcase Token.ASSIGN:\n\t\t\t\tthis.kind = PropertyKind.Assign;\n\t\t\t\treturn true;\n\t\t\tcase Token.LPAREN:\n\t\t\t\tthis.kind = PropertyKind.Method;\n\t\t\t\treturn true;\n\t\t\tcase Token.MUL:\n\t\t\tcase Token.SEMICOLON:\n\t\t\t\tthis.kind = PropertyKind.ClassField;\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn false;\n\t}\n\n}\n\nexport type FunctionInfo = { rest?: boolean };\n\nexport enum PreParserIdentifierType {\n\tNullIdentifier,\n\tUnknownIdentifier,\n\tEvalIdentifier,\n\tArgumentsIdentifier,\n\tConstructorIdentifier,\n\tAwaitIdentifier,\n\tAsyncIdentifier,\n\tNameIdentifier,\n\tPrivateNameIdentifier\n}\n\nexport enum FunctionBodyType {\n\tEXPRESSION,\n\tBLOCK,\n}\n\nexport enum ParseFunctionFlag {\n\tIsNormal = 0,\n\tIsGenerator = 1 << 0,\n\tIsAsync = 1 << 1\n}\n\nexport enum FunctionKind {\n\n\t// BEGIN constructable functions\n\tNormalFunction,\n\tModule,\n\tAsyncModule,\n\t// BEGIN class constructors\n\t// BEGIN base constructors\n\tBaseConstructor,\n\t// BEGIN default constructors\n\tDefaultBaseConstructor,\n\t// END base constructors\n\t// BEGIN derived constructors\n\tDefaultDerivedConstructor,\n\t// END default constructors\n\tDerivedConstructor,\n\t// END derived constructors\n\t// END class constructors\n\t// END constructable functions.\n\t// BEGIN accessors\n\tGetterFunction,\n\tStaticGetterFunction,\n\tSetterFunction,\n\tStaticSetterFunction,\n\t// END accessors\n\t// BEGIN arrow functions\n\tArrowFunction,\n\t// BEGIN async functions\n\tAsyncArrowFunction,\n\t// END arrow functions\n\tAsyncFunction,\n\t// BEGIN concise methods 1\n\tAsyncConciseMethod,\n\tStaticAsyncConciseMethod,\n\t// BEGIN generators\n\tAsyncConciseGeneratorMethod,\n\tStaticAsyncConciseGeneratorMethod,\n\t// END concise methods 1\n\tAsyncGeneratorFunction,\n\t// END async functions\n\tGeneratorFunction,\n\t// BEGIN concise methods 2\n\tConciseGeneratorMethod,\n\tStaticConciseGeneratorMethod,\n\t// END generators\n\tConciseMethod,\n\tStaticConciseMethod,\n\tClassMembersInitializerFunction,\n\tClassStaticInitializerFunction,\n\t// END concise methods 2\n\tInvalid,\n\n\tLastFunctionKind = ClassStaticInitializerFunction,\n}\n\nconst FUNCTIONS_TYPES: FunctionKind[][][] = [\n\t[\n\t\t// SubFunctionKind::kNormalFunction\n\t\t[// is_generator=false\n\t\t\tFunctionKind.NormalFunction,\n\t\t\tFunctionKind.AsyncFunction\n\t\t],\n\t\t[// is_generator=true\n\t\t\tFunctionKind.GeneratorFunction,\n\t\t\tFunctionKind.AsyncGeneratorFunction\n\t\t],\n\t],\n\t[\n\t\t// SubFunctionKind::kNonStaticMethod\n\t\t[// is_generator=false\n\t\t\tFunctionKind.ConciseMethod,\n\t\t\tFunctionKind.AsyncConciseMethod\n\t\t],\n\t\t[// is_generator=true\n\t\t\tFunctionKind.ConciseGeneratorMethod,\n\t\t\tFunctionKind.AsyncConciseGeneratorMethod\n\t\t],\n\t],\n\t[\n\t\t// SubFunctionKind::kStaticMethod\n\t\t[// is_generator=false\n\t\t\tFunctionKind.StaticConciseMethod,\n\t\t\tFunctionKind.StaticAsyncConciseMethod\n\t\t],\n\t\t[// is_generator=true\n\t\t\tFunctionKind.StaticConciseGeneratorMethod,\n\t\t\tFunctionKind.StaticAsyncConciseGeneratorMethod\n\t\t],\n\t]\n];\n\nexport enum SubFunctionKind {\n\tNormalFunction,\n\tNonStaticMethod,\n\tStaticMethod,\n}\n\nexport enum StaticFlag {\n\tNotStatic,\n\tStatic\n};\n\n\nexport function functionKindForImpl(subFunctionKind: SubFunctionKind, flags: ParseFunctionFlag): FunctionKind {\n\treturn FUNCTIONS_TYPES[subFunctionKind]\n\t[(flags & ParseFunctionFlag.IsGenerator) != 0 ? 1 : 0]\n\t[(flags & ParseFunctionFlag.IsAsync) != 0 ? 1 : 0];\n}\n\nexport function functionKindFor(isGenerator: boolean, isAsync: boolean): FunctionKind {\n\treturn FUNCTIONS_TYPES[SubFunctionKind.NormalFunction][isGenerator ? 1 : 0][isAsync ? 1 : 0];\n}\n\nexport function methodKindFor(isStatic: boolean, isGenerator: boolean, isAsync: boolean): FunctionKind {\n\treturn FUNCTIONS_TYPES[isStatic ? SubFunctionKind.StaticMethod : SubFunctionKind.NonStaticMethod][isGenerator ? 1 : 0][isAsync ? 1 : 0];\n}\n\nexport enum FunctionSyntaxKind {\n\tAnonymousExpression,\n\tNamedExpression,\n\tDeclaration,\n\tAccessorOrMethod,\n\tWrapped,\n\n\tLastFunctionSyntaxKind = Wrapped,\n};\n\n\n\nexport function isArrowFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.ArrowFunction, FunctionKind.AsyncArrowFunction);\n}\n\nexport function isModule(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.Module, FunctionKind.AsyncModule);\n}\n\nexport function isAsyncModule(kind: FunctionKind) {\n\treturn kind == FunctionKind.AsyncModule;\n}\n\nexport function isAsyncGeneratorFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.AsyncConciseGeneratorMethod, FunctionKind.AsyncGeneratorFunction);\n}\n\nexport function isGeneratorFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.AsyncConciseGeneratorMethod, FunctionKind.StaticConciseGeneratorMethod);\n}\n\nexport function isAsyncFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.AsyncArrowFunction, FunctionKind.AsyncGeneratorFunction);\n}\n\nexport function isResumableFunction(kind: FunctionKind) {\n\treturn isGeneratorFunction(kind) || isAsyncFunction(kind) || isModule(kind);\n}\n\nexport function isConciseMethod(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.AsyncConciseMethod, FunctionKind.StaticAsyncConciseGeneratorMethod)\n\t\t|| isInRange(kind, FunctionKind.ConciseGeneratorMethod, FunctionKind.ClassStaticInitializerFunction);\n}\n\nexport function isStrictFunctionWithoutPrototype(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.GetterFunction, FunctionKind.AsyncArrowFunction)\n\t\t|| isInRange(kind, FunctionKind.AsyncConciseMethod, FunctionKind.StaticAsyncConciseGeneratorMethod)\n\t\t|| isInRange(kind, FunctionKind.ConciseGeneratorMethod, FunctionKind.ClassStaticInitializerFunction);\n}\n\nexport function isGetterFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.GetterFunction, FunctionKind.StaticGetterFunction);\n}\n\nexport function isSetterFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.SetterFunction, FunctionKind.StaticSetterFunction);\n}\n\nexport function isAccessorFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.GetterFunction, FunctionKind.StaticSetterFunction);\n}\n\nexport function isDefaultConstructor(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.DefaultBaseConstructor, FunctionKind.DefaultDerivedConstructor);\n}\n\nexport function isBaseConstructor(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.BaseConstructor, FunctionKind.DefaultBaseConstructor);\n}\n\nexport function isDerivedConstructor(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.DefaultDerivedConstructor, FunctionKind.DerivedConstructor);\n}\n\nexport function isClassConstructor(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.BaseConstructor, FunctionKind.DerivedConstructor);\n}\n\nexport function isClassMembersInitializerFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.ClassMembersInitializerFunction, FunctionKind.ClassStaticInitializerFunction);\n}\n\nexport function isConstructable(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.NormalFunction, FunctionKind.DerivedConstructor);\n}\n\nexport function isStatic(kind: FunctionKind) {\n\tswitch (kind) {\n\t\tcase FunctionKind.StaticGetterFunction:\n\t\tcase FunctionKind.StaticSetterFunction:\n\t\tcase FunctionKind.StaticConciseMethod:\n\t\tcase FunctionKind.StaticConciseGeneratorMethod:\n\t\tcase FunctionKind.StaticAsyncConciseMethod:\n\t\tcase FunctionKind.StaticAsyncConciseGeneratorMethod:\n\t\tcase FunctionKind.ClassStaticInitializerFunction:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport function bindsSuper(kind: FunctionKind) {\n\treturn isConciseMethod(kind) || isAccessorFunction(kind) || isClassConstructor(kind);\n}\n\nexport function isAwaitAsIdentifierDisallowed(kind: FunctionKind) {\n\t// 'await' is always disallowed as an identifier in module contexts. Callers\n\t// should short-circuit the module case instead of calling this.\n\treturn !isModule(kind) && (isAsyncFunction(kind) || kind == FunctionKind.ClassStaticInitializerFunction);\n}\n\nexport function functionKind2String(kind: FunctionKind): string {\n\treturn FunctionKind[kind];\n}\n\nexport type ClassInfo = {\n\textends?: ExpressionNode;\n\tpublicMembers: (MethodDefinition | PropertyDefinition)[],\n\tprivateMembers: (MethodDefinition | PropertyDefinition)[],\n\tstaticElements: (MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock)[],\n\tinstanceFields: (MethodDefinition | PropertyDefinition | AccessorProperty)[],\n\tconstructor: MethodDefinition | undefined,\n\n\thasSeenConstructor: boolean;\n\thasStaticComputedNames: boolean;\n\thasStaticElements: boolean;\n\thasStaticPrivateMethods: boolean;\n\thasStaticBlocks: boolean;\n\thasInstanceMembers: boolean;\n\trequiresBrand: boolean;\n\tisAnonymous: boolean;\n\thasPrivateMethods: boolean,\n\n\tcomputedFieldCount: number;\n\n\thomeObjectVariable?: VariableDeclarator;\n\tstaticHomeObjectVariable?: VariableDeclarator;\n};\n\nexport function createClassInfo(): ClassInfo {\n\treturn {\n\t\tpublicMembers: [],\n\t\tprivateMembers: [],\n\t\tstaticElements: [],\n\t\tinstanceFields: [],\n\t\t'constructor': undefined,\n\n\t\thasSeenConstructor: false,\n\t\thasStaticComputedNames: false,\n\t\thasStaticElements: false,\n\t\thasStaticPrivateMethods: false,\n\t\thasStaticBlocks: false,\n\t\thasInstanceMembers: false,\n\t\trequiresBrand: false,\n\t\tisAnonymous: false,\n\t\thasPrivateMethods: false,\n\n\t\tcomputedFieldCount: 0,\n\t};\n}\n\nexport enum FunctionNameValidity {\n\tFunctionNameIsStrictReserved = 'FunctionNameIsStrictReserved',\n\tSkipFunctionNameCheck = 'SkipFunctionNameCheck',\n\tFunctionNameValidityUnknown = 'FunctionNameValidityUnknown'\n};\n\nexport enum ObjectLiteralPropertyKind {\n\tCONSTANT = 'CONSTANT',\t// Property with constant value (compile time).\n\tCOMPUTED = 'COMPUTED',\t// Property with computed value (execution time).\n\tMATERIALIZED_LITERAL = 'MATERIALIZED_LITERAL', // Property value is a materialized literal.\n\tGETTER = 'GETTER',\n\tSETTER = 'SETTER',\t\t// Property is an accessor function.\n\tPROTOTYPE = 'PROTOTYPE',\t// Property is __proto__.\n\tSPREAD = 'SPREAD'\n}\nexport class ObjectLiteralProperty {\n\tstatic Kind = ObjectLiteralPropertyKind;\n}\n\nexport enum ClassLiteralPropertyKind {\n\tMETHOD = 'METHOD',\n\tGETTER = 'GETTER',\n\tSETTER = 'SETTER',\n\tFIELD = 'FIELD'\n}\n\nexport class ClassLiteralProperty {\n\tstatic Kind = ClassLiteralPropertyKind;\n}\n\nexport function classPropertyKindFor(kind: PropertyKind): ClassLiteralPropertyKind {\n\tswitch (kind) {\n\t\tcase PropertyKind.AccessorGetter:\n\t\t\treturn ClassLiteralPropertyKind.GETTER;\n\t\tcase PropertyKind.AccessorSetter:\n\t\t\treturn ClassLiteralPropertyKind.SETTER;\n\t\tcase PropertyKind.Method:\n\t\t\treturn ClassLiteralPropertyKind.METHOD;\n\t\tcase PropertyKind.ClassField:\n\t\t\treturn ClassLiteralPropertyKind.FIELD;\n\t}\n\tthrow new Error(`unexpected property kind: ${kind}`);\n}\n\nexport enum VariableMode {\n\tConst = 'Const',\n\tPrivateMethod = 'PrivateMethod',\n\tPrivateGetterOnly = 'PrivateGetterOnly',\n\tPrivateSetterOnly = 'PrivateSetterOnly'\n}\n\nexport function getVariableMode(kind: ClassLiteralPropertyKind): VariableMode {\n\tswitch (kind) {\n\t\tcase ClassLiteralPropertyKind.FIELD:\n\t\t\treturn VariableMode.Const;\n\t\tcase ClassLiteralPropertyKind.METHOD:\n\t\t\treturn VariableMode.PrivateMethod;\n\t\tcase ClassLiteralPropertyKind.GETTER:\n\t\t\treturn VariableMode.PrivateGetterOnly;\n\t\tcase ClassLiteralPropertyKind.SETTER:\n\t\t\treturn VariableMode.PrivateSetterOnly;\n\t}\n}\n\nexport enum VariableDeclarationContext {\n\tStatementListItem,\n\tStatement,\n\tForStatement\n};\n\nexport enum AllowLabelledFunctionStatement {\n\tAllowLabelledFunctionStatement,\n\tDisallowLabelledFunctionStatement,\n};\n"]}
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/expressions/v8/enums.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,KAAa,EAAE,GAAW;IAChE,OAAO,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,CAAC;AACnC,CAAC;AAED,MAAM,CAAN,IAAY,oBAAkF;AAA9F,WAAY,oBAAoB;IAAG,iGAAqB,CAAA;IAAE,mFAAc,CAAA;IAAE,2FAAkB,CAAA;AAAC,CAAC,EAAlF,oBAAoB,KAApB,oBAAoB,QAA8D;AAC9F,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACvB,iDAAK,CAAA;IAAE,yDAAS,CAAA;IAAE,iFAAqB,CAAA;IACvC,mDAAM,CAAA;IAAE,mDAAM,CAAA;IAAE,2DAAU,CAAA;IAAE,mEAAc,CAAA;IAAE,mEAAc,CAAA;IAC1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["import { AccessorProperty, MethodDefinition, PropertyDefinition, StaticBlock } from '../api/class/class.js';\nimport { ExpressionNode } from '../api/expression.js';\nimport { VariableDeclarator } from '../api/statement/declarations/declares.js';\nimport { PositionMark } from './inline.js';\nimport { Token } from './token.js';\n\nexport function isInRange(num: number, start: number, end: number) {\n\treturn num >= start && num <= end;\n}\n\nexport enum ParsingArrowHeadFlag { CertainlyNotArrowHead, MaybeArrowHead, AsyncArrowFunction }\nexport enum PropertyKind {\n\tValue, Shorthand, ShorthandOrClassField,\n\tAssign, Method, ClassField, AccessorGetter, AccessorSetter,\n\tSpread, NotSet\n}\nexport function isAccessor(kind: PropertyKind) {\n\treturn kind === PropertyKind.AccessorGetter || kind === PropertyKind.AccessorSetter;\n}\n\nexport enum PropertyPosition {\n\tObjectLiteral,\n\tClassLiteral\n}\n\nexport class PropertyKindInfo {\n\tname: string;\n\tposition = PropertyPosition.ClassLiteral;\n\tfuncFlag = ParseFunctionFlag.IsNormal;\n\tkind = PropertyKind.NotSet;\n\tisComputedName = false;\n\tisPrivate = false;\n\tisStatic = false;\n\tisRest = false;\n\n\trangeStart: PositionMark;\n\n\tparsePropertyKindFromToken(token: Token): boolean {\n\t\t// This returns true, setting the property kind, iff the given token is\n\t\t// one which must occur after a property name, indicating that the\n\t\t// previous token was in fact a name and not a modifier (like the \"get\" in\n\t\t// \"get x\").\n\t\tswitch (token) {\n\t\t\tcase Token.COLON:\n\t\t\t\tthis.kind = PropertyKind.Value;\n\t\t\t\treturn true;\n\t\t\tcase Token.COMMA:\n\t\t\t\tthis.kind = PropertyKind.Shorthand;\n\t\t\t\treturn true;\n\t\t\tcase Token.RBRACE:\n\t\t\t\tthis.kind = PropertyKind.ShorthandOrClassField;\n\t\t\t\treturn true;\n\t\t\tcase Token.ASSIGN:\n\t\t\t\tthis.kind = PropertyKind.Assign;\n\t\t\t\treturn true;\n\t\t\tcase Token.LPAREN:\n\t\t\t\tthis.kind = PropertyKind.Method;\n\t\t\t\treturn true;\n\t\t\tcase Token.MUL:\n\t\t\tcase Token.SEMICOLON:\n\t\t\t\tthis.kind = PropertyKind.ClassField;\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn false;\n\t}\n\n}\n\nexport type FunctionInfo = { rest?: boolean };\n\nexport enum PreParserIdentifierType {\n\tNullIdentifier,\n\tUnknownIdentifier,\n\tEvalIdentifier,\n\tArgumentsIdentifier,\n\tConstructorIdentifier,\n\tAwaitIdentifier,\n\tAsyncIdentifier,\n\tNameIdentifier,\n\tPrivateNameIdentifier\n}\n\nexport enum FunctionBodyType {\n\tEXPRESSION,\n\tBLOCK,\n}\n\nexport enum ParseFunctionFlag {\n\tIsNormal = 0,\n\tIsGenerator = 1 << 0,\n\tIsAsync = 1 << 1\n}\n\nexport enum FunctionKind {\n\n\t// BEGIN constructable functions\n\tNormalFunction,\n\tModule,\n\tAsyncModule,\n\t// BEGIN class constructors\n\t// BEGIN base constructors\n\tBaseConstructor,\n\t// BEGIN default constructors\n\tDefaultBaseConstructor,\n\t// END base constructors\n\t// BEGIN derived constructors\n\tDefaultDerivedConstructor,\n\t// END default constructors\n\tDerivedConstructor,\n\t// END derived constructors\n\t// END class constructors\n\t// END constructable functions.\n\t// BEGIN accessors\n\tGetterFunction,\n\tStaticGetterFunction,\n\tSetterFunction,\n\tStaticSetterFunction,\n\t// END accessors\n\t// BEGIN arrow functions\n\tArrowFunction,\n\t// BEGIN async functions\n\tAsyncArrowFunction,\n\t// END arrow functions\n\tAsyncFunction,\n\t// BEGIN concise methods 1\n\tAsyncConciseMethod,\n\tStaticAsyncConciseMethod,\n\t// BEGIN generators\n\tAsyncConciseGeneratorMethod,\n\tStaticAsyncConciseGeneratorMethod,\n\t// END concise methods 1\n\tAsyncGeneratorFunction,\n\t// END async functions\n\tGeneratorFunction,\n\t// BEGIN concise methods 2\n\tConciseGeneratorMethod,\n\tStaticConciseGeneratorMethod,\n\t// END generators\n\tConciseMethod,\n\tStaticConciseMethod,\n\tClassMembersInitializerFunction,\n\tClassStaticInitializerFunction,\n\t// END concise methods 2\n\tInvalid,\n\n\tLastFunctionKind = ClassStaticInitializerFunction,\n}\n\nconst FUNCTIONS_TYPES: FunctionKind[][][] = [\n\t[\n\t\t// SubFunctionKind::kNormalFunction\n\t\t[// is_generator=false\n\t\t\tFunctionKind.NormalFunction,\n\t\t\tFunctionKind.AsyncFunction\n\t\t],\n\t\t[// is_generator=true\n\t\t\tFunctionKind.GeneratorFunction,\n\t\t\tFunctionKind.AsyncGeneratorFunction\n\t\t],\n\t],\n\t[\n\t\t// SubFunctionKind::kNonStaticMethod\n\t\t[// is_generator=false\n\t\t\tFunctionKind.ConciseMethod,\n\t\t\tFunctionKind.AsyncConciseMethod\n\t\t],\n\t\t[// is_generator=true\n\t\t\tFunctionKind.ConciseGeneratorMethod,\n\t\t\tFunctionKind.AsyncConciseGeneratorMethod\n\t\t],\n\t],\n\t[\n\t\t// SubFunctionKind::kStaticMethod\n\t\t[// is_generator=false\n\t\t\tFunctionKind.StaticConciseMethod,\n\t\t\tFunctionKind.StaticAsyncConciseMethod\n\t\t],\n\t\t[// is_generator=true\n\t\t\tFunctionKind.StaticConciseGeneratorMethod,\n\t\t\tFunctionKind.StaticAsyncConciseGeneratorMethod\n\t\t],\n\t]\n];\n\nexport enum SubFunctionKind {\n\tNormalFunction,\n\tNonStaticMethod,\n\tStaticMethod,\n}\n\nexport enum StaticFlag {\n\tNotStatic,\n\tStatic\n};\n\n\nexport function functionKindForImpl(subFunctionKind: SubFunctionKind, flags: ParseFunctionFlag): FunctionKind {\n\treturn FUNCTIONS_TYPES[subFunctionKind]\n\t[(flags & ParseFunctionFlag.IsGenerator) != 0 ? 1 : 0]\n\t[(flags & ParseFunctionFlag.IsAsync) != 0 ? 1 : 0];\n}\n\nexport function functionKindFor(isGenerator: boolean, isAsync: boolean): FunctionKind {\n\treturn FUNCTIONS_TYPES[SubFunctionKind.NormalFunction][isGenerator ? 1 : 0][isAsync ? 1 : 0];\n}\n\nexport function methodKindFor(isStatic: boolean, isGenerator: boolean, isAsync: boolean): FunctionKind {\n\treturn FUNCTIONS_TYPES[isStatic ? SubFunctionKind.StaticMethod : SubFunctionKind.NonStaticMethod][isGenerator ? 1 : 0][isAsync ? 1 : 0];\n}\n\nexport enum FunctionSyntaxKind {\n\tAnonymousExpression,\n\tNamedExpression,\n\tDeclaration,\n\tAccessorOrMethod,\n\tWrapped,\n\n\tLastFunctionSyntaxKind = Wrapped,\n};\n\n\n\nexport function isArrowFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.ArrowFunction, FunctionKind.AsyncArrowFunction);\n}\n\nexport function isModule(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.Module, FunctionKind.AsyncModule);\n}\n\nexport function isAsyncModule(kind: FunctionKind) {\n\treturn kind == FunctionKind.AsyncModule;\n}\n\nexport function isAsyncGeneratorFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.AsyncConciseGeneratorMethod, FunctionKind.AsyncGeneratorFunction);\n}\n\nexport function isGeneratorFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.AsyncConciseGeneratorMethod, FunctionKind.StaticConciseGeneratorMethod);\n}\n\nexport function isAsyncFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.AsyncArrowFunction, FunctionKind.AsyncGeneratorFunction);\n}\n\nexport function isResumableFunction(kind: FunctionKind) {\n\treturn isGeneratorFunction(kind) || isAsyncFunction(kind) || isModule(kind);\n}\n\nexport function isConciseMethod(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.AsyncConciseMethod, FunctionKind.StaticAsyncConciseGeneratorMethod)\n\t\t|| isInRange(kind, FunctionKind.ConciseGeneratorMethod, FunctionKind.ClassStaticInitializerFunction);\n}\n\nexport function isStrictFunctionWithoutPrototype(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.GetterFunction, FunctionKind.AsyncArrowFunction)\n\t\t|| isInRange(kind, FunctionKind.AsyncConciseMethod, FunctionKind.StaticAsyncConciseGeneratorMethod)\n\t\t|| isInRange(kind, FunctionKind.ConciseGeneratorMethod, FunctionKind.ClassStaticInitializerFunction);\n}\n\nexport function isGetterFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.GetterFunction, FunctionKind.StaticGetterFunction);\n}\n\nexport function isSetterFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.SetterFunction, FunctionKind.StaticSetterFunction);\n}\n\nexport function isAccessorFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.GetterFunction, FunctionKind.StaticSetterFunction);\n}\n\nexport function isDefaultConstructor(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.DefaultBaseConstructor, FunctionKind.DefaultDerivedConstructor);\n}\n\nexport function isBaseConstructor(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.BaseConstructor, FunctionKind.DefaultBaseConstructor);\n}\n\nexport function isDerivedConstructor(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.DefaultDerivedConstructor, FunctionKind.DerivedConstructor);\n}\n\nexport function isClassConstructor(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.BaseConstructor, FunctionKind.DerivedConstructor);\n}\n\nexport function isClassMembersInitializerFunction(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.ClassMembersInitializerFunction, FunctionKind.ClassStaticInitializerFunction);\n}\n\nexport function isConstructable(kind: FunctionKind) {\n\treturn isInRange(kind, FunctionKind.NormalFunction, FunctionKind.DerivedConstructor);\n}\n\nexport function isStatic(kind: FunctionKind) {\n\tswitch (kind) {\n\t\tcase FunctionKind.StaticGetterFunction:\n\t\tcase FunctionKind.StaticSetterFunction:\n\t\tcase FunctionKind.StaticConciseMethod:\n\t\tcase FunctionKind.StaticConciseGeneratorMethod:\n\t\tcase FunctionKind.StaticAsyncConciseMethod:\n\t\tcase FunctionKind.StaticAsyncConciseGeneratorMethod:\n\t\tcase FunctionKind.ClassStaticInitializerFunction:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport function bindsSuper(kind: FunctionKind) {\n\treturn isConciseMethod(kind) || isAccessorFunction(kind) || isClassConstructor(kind);\n}\n\nexport function isAwaitAsIdentifierDisallowed(kind: FunctionKind) {\n\t// 'await' is always disallowed as an identifier in module contexts. Callers\n\t// should short-circuit the module case instead of calling this.\n\treturn !isModule(kind) && (isAsyncFunction(kind) || kind == FunctionKind.ClassStaticInitializerFunction);\n}\n\nexport function functionKind2String(kind: FunctionKind): string {\n\treturn FunctionKind[kind];\n}\n\nexport type ClassInfo = {\n\textends?: ExpressionNode;\n\tpublicMembers: (MethodDefinition | PropertyDefinition)[],\n\tprivateMembers: (MethodDefinition | PropertyDefinition)[],\n\tstaticElements: (MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock)[],\n\tinstanceFields: (MethodDefinition | PropertyDefinition | AccessorProperty)[],\n\tconstructor: MethodDefinition | undefined,\n\n\thasSeenConstructor: boolean;\n\thasStaticComputedNames: boolean;\n\thasStaticElements: boolean;\n\thasStaticPrivateMethods: boolean;\n\thasStaticBlocks: boolean;\n\thasInstanceMembers: boolean;\n\trequiresBrand: boolean;\n\tisAnonymous: boolean;\n\thasPrivateMethods: boolean,\n\n\tcomputedFieldCount: number;\n\n\thomeObjectVariable?: VariableDeclarator;\n\tstaticHomeObjectVariable?: VariableDeclarator;\n};\n\nexport function createClassInfo(): ClassInfo {\n\treturn {\n\t\tpublicMembers: [],\n\t\tprivateMembers: [],\n\t\tstaticElements: [],\n\t\tinstanceFields: [],\n\t\t'constructor': undefined,\n\n\t\thasSeenConstructor: false,\n\t\thasStaticComputedNames: false,\n\t\thasStaticElements: false,\n\t\thasStaticPrivateMethods: false,\n\t\thasStaticBlocks: false,\n\t\thasInstanceMembers: false,\n\t\trequiresBrand: false,\n\t\tisAnonymous: false,\n\t\thasPrivateMethods: false,\n\n\t\tcomputedFieldCount: 0,\n\t};\n}\n\nexport enum FunctionNameValidity {\n\tFunctionNameIsStrictReserved = 'FunctionNameIsStrictReserved',\n\tSkipFunctionNameCheck = 'SkipFunctionNameCheck',\n\tFunctionNameValidityUnknown = 'FunctionNameValidityUnknown'\n};\n\nexport enum ObjectLiteralPropertyKind {\n\tCONSTANT = 'CONSTANT',\t// Property with constant value (compile time).\n\tCOMPUTED = 'COMPUTED',\t// Property with computed value (execution time).\n\tMATERIALIZED_LITERAL = 'MATERIALIZED_LITERAL', // Property value is a materialized literal.\n\tGETTER = 'GETTER',\n\tSETTER = 'SETTER',\t\t// Property is an accessor function.\n\tPROTOTYPE = 'PROTOTYPE',\t// Property is __proto__.\n\tSPREAD = 'SPREAD'\n}\nexport class ObjectLiteralProperty {\n\tstatic Kind = ObjectLiteralPropertyKind;\n}\n\nexport enum ClassLiteralPropertyKind {\n\tMETHOD = 'METHOD',\n\tGETTER = 'GETTER',\n\tSETTER = 'SETTER',\n\tFIELD = 'FIELD'\n}\n\nexport class ClassLiteralProperty {\n\tstatic Kind = ClassLiteralPropertyKind;\n}\n\nexport function classPropertyKindFor(kind: PropertyKind): ClassLiteralPropertyKind {\n\tswitch (kind) {\n\t\tcase PropertyKind.AccessorGetter:\n\t\t\treturn ClassLiteralPropertyKind.GETTER;\n\t\tcase PropertyKind.AccessorSetter:\n\t\t\treturn ClassLiteralPropertyKind.SETTER;\n\t\tcase PropertyKind.Method:\n\t\t\treturn ClassLiteralPropertyKind.METHOD;\n\t\tcase PropertyKind.ClassField:\n\t\t\treturn ClassLiteralPropertyKind.FIELD;\n\t}\n\tthrow new Error(`unexpected property kind: ${kind}`);\n}\n\nexport enum VariableMode {\n\tConst = 'Const',\n\tPrivateMethod = 'PrivateMethod',\n\tPrivateGetterOnly = 'PrivateGetterOnly',\n\tPrivateSetterOnly = 'PrivateSetterOnly'\n}\n\nexport function getVariableMode(kind: ClassLiteralPropertyKind): VariableMode {\n\tswitch (kind) {\n\t\tcase ClassLiteralPropertyKind.FIELD:\n\t\t\treturn VariableMode.Const;\n\t\tcase ClassLiteralPropertyKind.METHOD:\n\t\t\treturn VariableMode.PrivateMethod;\n\t\tcase ClassLiteralPropertyKind.GETTER:\n\t\t\treturn VariableMode.PrivateGetterOnly;\n\t\tcase ClassLiteralPropertyKind.SETTER:\n\t\t\treturn VariableMode.PrivateSetterOnly;\n\t}\n}\n\nexport enum VariableDeclarationContext {\n\tStatementListItem,\n\tStatement,\n\tForStatement\n};\n\nexport enum AllowLabelledFunctionStatement {\n\tAllowLabelledFunctionStatement,\n\tDisallowLabelledFunctionStatement,\n};\n"]}