@next-core/brick-kit 2.188.3 → 2.189.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-9000b9fd.js +1586 -0
- package/dist/index-9000b9fd.js.map +1 -0
- package/dist/index.bundle.js +1665 -12
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +68 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/AuthenticationChange.d.ts +3 -0
- package/dist/types/core/AuthenticationChange.d.ts.map +1 -0
- package/dist/types/core/Kernel.d.ts.map +1 -1
- package/dist/types/i18n/constants.d.ts +3 -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/images.d.ts.map +1 -1
- package/package.json +11 -10
package/dist/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, merge, sortBy, orderBy, pick, isObject as isObject$1, uniq, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
|
|
6
|
+
import _, { escapeRegExp, set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, merge, sortBy, orderBy, pick, isObject as isObject$1, uniq, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
|
|
7
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, scanProcessorsInAny, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, snippetEvaluate, scanCustomApisInStoryboard, prefetchScript, scanBricksInBrickConf, loadScript, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
8
8
|
import React, { useState, useEffect, useMemo, useContext, createContext, useRef, useReducer, useCallback } from 'react';
|
|
9
9
|
import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
|
|
@@ -179,6 +179,8 @@ var K;
|
|
|
179
179
|
K["OTHER_ERROR"] = "OTHER_ERROR";
|
|
180
180
|
K["GO_BACK_PREVIOUS_PAGE"] = "GO_BACK_PREVIOUS_PAGE";
|
|
181
181
|
K["GO_BACK_HOME_PAGE"] = "GO_BACK_HOME_PAGE";
|
|
182
|
+
K["LOGIN_CHANGED"] = "LOGIN_CHANGED";
|
|
183
|
+
K["LOGOUT_APPLIED"] = "LOGOUT_APPLIED";
|
|
182
184
|
})(K || (K = {}));
|
|
183
185
|
|
|
184
186
|
/**
|
|
@@ -708,12 +710,7 @@ function imagesFactory(appId, isBuildPush, version) {
|
|
|
708
710
|
suffix = getBasePath() + suffix;
|
|
709
711
|
}
|
|
710
712
|
if (window.APP_ID && window.APP_ID !== appId) {
|
|
711
|
-
return suffix.replace(new RegExp("
|
|
712
|
-
if (p1 === window.APP_ID) {
|
|
713
|
-
return "/".concat(appId, "/");
|
|
714
|
-
}
|
|
715
|
-
return "/".concat(version, "/");
|
|
716
|
-
});
|
|
713
|
+
return suffix.replace(new RegExp("(^|/)".concat(escapeRegExp(window.APP_ID), "/")), "$1".concat(appId, "/")).replace(/\/\d+\.\d+\.\d+\//, "/".concat(version, "/"));
|
|
717
714
|
}
|
|
718
715
|
return suffix;
|
|
719
716
|
};
|
|
@@ -1213,7 +1210,9 @@ var locale$7 = {
|
|
|
1213
1210
|
[K.NO_PERMISSION]: "Unauthorized access, unable to retrieve the required resources for this page",
|
|
1214
1211
|
[K.OTHER_ERROR]: "Oops! Something went wrong",
|
|
1215
1212
|
[K.GO_BACK_PREVIOUS_PAGE]: "Go back to previous page",
|
|
1216
|
-
[K.GO_BACK_HOME_PAGE]: "Back to home page"
|
|
1213
|
+
[K.GO_BACK_HOME_PAGE]: "Back to home page",
|
|
1214
|
+
[K.LOGIN_CHANGED]: "You have logged in as another account, click OK to refresh the page.",
|
|
1215
|
+
[K.LOGOUT_APPLIED]: "Your account has been logged out, click OK to refresh the page."
|
|
1217
1216
|
};
|
|
1218
1217
|
var en = locale$7;
|
|
1219
1218
|
|
|
@@ -1230,7 +1229,9 @@ var locale$6 = {
|
|
|
1230
1229
|
[K.NO_PERMISSION]: "没有权限,无法获取页面所需要的资源",
|
|
1231
1230
|
[K.OTHER_ERROR]: "糟糕!页面出现了一些问题",
|
|
1232
1231
|
[K.GO_BACK_PREVIOUS_PAGE]: "回到上一页",
|
|
1233
|
-
[K.GO_BACK_HOME_PAGE]: "回到首页"
|
|
1232
|
+
[K.GO_BACK_HOME_PAGE]: "回到首页",
|
|
1233
|
+
[K.LOGIN_CHANGED]: "您已经登录另一个账号,点击确定刷新页面。",
|
|
1234
|
+
[K.LOGOUT_APPLIED]: "您的账号已经登出,点击确定刷新页面。"
|
|
1234
1235
|
};
|
|
1235
1236
|
var zh = locale$6;
|
|
1236
1237
|
|
|
@@ -8793,6 +8794,63 @@ function getRuntimeMisc() {
|
|
|
8793
8794
|
return misc;
|
|
8794
8795
|
}
|
|
8795
8796
|
|
|
8797
|
+
var REFRESH_CHANNEL = "brick-next:authentication-change";
|
|
8798
|
+
var warnedToRefresh = false;
|
|
8799
|
+
function refreshPageIfAuthenticationChanged(_x) {
|
|
8800
|
+
return _refreshPageIfAuthenticationChanged.apply(this, arguments);
|
|
8801
|
+
}
|
|
8802
|
+
function _refreshPageIfAuthenticationChanged() {
|
|
8803
|
+
_refreshPageIfAuthenticationChanged = _asyncToGenerator$3(function* (auth) {
|
|
8804
|
+
if (window.BroadcastChannel) {
|
|
8805
|
+
var channel = new BroadcastChannel(REFRESH_CHANNEL);
|
|
8806
|
+
channel.postMessage({
|
|
8807
|
+
type: "check-login",
|
|
8808
|
+
org: auth.org,
|
|
8809
|
+
username: auth.username
|
|
8810
|
+
});
|
|
8811
|
+
channel.addEventListener("message", e => {
|
|
8812
|
+
handleAuthenticationChange(e.data, auth);
|
|
8813
|
+
});
|
|
8814
|
+
} else {
|
|
8815
|
+
var PolyfillChannel = (yield import('./index-9000b9fd.js')).BroadcastChannel;
|
|
8816
|
+
var _channel = new PolyfillChannel(REFRESH_CHANNEL);
|
|
8817
|
+
_channel.postMessage({
|
|
8818
|
+
type: "check-login",
|
|
8819
|
+
org: auth.org,
|
|
8820
|
+
username: auth.username
|
|
8821
|
+
});
|
|
8822
|
+
// The npm package `broadcast-channel` dispatch message as raw data instead of a MessageEvent.
|
|
8823
|
+
_channel.addEventListener("message", data => {
|
|
8824
|
+
handleAuthenticationChange(data, auth);
|
|
8825
|
+
});
|
|
8826
|
+
}
|
|
8827
|
+
});
|
|
8828
|
+
return _refreshPageIfAuthenticationChanged.apply(this, arguments);
|
|
8829
|
+
}
|
|
8830
|
+
function handleAuthenticationChange(_x2, _x3) {
|
|
8831
|
+
return _handleAuthenticationChange.apply(this, arguments);
|
|
8832
|
+
}
|
|
8833
|
+
function _handleAuthenticationChange() {
|
|
8834
|
+
_handleAuthenticationChange = _asyncToGenerator$3(function* (payload, auth) {
|
|
8835
|
+
if (!warnedToRefresh && (payload.type === "logout" || payload.type === "check-login" && (payload.org !== auth.org || payload.username !== auth.username)) && getRuntime().getFeatureFlags()["refresh-page-if-authentication-changed"]) {
|
|
8836
|
+
// Only warn the user once.
|
|
8837
|
+
warnedToRefresh = true;
|
|
8838
|
+
// Open a modal to ask the user to refresh the page.
|
|
8839
|
+
// window.alert(i18next.t(`${NS_BRICK_KIT}:${payload.type === "logout" ? K.LOGOUT_APPLIED : K.LOGIN_CHANGED}`));
|
|
8840
|
+
Modal.warning({
|
|
8841
|
+
icon: /*#__PURE__*/React.createElement(ExclamationCircleOutlined, null),
|
|
8842
|
+
content: i18next.t("".concat(NS_BRICK_KIT, ":").concat(payload.type === "logout" ? K.LOGOUT_APPLIED : K.LOGIN_CHANGED)),
|
|
8843
|
+
okText: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.MODAL_OK)),
|
|
8844
|
+
keyboard: false,
|
|
8845
|
+
onOk: () => {
|
|
8846
|
+
location.reload();
|
|
8847
|
+
}
|
|
8848
|
+
});
|
|
8849
|
+
}
|
|
8850
|
+
});
|
|
8851
|
+
return _handleAuthenticationChange.apply(this, arguments);
|
|
8852
|
+
}
|
|
8853
|
+
|
|
8796
8854
|
var _excluded$3 = ["params"];
|
|
8797
8855
|
var V3WidgetMates = ["basic.v3-widget-mate"];
|
|
8798
8856
|
class Kernel {
|
|
@@ -8999,6 +9057,7 @@ class Kernel {
|
|
|
8999
9057
|
var auth = yield checkLogin();
|
|
9000
9058
|
if (auth.loggedIn) {
|
|
9001
9059
|
authenticate(auth);
|
|
9060
|
+
refreshPageIfAuthenticationChanged(auth);
|
|
9002
9061
|
}
|
|
9003
9062
|
}
|
|
9004
9063
|
})();
|