@blumjs/router
Advanced tools
Comparing version 7.4.0 to 7.5.0
import { Routes } from "./types"; | ||
export declare const blumRouter: { | ||
isDispatchChangeStateEventBeforeMiddleware: boolean; | ||
isDispatchChangeStateEventAfterMiddleware: boolean; | ||
beforeBackHandledCallback: (() => void) | null; | ||
isBackFromBrowser: boolean; | ||
afterBackHandledCallback: (() => void) | null; | ||
subscribers: Subscriber[]; | ||
setDefaultBackHandlerOptions(): void; | ||
setBackHandlerOptions(options: BackHandlerOptions): void; | ||
historyPush(routes: Partial<Routes>): void; | ||
@@ -20,1 +27,8 @@ changeState(routes: BlumRouterEventMap["changestate"]): void; | ||
}; | ||
export type BackHandlerOptions = { | ||
beforeBackHandledCallback?: (() => void) | null; | ||
afterBackHandledCallback?: (() => void) | null; | ||
isDispatchChangeStateEventBeforeMiddleware?: boolean; | ||
isDispatchChangeStateEventAfterMiddleware?: boolean; | ||
isBackFromBrowser?: boolean; | ||
}; |
import { blumRouter } from "./blum-router"; | ||
import { back, setActiveModal, setActivePanel, setActivePopout, setActiveViewPanel, setBackHandlerOptions, setDefaultBackHandlerOptions, _setActiveModal, _setActivePanel, _setActivePopout, _setActiveView } from "./router"; | ||
import { back, setActiveModal, setActivePanel, setActivePopout, setActiveViewPanel, _setActiveModal, _setActivePanel, _setActivePopout, _setActiveView } from "./router"; | ||
import { createCatchBackBrowserRouteMiddleware, createDisableBackBrowserRouteMiddleware, createRouteMiddleware, useInitRouter, useRouter } from "./useRoutes"; | ||
export { createCatchBackBrowserRouteMiddleware, setBackHandlerOptions, useRouter, blumRouter, useInitRouter, createDisableBackBrowserRouteMiddleware, createRouteMiddleware, setActiveModal, setActiveViewPanel, setActivePanel, setActivePopout, setDefaultBackHandlerOptions, back, _setActiveView, _setActivePanel, _setActiveModal, _setActivePopout, }; | ||
export { createCatchBackBrowserRouteMiddleware, useRouter, blumRouter, useInitRouter, createDisableBackBrowserRouteMiddleware, createRouteMiddleware, setActiveModal, setActiveViewPanel, setActivePanel, setActivePopout, back, _setActiveView, _setActivePanel, _setActiveModal, _setActivePopout, }; |
@@ -1,6 +0,25 @@ | ||
import V, { useEffect as et } from "react"; | ||
const x = { | ||
import M, { useEffect as Ze } from "react"; | ||
const O = { | ||
isDispatchChangeStateEventBeforeMiddleware: !1, | ||
isDispatchChangeStateEventAfterMiddleware: !0, | ||
beforeBackHandledCallback: null, | ||
isBackFromBrowser: !0, | ||
afterBackHandledCallback: null, | ||
subscribers: [], | ||
setDefaultBackHandlerOptions() { | ||
this.setBackHandlerOptions({ | ||
isDispatchChangeStateEventAfterMiddleware: !0, | ||
isDispatchChangeStateEventBeforeMiddleware: !1, | ||
beforeBackHandledCallback: null, | ||
afterBackHandledCallback: null, | ||
isBackFromBrowser: !0 | ||
}); | ||
}, | ||
setBackHandlerOptions(e) { | ||
Object.keys(e).forEach((t) => { | ||
e.hasOwnProperty(t) && (O[t] = e[t]); | ||
}), e.hasOwnProperty("beforeBackHandledCallback") && (O.beforeBackHandledCallback = e.beforeBackHandledCallback), e.hasOwnProperty("afterBackHandledCallback") && (O.afterBackHandledCallback = e.afterBackHandledCallback), e.hasOwnProperty("isDispatchChangeStateEventAfterMiddleware") && (O.isDispatchChangeStateEventAfterMiddleware = e.isDispatchChangeStateEventAfterMiddleware), e.hasOwnProperty("isDispatchChangeStateEventBeforeMiddleware") && (O.isDispatchChangeStateEventBeforeMiddleware = e.isDispatchChangeStateEventBeforeMiddleware), e.hasOwnProperty("isBackFromBrowser") && (O.isBackFromBrowser = e.isBackFromBrowser); | ||
}, | ||
historyPush(e) { | ||
const { view: t, panel: r, modal: n, popout: i } = window.history.state ?? { | ||
const { view: t, panel: r, modal: n, popout: o } = window.history.state ?? { | ||
view: void 0, | ||
@@ -15,3 +34,3 @@ panel: void 0, | ||
modal: e.hasOwnProperty("modal") ? e.modal : n, | ||
popout: e.hasOwnProperty("popout") ? e.popout : i | ||
popout: e.hasOwnProperty("popout") ? e.popout : o | ||
}); | ||
@@ -38,22 +57,12 @@ }, | ||
} | ||
}, fr = (e) => { | ||
e && O.setBackHandlerOptions(e), (!e || !e.hasOwnProperty("isBackFromBrowser")) && O.setBackHandlerOptions({ isBackFromBrowser: !1 }), history.back(); | ||
}, dr = (e) => { | ||
O.historyPush({ view: e.view, panel: e.panel }); | ||
}, pr = (e) => { | ||
e && gt(e), window.blumRouter.isBackFromBrowser = !1, window.history.back(); | ||
}, gt = ({ beforeBackHandledCallback: e, afterBackHandledCallback: t, isDispatchChangeStateEventAfterMiddleware: r, isDispatchChangeStateEventBeforeMiddleware: n }) => { | ||
e && (window.blumRouter.beforeBackHandledCallback = e), t && (window.blumRouter.afterBackHandledCallback = t), typeof r == "boolean" && (window.blumRouter.isDispatchChangeStateEventAfterMiddleware = r), typeof n == "boolean" && (window.blumRouter.isDispatchChangeStateEventBeforeMiddleware = n); | ||
}, $e = () => { | ||
window.blumRouter = { | ||
isBackFromBrowser: !0, | ||
beforeBackHandledCallback: null, | ||
afterBackHandledCallback: null, | ||
isDispatchChangeStateEventBeforeMiddleware: !1, | ||
isDispatchChangeStateEventAfterMiddleware: !0 | ||
}; | ||
O.historyPush({ panel: e }); | ||
}, vr = (e) => { | ||
x.historyPush({ view: e.view, panel: e.panel }); | ||
O.historyPush({ modal: e }); | ||
}, hr = (e) => { | ||
x.historyPush({ panel: e }); | ||
}, mr = (e) => { | ||
x.historyPush({ modal: e }); | ||
}, Sr = (e) => { | ||
x.historyPush({ popout: e }); | ||
O.historyPush({ popout: e }); | ||
}; | ||
@@ -64,75 +73,75 @@ function yt(e, t) { | ||
} | ||
function A(e, t) { | ||
function L(e, t) { | ||
e.forEach(t); | ||
} | ||
function W(e, t) { | ||
function j(e, t) { | ||
if (!e) | ||
throw Error(t); | ||
} | ||
function P({ node: e = [], from: t, source: r, parent: n = t || r, to: i, target: s, child: o = i || s, scope: p = {}, meta: w = {}, family: c = { type: "regular" }, regional: S } = {}) { | ||
let l = ie(n), d = ie(c.links), f = ie(c.owners), a = []; | ||
A(e, (v) => v && M(a, v)); | ||
let u = { id: Ct(), seq: a, next: ie(o), meta: w, scope: p, family: { type: c.type || "crosslink", links: d, owners: f } }; | ||
return A(d, (v) => M(ce(v), u)), A(f, (v) => M(fe(v), u)), A(l, (v) => M(v.next, u)), S && z && at(J(z), [u]), u; | ||
function P({ node: e = [], from: t, source: r, parent: n = t || r, to: o, target: s, child: a = o || s, scope: p = {}, meta: g = {}, family: c = { type: "regular" }, regional: S } = {}) { | ||
let u = oe(n), d = oe(c.links), f = oe(c.owners), i = []; | ||
L(e, (v) => v && V(i, v)); | ||
let l = { id: Ct(), seq: i, next: oe(a), meta: g, scope: p, family: { type: c.type || "crosslink", links: d, owners: f } }; | ||
return L(d, (v) => V(ce(v), l)), L(f, (v) => V(fe(v), l)), L(u, (v) => V(v.next, l)), S && z && ot(J(z), [l]), l; | ||
} | ||
function tt(e, t, r) { | ||
let n, i = B, s = null, o = b; | ||
if (e.target && (t = e.params, r = e.defer, n = e.meta, i = "page" in e ? e.page : i, e.stack && (s = e.stack), o = oe(e) || o, e = e.target), o && b && o !== b && (b = null), Array.isArray(e)) | ||
for (let a = 0; a < e.length; a++) | ||
T("pure", i, D(e[a]), s, t[a], o, n); | ||
function et(e, t, r) { | ||
let n, o = D, s = null, a = b; | ||
if (e.target && (t = e.params, r = e.defer, n = e.meta, o = "page" in e ? e.page : o, e.stack && (s = e.stack), a = ae(e) || a, e = e.target), a && b && a !== b && (b = null), Array.isArray(e)) | ||
for (let i = 0; i < e.length; i++) | ||
H("pure", o, x(e[i]), s, t[i], a, n); | ||
else | ||
T("pure", i, D(e), s, t, o, n); | ||
if (r && !ae) | ||
H("pure", o, x(e), s, t, a, n); | ||
if (r && !ie) | ||
return; | ||
let p, w, c, S, l, d, f = { isRoot: ae, currentPage: B, scope: b, isWatch: ge, isPure: se }; | ||
ae = 0; | ||
let p, g, c, S, u, d, f = { isRoot: ie, currentPage: D, scope: b, isWatch: _e, isPure: se }; | ||
ie = 0; | ||
e: | ||
for (; S = $t(); ) { | ||
let { idx: a, stack: u, type: v } = S; | ||
c = u.node, B = l = u.page, b = oe(u), l ? d = l.reg : b && (d = b.reg); | ||
let R = !!l, L = !!b, y = { fail: 0, scope: c.scope }; | ||
p = w = 0; | ||
for (let h = a; h < c.seq.length && !p; h++) { | ||
let g = c.seq[h]; | ||
if (g.order) { | ||
let { priority: m, barrierID: _ } = g.order, E = _ ? l ? `${l.fullID}_${_}` : _ : 0; | ||
if (h !== a || v !== m) { | ||
_ ? _e.has(E) || (_e.add(E), Le(h, u, m, _)) : Le(h, u, m); | ||
for (; S = Tt(); ) { | ||
let { idx: i, stack: l, type: v } = S; | ||
c = l.node, D = u = l.page, b = ae(l), u ? d = u.reg : b && (d = b.reg); | ||
let B = !!u, A = !!b, w = { fail: 0, scope: c.scope }; | ||
p = g = 0; | ||
for (let h = i; h < c.seq.length && !p; h++) { | ||
let _ = c.seq[h]; | ||
if (_.order) { | ||
let { priority: m, barrierID: y } = _.order, E = y ? u ? `${u.fullID}_${y}` : y : 0; | ||
if (h !== i || v !== m) { | ||
y ? ye.has(E) || (ye.add(E), Ce(h, l, m, y)) : Ce(h, l, m); | ||
continue e; | ||
} | ||
_ && _e.delete(E); | ||
y && ye.delete(E); | ||
} | ||
switch (g.type) { | ||
switch (_.type) { | ||
case "mov": { | ||
let _, E = g.data; | ||
let y, E = _.data; | ||
switch (E.from) { | ||
case X: | ||
_ = J(u); | ||
y = J(l); | ||
break; | ||
case "a": | ||
case "b": | ||
_ = u[E.from]; | ||
y = l[E.from]; | ||
break; | ||
case "value": | ||
_ = E.store; | ||
y = E.store; | ||
break; | ||
case "store": | ||
if (d && !d[E.store.id]) | ||
if (R) { | ||
let O = lt(l, E.store.id); | ||
u.page = l = O, O ? d = O.reg : L ? (G(b, E.store, 0, 1, E.softRead), d = b.reg) : d = void 0; | ||
if (B) { | ||
let k = lt(u, E.store.id); | ||
l.page = u = k, k ? d = k.reg : A ? (G(b, E.store, 0, 1, E.softRead), d = b.reg) : d = void 0; | ||
} else | ||
L && G(b, E.store, 0, 1, E.softRead); | ||
_ = ut(d && d[E.store.id] || E.store); | ||
A && G(b, E.store, 0, 1, E.softRead); | ||
y = st(d && d[E.store.id] || E.store); | ||
} | ||
switch (E.to) { | ||
case X: | ||
u.value = _; | ||
l.value = y; | ||
break; | ||
case "a": | ||
case "b": | ||
u[E.to] = _; | ||
l[E.to] = y; | ||
break; | ||
case "store": | ||
Ht(l, b, c, E.target).current = _; | ||
It(u, b, c, E.target).current = y; | ||
} | ||
@@ -142,20 +151,20 @@ break; | ||
case "compute": | ||
let m = g.data; | ||
let m = _.data; | ||
if (m.fn) { | ||
ge = k(c, "op") === "watch", se = m.pure; | ||
let _ = m.safe ? (0, m.fn)(J(u), y.scope, u) : Wt(y, m.fn, u); | ||
m.filter ? w = !_ : u.value = _, ge = f.isWatch, se = f.isPure; | ||
_e = C(c, "op") === "watch", se = m.pure; | ||
let y = m.safe ? (0, m.fn)(J(l), w.scope, l) : $t(w, m.fn, l); | ||
m.filter ? g = !y : l.value = y, _e = f.isWatch, se = f.isPure; | ||
} | ||
} | ||
p = y.fail || w; | ||
p = w.fail || g; | ||
} | ||
if (!p) { | ||
let h = J(u), g = oe(u); | ||
if (A(c.next, (m) => { | ||
T("child", l, m, u, h, g); | ||
}), g) { | ||
k(c, "needFxCounter") && T("child", l, g.fxCount, u, h, g), k(c, "storeChange") && T("child", l, g.storeChange, u, h, g), k(c, "warnSerialize") && T("child", l, g.warnSerializeNode, u, h, g); | ||
let m = g.additionalLinks[c.id]; | ||
m && A(m, (_) => { | ||
T("child", l, _, u, h, g); | ||
let h = J(l), _ = ae(l); | ||
if (L(c.next, (m) => { | ||
H("child", u, m, l, h, _); | ||
}), _) { | ||
C(c, "needFxCounter") && H("child", u, _.fxCount, l, h, _), C(c, "storeChange") && H("child", u, _.storeChange, l, h, _), C(c, "warnSerialize") && H("child", u, _.warnSerializeNode, l, h, _); | ||
let m = _.additionalLinks[c.id]; | ||
m && L(m, (y) => { | ||
H("child", u, y, l, h, _); | ||
}); | ||
@@ -165,15 +174,15 @@ } | ||
} | ||
ae = f.isRoot, B = f.currentPage, b = oe(f); | ||
ie = f.isRoot, D = f.currentPage, b = ae(f); | ||
} | ||
function Et(e, t) { | ||
let r, n, i = e; | ||
function _t(e, t) { | ||
let r, n, o = e; | ||
if (t) { | ||
let s = Ot(t); | ||
let s = Et(t); | ||
e.length === 0 ? (r = s.path, n = s.fullName) : (r = s.path.concat([e]), n = s.fullName.length === 0 ? e : s.fullName + "/" + e); | ||
} else | ||
r = e.length === 0 ? [] : [e], n = e; | ||
return { shortName: i, fullName: n, path: r }; | ||
return { shortName: o, fullName: n, path: r }; | ||
} | ||
function Y(e, ...t) { | ||
let r = it(); | ||
let r = at(); | ||
if (r) { | ||
@@ -185,85 +194,85 @@ let n = r.handlers[e]; | ||
} | ||
function C(e, t) { | ||
let r = te({ or: t, and: typeof e == "string" ? { name: e } : e }), n = (o, ...p) => (Z(!k(n, "derived"), "call of derived event", "createEvent"), Z(!se, "unit call from pure function", "operators like sample"), B ? ((w, c, S, l) => { | ||
let d = B, f = null; | ||
function R(e, t) { | ||
let r = te({ or: t, and: typeof e == "string" ? { name: e } : e }), n = (a, ...p) => (Z(!C(n, "derived"), "call of derived event", "createEvent"), Z(!se, "unit call from pure function", "operators like sample"), D ? ((g, c, S, u) => { | ||
let d = D, f = null; | ||
if (c) | ||
for (f = B; f && f.template !== c; ) | ||
f = j(f); | ||
Ue(f); | ||
let a = w.create(S, l); | ||
return Ue(d), a; | ||
})(n, i, o, p) : n.create(o, p)), i = it(), s = Object.assign(n, { graphite: P({ meta: dt("event", n, r), regional: 1 }), create: (o) => (tt({ target: n, params: o, scope: b }), o), watch: (o) => ft(n, o), map: (o) => ye(n, Q, o, [$()]), filter: (o) => ye(n, "filter", o.fn ? o : o.fn, [$(Me, 1)]), filterMap: (o) => ye(n, "filterMap", o, [$(), ke((p) => !N(p), 1)]), prepend(o) { | ||
let p = C("* → " + n.shortName, { parent: j(n) }); | ||
return Y("eventPrepend", D(p)), Ne(p, n, [$()], "prepend", o), jt(n, p), p; | ||
for (f = D; f && f.template !== c; ) | ||
f = W(f); | ||
Fe(f); | ||
let i = g.create(S, u); | ||
return Fe(d), i; | ||
})(n, o, a, p) : n.create(a, p)), o = at(), s = Object.assign(n, { graphite: P({ meta: ft("event", n, r), regional: 1 }), create: (a) => (et({ target: n, params: a, scope: b }), a), watch: (a) => ct(n, a), map: (a) => we(n, Q, a, [N()]), filter: (a) => we(n, "filter", a.fn ? a : a.fn, [N(Ve, 1)]), filterMap: (a) => we(n, "filterMap", a, [N(), Be((p) => !I(p), 1)]), prepend(a) { | ||
let p = R("* → " + n.shortName, { parent: W(n) }); | ||
return Y("eventPrepend", x(p)), Ie(p, n, [N()], "prepend", a), zt(n, p), p; | ||
} }); | ||
return r != null && r.domain && r.domain.hooks.event(s), s; | ||
} | ||
function He(e, t, r, n) { | ||
return Vt(r, t, "first argument"), W(I(n), "second argument should be a function"), Z(!k(e, "derived"), `${t} in derived store`, `${t} in store created via createStore`), A(Array.isArray(r) ? r : [r], (i) => { | ||
e.off(i), le(e).set(i, ct(pt(i, e, "on", Dt, n))); | ||
function Ne(e, t, r, n) { | ||
return Rt(r, t, "first argument"), j(T(n), "second argument should be a function"), Z(!C(e, "derived"), `${t} in derived store`, `${t} in store created via createStore`), L(Array.isArray(r) ? r : [r], (o) => { | ||
e.off(o), ue(e).set(o, ut(dt(o, e, "on", Dt, n))); | ||
}), e; | ||
} | ||
function rt(e, t) { | ||
let r = te(t), n = It(e), i = C({ named: "updates", derived: 1 }); | ||
function tt(e, t) { | ||
let r = te(t), n = Ht(e), o = R({ named: "updates", derived: 1 }); | ||
Y("storeBase", n); | ||
let s = n.id, o = { subscribers: /* @__PURE__ */ new Map(), updates: i, defaultState: e, stateRef: n, getState() { | ||
let a, u = n; | ||
if (B) { | ||
let v = B; | ||
let s = n.id, a = { subscribers: /* @__PURE__ */ new Map(), updates: o, defaultState: e, stateRef: n, getState() { | ||
let i, l = n; | ||
if (D) { | ||
let v = D; | ||
for (; v && !v.reg[s]; ) | ||
v = j(v); | ||
v && (a = v); | ||
v = W(v); | ||
v && (i = v); | ||
} | ||
return !a && b && (G(b, n, 1), a = b), a && (u = a.reg[s]), ut(u); | ||
}, setState: (a) => tt({ target: o, params: a, defer: 1, scope: b }), reset: (...a) => (A(a, (u) => He(o, ".reset", u, () => o.defaultState)), o), on: (a, u) => He(o, ".on", a, u), off(a) { | ||
let u = le(o).get(a); | ||
return u && (u(), le(o).delete(a)), o; | ||
}, map(a, u) { | ||
let v, R; | ||
K(a) && (v = a, a = a.fn), Z(N(u), "second argument of store.map", "updateFilter"); | ||
let L = o.getState(); | ||
N(L) || (R = a(L, u)); | ||
let y = rt(R, { name: `${o.shortName} → *`, derived: 1, and: v }), h = pt(o, y, Q, Ge, a); | ||
return Nt(ue(y), { type: Q, fn: a, from: n }), ue(y).noInit = 1, Y("storeMap", n, h), y; | ||
}, watch(a, u) { | ||
if (!u || !xe(a)) { | ||
let v = ft(o, a); | ||
return Y("storeWatch", n, a) || a(o.getState()), v; | ||
return !i && b && (G(b, n, 1), i = b), i && (l = i.reg[s]), st(l); | ||
}, setState: (i) => et({ target: a, params: i, defer: 1, scope: b }), reset: (...i) => (L(i, (l) => Ne(a, ".reset", l, () => a.defaultState)), a), on: (i, l) => Ne(a, ".on", i, l), off(i) { | ||
let l = ue(a).get(i); | ||
return l && (l(), ue(a).delete(i)), a; | ||
}, map(i, l) { | ||
let v, B; | ||
F(i) && (v = i, i = i.fn), Z(I(l), "second argument of store.map", "updateFilter"); | ||
let A = a.getState(); | ||
I(A) || (B = i(A, l)); | ||
let w = tt(B, { name: `${a.shortName} → *`, derived: 1, and: v }), h = dt(a, w, Q, We, i); | ||
return Pt(le(w), { type: Q, fn: i, from: n }), le(w).noInit = 1, Y("storeMap", n, h), w; | ||
}, watch(i, l) { | ||
if (!l || !De(i)) { | ||
let v = ct(a, i); | ||
return Y("storeWatch", n, i) || i(a.getState()), v; | ||
} | ||
return W(I(u), "second argument should be a function"), a.watch((v) => u(o.getState(), v)); | ||
} }, p = dt("store", o, r), w = o.defaultConfig.updateFilter; | ||
o.graphite = P({ scope: { state: n, fn: w }, node: [ke((a, u, v) => (v.scope && !v.scope.reg[n.id] && (v.b = 1), a)), Tt(n), ke((a, u, { a: v, b: R }) => !N(a) && (a !== v || R), 1), w && $(Ge, 1), de({ from: X, target: n })], child: i, meta: p, regional: 1 }); | ||
let c = k(o, "serialize"), S = k(o, "derived"), l = c === "ignore", d = !c || l ? 0 : c, f = k(o, "sid"); | ||
return f && (l || ze(o, "storeChange", 1), n.sid = f, d && (n.meta = { ...n == null ? void 0 : n.meta, serialize: d })), f || l || S || ze(o, "warnSerialize", 1), W(S || !N(e), "current state can't be undefined, use null instead"), at(o, [i]), r != null && r.domain && r.domain.hooks.store(o), S || (o.reinit = C(), o.reset(o.reinit)), o; | ||
return j(T(l), "second argument should be a function"), i.watch((v) => l(a.getState(), v)); | ||
} }, p = ft("store", a, r), g = a.defaultConfig.updateFilter; | ||
a.graphite = P({ scope: { state: n, fn: g }, node: [Be((i, l, v) => (v.scope && !v.scope.reg[n.id] && (v.b = 1), i)), xt(n), Be((i, l, { a: v, b: B }) => !I(i) && (i !== v || B), 1), g && N(We, 1), de({ from: X, target: n })], child: o, meta: p, regional: 1 }); | ||
let c = C(a, "serialize"), S = C(a, "derived"), u = c === "ignore", d = !c || u ? 0 : c, f = C(a, "sid"); | ||
return f && (u || $e(a, "storeChange", 1), n.sid = f, d && (n.meta = { ...n == null ? void 0 : n.meta, serialize: d })), f || u || S || $e(a, "warnSerialize", 1), j(S || !I(e), "current state can't be undefined, use null instead"), ot(a, [o]), r != null && r.domain && r.domain.hooks.store(a), S || (a.reinit = R(), a.reset(a.reinit)), a; | ||
} | ||
let bt = typeof Symbol < "u" && Symbol.observable || "@@observable", Q = "map", X = "stack", D = (e) => e.graphite || e, ce = (e) => e.family.owners, fe = (e) => e.family.links, ue = (e) => e.stateRef, J = (e) => e.value, le = (e) => e.subscribers, j = (e) => e.parent, oe = (e) => e.scope, k = (e, t) => D(e).meta[t], ze = (e, t, r) => D(e).meta[t] = r, Ot = (e) => e.compositeName, xe = (e) => (I(e) || K(e)) && "kind" in e; | ||
const ne = (e) => (t) => xe(t) && t.kind === e; | ||
let Ve = ne("store"), Rt = ne("event"), We = ne("effect"), nt = ne("domain"), kt = ne("scope"); | ||
var Lt = { __proto__: null, unit: xe, store: Ve, event: Rt, effect: We, domain: nt, scope: kt, attached: (e) => We(e) && k(e, "attached") == 1 }; | ||
let we = (e, t) => { | ||
let wt = typeof Symbol < "u" && Symbol.observable || "@@observable", Q = "map", X = "stack", x = (e) => e.graphite || e, ce = (e) => e.family.owners, fe = (e) => e.family.links, le = (e) => e.stateRef, J = (e) => e.value, ue = (e) => e.subscribers, W = (e) => e.parent, ae = (e) => e.scope, C = (e, t) => x(e).meta[t], $e = (e, t, r) => x(e).meta[t] = r, Et = (e) => e.compositeName, De = (e) => (T(e) || F(e)) && "kind" in e; | ||
const ne = (e) => (t) => De(t) && t.kind === e; | ||
let Me = ne("store"), Ot = ne("event"), ze = ne("effect"), rt = ne("domain"), bt = ne("scope"); | ||
var kt = { __proto__: null, unit: De, store: Me, event: Ot, effect: ze, domain: rt, scope: bt, attached: (e) => ze(e) && C(e, "attached") == 1 }; | ||
let ge = (e, t) => { | ||
let r = e.indexOf(t); | ||
r !== -1 && e.splice(r, 1); | ||
}, M = (e, t) => e.push(t), Z = (e, t, r) => !e && console.error(`${t} is deprecated${r ? `, use ${r} instead` : ""}`); | ||
const De = () => { | ||
}, V = (e, t) => e.push(t), Z = (e, t, r) => !e && console.error(`${t} is deprecated${r ? `, use ${r} instead` : ""}`); | ||
const xe = () => { | ||
let e = 0; | ||
return () => "" + ++e; | ||
}; | ||
let At = De(), ot = De(), Ct = De(), z = null, it = () => z, Bt = (e) => (e && z && z.sidRoot && (e = `${z.sidRoot}|${e}`), e), at = (e, t) => { | ||
let r = D(e); | ||
A(t, (n) => { | ||
let i = D(n); | ||
r.family.type !== "domain" && (i.family.type = "crosslink"), M(ce(i), r), M(fe(r), i); | ||
let Bt = xe(), nt = xe(), Ct = xe(), z = null, at = () => z, At = (e) => (e && z && z.sidRoot && (e = `${z.sidRoot}|${e}`), e), ot = (e, t) => { | ||
let r = x(e); | ||
L(t, (n) => { | ||
let o = x(n); | ||
r.family.type !== "domain" && (o.family.type = "crosslink"), V(ce(o), r), V(fe(r), o); | ||
}); | ||
}, ie = (e = []) => (Array.isArray(e) ? e : [e]).flat().map(D), K = (e) => typeof e == "object" && e !== null, I = (e) => typeof e == "function", N = (e) => e === void 0, xt = (e) => W(K(e) || I(e), "expect first argument be an object"); | ||
const je = (e, t, r, n) => W(!(!K(e) && !I(e) || !("family" in e) && !("graphite" in e)), `${t}: expect ${r} to be a unit (store, event or effect)${n}`); | ||
let Vt = (e, t, r) => { | ||
Array.isArray(e) ? A(e, (n, i) => je(n, t, `${i} item of ${r}`, "")) : je(e, t, r, " or array of units"); | ||
}, Ge = (e, { fn: t }, { a: r }) => t(e, r), Dt = (e, { fn: t }, { a: r }) => t(r, e), Me = (e, { fn: t }) => t(e); | ||
const st = (e, t, r, n) => { | ||
let i = { id: ot(), type: e, data: t }; | ||
return r && (i.order = { priority: r }, n && (i.order.barrierID = ++Mt)), i; | ||
}, oe = (e = []) => (Array.isArray(e) ? e : [e]).flat().map(x), F = (e) => typeof e == "object" && e !== null, T = (e) => typeof e == "function", I = (e) => e === void 0, Lt = (e) => j(F(e) || T(e), "expect first argument be an object"); | ||
const je = (e, t, r, n) => j(!(!F(e) && !T(e) || !("family" in e) && !("graphite" in e)), `${t}: expect ${r} to be a unit (store, event or effect)${n}`); | ||
let Rt = (e, t, r) => { | ||
Array.isArray(e) ? L(e, (n, o) => je(n, t, `${o} item of ${r}`, "")) : je(e, t, r, " or array of units"); | ||
}, We = (e, { fn: t }, { a: r }) => t(e, r), Dt = (e, { fn: t }, { a: r }) => t(r, e), Ve = (e, { fn: t }) => t(e); | ||
const it = (e, t, r, n) => { | ||
let o = { id: nt(), type: e, data: t }; | ||
return r && (o.order = { priority: r }, n && (o.order.barrierID = ++Mt)), o; | ||
}; | ||
let Mt = 0, de = ({ from: e = "store", store: t, target: r, to: n = r ? "store" : X, batch: i, priority: s }) => st("mov", { from: e, store: t, to: n, target: r }, s, i), ee = ({ fn: e, batch: t, priority: r, safe: n = 0, filter: i = 0, pure: s = 0 }) => st("compute", { fn: e, safe: n, filter: i, pure: s }, r, t), Te = ({ fn: e }) => ee({ fn: e, priority: "effect" }), ke = (e, t, r) => ee({ fn: e, safe: 1, filter: t, priority: r && "effect" }), Tt = (e, t, r) => de({ store: e, to: t ? X : "a", priority: r && "sampler", batch: 1 }), $ = (e = Me, t) => ee({ fn: e, pure: 1, filter: t }), Pt = { mov: de, compute: ee, filter: ({ fn: e, pure: t }) => ee({ fn: e, filter: 1, pure: t }), run: Te }, It = (e) => ({ id: ot(), current: e }), ut = ({ current: e }) => e, Nt = (e, t) => { | ||
e.before || (e.before = []), M(e.before, t); | ||
}, H = null; | ||
let Mt = 0, de = ({ from: e = "store", store: t, target: r, to: n = r ? "store" : X, batch: o, priority: s }) => it("mov", { from: e, store: t, to: n, target: r }, s, o), ee = ({ fn: e, batch: t, priority: r, safe: n = 0, filter: o = 0, pure: s = 0 }) => it("compute", { fn: e, safe: n, filter: o, pure: s }, r, t), He = ({ fn: e }) => ee({ fn: e, priority: "effect" }), Be = (e, t, r) => ee({ fn: e, safe: 1, filter: t, priority: r && "effect" }), xt = (e, t, r) => de({ store: e, to: t ? X : "a", priority: r && "sampler", batch: 1 }), N = (e = Ve, t) => ee({ fn: e, pure: 1, filter: t }), Vt = { mov: de, compute: ee, filter: ({ fn: e, pure: t }) => ee({ fn: e, filter: 1, pure: t }), run: He }, Ht = (e) => ({ id: nt(), current: e }), st = ({ current: e }) => e, Pt = (e, t) => { | ||
e.before || (e.before = []), V(e.before, t); | ||
}, $ = null; | ||
const Pe = (e, t) => { | ||
@@ -276,14 +285,14 @@ if (!e) | ||
return (e.v.type === t.v.type && e.v.id > t.v.id || Ae(e.v.type) > Ae(t.v.type)) && (r = e, e = t, t = r), r = Pe(e.r, t), e.r = e.l, e.l = r, e; | ||
}, Ie = []; | ||
let Ke = 0; | ||
for (; Ke < 6; ) | ||
M(Ie, { first: null, last: null, size: 0 }), Ke += 1; | ||
const $t = () => { | ||
}, Te = []; | ||
let Ge = 0; | ||
for (; Ge < 6; ) | ||
V(Te, { first: null, last: null, size: 0 }), Ge += 1; | ||
const Tt = () => { | ||
for (let e = 0; e < 6; e++) { | ||
let t = Ie[e]; | ||
let t = Te[e]; | ||
if (t.size > 0) { | ||
if (e === 3 || e === 4) { | ||
t.size -= 1; | ||
let n = H.v; | ||
return H = Pe(H.l, H.r), n; | ||
let n = $.v; | ||
return $ = Pe($.l, $.r), n; | ||
} | ||
@@ -295,5 +304,5 @@ t.size === 1 && (t.last = null); | ||
} | ||
}, T = (e, t, r, n, i, s, o) => Le(0, { a: null, b: null, node: r, parent: n, value: i, page: t, scope: s, meta: o }, e), Le = (e, t, r, n = 0) => { | ||
let i = Ae(r), s = Ie[i], o = { v: { idx: e, stack: t, type: r, id: n }, l: null, r: null }; | ||
i === 3 || i === 4 ? H = Pe(H, o) : (s.size === 0 ? s.first = o : s.last.r = o, s.last = o), s.size += 1; | ||
}, H = (e, t, r, n, o, s, a) => Ce(0, { a: null, b: null, node: r, parent: n, value: o, page: t, scope: s, meta: a }, e), Ce = (e, t, r, n = 0) => { | ||
let o = Ae(r), s = Te[o], a = { v: { idx: e, stack: t, type: r, id: n }, l: null, r: null }; | ||
o === 3 || o === 4 ? $ = Pe($, a) : (s.size === 0 ? s.first = a : s.last.r = a, s.last = a), s.size += 1; | ||
}, Ae = (e) => { | ||
@@ -316,5 +325,5 @@ switch (e) { | ||
} | ||
}, _e = /* @__PURE__ */ new Set(); | ||
let b, ae = 1, ge = 0, se = 0, B = null, Ue = (e) => { | ||
B = e; | ||
}, ye = /* @__PURE__ */ new Set(); | ||
let b, ie = 1, _e = 0, se = 0, D = null, Fe = (e) => { | ||
D = e; | ||
}; | ||
@@ -324,3 +333,3 @@ const lt = (e, t) => { | ||
for (; e && !e.reg[t]; ) | ||
e = j(e); | ||
e = W(e); | ||
if (e) | ||
@@ -331,18 +340,18 @@ return e; | ||
}; | ||
let Ht = (e, t, r, n, i) => { | ||
let It = (e, t, r, n, o) => { | ||
let s = lt(e, n.id); | ||
return s ? s.reg[n.id] : t ? (G(t, n, i), t.reg[n.id]) : n; | ||
return s ? s.reg[n.id] : t ? (G(t, n, o), t.reg[n.id]) : n; | ||
}; | ||
const zt = (e) => e; | ||
let G = (e, t, r, n, i) => { | ||
const Nt = (e) => e; | ||
let G = (e, t, r, n, o) => { | ||
var s; | ||
let o = e.reg, p = t.sid, w = t == null || (s = t.meta) === null || s === void 0 ? void 0 : s.serialize; | ||
if (o[t.id]) | ||
let a = e.reg, p = t.sid, g = t == null || (s = t.meta) === null || s === void 0 ? void 0 : s.serialize; | ||
if (a[t.id]) | ||
return; | ||
let c = { id: t.id, current: t.current, meta: t.meta }; | ||
if (p && p in e.sidValuesMap && !(p in e.sidIdMap)) | ||
c.current = (e.fromSerialize && w !== "ignore" && (w == null ? void 0 : w.read) || zt)(e.sidValuesMap[p]); | ||
else if (t.before && !i) { | ||
let S = 0, l = r || !t.noInit || n; | ||
A(t.before, (d) => { | ||
c.current = (e.fromSerialize && g !== "ignore" && (g == null ? void 0 : g.read) || Nt)(e.sidValuesMap[p]); | ||
else if (t.before && !o) { | ||
let S = 0, u = r || !t.noInit || n; | ||
L(t.before, (d) => { | ||
switch (d.type) { | ||
@@ -353,4 +362,4 @@ case Q: { | ||
f && G(e, f, r, n); | ||
let a = f && o[f.id].current; | ||
l && (c.current = d.fn ? d.fn(a) : a); | ||
let i = f && a[f.id].current; | ||
u && (c.current = d.fn ? d.fn(i) : i); | ||
} | ||
@@ -360,9 +369,9 @@ break; | ||
case "field": | ||
S || (S = 1, c.current = Array.isArray(c.current) ? [...c.current] : { ...c.current }), G(e, d.from, r, n), l && (c.current[d.field] = o[o[d.from.id].id].current); | ||
S || (S = 1, c.current = Array.isArray(c.current) ? [...c.current] : { ...c.current }), G(e, d.from, r, n), u && (c.current[d.field] = a[a[d.from.id].id].current); | ||
} | ||
}); | ||
} | ||
p && (e.sidIdMap[p] = t.id), o[t.id] = c; | ||
p && (e.sidIdMap[p] = t.id), a[t.id] = c; | ||
}; | ||
const Wt = (e, t, r) => { | ||
const $t = (e, t, r) => { | ||
try { | ||
@@ -374,48 +383,48 @@ return t(J(r), e.scope, r); | ||
}; | ||
let te = (e, t = {}) => (K(e) && (te(e.or, t), yt(e, (r, n) => { | ||
N(r) || n === "or" || n === "and" || (t[n] = r); | ||
let te = (e, t = {}) => (F(e) && (te(e.or, t), yt(e, (r, n) => { | ||
I(r) || n === "or" || n === "and" || (t[n] = r); | ||
}), te(e.and, t)), t); | ||
const qe = (e, t) => { | ||
we(e.next, t), we(ce(e), t), we(fe(e), t); | ||
}, Ce = (e, t, r) => { | ||
const Ke = (e, t) => { | ||
ge(e.next, t), ge(ce(e), t), ge(fe(e), t); | ||
}, Le = (e, t, r) => { | ||
let n; | ||
e.next.length = 0, e.seq.length = 0, e.scope = null; | ||
let i = fe(e); | ||
for (; n = i.pop(); ) | ||
qe(n, e), (t || r && k(e, "op") !== "sample" || n.family.type === "crosslink") && Ce(n, t, k(n, "op") !== "on" && r); | ||
for (i = ce(e); n = i.pop(); ) | ||
qe(n, e), r && n.family.type === "crosslink" && Ce(n, t, k(n, "op") !== "on" && r); | ||
}, F = (e) => e.clear(); | ||
let Be = (e, { deep: t } = {}) => { | ||
let o = fe(e); | ||
for (; n = o.pop(); ) | ||
Ke(n, e), (t || r && C(e, "op") !== "sample" || n.family.type === "crosslink") && Le(n, t, C(n, "op") !== "on" && r); | ||
for (o = ce(e); n = o.pop(); ) | ||
Ke(n, e), r && n.family.type === "crosslink" && Le(n, t, C(n, "op") !== "on" && r); | ||
}, q = (e) => e.clear(); | ||
let Re = (e, { deep: t } = {}) => { | ||
let r = 0; | ||
if (e.ownerSet && e.ownerSet.delete(e), Ve(e)) | ||
F(le(e)); | ||
else if (nt(e)) { | ||
if (e.ownerSet && e.ownerSet.delete(e), Me(e)) | ||
q(ue(e)); | ||
else if (rt(e)) { | ||
r = 1; | ||
let n = e.history; | ||
F(n.events), F(n.effects), F(n.stores), F(n.domains); | ||
q(n.events), q(n.effects), q(n.stores), q(n.domains); | ||
} | ||
Ce(D(e), !!t, r); | ||
}, ct = (e) => { | ||
let t = () => Be(e); | ||
Le(x(e), !!t, r); | ||
}, ut = (e) => { | ||
let t = () => Re(e); | ||
return t.unsubscribe = t, t; | ||
}, Ne = (e, t, r, n, i) => P({ node: r, parent: e, child: t, scope: { fn: i }, meta: { op: n }, family: { owners: [e, t], links: t }, regional: 1 }), ft = (e, t) => (W(I(t), ".watch argument should be a function"), ct(P({ scope: { fn: t }, node: [Te({ fn: Me })], parent: e, meta: { op: "watch" }, family: { owners: e }, regional: 1 }))), jt = (e, t, r = "event") => { | ||
j(e) && j(e).hooks[r](t); | ||
}, dt = (e, t, r) => { | ||
let n = te(r), i = e === "domain", s = At(), { sid: o = null, named: p = null, domain: w = null, parent: c = w } = n, S = p || n.name || (i ? "" : s), l = Et(S, c), d = { op: t.kind = e, name: t.shortName = S, sid: t.sid = Bt(o), named: p, unitId: t.id = s, serialize: n.serialize, derived: n.derived, config: n }; | ||
return t.parent = c, t.compositeName = l, t.defaultConfig = n, t.thru = (f) => (Z(0, "thru", "js pipe"), f(t)), t.getType = () => l.fullName, !i && (t.subscribe = (f) => (xt(f), t.watch(I(f) ? f : (a) => f.next && f.next(a))), t[bt] = () => t), d; | ||
}, Ie = (e, t, r, n, o) => P({ node: r, parent: e, child: t, scope: { fn: o }, meta: { op: n }, family: { owners: [e, t], links: t }, regional: 1 }), ct = (e, t) => (j(T(t), ".watch argument should be a function"), ut(P({ scope: { fn: t }, node: [He({ fn: Ve })], parent: e, meta: { op: "watch" }, family: { owners: e }, regional: 1 }))), zt = (e, t, r = "event") => { | ||
W(e) && W(e).hooks[r](t); | ||
}, ft = (e, t, r) => { | ||
let n = te(r), o = e === "domain", s = Bt(), { sid: a = null, named: p = null, domain: g = null, parent: c = g } = n, S = p || n.name || (o ? "" : s), u = _t(S, c), d = { op: t.kind = e, name: t.shortName = S, sid: t.sid = At(a), named: p, unitId: t.id = s, serialize: n.serialize, derived: n.derived, config: n }; | ||
return t.parent = c, t.compositeName = u, t.defaultConfig = n, t.thru = (f) => (Z(0, "thru", "js pipe"), f(t)), t.getType = () => u.fullName, !o && (t.subscribe = (f) => (Lt(f), t.watch(T(f) ? f : (i) => f.next && f.next(i))), t[wt] = () => t), d; | ||
}; | ||
const ye = (e, t, r, n) => { | ||
let i; | ||
K(r) && (i = r, r = r.fn); | ||
let s = C({ name: `${e.shortName} → *`, derived: 1, and: i }); | ||
return Ne(e, s, n, t, r), s; | ||
}, pt = (e, t, r, n, i) => { | ||
let s = ue(t), o = de({ store: s, to: "a", priority: "read" }); | ||
r === Q && (o.data.softRead = 1); | ||
let p = [o, $(n)]; | ||
return Y("storeOnMap", s, p, Ve(e) && ue(e)), Ne(e, t, p, r, i); | ||
const we = (e, t, r, n) => { | ||
let o; | ||
F(r) && (o = r, r = r.fn); | ||
let s = R({ name: `${e.shortName} → *`, derived: 1, and: o }); | ||
return Ie(e, s, n, t, r), s; | ||
}, dt = (e, t, r, n, o) => { | ||
let s = le(t), a = de({ store: s, to: "a", priority: "read" }); | ||
r === Q && (a.data.softRead = 1); | ||
let p = [a, N(n)]; | ||
return Y("storeOnMap", s, p, Me(e) && le(e)), Ie(e, t, p, r, o); | ||
}; | ||
P({ node: [Te({ fn: ({ fn: e, value: t }) => e(t) })], meta: { op: "fx", fx: "sidechain" } }); | ||
const Gt = C(), Kt = C(), vt = C(), ht = C(), mt = C(), St = C(), Ut = C(), qt = rt({ | ||
P({ node: [He({ fn: ({ fn: e, value: t }) => e(t) })], meta: { op: "fx", fx: "sidechain" } }); | ||
const jt = R(), Wt = R(), pt = R(), vt = R(), ht = R(), mt = R(), Gt = R(), Ft = tt({ | ||
activeView: null, | ||
@@ -427,36 +436,36 @@ activePanel: null, | ||
isBackHandled: !0 | ||
}).on(Gt, (e, t) => ({ | ||
}).on(jt, (e, t) => ({ | ||
...e, | ||
activeView: t | ||
})).on(Kt, (e, t) => ({ | ||
})).on(Wt, (e, t) => ({ | ||
...e, | ||
activePanel: t | ||
})).on(ht, (e, t) => ({ | ||
})).on(vt, (e, t) => ({ | ||
...e, | ||
activeModal: t | ||
})).on(mt, (e, t) => ({ | ||
})).on(ht, (e, t) => ({ | ||
...e, | ||
activePopout: t | ||
})).on(St, (e) => ({ | ||
})).on(mt, (e) => ({ | ||
...e, | ||
isRouteInit: !0 | ||
})).on(vt, (e, { view: t, panel: r }) => ({ | ||
})).on(pt, (e, { view: t, panel: r }) => ({ | ||
...e, | ||
activeView: t, | ||
activePanel: r | ||
})).on(Ut, (e, t) => ({ | ||
})).on(Gt, (e, t) => ({ | ||
...e, | ||
isBackHandled: t | ||
})); | ||
function Ft(e) { | ||
function Kt(e) { | ||
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; | ||
} | ||
var Fe = {}, Yt = { | ||
var Ue = {}, Ut = { | ||
get exports() { | ||
return Fe; | ||
return Ue; | ||
}, | ||
set exports(e) { | ||
Fe = e; | ||
Ue = e; | ||
} | ||
}, Ee = {}, re = {}, Jt = { | ||
}, Ee = {}, re = {}, qt = { | ||
get exports() { | ||
@@ -468,3 +477,3 @@ return re; | ||
} | ||
}, be = {}; | ||
}, Oe = {}; | ||
/** | ||
@@ -479,28 +488,28 @@ * @license React | ||
*/ | ||
var Ye; | ||
function Qt() { | ||
if (Ye) | ||
return be; | ||
Ye = 1; | ||
var e = V; | ||
function t(l, d) { | ||
return l === d && (l !== 0 || 1 / l === 1 / d) || l !== l && d !== d; | ||
var qe; | ||
function Yt() { | ||
if (qe) | ||
return Oe; | ||
qe = 1; | ||
var e = M; | ||
function t(u, d) { | ||
return u === d && (u !== 0 || 1 / u === 1 / d) || u !== u && d !== d; | ||
} | ||
var r = typeof Object.is == "function" ? Object.is : t, n = e.useState, i = e.useEffect, s = e.useLayoutEffect, o = e.useDebugValue; | ||
function p(l, d) { | ||
var f = d(), a = n({ inst: { value: f, getSnapshot: d } }), u = a[0].inst, v = a[1]; | ||
var r = typeof Object.is == "function" ? Object.is : t, n = e.useState, o = e.useEffect, s = e.useLayoutEffect, a = e.useDebugValue; | ||
function p(u, d) { | ||
var f = d(), i = n({ inst: { value: f, getSnapshot: d } }), l = i[0].inst, v = i[1]; | ||
return s(function() { | ||
u.value = f, u.getSnapshot = d, w(u) && v({ inst: u }); | ||
}, [l, f, d]), i(function() { | ||
return w(u) && v({ inst: u }), l(function() { | ||
w(u) && v({ inst: u }); | ||
l.value = f, l.getSnapshot = d, g(l) && v({ inst: l }); | ||
}, [u, f, d]), o(function() { | ||
return g(l) && v({ inst: l }), u(function() { | ||
g(l) && v({ inst: l }); | ||
}); | ||
}, [l]), o(f), f; | ||
}, [u]), a(f), f; | ||
} | ||
function w(l) { | ||
var d = l.getSnapshot; | ||
l = l.value; | ||
function g(u) { | ||
var d = u.getSnapshot; | ||
u = u.value; | ||
try { | ||
var f = d(); | ||
return !r(l, f); | ||
return !r(u, f); | ||
} catch { | ||
@@ -510,9 +519,9 @@ return !0; | ||
} | ||
function c(l, d) { | ||
function c(u, d) { | ||
return d(); | ||
} | ||
var S = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? c : p; | ||
return be.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : S, be; | ||
return Oe.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : S, Oe; | ||
} | ||
var Oe = {}; | ||
var be = {}; | ||
/** | ||
@@ -527,36 +536,36 @@ * @license React | ||
*/ | ||
var Je; | ||
function Xt() { | ||
return Je || (Je = 1, process.env.NODE_ENV !== "production" && function() { | ||
var Ye; | ||
function Jt() { | ||
return Ye || (Ye = 1, process.env.NODE_ENV !== "production" && function() { | ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); | ||
var e = V, t = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
function r(y) { | ||
var e = M, t = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
function r(w) { | ||
{ | ||
for (var h = arguments.length, g = new Array(h > 1 ? h - 1 : 0), m = 1; m < h; m++) | ||
g[m - 1] = arguments[m]; | ||
n("error", y, g); | ||
for (var h = arguments.length, _ = new Array(h > 1 ? h - 1 : 0), m = 1; m < h; m++) | ||
_[m - 1] = arguments[m]; | ||
n("error", w, _); | ||
} | ||
} | ||
function n(y, h, g) { | ||
function n(w, h, _) { | ||
{ | ||
var m = t.ReactDebugCurrentFrame, _ = m.getStackAddendum(); | ||
_ !== "" && (h += "%s", g = g.concat([_])); | ||
var E = g.map(function(O) { | ||
return String(O); | ||
var m = t.ReactDebugCurrentFrame, y = m.getStackAddendum(); | ||
y !== "" && (h += "%s", _ = _.concat([y])); | ||
var E = _.map(function(k) { | ||
return String(k); | ||
}); | ||
E.unshift("Warning: " + h), Function.prototype.apply.call(console[y], console, E); | ||
E.unshift("Warning: " + h), Function.prototype.apply.call(console[w], console, E); | ||
} | ||
} | ||
function i(y, h) { | ||
return y === h && (y !== 0 || 1 / y === 1 / h) || y !== y && h !== h; | ||
function o(w, h) { | ||
return w === h && (w !== 0 || 1 / w === 1 / h) || w !== w && h !== h; | ||
} | ||
var s = typeof Object.is == "function" ? Object.is : i, o = e.useState, p = e.useEffect, w = e.useLayoutEffect, c = e.useDebugValue, S = !1, l = !1; | ||
function d(y, h, g) { | ||
var s = typeof Object.is == "function" ? Object.is : o, a = e.useState, p = e.useEffect, g = e.useLayoutEffect, c = e.useDebugValue, S = !1, u = !1; | ||
function d(w, h, _) { | ||
S || e.startTransition !== void 0 && (S = !0, r("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.")); | ||
var m = h(); | ||
if (!l) { | ||
var _ = h(); | ||
s(m, _) || (r("The result of getSnapshot should be cached to avoid an infinite loop"), l = !0); | ||
if (!u) { | ||
var y = h(); | ||
s(m, y) || (r("The result of getSnapshot should be cached to avoid an infinite loop"), u = !0); | ||
} | ||
var E = o({ | ||
var E = a({ | ||
inst: { | ||
@@ -566,24 +575,24 @@ value: m, | ||
} | ||
}), O = E[0].inst, U = E[1]; | ||
return w(function() { | ||
O.value = m, O.getSnapshot = h, f(O) && U({ | ||
inst: O | ||
}), k = E[0].inst, K = E[1]; | ||
return g(function() { | ||
k.value = m, k.getSnapshot = h, f(k) && K({ | ||
inst: k | ||
}); | ||
}, [y, m, h]), p(function() { | ||
f(O) && U({ | ||
inst: O | ||
}, [w, m, h]), p(function() { | ||
f(k) && K({ | ||
inst: k | ||
}); | ||
var pe = function() { | ||
f(O) && U({ | ||
inst: O | ||
f(k) && K({ | ||
inst: k | ||
}); | ||
}; | ||
return y(pe); | ||
}, [y]), c(m), m; | ||
return w(pe); | ||
}, [w]), c(m), m; | ||
} | ||
function f(y) { | ||
var h = y.getSnapshot, g = y.value; | ||
function f(w) { | ||
var h = w.getSnapshot, _ = w.value; | ||
try { | ||
var m = h(); | ||
return !s(g, m); | ||
return !s(_, m); | ||
} catch { | ||
@@ -593,13 +602,13 @@ return !0; | ||
} | ||
function a(y, h, g) { | ||
function i(w, h, _) { | ||
return h(); | ||
} | ||
var u = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", v = !u, R = v ? a : d, L = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : R; | ||
Oe.useSyncExternalStore = L, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); | ||
}()), Oe; | ||
var l = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", v = !l, B = v ? i : d, A = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : B; | ||
be.useSyncExternalStore = A, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); | ||
}()), be; | ||
} | ||
(function(e) { | ||
process.env.NODE_ENV === "production" ? e.exports = Qt() : e.exports = Xt(); | ||
})(Jt); | ||
const Zt = /* @__PURE__ */ Ft(re); | ||
process.env.NODE_ENV === "production" ? e.exports = Yt() : e.exports = Jt(); | ||
})(qt); | ||
const Qt = /* @__PURE__ */ Kt(re); | ||
/** | ||
@@ -614,48 +623,48 @@ * @license React | ||
*/ | ||
var Qe; | ||
function er() { | ||
if (Qe) | ||
var Je; | ||
function Xt() { | ||
if (Je) | ||
return Ee; | ||
Qe = 1; | ||
var e = V, t = re; | ||
Je = 1; | ||
var e = M, t = re; | ||
function r(c, S) { | ||
return c === S && (c !== 0 || 1 / c === 1 / S) || c !== c && S !== S; | ||
} | ||
var n = typeof Object.is == "function" ? Object.is : r, i = t.useSyncExternalStore, s = e.useRef, o = e.useEffect, p = e.useMemo, w = e.useDebugValue; | ||
return Ee.useSyncExternalStoreWithSelector = function(c, S, l, d, f) { | ||
var a = s(null); | ||
if (a.current === null) { | ||
var u = { hasValue: !1, value: null }; | ||
a.current = u; | ||
var n = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, s = e.useRef, a = e.useEffect, p = e.useMemo, g = e.useDebugValue; | ||
return Ee.useSyncExternalStoreWithSelector = function(c, S, u, d, f) { | ||
var i = s(null); | ||
if (i.current === null) { | ||
var l = { hasValue: !1, value: null }; | ||
i.current = l; | ||
} else | ||
u = a.current; | ||
a = p(function() { | ||
function R(m) { | ||
if (!L) { | ||
if (L = !0, y = m, m = d(m), f !== void 0 && u.hasValue) { | ||
var _ = u.value; | ||
if (f(_, m)) | ||
return h = _; | ||
l = i.current; | ||
i = p(function() { | ||
function B(m) { | ||
if (!A) { | ||
if (A = !0, w = m, m = d(m), f !== void 0 && l.hasValue) { | ||
var y = l.value; | ||
if (f(y, m)) | ||
return h = y; | ||
} | ||
return h = m; | ||
} | ||
if (_ = h, n(y, m)) | ||
return _; | ||
if (y = h, n(w, m)) | ||
return y; | ||
var E = d(m); | ||
return f !== void 0 && f(_, E) ? _ : (y = m, h = E); | ||
return f !== void 0 && f(y, E) ? y : (w = m, h = E); | ||
} | ||
var L = !1, y, h, g = l === void 0 ? null : l; | ||
var A = !1, w, h, _ = u === void 0 ? null : u; | ||
return [function() { | ||
return R(S()); | ||
}, g === null ? void 0 : function() { | ||
return R(g()); | ||
return B(S()); | ||
}, _ === null ? void 0 : function() { | ||
return B(_()); | ||
}]; | ||
}, [S, l, d, f]); | ||
var v = i(c, a[0], a[1]); | ||
return o(function() { | ||
u.hasValue = !0, u.value = v; | ||
}, [v]), w(v), v; | ||
}, [S, u, d, f]); | ||
var v = o(c, i[0], i[1]); | ||
return a(function() { | ||
l.hasValue = !0, l.value = v; | ||
}, [v]), g(v), v; | ||
}, Ee; | ||
} | ||
var Re = {}; | ||
var ke = {}; | ||
/** | ||
@@ -670,100 +679,100 @@ * @license React | ||
*/ | ||
var Xe; | ||
function tr() { | ||
return Xe || (Xe = 1, process.env.NODE_ENV !== "production" && function() { | ||
var Qe; | ||
function Zt() { | ||
return Qe || (Qe = 1, process.env.NODE_ENV !== "production" && function() { | ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); | ||
var e = V, t = re; | ||
function r(S, l) { | ||
return S === l && (S !== 0 || 1 / S === 1 / l) || S !== S && l !== l; | ||
var e = M, t = re; | ||
function r(S, u) { | ||
return S === u && (S !== 0 || 1 / S === 1 / u) || S !== S && u !== u; | ||
} | ||
var n = typeof Object.is == "function" ? Object.is : r, i = t.useSyncExternalStore, s = e.useRef, o = e.useEffect, p = e.useMemo, w = e.useDebugValue; | ||
function c(S, l, d, f, a) { | ||
var u = s(null), v; | ||
u.current === null ? (v = { | ||
var n = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, s = e.useRef, a = e.useEffect, p = e.useMemo, g = e.useDebugValue; | ||
function c(S, u, d, f, i) { | ||
var l = s(null), v; | ||
l.current === null ? (v = { | ||
hasValue: !1, | ||
value: null | ||
}, u.current = v) : v = u.current; | ||
var R = p(function() { | ||
var g = !1, m, _, E = function(q) { | ||
if (!g) { | ||
g = !0, m = q; | ||
var ve = f(q); | ||
if (a !== void 0 && v.hasValue) { | ||
}, l.current = v) : v = l.current; | ||
var B = p(function() { | ||
var _ = !1, m, y, E = function(U) { | ||
if (!_) { | ||
_ = !0, m = U; | ||
var ve = f(U); | ||
if (i !== void 0 && v.hasValue) { | ||
var he = v.value; | ||
if (a(he, ve)) | ||
return _ = he, he; | ||
if (i(he, ve)) | ||
return y = he, he; | ||
} | ||
return _ = ve, ve; | ||
return y = ve, ve; | ||
} | ||
var _t = m, me = _; | ||
if (n(_t, q)) | ||
var gt = m, me = y; | ||
if (n(gt, U)) | ||
return me; | ||
var Se = f(q); | ||
return a !== void 0 && a(me, Se) ? me : (m = q, _ = Se, Se); | ||
}, O = d === void 0 ? null : d, U = function() { | ||
return E(l()); | ||
}, pe = O === null ? void 0 : function() { | ||
return E(O()); | ||
var Se = f(U); | ||
return i !== void 0 && i(me, Se) ? me : (m = U, y = Se, Se); | ||
}, k = d === void 0 ? null : d, K = function() { | ||
return E(u()); | ||
}, pe = k === null ? void 0 : function() { | ||
return E(k()); | ||
}; | ||
return [U, pe]; | ||
}, [l, d, f, a]), L = R[0], y = R[1], h = i(S, L, y); | ||
return o(function() { | ||
return [K, pe]; | ||
}, [u, d, f, i]), A = B[0], w = B[1], h = o(S, A, w); | ||
return a(function() { | ||
v.hasValue = !0, v.value = h; | ||
}, [h]), w(h), h; | ||
}, [h]), g(h), h; | ||
} | ||
Re.useSyncExternalStoreWithSelector = c, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); | ||
}()), Re; | ||
ke.useSyncExternalStoreWithSelector = c, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); | ||
}()), ke; | ||
} | ||
(function(e) { | ||
process.env.NODE_ENV === "production" ? e.exports = er() : e.exports = tr(); | ||
})(Yt); | ||
function rr(e, t, r, n) { | ||
let i = [Pt.run({ fn: (s) => t(s) })]; | ||
if (n && i.unshift(n), r) { | ||
let s = P({ node: i }), o = e.graphite.id, p = r.additionalLinks, w = p[o] || []; | ||
return p[o] = w, w.push(s), () => { | ||
let c = w.indexOf(s); | ||
c !== -1 && w.splice(c, 1), Be(s); | ||
process.env.NODE_ENV === "production" ? e.exports = Xt() : e.exports = Zt(); | ||
})(Ut); | ||
function er(e, t, r, n) { | ||
let o = [Vt.run({ fn: (s) => t(s) })]; | ||
if (n && o.unshift(n), r) { | ||
let s = P({ node: o }), a = e.graphite.id, p = r.additionalLinks, g = p[a] || []; | ||
return p[a] = g, g.push(s), () => { | ||
let c = g.indexOf(s); | ||
c !== -1 && g.splice(c, 1), Re(s); | ||
}; | ||
} | ||
{ | ||
let s = P({ node: i, parent: [e], family: { owners: e } }); | ||
let s = P({ node: o, parent: [e], family: { owners: e } }); | ||
return () => { | ||
Be(s); | ||
Re(s); | ||
}; | ||
} | ||
} | ||
function nr(e, t) { | ||
Lt.store(e) || wt("expect useStore argument to be a store"); | ||
let r = V.useCallback((i) => rr(e, i, t), [e, t]), n = V.useCallback(() => sr(e, t), [e, t]); | ||
function tr(e, t) { | ||
kt.store(e) || St("expect useStore argument to be a store"); | ||
let r = M.useCallback((o) => er(e, o, t), [e, t]), n = M.useCallback(() => or(e, t), [e, t]); | ||
return ar(r, n, n); | ||
} | ||
function or(e) { | ||
let t = V.useContext(ur); | ||
return e && !t && wt("No scope found, consider adding <Provider> to app root"), t; | ||
function rr(e) { | ||
let t = M.useContext(ir); | ||
return e && !t && St("No scope found, consider adding <Provider> to app root"), t; | ||
} | ||
function ir(e, t) { | ||
return nr(e, or(t == null ? void 0 : t.forceScope)); | ||
function nr(e, t) { | ||
return tr(e, rr(t == null ? void 0 : t.forceScope)); | ||
} | ||
let wt = (e) => { | ||
let St = (e) => { | ||
throw Error(e); | ||
}; | ||
typeof window < "u" ? V.useLayoutEffect : V.useEffect; | ||
const { useSyncExternalStore: ar } = Zt, sr = (e, t) => t ? t.getState(e) : e.getState(), ur = V.createContext(null), lr = (e, t, r) => { | ||
et(() => { | ||
const n = (i) => { | ||
i instanceof KeyboardEvent && i.key === r ? t(i) : r || t(i); | ||
typeof window < "u" ? M.useLayoutEffect : M.useEffect; | ||
const { useSyncExternalStore: ar } = Qt, or = (e, t) => t ? t.getState(e) : e.getState(), ir = M.createContext(null), sr = (e, t, r) => { | ||
Ze(() => { | ||
const n = (o) => { | ||
o instanceof KeyboardEvent && o.key === r ? t(o) : r || t(o); | ||
}; | ||
return window.addEventListener(e, n), () => window.removeEventListener(e, n); | ||
}, [e, r, t]); | ||
}, Ze = (e, t, r, n) => { | ||
et(() => (x.addEventListener(e, t, r), () => x.removeEventListener(r)), [...n]); | ||
}, wr = (e, ...t) => { | ||
const { activeView: r, activePanel: n, activeModal: i, activePopout: s, isRouteInit: o } = cr(); | ||
Ze("init", (p) => { | ||
console.log("[blum]: initialized", p), o || ($e(), x.historyPush(e)); | ||
}, 1, [o]), lr("popstate", async () => { | ||
}, Xe = (e, t, r, n) => { | ||
Ze(() => (O.addEventListener(e, t, r), () => O.removeEventListener(r)), [...n]); | ||
}, mr = (e, ...t) => { | ||
const { activeView: r, activePanel: n, activeModal: o, activePopout: s, isRouteInit: a } = lr(); | ||
Xe("init", (p) => { | ||
console.log("[blum]: initialized", p), a || (O.setDefaultBackHandlerOptions(), O.historyPush(e)); | ||
}, 1, [a]), sr("popstate", async () => { | ||
const p = async () => { | ||
window.blumRouter.isDispatchChangeStateEventBeforeMiddleware && x.dispatchChangeStateEvent(); | ||
const { view: w, panel: c, modal: S, popout: l } = window.history.state ?? { | ||
O.isDispatchChangeStateEventBeforeMiddleware && O.dispatchChangeStateEvent(); | ||
const { view: g, panel: c, modal: S, popout: u } = window.history.state ?? { | ||
view: void 0, | ||
@@ -774,3 +783,3 @@ panel: void 0, | ||
}; | ||
console.log("prevRoutes", w, c, S, l), console.log("storeRoutes", r, n, i, s); | ||
console.log("prevRoutes", g, c, S, u), console.log("storeRoutes", r, n, o, s); | ||
for (const d in t) | ||
@@ -780,36 +789,34 @@ if (!await t[d]({ | ||
panel: n, | ||
modal: i, | ||
modal: o, | ||
popout: s | ||
}, { view: w, panel: c, modal: S, popout: l })) | ||
}, { view: g, panel: c, modal: S, popout: u })) | ||
return; | ||
window.blumRouter.isDispatchChangeStateEventAfterMiddleware && x.dispatchChangeStateEvent(); | ||
O.isDispatchChangeStateEventAfterMiddleware && O.dispatchChangeStateEvent(); | ||
}; | ||
o && (window.blumRouter.beforeBackHandledCallback && window.blumRouter.beforeBackHandledCallback(), await p(), window.blumRouter.isBackFromBrowser = !0, window.blumRouter.afterBackHandledCallback && window.blumRouter.afterBackHandledCallback(), $e()); | ||
}), Ze("changestate", (p) => { | ||
a && (O.beforeBackHandledCallback && O.beforeBackHandledCallback(), await p(), O.isBackFromBrowser = !0, O.afterBackHandledCallback && O.afterBackHandledCallback(), O.setDefaultBackHandlerOptions()); | ||
}), Xe("changestate", (p) => { | ||
if (console.log("[blum]: state changed", p), p) { | ||
const { view: w, panel: c, modal: S, popout: l } = p; | ||
w && c && vt({ view: w, panel: c }), ht(S), mt(l), o || St(); | ||
const { view: g, panel: c, modal: S, popout: u } = p; | ||
g && c && pt({ view: g, panel: c }), vt(S), ht(u), a || mt(); | ||
} | ||
}, 2, [o]); | ||
}, cr = () => ir(qt), _r = (e) => e, gr = (e, t) => fr(e, (r, n) => { | ||
t && t(r, n), x.historyPush(r); | ||
}), fr = (e, t) => (r, n) => ["view", "panel", "modal", "popout"].some((s) => r[s] === e && r[s] !== n[s]) && window.blumRouter.isBackFromBrowser ? (t && t(r, n), !1) : !0; | ||
}, 2, [a]); | ||
}, lr = () => nr(Ft), Sr = (e) => e, gr = (e, t) => ur(e, (r, n) => { | ||
t && t(r, n), O.historyPush(r); | ||
}), ur = (e, t) => (r, n) => ["view", "panel", "modal", "popout"].some((s) => r[s] === e && r[s] !== n[s]) && O.isBackFromBrowser ? (t && t(r, n), !1) : !0; | ||
export { | ||
ht as _setActiveModal, | ||
Kt as _setActivePanel, | ||
mt as _setActivePopout, | ||
Gt as _setActiveView, | ||
pr as back, | ||
x as blumRouter, | ||
fr as createCatchBackBrowserRouteMiddleware, | ||
vt as _setActiveModal, | ||
Wt as _setActivePanel, | ||
ht as _setActivePopout, | ||
jt as _setActiveView, | ||
fr as back, | ||
O as blumRouter, | ||
ur as createCatchBackBrowserRouteMiddleware, | ||
gr as createDisableBackBrowserRouteMiddleware, | ||
_r as createRouteMiddleware, | ||
mr as setActiveModal, | ||
hr as setActivePanel, | ||
Sr as setActivePopout, | ||
vr as setActiveViewPanel, | ||
gt as setBackHandlerOptions, | ||
$e as setDefaultBackHandlerOptions, | ||
wr as useInitRouter, | ||
cr as useRouter | ||
Sr as createRouteMiddleware, | ||
vr as setActiveModal, | ||
pr as setActivePanel, | ||
hr as setActivePopout, | ||
dr as setActiveViewPanel, | ||
mr as useInitRouter, | ||
lr as useRouter | ||
}; |
@@ -0,4 +1,3 @@ | ||
import { BackHandlerOptions } from "src/blum-router"; | ||
export declare const back: (options?: BackHandlerOptions) => void; | ||
export declare const setBackHandlerOptions: ({ beforeBackHandledCallback, afterBackHandledCallback, isDispatchChangeStateEventAfterMiddleware, isDispatchChangeStateEventBeforeMiddleware, }: BackHandlerOptions) => void; | ||
export declare const setDefaultBackHandlerOptions: () => void; | ||
export declare const setActiveViewPanel: (routes: { | ||
@@ -11,8 +10,1 @@ view: string; | ||
export declare const setActivePopout: (popout: string) => void; | ||
type BackHandlerOptions = { | ||
beforeBackHandledCallback?: (() => void) | null; | ||
afterBackHandledCallback?: (() => void) | null; | ||
isDispatchChangeStateEventBeforeMiddleware?: boolean; | ||
isDispatchChangeStateEventAfterMiddleware?: boolean; | ||
}; | ||
export {}; |
{ | ||
"name": "@blumjs/router", | ||
"version": "7.4.0", | ||
"version": "7.5.0", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "exports": { | ||
"dev": "vite", | ||
"deploy": "npm run build & npm publish" | ||
"deploy": "npm run build && npm publish" | ||
}, | ||
@@ -20,0 +20,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64009
1029