@next-core/brick-kit 2.167.0 → 2.168.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 +140 -27
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +141 -28
- 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
|
|
|
@@ -2621,12 +2661,12 @@ function setupTemplateProxy(proxyContext, ref, slots) {
|
|
|
2621
2661
|
var _excluded$7 = ["properties", "slots"];
|
|
2622
2662
|
function setupUseBrickInTemplate(props, proxyContext) {
|
|
2623
2663
|
function walk(props) {
|
|
2624
|
-
if (!isObject(props)) {
|
|
2625
|
-
return props;
|
|
2626
|
-
}
|
|
2627
2664
|
if (Array.isArray(props)) {
|
|
2628
2665
|
return props.map(walk);
|
|
2629
2666
|
}
|
|
2667
|
+
if (!isObject(props) || !isPlainObject(props)) {
|
|
2668
|
+
return props;
|
|
2669
|
+
}
|
|
2630
2670
|
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
2631
2671
|
var [key, value] = _ref;
|
|
2632
2672
|
return isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
@@ -2653,6 +2693,9 @@ function setupUseBrickInTemplate(props, proxyContext) {
|
|
|
2653
2693
|
}
|
|
2654
2694
|
return walk(props);
|
|
2655
2695
|
}
|
|
2696
|
+
function isPlainObject(object) {
|
|
2697
|
+
return Object.prototype.toString.call(object) === "[object Object]";
|
|
2698
|
+
}
|
|
2656
2699
|
|
|
2657
2700
|
var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
2658
2701
|
var preEvaluated = isPreEvaluated(value);
|
|
@@ -2752,11 +2795,12 @@ function computeRealProperties(properties, context, injectDeep, trackingContextL
|
|
|
2752
2795
|
result[propName] = realValue;
|
|
2753
2796
|
}
|
|
2754
2797
|
}
|
|
2755
|
-
if (Array.isArray(trackingContextList)
|
|
2756
|
-
var
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2798
|
+
if (Array.isArray(trackingContextList)) {
|
|
2799
|
+
var {
|
|
2800
|
+
contextNames,
|
|
2801
|
+
stateNames,
|
|
2802
|
+
formStateNames
|
|
2803
|
+
} = getTracks(propValue);
|
|
2760
2804
|
if (contextNames || stateNames || formStateNames) {
|
|
2761
2805
|
trackingContextList.push({
|
|
2762
2806
|
contextNames,
|
|
@@ -3902,6 +3946,47 @@ function LoginTimeoutMessage() {
|
|
|
3902
3946
|
}, []);
|
|
3903
3947
|
return /*#__PURE__*/React.createElement("div", null, i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.LOGIN_TIMEOUT_MESSAGE)));
|
|
3904
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
|
+
}
|
|
3905
3990
|
|
|
3906
3991
|
class WebsocketMessageRequest {
|
|
3907
3992
|
constructor(event, topic) {
|
|
@@ -8696,10 +8781,10 @@ class Kernel {
|
|
|
8696
8781
|
_this3.presetBricks = layout === "business" ? {
|
|
8697
8782
|
loadingBar: "business-website.loading-bar",
|
|
8698
8783
|
pageNotFound: "presentational-bricks.brick-result",
|
|
8699
|
-
pageError: "
|
|
8784
|
+
pageError: "presentational-bricks.brick-result"
|
|
8700
8785
|
} : _objectSpread(_objectSpread({}, _this3.bootstrapData.navbar), {}, {
|
|
8701
8786
|
pageNotFound: "presentational-bricks.brick-result",
|
|
8702
|
-
pageError: "
|
|
8787
|
+
pageError: "presentational-bricks.brick-result"
|
|
8703
8788
|
});
|
|
8704
8789
|
for (var item of supportedLayouts) {
|
|
8705
8790
|
if (item === layout) {
|
|
@@ -11513,6 +11598,13 @@ class Router {
|
|
|
11513
11598
|
}
|
|
11514
11599
|
_this3.kernel.setOriginFaviconHref(faviconElement.href);
|
|
11515
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
|
+
};
|
|
11516
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");
|
|
11517
11609
|
getRuntime().getFeatureFlags()["support-ui-8.2-compact-layout"] ? document.body.classList.add("compact-layout") : document.body.classList.remove("compact-layout");
|
|
11518
11610
|
setMode("default");
|
|
@@ -11570,14 +11662,41 @@ class Router {
|
|
|
11570
11662
|
var brickPageError = _this3.kernel.presetBricks.pageError;
|
|
11571
11663
|
yield _this3.kernel.loadDynamicBricks([brickPageError]);
|
|
11572
11664
|
mountRoutesResult.flags.failed = true;
|
|
11573
|
-
|
|
11665
|
+
var {
|
|
11666
|
+
title,
|
|
11667
|
+
illustration,
|
|
11668
|
+
showBackLink
|
|
11669
|
+
} = getRefinedErrorConf(error);
|
|
11670
|
+
mountRoutesResult.main = [_objectSpread(_objectSpread({
|
|
11574
11671
|
type: brickPageError,
|
|
11575
11672
|
properties: {
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
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
|
+
} : {}), {}, {
|
|
11579
11698
|
events: {}
|
|
11580
|
-
}];
|
|
11699
|
+
})];
|
|
11581
11700
|
mountRoutesResult.portal = [];
|
|
11582
11701
|
}
|
|
11583
11702
|
}
|
|
@@ -11798,13 +11917,7 @@ class Router {
|
|
|
11798
11917
|
properties: _objectSpread({
|
|
11799
11918
|
status: "illustrations",
|
|
11800
11919
|
useNewIllustration: true,
|
|
11801
|
-
style:
|
|
11802
|
-
display: "flex",
|
|
11803
|
-
alignItems: "center",
|
|
11804
|
-
justifyContent: "center",
|
|
11805
|
-
transform: "translateY(-100px)",
|
|
11806
|
-
height: "calc(100vh - var(--app-bar-height))"
|
|
11807
|
-
}
|
|
11920
|
+
style: illustrationStyle
|
|
11808
11921
|
}, storyboard ? notFoundPageConfig : notFoundAppConfig),
|
|
11809
11922
|
events: {}
|
|
11810
11923
|
}], mountPoints.main);
|