@flowgram.ai/free-auto-layout-plugin 0.1.0-alpha.15 → 0.1.0-alpha.16

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/dist/index.d.mts CHANGED
@@ -145,44 +145,26 @@ declare namespace dagreLib {
145
145
  * SPDX-License-Identifier: MIT
146
146
  */
147
147
 
148
- declare class LayoutStore {
149
- readonly config: LayoutConfig;
150
- private indexMap;
151
- private init;
152
- private store;
153
- private container;
148
+ interface ILayoutStore {
149
+ container: LayoutNode;
154
150
  options: LayoutOptions;
155
- constructor(config: LayoutConfig);
156
151
  get initialized(): boolean;
157
152
  getNode(id?: string): LayoutNode | undefined;
158
153
  getNodeByIndex(index: string): LayoutNode | undefined;
159
154
  getEdge(id: string): LayoutEdge | undefined;
160
- get nodes(): LayoutNode[];
161
- get edges(): LayoutEdge[];
155
+ nodes: LayoutNode[];
156
+ edges: LayoutEdge[];
162
157
  create(params: LayoutParams, options: LayoutOptions): void;
163
- /** 创建布局数据 */
164
- private createStore;
165
- /** 创建节点布局数据 */
166
- private createLayoutNodes;
167
- /** 创建线条布局数据 */
168
- private createEdgesStore;
169
- /** 创建虚拟线条数据 */
170
- private createVirtualEdges;
171
- /** 创建节点索引映射 */
172
- private createIndexMap;
173
- /** 节点排序 */
174
- private sortNodes;
175
- /** 记录运行选项 */
176
- private setOptions;
177
- /** 设置跟随节点配置 */
178
- private setFollowNode;
179
158
  }
180
-
181
- /**
182
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
183
- * SPDX-License-Identifier: MIT
184
- */
185
-
159
+ interface ILayout {
160
+ init(params: LayoutParams, options: LayoutOptions): void;
161
+ layout(): void;
162
+ position(): Promise<void>;
163
+ }
164
+ interface LayoutSize {
165
+ width: number;
166
+ height: number;
167
+ }
186
168
  interface LayoutNode {
187
169
  id: string;
188
170
  /** 节点索引 */
@@ -203,13 +185,19 @@ interface LayoutNode {
203
185
  x: number;
204
186
  y: number;
205
187
  };
206
- /** 宽高 */
207
- size: {
208
- width: number;
209
- height: number;
188
+ /** 边距 */
189
+ padding: {
190
+ top: number;
191
+ bottom: number;
192
+ left: number;
193
+ right: number;
210
194
  };
211
- /** 是否存在子节点 */
212
- hasChildren: boolean;
195
+ /** 宽高 */
196
+ size: LayoutSize;
197
+ /** 子节点 */
198
+ layoutNodes: LayoutNode[];
199
+ /** 子线条 */
200
+ layoutEdges: LayoutEdge[];
213
201
  /** 被跟随节点 */
214
202
  followedBy?: string[];
215
203
  /** 跟随节点 */
@@ -231,13 +219,16 @@ interface LayoutEdge {
231
219
  name: string;
232
220
  }
233
221
  interface LayoutParams {
234
- nodes: WorkflowNodeEntity[];
235
- edges: WorkflowLineEntity[];
236
- container: WorkflowNodeEntity;
222
+ container: LayoutNode;
223
+ layoutNodes: LayoutNode[];
224
+ layoutEdges: LayoutEdge[];
237
225
  }
238
226
  interface LayoutOptions {
227
+ containerNode?: WorkflowNodeEntity;
239
228
  getFollowNode?: GetFollowNode;
240
229
  enableAnimation?: boolean;
230
+ animationDuration?: number;
231
+ disableFitView?: boolean;
241
232
  }
242
233
  interface LayoutConfig {
243
234
  /** Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right. */
@@ -260,7 +251,7 @@ interface LayoutConfig {
260
251
  ranker: 'network-simplex' | 'tight-tree' | 'longest-path';
261
252
  }
262
253
  type GetFollowNode = (node: LayoutNode, context: {
263
- store: LayoutStore;
254
+ store: ILayoutStore;
264
255
  /** 业务自定义参数 */
265
256
  [key: string]: any;
266
257
  }) => {
@@ -283,7 +274,7 @@ declare const createFreeAutoLayoutPlugin: _flowgram_ai_core.PluginCreator<AutoLa
283
274
  * SPDX-License-Identifier: MIT
284
275
  */
285
276
 
286
- declare class Layout {
277
+ declare class Layout implements ILayout {
287
278
  private readonly _store;
288
279
  private readonly _layout;
289
280
  private readonly _position;
@@ -293,6 +284,40 @@ declare class Layout {
293
284
  position(): Promise<void>;
294
285
  }
295
286
 
287
+ /**
288
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
289
+ * SPDX-License-Identifier: MIT
290
+ */
291
+
292
+ declare class LayoutStore implements ILayoutStore {
293
+ readonly config: LayoutConfig;
294
+ private indexMap;
295
+ private init;
296
+ private store;
297
+ options: LayoutOptions;
298
+ container: LayoutNode;
299
+ constructor(config: LayoutConfig);
300
+ get initialized(): boolean;
301
+ getNode(id?: string): LayoutNode | undefined;
302
+ getNodeByIndex(index: string): LayoutNode | undefined;
303
+ getEdge(id: string): LayoutEdge | undefined;
304
+ get nodes(): LayoutNode[];
305
+ get edges(): LayoutEdge[];
306
+ create(params: LayoutParams, options: LayoutOptions): void;
307
+ /** 创建布局数据 */
308
+ private createStore;
309
+ /** 创建虚拟线条数据 */
310
+ private createVirtualEdges;
311
+ /** 创建节点索引映射 */
312
+ private createIndexMap;
313
+ /** 节点排序 */
314
+ private sortNodes;
315
+ /** 记录运行选项 */
316
+ private setOptions;
317
+ /** 设置跟随节点配置 */
318
+ private setFollowNode;
319
+ }
320
+
296
321
  /**
297
322
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
298
323
  * SPDX-License-Identifier: MIT
@@ -306,12 +331,22 @@ declare const DefaultLayoutConfig: LayoutConfig;
306
331
  */
307
332
 
308
333
  declare class AutoLayoutService {
334
+ private playground;
309
335
  private readonly document;
310
336
  private layoutConfig;
311
337
  init(options: AutoLayoutOptions): void;
312
338
  layout(options?: Partial<LayoutOptions>): Promise<void>;
339
+ private fitView;
313
340
  private layoutNode;
341
+ private createLayoutNodes;
342
+ /** 创建节点布局数据 */
343
+ private createLayoutNode;
344
+ private createLayoutEdges;
345
+ /** 创建线条布局数据 */
346
+ private createLayoutEdge;
314
347
  private getNodesAllLines;
348
+ private getLayoutNodeRect;
349
+ private layoutNodeRect;
315
350
  }
316
351
 
317
352
  export { AutoLayoutService, DefaultLayoutConfig, type GetFollowNode, Layout, type LayoutEdge, type LayoutNode, type LayoutOptions, LayoutStore, createFreeAutoLayoutPlugin, dagreLib };
package/dist/index.d.ts CHANGED
@@ -145,44 +145,26 @@ declare namespace dagreLib {
145
145
  * SPDX-License-Identifier: MIT
146
146
  */
147
147
 
148
- declare class LayoutStore {
149
- readonly config: LayoutConfig;
150
- private indexMap;
151
- private init;
152
- private store;
153
- private container;
148
+ interface ILayoutStore {
149
+ container: LayoutNode;
154
150
  options: LayoutOptions;
155
- constructor(config: LayoutConfig);
156
151
  get initialized(): boolean;
157
152
  getNode(id?: string): LayoutNode | undefined;
158
153
  getNodeByIndex(index: string): LayoutNode | undefined;
159
154
  getEdge(id: string): LayoutEdge | undefined;
160
- get nodes(): LayoutNode[];
161
- get edges(): LayoutEdge[];
155
+ nodes: LayoutNode[];
156
+ edges: LayoutEdge[];
162
157
  create(params: LayoutParams, options: LayoutOptions): void;
163
- /** 创建布局数据 */
164
- private createStore;
165
- /** 创建节点布局数据 */
166
- private createLayoutNodes;
167
- /** 创建线条布局数据 */
168
- private createEdgesStore;
169
- /** 创建虚拟线条数据 */
170
- private createVirtualEdges;
171
- /** 创建节点索引映射 */
172
- private createIndexMap;
173
- /** 节点排序 */
174
- private sortNodes;
175
- /** 记录运行选项 */
176
- private setOptions;
177
- /** 设置跟随节点配置 */
178
- private setFollowNode;
179
158
  }
180
-
181
- /**
182
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
183
- * SPDX-License-Identifier: MIT
184
- */
185
-
159
+ interface ILayout {
160
+ init(params: LayoutParams, options: LayoutOptions): void;
161
+ layout(): void;
162
+ position(): Promise<void>;
163
+ }
164
+ interface LayoutSize {
165
+ width: number;
166
+ height: number;
167
+ }
186
168
  interface LayoutNode {
187
169
  id: string;
188
170
  /** 节点索引 */
@@ -203,13 +185,19 @@ interface LayoutNode {
203
185
  x: number;
204
186
  y: number;
205
187
  };
206
- /** 宽高 */
207
- size: {
208
- width: number;
209
- height: number;
188
+ /** 边距 */
189
+ padding: {
190
+ top: number;
191
+ bottom: number;
192
+ left: number;
193
+ right: number;
210
194
  };
211
- /** 是否存在子节点 */
212
- hasChildren: boolean;
195
+ /** 宽高 */
196
+ size: LayoutSize;
197
+ /** 子节点 */
198
+ layoutNodes: LayoutNode[];
199
+ /** 子线条 */
200
+ layoutEdges: LayoutEdge[];
213
201
  /** 被跟随节点 */
214
202
  followedBy?: string[];
215
203
  /** 跟随节点 */
@@ -231,13 +219,16 @@ interface LayoutEdge {
231
219
  name: string;
232
220
  }
233
221
  interface LayoutParams {
234
- nodes: WorkflowNodeEntity[];
235
- edges: WorkflowLineEntity[];
236
- container: WorkflowNodeEntity;
222
+ container: LayoutNode;
223
+ layoutNodes: LayoutNode[];
224
+ layoutEdges: LayoutEdge[];
237
225
  }
238
226
  interface LayoutOptions {
227
+ containerNode?: WorkflowNodeEntity;
239
228
  getFollowNode?: GetFollowNode;
240
229
  enableAnimation?: boolean;
230
+ animationDuration?: number;
231
+ disableFitView?: boolean;
241
232
  }
242
233
  interface LayoutConfig {
243
234
  /** Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right. */
@@ -260,7 +251,7 @@ interface LayoutConfig {
260
251
  ranker: 'network-simplex' | 'tight-tree' | 'longest-path';
261
252
  }
262
253
  type GetFollowNode = (node: LayoutNode, context: {
263
- store: LayoutStore;
254
+ store: ILayoutStore;
264
255
  /** 业务自定义参数 */
265
256
  [key: string]: any;
266
257
  }) => {
@@ -283,7 +274,7 @@ declare const createFreeAutoLayoutPlugin: _flowgram_ai_core.PluginCreator<AutoLa
283
274
  * SPDX-License-Identifier: MIT
284
275
  */
285
276
 
286
- declare class Layout {
277
+ declare class Layout implements ILayout {
287
278
  private readonly _store;
288
279
  private readonly _layout;
289
280
  private readonly _position;
@@ -293,6 +284,40 @@ declare class Layout {
293
284
  position(): Promise<void>;
294
285
  }
295
286
 
287
+ /**
288
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
289
+ * SPDX-License-Identifier: MIT
290
+ */
291
+
292
+ declare class LayoutStore implements ILayoutStore {
293
+ readonly config: LayoutConfig;
294
+ private indexMap;
295
+ private init;
296
+ private store;
297
+ options: LayoutOptions;
298
+ container: LayoutNode;
299
+ constructor(config: LayoutConfig);
300
+ get initialized(): boolean;
301
+ getNode(id?: string): LayoutNode | undefined;
302
+ getNodeByIndex(index: string): LayoutNode | undefined;
303
+ getEdge(id: string): LayoutEdge | undefined;
304
+ get nodes(): LayoutNode[];
305
+ get edges(): LayoutEdge[];
306
+ create(params: LayoutParams, options: LayoutOptions): void;
307
+ /** 创建布局数据 */
308
+ private createStore;
309
+ /** 创建虚拟线条数据 */
310
+ private createVirtualEdges;
311
+ /** 创建节点索引映射 */
312
+ private createIndexMap;
313
+ /** 节点排序 */
314
+ private sortNodes;
315
+ /** 记录运行选项 */
316
+ private setOptions;
317
+ /** 设置跟随节点配置 */
318
+ private setFollowNode;
319
+ }
320
+
296
321
  /**
297
322
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
298
323
  * SPDX-License-Identifier: MIT
@@ -306,12 +331,22 @@ declare const DefaultLayoutConfig: LayoutConfig;
306
331
  */
307
332
 
308
333
  declare class AutoLayoutService {
334
+ private playground;
309
335
  private readonly document;
310
336
  private layoutConfig;
311
337
  init(options: AutoLayoutOptions): void;
312
338
  layout(options?: Partial<LayoutOptions>): Promise<void>;
339
+ private fitView;
313
340
  private layoutNode;
341
+ private createLayoutNodes;
342
+ /** 创建节点布局数据 */
343
+ private createLayoutNode;
344
+ private createLayoutEdges;
345
+ /** 创建线条布局数据 */
346
+ private createLayoutEdge;
314
347
  private getNodesAllLines;
348
+ private getLayoutNodeRect;
349
+ private layoutNodeRect;
315
350
  }
316
351
 
317
352
  export { AutoLayoutService, DefaultLayoutConfig, type GetFollowNode, Layout, type LayoutEdge, type LayoutNode, type LayoutOptions, LayoutStore, createFreeAutoLayoutPlugin, dagreLib };