@virtuoso.dev/gurx
Advanced tools
+6
-0
| # Change Log - @virtuoso.dev/gurx | ||
| ## 1.1.1 | ||
| ### Patch Changes | ||
| - 986d01d: Perf fix for useCellValues | ||
| ## 1.1.0 | ||
@@ -4,0 +10,0 @@ |
+94
-94
| var T = Object.defineProperty; | ||
| var L = (s, t, e) => t in s ? T(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; | ||
| var g = (s, t, e) => L(s, typeof t != "symbol" ? t + "" : t, e); | ||
| import * as h from "react"; | ||
| import * as p from "react"; | ||
| import { jsx as A } from "react/jsx-runtime"; | ||
@@ -22,3 +22,3 @@ class x { | ||
| } | ||
| class M { | ||
| class C { | ||
| constructor() { | ||
@@ -52,3 +52,3 @@ g(this, "map", /* @__PURE__ */ new Map()); | ||
| const w = /* @__PURE__ */ new Map(); | ||
| let I; | ||
| let M; | ||
| class K { | ||
@@ -64,7 +64,7 @@ /** | ||
| g(this, "executionMaps", /* @__PURE__ */ new Map()); | ||
| g(this, "graph", new M()); | ||
| g(this, "graph", new C()); | ||
| g(this, "pipeMap", /* @__PURE__ */ new Map()); | ||
| g(this, "singletonSubscriptions", /* @__PURE__ */ new Map()); | ||
| g(this, "state", /* @__PURE__ */ new Map()); | ||
| g(this, "subscriptions", new M()); | ||
| g(this, "subscriptions", new C()); | ||
| for (const e of Object.getOwnPropertySymbols(t)) | ||
@@ -103,4 +103,4 @@ this.state.set(e, t[e]); | ||
| this.connect({ | ||
| map: (i) => (r, u) => { | ||
| i(n(u, r)); | ||
| map: (i) => (r, o) => { | ||
| i(n(o, r)); | ||
| }, | ||
@@ -158,4 +158,4 @@ pulls: [t], | ||
| }; | ||
| for (const u of [...i, ...e]) | ||
| this.register(u), this.graph.getOrCreate(u).add(r); | ||
| for (const o of [...i, ...e]) | ||
| this.register(o), this.graph.getOrCreate(o).add(r); | ||
| this.executionMaps.clear(); | ||
@@ -186,6 +186,6 @@ } | ||
| inContext(t) { | ||
| const e = I; | ||
| I = this; | ||
| const e = M; | ||
| M = this; | ||
| const n = t(); | ||
| return I = e, n; | ||
| return M = e, n; | ||
| } | ||
@@ -224,11 +224,11 @@ /** | ||
| pubIn(t) { | ||
| var d; | ||
| const e = Reflect.ownKeys(t).map((a) => this.pipeMap.get(a) ?? a), n = Reflect.ownKeys(t).reduce((a, o) => { | ||
| const p = o, S = t[p], f = this.pipeMap.get(p) ?? p; | ||
| var y; | ||
| const e = Reflect.ownKeys(t).map((a) => this.pipeMap.get(a) ?? a), n = Reflect.ownKeys(t).reduce((a, u) => { | ||
| const h = u, S = t[h], f = this.pipeMap.get(h) ?? h; | ||
| return a[f] = S, a; | ||
| }, {}), i = this.getExecutionMap(e), r = i.refCount.clone(), u = i.participatingNodes.slice(), c = new Map(this.state), l = (a) => { | ||
| this.graph.use(a, (o) => { | ||
| for (const { sink: p, sources: S } of o) | ||
| S.has(a) && r.decrement(p, () => { | ||
| u.splice(u.indexOf(p), 1), l(p); | ||
| }, {}), i = this.getExecutionMap(e), r = i.refCount.clone(), o = i.participatingNodes.slice(), c = new Map(this.state), l = (a) => { | ||
| this.graph.use(a, (u) => { | ||
| for (const { sink: h, sources: S } of u) | ||
| S.has(a) && r.decrement(h, () => { | ||
| o.splice(o.indexOf(h), 1), l(h); | ||
| }); | ||
@@ -238,16 +238,16 @@ }); | ||
| for (; ; ) { | ||
| const a = u.shift(); | ||
| const a = o.shift(); | ||
| if (a === void 0) | ||
| break; | ||
| const o = a; | ||
| let p = !1; | ||
| const u = a; | ||
| let h = !1; | ||
| const S = (f) => { | ||
| const b = this.distinctNodes.get(o); | ||
| if (b != null && b(c.get(o), f)) { | ||
| p = !1; | ||
| const b = this.distinctNodes.get(u); | ||
| if (b != null && b(c.get(u), f)) { | ||
| h = !1; | ||
| return; | ||
| } | ||
| p = !0, c.set(o, f), this.state.has(o) && this.state.set(o, f); | ||
| h = !0, c.set(u, f), this.state.has(u) && this.state.set(u, f); | ||
| }; | ||
| if (Object.hasOwn(n, o) ? S(n[o]) : i.projections.use(o, (f) => { | ||
| if (Object.hasOwn(n, u) ? S(n[u]) : i.projections.use(u, (f) => { | ||
| for (const b of f) { | ||
@@ -257,12 +257,12 @@ const k = [...Array.from(b.sources), ...Array.from(b.pulls)].map((v) => c.get(v)); | ||
| } | ||
| }), p) { | ||
| const f = c.get(o); | ||
| }), h) { | ||
| const f = c.get(u); | ||
| this.inContext(() => { | ||
| this.subscriptions.use(o, (b) => { | ||
| this.subscriptions.use(u, (b) => { | ||
| for (const k of b) | ||
| k(f); | ||
| }); | ||
| }), (d = this.singletonSubscriptions.get(o)) == null || d(f); | ||
| }), (y = this.singletonSubscriptions.get(u)) == null || y(f); | ||
| } else | ||
| l(o); | ||
| l(u); | ||
| } | ||
@@ -281,11 +281,11 @@ } | ||
| if (this.definitionRegistry.add(t), e.type === V) | ||
| return m(this.cellInstance(e.initial, e.distinct, t), (u) => { | ||
| return m(this.cellInstance(e.initial, e.distinct, t), (o) => { | ||
| this.inContext(() => { | ||
| e.init(this, u); | ||
| e.init(this, o); | ||
| }); | ||
| }); | ||
| if (e.type === j) | ||
| return m(this.signalInstance(e.distinct, t), (u) => { | ||
| return m(this.signalInstance(e.distinct, t), (o) => { | ||
| this.inContext(() => { | ||
| e.init(this, u); | ||
| e.init(this, o); | ||
| }); | ||
@@ -371,11 +371,11 @@ }); | ||
| calculateExecutionMap(t) { | ||
| const e = [], n = /* @__PURE__ */ new Set(), i = new M(), r = new x(), u = new M(), c = (l, d = 0) => { | ||
| const e = [], n = /* @__PURE__ */ new Set(), i = new C(), r = new x(), o = new C(), c = (l, y = 0) => { | ||
| r.increment(l), !n.has(l) && (this.register(l), i.use(l, (a) => { | ||
| d = Math.max(...Array.from(a).map((o) => e.indexOf(o))) + 1; | ||
| y = Math.max(...Array.from(a).map((u) => e.indexOf(u))) + 1; | ||
| }), this.graph.use(l, (a) => { | ||
| for (const o of a) | ||
| o.sources.has(l) ? (u.getOrCreate(o.sink).add(o), c(o.sink, d)) : i.getOrCreate(o.sink).add(l); | ||
| }), n.add(l), e.splice(d, 0, l)); | ||
| for (const u of a) | ||
| u.sources.has(l) ? (o.getOrCreate(u.sink).add(u), c(u.sink, y)) : i.getOrCreate(u.sink).add(l); | ||
| }), n.add(l), e.splice(y, 0, l)); | ||
| }; | ||
| return t.forEach(c), { participatingNodes: e, pendingPulls: i, projections: u, refCount: r }; | ||
| return t.forEach(c), { participatingNodes: e, pendingPulls: i, projections: o, refCount: r }; | ||
| } | ||
@@ -398,3 +398,3 @@ combineOperators(...t) { | ||
| for (const [i, r] of this.executionMaps.entries()) | ||
| if (Array.isArray(i) && i.length === t.length && i.every((u) => t.includes(u))) | ||
| if (Array.isArray(i) && i.length === t.length && i.every((o) => t.includes(o))) | ||
| return r; | ||
@@ -437,20 +437,20 @@ const n = this.calculateExecutionMap(t); | ||
| } | ||
| function y() { | ||
| if (!I) | ||
| function d() { | ||
| if (!M) | ||
| throw new Error("This function must be called within a realm instance"); | ||
| return I; | ||
| return M; | ||
| } | ||
| const J = (s, t) => { | ||
| y().link(s, t); | ||
| d().link(s, t); | ||
| }, X = (...s) => { | ||
| y().pub(...s); | ||
| }, Z = (...s) => y().sub(...s), $ = (...s) => { | ||
| y().pubIn(...s); | ||
| }, tt = (...s) => y().pipe(...s), et = (...s) => { | ||
| y().changeWith(...s); | ||
| }, nt = (...s) => y().combine(...s), st = (s) => y().getValue(s), N = { data: null, error: null, isLoading: !0, type: "loading" }; | ||
| d().pub(...s); | ||
| }, Z = (...s) => d().sub(...s), $ = (...s) => { | ||
| d().pubIn(...s); | ||
| }, tt = (...s) => d().pipe(...s), et = (...s) => { | ||
| d().changeWith(...s); | ||
| }, nt = (...s) => d().combine(...s), st = (s) => d().getValue(s), N = { data: null, error: null, isLoading: !0, type: "loading" }; | ||
| function it(s, t) { | ||
| return Y(N, (e, n, i) => { | ||
| function r(u) { | ||
| e.pub(i, N), s(u).then((c) => { | ||
| function r(o) { | ||
| e.pub(i, N), s(o).then((c) => { | ||
| e.pub(i, { data: c, error: null, isLoading: !1, type: "success" }); | ||
@@ -464,3 +464,3 @@ }).catch((c) => { | ||
| } | ||
| const O = h.createContext(null); | ||
| const O = p.createContext(null); | ||
| function rt({ | ||
@@ -471,10 +471,10 @@ children: s, | ||
| }) { | ||
| const n = h.useMemo(() => new K(t), []); | ||
| return h.useEffect(() => { | ||
| const n = p.useMemo(() => new K(t), []); | ||
| return p.useEffect(() => { | ||
| n.pubIn(e); | ||
| }, [e, n]), /* @__PURE__ */ A(O.Provider, { value: n, children: s }); | ||
| } | ||
| const _ = typeof document < "u" ? h.useLayoutEffect : h.useEffect; | ||
| function C() { | ||
| const s = h.useContext(O); | ||
| const _ = typeof document < "u" ? p.useLayoutEffect : p.useEffect; | ||
| function I() { | ||
| const s = p.useContext(O); | ||
| if (s === null) | ||
@@ -485,6 +485,6 @@ throw new Error("useRealm must be used within a RealmContextProvider"); | ||
| function Q(s) { | ||
| const t = C(); | ||
| const t = I(); | ||
| t.register(s); | ||
| const e = h.useCallback((n) => t.sub(s, n), [t, s]); | ||
| return h.useSyncExternalStore( | ||
| const e = p.useCallback((n) => t.sub(s, n), [t, s]); | ||
| return p.useSyncExternalStore( | ||
| e, | ||
@@ -496,5 +496,5 @@ () => t.getValue(s), | ||
| function D(s) { | ||
| const t = C(); | ||
| const t = I(); | ||
| t.register(s); | ||
| const [e, n] = h.useState(() => t.getValue(s)); | ||
| const [e, n] = p.useState(() => t.getValue(s)); | ||
| return _(() => { | ||
@@ -509,10 +509,10 @@ const i = t.sub(s, () => { | ||
| } | ||
| const P = "useSyncExternalStore" in h ? Q : D; | ||
| function ut(...s) { | ||
| const t = C(); | ||
| return P(t.combineCells.apply(t, s)); | ||
| const P = "useSyncExternalStore" in p ? Q : D; | ||
| function ot(...s) { | ||
| const t = I(), e = p.useMemo(() => t.combineCells(...s), [t, ...s]); | ||
| return P(e); | ||
| } | ||
| function U(s) { | ||
| const t = C(); | ||
| return t.register(s), h.useCallback( | ||
| const t = I(); | ||
| return t.register(s), p.useCallback( | ||
| (e) => { | ||
@@ -524,3 +524,3 @@ t.pub(s, e); | ||
| } | ||
| function ot(s) { | ||
| function ut(s) { | ||
| return [P(s), U(s)]; | ||
@@ -594,4 +594,4 @@ } | ||
| return n.connect({ | ||
| map: (r) => (u) => { | ||
| r(t = s(t, u)); | ||
| map: (r) => (o) => { | ||
| r(t = s(t, o)); | ||
| }, | ||
@@ -607,4 +607,4 @@ sink: i, | ||
| let i, r = null; | ||
| return e.sub(t, (u) => { | ||
| i = u, r === null && (r = setTimeout(() => { | ||
| return e.sub(t, (o) => { | ||
| i = o, r === null && (r = setTimeout(() => { | ||
| r = null, e.pub(n, i); | ||
@@ -619,4 +619,4 @@ }, s)); | ||
| let i, r = null; | ||
| return e.sub(t, (u) => { | ||
| i = u, r !== null && clearTimeout(r), r = setTimeout(() => { | ||
| return e.sub(t, (o) => { | ||
| i = o, r !== null && clearTimeout(r), r = setTimeout(() => { | ||
| e.pub(n, i); | ||
@@ -637,3 +637,3 @@ }, s); | ||
| } | ||
| function yt(s) { | ||
| function dt(s) { | ||
| return (t, e) => { | ||
@@ -643,21 +643,21 @@ const n = e.signalInstance(), i = Symbol(); | ||
| return e.connect({ | ||
| map: (u) => (c) => { | ||
| r !== i && (u([r, c]), r = i); | ||
| map: (o) => (c) => { | ||
| r !== i && (o([r, c]), r = i); | ||
| }, | ||
| sink: n, | ||
| sources: [s] | ||
| }), e.sub(t, (u) => { | ||
| r = u; | ||
| }), e.sub(t, (o) => { | ||
| r = o; | ||
| }), n; | ||
| }; | ||
| } | ||
| function dt(s, t, e) { | ||
| function yt(s, t, e) { | ||
| return (n, i) => { | ||
| const r = i.signalInstance(); | ||
| return i.sub(n, (u) => { | ||
| u !== null && typeof u == "object" && "then" in u ? (i.pub(r, s()), u.then((c) => { | ||
| return i.sub(n, (o) => { | ||
| o !== null && typeof o == "object" && "then" in o ? (i.pub(r, s()), o.then((c) => { | ||
| i.pub(r, t(c)); | ||
| }).catch((c) => { | ||
| i.pub(r, e(c)); | ||
| })) : i.pub(r, t(u)); | ||
| })) : i.pub(r, t(o)); | ||
| }), r; | ||
@@ -683,7 +683,7 @@ }; | ||
| st as getValue, | ||
| dt as handlePromise, | ||
| yt as handlePromise, | ||
| J as link, | ||
| ct as map, | ||
| lt as mapTo, | ||
| yt as onNext, | ||
| dt as onNext, | ||
| ht as once, | ||
@@ -696,8 +696,8 @@ tt as pipe, | ||
| gt as throttleTime, | ||
| ot as useCell, | ||
| ut as useCell, | ||
| P as useCellValue, | ||
| ut as useCellValues, | ||
| ot as useCellValues, | ||
| U as usePublisher, | ||
| C as useRealm, | ||
| I as useRealm, | ||
| at as withLatestFrom | ||
| }; |
+1
-1
@@ -6,3 +6,3 @@ { | ||
| "type": "module", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "module": "dist/index.js", | ||
@@ -9,0 +9,0 @@ "main": "dist/index.js", |
73166
0.13%