@logicflow/vue-node-registry 1.1.11 → 1.1.13

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.
@@ -1,10 +1,14 @@
1
1
 
2
- > @logicflow/vue-node-registry@1.1.10 build:dev /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
2
+ > @logicflow/vue-node-registry@1.1.12 build:dev /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
3
3
  > rss
4
4
 
5
5
  > [build:dev] pnpm run --if-present build:less && run-p -s build:cjs build:esm
6
6
 
7
- > @logicflow/vue-node-registry@1.1.10 build:less /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
7
+ > @logicflow/vue-node-registry@1.1.12 build:less /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
8
8
  > rss
9
9
 
10
10
  > [build:less] ./scripts/build-less
11
+ src/view.ts(48,11): error TS2554: Expected 2 arguments, but got 1.
12
+ src/view.ts(56,11): error TS2554: Expected 2 arguments, but got 1.
13
+ src/view.ts(48,11): error TS2554: Expected 2 arguments, but got 1.
14
+ src/view.ts(56,11): error TS2554: Expected 2 arguments, but got 1.
@@ -1,11 +1,11 @@
1
1
 
2
- > @logicflow/vue-node-registry@1.1.10 prebuild /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
2
+ > @logicflow/vue-node-registry@1.1.12 prebuild /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
3
3
  > rss
4
4
 
5
5
  > [prebuild] run-s -s clean:build
6
6
  > [clean:build] rimraf dist es lib
7
7
 
8
- > @logicflow/vue-node-registry@1.1.10 build /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
8
+ > @logicflow/vue-node-registry@1.1.12 build /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
9
9
  > rss
10
10
 
11
11
  > [build] run-p -s build:dev build:umd
@@ -13,22 +13,39 @@
13
13
  > [build:dev] pnpm run --if-present build:less && run-p -s build:cjs build:esm
14
14
  > [build:less] ./scripts/build-less
15
15
  > [build:less] ./scripts/build-less
16
+ src/view.ts(48,11): error TS2554: Expected 2 arguments, but got 1.
17
+ src/view.ts(56,11): error TS2554: Expected 2 arguments, but got 1.
18
+ src/view.ts(48,11): error TS2554: Expected 2 arguments, but got 1.
19
+ src/view.ts(56,11): error TS2554: Expected 2 arguments, but got 1.
16
20
  
17
21
  ./src/index.ts → dist/index.min.js...
18
- +----------------------------------------------+
19
- | |
20
- | Bundle Format: umd |
21
- | Bundle Name: VueNodeRegistry |
22
- | External Globals: |
23
- |  @logicflow/core: Core |
24
- |  @vue/composition-api: VueCompositionApi |
25
- |  vue: Vue |
26
- | |
27
- | Destination: dist/index.min.js |
28
- | Bundle Size: 390 B |
29
- | Minified Size: 351 B |
30
- | GZipped Size: 200 B |
31
- | |
32
- +----------------------------------------------+
33
22
  (!) [plugin typescript] @rollup/plugin-typescript: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a "module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.
34
- created dist/index.min.js in 6.4s
23
+ [!] (plugin typescript) RollupError: [plugin typescript] src/view.ts (48:11): @rollup/plugin-typescript TS2554: Expected 2 arguments, but got 1.
24
+ src/view.ts (48:11)
25
+ 
26
+ 48 disconnect(this.targetId())
27
+    ~~~~~~~~~~
28
+
29
+ src/teleport.ts:44:40
30
+ 44 export function disconnect(id: string, flowId: string) {
31
+    ~~~~~~~~~~~~~~
32
+ An argument for 'flowId' was not provided.
33
+ 
34
+  at getRollupError (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/rollup@4.22.4/node_modules/rollup/dist/shared/parseAst.js:282:41)
35
+ at Object.error (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/rollup@4.22.4/node_modules/rollup/dist/shared/parseAst.js:278:42)
36
+ at Object.error (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/rollup@4.22.4/node_modules/rollup/dist/shared/rollup.js:815:32)
37
+ at emitDiagnostic (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/@rollup+plugin-typescript@10.0.1_rollup@4.22.4_tslib@2.6.3_typescript@5.4.5/node_modules/@rollup/plugin-typescript/dist/cjs/index.js:535:17)
38
+ at reportDiagnostics (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/@rollup+plugin-typescript@10.0.1_rollup@4.22.4_tslib@2.6.3_typescript@5.4.5/node_modules/@rollup/plugin-typescript/dist/cjs/index.js:543:9)
39
+ at Array.forEach (<anonymous>)
40
+ at emitFilesAndReportErrors (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/typescript@5.4.5/node_modules/typescript/lib/typescript.js:127124:17)
41
+ at Object.result.afterProgramCreate (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/typescript@5.4.5/node_modules/typescript/lib/typescript.js:127283:7)
42
+ at Object.afterProgramCreate (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/@rollup+plugin-typescript@10.0.1_rollup@4.22.4_tslib@2.6.3_typescript@5.4.5/node_modules/@rollup/plugin-typescript/dist/cjs/index.js:700:29)
43
+ at synchronizeProgram (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/typescript@5.4.5/node_modules/typescript/lib/typescript.js:127652:14)
44
+ at Object.createWatchProgram (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/typescript@5.4.5/node_modules/typescript/lib/typescript.js:127553:5)
45
+ at createWatchProgram (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/@rollup+plugin-typescript@10.0.1_rollup@4.22.4_tslib@2.6.3_typescript@5.4.5/node_modules/@rollup/plugin-typescript/dist/cjs/index.js:715:15)
46
+ at Object.buildStart (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/@rollup+plugin-typescript@10.0.1_rollup@4.22.4_tslib@2.6.3_typescript@5.4.5/node_modules/@rollup/plugin-typescript/dist/cjs/index.js:776:27)
47
+ at /Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/rollup@4.22.4/node_modules/rollup/dist/shared/rollup.js:1000:40
48
+ at async Promise.all (index 2)
49
+ at PluginDriver.hookParallel (/Users/didi/Desktop/github/LogicFlow/node_modules/.pnpm/rollup@4.22.4/node_modules/rollup/dist/shared/rollup.js:928:9)
50
+
51
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @logicflow/vue-node-registry
2
2
 
3
+ ## 1.1.13
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(vue-node-registry): 为每个 LogicFlow 实例分配 vueNodesMap 范围,以支持嵌套场景
8
+
9
+ ## 1.1.12
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - @logicflow/core@2.1.11
15
+
3
16
  ## 1.1.11
4
17
 
5
18
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/vue-node-registry",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "LogicFlow Vue Component Node Registry",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,7 +20,7 @@
20
20
  "peerDependencies": {
21
21
  "@vue/composition-api": "^1.0.0-rc.10",
22
22
  "vue": "^2.0.0 || >=3.0.0",
23
- "@logicflow/core": "2.1.10"
23
+ "@logicflow/core": "2.1.11"
24
24
  },
25
25
  "peerDependenciesMeta": {
26
26
  "@vue/composition-api": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "vue": "^3.0.0",
32
- "@logicflow/core": "2.1.10"
32
+ "@logicflow/core": "2.1.11"
33
33
  },
34
34
  "author": {
35
35
  "name": "boyongjiong",
package/src/registry.ts CHANGED
@@ -1,4 +1,4 @@
1
- import LogicFlow from '@logicflow/core'
1
+ import LogicFlow, { GraphModel } from '@logicflow/core'
2
2
  import { VueNodeView } from './view'
3
3
  import { VueNodeModel } from './model'
4
4
 
@@ -10,13 +10,35 @@ export type VueNodeConfig = {
10
10
  effect?: (keyof LogicFlow.PropertiesType)[]
11
11
  } & Partial<RegisterConfig>
12
12
 
13
- export const vueNodesMap: Record<
14
- string,
15
- {
16
- component: any
17
- effect?: (keyof LogicFlow.PropertiesType)[]
13
+ type VueNodeEntry = {
14
+ component: any
15
+ effect?: (keyof LogicFlow.PropertiesType)[]
16
+ }
17
+
18
+ // Per-instance map: entries are eligible for garbage collection once the associated GraphModel instance is no longer referenced
19
+ const vueNodesMaps = new WeakMap<GraphModel, Map<string, VueNodeEntry>>()
20
+
21
+ /**
22
+ * @deprecated Use {@link getVueNodeConfig} instead for multi-instance support.
23
+ * This global map is still populated for backward compatibility but does NOT
24
+ * isolate registrations across different LogicFlow instances.
25
+ */
26
+ export const vueNodesMap: Record<string, VueNodeEntry> = Object.create(
27
+ null,
28
+ ) as Record<string, VueNodeEntry>
29
+
30
+ /**
31
+ * Retrieve the Vue node configuration scoped to a specific LogicFlow instance.
32
+ */
33
+ export function getVueNodeConfig(
34
+ type: string,
35
+ graphModel?: GraphModel | null,
36
+ ): VueNodeEntry | undefined {
37
+ if (typeof graphModel !== 'object' || graphModel === null) {
38
+ return undefined
18
39
  }
19
- > = {}
40
+ return vueNodesMaps.get(graphModel)?.get(type)
41
+ }
20
42
 
21
43
  export function register(config: VueNodeConfig, lf: LogicFlow) {
22
44
  const {
@@ -30,10 +52,19 @@ export function register(config: VueNodeConfig, lf: LogicFlow) {
30
52
  if (!type) {
31
53
  throw new Error('You should specify type in config')
32
54
  }
33
- vueNodesMap[type] = {
34
- component,
35
- effect,
55
+
56
+ const entry: VueNodeEntry = { component, effect }
57
+
58
+ // Scope to this LogicFlow instance
59
+ let map = vueNodesMaps.get(lf.graphModel)
60
+ if (!map) {
61
+ map = new Map<string, VueNodeEntry>()
62
+ vueNodesMaps.set(lf.graphModel, map)
36
63
  }
64
+ map.set(type, entry)
65
+
66
+ // Also populate global map for backward compatibility
67
+ vueNodesMap[type] = entry
37
68
 
38
69
  lf.register({
39
70
  type,
package/src/view.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isVue2, isVue3, createApp, h, Vue2 } from 'vue-demi'
2
2
  import { HtmlNode } from '@logicflow/core'
3
- import { vueNodesMap } from './registry'
3
+ import { getVueNodeConfig } from './registry'
4
4
  import { isActive, connect, disconnect } from './teleport'
5
5
 
6
6
  export class VueNodeView extends HtmlNode {
@@ -41,7 +41,22 @@ export class VueNodeView extends HtmlNode {
41
41
  const { model, graphModel } = this.props
42
42
 
43
43
  if (root) {
44
- const { component } = vueNodesMap[model.type]
44
+ const nodeConfig = getVueNodeConfig(model.type, graphModel)
45
+ if (!nodeConfig) {
46
+ // No registered config for this node type; ensure any existing Teleport mount is cleaned up
47
+ if (isVue3 && isActive()) {
48
+ disconnect(this.targetId())
49
+ }
50
+ return
51
+ }
52
+ const { component } = nodeConfig
53
+ if (!component) {
54
+ // Config exists but has no component; also clean up any existing Teleport mount
55
+ if (isVue3 && isActive()) {
56
+ disconnect(this.targetId())
57
+ }
58
+ return
59
+ }
45
60
  if (component) {
46
61
  if (isVue2) {
47
62
  const Vue = Vue2 as any
package/dist/index.min.js DELETED
@@ -1,2 +0,0 @@
1
- !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./view"),exports),e.__exportStar(require("./model"),exports),e.__exportStar(require("./registry"),exports),e.__exportStar(require("./teleport"),exports)}));
2
- //# sourceMappingURL=index.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.min.js","sources":["../src/index.ts"],"sourcesContent":["export * from './view'\nexport * from './model'\nexport * from './registry'\nexport * from './teleport'\n"],"names":["tslib_1","__exportStar","require","exports"],"mappings":"2KAAAA,EAAsBC,aAAAC,QAAA,UAAAC,SACtBH,EAAuBC,aAAAC,QAAA,WAAAC,SACvBH,EAA0BC,aAAAC,QAAA,cAAAC,SAC1BH,EAA0BC,aAAAC,QAAA,cAAAC"}
package/es/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './view';
2
- export * from './model';
3
- export * from './registry';
4
- export * from './teleport';
package/es/index.js DELETED
@@ -1,5 +0,0 @@
1
- export * from './view';
2
- export * from './model';
3
- export * from './registry';
4
- export * from './teleport';
5
- //# sourceMappingURL=index.js.map
package/es/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
package/es/model.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import LogicFlow, { HtmlNodeModel, IHtmlNodeProperties } from '@logicflow/core';
2
- export interface VueCustomProperties extends IHtmlNodeProperties {
3
- width?: number;
4
- height?: number;
5
- radius?: number;
6
- refX?: number;
7
- refY?: number;
8
- style?: LogicFlow.CommonTheme;
9
- textStyle?: LogicFlow.TextNodeTheme;
10
- }
11
- export declare class VueNodeModel<P extends VueCustomProperties = VueCustomProperties> extends HtmlNodeModel<P> {
12
- setAttributes(): void;
13
- getTextStyle(): LogicFlow.TextNodeTheme;
14
- getNodeStyle(): LogicFlow.CommonTheme;
15
- }
16
- export default VueNodeModel;
package/es/model.js DELETED
@@ -1,62 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var __assign = (this && this.__assign) || function () {
17
- __assign = Object.assign || function(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
- t[p] = s[p];
22
- }
23
- return t;
24
- };
25
- return __assign.apply(this, arguments);
26
- };
27
- import { HtmlNodeModel } from '@logicflow/core';
28
- import { cloneDeep, isNil } from 'lodash-es';
29
- var VueNodeModel = /** @class */ (function (_super) {
30
- __extends(VueNodeModel, _super);
31
- function VueNodeModel() {
32
- return _super !== null && _super.apply(this, arguments) || this;
33
- }
34
- VueNodeModel.prototype.setAttributes = function () {
35
- // DONE: 解决 width、height、radius 为 0 时的问题
36
- var _a = this.properties, width = _a.width, height = _a.height, radius = _a.radius;
37
- if (!isNil(width)) {
38
- this.width = width;
39
- }
40
- if (!isNil(height)) {
41
- this.height = height;
42
- }
43
- if (!isNil(radius)) {
44
- this.radius = radius;
45
- }
46
- };
47
- VueNodeModel.prototype.getTextStyle = function () {
48
- var _a = this.properties, _b = _a.refX, refX = _b === void 0 ? 0 : _b, _c = _a.refY, refY = _c === void 0 ? 0 : _c, textStyle = _a.textStyle;
49
- var style = _super.prototype.getTextStyle.call(this);
50
- // 通过 transform 重新设置 text 的位置
51
- return __assign(__assign(__assign({}, style), (cloneDeep(textStyle) || {})), { transform: "matrix(1 0 0 1 ".concat(refX, " ").concat(refY, ")") });
52
- };
53
- VueNodeModel.prototype.getNodeStyle = function () {
54
- var style = _super.prototype.getNodeStyle.call(this);
55
- var customNodeStyle = this.properties.style;
56
- return __assign(__assign({}, style), (cloneDeep(customNodeStyle) || {}));
57
- };
58
- return VueNodeModel;
59
- }(HtmlNodeModel));
60
- export { VueNodeModel };
61
- export default VueNodeModel;
62
- //# sourceMappingURL=model.js.map
package/es/model.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAkB,EA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CAAC,AA3CD,CAEU,aAAa,GAyCtB;;AAED,eAAe,YAAY,CAAA"}
package/es/registry.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import LogicFlow from '@logicflow/core';
2
- import RegisterConfig = LogicFlow.RegisterConfig;
3
- export type VueNodeConfig = {
4
- type: string;
5
- component: any;
6
- effect?: (keyof LogicFlow.PropertiesType)[];
7
- } & Partial<RegisterConfig>;
8
- export declare const vueNodesMap: Record<string, {
9
- component: any;
10
- effect?: (keyof LogicFlow.PropertiesType)[];
11
- }>;
12
- export declare function register(config: VueNodeConfig, lf: LogicFlow): void;
package/es/registry.js DELETED
@@ -1,19 +0,0 @@
1
- import { VueNodeView } from './view';
2
- import { VueNodeModel } from './model';
3
- export var vueNodesMap = {};
4
- export function register(config, lf) {
5
- var type = config.type, component = config.component, effect = config.effect, CustomNodeView = config.view, CustomNodeModel = config.model;
6
- if (!type) {
7
- throw new Error('You should specify type in config');
8
- }
9
- vueNodesMap[type] = {
10
- component: component,
11
- effect: effect,
12
- };
13
- lf.register({
14
- type: type,
15
- view: CustomNodeView || VueNodeView,
16
- model: CustomNodeModel || VueNodeModel,
17
- });
18
- }
19
- //# sourceMappingURL=registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAUtC,MAAM,CAAC,IAAM,WAAW,GAMpB,EAAE,CAAA;AAEN,MAAM,UAAU,QAAQ,CAAC,MAAqB,EAAE,EAAa;IAEzD,IAAA,IAAI,GAKF,MAAM,KALJ,EACJ,SAAS,GAIP,MAAM,UAJC,EACT,MAAM,GAGJ,MAAM,OAHF,EACA,cAAc,GAElB,MAAM,KAFY,EACb,eAAe,GACpB,MAAM,MADc,CACd;IAEV,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IACtD,CAAC;IACD,WAAW,CAAC,IAAI,CAAC,GAAG;QAClB,SAAS,WAAA;QACT,MAAM,QAAA;KACP,CAAA;IAED,EAAE,CAAC,QAAQ,CAAC;QACV,IAAI,MAAA;QACJ,IAAI,EAAE,cAAc,IAAI,WAAW;QACnC,KAAK,EAAE,eAAe,IAAI,YAAY;KACvC,CAAC,CAAA;AACJ,CAAC"}
package/es/teleport.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import { BaseNodeModel, GraphModel } from '@logicflow/core';
2
- export declare function connect(id: string, component: any, container: HTMLDivElement, node: BaseNodeModel, graph: GraphModel): void;
3
- export declare function disconnect(id: string, flowId: string): void;
4
- export declare function isActive(): boolean;
5
- export declare function getTeleport(): any;
6
- /**
7
- * 创建并挂载 Teleport 容器组件
8
- * @param container 目标容器元素
9
- * @param flowId 当前流程图的唯一标识
10
- */
11
- export declare function createTeleportContainer(container: HTMLElement, flowId: string | undefined): void;
12
- /**
13
- * 卸载 Teleport 容器组件
14
- * @param flowId 需要卸载流程图的唯一标识
15
- */
16
- export declare function destroyTeleportContainer(flowId: string | undefined): void;
package/es/teleport.js DELETED
@@ -1,121 +0,0 @@
1
- import { defineComponent, h, createApp, reactive, isVue3, Teleport, markRaw, Fragment, } from 'vue-demi';
2
- var active = false;
3
- var appInstances = new Map();
4
- var appNodesMap = new Map(); // 用于储存当前流程图节点id当节点都销毁时同时卸载vueApp实例
5
- var items = reactive({});
6
- export function connect(id, component, container, node, graph) {
7
- if (active) {
8
- if (graph.isMiniMap) {
9
- createTeleportContainer(container, graph.flowId);
10
- }
11
- items[id] = markRaw(defineComponent({
12
- render: function () {
13
- return h(Teleport, { to: container }, [
14
- h(component, { node: node, graph: graph }),
15
- ]);
16
- },
17
- provide: function () { return ({
18
- getNode: function () { return node; },
19
- getGraph: function () { return graph; },
20
- }); },
21
- }));
22
- }
23
- }
24
- export function disconnect(id, flowId) {
25
- if (active) {
26
- delete items[id];
27
- if (appInstances.has(flowId)) {
28
- var appNodeList = appNodesMap.get(flowId) || [];
29
- var index = appNodeList.indexOf(id);
30
- if (index > -1) {
31
- appNodeList.splice(index, 1);
32
- if (appNodeList.length === 0) {
33
- destroyTeleportContainer(flowId);
34
- }
35
- else {
36
- appNodesMap.set(flowId, appNodeList);
37
- }
38
- }
39
- }
40
- }
41
- }
42
- export function isActive() {
43
- return active;
44
- }
45
- export function getTeleport() {
46
- if (!isVue3) {
47
- throw new Error('teleport is only available in Vue3');
48
- }
49
- active = true;
50
- return defineComponent({
51
- props: {
52
- flowId: {
53
- type: String,
54
- required: true,
55
- },
56
- },
57
- setup: function (props) {
58
- return function () {
59
- var children = [];
60
- Object.keys(items).forEach(function (id) {
61
- // https://github.com/didi/LogicFlow/issues/1768
62
- // 多个不同的VueNodeView都会connect注册到items中,因此items存储了可能有多个flowId流程图的数据
63
- // 当使用多个LogicFlow时,会创建多个flowId + 同时使用KeepAlive
64
- // 每一次items改变,会触发不同flowId持有的setup()执行,由于每次setup()执行就是遍历items,因此存在多次重复渲染元素的问题
65
- // 即items[0]会在Page1的setup()执行,items[0]也会在Page2的setup()执行,从而生成两个items[0]
66
- // 比对当前界面显示的flowId,只更新items[当前页面flowId:nodeId]的数据
67
- // 比如items[0]属于Page1的数据,那么Page2无论active=true/false,都无法执行items[0]
68
- if (id.startsWith(props.flowId)) {
69
- if (appInstances.has(props.flowId)) {
70
- var appNodeList = appNodesMap.get(props.flowId) || [];
71
- if (!appNodeList.includes(id)) {
72
- appNodeList.push(id);
73
- appNodesMap.set(props.flowId, appNodeList);
74
- }
75
- }
76
- children.push(items[id]);
77
- }
78
- });
79
- return h(Fragment, {}, children.map(function (item) { return h(item); }));
80
- };
81
- },
82
- });
83
- }
84
- /**
85
- * 创建并挂载 Teleport 容器组件
86
- * @param container 目标容器元素
87
- * @param flowId 当前流程图的唯一标识
88
- */
89
- export function createTeleportContainer(container, flowId) {
90
- if (!isVue3 || !flowId || !container || !active)
91
- return;
92
- // 获取 Teleport 组件
93
- var TeleportContainer = getTeleport();
94
- // 不重新创建 Teleport 容器组件
95
- if (appInstances.has(flowId)) {
96
- return;
97
- }
98
- // ✅ 1. 创建独立容器放到目标容器中
99
- var mountPoint = document.createElement('div');
100
- container.appendChild(mountPoint);
101
- // ✅ 2. 创建并挂载 Vue 应用到新容器
102
- var app = createApp(TeleportContainer, { flowId: flowId });
103
- app.mount(mountPoint);
104
- appInstances.set(flowId, app);
105
- appNodesMap.set(flowId, []);
106
- }
107
- /**
108
- * 卸载 Teleport 容器组件
109
- * @param flowId 需要卸载流程图的唯一标识
110
- */
111
- export function destroyTeleportContainer(flowId) {
112
- if (!isVue3 || !flowId || !active)
113
- return;
114
- var app = appInstances.get(flowId);
115
- if (app) {
116
- app.unmount();
117
- appInstances.delete(flowId);
118
- appNodesMap.delete(flowId);
119
- }
120
- }
121
- //# sourceMappingURL=teleport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"teleport.js","sourceRoot":"","sources":["../src/teleport.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,CAAC,EACD,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,GACT,MAAM,UAAU,CAAA;AAEjB,IAAI,MAAM,GAAG,KAAK,CAAA;AAClB,IAAM,YAAY,GAAG,IAAI,GAAG,EAA6B,CAAA;AACzD,IAAM,WAAW,GAAG,IAAI,GAAG,EAAe,CAAA,CAAC,mCAAmC;AAC9E,IAAM,KAAK,GAAG,QAAQ,CAAyB,EAAE,CAAC,CAAA;AAElD,MAAM,UAAU,OAAO,CACrB,EAAU,EACV,SAAc,EACd,SAAyB,EACzB,IAAmB,EACnB,KAAiB;IAEjB,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACpB,uBAAuB,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAClD,CAAC;QACD,KAAK,CAAC,EAAE,CAA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AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,SAAsB,EACtB,MAA0B;IAE1B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM;QAAE,OAAM;IAEvD,iBAAiB;IACjB,IAAM,iBAAiB,GAAG,WAAW,EAAE,CAAA;IAEvC,sBAAsB;IACtB,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,OAAM;IACR,CAAC;IAED,qBAAqB;IACrB,IAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAChD,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;IAEjC,wBAAwB;IACxB,IAAM,GAAG,GAAG,SAAS,CAAC,iBAAiB,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAA;IACpD,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAErB,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC7B,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAC7B,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAA0B;IACjE,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAM;IACzC,IAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACpC,IAAI,GAAG,EAAE,CAAC;QACR,GAAG,CAAC,OAAO,EAAE,CAAA;QACb,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAC3B,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC5B,CAAC;AACH,CAAC"}
package/es/view.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { HtmlNode } from '@logicflow/core';
2
- export declare class VueNodeView extends HtmlNode {
3
- root?: any;
4
- private vm;
5
- getComponentContainer(): any;
6
- protected targetId(): string;
7
- componentWillUnmount(): void;
8
- setHtml(rootEl: SVGForeignObjectElement): void;
9
- confirmUpdate(_rootEl: SVGForeignObjectElement): void;
10
- protected renderVueComponent(): void;
11
- protected unmountVueComponent(): any;
12
- unmount(): void;
13
- }
14
- export default VueNodeView;
package/es/view.js DELETED
@@ -1,120 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import { isVue2, isVue3, createApp, h, Vue2 } from 'vue-demi';
17
- import { HtmlNode } from '@logicflow/core';
18
- import { vueNodesMap } from './registry';
19
- import { isActive, connect, disconnect } from './teleport';
20
- var VueNodeView = /** @class */ (function (_super) {
21
- __extends(VueNodeView, _super);
22
- function VueNodeView() {
23
- return _super !== null && _super.apply(this, arguments) || this;
24
- }
25
- VueNodeView.prototype.getComponentContainer = function () {
26
- return this.root;
27
- };
28
- VueNodeView.prototype.targetId = function () {
29
- return "".concat(this.props.graphModel.flowId, ":").concat(this.props.model.id);
30
- };
31
- VueNodeView.prototype.componentWillUnmount = function () {
32
- _super.prototype.componentWillUnmount.call(this);
33
- this.unmount();
34
- };
35
- VueNodeView.prototype.setHtml = function (rootEl) {
36
- var el = document.createElement('div');
37
- el.className = 'custom-vue-node-content';
38
- this.root = el;
39
- rootEl.appendChild(el);
40
- this.renderVueComponent();
41
- };
42
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
43
- VueNodeView.prototype.confirmUpdate = function (_rootEl) {
44
- // TODO: 如有需要,可以先通过继承的方式,自定义该节点的更新逻辑;我们后续会根据实际需求,丰富该功能
45
- // console.log('_rootEl', _rootEl)
46
- };
47
- VueNodeView.prototype.renderVueComponent = function () {
48
- var _a;
49
- this.unmountVueComponent();
50
- var root = this.getComponentContainer();
51
- var _b = this.props, model = _b.model, graphModel = _b.graphModel;
52
- if (root) {
53
- var component_1 = vueNodesMap[model.type].component;
54
- if (component_1) {
55
- if (isVue2) {
56
- var Vue = Vue2;
57
- this.vm = new Vue({
58
- el: root,
59
- render: function (h) {
60
- return h(component_1, {
61
- node: model,
62
- graph: graphModel,
63
- });
64
- },
65
- provide: function () {
66
- return {
67
- getNode: function () { return model; },
68
- getGraph: function () { return graphModel; },
69
- };
70
- },
71
- });
72
- }
73
- else if (isVue3) {
74
- if (isActive()) {
75
- connect(this.targetId(), component_1, root, model, graphModel);
76
- }
77
- else {
78
- this.vm = createApp({
79
- render: function () {
80
- return h(component_1, {
81
- node: model,
82
- graph: graphModel,
83
- });
84
- },
85
- provide: function () {
86
- return {
87
- getNode: function () { return model; },
88
- getGraph: function () { return graphModel; },
89
- };
90
- },
91
- });
92
- (_a = this.vm) === null || _a === void 0 ? void 0 : _a.mount(root);
93
- }
94
- }
95
- }
96
- }
97
- };
98
- VueNodeView.prototype.unmountVueComponent = function () {
99
- var root = this.getComponentContainer();
100
- if (this.vm) {
101
- isVue2 && this.vm.$destroy();
102
- isVue3 && this.vm.unmount();
103
- this.vm = null;
104
- }
105
- if (root && !isActive()) {
106
- root.innerHTML = '';
107
- }
108
- return root;
109
- };
110
- VueNodeView.prototype.unmount = function () {
111
- if (isActive()) {
112
- disconnect(this.targetId(), this.props.graphModel.flowId);
113
- }
114
- this.unmountVueComponent();
115
- };
116
- return VueNodeView;
117
- }(HtmlNode));
118
- export { VueNodeView };
119
- export default VueNodeView;
120
- //# sourceMappingURL=view.js.map
package/es/view.js.map DELETED
@@ -1 +0,0 @@
1
- {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AE,KAAK,CAAC,IAAI,CAAC,CAAA;oBACtB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAES,yCAAmB,GAA7B;QACE,IAAM,IAAI,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;QACzC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAA;YAC5B,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAA;YAC3B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAA;QAChB,CAAC;QACD,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;QACrB,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,6BAAO,GAAP;QACE,IAAI,QAAQ,EAAE,EAAE,CAAC;YACf,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAgB,CAAC,CAAA;QACrE,CAAC;QACD,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IACH,kBAAC;AAAD,CAAC,AArGD,CAAiC,QAAQ,GAqGxC;;AAED,eAAe,WAAW,CAAA"}
package/lib/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './view';
2
- export * from './model';
3
- export * from './registry';
4
- export * from './teleport';
package/lib/index.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./view"), exports);
18
- __exportStar(require("./model"), exports);
19
- __exportStar(require("./registry"), exports);
20
- __exportStar(require("./teleport"), exports);
21
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAsB;AACtB,0CAAuB;AACvB,6CAA0B;AAC1B,6CAA0B"}
package/lib/model.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import LogicFlow, { HtmlNodeModel, IHtmlNodeProperties } from '@logicflow/core';
2
- export interface VueCustomProperties extends IHtmlNodeProperties {
3
- width?: number;
4
- height?: number;
5
- radius?: number;
6
- refX?: number;
7
- refY?: number;
8
- style?: LogicFlow.CommonTheme;
9
- textStyle?: LogicFlow.TextNodeTheme;
10
- }
11
- export declare class VueNodeModel<P extends VueCustomProperties = VueCustomProperties> extends HtmlNodeModel<P> {
12
- setAttributes(): void;
13
- getTextStyle(): LogicFlow.TextNodeTheme;
14
- getNodeStyle(): LogicFlow.CommonTheme;
15
- }
16
- export default VueNodeModel;
package/lib/model.js DELETED
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.VueNodeModel = void 0;
30
- var core_1 = require("@logicflow/core");
31
- var lodash_es_1 = require("lodash-es");
32
- var VueNodeModel = /** @class */ (function (_super) {
33
- __extends(VueNodeModel, _super);
34
- function VueNodeModel() {
35
- return _super !== null && _super.apply(this, arguments) || this;
36
- }
37
- VueNodeModel.prototype.setAttributes = function () {
38
- // DONE: 解决 width、height、radius 为 0 时的问题
39
- var _a = this.properties, width = _a.width, height = _a.height, radius = _a.radius;
40
- if (!(0, lodash_es_1.isNil)(width)) {
41
- this.width = width;
42
- }
43
- if (!(0, lodash_es_1.isNil)(height)) {
44
- this.height = height;
45
- }
46
- if (!(0, lodash_es_1.isNil)(radius)) {
47
- this.radius = radius;
48
- }
49
- };
50
- VueNodeModel.prototype.getTextStyle = function () {
51
- var _a = this.properties, _b = _a.refX, refX = _b === void 0 ? 0 : _b, _c = _a.refY, refY = _c === void 0 ? 0 : _c, textStyle = _a.textStyle;
52
- var style = _super.prototype.getTextStyle.call(this);
53
- // 通过 transform 重新设置 text 的位置
54
- return __assign(__assign(__assign({}, style), ((0, lodash_es_1.cloneDeep)(textStyle) || {})), { transform: "matrix(1 0 0 1 ".concat(refX, " ").concat(refY, ")") });
55
- };
56
- VueNodeModel.prototype.getNodeStyle = function () {
57
- var style = _super.prototype.getNodeStyle.call(this);
58
- var customNodeStyle = this.properties.style;
59
- return __assign(__assign({}, style), ((0, lodash_es_1.cloneDeep)(customNodeStyle) || {}));
60
- };
61
- return VueNodeModel;
62
- }(core_1.HtmlNodeModel));
63
- exports.VueNodeModel = VueNodeModel;
64
- exports.default = VueNodeModel;
65
- //# sourceMappingURL=model.js.map
package/lib/model.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAA+E;AAC/E,uCAA4C;AAiB5C;IAEU,gCAAgB;IAF1B;;IA2CA,CAAC;IAxCC,oCAAa,GAAb;QACE,wCAAwC;QAClC,IAAA,KAA4B,IAAI,CAAC,UAAU,EAAzC,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,MAAM,YAAoB,CAAA;QACjD,IAAI,CAAC,IAAA,iBAAK,EAAC,KAAK,CAAC,EAAE,CAAC;YAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,CAAC;QACD,IAAI,CAAC,IAAA,iBAAK,EAAC,MAAM,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACtB,CAAC;QACD,IAAI,CAAC,IAAA,iBAAK,EAAC,MAAM,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACtB,CAAC;IACH,CAAC;IAED,mCAAY,GAAZ;QACQ,IAAA,KAAoC,IAAI,CAAC,UAAU,EAAjD,YAAQ,EAAR,IAAI,mBAAG,CAAC,KAAA,EAAE,YAAQ,EAAR,IAAI,mBAAG,CAAC,KAAA,EAAE,SAAS,eAAoB,CAAA;QACzD,IAAM,KAAK,GAAG,gBAAK,CAAC,YAAY,WAAE,CAAA;QAElC,6BAA6B;QAC7B,sCACK,KAAK,GACL,CAAC,IAAA,qBAAS,EAAC,SAAS,CAAC,IAAI,EAAE,CAAC,KAC/B,SAAS,EAAE,yBAAkB,IAAI,cAAI,IAAI,MAAG,IAC7C;IACH,CAAC;IAED,mCAAY,GAAZ;QACE,IAAM,KAAK,GAAG,gBAAK,CAAC,YAAY,WAAE,CAAA;QAEhC,IAAO,eAAe,GAEpB,IAAI,CAAC,UAAU,MAFK,CAEL;QAEnB,6BACK,KAAK,GACL,CAAC,IAAA,qBAAS,EAAC,eAAe,CAAC,IAAI,EAAE,CAAC,EAGtC;IACH,CAAC;IACH,mBAAC;AAAD,CAAC,AA3CD,CAEU,oBAAa,GAyCtB;AA3CY,oCAAY;AA6CzB,kBAAe,YAAY,CAAA"}
package/lib/registry.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import LogicFlow from '@logicflow/core';
2
- import RegisterConfig = LogicFlow.RegisterConfig;
3
- export type VueNodeConfig = {
4
- type: string;
5
- component: any;
6
- effect?: (keyof LogicFlow.PropertiesType)[];
7
- } & Partial<RegisterConfig>;
8
- export declare const vueNodesMap: Record<string, {
9
- component: any;
10
- effect?: (keyof LogicFlow.PropertiesType)[];
11
- }>;
12
- export declare function register(config: VueNodeConfig, lf: LogicFlow): void;
package/lib/registry.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = exports.vueNodesMap = void 0;
4
- var view_1 = require("./view");
5
- var model_1 = require("./model");
6
- exports.vueNodesMap = {};
7
- function register(config, lf) {
8
- var type = config.type, component = config.component, effect = config.effect, CustomNodeView = config.view, CustomNodeModel = config.model;
9
- if (!type) {
10
- throw new Error('You should specify type in config');
11
- }
12
- exports.vueNodesMap[type] = {
13
- component: component,
14
- effect: effect,
15
- };
16
- lf.register({
17
- type: type,
18
- view: CustomNodeView || view_1.VueNodeView,
19
- model: CustomNodeModel || model_1.VueNodeModel,
20
- });
21
- }
22
- exports.register = register;
23
- //# sourceMappingURL=registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";;;AACA,+BAAoC;AACpC,iCAAsC;AAUzB,QAAA,WAAW,GAMpB,EAAE,CAAA;AAEN,SAAgB,QAAQ,CAAC,MAAqB,EAAE,EAAa;IAEzD,IAAA,IAAI,GAKF,MAAM,KALJ,EACJ,SAAS,GAIP,MAAM,UAJC,EACT,MAAM,GAGJ,MAAM,OAHF,EACA,cAAc,GAElB,MAAM,KAFY,EACb,eAAe,GACpB,MAAM,MADc,CACd;IAEV,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IACtD,CAAC;IACD,mBAAW,CAAC,IAAI,CAAC,GAAG;QAClB,SAAS,WAAA;QACT,MAAM,QAAA;KACP,CAAA;IAED,EAAE,CAAC,QAAQ,CAAC;QACV,IAAI,MAAA;QACJ,IAAI,EAAE,cAAc,IAAI,kBAAW;QACnC,KAAK,EAAE,eAAe,IAAI,oBAAY;KACvC,CAAC,CAAA;AACJ,CAAC;AAtBD,4BAsBC"}
package/lib/teleport.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import { BaseNodeModel, GraphModel } from '@logicflow/core';
2
- export declare function connect(id: string, component: any, container: HTMLDivElement, node: BaseNodeModel, graph: GraphModel): void;
3
- export declare function disconnect(id: string, flowId: string): void;
4
- export declare function isActive(): boolean;
5
- export declare function getTeleport(): any;
6
- /**
7
- * 创建并挂载 Teleport 容器组件
8
- * @param container 目标容器元素
9
- * @param flowId 当前流程图的唯一标识
10
- */
11
- export declare function createTeleportContainer(container: HTMLElement, flowId: string | undefined): void;
12
- /**
13
- * 卸载 Teleport 容器组件
14
- * @param flowId 需要卸载流程图的唯一标识
15
- */
16
- export declare function destroyTeleportContainer(flowId: string | undefined): void;
package/lib/teleport.js DELETED
@@ -1,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.destroyTeleportContainer = exports.createTeleportContainer = exports.getTeleport = exports.isActive = exports.disconnect = exports.connect = void 0;
4
- var vue_demi_1 = require("vue-demi");
5
- var active = false;
6
- var appInstances = new Map();
7
- var appNodesMap = new Map(); // 用于储存当前流程图节点id当节点都销毁时同时卸载vueApp实例
8
- var items = (0, vue_demi_1.reactive)({});
9
- function connect(id, component, container, node, graph) {
10
- if (active) {
11
- if (graph.isMiniMap) {
12
- createTeleportContainer(container, graph.flowId);
13
- }
14
- items[id] = (0, vue_demi_1.markRaw)((0, vue_demi_1.defineComponent)({
15
- render: function () {
16
- return (0, vue_demi_1.h)(vue_demi_1.Teleport, { to: container }, [
17
- (0, vue_demi_1.h)(component, { node: node, graph: graph }),
18
- ]);
19
- },
20
- provide: function () { return ({
21
- getNode: function () { return node; },
22
- getGraph: function () { return graph; },
23
- }); },
24
- }));
25
- }
26
- }
27
- exports.connect = connect;
28
- function disconnect(id, flowId) {
29
- if (active) {
30
- delete items[id];
31
- if (appInstances.has(flowId)) {
32
- var appNodeList = appNodesMap.get(flowId) || [];
33
- var index = appNodeList.indexOf(id);
34
- if (index > -1) {
35
- appNodeList.splice(index, 1);
36
- if (appNodeList.length === 0) {
37
- destroyTeleportContainer(flowId);
38
- }
39
- else {
40
- appNodesMap.set(flowId, appNodeList);
41
- }
42
- }
43
- }
44
- }
45
- }
46
- exports.disconnect = disconnect;
47
- function isActive() {
48
- return active;
49
- }
50
- exports.isActive = isActive;
51
- function getTeleport() {
52
- if (!vue_demi_1.isVue3) {
53
- throw new Error('teleport is only available in Vue3');
54
- }
55
- active = true;
56
- return (0, vue_demi_1.defineComponent)({
57
- props: {
58
- flowId: {
59
- type: String,
60
- required: true,
61
- },
62
- },
63
- setup: function (props) {
64
- return function () {
65
- var children = [];
66
- Object.keys(items).forEach(function (id) {
67
- // https://github.com/didi/LogicFlow/issues/1768
68
- // 多个不同的VueNodeView都会connect注册到items中,因此items存储了可能有多个flowId流程图的数据
69
- // 当使用多个LogicFlow时,会创建多个flowId + 同时使用KeepAlive
70
- // 每一次items改变,会触发不同flowId持有的setup()执行,由于每次setup()执行就是遍历items,因此存在多次重复渲染元素的问题
71
- // 即items[0]会在Page1的setup()执行,items[0]也会在Page2的setup()执行,从而生成两个items[0]
72
- // 比对当前界面显示的flowId,只更新items[当前页面flowId:nodeId]的数据
73
- // 比如items[0]属于Page1的数据,那么Page2无论active=true/false,都无法执行items[0]
74
- if (id.startsWith(props.flowId)) {
75
- if (appInstances.has(props.flowId)) {
76
- var appNodeList = appNodesMap.get(props.flowId) || [];
77
- if (!appNodeList.includes(id)) {
78
- appNodeList.push(id);
79
- appNodesMap.set(props.flowId, appNodeList);
80
- }
81
- }
82
- children.push(items[id]);
83
- }
84
- });
85
- return (0, vue_demi_1.h)(vue_demi_1.Fragment, {}, children.map(function (item) { return (0, vue_demi_1.h)(item); }));
86
- };
87
- },
88
- });
89
- }
90
- exports.getTeleport = getTeleport;
91
- /**
92
- * 创建并挂载 Teleport 容器组件
93
- * @param container 目标容器元素
94
- * @param flowId 当前流程图的唯一标识
95
- */
96
- function createTeleportContainer(container, flowId) {
97
- if (!vue_demi_1.isVue3 || !flowId || !container || !active)
98
- return;
99
- // 获取 Teleport 组件
100
- var TeleportContainer = getTeleport();
101
- // 不重新创建 Teleport 容器组件
102
- if (appInstances.has(flowId)) {
103
- return;
104
- }
105
- // ✅ 1. 创建独立容器放到目标容器中
106
- var mountPoint = document.createElement('div');
107
- container.appendChild(mountPoint);
108
- // ✅ 2. 创建并挂载 Vue 应用到新容器
109
- var app = (0, vue_demi_1.createApp)(TeleportContainer, { flowId: flowId });
110
- app.mount(mountPoint);
111
- appInstances.set(flowId, app);
112
- appNodesMap.set(flowId, []);
113
- }
114
- exports.createTeleportContainer = createTeleportContainer;
115
- /**
116
- * 卸载 Teleport 容器组件
117
- * @param flowId 需要卸载流程图的唯一标识
118
- */
119
- function destroyTeleportContainer(flowId) {
120
- if (!vue_demi_1.isVue3 || !flowId || !active)
121
- return;
122
- var app = appInstances.get(flowId);
123
- if (app) {
124
- app.unmount();
125
- appInstances.delete(flowId);
126
- appNodesMap.delete(flowId);
127
- }
128
- }
129
- exports.destroyTeleportContainer = destroyTeleportContainer;
130
- //# sourceMappingURL=teleport.js.map
@@ -1 +0,0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AU,CAAC,CAAA;IAErB,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC7B,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAC7B,CAAC;AAxBD,0DAwBC;AACD;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,MAA0B;IACjE,IAAI,CAAC,iBAAM,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAM;IACzC,IAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACpC,IAAI,GAAG,EAAE,CAAC;QACR,GAAG,CAAC,OAAO,EAAE,CAAA;QACb,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAC3B,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC5B,CAAC;AACH,CAAC;AARD,4DAQC"}
package/lib/view.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { HtmlNode } from '@logicflow/core';
2
- export declare class VueNodeView extends HtmlNode {
3
- root?: any;
4
- private vm;
5
- getComponentContainer(): any;
6
- protected targetId(): string;
7
- componentWillUnmount(): void;
8
- setHtml(rootEl: SVGForeignObjectElement): void;
9
- confirmUpdate(_rootEl: SVGForeignObjectElement): void;
10
- protected renderVueComponent(): void;
11
- protected unmountVueComponent(): any;
12
- unmount(): void;
13
- }
14
- export default VueNodeView;
package/lib/view.js DELETED
@@ -1,123 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.VueNodeView = void 0;
19
- var vue_demi_1 = require("vue-demi");
20
- var core_1 = require("@logicflow/core");
21
- var registry_1 = require("./registry");
22
- var teleport_1 = require("./teleport");
23
- var VueNodeView = /** @class */ (function (_super) {
24
- __extends(VueNodeView, _super);
25
- function VueNodeView() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- VueNodeView.prototype.getComponentContainer = function () {
29
- return this.root;
30
- };
31
- VueNodeView.prototype.targetId = function () {
32
- return "".concat(this.props.graphModel.flowId, ":").concat(this.props.model.id);
33
- };
34
- VueNodeView.prototype.componentWillUnmount = function () {
35
- _super.prototype.componentWillUnmount.call(this);
36
- this.unmount();
37
- };
38
- VueNodeView.prototype.setHtml = function (rootEl) {
39
- var el = document.createElement('div');
40
- el.className = 'custom-vue-node-content';
41
- this.root = el;
42
- rootEl.appendChild(el);
43
- this.renderVueComponent();
44
- };
45
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
- VueNodeView.prototype.confirmUpdate = function (_rootEl) {
47
- // TODO: 如有需要,可以先通过继承的方式,自定义该节点的更新逻辑;我们后续会根据实际需求,丰富该功能
48
- // console.log('_rootEl', _rootEl)
49
- };
50
- VueNodeView.prototype.renderVueComponent = function () {
51
- var _a;
52
- this.unmountVueComponent();
53
- var root = this.getComponentContainer();
54
- var _b = this.props, model = _b.model, graphModel = _b.graphModel;
55
- if (root) {
56
- var component_1 = registry_1.vueNodesMap[model.type].component;
57
- if (component_1) {
58
- if (vue_demi_1.isVue2) {
59
- var Vue = vue_demi_1.Vue2;
60
- this.vm = new Vue({
61
- el: root,
62
- render: function (h) {
63
- return h(component_1, {
64
- node: model,
65
- graph: graphModel,
66
- });
67
- },
68
- provide: function () {
69
- return {
70
- getNode: function () { return model; },
71
- getGraph: function () { return graphModel; },
72
- };
73
- },
74
- });
75
- }
76
- else if (vue_demi_1.isVue3) {
77
- if ((0, teleport_1.isActive)()) {
78
- (0, teleport_1.connect)(this.targetId(), component_1, root, model, graphModel);
79
- }
80
- else {
81
- this.vm = (0, vue_demi_1.createApp)({
82
- render: function () {
83
- return (0, vue_demi_1.h)(component_1, {
84
- node: model,
85
- graph: graphModel,
86
- });
87
- },
88
- provide: function () {
89
- return {
90
- getNode: function () { return model; },
91
- getGraph: function () { return graphModel; },
92
- };
93
- },
94
- });
95
- (_a = this.vm) === null || _a === void 0 ? void 0 : _a.mount(root);
96
- }
97
- }
98
- }
99
- }
100
- };
101
- VueNodeView.prototype.unmountVueComponent = function () {
102
- var root = this.getComponentContainer();
103
- if (this.vm) {
104
- vue_demi_1.isVue2 && this.vm.$destroy();
105
- vue_demi_1.isVue3 && this.vm.unmount();
106
- this.vm = null;
107
- }
108
- if (root && !(0, teleport_1.isActive)()) {
109
- root.innerHTML = '';
110
- }
111
- return root;
112
- };
113
- VueNodeView.prototype.unmount = function () {
114
- if ((0, teleport_1.isActive)()) {
115
- (0, teleport_1.disconnect)(this.targetId(), this.props.graphModel.flowId);
116
- }
117
- this.unmountVueComponent();
118
- };
119
- return VueNodeView;
120
- }(core_1.HtmlNode));
121
- exports.VueNodeView = VueNodeView;
122
- exports.default = VueNodeView;
123
- //# sourceMappingURL=view.js.map
package/lib/view.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"view.js","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,qCAA6D;AAC7D,wCAA0C;AAC1C,uCAAwC;AACxC,uCAA0D;AAE1D;IAAiC,+BAAQ;IAAzC;;IAqGA,CAAC;IAjGC,2CAAqB,GAArB;QACE,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAES,8BAAQ,GAAlB;QACE,OAAO,UAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,cAAI,IAAI,CAAC,KAAK,CAAC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