New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@freact/core

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@freact/core - npm Package Compare versions

Comparing version
0.0.11
to
0.0.12
+2
dist/types/utils/reinstantiate.d.ts
import { FreactNode } from "@/types";
export declare function reinstantiate<T extends FreactNode>(node: T): T;
+271
-233

@@ -1,7 +0,7 @@

function f(n, e, ...t) {
const l = e && Object.hasOwn(e, "key"), i = e?.key;
if (delete e?.key, n === S)
return l && (t.key = i), t.length > 0 ? t : void 0;
const u = {
type: n,
function u(s, e, ...t) {
const n = e && Object.hasOwn(e, "key"), o = e?.key;
if (delete e?.key, s === S)
return n && (t.key = o), t.length > 0 ? t : void 0;
const a = {
type: s,
props: {

@@ -11,5 +11,5 @@ ...e

};
return t.length > 0 && (u.props.children = t.length > 1 ? t : t[0]), l && (u.key = i), u;
return t.length > 0 && (a.props.children = t.length > 1 ? t : t[0]), n && (a.key = o), a;
}
const o = {
const i = {
self: null,

@@ -21,79 +21,79 @@ index: 0,

};
function m(n, e) {
const t = o.data, l = o.index++;
if (!Object.hasOwn(t, l))
t[l] = { val: n(), deps: e };
function P(s, e) {
const t = i.data, n = i.index++;
if (!Object.hasOwn(t, n))
t[n] = { val: s(), deps: e };
else {
let i = t[l].deps.length === e.length;
if (i) {
for (let u = 0; u < e.length; u++)
if (!Object.is(t[l].deps[u], e[u])) {
i = !1;
let o = t[n].deps.length === e.length;
if (o) {
for (let a = 0; a < e.length; a++)
if (!Object.is(t[n].deps[a], e[a])) {
o = !1;
break;
}
}
i || (t[l].val = n(), t[l].deps = e);
o || (t[n].val = s(), t[n].deps = e);
}
return t[l].val;
return t[n].val;
}
const P = (n, e) => {
const W = (s, e) => {
const t = Object.keys(e);
if (t.length !== Object.keys(n).length)
if (t.length !== Object.keys(s).length)
return !1;
const l = Object.hasOwn(e, "children");
if (Object.hasOwn(n, "children") !== l)
const n = Object.hasOwn(e, "children");
if (Object.hasOwn(s, "children") !== n)
return !1;
if (l) {
if (n.children.length !== e.children.length)
if (n) {
if (s.children.length !== e.children.length)
return !1;
for (let i = 0; i < e.children.length; i++)
if (!Object.is(e.children[i], n.children[i]))
for (let o = 0; o < e.children.length; o++)
if (!Object.is(e.children[o], s.children[o]))
return !1;
}
for (const i of t)
if (i !== "children" && !Object.is(n[i], e[i]))
for (const o of t)
if (o !== "children" && !Object.is(s[o], e[o]))
return !1;
return !0;
};
function V(n, e = P) {
function V(s, e = W) {
let t = !1;
return (l) => (t = e(
o.self?.value.__context?.prevProps ?? {},
l
) ? t : !t, m(() => f(n, l), [t]));
return (n) => (t = e(
i.self?.value.__context?.prevProps ?? {},
n
) ? t : !t, P(() => u(s, n), [t]));
}
function G(n, e) {
const t = o.data, l = o.index++;
if (!Object.hasOwn(t, l))
t[l] = {
effect: n,
function G(s, e) {
const t = i.data, n = i.index++;
if (!Object.hasOwn(t, n))
t[n] = {
effect: s,
cb: null,
deps: e ?? null
}, o.fx.push(t[l]);
}, i.fx.push(t[n]);
else {
let i = !!t[l].deps && t[l].deps?.length === e?.length;
if (i) {
for (let u = 0; u < e.length; u++)
if (!Object.is(t[l].deps[u], e[u])) {
i = !1;
let o = !!t[n].deps && t[n].deps?.length === e?.length;
if (o) {
for (let a = 0; a < e.length; a++)
if (!Object.is(t[n].deps[a], e[a])) {
o = !1;
break;
}
}
i || (t[l].effect = n, t[l].deps = e ?? null);
o || (t[n].effect = s, t[n].deps = e ?? null);
}
}
function W(n) {
if (!o.self)
function q(s) {
if (!i.self)
throw new Error("Missing context data inside useContext hook");
const e = o.data, t = o.index++, l = o.self;
return Object.hasOwn(e, t) || (e[t] = M.get(n).value, e[t].subs.add(l)), G(() => () => e[t].subs.delete(l), []), e[t].val;
const e = i.data, t = i.index++, n = i.self;
return Object.hasOwn(e, t) || (e[t] = T.get(s).value, e[t].subs.add(n)), G(() => () => e[t].subs.delete(n), []), e[t].val;
}
function q(n) {
const e = o.data, t = o.index++;
return Object.hasOwn(e, t) || (e[t] = { current: n }), e[t];
function U(s) {
const e = i.data, t = i.index++;
return Object.hasOwn(e, t) || (e[t] = { current: s }), e[t];
}
const M = /* @__PURE__ */ new Map();
class U {
const T = /* @__PURE__ */ new Map();
class F {
constructor(e) {
M.set(this, {
T.set(this, {
prev: null,

@@ -104,53 +104,53 @@ value: { val: e, subs: /* @__PURE__ */ new Set() }

Provider = ({ value: e, children: t }) => {
const l = q({ val: e, subs: /* @__PURE__ */ new Set() });
l.current.val !== e && (l.current.val = e, l.current.subs.forEach((u) => {
o.root?.__internalAddPending(u);
const n = U({ val: e, subs: /* @__PURE__ */ new Set() });
n.current.val !== e && (n.current.val = e, n.current.subs.forEach((a) => {
i.root?.__internalAddPending(a);
}));
const i = M.get(this);
return M.set(this, {
prev: i,
value: l.current
const o = T.get(this);
return T.set(this, {
prev: o,
value: n.current
}), G(() => {
M.set(this, i);
}), f(S, null, t);
T.set(this, o);
}), u(S, null, t);
};
Consumer = ({ children: e }) => {
const t = W(this);
return f(S, null, e(t));
const t = q(this);
return u(S, null, e(t));
};
}
function $(n) {
return new U(n);
function $(s) {
return new F(s);
}
function B(n, e) {
return m(() => n, e);
function B(s, e) {
return P(() => s, e);
}
function z(n, e, t) {
if (!o.root || !o.self)
function z(s, e, t) {
if (!i.root || !i.self)
throw new Error("Missing context data inside useReducer hook");
const l = o.data, i = o.index++, u = o.root, _ = o.self;
if (!Object.hasOwn(l, i)) {
const x = (C) => {
const y = n(l[i].val, C);
Object.is(y, l[i].val) || (l[i].val = y, u.__internalAddPending(_), u.__internalUpdate());
const n = i.data, o = i.index++, a = i.root, E = i.self;
if (!Object.hasOwn(n, o)) {
const y = (R) => {
const x = s(n[o].val, R);
Object.is(x, n[o].val) || (n[o].val = x, a.__internalAddPending(E), a.__internalUpdate());
};
l[i] = {
n[o] = {
val: t ? t(e) : e,
dispatch: x
dispatch: y
};
}
return [l[i].val, l[i].dispatch];
return [n[o].val, n[o].dispatch];
}
function F(n) {
if (!o.root || !o.self)
function J(s) {
if (!i.root || !i.self)
throw new Error("Missing context data inside useState hook");
const e = o.data, t = o.index++, l = o.root, i = o.self;
const e = i.data, t = i.index++, n = i.root, o = i.self;
if (!Object.hasOwn(e, t)) {
const u = (_) => {
const x = typeof _ == "function" ? _(e[t].val) : _;
Object.is(x, e[t].val) || (e[t].val = x, l.__internalAddPending(i), l.__internalUpdate());
const a = (E) => {
const y = typeof E == "function" ? E(e[t].val) : E;
Object.is(y, e[t].val) || (e[t].val = y, n.__internalAddPending(o), n.__internalUpdate());
};
e[t] = {
setter: u,
val: typeof n != "function" ? n : n()
setter: a,
val: typeof s != "function" ? s : s()
};

@@ -160,28 +160,28 @@ }

}
var a = /* @__PURE__ */ ((n) => (n[n.LITERAL = 0] = "LITERAL", n[n.FRAGMENT = 1] = "FRAGMENT", n[n.ELEMENT = 2] = "ELEMENT", n[n.COMPONENT = 4] = "COMPONENT", n[n.NODRAW = 5] = "NODRAW", n))(a || {});
function T(n) {
return typeof n != "object" || n === null || !Object.hasOwn(n, "key") ? null : n.key;
var c = /* @__PURE__ */ ((s) => (s[s.LITERAL = 0] = "LITERAL", s[s.FRAGMENT = 1] = "FRAGMENT", s[s.ELEMENT = 2] = "ELEMENT", s[s.COMPONENT = 4] = "COMPONENT", s[s.NODRAW = 5] = "NODRAW", s))(c || {});
function C(s) {
return typeof s != "object" || s === null || !Object.hasOwn(s, "key") ? null : s.key;
}
function K(n, e) {
function K(s, e) {
for (const t of Object.keys(e))
typeof e[t] == "object" ? K(n[t], e[t]) : n[t] = e[t];
typeof e[t] == "object" ? K(s[t], e[t]) : s[t] = e[t];
}
function j(n, e, t) {
e === "class" && (e = "className"), typeof t == "object" ? K(n[e], t) : n[e] = t;
function A(s, e, t) {
e === "class" && (e = "className"), typeof t == "object" ? K(s[e], t) : s[e] = t;
}
function R(n, e, t) {
const l = typeof e == "object" ? e : document.createTextNode(`${e}`);
n.childNodes.length > 0 ? n.insertBefore(l, n.childNodes[t]) : n.appendChild(l);
function N(s, e, t) {
const n = typeof e == "object" ? e : document.createTextNode(`${e}`);
s.childNodes.length > 0 ? s.insertBefore(n, s.childNodes[t]) : s.appendChild(n);
}
function L(n) {
return typeof n == "object" && n !== null ? Array.isArray(n) ? a.FRAGMENT : typeof n.type == "string" ? a.ELEMENT : a.COMPONENT : typeof n == "string" || typeof n == "number" || typeof n == "bigint" ? a.LITERAL : a.NODRAW;
function L(s) {
return typeof s == "object" && s !== null ? Array.isArray(s) ? c.FRAGMENT : typeof s.type == "function" ? c.COMPONENT : c.ELEMENT : typeof s == "string" || typeof s == "number" || typeof s == "bigint" ? c.LITERAL : c.NODRAW;
}
function N(n, e) {
const t = o.data, l = o.index, i = o.fx, u = o.self;
o.self = n.self, o.index = 0, o.data = n.hookData, o.fx = n.fx, e(), o.self = u, o.index = l, o.data = t, o.fx = i;
function m(s, e) {
const t = i.data, n = i.index, o = i.fx, a = i.self;
i.self = s.self, i.index = 0, i.data = s.hookData, i.fx = s.fx, e(), i.self = a, i.index = n, i.data = t, i.fx = o;
}
function D(n) {
for (const e of n.fx)
function D(s) {
for (const e of s.fx)
e.effect && e.cb?.();
for (const e of n.fx) {
for (const e of s.fx) {
if (!e.effect)

@@ -193,90 +193,128 @@ continue;

}
function I(n) {
return Object.hasOwn(n.props, "children") ? Array.isArray(n.props.children) ? n.props.children : [n.props.children] : [];
function I(s) {
return Object.hasOwn(s.props, "children") ? Array.isArray(s.props.children) ? s.props.children : [s.props.children] : [];
}
function w(s) {
const e = Array.isArray(s) ? [...s] : [s];
for (let t = 0; t < e.length; t++) {
const n = e[t];
switch (L(n)) {
case c.COMPONENT: {
e[t] = {
type: n.type,
props: { ...n.props },
key: n.key,
__vnode: n
};
break;
}
case c.ELEMENT: {
const o = {
type: n.type,
props: { ...n.props },
key: n.key,
__vnode: n
};
n.props.children && (o.props.children = w(o.props.children)), e[t] = o;
break;
}
case c.FRAGMENT: {
const o = w(n);
o.__vnode = n, e[t] = o;
break;
}
}
}
return Array.isArray(s) ? e : e[0];
}
class H {
#l;
#s;
#t = /* @__PURE__ */ new Set();
#n = !1;
constructor(e) {
this.#l = e, e.innerHTML = "";
this.#s = e, e.innerHTML = "";
}
#e(e, t, l, i) {
const u = /* @__PURE__ */ new Set([...Object.keys(t.props), ...Object.keys(e.props)]);
for (const s of u)
if (s !== "children") {
if (s === "ref") {
Object.hasOwn(e.props, s) && (e.props[s].current = null), Object.hasOwn(t.props, s) && (t.props[s].current = l);
#e(e, t, n, o) {
const a = /* @__PURE__ */ new Set([...Object.keys(t.props), ...Object.keys(e.props)]);
for (const l of a)
if (l !== "children") {
if (l === "ref") {
Object.hasOwn(e.props, l) && (e.props[l].current = null), Object.hasOwn(t.props, l) && (t.props[l].current = n);
continue;
}
if (!Object.hasOwn(t.props, s))
s.slice(0, 2) === "on" && typeof e.props[s] == "function" ? l.removeEventListener(s.slice(2).toLowerCase(), e.props[s]) : l[s] = "";
else if (!Object.hasOwn(e.props, s))
s.slice(0, 2) === "on" && typeof t.props[s] == "function" ? l.addEventListener(s.slice(2).toLowerCase(), t.props[s]) : j(l, s, t.props[s]);
else if (s.slice(0, 2) === "on") {
if (t.props[s] === e.props[s])
if (!Object.hasOwn(t.props, l))
l.slice(0, 2) === "on" && typeof e.props[l] == "function" ? n.removeEventListener(l.slice(2).toLowerCase(), e.props[l]) : n[l] = "";
else if (!Object.hasOwn(e.props, l))
l.slice(0, 2) === "on" && typeof t.props[l] == "function" ? n.addEventListener(l.slice(2).toLowerCase(), t.props[l]) : A(n, l, t.props[l]);
else if (l.slice(0, 2) === "on") {
if (t.props[l] === e.props[l])
continue;
const h = s.slice(2).toLowerCase();
typeof e.props[s] == "function" ? l.removeEventListener(h, e.props[s]) : j(l, s, ""), typeof t.props[s] == "function" ? l.addEventListener(h, t.props[s]) : j(l, s, t.props[s]);
} else if (s === "value" || s === "checked")
l[s] !== t.props[s] && j(l, s, t.props[s]);
const h = l.slice(2).toLowerCase();
typeof e.props[l] == "function" ? n.removeEventListener(h, e.props[l]) : A(n, l, ""), typeof t.props[l] == "function" ? n.addEventListener(h, t.props[l]) : A(n, l, t.props[l]);
} else if (l === "value" || l === "checked")
n[l] !== t.props[l] && A(n, l, t.props[l]);
else {
if (t.props[s] === e.props[s])
if (t.props[l] === e.props[l])
continue;
j(l, s, t.props[s]);
A(n, l, t.props[l]);
}
}
const _ = I(e), x = I(t), C = Math.max(_.length, x.length), y = /* @__PURE__ */ new Map(), c = i ?? { value: 0 };
let A = c.value;
for (let s = 0; s < _.length; s++) {
const h = _[s], O = x[s], b = T(h), g = T(O), v = L(h), E = A;
if (A = v === a.FRAGMENT || v === a.COMPONENT ? h.__domEnd : A + 1, b === null || b === g)
const E = I(e), y = I(t), R = Math.max(E.length, y.length), x = /* @__PURE__ */ new Map(), f = o ?? { value: 0 };
let j = f.value;
for (let l = 0; l < E.length; l++) {
const h = E[l], O = y[l], b = C(h), g = C(O), v = L(h), _ = j;
if (j = v === c.FRAGMENT || v === c.COMPONENT ? h.__domEnd : j + 1, b === null || b === g)
continue;
const r = [];
for (let p = E; p < A; p++)
r.push(l.childNodes[p]);
y.set(b, [h, r]), _[s] = void 0;
for (let p = _; p < j; p++)
r.push(n.childNodes[p]);
x.set(b, [h, r]), E[l] = void 0;
}
for (const [s, [h, O]] of y)
for (const [l, [h, O]] of x)
for (const b of O)
l.removeChild(b);
for (let s = 0; s < C; s++) {
const h = x[s];
let O = _[s];
const b = T(O), g = T(h);
if (g !== null && g !== b && y.has(g)) {
const [d, w] = y.get(g);
y.delete(g), b === null && this.#e(
f(null, null, O),
f(null, null),
l,
c
), _[s] = d, O = d;
for (let k = 0; k < w.length; k++)
R(l, w[k], c.value + k);
n.removeChild(b);
for (let l = 0; l < R; l++) {
const h = y[l];
let O = E[l];
const b = C(O), g = C(h);
if (g !== null && g !== b && x.has(g)) {
const [d, M] = x.get(g);
x.delete(g), b === null && this.#e(
u(null, null, O),
u(null, null),
n,
f
), E[l] = d, O = d;
for (let k = 0; k < M.length; k++)
N(n, M[k], f.value + k);
}
const v = L(O), E = L(h), r = h, p = O;
if (E !== a.NODRAW) {
if (v !== a.NODRAW)
if (v !== E || (E === a.ELEMENT || E === a.COMPONENT) && r.type !== p.type)
const v = L(O), _ = L(h), r = h, p = O;
if (_ !== c.NODRAW) {
if (v !== c.NODRAW)
if (v !== _ || (_ === c.ELEMENT || _ === c.COMPONENT) && r.type !== p.type)
this.#e(
f(null, null, O),
f(null, null),
l,
c
u(null, null, O),
u(null, null),
n,
f
), this.#e(
f(null, null),
f(null, null, h),
l,
c
u(null, null),
u(null, null, h),
n,
f
);
else {
if (Object.is(h, O)) {
E === a.COMPONENT || E === a.FRAGMENT ? c.value = r.__domEnd : c.value++;
if (_ === c.ELEMENT || _ === c.COMPONENT || _ === c.FRAGMENT) {
if (Object.is(p.__vnode, r.__vnode)) {
r.__vnode = p.__vnode, (_ === c.COMPONENT || _ === c.FRAGMENT) && (r.__domStart = p.__domStart, r.__domEnd = p.__domEnd), _ === c.COMPONENT && (r.__context = p.__context, r.__context.self.value = r, r.__ref = p.__ref), f.value = _ === c.ELEMENT ? f.value + 1 : p.__domEnd;
continue;
}
} else if (Object.is(O, h)) {
f.value++;
continue;
}
if (E === a.LITERAL)
l.childNodes[c.value++].textContent = `${h}`;
else if (E === a.ELEMENT) {
const d = l.childNodes[c.value++];
if (_ === c.LITERAL)
n.childNodes[f.value++].textContent = `${h}`;
else if (_ === c.ELEMENT) {
const d = n.childNodes[f.value++];
this.#e(

@@ -288,29 +326,29 @@ p,

} else
E === a.COMPONENT ? (this.#t.delete(p.__context.self), N(p.__context, () => {
const d = r.type(r.props);
r.__domStart = c.value, r.__ref = l, this.#e(
f(null, null, p.__context.prevTree),
f(null, null, d),
l,
c
), r.__context = p.__context, r.__context.prevTree = d, r.__context.self.value = r, r.__domEnd = c.value, D(r.__context);
})) : (r.__domStart = c.value, this.#e(
f(null, null, ...O),
f(null, null, ...h),
l,
c
), r.__domEnd = c.value);
_ === c.COMPONENT ? (this.#t.delete(p.__context.self), m(p.__context, () => {
const d = w(r.type(r.props));
r.__domStart = f.value, r.__ref = n, this.#e(
u(null, null, p.__context.prevTree),
u(null, null, d),
n,
f
), r.__context = p.__context, r.__context.prevTree = d, r.__context.self.value = r, r.__domEnd = f.value, D(r.__context);
})) : (r.__domStart = f.value, this.#e(
u(null, null, ...O),
u(null, null, ...h),
n,
f
), r.__domEnd = f.value);
}
else if (E === a.LITERAL)
R(l, h, c.value++);
else if (E === a.FRAGMENT)
r.__domStart = c.value, this.#e(
f(null, null),
f(null, null, ...h),
l,
c
), r.__domEnd = c.value;
else if (_ === c.LITERAL)
N(n, h, f.value++);
else if (_ === c.FRAGMENT)
r.__domStart = f.value, this.#e(
u(null, null),
u(null, null, ...h),
n,
f
), r.__domEnd = f.value;
else if (typeof r.type == "string") {
const d = document.createElement(r.type);
this.#e(f(r.type, {}), r, d), R(l, d, c.value++);
this.#e(u(r.type, {}), r, d), N(n, d, f.value++);
} else if (r.type !== null) {

@@ -324,26 +362,26 @@ const d = {

};
N(d, () => {
const w = r.type(r.props);
r.__domStart = c.value, r.__ref = l, this.#e(
f(null, null),
f(null, null, w),
l,
c
), r.__domEnd = c.value, r.__context = d, d.prevTree = w, D(r.__context);
m(d, () => {
const M = w(r.type(r.props));
r.__domStart = f.value, r.__ref = n, this.#e(
u(null, null),
u(null, null, M),
n,
f
), r.__domEnd = f.value, r.__context = d, d.prevTree = M, D(r.__context);
});
}
} else if (v !== a.NODRAW)
if (v === a.FRAGMENT)
} else if (v !== c.NODRAW)
if (v === c.FRAGMENT)
this.#e(
f(null, null, ...O),
f(null, null, h),
l,
c
u(null, null, ...O),
u(null, null, h),
n,
f
);
else if (v === a.COMPONENT) {
else if (v === c.COMPONENT) {
this.#t.delete(p.__context.self), this.#e(
f(null, null, p.__context?.prevTree),
f(null, null, h),
l,
c
u(null, null, p.__context?.prevTree),
u(null, null, h),
n,
f
);

@@ -353,7 +391,7 @@ for (const d of p.__context.fx)

} else
v === a.ELEMENT && (_.length > 0 && this.#e(
v === c.ELEMENT && (E.length > 0 && this.#e(
p,
f(null, null),
l.childNodes[c.value]
), Object.hasOwn(p.props, "ref") && (p.props.ref.current = null)), l.childNodes[c.value].remove();
u(null, null),
n.childNodes[f.value]
), Object.hasOwn(p.props, "ref") && (p.props.ref.current = null)), n.childNodes[f.value].remove();
}

@@ -366,8 +404,8 @@ }

this.#n || (this.#n = !0, requestIdleCallback(() => {
o.root = this;
i.root = this;
for (const e of this.#t) {
const t = { value: e.value.__domStart };
this.#t.delete(e), this.#e(
f(null, null, e.value),
f(null, null, { ...e.value }),
u(null, null, e.value),
w(u(null, null, e.value)),
e.value.__ref,

@@ -381,11 +419,11 @@ t

render(e) {
o.root = this, this.#e(
f(null, null),
f(null, null, e),
this.#l
i.root = this, this.#e(
u(null, null),
w(u(null, null, e)),
this.#s
);
}
}
function J(n) {
const e = document.querySelector(n);
function Q(s) {
const e = document.querySelector(s);
if (!e)

@@ -399,12 +437,12 @@ throw new Error("Root element doesn't exist");

$ as createContext,
J as createRoot,
f as h,
Q as createRoot,
u as h,
V as memo,
B as useCallback,
W as useContext,
q as useContext,
G as useEffect,
m as useMemo,
P as useMemo,
z as useReducer,
q as useRef,
F as useState
U as useRef,
J as useState
};

@@ -1,1 +0,1 @@

var Freact=function(_){"use strict";function c(n,e,...t){const l=e&&Object.hasOwn(e,"key"),i=e?.key;if(delete e?.key,n===k)return l&&(t.key=i),t.length>0?t:void 0;const u={type:n,props:{...e}};return t.length>0&&(u.props.children=t.length>1?t:t[0]),l&&(u.key=i),u}const o={self:null,index:0,data:[],fx:[],root:null};function L(n,e){const t=o.data,l=o.index++;if(!Object.hasOwn(t,l))t[l]={val:n(),deps:e};else{let i=t[l].deps.length===e.length;if(i){for(let u=0;u<e.length;u++)if(!Object.is(t[l].deps[u],e[u])){i=!1;break}}i||(t[l].val=n(),t[l].deps=e)}return t[l].val}const U=(n,e)=>{const t=Object.keys(e);if(t.length!==Object.keys(n).length)return!1;const l=Object.hasOwn(e,"children");if(Object.hasOwn(n,"children")!==l)return!1;if(l){if(n.children.length!==e.children.length)return!1;for(let i=0;i<e.children.length;i++)if(!Object.is(e.children[i],n.children[i]))return!1}for(const i of t)if(i!=="children"&&!Object.is(n[i],e[i]))return!1;return!0};function F(n,e=U){let t=!1;return l=>(t=e(o.self?.value.__context?.prevProps??{},l)?t:!t,L(()=>c(n,l),[t]))}function S(n,e){const t=o.data,l=o.index++;if(!Object.hasOwn(t,l))t[l]={effect:n,cb:null,deps:e??null},o.fx.push(t[l]);else{let i=!!t[l].deps&&t[l].deps?.length===e?.length;if(i){for(let u=0;u<e.length;u++)if(!Object.is(t[l].deps[u],e[u])){i=!1;break}}i||(t[l].effect=n,t[l].deps=e??null)}}function I(n){if(!o.self)throw new Error("Missing context data inside useContext hook");const e=o.data,t=o.index++,l=o.self;return Object.hasOwn(e,t)||(e[t]=j.get(n).value,e[t].subs.add(l)),S(()=>()=>e[t].subs.delete(l),[]),e[t].val}function P(n){const e=o.data,t=o.index++;return Object.hasOwn(e,t)||(e[t]={current:n}),e[t]}const j=new Map;class H{constructor(e){j.set(this,{prev:null,value:{val:e,subs:new Set}})}Provider=({value:e,children:t})=>{const l=P({val:e,subs:new Set});l.current.val!==e&&(l.current.val=e,l.current.subs.forEach(u=>{o.root?.__internalAddPending(u)}));const i=j.get(this);return j.set(this,{prev:i,value:l.current}),S(()=>{j.set(this,i)}),c(k,null,t)};Consumer=({children:e})=>{const t=I(this);return c(k,null,e(t))}}function V(n){return new H(n)}function $(n,e){return L(()=>n,e)}function B(n,e,t){if(!o.root||!o.self)throw new Error("Missing context data inside useReducer hook");const l=o.data,i=o.index++,u=o.root,O=o.self;if(!Object.hasOwn(l,i)){const b=D=>{const x=n(l[i].val,D);Object.is(x,l[i].val)||(l[i].val=x,u.__internalAddPending(O),u.__internalUpdate())};l[i]={val:t?t(e):e,dispatch:b}}return[l[i].val,l[i].dispatch]}function z(n){if(!o.root||!o.self)throw new Error("Missing context data inside useState hook");const e=o.data,t=o.index++,l=o.root,i=o.self;if(!Object.hasOwn(e,t)){const u=O=>{const b=typeof O=="function"?O(e[t].val):O;Object.is(b,e[t].val)||(e[t].val=b,l.__internalAddPending(i),l.__internalUpdate())};e[t]={setter:u,val:typeof n!="function"?n:n()}}return[e[t].val,e[t].setter]}var a=(n=>(n[n.LITERAL=0]="LITERAL",n[n.FRAGMENT=1]="FRAGMENT",n[n.ELEMENT=2]="ELEMENT",n[n.COMPONENT=4]="COMPONENT",n[n.NODRAW=5]="NODRAW",n))(a||{});function C(n){return typeof n!="object"||n===null||!Object.hasOwn(n,"key")?null:n.key}function G(n,e){for(const t of Object.keys(e))typeof e[t]=="object"?G(n[t],e[t]):n[t]=e[t]}function M(n,e,t){e==="class"&&(e="className"),typeof t=="object"?G(n[e],t):n[e]=t}function m(n,e,t){const l=typeof e=="object"?e:document.createTextNode(`${e}`);n.childNodes.length>0?n.insertBefore(l,n.childNodes[t]):n.appendChild(l)}function N(n){return typeof n=="object"&&n!==null?Array.isArray(n)?a.FRAGMENT:typeof n.type=="string"?a.ELEMENT:a.COMPONENT:typeof n=="string"||typeof n=="number"||typeof n=="bigint"?a.LITERAL:a.NODRAW}function K(n,e){const t=o.data,l=o.index,i=o.fx,u=o.self;o.self=n.self,o.index=0,o.data=n.hookData,o.fx=n.fx,e(),o.self=u,o.index=l,o.data=t,o.fx=i}function W(n){for(const e of n.fx)e.effect&&e.cb?.();for(const e of n.fx){if(!e.effect)continue;const t=e.effect();e.effect=null,typeof t=="function"&&(e.cb=t)}}function q(n){return Object.hasOwn(n.props,"children")?Array.isArray(n.props.children)?n.props.children:[n.props.children]:[]}class J{#l;#t=new Set;#n=!1;constructor(e){this.#l=e,e.innerHTML=""}#e(e,t,l,i){const u=new Set([...Object.keys(t.props),...Object.keys(e.props)]);for(const s of u)if(s!=="children"){if(s==="ref"){Object.hasOwn(e.props,s)&&(e.props[s].current=null),Object.hasOwn(t.props,s)&&(t.props[s].current=l);continue}if(!Object.hasOwn(t.props,s))s.slice(0,2)==="on"&&typeof e.props[s]=="function"?l.removeEventListener(s.slice(2).toLowerCase(),e.props[s]):l[s]="";else if(!Object.hasOwn(e.props,s))s.slice(0,2)==="on"&&typeof t.props[s]=="function"?l.addEventListener(s.slice(2).toLowerCase(),t.props[s]):M(l,s,t.props[s]);else if(s.slice(0,2)==="on"){if(t.props[s]===e.props[s])continue;const h=s.slice(2).toLowerCase();typeof e.props[s]=="function"?l.removeEventListener(h,e.props[s]):M(l,s,""),typeof t.props[s]=="function"?l.addEventListener(h,t.props[s]):M(l,s,t.props[s])}else if(s==="value"||s==="checked")l[s]!==t.props[s]&&M(l,s,t.props[s]);else{if(t.props[s]===e.props[s])continue;M(l,s,t.props[s])}}const O=q(e),b=q(t),D=Math.max(O.length,b.length),x=new Map,f=i??{value:0};let T=f.value;for(let s=0;s<O.length;s++){const h=O[s],E=b[s],g=C(h),w=C(E),y=N(h),v=T;if(T=y===a.FRAGMENT||y===a.COMPONENT?h.__domEnd:T+1,g===null||g===w)continue;const r=[];for(let p=v;p<T;p++)r.push(l.childNodes[p]);x.set(g,[h,r]),O[s]=void 0}for(const[s,[h,E]]of x)for(const g of E)l.removeChild(g);for(let s=0;s<D;s++){const h=b[s];let E=O[s];const g=C(E),w=C(h);if(w!==null&&w!==g&&x.has(w)){const[d,A]=x.get(w);x.delete(w),g===null&&this.#e(c(null,null,E),c(null,null),l,f),O[s]=d,E=d;for(let R=0;R<A.length;R++)m(l,A[R],f.value+R)}const y=N(E),v=N(h),r=h,p=E;if(v!==a.NODRAW){if(y!==a.NODRAW)if(y!==v||(v===a.ELEMENT||v===a.COMPONENT)&&r.type!==p.type)this.#e(c(null,null,E),c(null,null),l,f),this.#e(c(null,null),c(null,null,h),l,f);else{if(Object.is(h,E)){v===a.COMPONENT||v===a.FRAGMENT?f.value=r.__domEnd:f.value++;continue}if(v===a.LITERAL)l.childNodes[f.value++].textContent=`${h}`;else if(v===a.ELEMENT){const d=l.childNodes[f.value++];this.#e(p,r,d)}else v===a.COMPONENT?(this.#t.delete(p.__context.self),K(p.__context,()=>{const d=r.type(r.props);r.__domStart=f.value,r.__ref=l,this.#e(c(null,null,p.__context.prevTree),c(null,null,d),l,f),r.__context=p.__context,r.__context.prevTree=d,r.__context.self.value=r,r.__domEnd=f.value,W(r.__context)})):(r.__domStart=f.value,this.#e(c(null,null,...E),c(null,null,...h),l,f),r.__domEnd=f.value)}else if(v===a.LITERAL)m(l,h,f.value++);else if(v===a.FRAGMENT)r.__domStart=f.value,this.#e(c(null,null),c(null,null,...h),l,f),r.__domEnd=f.value;else if(typeof r.type=="string"){const d=document.createElement(r.type);this.#e(c(r.type,{}),r,d),m(l,d,f.value++)}else if(r.type!==null){const d={hookData:[],fx:[],self:{value:r},prevProps:r.props,prevTree:null};K(d,()=>{const A=r.type(r.props);r.__domStart=f.value,r.__ref=l,this.#e(c(null,null),c(null,null,A),l,f),r.__domEnd=f.value,r.__context=d,d.prevTree=A,W(r.__context)})}}else if(y!==a.NODRAW)if(y===a.FRAGMENT)this.#e(c(null,null,...E),c(null,null,h),l,f);else if(y===a.COMPONENT){this.#t.delete(p.__context.self),this.#e(c(null,null,p.__context?.prevTree),c(null,null,h),l,f);for(const d of p.__context.fx)d.cb?.()}else y===a.ELEMENT&&(O.length>0&&this.#e(p,c(null,null),l.childNodes[f.value]),Object.hasOwn(p.props,"ref")&&(p.props.ref.current=null)),l.childNodes[f.value].remove()}}__internalAddPending(e){this.#t.add(e)}__internalUpdate(){this.#n||(this.#n=!0,requestIdleCallback(()=>{o.root=this;for(const e of this.#t){const t={value:e.value.__domStart};this.#t.delete(e),this.#e(c(null,null,e.value),c(null,null,{...e.value}),e.value.__ref,t)}this.#n=!1}))}render(e){o.root=this,this.#e(c(null,null),c(null,null,e),this.#l)}}function Q(n){const e=document.querySelector(n);if(!e)throw new Error("Root element doesn't exist");return new J(e)}const k=Symbol.for("freact.fragment");return _.Fragment=k,_.createContext=V,_.createRoot=Q,_.h=c,_.memo=F,_.useCallback=$,_.useContext=I,_.useEffect=S,_.useMemo=L,_.useReducer=B,_.useRef=P,_.useState=z,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),_}({});
var Freact=function(E){"use strict";function f(s,e,...t){const n=e&&Object.hasOwn(e,"key"),o=e?.key;if(delete e?.key,s===R)return n&&(t.key=o),t.length>0?t:void 0;const a={type:s,props:{...e}};return t.length>0&&(a.props.children=t.length>1?t:t[0]),n&&(a.key=o),a}const i={self:null,index:0,data:[],fx:[],root:null};function S(s,e){const t=i.data,n=i.index++;if(!Object.hasOwn(t,n))t[n]={val:s(),deps:e};else{let o=t[n].deps.length===e.length;if(o){for(let a=0;a<e.length;a++)if(!Object.is(t[n].deps[a],e[a])){o=!1;break}}o||(t[n].val=s(),t[n].deps=e)}return t[n].val}const U=(s,e)=>{const t=Object.keys(e);if(t.length!==Object.keys(s).length)return!1;const n=Object.hasOwn(e,"children");if(Object.hasOwn(s,"children")!==n)return!1;if(n){if(s.children.length!==e.children.length)return!1;for(let o=0;o<e.children.length;o++)if(!Object.is(e.children[o],s.children[o]))return!1}for(const o of t)if(o!=="children"&&!Object.is(s[o],e[o]))return!1;return!0};function H(s,e=U){let t=!1;return n=>(t=e(i.self?.value.__context?.prevProps??{},n)?t:!t,S(()=>f(s,n),[t]))}function m(s,e){const t=i.data,n=i.index++;if(!Object.hasOwn(t,n))t[n]={effect:s,cb:null,deps:e??null},i.fx.push(t[n]);else{let o=!!t[n].deps&&t[n].deps?.length===e?.length;if(o){for(let a=0;a<e.length;a++)if(!Object.is(t[n].deps[a],e[a])){o=!1;break}}o||(t[n].effect=s,t[n].deps=e??null)}}function I(s){if(!i.self)throw new Error("Missing context data inside useContext hook");const e=i.data,t=i.index++,n=i.self;return Object.hasOwn(e,t)||(e[t]=T.get(s).value,e[t].subs.add(n)),m(()=>()=>e[t].subs.delete(n),[]),e[t].val}function G(s){const e=i.data,t=i.index++;return Object.hasOwn(e,t)||(e[t]={current:s}),e[t]}const T=new Map;class V{constructor(e){T.set(this,{prev:null,value:{val:e,subs:new Set}})}Provider=({value:e,children:t})=>{const n=G({val:e,subs:new Set});n.current.val!==e&&(n.current.val=e,n.current.subs.forEach(a=>{i.root?.__internalAddPending(a)}));const o=T.get(this);return T.set(this,{prev:o,value:n.current}),m(()=>{T.set(this,o)}),f(R,null,t)};Consumer=({children:e})=>{const t=I(this);return f(R,null,e(t))}}function $(s){return new V(s)}function B(s,e){return S(()=>s,e)}function z(s,e,t){if(!i.root||!i.self)throw new Error("Missing context data inside useReducer hook");const n=i.data,o=i.index++,a=i.root,O=i.self;if(!Object.hasOwn(n,o)){const b=P=>{const x=s(n[o].val,P);Object.is(x,n[o].val)||(n[o].val=x,a.__internalAddPending(O),a.__internalUpdate())};n[o]={val:t?t(e):e,dispatch:b}}return[n[o].val,n[o].dispatch]}function J(s){if(!i.root||!i.self)throw new Error("Missing context data inside useState hook");const e=i.data,t=i.index++,n=i.root,o=i.self;if(!Object.hasOwn(e,t)){const a=O=>{const b=typeof O=="function"?O(e[t].val):O;Object.is(b,e[t].val)||(e[t].val=b,n.__internalAddPending(o),n.__internalUpdate())};e[t]={setter:a,val:typeof s!="function"?s:s()}}return[e[t].val,e[t].setter]}var c=(s=>(s[s.LITERAL=0]="LITERAL",s[s.FRAGMENT=1]="FRAGMENT",s[s.ELEMENT=2]="ELEMENT",s[s.COMPONENT=4]="COMPONENT",s[s.NODRAW=5]="NODRAW",s))(c||{});function A(s){return typeof s!="object"||s===null||!Object.hasOwn(s,"key")?null:s.key}function K(s,e){for(const t of Object.keys(e))typeof e[t]=="object"?K(s[t],e[t]):s[t]=e[t]}function j(s,e,t){e==="class"&&(e="className"),typeof t=="object"?K(s[e],t):s[e]=t}function D(s,e,t){const n=typeof e=="object"?e:document.createTextNode(`${e}`);s.childNodes.length>0?s.insertBefore(n,s.childNodes[t]):s.appendChild(n)}function C(s){return typeof s=="object"&&s!==null?Array.isArray(s)?c.FRAGMENT:typeof s.type=="function"?c.COMPONENT:c.ELEMENT:typeof s=="string"||typeof s=="number"||typeof s=="bigint"?c.LITERAL:c.NODRAW}function W(s,e){const t=i.data,n=i.index,o=i.fx,a=i.self;i.self=s.self,i.index=0,i.data=s.hookData,i.fx=s.fx,e(),i.self=a,i.index=n,i.data=t,i.fx=o}function F(s){for(const e of s.fx)e.effect&&e.cb?.();for(const e of s.fx){if(!e.effect)continue;const t=e.effect();e.effect=null,typeof t=="function"&&(e.cb=t)}}function q(s){return Object.hasOwn(s.props,"children")?Array.isArray(s.props.children)?s.props.children:[s.props.children]:[]}function w(s){const e=Array.isArray(s)?[...s]:[s];for(let t=0;t<e.length;t++){const n=e[t];switch(C(n)){case c.COMPONENT:{e[t]={type:n.type,props:{...n.props},key:n.key,__vnode:n};break}case c.ELEMENT:{const o={type:n.type,props:{...n.props},key:n.key,__vnode:n};n.props.children&&(o.props.children=w(o.props.children)),e[t]=o;break}case c.FRAGMENT:{const o=w(n);o.__vnode=n,e[t]=o;break}}}return Array.isArray(s)?e:e[0]}class Q{#s;#t=new Set;#n=!1;constructor(e){this.#s=e,e.innerHTML=""}#e(e,t,n,o){const a=new Set([...Object.keys(t.props),...Object.keys(e.props)]);for(const l of a)if(l!=="children"){if(l==="ref"){Object.hasOwn(e.props,l)&&(e.props[l].current=null),Object.hasOwn(t.props,l)&&(t.props[l].current=n);continue}if(!Object.hasOwn(t.props,l))l.slice(0,2)==="on"&&typeof e.props[l]=="function"?n.removeEventListener(l.slice(2).toLowerCase(),e.props[l]):n[l]="";else if(!Object.hasOwn(e.props,l))l.slice(0,2)==="on"&&typeof t.props[l]=="function"?n.addEventListener(l.slice(2).toLowerCase(),t.props[l]):j(n,l,t.props[l]);else if(l.slice(0,2)==="on"){if(t.props[l]===e.props[l])continue;const _=l.slice(2).toLowerCase();typeof e.props[l]=="function"?n.removeEventListener(_,e.props[l]):j(n,l,""),typeof t.props[l]=="function"?n.addEventListener(_,t.props[l]):j(n,l,t.props[l])}else if(l==="value"||l==="checked")n[l]!==t.props[l]&&j(n,l,t.props[l]);else{if(t.props[l]===e.props[l])continue;j(n,l,t.props[l])}}const O=q(e),b=q(t),P=Math.max(O.length,b.length),x=new Map,u=o??{value:0};let L=u.value;for(let l=0;l<O.length;l++){const _=O[l],v=b[l],g=A(_),M=A(v),y=C(_),p=L;if(L=y===c.FRAGMENT||y===c.COMPONENT?_.__domEnd:L+1,g===null||g===M)continue;const r=[];for(let h=p;h<L;h++)r.push(n.childNodes[h]);x.set(g,[_,r]),O[l]=void 0}for(const[l,[_,v]]of x)for(const g of v)n.removeChild(g);for(let l=0;l<P;l++){const _=b[l];let v=O[l];const g=A(v),M=A(_);if(M!==null&&M!==g&&x.has(M)){const[d,k]=x.get(M);x.delete(M),g===null&&this.#e(f(null,null,v),f(null,null),n,u),O[l]=d,v=d;for(let N=0;N<k.length;N++)D(n,k[N],u.value+N)}const y=C(v),p=C(_),r=_,h=v;if(p!==c.NODRAW){if(y!==c.NODRAW)if(y!==p||(p===c.ELEMENT||p===c.COMPONENT)&&r.type!==h.type)this.#e(f(null,null,v),f(null,null),n,u),this.#e(f(null,null),f(null,null,_),n,u);else{if(p===c.ELEMENT||p===c.COMPONENT||p===c.FRAGMENT){if(Object.is(h.__vnode,r.__vnode)){r.__vnode=h.__vnode,(p===c.COMPONENT||p===c.FRAGMENT)&&(r.__domStart=h.__domStart,r.__domEnd=h.__domEnd),p===c.COMPONENT&&(r.__context=h.__context,r.__context.self.value=r,r.__ref=h.__ref),u.value=p===c.ELEMENT?u.value+1:h.__domEnd;continue}}else if(Object.is(v,_)){u.value++;continue}if(p===c.LITERAL)n.childNodes[u.value++].textContent=`${_}`;else if(p===c.ELEMENT){const d=n.childNodes[u.value++];this.#e(h,r,d)}else p===c.COMPONENT?(this.#t.delete(h.__context.self),W(h.__context,()=>{const d=w(r.type(r.props));r.__domStart=u.value,r.__ref=n,this.#e(f(null,null,h.__context.prevTree),f(null,null,d),n,u),r.__context=h.__context,r.__context.prevTree=d,r.__context.self.value=r,r.__domEnd=u.value,F(r.__context)})):(r.__domStart=u.value,this.#e(f(null,null,...v),f(null,null,..._),n,u),r.__domEnd=u.value)}else if(p===c.LITERAL)D(n,_,u.value++);else if(p===c.FRAGMENT)r.__domStart=u.value,this.#e(f(null,null),f(null,null,..._),n,u),r.__domEnd=u.value;else if(typeof r.type=="string"){const d=document.createElement(r.type);this.#e(f(r.type,{}),r,d),D(n,d,u.value++)}else if(r.type!==null){const d={hookData:[],fx:[],self:{value:r},prevProps:r.props,prevTree:null};W(d,()=>{const k=w(r.type(r.props));r.__domStart=u.value,r.__ref=n,this.#e(f(null,null),f(null,null,k),n,u),r.__domEnd=u.value,r.__context=d,d.prevTree=k,F(r.__context)})}}else if(y!==c.NODRAW)if(y===c.FRAGMENT)this.#e(f(null,null,...v),f(null,null,_),n,u);else if(y===c.COMPONENT){this.#t.delete(h.__context.self),this.#e(f(null,null,h.__context?.prevTree),f(null,null,_),n,u);for(const d of h.__context.fx)d.cb?.()}else y===c.ELEMENT&&(O.length>0&&this.#e(h,f(null,null),n.childNodes[u.value]),Object.hasOwn(h.props,"ref")&&(h.props.ref.current=null)),n.childNodes[u.value].remove()}}__internalAddPending(e){this.#t.add(e)}__internalUpdate(){this.#n||(this.#n=!0,requestIdleCallback(()=>{i.root=this;for(const e of this.#t){const t={value:e.value.__domStart};this.#t.delete(e),this.#e(f(null,null,e.value),w(f(null,null,e.value)),e.value.__ref,t)}this.#n=!1}))}render(e){i.root=this,this.#e(f(null,null),w(f(null,null,e)),this.#s)}}function X(s){const e=document.querySelector(s);if(!e)throw new Error("Root element doesn't exist");return new Q(e)}const R=Symbol.for("freact.fragment");return E.Fragment=R,E.createContext=$,E.createRoot=X,E.h=f,E.memo=H,E.useCallback=B,E.useContext=I,E.useEffect=m,E.useMemo=S,E.useReducer=z,E.useRef=G,E.useState=J,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"}),E}({});

@@ -1,1 +0,1 @@

(function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p.Freact={}))})(this,function(p){"use strict";function f(n,e,...t){const l=e&&Object.hasOwn(e,"key"),i=e?.key;if(delete e?.key,n===C)return l&&(t.key=i),t.length>0?t:void 0;const u={type:n,props:{...e}};return t.length>0&&(u.props.children=t.length>1?t:t[0]),l&&(u.key=i),u}const o={self:null,index:0,data:[],fx:[],root:null};function L(n,e){const t=o.data,l=o.index++;if(!Object.hasOwn(t,l))t[l]={val:n(),deps:e};else{let i=t[l].deps.length===e.length;if(i){for(let u=0;u<e.length;u++)if(!Object.is(t[l].deps[u],e[u])){i=!1;break}}i||(t[l].val=n(),t[l].deps=e)}return t[l].val}const U=(n,e)=>{const t=Object.keys(e);if(t.length!==Object.keys(n).length)return!1;const l=Object.hasOwn(e,"children");if(Object.hasOwn(n,"children")!==l)return!1;if(l){if(n.children.length!==e.children.length)return!1;for(let i=0;i<e.children.length;i++)if(!Object.is(e.children[i],n.children[i]))return!1}for(const i of t)if(i!=="children"&&!Object.is(n[i],e[i]))return!1;return!0};function F(n,e=U){let t=!1;return l=>(t=e(o.self?.value.__context?.prevProps??{},l)?t:!t,L(()=>f(n,l),[t]))}function S(n,e){const t=o.data,l=o.index++;if(!Object.hasOwn(t,l))t[l]={effect:n,cb:null,deps:e??null},o.fx.push(t[l]);else{let i=!!t[l].deps&&t[l].deps?.length===e?.length;if(i){for(let u=0;u<e.length;u++)if(!Object.is(t[l].deps[u],e[u])){i=!1;break}}i||(t[l].effect=n,t[l].deps=e??null)}}function I(n){if(!o.self)throw new Error("Missing context data inside useContext hook");const e=o.data,t=o.index++,l=o.self;return Object.hasOwn(e,t)||(e[t]=j.get(n).value,e[t].subs.add(l)),S(()=>()=>e[t].subs.delete(l),[]),e[t].val}function P(n){const e=o.data,t=o.index++;return Object.hasOwn(e,t)||(e[t]={current:n}),e[t]}const j=new Map;class H{constructor(e){j.set(this,{prev:null,value:{val:e,subs:new Set}})}Provider=({value:e,children:t})=>{const l=P({val:e,subs:new Set});l.current.val!==e&&(l.current.val=e,l.current.subs.forEach(u=>{o.root?.__internalAddPending(u)}));const i=j.get(this);return j.set(this,{prev:i,value:l.current}),S(()=>{j.set(this,i)}),f(C,null,t)};Consumer=({children:e})=>{const t=I(this);return f(C,null,e(t))}}function V(n){return new H(n)}function $(n,e){return L(()=>n,e)}function B(n,e,t){if(!o.root||!o.self)throw new Error("Missing context data inside useReducer hook");const l=o.data,i=o.index++,u=o.root,O=o.self;if(!Object.hasOwn(l,i)){const b=D=>{const x=n(l[i].val,D);Object.is(x,l[i].val)||(l[i].val=x,u.__internalAddPending(O),u.__internalUpdate())};l[i]={val:t?t(e):e,dispatch:b}}return[l[i].val,l[i].dispatch]}function z(n){if(!o.root||!o.self)throw new Error("Missing context data inside useState hook");const e=o.data,t=o.index++,l=o.root,i=o.self;if(!Object.hasOwn(e,t)){const u=O=>{const b=typeof O=="function"?O(e[t].val):O;Object.is(b,e[t].val)||(e[t].val=b,l.__internalAddPending(i),l.__internalUpdate())};e[t]={setter:u,val:typeof n!="function"?n:n()}}return[e[t].val,e[t].setter]}var a=(n=>(n[n.LITERAL=0]="LITERAL",n[n.FRAGMENT=1]="FRAGMENT",n[n.ELEMENT=2]="ELEMENT",n[n.COMPONENT=4]="COMPONENT",n[n.NODRAW=5]="NODRAW",n))(a||{});function A(n){return typeof n!="object"||n===null||!Object.hasOwn(n,"key")?null:n.key}function G(n,e){for(const t of Object.keys(e))typeof e[t]=="object"?G(n[t],e[t]):n[t]=e[t]}function M(n,e,t){e==="class"&&(e="className"),typeof t=="object"?G(n[e],t):n[e]=t}function m(n,e,t){const l=typeof e=="object"?e:document.createTextNode(`${e}`);n.childNodes.length>0?n.insertBefore(l,n.childNodes[t]):n.appendChild(l)}function N(n){return typeof n=="object"&&n!==null?Array.isArray(n)?a.FRAGMENT:typeof n.type=="string"?a.ELEMENT:a.COMPONENT:typeof n=="string"||typeof n=="number"||typeof n=="bigint"?a.LITERAL:a.NODRAW}function K(n,e){const t=o.data,l=o.index,i=o.fx,u=o.self;o.self=n.self,o.index=0,o.data=n.hookData,o.fx=n.fx,e(),o.self=u,o.index=l,o.data=t,o.fx=i}function W(n){for(const e of n.fx)e.effect&&e.cb?.();for(const e of n.fx){if(!e.effect)continue;const t=e.effect();e.effect=null,typeof t=="function"&&(e.cb=t)}}function q(n){return Object.hasOwn(n.props,"children")?Array.isArray(n.props.children)?n.props.children:[n.props.children]:[]}class J{#l;#t=new Set;#n=!1;constructor(e){this.#l=e,e.innerHTML=""}#e(e,t,l,i){const u=new Set([...Object.keys(t.props),...Object.keys(e.props)]);for(const s of u)if(s!=="children"){if(s==="ref"){Object.hasOwn(e.props,s)&&(e.props[s].current=null),Object.hasOwn(t.props,s)&&(t.props[s].current=l);continue}if(!Object.hasOwn(t.props,s))s.slice(0,2)==="on"&&typeof e.props[s]=="function"?l.removeEventListener(s.slice(2).toLowerCase(),e.props[s]):l[s]="";else if(!Object.hasOwn(e.props,s))s.slice(0,2)==="on"&&typeof t.props[s]=="function"?l.addEventListener(s.slice(2).toLowerCase(),t.props[s]):M(l,s,t.props[s]);else if(s.slice(0,2)==="on"){if(t.props[s]===e.props[s])continue;const h=s.slice(2).toLowerCase();typeof e.props[s]=="function"?l.removeEventListener(h,e.props[s]):M(l,s,""),typeof t.props[s]=="function"?l.addEventListener(h,t.props[s]):M(l,s,t.props[s])}else if(s==="value"||s==="checked")l[s]!==t.props[s]&&M(l,s,t.props[s]);else{if(t.props[s]===e.props[s])continue;M(l,s,t.props[s])}}const O=q(e),b=q(t),D=Math.max(O.length,b.length),x=new Map,c=i??{value:0};let k=c.value;for(let s=0;s<O.length;s++){const h=O[s],E=b[s],g=A(h),w=A(E),y=N(h),v=k;if(k=y===a.FRAGMENT||y===a.COMPONENT?h.__domEnd:k+1,g===null||g===w)continue;const r=[];for(let d=v;d<k;d++)r.push(l.childNodes[d]);x.set(g,[h,r]),O[s]=void 0}for(const[s,[h,E]]of x)for(const g of E)l.removeChild(g);for(let s=0;s<D;s++){const h=b[s];let E=O[s];const g=A(E),w=A(h);if(w!==null&&w!==g&&x.has(w)){const[_,T]=x.get(w);x.delete(w),g===null&&this.#e(f(null,null,E),f(null,null),l,c),O[s]=_,E=_;for(let R=0;R<T.length;R++)m(l,T[R],c.value+R)}const y=N(E),v=N(h),r=h,d=E;if(v!==a.NODRAW){if(y!==a.NODRAW)if(y!==v||(v===a.ELEMENT||v===a.COMPONENT)&&r.type!==d.type)this.#e(f(null,null,E),f(null,null),l,c),this.#e(f(null,null),f(null,null,h),l,c);else{if(Object.is(h,E)){v===a.COMPONENT||v===a.FRAGMENT?c.value=r.__domEnd:c.value++;continue}if(v===a.LITERAL)l.childNodes[c.value++].textContent=`${h}`;else if(v===a.ELEMENT){const _=l.childNodes[c.value++];this.#e(d,r,_)}else v===a.COMPONENT?(this.#t.delete(d.__context.self),K(d.__context,()=>{const _=r.type(r.props);r.__domStart=c.value,r.__ref=l,this.#e(f(null,null,d.__context.prevTree),f(null,null,_),l,c),r.__context=d.__context,r.__context.prevTree=_,r.__context.self.value=r,r.__domEnd=c.value,W(r.__context)})):(r.__domStart=c.value,this.#e(f(null,null,...E),f(null,null,...h),l,c),r.__domEnd=c.value)}else if(v===a.LITERAL)m(l,h,c.value++);else if(v===a.FRAGMENT)r.__domStart=c.value,this.#e(f(null,null),f(null,null,...h),l,c),r.__domEnd=c.value;else if(typeof r.type=="string"){const _=document.createElement(r.type);this.#e(f(r.type,{}),r,_),m(l,_,c.value++)}else if(r.type!==null){const _={hookData:[],fx:[],self:{value:r},prevProps:r.props,prevTree:null};K(_,()=>{const T=r.type(r.props);r.__domStart=c.value,r.__ref=l,this.#e(f(null,null),f(null,null,T),l,c),r.__domEnd=c.value,r.__context=_,_.prevTree=T,W(r.__context)})}}else if(y!==a.NODRAW)if(y===a.FRAGMENT)this.#e(f(null,null,...E),f(null,null,h),l,c);else if(y===a.COMPONENT){this.#t.delete(d.__context.self),this.#e(f(null,null,d.__context?.prevTree),f(null,null,h),l,c);for(const _ of d.__context.fx)_.cb?.()}else y===a.ELEMENT&&(O.length>0&&this.#e(d,f(null,null),l.childNodes[c.value]),Object.hasOwn(d.props,"ref")&&(d.props.ref.current=null)),l.childNodes[c.value].remove()}}__internalAddPending(e){this.#t.add(e)}__internalUpdate(){this.#n||(this.#n=!0,requestIdleCallback(()=>{o.root=this;for(const e of this.#t){const t={value:e.value.__domStart};this.#t.delete(e),this.#e(f(null,null,e.value),f(null,null,{...e.value}),e.value.__ref,t)}this.#n=!1}))}render(e){o.root=this,this.#e(f(null,null),f(null,null,e),this.#l)}}function Q(n){const e=document.querySelector(n);if(!e)throw new Error("Root element doesn't exist");return new J(e)}const C=Symbol.for("freact.fragment");p.Fragment=C,p.createContext=V,p.createRoot=Q,p.h=f,p.memo=F,p.useCallback=$,p.useContext=I,p.useEffect=S,p.useMemo=L,p.useReducer=B,p.useRef=P,p.useState=z,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
(function(d,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(d=typeof globalThis<"u"?globalThis:d||self,c(d.Freact={}))})(this,function(d){"use strict";function c(s,e,...t){const n=e&&Object.hasOwn(e,"key"),o=e?.key;if(delete e?.key,s===R)return n&&(t.key=o),t.length>0?t:void 0;const a={type:s,props:{...e}};return t.length>0&&(a.props.children=t.length>1?t:t[0]),n&&(a.key=o),a}const r={self:null,index:0,data:[],fx:[],root:null};function S(s,e){const t=r.data,n=r.index++;if(!Object.hasOwn(t,n))t[n]={val:s(),deps:e};else{let o=t[n].deps.length===e.length;if(o){for(let a=0;a<e.length;a++)if(!Object.is(t[n].deps[a],e[a])){o=!1;break}}o||(t[n].val=s(),t[n].deps=e)}return t[n].val}const U=(s,e)=>{const t=Object.keys(e);if(t.length!==Object.keys(s).length)return!1;const n=Object.hasOwn(e,"children");if(Object.hasOwn(s,"children")!==n)return!1;if(n){if(s.children.length!==e.children.length)return!1;for(let o=0;o<e.children.length;o++)if(!Object.is(e.children[o],s.children[o]))return!1}for(const o of t)if(o!=="children"&&!Object.is(s[o],e[o]))return!1;return!0};function H(s,e=U){let t=!1;return n=>(t=e(r.self?.value.__context?.prevProps??{},n)?t:!t,S(()=>c(s,n),[t]))}function m(s,e){const t=r.data,n=r.index++;if(!Object.hasOwn(t,n))t[n]={effect:s,cb:null,deps:e??null},r.fx.push(t[n]);else{let o=!!t[n].deps&&t[n].deps?.length===e?.length;if(o){for(let a=0;a<e.length;a++)if(!Object.is(t[n].deps[a],e[a])){o=!1;break}}o||(t[n].effect=s,t[n].deps=e??null)}}function I(s){if(!r.self)throw new Error("Missing context data inside useContext hook");const e=r.data,t=r.index++,n=r.self;return Object.hasOwn(e,t)||(e[t]=T.get(s).value,e[t].subs.add(n)),m(()=>()=>e[t].subs.delete(n),[]),e[t].val}function G(s){const e=r.data,t=r.index++;return Object.hasOwn(e,t)||(e[t]={current:s}),e[t]}const T=new Map;class V{constructor(e){T.set(this,{prev:null,value:{val:e,subs:new Set}})}Provider=({value:e,children:t})=>{const n=G({val:e,subs:new Set});n.current.val!==e&&(n.current.val=e,n.current.subs.forEach(a=>{r.root?.__internalAddPending(a)}));const o=T.get(this);return T.set(this,{prev:o,value:n.current}),m(()=>{T.set(this,o)}),c(R,null,t)};Consumer=({children:e})=>{const t=I(this);return c(R,null,e(t))}}function $(s){return new V(s)}function B(s,e){return S(()=>s,e)}function z(s,e,t){if(!r.root||!r.self)throw new Error("Missing context data inside useReducer hook");const n=r.data,o=r.index++,a=r.root,O=r.self;if(!Object.hasOwn(n,o)){const b=P=>{const x=s(n[o].val,P);Object.is(x,n[o].val)||(n[o].val=x,a.__internalAddPending(O),a.__internalUpdate())};n[o]={val:t?t(e):e,dispatch:b}}return[n[o].val,n[o].dispatch]}function J(s){if(!r.root||!r.self)throw new Error("Missing context data inside useState hook");const e=r.data,t=r.index++,n=r.root,o=r.self;if(!Object.hasOwn(e,t)){const a=O=>{const b=typeof O=="function"?O(e[t].val):O;Object.is(b,e[t].val)||(e[t].val=b,n.__internalAddPending(o),n.__internalUpdate())};e[t]={setter:a,val:typeof s!="function"?s:s()}}return[e[t].val,e[t].setter]}var f=(s=>(s[s.LITERAL=0]="LITERAL",s[s.FRAGMENT=1]="FRAGMENT",s[s.ELEMENT=2]="ELEMENT",s[s.COMPONENT=4]="COMPONENT",s[s.NODRAW=5]="NODRAW",s))(f||{});function A(s){return typeof s!="object"||s===null||!Object.hasOwn(s,"key")?null:s.key}function K(s,e){for(const t of Object.keys(e))typeof e[t]=="object"?K(s[t],e[t]):s[t]=e[t]}function j(s,e,t){e==="class"&&(e="className"),typeof t=="object"?K(s[e],t):s[e]=t}function D(s,e,t){const n=typeof e=="object"?e:document.createTextNode(`${e}`);s.childNodes.length>0?s.insertBefore(n,s.childNodes[t]):s.appendChild(n)}function C(s){return typeof s=="object"&&s!==null?Array.isArray(s)?f.FRAGMENT:typeof s.type=="function"?f.COMPONENT:f.ELEMENT:typeof s=="string"||typeof s=="number"||typeof s=="bigint"?f.LITERAL:f.NODRAW}function W(s,e){const t=r.data,n=r.index,o=r.fx,a=r.self;r.self=s.self,r.index=0,r.data=s.hookData,r.fx=s.fx,e(),r.self=a,r.index=n,r.data=t,r.fx=o}function F(s){for(const e of s.fx)e.effect&&e.cb?.();for(const e of s.fx){if(!e.effect)continue;const t=e.effect();e.effect=null,typeof t=="function"&&(e.cb=t)}}function q(s){return Object.hasOwn(s.props,"children")?Array.isArray(s.props.children)?s.props.children:[s.props.children]:[]}function w(s){const e=Array.isArray(s)?[...s]:[s];for(let t=0;t<e.length;t++){const n=e[t];switch(C(n)){case f.COMPONENT:{e[t]={type:n.type,props:{...n.props},key:n.key,__vnode:n};break}case f.ELEMENT:{const o={type:n.type,props:{...n.props},key:n.key,__vnode:n};n.props.children&&(o.props.children=w(o.props.children)),e[t]=o;break}case f.FRAGMENT:{const o=w(n);o.__vnode=n,e[t]=o;break}}}return Array.isArray(s)?e:e[0]}class Q{#s;#t=new Set;#n=!1;constructor(e){this.#s=e,e.innerHTML=""}#e(e,t,n,o){const a=new Set([...Object.keys(t.props),...Object.keys(e.props)]);for(const l of a)if(l!=="children"){if(l==="ref"){Object.hasOwn(e.props,l)&&(e.props[l].current=null),Object.hasOwn(t.props,l)&&(t.props[l].current=n);continue}if(!Object.hasOwn(t.props,l))l.slice(0,2)==="on"&&typeof e.props[l]=="function"?n.removeEventListener(l.slice(2).toLowerCase(),e.props[l]):n[l]="";else if(!Object.hasOwn(e.props,l))l.slice(0,2)==="on"&&typeof t.props[l]=="function"?n.addEventListener(l.slice(2).toLowerCase(),t.props[l]):j(n,l,t.props[l]);else if(l.slice(0,2)==="on"){if(t.props[l]===e.props[l])continue;const p=l.slice(2).toLowerCase();typeof e.props[l]=="function"?n.removeEventListener(p,e.props[l]):j(n,l,""),typeof t.props[l]=="function"?n.addEventListener(p,t.props[l]):j(n,l,t.props[l])}else if(l==="value"||l==="checked")n[l]!==t.props[l]&&j(n,l,t.props[l]);else{if(t.props[l]===e.props[l])continue;j(n,l,t.props[l])}}const O=q(e),b=q(t),P=Math.max(O.length,b.length),x=new Map,u=o??{value:0};let L=u.value;for(let l=0;l<O.length;l++){const p=O[l],v=b[l],g=A(p),M=A(v),y=C(p),_=L;if(L=y===f.FRAGMENT||y===f.COMPONENT?p.__domEnd:L+1,g===null||g===M)continue;const i=[];for(let h=_;h<L;h++)i.push(n.childNodes[h]);x.set(g,[p,i]),O[l]=void 0}for(const[l,[p,v]]of x)for(const g of v)n.removeChild(g);for(let l=0;l<P;l++){const p=b[l];let v=O[l];const g=A(v),M=A(p);if(M!==null&&M!==g&&x.has(M)){const[E,k]=x.get(M);x.delete(M),g===null&&this.#e(c(null,null,v),c(null,null),n,u),O[l]=E,v=E;for(let N=0;N<k.length;N++)D(n,k[N],u.value+N)}const y=C(v),_=C(p),i=p,h=v;if(_!==f.NODRAW){if(y!==f.NODRAW)if(y!==_||(_===f.ELEMENT||_===f.COMPONENT)&&i.type!==h.type)this.#e(c(null,null,v),c(null,null),n,u),this.#e(c(null,null),c(null,null,p),n,u);else{if(_===f.ELEMENT||_===f.COMPONENT||_===f.FRAGMENT){if(Object.is(h.__vnode,i.__vnode)){i.__vnode=h.__vnode,(_===f.COMPONENT||_===f.FRAGMENT)&&(i.__domStart=h.__domStart,i.__domEnd=h.__domEnd),_===f.COMPONENT&&(i.__context=h.__context,i.__context.self.value=i,i.__ref=h.__ref),u.value=_===f.ELEMENT?u.value+1:h.__domEnd;continue}}else if(Object.is(v,p)){u.value++;continue}if(_===f.LITERAL)n.childNodes[u.value++].textContent=`${p}`;else if(_===f.ELEMENT){const E=n.childNodes[u.value++];this.#e(h,i,E)}else _===f.COMPONENT?(this.#t.delete(h.__context.self),W(h.__context,()=>{const E=w(i.type(i.props));i.__domStart=u.value,i.__ref=n,this.#e(c(null,null,h.__context.prevTree),c(null,null,E),n,u),i.__context=h.__context,i.__context.prevTree=E,i.__context.self.value=i,i.__domEnd=u.value,F(i.__context)})):(i.__domStart=u.value,this.#e(c(null,null,...v),c(null,null,...p),n,u),i.__domEnd=u.value)}else if(_===f.LITERAL)D(n,p,u.value++);else if(_===f.FRAGMENT)i.__domStart=u.value,this.#e(c(null,null),c(null,null,...p),n,u),i.__domEnd=u.value;else if(typeof i.type=="string"){const E=document.createElement(i.type);this.#e(c(i.type,{}),i,E),D(n,E,u.value++)}else if(i.type!==null){const E={hookData:[],fx:[],self:{value:i},prevProps:i.props,prevTree:null};W(E,()=>{const k=w(i.type(i.props));i.__domStart=u.value,i.__ref=n,this.#e(c(null,null),c(null,null,k),n,u),i.__domEnd=u.value,i.__context=E,E.prevTree=k,F(i.__context)})}}else if(y!==f.NODRAW)if(y===f.FRAGMENT)this.#e(c(null,null,...v),c(null,null,p),n,u);else if(y===f.COMPONENT){this.#t.delete(h.__context.self),this.#e(c(null,null,h.__context?.prevTree),c(null,null,p),n,u);for(const E of h.__context.fx)E.cb?.()}else y===f.ELEMENT&&(O.length>0&&this.#e(h,c(null,null),n.childNodes[u.value]),Object.hasOwn(h.props,"ref")&&(h.props.ref.current=null)),n.childNodes[u.value].remove()}}__internalAddPending(e){this.#t.add(e)}__internalUpdate(){this.#n||(this.#n=!0,requestIdleCallback(()=>{r.root=this;for(const e of this.#t){const t={value:e.value.__domStart};this.#t.delete(e),this.#e(c(null,null,e.value),w(c(null,null,e.value)),e.value.__ref,t)}this.#n=!1}))}render(e){r.root=this,this.#e(c(null,null),w(c(null,null,e)),this.#s)}}function X(s){const e=document.querySelector(s);if(!e)throw new Error("Root element doesn't exist");return new Q(e)}const R=Symbol.for("freact.fragment");d.Fragment=R,d.createContext=$,d.createRoot=X,d.h=c,d.memo=H,d.useCallback=B,d.useContext=I,d.useEffect=m,d.useMemo=S,d.useReducer=z,d.useRef=G,d.useState=J,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});

@@ -16,2 +16,3 @@ import { ProviderData } from "./createContext";

__domEnd?: number;
__vnode?: FreactElement;
}

@@ -22,3 +23,3 @@ export type FreactFragment = (FreactNode[] & FreactNodeProps);

export type PropsWithChildren<T> = T & {
children?: FreactNode[];
children?: FreactNode;
key?: KeyType;

@@ -25,0 +26,0 @@ };

{
"name": "@freact/core",
"version": "0.0.11",
"version": "0.0.12",
"author": "Fry",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet