@next-core/brick-kit 2.205.0 → 2.206.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
@@ -1177,9 +1177,11 @@ var PermissionApi_validatePermissions = /*#__PURE__*/function () {
1177
1177
  }();
1178
1178
 
1179
1179
  var auth = {};
1180
+ var pathBlackListSet = new Set();
1180
1181
 
1181
1182
  /** @internal */
1182
1183
  function authenticate(newAuth) {
1184
+ var _newAuth$license;
1183
1185
  Object.assign(auth, {
1184
1186
  org: newAuth.org,
1185
1187
  username: newAuth.username,
@@ -1192,6 +1194,7 @@ function authenticate(newAuth) {
1192
1194
  accessToken: newAuth.accessToken,
1193
1195
  userShowValue: newAuth.userShowValue
1194
1196
  });
1197
+ pathBlackListSet = new Set((_newAuth$license = newAuth.license) === null || _newAuth$license === void 0 ? void 0 : _newAuth$license.blackList);
1195
1198
 
1196
1199
  // re-init analytics to set user_id
1197
1200
  if (userAnalytics.initialized) {
@@ -1228,14 +1231,20 @@ function isLoggedIn() {
1228
1231
  return auth.username !== undefined;
1229
1232
  }
1230
1233
 
1234
+ /**
1235
+ * 增加路径黑名单
1236
+ */
1237
+ function addPathToBlackList(path) {
1238
+ pathBlackListSet.add(path);
1239
+ }
1240
+
1231
1241
  /**
1232
1242
  * 判断一个内部 URL 路径是否被屏蔽。
1233
1243
  */
1234
1244
  function isBlockedPath(pathname) {
1235
- var _auth$license, _auth$license$blackLi;
1236
- return !!((_auth$license = auth.license) !== null && _auth$license !== void 0 && (_auth$license$blackLi = _auth$license.blackList) !== null && _auth$license$blackLi !== void 0 && _auth$license$blackLi.some(path => matchPath(pathname, {
1245
+ return [...pathBlackListSet].some(path => matchPath(pathname, {
1237
1246
  path
1238
- })));
1247
+ }));
1239
1248
  }
1240
1249
 
1241
1250
  /**
@@ -7384,12 +7393,13 @@ function initAnalytics() {
7384
7393
  * @endpoint GET /api/v1/micro_app_standalone/runtime/:appId
7385
7394
  */
7386
7395
  var RuntimeApi_runtimeMicroAppStandalone = /*#__PURE__*/function () {
7387
- var _ref = _asyncToGenerator$3(function* (appId, options) {
7388
- return (/**! @contract easyops.api.micro_app_standalone.runtime.RuntimeMicroAppStandalone@1.0.1 */
7389
- (yield http.get("api/gateway/micro_app_standalone.runtime.RuntimeMicroAppStandalone/api/v1/micro_app_standalone/runtime/".concat(appId), options)).data
7396
+ var _ref = _asyncToGenerator$3(function* (appId, params, options) {
7397
+ return (/**! @contract easyops.api.micro_app_standalone.runtime.RuntimeMicroAppStandalone@1.0.1 */(yield http.get("api/gateway/logic.micro_app_standalone_service/api/v1/micro_app_standalone/runtime/".concat(appId), _objectSpread(_objectSpread({}, options), {}, {
7398
+ params
7399
+ }))).data
7390
7400
  );
7391
7401
  });
7392
- return function RuntimeApi_runtimeMicroAppStandalone(_x, _x2) {
7402
+ return function RuntimeApi_runtimeMicroAppStandalone(_x, _x2, _x3) {
7393
7403
  return _ref.apply(this, arguments);
7394
7404
  };
7395
7405
  }();
@@ -7400,8 +7410,7 @@ var RuntimeApi_runtimeMicroAppStandalone = /*#__PURE__*/function () {
7400
7410
  */
7401
7411
  var RuntimeApi_searchMicroAppStandalone = /*#__PURE__*/function () {
7402
7412
  var _ref = _asyncToGenerator$3(function* (data, options) {
7403
- return (/**! @contract easyops.api.micro_app_standalone.runtime.SearchMicroAppStandalone@1.0.1 */
7404
- (yield http.post("api/gateway/micro_app_standalone.runtime.SearchMicroAppStandalone/api/v1/micro_app_standalone/search", data, options)).data
7413
+ return (/**! @contract easyops.api.micro_app_standalone.runtime.SearchMicroAppStandalone@1.0.1 */(yield http.post("api/gateway/logic.micro_app_standalone_service/api/v1/micro_app_standalone/search", data, options)).data
7405
7414
  );
7406
7415
  });
7407
7416
  return function RuntimeApi_searchMicroAppStandalone(_x, _x2) {
@@ -7525,9 +7534,7 @@ function _safeGetRuntimeMicroAppStandalone() {
7525
7534
  return appRuntimeDataMap.get(appId);
7526
7535
  }
7527
7536
  var promise = RuntimeApi_runtimeMicroAppStandalone(appId, {
7528
- params: {
7529
- version
7530
- }
7537
+ version
7531
7538
  }).catch(function (error) {
7532
7539
  // make it not crash when the backend service is not updated.
7533
7540
  // eslint-disable-next-line no-console
@@ -9378,7 +9385,8 @@ class Kernel {
9378
9385
  initializeAppConfig(storyboard.app);
9379
9386
  // get inject menus (Actually, appRuntimeData contains both main and inject menus)
9380
9387
  storyboard.meta = _objectSpread(_objectSpread({}, storyboard.meta), {}, {
9381
- injectMenus: appRuntimeData.injectMenus
9388
+ injectMenus: appRuntimeData.injectMenus,
9389
+ blackList: appRuntimeData.blackList
9382
9390
  });
9383
9391
  }
9384
9392
  }
@@ -12298,51 +12306,72 @@ class Router {
12298
12306
  /** Pending task for loading bricks */
12299
12307
  var pendingTask;
12300
12308
  if (storyboard) {
12301
- var _storyboard$meta, _storyboard$meta2, _storyboard$meta3;
12309
+ var _storyboard$meta, _storyboard$meta$blac, _storyboard$meta$blac2;
12302
12310
  yield _this3.kernel.fulfilStoryboard(storyboard);
12303
- setAppLocales(storyboard.app);
12304
12311
  _this3.kernel.nextApp = storyboard.app;
12305
- setWatermark();
12306
- removeDeadConditions(storyboard, {
12307
- constantFeatureFlags: true,
12308
- featureFlags: _this3.kernel.getFeatureFlags()
12312
+ (_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : (_storyboard$meta$blac = _storyboard$meta.blackList) === null || _storyboard$meta$blac === void 0 ? void 0 : (_storyboard$meta$blac2 = _storyboard$meta$blac.forEach) === null || _storyboard$meta$blac2 === void 0 ? void 0 : _storyboard$meta$blac2.call(_storyboard$meta$blac, item => {
12313
+ var path = item && (item.to || item.url);
12314
+ if (!path || typeof path !== "string") return;
12315
+ path = path.split("?")[0].replace(/\${\s*(?:(?:PATH|CTX)\.)?(\w+)\s*}/g, ":$1");
12316
+ if (item.to) {
12317
+ try {
12318
+ path = computeRealValue(path, _this3.locationContext.getCurrentContext());
12319
+ } catch (e) /* istanbul ignore next */{
12320
+ // eslint-disable-next-line no-console
12321
+ console.error(e);
12322
+ }
12323
+ } else {
12324
+ path = path.replace(/^\/next\//, "/");
12325
+ }
12326
+ path && addPathToBlackList(path);
12309
12327
  });
12328
+ if (isBlockedPath(location.pathname)) {
12329
+ blocked = true;
12330
+ } else {
12331
+ var _storyboard$meta2, _storyboard$meta3, _storyboard$meta4;
12332
+ setAppLocales(storyboard.app);
12333
+ setWatermark();
12334
+ removeDeadConditions(storyboard, {
12335
+ constantFeatureFlags: true,
12336
+ featureFlags: _this3.kernel.getFeatureFlags()
12337
+ });
12310
12338
 
12311
- // 将动态解析后的模板还原,以便重新动态解析。
12312
- restoreDynamicTemplates(storyboard);
12313
- var parallelRequests = [];
12339
+ // 将动态解析后的模板还原,以便重新动态解析。
12340
+ restoreDynamicTemplates(storyboard);
12341
+ var parallelRequests = [];
12314
12342
 
12315
- // 预加载权限信息
12316
- if (isLoggedIn() && !getAuth().isAdmin) {
12317
- parallelRequests.push(preCheckPermissions(storyboard));
12318
- }
12343
+ // 预加载权限信息
12344
+ if (isLoggedIn() && !getAuth().isAdmin) {
12345
+ parallelRequests.push(preCheckPermissions(storyboard));
12346
+ }
12319
12347
 
12320
- // Standalone App 需要额外读取 Installed App 信息
12321
- if (window.STANDALONE_MICRO_APPS && !window.NO_AUTH_GUARD) {
12322
- // TODO: get standalone apps when NO_AUTH_GUARD, maybe from conf.yaml
12323
- parallelRequests.push(preFetchStandaloneInstalledApps(storyboard).then(() => {
12324
- _this3.kernel.bootstrapData.offSiteStandaloneApps = getStandaloneInstalledApps();
12325
- }));
12326
- }
12348
+ // Standalone App 需要额外读取 Installed App 信息
12349
+ if (window.STANDALONE_MICRO_APPS && !window.NO_AUTH_GUARD) {
12350
+ // TODO: get standalone apps when NO_AUTH_GUARD, maybe from conf.yaml
12351
+ parallelRequests.push(preFetchStandaloneInstalledApps(storyboard).then(() => {
12352
+ _this3.kernel.bootstrapData.offSiteStandaloneApps = getStandaloneInstalledApps();
12353
+ }));
12354
+ }
12327
12355
 
12328
- // `loadDepsOfStoryboard()` may requires these data.
12329
- yield Promise.all(parallelRequests);
12356
+ // `loadDepsOfStoryboard()` may requires these data.
12357
+ yield Promise.all(parallelRequests);
12330
12358
 
12331
- // 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
12332
- var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
12333
- ({
12334
- pendingTask
12335
- } = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
12359
+ // 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
12360
+ var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
12361
+ ({
12362
+ pendingTask
12363
+ } = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
12336
12364
 
12337
- // 注册 Storyboard 中定义的自定义模板和函数。
12338
- _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
12339
- registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions, storyboard.app);
12340
- registerMock((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.mocks);
12341
- registerFormRenderer();
12342
- collectContract((_storyboard$meta3 = storyboard.meta) === null || _storyboard$meta3 === void 0 ? void 0 : _storyboard$meta3.contracts);
12365
+ // 注册 Storyboard 中定义的自定义模板和函数。
12366
+ _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
12367
+ registerStoryboardFunctions((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.functions, storyboard.app);
12368
+ registerMock((_storyboard$meta3 = storyboard.meta) === null || _storyboard$meta3 === void 0 ? void 0 : _storyboard$meta3.mocks);
12369
+ registerFormRenderer();
12370
+ collectContract((_storyboard$meta4 = storyboard.meta) === null || _storyboard$meta4 === void 0 ? void 0 : _storyboard$meta4.contracts);
12343
12371
 
12344
- // `app` maybe fulfilled
12345
- currentApp = storyboard.app;
12372
+ // `app` maybe fulfilled
12373
+ currentApp = storyboard.app;
12374
+ }
12346
12375
  }
12347
12376
  var mountPoints = _this3.kernel.mountPoints;
12348
12377
  var legacy = currentApp ? currentApp.legacy : undefined;
@@ -12378,7 +12407,7 @@ class Router {
12378
12407
  from: location
12379
12408
  });
12380
12409
  };
12381
- if (storyboard) {
12410
+ if (storyboard && !blocked) {
12382
12411
  var _currentApp$breadcrum, _currentApp$breadcrum2, _currentApp$breadcrum3, _currentApp$breadcrum4;
12383
12412
  var {
12384
12413
  bricks,
@@ -15494,5 +15523,5 @@ function instantiateModalStack() {
15494
15523
  };
15495
15524
  }
15496
15525
 
15497
- export { BrickAsComponent, BrickAsComponentFactory, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ForwardRefSingleBrickAsComponentFactory, ModalElement, SingleBrickAsComponent, SingleBrickAsComponentFactory, StoryboardFunctionRegistryFactory, UpdatingElement, WebsocketMessageRequest, WebsocketMessageResponse, abortController, applyTheme, authenticate, batchSetAppsLocalTheme, checkIf, checkIfByTransform, clearDebugContract, collectDebugContract, constructEventListener, createHistory, createRuntime, createWebSocket, developHelper, doTransform, event, getAuth, getCssPropertyValue, getCurrentTheme, getHistory, getMockInfo, getRealValue, getRuntime, getRuntimeMisc, getWebSocket, handleHttpError, httpErrorToString, i18nText, initI18n, instantiateModalStack, isBlockedHref, isBlockedPath, isBlockedUrl, isLoggedIn, logout, looseCheckIf$1 as looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, setAppLocales, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useProvider, useRecentApps };
15526
+ export { BrickAsComponent, BrickAsComponentFactory, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ForwardRefSingleBrickAsComponentFactory, ModalElement, SingleBrickAsComponent, SingleBrickAsComponentFactory, StoryboardFunctionRegistryFactory, UpdatingElement, WebsocketMessageRequest, WebsocketMessageResponse, abortController, addPathToBlackList, applyTheme, authenticate, batchSetAppsLocalTheme, checkIf, checkIfByTransform, clearDebugContract, collectDebugContract, constructEventListener, createHistory, createRuntime, createWebSocket, developHelper, doTransform, event, getAuth, getCssPropertyValue, getCurrentTheme, getHistory, getMockInfo, getRealValue, getRuntime, getRuntimeMisc, getWebSocket, handleHttpError, httpErrorToString, i18nText, initI18n, instantiateModalStack, isBlockedHref, isBlockedPath, isBlockedUrl, isLoggedIn, logout, looseCheckIf$1 as looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, setAppLocales, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useProvider, useRecentApps };
15498
15527
  //# sourceMappingURL=index.esm.js.map