mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-04-20 04:18:05 +00:00
Merge branch 'release/1.0.0' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into refactor/runtime
This commit is contained in:
commit
09d5562fe7
@ -13,9 +13,10 @@
|
||||
"build": "./scripts/build.sh",
|
||||
"clean": "rm -rf ./packages/*/lib ./packages/*/es ./packages/*/dist ./packages/*/build",
|
||||
"commit": "git-cz",
|
||||
"pub": "lerna publish --cd-version patch",
|
||||
"pub": "lerna publish --force-publish --cd-version prepatch",
|
||||
"setup": "./scripts/setup.sh",
|
||||
"start": "./scripts/start.sh",
|
||||
"start:server": "./scripts/start-server.sh",
|
||||
"test": "lerna run test --stream",
|
||||
"test:snapshot": "lerna run test:snapshot"
|
||||
},
|
||||
|
||||
@ -3,6 +3,126 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="1.0.7-0"></a>
|
||||
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.6-0...@ali/lowcode-code-generator@1.0.7-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="1.0.6-0"></a>
|
||||
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.5-0...@ali/lowcode-code-generator@1.0.6-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="1.0.5-0"></a>
|
||||
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.4-0...@ali/lowcode-code-generator@1.0.5-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="1.0.4-0"></a>
|
||||
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.3-0...@ali/lowcode-code-generator@1.0.4-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="1.0.3-0"></a>
|
||||
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.2-0...@ali/lowcode-code-generator@1.0.3-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="1.0.2-0"></a>
|
||||
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.1-0...@ali/lowcode-code-generator@1.0.2-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="1.0.1-0"></a>
|
||||
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@1.0.0...@ali/lowcode-code-generator@1.0.1-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.13.0...@ali/lowcode-code-generator@1.0.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="0.13.0"></a>
|
||||
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.12.0...@ali/lowcode-code-generator@0.13.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="0.12.0"></a>
|
||||
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.10.0...@ali/lowcode-code-generator@0.12.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="0.11.0"></a>
|
||||
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.10.0...@ali/lowcode-code-generator@0.11.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.9.0...@ali/lowcode-code-generator@0.10.0) (2020-08-16)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-code-generator
|
||||
|
||||
<a name="0.9.0"></a>
|
||||
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.8.10...@ali/lowcode-code-generator@0.9.0) (2020-08-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 🐛 bugs about deps ([1eabd50](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1eabd50))
|
||||
* 🐛 children in props ([fe0ace8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fe0ace8))
|
||||
* 🐛 get deps info from slot ([6c3ae36](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6c3ae36))
|
||||
* 🐛 group chunks by filetype family ([db144a9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/db144a9))
|
||||
* 🐛 loop bug ([8f53910](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8f53910))
|
||||
* 🐛 repair children before deps analyze ([737d06e](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/737d06e))
|
||||
* 🐛 support JSFunction type ([9061e4b](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9061e4b))
|
||||
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 🎸 add node type mapping config for jsx plugin ([19a51b8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/19a51b8))
|
||||
* 🎸 code generator fix slot support ([e51b9cb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e51b9cb))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.8.10"></a>
|
||||
## [0.8.10](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-code-generator@0.8.9...@ali/lowcode-code-generator@0.8.10) (2020-07-21)
|
||||
|
||||
|
||||
13473
packages/code-generator/demo/assets.json
Normal file
13473
packages/code-generator/demo/assets.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,20 +4,20 @@ const CodeGenerator = require('../lib').default;
|
||||
|
||||
function flatFiles(rootName, dir) {
|
||||
const dirRoot = rootName ? `${rootName}/${dir.name}` : dir.name;
|
||||
const files = dir.files.map(file => ({
|
||||
const files = dir.files.map((file) => ({
|
||||
name: `${dirRoot}/${file.name}.${file.ext}`,
|
||||
content: file.content,
|
||||
ext: '',
|
||||
}));
|
||||
const filesInSub = dir.dirs.map(subDir => flatFiles(`${dirRoot}`, subDir));
|
||||
const result = files.concat.apply(files, filesInSub);
|
||||
const filesInSub = dir.dirs.map((subDir) => flatFiles(`${dirRoot}`, subDir));
|
||||
const result = files.concat(...filesInSub);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function displayResultInConsole(root, fileName) {
|
||||
const files = flatFiles('.', root);
|
||||
files.forEach(file => {
|
||||
files.forEach((file) => {
|
||||
if (!fileName || fileName === file.name) {
|
||||
console.log(`========== ${file.name} Start ==========`);
|
||||
console.log(file.content);
|
||||
@ -37,16 +37,56 @@ async function writeResultToDisk(root, path) {
|
||||
});
|
||||
}
|
||||
|
||||
function getComponentsMap() {
|
||||
const assetJson = fs.readFileSync('./demo/assets.json', { encoding: 'utf8' });
|
||||
const assets = JSON.parse(assetJson);
|
||||
const { components } = assets;
|
||||
|
||||
const componentsMap = components
|
||||
.filter((c) => !!c.npm)
|
||||
.map((c) => ({
|
||||
componentName: c.componentName,
|
||||
...(c.npm || {}),
|
||||
}));
|
||||
|
||||
return componentsMap;
|
||||
}
|
||||
|
||||
function main() {
|
||||
const schemaJson = fs.readFileSync('./demo/sampleSchema.json', { encoding: 'utf8' });
|
||||
const createIceJsProjectBuilder = CodeGenerator.solutions.icejs;
|
||||
const builder = createIceJsProjectBuilder();
|
||||
|
||||
builder.generateProject(schemaJson).then(result => {
|
||||
builder.generateProject(schemaJson).then((result) => {
|
||||
displayResultInConsole(result);
|
||||
writeResultToDisk(result, 'output/lowcodeDemo').then((response) => console.log('Write to disk: ', JSON.stringify(response)),);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
function demo() {
|
||||
const schemaJson = fs.readFileSync('./demo/schema.json', { encoding: 'utf8' });
|
||||
const createIceJsProjectBuilder = CodeGenerator.solutions.icejs;
|
||||
const builder = createIceJsProjectBuilder();
|
||||
|
||||
const componentsMap = getComponentsMap();
|
||||
const root = JSON.parse(schemaJson);
|
||||
|
||||
const fullSchema = {
|
||||
version: '1.0.0',
|
||||
config: {
|
||||
historyMode: 'hash',
|
||||
targetRootID: 'J_Container',
|
||||
},
|
||||
meta: {
|
||||
name: 'demoproject',
|
||||
},
|
||||
componentsTree: [root],
|
||||
componentsMap,
|
||||
};
|
||||
|
||||
builder.generateProject(fullSchema).then((result) => {
|
||||
displayResultInConsole(result);
|
||||
writeResultToDisk(result, 'output/lowcodeDemo').then(response =>
|
||||
console.log('Write to disk: ', JSON.stringify(response)),
|
||||
);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
@ -66,13 +106,11 @@ function exportModule() {
|
||||
CodeGenerator.plugins.react.jsx(),
|
||||
CodeGenerator.plugins.style.css(),
|
||||
],
|
||||
postProcessors: [
|
||||
CodeGenerator.postprocessor.prettier(),
|
||||
],
|
||||
postProcessors: [CodeGenerator.postprocessor.prettier()],
|
||||
mainFileName: 'index',
|
||||
});
|
||||
|
||||
moduleBuilder.generateModuleCode(schemaJson).then(result => {
|
||||
moduleBuilder.generateModuleCode(schemaJson).then((result) => {
|
||||
displayResultInConsole(result);
|
||||
return result;
|
||||
});
|
||||
@ -81,7 +119,7 @@ function exportModule() {
|
||||
function exportProject() {
|
||||
const schemaJson = fs.readFileSync('./demo/sampleSchema.json', { encoding: 'utf8' });
|
||||
|
||||
const builder = CodeGenerator.createProjectBuilder({
|
||||
const builder = CodeGenerator.createProjectBuilder({
|
||||
template: CodeGenerator.solutionParts.icejs.template,
|
||||
plugins: {
|
||||
components: [
|
||||
@ -108,47 +146,26 @@ function exportProject() {
|
||||
CodeGenerator.plugins.react.jsx(),
|
||||
CodeGenerator.plugins.style.css(),
|
||||
],
|
||||
router: [
|
||||
CodeGenerator.plugins.common.esmodule(),
|
||||
CodeGenerator.solutionParts.icejs.plugins.router(),
|
||||
],
|
||||
entry: [
|
||||
CodeGenerator.solutionParts.icejs.plugins.entry(),
|
||||
],
|
||||
constants: [
|
||||
CodeGenerator.plugins.project.constants(),
|
||||
],
|
||||
utils: [
|
||||
CodeGenerator.plugins.common.esmodule(),
|
||||
CodeGenerator.plugins.project.utils(),
|
||||
],
|
||||
i18n: [
|
||||
CodeGenerator.plugins.project.i18n(),
|
||||
],
|
||||
globalStyle: [
|
||||
CodeGenerator.solutionParts.icejs.plugins.globalStyle(),
|
||||
],
|
||||
htmlEntry: [
|
||||
CodeGenerator.solutionParts.icejs.plugins.entryHtml(),
|
||||
],
|
||||
packageJSON: [
|
||||
CodeGenerator.solutionParts.icejs.plugins.packageJSON(),
|
||||
],
|
||||
router: [CodeGenerator.plugins.common.esmodule(), CodeGenerator.solutionParts.icejs.plugins.router()],
|
||||
entry: [CodeGenerator.solutionParts.icejs.plugins.entry()],
|
||||
constants: [CodeGenerator.plugins.project.constants()],
|
||||
utils: [CodeGenerator.plugins.common.esmodule(), CodeGenerator.plugins.project.utils()],
|
||||
i18n: [CodeGenerator.plugins.project.i18n()],
|
||||
globalStyle: [CodeGenerator.solutionParts.icejs.plugins.globalStyle()],
|
||||
htmlEntry: [CodeGenerator.solutionParts.icejs.plugins.entryHtml()],
|
||||
packageJSON: [CodeGenerator.solutionParts.icejs.plugins.packageJSON()],
|
||||
},
|
||||
postProcessors: [
|
||||
CodeGenerator.postprocessor.prettier(),
|
||||
],
|
||||
postProcessors: [CodeGenerator.postprocessor.prettier()],
|
||||
});
|
||||
|
||||
builder.generateProject(schemaJson).then(result => {
|
||||
builder.generateProject(schemaJson).then((result) => {
|
||||
displayResultInConsole(result);
|
||||
writeResultToDisk(result, 'output/lowcodeDemo').then(response =>
|
||||
console.log('Write to disk: ', JSON.stringify(response)),
|
||||
);
|
||||
writeResultToDisk(result, 'output/lowcodeDemo').then((response) => console.log('Write to disk: ', JSON.stringify(response)),);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
// main();
|
||||
// exportModule();
|
||||
exportProject();
|
||||
// exportProject();
|
||||
demo();
|
||||
|
||||
420
packages/code-generator/demo/schema.json
Normal file
420
packages/code-generator/demo/schema.json
Normal file
@ -0,0 +1,420 @@
|
||||
{
|
||||
"componentName": "Page",
|
||||
"id": "node_dockcviv8fo1",
|
||||
"props": {
|
||||
"ref": "outterView",
|
||||
"autoLoading": true,
|
||||
"style": {
|
||||
"padding": "0 5px 0 5px"
|
||||
}
|
||||
},
|
||||
"fileName": "test",
|
||||
"dataSource": {
|
||||
"list": []
|
||||
},
|
||||
"state": {
|
||||
"text": "outter",
|
||||
"isShowDialog": false
|
||||
},
|
||||
"css": "body {font-size: 12px;} .botton{width:100px;color:#ff00ff}",
|
||||
"lifeCycles": {
|
||||
"componentDidMount": {
|
||||
"type": "JSFunction",
|
||||
"value": "function() {\n console.log('did mount');\n }"
|
||||
},
|
||||
"componentWillUnmount": {
|
||||
"type": "JSFunction",
|
||||
"value": "function() {\n console.log('will umount');\n }"
|
||||
}
|
||||
},
|
||||
"methods": {
|
||||
"testFunc": {
|
||||
"type": "JSFunction",
|
||||
"value": "function() {\n console.log('test func');\n }"
|
||||
},
|
||||
"onClick": {
|
||||
"type": "JSFunction",
|
||||
"value": "function(){\n this.setState({\n isShowDialog:true\n })\n\t}"
|
||||
}
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Box",
|
||||
"id": "node_dockcy8n9xed",
|
||||
"props": {
|
||||
"style": {
|
||||
"backgroundColor": "rgba(31,56,88,0.1)",
|
||||
"padding": "12px 12px 12px 12px"
|
||||
}
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Box",
|
||||
"id": "node_dockcy8n9xee",
|
||||
"props": {
|
||||
"style": {
|
||||
"padding": "12px 12px 12px 12px",
|
||||
"backgroundColor": "#ffffff"
|
||||
}
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Breadcrumb",
|
||||
"id": "node_dockcy8n9xef",
|
||||
"props": {
|
||||
"prefix": "next-",
|
||||
"maxNode": 100,
|
||||
"component": "nav"
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Breadcrumb.Item",
|
||||
"id": "node_dockcy8n9xeg",
|
||||
"props": {
|
||||
"prefix": "next-"
|
||||
},
|
||||
"children": ["首页"]
|
||||
}, {
|
||||
"componentName": "Breadcrumb.Item",
|
||||
"id": "node_dockcy8n9xei",
|
||||
"props": {
|
||||
"prefix": "next-"
|
||||
},
|
||||
"children": ["品质中台"]
|
||||
}, {
|
||||
"componentName": "Breadcrumb.Item",
|
||||
"id": "node_dockcy8n9xek",
|
||||
"props": {
|
||||
"prefix": "next-"
|
||||
},
|
||||
"children": ["商家品质页面管理"]
|
||||
}, {
|
||||
"componentName": "Breadcrumb.Item",
|
||||
"id": "node_dockcy8n9xem",
|
||||
"props": {
|
||||
"prefix": "next-"
|
||||
},
|
||||
"children": ["质检知识条配置"]
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
"componentName": "Box",
|
||||
"id": "node_dockcy8n9xeo",
|
||||
"props": {
|
||||
"style": {
|
||||
"marginTop": "12px",
|
||||
"backgroundColor": "#ffffff"
|
||||
}
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Form",
|
||||
"id": "node_dockcy8n9xep",
|
||||
"props": {
|
||||
"inline": true,
|
||||
"style": {
|
||||
"marginTop": "12px",
|
||||
"marginRight": "12px",
|
||||
"marginLeft": "12px"
|
||||
},
|
||||
"__events": []
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Form.Item",
|
||||
"id": "node_dockcy8n9xeq",
|
||||
"props": {
|
||||
"style": {
|
||||
"marginBottom": "0"
|
||||
},
|
||||
"label": "类目名:"
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Select",
|
||||
"id": "node_dockcy8n9xer",
|
||||
"props": {
|
||||
"mode": "single",
|
||||
"hasArrow": true,
|
||||
"cacheValue": true,
|
||||
"style": {
|
||||
"width": "150px"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
"componentName": "Form.Item",
|
||||
"id": "node_dockcy8n9xes",
|
||||
"props": {
|
||||
"style": {
|
||||
"marginBottom": "0"
|
||||
},
|
||||
"label": "项目类型:"
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Select",
|
||||
"id": "node_dockcy8n9xet",
|
||||
"props": {
|
||||
"mode": "single",
|
||||
"hasArrow": true,
|
||||
"cacheValue": true,
|
||||
"style": {
|
||||
"width": "200px"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
"componentName": "Form.Item",
|
||||
"id": "node_dockcy8n9xeu",
|
||||
"props": {
|
||||
"style": {
|
||||
"marginBottom": "0"
|
||||
},
|
||||
"label": "项目 ID:"
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Input",
|
||||
"id": "node_dockcy8n9xev",
|
||||
"props": {
|
||||
"hasBorder": true,
|
||||
"size": "medium",
|
||||
"autoComplete": "off",
|
||||
"style": {
|
||||
"width": "200px"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
"componentName": "Button.Group",
|
||||
"id": "node_dockcy8n9xew",
|
||||
"props": {},
|
||||
"children": [{
|
||||
"componentName": "Button",
|
||||
"id": "node_dockcy8n9xex",
|
||||
"props": {
|
||||
"type": "primary",
|
||||
"style": {
|
||||
"margin": "0 5px 0 5px"
|
||||
},
|
||||
"htmlType": "submit"
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Icon",
|
||||
"id": "node_dockcy8n9xey",
|
||||
"props": {
|
||||
"type": "success"
|
||||
}
|
||||
}, "搜索"]
|
||||
}, {
|
||||
"componentName": "Button",
|
||||
"id": "node_dockcy8n9xe10",
|
||||
"props": {
|
||||
"type": "normal",
|
||||
"style": {
|
||||
"margin": "0 5px 0 5px"
|
||||
},
|
||||
"htmlType": "reset"
|
||||
},
|
||||
"children": ["清空"]
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
"componentName": "Box",
|
||||
"id": "node_dockcy8n9xe12",
|
||||
"props": {
|
||||
"style": {
|
||||
"justifyContent": "flex-end",
|
||||
"display": "flex",
|
||||
"backgroundColor": "#ffffff",
|
||||
"flexDirection": "row",
|
||||
"paddingRight": "24px"
|
||||
}
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Button",
|
||||
"id": "node_dockcy8n9xe13",
|
||||
"props": {
|
||||
"prefix": "next-",
|
||||
"type": "primary",
|
||||
"size": "medium",
|
||||
"htmlType": "button",
|
||||
"component": "button",
|
||||
"style": {
|
||||
"width": "100px"
|
||||
},
|
||||
"events": {
|
||||
"onClick": {
|
||||
"type": "JSFunction",
|
||||
"value": "function(){ this.onClick() }",
|
||||
"__eventData": {
|
||||
"type": "componentEvent",
|
||||
"name": "onClick",
|
||||
"relatedEventName": "onClick"
|
||||
}
|
||||
}
|
||||
},
|
||||
"__events": [{
|
||||
"type": "componentEvent",
|
||||
"name": "onClick",
|
||||
"relatedEventName": "onClick"
|
||||
}],
|
||||
"onClick": {
|
||||
"type": "JSFunction",
|
||||
"value": "function(){ this.onClick() }"
|
||||
}
|
||||
},
|
||||
"children": ["新建配置"]
|
||||
}]
|
||||
}, {
|
||||
"componentName": "Box",
|
||||
"id": "node_dockcy8n9xe15",
|
||||
"props": {
|
||||
"style": {
|
||||
"backgroundColor": "#ffffff"
|
||||
}
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Table",
|
||||
"id": "node_dockcy8n9xe16",
|
||||
"props": {
|
||||
"dataSource": [{
|
||||
"firstCategory": "其他",
|
||||
"secondCategory": "新品预览",
|
||||
"leafCategory": "",
|
||||
"projectType": "标识判断",
|
||||
"projectId": "",
|
||||
"title": "其他类目->新品预览类目类型知识库",
|
||||
"url": "其他",
|
||||
"operation": "编辑"
|
||||
}, {
|
||||
"firstCategory": "其他",
|
||||
"secondCategory": "新品预览",
|
||||
"leafCategory": "",
|
||||
"projectType": "",
|
||||
"projectId": "1",
|
||||
"title": "其他类目->新品预览项目Id知识库",
|
||||
"url": "其他",
|
||||
"operation": "编辑"
|
||||
}],
|
||||
"size": "medium",
|
||||
"prefix": "next-",
|
||||
"hasBorder": true,
|
||||
"hasHeader": true,
|
||||
"isZebra": false,
|
||||
"loading": false,
|
||||
"expandedIndexSimulate": false,
|
||||
"primaryKey": "id",
|
||||
"locale": "zhCN.Table",
|
||||
"crossline": false,
|
||||
"style": {
|
||||
"margin": "24px 12px 24px 12px"
|
||||
}
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Table.Column",
|
||||
"id": "node_dockcy8n9xe17",
|
||||
"props": {
|
||||
"title": "一级类目",
|
||||
"dataIndex": "firstCategory"
|
||||
}
|
||||
}, {
|
||||
"componentName": "Table.Column",
|
||||
"id": "node_dockcy8n9xe18",
|
||||
"props": {
|
||||
"title": "二级类目",
|
||||
"dataIndex": "secondCategory"
|
||||
}
|
||||
}, {
|
||||
"componentName": "Table.Column",
|
||||
"id": "node_dockcy8n9xe19",
|
||||
"props": {
|
||||
"title": "叶子类目",
|
||||
"dataIndex": "leafCategory"
|
||||
}
|
||||
}, {
|
||||
"componentName": "Table.Column",
|
||||
"id": "node_dockcy8n9xe1a",
|
||||
"props": {
|
||||
"title": "项目类型",
|
||||
"dataIndex": "projectType"
|
||||
}
|
||||
}, {
|
||||
"componentName": "Table.Column",
|
||||
"id": "node_dockcy8n9xe1b",
|
||||
"props": {
|
||||
"title": "项目 ID",
|
||||
"dataIndex": "projectId"
|
||||
}
|
||||
}, {
|
||||
"componentName": "Table.Column",
|
||||
"id": "node_dockcy8n9xe1c",
|
||||
"props": {
|
||||
"title": "知识条标题",
|
||||
"dataIndex": "title"
|
||||
}
|
||||
}, {
|
||||
"componentName": "Table.Column",
|
||||
"id": "node_dockcy8n9xe1d",
|
||||
"props": {
|
||||
"title": "知识条链接",
|
||||
"dataIndex": "url"
|
||||
}
|
||||
}, {
|
||||
"componentName": "Table.Column",
|
||||
"id": "node_dockcy8n9xe1e",
|
||||
"props": {
|
||||
"title": "操作",
|
||||
"dataIndex": "operation"
|
||||
}
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
"componentName": "Box",
|
||||
"id": "node_dockcy8n9xe1f",
|
||||
"props": {
|
||||
"style": {
|
||||
"backgroundColor": "#ffffff",
|
||||
"paddingBottom": "24px"
|
||||
}
|
||||
},
|
||||
"children": [{
|
||||
"componentName": "Pagination",
|
||||
"id": "node_dockcy8n9xe1g",
|
||||
"props": {
|
||||
"prefix": "next-",
|
||||
"type": "normal",
|
||||
"shape": "normal",
|
||||
"size": "medium",
|
||||
"defaultCurrent": 1,
|
||||
"total": 100,
|
||||
"pageShowCount": 5,
|
||||
"pageSize": 10,
|
||||
"pageSizePosition": "start",
|
||||
"showJump": true,
|
||||
"style": {
|
||||
"display": "flex",
|
||||
"justifyContent": "flex-end"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
"componentName": "Dialog",
|
||||
"id": "node_dockcy8n9xe1h",
|
||||
"props": {
|
||||
"prefix": "next-",
|
||||
"footerAlign": "right",
|
||||
"footerActions": ["ok", "cancel"],
|
||||
"closeable": "esc,close",
|
||||
"hasMask": true,
|
||||
"align": "cc cc",
|
||||
"minMargin": 40,
|
||||
"visible": {
|
||||
"type": "JSExpression",
|
||||
"value": "this.state.isShowDialog"
|
||||
},
|
||||
"children": {
|
||||
"type": "JSSlot"
|
||||
},
|
||||
"title": "标题",
|
||||
"footer": {
|
||||
"type": "JSSlot"
|
||||
},
|
||||
"events": []
|
||||
}
|
||||
}]
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ali/lowcode-code-generator",
|
||||
"version": "0.8.10",
|
||||
"version": "1.0.7-0",
|
||||
"description": "出码引擎 for LowCode Engine",
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
|
||||
3
packages/code-generator/src/const/file.ts
Normal file
3
packages/code-generator/src/const/file.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { FileType } from '../types/core';
|
||||
|
||||
export const FILE_TYPE_FAMILY = [[FileType.TSX, FileType.TS, FileType.JSX, FileType.JS]];
|
||||
@ -1,28 +1,72 @@
|
||||
import {
|
||||
BuilderComponentPlugin,
|
||||
IChunkBuilder,
|
||||
ICodeChunk,
|
||||
ICodeStruct,
|
||||
} from '../types';
|
||||
import { BuilderComponentPlugin, IChunkBuilder, ICodeChunk, ICodeStruct, FileType } from '../types';
|
||||
|
||||
import { COMMON_SUB_MODULE_NAME } from '../const/generator';
|
||||
import { FILE_TYPE_FAMILY } from '../const/file';
|
||||
|
||||
type ChunkGroupInfo = {
|
||||
chunk: ICodeChunk;
|
||||
familyIdx?: number;
|
||||
};
|
||||
|
||||
function whichFamily(type: FileType): [number, FileType[]] | undefined {
|
||||
const idx = FILE_TYPE_FAMILY.findIndex((family) => family.indexOf(type) >= 0);
|
||||
if (idx < 0) {
|
||||
return undefined;
|
||||
}
|
||||
return [idx, FILE_TYPE_FAMILY[idx]];
|
||||
}
|
||||
|
||||
export const groupChunks = (chunks: ICodeChunk[]): ICodeChunk[][] => {
|
||||
const col = chunks.reduce(
|
||||
(chunksSet: Record<string, ICodeChunk[]>, chunk) => {
|
||||
const fileKey = `${chunk.subModule || COMMON_SUB_MODULE_NAME}.${
|
||||
chunk.fileType
|
||||
}`;
|
||||
if (!chunksSet[fileKey]) {
|
||||
chunksSet[fileKey] = [];
|
||||
const tmp: Record<string, Record<number, number>> = {};
|
||||
const col = chunks.reduce((chunksSet: Record<string, ChunkGroupInfo[]>, chunk) => {
|
||||
const fileKey = chunk.subModule || COMMON_SUB_MODULE_NAME;
|
||||
if (!chunksSet[fileKey]) {
|
||||
chunksSet[fileKey] = [];
|
||||
}
|
||||
const res = whichFamily(chunk.fileType as FileType);
|
||||
const info: ChunkGroupInfo = {
|
||||
chunk,
|
||||
};
|
||||
if (res) {
|
||||
const [familyIdx, family] = res;
|
||||
const rank = family.indexOf(chunk.fileType as FileType);
|
||||
if (tmp[fileKey]) {
|
||||
if (tmp[fileKey][familyIdx] !== undefined) {
|
||||
if (tmp[fileKey][familyIdx] > rank) {
|
||||
tmp[fileKey][familyIdx] = rank;
|
||||
}
|
||||
} else {
|
||||
tmp[fileKey][familyIdx] = rank;
|
||||
}
|
||||
} else {
|
||||
tmp[fileKey] = {};
|
||||
tmp[fileKey][familyIdx] = rank;
|
||||
}
|
||||
chunksSet[fileKey].push(chunk);
|
||||
return chunksSet;
|
||||
},
|
||||
{},
|
||||
);
|
||||
info.familyIdx = familyIdx;
|
||||
}
|
||||
|
||||
return Object.keys(col).map(key => col[key]);
|
||||
chunksSet[fileKey].push(info);
|
||||
return chunksSet;
|
||||
}, {});
|
||||
|
||||
const result: ICodeChunk[][] = [];
|
||||
Object.keys(col).forEach((key) => {
|
||||
const byType: Record<string, ICodeChunk[]> = {};
|
||||
col[key].forEach((info) => {
|
||||
let t: string = info.chunk.fileType;
|
||||
if (info.familyIdx !== undefined) {
|
||||
t = FILE_TYPE_FAMILY[info.familyIdx][tmp[key][info.familyIdx]];
|
||||
info.chunk.fileType = t;
|
||||
}
|
||||
if (!byType[t]) {
|
||||
byType[t] = [];
|
||||
}
|
||||
byType[t].push(info.chunk);
|
||||
});
|
||||
result.push(...Object.keys(byType).map((t) => byType[t]));
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -39,7 +83,7 @@ export default class ChunkBuilder implements IChunkBuilder {
|
||||
this.plugins = plugins;
|
||||
}
|
||||
|
||||
public async run(
|
||||
async run(
|
||||
ir: unknown,
|
||||
initialStructure: ICodeStruct = {
|
||||
ir,
|
||||
@ -64,11 +108,11 @@ export default class ChunkBuilder implements IChunkBuilder {
|
||||
};
|
||||
}
|
||||
|
||||
public getPlugins() {
|
||||
getPlugins() {
|
||||
return this.plugins;
|
||||
}
|
||||
|
||||
public addPlugin(plugin: BuilderComponentPlugin) {
|
||||
addPlugin(plugin: BuilderComponentPlugin) {
|
||||
this.plugins.push(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,29 +37,23 @@ export function createModuleBuilder(
|
||||
const generateModule = async (input: unknown): Promise<ICompiledModule> => {
|
||||
const moduleMainName = options.mainFileName || COMMON_SUB_MODULE_NAME;
|
||||
if (chunkGenerator.getPlugins().length <= 0) {
|
||||
throw new CodeGeneratorError(
|
||||
'No plugins found. Component generation cannot work without any plugins!',
|
||||
);
|
||||
throw new CodeGeneratorError('No plugins found. Component generation cannot work without any plugins!');
|
||||
}
|
||||
|
||||
let files: IResultFile[] = [];
|
||||
|
||||
const { chunks } = await chunkGenerator.run(input);
|
||||
chunks.forEach(fileChunkList => {
|
||||
chunks.forEach((fileChunkList) => {
|
||||
const content = linker.link(fileChunkList);
|
||||
const file = new ResultFile(
|
||||
fileChunkList[0].subModule || moduleMainName,
|
||||
fileChunkList[0].fileType,
|
||||
content,
|
||||
);
|
||||
const file = new ResultFile(fileChunkList[0].subModule || moduleMainName, fileChunkList[0].fileType, content);
|
||||
files.push(file);
|
||||
});
|
||||
|
||||
if (options.postProcessors.length > 0) {
|
||||
files = files.map(file => {
|
||||
files = files.map((file) => {
|
||||
let content = file.content;
|
||||
const type = file.ext;
|
||||
options.postProcessors.forEach(processer => {
|
||||
options.postProcessors.forEach((processer) => {
|
||||
content = processer(content, type);
|
||||
});
|
||||
|
||||
@ -81,25 +75,18 @@ export function createModuleBuilder(
|
||||
const { files } = await generateModule(containerInfo);
|
||||
|
||||
const dir = new ResultDir(containerInfo.moduleName);
|
||||
files.forEach(file => dir.addFile(file));
|
||||
files.forEach((file) => dir.addFile(file));
|
||||
|
||||
return dir;
|
||||
}
|
||||
};
|
||||
|
||||
const linkCodeChunks = (
|
||||
chunks: Record<string, ICodeChunk[]>,
|
||||
fileName: string,
|
||||
) => {
|
||||
const linkCodeChunks = (chunks: Record<string, ICodeChunk[]>, fileName: string) => {
|
||||
const files: IResultFile[] = [];
|
||||
|
||||
Object.keys(chunks).forEach(fileKey => {
|
||||
Object.keys(chunks).forEach((fileKey) => {
|
||||
const fileChunkList = chunks[fileKey];
|
||||
const content = linker.link(fileChunkList);
|
||||
const file = new ResultFile(
|
||||
fileChunkList[0].subModule || fileName,
|
||||
fileChunkList[0].fileType,
|
||||
content,
|
||||
);
|
||||
const file = new ResultFile(fileChunkList[0].subModule || fileName, fileChunkList[0].fileType, content);
|
||||
files.push(file);
|
||||
});
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@ interface IModuleInfo {
|
||||
|
||||
function getDirFromRoot(root: IResultDir, path: string[]): IResultDir {
|
||||
let current: IResultDir = root;
|
||||
path.forEach(p => {
|
||||
const exist = current.dirs.find(d => d.name === p);
|
||||
path.forEach((p) => {
|
||||
const exist = current.dirs.find((d) => d.name === p);
|
||||
if (exist) {
|
||||
current = exist;
|
||||
} else {
|
||||
@ -57,7 +57,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
this.postProcessors = postProcessors;
|
||||
}
|
||||
|
||||
public async generateProject(schema: IProjectSchema | string): Promise<IResultDir> {
|
||||
async generateProject(schema: IProjectSchema | string): Promise<IResultDir> {
|
||||
// Init
|
||||
const schemaParser: ISchemaParser = new SchemaParser();
|
||||
const builders = this.createModuleBuilders();
|
||||
@ -76,7 +76,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
// components
|
||||
// pages
|
||||
const containerBuildResult: IModuleInfo[] = await Promise.all<IModuleInfo>(
|
||||
parseResult.containers.map(async containerInfo => {
|
||||
parseResult.containers.map(async (containerInfo) => {
|
||||
let builder: IModuleBuilder;
|
||||
let path: string[];
|
||||
if (containerInfo.containerType === 'Page') {
|
||||
@ -100,9 +100,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
|
||||
// router
|
||||
if (parseResult.globalRouter && builders.router) {
|
||||
const { files } = await builders.router.generateModule(
|
||||
parseResult.globalRouter,
|
||||
);
|
||||
const { files } = await builders.router.generateModule(parseResult.globalRouter);
|
||||
|
||||
buildResult.push({
|
||||
path: this.template.slots.router.path,
|
||||
@ -112,9 +110,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
|
||||
// entry
|
||||
if (parseResult.project && builders.entry) {
|
||||
const { files } = await builders.entry.generateModule(
|
||||
parseResult.project,
|
||||
);
|
||||
const { files } = await builders.entry.generateModule(parseResult.project);
|
||||
|
||||
buildResult.push({
|
||||
path: this.template.slots.entry.path,
|
||||
@ -122,14 +118,8 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
});
|
||||
}
|
||||
// constants?
|
||||
if (
|
||||
parseResult.project &&
|
||||
builders.constants &&
|
||||
this.template.slots.constants
|
||||
) {
|
||||
const { files } = await builders.constants.generateModule(
|
||||
parseResult.project,
|
||||
);
|
||||
if (parseResult.project && builders.constants && this.template.slots.constants) {
|
||||
const { files } = await builders.constants.generateModule(parseResult.project);
|
||||
|
||||
buildResult.push({
|
||||
path: this.template.slots.constants.path,
|
||||
@ -137,14 +127,8 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
});
|
||||
}
|
||||
// utils?
|
||||
if (
|
||||
parseResult.globalUtils &&
|
||||
builders.utils &&
|
||||
this.template.slots.utils
|
||||
) {
|
||||
const { files } = await builders.utils.generateModule(
|
||||
parseResult.globalUtils,
|
||||
);
|
||||
if (parseResult.globalUtils && builders.utils && this.template.slots.utils) {
|
||||
const { files } = await builders.utils.generateModule(parseResult.globalUtils);
|
||||
|
||||
buildResult.push({
|
||||
path: this.template.slots.utils.path,
|
||||
@ -153,9 +137,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
}
|
||||
// i18n?
|
||||
if (parseResult.globalI18n && builders.i18n && this.template.slots.i18n) {
|
||||
const { files } = await builders.i18n.generateModule(
|
||||
parseResult.globalI18n,
|
||||
);
|
||||
const { files } = await builders.i18n.generateModule(parseResult.globalI18n);
|
||||
|
||||
buildResult.push({
|
||||
path: this.template.slots.i18n.path,
|
||||
@ -164,9 +146,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
}
|
||||
// globalStyle
|
||||
if (parseResult.project && builders.globalStyle) {
|
||||
const { files } = await builders.globalStyle.generateModule(
|
||||
parseResult.project,
|
||||
);
|
||||
const { files } = await builders.globalStyle.generateModule(parseResult.project);
|
||||
|
||||
buildResult.push({
|
||||
path: this.template.slots.globalStyle.path,
|
||||
@ -175,9 +155,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
}
|
||||
// htmlEntry
|
||||
if (parseResult.project && builders.htmlEntry) {
|
||||
const { files } = await builders.htmlEntry.generateModule(
|
||||
parseResult.project,
|
||||
);
|
||||
const { files } = await builders.htmlEntry.generateModule(parseResult.project);
|
||||
|
||||
buildResult.push({
|
||||
path: this.template.slots.htmlEntry.path,
|
||||
@ -186,9 +164,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
}
|
||||
// packageJSON
|
||||
if (parseResult.project && builders.packageJSON) {
|
||||
const { files } = await builders.packageJSON.generateModule(
|
||||
parseResult.project,
|
||||
);
|
||||
const { files } = await builders.packageJSON.generateModule(parseResult.project);
|
||||
|
||||
buildResult.push({
|
||||
path: this.template.slots.packageJSON.path,
|
||||
@ -199,14 +175,14 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
// Post Process
|
||||
|
||||
// Combine Modules
|
||||
buildResult.forEach(moduleInfo => {
|
||||
buildResult.forEach((moduleInfo) => {
|
||||
let targetDir = getDirFromRoot(projectRoot, moduleInfo.path);
|
||||
if (moduleInfo.moduleName) {
|
||||
const dir = new ResultDir(moduleInfo.moduleName);
|
||||
targetDir.addDirectory(dir);
|
||||
targetDir = dir;
|
||||
}
|
||||
moduleInfo.files.forEach(file => targetDir.addFile(file));
|
||||
moduleInfo.files.forEach((file) => targetDir.addFile(file));
|
||||
});
|
||||
|
||||
return projectRoot;
|
||||
@ -215,7 +191,7 @@ export class ProjectBuilder implements IProjectBuilder {
|
||||
private createModuleBuilders(): Record<string, IModuleBuilder> {
|
||||
const builders: Record<string, IModuleBuilder> = {};
|
||||
|
||||
Object.keys(this.plugins).forEach(pluginName => {
|
||||
Object.keys(this.plugins).forEach((pluginName) => {
|
||||
if (this.plugins[pluginName].length > 0) {
|
||||
const options: { mainFileName?: string } = {};
|
||||
if (this.template.slots[pluginName] && this.template.slots[pluginName].fileName) {
|
||||
|
||||
@ -11,11 +11,7 @@ import createRecoreProjectBuilder from './solutions/recore';
|
||||
|
||||
// 引入说明
|
||||
import { REACT_CHUNK_NAME } from './plugins/component/react/const';
|
||||
import {
|
||||
COMMON_CHUNK_NAME,
|
||||
CLASS_DEFINE_CHUNK_NAME,
|
||||
DEFAULT_LINK_AFTER,
|
||||
} from './const/generator';
|
||||
import { COMMON_CHUNK_NAME, CLASS_DEFINE_CHUNK_NAME, DEFAULT_LINK_AFTER } from './const/generator';
|
||||
|
||||
// 引入通用插件组
|
||||
import esmodule from './plugins/common/esmodule';
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
|
||||
import { SUPPORT_SCHEMA_VERSION_LIST } from '../const';
|
||||
|
||||
import { handleChildren } from '../utils/nodeToJSX';
|
||||
import { handleSubNodes } from '../utils/nodeToJSX';
|
||||
import { uniqueArray } from '../utils/common';
|
||||
|
||||
import {
|
||||
ChildNodeType,
|
||||
@ -24,6 +25,7 @@ import {
|
||||
IProjectSchema,
|
||||
ISchemaParser,
|
||||
IUtilItem,
|
||||
INpmPackage,
|
||||
} from '../types';
|
||||
|
||||
const defaultContainer: IContainerInfo = {
|
||||
@ -36,17 +38,15 @@ const defaultContainer: IContainerInfo = {
|
||||
};
|
||||
|
||||
class SchemaParser implements ISchemaParser {
|
||||
public validate(schema: IBasicSchema): boolean {
|
||||
validate(schema: IBasicSchema): boolean {
|
||||
if (SUPPORT_SCHEMA_VERSION_LIST.indexOf(schema.version) < 0) {
|
||||
throw new CompatibilityError(
|
||||
`Not support schema with version [${schema.version}]`,
|
||||
);
|
||||
throw new CompatibilityError(`Not support schema with version [${schema.version}]`);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(schemaSrc: IProjectSchema | string): IParseResult {
|
||||
parse(schemaSrc: IProjectSchema | string): IParseResult {
|
||||
// TODO: collect utils depends in JSExpression
|
||||
const compDeps: Record<string, IExternalDependency> = {};
|
||||
const internalDeps: Record<string, IInternalDependency> = {};
|
||||
@ -64,7 +64,7 @@ class SchemaParser implements ISchemaParser {
|
||||
}
|
||||
|
||||
// 解析三方组件依赖
|
||||
schema.componentsMap.forEach(info => {
|
||||
schema.componentsMap.forEach((info) => {
|
||||
info.dependencyType = DependencyType.External;
|
||||
info.importName = info.componentName;
|
||||
compDeps[info.componentName] = info;
|
||||
@ -73,8 +73,7 @@ class SchemaParser implements ISchemaParser {
|
||||
let containers: IContainerInfo[];
|
||||
// Test if this is a lowcode component without container
|
||||
if (schema.componentsTree.length > 0) {
|
||||
const firstRoot: IContainerNodeItem = schema
|
||||
.componentsTree[0] as IContainerNodeItem;
|
||||
const firstRoot: IContainerNodeItem = schema.componentsTree[0] as IContainerNodeItem;
|
||||
|
||||
if (!firstRoot.fileName) {
|
||||
// 整个 schema 描述一个容器,且无根节点定义
|
||||
@ -85,7 +84,7 @@ class SchemaParser implements ISchemaParser {
|
||||
containers = [container];
|
||||
} else {
|
||||
// 普通带 1 到多个容器的 schema
|
||||
containers = schema.componentsTree.map(n => {
|
||||
containers = schema.componentsTree.map((n) => {
|
||||
const subRoot = n as IContainerNodeItem;
|
||||
const container: IContainerInfo = {
|
||||
...subRoot,
|
||||
@ -100,7 +99,7 @@ class SchemaParser implements ISchemaParser {
|
||||
}
|
||||
|
||||
// 建立所有容器的内部依赖索引
|
||||
containers.forEach(container => {
|
||||
containers.forEach((container) => {
|
||||
let type;
|
||||
switch (container.containerType) {
|
||||
case 'Page':
|
||||
@ -125,23 +124,42 @@ class SchemaParser implements ISchemaParser {
|
||||
internalDeps[dep.moduleName] = dep;
|
||||
});
|
||||
|
||||
// 分析容器内部组件依赖
|
||||
containers.forEach(container => {
|
||||
// TODO: 不应该在出码部分解决?
|
||||
// 处理 children 写在了 props 里的情况
|
||||
containers.forEach((container) => {
|
||||
if (container.children) {
|
||||
// const depNames = this.getComponentNames(container.children);
|
||||
// container.deps = uniqueArray<string>(depNames)
|
||||
// .map(depName => internalDeps[depName] || compDeps[depName])
|
||||
// .filter(dep => !!dep);
|
||||
container.deps = Object.keys(compDeps).map(
|
||||
depName => compDeps[depName],
|
||||
handleSubNodes<string>(
|
||||
container.children,
|
||||
{
|
||||
node: (i: IComponentNodeItem) => {
|
||||
if (i.props && i.props.children && !i.children) {
|
||||
i.children = i.props.children as ChildNodeType;
|
||||
}
|
||||
return [''];
|
||||
},
|
||||
},
|
||||
{
|
||||
rerun: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// 分析容器内部组件依赖
|
||||
containers.forEach((container) => {
|
||||
if (container.children) {
|
||||
const depNames = this.getComponentNames(container.children);
|
||||
container.deps = uniqueArray<string>(depNames, (i: string) => i)
|
||||
.map((depName) => internalDeps[depName] || compDeps[depName])
|
||||
.filter((dep) => !!dep);
|
||||
// container.deps = Object.keys(compDeps).map((depName) => compDeps[depName]);
|
||||
}
|
||||
});
|
||||
|
||||
// 分析路由配置
|
||||
const routes = containers
|
||||
.filter(container => container.containerType === 'Page')
|
||||
.map(page => {
|
||||
.filter((container) => container.containerType === 'Page')
|
||||
.map((page) => {
|
||||
const meta = page.meta as IPageMeta;
|
||||
if (meta) {
|
||||
return {
|
||||
@ -156,20 +174,28 @@ class SchemaParser implements ISchemaParser {
|
||||
});
|
||||
|
||||
const routerDeps = routes
|
||||
.map(r => internalDeps[r.componentName] || compDeps[r.componentName])
|
||||
.filter(dep => !!dep);
|
||||
.map((r) => internalDeps[r.componentName] || compDeps[r.componentName])
|
||||
.filter((dep) => !!dep);
|
||||
|
||||
// 分析 Utils 依赖
|
||||
let utils: IUtilItem[];
|
||||
if (schema.utils) {
|
||||
utils = schema.utils;
|
||||
utilsDeps = schema.utils
|
||||
.filter(u => u.type !== 'function')
|
||||
.map(u => u.content as IExternalDependency);
|
||||
utilsDeps = schema.utils.filter((u) => u.type !== 'function').map((u) => u.content as IExternalDependency);
|
||||
} else {
|
||||
utils = [];
|
||||
}
|
||||
|
||||
// 分析项目 npm 依赖
|
||||
let npms: INpmPackage[] = [];
|
||||
containers.forEach((con) => {
|
||||
const p = (con.deps || [])
|
||||
.map((dep) => (dep.dependencyType === DependencyType.External ? dep : null))
|
||||
.filter((dep) => dep !== null);
|
||||
npms.push(...((p as unknown) as INpmPackage[]));
|
||||
});
|
||||
npms = uniqueArray<INpmPackage>(npms, (i) => i.package);
|
||||
|
||||
return {
|
||||
containers,
|
||||
globalUtils: {
|
||||
@ -187,14 +213,21 @@ class SchemaParser implements ISchemaParser {
|
||||
css: schema.css,
|
||||
constants: schema.constants,
|
||||
i18n: schema.i18n,
|
||||
packages: npms,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public getComponentNames(children: ChildNodeType): string[] {
|
||||
return handleChildren<string>(children, {
|
||||
node: (i: IComponentNodeItem) => [i.componentName],
|
||||
});
|
||||
getComponentNames(children: ChildNodeType): string[] {
|
||||
return handleSubNodes<string>(
|
||||
children,
|
||||
{
|
||||
node: (i: IComponentNodeItem) => [i.componentName],
|
||||
},
|
||||
{
|
||||
rerun: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,8 @@ import {
|
||||
IWithDependency,
|
||||
} from '../../types';
|
||||
|
||||
import { isValidIdentifier } from '../../utils/validate';
|
||||
|
||||
function groupDepsByPack(deps: IDependency[]): Record<string, IDependency[]> {
|
||||
const depMap: Record<string, IDependency[]> = {};
|
||||
|
||||
@ -25,48 +27,53 @@ function groupDepsByPack(deps: IDependency[]): Record<string, IDependency[]> {
|
||||
depMap[pkg].push(dep);
|
||||
};
|
||||
|
||||
deps.forEach(dep => {
|
||||
// TODO: main 这个信息到底怎么用,是不是外部包不需要使用?
|
||||
// deps.forEach(dep => {
|
||||
// if (dep.dependencyType === DependencyType.Internal) {
|
||||
// addDep(
|
||||
// `${(dep as IInternalDependency).moduleName}${`/${dep.main}` || ''}`,
|
||||
// dep,
|
||||
// );
|
||||
// } else {
|
||||
// addDep(`${(dep as IExternalDependency).package}${`/${dep.main}` || ''}`, dep);
|
||||
// }
|
||||
// });
|
||||
|
||||
deps.forEach((dep) => {
|
||||
if (dep.dependencyType === DependencyType.Internal) {
|
||||
addDep(
|
||||
`${(dep as IInternalDependency).moduleName}${dep.main || ''}`,
|
||||
dep,
|
||||
);
|
||||
addDep(`${(dep as IInternalDependency).moduleName}`, dep);
|
||||
} else {
|
||||
addDep(`${(dep as IExternalDependency).package}${dep.main || ''}`, dep);
|
||||
addDep(`${(dep as IExternalDependency).package}`, dep);
|
||||
}
|
||||
});
|
||||
|
||||
return depMap;
|
||||
}
|
||||
|
||||
function buildPackageImport(
|
||||
pkg: string,
|
||||
deps: IDependency[],
|
||||
targetFileType: string,
|
||||
): ICodeChunk[] {
|
||||
function buildPackageImport(pkg: string, deps: IDependency[], targetFileType: string): ICodeChunk[] {
|
||||
const chunks: ICodeChunk[] = [];
|
||||
let defaultImport: string = '';
|
||||
let defaultImportAs: string = '';
|
||||
let defaultImport = '';
|
||||
let defaultImportAs = '';
|
||||
const imports: Record<string, string> = {};
|
||||
|
||||
deps.forEach(dep => {
|
||||
deps.forEach((dep) => {
|
||||
const srcName = dep.exportName;
|
||||
let targetName = dep.importName || dep.exportName;
|
||||
if (dep.subName) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dep.subName) {
|
||||
chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: targetFileType,
|
||||
name: COMMON_CHUNK_NAME.FileVarDefine,
|
||||
content: `const ${targetName} = ${srcName}.${dep.subName};`,
|
||||
linkAfter: [
|
||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||
],
|
||||
});
|
||||
if (targetName !== `${srcName}.${dep.subName}`) {
|
||||
if (!isValidIdentifier(targetName)) {
|
||||
throw new CodeGeneratorError(`Invalid Identifier [${targetName}]`);
|
||||
}
|
||||
|
||||
chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: targetFileType,
|
||||
name: COMMON_CHUNK_NAME.FileVarDefine,
|
||||
content: `const ${targetName} = ${srcName}.${dep.subName};`,
|
||||
linkAfter: [COMMON_CHUNK_NAME.ExternalDepsImport, COMMON_CHUNK_NAME.InternalDepsImport],
|
||||
});
|
||||
}
|
||||
|
||||
targetName = srcName;
|
||||
}
|
||||
@ -74,18 +81,14 @@ function buildPackageImport(
|
||||
if (dep.destructuring) {
|
||||
imports[srcName] = targetName;
|
||||
} else if (defaultImport) {
|
||||
throw new CodeGeneratorError(
|
||||
`[${pkg}] has more than one default export.`,
|
||||
);
|
||||
throw new CodeGeneratorError(`[${pkg}] has more than one default export.`);
|
||||
} else {
|
||||
defaultImport = srcName;
|
||||
defaultImportAs = targetName;
|
||||
}
|
||||
});
|
||||
|
||||
const items = Object.keys(imports).map(src =>
|
||||
src === imports[src] ? src : `${src} as ${imports[src]}`,
|
||||
);
|
||||
const items = Object.keys(imports).map((src) => (src === imports[src] ? src : `${src} as ${imports[src]}`));
|
||||
|
||||
const statementL = ['import'];
|
||||
if (defaultImport) {
|
||||
@ -125,7 +128,7 @@ function buildPackageImport(
|
||||
|
||||
type PluginConfig = {
|
||||
fileType: string;
|
||||
}
|
||||
};
|
||||
|
||||
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?: PluginConfig) => {
|
||||
const cfg: PluginConfig = {
|
||||
@ -143,9 +146,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?: Plu
|
||||
if (ir && ir.deps && ir.deps.length > 0) {
|
||||
const packs = groupDepsByPack(ir.deps);
|
||||
|
||||
Object.keys(packs).forEach(pkg => {
|
||||
Object.keys(packs).forEach((pkg) => {
|
||||
const chunks = buildPackageImport(pkg, packs[pkg], cfg.fileType);
|
||||
next.chunks.push.apply(next.chunks, chunks);
|
||||
next.chunks.push(...chunks);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ import {
|
||||
|
||||
type PluginConfig = {
|
||||
fileType: string;
|
||||
}
|
||||
};
|
||||
|
||||
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
|
||||
const cfg: PluginConfig = {
|
||||
@ -30,9 +30,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
|
||||
if (ir.state) {
|
||||
const state = ir.state;
|
||||
const fields = Object.keys(state).map<string>(stateName => {
|
||||
const [isString, value] = generateCompositeType(state[stateName]);
|
||||
return `${stateName}: ${isString ? `'${value}'` : value},`;
|
||||
const fields = Object.keys(state).map<string>((stateName) => {
|
||||
const value = generateCompositeType(state[stateName]);
|
||||
return `${stateName}: ${value},`;
|
||||
});
|
||||
|
||||
next.chunks.push({
|
||||
|
||||
@ -14,7 +14,7 @@ import {
|
||||
type PluginConfig = {
|
||||
fileType: string;
|
||||
implementType: 'inConstructor' | 'insMember' | 'hooks';
|
||||
}
|
||||
};
|
||||
|
||||
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
|
||||
const cfg: PluginConfig = {
|
||||
@ -32,9 +32,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
|
||||
if (ir.state) {
|
||||
const state = ir.state;
|
||||
const fields = Object.keys(state).map<string>(stateName => {
|
||||
const [isString, value] = generateCompositeType(state[stateName]);
|
||||
return `${stateName}: ${isString ? `'${value}'` : value},`;
|
||||
const fields = Object.keys(state).map<string>((stateName) => {
|
||||
const value = generateCompositeType(state[stateName]);
|
||||
return `${stateName}: ${value},`;
|
||||
});
|
||||
|
||||
if (cfg.implementType === 'inConstructor') {
|
||||
|
||||
@ -1,28 +1,23 @@
|
||||
import { CLASS_DEFINE_CHUNK_NAME, DEFAULT_LINK_AFTER } from '../../../const/generator';
|
||||
import { REACT_CHUNK_NAME } from './const';
|
||||
|
||||
import {
|
||||
getFuncExprBody,
|
||||
transformFuncExpr2MethodMember,
|
||||
} from '../../../utils/jsExpression';
|
||||
import { generateFunction } from '../../../utils/jsExpression';
|
||||
|
||||
import {
|
||||
BuilderComponentPlugin,
|
||||
BuilderComponentPluginFactory,
|
||||
ChunkType,
|
||||
CodeGeneratorError,
|
||||
FileType,
|
||||
ICodeChunk,
|
||||
ICodeStruct,
|
||||
IContainerInfo,
|
||||
IJSExpression,
|
||||
} from '../../../types';
|
||||
|
||||
type PluginConfig = {
|
||||
fileType: string;
|
||||
exportNameMapping: Record<string, string>;
|
||||
normalizeNameMapping: Record<string, string>;
|
||||
}
|
||||
};
|
||||
|
||||
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
|
||||
const cfg: PluginConfig = {
|
||||
@ -41,7 +36,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
|
||||
if (ir.lifeCycles) {
|
||||
const lifeCycles = ir.lifeCycles;
|
||||
const chunks = Object.keys(lifeCycles).map<ICodeChunk>(lifeCycleName => {
|
||||
const chunks = Object.keys(lifeCycles).map<ICodeChunk>((lifeCycleName) => {
|
||||
const normalizeName = cfg.normalizeNameMapping[lifeCycleName] || lifeCycleName;
|
||||
const exportName = cfg.exportNameMapping[lifeCycleName] || lifeCycleName;
|
||||
if (normalizeName === 'constructor') {
|
||||
@ -49,9 +44,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
type: ChunkType.STRING,
|
||||
fileType: cfg.fileType,
|
||||
name: CLASS_DEFINE_CHUNK_NAME.ConstructorContent,
|
||||
content: getFuncExprBody(
|
||||
(lifeCycles[lifeCycleName] as IJSExpression).value,
|
||||
),
|
||||
content: generateFunction(lifeCycles[lifeCycleName], { isBlock: true }),
|
||||
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.ConstructorStart]],
|
||||
};
|
||||
}
|
||||
@ -60,9 +53,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
type: ChunkType.STRING,
|
||||
fileType: cfg.fileType,
|
||||
name: REACT_CHUNK_NAME.ClassRenderPre,
|
||||
content: getFuncExprBody(
|
||||
(lifeCycles[lifeCycleName] as IJSExpression).value,
|
||||
),
|
||||
content: generateFunction(lifeCycles[lifeCycleName], { isBlock: true }),
|
||||
linkAfter: [REACT_CHUNK_NAME.ClassRenderStart],
|
||||
};
|
||||
}
|
||||
@ -71,15 +62,12 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
type: ChunkType.STRING,
|
||||
fileType: cfg.fileType,
|
||||
name: CLASS_DEFINE_CHUNK_NAME.InsMethod,
|
||||
content: transformFuncExpr2MethodMember(
|
||||
exportName,
|
||||
(lifeCycles[lifeCycleName] as IJSExpression).value,
|
||||
),
|
||||
content: generateFunction(lifeCycles[lifeCycleName], { name: exportName, isMember: true }),
|
||||
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsMethod]],
|
||||
};
|
||||
});
|
||||
|
||||
next.chunks.push.apply(next.chunks, chunks);
|
||||
next.chunks.push(...chunks);
|
||||
}
|
||||
|
||||
return next;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { CLASS_DEFINE_CHUNK_NAME, DEFAULT_LINK_AFTER } from '../../../const/generator';
|
||||
|
||||
import { transformFuncExpr2MethodMember } from '../../../utils/jsExpression';
|
||||
import { generateFunction } from '../../../utils/jsExpression';
|
||||
|
||||
import {
|
||||
BuilderComponentPlugin,
|
||||
@ -10,12 +10,11 @@ import {
|
||||
ICodeChunk,
|
||||
ICodeStruct,
|
||||
IContainerInfo,
|
||||
IJSExpression,
|
||||
} from '../../../types';
|
||||
|
||||
type PluginConfig = {
|
||||
fileType: string;
|
||||
}
|
||||
};
|
||||
|
||||
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
|
||||
const cfg: PluginConfig = {
|
||||
@ -32,18 +31,15 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
|
||||
if (ir.methods) {
|
||||
const methods = ir.methods;
|
||||
const chunks = Object.keys(methods).map<ICodeChunk>(methodName => ({
|
||||
const chunks = Object.keys(methods).map<ICodeChunk>((methodName) => ({
|
||||
type: ChunkType.STRING,
|
||||
fileType: cfg.fileType,
|
||||
name: CLASS_DEFINE_CHUNK_NAME.InsMethod,
|
||||
content: transformFuncExpr2MethodMember(
|
||||
methodName,
|
||||
(methods[methodName] as IJSExpression).value,
|
||||
),
|
||||
content: generateFunction(methods[methodName], { name: methodName, isMember: true }),
|
||||
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsMethod]],
|
||||
}));
|
||||
|
||||
next.chunks.push.apply(next.chunks, chunks);
|
||||
next.chunks.push(...chunks);
|
||||
}
|
||||
|
||||
return next;
|
||||
|
||||
@ -12,16 +12,18 @@ import { REACT_CHUNK_NAME } from './const';
|
||||
import { createReactNodeGenerator } from '../../../utils/nodeToJSX';
|
||||
|
||||
type PluginConfig = {
|
||||
fileType: string;
|
||||
fileType?: string;
|
||||
nodeTypeMapping?: Record<string, string>;
|
||||
}
|
||||
|
||||
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
|
||||
const cfg: PluginConfig = {
|
||||
const cfg = {
|
||||
fileType: FileType.JSX,
|
||||
nodeTypeMapping: {},
|
||||
...config,
|
||||
};
|
||||
|
||||
const generator = createReactNodeGenerator();
|
||||
const generator = createReactNodeGenerator({ nodeTypeMapping: cfg.nodeTypeMapping });
|
||||
|
||||
const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {
|
||||
const next: ICodeStruct = {
|
||||
|
||||
@ -11,7 +11,7 @@ import {
|
||||
CompositeValue,
|
||||
} from '../../../types';
|
||||
|
||||
import { generateCompositeType, handleStringValueDefault } from '../../../utils/compositeType';
|
||||
import { generateCompositeType } from '../../../utils/compositeType';
|
||||
import { generateExpression } from '../../../utils/jsExpression';
|
||||
|
||||
function packJsExpression(exp: unknown): string {
|
||||
@ -29,24 +29,23 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
const ir = next.ir as IContainerInfo;
|
||||
if (ir.dataSource) {
|
||||
const { dataSource } = ir;
|
||||
const {
|
||||
list,
|
||||
...rest
|
||||
} = dataSource;
|
||||
const { list, ...rest } = dataSource;
|
||||
|
||||
let attrs: string[] = [];
|
||||
|
||||
const extConfigs = Object.keys(rest).map(extConfigName => {
|
||||
const extConfigs = Object.keys(rest).map((extConfigName) => {
|
||||
const value = (rest as Record<string, CompositeValue>)[extConfigName];
|
||||
const [isString, valueStr] = generateCompositeType(value);
|
||||
return `${extConfigName}: ${isString ? `'${valueStr}'` : valueStr}`;
|
||||
const valueStr = generateCompositeType(value);
|
||||
return `${extConfigName}: ${valueStr}`;
|
||||
});
|
||||
|
||||
attrs = [...attrs, ...extConfigs];
|
||||
|
||||
const listProp = handleStringValueDefault(generateCompositeType(list as unknown as CompositeValue, {
|
||||
expression: packJsExpression,
|
||||
}));
|
||||
const listProp = generateCompositeType((list as unknown) as CompositeValue, {
|
||||
handlers: {
|
||||
expression: packJsExpression,
|
||||
},
|
||||
});
|
||||
|
||||
attrs.push(`list: ${listProp}`);
|
||||
|
||||
|
||||
@ -5,27 +5,30 @@ import {
|
||||
ICodeStruct,
|
||||
IContainerInfo,
|
||||
IComponentNodeItem,
|
||||
INodeGeneratorContext,
|
||||
CodePiece,
|
||||
PIECE_TYPE,
|
||||
} from '../../../types';
|
||||
import { COMMON_CHUNK_NAME, DEFAULT_LINK_AFTER } from '../../../const/generator';
|
||||
import { COMMON_CHUNK_NAME } from '../../../const/generator';
|
||||
|
||||
import { createNodeGenerator, generateString } from '../../../utils/nodeToJSX';
|
||||
import { generateExpression } from '../../../utils/jsExpression';
|
||||
import { generateCompositeType, handleStringValueDefault } from '../../../utils/compositeType';
|
||||
import { generateCompositeType } from '../../../utils/compositeType';
|
||||
|
||||
const generateGlobalProps = (nodeItem: IComponentNodeItem): CodePiece[] => {
|
||||
return [{
|
||||
value: `{...globalProps.${nodeItem.componentName}}`,
|
||||
type: PIECE_TYPE.ATTR,
|
||||
}];
|
||||
const generateGlobalProps = (ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] => {
|
||||
return [
|
||||
{
|
||||
value: `{...globalProps.${nodeItem.componentName}}`,
|
||||
type: PIECE_TYPE.ATTR,
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
const generateCtrlLine = (nodeItem: IComponentNodeItem): CodePiece[] => {
|
||||
const generateCtrlLine = (ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] => {
|
||||
const pieces: CodePiece[] = [];
|
||||
|
||||
if (nodeItem.loop && nodeItem.loopArgs) {
|
||||
const loopDataExp = handleStringValueDefault(generateCompositeType(nodeItem.loop));
|
||||
const loopDataExp = generateCompositeType(nodeItem.loop);
|
||||
pieces.push({
|
||||
type: PIECE_TYPE.ATTR,
|
||||
value: `x-for={${loopDataExp}}`,
|
||||
@ -38,7 +41,7 @@ const generateCtrlLine = (nodeItem: IComponentNodeItem): CodePiece[] => {
|
||||
}
|
||||
|
||||
if (nodeItem.condition) {
|
||||
const conditionExp = handleStringValueDefault(generateCompositeType(nodeItem.condition));
|
||||
const conditionExp = generateCompositeType(nodeItem.condition);
|
||||
pieces.push({
|
||||
type: PIECE_TYPE.ATTR,
|
||||
value: `x-if={${conditionExp}}`,
|
||||
@ -49,13 +52,13 @@ const generateCtrlLine = (nodeItem: IComponentNodeItem): CodePiece[] => {
|
||||
};
|
||||
|
||||
const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
const generator = createNodeGenerator({
|
||||
string: generateString,
|
||||
expression: (input) => [generateExpression(input)],
|
||||
}, [
|
||||
generateGlobalProps,
|
||||
generateCtrlLine,
|
||||
]);
|
||||
const generator = createNodeGenerator(
|
||||
{
|
||||
string: generateString,
|
||||
expression: (input) => [generateExpression(input)],
|
||||
},
|
||||
[generateGlobalProps, generateCtrlLine],
|
||||
);
|
||||
|
||||
const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {
|
||||
const next: ICodeStruct = {
|
||||
|
||||
@ -17,7 +17,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
|
||||
const ir = next.ir as IProjectInfo;
|
||||
if (ir.constants) {
|
||||
const [, constantStr] = generateCompositeType(ir.constants);
|
||||
const constantStr = generateCompositeType(ir.constants);
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
@ -26,10 +26,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
content: `
|
||||
const constantConfig = ${constantStr};
|
||||
`,
|
||||
linkAfter: [
|
||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||
],
|
||||
linkAfter: [COMMON_CHUNK_NAME.ExternalDepsImport, COMMON_CHUNK_NAME.InternalDepsImport],
|
||||
});
|
||||
|
||||
next.chunks.push({
|
||||
|
||||
@ -73,6 +73,8 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
originTemplate: '@alifd/scaffold-lite-js',
|
||||
};
|
||||
|
||||
ir.packages.forEach((packageInfo) => (packageJson.dependencies[packageInfo.package] = packageInfo.version));
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.JSON,
|
||||
fileType: FileType.JSON,
|
||||
|
||||
@ -17,7 +17,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
|
||||
const ir = next.ir as IProjectInfo;
|
||||
if (ir.i18n) {
|
||||
const [, i18nStr] = generateCompositeType(ir.i18n);
|
||||
const i18nStr = generateCompositeType(ir.i18n);
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
|
||||
@ -5,7 +5,7 @@ import { createProjectBuilder } from '../generator/ProjectBuilder';
|
||||
import esmodule from '../plugins/common/esmodule';
|
||||
import containerClass from '../plugins/component/react/containerClass';
|
||||
import containerInitState from '../plugins/component/react/containerInitState';
|
||||
import containerInjectUtils from '../plugins/component/react/containerInjectUtils';
|
||||
// import containerInjectUtils from '../plugins/component/react/containerInjectUtils';
|
||||
import containerLifeCycle from '../plugins/component/react/containerLifeCycle';
|
||||
import containerMethod from '../plugins/component/react/containerMethod';
|
||||
import jsx from '../plugins/component/react/jsx';
|
||||
@ -29,11 +29,18 @@ export default function createIceJsProjectBuilder(): IProjectBuilder {
|
||||
fileType: 'jsx',
|
||||
}),
|
||||
containerClass(),
|
||||
containerInjectUtils(),
|
||||
// containerInjectUtils(),
|
||||
containerInitState(),
|
||||
containerLifeCycle(),
|
||||
containerMethod(),
|
||||
jsx(),
|
||||
jsx({
|
||||
nodeTypeMapping: {
|
||||
Div: 'div',
|
||||
Component: 'div',
|
||||
Page: 'div',
|
||||
Block: 'div',
|
||||
},
|
||||
}),
|
||||
css(),
|
||||
],
|
||||
pages: [
|
||||
@ -42,11 +49,19 @@ export default function createIceJsProjectBuilder(): IProjectBuilder {
|
||||
fileType: 'jsx',
|
||||
}),
|
||||
containerClass(),
|
||||
containerInjectUtils(),
|
||||
// containerInjectUtils(),
|
||||
containerInitState(),
|
||||
containerLifeCycle(),
|
||||
containerMethod(),
|
||||
jsx(),
|
||||
jsx({
|
||||
nodeTypeMapping: {
|
||||
Div: 'div',
|
||||
Component: 'div',
|
||||
Page: 'div',
|
||||
Block: 'div',
|
||||
// Box: 'div',
|
||||
},
|
||||
}),
|
||||
css(),
|
||||
],
|
||||
router: [esmodule(), icejs.plugins.router()],
|
||||
@ -58,6 +73,6 @@ export default function createIceJsProjectBuilder(): IProjectBuilder {
|
||||
htmlEntry: [icejs.plugins.entryHtml()],
|
||||
packageJSON: [icejs.plugins.packageJSON()],
|
||||
},
|
||||
postProcessors: [prettier()],
|
||||
postProcessors: [prettier()], // prettier()
|
||||
});
|
||||
}
|
||||
|
||||
@ -53,17 +53,12 @@ export interface ICodeStruct extends IBaseCodeStruct {
|
||||
chunks: ICodeChunk[];
|
||||
}
|
||||
|
||||
export type BuilderComponentPlugin = (
|
||||
initStruct: ICodeStruct,
|
||||
) => Promise<ICodeStruct>;
|
||||
export type BuilderComponentPlugin = (initStruct: ICodeStruct) => Promise<ICodeStruct>;
|
||||
|
||||
export type BuilderComponentPluginFactory<T> = (config?: T) => BuilderComponentPlugin;
|
||||
|
||||
export interface IChunkBuilder {
|
||||
run(
|
||||
ir: any,
|
||||
initialStructure?: ICodeStruct,
|
||||
): Promise<{ chunks: ICodeChunk[][] }>;
|
||||
run(ir: any, initialStructure?: ICodeStruct): Promise<{ chunks: ICodeChunk[][] }>;
|
||||
getPlugins(): BuilderComponentPlugin[];
|
||||
addPlugin(plugin: BuilderComponentPlugin): void;
|
||||
}
|
||||
@ -80,10 +75,7 @@ export interface ICompiledModule {
|
||||
export interface IModuleBuilder {
|
||||
generateModule(input: unknown): Promise<ICompiledModule>;
|
||||
generateModuleCode(schema: IBasicSchema | string): Promise<IResultDir>;
|
||||
linkCodeChunks(
|
||||
chunks: Record<string, ICodeChunk[]>,
|
||||
fileName: string,
|
||||
): IResultFile[];
|
||||
linkCodeChunks(chunks: Record<string, ICodeChunk[]>, fileName: string): IResultFile[];
|
||||
addPlugin(plugin: BuilderComponentPlugin): void;
|
||||
}
|
||||
|
||||
@ -154,7 +146,7 @@ export enum PIECE_TYPE {
|
||||
ATTR = 'NodeCodePieceAttr',
|
||||
CHILDREN = 'NodeCodePieceChildren',
|
||||
AFTER = 'NodeCodePieceAfter',
|
||||
};
|
||||
}
|
||||
|
||||
export interface CodePiece {
|
||||
value: string;
|
||||
@ -168,10 +160,42 @@ export interface HandlerSet<T> {
|
||||
common?: (input: unknown) => T[];
|
||||
}
|
||||
|
||||
export type ExtGeneratorPlugin = (nodeItem: IComponentNodeItem) => CodePiece[];
|
||||
export type ExtGeneratorPlugin = (ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem) => CodePiece[];
|
||||
|
||||
export interface INodeGeneratorConfig {
|
||||
nodeTypeMapping?: Record<string, string>;
|
||||
}
|
||||
|
||||
export type NodeGenerator = (nodeItem: IComponentNodeItem) => string;
|
||||
|
||||
export interface INodeGeneratorContext {
|
||||
generator: NodeGenerator;
|
||||
}
|
||||
|
||||
// export interface InteratorScope {
|
||||
// [$item: string]: string; // $item 默认取值 "item"
|
||||
// [$index: string]: string | number; // $index 默认取值 "index"
|
||||
// __proto__: BlockInstance;
|
||||
// }
|
||||
|
||||
export type CompositeValueCustomHandler = (data: unknown) => string;
|
||||
export type CompositeTypeContainerHandler = (value: string) => string;
|
||||
export interface CompositeValueCustomHandlerSet {
|
||||
boolean?: CompositeValueCustomHandler;
|
||||
number?: CompositeValueCustomHandler;
|
||||
string?: CompositeValueCustomHandler;
|
||||
array?: CompositeValueCustomHandler;
|
||||
object?: CompositeValueCustomHandler;
|
||||
expression?: CompositeValueCustomHandler;
|
||||
}
|
||||
|
||||
export interface CompositeTypeContainerHandlerSet {
|
||||
default?: CompositeTypeContainerHandler;
|
||||
string?: CompositeValueCustomHandler;
|
||||
}
|
||||
|
||||
export interface CompositeValueGeneratorOptions {
|
||||
handlers?: CompositeValueCustomHandlerSet;
|
||||
containerHandlers?: CompositeTypeContainerHandlerSet;
|
||||
nodeGenerator?: NodeGenerator;
|
||||
}
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
export interface INpmPackage {
|
||||
package: string; // 组件包的名称
|
||||
version: string; // 组件包的版本
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部依赖描述
|
||||
*
|
||||
* @export
|
||||
* @interface IExternalDependency
|
||||
*/
|
||||
export interface IExternalDependency extends IDependency {
|
||||
package: string; // 组件包的名称
|
||||
version: string; // 组件包的版本
|
||||
}
|
||||
export interface IExternalDependency extends INpmPackage, IDependency {}
|
||||
|
||||
export enum InternalDependencyType {
|
||||
PAGE = 'pages',
|
||||
|
||||
@ -5,6 +5,7 @@ import {
|
||||
IDependency,
|
||||
II18nMap,
|
||||
IInternalDependency,
|
||||
INpmPackage,
|
||||
IUtilItem,
|
||||
} from './index';
|
||||
|
||||
@ -42,6 +43,7 @@ export interface IProjectInfo {
|
||||
css?: string;
|
||||
constants?: Record<string, string>;
|
||||
i18n?: II18nMap;
|
||||
packages: INpmPackage[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -13,18 +13,37 @@ export interface IJSExpression {
|
||||
[extConfigName: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搭建基础协议 - 函数定义
|
||||
*
|
||||
* @export
|
||||
* @interface IJSFunction
|
||||
*/
|
||||
export interface IJSFunction {
|
||||
type: 'JSFunction';
|
||||
value: string;
|
||||
[extConfigName: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搭建基础协议 - 函数定义
|
||||
*
|
||||
* @export
|
||||
* @interface IJSSlot
|
||||
*/
|
||||
export interface IJSSlot {
|
||||
type: 'JSSlot';
|
||||
value: IComponentNodeItem[];
|
||||
params?: string[];
|
||||
[extConfigName: string]: any;
|
||||
}
|
||||
|
||||
// JSON 基本类型
|
||||
export interface IJSONObject {
|
||||
[key: string]: JSONValue;
|
||||
}
|
||||
|
||||
export type JSONValue =
|
||||
| boolean
|
||||
| string
|
||||
| number
|
||||
| null
|
||||
| JSONArray
|
||||
| IJSONObject;
|
||||
export type JSONValue = boolean | string | number | null | JSONArray | IJSONObject;
|
||||
export type JSONArray = JSONValue[];
|
||||
|
||||
export type CompositeArray = CompositeValue[];
|
||||
@ -33,11 +52,7 @@ export interface ICompositeObject {
|
||||
}
|
||||
|
||||
// 复合类型
|
||||
export type CompositeValue =
|
||||
| JSONValue
|
||||
| IJSExpression
|
||||
| CompositeArray
|
||||
| ICompositeObject;
|
||||
export type CompositeValue = JSONValue | IJSExpression | IJSFunction | IJSSlot | CompositeArray | ICompositeObject;
|
||||
|
||||
/**
|
||||
* 搭建基础协议 - 多语言描述
|
||||
@ -136,8 +151,8 @@ export interface IContainerNodeItem extends IComponentNodeItem {
|
||||
* • componentWillUnmount()
|
||||
* • componentDidCatch(error, info)
|
||||
*/
|
||||
lifeCycles?: Record<string, IJSExpression>; // 生命周期Hook方法
|
||||
methods?: Record<string, IJSExpression>; // 自定义方法设置
|
||||
lifeCycles?: Record<string, IJSExpression | IJSFunction>; // 生命周期Hook方法
|
||||
methods?: Record<string, IJSExpression | IJSFunction>; // 自定义方法设置
|
||||
dataSource?: {
|
||||
list: IDataSourceConfig[];
|
||||
}; // 异步数据源配置
|
||||
@ -154,9 +169,9 @@ export interface IDataSourceConfig {
|
||||
id: string; // 数据请求ID标识
|
||||
isInit: boolean; // 是否为初始数据 支持表达式 值为true时,将在组件初始化渲染时自动发送当前数据请求
|
||||
type: string; // 数据请求类型 'fetch' | 'mtop' | 'jsonp' | 'custom'
|
||||
requestHandler?: IJSExpression; // 自定义扩展的外部请求处理器 仅type='custom'时生效
|
||||
requestHandler?: IJSExpression | IJSFunction; // 自定义扩展的外部请求处理器 仅type='custom'时生效
|
||||
options?: IFetchOptions; // 请求参数配置 每种请求类型对应不同参数
|
||||
dataHandler?: IJSExpression; // 数据结果处理函数,形如:(data, err) => Object
|
||||
dataHandler?: IJSExpression | IJSFunction; // 数据结果处理函数,形如:(data, err) => Object
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,7 +22,10 @@ export function upperCaseFirst(inputValue: string): string {
|
||||
return changeCase.upperCaseFirst(inputValue);
|
||||
}
|
||||
|
||||
export function uniqueArray<T>(arr: T[]) {
|
||||
const uniqueItems = [...new Set<T>(arr)];
|
||||
export function uniqueArray<T>(arr: T[], by: (i: T) => string) {
|
||||
const map: Record<string, T> = {};
|
||||
arr.forEach((item) => (map[by(item)] = item));
|
||||
const uniqueKeys = [...new Set<string>(Object.keys(map))];
|
||||
const uniqueItems = uniqueKeys.map((key) => map[key]);
|
||||
return uniqueItems;
|
||||
}
|
||||
|
||||
@ -1,88 +1,106 @@
|
||||
import { CompositeArray, CompositeValue, ICompositeObject } from '../types';
|
||||
import { generateExpression, isJsExpression } from './jsExpression';
|
||||
import {
|
||||
CompositeArray,
|
||||
CompositeValue,
|
||||
ICompositeObject,
|
||||
CompositeValueGeneratorOptions,
|
||||
CompositeTypeContainerHandlerSet,
|
||||
CodeGeneratorError,
|
||||
} from '../types';
|
||||
import { generateExpression, generateFunction, isJsExpression, isJsFunction } from './jsExpression';
|
||||
import { isJsSlot, generateJsSlot } from './jsSlot';
|
||||
import { isValidIdentifier } from './validate';
|
||||
import { camelize } from './common';
|
||||
|
||||
type CustomHandler = (data: unknown) => string;
|
||||
interface CustomHandlerSet {
|
||||
boolean?: CustomHandler;
|
||||
number?: CustomHandler;
|
||||
string?: CustomHandler;
|
||||
array?: CustomHandler;
|
||||
object?: CustomHandler;
|
||||
expression?: CustomHandler;
|
||||
}
|
||||
const defaultContainerHandlers: CompositeTypeContainerHandlerSet = {
|
||||
default: (v) => v,
|
||||
string: (v) => `'${v}'`,
|
||||
};
|
||||
|
||||
function generateArray(
|
||||
value: CompositeArray,
|
||||
handlers: CustomHandlerSet = {},
|
||||
): string {
|
||||
const body = value.map(v => generateUnknownType(v, handlers)).join(',');
|
||||
function generateArray(value: CompositeArray, options: CompositeValueGeneratorOptions = {}): string {
|
||||
const body = value.map((v) => generateUnknownType(v, options)).join(',');
|
||||
return `[${body}]`;
|
||||
}
|
||||
|
||||
function generateObject(
|
||||
value: ICompositeObject,
|
||||
handlers: CustomHandlerSet = {},
|
||||
): string {
|
||||
function generateObject(value: ICompositeObject, options: CompositeValueGeneratorOptions = {}): string {
|
||||
if (isJsExpression(value)) {
|
||||
if (handlers.expression) {
|
||||
return handlers.expression(value);
|
||||
if (options.handlers && options.handlers.expression) {
|
||||
return options.handlers.expression(value);
|
||||
}
|
||||
return generateExpression(value);
|
||||
}
|
||||
|
||||
if (isJsFunction(value)) {
|
||||
return generateFunction(value, { isArrow: true });
|
||||
}
|
||||
|
||||
if (isJsSlot(value)) {
|
||||
if (options.nodeGenerator) {
|
||||
return generateJsSlot(value, options.nodeGenerator);
|
||||
}
|
||||
throw new CodeGeneratorError("Can't find Node Generator");
|
||||
}
|
||||
|
||||
const body = Object.keys(value)
|
||||
.map(key => {
|
||||
const v = generateUnknownType(value[key], handlers);
|
||||
return `${key}: ${v}`;
|
||||
.map((key) => {
|
||||
let propName = key;
|
||||
|
||||
// TODO: 可以增加更多智能修复的方法
|
||||
const fixMethods: Array<(v: string) => string> = [camelize];
|
||||
// Try to fix propName
|
||||
while (!isValidIdentifier(propName)) {
|
||||
const fixMethod = fixMethods.pop();
|
||||
if (fixMethod) {
|
||||
try {
|
||||
propName = fixMethod(propName);
|
||||
} catch (error) {
|
||||
throw new CodeGeneratorError(error.message);
|
||||
}
|
||||
} else {
|
||||
throw new CodeGeneratorError(`Propname: ${key} is not a valid identifier.`);
|
||||
}
|
||||
}
|
||||
const v = generateUnknownType(value[key], options);
|
||||
return `${propName}: ${v}`;
|
||||
})
|
||||
.join(',\n');
|
||||
|
||||
return `{${body}}`;
|
||||
}
|
||||
|
||||
export function generateUnknownType(
|
||||
value: CompositeValue,
|
||||
handlers: CustomHandlerSet = {},
|
||||
): string {
|
||||
export function generateUnknownType(value: CompositeValue, options: CompositeValueGeneratorOptions = {}): string {
|
||||
if (Array.isArray(value)) {
|
||||
if (handlers.array) {
|
||||
return handlers.array(value);
|
||||
if (options.handlers && options.handlers.array) {
|
||||
return options.handlers.array(value);
|
||||
}
|
||||
return generateArray(value as CompositeArray, handlers);
|
||||
return generateArray(value as CompositeArray, options);
|
||||
} else if (typeof value === 'object') {
|
||||
if (handlers.object) {
|
||||
return handlers.object(value);
|
||||
if (options.handlers && options.handlers.object) {
|
||||
return options.handlers.object(value);
|
||||
}
|
||||
return generateObject(value as ICompositeObject, handlers);
|
||||
return generateObject(value as ICompositeObject, options);
|
||||
} else if (typeof value === 'string') {
|
||||
if (handlers.string) {
|
||||
return handlers.string(value);
|
||||
if (options.handlers && options.handlers.string) {
|
||||
return options.handlers.string(value);
|
||||
}
|
||||
return `'${value}'`;
|
||||
} else if (typeof value === 'number' && handlers.number) {
|
||||
return handlers.number(value);
|
||||
} else if (typeof value === 'boolean' && handlers.boolean) {
|
||||
return handlers.boolean(value);
|
||||
} else if (typeof value === 'number' && options.handlers && options.handlers.number) {
|
||||
return options.handlers.number(value);
|
||||
} else if (typeof value === 'boolean' && options.handlers && options.handlers.boolean) {
|
||||
return options.handlers.boolean(value);
|
||||
}
|
||||
return `${value}`;
|
||||
}
|
||||
|
||||
export function generateCompositeType(
|
||||
value: CompositeValue,
|
||||
handlers: CustomHandlerSet = {},
|
||||
): [boolean, string] {
|
||||
const result = generateUnknownType(value, handlers);
|
||||
export function generateCompositeType(value: CompositeValue, options: CompositeValueGeneratorOptions = {}): string {
|
||||
const result = generateUnknownType(value, options);
|
||||
const containerHandlers = {
|
||||
...defaultContainerHandlers,
|
||||
...(options.containerHandlers || {}),
|
||||
};
|
||||
|
||||
if (result.substr(0, 1) === "'" && result.substr(-1, 1) === "'") {
|
||||
return [true, result.substring(1, result.length - 1)];
|
||||
const isStringType = result.substr(0, 1) === "'" && result.substr(-1, 1) === "'";
|
||||
if (isStringType) {
|
||||
return (containerHandlers.string && containerHandlers.string(result.substring(1, result.length - 1))) || '';
|
||||
}
|
||||
|
||||
return [false, result];
|
||||
}
|
||||
|
||||
export function handleStringValueDefault([isString, result]: [boolean, string]) {
|
||||
if (isString) {
|
||||
return `'${result}'`;
|
||||
}
|
||||
return result;
|
||||
return (containerHandlers.default && containerHandlers.default(result)) || '';
|
||||
}
|
||||
|
||||
@ -1,39 +1,6 @@
|
||||
import traverse from '@babel/traverse';
|
||||
import * as parser from '@babel/parser';
|
||||
import { CodeGeneratorError, IJSExpression } from '../types';
|
||||
|
||||
let count = 0;
|
||||
|
||||
function test(functionBody: string) {
|
||||
console.log(functionBody);
|
||||
console.log('---->');
|
||||
try {
|
||||
const parseResult = parser.parse(functionBody);
|
||||
// console.log(JSON.stringify(parseResult));
|
||||
traverse(parseResult, {
|
||||
enter(path) {
|
||||
console.log('path: ', JSON.stringify(path));
|
||||
}
|
||||
});
|
||||
|
||||
if (count === 0) {
|
||||
count++;
|
||||
|
||||
test('this.aaa && this.bbb');
|
||||
}
|
||||
} catch (error) {
|
||||
// console.log('Error');
|
||||
console.log(error.message);
|
||||
}
|
||||
console.log('=====================');
|
||||
}
|
||||
|
||||
export function transformFuncExpr2MethodMember(
|
||||
methodName: string,
|
||||
functionBody: string,
|
||||
): string {
|
||||
// test(functionBody);
|
||||
import { CodeGeneratorError, IJSExpression, IJSFunction } from '../types';
|
||||
|
||||
export function transformFuncExpr2MethodMember(methodName: string, functionBody: string): string {
|
||||
const args = getFuncExprArguments(functionBody);
|
||||
const body = getFuncExprBody(functionBody);
|
||||
|
||||
@ -66,20 +33,60 @@ export function getFuncExprBody(functionBody: string) {
|
||||
return body;
|
||||
}
|
||||
|
||||
export function generateExpression(value: any): string {
|
||||
if (value && (value as IJSExpression).type === 'JSExpression') {
|
||||
// test((value as IJSExpression).value);
|
||||
export function getArrowFunction(functionBody: string) {
|
||||
const args = getFuncExprArguments(functionBody);
|
||||
const body = getFuncExprBody(functionBody);
|
||||
|
||||
return `(${args}) => { ${body} }`;
|
||||
}
|
||||
|
||||
export function isJsExpression(value: unknown): boolean {
|
||||
return value && typeof value === 'object' && (value as IJSExpression).type === 'JSExpression';
|
||||
}
|
||||
|
||||
export function isJsFunction(value: unknown): boolean {
|
||||
return value && typeof value === 'object' && (value as IJSFunction).type === 'JSFunction';
|
||||
}
|
||||
|
||||
export function isJsCode(value: unknown): boolean {
|
||||
return isJsExpression(value) || isJsFunction(value);
|
||||
}
|
||||
|
||||
export function generateExpression(value: any): string {
|
||||
if (isJsExpression(value)) {
|
||||
return (value as IJSExpression).value || 'null';
|
||||
}
|
||||
|
||||
throw new CodeGeneratorError('Not a JSExpression');
|
||||
}
|
||||
|
||||
export function isJsExpression(value: any): boolean {
|
||||
return (
|
||||
value &&
|
||||
typeof value === 'object' &&
|
||||
(value as IJSExpression).type === 'JSExpression'
|
||||
);
|
||||
export function generateFunction(
|
||||
value: any,
|
||||
config: {
|
||||
name?: string;
|
||||
isMember?: boolean;
|
||||
isBlock?: boolean;
|
||||
isArrow?: boolean;
|
||||
} = {
|
||||
name: undefined,
|
||||
isMember: false,
|
||||
isBlock: false,
|
||||
isArrow: false,
|
||||
},
|
||||
) {
|
||||
if (isJsCode(value)) {
|
||||
const functionCfg = value as IJSFunction;
|
||||
if (config.isMember) {
|
||||
return transformFuncExpr2MethodMember(config.name || '', functionCfg.value);
|
||||
}
|
||||
if (config.isBlock) {
|
||||
return getFuncExprBody(functionCfg.value);
|
||||
}
|
||||
if (config.isArrow) {
|
||||
return getArrowFunction(functionCfg.value);
|
||||
}
|
||||
return functionCfg.value;
|
||||
}
|
||||
|
||||
throw new CodeGeneratorError('Not a JSFunction or JSExpression');
|
||||
}
|
||||
|
||||
21
packages/code-generator/src/utils/jsSlot.ts
Normal file
21
packages/code-generator/src/utils/jsSlot.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { CodeGeneratorError, NodeGenerator, IJSSlot } from '../types';
|
||||
|
||||
export function isJsSlot(value: unknown): boolean {
|
||||
return value && typeof value === 'object' && (value as IJSSlot).type === 'JSSlot';
|
||||
}
|
||||
|
||||
export function generateJsSlot(value: any, generator: NodeGenerator): string {
|
||||
if (isJsSlot(value)) {
|
||||
const slotCfg = value as IJSSlot;
|
||||
if (!slotCfg.value) {
|
||||
return 'null';
|
||||
}
|
||||
const results = slotCfg.value.map((n) => generator(n));
|
||||
if (results.length === 1) {
|
||||
return results[0];
|
||||
}
|
||||
return `[${results.join(',')}]`;
|
||||
}
|
||||
|
||||
throw new CodeGeneratorError('Not a JSSlot');
|
||||
}
|
||||
@ -8,85 +8,171 @@ import {
|
||||
CodePiece,
|
||||
HandlerSet,
|
||||
ExtGeneratorPlugin,
|
||||
IJSSlot,
|
||||
INodeGeneratorConfig,
|
||||
INodeGeneratorContext,
|
||||
NodeGenerator,
|
||||
} from '../types';
|
||||
import { generateCompositeType } from './compositeType';
|
||||
import { generateExpression } from './jsExpression';
|
||||
import { generateExpression, isJsExpression } from './jsExpression';
|
||||
import { isJsSlot } from './jsSlot';
|
||||
|
||||
// tslint:disable-next-line: no-empty
|
||||
const noop = () => [];
|
||||
|
||||
export function handleChildren<T>(
|
||||
const handleChildrenDefaultOptions = {
|
||||
rerun: false,
|
||||
};
|
||||
|
||||
export function handleSubNodes<T>(
|
||||
children: ChildNodeType,
|
||||
handlers: HandlerSet<T>,
|
||||
options?: {
|
||||
rerun?: boolean;
|
||||
},
|
||||
): T[] {
|
||||
const opt = {
|
||||
...handleChildrenDefaultOptions,
|
||||
...(options || {}),
|
||||
};
|
||||
|
||||
if (Array.isArray(children)) {
|
||||
const list: ChildNodeItem[] = children as ChildNodeItem[];
|
||||
return list
|
||||
.map(child => handleChildren(child, handlers))
|
||||
.reduce((p, c) => p.concat(c), []);
|
||||
return list.map((child) => handleSubNodes(child, handlers, opt)).reduce((p, c) => p.concat(c), []);
|
||||
} else if (typeof children === 'string') {
|
||||
const handler = handlers.string || handlers.common || noop;
|
||||
return handler(children as string);
|
||||
} else if ((children as IJSExpression).type === 'JSExpression') {
|
||||
} else if (isJsExpression(children)) {
|
||||
const handler = handlers.expression || handlers.common || noop;
|
||||
return handler(children as IJSExpression);
|
||||
} else {
|
||||
const handler = handlers.node || handlers.common || noop;
|
||||
return handler(children as IComponentNodeItem);
|
||||
let curRes = handler(children as IComponentNodeItem);
|
||||
if (opt.rerun && children.children) {
|
||||
const childRes = handleSubNodes(children.children, handlers, opt);
|
||||
curRes = curRes.concat(childRes || []);
|
||||
}
|
||||
if (children.props) {
|
||||
Object.keys(children.props)
|
||||
.filter((propName) => isJsSlot(children.props[propName]))
|
||||
.forEach((propName) => {
|
||||
const soltVals = (children.props[propName] as IJSSlot).value;
|
||||
(soltVals || []).forEach((soltVal) => {
|
||||
const childRes = handleSubNodes(soltVal, handlers, opt);
|
||||
curRes = curRes.concat(childRes || []);
|
||||
});
|
||||
});
|
||||
}
|
||||
return curRes;
|
||||
}
|
||||
}
|
||||
|
||||
export function generateAttr(attrName: string, attrValue: any): CodePiece[] {
|
||||
if (attrName === 'initValue' || attrName === 'labelCol') {
|
||||
export function handleChildren<T>(
|
||||
ctx: INodeGeneratorContext,
|
||||
children: ChildNodeType,
|
||||
handlers: HandlerSet<T>,
|
||||
options?: {
|
||||
rerun?: boolean;
|
||||
},
|
||||
): T[] {
|
||||
const opt = {
|
||||
...handleChildrenDefaultOptions,
|
||||
...(options || {}),
|
||||
};
|
||||
|
||||
if (Array.isArray(children)) {
|
||||
const list: ChildNodeItem[] = children as ChildNodeItem[];
|
||||
return list.map((child) => handleChildren(ctx, child, handlers, opt)).reduce((p, c) => p.concat(c), []);
|
||||
} else if (typeof children === 'string') {
|
||||
const handler = handlers.string || handlers.common || noop;
|
||||
return handler(children as string);
|
||||
} else if (isJsExpression(children)) {
|
||||
const handler = handlers.expression || handlers.common || noop;
|
||||
return handler(children as IJSExpression);
|
||||
} else {
|
||||
const handler = handlers.node || handlers.common || noop;
|
||||
let curRes = handler(children as IComponentNodeItem);
|
||||
if (opt.rerun && children.children) {
|
||||
const childRes = handleChildren(ctx, children.children, handlers, opt);
|
||||
curRes = curRes.concat(childRes || []);
|
||||
}
|
||||
return curRes;
|
||||
}
|
||||
}
|
||||
|
||||
export function generateAttr(ctx: INodeGeneratorContext, attrName: string, attrValue: any): CodePiece[] {
|
||||
if (attrName === 'initValue') {
|
||||
return [];
|
||||
}
|
||||
const [isString, valueStr] = generateCompositeType(attrValue);
|
||||
return [{
|
||||
value: `${attrName}=${isString ? `"${valueStr}"` : `{${valueStr}}`}`,
|
||||
type: PIECE_TYPE.ATTR,
|
||||
}];
|
||||
const valueStr = generateCompositeType(attrValue, {
|
||||
containerHandlers: {
|
||||
default: (v) => `{${v}}`,
|
||||
string: (v) => `"${v}"`,
|
||||
},
|
||||
nodeGenerator: ctx.generator,
|
||||
});
|
||||
return [
|
||||
{
|
||||
value: `${attrName}=${valueStr}`,
|
||||
type: PIECE_TYPE.ATTR,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export function generateAttrs(nodeItem: IComponentNodeItem): CodePiece[] {
|
||||
export function generateAttrs(ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] {
|
||||
const { props } = nodeItem;
|
||||
let pieces: CodePiece[] = [];
|
||||
|
||||
Object.keys(props).forEach((propName: string) =>
|
||||
pieces = pieces.concat(generateAttr(propName, props[propName])),
|
||||
Object.keys(props).forEach(
|
||||
(propName: string) => (pieces = pieces.concat(generateAttr(ctx, propName, props[propName]))),
|
||||
);
|
||||
|
||||
return pieces;
|
||||
}
|
||||
|
||||
export function mapNodeName(src: string): string {
|
||||
if (src === 'Div') {
|
||||
return 'div';
|
||||
function mapNodeName(src: string, mapping: Record<string, string>): string {
|
||||
if (mapping[src]) {
|
||||
return mapping[src];
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
export function generateBasicNode(nodeItem: IComponentNodeItem): CodePiece[] {
|
||||
export function generateBasicNode(
|
||||
ctx: INodeGeneratorContext,
|
||||
nodeItem: IComponentNodeItem,
|
||||
mapping: Record<string, string>,
|
||||
): CodePiece[] {
|
||||
const pieces: CodePiece[] = [];
|
||||
pieces.push({
|
||||
value: mapNodeName(nodeItem.componentName),
|
||||
value: mapNodeName(nodeItem.componentName, mapping),
|
||||
type: PIECE_TYPE.TAG,
|
||||
});
|
||||
|
||||
return pieces;
|
||||
}
|
||||
|
||||
export function generateReactCtrlLine(nodeItem: IComponentNodeItem): CodePiece[] {
|
||||
// TODO: 生成文档
|
||||
// 为包裹的代码片段生成子上下文,集成父级上下文,并传入子级上下文新增内容。(如果存在多级上下文怎么处理?)
|
||||
// 创建新的上下文,并从作用域中取对应同名变量塞到作用域里面?
|
||||
// export function createSubContext() {}
|
||||
|
||||
/**
|
||||
* JSX 生成逻辑插件。在 React 代码模式下生成 loop 与 condition 相关的逻辑代码
|
||||
*
|
||||
* @export
|
||||
* @param {IComponentNodeItem} nodeItem 当前 UI 节点
|
||||
* @returns {CodePiece[]} 实现功能的相关代码片段
|
||||
*/
|
||||
export function generateReactCtrlLine(ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] {
|
||||
const pieces: CodePiece[] = [];
|
||||
|
||||
if (nodeItem.loop && nodeItem.loopArgs) {
|
||||
let loopDataExp;
|
||||
if ((nodeItem.loop as IJSExpression).type === 'JSExpression') {
|
||||
loopDataExp = `(${(nodeItem.loop as IJSExpression).value})`;
|
||||
} else {
|
||||
loopDataExp = JSON.stringify(nodeItem.loop);
|
||||
}
|
||||
if (nodeItem.loop) {
|
||||
const args: [string, string] = nodeItem.loopArgs || ['item', 'index'];
|
||||
const loopData = generateCompositeType(nodeItem.loop, {
|
||||
nodeGenerator: ctx.generator,
|
||||
});
|
||||
pieces.unshift({
|
||||
value: `${loopDataExp}.map((${nodeItem.loopArgs[0]}, ${nodeItem.loopArgs[1]}) => (`,
|
||||
value: `(${loopData}).map((${args[0]}, ${args[1]}) => (`,
|
||||
type: PIECE_TYPE.BEFORE,
|
||||
});
|
||||
pieces.push({
|
||||
@ -96,10 +182,12 @@ export function generateReactCtrlLine(nodeItem: IComponentNodeItem): CodePiece[]
|
||||
}
|
||||
|
||||
if (nodeItem.condition) {
|
||||
const [isString, value] = generateCompositeType(nodeItem.condition);
|
||||
const value = generateCompositeType(nodeItem.condition, {
|
||||
nodeGenerator: ctx.generator,
|
||||
});
|
||||
|
||||
pieces.unshift({
|
||||
value: `(${isString ? `'${value}'` : value}) && (`,
|
||||
value: `(${value}) && (`,
|
||||
type: PIECE_TYPE.BEFORE,
|
||||
});
|
||||
pieces.push({
|
||||
@ -108,7 +196,7 @@ export function generateReactCtrlLine(nodeItem: IComponentNodeItem): CodePiece[]
|
||||
});
|
||||
}
|
||||
|
||||
if (nodeItem.condition || (nodeItem.loop && nodeItem.loopArgs)) {
|
||||
if (nodeItem.condition || nodeItem.loop) {
|
||||
pieces.unshift({
|
||||
value: '{',
|
||||
type: PIECE_TYPE.BEFORE,
|
||||
@ -123,29 +211,29 @@ export function generateReactCtrlLine(nodeItem: IComponentNodeItem): CodePiece[]
|
||||
}
|
||||
|
||||
export function linkPieces(pieces: CodePiece[]): string {
|
||||
if (pieces.filter(p => p.type === PIECE_TYPE.TAG).length !== 1) {
|
||||
if (pieces.filter((p) => p.type === PIECE_TYPE.TAG).length !== 1) {
|
||||
throw new CodeGeneratorError('One node only need one tag define');
|
||||
}
|
||||
const tagName = pieces.filter(p => p.type === PIECE_TYPE.TAG)[0].value;
|
||||
const tagName = pieces.filter((p) => p.type === PIECE_TYPE.TAG)[0].value;
|
||||
|
||||
const beforeParts = pieces
|
||||
.filter(p => p.type === PIECE_TYPE.BEFORE)
|
||||
.map(p => p.value)
|
||||
.filter((p) => p.type === PIECE_TYPE.BEFORE)
|
||||
.map((p) => p.value)
|
||||
.join('');
|
||||
|
||||
const afterParts = pieces
|
||||
.filter(p => p.type === PIECE_TYPE.AFTER)
|
||||
.map(p => p.value)
|
||||
.filter((p) => p.type === PIECE_TYPE.AFTER)
|
||||
.map((p) => p.value)
|
||||
.join('');
|
||||
|
||||
const childrenParts = pieces
|
||||
.filter(p => p.type === PIECE_TYPE.CHILDREN)
|
||||
.map(p => p.value)
|
||||
.filter((p) => p.type === PIECE_TYPE.CHILDREN)
|
||||
.map((p) => p.value)
|
||||
.join('');
|
||||
|
||||
let attrsParts = pieces
|
||||
.filter(p => p.type === PIECE_TYPE.ATTR)
|
||||
.map(p => p.value)
|
||||
.filter((p) => p.type === PIECE_TYPE.ATTR)
|
||||
.map((p) => p.value)
|
||||
.join(' ');
|
||||
|
||||
attrsParts = !!attrsParts ? ` ${attrsParts}` : '';
|
||||
@ -157,20 +245,34 @@ export function linkPieces(pieces: CodePiece[]): string {
|
||||
return `${beforeParts}<${tagName}${attrsParts} />${afterParts}`;
|
||||
}
|
||||
|
||||
export function createNodeGenerator(handlers: HandlerSet<string>, plugins: ExtGeneratorPlugin[]) {
|
||||
export function createNodeGenerator(
|
||||
handlers: HandlerSet<string>,
|
||||
plugins: ExtGeneratorPlugin[],
|
||||
cfg?: INodeGeneratorConfig,
|
||||
): NodeGenerator {
|
||||
let nodeTypeMapping: Record<string, string> = {};
|
||||
if (cfg && cfg.nodeTypeMapping) {
|
||||
nodeTypeMapping = cfg.nodeTypeMapping;
|
||||
}
|
||||
|
||||
const generateNode = (nodeItem: IComponentNodeItem): string => {
|
||||
let pieces: CodePiece[] = [];
|
||||
const ctx: INodeGeneratorContext = {
|
||||
generator: generateNode,
|
||||
};
|
||||
|
||||
plugins.forEach(p => {
|
||||
pieces = pieces.concat(p(nodeItem));
|
||||
plugins.forEach((p) => {
|
||||
pieces = pieces.concat(p(ctx, nodeItem));
|
||||
});
|
||||
pieces = pieces.concat(generateBasicNode(nodeItem));
|
||||
pieces = pieces.concat(generateAttrs(nodeItem));
|
||||
pieces = pieces.concat(generateBasicNode(ctx, nodeItem, nodeTypeMapping));
|
||||
pieces = pieces.concat(generateAttrs(ctx, nodeItem));
|
||||
if (nodeItem.children && (nodeItem.children as unknown[]).length > 0) {
|
||||
pieces = pieces.concat(handleChildren<string>(nodeItem.children, handlers).map(l => ({
|
||||
type: PIECE_TYPE.CHILDREN,
|
||||
value: l,
|
||||
})));
|
||||
pieces = pieces.concat(
|
||||
handleChildren<string>(ctx, nodeItem.children, handlers).map((l) => ({
|
||||
type: PIECE_TYPE.CHILDREN,
|
||||
value: l,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
return linkPieces(pieces);
|
||||
@ -183,11 +285,13 @@ export function createNodeGenerator(handlers: HandlerSet<string>, plugins: ExtGe
|
||||
|
||||
export const generateString = (input: string) => [input];
|
||||
|
||||
export function createReactNodeGenerator() {
|
||||
return createNodeGenerator({
|
||||
string: generateString,
|
||||
expression: (input) => [generateExpression(input)],
|
||||
}, [
|
||||
generateReactCtrlLine,
|
||||
]);
|
||||
export function createReactNodeGenerator(cfg?: INodeGeneratorConfig): NodeGenerator {
|
||||
return createNodeGenerator(
|
||||
{
|
||||
string: generateString,
|
||||
expression: (input) => [generateExpression(input)],
|
||||
},
|
||||
[generateReactCtrlLine],
|
||||
cfg,
|
||||
);
|
||||
}
|
||||
|
||||
3
packages/code-generator/src/utils/validate.ts
Normal file
3
packages/code-generator/src/utils/validate.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export const isValidIdentifier = (name: string) => {
|
||||
return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(name);
|
||||
};
|
||||
24
packages/demo-server/.eslintrc.js
Normal file
24
packages/demo-server/.eslintrc.js
Normal file
@ -0,0 +1,24 @@
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.json',
|
||||
sourceType: 'module',
|
||||
},
|
||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/eslint-recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier',
|
||||
'prettier/@typescript-eslint',
|
||||
],
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
},
|
||||
};
|
||||
4
packages/demo-server/.prettierrc
Normal file
4
packages/demo-server/.prettierrc
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
116
packages/demo-server/CHANGELOG.md
Normal file
116
packages/demo-server/CHANGELOG.md
Normal file
@ -0,0 +1,116 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="1.0.7-0"></a>
|
||||
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.6-0...@ali/lowcode-demo-server@1.0.7-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="1.0.6-0"></a>
|
||||
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.5-0...@ali/lowcode-demo-server@1.0.6-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="1.0.5-0"></a>
|
||||
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.4-0...@ali/lowcode-demo-server@1.0.5-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="1.0.4-0"></a>
|
||||
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.3-0...@ali/lowcode-demo-server@1.0.4-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="1.0.3-0"></a>
|
||||
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.2-0...@ali/lowcode-demo-server@1.0.3-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="1.0.2-0"></a>
|
||||
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.1-0...@ali/lowcode-demo-server@1.0.2-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="1.0.1-0"></a>
|
||||
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@1.0.0...@ali/lowcode-demo-server@1.0.1-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.14.0...@ali/lowcode-demo-server@1.0.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="0.14.0"></a>
|
||||
# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.13.0...@ali/lowcode-demo-server@0.14.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="0.13.0"></a>
|
||||
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.11.0...@ali/lowcode-demo-server@0.13.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="0.12.0"></a>
|
||||
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.11.0...@ali/lowcode-demo-server@0.12.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="0.11.0"></a>
|
||||
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.10.0...@ali/lowcode-demo-server@0.11.0) (2020-08-16)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo-server@0.9.0...@ali/lowcode-demo-server@0.10.0) (2020-08-14)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo-server
|
||||
|
||||
<a name="0.9.0"></a>
|
||||
# 0.9.0 (2020-08-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))
|
||||
75
packages/demo-server/README.md
Normal file
75
packages/demo-server/README.md
Normal file
@ -0,0 +1,75 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
|
||||
[travis-url]: https://travis-ci.org/nestjs/nest
|
||||
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
|
||||
[linux-url]: https://travis-ci.org/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
||||
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
|
||||
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
||||
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
|
||||
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Running the app
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ npm run start
|
||||
|
||||
# watch mode
|
||||
$ npm run start:dev
|
||||
|
||||
# production mode
|
||||
$ npm run start:prod
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ npm run test
|
||||
|
||||
# e2e tests
|
||||
$ npm run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ npm run test:cov
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||
|
||||
## Stay in touch
|
||||
|
||||
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
||||
4
packages/demo-server/nest-cli.json
Normal file
4
packages/demo-server/nest-cli.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src"
|
||||
}
|
||||
66
packages/demo-server/package.json
Normal file
66
packages/demo-server/package.json
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "@ali/lowcode-demo-server",
|
||||
"version": "1.0.7-0",
|
||||
"private": true,
|
||||
"description": "低代码引擎 DEMO Server 端",
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"start": "nest start",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"test": "jest",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||
"test:watch": "jest --watch"
|
||||
},
|
||||
"jest": {
|
||||
"coverageDirectory": "../coverage",
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@ali/lowcode-code-generator": "0.8.8",
|
||||
"@nestjs/common": "^7.0.0",
|
||||
"@nestjs/core": "^7.0.0",
|
||||
"@nestjs/platform-express": "^7.0.0",
|
||||
"jszip": "^3.5.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^7.0.0",
|
||||
"@nestjs/schematics": "^7.0.0",
|
||||
"@nestjs/testing": "^7.0.0",
|
||||
"@types/express": "^4.17.3",
|
||||
"@types/jest": "25.2.3",
|
||||
"@types/node": "^13.9.1",
|
||||
"@types/supertest": "^2.0.8",
|
||||
"@typescript-eslint/eslint-plugin": "3.0.2",
|
||||
"@typescript-eslint/parser": "3.0.2",
|
||||
"eslint": "7.1.0",
|
||||
"eslint-config-prettier": "^6.10.0",
|
||||
"eslint-plugin-import": "^2.20.1",
|
||||
"jest": "26.0.1",
|
||||
"prettier": "^1.19.1",
|
||||
"supertest": "^4.0.2",
|
||||
"ts-jest": "26.1.0",
|
||||
"ts-loader": "^6.2.1",
|
||||
"ts-node": "^8.6.2",
|
||||
"tsconfig-paths": "^3.9.0",
|
||||
"typescript": "^3.7.4"
|
||||
}
|
||||
}
|
||||
18
packages/demo-server/src/api/api.controller.spec.ts
Normal file
18
packages/demo-server/src/api/api.controller.spec.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { ApiController } from './api.controller';
|
||||
|
||||
describe('Api Controller', () => {
|
||||
let controller: ApiController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [ApiController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<ApiController>(ApiController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
21
packages/demo-server/src/api/api.controller.ts
Normal file
21
packages/demo-server/src/api/api.controller.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Controller, Res, Get, Post, Body, Header } from '@nestjs/common';
|
||||
import { Response } from 'express';
|
||||
import { ApiService } from './api.service';
|
||||
import { GenerateProjectDto } from '../dto/generate-project.dto';
|
||||
|
||||
@Controller('api')
|
||||
export class ApiController {
|
||||
constructor(private readonly apiService: ApiService) {}
|
||||
|
||||
@Get('generate/test')
|
||||
generateTest() {
|
||||
return 'generate test';
|
||||
}
|
||||
|
||||
@Post('generate/project')
|
||||
@Header('Content-Type', 'application/zip')
|
||||
async generateProject(@Res() res: Response, @Body() dto: GenerateProjectDto) {
|
||||
const file = await this.apiService.generateProject(dto.schema);
|
||||
file.pipe(res);
|
||||
}
|
||||
}
|
||||
18
packages/demo-server/src/api/api.service.spec.ts
Normal file
18
packages/demo-server/src/api/api.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { ApiService } from './api.service';
|
||||
|
||||
describe('ApiService', () => {
|
||||
let service: ApiService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [ApiService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<ApiService>(ApiService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
30
packages/demo-server/src/api/api.service.ts
Normal file
30
packages/demo-server/src/api/api.service.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import CodeGenerator from '@ali/lowcode-code-generator';
|
||||
import { createZipPublisher } from '../publisher';
|
||||
|
||||
@Injectable()
|
||||
export class ApiService {
|
||||
async generateProject(schema: string) {
|
||||
const tmpDir = os.tmpdir();
|
||||
const createIceJsProjectBuilder = CodeGenerator.solutions.icejs;
|
||||
const builder = createIceJsProjectBuilder();
|
||||
const publisher = createZipPublisher({
|
||||
outputPath: tmpDir,
|
||||
projectSlug: 'demo-project',
|
||||
});
|
||||
const filePath = path.join(tmpDir, 'demo-project.zip');
|
||||
|
||||
const result = await builder.generateProject(schema);
|
||||
publisher.setProject(result);
|
||||
const response = await publisher.publish();
|
||||
if (!response.success) {
|
||||
throw new Error('generateProject failed');
|
||||
}
|
||||
return fs.createReadStream(filePath);
|
||||
|
||||
// return filePath;
|
||||
}
|
||||
}
|
||||
22
packages/demo-server/src/app.controller.spec.ts
Normal file
22
packages/demo-server/src/app.controller.spec.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
describe('AppController', () => {
|
||||
let appController: AppController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
}).compile();
|
||||
|
||||
appController = app.get<AppController>(AppController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(appController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
||||
12
packages/demo-server/src/app.controller.ts
Normal file
12
packages/demo-server/src/app.controller.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
}
|
||||
12
packages/demo-server/src/app.module.ts
Normal file
12
packages/demo-server/src/app.module.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { ApiController } from './api/api.controller';
|
||||
import { ApiService } from './api/api.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AppController, ApiController],
|
||||
providers: [AppService, ApiService],
|
||||
})
|
||||
export class AppModule {}
|
||||
8
packages/demo-server/src/app.service.ts
Normal file
8
packages/demo-server/src/app.service.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import { GenerateProjectDto } from './generate-project.dto';
|
||||
|
||||
describe('GenerateProjectDto', () => {
|
||||
it('should be defined', () => {
|
||||
expect(new GenerateProjectDto()).toBeDefined();
|
||||
});
|
||||
});
|
||||
3
packages/demo-server/src/dto/generate-project.dto.ts
Normal file
3
packages/demo-server/src/dto/generate-project.dto.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export class GenerateProjectDto {
|
||||
schema: string;
|
||||
}
|
||||
9
packages/demo-server/src/main.ts
Normal file
9
packages/demo-server/src/main.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.enableCors();
|
||||
await app.listen(7002);
|
||||
}
|
||||
bootstrap();
|
||||
76
packages/demo-server/src/publisher/index.ts
Normal file
76
packages/demo-server/src/publisher/index.ts
Normal file
@ -0,0 +1,76 @@
|
||||
import { IResultDir } from '@ali/lowcode-code-generator';
|
||||
import { isNodeProcess, writeZipToDisk, generateProjectZip } from './utils'
|
||||
|
||||
export type PublisherFactory<T, U> = (configuration?: Partial<T>) => U;
|
||||
|
||||
export interface IPublisher<T, U> {
|
||||
publish: (options?: T) => Promise<IPublisherResponse<U>>;
|
||||
getProject: () => IResultDir | void;
|
||||
setProject: (project: IResultDir) => void;
|
||||
}
|
||||
|
||||
export interface IPublisherFactoryParams {
|
||||
project?: IResultDir;
|
||||
}
|
||||
export interface IPublisherResponse<T> {
|
||||
success: boolean;
|
||||
payload?: T;
|
||||
}
|
||||
|
||||
declare type ZipPublisherResponse = string | Buffer | Blob
|
||||
|
||||
export interface ZipFactoryParams extends IPublisherFactoryParams {
|
||||
outputPath?: string
|
||||
projectSlug?: string
|
||||
}
|
||||
|
||||
export interface ZipPublisher extends IPublisher<ZipFactoryParams, ZipPublisherResponse> {
|
||||
getOutputPath: () => string
|
||||
setOutputPath: (path: string) => void
|
||||
}
|
||||
|
||||
export const createZipPublisher: PublisherFactory<ZipFactoryParams, ZipPublisher> = (
|
||||
params: ZipFactoryParams = {}
|
||||
): ZipPublisher => {
|
||||
let { project, outputPath } = params
|
||||
|
||||
const getProject = () => project
|
||||
const setProject = (projectToSet: IResultDir) => {
|
||||
project = projectToSet
|
||||
}
|
||||
|
||||
const getOutputPath = () => outputPath
|
||||
const setOutputPath = (path: string) => {
|
||||
outputPath = path
|
||||
}
|
||||
|
||||
const publish = async (options: ZipFactoryParams = {}) => {
|
||||
const projectToPublish = options.project || project
|
||||
if (!projectToPublish) {
|
||||
throw new Error('MissingProject');
|
||||
}
|
||||
|
||||
const zipName = options.projectSlug || params.projectSlug || projectToPublish.name
|
||||
|
||||
try {
|
||||
const zipContent = await generateProjectZip(projectToPublish)
|
||||
|
||||
// If not output path is provided, zip is not written to disk
|
||||
const projectOutputPath = options.outputPath || outputPath
|
||||
if (projectOutputPath && isNodeProcess()) {
|
||||
await writeZipToDisk(projectOutputPath, zipContent, zipName)
|
||||
}
|
||||
return { success: true, payload: zipContent }
|
||||
} catch (error) {
|
||||
throw new Error('ZipUnexpected');
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
publish,
|
||||
getProject,
|
||||
setProject,
|
||||
getOutputPath,
|
||||
setOutputPath,
|
||||
}
|
||||
}
|
||||
57
packages/demo-server/src/publisher/utils.ts
Normal file
57
packages/demo-server/src/publisher/utils.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import * as JSZip from 'jszip';
|
||||
import { IResultFile, IResultDir } from '@ali/lowcode-code-generator';
|
||||
|
||||
export const isNodeProcess = (): boolean => {
|
||||
return (
|
||||
typeof process === 'object' &&
|
||||
typeof process.versions === 'object' &&
|
||||
typeof process.versions.node !== 'undefined'
|
||||
)
|
||||
}
|
||||
|
||||
export const writeZipToDisk = (
|
||||
zipFolderPath: string,
|
||||
content: Buffer | Blob,
|
||||
zipName: string
|
||||
): void => {
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
if (!fs.existsSync(zipFolderPath)) {
|
||||
fs.mkdirSync(zipFolderPath, { recursive: true })
|
||||
}
|
||||
|
||||
const zipPath = path.join(zipFolderPath, `${zipName}.zip`)
|
||||
|
||||
const writeStream = fs.createWriteStream(zipPath)
|
||||
writeStream.write(content)
|
||||
writeStream.end()
|
||||
}
|
||||
|
||||
export const generateProjectZip = async (project: IResultDir): Promise<Buffer | Blob> => {
|
||||
let zip = new JSZip()
|
||||
zip = writeFolderToZip(project, zip, true)
|
||||
const zipType = isNodeProcess() ? 'nodebuffer' : 'blob'
|
||||
return zip.generateAsync({ type: zipType })
|
||||
}
|
||||
|
||||
const writeFolderToZip = (
|
||||
folder: IResultDir,
|
||||
parentFolder: JSZip,
|
||||
ignoreFolder: boolean = false
|
||||
) => {
|
||||
const zipFolder = ignoreFolder ? parentFolder : parentFolder.folder(folder.name)
|
||||
|
||||
folder.files.forEach((file: IResultFile) => {
|
||||
// const options = file.contentEncoding === 'base64' ? { base64: true } : {}
|
||||
const options = {};
|
||||
const fileName = file.ext ? `${file.name}.${file.ext}` : file.name
|
||||
zipFolder.file(fileName, file.content, options)
|
||||
})
|
||||
|
||||
folder.dirs.forEach((subFolder: IResultDir) => {
|
||||
writeFolderToZip(subFolder, zipFolder)
|
||||
})
|
||||
|
||||
return parentFolder
|
||||
}
|
||||
24
packages/demo-server/test/app.e2e-spec.ts
Normal file
24
packages/demo-server/test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from './../src/app.module';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
||||
9
packages/demo-server/test/jest-e2e.json
Normal file
9
packages/demo-server/test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
4
packages/demo-server/tsconfig.build.json
Normal file
4
packages/demo-server/tsconfig.build.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
||||
15
packages/demo-server/tsconfig.json
Normal file
15
packages/demo-server/tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es2017",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true
|
||||
}
|
||||
}
|
||||
@ -3,129 +3,212 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="0.8.62"></a>
|
||||
## [0.8.62](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.61...@ali/lowcode-demo@0.8.62) (2020-08-27)
|
||||
<a name="1.0.7-0"></a>
|
||||
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@1.0.6-0...@ali/lowcode-demo@1.0.7-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.61"></a>
|
||||
## [0.8.61](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.60...@ali/lowcode-demo@0.8.61) (2020-08-26)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.60"></a>
|
||||
## [0.8.60](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.59...@ali/lowcode-demo@0.8.60) (2020-08-24)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.59"></a>
|
||||
## [0.8.59](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.58...@ali/lowcode-demo@0.8.59) (2020-08-23)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.58"></a>
|
||||
## [0.8.58](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.57...@ali/lowcode-demo@0.8.58) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.57"></a>
|
||||
## [0.8.57](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.56...@ali/lowcode-demo@0.8.57) (2020-08-19)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.56"></a>
|
||||
## [0.8.56](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.55...@ali/lowcode-demo@0.8.56) (2020-08-19)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.55"></a>
|
||||
## [0.8.55](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.54...@ali/lowcode-demo@0.8.55) (2020-08-19)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.54"></a>
|
||||
## [0.8.54](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.53...@ali/lowcode-demo@0.8.54) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.53"></a>
|
||||
## [0.8.53](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.52...@ali/lowcode-demo@0.8.53) (2020-08-14)
|
||||
<a name="1.0.6-0"></a>
|
||||
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.62...@ali/lowcode-demo@1.0.6-0) (2020-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修改移动端设备宽度 ([cd7b1e6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/cd7b1e6))
|
||||
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
|
||||
* 🐛 after event name & TabItem parent limitation ([76fb0b3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/76fb0b3))
|
||||
* 🐛 Card component's settings ([f44e7ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f44e7ab))
|
||||
* 🐛 Cascader init status ([e4a28c4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e4a28c4))
|
||||
* 🐛 codeout btn fix ([afda7d4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/afda7d4))
|
||||
* 🐛 Collapse render error ([6fed968](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6fed968))
|
||||
* 🐛 fix Menu & MenuButton assets cfg ([3d40aa2](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3d40aa2))
|
||||
* 🐛 Menu Items ([5ecacef](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/5ecacef))
|
||||
* 🐛 save and generator last page ([3e4254c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3e4254c))
|
||||
* 🐛 Tab & TabItem assets config ([0cc08fb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0cc08fb))
|
||||
* 🐛 Tag assets ([b460dcf](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b460dcf))
|
||||
* 🐛 Tag components setting ([de941da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/de941da))
|
||||
* 🐛 Timeline asset config ([436dadd](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/436dadd))
|
||||
* 🐛 use JsonSetter as dataSource Setter ([553f924](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/553f924))
|
||||
* 😈 table 无法选中问题 ([34825f8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/34825f8))
|
||||
* 适配Nav组件 ([7e9829f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7e9829f))
|
||||
* 修改插件面板配置 ([f9ceda5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9ceda5))
|
||||
* 修改js面板的保存schema问题 ([0ee8892](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0ee8892))
|
||||
* dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125))
|
||||
* fix mixsetter style ([0ecce83](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0ecce83))
|
||||
* fix NextTable callback function ([ce77375](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce77375))
|
||||
* fix source edit bug ([047247c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/047247c))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))
|
||||
* 🎸 Box config edit ([49b49ee](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/49b49ee))
|
||||
* 🎸 Button update ([7969273](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7969273))
|
||||
* 🎸 Collapse component update ([c682cc5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c682cc5))
|
||||
* 🎸 Collapse.panel has drop in Collapse ([d4d41e4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d4d41e4))
|
||||
* 🎸 pagination update ([f13b3ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f13b3ab))
|
||||
* 🎸 saveload btn for demo ([f91da66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f91da66))
|
||||
* 🎸 update upload component ([10abef5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/10abef5))
|
||||
* 🎸 upload update ([f81932b](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f81932b))
|
||||
* 适配TreeNode节点 ([8c36928](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8c36928))
|
||||
* 新增分隔符物料配置 ([af39c17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/af39c17))
|
||||
* 新增simulatorurl,可以设置cdn使用simulator ([1f45b05](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f45b05))
|
||||
* 增加出码按钮 ([6f7b066](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6f7b066))
|
||||
* 主设置面板里深层次界面通过 stagebox 进行过渡 ([783e945](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/783e945))
|
||||
* demo 构造 componentsMap ([f445ffe](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f445ffe))
|
||||
* tree 组件修改 ([7efa52f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7efa52f))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.8.52"></a>
|
||||
## [0.8.52](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.51...@ali/lowcode-demo@0.8.52) (2020-08-14)
|
||||
<a name="1.0.3-0"></a>
|
||||
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@1.0.2-0...@ali/lowcode-demo@1.0.3-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.51"></a>
|
||||
## [0.8.51](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.50...@ali/lowcode-demo@0.8.51) (2020-08-07)
|
||||
<a name="1.0.2-0"></a>
|
||||
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@1.0.1-0...@ali/lowcode-demo@1.0.2-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.50"></a>
|
||||
## [0.8.50](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.49...@ali/lowcode-demo@0.8.50) (2020-08-06)
|
||||
<a name="1.0.1-0"></a>
|
||||
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.57...@ali/lowcode-demo@1.0.1-0) (2020-08-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 🐛 Card component's settings ([f44e7ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f44e7ab))
|
||||
* 🐛 Cascader init status ([e4a28c4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e4a28c4))
|
||||
* 🐛 codeout btn fix ([afda7d4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/afda7d4))
|
||||
* 🐛 Collapse render error ([6fed968](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6fed968))
|
||||
* 🐛 save and generator last page ([3e4254c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3e4254c))
|
||||
* 🐛 Tab & TabItem assets config ([0cc08fb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0cc08fb))
|
||||
* 🐛 Tag assets ([b460dcf](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b460dcf))
|
||||
* 🐛 Tag components setting ([de941da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/de941da))
|
||||
* 🐛 use JsonSetter as dataSource Setter ([553f924](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/553f924))
|
||||
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
|
||||
* 😈 table 无法选中问题 ([34825f8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/34825f8))
|
||||
* dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125))
|
||||
* fix source edit bug ([047247c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/047247c))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))
|
||||
* 🎸 Box config edit ([49b49ee](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/49b49ee))
|
||||
* 🎸 Button update ([7969273](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7969273))
|
||||
* 🎸 Collapse component update ([c682cc5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c682cc5))
|
||||
* 🎸 Collapse.panel has drop in Collapse ([d4d41e4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d4d41e4))
|
||||
* 🎸 saveload btn for demo ([f91da66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f91da66))
|
||||
* demo 构造 componentsMap ([f445ffe](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f445ffe))
|
||||
* 主设置面板里深层次界面通过 stagebox 进行过渡 ([783e945](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/783e945))
|
||||
* 增加出码按钮 ([6f7b066](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6f7b066))
|
||||
* 新增分隔符物料配置 ([af39c17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/af39c17))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.15.0...@ali/lowcode-demo@1.0.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.49"></a>
|
||||
## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.48...@ali/lowcode-demo@0.8.49) (2020-08-06)
|
||||
<a name="0.15.0"></a>
|
||||
# [0.15.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.14.0...@ali/lowcode-demo@0.15.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.8.48"></a>
|
||||
## [0.8.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.47...@ali/lowcode-demo@0.8.48) (2020-08-06)
|
||||
<a name="0.14.0"></a>
|
||||
# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.12.0...@ali/lowcode-demo@0.14.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.13.0"></a>
|
||||
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.12.0...@ali/lowcode-demo@0.13.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.12.0"></a>
|
||||
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.11.0...@ali/lowcode-demo@0.12.0) (2020-08-16)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.11.0"></a>
|
||||
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.10.0...@ali/lowcode-demo@0.11.0) (2020-08-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 🐛 Tab & TabItem assets config ([0cc08fb](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0cc08fb))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.9.0...@ali/lowcode-demo@0.10.0) (2020-08-14)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-demo
|
||||
|
||||
<a name="0.9.0"></a>
|
||||
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.47...@ali/lowcode-demo@0.9.0) (2020-08-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 🐛 Card component's settings ([f44e7ab](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f44e7ab))
|
||||
* 🐛 Cascader init status ([e4a28c4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e4a28c4))
|
||||
* 🐛 codeout btn fix ([afda7d4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/afda7d4))
|
||||
* 🐛 Collapse render error ([6fed968](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6fed968))
|
||||
* 🐛 save and generator last page ([3e4254c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3e4254c))
|
||||
* 🐛 Tag assets ([b460dcf](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b460dcf))
|
||||
* 🐛 Tag components setting ([de941da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/de941da))
|
||||
* 🐛 use JsonSetter as dataSource Setter ([553f924](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/553f924))
|
||||
* 🐛 更改复杂类型生成工具的接口形式,减少调用复杂度 ([ce616b5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce616b5))
|
||||
* 😈 table 无法选中问题 ([34825f8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/34825f8))
|
||||
* dropdown and menu schema ([ae1d125](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ae1d125))
|
||||
* fix source edit bug ([047247c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/047247c))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 🎸 add demo-server ([df35c6a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/df35c6a))
|
||||
* 🎸 Box config edit ([49b49ee](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/49b49ee))
|
||||
* 🎸 Button update ([7969273](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7969273))
|
||||
* 🎸 saveload btn for demo ([f91da66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f91da66))
|
||||
* demo 构造 componentsMap ([f445ffe](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f445ffe))
|
||||
* 主设置面板里深层次界面通过 stagebox 进行过渡 ([783e945](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/783e945))
|
||||
* 增加出码按钮 ([6f7b066](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6f7b066))
|
||||
* 新增分隔符物料配置 ([af39c17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/af39c17))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.8.47"></a>
|
||||
## [0.8.47](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-demo@0.8.46...@ali/lowcode-demo@0.8.47) (2020-08-04)
|
||||
|
||||
@ -523,10 +606,5 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
### Features
|
||||
|
||||
<<<<<<< HEAD
|
||||
* complet preview ([56c16ff](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/56c16ff))
|
||||
* double outline & ZH_EN support ([b379bd7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b379bd7))
|
||||
=======
|
||||
* complet preview ([56c16ff](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/56c16ffa5c39c2d01abd9cfa90fea49a4539da1d))
|
||||
* double outline & ZH_EN support ([b379bd7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b379bd7c0c488ef24f825760750a13d3fa083c96))
|
||||
>>>>>>> df955e1db90ff104cd11160def80113cfd6faccc
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ali/lowcode-demo",
|
||||
"version": "0.8.62",
|
||||
"version": "1.0.7-0",
|
||||
"private": true,
|
||||
"description": "低代码引擎 DEMO",
|
||||
"scripts": {
|
||||
@ -9,21 +9,21 @@
|
||||
},
|
||||
"config": {},
|
||||
"dependencies": {
|
||||
"@ali/lowcode-editor-core": "^0.8.34",
|
||||
"@ali/lowcode-editor-skeleton": "^0.8.58",
|
||||
"@ali/lowcode-plugin-components-pane": "^0.8.54",
|
||||
"@ali/lowcode-plugin-designer": "^0.9.52",
|
||||
"@ali/lowcode-plugin-event-bind-dialog": "^0.8.32",
|
||||
"@ali/lowcode-plugin-outline-pane": "^0.8.58",
|
||||
"@ali/lowcode-plugin-sample-logo": "^0.8.31",
|
||||
"@ali/lowcode-plugin-sample-preview": "^0.8.56",
|
||||
"@ali/lowcode-editor-core": "^1.0.7-0",
|
||||
"@ali/lowcode-editor-skeleton": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-components-pane": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-designer": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-event-bind-dialog": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-outline-pane": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-sample-logo": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-sample-preview": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-settings-pane": "^0.8.8",
|
||||
"@ali/lowcode-plugin-undo-redo": "^0.8.56",
|
||||
"@ali/lowcode-plugin-variable-bind-dialog": "^0.8.30",
|
||||
"@ali/lowcode-plugin-zh-en": "^0.8.34",
|
||||
"@ali/lowcode-react-renderer": "^0.8.20",
|
||||
"@ali/lowcode-runtime": "^0.8.16",
|
||||
"@ali/lowcode-utils": "^0.8.20",
|
||||
"@ali/lowcode-plugin-undo-redo": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-variable-bind-dialog": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-zh-en": "^1.0.7-0",
|
||||
"@ali/lowcode-react-renderer": "^1.0.7-0",
|
||||
"@ali/lowcode-runtime": "^1.0.7-0",
|
||||
"@ali/lowcode-utils": "^1.0.7-0",
|
||||
"@ali/ve-action-pane": "^4.7.0-beta.0",
|
||||
"@ali/ve-datapool-pane": "^6.4.3",
|
||||
"@ali/ve-history-pane": "4.0.0",
|
||||
@ -39,13 +39,16 @@
|
||||
"@alife/theme-lowcode-light": "^0.1.0",
|
||||
"compare-versions": "^3.0.1",
|
||||
"react": "^16.8.1",
|
||||
"react-dom": "^16.8.1"
|
||||
"react-dom": "^16.8.1",
|
||||
"streamsaver": "^2.0.4",
|
||||
"web-streams-polyfill": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alib/build-scripts": "^0.1.18",
|
||||
"@types/events": "^3.0.0",
|
||||
"@types/react": "^16.8.3",
|
||||
"@types/react-dom": "^16.8.2",
|
||||
"@types/streamsaver": "^2.0.0",
|
||||
"build-plugin-fusion": "^0.1.0",
|
||||
"build-plugin-moment-locales": "^0.1.0",
|
||||
"build-plugin-react-app": "^1.1.2",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -14,8 +14,8 @@
|
||||
</script>
|
||||
<script src="https://g.alicdn.com/platform/c/??react15-polyfill/0.0.1/dist/index.js,lodash/4.6.1/lodash.min.js,immutable/3.7.6/dist/immutable.min.js,natty-storage/2.0.2/dist/natty-storage.min.js,natty-fetch/2.6.0/dist/natty-fetch.pc.min.js,tinymce/4.2.5/tinymce-full.js"></script>
|
||||
<script src="https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js"></script>
|
||||
<link rel="stylesheet" href="https://alifd.alicdn.com/npm/@alifd/next/1.11.6/next.min.css" />
|
||||
<script src="https://unpkg.alibaba-inc.com/@alifd/next@1.18.17/dist/next.min.js"></script>
|
||||
<link rel="stylesheet" href="https://unpkg.alibaba-inc.com/@alifd/next@1.20.25/dist/next.min.css" />
|
||||
<script src="https://unpkg.alibaba-inc.com/@alifd/next@1.20.25/dist/next.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/rax@1.1.3/dist/rax.js"></script>
|
||||
<link rel="stylesheet" href="/css/editor-preset-vision.css" />
|
||||
<script>
|
||||
@ -69,6 +69,10 @@
|
||||
|
||||
<body>
|
||||
<!-- lowcode engine globals -->
|
||||
<div id="lce-container"></div>
|
||||
<!-- vision 测试使用
|
||||
|
||||
-->
|
||||
<script src="/js/editor-preset-vision.js"></script>
|
||||
<script src="https://dev.g.alicdn.com/vision/visualengine-utils/5.0.0/engine-utils.js"></script>
|
||||
</body>
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
{ "library": "VisualEngineUtils.NumberSetter", "name": "@ali/vs-number" },
|
||||
{ "library": "VisualEngineUtils.OptionsSetter", "name": "@ali/vs-options" },
|
||||
{ "library": "VisualEngineUtils.SelectSetter", "name": "@ali/vs-select" },
|
||||
{ "library": "VisualEngineUtils.TextSetter", "name": "@ali/vs-text" },
|
||||
{ "library": "VisualEngineUtils.TextSetter", "name": "@ali/vs-text"},
|
||||
{ "library": "VisualEngineUtils.ValidationSetter", "name": "@ali/vs-validation" },
|
||||
{ "library": "VisualEngineUtils.ImageSetter", "name": "@ali/vs-image" },
|
||||
{ "library": "VisualEngineUtils.StyleSetter", "name": "@ali/vs-style" },
|
||||
@ -84,6 +84,23 @@
|
||||
"appKey": "template_deep_mobile",
|
||||
"systemType": "",
|
||||
"componentDependencies": [
|
||||
{
|
||||
"packageName": "@alife/service-hall-base-space",
|
||||
"library": "alifeServiceHallBaseSpace",
|
||||
"version": "0.1.0",
|
||||
"components": null,
|
||||
"prototypeViewsUrl": null,
|
||||
"prototypeUrls": {
|
||||
"default": [
|
||||
"https://dev.g.alicdn.com/service-hall-components/base-space/0.1.0/designer.js"
|
||||
]
|
||||
},
|
||||
"alias": "",
|
||||
"prototypeConfigsUrl": [
|
||||
"https://dev.g.alicdn.com/service-hall-components/base-space/0.1.0/designer.js"
|
||||
],
|
||||
"urls": ["https://dev.g.alicdn.com/service-hall-components/base-space/0.1.0/view.js"]
|
||||
},
|
||||
{
|
||||
"prototypeViewsUrl": null,
|
||||
"prototypeUrls": {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
52
packages/demo/public/text.json
Normal file
52
packages/demo/public/text.json
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
{
|
||||
"packageName": "@alife/knowledge-detail",
|
||||
"version": "0.1.0",
|
||||
"library": "ServiceHallKnowledgeDetail",
|
||||
"ext": {
|
||||
"project": "knowledge-detail",
|
||||
"group": "service-hall-components"
|
||||
},
|
||||
"urls": ["https://dev.g.alicdn.com/service-hall-components/knowledge-detail/0.1.0/designer.js"]
|
||||
},
|
||||
{
|
||||
"packageName": "@alife/benefits-list",
|
||||
"version": "0.1.1",
|
||||
"library": "ServiceHallBenefitsList",
|
||||
"ext": {
|
||||
"project": "benefits-list",
|
||||
"group": "service-hall-components"
|
||||
},
|
||||
"urls": ["https://dev.g.alicdn.com/service-hall-components/benefits-list/0.1.1/designer.js"]
|
||||
},
|
||||
{
|
||||
"packageName": "@alife/todo-list",
|
||||
"version": "0.1.1",
|
||||
"library": "ServiceHallTodoList",
|
||||
"ext": {
|
||||
"project": "todo-list",
|
||||
"group": "service-hall-components"
|
||||
},
|
||||
"urls": ["https://dev.g.alicdn.com/service-hall-components/todo-list/0.1.1/designer.js"]
|
||||
},
|
||||
{
|
||||
"packageName": "@alife/todo-list-detail",
|
||||
"version": "0.1.1",
|
||||
"library": "ServiceHallTodoListDetail",
|
||||
"ext": {
|
||||
"project": "todo-list-detail",
|
||||
"group": "service-hall-components"
|
||||
},
|
||||
"urls": ["https://dev.g.alicdn.com/service-hall-components/todo-list-detail/0.1.1/designer.js"]
|
||||
},
|
||||
{
|
||||
"packageName": "@alife/service-hall-tabs",
|
||||
"library": "ServiceHallTabs",
|
||||
"version": "0.1.0",
|
||||
"ext": {
|
||||
"project": "tabs",
|
||||
"group": "service-hall-components"
|
||||
},
|
||||
"urls": ["https://dev.g.alicdn.com/service-hall-components/tabs/0.1.0/designer.js"]
|
||||
}
|
||||
}
|
||||
887
packages/demo/public/vision-schema.json
Normal file
887
packages/demo/public/vision-schema.json
Normal file
@ -0,0 +1,887 @@
|
||||
{
|
||||
"componentName": "Page",
|
||||
"id": "node_1",
|
||||
"props": {
|
||||
"ref": "outterView",
|
||||
"autoLoading": true,
|
||||
"style": {
|
||||
"padding": 20
|
||||
}
|
||||
},
|
||||
"fileName": "test",
|
||||
"dataSource": {
|
||||
"list": []
|
||||
},
|
||||
"state": {
|
||||
"text": "outter",
|
||||
"abc": [1, 2, 3]
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Steps",
|
||||
"id": "node_1i",
|
||||
"props": {
|
||||
"dataSource": [
|
||||
{
|
||||
"title": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": "报名"
|
||||
},
|
||||
"status": "",
|
||||
"content": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": "Open the refrigerator door"
|
||||
},
|
||||
"customSwitcher": false
|
||||
},
|
||||
{
|
||||
"title": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": "信息收集"
|
||||
},
|
||||
"status": "",
|
||||
"content": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": "Put the elephant in the refrigerator"
|
||||
},
|
||||
"customSwitcher": false
|
||||
},
|
||||
{
|
||||
"title": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": "审核"
|
||||
},
|
||||
"status": "",
|
||||
"content": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": "Close the refrigerator door"
|
||||
},
|
||||
"customSwitcher": false
|
||||
}
|
||||
],
|
||||
"current": 1,
|
||||
"shape": "circle",
|
||||
"direction": "horizontal",
|
||||
"labelPlacement": "vertical",
|
||||
"readOnly": false,
|
||||
"animation": true,
|
||||
"__style__": {},
|
||||
"fieldId": "steps_kadcb0ov"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "Title",
|
||||
"id": "node_b",
|
||||
"props": {
|
||||
"text": "请填写以下人员信息表单",
|
||||
"type": "primary",
|
||||
"noDecoration": false,
|
||||
"__style__": {},
|
||||
"fieldId": "title_kadcb0nw"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "Paragraph",
|
||||
"id": "node_e",
|
||||
"props": {
|
||||
"content": "人最宝贵的是生命。它给予我们只有一次。人的一生应当这样度过:当他回首往事时不因虚度年华而悔恨,也不因碌碌无为而羞耻。这样在他临死的时侯就能够说:我已把我整个的生命和全部精力都献给最壮丽的事业——为人类的解放而斗争。",
|
||||
"size": "medium",
|
||||
"type": "long",
|
||||
"__style__": {},
|
||||
"fieldId": "paragraph_kadcb0nz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "ColumnsLayout",
|
||||
"id": "node_r",
|
||||
"props": {
|
||||
"layout": "6:6",
|
||||
"columnGap": "16px",
|
||||
"rowGap": "16px",
|
||||
"__style__": {
|
||||
"marginTop": "24px"
|
||||
},
|
||||
"fieldId": "columnsLayout_kadcb0ob"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Column",
|
||||
"id": "node_s",
|
||||
"props": {
|
||||
"fieldId": "column_kadcb0o9",
|
||||
"__style__": {}
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Card",
|
||||
"id": "node_n",
|
||||
"props": {
|
||||
"title": "基本信息",
|
||||
"subTitle": {
|
||||
"type": "i18n",
|
||||
"zh_CN": "",
|
||||
"en_US": ""
|
||||
},
|
||||
"extra": {
|
||||
"type": "JSSlot",
|
||||
"params": null,
|
||||
"value": [
|
||||
{
|
||||
"componentName": "Icon",
|
||||
"id": "node_q",
|
||||
"props": {
|
||||
"type": {
|
||||
"useType": true,
|
||||
"baseType": "smile",
|
||||
"otherType": "smile"
|
||||
},
|
||||
"size": "medium",
|
||||
"__style__": {},
|
||||
"fieldId": "icon_kadcb0o8"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"showTitleBullet": true,
|
||||
"showHeadDivider": true,
|
||||
"dividerNoInset": false,
|
||||
"contentHeight": "",
|
||||
"__style__": {},
|
||||
"fieldId": "card_kadcb0o7"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "CardContent",
|
||||
"id": "node_o",
|
||||
"props": {},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Form",
|
||||
"id": "node_f",
|
||||
"props": {
|
||||
"labelAlign": "top",
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"autoValidate": true,
|
||||
"scrollToFirstError": true,
|
||||
"autoUnmount": true,
|
||||
"fieldOptions": {},
|
||||
"__style__": {
|
||||
"marginTop": "24px"
|
||||
},
|
||||
"fieldId": "form_kadcb0o5"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "TextField",
|
||||
"id": "node_g",
|
||||
"props": {
|
||||
"__category__": "form",
|
||||
"__useMediator": "value",
|
||||
"label": "姓名",
|
||||
"value": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"labelAlign": "top",
|
||||
"labelColSpan": 4,
|
||||
"labelColOffset": 0,
|
||||
"wrapperColSpan": 0,
|
||||
"wrapperColOffset": 0,
|
||||
"labelTextAlign": "right",
|
||||
"placeholder": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": "Please enter",
|
||||
"zh_CN": "请输入"
|
||||
},
|
||||
"tips": {
|
||||
"zh_CN": "",
|
||||
"en_US": "",
|
||||
"type": "i18n"
|
||||
},
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"labelTipsTypes": "none",
|
||||
"labelTipsIcon": "",
|
||||
"labelTipsText": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"htmlType": "input",
|
||||
"state": "",
|
||||
"rows": 4,
|
||||
"autoHeight": false,
|
||||
"hasClear": false,
|
||||
"trim": false,
|
||||
"autoFocus": false,
|
||||
"addonBefore": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"addonAfter": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"validation": [],
|
||||
"hasLimitHint": false,
|
||||
"cutString": false,
|
||||
"__style__": {},
|
||||
"fieldId": "textField_kadcb0o0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "RadioField",
|
||||
"id": "node_14",
|
||||
"props": {
|
||||
"__category__": "form",
|
||||
"__useMediator": "value",
|
||||
"label": "性别",
|
||||
"value": "",
|
||||
"labelAlign": "top",
|
||||
"labelColSpan": 4,
|
||||
"labelColOffset": 0,
|
||||
"wrapperColSpan": 0,
|
||||
"wrapperColOffset": 0,
|
||||
"labelTextAlign": "right",
|
||||
"tips": {
|
||||
"zh_CN": "",
|
||||
"en_US": "",
|
||||
"type": "i18n"
|
||||
},
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"labelTipsTypes": "none",
|
||||
"labelTipsIcon": "",
|
||||
"labelTipsText": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"shape": "default",
|
||||
"itemDirection": "hoz",
|
||||
"dataSource": [
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项一",
|
||||
"en_US": "Option 1",
|
||||
"type": "i18n",
|
||||
"use": "zh_CN"
|
||||
},
|
||||
"value": "1",
|
||||
"disable": false
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项二",
|
||||
"en_US": "Option 2",
|
||||
"type": "i18n",
|
||||
"use": "zh_CN"
|
||||
},
|
||||
"value": "2",
|
||||
"disable": false
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项三",
|
||||
"en_US": "Option 3",
|
||||
"type": "i18n",
|
||||
"use": "zh_CN"
|
||||
},
|
||||
"value": "3",
|
||||
"disable": true
|
||||
}
|
||||
],
|
||||
"validation": [],
|
||||
"__style__": {},
|
||||
"fieldId": "radioField_kadcb0ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "SelectField",
|
||||
"id": "node_h",
|
||||
"props": {
|
||||
"__category__": "form",
|
||||
"__useMediator": "value",
|
||||
"label": "学校",
|
||||
"value": "",
|
||||
"labelAlign": "top",
|
||||
"labelColSpan": 4,
|
||||
"labelColOffset": 0,
|
||||
"wrapperColSpan": 0,
|
||||
"wrapperColOffset": 0,
|
||||
"labelTextAlign": "right",
|
||||
"placeholder": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": "please select",
|
||||
"zh_CN": "请选择"
|
||||
},
|
||||
"tips": {
|
||||
"zh_CN": "",
|
||||
"en_US": "",
|
||||
"type": "i18n"
|
||||
},
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"labelTipsTypes": "none",
|
||||
"labelTipsIcon": "",
|
||||
"labelTipsText": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"mode": "single",
|
||||
"hasClear": false,
|
||||
"hasSelectAll": false,
|
||||
"showSearch": false,
|
||||
"filterLocal": true,
|
||||
"dataSource": [
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项一",
|
||||
"en_US": "Option 1",
|
||||
"type": "i18n"
|
||||
},
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项二",
|
||||
"en_US": "Option 2",
|
||||
"type": "i18n"
|
||||
},
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项三",
|
||||
"en_US": "Option 3",
|
||||
"type": "i18n"
|
||||
},
|
||||
"value": "3"
|
||||
}
|
||||
],
|
||||
"validation": [],
|
||||
"notFoundContent": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null
|
||||
},
|
||||
"hasArrow": true,
|
||||
"hasBorder": true,
|
||||
"autoWidth": true,
|
||||
"searchDelay": 300,
|
||||
"__style__": {},
|
||||
"fieldId": "select_kadcb0o1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "Div",
|
||||
"id": "node_i",
|
||||
"props": {
|
||||
"behavior": "NORMAL",
|
||||
"__style__": {},
|
||||
"fieldId": "div_kadcb0o4"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Button",
|
||||
"id": "node_j",
|
||||
"props": {
|
||||
"content": {
|
||||
"type": "i18n",
|
||||
"en_US": "Ok",
|
||||
"zh_CN": "提交"
|
||||
},
|
||||
"type": "primary",
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"baseIcon": "",
|
||||
"otherIcon": "",
|
||||
"loading": false,
|
||||
"triggerEventsWhenLoading": false,
|
||||
"__style__": ":root {\n margin-right: 15px;\n}",
|
||||
"fieldId": "button_kadcb0o2",
|
||||
"onClick": {
|
||||
"type": "JSExpression",
|
||||
"value": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}",
|
||||
"extType": "function",
|
||||
"events": [
|
||||
{
|
||||
"name": "onClick",
|
||||
"params": {},
|
||||
"func": {
|
||||
"type": "js",
|
||||
"source": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}",
|
||||
"compiled": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "Button",
|
||||
"id": "node_k",
|
||||
"props": {
|
||||
"content": {
|
||||
"type": "i18n",
|
||||
"en_US": "Reset",
|
||||
"zh_CN": "重置"
|
||||
},
|
||||
"type": "secondary",
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"baseIcon": "",
|
||||
"otherIcon": "",
|
||||
"loading": false,
|
||||
"triggerEventsWhenLoading": false,
|
||||
"__style__": {},
|
||||
"fieldId": "button_kadcb0o3",
|
||||
"onClick": {
|
||||
"type": "JSExpression",
|
||||
"value": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}",
|
||||
"extType": "function",
|
||||
"events": [
|
||||
{
|
||||
"name": "onClick",
|
||||
"params": {},
|
||||
"func": {
|
||||
"type": "js",
|
||||
"source": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}",
|
||||
"compiled": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"componentName": "Column",
|
||||
"id": "node_t",
|
||||
"props": {
|
||||
"fieldId": "column_kadcb0oa",
|
||||
"__style__": {}
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Card",
|
||||
"id": "node_u",
|
||||
"props": {
|
||||
"title": {
|
||||
"type": "JSSlot",
|
||||
"params": null,
|
||||
"value": [
|
||||
{
|
||||
"componentName": "Icon",
|
||||
"id": "node_18",
|
||||
"props": {
|
||||
"type": {
|
||||
"useType": true,
|
||||
"baseType": "smile",
|
||||
"otherType": "smile"
|
||||
},
|
||||
"size": "medium",
|
||||
"__style__": {},
|
||||
"fieldId": "icon_kadcb0on"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "Link",
|
||||
"id": "node_19",
|
||||
"props": {
|
||||
"content": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": "link text",
|
||||
"zh_CN": "扩展信息"
|
||||
},
|
||||
"textOverflow": false,
|
||||
"link": {
|
||||
"type": "page",
|
||||
"page": null,
|
||||
"router": {
|
||||
"type": "JSExpression",
|
||||
"value": "this.utils.router"
|
||||
}
|
||||
},
|
||||
"__style__": {},
|
||||
"fieldId": "link_kadcb0oo"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"subTitle": {
|
||||
"type": "i18n",
|
||||
"zh_CN": "",
|
||||
"en_US": ""
|
||||
},
|
||||
"extra": {
|
||||
"type": "JSSlot",
|
||||
"params": null,
|
||||
"value": [
|
||||
{
|
||||
"componentName": "Icon",
|
||||
"id": "node_1a",
|
||||
"props": {
|
||||
"type": {
|
||||
"useType": true,
|
||||
"baseType": "smile",
|
||||
"otherType": "smile"
|
||||
},
|
||||
"size": "xl",
|
||||
"__style__": {},
|
||||
"fieldId": "icon_kadcb0op"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"showTitleBullet": true,
|
||||
"showHeadDivider": true,
|
||||
"dividerNoInset": false,
|
||||
"contentHeight": "",
|
||||
"__style__": {},
|
||||
"fieldId": "card_kadcb0oc"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "CardContent",
|
||||
"id": "node_v",
|
||||
"props": {},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Form",
|
||||
"id": "node_x",
|
||||
"props": {
|
||||
"labelAlign": "top",
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"autoValidate": true,
|
||||
"scrollToFirstError": true,
|
||||
"autoUnmount": true,
|
||||
"fieldOptions": {},
|
||||
"__style__": {
|
||||
"marginTop": "24px"
|
||||
},
|
||||
"fieldId": "form_kadcb0oi"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "TextField",
|
||||
"id": "node_y",
|
||||
"props": {
|
||||
"__category__": "form",
|
||||
"__useMediator": "value",
|
||||
"label": "职位",
|
||||
"value": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"labelAlign": "top",
|
||||
"labelColSpan": 4,
|
||||
"labelColOffset": 0,
|
||||
"wrapperColSpan": 0,
|
||||
"wrapperColOffset": 0,
|
||||
"labelTextAlign": "right",
|
||||
"placeholder": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": "Please enter",
|
||||
"zh_CN": "请输入"
|
||||
},
|
||||
"tips": {
|
||||
"zh_CN": "",
|
||||
"en_US": "",
|
||||
"type": "i18n"
|
||||
},
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"labelTipsTypes": "none",
|
||||
"labelTipsIcon": "",
|
||||
"labelTipsText": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"htmlType": "input",
|
||||
"state": "",
|
||||
"rows": 4,
|
||||
"autoHeight": false,
|
||||
"hasClear": false,
|
||||
"trim": false,
|
||||
"autoFocus": false,
|
||||
"addonBefore": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"addonAfter": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"validation": [],
|
||||
"hasLimitHint": false,
|
||||
"cutString": false,
|
||||
"__style__": {},
|
||||
"fieldId": "textField_kadcb0od"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "DateField",
|
||||
"id": "node_15",
|
||||
"props": {
|
||||
"__category__": "form",
|
||||
"__useMediator": "value",
|
||||
"label": "入职时间",
|
||||
"value": "",
|
||||
"labelAlign": "top",
|
||||
"labelColSpan": 4,
|
||||
"labelColOffset": 0,
|
||||
"wrapperColSpan": 0,
|
||||
"wrapperColOffset": 0,
|
||||
"labelTextAlign": "right",
|
||||
"placeholder": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": "please select",
|
||||
"zh_CN": "请选择"
|
||||
},
|
||||
"tips": {
|
||||
"zh_CN": "",
|
||||
"en_US": "",
|
||||
"type": "i18n"
|
||||
},
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"format": "YYYY-MM-DD",
|
||||
"returnType": "timestamp",
|
||||
"labelTipsTypes": "none",
|
||||
"labelTipsIcon": "",
|
||||
"labelTipsText": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"hasClear": true,
|
||||
"resetTime": false,
|
||||
"disabledDate": false,
|
||||
"validation": [],
|
||||
"__style__": {},
|
||||
"fieldId": "dateField_kadcb0ol"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "SelectField",
|
||||
"id": "node_z",
|
||||
"props": {
|
||||
"__category__": "form",
|
||||
"__useMediator": "value",
|
||||
"label": "下拉选择",
|
||||
"value": "",
|
||||
"labelAlign": "top",
|
||||
"labelColSpan": 4,
|
||||
"labelColOffset": 0,
|
||||
"wrapperColSpan": 0,
|
||||
"wrapperColOffset": 0,
|
||||
"labelTextAlign": "right",
|
||||
"placeholder": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": "please select",
|
||||
"zh_CN": "请选择"
|
||||
},
|
||||
"tips": {
|
||||
"zh_CN": "",
|
||||
"en_US": "",
|
||||
"type": "i18n"
|
||||
},
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"labelTipsTypes": "none",
|
||||
"labelTipsIcon": "",
|
||||
"labelTipsText": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null,
|
||||
"zh_CN": ""
|
||||
},
|
||||
"mode": "single",
|
||||
"hasClear": false,
|
||||
"hasSelectAll": false,
|
||||
"showSearch": false,
|
||||
"filterLocal": true,
|
||||
"dataSource": [
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项一",
|
||||
"en_US": "Option 1",
|
||||
"type": "i18n"
|
||||
},
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项二",
|
||||
"en_US": "Option 2",
|
||||
"type": "i18n"
|
||||
},
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"zh_CN": "选项三",
|
||||
"en_US": "Option 3",
|
||||
"type": "i18n"
|
||||
},
|
||||
"value": "3"
|
||||
}
|
||||
],
|
||||
"validation": [],
|
||||
"notFoundContent": {
|
||||
"type": "i18n",
|
||||
"use": "zh_CN",
|
||||
"en_US": null
|
||||
},
|
||||
"hasArrow": true,
|
||||
"hasBorder": true,
|
||||
"autoWidth": true,
|
||||
"searchDelay": 300,
|
||||
"__style__": {},
|
||||
"fieldId": "select_kadcb0oe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "Div",
|
||||
"id": "node_10",
|
||||
"props": {
|
||||
"behavior": "NORMAL",
|
||||
"__style__": {},
|
||||
"fieldId": "div_kadcb0oh"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Button",
|
||||
"id": "node_11",
|
||||
"props": {
|
||||
"content": {
|
||||
"type": "i18n",
|
||||
"en_US": "Ok",
|
||||
"zh_CN": "提交"
|
||||
},
|
||||
"type": "primary",
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"baseIcon": "",
|
||||
"otherIcon": "",
|
||||
"loading": false,
|
||||
"triggerEventsWhenLoading": false,
|
||||
"__style__": ":root {\n margin-right: 15px;\n}",
|
||||
"fieldId": "button_kadcb0of",
|
||||
"onClick": {
|
||||
"type": "JSExpression",
|
||||
"value": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}",
|
||||
"extType": "function",
|
||||
"events": [
|
||||
{
|
||||
"name": "onClick",
|
||||
"params": {},
|
||||
"func": {
|
||||
"type": "js",
|
||||
"source": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}",
|
||||
"compiled": "function onSubmit(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').submit(function(data, error) {\n if (data) {\n console.log(data);\n // 往后端提交数据,一般写法如下\n // this.dataSourceMap['xxx'].load(data).then(() => {\n // this.utils.toast({\n // type: 'success',\n // title: '提交成功'\n // });\n // });\n }\n });\n}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"componentName": "Button",
|
||||
"id": "node_12",
|
||||
"props": {
|
||||
"content": {
|
||||
"type": "i18n",
|
||||
"en_US": "Reset",
|
||||
"zh_CN": "重置"
|
||||
},
|
||||
"type": "secondary",
|
||||
"size": "medium",
|
||||
"behavior": "NORMAL",
|
||||
"baseIcon": "",
|
||||
"otherIcon": "",
|
||||
"loading": false,
|
||||
"triggerEventsWhenLoading": false,
|
||||
"__style__": {},
|
||||
"fieldId": "button_kadcb0og",
|
||||
"onClick": {
|
||||
"type": "JSExpression",
|
||||
"value": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}",
|
||||
"extType": "function",
|
||||
"events": [
|
||||
{
|
||||
"name": "onClick",
|
||||
"params": {},
|
||||
"func": {
|
||||
"type": "js",
|
||||
"source": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}",
|
||||
"compiled": "function onReset(){\n // 请将 fieldId 替换为表单容器的 fieldId\n this.$('fieldId').reset();\n}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import { ReactProvider, Utils } from '@ali/lowcode-runtime';
|
||||
import { ReactProvider } from '@ali/lowcode-runtime';
|
||||
import { buildComponents } from '@ali/lowcode-utils';
|
||||
import appConfig from '../config/app';
|
||||
import builtInComps from '../config/components';
|
||||
import componentsMap from '../config/componentsMap';
|
||||
@ -31,7 +32,7 @@ export default class Preview extends ReactProvider {
|
||||
layout,
|
||||
routes,
|
||||
containerId,
|
||||
components: { ...builtInComps, ...Utils.buildComponents({ '@alifd/next': 'Next' }, componentsMap) },
|
||||
components: { ...builtInComps, ...buildComponents({ '@alifd/next': 'Next' }, componentsMap) },
|
||||
componentsMap,
|
||||
utils: utils,
|
||||
constants,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import logo from '@ali/lowcode-plugin-sample-logo';
|
||||
import samplePreview from '@ali/lowcode-plugin-sample-preview';
|
||||
//import undoRedo from '@ali/lowcode-plugin-undo-redo';
|
||||
import undoRedo from '@ali/lowcode-plugin-undo-redo';
|
||||
import componentsPane from '@ali/lowcode-plugin-components-pane';
|
||||
import outline, { OutlinePane } from '@ali/lowcode-plugin-outline-pane';
|
||||
import zhEn from '@ali/lowcode-plugin-zh-en';
|
||||
@ -8,14 +8,19 @@ import eventBindDialog from '@ali/lowcode-plugin-event-bind-dialog';
|
||||
import variableBindDialog from '@ali/lowcode-plugin-variable-bind-dialog';
|
||||
import sourceEditor from '@ali/lowcode-plugin-source-editor';
|
||||
|
||||
import codeout from './plugins/codeout';
|
||||
import saveload from './plugins/saveload';
|
||||
|
||||
export default {
|
||||
logo,
|
||||
samplePreview,
|
||||
//undoRedo,
|
||||
undoRedo,
|
||||
componentsPane,
|
||||
outline,
|
||||
zhEn,
|
||||
eventBindDialog,
|
||||
variableBindDialog,
|
||||
sourceEditor,
|
||||
codeout,
|
||||
saveload,
|
||||
};
|
||||
|
||||
@ -13,7 +13,6 @@ export default {
|
||||
href: '/',
|
||||
},
|
||||
},
|
||||
/*
|
||||
{
|
||||
pluginKey: 'undoRedo',
|
||||
type: 'Custom',
|
||||
@ -22,6 +21,7 @@ export default {
|
||||
width: 88,
|
||||
},
|
||||
},
|
||||
/*
|
||||
{
|
||||
pluginKey: 'divider',
|
||||
type: 'Divider',
|
||||
@ -37,8 +37,37 @@ export default {
|
||||
width: 64,
|
||||
},
|
||||
},
|
||||
{
|
||||
pluginKey: 'codeout',
|
||||
type: 'Custom',
|
||||
props: {
|
||||
align: 'right',
|
||||
width: 64,
|
||||
},
|
||||
},
|
||||
{
|
||||
pluginKey: 'saveload',
|
||||
type: 'Custom',
|
||||
props: {
|
||||
align: 'right',
|
||||
width: 128,
|
||||
},
|
||||
},
|
||||
],
|
||||
leftArea: [
|
||||
{
|
||||
pluginKey: 'outline',
|
||||
type: 'PanelIcon',
|
||||
props: {
|
||||
align: 'top',
|
||||
icon: 'shuxingkongjian',
|
||||
description: '大纲树',
|
||||
panelProps: {
|
||||
area: 'leftFixedArea',
|
||||
},
|
||||
},
|
||||
pluginProps: {},
|
||||
},
|
||||
{
|
||||
pluginKey: 'componentsPane',
|
||||
type: 'PanelIcon',
|
||||
@ -49,31 +78,21 @@ export default {
|
||||
},
|
||||
pluginProps: {},
|
||||
},
|
||||
{
|
||||
pluginKey: 'outline',
|
||||
type: 'PanelIcon',
|
||||
props: {
|
||||
align: 'top',
|
||||
icon: 'shuxingkongjian',
|
||||
description: '大纲树',
|
||||
},
|
||||
pluginProps: {},
|
||||
},
|
||||
{
|
||||
pluginKey: 'sourceEditor',
|
||||
type: 'PanelIcon',
|
||||
props: {
|
||||
align: 'top',
|
||||
icon: 'wenjian',
|
||||
description: '资源面板',
|
||||
description: 'JS面板',
|
||||
panelProps: {
|
||||
floatable: true,
|
||||
height: 300,
|
||||
help: undefined,
|
||||
hideTitleBar: true,
|
||||
hideTitleBar: false,
|
||||
maxHeight: 800,
|
||||
maxWidth: 1200,
|
||||
title: '动作面板',
|
||||
title: 'JS面板',
|
||||
width: 600,
|
||||
},
|
||||
},
|
||||
@ -101,6 +120,12 @@ export default {
|
||||
init: async function init(editor) {
|
||||
const assets = await editor.utils.get('./assets.json');
|
||||
editor.set('assets', assets);
|
||||
const simulatorUrl = [
|
||||
'https://dev.g.alicdn.com/ali-lowcode/ali-lowcode-engine/0.9.50/react-simulator-renderer.css',
|
||||
'https://dev.g.alicdn.com/ali-lowcode/ali-lowcode-engine/0.9.50/react-simulator-renderer.js',
|
||||
];
|
||||
editor.set('simulatorUrl', simulatorUrl);
|
||||
// editor.set('renderEnv', 'rax');
|
||||
|
||||
const schema = await editor.utils.get('./schema.json');
|
||||
editor.set('schema', schema);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { render } from 'react-dom';
|
||||
import GeneralWorkbench, { editor } from '../../../editor-preset-general/src';
|
||||
import GeneralWorkbench, { editor } from '@ali/lowcode-editor-preset-general';
|
||||
import config from './config';
|
||||
import components from './components';
|
||||
import './global.scss';
|
||||
|
||||
3
packages/demo/src/editor/plugins/codeout.scss
Normal file
3
packages/demo/src/editor/plugins/codeout.scss
Normal file
@ -0,0 +1,3 @@
|
||||
.lowcode-plugin-codeout {
|
||||
padding: 10px 4px;
|
||||
}
|
||||
85
packages/demo/src/editor/plugins/codeout.tsx
Normal file
85
packages/demo/src/editor/plugins/codeout.tsx
Normal file
@ -0,0 +1,85 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
import React from 'react';
|
||||
import { Button } from '@alifd/next';
|
||||
import { PluginProps, NpmInfo } from '@ali/lowcode-types';
|
||||
import { Designer } from '@ali/lowcode-designer';
|
||||
import streamSaver from 'streamsaver';
|
||||
|
||||
import './codeout.scss';
|
||||
|
||||
interface BasicSection {
|
||||
componentName: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
docUrl?: string;
|
||||
screenshot?: string;
|
||||
icon?: string;
|
||||
tags?: string[];
|
||||
devMode?: 'proCode' | 'lowCode';
|
||||
npm: NpmInfo;
|
||||
[k: string]: any;
|
||||
}
|
||||
|
||||
const CODEOUT_SERVICE_HOST = 'localhost:7002';
|
||||
|
||||
const Codeout = ({ editor }: PluginProps) => {
|
||||
const handleClick = () => {
|
||||
const designer = editor.get(Designer);
|
||||
if (designer) {
|
||||
const assets = editor.get('assets') as { components: BasicSection[] };
|
||||
const components = assets.components;
|
||||
|
||||
const componentsMap = components
|
||||
.filter((c) => !!c.npm)
|
||||
.map((c) => ({
|
||||
componentName: c.componentName,
|
||||
...(c.npm || {}),
|
||||
}));
|
||||
|
||||
const fullSchema = {
|
||||
config: {
|
||||
historyMode: 'hash',
|
||||
targetRootID: 'J_Container',
|
||||
},
|
||||
meta: {
|
||||
name: 'demoproject',
|
||||
},
|
||||
componentsMap,
|
||||
componentsTree: [designer.schema.componentsTree[designer.schema.componentsTree.length - 1]],
|
||||
};
|
||||
|
||||
console.info('codeout schema:', fullSchema);
|
||||
fetch(`http://${CODEOUT_SERVICE_HOST}/api/generate/project`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ schema: JSON.stringify(fullSchema) }),
|
||||
headers: new Headers({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
mode: 'cors',
|
||||
}).then((res) => {
|
||||
const fileStream = streamSaver.createWriteStream('demoProject.zip');
|
||||
if (res.body !== null) {
|
||||
res.body.pipeTo(fileStream).then(
|
||||
() => {
|
||||
console.log('success');
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="lowcode-plugin-codeout">
|
||||
<Button type="primary" onClick={handleClick}>
|
||||
出码
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Codeout;
|
||||
4
packages/demo/src/editor/plugins/saveload.scss
Normal file
4
packages/demo/src/editor/plugins/saveload.scss
Normal file
@ -0,0 +1,4 @@
|
||||
.lowcode-plugin-saveload {
|
||||
padding: 10px 4px;
|
||||
display: inline-block;
|
||||
}
|
||||
75
packages/demo/src/editor/plugins/saveload.tsx
Normal file
75
packages/demo/src/editor/plugins/saveload.tsx
Normal file
@ -0,0 +1,75 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
import React from 'react';
|
||||
import { Button } from '@alifd/next';
|
||||
import { PluginProps, NpmInfo } from '@ali/lowcode-types';
|
||||
import { Designer } from '@ali/lowcode-designer';
|
||||
|
||||
import './saveload.scss';
|
||||
|
||||
interface BasicSection {
|
||||
componentName: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
docUrl?: string;
|
||||
screenshot?: string;
|
||||
icon?: string;
|
||||
tags?: string[];
|
||||
devMode?: 'proCode' | 'lowCode';
|
||||
npm: NpmInfo;
|
||||
[k: string]: any;
|
||||
}
|
||||
|
||||
const Codeout = ({ editor }: PluginProps) => {
|
||||
const handleSaveClick = () => {
|
||||
|
||||
debugger;
|
||||
|
||||
let schema = editor.get('designer').project.getSchema();
|
||||
console.log(schema);
|
||||
|
||||
|
||||
// const designer = editor.get(Designer);
|
||||
// if (designer) {
|
||||
// const schema = designer.schema.componentsTree[designer.schema.componentsTree.length - 1]; // editor.get('schema');
|
||||
// const schemaStr = JSON.stringify(schema);
|
||||
// window.localStorage.setItem('schema_data', schemaStr);
|
||||
// console.info('save schema:', schemaStr);
|
||||
// alert('保存成功');
|
||||
// }
|
||||
};
|
||||
|
||||
const handleLoadClick = () => {
|
||||
const designer = editor.get(Designer);
|
||||
if (designer) {
|
||||
const tmp = window.localStorage.getItem('schema_data');
|
||||
if (tmp) {
|
||||
try {
|
||||
const schema = JSON.parse(tmp);
|
||||
editor.set('schema', schema);
|
||||
console.info('load schema:', schema);
|
||||
alert('加载成功');
|
||||
} catch (error) {
|
||||
console.log('Invalid Schema', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="lowcode-plugin-saveload">
|
||||
<Button type="primary" onClick={handleSaveClick}>
|
||||
保存
|
||||
</Button>
|
||||
</div>
|
||||
<div className="lowcode-plugin-saveload">
|
||||
<Button type="primary" onClick={handleLoadClick}>
|
||||
加载
|
||||
</Button>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export default Codeout;
|
||||
@ -1 +1,2 @@
|
||||
import './vision';
|
||||
// import './vision';
|
||||
import './editor';
|
||||
|
||||
@ -14,14 +14,13 @@ import ActionPane from '@ali/ve-action-pane';
|
||||
import SourceEditor from '@ali/lowcode-plugin-source-editor';
|
||||
import fetchContext from '@ali/vu-legao-design-fetch-context';
|
||||
import EventBindDialog from '@ali/lowcode-plugin-event-bind-dialog';
|
||||
import loadUrls from './loader';
|
||||
import { upgradeAssetsBundle } from './upgrade-assets';
|
||||
import { isCSSUrl } from '@ali/lowcode-utils';
|
||||
import VariableSetter from '@ali/vs-variable-setter';
|
||||
import _isArray from "lodash/isArray";
|
||||
import _isObject from "lodash/isObject";
|
||||
import _get from 'lodash/get';
|
||||
import funcParser from '@ali/vu-function-parser';
|
||||
|
||||
import {
|
||||
NumberSetter,
|
||||
BoolSetter,
|
||||
@ -39,6 +38,13 @@ import {
|
||||
ActionSetter,
|
||||
} from '@ali/visualengine-utils';
|
||||
|
||||
import PropType from 'prop-types';
|
||||
|
||||
import loadUrls from './loader';
|
||||
import { upgradeAssetsBundle } from './upgrade-assets';
|
||||
|
||||
console.log(PropType);
|
||||
|
||||
const { editor, skeleton, context, HOOKS, Trunk } = Engine;
|
||||
|
||||
Trunk.registerSetter('Input', TextSetter);
|
||||
@ -102,8 +108,8 @@ context.use(HOOKS.VE_SETTING_FIELD_VARIABLE_SETTER, VariableSetter);
|
||||
const externals = ['react', 'react-dom', 'prop-types', 'react-router', 'react-router-dom', '@ali/recore'];
|
||||
|
||||
async function loadAssets() {
|
||||
const legaoAssets = await editor.utils.get('./raxAssets.json');
|
||||
// const legaoAssets = await editor.utils.get('./legao-assets.json');
|
||||
// const legaoAssets = await editor.utils.get('./raxAssets.json');
|
||||
const legaoAssets = await editor.utils.get('./legao-assets.json');
|
||||
|
||||
const assets = upgradeAssetsBundle(legaoAssets);
|
||||
|
||||
@ -145,11 +151,11 @@ async function loadAssets() {
|
||||
}
|
||||
|
||||
async function loadSchema() {
|
||||
const schema = await editor.utils.get('./rax.json');
|
||||
// const schema = await editor.utils.get('./schema.json');
|
||||
// const schema = await editor.utils.get('./rax.json');
|
||||
const schema = await editor.utils.get('./vision-schema.json');
|
||||
editor.set('schema', schema);
|
||||
editor.set('renderEnv', 'rax');
|
||||
editor.set('clientTypes', ['mobile']);
|
||||
// editor.set('renderEnv', 'rax');
|
||||
// editor.set('clientTypes', ['mobile']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,35 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="1.0.7-0"></a>
|
||||
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@1.0.6-0...@ali/lowcode-designer@1.0.7-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-designer
|
||||
|
||||
<a name="1.0.6-0"></a>
|
||||
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.52...@ali/lowcode-designer@1.0.6-0) (2020-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
|
||||
* 兼容modal模式 ([1092ee9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1092ee9))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 🎸 支持设置模拟器的 viewport 的宽高和缩放级别 ([3a54241](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/3a54241))
|
||||
* 新增simulatorurl,可以设置cdn使用simulator ([1f45b05](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1f45b05))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.0.5-0"></a>
|
||||
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@1.0.4-0...@ali/lowcode-designer@1.0.5-0) (2020-08-20)
|
||||
|
||||
<a name="0.9.52"></a>
|
||||
## [0.9.52](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.51...@ali/lowcode-designer@0.9.52) (2020-08-27)
|
||||
|
||||
@ -51,6 +80,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
<a name="0.9.48"></a>
|
||||
## [0.9.48](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.47...@ali/lowcode-designer@0.9.48) (2020-08-20)
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
|
||||
@ -75,38 +105,31 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
### Bug Fixes
|
||||
|
||||
* support dropObject is data ([809fda7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/809fda7))
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.9.45"></a>
|
||||
## [0.9.45](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.44...@ali/lowcode-designer@0.9.45) (2020-08-19)
|
||||
**Note:** Version bump only for package @ali/lowcode-designer
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **designer/node.ts:** fix hasLoop logic ([99a7288](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99a7288))
|
||||
* currentPage.id 返回 formUuid ([775725d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/775725d))
|
||||
* 优化画布中点击事件屏蔽,增加富文本组件的部分屏蔽 ([ec08c6c](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ec08c6c))
|
||||
* 优化画布中点击事件屏蔽,增加富文本组件的部分屏蔽 ([a5b6557](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a5b6557))
|
||||
* 区块组件无法删除 ([d936d2b](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/d936d2b))
|
||||
<a name="0.12.0"></a>
|
||||
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.11.0...@ali/lowcode-designer@0.12.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.9.44"></a>
|
||||
## [0.9.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.43...@ali/lowcode-designer@0.9.44) (2020-08-17)
|
||||
**Note:** Version bump only for package @ali/lowcode-designer
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fieldId 重复 ([5d64312](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/5d64312))
|
||||
* 去掉根据 componentName 判断 isModal 的逻辑 ([28f0213](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/28f0213))
|
||||
* 页面加载之后就被标记位 isModified ([2840d27](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2840d27))
|
||||
<a name="0.11.0"></a>
|
||||
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.10.0...@ali/lowcode-designer@0.11.0) (2020-08-16)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-designer
|
||||
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.37...@ali/lowcode-designer@0.10.0) (2020-08-14)
|
||||
<a name="0.9.43"></a>
|
||||
## [0.9.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.42...@ali/lowcode-designer@0.9.43) (2020-08-14)
|
||||
|
||||
@ -176,11 +199,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
<a name="0.9.38"></a>
|
||||
## [0.9.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-designer@0.9.37...@ali/lowcode-designer@0.9.38) (2020-08-06)
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复 preset-vision 版本 lifeCycles 丢失以及 slot 初始化问题 ([7cf6d24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7cf6d24))
|
||||
* 兼容modal模式 ([1092ee9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1092ee9))
|
||||
|
||||
|
||||
|
||||
@ -669,12 +693,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
### Features
|
||||
|
||||
<<<<<<< HEAD
|
||||
* 🎸 merge material-parser ([b40c286](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b40c286))
|
||||
* history log ([fbb3577](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fbb3577))
|
||||
* import react-docgen to parse propTypes ([6e66168](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6e66168))
|
||||
=======
|
||||
* 🎸 merge material-parser ([b40c286](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b40c2869a0bc901d855279735fe86b84dabaa04d))
|
||||
* history log ([fbb3577](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fbb3577bd434c0ac77cc907abc36e3efe110fe8c))
|
||||
* import react-docgen to parse propTypes ([6e66168](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6e661686e4693e69279c496f3be1dd173703c55e))
|
||||
>>>>>>> df955e1db90ff104cd11160def80113cfd6faccc
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ali/lowcode-designer",
|
||||
"version": "0.9.52",
|
||||
"version": "1.0.7-0",
|
||||
"description": "Designer for Ali LowCode Engine",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
@ -15,9 +15,9 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ali/lowcode-editor-core": "^0.8.34",
|
||||
"@ali/lowcode-types": "^0.8.17",
|
||||
"@ali/lowcode-utils": "^0.8.20",
|
||||
"@ali/lowcode-editor-core": "^1.0.7-0",
|
||||
"@ali/lowcode-types": "^1.0.7-0",
|
||||
"@ali/lowcode-utils": "^1.0.7-0",
|
||||
"classnames": "^2.2.6",
|
||||
"event": "^1.0.0",
|
||||
"react": "^16",
|
||||
|
||||
@ -60,7 +60,7 @@ class Canvas extends Component<{ host: BuiltinSimulatorHost }> {
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<div ref={elmt => sim.mountViewport(elmt)} className="lc-simulator-canvas-viewport">
|
||||
<div ref={(elmt) => sim.mountViewport(elmt)} className="lc-simulator-canvas-viewport">
|
||||
<BemTools host={sim} />
|
||||
<Content host={sim} />
|
||||
</div>
|
||||
@ -74,18 +74,19 @@ class Content extends Component<{ host: BuiltinSimulatorHost }> {
|
||||
render() {
|
||||
const sim = this.props.host;
|
||||
const viewport = sim.viewport;
|
||||
let frameStyle = {};
|
||||
if (viewport.scale < 1) {
|
||||
frameStyle = {
|
||||
transform: `scale(${viewport.scale})`,
|
||||
height: viewport.contentHeight,
|
||||
width: viewport.contentWidth,
|
||||
};
|
||||
}
|
||||
const frameStyle = {
|
||||
transform: `scale(${viewport.scale})`,
|
||||
height: viewport.contentHeight,
|
||||
width: viewport.contentWidth,
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="lc-simulator-content">
|
||||
<iframe className="lc-simulator-content-frame" style={frameStyle} ref={frame => sim.mountContentFrame(frame)} />
|
||||
<iframe
|
||||
className="lc-simulator-content-frame"
|
||||
style={frameStyle}
|
||||
ref={(frame) => sim.mountContentFrame(frame)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
const vendors = [
|
||||
// required & use once
|
||||
assetBundle(
|
||||
this.get('environment') || this.renderEnv === 'rax' ? defaultRaxEnvironment : defaultEnvironment,
|
||||
this.get('environment') || (this.renderEnv === 'rax' ? defaultRaxEnvironment : defaultEnvironment),
|
||||
AssetLevel.Environment,
|
||||
),
|
||||
// required & use once
|
||||
@ -236,7 +236,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
assetBundle(this.theme, AssetLevel.Theme),
|
||||
// required & use once
|
||||
assetBundle(
|
||||
this.get('simulatorUrl') || this.renderEnv === 'rax' ? defaultRaxSimulatorUrl : defaultSimulatorUrl,
|
||||
this.get('simulatorUrl') || (this.renderEnv === 'rax' ? defaultRaxSimulatorUrl : defaultSimulatorUrl),
|
||||
AssetLevel.Runtime,
|
||||
),
|
||||
];
|
||||
@ -465,9 +465,10 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
}
|
||||
const node = nodeInst.node || this.document.rootNode;
|
||||
|
||||
const rootElement = this.findDOMNodes(nodeInst.instance, node.componentMeta.rootSelector)?.find((item) =>
|
||||
// 可能是 [null];
|
||||
item && item.contains(targetElement),
|
||||
const rootElement = this.findDOMNodes(nodeInst.instance, node.componentMeta.rootSelector)?.find(
|
||||
(item) =>
|
||||
// 可能是 [null];
|
||||
item && item.contains(targetElement),
|
||||
) as HTMLElement;
|
||||
if (!rootElement) {
|
||||
return;
|
||||
@ -830,7 +831,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
|
||||
// fix target : 浏览器事件响应目标
|
||||
if (!e.target || notMyEvent) {
|
||||
e.target = this.contentDocument!.elementFromPoint(e.canvasX!, e.canvasY!);
|
||||
e.target = this.contentDocument?.elementFromPoint(e.canvasX!, e.canvasY!);
|
||||
}
|
||||
|
||||
// documentModel : 目标文档
|
||||
@ -877,7 +878,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
if (nodes && (!operationalNodes || operationalNodes.length === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.sensing = true;
|
||||
this.scroller.scrolling(e);
|
||||
const dropContainer = this.getDropContainer(e);
|
||||
@ -919,7 +920,13 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
event: e,
|
||||
};
|
||||
|
||||
if (dragObject.type === 'node' && nodes && operationalNodes[0]?.getPrototype()?.isModal()) {
|
||||
// if (e.dragObject.type === 'node' && e.dragObject.nodes[0]?.getPrototype()?.isModal()) {
|
||||
if (
|
||||
e.dragObject &&
|
||||
e.dragObject.nodes &&
|
||||
e.dragObject.nodes.length &&
|
||||
e.dragObject.nodes[0].getPrototype()?.isModal()
|
||||
) {
|
||||
return this.designer.createLocation({
|
||||
target: this.document.rootNode,
|
||||
detail: {
|
||||
|
||||
@ -22,8 +22,8 @@ export default class Viewport implements IViewport {
|
||||
return new DOMRect(0, 0, bounds.width / scale, bounds.height / scale);
|
||||
}
|
||||
|
||||
private viewportElement?: Element;
|
||||
mount(viewportElement: Element | null) {
|
||||
private viewportElement?: HTMLElement;
|
||||
mount(viewportElement: HTMLElement | null) {
|
||||
if (!viewportElement || this.viewportElement === viewportElement) {
|
||||
return;
|
||||
}
|
||||
@ -43,6 +43,15 @@ export default class Viewport implements IViewport {
|
||||
}
|
||||
return this.rect.height;
|
||||
}
|
||||
|
||||
set height(newHeight: number) {
|
||||
this._contentHeight = newHeight / this.scale;
|
||||
if (this.viewportElement) {
|
||||
this.viewportElement.style.height = `${newHeight}px`;
|
||||
this.touch();
|
||||
}
|
||||
}
|
||||
|
||||
@computed get width(): number {
|
||||
if (!this.rect) {
|
||||
return 1000;
|
||||
@ -50,29 +59,45 @@ export default class Viewport implements IViewport {
|
||||
return this.rect.width;
|
||||
}
|
||||
|
||||
set width(newWidth: number) {
|
||||
this._contentWidth = newWidth / this.scale;
|
||||
if (this.viewportElement) {
|
||||
this.viewportElement.style.width = `${newWidth}px`;
|
||||
this.touch();
|
||||
}
|
||||
}
|
||||
|
||||
@obx.ref private _scale: number = 1;
|
||||
|
||||
/**
|
||||
* 缩放比例
|
||||
*/
|
||||
@computed get scale(): number {
|
||||
if (!this.rect || this.contentWidth === AutoFit) {
|
||||
return 1;
|
||||
return this._scale;
|
||||
}
|
||||
|
||||
set scale(newScale: number) {
|
||||
if (isNaN(newScale) || newScale <= 0) {
|
||||
throw new Error(`invalid new scale "${newScale}"`);
|
||||
}
|
||||
return this.width / this.contentWidth;
|
||||
|
||||
this._scale = newScale;
|
||||
this._contentWidth = this.width / this.scale;
|
||||
this._contentHeight = this.height / this.scale;
|
||||
}
|
||||
|
||||
@obx.ref private _contentWidth: number | AutoFit = AutoFit;
|
||||
@obx.ref private _contentHeight: number | AutoFit = AutoFit;
|
||||
|
||||
@computed get contentHeight(): number | AutoFit {
|
||||
if (!this.rect || this.scale === 1) {
|
||||
return AutoFit;
|
||||
}
|
||||
return this.height / this.scale;
|
||||
return this._contentHeight;
|
||||
}
|
||||
|
||||
set contentHeight(newContentHeight: number | AutoFit) {
|
||||
this._contentHeight = newContentHeight;
|
||||
}
|
||||
|
||||
@computed get contentWidth(): number | AutoFit {
|
||||
if (!this.rect || (this._contentWidth !== AutoFit && this._contentWidth <= this.width)) {
|
||||
return AutoFit;
|
||||
}
|
||||
return this._contentWidth;
|
||||
}
|
||||
|
||||
|
||||
@ -160,8 +160,8 @@ export class ComponentMeta {
|
||||
const liveTextEditing = this._transformedMetadata.experimental?.liveTextEditing || [];
|
||||
|
||||
function collectLiveTextEditing(items: FieldConfig[]) {
|
||||
items.forEach(config => {
|
||||
if (config.items) {
|
||||
items.forEach((config) => {
|
||||
if (config?.items) {
|
||||
collectLiveTextEditing(config.items);
|
||||
} else {
|
||||
const liveConfig = config.liveTextEditing || config.extraProps?.liveTextEditing;
|
||||
@ -277,7 +277,6 @@ function preprocessMetadata(metadata: ComponentMetadata): TransformedComponentMe
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export interface MetadataTransducer {
|
||||
(prev: TransformedComponentMetadata): TransformedComponentMetadata;
|
||||
/**
|
||||
@ -293,7 +292,7 @@ export interface MetadataTransducer {
|
||||
}
|
||||
const metadataTransducers: MetadataTransducer[] = [];
|
||||
|
||||
export function registerMetadataTransducer(transducer: MetadataTransducer, level: number = 100, id?: string) {
|
||||
export function registerMetadataTransducer(transducer: MetadataTransducer, level = 100, id?: string) {
|
||||
transducer.level = level;
|
||||
transducer.id = id;
|
||||
const i = metadataTransducers.findIndex((item) => item.level != null && item.level > level);
|
||||
@ -308,7 +307,6 @@ export function getRegisteredMetadataTransducers(): MetadataTransducer[] {
|
||||
return metadataTransducers;
|
||||
}
|
||||
|
||||
|
||||
registerMetadataTransducer((metadata) => {
|
||||
const { configure, componentName } = metadata;
|
||||
const { component = {} } = configure;
|
||||
|
||||
@ -437,7 +437,7 @@ export class Designer {
|
||||
designer._componentMetasMap.forEach((config, key) => {
|
||||
const metaData = config.getMetadata();
|
||||
if (metaData.devMode === 'lowcode') {
|
||||
maps[key] = metaData.schema;
|
||||
maps[key] = this.currentDocument?.simulator?.createComponent(metaData.schema!);
|
||||
} else {
|
||||
const view = metaData.experimental?.view;
|
||||
if (view) {
|
||||
|
||||
@ -9,10 +9,13 @@ function getHotterFromSetter(setter) {
|
||||
}
|
||||
|
||||
function getTransducerFromSetter(setter) {
|
||||
return setter && (
|
||||
setter.transducer || setter.Transducer
|
||||
|| (setter.type && (setter.type.transducer || setter.type.Transducer))
|
||||
) || null; // eslint-disable-line
|
||||
return (
|
||||
(setter &&
|
||||
(setter.transducer ||
|
||||
setter.Transducer ||
|
||||
(setter.type && (setter.type.transducer || setter.type.Transducer)))) ||
|
||||
null
|
||||
); // eslint-disable-line
|
||||
}
|
||||
|
||||
function combineTransducer(transducer, arr, context) {
|
||||
@ -39,7 +42,7 @@ export class Transducer {
|
||||
} else if (isValidElement(setter) && setter.type.displayName === 'MixedSetter') {
|
||||
setter = setter.props?.setters?.[0];
|
||||
} else if (typeof setter === 'object' && setter.componentName === 'MixedSetter') {
|
||||
setter = setter.props?.setters?.[0];
|
||||
setter = setter && setter.props && setter.props.setters && Array.isArray(setter.props.setters) && setter.props.setters[0];
|
||||
}
|
||||
|
||||
if (isSetterConfig(setter)) {
|
||||
@ -49,11 +52,7 @@ export class Transducer {
|
||||
setter = getSetter(setter)?.component;
|
||||
}
|
||||
|
||||
this.setterTransducer = combineTransducer(
|
||||
getTransducerFromSetter(setter),
|
||||
getHotterFromSetter(setter),
|
||||
context,
|
||||
);
|
||||
this.setterTransducer = combineTransducer(getTransducerFromSetter(setter), getHotterFromSetter(setter), context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { computed, obx } from '@ali/lowcode-editor-core';
|
||||
import { NodeData, isJSExpression, isDOMText, NodeSchema, isNodeSchema, RootSchema } from '@ali/lowcode-types';
|
||||
import { NodeData, isJSExpression, isDOMText, NodeSchema, isNodeSchema, RootSchema, PageSchema } from '@ali/lowcode-types';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Project } from '../project';
|
||||
import { ISimulatorHost } from '../simulator';
|
||||
@ -659,3 +659,7 @@ export class DocumentModel {
|
||||
export function isDocumentModel(obj: any): obj is DocumentModel {
|
||||
return obj && obj.rootNode;
|
||||
}
|
||||
|
||||
export function isPageSchema(obj: any): obj is PageSchema {
|
||||
return obj?.componentName === 'Page';
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { obx, computed } from '@ali/lowcode-editor-core';
|
||||
import { Designer } from '../designer';
|
||||
import { DocumentModel, isDocumentModel } from '../document';
|
||||
import { DocumentModel, isDocumentModel, isPageSchema } from '../document';
|
||||
import { ProjectSchema, RootSchema } from '@ali/lowcode-types';
|
||||
|
||||
export class Project {
|
||||
@ -138,6 +138,11 @@ export class Project {
|
||||
|
||||
if (isDocumentModel(doc)) {
|
||||
return doc.open();
|
||||
} else if (isPageSchema(doc)) {
|
||||
const foundDoc = this.documents.find(curDoc => curDoc?.rootNode?.id && curDoc?.rootNode?.id === doc?.id);
|
||||
if (foundDoc) {
|
||||
foundDoc.remove();
|
||||
}
|
||||
}
|
||||
|
||||
doc = new DocumentModel(this, doc);
|
||||
|
||||
@ -3,6 +3,29 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="1.0.7-0"></a>
|
||||
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.6-0...@ali/lowcode-editor-core@1.0.7-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="1.0.6-0"></a>
|
||||
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.34...@ali/lowcode-editor-core@1.0.6-0) (2020-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
|
||||
* 清理代码依赖及版本 ([0b15d30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0b15d30))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.0.5-0"></a>
|
||||
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.4-0...@ali/lowcode-editor-core@1.0.5-0) (2020-08-20)
|
||||
|
||||
<a name="0.8.34"></a>
|
||||
## [0.8.34](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.33...@ali/lowcode-editor-core@0.8.34) (2020-08-27)
|
||||
|
||||
@ -22,24 +45,93 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
|
||||
|
||||
>>>>>>> master
|
||||
<a name="0.8.32"></a>
|
||||
## [0.8.32](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.30...@ali/lowcode-editor-core@0.8.32) (2020-08-20)
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="1.0.4-0"></a>
|
||||
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.3-0...@ali/lowcode-editor-core@1.0.4-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="1.0.3-0"></a>
|
||||
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.2-0...@ali/lowcode-editor-core@1.0.3-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="1.0.2-0"></a>
|
||||
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@1.0.1-0...@ali/lowcode-editor-core@1.0.2-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="1.0.1-0"></a>
|
||||
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.30...@ali/lowcode-editor-core@1.0.1-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.13.0...@ali/lowcode-editor-core@1.0.0) (2020-08-17)
|
||||
<a name="0.8.30"></a>
|
||||
## [0.8.30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.29...@ali/lowcode-editor-core@0.8.30) (2020-08-19)
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="0.8.29"></a>
|
||||
## [0.8.29](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.28...@ali/lowcode-editor-core@0.8.29) (2020-08-17)
|
||||
<a name="0.13.0"></a>
|
||||
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.12.0...@ali/lowcode-editor-core@0.13.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="0.12.0"></a>
|
||||
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.10.0...@ali/lowcode-editor-core@0.12.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="0.11.0"></a>
|
||||
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.10.0...@ali/lowcode-editor-core@0.11.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.9.0...@ali/lowcode-editor-core@0.10.0) (2020-08-16)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-core
|
||||
|
||||
<a name="0.9.0"></a>
|
||||
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-core@0.8.28...@ali/lowcode-editor-core@0.9.0) (2020-08-14)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ali/lowcode-editor-core",
|
||||
"version": "0.8.34",
|
||||
"version": "1.0.7-0",
|
||||
"description": "Core Api for Ali lowCode engine",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
@ -15,14 +15,14 @@
|
||||
"cloud-build": "build-scripts build --skip-demo"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ali/lowcode-types": "^0.8.17",
|
||||
"@ali/lowcode-utils": "^0.8.20",
|
||||
"@ali/lowcode-types": "^1.0.7-0",
|
||||
"@ali/lowcode-utils": "^1.0.7-0",
|
||||
"@alifd/next": "^1.19.16",
|
||||
"@recore/obx": "^1.0.9",
|
||||
"@recore/obx-react": "^1.0.8",
|
||||
"classnames": "^2.2.6",
|
||||
"debug": "^4.1.1",
|
||||
"intl-messageformat": "^8.3.1",
|
||||
"intl-messageformat": "^9.3.1",
|
||||
"power-di": "^2.2.4",
|
||||
"react": "^16",
|
||||
"react-dom": "^16.7.0",
|
||||
|
||||
@ -6,6 +6,11 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 4px;
|
||||
img {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
filter: brightness(0) invert(1)
|
||||
}
|
||||
}
|
||||
&.only-icon {
|
||||
.lc-title-icon {
|
||||
|
||||
@ -3,6 +3,28 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="1.0.7-0"></a>
|
||||
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.6-0...@ali/lowcode-editor-preset-general@1.0.7-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
|
||||
<a name="1.0.6-0"></a>
|
||||
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.37...@ali/lowcode-editor-preset-general@1.0.6-0) (2020-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.0.5-0"></a>
|
||||
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.4-0...@ali/lowcode-editor-preset-general@1.0.5-0) (2020-08-20)
|
||||
|
||||
<a name="0.9.37"></a>
|
||||
## [0.9.37](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.36...@ali/lowcode-editor-preset-general@0.9.37) (2020-08-27)
|
||||
|
||||
@ -35,14 +57,50 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
|
||||
>>>>>>> master
|
||||
<a name="0.9.33"></a>
|
||||
## [0.9.33](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.32...@ali/lowcode-editor-preset-general@0.9.33) (2020-08-20)
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
|
||||
<a name="1.0.4-0"></a>
|
||||
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.3-0...@ali/lowcode-editor-preset-general@1.0.4-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
|
||||
<a name="1.0.3-0"></a>
|
||||
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.2-0...@ali/lowcode-editor-preset-general@1.0.3-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
|
||||
<a name="1.0.2-0"></a>
|
||||
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@1.0.1-0...@ali/lowcode-editor-preset-general@1.0.2-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
|
||||
<a name="1.0.1-0"></a>
|
||||
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.32...@ali/lowcode-editor-preset-general@1.0.1-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.14.0...@ali/lowcode-editor-preset-general-beta@1.0.0) (2020-08-17)
|
||||
<a name="0.9.32"></a>
|
||||
## [0.9.32](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.31...@ali/lowcode-editor-preset-general@0.9.32) (2020-08-19)
|
||||
|
||||
@ -78,48 +136,50 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
|
||||
>>>>>>> master
|
||||
<a name="0.9.28"></a>
|
||||
## [0.9.28](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.27...@ali/lowcode-editor-preset-general@0.9.28) (2020-08-14)
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
|
||||
|
||||
<a name="0.9.27"></a>
|
||||
## [0.9.27](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.26...@ali/lowcode-editor-preset-general@0.9.27) (2020-08-14)
|
||||
<a name="0.14.0"></a>
|
||||
# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.13.0...@ali/lowcode-editor-preset-general-beta@0.14.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
|
||||
|
||||
<a name="0.9.26"></a>
|
||||
## [0.9.26](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.25...@ali/lowcode-editor-preset-general@0.9.26) (2020-08-07)
|
||||
<a name="0.13.0"></a>
|
||||
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.11.0...@ali/lowcode-editor-preset-general-beta@0.13.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
|
||||
|
||||
<a name="0.9.25"></a>
|
||||
## [0.9.25](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.24...@ali/lowcode-editor-preset-general@0.9.25) (2020-08-06)
|
||||
<a name="0.12.0"></a>
|
||||
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general-beta@0.11.0...@ali/lowcode-editor-preset-general-beta@0.12.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
|
||||
|
||||
<a name="0.9.24"></a>
|
||||
## [0.9.24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.23...@ali/lowcode-editor-preset-general@0.9.24) (2020-08-06)
|
||||
<a name="0.11.0"></a>
|
||||
# 0.11.0 (2020-08-16)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-general-beta
|
||||
|
||||
<a name="0.9.23"></a>
|
||||
## [0.9.23](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.22...@ali/lowcode-editor-preset-general@0.9.23) (2020-08-06)
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-general@0.9.22...@ali/lowcode-editor-preset-general@0.10.0) (2020-08-14)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "@ali/lowcode-editor-preset-general",
|
||||
"version": "0.9.37",
|
||||
"private": true,
|
||||
"version": "1.0.7-0",
|
||||
"description": "Ali General Editor Preset",
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
@ -15,12 +14,12 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ali/lowcode-editor-core": "^0.8.34",
|
||||
"@ali/lowcode-editor-skeleton": "^0.8.58",
|
||||
"@ali/lowcode-plugin-designer": "^0.9.52",
|
||||
"@ali/lowcode-plugin-outline-pane": "^0.8.58",
|
||||
"@ali/lowcode-types": "^0.8.17",
|
||||
"@ali/lowcode-utils": "^0.8.20",
|
||||
"@ali/lowcode-editor-core": "^1.0.7-0",
|
||||
"@ali/lowcode-editor-skeleton": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-designer": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-outline-pane": "^1.0.7-0",
|
||||
"@ali/lowcode-types": "^1.0.7-0",
|
||||
"@ali/lowcode-utils": "^1.0.7-0",
|
||||
"@alifd/next": "^1.19.12",
|
||||
"@alife/theme-lowcode-dark": "^0.1.0",
|
||||
"@alife/theme-lowcode-light": "^0.1.0",
|
||||
@ -28,7 +27,7 @@
|
||||
"react-dom": "^16.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ali/lowcode-editor-setters": "^0.9.19",
|
||||
"@ali/lowcode-editor-setters": "^1.0.7-0",
|
||||
"@alib/build-scripts": "^0.1.18",
|
||||
"@types/events": "^3.0.0",
|
||||
"@types/react": "^16.8.3",
|
||||
|
||||
@ -2,10 +2,11 @@ import { render } from 'react-dom';
|
||||
import { createElement } from 'react';
|
||||
import { Workbench, Skeleton, SettingsPrimaryPane, registerDefaults } from '@ali/lowcode-editor-skeleton';
|
||||
import { globalContext, Editor } from '@ali/lowcode-editor-core';
|
||||
import { Designer } from '@ali/lowcode-designer';
|
||||
import { Designer, LiveEditing, TransformStage, Node } from '@ali/lowcode-designer';
|
||||
import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-outline-pane';
|
||||
import DesignerPlugin from '@ali/lowcode-plugin-designer';
|
||||
import '@ali/lowcode-editor-setters';
|
||||
import { liveEditingRule, liveEditingSaveHander } from './live-editing';
|
||||
|
||||
export * from '@ali/lowcode-types';
|
||||
export * from '@ali/lowcode-utils';
|
||||
@ -31,15 +32,6 @@ skeleton.add({
|
||||
type: 'Widget',
|
||||
content: DesignerPlugin,
|
||||
});
|
||||
skeleton.add({
|
||||
area: 'leftArea',
|
||||
name: 'outlinePane',
|
||||
type: 'PanelDock',
|
||||
content: Outline,
|
||||
panelProps: {
|
||||
area: 'leftFixedArea',
|
||||
},
|
||||
});
|
||||
skeleton.add({
|
||||
area: 'rightArea',
|
||||
name: 'settingsPane',
|
||||
@ -53,7 +45,7 @@ skeleton.add({
|
||||
props: {
|
||||
condition: () => {
|
||||
return designer.dragon.dragging && !getTreeMaster(designer).hasVisibleTreeBoard();
|
||||
}
|
||||
},
|
||||
},
|
||||
content: OutlineBackupPane,
|
||||
});
|
||||
@ -77,14 +69,10 @@ export function init(container?: Element) {
|
||||
}
|
||||
container.id = 'lowcodeEditorPresetGeneral';
|
||||
|
||||
render(
|
||||
createElement(GeneralWorkbench),
|
||||
container,
|
||||
);
|
||||
render(createElement(GeneralWorkbench), container);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`%cLowcodeEngine %cv${version}`,
|
||||
"color:#000;font-weight:bold;",
|
||||
"color:green;font-weight:bold;"
|
||||
);
|
||||
console.log(`%cLowcodeEngine %cv${version}`, 'color:#000;font-weight:bold;', 'color:green;font-weight:bold;');
|
||||
|
||||
LiveEditing.addLiveEditingSpecificRule(liveEditingRule);
|
||||
LiveEditing.addLiveEditingSaveHandler(liveEditingSaveHander);
|
||||
|
||||
80
packages/editor-preset-general/src/live-editing.ts
Normal file
80
packages/editor-preset-general/src/live-editing.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import { EditingTarget, Node as DocNode, SaveHandler } from '@ali/lowcode-designer';
|
||||
import { isJSExpression } from '@ali/lowcode-types';
|
||||
|
||||
function getText(node: DocNode, prop: string) {
|
||||
const p = node.getProp(prop, false);
|
||||
if (!p || p.isUnset()) {
|
||||
return null;
|
||||
}
|
||||
let v = p.getValue();
|
||||
if (isJSExpression(v)) {
|
||||
v = v.mock;
|
||||
}
|
||||
if (v == null) {
|
||||
return null;
|
||||
}
|
||||
if (p.type === 'literal') {
|
||||
return v;
|
||||
}
|
||||
return Symbol.for('not-literal');
|
||||
}
|
||||
|
||||
export function liveEditingRule(target: EditingTarget) {
|
||||
// for vision components specific
|
||||
const { node, rootElement, event } = target;
|
||||
|
||||
const targetElement = event.target as HTMLElement;
|
||||
|
||||
if (!Array.from(targetElement.childNodes).every(item => item.nodeType === Node.TEXT_NODE)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const innerText = targetElement.innerText;
|
||||
const propTarget = ['title', 'label', 'text', 'content', 'children'].find(prop => {
|
||||
return equalText(getText(node, prop), innerText);
|
||||
});
|
||||
|
||||
if (propTarget) {
|
||||
return {
|
||||
propElement: targetElement,
|
||||
propTarget,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function equalText(v: any, innerText: string) {
|
||||
// TODO: enhance compare text logic
|
||||
if (typeof v !== 'string') {
|
||||
return false;
|
||||
}
|
||||
return v.trim() === innerText
|
||||
}
|
||||
|
||||
export const liveEditingSaveHander: SaveHandler = {
|
||||
condition: (prop) => {
|
||||
const v = prop.getValue();
|
||||
return prop.type === 'expression'; // || isI18nData(v);
|
||||
},
|
||||
onSaveContent: (content, prop) => {
|
||||
const v = prop.getValue();
|
||||
let data = v;
|
||||
if (isJSExpression(v)) {
|
||||
data = v.mock;
|
||||
}
|
||||
data = content;
|
||||
if (isJSExpression(v)) {
|
||||
prop.setValue({
|
||||
type: 'JSExpression',
|
||||
value: v.value,
|
||||
mock: data,
|
||||
});
|
||||
} else {
|
||||
prop.setValue(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO:
|
||||
// 非文本编辑
|
||||
// 国际化数据,改变当前
|
||||
// JSExpression, 改变 mock 或 弹出绑定变量
|
||||
@ -3,6 +3,45 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="1.0.7-0"></a>
|
||||
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.6-0...@ali/lowcode-editor-preset-vision@1.0.7-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="1.0.6-0"></a>
|
||||
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.54...@ali/lowcode-editor-preset-vision@1.0.6-0) (2020-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
|
||||
* 用户在动态修改 prototype 时也需要重新计算 meta ([66c21c0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/66c21c0))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.0.5-0"></a>
|
||||
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.4-0...@ali/lowcode-editor-preset-vision@1.0.5-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="1.0.4-0"></a>
|
||||
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.3-0...@ali/lowcode-editor-preset-vision@1.0.4-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="1.0.3-0"></a>
|
||||
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.2-0...@ali/lowcode-editor-preset-vision@1.0.3-0) (2020-08-20)
|
||||
=======
|
||||
<a name="0.8.54"></a>
|
||||
## [0.8.54](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.53...@ali/lowcode-editor-preset-vision@0.8.54) (2020-08-27)
|
||||
|
||||
@ -26,25 +65,34 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
|
||||
|
||||
<a name="0.8.52"></a>
|
||||
## [0.8.52](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.51...@ali/lowcode-editor-preset-vision@0.8.52) (2020-08-24)
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="1.0.2-0"></a>
|
||||
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@1.0.1-0...@ali/lowcode-editor-preset-vision@1.0.2-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="0.8.51"></a>
|
||||
## [0.8.51](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.50...@ali/lowcode-editor-preset-vision@0.8.51) (2020-08-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fieldId 重置bug ([31215da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/31215da))
|
||||
<a name="1.0.1-0"></a>
|
||||
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.49...@ali/lowcode-editor-preset-vision@1.0.1-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.13.0...@ali/lowcode-editor-preset-vision@1.0.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="0.13.0"></a>
|
||||
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.12.0...@ali/lowcode-editor-preset-vision@0.13.0) (2020-08-17)
|
||||
<a name="0.8.50"></a>
|
||||
## [0.8.50](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.49...@ali/lowcode-editor-preset-vision@0.8.50) (2020-08-20)
|
||||
|
||||
@ -56,6 +104,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
|
||||
|
||||
>>>>>>> master
|
||||
<a name="0.8.49"></a>
|
||||
## [0.8.49](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.48...@ali/lowcode-editor-preset-vision@0.8.49) (2020-08-19)
|
||||
|
||||
@ -121,72 +170,44 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
<a name="0.8.44"></a>
|
||||
## [0.8.44](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.43...@ali/lowcode-editor-preset-vision@0.8.44) (2020-08-14)
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="0.8.43"></a>
|
||||
## [0.8.43](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.42...@ali/lowcode-editor-preset-vision@0.8.43) (2020-08-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* createComponent 支持所有 schema ([7f946f5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7f946f5))
|
||||
* upgradePropsReducer ([e68977f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e68977f))
|
||||
* vision 大包 window 指向问题 ([aa1b526](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/aa1b526))
|
||||
* 不对外暴露 Node ([05957ce](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/05957ce))
|
||||
* 支持 AC 组件 ([c287bad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/c287bad))
|
||||
<a name="0.12.0"></a>
|
||||
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.10.0...@ali/lowcode-editor-preset-vision@0.12.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.8.42"></a>
|
||||
## [0.8.42](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.41...@ali/lowcode-editor-preset-vision@0.8.42) (2020-08-07)
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* vision API 兼容 DockPane.getDocks() ([f72fb66](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f72fb66))
|
||||
<a name="0.11.0"></a>
|
||||
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.10.0...@ali/lowcode-editor-preset-vision@0.11.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.8.41"></a>
|
||||
## [0.8.41](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.40...@ali/lowcode-editor-preset-vision@0.8.41) (2020-08-06)
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fieldId 重复问题 ([e761b1a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/e761b1a))
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.9.0...@ali/lowcode-editor-preset-vision@0.10.0) (2020-08-16)
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.8.40"></a>
|
||||
## [0.8.40](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.39...@ali/lowcode-editor-preset-vision@0.8.40) (2020-08-06)
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 保存区块按钮渲染异常 ([33a7227](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/33a7227))
|
||||
* 增加兼容 API ([2960446](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/2960446))
|
||||
<a name="0.9.0"></a>
|
||||
# [0.9.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.38...@ali/lowcode-editor-preset-vision@0.9.0) (2020-08-14)
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.8.39"></a>
|
||||
## [0.8.39](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.38...@ali/lowcode-editor-preset-vision@0.8.39) (2020-08-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复 preset-vision 版本 lifeCycles 丢失以及 slot 初始化问题 ([7cf6d24](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7cf6d24))
|
||||
* 框架样式调整 ([58790c5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/58790c5))
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-preset-vision
|
||||
|
||||
<a name="0.8.38"></a>
|
||||
## [0.8.38](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-preset-vision@0.8.37...@ali/lowcode-editor-preset-vision@0.8.38) (2020-08-04)
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "@ali/lowcode-editor-preset-vision",
|
||||
"version": "0.8.54",
|
||||
"private": true,
|
||||
"version": "1.0.7-0",
|
||||
"description": "Vision Polyfill for Ali lowCode engine",
|
||||
"main": "lib/index.js",
|
||||
"private": true,
|
||||
"files": [
|
||||
"dist",
|
||||
"es",
|
||||
@ -15,11 +15,11 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ali/lowcode-designer": "^0.9.52",
|
||||
"@ali/lowcode-editor-core": "^0.8.34",
|
||||
"@ali/lowcode-editor-skeleton": "^0.8.58",
|
||||
"@ali/lowcode-plugin-designer": "^0.9.52",
|
||||
"@ali/lowcode-plugin-outline-pane": "^0.8.58",
|
||||
"@ali/lowcode-designer": "^1.0.7-0",
|
||||
"@ali/lowcode-editor-core": "^1.0.7-0",
|
||||
"@ali/lowcode-editor-skeleton": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-designer": "^1.0.7-0",
|
||||
"@ali/lowcode-plugin-outline-pane": "^1.0.7-0",
|
||||
"@ali/ve-i18n-util": "^2.0.0",
|
||||
"@ali/ve-icons": "^4.1.9",
|
||||
"@ali/ve-less-variables": "2.0.3",
|
||||
|
||||
@ -197,13 +197,13 @@ function compatiableReducer(props: any) {
|
||||
};
|
||||
}
|
||||
// 为了能降级到老版本,建议在后期版本去掉以下代码
|
||||
if (isJSExpression(props) && !props.events) {
|
||||
return {
|
||||
type: 'variable',
|
||||
value: props.mock,
|
||||
variable: props.value,
|
||||
}
|
||||
}
|
||||
// if (isJSExpression(props) && !props.events) {
|
||||
// return {
|
||||
// type: 'variable',
|
||||
// value: props.mock,
|
||||
// variable: props.value,
|
||||
// }
|
||||
// }
|
||||
const newProps: any = {};
|
||||
Object.entries<any>(props).forEach(([key, val]) => {
|
||||
newProps[key] = compatiableReducer(val);
|
||||
|
||||
@ -41,19 +41,21 @@ const pages = Object.assign(project, {
|
||||
if (componentsTree[0]) {
|
||||
componentsTree[0].componentName = componentsTree[0].componentName || 'Page';
|
||||
// FIXME
|
||||
if (componentsTree[0].componentName === 'Page' ||
|
||||
componentsTree[0].componentName === 'Component') {
|
||||
if (componentsTree[0].componentName === 'Page' || componentsTree[0].componentName === 'Component') {
|
||||
componentsTree[0].methods = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.load({
|
||||
version: '1.0.0',
|
||||
componentsMap: [],
|
||||
componentsTree,
|
||||
id: pages[0].id,
|
||||
}, true);
|
||||
project.load(
|
||||
{
|
||||
version: '1.0.0',
|
||||
componentsMap: [],
|
||||
componentsTree,
|
||||
id: pages[0].id,
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
// FIXME: 根本原因应该是 propStash 导致的,这样可以避免页面加载之后就被标记为 isModified
|
||||
setTimeout(() => {
|
||||
@ -95,18 +97,20 @@ const pages = Object.assign(project, {
|
||||
return project.onCurrentDocumentChange(fn);
|
||||
},
|
||||
toData() {
|
||||
return project.documents.map(doc => doc.toData());
|
||||
}
|
||||
return project.documents.map((doc) => doc.toData());
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(pages, 'currentPage', {
|
||||
get() {
|
||||
return project.currentDocument;
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
pages.onCurrentPageChange((page: DocumentModel) => {
|
||||
if (!page) { return; }
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
page.acceptRootNodeVisitor('NodeCache', (rootNode) => {
|
||||
const visitor: NodeCacheVisitor = page.getRootNodeVisitor('NodeCache');
|
||||
if (visitor) {
|
||||
|
||||
@ -3,6 +3,43 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<a name="1.0.7-0"></a>
|
||||
## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.6-0...@ali/lowcode-editor-setters@1.0.7-0) (2020-09-02)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="1.0.6-0"></a>
|
||||
## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.19...@ali/lowcode-editor-setters@1.0.6-0) (2020-09-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad))
|
||||
* 清理代码依赖及版本 ([0b15d30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0b15d30))
|
||||
* 适配Nav组件 ([7e9829f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7e9829f))
|
||||
* fix function-setter bug ([dced647](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/dced647))
|
||||
* fix function-setter bug ([8fd77df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8fd77df))
|
||||
* fix NextTable callback function ([ce77375](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce77375))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* 新增事件入参功能 ([0614fa7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0614fa7))
|
||||
* 新增functionSetter ([9359ac6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9359ac6))
|
||||
* add function setter ([114b6b0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/114b6b0))
|
||||
* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84))
|
||||
* setting-pane 新增removeProp 函数 ([b97c807](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b97c807))
|
||||
* tree 组件修改 ([7efa52f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7efa52f))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.0.5-0"></a>
|
||||
## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.4-0...@ali/lowcode-editor-setters@1.0.5-0) (2020-08-20)
|
||||
|
||||
<a name="0.9.19"></a>
|
||||
## [0.9.19](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.18...@ali/lowcode-editor-setters@0.9.19) (2020-08-27)
|
||||
|
||||
@ -27,22 +64,103 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="1.0.4-0"></a>
|
||||
## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.3-0...@ali/lowcode-editor-setters@1.0.4-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="1.0.3-0"></a>
|
||||
## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.2-0...@ali/lowcode-editor-setters@1.0.3-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="1.0.2-0"></a>
|
||||
## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.1-0...@ali/lowcode-editor-setters@1.0.2-0) (2020-08-20)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="1.0.1-0"></a>
|
||||
## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.16...@ali/lowcode-editor-setters@1.0.1-0) (2020-08-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix function-setter bug ([8fd77df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8fd77df))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add function setter ([114b6b0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/114b6b0))
|
||||
* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84))
|
||||
* setting-pane 新增removeProp 函数 ([b97c807](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b97c807))
|
||||
* 新增functionSetter ([9359ac6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9359ac6))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.14.0...@ali/lowcode-editor-setters@1.0.0) (2020-08-17)
|
||||
<a name="0.9.16"></a>
|
||||
## [0.9.16](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.15...@ali/lowcode-editor-setters@0.9.16) (2020-08-19)
|
||||
>>>>>>> master
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="0.9.15"></a>
|
||||
## [0.9.15](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.14...@ali/lowcode-editor-setters@0.9.15) (2020-08-17)
|
||||
<a name="0.14.0"></a>
|
||||
# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.13.0...@ali/lowcode-editor-setters@0.14.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="0.13.0"></a>
|
||||
# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.11.0...@ali/lowcode-editor-setters@0.13.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="0.12.0"></a>
|
||||
# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.11.0...@ali/lowcode-editor-setters@0.12.0) (2020-08-17)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="0.11.0"></a>
|
||||
# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.10.0...@ali/lowcode-editor-setters@0.11.0) (2020-08-16)
|
||||
|
||||
|
||||
|
||||
|
||||
**Note:** Version bump only for package @ali/lowcode-editor-setters
|
||||
|
||||
<a name="0.10.0"></a>
|
||||
# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.14...@ali/lowcode-editor-setters@0.10.0) (2020-08-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84))
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="0.9.14"></a>
|
||||
## [0.9.14](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.13...@ali/lowcode-editor-setters@0.9.14) (2020-08-04)
|
||||
|
||||
@ -283,8 +401,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
<<<<<<< HEAD
|
||||
* ts type ([1732e7d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1732e7d))
|
||||
=======
|
||||
* ts type ([1732e7d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1732e7db5fccb6e185cfa12e197ae698932fe127))
|
||||
>>>>>>> df955e1db90ff104cd11160def80113cfd6faccc
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ali/lowcode-editor-setters",
|
||||
"version": "0.9.19",
|
||||
"version": "1.0.7-0",
|
||||
"description": "Builtin setters for Ali lowCode engine",
|
||||
"files": [
|
||||
"es",
|
||||
@ -22,11 +22,11 @@
|
||||
"@ali/iceluna-comp-react-node": "^1.0.5",
|
||||
"@ali/iceluna-sdk": "^1.0.5-beta.24",
|
||||
"@ali/lc-style-setter": "^0.0.1",
|
||||
"@ali/lowcode-editor-core": "^0.8.34",
|
||||
"@ali/lowcode-editor-core": "^1.0.7-0",
|
||||
"@alifd/next": "^1.19.16",
|
||||
"acorn": "^6.4.1",
|
||||
"classnames": "^2.2.6",
|
||||
"intl-messageformat": "^8.2.1",
|
||||
"intl-messageformat": "^9.3.1",
|
||||
"monaco-editor": "^0.20.0",
|
||||
"qs": "^6.9.1",
|
||||
"react": "^16",
|
||||
|
||||
@ -18,23 +18,23 @@ export default class ColorPickerView extends PureComponent<PluginProps> {
|
||||
static display = 'ColorPicker';
|
||||
static propTypes = {
|
||||
onChange: PropTypes.func,
|
||||
value: PropTypes.string
|
||||
value: PropTypes.string,
|
||||
};
|
||||
static defaultProps = {
|
||||
onChange: () => {},
|
||||
value: ''
|
||||
value: '',
|
||||
};
|
||||
constructor(props: Readonly<{value: string; defaultValue: string}>) {
|
||||
constructor(props: Readonly<{ value: string; defaultValue: string }>) {
|
||||
super(props);
|
||||
this.state = {
|
||||
value: props.value || props.defaultValue
|
||||
value: props.value || props.defaultValue,
|
||||
};
|
||||
}
|
||||
static getDerivedStateFromProps(props: { value: string; }, state: { preValue: string; }) {
|
||||
static getDerivedStateFromProps(props: { value: string }, state: { preValue: string }) {
|
||||
if (props.value != state.preValue) {
|
||||
return {
|
||||
preValue: props.value,
|
||||
value: props.value
|
||||
value: props.value,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
@ -42,35 +42,35 @@ export default class ColorPickerView extends PureComponent<PluginProps> {
|
||||
onChangeComplete = (color: Color): void => {
|
||||
let value;
|
||||
if (color.rgb.a < 1) {
|
||||
let rgb = color.rgb;
|
||||
let rgba = [rgb.r, rgb.g, rgb.b, rgb.a];
|
||||
const rgb = color.rgb;
|
||||
const rgba = [rgb.r, rgb.g, rgb.b, rgb.a];
|
||||
value = `rgba(${rgba.join(',')})`;
|
||||
} else {
|
||||
value = color.hex;
|
||||
}
|
||||
this.setState({
|
||||
value
|
||||
value,
|
||||
});
|
||||
this.props.onChange && this.props.onChange(value);
|
||||
}
|
||||
};
|
||||
onInputChange = (value: string): void => {
|
||||
if (/^[0-9a-zA-Z]{6}$/.test(value)) value = '#' + value;
|
||||
this.setState({
|
||||
value
|
||||
value,
|
||||
});
|
||||
this.props.onChange && this.props.onChange(value);
|
||||
}
|
||||
render(): React.ReactNode {
|
||||
};
|
||||
render(): React.ReactNode {
|
||||
const { value, onChange, ...restProps } = this.props;
|
||||
let boxStyle = {
|
||||
backgroundColor: this.state.value
|
||||
const boxStyle = {
|
||||
backgroundColor: this.state.value,
|
||||
};
|
||||
let triggerNode = (
|
||||
const triggerNode = (
|
||||
<div className="lowcode-color-box">
|
||||
<div style={boxStyle} />
|
||||
</div>
|
||||
);
|
||||
let InnerBeforeNode = (
|
||||
const InnerBeforeNode = (
|
||||
<Balloon
|
||||
className={'lowcode-color-content'}
|
||||
trigger={triggerNode}
|
||||
@ -80,20 +80,11 @@ export default class ColorPickerView extends PureComponent<PluginProps> {
|
||||
alignEdge="edge"
|
||||
offset={[-3, -6]}
|
||||
>
|
||||
<SketchPicker
|
||||
onChangeComplete={this.onChangeComplete}
|
||||
color={this.state.value}
|
||||
arrowPointAtCenter={true}
|
||||
/>
|
||||
<SketchPicker onChangeComplete={this.onChangeComplete} color={this.state.value} arrowPointAtCenter={true} />
|
||||
</Balloon>
|
||||
);
|
||||
return (
|
||||
<Input
|
||||
{...restProps}
|
||||
innerBefore={InnerBeforeNode}
|
||||
onChange={this.onInputChange}
|
||||
value={this.state.value}
|
||||
/>
|
||||
<Input {...restProps} innerBefore={InnerBeforeNode} onChange={this.onInputChange} value={this.state.value} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
|
||||
.event-menu {
|
||||
max-height: 300px;
|
||||
width: 230px;
|
||||
width: 256px;
|
||||
overflow-x: hidden;
|
||||
position: absolute;
|
||||
top: 67px;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user