@cloudbase/lowcode-builder 1.8.99 → 1.8.101

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.
@@ -28,3 +28,7 @@ export declare const REPEATER: {
28
28
  REPEATER_NAME: string;
29
29
  REPEATER_ITEM_NAME: string;
30
30
  };
31
+ export declare function getPrivatelinkJsUrl(cdngoDomain?: string | undefined): {
32
+ vm: string;
33
+ vender: string;
34
+ };
@@ -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: (0, config_1.generateCdnEndpoints)(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: { ...buildContext, isMixMode: false },
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: (0, config_1.generateCdnEndpoints)(cdnEndpoints),
244
+ cdnEndpoints,
234
245
  });
235
246
  await (cb === null || cb === void 0 ? void 0 : cb(null, {
236
247
  outDir: h5BuildDir,
@@ -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
  */
@@ -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
- await (0, generateFiles_1.copyRecursiveSync)(path_1.default.join(templateDir, 'packages/$wd_system/pages'), path_1.default.join(subpackageRootPath, 'pages'), {
279
- filter: (src) => {
280
- var _a, _b;
281
- if (/.tpl$/.test(src)) {
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
- return true;
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 文件
@@ -501,7 +519,7 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
501
519
  return map;
502
520
  }, {});
503
521
  await Promise.all(weapp.pageInstanceList.map(async (page, index) => {
504
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
522
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
505
523
  // # Generating page
506
524
  const rootPath = weapp.rootPath || '';
507
525
  const usingComponents = {};
@@ -519,7 +537,7 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
519
537
  const subLevelPath = rootPath ? `${path_1.default.posix.relative(`packages/${rootPath}`, '')}/` : '';
520
538
  const pageDataBinds = {};
521
539
  Object.entries(page.data || {}).forEach(([prop, val]) => {
522
- if (/^(appShareMessage)/.test(prop)) {
540
+ if (/^(appShareMessage|shareTimeline)/.test(prop)) {
523
541
  (0, util_2.setDataBind)(pageDataBinds, prop, val);
524
542
  }
525
543
  });
@@ -562,7 +580,8 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
562
580
  eventHandlers: (0, util_2.createEventHandlers)(ctx, componentInstances, 'this', page),
563
581
  dataBinds: (0, util_2.createDataBinds)(ctx, componentInstances),
564
582
  pageAttributes: {
565
- ...(((_e = page.data) === null || _e === void 0 ? void 0 : _e.appShareMessage) ? { appShareMessage: page.data.appShareMessage.value } : {}),
583
+ appShareMessage: (_f = (_e = page.data) === null || _e === void 0 ? void 0 : _e.appShareMessage) === null || _f === void 0 ? void 0 : _f.value,
584
+ shareTimeline: (_h = (_g = page.data) === null || _g === void 0 ? void 0 : _g.shareTimeline) === null || _h === void 0 ? void 0 : _h.value,
566
585
  },
567
586
  pageDataBinds,
568
587
  debug: ctx.debugMode,
@@ -572,11 +591,11 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
572
591
  stringifyObj: util_1.inspect,
573
592
  subLevelPath,
574
593
  importor,
575
- query: (0, util_2.createTemplateQuery)(ctx, (_f = page.dataset) === null || _f === void 0 ? void 0 : _f.query),
594
+ query: (0, util_2.createTemplateQuery)(ctx, (_j = page.dataset) === null || _j === void 0 ? void 0 : _j.query),
576
595
  datasetProfile: (0, util_3.JsonToStringWithVariableName)((0, lowcode_generator_1.generateDynamicDataset)(page.dataset || {}), { EOL: true }),
577
596
  eventFlows: (0, util_2.createTemplateEventFlows)(ctx, page.eventFlows),
578
- 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) ||
579
- ((_k = allAppUsedComps === null || allAppUsedComps === void 0 ? void 0 : allAppUsedComps[cals_1.OFFICIAL_LIB_KEY]) === null || _k === void 0 ? void 0 : _k.has('Share')) ||
597
+ resetShare: ((_m = (_l = (_k = page === null || page === void 0 ? void 0 : page.data) === null || _k === void 0 ? void 0 : _k.appShareMessage) === null || _l === void 0 ? void 0 : _l.value) === null || _m === void 0 ? void 0 : _m.enable) ||
598
+ ((_o = allAppUsedComps === null || allAppUsedComps === void 0 ? void 0 : allAppUsedComps[cals_1.OFFICIAL_LIB_KEY]) === null || _o === void 0 ? void 0 : _o.has('Share')) ||
580
599
  /* 从 enablePageRoot 的版本开始支持按需reset share
581
600
  * 否则默认都开启
582
601
  */ !ctx.enablePageRoot,
@@ -591,13 +610,13 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs, cssVarMap
591
610
  content: wxml,
592
611
  },
593
612
  [`index.wxss|${pageFileName}.wxss`]: {
594
- subWxss: rootPath && !((_l = ctx.mainAppData) === null || _l === void 0 ? void 0 : _l.mpPkgUrl)
613
+ subWxss: rootPath && !((_p = ctx.mainAppData) === null || _p === void 0 ? void 0 : _p.mpPkgUrl)
595
614
  ? `@import "${path_1.default.posix.relative(`/packages/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
596
615
  : '',
597
616
  content: [
598
- (0, weapps_core_1.toCssText)(((_o = (_m = CALS_PAGE_MAP[page.id]) === null || _m === void 0 ? void 0 : _m.attributes) === null || _o === void 0 ? void 0 : _o.style) &&
599
- ((_r = Object.keys(((_q = (_p = CALS_PAGE_MAP[page.id]) === null || _p === void 0 ? void 0 : _p.attributes) === null || _q === void 0 ? void 0 : _q.style) || {})) === null || _r === void 0 ? void 0 : _r.length)
600
- ? (0, cals_1.processCSSPropertiesUnit)(((_t = (_s = CALS_PAGE_MAP[page.id]) === null || _s === void 0 ? void 0 : _s.attributes) === null || _t === void 0 ? void 0 : _t.style) || {}, processCssUnit)
617
+ (0, weapps_core_1.toCssText)(((_r = (_q = CALS_PAGE_MAP[page.id]) === null || _q === void 0 ? void 0 : _q.attributes) === null || _r === void 0 ? void 0 : _r.style) &&
618
+ ((_u = Object.keys(((_t = (_s = CALS_PAGE_MAP[page.id]) === null || _s === void 0 ? void 0 : _s.attributes) === null || _t === void 0 ? void 0 : _t.style) || {})) === null || _u === void 0 ? void 0 : _u.length)
619
+ ? (0, cals_1.processCSSPropertiesUnit)(((_w = (_v = CALS_PAGE_MAP[page.id]) === null || _v === void 0 ? void 0 : _v.attributes) === null || _w === void 0 ? void 0 : _w.style) || {}, processCssUnit)
601
620
  : (0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
602
621
  defaultUnit: processCssUnit,
603
622
  }), 'page'),
@@ -729,7 +748,7 @@ async function writeLowCodeFiles(ctx, appData, outDir, cssVarMap) {
729
748
  exports.writeLowCodeFiles = writeLowCodeFiles;
730
749
  // {a: 1} -> , "a": 1
731
750
  function getAppendableJson(json = {}) {
732
- const { namespace, appShareMessage, ...restJson } = json;
751
+ const { namespace, appShareMessage, shareTimeline, ...restJson } = json;
733
752
  const obj = { ...restJson };
734
753
  if (obj.reachBottomDistance) {
735
754
  obj.onReachBottomDistance = parseInt(obj.reachBottomDistance, 10) || 0;