@flowgram.ai/free-layout-core 0.2.7 → 0.2.9

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.
@@ -0,0 +1,21 @@
1
+ // src/typings/workflow-line.ts
2
+ var LineType = /* @__PURE__ */ ((LineType2) => {
3
+ LineType2[LineType2["BEZIER"] = 0] = "BEZIER";
4
+ LineType2[LineType2["LINE_CHART"] = 1] = "LINE_CHART";
5
+ return LineType2;
6
+ })(LineType || {});
7
+ var LineColors = /* @__PURE__ */ ((LineColors2) => {
8
+ LineColors2["HIDDEN"] = "var(--g-line-color-hidden,transparent)";
9
+ LineColors2["DEFUALT"] = "var(--g-line-color-default,#4d53e8)";
10
+ LineColors2["DRAWING"] = "var(--g-line-color-drawing, #5DD6E3)";
11
+ LineColors2["HOVER"] = "var(--g-line-color-hover,#37d0ff)";
12
+ LineColors2["SELECTED"] = "var(--g-line-color-selected,#37d0ff)";
13
+ LineColors2["ERROR"] = "var(--g-line-color-error,red)";
14
+ return LineColors2;
15
+ })(LineColors || {});
16
+
17
+ export {
18
+ LineType,
19
+ LineColors
20
+ };
21
+ //# sourceMappingURL=chunk-6DKK25L7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/typings/workflow-line.ts"],"sourcesContent":["import type { Rectangle, IPoint } from '@flowgram.ai/utils';\n\nimport { type WorkflowLineEntity } from '../entities';\n\nexport enum LineType {\n BEZIER, // 贝塞尔曲线\n LINE_CHART, // 折叠线\n}\n\nexport type LineRenderType = LineType | string;\n\nexport interface LinePosition {\n from: IPoint;\n to: IPoint;\n}\n\nexport interface LineColor {\n hidden: string;\n default: string;\n drawing: string;\n hovered: string;\n selected: string;\n error: string;\n}\n\nexport enum LineColors {\n HIDDEN = 'var(--g-line-color-hidden,transparent)', // 隐藏线条\n DEFUALT = 'var(--g-line-color-default,#4d53e8)',\n DRAWING = 'var(--g-line-color-drawing, #5DD6E3)', // '#b5bbf8', // '#9197F1',\n HOVER = 'var(--g-line-color-hover,#37d0ff)',\n SELECTED = 'var(--g-line-color-selected,#37d0ff)',\n ERROR = 'var(--g-line-color-error,red)',\n}\n\nexport interface WorkflowLineRenderContribution {\n entity: WorkflowLineEntity;\n path: string;\n bounds: Rectangle;\n update: (params: { fromPos: IPoint; toPos: IPoint }) => void;\n calcDistance: (pos: IPoint) => number;\n}\n\nexport type WorkflowLineRenderContributionFactory = (new (\n entity: WorkflowLineEntity\n) => WorkflowLineRenderContribution) & {\n type: LineRenderType;\n};\n"],"mappings":";AAIO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,oBAAA;AACA,EAAAA,oBAAA;AAFU,SAAAA;AAAA,GAAA;AAqBL,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,YAAS;AACT,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,WAAQ;AANE,SAAAA;AAAA,GAAA;","names":["LineType","LineColors"]}
package/dist/esm/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  LineColors,
13
13
  LineType
14
- } from "./chunk-PT4ZVDZZ.js";
14
+ } from "./chunk-6DKK25L7.js";
15
15
  import "./chunk-DDJTYHXN.js";
16
16
  import {
17
17
  WorkflowOperationBaseService
@@ -1236,12 +1236,12 @@ var WorkflowLinesManager = class {
1236
1236
  }
1237
1237
  get lineColor() {
1238
1238
  const color = {
1239
- default: "#4d53e8" /* DEFUALT */,
1240
- error: "red" /* ERROR */,
1241
- hidden: "transparent" /* HIDDEN */,
1242
- drawing: "#5DD6E3" /* DRAWING */,
1243
- hovered: "#37d0ff" /* HOVER */,
1244
- selected: "#37d0ff" /* HOVER */
1239
+ default: "var(--g-line-color-default,#4d53e8)" /* DEFUALT */,
1240
+ error: "var(--g-line-color-error,red)" /* ERROR */,
1241
+ hidden: "var(--g-line-color-hidden,transparent)" /* HIDDEN */,
1242
+ drawing: "var(--g-line-color-drawing, #5DD6E3)" /* DRAWING */,
1243
+ hovered: "var(--g-line-color-hover,#37d0ff)" /* HOVER */,
1244
+ selected: "var(--g-line-color-selected,#37d0ff)" /* SELECTED */
1245
1245
  };
1246
1246
  if (this.options.lineColor) {
1247
1247
  Object.assign(color, this.options.lineColor);
@@ -1535,7 +1535,11 @@ import { customAlphabet } from "nanoid";
1535
1535
  import { inject as inject5, injectable as injectable5, optional, postConstruct } from "inversify";
1536
1536
  import { Emitter as Emitter4 } from "@flowgram.ai/utils";
1537
1537
  import { NodeEngineContext } from "@flowgram.ai/form-core";
1538
- import { FlowDocument, FlowNodeBaseType, FlowNodeTransformData as FlowNodeTransformData5 } from "@flowgram.ai/document";
1538
+ import {
1539
+ FlowDocument,
1540
+ FlowNodeBaseType,
1541
+ FlowNodeTransformData as FlowNodeTransformData5
1542
+ } from "@flowgram.ai/document";
1539
1543
  import {
1540
1544
  injectPlaygroundContext,
1541
1545
  PlaygroundConfigEntity as PlaygroundConfigEntity4,
@@ -1778,7 +1782,6 @@ var WorkflowDocument = class extends FlowDocument {
1778
1782
  parent
1779
1783
  },
1780
1784
  void 0,
1781
- true,
1782
1785
  true
1783
1786
  );
1784
1787
  const registry = node.getNodeRegistry();
@@ -1883,6 +1886,64 @@ var WorkflowDocument = class extends FlowDocument {
1883
1886
  }
1884
1887
  return node;
1885
1888
  }
1889
+ /**
1890
+ * 添加节点,如果节点已经存在则不会重复创建
1891
+ * @param data
1892
+ * @param addedNodes
1893
+ */
1894
+ addNode(data, addedNodes, ignoreCreateAndUpdateEvent) {
1895
+ const { id, type = "block", originParent, parent, meta, hidden, index } = data;
1896
+ let node = this.getNode(id);
1897
+ let isNew = false;
1898
+ const register = this.getNodeRegistry(type, data.originParent);
1899
+ if (node && node.flowNodeType !== data.type) {
1900
+ node.dispose();
1901
+ node = void 0;
1902
+ }
1903
+ if (!node) {
1904
+ const { dataRegistries } = register;
1905
+ node = this.entityManager.createEntity(WorkflowNodeEntity, {
1906
+ id,
1907
+ document: this,
1908
+ flowNodeType: type,
1909
+ originParent,
1910
+ meta
1911
+ });
1912
+ const datas = dataRegistries ? this.nodeDataRegistries.concat(...dataRegistries) : this.nodeDataRegistries;
1913
+ node.addInitializeData(datas);
1914
+ node.onDispose(() => this.onNodeDisposeEmitter.fire({ node }));
1915
+ this.options.fromNodeJSON?.(node, data, true);
1916
+ isNew = true;
1917
+ } else {
1918
+ this.options.fromNodeJSON?.(node, data, false);
1919
+ }
1920
+ node.initData({
1921
+ originParent,
1922
+ parent,
1923
+ meta,
1924
+ hidden,
1925
+ index
1926
+ });
1927
+ addedNodes?.push(node);
1928
+ if (register.onCreate) {
1929
+ const extendNodes = register.onCreate(node, data);
1930
+ if (extendNodes && addedNodes) {
1931
+ addedNodes.push(...extendNodes);
1932
+ }
1933
+ }
1934
+ if (!ignoreCreateAndUpdateEvent) {
1935
+ if (isNew) {
1936
+ this.onNodeCreateEmitter.fire({
1937
+ node,
1938
+ data,
1939
+ json: data
1940
+ });
1941
+ } else {
1942
+ this.onNodeUpdateEmitter.fire({ node, data, json: data });
1943
+ }
1944
+ }
1945
+ return node;
1946
+ }
1886
1947
  get layout() {
1887
1948
  const layout = this.layouts.find((layout2) => layout2.name == this.currentLayoutKey);
1888
1949
  if (!layout) {