@ibyar/expressions 0.5.1 → 0.5.6

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 (187) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -4
  3. package/api/abstract.d.ts +5 -6
  4. package/api/abstract.js +3 -3
  5. package/api/abstract.js.map +1 -1
  6. package/api/class/class.d.ts +202 -0
  7. package/api/class/class.js +635 -0
  8. package/api/class/class.js.map +1 -0
  9. package/api/class/decorator.d.ts +20 -0
  10. package/api/class/decorator.js +48 -0
  11. package/api/class/decorator.js.map +1 -0
  12. package/api/computing/call.d.ts +3 -1
  13. package/api/computing/call.js +16 -4
  14. package/api/computing/call.js.map +1 -1
  15. package/api/computing/debugger.d.ts +15 -0
  16. package/api/computing/debugger.js +35 -0
  17. package/api/computing/debugger.js.map +1 -0
  18. package/api/computing/new.d.ts +2 -1
  19. package/api/computing/new.js +4 -0
  20. package/api/computing/new.js.map +1 -1
  21. package/api/computing/rest.d.ts +6 -6
  22. package/api/computing/rest.js +5 -2
  23. package/api/computing/rest.js.map +1 -1
  24. package/api/computing/return.d.ts +2 -1
  25. package/api/computing/return.js +3 -0
  26. package/api/computing/return.js.map +1 -1
  27. package/api/computing/spread.d.ts +2 -1
  28. package/api/computing/spread.js +5 -2
  29. package/api/computing/spread.js.map +1 -1
  30. package/api/computing/throw.d.ts +2 -1
  31. package/api/computing/throw.js +3 -0
  32. package/api/computing/throw.js.map +1 -1
  33. package/api/computing/yield.d.ts +2 -1
  34. package/api/computing/yield.js +3 -0
  35. package/api/computing/yield.js.map +1 -1
  36. package/api/definition/array.d.ts +12 -12
  37. package/api/definition/array.js +31 -25
  38. package/api/definition/array.js.map +1 -1
  39. package/api/definition/bind.d.ts +2 -2
  40. package/api/definition/bind.js +1 -1
  41. package/api/definition/bind.js.map +1 -1
  42. package/api/definition/function.d.ts +40 -51
  43. package/api/definition/function.js +291 -309
  44. package/api/definition/function.js.map +1 -1
  45. package/api/definition/member.d.ts +2 -2
  46. package/api/definition/member.js +1 -1
  47. package/api/definition/member.js.map +1 -1
  48. package/api/definition/object.d.ts +15 -12
  49. package/api/definition/object.js +43 -13
  50. package/api/definition/object.js.map +1 -1
  51. package/api/definition/statement.d.ts +2 -2
  52. package/api/definition/statement.js +7 -3
  53. package/api/definition/statement.js.map +1 -1
  54. package/api/definition/values.d.ts +35 -50
  55. package/api/definition/values.js +66 -149
  56. package/api/definition/values.js.map +1 -1
  57. package/api/deserialize/deserialize.d.ts +2 -1
  58. package/api/deserialize/deserialize.js +4 -1
  59. package/api/deserialize/deserialize.js.map +1 -1
  60. package/api/deserialize/type-store.d.ts +2 -2
  61. package/api/deserialize/type-store.js.map +1 -1
  62. package/api/expression.d.ts +13 -18
  63. package/api/expression.js.map +1 -1
  64. package/api/index.d.ts +2 -0
  65. package/api/index.js +2 -0
  66. package/api/index.js.map +1 -1
  67. package/api/module/common.d.ts +29 -0
  68. package/api/module/common.js +71 -0
  69. package/api/module/common.js.map +1 -0
  70. package/api/module/export.d.ts +66 -25
  71. package/api/module/export.js +270 -58
  72. package/api/module/export.js.map +1 -1
  73. package/api/module/import.d.ts +61 -25
  74. package/api/module/import.js +226 -68
  75. package/api/module/import.js.map +1 -1
  76. package/api/operators/assignment.d.ts +2 -2
  77. package/api/operators/assignment.js +1 -1
  78. package/api/operators/assignment.js.map +1 -1
  79. package/api/operators/await.d.ts +2 -2
  80. package/api/operators/await.js +1 -1
  81. package/api/operators/await.js.map +1 -1
  82. package/api/operators/binary.d.ts +2 -2
  83. package/api/operators/binary.js +1 -1
  84. package/api/operators/binary.js.map +1 -1
  85. package/api/operators/chaining.d.ts +2 -2
  86. package/api/operators/chaining.js +1 -1
  87. package/api/operators/chaining.js.map +1 -1
  88. package/api/operators/comma.d.ts +2 -2
  89. package/api/operators/comma.js +2 -2
  90. package/api/operators/comma.js.map +1 -1
  91. package/api/operators/grouping.d.ts +2 -2
  92. package/api/operators/grouping.js +1 -1
  93. package/api/operators/grouping.js.map +1 -1
  94. package/api/operators/logical.d.ts +2 -2
  95. package/api/operators/logical.js +1 -1
  96. package/api/operators/logical.js.map +1 -1
  97. package/api/operators/pipeline.d.ts +2 -2
  98. package/api/operators/pipeline.js +1 -1
  99. package/api/operators/pipeline.js.map +1 -1
  100. package/api/operators/ternary.d.ts +2 -2
  101. package/api/operators/ternary.js +1 -1
  102. package/api/operators/ternary.js.map +1 -1
  103. package/api/operators/unary.d.ts +3 -3
  104. package/api/operators/unary.js +4 -3
  105. package/api/operators/unary.js.map +1 -1
  106. package/api/operators/update.d.ts +2 -2
  107. package/api/operators/update.js +1 -1
  108. package/api/operators/update.js.map +1 -1
  109. package/api/{app/program.d.ts → program.d.ts} +8 -9
  110. package/api/program.js +45 -0
  111. package/api/program.js.map +1 -0
  112. package/api/statement/control/block.d.ts +4 -5
  113. package/api/statement/control/block.js +22 -23
  114. package/api/statement/control/block.js.map +1 -1
  115. package/api/statement/control/empty.d.ts +1 -1
  116. package/api/statement/control/empty.js.map +1 -1
  117. package/api/statement/control/if.d.ts +2 -2
  118. package/api/statement/control/if.js +1 -1
  119. package/api/statement/control/if.js.map +1 -1
  120. package/api/statement/control/switch.d.ts +4 -5
  121. package/api/statement/control/switch.js +13 -9
  122. package/api/statement/control/switch.js.map +1 -1
  123. package/api/statement/control/terminate.d.ts +38 -13
  124. package/api/statement/control/terminate.js +81 -20
  125. package/api/statement/control/terminate.js.map +1 -1
  126. package/api/statement/declarations/declares.d.ts +17 -16
  127. package/api/statement/declarations/declares.js +24 -19
  128. package/api/statement/declarations/declares.js.map +1 -1
  129. package/api/statement/iterations/for.d.ts +5 -5
  130. package/api/statement/iterations/for.js +29 -23
  131. package/api/statement/iterations/for.js.map +1 -1
  132. package/api/statement/iterations/while.d.ts +3 -3
  133. package/api/statement/iterations/while.js +17 -13
  134. package/api/statement/iterations/while.js.map +1 -1
  135. package/api/utils.d.ts +5 -0
  136. package/api/utils.js +4 -0
  137. package/api/utils.js.map +1 -0
  138. package/package.json +5 -5
  139. package/scope/event.d.ts +2 -2
  140. package/scope/event.js +8 -14
  141. package/scope/event.js.map +1 -1
  142. package/scope/finalizer.d.ts +4 -0
  143. package/scope/finalizer.js +11 -0
  144. package/scope/finalizer.js.map +1 -0
  145. package/scope/proxy.d.ts +2 -3
  146. package/scope/proxy.js +22 -26
  147. package/scope/proxy.js.map +1 -1
  148. package/scope/scope.d.ts +42 -53
  149. package/scope/scope.js +73 -143
  150. package/scope/scope.js.map +1 -1
  151. package/scope/stack.d.ts +43 -26
  152. package/scope/stack.js +148 -102
  153. package/scope/stack.js.map +1 -1
  154. package/v8/enums.d.ts +204 -0
  155. package/v8/enums.js +375 -0
  156. package/v8/enums.js.map +1 -0
  157. package/v8/index.d.ts +2 -1
  158. package/v8/index.js +2 -1
  159. package/v8/index.js.map +1 -1
  160. package/v8/inline.d.ts +177 -0
  161. package/v8/inline.js +1973 -0
  162. package/v8/inline.js.map +1 -0
  163. package/v8/nodes.d.ts +8 -7
  164. package/v8/nodes.js +37 -63
  165. package/v8/nodes.js.map +1 -1
  166. package/v8/parser.d.ts +41 -151
  167. package/v8/parser.js +507 -1578
  168. package/v8/parser.js.map +1 -1
  169. package/v8/stream.d.ts +35 -3
  170. package/v8/stream.js +616 -164
  171. package/v8/stream.js.map +1 -1
  172. package/v8/token.d.ts +15 -9
  173. package/v8/token.js +79 -46
  174. package/v8/token.js.map +1 -1
  175. package/visit/visitor.js +4 -7
  176. package/visit/visitor.js.map +1 -1
  177. package/api/app/class.d.ts +0 -117
  178. package/api/app/class.js +0 -292
  179. package/api/app/class.js.map +0 -1
  180. package/api/app/program.js +0 -39
  181. package/api/app/program.js.map +0 -1
  182. package/api/module/module.d.ts +0 -26
  183. package/api/module/module.js +0 -63
  184. package/api/module/module.js.map +0 -1
  185. package/v8/app.d.ts +0 -0
  186. package/v8/app.js +0 -2
  187. package/v8/app.js.map +0 -1
package/scope/event.js CHANGED
@@ -1,41 +1,35 @@
1
1
  import { ReactiveScope } from './scope.js';
2
- function visitInnerScope(eventNames, events, scope, scopeMap) {
2
+ function visitInnerScope(eventNames, events, scope, scopeTuples) {
3
3
  eventNames.forEach(eventName => {
4
4
  if (eventName.startsWith(':')) {
5
5
  return;
6
6
  }
7
- scopeMap.set(eventName, scope);
7
+ scopeTuples.push([eventName, scope]);
8
8
  const nextEvents = Object.keys(events[eventName]);
9
9
  if (!nextEvents.length) {
10
10
  return;
11
11
  }
12
12
  const innerScope = scope.getScopeOrCreat(eventName);
13
- visitInnerScope(nextEvents, events[eventName], innerScope, scopeMap);
13
+ visitInnerScope(nextEvents, events[eventName], innerScope, scopeTuples);
14
14
  });
15
15
  }
16
16
  export function findScopeByEventMap(events, stack) {
17
- const scopeMap = new Map();
17
+ const scopeTuples = [];
18
18
  const rootEventNames = Object.keys(events);
19
19
  rootEventNames.forEach(eventName => {
20
20
  const scope = stack.findScope(eventName);
21
- scopeMap.set(eventName, scope);
21
+ scopeTuples.push([eventName, scope]);
22
22
  const nextEvents = Object.keys(events[eventName]);
23
23
  if (!nextEvents.length) {
24
24
  return;
25
25
  }
26
26
  const eventScope = scope.getScopeOrCreat(eventName);
27
- visitInnerScope(nextEvents, events[eventName], eventScope, scopeMap);
27
+ visitInnerScope(nextEvents, events[eventName], eventScope, scopeTuples);
28
28
  });
29
- return scopeMap;
29
+ return scopeTuples;
30
30
  }
31
31
  export function findReactiveScopeByEventMap(events, stack) {
32
32
  const allScopes = findScopeByEventMap(events, stack);
33
- const scopeMap = new Map();
34
- allScopes.forEach((scope, eventName) => {
35
- if (scope instanceof ReactiveScope) {
36
- scopeMap.set(eventName, scope);
37
- }
38
- });
39
- return scopeMap;
33
+ return allScopes.filter(tuple => tuple[1] instanceof ReactiveScope);
40
34
  }
41
35
  //# sourceMappingURL=event.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/expressions/scope/event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAuB,MAAM,YAAY,CAA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C,CAAC;IACtE,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAA0B,EAAE,KAAY;IACnF,MAAM,SAAS,GAAG,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAErD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAuC,CAAC;IAChE,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACtC,IAAI,KAAK,YAAY,aAAa,EAAE;YACnC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SAC/B;IACF,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import { ExpressionEventMap } from '../api/expression.js';\nimport { ReactiveScope, Scope, ScopeContext } from './scope.js';\nimport { Stack } from './stack.js';\n\nfunction visitInnerScope(eventNames: string[], events: ExpressionEventMap, scope: Scope<ScopeContext>, scopeMap: Map<string, Scope<object>>) {\n\teventNames.forEach(eventName => {\n\t\tif (eventName.startsWith(':')) {\n\t\t\treturn;\n\t\t}\n\t\tscopeMap.set(eventName, scope);\n\t\tconst nextEvents = Object.keys(events[eventName]);\n\t\tif (!nextEvents.length) {\n\t\t\treturn;\n\t\t}\n\t\tconst innerScope = scope.getScopeOrCreat(eventName);\n\t\tvisitInnerScope(nextEvents, events[eventName], innerScope, scopeMap);\n\t});\n}\n\nexport function findScopeByEventMap(events: ExpressionEventMap, stack: Stack): Map<string, Scope<ScopeContext>> {\n\tconst scopeMap = new Map<string, Scope<object>>();\n\tconst rootEventNames = Object.keys(events);\n\trootEventNames.forEach(eventName => {\n\t\tconst scope = stack.findScope<ScopeContext>(eventName);\n\t\tscopeMap.set(eventName, scope);\n\t\tconst nextEvents = Object.keys(events[eventName]);\n\t\tif (!nextEvents.length) {\n\t\t\treturn;\n\t\t}\n\t\tconst eventScope = scope.getScopeOrCreat<ScopeContext>(eventName);\n\t\tvisitInnerScope(nextEvents, events[eventName], eventScope, scopeMap);\n\t});\n\treturn scopeMap;\n}\n\nexport function findReactiveScopeByEventMap(events: ExpressionEventMap, stack: Stack): Map<string, ReactiveScope<ScopeContext>> {\n\tconst allScopes = findScopeByEventMap(events, stack);\n\n\tconst scopeMap = new Map<string, ReactiveScope<ScopeContext>>();\n\tallScopes.forEach((scope, eventName) => {\n\t\tif (scope instanceof ReactiveScope) {\n\t\t\tscopeMap.set(eventName, scope);\n\t\t}\n\t});\n\treturn scopeMap;\n}\n"]}
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/expressions/scope/event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAuB,MAAM,YAAY,CAAC;AAGhE,SAAS,eAAe,CAAC,UAAoB,EAAE,MAA0B,EAAE,KAA0B,EAAE,WAA4C;IAClJ,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC9B,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC9B,OAAO;SACP;QACD,WAAW,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QACrC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YACvB,OAAO;SACP;QACD,MAAM,UAAU,GAAG,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACpD,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAA0B,EAAE,KAAY;IAC3E,MAAM,WAAW,GAAoC,EAAE,CAAC;IACxD,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAClC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAe,SAAS,CAAC,CAAC;QACvD,WAAW,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QACrC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YACvB,OAAO;SACP;QACD,MAAM,UAAU,GAAG,KAAK,CAAC,eAAe,CAAe,SAAS,CAAC,CAAC;QAClE,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAA0B,EAAE,KAAY;IACnF,MAAM,SAAS,GAAG,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrD,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,aAAa,CAA4C,CAAC;AAChH,CAAC","sourcesContent":["import { ExpressionEventMap } from '../api/expression.js';\nimport { ReactiveScope, Scope, ScopeContext } from './scope.js';\nimport { Stack } from './stack.js';\n\nfunction visitInnerScope(eventNames: string[], events: ExpressionEventMap, scope: Scope<ScopeContext>, scopeTuples: [string, Scope<ScopeContext>][]) {\n\teventNames.forEach(eventName => {\n\t\tif (eventName.startsWith(':')) {\n\t\t\treturn;\n\t\t}\n\t\tscopeTuples.push([eventName, scope]);\n\t\tconst nextEvents = Object.keys(events[eventName]);\n\t\tif (!nextEvents.length) {\n\t\t\treturn;\n\t\t}\n\t\tconst innerScope = scope.getScopeOrCreat(eventName);\n\t\tvisitInnerScope(nextEvents, events[eventName], innerScope, scopeTuples);\n\t});\n}\n\nexport function findScopeByEventMap(events: ExpressionEventMap, stack: Stack): [string, Scope<ScopeContext>][] {\n\tconst scopeTuples: [string, Scope<ScopeContext>][] = [];\n\tconst rootEventNames = Object.keys(events);\n\trootEventNames.forEach(eventName => {\n\t\tconst scope = stack.findScope<ScopeContext>(eventName);\n\t\tscopeTuples.push([eventName, scope]);\n\t\tconst nextEvents = Object.keys(events[eventName]);\n\t\tif (!nextEvents.length) {\n\t\t\treturn;\n\t\t}\n\t\tconst eventScope = scope.getScopeOrCreat<ScopeContext>(eventName);\n\t\tvisitInnerScope(nextEvents, events[eventName], eventScope, scopeTuples);\n\t});\n\treturn scopeTuples;\n}\n\nexport function findReactiveScopeByEventMap(events: ExpressionEventMap, stack: Stack): [string, ReactiveScope<ScopeContext>][] {\n\tconst allScopes = findScopeByEventMap(events, stack);\n\treturn allScopes.filter(tuple => tuple[1] instanceof ReactiveScope) as [string, ReactiveScope<ScopeContext>][];\n}\n"]}
@@ -0,0 +1,4 @@
1
+ declare type Actions = (() => void)[];
2
+ export declare function finalizerRegister(target: object, actions: Actions, unregisterToken?: object): void;
3
+ export declare function finalizerUnregister(unregisterToken: object): void;
4
+ export {};
@@ -0,0 +1,11 @@
1
+ const actionsFinalizer = !FinalizationRegistry ? undefined : new FinalizationRegistry(actions => actions.forEach(action => { try {
2
+ action();
3
+ }
4
+ catch (e) { } }));
5
+ export function finalizerRegister(target, actions, unregisterToken) {
6
+ actionsFinalizer?.register(target, actions, unregisterToken);
7
+ }
8
+ export function finalizerUnregister(unregisterToken) {
9
+ actionsFinalizer?.unregister(unregisterToken);
10
+ }
11
+ //# sourceMappingURL=finalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"finalizer.js","sourceRoot":"","sources":["../../../src/expressions/scope/finalizer.ts"],"names":[],"mappings":"AACA,MAAM,gBAAgB,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,oBAAoB,CACpF,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI;IAAE,MAAM,EAAE,CAAC;CAAE;AAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CACzE,CAAC;AAGF,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,OAAgB,EAAE,eAAwB;IAC3F,gBAAgB,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;AAC9D,CAAC;AAGD,MAAM,UAAU,mBAAmB,CAAC,eAAuB;IAC1D,gBAAgB,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["type Actions = (() => void)[];\nconst actionsFinalizer = !FinalizationRegistry ? undefined : new FinalizationRegistry<Actions>(\n\tactions => actions.forEach(action => { try { action(); } catch (e) { } })\n);\n\n\nexport function finalizerRegister(target: object, actions: Actions, unregisterToken?: object): void {\n\tactionsFinalizer?.register(target, actions, unregisterToken);\n}\n\n\nexport function finalizerUnregister(unregisterToken: object): void {\n\tactionsFinalizer?.unregister(unregisterToken);\n}\n"]}
package/scope/proxy.d.ts CHANGED
@@ -2,12 +2,11 @@ import type { Scope, ScopeContext } from './scope.js';
2
2
  export declare class FunctionProxyHandler<T extends Function> implements ProxyHandler<T> {
3
3
  private thisContext;
4
4
  constructor(thisContext: object);
5
- apply(targetFunc: T, ignoreThisArg: any, argArray: any[]): any;
5
+ apply(targetFunc: T, targetThisArg: any, argArray: any[]): any;
6
+ private computeThisArg;
6
7
  }
7
8
  export declare class ScopeProxyHandler<T extends ScopeContext> implements ProxyHandler<ScopeContext> {
8
9
  private scope;
9
- private proxyMap;
10
- private proxyValueMap;
11
10
  private functionHandler;
12
11
  constructor(scope: Scope<T>);
13
12
  has(model: T, propertyKey: PropertyKey): boolean;
package/scope/proxy.js CHANGED
@@ -2,57 +2,53 @@ export class FunctionProxyHandler {
2
2
  constructor(thisContext) {
3
3
  this.thisContext = thisContext;
4
4
  }
5
- apply(targetFunc, ignoreThisArg, argArray) {
6
- return targetFunc.apply(this.thisContext, argArray);
5
+ apply(targetFunc, targetThisArg, argArray) {
6
+ return targetFunc.apply(this.computeThisArg(targetThisArg), argArray);
7
+ }
8
+ computeThisArg(targetThisArg) {
9
+ switch (true) {
10
+ case this.thisContext instanceof Map:
11
+ case this.thisContext instanceof Set:
12
+ case this.thisContext instanceof Date:
13
+ case this.thisContext instanceof WeakMap:
14
+ case this.thisContext instanceof WeakSet:
15
+ case this.thisContext instanceof Promise:
16
+ case this.thisContext instanceof HTMLElement:
17
+ return this.thisContext;
18
+ default:
19
+ return targetThisArg;
20
+ }
7
21
  }
8
22
  }
9
23
  export class ScopeProxyHandler {
10
24
  constructor(scope) {
11
25
  this.scope = scope;
12
- this.proxyMap = new Map();
13
- this.proxyValueMap = new WeakMap();
14
26
  }
15
27
  has(model, propertyKey) {
16
28
  return this.scope.has(propertyKey);
17
29
  }
18
30
  get(model, propertyKey, receiver) {
19
- if (this.proxyMap.has(propertyKey)) {
20
- return this.proxyMap.get(propertyKey);
21
- }
22
31
  const value = this.scope.get(propertyKey);
32
+ if (value == null) {
33
+ return value;
34
+ }
23
35
  if (typeof value === 'object') {
24
36
  const scope = this.scope.getScope(propertyKey);
25
37
  if (scope) {
26
- const proxy = new Proxy(value, new ScopeProxyHandler(scope));
27
- this.proxyMap.set(propertyKey, proxy);
28
- this.proxyValueMap.set(proxy, value);
29
- return proxy;
38
+ return new Proxy(value, new ScopeProxyHandler(scope));
30
39
  }
31
40
  }
32
41
  else if (typeof value === 'function') {
33
- const proxy = new Proxy(value, this.functionHandler
42
+ return new Proxy(value, this.functionHandler
34
43
  ?? (this.functionHandler = new FunctionProxyHandler(this.scope.getContext())));
35
- this.proxyMap.set(propertyKey, proxy);
36
- this.proxyValueMap.set(proxy, value);
37
- return proxy;
38
44
  }
39
45
  return value;
40
46
  }
41
47
  set(model, propertyKey, value, receiver) {
42
- if ((typeof value === 'object' || typeof value === 'function') && this.proxyValueMap.has(value)) {
43
- value = this.proxyValueMap.get(value);
44
- }
45
48
  return this.scope.set(propertyKey, value);
46
49
  }
47
50
  deleteProperty(model, propertyKey) {
48
- const isDelete = Reflect.deleteProperty(model, propertyKey);
49
- if (isDelete) {
50
- this.scope.set(propertyKey, undefined);
51
- if (this.proxyMap.has(propertyKey)) {
52
- this.proxyMap.delete(propertyKey);
53
- }
54
- }
55
- return isDelete;
51
+ return this.scope.delete(propertyKey);
56
52
  }
57
53
  }
58
54
  export function createRevocableProxyForContext(context, scope) {
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/expressions/scope/proxy.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,oBAAoB;IAChC,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;IAAI,CAAC;IAC5C,KAAK,CAAC,UAAa,EAAE,aAAkB,EAAE,QAAe;QACvD,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;CACD;AAKD,MAAM,OAAO,iBAAiB;IAI7B,YAAoB,KAAe;QAAf,UAAK,GAAL,KAAK,CAAU;QAH3B,aAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;QACrC,kBAAa,GAAG,IAAI,OAAO,EAAkB,CAAC;IAEf,CAAC;IACxC,GAAG,CAAC,KAAQ,EAAE,WAAwB;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;IACD,GAAG,CAAC,KAAQ,EAAE,WAAwB,EAAE,QAAa;QACpD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;SACtC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC1C,IAAI,OAAO,KA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,CAAC,KAAQ,EAAE,WAA4B;QACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC5D,IAAI,QAAQ,EAAE;YACb,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;YACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;gBACnC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;aAClC;SACD;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AAOD,MAAM,UAAU,8BAA8B,CAAmB,OAAU,EAAE,KAAe;IAC3F,OAAO,KAAK,CAAC,SAAS,CAAI,OAAO,EAAE,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAmB,KAAe;IACtE,OAAO,IAAI,KAAK,CAAI,KAAK,CAAC,UAAU,EAAE,EAAE,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type { Scope, ScopeContext } from './scope.js';\n\nexport class FunctionProxyHandler<T extends Function> implements ProxyHandler<T> {\n\tconstructor(private thisContext: object) { }\n\tapply(targetFunc: T, ignoreThisArg: any, argArray: any[]): any {\n\t\treturn targetFunc.apply(this.thisContext, argArray);\n\t}\n}\n\n/**\n * crete new proxy handler object as scoped context\n */\nexport class ScopeProxyHandler<T extends ScopeContext> implements ProxyHandler<ScopeContext> {\n\tprivate proxyMap = new Map<PropertyKey, T>();\n\tprivate proxyValueMap = new WeakMap<object, object>();\n\tprivate functionHandler: FunctionProxyHandler<Function>;\n\tconstructor(private scope: Scope<T>) { }\n\thas(model: T, propertyKey: PropertyKey): boolean {\n\t\treturn this.scope.has(propertyKey);\n\t}\n\tget(model: T, propertyKey: PropertyKey, receiver: any): any {\n\t\tif (this.proxyMap.has(propertyKey)) {\n\t\t\treturn this.proxyMap.get(propertyKey);\n\t\t}\n\t\tconst value = this.scope.get(propertyKey);\n\t\tif (typeof value === 'object') {\n\t\t\tconst scope = this.scope.getScope(propertyKey);\n\t\t\tif (scope) {\n\t\t\t\tconst proxy = new Proxy(value, new ScopeProxyHandler(scope));\n\t\t\t\tthis.proxyMap.set(propertyKey, proxy);\n\t\t\t\tthis.proxyValueMap.set(proxy, value);\n\t\t\t\treturn proxy;\n\t\t\t}\n\t\t} else if (typeof value === 'function') {\n\t\t\tconst proxy = new Proxy(value, this.functionHandler\n\t\t\t\t?? (this.functionHandler = new FunctionProxyHandler(this.scope.getContext()))\n\t\t\t);\n\t\t\tthis.proxyMap.set(propertyKey, proxy);\n\t\t\tthis.proxyValueMap.set(proxy, value);\n\t\t\treturn proxy;\n\t\t}\n\t\treturn value;\n\t}\n\tset(model: T, propertyKey: PropertyKey, value: any, receiver: any): boolean {\n\t\tif ((typeof value === 'object' || typeof value === 'function') && this.proxyValueMap.has(value)) {\n\t\t\tvalue = this.proxyValueMap.get(value);\n\t\t}\n\t\treturn this.scope.set(propertyKey, value);\n\t}\n\tdeleteProperty(model: T, propertyKey: string | symbol): boolean {\n\t\tconst isDelete = Reflect.deleteProperty(model, propertyKey);\n\t\tif (isDelete) {\n\t\t\tthis.scope.set(propertyKey, undefined);\n\t\t\tif (this.proxyMap.has(propertyKey)) {\n\t\t\t\tthis.proxyMap.delete(propertyKey);\n\t\t\t}\n\t\t}\n\t\treturn isDelete;\n\t}\n}\n\nexport type RevocableProxy<T> = {\n\tproxy: T;\n\trevoke: () => void;\n};\n\nexport function createRevocableProxyForContext<T extends object>(context: T, scope: Scope<T>): RevocableProxy<T> {\n\treturn Proxy.revocable<T>(context, new ScopeProxyHandler(scope));\n}\n\nexport function createProxyForContext<T extends object>(scope: Scope<T>): T {\n\treturn new Proxy<T>(scope.getContext(), new ScopeProxyHandler(scope));\n}\n"]}
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/express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KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC/C,IAAI,KAAK,EAAE;gBACV,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;aACtD;SACD;aAAM,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YACvC,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe;mBACxC,CAAC,IAAI,CAAC,eAAe,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAC7E,CAAC;SACF;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,GAAG,CAAC,KAAQ,EAAE,WAAwB,EAAE,KAAU,EAAE,QAAa;QAChE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,cAAc,CAAC,KAAQ,EAAE,WAA4B;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;CACD;AAOD,MAAM,UAAU,8BAA8B,CAAmB,OAAU,EAAE,KAAe;IAC3F,OAAO,KAAK,CAAC,SAAS,CAAI,OAAO,EAAE,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAmB,KAAe;IACtE,OAAO,IAAI,KAAK,CAAI,KAAK,CAAC,UAAU,EAAE,EAAE,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type { Scope, ScopeContext } from './scope.js';\n\nexport class FunctionProxyHandler<T extends Function> implements ProxyHandler<T> {\n\tconstructor(private thisContext: object) { }\n\tapply(targetFunc: T, targetThisArg: any, argArray: any[]): any {\n\t\treturn targetFunc.apply(this.computeThisArg(targetThisArg), argArray);\n\t}\n\n\tprivate computeThisArg(targetThisArg: any): any {\n\t\tswitch (true) {\n\t\t\t// exclude classes that have binding hook\n\t\t\tcase this.thisContext instanceof Map:\n\t\t\tcase this.thisContext instanceof Set:\n\t\t\tcase this.thisContext instanceof Date:\n\t\t\tcase this.thisContext instanceof WeakMap:\n\t\t\tcase this.thisContext instanceof WeakSet:\n\t\t\tcase this.thisContext instanceof Promise:\n\t\t\tcase this.thisContext instanceof HTMLElement:\n\t\t\t\treturn this.thisContext;\n\t\t\tdefault:\n\t\t\t\treturn targetThisArg;\n\t\t}\n\t}\n}\n\n/**\n * crete new proxy handler object as scoped context\n */\nexport class ScopeProxyHandler<T extends ScopeContext> implements ProxyHandler<ScopeContext> {\n\tprivate functionHandler: FunctionProxyHandler<Function>;\n\tconstructor(private scope: Scope<T>) { }\n\thas(model: T, propertyKey: PropertyKey): boolean {\n\t\treturn this.scope.has(propertyKey);\n\t}\n\tget(model: T, propertyKey: PropertyKey, receiver: any): any {\n\t\tconst value = this.scope.get(propertyKey);\n\t\tif (value == null) {\n\t\t\treturn value;\n\t\t}\n\t\tif (typeof value === 'object') {\n\t\t\tconst scope = this.scope.getScope(propertyKey);\n\t\t\tif (scope) {\n\t\t\t\treturn new Proxy(value, new ScopeProxyHandler(scope));\n\t\t\t}\n\t\t} else if (typeof value === 'function') {\n\t\t\treturn new Proxy(value, this.functionHandler\n\t\t\t\t?? (this.functionHandler = new FunctionProxyHandler(this.scope.getContext()))\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t}\n\tset(model: T, propertyKey: PropertyKey, value: any, receiver: any): boolean {\n\t\treturn this.scope.set(propertyKey, value);\n\t}\n\tdeleteProperty(model: T, propertyKey: string | symbol): boolean {\n\t\treturn this.scope.delete(propertyKey);\n\t}\n}\n\nexport type RevocableProxy<T> = {\n\tproxy: T;\n\trevoke: () => void;\n};\n\nexport function createRevocableProxyForContext<T extends object>(context: T, scope: Scope<T>): RevocableProxy<T> {\n\treturn Proxy.revocable<T>(context, new ScopeProxyHandler(scope));\n}\n\nexport function createProxyForContext<T extends object>(scope: Scope<T>): T {\n\treturn new Proxy<T>(scope.getContext(), new ScopeProxyHandler(scope));\n}\n"]}
package/scope/scope.d.ts CHANGED
@@ -1,48 +1,32 @@
1
- export declare type ScopeType = 'block' | 'function' | 'class' | 'module' | 'global';
1
+ import { TypeOf } from '../api/utils.js';
2
2
  export declare type ScopeContext = {
3
3
  [key: PropertyKey]: ScopeContext | any;
4
4
  };
5
5
  export interface Scope<T = ScopeContext> {
6
- type: ScopeType;
7
6
  get(propertyKey: keyof T): any;
8
7
  set(propertyKey: keyof T, value?: any, receiver?: any): boolean;
9
8
  has(propertyKey: keyof T): boolean;
10
9
  delete(propertyKey: keyof T): boolean;
11
10
  getContext(): T;
11
+ getContextProxy?(): T;
12
12
  getScope<V extends ScopeContext>(propertyKey: keyof T): Scope<V> | undefined;
13
13
  getScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): Scope<V>;
14
+ getClass(): TypeOf<Scope<ScopeContext>>;
14
15
  }
15
16
  export declare class Scope<T extends ScopeContext> implements Scope<T> {
16
17
  protected context: T;
17
- type: ScopeType;
18
- static for<T extends ScopeContext>(context: T, type: ScopeType): Scope<T>;
19
- static blockScopeFor<T extends ScopeContext>(context: T): Scope<T>;
20
- static functionScopeFor<T extends ScopeContext>(context: T): Scope<T>;
21
- static classScopeFor<T extends ScopeContext>(context: T): Scope<T>;
22
- static moduleScopeFor<T extends ScopeContext>(context: T): Scope<T>;
23
- static globalScopeFor<T extends ScopeContext>(context: T): Scope<T>;
24
- static blockScope<T extends ScopeContext>(): Scope<T>;
25
- static functionScope<T extends ScopeContext>(): Scope<T>;
26
- static classScope<T extends ScopeContext>(): Scope<T>;
27
- static moduleScope<T extends ScopeContext>(): Scope<T>;
28
- static globalScope<T extends ScopeContext>(): Scope<T>;
18
+ static for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]): Scope<T>;
19
+ static blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]): Scope<T>;
29
20
  protected scopeMap: Map<keyof T, Scope<any>>;
30
- constructor(context: T, type: ScopeType);
21
+ protected propertyKeys?: (keyof T)[];
22
+ constructor(context: T, propertyKeys?: (keyof T)[]);
31
23
  }
32
24
  export declare class ReadOnlyScope<T extends ScopeContext> extends Scope<T> {
33
- static for<T extends ScopeContext>(context: T, type: ScopeType): ReadOnlyScope<T>;
34
- static blockScopeFor<T extends ScopeContext>(context: T): ReadOnlyScope<T>;
35
- static functionScopeFor<T extends ScopeContext>(context: T): ReadOnlyScope<T>;
36
- static classScopeFor<T extends ScopeContext>(context: T): ReadOnlyScope<T>;
37
- static moduleScopeFor<T extends ScopeContext>(context: T): ReadOnlyScope<T>;
38
- static globalScopeFor<T extends ScopeContext>(context: T): ReadOnlyScope<T>;
39
- static blockScope<T extends ScopeContext>(): ReadOnlyScope<T>;
40
- static functionScope<T extends ScopeContext>(): ReadOnlyScope<T>;
41
- static classScope<T extends ScopeContext>(): ReadOnlyScope<T>;
42
- static moduleScope<T extends ScopeContext>(): ReadOnlyScope<T>;
43
- static globalScope<T extends ScopeContext>(): ReadOnlyScope<T>;
25
+ static for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]): ReadOnlyScope<T>;
26
+ static blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]): ReadOnlyScope<T>;
44
27
  set(propertyKey: keyof T, value: any, receiver?: any): boolean;
45
28
  delete(propertyKey: keyof T): boolean;
29
+ getClass(): TypeOf<ReadOnlyScope<ScopeContext>>;
46
30
  }
47
31
  export declare class ScopeSubscription<T> {
48
32
  private propertyKey;
@@ -64,22 +48,13 @@ export declare class ValueChangeObserver<T> {
64
48
  destroy(): void;
65
49
  }
66
50
  export declare class ReactiveScope<T extends ScopeContext> extends Scope<T> {
67
- protected name?: string | undefined;
68
51
  protected parent?: ReactiveScope<any> | undefined;
69
- static for<T extends ScopeContext>(context: T, type: ScopeType): ReactiveScope<T>;
70
- static blockScopeFor<T extends ScopeContext>(context: T): ReactiveScope<T>;
71
- static functionScopeFor<T extends ScopeContext>(context: T): ReactiveScope<T>;
72
- static classScopeFor<T extends ScopeContext>(context: T): ReactiveScope<T>;
73
- static moduleScopeFor<T extends ScopeContext>(context: T): ReactiveScope<T>;
74
- static globalScopeFor<T extends ScopeContext>(context: T): ReactiveScope<T>;
75
- static blockScope<T extends ScopeContext>(): ReactiveScope<T>;
76
- static functionScope<T extends ScopeContext>(): ReactiveScope<T>;
77
- static classScope<T extends ScopeContext>(): ReactiveScope<T>;
78
- static moduleScope<T extends ScopeContext>(): ReactiveScope<T>;
79
- static globalScope<T extends ScopeContext>(): ReactiveScope<T>;
52
+ static for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]): ReactiveScope<T>;
53
+ static blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]): ReactiveScope<T>;
80
54
  protected observer: ValueChangeObserver<T>;
81
- constructor(context: T, type: ScopeType);
82
- constructor(context: T, type: ScopeType, name: string, parent: ReactiveScope<any>);
55
+ protected name?: string;
56
+ constructor(context: T, propertyKeys?: (keyof T)[]);
57
+ constructor(context: T, name: string, parent: ReactiveScope<any>, propertyKeys?: (keyof T)[]);
83
58
  set(propertyKey: keyof T, newValue: any, receiver?: any): boolean;
84
59
  delete(propertyKey: keyof T): boolean;
85
60
  getScope<V extends ScopeContext>(propertyKey: keyof T): ReactiveScope<V> | undefined;
@@ -87,28 +62,42 @@ export declare class ReactiveScope<T extends ScopeContext> extends Scope<T> {
87
62
  emit(propertyKey: keyof T, newValue: any, oldValue?: any): void;
88
63
  subscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T>;
89
64
  unsubscribe(propertyKey?: keyof T, subscription?: ScopeSubscription<T>): void;
65
+ getClass(): TypeOf<ReactiveScope<ScopeContext>>;
90
66
  }
91
67
  export interface ScopeControl<T extends ScopeContext> {
68
+ isAttached(): boolean;
92
69
  detach(): void;
93
70
  reattach(): void;
94
- emitChanges(propertyKey?: keyof T): void;
71
+ emitChanges(propertyKey?: keyof T, propertyValue?: any): void;
95
72
  }
96
73
  export declare class ReactiveScopeControl<T extends ScopeContext> extends ReactiveScope<T> implements ScopeControl<T> {
97
- static for<T extends ScopeContext>(context: T, type: ScopeType): ReactiveScopeControl<T>;
98
- static blockScopeFor<T extends ScopeContext>(context: T): ReactiveScopeControl<T>;
99
- static functionScopeFor<T extends ScopeContext>(context: T): ReactiveScopeControl<T>;
100
- static classScopeFor<T extends ScopeContext>(context: T): ReactiveScopeControl<T>;
101
- static moduleScopeFor<T extends ScopeContext>(context: T): ReactiveScopeControl<T>;
102
- static globalScopeFor<T extends ScopeContext>(context: T): ReactiveScopeControl<T>;
103
- static blockScope<T extends ScopeContext>(): ReactiveScopeControl<T>;
104
- static functionScope<T extends ScopeContext>(): ReactiveScopeControl<T>;
105
- static classScope<T extends ScopeContext>(): ReactiveScopeControl<T>;
106
- static moduleScope<T extends ScopeContext>(): ReactiveScopeControl<T>;
107
- static globalScope<T extends ScopeContext>(): ReactiveScopeControl<T>;
74
+ static for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]): ReactiveScopeControl<T>;
75
+ static blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]): ReactiveScopeControl<T>;
108
76
  protected attached: boolean;
109
77
  protected marked: ScopeContext;
110
78
  emit(propertyKey: keyof T, newValue: any, oldValue?: any): void;
79
+ isAttached(): boolean;
111
80
  detach(): void;
112
81
  reattach(): void;
113
- emitChanges(propertyKey?: keyof T): void;
82
+ emitChanges(propertyKey?: keyof T, propertyValue?: any): void;
83
+ getClass(): TypeOf<ReactiveScopeControl<ScopeContext>>;
114
84
  }
85
+ interface ImportMeta {
86
+ url: URL;
87
+ resolve?(specified: string, parent?: string | URL): Promise<string>;
88
+ }
89
+ export interface ModuleImport {
90
+ meta: ImportMeta;
91
+ }
92
+ export interface ModuleContext extends ScopeContext {
93
+ import: ModuleImport & ((path: string) => Promise<any>);
94
+ }
95
+ export declare class ModuleScope extends ReactiveScope<ModuleContext> {
96
+ constructor(context: ModuleContext, propertyKeys?: (keyof ModuleContext)[]);
97
+ importModule(propertyKey: keyof ModuleContext, scope: ModuleScope): void;
98
+ }
99
+ export declare class WebModuleScope extends ModuleScope {
100
+ constructor();
101
+ updateContext(context: any): void;
102
+ }
103
+ export {};