@meshflow/core 0.4.0 → 0.4.2
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/index.d.mts +27 -14
- package/index.d.ts +27 -14
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type ContractType = 'boolean' | 'scalar' | 'array' | 'object';
|
|
2
2
|
declare enum DefaultStrategy {
|
|
3
3
|
OR = "OR",
|
|
4
|
-
PRIORITY = "PRIORITY"
|
|
4
|
+
PRIORITY = "PRIORITY",
|
|
5
|
+
MERGE = "MERGE"
|
|
5
6
|
}
|
|
6
7
|
declare class SchemaBucket<P> {
|
|
7
8
|
private path;
|
|
@@ -60,6 +61,7 @@ type KeysOfUnion<T> = T extends any ? keyof T : never;
|
|
|
60
61
|
interface BaseMeshEvents {
|
|
61
62
|
"flow:start": {
|
|
62
63
|
path: MeshPath;
|
|
64
|
+
token: symbol;
|
|
63
65
|
};
|
|
64
66
|
"node:start": {
|
|
65
67
|
path: MeshPath;
|
|
@@ -122,10 +124,14 @@ interface BaseMeshEvents {
|
|
|
122
124
|
interface MeshEvents extends BaseMeshEvents {
|
|
123
125
|
"flow:success": {
|
|
124
126
|
duration: string;
|
|
127
|
+
token: symbol;
|
|
125
128
|
};
|
|
126
129
|
"flow:end": {
|
|
127
130
|
type: number;
|
|
128
131
|
};
|
|
132
|
+
"flow:abort": {
|
|
133
|
+
token: symbol;
|
|
134
|
+
};
|
|
129
135
|
"node:revive": {
|
|
130
136
|
path: MeshPath;
|
|
131
137
|
triggerPath: MeshPath;
|
|
@@ -159,6 +165,7 @@ interface MeshErrorContext {
|
|
|
159
165
|
error: any;
|
|
160
166
|
}
|
|
161
167
|
type MeshPath = string | number | symbol;
|
|
168
|
+
type MeshNodeProxy<Node, V, NM, Extra = {}> = Extra & V & Node & NM;
|
|
162
169
|
interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, NM = any> {
|
|
163
170
|
path: P;
|
|
164
171
|
uid: number;
|
|
@@ -167,11 +174,11 @@ interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, NM = any> {
|
|
|
167
174
|
nodeBucket: Record<keyof NM, SchemaBucket<P>>;
|
|
168
175
|
notifyKeys: Set<keyof NM>;
|
|
169
176
|
dirtySignal: any;
|
|
170
|
-
proxy:
|
|
177
|
+
proxy: MeshNodeProxy<MeshFlowTaskNode<P, V, NM>, V, NM>;
|
|
171
178
|
calledBy: TriggerCause;
|
|
172
179
|
meta: NM;
|
|
173
180
|
dependOn: (cb: (val: V) => V, key?: keyof NM) => void;
|
|
174
|
-
createView:
|
|
181
|
+
createView: <E extends Record<string, any> = {}>(extraProps?: E) => MeshNodeProxy<MeshFlowTaskNode<P, V, NM>, V, NM, E>;
|
|
175
182
|
}
|
|
176
183
|
interface MeshFlowGroupNode<P extends MeshPath = MeshPath> {
|
|
177
184
|
path: P;
|
|
@@ -204,15 +211,18 @@ interface SetRuleOptions<NM, TKeys extends KeysOfUnion<NM>> {
|
|
|
204
211
|
}
|
|
205
212
|
type EntangleGhost<T = any> = {
|
|
206
213
|
key: string;
|
|
207
|
-
value?:
|
|
208
|
-
delta?: number;
|
|
214
|
+
value?: any;
|
|
215
|
+
delta?: number | any;
|
|
209
216
|
weight?: number;
|
|
217
|
+
op?: "add" | "intersect" | "union" | "merge" | "remove";
|
|
218
|
+
patch?: (oldState: T) => T;
|
|
210
219
|
};
|
|
211
220
|
type EntangleArgType<P extends MeshPath> = {
|
|
212
221
|
observer: P;
|
|
213
222
|
target: P;
|
|
214
223
|
triggerKeys: string[];
|
|
215
|
-
|
|
224
|
+
filter?: (obs: any, tgt: any) => boolean;
|
|
225
|
+
emit: (observerState: any, currentState: any) => void | EntangleGhost | undefined | Promise<void | EntangleGhost | undefined>;
|
|
216
226
|
};
|
|
217
227
|
declare enum TriggerCause {
|
|
218
228
|
CAUSALITY = 0,// 因果推导(正常)
|
|
@@ -264,7 +274,7 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, M extends Rec
|
|
|
264
274
|
};
|
|
265
275
|
usePlugin: (plugin: {
|
|
266
276
|
apply: (api: {
|
|
267
|
-
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
277
|
+
on: (event: MeshEventName, cb: Function) => () => boolean | undefined;
|
|
268
278
|
}) => void;
|
|
269
279
|
}) => () => void;
|
|
270
280
|
SetValue: (path: P, key: KeysOfUnion<NM> | (string & {}), value: any) => void;
|
|
@@ -296,7 +306,7 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, M extends Rec
|
|
|
296
306
|
path: P;
|
|
297
307
|
}) => void) => () => void;
|
|
298
308
|
scheduler: {
|
|
299
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowTaskNode<P, any, NM>;
|
|
309
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal" | "nodeBucket">) => MeshFlowTaskNode<P, any, NM>;
|
|
300
310
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowGroupNode<P>;
|
|
301
311
|
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
302
312
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath>;
|
|
@@ -312,6 +322,7 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, M extends Rec
|
|
|
312
322
|
UITrigger: any;
|
|
313
323
|
UidToNodeMap: MeshFlowTaskNode<P, any, NM>[];
|
|
314
324
|
};
|
|
325
|
+
destroyPlugin: () => void;
|
|
315
326
|
};
|
|
316
327
|
|
|
317
328
|
declare function useScheduler<T, //ui trigger中定义的类型
|
|
@@ -335,7 +346,7 @@ B extends Record<string, any> = StandardUITrigger<T>, NM = any>(config: {
|
|
|
335
346
|
callOnStart: any;
|
|
336
347
|
emit: MeshEmit;
|
|
337
348
|
}, UITrigger: B): {
|
|
338
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowTaskNode<P, any, NM>;
|
|
349
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal" | "nodeBucket">) => MeshFlowTaskNode<P, any, NM>;
|
|
339
350
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowGroupNode<P>;
|
|
340
351
|
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
341
352
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath>;
|
|
@@ -450,7 +461,7 @@ M extends Record<string, any>, NM extends Record<string, any> = InferLeafType<S>
|
|
|
450
461
|
};
|
|
451
462
|
usePlugin: (plugin: {
|
|
452
463
|
apply: (api: {
|
|
453
|
-
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
464
|
+
on: (event: MeshEventName, cb: Function) => () => boolean | undefined;
|
|
454
465
|
}) => void;
|
|
455
466
|
}) => () => void;
|
|
456
467
|
SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
|
|
@@ -482,7 +493,7 @@ M extends Record<string, any>, NM extends Record<string, any> = InferLeafType<S>
|
|
|
482
493
|
path: P;
|
|
483
494
|
}) => void) => () => void;
|
|
484
495
|
scheduler: {
|
|
485
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowTaskNode<P, any, NM>;
|
|
496
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal" | "nodeBucket">) => MeshFlowTaskNode<P, any, NM>;
|
|
486
497
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowGroupNode<P>;
|
|
487
498
|
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
488
499
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath>;
|
|
@@ -498,6 +509,7 @@ M extends Record<string, any>, NM extends Record<string, any> = InferLeafType<S>
|
|
|
498
509
|
UITrigger: any;
|
|
499
510
|
UidToNodeMap: MeshFlowTaskNode<P, any, NM>[];
|
|
500
511
|
};
|
|
512
|
+
destroyPlugin: () => void;
|
|
501
513
|
}, M, P>;
|
|
502
514
|
declare const useMeshFlowDefiner: <P extends MeshPath, S extends Record<string, any> | any[] = any, NM extends Record<string, any> = any>() => <T, M extends Record<string, any>>(id: MeshPath, schema: S, options: {
|
|
503
515
|
metaType?: NM;
|
|
@@ -536,7 +548,7 @@ declare const useMeshFlow: <const S extends Record<string, any> | any[], T, M ex
|
|
|
536
548
|
};
|
|
537
549
|
usePlugin: (plugin: {
|
|
538
550
|
apply: (api: {
|
|
539
|
-
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
551
|
+
on: (event: MeshEventName, cb: Function) => () => boolean | undefined;
|
|
540
552
|
}) => void;
|
|
541
553
|
}) => () => void;
|
|
542
554
|
SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
|
|
@@ -568,7 +580,7 @@ declare const useMeshFlow: <const S extends Record<string, any> | any[], T, M ex
|
|
|
568
580
|
path: P;
|
|
569
581
|
}) => void) => () => void;
|
|
570
582
|
scheduler: {
|
|
571
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowTaskNode<P, any, NM>;
|
|
583
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal" | "nodeBucket">) => MeshFlowTaskNode<P, any, NM>;
|
|
572
584
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowGroupNode<P>;
|
|
573
585
|
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
574
586
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath>;
|
|
@@ -584,6 +596,7 @@ declare const useMeshFlow: <const S extends Record<string, any> | any[], T, M ex
|
|
|
584
596
|
UITrigger: any;
|
|
585
597
|
UidToNodeMap: MeshFlowTaskNode<P, any, NM>[];
|
|
586
598
|
};
|
|
599
|
+
destroyPlugin: () => void;
|
|
587
600
|
}, M, P>;
|
|
588
601
|
|
|
589
|
-
export { type BaseEngine, DefaultStrategy, type Engine, type EngineModules, type InferLeafPath, type InferLeafType, type MapModuleToReturn, type MeshErrorContext, type MeshEvents, type MeshFlowGroupNode, type MeshFlowTaskNode, type MeshPath, type SchedulerType, SchemaBucket, type SetRuleOptions, type TransformModuleKey, TriggerCause, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };
|
|
602
|
+
export { type BaseEngine, DefaultStrategy, type Engine, type EngineModules, type InferLeafPath, type InferLeafType, type MapModuleToReturn, type MeshErrorContext, type MeshEvents, type MeshFlowGroupNode, type MeshFlowTaskNode, type MeshNodeProxy, type MeshPath, type SchedulerType, SchemaBucket, type SetRuleOptions, type TransformModuleKey, TriggerCause, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type ContractType = 'boolean' | 'scalar' | 'array' | 'object';
|
|
2
2
|
declare enum DefaultStrategy {
|
|
3
3
|
OR = "OR",
|
|
4
|
-
PRIORITY = "PRIORITY"
|
|
4
|
+
PRIORITY = "PRIORITY",
|
|
5
|
+
MERGE = "MERGE"
|
|
5
6
|
}
|
|
6
7
|
declare class SchemaBucket<P> {
|
|
7
8
|
private path;
|
|
@@ -60,6 +61,7 @@ type KeysOfUnion<T> = T extends any ? keyof T : never;
|
|
|
60
61
|
interface BaseMeshEvents {
|
|
61
62
|
"flow:start": {
|
|
62
63
|
path: MeshPath;
|
|
64
|
+
token: symbol;
|
|
63
65
|
};
|
|
64
66
|
"node:start": {
|
|
65
67
|
path: MeshPath;
|
|
@@ -122,10 +124,14 @@ interface BaseMeshEvents {
|
|
|
122
124
|
interface MeshEvents extends BaseMeshEvents {
|
|
123
125
|
"flow:success": {
|
|
124
126
|
duration: string;
|
|
127
|
+
token: symbol;
|
|
125
128
|
};
|
|
126
129
|
"flow:end": {
|
|
127
130
|
type: number;
|
|
128
131
|
};
|
|
132
|
+
"flow:abort": {
|
|
133
|
+
token: symbol;
|
|
134
|
+
};
|
|
129
135
|
"node:revive": {
|
|
130
136
|
path: MeshPath;
|
|
131
137
|
triggerPath: MeshPath;
|
|
@@ -159,6 +165,7 @@ interface MeshErrorContext {
|
|
|
159
165
|
error: any;
|
|
160
166
|
}
|
|
161
167
|
type MeshPath = string | number | symbol;
|
|
168
|
+
type MeshNodeProxy<Node, V, NM, Extra = {}> = Extra & V & Node & NM;
|
|
162
169
|
interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, NM = any> {
|
|
163
170
|
path: P;
|
|
164
171
|
uid: number;
|
|
@@ -167,11 +174,11 @@ interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, NM = any> {
|
|
|
167
174
|
nodeBucket: Record<keyof NM, SchemaBucket<P>>;
|
|
168
175
|
notifyKeys: Set<keyof NM>;
|
|
169
176
|
dirtySignal: any;
|
|
170
|
-
proxy:
|
|
177
|
+
proxy: MeshNodeProxy<MeshFlowTaskNode<P, V, NM>, V, NM>;
|
|
171
178
|
calledBy: TriggerCause;
|
|
172
179
|
meta: NM;
|
|
173
180
|
dependOn: (cb: (val: V) => V, key?: keyof NM) => void;
|
|
174
|
-
createView:
|
|
181
|
+
createView: <E extends Record<string, any> = {}>(extraProps?: E) => MeshNodeProxy<MeshFlowTaskNode<P, V, NM>, V, NM, E>;
|
|
175
182
|
}
|
|
176
183
|
interface MeshFlowGroupNode<P extends MeshPath = MeshPath> {
|
|
177
184
|
path: P;
|
|
@@ -204,15 +211,18 @@ interface SetRuleOptions<NM, TKeys extends KeysOfUnion<NM>> {
|
|
|
204
211
|
}
|
|
205
212
|
type EntangleGhost<T = any> = {
|
|
206
213
|
key: string;
|
|
207
|
-
value?:
|
|
208
|
-
delta?: number;
|
|
214
|
+
value?: any;
|
|
215
|
+
delta?: number | any;
|
|
209
216
|
weight?: number;
|
|
217
|
+
op?: "add" | "intersect" | "union" | "merge" | "remove";
|
|
218
|
+
patch?: (oldState: T) => T;
|
|
210
219
|
};
|
|
211
220
|
type EntangleArgType<P extends MeshPath> = {
|
|
212
221
|
observer: P;
|
|
213
222
|
target: P;
|
|
214
223
|
triggerKeys: string[];
|
|
215
|
-
|
|
224
|
+
filter?: (obs: any, tgt: any) => boolean;
|
|
225
|
+
emit: (observerState: any, currentState: any) => void | EntangleGhost | undefined | Promise<void | EntangleGhost | undefined>;
|
|
216
226
|
};
|
|
217
227
|
declare enum TriggerCause {
|
|
218
228
|
CAUSALITY = 0,// 因果推导(正常)
|
|
@@ -264,7 +274,7 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, M extends Rec
|
|
|
264
274
|
};
|
|
265
275
|
usePlugin: (plugin: {
|
|
266
276
|
apply: (api: {
|
|
267
|
-
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
277
|
+
on: (event: MeshEventName, cb: Function) => () => boolean | undefined;
|
|
268
278
|
}) => void;
|
|
269
279
|
}) => () => void;
|
|
270
280
|
SetValue: (path: P, key: KeysOfUnion<NM> | (string & {}), value: any) => void;
|
|
@@ -296,7 +306,7 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, M extends Rec
|
|
|
296
306
|
path: P;
|
|
297
307
|
}) => void) => () => void;
|
|
298
308
|
scheduler: {
|
|
299
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowTaskNode<P, any, NM>;
|
|
309
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal" | "nodeBucket">) => MeshFlowTaskNode<P, any, NM>;
|
|
300
310
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowGroupNode<P>;
|
|
301
311
|
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
302
312
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath>;
|
|
@@ -312,6 +322,7 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, M extends Rec
|
|
|
312
322
|
UITrigger: any;
|
|
313
323
|
UidToNodeMap: MeshFlowTaskNode<P, any, NM>[];
|
|
314
324
|
};
|
|
325
|
+
destroyPlugin: () => void;
|
|
315
326
|
};
|
|
316
327
|
|
|
317
328
|
declare function useScheduler<T, //ui trigger中定义的类型
|
|
@@ -335,7 +346,7 @@ B extends Record<string, any> = StandardUITrigger<T>, NM = any>(config: {
|
|
|
335
346
|
callOnStart: any;
|
|
336
347
|
emit: MeshEmit;
|
|
337
348
|
}, UITrigger: B): {
|
|
338
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowTaskNode<P, any, NM>;
|
|
349
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal" | "nodeBucket">) => MeshFlowTaskNode<P, any, NM>;
|
|
339
350
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowGroupNode<P>;
|
|
340
351
|
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
341
352
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath>;
|
|
@@ -450,7 +461,7 @@ M extends Record<string, any>, NM extends Record<string, any> = InferLeafType<S>
|
|
|
450
461
|
};
|
|
451
462
|
usePlugin: (plugin: {
|
|
452
463
|
apply: (api: {
|
|
453
|
-
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
464
|
+
on: (event: MeshEventName, cb: Function) => () => boolean | undefined;
|
|
454
465
|
}) => void;
|
|
455
466
|
}) => () => void;
|
|
456
467
|
SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
|
|
@@ -482,7 +493,7 @@ M extends Record<string, any>, NM extends Record<string, any> = InferLeafType<S>
|
|
|
482
493
|
path: P;
|
|
483
494
|
}) => void) => () => void;
|
|
484
495
|
scheduler: {
|
|
485
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowTaskNode<P, any, NM>;
|
|
496
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal" | "nodeBucket">) => MeshFlowTaskNode<P, any, NM>;
|
|
486
497
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowGroupNode<P>;
|
|
487
498
|
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
488
499
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath>;
|
|
@@ -498,6 +509,7 @@ M extends Record<string, any>, NM extends Record<string, any> = InferLeafType<S>
|
|
|
498
509
|
UITrigger: any;
|
|
499
510
|
UidToNodeMap: MeshFlowTaskNode<P, any, NM>[];
|
|
500
511
|
};
|
|
512
|
+
destroyPlugin: () => void;
|
|
501
513
|
}, M, P>;
|
|
502
514
|
declare const useMeshFlowDefiner: <P extends MeshPath, S extends Record<string, any> | any[] = any, NM extends Record<string, any> = any>() => <T, M extends Record<string, any>>(id: MeshPath, schema: S, options: {
|
|
503
515
|
metaType?: NM;
|
|
@@ -536,7 +548,7 @@ declare const useMeshFlow: <const S extends Record<string, any> | any[], T, M ex
|
|
|
536
548
|
};
|
|
537
549
|
usePlugin: (plugin: {
|
|
538
550
|
apply: (api: {
|
|
539
|
-
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
551
|
+
on: (event: MeshEventName, cb: Function) => () => boolean | undefined;
|
|
540
552
|
}) => void;
|
|
541
553
|
}) => () => void;
|
|
542
554
|
SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
|
|
@@ -568,7 +580,7 @@ declare const useMeshFlow: <const S extends Record<string, any> | any[], T, M ex
|
|
|
568
580
|
path: P;
|
|
569
581
|
}) => void) => () => void;
|
|
570
582
|
scheduler: {
|
|
571
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowTaskNode<P, any, NM>;
|
|
583
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy" | "dependOn" | "calledBy" | "uid" | "dirtySignal" | "nodeBucket">) => MeshFlowTaskNode<P, any, NM>;
|
|
572
584
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView" | "calledBy" | "uid" | "dirtySignal">) => MeshFlowGroupNode<P>;
|
|
573
585
|
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
574
586
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath>;
|
|
@@ -584,6 +596,7 @@ declare const useMeshFlow: <const S extends Record<string, any> | any[], T, M ex
|
|
|
584
596
|
UITrigger: any;
|
|
585
597
|
UidToNodeMap: MeshFlowTaskNode<P, any, NM>[];
|
|
586
598
|
};
|
|
599
|
+
destroyPlugin: () => void;
|
|
587
600
|
}, M, P>;
|
|
588
601
|
|
|
589
|
-
export { type BaseEngine, DefaultStrategy, type Engine, type EngineModules, type InferLeafPath, type InferLeafType, type MapModuleToReturn, type MeshErrorContext, type MeshEvents, type MeshFlowGroupNode, type MeshFlowTaskNode, type MeshPath, type SchedulerType, SchemaBucket, type SetRuleOptions, type TransformModuleKey, TriggerCause, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };
|
|
602
|
+
export { type BaseEngine, DefaultStrategy, type Engine, type EngineModules, type InferLeafPath, type InferLeafType, type MapModuleToReturn, type MeshErrorContext, type MeshEvents, type MeshFlowGroupNode, type MeshFlowTaskNode, type MeshNodeProxy, type MeshPath, type SchedulerType, SchemaBucket, type SetRuleOptions, type TransformModuleKey, TriggerCause, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var Me=class{computedRules=[];store={OR:(e,n)=>{let t,o,r=this.computedRules;for(let s=0;s<r.length;s++){let a=r[s],i=a.logic(e);if(i instanceof Promise)return (async()=>{let l=await i;if(a.entityId==="__base__"?o=l:l&&(t=l),typeof t>"u")for(let y=s+1;y<r.length;y++){let m=r[y],g=m.logic(e),u=g instanceof Promise?await g:g;if(m.entityId==="__base__"){o=u;continue}if(u){t=m.value;break}}return typeof t>"u"&&(t=o),{res:t,version:n}})();let d=i;if(a.entityId==="__base__"){o=d;continue}if(d){t=a.value;break}}return typeof t>"u"&&(t=o),{res:t,version:n}},PRIORITY:(e,n)=>{let t,o=this.computedRules;for(let r=0;r<o.length;r++){let a=o[r].logic(e);if(a instanceof Promise)return (async()=>{let i=await a;if(i!==void 0)return {res:i,version:n};for(let d=r+1;d<o.length;d++){let l=o[d].logic(e),y=l instanceof Promise?await l:l;if(y!==void 0)return {res:y,version:n}}return {res:void 0,version:n}})();if(a!==void 0)return {res:a,version:n}}return {res:t,version:n}}};CurrentStrategy=()=>{};CurrentStrategyType="PRIORITY";getRules=()=>{};constructor(e){this.getRules=e,this.CurrentStrategy=this.store.PRIORITY,this.updateComputedRules();}updateComputedRules(){let e=this.getRules();this.CurrentStrategyType==="PRIORITY"?this.computedRules=Array.from(e.values()).map(n=>Array.from(n)).flat().sort((n,t)=>t.priority-n.priority):this.computedRules=Array.from(e.values()).map(n=>Array.from(n)).flat();}setStrategy(e){this.CurrentStrategy=this.store[e],this.updateComputedRules();}evaluate(e,n){return this.CurrentStrategy(e,n)}},fe=class{path;strategy;contract;rules=new Map;isValue=false;id=0;cache=void 0;pendingPromise=null;version=0;deps=new Map;_forceNotify=false;promiseToken=null;useCache=true;effectArray=[];constructor(e,n,t){let o=()=>this.rules;this.strategy=new Me(o),this.path=t,this.isValue=n==="value",this.contract=this.inferType(e),this.cache=e,this.setRule({priority:0,entityId:"__base__",logic:()=>e});}setUseCache(e){this.useCache=e;}forceNotify(){this._forceNotify=true;}isForceNotify(){return this._forceNotify}setStrategy(e){this.strategy.setStrategy(e);}setDefaultRule(e){let n=new Set;n.add(e),this.rules.set("defaultRules",n);}setRules(e,n){n&&this.updateDeps(n);let t=++this.id,o={...e,entityId:t};for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(o);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let s=this.rules.get(r);s&&(s.delete(o),s.size===0&&(this.rules.delete(r),this.deps.delete(r)));}this.strategy.updateComputedRules();}}updateDeps(e){for(let[n,t]of e)this.deps.set(n,t);}setRule(e,n){if(n&&this.updateDeps(n),typeof e.entityId=="string"){this.setDefaultRule(e);return}let t=++this.id,o={...e,entityId:t};if(e)for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(o);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let s=this.rules.get(r);s&&(s.delete(o),s.size===0&&(this.rules.delete(r),this.deps.delete(r)));}this.strategy.updateComputedRules();}}setSideEffect(e){this.effectArray.push(e);}getSideEffect(){return [...this.effectArray]}evaluate(e){let n=null;if(e.GetToken&&(n=e.GetToken()),this.pendingPromise&&this.promiseToken!==n&&(this.pendingPromise=null,this.promiseToken=null),this.pendingPromise)return this.pendingPromise;let t=false;if(typeof e.triggerPath=="string"){t=true;let s=this.deps.get(e.triggerPath),a=e.getStateByPath(e.triggerPath);if(typeof s=="object"||typeof a=="object")t=false;else {let i=Array.from(this.deps.keys());for(let d of i){let l=this.deps.get(d),y=e.getStateByPath(d);if(l!==y){t=false;break}}}}if(t&&this.useCache)return this.cache;this.promiseToken=n;let o=++this.version,r=this.strategy.evaluate(e,o);if(!(r instanceof Promise)){let{res:s,version:a}=r;return this.finalizeSync(s,a,e,n)}return this.pendingPromise=(async()=>{try{let{res:s,version:a}=await r;return this.finalizeSync(s,a,e,n)}catch(s){throw {path:this.path,error:s}}finally{this.promiseToken===n&&(this.pendingPromise=null,this.promiseToken=null);}})(),this.pendingPromise}finalizeSync(e,n,t,o){return o!==this.promiseToken||n<this.version?this.cache:(this.cache=e,this.deps.forEach((r,s)=>{this.deps.set(s,t.GetRenderSchemaByPath(s));}),e)}inferType(e){return Array.isArray(e)?"array":typeof e}};var xe=(c,e,n)=>{let o=r=>{let s=n.triggerPaths.map(d=>{let l=r.GetRenderSchemaByPath(d),y={};return n.triggerKeys.forEach(m=>{y[m]=l[m];}),y}),a=Object.create(null);return Object.defineProperty(a,"triggerTargets",{get:()=>s}),Object.defineProperty(a,"affectedTatget",{get:()=>r.GetRenderSchemaByPath(c)[e]}),n.logic({slot:a})};return {value:n.value,targetPath:c,triggerPaths:n.triggerPaths,priority:n.priority??10,logic:o}},Ne=(c,e,n)=>{if(!c)throw Error("");let t=c,o=(a,i)=>{e.has(a)||e.set(a,new Set),e.get(a).add(i),n.has(i)||n.set(i,new Set),n.get(i).add(a);};return {SetRule:(a,i,d,l)=>{let y=t(i),m=l.triggerKeys||[];m.length==0&&m.push("value");let g=xe(i,d,{...l,triggerPaths:[a],triggerKeys:m}),u=[a].map(f=>[f,t(f).state.value]);if(o(a,i),y.nodeBucket[d])y.nodeBucket[d].setRule(g,u),l.effect&&y.nodeBucket[d].setSideEffect({fn:l.effect,args:l.effectArgs?l.effectArgs:[d]});else {let f=y.meta[d],P=new fe(f,d,i);P.setRule(g,u),l.effect&&P.setSideEffect({fn:l.effect,args:l.effectArgs?l.effectArgs:[d]}),y.nodeBucket[d]=P;}y.state[d]=y.meta[d],l.forceNotify&&y.nodeBucket[d].forceNotify(),l.cacheStrategy=="none"&&y.nodeBucket[d].setUseCache(false);},SetRules:(a,i,d,l)=>{let y=t(i);for(let f of a)o(f,i);let m=l.triggerKeys||[];m.length==0&&m.push("value");let g=xe(i,d,{...l,triggerPaths:a,triggerKeys:m}),u=a.map(f=>[f,t(f).state.value]);if(y.nodeBucket[d])y.nodeBucket[d].setRules(g,u),l.effect&&y.nodeBucket[d].setSideEffect({fn:l.effect,args:l.effectArgs?l.effectArgs:[d]});else {let f=y.meta[d],P=new fe(f,d,i);P.setRules(g,u),l.effect&&P.setSideEffect({fn:l.effect,args:l.effectArgs?l.effectArgs:[d]}),y.nodeBucket[d]=P;}y.state[d]=y.meta[d],l.forceNotify&&y.nodeBucket[d].forceNotify(),l.cacheStrategy=="none"&&y.nodeBucket[d].setUseCache(false);}}};var we=c=>{let e=c||void 0;if(!e)throw Error("");return {SetStrategy:(t,o,r)=>{e(t).nodeBucket[o].setStrategy(r);}}};function Re(){let c=new Map,e=new Map,n=new Set,t=(s,a)=>{c.set(s,a);let i=e.get(s);i&&i(a);};return {SetTrace:(s,a)=>{e.set(s,a);let i=c.get(s)||"idle";return a(i),{cancel:()=>{e.delete(s);}}},useTrace:()=>({apply:a=>{a.on("flow:start",()=>{n.forEach(i=>t(i,"idle")),n.clear(),c.clear();}),a.on("node:release",({path:i,type:d})=>{(d==1||d==2)&&(n.add(i),t(i,"pending"));}),a.on("node:pending",({path:i})=>{n.add(i),(!c.has(i)||c.get(i)==="idle")&&t(i,"pending");}),a.on("node:start",({path:i})=>{n.add(i),t(i,"calculating");}),a.on("node:success",({path:i})=>{t(i,"calculated");}),a.on("node:intercept",({path:i,type:d})=>{d==3&&t(i,"calculating"),d==6&&t(i,"idle");}),a.on("node:stagnate",({path:i})=>{t(i,"pending");}),a.on("node:error",({path:i})=>t(i,"error"));}})}}function Ee(c,e,n,t){let o=l=>{let y=c(),m=e(),g=new Set;return y.get(l)?.forEach(u=>g.add(u)),g.size===0?[]:Array.from(g).filter(u=>{let f=m.get(u)||new Set;return !Array.from(f).some(v=>g.has(v))})};return {GetNextDependency:l=>{let y=t();return Array.from(y.get(l)||[])},GetPrevDependency:l=>{let y=n();return Array.from(y.get(l)||[])},GetAllPrevDependency:l=>{let y=e();return Array.from(y.get(l)||[])},GetAllNextDependency:l=>{let y=c();return Array.from(y.get(l)||[])},rebuildDirectDependencyMaps:l=>{let y=new Map,m=new Map;for(let g of l){let u=o(g);y.set(g,new Set(u));for(let f of u)m.has(f)||m.set(f,new Set),m.get(f).add(g);}return {directNextMap:y,directPrevMap:m}}}}function be(c){let e=t=>{let o=[],r=[],s=new Map,a=t.size,i=0,d=0;for(let[l,y]of t)y===0&&r.push(l);if(r.length===0&&a>0)throw Error("Circular dependency detected");for(;r.length>0;){o.push([...r]);let l=[];for(let y of r){i++,s.set(y,d);let m=c.get(y);if(m)for(let g of m){let u=t.get(g)-1;t.set(g,u),u===0&&l.push(g);}}r=l,d++;}if(i<a)throw Error("Circular dependency detected");return {steps:o,levelMap:s}};return ()=>{let t=new Map;for(let o of c.keys()){let r=Array.from(c.get(o)||[]);t.has(o)||t.set(o,0);for(let s of r){let a=t.get(s)||0;t.set(s,++a);}}return e(t)}}var ce=()=>{let c=[];return {on:e=>(c.push(e),()=>{let n=c.indexOf(e);n>-1&&c.splice(n,1);}),call:e=>c.forEach(n=>{n(e);})}};function Ae(){let{on:c,call:e}=ce();return {onError:c,callOnError:e}}function Ge(){let{on:c,call:e}=ce();return {onSuccess:c,callOnSuccess:e}}var Oe=()=>{let c=new Set,e=new Map,n=(r,s)=>{e.get(r)?.forEach(a=>a(s));},t=(r,s)=>(e.has(r)||e.set(r,new Set),e.get(r).add(s),()=>e.get(r).delete(s));return {usePlugin:r=>{let s=new Set,a=(i,d)=>{let l=t(i,d);return s.add(l),l};return r.apply({on:a}),c.add(r),()=>{s.forEach(i=>i()),s.clear(),c.delete(r);}},emit:n}};function Fe(){let{on:c,call:e}=ce();return {onStart:c,callOnStart:e}}var Se=(t=>(t[t.CAUSALITY=0]="CAUSALITY",t[t.INVERSION=1]="INVERSION",t[t.REPERCUSSION=2]="REPERCUSSION",t))(Se||{});function Ke(c,e,n,t,o,r){let s=new Map,a=c.useGreedy;return async(d,l)=>{let m=Symbol("token"),g=d||"__NOTIFY_ALL__";s.set(g,m);let u=false;r.reset();let f=new Set,P=new Set,k=new Set;l.forEach(O=>{k.add(O),e.GetAllNextDependency(O).forEach(N=>k.add(N));});let v=new Map,T=new Map,$=new Map,D=[],b=n.Turnstile,_=b.volatileLevels.size>0,j=_?b.hasObserver:()=>false,Q=_?b.receiveGhosts:()=>[],G=_?b.resolveGhosts:()=>[],H=_?b.getTriggerKeys:()=>[],h=b?.volatileLevels||new Set,x=-1,p=new Set,M=e.GetPathToLevelMap(),w=0,I=0,L=O=>{e.GetAllNextDependency(O).forEach(ne=>{let V=M.get(ne)||0;V>I&&(I=V);});},W=new Set;d&&(f.add(d),W.add(d),L(d),o.flushPathSet.add(d));let re=d?[d]:l;r.shouldYield()&&(o.requestUpdate(),await r.yieldToMain());let de=re.map(async O=>{if(j(O)){let N=n.GetNodeByPath(O),ne=H(O);if(ne.length>0){let V=Q(N,ne);return V instanceof Promise&&(V=await V),{seed:O,hitTargets:V}}}return {seed:O,hitTargets:[]}});if((await Promise.all(de)).forEach(({seed:O,hitTargets:N})=>{if(N&&N.length>0){D.push(...N);let ne=M.get(O)||0;x=Math.max(x,ne);}}),(D.length>0||re.length>1)&&(o.requestUpdate(),await r.yieldToMain(),s.get(g)!==m))return;let le=D.length>0;l.forEach(O=>{if(!W.has(O))if(le){let N=M.get(O)??0;T.has(N)||T.set(N,new Set),T.get(N).add(O),t.emit("node:stagnate",{path:O,type:2});}else p.add(O),L(O);}),d?w=M.get(d)??0:w=Math.min(...l.map(O=>M.get(O)??0));let pe=performance.now();t.emit("flow:start",{path:g}),t.callOnStart({path:g});let ye=false,ge=30,Pe=O=>{let{target:N,trigger:ne}=O,V=false,ee=false,U=n.GetNodeByPath(N),se=U.calledBy,F=[],R=[],A=false;if(U.calledBy===1){A=true,V=true,o.flushPathSet.add(N);let S=$.get(N);S&&(F.push(...S),$.delete(N));}let E=(S,K)=>{let B=M.get(S)??0,Z=(se===1||se===2)&&B<=x;Z&&f.has(S)&&(f.delete(S),t.emit("node:revive",{path:S,triggerPath:N}));let z=0;if(!(f.has(S)||P.has(S)||p.has(S))){if(v.has(S))z=v.get(S)-1;else {if(B>w&&v.size>ge){T.has(B)||T.set(B,new Set),T.get(B).add(S),t.emit("node:intercept",{path:S,type:7});return}let te=e.GetPrevDependency(S),J=0;for(let ae of te){if(f.has(ae))continue;(M.get(ae)??0)>w&&J++;}z=J;}if(z<=0){let te=p.has(S),J=P.has(S);if(te||J){t.emit("node:intercept",{path:S,type:J?3:3.1});return}v.delete(S);let ae=n.GetNodeByPath(S);Z?ae.calledBy=2:ae.calledBy=0,p.add(S),t.emit("node:release",{path:S,type:K,detail:{path:N}});}else v.set(S,z);}},C=(S=[])=>{if(s.get(g)!==m)return;if(S.length){let B={},Z=U.proxy;for(let z of S){let te=(z.args||[]).reduce((J,ae)=>(J[ae]=Z[ae],J),{});try{let J=z.fn(te);J&&typeof J=="object"&&Object.assign(B,J);}catch(J){}}for(let z in B)if(z in U.state)Object.is(U.state[z],B[z])||(U.state[z]=B[z],F.push(z));else throw {error:`wrong effect in ${String(U.path)}`};V=true;}V&&o.flushPathSet.add(N);let K=(B=[])=>{if(s.get(g)!==m)return;B&&B.length>0&&(D.push(...B),x=Math.max(x,M.get(N)||0)),F.length=0,t.emit("node:success",{path:N,calledBy:U.calledBy}),f.add(N);let Z=e.GetNextDependency(N);(V||ee)&&e.GetAllNextDependency(N).forEach(oe=>k.add(oe));let z=n.GetNodeByPath(N),te=M.get(N)??0,J=h.has(te)||D.length>0;for(let q of Z){let oe=M.get(q)??0;if(J&&oe>=te){T.has(oe)||T.set(oe,new Set),T.get(oe).add(q),t.emit("node:stagnate",{path:q,type:2});continue}if(f.has(q)){t.emit("node:intercept",{path:q,type:2});continue}if(P.has(q)||p.has(q)){t.emit("node:intercept",{path:q,type:P.has(q)?3:3.1});continue}if(V||ee)E(q,1);else if(v.has(q))E(q,2);else {let me=M.get(q);T.has(me)||T.set(me,new Set);let ve=T.get(me);ve.has(q)||(ve.add(q),t.emit("node:stagnate",{path:q,type:1}));}}P.delete(N),z.calledBy=0,(async()=>{if(!u){let q=P.size,oe=p.size;t.emit("flow:fire",{path:N,type:1,detail:{active:q,pending:oe,blocked:v.size}}),ue();}})();};if(j(N)&&F.length>0){let B=n.GetNodeByPath(N),Z=Q(B,F);Z instanceof Promise||Z&&typeof Z.then=="function"?Z.then(K).catch(Y):K(Z);}else K([]);},Y=S=>{t.emit("node:error",{path:N,error:S});let K=Symbol("abort");s.set(g,K),p.clear(),v.clear(),P.clear(),t.callOnError(S);},X=(S,K)=>{let B=false;S!==U.state[K]&&(U.state[K]=S,V=true,F.push(String(K)),t.emit("node:bucket:success",{path:N,key:String(K),value:S,calledBy:U.calledBy}),U.notifyKeys.has(K)&&(B=true)),U.nodeBucket[K].isForceNotify()&&(ee=true),(B||ee)&&L(N);};t.emit("node:start",{path:N,calledBy:U.calledBy});try{let S=[];for(let K in U.nodeBucket){let B=U.nodeBucket[K];if(S.push(...B.getSideEffect()),A){t.emit("node:bucket:success",{path:N,key:String(K),value:U.state[K],calledBy:U.calledBy}),B.isForceNotify()&&(ee=!0),U.notifyKeys.has(K)&&L(N);continue}let Z=B.evaluate({affectKey:K,triggerPath:ne,GetRenderSchemaByPath:z=>n.GetNodeByPath(z).proxy,getStateByPath:z=>n.GetNodeByPath(z).state,GetToken:()=>m});if(Z instanceof Promise){let z=Z.then(te=>{s.get(g)===m&&X(te,K);});R.push(z);}else X(Z,K);}if(R.length>0)return Promise.all(R).then(()=>{C(S);}).catch(Y);C(S);return}catch(S){Y(S);}},ue=async()=>{if(s.get(g)!==m){u=false;return}u=true;let O=r.getIsFirstFrame(),N=0,ne=()=>a&&O?30:1/0,V=0,ee=ne();try{for(;s.get(g)===m;){let U=V>=ee,se=r.shouldYield();if(U||se){if(V>0&&(N++,(O||N%2===0)&&o.requestUpdate()),await r.yieldToMain(),s.get(g)!==m)break;V=0,O=r.getIsFirstFrame();}if(p.size>0&&P.size<40){for(let F of p){if(P.size>=40||V>=ee)break;let R=M.get(F)??0,A=e.GetPrevDependency(F),E=A.length>1;if((!a||E)&&R>w){p.delete(F);let X=A.filter(S=>k.has(S)&&!f.has(S)).length;v.set(F,X||0),t.emit("node:intercept",{path:F,type:X>0?4:5,detail:{targetLevel:R,currentLevel:w,pendingParentsCount:X}});continue}p.delete(F),P.add(F);let Y=n.GetNodeByPath(F);if(t.emit("node:processing",{path:F,calledBy:Y.calledBy}),Pe({target:F,trigger:d}),V++,V>=ee||r.shouldYield())break}if(p.size>0)continue}if(V<ee&&a&&v.size>0&&P.size<40){let F=!1,R=0;for(let[A,E]of v)if(E<=0){let C=M.get(A)??0,Y=e.GetPrevDependency(A);if(C>w&&Y.length>1)continue;if(v.delete(A),p.add(A),R++,F=!0,t.emit("node:release",{path:A,type:4}),R>=ee)break}if(R>0)continue;if(F){if(r.shouldYield()&&(await r.yieldToMain(),s.get(g)!==m))break;continue}}if(P.size===0&&p.size===0){if(D.length>0){let E=!1,C=w,Y=Array.from(new Set(D));D.length=0;for(let X of Y){let S=n.GetNodeByPath(X),K=G(S);if(K&&K.length>0){E=!0,S.calledBy=1,$.set(X,K),f.delete(X),v.delete(X),p.add(X);let B=M.get(X)??0;B<C&&(C=B),L(X),o.flushPathSet.add(X);}}if(E){if(C<w&&(w=C),o.requestUpdate(),r.shouldYield()&&(await r.yieldToMain(),s.get(g)!==m))break;continue}}let F=new Set;for(let E of T.keys())F.add(E);for(let[E]of v){let C=M.get(E)??0;C>w&&F.add(C);}let R=Array.from(F).sort((E,C)=>E-C),A=R[0];if(R.length>0&&A<=I){let E=R[0];if(E<=I){w=E;let C=T.get(E);C&&(C.forEach(Y=>p.add(Y)),T.delete(E));for(let[Y]of v)(M.get(Y)??0)===E&&(v.delete(Y),p.add(Y),t.emit("node:release",{path:Y,type:3,detail:{level:E}}));continue}}else {T.forEach((E,C)=>{E.forEach(Y=>{f.add(Y),t.emit("node:intercept",{path:Y,type:6});});}),T.clear();for(let[E]of v)f.add(E),t.emit("node:intercept",{path:E,type:6});v.clear();break}}p.size>0&&P.size>=40&&t.emit("flow:wait",{type:2});break}}finally{u=false;let U=P.size+v.size+p.size,se=b.inFlightCount||0;if(o.requestUpdate(),U===0&&se===0){if(s.get(g)===m&&!ye){ye=true,t.emit("flow:end",{type:1}),b.resetCounters();let F=performance.now();x=-1,t.emit("flow:success",{duration:(F-pe).toFixed(2.1)+"ms"}),Promise.resolve().then(()=>{t.callOnSuccess();});}}else {let F=U===0&&se>0?3:1;t.emit("flow:wait",{type:F,detail:{nums:P.size,asyncNums:se}});}}};ue();}}function Te(c){let{path:e,uid:n,type:t,meta:o,dirtySignal:r,state:s}=c,a=null,i=["path","uid","type","dependOn","nodeBucket"],l={path:e,uid:n,type:t,meta:o,dirtySignal:r,createView:(y={})=>{if(a&&Object.keys(y).length===0)return a;let m=new Proxy(y,{get(g,u){let f=u;return Reflect.has(g,u)?Reflect.get(g,u):f in c.state?c.state[f]:f in c?c[f]:o&&f in o?o[f]:Reflect.get(g,u)},set(g,u,f){let P=u;return P in c.state?(c.state[P]=f,true):Reflect.set(g,u,f)},ownKeys(g){let u=new Set([...Reflect.ownKeys(g),...Object.keys(s||{}),...Object.keys(o||{}),...i]);return Array.from(u)},getOwnPropertyDescriptor(g,u){let f=u;return Reflect.has(g,u)||s&&f in s||o&&f in o||i.includes(f)?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(g,u)}});return a=m,m}};return "children"in c?{...l,children:c.children}:{...l,state:c.state,nodeBucket:c.nodeBucket,notifyKeys:c.notifyKeys,dependOn:c.dependOn,calledBy:0,get proxy(){return a}}}var Ie=(c={frameQuota:12})=>{let e=performance.now(),n=0,t=false,o=()=>!!navigator?.scheduling?.isInputPending?.({includeContinuous:true});return {getIsFirstFrame:()=>t,reset(){e=performance.now(),n=0,t=true;},shouldYield(){let r=performance.now();return n++,!!((n>=5||t)&&(n=0,r-e>c.frameQuota||o()))},async yieldToMain(){return new Promise(r=>{Ue(()=>{e=performance.now(),n=0,t&&(t=false),r();});})}}},Ue=c=>{let{port1:e,port2:n}=new MessageChannel;e.onmessage=c,n.postMessage(null);};var Ce=(c,e,n,t,o)=>{let r=c.useEntangleStep,s=new Map,a=new Map,i=new Set,d=t,l=0;return {useEntangle:u=>{let{observer:f,target:P,triggerKeys:k,emit:v}=u;if(!k||k.length===0){o.emit("entangle:warn",{path:f,type:"no_keys"});return}s.has(f)||s.set(f,new Map);let T=s.get(f);k.forEach($=>{T.has($)||T.set($,[]),T.get($).push({target:P,emit:v,count:0});});},updateEntangleLevel:()=>{let u=n();if(!(!u||u.size===0)){i.clear();for(let f of s.keys()){let P=u.get(f);P!==void 0?i.add(P):o.emit("entangle:warn",{path:f,type:"no_level"});}}},Turnstile:{volatileLevels:i,get inFlightCount(){return l},get hasPendingGhosts(){for(let u of a.values())if(u.length>0)return true;return false},hasObserver:u=>s.has(u),getTriggerKeys:u=>{let f=s.get(u);return f?Array.from(f.keys()):[]},receiveGhosts:(u,f=[])=>{let P=u.path,k=[],v=s.get(P);if(!v||f.length===0)return k;let T=new Set;f.forEach(G=>{let H=v.get(G);H&&H.forEach(h=>T.add(h));});let $=G=>G instanceof Promise||G!==null&&typeof G=="object"&&typeof G.then=="function",D=G=>{let H=G.target;if(G.count>=r){o.emit("entangle:blocked",{observer:P,target:H,count:G.count});return}let h=d(H),x=G.emit(u.proxy,h.proxy),p=M=>{M&&M.key!==void 0&&(G.count++,a.has(H)||a.set(H,[]),a.get(H).push({weight:1,...M}),k.push(H));};if($(x))return l++,(async()=>{try{let M=await x;p(M);}catch(M){o.emit("node:error",{path:P,error:M}),o.onError({path:P,error:M});}finally{l--;}})();p(x);},b=Array.from(T),_=0,j=false,Q=null;for(;_<b.length;_++){if(e.shouldYield()){j=true;break}let G=D(b[_]);if(G){Q=G,j=true,_++;break}}return j?(async()=>{Q&&await Q,e.shouldYield()&&await e.yieldToMain();let G=50;for(;_<b.length;_+=G){let H=b.slice(_,_+G),h=[];for(let x of H){let p=D(x);p&&h.push(p);}if(h.length>0){let x=h.map(async p=>{await p,e.shouldYield()&&await e.yieldToMain();});await Promise.all(x);}e.shouldYield()&&await e.yieldToMain();}return Array.from(new Set(k))})():Array.from(new Set(k))},resolveGhosts:u=>{let f=u.path,P=a.get(f);if(!P||P.length===0)return [];let k=[],v=new Map;for(let T of P)v.has(T.key)||v.set(T.key,[]),v.get(T.key).push(T);for(let[T,$]of v.entries()){let D=u.state[T],b=$.filter(j=>j.delta!==void 0),_=$.filter(j=>j.value!==void 0);if(_.length>0&&(D=_.reduce((Q,G)=>(G.weight??1)>=(Q.weight??1)?G:Q).value),b.length>0){let j=b.reduce((G,H)=>G+H.delta,0),Q=(typeof D=="number"?D:0)+j;D=Math.max(0,parseFloat(Q.toFixed(6)));}Object.is(u.state[T],D)||(u.state[T]=D,k.push(T));}return a.set(f,[]),k.length>0?k:[]},resetCounters:()=>{for(let u of s.values())for(let f of u.values())f.forEach(P=>P.count=0);}}}};function Be(c,e,n,t,o){let r=Ie(),s=0,a=new Map,i=[],d=[],l=false,y=new Set,g=async()=>{let h=Array.from(y);if(y.clear(),"signalTrigger"in o&&typeof o.signalTrigger=="function")for(let x of h){let p=b(x);o.signalTrigger(p.dirtySignal);}else "emit"in o&&o.emit(h);},u=()=>{l||(l=true,requestAnimationFrame(()=>{try{for(;y.size>0;)g();}finally{l=false;}}));},{useEntangle:f,updateEntangleLevel:P,Turnstile:k}=Ce({useEntangleStep:c.useEntangleStep},r,e.GetPathToLevelMap,b,{emit:t.emit,onError:t.callOnError}),v=Ke({useGreedy:c.useGreedy},e,{GetNodeByPath:b,Turnstile:k},t,{requestUpdate:u,flushPathSet:y},r),T=h=>{throw new Error(`[MeshFlow] Duplicate Path: ${h}`)},$=h=>{a.has(h.path)&&T(String(h.path));let x=++s,p={path:h.path,getNode:I=>b(I)},M=(I,L="value")=>{let W=I({...p}),re=b(h.path);if(n.createHistoryAction&&n.pushIntoHistory){let de=n.createHistoryAction([{path:h.path,value:re.state[L]},{path:h.path,value:W}],ie=>{let le=b(ie.path);le.state[L]=ie.value,j(ie.path);});n.pushIntoHistory(de);}re.state[L]=W,j(h.path);};h.notifyKeys.size==0&&h.notifyKeys.add("value");let w=Te({uid:x,type:h.type,path:h.path,state:h.state,meta:h.meta,nodeBucket:h.nodeBucket,dirtySignal:"signalCreator"in o?o.signalCreator():void 0,notifyKeys:h.notifyKeys,dependOn:M});return a.set(w.path,x),i[x]=w,w},D=h=>{a.has(h.path)&&T(String(h.path));let x=++s,p=Te({uid:x,type:h.type,path:h.path,state:{},meta:h,nodeBucket:{},children:h.children});return a.set(p.path,x),d[x]=p,p};function b(h){let x=a.get(h),p=i[x];if(!p)throw Error("wrong ID");return p}function _(h){let x=a.get(h);return d[x]}let j=h=>{if(!b(h))throw Error("Node undefined");y.add(h),u();let p=e.GetNextDependency(h);Q(p,h);};function Q(h,x){v(x,h);}return {registerNode:$,registerGroupNode:D,GetNodeByPath:b,GetGroupByPath:_,notify:j,notifyAll:async()=>{Promise.resolve().then(async()=>{let h=e.GetDependencyOrder();if(!h||h.length===0)return;let x=h[0];try{v(null,x);}catch(p){throw t.callOnError(p),p}finally{u();}});},batchNotify:h=>{if(!h||h.length===0)return;if(n.createHistoryAction&&n.pushIntoHistory){let p=n.createHistoryAction([h.map(M=>({path:M.path,key:M.key,value:b(M.path).state[M.key]})),h.map(M=>({path:M.path,key:M.key,value:M.value}))],M=>{let w=new Set;M.forEach(I=>{let L=b(I.path);L.state[I.key]=I.value,y.add(I.path),w.add(I.path);}),u(),w.size>0&&v(null,Array.from(w));});n.pushIntoHistory(p);}let x=new Set;h.forEach(p=>{let M=b(p.path);M.state[p.key]=p.value,y.add(p.path),x.add(p.path);}),u(),x.size>0&&v(null,Array.from(x));},useEntangle:f,updateEntangleLevel:P,UITrigger:o,UidToNodeMap:i}}function ke(c,e){let n=false,t=false,o=new Map,r=new Map,s=new Map,a=new Map,i=[],d=new Map,{GetNextDependency:y,GetPrevDependency:m,GetAllPrevDependency:g,GetAllNextDependency:u,rebuildDirectDependencyMaps:f}=Ee(()=>o,()=>r,()=>a,()=>s),P={},k={};if(e.modules.useHistory){let R=e.modules.useHistory,A;R.isMeshModuleInited?A=R:A=R();let{Undo:E,Redo:C,PushIntoHistory:Y,CreateHistoryAction:X,updateUndoSize:S,updateRedoSize:K}=A();P.pushIntoHistory=Y,P.createHistoryAction=X,k={Undo:E,Redo:C,updateUndoSize:S,updateRedoSize:K};}let v=!!e.modules.useMeshRenderGate,T={};if(v){let R=e.modules.useMeshRenderGate.isMeshModuleInited,A=e.modules.useMeshRenderGate;T=(R?A:A())(()=>L);}let{onError:$,callOnError:D}=Ae(),{onSuccess:b,callOnSuccess:_}=Ge(),{onStart:j,callOnStart:Q}=Fe(),{emit:G,usePlugin:H}=Oe(),{SetTrace:h,useTrace:x}=Re(),p=x();H(p);let M=v?{...T}:{...e.UITrigger},w=Be({useGreedy:e.config.useGreedy,useEntangleStep:e.config.useEntangleStep||100},{GetDependencyOrder:()=>i,GetAllNextDependency:u,GetNextDependency:y,GetPrevDependency:m,GetAllPrevDependency:g,GetPathToLevelMap:()=>d},P,{callOnError:D,callOnSuccess:_,callOnStart:Q,emit:G},M),{GetGroupByPath:I,GetNodeByPath:L,notifyAll:W,useEntangle:re,updateEntangleLevel:de}=w;v&&T.init();let ie={};if(e.modules.useInternalForm){let{uiSchema:R,GetFormData:A}=e.modules.useInternalForm(w,c);ie={uiSchema:R,GetFormData:A};}let le={};if(e.modules.useSchemaValidators){let{SetValidators:R}=e.modules.useSchemaValidators(L);le={SetValidators:R};}let{SetRule:pe,SetRules:ye}=Ne(L,o,r),{SetStrategy:ge}=we(L),Pe=be(o),ue=()=>{let R=Pe();i=R.steps,d=R.levelMap,de();},O=()=>{t||(t=true,Promise.resolve().then(()=>{if(ue(),n){let{directNextMap:R,directPrevMap:A}=f(i.flat());s=R,a=A;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(R,A,E,C)=>{pe(R,A,E,C),n=true,O();},SetRules:(R,A,E,C)=>{ye(R,A,E,C),n=true,O();},SetStrategy:ge,useEntangle:re,SetTrace:h,usePlugin:H,SetValue:(R,A,E)=>{L(R).dependOn(()=>E,A);},GetValue:(R,A="value")=>L(R).proxy[A],SetValues:R=>{w.batchNotify(R);},GetGroupByPath:I,notifyAll:async()=>{ue(),await W();},GetAllDependency:()=>o,GetDependencyOrder:()=>i,historyExports:k,formExports:ie,validatorExports:le,batchRenderExport:T,hasRenderGate:()=>v,onError:$,onSuccess:b,onStart:j,scheduler:w}}var he=new Map,De=(c,e,n)=>{try{if(he.has(c))throw Error("engineID repeated");let t=ke(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules??{},plugins:{}}),{SetRule:o,SetRules:r,SetValues:s,SetStrategy:a,SetValue:i,GetValue:d,usePlugin:l,useEntangle:y,GetGroupByPath:m,notifyAll:g,SetTrace:u,GetAllDependency:f,GetDependencyOrder:P,historyExports:k,formExports:v,validatorExports:T,batchRenderExport:$,hasRenderGate:D,onError:b,onSuccess:_,onStart:j,scheduler:Q}=t,G={config:{SetRule:o,SetRules:r,SetStrategy:a,notifyAll:g,SetTrace:u,usePlugin:l,hasRenderGate:D,useEntangle:y},data:{SetValue:i,GetValue:d,SetValues:s,GetGroupByPath:m},dependency:{GetAllDependency:f,GetDependencyOrder:P},hooks:{onError:b,onSuccess:_,onStart:j}},H=(p,M,w)=>{!M||typeof M!="object"||Object.keys(M).forEach(I=>{let L=M[I];if(typeof L=="object"&&L!==null)p[I]=p[I]||{},H(p[I],L,w);else if(typeof L=="function"){let W=I;if(W==="useMeshRenderGate")W="render";else if(W.startsWith("use")){let re=W.slice(3);W=re.charAt(0).toLowerCase()+re.slice(1);}I==="useHistory"&&w.exports.history&&Object.keys(w.exports.history).length>0?p[W]=w.exports.history:I==="useInternalForm"&&w.exports.form&&Object.keys(w.exports.form).length>0?p[W]=w.exports.form:I==="useSchemaValidators"&&w.exports.validator&&Object.keys(w.exports.validator).length>0?p[W]=w.exports.validator:I==="useMeshRenderGate"&&w.exports.render?p[W]=w.exports.render:p[W]=L(w.scheduler,w.Schema);}});},h={...G,modules:{}},x=n.modules;return x&&H(h.modules,x,{scheduler:Q,Schema:e,exports:{history:k,form:v,validator:T,render:$}}),he.set(c,h),h}catch(t){throw Error(t)}},At=()=>(c,e,n)=>Le(c,e,n),Gt=c=>{let e=he.get(c);if(!e)throw Error(`[MeshFlow] Engine ID "${String(c)}" not found. Ensure it is initialized with useMeshFlow.`);return e},Ot=c=>{he.delete(c);},Le=De;exports.TriggerCause=Se;exports.deleteEngine=Ot;exports.useEngine=Gt;exports.useEngineManager=De;exports.useMeshFlow=Le;exports.useMeshFlowDefiner=At;exports.useScheduler=Be;
|
|
1
|
+
'use strict';var we=(t=>(t.OR="OR",t.PRIORITY="PRIORITY",t.MERGE="MERGE",t))(we||{}),Te=class{computedRules=[];store={OR:(e,n)=>{let t,i,l=this.computedRules;for(let o=0;o<l.length;o++){let s=l[o],r=s.logic(e);if(r instanceof Promise)return (async()=>{let a=await r;if(s.entityId==="__base__"?i=a:a&&(t=a),typeof t>"u")for(let c=o+1;c<l.length;c++){let w=l[c],h=w.logic(e),p=h instanceof Promise?await h:h;if(w.entityId==="__base__"){i=p;continue}if(p){t=w.value;break}}return typeof t>"u"&&(t=i),{res:t,version:n}})();let u=r;if(s.entityId==="__base__"){i=u;continue}if(u){t=s.value;break}}return typeof t>"u"&&(t=i),{res:t,version:n}},PRIORITY:(e,n)=>{let t,i=this.computedRules;for(let l=0;l<i.length;l++){let s=i[l].logic(e);if(s instanceof Promise)return (async()=>{let r=await s;if(r!==void 0)return {res:r,version:n};for(let u=l+1;u<i.length;u++){let a=i[u].logic(e),c=a instanceof Promise?await a:a;if(c!==void 0)return {res:c,version:n}}return {res:void 0,version:n}})();if(s!==void 0)return {res:s,version:n}}return {res:t,version:n}},MERGE:(e,n)=>{let t,i,l=this.computedRules,o=(r,u)=>r===void 0?u:u===void 0?r:Array.isArray(r)&&Array.isArray(u)?[...u,...r]:typeof r=="object"&&typeof u=="object"?{...u,...r}:r;for(let r=0;r<l.length;r++){let u=l[r],a=u.logic(e);if(a instanceof Promise)return (async()=>{let w=await a,h=(f,g)=>{if(f.entityId==="__base__")i=o(i,g);else if(g){let x=f.value!==void 0?f.value:g;t=o(t,x);}};h(u,w);for(let f=r+1;f<l.length;f++){let g=l[f],x=g.logic(e),O=x instanceof Promise?await x:x;h(g,O);}return {res:o(t,i),version:n}})();let c=a;if(u.entityId==="__base__"){i=o(i,c);continue}if(c){let w=u.value!==void 0?u.value:c;t=o(t,w);}}return {res:o(t,i),version:n}}};CurrentStrategy=()=>{};CurrentStrategyType="PRIORITY";getRules=()=>{};constructor(e){this.getRules=e,this.CurrentStrategy=this.store.PRIORITY,this.updateComputedRules();}updateComputedRules(){let e=this.getRules();this.CurrentStrategyType==="PRIORITY"||this.CurrentStrategyType==="MERGE"?this.computedRules=Array.from(e.values()).map(n=>Array.from(n)).flat().sort((n,t)=>t.priority-n.priority):this.computedRules=Array.from(e.values()).map(n=>Array.from(n)).flat();}setStrategy(e){this.CurrentStrategyType=e,this.CurrentStrategy=this.store[e],this.updateComputedRules();}evaluate(e,n){return this.CurrentStrategy(e,n)}},ye=class{path;strategy;contract;rules=new Map;isValue=false;id=0;cache=void 0;pendingPromise=null;version=0;deps=new Map;_forceNotify=false;promiseToken=null;useCache=true;effectArray=[];constructor(e,n,t){let i=()=>this.rules;this.strategy=new Te(i),this.path=t,this.isValue=n==="value",this.contract=this.inferType(e),this.cache=e,this.setRule({priority:0,entityId:"__base__",logic:()=>e});}setUseCache(e){this.useCache=e;}forceNotify(){this._forceNotify=true;}isForceNotify(){return this._forceNotify}setStrategy(e){this.strategy.setStrategy(e);}setDefaultRule(e){let n=new Set;n.add(e),this.rules.set("defaultRules",n);}setRules(e,n){n&&this.updateDeps(n);let t=++this.id,i={...e,entityId:t};for(let l of e.triggerPaths)this.rules.has(l)||this.rules.set(l,new Set),this.rules.get(l).add(i);return this.strategy.updateComputedRules(),()=>{for(let l of e.triggerPaths){let o=this.rules.get(l);o&&(o.delete(i),o.size===0&&(this.rules.delete(l),this.deps.delete(l)));}this.strategy.updateComputedRules();}}updateDeps(e){for(let[n,t]of e)this.deps.set(n,t);}setRule(e,n){if(n&&this.updateDeps(n),typeof e.entityId=="string"){this.setDefaultRule(e);return}let t=++this.id,i={...e,entityId:t};if(e)for(let l of e.triggerPaths)this.rules.has(l)||this.rules.set(l,new Set),this.rules.get(l).add(i);return this.strategy.updateComputedRules(),()=>{for(let l of e.triggerPaths){let o=this.rules.get(l);o&&(o.delete(i),o.size===0&&(this.rules.delete(l),this.deps.delete(l)));}this.strategy.updateComputedRules();}}setSideEffect(e){this.effectArray.push(e);}getSideEffect(){return [...this.effectArray]}evaluate(e){let n=null;if(e.GetToken&&(n=e.GetToken()),this.pendingPromise&&this.promiseToken!==n&&(this.pendingPromise=null,this.promiseToken=null),this.pendingPromise)return this.pendingPromise;let t=false;if(typeof e.triggerPath=="string"){t=true;let o=this.deps.get(e.triggerPath),s=e.getStateByPath(e.triggerPath);if(typeof o=="object"||typeof s=="object")t=false;else {let r=Array.from(this.deps.keys());for(let u of r){let a=this.deps.get(u),c=e.getStateByPath(u);if(a!==c){t=false;break}}}}if(t&&this.useCache)return this.cache;this.promiseToken=n;let i=++this.version,l=this.strategy.evaluate(e,i);if(!(l instanceof Promise)){let{res:o,version:s}=l;return this.finalizeSync(o,s,e,n)}return this.pendingPromise=(async()=>{try{let{res:o,version:s}=await l;return this.finalizeSync(o,s,e,n)}catch(o){throw {path:this.path,error:o}}finally{this.promiseToken===n&&(this.pendingPromise=null,this.promiseToken=null);}})(),this.pendingPromise}finalizeSync(e,n,t,i){return i!==this.promiseToken||n<this.version?this.cache:(this.cache=e,this.deps.forEach((l,o)=>{this.deps.set(o,t.GetRenderSchemaByPath(o));}),e)}inferType(e){return Array.isArray(e)?"array":typeof e}};var Re=(d,e,n)=>{let i=l=>{let o=n.triggerPaths.map(u=>{let a=l.GetRenderSchemaByPath(u),c={};return n.triggerKeys.forEach(w=>{c[w]=a[w];}),c}),s=Object.create(null);return Object.defineProperty(s,"triggerTargets",{get:()=>o}),Object.defineProperty(s,"affectedTatget",{get:()=>l.GetRenderSchemaByPath(d)[e]}),n.logic({slot:s})};return {value:n.value,targetPath:d,triggerPaths:n.triggerPaths,priority:n.priority??10,logic:i}},be=(d,e,n)=>{if(!d)throw Error("");let t=d,i=(s,r)=>{e.has(s)||e.set(s,new Set),e.get(s).add(r),n.has(r)||n.set(r,new Set),n.get(r).add(s);};return {SetRule:(s,r,u,a)=>{let c=t(r),w=a.triggerKeys||[];w.length==0&&w.push("value");let h=Re(r,u,{...a,triggerPaths:[s],triggerKeys:w}),p=[s].map(f=>[f,t(f).state.value]);if(i(s,r),c.nodeBucket[u])c.nodeBucket[u].setRule(h,p),a.effect&&c.nodeBucket[u].setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[u]});else {let f=c.meta[u],g=new ye(f,u,r);g.setRule(h,p),a.effect&&g.setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[u]}),c.nodeBucket[u]=g;}c.state[u]=c.meta[u],a.forceNotify&&c.nodeBucket[u].forceNotify(),a.cacheStrategy=="none"&&c.nodeBucket[u].setUseCache(false);},SetRules:(s,r,u,a)=>{let c=t(r);for(let f of s)i(f,r);let w=a.triggerKeys||[];w.length==0&&w.push("value");let h=Re(r,u,{...a,triggerPaths:s,triggerKeys:w}),p=s.map(f=>[f,t(f).state.value]);if(c.nodeBucket[u])c.nodeBucket[u].setRules(h,p),a.effect&&c.nodeBucket[u].setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[u]});else {let f=c.meta[u],g=new ye(f,u,r);g.setRules(h,p),a.effect&&g.setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[u]}),c.nodeBucket[u]=g;}c.state[u]=c.meta[u],a.forceNotify&&c.nodeBucket[u].forceNotify(),a.cacheStrategy=="none"&&c.nodeBucket[u].setUseCache(false);}}};var Ae=d=>{let e=d||void 0;if(!e)throw Error("");return {SetStrategy:(t,i,l)=>{e(t).nodeBucket[i].setStrategy(l);}}};function Ge(){let d=new Map,e=new Map,n=new Set,t=(o,s)=>{d.set(o,s);let r=e.get(o);r&&r(s);};return {SetTrace:(o,s)=>{e.set(o,s);let r=d.get(o)||"idle";return s(r),{cancel:()=>{e.delete(o);}}},useTrace:()=>({apply:s=>{s.on("flow:start",()=>{n.forEach(r=>t(r,"idle")),n.clear(),d.clear();}),s.on("node:release",({path:r,type:u})=>{(u==1||u==2)&&(n.add(r),t(r,"pending"));}),s.on("node:pending",({path:r})=>{n.add(r),(!d.has(r)||d.get(r)==="idle")&&t(r,"pending");}),s.on("node:start",({path:r})=>{n.add(r),t(r,"calculating");}),s.on("node:success",({path:r})=>{t(r,"calculated");}),s.on("node:intercept",({path:r,type:u})=>{u==3&&t(r,"calculating"),u==6&&t(r,"idle");}),s.on("node:stagnate",({path:r})=>{t(r,"pending");}),s.on("node:error",({path:r})=>t(r,"error"));}})}}function Oe(d,e,n,t){let i=a=>{let c=d(),w=e(),h=new Set;return c.get(a)?.forEach(p=>h.add(p)),h.size===0?[]:Array.from(h).filter(p=>{let f=w.get(p)||new Set;return !Array.from(f).some(O=>h.has(O))})};return {GetNextDependency:a=>{let c=t();return Array.from(c.get(a)||[])},GetPrevDependency:a=>{let c=n();return Array.from(c.get(a)||[])},GetAllPrevDependency:a=>{let c=e();return Array.from(c.get(a)||[])},GetAllNextDependency:a=>{let c=d();return Array.from(c.get(a)||[])},rebuildDirectDependencyMaps:a=>{let c=new Map,w=new Map;for(let h of a){let p=i(h);c.set(h,new Set(p));for(let f of p)w.has(f)||w.set(f,new Set),w.get(f).add(h);}return {directNextMap:c,directPrevMap:w}}}}function Fe(d){let e=t=>{let i=[],l=[],o=new Map,s=t.size,r=0,u=0;for(let[a,c]of t)c===0&&l.push(a);if(l.length===0&&s>0)throw Error("Circular dependency detected");for(;l.length>0;){i.push([...l]);let a=[];for(let c of l){r++,o.set(c,u);let w=d.get(c);if(w)for(let h of w){let p=t.get(h)-1;t.set(h,p),p===0&&a.push(h);}}l=a,u++;}if(r<s)throw Error("Circular dependency detected");return {steps:i,levelMap:o}};return ()=>{let t=new Map;for(let i of d.keys()){let l=Array.from(d.get(i)||[]);t.has(i)||t.set(i,0);for(let o of l){let s=t.get(o)||0;t.set(o,++s);}}return e(t)}}var ue=()=>{let d=[];return {on:e=>(d.push(e),()=>{let n=d.indexOf(e);n>-1&&d.splice(n,1);}),call:e=>d.forEach(n=>{n(e);})}};function Ke(){let{on:d,call:e}=ue();return {onError:d,callOnError:e}}function Ie(){let{on:d,call:e}=ue();return {onSuccess:d,callOnSuccess:e}}var Ce=()=>{let d=new Set,e=new Map,n=new Set,t=(s,r)=>{e.get(s)?.forEach(u=>u(r));},i=(s,r)=>(e.has(s)||e.set(s,new Set),e.get(s).add(r),()=>e.get(s)?.delete(r));return {usePlugin:s=>{let r=new Set,u=(c,w)=>{let h=i(c,w);return r.add(h),h};s.apply({on:u}),d.add(s);let a=()=>{r.forEach(c=>c()),r.clear(),d.delete(s),n.delete(a);};return n.add(a),a},emit:t,destroyPlugin:()=>{n.forEach(s=>s()),n.clear(),e.clear(),d.clear();}}};function ke(){let{on:d,call:e}=ue();return {onStart:d,callOnStart:e}}var Be=(d={frameQuota:12})=>{let e=performance.now(),n=0,t=false,i=()=>!!navigator?.scheduling?.isInputPending?.({includeContinuous:true});return {getIsFirstFrame:()=>t,reset(){e=performance.now(),n=0,t=true;},shouldYield(){let l=performance.now();return n++,!!((n>=5||t)&&(n=0,l-e>d.frameQuota||i()))},async yieldToMain(){return new Promise(l=>{ve(()=>{e=performance.now(),n=0,t&&(t=false),l();});})}}},ve=d=>{let{port1:e,port2:n}=new MessageChannel;e.onmessage=d,n.postMessage(null);};var xe=(t=>(t[t.CAUSALITY=0]="CAUSALITY",t[t.INVERSION=1]="INVERSION",t[t.REPERCUSSION=2]="REPERCUSSION",t))(xe||{});function Ue(d,e,n,t,i,l){let o=new Map,s=d.useGreedy,r=null;return async(a,c)=>{let h=Symbol("token"),p=a||"__NOTIFY_ALL__";o.set(p,h),r=h;let f=false;l.reset();let g=new Set,x=new Set,O=new Set;c.forEach(C=>{O.add(C),e.GetAllNextDependency(C).forEach(v=>O.add(v));});let G=new Map,R=new Map,V=new Map,b=[],L=n.Turnstile,k=L.volatileLevels.size>0,ee=k?L.hasObserver:()=>false,K=k?L.receiveGhosts:()=>[],N=k?L.resolveGhosts:()=>[],y=k?L.getTriggerKeys:()=>[],M=L?.volatileLevels||new Set,S=-1,P=new Set,T=e.GetPathToLevelMap(),A=0,z=0,q=C=>{e.GetAllNextDependency(C).forEach(ne=>{let j=T.get(ne)||0;j>z&&(z=j);});},Z=new Set;a&&(g.add(a),Z.add(a),q(a),i.flushPathSet.add(a));let re=a?[a]:c;l.shouldYield()&&(i.requestUpdate(),await l.yieldToMain());let ce=re.map(async C=>{if(ee(C)){let v=n.GetNodeByPath(C),ne=y(C);if(ne.length>0){let j=K(v,ne);return j instanceof Promise&&(j=await j),{seed:C,hitTargets:j}}}return {seed:C,hitTargets:[]}});if((await Promise.all(ce)).forEach(({seed:C,hitTargets:v})=>{if(v&&v.length>0){b.push(...v);let ne=T.get(C)||0;S=Math.max(S,ne);}}),(b.length>0||re.length>1)&&(i.requestUpdate(),await l.yieldToMain(),o.get(p)!==h))return;let Pe=b.length>0;c.forEach(C=>{if(!Z.has(C))if(Pe){let v=T.get(C)??0;R.has(v)||R.set(v,new Set),R.get(v).add(C),t.emit("node:stagnate",{path:C,type:2});}else P.add(C),q(C);}),a?A=T.get(a)??0:A=Math.min(...c.map(C=>T.get(C)??0));let ge=performance.now();t.emit("flow:start",{path:p,token:h}),t.callOnStart({path:p});let de=false,me=30,Me=C=>{let{target:v,trigger:ne}=C,j=false,se=false,oe=false,I=n.GetNodeByPath(v),_=I.calledBy,Y=[],Q=[],B=false;if(I.calledBy===1){B=true,j=true,i.flushPathSet.add(v);let m=V.get(v);m&&(Y.push(...m),V.delete(v));}let W=(m,F)=>{let H=T.get(m)??0,J=(_===1||_===2)&&H<=S;J&&g.has(m)&&(g.delete(m),t.emit("node:revive",{path:m,triggerPath:v}));let D=0;if(!(g.has(m)||x.has(m)||P.has(m))){if(G.has(m))D=G.get(m)-1;else {if(H>A&&G.size>me){R.has(H)||R.set(H,new Set),R.get(H).add(m),t.emit("node:intercept",{path:m,type:7});return}let ae=e.GetPrevDependency(m),te=0;for(let ie of ae){if(g.has(ie))continue;(T.get(ie)??0)>A&&te++;}D=te;}if(D<=0){let ae=P.has(m),te=x.has(m);if(ae||te){t.emit("node:intercept",{path:m,type:te?3:3.1});return}G.delete(m);let ie=n.GetNodeByPath(m);J?ie.calledBy=2:ie.calledBy=0,P.add(m),t.emit("node:release",{path:m,type:F,detail:{path:v}});}else G.set(m,D);}},X=(m=[])=>{if(o.get(p)!==h)return;if(m.length){let H={},J=I.proxy;for(let D of m){let ae=(D.args||[]).reduce((te,ie)=>(te[ie]=J[ie],te),{});try{let te=D.fn(ae);te&&typeof te=="object"&&Object.assign(H,te);}catch(te){}}for(let D in H)if(D in I.state)Object.is(I.state[D],H[D])||(I.state[D]=H[D],Y.push(D),j=true,(I.notifyKeys.size===0||I.notifyKeys.has(D))&&(se=true));else throw {error:`wrong effect in ${String(I.path)}`}}j&&i.flushPathSet.add(v);let F=(H=[])=>{if(o.get(p)!==h)return;H&&H.length>0&&(b.push(...H),S=Math.max(S,T.get(v)||0)),Y.length=0,t.emit("node:success",{path:v,calledBy:I.calledBy}),g.add(v);let J=e.GetNextDependency(v);(se||oe)&&(q(v),e.GetAllNextDependency(v).forEach(le=>O.add(le)));let D=n.GetNodeByPath(v),ae=T.get(v)??0,te=M.has(ae)||b.length>0;for(let $ of J){let le=T.get($)??0;if(te&&le>=ae){R.has(le)||R.set(le,new Set),R.get(le).add($),t.emit("node:stagnate",{path:$,type:2});continue}if(g.has($)){t.emit("node:intercept",{path:$,type:2});continue}if(x.has($)||P.has($)){t.emit("node:intercept",{path:$,type:x.has($)?3:3.1});continue}if(se||oe)W($,1);else if(G.has($))W($,2);else {let Se=T.get($);R.has(Se)||R.set(Se,new Set);let Ee=R.get(Se);Ee.has($)||(Ee.add($),t.emit("node:stagnate",{path:$,type:1}));}}x.delete(v),D.calledBy=0,(()=>{if(!f){f=true;let $=x.size,le=P.size;t.emit("flow:fire",{path:v,type:1,detail:{active:$,pending:le,blocked:G.size}}),fe();}})();};if(ee(v)&&Y.length>0){let H=n.GetNodeByPath(v),J=K(H,Y);J instanceof Promise||J&&typeof J.then=="function"?J.then(F).catch(E):F(J);}else F([]);},E=m=>{t.emit("node:error",{path:v,error:m});let F=Symbol("abort");o.set(p,F),P.clear(),G.clear(),x.clear(),V.clear(),t.callOnError(m);},U=(m,F)=>{m!==I.state[F]&&(I.state[F]=m,j=true,Y.push(String(F)),t.emit("node:bucket:success",{path:v,key:String(F),value:m,calledBy:I.calledBy}),(I.notifyKeys.size===0||I.notifyKeys.has(F))&&(se=true)),I.nodeBucket[F].isForceNotify()&&(oe=true),(se||oe)&&q(v);};t.emit("node:start",{path:v,calledBy:I.calledBy});try{let m=[];for(let F in I.nodeBucket){let H=I.nodeBucket[F];if(m.push(...H.getSideEffect()),B){t.emit("node:bucket:success",{path:v,key:String(F),value:I.state[F],calledBy:I.calledBy}),H.isForceNotify()&&(oe=!0),(I.notifyKeys.size===0||I.notifyKeys.has(F))&&q(v);continue}let J=H.evaluate({affectKey:F,triggerPath:ne,GetRenderSchemaByPath:D=>n.GetNodeByPath(D).proxy,getStateByPath:D=>n.GetNodeByPath(D).state,GetToken:()=>h});if(J instanceof Promise){let D=J.then(ae=>{o.get(p)===h&&U(ae,F);});Q.push(D);}else U(J,F);}if(Q.length>0)return Promise.all(Q).then(()=>{X(m);}).catch(E);X(m);return}catch(m){E(m);}},fe=async()=>{if(o.get(p)!==h){f=false;return}f=true;let C=l.getIsFirstFrame(),v=0,ne=()=>s&&C?30:1/0,j=0,se=ne();try{for(;o.get(p)===h;){let oe=j>=se,I=l.shouldYield();if(oe||I){if(j>0&&(v++,(C||v%2===0)&&i.requestUpdate()),await l.yieldToMain(),o.get(p)!==h)break;j=0,C=l.getIsFirstFrame();}if(P.size>0&&x.size<40){for(let _ of P){if(x.size>=40||j>=se)break;let Y=T.get(_)??0,Q=e.GetPrevDependency(_),B=Q.length>1;if((!s||B)&&Y>A){P.delete(_);let E=Q.filter(U=>O.has(U)&&!g.has(U)).length;G.set(_,E||0),t.emit("node:intercept",{path:_,type:E>0?4:5,detail:{targetLevel:Y,currentLevel:A,pendingParentsCount:E}});continue}P.delete(_),x.add(_);let X=n.GetNodeByPath(_);if(t.emit("node:processing",{path:_,calledBy:X.calledBy}),Me({target:_,trigger:a}),j++,j>=se||l.shouldYield())break}if(P.size>0)continue}if(j<se&&s&&G.size>0&&x.size<40){let _=!1,Y=0;for(let[Q,B]of G)if(B<=0){let W=T.get(Q)??0,X=e.GetPrevDependency(Q);if(W>A&&X.length>1)continue;if(G.delete(Q),P.add(Q),Y++,_=!0,t.emit("node:release",{path:Q,type:4}),Y>=se)break}if(Y>0)continue;if(_){if(l.shouldYield()&&(await l.yieldToMain(),o.get(p)!==h))break;continue}}if(x.size===0&&P.size===0){if(b.length>0){let B=!1,W=A,X=Array.from(new Set(b));b.length=0;for(let E of X){let U=n.GetNodeByPath(E),m=N(U);if(m&&m.length>0){B=!0,U.calledBy=1,V.set(E,m),g.delete(E),G.delete(E),P.add(E);let F=T.get(E)??0;F<W&&(W=F),q(E),i.flushPathSet.add(E);}}if(B){if(W<A&&(A=W),i.requestUpdate(),l.shouldYield()&&(await l.yieldToMain(),o.get(p)!==h))break;continue}}let _=new Set;for(let B of R.keys())_.add(B);for(let[B]of G){let W=T.get(B)??0;W>A&&_.add(W);}let Y=Array.from(_).sort((B,W)=>B-W),Q=Y[0];if(Y.length>0&&Q<=z){let B=Y[0];if(B<=z){A=B;let W=R.get(B);W&&(W.forEach(X=>P.add(X)),R.delete(B));for(let[X]of G)(T.get(X)??0)===B&&(G.delete(X),P.add(X),t.emit("node:release",{path:X,type:3,detail:{level:B}}));continue}}else {R.forEach((B,W)=>{B.forEach(X=>{g.add(X),t.emit("node:intercept",{path:X,type:6});});}),R.clear();for(let[B]of G)g.add(B),t.emit("node:intercept",{path:B,type:6});G.clear();break}}P.size>0&&x.size>=40&&t.emit("flow:wait",{type:2});break}}finally{f=false;let oe=x.size+G.size+P.size,I=L.inFlightCount||0;if(!(r===h)){t.emit("flow:abort",{token:h});return}if(i.requestUpdate(),oe===0&&I===0){if(o.get(p)===h&&!de){de=true,t.emit("flow:end",{type:1}),L.resetCounters(),V.clear();let Y=performance.now();S=-1,o.delete(p),t.emit("flow:success",{token:h,duration:(Y-ge).toFixed(2.1)+"ms"}),Promise.resolve().then(()=>{t.callOnSuccess();});}}else {let Y=oe===0&&I>0?3:1;if(t.emit("flow:wait",{type:Y,detail:{nums:x.size,asyncNums:I}}),I>0){let Q=()=>{r===h&&(L.inFlightCount===0?ve(()=>{L.inFlightCount===0?fe():requestAnimationFrame(Q);}):requestAnimationFrame(Q));};requestAnimationFrame(Q);}}}};fe();}}function Ne(d){let{path:e,uid:n,type:t,meta:i,dirtySignal:l,state:o}=d,s=null,r=["path","uid","type","dependOn","nodeBucket"],a={path:e,uid:n,type:t,meta:i,dirtySignal:l,createView:(c={})=>{if(s&&Object.keys(c).length===0)return s;let w=new Proxy(c,{get(h,p){let f=p;return Reflect.has(h,p)?Reflect.get(h,p):f in d.state?d.state[f]:f in d?d[f]:i&&f in i?i[f]:Reflect.get(h,p)},set(h,p,f){let g=p;return g in d.state?(d.state[g]=f,true):Reflect.set(h,p,f)},ownKeys(h){let p=new Set([...Reflect.ownKeys(h),...Object.keys(o||{}),...Object.keys(i||{}),...r]);return Array.from(p)},getOwnPropertyDescriptor(h,p){let f=p;return Reflect.has(h,p)||o&&f in o||i&&f in i||r.includes(f)?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(h,p)}});return s=w,w}};return "children"in d?{...a,children:d.children}:{...a,state:d.state,nodeBucket:d.nodeBucket,notifyKeys:d.notifyKeys,dependOn:d.dependOn,calledBy:0,get proxy(){return s}}}var De=(d,e,n,t,i)=>{let l=d.useEntangleStep,o=new Map,s=new Map,r=new Set,u=t,c=0;return {useEntangle:f=>{let{observer:g,target:x,triggerKeys:O,emit:G,filter:R}=f;if(!O||O.length===0){i.emit("entangle:warn",{path:g,type:"no_keys"});return}o.has(g)||o.set(g,new Map);let V=o.get(g);O.forEach(b=>{V.has(b)||V.set(b,[]),V.get(b).push({target:x,emit:G,filter:R,count:0});});},updateEntangleLevel:()=>{let f=n();r.clear();for(let g of o.keys()){let x=f.get(g)||0;r.add(x);}},Turnstile:{volatileLevels:r,get inFlightCount(){return c},get hasPendingGhosts(){for(let f of s.values())if(f.length>0)return true;return false},onSettle:f=>{},hasObserver:f=>o.has(f),getTriggerKeys:f=>{let g=o.get(f);return g?Array.from(g.keys()):[]},receiveGhosts:(f,g=[])=>{let x=f.path,O=[],G=o.get(x);if(!G||g.length===0)return O;let R=new Set;g.forEach(N=>{let y=G.get(N);y&&y.forEach(M=>R.add(M));});let V=N=>N instanceof Promise||N!==null&&typeof N=="object"&&typeof N.then=="function",b=N=>{let y=N.target;if(N.count>=l){i.emit("entangle:blocked",{observer:x,target:y,count:N.count});return}let M=u(y);if(N.filter&&!N.filter(f.proxy,M.proxy))return;let S=N.emit(f.proxy,M.proxy),P=T=>{if(T&&T.key!==void 0){if(T.delta===void 0&&T.value!==void 0&&T.value===M.state[T.key])return;N.count++,s.has(y)||s.set(y,[]),s.get(y).push({weight:1,...T}),O.push(y);}};if(V(S))return c++,(async()=>{try{let T=await S;P(T);}catch(T){i.emit("node:error",{path:x,error:T}),i.onError({path:x,error:T});}finally{c--;}})();P(S);},L=Array.from(R),k=0,ee=false,K=null;for(;k<L.length;k++){if(e.shouldYield()){ee=true;break}let N=b(L[k]);if(N){K=N,ee=true,k++;break}}return ee?(async()=>{K&&await K,e.shouldYield()&&await e.yieldToMain();let N=50;for(;k<L.length;k+=N){let y=L.slice(k,k+N),M=[];for(let S of y){let P=b(S);P&&M.push(P);}if(M.length>0){let S=M.map(async P=>{await P,e.shouldYield()&&await e.yieldToMain();});await Promise.all(S);}e.shouldYield()&&await e.yieldToMain();}return Array.from(new Set(O))})():Array.from(new Set(O))},resolveGhosts:f=>{let g=f.path,x=s.get(g);if(!x||x.length===0)return [];let O=[],G=new Map;for(let R of x)G.has(R.key)||G.set(R.key,[]),G.get(R.key).push(R);for(let[R,V]of G.entries()){let b=f.state[R],L=V.filter(k=>k.patch!==void 0);if(L.length>0)b=L.reduce((k,ee)=>ee.patch(k),b);else {let k=V.filter(K=>K.delta!==void 0),ee=V.filter(K=>K.value!==void 0);ee.length>0&&(b=ee.reduce((N,y)=>(y.weight??1)>=(N.weight??1)?y:N).value),k.length>0&&(b=k.reduce((K,N)=>{switch(N.op||"add"){case "add":return (typeof K=="number"?K:0)+N.delta;case "remove":return Array.isArray(K)?K.filter(M=>M!==N.delta):K;case "intersect":return Array.isArray(K)?K.filter(M=>N.delta.includes(M)):N.delta;case "union":{let M=Array.isArray(K)?K:[],S=Array.isArray(N.delta)?N.delta:[N.delta];return [...new Set([...M,...S])]}case "merge":{let M=typeof K=="object"&&K!==null&&!Array.isArray(K)?K:{},S=typeof N.delta=="object"&&N.delta!==null&&!Array.isArray(N.delta)?N.delta:{};return {...M,...S}}default:return K}},b));}Object.is(f.state[R],b)||(f.state[R]=b,O.push(R));}return s.set(g,[]),O.length>0?O:[]},resetCounters:()=>{for(let f of o.values())for(let g of f.values())g.forEach(x=>x.count=0);}}}};function Ve(d,e,n,t,i){let l=Be(),o=0,s=new Map,r=[],u=[],a=false,c=new Set,h=async()=>{let y=Array.from(c);if(c.clear(),"signalTrigger"in i&&typeof i.signalTrigger=="function")for(let M of y){let S=b(M);i.signalTrigger(S.dirtySignal);}else "emit"in i&&i.emit(y);},p=()=>{a||(a=true,requestAnimationFrame(()=>{try{for(;c.size>0;)h();}finally{a=false;}}));},{useEntangle:f,updateEntangleLevel:g,Turnstile:x}=De({useEntangleStep:d.useEntangleStep},l,e.GetPathToLevelMap,b,{emit:t.emit,onError:t.callOnError}),O=Ue({useGreedy:d.useGreedy},e,{GetNodeByPath:b,Turnstile:x},t,{requestUpdate:p,flushPathSet:c},l),G=y=>{throw new Error(`[MeshFlow] Duplicate Path: ${y}`)},R=y=>{s.has(y.path)&&G(String(y.path));let M=++o,S={path:y.path,getNode:A=>b(A)},P=(A,z="value")=>{let q=A({...S}),Z=b(y.path);if(n.createHistoryAction&&n.pushIntoHistory){let re=n.createHistoryAction([{path:y.path,value:Z.state[z]},{path:y.path,value:q}],ce=>{let pe=b(ce.path);pe.state[z]=ce.value,k(ce.path);});n.pushIntoHistory(re);}Z.state[z]=q,k(y.path);},T=Ne({uid:M,type:y.type,path:y.path,state:y.state,meta:y.meta,nodeBucket:{},dirtySignal:"signalCreator"in i?i.signalCreator():void 0,notifyKeys:y.notifyKeys,dependOn:P});return s.set(T.path,M),r[M]=T,T},V=y=>{s.has(y.path)&&G(String(y.path));let M=++o,S=Ne({uid:M,type:y.type,path:y.path,state:{},meta:y,nodeBucket:{},children:y.children});return s.set(S.path,M),u[M]=S,S};function b(y){let M=s.get(y),S=r[M];if(!S)throw Error("wrong ID");return S}function L(y){let M=s.get(y);return u[M]}let k=y=>{if(!b(y))throw Error("Node undefined");c.add(y),p();let S=e.GetNextDependency(y);ee(S,y);};function ee(y,M){O(M,y);}return {registerNode:R,registerGroupNode:V,GetNodeByPath:b,GetGroupByPath:L,notify:k,notifyAll:async()=>{Promise.resolve().then(async()=>{let y=e.GetDependencyOrder();if(!y||y.length===0)return;let M=y[0];try{O(null,M);}catch(S){throw t.callOnError(S),S}finally{p();}});},batchNotify:y=>{if(!y||y.length===0)return;if(n.createHistoryAction&&n.pushIntoHistory){let S=n.createHistoryAction([y.map(P=>({path:P.path,key:P.key,value:b(P.path).state[P.key]})),y.map(P=>({path:P.path,key:P.key,value:P.value}))],P=>{let T=new Set;P.forEach(A=>{let z=b(A.path);z.state[A.key]=A.value,c.add(A.path),T.add(A.path);}),p(),T.size>0&&O(null,Array.from(T));});n.pushIntoHistory(S);}let M=new Set;y.forEach(S=>{let P=b(S.path);P.state[S.key]=S.value,c.add(S.path),M.add(S.path);}),p(),M.size>0&&O(null,Array.from(M));},useEntangle:f,updateEntangleLevel:g,UITrigger:i,UidToNodeMap:r}}function Le(d,e){let n=false,t=false,i=false,l=false,o=new Map,s=new Map,r=new Map,u=new Map,a=[],c=new Map,{GetNextDependency:h,GetPrevDependency:p,GetAllPrevDependency:f,GetAllNextDependency:g,rebuildDirectDependencyMaps:x}=Oe(()=>o,()=>s,()=>u,()=>r),O={},G={};if(e.modules.useHistory){let E=e.modules.useHistory,U;E.isMeshModuleInited?U=E:U=E();let{Undo:m,Redo:F,PushIntoHistory:H,CreateHistoryAction:J,updateUndoSize:D,updateRedoSize:ae}=U();O.pushIntoHistory=H,O.createHistoryAction=J,G={Undo:m,Redo:F,updateUndoSize:D,updateRedoSize:ae};}let R=!!e.modules.useMeshRenderGate,V={};if(R){let E=e.modules.useMeshRenderGate.isMeshModuleInited,U=e.modules.useMeshRenderGate;V=(E?U:U())(()=>re);}let{onError:b,callOnError:L}=Ke(),{onSuccess:k,callOnSuccess:ee}=Ie(),{onStart:K,callOnStart:N}=ke(),{emit:y,usePlugin:M,destroyPlugin:S}=Ce(),{SetTrace:P,useTrace:T}=Ge(),A=T();M(A);let z=R?{...V}:{...e.UITrigger},q=Ve({useGreedy:e.config.useGreedy,useEntangleStep:e.config.useEntangleStep||100},{GetDependencyOrder:()=>a,GetAllNextDependency:g,GetNextDependency:h,GetPrevDependency:p,GetAllPrevDependency:f,GetPathToLevelMap:()=>c},O,{callOnError:L,callOnSuccess:ee,callOnStart:N,emit:y},z),{GetGroupByPath:Z,GetNodeByPath:re,notifyAll:ce,useEntangle:pe,updateEntangleLevel:Pe}=q;R&&V.init();let ge={};if(e.modules.useInternalForm){let{uiSchema:E,GetFormData:U}=e.modules.useInternalForm(q,d);ge={uiSchema:E,GetFormData:U};}let de={};if(e.modules.useSchemaValidators){let{SetValidators:E}=e.modules.useSchemaValidators(re);de={SetValidators:E};}let{SetRule:me,SetRules:Me}=be(re,o,s),{SetStrategy:fe}=Ae(re),C=Fe(o),v=()=>{let E=C();a=E.steps,c=E.levelMap,ne();},ne=()=>{i&&(Pe(),i=false);},j=()=>{l||(l=true,Promise.resolve().then(ne).finally(()=>{l=false;}));},se=()=>{t||(t=true,Promise.resolve().then(()=>{if(v(),n){let{directNextMap:E,directPrevMap:U}=x(a.flat());r=E,u=U;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(E,U,m,F)=>{me(E,U,m,F),n=true,se();},SetRules:(E,U,m,F)=>{Me(E,U,m,F),n=true,se();},SetStrategy:fe,useEntangle:E=>{pe(E),i=true,j();},SetTrace:P,usePlugin:M,SetValue:(E,U,m)=>{ne(),re(E).dependOn(()=>m,U);},GetValue:(E,U="value")=>re(E).proxy[U],SetValues:E=>{ne(),q.batchNotify(E);},GetGroupByPath:Z,notifyAll:async()=>{v(),await ce();},GetAllDependency:()=>o,GetDependencyOrder:()=>a,historyExports:G,formExports:ge,validatorExports:de,batchRenderExport:V,hasRenderGate:()=>R,onError:b,onSuccess:k,onStart:K,scheduler:q,destroyPlugin:S}}var he=new Map,_e=(d,e,n)=>{try{if(he.has(d))throw Error("engineID repeated");let t=Le(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules??{},plugins:{}}),{SetRule:i,SetRules:l,SetValues:o,SetStrategy:s,SetValue:r,GetValue:u,usePlugin:a,useEntangle:c,GetGroupByPath:w,notifyAll:h,SetTrace:p,GetAllDependency:f,GetDependencyOrder:g,historyExports:x,formExports:O,validatorExports:G,batchRenderExport:R,hasRenderGate:V,onError:b,onSuccess:L,onStart:k,scheduler:ee,destroyPlugin:K}=t,N={config:{SetRule:i,SetRules:l,SetStrategy:s,notifyAll:h,SetTrace:p,usePlugin:a,hasRenderGate:V,useEntangle:c},data:{SetValue:r,GetValue:u,SetValues:o,GetGroupByPath:w},dependency:{GetAllDependency:f,GetDependencyOrder:g},hooks:{onError:b,onSuccess:L,onStart:k}},y=(P,T,A)=>{!T||typeof T!="object"||Object.keys(T).forEach(z=>{let q=T[z];if(typeof q=="object"&&q!==null)P[z]=P[z]||{},y(P[z],q,A);else if(typeof q=="function"){let Z=z;if(Z==="useMeshRenderGate")Z="render";else if(Z.startsWith("use")){let re=Z.slice(3);Z=re.charAt(0).toLowerCase()+re.slice(1);}z==="useHistory"&&A.exports.history&&Object.keys(A.exports.history).length>0?P[Z]=A.exports.history:z==="useInternalForm"&&A.exports.form&&Object.keys(A.exports.form).length>0?P[Z]=A.exports.form:z==="useSchemaValidators"&&A.exports.validator&&Object.keys(A.exports.validator).length>0?P[Z]=A.exports.validator:z==="useMeshRenderGate"&&A.exports.render?P[Z]=A.exports.render:P[Z]=q(A.scheduler,A.Schema);}});},M={...N,destroyPlugin:K,modules:{}},S=n.modules;return S&&y(M.modules,S,{scheduler:ee,Schema:e,exports:{history:x,form:O,validator:G,render:R}}),he.set(d,M),M}catch(t){throw Error(t)}},It=()=>(d,e,n)=>He(d,e,n),Ct=d=>{let e=he.get(d);if(!e)throw Error(`[MeshFlow] Engine ID "${String(d)}" not found. Ensure it is initialized with useMeshFlow.`);return e},kt=d=>{he.get(d).destroyPlugin(),he.delete(d);},He=_e;exports.DefaultStrategy=we;exports.TriggerCause=xe;exports.deleteEngine=kt;exports.useEngine=Ct;exports.useEngineManager=_e;exports.useMeshFlow=He;exports.useMeshFlowDefiner=It;exports.useScheduler=Ve;
|
package/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Me=class{computedRules=[];store={OR:(e,n)=>{let t,o,r=this.computedRules;for(let s=0;s<r.length;s++){let a=r[s],i=a.logic(e);if(i instanceof Promise)return (async()=>{let l=await i;if(a.entityId==="__base__"?o=l:l&&(t=l),typeof t>"u")for(let y=s+1;y<r.length;y++){let m=r[y],g=m.logic(e),u=g instanceof Promise?await g:g;if(m.entityId==="__base__"){o=u;continue}if(u){t=m.value;break}}return typeof t>"u"&&(t=o),{res:t,version:n}})();let d=i;if(a.entityId==="__base__"){o=d;continue}if(d){t=a.value;break}}return typeof t>"u"&&(t=o),{res:t,version:n}},PRIORITY:(e,n)=>{let t,o=this.computedRules;for(let r=0;r<o.length;r++){let a=o[r].logic(e);if(a instanceof Promise)return (async()=>{let i=await a;if(i!==void 0)return {res:i,version:n};for(let d=r+1;d<o.length;d++){let l=o[d].logic(e),y=l instanceof Promise?await l:l;if(y!==void 0)return {res:y,version:n}}return {res:void 0,version:n}})();if(a!==void 0)return {res:a,version:n}}return {res:t,version:n}}};CurrentStrategy=()=>{};CurrentStrategyType="PRIORITY";getRules=()=>{};constructor(e){this.getRules=e,this.CurrentStrategy=this.store.PRIORITY,this.updateComputedRules();}updateComputedRules(){let e=this.getRules();this.CurrentStrategyType==="PRIORITY"?this.computedRules=Array.from(e.values()).map(n=>Array.from(n)).flat().sort((n,t)=>t.priority-n.priority):this.computedRules=Array.from(e.values()).map(n=>Array.from(n)).flat();}setStrategy(e){this.CurrentStrategy=this.store[e],this.updateComputedRules();}evaluate(e,n){return this.CurrentStrategy(e,n)}},fe=class{path;strategy;contract;rules=new Map;isValue=false;id=0;cache=void 0;pendingPromise=null;version=0;deps=new Map;_forceNotify=false;promiseToken=null;useCache=true;effectArray=[];constructor(e,n,t){let o=()=>this.rules;this.strategy=new Me(o),this.path=t,this.isValue=n==="value",this.contract=this.inferType(e),this.cache=e,this.setRule({priority:0,entityId:"__base__",logic:()=>e});}setUseCache(e){this.useCache=e;}forceNotify(){this._forceNotify=true;}isForceNotify(){return this._forceNotify}setStrategy(e){this.strategy.setStrategy(e);}setDefaultRule(e){let n=new Set;n.add(e),this.rules.set("defaultRules",n);}setRules(e,n){n&&this.updateDeps(n);let t=++this.id,o={...e,entityId:t};for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(o);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let s=this.rules.get(r);s&&(s.delete(o),s.size===0&&(this.rules.delete(r),this.deps.delete(r)));}this.strategy.updateComputedRules();}}updateDeps(e){for(let[n,t]of e)this.deps.set(n,t);}setRule(e,n){if(n&&this.updateDeps(n),typeof e.entityId=="string"){this.setDefaultRule(e);return}let t=++this.id,o={...e,entityId:t};if(e)for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(o);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let s=this.rules.get(r);s&&(s.delete(o),s.size===0&&(this.rules.delete(r),this.deps.delete(r)));}this.strategy.updateComputedRules();}}setSideEffect(e){this.effectArray.push(e);}getSideEffect(){return [...this.effectArray]}evaluate(e){let n=null;if(e.GetToken&&(n=e.GetToken()),this.pendingPromise&&this.promiseToken!==n&&(this.pendingPromise=null,this.promiseToken=null),this.pendingPromise)return this.pendingPromise;let t=false;if(typeof e.triggerPath=="string"){t=true;let s=this.deps.get(e.triggerPath),a=e.getStateByPath(e.triggerPath);if(typeof s=="object"||typeof a=="object")t=false;else {let i=Array.from(this.deps.keys());for(let d of i){let l=this.deps.get(d),y=e.getStateByPath(d);if(l!==y){t=false;break}}}}if(t&&this.useCache)return this.cache;this.promiseToken=n;let o=++this.version,r=this.strategy.evaluate(e,o);if(!(r instanceof Promise)){let{res:s,version:a}=r;return this.finalizeSync(s,a,e,n)}return this.pendingPromise=(async()=>{try{let{res:s,version:a}=await r;return this.finalizeSync(s,a,e,n)}catch(s){throw {path:this.path,error:s}}finally{this.promiseToken===n&&(this.pendingPromise=null,this.promiseToken=null);}})(),this.pendingPromise}finalizeSync(e,n,t,o){return o!==this.promiseToken||n<this.version?this.cache:(this.cache=e,this.deps.forEach((r,s)=>{this.deps.set(s,t.GetRenderSchemaByPath(s));}),e)}inferType(e){return Array.isArray(e)?"array":typeof e}};var xe=(c,e,n)=>{let o=r=>{let s=n.triggerPaths.map(d=>{let l=r.GetRenderSchemaByPath(d),y={};return n.triggerKeys.forEach(m=>{y[m]=l[m];}),y}),a=Object.create(null);return Object.defineProperty(a,"triggerTargets",{get:()=>s}),Object.defineProperty(a,"affectedTatget",{get:()=>r.GetRenderSchemaByPath(c)[e]}),n.logic({slot:a})};return {value:n.value,targetPath:c,triggerPaths:n.triggerPaths,priority:n.priority??10,logic:o}},Ne=(c,e,n)=>{if(!c)throw Error("");let t=c,o=(a,i)=>{e.has(a)||e.set(a,new Set),e.get(a).add(i),n.has(i)||n.set(i,new Set),n.get(i).add(a);};return {SetRule:(a,i,d,l)=>{let y=t(i),m=l.triggerKeys||[];m.length==0&&m.push("value");let g=xe(i,d,{...l,triggerPaths:[a],triggerKeys:m}),u=[a].map(f=>[f,t(f).state.value]);if(o(a,i),y.nodeBucket[d])y.nodeBucket[d].setRule(g,u),l.effect&&y.nodeBucket[d].setSideEffect({fn:l.effect,args:l.effectArgs?l.effectArgs:[d]});else {let f=y.meta[d],P=new fe(f,d,i);P.setRule(g,u),l.effect&&P.setSideEffect({fn:l.effect,args:l.effectArgs?l.effectArgs:[d]}),y.nodeBucket[d]=P;}y.state[d]=y.meta[d],l.forceNotify&&y.nodeBucket[d].forceNotify(),l.cacheStrategy=="none"&&y.nodeBucket[d].setUseCache(false);},SetRules:(a,i,d,l)=>{let y=t(i);for(let f of a)o(f,i);let m=l.triggerKeys||[];m.length==0&&m.push("value");let g=xe(i,d,{...l,triggerPaths:a,triggerKeys:m}),u=a.map(f=>[f,t(f).state.value]);if(y.nodeBucket[d])y.nodeBucket[d].setRules(g,u),l.effect&&y.nodeBucket[d].setSideEffect({fn:l.effect,args:l.effectArgs?l.effectArgs:[d]});else {let f=y.meta[d],P=new fe(f,d,i);P.setRules(g,u),l.effect&&P.setSideEffect({fn:l.effect,args:l.effectArgs?l.effectArgs:[d]}),y.nodeBucket[d]=P;}y.state[d]=y.meta[d],l.forceNotify&&y.nodeBucket[d].forceNotify(),l.cacheStrategy=="none"&&y.nodeBucket[d].setUseCache(false);}}};var we=c=>{let e=c||void 0;if(!e)throw Error("");return {SetStrategy:(t,o,r)=>{e(t).nodeBucket[o].setStrategy(r);}}};function Re(){let c=new Map,e=new Map,n=new Set,t=(s,a)=>{c.set(s,a);let i=e.get(s);i&&i(a);};return {SetTrace:(s,a)=>{e.set(s,a);let i=c.get(s)||"idle";return a(i),{cancel:()=>{e.delete(s);}}},useTrace:()=>({apply:a=>{a.on("flow:start",()=>{n.forEach(i=>t(i,"idle")),n.clear(),c.clear();}),a.on("node:release",({path:i,type:d})=>{(d==1||d==2)&&(n.add(i),t(i,"pending"));}),a.on("node:pending",({path:i})=>{n.add(i),(!c.has(i)||c.get(i)==="idle")&&t(i,"pending");}),a.on("node:start",({path:i})=>{n.add(i),t(i,"calculating");}),a.on("node:success",({path:i})=>{t(i,"calculated");}),a.on("node:intercept",({path:i,type:d})=>{d==3&&t(i,"calculating"),d==6&&t(i,"idle");}),a.on("node:stagnate",({path:i})=>{t(i,"pending");}),a.on("node:error",({path:i})=>t(i,"error"));}})}}function Ee(c,e,n,t){let o=l=>{let y=c(),m=e(),g=new Set;return y.get(l)?.forEach(u=>g.add(u)),g.size===0?[]:Array.from(g).filter(u=>{let f=m.get(u)||new Set;return !Array.from(f).some(v=>g.has(v))})};return {GetNextDependency:l=>{let y=t();return Array.from(y.get(l)||[])},GetPrevDependency:l=>{let y=n();return Array.from(y.get(l)||[])},GetAllPrevDependency:l=>{let y=e();return Array.from(y.get(l)||[])},GetAllNextDependency:l=>{let y=c();return Array.from(y.get(l)||[])},rebuildDirectDependencyMaps:l=>{let y=new Map,m=new Map;for(let g of l){let u=o(g);y.set(g,new Set(u));for(let f of u)m.has(f)||m.set(f,new Set),m.get(f).add(g);}return {directNextMap:y,directPrevMap:m}}}}function be(c){let e=t=>{let o=[],r=[],s=new Map,a=t.size,i=0,d=0;for(let[l,y]of t)y===0&&r.push(l);if(r.length===0&&a>0)throw Error("Circular dependency detected");for(;r.length>0;){o.push([...r]);let l=[];for(let y of r){i++,s.set(y,d);let m=c.get(y);if(m)for(let g of m){let u=t.get(g)-1;t.set(g,u),u===0&&l.push(g);}}r=l,d++;}if(i<a)throw Error("Circular dependency detected");return {steps:o,levelMap:s}};return ()=>{let t=new Map;for(let o of c.keys()){let r=Array.from(c.get(o)||[]);t.has(o)||t.set(o,0);for(let s of r){let a=t.get(s)||0;t.set(s,++a);}}return e(t)}}var ce=()=>{let c=[];return {on:e=>(c.push(e),()=>{let n=c.indexOf(e);n>-1&&c.splice(n,1);}),call:e=>c.forEach(n=>{n(e);})}};function Ae(){let{on:c,call:e}=ce();return {onError:c,callOnError:e}}function Ge(){let{on:c,call:e}=ce();return {onSuccess:c,callOnSuccess:e}}var Oe=()=>{let c=new Set,e=new Map,n=(r,s)=>{e.get(r)?.forEach(a=>a(s));},t=(r,s)=>(e.has(r)||e.set(r,new Set),e.get(r).add(s),()=>e.get(r).delete(s));return {usePlugin:r=>{let s=new Set,a=(i,d)=>{let l=t(i,d);return s.add(l),l};return r.apply({on:a}),c.add(r),()=>{s.forEach(i=>i()),s.clear(),c.delete(r);}},emit:n}};function Fe(){let{on:c,call:e}=ce();return {onStart:c,callOnStart:e}}var Se=(t=>(t[t.CAUSALITY=0]="CAUSALITY",t[t.INVERSION=1]="INVERSION",t[t.REPERCUSSION=2]="REPERCUSSION",t))(Se||{});function Ke(c,e,n,t,o,r){let s=new Map,a=c.useGreedy;return async(d,l)=>{let m=Symbol("token"),g=d||"__NOTIFY_ALL__";s.set(g,m);let u=false;r.reset();let f=new Set,P=new Set,k=new Set;l.forEach(O=>{k.add(O),e.GetAllNextDependency(O).forEach(N=>k.add(N));});let v=new Map,T=new Map,$=new Map,D=[],b=n.Turnstile,_=b.volatileLevels.size>0,j=_?b.hasObserver:()=>false,Q=_?b.receiveGhosts:()=>[],G=_?b.resolveGhosts:()=>[],H=_?b.getTriggerKeys:()=>[],h=b?.volatileLevels||new Set,x=-1,p=new Set,M=e.GetPathToLevelMap(),w=0,I=0,L=O=>{e.GetAllNextDependency(O).forEach(ne=>{let V=M.get(ne)||0;V>I&&(I=V);});},W=new Set;d&&(f.add(d),W.add(d),L(d),o.flushPathSet.add(d));let re=d?[d]:l;r.shouldYield()&&(o.requestUpdate(),await r.yieldToMain());let de=re.map(async O=>{if(j(O)){let N=n.GetNodeByPath(O),ne=H(O);if(ne.length>0){let V=Q(N,ne);return V instanceof Promise&&(V=await V),{seed:O,hitTargets:V}}}return {seed:O,hitTargets:[]}});if((await Promise.all(de)).forEach(({seed:O,hitTargets:N})=>{if(N&&N.length>0){D.push(...N);let ne=M.get(O)||0;x=Math.max(x,ne);}}),(D.length>0||re.length>1)&&(o.requestUpdate(),await r.yieldToMain(),s.get(g)!==m))return;let le=D.length>0;l.forEach(O=>{if(!W.has(O))if(le){let N=M.get(O)??0;T.has(N)||T.set(N,new Set),T.get(N).add(O),t.emit("node:stagnate",{path:O,type:2});}else p.add(O),L(O);}),d?w=M.get(d)??0:w=Math.min(...l.map(O=>M.get(O)??0));let pe=performance.now();t.emit("flow:start",{path:g}),t.callOnStart({path:g});let ye=false,ge=30,Pe=O=>{let{target:N,trigger:ne}=O,V=false,ee=false,U=n.GetNodeByPath(N),se=U.calledBy,F=[],R=[],A=false;if(U.calledBy===1){A=true,V=true,o.flushPathSet.add(N);let S=$.get(N);S&&(F.push(...S),$.delete(N));}let E=(S,K)=>{let B=M.get(S)??0,Z=(se===1||se===2)&&B<=x;Z&&f.has(S)&&(f.delete(S),t.emit("node:revive",{path:S,triggerPath:N}));let z=0;if(!(f.has(S)||P.has(S)||p.has(S))){if(v.has(S))z=v.get(S)-1;else {if(B>w&&v.size>ge){T.has(B)||T.set(B,new Set),T.get(B).add(S),t.emit("node:intercept",{path:S,type:7});return}let te=e.GetPrevDependency(S),J=0;for(let ae of te){if(f.has(ae))continue;(M.get(ae)??0)>w&&J++;}z=J;}if(z<=0){let te=p.has(S),J=P.has(S);if(te||J){t.emit("node:intercept",{path:S,type:J?3:3.1});return}v.delete(S);let ae=n.GetNodeByPath(S);Z?ae.calledBy=2:ae.calledBy=0,p.add(S),t.emit("node:release",{path:S,type:K,detail:{path:N}});}else v.set(S,z);}},C=(S=[])=>{if(s.get(g)!==m)return;if(S.length){let B={},Z=U.proxy;for(let z of S){let te=(z.args||[]).reduce((J,ae)=>(J[ae]=Z[ae],J),{});try{let J=z.fn(te);J&&typeof J=="object"&&Object.assign(B,J);}catch(J){}}for(let z in B)if(z in U.state)Object.is(U.state[z],B[z])||(U.state[z]=B[z],F.push(z));else throw {error:`wrong effect in ${String(U.path)}`};V=true;}V&&o.flushPathSet.add(N);let K=(B=[])=>{if(s.get(g)!==m)return;B&&B.length>0&&(D.push(...B),x=Math.max(x,M.get(N)||0)),F.length=0,t.emit("node:success",{path:N,calledBy:U.calledBy}),f.add(N);let Z=e.GetNextDependency(N);(V||ee)&&e.GetAllNextDependency(N).forEach(oe=>k.add(oe));let z=n.GetNodeByPath(N),te=M.get(N)??0,J=h.has(te)||D.length>0;for(let q of Z){let oe=M.get(q)??0;if(J&&oe>=te){T.has(oe)||T.set(oe,new Set),T.get(oe).add(q),t.emit("node:stagnate",{path:q,type:2});continue}if(f.has(q)){t.emit("node:intercept",{path:q,type:2});continue}if(P.has(q)||p.has(q)){t.emit("node:intercept",{path:q,type:P.has(q)?3:3.1});continue}if(V||ee)E(q,1);else if(v.has(q))E(q,2);else {let me=M.get(q);T.has(me)||T.set(me,new Set);let ve=T.get(me);ve.has(q)||(ve.add(q),t.emit("node:stagnate",{path:q,type:1}));}}P.delete(N),z.calledBy=0,(async()=>{if(!u){let q=P.size,oe=p.size;t.emit("flow:fire",{path:N,type:1,detail:{active:q,pending:oe,blocked:v.size}}),ue();}})();};if(j(N)&&F.length>0){let B=n.GetNodeByPath(N),Z=Q(B,F);Z instanceof Promise||Z&&typeof Z.then=="function"?Z.then(K).catch(Y):K(Z);}else K([]);},Y=S=>{t.emit("node:error",{path:N,error:S});let K=Symbol("abort");s.set(g,K),p.clear(),v.clear(),P.clear(),t.callOnError(S);},X=(S,K)=>{let B=false;S!==U.state[K]&&(U.state[K]=S,V=true,F.push(String(K)),t.emit("node:bucket:success",{path:N,key:String(K),value:S,calledBy:U.calledBy}),U.notifyKeys.has(K)&&(B=true)),U.nodeBucket[K].isForceNotify()&&(ee=true),(B||ee)&&L(N);};t.emit("node:start",{path:N,calledBy:U.calledBy});try{let S=[];for(let K in U.nodeBucket){let B=U.nodeBucket[K];if(S.push(...B.getSideEffect()),A){t.emit("node:bucket:success",{path:N,key:String(K),value:U.state[K],calledBy:U.calledBy}),B.isForceNotify()&&(ee=!0),U.notifyKeys.has(K)&&L(N);continue}let Z=B.evaluate({affectKey:K,triggerPath:ne,GetRenderSchemaByPath:z=>n.GetNodeByPath(z).proxy,getStateByPath:z=>n.GetNodeByPath(z).state,GetToken:()=>m});if(Z instanceof Promise){let z=Z.then(te=>{s.get(g)===m&&X(te,K);});R.push(z);}else X(Z,K);}if(R.length>0)return Promise.all(R).then(()=>{C(S);}).catch(Y);C(S);return}catch(S){Y(S);}},ue=async()=>{if(s.get(g)!==m){u=false;return}u=true;let O=r.getIsFirstFrame(),N=0,ne=()=>a&&O?30:1/0,V=0,ee=ne();try{for(;s.get(g)===m;){let U=V>=ee,se=r.shouldYield();if(U||se){if(V>0&&(N++,(O||N%2===0)&&o.requestUpdate()),await r.yieldToMain(),s.get(g)!==m)break;V=0,O=r.getIsFirstFrame();}if(p.size>0&&P.size<40){for(let F of p){if(P.size>=40||V>=ee)break;let R=M.get(F)??0,A=e.GetPrevDependency(F),E=A.length>1;if((!a||E)&&R>w){p.delete(F);let X=A.filter(S=>k.has(S)&&!f.has(S)).length;v.set(F,X||0),t.emit("node:intercept",{path:F,type:X>0?4:5,detail:{targetLevel:R,currentLevel:w,pendingParentsCount:X}});continue}p.delete(F),P.add(F);let Y=n.GetNodeByPath(F);if(t.emit("node:processing",{path:F,calledBy:Y.calledBy}),Pe({target:F,trigger:d}),V++,V>=ee||r.shouldYield())break}if(p.size>0)continue}if(V<ee&&a&&v.size>0&&P.size<40){let F=!1,R=0;for(let[A,E]of v)if(E<=0){let C=M.get(A)??0,Y=e.GetPrevDependency(A);if(C>w&&Y.length>1)continue;if(v.delete(A),p.add(A),R++,F=!0,t.emit("node:release",{path:A,type:4}),R>=ee)break}if(R>0)continue;if(F){if(r.shouldYield()&&(await r.yieldToMain(),s.get(g)!==m))break;continue}}if(P.size===0&&p.size===0){if(D.length>0){let E=!1,C=w,Y=Array.from(new Set(D));D.length=0;for(let X of Y){let S=n.GetNodeByPath(X),K=G(S);if(K&&K.length>0){E=!0,S.calledBy=1,$.set(X,K),f.delete(X),v.delete(X),p.add(X);let B=M.get(X)??0;B<C&&(C=B),L(X),o.flushPathSet.add(X);}}if(E){if(C<w&&(w=C),o.requestUpdate(),r.shouldYield()&&(await r.yieldToMain(),s.get(g)!==m))break;continue}}let F=new Set;for(let E of T.keys())F.add(E);for(let[E]of v){let C=M.get(E)??0;C>w&&F.add(C);}let R=Array.from(F).sort((E,C)=>E-C),A=R[0];if(R.length>0&&A<=I){let E=R[0];if(E<=I){w=E;let C=T.get(E);C&&(C.forEach(Y=>p.add(Y)),T.delete(E));for(let[Y]of v)(M.get(Y)??0)===E&&(v.delete(Y),p.add(Y),t.emit("node:release",{path:Y,type:3,detail:{level:E}}));continue}}else {T.forEach((E,C)=>{E.forEach(Y=>{f.add(Y),t.emit("node:intercept",{path:Y,type:6});});}),T.clear();for(let[E]of v)f.add(E),t.emit("node:intercept",{path:E,type:6});v.clear();break}}p.size>0&&P.size>=40&&t.emit("flow:wait",{type:2});break}}finally{u=false;let U=P.size+v.size+p.size,se=b.inFlightCount||0;if(o.requestUpdate(),U===0&&se===0){if(s.get(g)===m&&!ye){ye=true,t.emit("flow:end",{type:1}),b.resetCounters();let F=performance.now();x=-1,t.emit("flow:success",{duration:(F-pe).toFixed(2.1)+"ms"}),Promise.resolve().then(()=>{t.callOnSuccess();});}}else {let F=U===0&&se>0?3:1;t.emit("flow:wait",{type:F,detail:{nums:P.size,asyncNums:se}});}}};ue();}}function Te(c){let{path:e,uid:n,type:t,meta:o,dirtySignal:r,state:s}=c,a=null,i=["path","uid","type","dependOn","nodeBucket"],l={path:e,uid:n,type:t,meta:o,dirtySignal:r,createView:(y={})=>{if(a&&Object.keys(y).length===0)return a;let m=new Proxy(y,{get(g,u){let f=u;return Reflect.has(g,u)?Reflect.get(g,u):f in c.state?c.state[f]:f in c?c[f]:o&&f in o?o[f]:Reflect.get(g,u)},set(g,u,f){let P=u;return P in c.state?(c.state[P]=f,true):Reflect.set(g,u,f)},ownKeys(g){let u=new Set([...Reflect.ownKeys(g),...Object.keys(s||{}),...Object.keys(o||{}),...i]);return Array.from(u)},getOwnPropertyDescriptor(g,u){let f=u;return Reflect.has(g,u)||s&&f in s||o&&f in o||i.includes(f)?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(g,u)}});return a=m,m}};return "children"in c?{...l,children:c.children}:{...l,state:c.state,nodeBucket:c.nodeBucket,notifyKeys:c.notifyKeys,dependOn:c.dependOn,calledBy:0,get proxy(){return a}}}var Ie=(c={frameQuota:12})=>{let e=performance.now(),n=0,t=false,o=()=>!!navigator?.scheduling?.isInputPending?.({includeContinuous:true});return {getIsFirstFrame:()=>t,reset(){e=performance.now(),n=0,t=true;},shouldYield(){let r=performance.now();return n++,!!((n>=5||t)&&(n=0,r-e>c.frameQuota||o()))},async yieldToMain(){return new Promise(r=>{Ue(()=>{e=performance.now(),n=0,t&&(t=false),r();});})}}},Ue=c=>{let{port1:e,port2:n}=new MessageChannel;e.onmessage=c,n.postMessage(null);};var Ce=(c,e,n,t,o)=>{let r=c.useEntangleStep,s=new Map,a=new Map,i=new Set,d=t,l=0;return {useEntangle:u=>{let{observer:f,target:P,triggerKeys:k,emit:v}=u;if(!k||k.length===0){o.emit("entangle:warn",{path:f,type:"no_keys"});return}s.has(f)||s.set(f,new Map);let T=s.get(f);k.forEach($=>{T.has($)||T.set($,[]),T.get($).push({target:P,emit:v,count:0});});},updateEntangleLevel:()=>{let u=n();if(!(!u||u.size===0)){i.clear();for(let f of s.keys()){let P=u.get(f);P!==void 0?i.add(P):o.emit("entangle:warn",{path:f,type:"no_level"});}}},Turnstile:{volatileLevels:i,get inFlightCount(){return l},get hasPendingGhosts(){for(let u of a.values())if(u.length>0)return true;return false},hasObserver:u=>s.has(u),getTriggerKeys:u=>{let f=s.get(u);return f?Array.from(f.keys()):[]},receiveGhosts:(u,f=[])=>{let P=u.path,k=[],v=s.get(P);if(!v||f.length===0)return k;let T=new Set;f.forEach(G=>{let H=v.get(G);H&&H.forEach(h=>T.add(h));});let $=G=>G instanceof Promise||G!==null&&typeof G=="object"&&typeof G.then=="function",D=G=>{let H=G.target;if(G.count>=r){o.emit("entangle:blocked",{observer:P,target:H,count:G.count});return}let h=d(H),x=G.emit(u.proxy,h.proxy),p=M=>{M&&M.key!==void 0&&(G.count++,a.has(H)||a.set(H,[]),a.get(H).push({weight:1,...M}),k.push(H));};if($(x))return l++,(async()=>{try{let M=await x;p(M);}catch(M){o.emit("node:error",{path:P,error:M}),o.onError({path:P,error:M});}finally{l--;}})();p(x);},b=Array.from(T),_=0,j=false,Q=null;for(;_<b.length;_++){if(e.shouldYield()){j=true;break}let G=D(b[_]);if(G){Q=G,j=true,_++;break}}return j?(async()=>{Q&&await Q,e.shouldYield()&&await e.yieldToMain();let G=50;for(;_<b.length;_+=G){let H=b.slice(_,_+G),h=[];for(let x of H){let p=D(x);p&&h.push(p);}if(h.length>0){let x=h.map(async p=>{await p,e.shouldYield()&&await e.yieldToMain();});await Promise.all(x);}e.shouldYield()&&await e.yieldToMain();}return Array.from(new Set(k))})():Array.from(new Set(k))},resolveGhosts:u=>{let f=u.path,P=a.get(f);if(!P||P.length===0)return [];let k=[],v=new Map;for(let T of P)v.has(T.key)||v.set(T.key,[]),v.get(T.key).push(T);for(let[T,$]of v.entries()){let D=u.state[T],b=$.filter(j=>j.delta!==void 0),_=$.filter(j=>j.value!==void 0);if(_.length>0&&(D=_.reduce((Q,G)=>(G.weight??1)>=(Q.weight??1)?G:Q).value),b.length>0){let j=b.reduce((G,H)=>G+H.delta,0),Q=(typeof D=="number"?D:0)+j;D=Math.max(0,parseFloat(Q.toFixed(6)));}Object.is(u.state[T],D)||(u.state[T]=D,k.push(T));}return a.set(f,[]),k.length>0?k:[]},resetCounters:()=>{for(let u of s.values())for(let f of u.values())f.forEach(P=>P.count=0);}}}};function Be(c,e,n,t,o){let r=Ie(),s=0,a=new Map,i=[],d=[],l=false,y=new Set,g=async()=>{let h=Array.from(y);if(y.clear(),"signalTrigger"in o&&typeof o.signalTrigger=="function")for(let x of h){let p=b(x);o.signalTrigger(p.dirtySignal);}else "emit"in o&&o.emit(h);},u=()=>{l||(l=true,requestAnimationFrame(()=>{try{for(;y.size>0;)g();}finally{l=false;}}));},{useEntangle:f,updateEntangleLevel:P,Turnstile:k}=Ce({useEntangleStep:c.useEntangleStep},r,e.GetPathToLevelMap,b,{emit:t.emit,onError:t.callOnError}),v=Ke({useGreedy:c.useGreedy},e,{GetNodeByPath:b,Turnstile:k},t,{requestUpdate:u,flushPathSet:y},r),T=h=>{throw new Error(`[MeshFlow] Duplicate Path: ${h}`)},$=h=>{a.has(h.path)&&T(String(h.path));let x=++s,p={path:h.path,getNode:I=>b(I)},M=(I,L="value")=>{let W=I({...p}),re=b(h.path);if(n.createHistoryAction&&n.pushIntoHistory){let de=n.createHistoryAction([{path:h.path,value:re.state[L]},{path:h.path,value:W}],ie=>{let le=b(ie.path);le.state[L]=ie.value,j(ie.path);});n.pushIntoHistory(de);}re.state[L]=W,j(h.path);};h.notifyKeys.size==0&&h.notifyKeys.add("value");let w=Te({uid:x,type:h.type,path:h.path,state:h.state,meta:h.meta,nodeBucket:h.nodeBucket,dirtySignal:"signalCreator"in o?o.signalCreator():void 0,notifyKeys:h.notifyKeys,dependOn:M});return a.set(w.path,x),i[x]=w,w},D=h=>{a.has(h.path)&&T(String(h.path));let x=++s,p=Te({uid:x,type:h.type,path:h.path,state:{},meta:h,nodeBucket:{},children:h.children});return a.set(p.path,x),d[x]=p,p};function b(h){let x=a.get(h),p=i[x];if(!p)throw Error("wrong ID");return p}function _(h){let x=a.get(h);return d[x]}let j=h=>{if(!b(h))throw Error("Node undefined");y.add(h),u();let p=e.GetNextDependency(h);Q(p,h);};function Q(h,x){v(x,h);}return {registerNode:$,registerGroupNode:D,GetNodeByPath:b,GetGroupByPath:_,notify:j,notifyAll:async()=>{Promise.resolve().then(async()=>{let h=e.GetDependencyOrder();if(!h||h.length===0)return;let x=h[0];try{v(null,x);}catch(p){throw t.callOnError(p),p}finally{u();}});},batchNotify:h=>{if(!h||h.length===0)return;if(n.createHistoryAction&&n.pushIntoHistory){let p=n.createHistoryAction([h.map(M=>({path:M.path,key:M.key,value:b(M.path).state[M.key]})),h.map(M=>({path:M.path,key:M.key,value:M.value}))],M=>{let w=new Set;M.forEach(I=>{let L=b(I.path);L.state[I.key]=I.value,y.add(I.path),w.add(I.path);}),u(),w.size>0&&v(null,Array.from(w));});n.pushIntoHistory(p);}let x=new Set;h.forEach(p=>{let M=b(p.path);M.state[p.key]=p.value,y.add(p.path),x.add(p.path);}),u(),x.size>0&&v(null,Array.from(x));},useEntangle:f,updateEntangleLevel:P,UITrigger:o,UidToNodeMap:i}}function ke(c,e){let n=false,t=false,o=new Map,r=new Map,s=new Map,a=new Map,i=[],d=new Map,{GetNextDependency:y,GetPrevDependency:m,GetAllPrevDependency:g,GetAllNextDependency:u,rebuildDirectDependencyMaps:f}=Ee(()=>o,()=>r,()=>a,()=>s),P={},k={};if(e.modules.useHistory){let R=e.modules.useHistory,A;R.isMeshModuleInited?A=R:A=R();let{Undo:E,Redo:C,PushIntoHistory:Y,CreateHistoryAction:X,updateUndoSize:S,updateRedoSize:K}=A();P.pushIntoHistory=Y,P.createHistoryAction=X,k={Undo:E,Redo:C,updateUndoSize:S,updateRedoSize:K};}let v=!!e.modules.useMeshRenderGate,T={};if(v){let R=e.modules.useMeshRenderGate.isMeshModuleInited,A=e.modules.useMeshRenderGate;T=(R?A:A())(()=>L);}let{onError:$,callOnError:D}=Ae(),{onSuccess:b,callOnSuccess:_}=Ge(),{onStart:j,callOnStart:Q}=Fe(),{emit:G,usePlugin:H}=Oe(),{SetTrace:h,useTrace:x}=Re(),p=x();H(p);let M=v?{...T}:{...e.UITrigger},w=Be({useGreedy:e.config.useGreedy,useEntangleStep:e.config.useEntangleStep||100},{GetDependencyOrder:()=>i,GetAllNextDependency:u,GetNextDependency:y,GetPrevDependency:m,GetAllPrevDependency:g,GetPathToLevelMap:()=>d},P,{callOnError:D,callOnSuccess:_,callOnStart:Q,emit:G},M),{GetGroupByPath:I,GetNodeByPath:L,notifyAll:W,useEntangle:re,updateEntangleLevel:de}=w;v&&T.init();let ie={};if(e.modules.useInternalForm){let{uiSchema:R,GetFormData:A}=e.modules.useInternalForm(w,c);ie={uiSchema:R,GetFormData:A};}let le={};if(e.modules.useSchemaValidators){let{SetValidators:R}=e.modules.useSchemaValidators(L);le={SetValidators:R};}let{SetRule:pe,SetRules:ye}=Ne(L,o,r),{SetStrategy:ge}=we(L),Pe=be(o),ue=()=>{let R=Pe();i=R.steps,d=R.levelMap,de();},O=()=>{t||(t=true,Promise.resolve().then(()=>{if(ue(),n){let{directNextMap:R,directPrevMap:A}=f(i.flat());s=R,a=A;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(R,A,E,C)=>{pe(R,A,E,C),n=true,O();},SetRules:(R,A,E,C)=>{ye(R,A,E,C),n=true,O();},SetStrategy:ge,useEntangle:re,SetTrace:h,usePlugin:H,SetValue:(R,A,E)=>{L(R).dependOn(()=>E,A);},GetValue:(R,A="value")=>L(R).proxy[A],SetValues:R=>{w.batchNotify(R);},GetGroupByPath:I,notifyAll:async()=>{ue(),await W();},GetAllDependency:()=>o,GetDependencyOrder:()=>i,historyExports:k,formExports:ie,validatorExports:le,batchRenderExport:T,hasRenderGate:()=>v,onError:$,onSuccess:b,onStart:j,scheduler:w}}var he=new Map,De=(c,e,n)=>{try{if(he.has(c))throw Error("engineID repeated");let t=ke(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules??{},plugins:{}}),{SetRule:o,SetRules:r,SetValues:s,SetStrategy:a,SetValue:i,GetValue:d,usePlugin:l,useEntangle:y,GetGroupByPath:m,notifyAll:g,SetTrace:u,GetAllDependency:f,GetDependencyOrder:P,historyExports:k,formExports:v,validatorExports:T,batchRenderExport:$,hasRenderGate:D,onError:b,onSuccess:_,onStart:j,scheduler:Q}=t,G={config:{SetRule:o,SetRules:r,SetStrategy:a,notifyAll:g,SetTrace:u,usePlugin:l,hasRenderGate:D,useEntangle:y},data:{SetValue:i,GetValue:d,SetValues:s,GetGroupByPath:m},dependency:{GetAllDependency:f,GetDependencyOrder:P},hooks:{onError:b,onSuccess:_,onStart:j}},H=(p,M,w)=>{!M||typeof M!="object"||Object.keys(M).forEach(I=>{let L=M[I];if(typeof L=="object"&&L!==null)p[I]=p[I]||{},H(p[I],L,w);else if(typeof L=="function"){let W=I;if(W==="useMeshRenderGate")W="render";else if(W.startsWith("use")){let re=W.slice(3);W=re.charAt(0).toLowerCase()+re.slice(1);}I==="useHistory"&&w.exports.history&&Object.keys(w.exports.history).length>0?p[W]=w.exports.history:I==="useInternalForm"&&w.exports.form&&Object.keys(w.exports.form).length>0?p[W]=w.exports.form:I==="useSchemaValidators"&&w.exports.validator&&Object.keys(w.exports.validator).length>0?p[W]=w.exports.validator:I==="useMeshRenderGate"&&w.exports.render?p[W]=w.exports.render:p[W]=L(w.scheduler,w.Schema);}});},h={...G,modules:{}},x=n.modules;return x&&H(h.modules,x,{scheduler:Q,Schema:e,exports:{history:k,form:v,validator:T,render:$}}),he.set(c,h),h}catch(t){throw Error(t)}},At=()=>(c,e,n)=>Le(c,e,n),Gt=c=>{let e=he.get(c);if(!e)throw Error(`[MeshFlow] Engine ID "${String(c)}" not found. Ensure it is initialized with useMeshFlow.`);return e},Ot=c=>{he.delete(c);},Le=De;export{Se as TriggerCause,Ot as deleteEngine,Gt as useEngine,De as useEngineManager,Le as useMeshFlow,At as useMeshFlowDefiner,Be as useScheduler};
|
|
1
|
+
var we=(t=>(t.OR="OR",t.PRIORITY="PRIORITY",t.MERGE="MERGE",t))(we||{}),Te=class{computedRules=[];store={OR:(e,n)=>{let t,i,l=this.computedRules;for(let o=0;o<l.length;o++){let s=l[o],r=s.logic(e);if(r instanceof Promise)return (async()=>{let a=await r;if(s.entityId==="__base__"?i=a:a&&(t=a),typeof t>"u")for(let c=o+1;c<l.length;c++){let w=l[c],h=w.logic(e),p=h instanceof Promise?await h:h;if(w.entityId==="__base__"){i=p;continue}if(p){t=w.value;break}}return typeof t>"u"&&(t=i),{res:t,version:n}})();let u=r;if(s.entityId==="__base__"){i=u;continue}if(u){t=s.value;break}}return typeof t>"u"&&(t=i),{res:t,version:n}},PRIORITY:(e,n)=>{let t,i=this.computedRules;for(let l=0;l<i.length;l++){let s=i[l].logic(e);if(s instanceof Promise)return (async()=>{let r=await s;if(r!==void 0)return {res:r,version:n};for(let u=l+1;u<i.length;u++){let a=i[u].logic(e),c=a instanceof Promise?await a:a;if(c!==void 0)return {res:c,version:n}}return {res:void 0,version:n}})();if(s!==void 0)return {res:s,version:n}}return {res:t,version:n}},MERGE:(e,n)=>{let t,i,l=this.computedRules,o=(r,u)=>r===void 0?u:u===void 0?r:Array.isArray(r)&&Array.isArray(u)?[...u,...r]:typeof r=="object"&&typeof u=="object"?{...u,...r}:r;for(let r=0;r<l.length;r++){let u=l[r],a=u.logic(e);if(a instanceof Promise)return (async()=>{let w=await a,h=(f,g)=>{if(f.entityId==="__base__")i=o(i,g);else if(g){let x=f.value!==void 0?f.value:g;t=o(t,x);}};h(u,w);for(let f=r+1;f<l.length;f++){let g=l[f],x=g.logic(e),O=x instanceof Promise?await x:x;h(g,O);}return {res:o(t,i),version:n}})();let c=a;if(u.entityId==="__base__"){i=o(i,c);continue}if(c){let w=u.value!==void 0?u.value:c;t=o(t,w);}}return {res:o(t,i),version:n}}};CurrentStrategy=()=>{};CurrentStrategyType="PRIORITY";getRules=()=>{};constructor(e){this.getRules=e,this.CurrentStrategy=this.store.PRIORITY,this.updateComputedRules();}updateComputedRules(){let e=this.getRules();this.CurrentStrategyType==="PRIORITY"||this.CurrentStrategyType==="MERGE"?this.computedRules=Array.from(e.values()).map(n=>Array.from(n)).flat().sort((n,t)=>t.priority-n.priority):this.computedRules=Array.from(e.values()).map(n=>Array.from(n)).flat();}setStrategy(e){this.CurrentStrategyType=e,this.CurrentStrategy=this.store[e],this.updateComputedRules();}evaluate(e,n){return this.CurrentStrategy(e,n)}},ye=class{path;strategy;contract;rules=new Map;isValue=false;id=0;cache=void 0;pendingPromise=null;version=0;deps=new Map;_forceNotify=false;promiseToken=null;useCache=true;effectArray=[];constructor(e,n,t){let i=()=>this.rules;this.strategy=new Te(i),this.path=t,this.isValue=n==="value",this.contract=this.inferType(e),this.cache=e,this.setRule({priority:0,entityId:"__base__",logic:()=>e});}setUseCache(e){this.useCache=e;}forceNotify(){this._forceNotify=true;}isForceNotify(){return this._forceNotify}setStrategy(e){this.strategy.setStrategy(e);}setDefaultRule(e){let n=new Set;n.add(e),this.rules.set("defaultRules",n);}setRules(e,n){n&&this.updateDeps(n);let t=++this.id,i={...e,entityId:t};for(let l of e.triggerPaths)this.rules.has(l)||this.rules.set(l,new Set),this.rules.get(l).add(i);return this.strategy.updateComputedRules(),()=>{for(let l of e.triggerPaths){let o=this.rules.get(l);o&&(o.delete(i),o.size===0&&(this.rules.delete(l),this.deps.delete(l)));}this.strategy.updateComputedRules();}}updateDeps(e){for(let[n,t]of e)this.deps.set(n,t);}setRule(e,n){if(n&&this.updateDeps(n),typeof e.entityId=="string"){this.setDefaultRule(e);return}let t=++this.id,i={...e,entityId:t};if(e)for(let l of e.triggerPaths)this.rules.has(l)||this.rules.set(l,new Set),this.rules.get(l).add(i);return this.strategy.updateComputedRules(),()=>{for(let l of e.triggerPaths){let o=this.rules.get(l);o&&(o.delete(i),o.size===0&&(this.rules.delete(l),this.deps.delete(l)));}this.strategy.updateComputedRules();}}setSideEffect(e){this.effectArray.push(e);}getSideEffect(){return [...this.effectArray]}evaluate(e){let n=null;if(e.GetToken&&(n=e.GetToken()),this.pendingPromise&&this.promiseToken!==n&&(this.pendingPromise=null,this.promiseToken=null),this.pendingPromise)return this.pendingPromise;let t=false;if(typeof e.triggerPath=="string"){t=true;let o=this.deps.get(e.triggerPath),s=e.getStateByPath(e.triggerPath);if(typeof o=="object"||typeof s=="object")t=false;else {let r=Array.from(this.deps.keys());for(let u of r){let a=this.deps.get(u),c=e.getStateByPath(u);if(a!==c){t=false;break}}}}if(t&&this.useCache)return this.cache;this.promiseToken=n;let i=++this.version,l=this.strategy.evaluate(e,i);if(!(l instanceof Promise)){let{res:o,version:s}=l;return this.finalizeSync(o,s,e,n)}return this.pendingPromise=(async()=>{try{let{res:o,version:s}=await l;return this.finalizeSync(o,s,e,n)}catch(o){throw {path:this.path,error:o}}finally{this.promiseToken===n&&(this.pendingPromise=null,this.promiseToken=null);}})(),this.pendingPromise}finalizeSync(e,n,t,i){return i!==this.promiseToken||n<this.version?this.cache:(this.cache=e,this.deps.forEach((l,o)=>{this.deps.set(o,t.GetRenderSchemaByPath(o));}),e)}inferType(e){return Array.isArray(e)?"array":typeof e}};var Re=(d,e,n)=>{let i=l=>{let o=n.triggerPaths.map(u=>{let a=l.GetRenderSchemaByPath(u),c={};return n.triggerKeys.forEach(w=>{c[w]=a[w];}),c}),s=Object.create(null);return Object.defineProperty(s,"triggerTargets",{get:()=>o}),Object.defineProperty(s,"affectedTatget",{get:()=>l.GetRenderSchemaByPath(d)[e]}),n.logic({slot:s})};return {value:n.value,targetPath:d,triggerPaths:n.triggerPaths,priority:n.priority??10,logic:i}},be=(d,e,n)=>{if(!d)throw Error("");let t=d,i=(s,r)=>{e.has(s)||e.set(s,new Set),e.get(s).add(r),n.has(r)||n.set(r,new Set),n.get(r).add(s);};return {SetRule:(s,r,u,a)=>{let c=t(r),w=a.triggerKeys||[];w.length==0&&w.push("value");let h=Re(r,u,{...a,triggerPaths:[s],triggerKeys:w}),p=[s].map(f=>[f,t(f).state.value]);if(i(s,r),c.nodeBucket[u])c.nodeBucket[u].setRule(h,p),a.effect&&c.nodeBucket[u].setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[u]});else {let f=c.meta[u],g=new ye(f,u,r);g.setRule(h,p),a.effect&&g.setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[u]}),c.nodeBucket[u]=g;}c.state[u]=c.meta[u],a.forceNotify&&c.nodeBucket[u].forceNotify(),a.cacheStrategy=="none"&&c.nodeBucket[u].setUseCache(false);},SetRules:(s,r,u,a)=>{let c=t(r);for(let f of s)i(f,r);let w=a.triggerKeys||[];w.length==0&&w.push("value");let h=Re(r,u,{...a,triggerPaths:s,triggerKeys:w}),p=s.map(f=>[f,t(f).state.value]);if(c.nodeBucket[u])c.nodeBucket[u].setRules(h,p),a.effect&&c.nodeBucket[u].setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[u]});else {let f=c.meta[u],g=new ye(f,u,r);g.setRules(h,p),a.effect&&g.setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[u]}),c.nodeBucket[u]=g;}c.state[u]=c.meta[u],a.forceNotify&&c.nodeBucket[u].forceNotify(),a.cacheStrategy=="none"&&c.nodeBucket[u].setUseCache(false);}}};var Ae=d=>{let e=d||void 0;if(!e)throw Error("");return {SetStrategy:(t,i,l)=>{e(t).nodeBucket[i].setStrategy(l);}}};function Ge(){let d=new Map,e=new Map,n=new Set,t=(o,s)=>{d.set(o,s);let r=e.get(o);r&&r(s);};return {SetTrace:(o,s)=>{e.set(o,s);let r=d.get(o)||"idle";return s(r),{cancel:()=>{e.delete(o);}}},useTrace:()=>({apply:s=>{s.on("flow:start",()=>{n.forEach(r=>t(r,"idle")),n.clear(),d.clear();}),s.on("node:release",({path:r,type:u})=>{(u==1||u==2)&&(n.add(r),t(r,"pending"));}),s.on("node:pending",({path:r})=>{n.add(r),(!d.has(r)||d.get(r)==="idle")&&t(r,"pending");}),s.on("node:start",({path:r})=>{n.add(r),t(r,"calculating");}),s.on("node:success",({path:r})=>{t(r,"calculated");}),s.on("node:intercept",({path:r,type:u})=>{u==3&&t(r,"calculating"),u==6&&t(r,"idle");}),s.on("node:stagnate",({path:r})=>{t(r,"pending");}),s.on("node:error",({path:r})=>t(r,"error"));}})}}function Oe(d,e,n,t){let i=a=>{let c=d(),w=e(),h=new Set;return c.get(a)?.forEach(p=>h.add(p)),h.size===0?[]:Array.from(h).filter(p=>{let f=w.get(p)||new Set;return !Array.from(f).some(O=>h.has(O))})};return {GetNextDependency:a=>{let c=t();return Array.from(c.get(a)||[])},GetPrevDependency:a=>{let c=n();return Array.from(c.get(a)||[])},GetAllPrevDependency:a=>{let c=e();return Array.from(c.get(a)||[])},GetAllNextDependency:a=>{let c=d();return Array.from(c.get(a)||[])},rebuildDirectDependencyMaps:a=>{let c=new Map,w=new Map;for(let h of a){let p=i(h);c.set(h,new Set(p));for(let f of p)w.has(f)||w.set(f,new Set),w.get(f).add(h);}return {directNextMap:c,directPrevMap:w}}}}function Fe(d){let e=t=>{let i=[],l=[],o=new Map,s=t.size,r=0,u=0;for(let[a,c]of t)c===0&&l.push(a);if(l.length===0&&s>0)throw Error("Circular dependency detected");for(;l.length>0;){i.push([...l]);let a=[];for(let c of l){r++,o.set(c,u);let w=d.get(c);if(w)for(let h of w){let p=t.get(h)-1;t.set(h,p),p===0&&a.push(h);}}l=a,u++;}if(r<s)throw Error("Circular dependency detected");return {steps:i,levelMap:o}};return ()=>{let t=new Map;for(let i of d.keys()){let l=Array.from(d.get(i)||[]);t.has(i)||t.set(i,0);for(let o of l){let s=t.get(o)||0;t.set(o,++s);}}return e(t)}}var ue=()=>{let d=[];return {on:e=>(d.push(e),()=>{let n=d.indexOf(e);n>-1&&d.splice(n,1);}),call:e=>d.forEach(n=>{n(e);})}};function Ke(){let{on:d,call:e}=ue();return {onError:d,callOnError:e}}function Ie(){let{on:d,call:e}=ue();return {onSuccess:d,callOnSuccess:e}}var Ce=()=>{let d=new Set,e=new Map,n=new Set,t=(s,r)=>{e.get(s)?.forEach(u=>u(r));},i=(s,r)=>(e.has(s)||e.set(s,new Set),e.get(s).add(r),()=>e.get(s)?.delete(r));return {usePlugin:s=>{let r=new Set,u=(c,w)=>{let h=i(c,w);return r.add(h),h};s.apply({on:u}),d.add(s);let a=()=>{r.forEach(c=>c()),r.clear(),d.delete(s),n.delete(a);};return n.add(a),a},emit:t,destroyPlugin:()=>{n.forEach(s=>s()),n.clear(),e.clear(),d.clear();}}};function ke(){let{on:d,call:e}=ue();return {onStart:d,callOnStart:e}}var Be=(d={frameQuota:12})=>{let e=performance.now(),n=0,t=false,i=()=>!!navigator?.scheduling?.isInputPending?.({includeContinuous:true});return {getIsFirstFrame:()=>t,reset(){e=performance.now(),n=0,t=true;},shouldYield(){let l=performance.now();return n++,!!((n>=5||t)&&(n=0,l-e>d.frameQuota||i()))},async yieldToMain(){return new Promise(l=>{ve(()=>{e=performance.now(),n=0,t&&(t=false),l();});})}}},ve=d=>{let{port1:e,port2:n}=new MessageChannel;e.onmessage=d,n.postMessage(null);};var xe=(t=>(t[t.CAUSALITY=0]="CAUSALITY",t[t.INVERSION=1]="INVERSION",t[t.REPERCUSSION=2]="REPERCUSSION",t))(xe||{});function Ue(d,e,n,t,i,l){let o=new Map,s=d.useGreedy,r=null;return async(a,c)=>{let h=Symbol("token"),p=a||"__NOTIFY_ALL__";o.set(p,h),r=h;let f=false;l.reset();let g=new Set,x=new Set,O=new Set;c.forEach(C=>{O.add(C),e.GetAllNextDependency(C).forEach(v=>O.add(v));});let G=new Map,R=new Map,V=new Map,b=[],L=n.Turnstile,k=L.volatileLevels.size>0,ee=k?L.hasObserver:()=>false,K=k?L.receiveGhosts:()=>[],N=k?L.resolveGhosts:()=>[],y=k?L.getTriggerKeys:()=>[],M=L?.volatileLevels||new Set,S=-1,P=new Set,T=e.GetPathToLevelMap(),A=0,z=0,q=C=>{e.GetAllNextDependency(C).forEach(ne=>{let j=T.get(ne)||0;j>z&&(z=j);});},Z=new Set;a&&(g.add(a),Z.add(a),q(a),i.flushPathSet.add(a));let re=a?[a]:c;l.shouldYield()&&(i.requestUpdate(),await l.yieldToMain());let ce=re.map(async C=>{if(ee(C)){let v=n.GetNodeByPath(C),ne=y(C);if(ne.length>0){let j=K(v,ne);return j instanceof Promise&&(j=await j),{seed:C,hitTargets:j}}}return {seed:C,hitTargets:[]}});if((await Promise.all(ce)).forEach(({seed:C,hitTargets:v})=>{if(v&&v.length>0){b.push(...v);let ne=T.get(C)||0;S=Math.max(S,ne);}}),(b.length>0||re.length>1)&&(i.requestUpdate(),await l.yieldToMain(),o.get(p)!==h))return;let Pe=b.length>0;c.forEach(C=>{if(!Z.has(C))if(Pe){let v=T.get(C)??0;R.has(v)||R.set(v,new Set),R.get(v).add(C),t.emit("node:stagnate",{path:C,type:2});}else P.add(C),q(C);}),a?A=T.get(a)??0:A=Math.min(...c.map(C=>T.get(C)??0));let ge=performance.now();t.emit("flow:start",{path:p,token:h}),t.callOnStart({path:p});let de=false,me=30,Me=C=>{let{target:v,trigger:ne}=C,j=false,se=false,oe=false,I=n.GetNodeByPath(v),_=I.calledBy,Y=[],Q=[],B=false;if(I.calledBy===1){B=true,j=true,i.flushPathSet.add(v);let m=V.get(v);m&&(Y.push(...m),V.delete(v));}let W=(m,F)=>{let H=T.get(m)??0,J=(_===1||_===2)&&H<=S;J&&g.has(m)&&(g.delete(m),t.emit("node:revive",{path:m,triggerPath:v}));let D=0;if(!(g.has(m)||x.has(m)||P.has(m))){if(G.has(m))D=G.get(m)-1;else {if(H>A&&G.size>me){R.has(H)||R.set(H,new Set),R.get(H).add(m),t.emit("node:intercept",{path:m,type:7});return}let ae=e.GetPrevDependency(m),te=0;for(let ie of ae){if(g.has(ie))continue;(T.get(ie)??0)>A&&te++;}D=te;}if(D<=0){let ae=P.has(m),te=x.has(m);if(ae||te){t.emit("node:intercept",{path:m,type:te?3:3.1});return}G.delete(m);let ie=n.GetNodeByPath(m);J?ie.calledBy=2:ie.calledBy=0,P.add(m),t.emit("node:release",{path:m,type:F,detail:{path:v}});}else G.set(m,D);}},X=(m=[])=>{if(o.get(p)!==h)return;if(m.length){let H={},J=I.proxy;for(let D of m){let ae=(D.args||[]).reduce((te,ie)=>(te[ie]=J[ie],te),{});try{let te=D.fn(ae);te&&typeof te=="object"&&Object.assign(H,te);}catch(te){}}for(let D in H)if(D in I.state)Object.is(I.state[D],H[D])||(I.state[D]=H[D],Y.push(D),j=true,(I.notifyKeys.size===0||I.notifyKeys.has(D))&&(se=true));else throw {error:`wrong effect in ${String(I.path)}`}}j&&i.flushPathSet.add(v);let F=(H=[])=>{if(o.get(p)!==h)return;H&&H.length>0&&(b.push(...H),S=Math.max(S,T.get(v)||0)),Y.length=0,t.emit("node:success",{path:v,calledBy:I.calledBy}),g.add(v);let J=e.GetNextDependency(v);(se||oe)&&(q(v),e.GetAllNextDependency(v).forEach(le=>O.add(le)));let D=n.GetNodeByPath(v),ae=T.get(v)??0,te=M.has(ae)||b.length>0;for(let $ of J){let le=T.get($)??0;if(te&&le>=ae){R.has(le)||R.set(le,new Set),R.get(le).add($),t.emit("node:stagnate",{path:$,type:2});continue}if(g.has($)){t.emit("node:intercept",{path:$,type:2});continue}if(x.has($)||P.has($)){t.emit("node:intercept",{path:$,type:x.has($)?3:3.1});continue}if(se||oe)W($,1);else if(G.has($))W($,2);else {let Se=T.get($);R.has(Se)||R.set(Se,new Set);let Ee=R.get(Se);Ee.has($)||(Ee.add($),t.emit("node:stagnate",{path:$,type:1}));}}x.delete(v),D.calledBy=0,(()=>{if(!f){f=true;let $=x.size,le=P.size;t.emit("flow:fire",{path:v,type:1,detail:{active:$,pending:le,blocked:G.size}}),fe();}})();};if(ee(v)&&Y.length>0){let H=n.GetNodeByPath(v),J=K(H,Y);J instanceof Promise||J&&typeof J.then=="function"?J.then(F).catch(E):F(J);}else F([]);},E=m=>{t.emit("node:error",{path:v,error:m});let F=Symbol("abort");o.set(p,F),P.clear(),G.clear(),x.clear(),V.clear(),t.callOnError(m);},U=(m,F)=>{m!==I.state[F]&&(I.state[F]=m,j=true,Y.push(String(F)),t.emit("node:bucket:success",{path:v,key:String(F),value:m,calledBy:I.calledBy}),(I.notifyKeys.size===0||I.notifyKeys.has(F))&&(se=true)),I.nodeBucket[F].isForceNotify()&&(oe=true),(se||oe)&&q(v);};t.emit("node:start",{path:v,calledBy:I.calledBy});try{let m=[];for(let F in I.nodeBucket){let H=I.nodeBucket[F];if(m.push(...H.getSideEffect()),B){t.emit("node:bucket:success",{path:v,key:String(F),value:I.state[F],calledBy:I.calledBy}),H.isForceNotify()&&(oe=!0),(I.notifyKeys.size===0||I.notifyKeys.has(F))&&q(v);continue}let J=H.evaluate({affectKey:F,triggerPath:ne,GetRenderSchemaByPath:D=>n.GetNodeByPath(D).proxy,getStateByPath:D=>n.GetNodeByPath(D).state,GetToken:()=>h});if(J instanceof Promise){let D=J.then(ae=>{o.get(p)===h&&U(ae,F);});Q.push(D);}else U(J,F);}if(Q.length>0)return Promise.all(Q).then(()=>{X(m);}).catch(E);X(m);return}catch(m){E(m);}},fe=async()=>{if(o.get(p)!==h){f=false;return}f=true;let C=l.getIsFirstFrame(),v=0,ne=()=>s&&C?30:1/0,j=0,se=ne();try{for(;o.get(p)===h;){let oe=j>=se,I=l.shouldYield();if(oe||I){if(j>0&&(v++,(C||v%2===0)&&i.requestUpdate()),await l.yieldToMain(),o.get(p)!==h)break;j=0,C=l.getIsFirstFrame();}if(P.size>0&&x.size<40){for(let _ of P){if(x.size>=40||j>=se)break;let Y=T.get(_)??0,Q=e.GetPrevDependency(_),B=Q.length>1;if((!s||B)&&Y>A){P.delete(_);let E=Q.filter(U=>O.has(U)&&!g.has(U)).length;G.set(_,E||0),t.emit("node:intercept",{path:_,type:E>0?4:5,detail:{targetLevel:Y,currentLevel:A,pendingParentsCount:E}});continue}P.delete(_),x.add(_);let X=n.GetNodeByPath(_);if(t.emit("node:processing",{path:_,calledBy:X.calledBy}),Me({target:_,trigger:a}),j++,j>=se||l.shouldYield())break}if(P.size>0)continue}if(j<se&&s&&G.size>0&&x.size<40){let _=!1,Y=0;for(let[Q,B]of G)if(B<=0){let W=T.get(Q)??0,X=e.GetPrevDependency(Q);if(W>A&&X.length>1)continue;if(G.delete(Q),P.add(Q),Y++,_=!0,t.emit("node:release",{path:Q,type:4}),Y>=se)break}if(Y>0)continue;if(_){if(l.shouldYield()&&(await l.yieldToMain(),o.get(p)!==h))break;continue}}if(x.size===0&&P.size===0){if(b.length>0){let B=!1,W=A,X=Array.from(new Set(b));b.length=0;for(let E of X){let U=n.GetNodeByPath(E),m=N(U);if(m&&m.length>0){B=!0,U.calledBy=1,V.set(E,m),g.delete(E),G.delete(E),P.add(E);let F=T.get(E)??0;F<W&&(W=F),q(E),i.flushPathSet.add(E);}}if(B){if(W<A&&(A=W),i.requestUpdate(),l.shouldYield()&&(await l.yieldToMain(),o.get(p)!==h))break;continue}}let _=new Set;for(let B of R.keys())_.add(B);for(let[B]of G){let W=T.get(B)??0;W>A&&_.add(W);}let Y=Array.from(_).sort((B,W)=>B-W),Q=Y[0];if(Y.length>0&&Q<=z){let B=Y[0];if(B<=z){A=B;let W=R.get(B);W&&(W.forEach(X=>P.add(X)),R.delete(B));for(let[X]of G)(T.get(X)??0)===B&&(G.delete(X),P.add(X),t.emit("node:release",{path:X,type:3,detail:{level:B}}));continue}}else {R.forEach((B,W)=>{B.forEach(X=>{g.add(X),t.emit("node:intercept",{path:X,type:6});});}),R.clear();for(let[B]of G)g.add(B),t.emit("node:intercept",{path:B,type:6});G.clear();break}}P.size>0&&x.size>=40&&t.emit("flow:wait",{type:2});break}}finally{f=false;let oe=x.size+G.size+P.size,I=L.inFlightCount||0;if(!(r===h)){t.emit("flow:abort",{token:h});return}if(i.requestUpdate(),oe===0&&I===0){if(o.get(p)===h&&!de){de=true,t.emit("flow:end",{type:1}),L.resetCounters(),V.clear();let Y=performance.now();S=-1,o.delete(p),t.emit("flow:success",{token:h,duration:(Y-ge).toFixed(2.1)+"ms"}),Promise.resolve().then(()=>{t.callOnSuccess();});}}else {let Y=oe===0&&I>0?3:1;if(t.emit("flow:wait",{type:Y,detail:{nums:x.size,asyncNums:I}}),I>0){let Q=()=>{r===h&&(L.inFlightCount===0?ve(()=>{L.inFlightCount===0?fe():requestAnimationFrame(Q);}):requestAnimationFrame(Q));};requestAnimationFrame(Q);}}}};fe();}}function Ne(d){let{path:e,uid:n,type:t,meta:i,dirtySignal:l,state:o}=d,s=null,r=["path","uid","type","dependOn","nodeBucket"],a={path:e,uid:n,type:t,meta:i,dirtySignal:l,createView:(c={})=>{if(s&&Object.keys(c).length===0)return s;let w=new Proxy(c,{get(h,p){let f=p;return Reflect.has(h,p)?Reflect.get(h,p):f in d.state?d.state[f]:f in d?d[f]:i&&f in i?i[f]:Reflect.get(h,p)},set(h,p,f){let g=p;return g in d.state?(d.state[g]=f,true):Reflect.set(h,p,f)},ownKeys(h){let p=new Set([...Reflect.ownKeys(h),...Object.keys(o||{}),...Object.keys(i||{}),...r]);return Array.from(p)},getOwnPropertyDescriptor(h,p){let f=p;return Reflect.has(h,p)||o&&f in o||i&&f in i||r.includes(f)?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(h,p)}});return s=w,w}};return "children"in d?{...a,children:d.children}:{...a,state:d.state,nodeBucket:d.nodeBucket,notifyKeys:d.notifyKeys,dependOn:d.dependOn,calledBy:0,get proxy(){return s}}}var De=(d,e,n,t,i)=>{let l=d.useEntangleStep,o=new Map,s=new Map,r=new Set,u=t,c=0;return {useEntangle:f=>{let{observer:g,target:x,triggerKeys:O,emit:G,filter:R}=f;if(!O||O.length===0){i.emit("entangle:warn",{path:g,type:"no_keys"});return}o.has(g)||o.set(g,new Map);let V=o.get(g);O.forEach(b=>{V.has(b)||V.set(b,[]),V.get(b).push({target:x,emit:G,filter:R,count:0});});},updateEntangleLevel:()=>{let f=n();r.clear();for(let g of o.keys()){let x=f.get(g)||0;r.add(x);}},Turnstile:{volatileLevels:r,get inFlightCount(){return c},get hasPendingGhosts(){for(let f of s.values())if(f.length>0)return true;return false},onSettle:f=>{},hasObserver:f=>o.has(f),getTriggerKeys:f=>{let g=o.get(f);return g?Array.from(g.keys()):[]},receiveGhosts:(f,g=[])=>{let x=f.path,O=[],G=o.get(x);if(!G||g.length===0)return O;let R=new Set;g.forEach(N=>{let y=G.get(N);y&&y.forEach(M=>R.add(M));});let V=N=>N instanceof Promise||N!==null&&typeof N=="object"&&typeof N.then=="function",b=N=>{let y=N.target;if(N.count>=l){i.emit("entangle:blocked",{observer:x,target:y,count:N.count});return}let M=u(y);if(N.filter&&!N.filter(f.proxy,M.proxy))return;let S=N.emit(f.proxy,M.proxy),P=T=>{if(T&&T.key!==void 0){if(T.delta===void 0&&T.value!==void 0&&T.value===M.state[T.key])return;N.count++,s.has(y)||s.set(y,[]),s.get(y).push({weight:1,...T}),O.push(y);}};if(V(S))return c++,(async()=>{try{let T=await S;P(T);}catch(T){i.emit("node:error",{path:x,error:T}),i.onError({path:x,error:T});}finally{c--;}})();P(S);},L=Array.from(R),k=0,ee=false,K=null;for(;k<L.length;k++){if(e.shouldYield()){ee=true;break}let N=b(L[k]);if(N){K=N,ee=true,k++;break}}return ee?(async()=>{K&&await K,e.shouldYield()&&await e.yieldToMain();let N=50;for(;k<L.length;k+=N){let y=L.slice(k,k+N),M=[];for(let S of y){let P=b(S);P&&M.push(P);}if(M.length>0){let S=M.map(async P=>{await P,e.shouldYield()&&await e.yieldToMain();});await Promise.all(S);}e.shouldYield()&&await e.yieldToMain();}return Array.from(new Set(O))})():Array.from(new Set(O))},resolveGhosts:f=>{let g=f.path,x=s.get(g);if(!x||x.length===0)return [];let O=[],G=new Map;for(let R of x)G.has(R.key)||G.set(R.key,[]),G.get(R.key).push(R);for(let[R,V]of G.entries()){let b=f.state[R],L=V.filter(k=>k.patch!==void 0);if(L.length>0)b=L.reduce((k,ee)=>ee.patch(k),b);else {let k=V.filter(K=>K.delta!==void 0),ee=V.filter(K=>K.value!==void 0);ee.length>0&&(b=ee.reduce((N,y)=>(y.weight??1)>=(N.weight??1)?y:N).value),k.length>0&&(b=k.reduce((K,N)=>{switch(N.op||"add"){case "add":return (typeof K=="number"?K:0)+N.delta;case "remove":return Array.isArray(K)?K.filter(M=>M!==N.delta):K;case "intersect":return Array.isArray(K)?K.filter(M=>N.delta.includes(M)):N.delta;case "union":{let M=Array.isArray(K)?K:[],S=Array.isArray(N.delta)?N.delta:[N.delta];return [...new Set([...M,...S])]}case "merge":{let M=typeof K=="object"&&K!==null&&!Array.isArray(K)?K:{},S=typeof N.delta=="object"&&N.delta!==null&&!Array.isArray(N.delta)?N.delta:{};return {...M,...S}}default:return K}},b));}Object.is(f.state[R],b)||(f.state[R]=b,O.push(R));}return s.set(g,[]),O.length>0?O:[]},resetCounters:()=>{for(let f of o.values())for(let g of f.values())g.forEach(x=>x.count=0);}}}};function Ve(d,e,n,t,i){let l=Be(),o=0,s=new Map,r=[],u=[],a=false,c=new Set,h=async()=>{let y=Array.from(c);if(c.clear(),"signalTrigger"in i&&typeof i.signalTrigger=="function")for(let M of y){let S=b(M);i.signalTrigger(S.dirtySignal);}else "emit"in i&&i.emit(y);},p=()=>{a||(a=true,requestAnimationFrame(()=>{try{for(;c.size>0;)h();}finally{a=false;}}));},{useEntangle:f,updateEntangleLevel:g,Turnstile:x}=De({useEntangleStep:d.useEntangleStep},l,e.GetPathToLevelMap,b,{emit:t.emit,onError:t.callOnError}),O=Ue({useGreedy:d.useGreedy},e,{GetNodeByPath:b,Turnstile:x},t,{requestUpdate:p,flushPathSet:c},l),G=y=>{throw new Error(`[MeshFlow] Duplicate Path: ${y}`)},R=y=>{s.has(y.path)&&G(String(y.path));let M=++o,S={path:y.path,getNode:A=>b(A)},P=(A,z="value")=>{let q=A({...S}),Z=b(y.path);if(n.createHistoryAction&&n.pushIntoHistory){let re=n.createHistoryAction([{path:y.path,value:Z.state[z]},{path:y.path,value:q}],ce=>{let pe=b(ce.path);pe.state[z]=ce.value,k(ce.path);});n.pushIntoHistory(re);}Z.state[z]=q,k(y.path);},T=Ne({uid:M,type:y.type,path:y.path,state:y.state,meta:y.meta,nodeBucket:{},dirtySignal:"signalCreator"in i?i.signalCreator():void 0,notifyKeys:y.notifyKeys,dependOn:P});return s.set(T.path,M),r[M]=T,T},V=y=>{s.has(y.path)&&G(String(y.path));let M=++o,S=Ne({uid:M,type:y.type,path:y.path,state:{},meta:y,nodeBucket:{},children:y.children});return s.set(S.path,M),u[M]=S,S};function b(y){let M=s.get(y),S=r[M];if(!S)throw Error("wrong ID");return S}function L(y){let M=s.get(y);return u[M]}let k=y=>{if(!b(y))throw Error("Node undefined");c.add(y),p();let S=e.GetNextDependency(y);ee(S,y);};function ee(y,M){O(M,y);}return {registerNode:R,registerGroupNode:V,GetNodeByPath:b,GetGroupByPath:L,notify:k,notifyAll:async()=>{Promise.resolve().then(async()=>{let y=e.GetDependencyOrder();if(!y||y.length===0)return;let M=y[0];try{O(null,M);}catch(S){throw t.callOnError(S),S}finally{p();}});},batchNotify:y=>{if(!y||y.length===0)return;if(n.createHistoryAction&&n.pushIntoHistory){let S=n.createHistoryAction([y.map(P=>({path:P.path,key:P.key,value:b(P.path).state[P.key]})),y.map(P=>({path:P.path,key:P.key,value:P.value}))],P=>{let T=new Set;P.forEach(A=>{let z=b(A.path);z.state[A.key]=A.value,c.add(A.path),T.add(A.path);}),p(),T.size>0&&O(null,Array.from(T));});n.pushIntoHistory(S);}let M=new Set;y.forEach(S=>{let P=b(S.path);P.state[S.key]=S.value,c.add(S.path),M.add(S.path);}),p(),M.size>0&&O(null,Array.from(M));},useEntangle:f,updateEntangleLevel:g,UITrigger:i,UidToNodeMap:r}}function Le(d,e){let n=false,t=false,i=false,l=false,o=new Map,s=new Map,r=new Map,u=new Map,a=[],c=new Map,{GetNextDependency:h,GetPrevDependency:p,GetAllPrevDependency:f,GetAllNextDependency:g,rebuildDirectDependencyMaps:x}=Oe(()=>o,()=>s,()=>u,()=>r),O={},G={};if(e.modules.useHistory){let E=e.modules.useHistory,U;E.isMeshModuleInited?U=E:U=E();let{Undo:m,Redo:F,PushIntoHistory:H,CreateHistoryAction:J,updateUndoSize:D,updateRedoSize:ae}=U();O.pushIntoHistory=H,O.createHistoryAction=J,G={Undo:m,Redo:F,updateUndoSize:D,updateRedoSize:ae};}let R=!!e.modules.useMeshRenderGate,V={};if(R){let E=e.modules.useMeshRenderGate.isMeshModuleInited,U=e.modules.useMeshRenderGate;V=(E?U:U())(()=>re);}let{onError:b,callOnError:L}=Ke(),{onSuccess:k,callOnSuccess:ee}=Ie(),{onStart:K,callOnStart:N}=ke(),{emit:y,usePlugin:M,destroyPlugin:S}=Ce(),{SetTrace:P,useTrace:T}=Ge(),A=T();M(A);let z=R?{...V}:{...e.UITrigger},q=Ve({useGreedy:e.config.useGreedy,useEntangleStep:e.config.useEntangleStep||100},{GetDependencyOrder:()=>a,GetAllNextDependency:g,GetNextDependency:h,GetPrevDependency:p,GetAllPrevDependency:f,GetPathToLevelMap:()=>c},O,{callOnError:L,callOnSuccess:ee,callOnStart:N,emit:y},z),{GetGroupByPath:Z,GetNodeByPath:re,notifyAll:ce,useEntangle:pe,updateEntangleLevel:Pe}=q;R&&V.init();let ge={};if(e.modules.useInternalForm){let{uiSchema:E,GetFormData:U}=e.modules.useInternalForm(q,d);ge={uiSchema:E,GetFormData:U};}let de={};if(e.modules.useSchemaValidators){let{SetValidators:E}=e.modules.useSchemaValidators(re);de={SetValidators:E};}let{SetRule:me,SetRules:Me}=be(re,o,s),{SetStrategy:fe}=Ae(re),C=Fe(o),v=()=>{let E=C();a=E.steps,c=E.levelMap,ne();},ne=()=>{i&&(Pe(),i=false);},j=()=>{l||(l=true,Promise.resolve().then(ne).finally(()=>{l=false;}));},se=()=>{t||(t=true,Promise.resolve().then(()=>{if(v(),n){let{directNextMap:E,directPrevMap:U}=x(a.flat());r=E,u=U;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(E,U,m,F)=>{me(E,U,m,F),n=true,se();},SetRules:(E,U,m,F)=>{Me(E,U,m,F),n=true,se();},SetStrategy:fe,useEntangle:E=>{pe(E),i=true,j();},SetTrace:P,usePlugin:M,SetValue:(E,U,m)=>{ne(),re(E).dependOn(()=>m,U);},GetValue:(E,U="value")=>re(E).proxy[U],SetValues:E=>{ne(),q.batchNotify(E);},GetGroupByPath:Z,notifyAll:async()=>{v(),await ce();},GetAllDependency:()=>o,GetDependencyOrder:()=>a,historyExports:G,formExports:ge,validatorExports:de,batchRenderExport:V,hasRenderGate:()=>R,onError:b,onSuccess:k,onStart:K,scheduler:q,destroyPlugin:S}}var he=new Map,_e=(d,e,n)=>{try{if(he.has(d))throw Error("engineID repeated");let t=Le(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules??{},plugins:{}}),{SetRule:i,SetRules:l,SetValues:o,SetStrategy:s,SetValue:r,GetValue:u,usePlugin:a,useEntangle:c,GetGroupByPath:w,notifyAll:h,SetTrace:p,GetAllDependency:f,GetDependencyOrder:g,historyExports:x,formExports:O,validatorExports:G,batchRenderExport:R,hasRenderGate:V,onError:b,onSuccess:L,onStart:k,scheduler:ee,destroyPlugin:K}=t,N={config:{SetRule:i,SetRules:l,SetStrategy:s,notifyAll:h,SetTrace:p,usePlugin:a,hasRenderGate:V,useEntangle:c},data:{SetValue:r,GetValue:u,SetValues:o,GetGroupByPath:w},dependency:{GetAllDependency:f,GetDependencyOrder:g},hooks:{onError:b,onSuccess:L,onStart:k}},y=(P,T,A)=>{!T||typeof T!="object"||Object.keys(T).forEach(z=>{let q=T[z];if(typeof q=="object"&&q!==null)P[z]=P[z]||{},y(P[z],q,A);else if(typeof q=="function"){let Z=z;if(Z==="useMeshRenderGate")Z="render";else if(Z.startsWith("use")){let re=Z.slice(3);Z=re.charAt(0).toLowerCase()+re.slice(1);}z==="useHistory"&&A.exports.history&&Object.keys(A.exports.history).length>0?P[Z]=A.exports.history:z==="useInternalForm"&&A.exports.form&&Object.keys(A.exports.form).length>0?P[Z]=A.exports.form:z==="useSchemaValidators"&&A.exports.validator&&Object.keys(A.exports.validator).length>0?P[Z]=A.exports.validator:z==="useMeshRenderGate"&&A.exports.render?P[Z]=A.exports.render:P[Z]=q(A.scheduler,A.Schema);}});},M={...N,destroyPlugin:K,modules:{}},S=n.modules;return S&&y(M.modules,S,{scheduler:ee,Schema:e,exports:{history:x,form:O,validator:G,render:R}}),he.set(d,M),M}catch(t){throw Error(t)}},It=()=>(d,e,n)=>He(d,e,n),Ct=d=>{let e=he.get(d);if(!e)throw Error(`[MeshFlow] Engine ID "${String(d)}" not found. Ensure it is initialized with useMeshFlow.`);return e},kt=d=>{he.get(d).destroyPlugin(),he.delete(d);},He=_e;export{we as DefaultStrategy,xe as TriggerCause,kt as deleteEngine,Ct as useEngine,_e as useEngineManager,He as useMeshFlow,It as useMeshFlowDefiner,Ve as useScheduler};
|
package/metafile-cjs.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"utils/core/engine/bucket.ts":{"bytes":
|
|
1
|
+
{"inputs":{"utils/core/engine/bucket.ts":{"bytes":20501,"imports":[],"format":"esm"},"utils/core/dependency/useSetRule.ts":{"bytes":8165,"imports":[{"path":"utils/core/engine/bucket.ts","kind":"import-statement","original":"../engine/bucket"},{"path":"../types/types","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/dependency/useStrategy.ts":{"bytes":526,"imports":[{"path":"../engine/bucket","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/plugins/useExecutionTrace.ts":{"bytes":3723,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/dependency/useDepenency.ts":{"bytes":6099,"imports":[],"format":"esm"},"utils/core/hooks/useCreateHook.ts":{"bytes":436,"imports":[],"format":"esm"},"utils/core/hooks/useOnError.ts":{"bytes":481,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"},{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/hooks/useOnSuccess.ts":{"bytes":216,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"}],"format":"esm"},"utils/core/plugins/usePlugin.ts":{"bytes":2959,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/hooks/useOnStart.ts":{"bytes":210,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"}],"format":"esm"},"utils/core/utils/util.ts":{"bytes":5758,"imports":[],"format":"esm"},"utils/core/types/types.ts":{"bytes":5908,"imports":[{"path":"../engine/bucket","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useMeshTask.ts":{"bytes":60113,"imports":[{"path":"utils/core/utils/util.ts","kind":"import-statement","original":"../utils/util"},{"path":"utils/core/types/types.ts","kind":"import-statement","original":"../types/types"}],"format":"esm"},"utils/core/engine/useMeshNode.ts":{"bytes":4002,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/dependency/useSetEntangle.ts":{"bytes":14127,"imports":[{"path":"../types/types","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useScheduler.ts":{"bytes":12626,"imports":[{"path":"../types/types","kind":"import-statement","external":true},{"path":"utils/core/engine/useMeshTask.ts","kind":"import-statement","original":"./useMeshTask"},{"path":"utils/core/engine/useMeshNode.ts","kind":"import-statement","original":"./useMeshNode"},{"path":"utils/core/utils/util.ts","kind":"import-statement","original":"../utils/util"},{"path":"utils/core/dependency/useSetEntangle.ts","kind":"import-statement","original":"../dependency/useSetEntangle"}],"format":"esm"},"utils/core/engine/useEngineInstance.ts":{"bytes":12256,"imports":[{"path":"utils/core/dependency/useSetRule.ts","kind":"import-statement","original":"../dependency/useSetRule"},{"path":"utils/core/dependency/useStrategy.ts","kind":"import-statement","original":"../dependency/useStrategy"},{"path":"utils/core/plugins/useExecutionTrace.ts","kind":"import-statement","original":"../plugins/useExecutionTrace"},{"path":"utils/core/dependency/useDepenency.ts","kind":"import-statement","original":"../dependency/useDepenency"},{"path":"utils/core/hooks/useOnError.ts","kind":"import-statement","original":"../hooks/useOnError"},{"path":"utils/core/hooks/useOnSuccess.ts","kind":"import-statement","original":"../hooks/useOnSuccess"},{"path":"utils/core/plugins/usePlugin.ts","kind":"import-statement","original":"../plugins/usePlugin"},{"path":"utils/core/hooks/useOnStart.ts","kind":"import-statement","original":"../hooks/useOnStart"},{"path":"../types/types","kind":"import-statement","external":true},{"path":"utils/core/engine/useScheduler.ts","kind":"import-statement","original":"./useScheduler"},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useEngineManager.ts":{"bytes":11202,"imports":[{"path":"../types/types","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true},{"path":"utils/core/engine/useEngineInstance.ts","kind":"import-statement","original":"./useEngineInstance"},{"path":"utils/core/types/types.ts","kind":"import-statement","original":"../types/types"},{"path":"utils/core/engine/bucket.ts","kind":"import-statement","original":"../engine/bucket"},{"path":"utils/core/engine/useScheduler.ts","kind":"import-statement","original":"../engine/useScheduler"}],"format":"esm"}},"outputs":{"lib-dist/index.js":{"imports":[],"exports":["DefaultStrategy","TriggerCause","deleteEngine","useEngine","useEngineManager","useMeshFlow","useMeshFlowDefiner","useScheduler"],"entryPoint":"utils/core/engine/useEngineManager.ts","inputs":{"utils/core/engine/bucket.ts":{"bytesInOutput":5020},"utils/core/dependency/useSetRule.ts":{"bytesInOutput":1754},"utils/core/dependency/useStrategy.ts":{"bytesInOutput":115},"utils/core/plugins/useExecutionTrace.ts":{"bytesInOutput":760},"utils/core/dependency/useDepenency.ts":{"bytesInOutput":1244},"utils/core/hooks/useCreateHook.ts":{"bytesInOutput":122},"utils/core/hooks/useOnError.ts":{"bytesInOutput":68},"utils/core/hooks/useOnSuccess.ts":{"bytesInOutput":72},"utils/core/plugins/usePlugin.ts":{"bytesInOutput":424},"utils/core/hooks/useOnStart.ts":{"bytesInOutput":68},"utils/core/utils/util.ts":{"bytesInOutput":472},"utils/core/types/types.ts":{"bytesInOutput":117},"utils/core/engine/useMeshTask.ts":{"bytesInOutput":7679},"utils/core/engine/useMeshNode.ts":{"bytesInOutput":932},"utils/core/dependency/useSetEntangle.ts":{"bytesInOutput":3145},"utils/core/engine/useScheduler.ts":{"bytesInOutput":2496},"utils/core/engine/useEngineInstance.ts":{"bytesInOutput":2428},"utils/core/engine/useEngineManager.ts":{"bytesInOutput":1881}},"bytes":28967}}}
|
package/metafile-esm.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"utils/core/engine/bucket.ts":{"bytes":
|
|
1
|
+
{"inputs":{"utils/core/engine/bucket.ts":{"bytes":20501,"imports":[],"format":"esm"},"utils/core/dependency/useSetRule.ts":{"bytes":8165,"imports":[{"path":"utils/core/engine/bucket.ts","kind":"import-statement","original":"../engine/bucket"},{"path":"../types/types","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/dependency/useStrategy.ts":{"bytes":526,"imports":[{"path":"../engine/bucket","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/plugins/useExecutionTrace.ts":{"bytes":3723,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/dependency/useDepenency.ts":{"bytes":6099,"imports":[],"format":"esm"},"utils/core/hooks/useCreateHook.ts":{"bytes":436,"imports":[],"format":"esm"},"utils/core/hooks/useOnError.ts":{"bytes":481,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"},{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/hooks/useOnSuccess.ts":{"bytes":216,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"}],"format":"esm"},"utils/core/plugins/usePlugin.ts":{"bytes":2959,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/hooks/useOnStart.ts":{"bytes":210,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"}],"format":"esm"},"utils/core/utils/util.ts":{"bytes":5758,"imports":[],"format":"esm"},"utils/core/types/types.ts":{"bytes":5908,"imports":[{"path":"../engine/bucket","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useMeshTask.ts":{"bytes":60113,"imports":[{"path":"utils/core/utils/util.ts","kind":"import-statement","original":"../utils/util"},{"path":"utils/core/types/types.ts","kind":"import-statement","original":"../types/types"}],"format":"esm"},"utils/core/engine/useMeshNode.ts":{"bytes":4002,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/dependency/useSetEntangle.ts":{"bytes":14127,"imports":[{"path":"../types/types","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useScheduler.ts":{"bytes":12626,"imports":[{"path":"../types/types","kind":"import-statement","external":true},{"path":"utils/core/engine/useMeshTask.ts","kind":"import-statement","original":"./useMeshTask"},{"path":"utils/core/engine/useMeshNode.ts","kind":"import-statement","original":"./useMeshNode"},{"path":"utils/core/utils/util.ts","kind":"import-statement","original":"../utils/util"},{"path":"utils/core/dependency/useSetEntangle.ts","kind":"import-statement","original":"../dependency/useSetEntangle"}],"format":"esm"},"utils/core/engine/useEngineInstance.ts":{"bytes":12256,"imports":[{"path":"utils/core/dependency/useSetRule.ts","kind":"import-statement","original":"../dependency/useSetRule"},{"path":"utils/core/dependency/useStrategy.ts","kind":"import-statement","original":"../dependency/useStrategy"},{"path":"utils/core/plugins/useExecutionTrace.ts","kind":"import-statement","original":"../plugins/useExecutionTrace"},{"path":"utils/core/dependency/useDepenency.ts","kind":"import-statement","original":"../dependency/useDepenency"},{"path":"utils/core/hooks/useOnError.ts","kind":"import-statement","original":"../hooks/useOnError"},{"path":"utils/core/hooks/useOnSuccess.ts","kind":"import-statement","original":"../hooks/useOnSuccess"},{"path":"utils/core/plugins/usePlugin.ts","kind":"import-statement","original":"../plugins/usePlugin"},{"path":"utils/core/hooks/useOnStart.ts","kind":"import-statement","original":"../hooks/useOnStart"},{"path":"../types/types","kind":"import-statement","external":true},{"path":"utils/core/engine/useScheduler.ts","kind":"import-statement","original":"./useScheduler"},{"path":"../utils/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useEngineManager.ts":{"bytes":11202,"imports":[{"path":"../types/types","kind":"import-statement","external":true},{"path":"../utils/util","kind":"import-statement","external":true},{"path":"utils/core/engine/useEngineInstance.ts","kind":"import-statement","original":"./useEngineInstance"},{"path":"utils/core/types/types.ts","kind":"import-statement","original":"../types/types"},{"path":"utils/core/engine/bucket.ts","kind":"import-statement","original":"../engine/bucket"},{"path":"utils/core/engine/useScheduler.ts","kind":"import-statement","original":"../engine/useScheduler"}],"format":"esm"}},"outputs":{"lib-dist/index.mjs":{"imports":[],"exports":["DefaultStrategy","TriggerCause","deleteEngine","useEngine","useEngineManager","useMeshFlow","useMeshFlowDefiner","useScheduler"],"entryPoint":"utils/core/engine/useEngineManager.ts","inputs":{"utils/core/engine/bucket.ts":{"bytesInOutput":5020},"utils/core/dependency/useSetRule.ts":{"bytesInOutput":1754},"utils/core/dependency/useStrategy.ts":{"bytesInOutput":115},"utils/core/plugins/useExecutionTrace.ts":{"bytesInOutput":760},"utils/core/dependency/useDepenency.ts":{"bytesInOutput":1244},"utils/core/hooks/useCreateHook.ts":{"bytesInOutput":122},"utils/core/hooks/useOnError.ts":{"bytesInOutput":68},"utils/core/hooks/useOnSuccess.ts":{"bytesInOutput":72},"utils/core/plugins/usePlugin.ts":{"bytesInOutput":424},"utils/core/hooks/useOnStart.ts":{"bytesInOutput":68},"utils/core/utils/util.ts":{"bytesInOutput":472},"utils/core/types/types.ts":{"bytesInOutput":117},"utils/core/engine/useMeshTask.ts":{"bytesInOutput":7679},"utils/core/engine/useMeshNode.ts":{"bytesInOutput":932},"utils/core/dependency/useSetEntangle.ts":{"bytesInOutput":3145},"utils/core/engine/useScheduler.ts":{"bytesInOutput":2496},"utils/core/engine/useEngineInstance.ts":{"bytesInOutput":2428},"utils/core/engine/useEngineManager.ts":{"bytesInOutput":1881}},"bytes":28967}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshflow/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "A logic orchestration engine utilizing topological scheduling and watermark control to resolve asynchronous race conditions in complex dependency linkages.”",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"module": "./index.js",
|