@next-core/brick-kit 2.146.2 → 2.147.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/CHANGELOG.md +16 -0
- package/dist/index.bundle.js +107 -54
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +110 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/types/abortController.d.ts +6 -0
- package/dist/types/abortController.d.ts.map +1 -0
- package/dist/types/core/LocationContext.d.ts +1 -1
- package/dist/types/core/LocationContext.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/core/Runtime.d.ts +2 -2
- package/dist/types/core/Runtime.d.ts.map +1 -1
- package/dist/types/core/matchStoryboard.d.ts +11 -0
- package/dist/types/core/matchStoryboard.d.ts.map +1 -0
- package/dist/types/handleHttpError.d.ts +2 -2
- package/dist/types/handleHttpError.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/internal/historyExtended.d.ts.map +1 -1
- package/dist/types/internal/isHttpAbortError.d.ts +3 -0
- package/dist/types/internal/isHttpAbortError.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -4,9 +4,9 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
|
|
5
5
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
6
6
|
import React, { useState, useEffect, useRef, forwardRef, useImperativeHandle, useMemo, useContext, createContext, useReducer, useCallback } from 'react';
|
|
7
|
-
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, deepFreeze, createProviderClass, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript,
|
|
8
|
-
import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, sortBy, merge, isObject as isObject$1, pick,
|
|
9
|
-
import { http, HttpResponseError, HttpFetchError } from '@next-core/brick-http';
|
|
7
|
+
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, matchPath, deepFreeze, createProviderClass, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript, scanAppGetMenuInAny, asyncProcessBrick, scanInstalledAppsInStoryboard, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
8
|
+
import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, sortBy, orderBy, merge, isObject as isObject$1, pick, omit, findLastIndex, noop, isString } from 'lodash';
|
|
9
|
+
import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
|
|
10
10
|
import moment from 'moment';
|
|
11
11
|
import { pipes } from '@next-core/pipes';
|
|
12
12
|
import i18next, { getFixedT } from 'i18next';
|
|
@@ -3520,6 +3520,43 @@ function loadAllLazyBricks() {
|
|
|
3520
3520
|
return loadLazyBricks(lazyBrickRegistry.keys());
|
|
3521
3521
|
}
|
|
3522
3522
|
|
|
3523
|
+
function matchStoryboard(storyboards, pathname) {
|
|
3524
|
+
// Put apps with longer homepage before shorter ones.
|
|
3525
|
+
// E.g., `/legacy/tool` will match first before `/legacy`.
|
|
3526
|
+
// This enables two apps with relationship of parent-child of homepage.
|
|
3527
|
+
var sortedStoryboards = orderBy(storyboards, storyboard => {
|
|
3528
|
+
var _storyboard$app$homep, _storyboard$app, _storyboard$app$homep2;
|
|
3529
|
+
|
|
3530
|
+
return (_storyboard$app$homep = (_storyboard$app = storyboard.app) === null || _storyboard$app === void 0 ? void 0 : (_storyboard$app$homep2 = _storyboard$app.homepage) === null || _storyboard$app$homep2 === void 0 ? void 0 : _storyboard$app$homep2.length) !== null && _storyboard$app$homep !== void 0 ? _storyboard$app$homep : 0;
|
|
3531
|
+
}, "desc");
|
|
3532
|
+
|
|
3533
|
+
for (var storyboard of sortedStoryboards) {
|
|
3534
|
+
var _storyboard$app2;
|
|
3535
|
+
|
|
3536
|
+
var homepage = (_storyboard$app2 = storyboard.app) === null || _storyboard$app2 === void 0 ? void 0 : _storyboard$app2.homepage;
|
|
3537
|
+
|
|
3538
|
+
if (typeof homepage === "string" && homepage[0] === "/") {
|
|
3539
|
+
if (matchPath(pathname, {
|
|
3540
|
+
path: homepage,
|
|
3541
|
+
exact: homepage === "/"
|
|
3542
|
+
})) {
|
|
3543
|
+
return storyboard;
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
/**
|
|
3549
|
+
* We say it's an outside app when at least one of the below conditions are true:
|
|
3550
|
+
* - target app is not found.
|
|
3551
|
+
* - current app is non-standalone mode and target app is standalone mode.
|
|
3552
|
+
*
|
|
3553
|
+
* Note: when current app is standalone mode, other apps will not be found.
|
|
3554
|
+
*/
|
|
3555
|
+
|
|
3556
|
+
function isOutsideApp(storyboard) {
|
|
3557
|
+
return !storyboard || !window.STANDALONE_MICRO_APPS && storyboard.app.standaloneMode;
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3523
3560
|
var kernel;
|
|
3524
3561
|
/* istanbul ignore next */
|
|
3525
3562
|
|
|
@@ -3891,16 +3928,10 @@ function _internalApiGetCurrentContext() {
|
|
|
3891
3928
|
|
|
3892
3929
|
return kernel.router.getCurrentContext();
|
|
3893
3930
|
}
|
|
3894
|
-
|
|
3895
|
-
for (var {
|
|
3896
|
-
homepage
|
|
3897
|
-
} of kernel.bootstrapData.microApps) {
|
|
3898
|
-
if (pathname === homepage || pathname.startsWith("".concat(homepage, "/"))) {
|
|
3899
|
-
return true;
|
|
3900
|
-
}
|
|
3901
|
-
}
|
|
3931
|
+
/* istanbul ignore next */
|
|
3902
3932
|
|
|
3903
|
-
|
|
3933
|
+
function _internalApiMatchStoryboard(pathname) {
|
|
3934
|
+
return matchStoryboard(kernel.bootstrapData.storyboards, pathname);
|
|
3904
3935
|
}
|
|
3905
3936
|
/* istanbul ignore next */
|
|
3906
3937
|
|
|
@@ -4017,13 +4048,11 @@ function historyExtended(browserHistory) {
|
|
|
4017
4048
|
reload,
|
|
4018
4049
|
setBlockMessage,
|
|
4019
4050
|
getBlockMessage,
|
|
4020
|
-
unblock
|
|
4021
|
-
|
|
4022
|
-
replace
|
|
4023
|
-
}, window.STANDALONE_MICRO_APPS ? standaloneHistoryOverridden(_objectSpread(_objectSpread({}, browserHistory), {}, {
|
|
4051
|
+
unblock
|
|
4052
|
+
}, historyOverridden(_objectSpread(_objectSpread({}, browserHistory), {}, {
|
|
4024
4053
|
push,
|
|
4025
4054
|
replace
|
|
4026
|
-
}))
|
|
4055
|
+
})));
|
|
4027
4056
|
}
|
|
4028
4057
|
/**
|
|
4029
4058
|
* Override history for standalone micro apps.
|
|
@@ -4031,7 +4060,7 @@ function historyExtended(browserHistory) {
|
|
|
4031
4060
|
* when `push` or `replace` to other apps, force page refresh.
|
|
4032
4061
|
*/
|
|
4033
4062
|
|
|
4034
|
-
function
|
|
4063
|
+
function historyOverridden(browserHistory) {
|
|
4035
4064
|
var {
|
|
4036
4065
|
push: originalPush,
|
|
4037
4066
|
replace: originalReplace
|
|
@@ -4046,14 +4075,16 @@ function standaloneHistoryOverridden(browserHistory) {
|
|
|
4046
4075
|
pathname = parsePath(path).pathname;
|
|
4047
4076
|
} else {
|
|
4048
4077
|
pathname = path.pathname;
|
|
4049
|
-
}
|
|
4078
|
+
} // When history.push or history.replace is performing with a non-empty pathname,
|
|
4079
|
+
// force load the target page when it is a page of an outside app.
|
|
4050
4080
|
|
|
4051
|
-
if (pathname === "" || _internalApiHasMatchedApp(pathname)) {
|
|
4052
|
-
return (method === "push" ? originalPush : originalReplace)(path, state, callback);
|
|
4053
|
-
} // Going to outside apps.
|
|
4054
4081
|
|
|
4082
|
+
if (pathname !== "" && isOutsideApp(_internalApiMatchStoryboard(pathname))) {
|
|
4083
|
+
// Going to outside apps.
|
|
4084
|
+
return location[method === "push" ? "assign" : "replace"](pathIsString ? getBasePath() + path.replace(/^\//, "") : browserHistory.createHref(path));
|
|
4085
|
+
}
|
|
4055
4086
|
|
|
4056
|
-
return
|
|
4087
|
+
return (method === "push" ? originalPush : originalReplace)(path, state, callback);
|
|
4057
4088
|
};
|
|
4058
4089
|
}
|
|
4059
4090
|
|
|
@@ -4089,6 +4120,12 @@ function isUnauthenticatedError(error) {
|
|
|
4089
4120
|
return error instanceof HttpResponseError && error.response.status === 401 && !!error.responseJson && error.responseJson.code === 100003;
|
|
4090
4121
|
}
|
|
4091
4122
|
|
|
4123
|
+
/** @internal */
|
|
4124
|
+
|
|
4125
|
+
function isHttpAbortError(error) {
|
|
4126
|
+
return error instanceof HttpAbortError;
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4092
4129
|
/**
|
|
4093
4130
|
* 将 http 请求错误转换为可读的字符串。
|
|
4094
4131
|
*
|
|
@@ -4130,7 +4167,12 @@ var unauthenticatedConfirmModal;
|
|
|
4130
4167
|
*/
|
|
4131
4168
|
|
|
4132
4169
|
function handleHttpError(error) {
|
|
4133
|
-
//
|
|
4170
|
+
// Do nothing if aborted http requests
|
|
4171
|
+
if (isHttpAbortError(error)) {
|
|
4172
|
+
return;
|
|
4173
|
+
} // Redirect to login page if not logged in.
|
|
4174
|
+
|
|
4175
|
+
|
|
4134
4176
|
if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {
|
|
4135
4177
|
// Do not show multiple confirm modals.
|
|
4136
4178
|
if (unauthenticatedConfirmModal) {
|
|
@@ -10616,30 +10658,8 @@ class LocationContext {
|
|
|
10616
10658
|
return "missed";
|
|
10617
10659
|
}
|
|
10618
10660
|
|
|
10619
|
-
matchStoryboard(storyboards
|
|
10620
|
-
|
|
10621
|
-
// E.g., `/legacy/tool` will match first before `/legacy`.
|
|
10622
|
-
// This enables two apps with relationship of parent-child of homepage.
|
|
10623
|
-
var sortedStoryboards = orderBy(storyboards, storyboard => {
|
|
10624
|
-
var _storyboard$app$homep, _storyboard$app, _storyboard$app$homep2;
|
|
10625
|
-
|
|
10626
|
-
return (_storyboard$app$homep = (_storyboard$app = storyboard.app) === null || _storyboard$app === void 0 ? void 0 : (_storyboard$app$homep2 = _storyboard$app.homepage) === null || _storyboard$app$homep2 === void 0 ? void 0 : _storyboard$app$homep2.length) !== null && _storyboard$app$homep !== void 0 ? _storyboard$app$homep : 0;
|
|
10627
|
-
}, "desc");
|
|
10628
|
-
|
|
10629
|
-
for (var storyboard of sortedStoryboards) {
|
|
10630
|
-
var _storyboard$app2;
|
|
10631
|
-
|
|
10632
|
-
var homepage = (_storyboard$app2 = storyboard.app) === null || _storyboard$app2 === void 0 ? void 0 : _storyboard$app2.homepage;
|
|
10633
|
-
|
|
10634
|
-
if (typeof homepage === "string" && homepage[0] === "/") {
|
|
10635
|
-
if (matchPath((location || this.location).pathname, {
|
|
10636
|
-
path: homepage,
|
|
10637
|
-
exact: homepage === "/"
|
|
10638
|
-
})) {
|
|
10639
|
-
return storyboard;
|
|
10640
|
-
}
|
|
10641
|
-
}
|
|
10642
|
-
}
|
|
10661
|
+
matchStoryboard(storyboards) {
|
|
10662
|
+
return matchStoryboard(storyboards, this.location.pathname);
|
|
10643
10663
|
}
|
|
10644
10664
|
|
|
10645
10665
|
getSubStoryboardByRoute(storyboard) {
|
|
@@ -11898,6 +11918,39 @@ function mergePreviewRoutes(routes) {
|
|
|
11898
11918
|
return mergedRoutes;
|
|
11899
11919
|
}
|
|
11900
11920
|
|
|
11921
|
+
/** @internal */
|
|
11922
|
+
var abortController = (() => {
|
|
11923
|
+
var supported = ("AbortController" in window);
|
|
11924
|
+
|
|
11925
|
+
if (!supported) {
|
|
11926
|
+
return {
|
|
11927
|
+
abortPendingRequest() {// Do nothing
|
|
11928
|
+
},
|
|
11929
|
+
|
|
11930
|
+
getSignalToken() {
|
|
11931
|
+
return null;
|
|
11932
|
+
}
|
|
11933
|
+
|
|
11934
|
+
};
|
|
11935
|
+
}
|
|
11936
|
+
|
|
11937
|
+
var controller = new AbortController();
|
|
11938
|
+
var signal = controller.signal;
|
|
11939
|
+
|
|
11940
|
+
var abortPendingRequest = () => {
|
|
11941
|
+
controller.abort();
|
|
11942
|
+
controller = new AbortController();
|
|
11943
|
+
signal = controller.signal;
|
|
11944
|
+
};
|
|
11945
|
+
|
|
11946
|
+
var getSignalToken = () => signal;
|
|
11947
|
+
|
|
11948
|
+
return {
|
|
11949
|
+
abortPendingRequest,
|
|
11950
|
+
getSignalToken
|
|
11951
|
+
};
|
|
11952
|
+
})();
|
|
11953
|
+
|
|
11901
11954
|
class Router {
|
|
11902
11955
|
constructor(kernel) {
|
|
11903
11956
|
_defineProperty$1(this, "defaultCollapsed", false);
|
|
@@ -12013,6 +12066,8 @@ class Router {
|
|
|
12013
12066
|
return;
|
|
12014
12067
|
}
|
|
12015
12068
|
|
|
12069
|
+
abortController.abortPendingRequest();
|
|
12070
|
+
|
|
12016
12071
|
_this.locationChangeNotify(_this.prevLocation.pathname, location.pathname);
|
|
12017
12072
|
|
|
12018
12073
|
_this.prevLocation = location;
|
|
@@ -12021,16 +12076,11 @@ class Router {
|
|
|
12021
12076
|
|
|
12022
12077
|
_this.locationContext.messageDispatcher.reset();
|
|
12023
12078
|
|
|
12024
|
-
|
|
12025
|
-
|
|
12079
|
+
if (action === "POP") {
|
|
12080
|
+
var storyboard = matchStoryboard(_this.kernel.bootstrapData.storyboards, location.pathname); // When a browser action of goBack or goForward is performing,
|
|
12081
|
+
// force reload when the target page is a page of an outside app.
|
|
12026
12082
|
|
|
12027
|
-
|
|
12028
|
-
if (!window.STANDALONE_MICRO_APPS) {
|
|
12029
|
-
if (storyboard && storyboard.app.standaloneMode) {
|
|
12030
|
-
window.location.reload();
|
|
12031
|
-
}
|
|
12032
|
-
} else {
|
|
12033
|
-
if (!storyboard) {
|
|
12083
|
+
if (isOutsideApp(storyboard)) {
|
|
12034
12084
|
window.location.reload();
|
|
12035
12085
|
}
|
|
12036
12086
|
}
|
|
@@ -12207,6 +12257,8 @@ class Router {
|
|
|
12207
12257
|
|
|
12208
12258
|
if (isUnauthenticatedError(error) && !window.NO_AUTH_GUARD) {
|
|
12209
12259
|
mountRoutesResult.flags.unauthenticated = true;
|
|
12260
|
+
} else if (isHttpAbortError(error)) {
|
|
12261
|
+
return;
|
|
12210
12262
|
} else {
|
|
12211
12263
|
yield _this3.kernel.layoutBootstrap(layoutType);
|
|
12212
12264
|
var brickPageError = _this3.kernel.presetBricks.pageError;
|
|
@@ -14958,5 +15010,5 @@ function useProvider() {
|
|
|
14958
15010
|
}));
|
|
14959
15011
|
}
|
|
14960
15012
|
|
|
14961
|
-
export { BrickAsComponent, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ModalElement, SingleBrickAsComponent, StoryboardFunctionRegistryFactory, UpdatingElement, authenticate, batchSetAppsLocalTheme, checkIf, checkIfByTransform, createHistory, createRuntime, developHelper, doTransform, event, getAuth, getCssPropertyValue, getCurrentTheme, getHistory, getMockInfo, getRuntime, getRuntimeMisc, handleHttpError, httpErrorToString, i18nText, initI18n, isLoggedIn, logout, looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useProvider, useRecentApps };
|
|
15013
|
+
export { BrickAsComponent, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ModalElement, SingleBrickAsComponent, StoryboardFunctionRegistryFactory, UpdatingElement, abortController, authenticate, batchSetAppsLocalTheme, checkIf, checkIfByTransform, createHistory, createRuntime, developHelper, doTransform, event, getAuth, getCssPropertyValue, getCurrentTheme, getHistory, getMockInfo, getRuntime, getRuntimeMisc, handleHttpError, httpErrorToString, i18nText, initI18n, isLoggedIn, logout, looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useProvider, useRecentApps };
|
|
14962
15014
|
//# sourceMappingURL=index.esm.js.map
|