@tmagic/utils 1.8.0-beta.24 → 1.8.0-beta.26

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/types/index.d.ts +2225 -1
package/types/index.d.ts CHANGED
@@ -1,12 +1,2236 @@
1
1
  import { DataSchema, DataSourceDeps, Id, MComponent, MNode, MNodeInstance } from "@tmagic/schema";
2
- import { MContainer, MNode as MNode$1, MPage, MPageFragment } from "@tmagic/core";
2
+ import { Component } from "vue";
3
+ import { EventEmitter } from "events";
4
+ import { PascalCasedProperties, Writable } from "type-fest";
5
+ import { CodeBlockContent, CodeBlockDSL, DataSourceSchema, DepData, DepExtendedData, DepTargetType, EventOption, Id as Id$1, MApp, MContainer, MNode as MNode$1, MPage, MPageFragment, Target, TargetOptions } from "@tmagic/core";
6
+ import { ChangeRecord, FormConfig, TableColumnConfig } from "@tmagic/form";
7
+ import StageCore, { CanDropIn, ContainerHighlightType, CustomizeMoveableOptions, GuidesOptions, RenderType, UpdateDragEl } from "@tmagic/stage";
8
+ //#region temp/packages/editor/src/services/BaseService.d.ts
9
+ /**
10
+ * 对Class进行扩展
11
+ * 给Class中的每个方法都添加before after两个钩子
12
+ * 给Class添加一个usePlugin方法,usePlugin方法可以传入一个包含before或者after方法的对象
13
+ *
14
+ * 例如:
15
+ * Class EditorService extends BaseService {
16
+ * constructor() {
17
+ * super([ { name: 'add', isAsync: true },]);
18
+ * }
19
+ * add(value) { return result; }
20
+ * };
21
+ *
22
+ * const editorService = new EditorService();
23
+ *
24
+ * editorService.usePlugin({
25
+ * beforeAdd(value) { return [value] },
26
+ * afterAdd(result, value) { return result },
27
+ * });
28
+ *
29
+ * editorService.add(); 最终会变成 () => {
30
+ * editorService.beforeAdd();
31
+ * editorService.add();
32
+ * editorService.afterAdd();
33
+ * }
34
+ *
35
+ * 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after第一个参数则是原方法的return值;
36
+ * 如需终止后续方法调用可以return new Error();
37
+ */
38
+ declare class BaseService extends EventEmitter {
39
+ private pluginOptionsList;
40
+ private taskList;
41
+ private doingTask;
42
+ constructor(methods?: {
43
+ name: string;
44
+ isAsync: boolean;
45
+ }[], serialMethods?: string[]);
46
+ usePlugin(options: Record<string, Function>): void;
47
+ removePlugin(options: Record<string, Function>): void;
48
+ removeAllPlugins(): void;
49
+ private doTask;
50
+ }
51
+ //#endregion
52
+ //#region temp/packages/editor/src/services/codeBlock.d.ts
53
+ declare const canUsePluginMethods$8: {
54
+ async: readonly ["setCodeDslById", "setEditStatus", "setCombineIds", "setUndeleteableList", "deleteCodeDslByIds"];
55
+ sync: string[];
56
+ };
57
+ type AsyncMethodName$4 = Writable<(typeof canUsePluginMethods$8)['async']>;
58
+ declare class CodeBlock extends BaseService {
59
+ private state;
60
+ /**
61
+ * 最近一次写入历史栈的代码块历史记录 uuid(单条写入场景:新增 / 更新)。
62
+ * 供 setCodeDslById(Sync)AndGetHistoryId 取回,普通方法不读取它。
63
+ */
64
+ private lastPushedHistoryId;
65
+ /**
66
+ * deleteCodeDslByIds 一次删除多个代码块时,按写入顺序收集的历史记录 uuid 列表。
67
+ * 在 deleteCodeDslByIds 入口处重置,供 deleteCodeDslByIdsAndGetHistoryId 取回。
68
+ */
69
+ private lastDeletedHistoryIds;
70
+ constructor();
71
+ /**
72
+ * 设置活动的代码块dsl数据源
73
+ * @param {CodeBlockDSL} codeDsl 代码DSL
74
+ * @returns {void}
75
+ */
76
+ setCodeDsl(codeDsl: CodeBlockDSL): Promise<void>;
77
+ /**
78
+ * 获取活动的代码块dsl数据源(默认从dsl中的codeBlocks字段读取)
79
+ * 方法要支持钩子添加扩展,会被重写为异步方法,因此这里显示写为异步以提醒调用者需以异步形式调用
80
+ * @param {boolean} forceRefresh 是否强制从活动dsl拉取刷新
81
+ * @returns {CodeBlockDSL | null}
82
+ */
83
+ getCodeDsl(): CodeBlockDSL | null;
84
+ /**
85
+ * 根据代码块id获取代码块内容
86
+ * @param {Id} id 代码块id
87
+ * @returns {CodeBlockContent | null}
88
+ */
89
+ getCodeContentById(id: Id$1): CodeBlockContent | null;
90
+ /**
91
+ * 设置代码块ID和代码内容到源dsl
92
+ * @param {Id} id 代码块id
93
+ * @param {CodeBlockContent} codeConfig 代码块内容配置信息
94
+ * @param options 可选配置
95
+ * @param options.changeRecords form 端 propPath/value 列表,用于历史记录的精细化撤销/重做
96
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
97
+ * @returns {void}
98
+ */
99
+ setCodeDslById(id: Id$1, codeConfig: Partial<CodeBlockContent>, { changeRecords, doNotPushHistory, historyDescription, historySource }?: HistoryOpOptionsWithChangeRecords): Promise<void>;
100
+ /**
101
+ * 为了兼容历史原因
102
+ * 设置代码块ID和代码内容到源dsl
103
+ * @param {Id} id 代码块id
104
+ * @param {CodeBlockContent} codeConfig 代码块内容配置信息
105
+ * @param {boolean} force 是否强制写入,默认true
106
+ * @param options 可选配置
107
+ * @param options.changeRecords form 端 propPath/value 列表,用于历史记录的精细化撤销/重做
108
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
109
+ * @param options.historyDescription 入栈时附带的人类可读描述,用于历史面板展示
110
+ * @returns {void}
111
+ */
112
+ setCodeDslByIdSync(id: Id$1, codeConfig: Partial<CodeBlockContent>, force?: boolean, { changeRecords, doNotPushHistory, historyDescription, historySource }?: HistoryOpOptionsWithChangeRecords): void;
113
+ /**
114
+ * 根据代码块id数组获取代码dsl
115
+ * @param {string[]} ids 代码块id数组
116
+ * @returns {CodeBlockDSL}
117
+ */
118
+ getCodeDslByIds(ids: string[]): CodeBlockDSL;
119
+ /**
120
+ * 获取编辑状态
121
+ * @returns {boolean} 是否可编辑
122
+ */
123
+ getEditStatus(): boolean;
124
+ /**
125
+ * 设置编辑状态
126
+ * @param {boolean} status 是否可编辑
127
+ * @returns {void}
128
+ */
129
+ setEditStatus(status: boolean): Promise<void>;
130
+ /**
131
+ * 设置当前选中组件已关联绑定的代码块id数组
132
+ * @param {string[]} ids 代码块id数组
133
+ * @returns {void}
134
+ */
135
+ setCombineIds(ids: string[]): Promise<void>;
136
+ /**
137
+ * 获取当前选中组件已关联绑定的代码块id数组
138
+ * @returns {string[]}
139
+ */
140
+ getCombineIds(): string[];
141
+ /**
142
+ * 获取不可删除列表
143
+ * @returns {Id[]}
144
+ */
145
+ getUndeletableList(): Id$1[];
146
+ /**
147
+ * 设置不可删除列表:为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除)
148
+ * @param {Id[]} codeIds 代码块id数组
149
+ * @returns {void}
150
+ */
151
+ setUndeleteableList(codeIds: Id$1[]): Promise<void>;
152
+ /**
153
+ * 设置代码草稿
154
+ */
155
+ setCodeDraft(codeId: Id$1, content: string): void;
156
+ /**
157
+ * 获取代码草稿
158
+ */
159
+ getCodeDraft(codeId: Id$1): string | null;
160
+ /**
161
+ * 删除代码草稿
162
+ */
163
+ removeCodeDraft(codeId: Id$1): void;
164
+ /**
165
+ * 在dsl数据源中删除指定id的代码块
166
+ * @param {Id[]} codeIds 需要删除的代码块id数组
167
+ * @param options 可选配置
168
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
169
+ */
170
+ deleteCodeDslByIds(codeIds: Id$1[], { doNotPushHistory, historyDescription, historySource }?: HistoryOpOptions): Promise<void>;
171
+ /**
172
+ * 下列 *AndGetHistoryId 方法与对应的写入方法行为完全一致,
173
+ * 返回值在 {@link DslOpWithHistoryIdsResult} 中同时包含原操作结果与本次写入的历史 uuid 列表,
174
+ * 可用于精确引用 / 定位该条历史记录(埋点、revert、跨端同步等)。
175
+ *
176
+ * 当本次操作未写入历史(doNotPushHistory 为 true、或无对应记录)时 historyIds 为 `[]`。
177
+ */
178
+ /** 等价于 {@link setCodeDslById},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
179
+ setCodeDslByIdAndGetHistoryId(id: Id$1, codeConfig: Partial<CodeBlockContent>, options?: HistoryOpOptionsWithChangeRecords): Promise<DslOpWithHistoryIdsResult<void>>;
180
+ /** 等价于 {@link setCodeDslByIdSync},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
181
+ setCodeDslByIdSyncAndGetHistoryId(id: Id$1, codeConfig: Partial<CodeBlockContent>, force?: boolean, options?: HistoryOpOptionsWithChangeRecords): DslOpWithHistoryIdsResult<void>;
182
+ /**
183
+ * 等价于 {@link deleteCodeDslByIds},并额外返回本次写入的全部历史记录 uuid(按删除顺序)。
184
+ * 一次删除多个代码块会产生多条历史记录;未写入任何历史时 historyIds 为 `[]`。
185
+ */
186
+ deleteCodeDslByIdsAndGetHistoryId(codeIds: Id$1[], options?: HistoryOpOptions): Promise<DslOpWithHistoryIdsResult<void>>;
187
+ setParamsColConfig(config: TableColumnConfig): void;
188
+ getParamsColConfig(): TableColumnConfig | undefined;
189
+ /**
190
+ * 撤销指定代码块的最近一次变更。
191
+ *
192
+ * 内部走 setCodeDslByIdSync / deleteCodeDslByIds,因此会自动触发 codeBlockService 的
193
+ * `addOrUpdate` / `remove` 事件,由 initService 中的 handler 重新维护 dep target
194
+ * (DepTargetType.CODE_BLOCK 的 add / remove)。所有写回都带 `doNotPushHistory: true`,
195
+ * 确保不会在历史栈里产生新的记录。
196
+ *
197
+ * @param id 代码块 id
198
+ * @returns 撤销的 step;栈不存在或已无可撤销时返回 null
199
+ */
200
+ undo(id: Id$1): Promise<CodeBlockStepValue | null>;
201
+ /**
202
+ * 重做指定代码块的下一次变更。
203
+ * @param id 代码块 id
204
+ * @returns 重做的 step;栈不存在或已无可重做时返回 null
205
+ */
206
+ redo(id: Id$1): Promise<CodeBlockStepValue | null>;
207
+ /** 是否可对指定代码块撤销。 */
208
+ canUndo(id: Id$1): boolean;
209
+ /** 是否可对指定代码块重做。 */
210
+ canRedo(id: Id$1): boolean;
211
+ /**
212
+ * 跳转指定代码块的历史栈到目标游标。语义同 editor.gotoPageStep。
213
+ *
214
+ * @param id 代码块 id
215
+ * @param targetCursor 目标游标位置(已应用步骤数量)
216
+ * @returns 实际移动到的最终游标位置
217
+ */
218
+ goto(id: Id$1, targetCursor: number): Promise<number>;
219
+ /**
220
+ * 「回滚」指定代码块历史步骤(类 git revert 语义):
221
+ * - 不动原始栈结构(不移动 cursor、不丢弃任何步骤);
222
+ * - 把目标 step 的修改**反向应用**一次,并作为**新步骤**追加到栈顶;
223
+ * - 仅对已应用的步骤生效。
224
+ *
225
+ * @param id 代码块 id
226
+ * @param index 目标 step 在该栈中的索引(0 为最早),通常由历史面板传入
227
+ * @returns 反向后产生的新 step;目标不存在 / 未应用时返回 null
228
+ */
229
+ revert(id: Id$1, index: number): Promise<CodeBlockStepValue | null>;
230
+ /**
231
+ * 通过历史记录 uuid 回滚代码块历史步骤,语义同 {@link revert},
232
+ * 仅无需调用方再传 codeBlockId 与 index:内部会按 uuid 在全部代码块栈中定位对应步骤后再回滚。
233
+ * 按数组顺序依次回滚,返回与入参同序的结果列表(某项失败时为 `null`)。
234
+ *
235
+ * @param uuids 目标历史记录的 uuid 列表,通常由 {@link setCodeDslByIdAndGetHistoryId} 等方法返回的 `historyIds`
236
+ */
237
+ revertById(uuids: string[]): Promise<(CodeBlockStepValue | null)[]>;
238
+ /**
239
+ * 生成代码块唯一id
240
+ * @returns {Id} 代码块唯一id
241
+ */
242
+ getUniqueId(): Promise<string>;
243
+ /**
244
+ * 复制时会带上组件关联的代码块
245
+ * @param config 组件节点配置
246
+ * @returns
247
+ */
248
+ copyWithRelated(config: MNode$1 | MNode$1[], collectorOptions?: TargetOptions): void;
249
+ /**
250
+ * 粘贴代码块
251
+ * @returns
252
+ */
253
+ paste(): void;
254
+ resetState(): void;
255
+ destroy(): void;
256
+ usePlugin(options: AsyncHookPlugin<AsyncMethodName$4, CodeBlock>): void;
257
+ /**
258
+ * 反向应用一个 step 并以新 step 入栈。逻辑与 applyHistoryStep(reverse=true) 同构,
259
+ * 差异仅在于通过公开的 setCodeDslByIdSync / deleteCodeDslByIds 触发 push。
260
+ */
261
+ private applyRevertStep;
262
+ /**
263
+ * 把一条历史 step 应用到当前代码块服务上。
264
+ *
265
+ * 复用现有的 setCodeDslByIdSync / deleteCodeDslByIds,目的是借助它们发出的事件
266
+ * 触发 initService 中的 dep target 维护(CODE_BLOCK 的 add / remove)。
267
+ * 所有写回都带 `doNotPushHistory: true`,确保不会在历史栈里产生新的记录。
268
+ *
269
+ * - oldContent=null, newContent≠null:原始为新增 → undo 删除;redo 再次 setCodeDslByIdSync
270
+ * - oldContent≠null, newContent=null:原始为删除 → undo 还原写入;redo 再次删除
271
+ * - 两侧都有:原始为更新 → 按 changeRecords 局部 patch;缺省退化为整内容替换
272
+ *
273
+ * @param step 历史 step
274
+ * @param reverse true=撤销,false=重做
275
+ */
276
+ private applyHistoryStep;
277
+ }
278
+ type CodeBlockService = CodeBlock;
279
+ //#endregion
280
+ //#region temp/packages/editor/src/services/componentList.d.ts
281
+ declare class ComponentList extends BaseService {
282
+ private state;
283
+ constructor();
284
+ /**
285
+ * @param componentGroupList 组件列表配置
286
+ */
287
+ setList(componentGroupList: ComponentGroup[]): void;
288
+ getList(): ComponentGroup[];
289
+ resetState(): void;
290
+ destroy(): void;
291
+ }
292
+ type ComponentListService = ComponentList;
293
+ //#endregion
294
+ //#region temp/packages/editor/src/services/dataSource.d.ts
295
+ interface State$1 {
296
+ datasourceTypeList: DatasourceTypeOption[];
297
+ dataSources: DataSourceSchema[];
298
+ editable: boolean;
299
+ configs: Record<string, FormConfig>;
300
+ values: Record<string, Partial<DataSourceSchema>>;
301
+ events: Record<string, EventOption[]>;
302
+ methods: Record<string, EventOption[]>;
303
+ }
304
+ type StateKey$1 = keyof State$1;
305
+ declare const canUsePluginMethods$7: {
306
+ async: never[];
307
+ sync: readonly ["getFormConfig", "setFormConfig", "getFormValue", "setFormValue", "getFormEvent", "setFormEvent", "getFormMethod", "setFormMethod", "add", "update", "remove", "createId"];
308
+ };
309
+ type SyncMethodName$5 = Writable<(typeof canUsePluginMethods$7)['sync']>;
310
+ declare class DataSource extends BaseService {
311
+ private state;
312
+ /**
313
+ * 最近一次写入历史栈的数据源历史记录 uuid。
314
+ * 供 *AndGetHistoryId 系列方法在调用 add / update / remove 后取回本次产生的历史记录 id;
315
+ * 普通方法不读取它,调用前由 *AndGetHistoryId 重置为 null。
316
+ */
317
+ private lastPushedHistoryId;
318
+ constructor();
319
+ set<K extends StateKey$1, T extends State$1[K]>(name: K, value: T): void;
320
+ get<K extends StateKey$1>(name: K): State$1[K];
321
+ getFormConfig(type?: string): FormConfig;
322
+ setFormConfig(type: string, config: FormConfig): void;
323
+ getFormValue(type?: string): Partial<DataSourceSchema>;
324
+ setFormValue(type: string, value: Partial<DataSourceSchema>): void;
325
+ getFormEvent(type?: string): EventOption[];
326
+ setFormEvent(type: string, value?: EventOption[]): void;
327
+ getFormMethod(type?: string): EventOption[];
328
+ setFormMethod(type: string, value?: EventOption[]): void;
329
+ /**
330
+ * 新增数据源
331
+ * @param config 数据源配置
332
+ * @param options 可选配置
333
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
334
+ * @param options.historyDescription 入栈时附带的人类可读描述,用于历史面板展示
335
+ */
336
+ add(config: DataSourceSchema, { doNotPushHistory, historyDescription, historySource }?: HistoryOpOptions): {
337
+ id: string;
338
+ type: string;
339
+ title?: string;
340
+ description?: string;
341
+ fields: import("@tmagic/schema").DataSchema[];
342
+ methods: import("@tmagic/schema").CodeBlockContent[];
343
+ mocks?: import("@tmagic/schema").MockSchema[];
344
+ events: import("@tmagic/schema").EventConfig[];
345
+ disabledInitInJsEngine?: (import("@tmagic/schema").JsEngine | string)[];
346
+ };
347
+ /**
348
+ * 更新数据源
349
+ * @param config 数据源配置
350
+ * @param data 额外数据
351
+ * @param data.changeRecords form 端变更记录
352
+ * @param data.doNotPushHistory 是否不写入历史记录(默认 false)
353
+ * @param data.historyDescription 入栈时附带的人类可读描述,用于历史面板展示
354
+ */
355
+ update(config: DataSourceSchema, { changeRecords, doNotPushHistory, historyDescription, historySource }?: HistoryOpOptionsWithChangeRecords): DataSourceSchema;
356
+ /**
357
+ * 删除数据源
358
+ * @param id 数据源 id
359
+ * @param options 可选配置
360
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
361
+ * @param options.historyDescription 入栈时附带的人类可读描述,用于历史面板展示
362
+ */
363
+ remove(id: string, { doNotPushHistory, historyDescription, historySource }?: HistoryOpOptions): void;
364
+ /**
365
+ * 下列 *AndGetHistoryId 方法与对应的 add / update / remove 行为完全一致,
366
+ * 返回值在 {@link DslOpWithHistoryIdsResult} 中同时包含原操作结果与本次写入历史栈的 uuid 列表({@link DataSourceStepValue.uuid}),
367
+ * 可用于精确引用 / 定位该条历史记录(埋点、revert、跨端同步等)。
368
+ *
369
+ * 当本次操作未写入历史(doNotPushHistory 为 true、或无对应记录)时 historyIds 为 `[]`。
370
+ */
371
+ /** 等价于 {@link add},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
372
+ addAndGetHistoryId(config: DataSourceSchema, options?: HistoryOpOptions): DslOpWithHistoryIdsResult<DataSourceSchema>;
373
+ /** 等价于 {@link update},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
374
+ updateAndGetHistoryId(config: DataSourceSchema, options?: HistoryOpOptionsWithChangeRecords): DslOpWithHistoryIdsResult<DataSourceSchema>;
375
+ /** 等价于 {@link remove},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
376
+ removeAndGetHistoryId(id: string, options?: HistoryOpOptions): DslOpWithHistoryIdsResult<void>;
377
+ /**
378
+ * 撤销指定数据源的最近一次变更。
379
+ *
380
+ * 内部走 add / update / remove,因此会自动触发 dataSourceService 的事件,
381
+ * 由 initService 中的对应 handler 重新收集 dep(DATA_SOURCE / DATA_SOURCE_COND / DATA_SOURCE_METHOD)。
382
+ * 所有写回都带 `doNotPushHistory: true`,避免在历史栈里产生新的记录。
383
+ *
384
+ * @param id 数据源 id
385
+ * @returns 撤销的 step;栈不存在或已无可撤销时返回 null
386
+ */
387
+ undo(id: Id$1): DataSourceStepValue | null;
388
+ /**
389
+ * 重做指定数据源的下一次变更。
390
+ * @param id 数据源 id
391
+ * @returns 重做的 step;栈不存在或已无可重做时返回 null
392
+ */
393
+ redo(id: Id$1): DataSourceStepValue | null;
394
+ /** 是否可对指定数据源撤销。 */
395
+ canUndo(id: Id$1): boolean;
396
+ /** 是否可对指定数据源重做。 */
397
+ canRedo(id: Id$1): boolean;
398
+ /**
399
+ * 跳转指定数据源的历史栈到目标游标。语义同 editor.gotoPageStep。
400
+ *
401
+ * @param id 数据源 id
402
+ * @param targetCursor 目标游标位置(已应用步骤数量)
403
+ * @returns 实际移动到的最终游标位置
404
+ */
405
+ goto(id: Id$1, targetCursor: number): number;
406
+ /**
407
+ * 「回滚」指定数据源历史步骤(类 git revert 语义):
408
+ * - 不动原始栈结构(不移动 cursor、不丢弃任何步骤);
409
+ * - 把目标 step 的修改**反向应用**一次,并作为**新步骤**追加到栈顶;
410
+ * - 仅对已应用的步骤生效——未应用步骤本身就不存在于当前 schema 中,反向无意义。
411
+ *
412
+ * @param id 数据源 id
413
+ * @param index 目标 step 在该栈中的索引(0 为最早),通常由历史面板传入
414
+ * @returns 反向后产生的新 step;目标不存在 / 未应用时返回 null
415
+ */
416
+ revert(id: Id$1, index: number): DataSourceStepValue | null;
417
+ /**
418
+ * 通过历史记录 uuid 回滚数据源历史步骤,语义同 {@link revert},
419
+ * 仅无需调用方再传 dataSourceId 与 index:内部会按 uuid 在全部数据源栈中定位对应步骤后再回滚。
420
+ * 按数组顺序依次回滚,返回与入参同序的结果列表(某项失败时为 `null`)。
421
+ *
422
+ * @param uuids 目标历史记录的 uuid 列表,通常由 {@link addAndGetHistoryId} 等方法返回的 `historyIds`
423
+ */
424
+ revertById(uuids: string[]): (DataSourceStepValue | null)[];
425
+ createId(): string;
426
+ getDataSourceById(id: string): DataSourceSchema | undefined;
427
+ resetState(): void;
428
+ destroy(): void;
429
+ usePlugin(options: SyncHookPlugin<SyncMethodName$5, DataSource>): void;
430
+ /**
431
+ * 复制时会带上组件关联的数据源
432
+ * @param config 组件节点配置
433
+ * @returns
434
+ */
435
+ copyWithRelated(config: MNode$1 | MNode$1[], collectorOptions?: TargetOptions): void;
436
+ /**
437
+ * 粘贴数据源
438
+ * @returns
439
+ */
440
+ paste(): void;
441
+ /**
442
+ * 反向应用一个 step 并以新 step 入栈(不带 doNotPushHistory)。逻辑与 applyHistoryStep(reverse=true)
443
+ * 同构,差异仅在于走对应的公共 add / update / remove 而不是带 doNotPushHistory 的版本。
444
+ */
445
+ private applyRevertStep;
446
+ /**
447
+ * 把一条历史 step 应用到当前数据源服务上。
448
+ *
449
+ * 复用现有的 add / update / remove,目的是借助它们发出的事件触发 initService 中
450
+ * 的依赖收集逻辑(DATA_SOURCE / DATA_SOURCE_COND / DATA_SOURCE_METHOD)。
451
+ * 所有写回都带 `doNotPushHistory: true`,确保不会在历史栈里产生新的记录。
452
+ *
453
+ * - oldSchema=null, newSchema≠null:原始为新增 → undo 删除;redo 再次 add
454
+ * - oldSchema≠null, newSchema=null:原始为删除 → undo 还原 add;redo 再次删除
455
+ * - 两侧都有:原始为更新 → 按 changeRecords 局部 patch;缺省退化为整 schema 替换
456
+ *
457
+ * @param step 历史 step
458
+ * @param reverse true=撤销,false=重做
459
+ */
460
+ private applyHistoryStep;
461
+ }
462
+ type DataSourceService = DataSource;
463
+ //#endregion
464
+ //#region temp/packages/editor/src/utils/dep/worker.d.ts
465
+ type DepsData = Record<string, Record<Id$1, DepData>>;
466
+ //#endregion
467
+ //#region temp/packages/editor/src/services/dep.d.ts
468
+ interface DepEvents {
469
+ 'add-target': [target: Target];
470
+ 'remove-target': [id: string | number, type: string | DepTargetType];
471
+ collected: [nodes: MNode$1[], deep: boolean];
472
+ 'ds-collected': [nodes: MNode$1[], deep: boolean];
473
+ }
474
+ interface State {
475
+ collecting: boolean;
476
+ taskLength: number;
477
+ }
478
+ type StateKey = keyof State;
479
+ declare class Dep extends BaseService {
480
+ private state;
481
+ private idleTask;
482
+ private collectWorker;
483
+ private watcher;
484
+ private waitingWorker?;
485
+ private resolveWaitingWorker?;
486
+ private workerGeneration;
487
+ private activeBatches;
488
+ constructor();
489
+ set<K extends StateKey, T extends State[K]>(name: K, value: T): void;
490
+ get<K extends StateKey>(name: K): State[K];
491
+ removeTargets(type?: string): void;
492
+ getTargets(type?: string): {
493
+ [targetId: string]: Target;
494
+ [targetId: number]: Target;
495
+ };
496
+ getTarget(id: Id$1, type?: string): Target;
497
+ addTarget(target: Target): void;
498
+ removeTarget(id: Id$1, type?: string): void;
499
+ clearTargets(): void;
500
+ collect(nodes: MNode$1[], depExtendedData?: DepExtendedData, deep?: boolean, type?: DepTargetType): void;
501
+ /**
502
+ * 空闲收集依赖
503
+ *
504
+ * 遍历匹配是整个收集过程中最耗时的部分(要深度遍历节点树并对每个属性做 target 匹配),
505
+ * 节点/数据源多时在主线程执行会长时间卡死页面,因此优先交给 worker 执行,主线程只负责把结果写回 target。
506
+ * 自定义 target 的 isTarget 是无法跨线程传递的闭包函数(没有 descriptor),仍走主线程空闲队列;
507
+ * worker 不可用(如 SSR)或执行失败时也会回退到主线程空闲队列。
508
+ */
509
+ collectIdle(nodes: MNode$1[], depExtendedData?: DepExtendedData, deep?: boolean, type?: DepTargetType): Promise<boolean>;
510
+ collectByWorker(dsl: MApp): Promise<DepsData>;
511
+ collectNode(node: MNode$1, target: Target, depExtendedData?: DepExtendedData, deep?: boolean): void;
512
+ clear(nodes?: MNode$1[]): void;
513
+ clearByType(type: DepTargetType, nodes?: MNode$1[]): void;
514
+ hasTarget(id: Id$1, type?: string): boolean;
515
+ hasSpecifiedTypeTarget(type?: string): boolean;
516
+ clearIdleTasks(): void;
517
+ on<Name extends keyof DepEvents, Param extends DepEvents[Name]>(eventName: Name, listener: (...args: Param) => void | Promise<void>): this;
518
+ once<Name extends keyof DepEvents, Param extends DepEvents[Name]>(eventName: Name, listener: (...args: Param) => void | Promise<void>): this;
519
+ reset(): void;
520
+ destroy(): void;
521
+ emit<Name extends keyof DepEvents, Param extends DepEvents[Name]>(eventName: Name, ...args: Param): boolean;
522
+ /**
523
+ * 删除指定 page 在该 target 下的旧依赖:
524
+ * 按 pageId 匹配,可清掉页面内已被删除节点的残留依赖
525
+ */
526
+ private removePageDep;
527
+ /**
528
+ * 把遍历匹配交给 worker,结果回来后按 target 分片写回主线程
529
+ */
530
+ private collectByCollectWorker;
531
+ /**
532
+ * 用 worker 的收集结果替换 target 上这批节点的依赖
533
+ */
534
+ private enqueueApplyTask;
535
+ private enqueueTasks;
536
+ private enqueueTask;
537
+ private beginBatchTask;
538
+ private onBatchTaskDone;
539
+ private settleBatchDs;
540
+ private finishBatch;
541
+ /**
542
+ * idleTask 被清空时,在途批次的任务不会再执行,必须主动结算,
543
+ * 否则对应的 collectIdle Promise 永远不会 resolve(collecting 卡在 true、once 监听器泄漏)。
544
+ * 收集被中断(通常紧跟一次全量重新收集),因此不再 emit collected/ds-collected,仅结算 Promise。
545
+ */
546
+ private abortActiveBatches;
547
+ private updateCollectingState;
548
+ }
549
+ type DepService = Dep;
550
+ //#endregion
551
+ //#region temp/packages/editor/src/services/editor.d.ts
552
+ declare class Editor extends BaseService {
553
+ state: StoreState;
554
+ private selectionBeforeOp;
555
+ /**
556
+ * 操作前的节点校验错误快照,与 selectionBeforeOp 同时在 captureSelectionBeforeOp 中捕获,
557
+ * 供 pushOpHistory 写入 step.extra.invalidNodeIdsBefore,用于撤销时还原到「操作前」的错误状态。
558
+ */
559
+ private invalidNodeIdsBeforeOp;
560
+ /**
561
+ * 最近一次 pushOpHistory 写入的历史记录 uuid。
562
+ * 供 *AndGetHistoryId 系列方法在调用普通操作后取回本次产生的历史记录 id;
563
+ * 普通操作不会读取它,调用前由 *AndGetHistoryId 重置为 null。
564
+ */
565
+ private lastPushedHistoryId;
566
+ /**
567
+ * 上一次 doAdd 的插入记忆:nodeId 为插入的节点,selectedId 为当时的选中节点。
568
+ * 仅在选中节点未变化时复用(连续 add / doNotSelect / 批量粘贴),选中变化后自动失效,无需手动清理。
569
+ */
570
+ private lastAdded;
571
+ constructor();
572
+ /**
573
+ * 设置当前指点节点配置
574
+ * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'invalidNodeIds' | 'pageLength' | 'pageFragmentLength
575
+ * @param value MNode
576
+ * @param options.historySource 设置 root 时,本次变更写入历史记录的「操作来源」(仅 name === 'root' 时生效)
577
+ */
578
+ set<K extends StoreStateKey, T extends StoreState[K]>(name: K, value: T, options?: {
579
+ historySource?: HistoryOpSource;
580
+ }): void;
581
+ /**
582
+ * 获取当前指点节点配置
583
+ * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'invalidNodeIds' | 'pageLength' | 'pageFragmentLength'
584
+ * @returns MNode
585
+ */
586
+ get<K extends StoreStateKey>(name: K): StoreState[K];
587
+ /**
588
+ * 根据id获取组件、组件的父组件以及组件所属的页面节点
589
+ * @param {number | string} id 组件id
590
+ * @param {boolean} raw 是否使用toRaw
591
+ * @returns {EditorNodeInfo}
592
+ */
593
+ getNodeInfo(id: Id$1, raw?: boolean): EditorNodeInfo;
594
+ /**
595
+ * 根据ID获取指点节点配置
596
+ * @param id 组件ID
597
+ * @param {boolean} raw 是否使用toRaw
598
+ * @returns 组件节点配置
599
+ */
600
+ getNodeById(id: Id$1, raw?: boolean): MNode$1 | null;
601
+ /**
602
+ * 根据ID获取指点节点的父节点配置
603
+ * @param id 组件ID
604
+ * @param {boolean} raw 是否使用toRaw
605
+ * @returns 指点组件的父节点配置
606
+ */
607
+ getParentById(id: Id$1, raw?: boolean): MContainer | null;
608
+ /**
609
+ * 判断给定节点是否位于非当前页面(即选中该节点将会引起当前页面切换)
610
+ * @param node 节点
611
+ * @returns true 表示该节点位于非当前页面
612
+ */
613
+ isOnDifferentPage(node: MNode$1): boolean;
614
+ /**
615
+ * 只有容器拥有布局
616
+ */
617
+ getLayout(parent: MNode$1, node?: MNode$1 | null): Promise<Layout>;
618
+ /**
619
+ * 选中指定节点(将指定节点设置成当前选中状态)
620
+ * @param config 指定节点配置或者ID
621
+ * @returns 当前选中的节点配置
622
+ */
623
+ select(config: MNode$1 | Id$1): Promise<MNode$1> | never;
624
+ selectNextNode(): Promise<MNode$1 | null> | never;
625
+ selectNextPage(): Promise<MNode$1> | never;
626
+ /**
627
+ * 高亮指定节点
628
+ * @param config 指定节点配置或者ID
629
+ * @returns 当前高亮的节点配置
630
+ */
631
+ highlight(config: MNode$1 | Id$1): void;
632
+ /**
633
+ * 多选
634
+ * @param ids 指定节点ID
635
+ * @returns 加入多选的节点配置
636
+ */
637
+ multiSelect(ids: Id$1[]): void;
638
+ selectRoot(): void;
639
+ doAdd(node: MNode$1, parent: MContainer, _options?: DslOpOptions): Promise<MNode$1>;
640
+ /**
641
+ * 向指点容器添加组件节点
642
+ * @param addConfig 将要添加的组件节点配置
643
+ * @param parent 要添加到的容器组件节点配置,如果不设置,默认为当前选中的组件的父节点
644
+ * @param options 可选配置,见 {@link DslOpOptions}
645
+ * @returns 添加后的节点
646
+ */
647
+ add(addNode: AddMNode | MNode$1[], parent?: MContainer | null, options?: DslOpOptions): Promise<MNode$1 | MNode$1[]>;
648
+ doRemove(node: MNode$1, { doNotSelect, doNotSwitchPage }?: DslOpOptions): Promise<void>;
649
+ /**
650
+ * 删除组件
651
+ * @param {Object} node 要删除的节点或节点集合
652
+ * @param options 可选配置
653
+ * @param options.doNotSelect 删除后是否不更新当前选中节点(默认 false,删除后会选中父节点或首个页面)
654
+ * @param options.doNotSwitchPage 删除后是否不切换当前页面(默认 false;删除页面 / 页面片段时为 true 会跳过自动切换到首个剩余页面)
655
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
656
+ */
657
+ remove(nodeOrNodeList: MNode$1 | MNode$1[], options?: DslOpOptions): Promise<void>;
658
+ doUpdate(config: MNode$1, data?: UpdateOptions): Promise<{
659
+ newNode: MNode$1;
660
+ oldNode: MNode$1;
661
+ changeRecords?: ChangeRecord[];
662
+ }>;
663
+ /**
664
+ * 更新节点
665
+ * update后会触发依赖收集,收集完后会掉stage.update方法
666
+ * @param config 新的节点配置,配置中需要有id信息
667
+ * @param data 额外数据,见 {@link UpdateOptions}
668
+ * @returns 更新后的节点配置
669
+ */
670
+ update(config: MNode$1 | MNode$1[], data?: UpdateOptions): Promise<MNode$1 | MNode$1[]>;
671
+ /**
672
+ * 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
673
+ * @param id1 组件ID
674
+ * @param id2 组件ID
675
+ * @param options 可选配置
676
+ * @param options.doNotSelect 排序后是否不更新当前选中节点(默认 false)
677
+ * @param options.doNotSwitchPage 排序后是否不切换当前页面(排序只发生在同一父节点内,方法内为空操作;保留以与其它 DSL 操作 API 一致)
678
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
679
+ * @returns void
680
+ */
681
+ sort(id1: Id$1, id2: Id$1, { doNotSelect, doNotPushHistory, historySource }?: DslOpOptions): Promise<void>;
682
+ /**
683
+ * 将组件节点配置存储到localStorage中
684
+ * @param config 组件节点配置
685
+ * @returns
686
+ */
687
+ copy(config: MNode$1 | MNode$1[]): void;
688
+ /**
689
+ * 复制时会带上组件关联的依赖
690
+ * @param config 组件节点配置
691
+ * @returns
692
+ */
693
+ copyWithRelated(config: MNode$1 | MNode$1[], collectorOptions?: TargetOptions): void;
694
+ /**
695
+ * 从localStorage中获取节点,然后添加到当前容器中
696
+ * @param position 粘贴的坐标
697
+ * @param collectorOptions 可选的依赖收集器配置
698
+ * @param options 可选配置
699
+ * @param options.doNotSelect 粘贴后是否不更新当前选中节点(默认 false)
700
+ * @param options.doNotSwitchPage 粘贴后是否不切换当前页面(默认 false;跨页粘贴时为 true 会跳过页面切换)
701
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
702
+ * @returns 添加后的组件节点配置
703
+ */
704
+ paste(position?: PastePosition, collectorOptions?: TargetOptions, { doNotSelect, doNotSwitchPage, doNotPushHistory, historyDescription, historySource }?: DslOpOptions): Promise<MNode$1 | MNode$1[] | void>;
705
+ doPaste(config: MNode$1[], position?: PastePosition): Promise<MNode$1[]>;
706
+ doAlignCenter(config: MNode$1): Promise<MNode$1>;
707
+ /**
708
+ * 将指点节点设置居中
709
+ * @param config 组件节点配置
710
+ * @param options 可选配置
711
+ * @param options.doNotSelect 居中后是否不更新当前选中节点(默认 false)
712
+ * @param options.doNotSwitchPage 居中后是否不切换当前页面(居中只更新节点 style,方法内为空操作;保留以与其它 DSL 操作 API 一致)
713
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
714
+ * @returns 当前组件节点配置
715
+ */
716
+ alignCenter(config: MNode$1 | MNode$1[], { doNotSelect, doNotPushHistory, historyDescription, historySource }?: DslOpOptions): Promise<MNode$1 | MNode$1[]>;
717
+ /**
718
+ * 移动当前选中节点位置
719
+ * @param offset 偏移量
720
+ * @param options 可选配置
721
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
722
+ */
723
+ moveLayer(offset: number | LayerOffset, { doNotPushHistory, historyDescription, historySource }?: DslOpOptions): Promise<void>;
724
+ /**
725
+ * 移动一个或多个节点到指定容器中。
726
+ *
727
+ * 多选场景(config 是数组)只会产生一条历史记录,
728
+ * `updatedItems` 涵盖所有源父容器 + 目标容器的前后快照。
729
+ * 这避免了"多选移动到某容器"在历史栈里被切成 N 条记录。
730
+ *
731
+ * @param config 需要移动的节点(或节点数组,各项需带 id;style 等字段会与原节点合并)
732
+ * @param targetId 容器ID
733
+ * @param options 可选配置
734
+ * @param options.doNotSelect 移动后是否不更新当前选中节点(默认 false)
735
+ * @param options.doNotSwitchPage 移动后是否不切换当前页面(默认 false;目标容器位于其它页面时为 true 会跳过自动选中以避免页面切换)
736
+ * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
737
+ */
738
+ moveToContainer(config: MNode$1 | MNode$1[], targetId: Id$1, { doNotSelect, doNotSwitchPage, doNotPushHistory, historyDescription, historySource }?: DslOpOptions): Promise<MNode$1 | MNode$1[]>;
739
+ dragTo(config: MNode$1 | MNode$1[], targetParent: MContainer, targetIndex: number, { doNotPushHistory, historyDescription, historySource }?: DslOpOptions): Promise<void>;
740
+ /**
741
+ * 下列 *AndGetHistoryId 方法与对应的普通操作(add / remove / update ...)行为完全一致,
742
+ * 返回值在 {@link DslOpWithHistoryIdsResult} 中同时包含原操作结果与本次写入历史栈的 uuid 列表({@link StepValue.uuid}),
743
+ * 可用于精确引用 / 定位该条历史记录(埋点、revert、跨端同步等)。
744
+ *
745
+ * 当本次操作未写入历史(doNotPushHistory 为 true、或操作无实际变更 / 提前返回)时 historyIds 为 `[]`。
746
+ */
747
+ /** 等价于 {@link add},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
748
+ addAndGetHistoryId(addNode: AddMNode | MNode$1[], parent?: MContainer | null, options?: DslOpOptions): Promise<DslOpWithHistoryIdsResult<MNode$1 | MNode$1[]>>;
749
+ /** 等价于 {@link remove},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
750
+ removeAndGetHistoryId(nodeOrNodeList: MNode$1 | MNode$1[], options?: DslOpOptions): Promise<DslOpWithHistoryIdsResult<void>>;
751
+ /** 等价于 {@link update},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
752
+ updateAndGetHistoryId(config: MNode$1 | MNode$1[], data?: UpdateOptions): Promise<DslOpWithHistoryIdsResult<MNode$1 | MNode$1[]>>;
753
+ /** 等价于 {@link moveLayer},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
754
+ moveLayerAndGetHistoryId(offset: number | LayerOffset, options?: DslOpOptions): Promise<DslOpWithHistoryIdsResult<void>>;
755
+ /** 等价于 {@link moveToContainer},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
756
+ moveToContainerAndGetHistoryId(config: MNode$1 | MNode$1[], targetId: Id$1, options?: DslOpOptions): Promise<DslOpWithHistoryIdsResult<MNode$1 | MNode$1[]>>;
757
+ /** 等价于 {@link dragTo},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
758
+ dragToAndGetHistoryId(config: MNode$1 | MNode$1[], targetParent: MContainer, targetIndex: number, options?: DslOpOptions): Promise<DslOpWithHistoryIdsResult<void>>;
759
+ /**
760
+ * 撤销当前操作
761
+ * @returns 被撤销的操作
762
+ */
763
+ undo(): Promise<StepValue | null>;
764
+ /**
765
+ * 恢复到下一步
766
+ * @returns 被恢复的操作
767
+ */
768
+ redo(): Promise<StepValue | null>;
769
+ /**
770
+ * 「回滚」指定页面历史步骤(类 git revert 语义):
771
+ * - 不动原始历史栈结构(不移动 cursor、不丢弃任何步骤);
772
+ * - 取出 `index` 对应的 step,**反向应用**一次(add→remove / remove→add / update→旧值);
773
+ * - 把这次反向应用作为一条**新步骤**追加到栈顶,可被普通 undo / redo。
774
+ *
775
+ * 与 `gotoPageStep`(类 git reset)的区别在于此操作**不丢弃**目标之后的历史。
776
+ * 与 `applyHistoryOp(reverse=true)` 的区别在于:本方法**不带** `doNotPushHistory`,
777
+ * 反向应用会以一条新 step 入栈;并且不实施 step 中保存的选区与 modifiedNodeIds 状态,
778
+ * 选区由用户当前位置决定,符合"新提交"语义。
779
+ *
780
+ * 仅对处于「已应用」状态的步骤生效——未应用的步骤本身就不存在于当前 DSL 中,反向无意义。
781
+ *
782
+ * @param index 目标 step 在所属页面栈中的索引(0 为最早),通常由历史面板传入
783
+ * @returns 反向后产生的新 step;目标不存在 / 未应用 / 反向失败时返回 null
784
+ */
785
+ revertPageStep(index: number): Promise<StepValue | null>;
786
+ /**
787
+ * 通过历史记录 uuid 回滚当前页面的历史步骤,语义与 {@link revertPageStep} 完全一致,
788
+ * 仅入参从 index 改为 uuid 列表({@link StepValue.uuid})。按数组顺序依次回滚,
789
+ * 返回与入参同序的结果列表(某项失败时为 `null`)。
790
+ *
791
+ * @param uuids 目标历史记录的 uuid 列表,通常由 *AndGetHistoryId 方法返回的 `historyIds`
792
+ */
793
+ revertPageStepById(uuids: string[]): Promise<(StepValue | null)[]>;
794
+ /**
795
+ * 跳转当前页面历史栈到指定游标位置。
796
+ *
797
+ * `targetCursor` 与 `UndoRedo.getCursor()` 同义:表示"已应用步骤数量",
798
+ * 取值范围 `[0, length]`。当目标 < 当前游标时循环 undo,否则循环 redo。
799
+ * 通常由历史面板传入「点击的 step.index + 1」作为目标。
800
+ *
801
+ * @returns 实际移动到的最终游标位置
802
+ */
803
+ gotoPageStep(targetCursor: number): Promise<number>;
804
+ move(left: number, top: number, { doNotPushHistory, historyDescription, historySource }?: DslOpOptions): Promise<void>;
805
+ resetState(): void;
806
+ destroy(): void;
807
+ resetModifiedNodeId(): void;
808
+ /**
809
+ * 记录(或覆盖)某个节点在指定来源(属性表单 / 样式表单)上的校验错误信息。
810
+ * @param id 节点 id
811
+ * @param source 错误来源:'props'(属性表单)| 'style'(样式表单)
812
+ * @param message 错误文案(可能是包含 <br> 的 HTML)
813
+ */
814
+ setInvalidNode(id: Id$1, source: NodeInvalidSource, message: string): void;
815
+ /**
816
+ * 删除节点的校验错误记录。
817
+ * @param id 节点 id
818
+ * @param source 指定来源则仅删除该来源;不传则删除该节点全部来源的错误
819
+ */
820
+ deleteInvalidNode(id: Id$1, source?: NodeInvalidSource): void;
821
+ /** 获取当前存在校验错误的节点错误 Map(key 为节点 id) */
822
+ getInvalidNodeIds(): Map<Id$1, NodeInvalidInfo>;
823
+ /** 获取指定节点的校验错误信息 */
824
+ getInvalidNodeInfo(id: Id$1): NodeInvalidInfo | undefined;
825
+ /** 清空全部校验错误记录 */
826
+ resetInvalidNodeId(): void;
827
+ usePlugin(options: AsyncHookPlugin<AsyncMethodName, Editor>): void;
828
+ on<Name extends keyof EditorEvents, Param extends EditorEvents[Name]>(eventName: Name, listener: (...args: Param) => void | Promise<void>): this;
829
+ once<Name extends keyof EditorEvents, Param extends EditorEvents[Name]>(eventName: Name, listener: (...args: Param) => void | Promise<void>): this;
830
+ emit<Name extends keyof EditorEvents, Param extends EditorEvents[Name]>(eventName: Name, ...args: Param): boolean;
831
+ /**
832
+ * 应用一次属性面板提交携带的校验错误信息(在写入历史记录之前调用,使历史快照与本次变更对齐)。
833
+ * - invalidInfo 为空(调用方未携带):认为本次更新对应的节点已无校验错误,清除其全部来源的错误;
834
+ * - error 非空则记录错误,为空则清除对应来源的错误。
835
+ */
836
+ private applyInvalidInfo;
837
+ /** 删除被移除节点(含其子树)的校验错误记录,避免残留误报 */
838
+ private removeInvalidNodesBySubtree;
839
+ /** 清理不在当前 DSL 中的失效节点错误记录(用于整体替换 root 后) */
840
+ private pruneInvalidNodeIds;
841
+ private addModifiedNodeId;
842
+ /**
843
+ * 获取指定节点所属的页面 / 页面片:
844
+ * - 普通节点返回其所在的 page;
845
+ * - 节点本身就是 page / pageFragment 时返回它自己;
846
+ * - 找不到时返回 null。
847
+ * 供 `change` 事件携带「变更节点对应的 page」(而非编辑器当前选中页)。
848
+ */
849
+ private getPageOfNode;
850
+ private captureSelectionBeforeOp;
851
+ /**
852
+ * 比较「上一次 root」与「新 root」的页面 / 页面片,按页面粒度把整体替换拆成历史记录:
853
+ * - 新旧都存在且内容变化的页面 → 一条 `update`(整页快照替换,无 changeRecords);
854
+ * - 仅新 root 存在的页面 → 一条 `add`;
855
+ * - 仅旧 root 存在的页面 → 一条 `remove`。
856
+ *
857
+ * 每条记录落到对应页面自己的历史栈(与普通节点操作一致),并标记来源 `source`。
858
+ * 内容未变化的页面不产生记录,避免重复设置相同 DSL 时产生噪声。
859
+ */
860
+ private pushRootDiffHistory;
861
+ /**
862
+ * 构造一条页面级「set root」历史记录(不携带选区 / modifiedNodeIds 上下文)并落到该页面自己的栈。
863
+ *
864
+ * 连续 set root 替换:若该页栈最新一条已是**同来源**的 set root 记录({@link StepValue.rootStep} 且 `source` 相同),
865
+ * 则用本次记录**替换**它而非新增,避免源码反复保存 / 外部重设 DSL 时堆积多条 root 记录;
866
+ * 来源不同则照常新增(initial 基线不是 rootStep,不在此列)。
867
+ */
868
+ private pushPageDiffStep;
869
+ private pushOpHistory;
870
+ /**
871
+ * 应用历史操作(撤销 / 重做)
872
+ *
873
+ * 删除 / 更新类修改走 `editor.remove / update`,并通过 `doNotPushHistory` 阻止再次入栈、
874
+ * `doNotSelect / doNotSwitchPage` 让选区由方法末尾的统一逻辑兜底;
875
+ * 「重新插回节点」(撤销 remove / 重做 add)需按 step 记录的 parentId / index 精确还原,
876
+ * 不走 this.add,由手工 splice + stage.add 完成后补发等价的 add / change 事件(见 emitHistoryInsertEvents)。
877
+ *
878
+ * 注意:这些路径都会发出 add / remove / update / change 事件,业务侧若需要区分"用户操作"与"撤销重做触发",
879
+ * 请监听 `history-change` 事件配合判断。
880
+ *
881
+ * @param step 操作记录
882
+ * @param reverse true = 撤销,false = 重做
883
+ */
884
+ private applyHistoryOp;
885
+ private selectedConfigExceptionHandler;
886
+ /**
887
+ * 撤销 remove / 重做 add 通过手工 splice 按 step 记录的 parentId / index 精确还原节点(不走 this.add,原因见调用处注释),
888
+ * 这里补齐与 this.add 等价的 add / change 事件,保证撤销/重做路径的事件行为与正向操作一致。
889
+ */
890
+ private emitHistoryInsertEvents;
891
+ }
892
+ type EditorService = Editor;
893
+ //#endregion
894
+ //#region temp/packages/editor/src/services/events.d.ts
895
+ declare const canUsePluginMethods$6: {
896
+ async: readonly [];
897
+ sync: readonly ["setEvent", "getEvent", "setMethod", "getMethod"];
898
+ };
899
+ type AsyncMethodName$3 = Writable<(typeof canUsePluginMethods$6)['async']>;
900
+ type SyncMethodName$4 = Writable<(typeof canUsePluginMethods$6)['sync']>;
901
+ declare class Events extends BaseService {
902
+ constructor();
903
+ setEvents(events: Record<string, EventOption[]>): void;
904
+ setEvent(type: string, events: EventOption[]): void;
905
+ getEvent(type: string, _data?: {
906
+ node?: MNode$1 | null;
907
+ }): EventOption[];
908
+ setMethods(methods: Record<string, EventOption[]>): void;
909
+ setMethod(type: string, method: EventOption[]): void;
910
+ getMethod(type: string, _data?: {
911
+ node?: MNode$1 | null;
912
+ targetId?: Id$1;
913
+ }): EventOption[];
914
+ resetState(): void;
915
+ destroy(): void;
916
+ usePlugin(options: AsyncHookPlugin<AsyncMethodName$3, Events> & SyncHookPlugin<SyncMethodName$4, Events>): void;
917
+ }
918
+ type EventsService = Events;
919
+ //#endregion
920
+ //#region temp/packages/editor/src/utils/undo-redo.d.ts
921
+ /**
922
+ * UndoRedo 栈的可序列化快照,用于持久化(如写入 IndexedDB)后再还原。
923
+ */
924
+ interface SerializedUndoRedo<T = any> {
925
+ /** 栈内全部元素(按时间正序,索引 0 为最早一步)。 */
926
+ elementList: T[];
927
+ /** 游标位置(已应用步骤数量)。 */
928
+ listCursor: number;
929
+ /** 栈容量上限。 */
930
+ listMaxSize: number;
931
+ }
932
+ declare class UndoRedo<T = any> {
933
+ /**
934
+ * 由 {@link UndoRedo.serialize} 产出的快照重建一个 UndoRedo 实例。
935
+ * 游标会被夹紧到 [0, length] 区间,避免脏数据导致越界。
936
+ *
937
+ * @param options.isSavedStep 可选谓词:若提供,则把游标定位到「最近一条满足该谓词的记录」之后
938
+ * (即恢复到最近一个已保存点);找不到匹配记录时退回快照中的原游标。
939
+ */
940
+ static fromSerialized<T = any>(data: SerializedUndoRedo<T>, options?: {
941
+ isSavedStep?: (element: T) => boolean;
942
+ }): UndoRedo<T>;
943
+ private elementList;
944
+ private listCursor;
945
+ private listMaxSize;
946
+ constructor(listMaxSize?: number);
947
+ /**
948
+ * 导出当前栈的可序列化快照(深克隆,避免外部改动污染内部状态)。
949
+ * 配合 {@link UndoRedo.fromSerialized} 可在持久化后完整还原撤销/重做栈。
950
+ */
951
+ serialize(): SerializedUndoRedo<T>;
952
+ pushElement(element: T): void;
953
+ canUndo(): boolean;
954
+ /** 返回被撤销的操作 */
955
+ undo(): T | null;
956
+ canRedo(): boolean;
957
+ /** 返回被重做的操作 */
958
+ redo(): T | null;
959
+ getCurrentElement(): T | null;
960
+ /**
961
+ * 用 `element` 替换当前游标所在元素(cursor - 1),并丢弃其后的重做尾部(与 {@link pushElement} 的丢尾一致),
962
+ * 游标位置保持不变(元素数量不增)。cursor 为 0(无已应用元素)时不做任何操作并返回 false。
963
+ * 用于「连续同类记录合并」等就地替换最新一条的场景。
964
+ */
965
+ replaceCurrentElement(element: T): boolean;
966
+ /**
967
+ * 对当前游标所在元素(cursor - 1)做就地更新;cursor 为 0(全部已撤销)时不做任何操作。
968
+ * 用于给「当前步骤」打标记(如标记为已保存)等元数据写入场景。
969
+ */
970
+ updateCurrentElement(updater: (element: T) => void): void;
971
+ /** 对栈内全部元素做就地更新。用于批量清理元数据(如清空所有元素的已保存标记)。 */
972
+ updateElements(updater: (element: T, index: number) => void): void;
973
+ /**
974
+ * 返回栈内全部元素的浅克隆数组(按时间顺序,索引 0 为最早一步)。
975
+ * 仅用于历史面板等只读展示场景,不应直接修改返回值。
976
+ */
977
+ getElementList(): T[];
978
+ /**
979
+ * 当前游标位置:表示已应用的步骤数量。
980
+ * - cursor === 0 表示全部已撤销
981
+ * - cursor === length 表示已重做到末尾
982
+ * 历史面板用于区分"已应用 / 已撤销"两段。
983
+ */
984
+ getCursor(): number;
985
+ /** 栈内总步数。 */
986
+ getLength(): number;
987
+ }
988
+ //#endregion
989
+ //#region temp/packages/editor/src/services/history.d.ts
990
+ declare const canUsePluginMethods$5: {
991
+ sync: readonly ["push", "undo", "redo"];
992
+ };
993
+ type SyncMethodName$3 = Writable<(typeof canUsePluginMethods$5)['sync']>;
994
+ declare class History extends BaseService {
995
+ state: {
996
+ steps: {
997
+ [x: string]: Record<Id$1, UndoRedo<any>>;
998
+ page: Record<Id$1, UndoRedo<StepValue>>;
999
+ codeBlock: Record<Id$1, UndoRedo<CodeBlockStepValue>>;
1000
+ dataSource: Record<Id$1, UndoRedo<DataSourceStepValue>>;
1001
+ };
1002
+ stepNames: Record<string, string>;
1003
+ };
1004
+ constructor();
1005
+ /**
1006
+ * 注册一个扩展历史类型,使其可与内置 `page` / `codeBlock` / `dataSource` 一样走统一的
1007
+ * {@link push} / {@link undo} / {@link redo}(按 id 分栈、独立 undo/redo)。
1008
+ *
1009
+ * @param stepType 自定义历史类型标识(勿与内置类型重名)
1010
+ * @param options.event push/undo/redo 后派发的事件名,缺省为 `${stepType}-history-change`
1011
+ * @param options.name 历史面板中的展示名称(tab / 分组标题等),缺省回退到 stepType 本身
1012
+ */
1013
+ registerStepType(stepType: string, options?: {
1014
+ event?: string;
1015
+ name?: string;
1016
+ }): void;
1017
+ /**
1018
+ * 读取指定历史类型的展示名称(用于历史面板 tab / 分组标题等)。
1019
+ * 未登记名称时回退到 stepType 本身。
1020
+ */
1021
+ getStepName(stepType: HistoryStepType): string;
1022
+ /**
1023
+ * 设置指定历史类型的展示名称(用于历史面板 tab / 分组标题等)。
1024
+ * 内置 `page` / `codeBlock` / `dataSource` 也可在此覆盖默认中文名。
1025
+ */
1026
+ setStepName(stepType: HistoryStepType, name: string): void;
1027
+ reset(): void;
1028
+ resetState(): void;
1029
+ /**
1030
+ * 为指定历史栈(默认 `page`,也适用于 codeBlock / dataSource / 扩展类型)种入一条「初始基线」记录。
1031
+ *
1032
+ * 该记录是一条 `opType: 'initial'` 的 step,作为对应栈 **index 0 的固定底线**:
1033
+ * - 它是一条真实入栈的 step(随栈一起持久化),但被钉为撤销/回滚的下限——cursor 永不低于它,
1034
+ * 因此不会被 undo / goto / revert 触达(详见 {@link undo} / {@link undoFloor});
1035
+ * - 历史面板把它过滤出分组列表(见 {@link getHistoryGroups}),改由底部「初始」行展示。
1036
+ *
1037
+ * 仅当目标栈为空时种入(保证 initial 一定位于 index 0);已存在 initial 底线时不重复种入。
1038
+ *
1039
+ * @param stepType 历史类型
1040
+ * @param id 目标栈 id(page 为 pageId,其余类型为对应资源 id)
1041
+ * @param options 基线展示信息(名称 / 描述 / 来源)
1042
+ */
1043
+ setMarker(stepType: HistoryStepType, id: Id$1, options?: {
1044
+ name?: string;
1045
+ description?: string;
1046
+ source?: HistoryOpSource;
1047
+ extra?: Record<string, any>;
1048
+ }): StepValue | null;
1049
+ /**
1050
+ * 读取指定历史栈的初始基线 step(栈 index 0 且 `opType: 'initial'`);
1051
+ * 不存在或 id 缺省时返回 undefined。
1052
+ */
1053
+ getMarker(stepType: HistoryStepType, id?: Id$1): StepValue | undefined;
1054
+ /**
1055
+ * 把一条步骤推入指定历史栈。统一入口,所有类型(page / codeBlock / dataSource / 扩展)行为完全一致:
1056
+ * 按 `stepType` 选择目标栈类型,按 `id`(必填)选择具体栈,按需建栈后入栈,并派发对应的历史变更事件
1057
+ * (`page` 为 `change`,其余见 {@link registerStepType}),回调签名统一为 `(id, step)`。
1058
+ *
1059
+ * 跨页 / 跨资源操作(如 `moveToContainer` 把节点搬到其它页)必须显式传入目标 id,
1060
+ * 否则无法落到正确的栈。step 可由 `createStackStep` 等构造后传入。
1061
+ *
1062
+ * @param stepType 历史类型
1063
+ * @param step 已构造好的历史记录(缺省自动补全 uuid / timestamp)
1064
+ * @param id 目标栈 id(page 为 pageId,其余类型为对应资源 id),必填
1065
+ */
1066
+ push(stepType: 'page', step: StepValue, id: Id$1): StepValue | null;
1067
+ push(stepType: 'codeBlock', step: CodeBlockStepValue, id: Id$1): CodeBlockStepValue | null;
1068
+ push(stepType: 'dataSource', step: DataSourceStepValue, id: Id$1): DataSourceStepValue | null;
1069
+ push<T extends BaseStepValue>(stepType: string, step: T, id: Id$1): T | null;
1070
+ /**
1071
+ * 撤销指定历史栈的最近一次变更。统一入口,所有类型行为一致:
1072
+ * 按 `id`(必填)+ `stepType` 定位栈,不会越过 index 0 的 initial 基线(所有类型同等适用),
1073
+ * 仅在确有可撤销 step 时派发对应的历史变更事件(`page` 为 `change`,回调签名 `(id, step)`)。
1074
+ *
1075
+ * @param stepType 历史类型
1076
+ * @param id 目标栈 id(page 为 pageId,其余类型为对应资源 id),必填
1077
+ */
1078
+ undo(stepType: 'page', id: Id$1): StepValue | null;
1079
+ undo(stepType: 'codeBlock', id: Id$1): CodeBlockStepValue | null;
1080
+ undo(stepType: 'dataSource', id: Id$1): DataSourceStepValue | null;
1081
+ undo<T extends BaseStepValue>(stepType: string, id: Id$1): T | null;
1082
+ /**
1083
+ * 重做指定历史栈的下一次变更。语义与 {@link undo} 对称,详见其说明。
1084
+ *
1085
+ * @param stepType 历史类型
1086
+ * @param id 目标栈 id(page 为 pageId,其余类型为对应资源 id),必填
1087
+ */
1088
+ redo(stepType: 'page', id: Id$1): StepValue | null;
1089
+ redo(stepType: 'codeBlock', id: Id$1): CodeBlockStepValue | null;
1090
+ redo(stepType: 'dataSource', id: Id$1): DataSourceStepValue | null;
1091
+ redo<T extends BaseStepValue>(stepType: string, id: Id$1): T | null;
1092
+ /**
1093
+ * 是否可对指定历史栈撤销(cursor 高于 initial 基线底线)。
1094
+ * @param stepType 历史类型
1095
+ * @param id 目标栈 id;缺省 / 无效时返回 false
1096
+ */
1097
+ canUndo(stepType: HistoryStepType, id?: Id$1): boolean;
1098
+ /**
1099
+ * 是否可对指定历史栈重做。
1100
+ * @param stepType 历史类型
1101
+ * @param id 目标栈 id;缺省 / 无效时返回 false
1102
+ */
1103
+ canRedo(stepType: HistoryStepType, id?: Id$1): boolean;
1104
+ /** 读取指定页面历史栈当前游标所在的 step(cursor - 1);无则返回 null。 */
1105
+ getCurrentPageStep(pageId: Id$1): StepValue | null;
1106
+ /**
1107
+ * 用 `state` 替换指定页面栈当前游标所在的 step(并丢弃其后的重做尾部),游标不变。
1108
+ * 用于「连续 set root 记录合并」等就地替换最新一条的场景;替换成功后派发 `change`。
1109
+ */
1110
+ replaceCurrentStep(stepType: HistoryStepType, state: StepValue, id: Id$1): StepValue | null;
1111
+ destroy(): void;
1112
+ /**
1113
+ * 清空历史记录栈。统一入口,所有类型(page / codeBlock / dataSource / 扩展)行为一致:
1114
+ * - 传入 `id`:仅清空 `stepType` 下该 id 对应的栈;
1115
+ * - 缺省 `id`:清空 `stepType` 下的全部栈。
1116
+ *
1117
+ * 仅删除撤销/重做记录,不会改动 DSL / 代码块 / 数据源本身。清空时会**保留各栈原有的
1118
+ * initial 基线**(文案 / 来源),无基线时清空成空栈。清空后派发 `clear`(签名 `(id, stepType)`)。
1119
+ *
1120
+ * @param stepType 历史类型
1121
+ * @param id 目标栈 id;缺省表示清空该类型下全部栈
1122
+ */
1123
+ clear(stepType: HistoryStepType, id?: Id$1): void;
1124
+ /**
1125
+ * 标记历史记录为「已保存」(把对应栈当前游标所在的记录标为 `saved`)。统一入口:
1126
+ * - 缺省 `id`:标记**全部类型、全部栈**(整份 DSL 落库场景),派发 `mark-saved` 且 `kind: 'all'`;
1127
+ * - 传入 `id`:仅标记 `stepType` 下该 id 对应的栈,派发 `mark-saved` 且 `kind` 为 `stepType`。
1128
+ *
1129
+ * 同一栈内任意时刻最多只有一条记录为 `saved`;从 IndexedDB 恢复时游标会被定位到最近一条已保存记录之后。
1130
+ *
1131
+ * @param stepType 历史类型
1132
+ * @param id 目标栈 id;缺省表示标记全部类型 / 全部栈
1133
+ */
1134
+ markSaved(stepType: HistoryStepType, id?: Id$1): void;
1135
+ /**
1136
+ * 派发「页面 / 页面片结构变更」事件(`page-structure-change`)。
1137
+ *
1138
+ * 常规 `editorService.add` / `remove` 页面节点不会写入 `page` 历史栈(见 editor.add / remove 中
1139
+ * 对 isPageOrFragment 的分支),因此不会产生任何 historyService 事件。该方法用于在这些
1140
+ * 场景(以及 setRoot 整体替换 DSL 增删页面)下,向外统一通知页面结构的增删变化,供业务方感知。
1141
+ *
1142
+ * 一次操作涉及多个页面时,调用方应把本次增删的页面**合并为一个 change 一次性传入**,
1143
+ * 使一次操作只派发一个事件;`add` / `remove` 分别为本次新增与删除的页面列表(其一可为空数组)。
1144
+ *
1145
+ * @param change 本次结构变更:{ add: 新增的页面列表, remove: 删除的页面列表 }
1146
+ */
1147
+ notifyPageStructureChange(change: {
1148
+ add: (MPage | MPageFragment)[];
1149
+ remove: (MPage | MPageFragment)[];
1150
+ }): void;
1151
+ /**
1152
+ * 把当前内存中的全部历史栈(页面 / 代码块 / 数据源 / 扩展类型)序列化后写入本地 IndexedDB。
1153
+ *
1154
+ * - 每个 UndoRedo 栈连同其游标、容量一并保存,恢复后可继续 undo/redo;
1155
+ * - `key` 用于区分不同活动页 / 项目(同一 store 下可保存多份快照),缺省为 `default`;
1156
+ * - 返回写入成功的快照对象,便于调用方记录 savedAt 等信息;
1157
+ * - 不支持 IndexedDB 的环境(如 SSR)会 reject。
1158
+ */
1159
+ saveToIndexedDB(options?: HistoryPersistOptions): Promise<PersistedHistoryState>;
1160
+ /**
1161
+ * 从本地 IndexedDB 读取此前保存的历史快照并重建全部撤销/重做栈。
1162
+ *
1163
+ * - 读取到的每个栈都会经 {@link UndoRedo.fromSerialized} 还原(含游标),随后可直接 undo/redo;
1164
+ * - 会整体覆盖当前内存中的历史状态(活动页由 editorService 维护,不在此恢复);
1165
+ * - 找不到对应记录时返回 null,且不改动当前状态;
1166
+ * - 不支持 IndexedDB 的环境(如 SSR)会 reject。
1167
+ */
1168
+ restoreFromIndexedDB(options?: HistoryPersistOptions): Promise<PersistedHistoryState | null>;
1169
+ /**
1170
+ * 取出指定历史类型(页面 / 代码块 / 数据源 / 扩展类型)某个栈的平铺步骤列表(含 applied 标记)。
1171
+ * 统一入口,替代旧的 `getPageStepList` / `getCodeBlockStepList` / `getDataSourceStepList`。
1172
+ *
1173
+ * 列表按时间正序,最早一步在最前面;`applied` 表示该步骤处于栈游标之前(已应用)。
1174
+ * 供 revert / goto 等按 index 索引步骤的场景使用。通常 UI 应使用
1175
+ * {@link getHistoryGroups} 取已合并分组的版本;本方法仅为兼容/调试保留。
1176
+ *
1177
+ * @param stepType 历史类型
1178
+ * @param id 目标栈 id(page 为 pageId,其余类型为对应资源 id);缺省 / 无效时返回空数组
1179
+ */
1180
+ getStepList(stepType: 'page', id?: Id$1): HistoryStepEntry<StepValue>[];
1181
+ getStepList(stepType: 'codeBlock', id: Id$1): HistoryStepEntry<CodeBlockStepValue>[];
1182
+ getStepList(stepType: 'dataSource', id: Id$1): HistoryStepEntry<DataSourceStepValue>[];
1183
+ getStepList<T extends BaseStepValue>(stepType: HistoryStepType, id?: Id$1): HistoryStepEntry<T>[];
1184
+ /**
1185
+ * 取出指定历史类型的历史分组(页面 / 代码块 / 数据源 / 扩展类型统一入口)。
1186
+ *
1187
+ * 把目标栈的步骤列表按"目标"做相邻合并(连续修改同一目标的 update 合并为一组,组内可展开查看每步;
1188
+ * add / remove / 多实体 update 始终独立成组),并过滤掉 index 0 的 initial 基线(底部「初始」行由
1189
+ * {@link getMarker} 驱动)。各类型行为完全一致,仅 `kind` 与 step 快照类型不同。
1190
+ *
1191
+ * 作用域:
1192
+ * - 传入 `id`:仅取该 id 对应的单个栈(页面历史按活动页查看,传入 pageId);
1193
+ * - 缺省 `id`:遍历该类型下全部栈并汇总(代码块 / 数据源按全部资源分桶展示)。
1194
+ *
1195
+ * @param stepType 历史类型,缺省 `page`
1196
+ * @param id 目标栈 id;缺省表示遍历该类型下全部栈
1197
+ */
1198
+ getHistoryGroups(stepType: 'page', id?: Id$1): HistoryGroup<StepValue>[];
1199
+ getHistoryGroups(stepType: 'codeBlock', id?: Id$1): HistoryGroup<CodeBlockStepValue>[];
1200
+ getHistoryGroups(stepType: 'dataSource', id?: Id$1): HistoryGroup<DataSourceStepValue>[];
1201
+ getHistoryGroups<T extends BaseStepValue>(stepType: HistoryStepType, id?: Id$1): HistoryGroup<T>[];
1202
+ /**
1203
+ * 读取指定历史栈的当前游标(已应用步骤数量)。统一入口,替代旧的
1204
+ * `getPageCursor` / `getCodeBlockCursor` / `getDataSourceCursor`。
1205
+ * - `id` 缺省或非法、或对应栈不存在时返回 0;
1206
+ * - `stepType` 支持 `page` / `codeBlock` / `dataSource` / 扩展类型。
1207
+ */
1208
+ getCursor(stepType: HistoryStepType, id?: Id$1): number;
1209
+ /**
1210
+ * 按历史记录 uuid 在指定历史类型的栈中查找其所属 id 与索引,统一入口,替代旧的
1211
+ * `getPageStepIndexByUuid` / `findCodeBlockStepLocationByUuid` / `findDataSourceStepLocationByUuid`。
1212
+ *
1213
+ * - 传入 `id`:仅在该 id 对应的单个栈中查找(如页面历史按活动页查看,传入 pageId);
1214
+ * - 缺省 `id`:遍历该类型下全部栈查找(代码块 / 数据源等按全部资源分桶的场景)。
1215
+ *
1216
+ * 找不到时返回 null。供「按 uuid 回滚」等需要把 uuid 映射回 (id, index) 的场景使用。
1217
+ *
1218
+ * @param stepType 历史类型
1219
+ * @param uuid 目标历史记录的 uuid
1220
+ * @param id 目标栈 id;缺省表示遍历该类型下全部栈
1221
+ */
1222
+ findStepLocationByUuid(stepType: HistoryStepType, uuid: string, id?: Id$1): {
1223
+ id: Id$1;
1224
+ index: number;
1225
+ } | null;
1226
+ usePlugin(options: SyncHookPlugin<SyncMethodName$3, History>): void;
1227
+ emit<Name extends keyof HistoryEvents, Param extends HistoryEvents[Name]>(eventName: Name, ...args: Param): boolean;
1228
+ /**
1229
+ * 取出指定历史类型的栈桶(`Record<id, UndoRedo>`);不存在时按需创建空桶,
1230
+ * 从而支持通过 {@link registerStepType} 或首次 push 动态扩展历史类型。
1231
+ */
1232
+ private getStepBucket;
1233
+ /**
1234
+ * 清空单个历史栈并按需重建其 initial 基线(保留原基线的文案 / 来源)。
1235
+ */
1236
+ private clearStack;
1237
+ /** 入栈前补全 step 的 uuid / timestamp(调用方未指定时)。 */
1238
+ private fillStepMeta;
1239
+ /** 校验「按 id 分栈」类型(codeBlock / dataSource / 扩展)的 id 是否有效。 */
1240
+ private isValidStackId;
1241
+ /** 清空全部历史栈内容(保留已注册的类型键,使扩展类型在 reset 后仍可用)。 */
1242
+ private clearAllSteps;
1243
+ /**
1244
+ * 把基础 dbName 与当前 DSL(root app)的 id 拼成最终库名,实现不同应用历史隔离。
1245
+ * 取不到 app id(如尚未加载 DSL)时退回基础 dbName。
1246
+ */
1247
+ private resolveDbName;
1248
+ }
1249
+ type HistoryService = History;
1250
+ //#endregion
1251
+ //#region temp/packages/editor/src/services/keybinding.d.ts
1252
+ declare class Keybinding extends BaseService {
1253
+ ctrlKey: string;
1254
+ private controllers;
1255
+ private bindingList;
1256
+ private commands;
1257
+ registerCommand(command: string, handler: (e: KeyboardEvent) => void | Promise<void>): void;
1258
+ /**
1259
+ * @deprecated
1260
+ */
1261
+ registeCommand(command: string, handler: (e: KeyboardEvent) => void | Promise<void>): void;
1262
+ unregisterCommand(command: string): void;
1263
+ /**
1264
+ * @deprecated
1265
+ */
1266
+ unregisteCommand(command: string): void;
1267
+ registerEl(name: string, el?: HTMLElement): void;
1268
+ /**
1269
+ * @deprecated
1270
+ */
1271
+ registeEl(name: string, el?: HTMLElement): void;
1272
+ unregisterEl(name: string): void;
1273
+ /**
1274
+ * @deprecated
1275
+ */
1276
+ unregisteEl(name: string): void;
1277
+ register(maps: KeyBindingItem[]): void;
1278
+ /**
1279
+ * @deprecated
1280
+ */
1281
+ registe(map: KeyBindingItem[]): void;
1282
+ reset(): void;
1283
+ destroy(): void;
1284
+ private bind;
1285
+ private getKeyconKeys;
1286
+ }
1287
+ type KeybindingService = Keybinding;
1288
+ //#endregion
1289
+ //#region temp/packages/editor/src/services/props.d.ts
1290
+ declare const canUsePluginMethods$4: {
1291
+ async: readonly ["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "fillConfig", "getDefaultPropsValue"];
1292
+ sync: readonly ["createId", "setNewItemId"];
1293
+ };
1294
+ type AsyncMethodName$2 = Writable<(typeof canUsePluginMethods$4)['async']>;
1295
+ type SyncMethodName$2 = Writable<(typeof canUsePluginMethods$4)['sync']>;
1296
+ declare class Props extends BaseService {
1297
+ private state;
1298
+ constructor();
1299
+ setDisabledDataSource(disabled: boolean): void;
1300
+ setDisabledCodeBlock(disabled: boolean): void;
1301
+ getDisabledDataSource(): boolean;
1302
+ getDisabledCodeBlock(): boolean;
1303
+ setPropsConfigs(configs: Record<string, FormConfig | PropsFormConfigFunction>): void;
1304
+ getPropsConfigs(): Record<string, FormConfig>;
1305
+ fillConfig(config: FormConfig, labelWidth?: string): Promise<FormConfig>;
1306
+ setPropsConfig(type: string, config: FormConfig | PropsFormConfigFunction): Promise<void>;
1307
+ /**
1308
+ * 获取指点类型的组件属性表单配置
1309
+ * @param type 组件类型
1310
+ * @returns 组件属性表单配置
1311
+ */
1312
+ getPropsConfig(type: string, data?: {
1313
+ node?: MNode$1 | null;
1314
+ }): Promise<FormConfig>;
1315
+ hasPropsConfig(type: string): boolean;
1316
+ setPropsValues(values: Record<string, Partial<MNode$1> | PropsFormValueFunction>): void;
1317
+ getPropsValues(): Record<string, Partial<MNode$1>>;
1318
+ /**
1319
+ * 为指点类型组件设置组件初始值
1320
+ * @param type 组件类型
1321
+ * @param value 组件初始值
1322
+ */
1323
+ setPropsValue(type: string, value: Partial<MNode$1> | PropsFormValueFunction): Promise<void>;
1324
+ /**
1325
+ * 获取指定类型的组件初始值
1326
+ * @param type 组件类型
1327
+ * @returns 组件初始值
1328
+ */
1329
+ getPropsValue(componentType: string, { inputEvent, ...defaultValue }?: Record<string, any>): Promise<any>;
1330
+ hasPropsValue(type: string): boolean;
1331
+ createId(type: string | number): string;
1332
+ /**
1333
+ * 将组件与组件的子元素配置中的id都设置成一个新的ID
1334
+ * 如果没有相同ID并且force为false则保持不变
1335
+ * @param {Object} config 组件配置
1336
+ * @param {Boolean} force 是否强制设置新的ID
1337
+ */
1338
+ setNewItemId(config: MNode$1, force?: boolean): MNode$1;
1339
+ /**
1340
+ * 获取默认属性配置
1341
+ * @param type 组件类型
1342
+ * @returns Object
1343
+ */
1344
+ getDefaultPropsValue(type: string): {
1345
+ type: string;
1346
+ layout: string;
1347
+ style: {};
1348
+ name: string;
1349
+ items: never[];
1350
+ } | {
1351
+ type: string;
1352
+ style: {};
1353
+ name: string;
1354
+ layout?: undefined;
1355
+ items?: undefined;
1356
+ };
1357
+ resetState(): void;
1358
+ /**
1359
+ * 替换关联ID
1360
+ * @param originConfigs 原组件配置
1361
+ * @param targetConfigs 待替换的组件配置
1362
+ */
1363
+ replaceRelateId(originConfigs: MNode$1[], targetConfigs: MNode$1[], collectorOptions: TargetOptions): void;
1364
+ /**
1365
+ * 清除setNewItemId前后映射关系
1366
+ */
1367
+ clearRelateId(): void;
1368
+ destroy(): void;
1369
+ usePlugin(options: AsyncHookPlugin<AsyncMethodName$2, Props> & SyncHookPlugin<SyncMethodName$2, Props>): void;
1370
+ /**
1371
+ * 获取setNewItemId前后映射关系
1372
+ * @param oldId 原组件ID
1373
+ * @returns 新旧ID映射
1374
+ */
1375
+ private getRelateIdMap;
1376
+ /**
1377
+ * 记录setNewItemId前后映射关系
1378
+ * @param oldId 原组件ID
1379
+ * @param newId 分配的新ID
1380
+ */
1381
+ private setRelateId;
1382
+ }
1383
+ type PropsService = Props;
1384
+ //#endregion
1385
+ //#region temp/packages/editor/src/services/stageOverlay.d.ts
1386
+ declare const canUsePluginMethods$3: {
1387
+ async: never[];
1388
+ sync: readonly ["openOverlay", "closeOverlay", "updateOverlay", "createStage"];
1389
+ };
1390
+ type SyncMethodName$1 = Writable<(typeof canUsePluginMethods$3)['sync']>;
1391
+ declare class StageOverlay extends BaseService {
1392
+ private state;
1393
+ constructor();
1394
+ get<K extends keyof StageOverlayState>(name: K): StageOverlayState[K];
1395
+ set<K extends keyof StageOverlayState, T extends StageOverlayState[K]>(name: K, value: T): void;
1396
+ openOverlay(el: HTMLElement | null): void;
1397
+ closeOverlay(): void;
1398
+ updateOverlay(): void;
1399
+ createStage(stageOptions?: StageOptions): StageCore;
1400
+ usePlugin(options: SyncHookPlugin<SyncMethodName$1, StageOverlay>): void;
1401
+ private createContentEl;
1402
+ private copyDocumentElement;
1403
+ private render;
1404
+ private updateHandler;
1405
+ private addHandler;
1406
+ private removeHandler;
1407
+ private updateSelectStatus;
1408
+ }
1409
+ type StageOverlayService = StageOverlay;
1410
+ //#endregion
1411
+ //#region temp/packages/editor/src/services/storage.d.ts
1412
+ interface Options {
1413
+ namespace?: string;
1414
+ protocol?: Protocol;
1415
+ }
1416
+ declare enum Protocol {
1417
+ OBJECT = "object",
1418
+ JSON = "json",
1419
+ STRING = "string",
1420
+ NUMBER = "number",
1421
+ BOOLEAN = "boolean"
1422
+ }
1423
+ declare const canUsePluginMethods$2: {
1424
+ async: never[];
1425
+ sync: readonly ["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"];
1426
+ };
1427
+ type SyncMethodName = Writable<(typeof canUsePluginMethods$2)['sync']>;
1428
+ /**
1429
+ * 数据存储服务
1430
+ */
1431
+ declare class WebStorage extends BaseService {
1432
+ private storage;
1433
+ private namespace;
1434
+ constructor();
1435
+ /**
1436
+ * 获取数据存储对象,可以通过
1437
+ * const storageService = new StorageService();
1438
+ * storageService.usePlugin({
1439
+ * // 替换存储对象为 sessionStorage
1440
+ * async afterGetStorage(): Promise<Storage> {
1441
+ * return window.sessionStorage;
1442
+ * },
1443
+ * });
1444
+ */
1445
+ getStorage(): Storage;
1446
+ getNamespace(): string;
1447
+ /**
1448
+ * 清理,支持storageService.usePlugin
1449
+ */
1450
+ clear(): void;
1451
+ /**
1452
+ * 获取存储项,支持storageService.usePlugin
1453
+ */
1454
+ getItem(key: string, options?: Options): any;
1455
+ /**
1456
+ * 获取指定索引位置的key
1457
+ */
1458
+ key(index: number): string | null;
1459
+ /**
1460
+ * 移除存储项,支持storageService.usePlugin
1461
+ */
1462
+ removeItem(key: string, options?: Options): void;
1463
+ /**
1464
+ * 设置存储项,支持storageService.usePlugin
1465
+ */
1466
+ setItem(key: string, value: any, options?: Options): void;
1467
+ destroy(): void;
1468
+ usePlugin(options: SyncHookPlugin<SyncMethodName, WebStorage>): void;
1469
+ private getValueAndProtocol;
1470
+ }
1471
+ type StorageService = WebStorage;
1472
+ //#endregion
1473
+ //#region temp/packages/editor/src/services/ui.d.ts
1474
+ declare const canUsePluginMethods$1: {
1475
+ async: readonly ["zoom", "calcZoom"];
1476
+ sync: readonly [];
1477
+ };
1478
+ type AsyncMethodName$1 = Writable<(typeof canUsePluginMethods$1)['async']>;
1479
+ declare class Ui extends BaseService {
1480
+ constructor();
1481
+ set<K extends keyof UiState, T extends UiState[K]>(name: K, value: T): void;
1482
+ get<K extends keyof UiState>(name: K): import("@vue/reactivity").ShallowReactive<UiState>[K];
1483
+ zoom(zoom: number): Promise<void>;
1484
+ calcZoom(): Promise<number>;
1485
+ resetState(): void;
1486
+ destroy(): void;
1487
+ usePlugin(options: AsyncHookPlugin<AsyncMethodName$1, Ui>): void;
1488
+ private setStageRect;
1489
+ }
1490
+ type UiService = Ui;
1491
+ //#endregion
3
1492
  //#region temp/packages/editor/src/type.d.ts
1493
+ interface Services {
1494
+ editorService: EditorService;
1495
+ historyService: HistoryService;
1496
+ storageService: StorageService;
1497
+ eventsService: EventsService;
1498
+ propsService: PropsService;
1499
+ componentListService: ComponentListService;
1500
+ uiService: UiService;
1501
+ codeBlockService: CodeBlockService;
1502
+ depService: DepService;
1503
+ dataSourceService: DataSourceService;
1504
+ keybindingService: KeybindingService;
1505
+ stageOverlayService: StageOverlayService;
1506
+ }
1507
+ declare module '@tmagic/form-schema' {
1508
+ interface FormContext {
1509
+ /** 编辑器服务集合(由 Editor / FormPanel provide) */
1510
+ services?: Services;
1511
+ /** 当前画布 Stage 实例(由 Editor / FormPanel provide) */
1512
+ stage?: any;
1513
+ }
1514
+ }
1515
+ interface StageOptions {
1516
+ runtimeUrl?: string;
1517
+ autoScrollIntoView?: boolean;
1518
+ containerHighlightClassName?: string;
1519
+ containerHighlightDuration?: number;
1520
+ containerHighlightType?: ContainerHighlightType;
1521
+ /**
1522
+ * 是否仅在新增组件(从组件列表拖入新组件)时才启用识别容器,
1523
+ * 开启后在画布中拖动已有组件不会识别容器,默认 false
1524
+ */
1525
+ containerHighlightAddOnly?: boolean;
1526
+ disabledDragStart?: boolean;
1527
+ render?: (stage: StageCore) => HTMLDivElement | void | Promise<HTMLDivElement | void>;
1528
+ moveableOptions?: CustomizeMoveableOptions;
1529
+ canSelect?: (el: HTMLElement) => boolean | Promise<boolean>;
1530
+ isContainer?: (el: HTMLElement) => boolean | Promise<boolean>;
1531
+ /**
1532
+ * 画布上拖入组件(包括从组件列表拖入新组件、画布上拖动已有组件)时,
1533
+ * 对已通过 isContainer 命中的候选容器进行二次过滤;返回 false 时阻止该容器被高亮命中
1534
+ * - 在画布上拖动已有组件时:sourceIds 为被拖动组件的 id 列表
1535
+ * - 从组件列表拖入新组件时:sourceIds 为空数组(尚无 id,仅可依据 targetId 判断)
1536
+ * 该选项会被透传给 StageCore 的 canDropIn
1537
+ */
1538
+ canDropIn?: CanDropIn;
1539
+ updateDragEl?: UpdateDragEl;
1540
+ renderType?: RenderType;
1541
+ guidesOptions?: Partial<GuidesOptions>;
1542
+ disabledMultiSelect?: boolean;
1543
+ /**
1544
+ * 始终启用多选模式(无需按住 Ctrl/Meta),默认 false。
1545
+ * 当 `disabledMultiSelect` 为 true 时本配置失效。
1546
+ */
1547
+ alwaysMultiSelect?: boolean;
1548
+ disabledRule?: boolean;
1549
+ /**
1550
+ * 禁用「非点击画布选中组件时(如从图层树、面包屑等外部选中),对选中区域做高亮闪烁提示」,
1551
+ * 默认 false(即默认开启闪烁)
1552
+ */
1553
+ disabledFlashTip?: boolean;
1554
+ zoom?: number;
1555
+ /** 画布双击前的钩子函数,返回 false 则阻止默认的双击行为 */
1556
+ beforeDblclick?: (event: MouseEvent) => Promise<boolean | void> | boolean | void;
1557
+ }
1558
+ /**
1559
+ * 节点校验错误信息,按来源(属性表单 / 样式表单)分别保存错误文案。
1560
+ * 属性表单与样式表单是两个独立的 FormPanel,均指向同一节点,故以来源为键,
1561
+ * 避免某个面板校验通过时误清另一个面板记录的错误。
1562
+ * 节点视为存在错误当且仅当任一来源存在非空文本。
1563
+ */
1564
+ interface NodeInvalidInfo {
1565
+ /** 属性表单校验错误文案(可能为包含 <br> 的 HTML) */
1566
+ props?: string;
1567
+ /** 样式表单校验错误文案(可能为包含 <br> 的 HTML) */
1568
+ style?: string;
1569
+ }
1570
+ /** 节点校验错误来源 */
1571
+ type NodeInvalidSource = keyof NodeInvalidInfo;
1572
+ interface StoreState {
1573
+ root: MApp | null;
1574
+ page: MPage | MPageFragment | null;
1575
+ parent: MContainer | null;
1576
+ node: MNode$1 | null;
1577
+ highlightNode: MNode$1 | null;
1578
+ nodes: MNode$1[];
1579
+ stage: StageCore | null;
1580
+ stageLoading: boolean;
1581
+ modifiedNodeIds: Map<Id$1, Id$1>;
1582
+ /** 校验失败的节点错误信息,按节点 id 存储,供组件树标记与保存拦截读取 */
1583
+ invalidNodeIds: Map<Id$1, NodeInvalidInfo>;
1584
+ pageLength: number;
1585
+ pageFragmentLength: number;
1586
+ disabledMultiSelect: boolean;
1587
+ /** 是否始终启用多选模式(无需按住 Ctrl/Meta) */
1588
+ alwaysMultiSelect: boolean;
1589
+ }
1590
+ type StoreStateKey = keyof StoreState;
1591
+ interface StageOverlayState {
1592
+ wrapDiv: HTMLDivElement;
1593
+ sourceEl: HTMLElement | null;
1594
+ contentEl: HTMLElement | null;
1595
+ stage: StageCore | null;
1596
+ stageOptions: StageOptions | null;
1597
+ wrapWidth: number;
1598
+ wrapHeight: number;
1599
+ stageOverlayVisible: boolean;
1600
+ }
1601
+ declare enum ColumnLayout {
1602
+ LEFT = "left",
1603
+ CENTER = "center",
1604
+ RIGHT = "right"
1605
+ }
1606
+ interface GetColumnWidth {
1607
+ [ColumnLayout.LEFT]: number;
1608
+ [ColumnLayout.CENTER]: number;
1609
+ [ColumnLayout.RIGHT]: number;
1610
+ }
1611
+ interface StageRect {
1612
+ width: number | string;
1613
+ height: number | string;
1614
+ }
1615
+ interface UiState {
1616
+ /** 当前点击画布是否触发选中,true: 不触发,false: 触发,默认为false */
1617
+ uiSelectMode: boolean;
1618
+ /** 是否显示整个配置源码, true: 显示, false: 不显示,默认为false */
1619
+ showSrc: boolean;
1620
+ /** 是否将样式配置单独一列显示, true: 显示, false: 不显示,默认为true */
1621
+ showStylePanel: boolean;
1622
+ /** 画布显示放大倍数,默认为 1 */
1623
+ zoom: number;
1624
+ /** 画布容器的宽高 */
1625
+ stageContainerRect: {
1626
+ width: number;
1627
+ height: number;
1628
+ };
1629
+ /** 画布顶层div的宽高,可用于改变画布的大小 */
1630
+ stageRect: StageRect;
1631
+ /** 编辑器列布局每一列的宽度,分为左中右三列 */
1632
+ columnWidth: GetColumnWidth;
1633
+ /** 编辑器列布局左侧列最小宽度 */
1634
+ minLeftColumnWidth: number;
1635
+ /** 编辑器列布局中间列最小宽度 */
1636
+ minCenterColumnWidth: number;
1637
+ /** 编辑器列布局右侧列最小宽度 */
1638
+ minRightColumnWidth: number;
1639
+ /** 是否显示画布参考线,true: 显示,false: 不显示,默认为true */
1640
+ showGuides: boolean;
1641
+ /** 画布上是否存在参考线 */
1642
+ hasGuides: boolean;
1643
+ /** 是否显示标尺,true: 显示,false: 不显示,默认为true */
1644
+ showRule: boolean;
1645
+ /** 用于控制该属性配置表单内组件的尺寸 */
1646
+ propsPanelSize: 'large' | 'default' | 'small';
1647
+ /** 是否显示新增页面按钮 */
1648
+ showAddPageButton: boolean;
1649
+ /** 是否在页面工具栏显示呼起页面列表按钮 */
1650
+ showPageListButton: boolean;
1651
+ /** 是否隐藏侧边栏 */
1652
+ hideSlideBar: boolean;
1653
+ /** 侧边栏面板配置 */
1654
+ sideBarItems: SideComponent[];
1655
+ /** 当前激活的侧边栏面板 */
1656
+ sideBarActiveTabName: string;
1657
+ navMenuRect: {
1658
+ left: number;
1659
+ top: number;
1660
+ width: number;
1661
+ height: number;
1662
+ };
1663
+ frameworkRect: {
1664
+ left: number;
1665
+ top: number;
1666
+ width: number;
1667
+ height: number;
1668
+ };
1669
+ }
4
1670
  interface EditorNodeInfo {
5
1671
  node: MNode$1 | null;
6
1672
  parent: MContainer | null;
7
1673
  page: MPage | MPageFragment | null;
8
1674
  path: MNode$1[];
9
1675
  }
1676
+ interface AddMNode {
1677
+ type: string;
1678
+ name?: string;
1679
+ inputEvent?: DragEvent;
1680
+ [key: string]: any;
1681
+ }
1682
+ interface PastePosition {
1683
+ left?: number;
1684
+ top?: number;
1685
+ /**
1686
+ * 粘贴位置X方向偏移量
1687
+ */
1688
+ offsetX?: number;
1689
+ /**
1690
+ * 粘贴位置Y方向偏移量
1691
+ */
1692
+ offsetY?: number;
1693
+ }
1694
+ interface MenuComponent {
1695
+ type: 'component';
1696
+ /** Vue3组件 */
1697
+ component: any;
1698
+ /** 传入组件的props对象 */
1699
+ props?: Record<string, any>;
1700
+ /** 组件监听的事件对象,如:{ click: () => { console.log('click'); } } */
1701
+ listeners?: Record<string, Function>;
1702
+ slots?: Record<string, any>;
1703
+ /** 是否显示,默认为true */
1704
+ className?: string;
1705
+ display?: boolean | ((data: Services) => Promise<boolean> | boolean);
1706
+ [key: string]: any;
1707
+ }
1708
+ interface SideComponent extends MenuComponent {
1709
+ /** 显示文案 */
1710
+ text: string;
1711
+ /** tab样式 */
1712
+ tabStyle?: string | Record<string, any>;
1713
+ /** vue组件或url */
1714
+ icon?: any;
1715
+ /** slide 唯一标识 key */
1716
+ $key: string;
1717
+ /** 是否可以将面板拖出,默认为true */
1718
+ draggable?: boolean;
1719
+ /** 点击切换tab前调用,返回false阻止切换 */
1720
+ beforeClick?: (config: SideComponent) => boolean | Promise<boolean>;
1721
+ /** 组件扩展参数 */
1722
+ boxComponentConfig?: {
1723
+ /** Vue3组件 */
1724
+ component?: any;
1725
+ /** 传入组件的props对象 */
1726
+ props?: Record<string, any>;
1727
+ };
1728
+ }
1729
+ interface ComponentItem {
1730
+ /** 显示文案 */
1731
+ text: string;
1732
+ /** 详情,用于tooltip */
1733
+ desc?: string;
1734
+ /** 组件类型 */
1735
+ type: string;
1736
+ /** Vue组件或url */
1737
+ icon?: string | Component<{}, {}, any>;
1738
+ /** 新增组件时需要透传到组价节点上的数据 */
1739
+ data?: {
1740
+ [key: string]: any;
1741
+ };
1742
+ }
1743
+ interface ComponentGroup {
1744
+ /** 显示文案 */
1745
+ title: string;
1746
+ /** 组内列表 */
1747
+ items: ComponentItem[];
1748
+ }
1749
+ declare enum LayerOffset {
1750
+ TOP = "top",
1751
+ BOTTOM = "bottom"
1752
+ }
1753
+ /** 容器布局 */
1754
+ declare enum Layout {
1755
+ FLEX = "flex",
1756
+ FIXED = "fixed",
1757
+ RELATIVE = "relative",
1758
+ ABSOLUTE = "absolute"
1759
+ }
1760
+ /**
1761
+ * 历史记录操作类型:
1762
+ * - `add` / `remove` / `update`:普通可撤销/重做的节点变更;
1763
+ * - `initial`:页面「未修改的初始状态」基线(设置 root 时生成),作为页面栈 index 0 的固定底线 step。
1764
+ * 该 step 不可被撤销/回滚(cursor 不会低于它),仅用于历史面板底部的初始行展示。
1765
+ */
1766
+ type HistoryOpType = 'add' | 'remove' | 'update' | 'initial';
1767
+ /**
1768
+ * 历史记录的「操作途径」——标记本次变更由哪条交互入口触发,仅用于历史面板展示 / 业务埋点,
1769
+ * 不影响 undo/redo 行为。缺省(未传)时 UI 视为「未知」。
1770
+ *
1771
+ * - `stage`:画布(拖拽 / 缩放 / 排序等舞台直接操作)
1772
+ * - `tree`:树形面板(图层 / 数据源 / 代码块等树形结构里的拖拽 / 菜单操作)
1773
+ * - `component-panel`:组件面板(左侧组件列表点击 / 拖拽新增组件)
1774
+ * - `props`:配置面板表单(属性表单字段编辑)
1775
+ * - `code`:源码编辑器(配置面板「源码」面板里直接编辑 JSON/代码后保存)
1776
+ * - `stage-contextmenu`:画布右键菜单(舞台上节点的右键上下文菜单)
1777
+ * - `tree-contextmenu`:树面板右键菜单(图层 / 数据源 / 代码块等树形列表上的右键上下文菜单)
1778
+ * - `toolbar`:工具栏菜单(顶部导航工具栏按钮)
1779
+ * - `shortcut`:键盘快捷键
1780
+ * - `rollback`:历史回滚(历史面板里对某条历史「回滚」,反向应用为一条新记录,类 git revert)
1781
+ * - `api`:代码 / 接口调用(程序化触发)
1782
+ * - `ai`:AI 生成 / 智能助手触发的变更
1783
+ * - `unknown`:未知来源
1784
+ *
1785
+ * 通过 `(string & {})` 允许业务侧扩展自定义途径字符串,同时保留内置值的自动补全。
1786
+ */
1787
+ type HistoryOpSource = 'initial' | 'stage' | 'tree' | 'component-panel' | 'props' | 'code' | 'root-code' | 'stage-contextmenu' | 'tree-contextmenu' | 'toolbar' | 'shortcut' | 'rollback' | 'api' | 'ai' | 'sync' | 'unknown' | (string & {});
1788
+ /** *AndGetHistoryId 系列方法返回值:原操作结果 + 本次写入历史记录的 uuid 列表(未入栈时为 `[]`)。 */
1789
+ type DslOpWithHistoryIdsResult<T> = {
1790
+ result: T;
1791
+ historyIds: string[];
1792
+ };
1793
+ /**
1794
+ * 单条变更的 diff 描述,统一表达「页面节点 / 代码块 / 数据源」的变化内容,
1795
+ * 被 {@link StepValue} / {@link CodeBlockStepValue} / {@link DataSourceStepValue} 的 `diff` 复用。
1796
+ *
1797
+ * 按 `opType` 区分携带的字段:
1798
+ * - `add`:仅 `newSchema`(页面节点还带 `parentId` / `index`);
1799
+ * - `remove`:仅 `oldSchema`(页面节点还带 `parentId` / `index`);
1800
+ * - `update`:`oldSchema` + `newSchema`,并可带 `changeRecords` 做局部更新。
1801
+ *
1802
+ * 泛型 `T` 为变化内容的快照类型:页面节点为 `MNode`,代码块为 `CodeBlockContent`,数据源为 `DataSourceSchema`。
1803
+ */
1804
+ interface StepDiffItem<T = unknown> {
1805
+ /** 变更后的内容快照。`opType` 为 `add` / `update` 时有,`remove` 时无。 */
1806
+ newSchema?: T;
1807
+ /** 变更前的内容快照。`opType` 为 `remove` / `update` 时有,`add` 时无。 */
1808
+ oldSchema?: T;
1809
+ /** 父节点 id。仅页面节点有(数据源 / 代码块没有父节点)。 */
1810
+ parentId?: Id$1;
1811
+ /** 在父节点 items 数组中的索引。仅页面节点有(数据源 / 代码块无需排序)。 */
1812
+ index?: number;
1813
+ /**
1814
+ * form 端 propPath/value 变更列表,仅 `opType` 为 `update` 时有;
1815
+ * 撤销/重做时若有则按 propPath 局部更新,缺省才退化为整内容替换。
1816
+ */
1817
+ changeRecords?: ChangeRecord[];
1818
+ }
1819
+ /**
1820
+ * 历史记录条目公共字段,被 {@link StepValue} / {@link CodeBlockStepValue} / {@link DataSourceStepValue} 复用。
1821
+ *
1822
+ * 泛型 `T` 为 `diff` 中变化内容的快照类型(页面节点 `MNode` / 代码块 `CodeBlockContent` / 数据源 `DataSourceSchema`)。
1823
+ */
1824
+ interface BaseStepValue<T = unknown, U extends Record<string, any> = {}> {
1825
+ /**
1826
+ * 历史记录唯一标识(uuid)。入栈时自动写入(若调用方未指定),
1827
+ * 用于精确定位 / 引用某一条历史记录(如 revert、埋点、跨端同步等)。
1828
+ * 注意与 `data.id`(关联的页面 / 代码块 / 数据源 id)区分。
1829
+ */
1830
+ uuid: string;
1831
+ /**
1832
+ * 关联目标信息:`id` 为关联的页面 / 代码块 / 数据源等资源 id(也是历史栈的分组 key),
1833
+ * `name` 为展示名。所有历史类型统一携带。
1834
+ */
1835
+ data: {
1836
+ name: string;
1837
+ id: Id$1;
1838
+ };
1839
+ /** 操作类型:新增 / 删除 / 更新(三类历史记录统一携带)。 */
1840
+ opType: HistoryOpType;
1841
+ /**
1842
+ * 本次变更的内容(统一 diff 表达),每项见 {@link StepDiffItem}。
1843
+ * 页面节点(add/remove 多节点、update 多节点)会有多项,代码块 / 数据源通常只有一项。
1844
+ */
1845
+ diff: StepDiffItem<T>[];
1846
+ /**
1847
+ * 调用方可选传入的人类可读描述(如「调整按钮颜色」),用于历史面板展示。
1848
+ * 不影响 undo/redo 行为;缺省时面板会根据节点 / propPath 自动生成描述。
1849
+ */
1850
+ historyDescription?: string;
1851
+ /**
1852
+ * 操作途径:标记本次变更由哪条交互入口触发,取值见 {@link HistoryOpSource}
1853
+ * (画布 / 树面板 / 组件面板 / 配置面板 / 源码编辑器 / 右键菜单 / 工具栏 / 快捷键 / 回滚 / 接口 等)。
1854
+ * 仅用于历史面板展示与业务埋点,不影响 undo/redo 行为;缺省时面板视为「未知」。
1855
+ */
1856
+ source?: HistoryOpSource;
1857
+ /**
1858
+ * 入栈时间戳(毫秒)。入栈时自动写入(若调用方未指定),仅用于历史面板展示。
1859
+ */
1860
+ timestamp?: number;
1861
+ /**
1862
+ * 是否为「已保存」记录:DSL 落库(如保存到后端 / 本地)时由 historyService.markSaved 标记。
1863
+ * 同一栈内任意时刻最多只有一条记录为 true;从 IndexedDB 恢复时游标会被定位到最近一条已保存记录之后。
1864
+ */
1865
+ saved?: boolean;
1866
+ /**
1867
+ * 是否为「整体设置 root」(set root)产生的记录(由 {@link Editor.pushRootDiffHistory} 写入)。
1868
+ * 用于「连续 set root 合并」:当某页栈最新一条已是 root 记录时,下一条 set root 会替换它而非新增,
1869
+ * 避免源码反复保存 / 外部重设 DSL 时堆积多条 root 记录。
1870
+ */
1871
+ rootStep?: boolean;
1872
+ /** 操作人 */
1873
+ operator?: string;
1874
+ /** 扩展信息 */
1875
+ extra?: U;
1876
+ }
1877
+ /**
1878
+ * 历史记录的扩展上下文({@link BaseStepValue.extra})。
1879
+ * 内置字段供 `page` 类型在撤销 / 重做时恢复选区与受影响节点;扩展类型可自由附加其它键。
1880
+ */
1881
+ interface StepExtra {
1882
+ /** 操作前选中的节点 ID,用于撤销后恢复选择状态(page 类型) */
1883
+ selectedBefore?: Id$1[];
1884
+ /** 操作后选中的节点 ID,用于重做后恢复选择状态(page 类型) */
1885
+ selectedAfter?: Id$1[];
1886
+ /** 本次操作涉及的节点 id 集合(page 类型) */
1887
+ modifiedNodeIds?: Map<Id$1, Id$1>;
1888
+ /** 操作前的节点校验错误快照,撤销后还原(使撤销一个「校验失败」的改动后错误消失) */
1889
+ invalidNodeIdsBefore?: Map<Id$1, NodeInvalidInfo>;
1890
+ /** 操作后的节点校验错误快照,重做后还原(使重做后错误恢复) */
1891
+ invalidNodeIdsAfter?: Map<Id$1, NodeInvalidInfo>;
1892
+ [key: string]: any;
1893
+ }
1894
+ /**
1895
+ * 页面节点历史记录条目(`diff` 内容为 {@link MNode})。结构已与代码块 / 数据源统一收敛到
1896
+ * {@link BaseStepValue}:关联 id 见 `data.id`,选区等上下文见 `extra`。
1897
+ */
1898
+ type StepValue = BaseStepValue<MNode$1, StepExtra>;
1899
+ /**
1900
+ * 代码块历史记录条目(`diff` 内容为 {@link CodeBlockContent}),按 `data.id`(codeBlock.id)
1901
+ * 分组保存到 historyState.steps.codeBlock。结构与 {@link StepValue} / {@link DataSourceStepValue}
1902
+ * 一致,仅 `diff` 快照类型不同。
1903
+ */
1904
+ type CodeBlockStepValue = BaseStepValue<CodeBlockContent>;
1905
+ /**
1906
+ * 数据源历史记录条目(`diff` 内容为 {@link DataSourceSchema}),按 `data.id`(dataSource.id)
1907
+ * 分组保存到 historyState.steps.dataSource。结构与 {@link StepValue} / {@link CodeBlockStepValue}
1908
+ * 一致,仅 `diff` 快照类型不同。
1909
+ */
1910
+ type DataSourceStepValue = BaseStepValue<DataSourceSchema>;
1911
+ /**
1912
+ * 历史记录类型标识:内置 `page` / `codeBlock` / `dataSource`,并允许业务扩展自定义类型。
1913
+ * `(string & {})` 保留对内置字面量的智能提示,同时不限制扩展取值。
1914
+ */
1915
+ type HistoryStepType = 'page' | 'codeBlock' | 'dataSource' | (string & {});
1916
+ /**
1917
+ * 历史记录的可持久化快照。由 historyService.saveToIndexedDB 写入 IndexedDB,
1918
+ * 再由 historyService.restoreFromIndexedDB 读出并重建各 UndoRedo 栈。
1919
+ */
1920
+ interface PersistedHistoryState {
1921
+ /** 快照结构版本号,便于后续兼容升级。 */
1922
+ version: number;
1923
+ /**
1924
+ * 全部历史栈的序列化快照,按「类型 -> id」两级分组,与 {@link HistorySteps} 对应。
1925
+ * 内置 `page` / `codeBlock` / `dataSource`,并包含业务注册的扩展类型。
1926
+ */
1927
+ steps: {
1928
+ page: Record<Id$1, SerializedUndoRedo<StepValue>>;
1929
+ codeBlock: Record<Id$1, SerializedUndoRedo<CodeBlockStepValue>>;
1930
+ dataSource: Record<Id$1, SerializedUndoRedo<DataSourceStepValue>>;
1931
+ [stepType: string]: Record<Id$1, SerializedUndoRedo<any>>;
1932
+ };
1933
+ /** 保存时间戳(毫秒)。 */
1934
+ savedAt: number;
1935
+ }
1936
+ /** historyService 持久化相关 API 的可选配置。 */
1937
+ interface HistoryPersistOptions {
1938
+ /** IndexedDB 数据库名,默认 `tmagic-editor`(最终库名会拼上当前 DSL app id)。 */
1939
+ dbName?: string;
1940
+ /** objectStore 名,默认 `history`。 */
1941
+ storeName?: string;
1942
+ /** 记录 key,用于区分不同活动页 / 项目,默认 `default`。 */
1943
+ key?: IDBValidKey;
1944
+ /**
1945
+ * 显式指定用于库名隔离的 DSL app id。
1946
+ * 缺省时回退到当前 editorService 的 `root.id`;在「先恢复历史再 set root」场景下 root 尚未设置,
1947
+ * 需由调用方(如从待加载 DSL 取 id)显式传入,否则会读 / 写到未按 app 隔离的默认库。
1948
+ */
1949
+ appId?: Id$1;
1950
+ }
1951
+ /**
1952
+ * 历史面板用:当前页面的一条历史步骤(包含位置和是否已应用)。
1953
+ */
1954
+ interface HistoryStepEntry<T> {
1955
+ /** 步骤内容 */
1956
+ step: T;
1957
+ /** 在所属栈中的索引(0 为最早) */
1958
+ index: number;
1959
+ /** 是否处于"已应用"段(即位于栈游标之前)。撤销后变为 false。 */
1960
+ applied: boolean;
1961
+ /** 是否为当前所在的步骤(栈中最近一次已应用的那一步,即 index === cursor - 1)。 */
1962
+ isCurrent?: boolean;
1963
+ }
1964
+ /**
1965
+ * 历史面板分组(页面 / 数据源 / 代码块 / 扩展类型统一结构)。
1966
+ *
1967
+ * 把指定历史栈的步骤列表按"目标"做相邻合并:
1968
+ * - 连续修改同一目标(单实体 update,targetId 一致)的多步合并成一组,组内可展开查看每步;
1969
+ * - add / remove / 多实体 update 始终独立成组(无法明确归属单一目标);
1970
+ * - targetId 为 undefined 表示"无明确目标",不参与合并。
1971
+ *
1972
+ * 各类型仅 `kind` 与 step 快照类型不同,统一由泛型描述:
1973
+ * - 页面:`HistoryGroup<StepValue>`,`kind: 'page'`,`id` 为 pageId,`targetId` 为被改节点 id;
1974
+ * - 数据源:`HistoryGroup<DataSourceStepValue>`,`kind: 'data-source'`,`id` 为 dataSource.id;
1975
+ * - 代码块:`HistoryGroup<CodeBlockStepValue>`,`kind: 'code-block'`,`id` 为 codeBlock.id。
1976
+ */
1977
+ interface HistoryGroup<T extends BaseStepValue = BaseStepValue> {
1978
+ /** 历史类型标识:page / code-block / data-source(扩展类型同理)。 */
1979
+ kind: string;
1980
+ /** 所属栈 id(page 为 pageId,代码块 / 数据源为对应资源 id)。 */
1981
+ id: Id$1;
1982
+ /** 该分组的操作类型。 */
1983
+ opType: HistoryOpType;
1984
+ /**
1985
+ * 合并的目标 id:仅"单实体 update"有值,并按此与相邻同 id 的 update 合并。
1986
+ * undefined 表示该分组不可被合并(add / remove / 多实体 update)。
1987
+ */
1988
+ targetId?: Id$1;
1989
+ /** 目标可读名(取最后一步快照的 name/type/id)。 */
1990
+ targetName?: string;
1991
+ /** 组内所有步骤,按时间正序。 */
1992
+ steps: {
1993
+ step: T;
1994
+ index: number;
1995
+ applied: boolean;
1996
+ isCurrent?: boolean;
1997
+ }[];
1998
+ /** 组内最后一步是否已应用。 */
1999
+ applied: boolean;
2000
+ /** 是否为当前所在的分组(包含栈中最近一次已应用步骤的那一组)。 */
2001
+ isCurrent?: boolean;
2002
+ }
2003
+ declare enum KeyBindingCommand {
2004
+ /** 复制 */
2005
+ COPY_NODE = "tmagic-system-copy-node",
2006
+ /** 粘贴 */
2007
+ PASTE_NODE = "tmagic-system-paste-node",
2008
+ /** 删除 */
2009
+ DELETE_NODE = "tmagic-system-delete-node",
2010
+ /** 剪切 */
2011
+ CUT_NODE = "tmagic-system-cut-node",
2012
+ /** 撤销 */
2013
+ UNDO = "tmagic-system-undo",
2014
+ /** 重做 */
2015
+ REDO = "tmagic-system-redo",
2016
+ /** 放大 */
2017
+ ZOOM_IN = "tmagic-system-zoom-in",
2018
+ /** 缩小 */
2019
+ ZOOM_OUT = "tmagic-system-zoom-out",
2020
+ /** 缩放到实际大小 */
2021
+ ZOOM_RESET = "tmagic-system-zoom-reset",
2022
+ /** 缩放以适应 */
2023
+ ZOOM_FIT = "tmagic-system-zoom-fit",
2024
+ /** 向上移动1px */
2025
+ MOVE_UP_1 = "tmagic-system-move-up-1",
2026
+ /** 向下移动1px */
2027
+ MOVE_DOWN_1 = "tmagic-system-move-down-1",
2028
+ /** 向左移动1px */
2029
+ MOVE_LEFT_1 = "tmagic-system-move-left-1",
2030
+ /** 向右移动1px */
2031
+ MOVE_RIGHT_1 = "tmagic-system-move-right-1",
2032
+ /** 向上移动10px */
2033
+ MOVE_UP_10 = "tmagic-system-move-up-10",
2034
+ /** 向下移动10px */
2035
+ MOVE_DOWN_10 = "tmagic-system-move-down-10",
2036
+ /** 向左移动10px */
2037
+ MOVE_LEFT_10 = "tmagic-system-move-left-10",
2038
+ /** 向右移动10px */
2039
+ MOVE_RIGHT_10 = "tmagic-system-move-right-10",
2040
+ /** 切换组件 */
2041
+ SWITCH_NODE = "tmagic-system-switch-node"
2042
+ }
2043
+ interface KeyBindingItem {
2044
+ command: KeyBindingCommand | string;
2045
+ keybinding?: string | string[];
2046
+ when: [string, 'keyup' | 'keydown'][];
2047
+ }
2048
+ /** 可新增的数据源类型选项 */
2049
+ interface DatasourceTypeOption {
2050
+ /** 数据源类型 */
2051
+ type: string;
2052
+ /** 数据源名称 */
2053
+ text: string;
2054
+ }
2055
+ type AsyncBeforeHook<Value extends Array<string>, C extends Record<Value[number], (...args: any) => any>> = { [K in Value[number]]?: (...args: Parameters<C[K]>) => Promise<Parameters<C[K]>> | Parameters<C[K]>; };
2056
+ type AsyncAfterHook<Value extends Array<string>, C extends Record<Value[number], (...args: any) => any>> = { [K in Value[number]]?: (result: Awaited<ReturnType<C[K]>>, ...args: Parameters<C[K]>) => ReturnType<C[K]> | Awaited<ReturnType<C[K]>>; };
2057
+ type SyncBeforeHook<Value extends Array<string>, C extends Record<Value[number], (...args: any) => any>> = { [K in Value[number]]?: (...args: Parameters<C[K]>) => Parameters<C[K]>; };
2058
+ type SyncAfterHook<Value extends Array<string>, C extends Record<Value[number], (...args: any) => any>> = { [K in Value[number]]?: (result: ReturnType<C[K]>, ...args: Parameters<C[K]>) => ReturnType<C[K]>; };
2059
+ type AddPrefixToObject<T, P extends string> = { [K in keyof T as K extends string ? `${P}${K}` : never]: T[K]; };
2060
+ type AsyncHookPlugin<T extends Array<string>, C extends Record<T[number], (...args: any) => any>> = AddPrefixToObject<PascalCasedProperties<AsyncBeforeHook<T, C>>, 'before'> & AddPrefixToObject<PascalCasedProperties<AsyncAfterHook<T, C>>, 'after'>;
2061
+ type SyncHookPlugin<T extends Array<string>, C extends Record<T[number], (...args: any) => any>> = AddPrefixToObject<PascalCasedProperties<SyncBeforeHook<T, C>>, 'before'> & AddPrefixToObject<PascalCasedProperties<SyncAfterHook<T, C>>, 'after'>;
2062
+ type PropsFormConfigFunction = (data: {
2063
+ editorService: EditorService;
2064
+ }) => FormConfig;
2065
+ type PropsFormValueFunction = (data: {
2066
+ editorService: EditorService;
2067
+ }) => Partial<MNode$1>;
2068
+ interface EditorEvents {
2069
+ 'root-change': [value: StoreState['root'], preValue?: StoreState['root'], options?: {
2070
+ historySource?: HistoryOpSource;
2071
+ }];
2072
+ select: [node: MNode$1 | null];
2073
+ add: [nodes: MNode$1[]];
2074
+ remove: [nodes: MNode$1[]];
2075
+ update: [nodes: {
2076
+ newNode: MNode$1;
2077
+ oldNode: MNode$1;
2078
+ changeRecords?: ChangeRecord[];
2079
+ }[]];
2080
+ 'move-layer': [offset: number | LayerOffset];
2081
+ 'drag-to': [data: {
2082
+ targetIndex: number;
2083
+ configs: MNode$1 | MNode$1[];
2084
+ targetParent: MContainer;
2085
+ }];
2086
+ 'history-change': [data: MPage | MPageFragment];
2087
+ /**
2088
+ * DSL 发生变更后统一触发,免去分别监听 add / remove / update / move-layer / drag-to。
2089
+ * 回调参数为 {@link EditorChangeEvent},按 `type` 区分操作类型并携带各自的操作内容(payload)
2090
+ * 以及变更所在的当前 page(可能为 null)。撤销 / 重做内部同样会经由
2091
+ * add / remove / update 触发本事件;如需区分「用户操作」与「撤销重做」请配合 `history-change`。
2092
+ */
2093
+ change: [event: EditorChangeEvent];
2094
+ /** 节点校验错误状态发生变化时触发,携带当前完整的错误 Map(供非响应式消费方订阅) */
2095
+ 'invalid-node-change': [invalidNodeIds: Map<Id$1, NodeInvalidInfo>];
2096
+ }
2097
+ /** `change` 事件中单个变更项:变更的 node 及其所属的 page(可能为 null)。 */
2098
+ interface EditorChangeItem {
2099
+ node: MNode$1;
2100
+ page: StoreState['page'];
2101
+ }
2102
+ /** `update` 类型变更项:node 为前后快照及 form 端变更记录,page 为其所属页面。 */
2103
+ interface EditorUpdateChangeItem {
2104
+ node: {
2105
+ newNode: MNode$1;
2106
+ oldNode: MNode$1;
2107
+ changeRecords?: ChangeRecord[];
2108
+ };
2109
+ page: StoreState['page'];
2110
+ }
2111
+ /** {@link EditorEvents.change} 各操作类型共有的历史相关字段。 */
2112
+ interface EditorChangeEventHistoryMeta {
2113
+ /**
2114
+ * 本次变更的「历史来源」(调用 DSL 操作时传入的 {@link HistoryOpOptions.historySource},
2115
+ * 撤销 / 重做时则为被应用 step 上记录的 `source`),未携带时为 undefined。
2116
+ */
2117
+ historySource?: HistoryOpSource;
2118
+ /**
2119
+ * 本次操作是否未写入历史记录(即调用时传入的 {@link HistoryOpOptions.doNotPushHistory},缺省为 false);
2120
+ * 撤销 / 重做路径补发的事件恒为 true(撤销/重做本身不再入栈)。
2121
+ */
2122
+ doNotPushHistory?: boolean;
2123
+ }
2124
+ /**
2125
+ * {@link EditorEvents.change} 的回调参数:以 `type` 区分操作类型,并携带对应的操作内容。
2126
+ * `data` 为本次变更的节点列表,每项包含 node 及其所属的 page(可能为 null);
2127
+ * `move-layer` 额外带层级偏移 `offset`,`drag-to` 额外带目标位置 `targetIndex` / `targetParent`;
2128
+ * 历史相关字段(historySource / doNotPushHistory)见 {@link EditorChangeEventHistoryMeta}。
2129
+ */
2130
+ type EditorChangeEvent = ({
2131
+ type: 'add';
2132
+ data: EditorChangeItem[];
2133
+ } & EditorChangeEventHistoryMeta) | ({
2134
+ type: 'remove';
2135
+ data: EditorChangeItem[];
2136
+ } & EditorChangeEventHistoryMeta) | ({
2137
+ type: 'update';
2138
+ data: EditorUpdateChangeItem[];
2139
+ } & EditorChangeEventHistoryMeta) | ({
2140
+ type: 'move-layer';
2141
+ data: EditorChangeItem[];
2142
+ offset: number | LayerOffset;
2143
+ } & EditorChangeEventHistoryMeta) | ({
2144
+ type: 'drag-to';
2145
+ data: EditorChangeItem[];
2146
+ targetIndex: number;
2147
+ targetParent: MContainer;
2148
+ } & EditorChangeEventHistoryMeta);
2149
+ interface HistoryEvents {
2150
+ change: [state: BaseStepValue | StepValue | CodeBlockStepValue | DataSourceStepValue, stepType: HistoryStepType, id: Id$1];
2151
+ 'code-block-history-change': [id: Id$1, state: CodeBlockStepValue];
2152
+ 'data-source-history-change': [id: Id$1, state: DataSourceStepValue];
2153
+ 'restore-from-indexed-db': [snapshot: PersistedHistoryState | null];
2154
+ 'save-to-indexed-db': [snapshot: PersistedHistoryState];
2155
+ 'mark-saved': [{
2156
+ kind: HistoryStepType;
2157
+ id?: Id$1;
2158
+ }];
2159
+ clear: [{
2160
+ id: Id$1;
2161
+ stepType: HistoryStepType;
2162
+ }];
2163
+ 'marker-change': [{
2164
+ id: Id$1;
2165
+ marker: StepValue;
2166
+ stepType: HistoryStepType;
2167
+ }];
2168
+ /**
2169
+ * 页面 / 页面片结构变更(新增 / 删除)时派发,见 {@link HistoryService.notifyPageStructureChange}。
2170
+ * 一次操作(add / remove / setRoot 整体替换)涉及多个页面时合并为**一个**事件;
2171
+ * `add` / `remove` 分别为本次新增与删除的页面列表(其一可为空数组)。
2172
+ */
2173
+ 'page-structure-change': [change: {
2174
+ add: (MPage | MPageFragment)[];
2175
+ remove: (MPage | MPageFragment)[];
2176
+ }];
2177
+ }
2178
+ declare const canUsePluginMethods: {
2179
+ async: readonly ["getLayout", "highlight", "select", "multiSelect", "doAdd", "add", "doRemove", "remove", "doUpdate", "update", "sort", "copy", "paste", "doPaste", "doAlignCenter", "alignCenter", "moveLayer", "moveToContainer", "dragTo", "undo", "redo", "move"];
2180
+ sync: never[];
2181
+ };
2182
+ type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
2183
+ /**
2184
+ * 历史记录写入相关的通用配置(codeBlock / dataSource / editor 共用)
2185
+ * - doNotPushHistory: 操作完成后是否不要将本次操作压入历史栈(撤销/重做记录),默认 false
2186
+ * - historyDescription: 入栈时附带的人类可读描述,用于历史面板展示;不影响 undo/redo 行为,缺省时面板会自动生成描述
2187
+ * - historySource: 操作途径,取值见 {@link HistoryOpSource}(画布 / 树面板 / 组件面板 / 配置面板 / 源码编辑器 / 右键菜单 / 工具栏 / 快捷键 / 回滚 / 接口 等),用于历史面板展示与埋点;不影响 undo/redo 行为
2188
+ */
2189
+ interface HistoryOpOptions {
2190
+ doNotPushHistory?: boolean;
2191
+ historyDescription?: string;
2192
+ historySource?: HistoryOpSource;
2193
+ }
2194
+ /**
2195
+ * 在 HistoryOpOptions 基础上携带 form 端 propPath/value 变更记录,
2196
+ * 用于历史记录的精细化撤销/重做(按 propPath 局部 patch)。
2197
+ */
2198
+ interface HistoryOpOptionsWithChangeRecords extends HistoryOpOptions {
2199
+ changeRecords?: ChangeRecord[];
2200
+ }
2201
+ /**
2202
+ * DSL 修改类操作的通用配置
2203
+ * - doNotSelect: 操作后是否不要自动触发选中(不调用 this.select / this.multiSelect / stage.select / stage.multiSelect)
2204
+ * - doNotSwitchPage: 操作若会引发当前页面切换(如新增 / 删除 / 跨页移动),是否跳过这次切换
2205
+ */
2206
+ interface DslOpOptions extends HistoryOpOptions {
2207
+ doNotSelect?: boolean;
2208
+ doNotSwitchPage?: boolean;
2209
+ }
2210
+ /**
2211
+ * {@link EditorService.update} / {@link EditorService.doUpdate} 的额外数据
2212
+ * - changeRecords: 单节点 form 端变更记录(多节点场景下被忽略,使用 changeRecordList)
2213
+ * - changeRecordList: 多节点 form 端变更记录列表,按 config 数组同序对应每个节点;优先级高于 changeRecords
2214
+ * - replace: 为 true 时跳过 mergeWith / toggleFixedPosition / setChildrenLayout,直接用传入配置整节点替换
2215
+ * - invalidInfo: 属性面板提交时携带的校验错误信息,在写入历史记录之前落库
2216
+ */
2217
+ interface UpdateOptions extends HistoryOpOptionsWithChangeRecords {
2218
+ changeRecordList?: ChangeRecord[][];
2219
+ /**
2220
+ * 为 true 时不做深合并等变换,直接用传入配置整节点替换现有节点。
2221
+ * 适用于源码编辑、历史整节点快照回放等「完整 DSL」场景;默认 false(局部属性更新走 merge)。
2222
+ */
2223
+ replace?: boolean;
2224
+ /**
2225
+ * 属性面板提交时携带的校验错误信息,在写入历史记录之前落库,
2226
+ * 使历史快照与本次变更对齐,从而 undo/redo 能正确还原错误标记。
2227
+ */
2228
+ invalidInfo?: {
2229
+ id: Id$1;
2230
+ source: NodeInvalidSource;
2231
+ error?: string;
2232
+ };
2233
+ }
10
2234
  //#endregion
11
2235
  //#region temp/packages/utils/src/dom.d.ts
12
2236
  declare const asyncLoadJs: (url: string, crossOrigin?: string, document?: Document) => any;