UNPKG

mirador

Version:

An open-source, web-based 'multi-up' viewer that supports zoom-pan-rotate functionality, ability to display/compare simple images, and images with annotations.

67 lines (66 loc) 1.9 kB
import { Component as e, createContext as t, createElement as n } from "react"; //#region node_modules/react-error-boundary/dist/react-error-boundary.esm.js var r = t(null), i = { didCatch: !1, error: null }, a = class extends e { constructor(e) { super(e), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = i; } static getDerivedStateFromError(e) { return { didCatch: !0, error: e }; } resetErrorBoundary() { let { error: e } = this.state; if (e !== null) { var t, n, r = [...arguments]; (t = (n = this.props).onReset) == null || t.call(n, { args: r, reason: "imperative-api" }), this.setState(i); } } componentDidCatch(e, t) { var n, r; (n = (r = this.props).onError) == null || n.call(r, e, t); } componentDidUpdate(e, t) { let { didCatch: n } = this.state, { resetKeys: r } = this.props; if (n && t.error !== null && o(e.resetKeys, r)) { var a, s; (a = (s = this.props).onReset) == null || a.call(s, { next: r, prev: e.resetKeys, reason: "keys" }), this.setState(i); } } render() { let { children: e, fallbackRender: t, FallbackComponent: i, fallback: a } = this.props, { didCatch: o, error: s } = this.state, c = e; if (o) { let e = { error: s, resetErrorBoundary: this.resetErrorBoundary }; if (typeof t == "function") c = t(e); else if (i) c = n(i, e); else if (a !== void 0) c = a; else throw s; } return n(r.Provider, { value: { didCatch: o, error: s, resetErrorBoundary: this.resetErrorBoundary } }, c); } }; function o() { let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; return e.length !== t.length || e.some((e, n) => !Object.is(e, t[n])); } //#endregion export { a as t }; //# sourceMappingURL=react-error-boundary.esm-ByHqCaxk.js.map