From e3738ccecad2296309b4c06ab4db767214918f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=9B=E7=9A=93?= Date: Mon, 24 May 2021 17:51:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=BC=E5=87=BA=20utils=20=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/designer/src/plugin/plugin-types.ts | 6 ++---- packages/designer/src/types/index.ts | 10 ++++++++++ packages/engine/src/engine-core.ts | 5 ++++- packages/engine/src/modules/lowcode-types.ts | 1 + packages/engine/src/modules/utils.ts | 11 +++++++++++ packages/rax-simulator-renderer/package.json | 2 +- packages/utils/src/schema.ts | 2 +- 7 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 packages/engine/src/modules/utils.ts diff --git a/packages/designer/src/plugin/plugin-types.ts b/packages/designer/src/plugin/plugin-types.ts index 9c9a8bdb1..7da48f886 100644 --- a/packages/designer/src/plugin/plugin-types.ts +++ b/packages/designer/src/plugin/plugin-types.ts @@ -6,7 +6,7 @@ import { MetadataTransducer, Designer, } from '@ali/lowcode-designer'; -import { Setters } from '../types'; +import { Setters, Utils } from '../types'; export interface ILowCodePluginConfig { name: string; @@ -53,9 +53,7 @@ export interface ILowCodePluginContext { plugins: ILowCodePluginManager; designerCabin: IDesignerCabin; setters: Setters; - /** - 其他暂不增加,按需增加 - */ + utils: Utils; } interface ILowCodePluginManagerPluginAccessor { diff --git a/packages/designer/src/types/index.ts b/packages/designer/src/types/index.ts index db339c476..e079964b0 100644 --- a/packages/designer/src/types/index.ts +++ b/packages/designer/src/types/index.ts @@ -1,4 +1,6 @@ import { getSetter, registerSetter, getSettersMap } from '@ali/lowcode-editor-core'; +import { isFormEvent, compatibleLegaoSchema, getNodeSchemaById } from '@ali/lowcode-utils'; +import { isNodeSchema } from '@ali/lowcode-types'; export type Setters = { getSetter: typeof getSetter; @@ -9,3 +11,11 @@ export type Setters = { export type NodeRemoveOptions = { suppressRemoveEvent?: boolean; }; + +const utils = { + isNodeSchema, + isFormEvent, + compatibleLegaoSchema, + getNodeSchemaById, +}; +export type Utils = typeof utils; \ No newline at end of file diff --git a/packages/engine/src/engine-core.ts b/packages/engine/src/engine-core.ts index 9a73d421b..b979a8af6 100644 --- a/packages/engine/src/engine-core.ts +++ b/packages/engine/src/engine-core.ts @@ -15,11 +15,12 @@ import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-o import DesignerPlugin from '@ali/lowcode-plugin-designer'; import './modules/live-editing'; import { isPlainObject } from '@ali/lowcode-utils'; +import utils from './modules/utils'; export * from './modules/editor-types'; export * from './modules/skeleton-types'; export * from './modules/designer-types'; -// export * from './modules/lowcode-types'; +export * from './modules/lowcode-types'; const { hotkey, monitor, getSetter, registerSetter, getSettersMap } = editorCabin; registerDefaults(); @@ -68,6 +69,7 @@ export { // store, hotkey, monitor, + utils, engineConfig, }; @@ -97,6 +99,7 @@ const getSelection = () => designer.currentDocument?.selection; hotkey, monitor, init, + utils, engineConfig, }; diff --git a/packages/engine/src/modules/lowcode-types.ts b/packages/engine/src/modules/lowcode-types.ts index e69de29bb..d2f4ec957 100644 --- a/packages/engine/src/modules/lowcode-types.ts +++ b/packages/engine/src/modules/lowcode-types.ts @@ -0,0 +1 @@ +export { NodeSchema } from '@ali/lowcode-types'; \ No newline at end of file diff --git a/packages/engine/src/modules/utils.ts b/packages/engine/src/modules/utils.ts new file mode 100644 index 000000000..0288bdc0f --- /dev/null +++ b/packages/engine/src/modules/utils.ts @@ -0,0 +1,11 @@ +import { isFormEvent, compatibleLegaoSchema, getNodeSchemaById } from '@ali/lowcode-utils'; +import { isNodeSchema } from '@ali/lowcode-types'; + +const utils = { + isNodeSchema, + isFormEvent, + compatibleLegaoSchema, + getNodeSchemaById, +}; + +export default utils; \ No newline at end of file diff --git a/packages/rax-simulator-renderer/package.json b/packages/rax-simulator-renderer/package.json index f00507f5f..438dcc255 100644 --- a/packages/rax-simulator-renderer/package.json +++ b/packages/rax-simulator-renderer/package.json @@ -57,6 +57,6 @@ "publishConfig": { "registry": "https://registry.npm.alibaba-inc.com" }, - "homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@1.0.48/build/index.html", + "homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@1.0.49/build/index.html", "gitHead": "3bfd7df92985ec6c9d2ccb8ba95d7b0829fa2b1d" } diff --git a/packages/utils/src/schema.ts b/packages/utils/src/schema.ts index 29629e5be..4b9bcb5be 100644 --- a/packages/utils/src/schema.ts +++ b/packages/utils/src/schema.ts @@ -55,7 +55,7 @@ export function compatibleLegaoSchema(props: any): any { return newProps; } -function getNodeSchemaById(schema: NodeSchema, nodeId: string): NodeSchema | undefined { +export function getNodeSchemaById(schema: NodeSchema, nodeId: string): NodeSchema | undefined { let found: NodeSchema | undefined; if (schema.id === nodeId) { return schema;