@cloudbase/lowcode-builder 1.8.22 → 1.8.24

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.
@@ -19,3 +19,7 @@ export declare function buildH5App({ buildContext, i18nConfig, extraData, cals:
19
19
  ignoreInstall?: boolean;
20
20
  cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
21
21
  }): Promise<string>;
22
+ /**
23
+ * 导出进行单测
24
+ */
25
+ export declare function _BabelTransformCalsExpression(key: any, value: any): any;
@@ -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.buildH5App = void 0;
29
+ exports._BabelTransformCalsExpression = exports.buildH5App = void 0;
30
30
  const path_1 = __importDefault(require("path"));
31
31
  const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
32
32
  const material_1 = require("./material");
@@ -203,15 +203,7 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
203
203
  exports.buildH5App = buildH5App;
204
204
  function processCals(cals) {
205
205
  return walkThroughJson(cals, (key, value, prefix) => {
206
- if (/^:(.*)$/.test(key)) {
207
- try {
208
- return (0, transform_1.BabelTransform)(value, { IIFE: true });
209
- }
210
- catch (e) {
211
- return value;
212
- }
213
- }
214
- return value;
206
+ return _BabelTransformCalsExpression(key, value);
215
207
  });
216
208
  }
217
209
  function _isPlainObj(obj) {
@@ -237,3 +229,32 @@ function walkThroughJson(obj, callback, path = '') {
237
229
  }
238
230
  return obj;
239
231
  }
232
+ /**
233
+ * 导出进行单测
234
+ */
235
+ function _BabelTransformCalsExpression(key, value) {
236
+ const DYNAMIC_REG = /^:(.*)$/;
237
+ const FOR_IN_REG = /^(.*?in\s)/;
238
+ if (DYNAMIC_REG.test(key)) {
239
+ try {
240
+ let forPrefix = '';
241
+ if (key === ':for') {
242
+ const matched = value.match(FOR_IN_REG) || [];
243
+ forPrefix = matched[0];
244
+ if (forPrefix) {
245
+ value = value.replace(FOR_IN_REG, '');
246
+ }
247
+ }
248
+ value = (0, transform_1.BabelTransform)(value, { IIFE: true });
249
+ if (forPrefix) {
250
+ value = `${forPrefix}${value}`;
251
+ }
252
+ return value;
253
+ }
254
+ catch (e) {
255
+ return value;
256
+ }
257
+ }
258
+ return value;
259
+ }
260
+ exports._BabelTransformCalsExpression = _BabelTransformCalsExpression;