mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 11:20:11 +00:00
Merge branch 'develop'
This commit is contained in:
commit
267f79cc4c
@ -1,6 +1,6 @@
|
||||
{
|
||||
"lerna": "4.0.0",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"packages": [
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-designer",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "Designer for Ali LowCode Engine",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -15,10 +15,10 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-editor-core": "1.0.11",
|
||||
"@alilc/lowcode-shell": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-editor-core": "1.0.12",
|
||||
"@alilc/lowcode-shell": "1.0.12",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"classnames": "^2.2.6",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-react-16": "^1.15.5",
|
||||
|
||||
@ -618,7 +618,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
'.next-calendar-table',
|
||||
'.editor-container', // 富文本组件
|
||||
];
|
||||
const ignoreSelectors = customizeIgnoreSelectors?.(defaultIgnoreSelectors) || defaultIgnoreSelectors;
|
||||
const ignoreSelectors = customizeIgnoreSelectors?.(defaultIgnoreSelectors, e) || defaultIgnoreSelectors;
|
||||
const ignoreSelectorsString = ignoreSelectors.join(',');
|
||||
// 提供了 customizeIgnoreSelectors 的情况下,忽略 isFormEvent() 判断
|
||||
if ((!customizeIgnoreSelectors && isFormEvent(e)) || target?.closest(ignoreSelectorsString)) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-editor-core",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"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.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"classnames": "^2.2.6",
|
||||
"debug": "^4.1.1",
|
||||
"intl-messageformat": "^9.3.1",
|
||||
|
||||
@ -73,7 +73,7 @@ const VALID_ENGINE_OPTIONS = {
|
||||
customizeIgnoreSelectors: {
|
||||
type: 'function',
|
||||
default: undefined,
|
||||
description: '定制画布中点击被忽略的 selectors, eg. (defaultIgnoreSelectors: string[]) => string[]',
|
||||
description: '定制画布中点击被忽略的 selectors, eg. (defaultIgnoreSelectors: string[], e: MouseEvent) => string[]',
|
||||
},
|
||||
disableDefaultSettingPanel: {
|
||||
type: 'boolean',
|
||||
@ -192,7 +192,7 @@ export interface EngineOptions {
|
||||
/**
|
||||
* 定制画布中点击被忽略的 selectors,默认值:undefined
|
||||
*/
|
||||
customizeIgnoreSelectors?: (defaultIgnoreSelectors: string[]) => string[];
|
||||
customizeIgnoreSelectors?: (defaultIgnoreSelectors: string[], e: MouseEvent) => string[];
|
||||
/**
|
||||
* 禁止默认的设置面板,默认值:false
|
||||
*/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-editor-skeleton",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"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.0.11",
|
||||
"@alilc/lowcode-editor-core": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-designer": "1.0.12",
|
||||
"@alilc/lowcode-editor-core": "1.0.12",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"classnames": "^2.2.6",
|
||||
"react": "^16.8.1",
|
||||
"react-dom": "^16.8.1"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-engine",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系",
|
||||
"main": "lib/engine-core.js",
|
||||
"module": "es/engine-core.js",
|
||||
@ -19,14 +19,14 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.19.12",
|
||||
"@alilc/lowcode-designer": "1.0.11",
|
||||
"@alilc/lowcode-editor-core": "1.0.11",
|
||||
"@alilc/lowcode-editor-skeleton": "1.0.11",
|
||||
"@alilc/lowcode-designer": "1.0.12",
|
||||
"@alilc/lowcode-editor-core": "1.0.12",
|
||||
"@alilc/lowcode-editor-skeleton": "1.0.12",
|
||||
"@alilc/lowcode-engine-ext": "^1.0.0",
|
||||
"@alilc/lowcode-plugin-designer": "1.0.11",
|
||||
"@alilc/lowcode-plugin-outline-pane": "1.0.11",
|
||||
"@alilc/lowcode-shell": "1.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-plugin-designer": "1.0.12",
|
||||
"@alilc/lowcode-plugin-outline-pane": "1.0.12",
|
||||
"@alilc/lowcode-shell": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"react": "^16.8.1",
|
||||
"react-dom": "^16.8.1"
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-ignitor",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "点火器,bootstrap lce project",
|
||||
"main": "lib/index.js",
|
||||
"private": true,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-plugin-designer",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "alibaba lowcode editor designer plugin",
|
||||
"files": [
|
||||
"es",
|
||||
@ -18,9 +18,9 @@
|
||||
],
|
||||
"author": "xiayang.xy",
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-designer": "1.0.11",
|
||||
"@alilc/lowcode-editor-core": "1.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-designer": "1.0.12",
|
||||
"@alilc/lowcode-editor-core": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"react": "^16.8.1",
|
||||
"react-dom": "^16.8.1"
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-plugin-outline-pane",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "Outline pane for Ali lowCode engine",
|
||||
"files": [
|
||||
"es",
|
||||
@ -13,10 +13,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.19.16",
|
||||
"@alilc/lowcode-designer": "1.0.11",
|
||||
"@alilc/lowcode-editor-core": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-designer": "1.0.12",
|
||||
"@alilc/lowcode-editor-core": "1.0.12",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"classnames": "^2.2.6",
|
||||
"react": "^16",
|
||||
"react-dom": "^16.7.0"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-rax-renderer",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"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.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-renderer-core": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"rax-find-dom-node": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-rax-simulator-renderer",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"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.0.11",
|
||||
"@alilc/lowcode-rax-renderer": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-designer": "1.0.12",
|
||||
"@alilc/lowcode-rax-renderer": "1.0.12",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"classnames": "^2.2.6",
|
||||
"driver-universal": "^3.1.3",
|
||||
"history": "^5.0.0",
|
||||
|
||||
@ -523,10 +523,11 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
||||
...extraProps,
|
||||
schema: _schema,
|
||||
components,
|
||||
designMode: renderer.designMode,
|
||||
designMode: '',
|
||||
device: renderer.device,
|
||||
appHelper: renderer.context,
|
||||
rendererName: 'LowCodeRenderer',
|
||||
thisRequiredInJSE: host.thisRequiredInJSE,
|
||||
customCreateElement: (Comp: any, props: any, children: any) => {
|
||||
const componentMeta = host.currentDocument?.getComponentMeta(Comp.displayName);
|
||||
if (componentMeta?.isModal) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-react-renderer",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"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.0.11"
|
||||
"@alilc/lowcode-renderer-core": "1.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alib/build-scripts": "^0.1.18",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-react-simulator-renderer",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "react simulator renderer for alibaba lowcode designer",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -16,10 +16,10 @@
|
||||
"build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-designer": "1.0.11",
|
||||
"@alilc/lowcode-react-renderer": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-designer": "1.0.12",
|
||||
"@alilc/lowcode-react-renderer": "1.0.12",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"classnames": "^2.2.6",
|
||||
"mobx": "^6.3.0",
|
||||
"mobx-react": "^7.2.0",
|
||||
|
||||
@ -450,10 +450,11 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
||||
// 使用 _schema 为了使低代码组件在页面设计中使用变量,同 react 组件使用效果一致
|
||||
schema: _schema,
|
||||
components: renderer.components,
|
||||
designMode: renderer.designMode,
|
||||
designMode: '',
|
||||
device: renderer.device,
|
||||
appHelper: renderer.context,
|
||||
rendererName: 'LowCodeRenderer',
|
||||
thisRequiredInJSE: host.thisRequiredInJSE,
|
||||
customCreateElement: (Comp: any, props: any, children: any) => {
|
||||
const componentMeta = host.currentDocument?.getComponentMeta(Comp.displayName);
|
||||
if (componentMeta?.isModal) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-renderer-core",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"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.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"classnames": "^2.2.6",
|
||||
"debug": "^4.1.1",
|
||||
"fetch-jsonp": "^1.1.3",
|
||||
@ -27,14 +27,13 @@
|
||||
"moment": "^2.24.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-is": "^16.10.1",
|
||||
"serialize-javascript": "^1.7.0",
|
||||
"socket.io-client": "^2.2.0",
|
||||
"whatwg-fetch": "^3.0.0",
|
||||
"zen-logger": "^1.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alib/build-scripts": "^0.1.18",
|
||||
"@alilc/lowcode-designer": "1.0.11",
|
||||
"@alilc/lowcode-designer": "1.0.12",
|
||||
"@alilc/lowcode-test-mate": "^1.0.1",
|
||||
"@babel/plugin-transform-typescript": "^7.16.8",
|
||||
"@testing-library/react": "^11.2.2",
|
||||
@ -45,7 +44,6 @@
|
||||
"@types/node": "^13.7.1",
|
||||
"@types/prop-types": "^15.7.3",
|
||||
"@types/react-test-renderer": "^17.0.1",
|
||||
"@types/serialize-javascript": "^5.0.0",
|
||||
"babel-jest": "^26.5.2",
|
||||
"build-plugin-component": "^0.2.11",
|
||||
"jest": "^26.6.3",
|
||||
|
||||
@ -45,7 +45,7 @@ export default function addonRendererFactory(): IBaseRenderComponent {
|
||||
this.__initDataSource(props);
|
||||
this.open = this.open || (() => { });
|
||||
this.close = this.close || (() => { });
|
||||
this.__setLifeCycleMethods('constructor', [...arguments]);
|
||||
this.__excuteLifeCycleMethod('constructor', [...arguments]);
|
||||
}
|
||||
|
||||
async componentWillUnmount() {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-console */
|
||||
/* eslint-disable max-len */
|
||||
/* eslint-disable react/prop-types */
|
||||
import classnames from 'classnames';
|
||||
@ -47,7 +48,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
Record<string, any>,
|
||||
any
|
||||
>;
|
||||
const createElement = runtime.createElement;
|
||||
const { createElement } = runtime;
|
||||
const Div = divFactory();
|
||||
const VisualDom = visualDomFactory();
|
||||
const AppContext = contextFactory();
|
||||
@ -97,6 +98,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
this.__debug(`constructor - ${props?.__schema?.fileName}`);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
__beforeInit(_props: IBaseRendererProps) { }
|
||||
|
||||
__init(props: IBaseRendererProps) {
|
||||
@ -107,6 +109,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
this.__initI18nAPIs();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
__afterInit(_props: IBaseRendererProps) { }
|
||||
|
||||
static getDerivedStateFromProps(props: IBaseRendererProps, state: any) {
|
||||
@ -116,40 +119,41 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
if (func) {
|
||||
if (isJSExpression(func) || isJSFunction(func)) {
|
||||
const fn = props.thisRequiredInJSE ? parseThisRequiredExpression(func, this) : parseExpression(func, this);
|
||||
return fn(props, state);
|
||||
return fn?.(props, state);
|
||||
}
|
||||
|
||||
if (typeof func === 'function') {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
return (func as Function)(props, state);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async getSnapshotBeforeUpdate() {
|
||||
this.__setLifeCycleMethods('getSnapshotBeforeUpdate', arguments);
|
||||
async getSnapshotBeforeUpdate(...args: any[]) {
|
||||
this.__excuteLifeCycleMethod('getSnapshotBeforeUpdate', args);
|
||||
this.__debug(`getSnapshotBeforeUpdate - ${this.props?.__schema?.fileName}`);
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
async componentDidMount(...args: any[]) {
|
||||
this.reloadDataSource();
|
||||
this.__setLifeCycleMethods('componentDidMount', arguments);
|
||||
this.__excuteLifeCycleMethod('componentDidMount', args);
|
||||
this.__debug(`componentDidMount - ${this.props?.__schema?.fileName}`);
|
||||
}
|
||||
|
||||
async componentDidUpdate(...args: any) {
|
||||
this.__setLifeCycleMethods('componentDidUpdate', args);
|
||||
async componentDidUpdate(...args: any[]) {
|
||||
this.__excuteLifeCycleMethod('componentDidUpdate', args);
|
||||
this.__debug(`componentDidUpdate - ${this.props.__schema.fileName}`);
|
||||
}
|
||||
|
||||
async componentWillUnmount(...args: any) {
|
||||
this.__setLifeCycleMethods('componentWillUnmount', args);
|
||||
async componentWillUnmount(...args: any[]) {
|
||||
this.__excuteLifeCycleMethod('componentWillUnmount', args);
|
||||
this.__debug(`componentWillUnmount - ${this.props?.__schema?.fileName}`);
|
||||
}
|
||||
|
||||
async componentDidCatch(e: any) {
|
||||
this.__setLifeCycleMethods('componentDidCatch', arguments);
|
||||
console.warn(e);
|
||||
async componentDidCatch(...args: any[]) {
|
||||
this.__excuteLifeCycleMethod('componentDidCatch', args);
|
||||
console.warn(args);
|
||||
}
|
||||
|
||||
reloadDataSource = () => new Promise((resolve, reject) => {
|
||||
@ -165,7 +169,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
this.forceUpdate();
|
||||
return resolve({});
|
||||
}
|
||||
this.setState(res, resolve);
|
||||
this.setState(res, resolve as () => void);
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
if (this.__showPlaceholder) {
|
||||
@ -190,7 +194,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
}
|
||||
}
|
||||
|
||||
__setLifeCycleMethods = (method: string, args?: any) => {
|
||||
__excuteLifeCycleMethod = (method: string, args?: any) => {
|
||||
const lifeCycleMethods = getValue(this.props.__schema, 'lifeCycles', {});
|
||||
let fn = lifeCycleMethods[method];
|
||||
if (fn) {
|
||||
@ -210,6 +214,14 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
}
|
||||
};
|
||||
|
||||
_getComponentView = (componentName: string) => {
|
||||
const { __components } = this.props;
|
||||
if (!__components) {
|
||||
return;
|
||||
}
|
||||
return __components[componentName];
|
||||
};
|
||||
|
||||
__bindCustomMethods = (props = this.props) => {
|
||||
const { __schema } = props;
|
||||
const customMethodsList = Object.keys(__schema.methods || {}) || [];
|
||||
@ -221,14 +233,15 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
});
|
||||
this.__customMethodsList = customMethodsList;
|
||||
forEach(__schema.methods, (val: any, key: string) => {
|
||||
if (isJSExpression(val) || isJSFunction(val)) {
|
||||
val = this.parseExpression(val, this);
|
||||
let value = val;
|
||||
if (isJSExpression(value) || isJSFunction(value)) {
|
||||
value = this.parseExpression(value, this);
|
||||
}
|
||||
if (typeof val !== 'function') {
|
||||
console.error(`自定义函数${key}类型不符`, val);
|
||||
if (typeof value !== 'function') {
|
||||
console.error(`自定义函数${key}类型不符`, value);
|
||||
return;
|
||||
}
|
||||
this[key] = val.bind(this);
|
||||
this[key] = value.bind(this);
|
||||
});
|
||||
};
|
||||
|
||||
@ -296,7 +309,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
this.forceUpdate();
|
||||
return resolve({});
|
||||
}
|
||||
this.setState(res, resolve);
|
||||
this.setState(res, resolve as () => void);
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
if (this.__showPlaceholder) {
|
||||
@ -347,7 +360,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
|
||||
__render = () => {
|
||||
const schema = this.props.__schema;
|
||||
this.__setLifeCycleMethods('render');
|
||||
this.__excuteLifeCycleMethod('render');
|
||||
this.__writeCss();
|
||||
|
||||
const { engine } = this.context;
|
||||
@ -409,7 +422,9 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
// self 为每个渲染组件构造的上下文,self是自上而下继承的
|
||||
// parentInfo 父组件的信息,包含schema和Comp
|
||||
// idx 若为循环渲染的循环Index
|
||||
__createVirtualDom = (schema: NodeData | NodeData[] | undefined, scope: any, parentInfo: IInfo, idx: string | number = ''): any => {
|
||||
__createVirtualDom = (originalSchema: NodeData | NodeData[] | undefined, originalScope: any, parentInfo: IInfo, idx: string | number = ''): any => {
|
||||
let scope = originalScope;
|
||||
let schema = originalSchema;
|
||||
const { engine } = this.context || {};
|
||||
try {
|
||||
if (!schema) return null;
|
||||
@ -580,7 +595,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
}
|
||||
|
||||
let child = this.__getSchemaChildrenVirtualDom(schema, scope, Comp);
|
||||
const renderComp = (props: any) => engine.createElement(Comp, props, child);
|
||||
const renderComp = (innerProps: any) => engine.createElement(Comp, innerProps, child);
|
||||
// 设计模式下的特殊处理
|
||||
if (engine && [DESIGN_MODE.EXTEND, DESIGN_MODE.BORDER].includes(engine.props.designMode)) {
|
||||
// 对于overlay,dialog等组件为了使其在设计模式下显示,外层需要增加一个div容器
|
||||
@ -690,7 +705,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
if (!Array.isArray(schema.loop)) return null;
|
||||
const itemArg = (schema.loopArgs && schema.loopArgs[0]) || 'item';
|
||||
const indexArg = (schema.loopArgs && schema.loopArgs[1]) || 'index';
|
||||
const loop: (JSONValue| CompositeValue)[] = schema.loop;
|
||||
const { loop } = schema;
|
||||
return loop.map((item: JSONValue | CompositeValue, i: number) => {
|
||||
const loopSelf: any = {
|
||||
[itemArg]: item,
|
||||
@ -714,7 +729,8 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
return engine?.props?.designMode === 'design';
|
||||
}
|
||||
|
||||
__parseProps = (props: any, scope: any, path: string, info: IInfo): any => {
|
||||
__parseProps = (originalProps: any, scope: any, path: string, info: IInfo): any => {
|
||||
let props = originalProps;
|
||||
const { schema, Comp, componentInfo = {} } = info;
|
||||
const propInfo = getValue(componentInfo.props, path);
|
||||
// FIXME! 将这行逻辑外置,解耦,线上环境不要验证参数,调试环境可以有,通过传参自定义
|
||||
@ -729,14 +745,14 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
if (isEmpty(params)) {
|
||||
return checkProps(this.__createVirtualDom(data, scope, ({ schema, Comp } as IInfo)));
|
||||
}
|
||||
return checkProps(function () {
|
||||
return checkProps((...argValues: any[]) => {
|
||||
const args: any = {};
|
||||
if (Array.isArray(params) && params.length) {
|
||||
params.forEach((item, idx) => {
|
||||
if (typeof item === 'string') {
|
||||
args[item] = arguments[idx];
|
||||
args[item] = argValues[idx];
|
||||
} else if (item && typeof item === 'object') {
|
||||
args[item.name] = arguments[idx];
|
||||
args[item.name] = argValues[idx];
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -762,7 +778,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
if (!isSchema(props) && !isJSSlot(props)) return checkProps(props);
|
||||
}
|
||||
|
||||
const handleLegaoI18n = (props: any) => props[props.use || 'zh_CN'];
|
||||
const handleLegaoI18n = (innerProps: any) => innerProps[innerProps.use || 'zh_CN'];
|
||||
|
||||
// 兼容乐高设计态 i18n 数据
|
||||
if (isI18nData(props)) {
|
||||
@ -802,13 +818,16 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
&& propInfo?.props?.types?.indexOf('ReactNode') > -1
|
||||
&& propInfo?.props?.reactNodeProps?.type === 'function'
|
||||
);
|
||||
|
||||
let params = null;
|
||||
if (isReactNodeFunction) {
|
||||
params = propInfo?.props?.params;
|
||||
} else if (isMixinReactNodeFunction) {
|
||||
params = propInfo?.props?.reactNodeProps?.params;
|
||||
}
|
||||
return parseReactNode(
|
||||
props,
|
||||
isReactNodeFunction
|
||||
? propInfo.props.params
|
||||
: isMixinReactNodeFunction
|
||||
? propInfo.props.reactNodeProps.params
|
||||
: null,
|
||||
params,
|
||||
);
|
||||
}
|
||||
if (Array.isArray(props)) {
|
||||
@ -849,15 +868,13 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
__debug = logger.log;
|
||||
|
||||
__renderContextProvider = (customProps?: object, children?: any) => {
|
||||
customProps = customProps || {};
|
||||
children = children || this.__createDom();
|
||||
return createElement(AppContext.Provider, {
|
||||
value: {
|
||||
...this.context,
|
||||
blockContext: this,
|
||||
...customProps,
|
||||
...(customProps || {}),
|
||||
},
|
||||
children,
|
||||
children: children || this.__createDom(),
|
||||
});
|
||||
};
|
||||
|
||||
@ -865,7 +882,8 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
return createElement(AppContext.Consumer, {}, children);
|
||||
};
|
||||
|
||||
__getHocComp(Comp: any, schema: any, scope: any) {
|
||||
__getHocComp(OriginalComp: any, schema: any, scope: any) {
|
||||
let Comp = OriginalComp;
|
||||
this.componentHoc.forEach((ComponentConstruct: IComponentConstruct) => {
|
||||
Comp = ComponentConstruct(Comp || Div, {
|
||||
schema,
|
||||
@ -878,7 +896,8 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
return Comp;
|
||||
}
|
||||
|
||||
__renderComp(Comp: any, ctxProps: object) {
|
||||
__renderComp(OriginalComp: any, ctxProps: object) {
|
||||
let Comp = OriginalComp;
|
||||
const { __schema } = this.props;
|
||||
const { __ctx } = this.props;
|
||||
const scope: any = {};
|
||||
@ -927,7 +946,8 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
||||
}, children);
|
||||
}
|
||||
|
||||
__checkSchema = (schema: NodeSchema | undefined, extraComponents: string | string[] = []) => {
|
||||
__checkSchema = (schema: NodeSchema | undefined, originalExtraComponents: string | string[] = []) => {
|
||||
let extraComponents = originalExtraComponents;
|
||||
if (typeof extraComponents === 'string') {
|
||||
extraComponents = [extraComponents];
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ export default function blockRendererFactory(): IBaseRenderComponent {
|
||||
const schema = props.__schema || {};
|
||||
this.state = this.__parseData(schema.state || {});
|
||||
this.__initDataSource(props);
|
||||
this.__setLifeCycleMethods('constructor', [...arguments]);
|
||||
this.__excuteLifeCycleMethod('constructor', [...arguments]);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@ -15,7 +15,7 @@ export default function componentRendererFactory(): IBaseRenderComponent {
|
||||
const schema = props.__schema || {};
|
||||
this.state = this.__parseData(schema.state || {});
|
||||
this.__initDataSource(props);
|
||||
this.__setLifeCycleMethods('constructor', arguments as any);
|
||||
this.__excuteLifeCycleMethod('constructor', arguments as any);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@ -15,7 +15,7 @@ export default function pageRendererFactory(): IBaseRenderComponent {
|
||||
const schema = props.__schema || {};
|
||||
this.state = this.__parseData(schema.state || {});
|
||||
this.__initDataSource(props);
|
||||
this.__setLifeCycleMethods('constructor', [props, ...rest]);
|
||||
this.__excuteLifeCycleMethod('constructor', [props, ...rest]);
|
||||
}
|
||||
|
||||
async componentDidUpdate(prevProps: IBaseRendererProps, _prevState: {}, snapshot: unknown) {
|
||||
@ -40,7 +40,7 @@ export default function pageRendererFactory(): IBaseRenderComponent {
|
||||
this.__bindCustomMethods(this.props);
|
||||
this.__initDataSource(this.props);
|
||||
|
||||
// this.__setLifeCycleMethods('constructor', arguments);
|
||||
// this.__excuteLifeCycleMethod('constructor', arguments);
|
||||
|
||||
this.__generateCtx({
|
||||
page: this,
|
||||
|
||||
@ -240,7 +240,7 @@ export type IBaseRendererInstance = IGeneralComponent<
|
||||
__beforeInit(props: IBaseRendererProps): void;
|
||||
__init(props: IBaseRendererProps): void;
|
||||
__afterInit(props: IBaseRendererProps): void;
|
||||
__setLifeCycleMethods(method: string, args?: any[]): void;
|
||||
__excuteLifeCycleMethod(method: string, args?: any[]): void;
|
||||
__bindCustomMethods(props: IBaseRendererProps): void;
|
||||
__generateCtx(ctx: Record<string, any>): void;
|
||||
__parseData(data: any, ctx?: any): any;
|
||||
|
||||
@ -5,22 +5,15 @@ import { isI18nData, RootSchema, NodeSchema, isJSExpression, JSSlot } from '@ali
|
||||
// moment对象配置
|
||||
import _moment from 'moment';
|
||||
import 'moment/locale/zh-cn';
|
||||
import pkg from '../../package.json';
|
||||
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
import _serialize from 'serialize-javascript';
|
||||
import * as _jsonuri from 'jsonuri';
|
||||
|
||||
import IntlMessageFormat from 'intl-messageformat';
|
||||
import pkg from '../../package.json';
|
||||
|
||||
export const moment = _moment;
|
||||
moment.locale('zh-cn');
|
||||
(window as any).sdkVersion = pkg.version;
|
||||
|
||||
export { pick, isEqualWith as deepEqual, cloneDeep as clone, isEmpty, throttle, debounce } from 'lodash';
|
||||
export const jsonuri = _jsonuri;
|
||||
export const serialize = _serialize;
|
||||
|
||||
const ReactIs = require('react-is');
|
||||
const ReactPropTypesSecret = require('prop-types/lib/ReactPropTypesSecret');
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import adapter, { Env } from '../../src/adapter';
|
||||
import { IRuntime, IRendererModules, IGeneralConstructor } from '../../src/types';
|
||||
|
||||
|
||||
|
||||
|
||||
18
packages/renderer-core/tests/renderer/base.test.tsx
Normal file
18
packages/renderer-core/tests/renderer/base.test.tsx
Normal file
@ -0,0 +1,18 @@
|
||||
const mockGetRenderers = jest.fn();
|
||||
jest.mock('../../src/adapter', () => {
|
||||
return {
|
||||
getRenderers: () => { return mockGetRenderers();}
|
||||
};
|
||||
});
|
||||
|
||||
import baseRendererFactory from '../../src/renderer/base';
|
||||
|
||||
describe('Base Render', () => {
|
||||
it('customBaseRenderer logic works', () => {
|
||||
mockGetRenderers.mockReturnValue({BaseRenderer: {}});
|
||||
const baseRenderer = baseRendererFactory();
|
||||
expect(mockGetRenderers).toBeCalledTimes(1);
|
||||
expect(baseRenderer).toStrictEqual({});
|
||||
mockGetRenderers.mockClear();
|
||||
});
|
||||
});
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-shell",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "Shell Layer for AliLowCodeEngine",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -15,11 +15,11 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-designer": "1.0.11",
|
||||
"@alilc/lowcode-editor-core": "1.0.11",
|
||||
"@alilc/lowcode-editor-skeleton": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.11",
|
||||
"@alilc/lowcode-utils": "1.0.11",
|
||||
"@alilc/lowcode-designer": "1.0.12",
|
||||
"@alilc/lowcode-editor-core": "1.0.12",
|
||||
"@alilc/lowcode-editor-skeleton": "1.0.12",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"@alilc/lowcode-utils": "1.0.12",
|
||||
"classnames": "^2.2.6",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-react-16": "^1.15.5",
|
||||
|
||||
@ -136,41 +136,40 @@ export default class Project {
|
||||
* 当前 project 内的 document 变更事件
|
||||
*/
|
||||
onChangeDocument(fn: (doc: DocumentModel) => void) {
|
||||
if (this[projectSymbol].currentDocument) {
|
||||
fn(DocumentModel.create(this[projectSymbol].currentDocument)!);
|
||||
return () => {};
|
||||
}
|
||||
return this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
|
||||
const offFn = this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
|
||||
fn(DocumentModel.create(originalDoc)!);
|
||||
});
|
||||
if (this[projectSymbol].currentDocument) {
|
||||
fn(DocumentModel.create(this[projectSymbol].currentDocument)!);
|
||||
}
|
||||
return offFn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前 project 的模拟器 ready 事件
|
||||
*/
|
||||
onSimulatorHostReady(fn: (host: SimulatorHost) => void) {
|
||||
if (this[simulatorHostSymbol]) {
|
||||
fn(SimulatorHost.create(this[simulatorHostSymbol])!);
|
||||
return () => {};
|
||||
}
|
||||
return this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => {
|
||||
const offFn = this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => {
|
||||
this[simulatorHostSymbol] = simulator;
|
||||
fn(SimulatorHost.create(simulator)!);
|
||||
});
|
||||
if (this[simulatorHostSymbol]) {
|
||||
fn(SimulatorHost.create(this[simulatorHostSymbol])!);
|
||||
}
|
||||
return offFn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前 project 的渲染器 ready 事件
|
||||
*/
|
||||
onSimulatorRendererReady(fn: () => void) {
|
||||
if (this[simulatorRendererSymbol]) {
|
||||
fn();
|
||||
return () => {};
|
||||
}
|
||||
// TODO: 补充 renderer 实例
|
||||
return this[projectSymbol].onRendererReady((renderer: any) => {
|
||||
const offFn = this[projectSymbol].onRendererReady((renderer: any) => {
|
||||
this[simulatorRendererSymbol] = renderer;
|
||||
fn();
|
||||
});
|
||||
if (this[simulatorRendererSymbol]) {
|
||||
fn();
|
||||
}
|
||||
return offFn;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-types",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "Types for Ali lowCode engine",
|
||||
"files": [
|
||||
"es",
|
||||
|
||||
@ -26,7 +26,7 @@ export interface NodeSchema {
|
||||
* 组件属性对象
|
||||
*/
|
||||
props?: {
|
||||
children?: NodeData[];
|
||||
children?: NodeData | NodeData[];
|
||||
} & PropsMap;// | PropsList;
|
||||
/**
|
||||
* 组件属性对象
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-utils",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "Utils for Ali lowCode engine",
|
||||
"files": [
|
||||
"lib",
|
||||
@ -14,7 +14,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.19.16",
|
||||
"@alilc/lowcode-types": "1.0.11",
|
||||
"@alilc/lowcode-types": "1.0.12",
|
||||
"lodash": "^4.17.21",
|
||||
"react": "^16",
|
||||
"zen-logger": "^1.1.0"
|
||||
|
||||
@ -3,6 +3,7 @@ import { NpmInfo, ComponentSchema } from '@alilc/lowcode-types';
|
||||
import { Component } from '@alilc/lowcode-designer';
|
||||
import { isESModule } from './is-es-module';
|
||||
import { isReactComponent, acceptsRef, wrapReactClass } from './is-react';
|
||||
import { isObject } from './is-object';
|
||||
|
||||
interface LibraryMap {
|
||||
[key: string]: string;
|
||||
@ -76,6 +77,22 @@ function findComponent(libraryMap: LibraryMap, componentName: string, npm?: NpmI
|
||||
return getSubComponent(library, paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是一个混合组件,即 components 是一个对象,对象值是 React 组件
|
||||
* 示例:
|
||||
* {
|
||||
* Button: ReactNode,
|
||||
* Text: ReactNode,
|
||||
* }
|
||||
*/
|
||||
function isMixinComponent(components: any) {
|
||||
if (!isObject(components)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Object.keys(components).some(componentName => isReactComponent(components[componentName]));
|
||||
}
|
||||
|
||||
export function buildComponents(libraryMap: LibraryMap,
|
||||
componentsMap: { [componentName: string]: NpmInfo | ComponentType<any> | ComponentSchema },
|
||||
createComponent: (schema: ComponentSchema) => Component | null) {
|
||||
@ -89,6 +106,8 @@ export function buildComponents(libraryMap: LibraryMap,
|
||||
component = wrapReactClass(component as FunctionComponent);
|
||||
}
|
||||
components[componentName] = component;
|
||||
} else if (isMixinComponent(component)) {
|
||||
components[componentName] = component;
|
||||
} else {
|
||||
component = findComponent(libraryMap, componentName, component);
|
||||
if (component) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user