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