@lingxiteam/ebe-utils 0.0.17 → 0.0.19

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.
package/es/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export declare const treeForEach: (tree: any, callback: (item: any, root: boolea
8
8
  children: string;
9
9
  }) => void;
10
10
  export declare const getPageDsls: (resultObjects: any[]) => any[];
11
+ export declare function findAllItem<T = any>(target: T[], callback: (item: T, index: number, list: T[]) => boolean, itemHash: any): void;
11
12
  export declare function findItem<T = any>(target: T[], callback: (item: T, index: number, list: T[]) => boolean): T | null;
12
13
  export declare const cleanTree: (tree: any, fields: any) => any;
13
14
  export declare const clearLXPagesDSL: (pages: any[]) => any[];
package/es/index.js CHANGED
@@ -156,28 +156,25 @@ export var getPageDsls = function getPageDsls(resultObjects) {
156
156
  }
157
157
  }).filter(Boolean);
158
158
  };
159
- // export function findAllItem<T = any>(
160
- // target: T[],
161
- // callback: (item: T, index: number, list: T[]) => boolean,
162
- // itemHash: any,
163
- // ) {
164
- // const list = target;
165
- // // Makes sures is always has an positive integer as length.
166
- // // eslint-disable-next-line
167
- // const length = list.length >>> 0;
168
- // // eslint-disable-next-line
169
- // const thisArg = arguments[1];
170
- // for (let i = 0; i < length; ) {
171
- // const element = list[i] as any;
172
- // if (callback.call(thisArg, element, i, list)) {
173
- // itemHash[element?.props?.busiCompId ?? ''] = 1;
174
- // }
175
- // i += 1;
176
- // if (element?.components) {
177
- // findAllItem(element?.components, callback, itemHash);
178
- // }
179
- // }
180
- // }
159
+ export function findAllItem(target, callback, itemHash) {
160
+ var list = target;
161
+ // Makes sures is always has an positive integer as length.
162
+ // eslint-disable-next-line
163
+ var length = list.length >>> 0;
164
+ // eslint-disable-next-line
165
+ var thisArg = arguments[1];
166
+ for (var i = 0; i < length;) {
167
+ var element = list[i];
168
+ if (callback.call(thisArg, element, i, list)) {
169
+ var _element$props$busiCo, _element$props;
170
+ itemHash[(_element$props$busiCo = element === null || element === void 0 || (_element$props = element.props) === null || _element$props === void 0 ? void 0 : _element$props.busiCompId) !== null && _element$props$busiCo !== void 0 ? _element$props$busiCo : ''] = 1;
171
+ }
172
+ i += 1;
173
+ if (element !== null && element !== void 0 && element.components) {
174
+ findAllItem(element === null || element === void 0 ? void 0 : element.components, callback, itemHash);
175
+ }
176
+ }
177
+ }
181
178
  export function findItem(target, callback) {
182
179
  var list = target;
183
180
  // Makes sures is always has an positive integer as length.
@@ -253,7 +250,7 @@ var getIsIncrementalConstruction = function getIsIncrementalConstruction(ic) {
253
250
  export var fetchData = /*#__PURE__*/function () {
254
251
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
255
252
  var _ref6, _attrSpecPage;
256
- var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, pages, _yield$services$qryBu, itemLists, _incrementalConstruct, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, options, cleanedTree;
253
+ var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, pages, _yield$services$qryBu, itemLists, _incrementalConstruct, itemHash, _itemLists, alllBusiComp, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, options, cleanedTree;
257
254
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
258
255
  while (1) switch (_context3.prev = _context3.next) {
259
256
  case 0:
@@ -450,20 +447,27 @@ export var fetchData = /*#__PURE__*/function () {
450
447
  }));
451
448
  case 66:
452
449
  busiData = _context3.sent;
453
- _context3.next = 72;
450
+ _context3.next = 76;
454
451
  break;
455
452
  case 69:
456
- _context3.next = 71;
457
- return Promise.all(((_incrementalConstruct = incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.busiCompIds) !== null && _incrementalConstruct !== void 0 ? _incrementalConstruct : []).map(function (i) {
453
+ // busiCompId 过滤重复
454
+ itemHash = {}; // 找到所有页面使用到的 业务组件
455
+ findAllItem(pages, function (item) {
456
+ return item.compName === 'BOFramer';
457
+ }, itemHash);
458
+ _itemLists = Object.keys(itemHash); // 请求所有业务组件的 dsl
459
+ alllBusiComp = ((_incrementalConstruct = incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.busiCompIds) !== null && _incrementalConstruct !== void 0 ? _incrementalConstruct : []).concat(_itemLists);
460
+ _context3.next = 75;
461
+ return Promise.all(alllBusiComp.map(function (i) {
458
462
  return services.findBusiCompById({
459
463
  busiCompId: i,
460
464
  appId: appId,
461
465
  pageId: lastPageId
462
466
  });
463
467
  }));
464
- case 71:
468
+ case 75:
465
469
  busiData = _context3.sent;
466
- case 72:
470
+ case 76:
467
471
  // 过滤为空
468
472
  busiPages = busiData.filter(Boolean).map(function (i, index) {
469
473
  var _i$busiCompVersion;
@@ -536,14 +540,14 @@ export var fetchData = /*#__PURE__*/function () {
536
540
  });
537
541
  translateNames = {};
538
542
  if (!(chinese.length > 0)) {
539
- _context3.next = 80;
543
+ _context3.next = 84;
540
544
  break;
541
545
  }
542
- _context3.next = 79;
546
+ _context3.next = 83;
543
547
  return getTranslateName(appId, chinese, 'UPPER_CAMEL');
544
- case 79:
548
+ case 83:
545
549
  translateNames = _context3.sent;
546
- case 80:
550
+ case 84:
547
551
  // 翻译业务组件的名字
548
552
  for (key = 0; key < busiPages.length; key++) {
549
553
  onProgress({
@@ -555,7 +559,7 @@ export var fetchData = /*#__PURE__*/function () {
555
559
  }
556
560
  pagePathEnglishMapping = {};
557
561
  if (!needTranslatePagePathToEnglish) {
558
- _context3.next = 93;
562
+ _context3.next = 97;
559
563
  break;
560
564
  }
561
565
  pagePathEnglishSet = {};
@@ -577,14 +581,14 @@ export var fetchData = /*#__PURE__*/function () {
577
581
  });
578
582
  pagesTranslateNames = {};
579
583
  if (!(pagesChinese.length > 0)) {
580
- _context3.next = 91;
584
+ _context3.next = 95;
581
585
  break;
582
586
  }
583
- _context3.next = 90;
587
+ _context3.next = 94;
584
588
  return getTranslateName(appId, pagesChinese, 'UPPER_CAMEL');
585
- case 90:
589
+ case 94:
586
590
  pagesTranslateNames = _context3.sent;
587
- case 91:
591
+ case 95:
588
592
  findPageKeyByPageId = function findPageKeyByPageId(id, arrs) {
589
593
  for (var _key = 0; _key < arrs.length; _key++) {
590
594
  var _arrs$_key;
@@ -610,7 +614,7 @@ export var fetchData = /*#__PURE__*/function () {
610
614
  pages[pageKey].pagePath = safeTranslateName;
611
615
  }
612
616
  }
613
- case 93:
617
+ case 97:
614
618
  // 合并页面,生成器那边支持页面类型和业务组件类型
615
619
  pageDSLS = [].concat(_toConsumableArray(pages), _toConsumableArray(busiPages));
616
620
  getPlatform = function getPlatform(platFormtype) {
@@ -653,7 +657,7 @@ export var fetchData = /*#__PURE__*/function () {
653
657
  options: options,
654
658
  cleanedTree: cleanedTree
655
659
  });
656
- case 100:
660
+ case 104:
657
661
  case "end":
658
662
  return _context3.stop();
659
663
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/ebe-utils",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -17,7 +17,7 @@
17
17
  "@babel/parser": "^7.12.12",
18
18
  "@babel/traverse": "^7.12.12",
19
19
  "@babel/types": "^7.12.12",
20
- "@lingxiteam/ebe": "0.0.17",
20
+ "@lingxiteam/ebe": "0.0.19",
21
21
  "cac": "^6.7.14",
22
22
  "fs-extra": "9.x"
23
23
  },