@meshflow/core 0.1.8 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,7 +61,7 @@ const engine = useMeshFlow<Ref<number,number>,AllPath>('main',schema, {
61
61
  // useGreedy:true
62
62
  // },
63
63
  UITrigger:{//以vue为例
64
- signalCreateor: () => ref(0),
64
+ signalCreator: () => ref(0),
65
65
  signalTrigger(signal) {
66
66
  signal.value++;
67
67
  },
package/index.d.mts CHANGED
@@ -3,6 +3,58 @@ interface MeshErrorContext {
3
3
  error: any;
4
4
  }
5
5
 
6
+ type ContractType = 'boolean' | 'scalar' | 'array' | 'object';
7
+ declare enum DefaultStarategy {
8
+ OR = "OR",
9
+ PRIORITY = "PRIORITY"
10
+ }
11
+ declare class SchemaBucket<P> {
12
+ private path;
13
+ private strategy;
14
+ contract: ContractType;
15
+ private rules;
16
+ private isValue;
17
+ private id;
18
+ private cache;
19
+ private pendingPromise;
20
+ private version;
21
+ private deps;
22
+ private _forceNotify;
23
+ promiseToken: any;
24
+ private effectArray;
25
+ constructor(baseValue: any, key: string | number | symbol, path: P);
26
+ forceNotify(): void;
27
+ isForceNotify(): boolean;
28
+ setStrategy(type: DefaultStarategy): void;
29
+ setDefaultRule(value: any): void;
30
+ setRules(value: any, DepsArray?: Array<[P, any]>): () => void;
31
+ updateDeps(DepsArray: Array<[P, any]>): void;
32
+ setRule(value: any, DepsArray?: Array<[P, any]>): (() => void) | undefined;
33
+ setSideEffect(data: {
34
+ fn: (args: any[]) => any;
35
+ args: any[];
36
+ }): void;
37
+ getSideEffect(): {
38
+ fn: (args: any) => any;
39
+ args: any[];
40
+ }[];
41
+ evaluate(api: any): any;
42
+ private finalizeSync;
43
+ private inferType;
44
+ }
45
+
46
+ type Unwrap<T> = T extends ReadonlyArray<infer U> ? U : T;
47
+ type InferLeafPath<T, Prefix extends string = ""> = Unwrap<T> extends infer Node ? Node extends {
48
+ readonly name: infer N;
49
+ } ? N extends string ? N extends "" ? Node extends {
50
+ readonly children: infer C;
51
+ } ? InferLeafPath<C, Prefix> : never : (Node extends {
52
+ readonly children: infer C;
53
+ } ? InferLeafPath<C, Prefix extends "" ? N : `${Prefix}.${N}`> : (Prefix extends "" ? N : `${Prefix}.${N}`)) : N extends number | symbol ? Node extends {
54
+ readonly children: infer C;
55
+ } ? InferLeafPath<C, Prefix> : N : never : never : never;
56
+ type KeysOfUnion<T> = T extends any ? keyof T : never;
57
+
6
58
  interface MeshEvents {
7
59
  'node:start': {
8
60
  path: MeshPath;
@@ -91,179 +143,75 @@ interface MeshBucket<P> {
91
143
  evaluate: (context: any) => Promise<any> | any;
92
144
  [key: string]: any;
93
145
  }
94
- interface MeshFlowTaskNode<P extends MeshPath = MeshPath, S = any, V = any> {
146
+ interface MeshFlowTaskNode<P extends MeshPath = MeshPath, V = any, S = any> {
95
147
  path: P;
96
148
  uid: number;
97
149
  type: string;
98
150
  state: {
99
151
  value: V;
100
152
  };
101
- buckets: Record<string, MeshBucket<P>>;
153
+ nodeBucket: Record<keyof S, MeshBucket<P>>;
102
154
  notifyKeys: Set<keyof S>;
103
155
  dirtySignal: any;
104
156
  meta: S;
105
157
  dependOn: (cb: (val: V) => V) => void;
158
+ createView: (extraProps?: Record<string, any>) => any;
106
159
  }
107
160
  interface MeshFlowGroupNode<P extends MeshPath = MeshPath> {
108
161
  path: P;
109
162
  uid: number;
110
163
  type: 'group';
111
164
  children: Array<P>;
165
+ dirtySignal: any;
112
166
  meta: Record<string, any>;
113
167
  }
114
- interface DependOnContext<P extends MeshPath> {
115
- path: P;
116
- getNode: (path: P) => MeshFlowTaskNode<P>;
117
- }
118
-
119
- type ContractType = 'boolean' | 'scalar' | 'array' | 'object';
120
- declare enum DefaultStarategy {
121
- OR = "OR",
122
- PRIORITY = "PRIORITY"
123
- }
124
- declare class SchemaBucket<P> {
125
- private path;
126
- private strategy;
127
- contract: ContractType;
128
- private rules;
129
- private isValue;
130
- private id;
131
- private cache;
132
- private pendingPromise;
133
- private version;
134
- private deps;
135
- private _forceNotify;
136
- promiseToken: any;
137
- private effectArray;
138
- constructor(baseValue: any, key: string, path: P);
139
- forceNotify(): void;
140
- isForceNotify(): boolean;
141
- setStrategy(type: DefaultStarategy): void;
142
- setDefaultRule(value: any): void;
143
- setRules(value: any, DepsArray?: Array<[P, any]>): () => void;
144
- updateDeps(DepsArray: Array<[P, any]>): void;
145
- setRule(value: any, DepsArray?: Array<[P, any]>): (() => void) | undefined;
146
- setSideEffect(data: {
147
- fn: (args: any[]) => any;
148
- args: any[];
149
- }): void;
150
- getSideEffect(): {
151
- fn: (args: any) => any;
152
- args: any[];
153
- }[];
154
- evaluate(api: any): any;
155
- private finalizeSync;
156
- private inferType;
157
- }
158
-
159
- type FinalFlatten<T> = T extends infer O ? {
160
- [K in keyof O]: O[K];
161
- } : never;
162
- type Unwrap<T> = T extends ReadonlyArray<infer U> ? U : T;
163
- type InferLeafPath<T, Prefix extends string = ""> = Unwrap<T> extends infer Node ? Node extends {
164
- readonly name: infer N;
165
- } ? N extends string ? N extends "" ? Node extends {
166
- readonly children: infer C;
167
- } ? InferLeafPath<C, Prefix> : never : (Node extends {
168
- readonly children: infer C;
169
- } ? InferLeafPath<C, Prefix extends "" ? N : `${Prefix}.${N}`> : (Prefix extends "" ? N : `${Prefix}.${N}`)) : N extends number | symbol ? Node extends {
170
- readonly children: infer C;
171
- } ? InferLeafPath<C, Prefix> : N : never : never : never;
172
- type KeysOfUnion<T> = T extends any ? keyof T : never;
173
-
174
- type BaseField = {
175
- label: string;
176
- name: string;
177
- placeholder?: string;
178
- disabled: boolean;
179
- readonly: boolean;
180
- hidden?: boolean;
181
- validators?: any;
182
- theme?: string;
183
- };
184
- type InputField = BaseField & {
185
- type: "input" | "number";
186
- required: boolean;
187
- min?: number;
188
- maxLength: number;
189
- value: string | number;
190
- };
191
- type CheckboxField = BaseField & {
192
- type: "checkbox";
193
- description?: string;
194
- required: boolean;
195
- value: boolean;
196
- };
197
- type SelectField = BaseField & {
198
- type: "select";
199
- required: boolean;
200
- options: {
201
- label: string;
202
- value: any;
203
- }[];
204
- value: any;
205
- };
206
- type GroupField = Omit<BaseField, "label" | "name" | "placeholder" | "validators"> & {
207
- type: "group";
208
- name?: string;
209
- children: FormFieldSchema[];
210
- };
211
- type FormFieldSchema = InputField | CheckboxField | SelectField | GroupField;
212
- type RenderSchemaExtraCommonType<P = any> = {
213
- path: P;
214
- dirtySignal: any;
215
- uid: number;
216
- nodeBucket: Record<string, SchemaBucket<P>>;
217
- dependOn: (cb: (...args: any) => void) => void;
218
- };
219
- type RenderSchemaFn<T> = FinalFlatten<T extends GroupField ? Omit<T, "children"> & RenderSchemaExtraCommonType & {
220
- children: Array<RenderSchemaFn<FormFieldSchema>>;
221
- } : T & RenderSchemaExtraCommonType>;
222
- type RenderSchema = RenderSchemaFn<FormFieldSchema>;
223
-
224
168
  interface logicApi {
225
169
  slot: {
226
170
  triggerTargets: any;
227
171
  affectedTatget: any;
228
172
  };
229
173
  }
174
+ interface SetRuleOptions<NM> {
175
+ value?: any;
176
+ priority?: number;
177
+ forceNotify?: boolean;
178
+ logic: (api: logicApi) => any;
179
+ effect?: (args: any) => any;
180
+ effectArgs?: Array<KeysOfUnion<NM>>;
181
+ }
230
182
 
231
- declare function useEngineInstance<T, P extends MeshPath>(data: any, options: {
183
+ /**
184
+ * 🌟 入口函数
185
+ * @template T - UI 信号类型 (Signal)
186
+ * @template P - 路径联合类型 ("user.name" | "user.age") 也支持number或者symbol
187
+ * @template S - 业务元数据类型 (默认使用表单的 Meta,但也允许传入 any)
188
+ */
189
+ declare function useEngineInstance<T, P extends MeshPath, S = any, NM = any>(data: S, options: {
232
190
  config: {
233
191
  useGreedy: boolean;
234
192
  };
235
193
  UITrigger: {
236
- signalCreateor: () => T;
194
+ signalCreator: () => T;
237
195
  signalTrigger: (signal: T) => void;
238
196
  };
239
197
  modules: {
240
198
  useHistory?: () => MeshFlowHistory;
199
+ useInternalForm?: <T, P>(scheduler: any, data: any) => any;
200
+ useSchemaValidators?: <P>(Finder: (path: P) => any) => {
201
+ SetValidators: (path: P, options: {
202
+ logic: (val: any, GetByPath: any) => any;
203
+ condition: (data: any) => boolean;
204
+ }) => void;
205
+ };
241
206
  };
242
207
  plugins: {};
243
208
  }): {
244
- schema: RenderSchema;
245
- SetRule: (outDegreePath: P, inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
246
- value?: any;
247
- priority?: number;
248
- forceNotify?: boolean;
249
- logic: (api: logicApi) => any;
250
- effect?: ((args: any) => any) | undefined;
251
- effectArgs?: Array<KeysOfUnion<Exclude<FormFieldSchema, GroupField>>>;
252
- } | undefined) => void;
253
- SetRules: (outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
254
- value?: any;
255
- priority?: number;
256
- forceNotify?: boolean;
257
- logic: (api: logicApi) => any;
258
- effect?: ((args: any) => any) | undefined;
259
- effectArgs?: Array<KeysOfUnion<Exclude<FormFieldSchema, GroupField>>>;
260
- } | undefined) => void;
261
- SetStrategy: (path: unknown, key: KeysOfUnion<Exclude<FormFieldSchema, GroupField>>, strategy: DefaultStarategy) => void;
262
- SetValidators: (path: P, options: {
263
- logic: (val: any, GetByPath: any) => any;
264
- condition: (data: any) => boolean;
265
- }) => void;
266
- SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => () => void;
209
+ SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
210
+ SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
211
+ SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStarategy) => void;
212
+ SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
213
+ cancel: () => void;
214
+ };
267
215
  usePlugin: (plugin: {
268
216
  apply: (api: {
269
217
  on: (event: MeshEventName, cb: Function) => () => boolean;
@@ -271,13 +219,18 @@ declare function useEngineInstance<T, P extends MeshPath>(data: any, options: {
271
219
  }) => () => void;
272
220
  SetValue: (path: P, value: any) => void;
273
221
  GetValue: (path: P, key?: string) => any;
274
- GetFormData: () => any;
275
- GetGroupByPath: (path: MeshPath) => RenderSchema | undefined;
222
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
276
223
  notifyAll: () => Promise<void>;
277
- AddNewSchema: (path: string, data: any) => RenderSchema;
278
224
  GetAllDependency: () => Map<P, Set<P>>;
279
225
  GetDependencyOrder: () => P[][];
280
226
  historyExports: Partial<MeshFlowHistory>;
227
+ formExports: {};
228
+ validatorExports: {
229
+ SetValidators?: (path: P, options: {
230
+ logic: (val: any, GetByPath: any) => any;
231
+ condition: (data: any) => boolean;
232
+ }) => void;
233
+ };
281
234
  onError: (cb: (error: MeshErrorContext) => void) => () => void;
282
235
  onSuccess: (cb: (data: unknown) => void) => () => void;
283
236
  onStart: (cb: (data: {
@@ -285,62 +238,125 @@ declare function useEngineInstance<T, P extends MeshPath>(data: any, options: {
285
238
  }) => void) => () => void;
286
239
  };
287
240
 
288
- type SchedulerType<T, P extends MeshPath> = ReturnType<typeof useEngineInstance<T, P>>;
289
- type GetType<T, P> = P extends keyof T ? T[P] : never;
241
+ declare function useScheduler<T, //ui trigger中定义的类型
242
+ P extends MeshPath, // 路径类型
243
+ S = any>(schema: S, config: {
244
+ useGreedy: boolean;
245
+ }, dependency: {
246
+ GetDependencyOrder: () => P[][];
247
+ GetAllNextDependency: (path: P) => P[];
248
+ GetNextDependency: (path: P) => P[];
249
+ GetPrevDependency: (path: P) => P[];
250
+ GetAllPrevDependency: (path: P) => P[];
251
+ GetPathToLevelMap: () => Map<P, number>;
252
+ }, history: Partial<{
253
+ pushIntoHistory: any;
254
+ createHistoryAction: any;
255
+ }>, hooks: {
256
+ callOnError: any;
257
+ callOnSuccess: any;
258
+ callOnStart: any;
259
+ emit: MeshEmit;
260
+ }, UITrigger: {
261
+ signalCreator: () => T;
262
+ signalTrigger: (signal: T) => void;
263
+ }): {
264
+ registerNode: (nodeMeta: Omit<MeshFlowTaskNode<P>, "createView">) => MeshFlowTaskNode<P, any, any>;
265
+ registerGroupNode: (groupMeta: Omit<MeshFlowGroupNode<P>, "createView">) => MeshFlowGroupNode<P>;
266
+ GetNodeByPath: (path: P) => MeshFlowTaskNode<P, any, S>;
267
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
268
+ notify: (path: P) => void;
269
+ notifyAll: () => Promise<void>;
270
+ UITrigger: {
271
+ signalCreator: () => T;
272
+ signalTrigger: (signal: T) => void;
273
+ };
274
+ UidToNodeMap: Map<number, MeshFlowTaskNode<P, any, S>>;
275
+ };
276
+
277
+ type SchedulerType<T, P extends MeshPath, S, NM> = ReturnType<typeof useEngineInstance<T, P, S, NM>>;
290
278
  type BaseEngine<T> = {
291
279
  data: {
292
- [K in "schema" | "GetFormData" | "AddNewSchema" | 'SetValue' | 'GetValue' | 'GetGroupByPath']: GetType<T, K>;
280
+ SetValue: T extends {
281
+ SetValue: infer F;
282
+ } ? F : never;
283
+ GetValue: T extends {
284
+ GetValue: infer F;
285
+ } ? F : never;
286
+ GetGroupByPath: T extends {
287
+ GetGroupByPath: infer F;
288
+ } ? F : never;
293
289
  };
294
290
  config: {
295
- [K in "SetRule" | "SetRules" | "SetStrategy" | "SetValidators" | "notifyAll" | "SetTrace" | "usePlugin"]: GetType<T, K>;
291
+ SetRule: T extends {
292
+ SetRule: infer F;
293
+ } ? F : never;
294
+ SetRules: T extends {
295
+ SetRules: infer F;
296
+ } ? F : never;
297
+ SetStrategy: T extends {
298
+ SetStrategy: infer F;
299
+ } ? F : never;
300
+ notifyAll: T extends {
301
+ notifyAll: infer F;
302
+ } ? F : never;
303
+ SetTrace: T extends {
304
+ SetTrace: infer F;
305
+ } ? F : never;
306
+ usePlugin: T extends {
307
+ usePlugin: infer F;
308
+ } ? F : never;
296
309
  };
297
310
  dependency: {
298
- [K in 'GetAllDependency' | 'GetDependencyOrder']: GetType<T, K>;
311
+ GetAllDependency: T extends {
312
+ GetAllDependency: infer F;
313
+ } ? F : never;
314
+ GetDependencyOrder: T extends {
315
+ GetDependencyOrder: infer F;
316
+ } ? F : never;
299
317
  };
300
318
  hooks: {
301
- [K in "onError" | "onSuccess" | "onStart"]: GetType<T, K>;
319
+ onError: T extends {
320
+ onError: infer F;
321
+ } ? F : never;
322
+ onSuccess: T extends {
323
+ onSuccess: infer F;
324
+ } ? F : never;
325
+ onStart: T extends {
326
+ onStart: infer F;
327
+ } ? F : never;
302
328
  };
303
329
  };
304
- type TransformKey<T> = T extends `use${infer Rest}` ? Uncapitalize<Rest> : T;
305
- type EngineModules<M> = {
306
- [K in keyof M as TransformKey<string & K>]: M[K] extends (...args: any) => infer R ? R : never;
330
+ type TransformModuleKey<T> = T extends `use${infer Rest}` ? Uncapitalize<Rest> : T;
331
+ type MapModuleToReturn<K, F, P extends MeshPath> = K extends 'useSchemaValidators' | 'schemaValidators' ? {
332
+ SetValidators: (path: P, options: {
333
+ logic: (val: any, GetByPath: (path: P) => any) => any;
334
+ condition: (data: any) => boolean;
335
+ }) => void;
336
+ } : F extends (...args: any) => infer R ? R : any;
337
+ type EngineModules<M, P extends MeshPath> = {
338
+ [K in keyof M as TransformModuleKey<string & K>]: MapModuleToReturn<K, M[K], P>;
307
339
  };
308
- type Engine<T, M> = BaseEngine<T> & EngineModules<M>;
340
+ type Engine<T, M, P extends MeshPath> = BaseEngine<T> & EngineModules<M, P>;
309
341
  /** @deprecated 请使用新的 useMeshFlow 别名 */
310
342
  declare const useEngineManager: <const S extends Record<string, any>, T, //UITrigger的类型
311
- M extends Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
343
+ M extends Record<string, any>, NM extends Record<string, any> = Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
344
+ metaType?: NM;
312
345
  config?: {
313
346
  useGreedy: boolean;
314
347
  };
315
348
  modules?: M;
316
349
  UITrigger: {
317
- signalCreateor: () => T;
350
+ signalCreator: () => T;
318
351
  signalTrigger: (signal: T) => void;
319
352
  };
320
353
  }) => Engine<{
321
- schema: RenderSchema;
322
- SetRule: (outDegreePath: P, inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
323
- value?: any;
324
- priority?: number;
325
- forceNotify?: boolean;
326
- logic: (api: logicApi) => any;
327
- effect?: ((args: any) => any) | undefined;
328
- effectArgs?: Array<KeysOfUnion<Exclude<FormFieldSchema, GroupField>>>;
329
- } | undefined) => void;
330
- SetRules: (outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
331
- value?: any;
332
- priority?: number;
333
- forceNotify?: boolean;
334
- logic: (api: logicApi) => any;
335
- effect?: ((args: any) => any) | undefined;
336
- effectArgs?: Array<KeysOfUnion<Exclude<FormFieldSchema, GroupField>>>;
337
- } | undefined) => void;
338
- SetStrategy: (path: unknown, key: KeysOfUnion<Exclude<FormFieldSchema, GroupField>>, strategy: DefaultStarategy) => void;
339
- SetValidators: (path: P, options: {
340
- logic: (val: any, GetByPath: any) => any;
341
- condition: (data: any) => boolean;
342
- }) => void;
343
- SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => () => void;
354
+ SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
355
+ SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
356
+ SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStarategy) => void;
357
+ SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
358
+ cancel: () => void;
359
+ };
344
360
  usePlugin: (plugin: {
345
361
  apply: (api: {
346
362
  on: (event: MeshEventName, cb: Function) => () => boolean;
@@ -348,67 +364,57 @@ M extends Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [
348
364
  }) => () => void;
349
365
  SetValue: (path: P, value: any) => void;
350
366
  GetValue: (path: P, key?: string) => any;
351
- GetFormData: () => any;
352
- GetGroupByPath: (path: MeshPath) => RenderSchema | undefined;
367
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
353
368
  notifyAll: () => Promise<void>;
354
- AddNewSchema: (path: string, data: any) => RenderSchema;
355
369
  GetAllDependency: () => Map<P, Set<P>>;
356
370
  GetDependencyOrder: () => P[][];
357
371
  historyExports: Partial<MeshFlowHistory>;
372
+ formExports: {};
373
+ validatorExports: {
374
+ SetValidators?: ((path: P, options: {
375
+ logic: (val: any, GetByPath: any) => any;
376
+ condition: (data: any) => boolean;
377
+ }) => void) | undefined;
378
+ };
358
379
  onError: (cb: (error: MeshErrorContext) => void) => () => void;
359
380
  onSuccess: (cb: (data: unknown) => void) => () => void;
360
381
  onStart: (cb: (data: {
361
382
  path: P;
362
383
  }) => void) => () => void;
363
- }, M>;
364
- declare const useMeshFlowDefiner: <P extends string>() => <T, M extends Record<string, any>>(id: MeshPath, schema: any, options: {
384
+ }, M, P>;
385
+ declare const useMeshFlowDefiner: <P extends MeshPath, NM extends Record<string, any> = any>() => <T, M extends Record<string, any>>(id: MeshPath, schema: any, options: {
386
+ metaType?: NM;
365
387
  UITrigger: {
366
- signalCreateor: () => T;
388
+ signalCreator: () => T;
367
389
  signalTrigger: (s: T) => void;
368
390
  };
369
391
  modules?: M;
370
392
  config?: any;
371
- }) => Engine<ReturnType<typeof useEngineInstance<T, P>>, M>;
393
+ }) => Engine<SchedulerType<T, P, any, NM>, M, P>;
372
394
  /**
373
395
  * 获取 Engine 实例
374
396
  * @template M 手动注入的模块映射 (例如 { useHistory: typeof useHistory })
375
- * @template K ID 类型 (支持 string | number | symbol)
397
+ * @template P ID 类型 (支持 string | number | symbol)
376
398
  */
377
- declare const useEngine: <M, ID extends keyof MeshFlowEngineMap | (MeshPath & {}) = MeshPath>(id: ID) => [M] extends [never] ? (ID extends keyof MeshFlowEngineMap ? MeshFlowEngineMap[ID] : Engine<SchedulerType<any, any>, {}>) : Engine<SchedulerType<any, any>, M>;
399
+ 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>;
378
400
  declare const deleteEngine: (id: MeshPath) => void;
379
- declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
401
+ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Record<string, any>, NM extends Record<string, any> = Record<string, any>, P extends MeshPath = [InferLeafPath<S>] extends [never] ? MeshPath : InferLeafPath<S> | (string & {})>(id: MeshPath, Schema: S, options: {
402
+ metaType?: NM;
380
403
  config?: {
381
404
  useGreedy: boolean;
382
405
  };
383
406
  modules?: M;
384
407
  UITrigger: {
385
- signalCreateor: () => T;
408
+ signalCreator: () => T;
386
409
  signalTrigger: (signal: T) => void;
387
410
  };
388
411
  }) => Engine<{
389
- schema: RenderSchema;
390
- SetRule: (outDegreePath: P, inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
391
- value?: any;
392
- priority?: number;
393
- forceNotify?: boolean;
394
- logic: (api: logicApi) => any;
395
- effect?: ((args: any) => any) | undefined;
396
- effectArgs?: Array<KeysOfUnion<Exclude<FormFieldSchema, GroupField>>>;
397
- } | undefined) => void;
398
- SetRules: (outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
399
- value?: any;
400
- priority?: number;
401
- forceNotify?: boolean;
402
- logic: (api: logicApi) => any;
403
- effect?: ((args: any) => any) | undefined;
404
- effectArgs?: Array<KeysOfUnion<Exclude<FormFieldSchema, GroupField>>>;
405
- } | undefined) => void;
406
- SetStrategy: (path: unknown, key: KeysOfUnion<Exclude<FormFieldSchema, GroupField>>, strategy: DefaultStarategy) => void;
407
- SetValidators: (path: P, options: {
408
- logic: (val: any, GetByPath: any) => any;
409
- condition: (data: any) => boolean;
410
- }) => void;
411
- SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => () => void;
412
+ SetRule: <K extends KeysOfUnion<NM>>(outDegreePath: P, inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
413
+ SetRules: <K extends KeysOfUnion<NM>>(outDegreePaths: P[], inDegreePath: P, key: K, options: SetRuleOptions<NM>) => void;
414
+ SetStrategy: (path: P, key: KeysOfUnion<NM>, strategy: DefaultStarategy) => void;
415
+ SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void) => {
416
+ cancel: () => void;
417
+ };
412
418
  usePlugin: (plugin: {
413
419
  apply: (api: {
414
420
  on: (event: MeshEventName, cb: Function) => () => boolean;
@@ -416,18 +422,23 @@ declare const useMeshFlow: <const S extends Record<string, any>, T, M extends Re
416
422
  }) => () => void;
417
423
  SetValue: (path: P, value: any) => void;
418
424
  GetValue: (path: P, key?: string) => any;
419
- GetFormData: () => any;
420
- GetGroupByPath: (path: MeshPath) => RenderSchema | undefined;
425
+ GetGroupByPath: (path: MeshPath) => MeshFlowGroupNode<MeshPath> | undefined;
421
426
  notifyAll: () => Promise<void>;
422
- AddNewSchema: (path: string, data: any) => RenderSchema;
423
427
  GetAllDependency: () => Map<P, Set<P>>;
424
428
  GetDependencyOrder: () => P[][];
425
429
  historyExports: Partial<MeshFlowHistory>;
430
+ formExports: {};
431
+ validatorExports: {
432
+ SetValidators?: ((path: P, options: {
433
+ logic: (val: any, GetByPath: any) => any;
434
+ condition: (data: any) => boolean;
435
+ }) => void) | undefined;
436
+ };
426
437
  onError: (cb: (error: MeshErrorContext) => void) => () => void;
427
438
  onSuccess: (cb: (data: unknown) => void) => () => void;
428
439
  onStart: (cb: (data: {
429
440
  path: P;
430
441
  }) => void) => () => void;
431
- }, M>;
442
+ }, M, P>;
432
443
 
433
- export { type DependOnContext, type HistoryActionItem, type MeshBucket, type MeshEmit, type MeshEventName, type MeshEvents, type MeshFlowEngineMap, type MeshFlowGroupNode, type MeshFlowHistory, type MeshFlowTaskNode, type MeshPath, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner };
444
+ export { type MeshPath, SchemaBucket, type SetRuleOptions, deleteEngine, useEngine, useEngineManager, useMeshFlow, useMeshFlowDefiner, useScheduler };