@cloudbase/lowcode-builder 1.8.53 → 1.8.55
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 +79 -0
- package/lib/builder/config/index.d.ts +3 -1
- package/lib/builder/config/index.js +4 -2
- package/lib/builder/core/index.js +3 -2
- package/lib/builder/h5/generate.d.ts +2 -2
- package/lib/builder/h5/index.d.ts +2 -2
- package/lib/builder/h5/webpack.d.ts +2 -2
- package/lib/builder/mp/BuildContext.d.ts +13 -7
- package/lib/builder/mp/index.js +61 -11
- package/lib/builder/mp/materials.js +5 -1
- package/lib/builder/mp/mp_config.js +29 -2
- package/lib/builder/mp/wxml.d.ts +2 -0
- package/lib/builder/mp/wxml.js +13 -9
- package/lib/builder/util/net.js +9 -3
- package/lib/builder.web.js +21 -13
- package/package.json +2 -2
- package/template/html/index.html.ejs +1 -1
- package/template/mp/app.js +16 -0
- package/template/mp/common/util.js +4 -1
- package/template/mp/common/weapp-page.js +1 -0
- package/template/mp/datasources/config.js.tpl +7 -2
- package/template/mp/datasources/index.js.tpl +4 -2
- package/template/mp/package.json +1 -2
- package/template/mp/packages/$wd_system/index.js.tpl +11 -0
- package/template/mp/packages/$wd_system/package.json +8 -0
- package/template/mp/page/index.json +1 -1
- /package/template/mp/common/placeholder/{index.ts → index.js} +0 -0
|
@@ -6,16 +6,18 @@ 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.file.myqcloud.com/lcap-builder/template.1.8.
|
|
9
|
+
export declare const builderTemplateURL = "https://comp-public-1303824488.file.myqcloud.com/lcap-builder/template.1.8.55-alpha.0.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
14
|
export declare const miniprogramURL = "https://comp-public-1303824488.file.myqcloud.com/lcap-builder/miniprogram_npm.1.8.43.zip";
|
|
15
|
+
export declare const systemSubpackageMiniprogramURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/wd_system_miniprogram_npm.zip";
|
|
15
16
|
/**
|
|
16
17
|
* miniprogram_npm存放目录。IDE插件builder用到
|
|
17
18
|
*/
|
|
18
19
|
export declare const miniprogramDir: string;
|
|
20
|
+
export declare const systemSubpackageMiniprogramDir: string;
|
|
19
21
|
export interface ICDN_ENDPOINTS_COFIG {
|
|
20
22
|
common?: string;
|
|
21
23
|
cloudbase?: string;
|
|
@@ -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.REPEATER = exports.generateCdnEndpoints = exports.CDN_ENDPONTS_CONFIG = exports.miniprogramDir = exports.miniprogramURL = exports.builderTemplateURL = exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.OFFICIAL_LIB_KEY = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
|
|
29
|
+
exports.REPEATER = exports.generateCdnEndpoints = exports.CDN_ENDPONTS_CONFIG = exports.systemSubpackageMiniprogramDir = exports.miniprogramDir = exports.systemSubpackageMiniprogramURL = exports.miniprogramURL = exports.builderTemplateURL = exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.OFFICIAL_LIB_KEY = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const os_1 = __importDefault(require("os"));
|
|
32
32
|
const index_1 = require("@cloudbase/lowcode-generator/lib/generator/config/index");
|
|
@@ -45,16 +45,18 @@ 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.file.myqcloud.com/lcap-builder/template.1.8.
|
|
48
|
+
exports.builderTemplateURL = 'https://comp-public-1303824488.file.myqcloud.com/lcap-builder/template.1.8.55-alpha.0.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
53
|
exports.miniprogramURL = 'https://comp-public-1303824488.file.myqcloud.com/lcap-builder/miniprogram_npm.1.8.43.zip';
|
|
54
|
+
exports.systemSubpackageMiniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/wd_system_miniprogram_npm.zip';
|
|
54
55
|
/**
|
|
55
56
|
* miniprogram_npm存放目录。IDE插件builder用到
|
|
56
57
|
*/
|
|
57
58
|
exports.miniprogramDir = path.join(os_1.default.homedir(), exports.sharedMaterialsDir, 'miniprogram_npm');
|
|
59
|
+
exports.systemSubpackageMiniprogramDir = path.join(os_1.default.homedir(), exports.sharedMaterialsDir, '$wd_system_miniprogram_npm');
|
|
58
60
|
exports.CDN_ENDPONTS_CONFIG = {
|
|
59
61
|
common: '',
|
|
60
62
|
cloudbase: '//static.cloudbase.net',
|
|
@@ -141,7 +141,7 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
141
141
|
// 尽早下载物料
|
|
142
142
|
await (0, net_1.downloadBrowserMaterial)(output === null || output === void 0 ? void 0 : output.path);
|
|
143
143
|
}
|
|
144
|
-
const { enablePageRoot } = (0, cals_1.parseVersion)(cals === null || cals === void 0 ? void 0 : cals.schemaVersion, dependencies);
|
|
144
|
+
const { enablePageRoot, enableAsyncMaterials } = (0, cals_1.parseVersion)(cals === null || cals === void 0 ? void 0 : cals.schemaVersion, dependencies);
|
|
145
145
|
const mpBuildContext = {
|
|
146
146
|
...buildContext,
|
|
147
147
|
projDir: (output === null || output === void 0 ? void 0 : output.path) || path_1.default.join(appBuildDir, 'mp'),
|
|
@@ -154,6 +154,7 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
154
154
|
: 'rpx'),
|
|
155
155
|
enablePageRoot,
|
|
156
156
|
enableLoading: (_e = cals === null || cals === void 0 ? void 0 : cals.extra) === null || _e === void 0 ? void 0 : _e.enableLoading,
|
|
157
|
+
enableAsyncMaterials,
|
|
157
158
|
};
|
|
158
159
|
const result = await (0, index_1.generateWxMp)({
|
|
159
160
|
weapps: apps,
|
|
@@ -168,7 +169,7 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
168
169
|
},
|
|
169
170
|
buildTypeList,
|
|
170
171
|
ignoreInstall,
|
|
171
|
-
cdnEndpoints:
|
|
172
|
+
cdnEndpoints: (0, config_1.generateCdnEndpoints)(cdnEndpoints),
|
|
172
173
|
});
|
|
173
174
|
// 如果是混合模式,则将特定的目录复制到工程下
|
|
174
175
|
// 针对 app.json / package.json 则采用 merge 的操作
|
|
@@ -2,7 +2,7 @@ import { BuildAppProps } from '@cloudbase/lowcode-generator';
|
|
|
2
2
|
import { IPlatformApp } from '@cloudbase/cals';
|
|
3
3
|
import { ICDN_ENDPOINTS_COFIG } from '../config';
|
|
4
4
|
import { BuildType } from '../types/common';
|
|
5
|
-
import {
|
|
5
|
+
import { ICommonBuildContext } from '../mp/BuildContext';
|
|
6
6
|
/**
|
|
7
7
|
* 该函数从 @govcloud/generate 取到需要的模版文件
|
|
8
8
|
*/
|
|
@@ -13,7 +13,7 @@ export declare function generateHTML({ buildContext, appId, envId, description,
|
|
|
13
13
|
* 默认值为 undefined 否则应为 false
|
|
14
14
|
*/
|
|
15
15
|
enableLoading, }: {
|
|
16
|
-
buildContext: Omit<
|
|
16
|
+
buildContext: Omit<ICommonBuildContext, 'mainAppData'>;
|
|
17
17
|
appId: string;
|
|
18
18
|
envId: string;
|
|
19
19
|
description?: string;
|
|
@@ -3,10 +3,10 @@ import { BuildType, WebpackModeType } from '../types/common';
|
|
|
3
3
|
import { RUNTIME } from '../../types';
|
|
4
4
|
import { IPlatformApp } from '@cloudbase/cals';
|
|
5
5
|
import { ICDN_ENDPOINTS_COFIG } from '../config';
|
|
6
|
-
import {
|
|
6
|
+
import { ICommonBuildContext } from '../mp/BuildContext';
|
|
7
7
|
import { IBuildWedaApp } from '../core';
|
|
8
8
|
export declare function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, buildTypeList, subAppCalsList, mode, devTool, runtime, deployOptions, ignoreInstall, cdnEndpoints, }: {
|
|
9
|
-
buildContext: Omit<
|
|
9
|
+
buildContext: Omit<ICommonBuildContext, 'mainAppData'>;
|
|
10
10
|
cals: IPlatformApp;
|
|
11
11
|
subAppCalsList: IPlatformApp[];
|
|
12
12
|
i18nConfig?: II18nConfig;
|
|
@@ -2,9 +2,9 @@ import { IWebRuntimeAppData } from '@cloudbase/lowcode-generator/lib/weapps-core
|
|
|
2
2
|
import { BuildAppProps } from '../core/index';
|
|
3
3
|
import { IPlatformApp } from '@cloudbase/cals';
|
|
4
4
|
import { ICDN_ENDPOINTS_COFIG } from '../config';
|
|
5
|
-
import {
|
|
5
|
+
import { ICommonBuildContext } from '../mp/BuildContext';
|
|
6
6
|
interface IWebpackCoreProps extends BuildAppProps {
|
|
7
|
-
buildContext: Omit<
|
|
7
|
+
buildContext: Omit<ICommonBuildContext, 'mainAppData'>;
|
|
8
8
|
cals: IPlatformApp;
|
|
9
9
|
appBuildDir: string;
|
|
10
10
|
mainAppData: IWebRuntimeAppData;
|
|
@@ -2,7 +2,7 @@ import { IMaterialItem, IWeAppData, IMiniprogramPlugin } from '@cloudbase/lowcod
|
|
|
2
2
|
/**
|
|
3
3
|
* All build parameters and intermediate data to be share across processes
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface ICommonBuildContext {
|
|
6
6
|
/**
|
|
7
7
|
* 账号信息
|
|
8
8
|
*/
|
|
@@ -11,8 +11,8 @@ export interface IBuildContext {
|
|
|
11
11
|
* 应用id
|
|
12
12
|
*/
|
|
13
13
|
appId: string;
|
|
14
|
-
domain: string;
|
|
15
14
|
projDir: string;
|
|
15
|
+
domain: string;
|
|
16
16
|
materialLibs: IMaterialItem[];
|
|
17
17
|
isProduction: boolean;
|
|
18
18
|
mainAppData: IWeAppData;
|
|
@@ -30,11 +30,6 @@ export interface IBuildContext {
|
|
|
30
30
|
* 云开发sdk请求,js-sdk or wx.cloud
|
|
31
31
|
*/
|
|
32
32
|
endpointType?: 'tcb-api' | 'wechat-service';
|
|
33
|
-
/**
|
|
34
|
-
* 是否在页面层面添加节点
|
|
35
|
-
* 并设置 #page-root-id
|
|
36
|
-
*/
|
|
37
|
-
enablePageRoot?: boolean;
|
|
38
33
|
/**
|
|
39
34
|
* 是否使用默认加载
|
|
40
35
|
*/
|
|
@@ -56,3 +51,14 @@ export interface IBuildContext {
|
|
|
56
51
|
*/
|
|
57
52
|
statusPageId?: string;
|
|
58
53
|
}
|
|
54
|
+
export interface IBuildContext extends ICommonBuildContext {
|
|
55
|
+
/**
|
|
56
|
+
* 是否在页面层面添加节点
|
|
57
|
+
* 并设置 #page-root-id
|
|
58
|
+
*/
|
|
59
|
+
enablePageRoot?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* 组件库目录独立子包
|
|
62
|
+
*/
|
|
63
|
+
enableAsyncMaterials?: boolean;
|
|
64
|
+
}
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -83,6 +83,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
83
83
|
await (0, materials_1.installMaterials)(buildContext, projDir, allAppUsedComps, weapps);
|
|
84
84
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!isProduction);
|
|
85
85
|
const { projConfig, appConfig, pageConfigs } = (0, mp_config_1.generateMpConfig)(buildContext, weapps, { mpAppId: options.mpAppId });
|
|
86
|
+
const hasLowcodePkg = weapps.find((item) => !item.mpPkgUrl);
|
|
86
87
|
// #1 generate project files
|
|
87
88
|
if (!mainAppData.mpPkgUrl) {
|
|
88
89
|
const projectFileData = {
|
|
@@ -99,7 +100,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
99
100
|
await generateFramework(buildContext, mainAppData, miniprogramRoot, { deployOptions });
|
|
100
101
|
// #3 生成主包根路径文件
|
|
101
102
|
let appFileData = {};
|
|
102
|
-
if (
|
|
103
|
+
if (hasLowcodePkg) {
|
|
103
104
|
await generateFramework(buildContext, mainAppData, miniprogramRoot, { deployOptions });
|
|
104
105
|
// 有了 framework app 之后,并且是源码的方式,追加 app 引用
|
|
105
106
|
if (mainAppData.mpPkgUrl) {
|
|
@@ -149,17 +150,35 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
149
150
|
*/
|
|
150
151
|
// 'common/behaviors.js': {},
|
|
151
152
|
};
|
|
153
|
+
if (buildContext.enableAsyncMaterials && !appFileData['common/placeholder']) {
|
|
154
|
+
appFileData['common/placeholder'] = {};
|
|
155
|
+
}
|
|
152
156
|
}
|
|
153
157
|
if (mainAppData.mpPkgUrl) {
|
|
154
158
|
// 合并 project 和 app json,复写 appId
|
|
155
159
|
projectConfigJson.appId = projConfig.appId;
|
|
156
|
-
if (!projectConfigJson.setting) {
|
|
157
|
-
projectConfigJson.setting = {};
|
|
158
|
-
}
|
|
159
160
|
projectConfigJson.setting = {
|
|
160
161
|
...projectConfigJson.setting,
|
|
161
162
|
...projConfig.setting,
|
|
162
163
|
};
|
|
164
|
+
const projectMpRoot = projectConfigJson.miniprogramRoot || '/';
|
|
165
|
+
if (!projectConfigJson.setting.packNpmManually) {
|
|
166
|
+
projectConfigJson.setting.packNpmManually = true;
|
|
167
|
+
}
|
|
168
|
+
if (!projectConfigJson.setting.packNpmRelationList) {
|
|
169
|
+
projectConfigJson.setting.packNpmRelationList = [];
|
|
170
|
+
}
|
|
171
|
+
projectConfigJson.setting.packNpmRelationList = [
|
|
172
|
+
...projectConfigJson.setting.packNpmRelationList.filter((item) => item.packageJsonPath === './package.json' || item.packageJsonPath === './packages/$wd_system/package.json'),
|
|
173
|
+
{
|
|
174
|
+
packageJsonPath: path_1.default.posix.join(projectMpRoot, 'package.json'),
|
|
175
|
+
miniprogramNpmDistDir: projectMpRoot,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
packageJsonPath: path_1.default.posix.join(projectMpRoot, 'packages', '$wd_system', 'package.json'),
|
|
179
|
+
miniprogramNpmDistDir: path_1.default.posix.join(projectMpRoot, 'packages', '$wd_system'),
|
|
180
|
+
},
|
|
181
|
+
];
|
|
163
182
|
await (0, generateFiles_1.writeFile)(projectConfigJsonPath, JSON.stringify(projectConfigJson, undefined, 2));
|
|
164
183
|
let appJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
|
|
165
184
|
let appJson = await fs.readJson(appJsonPath);
|
|
@@ -170,7 +189,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
170
189
|
const importor = (0, util_3.generateLowcodeImportor)(mainAppData.lowCodes || []);
|
|
171
190
|
appFileData = {
|
|
172
191
|
...appFileData,
|
|
173
|
-
'app.js': { appConfig, importor },
|
|
192
|
+
'app.js': { appConfig, importor, materialSubPackagePath: config_1.materialsDirName },
|
|
174
193
|
'app.json': { content: appConfig },
|
|
175
194
|
'app.wxss': {
|
|
176
195
|
importStyles: materials
|
|
@@ -196,7 +215,7 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
196
215
|
await fs.move(path_1.default.join(projDir, config_1.materialsDirName), path_1.default.join(miniprogramRoot, config_1.materialsDirName));
|
|
197
216
|
}
|
|
198
217
|
// 生成数据源
|
|
199
|
-
if (
|
|
218
|
+
if (hasLowcodePkg) {
|
|
200
219
|
const officialLib = materials.find((item) => item.name === cals_1.OFFICIAL_LIB_KEY);
|
|
201
220
|
const datasourceFileData = {
|
|
202
221
|
'datasources/index.js.tpl': {
|
|
@@ -225,6 +244,16 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
225
244
|
console.log(`Generating ${em('datasources')} files`);
|
|
226
245
|
await (0, generateFiles_1.default)(datasourceFileData, templateDir, miniprogramRoot);
|
|
227
246
|
}
|
|
247
|
+
// 生成上报 & 系统子包模块模块
|
|
248
|
+
if (hasLowcodePkg) {
|
|
249
|
+
const subpackageRootPath = path_1.default.join(miniprogramRoot, 'packages', '$wd_system');
|
|
250
|
+
const sysSubpackageFileData = {
|
|
251
|
+
'package.json': { cdnEndpoints },
|
|
252
|
+
'index.js.tpl': { cdnEndpoints },
|
|
253
|
+
};
|
|
254
|
+
console.log(`Generating ${em('system subpackage')} files`);
|
|
255
|
+
await (0, generateFiles_1.default)(sysSubpackageFileData, path_1.default.join(templateDir, 'packages/$wd_system'), subpackageRootPath);
|
|
256
|
+
}
|
|
228
257
|
// 生成子包
|
|
229
258
|
await Promise.all(weapps.map(async (app, index) => {
|
|
230
259
|
if (index == 0) {
|
|
@@ -252,11 +281,19 @@ async function generateWxMp({ buildContext, weapps, calses, plugins, deployOptio
|
|
|
252
281
|
}
|
|
253
282
|
}
|
|
254
283
|
}));
|
|
255
|
-
if (!isBrowserMpBuilder
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
284
|
+
if (!isBrowserMpBuilder) {
|
|
285
|
+
if (fs.existsSync(path_1.default.join(miniprogramRoot, 'package.json'))) {
|
|
286
|
+
await (0, webpack_1.installDependencies)(miniprogramRoot, {
|
|
287
|
+
ignoreInstall,
|
|
288
|
+
fixNodeModulesMap: { '@cloudbase/js-sdk': endpointType !== 'tcb-api', mobx: true },
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
const wdSystemSubRoot = path_1.default.join(miniprogramRoot, 'packages', '$wd_system');
|
|
292
|
+
if (fs.existsSync(path_1.default.join(wdSystemSubRoot, 'package.json'))) {
|
|
293
|
+
await (0, webpack_1.installDependencies)(wdSystemSubRoot, {
|
|
294
|
+
ignoreInstall,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
260
297
|
}
|
|
261
298
|
await handleMpPlugins();
|
|
262
299
|
console.timeEnd(operationLabel);
|
|
@@ -365,6 +402,18 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
365
402
|
(0, util_2.setDataBind)(pageDataBinds, prop, val);
|
|
366
403
|
}
|
|
367
404
|
});
|
|
405
|
+
/**
|
|
406
|
+
* 使用最终的 usingComponents 生成一份 componentPlaceholder
|
|
407
|
+
*/
|
|
408
|
+
let componentPlaceholder;
|
|
409
|
+
if (usingComponents[wxml_1.WD_EMPTY_PLACEHOLDER] && ctx.enableAsyncMaterials) {
|
|
410
|
+
componentPlaceholder = Object.keys(usingComponents).reduce((map, key) => {
|
|
411
|
+
if (!wxml_1.WD_RUNTIME_TAG.includes(key)) {
|
|
412
|
+
map[key] = wxml_1.WD_EMPTY_PLACEHOLDER;
|
|
413
|
+
}
|
|
414
|
+
return map;
|
|
415
|
+
}, {});
|
|
416
|
+
}
|
|
368
417
|
const pageFileData = {
|
|
369
418
|
[`api.js|api.js`]: {
|
|
370
419
|
subLevelPath,
|
|
@@ -401,6 +450,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
401
450
|
[`index.json|${pageFileName}.json`]: {
|
|
402
451
|
usingComponents,
|
|
403
452
|
componentGenerics,
|
|
453
|
+
componentPlaceholder,
|
|
404
454
|
extra: getAppendableJson(pageConfigs[page.id]),
|
|
405
455
|
},
|
|
406
456
|
[`index.wxml|${pageFileName}.wxml`]: {
|
|
@@ -181,7 +181,11 @@ async function installMaterials(ctx, projDir, usedComps, weapps) {
|
|
|
181
181
|
await Promise.all(lib.components.map(async (cmp) => {
|
|
182
182
|
return generateCompositeComponent({
|
|
183
183
|
...ctx,
|
|
184
|
-
|
|
184
|
+
/**
|
|
185
|
+
* 此处强行覆盖为 rpx 是为了兼容老的复合组件
|
|
186
|
+
* $template 应该跟随应用的配置
|
|
187
|
+
*/
|
|
188
|
+
processCssUnit: lib.name !== '$template' ? 'rpx' : ctx.processCssUnit,
|
|
185
189
|
// 只生成在主目录中,减少冗余
|
|
186
190
|
// rootPath: app.rootPath || '', // 主包是没有 rootPath 的
|
|
187
191
|
}, cmp, lib.compLibCommonResource);
|
|
@@ -41,7 +41,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
41
41
|
* @param appConfigs app config from prop edit panel
|
|
42
42
|
*/
|
|
43
43
|
function generateMpConfig(ctx, weapps, options) {
|
|
44
|
-
var _a;
|
|
44
|
+
var _a, _b;
|
|
45
45
|
const appConfig = {
|
|
46
46
|
useExtendedLib: { weui: true },
|
|
47
47
|
};
|
|
@@ -87,7 +87,23 @@ function generateMpConfig(ctx, weapps, options) {
|
|
|
87
87
|
// keep main app config only, ignore subapp config
|
|
88
88
|
const { subpackages, ...extra } = extractPages(weapps, pageConfigs);
|
|
89
89
|
(0, lodash_1.merge)(appConfig, mainAppConfig, extra);
|
|
90
|
-
appConfig.subpackages = mergeSubPackages(appConfig.subpackages,
|
|
90
|
+
appConfig.subpackages = mergeSubPackages(appConfig.subpackages, [
|
|
91
|
+
{
|
|
92
|
+
root: 'packages/$wd_system',
|
|
93
|
+
name: 'wd-sys-module',
|
|
94
|
+
pages: [],
|
|
95
|
+
},
|
|
96
|
+
]
|
|
97
|
+
.concat(ctx.enableAsyncMaterials && !((_b = weapps[0]) === null || _b === void 0 ? void 0 : _b.mpPkgUrl)
|
|
98
|
+
? [
|
|
99
|
+
{
|
|
100
|
+
root: config_1.materialsDirName,
|
|
101
|
+
name: 'wd-sys-materials',
|
|
102
|
+
pages: [],
|
|
103
|
+
},
|
|
104
|
+
]
|
|
105
|
+
: [])
|
|
106
|
+
.concat(subpackages));
|
|
91
107
|
if (tradingCapability) {
|
|
92
108
|
const tradePluginKey = `weda-mini-shop-plugin`;
|
|
93
109
|
const pluginMeta = {
|
|
@@ -121,6 +137,17 @@ function generateMpConfig(ctx, weapps, options) {
|
|
|
121
137
|
projConfig.setting = {};
|
|
122
138
|
}
|
|
123
139
|
projConfig.setting.bigPackageSizeSupport = true;
|
|
140
|
+
projConfig.setting.packNpmManually = true;
|
|
141
|
+
projConfig.setting.packNpmRelationList = [
|
|
142
|
+
{
|
|
143
|
+
packageJsonPath: './package.json',
|
|
144
|
+
miniprogramNpmDistDir: './',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
packageJsonPath: './packages/$wd_system/package.json',
|
|
148
|
+
miniprogramNpmDistDir: './packages/$wd_system',
|
|
149
|
+
},
|
|
150
|
+
];
|
|
124
151
|
if (process.env.IS_WEB_WORKER) {
|
|
125
152
|
projConfig.setting.ignoreUploadUnusedFiles = true;
|
|
126
153
|
}
|
package/lib/builder/mp/wxml.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IWeAppComponentInstance, IEventModifiers } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { IBuildContext } from './BuildContext';
|
|
3
|
+
export declare const WD_EMPTY_PLACEHOLDER = "wd-ph";
|
|
4
|
+
export declare const WD_RUNTIME_TAG: string[];
|
|
3
5
|
export declare function generateWxml(ctx: IBuildContext & {
|
|
4
6
|
pageUUID?: string;
|
|
5
7
|
}, widgets: {
|
package/lib/builder/mp/wxml.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getUsedComponents = exports.getMpEventHandlerName = exports.generateWxml = void 0;
|
|
6
|
+
exports.getUsedComponents = exports.getMpEventHandlerName = exports.generateWxml = exports.WD_RUNTIME_TAG = exports.WD_EMPTY_PLACEHOLDER = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
9
9
|
const xml_js_1 = require("xml-js");
|
|
@@ -13,6 +13,9 @@ const weapp_1 = require("@cloudbase/lowcode-generator/lib/generator/util/weapp")
|
|
|
13
13
|
const name_mangler_1 = __importDefault(require("@cloudbase/lowcode-generator/lib/generator/util/name-mangler"));
|
|
14
14
|
const config_1 = require("../config");
|
|
15
15
|
const util_1 = require("./util");
|
|
16
|
+
exports.WD_EMPTY_PLACEHOLDER = 'wd-ph';
|
|
17
|
+
const WD_INFO = 'wd-info';
|
|
18
|
+
exports.WD_RUNTIME_TAG = [exports.WD_EMPTY_PLACEHOLDER, WD_INFO];
|
|
16
19
|
const error = chalk_1.default.redBright;
|
|
17
20
|
function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, componentGenerics, nodeTransform) {
|
|
18
21
|
const nameMangler = ctx.isProduction ? new name_mangler_1.default({ blackList: mp_1.builtinMpTags }) : undefined;
|
|
@@ -20,15 +23,18 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
20
23
|
elements: createXml(widgets),
|
|
21
24
|
};
|
|
22
25
|
if (ctx.pageUUID) {
|
|
23
|
-
const { enablePageRoot, disabled } = ctx;
|
|
26
|
+
const { enablePageRoot, disabled, enableAsyncMaterials } = ctx;
|
|
24
27
|
const originElements = xmlJson.elements;
|
|
25
28
|
// usingComponents['wd-privacy'] = '/common/privacyModal/index';
|
|
26
|
-
usingComponents[
|
|
29
|
+
usingComponents[WD_INFO] = '/common/info/index';
|
|
30
|
+
if (enableAsyncMaterials) {
|
|
31
|
+
usingComponents[exports.WD_EMPTY_PLACEHOLDER] = '/common/placeholder/index';
|
|
32
|
+
}
|
|
27
33
|
if (disabled && ctx.pageUUID !== ctx.statusPageId) {
|
|
28
34
|
xmlJson.elements = [
|
|
29
35
|
{
|
|
30
36
|
type: 'element',
|
|
31
|
-
name:
|
|
37
|
+
name: WD_INFO,
|
|
32
38
|
attributes: {
|
|
33
39
|
message: '当前页面无法访问',
|
|
34
40
|
type: 'notfound',
|
|
@@ -83,7 +89,7 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
83
89
|
},
|
|
84
90
|
{
|
|
85
91
|
type: 'element',
|
|
86
|
-
name:
|
|
92
|
+
name: WD_INFO,
|
|
87
93
|
attributes: {
|
|
88
94
|
['wx:if']: '{{weDaHasLogin === false && !_expiredMessage}}',
|
|
89
95
|
message: '无权限访问',
|
|
@@ -98,10 +104,9 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
98
104
|
},
|
|
99
105
|
];
|
|
100
106
|
if (ctx.enableExpiredTag) {
|
|
101
|
-
usingComponents['wd-info'] = '/common/info/index';
|
|
102
107
|
xmlJson.elements.push({
|
|
103
108
|
type: 'element',
|
|
104
|
-
name:
|
|
109
|
+
name: WD_INFO,
|
|
105
110
|
attributes: {
|
|
106
111
|
['wx:if']: '{{_expiredMessage}}',
|
|
107
112
|
message: '{{_expiredMessage}}',
|
|
@@ -113,10 +118,9 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
113
118
|
});
|
|
114
119
|
}
|
|
115
120
|
if (ctx.enableLoading) {
|
|
116
|
-
usingComponents['wd-info'] = '/common/info/index';
|
|
117
121
|
xmlJson.elements.push({
|
|
118
122
|
type: 'element',
|
|
119
|
-
name:
|
|
123
|
+
name: WD_INFO,
|
|
120
124
|
attributes: {
|
|
121
125
|
['wx:if']: '{{_isCheckingAtuh && !_expiredMessage}}',
|
|
122
126
|
type: 'loading',
|
package/lib/builder/util/net.js
CHANGED
|
@@ -95,10 +95,11 @@ async function saveFiles(files, dstDir) {
|
|
|
95
95
|
if ((0, junk_1.isFilePath)(dest)) {
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
|
-
if (files[fileName].dir) {
|
|
98
|
+
if (files[fileName].dir) {
|
|
99
|
+
// 如果该文件为目录需先创建文件夹
|
|
99
100
|
if (!fs_extra_1.default.pathExistsSync(dest)) {
|
|
100
101
|
fs_extra_1.default.mkdirSync(dest, {
|
|
101
|
-
recursive: true
|
|
102
|
+
recursive: true,
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
}
|
|
@@ -118,8 +119,13 @@ async function saveFiles(files, dstDir) {
|
|
|
118
119
|
* @param output
|
|
119
120
|
*/
|
|
120
121
|
async function downloadBrowserMaterial(output = '.weapps-build') {
|
|
121
|
-
await Promise.all([
|
|
122
|
+
await Promise.all([
|
|
123
|
+
downloadZip(config_1.builderTemplateURL, config_1.appTemplateDir, true),
|
|
124
|
+
downloadZip(config_1.miniprogramURL, config_1.miniprogramDir, true),
|
|
125
|
+
downloadZip(config_1.systemSubpackageMiniprogramURL, config_1.systemSubpackageMiniprogramDir, true),
|
|
126
|
+
]);
|
|
122
127
|
// 必须先下载到.weapps-materials目录,因为.weapps-materials是默认下载目录,共享组件逻辑sharedMaterialsDir时会读取文件
|
|
123
128
|
(0, generateFiles_1.copyRecursiveSync)(config_1.miniprogramDir, path.join(output, 'miniprogram_npm'));
|
|
129
|
+
(0, generateFiles_1.copyRecursiveSync)(config_1.systemSubpackageMiniprogramDir, path.join(output, 'packages', '$wd_system', 'miniprogram_npm'));
|
|
124
130
|
}
|
|
125
131
|
exports.downloadBrowserMaterial = downloadBrowserMaterial;
|