@serenity-ui/primitives
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,2 +0,2 @@ | ||
export * from "./ui"; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,211 +0,1 @@ | ||
const N = (t, e) => t === e, E = { | ||
equals: N | ||
}; | ||
let T = y; | ||
const a = 1, h = 2, O = { | ||
owned: null, | ||
cleanups: null, | ||
context: null, | ||
owner: null | ||
}; | ||
var i = null; | ||
let S = null, l = null, o = null, c = null, w = 0; | ||
function D(t, e) { | ||
e = e ? Object.assign({}, E, e) : E; | ||
const s = { | ||
value: t, | ||
observers: null, | ||
observerSlots: null, | ||
comparator: e.equals || void 0 | ||
}, r = (n) => (typeof n == "function" && (n = n(s.value)), C(s, n)); | ||
return [j.bind(s), r]; | ||
} | ||
function L(t, e, s) { | ||
T = Q; | ||
const r = I(t, e, !1, a), n = x && V(x); | ||
n && (r.suspense = n), (!s || !s.render) && (r.user = !0), c ? c.push(r) : m(r); | ||
} | ||
function F(t) { | ||
if (l === null) | ||
return t(); | ||
const e = l; | ||
l = null; | ||
try { | ||
return t(); | ||
} finally { | ||
l = e; | ||
} | ||
} | ||
function V(t) { | ||
return i && i.context && i.context[t.id] !== void 0 ? i.context[t.id] : t.defaultValue; | ||
} | ||
let x; | ||
function j() { | ||
if (this.sources && this.state) | ||
if (this.state === a) | ||
m(this); | ||
else { | ||
const t = o; | ||
o = null, b(() => g(this), !1), o = t; | ||
} | ||
if (l) { | ||
const t = this.observers ? this.observers.length : 0; | ||
l.sources ? (l.sources.push(this), l.sourceSlots.push(t)) : (l.sources = [this], l.sourceSlots = [t]), this.observers ? (this.observers.push(l), this.observerSlots.push(l.sources.length - 1)) : (this.observers = [l], this.observerSlots = [l.sources.length - 1]); | ||
} | ||
return this.value; | ||
} | ||
function C(t, e, s) { | ||
let r = t.value; | ||
return (!t.comparator || !t.comparator(r, e)) && (t.value = e, t.observers && t.observers.length && b(() => { | ||
for (let n = 0; n < t.observers.length; n += 1) { | ||
const u = t.observers[n], f = S && S.running; | ||
f && S.disposed.has(u), (f ? !u.tState : !u.state) && (u.pure ? o.push(u) : c.push(u), u.observers && U(u)), f || (u.state = a); | ||
} | ||
if (o.length > 1e6) | ||
throw o = [], new Error(); | ||
}, !1)), e; | ||
} | ||
function m(t) { | ||
if (!t.fn) | ||
return; | ||
A(t); | ||
const e = i, s = l, r = w; | ||
l = i = t, G(t, t.value, r), l = s, i = e; | ||
} | ||
function G(t, e, s) { | ||
let r; | ||
try { | ||
r = t.fn(e); | ||
} catch (n) { | ||
return t.pure && (t.state = a, t.owned && t.owned.forEach(A), t.owned = null), t.updatedAt = s + 1, k(n); | ||
} | ||
(!t.updatedAt || t.updatedAt <= s) && (t.updatedAt != null && "observers" in t ? C(t, r) : t.value = r, t.updatedAt = s); | ||
} | ||
function I(t, e, s, r = a, n) { | ||
const u = { | ||
fn: t, | ||
state: r, | ||
updatedAt: null, | ||
owned: null, | ||
sources: null, | ||
sourceSlots: null, | ||
cleanups: null, | ||
value: e, | ||
owner: i, | ||
context: i ? i.context : null, | ||
pure: s | ||
}; | ||
return i === null || i !== O && (i.owned ? i.owned.push(u) : i.owned = [u]), u; | ||
} | ||
function p(t) { | ||
if (t.state === 0) | ||
return; | ||
if (t.state === h) | ||
return g(t); | ||
if (t.suspense && F(t.suspense.inFallback)) | ||
return t.suspense.effects.push(t); | ||
const e = [t]; | ||
for (; (t = t.owner) && (!t.updatedAt || t.updatedAt < w); ) | ||
t.state && e.push(t); | ||
for (let s = e.length - 1; s >= 0; s--) | ||
if (t = e[s], t.state === a) | ||
m(t); | ||
else if (t.state === h) { | ||
const r = o; | ||
o = null, b(() => g(t, e[0]), !1), o = r; | ||
} | ||
} | ||
function b(t, e) { | ||
if (o) | ||
return t(); | ||
let s = !1; | ||
e || (o = []), c ? s = !0 : c = [], w++; | ||
try { | ||
const r = t(); | ||
return P(s), r; | ||
} catch (r) { | ||
s || (c = null), o = null, k(r); | ||
} | ||
} | ||
function P(t) { | ||
if (o && (y(o), o = null), t) | ||
return; | ||
const e = c; | ||
c = null, e.length && b(() => T(e), !1); | ||
} | ||
function y(t) { | ||
for (let e = 0; e < t.length; e++) | ||
p(t[e]); | ||
} | ||
function Q(t) { | ||
let e, s = 0; | ||
for (e = 0; e < t.length; e++) { | ||
const r = t[e]; | ||
r.user ? t[s++] = r : p(r); | ||
} | ||
for (e = 0; e < s; e++) | ||
p(t[e]); | ||
} | ||
function g(t, e) { | ||
t.state = 0; | ||
for (let s = 0; s < t.sources.length; s += 1) { | ||
const r = t.sources[s]; | ||
if (r.sources) { | ||
const n = r.state; | ||
n === a ? r !== e && (!r.updatedAt || r.updatedAt < w) && p(r) : n === h && g(r, e); | ||
} | ||
} | ||
} | ||
function U(t) { | ||
for (let e = 0; e < t.observers.length; e += 1) { | ||
const s = t.observers[e]; | ||
s.state || (s.state = h, s.pure ? o.push(s) : c.push(s), s.observers && U(s)); | ||
} | ||
} | ||
function A(t) { | ||
let e; | ||
if (t.sources) | ||
for (; t.sources.length; ) { | ||
const s = t.sources.pop(), r = t.sourceSlots.pop(), n = s.observers; | ||
if (n && n.length) { | ||
const u = n.pop(), f = s.observerSlots.pop(); | ||
r < n.length && (u.sourceSlots[f] = r, n[r] = u, s.observerSlots[r] = f); | ||
} | ||
} | ||
if (t.owned) { | ||
for (e = t.owned.length - 1; e >= 0; e--) | ||
A(t.owned[e]); | ||
t.owned = null; | ||
} | ||
if (t.cleanups) { | ||
for (e = t.cleanups.length - 1; e >= 0; e--) | ||
t.cleanups[e](); | ||
t.cleanups = null; | ||
} | ||
t.state = 0; | ||
} | ||
function R(t) { | ||
return t instanceof Error ? t : new Error(typeof t == "string" ? t : "Unknown error", { | ||
cause: t | ||
}); | ||
} | ||
function k(t, e = i) { | ||
throw R(t); | ||
} | ||
function W(t) { | ||
const e = t ?? document.querySelector("html"), s = e == null ? void 0 : e.getAttribute("data-theme"), [r, n] = D(s ?? "light"), u = () => { | ||
n((v) => v === "light" ? "dark" : "light"); | ||
}, f = (v) => { | ||
n(v); | ||
}; | ||
return L(() => { | ||
e == null || e.setAttribute("data-theme", r()); | ||
}), { | ||
toggleTheme: u, | ||
setTheme: f, | ||
theme: r | ||
}; | ||
} | ||
export { | ||
W as useTheme | ||
}; | ||
{ | ||
"name": "@serenity-ui/primitives", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/serenity-primitives.umd.cjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
3523
15
1