@next-core/brick-kit 2.167.1 → 2.168.1
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 +134 -24
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +135 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/handleHttpError.d.ts +12 -0
- package/dist/types/handleHttpError.d.ts.map +1 -1
- package/dist/types/i18n/constants.d.ts +5 -1
- 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/getTracks.d.ts +6 -0
- package/dist/types/internal/getTracks.d.ts.map +1 -0
- package/dist/types/internal/setProperties.d.ts.map +1 -1
- package/dist/types/transformProperties.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
|
|
6
6
|
import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, merge, sortBy, orderBy, isObject as isObject$1, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
|
|
7
|
-
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable,
|
|
7
|
+
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, isTrackAll, trackAll, trackContext, trackState, trackFormState, transformAndInject, transform, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, deepFreeze, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript as loadScript$1, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
8
8
|
import React, { useState, useEffect, useRef, useMemo, useCallback, forwardRef, useImperativeHandle, useContext, createContext, useReducer } from 'react';
|
|
9
9
|
import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
|
|
10
10
|
import { Modal, message, Empty, ConfigProvider } from 'antd';
|
|
@@ -173,6 +173,10 @@ var K;
|
|
|
173
173
|
K["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
174
174
|
K["PAGE_NOT_FOUND"] = "PAGE_NOT_FOUND";
|
|
175
175
|
K["APP_NOT_FOUND"] = "APP_NOT_FOUND";
|
|
176
|
+
K["LICENSE_EXPIRED"] = "LICENSE_EXPIRED";
|
|
177
|
+
K["NO_PERMISSION"] = "NO_PERMISSION";
|
|
178
|
+
K["OTHER_ERROR"] = "OTHER_ERROR";
|
|
179
|
+
K["GO_BACK_PREVIOUS_PAGE"] = "GO_BACK_PREVIOUS_PAGE";
|
|
176
180
|
})(K || (K = {}));
|
|
177
181
|
|
|
178
182
|
/**
|
|
@@ -822,6 +826,32 @@ function getNextStateOfUseBrick(state, isArray, key) {
|
|
|
822
826
|
return StateOfUseBrick.INITIAL;
|
|
823
827
|
}
|
|
824
828
|
|
|
829
|
+
function getTracks(value) {
|
|
830
|
+
var contextNames = false;
|
|
831
|
+
var stateNames = false;
|
|
832
|
+
var formStateNames = false;
|
|
833
|
+
if (typeof value === "string" ? isEvaluable(value) : isPreEvaluated(value)) {
|
|
834
|
+
var raw = typeof value === "string" ? value : getPreEvaluatedRaw(value);
|
|
835
|
+
if (isTrackAll(raw)) {
|
|
836
|
+
var result = trackAll(raw);
|
|
837
|
+
if (result) {
|
|
838
|
+
contextNames = result.context;
|
|
839
|
+
stateNames = result.state;
|
|
840
|
+
formStateNames = result.formState;
|
|
841
|
+
}
|
|
842
|
+
} else {
|
|
843
|
+
contextNames = trackContext(raw);
|
|
844
|
+
stateNames = trackState(raw);
|
|
845
|
+
formStateNames = trackFormState(raw);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
return {
|
|
849
|
+
contextNames,
|
|
850
|
+
stateNames,
|
|
851
|
+
formStateNames
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
|
|
825
855
|
/** @internal */
|
|
826
856
|
function transformElementProperties(element, data, to, from, mapArray) {
|
|
827
857
|
var result = preprocessTransformProperties(data, to, from, mapArray);
|
|
@@ -886,9 +916,11 @@ function doTransform(data, to, options) {
|
|
|
886
916
|
raw = getPreEvaluatedRaw(v);
|
|
887
917
|
addDataToPreEvaluated(v, data);
|
|
888
918
|
}
|
|
889
|
-
var
|
|
890
|
-
|
|
891
|
-
|
|
919
|
+
var {
|
|
920
|
+
contextNames,
|
|
921
|
+
stateNames,
|
|
922
|
+
formStateNames
|
|
923
|
+
} = getTracks(raw);
|
|
892
924
|
if (contextNames || stateNames || formStateNames) {
|
|
893
925
|
options.trackingContextList.push({
|
|
894
926
|
contextNames,
|
|
@@ -1126,7 +1158,11 @@ var locale$7 = {
|
|
|
1126
1158
|
[K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
|
|
1127
1159
|
[K.NETWORK_ERROR]: "Network error, please check your network.",
|
|
1128
1160
|
[K.PAGE_NOT_FOUND]: "Page not found, please check the URL",
|
|
1129
|
-
[K.APP_NOT_FOUND]: "App not found, maybe the URL is wrong or you don't have permission to access"
|
|
1161
|
+
[K.APP_NOT_FOUND]: "App not found, maybe the URL is wrong or you don't have permission to access",
|
|
1162
|
+
[K.LICENSE_EXPIRED]: "The license authorization has expired, please contact the platform administrator",
|
|
1163
|
+
[K.NO_PERMISSION]: "Unauthorized access, unable to retrieve the required resources for this page",
|
|
1164
|
+
[K.OTHER_ERROR]: "Oops! Something went wrong",
|
|
1165
|
+
[K.GO_BACK_PREVIOUS_PAGE]: "Go back to previous page"
|
|
1130
1166
|
};
|
|
1131
1167
|
var en = locale$7;
|
|
1132
1168
|
|
|
@@ -1138,7 +1174,11 @@ var locale$6 = {
|
|
|
1138
1174
|
[K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
|
|
1139
1175
|
[K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。",
|
|
1140
1176
|
[K.PAGE_NOT_FOUND]: "请求的页面未找到,请确认 URL 是否正确",
|
|
1141
|
-
[K.APP_NOT_FOUND]: "请求的微应用无法找到, 可能是 URL 错误或者无权限访问"
|
|
1177
|
+
[K.APP_NOT_FOUND]: "请求的微应用无法找到, 可能是 URL 错误或者无权限访问",
|
|
1178
|
+
[K.LICENSE_EXPIRED]: "License 授权失效,请联系平台管理员",
|
|
1179
|
+
[K.NO_PERMISSION]: "没有权限,无法获取页面所需要的资源",
|
|
1180
|
+
[K.OTHER_ERROR]: "糟糕!页面出现了一些问题",
|
|
1181
|
+
[K.GO_BACK_PREVIOUS_PAGE]: "回到上一页"
|
|
1142
1182
|
};
|
|
1143
1183
|
var zh = locale$6;
|
|
1144
1184
|
|
|
@@ -2755,11 +2795,12 @@ function computeRealProperties(properties, context, injectDeep, trackingContextL
|
|
|
2755
2795
|
result[propName] = realValue;
|
|
2756
2796
|
}
|
|
2757
2797
|
}
|
|
2758
|
-
if (Array.isArray(trackingContextList)
|
|
2759
|
-
var
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2798
|
+
if (Array.isArray(trackingContextList)) {
|
|
2799
|
+
var {
|
|
2800
|
+
contextNames,
|
|
2801
|
+
stateNames,
|
|
2802
|
+
formStateNames
|
|
2803
|
+
} = getTracks(propValue);
|
|
2763
2804
|
if (contextNames || stateNames || formStateNames) {
|
|
2764
2805
|
trackingContextList.push({
|
|
2765
2806
|
contextNames,
|
|
@@ -3905,6 +3946,47 @@ function LoginTimeoutMessage() {
|
|
|
3905
3946
|
}, []);
|
|
3906
3947
|
return /*#__PURE__*/React.createElement("div", null, i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.LOGIN_TIMEOUT_MESSAGE)));
|
|
3907
3948
|
}
|
|
3949
|
+
function getConfOfHttpStatus(error) {
|
|
3950
|
+
var _error$response;
|
|
3951
|
+
switch ((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) {
|
|
3952
|
+
case 403:
|
|
3953
|
+
return {
|
|
3954
|
+
showBackLink: true,
|
|
3955
|
+
title: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.NO_PERMISSION)),
|
|
3956
|
+
illustration: {
|
|
3957
|
+
name: "no-permission",
|
|
3958
|
+
category: "easyops2"
|
|
3959
|
+
}
|
|
3960
|
+
};
|
|
3961
|
+
default:
|
|
3962
|
+
return null;
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
function getConfOfHttpCode(error) {
|
|
3966
|
+
var _error$responseJson;
|
|
3967
|
+
switch ((_error$responseJson = error.responseJson) === null || _error$responseJson === void 0 ? void 0 : _error$responseJson.code) {
|
|
3968
|
+
case "200000":
|
|
3969
|
+
return {
|
|
3970
|
+
title: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.LICENSE_EXPIRED)),
|
|
3971
|
+
illustration: {
|
|
3972
|
+
name: "license-expired",
|
|
3973
|
+
category: "easyops2"
|
|
3974
|
+
}
|
|
3975
|
+
};
|
|
3976
|
+
default:
|
|
3977
|
+
return {
|
|
3978
|
+
showBackLink: true,
|
|
3979
|
+
title: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.OTHER_ERROR)),
|
|
3980
|
+
illustration: {
|
|
3981
|
+
name: "unknown-error",
|
|
3982
|
+
category: "easyops2"
|
|
3983
|
+
}
|
|
3984
|
+
};
|
|
3985
|
+
}
|
|
3986
|
+
}
|
|
3987
|
+
function getRefinedErrorConf(error) {
|
|
3988
|
+
return [getConfOfHttpStatus, getConfOfHttpCode].reduce((result, method) => result ? result : method(error), null);
|
|
3989
|
+
}
|
|
3908
3990
|
|
|
3909
3991
|
class WebsocketMessageRequest {
|
|
3910
3992
|
constructor(event, topic) {
|
|
@@ -8699,10 +8781,10 @@ class Kernel {
|
|
|
8699
8781
|
_this3.presetBricks = layout === "business" ? {
|
|
8700
8782
|
loadingBar: "business-website.loading-bar",
|
|
8701
8783
|
pageNotFound: "presentational-bricks.brick-result",
|
|
8702
|
-
pageError: "
|
|
8784
|
+
pageError: "presentational-bricks.brick-result"
|
|
8703
8785
|
} : _objectSpread(_objectSpread({}, _this3.bootstrapData.navbar), {}, {
|
|
8704
8786
|
pageNotFound: "presentational-bricks.brick-result",
|
|
8705
|
-
pageError: "
|
|
8787
|
+
pageError: "presentational-bricks.brick-result"
|
|
8706
8788
|
});
|
|
8707
8789
|
for (var item of supportedLayouts) {
|
|
8708
8790
|
if (item === layout) {
|
|
@@ -11516,6 +11598,13 @@ class Router {
|
|
|
11516
11598
|
}
|
|
11517
11599
|
_this3.kernel.setOriginFaviconHref(faviconElement.href);
|
|
11518
11600
|
}
|
|
11601
|
+
var illustrationStyle = {
|
|
11602
|
+
display: "flex",
|
|
11603
|
+
alignItems: "center",
|
|
11604
|
+
justifyContent: "center",
|
|
11605
|
+
transform: "translateY(-100px)",
|
|
11606
|
+
height: "calc(100vh - var(--app-bar-height))"
|
|
11607
|
+
};
|
|
11519
11608
|
setTheme(((_getLocalAppsTheme = getLocalAppsTheme()) === null || _getLocalAppsTheme === void 0 ? void 0 : _getLocalAppsTheme[currentApp === null || currentApp === void 0 ? void 0 : currentApp.id]) || (currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) || "light");
|
|
11520
11609
|
getRuntime().getFeatureFlags()["support-ui-8.2-compact-layout"] ? document.body.classList.add("compact-layout") : document.body.classList.remove("compact-layout");
|
|
11521
11610
|
setMode("default");
|
|
@@ -11573,14 +11662,41 @@ class Router {
|
|
|
11573
11662
|
var brickPageError = _this3.kernel.presetBricks.pageError;
|
|
11574
11663
|
yield _this3.kernel.loadDynamicBricks([brickPageError]);
|
|
11575
11664
|
mountRoutesResult.flags.failed = true;
|
|
11576
|
-
|
|
11665
|
+
var {
|
|
11666
|
+
title,
|
|
11667
|
+
illustration,
|
|
11668
|
+
showBackLink
|
|
11669
|
+
} = getRefinedErrorConf(error);
|
|
11670
|
+
mountRoutesResult.main = [_objectSpread(_objectSpread({
|
|
11577
11671
|
type: brickPageError,
|
|
11578
11672
|
properties: {
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11673
|
+
status: "illustrations",
|
|
11674
|
+
useNewIllustration: true,
|
|
11675
|
+
customTitle: title,
|
|
11676
|
+
subTitle: httpErrorToString(error),
|
|
11677
|
+
illustrationsConfig: illustration,
|
|
11678
|
+
style: illustrationStyle
|
|
11679
|
+
}
|
|
11680
|
+
}, showBackLink ? {
|
|
11681
|
+
children: [{
|
|
11682
|
+
type: "a",
|
|
11683
|
+
properties: {
|
|
11684
|
+
textContent: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.GO_BACK_PREVIOUS_PAGE)),
|
|
11685
|
+
style: {
|
|
11686
|
+
display: "block",
|
|
11687
|
+
textAlign: "center"
|
|
11688
|
+
}
|
|
11689
|
+
},
|
|
11690
|
+
slotId: "content",
|
|
11691
|
+
events: {
|
|
11692
|
+
click: [{
|
|
11693
|
+
action: "history.goBack"
|
|
11694
|
+
}]
|
|
11695
|
+
}
|
|
11696
|
+
}]
|
|
11697
|
+
} : {}), {}, {
|
|
11582
11698
|
events: {}
|
|
11583
|
-
}];
|
|
11699
|
+
})];
|
|
11584
11700
|
mountRoutesResult.portal = [];
|
|
11585
11701
|
}
|
|
11586
11702
|
}
|
|
@@ -11801,13 +11917,7 @@ class Router {
|
|
|
11801
11917
|
properties: _objectSpread({
|
|
11802
11918
|
status: "illustrations",
|
|
11803
11919
|
useNewIllustration: true,
|
|
11804
|
-
style:
|
|
11805
|
-
display: "flex",
|
|
11806
|
-
alignItems: "center",
|
|
11807
|
-
justifyContent: "center",
|
|
11808
|
-
transform: "translateY(-100px)",
|
|
11809
|
-
height: "calc(100vh - var(--app-bar-height))"
|
|
11810
|
-
}
|
|
11920
|
+
style: illustrationStyle
|
|
11811
11921
|
}, storyboard ? notFoundPageConfig : notFoundAppConfig),
|
|
11812
11922
|
events: {}
|
|
11813
11923
|
}], mountPoints.main);
|