@cloudbase/lowcode-builder 1.8.44-alpha.0 → 1.8.45-beta.1
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 +29 -13
- package/lib/builder/mp/index.js +14 -12
- package/lib/builder/mp/util.d.ts +1 -0
- package/lib/builder/mp/util.js +34 -1
- package/lib/builder.web.js +29 -13
- package/package.json +6 -5
- package/template/mp/common/merge-renderer.js +1 -1
- package/template/mp/common/modal/index.js +200 -0
- package/template/mp/common/modal/index.json +5 -0
- package/template/mp/common/modal/index.wxml +16 -0
- package/template/mp/common/modal/index.wxss +1 -0
- package/template/mp/common/modal/wd-modal.wxss +177 -0
- package/template/mp/common/privacyModal/index.json +2 -5
- package/template/mp/common/privacyModal/index.wxml +8 -8
- package/template/mp/common/privacyModal/index.wxss +15 -2
- package/template/mp/common/util.js +3 -16
- package/template/mp/common/widget.js +6 -6
- package/template/mp/page/api.js +1 -3
package/lib/builder/mp/index.js
CHANGED
|
@@ -138,6 +138,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
138
138
|
'common/flow.js': {},
|
|
139
139
|
'common/info': {},
|
|
140
140
|
'common/privacyModal': {},
|
|
141
|
+
'common/modal': {},
|
|
141
142
|
/**
|
|
142
143
|
* 调试用
|
|
143
144
|
*/
|
|
@@ -325,7 +326,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
325
326
|
console.log(`Generating ${em('page')} files`);
|
|
326
327
|
(0, generateFiles_1.cleanDir)(path_1.default.join(appRoot, 'pages'), []);
|
|
327
328
|
await Promise.all(weapp.pageInstanceList.map(async (page, index) => {
|
|
328
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
329
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
329
330
|
// # Generating page
|
|
330
331
|
const rootPath = weapp.rootPath || '';
|
|
331
332
|
const usingComponents = {};
|
|
@@ -346,10 +347,8 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
346
347
|
const pageFileData = {
|
|
347
348
|
[`api.js|api.js`]: {
|
|
348
349
|
subLevelPath: rootPath ? `${path_1.default.posix.relative(rootPath, '')}/` : '',
|
|
349
|
-
packageName: rootPath || '',
|
|
350
|
-
subAppId: rootPath ? ((_a = weapp.extra) === null || _a === void 0 ? void 0 : _a.id) || weapp.id || '' : '',
|
|
351
350
|
uuid: rootPath ? `${rootPath}/${page.id}` : page.id,
|
|
352
|
-
label: ((
|
|
351
|
+
label: ((_b = (_a = page === null || page === void 0 ? void 0 : page.data) === null || _a === void 0 ? void 0 : _a.navigationBarTitleText) === null || _b === void 0 ? void 0 : _b.value) || ((_d = (_c = page === null || page === void 0 ? void 0 : page.data) === null || _c === void 0 ? void 0 : _c.title) === null || _d === void 0 ? void 0 : _d.value),
|
|
353
352
|
},
|
|
354
353
|
[`data.js|data.js`]: {
|
|
355
354
|
widgetProps: (0, util_2.createWidgetProps)(ctx, componentInstances),
|
|
@@ -362,16 +361,16 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
362
361
|
eventHandlers: (0, util_2.createEventHandlers)(ctx, componentInstances, 'this', page),
|
|
363
362
|
dataBinds: (0, util_2.createDataBinds)(ctx, componentInstances),
|
|
364
363
|
pageAttributes: {
|
|
365
|
-
...(((
|
|
364
|
+
...(((_e = page.data) === null || _e === void 0 ? void 0 : _e.appShareMessage) ? { appShareMessage: page.data.appShareMessage.value } : {}),
|
|
366
365
|
},
|
|
367
366
|
debug: ctx.debugMode,
|
|
368
367
|
stringifyObj: util_1.inspect,
|
|
369
368
|
subLevelPath: rootPath ? `${path_1.default.posix.relative(rootPath, '')}/` : '',
|
|
370
369
|
importor,
|
|
371
|
-
query: (0, util_2.createTemplateQuery)(ctx, (
|
|
370
|
+
query: (0, util_2.createTemplateQuery)(ctx, (_f = page.dataset) === null || _f === void 0 ? void 0 : _f.query),
|
|
372
371
|
eventFlows: (0, util_2.createTemplateEventFlows)(ctx, page.eventFlows),
|
|
373
|
-
resetShare: ((
|
|
374
|
-
((
|
|
372
|
+
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) ||
|
|
373
|
+
((_k = allAppUsedComps === null || allAppUsedComps === void 0 ? void 0 : allAppUsedComps[cals_1.OFFICIAL_LIB_KEY]) === null || _k === void 0 ? void 0 : _k.has('Share')) ||
|
|
375
374
|
/* 从 enablePageRoot 的版本开始支持按需reset share
|
|
376
375
|
* 否则默认都开启
|
|
377
376
|
*/ !ctx.enablePageRoot,
|
|
@@ -385,12 +384,15 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
385
384
|
content: wxml,
|
|
386
385
|
},
|
|
387
386
|
[`index.wxss|${pageFileName}.wxss`]: {
|
|
388
|
-
subWxss: rootPath && !((
|
|
387
|
+
subWxss: rootPath && !((_l = ctx.mainAppData) === null || _l === void 0 ? void 0 : _l.mpPkgUrl)
|
|
389
388
|
? `@import "${path_1.default.posix.relative(`/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
|
|
390
389
|
: '',
|
|
391
|
-
content:
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
content: [
|
|
391
|
+
(0, weapps_core_1.toCssText)((0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
|
|
392
|
+
defaultUnit: processCssUnit,
|
|
393
|
+
}), 'page'),
|
|
394
|
+
(0, util_2.generateScopedStyleText)(componentInstances),
|
|
395
|
+
].join('\n'),
|
|
394
396
|
pageWxss: importor.styles.length ? `@import "../../lowcode/${page.id}/style.wxss"` : '',
|
|
395
397
|
},
|
|
396
398
|
};
|
package/lib/builder/mp/util.d.ts
CHANGED
package/lib/builder/mp/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findComponentInfo = exports.processRepeaterSchema = exports.createDataBinds = exports.createTemplateEventFlows = exports.createTemplateQuery = exports.generateDataContainerListeners = exports.generateSyncListeners = exports.createEventHandlers = exports.createWidgetProps = exports.generatedDynamicData = void 0;
|
|
3
|
+
exports.generateScopedStyleText = exports.findComponentInfo = exports.processRepeaterSchema = exports.createDataBinds = exports.createTemplateEventFlows = exports.createTemplateQuery = exports.generateDataContainerListeners = exports.generateSyncListeners = exports.createEventHandlers = exports.createWidgetProps = exports.generatedDynamicData = void 0;
|
|
4
4
|
const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
5
5
|
const lowcode_generator_1 = require("@cloudbase/lowcode-generator");
|
|
6
6
|
const weapp_1 = require("@cloudbase/lowcode-generator/lib/generator/util/weapp");
|
|
@@ -481,3 +481,36 @@ function findComponentInfo(xComponent, { materialLibs, miniprogramPlugins }) {
|
|
|
481
481
|
return compProto;
|
|
482
482
|
}
|
|
483
483
|
exports.findComponentInfo = findComponentInfo;
|
|
484
|
+
function generateScopedStyleText(widgets) {
|
|
485
|
+
const cssTextList = [];
|
|
486
|
+
function traverse(target) {
|
|
487
|
+
var _a;
|
|
488
|
+
for (const [id, widget] of Object.entries(target)) {
|
|
489
|
+
const scopedStyle = (_a = widget.xProps) === null || _a === void 0 ? void 0 : _a.scopedStyle;
|
|
490
|
+
if (scopedStyle) {
|
|
491
|
+
let cssText = scopedStyle
|
|
492
|
+
// 移除 `/* ... */` 注释
|
|
493
|
+
.replace(/\/\*(?:[\s\S]*?)\*\//g, '')
|
|
494
|
+
// 移除换行及其前后的空白符
|
|
495
|
+
.replace(/\s*\n\s*/g, '')
|
|
496
|
+
// 添加 `#wd-page-root` 前缀以增加样式权重
|
|
497
|
+
.replace(/(:root.*?{)/g, '\n#wd-page-root $1')
|
|
498
|
+
// 替换 `:root`
|
|
499
|
+
.replace(/:root/g, `.wd-comp-id-${id}`)
|
|
500
|
+
// `: ` => `:`
|
|
501
|
+
.replace(/\s*:\s*/g, ':')
|
|
502
|
+
// ` {` => `{`
|
|
503
|
+
.replace(/\s*{\s*/g, '{')
|
|
504
|
+
// `;}` => `}`
|
|
505
|
+
.replace(/;\s*}/g, '}');
|
|
506
|
+
cssTextList.push(cssText.trim());
|
|
507
|
+
}
|
|
508
|
+
if (widget.properties) {
|
|
509
|
+
traverse(widget.properties);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
traverse(widgets);
|
|
514
|
+
return cssTextList.join('\n');
|
|
515
|
+
}
|
|
516
|
+
exports.generateScopedStyleText = generateScopedStyleText;
|