Procházet zdrojové kódy

Merge pull request #4 from sanmaopep/chore/variable-api

chore: add variable api
YiWei Mao před 10 měsíci
rodič
revize
e454ce2154
48 změnil soubory, kde provedl 234 přidání a 26 odebrání
  1. 2 0
      packages/canvas-engine/core/package.json
  2. 2 1
      packages/canvas-engine/document/package.json
  3. 2 0
      packages/canvas-engine/fixed-layout-core/package.json
  4. 2 0
      packages/canvas-engine/free-layout-core/package.json
  5. 0 1
      packages/canvas-engine/free-layout-core/vitest.config.ts
  6. 2 0
      packages/canvas-engine/renderer/package.json
  7. 2 0
      packages/client/editor/package.json
  8. 2 0
      packages/client/fixed-layout-editor/package.json
  9. 2 0
      packages/client/free-layout-editor/package.json
  10. 2 0
      packages/client/playground-react/package.json
  11. 2 0
      packages/common/command/package.json
  12. 2 0
      packages/common/history-storage/package.json
  13. 2 0
      packages/common/history/package.json
  14. 2 0
      packages/common/i18n/package.json
  15. 2 0
      packages/common/reactive/package.json
  16. 2 0
      packages/common/utils/package.json
  17. 2 0
      packages/materials/fixed-semi-materials/package.json
  18. 2 1
      packages/node-engine/form-core/package.json
  19. 20 1
      packages/node-engine/form-core/src/form/services/form-manager.ts
  20. 2 1
      packages/node-engine/form/package.json
  21. 2 1
      packages/node-engine/node/package.json
  22. 2 0
      packages/plugins/background-plugin/package.json
  23. 2 0
      packages/plugins/fixed-drag-plugin/package.json
  24. 2 0
      packages/plugins/fixed-history-plugin/package.json
  25. 2 0
      packages/plugins/fixed-reactor-plugin/package.json
  26. 2 0
      packages/plugins/free-auto-layout-plugin/package.json
  27. 2 0
      packages/plugins/free-history-plugin/package.json
  28. 19 12
      packages/plugins/free-history-plugin/src/free-history-manager.ts
  29. 2 0
      packages/plugins/free-hover-plugin/package.json
  30. 3 1
      packages/plugins/free-lines-plugin/package.json
  31. 2 0
      packages/plugins/free-node-panel-plugin/package.json
  32. 2 0
      packages/plugins/free-snap-plugin/package.json
  33. 2 0
      packages/plugins/free-stack-plugin/package.json
  34. 2 0
      packages/plugins/group-plugin/package.json
  35. 2 0
      packages/plugins/history-node-plugin/package.json
  36. 2 0
      packages/plugins/i18n-plugin/package.json
  37. 2 0
      packages/plugins/materials-plugin/package.json
  38. 2 0
      packages/plugins/minimap-plugin/package.json
  39. 2 0
      packages/plugins/node-core-plugin/package.json
  40. 3 0
      packages/plugins/node-core-plugin/src/create-node-core-plugin.ts
  41. 2 0
      packages/plugins/node-variable-plugin/package.json
  42. 2 0
      packages/plugins/redux-devtool-plugin/package.json
  43. 2 0
      packages/plugins/select-box-plugin/package.json
  44. 2 0
      packages/plugins/shortcuts-plugin/package.json
  45. 2 0
      packages/plugins/variable-plugin/package.json
  46. 2 1
      packages/variable-engine/variable-core/package.json
  47. 2 0
      packages/variable-engine/variable-layout/package.json
  48. 105 6
      packages/variable-engine/variable-layout/src/flow-node-variable-data.ts

+ 2 - 0
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",

+ 2 - 1
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",

+ 2 - 0
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",

+ 2 - 0
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": {
     ".": {

+ 0 - 1
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',

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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": {
     ".": {

+ 2 - 0
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": {
     ".": {

+ 2 - 0
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": {
     ".": {

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 1
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",

+ 20 - 1
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<string, any> {
     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));

+ 2 - 1
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",

+ 2 - 1
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 19 - 12
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>(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 }
         );
       }),
     ]);

+ 2 - 0
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",

+ 3 - 1
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/"
   }
-}
+}

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 3 - 0
packages/plugins/node-core-plugin/src/create-node-core-plugin.ts

@@ -46,6 +46,9 @@ export const createNodeCorePlugin = definePluginCreator<NodeCorePluginOptions>({
 
     registerNodeMaterial({ nodeManager, formManager, material: options.materials! });
   },
+  onDispose(ctx) {
+    ctx.get<FormManager>(FormManager)?.dispose();
+  },
   containerModules: createNodeContainerModules(),
   // onBind: ({ bind }) => {
   //   bindContributions(bind, FormNodeContribution, [NodeContribution]);

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 0
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",

+ 2 - 1
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",

+ 2 - 0
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",

+ 105 - 6
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);