@microsoft/omnichannel-chat-widget 1.8.1-main.5ac9acf → 1.8.1-main.6ec59e7
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/lib/cjs/common/facades/FacadeChatSDK.js +7 -49
- package/lib/cjs/common/telemetry/TelemetryConstants.js +0 -3
- package/lib/cjs/common/telemetry/TelemetryManager.js +2 -2
- package/lib/cjs/common/utils.js +0 -3
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +3 -7
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -15
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +5 -12
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +0 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +2 -2
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +9 -55
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +19 -31
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -14
- package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +0 -1
- package/lib/esm/common/facades/FacadeChatSDK.js +7 -49
- package/lib/esm/common/telemetry/TelemetryConstants.js +0 -3
- package/lib/esm/common/telemetry/TelemetryManager.js +2 -2
- package/lib/esm/common/utils.js +0 -3
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +3 -7
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +5 -16
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +5 -12
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +0 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +2 -2
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +8 -53
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +19 -31
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -14
- package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +0 -1
- package/lib/types/common/facades/FacadeChatSDK.d.ts +0 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +0 -3
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/persistentChatHelper.d.ts +1 -2
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +0 -1
- package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +1 -2
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +0 -1
- package/package.json +2 -2
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +0 -68
- package/lib/esm/components/errorboundary/ErrorBoundary.js +0 -59
- package/lib/types/components/errorboundary/ErrorBoundary.d.ts +0 -14
|
@@ -9,14 +9,13 @@ import { defaultGeneralPostChatSurveyPaneStyleProps } from "./common/defaultStyl
|
|
|
9
9
|
import { findAllFocusableElement } from "../../common/utils";
|
|
10
10
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
11
11
|
import isValidSurveyUrl from "./common/isValidSurveyUrl";
|
|
12
|
-
const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact
|
|
13
|
-
let showMultiLingual = arguments.length >
|
|
12
|
+
const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact) {
|
|
13
|
+
let showMultiLingual = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
14
14
|
const surveyLinkParams = new URLSearchParams({
|
|
15
15
|
embed: isEmbed.toString(),
|
|
16
16
|
compact: (compact ?? true).toString(),
|
|
17
17
|
lang: locale ?? "en-us",
|
|
18
|
-
showmultilingual: (showMultiLingual ?? false).toString()
|
|
19
|
-
cvResponsePageRequestId: customerVoiceSurveyCorrelationId
|
|
18
|
+
showmultilingual: (showMultiLingual ?? false).toString()
|
|
20
19
|
});
|
|
21
20
|
return `${surveyInviteLink}&${surveyLinkParams.toString()}`;
|
|
22
21
|
};
|
|
@@ -32,9 +31,9 @@ export const PostChatSurveyPaneStateful = props => {
|
|
|
32
31
|
// Bot survey enabled
|
|
33
32
|
state.appStates.postChatParticipantType === ParticipantType.Bot) {
|
|
34
33
|
// Only Bot has engaged
|
|
35
|
-
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true
|
|
34
|
+
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
36
35
|
} else {
|
|
37
|
-
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true
|
|
36
|
+
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
38
37
|
}
|
|
39
38
|
if (props.copilotSurveyContext) {
|
|
40
39
|
surveyInviteLink = `${surveyInviteLink}&mcs_additionalcontext=${JSON.stringify(props.copilotSurveyContext)}`;
|
|
@@ -97,14 +96,6 @@ export const PostChatSurveyPaneStateful = props => {
|
|
|
97
96
|
message: "Customer Voice form response error."
|
|
98
97
|
}
|
|
99
98
|
});
|
|
100
|
-
} else if (typeof data === "string" && data.startsWith(CustomerVoiceEvents.FormsError)) {
|
|
101
|
-
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.ERROR, {
|
|
102
|
-
Event: TelemetryEvent.CustomerVoiceFormsError,
|
|
103
|
-
Description: "Customer Voice failed to load with forms error.",
|
|
104
|
-
ExceptionDetails: {
|
|
105
|
-
message: `Customer Voice forms error details: ${data}`
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
99
|
}
|
|
109
100
|
});
|
|
110
101
|
}, []);
|
|
@@ -3,5 +3,4 @@ export let CustomerVoiceEvents;
|
|
|
3
3
|
CustomerVoiceEvents["ResponsePageLoaded"] = "ResponsePageLoaded";
|
|
4
4
|
CustomerVoiceEvents["FormResponseSubmitted"] = "FormResponseSubmitted";
|
|
5
5
|
CustomerVoiceEvents["FormResponseError"] = "FormResponseError";
|
|
6
|
-
CustomerVoiceEvents["FormsError"] = "FormsError";
|
|
7
6
|
})(CustomerVoiceEvents || (CustomerVoiceEvents = {}));
|
|
@@ -72,5 +72,4 @@ export declare class FacadeChatSDK {
|
|
|
72
72
|
getVoiceVideoCalling(params?: VoiceVideoCallingOptionalParams): Promise<GetVoiceVideoCallingResponse>;
|
|
73
73
|
getPostChatSurveyContext(): Promise<PostChatContext>;
|
|
74
74
|
getAgentAvailability(optionalParams?: GetAgentAvailabilityOptionalParams): Promise<GetAgentAvailabilityResponse>;
|
|
75
|
-
getReconnectableChats(reconnectableChatsParams?: any): Promise<any>;
|
|
76
75
|
}
|
|
@@ -94,8 +94,6 @@ export declare enum TelemetryEvent {
|
|
|
94
94
|
DisconnectEndChatSDKCallFailed = "DisconnectEndChatSDKCallFailed",
|
|
95
95
|
GetChatReconnectContextSDKCallStarted = "GetChatReconnectContextSDKCallStarted",
|
|
96
96
|
GetChatReconnectContextSDKCallFailed = "GetChatReconnectContextSDKCallFailed",
|
|
97
|
-
CheckContactIdError = "checkContactIdError",
|
|
98
|
-
GetChatReconnectContextSDKCallSucceeded = "GetChatReconnectContextSDKCallSucceeded",
|
|
99
97
|
ParseAdaptiveCardFailed = "ParseAdaptiveCardFailed",
|
|
100
98
|
ClientDataStoreProviderFailed = "ClientDataStoreProviderFailed",
|
|
101
99
|
InMemoryDataStoreFailed = "InMemoryDataStoreFailed",
|
|
@@ -163,7 +161,6 @@ export declare enum TelemetryEvent {
|
|
|
163
161
|
CustomerVoiceResponsePageLoaded = "CustomerVoiceResponsePageLoaded",
|
|
164
162
|
CustomerVoiceFormResponseSubmitted = "CustomerVoiceFormResponseSubmitted",
|
|
165
163
|
CustomerVoiceFormResponseError = "CustomerVoiceFormResponseError",
|
|
166
|
-
CustomerVoiceFormsError = "CustomerVoiceFormsError",
|
|
167
164
|
BotAuthActivityEmptySasUrl = "BotAuthActivityEmptySasUrl",
|
|
168
165
|
SetBotAuthProviderFetchConfig = "SetBotAuthProviderFetchConfig",
|
|
169
166
|
SetBotAuthProviderHideCard = "SetBotAuthProviderHideCard",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
2
2
|
export declare const isPostChatSurveyEnabled: (facadeChatSDK: FacadeChatSDK) => Promise<boolean>;
|
|
3
|
-
export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => boolean
|
|
3
|
+
export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => Promise<boolean>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const shouldSetPreChatIfPersistentChat: (facadeChatSDK: FacadeChatSDK, conversationMode: string, showPreChat: boolean) => Promise<boolean>;
|
|
1
|
+
export declare const shouldSetPreChatIfPersistentChat: (chatSDK: any, conversationMode: string, showPreChat: boolean) => Promise<boolean>;
|
|
@@ -4,4 +4,3 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
|
|
|
4
4
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
5
|
export declare const handleStartChatError: (dispatch: Dispatch<ILiveChatWidgetAction>, facadeChatSDK: FacadeChatSDK, props: ILiveChatWidgetProps | undefined, ex: any, isStartChatSuccessful: boolean) => void;
|
|
6
6
|
export declare const logWidgetLoadComplete: (additionalMessage?: string) => void;
|
|
7
|
-
export declare const logWidgetLoadWithUnexpectedError: (ex: any) => void;
|
|
@@ -2,5 +2,4 @@ import { IPostChatSurveyPaneProps } from "@microsoft/omnichannel-chat-components
|
|
|
2
2
|
export interface IPostChatSurveyPaneStatefulProps extends IPostChatSurveyPaneProps {
|
|
3
3
|
isCustomerVoiceSurveyCompact?: boolean;
|
|
4
4
|
copilotSurveyContext?: Record<string, string>;
|
|
5
|
-
customerVoiceSurveyCorrelationId?: string;
|
|
6
5
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.8.1-main.
|
|
3
|
+
"version": "1.8.1-main.6ec59e7",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@azure/core-tracing": "^1.2.0",
|
|
88
88
|
"@microsoft/applicationinsights-web": "^3.3.6",
|
|
89
89
|
"@microsoft/omnichannel-chat-components": "1.1.12",
|
|
90
|
-
"@microsoft/omnichannel-chat-sdk": "^1.11.
|
|
90
|
+
"@microsoft/omnichannel-chat-sdk": "^1.11.1",
|
|
91
91
|
"@opentelemetry/api": "^1.9.0",
|
|
92
92
|
"abort-controller": "^3",
|
|
93
93
|
"abort-controller-es5": "^2.0.1",
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
17
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
18
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
19
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
const RenderChildrenFunction = _ref => {
|
|
23
|
-
let {
|
|
24
|
-
children
|
|
25
|
-
} = _ref;
|
|
26
|
-
return typeof children === 'function' ? children() : children;
|
|
27
|
-
};
|
|
28
|
-
let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
29
|
-
_inherits(ErrorBoundary, _Component);
|
|
30
|
-
var _super = _createSuper(ErrorBoundary);
|
|
31
|
-
function ErrorBoundary(props) {
|
|
32
|
-
var _this;
|
|
33
|
-
_classCallCheck(this, ErrorBoundary);
|
|
34
|
-
_this = _super.call(this, props);
|
|
35
|
-
_this.state = {
|
|
36
|
-
hasError: false
|
|
37
|
-
};
|
|
38
|
-
return _this;
|
|
39
|
-
}
|
|
40
|
-
_createClass(ErrorBoundary, [{
|
|
41
|
-
key: "componentDidCatch",
|
|
42
|
-
value: function componentDidCatch(error) {
|
|
43
|
-
const {
|
|
44
|
-
onError
|
|
45
|
-
} = this.props;
|
|
46
|
-
this.setState({
|
|
47
|
-
hasError: true
|
|
48
|
-
});
|
|
49
|
-
if (onError) {
|
|
50
|
-
onError(error);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "render",
|
|
55
|
-
value: function render() {
|
|
56
|
-
const {
|
|
57
|
-
children
|
|
58
|
-
} = this.props;
|
|
59
|
-
const {
|
|
60
|
-
hasError
|
|
61
|
-
} = this.state;
|
|
62
|
-
return !hasError && /*#__PURE__*/_react.default.createElement(RenderChildrenFunction, null, children);
|
|
63
|
-
}
|
|
64
|
-
}]);
|
|
65
|
-
return ErrorBoundary;
|
|
66
|
-
}(_react.Component);
|
|
67
|
-
var _default = ErrorBoundary;
|
|
68
|
-
exports.default = _default;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
5
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
7
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
10
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
13
|
-
import React, { Component } from 'react';
|
|
14
|
-
const RenderChildrenFunction = _ref => {
|
|
15
|
-
let {
|
|
16
|
-
children
|
|
17
|
-
} = _ref;
|
|
18
|
-
return typeof children === 'function' ? children() : children;
|
|
19
|
-
};
|
|
20
|
-
let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
21
|
-
_inherits(ErrorBoundary, _Component);
|
|
22
|
-
var _super = _createSuper(ErrorBoundary);
|
|
23
|
-
function ErrorBoundary(props) {
|
|
24
|
-
var _this;
|
|
25
|
-
_classCallCheck(this, ErrorBoundary);
|
|
26
|
-
_this = _super.call(this, props);
|
|
27
|
-
_this.state = {
|
|
28
|
-
hasError: false
|
|
29
|
-
};
|
|
30
|
-
return _this;
|
|
31
|
-
}
|
|
32
|
-
_createClass(ErrorBoundary, [{
|
|
33
|
-
key: "componentDidCatch",
|
|
34
|
-
value: function componentDidCatch(error) {
|
|
35
|
-
const {
|
|
36
|
-
onError
|
|
37
|
-
} = this.props;
|
|
38
|
-
this.setState({
|
|
39
|
-
hasError: true
|
|
40
|
-
});
|
|
41
|
-
if (onError) {
|
|
42
|
-
onError(error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: "render",
|
|
47
|
-
value: function render() {
|
|
48
|
-
const {
|
|
49
|
-
children
|
|
50
|
-
} = this.props;
|
|
51
|
-
const {
|
|
52
|
-
hasError
|
|
53
|
-
} = this.state;
|
|
54
|
-
return !hasError && /*#__PURE__*/React.createElement(RenderChildrenFunction, null, children);
|
|
55
|
-
}
|
|
56
|
-
}]);
|
|
57
|
-
return ErrorBoundary;
|
|
58
|
-
}(Component);
|
|
59
|
-
export default ErrorBoundary;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
interface ErrorBoundaryProps {
|
|
3
|
-
children: React.ReactNode | (() => React.ReactNode);
|
|
4
|
-
onError?: (error: Error) => void;
|
|
5
|
-
}
|
|
6
|
-
interface ErrorBoundaryState {
|
|
7
|
-
hasError: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
10
|
-
constructor(props: ErrorBoundaryProps);
|
|
11
|
-
componentDidCatch(error: Error): void;
|
|
12
|
-
render(): false | React.JSX.Element;
|
|
13
|
-
}
|
|
14
|
-
export default ErrorBoundary;
|