mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 14:04:28 +00:00
fix: 解决 device 变化后不刷新视图的 bug
This commit is contained in:
parent
0e7268fae3
commit
11e8e02f70
@ -4,8 +4,9 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"description": "低代码引擎 DEMO",
|
"description": "低代码引擎 DEMO",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cloud-build": "build-scripts build --config cloud-build.json",
|
"start": "build-scripts start",
|
||||||
"start": "build-scripts start"
|
"build": "build-scripts build",
|
||||||
|
"cloud-build": "build-scripts build --config cloud-build.json"
|
||||||
},
|
},
|
||||||
"config": {},
|
"config": {},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -14,5 +14,6 @@ module.exports = {
|
|||||||
'no-useless-constructor': 1,
|
'no-useless-constructor': 1,
|
||||||
'no-empty-function': 1,
|
'no-empty-function': 1,
|
||||||
'@typescript-eslint/member-ordering': 0,
|
'@typescript-eslint/member-ordering': 0,
|
||||||
|
'lines-between-class-members': 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
"build-plugin-component",
|
||||||
"@ali/lowcode-test-mate/plugin/index.ts"
|
"@ali/lowcode-test-mate/plugin/index.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-scripts build --skip-demo",
|
"build": "build-scripts build --skip-demo",
|
||||||
"test": "build-scripts --config build.test.json test"
|
"test": "build-scripts test --config build.test.json"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
12
packages/designer/plugin.js
Normal file
12
packages/designer/plugin.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module.exports = ({ onGetJestConfig, onGetWebpackConfig }) => {
|
||||||
|
console.log('111111111111xxxxxxxxxxxx')
|
||||||
|
onGetWebpackConfig((config) => {
|
||||||
|
console.log('111111111111')
|
||||||
|
config.browserslist('last 2 versions, Firefox ESR, > 1%, ie >= 9, iOS >= 8, Android >= 4');
|
||||||
|
});
|
||||||
|
|
||||||
|
onGetJestConfig((jestConfig) => {
|
||||||
|
console.log('11111111111122222222')
|
||||||
|
return jestConfig;
|
||||||
|
});
|
||||||
|
};
|
||||||
@ -9,7 +9,7 @@ export interface Serialization<T = any> {
|
|||||||
unserialize(data: T): NodeSchema;
|
unserialize(data: T): NodeSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentSerializion: Serialization<any> = {
|
let currentSerialization: Serialization<any> = {
|
||||||
serialize(data: NodeSchema): string {
|
serialize(data: NodeSchema): string {
|
||||||
return JSON.stringify(data);
|
return JSON.stringify(data);
|
||||||
},
|
},
|
||||||
@ -18,8 +18,8 @@ let currentSerializion: Serialization<any> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function setSerialization(serializion: Serialization) {
|
export function setSerialization(serialization: Serialization) {
|
||||||
currentSerializion = serializion;
|
currentSerialization = serialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class History {
|
export class History {
|
||||||
@ -46,7 +46,7 @@ export class History {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
untracked(() => {
|
untracked(() => {
|
||||||
const log = currentSerializion.serialize(data);
|
const log = currentSerialization.serialize(data);
|
||||||
if (this.session.cursor === 0 && this.session.isActive()) {
|
if (this.session.cursor === 0 && this.session.isActive()) {
|
||||||
// first log
|
// first log
|
||||||
this.session.log(log);
|
this.session.log(log);
|
||||||
@ -98,7 +98,7 @@ export class History {
|
|||||||
|
|
||||||
this.obx.sleep();
|
this.obx.sleep();
|
||||||
try {
|
try {
|
||||||
this.redoer(currentSerializion.unserialize(hotData));
|
this.redoer(currentSerialization.unserialize(hotData));
|
||||||
this.emitter.emit('cursor', hotData);
|
this.emitter.emit('cursor', hotData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//
|
//
|
||||||
|
|||||||
19
packages/editor-preset-vision/build.test.json
Normal file
19
packages/editor-preset-vision/build.test.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"build-plugin-component",
|
||||||
|
{
|
||||||
|
"filename": "editor-preset-vision",
|
||||||
|
"library": "LowcodeEditor",
|
||||||
|
"libraryTarget": "umd",
|
||||||
|
"externals": {
|
||||||
|
"react": "var window.React",
|
||||||
|
"react-dom": "var window.ReactDOM",
|
||||||
|
"prop-types": "var window.PropTypes",
|
||||||
|
"rax": "var window.Rax"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@ali/lowcode-test-mate/plugin/index.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
23
packages/editor-preset-vision/jest.config.js
Normal file
23
packages/editor-preset-vision/jest.config.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const esModules = [
|
||||||
|
'@recore/obx-react',
|
||||||
|
'@ali/lowcode-editor-core',
|
||||||
|
].join('|');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
// transform: {
|
||||||
|
// '^.+\\.[jt]sx?$': 'babel-jest',
|
||||||
|
// // '^.+\\.(ts|tsx)$': 'ts-jest',
|
||||||
|
// // '^.+\\.(js|jsx)$': 'babel-jest',
|
||||||
|
// },
|
||||||
|
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
|
||||||
|
transformIgnorePatterns: [
|
||||||
|
`/node_modules/(?!${esModules})/`,
|
||||||
|
],
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
||||||
|
collectCoverage: false,
|
||||||
|
collectCoverageFrom: [
|
||||||
|
'src/**/*.{ts,tsx}',
|
||||||
|
'!**/node_modules/**',
|
||||||
|
'!**/vendor/**',
|
||||||
|
],
|
||||||
|
};
|
||||||
@ -11,7 +11,8 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "build-scripts build --skip-demo",
|
"build": "build-scripts build --skip-demo",
|
||||||
"cloud-build": "build-scripts build --skip-demo"
|
"cloud-build": "build-scripts build --skip-demo",
|
||||||
|
"test": "build-scripts test --config build.test.json"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -37,6 +38,7 @@
|
|||||||
"react-dom": "^16.8.1"
|
"react-dom": "^16.8.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@ali/lowcode-test-mate": "^1.0.0",
|
||||||
"@alib/build-scripts": "^0.1.18",
|
"@alib/build-scripts": "^0.1.18",
|
||||||
"@types/domready": "^1.0.0",
|
"@types/domready": "^1.0.0",
|
||||||
"@types/events": "^3.0.0",
|
"@types/events": "^3.0.0",
|
||||||
@ -45,6 +47,7 @@
|
|||||||
"build-plugin-fusion": "^0.1.0",
|
"build-plugin-fusion": "^0.1.0",
|
||||||
"build-plugin-moment-locales": "^0.1.0",
|
"build-plugin-moment-locales": "^0.1.0",
|
||||||
"build-plugin-react-app": "^1.1.2",
|
"build-plugin-react-app": "^1.1.2",
|
||||||
|
"prop-types": "^15.7.2",
|
||||||
"tsconfig-paths-webpack-plugin": "^3.2.0"
|
"tsconfig-paths-webpack-plugin": "^3.2.0"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|||||||
@ -316,7 +316,7 @@ designer.addPropsReducer(deepValueParser, TransformStage.Render);
|
|||||||
|
|
||||||
// 清除空的 props value
|
// 清除空的 props value
|
||||||
function removeEmptyProps(props: any, node: Node) {
|
function removeEmptyProps(props: any, node: Node) {
|
||||||
if (node.isRoot() && props.dataSource) {
|
if (node.isRoot() && props.dataSource && Array.isArray(props.dataSource.online)) {
|
||||||
const online = cloneDeep(props.dataSource.online);
|
const online = cloneDeep(props.dataSource.online);
|
||||||
online.forEach((item: any) => {
|
online.forEach((item: any) => {
|
||||||
const newParam: any = {};
|
const newParam: any = {};
|
||||||
|
|||||||
@ -166,6 +166,6 @@ const version = '6.0.0(LowcodeEngine 0.9.3)';
|
|||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`%c VisionEngine %c v${version} `,
|
`%c VisionEngine %c v${version} `,
|
||||||
'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060;font-weight:bold;',
|
'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;',
|
||||||
'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e;font-weight:bold;',
|
'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;',
|
||||||
);
|
);
|
||||||
|
|||||||
1111
packages/editor-preset-vision/tests/fixtures/schema/form.ts
vendored
Normal file
1111
packages/editor-preset-vision/tests/fixtures/schema/form.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
packages/editor-preset-vision/tests/fixtures/window.ts
vendored
Normal file
5
packages/editor-preset-vision/tests/fixtures/window.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
React.PropTypes = PropTypes;
|
||||||
|
window.React = React;
|
||||||
46
packages/editor-preset-vision/tests/vision-api/pages.test.ts
Normal file
46
packages/editor-preset-vision/tests/vision-api/pages.test.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import set from 'lodash/set';
|
||||||
|
import cloneDeep from 'lodash/clonedeep';
|
||||||
|
import '../fixtures/window';
|
||||||
|
// import { Project } from '../../src/project/project';
|
||||||
|
// import { Node } from '../../src/document/node/node';
|
||||||
|
// import { Designer } from '../../src/designer/designer';
|
||||||
|
import formSchema from '../fixtures/schema/form';
|
||||||
|
import VisualEngine from '../../src';
|
||||||
|
// import { getIdsFromSchema, getNodeFromSchemaById } from '../utils';
|
||||||
|
|
||||||
|
// const mockCreateSettingEntry = jest.fn();
|
||||||
|
// jest.mock('../../src/designer/designer', () => {
|
||||||
|
// return {
|
||||||
|
// Designer: jest.fn().mockImplementation(() => {
|
||||||
|
// return {
|
||||||
|
// getComponentMeta() {
|
||||||
|
// return {
|
||||||
|
// getMetadata() {
|
||||||
|
// return { experimental: null };
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
// },
|
||||||
|
// transformProps(props) { return props; },
|
||||||
|
// createSettingEntry: mockCreateSettingEntry,
|
||||||
|
// postEvent() {},
|
||||||
|
// };
|
||||||
|
// }),
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// let designer = null;
|
||||||
|
// beforeAll(() => {
|
||||||
|
// designer = new Designer({});
|
||||||
|
// });
|
||||||
|
|
||||||
|
describe('schema 生成节点模型测试', () => {
|
||||||
|
describe('block ❌ | component ❌ | slot ❌', () => {
|
||||||
|
it('基本的节点模型初始化,模型导出,初始化传入 schema', () => {
|
||||||
|
console.log(VisualEngine);
|
||||||
|
|
||||||
|
console.log(VisualEngine.Pages.addPage(formSchema));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -54,5 +54,5 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "http://registry.npm.alibaba-inc.com"
|
"registry": "http://registry.npm.alibaba-inc.com"
|
||||||
},
|
},
|
||||||
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.13.1-10/build/index.html"
|
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.13.1-11/build/index.html"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -339,7 +339,7 @@ export default class BaseRender extends PureComponent {
|
|||||||
if (refProps && typeof refProps === 'string') {
|
if (refProps && typeof refProps === 'string') {
|
||||||
this[refProps] = ref;
|
this[refProps] = ref;
|
||||||
}
|
}
|
||||||
engine && engine.props.onCompGetRef(schema, ref);
|
ref && engine && engine.props.onCompGetRef(schema, ref);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// scope需要传入到组件上
|
// scope需要传入到组件上
|
||||||
|
|||||||
@ -187,7 +187,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
this._componentsMap = host.designer.componentsMap;
|
this._componentsMap = host.designer.componentsMap;
|
||||||
// 需要注意的是,autorun 依赖收集的是同步执行的代码,所以 await / promise / callback 里的变量不会被收集依赖
|
// 需要注意的是,autorun 依赖收集的是同步执行的代码,所以 await / promise / callback 里的变量不会被收集依赖
|
||||||
// 此例中,host.designer.componentsMap 是需要被收集依赖的,否则无法响应式
|
// 此例中,host.designer.componentsMap 是需要被收集依赖的,否则无法响应式
|
||||||
await host.waitForCurrentDocument();
|
// await host.waitForCurrentDocument();
|
||||||
this.buildComponents();
|
this.buildComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,6 +540,7 @@ function getComponentController(schema: NodeSchema, componentsMap: any) {
|
|||||||
|
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
super(props);
|
super(props);
|
||||||
|
console.log('>>> current');
|
||||||
const node = host.currentDocument?.createNode(schema);
|
const node = host.currentDocument?.createNode(schema);
|
||||||
this.renderSchema = node?.export(TransformStage.Render) || {};
|
this.renderSchema = node?.export(TransformStage.Render) || {};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user