@next-core/brick-kit 2.208.4 → 2.208.6
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.bundle.js +73 -12
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +73 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/types/auth.d.ts +4 -1
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/package.json +2 -2
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(
|
|
1245
|
-
return [...pathBlackListSet].some(
|
|
1246
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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();
|
|
@@ -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
|
|
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
|
-
|
|
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());
|
|
@@ -12505,9 +12566,9 @@ class Router {
|
|
|
12505
12566
|
} else {
|
|
12506
12567
|
path = path.replace(/^\/next\//, "/");
|
|
12507
12568
|
}
|
|
12508
|
-
path && addPathToBlackList(path);
|
|
12569
|
+
path && path.startsWith("/") && addPathToBlackList(path);
|
|
12509
12570
|
});
|
|
12510
|
-
if (isBlockedPath(
|
|
12571
|
+
if (isBlockedPath(pathToCheck)) {
|
|
12511
12572
|
blocked = true;
|
|
12512
12573
|
} else {
|
|
12513
12574
|
var _storyboard$meta2, _storyboard$meta3, _storyboard$meta4;
|