@cloudbase/framework-plugin-low-code 0.6.55 → 0.6.58-alpha.0

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.
Files changed (66) hide show
  1. package/lib/builder/config/common.js +1 -1
  2. package/lib/builder/config/index.js +2 -2
  3. package/lib/builder/config/mp.js +1 -1
  4. package/lib/builder/core/copy.js +3 -3
  5. package/lib/builder/core/generate.d.ts.map +1 -1
  6. package/lib/builder/core/generate.js +18 -14
  7. package/lib/builder/core/index.js +13 -13
  8. package/lib/builder/core/material.js +6 -6
  9. package/lib/builder/core/plugin.js +3 -3
  10. package/lib/builder/core/prepare.js +2 -2
  11. package/lib/builder/core/webpack.js +5 -5
  12. package/lib/builder/mp/index.d.ts.map +1 -1
  13. package/lib/builder/mp/index.js +54 -50
  14. package/lib/builder/mp/lowcode.js +4 -4
  15. package/lib/builder/mp/materials.js +16 -16
  16. package/lib/builder/mp/mixMode.js +12 -12
  17. package/lib/builder/mp/mp_config.js +11 -11
  18. package/lib/builder/mp/util.js +6 -6
  19. package/lib/builder/mp/wxml.js +4 -4
  20. package/lib/builder/service/builder/copy.js +11 -11
  21. package/lib/builder/service/builder/generate.d.ts.map +1 -1
  22. package/lib/builder/service/builder/generate.js +58 -60
  23. package/lib/builder/service/builder/index.js +2 -2
  24. package/lib/builder/service/builder/plugin.js +2 -2
  25. package/lib/builder/service/builder/webpack.js +23 -24
  26. package/lib/builder/types/common.js +0 -1
  27. package/lib/builder/util/common.js +6 -8
  28. package/lib/builder/util/console.js +1 -1
  29. package/lib/builder/util/generateFiles.js +2 -2
  30. package/lib/builder/util/index.js +1 -1
  31. package/lib/builder/util/junk.js +2 -4
  32. package/lib/builder/util/mp.js +1 -1
  33. package/lib/builder/util/net.js +1 -1
  34. package/lib/builder/util/style.js +1 -1
  35. package/lib/builder/util/weapp.js +1 -1
  36. package/lib/generate.js +2 -2
  37. package/lib/generator/config/index.js +2 -2
  38. package/lib/generator/core/generate.js +34 -36
  39. package/lib/generator/core/index.js +4 -4
  40. package/lib/generator/core/material.js +14 -14
  41. package/lib/generator/types/common.js +3 -6
  42. package/lib/generator/util/index.js +1 -1
  43. package/lib/generator/util/style.js +2 -2
  44. package/lib/index.js +53 -58
  45. package/lib/utils/common.d.ts +1 -1
  46. package/lib/utils/common.d.ts.map +1 -1
  47. package/lib/utils/common.js +2 -2
  48. package/lib/utils/dataSource.js +2 -2
  49. package/lib/utils/index.js +1 -1
  50. package/lib/utils/postProcess.js +3 -3
  51. package/lib/weapps-core/config/index.js +1 -1
  52. package/lib/weapps-core/index.js +2 -2
  53. package/lib/weapps-core/types/index.js +1 -1
  54. package/lib/weapps-core/utils/appbuild.js +3 -6
  55. package/lib/weapps-core/utils/common.js +2 -3
  56. package/lib/weapps-core/utils/file.d.ts +1 -1
  57. package/lib/weapps-core/utils/formily.js +37 -37
  58. package/lib/weapps-core/utils/index.js +1 -1
  59. package/lib/weapps-core/utils/style.js +15 -15
  60. package/package.json +1 -1
  61. package/template/html/index.html.ejs +6 -3
  62. package/template/mp/common/weapp-page.js +23 -11
  63. package/template/mp/component/index.js +2 -2
  64. package/template/mp/page/index.js +2 -2
  65. package/template/package.json +1 -0
  66. package/template/src/pages/app.tpl +53 -11
@@ -67,7 +67,7 @@ function generateAllPageJsxFile(pageInstanceList, appBuildDir, rootPath, depende
67
67
  compProps: {},
68
68
  }, buildTypeList) {
69
69
  return __awaiter(this, void 0, void 0, function* () {
70
- yield Promise.all((0, weapps_core_1.loopDealWithFn)(pageInstanceList, (pageInstance) => generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependencies, extraData, buildTypeList)));
70
+ yield Promise.all(weapps_core_1.loopDealWithFn(pageInstanceList, (pageInstance) => generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependencies, extraData, buildTypeList)));
71
71
  });
72
72
  }
73
73
  exports.generateAllPageJsxFile = generateAllPageJsxFile;
@@ -79,7 +79,7 @@ function generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependen
79
79
  const fixedDependencies = dependencies;
80
80
  const { componentSchemaJson, pluginInstances, listenerInstances: pageListenerInstances, style: PageStyle, data, } = pageInstance;
81
81
  const { originComponentList, originActionList, } = getOriginComponentAndActionList(componentSchemaJson, fixedDependencies);
82
- const componentsMeta = yield (0, util_1.getComponentsInfo)(appBuildDir, dependencies);
82
+ const componentsMeta = yield util_1.getComponentsInfo(appBuildDir, dependencies);
83
83
  const originPluginList = getOriginPluginList(pluginInstances, dependencies);
84
84
  pullActionToListByInstances(pageListenerInstances, originActionList, fixedDependencies);
85
85
  const originEntryMap = {};
@@ -108,10 +108,11 @@ function generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependen
108
108
  const actionImportStringArr = getActionImportStringArr(originActionList);
109
109
  const pluginImportStringArr = getPluginImportStringArr(originPluginList);
110
110
  const { widgets, dataBinds, componentSchema } = getComponentSchemaString(componentSchemaJson, false, componentsMeta);
111
- const pageStyleString = (0, weapps_core_1.toCssText)((0, weapps_core_1.toCssStyle)(PageStyle), (0, common_1.buildAsWebByBuildType)(buildTypeList) ? 'body' : 'page');
111
+ const pageStyleString = weapps_core_1.toCssText(weapps_core_1.toCssStyle(PageStyle), common_1.buildAsWebByBuildType(buildTypeList) ? 'body' : 'page');
112
112
  const templateData = {
113
113
  pageUUID: rootPath ? `${rootPath}/${pageInstance.id}` : pageInstance.id,
114
114
  pageName: pageInstance.id,
115
+ pageSource: pageInstance.data.src || '',
115
116
  pageStyleText: pageStyleString,
116
117
  entryImports: entryImportStringArr.join(';\n'),
117
118
  componentImports: componentImportStringArr.join(';\n'),
@@ -131,7 +132,7 @@ function generateSinglePageJsxFile(pageInstance, appBuildDir, rootPath, dependen
131
132
  const template = yield fs_extra_1.default.readFile(path_1.default.resolve(config_1.appTemplateDir, './src/pages/app.tpl'), {
132
133
  encoding: 'utf8',
133
134
  });
134
- const jsx = (0, lodash_template_1.default)(template)(templateData);
135
+ const jsx = lodash_template_1.default(template)(templateData);
135
136
  yield fs_extra_1.default.ensureFile(dest);
136
137
  yield fs_extra_1.default.writeFile(dest, jsx);
137
138
  const pageStyleDest = path_1.default.resolve(appBuildDir, `./pages/${pageInstance.id}/index.less`);
@@ -168,7 +169,7 @@ function getOriginPluginList(pluginInstances = [], dependencies = [], originPlug
168
169
  pluginInstances.map((instance) => {
169
170
  var _a;
170
171
  const { sourceKey } = instance;
171
- const { materialName, name, variableName } = (0, util_1.getMetaInfoBySourceKey)(sourceKey);
172
+ const { materialName, name, variableName } = util_1.getMetaInfoBySourceKey(sourceKey);
172
173
  const pluginKey = `${materialName}_${name}`;
173
174
  const isExist = originPluginList.find((item) => item.key === pluginKey);
174
175
  if (isExist) {
@@ -192,7 +193,7 @@ function pullActionToListByInstances(listenerInstances, originActionList, fixedD
192
193
  }
193
194
  listenerInstances.map((pageListenerInstance) => {
194
195
  const { sourceKey, type } = pageListenerInstance;
195
- const { materialName, name, variableName } = (0, util_1.getMetaInfoBySourceKey)(sourceKey);
196
+ const { materialName, name, variableName } = util_1.getMetaInfoBySourceKey(sourceKey);
196
197
  const material = fixedDependencies.find((m) => m.name === materialName);
197
198
  const actionKey = `${materialName}_${name}`;
198
199
  const isExistAction = originActionList.find((item) => item.key === actionKey);
@@ -211,7 +212,7 @@ function pullActionToListByInstances(listenerInstances, originActionList, fixedD
211
212
  }
212
213
  exports.pullActionToListByInstances = pullActionToListByInstances;
213
214
  function pullComponentToListByInstance(sourceKey, originComponentList, fixedDependencies) {
214
- const { materialName, name, variableName } = (0, util_1.getMetaInfoBySourceKey)(sourceKey);
215
+ const { materialName, name, variableName } = util_1.getMetaInfoBySourceKey(sourceKey);
215
216
  const componentKey = `${materialName}_${name}`;
216
217
  const isExistComponent = originComponentList.find((item) => item.key === componentKey);
217
218
  if (!isExistComponent) {
@@ -249,11 +250,11 @@ function isSlot(comp) {
249
250
  }
250
251
  exports.isSlot = isSlot;
251
252
  function getComponentSchemaString(componentSchema, isComposite = false, componentsInfoMap = {}, wrapperClass) {
252
- const componentInputProps = (0, util_1.getInputProps)(componentsInfoMap) || {};
253
- const copyJson = (0, util_1.simpleDeepClone)(componentSchema);
253
+ const componentInputProps = util_1.getInputProps(componentsInfoMap) || {};
254
+ const copyJson = util_1.simpleDeepClone(componentSchema);
254
255
  const compWidgets = {};
255
256
  const compDataBinds = {};
256
- const componentSchemaJson = (0, util_1.deepDealSchema)(copyJson, (schema) => {
257
+ const componentSchemaJson = util_1.deepDealSchema(copyJson, (schema) => {
257
258
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
258
259
  const { 'x-props': xProps = {}, properties } = schema;
259
260
  const { dataBinds = [], commonStyle = {}, data = {}, classNameList = [], sourceKey, styleBind, classNameListBind, staticResourceAttribute = [], } = xProps;
@@ -271,9 +272,8 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
271
272
  schema['emitEvents'] = componentInfo.emitEvents.map((item) => item.eventName);
272
273
  }
273
274
  if (!isSlot(schema) && schema.key) {
274
- compWidgets[schema.key] = Object.assign(Object.assign({}, data), { style: (0, weapps_core_1.toCssStyle)(commonStyle), classList: classNameList, widgetType: sourceKey, _parentId: isSlot(schema.parent)
275
- ? (_g = (_f = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _f === void 0 ? void 0 : _f.parent) === null || _g === void 0 ? void 0 : _g.key
276
- : (_h = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _h === void 0 ? void 0 : _h.key });
275
+ compWidgets[schema.key] = Object.assign(Object.assign({}, data), { style: weapps_core_1.toCssStyle(commonStyle), classList: classNameList, widgetType: sourceKey, _parentId: isSlot(schema.parent)
276
+ ? (_g = (_f = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _f === void 0 ? void 0 : _f.parent) === null || _g === void 0 ? void 0 : _g.key : (_h = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _h === void 0 ? void 0 : _h.key });
277
277
  if (dataBinds.length > 0) {
278
278
  compDataBinds[schema.key] = generateDataBinds(dataBinds, isComposite);
279
279
  }
@@ -291,7 +291,7 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
291
291
  compDataBinds[schema.key] = Object.assign(Object.assign({}, (compDataBinds[schema.key] || {})), generateDataBinds([classNameListBind], isComposite));
292
292
  }
293
293
  }
294
- if (properties && (0, weapps_core_1.isEmptyObj)(properties)) {
294
+ if (properties && weapps_core_1.isEmptyObj(properties)) {
295
295
  delete schema.properties;
296
296
  }
297
297
  delete schema.type;
@@ -302,8 +302,7 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
302
302
  if (propsVaule && Array.isArray(propsVaule)) {
303
303
  propsVaule.map((block) => {
304
304
  var _a, _b;
305
- const blockInstance = (block === null || block === void 0 ? void 0 : block.selectableBlock) &&
306
- ((_b = (_a = block === null || block === void 0 ? void 0 : block.selectableBlock) === null || _a === void 0 ? void 0 : _a['x-props']) === null || _b === void 0 ? void 0 : _b.listenerInstances);
305
+ const blockInstance = (block === null || block === void 0 ? void 0 : block.selectableBlock) && ((_b = (_a = block === null || block === void 0 ? void 0 : block.selectableBlock) === null || _a === void 0 ? void 0 : _a['x-props']) === null || _b === void 0 ? void 0 : _b.listenerInstances);
307
306
  if (blockInstance) {
308
307
  block.selectableBlock['x-props'].listenerInstances = generateListnerInstances(blockInstance, isComposite);
309
308
  }
@@ -320,12 +319,12 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
320
319
  xProps['classNameList'].push(wrapperClass);
321
320
  }
322
321
  }
323
- xProps['commonStyle'] = (0, weapps_core_1.toCssStyle)(xProps['commonStyle']);
322
+ xProps['commonStyle'] = weapps_core_1.toCssStyle(xProps['commonStyle']);
324
323
  xProps['staticResourceAttribute'] = staticResourceAttribute;
325
- if ((0, weapps_core_1.isEmptyObj)(xProps['commonStyle'])) {
324
+ if (weapps_core_1.isEmptyObj(xProps['commonStyle'])) {
326
325
  delete xProps['commonStyle'];
327
326
  }
328
- if ((0, weapps_core_1.isEmptyObj)(xProps['style'])) {
327
+ if (weapps_core_1.isEmptyObj(xProps['style'])) {
329
328
  delete xProps['style'];
330
329
  }
331
330
  if (xProps['dataBinds'] && xProps['dataBinds'].length === 0) {
@@ -347,7 +346,7 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
347
346
  xPropsData.staticResourceAttribute.length === 0) {
348
347
  delete xPropsData.staticResourceAttribute;
349
348
  }
350
- if ((0, weapps_core_1.isEmptyObj)(xPropsData)) {
349
+ if (weapps_core_1.isEmptyObj(xPropsData)) {
351
350
  delete xProps['data'];
352
351
  }
353
352
  }
@@ -389,9 +388,9 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
389
388
  }
390
389
  });
391
390
  return {
392
- widgets: (0, util_1.JsonToStringWithVariableName)(compWidgets),
393
- dataBinds: (0, util_1.JsonToStringWithVariableName)(compDataBinds),
394
- componentSchema: (0, util_1.JsonToStringWithVariableName)(componentSchemaJson),
391
+ widgets: util_1.JsonToStringWithVariableName(compWidgets),
392
+ dataBinds: util_1.JsonToStringWithVariableName(compDataBinds),
393
+ componentSchema: util_1.JsonToStringWithVariableName(componentSchemaJson),
395
394
  };
396
395
  }
397
396
  exports.getComponentSchemaString = getComponentSchemaString;
@@ -479,7 +478,7 @@ function generateListnerInstances(listenerInstances, isComposite = false) {
479
478
  };
480
479
  if (listener.type === weapps_core_1.ActionType.Material) {
481
480
  const { sourceKey } = listener;
482
- const { variableName } = (0, util_1.getMetaInfoBySourceKey)(sourceKey);
481
+ const { variableName } = util_1.getMetaInfoBySourceKey(sourceKey);
483
482
  generatedListener.instanceFunction = `${config_1.REPLACE_SIGN}${variableName}${config_1.REPLACE_SIGN}`;
484
483
  }
485
484
  else if (listener.type === weapps_core_1.ActionType.Platform) {
@@ -504,7 +503,7 @@ function generateListnerInstances(listenerInstances, isComposite = false) {
504
503
  generatedListener.instanceFunction = `${config_1.REPLACE_SIGN}handler.${((_e = listener.handler) === null || _e === void 0 ? void 0 : _e.name) || listener.jsCode}${config_1.REPLACE_SIGN}`;
505
504
  }
506
505
  }
507
- if (!(0, weapps_core_1.isEmptyObj)(listener.data)) {
506
+ if (!weapps_core_1.isEmptyObj(listener.data)) {
508
507
  generatedListener.data = listener.data;
509
508
  }
510
509
  if (listener.dataBinds && listener.dataBinds.length > 0) {
@@ -514,20 +513,20 @@ function generateListnerInstances(listenerInstances, isComposite = false) {
514
513
  });
515
514
  }
516
515
  function getListenersString(listeners = [], isComposite = false) {
517
- return (0, util_1.JsonToStringWithVariableName)(generateListnerInstances(listeners, isComposite));
516
+ return util_1.JsonToStringWithVariableName(generateListnerInstances(listeners, isComposite));
518
517
  }
519
518
  exports.getListenersString = getListenersString;
520
519
  function getPluginInstancesString(instances) {
521
520
  if (!instances || !instances.length) {
522
521
  return '[]';
523
522
  }
524
- const copyInstances = (0, util_1.simpleDeepClone)(instances);
523
+ const copyInstances = util_1.simpleDeepClone(instances);
525
524
  copyInstances.map((itemInstance) => {
526
525
  const { sourceKey } = itemInstance;
527
- const { variableName } = (0, util_1.getMetaInfoBySourceKey)(sourceKey);
526
+ const { variableName } = util_1.getMetaInfoBySourceKey(sourceKey);
528
527
  itemInstance.instanceFunction = `${config_1.REPLACE_SIGN}${variableName}${config_1.REPLACE_SIGN}`;
529
528
  });
530
- return (0, util_1.JsonToStringWithVariableName)(copyInstances);
529
+ return util_1.JsonToStringWithVariableName(copyInstances);
531
530
  }
532
531
  exports.getPluginInstancesString = getPluginInstancesString;
533
532
  function getPluginImportStringArr(plugins, pluginImportStringArr = []) {
@@ -550,7 +549,7 @@ function getComponentImportStringArr(components, componentImportStringArr = [])
550
549
  importString = `import { ${name} as ${lodash_1.default.upperFirst(variableName)} } from '${path_1.default.posix.join(`libraries/${materialName}@${materialVersion}`, entries === null || entries === void 0 ? void 0 : entries.components)}'`;
551
550
  }
552
551
  else if (entries === null || entries === void 0 ? void 0 : entries.entry) {
553
- const componentsLibVariableName = (0, util_3.camelcase)(`${materialName}`);
552
+ const componentsLibVariableName = util_3.camelcase(`${materialName}`);
554
553
  importString = `const { ${name}: ${lodash_1.default.upperFirst(variableName)} } = ${componentsLibVariableName}.components`;
555
554
  }
556
555
  else {
@@ -566,7 +565,7 @@ exports.getComponentImportStringArr = getComponentImportStringArr;
566
565
  function getEntryImportStringArr(materialInfoList = [], entryImportStringArr = []) {
567
566
  materialInfoList.forEach(({ materialName, version, entries }) => {
568
567
  if (!((entries === null || entries === void 0 ? void 0 : entries.actions) && (entries === null || entries === void 0 ? void 0 : entries.components)) && (entries === null || entries === void 0 ? void 0 : entries.entry)) {
569
- const componentsLibVariableName = (0, util_3.camelcase)(`${materialName}`);
568
+ const componentsLibVariableName = util_3.camelcase(`${materialName}`);
570
569
  const importComponentLibString = `import ${componentsLibVariableName} from '${path_1.default.posix.join(`libraries/${materialName}@${version}`, entries === null || entries === void 0 ? void 0 : entries.entry)}'`;
571
570
  if (!entryImportStringArr.includes(importComponentLibString)) {
572
571
  entryImportStringArr.push(importComponentLibString);
@@ -587,11 +586,9 @@ function getActionImportStringArr(originActionList, actionImportStringArr = [])
587
586
  exports.getActionImportStringArr = getActionImportStringArr;
588
587
  function pushActionToImportStringArr(listenerInstance, actionImportStringArr) {
589
588
  const { name, materialName, materialVersion, variableName, entries, } = listenerInstance;
590
- const componentsLibVariableName = (0, util_3.camelcase)(`${materialName}`);
591
- const importString = (entries === null || entries === void 0 ? void 0 : entries.actions)
592
- ? `import { ${name} as ${variableName} } from '${path_1.default.posix.join(`libraries/${materialName}@${materialVersion}`, entries === null || entries === void 0 ? void 0 : entries.actions)}'`
593
- : (entries === null || entries === void 0 ? void 0 : entries.entry)
594
- ? `const { ${name}: ${variableName} } = ${componentsLibVariableName}.actions`
589
+ const componentsLibVariableName = util_3.camelcase(`${materialName}`);
590
+ const importString = (entries === null || entries === void 0 ? void 0 : entries.actions) ? `import { ${name} as ${variableName} } from '${path_1.default.posix.join(`libraries/${materialName}@${materialVersion}`, entries === null || entries === void 0 ? void 0 : entries.actions)}'`
591
+ : (entries === null || entries === void 0 ? void 0 : entries.entry) ? `const { ${name}: ${variableName} } = ${componentsLibVariableName}.actions`
595
592
  : `import ${variableName} from 'libraries/${materialName}@${materialVersion}/actions/${name}'`;
596
593
  if (actionImportStringArr.includes(importString)) {
597
594
  return;
@@ -608,7 +605,7 @@ function generateRouterFile(allAppDataList, appBuildDir, basename = '', buildTyp
608
605
  const { pageInstanceList, rootPath = '' } = data;
609
606
  const pageFilePath = rootPath ? `packages/${rootPath}/` : '';
610
607
  mountApis.push(`import '${pageFilePath}app/mountAppApis';`);
611
- (0, weapps_core_1.loopDealWithFn)(pageInstanceList, (pageInstance) => {
608
+ weapps_core_1.loopDealWithFn(pageInstanceList, (pageInstance) => {
612
609
  const pageId = [rootPath, pageInstance.id].filter((i) => i).join('_');
613
610
  if (pageInstance.isHome && !rootPath) {
614
611
  routerRenders.push(`<Route from="/" exact children={() => <Redirect to="/${pageId}" />} />`);
@@ -620,7 +617,7 @@ function generateRouterFile(allAppDataList, appBuildDir, basename = '', buildTyp
620
617
  const routerTemplate = yield fs_extra_1.default.readFile(path_1.default.resolve(config_1.appTemplateDir, './src/router/index.tpl'), {
621
618
  encoding: 'utf8',
622
619
  });
623
- const routerIndexStr = (0, lodash_template_1.default)(routerTemplate)({
620
+ const routerIndexStr = lodash_template_1.default(routerTemplate)({
624
621
  routerImports: routerImports.join('\n'),
625
622
  routerRenders: routerRenders.join('\n'),
626
623
  mountApis: mountApis.join('\n'),
@@ -636,19 +633,19 @@ function writeLowCodeFiles(appData, appBuildDir) {
636
633
  return __awaiter(this, void 0, void 0, function* () {
637
634
  const lowcodeRootDir = path_1.default.join(appBuildDir, 'lowcode');
638
635
  console.log(chalk_1.default.blue.bold('Writing lowcode files:'));
639
- (0, generateFiles_1.cleanDir)(lowcodeRootDir, []);
640
- (0, style_1.generateDefaultTheme)(appData);
636
+ generateFiles_1.cleanDir(lowcodeRootDir, []);
637
+ style_1.generateDefaultTheme(appData);
641
638
  const themeCode = appData.codeModules.find((mod) => mod.type === 'theme');
642
639
  yield Promise.all(appData.codeModules.map((m) => writeCode2file(m, 'global')));
643
- yield Promise.all((0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, (page) => __awaiter(this, void 0, void 0, function* () {
644
- (0, style_1.generateDefaultStyle)(page);
640
+ yield Promise.all(weapps_core_1.loopDealWithFn(appData.pageInstanceList, (page) => __awaiter(this, void 0, void 0, function* () {
641
+ style_1.generateDefaultStyle(page);
645
642
  yield page.codeModules
646
643
  .filter((m) => m.name !== '____index____')
647
644
  .forEach((m) => writeCode2file(m, page.id));
648
645
  })));
649
646
  function writeCode2file(mod, pageId) {
650
647
  return __awaiter(this, void 0, void 0, function* () {
651
- const file = path_1.default.join(lowcodeRootDir, (0, weapps_core_1.getCodeModuleFilePath)(pageId, mod));
648
+ const file = path_1.default.join(lowcodeRootDir, weapps_core_1.getCodeModuleFilePath(pageId, mod));
652
649
  let weappsApiPrefix = '';
653
650
  if (mod.type !== 'theme') {
654
651
  weappsApiPrefix =
@@ -661,7 +658,7 @@ function writeLowCodeFiles(appData, appBuildDir) {
661
658
  console.log(chalk_1.default.green(file));
662
659
  let code = mod.code;
663
660
  if (mod.type === 'style') {
664
- code = yield (0, style_1.processLess)(((themeCode === null || themeCode === void 0 ? void 0 : themeCode.code) || style_1.defaultThemeCode) + code);
661
+ code = yield style_1.processLess(((themeCode === null || themeCode === void 0 ? void 0 : themeCode.code) || style_1.defaultThemeCode) + code);
665
662
  }
666
663
  yield fs_extra_1.default.ensureFile(file);
667
664
  yield fs_extra_1.default.writeFile(file, weappsApiPrefix + os_1.default.EOL + code);
@@ -675,7 +672,7 @@ function writeLowCodeFilesForCompositeComp(compositeGroups, appBuildDir) {
675
672
  const lowcodeRootDir = path_1.default.join(appBuildDir, 'src', 'lowcode', 'composite');
676
673
  console.log(chalk_1.default.blue.bold('Writing composite component lowcode files:'));
677
674
  yield Promise.all(compositeGroups.map((gItem) => __awaiter(this, void 0, void 0, function* () {
678
- yield (0, util_2.writeLibCommonRes2file)(gItem, path_1.default.join(appBuildDir, 'src', 'libraries', `${gItem.name}@${gItem.version}`, 'libCommonRes'));
675
+ yield util_2.writeLibCommonRes2file(gItem, path_1.default.join(appBuildDir, 'src', 'libraries', `${gItem.name}@${gItem.version}`, 'libCommonRes'));
679
676
  const compLibCommonResource = gItem.compLibCommonResource;
680
677
  let themeCode = '';
681
678
  if (compLibCommonResource) {
@@ -693,13 +690,13 @@ function writeLowCodeFilesForCompositeComp(compositeGroups, appBuildDir) {
693
690
  function writeCode2file(mod, lowcodeDir, comp, themeCode) {
694
691
  return __awaiter(this, void 0, void 0, function* () {
695
692
  const pageId = comp.name + '_' + comp.id;
696
- const file = path_1.default.join(lowcodeDir, (0, weapps_core_1.getCodeModuleFilePath)(pageId, mod));
693
+ const file = path_1.default.join(lowcodeDir, weapps_core_1.getCodeModuleFilePath(pageId, mod));
697
694
  yield fs_extra_1.default.ensureFile(file);
698
695
  let codeContent = '';
699
696
  if (mod.type === 'style') {
700
- codeContent = `.${(0, weapps_core_1.getCompositedComponentClass)(comp)} { \n${themeCode ? themeCode : ''}\n${mod.code}\n }`;
697
+ codeContent = `.${weapps_core_1.getCompositedComponentClass(comp)} { \n${themeCode ? themeCode : ''}\n${mod.code}\n }`;
701
698
  try {
702
- codeContent = yield (0, style_1.processLess)(`${codeContent}`);
699
+ codeContent = yield style_1.processLess(`${codeContent}`);
703
700
  }
704
701
  catch (e) {
705
702
  console.error(`样式转换失败 [${pageId}] :`, e, codeContent);
@@ -717,21 +714,22 @@ function writeLowCodeFilesForCompositeComp(compositeGroups, appBuildDir) {
717
714
  exports.writeLowCodeFilesForCompositeComp = writeLowCodeFilesForCompositeComp;
718
715
  function generateCodeFromTpl(appData, appBuildDir, dependencies, appKey, rootPath, deployMode, buildTypeList, extraData) {
719
716
  return __awaiter(this, void 0, void 0, function* () {
720
- const pageIds = [];
717
+ const computedPageIds = [];
721
718
  const pageModules = {};
722
- (0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, (p) => {
723
- pageIds.push(p.id);
719
+ weapps_core_1.loopDealWithFn(appData.pageInstanceList, (p) => {
724
720
  pageModules[p.id] = p.codeModules;
721
+ if (p.codeModules.find((item) => item.type === 'computed')) {
722
+ computedPageIds.push(p.id);
723
+ }
725
724
  });
726
- const yyptConfig = yield (0, util_2.getYyptConfigInfo)(extraData);
725
+ const yyptConfig = yield util_2.getYyptConfigInfo(extraData);
727
726
  const templatesData = {
728
727
  'store/index.js': {
729
- pageIds,
730
728
  appId: appKey,
731
729
  rootPath: rootPath,
732
730
  },
733
731
  'store/computed.js': {
734
- pageIds,
732
+ pageIds: computedPageIds,
735
733
  },
736
734
  'app/handlers.js': {
737
735
  pageModules,
@@ -746,7 +744,7 @@ function generateCodeFromTpl(appData, appBuildDir, dependencies, appKey, rootPat
746
744
  .map((m) => m.name),
747
745
  },
748
746
  'datasources/index.js.tpl': {
749
- isXPage: (0, common_1.buildAsXPageByBuildType)(buildTypeList),
747
+ isXPage: common_1.buildAsXPageByBuildType(buildTypeList),
750
748
  },
751
749
  'datasources/config.js.tpl': {
752
750
  appID: appKey,
@@ -754,14 +752,14 @@ function generateCodeFromTpl(appData, appBuildDir, dependencies, appKey, rootPat
754
752
  isProd: deployMode === types_1.DEPLOY_MODE.UPLOAD,
755
753
  },
756
754
  'datasources/datasource-profiles.js.tpl': {
757
- datasourceProfiles: (0, util_1.JsonToStringWithVariableName)((0, dataSource_1.getDatasourceProfiles)(appData.datasources || [])),
755
+ datasourceProfiles: util_1.JsonToStringWithVariableName(dataSource_1.getDatasourceProfiles(appData.datasources || [])),
758
756
  },
759
757
  'datasources/dataset-profiles.js.tpl': {
760
- datasetProfiles: (0, util_1.JsonToStringWithVariableName)((0, dataSource_1.getDatasetProfiles)(appData, [appData])),
758
+ datasetProfiles: util_1.JsonToStringWithVariableName(dataSource_1.getDatasetProfiles(appData, [appData])),
761
759
  },
762
760
  'handlers/utils/common.js': {
763
- isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
764
- isXPage: (0, common_1.buildAsXPageByBuildType)(buildTypeList),
761
+ isAdminPortal: common_1.buildAsAdminPortalByBuildType(buildTypeList),
762
+ isXPage: common_1.buildAsXPageByBuildType(buildTypeList),
765
763
  },
766
764
  };
767
765
  if (!rootPath) {
@@ -772,7 +770,7 @@ function generateCodeFromTpl(appData, appBuildDir, dependencies, appKey, rootPat
772
770
  const tplStr = yield fs_extra_1.default.readFile(path_1.default.join(config_1.appTemplateDir, 'src', file), {
773
771
  encoding: 'utf8',
774
772
  });
775
- const generatedCode = (0, lodash_template_1.default)(tplStr, {
773
+ const generatedCode = lodash_template_1.default(tplStr, {
776
774
  interpolate: /<%=([\s\S]+?)%>/g,
777
775
  })(templatesData[file]);
778
776
  const outFile = path_1.default.resolve(appBuildDir, file.replace(/.tpl$/, ''));
@@ -34,7 +34,7 @@ function createNodeModulesSoftLink(appBuildDir, nodeModulesPath) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
35
  const destPath = path_1.default.join(appBuildDir, 'node_modules');
36
36
  if (!fs_extra_1.default.existsSync(destPath)) {
37
- (0, util_1.promiseWrapper)((0, symlink_dir_1.default)(nodeModulesPath, destPath));
37
+ util_1.promiseWrapper(symlink_dir_1.default(nodeModulesPath, destPath));
38
38
  }
39
39
  });
40
40
  }
@@ -42,7 +42,7 @@ exports.createNodeModulesSoftLink = createNodeModulesSoftLink;
42
42
  function getStoreModuleList(appData) {
43
43
  const storeModuleList = [];
44
44
  extractRematchModules(appData.codeModules);
45
- (0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, (pageInstance) => {
45
+ weapps_core_1.loopDealWithFn(appData.pageInstanceList, (pageInstance) => {
46
46
  extractRematchModules(pageInstance.codeModules);
47
47
  });
48
48
  return storeModuleList;
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -49,7 +49,7 @@ function installMpPlugin(appBuildDir, plugins) {
49
49
  yield fs.copy(pluginNodeModuleSrcDir, mpBuildPluginDir, {
50
50
  overwrite: true,
51
51
  });
52
- yield (0, mp_1.mergeSubPackages)(mpBuildAppJsonPath, pluginAppJsonPath);
52
+ yield mp_1.mergeSubPackages(mpBuildAppJsonPath, pluginAppJsonPath);
53
53
  }))).catch(err => console.error(err));
54
54
  });
55
55
  }
@@ -33,7 +33,7 @@ const console_1 = require("../../util/console");
33
33
  const types_1 = require("../../../types");
34
34
  const index_1 = require("../../../index");
35
35
  const index_2 = require("./index");
36
- const yarnExists = (0, command_exists_1.sync)('yarn');
36
+ const yarnExists = command_exists_1.sync('yarn');
37
37
  const runningCompilations = {};
38
38
  function startCompile(options, cb) {
39
39
  const key = options.configPath;
@@ -43,8 +43,8 @@ function startCompile(options, cb) {
43
43
  return;
44
44
  }
45
45
  console.log('Running webpack by ' + options.configPath);
46
- (0, util_1.removeRequireUncached)(path_1.default.resolve(options.configPath, '../miniprogram.config.js'));
47
- const watching = (0, webpack_1.default)((0, util_1.requireUncached)(options.configPath), (err, stats) => __awaiter(this, void 0, void 0, function* () {
46
+ util_1.removeRequireUncached(path_1.default.resolve(options.configPath, '../miniprogram.config.js'));
47
+ const watching = webpack_1.default(util_1.requireUncached(options.configPath), (err, stats) => __awaiter(this, void 0, void 0, function* () {
48
48
  if (err) {
49
49
  console.error('webpack config error', err.stack || err);
50
50
  if (err.details) {
@@ -158,7 +158,7 @@ function downloadAndWriteTabBarIcon(iconPath, pagePath, appBuildDir, fileName) {
158
158
  const fileFullPath = path_1.default.resolve(appBuildDir, `dist/mp/${relativePath}`);
159
159
  yield fs_extra_1.default.ensureFile(fileFullPath);
160
160
  const writer = fs_extra_1.default.createWriteStream(fileFullPath);
161
- const response = yield (0, axios_1.default)({
161
+ const response = yield axios_1.default({
162
162
  method: 'get',
163
163
  url: iconPath,
164
164
  responseType: 'stream',
@@ -246,7 +246,7 @@ function generateMpJsonConfigFile(allAppDataList, userConfig, appBuildDir, plugi
246
246
  kbConfig.generate = Object.assign(Object.assign({}, kbConfig.generate), { app: 'noemit' });
247
247
  }
248
248
  if (plugins.length > 0) {
249
- kbConfig.generate.subpackages = Object.assign(Object.assign({}, kbConfig.generate.subpackages), (yield (0, plugin_1.getPluginKboneSubpackage)(appBuildDir, plugins)));
249
+ kbConfig.generate.subpackages = Object.assign(Object.assign({}, kbConfig.generate.subpackages), (yield plugin_1.getPluginKboneSubpackage(appBuildDir, plugins)));
250
250
  }
251
251
  const templateStr = JSON.stringify(kbConfig, null, 2);
252
252
  yield fs_extra_1.default.writeFile(path_1.default.resolve(appBuildDir, 'webpack/miniprogram.config.js'), `module.exports = ${templateStr}`);
@@ -259,7 +259,7 @@ function getMainAppDataByList(allAppDataList) {
259
259
  exports.getMainAppDataByList = getMainAppDataByList;
260
260
  function getHomePageInstance(pageInstanceList) {
261
261
  let target = pageInstanceList[0];
262
- (0, weapps_core_1.loopDealWithFn)(pageInstanceList, (pageInstance) => {
262
+ weapps_core_1.loopDealWithFn(pageInstanceList, (pageInstance) => {
263
263
  if (pageInstance.isHome) {
264
264
  target = pageInstance;
265
265
  return pageInstance;
@@ -277,7 +277,7 @@ function getMpAllRouterConfig(allAppDataList, getHome = false) {
277
277
  let homePath = '';
278
278
  allAppDataList.map((appData) => {
279
279
  const { pageInstanceList, rootPath = '' } = appData;
280
- (0, weapps_core_1.loopDealWithFn)(pageInstanceList, (pageInstance) => {
280
+ weapps_core_1.loopDealWithFn(pageInstanceList, (pageInstance) => {
281
281
  const name = [rootPath, pageInstance.id].filter((i) => i).join('_');
282
282
  const path = `/${name}`;
283
283
  if (!homePath) {
@@ -310,7 +310,7 @@ function getWebpackWebBuildParams(appId, appBuildDir, materialsDir, dependencies
310
310
  assets
311
311
  .filter((assetUrl) => !!assetUrl)
312
312
  .forEach((assetUrl) => __awaiter(this, void 0, void 0, function* () {
313
- const fileName = (0, common_1.getFileNameByUrl)(assetUrl);
313
+ const fileName = common_1.getFileNameByUrl(assetUrl);
314
314
  jsApis.push(`./${fileName}`);
315
315
  yield downloadAssets(targetDir, assetUrl);
316
316
  }));
@@ -354,7 +354,7 @@ function getWebpackWebBuildParams(appId, appBuildDir, materialsDir, dependencies
354
354
  path_1.default.resolve(appBuildDir, 'src'),
355
355
  ...getMaterialNodeModulesPathList(dependencies, materialsDir),
356
356
  ],
357
- definePlugin: Object.assign({ 'process.env.buildType': `"${buildTypeList[0]}"`, 'process.env.isApp': buildTypeList.includes("app"), 'process.env.isAdminPortal': (0, common_2.buildAsAdminPortalByBuildType)(buildTypeList) }, extraDefine),
357
+ definePlugin: Object.assign({ 'process.env.buildType': `"${buildTypeList[0]}"`, 'process.env.isApp': buildTypeList.includes("app"), 'process.env.isAdminPortal': common_2.buildAsAdminPortalByBuildType(buildTypeList) }, extraDefine),
358
358
  devtool: ['app-nvzcvt10', 'app-msa2ihs9'].includes(appId)
359
359
  ? 'source-map'
360
360
  : mode !== "production"
@@ -398,7 +398,7 @@ function getAllPageMpEntryPath(allAppDataList, appBuildDir, options = { generate
398
398
  allAppDataList.map((app) => {
399
399
  const { pageInstanceList, rootPath } = app;
400
400
  const packagePathStr = rootPath ? `packages/${rootPath}` : '';
401
- (0, weapps_core_1.loopDealWithFn)(pageInstanceList, (pageInstance) => {
401
+ weapps_core_1.loopDealWithFn(pageInstanceList, (pageInstance) => {
402
402
  const pageName = rootPath
403
403
  ? `${rootPath}_${pageInstance.id}`
404
404
  : pageInstance.id;
@@ -411,7 +411,7 @@ exports.getAllPageMpEntryPath = getAllPageMpEntryPath;
411
411
  const dependenciesMap = new Map();
412
412
  function downloadAndInstallDependencies(dependencies = [], materialsDir, installOptions = {}) {
413
413
  return __awaiter(this, void 0, void 0, function* () {
414
- const localPkg = (0, util_1.getCurrentPackageJson)();
414
+ const localPkg = util_1.getCurrentPackageJson();
415
415
  yield Promise.all(dependencies.map(({ name, version, srcZipUrl }) => __awaiter(this, void 0, void 0, function* () {
416
416
  const materialNameVersion = `${name}@${version}`;
417
417
  const targetDir = path_1.default.join(materialsDir, materialNameVersion);
@@ -420,11 +420,11 @@ function downloadAndInstallDependencies(dependencies = [], materialsDir, install
420
420
  return;
421
421
  }
422
422
  if (dependenciesMap.get(targetDir)) {
423
- (0, console_1.notice)(`${materialNameVersion} 存在 ${targetDir},无需安装, 如果依赖库报错,请重启wa watch`);
423
+ console_1.notice(`${materialNameVersion} 存在 ${targetDir},无需安装, 如果依赖库报错,请重启wa watch`);
424
424
  return;
425
425
  }
426
426
  const matched = srcZipUrl.match(/\/(cg-.*?)\//);
427
- const { appBuildDir } = (0, index_2.getCompileDirs)('app');
427
+ const { appBuildDir } = index_2.getCompileDirs('app');
428
428
  if (matched &&
429
429
  matched[1] &&
430
430
  fs_extra_1.default.existsSync(path_1.default.resolve(appBuildDir, `.component_cache/web/${matched[1]}@${version}`))) {
@@ -436,8 +436,7 @@ function downloadAndInstallDependencies(dependencies = [], materialsDir, install
436
436
  yield downloadDependencies(targetDir, srcZipUrl);
437
437
  }
438
438
  console.log(`处理${name}@${version}依赖 ...`);
439
- yield installDependencies(targetDir, Object.assign(Object.assign({}, installOptions), { ignoreInstall: (0, common_1.isOfficialComponentLib)(name, version) ||
440
- (installOptions === null || installOptions === void 0 ? void 0 : installOptions.ignoreInstall), dependenceMeta: {
439
+ yield installDependencies(targetDir, Object.assign(Object.assign({}, installOptions), { ignoreInstall: common_1.isOfficialComponentLib(name, version) || (installOptions === null || installOptions === void 0 ? void 0 : installOptions.ignoreInstall), dependenceMeta: {
441
440
  name,
442
441
  version,
443
442
  downloadUrl: srcZipUrl,
@@ -454,7 +453,7 @@ function downloadDependencies(targetDir, srcZipUrl) {
454
453
  return;
455
454
  }
456
455
  try {
457
- let response = yield (0, axios_1.default)({
456
+ let response = yield axios_1.default({
458
457
  url: srcZipUrl,
459
458
  responseType: 'stream',
460
459
  });
@@ -502,21 +501,21 @@ function installDependencies(targetDir, options = {}) {
502
501
  let installProcess;
503
502
  if (yarnExists && (options === null || options === void 0 ? void 0 : options.runtime) !== types_1.RUNTIME.CI) {
504
503
  const addPackage = packageName ? ['add', packageName] : [];
505
- installProcess = (0, cross_spawn_1.default)('yarn', [...addPackage, registry], {
504
+ installProcess = cross_spawn_1.default('yarn', [...addPackage, registry], {
506
505
  cwd: targetDir,
507
506
  env: process.env,
508
507
  stdio: ['inherit', 'pipe', 'pipe'],
509
508
  });
510
509
  }
511
510
  else {
512
- installProcess = (0, cross_spawn_1.default)('npm', ['install', packageName, ...npmOptions], {
511
+ installProcess = cross_spawn_1.default('npm', ['install', packageName, ...npmOptions], {
513
512
  cwd: targetDir,
514
513
  env: process.env,
515
514
  stdio: ['inherit', 'pipe', 'pipe'],
516
515
  });
517
516
  }
518
517
  installProcess.on('exit', () => console.timeEnd(operationTag));
519
- yield (0, process_1.promisifyProcess)(installProcess);
518
+ yield process_1.promisifyProcess(installProcess);
520
519
  try {
521
520
  yield fs_extra_1.default.remove(path_1.default.join(path_1.default.join(targetDir, 'package-lock.json')));
522
521
  yield fs_extra_1.default.remove(path_1.default.join(path_1.default.join(targetDir, 'yarn.lock')));
@@ -526,7 +525,7 @@ function installDependencies(targetDir, options = {}) {
526
525
  }
527
526
  exports.installDependencies = installDependencies;
528
527
  function getMaterialNodeModulesPathList(dependencies = [], materialsDir) {
529
- const localPkg = (0, util_1.getCurrentPackageJson)();
528
+ const localPkg = util_1.getCurrentPackageJson();
530
529
  return dependencies.map(({ name, version }) => {
531
530
  const nameVersion = `${name}@${version}`;
532
531
  if (localPkg && localPkg.name === name && localPkg.version === version) {
@@ -543,11 +542,11 @@ function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList, }) {
543
542
  const template = yield fs_extra_1.default.readFile(path_1.default.resolve(config_2.appTemplateDir, './webpack/devServer.js'), {
544
543
  encoding: 'utf8',
545
544
  });
546
- const jsContent = (0, lodash_template_1.default)(template, {
545
+ const jsContent = lodash_template_1.default(template, {
547
546
  interpolate: /<%=([\s\S]+?)%>/g,
548
547
  })({
549
548
  isApp: buildTypeList.includes("app"),
550
- isAdminPortal: (0, common_2.buildAsAdminPortalByBuildType)(buildTypeList),
549
+ isAdminPortal: common_2.buildAsAdminPortalByBuildType(buildTypeList),
551
550
  });
552
551
  yield fs_extra_1.default.ensureFile(dest);
553
552
  yield fs_extra_1.default.writeFile(dest, jsContent);
@@ -560,7 +559,7 @@ function downloadAssets(targetDir, assetUrl) {
560
559
  if (isExist) {
561
560
  return;
562
561
  }
563
- const [err, response] = yield (0, util_1.promiseWrapper)((0, axios_1.default)({
562
+ const [err, response] = yield util_1.promiseWrapper(axios_1.default({
564
563
  url: assetUrl,
565
564
  responseType: 'stream',
566
565
  }));
@@ -569,7 +568,7 @@ function downloadAssets(targetDir, assetUrl) {
569
568
  throw err;
570
569
  }
571
570
  yield fs_extra_1.default.ensureDir(targetDir);
572
- const filename = (0, common_1.getFileNameByUrl)(assetUrl);
571
+ const filename = common_1.getFileNameByUrl(assetUrl);
573
572
  const targetPath = path_1.default.resolve(targetDir, `./${filename}`);
574
573
  const writer = fs_extra_1.default.createWriteStream(targetPath);
575
574
  response.data.pipe(writer);
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildAsXPageByBuildType = exports.buildAsAdminPortalByBuildType = exports.buildAsWebByBuildType = void 0;
4
3
  var common_1 = require("../../generator/types/common");
5
4
  Object.defineProperty(exports, "buildAsWebByBuildType", { enumerable: true, get: function () { return common_1.buildAsWebByBuildType; } });
6
5
  Object.defineProperty(exports, "buildAsAdminPortalByBuildType", { enumerable: true, get: function () { return common_1.buildAsAdminPortalByBuildType; } });