/
index.esm.d.ts
266 lines (266 loc) · 7.44 KB
/
index.esm.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
export interface PathInfo {
listener: string;
update: string | undefined;
resolved: string | undefined;
}
export interface ListenerFunctionEventInfo {
type: string;
listener: Listener;
listenersCollection: ListenersCollection;
path: PathInfo;
params: Params;
options: ListenerOptions | UpdateOptions | undefined;
}
export declare type ListenerFunction = (value: any, eventInfo: ListenerFunctionEventInfo) => void;
export declare type Match = (path: string, debug?: boolean) => boolean;
export interface Options {
delimiter?: string;
useMute?: boolean;
notRecursive?: string;
param?: string;
wildcard?: string;
experimentalMatch?: boolean;
queue?: boolean;
useCache?: boolean;
useSplitCache?: boolean;
useIndicesCache?: boolean;
maxSimultaneousJobs?: number;
maxQueueRuns?: number;
defaultBulkValue?: boolean;
log?: (message: string, info: any) => void;
debug?: boolean;
extraDebug?: boolean;
Promise?: Promise<unknown> | any;
}
export interface ListenerOptions {
bulk?: boolean;
bulkValue?: boolean;
debug?: boolean;
source?: string;
data?: any;
queue?: boolean;
ignore?: string[];
group?: boolean | string;
}
export interface UpdateOptions {
only?: string[] | null;
source?: string;
debug?: boolean;
data?: any;
queue?: boolean;
force?: boolean;
}
export interface Listener {
fn: ListenerFunction;
options: ListenerOptions;
id?: number;
groupId: number | string | null;
}
export interface Queue {
id: number;
resolvedPath: string;
resolvedIdPath: string;
fn: () => void;
originalFn: ListenerFunction;
options: ListenerOptions;
groupId: number | string | null;
}
export interface GroupedListener {
listener: Listener;
listenersCollection: ListenersCollection;
eventInfo: ListenerFunctionEventInfo;
value: any;
}
export interface GroupedListenerContainer {
single: GroupedListener[];
bulk: GroupedListener[];
}
export interface GroupedListeners {
[path: string]: GroupedListenerContainer;
}
export declare type Updater = (value: any) => any;
export declare type ListenersObject = Map<string | number, Listener>;
export interface ListenersCollection {
path: string;
originalPath: string;
listeners: ListenersObject;
isWildcard: boolean;
isRecursive: boolean;
hasParams: boolean;
paramsInfo: ParamsInfo | undefined;
match: Match;
count: number;
}
export declare type Listeners = Map<string, ListenersCollection>;
export interface WaitingPath {
dirty: boolean;
isWildcard: boolean;
isRecursive: boolean;
paramsInfo?: ParamsInfo;
}
export interface WaitingPaths {
[key: string]: WaitingPath;
}
export declare type WaitingListenerFunction = (paths: WaitingPaths) => () => void;
export interface WaitingListener {
fn: WaitingListenerFunction;
paths: WaitingPaths;
}
export declare type WaitingListeners = Map<string[], WaitingListener>;
export interface ParamInfo {
name: string;
replaced: string;
original: string;
}
export interface Parameters {
[part: number]: ParamInfo;
}
export interface Params {
[key: string]: any;
}
export interface ParamsInfo {
params: Parameters;
replaced: string;
original: string;
}
export interface SubscribeAllOptions {
all: string[];
index: number;
groupId: number | string | null;
}
export interface TraceValue {
id: string;
sort: number;
stack: string[];
additionalData: any;
changed: any[];
}
export interface UpdateStack {
updatePath: string;
newValue: unknown;
options: UpdateOptions;
}
export interface Bulk {
path: string;
value: any;
params: Params;
}
export interface Multi {
update: (updatePath: string, fn: Updater | any, options?: UpdateOptions) => Multi;
done: () => void;
getStack: () => UpdateStack[];
}
export interface UnknownObject {
[key: string]: unknown;
}
declare class DeepState {
private listeners;
private waitingListeners;
private data;
$: object;
private options;
private id;
private scan;
private jobsRunning;
private updateQueue;
private subscribeQueue;
private listenersIgnoreCache;
private is_match;
private destroyed;
private queueRuns;
private resolved;
private muted;
private mutedListeners;
private groupId;
private namedGroups;
private numberGroups;
private traceId;
private pathGet;
private pathSet;
private traceMap;
private tracing;
private savedTrace;
private collection;
private collections;
private cache;
private splitCache;
constructor(data?: object, options?: Options);
private getDefaultListenerOptions;
private cacheGet;
private cacheSet;
/**
* Silently update data
* @param path string
* @param value any
* @returns
*/
silentSet(path: string, value: any): any;
loadWasmMatcher(pathToWasmFile: string): Promise<void>;
private same;
getListeners(): Listeners;
destroy(): void;
match(first: string, second: string, nested?: boolean): boolean;
private indices;
private getIndicesOf;
private indicesCount;
private getIndicesCount;
private cutPath;
private trimPath;
private split;
private isWildcard;
private isNotRecursive;
private cleanNotRecursivePath;
private hasParams;
private getParamsInfo;
private getParams;
waitForAll(userPaths: string[], fn: WaitingListenerFunction): () => void;
private executeWaitingListeners;
subscribeAll(userPaths: string[], fn: ListenerFunction | WaitingListenerFunction, options?: ListenerOptions): () => void;
private getCleanListenersCollection;
private getCleanListener;
private getListenerCollectionMatch;
private getListenersCollection;
subscribe(listenerPath: string, fn: ListenerFunction, options?: ListenerOptions, subscribeAllOptions?: SubscribeAllOptions): () => void;
private unsubscribe;
private runQueuedListeners;
private getQueueNotifyListeners;
private shouldIgnore;
private getSubscribedListeners;
private notifySubscribedListeners;
private useBulkValue;
private getNestedListeners;
private notifyNestedListeners;
private getNotifyOnlyListeners;
private runQueue;
private sortAndRunQueue;
private notifyOnly;
private canBeNested;
private getUpdateValues;
private wildcardNotify;
private wildcardUpdate;
private runUpdateQueue;
private updateNotify;
private updateNotifyAll;
private updateNotifyOnly;
update(updatePath: string, fnOrValue: Updater | any, options?: UpdateOptions, multi?: boolean): any;
multi(grouped?: boolean): Multi;
collect(): Multi;
executeCollected(): void;
getCollectedCount(): number;
getCollectedStack(): UpdateStack[];
get(userPath?: string | undefined): any;
private lastExecs;
last(callback: () => void): void;
isMuted(pathOrListenerFunction: string | ListenerFunction): boolean;
isMutedListener(listenerFunc: ListenerFunction): boolean;
mute(pathOrListenerFunction: string | ListenerFunction): Set<ListenerFunction>;
unmute(pathOrListenerFunction: string | ListenerFunction): boolean;
private debugSubscribe;
private debugListener;
private debugTime;
startTrace(name: string, additionalData?: any): string;
stopTrace(id: string): TraceValue;
saveTrace(id: string): TraceValue;
getSavedTraces(): TraceValue[];
}
export default DeepState;