@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.
- package/LICENSE +1 -1
- package/README.md +1 -0
- package/api/abstract.d.ts +3 -3
- package/api/abstract.js +7 -2
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +45 -24
- package/api/class/class.js +158 -112
- package/api/class/class.js.map +1 -1
- package/api/computing/debugger.d.ts +15 -0
- package/api/computing/debugger.js +35 -0
- package/api/computing/debugger.js.map +1 -0
- package/api/computing/rest.d.ts +4 -4
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +4 -0
- package/api/computing/return.js +5 -0
- package/api/computing/return.js.map +1 -1
- package/api/computing/throw.d.ts +4 -0
- package/api/computing/throw.js +4 -0
- package/api/computing/throw.js.map +1 -1
- package/api/definition/array.d.ts +7 -6
- package/api/definition/array.js +20 -14
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +6 -0
- package/api/definition/bind.js +6 -0
- package/api/definition/bind.js.map +1 -1
- package/api/definition/function.d.ts +35 -46
- package/api/definition/function.js +282 -299
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +9 -6
- package/api/definition/object.js +35 -5
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.js +5 -1
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +43 -50
- package/api/definition/values.js +84 -149
- package/api/definition/values.js.map +1 -1
- package/api/deserialize/deserialize.d.ts +7 -1
- package/api/deserialize/deserialize.js +9 -1
- package/api/deserialize/deserialize.js.map +1 -1
- package/api/deserialize/type-store.d.ts +2 -2
- package/api/deserialize/type-store.js.map +1 -1
- package/api/expression.d.ts +156 -12
- package/api/expression.js.map +1 -1
- package/api/index.d.ts +2 -0
- package/api/index.js +2 -0
- package/api/index.js.map +1 -1
- package/api/module/common.d.ts +29 -0
- package/api/module/common.js +71 -0
- package/api/module/common.js.map +1 -0
- package/api/module/export.d.ts +78 -9
- package/api/module/export.js +120 -15
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +56 -8
- package/api/module/import.js +62 -19
- package/api/module/import.js.map +1 -1
- package/api/operators/grouping.d.ts +7 -0
- package/api/operators/grouping.js +7 -0
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/pipeline.d.ts +12 -0
- package/api/operators/pipeline.js +12 -0
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/unary.js +3 -0
- package/api/operators/unary.js.map +1 -1
- package/api/{module/app/program.d.ts → program.d.ts} +5 -5
- package/api/{module/app/program.js → program.js} +3 -3
- package/api/program.js.map +1 -0
- package/api/statement/control/block.d.ts +5 -2
- package/api/statement/control/block.js +24 -21
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +7 -0
- package/api/statement/control/empty.js +7 -0
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +5 -0
- package/api/statement/control/if.js +5 -0
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +6 -0
- package/api/statement/control/switch.js +17 -3
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +44 -11
- package/api/statement/control/terminate.js +87 -18
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +7 -7
- package/api/statement/declarations/declares.js +1 -1
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +5 -0
- package/api/statement/iterations/for.js +35 -16
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +6 -0
- package/api/statement/iterations/while.js +25 -11
- package/api/statement/iterations/while.js.map +1 -1
- package/api/utils.d.ts +2 -0
- package/api/utils.js +3 -1
- package/api/utils.js.map +1 -1
- package/package.json +7 -5
- package/scope/event.d.ts +3 -3
- package/scope/event.js +2 -2
- package/scope/event.js.map +1 -1
- package/scope/pool.d.ts +7 -0
- package/scope/pool.js +29 -0
- package/scope/pool.js.map +1 -0
- package/scope/proxy.d.ts +6 -11
- package/scope/proxy.js +23 -52
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +161 -38
- package/scope/scope.js +260 -106
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +97 -21
- package/scope/stack.js +13 -0
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +204 -0
- package/v8/enums.js +406 -0
- package/v8/enums.js.map +1 -0
- package/v8/index.d.ts +2 -1
- package/v8/index.js +2 -1
- package/v8/index.js.map +1 -1
- package/v8/inline.d.ts +213 -0
- package/v8/inline.js +2375 -0
- package/v8/inline.js.map +1 -0
- package/v8/nodes.d.ts +8 -7
- package/v8/nodes.js +39 -64
- package/v8/nodes.js.map +1 -1
- package/v8/parser.d.ts +49 -151
- package/v8/parser.js +839 -1608
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +39 -3
- package/v8/stream.js +685 -171
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +244 -9
- package/v8/token.js +315 -47
- package/v8/token.js.map +1 -1
- package/visit/visitor.d.ts +3 -0
- package/visit/visitor.js.map +1 -1
- package/api/module/app/program.js.map +0 -1
- package/v8/app.d.ts +0 -0
- package/v8/app.js +0 -2
- 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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
17
|
-
protected
|
|
18
|
-
|
|
19
|
-
static
|
|
20
|
-
|
|
21
|
-
protected
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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<
|
|
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
|
|
42
|
-
private
|
|
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
|
|
51
|
-
protected
|
|
52
|
-
|
|
53
|
-
static
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
140
|
+
detectChanges(): void;
|
|
141
|
+
protected getPropertyKeys<V extends Record<PropertyKey, any>>(...objs: V[]): (keyof V)[];
|
|
142
|
+
getClass(): TypeOf<ReactiveScope<Context>>;
|
|
66
143
|
}
|
|
67
|
-
|
|
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
|
|
74
|
-
static for<T extends
|
|
75
|
-
static blockScope<T extends
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
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
|
|
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> {
|