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