mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
chore: add variable api
This commit is contained in:
parent
613351c770
commit
1b2c0ea06e
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/core",
|
"name": "@flowgram.ai/core",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
"flow",
|
"flow",
|
||||||
"engine"
|
"engine"
|
||||||
],
|
],
|
||||||
"homepage": "",
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/fixed-layout-core",
|
"name": "@flowgram.ai/fixed-layout-core",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-layout-core",
|
"name": "@flowgram.ai/free-layout-core",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
|||||||
@ -8,7 +8,6 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
testTimeout: 30000,
|
|
||||||
globals: true,
|
globals: true,
|
||||||
mockReset: false,
|
mockReset: false,
|
||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/renderer",
|
"name": "@flowgram.ai/renderer",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/editor",
|
"name": "@flowgram.ai/editor",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/fixed-layout-editor",
|
"name": "@flowgram.ai/fixed-layout-editor",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-layout-editor",
|
"name": "@flowgram.ai/free-layout-editor",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/playground-react",
|
"name": "@flowgram.ai/playground-react",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/command",
|
"name": "@flowgram.ai/command",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/history-storage",
|
"name": "@flowgram.ai/history-storage",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/history",
|
"name": "@flowgram.ai/history",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/i18n",
|
"name": "@flowgram.ai/i18n",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/reactive",
|
"name": "@flowgram.ai/reactive",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/utils",
|
"name": "@flowgram.ai/utils",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/fixed-semi-materials",
|
"name": "@flowgram.ai/fixed-semi-materials",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
"flow",
|
"flow",
|
||||||
"engine"
|
"engine"
|
||||||
],
|
],
|
||||||
"homepage": "",
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import { mapValues } from 'lodash';
|
import { mapValues } from 'lodash';
|
||||||
import { inject, injectable, multiInject, optional, postConstruct } from 'inversify';
|
import { inject, injectable, multiInject, optional, postConstruct } from 'inversify';
|
||||||
|
import { Emitter } from '@flowgram.ai/utils';
|
||||||
import { injectPlaygroundContext, PlaygroundContext } from '@flowgram.ai/core';
|
import { injectPlaygroundContext, PlaygroundContext } from '@flowgram.ai/core';
|
||||||
|
|
||||||
import { AbilityClass, FormItemAbility } from '../models/form-item-ability';
|
import { AbilityClass, FormItemAbility } from '../models/form-item-ability';
|
||||||
import { FormAbilityExtensionRegistry } from '../models';
|
import { FormAbilityExtensionRegistry, FormModel } from '../models';
|
||||||
import { FormContribution } from '../form-contribution';
|
import { FormContribution } from '../form-contribution';
|
||||||
import {
|
import {
|
||||||
DecoratorAbility,
|
DecoratorAbility,
|
||||||
@ -30,6 +31,13 @@ export class FormManager {
|
|||||||
|
|
||||||
@multiInject(FormContribution) @optional() protected formContributions: FormContribution[] = [];
|
@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> {
|
get components(): Record<string, any> {
|
||||||
return mapValues(
|
return mapValues(
|
||||||
this.extensionRegistryMap.get(SetterAbility.type)?.objectMap || {},
|
this.extensionRegistryMap.get(SetterAbility.type)?.objectMap || {},
|
||||||
@ -81,6 +89,17 @@ export class FormManager {
|
|||||||
this.setterHocs.push(hoc);
|
this.setterHocs.push(hoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fireFormModelWillInit(model: FormModel, data: any) {
|
||||||
|
this.onFormModelWillInitEmitter.fire({
|
||||||
|
model,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
this.onFormModelWillInitEmitter.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@postConstruct()
|
@postConstruct()
|
||||||
protected init(): void {
|
protected init(): void {
|
||||||
this.formContributions.forEach((contrib) => contrib.onRegister?.(this));
|
this.formContributions.forEach((contrib) => contrib.onRegister?.(this));
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
"flow",
|
"flow",
|
||||||
"engine"
|
"engine"
|
||||||
],
|
],
|
||||||
"homepage": "",
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
"flow",
|
"flow",
|
||||||
"engine"
|
"engine"
|
||||||
],
|
],
|
||||||
"homepage": "",
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/background-plugin",
|
"name": "@flowgram.ai/background-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/fixed-drag-plugin",
|
"name": "@flowgram.ai/fixed-drag-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/fixed-history-plugin",
|
"name": "@flowgram.ai/fixed-history-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/fixed-reactor-plugin",
|
"name": "@flowgram.ai/fixed-reactor-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-auto-layout-plugin",
|
"name": "@flowgram.ai/free-auto-layout-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/esm/index.js",
|
"import": "./dist/esm/index.js",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-history-plugin",
|
"name": "@flowgram.ai/free-history-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
import { injectable, inject } from 'inversify';
|
import { injectable, inject } from 'inversify';
|
||||||
import { FlowNodeFormData } from '@flowgram.ai/form-core';
|
import { DisposableCollection } from '@flowgram.ai/utils';
|
||||||
import { type PluginContext, PositionData } from '@flowgram.ai/core';
|
import { HistoryService } from '@flowgram.ai/history';
|
||||||
import {
|
import {
|
||||||
WorkflowDocument,
|
WorkflowDocument,
|
||||||
WorkflowResetLayoutService,
|
WorkflowResetLayoutService,
|
||||||
WorkflowDragService,
|
WorkflowDragService,
|
||||||
} from '@flowgram.ai/free-layout-core';
|
} from '@flowgram.ai/free-layout-core';
|
||||||
import { DisposableCollection } from '@flowgram.ai/utils';
|
import { FlowNodeFormData } from '@flowgram.ai/form-core';
|
||||||
import { HistoryService } from '@flowgram.ai/history';
|
import { FormManager } from '@flowgram.ai/form-core';
|
||||||
|
import { type PluginContext, PositionData } from '@flowgram.ai/core';
|
||||||
|
|
||||||
import { type FreeHistoryPluginOptions, FreeOperationType } from './types';
|
import { type FreeHistoryPluginOptions, FreeOperationType } from './types';
|
||||||
import { HistoryEntityManager } from './history-entity-manager';
|
import { HistoryEntityManager } from './history-entity-manager';
|
||||||
@ -34,6 +35,9 @@ export class FreeHistoryManager {
|
|||||||
@inject(HistoryEntityManager)
|
@inject(HistoryEntityManager)
|
||||||
private _entityManager: HistoryEntityManager;
|
private _entityManager: HistoryEntityManager;
|
||||||
|
|
||||||
|
@inject(FormManager)
|
||||||
|
private _formManager: FormManager;
|
||||||
|
|
||||||
private _toDispose: DisposableCollection = new DisposableCollection();
|
private _toDispose: DisposableCollection = new DisposableCollection();
|
||||||
|
|
||||||
onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {
|
onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {
|
||||||
@ -49,7 +53,7 @@ export class FreeHistoryManager {
|
|||||||
historyService.context.source = ctx;
|
historyService.context.source = ctx;
|
||||||
|
|
||||||
this._toDispose.pushAll([
|
this._toDispose.pushAll([
|
||||||
dragService.onNodesDrag(async event => {
|
dragService.onNodesDrag(async (event) => {
|
||||||
if (event.type !== 'onDragEnd') {
|
if (event.type !== 'onDragEnd') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -60,28 +64,31 @@ export class FreeHistoryManager {
|
|||||||
if (positionData) {
|
if (positionData) {
|
||||||
this._entityManager.addEntityData(positionData);
|
this._entityManager.addEntityData(positionData);
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
|
this._formManager.onFormModelWillInit(({ model, data }) => {
|
||||||
|
const node = model.flowNodeEntity;
|
||||||
const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);
|
const formData = node.getData<FlowNodeFormData>(FlowNodeFormData);
|
||||||
|
|
||||||
if (formData) {
|
if (formData) {
|
||||||
this._entityManager.setValue(formData, cloneDeep(data.data));
|
this._entityManager.setValue(formData, cloneDeep(data));
|
||||||
|
|
||||||
this._toDispose.push(
|
this._toDispose.push(
|
||||||
formData.onDetailChange(event => {
|
formData.onDetailChange((event) => {
|
||||||
this._changeNodeDataHandler.handle({
|
this._changeNodeDataHandler.handle({
|
||||||
...event,
|
...event,
|
||||||
node,
|
node,
|
||||||
});
|
});
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
document.onContentChange(async event => {
|
document.onContentChange(async (event) => {
|
||||||
await this._changeContentHandler.handle(event, ctx);
|
await this._changeContentHandler.handle(event, ctx);
|
||||||
}),
|
}),
|
||||||
document.onReload(_event => {
|
document.onReload((_event) => {
|
||||||
historyService.clear();
|
historyService.clear();
|
||||||
}),
|
}),
|
||||||
resetLayoutService.onResetLayout(event => {
|
resetLayoutService.onResetLayout((event) => {
|
||||||
historyService.pushOperation(
|
historyService.pushOperation(
|
||||||
{
|
{
|
||||||
type: FreeOperationType.resetLayout,
|
type: FreeOperationType.resetLayout,
|
||||||
@ -91,7 +98,7 @@ export class FreeHistoryManager {
|
|||||||
oldValue: event.oldPositionMap,
|
oldValue: event.oldPositionMap,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ noApply: true },
|
{ noApply: true }
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-hover-plugin",
|
"name": "@flowgram.ai/free-hover-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-lines-plugin",
|
"name": "@flowgram.ai/free-lines-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
@ -59,4 +61,4 @@
|
|||||||
"access": "public",
|
"access": "public",
|
||||||
"registry": "https://registry.npmjs.org/"
|
"registry": "https://registry.npmjs.org/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-node-panel-plugin",
|
"name": "@flowgram.ai/free-node-panel-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/esm/index.js",
|
"import": "./dist/esm/index.js",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-snap-plugin",
|
"name": "@flowgram.ai/free-snap-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/esm/index.js",
|
"import": "./dist/esm/index.js",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/free-stack-plugin",
|
"name": "@flowgram.ai/free-stack-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/esm/index.js",
|
"import": "./dist/esm/index.js",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/group-plugin",
|
"name": "@flowgram.ai/group-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/history-node-plugin",
|
"name": "@flowgram.ai/history-node-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/i18n-plugin",
|
"name": "@flowgram.ai/i18n-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/materials-plugin",
|
"name": "@flowgram.ai/materials-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/minimap-plugin",
|
"name": "@flowgram.ai/minimap-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"import": "./dist/esm/index.js",
|
"import": "./dist/esm/index.js",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/node-core-plugin",
|
"name": "@flowgram.ai/node-core-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -46,6 +46,9 @@ export const createNodeCorePlugin = definePluginCreator<NodeCorePluginOptions>({
|
|||||||
|
|
||||||
registerNodeMaterial({ nodeManager, formManager, material: options.materials! });
|
registerNodeMaterial({ nodeManager, formManager, material: options.materials! });
|
||||||
},
|
},
|
||||||
|
onDispose(ctx) {
|
||||||
|
ctx.get<FormManager>(FormManager)?.dispose();
|
||||||
|
},
|
||||||
containerModules: createNodeContainerModules(),
|
containerModules: createNodeContainerModules(),
|
||||||
// onBind: ({ bind }) => {
|
// onBind: ({ bind }) => {
|
||||||
// bindContributions(bind, FormNodeContribution, [NodeContribution]);
|
// bindContributions(bind, FormNodeContribution, [NodeContribution]);
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/node-variable-plugin",
|
"name": "@flowgram.ai/node-variable-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/redux-devtool-plugin",
|
"name": "@flowgram.ai/redux-devtool-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/select-box-plugin",
|
"name": "@flowgram.ai/select-box-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/shortcuts-plugin",
|
"name": "@flowgram.ai/shortcuts-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/variable-plugin",
|
"name": "@flowgram.ai/variable-plugin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -8,7 +8,8 @@
|
|||||||
"scope",
|
"scope",
|
||||||
"engine"
|
"engine"
|
||||||
],
|
],
|
||||||
"homepage": "",
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@flowgram.ai/variable-layout",
|
"name": "@flowgram.ai/variable-layout",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
"homepage": "https://coze-dev.github.io/flowgram.ai/",
|
||||||
|
"repository": "https://github.com/coze-dev/flowgram.ai",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { VariableEngine } from '@flowgram.ai/variable-core';
|
import { VariableEngine } from '@flowgram.ai/variable-core';
|
||||||
|
import { type ASTNode, ASTNodeJSON } from '@flowgram.ai/variable-core';
|
||||||
import { FlowNodeEntity } from '@flowgram.ai/document';
|
import { FlowNodeEntity } from '@flowgram.ai/document';
|
||||||
import { EntityData } from '@flowgram.ai/core';
|
import { EntityData } from '@flowgram.ai/core';
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ export class FlowNodeVariableData extends EntityData {
|
|||||||
readonly variableEngine: VariableEngine;
|
readonly variableEngine: VariableEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* private 的变量可以被 public 所访问,反之则不行
|
* Private variables can be accessed by public ones, but not the other way around.
|
||||||
*/
|
*/
|
||||||
protected _private?: FlowNodeScope;
|
protected _private?: FlowNodeScope;
|
||||||
|
|
||||||
@ -30,6 +31,104 @@ export class FlowNodeVariableData extends EntityData {
|
|||||||
return this._public;
|
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[] {
|
get allScopes(): FlowNodeScope[] {
|
||||||
const res = [];
|
const res = [];
|
||||||
|
|
||||||
@ -65,15 +164,15 @@ export class FlowNodeVariableData extends EntityData {
|
|||||||
node: this.entity,
|
node: this.entity,
|
||||||
type: FlowNodeScopeTypeEnum.private,
|
type: FlowNodeScopeTypeEnum.private,
|
||||||
} as FlowNodeScopeMeta);
|
} as FlowNodeScopeMeta);
|
||||||
// 1. 通知 private 的覆盖作用域更新依赖
|
// 1. Notify the covering scopes of private to update dependencies
|
||||||
this._private.coverScopes.forEach(_scope => {
|
this._private.coverScopes.forEach((_scope) => {
|
||||||
_scope.refreshDeps();
|
_scope.refreshDeps();
|
||||||
});
|
});
|
||||||
// 2. 通知 private 的依赖作用域更新覆盖
|
// 2. Notify the dependent scopes of private to update their covers
|
||||||
this._private.depScopes.forEach(_scope => {
|
this._private.depScopes.forEach((_scope) => {
|
||||||
_scope.refreshCovers();
|
_scope.refreshCovers();
|
||||||
});
|
});
|
||||||
// 3. private 自身需要刷新依赖
|
// 3. The private scope itself needs to refresh its dependencies
|
||||||
this._private.available.refresh();
|
this._private.available.refresh();
|
||||||
|
|
||||||
this.toDispose.push(this._private);
|
this.toDispose.push(this._private);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user