@cloudbase/framework-plugin-low-code 0.6.55 → 0.6.58-alpha.0
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/lib/builder/config/common.js +1 -1
- package/lib/builder/config/index.js +2 -2
- package/lib/builder/config/mp.js +1 -1
- package/lib/builder/core/copy.js +3 -3
- package/lib/builder/core/generate.d.ts.map +1 -1
- package/lib/builder/core/generate.js +18 -14
- package/lib/builder/core/index.js +13 -13
- package/lib/builder/core/material.js +6 -6
- package/lib/builder/core/plugin.js +3 -3
- package/lib/builder/core/prepare.js +2 -2
- package/lib/builder/core/webpack.js +5 -5
- package/lib/builder/mp/index.d.ts.map +1 -1
- package/lib/builder/mp/index.js +54 -50
- package/lib/builder/mp/lowcode.js +4 -4
- package/lib/builder/mp/materials.js +16 -16
- package/lib/builder/mp/mixMode.js +12 -12
- package/lib/builder/mp/mp_config.js +11 -11
- package/lib/builder/mp/util.js +6 -6
- package/lib/builder/mp/wxml.js +4 -4
- package/lib/builder/service/builder/copy.js +11 -11
- package/lib/builder/service/builder/generate.d.ts.map +1 -1
- package/lib/builder/service/builder/generate.js +58 -60
- package/lib/builder/service/builder/index.js +2 -2
- package/lib/builder/service/builder/plugin.js +2 -2
- package/lib/builder/service/builder/webpack.js +23 -24
- package/lib/builder/types/common.js +0 -1
- package/lib/builder/util/common.js +6 -8
- package/lib/builder/util/console.js +1 -1
- package/lib/builder/util/generateFiles.js +2 -2
- package/lib/builder/util/index.js +1 -1
- package/lib/builder/util/junk.js +2 -4
- package/lib/builder/util/mp.js +1 -1
- package/lib/builder/util/net.js +1 -1
- package/lib/builder/util/style.js +1 -1
- package/lib/builder/util/weapp.js +1 -1
- package/lib/generate.js +2 -2
- package/lib/generator/config/index.js +2 -2
- package/lib/generator/core/generate.js +34 -36
- package/lib/generator/core/index.js +4 -4
- package/lib/generator/core/material.js +14 -14
- package/lib/generator/types/common.js +3 -6
- package/lib/generator/util/index.js +1 -1
- package/lib/generator/util/style.js +2 -2
- package/lib/index.js +53 -58
- package/lib/utils/common.d.ts +1 -1
- package/lib/utils/common.d.ts.map +1 -1
- package/lib/utils/common.js +2 -2
- package/lib/utils/dataSource.js +2 -2
- package/lib/utils/index.js +1 -1
- package/lib/utils/postProcess.js +3 -3
- package/lib/weapps-core/config/index.js +1 -1
- package/lib/weapps-core/index.js +2 -2
- package/lib/weapps-core/types/index.js +1 -1
- package/lib/weapps-core/utils/appbuild.js +3 -6
- package/lib/weapps-core/utils/common.js +2 -3
- package/lib/weapps-core/utils/file.d.ts +1 -1
- package/lib/weapps-core/utils/formily.js +37 -37
- package/lib/weapps-core/utils/index.js +1 -1
- package/lib/weapps-core/utils/style.js +15 -15
- package/package.json +1 -1
- package/template/html/index.html.ejs +6 -3
- package/template/mp/common/weapp-page.js +23 -11
- package/template/mp/component/index.js +2 -2
- package/template/mp/page/index.js +2 -2
- package/template/package.json +1 -0
- package/template/src/pages/app.tpl +53 -11
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper =
|
|
15
|
+
exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
18
|
const style_1 = require("./style");
|
|
@@ -89,8 +89,7 @@ function getInputProps(componentsMetaMap) {
|
|
|
89
89
|
let compItem = component;
|
|
90
90
|
Object.keys(compItem.dataForm || {}).forEach((key) => {
|
|
91
91
|
var _a, _b;
|
|
92
|
-
const inputProps = ((_a = compItem.dataForm[key]) === null || _a === void 0 ? void 0 : _a.inputProp) ||
|
|
93
|
-
((_b = compItem.dataForm[key]) === null || _b === void 0 ? void 0 : _b.syncProps);
|
|
92
|
+
const inputProps = ((_a = compItem.dataForm[key]) === null || _a === void 0 ? void 0 : _a.inputProp) || ((_b = compItem.dataForm[key]) === null || _b === void 0 ? void 0 : _b.syncProps);
|
|
94
93
|
if (inputProps) {
|
|
95
94
|
outputObj[sourceKey] = Object.assign({ [key]: inputProps }, (outputObj[sourceKey] || {}));
|
|
96
95
|
}
|
|
@@ -185,7 +184,7 @@ function writeLibCommonRes2file(gItem, codeDir) {
|
|
|
185
184
|
libCommonResFiles.push({
|
|
186
185
|
path: path_1.default.join(codeDir, `class.${codeDir.includes('/mp/') ? 'wxss' : 'less'}`),
|
|
187
186
|
code: compLibCommonResource
|
|
188
|
-
? yield
|
|
187
|
+
? yield style_1.processLess(`
|
|
189
188
|
${compLibCommonResource.theme.variable || ''}
|
|
190
189
|
${compLibCommonResource.class || ''}
|
|
191
190
|
${compLibCommonResource.theme.class || ''}
|
|
@@ -198,7 +197,7 @@ function writeLibCommonRes2file(gItem, codeDir) {
|
|
|
198
197
|
path: path_1.default.join(codeDir, 'tools.js'),
|
|
199
198
|
code: compLibCommonResource ? compLibCommonResource.tools.code : '',
|
|
200
199
|
});
|
|
201
|
-
yield Promise.all(libCommonResFiles.map((item) =>
|
|
200
|
+
yield Promise.all(libCommonResFiles.map((item) => generateFiles_1.writeFile(item.path, item.code)));
|
|
202
201
|
});
|
|
203
202
|
}
|
|
204
203
|
exports.writeLibCommonRes2file = writeLibCommonRes2file;
|
|
@@ -213,7 +212,7 @@ function readComponentLibMata(libDir) {
|
|
|
213
212
|
let [major] = ((_a = meta === null || meta === void 0 ? void 0 : meta.schemaVersion) === null || _a === void 0 ? void 0 : _a.split('.')) || [];
|
|
214
213
|
const originComponentMetaMap = meta.components;
|
|
215
214
|
if (Number(major) >= 2) {
|
|
216
|
-
meta =
|
|
215
|
+
meta = cals_1.deserializeComponentLibraryMeta(meta);
|
|
217
216
|
}
|
|
218
217
|
for (let key in meta.components) {
|
|
219
218
|
meta.components[key] = Object.assign(Object.assign({}, originComponentMetaMap[key]), { name: key, meta: meta.components[key] });
|
|
@@ -227,7 +226,6 @@ const _OFFICIAL_COMPONENT_LIB = {
|
|
|
227
226
|
};
|
|
228
227
|
function isOfficialComponentLib(name, version) {
|
|
229
228
|
var _a, _b;
|
|
230
|
-
return (!!((_a = _OFFICIAL_COMPONENT_LIB[name]) === null || _a === void 0 ? void 0 : _a.includes(version)) ||
|
|
231
|
-
((_b = _OFFICIAL_COMPONENT_LIB[name]) === null || _b === void 0 ? void 0 : _b.includes('*')));
|
|
229
|
+
return (!!((_a = _OFFICIAL_COMPONENT_LIB[name]) === null || _a === void 0 ? void 0 : _a.includes(version)) || ((_b = _OFFICIAL_COMPONENT_LIB[name]) === null || _b === void 0 ? void 0 : _b.includes('*')));
|
|
232
230
|
}
|
|
233
231
|
exports.isOfficialComponentLib = isOfficialComponentLib;
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("../../generator/util/console"), exports);
|
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
@@ -47,7 +47,7 @@ function generateFiles(appFileData, srcDir, dstDir, ctx) {
|
|
|
47
47
|
const tplStr = yield fs_extra_1.default.readFile(path_1.default.join(srcDir, srcFileName), {
|
|
48
48
|
encoding: 'utf8',
|
|
49
49
|
});
|
|
50
|
-
let generatedCode =
|
|
50
|
+
let generatedCode = lodash_template_1.default(tplStr, { interpolate: /<%=([\s\S]+?)%>/ })(appFileData[file]);
|
|
51
51
|
const outFile = path_1.default.resolve(dstDir, outFileName.replace(/\.tpl$/, ''));
|
|
52
52
|
if (yield writeFile(outFile, generatedCode)) {
|
|
53
53
|
filesGenerated.push(outFileName);
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./common"), exports);
|
package/lib/builder/util/junk.js
CHANGED
|
@@ -19,7 +19,5 @@ const ignoreList = [
|
|
|
19
19
|
'@eaDir$',
|
|
20
20
|
];
|
|
21
21
|
const regex = new RegExp(ignoreList.join('|'));
|
|
22
|
-
|
|
23
|
-
exports.
|
|
24
|
-
const not = (filename) => !(0, exports.is)(filename);
|
|
25
|
-
exports.not = not;
|
|
22
|
+
exports.is = (filename) => regex.test(filename);
|
|
23
|
+
exports.not = (filename) => !exports.is(filename);
|
package/lib/builder/util/mp.js
CHANGED
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
package/lib/builder/util/net.js
CHANGED
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("../../generator/util/style"), exports);
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("../../generator/util/weapp"), exports);
|
package/lib/generate.js
CHANGED
|
@@ -35,7 +35,7 @@ function handleMpPlugins(plugins = [], appBuildDir) {
|
|
|
35
35
|
});
|
|
36
36
|
fs_extra_1.default.writeJsonSync(mpBuildPkgJsonPath, buildPkgJson, { spaces: 2 });
|
|
37
37
|
console.log('小程序安装依赖', appBuildMpDir);
|
|
38
|
-
yield
|
|
38
|
+
yield webpack_1.installDependencies(appBuildMpDir);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
exports.handleMpPlugins = handleMpPlugins;
|
|
@@ -54,7 +54,7 @@ function mergeSubPackages(baseAppJsonPath, mergeAppJsonPath) {
|
|
|
54
54
|
return item.root === mergeItem.root;
|
|
55
55
|
});
|
|
56
56
|
if (newJson.subpackages[targetItemIdx]) {
|
|
57
|
-
const pages =
|
|
57
|
+
const pages = lodash_1.uniq([].concat(newJson.subpackages[targetItemIdx].pages, mergeItem.pages));
|
|
58
58
|
newJson.subpackages[targetItemIdx].pages = pages;
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
@@ -14,12 +14,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
-
for (var p in m) if (p !== "default" && !
|
|
22
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.rpxConfig = exports.remConfig = exports.materialsDirName = exports.npmRegistry = exports.appTemplateDir = exports.rootDir = void 0;
|
|
@@ -62,7 +62,7 @@ function getGenericCompFromDep(dependencies = []) {
|
|
|
62
62
|
dependencies.forEach((compLib) => {
|
|
63
63
|
if (compLib.isComposite) {
|
|
64
64
|
compLib.components.forEach((component) => {
|
|
65
|
-
|
|
65
|
+
util_1.deepDealComponentSchemaJson(Object.values(component.componentInstances)[0], (componentSchema) => {
|
|
66
66
|
if (componentSchema === null || componentSchema === void 0 ? void 0 : componentSchema.genericComp) {
|
|
67
67
|
genericCompMap[`${component.materialName}:${component.name}`] =
|
|
68
68
|
componentSchema.genericComp;
|
|
@@ -82,7 +82,7 @@ function generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependen
|
|
|
82
82
|
const { componentSchemaJson, data, style } = pageInstance;
|
|
83
83
|
const genericCompMap = getGenericCompFromDep(dependencies);
|
|
84
84
|
const { originComponentList, originActionList, } = getOriginComponentAndActionList(componentSchemaJson, dependencies, [], [], genericCompMap);
|
|
85
|
-
const componentInfo = yield
|
|
85
|
+
const componentInfo = yield util_1.getComponentsInfo(appBuildDir, dependencies, fileCodeMap);
|
|
86
86
|
const { widgets, dataBinds, componentSchema } = getComponentSchemaString(componentSchemaJson, false, componentInfo);
|
|
87
87
|
const pageClass = [rootPath, pageInstance.id].filter(Boolean).join('-');
|
|
88
88
|
const templateData = {
|
|
@@ -90,7 +90,7 @@ function generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependen
|
|
|
90
90
|
cleanVarName: util_1.cleanVarName,
|
|
91
91
|
isSandbox,
|
|
92
92
|
pageName: pageInstance.id,
|
|
93
|
-
pageStyleText:
|
|
93
|
+
pageStyleText: weapps_core_1.toCssText(weapps_core_1.toCssStyle(style), `body`),
|
|
94
94
|
useComponents: originComponentList,
|
|
95
95
|
useActions: originActionList.filter((action) => action.type === weapps_core_1.ActionType.Material),
|
|
96
96
|
componentSchema,
|
|
@@ -103,7 +103,7 @@ function generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependen
|
|
|
103
103
|
};
|
|
104
104
|
const dest = path_1.default.join(dstDir, `/pages/${pageInstance.id}/index.jsx`);
|
|
105
105
|
const template = template_1.default[`/src/pages/app.tpl`];
|
|
106
|
-
const jsx =
|
|
106
|
+
const jsx = lodash_template_1.default(template.code, { interpolate: /<%=([\s\S]+?)%>/g })(templateData);
|
|
107
107
|
fileCodeMap[dest] = {
|
|
108
108
|
code: jsx,
|
|
109
109
|
};
|
|
@@ -143,7 +143,7 @@ function pullActionToListByInstances(listenerInstances, originActionList, fixedD
|
|
|
143
143
|
}
|
|
144
144
|
listenerInstances.map((pageListenerInstance) => {
|
|
145
145
|
const { sourceKey, type } = pageListenerInstance;
|
|
146
|
-
const { materialName, name, variableName } =
|
|
146
|
+
const { materialName, name, variableName } = util_1.getMetaInfoBySourceKey(sourceKey);
|
|
147
147
|
const material = fixedDependencies.find((m) => m.name === materialName);
|
|
148
148
|
const actionKey = `${materialName}_${name}`;
|
|
149
149
|
const isExistAction = originActionList.find((item) => item.key === actionKey);
|
|
@@ -163,7 +163,7 @@ function pullActionToListByInstances(listenerInstances, originActionList, fixedD
|
|
|
163
163
|
exports.pullActionToListByInstances = pullActionToListByInstances;
|
|
164
164
|
function pullComponentToListByInstance(sourceKey, originComponentList, fixedDependencies) {
|
|
165
165
|
var _a, _b;
|
|
166
|
-
const { materialName, name, variableName } =
|
|
166
|
+
const { materialName, name, variableName } = util_1.getMetaInfoBySourceKey(sourceKey);
|
|
167
167
|
const componentKey = `${materialName}_${name}`;
|
|
168
168
|
const isExistComponent = originComponentList.find((item) => item.key === componentKey);
|
|
169
169
|
if (!isExistComponent) {
|
|
@@ -197,11 +197,11 @@ function isSlot(comp) {
|
|
|
197
197
|
}
|
|
198
198
|
exports.isSlot = isSlot;
|
|
199
199
|
function getComponentSchemaString(componentSchema, isComposite = false, componentsInfoMap = {}, wrapperClass) {
|
|
200
|
-
const componentInputProps =
|
|
201
|
-
const copyJson =
|
|
200
|
+
const componentInputProps = util_1.getInputProps(componentsInfoMap) || {};
|
|
201
|
+
const copyJson = util_1.simpleDeepClone(componentSchema);
|
|
202
202
|
const compWidgets = {};
|
|
203
203
|
const compDataBinds = {};
|
|
204
|
-
const componentSchemaJson =
|
|
204
|
+
const componentSchemaJson = util_1.deepDealSchema(copyJson, (schema) => {
|
|
205
205
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
206
206
|
const { 'x-props': xProps = {}, properties } = schema;
|
|
207
207
|
const { dataBinds = [], commonStyle = {}, data = {}, classNameList = [], sourceKey, styleBind, classNameListBind, } = xProps;
|
|
@@ -220,9 +220,8 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
|
|
|
220
220
|
}
|
|
221
221
|
if (!isSlot(schema) && schema.key) {
|
|
222
222
|
const parentSchema = schema.parent;
|
|
223
|
-
compWidgets[schema.key] = Object.assign(Object.assign({}, data), { style:
|
|
224
|
-
? (_f = parentSchema.parent) === null || _f === void 0 ? void 0 : _f.key
|
|
225
|
-
: parentSchema.key });
|
|
223
|
+
compWidgets[schema.key] = Object.assign(Object.assign({}, data), { style: weapps_core_1.toCssStyle(commonStyle), classList: classNameList, widgetType: sourceKey, _parentId: isSlot(parentSchema)
|
|
224
|
+
? (_f = parentSchema.parent) === null || _f === void 0 ? void 0 : _f.key : parentSchema.key });
|
|
226
225
|
if (dataBinds.length > 0) {
|
|
227
226
|
compDataBinds[schema.key] = generateDataBinds(dataBinds, isComposite);
|
|
228
227
|
}
|
|
@@ -245,7 +244,7 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
|
|
|
245
244
|
delete xProps.dataBinds;
|
|
246
245
|
delete xProps.styleBind;
|
|
247
246
|
delete xProps.classNameListBind;
|
|
248
|
-
if (properties &&
|
|
247
|
+
if (properties && weapps_core_1.isEmptyObj(properties)) {
|
|
249
248
|
delete schema.properties;
|
|
250
249
|
}
|
|
251
250
|
delete schema.type;
|
|
@@ -256,8 +255,7 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
|
|
|
256
255
|
if (propsVaule && Array.isArray(propsVaule)) {
|
|
257
256
|
propsVaule.map((block) => {
|
|
258
257
|
var _a, _b;
|
|
259
|
-
const blockInstance = (block === null || block === void 0 ? void 0 : block.selectableBlock) &&
|
|
260
|
-
((_b = (_a = block === null || block === void 0 ? void 0 : block.selectableBlock) === null || _a === void 0 ? void 0 : _a['x-props']) === null || _b === void 0 ? void 0 : _b.listenerInstances);
|
|
258
|
+
const blockInstance = (block === null || block === void 0 ? void 0 : block.selectableBlock) && ((_b = (_a = block === null || block === void 0 ? void 0 : block.selectableBlock) === null || _a === void 0 ? void 0 : _a['x-props']) === null || _b === void 0 ? void 0 : _b.listenerInstances);
|
|
261
259
|
if (blockInstance) {
|
|
262
260
|
block.selectableBlock['x-props'].listenerInstances = generateListnerInstances(blockInstance, isComposite);
|
|
263
261
|
}
|
|
@@ -274,11 +272,11 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
|
|
|
274
272
|
xProps['classNameList'].push(wrapperClass);
|
|
275
273
|
}
|
|
276
274
|
}
|
|
277
|
-
xProps['commonStyle'] =
|
|
278
|
-
if (
|
|
275
|
+
xProps['commonStyle'] = weapps_core_1.toCssStyle(xProps['commonStyle']);
|
|
276
|
+
if (weapps_core_1.isEmptyObj(xProps['commonStyle'])) {
|
|
279
277
|
delete xProps['commonStyle'];
|
|
280
278
|
}
|
|
281
|
-
if (
|
|
279
|
+
if (weapps_core_1.isEmptyObj(xProps['style'])) {
|
|
282
280
|
delete xProps['style'];
|
|
283
281
|
}
|
|
284
282
|
if (xProps['dataBinds'] && xProps['dataBinds'].length === 0) {
|
|
@@ -296,7 +294,7 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
|
|
|
296
294
|
if (xPropsData.title === '') {
|
|
297
295
|
delete xPropsData.title;
|
|
298
296
|
}
|
|
299
|
-
if (
|
|
297
|
+
if (weapps_core_1.isEmptyObj(xPropsData)) {
|
|
300
298
|
delete xProps['data'];
|
|
301
299
|
}
|
|
302
300
|
}
|
|
@@ -338,9 +336,9 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
|
|
|
338
336
|
}
|
|
339
337
|
});
|
|
340
338
|
return {
|
|
341
|
-
widgets:
|
|
342
|
-
dataBinds:
|
|
343
|
-
componentSchema:
|
|
339
|
+
widgets: util_1.JsonToStringWithVariableName(compWidgets, { EOL: false }),
|
|
340
|
+
dataBinds: util_1.JsonToStringWithVariableName(compDataBinds, { EOL: true }),
|
|
341
|
+
componentSchema: util_1.JsonToStringWithVariableName(componentSchemaJson, {
|
|
344
342
|
EOL: true,
|
|
345
343
|
}),
|
|
346
344
|
};
|
|
@@ -431,7 +429,7 @@ function generateListnerInstances(listenerInstances, isComposite = false) {
|
|
|
431
429
|
};
|
|
432
430
|
if (listener.type === weapps_core_1.ActionType.Material) {
|
|
433
431
|
const { sourceKey } = listener;
|
|
434
|
-
const { variableName } =
|
|
432
|
+
const { variableName } = util_1.getMetaInfoBySourceKey(sourceKey);
|
|
435
433
|
generatedListener.instanceFunction = `${config_1.REPLACE_SIGN}${variableName}${config_1.REPLACE_SIGN}`;
|
|
436
434
|
}
|
|
437
435
|
else if (listener.type === weapps_core_1.ActionType.PropEvent) {
|
|
@@ -473,7 +471,7 @@ function generateListnerInstances(listenerInstances, isComposite = false) {
|
|
|
473
471
|
generatedListener.instanceFunction = `${config_1.REPLACE_SIGN}handler.${name}.bind(pageCodeContext)${config_1.REPLACE_SIGN}`;
|
|
474
472
|
}
|
|
475
473
|
}
|
|
476
|
-
if (!
|
|
474
|
+
if (!weapps_core_1.isEmptyObj(listener.data)) {
|
|
477
475
|
generatedListener.data = listener.data;
|
|
478
476
|
}
|
|
479
477
|
if (listener.dataBinds && listener.dataBinds.length > 0) {
|
|
@@ -483,7 +481,7 @@ function generateListnerInstances(listenerInstances, isComposite = false) {
|
|
|
483
481
|
});
|
|
484
482
|
}
|
|
485
483
|
function getListenersString(listeners = [], isComposite = false) {
|
|
486
|
-
return
|
|
484
|
+
return util_1.JsonToStringWithVariableName(generateListnerInstances(listeners, isComposite), {
|
|
487
485
|
EOL: true,
|
|
488
486
|
});
|
|
489
487
|
}
|
|
@@ -519,7 +517,7 @@ function generateRouterFile(allAppDataList, appBuildDir, basename = '', fileCode
|
|
|
519
517
|
});
|
|
520
518
|
})));
|
|
521
519
|
const routerTemplate = template_1.default['/src/router/index.tpl'].code;
|
|
522
|
-
const routerIndexStr =
|
|
520
|
+
const routerIndexStr = lodash_template_1.default(routerTemplate, {
|
|
523
521
|
interpolate: /<%=([\s\S]+?)%>/g,
|
|
524
522
|
})({
|
|
525
523
|
routerImports: routerImports.join('\n'),
|
|
@@ -539,19 +537,19 @@ exports.generateRouterFile = generateRouterFile;
|
|
|
539
537
|
function writeLowCodeFiles(appData, appBuildDir, fileCodeMap, rootPath) {
|
|
540
538
|
return __awaiter(this, void 0, void 0, function* () {
|
|
541
539
|
const lowcodeRootDir = path_1.default.join(appBuildDir, 'lowcode');
|
|
542
|
-
|
|
540
|
+
style_1.generateDefaultTheme(appData);
|
|
543
541
|
generateDefaultLifecycle(appData);
|
|
544
542
|
const themeCode = appData.codeModules.find((mod) => mod.type === 'theme');
|
|
545
543
|
yield Promise.all(appData.codeModules.map((m) => writeCode2file(m, 'global')));
|
|
546
544
|
yield Promise.all(appData.pageInstanceList.map((page) => __awaiter(this, void 0, void 0, function* () {
|
|
547
|
-
|
|
545
|
+
style_1.generateDefaultStyle(page);
|
|
548
546
|
yield page.codeModules
|
|
549
547
|
.filter((m) => m.name !== '____index____')
|
|
550
548
|
.forEach((m) => writeCode2file(m, page.id, page));
|
|
551
549
|
})));
|
|
552
550
|
function writeCode2file(mod, pageId, page) {
|
|
553
551
|
return __awaiter(this, void 0, void 0, function* () {
|
|
554
|
-
const file = path_1.default.join(lowcodeRootDir,
|
|
552
|
+
const file = path_1.default.join(lowcodeRootDir, weapps_core_1.getCodeModuleFilePath(pageId, mod, {
|
|
555
553
|
style: '.css',
|
|
556
554
|
}));
|
|
557
555
|
let code = mod.code || '';
|
|
@@ -570,9 +568,9 @@ function writeLowCodeFiles(appData, appBuildDir, fileCodeMap, rootPath) {
|
|
|
570
568
|
let pageStyleString = '';
|
|
571
569
|
if (page) {
|
|
572
570
|
const pageClass = [rootPath, page.id].filter(Boolean).join('-');
|
|
573
|
-
pageStyleString =
|
|
571
|
+
pageStyleString = weapps_core_1.toCssText(weapps_core_1.toCssStyle(page.style), `.weapps-page-${pageClass}`);
|
|
574
572
|
}
|
|
575
|
-
code = yield
|
|
573
|
+
code = yield style_1.processLess(((themeCode === null || themeCode === void 0 ? void 0 : themeCode.code) || style_1.defaultThemeCode) + code);
|
|
576
574
|
}
|
|
577
575
|
if (mod.type === 'theme') {
|
|
578
576
|
return;
|
|
@@ -609,7 +607,7 @@ function generateCodeFromTpl(appKey, appData, appBuildDir, rootPath, extraData,
|
|
|
609
607
|
pageIds.push(p.id);
|
|
610
608
|
pageModules[p.id] = p.codeModules;
|
|
611
609
|
});
|
|
612
|
-
const yyptConfig = yield
|
|
610
|
+
const yyptConfig = yield util_1.getYyptConfigInfo(extraData);
|
|
613
611
|
const templatesData = {
|
|
614
612
|
'app/global-api.js': {
|
|
615
613
|
appId: appKey,
|
|
@@ -636,13 +634,13 @@ function generateCodeFromTpl(appKey, appData, appBuildDir, rootPath, extraData,
|
|
|
636
634
|
isProd: deployMode === types_1.DEPLOY_MODE.UPLOAD,
|
|
637
635
|
},
|
|
638
636
|
'datasources/datasource-profiles.js.tpl': {
|
|
639
|
-
datasourceProfiles: JSON.stringify(
|
|
637
|
+
datasourceProfiles: JSON.stringify(dataSource_1.getDatasourceProfiles(appData.datasources || []), null, 2),
|
|
640
638
|
},
|
|
641
639
|
'datasources/dataset-profiles.js.tpl': {
|
|
642
|
-
datasetProfiles:
|
|
640
|
+
datasetProfiles: util_1.JsonToStringWithVariableName(dataSource_1.getDatasetProfiles(appData, [appData]), { EOL: true }),
|
|
643
641
|
},
|
|
644
642
|
'utils/common.js': {
|
|
645
|
-
isAdminPortal:
|
|
643
|
+
isAdminPortal: common_1.buildAsAdminPortalByBuildType(buildTypeList),
|
|
646
644
|
},
|
|
647
645
|
};
|
|
648
646
|
if (!rootPath) {
|
|
@@ -656,7 +654,7 @@ function generateCodeFromTpl(appKey, appData, appBuildDir, rootPath, extraData,
|
|
|
656
654
|
process.exit();
|
|
657
655
|
}
|
|
658
656
|
const tplStr = template_1.default[filePath].code;
|
|
659
|
-
const generatedCode =
|
|
657
|
+
const generatedCode = lodash_template_1.default(tplStr)(templatesData[file]);
|
|
660
658
|
const outFile = path_1.default.resolve(appBuildDir, file.replace(/.tpl$/, ''));
|
|
661
659
|
fileCodeMap[outFile] = {
|
|
662
660
|
code: generatedCode,
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.generateCompLibs = exports.generateCode =
|
|
15
|
+
exports.generateCompLibs = exports.generateCode = void 0;
|
|
16
16
|
const generate_1 = require("./generate");
|
|
17
17
|
const material_1 = require("./material");
|
|
18
18
|
const template_1 = __importDefault(require("../template"));
|
|
@@ -41,9 +41,9 @@ function generateCode(props) {
|
|
|
41
41
|
fileCodeMap,
|
|
42
42
|
});
|
|
43
43
|
if (!isSandbox) {
|
|
44
|
-
yield
|
|
44
|
+
yield material_1.runHandleMaterial(appBuildDir, dependencies, i18nConfig, fileCodeMap, isSandbox);
|
|
45
45
|
}
|
|
46
|
-
yield
|
|
46
|
+
yield generate_1.runGenerateCore({
|
|
47
47
|
appBuildDir,
|
|
48
48
|
appData: mainAppData,
|
|
49
49
|
subAppDataList,
|
|
@@ -70,7 +70,7 @@ function generateCompLibs(compLibs) {
|
|
|
70
70
|
const isSandbox = true;
|
|
71
71
|
const i18nConfig = {};
|
|
72
72
|
const appBuildDir = '/';
|
|
73
|
-
yield
|
|
73
|
+
yield material_1.runHandleMaterial(appBuildDir, dependencies, i18nConfig, fileCodeMap, isSandbox);
|
|
74
74
|
const includeRegex = /^\/src\/(utils|handlers)/;
|
|
75
75
|
copyFiles({
|
|
76
76
|
appBuildDir,
|
|
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
15
|
if (mod && mod.__esModule) return mod;
|
|
16
16
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
@@ -65,7 +65,7 @@ function handleCompositeComponent({ dependencies, appBuildDir, i18nConfig, fileC
|
|
|
65
65
|
schemaVersion: item.schemaVersion,
|
|
66
66
|
}));
|
|
67
67
|
console.log('=====================================*****', materialGroupInfoMap);
|
|
68
|
-
const componentsInfoMap = yield
|
|
68
|
+
const componentsInfoMap = yield util_1.getComponentsInfo(path.join(appBuildDir, 'src'), dependencies, fileCodeMap);
|
|
69
69
|
yield writeLowCodeFilesForCompositeComp(compositeDependencies, appBuildDir, fileCodeMap, isSandbox);
|
|
70
70
|
yield genCompositeComponentLibraries(compositeDependencies, appBuildDir, materialGroupInfoMap, componentsInfoMap, i18nConfig, fileCodeMap, isSandbox);
|
|
71
71
|
});
|
|
@@ -73,7 +73,7 @@ function handleCompositeComponent({ dependencies, appBuildDir, i18nConfig, fileC
|
|
|
73
73
|
function writeLowCodeFilesForCompositeComp(compositeGroups, appBuildDir, fileMap, isSandbox) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
yield Promise.all(compositeGroups.map((gItem) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const common = yield
|
|
76
|
+
const common = yield util_1.writeLibCommonRes2file(gItem, path.join(appBuildDir, 'src', 'libraries', `${gItem.name}@${gItem.version}`, 'libCommonRes'));
|
|
77
77
|
Object.assign(fileMap, common);
|
|
78
78
|
const compLibCommonResource = gItem.compLibCommonResource;
|
|
79
79
|
let themeCode = '';
|
|
@@ -100,12 +100,12 @@ function writeLowCodeFilesForCompositeComp(compositeGroups, appBuildDir, fileMap
|
|
|
100
100
|
function writeCode2file(mod, lowcodeDir, comp, themeCode, isSandbox) {
|
|
101
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
102
|
const pageId = comp.name + '_' + comp.id;
|
|
103
|
-
const file = path.join(lowcodeDir,
|
|
103
|
+
const file = path.join(lowcodeDir, weapps_core_1.getCodeModuleFilePath(pageId, mod, {
|
|
104
104
|
style: '.css',
|
|
105
105
|
}));
|
|
106
106
|
let codeContent = '';
|
|
107
107
|
if (mod.type === 'style') {
|
|
108
|
-
codeContent = yield
|
|
108
|
+
codeContent = yield style_1.processLess(`.${weapps_core_1.getCompositedComponentClass(comp)} { \n${themeCode ? themeCode : ''}\n${mod.code}\n }`);
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
111
|
const importApp = !isSandbox
|
|
@@ -153,16 +153,16 @@ function genCompositeComponentLibraries(dependencies = [], appBuildDir, material
|
|
|
153
153
|
const librariesDir = path.join(appBuildDir, 'src/libraries', materialNameVersion);
|
|
154
154
|
yield Promise.all(components.map((compItem) => __awaiter(this, void 0, void 0, function* () {
|
|
155
155
|
compItem.materialName = name;
|
|
156
|
-
const wrapperClass =
|
|
156
|
+
const wrapperClass = weapps_core_1.getCompositedComponentClass(compItem);
|
|
157
157
|
const componentSchemaJson = {
|
|
158
158
|
type: 'object',
|
|
159
|
-
properties:
|
|
159
|
+
properties: weapps_core_1.readCmpInstances(compItem.componentInstances),
|
|
160
160
|
};
|
|
161
|
-
const { widgets, dataBinds, componentSchema, } =
|
|
161
|
+
const { widgets, dataBinds, componentSchema, } = generate_1.getComponentSchemaString(componentSchemaJson, true, componentsInfoMap, wrapperClass);
|
|
162
162
|
const templateData = {
|
|
163
163
|
id: compItem.id,
|
|
164
164
|
name: compItem.name,
|
|
165
|
-
defaultProps:
|
|
165
|
+
defaultProps: json_schema_defaults_1.default({
|
|
166
166
|
type: 'object',
|
|
167
167
|
properties: compItem.dataForm || {},
|
|
168
168
|
}),
|
|
@@ -191,8 +191,8 @@ function genCompositeComponentLibraries(dependencies = [], appBuildDir, material
|
|
|
191
191
|
moduleName,
|
|
192
192
|
name,
|
|
193
193
|
key: `${moduleName}:${name}`,
|
|
194
|
-
var:
|
|
195
|
-
moduleNameVar:
|
|
194
|
+
var: lodash_1.upperFirst(util_1.camelcase(`${moduleName}:${name}`)),
|
|
195
|
+
moduleNameVar: util_1.camelcase(moduleName),
|
|
196
196
|
version: compLib === null || compLib === void 0 ? void 0 : compLib.version,
|
|
197
197
|
isComposite: compLib === null || compLib === void 0 ? void 0 : compLib.isComposite,
|
|
198
198
|
isPlainProps,
|
|
@@ -201,12 +201,12 @@ function genCompositeComponentLibraries(dependencies = [], appBuildDir, material
|
|
|
201
201
|
}
|
|
202
202
|
return value;
|
|
203
203
|
});
|
|
204
|
-
return
|
|
204
|
+
return lodash_uniqby_1.default(list, 'key');
|
|
205
205
|
})(),
|
|
206
206
|
widgets,
|
|
207
207
|
dataBinds,
|
|
208
208
|
componentSchema,
|
|
209
|
-
pageListenerInstances:
|
|
209
|
+
pageListenerInstances: generate_1.getListenersString(compItem.listeners, true),
|
|
210
210
|
materialName: name,
|
|
211
211
|
hasComponentAPI: compItem.lowCodes.some((item) => item.type === 'index'),
|
|
212
212
|
isSandbox,
|
|
@@ -214,7 +214,7 @@ function genCompositeComponentLibraries(dependencies = [], appBuildDir, material
|
|
|
214
214
|
const dest = path.resolve(librariesDir, `./components/${compItem.name}/index.jsx`);
|
|
215
215
|
const template = template_1.default['/src/pages/composite.tpl'].code;
|
|
216
216
|
try {
|
|
217
|
-
const jsx =
|
|
217
|
+
const jsx = lodash_template_1.default(template, { interpolate: /<%=([\s\S]+?)%>/g })(templateData);
|
|
218
218
|
fileMap[dest] = {
|
|
219
219
|
code: jsx,
|
|
220
220
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildAsXPageByBuildType = exports.buildAsAdminPortalByBuildType = exports.buildAsWebByBuildType = void 0;
|
|
4
|
-
|
|
4
|
+
exports.buildAsWebByBuildType = (buildTypeList = []) => {
|
|
5
5
|
return (buildTypeList.includes("web") ||
|
|
6
6
|
buildTypeList.includes("pc") ||
|
|
7
7
|
buildTypeList.includes("adminPortal") ||
|
|
@@ -10,12 +10,9 @@ const buildAsWebByBuildType = (buildTypeList = []) => {
|
|
|
10
10
|
buildTypeList.includes("wxH5") ||
|
|
11
11
|
buildTypeList.includes("xPagePC"));
|
|
12
12
|
};
|
|
13
|
-
exports.
|
|
14
|
-
const buildAsAdminPortalByBuildType = (buildTypeList = []) => {
|
|
13
|
+
exports.buildAsAdminPortalByBuildType = (buildTypeList = []) => {
|
|
15
14
|
return buildTypeList.includes("adminPortal");
|
|
16
15
|
};
|
|
17
|
-
exports.
|
|
18
|
-
const buildAsXPageByBuildType = (buildTypeList = []) => {
|
|
16
|
+
exports.buildAsXPageByBuildType = (buildTypeList = []) => {
|
|
19
17
|
return buildTypeList.includes("xPagePC");
|
|
20
18
|
};
|
|
21
|
-
exports.buildAsXPageByBuildType = buildAsXPageByBuildType;
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./common"), exports);
|
|
@@ -46,7 +46,7 @@ exports.defaultThemeCode = `
|
|
|
46
46
|
function processLess(lessCode) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
48
|
const { css: lessCss } = yield less_1.default.render(lessCode);
|
|
49
|
-
const { css: remCss } = yield
|
|
49
|
+
const { css: remCss } = yield postcss_1.default([postcss_pxtorem_1.default(config_1.remConfig)]).process(lessCss);
|
|
50
50
|
return remCss;
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -54,7 +54,7 @@ exports.processLess = processLess;
|
|
|
54
54
|
function processLessToRpx(lessCode) {
|
|
55
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
56
|
const { css: lessCss } = yield less_1.default.render(lessCode);
|
|
57
|
-
const { css: rpxCss } = yield
|
|
57
|
+
const { css: rpxCss } = yield postcss_1.default([postcss_rpx_1.default(config_1.rpxConfig)]).process(lessCss);
|
|
58
58
|
return rpxCss;
|
|
59
59
|
});
|
|
60
60
|
}
|