@next-core/brick-kit 2.203.3 → 2.204.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.bundle.js +59 -10
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +59 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/types/auth.d.ts +13 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/i18n/constants.d.ts +1 -0
- package/dist/types/i18n/constants.d.ts.map +1 -1
- package/dist/types/i18n/locales/en.d.ts.map +1 -1
- package/dist/types/i18n/locales/zh.d.ts.map +1 -1
- package/dist/types/internal/menu.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { parsePath, createBrowserHistory, locationsAreEqual } from 'history';
|
|
1
|
+
import { createLocation, parsePath, createBrowserHistory, locationsAreEqual } from 'history';
|
|
2
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
4
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
|
|
6
6
|
import _, { escapeRegExp, set, get, difference, identity, uniqueId, isNil, isEmpty, merge, sortBy, cloneDeep, clamp, orderBy, pick, isObject as isObject$1, uniq, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
|
|
7
|
-
import { toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable as isEvaluable$1, isTrackAll, trackAll, trackContext, trackState, trackFormState, transformAndInject, transform, JsonStorage, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, scanPermissionActionsInAny, deepFreeze, scanProcessorsInAny, preevaluate, shouldAllowRecursiveEvaluations, inject,
|
|
7
|
+
import { toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable as isEvaluable$1, isTrackAll, trackAll, trackContext, trackState, trackFormState, transformAndInject, transform, JsonStorage, matchPath, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, scanPermissionActionsInAny, deepFreeze, scanProcessorsInAny, preevaluate, shouldAllowRecursiveEvaluations, inject, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, snippetEvaluate, scanCustomApisInStoryboard, prefetchScript, scanBricksInBrickConf, loadScript, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, clearExpressionASTCache, clearFunctionASTCache, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
8
8
|
import moment from 'moment';
|
|
9
9
|
import { pipes } from '@next-core/pipes';
|
|
10
10
|
import i18next, { getFixedT } from 'i18next';
|
|
@@ -177,6 +177,7 @@ var K;
|
|
|
177
177
|
K["PAGE_NOT_FOUND"] = "PAGE_NOT_FOUND";
|
|
178
178
|
K["APP_NOT_FOUND"] = "APP_NOT_FOUND";
|
|
179
179
|
K["LICENSE_EXPIRED"] = "LICENSE_EXPIRED";
|
|
180
|
+
K["LICENSE_BLOCKED"] = "LICENSE_BLOCKED";
|
|
180
181
|
K["NO_PERMISSION"] = "NO_PERMISSION";
|
|
181
182
|
K["OTHER_ERROR"] = "OTHER_ERROR";
|
|
182
183
|
K["GO_BACK_PREVIOUS_PAGE"] = "GO_BACK_PREVIOUS_PAGE";
|
|
@@ -942,6 +943,7 @@ var locale$7 = {
|
|
|
942
943
|
[K.PAGE_NOT_FOUND]: "Page not found, please check the URL",
|
|
943
944
|
[K.APP_NOT_FOUND]: "App not found, maybe the URL is wrong or you don't have permission to access",
|
|
944
945
|
[K.LICENSE_EXPIRED]: "The license authorization has expired, please contact the platform administrator",
|
|
946
|
+
[K.LICENSE_BLOCKED]: "The page is not authorized, please contact the platform administrator",
|
|
945
947
|
[K.NO_PERMISSION]: "Unauthorized access, unable to retrieve the required resources for this page",
|
|
946
948
|
[K.OTHER_ERROR]: "Oops! Something went wrong",
|
|
947
949
|
[K.GO_BACK_PREVIOUS_PAGE]: "Go back to previous page",
|
|
@@ -961,6 +963,7 @@ var locale$6 = {
|
|
|
961
963
|
[K.PAGE_NOT_FOUND]: "请求的页面未找到,请确认 URL 是否正确",
|
|
962
964
|
[K.APP_NOT_FOUND]: "请求的微应用无法找到, 可能是 URL 错误或者无权限访问",
|
|
963
965
|
[K.LICENSE_EXPIRED]: "License 授权失效,请联系平台管理员",
|
|
966
|
+
[K.LICENSE_BLOCKED]: "该页面未授权,请联系平台管理员",
|
|
964
967
|
[K.NO_PERMISSION]: "没有权限,无法获取页面所需要的资源",
|
|
965
968
|
[K.OTHER_ERROR]: "糟糕!页面出现了一些问题",
|
|
966
969
|
[K.GO_BACK_PREVIOUS_PAGE]: "回到上一页",
|
|
@@ -1207,12 +1210,9 @@ function getAuth() {
|
|
|
1207
1210
|
|
|
1208
1211
|
/** @internal */
|
|
1209
1212
|
function logout() {
|
|
1210
|
-
auth
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
auth.accessRule = undefined;
|
|
1214
|
-
auth.isAdmin = undefined;
|
|
1215
|
-
auth.csrfToken = undefined;
|
|
1213
|
+
for (var key of Object.keys(auth)) {
|
|
1214
|
+
auth[key] = undefined;
|
|
1215
|
+
}
|
|
1216
1216
|
resetPermissionPreChecks();
|
|
1217
1217
|
|
|
1218
1218
|
// re-init analytics to clear user_id
|
|
@@ -1228,6 +1228,41 @@ function isLoggedIn() {
|
|
|
1228
1228
|
return auth.username !== undefined;
|
|
1229
1229
|
}
|
|
1230
1230
|
|
|
1231
|
+
/**
|
|
1232
|
+
* 判断一个内部 URL 路径是否被屏蔽。
|
|
1233
|
+
*/
|
|
1234
|
+
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, {
|
|
1237
|
+
path
|
|
1238
|
+
})));
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* 判断一个内部 URL 是否被屏蔽。
|
|
1243
|
+
*/
|
|
1244
|
+
function isBlockedUrl(url) {
|
|
1245
|
+
var pathname = (typeof url === "string" ? createLocation(url) : url).pathname;
|
|
1246
|
+
if (typeof pathname !== "string") {
|
|
1247
|
+
return false;
|
|
1248
|
+
}
|
|
1249
|
+
return isBlockedPath(pathname);
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* 判断一个 href 是否被屏蔽。
|
|
1254
|
+
*/
|
|
1255
|
+
function isBlockedHref(href) {
|
|
1256
|
+
var basePath = getBasePath();
|
|
1257
|
+
var url = new URL(href, "".concat(location.origin).concat(basePath));
|
|
1258
|
+
// 忽略外链地址
|
|
1259
|
+
if (url.origin !== location.origin || !url.pathname.startsWith(basePath)) {
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
// 转换为内部路径
|
|
1263
|
+
return isBlockedPath(url.pathname.substring(basePath.length - 1));
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1231
1266
|
var permissionMap = new Map();
|
|
1232
1267
|
function preCheckPermissions(_x) {
|
|
1233
1268
|
return _preCheckPermissions.apply(this, arguments);
|
|
@@ -2611,8 +2646,11 @@ function walkMenuItems(menuItems) {
|
|
|
2611
2646
|
icon: item.icon,
|
|
2612
2647
|
items: children,
|
|
2613
2648
|
defaultExpanded: item.defaultExpanded
|
|
2614
|
-
} : item;
|
|
2615
|
-
});
|
|
2649
|
+
} : isMenuItemBlocked(item) ? null : item;
|
|
2650
|
+
}).filter(Boolean);
|
|
2651
|
+
}
|
|
2652
|
+
function isMenuItemBlocked(item) {
|
|
2653
|
+
return item.href ? isBlockedHref(item.href) : item.to ? isBlockedUrl(item.to) : false;
|
|
2616
2654
|
}
|
|
2617
2655
|
function processMenu(_x15, _x16, _x17, _x18, _x19) {
|
|
2618
2656
|
return _processMenu.apply(this, arguments);
|
|
@@ -12218,6 +12256,7 @@ class Router {
|
|
|
12218
12256
|
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;
|
|
12219
12257
|
_this3.state = "initial";
|
|
12220
12258
|
var renderId = _this3.renderId = uniqueId("render-id-");
|
|
12259
|
+
var blocked = isBlockedPath(location.pathname);
|
|
12221
12260
|
resetAllInjected();
|
|
12222
12261
|
clearPollTimeout();
|
|
12223
12262
|
clearCollectWidgetContract();
|
|
@@ -12238,7 +12277,7 @@ class Router {
|
|
|
12238
12277
|
if (window.DEVELOPER_PREVIEW) {
|
|
12239
12278
|
return;
|
|
12240
12279
|
}
|
|
12241
|
-
var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
|
|
12280
|
+
var storyboard = blocked ? undefined : locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
|
|
12242
12281
|
var currentAppId = storyboard === null || storyboard === void 0 ? void 0 : (_storyboard$app = storyboard.app) === null || _storyboard$app === void 0 ? void 0 : _storyboard$app.id;
|
|
12243
12282
|
// dynamically change the value of the APP variable, if it's union app
|
|
12244
12283
|
if (window.BOOTSTRAP_UNION_FILE && currentAppId && currentAppId !== ((_this3$kernel$previou = _this3.kernel.previousApp) === null || _this3$kernel$previou === void 0 ? void 0 : _this3$kernel$previou.id)) {
|
|
@@ -12654,6 +12693,13 @@ class Router {
|
|
|
12654
12693
|
},
|
|
12655
12694
|
customTitle: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.PAGE_NOT_FOUND))
|
|
12656
12695
|
};
|
|
12696
|
+
var blockedPageConfig = {
|
|
12697
|
+
illustrationsConfig: {
|
|
12698
|
+
name: "no-permission",
|
|
12699
|
+
category: "easyops2"
|
|
12700
|
+
},
|
|
12701
|
+
customTitle: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.LICENSE_BLOCKED))
|
|
12702
|
+
};
|
|
12657
12703
|
_this3.state = "ready-to-mount";
|
|
12658
12704
|
mountTree([{
|
|
12659
12705
|
type: brickPageNotFound,
|
|
@@ -12661,7 +12707,7 @@ class Router {
|
|
|
12661
12707
|
status: "illustrations",
|
|
12662
12708
|
useNewIllustration: true,
|
|
12663
12709
|
style: illustrationStyle
|
|
12664
|
-
}, storyboard ? notFoundPageConfig : notFoundAppConfig),
|
|
12710
|
+
}, blocked ? blockedPageConfig : storyboard ? notFoundPageConfig : notFoundAppConfig),
|
|
12665
12711
|
children: [{
|
|
12666
12712
|
type: "a",
|
|
12667
12713
|
properties: {
|
|
@@ -15384,5 +15430,5 @@ function instantiateModalStack() {
|
|
|
15384
15430
|
};
|
|
15385
15431
|
}
|
|
15386
15432
|
|
|
15387
|
-
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, 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 };
|
|
15433
|
+
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 };
|
|
15388
15434
|
//# sourceMappingURL=index.esm.js.map
|