@cloudbase/lowcode-builder 1.8.102 → 1.8.104
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 +10 -0
- package/lib/builder/h5/index.js +2 -2
- package/lib/builder/mp/BuildContext.d.ts +22 -0
- package/lib/builder/mp/index.js +8 -3
- package/lib/builder/mp/lowcode.js +1 -1
- package/lib/builder/mp/mp_config.d.ts +1 -1
- package/lib/builder/mp/mp_config.js +5 -1
- package/lib/builder/mp/util.d.ts +2 -1
- package/lib/builder/mp/util.js +38 -1
- package/lib/builder.web.js +7 -7
- package/lib/types.d.ts +2 -1
- package/lib/types.js +1 -0
- package/lib/utils/postProcess.d.ts +4 -1
- package/package.json +3 -3
- package/template/html/index.html.ejs +1 -1
- package/template/mp/app/weapps-api.js +1 -0
- package/template/mp/datasources/config.js.tpl +1 -1
- package/template/mp/package.json +1 -1
|
@@ -326,6 +326,16 @@ function normalizeInputs(inputs, { envId, getWebRootPath, }) {
|
|
|
326
326
|
inputs.deployOptions.targetMpAppId = inputs.deployOptions.mpAppId;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
+
else {
|
|
330
|
+
// web 构建
|
|
331
|
+
const { deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW } } = inputs;
|
|
332
|
+
if (deployOptions.mode === types_1.DEPLOY_MODE.DYNAMIC) {
|
|
333
|
+
inputs.deployOptions = {
|
|
334
|
+
...deployOptions,
|
|
335
|
+
mode: types_1.DEPLOY_MODE.PREVIEW,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
329
339
|
if (extraData.isComposite) {
|
|
330
340
|
Object.keys(extraData.compProps.events).forEach((eName) => {
|
|
331
341
|
extraData.compProps.events[eName] = `$$EVENT_${eName}$$`;
|
package/lib/builder/h5/index.js
CHANGED
|
@@ -53,7 +53,7 @@ if (!process.env.IS_WEB_WORKER) {
|
|
|
53
53
|
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, }) {
|
|
54
54
|
var _a, _b, _c, _d, _e, _f;
|
|
55
55
|
const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode, enableExpiredTag, privatelinkConfig, } = buildContext;
|
|
56
|
-
if (!deployOptions.mode) {
|
|
56
|
+
if (!deployOptions.mode || deployOptions.mode === types_1.DEPLOY_MODE.DYNAMIC) {
|
|
57
57
|
deployOptions.mode = types_1.DEPLOY_MODE.PREVIEW;
|
|
58
58
|
}
|
|
59
59
|
try {
|
|
@@ -124,7 +124,7 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
|
|
|
124
124
|
buildTypeList,
|
|
125
125
|
isSandbox: false,
|
|
126
126
|
runtime,
|
|
127
|
-
deployOptions,
|
|
127
|
+
deployOptions: deployOptions,
|
|
128
128
|
_indexPage,
|
|
129
129
|
isPrivateMode,
|
|
130
130
|
expirationStartTimesnap: enableExpiredTag ? Date.now() : undefined,
|
|
@@ -19,6 +19,24 @@ export interface ICommonBuildContext {
|
|
|
19
19
|
*/
|
|
20
20
|
isPrivateMode?: boolean;
|
|
21
21
|
}
|
|
22
|
+
export interface IDefaultAppWindowConfig {
|
|
23
|
+
navigationBarBackgroundColor?: string;
|
|
24
|
+
navigationBarTextStyle?: 'white' | 'black';
|
|
25
|
+
navigationBarTitleText?: string;
|
|
26
|
+
navigationStyle?: 'default' | 'custom';
|
|
27
|
+
homeButton?: boolean;
|
|
28
|
+
backgroundColor?: string;
|
|
29
|
+
backgroundTextStyle?: 'dark' | 'light';
|
|
30
|
+
backgroundColorTop?: string;
|
|
31
|
+
backgroundColorBottom?: string;
|
|
32
|
+
enablePullDownRefresh?: boolean;
|
|
33
|
+
onReachBottomDistance?: number;
|
|
34
|
+
pageOrientation?: 'portrait' | 'auto' | 'landscape';
|
|
35
|
+
restartStrategy?: string;
|
|
36
|
+
initialRenderingCache?: 'static' | 'dynamic';
|
|
37
|
+
visualEffectInBackground?: 'none' | 'hidden';
|
|
38
|
+
handleWebviewPreload?: 'static' | 'manual' | 'auto';
|
|
39
|
+
}
|
|
22
40
|
export interface IAppCommonBuildContext extends ICommonBuildContext {
|
|
23
41
|
/**
|
|
24
42
|
* 应用id
|
|
@@ -82,4 +100,8 @@ export interface IBuildContext extends IAppCommonBuildContext, IMpCommonBuildCon
|
|
|
82
100
|
* weda 默认自身root
|
|
83
101
|
*/
|
|
84
102
|
wedaRoot?: string;
|
|
103
|
+
/**
|
|
104
|
+
* app.json文件window配置
|
|
105
|
+
*/
|
|
106
|
+
defaultAppWindowConfig?: IDefaultAppWindowConfig;
|
|
85
107
|
}
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -249,6 +249,7 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
249
249
|
appID: appId,
|
|
250
250
|
resourceAppid: !!options.isCrossAccount ? options.resourceAppId : '',
|
|
251
251
|
isProd: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.UPLOAD,
|
|
252
|
+
deployMode: deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode,
|
|
252
253
|
clientID: ((_g = mainAppData.extra) === null || _g === void 0 ? void 0 : _g.enableLoginStatusShare)
|
|
253
254
|
? mainAppData.envId
|
|
254
255
|
: (_h = mainAppData.extra) === null || _h === void 0 ? void 0 : _h.clientId,
|
|
@@ -375,6 +376,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
375
376
|
// path.join(miniprogramRoot, buildContext.wedaRoot || '', materialsDirName),
|
|
376
377
|
// );
|
|
377
378
|
// }
|
|
379
|
+
const appJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
|
|
380
|
+
const appJson = await fs.readJson(appJsonPath);
|
|
378
381
|
// 生成子包
|
|
379
382
|
await Promise.all(weapps.map(async (app, index) => {
|
|
380
383
|
if (index === 0) {
|
|
@@ -386,6 +389,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
386
389
|
...buildContext,
|
|
387
390
|
rootPath: app.rootPath,
|
|
388
391
|
};
|
|
392
|
+
if (appJson === null || appJson === void 0 ? void 0 : appJson.window) {
|
|
393
|
+
subpackageBuildCtx.defaultAppWindowConfig = appJson.window;
|
|
394
|
+
}
|
|
389
395
|
await generatePkg(subpackageBuildCtx, { cals: calses[index], weapp: app }, subpackageRootPath, pageConfigs[index], cssVarMap);
|
|
390
396
|
await generateFramework(subpackageBuildCtx, { cals: calses[index], weapp: app }, subpackageRootPath, {
|
|
391
397
|
deployOptions,
|
|
@@ -500,7 +506,7 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
|
|
|
500
506
|
var _a;
|
|
501
507
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
|
|
502
508
|
console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
|
|
503
|
-
const { processCssUnit = 'rpx' } = ctx;
|
|
509
|
+
const { processCssUnit = 'rpx', defaultAppWindowConfig = {} } = ctx;
|
|
504
510
|
if (weapp.mpPkgUrl) {
|
|
505
511
|
// 清空历史文件,使用zip覆盖
|
|
506
512
|
console.log(`Removing ${appRoot}`);
|
|
@@ -604,7 +610,7 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
|
|
|
604
610
|
usingComponents,
|
|
605
611
|
componentGenerics,
|
|
606
612
|
componentPlaceholder,
|
|
607
|
-
extra: getAppendableJson(pageConfigs[page.id]),
|
|
613
|
+
extra: getAppendableJson((0, util_2.cleanWindowDefultConfig)(pageConfigs[page.id], defaultAppWindowConfig)),
|
|
608
614
|
},
|
|
609
615
|
[`index.wxml|${pageFileName}.wxml`]: {
|
|
610
616
|
content: wxml,
|
|
@@ -687,7 +693,6 @@ async function generateFramework(ctx, { cals, weapp: appData }, outDir, options)
|
|
|
687
693
|
label: (appData === null || appData === void 0 ? void 0 : appData.label) || '',
|
|
688
694
|
version: (_a = options === null || options === void 0 ? void 0 : options.deployOptions) === null || _a === void 0 ? void 0 : _a.version,
|
|
689
695
|
envId: appData.envId,
|
|
690
|
-
envVersion: (ctx === null || ctx === void 0 ? void 0 : ctx.isProduction) ? 'production' : 'preview',
|
|
691
696
|
loginConfigVersion: (_b = cals.extra) === null || _b === void 0 ? void 0 : _b.loginConfigVersion,
|
|
692
697
|
basename: ctx.wedaRoot,
|
|
693
698
|
pages: appData.pageInstanceList
|
|
@@ -25,7 +25,7 @@ async function writeCode2file(ctx, mod, lowcodeRootDir, opts = {}, themeCode, ex
|
|
|
25
25
|
// Generate app lowcode
|
|
26
26
|
const baseDir = path_1.default.relative(path_1.default.dirname(file), appDir).replace(/\\/g, '/');
|
|
27
27
|
// 子包混合模式需要添加相对索引到根目录
|
|
28
|
-
const relativeRoot = (ctx === null || ctx === void 0 ? void 0 : ctx.isMixMode) && ctx.rootPath ? `${path_1.default.relative(`packages/${ctx.rootPath}`, '')}/` : '';
|
|
28
|
+
const relativeRoot = (ctx === null || ctx === void 0 ? void 0 : ctx.isMixMode) && ctx.rootPath ? `${path_1.default.posix.relative(`packages/${ctx.rootPath}`, '')}/` : '';
|
|
29
29
|
let weappsApiPrefix = externalAPIImport
|
|
30
30
|
? importFromClientSDK(pageId === 'global')
|
|
31
31
|
: [`import { app, $app${pageId !== 'global' ? '' : ', $w'} } from '${relativeRoot}${baseDir}/app/weapps-api';`]; // windows compatibility
|
|
@@ -12,8 +12,8 @@ export declare function generateMpConfig(ctx: Omit<IBuildContext, 'wedaRoot'>, w
|
|
|
12
12
|
mpAppId?: string;
|
|
13
13
|
mpConfig?: IBuildWedaApp['mpConfig'];
|
|
14
14
|
}): Promise<{
|
|
15
|
-
appConfig: any;
|
|
16
15
|
projConfig: any;
|
|
16
|
+
appConfig: any;
|
|
17
17
|
pageConfigs: {}[];
|
|
18
18
|
}>;
|
|
19
19
|
interface ISubpackage {
|
|
@@ -35,6 +35,7 @@ const config_1 = require("../config");
|
|
|
35
35
|
const net_1 = require("../util/net");
|
|
36
36
|
const chalk_1 = __importDefault(require("chalk"));
|
|
37
37
|
const util_1 = require("../util");
|
|
38
|
+
const util_2 = require("./util");
|
|
38
39
|
/**
|
|
39
40
|
* generate app.json & page.json for mp
|
|
40
41
|
*
|
|
@@ -162,6 +163,9 @@ async function generateMpConfig(ctx, weapps, calses, options) {
|
|
|
162
163
|
});
|
|
163
164
|
}
|
|
164
165
|
});
|
|
166
|
+
if (appConfig === null || appConfig === void 0 ? void 0 : appConfig.window) {
|
|
167
|
+
appConfig.window = (0, util_2.cleanWindowDefultConfig)(appConfig);
|
|
168
|
+
}
|
|
165
169
|
if (!projConfig.setting) {
|
|
166
170
|
projConfig.setting = {};
|
|
167
171
|
}
|
|
@@ -181,7 +185,7 @@ async function generateMpConfig(ctx, weapps, calses, options) {
|
|
|
181
185
|
projConfig.appId = options.mpAppId;
|
|
182
186
|
}
|
|
183
187
|
// merge(pageConfigs, extractAllPagesConfig())
|
|
184
|
-
return {
|
|
188
|
+
return { projConfig, appConfig, pageConfigs };
|
|
185
189
|
}
|
|
186
190
|
exports.generateMpConfig = generateMpConfig;
|
|
187
191
|
function extractPages(weapps, pageConfigs, options) {
|
package/lib/builder/mp/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDynamicValue, IWeAppComponentInstance, ActionType, ICompositedComponent, IWeAppPage, IEventListener, IQueryData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
|
-
import { IMpCommonBuildContext } from './BuildContext';
|
|
2
|
+
import { IMpCommonBuildContext, IDefaultAppWindowConfig } from './BuildContext';
|
|
3
3
|
export declare function generatedDynamicData(data: {
|
|
4
4
|
[key: string]: IDynamicValue;
|
|
5
5
|
}, compInfo?: ICompositedComponent, filterBuiltInProps?: boolean): {
|
|
@@ -53,3 +53,4 @@ export declare function isRepeaterWidget(w: {
|
|
|
53
53
|
componentType?: string;
|
|
54
54
|
};
|
|
55
55
|
}, repeaterComponentName: string): true | undefined;
|
|
56
|
+
export declare function cleanWindowDefultConfig(jsonConfig: IDefaultAppWindowConfig, appConfig?: IDefaultAppWindowConfig): IDefaultAppWindowConfig;
|
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.isRepeaterWidget = exports.generateScopedStyleText = exports.findComponentInfo = exports.processRepeaterSchema = exports.setDataBind = exports.createDataBinds = exports.generateArgsDynamicValueFromData = exports.createTemplateEventFlows = exports.createTemplateQuery = exports.generateDataContainerListeners = exports.generateSyncListeners = exports.createEventHandlers = exports.createWidgetProps = exports.generatedDynamicData = void 0;
|
|
3
|
+
exports.cleanWindowDefultConfig = exports.isRepeaterWidget = exports.generateScopedStyleText = exports.findComponentInfo = exports.processRepeaterSchema = exports.setDataBind = exports.createDataBinds = exports.generateArgsDynamicValueFromData = 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");
|
|
@@ -585,3 +585,40 @@ function checkRepeaterComponent(xComponent) {
|
|
|
585
585
|
}
|
|
586
586
|
return false;
|
|
587
587
|
}
|
|
588
|
+
// 小程序app.json window属性默认配置
|
|
589
|
+
const defaultConfig = {
|
|
590
|
+
navigationBarBackgroundColor: '#000000',
|
|
591
|
+
navigationBarTextStyle: 'white',
|
|
592
|
+
navigationBarTitleText: '',
|
|
593
|
+
navigationStyle: 'default',
|
|
594
|
+
homeButton: false,
|
|
595
|
+
backgroundColor: '#FFFFFF',
|
|
596
|
+
backgroundTextStyle: 'dark',
|
|
597
|
+
backgroundColorTop: '#FFFFFF',
|
|
598
|
+
backgroundColorBottom: '#FFFFFF',
|
|
599
|
+
enablePullDownRefresh: false,
|
|
600
|
+
onReachBottomDistance: 50,
|
|
601
|
+
pageOrientation: 'portrait',
|
|
602
|
+
restartStrategy: 'homePage',
|
|
603
|
+
visualEffectInBackground: 'none',
|
|
604
|
+
handleWebviewPreload: 'static',
|
|
605
|
+
};
|
|
606
|
+
// 筛选传入参数中与默认参数重复的部分,兼容大小写。
|
|
607
|
+
function removeDuplicatedSettings(customConfig, defaultConfig, appConfig) {
|
|
608
|
+
const resultConfig = {};
|
|
609
|
+
for (const key in customConfig) {
|
|
610
|
+
const customVal = typeof customConfig[key] === 'string' ? customConfig[key].toLowerCase() : customConfig[key];
|
|
611
|
+
const defaultVal = typeof defaultConfig[key] === 'string' ? defaultConfig[key].toLowerCase() : defaultConfig[key];
|
|
612
|
+
const appVal = typeof appConfig[key] === 'string' ? appConfig[key].toLowerCase() : appConfig[key];
|
|
613
|
+
// 逻辑为若appVal存在,则对比app,不存在情况下对比全局默认
|
|
614
|
+
if (customVal !== (appVal || defaultVal)) {
|
|
615
|
+
resultConfig[key] = customConfig[key];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return resultConfig;
|
|
619
|
+
}
|
|
620
|
+
// 删除传入配置中与默认值或者在index.json中与app.json相同的属性
|
|
621
|
+
function cleanWindowDefultConfig(jsonConfig, appConfig = {}) {
|
|
622
|
+
return removeDuplicatedSettings(jsonConfig, defaultConfig, appConfig);
|
|
623
|
+
}
|
|
624
|
+
exports.cleanWindowDefultConfig = cleanWindowDefultConfig;
|