@cloudbase/lowcode-builder 0.1.12 → 0.1.15

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.
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -46,9 +50,8 @@ const types_1 = require("../../types");
46
50
  const common_1 = require("../types/common");
47
51
  const lodash_1 = require("lodash");
48
52
  const junk = __importStar(require("../util/junk"));
49
- const path_2 = __importDefault(require("path"));
50
53
  const net_1 = require("../util/net");
51
- const templateDir = config_1.appTemplateDir + '/mp/';
54
+ const templateDir = `${config_1.appTemplateDir}/mp/`;
52
55
  const em = chalk_1.default.blue.bold;
53
56
  const error = chalk_1.default.redBright;
54
57
  async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder = false, }) {
@@ -85,7 +88,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
85
88
  const projectFileData = {
86
89
  'project.config.json': { content: projConfig },
87
90
  };
88
- console.log('Generating ' + em('project') + ' files');
91
+ console.log(`Generating ${em('project')} files`);
89
92
  await (0, generateFiles_1.default)(projectFileData, templateDir, projDir, buildContext);
90
93
  }
91
94
  // #2 生成主包
@@ -143,17 +146,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
143
146
  await (0, generateFiles_1.writeFile)(projectConfigJsonPath, JSON.stringify(projectConfigJson, undefined, 2));
144
147
  let appJsonPath = path_1.default.join(miniprogramRoot, 'app.json');
145
148
  let appJson = await fs.readJson(appJsonPath);
146
- let subpackages = appJson.subpackages || [];
147
- for (let item of appConfig.subpackages || []) {
148
- let find = subpackages.find((config) => config.root === item.root);
149
- if (find) {
150
- find.pages = Array.from(new Set([].concat(find.pages || []).concat(item.pages || [])));
151
- }
152
- else {
153
- subpackages.push(item);
154
- }
155
- }
156
- appJson.subpackages = subpackages;
149
+ appJson.subpackages = (0, mp_config_1.mergeSubPackages)(appJson.subpackages, appConfig.subpackages);
157
150
  await (0, generateFiles_1.writeFile)(appJsonPath, JSON.stringify(appJson, undefined, 2));
158
151
  }
159
152
  else {
@@ -328,7 +321,7 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
328
321
  dataBinds: (0, util_2.createDataBinds)(page.componentInstances, ctx),
329
322
  debug: ctx.debugMode,
330
323
  stringifyObj: util_1.inspect,
331
- subLevelPath: rootPath ? path_2.default.relative(rootPath, '') + '/' : '',
324
+ subLevelPath: rootPath ? path_1.default.relative(rootPath, '') + '/' : '',
332
325
  },
333
326
  [`index.json|${pageFileName}.json`]: {
334
327
  usingComponents,
@@ -341,7 +334,7 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
341
334
  },
342
335
  [`index.wxss|${pageFileName}.wxss`]: {
343
336
  subWxss: rootPath && !((_a = ctx.mainAppData) === null || _a === void 0 ? void 0 : _a.mpPkgUrl)
344
- ? `@import "${path_2.default.relative(`/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
337
+ ? `@import "${path_1.default.relative(`/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
345
338
  : '',
346
339
  content: (0, weapps_core_1.toCssText)((0, weapps_core_1.toCssStyle)(page.commonStyle, {
347
340
  toRem: false,
@@ -409,6 +402,7 @@ async function generateFramework(appData, outDir, ctx) {
409
402
  .sort((item) => (item.isHome ? -1 : 1))
410
403
  .map((item) => ({
411
404
  id: item.id,
405
+ type: item.data.isCustomLoginPage ? 'login' : '',
412
406
  })),
413
407
  }),
414
408
  },
@@ -425,14 +419,17 @@ async function generateFramework(appData, outDir, ctx) {
425
419
  await (0, generateFiles_1.default)(fileData, templateDir, outDir, ctx);
426
420
  }
427
421
  async function writeLowCodeFiles(appData, outDir, ctx) {
428
- console.log('Writing ' + em('lowcode') + ' files:');
422
+ console.log(`Writing ${em('lowcode')} files:`);
429
423
  const lowcodeRootDir = path_1.default.join(outDir, 'lowcode');
430
424
  const themeStyle = (0, style_1.generateDefaultTheme)(appData);
431
425
  // 混合模式,子包不生成顶级(应用级)的 lowcodes
432
426
  if (!(ctx.isMixMode && appData.rootPath)) {
433
427
  await Promise.all(appData.lowCodes
434
428
  .filter((mod) => mod.name !== '____index____')
435
- .map((m) => (0, lowcode_1.writeCode2file)(m, lowcodeRootDir, { appDir: outDir }, themeStyle.code)));
429
+ .filter((mod) => mod.type !== 'renderer')
430
+ .map((m) => {
431
+ (0, lowcode_1.writeCode2file)(m, lowcodeRootDir, { appDir: outDir }, themeStyle.code);
432
+ }));
436
433
  }
437
434
  await Promise.all((0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, async (page) => {
438
435
  var _a;
@@ -446,7 +443,9 @@ async function writeLowCodeFiles(appData, outDir, ctx) {
446
443
  path: 'xx/index',
447
444
  });
448
445
  }
449
- await ((_a = page === null || page === void 0 ? void 0 : page.lowCodes) === null || _a === void 0 ? void 0 : _a.filter((mod) => mod.name !== '____index____').forEach((m) => (0, lowcode_1.writeCode2file)(m, lowcodeRootDir, { pageId: page.id, appDir: outDir }, themeStyle.code, ctx)));
446
+ await ((_a = page === null || page === void 0 ? void 0 : page.lowCodes) === null || _a === void 0 ? void 0 : _a.filter((mod) => mod.name !== '____index____').filter((mod) => mod.type !== 'renderer').forEach((m) => {
447
+ (0, lowcode_1.writeCode2file)(m, lowcodeRootDir, { pageId: page.id, appDir: outDir }, themeStyle.code, ctx);
448
+ }));
450
449
  }));
451
450
  }
452
451
  exports.writeLowCodeFiles = writeLowCodeFiles;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -7,11 +7,17 @@ import { IBuildContext } from './BuildContext';
7
7
  * @param appConfigs app config from prop edit panel
8
8
  */
9
9
  export declare function generateMpConfig(weapps: IWeAppData[], ctx: IBuildContext): {
10
- appConfig: {
11
- useExtendedLib: {
12
- weui: boolean;
13
- };
14
- };
10
+ appConfig: any;
15
11
  projConfig: any;
16
12
  pageConfigs: {}[];
17
13
  };
14
+ interface ISubpackage {
15
+ root: string;
16
+ pages?: string[];
17
+ plugins?: Record<string, {
18
+ version?: string;
19
+ provider?: string;
20
+ }>;
21
+ }
22
+ export declare function mergeSubPackages(base?: ISubpackage[], extra?: ISubpackage[]): ISubpackage[];
23
+ export {};
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -22,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
27
  };
24
28
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.generateMpConfig = void 0;
29
+ exports.mergeSubPackages = exports.generateMpConfig = void 0;
26
30
  const path = __importStar(require("path"));
27
31
  const lodash_1 = require("lodash");
28
32
  const mp_1 = require("@cloudbase/lowcode-generator/lib/generator/config/mp");
@@ -43,7 +47,8 @@ function generateMpConfig(weapps, ctx) {
43
47
  };
44
48
  const { miniprogramPlugins = [] } = ctx;
45
49
  const projConfig = (0, lodash_1.merge)({}, mp_1.defaultProjConfig, {
46
- projectname: (ctx.mainAppData && ctx.mainAppData.label) || ('WeDa-' + ctx.appId),
50
+ projectname: (ctx.mainAppData && ctx.mainAppData.label) ||
51
+ `WeDa-${ctx.appId}`,
47
52
  });
48
53
  const pageConfigs = weapps.map((app) => {
49
54
  var _a;
@@ -80,7 +85,9 @@ function generateMpConfig(weapps, ctx) {
80
85
  projConfig.packOptions.ignore.push(...matertialMetaIgnores);
81
86
  const { tradingCapability, ...mainAppConfig } = weapps[0].appConfig || {};
82
87
  // keep main app config only, ignore subapp config
83
- (0, lodash_1.merge)(appConfig, mainAppConfig, extractPages(weapps, pageConfigs));
88
+ const { subpackages, ...extra } = extractPages(weapps, pageConfigs);
89
+ (0, lodash_1.merge)(appConfig, mainAppConfig, extra);
90
+ appConfig.subpackages = mergeSubPackages(appConfig.subpackages, subpackages);
84
91
  if (tradingCapability) {
85
92
  const tradePluginKey = `weda-mini-shop-plugin`;
86
93
  const pluginMeta = {
@@ -102,8 +109,8 @@ function generateMpConfig(weapps, ctx) {
102
109
  appConfig.plugins = plugins;
103
110
  }
104
111
  miniprogramPlugins.forEach((plugin) => {
105
- var _a, _b;
106
- if (!((_b = (_a = appConfig) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b[plugin.name])) {
112
+ var _a;
113
+ if (!((_a = appConfig === null || appConfig === void 0 ? void 0 : appConfig.plugins) === null || _a === void 0 ? void 0 : _a[plugin.name])) {
107
114
  (0, lodash_1.set)(appConfig, `plugins.${plugin.name}`, {
108
115
  version: plugin.version,
109
116
  provider: plugin.pluginAppId,
@@ -179,10 +186,29 @@ function parseTabConfig(tabBar, projDir) {
179
186
  console.error(chalk_1.default.red('App.json invalid tabbar icon path'), iconUrl);
180
187
  return;
181
188
  }
182
- const iconPath = 'assets/tab' + index + '/' + filename + path.extname(iconUrl);
183
- (0, net_1.downloadFile)(iconUrl, projDir + '/' + iconPath).catch((e) => {
189
+ const iconPath = `assets/tab${index}/${filename}${path.extname(iconUrl)}`;
190
+ (0, net_1.downloadFile)(iconUrl, `${projDir}/${iconPath}`).catch((e) => {
184
191
  console.error(chalk_1.default.red(`Fail to download tabBar icon from ${iconUrl}`), e);
185
192
  });
186
193
  return iconPath;
187
194
  }
188
195
  }
196
+ function mergeSubPackages(base = [], extra = []) {
197
+ const baseMap = base.reduce((map, item) => {
198
+ map[item.root] = item;
199
+ return map;
200
+ }, {});
201
+ for (const subpackage of extra) {
202
+ if (!baseMap[subpackage.root]) {
203
+ base.push(subpackage);
204
+ continue;
205
+ }
206
+ const current = baseMap[subpackage.root];
207
+ current.pages = Array.from(new Set([...(current.pages || []), ...(subpackage.pages || [])]));
208
+ if (current.plugins || subpackage.plugins) {
209
+ current.plugins = (0, lodash_1.merge)(current.pplugins, subpackage.plugins);
210
+ }
211
+ }
212
+ return base;
213
+ }
214
+ exports.mergeSubPackages = mergeSubPackages;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -55,7 +55,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
55
55
  ];
56
56
  }
57
57
  function createXml(widgets, parent = null, parentForNodes = []) {
58
- var _a;
58
+ var _a, _b, _c, _d, _e;
59
59
  const elements = [];
60
60
  for (const id in widgets) {
61
61
  const { xComponent, xProps, properties, xIndex, genericComp } = widgets[id];
@@ -77,7 +77,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
77
77
  }
78
78
  continue;
79
79
  }
80
- const componentKey = xComponent.moduleName + ':' + xComponent.name;
80
+ const componentKey = `${xComponent.moduleName}:${xComponent.name}`;
81
81
  const helpMsg = `Please check component(${id}) in component tree of ${docTag}.`;
82
82
  const materialLib = ctx.materialLibs.find((lib) => lib.name === xComponent.moduleName);
83
83
  const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === xComponent.moduleName);
@@ -94,7 +94,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
94
94
  }
95
95
  // eslint-disable-next-line prefer-const
96
96
  let { tagName, path } = (0, materials_1.getWxmlTag)(xComponent, ctx, nameMangler);
97
- if (genericComp && genericComp.propName) {
97
+ if (genericComp === null || genericComp === void 0 ? void 0 : genericComp.propName) {
98
98
  tagName = getGenericCompTagName(genericComp.propName);
99
99
  componentGenerics[tagName] = { default: path || tagName };
100
100
  }
@@ -102,7 +102,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
102
102
  usingComponents[tagName] = path;
103
103
  }
104
104
  let curForNodes = parentForNodes;
105
- if (directives.waFor && directives.waFor.value) {
105
+ if ((_b = directives.waFor) === null || _b === void 0 ? void 0 : _b.value) {
106
106
  curForNodes = [...curForNodes, id];
107
107
  }
108
108
  const attrPrefix = `${wxmlDataPrefix.widgetProp}${id}${curForNodes
@@ -126,7 +126,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
126
126
  _order: xIndex || 0,
127
127
  _parent: null,
128
128
  };
129
- if (directives.waIf && directives.waIf.value) {
129
+ if ((_c = directives.waIf) === null || _c === void 0 ? void 0 : _c.value) {
130
130
  slotNode.attributes['wx:if'] = getAttrBind(directives.waIf, `${attrPrefix}._waIf`);
131
131
  }
132
132
  elements.push(slotNode);
@@ -137,6 +137,8 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
137
137
  name: tagName,
138
138
  attributes: {
139
139
  id: idAttr,
140
+ bindattached: '__handlerAttached__',
141
+ binddetached: '__handlerDetached__',
140
142
  style: `{{${attrPrefix}.style}}`,
141
143
  [(0, mp_1.getClassAttrName)(tagName)]: `{{${attrPrefix}.className}}`,
142
144
  },
@@ -148,10 +150,10 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
148
150
  if (mustEmptyStyle) {
149
151
  delete node.attributes.style;
150
152
  }
151
- if (directives.waIf && directives.waIf.value) {
153
+ if ((_d = directives.waIf) === null || _d === void 0 ? void 0 : _d.value) {
152
154
  node.attributes['wx:if'] = getAttrBind(directives.waIf, `${attrPrefix}._waIf`);
153
155
  }
154
- if (directives.waFor && directives.waFor.value) {
156
+ if ((_e = directives.waFor) === null || _e === void 0 ? void 0 : _e.value) {
155
157
  node.attributes['wx:for'] = getAttrBind(directives.waFor, `${wxmlDataPrefix.widgetProp}${id}${parentForNodes
156
158
  .map((forNodeId) => `[${wxmlDataPrefix.forIndex}${forNodeId}]`)
157
159
  .join('')}`);
@@ -159,7 +161,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
159
161
  node.attributes['wx:key'] = 'id';
160
162
  }
161
163
  const compSchema = componentProto.dataForm;
162
- for (const prop in data) {
164
+ for (const prop of Object.keys(data || {})) {
163
165
  if (compSchema) {
164
166
  const fieldDef = compSchema[prop];
165
167
  if (!fieldDef && !isGlobalAttr(prop)) {
@@ -167,7 +169,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
167
169
  continue;
168
170
  }
169
171
  if (fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.readOnly) {
170
- if (fieldDef.hasOwnProperty('default')) {
172
+ if (Object.prototype.hasOwnProperty.call(fieldDef, 'default')) {
171
173
  node.attributes[prop] = fieldDef.default;
172
174
  }
173
175
  else {
@@ -180,7 +182,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
180
182
  const passedComp = data[prop].value;
181
183
  const [libName, compName] = passedComp.split(':');
182
184
  const { tagName, path } = (0, materials_1.getWxmlTag)({ moduleName: libName, name: compName }, ctx, nameMangler);
183
- node.attributes['generic:' + getGenericCompTagName(prop)] = tagName;
185
+ node.attributes[`generic:${getGenericCompTagName(prop)}`] = tagName;
184
186
  usingComponents[tagName] = path;
185
187
  continue;
186
188
  }
@@ -213,7 +215,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
213
215
  if (compConfig === null || compConfig === void 0 ? void 0 : compConfig.isDataContainer) {
214
216
  node.attributes['bind:onDataChange'] = getMpEventHanlderName(id, 'onDataChange');
215
217
  }
216
- if (compConfig && compConfig.pluginConfig) {
218
+ if (compConfig === null || compConfig === void 0 ? void 0 : compConfig.pluginConfig) {
217
219
  if (compConfig.pluginConfig.attributes) {
218
220
  Object.assign(node.attributes, compConfig.pluginConfig.attributes);
219
221
  }
@@ -243,7 +245,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
243
245
  componentKey === 'gsd-h5-react:Swiper') {
244
246
  node.elements = node.elements.map((item, index) => {
245
247
  var _a, _b;
246
- let { ['wx:for']: wxFor, ['wx:for-index']: wxForIndex, ['wx:key']: wxKey, ...itemRestKey } = item.attributes || {};
248
+ let { ['wx:for']: wxFor, ['wx:for-index']: wxForIndex, ['wx:key']: wxKey, ['wx:if']: wxIf, ...itemRestKey } = item.attributes || {};
247
249
  if (item.name !== 'swiper-item') {
248
250
  let SwiperItem = {
249
251
  type: 'element',
@@ -253,6 +255,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
253
255
  'wx:for': wxFor,
254
256
  'wx:for-index': wxForIndex,
255
257
  'wx:key': wxKey,
258
+ 'wx:if': wxIf,
256
259
  },
257
260
  elements: [],
258
261
  _order: index || 0,
@@ -274,7 +277,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
274
277
  }
275
278
  });
276
279
  }
277
- nodeTransform && nodeTransform(widgets[id], node);
280
+ nodeTransform === null || nodeTransform === void 0 ? void 0 : nodeTransform(widgets[id], node);
278
281
  elements.push(node);
279
282
  }
280
283
  return elements.sort((a, b) => a._order - b._order);
@@ -292,7 +295,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
292
295
  exports.generateWxml = generateWxml;
293
296
  function xmlJsonSetCustomAttr(node, prop, value, comp) {
294
297
  if (mp_1.builtinWigetProps.indexOf(prop) > -1) {
295
- console.error(error('Builtin prop(' + prop + ') is not allowed for custom component'), comp);
298
+ console.error(error(`Builtin prop(${prop}) is not allowed for custom component`), comp);
296
299
  return;
297
300
  }
298
301
  node.attributes[prop] = value;
@@ -302,7 +305,6 @@ function xmlJsonSetCustomAttr(node, prop, value, comp) {
302
305
  }
303
306
  }
304
307
  const evtNameMap = {
305
- // eslint-disable-next-line @typescript-eslint/camelcase
306
308
  __weapps_action_trigger_click: 'tap',
307
309
  };
308
310
  function getMpEventName(originalName) {
@@ -366,7 +368,7 @@ function getAttrBind(dVale, widgetBind, isStaticResource) {
366
368
  : `{{${attrVal}}}`;
367
369
  }
368
370
  function getGenericCompTagName(propName) {
369
- return 'g--' + propName;
371
+ return `g--${propName}`;
370
372
  }
371
373
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#list_of_global_attributes
372
374
  function isGlobalAttr(prop = '') {
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -32,6 +36,7 @@ exports.mergePages = exports.mergePackageDependiences = exports.mergePackageJson
32
36
  */
33
37
  const fs = __importStar(require("fs-extra"));
34
38
  const lodash_1 = __importDefault(require("lodash"));
39
+ const mp_config_1 = require("../mp/mp_config");
35
40
  // 将后面的子包配置合并到前面
36
41
  // 暂时不考虑 root 会重名的情况
37
42
  async function mergeSubPackages(baseAppJsonPath, mergeAppJsonPath) {
@@ -40,24 +45,7 @@ async function mergeSubPackages(baseAppJsonPath, mergeAppJsonPath) {
40
45
  if (!getSubPackages(mergeJson))
41
46
  return;
42
47
  const newJson = { ...baseJson };
43
- if (!baseJson.subpackages) {
44
- newJson.subpackages = getSubPackages(mergeJson);
45
- }
46
- else {
47
- getSubPackages(mergeJson).forEach((mergeItem) => {
48
- // 找到重复的进行合并再去重
49
- const targetItemIdx = newJson.subpackages.findIndex((item) => {
50
- return item.root === mergeItem.root;
51
- });
52
- if (newJson.subpackages[targetItemIdx]) {
53
- const pages = lodash_1.default.uniq([].concat(newJson.subpackages[targetItemIdx].pages, mergeItem.pages));
54
- newJson.subpackages[targetItemIdx].pages = pages;
55
- }
56
- else {
57
- newJson.subpackages.push(mergeItem);
58
- }
59
- });
60
- }
48
+ newJson.subpackages = (0, mp_config_1.mergeSubPackages)(baseJson.subpackages, mergeJson.subpackages);
61
49
  fs.writeJSONSync(baseAppJsonPath, newJson, { spaces: 2 });
62
50
  // 处理兼容
63
51
  function getSubPackages(json) {
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { ChildProcess } from 'child_process';
3
4
  interface IProcessOptions {
4
5
  onStdout?: (data: Buffer) => any;