@cloudbase/lowcode-builder 1.8.95 → 1.8.96
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/core/index.d.ts +9 -0
- package/lib/builder/core/index.js +118 -1
- package/lib/builder/h5/generate.d.ts +1 -1
- package/lib/builder/h5/index.d.ts +2 -2
- package/lib/builder/h5/webpack.d.ts +2 -2
- package/lib/builder/mp/BuildContext.d.ts +18 -14
- package/lib/builder/mp/index.d.ts +11 -1
- package/lib/builder/mp/index.js +97 -84
- package/lib/builder/mp/lowcode.d.ts +5 -3
- package/lib/builder/mp/lowcode.js +14 -5
- package/lib/builder/mp/materials.d.ts +10 -5
- package/lib/builder/mp/materials.js +139 -135
- package/lib/builder/mp/util.d.ts +15 -12
- package/lib/builder/mp/util.js +50 -22
- package/lib/builder/mp/wxml.d.ts +5 -3
- package/lib/builder/mp/wxml.js +29 -27
- package/lib/builder/service/webpack.js +0 -1
- package/lib/builder/util/common.d.ts +0 -1
- package/lib/builder/util/common.js +1 -44
- package/lib/builder/util/generateFiles.d.ts +1 -1
- package/lib/builder/util/generateFiles.js +5 -1
- package/lib/builder.web.js +8 -8
- package/package.json +2 -2
- package/template/html/index.html.ejs +7 -3
- package/template/mp/app/weapps-api.js +1 -1
- package/template/mp/app.js +4 -2
- package/template/mp/common/cloud-sdk.js +28 -0
- package/template/mp/common/data-patch.js +9 -1
- package/template/mp/common/util.js +6 -2
- package/template/mp/common/watch.js +1 -1
- package/template/mp/common/weapp-component.js +5 -5
- package/template/mp/common/weapp-page.js +4 -3
- package/template/mp/common/widget.js +51 -38
- package/template/mp/component/index.js +7 -6
- package/template/mp/datasources/index.js.tpl +2 -30
- package/template/mp/package.json +2 -2
- package/template/webpack/web.prod.js +1 -1
package/lib/builder/mp/wxml.js
CHANGED
|
@@ -194,35 +194,37 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
194
194
|
}
|
|
195
195
|
const componentKey = `${xComponent.moduleName}:${xComponent.name}`;
|
|
196
196
|
const helpMsg = `Please check component(${id}) in component tree of ${docTag}.`;
|
|
197
|
-
let tagName, path
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
197
|
+
let tagName, path;
|
|
198
|
+
const componentProto = (0, util_1.findComponentInfo)(xComponent, {
|
|
199
|
+
materialLibs: ctx.materialLibs,
|
|
200
|
+
miniprogramPlugins: ctx.miniprogramPlugins,
|
|
201
|
+
});
|
|
202
|
+
const simpleWidget = {
|
|
203
|
+
widgetType: componentKey,
|
|
204
|
+
getConfig: () => {
|
|
205
|
+
return (componentProto === null || componentProto === void 0 ? void 0 : componentProto.compConfig) || {};
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
if ((0, util_1.isRepeaterWidget)(simpleWidget, config_1.REPEATER.REPEATER_NAME)) {
|
|
209
|
+
const children = createXml(properties, parent, parentForNodes);
|
|
210
|
+
for (let item of children) {
|
|
211
|
+
item._order = xIndex || 0;
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
path = meta.path;
|
|
213
|
+
elements.push(...children);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
else if ((0, util_1.isRepeaterWidget)(simpleWidget, config_1.REPEATER.REPEATER_ITEM_NAME)) {
|
|
217
|
+
tagName = 'block';
|
|
218
|
+
path = '';
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
if (!componentProto) {
|
|
222
|
+
console.error(error(`Component(${xComponent.name}) not found in lib(${xComponent.moduleName}). ${helpMsg}`));
|
|
223
|
+
continue;
|
|
225
224
|
}
|
|
225
|
+
const meta = (0, materials_1.getWxmlTag)(ctx, xComponent, nameMangler);
|
|
226
|
+
tagName = meta.tagName;
|
|
227
|
+
path = meta.path;
|
|
226
228
|
}
|
|
227
229
|
if (genericComp === null || genericComp === void 0 ? void 0 : genericComp.propName) {
|
|
228
230
|
tagName = getGenericCompTagName(genericComp.propName);
|
|
@@ -259,7 +259,6 @@ async function downloadDependencies(targetDir, srcZipUrl) {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
exports.downloadDependencies = downloadDependencies;
|
|
262
|
-
// TODO use yarn if installed
|
|
263
262
|
async function installDependencies(targetDir, options = {}) {
|
|
264
263
|
var _a;
|
|
265
264
|
let yarnExists = false;
|
|
@@ -14,7 +14,6 @@ export declare function JsonToStringWithVariableName(copyJson: any, options?: {
|
|
|
14
14
|
export declare function requireUncached(module: any): any;
|
|
15
15
|
export declare function removeRequireUncached(path?: string): void;
|
|
16
16
|
export declare function getInputProps(componentsMetaMap: IComponentsInfoMap): IComponentInputProps;
|
|
17
|
-
export declare function getComponentsInfo(appBuildDir: string, dependencies: IMaterialItem[]): Promise<IComponentsInfoMap>;
|
|
18
17
|
export declare function getYyptConfigInfo(extraData: any): Promise<{
|
|
19
18
|
yyptAppKey: any;
|
|
20
19
|
reportUrl: any;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizeWedaRoot = exports.normalizePackageName = exports.generateLowcodeImportor = exports.getCompileDirs = exports.deepDealComponentSchemaJson = exports.canUseVite = exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.
|
|
6
|
+
exports.normalizeWedaRoot = exports.normalizePackageName = exports.generateLowcodeImportor = exports.getCompileDirs = exports.deepDealComponentSchemaJson = exports.canUseVite = exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
7
7
|
// import * as R from 'ramda'
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -99,49 +99,6 @@ function getInputProps(componentsMetaMap) {
|
|
|
99
99
|
return outputObj;
|
|
100
100
|
}
|
|
101
101
|
exports.getInputProps = getInputProps;
|
|
102
|
-
async function getComponentsInfo(appBuildDir, dependencies) {
|
|
103
|
-
const outputObj = {};
|
|
104
|
-
await Promise.all(dependencies.map(async ({ name: materialName, version, components = [], isComposite }) => {
|
|
105
|
-
if (isComposite) {
|
|
106
|
-
components.forEach((component) => {
|
|
107
|
-
let { lowCodes, componentInstances, ...compItem } = component;
|
|
108
|
-
const sourceKey = `${materialName}:${compItem.name}`;
|
|
109
|
-
outputObj[sourceKey] = {
|
|
110
|
-
isComposite,
|
|
111
|
-
...compItem,
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const materialComponentsPath = path_1.default.resolve(appBuildDir, `src/libraries/${materialName}@${version}/components`);
|
|
117
|
-
const componentLibPath = path_1.default.resolve(appBuildDir, `src/libraries/${materialName}@${version}`);
|
|
118
|
-
const meta = readComponentLibMata(componentLibPath);
|
|
119
|
-
if (meta) {
|
|
120
|
-
const { components: componentsMap } = meta;
|
|
121
|
-
for (let name in componentsMap) {
|
|
122
|
-
const sourceKey = `${materialName}:${name}`;
|
|
123
|
-
let metaJson = componentsMap[name];
|
|
124
|
-
outputObj[sourceKey] = { isComposite, ...metaJson };
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
// 老格式,需要从子目录下读取
|
|
129
|
-
const components = await fs_extra_1.default.readdir(materialComponentsPath);
|
|
130
|
-
await Promise.all(components.map(async (name) => {
|
|
131
|
-
const sourceKey = `${materialName}:${name}`;
|
|
132
|
-
const componentMetaPath = `${materialComponentsPath}/${name}/meta.json`;
|
|
133
|
-
let metaJson = {
|
|
134
|
-
name,
|
|
135
|
-
meta: await fs_extra_1.default.readJson(componentMetaPath),
|
|
136
|
-
};
|
|
137
|
-
outputObj[sourceKey] = { isComposite, ...metaJson };
|
|
138
|
-
}));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}));
|
|
142
|
-
return outputObj;
|
|
143
|
-
}
|
|
144
|
-
exports.getComponentsInfo = getComponentsInfo;
|
|
145
102
|
async function getYyptConfigInfo(extraData) {
|
|
146
103
|
let configJson;
|
|
147
104
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { OutputType } from 'jszip';
|
|
3
3
|
export declare const generatedFileContents: {};
|
|
4
|
-
export default function generateFiles(appFileData: any, srcDir: string, dstDir: string): Promise<void>;
|
|
4
|
+
export default function generateFiles(appFileData: any, srcDir: string, dstDir: string, filter?: (src: any) => boolean): Promise<void>;
|
|
5
5
|
export declare function writeFile(outFile: string, content: string): Promise<boolean>;
|
|
6
6
|
export declare function removeFile(file: string): void;
|
|
7
7
|
/**
|
|
@@ -35,7 +35,7 @@ const glob_1 = __importDefault(require("glob"));
|
|
|
35
35
|
const jszip_1 = __importDefault(require("jszip"));
|
|
36
36
|
const buffer_1 = require("buffer");
|
|
37
37
|
exports.generatedFileContents = {}; // generated files for incrmental build
|
|
38
|
-
async function generateFiles(appFileData, srcDir, dstDir) {
|
|
38
|
+
async function generateFiles(appFileData, srcDir, dstDir, filter = (src) => true) {
|
|
39
39
|
const filesGenerated = [];
|
|
40
40
|
// Generating file by template and data
|
|
41
41
|
for (const file in appFileData) {
|
|
@@ -43,6 +43,10 @@ async function generateFiles(appFileData, srcDir, dstDir) {
|
|
|
43
43
|
const srcFileName = fileNameList[0];
|
|
44
44
|
const outFileName = fileNameList[1] || fileNameList[0];
|
|
45
45
|
const srcePath = path_1.default.join(srcDir, srcFileName);
|
|
46
|
+
const use = filter ? filter(srcePath) : true;
|
|
47
|
+
if (!use) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
46
50
|
if (fs_extra_1.default.lstatSync(srcePath).isDirectory()) {
|
|
47
51
|
(0, exports.copyRecursiveSync)(srcePath, path_1.default.join(dstDir, outFileName));
|
|
48
52
|
}
|