| 'use client'; |
| "use strict"; |
| Object.defineProperty(exports, "__esModule", { |
| value: true |
| }); |
| 0 && (module.exports = { |
| ErrorBoundary: null, |
| ErrorBoundaryHandler: null |
| }); |
| function _export(target, all) { |
| for(var name in all)Object.defineProperty(target, name, { |
| enumerable: true, |
| get: all[name] |
| }); |
| } |
| _export(exports, { |
| ErrorBoundary: function() { |
| return ErrorBoundary; |
| }, |
| ErrorBoundaryHandler: function() { |
| return ErrorBoundaryHandler; |
| } |
| }); |
| const _interop_require_default = require("@swc/helpers/_/_interop_require_default"); |
| const _jsxruntime = require("react/jsx-runtime"); |
| const _react = _interop_require_default._(require("react")); |
| const _navigationuntracked = require("./navigation-untracked"); |
| const _isnextroutererror = require("./is-next-router-error"); |
| const _navfailurehandler = require("./nav-failure-handler"); |
| const _handleisrerror = require("./handle-isr-error"); |
| const _isbot = require("../../shared/lib/router/utils/is-bot"); |
| const isBotUserAgent = typeof window !== 'undefined' && (0, _isbot.isBot)(window.navigator.userAgent); |
| class ErrorBoundaryHandler extends _react.default.Component { |
| static getDerivedStateFromError(error) { |
| if ((0, _isnextroutererror.isNextRouterError)(error)) { |
| |
| |
| throw error; |
| } |
| return { |
| error |
| }; |
| } |
| static getDerivedStateFromProps(props, state) { |
| const { error } = state; |
| |
| |
| |
| |
| if (process.env.__NEXT_APP_NAV_FAIL_HANDLING) { |
| if (error && (0, _navfailurehandler.handleHardNavError)(error)) { |
| |
| return { |
| error: null, |
| previousPathname: props.pathname |
| }; |
| } |
| } |
| |
| |
| |
| |
| |
| if (props.pathname !== state.previousPathname && state.error) { |
| return { |
| error: null, |
| previousPathname: props.pathname |
| }; |
| } |
| return { |
| error: state.error, |
| previousPathname: props.pathname |
| }; |
| } |
| |
| render() { |
| |
| |
| if (this.state.error && !isBotUserAgent) { |
| return (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, { |
| children: [ |
| (0, _jsxruntime.jsx)(_handleisrerror.HandleISRError, { |
| error: this.state.error |
| }), |
| this.props.errorStyles, |
| this.props.errorScripts, |
| (0, _jsxruntime.jsx)(this.props.errorComponent, { |
| error: this.state.error, |
| reset: this.reset |
| }) |
| ] |
| }); |
| } |
| return this.props.children; |
| } |
| constructor(props){ |
| super(props), this.reset = ()=>{ |
| this.setState({ |
| error: null |
| }); |
| }; |
| this.state = { |
| error: null, |
| previousPathname: this.props.pathname |
| }; |
| } |
| } |
| function ErrorBoundary(param) { |
| let { errorComponent, errorStyles, errorScripts, children } = param; |
| |
| |
| |
| |
| const pathname = (0, _navigationuntracked.useUntrackedPathname)(); |
| if (errorComponent) { |
| return (0, _jsxruntime.jsx)(ErrorBoundaryHandler, { |
| pathname: pathname, |
| errorComponent: errorComponent, |
| errorStyles: errorStyles, |
| errorScripts: errorScripts, |
| children: children |
| }); |
| } |
| return (0, _jsxruntime.jsx)(_jsxruntime.Fragment, { |
| children: children |
| }); |
| } |
|
|
| if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { |
| Object.defineProperty(exports.default, '__esModule', { value: true }); |
| Object.assign(exports.default, exports); |
| module.exports = exports.default; |
| } |
|
|
| |