@next-core/brick-kit 2.203.2 → 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 +102 -11
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +102 -14
- 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/core/listen.d.ts +10 -0
- package/dist/types/core/listen.d.ts.map +1 -0
- package/dist/types/developHelper.d.ts +2 -0
- package/dist/types/developHelper.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);
|
|
@@ -12030,6 +12068,41 @@ function setWatermark() {
|
|
|
12030
12068
|
}
|
|
12031
12069
|
}
|
|
12032
12070
|
|
|
12071
|
+
var initialize;
|
|
12072
|
+
var origin;
|
|
12073
|
+
var cachedUrl;
|
|
12074
|
+
var LOCAL_HOST = /^https?:\/\/localhost(?:$|:)/;
|
|
12075
|
+
function start(_origin) {
|
|
12076
|
+
if (location.origin !== _origin && !LOCAL_HOST.test(location.origin) && !LOCAL_HOST.test(_origin)) {
|
|
12077
|
+
// 禁止除 localhost 之外的跨域消息
|
|
12078
|
+
return;
|
|
12079
|
+
}
|
|
12080
|
+
initialize = true;
|
|
12081
|
+
origin = _origin;
|
|
12082
|
+
if (cachedUrl) {
|
|
12083
|
+
sendMessage({
|
|
12084
|
+
sender: "next-core",
|
|
12085
|
+
type: "url-change",
|
|
12086
|
+
url: cachedUrl
|
|
12087
|
+
});
|
|
12088
|
+
}
|
|
12089
|
+
}
|
|
12090
|
+
function sendMessage(data) {
|
|
12091
|
+
window.parent.postMessage(data, origin);
|
|
12092
|
+
}
|
|
12093
|
+
function sendUrlChange(data) {
|
|
12094
|
+
if (window.self !== window.parent && (data === null || data === void 0 ? void 0 : data.url) !== cachedUrl) {
|
|
12095
|
+
cachedUrl = data.url;
|
|
12096
|
+
if (initialize) {
|
|
12097
|
+
sendMessage({
|
|
12098
|
+
sender: "next-core",
|
|
12099
|
+
type: "url-change",
|
|
12100
|
+
url: data.url
|
|
12101
|
+
});
|
|
12102
|
+
}
|
|
12103
|
+
}
|
|
12104
|
+
}
|
|
12105
|
+
|
|
12033
12106
|
class Router {
|
|
12034
12107
|
constructor(kernel) {
|
|
12035
12108
|
_defineProperty$1(this, "defaultCollapsed", false);
|
|
@@ -12096,6 +12169,9 @@ class Router {
|
|
|
12096
12169
|
history.listen( /*#__PURE__*/function () {
|
|
12097
12170
|
var _ref = _asyncToGenerator$3(function* (location, action) {
|
|
12098
12171
|
var _this$prevLocation$st, _location$state;
|
|
12172
|
+
sendUrlChange({
|
|
12173
|
+
url: window.location.origin + history.createHref(location)
|
|
12174
|
+
});
|
|
12099
12175
|
var ignoreRendering = false;
|
|
12100
12176
|
var omittedLocationProps = {
|
|
12101
12177
|
hash: null,
|
|
@@ -12151,6 +12227,9 @@ class Router {
|
|
|
12151
12227
|
return _ref.apply(this, arguments);
|
|
12152
12228
|
};
|
|
12153
12229
|
}());
|
|
12230
|
+
sendUrlChange({
|
|
12231
|
+
url: window.location.href
|
|
12232
|
+
});
|
|
12154
12233
|
yield _this.queuedRender(history.location);
|
|
12155
12234
|
_this.kernel.firstRendered();
|
|
12156
12235
|
})();
|
|
@@ -12177,6 +12256,7 @@ class Router {
|
|
|
12177
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;
|
|
12178
12257
|
_this3.state = "initial";
|
|
12179
12258
|
var renderId = _this3.renderId = uniqueId("render-id-");
|
|
12259
|
+
var blocked = isBlockedPath(location.pathname);
|
|
12180
12260
|
resetAllInjected();
|
|
12181
12261
|
clearPollTimeout();
|
|
12182
12262
|
clearCollectWidgetContract();
|
|
@@ -12197,7 +12277,7 @@ class Router {
|
|
|
12197
12277
|
if (window.DEVELOPER_PREVIEW) {
|
|
12198
12278
|
return;
|
|
12199
12279
|
}
|
|
12200
|
-
var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
|
|
12280
|
+
var storyboard = blocked ? undefined : locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
|
|
12201
12281
|
var currentAppId = storyboard === null || storyboard === void 0 ? void 0 : (_storyboard$app = storyboard.app) === null || _storyboard$app === void 0 ? void 0 : _storyboard$app.id;
|
|
12202
12282
|
// dynamically change the value of the APP variable, if it's union app
|
|
12203
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)) {
|
|
@@ -12613,6 +12693,13 @@ class Router {
|
|
|
12613
12693
|
},
|
|
12614
12694
|
customTitle: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.PAGE_NOT_FOUND))
|
|
12615
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
|
+
};
|
|
12616
12703
|
_this3.state = "ready-to-mount";
|
|
12617
12704
|
mountTree([{
|
|
12618
12705
|
type: brickPageNotFound,
|
|
@@ -12620,7 +12707,7 @@ class Router {
|
|
|
12620
12707
|
status: "illustrations",
|
|
12621
12708
|
useNewIllustration: true,
|
|
12622
12709
|
style: illustrationStyle
|
|
12623
|
-
}, storyboard ? notFoundPageConfig : notFoundAppConfig),
|
|
12710
|
+
}, blocked ? blockedPageConfig : storyboard ? notFoundPageConfig : notFoundAppConfig),
|
|
12624
12711
|
children: [{
|
|
12625
12712
|
type: "a",
|
|
12626
12713
|
properties: {
|
|
@@ -14675,7 +14762,8 @@ var developHelper = {
|
|
|
14675
14762
|
getLegalRuntimeValue: _dev_only_getLegalRuntimeValue,
|
|
14676
14763
|
render: _dev_only_render,
|
|
14677
14764
|
setRealTimeDataInspectRoot,
|
|
14678
|
-
addRealTimeDataInspectHook
|
|
14765
|
+
addRealTimeDataInspectHook,
|
|
14766
|
+
iframePreviewInitialize: start
|
|
14679
14767
|
};
|
|
14680
14768
|
|
|
14681
14769
|
var _excluded$2 = ["type"];
|
|
@@ -15342,5 +15430,5 @@ function instantiateModalStack() {
|
|
|
15342
15430
|
};
|
|
15343
15431
|
}
|
|
15344
15432
|
|
|
15345
|
-
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 };
|
|
15346
15434
|
//# sourceMappingURL=index.esm.js.map
|