@next-core/brick-kit 2.188.4 → 2.190.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 +1674 -8
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +76 -4
- 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/poll.d.ts.map +1 -1
- package/package.json +11 -10
package/dist/index.esm.js
CHANGED
|
@@ -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
|
/**
|
|
@@ -1208,7 +1210,9 @@ var locale$7 = {
|
|
|
1208
1210
|
[K.NO_PERMISSION]: "Unauthorized access, unable to retrieve the required resources for this page",
|
|
1209
1211
|
[K.OTHER_ERROR]: "Oops! Something went wrong",
|
|
1210
1212
|
[K.GO_BACK_PREVIOUS_PAGE]: "Go back to previous page",
|
|
1211
|
-
[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."
|
|
1212
1216
|
};
|
|
1213
1217
|
var en = locale$7;
|
|
1214
1218
|
|
|
@@ -1225,7 +1229,9 @@ var locale$6 = {
|
|
|
1225
1229
|
[K.NO_PERMISSION]: "没有权限,无法获取页面所需要的资源",
|
|
1226
1230
|
[K.OTHER_ERROR]: "糟糕!页面出现了一些问题",
|
|
1227
1231
|
[K.GO_BACK_PREVIOUS_PAGE]: "回到上一页",
|
|
1228
|
-
[K.GO_BACK_HOME_PAGE]: "回到首页"
|
|
1232
|
+
[K.GO_BACK_HOME_PAGE]: "回到首页",
|
|
1233
|
+
[K.LOGIN_CHANGED]: "您已经登录另一个账号,点击确定刷新页面。",
|
|
1234
|
+
[K.LOGOUT_APPLIED]: "您的账号已经登出,点击确定刷新页面。"
|
|
1229
1235
|
};
|
|
1230
1236
|
var zh = locale$6;
|
|
1231
1237
|
|
|
@@ -5844,9 +5850,10 @@ function startPoll(task, _ref, pollOptions, context) {
|
|
|
5844
5850
|
if (!shouldStop) {
|
|
5845
5851
|
var _computeRealValue2;
|
|
5846
5852
|
var _result = yield task();
|
|
5853
|
+
var expectPollStopImmediatelyResult = (_computeRealValue2 = computeRealValue(expectPollStopImmediately, context)) === null || _computeRealValue2 === void 0 ? void 0 : _computeRealValue2();
|
|
5847
5854
|
// Stop polling immediately when the expectation is match or a different router
|
|
5848
5855
|
// is rendering after the task processed.
|
|
5849
|
-
shouldStop =
|
|
5856
|
+
shouldStop = expectPollStopImmediatelyResult || currentRenderId !== _internalApiGetRouterRenderId();
|
|
5850
5857
|
if (!shouldStop) {
|
|
5851
5858
|
var _computeRealValue3;
|
|
5852
5859
|
progress === null || progress === void 0 ? void 0 : progress(_result);
|
|
@@ -5860,13 +5867,18 @@ function startPoll(task, _ref, pollOptions, context) {
|
|
|
5860
5867
|
} else {
|
|
5861
5868
|
delayedPoll(interval !== null && interval !== void 0 ? interval : 3000);
|
|
5862
5869
|
}
|
|
5870
|
+
} else if (expectPollStopImmediatelyResult) {
|
|
5871
|
+
finallyCallback === null || finallyCallback === void 0 ? void 0 : finallyCallback();
|
|
5863
5872
|
}
|
|
5873
|
+
} else {
|
|
5874
|
+
finallyCallback === null || finallyCallback === void 0 ? void 0 : finallyCallback();
|
|
5864
5875
|
}
|
|
5865
5876
|
} catch (e) {
|
|
5866
5877
|
var _computeRealValue4;
|
|
5878
|
+
var _expectPollStopImmediatelyResult = (_computeRealValue4 = computeRealValue(expectPollStopImmediately, context)) === null || _computeRealValue4 === void 0 ? void 0 : _computeRealValue4();
|
|
5867
5879
|
// Stop polling immediately when the expectation is match or a different router
|
|
5868
5880
|
// is rendering after the task processed.
|
|
5869
|
-
shouldStop =
|
|
5881
|
+
shouldStop = _expectPollStopImmediatelyResult || currentRenderId !== _internalApiGetRouterRenderId();
|
|
5870
5882
|
if (!shouldStop) {
|
|
5871
5883
|
error === null || error === void 0 ? void 0 : error(e);
|
|
5872
5884
|
if (continueOnError) {
|
|
@@ -5874,6 +5886,8 @@ function startPoll(task, _ref, pollOptions, context) {
|
|
|
5874
5886
|
} else {
|
|
5875
5887
|
finallyCallback === null || finallyCallback === void 0 ? void 0 : finallyCallback();
|
|
5876
5888
|
}
|
|
5889
|
+
} else if (_expectPollStopImmediatelyResult) {
|
|
5890
|
+
finallyCallback === null || finallyCallback === void 0 ? void 0 : finallyCallback();
|
|
5877
5891
|
}
|
|
5878
5892
|
} finally {
|
|
5879
5893
|
// Manually dispatch an event of `request.end` when the polling is stopped immediately.
|
|
@@ -8788,6 +8802,63 @@ function getRuntimeMisc() {
|
|
|
8788
8802
|
return misc;
|
|
8789
8803
|
}
|
|
8790
8804
|
|
|
8805
|
+
var REFRESH_CHANNEL = "brick-next:authentication-change";
|
|
8806
|
+
var warnedToRefresh = false;
|
|
8807
|
+
function refreshPageIfAuthenticationChanged(_x) {
|
|
8808
|
+
return _refreshPageIfAuthenticationChanged.apply(this, arguments);
|
|
8809
|
+
}
|
|
8810
|
+
function _refreshPageIfAuthenticationChanged() {
|
|
8811
|
+
_refreshPageIfAuthenticationChanged = _asyncToGenerator$3(function* (auth) {
|
|
8812
|
+
if (window.BroadcastChannel) {
|
|
8813
|
+
var channel = new BroadcastChannel(REFRESH_CHANNEL);
|
|
8814
|
+
channel.postMessage({
|
|
8815
|
+
type: "check-login",
|
|
8816
|
+
org: auth.org,
|
|
8817
|
+
username: auth.username
|
|
8818
|
+
});
|
|
8819
|
+
channel.addEventListener("message", e => {
|
|
8820
|
+
handleAuthenticationChange(e.data, auth);
|
|
8821
|
+
});
|
|
8822
|
+
} else {
|
|
8823
|
+
var PolyfillChannel = (yield import('./index-9000b9fd.js')).BroadcastChannel;
|
|
8824
|
+
var _channel = new PolyfillChannel(REFRESH_CHANNEL);
|
|
8825
|
+
_channel.postMessage({
|
|
8826
|
+
type: "check-login",
|
|
8827
|
+
org: auth.org,
|
|
8828
|
+
username: auth.username
|
|
8829
|
+
});
|
|
8830
|
+
// The npm package `broadcast-channel` dispatch message as raw data instead of a MessageEvent.
|
|
8831
|
+
_channel.addEventListener("message", data => {
|
|
8832
|
+
handleAuthenticationChange(data, auth);
|
|
8833
|
+
});
|
|
8834
|
+
}
|
|
8835
|
+
});
|
|
8836
|
+
return _refreshPageIfAuthenticationChanged.apply(this, arguments);
|
|
8837
|
+
}
|
|
8838
|
+
function handleAuthenticationChange(_x2, _x3) {
|
|
8839
|
+
return _handleAuthenticationChange.apply(this, arguments);
|
|
8840
|
+
}
|
|
8841
|
+
function _handleAuthenticationChange() {
|
|
8842
|
+
_handleAuthenticationChange = _asyncToGenerator$3(function* (payload, auth) {
|
|
8843
|
+
if (!warnedToRefresh && (payload.type === "logout" || payload.type === "check-login" && (payload.org !== auth.org || payload.username !== auth.username)) && getRuntime().getFeatureFlags()["refresh-page-if-authentication-changed"]) {
|
|
8844
|
+
// Only warn the user once.
|
|
8845
|
+
warnedToRefresh = true;
|
|
8846
|
+
// Open a modal to ask the user to refresh the page.
|
|
8847
|
+
// window.alert(i18next.t(`${NS_BRICK_KIT}:${payload.type === "logout" ? K.LOGOUT_APPLIED : K.LOGIN_CHANGED}`));
|
|
8848
|
+
Modal.warning({
|
|
8849
|
+
icon: /*#__PURE__*/React.createElement(ExclamationCircleOutlined, null),
|
|
8850
|
+
content: i18next.t("".concat(NS_BRICK_KIT, ":").concat(payload.type === "logout" ? K.LOGOUT_APPLIED : K.LOGIN_CHANGED)),
|
|
8851
|
+
okText: i18next.t("".concat(NS_BRICK_KIT, ":").concat(K.MODAL_OK)),
|
|
8852
|
+
keyboard: false,
|
|
8853
|
+
onOk: () => {
|
|
8854
|
+
location.reload();
|
|
8855
|
+
}
|
|
8856
|
+
});
|
|
8857
|
+
}
|
|
8858
|
+
});
|
|
8859
|
+
return _handleAuthenticationChange.apply(this, arguments);
|
|
8860
|
+
}
|
|
8861
|
+
|
|
8791
8862
|
var _excluded$3 = ["params"];
|
|
8792
8863
|
var V3WidgetMates = ["basic.v3-widget-mate"];
|
|
8793
8864
|
class Kernel {
|
|
@@ -8994,6 +9065,7 @@ class Kernel {
|
|
|
8994
9065
|
var auth = yield checkLogin();
|
|
8995
9066
|
if (auth.loggedIn) {
|
|
8996
9067
|
authenticate(auth);
|
|
9068
|
+
refreshPageIfAuthenticationChanged(auth);
|
|
8997
9069
|
}
|
|
8998
9070
|
}
|
|
8999
9071
|
})();
|