UNPKG

@p5-wrapper/next

Version:

A NextJS specific library for the @P5-Wrapper/react project.

538 lines (537 loc) 17.2 kB
import U from "react"; function de(a) { return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a; } var C = { exports: {} }, F = {}, Q; function G() { if (Q) return F; Q = 1; function a(l) { return l && l.__esModule ? l : { default: l }; } return F._ = a, F; } var N = { exports: {} }, A = {}; var K; function fe() { if (K) return A; K = 1; var a = Symbol.for("react.transitional.element"), l = Symbol.for("react.fragment"); function b(R, m, h) { var T = null; if (h !== void 0 && (T = "" + h), m.key !== void 0 && (T = "" + m.key), "key" in m) { h = {}; for (var v in m) v !== "key" && (h[v] = m[v]); } else h = m; return m = h.ref, { $$typeof: a, type: R, key: T, ref: m !== void 0 ? m : null, props: h }; } return A.Fragment = l, A.jsx = b, A.jsxs = b, A; } var j = {}; var ee; function _e() { return ee || (ee = 1, process.env.NODE_ENV !== "production" && (function() { function a(e) { if (e == null) return null; if (typeof e == "function") return e.$$typeof === ie ? null : e.displayName || e.name || null; if (typeof e == "string") return e; switch (e) { case r: return "Fragment"; case g: return "Profiler"; case s: return "StrictMode"; case w: return "Suspense"; case E: return "SuspenseList"; case le: return "Activity"; } if (typeof e == "object") switch (typeof e.tag == "number" && console.error( "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue." ), e.$$typeof) { case u: return "Portal"; case S: return e.displayName || "Context"; case L: return (e._context.displayName || "Context") + ".Consumer"; case c: var t = e.render; return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e; case ue: return t = e.displayName || null, t !== null ? t : a(e.type) || "Memo"; case q: t = e._payload, e = e._init; try { return a(e(t)); } catch { } } return null; } function l(e) { return "" + e; } function b(e) { try { l(e); var t = !1; } catch { t = !0; } if (t) { t = console; var i = t.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object"; return i.call( t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", d ), l(e); } } function R(e) { if (e === r) return "<>"; if (typeof e == "object" && e !== null && e.$$typeof === q) return "<...>"; try { var t = a(e); return t ? "<" + t + ">" : "<...>"; } catch { return "<...>"; } } function m() { var e = D.A; return e === null ? null : e.getOwner(); } function h() { return Error("react-stack-top-frame"); } function T(e) { if (J.call(e, "key")) { var t = Object.getOwnPropertyDescriptor(e, "key").get; if (t && t.isReactWarning) return !1; } return e.key !== void 0; } function v(e, t) { function i() { z || (z = !0, console.error( "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t )); } i.isReactWarning = !0, Object.defineProperty(e, "key", { get: i, configurable: !0 }); } function k() { var e = a(this.type); return X[e] || (X[e] = !0, console.error( "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release." )), e = this.props.ref, e !== void 0 ? e : null; } function O(e, t, i, d, x, Y) { var f = i.ref; return e = { $$typeof: n, type: e, key: t, props: i, _owner: d }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(e, "ref", { enumerable: !1, get: k }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: 0 }), Object.defineProperty(e, "_debugInfo", { configurable: !1, enumerable: !1, writable: !0, value: null }), Object.defineProperty(e, "_debugStack", { configurable: !1, enumerable: !1, writable: !0, value: x }), Object.defineProperty(e, "_debugTask", { configurable: !1, enumerable: !1, writable: !0, value: Y }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e; } function _(e, t, i, d, x, Y) { var f = t.children; if (f !== void 0) if (d) if (se(f)) { for (d = 0; d < f.length; d++) p(f[d]); Object.freeze && Object.freeze(f); } else console.error( "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead." ); else p(f); if (J.call(t, "key")) { f = a(e); var P = Object.keys(t).filter(function(ce) { return ce !== "key"; }); d = 0 < P.length ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}", B[f + d] || (P = 0 < P.length ? "{" + P.join(": ..., ") + ": ...}" : "{}", console.error( `A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`, d, f, P, f ), B[f + d] = !0); } if (f = null, i !== void 0 && (b(i), f = "" + i), T(t) && (b(t.key), f = "" + t.key), "key" in t) { i = {}; for (var M in t) M !== "key" && (i[M] = t[M]); } else i = t; return f && v( i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e ), O( e, f, i, m(), x, Y ); } function p(e) { y(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === q && (e._payload.status === "fulfilled" ? y(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1)); } function y(e) { return typeof e == "object" && e !== null && e.$$typeof === n; } var o = U, n = Symbol.for("react.transitional.element"), u = Symbol.for("react.portal"), r = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), g = Symbol.for("react.profiler"), L = Symbol.for("react.consumer"), S = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), ue = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), le = Symbol.for("react.activity"), ie = Symbol.for("react.client.reference"), D = o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, se = Array.isArray, I = console.createTask ? console.createTask : function() { return null; }; o = { react_stack_bottom_frame: function(e) { return e(); } }; var z, X = {}, Z = o.react_stack_bottom_frame.bind( o, h )(), H = I(R(h)), B = {}; j.Fragment = r, j.jsx = function(e, t, i) { var d = 1e4 > D.recentlyCreatedOwnerStacks++; return _( e, t, i, !1, d ? Error("react-stack-top-frame") : Z, d ? I(R(e)) : H ); }, j.jsxs = function(e, t, i) { var d = 1e4 > D.recentlyCreatedOwnerStacks++; return _( e, t, i, !0, d ? Error("react-stack-top-frame") : Z, d ? I(R(e)) : H ); }; })()), j; } var re; function me() { return re || (re = 1, process.env.NODE_ENV === "production" ? N.exports = fe() : N.exports = _e()), N.exports; } function pe(a) { throw new Error('Could not dynamically require "' + a + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var V = {}, W = {}, te; function be() { return te || (te = 1, (function(a) { "use client"; Object.defineProperty(a, "__esModule", { value: !0 }), Object.defineProperty(a, "LoadableContext", { enumerable: !0, get: function() { return R; } }); const R = (/* @__PURE__ */ (/* @__PURE__ */ G())._(U)).default.createContext(null); process.env.NODE_ENV !== "production" && (R.displayName = "LoadableContext"); })(W)), W; } var ne; function he() { return ne || (ne = 1, (function(a) { Object.defineProperty(a, "__esModule", { value: !0 }), Object.defineProperty(a, "default", { enumerable: !0, get: function() { return o; } }); const b = /* @__PURE__ */ (/* @__PURE__ */ G())._(U), R = be(); function m(n) { return n && n.default ? n.default : n; } const h = [], T = []; let v = !1; function k(n) { let u = n(), r = { loading: !0, loaded: null, error: null }; return r.promise = u.then((s) => (r.loading = !1, r.loaded = s, s)).catch((s) => { throw r.loading = !1, r.error = s, s; }), r; } function O(n, u) { let r = Object.assign({ loader: null, loading: null, delay: 200, timeout: null, webpack: null, modules: null }, u), s = null; function g() { if (!s) { const c = new _(n, r); s = { getCurrentValue: c.getCurrentValue.bind(c), subscribe: c.subscribe.bind(c), retry: c.retry.bind(c), promise: c.promise.bind(c) }; } return s.promise(); } if (typeof window > "u" && h.push(g), !v && typeof window < "u") { const c = r.webpack && typeof pe.resolveWeak == "function" ? r.webpack() : r.modules; c && T.push((w) => { for (const E of c) if (w.includes(E)) return g(); }); } function L() { g(); const c = b.default.useContext(R.LoadableContext); c && Array.isArray(r.modules) && r.modules.forEach((w) => { c(w); }); } function S(c, w) { L(); const E = b.default.useSyncExternalStore(s.subscribe, s.getCurrentValue, s.getCurrentValue); return b.default.useImperativeHandle(w, () => ({ retry: s.retry }), []), b.default.useMemo(() => E.loading || E.error ? /* @__PURE__ */ b.default.createElement(r.loading, { isLoading: E.loading, pastDelay: E.pastDelay, timedOut: E.timedOut, error: E.error, retry: s.retry }) : E.loaded ? /* @__PURE__ */ b.default.createElement(m(E.loaded), c) : null, [ c, E ]); } return S.preload = () => g(), S.displayName = "LoadableComponent", /* @__PURE__ */ b.default.forwardRef(S); } class _ { constructor(u, r) { this._loadFn = u, this._opts = r, this._callbacks = /* @__PURE__ */ new Set(), this._delay = null, this._timeout = null, this.retry(); } promise() { return this._res.promise; } retry() { this._clearTimeouts(), this._res = this._loadFn(this._opts.loader), this._state = { pastDelay: !1, timedOut: !1 }; const { _res: u, _opts: r } = this; u.loading && (typeof r.delay == "number" && (r.delay === 0 ? this._state.pastDelay = !0 : this._delay = setTimeout(() => { this._update({ pastDelay: !0 }); }, r.delay)), typeof r.timeout == "number" && (this._timeout = setTimeout(() => { this._update({ timedOut: !0 }); }, r.timeout))), this._res.promise.then(() => { this._update({}), this._clearTimeouts(); }).catch((s) => { this._update({}), this._clearTimeouts(); }), this._update({}); } _update(u) { this._state = { ...this._state, error: this._res.error, loaded: this._res.loaded, loading: this._res.loading, ...u }, this._callbacks.forEach((r) => r()); } _clearTimeouts() { clearTimeout(this._delay), clearTimeout(this._timeout); } getCurrentValue() { return this._state; } subscribe(u) { return this._callbacks.add(u), () => { this._callbacks.delete(u); }; } } function p(n) { return O(k, n); } function y(n, u) { let r = []; for (; n.length; ) { let s = n.pop(); r.push(s(u)); } return Promise.all(r).then(() => { if (n.length) return y(n, u); }); } p.preloadAll = () => new Promise((n, u) => { y(h).then(n, u); }), p.preloadReady = (n = []) => new Promise((u) => { const r = () => (v = !0, u()); y(T, n).then(r, r); }), typeof window < "u" && (window.__NEXT_PRELOADREADY = p.preloadReady); const o = p; })(V)), V; } var ae; function ye() { return ae || (ae = 1, (function(a, l) { Object.defineProperty(l, "__esModule", { value: !0 }); function b(_, p) { for (var y in p) Object.defineProperty(_, y, { enumerable: !0, get: p[y] }); } b(l, { /** * This function lets you dynamically import a component. * It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood. * * Read more: [Next.js Docs: `next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic) */ default: function() { return O; }, noSSR: function() { return k; } }); const R = /* @__PURE__ */ G(), m = me(), h = /* @__PURE__ */ R._(he()), T = typeof window > "u"; function v(_) { return { default: _?.default || _ }; } function k(_, p) { if (delete p.webpack, delete p.modules, !T) return _(p); const y = p.loading; return () => /* @__PURE__ */ (0, m.jsx)(y, { error: null, isLoading: !0, pastDelay: !1, timedOut: !1 }); } function O(_, p) { let y = h.default, o = { // A loading component is not required, so we default it loading: ({ error: r, isLoading: s, pastDelay: g }) => { if (!g) return null; if (process.env.NODE_ENV !== "production") { if (s) return null; if (r) return /* @__PURE__ */ (0, m.jsxs)("p", { children: [ r.message, /* @__PURE__ */ (0, m.jsx)("br", {}), r.stack ] }); } return null; } }; _ instanceof Promise ? o.loader = () => _ : typeof _ == "function" ? o.loader = _ : typeof _ == "object" && (o = { ...o, ..._ }), o = { ...o, ...p }; const n = o.loader, u = () => n != null ? n().then(v) : Promise.resolve(v(() => null)); return o.loadableGenerated && (o = { ...o, ...o.loadableGenerated }, delete o.loadableGenerated), typeof o.ssr == "boolean" && !o.ssr ? (delete o.webpack, delete o.modules, k(y, o)) : y({ ...o, loader: u }); } (typeof l.default == "function" || typeof l.default == "object" && l.default !== null) && typeof l.default.__esModule > "u" && (Object.defineProperty(l.default, "__esModule", { value: !0 }), Object.assign(l.default, l), a.exports = l.default); })(C, C.exports)), C.exports; } var $, oe; function Ee() { return oe || (oe = 1, $ = ye()), $; } var Re = Ee(); const ve = /* @__PURE__ */ de(Re), ge = ve( async () => (await import("@p5-wrapper/react")).P5Canvas, { ssr: !1 } ); export { ge as NextReactP5Wrapper };