@lingxiteam/ebe-utils 0.2.9 → 0.2.12

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 (2) hide show
  1. package/es/index.js +73 -63
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -227,7 +227,7 @@ export var clearLXPagesDSL = function clearLXPagesDSL(pages) {
227
227
  });
228
228
  };
229
229
  export var getSafeTypeName = function getSafeTypeName(name) {
230
- return name.replaceAll(' ', '').replaceAll('/', '').replaceAll('-', '').replaceAll('(', '').replaceAll(',', '').replaceAll(',', '').replaceAll(')', '');
230
+ return name.replaceAll(' ', '').replaceAll('/', '').replaceAll('-', '').replaceAll('(', '').replaceAll(',', '').replaceAll("'", '').replaceAll(',', '').replaceAll(')', '');
231
231
  };
232
232
  var workerJsUrl = '';
233
233
  export var setWorkerJsUrl = function setWorkerJsUrl(url) {
@@ -268,8 +268,8 @@ var checkHasPageRules = function checkHasPageRules(pageDsl) {
268
268
  };
269
269
  export var fetchData = /*#__PURE__*/function () {
270
270
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
271
- var _ref6, _attrSpecPage;
272
- var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, hasAppFileResource, hasExtendsApp, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, hasPageRulesPages, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, requestQueue, requests, pages, _yield$services$qryBu, itemLists, BusiCompRequest, _incrementalConstruct, itemHash, _itemLists, alllBusiComp, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, translateName, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, appFileResource, _services$queryAppFil, _yield$services$query, list, appFileResourceList, _yield$services$selec, toolBoxList, toolBox, pageRules, options, cleanedTree;
271
+ var _ref6, _appInfo$initialAppId, _attrSpecPage;
272
+ var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, hasAppFileResource, hasExtendsApp, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, hasPageRulesPages, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, requestQueue, requests, pages, _yield$services$qryBu, itemLists, BusiCompRequest, _incrementalConstruct, itemHash, _itemLists, alllBusiComp, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, translateName, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, appFileResource, _services$queryAppFil, _yield$services$query, _yield$services$query2, list, appFileResourceList, _yield$services$selec, toolBoxList, toolBox, pageRules, options, cleanedTree;
273
273
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
274
274
  while (1) switch (_context3.prev = _context3.next) {
275
275
  case 0:
@@ -331,24 +331,31 @@ export var fetchData = /*#__PURE__*/function () {
331
331
  // pageTypeMap[o.pageContainerType][o.pageId] = true;
332
332
  });
333
333
  if (isIncrementalConstruction) {
334
- _context3.next = 28;
334
+ _context3.next = 34;
335
335
  break;
336
336
  }
337
- _context3.next = 27;
337
+ _context3.prev = 25;
338
+ _context3.next = 28;
338
339
  return services.qryAttrSpecPage({
339
340
  appId: appId,
340
341
  pageNum: 1,
341
342
  pageSize: 999999
342
343
  });
343
- case 27:
344
- attrSpecPage = _context3.sent;
345
344
  case 28:
345
+ attrSpecPage = _context3.sent;
346
+ _context3.next = 34;
347
+ break;
348
+ case 31:
349
+ _context3.prev = 31;
350
+ _context3.t0 = _context3["catch"](25);
351
+ attrSpecPage = {};
352
+ case 34:
346
353
  if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.themeCssChange)) {
347
- _context3.next = 39;
354
+ _context3.next = 45;
348
355
  break;
349
356
  }
350
- _context3.prev = 29;
351
- _context3.next = 32;
357
+ _context3.prev = 35;
358
+ _context3.next = 38;
352
359
  return Promise.race([new Promise(function (resolve, reject) {
353
360
  services.getThemeCss({
354
361
  appId: appId,
@@ -361,26 +368,26 @@ export var fetchData = /*#__PURE__*/function () {
361
368
  resolve('');
362
369
  }, 5000);
363
370
  })]);
364
- case 32:
371
+ case 38:
365
372
  themeCss = _context3.sent;
366
373
  console.log('====获取主题成功');
367
- _context3.next = 39;
374
+ _context3.next = 45;
368
375
  break;
369
- case 36:
370
- _context3.prev = 36;
371
- _context3.t0 = _context3["catch"](29);
372
- console.error('====获取主题失败', _context3.t0);
373
- case 39:
376
+ case 42:
377
+ _context3.prev = 42;
378
+ _context3.t1 = _context3["catch"](35);
379
+ console.error('====获取主题失败', _context3.t1);
380
+ case 45:
374
381
  // 根据 appId 获取当前应用的使用的自定义组件
375
382
  onProgress({
376
383
  log: '获取当前应用的使用的自定义组件',
377
384
  progress: 3
378
385
  });
379
- _context3.next = 42;
386
+ _context3.next = 48;
380
387
  return services.qryPageCompAssetList({
381
388
  appId: appId
382
389
  });
383
- case 42:
390
+ case 48:
384
391
  temCompAssetList = _context3.sent;
385
392
  // 兼容下割接数据,数组前面的自定义组件是新的
386
393
  compAssetList = temCompAssetList.reduce(function (acc, current) {
@@ -393,7 +400,7 @@ export var fetchData = /*#__PURE__*/function () {
393
400
  return acc;
394
401
  }, []);
395
402
  if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.globalStoreChange)) {
396
- _context3.next = 51;
403
+ _context3.next = 57;
397
404
  break;
398
405
  }
399
406
  // 根据appId 获取全局数据源
@@ -401,12 +408,12 @@ export var fetchData = /*#__PURE__*/function () {
401
408
  log: '获取全局数据源',
402
409
  progress: 4
403
410
  });
404
- _context3.next = 48;
411
+ _context3.next = 54;
405
412
  return services.queryFrontendDatasourcePage({
406
413
  appId: appId,
407
414
  pageSize: 10000
408
415
  });
409
- case 48:
416
+ case 54:
410
417
  globalDataInfo = _context3.sent;
411
418
  dataSourceList = ((_globalDataInfo = globalDataInfo) === null || _globalDataInfo === void 0 ? void 0 : _globalDataInfo.list) || [];
412
419
  dataSourceList.forEach(function (item) {
@@ -421,7 +428,7 @@ export var fetchData = /*#__PURE__*/function () {
421
428
  }
422
429
  return null;
423
430
  });
424
- case 51:
431
+ case 57:
425
432
  pageIdMapping = {};
426
433
  lastPageId = ''; // 根据 pageId 获得 dsl
427
434
  data = [];
@@ -444,21 +451,23 @@ export var fetchData = /*#__PURE__*/function () {
444
451
  pageId: i.pageId
445
452
  });
446
453
  }).then(function (data) {
447
- // @ts-ignore
448
- pageIdMapping[data.pagePath] = data.pageId;
454
+ if (data) {
455
+ // @ts-ignore
456
+ pageIdMapping[data.pagePath] = data.pageId;
457
+ }
449
458
  resolve(data);
450
459
  }).catch(reject);
451
460
  });
452
461
  });
453
- _context3.next = 60;
462
+ _context3.next = 66;
454
463
  return Promise.all(requests);
455
- case 60:
464
+ case 66:
456
465
  data = _context3.sent;
457
466
  // 先清空
458
467
  requests = null;
459
468
  pages = getPageDsls(data, hasPageRulesPages);
460
469
  if (isIncrementalConstruction) {
461
- _context3.next = 76;
470
+ _context3.next = 82;
462
471
  break;
463
472
  }
464
473
  onProgress({
@@ -467,7 +476,7 @@ export var fetchData = /*#__PURE__*/function () {
467
476
  });
468
477
 
469
478
  // 业务组件从被使用才生成改为全部生成
470
- _context3.next = 67;
479
+ _context3.next = 73;
471
480
  return services.qryBusiCompPage({
472
481
  appIds: [appId],
473
482
  appId: appId,
@@ -476,7 +485,7 @@ export var fetchData = /*#__PURE__*/function () {
476
485
  pageSize: 999999,
477
486
  terminalType: platform
478
487
  });
479
- case 67:
488
+ case 73:
480
489
  _yield$services$qryBu = _context3.sent;
481
490
  itemLists = _yield$services$qryBu.list;
482
491
  BusiCompRequest = itemLists.map(function (i) {
@@ -490,15 +499,15 @@ export var fetchData = /*#__PURE__*/function () {
490
499
  }).then(resolve).catch(reject);
491
500
  });
492
501
  });
493
- _context3.next = 72;
502
+ _context3.next = 78;
494
503
  return Promise.all(BusiCompRequest);
495
- case 72:
504
+ case 78:
496
505
  busiData = _context3.sent;
497
506
  // 先清空
498
507
  BusiCompRequest = null;
499
- _context3.next = 83;
508
+ _context3.next = 89;
500
509
  break;
501
- case 76:
510
+ case 82:
502
511
  // busiCompId 过滤重复
503
512
  itemHash = {}; // 找到所有页面使用到的 业务组件
504
513
  findAllItem(pages, function (item) {
@@ -506,7 +515,7 @@ export var fetchData = /*#__PURE__*/function () {
506
515
  }, itemHash);
507
516
  _itemLists = Object.keys(itemHash); // 请求所有业务组件的 dsl
508
517
  alllBusiComp = ((_incrementalConstruct = incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.busiCompIds) !== null && _incrementalConstruct !== void 0 ? _incrementalConstruct : []).concat(_itemLists);
509
- _context3.next = 82;
518
+ _context3.next = 88;
510
519
  return Promise.all(alllBusiComp.map(function (i) {
511
520
  return services.findBusiCompById({
512
521
  busiCompId: i,
@@ -514,9 +523,9 @@ export var fetchData = /*#__PURE__*/function () {
514
523
  pageId: lastPageId
515
524
  });
516
525
  }));
517
- case 82:
526
+ case 88:
518
527
  busiData = _context3.sent;
519
- case 83:
528
+ case 89:
520
529
  // 过滤为空
521
530
  busiPages = busiData.filter(Boolean).map(function (i, index) {
522
531
  var _i$busiCompVersion;
@@ -590,14 +599,14 @@ export var fetchData = /*#__PURE__*/function () {
590
599
  });
591
600
  translateNames = {};
592
601
  if (!(chinese.length > 0)) {
593
- _context3.next = 91;
602
+ _context3.next = 97;
594
603
  break;
595
604
  }
596
- _context3.next = 90;
605
+ _context3.next = 96;
597
606
  return getTranslateName(appId, chinese, 'UPPER_CAMEL');
598
- case 90:
607
+ case 96:
599
608
  translateNames = _context3.sent;
600
- case 91:
609
+ case 97:
601
610
  // 翻译业务组件的名字
602
611
  for (key = 0; key < busiPages.length;) {
603
612
  onProgress({
@@ -607,13 +616,13 @@ export var fetchData = /*#__PURE__*/function () {
607
616
  translateName = (_translateNames = translateNames) === null || _translateNames === void 0 ? void 0 : _translateNames[getSafeTypeName(busiPages[key].pageName)]; // 翻译可能失败
608
617
  if (translateName) {
609
618
  busiPages[key]._pageName = busiPages[key].pageName;
610
- busiPages[key].pageName = translateName;
619
+ busiPages[key].pageName = getSafeTypeName(translateName);
611
620
  }
612
621
  key += 1;
613
622
  }
614
623
  pagePathEnglishMapping = {};
615
624
  if (!needTranslatePagePathToEnglish) {
616
- _context3.next = 104;
625
+ _context3.next = 110;
617
626
  break;
618
627
  }
619
628
  pagePathEnglishSet = {};
@@ -635,14 +644,14 @@ export var fetchData = /*#__PURE__*/function () {
635
644
  });
636
645
  pagesTranslateNames = {};
637
646
  if (!(pagesChinese.length > 0)) {
638
- _context3.next = 102;
647
+ _context3.next = 108;
639
648
  break;
640
649
  }
641
- _context3.next = 101;
650
+ _context3.next = 107;
642
651
  return getTranslateName(appId, pagesChinese, 'UPPER_CAMEL');
643
- case 101:
652
+ case 107:
644
653
  pagesTranslateNames = _context3.sent;
645
- case 102:
654
+ case 108:
646
655
  findPageKeyByPageId = function findPageKeyByPageId(id, arrs) {
647
656
  for (var _key = 0; _key < arrs.length;) {
648
657
  var _arrs$_key;
@@ -662,7 +671,7 @@ export var fetchData = /*#__PURE__*/function () {
662
671
  // index 保留不处理
663
672
  if (appPageList[_key2].pagePath !== '/index') {
664
673
  (_pagePathEnglishMappi = pagePathEnglishMapping[_appPageList$_key2$pa = appPageList[_key2].pageContainerType]) !== null && _pagePathEnglishMappi !== void 0 ? _pagePathEnglishMappi : pagePathEnglishMapping[_appPageList$_key2$pa] = {};
665
- safeTranslateName = getName(((_pagesTranslateNames = pagesTranslateNames) === null || _pagesTranslateNames === void 0 ? void 0 : _pagesTranslateNames[getSafeTypeName(appPageList[_key2].pageName)]) || appPageList[_key2].pageName, appPageList[_key2].pageContainerType);
674
+ safeTranslateName = getName(getSafeTypeName(((_pagesTranslateNames = pagesTranslateNames) === null || _pagesTranslateNames === void 0 ? void 0 : _pagesTranslateNames[getSafeTypeName(appPageList[_key2].pageName)]) || appPageList[_key2].pageName), appPageList[_key2].pageContainerType);
666
675
  pagePathEnglishMapping[appPageList[_key2].pageContainerType][appPageList[_key2].pagePath] = safeTranslateName;
667
676
  pageKey = findPageKeyByPageId(appPageList[_key2].pageId, pages);
668
677
  pages[pageKey]._pagePath = pages[pageKey].pagePath;
@@ -670,7 +679,7 @@ export var fetchData = /*#__PURE__*/function () {
670
679
  }
671
680
  _key2 += 1;
672
681
  }
673
- case 104:
682
+ case 110:
674
683
  // 合并页面,生成器那边支持页面类型和业务组件类型
675
684
  pageDSLS = [].concat(_toConsumableArray(pages), _toConsumableArray(busiPages));
676
685
  getPlatform = function getPlatform(platFormtype) {
@@ -685,10 +694,10 @@ export var fetchData = /*#__PURE__*/function () {
685
694
  }; // { '31232133':{fileName:'xxx',data:base64 }}
686
695
  appFileResource = {}; // 如果开启下载静态资源
687
696
  if (!hasAppFileResource) {
688
- _context3.next = 116;
697
+ _context3.next = 123;
689
698
  break;
690
699
  }
691
- _context3.next = 110;
700
+ _context3.next = 116;
692
701
  return services === null || services === void 0 || (_services$queryAppFil = services.queryAppFileResourcePage) === null || _services$queryAppFil === void 0 ? void 0 : _services$queryAppFil.call(services, {
693
702
  appId: appId,
694
703
  orderType: 'DESC',
@@ -696,10 +705,11 @@ export var fetchData = /*#__PURE__*/function () {
696
705
  pageSize: 999999,
697
706
  sharedObjFilter: 'F'
698
707
  });
699
- case 110:
708
+ case 116:
700
709
  _yield$services$query = _context3.sent;
701
- list = _yield$services$query.list;
702
- _context3.next = 114;
710
+ _yield$services$query2 = _yield$services$query.list;
711
+ list = _yield$services$query2 === void 0 ? [] : _yield$services$query2;
712
+ _context3.next = 121;
703
713
  return Promise.all((list || []).map(function (item) {
704
714
  return new Promise(function (resolve, reject) {
705
715
  requestQueue.sendRequest(function () {
@@ -722,19 +732,19 @@ export var fetchData = /*#__PURE__*/function () {
722
732
  }).catch(reject);
723
733
  });
724
734
  }));
725
- case 114:
735
+ case 121:
726
736
  appFileResourceList = _context3.sent;
727
737
  appFileResourceList.filter(Boolean).forEach(function (i) {
728
738
  appFileResource[i.fileCode] = i;
729
739
  });
730
- case 116:
731
- _context3.next = 118;
740
+ case 123:
741
+ _context3.next = 125;
732
742
  return services.selectToolBoxPage({
733
743
  appId: appId,
734
744
  qryType: 'F',
735
745
  toolScan: 'front_function'
736
746
  });
737
- case 118:
747
+ case 125:
738
748
  _yield$services$selec = _context3.sent;
739
749
  toolBoxList = _yield$services$selec.list;
740
750
  toolBox = (toolBoxList || []).map(function (i) {
@@ -742,7 +752,7 @@ export var fetchData = /*#__PURE__*/function () {
742
752
  var toolScript = toolScriptJson === null || toolScriptJson === void 0 ? void 0 : toolScriptJson.script;
743
753
  return "export ".concat(toolScript.replace(/function\s+(\w+)\s*\(/, "function ".concat(i === null || i === void 0 ? void 0 : i.toolCode, "(")));
744
754
  }).join('\n'); // TODO: 新接口,有些环境还没部署,等都部署了,可以去掉这个兜底
745
- _context3.next = 123;
755
+ _context3.next = 130;
746
756
  return Promise.race([new Promise(function (resolve, reject) {
747
757
  services.batchQryPageRulesByPageIds({
748
758
  appId: appId,
@@ -755,11 +765,11 @@ export var fetchData = /*#__PURE__*/function () {
755
765
  resolve({});
756
766
  }, 5000);
757
767
  })]);
758
- case 123:
768
+ case 130:
759
769
  pageRules = _context3.sent;
760
770
  options = {
761
771
  platform: getPlatform(platform),
762
- appId: appInfo.initialAppId,
772
+ appId: (_appInfo$initialAppId = appInfo === null || appInfo === void 0 ? void 0 : appInfo.initialAppId) !== null && _appInfo$initialAppId !== void 0 ? _appInfo$initialAppId : appId,
763
773
  pageIdMapping: pageIdMapping,
764
774
  compAssetList: compAssetList || [],
765
775
  baseUrl: baseUrl,
@@ -791,11 +801,11 @@ export var fetchData = /*#__PURE__*/function () {
791
801
  options: options,
792
802
  cleanedTree: cleanedTree
793
803
  });
794
- case 129:
804
+ case 136:
795
805
  case "end":
796
806
  return _context3.stop();
797
807
  }
798
- }, _callee3, null, [[29, 36]]);
808
+ }, _callee3, null, [[25, 31], [35, 42]]);
799
809
  }));
800
810
  return function fetchData(_x) {
801
811
  return _ref5.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/ebe-utils",
3
- "version": "0.2.9",
3
+ "version": "0.2.12",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -19,7 +19,7 @@
19
19
  "@babel/types": "^7.12.12",
20
20
  "cac": "^6.7.14",
21
21
  "fs-extra": "9.x",
22
- "@lingxiteam/ebe": "0.2.9"
22
+ "@lingxiteam/ebe": "0.2.12"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"