@cloudbase/lowcode-builder 1.8.23 → 1.8.24-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/dist/builder.web.js +7 -7
- package/lib/builder/config/index.d.ts +2 -2
- package/lib/builder/config/index.js +2 -2
- package/lib/builder/h5/index.d.ts +1 -5
- package/lib/builder/h5/index.js +5 -64
- package/lib/builder/h5/webpack.js +1 -1
- package/lib/builder/mp/index.js +7 -17
- package/lib/builder/mp/util.js +8 -11
- package/lib/builder/types/common.d.ts +1 -1
- package/lib/builder/util/common.d.ts +1 -1
- package/lib/builder/util/process.js +15 -12
- package/lib/builder.web.js +7 -7
- package/package.json +5 -4
- package/template/mp/app/weapps-api.js +1 -1
- package/template/mp/common/query.js +24 -9
- package/template/mp/common/util.js +4 -4
- package/template/mp/page/index.js +1 -1
- package/lib/utils/transform.d.ts +0 -3
- package/lib/utils/transform.js +0 -52
- package/template/.DS_Store +0 -0
- package/template/mp/.DS_Store +0 -0
- package/template/mp/common/.DS_Store +0 -0
|
@@ -6,12 +6,12 @@ export declare const materialsDirName = "materials";
|
|
|
6
6
|
* src/template的代码,在IDE编辑器插件中构建builder
|
|
7
7
|
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
8
8
|
*/
|
|
9
|
-
export declare const builderTemplateURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.1.8.
|
|
9
|
+
export declare const builderTemplateURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.1.8.13.zip";
|
|
10
10
|
/**
|
|
11
11
|
* miniprogram的代码,IDE插件后续会提供端功能
|
|
12
12
|
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
13
13
|
*/
|
|
14
|
-
export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/
|
|
14
|
+
export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm_20230606.zip";
|
|
15
15
|
/**
|
|
16
16
|
* miniprogram_npm存放目录。IDE插件builder用到
|
|
17
17
|
*/
|
|
@@ -45,12 +45,12 @@ exports.materialsDirName = 'materials'; // materials diretory of current project
|
|
|
45
45
|
* src/template的代码,在IDE编辑器插件中构建builder
|
|
46
46
|
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
47
47
|
*/
|
|
48
|
-
exports.builderTemplateURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.1.8.
|
|
48
|
+
exports.builderTemplateURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.1.8.13.zip';
|
|
49
49
|
/**
|
|
50
50
|
* miniprogram的代码,IDE插件后续会提供端功能
|
|
51
51
|
* 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488®ion=ap-shanghai&path=%252Flcap-builder%252F
|
|
52
52
|
*/
|
|
53
|
-
exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/
|
|
53
|
+
exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm_20230606.zip';
|
|
54
54
|
/**
|
|
55
55
|
* miniprogram_npm存放目录。IDE插件builder用到
|
|
56
56
|
*/
|
|
@@ -5,7 +5,7 @@ import { IPlatformApp } from '@cloudbase/cals';
|
|
|
5
5
|
import { ICDN_ENDPOINTS_COFIG } from '../config';
|
|
6
6
|
import { IBuildContext } from '../mp/BuildContext';
|
|
7
7
|
import { IBuildWedaApp } from '../core';
|
|
8
|
-
export declare function buildH5App({ buildContext, i18nConfig, extraData, cals
|
|
8
|
+
export declare function buildH5App({ buildContext, i18nConfig, extraData, cals, buildTypeList, subAppCalsList, mode, devTool, runtime, deployOptions, ignoreInstall, cdnEndpoints, }: {
|
|
9
9
|
buildContext: Omit<IBuildContext, 'mainAppData'>;
|
|
10
10
|
cals: IPlatformApp;
|
|
11
11
|
subAppCalsList: IPlatformApp[];
|
|
@@ -19,7 +19,3 @@ export declare function buildH5App({ buildContext, i18nConfig, extraData, cals:
|
|
|
19
19
|
ignoreInstall?: boolean;
|
|
20
20
|
cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
|
|
21
21
|
}): Promise<string>;
|
|
22
|
-
/**
|
|
23
|
-
* 导出进行单测
|
|
24
|
-
*/
|
|
25
|
-
export declare function _BabelTransformCalsExpression(key: any, value: any): any;
|
package/lib/builder/h5/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.buildH5App = void 0;
|
|
30
30
|
const path_1 = __importDefault(require("path"));
|
|
31
31
|
const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
32
32
|
const material_1 = require("./material");
|
|
@@ -45,8 +45,7 @@ const config_1 = require("../config");
|
|
|
45
45
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
46
46
|
const junk = __importStar(require("../util/junk"));
|
|
47
47
|
const url_1 = require("url");
|
|
48
|
-
|
|
49
|
-
async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, buildTypeList = [common_1.BuildType.WEB], subAppCalsList, mode, devTool, runtime = types_1.RUNTIME.NONE, deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, ignoreInstall = false, cdnEndpoints, }) {
|
|
48
|
+
async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildTypeList = [common_1.BuildType.WEB], subAppCalsList, mode, devTool, runtime = types_1.RUNTIME.NONE, deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, ignoreInstall = false, cdnEndpoints, }) {
|
|
50
49
|
var _a, _b, _c;
|
|
51
50
|
const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode } = buildContext;
|
|
52
51
|
if (!deployOptions.mode) {
|
|
@@ -58,12 +57,11 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
|
|
|
58
57
|
if (buildTypeList.includes(common_1.BuildType.APP) ||
|
|
59
58
|
buildTypeList.includes(common_1.BuildType.XPAGE_PC) ||
|
|
60
59
|
buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL)) {
|
|
61
|
-
if (!
|
|
62
|
-
|
|
60
|
+
if (!cals.extra) {
|
|
61
|
+
cals.extra = {};
|
|
63
62
|
}
|
|
64
|
-
|
|
63
|
+
cals.extra.historyType = types_1.HISTORY_TYPE.HASH;
|
|
65
64
|
}
|
|
66
|
-
const cals = processCals(_cals);
|
|
67
65
|
const mainAppSerializeData = (0, common_2.processCals2WeappsData)(cals, dependencies);
|
|
68
66
|
const subAppSerializeDataList = (subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map((item) => (0, common_2.processCals2WeappsData)(item, dependencies))) || [];
|
|
69
67
|
const { allAppUsedComps } = (0, mp_1.handleUsedComponents)({
|
|
@@ -201,60 +199,3 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
|
|
|
201
199
|
}
|
|
202
200
|
}
|
|
203
201
|
exports.buildH5App = buildH5App;
|
|
204
|
-
function processCals(cals) {
|
|
205
|
-
return walkThroughJson(cals, (key, value, prefix) => {
|
|
206
|
-
return _BabelTransformCalsExpression(key, value);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function _isPlainObj(obj) {
|
|
210
|
-
return typeof obj === 'object' && obj !== null;
|
|
211
|
-
}
|
|
212
|
-
function walkThroughJson(obj, callback, path = '') {
|
|
213
|
-
/**
|
|
214
|
-
* 跳过数据源 state 的处理
|
|
215
|
-
*/
|
|
216
|
-
if (/dataset\.state$/.test(path)) {
|
|
217
|
-
return obj;
|
|
218
|
-
}
|
|
219
|
-
if (typeof obj === 'object' && Array.isArray(obj)) {
|
|
220
|
-
return obj.map((item, index) => {
|
|
221
|
-
const prefix = path ? `${path}.${index}` : String(index);
|
|
222
|
-
return _isPlainObj(item) ? walkThroughJson(item, callback, prefix) : callback(index, item, prefix);
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
for (const key in obj) {
|
|
226
|
-
const value = obj[key];
|
|
227
|
-
const prefix = path ? `${path}.${key}` : key;
|
|
228
|
-
obj[key] = _isPlainObj(value) ? walkThroughJson(value, callback, prefix) : callback(key, value, prefix);
|
|
229
|
-
}
|
|
230
|
-
return obj;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* 导出进行单测
|
|
234
|
-
*/
|
|
235
|
-
function _BabelTransformCalsExpression(key, value) {
|
|
236
|
-
const DYNAMIC_REG = /^:(.*)$/;
|
|
237
|
-
const FOR_IN_REG = /^(.*?in\s)/;
|
|
238
|
-
if (DYNAMIC_REG.test(key)) {
|
|
239
|
-
try {
|
|
240
|
-
let forPrefix = '';
|
|
241
|
-
if (key === ':for') {
|
|
242
|
-
const matched = value.match(FOR_IN_REG) || [];
|
|
243
|
-
forPrefix = matched[0];
|
|
244
|
-
if (forPrefix) {
|
|
245
|
-
value = value.replace(FOR_IN_REG, '');
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
value = (0, transform_1.BabelTransform)(value, { IIFE: true });
|
|
249
|
-
if (forPrefix) {
|
|
250
|
-
value = `${forPrefix}${value}`;
|
|
251
|
-
}
|
|
252
|
-
return value;
|
|
253
|
-
}
|
|
254
|
-
catch (e) {
|
|
255
|
-
return value;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return value;
|
|
259
|
-
}
|
|
260
|
-
exports._BabelTransformCalsExpression = _BabelTransformCalsExpression;
|
|
@@ -30,7 +30,7 @@ async function runWebpackCore({ cals, mainAppData, subAppDataList, appBuildDir,
|
|
|
30
30
|
await (0, generate_1.generateHTML)({
|
|
31
31
|
appId: mainAppData.id || appKey,
|
|
32
32
|
envId: mainAppData.envId || '',
|
|
33
|
-
description: cals.description || cals.label || '',
|
|
33
|
+
description: cals.description /* || cals.label */ || '',
|
|
34
34
|
enableLoading: (_a = cals.extra) === null || _a === void 0 ? void 0 : _a.enableLoading,
|
|
35
35
|
appBuildDir,
|
|
36
36
|
externalResources: (cals.externalResources || []).concat(assets.map((url) => ({
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -106,7 +106,11 @@ async function generateWxMp({ buildContext, weapps, plugins, deployOptions, opti
|
|
|
106
106
|
isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
|
|
107
107
|
},
|
|
108
108
|
'common/widget.js': {},
|
|
109
|
-
'common/
|
|
109
|
+
'common/url.js': {},
|
|
110
|
+
'common/weapp-page.js': {
|
|
111
|
+
dataPropNames: wxmlDataPrefix,
|
|
112
|
+
debug: buildContext.debugMode,
|
|
113
|
+
},
|
|
110
114
|
'common/weapp-component.js': {},
|
|
111
115
|
'common/merge-renderer.js': {
|
|
112
116
|
dataPropNames: wxmlDataPrefix,
|
|
@@ -306,21 +310,12 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
306
310
|
console.log(`Generating ${em('page')} files`);
|
|
307
311
|
(0, generateFiles_1.cleanDir)(path_1.default.join(appRoot, 'pages'), []);
|
|
308
312
|
await Promise.all(weapp.pageInstanceList.map(async (page) => {
|
|
309
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
313
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
310
314
|
// # Generating page
|
|
311
315
|
const rootPath = weapp.rootPath || '';
|
|
312
316
|
const usingComponents = {};
|
|
313
317
|
const componentGenerics = {};
|
|
314
318
|
const componentInstances = (0, util_2.processRepeaterSchema)(ctx, page.componentInstances);
|
|
315
|
-
const { allAppUsedComps = [] } = handleUsedComponents({
|
|
316
|
-
buildContext: ctx,
|
|
317
|
-
weapps: [
|
|
318
|
-
{
|
|
319
|
-
...weapp,
|
|
320
|
-
pageInstanceList: [page],
|
|
321
|
-
},
|
|
322
|
-
],
|
|
323
|
-
});
|
|
324
319
|
const wxml = (0, wxml_1.generateWxml)({ ...ctx, rootPath, isPage: true }, componentInstances, `Page ${rootPath ? path_1.default.join(rootPath, 'pages') : ''}/${page.id}`, wxmlDataPrefix, usingComponents, componentGenerics);
|
|
325
320
|
const importor = (0, util_3.generateLowcodeImportor)(page.lowCodes);
|
|
326
321
|
const pageFileName = (0, lodash_1.get)(pageConfigs, `${page.id}.pageFileName`, 'index');
|
|
@@ -348,11 +343,6 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
348
343
|
importor,
|
|
349
344
|
query: (0, util_2.createTemplateQuery)(ctx, (_f = page.dataset) === null || _f === void 0 ? void 0 : _f.query),
|
|
350
345
|
eventFlows: (0, util_2.createTemplateEventFlows)(ctx, page.eventFlows),
|
|
351
|
-
resetShare: ((_j = (_h = (_g = page === null || page === void 0 ? void 0 : page.data) === null || _g === void 0 ? void 0 : _g.appShareMessage) === null || _h === void 0 ? void 0 : _h.value) === null || _j === void 0 ? void 0 : _j.enable) ||
|
|
352
|
-
((_k = allAppUsedComps === null || allAppUsedComps === void 0 ? void 0 : allAppUsedComps[cals_1.OFFICIAL_LIB_KEY]) === null || _k === void 0 ? void 0 : _k.has('Share')) ||
|
|
353
|
-
/* 从 enablePageRoot 的版本开始支持按需reset share
|
|
354
|
-
* 否则默认都开启
|
|
355
|
-
*/ !ctx.enablePageRoot,
|
|
356
346
|
},
|
|
357
347
|
[`index.json|${pageFileName}.json`]: {
|
|
358
348
|
usingComponents,
|
|
@@ -363,7 +353,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
363
353
|
content: wxml,
|
|
364
354
|
},
|
|
365
355
|
[`index.wxss|${pageFileName}.wxss`]: {
|
|
366
|
-
subWxss: rootPath && !((
|
|
356
|
+
subWxss: rootPath && !((_g = ctx.mainAppData) === null || _g === void 0 ? void 0 : _g.mpPkgUrl)
|
|
367
357
|
? `@import "${path_1.default.posix.relative(`/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
|
|
368
358
|
: '',
|
|
369
359
|
content: (0, weapps_core_1.toCssText)((0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
|
package/lib/builder/mp/util.js
CHANGED
|
@@ -9,24 +9,21 @@ const mp_1 = require("@cloudbase/lowcode-generator/lib/generator/config/mp");
|
|
|
9
9
|
const cals_1 = require("@cloudbase/cals");
|
|
10
10
|
const config_1 = require("../config");
|
|
11
11
|
function extractWidgetProps(props, compInfo, processCssUnit = 'rpx') {
|
|
12
|
-
var _a, _b
|
|
13
|
-
const { classList, staticResourceAttribute = []
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const { classList, staticResourceAttribute = [] } = props;
|
|
14
14
|
const staticProps = {
|
|
15
|
-
style:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...(0, cals_1.processCommonStyle2CSSProperties)(props.commonStyle || {}, {
|
|
19
|
-
defaultUnit: processCssUnit,
|
|
20
|
-
}),
|
|
21
|
-
},
|
|
15
|
+
style: (0, cals_1.processCommonStyle2CSSProperties)(props.commonStyle, {
|
|
16
|
+
defaultUnit: processCssUnit,
|
|
17
|
+
}),
|
|
22
18
|
classList: classList || [],
|
|
23
19
|
};
|
|
24
20
|
if (staticResourceAttribute === null || staticResourceAttribute === void 0 ? void 0 : staticResourceAttribute.length) {
|
|
25
21
|
staticProps._staticResourceAttribute = staticResourceAttribute;
|
|
26
22
|
}
|
|
23
|
+
const { data = {} } = props;
|
|
27
24
|
Object.assign(staticProps, generatedDynamicData(data, compInfo).staticProps);
|
|
28
|
-
if ((
|
|
29
|
-
staticProps._waForKey = (
|
|
25
|
+
if ((_a = props.directives) === null || _a === void 0 ? void 0 : _a.waForKey) {
|
|
26
|
+
staticProps._waForKey = (_b = props.directives) === null || _b === void 0 ? void 0 : _b.waForKey.value;
|
|
30
27
|
}
|
|
31
28
|
return staticProps;
|
|
32
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { BuildType, GenerateMpType, WebpackModeType, WebpackBuildCallBack, IPackageJson, buildAsWebByBuildType, buildAsAdminPortalByBuildType, buildAsXPageByBuildType, IAppUsedComp, IUsedComps, ISyncProp, IComponentInputProps, IFileCodeMap, } from '@cloudbase/lowcode-generator/lib/generator/types/common';
|
|
2
2
|
import { IComponentMeta, ICompositedComponent } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
3
|
-
export type IComponentsInfoMap = {
|
|
3
|
+
export declare type IComponentsInfoMap = {
|
|
4
4
|
[componentSourceKey: string]: ({
|
|
5
5
|
meta: IComponentMeta;
|
|
6
6
|
} & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IComponentInputProps, IComponentsInfoMap, IPackageJson } from '../types/common';
|
|
2
2
|
import { IMaterialItem, IWeAppComponentInstance, IWeAppCode } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
3
3
|
export { getMetaInfoBySourceKey, isArray, isPlainObject, deepDeal, simpleDeepClone, deepDealSchema, getFileNameByUrl, } from '@cloudbase/lowcode-generator/lib/generator/util/common';
|
|
4
|
-
type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
|
|
4
|
+
declare type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
|
|
5
5
|
export declare function promiseWrapper<T>(p: Promise<T>): PromiseResult<T>;
|
|
6
6
|
export declare function getCurrentPackageJson(): {
|
|
7
7
|
name: any;
|
|
@@ -3,22 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.promisifyProcess = void 0;
|
|
4
4
|
function promisifyProcess(p, opts = {}) {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
6
|
-
var _a, _b, _c, _d;
|
|
7
6
|
let stdout = '';
|
|
8
7
|
let stderr = '';
|
|
9
|
-
|
|
10
|
-
(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
p.stdout &&
|
|
9
|
+
p.stdout.on('data', opts.onStdout ||
|
|
10
|
+
((data) => {
|
|
11
|
+
console.log(data + '');
|
|
12
|
+
stdout += data;
|
|
13
|
+
}));
|
|
14
|
+
p.stderr &&
|
|
15
|
+
p.stderr.on('data', opts.onStderr ||
|
|
16
|
+
((data) => {
|
|
17
|
+
console.error(data + '');
|
|
18
|
+
stderr += data;
|
|
19
|
+
}));
|
|
19
20
|
p.on('error', reject);
|
|
20
21
|
p.on('exit', (exitCode) => {
|
|
21
|
-
exitCode === 0
|
|
22
|
+
exitCode === 0
|
|
23
|
+
? resolve(exitCode)
|
|
24
|
+
: reject(new Error(stderr || String(exitCode)));
|
|
22
25
|
});
|
|
23
26
|
});
|
|
24
27
|
}
|