@ibyar/expressions 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -0
  3. package/api/abstract.d.ts +3 -3
  4. package/api/abstract.js +7 -2
  5. package/api/abstract.js.map +1 -1
  6. package/api/class/class.d.ts +45 -24
  7. package/api/class/class.js +158 -112
  8. package/api/class/class.js.map +1 -1
  9. package/api/computing/debugger.d.ts +15 -0
  10. package/api/computing/debugger.js +35 -0
  11. package/api/computing/debugger.js.map +1 -0
  12. package/api/computing/rest.d.ts +4 -4
  13. package/api/computing/rest.js.map +1 -1
  14. package/api/computing/return.d.ts +4 -0
  15. package/api/computing/return.js +5 -0
  16. package/api/computing/return.js.map +1 -1
  17. package/api/computing/throw.d.ts +4 -0
  18. package/api/computing/throw.js +4 -0
  19. package/api/computing/throw.js.map +1 -1
  20. package/api/definition/array.d.ts +7 -6
  21. package/api/definition/array.js +20 -14
  22. package/api/definition/array.js.map +1 -1
  23. package/api/definition/bind.d.ts +6 -0
  24. package/api/definition/bind.js +6 -0
  25. package/api/definition/bind.js.map +1 -1
  26. package/api/definition/function.d.ts +35 -46
  27. package/api/definition/function.js +282 -299
  28. package/api/definition/function.js.map +1 -1
  29. package/api/definition/member.js.map +1 -1
  30. package/api/definition/object.d.ts +9 -6
  31. package/api/definition/object.js +35 -5
  32. package/api/definition/object.js.map +1 -1
  33. package/api/definition/statement.js +5 -1
  34. package/api/definition/statement.js.map +1 -1
  35. package/api/definition/values.d.ts +43 -50
  36. package/api/definition/values.js +84 -149
  37. package/api/definition/values.js.map +1 -1
  38. package/api/deserialize/deserialize.d.ts +7 -1
  39. package/api/deserialize/deserialize.js +9 -1
  40. package/api/deserialize/deserialize.js.map +1 -1
  41. package/api/deserialize/type-store.d.ts +2 -2
  42. package/api/deserialize/type-store.js.map +1 -1
  43. package/api/expression.d.ts +156 -12
  44. package/api/expression.js.map +1 -1
  45. package/api/index.d.ts +2 -0
  46. package/api/index.js +2 -0
  47. package/api/index.js.map +1 -1
  48. package/api/module/common.d.ts +29 -0
  49. package/api/module/common.js +71 -0
  50. package/api/module/common.js.map +1 -0
  51. package/api/module/export.d.ts +78 -9
  52. package/api/module/export.js +120 -15
  53. package/api/module/export.js.map +1 -1
  54. package/api/module/import.d.ts +56 -8
  55. package/api/module/import.js +62 -19
  56. package/api/module/import.js.map +1 -1
  57. package/api/operators/grouping.d.ts +7 -0
  58. package/api/operators/grouping.js +7 -0
  59. package/api/operators/grouping.js.map +1 -1
  60. package/api/operators/pipeline.d.ts +12 -0
  61. package/api/operators/pipeline.js +12 -0
  62. package/api/operators/pipeline.js.map +1 -1
  63. package/api/operators/unary.js +3 -0
  64. package/api/operators/unary.js.map +1 -1
  65. package/api/{module/app/program.d.ts → program.d.ts} +5 -5
  66. package/api/{module/app/program.js → program.js} +3 -3
  67. package/api/program.js.map +1 -0
  68. package/api/statement/control/block.d.ts +5 -2
  69. package/api/statement/control/block.js +24 -21
  70. package/api/statement/control/block.js.map +1 -1
  71. package/api/statement/control/empty.d.ts +7 -0
  72. package/api/statement/control/empty.js +7 -0
  73. package/api/statement/control/empty.js.map +1 -1
  74. package/api/statement/control/if.d.ts +5 -0
  75. package/api/statement/control/if.js +5 -0
  76. package/api/statement/control/if.js.map +1 -1
  77. package/api/statement/control/switch.d.ts +6 -0
  78. package/api/statement/control/switch.js +17 -3
  79. package/api/statement/control/switch.js.map +1 -1
  80. package/api/statement/control/terminate.d.ts +44 -11
  81. package/api/statement/control/terminate.js +87 -18
  82. package/api/statement/control/terminate.js.map +1 -1
  83. package/api/statement/declarations/declares.d.ts +7 -7
  84. package/api/statement/declarations/declares.js +1 -1
  85. package/api/statement/declarations/declares.js.map +1 -1
  86. package/api/statement/iterations/for.d.ts +5 -0
  87. package/api/statement/iterations/for.js +35 -16
  88. package/api/statement/iterations/for.js.map +1 -1
  89. package/api/statement/iterations/while.d.ts +6 -0
  90. package/api/statement/iterations/while.js +25 -11
  91. package/api/statement/iterations/while.js.map +1 -1
  92. package/api/utils.d.ts +2 -0
  93. package/api/utils.js +3 -1
  94. package/api/utils.js.map +1 -1
  95. package/package.json +7 -5
  96. package/scope/event.d.ts +3 -3
  97. package/scope/event.js +2 -2
  98. package/scope/event.js.map +1 -1
  99. package/scope/pool.d.ts +7 -0
  100. package/scope/pool.js +29 -0
  101. package/scope/pool.js.map +1 -0
  102. package/scope/proxy.d.ts +6 -11
  103. package/scope/proxy.js +23 -52
  104. package/scope/proxy.js.map +1 -1
  105. package/scope/scope.d.ts +161 -38
  106. package/scope/scope.js +260 -106
  107. package/scope/scope.js.map +1 -1
  108. package/scope/stack.d.ts +97 -21
  109. package/scope/stack.js +13 -0
  110. package/scope/stack.js.map +1 -1
  111. package/v8/enums.d.ts +204 -0
  112. package/v8/enums.js +406 -0
  113. package/v8/enums.js.map +1 -0
  114. package/v8/index.d.ts +2 -1
  115. package/v8/index.js +2 -1
  116. package/v8/index.js.map +1 -1
  117. package/v8/inline.d.ts +213 -0
  118. package/v8/inline.js +2375 -0
  119. package/v8/inline.js.map +1 -0
  120. package/v8/nodes.d.ts +8 -7
  121. package/v8/nodes.js +39 -64
  122. package/v8/nodes.js.map +1 -1
  123. package/v8/parser.d.ts +49 -151
  124. package/v8/parser.js +839 -1608
  125. package/v8/parser.js.map +1 -1
  126. package/v8/stream.d.ts +39 -3
  127. package/v8/stream.js +685 -171
  128. package/v8/stream.js.map +1 -1
  129. package/v8/token.d.ts +244 -9
  130. package/v8/token.js +315 -47
  131. package/v8/token.js.map +1 -1
  132. package/visit/visitor.d.ts +3 -0
  133. package/visit/visitor.js.map +1 -1
  134. package/api/module/app/program.js.map +0 -1
  135. package/v8/app.d.ts +0 -0
  136. package/v8/app.js +0 -2
  137. package/v8/app.js.map +0 -1
package/scope/scope.d.ts CHANGED
@@ -1,32 +1,89 @@
1
1
  import { TypeOf } from '../api/utils.js';
2
- export declare type ScopeContext = {
3
- [key: PropertyKey]: ScopeContext | any;
4
- };
5
- export interface Scope<T = ScopeContext> {
2
+ export declare type Context = Record<PropertyKey, any>;
3
+ export interface Scope<T = Context> {
4
+ /**
5
+ * get value of `propertyKey` in current context
6
+ * @param propertyKey
7
+ */
6
8
  get(propertyKey: keyof T): any;
9
+ /**
10
+ * set the value of `propertyKey` in current context, could be instilled with `value`.
11
+ * @param propertyKey
12
+ * @param value
13
+ * @param receiver
14
+ */
7
15
  set(propertyKey: keyof T, value?: any, receiver?: any): boolean;
16
+ /**
17
+ * is current context has `propertyKey` in hash map keys
18
+ * @param propertyKey
19
+ */
8
20
  has(propertyKey: keyof T): boolean;
21
+ /**
22
+ * delete property from context
23
+ * @param propertyKey
24
+ */
9
25
  delete(propertyKey: keyof T): boolean;
26
+ /**
27
+ * get current context object of this scope
28
+ */
10
29
  getContext(): T;
30
+ /**
31
+ * get a proxy of the current context object if exists.
32
+ */
11
33
  getContextProxy?(): T;
12
- getScope<V extends ScopeContext>(propertyKey: keyof T): Scope<V> | undefined;
13
- getScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): Scope<V>;
14
- getClass(): TypeOf<Scope<ScopeContext>>;
34
+ /**
35
+ * get a scope for an object named as `propertyKey` from cache map,
36
+ *
37
+ * if the current value is not type od `object`, will return `undefined`.
38
+ * @param propertyKey the name of the property
39
+ */
40
+ getInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S | undefined;
41
+ /**
42
+ * create a scope with the same type of this scope
43
+ */
44
+ setInnerScope<S extends Scope<Context>>(propertyKey: keyof T): S;
45
+ /**
46
+ * sc
47
+ * @param propertyKey
48
+ * @param scope
49
+ */
50
+ setInnerScope<S extends Scope<Context>>(propertyKey: keyof T, scope?: S): S;
51
+ getClass(): TypeOf<Scope<Context>>;
15
52
  }
16
- export declare class Scope<T extends ScopeContext> implements Scope<T> {
17
- protected context: 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>;
20
- protected scopeMap: Map<keyof T, Scope<any>>;
21
- protected propertyKeys?: (keyof T)[];
53
+ export declare class Scope<T extends Context> implements Scope<T> {
54
+ protected _ctx: T;
55
+ protected _keys?: (keyof T)[] | undefined;
56
+ static for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]): Scope<T>;
57
+ static blockScope<T extends Context>(propertyKeys?: (keyof T)[]): Scope<T>;
58
+ protected _inners: Map<keyof T, Scope<any>>;
22
59
  constructor(context: T, propertyKeys?: (keyof T)[]);
23
60
  }
24
- export declare class ReadOnlyScope<T extends ScopeContext> extends Scope<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>;
61
+ /**
62
+ * a class scope used for class instance and private static properties
63
+ */
64
+ export declare class ClassScope<T extends Context> extends Scope<T> {
65
+ private _pKeys?;
66
+ static for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]): ClassScope<T>;
67
+ static blockScope<T extends Context>(propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]): ClassScope<T>;
68
+ static readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]): ReadOnlyScope<{
69
+ this: T;
70
+ }>;
71
+ protected _private: Context;
72
+ constructor(context: T, propertyKeys?: (keyof T)[], privateKeys?: (keyof T)[]);
73
+ getPrivateContext(): T;
74
+ get(key: keyof T): any;
75
+ set(key: keyof T, value: any, receiver?: any): boolean;
76
+ has(key: keyof T): boolean;
77
+ delete(key: keyof T): boolean;
78
+ protected isPrivateKey(key: keyof T): boolean;
79
+ getClass(): TypeOf<ReadOnlyScope<Context>>;
80
+ }
81
+ export declare class ReadOnlyScope<T extends Context> extends Scope<T> {
82
+ static for<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]): ReadOnlyScope<T>;
83
+ static blockScope<T extends Context>(propertyKeys?: (keyof T)[]): ReadOnlyScope<T>;
27
84
  set(propertyKey: keyof T, value: any, receiver?: any): boolean;
28
85
  delete(propertyKey: keyof T): boolean;
29
- getClass(): TypeOf<ReadOnlyScope<ScopeContext>>;
86
+ getClass(): TypeOf<ReadOnlyScope<Context>>;
30
87
  }
31
88
  export declare class ScopeSubscription<T> {
32
89
  private propertyKey;
@@ -38,58 +95,124 @@ export declare class ScopeSubscription<T> {
38
95
  }
39
96
  export declare type ValueChangedCallback = (newValue: any, oldValue?: any) => void;
40
97
  export declare class ValueChangeObserver<T> {
41
- private subscribers;
42
- private propertiesLock;
98
+ private _subscribers;
99
+ private _lock;
43
100
  emit(propertyKey: keyof T, newValue: any, oldValue?: any): void;
44
101
  subscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T>;
45
102
  unsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>): void;
46
103
  pause(propertyKey: keyof T, subscription: ScopeSubscription<T>): void;
47
104
  resume(propertyKey: keyof T, subscription: ScopeSubscription<T>): void;
105
+ /**
106
+ * check if this Observer has any subscribers
107
+ */
108
+ hasSubscribers(): boolean;
109
+ /**
110
+ * check if there is any subscribers registered by the propertyKey.
111
+ *
112
+ * @param propertyKey
113
+ */
114
+ hasSubscribers(propertyKey: keyof T): boolean;
115
+ /**
116
+ * clear subscription maps
117
+ */
48
118
  destroy(): void;
49
119
  }
50
- export declare class ReactiveScope<T extends ScopeContext> extends Scope<T> {
51
- protected parent?: ReactiveScope<any> | undefined;
52
- static for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]): ReactiveScope<T>;
53
- static blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]): ReactiveScope<T>;
54
- protected observer: ValueChangeObserver<T>;
55
- protected name?: string;
56
- constructor(context: T, propertyKeys?: (keyof T)[]);
57
- constructor(context: T, name: string, parent: ReactiveScope<any>, propertyKeys?: (keyof T)[]);
120
+ export declare class ReactiveScope<T extends Context> extends Scope<T> {
121
+ protected _name?: keyof T | undefined;
122
+ protected _parent?: ReactiveScope<any> | undefined;
123
+ static for<T extends Context>(context: T, propertyKeys?: (keyof T)[]): ReactiveScope<T>;
124
+ static blockScope<T extends Context>(propertyKeys?: (keyof T)[]): ReactiveScope<T>;
125
+ static scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]): Scope<{
126
+ this: T;
127
+ }>;
128
+ static readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]): ReadOnlyScope<{
129
+ this: T;
130
+ }>;
131
+ protected _clone: T;
132
+ protected _inners: Map<keyof T, ReactiveScope<any>>;
133
+ protected _observer: ValueChangeObserver<T>;
134
+ constructor(context: T, propertyKeys?: (keyof T)[], _name?: keyof T | undefined, _parent?: ReactiveScope<any> | undefined);
58
135
  set(propertyKey: keyof T, newValue: any, receiver?: any): boolean;
59
136
  delete(propertyKey: keyof T): boolean;
60
- getScope<V extends ScopeContext>(propertyKey: keyof T): ReactiveScope<V> | undefined;
61
- getScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): ReactiveScope<V>;
62
137
  emit(propertyKey: keyof T, newValue: any, oldValue?: any): void;
63
138
  subscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T>;
64
139
  unsubscribe(propertyKey?: keyof T, subscription?: ScopeSubscription<T>): void;
65
- getClass(): TypeOf<ReactiveScope<ScopeContext>>;
140
+ detectChanges(): void;
141
+ protected getPropertyKeys<V extends Record<PropertyKey, any>>(...objs: V[]): (keyof V)[];
142
+ getClass(): TypeOf<ReactiveScope<Context>>;
66
143
  }
67
- export interface ScopeControl<T extends ScopeContext> {
144
+ /**
145
+ * used control/notify/pause scope about changes in current context
146
+ */
147
+ export interface ScopeControl<T extends Context> {
148
+ /**
149
+ * get current stacte of applying change detection.
150
+ */
68
151
  isAttached(): boolean;
152
+ /**
153
+ * used when want to update ui-view like, you want to replace an array with another
154
+ * without reflect changes on view until reattached again.
155
+ */
69
156
  detach(): void;
157
+ /**
158
+ * apply all the not emitted changes, and continue emit in time.
159
+ */
70
160
  reattach(): void;
161
+ /**
162
+ * apply changes now,
163
+ * will not effect the state of the detector wither if attached ot not.
164
+ *
165
+ * if a propertyKey is provided, will emit this property only
166
+ * @param propertyKey
167
+ */
71
168
  emitChanges(propertyKey?: keyof T, propertyValue?: any): void;
169
+ /**
170
+ * throw error if any changes has been made
171
+ */
172
+ checkNoChanges(): void;
72
173
  }
73
- export declare class ReactiveScopeControl<T extends ScopeContext> extends ReactiveScope<T> implements ScopeControl<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>;
76
- protected attached: boolean;
77
- protected marked: ScopeContext;
174
+ export declare class ReactiveScopeControl<T extends Context> extends ReactiveScope<T> implements ScopeControl<T> {
175
+ static for<T extends Context>(context: T, propertyKeys?: (keyof T)[]): ReactiveScopeControl<T>;
176
+ static blockScope<T extends Context>(propertyKeys?: (keyof T)[]): ReactiveScopeControl<T>;
177
+ static scopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]): Scope<{
178
+ this: T;
179
+ }>;
180
+ static readOnlyScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]): ReadOnlyScope<{
181
+ this: T;
182
+ }>;
183
+ static reactiveScopeForThis<T extends Context>(ctx: T, propertyKeys?: (keyof T)[]): Scope<{
184
+ this: T;
185
+ }>;
186
+ protected _attached: boolean;
187
+ protected _marked: {
188
+ [key: keyof Context]: [any, any];
189
+ };
78
190
  emit(propertyKey: keyof T, newValue: any, oldValue?: any): void;
79
191
  isAttached(): boolean;
80
192
  detach(): void;
81
193
  reattach(): void;
82
194
  emitChanges(propertyKey?: keyof T, propertyValue?: any): void;
83
- getClass(): TypeOf<ReactiveScopeControl<ScopeContext>>;
195
+ detectChanges(): void;
196
+ checkNoChanges(): void;
197
+ getClass(): TypeOf<ReactiveScopeControl<Context>>;
84
198
  }
85
199
  interface ImportMeta {
86
200
  url: URL;
201
+ /**
202
+ *
203
+ * Provides a module-relative resolution function scoped to each module, returning
204
+ * the URL string.
205
+ *
206
+ * @param specified The module specifier to resolve relative to `parent`.
207
+ * @param parent The absolute parent module URL to resolve from. If none
208
+ * is specified, the value of `import.meta.url` is used as the default.
209
+ */
87
210
  resolve?(specified: string, parent?: string | URL): Promise<string>;
88
211
  }
89
212
  export interface ModuleImport {
90
213
  meta: ImportMeta;
91
214
  }
92
- export interface ModuleContext extends ScopeContext {
215
+ export interface ModuleContext extends Context {
93
216
  import: ModuleImport & ((path: string) => Promise<any>);
94
217
  }
95
218
  export declare class ModuleScope extends ReactiveScope<ModuleContext> {