@cloudbase/lowcode-builder 1.8.96 → 1.8.98
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.js +3 -5
- package/lib/builder/mp/index.d.ts +4 -4
- package/lib/builder/mp/index.js +20 -19
- package/lib/builder/mp/lowcode.d.ts +1 -1
- package/lib/builder/mp/util.js +3 -1
- package/lib/builder/mp/wxml.js +1 -0
- package/lib/builder.web.js +6 -6
- package/package.json +2 -2
- package/template/html/index.html.ejs +1 -1
- package/template/mp/app/weapps-api.js +2 -0
- package/template/mp/app.js +1 -3
- package/template/mp/common/query.js +102 -78
- package/template/mp/common/util.js +5 -0
- package/template/mp/package.json +4 -3
- package/template/mp/packages/$wd_system/pages/login/index.wxml +1 -1
- package/template/mp/page/index.json +1 -0
|
@@ -324,7 +324,7 @@ function normalizeInputs(inputs, { envId, getWebRootPath, }) {
|
|
|
324
324
|
}
|
|
325
325
|
exports.normalizeInputs = normalizeInputs;
|
|
326
326
|
function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWebRootPath }) {
|
|
327
|
-
var _a
|
|
327
|
+
var _a;
|
|
328
328
|
if (!cals.extra) {
|
|
329
329
|
cals.extra = {};
|
|
330
330
|
}
|
|
@@ -335,9 +335,7 @@ function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWe
|
|
|
335
335
|
cals.extra.historyType = types_1.HISTORY_TYPE.HASH;
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
|
|
339
|
-
cals.extra.envId = envId;
|
|
340
|
-
}
|
|
338
|
+
cals.extra.envId = envId;
|
|
341
339
|
if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
|
|
342
340
|
// web 构建不处理小程序插件
|
|
343
341
|
if (cals.extra.miniprogramPlugins) {
|
|
@@ -352,7 +350,7 @@ function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWe
|
|
|
352
350
|
...window,
|
|
353
351
|
// Todo: 处理自定义域名逻辑
|
|
354
352
|
publicPath: (0, common_1.buildAsXPageByBuildType)(buildTypeList)
|
|
355
|
-
? (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.publicPath) || `https://${(
|
|
353
|
+
? (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.publicPath) || `https://${(_a = cals.extra) === null || _a === void 0 ? void 0 : _a.domain}${path}`
|
|
356
354
|
: path,
|
|
357
355
|
basename: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList)
|
|
358
356
|
? `app/${appId}${(deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) !== types_1.DEPLOY_MODE.UPLOAD ? '-preview' : ''}`
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { IWeAppData, IPlugin } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
1
|
+
import { IWeAppData, IPlugin, CSSProperties } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { ICDN_ENDPOINTS_COFIG } from '../config';
|
|
3
3
|
import { IBuildContext, IMpCommonBuildContext } from './BuildContext';
|
|
4
4
|
import { BuildType } from '../types/common';
|
|
5
5
|
import { IPlatformApp } from '@cloudbase/cals';
|
|
6
6
|
import { IBuildWedaApp } from '../core';
|
|
7
|
-
export declare function generateWedaRootCommonFile({ buildContext, buildTypeList, localWedaRoot, loginConfigVersion,
|
|
7
|
+
export declare function generateWedaRootCommonFile({ buildContext, buildTypeList, localWedaRoot, loginConfigVersion, cssVarMap, appId, nativeMode, filter, }: {
|
|
8
8
|
buildContext: IMpCommonBuildContext & Partial<Pick<IBuildContext, 'enableExpiredTag' | 'domain' | 'runtimeDynamicConfig'>>;
|
|
9
9
|
buildTypeList: BuildType[];
|
|
10
10
|
localWedaRoot: string;
|
|
11
11
|
appId?: string;
|
|
12
12
|
loginConfigVersion?: string;
|
|
13
|
-
|
|
13
|
+
cssVarMap?: Object;
|
|
14
14
|
nativeMode?: boolean;
|
|
15
15
|
filter?: (src: string) => boolean;
|
|
16
16
|
}): Promise<void>;
|
|
@@ -37,4 +37,4 @@ export declare function generateConfig(data: {
|
|
|
37
37
|
isPrivateMode?: boolean;
|
|
38
38
|
endpointType?: IBuildContext['endpointType'] | '';
|
|
39
39
|
}, root: string): Promise<void>;
|
|
40
|
-
export declare function writeLowCodeFiles(ctx: IBuildContext, appData: IWeAppData, outDir: string): Promise<void>;
|
|
40
|
+
export declare function writeLowCodeFiles(ctx: IBuildContext, appData: IWeAppData, outDir: string, cssVarMap?: CSSProperties): Promise<void>;
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -66,18 +66,9 @@ function patchBuildContext(ctx, calses) {
|
|
|
66
66
|
ctx.miniprogramPlugins = (mainAppData.miniprogramPlugins || []).filter((plugin) => used.component[plugin.name] || used.action[plugin.name]);
|
|
67
67
|
return { used };
|
|
68
68
|
}
|
|
69
|
-
async function generateWedaRootCommonFile({ buildContext, buildTypeList, localWedaRoot, loginConfigVersion,
|
|
69
|
+
async function generateWedaRootCommonFile({ buildContext, buildTypeList, localWedaRoot, loginConfigVersion, cssVarMap, appId, nativeMode, filter = () => true, }) {
|
|
70
70
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!buildContext.isProduction);
|
|
71
71
|
const expirationStartTimesnap = buildContext.enableExpiredTag ? Date.now() : 0;
|
|
72
|
-
const cssVarMap = Object.entries((0, theme_1.mergeCssVarConfig)(cssVarConfig, 'MP'))
|
|
73
|
-
.map(([key, _value]) => {
|
|
74
|
-
const value = _value || '';
|
|
75
|
-
return [key, value.replace(/;$/, '')];
|
|
76
|
-
})
|
|
77
|
-
.reduce((map, [key, value]) => {
|
|
78
|
-
map[key] = value;
|
|
79
|
-
return map;
|
|
80
|
-
}, {}) || {};
|
|
81
72
|
let customLoginConfig;
|
|
82
73
|
let loginConfigPathname = loginConfigVersion
|
|
83
74
|
? (0, cals_1.generateCustomLoginConfigPathname)({ appId: appId || '', version: loginConfigVersion })
|
|
@@ -205,6 +196,15 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
205
196
|
..._buildContext,
|
|
206
197
|
wedaRoot: (0, util_3.normalizeWedaRoot)(projectConfigJson.wedaRoot),
|
|
207
198
|
};
|
|
199
|
+
const cssVarMap = Object.entries((0, theme_1.mergeCssVarConfig)((_d = (_c = calses[0]) === null || _c === void 0 ? void 0 : _c.theme) === null || _d === void 0 ? void 0 : _d.cssVarConfig, 'MP'))
|
|
200
|
+
.map(([key, _value]) => {
|
|
201
|
+
const value = _value || '';
|
|
202
|
+
return [key, value.replace(/;$/, '')];
|
|
203
|
+
})
|
|
204
|
+
.reduce((map, [key, value]) => {
|
|
205
|
+
map[key] = value;
|
|
206
|
+
return map;
|
|
207
|
+
}, {}) || {};
|
|
208
208
|
// #1.5 安装依赖库,生成 materials 目录副作用修改了buildContext 因此需要早于页面生成
|
|
209
209
|
if (hasLowcodePkg) {
|
|
210
210
|
await (0, materials_1.installMaterials)(buildContext, localWedaRoot, used);
|
|
@@ -213,7 +213,7 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
213
213
|
if (mainAppData.mpPkgUrl) {
|
|
214
214
|
}
|
|
215
215
|
else {
|
|
216
|
-
await generatePkg({ ...buildContext, rootPath: mainAppData.rootPath }, { cals: calses[0], weapp: mainAppData }, localWedaRoot, pageConfigs[0]);
|
|
216
|
+
await generatePkg({ ...buildContext, rootPath: mainAppData.rootPath }, { cals: calses[0], weapp: mainAppData }, localWedaRoot, pageConfigs[0], cssVarMap);
|
|
217
217
|
}
|
|
218
218
|
// #3 生成 wedaRoot 文件
|
|
219
219
|
if (hasLowcodePkg) {
|
|
@@ -228,8 +228,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
228
228
|
buildTypeList,
|
|
229
229
|
localWedaRoot,
|
|
230
230
|
appId,
|
|
231
|
-
loginConfigVersion: (
|
|
232
|
-
|
|
231
|
+
loginConfigVersion: (_f = (_e = calses[0]) === null || _e === void 0 ? void 0 : _e.extra) === null || _f === void 0 ? void 0 : _f.loginConfigVersion,
|
|
232
|
+
cssVarMap,
|
|
233
233
|
});
|
|
234
234
|
await (0, generateFiles_1.default)({
|
|
235
235
|
'package.json': {
|
|
@@ -359,7 +359,7 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
359
359
|
// }
|
|
360
360
|
// 生成子包
|
|
361
361
|
await Promise.all(weapps.map(async (app, index) => {
|
|
362
|
-
if (index
|
|
362
|
+
if (index === 0) {
|
|
363
363
|
return;
|
|
364
364
|
}
|
|
365
365
|
else {
|
|
@@ -368,7 +368,7 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
368
368
|
...buildContext,
|
|
369
369
|
rootPath: app.rootPath,
|
|
370
370
|
};
|
|
371
|
-
await generatePkg(subpackageBuildCtx, { cals: calses[index], weapp: app }, subpackageRootPath, pageConfigs[index]);
|
|
371
|
+
await generatePkg(subpackageBuildCtx, { cals: calses[index], weapp: app }, subpackageRootPath, pageConfigs[index], cssVarMap);
|
|
372
372
|
await generateFramework(subpackageBuildCtx, { cals: calses[index], weapp: app }, subpackageRootPath, {
|
|
373
373
|
deployOptions,
|
|
374
374
|
});
|
|
@@ -478,7 +478,7 @@ async function generateConfig(data, root) {
|
|
|
478
478
|
}, templateDir, root);
|
|
479
479
|
}
|
|
480
480
|
exports.generateConfig = generateConfig;
|
|
481
|
-
async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs) {
|
|
481
|
+
async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap) {
|
|
482
482
|
var _a;
|
|
483
483
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
|
|
484
484
|
console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
|
|
@@ -610,7 +610,7 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs) {
|
|
|
610
610
|
await (0, generateFiles_1.default)(pageFileData, `${templateDir}/page`, path_1.default.join(appRoot, 'pages', page.id));
|
|
611
611
|
}));
|
|
612
612
|
// #3 writing lowcode files
|
|
613
|
-
await writeLowCodeFiles(ctx, weapp, appRoot);
|
|
613
|
+
await writeLowCodeFiles(ctx, weapp, appRoot, cssVarMap);
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
async function generateFramework(ctx, { cals, weapp: appData }, outDir, options) {
|
|
@@ -703,17 +703,18 @@ async function generateFramework(ctx, { cals, weapp: appData }, outDir, options)
|
|
|
703
703
|
console.log('Generate app framework');
|
|
704
704
|
await (0, generateFiles_1.default)(fileData, templateDir, outDir);
|
|
705
705
|
}
|
|
706
|
-
async function writeLowCodeFiles(ctx, appData, outDir) {
|
|
706
|
+
async function writeLowCodeFiles(ctx, appData, outDir, cssVarMap) {
|
|
707
707
|
console.log(`Writing ${em('lowcode')} files:`);
|
|
708
708
|
const lowcodeRootDir = path_1.default.join(outDir, 'lowcode');
|
|
709
709
|
const lowCodes = (0, cals_1.processRuntimeCodeResources)({ id: 'global' }, appData.lowCodes || appData.codeModules, 'app');
|
|
710
710
|
const themeStyle = lowCodes.find((mod) => mod.type === cals_1.ECodeType.THEME);
|
|
711
711
|
// 混合模式,子包不生成顶级(应用级)的 lowcodes
|
|
712
712
|
if (!(ctx.isMixMode && appData.rootPath)) {
|
|
713
|
+
const globalTheme = `${ctx.enablePageRoot && cssVarMap ? (0, weapps_core_1.toCssText)(cssVarMap || {}, 'page, page .wd-mp-root') : ''}${(themeStyle === null || themeStyle === void 0 ? void 0 : themeStyle.code) || ''}`;
|
|
713
714
|
await Promise.all(lowCodes
|
|
714
715
|
.filter((mod) => mod.type !== cals_1.ECodeType.RENDERER)
|
|
715
716
|
.map((m) => {
|
|
716
|
-
(0, lowcode_1.writeCode2file)(ctx, m, lowcodeRootDir, { appDir: outDir },
|
|
717
|
+
(0, lowcode_1.writeCode2file)(ctx, m, lowcodeRootDir, { appDir: outDir }, globalTheme);
|
|
717
718
|
}));
|
|
718
719
|
}
|
|
719
720
|
await Promise.all((0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, async (page) => {
|
|
@@ -6,6 +6,6 @@ export declare function writeCode2file(ctx: IBuildContext | (IMpCommonBuildConte
|
|
|
6
6
|
pageId?: string;
|
|
7
7
|
appDir?: string;
|
|
8
8
|
comp?: ICompositedComponent;
|
|
9
|
-
}, themeCode?:
|
|
9
|
+
}, themeCode?: string, externalAPIImport?: boolean): Promise<void>;
|
|
10
10
|
export declare function handle$page(code: string): string;
|
|
11
11
|
export declare function handle$comp(code: string): string;
|
package/lib/builder/mp/util.js
CHANGED
|
@@ -217,7 +217,9 @@ function createTemplateQuery(ctx, query = {}) {
|
|
|
217
217
|
const { staticProps, boundProps } = generatedDynamicData(generateArgsDynamicValueFromData(args, data) || {}, undefined, false);
|
|
218
218
|
map[key] = {
|
|
219
219
|
...rest,
|
|
220
|
-
handler:
|
|
220
|
+
handler: item.type === cals_1.EQueryType.GeneralFunc
|
|
221
|
+
? `(__data__,__params__) => (${handler['code']})({params:__params__,data:__data__})`
|
|
222
|
+
: `(...args) => $app.${handler === null || handler === void 0 ? void 0 : handler.name}(...args)`,
|
|
221
223
|
data: staticProps,
|
|
222
224
|
dataBinds: boundProps,
|
|
223
225
|
eventHandlers: getListenersHandlers(ctx, listeners, item.id, 'this'),
|
package/lib/builder/mp/wxml.js
CHANGED
|
@@ -76,6 +76,7 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
76
76
|
id: 'wd-page-root',
|
|
77
77
|
['wx:if']: '{{weDaHasLogin && !_expiredMessage}}',
|
|
78
78
|
['data-weui-theme']: 'light',
|
|
79
|
+
class: enablePageRoot ? 'wd-mp-root' : '',
|
|
79
80
|
},
|
|
80
81
|
elements: [
|
|
81
82
|
...originElements,
|