Compare commits

...

21 Commits

Author SHA1 Message Date
JackLian
d53d5bbe8b chore(release): publish 1.1.7-beta.9 2023-04-19 16:44:13 +08:00
LeoYuan 袁力皓
032606edf0 chore: add awesome badge for exploring LCE ecosystem 2023-04-19 16:42:08 +08:00
liujuping
83267dd68e feat(workspace): add enableAutoOpenFirstWindow config and onWindowRendererReady function 2023-04-19 16:42:08 +08:00
liujuping
1bdc1065d7 fix(prop): fix prop.export can not correctly export undefined[] 2023-04-19 16:42:08 +08:00
liujuping
e0a01890e4 docs(config): add demo for config.getPreference api 2023-04-19 16:42:08 +08:00
JackLian
20e67e85c1 chore(release): publish 1.1.7-beta.8 2023-04-18 14:27:10 +08:00
JackLian
fdb74f0aeb chore(release): publish 1.1.7-beta.7 2023-04-18 14:26:41 +08:00
liujuping
e4f5ff5010 feat(material): material apis add refreshComponentMetasMap function 2023-04-18 14:20:48 +08:00
JackLian
0254aa8b01 chore(release): publish 1.1.7-beta.6 2023-04-18 09:29:57 +08:00
liujuping
13c5c21a10 feat: remove editor api 2023-04-18 09:27:46 +08:00
liujuping
b0bef21b05 feat(renderer-core): added log when executing setState 2023-04-18 09:27:46 +08:00
JackLian
3f30f840eb chore(release): publish 1.1.7-beta.5 2023-04-17 17:32:33 +08:00
JackLian
1f81f0d85c chore(release): publish 1.1.7-beta.4 2023-04-17 17:31:40 +08:00
JackLian
55534f00ce chore(release): publish 1.1.7-beta.3 2023-04-17 17:31:10 +08:00
liujuping
386db0ca9a feat(common): add some api to be compatible with old platforms 2023-04-17 17:29:11 +08:00
JackLian
309f392b6e chore(release): publish 1.1.7-beta.2 2023-04-17 15:10:13 +08:00
liujuping
c64647bf2b fix(utils): isReactComponent not including react.memo 2023-04-17 15:08:07 +08:00
JackLian
d60eceda46 chore(release): publish 1.1.7-beta.1 2023-04-14 08:17:33 +08:00
liujuping
07f4d68781 fix: fix that the outline tree does not respond to modal addition/deletion related operations 2023-04-14 08:11:44 +08:00
liujuping
e977715b86 feat: added features in workspace mode 2023-04-14 08:11:44 +08:00
JackLian
778c8a5d58 chore(release): publish 1.1.7-beta.0 2023-04-12 10:25:00 +08:00
60 changed files with 552 additions and 176 deletions

View File

@ -91,6 +91,6 @@ cov-utils:
- uses: ArtiomTr/jest-coverage-report-action@v2
with:
working-directory: packages/utils
test-script: npm test
test-script: npm test -- --jest-ci --jest-json --jest-coverage --jest-testLocationInResults --jest-outputFile=report.json
package-manager: yarn
annotations: none

View File

@ -43,7 +43,7 @@ jobs:
- name: test
run: cd packages/designer && npm test
editor-skeleton:
test-editor-skeleton:
runs-on: ubuntu-latest
steps:
- name: checkout
@ -58,3 +58,51 @@ jobs:
- name: test
run: cd packages/editor-skeleton && npm test
test-renderer-core:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: install
run: npm i && npm run setup:skip-build
- name: test
run: cd packages/renderer-core && npm test
test-react-simulator-renderer:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: install
run: npm i && npm run setup:skip-build
- name: test
run: cd packages/react-simulator-renderer && npm test
test-utils:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: install
run: npm i && npm run setup:skip-build
- name: test
run: cd packages/utils && npm test

View File

@ -105,6 +105,17 @@ getPreference(): IPublicModelPreference;
**@since v1.1.0**
示例
```javascript
import { config } from '@alilc/lowcode-engine';
const panelName = 'outline-master-pane';
// 设置大纲树面板钉住,在大纲树下次重新打开时生效
config.getPreference().set(`${panelName}-pinned-status-isFloat`, false, 'skeleton')
```
## 事件
### onceGot

View File

@ -245,6 +245,7 @@ material.getComponentMeta('Input');
```
#### getComponentMetasMap
获取所有已注册的物料元数据
```typescript
@ -264,6 +265,15 @@ import { material } from '@alilc/lowcode-engine';
material.getComponentMetasMap();
```
#### refreshComponentMetasMap
刷新 componentMetasMap可触发模拟器里的 components 重新构建
**@since v1.1.7**
```typescript
refreshComponentMetasMap(): void;
```
### 物料元数据管道函数
#### registerMetadataTransducer

View File

@ -1,6 +1,6 @@
{
"lerna": "4.0.0",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-designer",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-types": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-editor-core": "1.1.7-beta.9",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"classnames": "^2.2.6",
"react": "^16",
"react-dom": "^16.7.0",
@ -52,5 +52,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/designer"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -20,7 +20,9 @@ export function createSimulator(
): Promise<BuiltinSimulatorRenderer> {
const win: any = iframe.contentWindow;
const doc = iframe.contentDocument!;
const innerPlugins = host.designer.editor.get('innerPlugins');
win.AliLowCodeEngine = innerPlugins._getLowCodePluginContext({});
win.LCSimulatorHost = host;
win._ = window._;

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { observer, globalContext } from '@alilc/lowcode-editor-core';
import { observer } from '@alilc/lowcode-editor-core';
import { BuiltinSimulatorHost, BuiltinSimulatorProps } from './host';
import { BemTools } from './bem-tools';
import { Project } from '../project';
@ -76,8 +76,7 @@ class Content extends Component<{ host: BuiltinSimulatorHost }> {
private dispose?: () => void;
componentDidMount() {
const workspace = globalContext.get('workspace');
const editor = workspace.isActive ? workspace.window.editor : globalContext.get('editor');
const editor = this.props.host.designer.editor;
const onEnableEvents = (type: boolean) => {
this.setState({
disabledEvents: type,

View File

@ -336,13 +336,9 @@ export class Prop implements IProp, IPropParent {
if (!this._items) {
return this._value;
}
const values = this.items!.map((prop) => {
return this.items!.map((prop) => {
return prop?.export(stage);
});
if (values.every((val) => val === undefined)) {
return undefined;
}
return values;
}
}

View File

@ -16,6 +16,7 @@ import {
IPublicApiWorkspace,
IPublicTypePluginMeta,
IPublicTypePluginRegisterOptions,
IPublicModelWindow,
} from '@alilc/lowcode-types';
import PluginContext from './plugin-context';
@ -56,6 +57,7 @@ export interface ILowCodePluginContextPrivate {
set pluginEvent(event: IPublicApiEvent);
set canvas(canvas: IPublicApiCanvas);
set workspace(workspace: IPublicApiWorkspace);
set editorWindow(window: IPublicModelWindow);
}
export interface ILowCodePluginContextApiAssembler {
assembleApis(

View File

@ -1,3 +1,4 @@
import { IPublicTypePluginMeta } from './../../../../lib/packages/types/src/shell/type/plugin-meta.d';
import '../fixtures/window';
import {
Editor,
@ -22,6 +23,7 @@ import { BuiltinSimulatorHost } from '../../src/builtin-simulator/host';
import { fireEvent } from '@testing-library/react';
import { shellModelFactory } from '../../../engine/src/modules/shell-model-factory';
import { Setters, Workspace } from '@alilc/lowcode-shell';
import { ILowCodePluginContextApiAssembler, ILowCodePluginContextPrivate, LowCodePluginManager } from '@alilc/lowcode-designer';
describe('Host 测试', () => {
let editor: Editor;
@ -32,10 +34,20 @@ describe('Host 测试', () => {
beforeAll(() => {
editor = new Editor();
const innerWorkspace = new InnerWorkspace();
const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
assembleApis: (context: ILowCodePluginContextPrivate, pluginName: string, meta: IPublicTypePluginMeta) => {
context.project = project;
const eventPrefix = meta?.eventPrefix || 'common';
context.workspace = workspace;
},
};
const innerPlugins = new LowCodePluginManager(pluginContextApiAssembler);
const innerWorkspace = new InnerWorkspace(() => {}, {});
const workspace = new Workspace(innerWorkspace);
editor.set('innerHotkey', new InnerHotkey())
editor.set('setters', new Setters(new InnerSetters()));
editor.set('innerPlugins' as any, innerPlugins);
!globalContext.has(Editor) && globalContext.register(editor, Editor);
!globalContext.has('workspace') && globalContext.register(innerWorkspace, 'workspace');
});

View File

@ -435,7 +435,7 @@ describe('Prop 类测试', () => {
it('should return undefined when all items are undefined', () => {
prop = new Prop(mockPropsInst, [undefined, undefined], '___loopArgs___');
expect(prop.getValue()).toBeUndefined();
expect(prop.getValue()).toEqual([undefined, undefined]);
});
it('迭代器 / map / forEach', () => {

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-editor-core",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"classnames": "^2.2.6",
"debug": "^4.1.1",
"intl-messageformat": "^9.3.1",
@ -47,5 +47,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/editor-core"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -145,6 +145,11 @@ const VALID_ENGINE_OPTIONS = {
type: 'function',
description: '配置指定节点为根组件',
},
enableAutoOpenFirstWindow: {
type: 'boolean',
description: '应用级设计模式下,自动打开第一个窗口',
default: true,
},
};
const getStrictModeValue = (engineOptions: IPublicTypeEngineOptions, defaultValue: boolean): boolean => {

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-editor-skeleton",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"description": "alibaba lowcode editor skeleton",
"main": "lib/index.js",
"module": "es/index.js",
@ -19,10 +19,10 @@
],
"dependencies": {
"@alifd/next": "^1.20.12",
"@alilc/lowcode-designer": "1.1.6",
"@alilc/lowcode-editor-core": "1.1.6",
"@alilc/lowcode-types": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@alilc/lowcode-editor-core": "1.1.7-beta.9",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"classnames": "^2.2.6",
"react": "^16.8.1",
"react-dom": "^16.8.1"
@ -42,5 +42,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/editor-skeleton"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -1,5 +1,5 @@
import { Component, MouseEvent, Fragment } from 'react';
import { shallowIntl, observer, obx, engineConfig, runInAction, globalContext } from '@alilc/lowcode-editor-core';
import { shallowIntl, observer, obx, engineConfig, runInAction } from '@alilc/lowcode-editor-core';
import { createContent, isJSSlot, isSetterConfig } from '@alilc/lowcode-utils';
import { Skeleton, Stage } from '@alilc/lowcode-editor-skeleton';
import { IPublicTypeCustomView } from '@alilc/lowcode-types';
@ -40,7 +40,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
stageName: string | undefined;
setters: Setters;
setters?: Setters;
constructor(props: SettingFieldViewProps) {
super(props);
@ -49,10 +49,10 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
const { extraProps } = field;
const { display } = extraProps;
const workspace = globalContext.get('workspace');
const editor = workspace.isActive ? workspace.window.editor : globalContext.get('editor');
const { stages } = editor.get('skeleton') as Skeleton;
this.setters = editor.get('setters');
const editor = field.designer?.editor;
const skeleton = editor?.get('skeleton') as Skeleton;
const { stages } = skeleton || {};
this.setters = editor?.get('setters');
let stageName;
if (display === 'entry') {
runInAction(() => {
@ -291,9 +291,8 @@ class SettingGroupView extends Component<SettingGroupViewProps> {
const { field } = this.props;
const { extraProps } = field;
const { display } = extraProps;
const workspace = globalContext.get('workspace');
const editor = workspace.isActive ? workspace.window.editor : globalContext.get('editor');
const { stages } = editor.get('skeleton') as Skeleton;
const editor = this.props.field.designer?.editor;
const { stages } = editor?.get('skeleton') as Skeleton;
// const items = field.items;
let stageName;
@ -343,15 +342,15 @@ class SettingGroupView extends Component<SettingGroupViewProps> {
}
}
export function createSettingFieldView(item: ISettingField | IPublicTypeCustomView, field: ISettingEntry, index?: number) {
if (isSettingField(item)) {
if (item.isGroup) {
return <SettingGroupView field={item} key={item.id} />;
export function createSettingFieldView(field: ISettingField | IPublicTypeCustomView, fieldEntry: ISettingEntry, index?: number) {
if (isSettingField(field)) {
if (field.isGroup) {
return <SettingGroupView field={field} key={field.id} />;
} else {
return <SettingFieldView field={item} key={item.id} />;
return <SettingFieldView field={field} key={field.id} />;
}
} else {
return createContent(item, { key: index, field });
return createContent(field, { key: index, field: fieldEntry });
}
}

View File

@ -14,7 +14,7 @@
[![][issues-helper-image]][issues-helper-url] [![Issues need help][help-wanted-image]][help-wanted-url]
[![codecov][codecov-image-url]][codecov-url]
[![codecov][codecov-image-url]][codecov-url] [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/lowcode-workspace/awesome-lowcode-engine)
[![](https://img.shields.io/badge/LowCodeEngine-%E6%9F%A5%E7%9C%8B%E8%B4%A1%E7%8C%AE%E6%8E%92%E8%A1%8C%E6%A6%9C-orange)](https://opensource.alibaba.com/contribution_leaderboard/details?projectValue=lowcode-engine)

View File

@ -14,7 +14,7 @@ An enterprise-class low-code technology stack with scale-out design
[![][issues-helper-image]][issues-helper-url] [![Issues need help][help-wanted-image]][help-wanted-url]
[![codecov][codecov-image-url]][codecov-url]
[![codecov][codecov-image-url]][codecov-url] [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/lowcode-workspace/awesome-lowcode-engine)
[![](https://img.shields.io/badge/LowCodeEngine-Check%20Your%20Contribution-orange)](https://opensource.alibaba.com/contribution_leaderboard/details?projectValue=lowcode-engine)

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-engine",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-editor-core": "1.1.6",
"@alilc/lowcode-editor-skeleton": "1.1.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@alilc/lowcode-editor-core": "1.1.7-beta.9",
"@alilc/lowcode-editor-skeleton": "1.1.7-beta.9",
"@alilc/lowcode-engine-ext": "^1.0.0",
"@alilc/lowcode-plugin-designer": "1.1.6",
"@alilc/lowcode-plugin-outline-pane": "1.1.6",
"@alilc/lowcode-shell": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-workspace": "1.1.6",
"@alilc/lowcode-plugin-designer": "1.1.7-beta.9",
"@alilc/lowcode-plugin-outline-pane": "1.1.7-beta.9",
"@alilc/lowcode-shell": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"@alilc/lowcode-workspace": "1.1.7-beta.9",
"react": "^16.8.1",
"react-dom": "^16.8.1"
},
@ -53,5 +53,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/engine"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -9,11 +9,15 @@ import {
engineConfig,
Setters as InnerSetters,
Hotkey as InnerHotkey,
IEditor,
} from '@alilc/lowcode-editor-core';
import {
IPublicTypeEngineOptions,
IPublicModelDocumentModel,
IPublicTypePluginMeta,
IPublicTypeDisposable,
IPublicApiPlugins,
IPublicApiWorkspace,
} from '@alilc/lowcode-types';
import {
Designer,
@ -21,6 +25,7 @@ import {
ILowCodePluginContextPrivate,
ILowCodePluginContextApiAssembler,
PluginPreference,
IDesigner,
} from '@alilc/lowcode-designer';
import {
Skeleton as InnerSkeleton,
@ -29,6 +34,7 @@ import {
import {
Workspace as InnerWorkspace,
Workbench as WorkSpaceWorkbench,
IWorkspace,
} from '@alilc/lowcode-workspace';
import {
@ -60,18 +66,30 @@ export * from './modules/skeleton-types';
export * from './modules/designer-types';
export * from './modules/lowcode-types';
async function registryInnerPlugin(designer: Designer, editor: Editor, plugins: Plugins) {
async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins: IPublicApiPlugins): Promise<IPublicTypeDisposable> {
// 注册一批内置插件
const componentMetaParserPlugin = componentMetaParser(designer);
const defaultPanelRegistryPlugin = defaultPanelRegistry(editor);
await plugins.register(OutlinePlugin, {}, { autoInit: true });
await plugins.register(componentMetaParser(designer));
await plugins.register(componentMetaParserPlugin);
await plugins.register(setterRegistry, {});
await plugins.register(defaultPanelRegistry(editor));
await plugins.register(defaultPanelRegistryPlugin);
await plugins.register(builtinHotkey);
await plugins.register(registerDefaults, {}, { autoInit: true });
return () => {
plugins.delete(OutlinePlugin.pluginName);
plugins.delete(componentMetaParserPlugin.pluginName);
plugins.delete(setterRegistry.pluginName);
plugins.delete(defaultPanelRegistryPlugin.pluginName);
plugins.delete(defaultPanelRegistryPlugin.pluginName);
plugins.delete(builtinHotkey.pluginName);
plugins.delete(registerDefaults.pluginName);
};
}
const innerWorkspace = new InnerWorkspace(registryInnerPlugin, shellModelFactory);
const workspace = new Workspace(innerWorkspace);
const innerWorkspace: IWorkspace = new InnerWorkspace(registryInnerPlugin, shellModelFactory);
const workspace: IPublicApiWorkspace = new Workspace(innerWorkspace);
const editor = new Editor();
globalContext.register(editor, Editor);
globalContext.register(editor, 'editor');
@ -139,8 +157,6 @@ export {
logger,
hotkey,
common,
// 兼容原 editor 的事件功能
event as editor,
workspace,
canvas,
};
@ -158,7 +174,7 @@ let engineContainer: HTMLElement;
export const version = VERSION_PLACEHOLDER;
engineConfig.set('ENGINE_VERSION', version);
registryInnerPlugin(designer, editor, plugins);
const pluginPromise = registryInnerPlugin(designer, editor, plugins);
export async function init(
container?: HTMLElement,
@ -183,10 +199,10 @@ export async function init(
}
engineConfig.setEngineOptions(engineOptions as any);
await plugins.init(pluginPreference as any);
const { Workbench } = common.skeletonCabin;
if (options && options.enableWorkspaceMode) {
const disposeFun = await pluginPromise;
disposeFun && disposeFun();
render(
createElement(WorkSpaceWorkbench, {
workspace: innerWorkspace,
@ -196,12 +212,16 @@ export async function init(
}),
engineContainer,
);
innerWorkspace.enableAutoOpenFirstWindow = engineConfig.get('enableAutoOpenFirstWindow', true);
innerWorkspace.setActive(true);
innerWorkspace.initWindow();
innerHotkey.activate(false);
await innerWorkspace.plugins.init(pluginPreference);
return;
}
await plugins.init(pluginPreference as any);
render(
createElement(Workbench, {
skeleton: innerSkeleton,

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-plugin-designer",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"description": "alibaba lowcode editor designer plugin",
"files": [
"es",
@ -18,9 +18,9 @@
],
"author": "xiayang.xy",
"dependencies": {
"@alilc/lowcode-designer": "1.1.6",
"@alilc/lowcode-editor-core": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@alilc/lowcode-editor-core": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"react": "^16.8.1",
"react-dom": "^16.8.1"
},
@ -37,5 +37,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/plugin-designer"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-plugin-outline-pane",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"description": "Outline pane for Ali lowCode engine",
"files": [
"es",
@ -13,10 +13,10 @@
},
"dependencies": {
"@alifd/next": "^1.19.16",
"@alilc/lowcode-designer": "1.1.6",
"@alilc/lowcode-editor-core": "1.1.6",
"@alilc/lowcode-types": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@alilc/lowcode-editor-core": "1.1.7-beta.9",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"classnames": "^2.2.6",
"react": "^16",
"react-dom": "^16.7.0",
@ -40,5 +40,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/plugin-outline-pane"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -9,6 +9,8 @@ import { IPublicModelPluginContext, IPublicModelModalNodesManager, IPublicTypeDi
class ModalTreeNodeView extends PureComponent<{
treeNode: TreeNode;
pluginContext: IPublicModelPluginContext;
}, {
treeChildren: TreeNode[] | null;
}> {
private modalNodesManager: IPublicModelModalNodesManager | undefined | null;
readonly pluginContext: IPublicModelPluginContext;
@ -20,18 +22,36 @@ class ModalTreeNodeView extends PureComponent<{
this.pluginContext = props.pluginContext;
const { project } = this.pluginContext;
this.modalNodesManager = project.currentDocument?.modalNodesManager;
this.state = {
treeChildren: this.rootTreeNode.children,
};
}
hideAllNodes() {
this.modalNodesManager?.hideModalNodes();
}
render() {
componentDidMount(): void {
const rootTreeNode = this.rootTreeNode;
rootTreeNode.onExpandableChanged(() => {
this.setState({
treeChildren: rootTreeNode.children,
});
});
}
get rootTreeNode() {
const { treeNode } = this.props;
// 当指定了新的根节点时,要从原始的根节点去获取模态节点
const { project } = this.pluginContext;
const rootNode = project.currentDocument?.root;
const rootTreeNode = treeNode.tree.getTreeNode(rootNode!);
return rootTreeNode;
}
render() {
const rootTreeNode = this.rootTreeNode;
const { expanded } = rootTreeNode;
const hasVisibleModalNode = !!this.modalNodesManager?.getVisibleModalNode();
@ -49,7 +69,7 @@ class ModalTreeNodeView extends PureComponent<{
<div className="tree-pane-modal-content">
<TreeBranches
treeNode={rootTreeNode}
treeChildren={rootTreeNode.children}
treeChildren={this.state.treeChildren}
expanded={expanded}
isModal
pluginContext={this.pluginContext}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-rax-renderer",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-renderer-core": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"rax-find-dom-node": "^1.0.1"
},
"devDependencies": {
@ -49,5 +49,5 @@
},
"license": "MIT",
"homepage": "https://unpkg.alibaba-inc.com/@alilc/lowcode-rax-renderer@0.1.2/build/index.html",
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-rax-simulator-renderer",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-rax-renderer": "1.1.6",
"@alilc/lowcode-types": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@alilc/lowcode-rax-renderer": "1.1.7-beta.9",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"classnames": "^2.2.6",
"driver-universal": "^3.1.3",
"history": "^5.0.0",
@ -50,5 +50,5 @@
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/rax-simulator-renderer"
},
"homepage": "https://unpkg.alibaba-inc.com/@alilc/lowcode-rax-simulator-renderer@1.0.73/build/index.html",
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-react-renderer",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6"
"@alilc/lowcode-renderer-core": "1.1.7-beta.9"
},
"devDependencies": {
"@alib/build-scripts": "^0.1.18",
@ -42,5 +42,5 @@
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/react-renderer"
},
"homepage": "https://unpkg.alibaba-inc.com/@alilc/lowcode-react-renderer@1.0.21/build/index.html",
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-react-simulator-renderer",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-react-renderer": "1.1.6",
"@alilc/lowcode-types": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@alilc/lowcode-react-renderer": "1.1.7-beta.9",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"classnames": "^2.2.6",
"mobx": "^6.3.0",
"mobx-react": "^7.2.0",
@ -43,5 +43,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/react-simulator-renderer"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -11,6 +11,7 @@ const jestConfig = {
// },
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
// testMatch: ['**/*/base.test.tsx'],
// testMatch: ['**/utils/common.test.ts'],
transformIgnorePatterns: [
`/node_modules/(?!${esModules})/`,
],

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-renderer-core",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@babel/plugin-transform-typescript": "^7.16.8",
"@testing-library/react": "^11.2.2",
"@types/classnames": "^2.2.11",
@ -55,5 +55,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/renderer-core"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -102,6 +102,9 @@ function initRerenderEvent({
return;
}
cache.event.get(schema.id)?.dispose.forEach((disposeFn: any) => disposeFn && disposeFn());
const debounceRerender = debounce(() => {
container.rerender();
}, 20);
cache.event.set(schema.id, {
clear: false,
leaf,
@ -111,21 +114,21 @@ function initRerenderEvent({
return;
}
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onPropsChange make rerender`);
container.rerender();
debounceRerender();
}),
leaf?.onChildrenChange?.(() => {
if (!container.autoRepaintNode) {
return;
}
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onChildrenChange make rerender`);
container.rerender();
debounceRerender();
}) as Function,
leaf?.onVisibleChange?.(() => {
if (!container.autoRepaintNode) {
return;
}
__debug(`${schema.componentName}[${schema.id}] leaf not render in SimulatorRendererView, leaf onVisibleChange make rerender`);
container.rerender();
debounceRerender();
}),
],
});

View File

@ -1,6 +1,9 @@
import { getLogger } from '@alilc/lowcode-utils';
import baseRendererFactory from './base';
import { IBaseRendererProps, IBaseRenderComponent } from '../types';
const logger = getLogger({ level: 'warn', bizName: 'renderer-core:page' });
export default function pageRendererFactory(): IBaseRenderComponent {
const BaseRenderer = baseRendererFactory();
return class PageRenderer extends BaseRenderer {
@ -29,6 +32,11 @@ export default function pageRendererFactory(): IBaseRenderComponent {
super.componentDidUpdate?.(prevProps, _prevState, snapshot);
}
setState(state: any, callback?: () => void) {
logger.info('page set state', state);
super.setState(state, callback);
}
render() {
const { __schema, __components } = this.props;
if (this.__checkSchema(__schema)) {

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-shell",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-editor-core": "1.1.6",
"@alilc/lowcode-editor-skeleton": "1.1.6",
"@alilc/lowcode-types": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-workspace": "1.1.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@alilc/lowcode-editor-core": "1.1.7-beta.9",
"@alilc/lowcode-editor-skeleton": "1.1.7-beta.9",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"@alilc/lowcode-workspace": "1.1.7-beta.9",
"classnames": "^2.2.6",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
@ -50,5 +50,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/shell"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -1,4 +1,4 @@
import { editorSymbol, skeletonSymbol, designerCabinSymbol, designerSymbol } from '../symbols';
import { editorSymbol, skeletonSymbol, designerCabinSymbol, designerSymbol, settingFieldSymbol } from '../symbols';
import {
isFormEvent as innerIsFormEvent,
compatibleLegaoSchema as innerCompatibleLegaoSchema,
@ -25,6 +25,7 @@ import {
IPublicTypeLocationDetailType as InnerLocationDetailType,
IPublicApiCommonEditorCabin,
IPublicModelDragon,
IPublicModelSettingField,
} from '@alilc/lowcode-types';
import {
SettingField as InnerSettingField,
@ -57,6 +58,9 @@ import {
untracked as innerUntracked,
computed as innerComputed,
observer as innerObserver,
action as innerAction,
runInAction as innerRunInAction,
engineConfig as innerEngineConfig,
} from '@alilc/lowcode-editor-core';
import { Dragon as ShellDragon } from '../model';
import { ReactNode } from 'react';
@ -168,8 +172,8 @@ class SkeletonCabin implements IPublicApiCommonSkeletonCabin {
/**
* @deprecated
*/
createSettingFieldView(item: any, field: any) {
return innerCreateSettingFieldView(item, field);
createSettingFieldView(field: IPublicModelSettingField, fieldEntry: any) {
return innerCreateSettingFieldView((field as any)[settingFieldSymbol] || field, fieldEntry);
}
/**
@ -301,6 +305,27 @@ class EditorCabin implements IPublicApiCommonEditorCabin {
return innerObx;
}
/**
* @deprecated
*/
get action() {
return innerAction;
}
/**
* @deprecated
*/
get engineConfig() {
return innerEngineConfig;
}
/**
* @deprecated
*/
get runInAction() {
return innerRunInAction;
}
/**
* @deprecated
*/

View File

@ -143,9 +143,16 @@ export class Material implements IPublicApiMaterial {
* action
* @param action
*/
addBuiltinComponentAction(action: IPublicTypeComponentAction) {
addBuiltinComponentAction = (action: IPublicTypeComponentAction) => {
this[designerSymbol].componentActions.addBuiltinComponentAction(action);
}
};
/**
* componentMetasMap components
*/
refreshComponentMetasMap = () => {
this[designerSymbol].refreshComponentMetasMap();
};
/**
* action

View File

@ -18,6 +18,9 @@ import {
import { DocumentModel as ShellDocumentModel } from '../model';
import { SimulatorHost } from './simulator-host';
import { editorSymbol, projectSymbol, simulatorHostSymbol, documentSymbol } from '../symbols';
import { getLogger } from '@alilc/lowcode-utils';
const logger = getLogger({ level: 'warn', bizName: 'shell-project' });
const innerProjectSymbol = Symbol('innerProject');
export class Project implements IPublicApiProject {
@ -29,6 +32,10 @@ export class Project implements IPublicApiProject {
}
const workspace = globalContext.get('workspace');
if (workspace.isActive) {
if (!workspace.window?.innerProject) {
logger.error('project api 调用时机出现问题,请检查');
return this[innerProjectSymbol];
}
return workspace.window.innerProject;
}
@ -43,8 +50,8 @@ export class Project implements IPublicApiProject {
this[innerProjectSymbol] = project;
}
static create(project: InnerProject) {
return new Project(project);
static create(project: InnerProject, workspaceMode: boolean = false) {
return new Project(project, workspaceMode);
}
/**
@ -231,9 +238,9 @@ export class Project implements IPublicApiProject {
this[projectSymbol].set('config', {
...oldConfig,
[params[0]]: params[1],
})
});
} else {
this[projectSymbol].set('config', params[0])
this[projectSymbol].set('config', params[0]);
}
}
}

View File

@ -1,10 +1,13 @@
import { IPublicTypeCustomView, IPublicApiSetters, IPublicTypeRegisteredSetter } from '@alilc/lowcode-types';
import { Setters as InnerSetters, globalContext } from '@alilc/lowcode-editor-core';
import { ReactNode } from 'react';
import { getLogger } from '@alilc/lowcode-utils';
const innerSettersSymbol = Symbol('setters');
const settersSymbol = Symbol('setters');
const logger = getLogger({ level: 'warn', bizName: 'shell-setters' });
export class Setters implements IPublicApiSetters {
readonly [innerSettersSymbol]: InnerSetters;
@ -15,6 +18,10 @@ export class Setters implements IPublicApiSetters {
const workspace = globalContext.get('workspace');
if (workspace.isActive) {
if (!workspace.window.innerSetters) {
logger.error('setter api 调用时机出现问题,请检查');
return this[innerSettersSymbol];
}
return workspace.window.innerSetters;
}

View File

@ -5,9 +5,12 @@ import {
} from '@alilc/lowcode-editor-skeleton';
import { skeletonSymbol } from '../symbols';
import { IPublicApiSkeleton, IPublicTypeDisposable, IPublicTypeSkeletonConfig, IPublicTypeWidgetConfigArea } from '@alilc/lowcode-types';
import { getLogger } from '@alilc/lowcode-utils';
const innerSkeletonSymbol = Symbol('skeleton');
const logger = getLogger({ level: 'warn', bizName: 'shell-skeleton' });
export class Skeleton implements IPublicApiSkeleton {
private readonly [innerSkeletonSymbol]: ISkeleton;
private readonly pluginName: string;
@ -18,6 +21,10 @@ export class Skeleton implements IPublicApiSkeleton {
}
const workspace = globalContext.get('workspace');
if (workspace.isActive) {
if (!workspace.window.innerSkeleton) {
logger.error('skeleton api 调用时机出现问题,请检查');
return this[innerSkeletonSymbol];
}
return workspace.window.innerSkeleton;
}

View File

@ -28,15 +28,22 @@ export class Workspace implements IPublicApiWorkspace {
}
get window() {
if (!this[workspaceSymbol].window) {
return null;
}
return new ShellWindow(this[workspaceSymbol].window);
}
onWindowRendererReady(fn: () => void): IPublicTypeDisposable {
return this[workspaceSymbol].onWindowRendererReady(fn);
}
registerResourceType(resourceTypeModel: IPublicTypeResourceType): void {
this[workspaceSymbol].registerResourceType(resourceTypeModel);
}
openEditorWindow(resourceName: string, title: string, extra: object, viewName?: string) {
this[workspaceSymbol].openEditorWindow(resourceName, title, extra, viewName);
openEditorWindow(resourceName: string, title: string, extra: object, viewName?: string, sleep?: boolean): void {
this[workspaceSymbol].openEditorWindow(resourceName, title, extra, viewName, sleep);
}
openEditorWindowById(id: string) {

View File

@ -10,6 +10,7 @@ import {
SettingTopEntry,
Clipboard,
SettingField,
Window,
} from './model';
import {
Project,
@ -50,6 +51,7 @@ export {
Selection,
Setters,
Hotkey,
Window,
Skeleton,
SettingField as SettingPropEntry,
SettingTopEntry,

View File

@ -90,7 +90,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
* @returns
*/
get project(): IPublicApiProject {
return ShellProject.create(this[documentSymbol].project);
return ShellProject.create(this[documentSymbol].project, true);
}
/**

View File

@ -41,4 +41,8 @@ export class Window implements IPublicModelWindow {
async save() {
return await this[windowSymbol].save();
}
get plugins() {
return this[windowSymbol].plugins;
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-types",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"description": "Types for Ali lowCode engine",
"files": [
"es",
@ -29,5 +29,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/types"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -122,4 +122,10 @@ export interface IPublicApiMaterial {
* @param fn
*/
onChangeAssets(fn: () => void): IPublicTypeDisposable;
/**
* componentMetasMap components
* @since v1.1.7
*/
refreshComponentMetasMap(): void;
}

View File

@ -10,7 +10,7 @@ export interface IPublicApiWorkspace<
isActive: boolean;
/** 当前设计器窗口 */
window: ModelWindow;
window: ModelWindow | null;
plugins: Plugins;
@ -30,7 +30,7 @@ export interface IPublicApiWorkspace<
registerResourceType(resourceTypeModel: IPublicTypeResourceType): void;
/** 打开视图窗口 */
openEditorWindow(resourceName: string, title: string, extra: Object, viewName?: string): void;
openEditorWindow(resourceName: string, title: string, extra: Object, viewName?: string, sleep?: boolean): void;
/** 通过视图 id 打开窗口 */
openEditorWindowById(id: string): void;
@ -46,4 +46,10 @@ export interface IPublicApiWorkspace<
/** active 窗口变更事件 */
onChangeActiveWindow(fn: () => void): IPublicTypeDisposable;
/**
* window renderer ready
* @since v1.1.7
*/
onWindowRendererReady(fn: () => void): IPublicTypeDisposable;
}

View File

@ -2,6 +2,7 @@ import { RequestHandlersMap } from '@alilc/lowcode-datasource-types';
import { ComponentType } from 'react';
export interface IPublicTypeEngineOptions {
/**
* condition condition
* when this is true, node that configured as conditional not renderring
@ -136,8 +137,10 @@ export interface IPublicTypeEngineOptions {
* react-renderer appHelper https://lowcode-engine.cn/site/docs/guide/expand/runtime/renderer#apphelper
*/
appHelper?: {
/** 全局公共函数 */
utils?: Record<string, any>;
/** 全局常量 */
constants?: Record<string, any>;
};
@ -168,6 +171,12 @@ export interface IPublicTypeEngineOptions {
*
*/
enableWorkspaceMode?: boolean;
/**
* @default true
*
*/
enableAutoOpenFirstWindow?: boolean;
}
/**

View File

@ -1,9 +1,20 @@
module.exports = {
const fs = require('fs');
const { join } = require('path');
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
const jestConfig = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: true,
collectCoverage: false,
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'src/**/*.ts',
'!src/**/*.d.ts',
'!**/node_modules/**',
'!**/vendor/**',
],
};
// 只对本仓库内的 pkg 做 mapping
jestConfig.moduleNameMapper = {};
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
module.exports = jestConfig;

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-utils",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"description": "Utils for Ali lowCode engine",
"files": [
"lib",
@ -14,7 +14,7 @@
},
"dependencies": {
"@alifd/next": "^1.19.16",
"@alilc/lowcode-types": "1.1.6",
"@alilc/lowcode-types": "1.1.7-beta.9",
"lodash": "^4.17.21",
"mobx": "^6.3.0",
"react": "^16"
@ -32,5 +32,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/utils"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -3,6 +3,7 @@ import { cloneEnumerableProperty } from './clone-enumerable-property';
const hasSymbol = typeof Symbol === 'function' && Symbol.for;
const REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
const REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
export function isReactClass(obj: any): obj is ComponentClass<any> {
return obj && obj.prototype && (obj.prototype.isReactComponent || obj.prototype instanceof Component);
@ -16,8 +17,16 @@ function isForwardRefType(obj: any): boolean {
return obj?.$$typeof && obj?.$$typeof === REACT_FORWARD_REF_TYPE;
}
function isMemoType(obj: any): boolean {
return obj?.$$typeof && obj.$$typeof === REACT_MEMO_TYPE;
}
export function isReactComponent(obj: any): obj is ComponentType<any> {
return obj && (isReactClass(obj) || typeof obj === 'function' || isForwardRefType(obj));
if (!obj) {
return false;
}
return Boolean(isReactClass(obj) || typeof obj === 'function' || isForwardRefType(obj) || isMemoType(obj));
}
export function wrapReactClass(view: FunctionComponent) {

View File

@ -309,8 +309,14 @@ describe('build-component', () => {
))
.toEqual({
Button: {
componentsMap: [],
componentsTree: [
{
componentName: 'Component',
schema: {},
}
],
version: "",
},
});
})

View File

@ -0,0 +1,38 @@
import React from "react";
import { isReactComponent, wrapReactClass } from "../../src/is-react";
class reactDemo extends React.Component {
}
const reactMemo = React.memo(reactDemo);
const reactForwardRef = React.forwardRef((props, ref): any => {
return '';
});
describe('is-react-ut', () => {
it('isReactComponent', () => {
expect(isReactComponent(null)).toBeFalsy();
expect(isReactComponent(() => {})).toBeTruthy();
expect(isReactComponent({
$$typeof: Symbol.for('react.memo')
})).toBeTruthy();
expect(isReactComponent({
$$typeof: Symbol.for('react.forward_ref')
})).toBeTruthy();
expect(isReactComponent(reactDemo)).toBeTruthy();
expect(isReactComponent(reactMemo)).toBeTruthy();
expect(isReactComponent(reactForwardRef)).toBeTruthy();
});
it('wrapReactClass', () => {
const wrap = wrapReactClass(() => {});
expect(isReactComponent(wrap)).toBeTruthy();
const fun = () => {};
fun.displayName = 'mock';
expect(wrapReactClass(fun).displayName).toBe('mock');
})
})

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-workspace",
"version": "1.1.6",
"version": "1.1.7-beta.9",
"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.6",
"@alilc/lowcode-editor-core": "1.1.6",
"@alilc/lowcode-editor-skeleton": "1.1.6",
"@alilc/lowcode-types": "1.1.6",
"@alilc/lowcode-utils": "1.1.6",
"@alilc/lowcode-designer": "1.1.7-beta.9",
"@alilc/lowcode-editor-core": "1.1.7-beta.9",
"@alilc/lowcode-editor-skeleton": "1.1.7-beta.9",
"@alilc/lowcode-types": "1.1.7-beta.9",
"@alilc/lowcode-utils": "1.1.7-beta.9",
"classnames": "^2.2.6",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
@ -49,5 +49,5 @@
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/shell"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6"
"gitHead": "fdb74f0aeb15a30f85387979f620e27dd1673b92"
}

View File

@ -30,6 +30,7 @@ import {
Common,
Logger,
Workspace,
Window,
Canvas,
} from '@alilc/lowcode-shell';
import {
@ -164,6 +165,9 @@ export class BasicContext implements IBasicContext {
context.plugins = plugins;
context.logger = new Logger({ level: 'warn', bizName: `plugin:${pluginName}` });
context.canvas = canvas;
if (editorWindow) {
context.editorWindow = new Window(editorWindow);
}
},
};

View File

@ -17,10 +17,6 @@ export class Context extends BasicContext {
@obx isInit: boolean = false;
@computed get active() {
return this._activate;
}
init = flow(function* (this: Context) {
if (this.viewType === 'webview') {
const url = yield this.instance?.url?.();
@ -43,6 +39,18 @@ export class Context extends BasicContext {
makeObservable(this);
}
@computed get active() {
return this._activate;
}
onSimulatorRendererReady = (): Promise<void> => {
return new Promise((resolve) => {
this.project.onSimulatorRendererReady(() => {
resolve();
});
});
};
setActivate = (_activate: boolean) => {
this._activate = _activate;
this.innerHotkey.activate(this._activate);

View File

@ -368,6 +368,9 @@ body {
right: 0;
bottom: 0;
left: 0;
flex-direction: column;
display: flex;
align-content: stretch;
}
.engine-actionitem {

View File

@ -47,7 +47,7 @@ export class Workbench extends Component<{
{
workspace.windows.map(d => (
<WindowView
active={d.id === workspace.window.id}
active={d.id === workspace.window?.id}
window={d}
key={d.id}
/>

View File

@ -39,7 +39,7 @@ export class Resource implements IResource {
}
get viewName() {
return this.resourceData.viewName || (this.resourceData as any).viewType;
return this.resourceData.viewName || (this.resourceData as any).viewType || this.defaultViewType;
}
get description() {

View File

@ -10,6 +10,7 @@ interface IWindowCOnfig {
title: string | undefined;
options?: Object;
viewType?: string | undefined;
sleep?: boolean;
}
export interface IEditorWindow extends Omit<IPublicModelWindow<IResource>, 'changeViewType'> {
@ -18,6 +19,12 @@ export interface IEditorWindow extends Omit<IPublicModelWindow<IResource>, 'chan
editorViews: Map<string, Context>;
changeViewType: (name: string, ignoreEmit?: boolean) => void;
initReady: boolean;
sleep?: boolean;
init(): void;
}
export class EditorWindow implements IEditorWindow {
@ -36,11 +43,16 @@ export class EditorWindow implements IEditorWindow {
@obx initReady = false;
sleep: boolean | undefined;
constructor(readonly resource: IResource, readonly workspace: IWorkspace, private config: IWindowCOnfig) {
makeObservable(this);
this.init();
this.title = config.title;
this.icon = resource.icon;
this.sleep = config.sleep;
if (!config.sleep) {
this.init();
}
}
async importSchema(schema: any) {
@ -70,9 +82,14 @@ export class EditorWindow implements IEditorWindow {
async init() {
await this.initViewTypes();
await this.execViewTypesInit();
Promise.all(Array.from(this.editorViews.values()).map((d) => d.onSimulatorRendererReady)).then(() => {
this.workspace.emitWindowRendererReady();
});
this.url = await this.resource.url();
this.setDefaultViewType();
this.initReady = true;
this.workspace.checkWindowQueue();
this.sleep = false;
}
initViewTypes = async () => {
@ -168,6 +185,10 @@ export class EditorWindow implements IEditorWindow {
return this.editorView?.designer;
}
get plugins() {
return this.editorView?.plugins;
}
get innerPlugins() {
return this.editorView?.innerPlugins;
}

View File

@ -1,6 +1,6 @@
import { IDesigner, ILowCodePluginManager, LowCodePluginManager } from '@alilc/lowcode-designer';
import { createModuleEventBus, Editor, IEventBus, makeObservable, obx } from '@alilc/lowcode-editor-core';
import { IPublicApiPlugins, IPublicApiWorkspace, IPublicResourceList, IPublicTypeResourceType, IShellModelFactory } from '@alilc/lowcode-types';
import { createModuleEventBus, Editor, IEditor, IEventBus, makeObservable, obx } from '@alilc/lowcode-editor-core';
import { IPublicApiPlugins, IPublicApiWorkspace, IPublicResourceList, IPublicTypeDisposable, IPublicTypeResourceType, IShellModelFactory } from '@alilc/lowcode-types';
import { BasicContext } from './context/base-context';
import { EditorWindow } from './window';
import type { IEditorWindow } from './window';
@ -11,6 +11,8 @@ enum EVENT {
CHANGE_WINDOW = 'change_window',
CHANGE_ACTIVE_WINDOW = 'change_active_window',
WINDOW_RENDER_READY = 'window_render_ready',
}
const CHANGE_EVENT = 'resource.list.change';
@ -19,10 +21,12 @@ export interface IWorkspace extends Omit<IPublicApiWorkspace<
LowCodePluginManager,
IEditorWindow
>, 'resourceList' | 'plugins'> {
readonly registryInnerPlugin: (designer: IDesigner, editor: Editor, plugins: IPublicApiPlugins) => Promise<void>;
readonly registryInnerPlugin: (designer: IDesigner, editor: Editor, plugins: IPublicApiPlugins) => Promise<IPublicTypeDisposable>;
readonly shellModelFactory: IShellModelFactory;
enableAutoOpenFirstWindow: boolean;
window: IEditorWindow;
plugins: ILowCodePluginManager;
@ -30,11 +34,21 @@ export interface IWorkspace extends Omit<IPublicApiWorkspace<
getResourceList(): IResource[];
getResourceType(resourceName: string): IResourceType;
checkWindowQueue(): void;
emitWindowRendererReady(): void;
initWindow(): void;
setActive(active: boolean): void;
}
export class Workspace implements IWorkspace {
context: BasicContext;
enableAutoOpenFirstWindow: boolean;
private emitter: IEventBus = createModuleEventBus('workspace');
private _isActive = false;
@ -69,30 +83,43 @@ export class Workspace implements IWorkspace {
@obx.ref window: IEditorWindow;
windowQueue: {
name: string;
title: string;
options: Object;
viewType?: string;
}[] = [];
constructor(
readonly registryInnerPlugin: (designer: IDesigner, editor: Editor, plugins: IPublicApiPlugins) => Promise<void>,
readonly registryInnerPlugin: (designer: IDesigner, editor: IEditor, plugins: IPublicApiPlugins) => Promise<IPublicTypeDisposable>,
readonly shellModelFactory: any,
) {
this.init();
this.context = new BasicContext(this, '');
makeObservable(this);
}
init() {
this.initWindow();
this.context = new BasicContext(this, '');
checkWindowQueue() {
if (!this.windowQueue || !this.windowQueue.length) {
return;
}
const windowInfo = this.windowQueue.shift();
if (windowInfo) {
this.openEditorWindow(windowInfo.name, windowInfo.title, windowInfo.options, windowInfo.viewType);
}
}
initWindow() {
if (!this.defaultResourceType) {
if (!this.defaultResourceType || this.enableAutoOpenFirstWindow === false) {
return;
}
const title = this.defaultResourceType.name;
const resourceName = this.defaultResourceType.name;
const resource = new Resource({
resourceName: title,
resourceName,
options: {},
}, this.defaultResourceType, this);
this.window = new EditorWindow(resource, this, {
title,
title: resource.title,
});
this.editorWindowMap.set(this.window.id, this.window);
this.windows.push(this.window);
@ -108,7 +135,7 @@ export class Workspace implements IWorkspace {
const resourceType = new ResourceType(resourceTypeModel);
this.resourceTypeMap.set(resourceTypeModel.resourceName, resourceType);
if (!this.window && this.defaultResourceType) {
if (!this.window && this.defaultResourceType && this._isActive) {
this.initWindow();
}
}
@ -129,6 +156,17 @@ export class Workspace implements IWorkspace {
};
}
onWindowRendererReady(fn: () => void): IPublicTypeDisposable {
this.emitter.on(EVENT.WINDOW_RENDER_READY, fn);
return () => {
this.emitter.off(EVENT.WINDOW_RENDER_READY, fn);
};
}
emitWindowRendererReady() {
this.emitter.emit(EVENT.WINDOW_RENDER_READY);
}
getResourceType(resourceName: string): IResourceType {
return this.resourceTypeMap.get(resourceName)!;
}
@ -167,7 +205,13 @@ export class Workspace implements IWorkspace {
}
}
openEditorWindow(name: string, title: string, options: Object, viewType?: string) {
openEditorWindow(name: string, title: string, options: Object, viewType?: string, sleep?: boolean) {
if (this.window && !this.window?.initReady && !sleep) {
this.windowQueue.push({
name, title, options, viewType,
});
return;
}
const resourceType = this.resourceTypeMap.get(name);
if (!resourceType) {
console.error(`${name} resourceType is not available`);
@ -176,6 +220,11 @@ export class Workspace implements IWorkspace {
const filterWindows = this.windows.filter(d => (d.resource?.name === name && d.resource.title == title));
if (filterWindows && filterWindows.length) {
this.window = filterWindows[0];
if (!sleep && this.window.sleep) {
this.window.init();
} else {
this.checkWindowQueue();
}
this.emitChangeActiveWindow();
return;
}
@ -184,13 +233,17 @@ export class Workspace implements IWorkspace {
title,
options,
}, resourceType, this);
this.window = new EditorWindow(resource, this, {
const window = new EditorWindow(resource, this, {
title,
options,
viewType,
sleep,
});
this.windows = [...this.windows, this.window];
this.editorWindowMap.set(this.window.id, this.window);
this.windows = [...this.windows, window];
this.editorWindowMap.set(window.id, window);
if (!sleep) {
this.window = window;
}
this.emitChangeWindow();
this.emitChangeActiveWindow();
}