@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.
@@ -1175,9 +1175,11 @@
1175
1175
  }();
1176
1176
 
1177
1177
  var auth = {};
1178
+ var pathBlackListSet = new Set();
1178
1179
 
1179
1180
  /** @internal */
1180
1181
  function authenticate(newAuth) {
1182
+ var _newAuth$license;
1181
1183
  Object.assign(auth, {
1182
1184
  org: newAuth.org,
1183
1185
  username: newAuth.username,
@@ -1190,6 +1192,7 @@
1190
1192
  accessToken: newAuth.accessToken,
1191
1193
  userShowValue: newAuth.userShowValue
1192
1194
  });
1195
+ pathBlackListSet = new Set((_newAuth$license = newAuth.license) === null || _newAuth$license === void 0 ? void 0 : _newAuth$license.blackList);
1193
1196
 
1194
1197
  // re-init analytics to set user_id
1195
1198
  if (easyopsAnalytics.userAnalytics.initialized) {
@@ -1226,14 +1229,20 @@
1226
1229
  return auth.username !== undefined;
1227
1230
  }
1228
1231
 
1232
+ /**
1233
+ * 增加路径黑名单
1234
+ */
1235
+ function addPathToBlackList(path) {
1236
+ pathBlackListSet.add(path);
1237
+ }
1238
+
1229
1239
  /**
1230
1240
  * 判断一个内部 URL 路径是否被屏蔽。
1231
1241
  */
1232
1242
  function isBlockedPath(pathname) {
1233
- var _auth$license, _auth$license$blackLi;
1234
- 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 => brickUtils.matchPath(pathname, {
1243
+ return [...pathBlackListSet].some(path => brickUtils.matchPath(pathname, {
1235
1244
  path
1236
- })));
1245
+ }));
1237
1246
  }
1238
1247
 
1239
1248
  /**
@@ -7382,12 +7391,13 @@
7382
7391
  * @endpoint GET /api/v1/micro_app_standalone/runtime/:appId
7383
7392
  */
7384
7393
  var RuntimeApi_runtimeMicroAppStandalone = /*#__PURE__*/function () {
7385
- var _ref = _asyncToGenerator__default["default"](function* (appId, options) {
7386
- return (/**! @contract easyops.api.micro_app_standalone.runtime.RuntimeMicroAppStandalone@1.0.1 */
7387
- (yield brickHttp.http.get("api/gateway/micro_app_standalone.runtime.RuntimeMicroAppStandalone/api/v1/micro_app_standalone/runtime/".concat(appId), options)).data
7394
+ var _ref = _asyncToGenerator__default["default"](function* (appId, params, options) {
7395
+ return (/**! @contract easyops.api.micro_app_standalone.runtime.RuntimeMicroAppStandalone@1.0.1 */(yield brickHttp.http.get("api/gateway/logic.micro_app_standalone_service/api/v1/micro_app_standalone/runtime/".concat(appId), _objectSpread__default["default"](_objectSpread__default["default"]({}, options), {}, {
7396
+ params
7397
+ }))).data
7388
7398
  );
7389
7399
  });
7390
- return function RuntimeApi_runtimeMicroAppStandalone(_x, _x2) {
7400
+ return function RuntimeApi_runtimeMicroAppStandalone(_x, _x2, _x3) {
7391
7401
  return _ref.apply(this, arguments);
7392
7402
  };
7393
7403
  }();
@@ -7398,8 +7408,7 @@
7398
7408
  */
7399
7409
  var RuntimeApi_searchMicroAppStandalone = /*#__PURE__*/function () {
7400
7410
  var _ref = _asyncToGenerator__default["default"](function* (data, options) {
7401
- return (/**! @contract easyops.api.micro_app_standalone.runtime.SearchMicroAppStandalone@1.0.1 */
7402
- (yield brickHttp.http.post("api/gateway/micro_app_standalone.runtime.SearchMicroAppStandalone/api/v1/micro_app_standalone/search", data, options)).data
7411
+ return (/**! @contract easyops.api.micro_app_standalone.runtime.SearchMicroAppStandalone@1.0.1 */(yield brickHttp.http.post("api/gateway/logic.micro_app_standalone_service/api/v1/micro_app_standalone/search", data, options)).data
7403
7412
  );
7404
7413
  });
7405
7414
  return function RuntimeApi_searchMicroAppStandalone(_x, _x2) {
@@ -7523,9 +7532,7 @@
7523
7532
  return appRuntimeDataMap.get(appId);
7524
7533
  }
7525
7534
  var promise = RuntimeApi_runtimeMicroAppStandalone(appId, {
7526
- params: {
7527
- version
7528
- }
7535
+ version
7529
7536
  }).catch(function (error) {
7530
7537
  // make it not crash when the backend service is not updated.
7531
7538
  // eslint-disable-next-line no-console
@@ -9376,7 +9383,8 @@
9376
9383
  initializeAppConfig(storyboard.app);
9377
9384
  // get inject menus (Actually, appRuntimeData contains both main and inject menus)
9378
9385
  storyboard.meta = _objectSpread__default["default"](_objectSpread__default["default"]({}, storyboard.meta), {}, {
9379
- injectMenus: appRuntimeData.injectMenus
9386
+ injectMenus: appRuntimeData.injectMenus,
9387
+ blackList: appRuntimeData.blackList
9380
9388
  });
9381
9389
  }
9382
9390
  }
@@ -12296,51 +12304,72 @@
12296
12304
  /** Pending task for loading bricks */
12297
12305
  var pendingTask;
12298
12306
  if (storyboard) {
12299
- var _storyboard$meta, _storyboard$meta2, _storyboard$meta3;
12307
+ var _storyboard$meta, _storyboard$meta$blac, _storyboard$meta$blac2;
12300
12308
  yield _this3.kernel.fulfilStoryboard(storyboard);
12301
- setAppLocales(storyboard.app);
12302
12309
  _this3.kernel.nextApp = storyboard.app;
12303
- setWatermark();
12304
- brickUtils.removeDeadConditions(storyboard, {
12305
- constantFeatureFlags: true,
12306
- featureFlags: _this3.kernel.getFeatureFlags()
12310
+ (_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 => {
12311
+ var path = item && (item.to || item.url);
12312
+ if (!path || typeof path !== "string") return;
12313
+ path = path.split("?")[0].replace(/\${\s*(?:(?:PATH|CTX)\.)?(\w+)\s*}/g, ":$1");
12314
+ if (item.to) {
12315
+ try {
12316
+ path = computeRealValue(path, _this3.locationContext.getCurrentContext());
12317
+ } catch (e) /* istanbul ignore next */{
12318
+ // eslint-disable-next-line no-console
12319
+ console.error(e);
12320
+ }
12321
+ } else {
12322
+ path = path.replace(/^\/next\//, "/");
12323
+ }
12324
+ path && addPathToBlackList(path);
12307
12325
  });
12326
+ if (isBlockedPath(location.pathname)) {
12327
+ blocked = true;
12328
+ } else {
12329
+ var _storyboard$meta2, _storyboard$meta3, _storyboard$meta4;
12330
+ setAppLocales(storyboard.app);
12331
+ setWatermark();
12332
+ brickUtils.removeDeadConditions(storyboard, {
12333
+ constantFeatureFlags: true,
12334
+ featureFlags: _this3.kernel.getFeatureFlags()
12335
+ });
12308
12336
 
12309
- // 将动态解析后的模板还原,以便重新动态解析。
12310
- brickUtils.restoreDynamicTemplates(storyboard);
12311
- var parallelRequests = [];
12337
+ // 将动态解析后的模板还原,以便重新动态解析。
12338
+ brickUtils.restoreDynamicTemplates(storyboard);
12339
+ var parallelRequests = [];
12312
12340
 
12313
- // 预加载权限信息
12314
- if (isLoggedIn() && !getAuth().isAdmin) {
12315
- parallelRequests.push(preCheckPermissions(storyboard));
12316
- }
12341
+ // 预加载权限信息
12342
+ if (isLoggedIn() && !getAuth().isAdmin) {
12343
+ parallelRequests.push(preCheckPermissions(storyboard));
12344
+ }
12317
12345
 
12318
- // Standalone App 需要额外读取 Installed App 信息
12319
- if (window.STANDALONE_MICRO_APPS && !window.NO_AUTH_GUARD) {
12320
- // TODO: get standalone apps when NO_AUTH_GUARD, maybe from conf.yaml
12321
- parallelRequests.push(preFetchStandaloneInstalledApps(storyboard).then(() => {
12322
- _this3.kernel.bootstrapData.offSiteStandaloneApps = getStandaloneInstalledApps();
12323
- }));
12324
- }
12346
+ // Standalone App 需要额外读取 Installed App 信息
12347
+ if (window.STANDALONE_MICRO_APPS && !window.NO_AUTH_GUARD) {
12348
+ // TODO: get standalone apps when NO_AUTH_GUARD, maybe from conf.yaml
12349
+ parallelRequests.push(preFetchStandaloneInstalledApps(storyboard).then(() => {
12350
+ _this3.kernel.bootstrapData.offSiteStandaloneApps = getStandaloneInstalledApps();
12351
+ }));
12352
+ }
12325
12353
 
12326
- // `loadDepsOfStoryboard()` may requires these data.
12327
- yield Promise.all(parallelRequests);
12354
+ // `loadDepsOfStoryboard()` may requires these data.
12355
+ yield Promise.all(parallelRequests);
12328
12356
 
12329
- // 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
12330
- var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
12331
- ({
12332
- pendingTask
12333
- } = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
12357
+ // 如果找到匹配的 storyboard,那么根据路由匹配得到的 sub-storyboard 加载它的依赖库。
12358
+ var subStoryboard = yield _this3.locationContext.getSubStoryboardByRoute(storyboard);
12359
+ ({
12360
+ pendingTask
12361
+ } = yield _this3.kernel.loadDepsOfStoryboard(subStoryboard));
12334
12362
 
12335
- // 注册 Storyboard 中定义的自定义模板和函数。
12336
- _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
12337
- registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions, storyboard.app);
12338
- registerMock((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.mocks);
12339
- registerFormRenderer();
12340
- collectContract((_storyboard$meta3 = storyboard.meta) === null || _storyboard$meta3 === void 0 ? void 0 : _storyboard$meta3.contracts);
12363
+ // 注册 Storyboard 中定义的自定义模板和函数。
12364
+ _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
12365
+ registerStoryboardFunctions((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.functions, storyboard.app);
12366
+ registerMock((_storyboard$meta3 = storyboard.meta) === null || _storyboard$meta3 === void 0 ? void 0 : _storyboard$meta3.mocks);
12367
+ registerFormRenderer();
12368
+ collectContract((_storyboard$meta4 = storyboard.meta) === null || _storyboard$meta4 === void 0 ? void 0 : _storyboard$meta4.contracts);
12341
12369
 
12342
- // `app` maybe fulfilled
12343
- currentApp = storyboard.app;
12370
+ // `app` maybe fulfilled
12371
+ currentApp = storyboard.app;
12372
+ }
12344
12373
  }
12345
12374
  var mountPoints = _this3.kernel.mountPoints;
12346
12375
  var legacy = currentApp ? currentApp.legacy : undefined;
@@ -12376,7 +12405,7 @@
12376
12405
  from: location
12377
12406
  });
12378
12407
  };
12379
- if (storyboard) {
12408
+ if (storyboard && !blocked) {
12380
12409
  var _currentApp$breadcrum, _currentApp$breadcrum2, _currentApp$breadcrum3, _currentApp$breadcrum4;
12381
12410
  var {
12382
12411
  bricks,
@@ -17103,6 +17132,7 @@
17103
17132
  exports.WebsocketMessageRequest = WebsocketMessageRequest;
17104
17133
  exports.WebsocketMessageResponse = WebsocketMessageResponse;
17105
17134
  exports.abortController = abortController;
17135
+ exports.addPathToBlackList = addPathToBlackList;
17106
17136
  exports.applyTheme = applyTheme;
17107
17137
  exports.authenticate = authenticate;
17108
17138
  exports.batchSetAppsLocalTheme = batchSetAppsLocalTheme;