@cloudbase/lowcode-builder 1.8.58 → 1.8.59
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/mp/index.js +11 -3
- package/lib/builder/mp/wxml.js +19 -8
- package/lib/builder.web.js +14870 -71
- package/lib/utils/theme.d.ts +1 -0
- package/lib/utils/theme.js +35 -0
- package/package.json +3 -1
- package/template/html/index.html.ejs +1 -1
- package/template/mp/common/weapp-page.js +2 -1
- package/template/mp/package.json +1 -1
- package/dist/builder.web.js +0 -71
package/lib/builder/mp/index.js
CHANGED
|
@@ -52,6 +52,7 @@ const junk = __importStar(require("../util/junk"));
|
|
|
52
52
|
const net_1 = require("../util/net");
|
|
53
53
|
const cals_1 = require("@cloudbase/cals");
|
|
54
54
|
const core_1 = require("../core");
|
|
55
|
+
const theme_1 = require("../../utils/theme");
|
|
55
56
|
const templateDir = `${config_1.appTemplateDir}/mp/`;
|
|
56
57
|
const em = chalk_1.default.blue.bold;
|
|
57
58
|
const error = chalk_1.default.redBright;
|
|
@@ -69,7 +70,7 @@ function patchBuildContext(ctx, calses, weapps) {
|
|
|
69
70
|
return { allAppUsedComps };
|
|
70
71
|
}
|
|
71
72
|
async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptions, options, buildTypeList, ignoreInstall = false, cdnEndpoints = {}, }) {
|
|
72
|
-
var _a, _b;
|
|
73
|
+
var _a, _b, _c, _d;
|
|
73
74
|
const operationLabel = em('Wexin MiniProgram Generated');
|
|
74
75
|
console.time(operationLabel);
|
|
75
76
|
console.log(`Generating ${em('Wexin MiniProgram')} to ${buildContext.projDir}`);
|
|
@@ -114,6 +115,12 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
114
115
|
endpointType,
|
|
115
116
|
}, miniprogramRoot);
|
|
116
117
|
const expirationStartTimesnap = buildContext.enableExpiredTag ? Date.now() : 0;
|
|
118
|
+
const cssVarList = Object.entries((0, theme_1.mergeCssVarConfig)((_b = (_a = calses[0]) === null || _a === void 0 ? void 0 : _a.theme) === null || _b === void 0 ? void 0 : _b.cssVarConfig, 'MP'))
|
|
119
|
+
.map(([key, _value]) => {
|
|
120
|
+
const value = _value || '';
|
|
121
|
+
return `${key}: ${value}${/;$/.test(value) ? '' : ';'}`;
|
|
122
|
+
})
|
|
123
|
+
.filter((str) => !!str) || [];
|
|
117
124
|
appFileData = {
|
|
118
125
|
...appFileData,
|
|
119
126
|
'common/style.js': {},
|
|
@@ -124,6 +131,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
124
131
|
'common/widget.js': {},
|
|
125
132
|
'common/weapp-page.js': {
|
|
126
133
|
expirationStartTimesnap,
|
|
134
|
+
pageStyle: cssVarList.join(''),
|
|
127
135
|
},
|
|
128
136
|
'common/weapp-component.js': {},
|
|
129
137
|
'common/merge-renderer.js': {
|
|
@@ -226,9 +234,9 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
226
234
|
appID: appId,
|
|
227
235
|
resourceAppid: !!options.isCrossAccount ? options.resourceAppId : '',
|
|
228
236
|
isProd: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.UPLOAD,
|
|
229
|
-
clientID: ((
|
|
237
|
+
clientID: ((_c = mainAppData.extra) === null || _c === void 0 ? void 0 : _c.enableLoginStatusShare)
|
|
230
238
|
? mainAppData.envId
|
|
231
|
-
: (
|
|
239
|
+
: (_d = mainAppData.extra) === null || _d === void 0 ? void 0 : _d.clientId,
|
|
232
240
|
cdnEndpoints,
|
|
233
241
|
builderVersion: core_1.version || '',
|
|
234
242
|
officialLibVersion: (officialLib === null || officialLib === void 0 ? void 0 : officialLib.version) || '',
|
package/lib/builder/mp/wxml.js
CHANGED
|
@@ -24,14 +24,25 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
24
24
|
};
|
|
25
25
|
if (ctx.pageUUID) {
|
|
26
26
|
const { enablePageRoot, disabled, enableAsyncMaterials } = ctx;
|
|
27
|
+
const pageMeta = {
|
|
28
|
+
name: 'page-meta',
|
|
29
|
+
type: 'element',
|
|
30
|
+
attributes: {
|
|
31
|
+
['page-style']: '{{pageStyle}}',
|
|
32
|
+
},
|
|
33
|
+
elements: [],
|
|
34
|
+
_order: Infinity,
|
|
35
|
+
_parent: null,
|
|
36
|
+
};
|
|
27
37
|
const originElements = xmlJson.elements;
|
|
38
|
+
xmlJson.elements = [pageMeta];
|
|
28
39
|
// usingComponents['wd-privacy'] = '/common/privacyModal/index';
|
|
29
40
|
usingComponents[WD_INFO] = '/common/info/index';
|
|
30
41
|
if (enableAsyncMaterials) {
|
|
31
42
|
usingComponents[exports.WD_EMPTY_PLACEHOLDER] = '/common/placeholder/index';
|
|
32
43
|
}
|
|
33
44
|
if (disabled && ctx.pageUUID !== ctx.statusPageId) {
|
|
34
|
-
|
|
45
|
+
pageMeta.elements = [
|
|
35
46
|
{
|
|
36
47
|
type: 'element',
|
|
37
48
|
name: WD_INFO,
|
|
@@ -49,14 +60,14 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
49
60
|
}
|
|
50
61
|
else {
|
|
51
62
|
// 登录校验: 向其最外层包裹一层block
|
|
52
|
-
|
|
63
|
+
pageMeta.elements = [
|
|
53
64
|
// {
|
|
54
65
|
// type: 'element',
|
|
55
66
|
// name: 'wd-privacy',
|
|
56
67
|
// attributes: {},
|
|
57
68
|
// elements: [],
|
|
58
69
|
// _order: -Infinity,
|
|
59
|
-
// _parent:
|
|
70
|
+
// _parent: pageMeta,
|
|
60
71
|
// },
|
|
61
72
|
{
|
|
62
73
|
type: 'element',
|
|
@@ -100,11 +111,11 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
100
111
|
},
|
|
101
112
|
elements: [],
|
|
102
113
|
_order: Infinity,
|
|
103
|
-
_parent:
|
|
114
|
+
_parent: pageMeta,
|
|
104
115
|
},
|
|
105
116
|
];
|
|
106
117
|
if (ctx.enableExpiredTag) {
|
|
107
|
-
|
|
118
|
+
pageMeta.elements.push({
|
|
108
119
|
type: 'element',
|
|
109
120
|
name: WD_INFO,
|
|
110
121
|
attributes: {
|
|
@@ -114,11 +125,11 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
114
125
|
},
|
|
115
126
|
elements: [],
|
|
116
127
|
_order: Infinity,
|
|
117
|
-
_parent:
|
|
128
|
+
_parent: pageMeta,
|
|
118
129
|
});
|
|
119
130
|
}
|
|
120
131
|
if (ctx.enableLoading) {
|
|
121
|
-
|
|
132
|
+
pageMeta.elements.push({
|
|
122
133
|
type: 'element',
|
|
123
134
|
name: WD_INFO,
|
|
124
135
|
attributes: {
|
|
@@ -127,7 +138,7 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
127
138
|
},
|
|
128
139
|
elements: [],
|
|
129
140
|
_order: Infinity,
|
|
130
|
-
_parent:
|
|
141
|
+
_parent: pageMeta,
|
|
131
142
|
});
|
|
132
143
|
}
|
|
133
144
|
}
|