@next-core/brick-kit 2.133.0 → 2.134.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.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { parsePath, createBrowserHistory, locationsAreEqual, createPath } from 'history';
1
+ import { parsePath, createBrowserHistory, locationsAreEqual } from 'history';
2
2
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
3
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
4
  import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
@@ -1353,24 +1353,6 @@ var InstalledMicroAppApi_getI18NData = /*#__PURE__*/function () {
1353
1353
  return _ref.apply(this, arguments);
1354
1354
  };
1355
1355
  }();
1356
- /**
1357
- * @description 查询模型关联小产品列表
1358
- * @endpoint LIST /api/micro_app/v1/object_micro_app
1359
- */
1360
-
1361
-
1362
- var ObjectMicroAppApi_getObjectMicroAppList = /*#__PURE__*/function () {
1363
- var _ref = _asyncToGenerator$3(function* (options) {
1364
- return (
1365
- /**! @contract easyops.api.micro_app.object_micro_app.GetObjectMicroAppList@1.0.0 */
1366
- (yield http.get("api/gateway/micro_app.object_micro_app.GetObjectMicroAppList/api/micro_app/v1/object_micro_app", options)).data
1367
- );
1368
- });
1369
-
1370
- return function ObjectMicroAppApi_getObjectMicroAppList(_x) {
1371
- return _ref.apply(this, arguments);
1372
- };
1373
- }();
1374
1356
  /**
1375
1357
  * @description 校验系统权限
1376
1358
  * @endpoint POST /api/micro_app/v1/permission/validate
@@ -3667,8 +3649,7 @@ class Runtime {
3667
3649
  /* istanbul ignore next */
3668
3650
 
3669
3651
 
3670
- reloadSharedData() {
3671
- return kernel.loadSharedData();
3652
+ reloadSharedData() {// Drop supports for related apps;
3672
3653
  }
3673
3654
  /* istanbul ignore next */
3674
3655
 
@@ -3770,27 +3751,25 @@ class Runtime {
3770
3751
 
3771
3752
  /* istanbul ignore next */
3772
3753
  getRelatedApps(appId) {
3773
- // eslint-disable-next-line no-console
3774
- console.warn("`getRuntime().getRelatedApps()` is deprecated and will always return an empty array, please use `await getRuntime().getRelatedAppsAsync()` instead");
3775
3754
  return [];
3776
3755
  }
3777
3756
  /* istanbul ignore next */
3778
3757
 
3779
3758
 
3780
3759
  getRelatedAppsAsync(appId) {
3781
- return kernel.getRelatedAppsAsync(appId);
3760
+ // eslint-disable-next-line no-console
3761
+ console.warn("`getRuntime().getRelatedAppsAsync()` is deprecated and will always resolve with an empty array");
3762
+ return Promise.resolve([]);
3782
3763
  }
3783
3764
  /* istanbul ignore next */
3784
3765
 
3785
3766
 
3786
- popWorkspaceStack() {
3787
- return kernel.popWorkspaceStack();
3767
+ popWorkspaceStack() {// deprecated
3788
3768
  }
3789
3769
  /* istanbul ignore next */
3790
3770
 
3791
3771
 
3792
- resetWorkspaceStack() {
3793
- kernel.workspaceStack = [];
3772
+ resetWorkspaceStack() {// deprecated
3794
3773
  }
3795
3774
 
3796
3775
  applyPageTitle(pageTitle) {
@@ -8854,18 +8833,16 @@ class Kernel {
8854
8833
 
8855
8834
  _defineProperty$1(this, "nextApp", void 0);
8856
8835
 
8857
- _defineProperty$1(this, "currentUrl", void 0);
8858
-
8859
8836
  _defineProperty$1(this, "currentRoute", void 0);
8860
8837
 
8861
- _defineProperty$1(this, "workspaceStack", []);
8862
-
8863
8838
  _defineProperty$1(this, "currentLayout", void 0);
8864
8839
 
8865
8840
  _defineProperty$1(this, "allUserMapPromise", Promise.resolve(new Map()));
8866
8841
 
8867
8842
  _defineProperty$1(this, "allMagicBrickConfigMapPromise", Promise.resolve(new Map()));
8868
8843
 
8844
+ _defineProperty$1(this, "originFaviconHref", void 0);
8845
+
8869
8846
  _defineProperty$1(this, "allRelatedAppsPromise", Promise.resolve([]));
8870
8847
 
8871
8848
  _defineProperty$1(this, "allMicroAppApiOrchestrationPromise", Promise.resolve(new Map()));
@@ -8956,7 +8933,7 @@ class Kernel {
8956
8933
  var _this2 = this;
8957
8934
 
8958
8935
  return _asyncToGenerator$3(function* () {
8959
- var _this2$bootstrapData$, _this2$bootstrapData$2;
8936
+ var _this2$bootstrapData$, _this2$bootstrapData$2, _document$querySelect;
8960
8937
 
8961
8938
  listenDevtoolsEagerly();
8962
8939
  _this2.mountPoints = mountPoints;
@@ -8972,16 +8949,12 @@ class Kernel {
8972
8949
  }
8973
8950
 
8974
8951
  generateColorTheme((_this2$bootstrapData$ = _this2.bootstrapData.settings) === null || _this2$bootstrapData$ === void 0 ? void 0 : (_this2$bootstrapData$2 = _this2$bootstrapData$.misc) === null || _this2$bootstrapData$2 === void 0 ? void 0 : _this2$bootstrapData$2.theme);
8975
-
8976
- if (isLoggedIn()) {
8977
- _this2.loadSharedData();
8978
- }
8979
-
8980
8952
  _this2.menuBar = new MenuBar(_this2, "menuBar");
8981
8953
  _this2.appBar = new AppBar(_this2, "appBar");
8982
8954
  _this2.loadingBar = new BaseBar(_this2, "loadingBar");
8983
8955
  _this2.router = new Router(_this2);
8984
8956
  initAnalytics();
8957
+ _this2.originFaviconHref = (_document$querySelect = document.querySelector("link[rel='shortcut icon']")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.href;
8985
8958
  yield _this2.router.bootstrap();
8986
8959
 
8987
8960
  if (!window.STANDALONE_MICRO_APPS) {
@@ -9500,12 +9473,6 @@ class Kernel {
9500
9473
  document.body.classList.toggle("show-legacy-iframe", visible);
9501
9474
  }
9502
9475
 
9503
- loadSharedData() {
9504
- if (!window.STANDALONE_MICRO_APPS) {
9505
- this.loadRelatedAppsAsync();
9506
- }
9507
- }
9508
-
9509
9476
  loadUsersAsync() {
9510
9477
  if (!this.loadUsersStarted) {
9511
9478
  this.loadUsersStarted = true;
@@ -9626,95 +9593,10 @@ class Kernel {
9626
9593
  })();
9627
9594
  }
9628
9595
 
9629
- loadRelatedAppsAsync() {
9630
- this.allRelatedAppsPromise = this.loadRelatedApps();
9631
- }
9632
-
9633
- loadRelatedApps() {
9634
- return _asyncToGenerator$3(function* () {
9635
- var relatedApps = [];
9636
-
9637
- try {
9638
- relatedApps = (yield ObjectMicroAppApi_getObjectMicroAppList()).list;
9639
- } catch (error) {
9640
- // eslint-disable-next-line no-console
9641
- console.warn("Load related apps error:", error);
9642
- }
9643
-
9644
- return relatedApps;
9645
- })();
9646
- }
9647
-
9648
- getRelatedAppsAsync(appId) {
9649
- var _this11 = this;
9650
-
9651
- return _asyncToGenerator$3(function* () {
9652
- if (!appId) {
9653
- return [];
9654
- }
9655
-
9656
- var allRelatedApps = yield _this11.allRelatedAppsPromise;
9657
- var thisApp = allRelatedApps.find(item => item.microAppId === appId);
9658
-
9659
- if (!thisApp) {
9660
- return [];
9661
- }
9662
-
9663
- return sortBy(allRelatedApps.filter(item => item.objectId === thisApp.objectId), ["order"]);
9664
- })();
9665
- }
9666
-
9667
- updateWorkspaceStack() {
9668
- var _this12 = this;
9669
-
9670
- return _asyncToGenerator$3(function* () {
9671
- if (_this12.currentApp && _this12.currentApp.id) {
9672
- var workspace = {
9673
- appId: _this12.currentApp.id,
9674
- appName: _this12.currentApp.name,
9675
- appLocaleName: _this12.currentApp.localeName,
9676
- url: _this12.currentUrl
9677
- };
9678
-
9679
- if (_this12.workspaceStack.length > 0) {
9680
- var previousWorkspace = _this12.workspaceStack[_this12.workspaceStack.length - 1];
9681
-
9682
- var _relatedApps = yield _this12.getRelatedAppsAsync(previousWorkspace.appId);
9683
-
9684
- if (_relatedApps.some(item => item.microAppId === _this12.currentApp.id)) {
9685
- Object.assign(previousWorkspace, workspace);
9686
- return;
9687
- }
9688
- }
9689
-
9690
- var relatedApps = yield _this12.getRelatedAppsAsync(_this12.currentApp.id);
9691
-
9692
- if (relatedApps.length > 0) {
9693
- _this12.workspaceStack.push(workspace);
9694
-
9695
- return;
9696
- }
9697
- }
9698
-
9699
- _this12.workspaceStack = [];
9700
- })();
9701
- }
9702
-
9703
- getPreviousWorkspace() {
9704
- if (this.workspaceStack.length > 1) {
9705
- return this.workspaceStack[this.workspaceStack.length - 2];
9706
- }
9707
- }
9708
-
9709
- popWorkspaceStack() {
9710
- this.workspaceStack.pop();
9711
- }
9712
-
9713
9596
  getRecentApps() {
9714
9597
  return {
9715
9598
  previousApp: this.previousApp,
9716
- currentApp: this.currentApp,
9717
- previousWorkspace: this.getPreviousWorkspace()
9599
+ currentApp: this.currentApp
9718
9600
  };
9719
9601
  }
9720
9602
 
@@ -9742,23 +9624,27 @@ class Kernel {
9742
9624
  });
9743
9625
  }
9744
9626
 
9627
+ getOriginFaviconHref() {
9628
+ return this.originFaviconHref;
9629
+ }
9630
+
9745
9631
  getProviderBrick(provider) {
9746
- var _this13 = this;
9632
+ var _this11 = this;
9747
9633
 
9748
9634
  return _asyncToGenerator$3(function* () {
9749
9635
  if (isCustomApiProvider(provider)) {
9750
9636
  provider = CUSTOM_API_PROVIDER;
9751
9637
  }
9752
9638
 
9753
- if (_this13.providerRepository.has(provider)) {
9754
- return _this13.providerRepository.get(provider);
9639
+ if (_this11.providerRepository.has(provider)) {
9640
+ return _this11.providerRepository.get(provider);
9755
9641
  }
9756
9642
 
9757
9643
  if (provider === CUSTOM_API_PROVIDER && !customElements.get(provider)) {
9758
9644
  registerCustomApi();
9759
9645
  }
9760
9646
 
9761
- yield _this13.loadDynamicBricks([provider]);
9647
+ yield _this11.loadDynamicBricks([provider]);
9762
9648
 
9763
9649
  if (!customElements.get(provider)) {
9764
9650
  throw new Error("Provider not defined: \"".concat(provider, "\"."));
@@ -9766,7 +9652,7 @@ class Kernel {
9766
9652
 
9767
9653
  var brick = document.createElement(provider);
9768
9654
 
9769
- _this13.providerRepository.set(provider, brick);
9655
+ _this11.providerRepository.set(provider, brick);
9770
9656
 
9771
9657
  return brick;
9772
9658
  })();
@@ -11937,7 +11823,7 @@ class Router {
11937
11823
  var _this3 = this;
11938
11824
 
11939
11825
  return _asyncToGenerator$3(function* () {
11940
- var _apiAnalyzer$getInsta, _getLocalAppsTheme;
11826
+ var _apiAnalyzer$getInsta, _currentApp$config, _currentApp$config$_e, _getLocalAppsTheme;
11941
11827
 
11942
11828
  _this3.state = "initial";
11943
11829
  _this3.renderId = uniqueId("render-id-");
@@ -11997,6 +11883,17 @@ class Router {
11997
11883
  var legacy = currentApp ? currentApp.legacy : undefined;
11998
11884
  _this3.kernel.nextApp = currentApp;
11999
11885
  var layoutType = (currentApp === null || currentApp === void 0 ? void 0 : currentApp.layoutType) || "console";
11886
+ var faviconElement = document.querySelector("link[rel='shortcut icon']");
11887
+ var customFaviconHref = currentApp === null || currentApp === void 0 ? void 0 : (_currentApp$config = currentApp.config) === null || _currentApp$config === void 0 ? void 0 : (_currentApp$config$_e = _currentApp$config._easyops_app_favicon) === null || _currentApp$config$_e === void 0 ? void 0 : _currentApp$config$_e.default;
11888
+
11889
+ if (faviconElement) {
11890
+ if (customFaviconHref) {
11891
+ faviconElement.href = /^(?:https?|data):|^\//.test(customFaviconHref) ? customFaviconHref : imagesFactory(currentApp.id, currentApp.isBuildPush).get(customFaviconHref);
11892
+ } else {
11893
+ faviconElement.href = _this3.kernel.getOriginFaviconHref();
11894
+ }
11895
+ }
11896
+
12000
11897
  setTheme(((_getLocalAppsTheme = getLocalAppsTheme()) === null || _getLocalAppsTheme === void 0 ? void 0 : _getLocalAppsTheme[currentApp === null || currentApp === void 0 ? void 0 : currentApp.id]) || (currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) || "light");
12001
11898
  setMode("default");
12002
11899
  devtoolsHookEmit("rendering");
@@ -12101,9 +11998,8 @@ class Router {
12101
11998
  _this3.kernel.previousApp = previousApp;
12102
11999
  }
12103
12000
 
12104
- _this3.kernel.currentUrl = createPath(location);
12105
12001
  _this3.kernel.currentRoute = route;
12106
- yield Promise.all([...(window.STANDALONE_MICRO_APPS ? [] : [_this3.kernel.updateWorkspaceStack()]), _this3.kernel.layoutBootstrap(layoutType)]);
12002
+ yield _this3.kernel.layoutBootstrap(layoutType);
12107
12003
  _this3.state = "ready-to-mount"; // Unmount main tree to avoid app change fired before new routes mounted.
12108
12004
 
12109
12005
  unmountTree(mountPoints.main);