@meshflow/core 0.2.7 → 0.2.8

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 CHANGED
@@ -21,8 +21,10 @@ declare class SchemaBucket<P> {
21
21
  private deps;
22
22
  private _forceNotify;
23
23
  promiseToken: any;
24
+ useCache: boolean;
24
25
  private effectArray;
25
26
  constructor(baseValue: any, key: string | number | symbol, path: P);
27
+ setUseCache(val: boolean): void;
26
28
  forceNotify(): void;
27
29
  isForceNotify(): boolean;
28
30
  setStrategy(type: DefaultStrategy): void;
@@ -44,6 +46,11 @@ declare class SchemaBucket<P> {
44
46
  }
45
47
 
46
48
  type Unwrap<T> = T extends ReadonlyArray<infer U> ? U : T;
49
+ type InferLeafType<T> = Unwrap<T> extends infer Node ? Node extends {
50
+ readonly name: any;
51
+ } ? Node extends {
52
+ readonly children: infer C;
53
+ } ? InferLeafType<C> : Node : never : never;
47
54
  type InferLeafPath<T, Prefix extends string = ""> = Unwrap<T> extends infer Node ? Node extends {
48
55
  readonly name: infer N;
49
56
  } ? N extends string ? N extends "" ? Node extends {
@@ -55,59 +62,61 @@ type InferLeafPath<T, Prefix extends string = ""> = Unwrap<T> extends infer Node
55
62
  } ? InferLeafPath<C, Prefix> : N : never : never : never;
56
63
  type KeysOfUnion<T> = T extends any ? keyof T : never;
57
64
 
58
- interface MeshEvents {
59
- 'node:start': {
65
+ interface BaseMeshEvents {
66
+ "flow:start": {
60
67
  path: MeshPath;
61
68
  };
62
- 'node:success': {
69
+ "node:start": {
63
70
  path: MeshPath;
64
71
  };
65
- 'node:bucket:success': {
72
+ "node:success": {
66
73
  path: MeshPath;
67
- key: string;
68
- value: any;
69
74
  };
70
- 'node:error': {
75
+ "node:error": {
71
76
  path: MeshPath;
72
77
  error: any;
73
78
  };
74
- 'node:intercept': {
79
+ "node:intercept": {
75
80
  path: MeshPath;
76
81
  type: number;
77
82
  detail?: any;
78
83
  };
79
- 'node:release': {
84
+ "node:release": {
80
85
  path: MeshPath;
81
86
  type: number;
82
87
  detail?: any;
83
88
  };
84
- 'node:stagnate': {
89
+ "node:stagnate": {
85
90
  path: MeshPath;
86
91
  type: number;
87
92
  };
88
- 'node:processing': {
93
+ "node:processing": {
94
+ path: MeshPath;
95
+ };
96
+ "node:pending": {
89
97
  path: MeshPath;
90
98
  };
91
- 'flow:wait': {
99
+ "flow:wait": {
92
100
  type: number;
93
101
  detail?: any;
94
102
  };
95
- 'flow:fire': {
103
+ "flow:fire": {
96
104
  path: MeshPath;
97
105
  type: number;
98
106
  detail?: any;
99
107
  };
100
- 'flow:start': {
101
- path: MeshPath;
102
- };
103
- 'flow:success': {
108
+ }
109
+ interface MeshEvents extends BaseMeshEvents {
110
+ "flow:success": {
104
111
  duration: string;
105
112
  };
106
- 'flow:end': {
113
+ "flow:end": {
107
114
  type: number;
108
115
  };
109
- 'node:pending': {
116
+ "node:bucket:success": {
110
117
  path: MeshPath;
118
+ key: string;
119
+ value: any;
111
120
  };
112
121
  }
113
122
  type MeshEventName = keyof MeshEvents;
@@ -122,16 +131,13 @@ type MeshFlowHistory = {
122
131
  initCanUndo: any;
123
132
  initCanRedo: any;
124
133
  PushIntoHistory: (action: HistoryActionItem, cleanRedo?: boolean) => void;
125
- CreateHistoryAction: (metadata: [
126
- {
127
- path: string;
128
- value: any;
129
- },
130
- {
131
- path: string;
132
- value: any;
133
- }
134
- ], cb: any) => {
134
+ CreateHistoryAction: (metadata: [{
135
+ path: string;
136
+ value: any;
137
+ }, {
138
+ path: string;
139
+ value: any;
140
+ }], cb: any) => {
135
141
  undoAction: () => any;
136
142
  redoAction: () => any;
137
143
  };
@@ -139,44 +145,42 @@ type MeshFlowHistory = {
139
145
  interface MeshFlowEngineMap {
140
146
  }
141
147
  type MeshPath = string | number | symbol;
142
- interface MeshBucket<P> {
143
- evaluate: (context: any) => Promise<any> | any;
144
- [key: string]: any;
145
- }
146
- interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, S = any> {
148
+ interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, NM = any> {
147
149
  path: P;
148
150
  uid: number;
149
151
  type: string;
150
152
  state: V;
151
- nodeBucket: Record<keyof S, MeshBucket<P>>;
152
- notifyKeys: Set<keyof S>;
153
+ nodeBucket: Record<keyof NM, SchemaBucket<P>>;
154
+ notifyKeys: Set<keyof NM>;
153
155
  dirtySignal: any;
154
156
  proxy: any;
155
- meta: S;
156
- dependOn: (cb: (val: V) => V) => void;
157
+ meta: NM;
158
+ dependOn: (cb: (val: V) => V, key?: keyof NM) => void;
157
159
  createView: (extraProps?: Record<string, any>) => any;
158
160
  }
159
161
  interface MeshFlowGroupNode<P extends MeshPath = MeshPath> {
160
162
  path: P;
161
163
  uid: number;
162
- type: 'group';
164
+ type: "group";
163
165
  children: Array<P>;
164
166
  dirtySignal: any;
165
167
  meta: Record<string, any>;
166
168
  }
167
- interface logicApi {
169
+ interface logicApi<NM, TKeys extends KeysOfUnion<NM>> {
168
170
  slot: {
169
- triggerTargets: any;
171
+ triggerTargets: Array<Record<TKeys, any>>;
170
172
  affectedTatget: any;
171
173
  };
172
174
  }
173
- interface SetRuleOptions<NM> {
175
+ interface SetRuleOptions<NM, TKeys extends KeysOfUnion<NM>> {
174
176
  value?: any;
175
177
  priority?: number;
176
178
  forceNotify?: boolean;
177
- logic: (api: logicApi) => any;
179
+ logic: (api: logicApi<NM, TKeys>) => any;
178
180
  effect?: (args: any) => any;
179
181
  effectArgs?: Array<KeysOfUnion<NM>>;
182
+ cacheStrategy?: "none" | "shallow";
183
+ triggerKeys?: TKeys[];
180
184
  }
181
185
 
182
186
  /**
@@ -205,8 +209,8 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
205
209
  };
206
210
  plugins: {};
207
211
  }): {
208
- SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
209
- SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
212
+ SetRule: <TKeys extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: KeysOfUnion<NM> | (string & {}), options: SetRuleOptions<NM, TKeys>) => void;
213
+ SetRules: <TKeys extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<NM> | (string & {}), options: SetRuleOptions<NM, TKeys>) => void;
210
214
  SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
211
215
  SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
212
216
  cancel: () => void;
@@ -216,8 +220,13 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
216
220
  on: (event: MeshEventName, cb: Function) => () => boolean;
217
221
  }) => void;
218
222
  }) => () => void;
219
- SetValue: (path: P, value: any) => void;
223
+ SetValue: (path: P, key: KeysOfUnion<NM> | (string & {}), value: any) => void;
220
224
  GetValue: (path: P, key?: string) => any;
225
+ SetValues: (updates: {
226
+ path: P;
227
+ key: KeysOfUnion<NM> | (string & {});
228
+ value: any;
229
+ }[]) => void;
221
230
  GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
222
231
  notifyAll: () => Promise<void>;
223
232
  GetAllDependency: () => Map<P, Set<P>>;
@@ -235,11 +244,29 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
235
244
  onStart: (cb: (data: {
236
245
  path: P;
237
246
  }) => void) => () => void;
247
+ scheduler: {
248
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
249
+ registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
250
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
251
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
252
+ notify: (path: P) => void;
253
+ notifyAll: () => Promise<void>;
254
+ batchNotify: (updates: {
255
+ path: P;
256
+ key: (string & {}) | KeysOfUnion<NM>;
257
+ value: any;
258
+ }[]) => void;
259
+ UITrigger: {
260
+ signalCreator: () => T;
261
+ signalTrigger: (signal: T) => void;
262
+ };
263
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
264
+ };
238
265
  };
239
266
 
240
267
  declare function useScheduler<T, //ui trigger中定义的类型
241
268
  P extends MeshPath, // 路径类型
242
- S = any>(schema: S, config: {
269
+ NM = any>(config: {
243
270
  useGreedy: boolean;
244
271
  }, dependency: {
245
272
  GetDependencyOrder: () => P[][];
@@ -260,17 +287,22 @@ S = any>(schema: S, config: {
260
287
  signalCreator: () => T;
261
288
  signalTrigger: (signal: T) => void;
262
289
  }): {
263
- registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, any>;
290
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
264
291
  registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
265
- GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, S>;
292
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
266
293
  GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
267
294
  notify: (path: P) => void;
268
295
  notifyAll: () => Promise<void>;
296
+ batchNotify: (updates: {
297
+ path: P;
298
+ key: KeysOfUnion<NM> | (string & {});
299
+ value: any;
300
+ }[]) => void;
269
301
  UITrigger: {
270
302
  signalCreator: () => T;
271
303
  signalTrigger: (signal: T) => void;
272
304
  };
273
- UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, S>>;
305
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
274
306
  };
275
307
 
276
308
  type SchedulerType<T, P extends MeshPath, S, NM> = ReturnType<typeof useEngineInstance<T, P, S, NM>>;
@@ -282,6 +314,9 @@ type BaseEngine<T> = {
282
314
  GetValue: T extends {
283
315
  GetValue: infer F;
284
316
  } ? F : never;
317
+ SetValues: T extends {
318
+ SetValues: infer F;
319
+ } ? F : never;
285
320
  GetGroupByPath: T extends {
286
321
  GetGroupByPath: infer F;
287
322
  } ? F : never;
@@ -338,8 +373,8 @@ type EngineModules<M, P extends MeshPath> = {
338
373
  };
339
374
  type Engine<T, M, P extends MeshPath> = BaseEngine<T> & EngineModules<M, P>;
340
375
  /** @deprecated 请使用新的 useMeshFlow 别名 */
341
- declare const useEngineManager: <const S extends Record<string, any>, T, //UITrigger的类型
342
- M extends Record<string, any>, NM extends Record<string, any> = Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
376
+ declare const useEngineManager: <const S extends Record<string, any> | any[], T, //UITrigger的类型
377
+ M extends Record<string, any>, NM extends Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
343
378
  metaType?: NM;
344
379
  config?: {
345
380
  useGreedy: boolean;
@@ -350,8 +385,8 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
350
385
  signalTrigger: (signal: T) => void;
351
386
  };
352
387
  }) => Engine<{
353
- SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
354
- SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
388
+ SetRule: <TKeys extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: (string & {}) | KeysOfUnion<NM>, options: SetRuleOptions<NM, TKeys>) => void;
389
+ SetRules: <TKeys extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: (string & {}) | KeysOfUnion<NM>, options: SetRuleOptions<NM, TKeys>) => void;
355
390
  SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
356
391
  SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
357
392
  cancel: () => void;
@@ -361,8 +396,13 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
361
396
  on: (event: MeshEventName, cb: Function) => () => boolean;
362
397
  }) => void;
363
398
  }) => () => void;
364
- SetValue: (path: P, value: any) => void;
399
+ SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
365
400
  GetValue: (path: P, key?: string) => any;
401
+ SetValues: (updates: {
402
+ path: P;
403
+ key: (string & {}) | KeysOfUnion<NM>;
404
+ value: any;
405
+ }[]) => void;
366
406
  GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
367
407
  notifyAll: () => Promise<void>;
368
408
  GetAllDependency: () => Map<P, Set<P>>;
@@ -380,6 +420,24 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
380
420
  onStart: (cb: (data: {
381
421
  path: P;
382
422
  }) => void) => () => void;
423
+ scheduler: {
424
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
425
+ registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
426
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
427
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
428
+ notify: (path: P) => void;
429
+ notifyAll: () => Promise<void>;
430
+ batchNotify: (updates: {
431
+ path: P;
432
+ key: (string & {}) | KeysOfUnion<NM>;
433
+ value: any;
434
+ }[]) => void;
435
+ UITrigger: {
436
+ signalCreator: () => T;
437
+ signalTrigger: (signal: T) => void;
438
+ };
439
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
440
+ };
383
441
  }, M, P>;
384
442
  declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string, any> = any>() => <T, M extends Record<string, any>>(id: MeshPath, schema: any, options: {
385
443
  metaType?: NM;
@@ -397,7 +455,7 @@ declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string,
397
455
  */
398
456
  declare const useEngine: <M, P extends MeshPath = any, NM = any, S = any, ID extends keyof MeshFlowEngineMap | (MeshPath & {}) = MeshPath>(id: ID) => [M] extends [never] ? (ID extends keyof MeshFlowEngineMap ? MeshFlowEngineMap[ID] : Engine<SchedulerType<any, any, any, any>, {}, P>) : Engine<SchedulerType<any, P, S, NM>, M, P>;
399
457
  declare const deleteEngine: (id: MeshPath) => void;
400
- declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Record<string, any>, NM extends Record<string, any> = Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
458
+ declare const useMeshFlow: <const S extends Record<string, any> | any[], T, M extends Record<string, any>, NM extends Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : (string & {}) | InferLeafPath<S>>(id: MeshPath, Schema: S, options: {
401
459
  metaType?: NM;
402
460
  config?: {
403
461
  useGreedy: boolean;
@@ -408,8 +466,8 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
408
466
  signalTrigger: (signal: T) => void;
409
467
  };
410
468
  }) => Engine<{
411
- SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
412
- SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
469
+ SetRule: <TKeys extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: (string & {}) | KeysOfUnion<NM>, options: SetRuleOptions<NM, TKeys>) => void;
470
+ SetRules: <TKeys extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: (string & {}) | KeysOfUnion<NM>, options: SetRuleOptions<NM, TKeys>) => void;
413
471
  SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
414
472
  SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
415
473
  cancel: () => void;
@@ -419,8 +477,13 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
419
477
  on: (event: MeshEventName, cb: Function) => () => boolean;
420
478
  }) => void;
421
479
  }) => () => void;
422
- SetValue: (path: P, value: any) => void;
480
+ SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
423
481
  GetValue: (path: P, key?: string) => any;
482
+ SetValues: (updates: {
483
+ path: P;
484
+ key: (string & {}) | KeysOfUnion<NM>;
485
+ value: any;
486
+ }[]) => void;
424
487
  GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
425
488
  notifyAll: () => Promise<void>;
426
489
  GetAllDependency: () => Map<P, Set<P>>;
@@ -438,6 +501,24 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
438
501
  onStart: (cb: (data: {
439
502
  path: P;
440
503
  }) => void) => () => void;
504
+ scheduler: {
505
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
506
+ registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
507
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
508
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
509
+ notify: (path: P) => void;
510
+ notifyAll: () => Promise<void>;
511
+ batchNotify: (updates: {
512
+ path: P;
513
+ key: (string & {}) | KeysOfUnion<NM>;
514
+ value: any;
515
+ }[]) => void;
516
+ UITrigger: {
517
+ signalCreator: () => T;
518
+ signalTrigger: (signal: T) => void;
519
+ };
520
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
521
+ };
441
522
  }, M, P>;
442
523
 
443
- export { type BaseEngine, DefaultStrategy, type Engine, type EngineModules, type InferLeafPath, type MapModuleToReturn, type MeshErrorContext, type MeshEvents, type MeshFlowEngineMap, type MeshFlowGroupNode, type MeshPath, type SchedulerType, SchemaBucket, type SetRuleOptions, type TransformModuleKey, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };
524
+ export { type BaseEngine, DefaultStrategy, type Engine, type EngineModules, type InferLeafPath, type InferLeafType, type MapModuleToReturn, type MeshErrorContext, type MeshEvents, type MeshFlowEngineMap, type MeshFlowGroupNode, type MeshPath, type SchedulerType, SchemaBucket, type SetRuleOptions, type TransformModuleKey, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };
package/index.d.ts CHANGED
@@ -21,8 +21,10 @@ declare class SchemaBucket<P> {
21
21
  private deps;
22
22
  private _forceNotify;
23
23
  promiseToken: any;
24
+ useCache: boolean;
24
25
  private effectArray;
25
26
  constructor(baseValue: any, key: string | number | symbol, path: P);
27
+ setUseCache(val: boolean): void;
26
28
  forceNotify(): void;
27
29
  isForceNotify(): boolean;
28
30
  setStrategy(type: DefaultStrategy): void;
@@ -44,6 +46,11 @@ declare class SchemaBucket<P> {
44
46
  }
45
47
 
46
48
  type Unwrap<T> = T extends ReadonlyArray<infer U> ? U : T;
49
+ type InferLeafType<T> = Unwrap<T> extends infer Node ? Node extends {
50
+ readonly name: any;
51
+ } ? Node extends {
52
+ readonly children: infer C;
53
+ } ? InferLeafType<C> : Node : never : never;
47
54
  type InferLeafPath<T, Prefix extends string = ""> = Unwrap<T> extends infer Node ? Node extends {
48
55
  readonly name: infer N;
49
56
  } ? N extends string ? N extends "" ? Node extends {
@@ -55,59 +62,61 @@ type InferLeafPath<T, Prefix extends string = ""> = Unwrap<T> extends infer Node
55
62
  } ? InferLeafPath<C, Prefix> : N : never : never : never;
56
63
  type KeysOfUnion<T> = T extends any ? keyof T : never;
57
64
 
58
- interface MeshEvents {
59
- 'node:start': {
65
+ interface BaseMeshEvents {
66
+ "flow:start": {
60
67
  path: MeshPath;
61
68
  };
62
- 'node:success': {
69
+ "node:start": {
63
70
  path: MeshPath;
64
71
  };
65
- 'node:bucket:success': {
72
+ "node:success": {
66
73
  path: MeshPath;
67
- key: string;
68
- value: any;
69
74
  };
70
- 'node:error': {
75
+ "node:error": {
71
76
  path: MeshPath;
72
77
  error: any;
73
78
  };
74
- 'node:intercept': {
79
+ "node:intercept": {
75
80
  path: MeshPath;
76
81
  type: number;
77
82
  detail?: any;
78
83
  };
79
- 'node:release': {
84
+ "node:release": {
80
85
  path: MeshPath;
81
86
  type: number;
82
87
  detail?: any;
83
88
  };
84
- 'node:stagnate': {
89
+ "node:stagnate": {
85
90
  path: MeshPath;
86
91
  type: number;
87
92
  };
88
- 'node:processing': {
93
+ "node:processing": {
94
+ path: MeshPath;
95
+ };
96
+ "node:pending": {
89
97
  path: MeshPath;
90
98
  };
91
- 'flow:wait': {
99
+ "flow:wait": {
92
100
  type: number;
93
101
  detail?: any;
94
102
  };
95
- 'flow:fire': {
103
+ "flow:fire": {
96
104
  path: MeshPath;
97
105
  type: number;
98
106
  detail?: any;
99
107
  };
100
- 'flow:start': {
101
- path: MeshPath;
102
- };
103
- 'flow:success': {
108
+ }
109
+ interface MeshEvents extends BaseMeshEvents {
110
+ "flow:success": {
104
111
  duration: string;
105
112
  };
106
- 'flow:end': {
113
+ "flow:end": {
107
114
  type: number;
108
115
  };
109
- 'node:pending': {
116
+ "node:bucket:success": {
110
117
  path: MeshPath;
118
+ key: string;
119
+ value: any;
111
120
  };
112
121
  }
113
122
  type MeshEventName = keyof MeshEvents;
@@ -122,16 +131,13 @@ type MeshFlowHistory = {
122
131
  initCanUndo: any;
123
132
  initCanRedo: any;
124
133
  PushIntoHistory: (action: HistoryActionItem, cleanRedo?: boolean) => void;
125
- CreateHistoryAction: (metadata: [
126
- {
127
- path: string;
128
- value: any;
129
- },
130
- {
131
- path: string;
132
- value: any;
133
- }
134
- ], cb: any) => {
134
+ CreateHistoryAction: (metadata: [{
135
+ path: string;
136
+ value: any;
137
+ }, {
138
+ path: string;
139
+ value: any;
140
+ }], cb: any) => {
135
141
  undoAction: () => any;
136
142
  redoAction: () => any;
137
143
  };
@@ -139,44 +145,42 @@ type MeshFlowHistory = {
139
145
  interface MeshFlowEngineMap {
140
146
  }
141
147
  type MeshPath = string | number | symbol;
142
- interface MeshBucket<P> {
143
- evaluate: (context: any) => Promise<any> | any;
144
- [key: string]: any;
145
- }
146
- interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, S = any> {
148
+ interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, NM = any> {
147
149
  path: P;
148
150
  uid: number;
149
151
  type: string;
150
152
  state: V;
151
- nodeBucket: Record<keyof S, MeshBucket<P>>;
152
- notifyKeys: Set<keyof S>;
153
+ nodeBucket: Record<keyof NM, SchemaBucket<P>>;
154
+ notifyKeys: Set<keyof NM>;
153
155
  dirtySignal: any;
154
156
  proxy: any;
155
- meta: S;
156
- dependOn: (cb: (val: V) => V) => void;
157
+ meta: NM;
158
+ dependOn: (cb: (val: V) => V, key?: keyof NM) => void;
157
159
  createView: (extraProps?: Record<string, any>) => any;
158
160
  }
159
161
  interface MeshFlowGroupNode<P extends MeshPath = MeshPath> {
160
162
  path: P;
161
163
  uid: number;
162
- type: 'group';
164
+ type: "group";
163
165
  children: Array<P>;
164
166
  dirtySignal: any;
165
167
  meta: Record<string, any>;
166
168
  }
167
- interface logicApi {
169
+ interface logicApi<NM, TKeys extends KeysOfUnion<NM>> {
168
170
  slot: {
169
- triggerTargets: any;
171
+ triggerTargets: Array<Record<TKeys, any>>;
170
172
  affectedTatget: any;
171
173
  };
172
174
  }
173
- interface SetRuleOptions<NM> {
175
+ interface SetRuleOptions<NM, TKeys extends KeysOfUnion<NM>> {
174
176
  value?: any;
175
177
  priority?: number;
176
178
  forceNotify?: boolean;
177
- logic: (api: logicApi) => any;
179
+ logic: (api: logicApi<NM, TKeys>) => any;
178
180
  effect?: (args: any) => any;
179
181
  effectArgs?: Array<KeysOfUnion<NM>>;
182
+ cacheStrategy?: "none" | "shallow";
183
+ triggerKeys?: TKeys[];
180
184
  }
181
185
 
182
186
  /**
@@ -205,8 +209,8 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
205
209
  };
206
210
  plugins: {};
207
211
  }): {
208
- SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
209
- SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
212
+ SetRule: <TKeys extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: KeysOfUnion<NM> | (string & {}), options: SetRuleOptions<NM, TKeys>) => void;
213
+ SetRules: <TKeys extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<NM> | (string & {}), options: SetRuleOptions<NM, TKeys>) => void;
210
214
  SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
211
215
  SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
212
216
  cancel: () => void;
@@ -216,8 +220,13 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
216
220
  on: (event: MeshEventName, cb: Function) => () => boolean;
217
221
  }) => void;
218
222
  }) => () => void;
219
- SetValue: (path: P, value: any) => void;
223
+ SetValue: (path: P, key: KeysOfUnion<NM> | (string & {}), value: any) => void;
220
224
  GetValue: (path: P, key?: string) => any;
225
+ SetValues: (updates: {
226
+ path: P;
227
+ key: KeysOfUnion<NM> | (string & {});
228
+ value: any;
229
+ }[]) => void;
221
230
  GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
222
231
  notifyAll: () => Promise<void>;
223
232
  GetAllDependency: () => Map<P, Set<P>>;
@@ -235,11 +244,29 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
235
244
  onStart: (cb: (data: {
236
245
  path: P;
237
246
  }) => void) => () => void;
247
+ scheduler: {
248
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
249
+ registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
250
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
251
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
252
+ notify: (path: P) => void;
253
+ notifyAll: () => Promise<void>;
254
+ batchNotify: (updates: {
255
+ path: P;
256
+ key: (string & {}) | KeysOfUnion<NM>;
257
+ value: any;
258
+ }[]) => void;
259
+ UITrigger: {
260
+ signalCreator: () => T;
261
+ signalTrigger: (signal: T) => void;
262
+ };
263
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
264
+ };
238
265
  };
239
266
 
240
267
  declare function useScheduler<T, //ui trigger中定义的类型
241
268
  P extends MeshPath, // 路径类型
242
- S = any>(schema: S, config: {
269
+ NM = any>(config: {
243
270
  useGreedy: boolean;
244
271
  }, dependency: {
245
272
  GetDependencyOrder: () => P[][];
@@ -260,17 +287,22 @@ S = any>(schema: S, config: {
260
287
  signalCreator: () => T;
261
288
  signalTrigger: (signal: T) => void;
262
289
  }): {
263
- registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, any>;
290
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
264
291
  registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
265
- GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, S>;
292
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
266
293
  GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
267
294
  notify: (path: P) => void;
268
295
  notifyAll: () => Promise<void>;
296
+ batchNotify: (updates: {
297
+ path: P;
298
+ key: KeysOfUnion<NM> | (string & {});
299
+ value: any;
300
+ }[]) => void;
269
301
  UITrigger: {
270
302
  signalCreator: () => T;
271
303
  signalTrigger: (signal: T) => void;
272
304
  };
273
- UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, S>>;
305
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
274
306
  };
275
307
 
276
308
  type SchedulerType<T, P extends MeshPath, S, NM> = ReturnType<typeof useEngineInstance<T, P, S, NM>>;
@@ -282,6 +314,9 @@ type BaseEngine<T> = {
282
314
  GetValue: T extends {
283
315
  GetValue: infer F;
284
316
  } ? F : never;
317
+ SetValues: T extends {
318
+ SetValues: infer F;
319
+ } ? F : never;
285
320
  GetGroupByPath: T extends {
286
321
  GetGroupByPath: infer F;
287
322
  } ? F : never;
@@ -338,8 +373,8 @@ type EngineModules<M, P extends MeshPath> = {
338
373
  };
339
374
  type Engine<T, M, P extends MeshPath> = BaseEngine<T> & EngineModules<M, P>;
340
375
  /** @deprecated 请使用新的 useMeshFlow 别名 */
341
- declare const useEngineManager: <const S extends Record<string, any>, T, //UITrigger的类型
342
- M extends Record<string, any>, NM extends Record<string, any> = Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
376
+ declare const useEngineManager: <const S extends Record<string, any> | any[], T, //UITrigger的类型
377
+ M extends Record<string, any>, NM extends Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
343
378
  metaType?: NM;
344
379
  config?: {
345
380
  useGreedy: boolean;
@@ -350,8 +385,8 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
350
385
  signalTrigger: (signal: T) => void;
351
386
  };
352
387
  }) => Engine<{
353
- SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
354
- SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
388
+ SetRule: <TKeys extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: (string & {}) | KeysOfUnion<NM>, options: SetRuleOptions<NM, TKeys>) => void;
389
+ SetRules: <TKeys extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: (string & {}) | KeysOfUnion<NM>, options: SetRuleOptions<NM, TKeys>) => void;
355
390
  SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
356
391
  SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
357
392
  cancel: () => void;
@@ -361,8 +396,13 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
361
396
  on: (event: MeshEventName, cb: Function) => () => boolean;
362
397
  }) => void;
363
398
  }) => () => void;
364
- SetValue: (path: P, value: any) => void;
399
+ SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
365
400
  GetValue: (path: P, key?: string) => any;
401
+ SetValues: (updates: {
402
+ path: P;
403
+ key: (string & {}) | KeysOfUnion<NM>;
404
+ value: any;
405
+ }[]) => void;
366
406
  GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
367
407
  notifyAll: () => Promise<void>;
368
408
  GetAllDependency: () => Map<P, Set<P>>;
@@ -380,6 +420,24 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
380
420
  onStart: (cb: (data: {
381
421
  path: P;
382
422
  }) => void) => () => void;
423
+ scheduler: {
424
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
425
+ registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
426
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
427
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
428
+ notify: (path: P) => void;
429
+ notifyAll: () => Promise<void>;
430
+ batchNotify: (updates: {
431
+ path: P;
432
+ key: (string & {}) | KeysOfUnion<NM>;
433
+ value: any;
434
+ }[]) => void;
435
+ UITrigger: {
436
+ signalCreator: () => T;
437
+ signalTrigger: (signal: T) => void;
438
+ };
439
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
440
+ };
383
441
  }, M, P>;
384
442
  declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string, any> = any>() => <T, M extends Record<string, any>>(id: MeshPath, schema: any, options: {
385
443
  metaType?: NM;
@@ -397,7 +455,7 @@ declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string,
397
455
  */
398
456
  declare const useEngine: <M, P extends MeshPath = any, NM = any, S = any, ID extends keyof MeshFlowEngineMap | (MeshPath & {}) = MeshPath>(id: ID) => [M] extends [never] ? (ID extends keyof MeshFlowEngineMap ? MeshFlowEngineMap[ID] : Engine<SchedulerType<any, any, any, any>, {}, P>) : Engine<SchedulerType<any, P, S, NM>, M, P>;
399
457
  declare const deleteEngine: (id: MeshPath) => void;
400
- declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Record<string, any>, NM extends Record<string, any> = Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
458
+ declare const useMeshFlow: <const S extends Record<string, any> | any[], T, M extends Record<string, any>, NM extends Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : (string & {}) | InferLeafPath<S>>(id: MeshPath, Schema: S, options: {
401
459
  metaType?: NM;
402
460
  config?: {
403
461
  useGreedy: boolean;
@@ -408,8 +466,8 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
408
466
  signalTrigger: (signal: T) => void;
409
467
  };
410
468
  }) => Engine<{
411
- SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
412
- SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
469
+ SetRule: <TKeys extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: (string & {}) | KeysOfUnion<NM>, options: SetRuleOptions<NM, TKeys>) => void;
470
+ SetRules: <TKeys extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: (string & {}) | KeysOfUnion<NM>, options: SetRuleOptions<NM, TKeys>) => void;
413
471
  SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
414
472
  SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
415
473
  cancel: () => void;
@@ -419,8 +477,13 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
419
477
  on: (event: MeshEventName, cb: Function) => () => boolean;
420
478
  }) => void;
421
479
  }) => () => void;
422
- SetValue: (path: P, value: any) => void;
480
+ SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
423
481
  GetValue: (path: P, key?: string) => any;
482
+ SetValues: (updates: {
483
+ path: P;
484
+ key: (string & {}) | KeysOfUnion<NM>;
485
+ value: any;
486
+ }[]) => void;
424
487
  GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
425
488
  notifyAll: () => Promise<void>;
426
489
  GetAllDependency: () => Map<P, Set<P>>;
@@ -438,6 +501,24 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
438
501
  onStart: (cb: (data: {
439
502
  path: P;
440
503
  }) => void) => () => void;
504
+ scheduler: {
505
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P, any, any>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
506
+ registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
507
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
508
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
509
+ notify: (path: P) => void;
510
+ notifyAll: () => Promise<void>;
511
+ batchNotify: (updates: {
512
+ path: P;
513
+ key: (string & {}) | KeysOfUnion<NM>;
514
+ value: any;
515
+ }[]) => void;
516
+ UITrigger: {
517
+ signalCreator: () => T;
518
+ signalTrigger: (signal: T) => void;
519
+ };
520
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
521
+ };
441
522
  }, M, P>;
442
523
 
443
- export { type BaseEngine, DefaultStrategy, type Engine, type EngineModules, type InferLeafPath, type MapModuleToReturn, type MeshErrorContext, type MeshEvents, type MeshFlowEngineMap, type MeshFlowGroupNode, type MeshPath, type SchedulerType, SchemaBucket, type SetRuleOptions, type TransformModuleKey, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };
524
+ export { type BaseEngine, DefaultStrategy, type Engine, type EngineModules, type InferLeafPath, type InferLeafType, type MapModuleToReturn, type MeshErrorContext, type MeshEvents, type MeshFlowEngineMap, type MeshFlowGroupNode, type MeshPath, type SchedulerType, SchemaBucket, type SetRuleOptions, type TransformModuleKey, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };
package/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var Z=class{computedRules=[];store={OR:(e,n)=>{let t,l,r=this.computedRules;for(let c=0;c<r.length;c++){let o=r[c],s=o.logic(e);if(s instanceof Promise)return (async()=>{let i=await s;if(o.entityId==="__base__"?l=i:i&&(t=i),typeof t>"u")for(let u=c+1;u<r.length;u++){let f=r[u],p=f.logic(e),P=p instanceof Promise?await p:p;if(f.entityId==="__base__"){l=P;continue}if(P){t=f.value;break}}return typeof t>"u"&&(t=l),{res:t,version:n}})();let d=s;if(o.entityId==="__base__"){l=d;continue}if(d){t=o.value;break}}return typeof t>"u"&&(t=l),{res:t,version:n}},PRIORITY:(e,n)=>{let t,l=this.computedRules;for(let r=0;r<l.length;r++){let o=l[r].logic(e);if(o instanceof Promise)return (async()=>{let s=await o;if(s!==void 0)return {res:s,version:n};for(let d=r+1;d<l.length;d++){let i=l[d].logic(e),u=i instanceof Promise?await i:i;if(u!==void 0)return {res:u,version:n}}return {res:void 0,version:n}})();if(o!==void 0)return {res:o,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)}},X=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;effectArray=[];constructor(e,n,t){let l=()=>this.rules;this.strategy=new Z(l),this.path=t,this.isValue=n==="value",this.contract=this.inferType(e),this.cache=e,this.setRule({priority:0,entityId:"__base__",logic:()=>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,l={...e,entityId:t};for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(l);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let c=this.rules.get(r);c&&(c.delete(l),c.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,l={...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(l);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let c=this.rules.get(r);c&&(c.delete(l),c.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 c=this.deps.get(e.triggerPath),o=e.GetValueByPath(e.triggerPath);if(typeof c=="object"||typeof o=="object")t=false;else {let s=Array.from(this.deps.keys());for(let d of s){let i=this.deps.get(d),u=e.GetValueByPath(d);if(i!==u){t=false;break}}}}if(t)return this.cache;this.promiseToken=n;let l=++this.version,r=this.strategy.evaluate(e,l);if(!(r instanceof Promise)){let{res:c,version:o}=r;return this.finalizeSync(c,o,e,n)}return this.pendingPromise=(async()=>{try{let{res:c,version:o}=await r;return this.finalizeSync(c,o,e,n)}catch(c){throw {path:this.path,error:c}}finally{this.promiseToken===n&&(this.pendingPromise=null,this.promiseToken=null);}})(),this.pendingPromise}finalizeSync(e,n,t,l){return l!==this.promiseToken||n<this.version?this.cache:(this.cache=e,this.deps.forEach((r,c)=>{this.deps.set(c,t.GetValueByPath(c));}),e)}inferType(e){return Array.isArray(e)?"array":typeof e}};var te=(a,e,n)=>{let l=r=>{let c=n.triggerPaths.map(d=>r.GetValueByPath(d).value),o=Object.create(null);return Object.defineProperty(o,"triggerTargets",{get:()=>c||[]}),Object.defineProperty(o,"affectedTatget",{get:()=>r.GetRenderSchemaByPath(a)[e]}),n.logic({slot:o})};return {value:n.value,targetPath:a,triggerPaths:n.triggerPaths,priority:n.priority??10,logic:l}},ne=(a,e,n,t)=>{if(!a)throw Error("");let l=a,r=(s,d)=>{e.has(s)||e.set(s,new Set),e.get(s).add(d),n.has(d)||n.set(d,new Set),n.get(d).add(s);};return {SetRule:(s,d,i,u={logic:()=>{}})=>{let f=l(d),p=te(d,i,{...u,triggerPaths:[s]}),P=[s].map(g=>[g,l(g).state.value]);if(r(s,d),f.nodeBucket[i])f.nodeBucket[i].setRule(p,P),u.effect&&f.nodeBucket[i].setSideEffect({fn:u.effect,args:u.effectArgs?u.effectArgs:[i]});else {let g=f.meta[i],m=new X(g,i,d);m.setRule(p,P),u.effect&&m.setSideEffect({fn:u.effect,args:u.effectArgs?u.effectArgs:[i]}),f.nodeBucket[i]=m;}f.state[i]=f.meta[i],u.forceNotify&&f.nodeBucket[i].forceNotify();},SetRules:(s,d,i,u={logic:()=>{}})=>{let f=l(d);for(let g of s)r(g,d);let p=te(d,i,{...u,triggerPaths:s}),P=s.map(g=>[g,l(g).state.value]);if(f.nodeBucket[i])f.nodeBucket[i].setRules(p,P),u.effect&&f.nodeBucket[i].setSideEffect({fn:u.effect,args:u.effectArgs?u.effectArgs:[i]});else {let g=f.meta[i],m=new X(g,i,d);m.setRules(p,P),u.effect&&m.setSideEffect({fn:u.effect,args:u.effectArgs?u.effectArgs:[i]}),f.nodeBucket[i]=m;}f.state[i]=f.meta[i],u.forceNotify&&f.nodeBucket[i].forceNotify();}}};var re=a=>{let e=a||void 0;if(!e)throw Error("");return {SetStrategy:(t,l,r)=>{e(t).nodeBucket[l].setStrategy(r);}}};function se(){let a=new Map,e=new Map,n=new Set,t=(c,o)=>{a.set(c,o);let s=e.get(c);s&&s(o);};return {SetTrace:(c,o)=>{e.set(c,o);let s=a.get(c)||"idle";return o(s),{cancel:()=>{e.delete(c);}}},useTrace:()=>({apply:o=>{o.on("flow:start",()=>{n.forEach(s=>t(s,"idle")),n.clear(),a.clear();}),o.on("node:release",({path:s,type:d})=>{(d==1||d==2)&&(n.add(s),t(s,"pending"));}),o.on("node:pending",({path:s})=>{n.add(s),(!a.has(s)||a.get(s)==="idle")&&t(s,"pending");}),o.on("node:start",({path:s})=>{n.add(s),t(s,"calculating");}),o.on("node:success",({path:s})=>{t(s,"calculated");}),o.on("node:intercept",({path:s,type:d})=>{d==3&&t(s,"calculating"),d==6&&t(s,"idle");}),o.on("node:stagnate",({path:s})=>{t(s,"pending");}),o.on("node:error",({path:s})=>t(s,"error"));}})}}function ae(a,e,n,t){let l=i=>{let u=a(),f=e(),p=new Set;return u.get(i)?.forEach(P=>p.add(P)),p.size===0?[]:Array.from(p).filter(P=>{let g=f.get(P)||new Set;return !Array.from(g).some(N=>p.has(N))})};return {GetNextDependency:i=>{let u=t();return Array.from(u.get(i)||[])},GetPrevDependency:i=>{let u=n();return Array.from(u.get(i)||[])},GetAllPrevDependency:i=>{let u=e();return Array.from(u.get(i)||[])},GetAllNextDependency:i=>{let u=a();return Array.from(u.get(i)||[])},rebuildDirectDependencyMaps:i=>{let u=new Map,f=new Map;for(let p of i){let P=l(p);u.set(p,new Set(P));for(let g of P)f.has(g)||f.set(g,new Set),f.get(g).add(p);}return {directNextMap:u,directPrevMap:f}}}}function oe(a){let e=t=>{let l=[],r=[],c=new Map,o=t.size,s=0,d=0;for(let[i,u]of t)u===0&&r.push(i);if(r.length===0&&o>0)throw Error("Circular dependency detected");for(;r.length>0;){l.push([...r]);let i=[];for(let u of r){s++,c.set(u,d);let f=a.get(u);if(f)for(let p of f){let P=t.get(p)-1;t.set(p,P),P===0&&i.push(p);}}r=i,d++;}if(s<o)throw Error("Circular dependency detected");return {steps:l,levelMap:c}};return ()=>{let t=new Map;for(let l of a.keys()){let r=Array.from(a.get(l)||[]);t.has(l)||t.set(l,0);for(let c of r){let o=t.get(c)||0;t.set(c,++o);}}return e(t)}}var q=()=>{let a=[];return {on:e=>(a.push(e),()=>{let n=a.indexOf(e);n>-1&&a.splice(n,1);}),call:e=>a.forEach(n=>{n(e);})}};function ie(){let{on:a,call:e}=q();return {onError:a,callOnError:e}}function le(){let{on:a,call:e}=q();return {onSuccess:a,callOnSuccess:e}}var ce=()=>{let a=new Set,e=new Map,n=(r,c)=>{e.get(r)?.forEach(o=>o(c));},t=(r,c)=>(e.has(r)||e.set(r,new Set),e.get(r).add(c),()=>e.get(r).delete(c));return {usePlugin:r=>{let c=new Set,o=(s,d)=>{let i=t(s,d);return c.add(i),i};return r.apply({on:o}),a.add(r),()=>{c.forEach(s=>s()),c.clear(),a.delete(r);}},emit:n}};function ue(){let{on:a,call:e}=q();return {onStart:a,callOnStart:e}}var de=(a={frameQuota:12})=>{let e=performance.now(),n=0,t=false,l=()=>!!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>a.frameQuota||l()))},async yieldToMain(){return new Promise(r=>{Pe(()=>{e=performance.now(),n=0,t&&(t=false),r();});})}}},Pe=a=>{let{port1:e,port2:n}=new MessageChannel;e.onmessage=a,n.postMessage(null);};function fe(a,e,n,t,l){let r=new Map,c=a.useGreedy,o=de();return async(d,i)=>{let f=Symbol("token"),p=d||"__NOTIFY_ALL__";r.set(p,f);let P=false;o.reset();let g=new Set,m=new Set,_=new Set;i.forEach(I=>{_.add(I),e.GetAllNextDependency(I).forEach(v=>_.add(v));});let N=new Map,C=new Map,M=new Set,L=e.GetPathToLevelMap(),G=0,z=0,H=I=>{e.GetAllNextDependency(I).forEach($=>{let A=L.get($)||0;A>z&&(z=A);});};d?(G=L.get(d)??0,H(d),g.add(d)):i.forEach(I=>H(I)),i.forEach(I=>{M.add(I);});let y=performance.now();t.emit("flow:start",{path:p}),t.callOnStart({path:p});let R=false,O=30,Q=I=>{let{target:v,trigger:$}=I,A=false,D=false,k=n.GetNodeByPath(v),W=[],E=(h,T)=>{if(g.has(h)||m.has(h)||M.has(h))return;let V=0,x=L.get(h)??0;if(N.has(h))V=N.get(h)-1;else {if(x>G&&N.size>O){C.has(x)||C.set(x,new Set),C.get(x).add(h),t.emit("node:intercept",{path:h,type:7});return}let F=e.GetPrevDependency(h),S=0;for(let b of F){if(g.has(b))continue;(L.get(b)??0)>G&&S++;}V=S;}if(V<=0){let F=M.has(h),S=m.has(h);if(F||S){t.emit("node:intercept",{path:h,type:S?3:3.1});return}N.delete(h),M.add(h),t.emit("node:release",{path:h,type:T,detail:{path:v}});}else N.set(h,V);},B=(h=[])=>{if(r.get(p)!==f)return;if(h.length){let x={},F=k.proxy;for(let S of h){let b=(S.args||[]).reduce((K,Y)=>(K[Y]=F[Y],K),{});try{let K=S.fn(b);K&&typeof K=="object"&&Object.assign(x,K);}catch(K){}}for(let S in x)if(S in k.state)k.state[S]=x[S];else throw {error:`wrong effect in ${String(k.path)}`};A=true;}A&&l.flushPathSet.add(v),t.emit("node:success",{path:v}),g.add(v);let T=e.GetNextDependency(v);(A||D)&&e.GetAllNextDependency(v).forEach(F=>_.add(F));for(let x of T){if(g.has(x)){t.emit("node:intercept",{path:x,type:2});continue}if(m.has(x)||M.has(x)){t.emit("node:intercept",{path:x,type:m.has(x)?3:3.1});continue}if(A||D)E(x,1);else if(N.has(x))E(x,2);else {let S=L.get(x);C.has(S)||C.set(S,new Set);let b=C.get(S);b.has(x)||(b.add(x),t.emit("node:stagnate",{path:x,type:1}));}}m.delete(v),(async()=>{if(!P){let x=m.size,F=M.size;t.emit("flow:fire",{path:v,type:1,detail:{active:x,pending:F,blocked:N.size}}),j();}})();},U=h=>{t.emit("node:error",{path:v,error:h});let T=Symbol("abort");r.set(p,T),M.clear(),N.clear(),m.clear(),t.callOnError(h);},w=(h,T)=>{let V=false;h!==k.state[T]&&(k.state[T]=h,A=true,t.emit("node:bucket:success",{path:v,key:String(T),value:h}),k.notifyKeys.has(T)&&(V=true)),k.nodeBucket[T].isForceNotify()&&(D=true),(V||D)&&H(v);};t.emit("node:start",{path:v});try{let h=[];for(let T in k.nodeBucket){let V=k.nodeBucket[T];h.push(...V.getSideEffect());let x=V.evaluate({affectKey:T,triggerPath:$,GetRenderSchemaByPath:F=>n.GetNodeByPath(F).proxy,GetValueByPath:F=>n.GetNodeByPath(F).state,GetToken:()=>f});if(x instanceof Promise){let F=x.then(S=>{r.get(p)===f&&w(S,T);});W.push(F);}else w(x,T);}if(W.length>0)return Promise.all(W).then(()=>{B(h);}).catch(U);B(h);return}catch(h){U(h);}},j=async()=>{if(r.get(p)!==f){P=false;return}P=true;let I=o.getIsFirstFrame(),v=0,$=()=>c&&I?30:1/0,A=0,D=$();try{for(;r.get(p)===f;){let k=A>=D,W=o.shouldYield();if(k||W){if(A>0&&(v++,(I||v%2===0)&&l.requestUpdate()),await o.yieldToMain(),r.get(p)!==f)break;A=0,I=o.getIsFirstFrame();}if(M.size>0&&m.size<5){for(let E of M){if(m.size>=5||A>=D)break;let B=L.get(E)??0,U=e.GetPrevDependency(E),w=U.length>1;if((!c||w)&&B>G){M.delete(E);let T=U.filter(V=>_.has(V)&&!g.has(V)).length;N.set(E,T||0),t.emit("node:intercept",{path:E,type:T>0?4:5,detail:{targetLevel:B,currentLevel:G,pendingParentsCount:T}});continue}if(M.delete(E),m.add(E),t.emit("node:processing",{path:E}),Q({target:E,trigger:d}),A++,A>=D||o.shouldYield())break}if(M.size>0)continue}if(A<D&&c&&N.size>0&&m.size<5){let E=!1,B=0;for(let[U,w]of N)if(w<=0){let h=L.get(U)??0,T=e.GetPrevDependency(U);if(h>G&&T.length>1)continue;if(N.delete(U),M.add(U),B++,E=!0,t.emit("node:release",{path:U,type:4}),B>=D)break}if(B>0)continue;if(E){if(o.shouldYield()&&(await o.yieldToMain(),r.get(p)!==f))break;continue}}if(m.size===0&&M.size===0){let E=new Set;for(let w of C.keys())E.add(w);for(let[w]of N){let h=L.get(w)??0;h>G&&E.add(h);}let B=Array.from(E).sort((w,h)=>w-h),U=B[0];if(B.length>0&&U<=z){let w=B[0];if(w<=z){G=w;let h=C.get(w);h&&(h.forEach(T=>M.add(T)),C.delete(w));for(let[T]of N)(L.get(T)??0)===w&&(N.delete(T),M.add(T),t.emit("node:release",{path:T,type:3,detail:{level:w}}));continue}}else {C.forEach((w,h)=>{w.forEach(T=>{g.add(T),t.emit("node:intercept",{path:T,type:6});});}),C.clear();for(let[w]of N)g.add(w),t.emit("node:intercept",{path:w,type:6});N.clear();break}}M.size>0&&m.size>=5&&t.emit("flow:wait",{type:2});break}}finally{if(P=false,m.size+N.size+M.size===0){if(r.get(p)===f&&!R){R=true,t.emit("flow:end",{type:1}),l.requestUpdate();let W=performance.now();t.emit("flow:success",{duration:(W-y).toFixed(2)+"ms"}),Promise.resolve().then(()=>{t.callOnSuccess();});}}else t.emit("flow:wait",{type:1,detail:{nums:m.size}});}};j();}}function ee(a){let{path:e,uid:n,type:t,meta:l,dirtySignal:r,triggerUI:c,state:o}=a,s=null,i={path:e,uid:n,type:t,meta:l,dirtySignal:r,createView:(u={})=>{let f=new Proxy(u,{get(p,P){let g=P;return g in a.state?a.state[g]:g in a?a[g]:l&&g in l?l[g]:Reflect.get(p,P)},set(p,P,g){let m=P;return m in a.state?(a.state[m]=g,true):Reflect.set(p,P,g)},ownKeys(p){let P=new Set([...Reflect.ownKeys(p),...Object.keys(o||{}),...Object.keys(l||{})]);return Array.from(P)},getOwnPropertyDescriptor(p,P){return o&&P in o||l&&P in l?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(p,P)}});return s=f,f}};return "children"in a?{...i,children:a.children}:{...i,state:a.state,nodeBucket:a.nodeBucket,notifyKeys:a.notifyKeys,dependOn:a.dependOn,get proxy(){return s}}}function ye(a,e,n,t,l,r){let c=0,o=new Map,s=new Map,d=new Map,i=false,u=new Set,g=async()=>{let y=Array.from(u);u.clear();for(let R of y){let O=M(R);r.signalTrigger(O.dirtySignal);}},m=()=>{i||(i=true,requestAnimationFrame(()=>{try{for(;u.size>0;)g();}finally{i=false;}}));},_=fe({useGreedy:e.useGreedy},n,{GetNodeByPath:M},l,{requestUpdate:m,flushPathSet:u}),N=y=>{if(o.has(y.path))throw new Error(`[MeshFlow] Duplicate Path: ${String(y.path)}`);let R=++c,O={path:y.path,getNode:I=>M(I)},Q=I=>{let v=I({...O}),$=M(y.path);if(t.createHistoryAction&&t.pushIntoHistory){let A=t.createHistoryAction([{path:y.path,value:$.state.value},{path:y.path,value:v}],D=>{let k=M(D.path);k.state.value=D.value,G(D.path);});t.pushIntoHistory(A);}$.state.value=v,G(y.path);};y.notifyKeys.size==0&&y.notifyKeys.add("value");let j=ee({uid:R,path:y.path,state:y.state,meta:y.meta,nodeBucket:y.nodeBucket,dirtySignal:y.dirtySignal,notifyKeys:y.notifyKeys,dependOn:Q});return o.set(j.path,R),s.set(R,j),j},C=y=>{if(o.has(y.path))throw new Error(`[MeshFlow] Duplicate Path: ${String(y.path)}`);let R=++c,O=ee({uid:R,path:y.path,state:{},meta:y,nodeBucket:{},children:y.children});return o.set(O.path,R),d.set(R,O),O};function M(y){let R=o.get(y),O=s.get(R);if(!O)throw Error("wrong ID");return O}function L(y){let R=o.get(y);return d.get(R)}let G=y=>{if(!M(y))throw Error("Node undefined");u.add(y),m();let O=n.GetNextDependency(y);z(O,y);};function z(y,R){_(R,y);}return {registerNode:N,registerGroupNode:C,GetNodeByPath:M,GetGroupByPath:L,notify:G,notifyAll:async()=>{Promise.resolve().then(async()=>{let y=n.GetDependencyOrder();if(!y||y.length===0)return;let R=y[0];try{_(null,R);}catch(O){throw l.callOnError(O),O}finally{m();}});},UITrigger:r,UidToNodeMap:s}}function pe(a,e){let n=false,t=false,l=new Map,r=new Map,c=new Map,o=new Map,s=[],d=new Map,{GetNextDependency:u,GetPrevDependency:f,GetAllPrevDependency:p,GetAllNextDependency:P,rebuildDirectDependencyMaps:g}=ae(()=>l,()=>r,()=>o,()=>c),m={},_={};if(e.modules.useHistory){let{Undo:S,Redo:b,PushIntoHistory:K,CreateHistoryAction:Y,initCanUndo:he,initCanRedo:ge}=e.modules.useHistory();m.pushIntoHistory=K,m.createHistoryAction=Y,_={Undo:S,Redo:b,initCanUndo:he,initCanRedo:ge};}let{onError:N,callOnError:C}=ie(),{onSuccess:M,callOnSuccess:L}=le(),{onStart:G,callOnStart:z}=ue(),{emit:H,usePlugin:y}=ce(),{SetTrace:R,useTrace:O}=se(),Q=O();y(Q);let j=ye(a,{useGreedy:e.config.useGreedy},{GetDependencyOrder:()=>s,GetAllNextDependency:P,GetNextDependency:u,GetPrevDependency:f,GetAllPrevDependency:p,GetPathToLevelMap:()=>d},m,{callOnError:C,callOnSuccess:L,callOnStart:z,emit:H},e.UITrigger),{GetGroupByPath:I,GetNodeByPath:v,notifyAll:$}=j,A={};if(e.modules.useInternalForm){let{uiSchema:S,GetFormData:b}=e.modules.useInternalForm(j,a);A={uiSchema:S,GetFormData:b};}let D={};if(e.modules.useSchemaValidators){let{SetValidators:S}=e.modules.useSchemaValidators(v);D={SetValidators:S};}let{SetRule:k,SetRules:W}=ne(v,l,r),{SetStrategy:E}=re(v),B=oe(l),U=()=>{let S=B();s=S.steps,d=S.levelMap;},w=()=>{t||(t=true,Promise.resolve().then(()=>{if(U(),n){let{directNextMap:S,directPrevMap:b}=g(s.flat());c=S,o=b;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(S,b,K,Y)=>{k(S,b,K,Y),n=true,w();},SetRules:(S,b,K,Y)=>{W(S,b,K,Y),n=true,w();},SetStrategy:E,SetTrace:R,usePlugin:y,SetValue:(S,b)=>{v(S).dependOn(()=>b);},GetValue:(S,b="value")=>v(S)[b],GetGroupByPath:I,notifyAll:async()=>{U(),await $();},GetAllDependency:()=>l,GetDependencyOrder:()=>s,historyExports:_,formExports:A,validatorExports:D,onError:N,onSuccess:M,onStart:G}}var J=new Map,me=(a,e,n)=>{try{if(typeof n.UITrigger.signalCreator!="function"||typeof n.UITrigger.signalTrigger!="function")throw Error("ui trigger undefined");if(J.has(a))throw Error("engineID repeated");let t=pe(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules||{},plugins:{}}),{SetRule:l,SetRules:r,SetStrategy:c,SetValue:o,GetValue:s,usePlugin:d,GetGroupByPath:i,notifyAll:u,SetTrace:f,GetAllDependency:p,GetDependencyOrder:P,historyExports:g,formExports:m,validatorExports:_,onError:N,onSuccess:C,onStart:M}=t,G={...{config:{SetRule:l,SetRules:r,SetStrategy:c,notifyAll:u,SetTrace:f,usePlugin:d},data:{SetValue:o,GetValue:s,GetGroupByPath:i},dependency:{GetAllDependency:p,GetDependencyOrder:P},hooks:{onError:N,onSuccess:C,onStart:M}}},z=n.modules;return z&&Object.keys(z).forEach(H=>{let y=H;if(y.startsWith("use")){let R=y.slice(3);y=R.charAt(0).toLowerCase()+R.slice(1);}H==="useHistory"&&g?Object.keys(g).length>0&&(G[y]=g):H==="useInternalForm"?Object.keys(m).length>0&&(G[y]=m):H==="useSchemaValidators"?Object.keys(_).length>0&&(G[y]=_):G[y]=z[H](t,e);}),J.set(a,G),G}catch(t){throw Error(t)}},Ze=()=>(a,e,n)=>Se(a,e,n),et=a=>{let e=J.get(a);if(e)return e;throw Error("[MeshFlow] Engine ID not found.")},tt=a=>{J.delete(a);},Se=me;exports.deleteEngine=tt;exports.useEngine=et;exports.useEngineManager=me;exports.useMeshFlow=Se;exports.useMeshFlowDefiner=Ze;exports.useScheduler=ye;
1
+ 'use strict';var ee=class{computedRules=[];store={OR:(e,n)=>{let t,u,r=this.computedRules;for(let l=0;l<r.length;l++){let s=r[l],o=s.logic(e);if(o instanceof Promise)return (async()=>{let a=await o;if(s.entityId==="__base__"?u=a:a&&(t=a),typeof t>"u")for(let f=l+1;f<r.length;f++){let g=r[f],y=g.logic(e),h=y instanceof Promise?await y:y;if(g.entityId==="__base__"){u=h;continue}if(h){t=g.value;break}}return typeof t>"u"&&(t=u),{res:t,version:n}})();let c=o;if(s.entityId==="__base__"){u=c;continue}if(c){t=s.value;break}}return typeof t>"u"&&(t=u),{res:t,version:n}},PRIORITY:(e,n)=>{let t,u=this.computedRules;for(let r=0;r<u.length;r++){let s=u[r].logic(e);if(s instanceof Promise)return (async()=>{let o=await s;if(o!==void 0)return {res:o,version:n};for(let c=r+1;c<u.length;c++){let a=u[c].logic(e),f=a instanceof Promise?await a:a;if(f!==void 0)return {res:f,version:n}}return {res:void 0,version:n}})();if(s!==void 0)return {res:s,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)}},J=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 u=()=>this.rules;this.strategy=new ee(u),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,u={...e,entityId:t};for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(u);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let l=this.rules.get(r);l&&(l.delete(u),l.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,u={...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(u);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let l=this.rules.get(r);l&&(l.delete(u),l.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 l=this.deps.get(e.triggerPath),s=e.GetValueByPath(e.triggerPath);if(typeof l=="object"||typeof s=="object")t=false;else {let o=Array.from(this.deps.keys());for(let c of o){let a=this.deps.get(c),f=e.GetValueByPath(c);if(a!==f){t=false;break}}}}if(t&&this.useCache)return this.cache;this.promiseToken=n;let u=++this.version,r=this.strategy.evaluate(e,u);if(!(r instanceof Promise)){let{res:l,version:s}=r;return this.finalizeSync(l,s,e,n)}return this.pendingPromise=(async()=>{try{let{res:l,version:s}=await r;return this.finalizeSync(l,s,e,n)}catch(l){throw {path:this.path,error:l}}finally{this.promiseToken===n&&(this.pendingPromise=null,this.promiseToken=null);}})(),this.pendingPromise}finalizeSync(e,n,t,u){return u!==this.promiseToken||n<this.version?this.cache:(this.cache=e,this.deps.forEach((r,l)=>{this.deps.set(l,t.GetValueByPath(l));}),e)}inferType(e){return Array.isArray(e)?"array":typeof e}};var ne=(i,e,n)=>{let u=r=>{let l=n.triggerPaths.map(c=>{let a=r.GetValueByPath(c),f={};return n.triggerKeys.forEach(g=>{f[g]=a[g];}),f}),s=Object.create(null);return Object.defineProperty(s,"triggerTargets",{get:()=>l}),Object.defineProperty(s,"affectedTatget",{get:()=>r.GetRenderSchemaByPath(i)[e]}),n.logic({slot:s})};return {value:n.value,targetPath:i,triggerPaths:n.triggerPaths,priority:n.priority??10,logic:u}},re=(i,e,n)=>{if(!i)throw Error("");let t=i,u=(s,o)=>{e.has(s)||e.set(s,new Set),e.get(s).add(o),n.has(o)||n.set(o,new Set),n.get(o).add(s);};return {SetRule:(s,o,c,a)=>{let f=t(o),g=a.triggerKeys||[];g.length==0&&g.push("value");let y=ne(o,c,{...a,triggerPaths:[s],triggerKeys:g}),h=[s].map(P=>[P,t(P).state.value]);if(u(s,o),f.nodeBucket[c])f.nodeBucket[c].setRule(y,h),a.effect&&f.nodeBucket[c].setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[c]});else {let P=f.meta[c],m=new J(P,c,o);m.setRule(y,h),a.effect&&m.setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[c]}),f.nodeBucket[c]=m;}f.state[c]=f.meta[c],a.forceNotify&&f.nodeBucket[c].forceNotify(),a.cacheStrategy=="none"&&f.nodeBucket[c].setUseCache(false);},SetRules:(s,o,c,a)=>{let f=t(o);for(let P of s)u(P,o);let g=a.triggerKeys||[];g.length==0&&g.push("value");let y=ne(o,c,{...a,triggerPaths:s,triggerKeys:g}),h=s.map(P=>[P,t(P).state.value]);if(f.nodeBucket[c])f.nodeBucket[c].setRules(y,h),a.effect&&f.nodeBucket[c].setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[c]});else {let P=f.meta[c],m=new J(P,c,o);m.setRules(y,h),a.effect&&m.setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[c]}),f.nodeBucket[c]=m;}f.state[c]=f.meta[c],a.forceNotify&&f.nodeBucket[c].forceNotify(),a.cacheStrategy=="none"&&f.nodeBucket[c].setUseCache(false);}}};var se=i=>{let e=i||void 0;if(!e)throw Error("");return {SetStrategy:(t,u,r)=>{e(t).nodeBucket[u].setStrategy(r);}}};function ae(){let i=new Map,e=new Map,n=new Set,t=(l,s)=>{i.set(l,s);let o=e.get(l);o&&o(s);};return {SetTrace:(l,s)=>{e.set(l,s);let o=i.get(l)||"idle";return s(o),{cancel:()=>{e.delete(l);}}},useTrace:()=>({apply:s=>{s.on("flow:start",()=>{n.forEach(o=>t(o,"idle")),n.clear(),i.clear();}),s.on("node:release",({path:o,type:c})=>{(c==1||c==2)&&(n.add(o),t(o,"pending"));}),s.on("node:pending",({path:o})=>{n.add(o),(!i.has(o)||i.get(o)==="idle")&&t(o,"pending");}),s.on("node:start",({path:o})=>{n.add(o),t(o,"calculating");}),s.on("node:success",({path:o})=>{t(o,"calculated");}),s.on("node:intercept",({path:o,type:c})=>{c==3&&t(o,"calculating"),c==6&&t(o,"idle");}),s.on("node:stagnate",({path:o})=>{t(o,"pending");}),s.on("node:error",({path:o})=>t(o,"error"));}})}}function oe(i,e,n,t){let u=a=>{let f=i(),g=e(),y=new Set;return f.get(a)?.forEach(h=>y.add(h)),y.size===0?[]:Array.from(y).filter(h=>{let P=g.get(h)||new Set;return !Array.from(P).some(S=>y.has(S))})};return {GetNextDependency:a=>{let f=t();return Array.from(f.get(a)||[])},GetPrevDependency:a=>{let f=n();return Array.from(f.get(a)||[])},GetAllPrevDependency:a=>{let f=e();return Array.from(f.get(a)||[])},GetAllNextDependency:a=>{let f=i();return Array.from(f.get(a)||[])},rebuildDirectDependencyMaps:a=>{let f=new Map,g=new Map;for(let y of a){let h=u(y);f.set(y,new Set(h));for(let P of h)g.has(P)||g.set(P,new Set),g.get(P).add(y);}return {directNextMap:f,directPrevMap:g}}}}function ie(i){let e=t=>{let u=[],r=[],l=new Map,s=t.size,o=0,c=0;for(let[a,f]of t)f===0&&r.push(a);if(r.length===0&&s>0)throw Error("Circular dependency detected");for(;r.length>0;){u.push([...r]);let a=[];for(let f of r){o++,l.set(f,c);let g=i.get(f);if(g)for(let y of g){let h=t.get(y)-1;t.set(y,h),h===0&&a.push(y);}}r=a,c++;}if(o<s)throw Error("Circular dependency detected");return {steps:u,levelMap:l}};return ()=>{let t=new Map;for(let u of i.keys()){let r=Array.from(i.get(u)||[]);t.has(u)||t.set(u,0);for(let l of r){let s=t.get(l)||0;t.set(l,++s);}}return e(t)}}var X=()=>{let i=[];return {on:e=>(i.push(e),()=>{let n=i.indexOf(e);n>-1&&i.splice(n,1);}),call:e=>i.forEach(n=>{n(e);})}};function le(){let{on:i,call:e}=X();return {onError:i,callOnError:e}}function ce(){let{on:i,call:e}=X();return {onSuccess:i,callOnSuccess:e}}var ue=()=>{let i=new Set,e=new Map,n=(r,l)=>{e.get(r)?.forEach(s=>s(l));},t=(r,l)=>(e.has(r)||e.set(r,new Set),e.get(r).add(l),()=>e.get(r).delete(l));return {usePlugin:r=>{let l=new Set,s=(o,c)=>{let a=t(o,c);return l.add(a),a};return r.apply({on:s}),i.add(r),()=>{l.forEach(o=>o()),l.clear(),i.delete(r);}},emit:n}};function fe(){let{on:i,call:e}=X();return {onStart:i,callOnStart:e}}var de=(i={frameQuota:12})=>{let e=performance.now(),n=0,t=false,u=()=>!!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>i.frameQuota||u()))},async yieldToMain(){return new Promise(r=>{me(()=>{e=performance.now(),n=0,t&&(t=false),r();});})}}},me=i=>{let{port1:e,port2:n}=new MessageChannel;e.onmessage=i,n.postMessage(null);};function ye(i,e,n,t,u){let r=new Map,l=i.useGreedy,s=de();return async(c,a)=>{let g=Symbol("token"),y=c||"__NOTIFY_ALL__";r.set(y,g);let h=false;s.reset();let P=new Set,m=new Set,z=new Set;a.forEach(G=>{z.add(G),e.GetAllNextDependency(G).forEach(w=>z.add(w));});let S=new Map,K=new Map,E=new Set,B=e.GetPathToLevelMap(),j=0,q=0,d=G=>{e.GetAllNextDependency(G).forEach($=>{let I=B.get($)||0;I>q&&(q=I);});};c?(j=B.get(c)??0,d(c),P.add(c)):a.forEach(G=>d(G)),a.forEach(G=>{E.add(G);});let x=performance.now();t.emit("flow:start",{path:y}),t.callOnStart({path:y});let T=false,O=30,H=G=>{let{target:w,trigger:$}=G,I=false,k=false,U=n.GetNodeByPath(w),W=[],b=(p,M)=>{if(P.has(p)||m.has(p)||E.has(p))return;let _=0,v=B.get(p)??0;if(S.has(p))_=S.get(p)-1;else {if(v>j&&S.size>O){K.has(v)||K.set(v,new Set),K.get(v).add(p),t.emit("node:intercept",{path:p,type:7});return}let C=e.GetPrevDependency(p),F=0;for(let N of C){if(P.has(N))continue;(B.get(N)??0)>j&&F++;}_=F;}if(_<=0){let C=E.has(p),F=m.has(p);if(C||F){t.emit("node:intercept",{path:p,type:F?3:3.1});return}S.delete(p),E.add(p),t.emit("node:release",{path:p,type:M,detail:{path:w}});}else S.set(p,_);},L=(p=[])=>{if(r.get(y)!==g)return;if(p.length){let v={},C=U.proxy;for(let F of p){let N=(F.args||[]).reduce((A,Y)=>(A[Y]=C[Y],A),{});try{let A=F.fn(N);A&&typeof A=="object"&&Object.assign(v,A);}catch(A){}}for(let F in v)if(F in U.state)U.state[F]=v[F];else throw {error:`wrong effect in ${String(U.path)}`};I=true;}I&&u.flushPathSet.add(w),t.emit("node:success",{path:w}),P.add(w);let M=e.GetNextDependency(w);(I||k)&&e.GetAllNextDependency(w).forEach(C=>z.add(C));for(let v of M){if(P.has(v)){t.emit("node:intercept",{path:v,type:2});continue}if(m.has(v)||E.has(v)){t.emit("node:intercept",{path:v,type:m.has(v)?3:3.1});continue}if(I||k)b(v,1);else if(S.has(v))b(v,2);else {let F=B.get(v);K.has(F)||K.set(F,new Set);let N=K.get(F);N.has(v)||(N.add(v),t.emit("node:stagnate",{path:v,type:1}));}}m.delete(w),(async()=>{if(!h){let v=m.size,C=E.size;t.emit("flow:fire",{path:w,type:1,detail:{active:v,pending:C,blocked:S.size}}),D();}})();},V=p=>{t.emit("node:error",{path:w,error:p});let M=Symbol("abort");r.set(y,M),E.clear(),S.clear(),m.clear(),t.callOnError(p);},R=(p,M)=>{let _=false;p!==U.state[M]&&(U.state[M]=p,I=true,t.emit("node:bucket:success",{path:w,key:String(M),value:p}),U.notifyKeys.has(M)&&(_=true)),U.nodeBucket[M].isForceNotify()&&(k=true),(_||k)&&d(w);};t.emit("node:start",{path:w});try{let p=[];for(let M in U.nodeBucket){let _=U.nodeBucket[M];p.push(..._.getSideEffect());let v=_.evaluate({affectKey:M,triggerPath:$,GetRenderSchemaByPath:C=>n.GetNodeByPath(C).proxy,GetValueByPath:C=>n.GetNodeByPath(C).state,GetToken:()=>g});if(v instanceof Promise){let C=v.then(F=>{r.get(y)===g&&R(F,M);});W.push(C);}else R(v,M);}if(W.length>0)return Promise.all(W).then(()=>{L(p);}).catch(V);L(p);return}catch(p){V(p);}},D=async()=>{if(r.get(y)!==g){h=false;return}h=true;let G=s.getIsFirstFrame(),w=0,$=()=>l&&G?30:1/0,I=0,k=$();try{for(;r.get(y)===g;){let U=I>=k,W=s.shouldYield();if(U||W){if(I>0&&(w++,(G||w%2===0)&&u.requestUpdate()),await s.yieldToMain(),r.get(y)!==g)break;I=0,G=s.getIsFirstFrame();}if(E.size>0&&m.size<5){for(let b of E){if(m.size>=5||I>=k)break;let L=B.get(b)??0,V=e.GetPrevDependency(b),R=V.length>1;if((!l||R)&&L>j){E.delete(b);let M=V.filter(_=>z.has(_)&&!P.has(_)).length;S.set(b,M||0),t.emit("node:intercept",{path:b,type:M>0?4:5,detail:{targetLevel:L,currentLevel:j,pendingParentsCount:M}});continue}if(E.delete(b),m.add(b),t.emit("node:processing",{path:b}),H({target:b,trigger:c}),I++,I>=k||s.shouldYield())break}if(E.size>0)continue}if(I<k&&l&&S.size>0&&m.size<5){let b=!1,L=0;for(let[V,R]of S)if(R<=0){let p=B.get(V)??0,M=e.GetPrevDependency(V);if(p>j&&M.length>1)continue;if(S.delete(V),E.add(V),L++,b=!0,t.emit("node:release",{path:V,type:4}),L>=k)break}if(L>0)continue;if(b){if(s.shouldYield()&&(await s.yieldToMain(),r.get(y)!==g))break;continue}}if(m.size===0&&E.size===0){let b=new Set;for(let R of K.keys())b.add(R);for(let[R]of S){let p=B.get(R)??0;p>j&&b.add(p);}let L=Array.from(b).sort((R,p)=>R-p),V=L[0];if(L.length>0&&V<=q){let R=L[0];if(R<=q){j=R;let p=K.get(R);p&&(p.forEach(M=>E.add(M)),K.delete(R));for(let[M]of S)(B.get(M)??0)===R&&(S.delete(M),E.add(M),t.emit("node:release",{path:M,type:3,detail:{level:R}}));continue}}else {K.forEach((R,p)=>{R.forEach(M=>{P.add(M),t.emit("node:intercept",{path:M,type:6});});}),K.clear();for(let[R]of S)P.add(R),t.emit("node:intercept",{path:R,type:6});S.clear();break}}E.size>0&&m.size>=5&&t.emit("flow:wait",{type:2});break}}finally{if(h=false,m.size+S.size+E.size===0){if(r.get(y)===g&&!T){T=true,t.emit("flow:end",{type:1}),u.requestUpdate();let W=performance.now();t.emit("flow:success",{duration:(W-x).toFixed(2)+"ms"}),Promise.resolve().then(()=>{t.callOnSuccess();});}}else t.emit("flow:wait",{type:1,detail:{nums:m.size}});}};D();}}function te(i){let{path:e,uid:n,type:t,meta:u,dirtySignal:r,triggerUI:l,state:s}=i,o=null,a={path:e,uid:n,type:t,meta:u,dirtySignal:r,createView:(f={})=>{let g=new Proxy(f,{get(y,h){let P=h;return P in i.state?i.state[P]:P in i?i[P]:u&&P in u?u[P]:Reflect.get(y,h)},set(y,h,P){let m=h;return m in i.state?(i.state[m]=P,true):Reflect.set(y,h,P)},ownKeys(y){let h=new Set([...Reflect.ownKeys(y),...Object.keys(s||{}),...Object.keys(u||{})]);return Array.from(h)},getOwnPropertyDescriptor(y,h){return s&&h in s||u&&h in u?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(y,h)}});return o=g,g}};return "children"in i?{...a,children:i.children}:{...a,state:i.state,nodeBucket:i.nodeBucket,notifyKeys:i.notifyKeys,dependOn:i.dependOn,get proxy(){return o}}}function pe(i,e,n,t,u){let r=0,l=new Map,s=new Map,o=new Map,c=false,a=new Set,g=async()=>{let d=Array.from(a);a.clear();for(let x of d){let T=S(x);u.signalTrigger(T.dirtySignal);}},y=()=>{c||(c=true,requestAnimationFrame(()=>{try{for(;a.size>0;)g();}finally{c=false;}}));},h=ye({useGreedy:i.useGreedy},e,{GetNodeByPath:S},t,{requestUpdate:y,flushPathSet:a}),P=d=>{throw new Error(`[MeshFlow] Duplicate Path: ${d}`)},m=d=>{l.has(d.path)&&P(String(d.path));let x=++r,T={path:d.path,getNode:D=>S(D)},O=(D,G="value")=>{let w=D({...T}),$=S(d.path);if(n.createHistoryAction&&n.pushIntoHistory){let I=n.createHistoryAction([{path:d.path,value:$.state[G]},{path:d.path,value:w}],k=>{let U=S(k.path);U.state[G]=k.value,E(k.path);});n.pushIntoHistory(I);}$.state[G]=w,E(d.path);};d.notifyKeys.size==0&&d.notifyKeys.add("value");let H=te({uid:x,path:d.path,state:d.state,meta:d.meta,nodeBucket:d.nodeBucket,dirtySignal:d.dirtySignal,notifyKeys:d.notifyKeys,dependOn:O});return l.set(H.path,x),s.set(x,H),H},z=d=>{l.has(d.path)&&P(String(d.path));let x=++r,T=te({uid:x,path:d.path,state:{},meta:d,nodeBucket:{},children:d.children});return l.set(T.path,x),o.set(x,T),T};function S(d){let x=l.get(d),T=s.get(x);if(!T)throw Error("wrong ID");return T}function K(d){let x=l.get(d);return o.get(x)}let E=d=>{if(!S(d))throw Error("Node undefined");a.add(d),y();let T=e.GetNextDependency(d);B(T,d);};function B(d,x){h(x,d);}return {registerNode:m,registerGroupNode:z,GetNodeByPath:S,GetGroupByPath:K,notify:E,notifyAll:async()=>{Promise.resolve().then(async()=>{let d=e.GetDependencyOrder();if(!d||d.length===0)return;let x=d[0];try{h(null,x);}catch(T){throw t.callOnError(T),T}finally{y();}});},batchNotify:d=>{if(!d||d.length===0)return;if(n.createHistoryAction&&n.pushIntoHistory){let T=n.createHistoryAction([d.map(O=>({path:O.path,key:O.key,value:S(O.path).state[O.key]})),d.map(O=>({path:O.path,key:O.key,value:O.value}))],O=>{let H=new Set;O.forEach(D=>{let G=S(D.path);G.state[D.key]=D.value,a.add(D.path),H.add(D.path);}),y(),H.size>0&&h(null,Array.from(H));});n.pushIntoHistory(T);}let x=new Set;d.forEach(T=>{let O=S(T.path);O.state[T.key]=T.value,a.add(T.path),x.add(T.path);}),y(),x.size>0&&h(null,Array.from(x));},UITrigger:u,UidToNodeMap:s}}function he(i,e){let n=false,t=false,u=new Map,r=new Map,l=new Map,s=new Map,o=[],c=new Map,{GetNextDependency:f,GetPrevDependency:g,GetAllPrevDependency:y,GetAllNextDependency:h,rebuildDirectDependencyMaps:P}=oe(()=>u,()=>r,()=>s,()=>l),m={},z={};if(e.modules.useHistory){let{Undo:N,Redo:A,PushIntoHistory:Y,CreateHistoryAction:Q,initCanUndo:ge,initCanRedo:Pe}=e.modules.useHistory();m.pushIntoHistory=Y,m.createHistoryAction=Q,z={Undo:N,Redo:A,initCanUndo:ge,initCanRedo:Pe};}let{onError:S,callOnError:K}=le(),{onSuccess:E,callOnSuccess:B}=ce(),{onStart:j,callOnStart:q}=fe(),{emit:d,usePlugin:x}=ue(),{SetTrace:T,useTrace:O}=ae(),H=O();x(H);let D=pe({useGreedy:e.config.useGreedy},{GetDependencyOrder:()=>o,GetAllNextDependency:h,GetNextDependency:f,GetPrevDependency:g,GetAllPrevDependency:y,GetPathToLevelMap:()=>c},m,{callOnError:K,callOnSuccess:B,callOnStart:q,emit:d},e.UITrigger),{GetGroupByPath:G,GetNodeByPath:w,notifyAll:$}=D,I={};if(e.modules.useInternalForm){let{uiSchema:N,GetFormData:A}=e.modules.useInternalForm(D,i);I={uiSchema:N,GetFormData:A};}let k={};if(e.modules.useSchemaValidators){let{SetValidators:N}=e.modules.useSchemaValidators(w);k={SetValidators:N};}let{SetRule:U,SetRules:W}=re(w,u,r),{SetStrategy:b}=se(w),L=ie(u),V=()=>{let N=L();o=N.steps,c=N.levelMap;},R=()=>{t||(t=true,Promise.resolve().then(()=>{if(V(),n){let{directNextMap:N,directPrevMap:A}=P(o.flat());l=N,s=A;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(N,A,Y,Q)=>{U(N,A,Y,Q),n=true,R();},SetRules:(N,A,Y,Q)=>{W(N,A,Y,Q),n=true,R();},SetStrategy:b,SetTrace:T,usePlugin:x,SetValue:(N,A,Y)=>{w(N).dependOn(()=>Y,A);},GetValue:(N,A="value")=>w(N)[A],SetValues:N=>{D.batchNotify(N);},GetGroupByPath:G,notifyAll:async()=>{V(),await $();},GetAllDependency:()=>u,GetDependencyOrder:()=>o,historyExports:z,formExports:I,validatorExports:k,onError:S,onSuccess:E,onStart:j,scheduler:D}}var Z=new Map,Se=(i,e,n)=>{try{if(typeof n.UITrigger.signalCreator!="function"||typeof n.UITrigger.signalTrigger!="function")throw Error("ui trigger undefined");if(Z.has(i))throw Error("engineID repeated");let t=he(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules||{},plugins:{}}),{SetRule:u,SetRules:r,SetValues:l,SetStrategy:s,SetValue:o,GetValue:c,usePlugin:a,GetGroupByPath:f,notifyAll:g,SetTrace:y,GetAllDependency:h,GetDependencyOrder:P,historyExports:m,formExports:z,validatorExports:S,onError:K,onSuccess:E,onStart:B,scheduler:j}=t,d={...{config:{SetRule:u,SetRules:r,SetStrategy:s,notifyAll:g,SetTrace:y,usePlugin:a},data:{SetValue:o,GetValue:c,SetValues:l,GetGroupByPath:f},dependency:{GetAllDependency:h,GetDependencyOrder:P},hooks:{onError:K,onSuccess:E,onStart:B}}},x=n.modules;return x&&Object.keys(x).forEach(T=>{let O=T;if(O.startsWith("use")){let H=O.slice(3);O=H.charAt(0).toLowerCase()+H.slice(1);}T==="useHistory"&&m?Object.keys(m).length>0&&(d[O]=m):T==="useInternalForm"?Object.keys(z).length>0&&(d[O]=z):T==="useSchemaValidators"?Object.keys(S).length>0&&(d[O]=S):d[O]=x[T](j,e);}),Z.set(i,d),d}catch(t){throw Error(t)}},et=()=>(i,e,n)=>Te(i,e,n),tt=i=>{let e=Z.get(i);if(e)return e;throw Error("[MeshFlow] Engine ID not found.")},nt=i=>{Z.delete(i);},Te=Se;exports.deleteEngine=nt;exports.useEngine=tt;exports.useEngineManager=Se;exports.useMeshFlow=Te;exports.useMeshFlowDefiner=et;exports.useScheduler=pe;
package/index.mjs CHANGED
@@ -1 +1 @@
1
- var Z=class{computedRules=[];store={OR:(e,n)=>{let t,l,r=this.computedRules;for(let c=0;c<r.length;c++){let o=r[c],s=o.logic(e);if(s instanceof Promise)return (async()=>{let i=await s;if(o.entityId==="__base__"?l=i:i&&(t=i),typeof t>"u")for(let u=c+1;u<r.length;u++){let f=r[u],p=f.logic(e),P=p instanceof Promise?await p:p;if(f.entityId==="__base__"){l=P;continue}if(P){t=f.value;break}}return typeof t>"u"&&(t=l),{res:t,version:n}})();let d=s;if(o.entityId==="__base__"){l=d;continue}if(d){t=o.value;break}}return typeof t>"u"&&(t=l),{res:t,version:n}},PRIORITY:(e,n)=>{let t,l=this.computedRules;for(let r=0;r<l.length;r++){let o=l[r].logic(e);if(o instanceof Promise)return (async()=>{let s=await o;if(s!==void 0)return {res:s,version:n};for(let d=r+1;d<l.length;d++){let i=l[d].logic(e),u=i instanceof Promise?await i:i;if(u!==void 0)return {res:u,version:n}}return {res:void 0,version:n}})();if(o!==void 0)return {res:o,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)}},X=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;effectArray=[];constructor(e,n,t){let l=()=>this.rules;this.strategy=new Z(l),this.path=t,this.isValue=n==="value",this.contract=this.inferType(e),this.cache=e,this.setRule({priority:0,entityId:"__base__",logic:()=>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,l={...e,entityId:t};for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(l);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let c=this.rules.get(r);c&&(c.delete(l),c.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,l={...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(l);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let c=this.rules.get(r);c&&(c.delete(l),c.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 c=this.deps.get(e.triggerPath),o=e.GetValueByPath(e.triggerPath);if(typeof c=="object"||typeof o=="object")t=false;else {let s=Array.from(this.deps.keys());for(let d of s){let i=this.deps.get(d),u=e.GetValueByPath(d);if(i!==u){t=false;break}}}}if(t)return this.cache;this.promiseToken=n;let l=++this.version,r=this.strategy.evaluate(e,l);if(!(r instanceof Promise)){let{res:c,version:o}=r;return this.finalizeSync(c,o,e,n)}return this.pendingPromise=(async()=>{try{let{res:c,version:o}=await r;return this.finalizeSync(c,o,e,n)}catch(c){throw {path:this.path,error:c}}finally{this.promiseToken===n&&(this.pendingPromise=null,this.promiseToken=null);}})(),this.pendingPromise}finalizeSync(e,n,t,l){return l!==this.promiseToken||n<this.version?this.cache:(this.cache=e,this.deps.forEach((r,c)=>{this.deps.set(c,t.GetValueByPath(c));}),e)}inferType(e){return Array.isArray(e)?"array":typeof e}};var te=(a,e,n)=>{let l=r=>{let c=n.triggerPaths.map(d=>r.GetValueByPath(d).value),o=Object.create(null);return Object.defineProperty(o,"triggerTargets",{get:()=>c||[]}),Object.defineProperty(o,"affectedTatget",{get:()=>r.GetRenderSchemaByPath(a)[e]}),n.logic({slot:o})};return {value:n.value,targetPath:a,triggerPaths:n.triggerPaths,priority:n.priority??10,logic:l}},ne=(a,e,n,t)=>{if(!a)throw Error("");let l=a,r=(s,d)=>{e.has(s)||e.set(s,new Set),e.get(s).add(d),n.has(d)||n.set(d,new Set),n.get(d).add(s);};return {SetRule:(s,d,i,u={logic:()=>{}})=>{let f=l(d),p=te(d,i,{...u,triggerPaths:[s]}),P=[s].map(g=>[g,l(g).state.value]);if(r(s,d),f.nodeBucket[i])f.nodeBucket[i].setRule(p,P),u.effect&&f.nodeBucket[i].setSideEffect({fn:u.effect,args:u.effectArgs?u.effectArgs:[i]});else {let g=f.meta[i],m=new X(g,i,d);m.setRule(p,P),u.effect&&m.setSideEffect({fn:u.effect,args:u.effectArgs?u.effectArgs:[i]}),f.nodeBucket[i]=m;}f.state[i]=f.meta[i],u.forceNotify&&f.nodeBucket[i].forceNotify();},SetRules:(s,d,i,u={logic:()=>{}})=>{let f=l(d);for(let g of s)r(g,d);let p=te(d,i,{...u,triggerPaths:s}),P=s.map(g=>[g,l(g).state.value]);if(f.nodeBucket[i])f.nodeBucket[i].setRules(p,P),u.effect&&f.nodeBucket[i].setSideEffect({fn:u.effect,args:u.effectArgs?u.effectArgs:[i]});else {let g=f.meta[i],m=new X(g,i,d);m.setRules(p,P),u.effect&&m.setSideEffect({fn:u.effect,args:u.effectArgs?u.effectArgs:[i]}),f.nodeBucket[i]=m;}f.state[i]=f.meta[i],u.forceNotify&&f.nodeBucket[i].forceNotify();}}};var re=a=>{let e=a||void 0;if(!e)throw Error("");return {SetStrategy:(t,l,r)=>{e(t).nodeBucket[l].setStrategy(r);}}};function se(){let a=new Map,e=new Map,n=new Set,t=(c,o)=>{a.set(c,o);let s=e.get(c);s&&s(o);};return {SetTrace:(c,o)=>{e.set(c,o);let s=a.get(c)||"idle";return o(s),{cancel:()=>{e.delete(c);}}},useTrace:()=>({apply:o=>{o.on("flow:start",()=>{n.forEach(s=>t(s,"idle")),n.clear(),a.clear();}),o.on("node:release",({path:s,type:d})=>{(d==1||d==2)&&(n.add(s),t(s,"pending"));}),o.on("node:pending",({path:s})=>{n.add(s),(!a.has(s)||a.get(s)==="idle")&&t(s,"pending");}),o.on("node:start",({path:s})=>{n.add(s),t(s,"calculating");}),o.on("node:success",({path:s})=>{t(s,"calculated");}),o.on("node:intercept",({path:s,type:d})=>{d==3&&t(s,"calculating"),d==6&&t(s,"idle");}),o.on("node:stagnate",({path:s})=>{t(s,"pending");}),o.on("node:error",({path:s})=>t(s,"error"));}})}}function ae(a,e,n,t){let l=i=>{let u=a(),f=e(),p=new Set;return u.get(i)?.forEach(P=>p.add(P)),p.size===0?[]:Array.from(p).filter(P=>{let g=f.get(P)||new Set;return !Array.from(g).some(N=>p.has(N))})};return {GetNextDependency:i=>{let u=t();return Array.from(u.get(i)||[])},GetPrevDependency:i=>{let u=n();return Array.from(u.get(i)||[])},GetAllPrevDependency:i=>{let u=e();return Array.from(u.get(i)||[])},GetAllNextDependency:i=>{let u=a();return Array.from(u.get(i)||[])},rebuildDirectDependencyMaps:i=>{let u=new Map,f=new Map;for(let p of i){let P=l(p);u.set(p,new Set(P));for(let g of P)f.has(g)||f.set(g,new Set),f.get(g).add(p);}return {directNextMap:u,directPrevMap:f}}}}function oe(a){let e=t=>{let l=[],r=[],c=new Map,o=t.size,s=0,d=0;for(let[i,u]of t)u===0&&r.push(i);if(r.length===0&&o>0)throw Error("Circular dependency detected");for(;r.length>0;){l.push([...r]);let i=[];for(let u of r){s++,c.set(u,d);let f=a.get(u);if(f)for(let p of f){let P=t.get(p)-1;t.set(p,P),P===0&&i.push(p);}}r=i,d++;}if(s<o)throw Error("Circular dependency detected");return {steps:l,levelMap:c}};return ()=>{let t=new Map;for(let l of a.keys()){let r=Array.from(a.get(l)||[]);t.has(l)||t.set(l,0);for(let c of r){let o=t.get(c)||0;t.set(c,++o);}}return e(t)}}var q=()=>{let a=[];return {on:e=>(a.push(e),()=>{let n=a.indexOf(e);n>-1&&a.splice(n,1);}),call:e=>a.forEach(n=>{n(e);})}};function ie(){let{on:a,call:e}=q();return {onError:a,callOnError:e}}function le(){let{on:a,call:e}=q();return {onSuccess:a,callOnSuccess:e}}var ce=()=>{let a=new Set,e=new Map,n=(r,c)=>{e.get(r)?.forEach(o=>o(c));},t=(r,c)=>(e.has(r)||e.set(r,new Set),e.get(r).add(c),()=>e.get(r).delete(c));return {usePlugin:r=>{let c=new Set,o=(s,d)=>{let i=t(s,d);return c.add(i),i};return r.apply({on:o}),a.add(r),()=>{c.forEach(s=>s()),c.clear(),a.delete(r);}},emit:n}};function ue(){let{on:a,call:e}=q();return {onStart:a,callOnStart:e}}var de=(a={frameQuota:12})=>{let e=performance.now(),n=0,t=false,l=()=>!!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>a.frameQuota||l()))},async yieldToMain(){return new Promise(r=>{Pe(()=>{e=performance.now(),n=0,t&&(t=false),r();});})}}},Pe=a=>{let{port1:e,port2:n}=new MessageChannel;e.onmessage=a,n.postMessage(null);};function fe(a,e,n,t,l){let r=new Map,c=a.useGreedy,o=de();return async(d,i)=>{let f=Symbol("token"),p=d||"__NOTIFY_ALL__";r.set(p,f);let P=false;o.reset();let g=new Set,m=new Set,_=new Set;i.forEach(I=>{_.add(I),e.GetAllNextDependency(I).forEach(v=>_.add(v));});let N=new Map,C=new Map,M=new Set,L=e.GetPathToLevelMap(),G=0,z=0,H=I=>{e.GetAllNextDependency(I).forEach($=>{let A=L.get($)||0;A>z&&(z=A);});};d?(G=L.get(d)??0,H(d),g.add(d)):i.forEach(I=>H(I)),i.forEach(I=>{M.add(I);});let y=performance.now();t.emit("flow:start",{path:p}),t.callOnStart({path:p});let R=false,O=30,Q=I=>{let{target:v,trigger:$}=I,A=false,D=false,k=n.GetNodeByPath(v),W=[],E=(h,T)=>{if(g.has(h)||m.has(h)||M.has(h))return;let V=0,x=L.get(h)??0;if(N.has(h))V=N.get(h)-1;else {if(x>G&&N.size>O){C.has(x)||C.set(x,new Set),C.get(x).add(h),t.emit("node:intercept",{path:h,type:7});return}let F=e.GetPrevDependency(h),S=0;for(let b of F){if(g.has(b))continue;(L.get(b)??0)>G&&S++;}V=S;}if(V<=0){let F=M.has(h),S=m.has(h);if(F||S){t.emit("node:intercept",{path:h,type:S?3:3.1});return}N.delete(h),M.add(h),t.emit("node:release",{path:h,type:T,detail:{path:v}});}else N.set(h,V);},B=(h=[])=>{if(r.get(p)!==f)return;if(h.length){let x={},F=k.proxy;for(let S of h){let b=(S.args||[]).reduce((K,Y)=>(K[Y]=F[Y],K),{});try{let K=S.fn(b);K&&typeof K=="object"&&Object.assign(x,K);}catch(K){}}for(let S in x)if(S in k.state)k.state[S]=x[S];else throw {error:`wrong effect in ${String(k.path)}`};A=true;}A&&l.flushPathSet.add(v),t.emit("node:success",{path:v}),g.add(v);let T=e.GetNextDependency(v);(A||D)&&e.GetAllNextDependency(v).forEach(F=>_.add(F));for(let x of T){if(g.has(x)){t.emit("node:intercept",{path:x,type:2});continue}if(m.has(x)||M.has(x)){t.emit("node:intercept",{path:x,type:m.has(x)?3:3.1});continue}if(A||D)E(x,1);else if(N.has(x))E(x,2);else {let S=L.get(x);C.has(S)||C.set(S,new Set);let b=C.get(S);b.has(x)||(b.add(x),t.emit("node:stagnate",{path:x,type:1}));}}m.delete(v),(async()=>{if(!P){let x=m.size,F=M.size;t.emit("flow:fire",{path:v,type:1,detail:{active:x,pending:F,blocked:N.size}}),j();}})();},U=h=>{t.emit("node:error",{path:v,error:h});let T=Symbol("abort");r.set(p,T),M.clear(),N.clear(),m.clear(),t.callOnError(h);},w=(h,T)=>{let V=false;h!==k.state[T]&&(k.state[T]=h,A=true,t.emit("node:bucket:success",{path:v,key:String(T),value:h}),k.notifyKeys.has(T)&&(V=true)),k.nodeBucket[T].isForceNotify()&&(D=true),(V||D)&&H(v);};t.emit("node:start",{path:v});try{let h=[];for(let T in k.nodeBucket){let V=k.nodeBucket[T];h.push(...V.getSideEffect());let x=V.evaluate({affectKey:T,triggerPath:$,GetRenderSchemaByPath:F=>n.GetNodeByPath(F).proxy,GetValueByPath:F=>n.GetNodeByPath(F).state,GetToken:()=>f});if(x instanceof Promise){let F=x.then(S=>{r.get(p)===f&&w(S,T);});W.push(F);}else w(x,T);}if(W.length>0)return Promise.all(W).then(()=>{B(h);}).catch(U);B(h);return}catch(h){U(h);}},j=async()=>{if(r.get(p)!==f){P=false;return}P=true;let I=o.getIsFirstFrame(),v=0,$=()=>c&&I?30:1/0,A=0,D=$();try{for(;r.get(p)===f;){let k=A>=D,W=o.shouldYield();if(k||W){if(A>0&&(v++,(I||v%2===0)&&l.requestUpdate()),await o.yieldToMain(),r.get(p)!==f)break;A=0,I=o.getIsFirstFrame();}if(M.size>0&&m.size<5){for(let E of M){if(m.size>=5||A>=D)break;let B=L.get(E)??0,U=e.GetPrevDependency(E),w=U.length>1;if((!c||w)&&B>G){M.delete(E);let T=U.filter(V=>_.has(V)&&!g.has(V)).length;N.set(E,T||0),t.emit("node:intercept",{path:E,type:T>0?4:5,detail:{targetLevel:B,currentLevel:G,pendingParentsCount:T}});continue}if(M.delete(E),m.add(E),t.emit("node:processing",{path:E}),Q({target:E,trigger:d}),A++,A>=D||o.shouldYield())break}if(M.size>0)continue}if(A<D&&c&&N.size>0&&m.size<5){let E=!1,B=0;for(let[U,w]of N)if(w<=0){let h=L.get(U)??0,T=e.GetPrevDependency(U);if(h>G&&T.length>1)continue;if(N.delete(U),M.add(U),B++,E=!0,t.emit("node:release",{path:U,type:4}),B>=D)break}if(B>0)continue;if(E){if(o.shouldYield()&&(await o.yieldToMain(),r.get(p)!==f))break;continue}}if(m.size===0&&M.size===0){let E=new Set;for(let w of C.keys())E.add(w);for(let[w]of N){let h=L.get(w)??0;h>G&&E.add(h);}let B=Array.from(E).sort((w,h)=>w-h),U=B[0];if(B.length>0&&U<=z){let w=B[0];if(w<=z){G=w;let h=C.get(w);h&&(h.forEach(T=>M.add(T)),C.delete(w));for(let[T]of N)(L.get(T)??0)===w&&(N.delete(T),M.add(T),t.emit("node:release",{path:T,type:3,detail:{level:w}}));continue}}else {C.forEach((w,h)=>{w.forEach(T=>{g.add(T),t.emit("node:intercept",{path:T,type:6});});}),C.clear();for(let[w]of N)g.add(w),t.emit("node:intercept",{path:w,type:6});N.clear();break}}M.size>0&&m.size>=5&&t.emit("flow:wait",{type:2});break}}finally{if(P=false,m.size+N.size+M.size===0){if(r.get(p)===f&&!R){R=true,t.emit("flow:end",{type:1}),l.requestUpdate();let W=performance.now();t.emit("flow:success",{duration:(W-y).toFixed(2)+"ms"}),Promise.resolve().then(()=>{t.callOnSuccess();});}}else t.emit("flow:wait",{type:1,detail:{nums:m.size}});}};j();}}function ee(a){let{path:e,uid:n,type:t,meta:l,dirtySignal:r,triggerUI:c,state:o}=a,s=null,i={path:e,uid:n,type:t,meta:l,dirtySignal:r,createView:(u={})=>{let f=new Proxy(u,{get(p,P){let g=P;return g in a.state?a.state[g]:g in a?a[g]:l&&g in l?l[g]:Reflect.get(p,P)},set(p,P,g){let m=P;return m in a.state?(a.state[m]=g,true):Reflect.set(p,P,g)},ownKeys(p){let P=new Set([...Reflect.ownKeys(p),...Object.keys(o||{}),...Object.keys(l||{})]);return Array.from(P)},getOwnPropertyDescriptor(p,P){return o&&P in o||l&&P in l?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(p,P)}});return s=f,f}};return "children"in a?{...i,children:a.children}:{...i,state:a.state,nodeBucket:a.nodeBucket,notifyKeys:a.notifyKeys,dependOn:a.dependOn,get proxy(){return s}}}function ye(a,e,n,t,l,r){let c=0,o=new Map,s=new Map,d=new Map,i=false,u=new Set,g=async()=>{let y=Array.from(u);u.clear();for(let R of y){let O=M(R);r.signalTrigger(O.dirtySignal);}},m=()=>{i||(i=true,requestAnimationFrame(()=>{try{for(;u.size>0;)g();}finally{i=false;}}));},_=fe({useGreedy:e.useGreedy},n,{GetNodeByPath:M},l,{requestUpdate:m,flushPathSet:u}),N=y=>{if(o.has(y.path))throw new Error(`[MeshFlow] Duplicate Path: ${String(y.path)}`);let R=++c,O={path:y.path,getNode:I=>M(I)},Q=I=>{let v=I({...O}),$=M(y.path);if(t.createHistoryAction&&t.pushIntoHistory){let A=t.createHistoryAction([{path:y.path,value:$.state.value},{path:y.path,value:v}],D=>{let k=M(D.path);k.state.value=D.value,G(D.path);});t.pushIntoHistory(A);}$.state.value=v,G(y.path);};y.notifyKeys.size==0&&y.notifyKeys.add("value");let j=ee({uid:R,path:y.path,state:y.state,meta:y.meta,nodeBucket:y.nodeBucket,dirtySignal:y.dirtySignal,notifyKeys:y.notifyKeys,dependOn:Q});return o.set(j.path,R),s.set(R,j),j},C=y=>{if(o.has(y.path))throw new Error(`[MeshFlow] Duplicate Path: ${String(y.path)}`);let R=++c,O=ee({uid:R,path:y.path,state:{},meta:y,nodeBucket:{},children:y.children});return o.set(O.path,R),d.set(R,O),O};function M(y){let R=o.get(y),O=s.get(R);if(!O)throw Error("wrong ID");return O}function L(y){let R=o.get(y);return d.get(R)}let G=y=>{if(!M(y))throw Error("Node undefined");u.add(y),m();let O=n.GetNextDependency(y);z(O,y);};function z(y,R){_(R,y);}return {registerNode:N,registerGroupNode:C,GetNodeByPath:M,GetGroupByPath:L,notify:G,notifyAll:async()=>{Promise.resolve().then(async()=>{let y=n.GetDependencyOrder();if(!y||y.length===0)return;let R=y[0];try{_(null,R);}catch(O){throw l.callOnError(O),O}finally{m();}});},UITrigger:r,UidToNodeMap:s}}function pe(a,e){let n=false,t=false,l=new Map,r=new Map,c=new Map,o=new Map,s=[],d=new Map,{GetNextDependency:u,GetPrevDependency:f,GetAllPrevDependency:p,GetAllNextDependency:P,rebuildDirectDependencyMaps:g}=ae(()=>l,()=>r,()=>o,()=>c),m={},_={};if(e.modules.useHistory){let{Undo:S,Redo:b,PushIntoHistory:K,CreateHistoryAction:Y,initCanUndo:he,initCanRedo:ge}=e.modules.useHistory();m.pushIntoHistory=K,m.createHistoryAction=Y,_={Undo:S,Redo:b,initCanUndo:he,initCanRedo:ge};}let{onError:N,callOnError:C}=ie(),{onSuccess:M,callOnSuccess:L}=le(),{onStart:G,callOnStart:z}=ue(),{emit:H,usePlugin:y}=ce(),{SetTrace:R,useTrace:O}=se(),Q=O();y(Q);let j=ye(a,{useGreedy:e.config.useGreedy},{GetDependencyOrder:()=>s,GetAllNextDependency:P,GetNextDependency:u,GetPrevDependency:f,GetAllPrevDependency:p,GetPathToLevelMap:()=>d},m,{callOnError:C,callOnSuccess:L,callOnStart:z,emit:H},e.UITrigger),{GetGroupByPath:I,GetNodeByPath:v,notifyAll:$}=j,A={};if(e.modules.useInternalForm){let{uiSchema:S,GetFormData:b}=e.modules.useInternalForm(j,a);A={uiSchema:S,GetFormData:b};}let D={};if(e.modules.useSchemaValidators){let{SetValidators:S}=e.modules.useSchemaValidators(v);D={SetValidators:S};}let{SetRule:k,SetRules:W}=ne(v,l,r),{SetStrategy:E}=re(v),B=oe(l),U=()=>{let S=B();s=S.steps,d=S.levelMap;},w=()=>{t||(t=true,Promise.resolve().then(()=>{if(U(),n){let{directNextMap:S,directPrevMap:b}=g(s.flat());c=S,o=b;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(S,b,K,Y)=>{k(S,b,K,Y),n=true,w();},SetRules:(S,b,K,Y)=>{W(S,b,K,Y),n=true,w();},SetStrategy:E,SetTrace:R,usePlugin:y,SetValue:(S,b)=>{v(S).dependOn(()=>b);},GetValue:(S,b="value")=>v(S)[b],GetGroupByPath:I,notifyAll:async()=>{U(),await $();},GetAllDependency:()=>l,GetDependencyOrder:()=>s,historyExports:_,formExports:A,validatorExports:D,onError:N,onSuccess:M,onStart:G}}var J=new Map,me=(a,e,n)=>{try{if(typeof n.UITrigger.signalCreator!="function"||typeof n.UITrigger.signalTrigger!="function")throw Error("ui trigger undefined");if(J.has(a))throw Error("engineID repeated");let t=pe(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules||{},plugins:{}}),{SetRule:l,SetRules:r,SetStrategy:c,SetValue:o,GetValue:s,usePlugin:d,GetGroupByPath:i,notifyAll:u,SetTrace:f,GetAllDependency:p,GetDependencyOrder:P,historyExports:g,formExports:m,validatorExports:_,onError:N,onSuccess:C,onStart:M}=t,G={...{config:{SetRule:l,SetRules:r,SetStrategy:c,notifyAll:u,SetTrace:f,usePlugin:d},data:{SetValue:o,GetValue:s,GetGroupByPath:i},dependency:{GetAllDependency:p,GetDependencyOrder:P},hooks:{onError:N,onSuccess:C,onStart:M}}},z=n.modules;return z&&Object.keys(z).forEach(H=>{let y=H;if(y.startsWith("use")){let R=y.slice(3);y=R.charAt(0).toLowerCase()+R.slice(1);}H==="useHistory"&&g?Object.keys(g).length>0&&(G[y]=g):H==="useInternalForm"?Object.keys(m).length>0&&(G[y]=m):H==="useSchemaValidators"?Object.keys(_).length>0&&(G[y]=_):G[y]=z[H](t,e);}),J.set(a,G),G}catch(t){throw Error(t)}},Ze=()=>(a,e,n)=>Se(a,e,n),et=a=>{let e=J.get(a);if(e)return e;throw Error("[MeshFlow] Engine ID not found.")},tt=a=>{J.delete(a);},Se=me;export{tt as deleteEngine,et as useEngine,me as useEngineManager,Se as useMeshFlow,Ze as useMeshFlowDefiner,ye as useScheduler};
1
+ var ee=class{computedRules=[];store={OR:(e,n)=>{let t,u,r=this.computedRules;for(let l=0;l<r.length;l++){let s=r[l],o=s.logic(e);if(o instanceof Promise)return (async()=>{let a=await o;if(s.entityId==="__base__"?u=a:a&&(t=a),typeof t>"u")for(let f=l+1;f<r.length;f++){let g=r[f],y=g.logic(e),h=y instanceof Promise?await y:y;if(g.entityId==="__base__"){u=h;continue}if(h){t=g.value;break}}return typeof t>"u"&&(t=u),{res:t,version:n}})();let c=o;if(s.entityId==="__base__"){u=c;continue}if(c){t=s.value;break}}return typeof t>"u"&&(t=u),{res:t,version:n}},PRIORITY:(e,n)=>{let t,u=this.computedRules;for(let r=0;r<u.length;r++){let s=u[r].logic(e);if(s instanceof Promise)return (async()=>{let o=await s;if(o!==void 0)return {res:o,version:n};for(let c=r+1;c<u.length;c++){let a=u[c].logic(e),f=a instanceof Promise?await a:a;if(f!==void 0)return {res:f,version:n}}return {res:void 0,version:n}})();if(s!==void 0)return {res:s,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)}},J=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 u=()=>this.rules;this.strategy=new ee(u),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,u={...e,entityId:t};for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(u);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let l=this.rules.get(r);l&&(l.delete(u),l.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,u={...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(u);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let l=this.rules.get(r);l&&(l.delete(u),l.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 l=this.deps.get(e.triggerPath),s=e.GetValueByPath(e.triggerPath);if(typeof l=="object"||typeof s=="object")t=false;else {let o=Array.from(this.deps.keys());for(let c of o){let a=this.deps.get(c),f=e.GetValueByPath(c);if(a!==f){t=false;break}}}}if(t&&this.useCache)return this.cache;this.promiseToken=n;let u=++this.version,r=this.strategy.evaluate(e,u);if(!(r instanceof Promise)){let{res:l,version:s}=r;return this.finalizeSync(l,s,e,n)}return this.pendingPromise=(async()=>{try{let{res:l,version:s}=await r;return this.finalizeSync(l,s,e,n)}catch(l){throw {path:this.path,error:l}}finally{this.promiseToken===n&&(this.pendingPromise=null,this.promiseToken=null);}})(),this.pendingPromise}finalizeSync(e,n,t,u){return u!==this.promiseToken||n<this.version?this.cache:(this.cache=e,this.deps.forEach((r,l)=>{this.deps.set(l,t.GetValueByPath(l));}),e)}inferType(e){return Array.isArray(e)?"array":typeof e}};var ne=(i,e,n)=>{let u=r=>{let l=n.triggerPaths.map(c=>{let a=r.GetValueByPath(c),f={};return n.triggerKeys.forEach(g=>{f[g]=a[g];}),f}),s=Object.create(null);return Object.defineProperty(s,"triggerTargets",{get:()=>l}),Object.defineProperty(s,"affectedTatget",{get:()=>r.GetRenderSchemaByPath(i)[e]}),n.logic({slot:s})};return {value:n.value,targetPath:i,triggerPaths:n.triggerPaths,priority:n.priority??10,logic:u}},re=(i,e,n)=>{if(!i)throw Error("");let t=i,u=(s,o)=>{e.has(s)||e.set(s,new Set),e.get(s).add(o),n.has(o)||n.set(o,new Set),n.get(o).add(s);};return {SetRule:(s,o,c,a)=>{let f=t(o),g=a.triggerKeys||[];g.length==0&&g.push("value");let y=ne(o,c,{...a,triggerPaths:[s],triggerKeys:g}),h=[s].map(P=>[P,t(P).state.value]);if(u(s,o),f.nodeBucket[c])f.nodeBucket[c].setRule(y,h),a.effect&&f.nodeBucket[c].setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[c]});else {let P=f.meta[c],m=new J(P,c,o);m.setRule(y,h),a.effect&&m.setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[c]}),f.nodeBucket[c]=m;}f.state[c]=f.meta[c],a.forceNotify&&f.nodeBucket[c].forceNotify(),a.cacheStrategy=="none"&&f.nodeBucket[c].setUseCache(false);},SetRules:(s,o,c,a)=>{let f=t(o);for(let P of s)u(P,o);let g=a.triggerKeys||[];g.length==0&&g.push("value");let y=ne(o,c,{...a,triggerPaths:s,triggerKeys:g}),h=s.map(P=>[P,t(P).state.value]);if(f.nodeBucket[c])f.nodeBucket[c].setRules(y,h),a.effect&&f.nodeBucket[c].setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[c]});else {let P=f.meta[c],m=new J(P,c,o);m.setRules(y,h),a.effect&&m.setSideEffect({fn:a.effect,args:a.effectArgs?a.effectArgs:[c]}),f.nodeBucket[c]=m;}f.state[c]=f.meta[c],a.forceNotify&&f.nodeBucket[c].forceNotify(),a.cacheStrategy=="none"&&f.nodeBucket[c].setUseCache(false);}}};var se=i=>{let e=i||void 0;if(!e)throw Error("");return {SetStrategy:(t,u,r)=>{e(t).nodeBucket[u].setStrategy(r);}}};function ae(){let i=new Map,e=new Map,n=new Set,t=(l,s)=>{i.set(l,s);let o=e.get(l);o&&o(s);};return {SetTrace:(l,s)=>{e.set(l,s);let o=i.get(l)||"idle";return s(o),{cancel:()=>{e.delete(l);}}},useTrace:()=>({apply:s=>{s.on("flow:start",()=>{n.forEach(o=>t(o,"idle")),n.clear(),i.clear();}),s.on("node:release",({path:o,type:c})=>{(c==1||c==2)&&(n.add(o),t(o,"pending"));}),s.on("node:pending",({path:o})=>{n.add(o),(!i.has(o)||i.get(o)==="idle")&&t(o,"pending");}),s.on("node:start",({path:o})=>{n.add(o),t(o,"calculating");}),s.on("node:success",({path:o})=>{t(o,"calculated");}),s.on("node:intercept",({path:o,type:c})=>{c==3&&t(o,"calculating"),c==6&&t(o,"idle");}),s.on("node:stagnate",({path:o})=>{t(o,"pending");}),s.on("node:error",({path:o})=>t(o,"error"));}})}}function oe(i,e,n,t){let u=a=>{let f=i(),g=e(),y=new Set;return f.get(a)?.forEach(h=>y.add(h)),y.size===0?[]:Array.from(y).filter(h=>{let P=g.get(h)||new Set;return !Array.from(P).some(S=>y.has(S))})};return {GetNextDependency:a=>{let f=t();return Array.from(f.get(a)||[])},GetPrevDependency:a=>{let f=n();return Array.from(f.get(a)||[])},GetAllPrevDependency:a=>{let f=e();return Array.from(f.get(a)||[])},GetAllNextDependency:a=>{let f=i();return Array.from(f.get(a)||[])},rebuildDirectDependencyMaps:a=>{let f=new Map,g=new Map;for(let y of a){let h=u(y);f.set(y,new Set(h));for(let P of h)g.has(P)||g.set(P,new Set),g.get(P).add(y);}return {directNextMap:f,directPrevMap:g}}}}function ie(i){let e=t=>{let u=[],r=[],l=new Map,s=t.size,o=0,c=0;for(let[a,f]of t)f===0&&r.push(a);if(r.length===0&&s>0)throw Error("Circular dependency detected");for(;r.length>0;){u.push([...r]);let a=[];for(let f of r){o++,l.set(f,c);let g=i.get(f);if(g)for(let y of g){let h=t.get(y)-1;t.set(y,h),h===0&&a.push(y);}}r=a,c++;}if(o<s)throw Error("Circular dependency detected");return {steps:u,levelMap:l}};return ()=>{let t=new Map;for(let u of i.keys()){let r=Array.from(i.get(u)||[]);t.has(u)||t.set(u,0);for(let l of r){let s=t.get(l)||0;t.set(l,++s);}}return e(t)}}var X=()=>{let i=[];return {on:e=>(i.push(e),()=>{let n=i.indexOf(e);n>-1&&i.splice(n,1);}),call:e=>i.forEach(n=>{n(e);})}};function le(){let{on:i,call:e}=X();return {onError:i,callOnError:e}}function ce(){let{on:i,call:e}=X();return {onSuccess:i,callOnSuccess:e}}var ue=()=>{let i=new Set,e=new Map,n=(r,l)=>{e.get(r)?.forEach(s=>s(l));},t=(r,l)=>(e.has(r)||e.set(r,new Set),e.get(r).add(l),()=>e.get(r).delete(l));return {usePlugin:r=>{let l=new Set,s=(o,c)=>{let a=t(o,c);return l.add(a),a};return r.apply({on:s}),i.add(r),()=>{l.forEach(o=>o()),l.clear(),i.delete(r);}},emit:n}};function fe(){let{on:i,call:e}=X();return {onStart:i,callOnStart:e}}var de=(i={frameQuota:12})=>{let e=performance.now(),n=0,t=false,u=()=>!!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>i.frameQuota||u()))},async yieldToMain(){return new Promise(r=>{me(()=>{e=performance.now(),n=0,t&&(t=false),r();});})}}},me=i=>{let{port1:e,port2:n}=new MessageChannel;e.onmessage=i,n.postMessage(null);};function ye(i,e,n,t,u){let r=new Map,l=i.useGreedy,s=de();return async(c,a)=>{let g=Symbol("token"),y=c||"__NOTIFY_ALL__";r.set(y,g);let h=false;s.reset();let P=new Set,m=new Set,z=new Set;a.forEach(G=>{z.add(G),e.GetAllNextDependency(G).forEach(w=>z.add(w));});let S=new Map,K=new Map,E=new Set,B=e.GetPathToLevelMap(),j=0,q=0,d=G=>{e.GetAllNextDependency(G).forEach($=>{let I=B.get($)||0;I>q&&(q=I);});};c?(j=B.get(c)??0,d(c),P.add(c)):a.forEach(G=>d(G)),a.forEach(G=>{E.add(G);});let x=performance.now();t.emit("flow:start",{path:y}),t.callOnStart({path:y});let T=false,O=30,H=G=>{let{target:w,trigger:$}=G,I=false,k=false,U=n.GetNodeByPath(w),W=[],b=(p,M)=>{if(P.has(p)||m.has(p)||E.has(p))return;let _=0,v=B.get(p)??0;if(S.has(p))_=S.get(p)-1;else {if(v>j&&S.size>O){K.has(v)||K.set(v,new Set),K.get(v).add(p),t.emit("node:intercept",{path:p,type:7});return}let C=e.GetPrevDependency(p),F=0;for(let N of C){if(P.has(N))continue;(B.get(N)??0)>j&&F++;}_=F;}if(_<=0){let C=E.has(p),F=m.has(p);if(C||F){t.emit("node:intercept",{path:p,type:F?3:3.1});return}S.delete(p),E.add(p),t.emit("node:release",{path:p,type:M,detail:{path:w}});}else S.set(p,_);},L=(p=[])=>{if(r.get(y)!==g)return;if(p.length){let v={},C=U.proxy;for(let F of p){let N=(F.args||[]).reduce((A,Y)=>(A[Y]=C[Y],A),{});try{let A=F.fn(N);A&&typeof A=="object"&&Object.assign(v,A);}catch(A){}}for(let F in v)if(F in U.state)U.state[F]=v[F];else throw {error:`wrong effect in ${String(U.path)}`};I=true;}I&&u.flushPathSet.add(w),t.emit("node:success",{path:w}),P.add(w);let M=e.GetNextDependency(w);(I||k)&&e.GetAllNextDependency(w).forEach(C=>z.add(C));for(let v of M){if(P.has(v)){t.emit("node:intercept",{path:v,type:2});continue}if(m.has(v)||E.has(v)){t.emit("node:intercept",{path:v,type:m.has(v)?3:3.1});continue}if(I||k)b(v,1);else if(S.has(v))b(v,2);else {let F=B.get(v);K.has(F)||K.set(F,new Set);let N=K.get(F);N.has(v)||(N.add(v),t.emit("node:stagnate",{path:v,type:1}));}}m.delete(w),(async()=>{if(!h){let v=m.size,C=E.size;t.emit("flow:fire",{path:w,type:1,detail:{active:v,pending:C,blocked:S.size}}),D();}})();},V=p=>{t.emit("node:error",{path:w,error:p});let M=Symbol("abort");r.set(y,M),E.clear(),S.clear(),m.clear(),t.callOnError(p);},R=(p,M)=>{let _=false;p!==U.state[M]&&(U.state[M]=p,I=true,t.emit("node:bucket:success",{path:w,key:String(M),value:p}),U.notifyKeys.has(M)&&(_=true)),U.nodeBucket[M].isForceNotify()&&(k=true),(_||k)&&d(w);};t.emit("node:start",{path:w});try{let p=[];for(let M in U.nodeBucket){let _=U.nodeBucket[M];p.push(..._.getSideEffect());let v=_.evaluate({affectKey:M,triggerPath:$,GetRenderSchemaByPath:C=>n.GetNodeByPath(C).proxy,GetValueByPath:C=>n.GetNodeByPath(C).state,GetToken:()=>g});if(v instanceof Promise){let C=v.then(F=>{r.get(y)===g&&R(F,M);});W.push(C);}else R(v,M);}if(W.length>0)return Promise.all(W).then(()=>{L(p);}).catch(V);L(p);return}catch(p){V(p);}},D=async()=>{if(r.get(y)!==g){h=false;return}h=true;let G=s.getIsFirstFrame(),w=0,$=()=>l&&G?30:1/0,I=0,k=$();try{for(;r.get(y)===g;){let U=I>=k,W=s.shouldYield();if(U||W){if(I>0&&(w++,(G||w%2===0)&&u.requestUpdate()),await s.yieldToMain(),r.get(y)!==g)break;I=0,G=s.getIsFirstFrame();}if(E.size>0&&m.size<5){for(let b of E){if(m.size>=5||I>=k)break;let L=B.get(b)??0,V=e.GetPrevDependency(b),R=V.length>1;if((!l||R)&&L>j){E.delete(b);let M=V.filter(_=>z.has(_)&&!P.has(_)).length;S.set(b,M||0),t.emit("node:intercept",{path:b,type:M>0?4:5,detail:{targetLevel:L,currentLevel:j,pendingParentsCount:M}});continue}if(E.delete(b),m.add(b),t.emit("node:processing",{path:b}),H({target:b,trigger:c}),I++,I>=k||s.shouldYield())break}if(E.size>0)continue}if(I<k&&l&&S.size>0&&m.size<5){let b=!1,L=0;for(let[V,R]of S)if(R<=0){let p=B.get(V)??0,M=e.GetPrevDependency(V);if(p>j&&M.length>1)continue;if(S.delete(V),E.add(V),L++,b=!0,t.emit("node:release",{path:V,type:4}),L>=k)break}if(L>0)continue;if(b){if(s.shouldYield()&&(await s.yieldToMain(),r.get(y)!==g))break;continue}}if(m.size===0&&E.size===0){let b=new Set;for(let R of K.keys())b.add(R);for(let[R]of S){let p=B.get(R)??0;p>j&&b.add(p);}let L=Array.from(b).sort((R,p)=>R-p),V=L[0];if(L.length>0&&V<=q){let R=L[0];if(R<=q){j=R;let p=K.get(R);p&&(p.forEach(M=>E.add(M)),K.delete(R));for(let[M]of S)(B.get(M)??0)===R&&(S.delete(M),E.add(M),t.emit("node:release",{path:M,type:3,detail:{level:R}}));continue}}else {K.forEach((R,p)=>{R.forEach(M=>{P.add(M),t.emit("node:intercept",{path:M,type:6});});}),K.clear();for(let[R]of S)P.add(R),t.emit("node:intercept",{path:R,type:6});S.clear();break}}E.size>0&&m.size>=5&&t.emit("flow:wait",{type:2});break}}finally{if(h=false,m.size+S.size+E.size===0){if(r.get(y)===g&&!T){T=true,t.emit("flow:end",{type:1}),u.requestUpdate();let W=performance.now();t.emit("flow:success",{duration:(W-x).toFixed(2)+"ms"}),Promise.resolve().then(()=>{t.callOnSuccess();});}}else t.emit("flow:wait",{type:1,detail:{nums:m.size}});}};D();}}function te(i){let{path:e,uid:n,type:t,meta:u,dirtySignal:r,triggerUI:l,state:s}=i,o=null,a={path:e,uid:n,type:t,meta:u,dirtySignal:r,createView:(f={})=>{let g=new Proxy(f,{get(y,h){let P=h;return P in i.state?i.state[P]:P in i?i[P]:u&&P in u?u[P]:Reflect.get(y,h)},set(y,h,P){let m=h;return m in i.state?(i.state[m]=P,true):Reflect.set(y,h,P)},ownKeys(y){let h=new Set([...Reflect.ownKeys(y),...Object.keys(s||{}),...Object.keys(u||{})]);return Array.from(h)},getOwnPropertyDescriptor(y,h){return s&&h in s||u&&h in u?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(y,h)}});return o=g,g}};return "children"in i?{...a,children:i.children}:{...a,state:i.state,nodeBucket:i.nodeBucket,notifyKeys:i.notifyKeys,dependOn:i.dependOn,get proxy(){return o}}}function pe(i,e,n,t,u){let r=0,l=new Map,s=new Map,o=new Map,c=false,a=new Set,g=async()=>{let d=Array.from(a);a.clear();for(let x of d){let T=S(x);u.signalTrigger(T.dirtySignal);}},y=()=>{c||(c=true,requestAnimationFrame(()=>{try{for(;a.size>0;)g();}finally{c=false;}}));},h=ye({useGreedy:i.useGreedy},e,{GetNodeByPath:S},t,{requestUpdate:y,flushPathSet:a}),P=d=>{throw new Error(`[MeshFlow] Duplicate Path: ${d}`)},m=d=>{l.has(d.path)&&P(String(d.path));let x=++r,T={path:d.path,getNode:D=>S(D)},O=(D,G="value")=>{let w=D({...T}),$=S(d.path);if(n.createHistoryAction&&n.pushIntoHistory){let I=n.createHistoryAction([{path:d.path,value:$.state[G]},{path:d.path,value:w}],k=>{let U=S(k.path);U.state[G]=k.value,E(k.path);});n.pushIntoHistory(I);}$.state[G]=w,E(d.path);};d.notifyKeys.size==0&&d.notifyKeys.add("value");let H=te({uid:x,path:d.path,state:d.state,meta:d.meta,nodeBucket:d.nodeBucket,dirtySignal:d.dirtySignal,notifyKeys:d.notifyKeys,dependOn:O});return l.set(H.path,x),s.set(x,H),H},z=d=>{l.has(d.path)&&P(String(d.path));let x=++r,T=te({uid:x,path:d.path,state:{},meta:d,nodeBucket:{},children:d.children});return l.set(T.path,x),o.set(x,T),T};function S(d){let x=l.get(d),T=s.get(x);if(!T)throw Error("wrong ID");return T}function K(d){let x=l.get(d);return o.get(x)}let E=d=>{if(!S(d))throw Error("Node undefined");a.add(d),y();let T=e.GetNextDependency(d);B(T,d);};function B(d,x){h(x,d);}return {registerNode:m,registerGroupNode:z,GetNodeByPath:S,GetGroupByPath:K,notify:E,notifyAll:async()=>{Promise.resolve().then(async()=>{let d=e.GetDependencyOrder();if(!d||d.length===0)return;let x=d[0];try{h(null,x);}catch(T){throw t.callOnError(T),T}finally{y();}});},batchNotify:d=>{if(!d||d.length===0)return;if(n.createHistoryAction&&n.pushIntoHistory){let T=n.createHistoryAction([d.map(O=>({path:O.path,key:O.key,value:S(O.path).state[O.key]})),d.map(O=>({path:O.path,key:O.key,value:O.value}))],O=>{let H=new Set;O.forEach(D=>{let G=S(D.path);G.state[D.key]=D.value,a.add(D.path),H.add(D.path);}),y(),H.size>0&&h(null,Array.from(H));});n.pushIntoHistory(T);}let x=new Set;d.forEach(T=>{let O=S(T.path);O.state[T.key]=T.value,a.add(T.path),x.add(T.path);}),y(),x.size>0&&h(null,Array.from(x));},UITrigger:u,UidToNodeMap:s}}function he(i,e){let n=false,t=false,u=new Map,r=new Map,l=new Map,s=new Map,o=[],c=new Map,{GetNextDependency:f,GetPrevDependency:g,GetAllPrevDependency:y,GetAllNextDependency:h,rebuildDirectDependencyMaps:P}=oe(()=>u,()=>r,()=>s,()=>l),m={},z={};if(e.modules.useHistory){let{Undo:N,Redo:A,PushIntoHistory:Y,CreateHistoryAction:Q,initCanUndo:ge,initCanRedo:Pe}=e.modules.useHistory();m.pushIntoHistory=Y,m.createHistoryAction=Q,z={Undo:N,Redo:A,initCanUndo:ge,initCanRedo:Pe};}let{onError:S,callOnError:K}=le(),{onSuccess:E,callOnSuccess:B}=ce(),{onStart:j,callOnStart:q}=fe(),{emit:d,usePlugin:x}=ue(),{SetTrace:T,useTrace:O}=ae(),H=O();x(H);let D=pe({useGreedy:e.config.useGreedy},{GetDependencyOrder:()=>o,GetAllNextDependency:h,GetNextDependency:f,GetPrevDependency:g,GetAllPrevDependency:y,GetPathToLevelMap:()=>c},m,{callOnError:K,callOnSuccess:B,callOnStart:q,emit:d},e.UITrigger),{GetGroupByPath:G,GetNodeByPath:w,notifyAll:$}=D,I={};if(e.modules.useInternalForm){let{uiSchema:N,GetFormData:A}=e.modules.useInternalForm(D,i);I={uiSchema:N,GetFormData:A};}let k={};if(e.modules.useSchemaValidators){let{SetValidators:N}=e.modules.useSchemaValidators(w);k={SetValidators:N};}let{SetRule:U,SetRules:W}=re(w,u,r),{SetStrategy:b}=se(w),L=ie(u),V=()=>{let N=L();o=N.steps,c=N.levelMap;},R=()=>{t||(t=true,Promise.resolve().then(()=>{if(V(),n){let{directNextMap:N,directPrevMap:A}=P(o.flat());l=N,s=A;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(N,A,Y,Q)=>{U(N,A,Y,Q),n=true,R();},SetRules:(N,A,Y,Q)=>{W(N,A,Y,Q),n=true,R();},SetStrategy:b,SetTrace:T,usePlugin:x,SetValue:(N,A,Y)=>{w(N).dependOn(()=>Y,A);},GetValue:(N,A="value")=>w(N)[A],SetValues:N=>{D.batchNotify(N);},GetGroupByPath:G,notifyAll:async()=>{V(),await $();},GetAllDependency:()=>u,GetDependencyOrder:()=>o,historyExports:z,formExports:I,validatorExports:k,onError:S,onSuccess:E,onStart:j,scheduler:D}}var Z=new Map,Se=(i,e,n)=>{try{if(typeof n.UITrigger.signalCreator!="function"||typeof n.UITrigger.signalTrigger!="function")throw Error("ui trigger undefined");if(Z.has(i))throw Error("engineID repeated");let t=he(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules||{},plugins:{}}),{SetRule:u,SetRules:r,SetValues:l,SetStrategy:s,SetValue:o,GetValue:c,usePlugin:a,GetGroupByPath:f,notifyAll:g,SetTrace:y,GetAllDependency:h,GetDependencyOrder:P,historyExports:m,formExports:z,validatorExports:S,onError:K,onSuccess:E,onStart:B,scheduler:j}=t,d={...{config:{SetRule:u,SetRules:r,SetStrategy:s,notifyAll:g,SetTrace:y,usePlugin:a},data:{SetValue:o,GetValue:c,SetValues:l,GetGroupByPath:f},dependency:{GetAllDependency:h,GetDependencyOrder:P},hooks:{onError:K,onSuccess:E,onStart:B}}},x=n.modules;return x&&Object.keys(x).forEach(T=>{let O=T;if(O.startsWith("use")){let H=O.slice(3);O=H.charAt(0).toLowerCase()+H.slice(1);}T==="useHistory"&&m?Object.keys(m).length>0&&(d[O]=m):T==="useInternalForm"?Object.keys(z).length>0&&(d[O]=z):T==="useSchemaValidators"?Object.keys(S).length>0&&(d[O]=S):d[O]=x[T](j,e);}),Z.set(i,d),d}catch(t){throw Error(t)}},et=()=>(i,e,n)=>Te(i,e,n),tt=i=>{let e=Z.get(i);if(e)return e;throw Error("[MeshFlow] Engine ID not found.")},nt=i=>{Z.delete(i);},Te=Se;export{nt as deleteEngine,tt as useEngine,Se as useEngineManager,Te as useMeshFlow,et as useMeshFlowDefiner,pe as useScheduler};
package/metafile-cjs.json CHANGED
@@ -1 +1 @@
1
- {"inputs":{"utils/core/engine/bucket.ts":{"bytes":16717,"imports":[],"format":"esm"},"utils/core/dependency/useSetRule.ts":{"bytes":7355,"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":4260,"imports":[],"format":"esm"},"utils/core/dependency/useDepenency.ts":{"bytes":6109,"imports":[],"format":"esm"},"utils/core/hooks/useCreateHook.ts":{"bytes":437,"imports":[],"format":"esm"},"utils/core/hooks/useOnError.ts":{"bytes":507,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"}],"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":1793,"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":6422,"imports":[],"format":"esm"},"utils/core/engine/useMeshTask.ts":{"bytes":35454,"imports":[{"path":"utils/core/utils/util.ts","kind":"import-statement","original":"../utils/util"},{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useMeshNode.ts":{"bytes":3242,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useScheduler.ts":{"bytes":10412,"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"}],"format":"esm"},"utils/core/engine/useEngineInstance.ts":{"bytes":10024,"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":8299,"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/engine/useScheduler.ts","kind":"import-statement","original":"../engine/useScheduler"}],"format":"esm"}},"outputs":{"lib-dist/index.js":{"imports":[],"exports":["deleteEngine","useEngine","useEngineManager","useMeshFlow","useMeshFlowDefiner","useScheduler"],"entryPoint":"utils/core/engine/useEngineManager.ts","inputs":{"utils/core/engine/bucket.ts":{"bytesInOutput":4168},"utils/core/dependency/useSetRule.ts":{"bytesInOutput":1479},"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":121},"utils/core/hooks/useOnError.ts":{"bytesInOutput":67},"utils/core/hooks/useOnSuccess.ts":{"bytesInOutput":71},"utils/core/plugins/usePlugin.ts":{"bytesInOutput":316},"utils/core/hooks/useOnStart.ts":{"bytesInOutput":67},"utils/core/utils/util.ts":{"bytesInOutput":472},"utils/core/engine/useMeshTask.ts":{"bytesInOutput":4827},"utils/core/engine/useMeshNode.ts":{"bytesInOutput":764},"utils/core/engine/useScheduler.ts":{"bytesInOutput":1750},"utils/core/engine/useEngineInstance.ts":{"bytesInOutput":1816},"utils/core/engine/useEngineManager.ts":{"bytesInOutput":1268}},"bytes":19434}}}
1
+ {"inputs":{"utils/core/engine/bucket.ts":{"bytes":16822,"imports":[],"format":"esm"},"utils/core/dependency/useSetRule.ts":{"bytes":7991,"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":437,"imports":[],"format":"esm"},"utils/core/hooks/useOnError.ts":{"bytes":507,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"}],"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":1793,"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/engine/useMeshTask.ts":{"bytes":35494,"imports":[{"path":"utils/core/utils/util.ts","kind":"import-statement","original":"../utils/util"},{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useMeshNode.ts":{"bytes":3248,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useScheduler.ts":{"bytes":13342,"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/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useEngineInstance.ts":{"bytes":9032,"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":8441,"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/engine/useScheduler.ts","kind":"import-statement","original":"../engine/useScheduler"}],"format":"esm"}},"outputs":{"lib-dist/index.js":{"imports":[],"exports":["deleteEngine","useEngine","useEngineManager","useMeshFlow","useMeshFlowDefiner","useScheduler"],"entryPoint":"utils/core/engine/useEngineManager.ts","inputs":{"utils/core/engine/bucket.ts":{"bytesInOutput":4228},"utils/core/dependency/useSetRule.ts":{"bytesInOutput":1745},"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":121},"utils/core/hooks/useOnError.ts":{"bytesInOutput":67},"utils/core/hooks/useOnSuccess.ts":{"bytesInOutput":71},"utils/core/plugins/usePlugin.ts":{"bytesInOutput":316},"utils/core/hooks/useOnStart.ts":{"bytesInOutput":67},"utils/core/utils/util.ts":{"bytesInOutput":472},"utils/core/engine/useMeshTask.ts":{"bytesInOutput":4827},"utils/core/engine/useMeshNode.ts":{"bytesInOutput":764},"utils/core/engine/useScheduler.ts":{"bytesInOutput":2228},"utils/core/engine/useEngineInstance.ts":{"bytesInOutput":1860},"utils/core/engine/useEngineManager.ts":{"bytesInOutput":1304}},"bytes":20318}}}
package/metafile-esm.json CHANGED
@@ -1 +1 @@
1
- {"inputs":{"utils/core/engine/bucket.ts":{"bytes":16717,"imports":[],"format":"esm"},"utils/core/dependency/useSetRule.ts":{"bytes":7355,"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":4260,"imports":[],"format":"esm"},"utils/core/dependency/useDepenency.ts":{"bytes":6109,"imports":[],"format":"esm"},"utils/core/hooks/useCreateHook.ts":{"bytes":437,"imports":[],"format":"esm"},"utils/core/hooks/useOnError.ts":{"bytes":507,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"}],"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":1793,"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":6422,"imports":[],"format":"esm"},"utils/core/engine/useMeshTask.ts":{"bytes":35454,"imports":[{"path":"utils/core/utils/util.ts","kind":"import-statement","original":"../utils/util"},{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useMeshNode.ts":{"bytes":3242,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useScheduler.ts":{"bytes":10412,"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"}],"format":"esm"},"utils/core/engine/useEngineInstance.ts":{"bytes":10024,"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":8299,"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/engine/useScheduler.ts","kind":"import-statement","original":"../engine/useScheduler"}],"format":"esm"}},"outputs":{"lib-dist/index.mjs":{"imports":[],"exports":["deleteEngine","useEngine","useEngineManager","useMeshFlow","useMeshFlowDefiner","useScheduler"],"entryPoint":"utils/core/engine/useEngineManager.ts","inputs":{"utils/core/engine/bucket.ts":{"bytesInOutput":4168},"utils/core/dependency/useSetRule.ts":{"bytesInOutput":1479},"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":121},"utils/core/hooks/useOnError.ts":{"bytesInOutput":67},"utils/core/hooks/useOnSuccess.ts":{"bytesInOutput":71},"utils/core/plugins/usePlugin.ts":{"bytesInOutput":316},"utils/core/hooks/useOnStart.ts":{"bytesInOutput":67},"utils/core/utils/util.ts":{"bytesInOutput":472},"utils/core/engine/useMeshTask.ts":{"bytesInOutput":4827},"utils/core/engine/useMeshNode.ts":{"bytesInOutput":764},"utils/core/engine/useScheduler.ts":{"bytesInOutput":1750},"utils/core/engine/useEngineInstance.ts":{"bytesInOutput":1816},"utils/core/engine/useEngineManager.ts":{"bytesInOutput":1268}},"bytes":19434}}}
1
+ {"inputs":{"utils/core/engine/bucket.ts":{"bytes":16822,"imports":[],"format":"esm"},"utils/core/dependency/useSetRule.ts":{"bytes":7991,"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":437,"imports":[],"format":"esm"},"utils/core/hooks/useOnError.ts":{"bytes":507,"imports":[{"path":"utils/core/hooks/useCreateHook.ts","kind":"import-statement","original":"./useCreateHook"}],"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":1793,"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/engine/useMeshTask.ts":{"bytes":35494,"imports":[{"path":"utils/core/utils/util.ts","kind":"import-statement","original":"../utils/util"},{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useMeshNode.ts":{"bytes":3248,"imports":[{"path":"../types/types","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useScheduler.ts":{"bytes":13342,"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/util","kind":"import-statement","external":true}],"format":"esm"},"utils/core/engine/useEngineInstance.ts":{"bytes":9032,"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":8441,"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/engine/useScheduler.ts","kind":"import-statement","original":"../engine/useScheduler"}],"format":"esm"}},"outputs":{"lib-dist/index.mjs":{"imports":[],"exports":["deleteEngine","useEngine","useEngineManager","useMeshFlow","useMeshFlowDefiner","useScheduler"],"entryPoint":"utils/core/engine/useEngineManager.ts","inputs":{"utils/core/engine/bucket.ts":{"bytesInOutput":4228},"utils/core/dependency/useSetRule.ts":{"bytesInOutput":1745},"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":121},"utils/core/hooks/useOnError.ts":{"bytesInOutput":67},"utils/core/hooks/useOnSuccess.ts":{"bytesInOutput":71},"utils/core/plugins/usePlugin.ts":{"bytesInOutput":316},"utils/core/hooks/useOnStart.ts":{"bytesInOutput":67},"utils/core/utils/util.ts":{"bytesInOutput":472},"utils/core/engine/useMeshTask.ts":{"bytesInOutput":4827},"utils/core/engine/useMeshNode.ts":{"bytesInOutput":764},"utils/core/engine/useScheduler.ts":{"bytesInOutput":2228},"utils/core/engine/useEngineInstance.ts":{"bytesInOutput":1860},"utils/core/engine/useEngineManager.ts":{"bytesInOutput":1304}},"bytes":20318}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshflow/core",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
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",