@meshflow/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +405 -0
- package/index.d.ts +405 -0
- package/index.js +1 -0
- package/index.mjs +1 -0
- package/package.json +20 -0
package/index.d.mts
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
interface MeshErrorContext {
|
|
2
|
+
path: string;
|
|
3
|
+
info: any;
|
|
4
|
+
}
|
|
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 isDefaultValue;
|
|
17
|
+
private id;
|
|
18
|
+
private cache;
|
|
19
|
+
private pendingPromise;
|
|
20
|
+
private version;
|
|
21
|
+
private deps;
|
|
22
|
+
private _forceNotify;
|
|
23
|
+
promiseToken: any;
|
|
24
|
+
globalCalcCount: number;
|
|
25
|
+
constructor(baseValue: any, key: string, path: P);
|
|
26
|
+
forceNotify(): void;
|
|
27
|
+
isForceNotify(): boolean;
|
|
28
|
+
setStrategy(type: DefaultStarategy): void;
|
|
29
|
+
updateInputValueRule(newVal: any): void;
|
|
30
|
+
setDefaultRule(value: any): void;
|
|
31
|
+
setRules(value: any, DepsArray?: Array<[P, any]>): () => void;
|
|
32
|
+
updateDeps(DepsArray: Array<[P, any]>): void;
|
|
33
|
+
setRule(value: any, DepsArray?: Array<[P, any]>): (() => void) | undefined;
|
|
34
|
+
evaluate(api: any): Promise<any>;
|
|
35
|
+
private inferType;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type FinalFlatten<T> = T extends infer O ? {
|
|
39
|
+
[K in keyof O]: O[K];
|
|
40
|
+
} : never;
|
|
41
|
+
type GetAllPath<T, Path = ''> = T extends object ? {
|
|
42
|
+
[K in keyof T]: GetAllPath<T[K], Path extends "" ? K : `${Path & string}.${K & string}`>;
|
|
43
|
+
}[keyof T] : Path;
|
|
44
|
+
type KeysOfUnion<T> = T extends any ? keyof T : never;
|
|
45
|
+
|
|
46
|
+
declare const clonedschema: {
|
|
47
|
+
readonly type: "group";
|
|
48
|
+
readonly name: "cloudConsole";
|
|
49
|
+
readonly label: "云资源采购中心 (专家版)";
|
|
50
|
+
readonly children: readonly [{
|
|
51
|
+
readonly type: "group";
|
|
52
|
+
readonly name: "environment";
|
|
53
|
+
readonly label: "环境与合规策略";
|
|
54
|
+
readonly children: readonly [{
|
|
55
|
+
readonly type: "select";
|
|
56
|
+
readonly name: "region";
|
|
57
|
+
readonly label: "部署地域";
|
|
58
|
+
readonly defaultValue: "china";
|
|
59
|
+
readonly required: true;
|
|
60
|
+
readonly options: readonly [{
|
|
61
|
+
readonly label: "中国大陆 (华北、华东、华南)";
|
|
62
|
+
readonly value: "china";
|
|
63
|
+
}, {
|
|
64
|
+
readonly label: "全球海外 (香港、新加坡、美国)";
|
|
65
|
+
readonly value: "global";
|
|
66
|
+
}];
|
|
67
|
+
}, {
|
|
68
|
+
readonly type: "select";
|
|
69
|
+
readonly name: "compliance";
|
|
70
|
+
readonly label: "合规性分级";
|
|
71
|
+
readonly defaultValue: "standard";
|
|
72
|
+
readonly required: true;
|
|
73
|
+
readonly options: readonly [{
|
|
74
|
+
readonly label: "Level 1: 标准合规 (Standard)";
|
|
75
|
+
readonly value: "standard";
|
|
76
|
+
}, {
|
|
77
|
+
readonly label: "Level 2: 高安全性 (High Security)";
|
|
78
|
+
readonly value: "high_security";
|
|
79
|
+
}, {
|
|
80
|
+
readonly label: "Level 3: 金融级监管 (Financial)";
|
|
81
|
+
readonly value: "financial";
|
|
82
|
+
}];
|
|
83
|
+
readonly description: "合规等级越高,可选资源规格越严格";
|
|
84
|
+
}];
|
|
85
|
+
}, {
|
|
86
|
+
readonly type: "group";
|
|
87
|
+
readonly name: "specs";
|
|
88
|
+
readonly label: "核心资源配置";
|
|
89
|
+
readonly children: readonly [{
|
|
90
|
+
readonly type: "select";
|
|
91
|
+
readonly name: "instanceFamily";
|
|
92
|
+
readonly label: "实例家族";
|
|
93
|
+
readonly defaultValue: "general";
|
|
94
|
+
readonly required: true;
|
|
95
|
+
readonly options: readonly [{
|
|
96
|
+
readonly label: "通用型 (g6)";
|
|
97
|
+
readonly value: "general";
|
|
98
|
+
}, {
|
|
99
|
+
readonly label: "计算型 (c6)";
|
|
100
|
+
readonly value: "compute";
|
|
101
|
+
}, {
|
|
102
|
+
readonly label: "GPU 训练型 (gn7)";
|
|
103
|
+
readonly value: "gpu";
|
|
104
|
+
}, {
|
|
105
|
+
readonly label: "高 IO 型 (i3)";
|
|
106
|
+
readonly value: "high_io";
|
|
107
|
+
}];
|
|
108
|
+
readonly message: "";
|
|
109
|
+
}, {
|
|
110
|
+
readonly type: "group";
|
|
111
|
+
readonly name: "storage";
|
|
112
|
+
readonly label: "存储方案";
|
|
113
|
+
readonly children: readonly [{
|
|
114
|
+
readonly type: "select";
|
|
115
|
+
readonly name: "diskType";
|
|
116
|
+
readonly label: "系统盘类型";
|
|
117
|
+
readonly defaultValue: "ssd";
|
|
118
|
+
readonly required: true;
|
|
119
|
+
readonly options: readonly [{
|
|
120
|
+
readonly label: "ESSD 增强型 SSD";
|
|
121
|
+
readonly value: "essd";
|
|
122
|
+
}, {
|
|
123
|
+
readonly label: "标准 SSD";
|
|
124
|
+
readonly value: "ssd";
|
|
125
|
+
}, {
|
|
126
|
+
readonly label: "高效云盘 (HDD)";
|
|
127
|
+
readonly value: "hdd";
|
|
128
|
+
}];
|
|
129
|
+
}, {
|
|
130
|
+
readonly type: "number";
|
|
131
|
+
readonly name: "capacity";
|
|
132
|
+
readonly label: "系统盘容量 (GB)";
|
|
133
|
+
readonly defaultValue: 40;
|
|
134
|
+
readonly min: 20;
|
|
135
|
+
readonly max: 32768;
|
|
136
|
+
readonly step: 10;
|
|
137
|
+
readonly required: true;
|
|
138
|
+
readonly message: "";
|
|
139
|
+
}];
|
|
140
|
+
}];
|
|
141
|
+
}, {
|
|
142
|
+
readonly type: "group";
|
|
143
|
+
readonly name: "security";
|
|
144
|
+
readonly label: "安全加固选项";
|
|
145
|
+
readonly children: readonly [{
|
|
146
|
+
readonly type: "select";
|
|
147
|
+
readonly name: "encryption";
|
|
148
|
+
readonly label: "数据盘加密";
|
|
149
|
+
readonly defaultValue: "no";
|
|
150
|
+
readonly required: true;
|
|
151
|
+
readonly options: readonly [{
|
|
152
|
+
readonly label: "开启落盘加密 (KMS)";
|
|
153
|
+
readonly value: "yes";
|
|
154
|
+
}, {
|
|
155
|
+
readonly label: "暂不开启";
|
|
156
|
+
readonly value: "no";
|
|
157
|
+
}];
|
|
158
|
+
}, {
|
|
159
|
+
readonly type: "input";
|
|
160
|
+
readonly name: "kmsKey";
|
|
161
|
+
readonly label: "KMS 密钥 ID";
|
|
162
|
+
readonly defaultValue: "";
|
|
163
|
+
readonly maxLength: 8;
|
|
164
|
+
readonly hidden: true;
|
|
165
|
+
readonly required: false;
|
|
166
|
+
readonly placeholder: "请输入云平台提供的密钥 UUID";
|
|
167
|
+
}];
|
|
168
|
+
}, {
|
|
169
|
+
readonly type: "group";
|
|
170
|
+
readonly name: "billing";
|
|
171
|
+
readonly label: "计费与汇总";
|
|
172
|
+
readonly children: readonly [{
|
|
173
|
+
readonly type: "number";
|
|
174
|
+
readonly name: "totalPrice";
|
|
175
|
+
readonly label: "预估月度总价";
|
|
176
|
+
readonly defaultValue: 0;
|
|
177
|
+
readonly readonly: true;
|
|
178
|
+
readonly required: true;
|
|
179
|
+
readonly prefix: "¥";
|
|
180
|
+
}, {
|
|
181
|
+
readonly type: "input";
|
|
182
|
+
readonly name: "priceDetail";
|
|
183
|
+
readonly label: "计费项说明";
|
|
184
|
+
readonly defaultValue: "基础配置费用";
|
|
185
|
+
readonly readonly: true;
|
|
186
|
+
readonly required: false;
|
|
187
|
+
readonly hidden: false;
|
|
188
|
+
}, {
|
|
189
|
+
readonly type: "checkbox";
|
|
190
|
+
readonly name: "autoRenew";
|
|
191
|
+
readonly label: "开启自动续费";
|
|
192
|
+
readonly defaultValue: false;
|
|
193
|
+
readonly disabled: false;
|
|
194
|
+
readonly description: "暂不支持自动续费";
|
|
195
|
+
}];
|
|
196
|
+
}];
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
type FormDataModel = FormResultType<typeof clonedschema>;
|
|
200
|
+
type AllPath = GetAllPath<FormDataModel> | (string & {});
|
|
201
|
+
|
|
202
|
+
type BaseField = {
|
|
203
|
+
label: string;
|
|
204
|
+
name: string;
|
|
205
|
+
placeholder?: string;
|
|
206
|
+
disabled: boolean;
|
|
207
|
+
readonly: boolean;
|
|
208
|
+
hidden?: boolean;
|
|
209
|
+
validators?: any;
|
|
210
|
+
theme?: string;
|
|
211
|
+
};
|
|
212
|
+
type InputField = BaseField & {
|
|
213
|
+
type: "input" | "number";
|
|
214
|
+
required: boolean;
|
|
215
|
+
min?: number;
|
|
216
|
+
maxLength: number;
|
|
217
|
+
defaultValue: string | number;
|
|
218
|
+
};
|
|
219
|
+
type CheckboxField = BaseField & {
|
|
220
|
+
type: "checkbox";
|
|
221
|
+
description?: string;
|
|
222
|
+
required: boolean;
|
|
223
|
+
defaultValue: boolean;
|
|
224
|
+
};
|
|
225
|
+
type SelectField = BaseField & {
|
|
226
|
+
type: "select";
|
|
227
|
+
required: boolean;
|
|
228
|
+
options: {
|
|
229
|
+
label: string;
|
|
230
|
+
value: any;
|
|
231
|
+
}[];
|
|
232
|
+
defaultValue: any;
|
|
233
|
+
};
|
|
234
|
+
type GroupField = Omit<BaseField, "label" | "name" | "placeholder" | "validators"> & {
|
|
235
|
+
type: "group";
|
|
236
|
+
name?: string;
|
|
237
|
+
children: FormFieldSchema[];
|
|
238
|
+
};
|
|
239
|
+
type FormFieldSchema = InputField | CheckboxField | SelectField | GroupField;
|
|
240
|
+
type RenderSchemaExtraCommonType<P = any> = {
|
|
241
|
+
path: AllPath;
|
|
242
|
+
dirtySignal: any;
|
|
243
|
+
uid: number;
|
|
244
|
+
nodeBucket: Record<string, SchemaBucket<P>>;
|
|
245
|
+
dependOn: (cb: (...args: any) => void) => void;
|
|
246
|
+
};
|
|
247
|
+
type RenderSchemaFn<T> = FinalFlatten<T extends GroupField ? Omit<T, "children"> & RenderSchemaExtraCommonType & {
|
|
248
|
+
children: Array<RenderSchemaFn<FormFieldSchema>>;
|
|
249
|
+
} : T & RenderSchemaExtraCommonType>;
|
|
250
|
+
type RenderSchema = RenderSchemaFn<FormFieldSchema>;
|
|
251
|
+
type CollapseChildren<T> = T extends readonly [infer First, ...infer Rest] ? FormResultType<First> & CollapseChildren<Rest> : {};
|
|
252
|
+
type FormResultType<T> = T extends any ? T extends {
|
|
253
|
+
readonly type: "group";
|
|
254
|
+
readonly name: infer N;
|
|
255
|
+
readonly children: infer C;
|
|
256
|
+
} ? N extends string ? N extends "" ? FinalFlatten<CollapseChildren<C>> : {
|
|
257
|
+
[K in N]: FinalFlatten<CollapseChildren<C>>;
|
|
258
|
+
} : FinalFlatten<CollapseChildren<C>> : T extends {
|
|
259
|
+
readonly name: infer N;
|
|
260
|
+
readonly defaultValue: infer V;
|
|
261
|
+
} ? N extends string ? {
|
|
262
|
+
[K in N]: FinalFlatten<V>;
|
|
263
|
+
} : never : {} : {};
|
|
264
|
+
|
|
265
|
+
interface logicApi {
|
|
266
|
+
slot: {
|
|
267
|
+
triggerTargets: any;
|
|
268
|
+
affectedTatget: any;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
type GetType<T, P> = P extends keyof T ? T[P] : never;
|
|
273
|
+
type Engine<T> = {
|
|
274
|
+
data: {
|
|
275
|
+
[K in "schema" | "GetFormData" | "AddNewSchema" | 'SetValue']: GetType<T, K>;
|
|
276
|
+
};
|
|
277
|
+
config: {
|
|
278
|
+
[K in "SetRule" | "SetRules" | "SetStrategy" | "SetValidators" | "notifyAll" | "SetTrace"]: GetType<T, K>;
|
|
279
|
+
};
|
|
280
|
+
dependency: {
|
|
281
|
+
[K in 'GetAllDependency' | 'GetDependencyOrder']: GetType<T, K>;
|
|
282
|
+
};
|
|
283
|
+
history: {
|
|
284
|
+
[K in "Undo" | "Redo" | "initCanUndo" | "initCanRedo"]: GetType<T, K>;
|
|
285
|
+
};
|
|
286
|
+
hooks: {
|
|
287
|
+
[K in "onError"]: GetType<T, K>;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
declare const useEngineManager: <T, P extends string>(id: string | symbol, Schema: any, UITrigger: {
|
|
291
|
+
signalCreateor: () => T;
|
|
292
|
+
signalTrigger: (signal: T) => void;
|
|
293
|
+
}) => Engine<{
|
|
294
|
+
schema: RenderSchema;
|
|
295
|
+
SetRule: (outDegreePath: P, inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
|
|
296
|
+
value?: any;
|
|
297
|
+
priority?: number;
|
|
298
|
+
forceNotify?: boolean;
|
|
299
|
+
logic: (api: logicApi) => any;
|
|
300
|
+
} | undefined) => void;
|
|
301
|
+
SetRules: (outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
|
|
302
|
+
value?: any;
|
|
303
|
+
priority?: number;
|
|
304
|
+
forceNotify?: boolean;
|
|
305
|
+
logic: (api: logicApi) => any;
|
|
306
|
+
} | undefined) => void;
|
|
307
|
+
SetStrategy: (path: unknown, key: KeysOfUnion<Exclude<FormFieldSchema, GroupField>>, strategy: DefaultStarategy) => void;
|
|
308
|
+
SetValidators: (path: P, options: {
|
|
309
|
+
logic: (val: any, GetByPath: any) => any;
|
|
310
|
+
condition: (data: any) => boolean;
|
|
311
|
+
}) => void;
|
|
312
|
+
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void, context: any) => () => void;
|
|
313
|
+
SetValue: (path: P, value: any) => void;
|
|
314
|
+
GetFormData: () => {
|
|
315
|
+
cloudConsole: {
|
|
316
|
+
environment: {
|
|
317
|
+
region: "china";
|
|
318
|
+
compliance: "standard";
|
|
319
|
+
};
|
|
320
|
+
specs: {
|
|
321
|
+
instanceFamily: "general";
|
|
322
|
+
storage: {
|
|
323
|
+
diskType: "ssd";
|
|
324
|
+
capacity: 40;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
security: {
|
|
328
|
+
encryption: "no";
|
|
329
|
+
kmsKey: "";
|
|
330
|
+
};
|
|
331
|
+
billing: {
|
|
332
|
+
totalPrice: 0;
|
|
333
|
+
priceDetail: "基础配置费用";
|
|
334
|
+
autoRenew: false;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
notifyAll: () => void;
|
|
339
|
+
AddNewSchema: (path: string, data: any) => RenderSchema;
|
|
340
|
+
GetAllDependency: () => Map<P, Set<P>>;
|
|
341
|
+
GetDependencyOrder: () => P[][];
|
|
342
|
+
Undo: () => void;
|
|
343
|
+
Redo: () => void;
|
|
344
|
+
initCanUndo: (cb: (newVal: number) => any) => void;
|
|
345
|
+
initCanRedo: (cb: (newVal: number) => any) => void;
|
|
346
|
+
onError: (cb: (error: MeshErrorContext) => void) => () => void;
|
|
347
|
+
}>;
|
|
348
|
+
declare const useEngine: <T = any, P extends string = string>(id: string | symbol) => Engine<{
|
|
349
|
+
schema: RenderSchema;
|
|
350
|
+
SetRule: (outDegreePath: P, inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
|
|
351
|
+
value?: any;
|
|
352
|
+
priority?: number;
|
|
353
|
+
forceNotify?: boolean;
|
|
354
|
+
logic: (api: logicApi) => any;
|
|
355
|
+
} | undefined) => void;
|
|
356
|
+
SetRules: (outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
|
|
357
|
+
value?: any;
|
|
358
|
+
priority?: number;
|
|
359
|
+
forceNotify?: boolean;
|
|
360
|
+
logic: (api: logicApi) => any;
|
|
361
|
+
} | undefined) => void;
|
|
362
|
+
SetStrategy: (path: unknown, key: KeysOfUnion<Exclude<FormFieldSchema, GroupField>>, strategy: DefaultStarategy) => void;
|
|
363
|
+
SetValidators: (path: P, options: {
|
|
364
|
+
logic: (val: any, GetByPath: any) => any;
|
|
365
|
+
condition: (data: any) => boolean;
|
|
366
|
+
}) => void;
|
|
367
|
+
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void, context: any) => () => void;
|
|
368
|
+
SetValue: (path: P, value: any) => void;
|
|
369
|
+
GetFormData: () => {
|
|
370
|
+
cloudConsole: {
|
|
371
|
+
environment: {
|
|
372
|
+
region: "china";
|
|
373
|
+
compliance: "standard";
|
|
374
|
+
};
|
|
375
|
+
specs: {
|
|
376
|
+
instanceFamily: "general";
|
|
377
|
+
storage: {
|
|
378
|
+
diskType: "ssd";
|
|
379
|
+
capacity: 40;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
security: {
|
|
383
|
+
encryption: "no";
|
|
384
|
+
kmsKey: "";
|
|
385
|
+
};
|
|
386
|
+
billing: {
|
|
387
|
+
totalPrice: 0;
|
|
388
|
+
priceDetail: "基础配置费用";
|
|
389
|
+
autoRenew: false;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
notifyAll: () => void;
|
|
394
|
+
AddNewSchema: (path: string, data: any) => RenderSchema;
|
|
395
|
+
GetAllDependency: () => Map<P, Set<P>>;
|
|
396
|
+
GetDependencyOrder: () => P[][];
|
|
397
|
+
Undo: () => void;
|
|
398
|
+
Redo: () => void;
|
|
399
|
+
initCanUndo: (cb: (newVal: number) => any) => void;
|
|
400
|
+
initCanRedo: (cb: (newVal: number) => any) => void;
|
|
401
|
+
onError: (cb: (error: MeshErrorContext) => void) => () => void;
|
|
402
|
+
}>;
|
|
403
|
+
declare const deleteEngine: (id: string | symbol) => void;
|
|
404
|
+
|
|
405
|
+
export { deleteEngine, useEngine, useEngineManager };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
interface MeshErrorContext {
|
|
2
|
+
path: string;
|
|
3
|
+
info: any;
|
|
4
|
+
}
|
|
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 isDefaultValue;
|
|
17
|
+
private id;
|
|
18
|
+
private cache;
|
|
19
|
+
private pendingPromise;
|
|
20
|
+
private version;
|
|
21
|
+
private deps;
|
|
22
|
+
private _forceNotify;
|
|
23
|
+
promiseToken: any;
|
|
24
|
+
globalCalcCount: number;
|
|
25
|
+
constructor(baseValue: any, key: string, path: P);
|
|
26
|
+
forceNotify(): void;
|
|
27
|
+
isForceNotify(): boolean;
|
|
28
|
+
setStrategy(type: DefaultStarategy): void;
|
|
29
|
+
updateInputValueRule(newVal: any): void;
|
|
30
|
+
setDefaultRule(value: any): void;
|
|
31
|
+
setRules(value: any, DepsArray?: Array<[P, any]>): () => void;
|
|
32
|
+
updateDeps(DepsArray: Array<[P, any]>): void;
|
|
33
|
+
setRule(value: any, DepsArray?: Array<[P, any]>): (() => void) | undefined;
|
|
34
|
+
evaluate(api: any): Promise<any>;
|
|
35
|
+
private inferType;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type FinalFlatten<T> = T extends infer O ? {
|
|
39
|
+
[K in keyof O]: O[K];
|
|
40
|
+
} : never;
|
|
41
|
+
type GetAllPath<T, Path = ''> = T extends object ? {
|
|
42
|
+
[K in keyof T]: GetAllPath<T[K], Path extends "" ? K : `${Path & string}.${K & string}`>;
|
|
43
|
+
}[keyof T] : Path;
|
|
44
|
+
type KeysOfUnion<T> = T extends any ? keyof T : never;
|
|
45
|
+
|
|
46
|
+
declare const clonedschema: {
|
|
47
|
+
readonly type: "group";
|
|
48
|
+
readonly name: "cloudConsole";
|
|
49
|
+
readonly label: "云资源采购中心 (专家版)";
|
|
50
|
+
readonly children: readonly [{
|
|
51
|
+
readonly type: "group";
|
|
52
|
+
readonly name: "environment";
|
|
53
|
+
readonly label: "环境与合规策略";
|
|
54
|
+
readonly children: readonly [{
|
|
55
|
+
readonly type: "select";
|
|
56
|
+
readonly name: "region";
|
|
57
|
+
readonly label: "部署地域";
|
|
58
|
+
readonly defaultValue: "china";
|
|
59
|
+
readonly required: true;
|
|
60
|
+
readonly options: readonly [{
|
|
61
|
+
readonly label: "中国大陆 (华北、华东、华南)";
|
|
62
|
+
readonly value: "china";
|
|
63
|
+
}, {
|
|
64
|
+
readonly label: "全球海外 (香港、新加坡、美国)";
|
|
65
|
+
readonly value: "global";
|
|
66
|
+
}];
|
|
67
|
+
}, {
|
|
68
|
+
readonly type: "select";
|
|
69
|
+
readonly name: "compliance";
|
|
70
|
+
readonly label: "合规性分级";
|
|
71
|
+
readonly defaultValue: "standard";
|
|
72
|
+
readonly required: true;
|
|
73
|
+
readonly options: readonly [{
|
|
74
|
+
readonly label: "Level 1: 标准合规 (Standard)";
|
|
75
|
+
readonly value: "standard";
|
|
76
|
+
}, {
|
|
77
|
+
readonly label: "Level 2: 高安全性 (High Security)";
|
|
78
|
+
readonly value: "high_security";
|
|
79
|
+
}, {
|
|
80
|
+
readonly label: "Level 3: 金融级监管 (Financial)";
|
|
81
|
+
readonly value: "financial";
|
|
82
|
+
}];
|
|
83
|
+
readonly description: "合规等级越高,可选资源规格越严格";
|
|
84
|
+
}];
|
|
85
|
+
}, {
|
|
86
|
+
readonly type: "group";
|
|
87
|
+
readonly name: "specs";
|
|
88
|
+
readonly label: "核心资源配置";
|
|
89
|
+
readonly children: readonly [{
|
|
90
|
+
readonly type: "select";
|
|
91
|
+
readonly name: "instanceFamily";
|
|
92
|
+
readonly label: "实例家族";
|
|
93
|
+
readonly defaultValue: "general";
|
|
94
|
+
readonly required: true;
|
|
95
|
+
readonly options: readonly [{
|
|
96
|
+
readonly label: "通用型 (g6)";
|
|
97
|
+
readonly value: "general";
|
|
98
|
+
}, {
|
|
99
|
+
readonly label: "计算型 (c6)";
|
|
100
|
+
readonly value: "compute";
|
|
101
|
+
}, {
|
|
102
|
+
readonly label: "GPU 训练型 (gn7)";
|
|
103
|
+
readonly value: "gpu";
|
|
104
|
+
}, {
|
|
105
|
+
readonly label: "高 IO 型 (i3)";
|
|
106
|
+
readonly value: "high_io";
|
|
107
|
+
}];
|
|
108
|
+
readonly message: "";
|
|
109
|
+
}, {
|
|
110
|
+
readonly type: "group";
|
|
111
|
+
readonly name: "storage";
|
|
112
|
+
readonly label: "存储方案";
|
|
113
|
+
readonly children: readonly [{
|
|
114
|
+
readonly type: "select";
|
|
115
|
+
readonly name: "diskType";
|
|
116
|
+
readonly label: "系统盘类型";
|
|
117
|
+
readonly defaultValue: "ssd";
|
|
118
|
+
readonly required: true;
|
|
119
|
+
readonly options: readonly [{
|
|
120
|
+
readonly label: "ESSD 增强型 SSD";
|
|
121
|
+
readonly value: "essd";
|
|
122
|
+
}, {
|
|
123
|
+
readonly label: "标准 SSD";
|
|
124
|
+
readonly value: "ssd";
|
|
125
|
+
}, {
|
|
126
|
+
readonly label: "高效云盘 (HDD)";
|
|
127
|
+
readonly value: "hdd";
|
|
128
|
+
}];
|
|
129
|
+
}, {
|
|
130
|
+
readonly type: "number";
|
|
131
|
+
readonly name: "capacity";
|
|
132
|
+
readonly label: "系统盘容量 (GB)";
|
|
133
|
+
readonly defaultValue: 40;
|
|
134
|
+
readonly min: 20;
|
|
135
|
+
readonly max: 32768;
|
|
136
|
+
readonly step: 10;
|
|
137
|
+
readonly required: true;
|
|
138
|
+
readonly message: "";
|
|
139
|
+
}];
|
|
140
|
+
}];
|
|
141
|
+
}, {
|
|
142
|
+
readonly type: "group";
|
|
143
|
+
readonly name: "security";
|
|
144
|
+
readonly label: "安全加固选项";
|
|
145
|
+
readonly children: readonly [{
|
|
146
|
+
readonly type: "select";
|
|
147
|
+
readonly name: "encryption";
|
|
148
|
+
readonly label: "数据盘加密";
|
|
149
|
+
readonly defaultValue: "no";
|
|
150
|
+
readonly required: true;
|
|
151
|
+
readonly options: readonly [{
|
|
152
|
+
readonly label: "开启落盘加密 (KMS)";
|
|
153
|
+
readonly value: "yes";
|
|
154
|
+
}, {
|
|
155
|
+
readonly label: "暂不开启";
|
|
156
|
+
readonly value: "no";
|
|
157
|
+
}];
|
|
158
|
+
}, {
|
|
159
|
+
readonly type: "input";
|
|
160
|
+
readonly name: "kmsKey";
|
|
161
|
+
readonly label: "KMS 密钥 ID";
|
|
162
|
+
readonly defaultValue: "";
|
|
163
|
+
readonly maxLength: 8;
|
|
164
|
+
readonly hidden: true;
|
|
165
|
+
readonly required: false;
|
|
166
|
+
readonly placeholder: "请输入云平台提供的密钥 UUID";
|
|
167
|
+
}];
|
|
168
|
+
}, {
|
|
169
|
+
readonly type: "group";
|
|
170
|
+
readonly name: "billing";
|
|
171
|
+
readonly label: "计费与汇总";
|
|
172
|
+
readonly children: readonly [{
|
|
173
|
+
readonly type: "number";
|
|
174
|
+
readonly name: "totalPrice";
|
|
175
|
+
readonly label: "预估月度总价";
|
|
176
|
+
readonly defaultValue: 0;
|
|
177
|
+
readonly readonly: true;
|
|
178
|
+
readonly required: true;
|
|
179
|
+
readonly prefix: "¥";
|
|
180
|
+
}, {
|
|
181
|
+
readonly type: "input";
|
|
182
|
+
readonly name: "priceDetail";
|
|
183
|
+
readonly label: "计费项说明";
|
|
184
|
+
readonly defaultValue: "基础配置费用";
|
|
185
|
+
readonly readonly: true;
|
|
186
|
+
readonly required: false;
|
|
187
|
+
readonly hidden: false;
|
|
188
|
+
}, {
|
|
189
|
+
readonly type: "checkbox";
|
|
190
|
+
readonly name: "autoRenew";
|
|
191
|
+
readonly label: "开启自动续费";
|
|
192
|
+
readonly defaultValue: false;
|
|
193
|
+
readonly disabled: false;
|
|
194
|
+
readonly description: "暂不支持自动续费";
|
|
195
|
+
}];
|
|
196
|
+
}];
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
type FormDataModel = FormResultType<typeof clonedschema>;
|
|
200
|
+
type AllPath = GetAllPath<FormDataModel> | (string & {});
|
|
201
|
+
|
|
202
|
+
type BaseField = {
|
|
203
|
+
label: string;
|
|
204
|
+
name: string;
|
|
205
|
+
placeholder?: string;
|
|
206
|
+
disabled: boolean;
|
|
207
|
+
readonly: boolean;
|
|
208
|
+
hidden?: boolean;
|
|
209
|
+
validators?: any;
|
|
210
|
+
theme?: string;
|
|
211
|
+
};
|
|
212
|
+
type InputField = BaseField & {
|
|
213
|
+
type: "input" | "number";
|
|
214
|
+
required: boolean;
|
|
215
|
+
min?: number;
|
|
216
|
+
maxLength: number;
|
|
217
|
+
defaultValue: string | number;
|
|
218
|
+
};
|
|
219
|
+
type CheckboxField = BaseField & {
|
|
220
|
+
type: "checkbox";
|
|
221
|
+
description?: string;
|
|
222
|
+
required: boolean;
|
|
223
|
+
defaultValue: boolean;
|
|
224
|
+
};
|
|
225
|
+
type SelectField = BaseField & {
|
|
226
|
+
type: "select";
|
|
227
|
+
required: boolean;
|
|
228
|
+
options: {
|
|
229
|
+
label: string;
|
|
230
|
+
value: any;
|
|
231
|
+
}[];
|
|
232
|
+
defaultValue: any;
|
|
233
|
+
};
|
|
234
|
+
type GroupField = Omit<BaseField, "label" | "name" | "placeholder" | "validators"> & {
|
|
235
|
+
type: "group";
|
|
236
|
+
name?: string;
|
|
237
|
+
children: FormFieldSchema[];
|
|
238
|
+
};
|
|
239
|
+
type FormFieldSchema = InputField | CheckboxField | SelectField | GroupField;
|
|
240
|
+
type RenderSchemaExtraCommonType<P = any> = {
|
|
241
|
+
path: AllPath;
|
|
242
|
+
dirtySignal: any;
|
|
243
|
+
uid: number;
|
|
244
|
+
nodeBucket: Record<string, SchemaBucket<P>>;
|
|
245
|
+
dependOn: (cb: (...args: any) => void) => void;
|
|
246
|
+
};
|
|
247
|
+
type RenderSchemaFn<T> = FinalFlatten<T extends GroupField ? Omit<T, "children"> & RenderSchemaExtraCommonType & {
|
|
248
|
+
children: Array<RenderSchemaFn<FormFieldSchema>>;
|
|
249
|
+
} : T & RenderSchemaExtraCommonType>;
|
|
250
|
+
type RenderSchema = RenderSchemaFn<FormFieldSchema>;
|
|
251
|
+
type CollapseChildren<T> = T extends readonly [infer First, ...infer Rest] ? FormResultType<First> & CollapseChildren<Rest> : {};
|
|
252
|
+
type FormResultType<T> = T extends any ? T extends {
|
|
253
|
+
readonly type: "group";
|
|
254
|
+
readonly name: infer N;
|
|
255
|
+
readonly children: infer C;
|
|
256
|
+
} ? N extends string ? N extends "" ? FinalFlatten<CollapseChildren<C>> : {
|
|
257
|
+
[K in N]: FinalFlatten<CollapseChildren<C>>;
|
|
258
|
+
} : FinalFlatten<CollapseChildren<C>> : T extends {
|
|
259
|
+
readonly name: infer N;
|
|
260
|
+
readonly defaultValue: infer V;
|
|
261
|
+
} ? N extends string ? {
|
|
262
|
+
[K in N]: FinalFlatten<V>;
|
|
263
|
+
} : never : {} : {};
|
|
264
|
+
|
|
265
|
+
interface logicApi {
|
|
266
|
+
slot: {
|
|
267
|
+
triggerTargets: any;
|
|
268
|
+
affectedTatget: any;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
type GetType<T, P> = P extends keyof T ? T[P] : never;
|
|
273
|
+
type Engine<T> = {
|
|
274
|
+
data: {
|
|
275
|
+
[K in "schema" | "GetFormData" | "AddNewSchema" | 'SetValue']: GetType<T, K>;
|
|
276
|
+
};
|
|
277
|
+
config: {
|
|
278
|
+
[K in "SetRule" | "SetRules" | "SetStrategy" | "SetValidators" | "notifyAll" | "SetTrace"]: GetType<T, K>;
|
|
279
|
+
};
|
|
280
|
+
dependency: {
|
|
281
|
+
[K in 'GetAllDependency' | 'GetDependencyOrder']: GetType<T, K>;
|
|
282
|
+
};
|
|
283
|
+
history: {
|
|
284
|
+
[K in "Undo" | "Redo" | "initCanUndo" | "initCanRedo"]: GetType<T, K>;
|
|
285
|
+
};
|
|
286
|
+
hooks: {
|
|
287
|
+
[K in "onError"]: GetType<T, K>;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
declare const useEngineManager: <T, P extends string>(id: string | symbol, Schema: any, UITrigger: {
|
|
291
|
+
signalCreateor: () => T;
|
|
292
|
+
signalTrigger: (signal: T) => void;
|
|
293
|
+
}) => Engine<{
|
|
294
|
+
schema: RenderSchema;
|
|
295
|
+
SetRule: (outDegreePath: P, inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
|
|
296
|
+
value?: any;
|
|
297
|
+
priority?: number;
|
|
298
|
+
forceNotify?: boolean;
|
|
299
|
+
logic: (api: logicApi) => any;
|
|
300
|
+
} | undefined) => void;
|
|
301
|
+
SetRules: (outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
|
|
302
|
+
value?: any;
|
|
303
|
+
priority?: number;
|
|
304
|
+
forceNotify?: boolean;
|
|
305
|
+
logic: (api: logicApi) => any;
|
|
306
|
+
} | undefined) => void;
|
|
307
|
+
SetStrategy: (path: unknown, key: KeysOfUnion<Exclude<FormFieldSchema, GroupField>>, strategy: DefaultStarategy) => void;
|
|
308
|
+
SetValidators: (path: P, options: {
|
|
309
|
+
logic: (val: any, GetByPath: any) => any;
|
|
310
|
+
condition: (data: any) => boolean;
|
|
311
|
+
}) => void;
|
|
312
|
+
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void, context: any) => () => void;
|
|
313
|
+
SetValue: (path: P, value: any) => void;
|
|
314
|
+
GetFormData: () => {
|
|
315
|
+
cloudConsole: {
|
|
316
|
+
environment: {
|
|
317
|
+
region: "china";
|
|
318
|
+
compliance: "standard";
|
|
319
|
+
};
|
|
320
|
+
specs: {
|
|
321
|
+
instanceFamily: "general";
|
|
322
|
+
storage: {
|
|
323
|
+
diskType: "ssd";
|
|
324
|
+
capacity: 40;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
security: {
|
|
328
|
+
encryption: "no";
|
|
329
|
+
kmsKey: "";
|
|
330
|
+
};
|
|
331
|
+
billing: {
|
|
332
|
+
totalPrice: 0;
|
|
333
|
+
priceDetail: "基础配置费用";
|
|
334
|
+
autoRenew: false;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
notifyAll: () => void;
|
|
339
|
+
AddNewSchema: (path: string, data: any) => RenderSchema;
|
|
340
|
+
GetAllDependency: () => Map<P, Set<P>>;
|
|
341
|
+
GetDependencyOrder: () => P[][];
|
|
342
|
+
Undo: () => void;
|
|
343
|
+
Redo: () => void;
|
|
344
|
+
initCanUndo: (cb: (newVal: number) => any) => void;
|
|
345
|
+
initCanRedo: (cb: (newVal: number) => any) => void;
|
|
346
|
+
onError: (cb: (error: MeshErrorContext) => void) => () => void;
|
|
347
|
+
}>;
|
|
348
|
+
declare const useEngine: <T = any, P extends string = string>(id: string | symbol) => Engine<{
|
|
349
|
+
schema: RenderSchema;
|
|
350
|
+
SetRule: (outDegreePath: P, inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
|
|
351
|
+
value?: any;
|
|
352
|
+
priority?: number;
|
|
353
|
+
forceNotify?: boolean;
|
|
354
|
+
logic: (api: logicApi) => any;
|
|
355
|
+
} | undefined) => void;
|
|
356
|
+
SetRules: (outDegreePaths: P[], inDegreePath: P, key: KeysOfUnion<InputField | CheckboxField | SelectField>, options?: {
|
|
357
|
+
value?: any;
|
|
358
|
+
priority?: number;
|
|
359
|
+
forceNotify?: boolean;
|
|
360
|
+
logic: (api: logicApi) => any;
|
|
361
|
+
} | undefined) => void;
|
|
362
|
+
SetStrategy: (path: unknown, key: KeysOfUnion<Exclude<FormFieldSchema, GroupField>>, strategy: DefaultStarategy) => void;
|
|
363
|
+
SetValidators: (path: P, options: {
|
|
364
|
+
logic: (val: any, GetByPath: any) => any;
|
|
365
|
+
condition: (data: any) => boolean;
|
|
366
|
+
}) => void;
|
|
367
|
+
SetTrace: (myPath: P, onUpdate: (newStatus: "idle" | "pending" | "calculating" | "calculated" | "error" | "canceled") => void, context: any) => () => void;
|
|
368
|
+
SetValue: (path: P, value: any) => void;
|
|
369
|
+
GetFormData: () => {
|
|
370
|
+
cloudConsole: {
|
|
371
|
+
environment: {
|
|
372
|
+
region: "china";
|
|
373
|
+
compliance: "standard";
|
|
374
|
+
};
|
|
375
|
+
specs: {
|
|
376
|
+
instanceFamily: "general";
|
|
377
|
+
storage: {
|
|
378
|
+
diskType: "ssd";
|
|
379
|
+
capacity: 40;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
security: {
|
|
383
|
+
encryption: "no";
|
|
384
|
+
kmsKey: "";
|
|
385
|
+
};
|
|
386
|
+
billing: {
|
|
387
|
+
totalPrice: 0;
|
|
388
|
+
priceDetail: "基础配置费用";
|
|
389
|
+
autoRenew: false;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
notifyAll: () => void;
|
|
394
|
+
AddNewSchema: (path: string, data: any) => RenderSchema;
|
|
395
|
+
GetAllDependency: () => Map<P, Set<P>>;
|
|
396
|
+
GetDependencyOrder: () => P[][];
|
|
397
|
+
Undo: () => void;
|
|
398
|
+
Redo: () => void;
|
|
399
|
+
initCanUndo: (cb: (newVal: number) => any) => void;
|
|
400
|
+
initCanRedo: (cb: (newVal: number) => any) => void;
|
|
401
|
+
onError: (cb: (error: MeshErrorContext) => void) => () => void;
|
|
402
|
+
}>;
|
|
403
|
+
declare const deleteEngine: (id: string | symbol) => void;
|
|
404
|
+
|
|
405
|
+
export { deleteEngine, useEngine, useEngineManager };
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var j=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var pe=(i,e)=>{for(var r in e)j(i,r,{get:e[r],enumerable:!0})},ye=(i,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ue(e))!de.call(i,a)&&a!==r&&j(i,a,{get:()=>e[a],enumerable:!(t=ce(e,a))||t.enumerable});return i};var fe=i=>ye(j({},"__esModule",{value:!0}),i);var Pe={};pe(Pe,{deleteEngine:()=>Se,useEngine:()=>ge,useEngineManager:()=>me});module.exports=fe(Pe);var W=class{computedRules=[];store={OR:async(e,r)=>{let t,a,n=this.computedRules;for(let u of n){let s=await u.logic(e);if(u.entityId==="__base__"){a=s;continue}if(s){t=u.value;break}}return typeof t>"u"&&(t=a),{res:t,version:r}},PRIORITY:async(e,r)=>{let t=null,a=this.computedRules;try{for(let n of a){let u=await n.logic(e);if(u!==void 0){t=u;break}}}catch(n){throw n}return{res:t,version:r}}};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(r=>Array.from(r)).flat().sort((r,t)=>t.priority-r.priority):this.computedRules=Array.from(e.values()).map(r=>Array.from(r)).flat()}setStrategy(e){this.CurrentStrategy=this.store[e],this.updateComputedRules()}evaluate(e,r){return this.CurrentStrategy(e,r)}},K=class{path;strategy;contract;rules=new Map;isDefaultValue=!1;id=0;cache=void 0;pendingPromise=null;version=0;deps=new Map;_forceNotify=!1;promiseToken=null;globalCalcCount=0;constructor(e,r,t){let a=()=>this.rules;this.strategy=new W(a),this.path=t,this.isDefaultValue=r==="defaultValue",this.contract=this.inferType(e),this.cache=e,this.setRule({priority:0,entityId:"__base__",logic:()=>e})}forceNotify(){this._forceNotify=!0}isForceNotify(){return this._forceNotify}setStrategy(e){this.strategy.setStrategy(e)}updateInputValueRule(e){this.isDefaultValue&&this.setRule({priority:1,entityId:"__input_value__",logic:()=>e})}setDefaultRule(e){let r=new Set;r.add(e),this.rules.set(e.id,r)}setRules(e,r){r&&this.updateDeps(r);let t=++this.id,a={...e,entityId:t};for(let n of e.triggerPaths)this.rules.has(n)||this.rules.set(n,new Set),this.rules.get(n).add(a);return this.strategy.updateComputedRules(),()=>{for(let n of e.triggerPaths){let u=this.rules.get(n);u&&(u.delete(a),u.size===0&&(this.rules.delete(n),this.deps.delete(n)))}this.strategy.updateComputedRules()}}updateDeps(e){for(let[r,t]of e)this.deps.set(r,t)}setRule(e,r){if(r&&this.updateDeps(r),typeof e.entityId=="string"){this.setDefaultRule(e);return}let t=++this.id,a={...e,entityId:t};if(e)for(let n of e.triggerPaths)this.rules.has(n)||this.rules.set(n,new Set),this.rules.get(n).add(a);return this.strategy.updateComputedRules(),()=>{for(let n of e.triggerPaths){let u=this.rules.get(n);u&&(u.delete(a),u.size===0&&(this.rules.delete(n),this.deps.delete(n)))}this.strategy.updateComputedRules()}}async evaluate(e){let r=null;if(e.GetToken&&(r=e.GetToken()),this.pendingPromise&&this.promiseToken!==r&&(console.log("[\u6876\u8EAB\u4EFD\u5931\u6548] \u7968\u53F7\u53D8\u4E86\uFF0C\u629B\u5F03\u65E7 Promise"),this.pendingPromise=null,this.promiseToken=null),this.pendingPromise)return console.log("\u2705 \u547D\u4E2D\u6027\u80FD\u4F18\u5316\uFF1A\u590D\u7528\u76F8\u540C Token \u7684 Promise"),this.pendingPromise;this.promiseToken=r;let t=++this.version;return this.pendingPromise=(async()=>{try{await Promise.resolve();let a=!1;if(typeof e.triggerPath=="string"){a=!0;let s=this.deps.get(e.triggerPath),p=e.GetValueByPath(e.triggerPath);if(console.log(` \u2514\u2500 \u89E6\u53D1\u8DEF\u5F84\u5BF9\u6BD4: ${e.triggerPath} | \u65E7\u503C:`,s," | \u65B0\u503C:",p),typeof s=="object"||typeof p=="object")a=!1;else{let c=Array.from(this.deps.keys());for(let l of c){let o=this.deps.get(l),h=e.GetValueByPath(l);if(o!==h){console.log(` %c \u2514\u2500 \u5224\u5B9A: \u53D1\u73B0\u5DEE\u5F02\u8DEF\u5F84 ${l} | ${o} -> ${h} | \u6267\u884C\u91CD\u7B97`,"color: #f56c6c"),a=!1;break}}}}if(a)return console.log(`%c [\u26A1\uFE0F\u9AD8\u901F\u7F13\u5B58] ${this.path} \u547D\u4E2D! \u7F13\u5B58\u503C:`,"color: #409EFF",this.cache),this.cache;let{res:n,version:u}=await this.strategy.evaluate(e,t);if(r!==this.promiseToken)return console.warn(`[\u62E6\u622A\u5E7D\u7075] \u6876\u7248\u672C\u5DF2\u8FDB\u5316\u4E3A ${this.version}, \u4EFB\u52A1\u7248\u672C ${u} \u4F5C\u5E9F`),console.log(n,this.cache),this.cache;if(u<this.version)return console.log("\u8FC7\u671F\u4EFB\u52A1"),this.cache;if(this.inferType(n)!==this.contract&&console.error(`[\u7C7B\u578B\u6CC4\u9732] \u6876\u4EA7\u51FA\u4E86\u975E ${this.contract} \u7C7B\u578B\u7684\u503C:`,n),this.cache=n,r===this.promiseToken){console.log(`${this.path}\u4FEE\u6539\u4E86cache:`,n);let s=Array.from(this.deps.keys());for(let p of s){let c=e.GetValueByPath(p);this.deps.set(p,c)}}return n}catch(a){throw{path:this.path,info:a}}finally{this.promiseToken===r&&(this.pendingPromise=null,this.promiseToken=null)}})(),this.pendingPromise}inferType(e){return Array.isArray(e)?"array":typeof e}},z=class{validators=[];defaultValidators=[];path="";constructor(e){this.path=e,this.SetDefaultValidators()}setValidators(e){this.validators.push(e)}SetDefaultValidators(){let e={logic:t=>t||typeof t=="number"?!0:`${this.path}\u4E0D\u80FD\u4E3A\u7A7A`,condition:t=>!!t.required},r={logic:function(t){return t.length>this.options.maxLength?`\u8D85\u51FA\u6700\u5927\u957F\u5EA6\uFF0C\u6700\u5927\u957F\u5EA6\u4E3A${this.options.maxLength}`:!0},condition:function(t){return typeof t.maxLength!="number"?!1:(r.options={maxLength:t.maxLength},t.type==="input"&&t.hidden===!1)},options:{}};this.defaultValidators.push(e),this.defaultValidators.push(r)}evaluate(e,r){let t=!0,a=[...this.defaultValidators,...this.validators];for(let n of a){if(!n.condition(r))continue;let s=n.logic(e);if(typeof s!="boolean"){t=s;break}}return t}};function X(i,e,r,t,a){let n=new Map;return(s,p)=>{let l=Symbol("token");n.set(s,l);let o=!1,h=new Set,y=new Set,m=new Set(i.GetAllNextDependency(s));m.add(s);let x=new Map,R=new Map,M=performance.now(),w=i.GetPathToLevelMap(),A=w.get(s)??0;m.forEach(v=>{if(v===s||p.includes(v))return;let d=i.GetPrevDependency(v).filter(f=>m.has(f)).length;d>0&&R.set(v,d)}),h.add(s);let E=Array.from(p).map(v=>(x.set(v,(x.get(v)||0)+1),{target:v,trigger:s,isReleased:!1}));e.pushExecution([...Array.from(p),s],!0),console.log(`%c \u{1F680} \u4EFB\u52A1\u542F\u52A8 | Trigger: ${s} | Token: ${l.description}`,"color: #67c23a; font-weight: bold;");let $=async v=>{let{target:S,trigger:d}=v;try{if(n.get(s)!==l)return;let f=!1,T=!1,g=r.GetRenderSchemaByPath(S);console.log(`%c \u2705 \u8BA1\u7B97\u5B8C\u6210: ${S}\u5F53\u524D\u503C:`,g.defaultValue,"color: #67c23a;");for(let F in g.nodeBucket){let b=g.nodeBucket[F],V=await b.evaluate({affectKey:F,triggerPath:d,GetRenderSchemaByPath:r.GetRenderSchemaByPath,GetValueByPath:P=>r.GetRenderSchemaByPath(P).defaultValue,GetToken:()=>l});if(n.get(s)!==l){console.log(`\u{1F6AB} \u4EE4\u724C\u8FC7\u671F\uFF0C\u4E22\u5F03${S}\u65E7\u4EFB\u52A1\u8BA1\u7B97\u7ED3\u679C`);return}F==="options"&&(V.some(G=>G.value==g.defaultValue)||(g.defaultValue=void 0,f=!0)),V!==g[F]&&(g[F]=V,f=!0),b.isForceNotify()&&(T=!0),f&&a.flushPathSet.add(S),h.add(S);let B=i.GetNextDependency(S);(f||T)&&i.GetAllNextDependency(S).forEach(G=>m.add(G));for(let P of B){if(h.has(P)){console.log(`\u{1F9CA} [\u62E6\u622A] \u4E0B\u6E38 ${P} \u5DF2\u7531\u5176\u4ED6\u8DEF\u5F84\u5904\u7406`);continue}if(f||T){if(!R.has(P)&&!h.has(P)&&!x.has(P)){let L=i.GetPrevDependency(P).filter(U=>m.has(U)).length;R.set(P,L)}let G=R.get(P)??0,C=Math.max(0,G-1);C<=0?(R.delete(P),E.push({target:P,trigger:S,isReleased:!0}),x.set(P,1),e.pushExecution([P]),console.log(`\u{1F525} [\u5F3A\u62C9\u52A8] ${S} \u503C\u53D8\u4E86\uFF0C\u91CA\u653E\u4E0B\u6E38: ${P}`)):R.set(P,C)}else console.log(`\u{1F9CA} [\u5F31\u5173\u8054] ${S} \u503C\u672A\u53D8\uFF0C${P} \u4EC5\u66F4\u65B0\u7586\u57DF\uFF0C\u539F\u5730\u5F85\u547D`)}}if(performance.now()-M>16&&(await new Promise(F=>requestAnimationFrame(F)),M=performance.now(),n.get(s)!==l))return;n.get(s)===l&&a.requestUpdate()}catch(f){console.error(`\u8BA1\u7B97\u8DEF\u5F84 ${S} \u65F6\u51FA\u9519:`,f);let T=Symbol("abort");n.set(s,T),E.length=0,R.clear(),y.clear(),e.markError(S),t.callOnError(f)}finally{n.get(s)===l&&(console.log(`[\u91CA\u653EProcessing] - ${S} | \u5269\u4F59Size: ${y.size-1}`),y.delete(S),e.popExecution([S]),o||O())}},O=async()=>{if(n.get(s)!==l){o=!1;return}o=!0;try{for(;(E.length>0||R.size>0)&&n.get(s)===l;){if(E.length>0){if(y.size>=20){o=!1;return}let v=E.shift(),{target:S}=v;if(h.has(S)){console.warn(`[\u62E6\u622A] \u{1F6E1}\uFE0F \u62D2\u7EDD\u91CD\u5165: ${S} | \u539F\u56E0: \u5DF2\u8BA1\u7B97\u5B8C\u6210`);continue}console.log(`[\u8C03\u5EA6] \u{1F4E5} \u51FA\u961F: ${S} | \u6765\u6E90: ${v.isReleased?"\u6551\u8D4E/\u62C9\u52A8":"\u521D\u59CB"} | \u5269\u4F59: ${E.length}`);let d=x.get(S)||0;d<=1?x.delete(S):x.set(S,d-1);let f=w.get(S)??0;if(f>A+1&&!v.isReleased){console.log(`[\u5F3A\u5236\u62E6\u622A] ${S} \u5C42\u7EA7\u592A\u6DF1(${f})\uFF0C\u5F53\u524D\u6C34\u4F4D(${A})\uFF0C\u79FB\u5165\u60B2\u89C2\u533A`),R.set(S,1);continue}y.add(S),console.log(`[\u9501\u5B9AProcessing] + ${S} | \u5F53\u524DSize: ${y.size} | \u6210\u5458: ${Array.from(y).join(",")}`),e.pushExecution([S]),$(v);continue}if(y.size>0){console.log(`[\u7184\u706B\u62E6\u622A] \u961F\u5217\u7A7A\u4F46\u6709\u4EFB\u52A1\u5728\u98DE | \u6B63\u5728\u98DE: ${Array.from(y).join(",")} | \u62E6\u622A\u6C34\u4F4D\u7EBF\u63A8\u8FDB`),o=!1;return}if(R.size>0){console.log(`%c \u26A1 \u7CFB\u7EDF\u9759\u9ED8\uFF0C\u626B\u63CF\u60B2\u89C2\u533A... \u5C42\u7EA7: ${A}`,"color: #9c27b0;");let v=!1,S=[];for(let[d]of R)i.GetPrevDependency(d).some(g=>h.has(g)?!1:y.has(g)||x.has(g)||m.has(g)?!0:(w.get(g)??0)>A)||S.push(d);if(S.length>0&&(S.forEach(d=>{R.delete(d),E.push({target:d,trigger:s,isReleased:!0}),x.set(d,1),e.pushExecution([d])}),v=!0,console.log(`\u{1F680} [\u7CBE\u51C6\u6551\u8D4E] \u91CA\u653E\u8282\u70B9: ${S.join(",")}`)),v)continue;if(Array.from(R.keys()).some(f=>i.GetPrevDependency(f).some(g=>m.has(g)&&!h.has(g)))){console.log(`\u23F3 \u5C1A\u6709\u6D3B\u8DC3\u4F9D\u8D56 \u672A\u5B8C\u6210\uFF0C\u6C34\u4F4D\u7EBF\u9501\u5B9A\u5728 ${A}`),o=!1;return}if(A++,console.log(`\u{1F4C8} \u6C34\u4F4D\u7EBF\u63A8\u79FB\u81F3: ${A}`),A>2e3)break;continue}}}finally{o=!1,console.log("[\u7184\u706B] \u{1F4A4} \u5168\u573A\u9759\u9ED8\uFF0C\u7B49\u5F85\u5F02\u6B65\u4EFB\u52A1\u964D\u843D...")}};O()}}function J(i,e,r,t,a,n){let u=he(i),s=0,p=new Map,c=new Map,l=new Map,o=!1,h=new Set,y=d=>{let f=p.get(d);return c.get(f)},m=d=>l.get(d),x=async()=>{console.log("\u6279\u5904\u7406\u5F00\u59CB\u5237\u65B0");let d=Array.from(h);h.clear();for(let f of d){let T=y(f);n.signalTrigger(T.dirtySignal)}},R=()=>{o||(o=!0,Promise.resolve().then(()=>{try{for(;h.size>0;)x()}finally{o=!1}}))},M=()=>{let d=(f,T,g)=>{if(typeof f!="object"||f===null||Array.isArray(f)){if(g.length>0){let b=g[g.length-1];T[b]=y(g.join(".")).defaultValue}return}let F=Object.getOwnPropertyNames(f);for(let b of F)g.push(b),d(f[b],f,g),g.pop()};return d(u,null,[]),u},w=X(e,r,{GetRenderSchemaByPath:y},a,{requestUpdate:R,flushPathSet:h}),I=async()=>{let d=e.GetDependencyOrder().flat();try{for(let f of d){let T=y(f);for(let g in T.nodeBucket){let F=await T.nodeBucket[g].evaluate({affectKey:g,triggerPath:void 0,GetRenderSchemaByPath:y,GetValueByPath:b=>y(b).defaultValue,isSameToken:()=>!1});if(g==="options"){let b=!1,V=T.defaultValue;for(let B of F)B.value==V&&(b=!0);b||(T.defaultValue=void 0,R())}F!==T[g]&&(T[g]=F,h.add(f),R())}}}catch(f){a.callOnError(f)}},A=async d=>{if(!d)throw Error("\u6CA1\u6709\u8DEF\u5F84");if(!y(d))throw Error("\u8DEF\u5F84\u9519\u8BEF\uFF0C\u6CA1\u6709\u5BF9\u5E94\u7684\u8282\u70B9");h.add(d),R();let T=e.GetNextDependency(d);E(T,d),r.popExecution([d],!0)};async function E(d,f){w(f,d)}let $=d=>{if(!d)throw Error("\u6CA1\u6709\u8DEF\u5F84");let f=y(d);f.nodeBucket.defaultValue&&f.nodeBucket.defaultValue.updateInputValueRule(f.defaultValue)},O=(d,f="")=>{let T="name"in d?d.name:void 0,g=T?f===""?T:`${f}.${T}`:f,F=n.signalCreateor(),b=s++,V={getRenderSchema:G=>y(G)},B=async(G,C)=>{let L=G(C),U=y(C.path),H=t.createHistoryAction([{path:C.path,value:U.defaultValue},{path:C.path,value:L}],async _=>{let Y=y(_.path);Y.defaultValue=_.value,$(_.path),await A(_.path)});U.defaultValue=L,t.pushIntoHistory(H),$(C.path),await A(C.path)},P={...d,disabled:!!d.disabled,hidden:"hidden"in d?d.hidden:!1,readonly:"readonly"in d?d.readonly:!1,required:"required"in d?d.required:!1,path:g,dirtySignal:F,uid:b,nodeBucket:{},validators:new z(g),theme:"secondary",dependOn:async G=>await B(G,{...V,path:g})};return d.type==="group"&&(delete P.nodeBucket,delete P.validators,P.children=d.children.map(G=>O(G,g)),l.set(P.path,P)),p.set(P.path,P.uid),c.set(P.uid,P),P};return{schema:O(i),GetFormData:()=>M(),GetRenderSchemaByPath:y,GetGroupByPath:m,notifyAll:I,convertToRenderSchema:O}}function he(i,e={}){let r=n=>{if(n.type=="group")return{key:n.name||"",isGroup:!0,val:n.children.reduce((u,s)=>[...u,r(s)],[])};if(n.type=="input"||n.type=="number"||n.type=="select"||n.type=="checkbox")return{key:n.name,isGroup:!1,val:n.defaultValue};throw Error(`\u672A\u5B9A\u4E49\u7684\u7C7B\u578B:${n.type}`)},t=(n,u)=>{if(u.isGroup){let s={};u.key===""?s=n:n[u.key]=s,u.val.forEach(p=>{t(s,p)})}else n[u.key]=u.val},a=r(i);return t(e,a),e}var Z=(i,e,r)=>{let a=n=>{let u=r.triggerPaths.map(c=>n.GetValueByPath(c)),s=Object.create(null);return Object.defineProperty(s,"triggerTargets",{get:()=>u}),Object.defineProperty(s,"affectedTatget",{get:()=>n.GetRenderSchemaByPath(i)[e]}),r.logic({slot:s})};return{value:r.value,targetPath:i,triggerPaths:r.triggerPaths,priority:r.priority??10,logic:a}},ee=(i,e,r)=>{if(!i)throw Error("");let t=i,a=(s,p)=>{e.has(s)||e.set(s,new Set),e.get(s).add(p),r.has(p)||r.set(p,new Set),r.get(p).add(s)};return{SetRule:(s,p,c,l={logic:o=>{}})=>{let o=t(p),h=Z(p,c,{...l,triggerPaths:[s]}),y=[s].map(m=>[m,t(m).defaultValue]);if(a(s,p),o.nodeBucket[c])o.nodeBucket[c].setRule(h,y);else{let m=new K(o[c],c,p);m.setRule(h,y),o.nodeBucket[c]=m}l.forceNotify&&o.nodeBucket[c].forceNotify()},SetRules:(s,p,c,l={logic:o=>{}})=>{let o=t(p);for(let m of s)a(m,p);let h=Z(p,c,{...l,triggerPaths:s}),y=s.map(m=>[m,t(m).defaultValue]);if(o.nodeBucket[c])o.nodeBucket[c].setRules(h,y);else{let m=new K(o[c],c,p);m.setRules(h,y),o.nodeBucket[c]=m}l.forceNotify&&o.nodeBucket[c].forceNotify()}}},te=i=>{let e=i||void 0;if(!e)throw Error("");return{SetStrategy:(t,a,n)=>{e(t).nodeBucket[a].setStrategy(n)}}};var ne=i=>{let e=i||void 0;return{SetValidators:(t,a)=>{let n=e(t),u=(p,c,l)=>p(c,l),s=(p,c,l)=>p(c,l);if(!n.validators)throw Error("validator\u6876\u672A\u521D\u59CB\u5316");n.validators.setValidators({logic:p=>u(a.logic,p,e),condition:typeof a.condition=="function"?p=>s(a.condition,p,e):()=>!0})}}};function re(i){let e=new Map,r=new Map,t=new Set,a=(c,l)=>{if(e.get(c)===l)return;e.set(c,l);let o=r.get(c);o&&o(l)};return{pushExecution:(c,l)=>{l&&(t.forEach(o=>a(o,"idle")),t.clear(),e.clear()),c.length!==0&&c.forEach(o=>{t.has(o)||t.add(o),a(o,"calculating"),i(o).forEach(y=>{t.has(y)||(t.add(y),e.has(y)||a(y,"pending"))})})},popExecution:c=>{c.forEach(l=>{a(l,"calculated")})},markError:c=>{a(c,"error"),t.forEach(l=>{let o=e.get(l);l!==c&&(o==="pending"||o==="calculating")&&a(l,"canceled")})},SetTrace:(c,l,o)=>{r.set(c,l);let h=e.get(c)||"idle";return l(h),()=>{r.delete(c)}}}}function oe(i,e,r,t){let a=l=>{let o=i(),h=e(),y=new Set;return o.get(l)?.forEach(m=>y.add(m)),y.size===0?[]:Array.from(y).filter(m=>{let x=h.get(m)||new Set;return!Array.from(x).some(w=>y.has(w))})};return{GetNextDependency:l=>{let o=t();return Array.from(o.get(l)||[])},GetPrevDependency:l=>{let o=r();return Array.from(o.get(l)||[])},GetAllPrevDependency:l=>{let o=e();return Array.from(o.get(l)||[])},GetAllNextDependency:l=>{let o=i();return Array.from(o.get(l)||[])},rebuildDirectDependencyMaps:l=>{let o=new Map,h=new Map;for(let y of l){let m=a(y);o.set(y,new Set(m));for(let x of m)h.has(x)||h.set(x,new Set),h.get(x).add(y)}return{directNextMap:o,directPrevMap:h}}}}function ae(i){let e=t=>{let a=[],n=[],u=new Map,s=t.size,p=0,c=0;for(let[l,o]of t)o===0&&n.push(l);if(n.length===0&&s>0)throw Error("\u521D\u59CB\u5165\u5EA6\u6CA1\u6709\u4E3A0\u7684path, \u4F9D\u8D56\u7EDF\u8BA1\u6709\u8BEF\u6216\u5B58\u5728\u73AF");for(;n.length>0;){a.push([...n]);let l=[];for(let o of n){p++,u.set(o,c);let h=i.get(o);if(h)for(let y of h){let m=t.get(y)-1;t.set(y,m),m===0&&l.push(y)}}n=l,c++}if(p<s)throw Error("\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56\uFF01");return{steps:a,levelMap:u}};return()=>{let t=new Map;for(let a of i.keys()){let n=Array.from(i.get(a)||[]);t.has(a)||t.set(a,0);for(let u of n){let s=t.get(u)||0;t.set(u,++s)}}return e(t)}}function se(){let i=[],e=[],t={canRedo:()=>{},canUndo:()=>{}},a=()=>{if(!i.length)return;let o=i.pop();o?.undoAction(),p(o)},n=()=>{if(!e.length)return;let o=e.pop();o?.redoAction(),c(o,!1)},u=o=>{t.canUndo=()=>o(i.length)},s=o=>{t.canRedo=()=>o(e.length)},p=o=>{e.push(o),e.length>100&&e.shift(),t.canRedo(),t.canUndo()},c=(o,h=!0)=>{h&&(e.length=0),i.push(o),i.length>100&&i.shift(),t.canUndo(),t.canRedo()};return{Undo:a,Redo:n,PushIntoHistory:c,CreateHistoryAction:(o,h)=>{let[y,m]=o;return{undoAction:()=>h(y),redoAction:()=>h(m)}},initCanUndo:u,initCanRedo:s}}function ie(){let i=[];return{onError:t=>{let a=n=>t(n);return i.push(a),()=>{let n=i.findIndex(u=>u===a);i.splice(n,1)}},callOnError:t=>{for(let a of i)a(t)}}}function le(i,e){let r=!1,t=!1,a=new Map,n=new Map,u=new Map,s=new Map,p=[],c=new Map,{GetNextDependency:l,GetPrevDependency:o,GetAllPrevDependency:h,GetAllNextDependency:y,rebuildDirectDependencyMaps:m}=oe(()=>a,()=>n,()=>s,()=>u),{SetTrace:x,pushExecution:R,popExecution:M,markError:w}=re(l),{Undo:I,Redo:A,PushIntoHistory:E,CreateHistoryAction:$,initCanUndo:O,initCanRedo:v}=se(),{onError:S,callOnError:d}=ie(),{schema:f,GetFormData:T,GetRenderSchemaByPath:g,GetGroupByPath:F,notifyAll:b,convertToRenderSchema:V}=J(i,{GetDependencyOrder:()=>p,GetAllNextDependency:y,GetNextDependency:l,GetPrevDependency:o,GetAllPrevDependency:h,GetPathToLevelMap:()=>c},{pushExecution:R,popExecution:M,markError:w},{pushIntoHistory:E,createHistoryAction:$},{callOnError:d},e),B=(k,D)=>{let N=F(k),Q=V(D,k);return N.children.push(Q),N.dirtySignal.value++,Q},{SetRule:P,SetRules:G}=ee(g,a,n),{SetStrategy:C}=te(g),{SetValidators:L}=ne(g),U=ae(a),H=()=>{let k=U();p=k.steps,c=k.levelMap};return{schema:f,SetRule:(...k)=>{P.apply(null,k),r=!0,!t&&new Promise((D,N)=>{t=!0,D()}).then(()=>{if(H(),r){let{directNextMap:D,directPrevMap:N}=m(p.flat());u=D,s=N}}).finally(()=>{t=!1,r=!1})},SetRules:(...k)=>{G.apply(null,k),r=!0,!t&&new Promise((D,N)=>{t=!0,D()}).then(()=>{if(H(),r){let{directNextMap:D,directPrevMap:N}=m(p.flat());u=D,s=N}}).finally(()=>{t=!1,r=!1})},SetStrategy:C,SetValidators:L,SetTrace:x,SetValue:(k,D)=>{g(k).dependOn(()=>D)},GetFormData:T,notifyAll:()=>{H(),b()},AddNewSchema:B,GetAllDependency:()=>a,GetDependencyOrder:()=>p,Undo:I,Redo:A,initCanUndo:O,initCanRedo:v,onError:S}}var q=new Map,me=(i,e,r)=>{try{if(typeof r.signalCreateor!="function"||typeof r.signalTrigger!="function")throw Error("\u9700\u8981\u5B9A\u4E49signal\u6765\u901A\u77E5ui");if(q.has(i))throw Error("engineID\u91CD\u590D\uFF0C\u4FEE\u6539id\u6216\u8005\u4F7F\u7528symbol");let t=le(e,r),{schema:a,GetFormData:n,SetRule:u,SetRules:s,SetStrategy:p,SetValidators:c,SetValue:l,notifyAll:o,SetTrace:h,GetAllDependency:y,GetDependencyOrder:m,AddNewSchema:x,Undo:R,Redo:M,initCanUndo:w,initCanRedo:I,onError:A}=t,E={config:{SetRule:u,SetRules:s,SetStrategy:p,SetValidators:c,notifyAll:o,SetTrace:h},data:{schema:a,GetFormData:n,AddNewSchema:x,SetValue:l},history:{Undo:R,Redo:M,initCanUndo:w,initCanRedo:I},dependency:{GetAllDependency:y,GetDependencyOrder:m},hooks:{onError:A}};return q.set(i,E),E}catch(t){throw Error(t)}},ge=i=>{if(q.has(i))return q.get(i);throw Error("\u4E0D\u5B58\u5728\u7684id")},Se=i=>{q.delete(i)};0&&(module.exports={deleteEngine,useEngine,useEngineManager});
|
package/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var j=class{computedRules=[];store={OR:async(e,o)=>{let t,s,n=this.computedRules;for(let u of n){let a=await u.logic(e);if(u.entityId==="__base__"){s=a;continue}if(a){t=u.value;break}}return typeof t>"u"&&(t=s),{res:t,version:o}},PRIORITY:async(e,o)=>{let t=null,s=this.computedRules;try{for(let n of s){let u=await n.logic(e);if(u!==void 0){t=u;break}}}catch(n){throw n}return{res:t,version:o}}};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(o=>Array.from(o)).flat().sort((o,t)=>t.priority-o.priority):this.computedRules=Array.from(e.values()).map(o=>Array.from(o)).flat()}setStrategy(e){this.CurrentStrategy=this.store[e],this.updateComputedRules()}evaluate(e,o){return this.CurrentStrategy(e,o)}},K=class{path;strategy;contract;rules=new Map;isDefaultValue=!1;id=0;cache=void 0;pendingPromise=null;version=0;deps=new Map;_forceNotify=!1;promiseToken=null;globalCalcCount=0;constructor(e,o,t){let s=()=>this.rules;this.strategy=new j(s),this.path=t,this.isDefaultValue=o==="defaultValue",this.contract=this.inferType(e),this.cache=e,this.setRule({priority:0,entityId:"__base__",logic:()=>e})}forceNotify(){this._forceNotify=!0}isForceNotify(){return this._forceNotify}setStrategy(e){this.strategy.setStrategy(e)}updateInputValueRule(e){this.isDefaultValue&&this.setRule({priority:1,entityId:"__input_value__",logic:()=>e})}setDefaultRule(e){let o=new Set;o.add(e),this.rules.set(e.id,o)}setRules(e,o){o&&this.updateDeps(o);let t=++this.id,s={...e,entityId:t};for(let n of e.triggerPaths)this.rules.has(n)||this.rules.set(n,new Set),this.rules.get(n).add(s);return this.strategy.updateComputedRules(),()=>{for(let n of e.triggerPaths){let u=this.rules.get(n);u&&(u.delete(s),u.size===0&&(this.rules.delete(n),this.deps.delete(n)))}this.strategy.updateComputedRules()}}updateDeps(e){for(let[o,t]of e)this.deps.set(o,t)}setRule(e,o){if(o&&this.updateDeps(o),typeof e.entityId=="string"){this.setDefaultRule(e);return}let t=++this.id,s={...e,entityId:t};if(e)for(let n of e.triggerPaths)this.rules.has(n)||this.rules.set(n,new Set),this.rules.get(n).add(s);return this.strategy.updateComputedRules(),()=>{for(let n of e.triggerPaths){let u=this.rules.get(n);u&&(u.delete(s),u.size===0&&(this.rules.delete(n),this.deps.delete(n)))}this.strategy.updateComputedRules()}}async evaluate(e){let o=null;if(e.GetToken&&(o=e.GetToken()),this.pendingPromise&&this.promiseToken!==o&&(console.log("[\u6876\u8EAB\u4EFD\u5931\u6548] \u7968\u53F7\u53D8\u4E86\uFF0C\u629B\u5F03\u65E7 Promise"),this.pendingPromise=null,this.promiseToken=null),this.pendingPromise)return console.log("\u2705 \u547D\u4E2D\u6027\u80FD\u4F18\u5316\uFF1A\u590D\u7528\u76F8\u540C Token \u7684 Promise"),this.pendingPromise;this.promiseToken=o;let t=++this.version;return this.pendingPromise=(async()=>{try{await Promise.resolve();let s=!1;if(typeof e.triggerPath=="string"){s=!0;let a=this.deps.get(e.triggerPath),p=e.GetValueByPath(e.triggerPath);if(console.log(` \u2514\u2500 \u89E6\u53D1\u8DEF\u5F84\u5BF9\u6BD4: ${e.triggerPath} | \u65E7\u503C:`,a," | \u65B0\u503C:",p),typeof a=="object"||typeof p=="object")s=!1;else{let c=Array.from(this.deps.keys());for(let i of c){let r=this.deps.get(i),h=e.GetValueByPath(i);if(r!==h){console.log(` %c \u2514\u2500 \u5224\u5B9A: \u53D1\u73B0\u5DEE\u5F02\u8DEF\u5F84 ${i} | ${r} -> ${h} | \u6267\u884C\u91CD\u7B97`,"color: #f56c6c"),s=!1;break}}}}if(s)return console.log(`%c [\u26A1\uFE0F\u9AD8\u901F\u7F13\u5B58] ${this.path} \u547D\u4E2D! \u7F13\u5B58\u503C:`,"color: #409EFF",this.cache),this.cache;let{res:n,version:u}=await this.strategy.evaluate(e,t);if(o!==this.promiseToken)return console.warn(`[\u62E6\u622A\u5E7D\u7075] \u6876\u7248\u672C\u5DF2\u8FDB\u5316\u4E3A ${this.version}, \u4EFB\u52A1\u7248\u672C ${u} \u4F5C\u5E9F`),console.log(n,this.cache),this.cache;if(u<this.version)return console.log("\u8FC7\u671F\u4EFB\u52A1"),this.cache;if(this.inferType(n)!==this.contract&&console.error(`[\u7C7B\u578B\u6CC4\u9732] \u6876\u4EA7\u51FA\u4E86\u975E ${this.contract} \u7C7B\u578B\u7684\u503C:`,n),this.cache=n,o===this.promiseToken){console.log(`${this.path}\u4FEE\u6539\u4E86cache:`,n);let a=Array.from(this.deps.keys());for(let p of a){let c=e.GetValueByPath(p);this.deps.set(p,c)}}return n}catch(s){throw{path:this.path,info:s}}finally{this.promiseToken===o&&(this.pendingPromise=null,this.promiseToken=null)}})(),this.pendingPromise}inferType(e){return Array.isArray(e)?"array":typeof e}},z=class{validators=[];defaultValidators=[];path="";constructor(e){this.path=e,this.SetDefaultValidators()}setValidators(e){this.validators.push(e)}SetDefaultValidators(){let e={logic:t=>t||typeof t=="number"?!0:`${this.path}\u4E0D\u80FD\u4E3A\u7A7A`,condition:t=>!!t.required},o={logic:function(t){return t.length>this.options.maxLength?`\u8D85\u51FA\u6700\u5927\u957F\u5EA6\uFF0C\u6700\u5927\u957F\u5EA6\u4E3A${this.options.maxLength}`:!0},condition:function(t){return typeof t.maxLength!="number"?!1:(o.options={maxLength:t.maxLength},t.type==="input"&&t.hidden===!1)},options:{}};this.defaultValidators.push(e),this.defaultValidators.push(o)}evaluate(e,o){let t=!0,s=[...this.defaultValidators,...this.validators];for(let n of s){if(!n.condition(o))continue;let a=n.logic(e);if(typeof a!="boolean"){t=a;break}}return t}};function Q(l,e,o,t,s){let n=new Map;return(a,p)=>{let i=Symbol("token");n.set(a,i);let r=!1,h=new Set,y=new Set,m=new Set(l.GetAllNextDependency(a));m.add(a);let x=new Map,R=new Map,M=performance.now(),w=l.GetPathToLevelMap(),A=w.get(a)??0;m.forEach(v=>{if(v===a||p.includes(v))return;let d=l.GetPrevDependency(v).filter(f=>m.has(f)).length;d>0&&R.set(v,d)}),h.add(a);let E=Array.from(p).map(v=>(x.set(v,(x.get(v)||0)+1),{target:v,trigger:a,isReleased:!1}));e.pushExecution([...Array.from(p),a],!0),console.log(`%c \u{1F680} \u4EFB\u52A1\u542F\u52A8 | Trigger: ${a} | Token: ${i.description}`,"color: #67c23a; font-weight: bold;");let $=async v=>{let{target:S,trigger:d}=v;try{if(n.get(a)!==i)return;let f=!1,T=!1,g=o.GetRenderSchemaByPath(S);console.log(`%c \u2705 \u8BA1\u7B97\u5B8C\u6210: ${S}\u5F53\u524D\u503C:`,g.defaultValue,"color: #67c23a;");for(let F in g.nodeBucket){let b=g.nodeBucket[F],V=await b.evaluate({affectKey:F,triggerPath:d,GetRenderSchemaByPath:o.GetRenderSchemaByPath,GetValueByPath:P=>o.GetRenderSchemaByPath(P).defaultValue,GetToken:()=>i});if(n.get(a)!==i){console.log(`\u{1F6AB} \u4EE4\u724C\u8FC7\u671F\uFF0C\u4E22\u5F03${S}\u65E7\u4EFB\u52A1\u8BA1\u7B97\u7ED3\u679C`);return}F==="options"&&(V.some(G=>G.value==g.defaultValue)||(g.defaultValue=void 0,f=!0)),V!==g[F]&&(g[F]=V,f=!0),b.isForceNotify()&&(T=!0),f&&s.flushPathSet.add(S),h.add(S);let B=l.GetNextDependency(S);(f||T)&&l.GetAllNextDependency(S).forEach(G=>m.add(G));for(let P of B){if(h.has(P)){console.log(`\u{1F9CA} [\u62E6\u622A] \u4E0B\u6E38 ${P} \u5DF2\u7531\u5176\u4ED6\u8DEF\u5F84\u5904\u7406`);continue}if(f||T){if(!R.has(P)&&!h.has(P)&&!x.has(P)){let L=l.GetPrevDependency(P).filter(U=>m.has(U)).length;R.set(P,L)}let G=R.get(P)??0,C=Math.max(0,G-1);C<=0?(R.delete(P),E.push({target:P,trigger:S,isReleased:!0}),x.set(P,1),e.pushExecution([P]),console.log(`\u{1F525} [\u5F3A\u62C9\u52A8] ${S} \u503C\u53D8\u4E86\uFF0C\u91CA\u653E\u4E0B\u6E38: ${P}`)):R.set(P,C)}else console.log(`\u{1F9CA} [\u5F31\u5173\u8054] ${S} \u503C\u672A\u53D8\uFF0C${P} \u4EC5\u66F4\u65B0\u7586\u57DF\uFF0C\u539F\u5730\u5F85\u547D`)}}if(performance.now()-M>16&&(await new Promise(F=>requestAnimationFrame(F)),M=performance.now(),n.get(a)!==i))return;n.get(a)===i&&s.requestUpdate()}catch(f){console.error(`\u8BA1\u7B97\u8DEF\u5F84 ${S} \u65F6\u51FA\u9519:`,f);let T=Symbol("abort");n.set(a,T),E.length=0,R.clear(),y.clear(),e.markError(S),t.callOnError(f)}finally{n.get(a)===i&&(console.log(`[\u91CA\u653EProcessing] - ${S} | \u5269\u4F59Size: ${y.size-1}`),y.delete(S),e.popExecution([S]),r||O())}},O=async()=>{if(n.get(a)!==i){r=!1;return}r=!0;try{for(;(E.length>0||R.size>0)&&n.get(a)===i;){if(E.length>0){if(y.size>=20){r=!1;return}let v=E.shift(),{target:S}=v;if(h.has(S)){console.warn(`[\u62E6\u622A] \u{1F6E1}\uFE0F \u62D2\u7EDD\u91CD\u5165: ${S} | \u539F\u56E0: \u5DF2\u8BA1\u7B97\u5B8C\u6210`);continue}console.log(`[\u8C03\u5EA6] \u{1F4E5} \u51FA\u961F: ${S} | \u6765\u6E90: ${v.isReleased?"\u6551\u8D4E/\u62C9\u52A8":"\u521D\u59CB"} | \u5269\u4F59: ${E.length}`);let d=x.get(S)||0;d<=1?x.delete(S):x.set(S,d-1);let f=w.get(S)??0;if(f>A+1&&!v.isReleased){console.log(`[\u5F3A\u5236\u62E6\u622A] ${S} \u5C42\u7EA7\u592A\u6DF1(${f})\uFF0C\u5F53\u524D\u6C34\u4F4D(${A})\uFF0C\u79FB\u5165\u60B2\u89C2\u533A`),R.set(S,1);continue}y.add(S),console.log(`[\u9501\u5B9AProcessing] + ${S} | \u5F53\u524DSize: ${y.size} | \u6210\u5458: ${Array.from(y).join(",")}`),e.pushExecution([S]),$(v);continue}if(y.size>0){console.log(`[\u7184\u706B\u62E6\u622A] \u961F\u5217\u7A7A\u4F46\u6709\u4EFB\u52A1\u5728\u98DE | \u6B63\u5728\u98DE: ${Array.from(y).join(",")} | \u62E6\u622A\u6C34\u4F4D\u7EBF\u63A8\u8FDB`),r=!1;return}if(R.size>0){console.log(`%c \u26A1 \u7CFB\u7EDF\u9759\u9ED8\uFF0C\u626B\u63CF\u60B2\u89C2\u533A... \u5C42\u7EA7: ${A}`,"color: #9c27b0;");let v=!1,S=[];for(let[d]of R)l.GetPrevDependency(d).some(g=>h.has(g)?!1:y.has(g)||x.has(g)||m.has(g)?!0:(w.get(g)??0)>A)||S.push(d);if(S.length>0&&(S.forEach(d=>{R.delete(d),E.push({target:d,trigger:a,isReleased:!0}),x.set(d,1),e.pushExecution([d])}),v=!0,console.log(`\u{1F680} [\u7CBE\u51C6\u6551\u8D4E] \u91CA\u653E\u8282\u70B9: ${S.join(",")}`)),v)continue;if(Array.from(R.keys()).some(f=>l.GetPrevDependency(f).some(g=>m.has(g)&&!h.has(g)))){console.log(`\u23F3 \u5C1A\u6709\u6D3B\u8DC3\u4F9D\u8D56 \u672A\u5B8C\u6210\uFF0C\u6C34\u4F4D\u7EBF\u9501\u5B9A\u5728 ${A}`),r=!1;return}if(A++,console.log(`\u{1F4C8} \u6C34\u4F4D\u7EBF\u63A8\u79FB\u81F3: ${A}`),A>2e3)break;continue}}}finally{r=!1,console.log("[\u7184\u706B] \u{1F4A4} \u5168\u573A\u9759\u9ED8\uFF0C\u7B49\u5F85\u5F02\u6B65\u4EFB\u52A1\u964D\u843D...")}};O()}}function X(l,e,o,t,s,n){let u=le(l),a=0,p=new Map,c=new Map,i=new Map,r=!1,h=new Set,y=d=>{let f=p.get(d);return c.get(f)},m=d=>i.get(d),x=async()=>{console.log("\u6279\u5904\u7406\u5F00\u59CB\u5237\u65B0");let d=Array.from(h);h.clear();for(let f of d){let T=y(f);n.signalTrigger(T.dirtySignal)}},R=()=>{r||(r=!0,Promise.resolve().then(()=>{try{for(;h.size>0;)x()}finally{r=!1}}))},M=()=>{let d=(f,T,g)=>{if(typeof f!="object"||f===null||Array.isArray(f)){if(g.length>0){let b=g[g.length-1];T[b]=y(g.join(".")).defaultValue}return}let F=Object.getOwnPropertyNames(f);for(let b of F)g.push(b),d(f[b],f,g),g.pop()};return d(u,null,[]),u},w=Q(e,o,{GetRenderSchemaByPath:y},s,{requestUpdate:R,flushPathSet:h}),I=async()=>{let d=e.GetDependencyOrder().flat();try{for(let f of d){let T=y(f);for(let g in T.nodeBucket){let F=await T.nodeBucket[g].evaluate({affectKey:g,triggerPath:void 0,GetRenderSchemaByPath:y,GetValueByPath:b=>y(b).defaultValue,isSameToken:()=>!1});if(g==="options"){let b=!1,V=T.defaultValue;for(let B of F)B.value==V&&(b=!0);b||(T.defaultValue=void 0,R())}F!==T[g]&&(T[g]=F,h.add(f),R())}}}catch(f){s.callOnError(f)}},A=async d=>{if(!d)throw Error("\u6CA1\u6709\u8DEF\u5F84");if(!y(d))throw Error("\u8DEF\u5F84\u9519\u8BEF\uFF0C\u6CA1\u6709\u5BF9\u5E94\u7684\u8282\u70B9");h.add(d),R();let T=e.GetNextDependency(d);E(T,d),o.popExecution([d],!0)};async function E(d,f){w(f,d)}let $=d=>{if(!d)throw Error("\u6CA1\u6709\u8DEF\u5F84");let f=y(d);f.nodeBucket.defaultValue&&f.nodeBucket.defaultValue.updateInputValueRule(f.defaultValue)},O=(d,f="")=>{let T="name"in d?d.name:void 0,g=T?f===""?T:`${f}.${T}`:f,F=n.signalCreateor(),b=a++,V={getRenderSchema:G=>y(G)},B=async(G,C)=>{let L=G(C),U=y(C.path),H=t.createHistoryAction([{path:C.path,value:U.defaultValue},{path:C.path,value:L}],async _=>{let W=y(_.path);W.defaultValue=_.value,$(_.path),await A(_.path)});U.defaultValue=L,t.pushIntoHistory(H),$(C.path),await A(C.path)},P={...d,disabled:!!d.disabled,hidden:"hidden"in d?d.hidden:!1,readonly:"readonly"in d?d.readonly:!1,required:"required"in d?d.required:!1,path:g,dirtySignal:F,uid:b,nodeBucket:{},validators:new z(g),theme:"secondary",dependOn:async G=>await B(G,{...V,path:g})};return d.type==="group"&&(delete P.nodeBucket,delete P.validators,P.children=d.children.map(G=>O(G,g)),i.set(P.path,P)),p.set(P.path,P.uid),c.set(P.uid,P),P};return{schema:O(l),GetFormData:()=>M(),GetRenderSchemaByPath:y,GetGroupByPath:m,notifyAll:I,convertToRenderSchema:O}}function le(l,e={}){let o=n=>{if(n.type=="group")return{key:n.name||"",isGroup:!0,val:n.children.reduce((u,a)=>[...u,o(a)],[])};if(n.type=="input"||n.type=="number"||n.type=="select"||n.type=="checkbox")return{key:n.name,isGroup:!1,val:n.defaultValue};throw Error(`\u672A\u5B9A\u4E49\u7684\u7C7B\u578B:${n.type}`)},t=(n,u)=>{if(u.isGroup){let a={};u.key===""?a=n:n[u.key]=a,u.val.forEach(p=>{t(a,p)})}else n[u.key]=u.val},s=o(l);return t(e,s),e}var J=(l,e,o)=>{let s=n=>{let u=o.triggerPaths.map(c=>n.GetValueByPath(c)),a=Object.create(null);return Object.defineProperty(a,"triggerTargets",{get:()=>u}),Object.defineProperty(a,"affectedTatget",{get:()=>n.GetRenderSchemaByPath(l)[e]}),o.logic({slot:a})};return{value:o.value,targetPath:l,triggerPaths:o.triggerPaths,priority:o.priority??10,logic:s}},Z=(l,e,o)=>{if(!l)throw Error("");let t=l,s=(a,p)=>{e.has(a)||e.set(a,new Set),e.get(a).add(p),o.has(p)||o.set(p,new Set),o.get(p).add(a)};return{SetRule:(a,p,c,i={logic:r=>{}})=>{let r=t(p),h=J(p,c,{...i,triggerPaths:[a]}),y=[a].map(m=>[m,t(m).defaultValue]);if(s(a,p),r.nodeBucket[c])r.nodeBucket[c].setRule(h,y);else{let m=new K(r[c],c,p);m.setRule(h,y),r.nodeBucket[c]=m}i.forceNotify&&r.nodeBucket[c].forceNotify()},SetRules:(a,p,c,i={logic:r=>{}})=>{let r=t(p);for(let m of a)s(m,p);let h=J(p,c,{...i,triggerPaths:a}),y=a.map(m=>[m,t(m).defaultValue]);if(r.nodeBucket[c])r.nodeBucket[c].setRules(h,y);else{let m=new K(r[c],c,p);m.setRules(h,y),r.nodeBucket[c]=m}i.forceNotify&&r.nodeBucket[c].forceNotify()}}},ee=l=>{let e=l||void 0;if(!e)throw Error("");return{SetStrategy:(t,s,n)=>{e(t).nodeBucket[s].setStrategy(n)}}};var te=l=>{let e=l||void 0;return{SetValidators:(t,s)=>{let n=e(t),u=(p,c,i)=>p(c,i),a=(p,c,i)=>p(c,i);if(!n.validators)throw Error("validator\u6876\u672A\u521D\u59CB\u5316");n.validators.setValidators({logic:p=>u(s.logic,p,e),condition:typeof s.condition=="function"?p=>a(s.condition,p,e):()=>!0})}}};function ne(l){let e=new Map,o=new Map,t=new Set,s=(c,i)=>{if(e.get(c)===i)return;e.set(c,i);let r=o.get(c);r&&r(i)};return{pushExecution:(c,i)=>{i&&(t.forEach(r=>s(r,"idle")),t.clear(),e.clear()),c.length!==0&&c.forEach(r=>{t.has(r)||t.add(r),s(r,"calculating"),l(r).forEach(y=>{t.has(y)||(t.add(y),e.has(y)||s(y,"pending"))})})},popExecution:c=>{c.forEach(i=>{s(i,"calculated")})},markError:c=>{s(c,"error"),t.forEach(i=>{let r=e.get(i);i!==c&&(r==="pending"||r==="calculating")&&s(i,"canceled")})},SetTrace:(c,i,r)=>{o.set(c,i);let h=e.get(c)||"idle";return i(h),()=>{o.delete(c)}}}}function re(l,e,o,t){let s=i=>{let r=l(),h=e(),y=new Set;return r.get(i)?.forEach(m=>y.add(m)),y.size===0?[]:Array.from(y).filter(m=>{let x=h.get(m)||new Set;return!Array.from(x).some(w=>y.has(w))})};return{GetNextDependency:i=>{let r=t();return Array.from(r.get(i)||[])},GetPrevDependency:i=>{let r=o();return Array.from(r.get(i)||[])},GetAllPrevDependency:i=>{let r=e();return Array.from(r.get(i)||[])},GetAllNextDependency:i=>{let r=l();return Array.from(r.get(i)||[])},rebuildDirectDependencyMaps:i=>{let r=new Map,h=new Map;for(let y of i){let m=s(y);r.set(y,new Set(m));for(let x of m)h.has(x)||h.set(x,new Set),h.get(x).add(y)}return{directNextMap:r,directPrevMap:h}}}}function oe(l){let e=t=>{let s=[],n=[],u=new Map,a=t.size,p=0,c=0;for(let[i,r]of t)r===0&&n.push(i);if(n.length===0&&a>0)throw Error("\u521D\u59CB\u5165\u5EA6\u6CA1\u6709\u4E3A0\u7684path, \u4F9D\u8D56\u7EDF\u8BA1\u6709\u8BEF\u6216\u5B58\u5728\u73AF");for(;n.length>0;){s.push([...n]);let i=[];for(let r of n){p++,u.set(r,c);let h=l.get(r);if(h)for(let y of h){let m=t.get(y)-1;t.set(y,m),m===0&&i.push(y)}}n=i,c++}if(p<a)throw Error("\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56\uFF01");return{steps:s,levelMap:u}};return()=>{let t=new Map;for(let s of l.keys()){let n=Array.from(l.get(s)||[]);t.has(s)||t.set(s,0);for(let u of n){let a=t.get(u)||0;t.set(u,++a)}}return e(t)}}function ae(){let l=[],e=[],t={canRedo:()=>{},canUndo:()=>{}},s=()=>{if(!l.length)return;let r=l.pop();r?.undoAction(),p(r)},n=()=>{if(!e.length)return;let r=e.pop();r?.redoAction(),c(r,!1)},u=r=>{t.canUndo=()=>r(l.length)},a=r=>{t.canRedo=()=>r(e.length)},p=r=>{e.push(r),e.length>100&&e.shift(),t.canRedo(),t.canUndo()},c=(r,h=!0)=>{h&&(e.length=0),l.push(r),l.length>100&&l.shift(),t.canUndo(),t.canRedo()};return{Undo:s,Redo:n,PushIntoHistory:c,CreateHistoryAction:(r,h)=>{let[y,m]=r;return{undoAction:()=>h(y),redoAction:()=>h(m)}},initCanUndo:u,initCanRedo:a}}function se(){let l=[];return{onError:t=>{let s=n=>t(n);return l.push(s),()=>{let n=l.findIndex(u=>u===s);l.splice(n,1)}},callOnError:t=>{for(let s of l)s(t)}}}function ie(l,e){let o=!1,t=!1,s=new Map,n=new Map,u=new Map,a=new Map,p=[],c=new Map,{GetNextDependency:i,GetPrevDependency:r,GetAllPrevDependency:h,GetAllNextDependency:y,rebuildDirectDependencyMaps:m}=re(()=>s,()=>n,()=>a,()=>u),{SetTrace:x,pushExecution:R,popExecution:M,markError:w}=ne(i),{Undo:I,Redo:A,PushIntoHistory:E,CreateHistoryAction:$,initCanUndo:O,initCanRedo:v}=ae(),{onError:S,callOnError:d}=se(),{schema:f,GetFormData:T,GetRenderSchemaByPath:g,GetGroupByPath:F,notifyAll:b,convertToRenderSchema:V}=X(l,{GetDependencyOrder:()=>p,GetAllNextDependency:y,GetNextDependency:i,GetPrevDependency:r,GetAllPrevDependency:h,GetPathToLevelMap:()=>c},{pushExecution:R,popExecution:M,markError:w},{pushIntoHistory:E,createHistoryAction:$},{callOnError:d},e),B=(k,D)=>{let N=F(k),Y=V(D,k);return N.children.push(Y),N.dirtySignal.value++,Y},{SetRule:P,SetRules:G}=Z(g,s,n),{SetStrategy:C}=ee(g),{SetValidators:L}=te(g),U=oe(s),H=()=>{let k=U();p=k.steps,c=k.levelMap};return{schema:f,SetRule:(...k)=>{P.apply(null,k),o=!0,!t&&new Promise((D,N)=>{t=!0,D()}).then(()=>{if(H(),o){let{directNextMap:D,directPrevMap:N}=m(p.flat());u=D,a=N}}).finally(()=>{t=!1,o=!1})},SetRules:(...k)=>{G.apply(null,k),o=!0,!t&&new Promise((D,N)=>{t=!0,D()}).then(()=>{if(H(),o){let{directNextMap:D,directPrevMap:N}=m(p.flat());u=D,a=N}}).finally(()=>{t=!1,o=!1})},SetStrategy:C,SetValidators:L,SetTrace:x,SetValue:(k,D)=>{g(k).dependOn(()=>D)},GetFormData:T,notifyAll:()=>{H(),b()},AddNewSchema:B,GetAllDependency:()=>s,GetDependencyOrder:()=>p,Undo:I,Redo:A,initCanUndo:O,initCanRedo:v,onError:S}}var q=new Map,$e=(l,e,o)=>{try{if(typeof o.signalCreateor!="function"||typeof o.signalTrigger!="function")throw Error("\u9700\u8981\u5B9A\u4E49signal\u6765\u901A\u77E5ui");if(q.has(l))throw Error("engineID\u91CD\u590D\uFF0C\u4FEE\u6539id\u6216\u8005\u4F7F\u7528symbol");let t=ie(e,o),{schema:s,GetFormData:n,SetRule:u,SetRules:a,SetStrategy:p,SetValidators:c,SetValue:i,notifyAll:r,SetTrace:h,GetAllDependency:y,GetDependencyOrder:m,AddNewSchema:x,Undo:R,Redo:M,initCanUndo:w,initCanRedo:I,onError:A}=t,E={config:{SetRule:u,SetRules:a,SetStrategy:p,SetValidators:c,notifyAll:r,SetTrace:h},data:{schema:s,GetFormData:n,AddNewSchema:x,SetValue:i},history:{Undo:R,Redo:M,initCanUndo:w,initCanRedo:I},dependency:{GetAllDependency:y,GetDependencyOrder:m},hooks:{onError:A}};return q.set(l,E),E}catch(t){throw Error(t)}},Le=l=>{if(q.has(l))return q.get(l);throw Error("\u4E0D\u5B58\u5728\u7684id")},Ue=l=>{q.delete(l)};export{Ue as deleteEngine,Le as useEngine,$e as useEngineManager};
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meshflow/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A logic orchestration engine utilizing topological scheduling and watermark control to resolve asynchronous race conditions in complex dependency linkages.”",
|
|
5
|
+
"main": "./index.cjs",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"author": "nzy",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"form",
|
|
12
|
+
"form-engine",
|
|
13
|
+
"logic-engine",
|
|
14
|
+
"topology",
|
|
15
|
+
"async-linkage",
|
|
16
|
+
"watermark",
|
|
17
|
+
"dag",
|
|
18
|
+
"reactive"
|
|
19
|
+
]
|
|
20
|
+
}
|