@meshflow/core 0.2.6 → 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/README.md +25 -81
- package/index.d.mts +143 -63
- package/index.d.ts +143 -63
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/metafile-cjs.json +1 -0
- package/metafile-esm.json +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,96 +5,40 @@
|
|
|
5
5
|
[](https://meshflow-docs.vercel.app/)
|
|
6
6
|
[](https://meshflow-factory-demo.vercel.app/)
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## 🏗️ 引擎定位
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
`@meshflow/core` 不预设任何业务场景。它是一个纯粹的**逻辑计算骨架**,负责管理节点(TaskNode)之间的拓扑依赖关系。
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
它只做三件事:
|
|
13
|
+
1. **构建拓扑图**:通过 Schema 定义节点及其层级。
|
|
14
|
+
2. **编排任务流**:管理节点间的联动规则(Rule)。
|
|
15
|
+
3. **确定性执行**:利用水位线(Watermark)机制,确保异步任务在复杂的依赖网中,依然能按正确的顺序提交。
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🎯 核心能力
|
|
19
20
|
|
|
21
|
+
### 1. 任务依赖编排 (Topology)
|
|
22
|
+
引擎会自动解析节点间的依赖关系(A -> B, C -> D)。当上游节点变化时,下游节点会根据拓扑层级进行原子化更新,完美解决“循环计算”和“重复触发”问题。
|
|
20
23
|
|
|
24
|
+
### 2. 异步水位线调度 (Watermark)
|
|
25
|
+
在异步任务流中,由于网络波动,旧的任务可能比新的任务更晚返回。引擎通过内置的水位线令牌,确保只有最新的任务结果会被采纳,彻底杜绝异步竞态导致的数据覆盖风险。
|
|
21
26
|
|
|
22
|
-
### 3.
|
|
23
|
-
|
|
24
|
-
* **方案**:将联动关系声明为“逻辑节点”。你只需关心数据流向,环检测和执行顺序交给引擎。
|
|
27
|
+
### 3. 计算路径剪枝 (Pruning)
|
|
28
|
+
引擎会自动比对节点的值(Value Check)。如果某个节点的计算结果与之前一致,引擎将自动截断该路径的后续传播,实现极致的性能优化,支持 500+ 节点的实时复杂联动。
|
|
25
29
|
|
|
26
30
|
---
|
|
27
31
|
|
|
28
|
-
## ✨
|
|
32
|
+
## ✨ 特性
|
|
33
|
+
|
|
34
|
+
- **🏗️ 纯粹 Headless**:无 UI 绑定,适配 Vue/React/Solid 或 Node.js 环境。
|
|
35
|
+
- **⚡ 极致类型推导**:提供完整的路径感知能力,支持超大规模 Schema 的深度类型检查。
|
|
36
|
+
- **🧩 开放式模块系统**:通过 `modules` 注入,你可以轻松给引擎套上“表单”、“动画”或“工作流”的壳子。
|
|
37
|
+
- **🚨 循环依赖检测**:在规则注册阶段即进行环检测,防止逻辑死循环。
|
|
38
|
+
- **📦 极简体积**:产物仅 **~19KB**,零第三方依赖。
|
|
29
39
|
|
|
30
|
-
* **🌊 水位线调度**:引入逻辑水位线机制,确保异步节点严格按序提交,彻底杜绝“旧数据覆盖新数据”的经典异步难题。
|
|
31
|
-
* **🏗️ 层级拓扑引擎**:基于 **Kahn 算法** 实现,自动计算节点深度等级,支持同层级节点并发执行。
|
|
32
|
-
* **⚡ 惰性求值与记忆化**:引入“桶计算”缓存机制,在拓扑传播过程中自动比对输入特征,仅在依赖项发生实质性变更时才触发逻辑重算。
|
|
33
|
-
* **⚡ 变更剪枝**:即使节点处于受影响路径上,若输入状态未通过有效性检查,引擎将自动截断该路径的后续传播,实现真正的计算最小化。
|
|
34
|
-
* **🚨 循环依赖检测**:在节点定义阶段实时进行 $O(V+E)$ 的环检测,提前发现逻辑死循环。
|
|
35
|
-
* **📦 极简轻量**:零依赖,体积仅 ~8kB(zipped),适配任何 JavaScript 运行时。
|
|
36
|
-
* **🔌 插件化架构 (New)**:支持生命周期拦截与监听(如官方调试插件 `@meshflow/logger`)。
|
|
37
40
|
---
|
|
38
|
-
|
|
39
|
-
## 🚀 快速上手
|
|
40
|
-
|
|
41
|
-
#### 安装
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npm install @meshflow/core
|
|
45
|
-
```
|
|
46
|
-
#### 初始化引擎
|
|
47
|
-
```typescript
|
|
48
|
-
import { useMeshFlow } from "@meshflow/core";
|
|
49
|
-
const schema = {
|
|
50
|
-
type: 'group',
|
|
51
|
-
name: 'billing',
|
|
52
|
-
label: '计费与汇总',
|
|
53
|
-
children: [
|
|
54
|
-
{ type: 'number', name: 'totalPrice', label: '预估月度总价', value: 0, },
|
|
55
|
-
{ type: 'input', name: 'priceDetail', label: '计费项说明', value: '基础配置费用'}
|
|
56
|
-
]
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const engine = useMeshFlow<Ref<number,number>,AllPath>('main',schema, {
|
|
60
|
-
// config:{
|
|
61
|
-
// useGreedy:true
|
|
62
|
-
// },
|
|
63
|
-
UITrigger:{//以vue为例
|
|
64
|
-
signalCreator: () => ref(0),
|
|
65
|
-
signalTrigger(signal) {
|
|
66
|
-
signal.value++;
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
```
|
|
71
|
-
#### 添加联动依赖
|
|
72
|
-
```typescript
|
|
73
|
-
//声明联动规则:当总价 > 2000 时,自动修改描述与主题
|
|
74
|
-
engine.config.SetRule("billing.totalPrice", "billing.priceDetail", "value", {
|
|
75
|
-
logic: ({ slot }) => {
|
|
76
|
-
const [total] = slot.triggerTargets; // 从触发目标中解构出 totalPrice
|
|
77
|
-
return total > 2000 ? "大客户折扣" : undefined;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
engine.config.SetRule( "billing.totalPrice", "billing.priceDetail", "theme", {
|
|
81
|
-
logic: (api) => {
|
|
82
|
-
const [value] = api.slot.triggerTargets;
|
|
83
|
-
return total > 2000 ? "warning" : undefined;
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
//触发首屏计算
|
|
87
|
-
engine.config.notifyAll();
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## 🛠️ 为什么选择 MeshFlow?
|
|
91
|
-
|
|
92
|
-
在传统的事件驱动开发中,当 A 变化触发 B 和 C,而 B 和 C 又共同触发 D 时(**钻石依赖**),D 往往会被重复触发,且异步回填的顺序无法保证。
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
`@meshflow/core` 通过内部的 **DAG(有向无环图)** 和 **Watermark** 机制,确保:
|
|
97
|
-
|
|
98
|
-
* **确定性**:无论异步耗时多久,最终状态始终保持一致。
|
|
99
|
-
* **原子性**:一次输入变化,仅触发一次拓扑链路的完整更新。
|
|
100
41
|
|
|
42
|
+
## 🚀 核心概念演示
|
|
43
|
+
|
|
44
|
+
* **[数据表单场景]** 👉 使用 [**@meshflow/form**](https://www.npmjs.com/package/@meshflow/form) (基于 Core 封装的专业表单逻辑层)。
|
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
|
|
59
|
-
|
|
65
|
+
interface BaseMeshEvents {
|
|
66
|
+
"flow:start": {
|
|
60
67
|
path: MeshPath;
|
|
61
68
|
};
|
|
62
|
-
|
|
69
|
+
"node:start": {
|
|
63
70
|
path: MeshPath;
|
|
64
71
|
};
|
|
65
|
-
|
|
72
|
+
"node:success": {
|
|
66
73
|
path: MeshPath;
|
|
67
|
-
key: string;
|
|
68
|
-
value: any;
|
|
69
74
|
};
|
|
70
|
-
|
|
75
|
+
"node:error": {
|
|
71
76
|
path: MeshPath;
|
|
72
77
|
error: any;
|
|
73
78
|
};
|
|
74
|
-
|
|
79
|
+
"node:intercept": {
|
|
75
80
|
path: MeshPath;
|
|
76
81
|
type: number;
|
|
77
82
|
detail?: any;
|
|
78
83
|
};
|
|
79
|
-
|
|
84
|
+
"node:release": {
|
|
80
85
|
path: MeshPath;
|
|
81
86
|
type: number;
|
|
82
87
|
detail?: any;
|
|
83
88
|
};
|
|
84
|
-
|
|
89
|
+
"node:stagnate": {
|
|
85
90
|
path: MeshPath;
|
|
86
91
|
type: number;
|
|
87
92
|
};
|
|
88
|
-
|
|
93
|
+
"node:processing": {
|
|
94
|
+
path: MeshPath;
|
|
95
|
+
};
|
|
96
|
+
"node:pending": {
|
|
89
97
|
path: MeshPath;
|
|
90
98
|
};
|
|
91
|
-
|
|
99
|
+
"flow:wait": {
|
|
92
100
|
type: number;
|
|
93
101
|
detail?: any;
|
|
94
102
|
};
|
|
95
|
-
|
|
103
|
+
"flow:fire": {
|
|
96
104
|
path: MeshPath;
|
|
97
105
|
type: number;
|
|
98
106
|
detail?: any;
|
|
99
107
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
'flow:success': {
|
|
108
|
+
}
|
|
109
|
+
interface MeshEvents extends BaseMeshEvents {
|
|
110
|
+
"flow:success": {
|
|
104
111
|
duration: string;
|
|
105
112
|
};
|
|
106
|
-
|
|
113
|
+
"flow:end": {
|
|
107
114
|
type: number;
|
|
108
115
|
};
|
|
109
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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,45 +145,42 @@ type MeshFlowHistory = {
|
|
|
139
145
|
interface MeshFlowEngineMap {
|
|
140
146
|
}
|
|
141
147
|
type MeshPath = string | number | symbol;
|
|
142
|
-
interface
|
|
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
|
-
state:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
nodeBucket: Record<keyof S, MeshBucket<P>>;
|
|
154
|
-
notifyKeys: Set<keyof S>;
|
|
152
|
+
state: V;
|
|
153
|
+
nodeBucket: Record<keyof NM, SchemaBucket<P>>;
|
|
154
|
+
notifyKeys: Set<keyof NM>;
|
|
155
155
|
dirtySignal: any;
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
proxy: any;
|
|
157
|
+
meta: NM;
|
|
158
|
+
dependOn: (cb: (val: V) => V, key?: keyof NM) => void;
|
|
158
159
|
createView: (extraProps?: Record<string, any>) => any;
|
|
159
160
|
}
|
|
160
161
|
interface MeshFlowGroupNode<P extends MeshPath = MeshPath> {
|
|
161
162
|
path: P;
|
|
162
163
|
uid: number;
|
|
163
|
-
type:
|
|
164
|
+
type: "group";
|
|
164
165
|
children: Array<P>;
|
|
165
166
|
dirtySignal: any;
|
|
166
167
|
meta: Record<string, any>;
|
|
167
168
|
}
|
|
168
|
-
interface logicApi {
|
|
169
|
+
interface logicApi<NM, TKeys extends KeysOfUnion<NM>> {
|
|
169
170
|
slot: {
|
|
170
|
-
triggerTargets: any
|
|
171
|
+
triggerTargets: Array<Record<TKeys, any>>;
|
|
171
172
|
affectedTatget: any;
|
|
172
173
|
};
|
|
173
174
|
}
|
|
174
|
-
interface SetRuleOptions<NM
|
|
175
|
+
interface SetRuleOptions<NM, TKeys extends KeysOfUnion<NM>> {
|
|
175
176
|
value?: any;
|
|
176
177
|
priority?: number;
|
|
177
178
|
forceNotify?: boolean;
|
|
178
|
-
logic: (api: logicApi) => any;
|
|
179
|
+
logic: (api: logicApi<NM, TKeys>) => any;
|
|
179
180
|
effect?: (args: any) => any;
|
|
180
181
|
effectArgs?: Array<KeysOfUnion<NM>>;
|
|
182
|
+
cacheStrategy?: "none" | "shallow";
|
|
183
|
+
triggerKeys?: TKeys[];
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
/**
|
|
@@ -206,8 +209,8 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
|
|
|
206
209
|
};
|
|
207
210
|
plugins: {};
|
|
208
211
|
}): {
|
|
209
|
-
SetRule: <
|
|
210
|
-
SetRules: <
|
|
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;
|
|
211
214
|
SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
|
|
212
215
|
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
|
|
213
216
|
cancel: () => void;
|
|
@@ -217,8 +220,13 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
|
|
|
217
220
|
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
218
221
|
}) => void;
|
|
219
222
|
}) => () => void;
|
|
220
|
-
SetValue: (path: P, value: any) => void;
|
|
223
|
+
SetValue: (path: P, key: KeysOfUnion<NM> | (string & {}), value: any) => void;
|
|
221
224
|
GetValue: (path: P, key?: string) => any;
|
|
225
|
+
SetValues: (updates: {
|
|
226
|
+
path: P;
|
|
227
|
+
key: KeysOfUnion<NM> | (string & {});
|
|
228
|
+
value: any;
|
|
229
|
+
}[]) => void;
|
|
222
230
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
|
|
223
231
|
notifyAll: () => Promise<void>;
|
|
224
232
|
GetAllDependency: () => Map<P, Set<P>>;
|
|
@@ -236,11 +244,29 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
|
|
|
236
244
|
onStart: (cb: (data: {
|
|
237
245
|
path: P;
|
|
238
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
|
+
};
|
|
239
265
|
};
|
|
240
266
|
|
|
241
267
|
declare function useScheduler<T, //ui trigger中定义的类型
|
|
242
268
|
P extends MeshPath, // 路径类型
|
|
243
|
-
|
|
269
|
+
NM = any>(config: {
|
|
244
270
|
useGreedy: boolean;
|
|
245
271
|
}, dependency: {
|
|
246
272
|
GetDependencyOrder: () => P[][];
|
|
@@ -261,17 +287,22 @@ S = any>(schema: S, config: {
|
|
|
261
287
|
signalCreator: () => T;
|
|
262
288
|
signalTrigger: (signal: T) => void;
|
|
263
289
|
}): {
|
|
264
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView">) => MeshFlowTaskNode<P, any,
|
|
290
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
|
|
265
291
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
|
|
266
|
-
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any,
|
|
292
|
+
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
267
293
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
|
|
268
294
|
notify: (path: P) => void;
|
|
269
295
|
notifyAll: () => Promise<void>;
|
|
296
|
+
batchNotify: (updates: {
|
|
297
|
+
path: P;
|
|
298
|
+
key: KeysOfUnion<NM> | (string & {});
|
|
299
|
+
value: any;
|
|
300
|
+
}[]) => void;
|
|
270
301
|
UITrigger: {
|
|
271
302
|
signalCreator: () => T;
|
|
272
303
|
signalTrigger: (signal: T) => void;
|
|
273
304
|
};
|
|
274
|
-
UidToNodeMap: Map<number, MeshFlowTaskNode<P, any,
|
|
305
|
+
UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
|
|
275
306
|
};
|
|
276
307
|
|
|
277
308
|
type SchedulerType<T, P extends MeshPath, S, NM> = ReturnType<typeof useEngineInstance<T, P, S, NM>>;
|
|
@@ -283,6 +314,9 @@ type BaseEngine<T> = {
|
|
|
283
314
|
GetValue: T extends {
|
|
284
315
|
GetValue: infer F;
|
|
285
316
|
} ? F : never;
|
|
317
|
+
SetValues: T extends {
|
|
318
|
+
SetValues: infer F;
|
|
319
|
+
} ? F : never;
|
|
286
320
|
GetGroupByPath: T extends {
|
|
287
321
|
GetGroupByPath: infer F;
|
|
288
322
|
} ? F : never;
|
|
@@ -339,8 +373,8 @@ type EngineModules<M, P extends MeshPath> = {
|
|
|
339
373
|
};
|
|
340
374
|
type Engine<T, M, P extends MeshPath> = BaseEngine<T> & EngineModules<M, P>;
|
|
341
375
|
/** @deprecated 请使用新的 useMeshFlow 别名 */
|
|
342
|
-
declare const useEngineManager: <const S extends Record<string, any
|
|
343
|
-
M extends Record<string, any>, NM extends Record<string, any
|
|
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: {
|
|
344
378
|
metaType?: NM;
|
|
345
379
|
config?: {
|
|
346
380
|
useGreedy: boolean;
|
|
@@ -351,8 +385,8 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
|
|
|
351
385
|
signalTrigger: (signal: T) => void;
|
|
352
386
|
};
|
|
353
387
|
}) => Engine<{
|
|
354
|
-
SetRule: <
|
|
355
|
-
SetRules: <
|
|
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;
|
|
356
390
|
SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
|
|
357
391
|
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
|
|
358
392
|
cancel: () => void;
|
|
@@ -362,8 +396,13 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
|
|
|
362
396
|
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
363
397
|
}) => void;
|
|
364
398
|
}) => () => void;
|
|
365
|
-
SetValue: (path: P, value: any) => void;
|
|
399
|
+
SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
|
|
366
400
|
GetValue: (path: P, key?: string) => any;
|
|
401
|
+
SetValues: (updates: {
|
|
402
|
+
path: P;
|
|
403
|
+
key: (string & {}) | KeysOfUnion<NM>;
|
|
404
|
+
value: any;
|
|
405
|
+
}[]) => void;
|
|
367
406
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
|
|
368
407
|
notifyAll: () => Promise<void>;
|
|
369
408
|
GetAllDependency: () => Map<P, Set<P>>;
|
|
@@ -381,6 +420,24 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
|
|
|
381
420
|
onStart: (cb: (data: {
|
|
382
421
|
path: P;
|
|
383
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
|
+
};
|
|
384
441
|
}, M, P>;
|
|
385
442
|
declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string, any> = any>() => <T, M extends Record<string, any>>(id: MeshPath, schema: any, options: {
|
|
386
443
|
metaType?: NM;
|
|
@@ -398,7 +455,7 @@ declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string,
|
|
|
398
455
|
*/
|
|
399
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>;
|
|
400
457
|
declare const deleteEngine: (id: MeshPath) => void;
|
|
401
|
-
declare const useMeshFlow: <const S extends Record<string, any
|
|
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: {
|
|
402
459
|
metaType?: NM;
|
|
403
460
|
config?: {
|
|
404
461
|
useGreedy: boolean;
|
|
@@ -409,8 +466,8 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
|
|
|
409
466
|
signalTrigger: (signal: T) => void;
|
|
410
467
|
};
|
|
411
468
|
}) => Engine<{
|
|
412
|
-
SetRule: <
|
|
413
|
-
SetRules: <
|
|
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;
|
|
414
471
|
SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
|
|
415
472
|
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
|
|
416
473
|
cancel: () => void;
|
|
@@ -420,8 +477,13 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
|
|
|
420
477
|
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
421
478
|
}) => void;
|
|
422
479
|
}) => () => void;
|
|
423
|
-
SetValue: (path: P, value: any) => void;
|
|
480
|
+
SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
|
|
424
481
|
GetValue: (path: P, key?: string) => any;
|
|
482
|
+
SetValues: (updates: {
|
|
483
|
+
path: P;
|
|
484
|
+
key: (string & {}) | KeysOfUnion<NM>;
|
|
485
|
+
value: any;
|
|
486
|
+
}[]) => void;
|
|
425
487
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
|
|
426
488
|
notifyAll: () => Promise<void>;
|
|
427
489
|
GetAllDependency: () => Map<P, Set<P>>;
|
|
@@ -439,6 +501,24 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
|
|
|
439
501
|
onStart: (cb: (data: {
|
|
440
502
|
path: P;
|
|
441
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
|
+
};
|
|
442
522
|
}, M, P>;
|
|
443
523
|
|
|
444
|
-
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
|
|
59
|
-
|
|
65
|
+
interface BaseMeshEvents {
|
|
66
|
+
"flow:start": {
|
|
60
67
|
path: MeshPath;
|
|
61
68
|
};
|
|
62
|
-
|
|
69
|
+
"node:start": {
|
|
63
70
|
path: MeshPath;
|
|
64
71
|
};
|
|
65
|
-
|
|
72
|
+
"node:success": {
|
|
66
73
|
path: MeshPath;
|
|
67
|
-
key: string;
|
|
68
|
-
value: any;
|
|
69
74
|
};
|
|
70
|
-
|
|
75
|
+
"node:error": {
|
|
71
76
|
path: MeshPath;
|
|
72
77
|
error: any;
|
|
73
78
|
};
|
|
74
|
-
|
|
79
|
+
"node:intercept": {
|
|
75
80
|
path: MeshPath;
|
|
76
81
|
type: number;
|
|
77
82
|
detail?: any;
|
|
78
83
|
};
|
|
79
|
-
|
|
84
|
+
"node:release": {
|
|
80
85
|
path: MeshPath;
|
|
81
86
|
type: number;
|
|
82
87
|
detail?: any;
|
|
83
88
|
};
|
|
84
|
-
|
|
89
|
+
"node:stagnate": {
|
|
85
90
|
path: MeshPath;
|
|
86
91
|
type: number;
|
|
87
92
|
};
|
|
88
|
-
|
|
93
|
+
"node:processing": {
|
|
94
|
+
path: MeshPath;
|
|
95
|
+
};
|
|
96
|
+
"node:pending": {
|
|
89
97
|
path: MeshPath;
|
|
90
98
|
};
|
|
91
|
-
|
|
99
|
+
"flow:wait": {
|
|
92
100
|
type: number;
|
|
93
101
|
detail?: any;
|
|
94
102
|
};
|
|
95
|
-
|
|
103
|
+
"flow:fire": {
|
|
96
104
|
path: MeshPath;
|
|
97
105
|
type: number;
|
|
98
106
|
detail?: any;
|
|
99
107
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
'flow:success': {
|
|
108
|
+
}
|
|
109
|
+
interface MeshEvents extends BaseMeshEvents {
|
|
110
|
+
"flow:success": {
|
|
104
111
|
duration: string;
|
|
105
112
|
};
|
|
106
|
-
|
|
113
|
+
"flow:end": {
|
|
107
114
|
type: number;
|
|
108
115
|
};
|
|
109
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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,45 +145,42 @@ type MeshFlowHistory = {
|
|
|
139
145
|
interface MeshFlowEngineMap {
|
|
140
146
|
}
|
|
141
147
|
type MeshPath = string | number | symbol;
|
|
142
|
-
interface
|
|
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
|
-
state:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
nodeBucket: Record<keyof S, MeshBucket<P>>;
|
|
154
|
-
notifyKeys: Set<keyof S>;
|
|
152
|
+
state: V;
|
|
153
|
+
nodeBucket: Record<keyof NM, SchemaBucket<P>>;
|
|
154
|
+
notifyKeys: Set<keyof NM>;
|
|
155
155
|
dirtySignal: any;
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
proxy: any;
|
|
157
|
+
meta: NM;
|
|
158
|
+
dependOn: (cb: (val: V) => V, key?: keyof NM) => void;
|
|
158
159
|
createView: (extraProps?: Record<string, any>) => any;
|
|
159
160
|
}
|
|
160
161
|
interface MeshFlowGroupNode<P extends MeshPath = MeshPath> {
|
|
161
162
|
path: P;
|
|
162
163
|
uid: number;
|
|
163
|
-
type:
|
|
164
|
+
type: "group";
|
|
164
165
|
children: Array<P>;
|
|
165
166
|
dirtySignal: any;
|
|
166
167
|
meta: Record<string, any>;
|
|
167
168
|
}
|
|
168
|
-
interface logicApi {
|
|
169
|
+
interface logicApi<NM, TKeys extends KeysOfUnion<NM>> {
|
|
169
170
|
slot: {
|
|
170
|
-
triggerTargets: any
|
|
171
|
+
triggerTargets: Array<Record<TKeys, any>>;
|
|
171
172
|
affectedTatget: any;
|
|
172
173
|
};
|
|
173
174
|
}
|
|
174
|
-
interface SetRuleOptions<NM
|
|
175
|
+
interface SetRuleOptions<NM, TKeys extends KeysOfUnion<NM>> {
|
|
175
176
|
value?: any;
|
|
176
177
|
priority?: number;
|
|
177
178
|
forceNotify?: boolean;
|
|
178
|
-
logic: (api: logicApi) => any;
|
|
179
|
+
logic: (api: logicApi<NM, TKeys>) => any;
|
|
179
180
|
effect?: (args: any) => any;
|
|
180
181
|
effectArgs?: Array<KeysOfUnion<NM>>;
|
|
182
|
+
cacheStrategy?: "none" | "shallow";
|
|
183
|
+
triggerKeys?: TKeys[];
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
/**
|
|
@@ -206,8 +209,8 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
|
|
|
206
209
|
};
|
|
207
210
|
plugins: {};
|
|
208
211
|
}): {
|
|
209
|
-
SetRule: <
|
|
210
|
-
SetRules: <
|
|
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;
|
|
211
214
|
SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
|
|
212
215
|
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
|
|
213
216
|
cancel: () => void;
|
|
@@ -217,8 +220,13 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
|
|
|
217
220
|
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
218
221
|
}) => void;
|
|
219
222
|
}) => () => void;
|
|
220
|
-
SetValue: (path: P, value: any) => void;
|
|
223
|
+
SetValue: (path: P, key: KeysOfUnion<NM> | (string & {}), value: any) => void;
|
|
221
224
|
GetValue: (path: P, key?: string) => any;
|
|
225
|
+
SetValues: (updates: {
|
|
226
|
+
path: P;
|
|
227
|
+
key: KeysOfUnion<NM> | (string & {});
|
|
228
|
+
value: any;
|
|
229
|
+
}[]) => void;
|
|
222
230
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
|
|
223
231
|
notifyAll: () => Promise<void>;
|
|
224
232
|
GetAllDependency: () => Map<P, Set<P>>;
|
|
@@ -236,11 +244,29 @@ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(dat
|
|
|
236
244
|
onStart: (cb: (data: {
|
|
237
245
|
path: P;
|
|
238
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
|
+
};
|
|
239
265
|
};
|
|
240
266
|
|
|
241
267
|
declare function useScheduler<T, //ui trigger中定义的类型
|
|
242
268
|
P extends MeshPath, // 路径类型
|
|
243
|
-
|
|
269
|
+
NM = any>(config: {
|
|
244
270
|
useGreedy: boolean;
|
|
245
271
|
}, dependency: {
|
|
246
272
|
GetDependencyOrder: () => P[][];
|
|
@@ -261,17 +287,22 @@ S = any>(schema: S, config: {
|
|
|
261
287
|
signalCreator: () => T;
|
|
262
288
|
signalTrigger: (signal: T) => void;
|
|
263
289
|
}): {
|
|
264
|
-
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView">) => MeshFlowTaskNode<P, any,
|
|
290
|
+
registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView" | "proxy">) => MeshFlowTaskNode<P, any, NM>;
|
|
265
291
|
registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
|
|
266
|
-
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any,
|
|
292
|
+
GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, NM>;
|
|
267
293
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
|
|
268
294
|
notify: (path: P) => void;
|
|
269
295
|
notifyAll: () => Promise<void>;
|
|
296
|
+
batchNotify: (updates: {
|
|
297
|
+
path: P;
|
|
298
|
+
key: KeysOfUnion<NM> | (string & {});
|
|
299
|
+
value: any;
|
|
300
|
+
}[]) => void;
|
|
270
301
|
UITrigger: {
|
|
271
302
|
signalCreator: () => T;
|
|
272
303
|
signalTrigger: (signal: T) => void;
|
|
273
304
|
};
|
|
274
|
-
UidToNodeMap: Map<number, MeshFlowTaskNode<P, any,
|
|
305
|
+
UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, NM>>;
|
|
275
306
|
};
|
|
276
307
|
|
|
277
308
|
type SchedulerType<T, P extends MeshPath, S, NM> = ReturnType<typeof useEngineInstance<T, P, S, NM>>;
|
|
@@ -283,6 +314,9 @@ type BaseEngine<T> = {
|
|
|
283
314
|
GetValue: T extends {
|
|
284
315
|
GetValue: infer F;
|
|
285
316
|
} ? F : never;
|
|
317
|
+
SetValues: T extends {
|
|
318
|
+
SetValues: infer F;
|
|
319
|
+
} ? F : never;
|
|
286
320
|
GetGroupByPath: T extends {
|
|
287
321
|
GetGroupByPath: infer F;
|
|
288
322
|
} ? F : never;
|
|
@@ -339,8 +373,8 @@ type EngineModules<M, P extends MeshPath> = {
|
|
|
339
373
|
};
|
|
340
374
|
type Engine<T, M, P extends MeshPath> = BaseEngine<T> & EngineModules<M, P>;
|
|
341
375
|
/** @deprecated 请使用新的 useMeshFlow 别名 */
|
|
342
|
-
declare const useEngineManager: <const S extends Record<string, any
|
|
343
|
-
M extends Record<string, any>, NM extends Record<string, any
|
|
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: {
|
|
344
378
|
metaType?: NM;
|
|
345
379
|
config?: {
|
|
346
380
|
useGreedy: boolean;
|
|
@@ -351,8 +385,8 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
|
|
|
351
385
|
signalTrigger: (signal: T) => void;
|
|
352
386
|
};
|
|
353
387
|
}) => Engine<{
|
|
354
|
-
SetRule: <
|
|
355
|
-
SetRules: <
|
|
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;
|
|
356
390
|
SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
|
|
357
391
|
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
|
|
358
392
|
cancel: () => void;
|
|
@@ -362,8 +396,13 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
|
|
|
362
396
|
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
363
397
|
}) => void;
|
|
364
398
|
}) => () => void;
|
|
365
|
-
SetValue: (path: P, value: any) => void;
|
|
399
|
+
SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
|
|
366
400
|
GetValue: (path: P, key?: string) => any;
|
|
401
|
+
SetValues: (updates: {
|
|
402
|
+
path: P;
|
|
403
|
+
key: (string & {}) | KeysOfUnion<NM>;
|
|
404
|
+
value: any;
|
|
405
|
+
}[]) => void;
|
|
367
406
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
|
|
368
407
|
notifyAll: () => Promise<void>;
|
|
369
408
|
GetAllDependency: () => Map<P, Set<P>>;
|
|
@@ -381,6 +420,24 @@ M extends Record<string, any>, NM extends Record<string, any> = Record<string, a
|
|
|
381
420
|
onStart: (cb: (data: {
|
|
382
421
|
path: P;
|
|
383
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
|
+
};
|
|
384
441
|
}, M, P>;
|
|
385
442
|
declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string, any> = any>() => <T, M extends Record<string, any>>(id: MeshPath, schema: any, options: {
|
|
386
443
|
metaType?: NM;
|
|
@@ -398,7 +455,7 @@ declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string,
|
|
|
398
455
|
*/
|
|
399
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>;
|
|
400
457
|
declare const deleteEngine: (id: MeshPath) => void;
|
|
401
|
-
declare const useMeshFlow: <const S extends Record<string, any
|
|
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: {
|
|
402
459
|
metaType?: NM;
|
|
403
460
|
config?: {
|
|
404
461
|
useGreedy: boolean;
|
|
@@ -409,8 +466,8 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
|
|
|
409
466
|
signalTrigger: (signal: T) => void;
|
|
410
467
|
};
|
|
411
468
|
}) => Engine<{
|
|
412
|
-
SetRule: <
|
|
413
|
-
SetRules: <
|
|
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;
|
|
414
471
|
SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStrategy) => void;
|
|
415
472
|
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
|
|
416
473
|
cancel: () => void;
|
|
@@ -420,8 +477,13 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
|
|
|
420
477
|
on: (event: MeshEventName, cb: Function) => () => boolean;
|
|
421
478
|
}) => void;
|
|
422
479
|
}) => () => void;
|
|
423
|
-
SetValue: (path: P, value: any) => void;
|
|
480
|
+
SetValue: (path: P, key: (string & {}) | KeysOfUnion<NM>, value: any) => void;
|
|
424
481
|
GetValue: (path: P, key?: string) => any;
|
|
482
|
+
SetValues: (updates: {
|
|
483
|
+
path: P;
|
|
484
|
+
key: (string & {}) | KeysOfUnion<NM>;
|
|
485
|
+
value: any;
|
|
486
|
+
}[]) => void;
|
|
425
487
|
GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
|
|
426
488
|
notifyAll: () => Promise<void>;
|
|
427
489
|
GetAllDependency: () => Map<P, Set<P>>;
|
|
@@ -439,6 +501,24 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
|
|
|
439
501
|
onStart: (cb: (data: {
|
|
440
502
|
path: P;
|
|
441
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
|
+
};
|
|
442
522
|
}, M, P>;
|
|
443
523
|
|
|
444
|
-
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,c,r=this.computedRules;for(let l=0;l<r.length;l++){let o=r[l],s=o.logic(e);if(s instanceof Promise)return (async()=>{let i=await s;if(o.entityId==="__base__"?c=i:i&&(t=i),typeof t>"u")for(let u=l+1;u<r.length;u++){let f=r[u],y=f.logic(e),P=y instanceof Promise?await y:y;if(f.entityId==="__base__"){c=P;continue}if(P){t=f.value;break}}return typeof t>"u"&&(t=c),{res:t,version:n}})();let d=s;if(o.entityId==="__base__"){c=d;continue}if(d){t=o.value;break}}return typeof t>"u"&&(t=c),{res:t,version:n}},PRIORITY:(e,n)=>{let t,c=this.computedRules;for(let r=0;r<c.length;r++){let o=c[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<c.length;d++){let i=c[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 c=()=>this.rules;this.strategy=new Z(c),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,c={...e,entityId:t};for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(c);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let l=this.rules.get(r);l&&(l.delete(c),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,c={...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(c);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let l=this.rules.get(r);l&&(l.delete(c),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),o=e.GetValueByPath(e.triggerPath);if(typeof l=="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 c=++this.version,r=this.strategy.evaluate(e,c);if(!(r instanceof Promise)){let{res:l,version:o}=r;return this.finalizeSync(l,o,e,n)}return this.pendingPromise=(async()=>{try{let{res:l,version:o}=await r;return this.finalizeSync(l,o,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,c){return c!==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 te=(a,e,n)=>{let c=r=>{let l=n.triggerPaths.map(d=>r.GetValueByPath(d).value),o=Object.create(null);return Object.defineProperty(o,"triggerTargets",{get:()=>l||[]}),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:c}},ne=(a,e,n,t)=>{if(!a)throw Error("");let c=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=c(d),y=te(d,i,{...u,triggerPaths:[s]}),P=[s].map(g=>[g,c(g).state.value]);if(r(s,d),f.nodeBucket[i])f.nodeBucket[i].setRule(y,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(y,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=c(d);for(let g of s)r(g,d);let y=te(d,i,{...u,triggerPaths:s}),P=s.map(g=>[g,c(g).state.value]);if(f.nodeBucket[i])f.nodeBucket[i].setRules(y,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(y,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,c,r)=>{e(t).nodeBucket[c].setStrategy(r);}}};function se(){let a=new Map,e=new Map,n=new Set,t=(l,o)=>{a.set(l,o);let s=e.get(l);s&&s(o);};return {SetTrace:(l,o)=>{e.set(l,o);let s=a.get(l)||"idle";return o(s),{cancel:()=>{e.delete(l);}}},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 c=i=>{let u=a(),f=e(),y=new Set;return u.get(i)?.forEach(P=>y.add(P)),y.size===0?[]:Array.from(y).filter(P=>{let g=f.get(P)||new Set;return !Array.from(g).some(N=>y.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 y of i){let P=c(y);u.set(y,new Set(P));for(let g of P)f.has(g)||f.set(g,new Set),f.get(g).add(y);}return {directNextMap:u,directPrevMap:f}}}}function oe(a){let e=t=>{let c=[],r=[],l=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;){c.push([...r]);let i=[];for(let u of r){s++,l.set(u,d);let f=a.get(u);if(f)for(let y of f){let P=t.get(y)-1;t.set(y,P),P===0&&i.push(y);}}r=i,d++;}if(s<o)throw Error("Circular dependency detected");return {steps:c,levelMap:l}};return ()=>{let t=new Map;for(let c of a.keys()){let r=Array.from(a.get(c)||[]);t.has(c)||t.set(c,0);for(let l of r){let o=t.get(l)||0;t.set(l,++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,l)=>{e.get(r)?.forEach(o=>o(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,o=(s,d)=>{let i=t(s,d);return l.add(i),i};return r.apply({on:o}),a.add(r),()=>{l.forEach(s=>s()),l.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,c=()=>!!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||c()))},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,c){let r=new Map,l=a.useGreedy,o=de();return async(d,i)=>{let f=Symbol("token"),y=d||"__NOTIFY_ALL__";r.set(y,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(),A=0,z=0,H=I=>{e.GetAllNextDependency(I).forEach($=>{let G=L.get($)||0;G>z&&(z=G);});};d?(A=L.get(d)??0,H(d),g.add(d)):i.forEach(I=>H(I)),i.forEach(I=>{M.add(I);});let p=performance.now();t.emit("flow:start",{path:y}),t.callOnStart({path:y});let R=false,O=30,Q=I=>{let{target:v,trigger:$}=I,G=false,D=false,k=n.GetNodeByPath(v),W=[],E=(h,T)=>{if(g.has(h)||m.has(h)||M.has(h))return;let K=0,x=L.get(h)??0;if(N.has(h))K=N.get(h)-1;else {if(x>A&&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)>A&&S++;}K=S;}if(K<=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,K);},B=(h=[])=>{if(r.get(y)!==f)return;if(h.length){let x={},F=k.proxy;for(let S of h){let b=(S.args||[]).reduce((U,Y)=>(U[Y]=F[Y],U),{});try{let U=S.fn(b);U&&typeof U=="object"&&Object.assign(x,U);}catch(U){}}for(let S in x)if(S in k.state)k.state[S]=x[S];else throw {error:`wrong effect in ${k.path}`};G=true;}G&&c.flushPathSet.add(v),t.emit("node:success",{path:v}),g.add(v);let T=e.GetNextDependency(v);(G||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(G||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();}})();},V=h=>{t.emit("node:error",{path:v,error:h});let T=Symbol("abort");r.set(y,T),M.clear(),N.clear(),m.clear(),t.callOnError(h);},w=(h,T)=>{let K=false;h!==k[T]&&(k[T]=h,k.state[T]=h,G=true,t.emit("node:bucket:success",{path:v,key:T,value:h}),T==="value"&&(K=true)),k.nodeBucket[T].isForceNotify()&&(D=true),(K||D)&&H(v);};t.emit("node:start",{path:v});try{let h=[];for(let T in k.nodeBucket){let K=k.nodeBucket[T];h.push(...K.getSideEffect());let x=K.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(y)===f&&w(S,T);});W.push(F);}else w(x,T);}if(W.length>0)return Promise.all(W).then(()=>{B(h);}).catch(V);B(h);return}catch(h){V(h);}},j=async()=>{if(r.get(y)!==f){P=false;return}P=true;let I=o.getIsFirstFrame(),v=0,$=()=>l&&I?30:1/0,G=0,D=$();try{for(;r.get(y)===f;){let k=G>=D,W=o.shouldYield();if(k||W){if(G>0&&(v++,(I||v%2===0)&&c.requestUpdate()),await o.yieldToMain(),r.get(y)!==f)break;G=0,I=o.getIsFirstFrame();}if(M.size>0&&m.size<5){for(let E of M){if(m.size>=5||G>=D)break;let B=L.get(E)??0,V=e.GetPrevDependency(E),w=V.length>1;if((!l||w)&&B>A){M.delete(E);let T=V.filter(K=>_.has(K)&&!g.has(K)).length;N.set(E,T||0),t.emit("node:intercept",{path:E,type:T>0?4:5,detail:{targetLevel:B,currentLevel:A,pendingParentsCount:T}});continue}if(M.delete(E),m.add(E),t.emit("node:processing",{path:E}),Q({target:E,trigger:d}),G++,G>=D||o.shouldYield())break}if(M.size>0)continue}if(G<D&&l&&N.size>0&&m.size<5){let E=!1,B=0;for(let[V,w]of N)if(w<=0){let h=L.get(V)??0,T=e.GetPrevDependency(V);if(h>A&&T.length>1)continue;if(N.delete(V),M.add(V),B++,E=!0,t.emit("node:release",{path:V,type:4}),B>=D)break}if(B>0)continue;if(E){if(o.shouldYield()&&(await o.yieldToMain(),r.get(y)!==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>A&&E.add(h);}let B=Array.from(E).sort((w,h)=>w-h),V=B[0];if(B.length>0&&V<=z){let w=B[0];if(w<=z){A=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(y)===f&&!R){R=true,t.emit("flow:end",{type:1}),c.requestUpdate();let W=performance.now();t.emit("flow:success",{duration:(W-p).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:c,dirtySignal:r,triggerUI:l,state:o}=a,s=null,i={path:e,uid:n,type:t,meta:c,dirtySignal:r,createView:(u={})=>{let f=new Proxy(u,{get(y,P){let g=P;return g in a.state?a.state[g]:g in a?a[g]:c&&g in c?c[g]:Reflect.get(y,P)},set(y,P,g){let m=P;return m in a.state?(a.state[m]=g,l(),true):Reflect.set(y,P,g)},ownKeys(y){let P=new Set([...Reflect.ownKeys(y),...Object.keys(o||{}),...Object.keys(c||{})]);return Array.from(P)},getOwnPropertyDescriptor(y,P){return o&&P in o||c&&P in c?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(y,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 pe(a,e,n,t,c,r){let l=0,o=new Map,s=new Map,d=new Map,i=false,u=new Set,g=async()=>{let p=Array.from(u);u.clear();for(let R of p){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},c,{requestUpdate:m,flushPathSet:u}),N=p=>{if(o.has(p.path))throw new Error(`[MeshFlow] Duplicate Path: ${String(p.path)}`);let R=++l,O={path:p.path,getNode:I=>M(I)},Q=I=>{let v=I({...O}),$=M(p.path);if(t.createHistoryAction&&t.pushIntoHistory){let G=t.createHistoryAction([{path:p.path,value:$.state.value},{path:p.path,value:v}],D=>{let k=M(D.path);k.state.value=D.value,A(D.path);});t.pushIntoHistory(G);}$.state.value=v,A(p.path);},j=ee({uid:R,path:p.path,state:p.state,meta:p.meta,nodeBucket:p.nodeBucket,dirtySignal:p.dirtySignal,notifyKeys:p.notifyKeys,dependOn:Q,triggerUI:()=>r.signalTrigger(p.dirtySignal)});return o.set(j.path,R),s.set(R,j),j},C=p=>{if(o.has(p.path))throw new Error(`[MeshFlow] Duplicate Path: ${String(p.path)}`);let R=++l,O=ee({uid:R,path:p.path,state:{},meta:p,nodeBucket:{},children:p.children});return o.set(O.path,R),d.set(R,O),O};function M(p){let R=o.get(p),O=s.get(R);if(!O)throw Error("wrong ID");return O}function L(p){let R=o.get(p);return d.get(R)}let A=p=>{if(!M(p))throw Error("Node undefined");u.add(p),m();let O=n.GetNextDependency(p);z(O,p);};function z(p,R){_(R,p);}return {registerNode:N,registerGroupNode:C,GetNodeByPath:M,GetGroupByPath:L,notify:A,notifyAll:async()=>{Promise.resolve().then(async()=>{let p=n.GetDependencyOrder();if(!p||p.length===0)return;let R=p[0];try{_(null,R);}catch(O){throw c.callOnError(O),O}finally{m();}});},UITrigger:r,UidToNodeMap:s}}function ye(a,e){let n=false,t=false,c=new Map,r=new Map,l=new Map,o=new Map,s=[],d=new Map,{GetNextDependency:u,GetPrevDependency:f,GetAllPrevDependency:y,GetAllNextDependency:P,rebuildDirectDependencyMaps:g}=ae(()=>c,()=>r,()=>o,()=>l),m={},_={};if(e.modules.useHistory){let{Undo:S,Redo:b,PushIntoHistory:U,CreateHistoryAction:Y,initCanUndo:he,initCanRedo:ge}=e.modules.useHistory();m.pushIntoHistory=U,m.createHistoryAction=Y,_={Undo:S,Redo:b,initCanUndo:he,initCanRedo:ge};}let{onError:N,callOnError:C}=ie(),{onSuccess:M,callOnSuccess:L}=le(),{onStart:A,callOnStart:z}=ue(),{emit:H,usePlugin:p}=ce(),{SetTrace:R,useTrace:O}=se(),Q=O();p(Q);let j=pe(a,{useGreedy:e.config.useGreedy},{GetDependencyOrder:()=>s,GetAllNextDependency:P,GetNextDependency:u,GetPrevDependency:f,GetAllPrevDependency:y,GetPathToLevelMap:()=>d},m,{callOnError:C,callOnSuccess:L,callOnStart:z,emit:H},e.UITrigger),{GetGroupByPath:I,GetNodeByPath:v,notifyAll:$}=j,G={};if(e.modules.useInternalForm){let{uiSchema:S,GetFormData:b}=e.modules.useInternalForm(j,a);G={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,c,r),{SetStrategy:E}=re(v),B=oe(c),V=()=>{let S=B();s=S.steps,d=S.levelMap;},w=()=>{t||(t=true,Promise.resolve().then(()=>{if(V(),n){let{directNextMap:S,directPrevMap:b}=g(s.flat());l=S,o=b;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(S,b,U,Y)=>{k(S,b,U,Y),n=true,w();},SetRules:(S,b,U,Y)=>{W(S,b,U,Y),n=true,w();},SetStrategy:E,SetTrace:R,usePlugin:p,SetValue:(S,b)=>{v(S).dependOn(()=>b);},GetValue:(S,b="value")=>v(S)[b],GetGroupByPath:I,notifyAll:async()=>{V(),await $();},GetAllDependency:()=>c,GetDependencyOrder:()=>s,historyExports:_,formExports:G,validatorExports:D,onError:N,onSuccess:M,onStart:A}}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=ye(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules||{},plugins:{}}),{SetRule:c,SetRules:r,SetStrategy:l,SetValue:o,GetValue:s,usePlugin:d,GetGroupByPath:i,notifyAll:u,SetTrace:f,GetAllDependency:y,GetDependencyOrder:P,historyExports:g,formExports:m,validatorExports:_,onError:N,onSuccess:C,onStart:M}=t,A={...{config:{SetRule:c,SetRules:r,SetStrategy:l,notifyAll:u,SetTrace:f,usePlugin:d},data:{SetValue:o,GetValue:s,GetGroupByPath:i},dependency:{GetAllDependency:y,GetDependencyOrder:P},hooks:{onError:N,onSuccess:C,onStart:M}}},z=n.modules;return z&&Object.keys(z).forEach(H=>{let p=H;if(p.startsWith("use")){let R=p.slice(3);p=R.charAt(0).toLowerCase()+R.slice(1);}H==="useHistory"&&g&&Object.keys(g).length>0&&(A[p]=g),H==="useInternalForm"&&Object.keys(m).length>0&&(A[p]=m),H==="useSchemaValidators"&&Object.keys(_).length>0&&(A[p]=_);}),J.set(a,A),A}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=pe;
|
|
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,c,r=this.computedRules;for(let l=0;l<r.length;l++){let o=r[l],s=o.logic(e);if(s instanceof Promise)return (async()=>{let i=await s;if(o.entityId==="__base__"?c=i:i&&(t=i),typeof t>"u")for(let u=l+1;u<r.length;u++){let f=r[u],y=f.logic(e),P=y instanceof Promise?await y:y;if(f.entityId==="__base__"){c=P;continue}if(P){t=f.value;break}}return typeof t>"u"&&(t=c),{res:t,version:n}})();let d=s;if(o.entityId==="__base__"){c=d;continue}if(d){t=o.value;break}}return typeof t>"u"&&(t=c),{res:t,version:n}},PRIORITY:(e,n)=>{let t,c=this.computedRules;for(let r=0;r<c.length;r++){let o=c[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<c.length;d++){let i=c[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 c=()=>this.rules;this.strategy=new Z(c),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,c={...e,entityId:t};for(let r of e.triggerPaths)this.rules.has(r)||this.rules.set(r,new Set),this.rules.get(r).add(c);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let l=this.rules.get(r);l&&(l.delete(c),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,c={...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(c);return this.strategy.updateComputedRules(),()=>{for(let r of e.triggerPaths){let l=this.rules.get(r);l&&(l.delete(c),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),o=e.GetValueByPath(e.triggerPath);if(typeof l=="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 c=++this.version,r=this.strategy.evaluate(e,c);if(!(r instanceof Promise)){let{res:l,version:o}=r;return this.finalizeSync(l,o,e,n)}return this.pendingPromise=(async()=>{try{let{res:l,version:o}=await r;return this.finalizeSync(l,o,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,c){return c!==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 te=(a,e,n)=>{let c=r=>{let l=n.triggerPaths.map(d=>r.GetValueByPath(d).value),o=Object.create(null);return Object.defineProperty(o,"triggerTargets",{get:()=>l||[]}),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:c}},ne=(a,e,n,t)=>{if(!a)throw Error("");let c=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=c(d),y=te(d,i,{...u,triggerPaths:[s]}),P=[s].map(g=>[g,c(g).state.value]);if(r(s,d),f.nodeBucket[i])f.nodeBucket[i].setRule(y,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(y,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=c(d);for(let g of s)r(g,d);let y=te(d,i,{...u,triggerPaths:s}),P=s.map(g=>[g,c(g).state.value]);if(f.nodeBucket[i])f.nodeBucket[i].setRules(y,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(y,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,c,r)=>{e(t).nodeBucket[c].setStrategy(r);}}};function se(){let a=new Map,e=new Map,n=new Set,t=(l,o)=>{a.set(l,o);let s=e.get(l);s&&s(o);};return {SetTrace:(l,o)=>{e.set(l,o);let s=a.get(l)||"idle";return o(s),{cancel:()=>{e.delete(l);}}},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 c=i=>{let u=a(),f=e(),y=new Set;return u.get(i)?.forEach(P=>y.add(P)),y.size===0?[]:Array.from(y).filter(P=>{let g=f.get(P)||new Set;return !Array.from(g).some(N=>y.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 y of i){let P=c(y);u.set(y,new Set(P));for(let g of P)f.has(g)||f.set(g,new Set),f.get(g).add(y);}return {directNextMap:u,directPrevMap:f}}}}function oe(a){let e=t=>{let c=[],r=[],l=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;){c.push([...r]);let i=[];for(let u of r){s++,l.set(u,d);let f=a.get(u);if(f)for(let y of f){let P=t.get(y)-1;t.set(y,P),P===0&&i.push(y);}}r=i,d++;}if(s<o)throw Error("Circular dependency detected");return {steps:c,levelMap:l}};return ()=>{let t=new Map;for(let c of a.keys()){let r=Array.from(a.get(c)||[]);t.has(c)||t.set(c,0);for(let l of r){let o=t.get(l)||0;t.set(l,++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,l)=>{e.get(r)?.forEach(o=>o(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,o=(s,d)=>{let i=t(s,d);return l.add(i),i};return r.apply({on:o}),a.add(r),()=>{l.forEach(s=>s()),l.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,c=()=>!!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||c()))},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,c){let r=new Map,l=a.useGreedy,o=de();return async(d,i)=>{let f=Symbol("token"),y=d||"__NOTIFY_ALL__";r.set(y,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(),A=0,z=0,H=I=>{e.GetAllNextDependency(I).forEach($=>{let G=L.get($)||0;G>z&&(z=G);});};d?(A=L.get(d)??0,H(d),g.add(d)):i.forEach(I=>H(I)),i.forEach(I=>{M.add(I);});let p=performance.now();t.emit("flow:start",{path:y}),t.callOnStart({path:y});let R=false,O=30,Q=I=>{let{target:v,trigger:$}=I,G=false,D=false,k=n.GetNodeByPath(v),W=[],E=(h,T)=>{if(g.has(h)||m.has(h)||M.has(h))return;let K=0,x=L.get(h)??0;if(N.has(h))K=N.get(h)-1;else {if(x>A&&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)>A&&S++;}K=S;}if(K<=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,K);},B=(h=[])=>{if(r.get(y)!==f)return;if(h.length){let x={},F=k.proxy;for(let S of h){let b=(S.args||[]).reduce((U,Y)=>(U[Y]=F[Y],U),{});try{let U=S.fn(b);U&&typeof U=="object"&&Object.assign(x,U);}catch(U){}}for(let S in x)if(S in k.state)k.state[S]=x[S];else throw {error:`wrong effect in ${k.path}`};G=true;}G&&c.flushPathSet.add(v),t.emit("node:success",{path:v}),g.add(v);let T=e.GetNextDependency(v);(G||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(G||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();}})();},V=h=>{t.emit("node:error",{path:v,error:h});let T=Symbol("abort");r.set(y,T),M.clear(),N.clear(),m.clear(),t.callOnError(h);},w=(h,T)=>{let K=false;h!==k[T]&&(k[T]=h,k.state[T]=h,G=true,t.emit("node:bucket:success",{path:v,key:T,value:h}),T==="value"&&(K=true)),k.nodeBucket[T].isForceNotify()&&(D=true),(K||D)&&H(v);};t.emit("node:start",{path:v});try{let h=[];for(let T in k.nodeBucket){let K=k.nodeBucket[T];h.push(...K.getSideEffect());let x=K.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(y)===f&&w(S,T);});W.push(F);}else w(x,T);}if(W.length>0)return Promise.all(W).then(()=>{B(h);}).catch(V);B(h);return}catch(h){V(h);}},j=async()=>{if(r.get(y)!==f){P=false;return}P=true;let I=o.getIsFirstFrame(),v=0,$=()=>l&&I?30:1/0,G=0,D=$();try{for(;r.get(y)===f;){let k=G>=D,W=o.shouldYield();if(k||W){if(G>0&&(v++,(I||v%2===0)&&c.requestUpdate()),await o.yieldToMain(),r.get(y)!==f)break;G=0,I=o.getIsFirstFrame();}if(M.size>0&&m.size<5){for(let E of M){if(m.size>=5||G>=D)break;let B=L.get(E)??0,V=e.GetPrevDependency(E),w=V.length>1;if((!l||w)&&B>A){M.delete(E);let T=V.filter(K=>_.has(K)&&!g.has(K)).length;N.set(E,T||0),t.emit("node:intercept",{path:E,type:T>0?4:5,detail:{targetLevel:B,currentLevel:A,pendingParentsCount:T}});continue}if(M.delete(E),m.add(E),t.emit("node:processing",{path:E}),Q({target:E,trigger:d}),G++,G>=D||o.shouldYield())break}if(M.size>0)continue}if(G<D&&l&&N.size>0&&m.size<5){let E=!1,B=0;for(let[V,w]of N)if(w<=0){let h=L.get(V)??0,T=e.GetPrevDependency(V);if(h>A&&T.length>1)continue;if(N.delete(V),M.add(V),B++,E=!0,t.emit("node:release",{path:V,type:4}),B>=D)break}if(B>0)continue;if(E){if(o.shouldYield()&&(await o.yieldToMain(),r.get(y)!==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>A&&E.add(h);}let B=Array.from(E).sort((w,h)=>w-h),V=B[0];if(B.length>0&&V<=z){let w=B[0];if(w<=z){A=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(y)===f&&!R){R=true,t.emit("flow:end",{type:1}),c.requestUpdate();let W=performance.now();t.emit("flow:success",{duration:(W-p).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:c,dirtySignal:r,triggerUI:l,state:o}=a,s=null,i={path:e,uid:n,type:t,meta:c,dirtySignal:r,createView:(u={})=>{let f=new Proxy(u,{get(y,P){let g=P;return g in a.state?a.state[g]:g in a?a[g]:c&&g in c?c[g]:Reflect.get(y,P)},set(y,P,g){let m=P;return m in a.state?(a.state[m]=g,l(),true):Reflect.set(y,P,g)},ownKeys(y){let P=new Set([...Reflect.ownKeys(y),...Object.keys(o||{}),...Object.keys(c||{})]);return Array.from(P)},getOwnPropertyDescriptor(y,P){return o&&P in o||c&&P in c?{enumerable:true,configurable:true}:Reflect.getOwnPropertyDescriptor(y,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 pe(a,e,n,t,c,r){let l=0,o=new Map,s=new Map,d=new Map,i=false,u=new Set,g=async()=>{let p=Array.from(u);u.clear();for(let R of p){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},c,{requestUpdate:m,flushPathSet:u}),N=p=>{if(o.has(p.path))throw new Error(`[MeshFlow] Duplicate Path: ${String(p.path)}`);let R=++l,O={path:p.path,getNode:I=>M(I)},Q=I=>{let v=I({...O}),$=M(p.path);if(t.createHistoryAction&&t.pushIntoHistory){let G=t.createHistoryAction([{path:p.path,value:$.state.value},{path:p.path,value:v}],D=>{let k=M(D.path);k.state.value=D.value,A(D.path);});t.pushIntoHistory(G);}$.state.value=v,A(p.path);},j=ee({uid:R,path:p.path,state:p.state,meta:p.meta,nodeBucket:p.nodeBucket,dirtySignal:p.dirtySignal,notifyKeys:p.notifyKeys,dependOn:Q,triggerUI:()=>r.signalTrigger(p.dirtySignal)});return o.set(j.path,R),s.set(R,j),j},C=p=>{if(o.has(p.path))throw new Error(`[MeshFlow] Duplicate Path: ${String(p.path)}`);let R=++l,O=ee({uid:R,path:p.path,state:{},meta:p,nodeBucket:{},children:p.children});return o.set(O.path,R),d.set(R,O),O};function M(p){let R=o.get(p),O=s.get(R);if(!O)throw Error("wrong ID");return O}function L(p){let R=o.get(p);return d.get(R)}let A=p=>{if(!M(p))throw Error("Node undefined");u.add(p),m();let O=n.GetNextDependency(p);z(O,p);};function z(p,R){_(R,p);}return {registerNode:N,registerGroupNode:C,GetNodeByPath:M,GetGroupByPath:L,notify:A,notifyAll:async()=>{Promise.resolve().then(async()=>{let p=n.GetDependencyOrder();if(!p||p.length===0)return;let R=p[0];try{_(null,R);}catch(O){throw c.callOnError(O),O}finally{m();}});},UITrigger:r,UidToNodeMap:s}}function ye(a,e){let n=false,t=false,c=new Map,r=new Map,l=new Map,o=new Map,s=[],d=new Map,{GetNextDependency:u,GetPrevDependency:f,GetAllPrevDependency:y,GetAllNextDependency:P,rebuildDirectDependencyMaps:g}=ae(()=>c,()=>r,()=>o,()=>l),m={},_={};if(e.modules.useHistory){let{Undo:S,Redo:b,PushIntoHistory:U,CreateHistoryAction:Y,initCanUndo:he,initCanRedo:ge}=e.modules.useHistory();m.pushIntoHistory=U,m.createHistoryAction=Y,_={Undo:S,Redo:b,initCanUndo:he,initCanRedo:ge};}let{onError:N,callOnError:C}=ie(),{onSuccess:M,callOnSuccess:L}=le(),{onStart:A,callOnStart:z}=ue(),{emit:H,usePlugin:p}=ce(),{SetTrace:R,useTrace:O}=se(),Q=O();p(Q);let j=pe(a,{useGreedy:e.config.useGreedy},{GetDependencyOrder:()=>s,GetAllNextDependency:P,GetNextDependency:u,GetPrevDependency:f,GetAllPrevDependency:y,GetPathToLevelMap:()=>d},m,{callOnError:C,callOnSuccess:L,callOnStart:z,emit:H},e.UITrigger),{GetGroupByPath:I,GetNodeByPath:v,notifyAll:$}=j,G={};if(e.modules.useInternalForm){let{uiSchema:S,GetFormData:b}=e.modules.useInternalForm(j,a);G={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,c,r),{SetStrategy:E}=re(v),B=oe(c),V=()=>{let S=B();s=S.steps,d=S.levelMap;},w=()=>{t||(t=true,Promise.resolve().then(()=>{if(V(),n){let{directNextMap:S,directPrevMap:b}=g(s.flat());l=S,o=b;}}).finally(()=>{t=false,n=false;}));};return {SetRule:(S,b,U,Y)=>{k(S,b,U,Y),n=true,w();},SetRules:(S,b,U,Y)=>{W(S,b,U,Y),n=true,w();},SetStrategy:E,SetTrace:R,usePlugin:p,SetValue:(S,b)=>{v(S).dependOn(()=>b);},GetValue:(S,b="value")=>v(S)[b],GetGroupByPath:I,notifyAll:async()=>{V(),await $();},GetAllDependency:()=>c,GetDependencyOrder:()=>s,historyExports:_,formExports:G,validatorExports:D,onError:N,onSuccess:M,onStart:A}}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=ye(e,{config:n.config||{useGreedy:!1},UITrigger:n.UITrigger,modules:n.modules||{},plugins:{}}),{SetRule:c,SetRules:r,SetStrategy:l,SetValue:o,GetValue:s,usePlugin:d,GetGroupByPath:i,notifyAll:u,SetTrace:f,GetAllDependency:y,GetDependencyOrder:P,historyExports:g,formExports:m,validatorExports:_,onError:N,onSuccess:C,onStart:M}=t,A={...{config:{SetRule:c,SetRules:r,SetStrategy:l,notifyAll:u,SetTrace:f,usePlugin:d},data:{SetValue:o,GetValue:s,GetGroupByPath:i},dependency:{GetAllDependency:y,GetDependencyOrder:P},hooks:{onError:N,onSuccess:C,onStart:M}}},z=n.modules;return z&&Object.keys(z).forEach(H=>{let p=H;if(p.startsWith("use")){let R=p.slice(3);p=R.charAt(0).toLowerCase()+R.slice(1);}H==="useHistory"&&g&&Object.keys(g).length>0&&(A[p]=g),H==="useInternalForm"&&Object.keys(m).length>0&&(A[p]=m),H==="useSchemaValidators"&&Object.keys(_).length>0&&(A[p]=_);}),J.set(a,A),A}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,pe 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};
|
|
@@ -0,0 +1 @@
|
|
|
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}}}
|
|
@@ -0,0 +1 @@
|
|
|
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.
|
|
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",
|