@cloudbase/lowcode-builder 1.8.100 → 1.8.102
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/config/index.d.ts +4 -0
- package/lib/builder/config/index.js +8 -1
- package/lib/builder/core/index.d.ts +2 -1
- package/lib/builder/core/index.js +15 -4
- package/lib/builder/h5/index.js +2 -1
- package/lib/builder/mp/BuildContext.d.ts +5 -0
- package/lib/builder/mp/index.js +35 -17
- package/lib/builder/mp/materials.js +1 -1
- package/lib/builder/mp/wxml.js +1 -1
- package/lib/builder.web.js +8 -8
- package/package.json +3 -3
- package/template/html/index.html.ejs +2 -2
- package/template/mp/app/weapps-api.js +2 -0
- package/template/mp/common/weapp-page.js +6 -4
- package/template/mp/datasources/config.js.tpl +7 -1
- package/template/mp/packages/$wd_system/index.js.tpl +2 -1
- package/template/mp/packages/$wd_system/package.json +7 -3
- package/template/mp/packages/$wd_system/privatelink/cloudbase.privatelink.vender.js +2 -0
- package/template/mp/packages/$wd_system/privatelink/cloudbase.privatelink.vm.js +1 -0
- package/template/mp/packages/$wd_system/privatelink/index.js +19 -0
- package/template/mp/packages/$wd_system/privatelink/pollyfill.js +36 -0
|
@@ -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.systemSubpackageMiniprogramDir = exports.cloudbaseMiniprogramDir = exports.miniprogramDir = exports.RUNTIME_CONFIG_URL = exports.systemSubpackageMiniprogramURL = exports.cloudbaseMiniprogramURL = exports.miniprogramURL = 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.getPrivatelinkJsUrl = exports.REPEATER = exports.generateCdnEndpoints = exports.CDN_ENDPONTS_CONFIG = exports.systemSubpackageMiniprogramDir = exports.cloudbaseMiniprogramDir = exports.miniprogramDir = exports.RUNTIME_CONFIG_URL = exports.systemSubpackageMiniprogramURL = exports.cloudbaseMiniprogramURL = exports.miniprogramURL = 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");
|
|
@@ -79,3 +79,10 @@ exports.REPEATER = {
|
|
|
79
79
|
REPEATER_NAME: 'Repeater',
|
|
80
80
|
REPEATER_ITEM_NAME: 'RepeaterItem',
|
|
81
81
|
};
|
|
82
|
+
function getPrivatelinkJsUrl(cdngoDomain = exports.CDN_ENDPONTS_CONFIG.cdngo) {
|
|
83
|
+
return {
|
|
84
|
+
vm: `${cdngoDomain}/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/privatelink@0.0.1/dist/cdn/cloudbase.privatelink.vm.js`,
|
|
85
|
+
vender: `${cdngoDomain}/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/privatelink-vender@0.0.2/dist/cdn/cloudbase.privatelink.vender.js`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
exports.getPrivatelinkJsUrl = getPrivatelinkJsUrl;
|
|
@@ -53,6 +53,7 @@ export interface IBuildWedaApp extends IBaseAppProps {
|
|
|
53
53
|
appJson?: Record<string, any>;
|
|
54
54
|
projectConfigJson?: Record<string, any>;
|
|
55
55
|
};
|
|
56
|
+
privatelinkConfig?: Record<string, any>;
|
|
56
57
|
}
|
|
57
58
|
export declare function buildWedaConfig({ output, domain, isPrivateMode, endpointType, buildTypeList, }: {
|
|
58
59
|
output: Required<IBuildWedaApp['output']>;
|
|
@@ -61,7 +62,7 @@ export declare function buildWedaConfig({ output, domain, isPrivateMode, endpoin
|
|
|
61
62
|
endpointType?: IBuildWedaApp['endpointType'];
|
|
62
63
|
buildTypeList?: IBuildWedaApp['buildTypeList'];
|
|
63
64
|
}): Promise<void>;
|
|
64
|
-
export declare function buildWedaApp({ cals, subAppCalsList: _subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder, cdnEndpoints, isPrivateMode, endpointType, enableExpiredTag, enableAd, account, mpConfig, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<any>;
|
|
65
|
+
export declare function buildWedaApp({ cals, subAppCalsList: _subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder, cdnEndpoints: _cdnEndpoints, isPrivateMode, endpointType, enableExpiredTag, enableAd, account, mpConfig, privatelinkConfig, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<any>;
|
|
65
66
|
export declare function cleanComponentDir(): Promise<void>;
|
|
66
67
|
export declare const version: any;
|
|
67
68
|
export { getFiles, fileToZip, strToBuf } from '../util/generateFiles';
|
|
@@ -60,8 +60,9 @@ exports.buildWedaConfig = buildWedaConfig;
|
|
|
60
60
|
async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], dependencies = [], appKey = 'test', runtime = types_1.RUNTIME.NONE, ignoreInstall = false, buildTypeList = [common_1.BuildType.WEB], mode = common_1.WebpackModeType.PRODUCTION, devTool = 'webpack', deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, generateMpType = common_1.GenerateMpType.APP, plugins = [], extraData = {
|
|
61
61
|
isComposite: false,
|
|
62
62
|
compProps: {},
|
|
63
|
-
}, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, cdnEndpoints, isPrivateMode = false, endpointType = undefined, enableExpiredTag = false, enableAd = false, account = {}, mpConfig = {}, }, cb) {
|
|
63
|
+
}, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, cdnEndpoints: _cdnEndpoints, isPrivateMode = false, endpointType = undefined, enableExpiredTag = false, enableAd = false, account = {}, mpConfig = {}, privatelinkConfig = undefined, }, cb) {
|
|
64
64
|
var _a, _b, _c, _d, _e, _f;
|
|
65
|
+
const cdnEndpoints = (0, config_1.generateCdnEndpoints)(_cdnEndpoints);
|
|
65
66
|
if (!cals) {
|
|
66
67
|
console.error('无效的应用配置');
|
|
67
68
|
return;
|
|
@@ -117,6 +118,7 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
|
|
|
117
118
|
runtimeDynamicConfig,
|
|
118
119
|
disabled: (_c = cals.extra) === null || _c === void 0 ? void 0 : _c.disabled,
|
|
119
120
|
statusPageId: (_d = cals.extra) === null || _d === void 0 ? void 0 : _d.statusPageId,
|
|
121
|
+
privatelinkConfig: privatelinkConfig ? { uin: account === null || account === void 0 ? void 0 : account.uin, ...privatelinkConfig } : undefined,
|
|
120
122
|
};
|
|
121
123
|
console.log('domain', domain);
|
|
122
124
|
console.log('应用名', appKey);
|
|
@@ -171,6 +173,9 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
|
|
|
171
173
|
const { enablePageRoot } = (0, cals_1.parseVersion)(cals === null || cals === void 0 ? void 0 : cals.schemaVersion, dependencies);
|
|
172
174
|
const mpBuildContext = {
|
|
173
175
|
...buildContext,
|
|
176
|
+
privatelinkConfig: buildContext.privatelinkConfig
|
|
177
|
+
? { ...buildContext.privatelinkConfig, jsUrl: undefined }
|
|
178
|
+
: undefined,
|
|
174
179
|
projDir: (output === null || output === void 0 ? void 0 : output.path) || path_1.default.join(appBuildDir, 'mp'),
|
|
175
180
|
mainAppData: mainAppSerializeData,
|
|
176
181
|
processCssUnit: (calses.find((cals) => {
|
|
@@ -197,7 +202,7 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
|
|
|
197
202
|
},
|
|
198
203
|
buildTypeList,
|
|
199
204
|
ignoreInstall,
|
|
200
|
-
cdnEndpoints
|
|
205
|
+
cdnEndpoints,
|
|
201
206
|
mpConfig,
|
|
202
207
|
});
|
|
203
208
|
const outDir = mpBuildContext.projDir;
|
|
@@ -220,7 +225,13 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
|
|
|
220
225
|
if (!process.env.IS_WEB_WORKER) {
|
|
221
226
|
const { buildH5App } = require('../h5/index');
|
|
222
227
|
const h5BuildDir = await buildH5App({
|
|
223
|
-
buildContext: {
|
|
228
|
+
buildContext: {
|
|
229
|
+
...buildContext,
|
|
230
|
+
isMixMode: false,
|
|
231
|
+
privatelinkConfig: buildContext.privatelinkConfig
|
|
232
|
+
? { ...buildContext.privatelinkConfig, jsUrl: (0, config_1.getPrivatelinkJsUrl)(cdnEndpoints.cdngo) }
|
|
233
|
+
: undefined,
|
|
234
|
+
},
|
|
224
235
|
cals,
|
|
225
236
|
subAppCalsList,
|
|
226
237
|
extraData,
|
|
@@ -230,7 +241,7 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
|
|
|
230
241
|
runtime,
|
|
231
242
|
deployOptions,
|
|
232
243
|
ignoreInstall,
|
|
233
|
-
cdnEndpoints
|
|
244
|
+
cdnEndpoints,
|
|
234
245
|
});
|
|
235
246
|
await (cb === null || cb === void 0 ? void 0 : cb(null, {
|
|
236
247
|
outDir: h5BuildDir,
|
package/lib/builder/h5/index.js
CHANGED
|
@@ -52,7 +52,7 @@ if (!process.env.IS_WEB_WORKER) {
|
|
|
52
52
|
}
|
|
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
|
-
const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode, enableExpiredTag, } = buildContext;
|
|
55
|
+
const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode, enableExpiredTag, privatelinkConfig, } = buildContext;
|
|
56
56
|
if (!deployOptions.mode) {
|
|
57
57
|
deployOptions.mode = types_1.DEPLOY_MODE.PREVIEW;
|
|
58
58
|
}
|
|
@@ -129,6 +129,7 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
|
|
|
129
129
|
isPrivateMode,
|
|
130
130
|
expirationStartTimesnap: enableExpiredTag ? Date.now() : undefined,
|
|
131
131
|
usedComps: used,
|
|
132
|
+
privatelinkConfig,
|
|
132
133
|
});
|
|
133
134
|
console.timeEnd(runGenerateTag);
|
|
134
135
|
// // 构建 NPM 包
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IMaterialItem, IWeAppData, IMiniprogramPlugin } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
|
+
import { IBuildWedaApp } from '../core';
|
|
2
3
|
/**
|
|
3
4
|
* All build parameters and intermediate data to be share across processes
|
|
4
5
|
*/
|
|
@@ -31,6 +32,10 @@ export interface IAppCommonBuildContext extends ICommonBuildContext {
|
|
|
31
32
|
* 云开发sdk请求,js-sdk or wx.cloud
|
|
32
33
|
*/
|
|
33
34
|
endpointType?: 'tcb-api' | 'wechat-service';
|
|
35
|
+
/**
|
|
36
|
+
* 云开发私密链路配置
|
|
37
|
+
*/
|
|
38
|
+
privatelinkConfig?: IBuildWedaApp['privatelinkConfig'];
|
|
34
39
|
/**
|
|
35
40
|
* 是否使用默认加载
|
|
36
41
|
*/
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -256,6 +256,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
256
256
|
builderVersion: core_1.version || '',
|
|
257
257
|
officialLibVersion: (officialLib === null || officialLib === void 0 ? void 0 : officialLib.version) || '',
|
|
258
258
|
uin,
|
|
259
|
+
privatelink: buildContext.privatelinkConfig
|
|
260
|
+
? JSON.stringify(buildContext.privatelinkConfig, undefined, 2)
|
|
261
|
+
: undefined,
|
|
259
262
|
},
|
|
260
263
|
'datasources/datasource-profiles.js.tpl': {
|
|
261
264
|
datasourceProfiles: (0, util_3.JsonToStringWithVariableName)([], { EOL: false }),
|
|
@@ -271,27 +274,42 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
|
|
|
271
274
|
// 生成上报 & 系统子包模块模块
|
|
272
275
|
const subpackageRootPath = path_1.default.join(localWedaRoot, 'packages', '$wd_system');
|
|
273
276
|
const sysSubpackageFileData = {
|
|
274
|
-
'package.json': { cdnEndpoints },
|
|
275
|
-
'index.js.tpl': { cdnEndpoints },
|
|
277
|
+
'package.json': { cdnEndpoints, privatelink: !!buildContext.privatelinkConfig },
|
|
278
|
+
'index.js.tpl': { cdnEndpoints, privatelink: !!buildContext.privatelinkConfig },
|
|
276
279
|
};
|
|
277
280
|
console.log(`Generating ${em('system subpackage')} files`);
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
284
|
-
if (/login\//.test(src)) {
|
|
285
|
-
if ((_b = (_a = calses[0]) === null || _a === void 0 ? void 0 : _a.extra) === null || _b === void 0 ? void 0 : _b.loginConfigVersion) {
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
281
|
+
function copyFilterTplRecursiveSync(src, dest, options) {
|
|
282
|
+
return (0, generateFiles_1.copyRecursiveSync)(src, dest, {
|
|
283
|
+
filter: (src) => {
|
|
284
|
+
if (/.tpl$/.test(src)) {
|
|
289
285
|
return false;
|
|
290
286
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
287
|
+
if (options === null || options === void 0 ? void 0 : options.filter) {
|
|
288
|
+
return options === null || options === void 0 ? void 0 : options.filter(src);
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
Promise.all([
|
|
295
|
+
!!buildContext.privatelinkConfig
|
|
296
|
+
? copyFilterTplRecursiveSync(path_1.default.join(templateDir, 'packages/$wd_system/privatelink'), path_1.default.join(subpackageRootPath, 'privatelink'))
|
|
297
|
+
: Promise.resolve(),
|
|
298
|
+
copyFilterTplRecursiveSync(path_1.default.join(templateDir, 'packages/$wd_system/pages'), path_1.default.join(subpackageRootPath, 'pages'), {
|
|
299
|
+
filter: (src) => {
|
|
300
|
+
var _a, _b;
|
|
301
|
+
if (/login\//.test(src)) {
|
|
302
|
+
if ((_b = (_a = calses[0]) === null || _a === void 0 ? void 0 : _a.extra) === null || _b === void 0 ? void 0 : _b.loginConfigVersion) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
},
|
|
311
|
+
}),
|
|
312
|
+
]);
|
|
295
313
|
await (0, generateFiles_1.default)(sysSubpackageFileData, path_1.default.join(templateDir, 'packages/$wd_system'), subpackageRootPath);
|
|
296
314
|
}
|
|
297
315
|
// #4 生成 miniprogramRoot 文件
|
|
@@ -85,7 +85,7 @@ async function generateCompLibs(ctx, outDir, mode) {
|
|
|
85
85
|
processCssUnit: lib.name === cals_1.OFFICIAL_COMPONENT_LIB_NAME || reg.test(lib.name) ? 'rpx' : ctx.processCssUnit,
|
|
86
86
|
// 只生成在主目录中,减少冗余
|
|
87
87
|
// rootPath: app.rootPath || '', // 主包是没有 rootPath 的
|
|
88
|
-
}, cmp, outDir, lib.rootPath !== undefined ? lib.rootPath : path.join(config_1.materialsDirName, lib.name), lib.compLibCommonResource, mode);
|
|
88
|
+
}, cmp, outDir, lib.rootPath !== undefined ? lib.rootPath : path.posix.join(config_1.materialsDirName, lib.name), lib.compLibCommonResource, mode);
|
|
89
89
|
}));
|
|
90
90
|
}));
|
|
91
91
|
}
|
package/lib/builder/mp/wxml.js
CHANGED
|
@@ -47,7 +47,7 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
|
|
|
47
47
|
type: 'element',
|
|
48
48
|
name: WD_INFO,
|
|
49
49
|
attributes: {
|
|
50
|
-
message: '当前页面无法访问',
|
|
50
|
+
message: disabled ? '当前应用已停用' : '当前页面无法访问',
|
|
51
51
|
type: 'notfound',
|
|
52
52
|
enableCustom: true,
|
|
53
53
|
pageUUID: ctx.pageUUID,
|