@cicctencent/low-code-simulate-base 0.0.0-stage → 1.1.9-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/__tests__/plugin.spec.ts +40 -0
- package/__tests__/utils.transform.test.ts +37 -0
- package/api-extractor.json +36 -0
- package/build/md.js +25 -0
- package/dist/VCComponent.d.ts +5 -0
- package/dist/VCComponent.js +91 -0
- package/dist/domain/BaseProjectDomain.d.ts +349 -0
- package/dist/domain/BaseProjectDomain.js +1305 -0
- package/dist/domain/ComponentManager.d.ts +78 -0
- package/dist/domain/ComponentManager.js +293 -0
- package/dist/domain/DataHistoryDomain.d.ts +53 -0
- package/dist/domain/DataHistoryDomain.js +110 -0
- package/dist/domain/PreviewDomain.d.ts +208 -0
- package/dist/domain/PreviewDomain.js +492 -0
- package/dist/domain/ProjectDomain.d.ts +209 -0
- package/dist/domain/ProjectDomain.js +138 -0
- package/dist/event/generateEventHandler.d.ts +21 -0
- package/dist/event/generateEventHandler.js +218 -0
- package/dist/event/generateEventSchema.d.ts +123 -0
- package/dist/event/generateEventSchema.js +342 -0
- package/dist/event/register.d.ts +56 -0
- package/dist/event/register.js +207 -0
- package/dist/index.d.ts +1330 -0
- package/dist/index.js +28 -0
- package/dist/plugin/onH5PageValidate.d.ts +7 -0
- package/dist/plugin/onH5PageValidate.js +178 -0
- package/dist/plugin/onPlaceholder.d.ts +6 -0
- package/dist/plugin/onPlaceholder.js +68 -0
- package/dist/plugin/subscribeInsertUploadList.d.ts +6 -0
- package/dist/plugin/subscribeInsertUploadList.js +49 -0
- package/dist/plugin/subscribeSetTitle.d.ts +6 -0
- package/dist/plugin/subscribeSetTitle.js +16 -0
- package/dist/plugin/subscribeTransformComponentMeta.d.ts +14 -0
- package/dist/plugin/subscribeTransformComponentMeta.js +31 -0
- package/dist/plugin/subscribeValidateField.d.ts +7 -0
- package/dist/plugin/subscribeValidateField.js +57 -0
- package/dist/plugin/subscribeValidateUpload.d.ts +6 -0
- package/dist/plugin/subscribeValidateUpload.js +92 -0
- package/dist/utils/base64.d.ts +14 -0
- package/dist/utils/base64.js +14 -0
- package/dist/utils/buildInVariable.d.ts +61 -0
- package/dist/utils/buildInVariable.js +216 -0
- package/dist/utils/dom.d.ts +14 -0
- package/dist/utils/dom.js +19 -0
- package/dist/utils/index.d.ts +55 -0
- package/dist/utils/index.js +201 -0
- package/dist/utils/transform.d.ts +39 -0
- package/dist/utils/transform.js +191 -0
- package/dist/utils/validate.d.ts +7 -0
- package/dist/utils/validate.js +18 -0
- package/docs/.api/low-code-simulate-base.api.json +8450 -0
- package/jest.config.ts +20 -0
- package/package.json +44 -4
- package/src/VCComponent.ts +118 -0
- package/src/domain/BaseProjectDomain.ts +1341 -0
- package/src/domain/ComponentManager.ts +241 -0
- package/src/domain/DataHistoryDomain.ts +102 -0
- package/src/domain/PreviewDomain.ts +424 -0
- package/src/domain/ProjectDomain.ts +244 -0
- package/src/event/generateEventHandler.ts +162 -0
- package/src/event/generateEventSchema.ts +371 -0
- package/src/event/register.ts +181 -0
- package/src/index.ts +61 -0
- package/src/plugin/onH5PageValidate.ts +179 -0
- package/src/plugin/onPlaceholder.ts +71 -0
- package/src/plugin/subscribeInsertUploadList.ts +51 -0
- package/src/plugin/subscribeSetTitle.ts +18 -0
- package/src/plugin/subscribeTransformComponentMeta.ts +38 -0
- package/src/plugin/subscribeValidateField.ts +65 -0
- package/src/plugin/subscribeValidateUpload.ts +116 -0
- package/src/utils/base64.ts +17 -0
- package/src/utils/buildInVariable.ts +157 -0
- package/src/utils/dom.ts +30 -0
- package/src/utils/index.ts +194 -0
- package/src/utils/transform.ts +171 -0
- package/src/utils/validate.ts +19 -0
- package/temp/low-code-simulate-base.api.md +597 -0
- package/test/plugin.test.ts +4 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +9 -0
- package/tsconfig.test.json +14 -0
package/jest.config.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Config } from '@jest/types';
|
|
2
|
+
|
|
3
|
+
const config: Config.InitialOptions = {
|
|
4
|
+
preset: 'ts-jest',
|
|
5
|
+
testMatch: ["<rootDir>/__tests__/**/*.(spec|test).ts?(x)"],
|
|
6
|
+
transform: {
|
|
7
|
+
// 将.js后缀的文件使用babel-jest处理
|
|
8
|
+
"^.+\\.js$": "babel-jest",
|
|
9
|
+
"^.+\\.(ts|tsx)$": "ts-jest"
|
|
10
|
+
},
|
|
11
|
+
// 下面非要从重要, 将不忽略 lodash-es es库, 从而使babel-jest去处理它们
|
|
12
|
+
transformIgnorePatterns: ["<rootDir>/node_modules/(?!(lodash-es))"],
|
|
13
|
+
globals: {
|
|
14
|
+
"ts-jest": {
|
|
15
|
+
"tsconfig": "tsconfig.test.json"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cicctencent/low-code-simulate-base",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.9-beta.5",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"tw": "jest --watch",
|
|
10
|
+
"build": "rimraf -rf dist && tsc --project tsconfig.build.json && rollup --config ../../scripts/rollup.dts.config.js --bundleConfigAsCjs && node ../../scripts/replace.js",
|
|
11
|
+
"api:json": "npm run build && npx api-extractor run",
|
|
12
|
+
"api:md": "npx api-documenter markdown -i ./docs/.api -o ./docs/api && node ./build/md.js && mv ./docs/api ../../docs/src/low-code-simulate-base",
|
|
13
|
+
"api": "npm run api:json && npm run api:md"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@jt/ark-util": ">=0.0.30",
|
|
17
|
+
"@cicctencent/low-code-core": "1.1.9-beta.5",
|
|
18
|
+
"@cicctencent/low-code-validate": "1.1.9-beta.5",
|
|
19
|
+
"@jt/postmessage-channel": ">=0.1.10",
|
|
20
|
+
"jm-jsruntime": "1.0.3",
|
|
21
|
+
"koa-compose": "^4.1.0",
|
|
22
|
+
"vue-demi": "latest"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@jest/types": "^28.1.1",
|
|
26
|
+
"@microsoft/api-documenter": "^7.23.17",
|
|
27
|
+
"@microsoft/api-extractor": "^7.39.1",
|
|
28
|
+
"@microsoft/tsdoc": "^0.14.2",
|
|
29
|
+
"@types/jest": "^29.5.0",
|
|
30
|
+
"jest": "^28.1.1",
|
|
31
|
+
"rollup": "^3.26.0",
|
|
32
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
33
|
+
"ts-jest": "^28.0.5"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"vue": "^2.6.0 || ^3.0.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"@vue/composition-api": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"keywords": [],
|
|
44
|
+
"author": "",
|
|
45
|
+
"license": "ISC"
|
|
46
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { h, getCurrentInstance, isVue3 } from 'vue-demi';
|
|
2
|
+
import * as Vue from 'vue-demi';
|
|
3
|
+
import { camelize } from '@jt/ark-util';
|
|
4
|
+
import { generateEventHandlers } from './event/generateEventHandler';
|
|
5
|
+
|
|
6
|
+
function renderVue3(item: any) {
|
|
7
|
+
//@ts-ignore
|
|
8
|
+
const that: any = getCurrentInstance();
|
|
9
|
+
const {
|
|
10
|
+
name,
|
|
11
|
+
componentId,
|
|
12
|
+
formData: { style, props, event = { list: [] } },
|
|
13
|
+
} = item;
|
|
14
|
+
let component;
|
|
15
|
+
if (isVue3) {
|
|
16
|
+
component = Vue.resolveComponent(name);
|
|
17
|
+
}
|
|
18
|
+
const { on, nativeOn } = generateEventHandlers(
|
|
19
|
+
// this.$children[0],
|
|
20
|
+
that,
|
|
21
|
+
event.list || []
|
|
22
|
+
);
|
|
23
|
+
const eventObj = { ...on, ...nativeOn };
|
|
24
|
+
const onEvent = {};
|
|
25
|
+
// 处理和过滤事件
|
|
26
|
+
Object.keys(eventObj).forEach(eventType => {
|
|
27
|
+
// 如果有生命周期的事件 不直接添加到组件上
|
|
28
|
+
if (['mounted'].includes(eventType)) return;
|
|
29
|
+
const eventKey = camelize(`on-${eventType}`);
|
|
30
|
+
onEvent[eventKey] = eventObj[eventType];
|
|
31
|
+
});
|
|
32
|
+
return h(
|
|
33
|
+
component,
|
|
34
|
+
{
|
|
35
|
+
componentId,
|
|
36
|
+
...props,
|
|
37
|
+
style,
|
|
38
|
+
key: `${name}-${componentId}`,
|
|
39
|
+
...onEvent,
|
|
40
|
+
},
|
|
41
|
+
{ ...that.slots }
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function renderVue2(item: any, c: any, thisArg) {
|
|
46
|
+
//@ts-ignore
|
|
47
|
+
const {
|
|
48
|
+
name,
|
|
49
|
+
componentId,
|
|
50
|
+
formData: { style, props, event = { list: [] } },
|
|
51
|
+
} = item;
|
|
52
|
+
|
|
53
|
+
const { on, nativeOn } = generateEventHandlers(
|
|
54
|
+
// this.$children[0],
|
|
55
|
+
thisArg,
|
|
56
|
+
event.list || []
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// 获取所有的插槽(包括具名插槽和默认插槽)
|
|
60
|
+
const slots = {
|
|
61
|
+
...thisArg.$slots,
|
|
62
|
+
...thisArg.$scopedSlots
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// 将插槽转换为函数对象
|
|
66
|
+
const scopedSlots = Object.keys(slots).reduce((acc, key) => {
|
|
67
|
+
acc[key] = props => slots[key](props);
|
|
68
|
+
return acc;
|
|
69
|
+
}, {});
|
|
70
|
+
|
|
71
|
+
return c(
|
|
72
|
+
name,
|
|
73
|
+
{
|
|
74
|
+
key: `${name}-${componentId}`,
|
|
75
|
+
props: {componentId, ...props},
|
|
76
|
+
style,
|
|
77
|
+
on,
|
|
78
|
+
nativeOn,
|
|
79
|
+
scopedSlots
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export const VcComponent: any = {
|
|
87
|
+
name: 'VCComponent',
|
|
88
|
+
props: {
|
|
89
|
+
componentDescriptor: Object,
|
|
90
|
+
},
|
|
91
|
+
computed: {
|
|
92
|
+
eventObj() {
|
|
93
|
+
const {
|
|
94
|
+
formData: { event = { list: [] } },
|
|
95
|
+
} = this.componentDescriptor;
|
|
96
|
+
const { on, nativeOn } = generateEventHandlers(this, event.list || []);
|
|
97
|
+
return { ...on, ...nativeOn };
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
mounted() {
|
|
101
|
+
if (Object.keys(this.eventObj).includes('mounted')) {
|
|
102
|
+
this.eventObj['mounted']();
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
render(c: any) {
|
|
106
|
+
const that: any = this;
|
|
107
|
+
|
|
108
|
+
return isVue3
|
|
109
|
+
? renderVue3(that.componentDescriptor)
|
|
110
|
+
: renderVue2(that.componentDescriptor, c, that);
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
VcComponent.install = function (app: any) {
|
|
115
|
+
app.component('VcComponent', VcComponent);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default VcComponent;
|