@next-core/brick-kit 2.208.5 → 2.208.8

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.
@@ -1238,22 +1238,72 @@
1238
1238
 
1239
1239
  /**
1240
1240
  * 判断一个内部 URL 路径是否被屏蔽。
1241
+ *
1242
+ * @param pathnameWithQuery - 路径(可包含查询字符串)
1243
+ * @returns 是否被屏蔽
1241
1244
  */
1242
- function isBlockedPath(pathname) {
1243
- return [...pathBlackListSet].some(path => brickUtils.matchPath(pathname, {
1244
- path
1245
- }));
1245
+ function isBlockedPath(pathnameWithQuery) {
1246
+ return [...pathBlackListSet].some(pattern => {
1247
+ // 分离 pattern 的路径和查询字符串
1248
+ var [patternPath, patternQuery] = pattern.split("?");
1249
+
1250
+ // 分离待检查路径的路径和查询字符串
1251
+ var [pathname, pathQuery] = pathnameWithQuery.split("?");
1252
+
1253
+ // 首先匹配路径部分
1254
+ var pathMatched = brickUtils.matchPath(pathname, {
1255
+ path: patternPath
1256
+ });
1257
+ if (!pathMatched) {
1258
+ return false;
1259
+ }
1260
+
1261
+ // 如果 pattern 不包含查询字符串,只要路径匹配就返回 true
1262
+ if (!patternQuery) {
1263
+ return true;
1264
+ }
1265
+
1266
+ // 如果 pattern 包含查询字符串,但待检查路径没有,返回 false
1267
+ if (!pathQuery) {
1268
+ return false;
1269
+ }
1270
+
1271
+ // 精确匹配查询字符串(所有 pattern 中的参数必须存在且值相同)
1272
+ var patternParams = new URLSearchParams(patternQuery);
1273
+ var pathParams = new URLSearchParams(pathQuery);
1274
+ for (var [key, value] of patternParams.entries()) {
1275
+ if (pathParams.get(key) !== value) {
1276
+ return false;
1277
+ }
1278
+ }
1279
+ return true;
1280
+ });
1281
+ }
1282
+
1283
+ /**
1284
+ * 根据特性开关决定是否拼接查询字符串
1285
+ * @param pathname - 路径名
1286
+ * @param search - 查询字符串(可选)
1287
+ * @returns 拼接后的路径
1288
+ */
1289
+ function getPathnameWithQuery(pathname, search) {
1290
+ var _getRuntime;
1291
+ var flags = (_getRuntime = getRuntime()) === null || _getRuntime === void 0 ? void 0 : _getRuntime.getFeatureFlags();
1292
+ var blackListPreserveQueryFlag = flags === null || flags === void 0 ? void 0 : flags["blacklist-preserve-query-string"];
1293
+ return blackListPreserveQueryFlag && search ? pathname + search : pathname;
1246
1294
  }
1247
1295
 
1248
1296
  /**
1249
1297
  * 判断一个内部 URL 是否被屏蔽。
1250
1298
  */
1251
1299
  function isBlockedUrl(url) {
1252
- var pathname = (typeof url === "string" ? history$1.createLocation(url) : url).pathname;
1300
+ var location = typeof url === "string" ? history$1.createLocation(url) : url;
1301
+ var pathname = location.pathname;
1253
1302
  if (typeof pathname !== "string") {
1254
1303
  return false;
1255
1304
  }
1256
- return isBlockedPath(pathname);
1305
+ var pathnameWithQuery = getPathnameWithQuery(pathname, location.search);
1306
+ return isBlockedPath(pathnameWithQuery);
1257
1307
  }
1258
1308
 
1259
1309
  /**
@@ -1267,7 +1317,9 @@
1267
1317
  return false;
1268
1318
  }
1269
1319
  // 转换为内部路径
1270
- return isBlockedPath(url.pathname.substring(basePath.length - 1));
1320
+ var internalPath = url.pathname.substring(basePath.length - 1);
1321
+ var pathnameWithQuery = getPathnameWithQuery(internalPath, url.search);
1322
+ return isBlockedPath(pathnameWithQuery);
1271
1323
  }
1272
1324
 
1273
1325
  var permissionMap = new Map();
@@ -9302,7 +9354,7 @@
9302
9354
  var _eager$v3Bricks;
9303
9355
  if ((_eager$v3Bricks = eager.v3Bricks) !== null && _eager$v3Bricks !== void 0 && _eager$v3Bricks.length) {
9304
9356
  yield catchLoad(loader.loadBricksImperatively(V3WidgetMates, brickPackages), "brick", V3WidgetMates[0]);
9305
- yield loader.loadBricksImperatively(eager.v3Bricks, brickPackages);
9357
+ yield loader.loadBricksImperatively(eager.v3Bricks, brickPackages, loadLazyBricks);
9306
9358
  }
9307
9359
  })(), _asyncToGenerator__default["default"](function* () {
9308
9360
  var _eager$v3Processors;
@@ -9315,7 +9367,7 @@
9315
9367
  // 挂载构件可能包括:Provider 构件实时挂载、路由准备完成后的统一挂载等。
9316
9368
  return {
9317
9369
  pendingTask: loadScriptOfDll(dll).then(() => loadScriptOfBricksOrTemplates(deps)).then( /*#__PURE__*/_asyncToGenerator__default["default"](function* () {
9318
- yield Promise.all([loadLazyBricks(bricks), (v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loader.loadBricksImperatively(v3Bricks, brickPackages), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loader.loadProcessorsImperatively(v3Processors, brickPackages)]);
9370
+ yield Promise.all([loadLazyBricks(bricks), (v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loader.loadBricksImperatively(v3Bricks, brickPackages, loadLazyBricks), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loader.loadProcessorsImperatively(v3Processors, brickPackages)]);
9319
9371
  }))
9320
9372
  };
9321
9373
  }
@@ -9345,7 +9397,7 @@
9345
9397
  if (v3Bricks !== null && v3Bricks !== void 0 && v3Bricks.some(brick => brick.includes(".tpl-"))) {
9346
9398
  yield catchLoad(loader.loadBricksImperatively(V3WidgetMates, brickPackages), "brick", V3WidgetMates[0]);
9347
9399
  }
9348
- yield Promise.all([(v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loader.loadBricksImperatively(v3Bricks, brickPackages), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loader.loadProcessorsImperatively(v3Processors, brickPackages)]);
9400
+ yield Promise.all([(v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loader.loadBricksImperatively(v3Bricks, brickPackages, loadLazyBricks), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loader.loadProcessorsImperatively(v3Processors, brickPackages)]);
9349
9401
  });
9350
9402
  return function loadV3Bricks() {
9351
9403
  return _ref6.apply(this, arguments);
@@ -12441,10 +12493,14 @@
12441
12493
  render(location) {
12442
12494
  var _this3 = this;
12443
12495
  return _asyncToGenerator__default["default"](function* () {
12444
- var _apiAnalyzer$getInsta, _storyboard$app, _this3$kernel$previou, _currentApp, _currentApp2, _currentApp2$config, _currentApp2$config$_, _this3$kernel$bootstr, _this3$kernel$bootstr2, _getLocalAppsTheme, _currentApp3, _currentApp4, _storyboard$app$homep, _storyboard$app2;
12496
+ var _getRuntime$getFeatur, _apiAnalyzer$getInsta, _storyboard$app, _this3$kernel$previou, _currentApp, _currentApp2, _currentApp2$config, _currentApp2$config$_, _this3$kernel$bootstr, _this3$kernel$bootstr2, _getLocalAppsTheme, _currentApp3, _currentApp4, _storyboard$app$homep, _storyboard$app2;
12445
12497
  _this3.state = "initial";
12446
12498
  var renderId = _this3.renderId = _.uniqueId("render-id-");
12447
- var blocked = isBlockedPath(location.pathname);
12499
+ var blackListPreserveQueryFlag = (_getRuntime$getFeatur = getRuntime().getFeatureFlags()) === null || _getRuntime$getFeatur === void 0 ? void 0 : _getRuntime$getFeatur["blacklist-preserve-query-string"];
12500
+
12501
+ // 第一次检查:全局黑名单
12502
+ var pathToCheck = "".concat(location.pathname).concat(blackListPreserveQueryFlag ? location.search : "");
12503
+ var blocked = isBlockedPath(pathToCheck);
12448
12504
  resetAllInjected();
12449
12505
  clearPollTimeout();
12450
12506
  clearCollectWidgetContract();
@@ -12492,7 +12548,12 @@
12492
12548
  (_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 => {
12493
12549
  var path = item && (item.to || item.url);
12494
12550
  if (!path || typeof path !== "string") return;
12495
- path = path.split("?")[0].replace(/\${\s*(?:(?:PATH|CTX)\.)?(\w+)\s*}/g, ":$1");
12551
+
12552
+ // 保留查询字符串(如果特性开关启用)
12553
+ var pathParts = path.split("?");
12554
+ var pathWithoutQuery = pathParts[0];
12555
+ var queryString = blackListPreserveQueryFlag && pathParts[1] ? "?".concat(pathParts[1]) : "";
12556
+ path = pathWithoutQuery.replace(/\${\s*(?:(?:PATH|CTX)\.)?(\w+)\s*}/g, ":$1") + queryString;
12496
12557
  if (item.to) {
12497
12558
  try {
12498
12559
  path = computeRealValue(path, _this3.locationContext.getCurrentContext());
@@ -12505,7 +12566,7 @@
12505
12566
  }
12506
12567
  path && path.startsWith("/") && addPathToBlackList(path);
12507
12568
  });
12508
- if (isBlockedPath(location.pathname)) {
12569
+ if (isBlockedPath(pathToCheck)) {
12509
12570
  blocked = true;
12510
12571
  } else {
12511
12572
  var _storyboard$meta2, _storyboard$meta3, _storyboard$meta4;