diff --git a/packages/canvas-engine/core/package.json b/packages/canvas-engine/core/package.json index 7bac7435..15cb0d38 100644 --- a/packages/canvas-engine/core/package.json +++ b/packages/canvas-engine/core/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/core", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/canvas-engine/document/package.json b/packages/canvas-engine/document/package.json index db0dfa31..8759f139 100644 --- a/packages/canvas-engine/document/package.json +++ b/packages/canvas-engine/document/package.json @@ -6,7 +6,8 @@ "flow", "engine" ], - "homepage": "", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/canvas-engine/fixed-layout-core/package.json b/packages/canvas-engine/fixed-layout-core/package.json index 64fd584b..c42afe5b 100644 --- a/packages/canvas-engine/fixed-layout-core/package.json +++ b/packages/canvas-engine/fixed-layout-core/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/fixed-layout-core", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/canvas-engine/free-layout-core/package.json b/packages/canvas-engine/free-layout-core/package.json index 5c6a25a8..bd71fdfe 100644 --- a/packages/canvas-engine/free-layout-core/package.json +++ b/packages/canvas-engine/free-layout-core/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-layout-core", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { ".": { diff --git a/packages/canvas-engine/free-layout-core/vitest.config.ts b/packages/canvas-engine/free-layout-core/vitest.config.ts index cff69775..97c9de9b 100644 --- a/packages/canvas-engine/free-layout-core/vitest.config.ts +++ b/packages/canvas-engine/free-layout-core/vitest.config.ts @@ -8,7 +8,6 @@ export default defineConfig({ }, }, test: { - testTimeout: 30000, globals: true, mockReset: false, environment: 'jsdom', diff --git a/packages/canvas-engine/renderer/package.json b/packages/canvas-engine/renderer/package.json index ed45f7b5..18403848 100644 --- a/packages/canvas-engine/renderer/package.json +++ b/packages/canvas-engine/renderer/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/renderer", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/client/editor/package.json b/packages/client/editor/package.json index 07ebb4bf..590c5d48 100644 --- a/packages/client/editor/package.json +++ b/packages/client/editor/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/editor", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/client/fixed-layout-editor/package.json b/packages/client/fixed-layout-editor/package.json index 014c2d21..ef9fc34c 100644 --- a/packages/client/fixed-layout-editor/package.json +++ b/packages/client/fixed-layout-editor/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/fixed-layout-editor", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { ".": { diff --git a/packages/client/free-layout-editor/package.json b/packages/client/free-layout-editor/package.json index 98911d8f..0de917b7 100644 --- a/packages/client/free-layout-editor/package.json +++ b/packages/client/free-layout-editor/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-layout-editor", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { ".": { diff --git a/packages/client/playground-react/package.json b/packages/client/playground-react/package.json index dd953eaf..5bee868e 100644 --- a/packages/client/playground-react/package.json +++ b/packages/client/playground-react/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/playground-react", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { ".": { diff --git a/packages/common/command/package.json b/packages/common/command/package.json index 1cf0ceef..7475b425 100644 --- a/packages/common/command/package.json +++ b/packages/common/command/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/command", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/common/history-storage/package.json b/packages/common/history-storage/package.json index b4f97f81..cd4ba0bd 100644 --- a/packages/common/history-storage/package.json +++ b/packages/common/history-storage/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/history-storage", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/common/history/package.json b/packages/common/history/package.json index e95a4ccf..dc3fff3c 100644 --- a/packages/common/history/package.json +++ b/packages/common/history/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/history", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/common/i18n/package.json b/packages/common/i18n/package.json index b5435199..c7364f36 100644 --- a/packages/common/i18n/package.json +++ b/packages/common/i18n/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/i18n", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/common/reactive/package.json b/packages/common/reactive/package.json index fb415a81..29640661 100644 --- a/packages/common/reactive/package.json +++ b/packages/common/reactive/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/reactive", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/common/utils/package.json b/packages/common/utils/package.json index 77782b62..4705b014 100644 --- a/packages/common/utils/package.json +++ b/packages/common/utils/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/utils", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/materials/fixed-semi-materials/package.json b/packages/materials/fixed-semi-materials/package.json index be03910f..6156c46b 100644 --- a/packages/materials/fixed-semi-materials/package.json +++ b/packages/materials/fixed-semi-materials/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/fixed-semi-materials", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/node-engine/form-core/package.json b/packages/node-engine/form-core/package.json index ec6fd911..3fe21dd9 100644 --- a/packages/node-engine/form-core/package.json +++ b/packages/node-engine/form-core/package.json @@ -6,7 +6,8 @@ "flow", "engine" ], - "homepage": "", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/node-engine/form-core/src/form/services/form-manager.ts b/packages/node-engine/form-core/src/form/services/form-manager.ts index 6788227c..617a1723 100644 --- a/packages/node-engine/form-core/src/form/services/form-manager.ts +++ b/packages/node-engine/form-core/src/form/services/form-manager.ts @@ -1,9 +1,10 @@ import { mapValues } from 'lodash'; import { inject, injectable, multiInject, optional, postConstruct } from 'inversify'; +import { Emitter } from '@flowgram.ai/utils'; import { injectPlaygroundContext, PlaygroundContext } from '@flowgram.ai/core'; import { AbilityClass, FormItemAbility } from '../models/form-item-ability'; -import { FormAbilityExtensionRegistry } from '../models'; +import { FormAbilityExtensionRegistry, FormModel } from '../models'; import { FormContribution } from '../form-contribution'; import { DecoratorAbility, @@ -30,6 +31,13 @@ export class FormManager { @multiInject(FormContribution) @optional() protected formContributions: FormContribution[] = []; + private readonly onFormModelWillInitEmitter = new Emitter<{ + model: FormModel; + data: any; + }>(); + + readonly onFormModelWillInit = this.onFormModelWillInitEmitter.event; + get components(): Record { return mapValues( this.extensionRegistryMap.get(SetterAbility.type)?.objectMap || {}, @@ -81,6 +89,17 @@ export class FormManager { this.setterHocs.push(hoc); } + fireFormModelWillInit(model: FormModel, data: any) { + this.onFormModelWillInitEmitter.fire({ + model, + data, + }); + } + + dispose() { + this.onFormModelWillInitEmitter.dispose(); + } + @postConstruct() protected init(): void { this.formContributions.forEach((contrib) => contrib.onRegister?.(this)); diff --git a/packages/node-engine/form/package.json b/packages/node-engine/form/package.json index 097ad91f..d44c3a9b 100644 --- a/packages/node-engine/form/package.json +++ b/packages/node-engine/form/package.json @@ -6,7 +6,8 @@ "flow", "engine" ], - "homepage": "", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/node-engine/node/package.json b/packages/node-engine/node/package.json index 6d99eda2..7ca7d701 100644 --- a/packages/node-engine/node/package.json +++ b/packages/node-engine/node/package.json @@ -6,7 +6,8 @@ "flow", "engine" ], - "homepage": "", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/background-plugin/package.json b/packages/plugins/background-plugin/package.json index e0668e2a..4e618d33 100644 --- a/packages/plugins/background-plugin/package.json +++ b/packages/plugins/background-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/background-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/fixed-drag-plugin/package.json b/packages/plugins/fixed-drag-plugin/package.json index 119b5b7e..1b943335 100644 --- a/packages/plugins/fixed-drag-plugin/package.json +++ b/packages/plugins/fixed-drag-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/fixed-drag-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/fixed-history-plugin/package.json b/packages/plugins/fixed-history-plugin/package.json index c843bcb5..accd2bc3 100644 --- a/packages/plugins/fixed-history-plugin/package.json +++ b/packages/plugins/fixed-history-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/fixed-history-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/fixed-reactor-plugin/package.json b/packages/plugins/fixed-reactor-plugin/package.json index 65accc00..45fa5d86 100644 --- a/packages/plugins/fixed-reactor-plugin/package.json +++ b/packages/plugins/fixed-reactor-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/fixed-reactor-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/free-auto-layout-plugin/package.json b/packages/plugins/free-auto-layout-plugin/package.json index c1635efb..70276c2c 100644 --- a/packages/plugins/free-auto-layout-plugin/package.json +++ b/packages/plugins/free-auto-layout-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-auto-layout-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "import": "./dist/esm/index.js", diff --git a/packages/plugins/free-history-plugin/package.json b/packages/plugins/free-history-plugin/package.json index 67b2018a..317bd693 100644 --- a/packages/plugins/free-history-plugin/package.json +++ b/packages/plugins/free-history-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-history-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/free-history-plugin/src/free-history-manager.ts b/packages/plugins/free-history-plugin/src/free-history-manager.ts index 4e0d8d66..a0ab8ffb 100644 --- a/packages/plugins/free-history-plugin/src/free-history-manager.ts +++ b/packages/plugins/free-history-plugin/src/free-history-manager.ts @@ -1,15 +1,16 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { cloneDeep } from 'lodash'; import { injectable, inject } from 'inversify'; -import { FlowNodeFormData } from '@flowgram.ai/form-core'; -import { type PluginContext, PositionData } from '@flowgram.ai/core'; +import { DisposableCollection } from '@flowgram.ai/utils'; +import { HistoryService } from '@flowgram.ai/history'; import { WorkflowDocument, WorkflowResetLayoutService, WorkflowDragService, } from '@flowgram.ai/free-layout-core'; -import { DisposableCollection } from '@flowgram.ai/utils'; -import { HistoryService } from '@flowgram.ai/history'; +import { FlowNodeFormData } from '@flowgram.ai/form-core'; +import { FormManager } from '@flowgram.ai/form-core'; +import { type PluginContext, PositionData } from '@flowgram.ai/core'; import { type FreeHistoryPluginOptions, FreeOperationType } from './types'; import { HistoryEntityManager } from './history-entity-manager'; @@ -34,6 +35,9 @@ export class FreeHistoryManager { @inject(HistoryEntityManager) private _entityManager: HistoryEntityManager; + @inject(FormManager) + private _formManager: FormManager; + private _toDispose: DisposableCollection = new DisposableCollection(); onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) { @@ -49,7 +53,7 @@ export class FreeHistoryManager { historyService.context.source = ctx; this._toDispose.pushAll([ - dragService.onNodesDrag(async event => { + dragService.onNodesDrag(async (event) => { if (event.type !== 'onDragEnd') { return; } @@ -60,28 +64,31 @@ export class FreeHistoryManager { if (positionData) { this._entityManager.addEntityData(positionData); } + }), + this._formManager.onFormModelWillInit(({ model, data }) => { + const node = model.flowNodeEntity; const formData = node.getData(FlowNodeFormData); if (formData) { - this._entityManager.setValue(formData, cloneDeep(data.data)); + this._entityManager.setValue(formData, cloneDeep(data)); this._toDispose.push( - formData.onDetailChange(event => { + formData.onDetailChange((event) => { this._changeNodeDataHandler.handle({ ...event, node, }); - }), + }) ); } }), - document.onContentChange(async event => { + document.onContentChange(async (event) => { await this._changeContentHandler.handle(event, ctx); }), - document.onReload(_event => { + document.onReload((_event) => { historyService.clear(); }), - resetLayoutService.onResetLayout(event => { + resetLayoutService.onResetLayout((event) => { historyService.pushOperation( { type: FreeOperationType.resetLayout, @@ -91,7 +98,7 @@ export class FreeHistoryManager { oldValue: event.oldPositionMap, }, }, - { noApply: true }, + { noApply: true } ); }), ]); diff --git a/packages/plugins/free-hover-plugin/package.json b/packages/plugins/free-hover-plugin/package.json index 2acf9ecd..94392a5d 100644 --- a/packages/plugins/free-hover-plugin/package.json +++ b/packages/plugins/free-hover-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-hover-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/free-lines-plugin/package.json b/packages/plugins/free-lines-plugin/package.json index 7c085a34..5969fe88 100644 --- a/packages/plugins/free-lines-plugin/package.json +++ b/packages/plugins/free-lines-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-lines-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", @@ -59,4 +61,4 @@ "access": "public", "registry": "https://registry.npmjs.org/" } -} +} \ No newline at end of file diff --git a/packages/plugins/free-node-panel-plugin/package.json b/packages/plugins/free-node-panel-plugin/package.json index dc9259e3..e983aaeb 100644 --- a/packages/plugins/free-node-panel-plugin/package.json +++ b/packages/plugins/free-node-panel-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-node-panel-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "import": "./dist/esm/index.js", diff --git a/packages/plugins/free-snap-plugin/package.json b/packages/plugins/free-snap-plugin/package.json index 2e74ceba..fb6e0761 100644 --- a/packages/plugins/free-snap-plugin/package.json +++ b/packages/plugins/free-snap-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-snap-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "import": "./dist/esm/index.js", diff --git a/packages/plugins/free-stack-plugin/package.json b/packages/plugins/free-stack-plugin/package.json index 8411d318..46083602 100644 --- a/packages/plugins/free-stack-plugin/package.json +++ b/packages/plugins/free-stack-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/free-stack-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "import": "./dist/esm/index.js", diff --git a/packages/plugins/group-plugin/package.json b/packages/plugins/group-plugin/package.json index ddaeb097..cef5cdc3 100644 --- a/packages/plugins/group-plugin/package.json +++ b/packages/plugins/group-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/group-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/history-node-plugin/package.json b/packages/plugins/history-node-plugin/package.json index b6895fa4..dd61da9d 100644 --- a/packages/plugins/history-node-plugin/package.json +++ b/packages/plugins/history-node-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/history-node-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/i18n-plugin/package.json b/packages/plugins/i18n-plugin/package.json index fe32f363..6102887a 100644 --- a/packages/plugins/i18n-plugin/package.json +++ b/packages/plugins/i18n-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/i18n-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/materials-plugin/package.json b/packages/plugins/materials-plugin/package.json index 031acf0f..f4b83696 100644 --- a/packages/plugins/materials-plugin/package.json +++ b/packages/plugins/materials-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/materials-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/minimap-plugin/package.json b/packages/plugins/minimap-plugin/package.json index 5bb302e2..0ebbbd58 100644 --- a/packages/plugins/minimap-plugin/package.json +++ b/packages/plugins/minimap-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/minimap-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "import": "./dist/esm/index.js", diff --git a/packages/plugins/node-core-plugin/package.json b/packages/plugins/node-core-plugin/package.json index 6c137cd8..359f729b 100644 --- a/packages/plugins/node-core-plugin/package.json +++ b/packages/plugins/node-core-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/node-core-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/node-core-plugin/src/create-node-core-plugin.ts b/packages/plugins/node-core-plugin/src/create-node-core-plugin.ts index 4c0f56eb..8a1a405f 100644 --- a/packages/plugins/node-core-plugin/src/create-node-core-plugin.ts +++ b/packages/plugins/node-core-plugin/src/create-node-core-plugin.ts @@ -46,6 +46,9 @@ export const createNodeCorePlugin = definePluginCreator({ registerNodeMaterial({ nodeManager, formManager, material: options.materials! }); }, + onDispose(ctx) { + ctx.get(FormManager)?.dispose(); + }, containerModules: createNodeContainerModules(), // onBind: ({ bind }) => { // bindContributions(bind, FormNodeContribution, [NodeContribution]); diff --git a/packages/plugins/node-variable-plugin/package.json b/packages/plugins/node-variable-plugin/package.json index 46040bf6..cbc7f90b 100644 --- a/packages/plugins/node-variable-plugin/package.json +++ b/packages/plugins/node-variable-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/node-variable-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/redux-devtool-plugin/package.json b/packages/plugins/redux-devtool-plugin/package.json index 3169c389..046914d8 100644 --- a/packages/plugins/redux-devtool-plugin/package.json +++ b/packages/plugins/redux-devtool-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/redux-devtool-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/select-box-plugin/package.json b/packages/plugins/select-box-plugin/package.json index 1a6075d9..1a3a9135 100644 --- a/packages/plugins/select-box-plugin/package.json +++ b/packages/plugins/select-box-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/select-box-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/shortcuts-plugin/package.json b/packages/plugins/shortcuts-plugin/package.json index c618e65c..a376811c 100644 --- a/packages/plugins/shortcuts-plugin/package.json +++ b/packages/plugins/shortcuts-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/shortcuts-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/plugins/variable-plugin/package.json b/packages/plugins/variable-plugin/package.json index 227eae96..55e6bf5b 100644 --- a/packages/plugins/variable-plugin/package.json +++ b/packages/plugins/variable-plugin/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/variable-plugin", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/variable-engine/variable-core/package.json b/packages/variable-engine/variable-core/package.json index 9cd4280f..d442242c 100644 --- a/packages/variable-engine/variable-core/package.json +++ b/packages/variable-engine/variable-core/package.json @@ -8,7 +8,8 @@ "scope", "engine" ], - "homepage": "", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/variable-engine/variable-layout/package.json b/packages/variable-engine/variable-layout/package.json index 87988dae..c97e79a0 100644 --- a/packages/variable-engine/variable-layout/package.json +++ b/packages/variable-engine/variable-layout/package.json @@ -1,6 +1,8 @@ { "name": "@flowgram.ai/variable-layout", "version": "0.1.0", + "homepage": "https://coze-dev.github.io/flowgram.ai/", + "repository": "https://github.com/coze-dev/flowgram.ai", "license": "MIT", "exports": { "types": "./dist/index.d.ts", diff --git a/packages/variable-engine/variable-layout/src/flow-node-variable-data.ts b/packages/variable-engine/variable-layout/src/flow-node-variable-data.ts index e717dbaf..493a4675 100644 --- a/packages/variable-engine/variable-layout/src/flow-node-variable-data.ts +++ b/packages/variable-engine/variable-layout/src/flow-node-variable-data.ts @@ -1,4 +1,5 @@ import { VariableEngine } from '@flowgram.ai/variable-core'; +import { type ASTNode, ASTNodeJSON } from '@flowgram.ai/variable-core'; import { FlowNodeEntity } from '@flowgram.ai/document'; import { EntityData } from '@flowgram.ai/core'; @@ -16,7 +17,7 @@ export class FlowNodeVariableData extends EntityData { readonly variableEngine: VariableEngine; /** - * private 的变量可以被 public 所访问,反之则不行 + * Private variables can be accessed by public ones, but not the other way around. */ protected _private?: FlowNodeScope; @@ -30,6 +31,104 @@ export class FlowNodeVariableData extends EntityData { return this._public; } + /** + * Sets a variable in the public AST (Abstract Syntax Tree) with the given key and JSON value. + * + * @param key - The key under which the variable will be stored. + * @param json - The JSON value to store. + * @returns The updated AST node. + */ + public setVar(key: string, json: ASTNodeJSON): ASTNode; + + /** + * Sets a variable in the public AST (Abstract Syntax Tree) with the default key 'outputs'. + * + * @param json - The JSON value to store. + * @returns The updated AST node. + */ + public setVar(json: ASTNodeJSON): ASTNode; + + public setVar(arg1: string | ASTNodeJSON, arg2?: ASTNodeJSON): ASTNode { + if (typeof arg1 === 'string' && arg2 !== undefined) { + return this.public.ast.set(arg1, arg2); + } + + if (typeof arg1 === 'object' && arg2 === undefined) { + return this.public.ast.set('outputs', arg1); + } + + throw new Error('Invalid arguments'); + } + + /** + * Retrieves a variable from the public AST (Abstract Syntax Tree) by key. + * + * @param key - The key of the variable to retrieve. Defaults to 'outputs'. + * @returns The value of the variable, or undefined if not found. + */ + public getVar(key: string = 'outputs') { + return this.public.ast.get(key); + } + + /** + * Clears a variable from the public AST (Abstract Syntax Tree) by key. + * + * @param key - The key of the variable to clear. Defaults to 'outputs'. + * @returns The updated AST node. + */ + public clearVar(key: string = 'outputs') { + return this.public.ast.remove(key); + } + + /** + * Sets a variable in the private AST (Abstract Syntax Tree) with the given key and JSON value. + * + * @param key - The key under which the variable will be stored. + * @param json - The JSON value to store. + * @returns The updated AST node. + */ + public setPrivateVar(key: string, json: ASTNodeJSON): ASTNode; + + /** + * Sets a variable in the private AST (Abstract Syntax Tree) with the default key 'outputs'. + * + * @param json - The JSON value to store. + * @returns The updated AST node. + */ + public setPrivateVar(json: ASTNodeJSON): ASTNode; + + public setPrivateVar(arg1: string | ASTNodeJSON, arg2?: ASTNodeJSON): ASTNode { + if (typeof arg1 === 'string' && arg2 !== undefined) { + return this.initPrivate().ast.set(arg1, arg2); + } + + if (typeof arg1 === 'object' && arg2 === undefined) { + return this.initPrivate().ast.set('outputs', arg1); + } + + throw new Error('Invalid arguments'); + } + + /** + * Retrieves a variable from the private AST (Abstract Syntax Tree) by key. + * + * @param key - The key of the variable to retrieve. Defaults to 'outputs'. + * @returns The value of the variable, or undefined if not found. + */ + public getPrivateVar(key: string = 'outputs') { + return this.private?.ast.get(key); + } + + /** + * Clears a variable from the private AST (Abstract Syntax Tree) by key. + * + * @param key - The key of the variable to clear. Defaults to 'outputs'. + * @returns The updated AST node. + */ + public clearPrivateVar(key: string = 'outputs') { + return this.private?.ast.remove(key); + } + get allScopes(): FlowNodeScope[] { const res = []; @@ -65,15 +164,15 @@ export class FlowNodeVariableData extends EntityData { node: this.entity, type: FlowNodeScopeTypeEnum.private, } as FlowNodeScopeMeta); - // 1. 通知 private 的覆盖作用域更新依赖 - this._private.coverScopes.forEach(_scope => { + // 1. Notify the covering scopes of private to update dependencies + this._private.coverScopes.forEach((_scope) => { _scope.refreshDeps(); }); - // 2. 通知 private 的依赖作用域更新覆盖 - this._private.depScopes.forEach(_scope => { + // 2. Notify the dependent scopes of private to update their covers + this._private.depScopes.forEach((_scope) => { _scope.refreshCovers(); }); - // 3. private 自身需要刷新依赖 + // 3. The private scope itself needs to refresh its dependencies this._private.available.refresh(); this.toDispose.push(this._private);