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) => {
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<string, IPublicTypePreferenceValueType> | null | undefined;
```
## 相关类型定义

View File

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

View File

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

View File

@ -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",

View File

@ -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 {

View File

@ -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",

View File

@ -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"

View File

@ -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"
},

View File

@ -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 });
@ -195,6 +195,7 @@ export async function init(
engineContainer,
);
innerWorkspace.setActive(true);
innerHotkey.activate(false);
await innerWorkspace.plugins.init(pluginPreference);
return;
}

View File

@ -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,

View File

@ -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"
},

View File

@ -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",

View File

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

View File

@ -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": {

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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;
}
}

View File

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

View File

@ -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

View File

@ -20,21 +20,34 @@ export interface IPublicApiPlugins {
): Promise<void>;
/**
* @deprecated use options instead
*
* use this to get preference config for this plugin when engine.init() called
*/
getPluginPreference(
pluginName: string,
): Record<string, IPublicTypePreferenceValueType> | 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;
}

View File

@ -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;

View File

@ -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;
}
/**

View File

@ -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;
/**
*
* 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>;
/** viewType 类型为 'webview' 时渲染的地址 */
url?: () => Promise<string>;
}

View File

@ -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[];

View File

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

View File

@ -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;
}

View File

@ -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<string, any>;
content?: 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",
"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"

View File

@ -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",

View File

@ -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 = {

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 { 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;

View File

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

View File

@ -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);
}

View File

@ -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 (
<div className={`workspace-engine-main ${active ? 'active' : ''}`}>
<div className={`workspace-engine-main 111 ${active ? 'active' : ''}`}>
<Loading />
</div>
);
}
if (resource.type === 'webview' && url) {
return <DesignerView url={url} viewName={resource.name} />;
}
return (
<div className={`workspace-engine-main ${active ? 'active' : ''}`}>
<ResourceView

View File

@ -5,19 +5,32 @@ import { Workspace } from './workspace';
import { Resource } from './resource';
import { IPublicTypeDisposable } from '../../types/es/shell/type/disposable';
interface IWindowCOnfig {
title: string | undefined;
options?: Object;
viewType?: string | undefined;
}
export class EditorWindow {
id: string = uniqueId('window');
icon: React.ReactElement | undefined;
private emitter: IEventBus = createModuleEventBus('Project');
title: string | undefined;
url: string | undefined;
@obx.ref editorView: 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);
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);
}

View File

@ -46,7 +46,7 @@ export class Workspace implements IPublicApiWorkspace {
return null;
}
windows: EditorWindow[] = [];
@obx.ref windows: EditorWindow[] = [];
editorWindowMap: Map<string, EditorWindow> = new Map<string, EditorWindow>();
@ -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,7 +85,6 @@ export class Workspace implements IPublicApiWorkspace {
}
async registerResourceType(resourceTypeModel: IPublicTypeResourceType): Promise<void> {
if (resourceTypeModel.resourceType === 'editor') {
const resourceType = new ResourceType(resourceTypeModel);
this.resourceTypeMap.set(resourceTypeModel.resourceName, resourceType);
@ -91,7 +92,6 @@ export class Workspace implements IPublicApiWorkspace {
this.initWindow();
}
}
}
getResourceList() {
return this.resourceList;
@ -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();