@cloudbase/lowcode-builder 1.8.88 → 1.8.89

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.
@@ -58,8 +58,12 @@ const templateDir = `${config_1.appTemplateDir}/mp/`;
58
58
  const em = chalk_1.default.blue.bold;
59
59
  const error = chalk_1.default.redBright;
60
60
  function patchBuildContext(ctx, calses) {
61
+ var _a, _b;
61
62
  const { mainAppData } = ctx;
62
63
  const used = (0, cals_1.getUsedComps)(calses, ctx.materialLibs, { streamline: true, withAction: true });
64
+ if ((_a = used.component) === null || _a === void 0 ? void 0 : _a['$template']) {
65
+ ctx.materialLibs = [...ctx.materialLibs, (0, cals_1.processTemplatesToDependiencies)((_b = calses === null || calses === void 0 ? void 0 : calses[0]) === null || _b === void 0 ? void 0 : _b.templates)];
66
+ }
63
67
  /**
64
68
  * 修改 buildContext 进行 miniprogramPlugins 精简
65
69
  */
@@ -67,7 +71,7 @@ function patchBuildContext(ctx, calses) {
67
71
  return { used: used };
68
72
  }
69
73
  async function generateWxMp({ buildContext: _buildContext, weapps, calses, deployOptions, options, buildTypeList, ignoreInstall = false, cdnEndpoints = {}, mpConfig = {}, }) {
70
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
74
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
71
75
  const operationLabel = em('Wexin MiniProgram Generated');
72
76
  console.time(operationLabel);
73
77
  console.log(`Generating ${em('Wexin MiniProgram')} to ${_buildContext.projDir}`);
@@ -84,26 +88,6 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
84
88
  mpAppId: options.mpAppId,
85
89
  mpConfig,
86
90
  });
87
- Object.values((appConfig === null || appConfig === void 0 ? void 0 : appConfig.usingComponents) || {}).forEach((path) => {
88
- var _a;
89
- const matched = path.match(new RegExp(`(?:\\.)?(?:\\/)?${config_1.materialsDirName}\\/\\$template\\/(.*)?\\/index`));
90
- if (matched) {
91
- const componentName = matched[1];
92
- if (!((_a = used.component) === null || _a === void 0 ? void 0 : _a['$template'])) {
93
- used.component['$template'] = new Set();
94
- }
95
- used.component['$template'].add(componentName);
96
- }
97
- });
98
- /**
99
- * 此处逻辑分离自 patchBuildContext
100
- * 因为 materialLibs 依赖 used 修正,used 依赖 generateMpConfig 后获取 appConfig 修正,generateMpConfig 有依赖 materialLibs 中源码组件库信息进行生成产生了循环
101
- * 根据当前的逻辑牺牲封装在此继续修正
102
- */
103
- if ((_a = used.component) === null || _a === void 0 ? void 0 : _a['$template']) {
104
- const templateLib = (0, cals_1.processTemplatesToDependiencies)((_b = calses === null || calses === void 0 ? void 0 : calses[0]) === null || _b === void 0 ? void 0 : _b.templates);
105
- _buildContext.materialLibs = [..._buildContext.materialLibs, templateLib];
106
- }
107
91
  const { uin = '', appId, projDir, materialLibs: materials, isProduction, mainAppData, domain, isPrivateMode = false, endpointType = '', isBrowserMpBuilder = false, } = _buildContext;
108
92
  const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!isProduction);
109
93
  const hasLowcodePkg = weapps.find((item) => !item.mpPkgUrl);
@@ -148,7 +132,7 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
148
132
  endpointType,
149
133
  }, localWedaRoot);
150
134
  const expirationStartTimesnap = buildContext.enableExpiredTag ? Date.now() : 0;
151
- const cssVarMap = Object.entries((0, theme_1.mergeCssVarConfig)((_d = (_c = calses[0]) === null || _c === void 0 ? void 0 : _c.theme) === null || _d === void 0 ? void 0 : _d.cssVarConfig, 'MP'))
135
+ const cssVarMap = Object.entries((0, theme_1.mergeCssVarConfig)((_b = (_a = calses[0]) === null || _a === void 0 ? void 0 : _a.theme) === null || _b === void 0 ? void 0 : _b.cssVarConfig, 'MP'))
152
136
  .map(([key, _value]) => {
153
137
  const value = _value || '';
154
138
  return [key, value.replace(/;$/, '')];
@@ -158,8 +142,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
158
142
  return map;
159
143
  }, {}) || {};
160
144
  let customLoginConfig;
161
- let loginConfigPathname = ((_f = (_e = calses[0]) === null || _e === void 0 ? void 0 : _e.extra) === null || _f === void 0 ? void 0 : _f.loginConfigVersion)
162
- ? (0, cals_1.generateCustomLoginConfigPathname)({ appId, version: (_h = (_g = calses[0]) === null || _g === void 0 ? void 0 : _g.extra) === null || _h === void 0 ? void 0 : _h.loginConfigVersion })
145
+ let loginConfigPathname = ((_d = (_c = calses[0]) === null || _c === void 0 ? void 0 : _c.extra) === null || _d === void 0 ? void 0 : _d.loginConfigVersion)
146
+ ? (0, cals_1.generateCustomLoginConfigPathname)({ appId, version: (_f = (_e = calses[0]) === null || _e === void 0 ? void 0 : _e.extra) === null || _f === void 0 ? void 0 : _f.loginConfigVersion })
163
147
  : '';
164
148
  if (loginConfigPathname) {
165
149
  const url = `https://${domain}${loginConfigPathname}`;
@@ -181,8 +165,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
181
165
  expirationStartTimesnap,
182
166
  runtimeDynamicConfig: buildContext.runtimeDynamicConfig,
183
167
  RUNTIME_CONFIG_URL: index_1.RUNTIME_CONFIG_URL,
184
- loginConfigPathname: ((_k = (_j = calses[0]) === null || _j === void 0 ? void 0 : _j.extra) === null || _k === void 0 ? void 0 : _k.loginConfigVersion)
185
- ? (0, cals_1.generateCustomLoginConfigPathname)({ appId, version: (_m = (_l = calses[0]) === null || _l === void 0 ? void 0 : _l.extra) === null || _m === void 0 ? void 0 : _m.loginConfigVersion })
168
+ loginConfigPathname: ((_h = (_g = calses[0]) === null || _g === void 0 ? void 0 : _g.extra) === null || _h === void 0 ? void 0 : _h.loginConfigVersion)
169
+ ? (0, cals_1.generateCustomLoginConfigPathname)({ appId, version: (_k = (_j = calses[0]) === null || _j === void 0 ? void 0 : _j.extra) === null || _k === void 0 ? void 0 : _k.loginConfigVersion })
186
170
  : '',
187
171
  customLoginConfig: customLoginConfig ? JSON.stringify(customLoginConfig, undefined, 2) : 'null',
188
172
  },
@@ -236,9 +220,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
236
220
  appID: appId,
237
221
  resourceAppid: !!options.isCrossAccount ? options.resourceAppId : '',
238
222
  isProd: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.UPLOAD,
239
- clientID: ((_o = mainAppData.extra) === null || _o === void 0 ? void 0 : _o.enableLoginStatusShare)
223
+ clientID: ((_l = mainAppData.extra) === null || _l === void 0 ? void 0 : _l.enableLoginStatusShare)
240
224
  ? mainAppData.envId
241
- : (_p = mainAppData.extra) === null || _p === void 0 ? void 0 : _p.clientId,
225
+ : (_m = mainAppData.extra) === null || _m === void 0 ? void 0 : _m.clientId,
242
226
  cdnEndpoints,
243
227
  builderVersion: core_1.version || '',
244
228
  officialLibVersion: (officialLib === null || officialLib === void 0 ? void 0 : officialLib.version) || '',
@@ -288,8 +272,8 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
288
272
  projectConfigJson.setting = {
289
273
  ...projectConfigJson.setting,
290
274
  ...projConfig.setting,
291
- packNpmRelationList: ((_q = projConfig.setting) === null || _q === void 0 ? void 0 : _q.packNpmRelationList) || ((_r = projectConfigJson.setting) === null || _r === void 0 ? void 0 : _r.packNpmRelationList)
292
- ? (0, mp_config_1.mergePackNpmRelationList)(projConfig.setting.packNpmRelationList, (_s = projectConfigJson.setting) === null || _s === void 0 ? void 0 : _s.packNpmRelationList)
275
+ packNpmRelationList: ((_o = projConfig.setting) === null || _o === void 0 ? void 0 : _o.packNpmRelationList) || ((_p = projectConfigJson.setting) === null || _p === void 0 ? void 0 : _p.packNpmRelationList)
276
+ ? (0, mp_config_1.mergePackNpmRelationList)(projConfig.setting.packNpmRelationList, (_q = projectConfigJson.setting) === null || _q === void 0 ? void 0 : _q.packNpmRelationList)
293
277
  : undefined,
294
278
  };
295
279
  const wedaRoot = path_1.default.posix.join('./', projectConfigJson.miniprogramRoot || '/', projectConfigJson.wedaRoot || '');
@@ -307,9 +291,9 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
307
291
  let appJsContent = await fs.readFile(appJsPath);
308
292
  await (0, generateFiles_1.writeFile)(appJsPath, `import { app as wedaApp } from './${path_1.default.posix.join('./', projectConfigJson.wedaRoot, 'app/weapps-api')}'\n${appJsContent}`);
309
293
  }
310
- const appJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
311
- const appJson = await fs.readJson(appJsonPath);
312
- appJson.subpackages = (0, mp_config_1.mergeSubPackages)(((_u = (_t = appJson.subpackages) === null || _t === void 0 ? void 0 : _t.filter) === null || _u === void 0 ? void 0 : _u.call(_t, (item) => item.name !== 'wd-sys-module' && item.name !== 'wd-sys-materials')) || [], appConfig.subpackages);
294
+ let appJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
295
+ let appJson = await fs.readJson(appJsonPath);
296
+ appJson.subpackages = (0, mp_config_1.mergeSubPackages)(((_s = (_r = appJson.subpackages) === null || _r === void 0 ? void 0 : _r.filter) === null || _s === void 0 ? void 0 : _s.call(_r, (item) => item.name !== 'wd-sys-module' && item.name !== 'wd-sys-materials')) || [], appConfig.subpackages);
313
297
  await (0, generateFiles_1.writeFile)(appJsonPath, JSON.stringify(appJson, undefined, 2));
314
298
  }
315
299
  else {
@@ -488,7 +472,7 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs) {
488
472
  return map;
489
473
  }, {});
490
474
  await Promise.all(weapp.pageInstanceList.map(async (page, index) => {
491
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
475
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
492
476
  // # Generating page
493
477
  const rootPath = weapp.rootPath || '';
494
478
  const usingComponents = {};
@@ -582,9 +566,12 @@ async function generatePkg(ctx, { cals, weapp }, appRoot, pageConfigs) {
582
566
  ? `@import "${path_1.default.posix.relative(`/packages/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
583
567
  : '',
584
568
  content: [
585
- (0, weapps_core_1.toCssText)((0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
586
- defaultUnit: processCssUnit,
587
- }), 'page'),
569
+ (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) &&
570
+ ((_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)
571
+ ? (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)
572
+ : (0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
573
+ defaultUnit: processCssUnit,
574
+ }), 'page'),
588
575
  (0, util_2.generateScopedStyleText)(componentInstances),
589
576
  ].join('\n'),
590
577
  pageWxss: importor.styles.length ? `@import "../../lowcode/${page.id}/style.wxss"` : '',
@@ -104,7 +104,7 @@ async function generateMpConfig(ctx, weapps, calses, options) {
104
104
  .reduce((arr, lib) => {
105
105
  arr.push({
106
106
  type: 'file',
107
- value: path.posix.join(projConfig.wedaRoot || '', `${config_1.materialsDirName}/${lib.name}/meta.json`),
107
+ value: path.posix.join(projConfig.wedaRoot || '', `materials/${lib.name}/meta.json`),
108
108
  });
109
109
  return arr;
110
110
  }, []));