From 2f69837002304c39b50fd8a0b4caebeb5a3b5c46 Mon Sep 17 00:00:00 2001 From: liujuping Date: Tue, 14 Feb 2023 12:07:11 +0800 Subject: [PATCH 1/8] fix: fix the problem that the default setter is not registered successfully --- packages/engine/src/engine-core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/engine/src/engine-core.ts b/packages/engine/src/engine-core.ts index acab43506..f32506303 100644 --- a/packages/engine/src/engine-core.ts +++ b/packages/engine/src/engine-core.ts @@ -63,7 +63,7 @@ async function registryInnerPlugin(designer: Designer, editor: Editor, plugins: // 注册一批内置插件 await plugins.register(OutlinePlugin, {}, { autoInit: true }); await plugins.register(componentMetaParser(designer)); - await plugins.register(setterRegistry, {}, { autoInit: true }); + await plugins.register(setterRegistry, {}); await plugins.register(defaultPanelRegistry(editor)); await plugins.register(builtinHotkey); await plugins.register(registerDefaults, {}, { autoInit: true }); From 631b5669327436b8fe7870bd474d2690a265ace5 Mon Sep 17 00:00:00 2001 From: liujuping Date: Tue, 14 Feb 2023 16:16:00 +0800 Subject: [PATCH 2/8] feat: fix the problem of plugin outline tree in workspace mode --- .../src/controllers/tree-master.ts | 20 ++++--------------- packages/plugin-outline-pane/src/index.tsx | 4 ++-- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/plugin-outline-pane/src/controllers/tree-master.ts b/packages/plugin-outline-pane/src/controllers/tree-master.ts index 38b723a98..074ed3447 100644 --- a/packages/plugin-outline-pane/src/controllers/tree-master.ts +++ b/packages/plugin-outline-pane/src/controllers/tree-master.ts @@ -11,6 +11,10 @@ export interface ITreeBoard { export class TreeMaster { readonly pluginContext: IPublicModelPluginContext; + private boards = new Set(); + + private treeMap = new Map(); + constructor(pluginContext: IPublicModelPluginContext) { this.pluginContext = pluginContext; let startTime: any; @@ -70,8 +74,6 @@ export class TreeMaster { } } - private boards = new Set(); - addBoard(board: ITreeBoard) { this.boards.add(board); } @@ -84,8 +86,6 @@ export class TreeMaster { // todo others purge } - private treeMap = new Map(); - get currentTree(): Tree | null { const doc = this.pluginContext.project.getCurrentDocument(); if (doc) { @@ -100,15 +100,3 @@ export class TreeMaster { return null; } } - -const mastersMap = new Map(); -export function getTreeMaster(pluginContext: IPublicModelPluginContext): TreeMaster { - const key = pluginContext.project.currentDocument?.id || 'unknown'; - let master = mastersMap.get(key); - if (!master) { - master = new TreeMaster(pluginContext); - pluginContext.logger.info('TreeMaster is created'); - mastersMap.set(key, master); - } - return master; -} diff --git a/packages/plugin-outline-pane/src/index.tsx b/packages/plugin-outline-pane/src/index.tsx index bf3c95b1a..701e46540 100644 --- a/packages/plugin-outline-pane/src/index.tsx +++ b/packages/plugin-outline-pane/src/index.tsx @@ -3,7 +3,7 @@ import { IconOutline } from './icons/outline'; import { IPublicModelPluginContext, IPublicModelDocumentModel } from '@alilc/lowcode-types'; import { enUS, zhCN } from './locale'; import { MasterPaneName, BackupPaneName } from './helper/consts'; -import { getTreeMaster } from './controllers/tree-master'; +import { TreeMaster } from './controllers/tree-master'; import { PaneController } from './controllers/pane-controller'; export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => { @@ -26,7 +26,7 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => { masterPane: false, backupPane: false, }; - const treeMaster = getTreeMaster(ctx); + const treeMaster = new TreeMaster(ctx); let masterPaneController: PaneController | null = null; let backupPaneController: PaneController | null = null; return { From 0eac230905e153e8fc43231eb6417efed69e5b83 Mon Sep 17 00:00:00 2001 From: liujuping Date: Wed, 15 Feb 2023 10:30:06 +0800 Subject: [PATCH 3/8] feat: add IPublicTypeSkeletonConfig type --- .../src/shell/type/widget-base-config.ts | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/types/src/shell/type/widget-base-config.ts b/packages/types/src/shell/type/widget-base-config.ts index 9c2819da3..08c14c8db 100644 --- a/packages/types/src/shell/type/widget-base-config.ts +++ b/packages/types/src/shell/type/widget-base-config.ts @@ -1,8 +1,10 @@ import { IPublicTypeWidgetConfigArea } from './'; export interface IPublicTypeWidgetBaseConfig { + [extra: string]: any; type: string; name: string; + /** * 停靠位置: * - 当 type 为 'Panel' 时自动为 'leftFloatArea'; @@ -13,6 +15,29 @@ export interface IPublicTypeWidgetBaseConfig { props?: Record; content?: any; contentProps?: Record; - // index?: number; - [extra: string]: any; } + +export interface IPublicTypePanelDockConfig extends IPublicTypeWidgetBaseConfig { + type: 'PanelDock'; + + panelProps?: IPublicTypePanelDockPanelProps; +} + +export interface IPublicTypePanelDockPanelProps { + [key: string]: any; + + /** 是否隐藏面板顶部条 */ + hideTitleBar?: boolean; + + width?: number; + + height?: number; + + maxWidth?: number; + + maxHeight?: number; + + area?: IPublicTypeWidgetConfigArea; +} + +export type IPublicTypeSkeletonConfig = IPublicTypePanelDockConfig | IPublicTypeWidgetBaseConfig; \ No newline at end of file From becdfecd5ab2410ee48bcbfbb137aaf41668a441 Mon Sep 17 00:00:00 2001 From: JackLian Date: Wed, 15 Feb 2023 10:36:15 +0800 Subject: [PATCH 4/8] fix: solve ut failure for code-generator --- modules/code-generator/package.json | 5 +++-- packages/types/src/shell/api/canvas.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/code-generator/package.json b/modules/code-generator/package.json index 97863584c..ee4ef1970 100644 --- a/modules/code-generator/package.json +++ b/modules/code-generator/package.json @@ -143,5 +143,6 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" - } -} + }, + "repository": "git@github.com:alibaba/lowcode-engine.git" +} \ No newline at end of file diff --git a/packages/types/src/shell/api/canvas.ts b/packages/types/src/shell/api/canvas.ts index 699e1a35d..b7ad196ce 100644 --- a/packages/types/src/shell/api/canvas.ts +++ b/packages/types/src/shell/api/canvas.ts @@ -1,5 +1,5 @@ -import { IPublicModelDragon, IPublicModelDropLocation, IPublicModelScrollTarget, IPublicTypeScrollable, IPublicModelScroller, IPublicModelActiveTracker, IPublicModelClipboard } from '../model'; -import { IPublicTypeLocationData } from '../type'; +import { IPublicModelDragon, IPublicModelDropLocation, IPublicModelScrollTarget, IPublicModelScroller, IPublicModelActiveTracker, IPublicModelClipboard } from '../model'; +import { IPublicTypeLocationData, IPublicTypeScrollable } from '../type'; /** * @since v1.1.0 From 8c82fe8f00ffd92931b9ffa6db3f0ee032c07c55 Mon Sep 17 00:00:00 2001 From: liujuping Date: Wed, 15 Feb 2023 15:24:58 +0800 Subject: [PATCH 5/8] feat: disable global hotkey binding shortcuts in workspace mode --- packages/engine/src/engine-core.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/engine/src/engine-core.ts b/packages/engine/src/engine-core.ts index f32506303..abe378d64 100644 --- a/packages/engine/src/engine-core.ts +++ b/packages/engine/src/engine-core.ts @@ -195,6 +195,7 @@ export async function init( engineContainer, ); innerWorkspace.setActive(true); + innerHotkey.activate(false); await innerWorkspace.plugins.init(pluginPreference); return; } From 36d1d3bef1d613c06219bab63e578d1939da1c56 Mon Sep 17 00:00:00 2001 From: liujuping Date: Wed, 15 Feb 2023 15:30:05 +0800 Subject: [PATCH 6/8] feat: support webview type resource in workspace mode --- packages/shell/src/model/resource.ts | 8 +++++ packages/types/src/shell/api/workspace.ts | 2 +- .../src/shell/type/editor-view-config.ts | 3 ++ .../types/src/shell/type/resource-list.ts | 5 +++ .../src/shell/type/resource-type-config.ts | 3 ++ .../types/src/shell/type/resource-type.ts | 4 +-- .../workspace/src/context/base-context.ts | 9 ++++- .../workspace/src/context/view-context.ts | 6 ++-- .../workspace/src/inner-plugins/webview.tsx | 2 +- packages/workspace/src/resource.ts | 18 ++++++++-- packages/workspace/src/view/window-view.tsx | 12 +++++-- packages/workspace/src/window.ts | 35 +++++++++++++++++-- packages/workspace/src/workspace.ts | 26 ++++++++------ 13 files changed, 105 insertions(+), 28 deletions(-) diff --git a/packages/shell/src/model/resource.ts b/packages/shell/src/model/resource.ts index 3fa625ed6..1f037c606 100644 --- a/packages/shell/src/model/resource.ts +++ b/packages/shell/src/model/resource.ts @@ -32,4 +32,12 @@ export class Resource implements IPublicModelResource { get category() { return this[resourceSymbol].category; } + + get children() { + return this[resourceSymbol].children.map((child) => new Resource(child)); + } + + get viewType() { + return this[resourceSymbol].viewType; + } } \ No newline at end of file diff --git a/packages/types/src/shell/api/workspace.ts b/packages/types/src/shell/api/workspace.ts index ee05bbe56..8f8b16e39 100644 --- a/packages/types/src/shell/api/workspace.ts +++ b/packages/types/src/shell/api/workspace.ts @@ -21,7 +21,7 @@ export interface IPublicApiWorkspace { setResourceList(resourceList: IPublicResourceList): void; /** 资源树列表更新事件 */ - onResourceListChange(fn: (resourceList: IPublicResourceList) => void): () => IPublicTypeDisposable; + onResourceListChange(fn: (resourceList: IPublicResourceList) => void): IPublicTypeDisposable; /** 注册资源 */ registerResourceType(resourceTypeModel: IPublicTypeResourceType): void; diff --git a/packages/types/src/shell/type/editor-view-config.ts b/packages/types/src/shell/type/editor-view-config.ts index 2b36a718a..9bb3b7555 100644 --- a/packages/types/src/shell/type/editor-view-config.ts +++ b/packages/types/src/shell/type/editor-view-config.ts @@ -5,4 +5,7 @@ export interface IPublicEditorViewConfig { /** 资源保存时,会调用视图的钩子 */ save?: () => Promise; + + /** viewType 类型为 'webview' 时渲染的地址 */ + url?: () => Promise; } \ No newline at end of file diff --git a/packages/types/src/shell/type/resource-list.ts b/packages/types/src/shell/type/resource-list.ts index 9b8cc3272..bd5e4a3b0 100644 --- a/packages/types/src/shell/type/resource-list.ts +++ b/packages/types/src/shell/type/resource-list.ts @@ -1,10 +1,15 @@ +import { ReactElement } from 'react'; + export interface IPublicResourceData { resourceName: string; title: string; category?: string; + viewType?: string; + icon?: ReactElement; options: { [key: string]: any; }; + children?: IPublicResourceData[]; } export type IPublicResourceList = IPublicResourceData[]; \ No newline at end of file diff --git a/packages/types/src/shell/type/resource-type-config.ts b/packages/types/src/shell/type/resource-type-config.ts index 93534fea2..e47afb53d 100644 --- a/packages/types/src/shell/type/resource-type-config.ts +++ b/packages/types/src/shell/type/resource-type-config.ts @@ -28,4 +28,7 @@ export interface IPublicResourceTypeConfig { /** 默认标题 */ defaultTitle?: string; + + /** resourceType 类型为 'webview' 时渲染的地址 */ + url?: () => Promise; } diff --git a/packages/types/src/shell/type/resource-type.ts b/packages/types/src/shell/type/resource-type.ts index 64ec85c79..7cfb125aa 100644 --- a/packages/types/src/shell/type/resource-type.ts +++ b/packages/types/src/shell/type/resource-type.ts @@ -4,7 +4,7 @@ import { IPublicResourceTypeConfig } from './resource-type-config'; export interface IPublicTypeResourceType { resourceName: string; - resourceType: string; + resourceType: 'editor' | 'webview'; - (ctx: IPublicModelPluginContext): IPublicResourceTypeConfig; + (ctx: IPublicModelPluginContext, options: Object): IPublicResourceTypeConfig; } \ No newline at end of file diff --git a/packages/workspace/src/context/base-context.ts b/packages/workspace/src/context/base-context.ts index b90a131a3..37ce7fafa 100644 --- a/packages/workspace/src/context/base-context.ts +++ b/packages/workspace/src/context/base-context.ts @@ -28,18 +28,22 @@ import { Canvas, } from '@alilc/lowcode-shell'; import { + IPluginPreferenceMananger, + IPublicApiEvent, + IPublicModelPluginContext, IPublicTypePluginMeta, } from '@alilc/lowcode-types'; import { getLogger } from '@alilc/lowcode-utils'; import { Workspace as InnerWorkspace } from '../workspace'; import { EditorWindow } from '../window'; -export class BasicContext { +export class BasicContext implements IPublicModelPluginContext { skeleton: Skeleton; plugins: Plugins; project: Project; setters: Setters; material: Material; + common: Common; config; event; logger; @@ -53,6 +57,8 @@ export class BasicContext { innerHotkey: InnerHotkey; innerPlugins: LowCodePluginManager; canvas: Canvas; + pluginEvent: IPublicApiEvent; + preference: IPluginPreferenceMananger; constructor(innerWorkspace: InnerWorkspace, viewName: string, public editorWindow?: EditorWindow) { const editor = new Editor(viewName, true); @@ -101,6 +107,7 @@ export class BasicContext { this.designer = designer; this.canvas = canvas; const common = new Common(editor, innerSkeleton); + this.common = common; let plugins: any; const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = { diff --git a/packages/workspace/src/context/view-context.ts b/packages/workspace/src/context/view-context.ts index 55bbf2d57..d14549667 100644 --- a/packages/workspace/src/context/view-context.ts +++ b/packages/workspace/src/context/view-context.ts @@ -1,4 +1,4 @@ -import { makeObservable, obx } from '@alilc/lowcode-editor-core'; +import { computed, makeObservable, obx } from '@alilc/lowcode-editor-core'; import { IPublicEditorViewConfig, IPublicTypeEditorView } from '@alilc/lowcode-types'; import { flow } from 'mobx'; import { Workspace as InnerWorkspace } from '../workspace'; @@ -17,7 +17,7 @@ export class Context extends BasicContext { @obx isInit: boolean = false; - get active() { + @computed get active() { return this._activate; } @@ -33,7 +33,7 @@ export class Context extends BasicContext { this.isInit = true; }); - constructor(public workspace: InnerWorkspace, public editorWindow: EditorWindow, public editorView: IPublicTypeEditorView, options: Object) { + constructor(public workspace: InnerWorkspace, public editorWindow: EditorWindow, public editorView: IPublicTypeEditorView, options: Object | undefined) { super(workspace, editorView.viewName, editorWindow); this.viewType = editorView.viewType || 'editor'; this.viewName = editorView.viewName; diff --git a/packages/workspace/src/inner-plugins/webview.tsx b/packages/workspace/src/inner-plugins/webview.tsx index be9c15f8b..de40bb521 100644 --- a/packages/workspace/src/inner-plugins/webview.tsx +++ b/packages/workspace/src/inner-plugins/webview.tsx @@ -1,6 +1,6 @@ import { IPublicModelPluginContext } from '@alilc/lowcode-types'; -function DesignerView(props: { +export function DesignerView(props: { url: string; viewName: string; }) { diff --git a/packages/workspace/src/resource.ts b/packages/workspace/src/resource.ts index effa6abee..119bcc488 100644 --- a/packages/workspace/src/resource.ts +++ b/packages/workspace/src/resource.ts @@ -17,12 +17,16 @@ export class Resource implements IPublicModelResource { return this.resourceType.name; } + get viewType() { + return this.resourceData.viewType; + } + get description() { return this.resourceTypeInstance?.description; } get icon() { - return this.resourceTypeInstance?.icon; + return this.resourceData.icon || this.resourceTypeInstance?.icon; } get type() { @@ -45,9 +49,13 @@ export class Resource implements IPublicModelResource { return this.context.innerSkeleton; } - constructor(readonly resourceData: IPublicResourceData, readonly resourceType: ResourceType, workspace: InnerWorkSpace) { + get children(): Resource[] { + return this.resourceData?.children?.map(d => new Resource(d, this.resourceType, this.workspace)) || []; + } + + constructor(readonly resourceData: IPublicResourceData, readonly resourceType: ResourceType, readonly workspace: InnerWorkSpace) { this.context = new BasicContext(workspace, `resource-${resourceData.resourceName || resourceType.name}`); - this.resourceTypeInstance = resourceType.resourceTypeModel(this.context, {}); + this.resourceTypeInstance = resourceType.resourceTypeModel(this.context, this.options); this.init(); if (this.resourceTypeInstance.editorViews) { this.resourceTypeInstance.editorViews.forEach((d: any) => { @@ -68,6 +76,10 @@ export class Resource implements IPublicModelResource { return await this.resourceTypeInstance.import?.(schema); } + async url() { + return await this.resourceTypeInstance.url?.(); + } + async save(value: any) { return await this.resourceTypeInstance.save?.(value); } diff --git a/packages/workspace/src/view/window-view.tsx b/packages/workspace/src/view/window-view.tsx index 396582a02..c468b084d 100644 --- a/packages/workspace/src/view/window-view.tsx +++ b/packages/workspace/src/view/window-view.tsx @@ -3,6 +3,7 @@ import { ResourceView } from './resource-view'; import { engineConfig, observer } from '@alilc/lowcode-editor-core'; import { EditorWindow } from '../window'; import { BuiltinLoading } from '@alilc/lowcode-designer'; +import { DesignerView } from '../inner-plugins/webview'; @observer export class WindowView extends PureComponent<{ @@ -11,16 +12,21 @@ export class WindowView extends PureComponent<{ }, any> { render() { const { active } = this.props; - const { editorView, resource } = this.props.window; - if (!editorView) { + const { resource, initReady, url } = this.props.window; + + if (!initReady) { const Loading = engineConfig.get('loadingComponent', BuiltinLoading); return ( -
+
); } + if (resource.type === 'webview' && url) { + return ; + } + return (
= new Map(); - constructor(readonly resource: Resource, readonly workspace: Workspace, public title: string | undefined = '', private options: Object = {}) { + @obx initReady = false; + + constructor(readonly resource: Resource, readonly workspace: Workspace, private config: IWindowCOnfig) { makeObservable(this); this.init(); + this.title = config.title; this.icon = resource.icon; } @@ -48,11 +61,16 @@ export class EditorWindow { async init() { await this.initViewTypes(); await this.execViewTypesInit(); + this.url = await this.resource.url(); this.setDefaultViewType(); + this.initReady = true; } initViewTypes = async () => { const editorViews = this.resource.editorViews; + if (!editorViews) { + return; + } for (let i = 0; i < editorViews.length; i++) { const name = editorViews[i].viewName; await this.initViewType(name); @@ -72,6 +90,9 @@ export class EditorWindow { execViewTypesInit = async () => { const editorViews = this.resource.editorViews; + if (!editorViews) { + return; + } for (let i = 0; i < editorViews.length; i++) { const name = editorViews[i].viewName; this.changeViewType(name); @@ -80,15 +101,19 @@ export class EditorWindow { }; setDefaultViewType = () => { - this.changeViewType(this.resource.defaultViewType); + this.changeViewType(this.config.viewType ?? this.resource.defaultViewType); }; + get resourceType() { + return this.resource.resourceType.type; + } + initViewType = async (name: string) => { const viewInfo = this.resource.getEditorView(name); if (this.editorViews.get(name)) { return; } - const editorView = new Context(this.workspace, this, viewInfo as any, this.options); + const editorView = new Context(this.workspace, this, viewInfo as any, this.config.options); this.editorViews.set(name, editorView); }; @@ -96,6 +121,10 @@ export class EditorWindow { this.editorView?.setActivate(false); this.editorView = this.editorViews.get(name)!; + if (!this.editorView) { + return; + } + if (!ignoreEmit) { this.emitter.emit('window.change.view.type', name); } diff --git a/packages/workspace/src/workspace.ts b/packages/workspace/src/workspace.ts index 509ca9d9d..0b7181cd8 100644 --- a/packages/workspace/src/workspace.ts +++ b/packages/workspace/src/workspace.ts @@ -46,7 +46,7 @@ export class Workspace implements IPublicApiWorkspace { return null; } - windows: EditorWindow[] = []; + @obx.ref windows: EditorWindow[] = []; editorWindowMap: Map = new Map(); @@ -71,7 +71,9 @@ export class Workspace implements IPublicApiWorkspace { } const title = this.defaultResourceType.name; const resource = new Resource({}, this.defaultResourceType, this); - this.window = new EditorWindow(resource, this, title); + this.window = new EditorWindow(resource, this, { + title, + }); this.editorWindowMap.set(this.window.id, this.window); this.windows.push(this.window); this.emitChangeWindow(); @@ -83,13 +85,11 @@ export class Workspace implements IPublicApiWorkspace { } async registerResourceType(resourceTypeModel: IPublicTypeResourceType): Promise { - if (resourceTypeModel.resourceType === 'editor') { - const resourceType = new ResourceType(resourceTypeModel); - this.resourceTypeMap.set(resourceTypeModel.resourceName, resourceType); + const resourceType = new ResourceType(resourceTypeModel); + this.resourceTypeMap.set(resourceTypeModel.resourceName, resourceType); - if (!this.window && this.defaultResourceType) { - this.initWindow(); - } + if (!this.window && this.defaultResourceType) { + this.initWindow(); } } @@ -150,7 +150,7 @@ export class Workspace implements IPublicApiWorkspace { openEditorWindow(name: string, title: string, options: Object, viewType?: string) { const resourceType = this.resourceTypeMap.get(name); if (!resourceType) { - console.error(`${name} is not available`); + console.error(`${name} resourceType is not available`); return; } const filterWindows = this.windows.filter(d => (d.resource.name === name && d.resource.title == title)); @@ -164,8 +164,12 @@ export class Workspace implements IPublicApiWorkspace { title, options, }, resourceType, this); - this.window = new EditorWindow(resource, this, title, options); - this.windows.push(this.window); + this.window = new EditorWindow(resource, this, { + title, + options, + viewType, + }); + this.windows = [...this.windows, this.window]; this.editorWindowMap.set(this.window.id, this.window); this.emitChangeWindow(); this.emitChangeActiveWindow(); From 9d83b8b5b9a916b9598e37d713fd4d2ffebbdff9 Mon Sep 17 00:00:00 2001 From: JackLian Date: Wed, 15 Feb 2023 17:07:04 +0800 Subject: [PATCH 7/8] docs: improve doc for plugin related apis --- docs/docs/api/plugins.md | 51 ++++++++++++++----- packages/designer/src/plugin/plugin-types.ts | 2 +- packages/shell/src/model/plugin-instance.ts | 2 +- packages/types/src/shell/api/plugins.ts | 25 ++++++--- .../types/src/shell/model/plugin-context.ts | 19 +++++-- .../types/src/shell/model/plugin-instance.ts | 27 ++++++++-- 6 files changed, 98 insertions(+), 28 deletions(-) diff --git a/docs/docs/api/plugins.md b/docs/docs/api/plugins.md index 58be1fde0..e35411d3a 100644 --- a/docs/docs/api/plugins.md +++ b/docs/docs/api/plugins.md @@ -118,11 +118,13 @@ import { IPublicModelPluginContext } from '@alilc/lowcode-types'; const BuiltinPluginRegistry = (ctx: IPublicModelPluginContext, options: any) => { return { async init() { - // 1.0.4 之后的传值方式,通过 register(xxx, options) - // 取值通过 options + // 直接传值方式: + // 通过 register(xxx, options) 传入 + // 通过 options 取出 - // 1.0.4 之前的传值方式,通过 init(..., preference) - // 取值通过 ctx.preference.getValue() + // 引擎初始化时也可以设置某插件的全局配置项: + // 通过 engine.init(..., preference) 传入 + // 通过 ctx.preference.getValue() 取出 }, }; } @@ -155,7 +157,6 @@ BuiltinPluginRegistry.meta = { }, } -// 从 1.0.4 开始,支持直接在 pluginCreator 的第二个参数 options 获取入参 await plugins.register(BuiltinPluginRegistry, { key1: 'abc', key5: 'willNotPassToPlugin' }); ``` @@ -164,8 +165,11 @@ await plugins.register(BuiltinPluginRegistry, { key1: 'abc', key5: 'willNotPassT 获取指定插件 ```typescript -function get(pluginName: string): IPublicModelPluginInstance; - +/** + * 获取指定插件 + * get plugin instance by name + */ +get(pluginName: string): IPublicModelPluginInstance | null; ``` 关联模型 [IPublicModelPluginInstance](./model/plugin-instance) @@ -175,8 +179,11 @@ function get(pluginName: string): IPublicModelPluginInstance; 获取所有的插件实例 ```typescript -function getAll(): IPublicModelPluginInstance[]; - +/** + * 获取所有的插件实例 + * get all plugin instances + */ +getAll(): IPublicModelPluginInstance[]; ``` 关联模型 [IPublicModelPluginInstance](./model/plugin-instance) @@ -186,8 +193,11 @@ function getAll(): IPublicModelPluginInstance[]; 判断是否有指定插件 ```typescript -function has(pluginName: string): boolean; - +/** + * 判断是否有指定插件 + * check if plugin with certain name exists + */ +has(pluginName: string): boolean; ``` ### delete @@ -195,8 +205,25 @@ function has(pluginName: string): boolean; 删除指定插件 ```typescript -function delete(pluginName: string): void; +/** + * 删除指定插件 + * delete plugin instance by name + */ +delete(pluginName: string): void; +``` +### getPluginPreference + +引擎初始化时可以提供全局配置给到各插件,通过这个方法可以获得本插件对应的配置 + +```typescript +/** + * 引擎初始化时可以提供全局配置给到各插件,通过这个方法可以获得本插件对应的配置 + * use this to get preference config for this plugin when engine.init() called + */ +getPluginPreference( + pluginName: string, + ): Record | null | undefined; ``` ## 相关类型定义 diff --git a/packages/designer/src/plugin/plugin-types.ts b/packages/designer/src/plugin/plugin-types.ts index 8c246a5d2..837fae4b1 100644 --- a/packages/designer/src/plugin/plugin-types.ts +++ b/packages/designer/src/plugin/plugin-types.ts @@ -26,12 +26,12 @@ export interface ILowCodePluginRuntimeCore { disabled: boolean; config: IPublicTypePluginConfig; logger: IPublicApiLogger; + meta: IPublicTypePluginMeta; init(forceInit?: boolean): void; isInited(): boolean; destroy(): void; toProxy(): any; setDisabled(flag: boolean): void; - meta: IPublicTypePluginMeta; } interface ILowCodePluginRuntimeExportsAccessor { diff --git a/packages/shell/src/model/plugin-instance.ts b/packages/shell/src/model/plugin-instance.ts index 47a619482..156ec7579 100644 --- a/packages/shell/src/model/plugin-instance.ts +++ b/packages/shell/src/model/plugin-instance.ts @@ -28,4 +28,4 @@ export class PluginInstance implements IPublicModelPluginInstance { get meta() { return this[pluginInstanceSymbol].meta; } -} \ No newline at end of file +} diff --git a/packages/types/src/shell/api/plugins.ts b/packages/types/src/shell/api/plugins.ts index 32e13c3b6..518362b97 100644 --- a/packages/types/src/shell/api/plugins.ts +++ b/packages/types/src/shell/api/plugins.ts @@ -20,21 +20,34 @@ export interface IPublicApiPlugins { ): Promise; /** - * @deprecated use options instead + * 引擎初始化时可以提供全局配置给到各插件,通过这个方法可以获得本插件对应的配置 + * use this to get preference config for this plugin when engine.init() called */ getPluginPreference( pluginName: string, ): Record | null | undefined; - /** 获取指定插件 */ + /** + * 获取指定插件 + * get plugin instance by name + */ get(pluginName: string): IPublicModelPluginInstance | null; - /** 获取所有的插件实例 */ + /** + * 获取所有的插件实例 + * get all plugin instances + */ getAll(): IPublicModelPluginInstance[]; - /** 判断是否有指定插件 */ + /** + * 判断是否有指定插件 + * check if plugin with certain name exists + */ has(pluginName: string): boolean; - /** 删除指定插件 */ + /** + * 删除指定插件 + * delete plugin instance by name + */ delete(pluginName: string): void; -} \ No newline at end of file +} diff --git a/packages/types/src/shell/model/plugin-context.ts b/packages/types/src/shell/model/plugin-context.ts index cc989ac76..ae7ef8bbb 100644 --- a/packages/types/src/shell/model/plugin-context.ts +++ b/packages/types/src/shell/model/plugin-context.ts @@ -14,11 +14,26 @@ import { import { IPublicModelEngineConfig } from './'; export interface IPublicModelPluginContext { + + /** + * 对于插件开发者来说,可以在 context 挂载自定义的内容,作为插件内全局上下文使用 + * + * for plugin developers, costom properties can be add to plugin context + * from inside plugin for convenience. + */ + [key: string]: any; + + /** + * 可通过该对象读取插件初始化配置 + * by using this, init options can be accessed from inside plugin + */ + preference: IPluginPreferenceMananger; get skeleton(): IPublicApiSkeleton; get hotkey(): IPublicApiHotkey; get setters(): IPublicApiSetters; get config(): IPublicModelEngineConfig; get material(): IPublicApiMaterial; + /** * this event works globally, can be used between plugins and engine. */ @@ -33,8 +48,6 @@ export interface IPublicModelPluginContext { */ get pluginEvent(): IPublicApiEvent; get canvas(): IPublicApiCanvas; - preference: IPluginPreferenceMananger; - [key: string]: any; } /** @@ -44,4 +57,4 @@ export interface IPublicModelPluginContext { */ export interface ILowCodePluginContext extends IPublicModelPluginContext { -} \ No newline at end of file +} diff --git a/packages/types/src/shell/model/plugin-instance.ts b/packages/types/src/shell/model/plugin-instance.ts index 7855d903b..88904205d 100644 --- a/packages/types/src/shell/model/plugin-instance.ts +++ b/packages/types/src/shell/model/plugin-instance.ts @@ -1,11 +1,28 @@ import { IPublicTypePluginMeta } from '../type/plugin-meta'; export interface IPublicModelPluginInstance { - pluginName: string; - - dep: string[]; + /** + * 是否 disable + * current plugin instance is disabled or not + */ disabled: boolean; - meta: IPublicTypePluginMeta; -} \ No newline at end of file + /** + * 插件名称 + * plugin name + */ + get pluginName(): string; + + /** + * 依赖信息,依赖的其他插件 + * depenency info + */ + get dep(): string[]; + + /** + * 插件配置元数据 + * meta info of this plugin + */ + get meta(): IPublicTypePluginMeta; +} From 18eeff953a687ae756433696b99e0c442ba99ea7 Mon Sep 17 00:00:00 2001 From: JackLian Date: Wed, 15 Feb 2023 17:23:11 +0800 Subject: [PATCH 8/8] chore(release): publish 1.1.1 --- lerna.json | 2 +- packages/designer/package.json | 8 ++++---- packages/editor-core/package.json | 6 +++--- packages/editor-skeleton/package.json | 10 +++++----- packages/engine/package.json | 18 +++++++++--------- packages/ignitor/package.json | 2 +- packages/plugin-designer/package.json | 8 ++++---- packages/plugin-outline-pane/package.json | 10 +++++----- packages/rax-renderer/package.json | 6 +++--- packages/rax-simulator-renderer/package.json | 10 +++++----- packages/react-renderer/package.json | 4 ++-- packages/react-simulator-renderer/package.json | 10 +++++----- packages/renderer-core/package.json | 8 ++++---- packages/shell/package.json | 14 +++++++------- packages/types/package.json | 2 +- packages/utils/package.json | 4 ++-- packages/workspace/package.json | 12 ++++++------ 17 files changed, 67 insertions(+), 67 deletions(-) diff --git a/lerna.json b/lerna.json index dc8950db4..2e2f55ad3 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "lerna": "4.0.0", - "version": "1.1.0", + "version": "1.1.1", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/designer/package.json b/packages/designer/package.json index 88ca8d173..b76dc8b02 100644 --- a/packages/designer/package.json +++ b/packages/designer/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-designer", - "version": "1.1.0", + "version": "1.1.1", "description": "Designer for Ali LowCode Engine", "main": "lib/index.js", "module": "es/index.js", @@ -15,9 +15,9 @@ }, "license": "MIT", "dependencies": { - "@alilc/lowcode-editor-core": "1.1.0", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-editor-core": "1.1.1", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "classnames": "^2.2.6", "react": "^16", "react-dom": "^16.7.0", diff --git a/packages/editor-core/package.json b/packages/editor-core/package.json index 3bdda2288..09b7d96af 100644 --- a/packages/editor-core/package.json +++ b/packages/editor-core/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-editor-core", - "version": "1.1.0", + "version": "1.1.1", "description": "Core Api for Ali lowCode engine", "license": "MIT", "main": "lib/index.js", @@ -14,8 +14,8 @@ }, "dependencies": { "@alifd/next": "^1.19.16", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "classnames": "^2.2.6", "debug": "^4.1.1", "intl-messageformat": "^9.3.1", diff --git a/packages/editor-skeleton/package.json b/packages/editor-skeleton/package.json index 586d543d5..45e4b1fd0 100644 --- a/packages/editor-skeleton/package.json +++ b/packages/editor-skeleton/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-editor-skeleton", - "version": "1.1.0", + "version": "1.1.1", "description": "alibaba lowcode editor skeleton", "main": "lib/index.js", "module": "es/index.js", @@ -18,10 +18,10 @@ ], "dependencies": { "@alifd/next": "^1.20.12", - "@alilc/lowcode-designer": "1.1.0", - "@alilc/lowcode-editor-core": "1.1.0", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", + "@alilc/lowcode-editor-core": "1.1.1", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "classnames": "^2.2.6", "react": "^16.8.1", "react-dom": "^16.8.1" diff --git a/packages/engine/package.json b/packages/engine/package.json index 5cc6ab8c9..23014a38b 100644 --- a/packages/engine/package.json +++ b/packages/engine/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-engine", - "version": "1.1.0", + "version": "1.1.1", "description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系", "main": "lib/engine-core.js", "module": "es/engine-core.js", @@ -19,15 +19,15 @@ "license": "MIT", "dependencies": { "@alifd/next": "^1.19.12", - "@alilc/lowcode-designer": "1.1.0", - "@alilc/lowcode-editor-core": "1.1.0", - "@alilc/lowcode-editor-skeleton": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", + "@alilc/lowcode-editor-core": "1.1.1", + "@alilc/lowcode-editor-skeleton": "1.1.1", "@alilc/lowcode-engine-ext": "^1.0.0", - "@alilc/lowcode-plugin-designer": "1.1.0", - "@alilc/lowcode-plugin-outline-pane": "1.1.0", - "@alilc/lowcode-shell": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", - "@alilc/lowcode-workspace": "1.1.0", + "@alilc/lowcode-plugin-designer": "1.1.1", + "@alilc/lowcode-plugin-outline-pane": "1.1.1", + "@alilc/lowcode-shell": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", + "@alilc/lowcode-workspace": "1.1.1", "react": "^16.8.1", "react-dom": "^16.8.1" }, diff --git a/packages/ignitor/package.json b/packages/ignitor/package.json index 3e5ac8ed8..d9658e8d0 100644 --- a/packages/ignitor/package.json +++ b/packages/ignitor/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-ignitor", - "version": "1.1.0", + "version": "1.1.1", "description": "点火器,bootstrap lce project", "main": "lib/index.js", "private": true, diff --git a/packages/plugin-designer/package.json b/packages/plugin-designer/package.json index c9820700a..bd7ac8261 100644 --- a/packages/plugin-designer/package.json +++ b/packages/plugin-designer/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-designer", - "version": "1.1.0", + "version": "1.1.1", "description": "alibaba lowcode editor designer plugin", "files": [ "es", @@ -18,9 +18,9 @@ ], "author": "xiayang.xy", "dependencies": { - "@alilc/lowcode-designer": "1.1.0", - "@alilc/lowcode-editor-core": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", + "@alilc/lowcode-editor-core": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "react": "^16.8.1", "react-dom": "^16.8.1" }, diff --git a/packages/plugin-outline-pane/package.json b/packages/plugin-outline-pane/package.json index 5c5eccab0..af974b044 100644 --- a/packages/plugin-outline-pane/package.json +++ b/packages/plugin-outline-pane/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-outline-pane", - "version": "1.1.0", + "version": "1.1.1", "description": "Outline pane for Ali lowCode engine", "files": [ "es", @@ -13,10 +13,10 @@ }, "dependencies": { "@alifd/next": "^1.19.16", - "@alilc/lowcode-designer": "1.1.0", - "@alilc/lowcode-editor-core": "1.1.0", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", + "@alilc/lowcode-editor-core": "1.1.1", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "classnames": "^2.2.6", "react": "^16", "react-dom": "^16.7.0", diff --git a/packages/rax-renderer/package.json b/packages/rax-renderer/package.json index 36276669c..ba03dfb9b 100644 --- a/packages/rax-renderer/package.json +++ b/packages/rax-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-rax-renderer", - "version": "1.1.0", + "version": "1.1.1", "description": "Rax renderer for Ali lowCode engine", "main": "lib/index.js", "module": "es/index.js", @@ -30,8 +30,8 @@ "build": "build-scripts build" }, "dependencies": { - "@alilc/lowcode-renderer-core": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-renderer-core": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "rax-find-dom-node": "^1.0.1" }, "devDependencies": { diff --git a/packages/rax-simulator-renderer/package.json b/packages/rax-simulator-renderer/package.json index ae042fdda..a196120c4 100644 --- a/packages/rax-simulator-renderer/package.json +++ b/packages/rax-simulator-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-rax-simulator-renderer", - "version": "1.1.0", + "version": "1.1.1", "description": "rax simulator renderer for alibaba lowcode designer", "main": "lib/index.js", "module": "es/index.js", @@ -13,10 +13,10 @@ "build:umd": "build-scripts build --config build.umd.json" }, "dependencies": { - "@alilc/lowcode-designer": "1.1.0", - "@alilc/lowcode-rax-renderer": "1.1.0", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", + "@alilc/lowcode-rax-renderer": "1.1.1", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "classnames": "^2.2.6", "driver-universal": "^3.1.3", "history": "^5.0.0", diff --git a/packages/react-renderer/package.json b/packages/react-renderer/package.json index 55fd0074d..bcc28aa11 100644 --- a/packages/react-renderer/package.json +++ b/packages/react-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-react-renderer", - "version": "1.1.0", + "version": "1.1.1", "description": "react renderer for ali lowcode engine", "main": "lib/index.js", "module": "es/index.js", @@ -22,7 +22,7 @@ ], "dependencies": { "@alifd/next": "^1.21.16", - "@alilc/lowcode-renderer-core": "1.1.0" + "@alilc/lowcode-renderer-core": "1.1.1" }, "devDependencies": { "@alib/build-scripts": "^0.1.18", diff --git a/packages/react-simulator-renderer/package.json b/packages/react-simulator-renderer/package.json index 6699b12b3..278b6f508 100644 --- a/packages/react-simulator-renderer/package.json +++ b/packages/react-simulator-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-react-simulator-renderer", - "version": "1.1.0", + "version": "1.1.1", "description": "react simulator renderer for alibaba lowcode designer", "main": "lib/index.js", "module": "es/index.js", @@ -17,10 +17,10 @@ "test:cov": "build-scripts test --config build.test.json --jest-coverage" }, "dependencies": { - "@alilc/lowcode-designer": "1.1.0", - "@alilc/lowcode-react-renderer": "1.1.0", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", + "@alilc/lowcode-react-renderer": "1.1.1", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "classnames": "^2.2.6", "mobx": "^6.3.0", "mobx-react": "^7.2.0", diff --git a/packages/renderer-core/package.json b/packages/renderer-core/package.json index d589ad2ee..0f4b9132e 100644 --- a/packages/renderer-core/package.json +++ b/packages/renderer-core/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-renderer-core", - "version": "1.1.0", + "version": "1.1.1", "description": "renderer core", "license": "MIT", "main": "lib/index.js", @@ -16,8 +16,8 @@ }, "dependencies": { "@alilc/lowcode-datasource-engine": "^1.0.0", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "classnames": "^2.2.6", "debug": "^4.1.1", "fetch-jsonp": "^1.1.3", @@ -32,7 +32,7 @@ "devDependencies": { "@alib/build-scripts": "^0.1.18", "@alifd/next": "^1.26.0", - "@alilc/lowcode-designer": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", "@babel/plugin-transform-typescript": "^7.16.8", "@testing-library/react": "^11.2.2", "@types/classnames": "^2.2.11", diff --git a/packages/shell/package.json b/packages/shell/package.json index 3ff5529b5..4566424f0 100644 --- a/packages/shell/package.json +++ b/packages/shell/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-shell", - "version": "1.1.0", + "version": "1.1.1", "description": "Shell Layer for AliLowCodeEngine", "main": "lib/index.js", "module": "es/index.js", @@ -15,12 +15,12 @@ }, "license": "MIT", "dependencies": { - "@alilc/lowcode-designer": "1.1.0", - "@alilc/lowcode-editor-core": "1.1.0", - "@alilc/lowcode-editor-skeleton": "1.1.0", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", - "@alilc/lowcode-workspace": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", + "@alilc/lowcode-editor-core": "1.1.1", + "@alilc/lowcode-editor-skeleton": "1.1.1", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", + "@alilc/lowcode-workspace": "1.1.1", "classnames": "^2.2.6", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.5", diff --git a/packages/types/package.json b/packages/types/package.json index 95c7fe887..a023cdd3f 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-types", - "version": "1.1.0", + "version": "1.1.1", "description": "Types for Ali lowCode engine", "files": [ "es", diff --git a/packages/utils/package.json b/packages/utils/package.json index 274fc34c2..4c351236f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-utils", - "version": "1.1.0", + "version": "1.1.1", "description": "Utils for Ali lowCode engine", "files": [ "lib", @@ -14,7 +14,7 @@ }, "dependencies": { "@alifd/next": "^1.19.16", - "@alilc/lowcode-types": "1.1.0", + "@alilc/lowcode-types": "1.1.1", "lodash": "^4.17.21", "mobx": "^6.3.0", "react": "^16" diff --git a/packages/workspace/package.json b/packages/workspace/package.json index 98f175987..54b468acb 100644 --- a/packages/workspace/package.json +++ b/packages/workspace/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-workspace", - "version": "1.1.0", + "version": "1.1.1", "description": "Shell Layer for AliLowCodeEngine", "main": "lib/index.js", "module": "es/index.js", @@ -15,11 +15,11 @@ }, "license": "MIT", "dependencies": { - "@alilc/lowcode-designer": "1.1.0", - "@alilc/lowcode-editor-core": "1.1.0", - "@alilc/lowcode-editor-skeleton": "1.1.0", - "@alilc/lowcode-types": "1.1.0", - "@alilc/lowcode-utils": "1.1.0", + "@alilc/lowcode-designer": "1.1.1", + "@alilc/lowcode-editor-core": "1.1.1", + "@alilc/lowcode-editor-skeleton": "1.1.1", + "@alilc/lowcode-types": "1.1.1", + "@alilc/lowcode-utils": "1.1.1", "classnames": "^2.2.6", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.5",