Merge branch 'release/1.1.1'

This commit is contained in:
JackLian 2023-02-15 17:24:42 +08:00
commit 12dee7f911
42 changed files with 310 additions and 148 deletions

View File

@ -118,11 +118,13 @@ import { IPublicModelPluginContext } from '@alilc/lowcode-types';
const BuiltinPluginRegistry = (ctx: IPublicModelPluginContext, options: any) => { const BuiltinPluginRegistry = (ctx: IPublicModelPluginContext, options: any) => {
return { return {
async init() { 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' }); await plugins.register(BuiltinPluginRegistry, { key1: 'abc', key5: 'willNotPassToPlugin' });
``` ```
@ -164,8 +165,11 @@ await plugins.register(BuiltinPluginRegistry, { key1: 'abc', key5: 'willNotPassT
获取指定插件 获取指定插件
```typescript ```typescript
function get(pluginName: string): IPublicModelPluginInstance; /**
* 获取指定插件
* get plugin instance by name
*/
get(pluginName: string): IPublicModelPluginInstance | null;
``` ```
关联模型 [IPublicModelPluginInstance](./model/plugin-instance) 关联模型 [IPublicModelPluginInstance](./model/plugin-instance)
@ -175,8 +179,11 @@ function get(pluginName: string): IPublicModelPluginInstance;
获取所有的插件实例 获取所有的插件实例
```typescript ```typescript
function getAll(): IPublicModelPluginInstance[]; /**
* 获取所有的插件实例
* get all plugin instances
*/
getAll(): IPublicModelPluginInstance[];
``` ```
关联模型 [IPublicModelPluginInstance](./model/plugin-instance) 关联模型 [IPublicModelPluginInstance](./model/plugin-instance)
@ -186,8 +193,11 @@ function getAll(): IPublicModelPluginInstance[];
判断是否有指定插件 判断是否有指定插件
```typescript ```typescript
function has(pluginName: string): boolean; /**
* 判断是否有指定插件
* check if plugin with certain name exists
*/
has(pluginName: string): boolean;
``` ```
### delete ### delete
@ -195,8 +205,25 @@ function has(pluginName: string): boolean;
删除指定插件 删除指定插件
```typescript ```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<string, IPublicTypePreferenceValueType> | null | undefined;
``` ```
## 相关类型定义 ## 相关类型定义

View File

@ -1,6 +1,6 @@
{ {
"lerna": "4.0.0", "lerna": "4.0.0",
"version": "1.1.0", "version": "1.1.1",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"packages": [ "packages": [

View File

@ -143,5 +143,6 @@
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"registry": "https://registry.npmjs.org/" "registry": "https://registry.npmjs.org/"
} },
"repository": "git@github.com:alibaba/lowcode-engine.git"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-designer", "name": "@alilc/lowcode-designer",
"version": "1.1.0", "version": "1.1.1",
"description": "Designer for Ali LowCode Engine", "description": "Designer for Ali LowCode Engine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -15,9 +15,9 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alilc/lowcode-editor-core": "1.1.0", "@alilc/lowcode-editor-core": "1.1.1",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"react": "^16", "react": "^16",
"react-dom": "^16.7.0", "react-dom": "^16.7.0",

View File

@ -26,12 +26,12 @@ export interface ILowCodePluginRuntimeCore {
disabled: boolean; disabled: boolean;
config: IPublicTypePluginConfig; config: IPublicTypePluginConfig;
logger: IPublicApiLogger; logger: IPublicApiLogger;
meta: IPublicTypePluginMeta;
init(forceInit?: boolean): void; init(forceInit?: boolean): void;
isInited(): boolean; isInited(): boolean;
destroy(): void; destroy(): void;
toProxy(): any; toProxy(): any;
setDisabled(flag: boolean): void; setDisabled(flag: boolean): void;
meta: IPublicTypePluginMeta;
} }
interface ILowCodePluginRuntimeExportsAccessor { interface ILowCodePluginRuntimeExportsAccessor {

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-editor-core", "name": "@alilc/lowcode-editor-core",
"version": "1.1.0", "version": "1.1.1",
"description": "Core Api for Ali lowCode engine", "description": "Core Api for Ali lowCode engine",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
@ -14,8 +14,8 @@
}, },
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.16", "@alifd/next": "^1.19.16",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"debug": "^4.1.1", "debug": "^4.1.1",
"intl-messageformat": "^9.3.1", "intl-messageformat": "^9.3.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-editor-skeleton", "name": "@alilc/lowcode-editor-skeleton",
"version": "1.1.0", "version": "1.1.1",
"description": "alibaba lowcode editor skeleton", "description": "alibaba lowcode editor skeleton",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -18,10 +18,10 @@
], ],
"dependencies": { "dependencies": {
"@alifd/next": "^1.20.12", "@alifd/next": "^1.20.12",
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@alilc/lowcode-editor-core": "1.1.0", "@alilc/lowcode-editor-core": "1.1.1",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"react": "^16.8.1", "react": "^16.8.1",
"react-dom": "^16.8.1" "react-dom": "^16.8.1"

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-engine", "name": "@alilc/lowcode-engine",
"version": "1.1.0", "version": "1.1.1",
"description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系", "description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系",
"main": "lib/engine-core.js", "main": "lib/engine-core.js",
"module": "es/engine-core.js", "module": "es/engine-core.js",
@ -19,15 +19,15 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.12", "@alifd/next": "^1.19.12",
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@alilc/lowcode-editor-core": "1.1.0", "@alilc/lowcode-editor-core": "1.1.1",
"@alilc/lowcode-editor-skeleton": "1.1.0", "@alilc/lowcode-editor-skeleton": "1.1.1",
"@alilc/lowcode-engine-ext": "^1.0.0", "@alilc/lowcode-engine-ext": "^1.0.0",
"@alilc/lowcode-plugin-designer": "1.1.0", "@alilc/lowcode-plugin-designer": "1.1.1",
"@alilc/lowcode-plugin-outline-pane": "1.1.0", "@alilc/lowcode-plugin-outline-pane": "1.1.1",
"@alilc/lowcode-shell": "1.1.0", "@alilc/lowcode-shell": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"@alilc/lowcode-workspace": "1.1.0", "@alilc/lowcode-workspace": "1.1.1",
"react": "^16.8.1", "react": "^16.8.1",
"react-dom": "^16.8.1" "react-dom": "^16.8.1"
}, },

View File

@ -63,7 +63,7 @@ async function registryInnerPlugin(designer: Designer, editor: Editor, plugins:
// 注册一批内置插件 // 注册一批内置插件
await plugins.register(OutlinePlugin, {}, { autoInit: true }); await plugins.register(OutlinePlugin, {}, { autoInit: true });
await plugins.register(componentMetaParser(designer)); await plugins.register(componentMetaParser(designer));
await plugins.register(setterRegistry, {}, { autoInit: true }); await plugins.register(setterRegistry, {});
await plugins.register(defaultPanelRegistry(editor)); await plugins.register(defaultPanelRegistry(editor));
await plugins.register(builtinHotkey); await plugins.register(builtinHotkey);
await plugins.register(registerDefaults, {}, { autoInit: true }); await plugins.register(registerDefaults, {}, { autoInit: true });
@ -195,6 +195,7 @@ export async function init(
engineContainer, engineContainer,
); );
innerWorkspace.setActive(true); innerWorkspace.setActive(true);
innerHotkey.activate(false);
await innerWorkspace.plugins.init(pluginPreference); await innerWorkspace.plugins.init(pluginPreference);
return; return;
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-ignitor", "name": "@alilc/lowcode-ignitor",
"version": "1.1.0", "version": "1.1.1",
"description": "点火器bootstrap lce project", "description": "点火器bootstrap lce project",
"main": "lib/index.js", "main": "lib/index.js",
"private": true, "private": true,

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-plugin-designer", "name": "@alilc/lowcode-plugin-designer",
"version": "1.1.0", "version": "1.1.1",
"description": "alibaba lowcode editor designer plugin", "description": "alibaba lowcode editor designer plugin",
"files": [ "files": [
"es", "es",
@ -18,9 +18,9 @@
], ],
"author": "xiayang.xy", "author": "xiayang.xy",
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@alilc/lowcode-editor-core": "1.1.0", "@alilc/lowcode-editor-core": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"react": "^16.8.1", "react": "^16.8.1",
"react-dom": "^16.8.1" "react-dom": "^16.8.1"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-plugin-outline-pane", "name": "@alilc/lowcode-plugin-outline-pane",
"version": "1.1.0", "version": "1.1.1",
"description": "Outline pane for Ali lowCode engine", "description": "Outline pane for Ali lowCode engine",
"files": [ "files": [
"es", "es",
@ -13,10 +13,10 @@
}, },
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.16", "@alifd/next": "^1.19.16",
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@alilc/lowcode-editor-core": "1.1.0", "@alilc/lowcode-editor-core": "1.1.1",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"react": "^16", "react": "^16",
"react-dom": "^16.7.0", "react-dom": "^16.7.0",

View File

@ -11,6 +11,10 @@ export interface ITreeBoard {
export class TreeMaster { export class TreeMaster {
readonly pluginContext: IPublicModelPluginContext; readonly pluginContext: IPublicModelPluginContext;
private boards = new Set<ITreeBoard>();
private treeMap = new Map<string, Tree>();
constructor(pluginContext: IPublicModelPluginContext) { constructor(pluginContext: IPublicModelPluginContext) {
this.pluginContext = pluginContext; this.pluginContext = pluginContext;
let startTime: any; let startTime: any;
@ -70,8 +74,6 @@ export class TreeMaster {
} }
} }
private boards = new Set<ITreeBoard>();
addBoard(board: ITreeBoard) { addBoard(board: ITreeBoard) {
this.boards.add(board); this.boards.add(board);
} }
@ -84,8 +86,6 @@ export class TreeMaster {
// todo others purge // todo others purge
} }
private treeMap = new Map<string, Tree>();
get currentTree(): Tree | null { get currentTree(): Tree | null {
const doc = this.pluginContext.project.getCurrentDocument(); const doc = this.pluginContext.project.getCurrentDocument();
if (doc) { if (doc) {
@ -100,15 +100,3 @@ export class TreeMaster {
return null; return null;
} }
} }
const mastersMap = new Map<string, TreeMaster>();
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;
}

View File

@ -3,7 +3,7 @@ import { IconOutline } from './icons/outline';
import { IPublicModelPluginContext, IPublicModelDocumentModel } from '@alilc/lowcode-types'; import { IPublicModelPluginContext, IPublicModelDocumentModel } from '@alilc/lowcode-types';
import { enUS, zhCN } from './locale'; import { enUS, zhCN } from './locale';
import { MasterPaneName, BackupPaneName } from './helper/consts'; import { MasterPaneName, BackupPaneName } from './helper/consts';
import { getTreeMaster } from './controllers/tree-master'; import { TreeMaster } from './controllers/tree-master';
import { PaneController } from './controllers/pane-controller'; import { PaneController } from './controllers/pane-controller';
export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => { export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
@ -26,7 +26,7 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
masterPane: false, masterPane: false,
backupPane: false, backupPane: false,
}; };
const treeMaster = getTreeMaster(ctx); const treeMaster = new TreeMaster(ctx);
let masterPaneController: PaneController | null = null; let masterPaneController: PaneController | null = null;
let backupPaneController: PaneController | null = null; let backupPaneController: PaneController | null = null;
return { return {

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-rax-renderer", "name": "@alilc/lowcode-rax-renderer",
"version": "1.1.0", "version": "1.1.1",
"description": "Rax renderer for Ali lowCode engine", "description": "Rax renderer for Ali lowCode engine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -30,8 +30,8 @@
"build": "build-scripts build" "build": "build-scripts build"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-renderer-core": "1.1.0", "@alilc/lowcode-renderer-core": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"rax-find-dom-node": "^1.0.1" "rax-find-dom-node": "^1.0.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-rax-simulator-renderer", "name": "@alilc/lowcode-rax-simulator-renderer",
"version": "1.1.0", "version": "1.1.1",
"description": "rax simulator renderer for alibaba lowcode designer", "description": "rax simulator renderer for alibaba lowcode designer",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -13,10 +13,10 @@
"build:umd": "build-scripts build --config build.umd.json" "build:umd": "build-scripts build --config build.umd.json"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@alilc/lowcode-rax-renderer": "1.1.0", "@alilc/lowcode-rax-renderer": "1.1.1",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"driver-universal": "^3.1.3", "driver-universal": "^3.1.3",
"history": "^5.0.0", "history": "^5.0.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-react-renderer", "name": "@alilc/lowcode-react-renderer",
"version": "1.1.0", "version": "1.1.1",
"description": "react renderer for ali lowcode engine", "description": "react renderer for ali lowcode engine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -22,7 +22,7 @@
], ],
"dependencies": { "dependencies": {
"@alifd/next": "^1.21.16", "@alifd/next": "^1.21.16",
"@alilc/lowcode-renderer-core": "1.1.0" "@alilc/lowcode-renderer-core": "1.1.1"
}, },
"devDependencies": { "devDependencies": {
"@alib/build-scripts": "^0.1.18", "@alib/build-scripts": "^0.1.18",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-react-simulator-renderer", "name": "@alilc/lowcode-react-simulator-renderer",
"version": "1.1.0", "version": "1.1.1",
"description": "react simulator renderer for alibaba lowcode designer", "description": "react simulator renderer for alibaba lowcode designer",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -17,10 +17,10 @@
"test:cov": "build-scripts test --config build.test.json --jest-coverage" "test:cov": "build-scripts test --config build.test.json --jest-coverage"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@alilc/lowcode-react-renderer": "1.1.0", "@alilc/lowcode-react-renderer": "1.1.1",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"mobx": "^6.3.0", "mobx": "^6.3.0",
"mobx-react": "^7.2.0", "mobx-react": "^7.2.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-renderer-core", "name": "@alilc/lowcode-renderer-core",
"version": "1.1.0", "version": "1.1.1",
"description": "renderer core", "description": "renderer core",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
@ -16,8 +16,8 @@
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-engine": "^1.0.0", "@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"debug": "^4.1.1", "debug": "^4.1.1",
"fetch-jsonp": "^1.1.3", "fetch-jsonp": "^1.1.3",
@ -32,7 +32,7 @@
"devDependencies": { "devDependencies": {
"@alib/build-scripts": "^0.1.18", "@alib/build-scripts": "^0.1.18",
"@alifd/next": "^1.26.0", "@alifd/next": "^1.26.0",
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@babel/plugin-transform-typescript": "^7.16.8", "@babel/plugin-transform-typescript": "^7.16.8",
"@testing-library/react": "^11.2.2", "@testing-library/react": "^11.2.2",
"@types/classnames": "^2.2.11", "@types/classnames": "^2.2.11",

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-shell", "name": "@alilc/lowcode-shell",
"version": "1.1.0", "version": "1.1.1",
"description": "Shell Layer for AliLowCodeEngine", "description": "Shell Layer for AliLowCodeEngine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -15,12 +15,12 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@alilc/lowcode-editor-core": "1.1.0", "@alilc/lowcode-editor-core": "1.1.1",
"@alilc/lowcode-editor-skeleton": "1.1.0", "@alilc/lowcode-editor-skeleton": "1.1.1",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"@alilc/lowcode-workspace": "1.1.0", "@alilc/lowcode-workspace": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5", "enzyme-adapter-react-16": "^1.15.5",

View File

@ -32,4 +32,12 @@ export class Resource implements IPublicModelResource {
get category() { get category() {
return this[resourceSymbol].category; return this[resourceSymbol].category;
} }
get children() {
return this[resourceSymbol].children.map((child) => new Resource(child));
}
get viewType() {
return this[resourceSymbol].viewType;
}
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-types", "name": "@alilc/lowcode-types",
"version": "1.1.0", "version": "1.1.1",
"description": "Types for Ali lowCode engine", "description": "Types for Ali lowCode engine",
"files": [ "files": [
"es", "es",

View File

@ -1,5 +1,5 @@
import { IPublicModelDragon, IPublicModelDropLocation, IPublicModelScrollTarget, IPublicTypeScrollable, IPublicModelScroller, IPublicModelActiveTracker, IPublicModelClipboard } from '../model'; import { IPublicModelDragon, IPublicModelDropLocation, IPublicModelScrollTarget, IPublicModelScroller, IPublicModelActiveTracker, IPublicModelClipboard } from '../model';
import { IPublicTypeLocationData } from '../type'; import { IPublicTypeLocationData, IPublicTypeScrollable } from '../type';
/** /**
* @since v1.1.0 * @since v1.1.0

View File

@ -20,21 +20,34 @@ export interface IPublicApiPlugins {
): Promise<void>; ): Promise<void>;
/** /**
* @deprecated use options instead *
* use this to get preference config for this plugin when engine.init() called
*/ */
getPluginPreference( getPluginPreference(
pluginName: string, pluginName: string,
): Record<string, IPublicTypePreferenceValueType> | null | undefined; ): Record<string, IPublicTypePreferenceValueType> | null | undefined;
/** 获取指定插件 */ /**
*
* get plugin instance by name
*/
get(pluginName: string): IPublicModelPluginInstance | null; get(pluginName: string): IPublicModelPluginInstance | null;
/** 获取所有的插件实例 */ /**
*
* get all plugin instances
*/
getAll(): IPublicModelPluginInstance[]; getAll(): IPublicModelPluginInstance[];
/** 判断是否有指定插件 */ /**
*
* check if plugin with certain name exists
*/
has(pluginName: string): boolean; has(pluginName: string): boolean;
/** 删除指定插件 */ /**
*
* delete plugin instance by name
*/
delete(pluginName: string): void; delete(pluginName: string): void;
} }

View File

@ -21,7 +21,7 @@ export interface IPublicApiWorkspace {
setResourceList(resourceList: IPublicResourceList): void; setResourceList(resourceList: IPublicResourceList): void;
/** 资源树列表更新事件 */ /** 资源树列表更新事件 */
onResourceListChange(fn: (resourceList: IPublicResourceList) => void): () => IPublicTypeDisposable; onResourceListChange(fn: (resourceList: IPublicResourceList) => void): IPublicTypeDisposable;
/** 注册资源 */ /** 注册资源 */
registerResourceType(resourceTypeModel: IPublicTypeResourceType): void; registerResourceType(resourceTypeModel: IPublicTypeResourceType): void;

View File

@ -14,11 +14,26 @@ import {
import { IPublicModelEngineConfig } from './'; import { IPublicModelEngineConfig } from './';
export interface IPublicModelPluginContext { 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 skeleton(): IPublicApiSkeleton;
get hotkey(): IPublicApiHotkey; get hotkey(): IPublicApiHotkey;
get setters(): IPublicApiSetters; get setters(): IPublicApiSetters;
get config(): IPublicModelEngineConfig; get config(): IPublicModelEngineConfig;
get material(): IPublicApiMaterial; get material(): IPublicApiMaterial;
/** /**
* this event works globally, can be used between plugins and engine. * this event works globally, can be used between plugins and engine.
*/ */
@ -33,8 +48,6 @@ export interface IPublicModelPluginContext {
*/ */
get pluginEvent(): IPublicApiEvent; get pluginEvent(): IPublicApiEvent;
get canvas(): IPublicApiCanvas; get canvas(): IPublicApiCanvas;
preference: IPluginPreferenceMananger;
[key: string]: any;
} }
/** /**

View File

@ -1,11 +1,28 @@
import { IPublicTypePluginMeta } from '../type/plugin-meta'; import { IPublicTypePluginMeta } from '../type/plugin-meta';
export interface IPublicModelPluginInstance { export interface IPublicModelPluginInstance {
pluginName: string;
dep: string[];
/**
* disable
* current plugin instance is disabled or not
*/
disabled: boolean; disabled: boolean;
meta: IPublicTypePluginMeta; /**
*
* plugin name
*/
get pluginName(): string;
/**
*
* depenency info
*/
get dep(): string[];
/**
*
* meta info of this plugin
*/
get meta(): IPublicTypePluginMeta;
} }

View File

@ -5,4 +5,7 @@ export interface IPublicEditorViewConfig {
/** 资源保存时,会调用视图的钩子 */ /** 资源保存时,会调用视图的钩子 */
save?: () => Promise<void>; save?: () => Promise<void>;
/** viewType 类型为 'webview' 时渲染的地址 */
url?: () => Promise<string>;
} }

View File

@ -1,10 +1,15 @@
import { ReactElement } from 'react';
export interface IPublicResourceData { export interface IPublicResourceData {
resourceName: string; resourceName: string;
title: string; title: string;
category?: string; category?: string;
viewType?: string;
icon?: ReactElement;
options: { options: {
[key: string]: any; [key: string]: any;
}; };
children?: IPublicResourceData[];
} }
export type IPublicResourceList = IPublicResourceData[]; export type IPublicResourceList = IPublicResourceData[];

View File

@ -28,4 +28,7 @@ export interface IPublicResourceTypeConfig {
/** 默认标题 */ /** 默认标题 */
defaultTitle?: string; defaultTitle?: string;
/** resourceType 类型为 'webview' 时渲染的地址 */
url?: () => Promise<string>;
} }

View File

@ -4,7 +4,7 @@ import { IPublicResourceTypeConfig } from './resource-type-config';
export interface IPublicTypeResourceType { export interface IPublicTypeResourceType {
resourceName: string; resourceName: string;
resourceType: string; resourceType: 'editor' | 'webview';
(ctx: IPublicModelPluginContext): IPublicResourceTypeConfig; (ctx: IPublicModelPluginContext, options: Object): IPublicResourceTypeConfig;
} }

View File

@ -1,8 +1,10 @@
import { IPublicTypeWidgetConfigArea } from './'; import { IPublicTypeWidgetConfigArea } from './';
export interface IPublicTypeWidgetBaseConfig { export interface IPublicTypeWidgetBaseConfig {
[extra: string]: any;
type: string; type: string;
name: string; name: string;
/** /**
* *
* - type 'Panel' 'leftFloatArea' * - type 'Panel' 'leftFloatArea'
@ -13,6 +15,29 @@ export interface IPublicTypeWidgetBaseConfig {
props?: Record<string, any>; props?: Record<string, any>;
content?: any; content?: any;
contentProps?: Record<string, any>; contentProps?: Record<string, any>;
// 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;

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-utils", "name": "@alilc/lowcode-utils",
"version": "1.1.0", "version": "1.1.1",
"description": "Utils for Ali lowCode engine", "description": "Utils for Ali lowCode engine",
"files": [ "files": [
"lib", "lib",
@ -14,7 +14,7 @@
}, },
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.16", "@alifd/next": "^1.19.16",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mobx": "^6.3.0", "mobx": "^6.3.0",
"react": "^16" "react": "^16"

View File

@ -1,6 +1,6 @@
{ {
"name": "@alilc/lowcode-workspace", "name": "@alilc/lowcode-workspace",
"version": "1.1.0", "version": "1.1.1",
"description": "Shell Layer for AliLowCodeEngine", "description": "Shell Layer for AliLowCodeEngine",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -15,11 +15,11 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alilc/lowcode-designer": "1.1.0", "@alilc/lowcode-designer": "1.1.1",
"@alilc/lowcode-editor-core": "1.1.0", "@alilc/lowcode-editor-core": "1.1.1",
"@alilc/lowcode-editor-skeleton": "1.1.0", "@alilc/lowcode-editor-skeleton": "1.1.1",
"@alilc/lowcode-types": "1.1.0", "@alilc/lowcode-types": "1.1.1",
"@alilc/lowcode-utils": "1.1.0", "@alilc/lowcode-utils": "1.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5", "enzyme-adapter-react-16": "^1.15.5",

View File

@ -28,18 +28,22 @@ import {
Canvas, Canvas,
} from '@alilc/lowcode-shell'; } from '@alilc/lowcode-shell';
import { import {
IPluginPreferenceMananger,
IPublicApiEvent,
IPublicModelPluginContext,
IPublicTypePluginMeta, IPublicTypePluginMeta,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import { getLogger } from '@alilc/lowcode-utils'; import { getLogger } from '@alilc/lowcode-utils';
import { Workspace as InnerWorkspace } from '../workspace'; import { Workspace as InnerWorkspace } from '../workspace';
import { EditorWindow } from '../window'; import { EditorWindow } from '../window';
export class BasicContext { export class BasicContext implements IPublicModelPluginContext {
skeleton: Skeleton; skeleton: Skeleton;
plugins: Plugins; plugins: Plugins;
project: Project; project: Project;
setters: Setters; setters: Setters;
material: Material; material: Material;
common: Common;
config; config;
event; event;
logger; logger;
@ -53,6 +57,8 @@ export class BasicContext {
innerHotkey: InnerHotkey; innerHotkey: InnerHotkey;
innerPlugins: LowCodePluginManager; innerPlugins: LowCodePluginManager;
canvas: Canvas; canvas: Canvas;
pluginEvent: IPublicApiEvent;
preference: IPluginPreferenceMananger;
constructor(innerWorkspace: InnerWorkspace, viewName: string, public editorWindow?: EditorWindow) { constructor(innerWorkspace: InnerWorkspace, viewName: string, public editorWindow?: EditorWindow) {
const editor = new Editor(viewName, true); const editor = new Editor(viewName, true);
@ -101,6 +107,7 @@ export class BasicContext {
this.designer = designer; this.designer = designer;
this.canvas = canvas; this.canvas = canvas;
const common = new Common(editor, innerSkeleton); const common = new Common(editor, innerSkeleton);
this.common = common;
let plugins: any; let plugins: any;
const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = { const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {

View File

@ -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 { IPublicEditorViewConfig, IPublicTypeEditorView } from '@alilc/lowcode-types';
import { flow } from 'mobx'; import { flow } from 'mobx';
import { Workspace as InnerWorkspace } from '../workspace'; import { Workspace as InnerWorkspace } from '../workspace';
@ -17,7 +17,7 @@ export class Context extends BasicContext {
@obx isInit: boolean = false; @obx isInit: boolean = false;
get active() { @computed get active() {
return this._activate; return this._activate;
} }
@ -33,7 +33,7 @@ export class Context extends BasicContext {
this.isInit = true; 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); super(workspace, editorView.viewName, editorWindow);
this.viewType = editorView.viewType || 'editor'; this.viewType = editorView.viewType || 'editor';
this.viewName = editorView.viewName; this.viewName = editorView.viewName;

View File

@ -1,6 +1,6 @@
import { IPublicModelPluginContext } from '@alilc/lowcode-types'; import { IPublicModelPluginContext } from '@alilc/lowcode-types';
function DesignerView(props: { export function DesignerView(props: {
url: string; url: string;
viewName: string; viewName: string;
}) { }) {

View File

@ -17,12 +17,16 @@ export class Resource implements IPublicModelResource {
return this.resourceType.name; return this.resourceType.name;
} }
get viewType() {
return this.resourceData.viewType;
}
get description() { get description() {
return this.resourceTypeInstance?.description; return this.resourceTypeInstance?.description;
} }
get icon() { get icon() {
return this.resourceTypeInstance?.icon; return this.resourceData.icon || this.resourceTypeInstance?.icon;
} }
get type() { get type() {
@ -45,9 +49,13 @@ export class Resource implements IPublicModelResource {
return this.context.innerSkeleton; 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.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(); this.init();
if (this.resourceTypeInstance.editorViews) { if (this.resourceTypeInstance.editorViews) {
this.resourceTypeInstance.editorViews.forEach((d: any) => { this.resourceTypeInstance.editorViews.forEach((d: any) => {
@ -68,6 +76,10 @@ export class Resource implements IPublicModelResource {
return await this.resourceTypeInstance.import?.(schema); return await this.resourceTypeInstance.import?.(schema);
} }
async url() {
return await this.resourceTypeInstance.url?.();
}
async save(value: any) { async save(value: any) {
return await this.resourceTypeInstance.save?.(value); return await this.resourceTypeInstance.save?.(value);
} }

View File

@ -3,6 +3,7 @@ import { ResourceView } from './resource-view';
import { engineConfig, observer } from '@alilc/lowcode-editor-core'; import { engineConfig, observer } from '@alilc/lowcode-editor-core';
import { EditorWindow } from '../window'; import { EditorWindow } from '../window';
import { BuiltinLoading } from '@alilc/lowcode-designer'; import { BuiltinLoading } from '@alilc/lowcode-designer';
import { DesignerView } from '../inner-plugins/webview';
@observer @observer
export class WindowView extends PureComponent<{ export class WindowView extends PureComponent<{
@ -11,16 +12,21 @@ export class WindowView extends PureComponent<{
}, any> { }, any> {
render() { render() {
const { active } = this.props; const { active } = this.props;
const { editorView, resource } = this.props.window; const { resource, initReady, url } = this.props.window;
if (!editorView) {
if (!initReady) {
const Loading = engineConfig.get('loadingComponent', BuiltinLoading); const Loading = engineConfig.get('loadingComponent', BuiltinLoading);
return ( return (
<div className={`workspace-engine-main ${active ? 'active' : ''}`}> <div className={`workspace-engine-main 111 ${active ? 'active' : ''}`}>
<Loading /> <Loading />
</div> </div>
); );
} }
if (resource.type === 'webview' && url) {
return <DesignerView url={url} viewName={resource.name} />;
}
return ( return (
<div className={`workspace-engine-main ${active ? 'active' : ''}`}> <div className={`workspace-engine-main ${active ? 'active' : ''}`}>
<ResourceView <ResourceView

View File

@ -5,19 +5,32 @@ import { Workspace } from './workspace';
import { Resource } from './resource'; import { Resource } from './resource';
import { IPublicTypeDisposable } from '../../types/es/shell/type/disposable'; import { IPublicTypeDisposable } from '../../types/es/shell/type/disposable';
interface IWindowCOnfig {
title: string | undefined;
options?: Object;
viewType?: string | undefined;
}
export class EditorWindow { export class EditorWindow {
id: string = uniqueId('window'); id: string = uniqueId('window');
icon: React.ReactElement | undefined; icon: React.ReactElement | undefined;
private emitter: IEventBus = createModuleEventBus('Project'); private emitter: IEventBus = createModuleEventBus('Project');
title: string | undefined;
url: string | undefined;
@obx.ref editorView: Context; @obx.ref editorView: Context;
@obx editorViews: Map<string, Context> = new Map<string, Context>(); @obx editorViews: Map<string, Context> = new Map<string, Context>();
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); makeObservable(this);
this.init(); this.init();
this.title = config.title;
this.icon = resource.icon; this.icon = resource.icon;
} }
@ -48,11 +61,16 @@ export class EditorWindow {
async init() { async init() {
await this.initViewTypes(); await this.initViewTypes();
await this.execViewTypesInit(); await this.execViewTypesInit();
this.url = await this.resource.url();
this.setDefaultViewType(); this.setDefaultViewType();
this.initReady = true;
} }
initViewTypes = async () => { initViewTypes = async () => {
const editorViews = this.resource.editorViews; const editorViews = this.resource.editorViews;
if (!editorViews) {
return;
}
for (let i = 0; i < editorViews.length; i++) { for (let i = 0; i < editorViews.length; i++) {
const name = editorViews[i].viewName; const name = editorViews[i].viewName;
await this.initViewType(name); await this.initViewType(name);
@ -72,6 +90,9 @@ export class EditorWindow {
execViewTypesInit = async () => { execViewTypesInit = async () => {
const editorViews = this.resource.editorViews; const editorViews = this.resource.editorViews;
if (!editorViews) {
return;
}
for (let i = 0; i < editorViews.length; i++) { for (let i = 0; i < editorViews.length; i++) {
const name = editorViews[i].viewName; const name = editorViews[i].viewName;
this.changeViewType(name); this.changeViewType(name);
@ -80,15 +101,19 @@ export class EditorWindow {
}; };
setDefaultViewType = () => { 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) => { initViewType = async (name: string) => {
const viewInfo = this.resource.getEditorView(name); const viewInfo = this.resource.getEditorView(name);
if (this.editorViews.get(name)) { if (this.editorViews.get(name)) {
return; 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); this.editorViews.set(name, editorView);
}; };
@ -96,6 +121,10 @@ export class EditorWindow {
this.editorView?.setActivate(false); this.editorView?.setActivate(false);
this.editorView = this.editorViews.get(name)!; this.editorView = this.editorViews.get(name)!;
if (!this.editorView) {
return;
}
if (!ignoreEmit) { if (!ignoreEmit) {
this.emitter.emit('window.change.view.type', name); this.emitter.emit('window.change.view.type', name);
} }

View File

@ -46,7 +46,7 @@ export class Workspace implements IPublicApiWorkspace {
return null; return null;
} }
windows: EditorWindow[] = []; @obx.ref windows: EditorWindow[] = [];
editorWindowMap: Map<string, EditorWindow> = new Map<string, EditorWindow>(); editorWindowMap: Map<string, EditorWindow> = new Map<string, EditorWindow>();
@ -71,7 +71,9 @@ export class Workspace implements IPublicApiWorkspace {
} }
const title = this.defaultResourceType.name; const title = this.defaultResourceType.name;
const resource = new Resource({}, this.defaultResourceType, this); 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.editorWindowMap.set(this.window.id, this.window);
this.windows.push(this.window); this.windows.push(this.window);
this.emitChangeWindow(); this.emitChangeWindow();
@ -83,13 +85,11 @@ export class Workspace implements IPublicApiWorkspace {
} }
async registerResourceType(resourceTypeModel: IPublicTypeResourceType): Promise<void> { async registerResourceType(resourceTypeModel: IPublicTypeResourceType): Promise<void> {
if (resourceTypeModel.resourceType === 'editor') { const resourceType = new ResourceType(resourceTypeModel);
const resourceType = new ResourceType(resourceTypeModel); this.resourceTypeMap.set(resourceTypeModel.resourceName, resourceType);
this.resourceTypeMap.set(resourceTypeModel.resourceName, resourceType);
if (!this.window && this.defaultResourceType) { if (!this.window && this.defaultResourceType) {
this.initWindow(); this.initWindow();
}
} }
} }
@ -150,7 +150,7 @@ export class Workspace implements IPublicApiWorkspace {
openEditorWindow(name: string, title: string, options: Object, viewType?: string) { openEditorWindow(name: string, title: string, options: Object, viewType?: string) {
const resourceType = this.resourceTypeMap.get(name); const resourceType = this.resourceTypeMap.get(name);
if (!resourceType) { if (!resourceType) {
console.error(`${name} is not available`); console.error(`${name} resourceType is not available`);
return; return;
} }
const filterWindows = this.windows.filter(d => (d.resource.name === name && d.resource.title == title)); const filterWindows = this.windows.filter(d => (d.resource.name === name && d.resource.title == title));
@ -164,8 +164,12 @@ export class Workspace implements IPublicApiWorkspace {
title, title,
options, options,
}, resourceType, this); }, resourceType, this);
this.window = new EditorWindow(resource, this, title, options); this.window = new EditorWindow(resource, this, {
this.windows.push(this.window); title,
options,
viewType,
});
this.windows = [...this.windows, this.window];
this.editorWindowMap.set(this.window.id, this.window); this.editorWindowMap.set(this.window.id, this.window);
this.emitChangeWindow(); this.emitChangeWindow();
this.emitChangeActiveWindow(); this.emitChangeActiveWindow();