Comparing version 2.6.63 to 2.6.64
@@ -258,3 +258,3 @@ declare type AllowFixed<T> = T extends RxList<infer U> ? U[] | T : T extends RxMap<infer K, infer V> ? [K, V][] | T : T extends Atom<infer U> ? U | T : T; | ||
export declare function createElementNS(type: string, props: AttributesArg, ...children: any[]): HTMLElement | SVGElement | DocumentFragment | ComponentNode; | ||
export declare function createElementNS(type: string, props: AttributesArg, ...children: any[]): HTMLElement | ComponentNode | DocumentFragment | SVGElement; | ||
@@ -336,5 +336,5 @@ /** | ||
export declare class DataContext { | ||
hostPath: Host[]; | ||
hostPath: LinkedNode<Host>; | ||
valueByType: Map<any, any>; | ||
constructor(hostPath: Host[]); | ||
constructor(hostPath: LinkedNode<Host>); | ||
get(contextType: any): any; | ||
@@ -615,2 +615,7 @@ set(contextType: any, value: any): void; | ||
declare type LinkedNode<T> = { | ||
prev: LinkedNode<T> | null; | ||
node: T; | ||
}; | ||
declare class ListNode<T> { | ||
@@ -1335,7 +1340,7 @@ item: T; | ||
elToStyleId: WeakMap<HTMLElement, string>; | ||
getStyleSheetId(hostPath: Host[], elementPath: number[], el: ExtendedElement | null): string; | ||
getStyleSheetId(hostPath: LinkedNode<Host>, elementPath: number[], el: ExtendedElement | null): string; | ||
stringifyStyleObject(styleObject: { | ||
[k: string]: any; | ||
}): string; | ||
update(hostPath: Host[], elementPath: number[], styleObject: StyleObject | StyleObject[], el: ExtendedElement, isStatic?: boolean): Promise<unknown>; | ||
update(hostPath: LinkedNode<Host>, elementPath: number[], styleObject: StyleObject | StyleObject[], el: ExtendedElement, isStatic?: boolean): Promise<unknown>; | ||
isNestedStyleObject(key: string, styleObject: any): boolean; | ||
@@ -1342,0 +1347,0 @@ separateStyleObject(styleObject: StyleObject, transitionPropertyNames: string[]): [StyleObject?, StyleObject?, StyleObject?]; |
1648
dist/axii.js
@@ -1,12 +0,12 @@ | ||
import { isAtom as q, atom as ee, RxList as _, RxSet as ne, RxMap as se, arrayComputed as ie, TrackOpTypes as I, TriggerOpTypes as $, destroyComputed as G, reactive as xe, ReactiveEffect as Le, computed as pe, autorun as me, Notifier as oe, isReactive as ye } from "data0"; | ||
import { isAtom as q, atom as Q, RxList as _, RxSet as rt, RxMap as nt, reactive as xt, ReactiveEffect as Tt, computed as pt, destroyComputed as mt, autorun as yt, Notifier as st, isReactive as vt, TrackOpTypes as it, TriggerOpTypes as ot } from "data0"; | ||
export * from "data0"; | ||
function He(t, e) { | ||
for (let r in t) | ||
e(t[r], r); | ||
function Rt(e, t) { | ||
for (let r in e) | ||
t(e[r], r); | ||
} | ||
function ge(t, e, r = !1) { | ||
if (t.parentElement !== e.parentElement) | ||
function gt(e, t, r = !1) { | ||
if (e.parentElement !== t.parentElement) | ||
throw new Error("placeholder and element parentElement not same"); | ||
let n = t; | ||
for (; n !== e; ) { | ||
let n = e; | ||
for (; n !== t; ) { | ||
const s = n; | ||
@@ -16,23 +16,23 @@ if (n = s.nextSibling, !n) throw new Error("can not find nextSibling"); | ||
} | ||
r && e.remove(); | ||
r && t.remove(); | ||
} | ||
const W = (t) => (t == null ? void 0 : t.constructor) === Object; | ||
function A(t, e) { | ||
if (!t) | ||
throw new Error(e); | ||
const G = (e) => (e == null ? void 0 : e.constructor) === Object; | ||
function b(e, t) { | ||
if (!e) | ||
throw new Error(t); | ||
} | ||
function z(t, e) { | ||
if (t === e) return !0; | ||
if (typeof t != "object" || typeof e != "object" || t === null || e === null) return !1; | ||
const r = Object.keys(t), n = Object.keys(e); | ||
function z(e, t) { | ||
if (e === t) return !0; | ||
if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1; | ||
const r = Object.keys(e), n = Object.keys(t); | ||
if (r.length !== n.length) return !1; | ||
for (let s of r) | ||
if (t[s] !== e[s]) return !1; | ||
if (e[s] !== t[s]) return !1; | ||
return !0; | ||
} | ||
function Re(t) { | ||
return t.length ? new Promise((e) => { | ||
function Lt(e) { | ||
return e.length ? new Promise((t) => { | ||
let r = 0; | ||
const n = (s) => { | ||
r < t.length ? (t[r++](s), requestAnimationFrame(n)) : e(!0); | ||
r < e.length ? (e[r++](s), requestAnimationFrame(n)) : t(!0); | ||
}; | ||
@@ -42,17 +42,17 @@ requestAnimationFrame(n); | ||
} | ||
const Oe = /^(width|height|top|left|right|bottom|margin|padding|border|fontSize|maxWidth|maxHeight|minHeight|minWidth|gap|flexBasis|columnGap|rowGap)/; | ||
let Ee = "px"; | ||
function kt(t) { | ||
Ee = t; | ||
const $t = /^(width|height|top|left|right|bottom|margin|padding|border|fontSize|maxWidth|maxHeight|minHeight|minWidth|gap|flexBasis|columnGap|rowGap)/; | ||
let Et = "px"; | ||
function Ve(e) { | ||
Et = e; | ||
} | ||
function ve(t) { | ||
return typeof t == "string" ? t : `${t}${Ee}`; | ||
function kt(e) { | ||
return typeof e == "string" ? e : `${e}${Et}`; | ||
} | ||
const Ie = /^(boxShadow|textShadow|transition|animation|backgroundImage)/; | ||
function te(t, e) { | ||
return e === void 0 ? "" : Array.isArray(e) ? Ie.test(t) ? e.join(",") : e.map((r) => te(t, r)).join(" ") : typeof e == "number" && Oe.test(t) ? ve(e) : e.toString(); | ||
const Ht = /^(boxShadow|textShadow|transition|animation|backgroundImage)/; | ||
function tt(e, t) { | ||
return t === void 0 ? "" : Array.isArray(t) ? Ht.test(e) ? t.join(",") : t.map((r) => tt(e, r)).join(" ") : typeof t == "number" && $t.test(e) ? kt(t) : t.toString(); | ||
} | ||
function $e(t, e, r) { | ||
function Ot(e, t, r) { | ||
try { | ||
t[e] = r; | ||
e[t] = r; | ||
} catch (n) { | ||
@@ -62,156 +62,161 @@ console.error(n); | ||
} | ||
function Ce(t) { | ||
const e = this._listeners[t.type]; | ||
return Array.isArray(e) ? e.forEach((r) => r == null ? void 0 : r(t, ...this.listenerBoundArgs || [])) : e == null ? void 0 : e(t, ...this.listenerBoundArgs || []); | ||
function St(e) { | ||
const t = this._listeners[e.type]; | ||
return Array.isArray(t) ? t.forEach((r) => r == null ? void 0 : r(e, ...this.listenerBoundArgs || [])) : t == null ? void 0 : t(e, ...this.listenerBoundArgs || []); | ||
} | ||
function Ne(t) { | ||
const e = this._captureListeners[t.type]; | ||
return Array.isArray(e) ? e.forEach((r) => r == null ? void 0 : r(t, ...this.listenerBoundArgs || [])) : e == null ? void 0 : e(t, ...this.listenerBoundArgs || []); | ||
function Nt(e) { | ||
const t = this._captureListeners[e.type]; | ||
return Array.isArray(t) ? t.forEach((r) => r == null ? void 0 : r(e, ...this.listenerBoundArgs || [])) : t == null ? void 0 : t(e, ...this.listenerBoundArgs || []); | ||
} | ||
const Y = /* @__PURE__ */ new WeakMap(); | ||
function De(t) { | ||
return t[0] === "o" && t[1] === "n"; | ||
const X = /* @__PURE__ */ new WeakMap(); | ||
function Vt(e) { | ||
return e[0] === "o" && e[1] === "n"; | ||
} | ||
const Me = /^(strokeWidth|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeDashoffset|strokeDasharray|strokeOpacity|fillOpacity|stopOpacity)/; | ||
function k(t, e, r, n) { | ||
if (Array.isArray(r) && e !== "style" && e !== "className" && !De(e)) | ||
return k(t, e, r.at(-1), n); | ||
if (e === "uuid") { | ||
t.setAttribute("data-uuid", r); | ||
const It = /^(strokeWidth|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeDashoffset|strokeDasharray|strokeOpacity|fillOpacity|stopOpacity)/; | ||
function V(e, t, r, n) { | ||
if (Array.isArray(r) && t !== "style" && t !== "className" && !Vt(t)) | ||
return V(e, t, r.at(-1), n); | ||
if (t === "uuid") { | ||
e.setAttribute("data-uuid", r); | ||
return; | ||
} | ||
if (e[0] === "o" && e[1] === "n") { | ||
const s = e !== (e = e.replace(/Capture$/, "")); | ||
let i = e.toLowerCase().substring(2); | ||
if (t[0] === "o" && t[1] === "n") { | ||
const s = t !== (t = t.replace(/Capture$/, "")); | ||
let i = t.toLowerCase().substring(2); | ||
i === "change" && (i = "input"); | ||
const o = s ? Ne : Ce; | ||
r ? t.addEventListener(i, o, s) : t.removeEventListener(i, o, s); | ||
const a = s ? t._captureListeners || (t._captureListeners = {}) : t._listeners || (t._listeners = {}); | ||
A((a == null ? void 0 : a[i]) === void 0, `${e} already listened`), a[i] = r; | ||
const o = s ? Nt : St; | ||
r ? e.addEventListener(i, o, s) : e.removeEventListener(i, o, s); | ||
const a = s ? e._captureListeners || (e._captureListeners = {}) : e._listeners || (e._listeners = {}); | ||
b((a == null ? void 0 : a[i]) === void 0, `${t} already listened`), a[i] = r; | ||
return; | ||
} | ||
if (e === "style") { | ||
(!r || Array.isArray(r) && !r.length) && (t.style.cssText = r || ""), (Array.isArray(r) ? r : [r]).forEach((i) => { | ||
typeof i == "string" ? t.style.cssText = i : typeof i == "object" ? He(i, (o, a) => { | ||
t.style[a] = te(a, o); | ||
}) : A(!1, "style can only be string or object."); | ||
if (t === "style") { | ||
(!r || Array.isArray(r) && !r.length) && (e.style.cssText = r || ""), (Array.isArray(r) ? r : [r]).forEach((i) => { | ||
typeof i == "string" ? e.style.cssText = i : typeof i == "object" ? Rt(i, (o, a) => { | ||
e.style[a] = tt(a, o); | ||
}) : b(!1, "style can only be string or object."); | ||
}); | ||
return; | ||
} | ||
if (e === "className") { | ||
if (t === "className") { | ||
const s = Array.isArray(r) ? r : [r]; | ||
let i = ""; | ||
s.forEach((o) => { | ||
typeof o == "object" ? Object.entries(o).forEach(([a, c]) => { | ||
c && (i = `${i} ${a}`); | ||
}) : typeof o == "string" ? i = `${i} ${o}` : A(!1, "className can only be string or {[k:string]:boolean}"); | ||
}), t.setAttribute("class", i); | ||
if (typeof o == "object") | ||
for (const a in o) | ||
o[a] && (i = `${i} ${a}`); | ||
else typeof o == "string" ? i = `${i} ${o}` : b(!1, "className can only be string or {[k:string]:boolean}"); | ||
}), e.setAttribute("class", i); | ||
return; | ||
} | ||
if (!(e === "key" || e === "ref")) if (e === "class" && !n) | ||
t.className = r || ""; | ||
else if (e === "value") | ||
t.value = r, t.tagName === "SELECT" ? Y.set(t, r) : t.tagName === "OPTION" ? Se(t) : t.tagName === "INPUT" && t.type === "checkbox" ? r ? t.setAttribute("checked", "true") : t.removeAttribute("checked") : t.tagName === "INPUT" && t.type === "text" && r === void 0 && (t.value = ""); | ||
else if (e === "checked" && t.tagName === "INPUT" && t.type === "checkbox") | ||
r ? t.setAttribute("checked", "true") : t.removeAttribute("checked"); | ||
else if (e === "disabled") | ||
r ? t.setAttribute("disabled", "true") : t.removeAttribute("disabled"); | ||
else if (e === "dangerouslySetInnerHTML") | ||
t.innerHTML = r; | ||
else if (e !== "list" && e !== "type" && !n && e in t) | ||
$e(t, e, r === null ? "" : r), r == null && t.removeAttribute(e); | ||
if (!(t === "key" || t === "ref")) if (t === "class" && !n) | ||
e.className = r || ""; | ||
else if (t === "value") | ||
e.value = r, e.tagName === "SELECT" ? X.set(e, r) : e.tagName === "OPTION" ? wt(e) : e.tagName === "INPUT" && e.type === "checkbox" ? r ? e.setAttribute("checked", "true") : e.removeAttribute("checked") : e.tagName === "INPUT" && e.type === "text" && r === void 0 && (e.value = ""); | ||
else if (t === "checked" && e.tagName === "INPUT" && e.type === "checkbox") | ||
r ? e.setAttribute("checked", "true") : e.removeAttribute("checked"); | ||
else if (t === "disabled") | ||
r ? e.setAttribute("disabled", "true") : e.removeAttribute("disabled"); | ||
else if (t === "dangerouslySetInnerHTML") | ||
e.innerHTML = r; | ||
else if (t !== "list" && t !== "type" && !n && t in e) | ||
Ot(e, t, r === null ? "" : r), r == null && e.removeAttribute(t); | ||
else { | ||
const s = n && e !== (e = e.replace(/^xlink\:?/, "")); | ||
const s = n && t !== (t = t.replace(/^xlink\:?/, "")); | ||
if (r == null || r === !1) | ||
s ? t.removeAttributeNS("http://www.w3.org/1999/xlink", e.toLowerCase()) : e.toLowerCase() === "contenteditable" && r === !1 ? t.setAttribute(e, "false") : t.removeAttribute(e); | ||
s ? e.removeAttributeNS("http://www.w3.org/1999/xlink", t.toLowerCase()) : t.toLowerCase() === "contenteditable" && r === !1 ? e.setAttribute(t, "false") : e.removeAttribute(t); | ||
else if (typeof r != "function" && s) | ||
t.setAttributeNS("http://www.w3.org/1999/xlink", e.toLowerCase(), r); | ||
e.setAttributeNS("http://www.w3.org/1999/xlink", t.toLowerCase(), r); | ||
else { | ||
const i = n && Me.test(e) ? e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase() : e; | ||
t.setAttribute(i, r); | ||
const i = n && It.test(t) ? t.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase() : t; | ||
e.setAttribute(i, r); | ||
} | ||
} | ||
} | ||
function g(t, e, ...r) { | ||
const { _isSVG: n, ...s } = e || {}; | ||
let i; | ||
const o = r.length ? r : s.children || []; | ||
if (t === we) | ||
i = document.createDocumentFragment(); | ||
else if (typeof t == "string") | ||
i = n ? document.createElementNS("http://www.w3.org/2000/svg", t) : document.createElement(t); | ||
else | ||
return { type: t, props: s, children: o }; | ||
const a = [], c = [], u = [], p = []; | ||
o == null || o.forEach((l, h) => { | ||
if (l != null) | ||
if (typeof l == "string" || typeof l == "number") | ||
i.appendChild(document.createTextNode(l.toString())); | ||
else if (l instanceof HTMLElement || l instanceof DocumentFragment || l instanceof SVGElement) { | ||
i.appendChild(l); | ||
const f = l, y = f.unhandledChildren || []; | ||
c.push(...y.map((E) => ({ ...E, path: [h, ...E.path] }))); | ||
const m = f.unhandledAttr || []; | ||
a.push(...m.map((E) => ({ ...E, path: [h, ...E.path] }))); | ||
const C = f.refHandles || []; | ||
u.push(...C.map((E) => ({ ...E, path: [h, ...E.path] }))); | ||
const x = f.detachStyledChildren || []; | ||
p.push(...x.map((E) => ({ ...E, path: [h, ...E.path] }))), delete f.unhandledChildren, delete f.unhandledAttr, delete f.refHandles, delete f.detachStyledChildren; | ||
} else { | ||
const f = document.createComment("unhandledChild"); | ||
i.appendChild(f), c.push({ placeholder: f, child: l, path: [h] }); | ||
} | ||
}), s && (s.ref && (u.push({ handle: s.ref, path: [], el: i }), delete s.ref), s.detachStyle && (p.push({ el: i, style: s.detachStyle, path: [] }), delete s.detachStyle), Object.entries(s).forEach(([l, h]) => { | ||
g.isValidAttribute(l, h) ? k(i, l, h, n) : a.push({ el: i, key: l, value: h, path: [] }); | ||
})); | ||
const d = i; | ||
return c.length && (d.unhandledChildren = c), a && (d.unhandledAttr = a), u.length && (d.refHandles = u), p.length && (d.detachStyledChildren = p), i; | ||
function w(e, t, ...r) { | ||
const { _isSVG: n, ref: s, detachStyle: i, children: o, ...a } = t || {}; | ||
if (typeof e != "string" && e !== F) { | ||
const u = r.length ? r : o || []; | ||
return { type: e, props: t || {}, children: u }; | ||
} | ||
const c = e === F ? document.createDocumentFragment() : n ? document.createElementNS("http://www.w3.org/2000/svg", e) : document.createElement(e), h = [], p = [], f = [], m = [], d = r.length ? r : o || []; | ||
if (e !== F && d.length === 1 && (typeof d[0] == "string" || typeof d[0] == "number")) | ||
c.textContent = d[0].toString(); | ||
else if (d.length) { | ||
const u = document.createDocumentFragment(); | ||
d.forEach((l, S) => { | ||
var x, T, v, R; | ||
if (l != null) | ||
if (typeof l == "string" || typeof l == "number") | ||
u.appendChild(document.createTextNode(l.toString())); | ||
else if (l instanceof Node) { | ||
u.appendChild(l); | ||
const y = l; | ||
(x = y.unhandledChildren) != null && x.length && (p.push(...y.unhandledChildren.map((E) => ({ ...E, path: [S, ...E.path] }))), y.unhandledChildren = void 0), (T = y.unhandledAttr) != null && T.length && (h.push(...y.unhandledAttr.map((E) => ({ ...E, path: [S, ...E.path] }))), y.unhandledAttr = void 0), (v = y.refHandles) != null && v.length && (f.push(...y.refHandles.map((E) => ({ ...E, path: [S, ...E.path] }))), y.refHandles = void 0), (R = y.detachStyledChildren) != null && R.length && (m.push(...y.detachStyledChildren.map((E) => ({ ...E, path: [S, ...E.path] }))), y.detachStyledChildren = void 0); | ||
} else { | ||
const y = document.createComment("unhandledChild"); | ||
u.appendChild(y), p.push({ placeholder: y, child: l, path: [S] }); | ||
} | ||
}), c.appendChild(u); | ||
} | ||
if (t) { | ||
s && f.push({ handle: s, path: [], el: c }), i && m.push({ el: c, style: i, path: [] }); | ||
for (const u in a) { | ||
const l = a[u]; | ||
w.isValidAttribute(u, a) ? V(c, u, l, n) : h.push({ el: c, key: u, value: l, path: [] }); | ||
} | ||
} | ||
const g = c; | ||
return p.length && (g.unhandledChildren = p), h.length && (g.unhandledAttr = h), f.length && (g.refHandles = f), m.length && (g.detachStyledChildren = m), c; | ||
} | ||
function ae(t) { | ||
return typeof t == "string" || typeof t == "number" || t instanceof M; | ||
function at(e) { | ||
return typeof e == "string" || typeof e == "number" || e instanceof N; | ||
} | ||
function ke(t) { | ||
return W(t) && Object.entries(t).every( | ||
([e, r]) => /[a-zA-Z\-]+/.test(e) && ae(r) || Array.isArray(r) && r.every(ae) | ||
function Mt(e) { | ||
return G(e) && Object.entries(e).every( | ||
([t, r]) => /[a-zA-Z\-]+/.test(t) && at(r) || Array.isArray(r) && r.every(at) | ||
); | ||
} | ||
g.isValidAttribute = function(t, e) { | ||
return Array.isArray(e) ? e.every((r) => g.isValidAttribute(t, r)) : !!(typeof e != "object" && typeof e != "function" || t[0] === "o" && t[1] === "n" && typeof e == "function" || (ke(e) || typeof e == "string") && t === "style" || W(e) && t === "className"); | ||
w.isValidAttribute = function(e, t) { | ||
if (Array.isArray(t)) | ||
return t.every((n) => w.isValidAttribute(e, n)); | ||
const r = typeof t; | ||
return !!(r !== "object" && r !== "function" || e[0] === "o" && e[1] === "n" && r === "function" || e === "style" && (Mt(t) || r === "string") || e === "className" && G(t)); | ||
}; | ||
g.attachRef = function(t, e) { | ||
if (Array.isArray(e)) { | ||
e.forEach((r) => g.attachRef(t, r)); | ||
w.attachRef = function(e, t) { | ||
if (Array.isArray(t)) { | ||
t.forEach((r) => w.attachRef(e, r)); | ||
return; | ||
} | ||
typeof e == "function" ? e(t) : typeof e == "object" ? e.current = t : A(!1, "ref should be function or object with current property"); | ||
typeof t == "function" ? t(e) : typeof t == "object" ? t.current = e : b(!1, "ref should be function or object with current property"); | ||
}; | ||
g.detachRef = function(t) { | ||
if (Array.isArray(t)) { | ||
t.forEach((e) => g.detachRef(e)); | ||
w.detachRef = function(e) { | ||
if (Array.isArray(e)) { | ||
e.forEach((t) => w.detachRef(t)); | ||
return; | ||
} | ||
typeof t == "function" ? t(null) : typeof t == "object" ? t.current = null : A(!1, "ref should be function or object with current property"); | ||
typeof e == "function" ? e(null) : typeof e == "object" ? e.current = null : b(!1, "ref should be function or object with current property"); | ||
}; | ||
function we() { | ||
function F() { | ||
} | ||
function Se(t) { | ||
const e = t.parentElement; | ||
Y.has(e) && (e.value = Y.get(e)); | ||
function wt(e) { | ||
const t = e.parentElement; | ||
X.has(t) && (t.value = X.get(t)); | ||
} | ||
function S(t, e) { | ||
const r = e.parentNode.insertBefore(t, e); | ||
return t.tagName === "OPTION" && Se(t), r; | ||
function k(e, t) { | ||
const r = t.parentNode.insertBefore(e, t); | ||
return e instanceof HTMLOptionElement && wt(e), r; | ||
} | ||
function Vt(t, e, ...r) { | ||
return g(t, { _isSVG: !0, ...e || {} }, r); | ||
function Ie(e, t, ...r) { | ||
return w(e, { _isSVG: !0, ...t || {} }, r); | ||
} | ||
function Ve(t, e, ...r) { | ||
return g(t, { _isSVG: !0, ...e || {} }, r); | ||
function jt(e, t, ...r) { | ||
return w(e, { _isSVG: !0, ...t || {} }, r); | ||
} | ||
function jt(t, e) { | ||
return Ce.call(t, e); | ||
function Me(e, t) { | ||
return St.call(e, t); | ||
} | ||
class M { | ||
constructor(e, r = "px") { | ||
this.value = e, this.unit = r, typeof e == "string" && (this.unit = "mixed"); | ||
class N { | ||
constructor(t, r = "px") { | ||
this.value = t, this.unit = r, typeof t == "string" && (this.unit = "mixed"); | ||
} | ||
@@ -222,3 +227,3 @@ toString() { | ||
clone() { | ||
return new M(this.value, this.unit); | ||
return new N(this.value, this.unit); | ||
} | ||
@@ -228,15 +233,15 @@ valueOf() { | ||
} | ||
mul(e) { | ||
return typeof this.value == "number" ? this.value = this.value * e : (this.value = `(${this.value}) * ${e}`, this.unit = "mixed"), this; | ||
mul(t) { | ||
return typeof this.value == "number" ? this.value = this.value * t : (this.value = `(${this.value}) * ${t}`, this.unit = "mixed"), this; | ||
} | ||
div(e) { | ||
return typeof this.value == "number" ? this.value = this.value / e : (this.value = `(${this.value}) / ${e}`, this.unit = "mixed"), this; | ||
div(t) { | ||
return typeof this.value == "number" ? this.value = this.value / t : (this.value = `(${this.value}) / ${t}`, this.unit = "mixed"), this; | ||
} | ||
add(e, r) { | ||
if (typeof this.value == "number" && typeof e == "number" && (!r || r === this.unit)) | ||
this.value = this.value + e; | ||
else if (typeof this.value == "number" && e instanceof M && this.unit === e.unit) | ||
this.value = this.value + e.value; | ||
add(t, r) { | ||
if (typeof this.value == "number" && typeof t == "number" && (!r || r === this.unit)) | ||
this.value = this.value + t; | ||
else if (typeof this.value == "number" && t instanceof N && this.unit === t.unit) | ||
this.value = this.value + t.value; | ||
else { | ||
const n = typeof this.value == "number" ? `${this.value}${this.unit}` : `(${this.value})`, s = typeof e == "number" ? `${e}${r || this.unit}` : e.unit === "mixed" ? `(${e.value})` : e.toString(); | ||
const n = typeof this.value == "number" ? `${this.value}${this.unit}` : `(${this.value})`, s = typeof t == "number" ? `${t}${r || this.unit}` : t.unit === "mixed" ? `(${t.value})` : t.toString(); | ||
this.value = `${n} + ${s}`, this.unit = "mixed"; | ||
@@ -246,9 +251,9 @@ } | ||
} | ||
sub(e, r) { | ||
if (typeof this.value == "number" && typeof e == "number" && (!r || r === this.unit)) | ||
this.value = this.value - e; | ||
else if (typeof this.value == "number" && e instanceof M && this.unit === e.unit) | ||
this.value = this.value - e.value; | ||
sub(t, r) { | ||
if (typeof this.value == "number" && typeof t == "number" && (!r || r === this.unit)) | ||
this.value = this.value - t; | ||
else if (typeof this.value == "number" && t instanceof N && this.unit === t.unit) | ||
this.value = this.value - t.value; | ||
else { | ||
const n = typeof this.value == "number" ? `${this.value}${this.unit}` : `(${this.value})`, s = typeof e == "number" ? `${e}${r || this.unit}` : e.unit === "mixed" ? `(${e.value})` : e.toString(); | ||
const n = typeof this.value == "number" ? `${this.value}${this.unit}` : `(${this.value})`, s = typeof t == "number" ? `${t}${r || this.unit}` : t.unit === "mixed" ? `(${t.value})` : t.toString(); | ||
this.value = `${n} - ${s}`, this.unit = "mixed"; | ||
@@ -259,19 +264,19 @@ } | ||
} | ||
function Ft(t, { children: e, ...r }) { | ||
return g(t, r, e); | ||
function je(e, { children: t, ...r }) { | ||
return w(e, r, t); | ||
} | ||
function _t(t, { children: e, ...r }) { | ||
return g(t, r, [e]); | ||
function De(e, { children: t, ...r }) { | ||
return w(e, r, [t]); | ||
} | ||
function Gt(t, { children: e, ...r }) { | ||
return Array.isArray(e) ? g(t, r, e) : g(t, r, e ? [e] : []); | ||
function Fe(e, { children: t, ...r }) { | ||
return Array.isArray(t) ? w(e, r, t) : w(e, r, t ? [t] : []); | ||
} | ||
function je() { | ||
function Dt() { | ||
} | ||
function ce(t) { | ||
const e = typeof t; | ||
return e === "string" || e === "number"; | ||
function ct(e) { | ||
const t = typeof e; | ||
return t === "string" || t === "number"; | ||
} | ||
function P(t) { | ||
function e(...r) { | ||
function C(e) { | ||
function t(...r) { | ||
var s, i, o; | ||
@@ -282,6 +287,6 @@ function n(a) { | ||
} | ||
return n.argv = r, n.stringify = (s = t.stringify) == null ? void 0 : s.bind(n), n.parse = (i = t.parse) == null ? void 0 : i.bind(n), n.check = (o = t.check) == null ? void 0 : o.bind(n), n.is = t.is || ((a) => a === e), n.zeroValue = t.zeroValue, n.required = t.required, n.createDefaultValue = t.createDefaultValue, n.coerce = t.coerce, n.required || Object.defineProperty(n, "isRequired", { | ||
return n.argv = r, n.stringify = (s = e.stringify) == null ? void 0 : s.bind(n), n.parse = (i = e.parse) == null ? void 0 : i.bind(n), n.check = (o = e.check) == null ? void 0 : o.bind(n), n.is = e.is || ((a) => a === t), n.zeroValue = e.zeroValue, n.required = e.required, n.createDefaultValue = e.createDefaultValue, n.coerce = e.coerce, n.required || Object.defineProperty(n, "isRequired", { | ||
get() { | ||
return P({ | ||
...t, | ||
return C({ | ||
...e, | ||
required: !0, | ||
@@ -299,4 +304,4 @@ // CAUTION 注意这里 isRequired.is 和之前一样 | ||
get() { | ||
return (a) => P({ | ||
...t, | ||
return (a) => C({ | ||
...e, | ||
required: n.required, | ||
@@ -309,5 +314,5 @@ createDefaultValue: a, | ||
} | ||
return e; | ||
return t; | ||
} | ||
function T(t, e) { | ||
function P(e, t) { | ||
const { | ||
@@ -319,12 +324,12 @@ stringify: r = JSON.stringify, | ||
...o | ||
} = e, a = function(c) { | ||
if (typeof t == "function" && !t(c)) | ||
} = t, a = function(c) { | ||
if (typeof e == "function" && !e(c)) | ||
return new Error(`${c} type check failed`); | ||
if (typeof t == "string" && typeof c !== t) | ||
return new Error(`${c} is not ${t}`); | ||
if (typeof e == "string" && typeof c !== e) | ||
return new Error(`${c} is not ${e}`); | ||
}; | ||
return a.stringify = r, a.parse = n, a.check = (c) => typeof t == "string" ? typeof c === t : t(c), a.is = s || ((c) => c === a), a.required = !!i, Object.assign(a, o), a.required || Object.defineProperty(a, "isRequired", { | ||
return a.stringify = r, a.parse = n, a.check = (c) => typeof e == "string" ? typeof c === e : e(c), a.is = s || ((c) => c === a), a.required = !!i, Object.assign(a, o), a.required || Object.defineProperty(a, "isRequired", { | ||
get() { | ||
return T(t, { | ||
...e, | ||
return P(e, { | ||
...t, | ||
required: !0, | ||
@@ -341,4 +346,4 @@ is: a.is | ||
get() { | ||
return (c) => T(t, { | ||
...e, | ||
return (c) => P(e, { | ||
...t, | ||
required: a.required, | ||
@@ -351,33 +356,33 @@ createDefaultValue: c, | ||
} | ||
const Fe = P({ | ||
stringify(t) { | ||
return t === null ? "" : ce(this.argv[0][0]) ? t.toString() : JSON.stringify(t); | ||
const Ft = C({ | ||
stringify(e) { | ||
return e === null ? "" : ct(this.argv[0][0]) ? e.toString() : JSON.stringify(e); | ||
}, | ||
parse(t) { | ||
return ce(this.argv[0][0]) ? typeof this.argv[0][0] == "string" ? t : parseFloat(t) : JSON.parse(t); | ||
parse(e) { | ||
return ct(this.argv[0][0]) ? typeof this.argv[0][0] == "string" ? e : parseFloat(e) : JSON.parse(e); | ||
}, | ||
check(t) { | ||
return this.argv[0].includes(t); | ||
check(e) { | ||
return this.argv[0].includes(e); | ||
}, | ||
zeroValue: [] | ||
}), _e = { | ||
}), _t = { | ||
zeroValue: "" | ||
}, Ge = T("string", _e), ze = { | ||
stringify(t) { | ||
return t.toString(); | ||
}, zt = P("string", _t), Bt = { | ||
stringify(e) { | ||
return e.toString(); | ||
}, | ||
parse(t) { | ||
if (/-?\d+(\.\d+)?/.test(t)) return parseFloat(t); | ||
throw new Error(`${t} is not a number`); | ||
parse(e) { | ||
if (/-?\d+(\.\d+)?/.test(e)) return parseFloat(e); | ||
throw new Error(`${e} is not a number`); | ||
}, | ||
zeroValue: 0 | ||
}, Be = T("number", ze), qe = { zeroValue: null }, We = T((t) => typeof t == "object" && !Array.isArray(t), qe), Ke = T((t) => Array.isArray(t), {}), Xe = { zeroValue: !1 }, Ye = T("bool", Xe), Ue = { | ||
stringify(t) { | ||
return t.toString(); | ||
}, qt = P("number", Bt), Gt = { zeroValue: null }, Wt = P((e) => typeof e == "object" && !Array.isArray(e), Gt), Kt = P((e) => Array.isArray(e), {}), Xt = { zeroValue: !1 }, Yt = P("bool", Xt), Ut = { | ||
stringify(e) { | ||
return e.toString(); | ||
}, | ||
// eslint-disable-next-line no-new-func | ||
parse(t) { | ||
return new Function(t); | ||
parse(e) { | ||
return new Function(e); | ||
} | ||
}, Je = T("function", Ue), Ze = T("symbol", {}), Qe = { | ||
}, Jt = P("function", Ut), Zt = P("symbol", {}), Qt = { | ||
stringify() { | ||
@@ -392,231 +397,114 @@ throw new Error("type any can not stringify"); | ||
} | ||
}, K = T(() => !0, Qe), et = P({ | ||
check(t) { | ||
return this.argv[0].some((e) => e.check(t)); | ||
}, W = P(() => !0, Qt), te = C({ | ||
check(e) { | ||
return this.argv[0].some((t) => t.check(e)); | ||
}, | ||
stringify(t) { | ||
return this.argv[0].find((r) => !(r(t) instanceof Error)).stringify(t); | ||
stringify(e) { | ||
return this.argv[0].find((r) => !(r(e) instanceof Error)).stringify(e); | ||
}, | ||
parse(t) { | ||
let e; | ||
parse(e) { | ||
let t; | ||
if (!this.argv[0].some((n) => { | ||
try { | ||
const s = n.parse(t); | ||
const s = n.parse(e); | ||
if (this.check(s)) | ||
return e = s, !0; | ||
return t = s, !0; | ||
} catch { | ||
} | ||
return !1; | ||
})) throw new Error(`can not parse ${t}`); | ||
return e; | ||
})) throw new Error(`can not parse ${e}`); | ||
return t; | ||
} | ||
}), tt = P({ | ||
check(t) { | ||
return Array.isArray(t) ? t.every((e) => this.argv[0].check(e)) : !1; | ||
}), ee = C({ | ||
check(e) { | ||
return Array.isArray(e) ? e.every((t) => this.argv[0].check(t)) : !1; | ||
}, | ||
stringify(t) { | ||
stringify(e) { | ||
}, | ||
parse(t) { | ||
parse(e) { | ||
}, | ||
zeroValue: [] | ||
}), rt = P({ | ||
check(t) { | ||
}), re = C({ | ||
check(e) { | ||
return !0; | ||
}, | ||
stringify(t) { | ||
stringify(e) { | ||
}, | ||
parse(t) { | ||
parse(e) { | ||
} | ||
}), nt = P({ | ||
check(t) { | ||
return Object.entries(this.argv[0]).every(([e, r]) => r.check(t[e])); | ||
}), ne = C({ | ||
check(e) { | ||
return Object.entries(this.argv[0]).every(([t, r]) => r.check(e[t])); | ||
}, | ||
stringify(t) { | ||
return `{${Object.entries(this.argv[0]).map(([e, r]) => `${e}:${JSON.stringify(r.stringify(t[e]))}`).join(",")}`; | ||
stringify(e) { | ||
return `{${Object.entries(this.argv[0]).map(([t, r]) => `${t}:${JSON.stringify(r.stringify(e[t]))}`).join(",")}`; | ||
}, | ||
parse(t) { | ||
const e = JSON.parse(t); | ||
return Object.keys(e).forEach((r) => { | ||
e[r] = this.argv[0][r].parse(e[r]); | ||
}), e; | ||
parse(e) { | ||
const t = JSON.parse(e); | ||
return Object.keys(t).forEach((r) => { | ||
t[r] = this.argv[0][r].parse(t[r]); | ||
}), t; | ||
} | ||
}), st = K, it = K, ot = K, at = je; | ||
function ct() { | ||
return P({ | ||
coerce: (t) => q(t) ? t : ee(t) | ||
}), se = W, ie = W, oe = W, ae = Dt; | ||
function ce() { | ||
return C({ | ||
coerce: (e) => q(e) ? e : Q(e) | ||
})(); | ||
} | ||
function lt() { | ||
return P({ | ||
coerce: (t) => t instanceof _ ? t : new _(t) | ||
function he() { | ||
return C({ | ||
coerce: (e) => e instanceof _ ? e : new _(e) | ||
})(); | ||
} | ||
function ht() { | ||
return P({ | ||
coerce: (t) => t instanceof ne ? t : new ne(t) | ||
function le() { | ||
return C({ | ||
coerce: (e) => e instanceof rt ? e : new rt(e) | ||
})(); | ||
} | ||
function ut() { | ||
return P({ | ||
coerce: (t) => t instanceof se ? t : new se(t) | ||
function ue() { | ||
return C({ | ||
coerce: (e) => e instanceof nt ? e : new nt(e) | ||
})(); | ||
} | ||
const v = { | ||
string: Ge, | ||
number: Be, | ||
object: We, | ||
array: Ke, | ||
bool: Ye, | ||
function: Je, | ||
symbol: Ze, | ||
node: st, | ||
element: it, | ||
elementType: ot, | ||
const H = { | ||
string: zt, | ||
number: qt, | ||
object: Wt, | ||
array: Kt, | ||
bool: Yt, | ||
function: Jt, | ||
symbol: Zt, | ||
node: se, | ||
element: ie, | ||
elementType: oe, | ||
// instanceOf | ||
// 枚举值 | ||
oneOf: Fe, | ||
oneOf: Ft, | ||
// 枚举类型 | ||
oneOfType: et, | ||
oneOfType: te, | ||
// 数组类型,里面的值应该只能跟类型 | ||
arrayOf: tt, | ||
arrayOf: ee, | ||
// objectOf, | ||
// 对象结构的嵌套类型。shape + arrayOf + oneOfType + any 可以描述任何 schema。 | ||
shapeOf: rt, | ||
shapeOf: re, | ||
// map 类型,就是简单的 kv,应该是 shape 的子集。 | ||
map: nt, | ||
map: ne, | ||
// exact, | ||
// customProps/customArrayProps | ||
any: K, | ||
checkPropTypes: at, | ||
any: W, | ||
checkPropTypes: ae, | ||
// reactive types | ||
atom: ct, | ||
rxList: lt, | ||
rxSet: ht, | ||
rxMap: ut | ||
}; | ||
function ft(t, e) { | ||
const r = t[1] === void 0 ? t.length < 2 ? 1 / 0 : 0 : t[1], n = r < 0 ? 0 : r; | ||
return n !== 1 / 0 ? n : e - t[0]; | ||
} | ||
class dt { | ||
constructor(e, r, n) { | ||
this.source = e, this.placeholder = r, this.pathContext = n, this.createHost = ([s, i]) => R(s, i, { ...this.pathContext, hostPath: [...this.pathContext.hostPath, this] }); | ||
} | ||
createPlaceholder(e) { | ||
return [e, document.createComment("frag item host")]; | ||
} | ||
isOnlyChildrenOfParent() { | ||
const e = this.placeholder.parentElement; | ||
return (e == null ? void 0 : e.lastChild) === this.placeholder && e.firstChild === this.element; | ||
} | ||
get element() { | ||
var e, r; | ||
return ((r = (e = this.hostsComputed) == null ? void 0 : e[0]) == null ? void 0 : r.element) || this.placeholder; | ||
} | ||
render() { | ||
const e = this; | ||
this.placeholderAndItemComputed = ie( | ||
function() { | ||
if (this.manualTrack(e.source, I.METHOD, $.METHOD), this.manualTrack(e.source, I.EXPLICIT_KEY_CHANGE, $.EXPLICIT_KEY_CHANGE), e.hostsComputed) | ||
throw new Error("should never recompute reactiveArray"); | ||
return e.source.map(e.createPlaceholder); | ||
}, | ||
function(n, s) { | ||
s.forEach(({ method: i, argv: o, result: a }) => { | ||
var c, u, p; | ||
if (i === "push") { | ||
const d = o.map(e.createPlaceholder); | ||
n.push(...d); | ||
} else if (i === "pop") | ||
n.pop(); | ||
else if (i === "shift") | ||
n.shift(); | ||
else if (i === "unshift") { | ||
const d = o.map(e.createPlaceholder); | ||
n.unshift(...d); | ||
} else if (i === "splice") { | ||
const d = o.slice(2).map(e.createPlaceholder); | ||
n.splice(o[0], o[1], ...d); | ||
} else if (!i && a) | ||
(c = a.add) == null || c.forEach(({}) => { | ||
throw new Error("can not use obj[key] = value to add item to reactive array, use push instead."); | ||
}), (u = a.remove) == null || u.forEach(({}) => { | ||
throw new Error("can not use delete obj[key] to delete item, use splice instead."); | ||
}), (p = a.update) == null || p.forEach(({ key: d, newValue: l }) => { | ||
n[d] = e.createPlaceholder(l); | ||
}); | ||
else | ||
throw new Error("unknown trigger info"); | ||
}); | ||
}, | ||
function(n) { | ||
n(); | ||
} | ||
), this.hostsComputed = ie( | ||
function() { | ||
var i; | ||
if ((i = e.hostsComputed) != null && i.length) throw new Error("hostsComputed should not recompute"); | ||
this.manualTrack(e.placeholderAndItemComputed, I.METHOD, $.METHOD), this.manualTrack(e.placeholderAndItemComputed, I.EXPLICIT_KEY_CHANGE, $.EXPLICIT_KEY_CHANGE); | ||
const n = e.placeholderAndItemComputed.map(([o, a]) => R(o, a, { ...e.pathContext, hostPath: [...e.pathContext.hostPath, e] })), s = document.createDocumentFragment(); | ||
return n.forEach((o) => { | ||
s.appendChild(o.placeholder), o.render(); | ||
}), S(s, e.placeholder), n; | ||
}, | ||
function(n, s) { | ||
s.forEach(({ method: i, argv: o, result: a }) => { | ||
var c, u, p, d; | ||
if (i === "push") { | ||
const l = o.map(e.createHost), h = document.createDocumentFragment(); | ||
l.forEach((f) => { | ||
h.appendChild(f.placeholder), f.render(); | ||
}), S(h, e.placeholder), n.push(...l); | ||
} else if (i === "pop") | ||
n.pop().destroy(); | ||
else if (i === "shift") | ||
n.shift().destroy(); | ||
else if (i === "unshift") { | ||
const l = o.map(e.createHost), h = document.createDocumentFragment(); | ||
l.forEach((f) => { | ||
h.appendChild(f.placeholder), f.render(); | ||
}), S(h, e.element), n.unshift(...l); | ||
} else if (i === "splice") { | ||
const l = document.createDocumentFragment(), h = o.slice(2).map(e.createHost); | ||
if (h.forEach((f) => { | ||
l.appendChild(f.placeholder), f.render(); | ||
}), o[0] === 0 && o[1] >= n.length && e.isOnlyChildrenOfParent()) { | ||
const f = e.placeholder.parentNode; | ||
!h.length && f instanceof HTMLElement ? (f.innerHTML = "", f.appendChild(l)) : f.replaceChildren(l), f.appendChild(e.placeholder), n.forEach((y) => y.destroy(!0)), n.splice(0, 1 / 0, ...h); | ||
} else { | ||
const f = ft(o, n.length); | ||
S(l, ((c = n[o[0] + f]) == null ? void 0 : c.element) || e.placeholder), n.splice(o[0], f, ...h).forEach((m) => m.destroy()); | ||
} | ||
} else if (!i && a) | ||
(u = a.add) == null || u.forEach(({}) => { | ||
throw new Error("should never occur"); | ||
}), (p = a.remove) == null || p.forEach(({}) => { | ||
throw new Error("should never occur"); | ||
}), (d = a.update) == null || d.forEach(({ key: l, newValue: h }) => { | ||
var f; | ||
n[l].destroy(), n[l] = e.createHost(h), S(n[l].placeholder, ((f = n[parseInt(l, 10) + 1]) == null ? void 0 : f.element) || e.placeholder), n[l].render(); | ||
}); | ||
else | ||
throw new Error("unknown trigger info"); | ||
}); | ||
}, | ||
!0 | ||
); | ||
} | ||
destroy(e, r) { | ||
r || (G(this.hostsComputed), G(this.placeholderAndItemComputed)), this.hostsComputed.forEach((n) => n.destroy(e)), e || this.placeholder.remove(); | ||
} | ||
} | ||
const le = /* @__PURE__ */ new WeakSet(); | ||
function pt({ container: t, content: e, destroyOnUnmount: r }, { useEffect: n, pathContext: s }) { | ||
typeof e != "function" && (le.has(e) && console.error("static portal content can only be rendered once. Use function content for content has reactive parts."), le.add(e)); | ||
const i = vt(t, s); | ||
return i.render(e), n(() => () => { | ||
atom: ce, | ||
rxList: he, | ||
rxSet: le, | ||
rxMap: ue | ||
}, ht = /* @__PURE__ */ new WeakSet(); | ||
function fe({ container: e, content: t, destroyOnUnmount: r }, { useEffect: n, pathContext: s }) { | ||
typeof t != "function" && (ht.has(t) && console.error("static portal content can only be rendered once. Use function content for content has reactive parts."), ht.add(t)); | ||
const i = Le(e, s); | ||
return i.render(t), n(() => () => { | ||
i.destroy(); | ||
}), null; | ||
} | ||
function mt() { | ||
function de() { | ||
return { | ||
@@ -626,54 +514,65 @@ current: null | ||
} | ||
function yt() { | ||
const t = ee(null); | ||
function pe() { | ||
const e = Q(null); | ||
return new Proxy({}, { | ||
get: (e, r) => { | ||
get: (t, r) => { | ||
if (r === "current") | ||
return t(); | ||
return e(); | ||
}, | ||
set: (e, r, n) => (r === "current" && t(n), !0) | ||
set: (t, r, n) => (r === "current" && e(n), !0) | ||
}); | ||
} | ||
function H(t) { | ||
return t ? Array.isArray(t) ? t : [t] : []; | ||
function M(e, t) { | ||
return { | ||
prev: t, | ||
node: e | ||
}; | ||
} | ||
function gt(t, e) { | ||
const r = { ...t }; | ||
return Object.entries(e).forEach(([n, s]) => { | ||
r[n] = U(n, t[n], s); | ||
}), r; | ||
function $(e) { | ||
return e ? Array.isArray(e) ? e : [e] : []; | ||
} | ||
function U(t, e, r) { | ||
return e && (t.startsWith("on") || t === "ref" || t === "style" || t === "classname" || t === "class") ? t === "style" ? H(e).concat(r) : H(r).concat(e) : r; | ||
function me(e, t) { | ||
const r = { ...e }; | ||
for (const n in t) { | ||
const s = t[n]; | ||
r[n] = Y(n, e[n], s); | ||
} | ||
return r; | ||
} | ||
const X = "__config__", L = class L { | ||
constructor({ type: e, props: r = {}, children: n }, s, i) { | ||
this.placeholder = s, this.pathContext = i, this.layoutEffects = /* @__PURE__ */ new Set(), this.effects = /* @__PURE__ */ new Set(), this.destroyCallback = /* @__PURE__ */ new Set(), this.layoutEffectDestroyHandles = /* @__PURE__ */ new Set(), this.refs = xe({}), this.itemConfig = {}, this.frame = [], this.exposed = {}, this.createHTMLOrSVGElement = (o, a, c, ...u) => { | ||
var x, E, N, D; | ||
const p = typeof a == "function", d = c == null ? void 0 : c.as; | ||
if (c == null || delete c.as, A(d !== "self", '"self" is reserved, please use another element name.'), d && ((x = this.itemConfig[d]) != null && x.use) && ((E = this.itemConfig[d]) == null ? void 0 : E.use) instanceof Element) | ||
return this.itemConfig[d].use; | ||
let l = u, { props: h, componentProps: f } = this.separateProps(c); | ||
const y = this.itemConfig[d]; | ||
d && y && (y.props && (p ? h = { ...c, ...y.props } : h = gt(c, y.props)), y.propMergeHandles && Object.entries(y.propMergeHandles).forEach(([b, O]) => { | ||
h[b] = O.reduce((Pe, Te) => Te(Pe, f), h[b]); | ||
}), y.propsMergeHandle && (h = y.propsMergeHandle.reduce((b, O) => O(b, f), h)), y.children && (l = y.children)); | ||
const m = ((N = this.itemConfig[d]) == null ? void 0 : N.use) || a; | ||
typeof m == "function" && !p && (f[Ct] = h, h = f), typeof m == "function" && ((D = y == null ? void 0 : y.configProps) != null && D.length) && Object.assign(h, { [X]: y.configProps }), d && (h.ref = H(h.ref).concat((b) => this.refs[d] = b)); | ||
const C = o ? Ve(m, h, ...l) : g(m, h, ...l); | ||
if (typeof m != "function") { | ||
const b = this.pathContext.hostPath.filter((O) => O instanceof L).map((O) => O.props).reverse(); | ||
C.listenerBoundArgs = [b, f]; | ||
function Y(e, t, r) { | ||
return t && (e.startsWith("on") || e === "ref" || e === "style" || e === "classname" || e === "class") ? e === "style" ? $(t).concat(r) : $(r).concat(t) : r; | ||
} | ||
const K = "__config__", L = class L { | ||
constructor({ type: t, props: r = {}, children: n }, s, i) { | ||
this.placeholder = s, this.pathContext = i, this.layoutEffects = /* @__PURE__ */ new Set(), this.effects = /* @__PURE__ */ new Set(), this.destroyCallback = /* @__PURE__ */ new Set(), this.layoutEffectDestroyHandles = /* @__PURE__ */ new Set(), this.refs = xt({}), this.itemConfig = {}, this.frame = [], this.exposed = {}, this.createHTMLOrSVGElement = (o, a, c, ...h) => { | ||
var x, T, v, R; | ||
const p = typeof a == "function", f = c == null ? void 0 : c.as; | ||
if (c == null || delete c.as, b(f !== "self", '"self" is reserved, please use another element name.'), f && ((x = this.itemConfig[f]) != null && x.use) && ((T = this.itemConfig[f]) == null ? void 0 : T.use) instanceof Element) | ||
return this.itemConfig[f].use; | ||
let m = h, { props: d, componentProps: g } = this.separateProps(c); | ||
const u = this.itemConfig[f]; | ||
f && u && (u.props && (p ? d = { ...c, ...u.props } : d = me(c, u.props)), u.propMergeHandles && Object.entries(u.propMergeHandles).forEach(([y, E]) => { | ||
d[y] = E.reduce((Ct, Pt) => Pt(Ct, g), d[y]); | ||
}), u.propsMergeHandle && (d = u.propsMergeHandle.reduce((y, E) => E(y, g), d)), u.children && (m = u.children)); | ||
const l = ((v = this.itemConfig[f]) == null ? void 0 : v.use) || a; | ||
typeof l == "function" && !p && (g[ge] = d, d = g), typeof l == "function" && ((R = u == null ? void 0 : u.configProps) != null && R.length) && Object.assign(d, { [K]: u.configProps }), f && (d.ref = $(d.ref).concat((y) => this.refs[f] = y)); | ||
const S = o ? jt(l, d, ...m) : w(l, d, ...m); | ||
if (typeof l != "function") { | ||
const y = []; | ||
let E = this.pathContext.hostPath; | ||
for (; E; ) | ||
E instanceof L && y.push(E.props), E = E.prev; | ||
S.listenerBoundArgs = [y, g]; | ||
} | ||
return C; | ||
}, this.createElement = this.createHTMLOrSVGElement.bind(this, !1), this.createSVGElement = this.createHTMLOrSVGElement.bind(this, !0), this.createPortal = (o, a) => g(pt, { container: a, content: o }), this.useLayoutEffect = (o) => { | ||
return S; | ||
}, this.createElement = this.createHTMLOrSVGElement.bind(this, !1), this.createSVGElement = this.createHTMLOrSVGElement.bind(this, !0), this.createPortal = (o, a) => w(fe, { container: a, content: o }), this.useLayoutEffect = (o) => { | ||
this.layoutEffects.add(o); | ||
}, this.useEffect = (o) => { | ||
this.effects.add(o); | ||
}, this.createRef = mt, this.createRxRef = yt, this.cleanupsOfExternalTarget = /* @__PURE__ */ new Set(), this.createStateFromRef = (o, a) => { | ||
}, this.createRef = de, this.createRxRef = pe, this.cleanupsOfExternalTarget = /* @__PURE__ */ new Set(), this.createStateFromRef = (o, a) => { | ||
let c; | ||
const u = (d) => { | ||
a && c && this.cleanupsOfExternalTarget.delete(c), c == null || c(), d !== null ? (c = o(d, p), a && c && this.cleanupsOfExternalTarget.add(c)) : (c = void 0, p(null)); | ||
}, p = new Proxy(ee(null), { | ||
get: (d, l) => l === "ref" ? u : d[l] | ||
const h = (f) => { | ||
a && c && this.cleanupsOfExternalTarget.delete(c), c == null || c(), f !== null ? (c = o(f, p), a && c && this.cleanupsOfExternalTarget.add(c)) : (c = void 0, p(null)); | ||
}, p = new Proxy(Q(null), { | ||
get: (f, m) => m === "ref" ? h : f[m] | ||
}); | ||
@@ -688,27 +587,27 @@ return a && p.ref(a), p; | ||
}); | ||
}, L.typeIds.has(e) || L.typeIds.set(e, L.typeIds.size), this.name = e.name, this.type = e, this.props = {}, this.refProp = r.ref, this.thisProp = r.__this, this.inputProps = r, this.children = n; | ||
}, L.typeIds.has(t) || L.typeIds.set(t, L.typeIds.size), this.name = t.name, this.type = t, this.props = {}, this.refProp = r.ref, this.thisProp = r.__this, this.inputProps = r, this.children = n; | ||
} | ||
parseItemConfigFromProp(e, r, n) { | ||
parseItemConfigFromProp(t, r, n) { | ||
if (r[0] === "$") { | ||
const [s, i] = r.slice(1).split(":"); | ||
if (e[s] || (e[s] = {}), i === "_eventTarget") | ||
e[s].eventTarget = H(e[s].eventTarget).concat(n); | ||
if (t[s] || (t[s] = {}), i === "_eventTarget") | ||
t[s].eventTarget = $(t[s].eventTarget).concat(n); | ||
else if (i === "_use") | ||
e[s].use = n; | ||
t[s].use = n; | ||
else if (i === "_props") | ||
e[s].propsMergeHandle = H(e[s].propsMergeHandle).concat(n); | ||
t[s].propsMergeHandle = $(t[s].propsMergeHandle).concat(n); | ||
else if (i === "_children") | ||
e[s].children = n; | ||
t[s].children = n; | ||
else if (i === void 0 || i === "") | ||
e[s].configProps = H(e[s].configProps).concat(n); | ||
t[s].configProps = $(t[s].configProps).concat(n); | ||
else if ((i == null ? void 0 : i[0]) === "_") | ||
A(!1, `unsupported config item: ${s}`); | ||
b(!1, `unsupported config item: ${s}`); | ||
else if (i.endsWith("_")) { | ||
e[s].propMergeHandles || (e[s].propMergeHandles = {}); | ||
t[s].propMergeHandles || (t[s].propMergeHandles = {}); | ||
const o = i.slice(0, -1); | ||
e[s].propMergeHandles[o] = H(e[s].propMergeHandles[o]).concat(n); | ||
t[s].propMergeHandles[o] = $(t[s].propMergeHandles[o]).concat(n); | ||
} else | ||
e[s].props || (e[s].props = {}), e[s].props[i] = U(i, e[s].props[i], n); | ||
t[s].props || (t[s].props = {}), t[s].props[i] = Y(i, t[s].props[i], n); | ||
} | ||
return e; | ||
return t; | ||
} | ||
@@ -723,14 +622,14 @@ get typeId() { | ||
get element() { | ||
var e; | ||
return ((e = this.innerHost) == null ? void 0 : e.element) || this.placeholder; | ||
var t; | ||
return ((t = this.innerHost) == null ? void 0 : t.element) || this.placeholder; | ||
} | ||
separateProps(e) { | ||
separateProps(t) { | ||
const r = {}, n = {}, s = {}; | ||
for (const i in e) | ||
i.startsWith("prop:") ? n[i.slice(5)] = e[i] : i.startsWith("$self:") ? s[i.slice(6)] = e[i] : r[i] = e[i]; | ||
for (const i in t) | ||
i.startsWith("prop:") ? n[i.slice(5)] = t[i] : i.startsWith("$self:") ? s[i.slice(6)] = t[i] : r[i] = t[i]; | ||
return this.parseAndMergeProps({ props: r, itemConfig: {}, componentProp: n }, s), { props: r, componentProps: n }; | ||
} | ||
normalizePropsByPropTypes(e, r) { | ||
normalizePropsByPropTypes(t, r) { | ||
const n = { ...r }; | ||
return Object.entries(e).forEach(([s, i]) => { | ||
return Object.entries(t).forEach(([s, i]) => { | ||
var o; | ||
@@ -740,5 +639,5 @@ r[s] !== void 0 ? n[s] = ((o = i.coerce) == null ? void 0 : o.call(i, r[s])) || r[s] : n[s] = i.defaultValue; | ||
} | ||
normalizePropsWithCoerceValue(e, r) { | ||
normalizePropsWithCoerceValue(t, r) { | ||
const n = { ...r }; | ||
return Object.entries(e).forEach(([s, i]) => { | ||
return Object.entries(t).forEach(([s, i]) => { | ||
var o; | ||
@@ -748,3 +647,3 @@ r[s] !== void 0 && (n[s] = ((o = i.coerce) == null ? void 0 : o.call(i, r[s])) || r[s]); | ||
} | ||
attachRef(e) { | ||
attachRef(t) { | ||
const r = { | ||
@@ -754,25 +653,25 @@ ...this.exposed, | ||
}; | ||
typeof e == "function" ? e(r) : e.current = r; | ||
typeof t == "function" ? t(r) : t.current = r; | ||
} | ||
attachThis(e) { | ||
typeof e == "function" ? e(this) : e.current = this; | ||
attachThis(t) { | ||
typeof t == "function" ? t(this) : t.current = this; | ||
} | ||
detachRef(e) { | ||
typeof e == "function" ? e(null) : e.current = null; | ||
detachRef(t) { | ||
typeof t == "function" ? t(null) : t.current = null; | ||
} | ||
evaluateBoundProps(e, r) { | ||
return (this.type.boundProps || []).map((n) => typeof n == "function" ? n(e, r) : n); | ||
evaluateBoundProps(t, r) { | ||
return (this.type.boundProps || []).map((n) => typeof n == "function" ? n(t, r) : n); | ||
} | ||
parseAndMergeProps(e, r) { | ||
parseAndMergeProps(t, r) { | ||
return Object.entries(r).forEach(([n, s]) => { | ||
n === X || (n[0] === "$" ? e.itemConfig = this.parseItemConfigFromProp(e.itemConfig, n, s) : e.props[n] = U(n, e.props[n], s)); | ||
}), e; | ||
n === K || (n[0] === "$" ? t.itemConfig = this.parseItemConfigFromProp(t.itemConfig, n, s) : t.props[n] = Y(n, t.props[n], s)); | ||
}), t; | ||
} | ||
getFinalPropsAndItemConfig() { | ||
const e = this.type.propTypes ? this.normalizePropsByPropTypes(this.type.propTypes, this.inputProps) : this.inputProps; | ||
return this.evaluateBoundProps(e, this.renderContext).concat(e, ...this.inputProps[X] || []).reduce((s, i) => this.parseAndMergeProps(s, i), { props: {}, itemConfig: {}, componentProp: {} }); | ||
const t = this.type.propTypes ? this.normalizePropsByPropTypes(this.type.propTypes, this.inputProps) : this.inputProps; | ||
return this.evaluateBoundProps(t, this.renderContext).concat(t, ...this.inputProps[K] || []).reduce((s, i) => this.parseAndMergeProps(s, i), { props: {}, itemConfig: {}, componentProp: {} }); | ||
} | ||
render() { | ||
this.element !== this.placeholder && A(!1, "should never rerender"), this.renderContext = { | ||
Fragment: we, | ||
this.element !== this.placeholder && b(!1, "should never rerender"), this.renderContext = { | ||
Fragment: F, | ||
createElement: this.createElement, | ||
@@ -784,3 +683,3 @@ createSVGElement: this.createSVGElement, | ||
pathContext: this.pathContext, | ||
context: new Et(this.pathContext.hostPath), | ||
context: new ye(this.pathContext.hostPath), | ||
createPortal: this.createPortal, | ||
@@ -793,3 +692,3 @@ createRef: this.createRef, | ||
}; | ||
const e = Le.collectEffect(), { props: r, itemConfig: n } = this.getFinalPropsAndItemConfig(); | ||
const t = Tt.collectEffect(), { props: r, itemConfig: n } = this.getFinalPropsAndItemConfig(); | ||
this.itemConfig = n, this.props = r; | ||
@@ -799,3 +698,3 @@ const s = this.type.propTypes ? this.normalizePropsWithCoerceValue(this.type.propTypes, r) : r; | ||
const i = this.type(s, this.renderContext); | ||
this.frame = e(), this.innerHost = R(i, this.placeholder, { ...this.pathContext, hostPath: [...this.pathContext.hostPath, this] }), this.innerHost.render(), this.refProp && this.attachRef(this.refProp), this.thisProp && this.attachThis(this.thisProp), this.effects.forEach((o) => { | ||
this.frame = t(), this.innerHost = O(i, this.placeholder, { ...this.pathContext, hostPath: M(this, this.pathContext.hostPath) }), this.innerHost.render(), this.refProp && this.attachRef(this.refProp), this.thisProp && this.attachThis(this.thisProp), this.effects.forEach((o) => { | ||
const a = o(); | ||
@@ -805,37 +704,38 @@ typeof a == "function" && this.destroyCallback.add(a); | ||
} | ||
destroy(e, r) { | ||
destroy(t, r) { | ||
var n, s; | ||
this.refProp && this.detachRef(this.refProp), r || (n = this.frame) == null || n.forEach( | ||
(i) => i.destroy() | ||
), this.innerHost.destroy(e, r), this.layoutEffectDestroyHandles.forEach((i) => i()), this.destroyCallback.forEach((i) => i()), this.cleanupsOfExternalTarget.forEach((i) => i()), this.cleanupsOfExternalTarget.clear(), e || this.placeholder.remove(), (s = this.deleteLayoutEffectCallback) == null || s.call(this); | ||
), this.innerHost.destroy(t, r), this.layoutEffectDestroyHandles.forEach((i) => i()), this.destroyCallback.forEach((i) => i()), this.cleanupsOfExternalTarget.forEach((i) => i()), this.cleanupsOfExternalTarget.clear(), t || this.placeholder.remove(), (s = this.deleteLayoutEffectCallback) == null || s.call(this); | ||
} | ||
}; | ||
L.typeIds = /* @__PURE__ */ new Map(); | ||
let V = L; | ||
class Et { | ||
constructor(e) { | ||
this.hostPath = e, this.valueByType = /* @__PURE__ */ new Map(); | ||
let I = L; | ||
class ye { | ||
constructor(t) { | ||
this.hostPath = t, this.valueByType = /* @__PURE__ */ new Map(); | ||
} | ||
get(e) { | ||
for (let r = this.hostPath.length - 1; r >= 0; r--) { | ||
const n = this.hostPath[r]; | ||
if (n instanceof V && n.renderContext.context.valueByType.has(e)) | ||
return n.renderContext.context.valueByType.get(e); | ||
get(t) { | ||
let r = this.hostPath; | ||
for (; r; ) { | ||
if (r.node instanceof I && r.node.renderContext.context.valueByType.has(t)) | ||
return r.node.renderContext.context.valueByType.get(t); | ||
r = r.prev; | ||
} | ||
} | ||
set(e, r) { | ||
this.valueByType.set(e, r); | ||
set(t, r) { | ||
this.valueByType.set(t, r); | ||
} | ||
} | ||
const Ct = "__nativeAttrs"; | ||
function zt(t, e) { | ||
const r = t.bind(null); | ||
return r.propTypes = t.propTypes, r.boundProps = H(r.boundProps).concat(e), r; | ||
const ge = "__nativeAttrs"; | ||
function _e(e, t) { | ||
const r = e.bind(null); | ||
return r.propTypes = e.propTypes, r.boundProps = $(r.boundProps).concat(t), r; | ||
} | ||
function he(t) { | ||
return t != null && t.toString ? t.toString() : t === void 0 ? "undefined" : JSON.stringify(t); | ||
function lt(e) { | ||
return e != null && e.toString ? e.toString() : e === void 0 ? "undefined" : JSON.stringify(e); | ||
} | ||
class wt { | ||
constructor(e, r, n) { | ||
this.source = e, this.placeholder = r, this.pathContext = n, this.stopAutoRun = () => { | ||
class Ee { | ||
constructor(t, r, n) { | ||
this.source = t, this.placeholder = r, this.pathContext = n, this.stopAutoRun = () => { | ||
}, this.element = this.placeholder; | ||
@@ -846,11 +746,11 @@ } | ||
} | ||
replace(e) { | ||
replace(t) { | ||
if (this.element === this.placeholder) { | ||
const r = document.createTextNode(he(e)); | ||
const r = document.createTextNode(lt(t)); | ||
this.parentElement.replaceChild(r, this.placeholder), this.element = r; | ||
} else | ||
this.element.nodeValue = he(e); | ||
this.element.nodeValue = lt(t); | ||
} | ||
render() { | ||
this.computed = pe( | ||
this.computed = pt( | ||
() => { | ||
@@ -866,9 +766,9 @@ this.replace(this.source()); | ||
} | ||
destroy(e, r) { | ||
r || G(this.computed), e || (this.element.remove(), this.placeholder.remove()); | ||
destroy(t, r) { | ||
r || mt(this.computed), t || (this.element.remove(), this.placeholder.remove()); | ||
} | ||
} | ||
class St { | ||
constructor(e, r, n) { | ||
this.source = e, this.placeholder = r, this.pathContext = n, this.fragmentParent = document.createDocumentFragment(); | ||
class Se { | ||
constructor(t, r, n) { | ||
this.source = t, this.placeholder = r, this.pathContext = n, this.fragmentParent = document.createDocumentFragment(); | ||
} | ||
@@ -879,62 +779,80 @@ get parentElement() { | ||
get element() { | ||
var e; | ||
return ((e = this.innerHost) == null ? void 0 : e.call(this).element) || this.placeholder; | ||
var t; | ||
return ((t = this.innerHost) == null ? void 0 : t.call(this).element) || this.placeholder; | ||
} | ||
render() { | ||
let e = !1; | ||
this.stopAutoRender = me(({ onCleanup: r }) => { | ||
let t = !1; | ||
this.stopAutoRender = yt(({ onCleanup: r }) => { | ||
const n = this.source(), s = document.createComment("computed node"); | ||
S(s, this.placeholder); | ||
const i = R(n, s, { ...this.pathContext, hostPath: [...this.pathContext.hostPath, this] }); | ||
oe.instance.pauseTracking(), i.render(), oe.instance.resetTracking(), r(() => { | ||
k(s, this.placeholder); | ||
const i = O(n, s, { ...this.pathContext, hostPath: M(this, this.pathContext.hostPath) }); | ||
st.instance.pauseTracking(), i.render(), st.instance.resetTracking(), r(() => { | ||
i.destroy(!1, !1); | ||
}); | ||
}, (r) => { | ||
e || (e = !0, queueMicrotask(() => { | ||
r(), e = !1; | ||
t || (t = !0, queueMicrotask(() => { | ||
r(), t = !1; | ||
})); | ||
}); | ||
} | ||
destroy(e, r) { | ||
r || this.stopAutoRender(), e || this.placeholder.remove(); | ||
destroy(t, r) { | ||
r || this.stopAutoRender(), t || this.placeholder.remove(); | ||
} | ||
} | ||
const bt = g.isValidAttribute; | ||
g.isValidAttribute = function(t, e) { | ||
return t.startsWith("on") ? !0 : Array.isArray(e) && e.some(ue) || ue(e) ? !1 : bt(t, e); | ||
const we = w.isValidAttribute; | ||
w.isValidAttribute = function(e, t) { | ||
return e.startsWith("on") ? !0 : Array.isArray(t) && t.some(ut) || ut(t) ? !1 : we(e, t); | ||
}; | ||
function ue(t) { | ||
return ye(t) || q(t) || typeof t == "function"; | ||
function ut(e) { | ||
return vt(e) || q(e) || typeof e == "function"; | ||
} | ||
function j(t) { | ||
return q(t) || typeof t == "function"; | ||
function j(e) { | ||
return q(e) || typeof e == "function"; | ||
} | ||
function be(t) { | ||
return Array.isArray(t) ? t.some(be) : Object.entries(t).some(([e, r]) => e.startsWith(":") || W(r)); | ||
function At(e) { | ||
if (Array.isArray(e)) | ||
return e.some(At); | ||
for (const t in e) | ||
if (t.startsWith(":") || G(e[t])) | ||
return !0; | ||
return !1; | ||
} | ||
function re(t) { | ||
return Array.isArray(t) ? t.some(re) : t.transition || t.transitionProperty; | ||
function et(e) { | ||
return Array.isArray(e) ? e.some(et) : e.transition || e.transitionProperty; | ||
} | ||
function J(t) { | ||
var e, r; | ||
return Array.isArray(t) ? t.flatMap(J) : ((e = t.transitionProperty) == null ? void 0 : e.split(",").map((n) => n.trim())) ?? ((r = t.transition) == null ? void 0 : r.split(",").map((n) => n.split(/\s+/)[0])) ?? []; | ||
function U(e) { | ||
var t, r; | ||
return Array.isArray(e) ? e.flatMap(U) : ((t = e.transitionProperty) == null ? void 0 : t.split(",").map((n) => n.trim())) ?? ((r = e.transition) == null ? void 0 : r.split(",").map((n) => n.split(/\s+/)[0])) ?? []; | ||
} | ||
function Ae(t) { | ||
return Array.isArray(t) ? t.some(Ae) : t["@keyframes"] !== void 0; | ||
function bt(e) { | ||
return Array.isArray(e) ? e.some(bt) : e["@keyframes"] !== void 0; | ||
} | ||
function fe(t) { | ||
t.offsetHeight; | ||
function ft(e) { | ||
e.offsetHeight; | ||
} | ||
function At(t, e) { | ||
return `${t.map((r) => r.pathContext.elementPath.join("_")).join("-")}-${e.join("_")}`; | ||
function Ae(e, t) { | ||
const r = []; | ||
let n = e; | ||
for (; n; ) | ||
r.unshift(n.node), n = n.prev; | ||
return `${r.map((s) => s.pathContext.elementPath.join("_")).join("-")}-${t.join("_")}`; | ||
} | ||
function Pt(t, e) { | ||
const r = t.findLastIndex((i) => i instanceof V), n = r === -1 ? void 0 : t[r], s = r === -1 ? t : t.slice(r + 1); | ||
return `gen-${(n == null ? void 0 : n.typeId) ?? "global"}-${s.map((i) => i.pathContext.elementPath.join("_")).join("-")}-${e.join("_")}`; | ||
function be(e, t) { | ||
let r; | ||
const n = []; | ||
let s = e; | ||
for (; s; ) { | ||
if (s.node instanceof I) { | ||
r = s.node; | ||
break; | ||
} | ||
n.unshift(s.node), s = s.prev; | ||
} | ||
return `gen-${(r == null ? void 0 : r.typeId) ?? "global"}-${n.map((i) => i.pathContext.elementPath.join("_")).join("-")}-${t.join("_")}`; | ||
} | ||
class Tt { | ||
class Ce { | ||
constructor() { | ||
this.styleScripts = /* @__PURE__ */ new Map(), this.elToStyleId = /* @__PURE__ */ new WeakMap(); | ||
} | ||
getStyleSheetId(e, r, n) { | ||
getStyleSheetId(t, r, n) { | ||
if (n) { | ||
@@ -949,10 +867,10 @@ const s = this.elToStyleId.get(n); | ||
} | ||
return Pt(e, r); | ||
return be(t, r); | ||
} | ||
stringifyStyleObject(e) { | ||
return Object.entries(e).map(([r, n]) => `${r.replace(/([A-Z])/g, "-$1").toLowerCase()}:${te(r, n)};`).join(` | ||
stringifyStyleObject(t) { | ||
return Object.entries(t).map(([r, n]) => `${r.replace(/([A-Z])/g, "-$1").toLowerCase()}:${tt(r, n)};`).join(` | ||
`); | ||
} | ||
update(e, r, n, s, i = !1) { | ||
const o = this.getStyleSheetId(e, r, i ? null : s); | ||
update(t, r, n, s, i = !1) { | ||
const o = this.getStyleSheetId(t, r, i ? null : s); | ||
let a = this.styleScripts.get(o); | ||
@@ -963,27 +881,27 @@ a || (a = new CSSStyleSheet(), document.adoptedStyleSheets = [...document.adoptedStyleSheets, a], this.styleScripts.set(o, a)), s.classList.add(o); | ||
`)); | ||
const u = J(c[0]); | ||
return u.length && fe(s), Re(c.slice(1).map((p) => () => { | ||
const [d, l, h] = this.separateStyleObject(p, u); | ||
if (l && this.generateStyleContent(`.${o}`, l).forEach((f) => { | ||
a.insertRule(f, a.cssRules.length); | ||
}), d) { | ||
const f = J(d); | ||
u.push(...f), this.generateStyleContent(`.${o}`, d).forEach((y) => { | ||
a.insertRule(y, a.cssRules.length); | ||
const h = U(c[0]); | ||
return h.length && ft(s), Lt(c.slice(1).map((p) => () => { | ||
const [f, m, d] = this.separateStyleObject(p, h); | ||
if (m && this.generateStyleContent(`.${o}`, m).forEach((g) => { | ||
a.insertRule(g, a.cssRules.length); | ||
}), f) { | ||
const g = U(f); | ||
h.push(...g), this.generateStyleContent(`.${o}`, f).forEach((u) => { | ||
a.insertRule(u, a.cssRules.length); | ||
}); | ||
} | ||
h && k(s, "style", h), re(p) && fe(s); | ||
d && V(s, "style", d), et(p) && ft(s); | ||
})); | ||
} | ||
isNestedStyleObject(e, r) { | ||
return e !== "@keyframes" && W(r); | ||
isNestedStyleObject(t, r) { | ||
return t !== "@keyframes" && G(r); | ||
} | ||
separateStyleObject(e, r) { | ||
separateStyleObject(t, r) { | ||
let n, s, i; | ||
for (const o in e) | ||
this.isNestedStyleObject(o, e[o]) || o === "animation" && e.keyframes ? (s || (s = {}), s[o] = e[o]) : r.includes(o) ? (i || (i = {}), i[o] = e[o]) : (n || (n = {}), n[o] = e[o]); | ||
for (const o in t) | ||
this.isNestedStyleObject(o, t[o]) || o === "animation" && t.keyframes ? (s || (s = {}), s[o] = t[o]) : r.includes(o) ? (i || (i = {}), i[o] = t[o]) : (n || (n = {}), n[o] = t[o]); | ||
return [n, s, i]; | ||
} | ||
stringifyKeyFrameObject(e) { | ||
return Object.entries(e).map(([r, n]) => `${r} { | ||
stringifyKeyFrameObject(t) { | ||
return Object.entries(t).map(([r, n]) => `${r} { | ||
${this.stringifyStyleObject(n)} | ||
@@ -993,3 +911,3 @@ }`).join(` | ||
} | ||
generateInlineAnimationContent(e, r) { | ||
generateInlineAnimationContent(t, r) { | ||
const n = []; | ||
@@ -1006,3 +924,3 @@ let s = ""; | ||
n.push(` | ||
${e} { | ||
${t} { | ||
animation: ${i}; | ||
@@ -1014,168 +932,152 @@ } | ||
} | ||
generateStyleContent(e, r) { | ||
generateStyleContent(t, r) { | ||
const n = { ...r }, s = [], i = {}; | ||
for (const c in n) | ||
c === "@keyframes" || c === "animation" ? (i[c] = n[c], delete n[c]) : this.isNestedStyleObject(c, n[c]) && (s.push([c, n[c]]), delete n[c]); | ||
const o = [`${e} { | ||
const o = [`${t} { | ||
${this.stringifyStyleObject(n)} | ||
}`], a = this.generateInlineAnimationContent(e, i); | ||
return o.push(...a), s.reduce((c, [u, p]) => { | ||
if (u.startsWith("@")) | ||
return c.concat(`${u} { | ||
${this.generateStyleContent(e, p)} | ||
}`], a = this.generateInlineAnimationContent(t, i); | ||
return o.push(...a), s.reduce((c, [h, p]) => { | ||
if (h.startsWith("@")) | ||
return c.concat(`${h} { | ||
${this.generateStyleContent(t, p)} | ||
}`); | ||
const d = /^(\s?)+&/.test(u) ? u.replace("&", e) : `${e} ${u}`; | ||
return c.concat(this.generateStyleContent(d, p)); | ||
const f = /^(\s?)+&/.test(h) ? h.replace("&", t) : `${t} ${h}`; | ||
return c.concat(this.generateStyleContent(f, p)); | ||
}, o); | ||
} | ||
} | ||
const xt = { | ||
const Pe = { | ||
autoGenerateTestId: !1 | ||
}, B = class B { | ||
constructor(e, r, n) { | ||
this.source = e, this.placeholder = r, this.pathContext = n, this.forceHandleElement = !1, this.computed = void 0, this.element = this.placeholder, this.attachRefs = () => { | ||
constructor(t, r, n) { | ||
this.source = t, this.placeholder = r, this.pathContext = n, this.forceHandleElement = !1, this.computed = void 0, this.element = this.placeholder, this.attachRefs = () => { | ||
var s; | ||
(s = this.refHandles) == null || s.forEach(({ handle: i, el: o }) => { | ||
g.attachRef(o, i); | ||
w.attachRef(o, i); | ||
}); | ||
}; | ||
}, this.parentElement = r.parentElement; | ||
} | ||
get parentElement() { | ||
return this.placeholder.parentElement; | ||
} | ||
render() { | ||
var e; | ||
A(this.element === this.placeholder, "should never rerender"), this.element = this.source instanceof DocumentFragment ? document.createComment("fragment start") : this.source, S(this.element, this.placeholder), this.source instanceof DocumentFragment && S(this.source, this.placeholder), this.collectInnerHost(), this.collectReactiveAttr(), this.collectRefHandles(), this.collectDetachStyledChildren(), (e = this.detachStyledChildren) != null && e.length && (this.forceHandleElement = !0), this.reactiveHosts.forEach((r) => r.render()), this.pathContext.root.attached ? this.attachRefs() : this.pathContext.root.on("attach", this.attachRefs); | ||
var t, r, n; | ||
b(this.element === this.placeholder, "should never rerender"), this.element = this.source instanceof DocumentFragment ? document.createComment("fragment start") : this.source, this.collectInnerHost(), this.collectReactiveAttr(), this.collectRefHandles(), this.collectDetachStyledChildren(), (t = this.detachStyledChildren) != null && t.length && (this.forceHandleElement = !0), (r = this.reactiveHosts) == null || r.forEach((s) => s.render()), k(this.element, this.placeholder), this.source instanceof DocumentFragment && k(this.source, this.placeholder), (n = this.refHandles) != null && n.length && (this.pathContext.root.attached ? this.attachRefs() : this.removeAttachListener = this.pathContext.root.on("attach", this.attachRefs)); | ||
} | ||
collectInnerHost() { | ||
const e = this.source; | ||
if (!(e instanceof HTMLElement || e instanceof DocumentFragment || e instanceof SVGElement)) return; | ||
const { unhandledChildren: r } = e; | ||
this.reactiveHosts = r ? r.map( | ||
({ placeholder: n, child: s, path: i }) => R(s, n, { | ||
const t = this.source, { unhandledChildren: r } = t; | ||
r && (this.reactiveHosts = r.map( | ||
({ placeholder: n, child: s, path: i }) => O(s, n, { | ||
...this.pathContext, | ||
hostPath: [...this.pathContext.hostPath, this], | ||
hostPath: M(this, this.pathContext.hostPath), | ||
elementPath: i | ||
}) | ||
) : [], delete e.unhandledChildren; | ||
), t.unhandledChildren = void 0); | ||
} | ||
collectReactiveAttr() { | ||
const e = this.source; | ||
if (!(e instanceof HTMLElement || e instanceof DocumentFragment || e instanceof SVGElement)) return; | ||
const r = e instanceof SVGElement, { unhandledAttr: n } = e; | ||
this.attrAutoruns = [], n == null || n.forEach(({ el: s, key: i, value: o, path: a }) => { | ||
s.hasAttribute("data-testid") || this.generateTestId(s, a), i.includes(":") || this.attrAutoruns.push(me(() => { | ||
const t = this.source, r = t instanceof SVGElement, { unhandledAttr: n } = t; | ||
n && (this.attrAutoruns = [], n.forEach(({ el: s, key: i, value: o, path: a }) => { | ||
s.hasAttribute("data-testid") || this.generateTestId(s, a), i.includes(":") || this.attrAutoruns.push(yt(() => { | ||
this.updateAttribute(s, i, o, a, r); | ||
}, !0)); | ||
}); | ||
}), t.unhandledAttr = void 0); | ||
} | ||
updateAttribute(e, r, n, s, i) { | ||
updateAttribute(t, r, n, s, i) { | ||
const o = Array.isArray(n) ? n.map((a) => j(a) ? a() : a) : j(n) ? n() : n; | ||
if (r === "style" && (be(o) || re(o) || Ae(o))) | ||
return B.styleManager.update(this.pathContext.hostPath, s, o, e, !1); | ||
k(e, r, o, i); | ||
if (r === "style" && (At(o) || et(o) || bt(o))) | ||
return B.styleManager.update(this.pathContext.hostPath, s, o, t, !1); | ||
V(t, r, o, i); | ||
} | ||
collectRefHandles() { | ||
const e = this.source; | ||
if (!(e instanceof HTMLElement || e instanceof DocumentFragment || e instanceof SVGElement)) return; | ||
const { refHandles: r } = e; | ||
this.refHandles = r; | ||
this.refHandles = this.source.refHandles; | ||
} | ||
collectDetachStyledChildren() { | ||
const e = this.source; | ||
if (!(e instanceof HTMLElement || e instanceof DocumentFragment || e instanceof SVGElement)) return; | ||
const { detachStyledChildren: r } = e; | ||
this.detachStyledChildren = r; | ||
this.detachStyledChildren = this.source.detachStyledChildren; | ||
} | ||
generateTestId(e, r) { | ||
if (!xt.autoGenerateTestId) return; | ||
const n = At(this.pathContext.hostPath, r); | ||
k(e, "data-testid", n); | ||
generateTestId(t, r) { | ||
if (!Pe.autoGenerateTestId) return; | ||
const n = Ae(this.pathContext.hostPath, r); | ||
V(t, "data-testid", n); | ||
} | ||
destroy(e, r) { | ||
var n, s, i; | ||
r || (n = this.attrAutoruns) == null || n.forEach((o) => o()), (s = this.reactiveHosts) == null || s.forEach((o) => o.destroy(!0, r)), (i = this.refHandles) == null || i.forEach(({ handle: o }) => { | ||
g.detachRef(o); | ||
}), this.removeElements(e); | ||
destroy(t, r) { | ||
var n, s, i, o; | ||
r || (n = this.attrAutoruns) == null || n.forEach((a) => a()), (s = this.removeAttachListener) == null || s.call(this), (i = this.reactiveHosts) == null || i.forEach((a) => a.destroy(!0, r)), (o = this.refHandles) == null || o.forEach(({ handle: a }) => { | ||
w.detachRef(a); | ||
}), this.removeElements(t); | ||
} | ||
async removeElements(e) { | ||
async removeElements(t) { | ||
var r, n, s; | ||
if (!e) { | ||
if (!t) { | ||
if ((r = this.detachStyledChildren) != null && r.length) { | ||
const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(); | ||
(n = this.detachStyledChildren) == null || n.forEach(({ el: u, style: p }) => { | ||
const d = getComputedStyle(u).transitionProperty.split(",").map((y) => y.trim()), l = Array.isArray(p) ? Object.assign({}, ...p.map((y) => j(y) ? y() : y)) : j(p) ? p() : p, h = Object.keys(l); | ||
(d.includes("all") || h.some((y) => d.includes(y))) && i.add(u), l.animation && o.add(u); | ||
}), await Promise.all(((s = this.detachStyledChildren) == null ? void 0 : s.map(({ el: u, style: p, path: d }) => this.updateAttribute(u, "style", p, d, u instanceof SVGElement))) || []); | ||
(n = this.detachStyledChildren) == null || n.forEach(({ el: h, style: p }) => { | ||
const f = getComputedStyle(h).transitionProperty.split(",").map((u) => u.trim()), m = Array.isArray(p) ? Object.assign({}, ...p.map((u) => j(u) ? u() : u)) : j(p) ? p() : p, d = Object.keys(m); | ||
(f.includes("all") || d.some((u) => f.includes(u))) && i.add(h), m.animation && o.add(h); | ||
}), await Promise.all(((s = this.detachStyledChildren) == null ? void 0 : s.map(({ el: h, style: p, path: f }) => this.updateAttribute(h, "style", p, f, h instanceof SVGElement))) || []); | ||
const a = Array.from(i), c = Array.from(o); | ||
await Promise.all([ | ||
...a.map((u) => F(u, "transitionrun")), | ||
...a.map((u) => F(u, "transitionend")), | ||
...c.map((u) => F(u, "animationrun")), | ||
...c.map((u) => F(u, "animationend")) | ||
...a.map((h) => D(h, "transitionrun")), | ||
...a.map((h) => D(h, "transitionend")), | ||
...c.map((h) => D(h, "animationrun")), | ||
...c.map((h) => D(h, "animationend")) | ||
]); | ||
} | ||
ge(this.element, this.placeholder, !0); | ||
gt(this.element, this.placeholder, !0); | ||
} | ||
} | ||
}; | ||
B.styleManager = new Tt(); | ||
let Z = B; | ||
function F(t, e) { | ||
B.styleManager = new Ce(); | ||
let J = B; | ||
function D(e, t) { | ||
return new Promise((r) => { | ||
t.addEventListener(e, r, { once: !0 }); | ||
e.addEventListener(t, r, { once: !0 }); | ||
}); | ||
} | ||
class Lt { | ||
constructor(e, r, n) { | ||
this.source = e, this.placeholder = r, this.pathContext = n, this.computed = void 0, this.childHosts = []; | ||
class xe { | ||
constructor(t, r, n) { | ||
this.source = t, this.placeholder = r, this.pathContext = n, this.computed = void 0, this.childHosts = [], this.parentElement = r.parentElement; | ||
} | ||
get parentElement() { | ||
return this.placeholder.parentElement; | ||
} | ||
get element() { | ||
var e; | ||
return ((e = this.firstChild) == null ? void 0 : e.element) || this.firstChild || this.placeholder; | ||
var t; | ||
return ((t = this.firstChild) == null ? void 0 : t.element) || this.firstChild || this.placeholder; | ||
} | ||
render() { | ||
if (this.element === this.placeholder) { | ||
const e = document.createDocumentFragment(); | ||
const t = document.createDocumentFragment(); | ||
this.source.forEach((r, n) => { | ||
if (typeof r == "string" || typeof r == "number") { | ||
const s = document.createTextNode(r.toString()); | ||
e.appendChild(s), n === 0 && (this.firstChild = s); | ||
t.appendChild(s), n === 0 && (this.firstChild = s); | ||
} else if (r instanceof Text) | ||
e.appendChild(r), n === 0 && (this.firstChild = r); | ||
t.appendChild(r), n === 0 && (this.firstChild = r); | ||
else { | ||
const s = document.createComment("array item"); | ||
e.appendChild(s); | ||
const i = R(r, s, { ...this.pathContext, hostPath: [...this.pathContext.hostPath, this] }); | ||
t.appendChild(s); | ||
const i = O(r, s, { ...this.pathContext, hostPath: M(this, this.pathContext.hostPath) }); | ||
this.childHosts.push(i), n === 0 && (this.firstChild = i); | ||
} | ||
}), this.childHosts.forEach((r) => r.render()), S(e, this.placeholder); | ||
}), this.childHosts.forEach((r) => r.render()), k(t, this.placeholder); | ||
} else | ||
throw new Error("should never rerender"); | ||
} | ||
destroy(e, r) { | ||
e || (ge(this.element, this.placeholder, !0), this.childHosts.forEach((n) => n.destroy(!0, r))); | ||
destroy(t, r) { | ||
t || (gt(this.element, this.placeholder, !0), this.childHosts.forEach((n) => n.destroy(!0, r))); | ||
} | ||
} | ||
class Ht { | ||
constructor(e, r, n) { | ||
this.source = e, this.placeholder = r, this.pathContext = n; | ||
class Te { | ||
constructor(t, r, n) { | ||
this.source = t, this.placeholder = r, this.pathContext = n; | ||
} | ||
createPlaceholder(e) { | ||
return [e, document.createComment("frag item host")]; | ||
createPlaceholder(t) { | ||
return [t, document.createComment("frag item host")]; | ||
} | ||
isOnlyChildrenOfParent() { | ||
const e = this.placeholder.parentElement; | ||
return (e == null ? void 0 : e.lastChild) === this.placeholder && e.firstChild === this.element; | ||
const t = this.placeholder.parentElement; | ||
return (t == null ? void 0 : t.lastChild) === this.placeholder && t.firstChild === this.element; | ||
} | ||
get element() { | ||
var e, r; | ||
return ((r = (e = this.hosts) == null ? void 0 : e.at(0)) == null ? void 0 : r.element) || this.placeholder; | ||
var t, r; | ||
return ((r = (t = this.hosts) == null ? void 0 : t.at(0)) == null ? void 0 : r.element) || this.placeholder; | ||
} | ||
renderNewHosts(e) { | ||
renderNewHosts(t) { | ||
const r = document.createDocumentFragment(); | ||
return e.forEach((n) => { | ||
return t.forEach((n) => { | ||
r.appendChild(n.placeholder), n.render(); | ||
@@ -1185,22 +1087,22 @@ }), r; | ||
render() { | ||
const e = this; | ||
this.hosts = this.source.map((r) => R(r, document.createComment("rx list item"), { ...this.pathContext, hostPath: [...this.pathContext.hostPath, this] })), this.hostRenderComputed = pe( | ||
const t = this; | ||
this.hosts = this.source.map((r) => O(r, document.createComment("rx list item"), { ...this.pathContext, hostPath: M(this, this.pathContext.hostPath) })), this.hostRenderComputed = pt( | ||
function() { | ||
return this.manualTrack(e.hosts, I.METHOD, $.METHOD), this.manualTrack(e.hosts, I.EXPLICIT_KEY_CHANGE, $.EXPLICIT_KEY_CHANGE), S(e.renderNewHosts(e.hosts), e.placeholder), null; | ||
return this.manualTrack(t.hosts, it.METHOD, ot.METHOD), this.manualTrack(t.hosts, it.EXPLICIT_KEY_CHANGE, ot.EXPLICIT_KEY_CHANGE), k(t.renderNewHosts(t.hosts), t.placeholder), null; | ||
}, | ||
function(n, s) { | ||
s.forEach(({ method: i, argv: o, result: a, key: c, newValue: u, methodResult: p }, d) => { | ||
var l; | ||
s.forEach(({ method: i, argv: o, result: a, key: c, newValue: h, methodResult: p }, f) => { | ||
var m; | ||
if (i === "splice") { | ||
const h = e.hosts.data.slice(o[0] + o.slice(2).length).find((m) => m.element.parentNode), f = o.slice(2); | ||
if (f.length) { | ||
const m = e.renderNewHosts(f); | ||
S(m, (h == null ? void 0 : h.element) || e.placeholder); | ||
const d = t.hosts.data.slice(o[0] + o.slice(2).length).find((l) => l.element.parentNode), g = o.slice(2); | ||
if (g.length) { | ||
const l = t.renderNewHosts(g); | ||
k(l, (d == null ? void 0 : d.element) || t.placeholder); | ||
} | ||
p.forEach((m) => m.destroy()); | ||
p.forEach((l) => l.destroy()); | ||
} else if (i === void 0 && c !== void 0) { | ||
const h = p; | ||
h == null || h.destroy(); | ||
const f = c; | ||
S(e.hosts.at(f).placeholder, ((l = e.hosts.at(f + 1)) == null ? void 0 : l.element) || e.placeholder), e.hosts.at(f).render(); | ||
const d = p; | ||
d == null || d.destroy(); | ||
const g = c; | ||
k(t.hosts.at(g).placeholder, ((m = t.hosts.at(g + 1)) == null ? void 0 : m.element) || t.placeholder), t.hosts.at(g).render(); | ||
} else | ||
@@ -1213,41 +1115,41 @@ throw new Error("unknown trigger info"); | ||
} | ||
destroy(e, r) { | ||
destroy(t, r) { | ||
var n; | ||
r || ((n = this.hosts) == null || n.destroy(), G(this.hostRenderComputed)), this.hosts.forEach((s) => s.destroy(e)), e || this.placeholder.remove(); | ||
r || ((n = this.hosts) == null || n.destroy(), mt(this.hostRenderComputed)), this.hosts.forEach((s) => s.destroy(t)), t || this.placeholder.remove(); | ||
} | ||
} | ||
class Rt { | ||
constructor(e, r) { | ||
this.pathContext = e, this.placeholder = r, this.element = document.createComment("empty"); | ||
class ve { | ||
constructor(t, r) { | ||
this.pathContext = t, this.placeholder = r, this.element = document.createComment("empty"); | ||
} | ||
render() { | ||
var e; | ||
(e = this.placeholder.parentNode) == null || e.insertBefore(this.element, this.placeholder); | ||
var t; | ||
(t = this.placeholder.parentNode) == null || t.insertBefore(this.element, this.placeholder); | ||
} | ||
destroy(e) { | ||
e || (this.element.remove(), this.placeholder.remove()); | ||
destroy(t) { | ||
t || (this.element.remove(), this.placeholder.remove()); | ||
} | ||
} | ||
class Ot { | ||
constructor(e, r, n) { | ||
this.source = e, this.placeholder = r, this.pathContext = n, this.element = this.placeholder; | ||
class Re { | ||
constructor(t, r, n) { | ||
this.source = t, this.placeholder = r, this.pathContext = n, this.element = this.placeholder; | ||
} | ||
render() { | ||
this.element = document.createTextNode(this.source.toString()), S(this.element, this.placeholder); | ||
this.element = document.createTextNode(this.source.toString()), k(this.element, this.placeholder); | ||
} | ||
destroy(e) { | ||
e || this.placeholder.remove(), this.element.remove(); | ||
destroy(t) { | ||
t || this.placeholder.remove(), this.element.remove(); | ||
} | ||
} | ||
function R(t, e, r) { | ||
if (!(e instanceof Comment)) throw new Error("incorrect placeholder type"); | ||
function O(e, t, r) { | ||
if (!(t instanceof Comment)) throw new Error("incorrect placeholder type"); | ||
let n; | ||
return t instanceof _ ? n = new Ht(t, e, r) : Array.isArray(t) ? ye(t) ? n = new dt(t, e, r) : n = new Lt(t, e, r) : typeof t == "object" && typeof (t == null ? void 0 : t.type) == "function" ? n = new V(t, e, r) : q(t) ? n = new wt(t, e, r) : typeof t == "function" ? n = new St(t, e, r) : t instanceof HTMLElement || t instanceof SVGElement || t instanceof DocumentFragment ? n = new Z(t, e, r) : t == null ? n = new Rt(r, e) : typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? n = new Ot(t, e, r) : A(!1, `unknown child type ${t}`), n; | ||
return e instanceof HTMLElement || e instanceof SVGElement || e instanceof DocumentFragment ? n = new J(e, t, r) : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? n = new Re(e, t, r) : Array.isArray(e) ? n = new xe(e, t, r) : e == null ? n = new ve(r, t) : e instanceof _ ? n = new Te(e, t, r) : typeof e == "object" && typeof (e == null ? void 0 : e.type) == "function" ? n = new I(e, t, r) : q(e) ? n = new Ee(e, t, r) : typeof e == "function" ? n = new Se(e, t, r) : b(!1, `unknown child type ${e}`), n; | ||
} | ||
function vt(t, e) { | ||
const r = /* @__PURE__ */ new Map(), n = e || { | ||
function Le(e, t) { | ||
const r = /* @__PURE__ */ new Map(), n = t || { | ||
hostPath: [], | ||
elementPath: [] | ||
}, s = { | ||
element: t, | ||
element: e, | ||
pathContext: n, | ||
@@ -1257,4 +1159,4 @@ host: void 0, | ||
render(i) { | ||
const o = document.createComment("root"); | ||
return t.appendChild(o), s.host = R(i, o, n), s.host.render(), document.body.contains(t) && (s.dispatch("attach"), s.attached = !0), s.host; | ||
const o = document.createComment("root"), a = document.createDocumentFragment(); | ||
return a.appendChild(o), s.host = O(i, o, n), s.host.render(), e.appendChild(a), e.isConnected && (s.dispatch("attach"), s.attached = !0), s.host; | ||
}, | ||
@@ -1279,19 +1181,19 @@ destroy() { | ||
} | ||
function w(t) { | ||
return (e) => (r) => { | ||
if (t(r)) | ||
return e(r); | ||
function A(e) { | ||
return (t) => (r) => { | ||
if (e(r)) | ||
return t(r); | ||
}; | ||
} | ||
const Bt = w((t) => t.key === "ArrowUp"), qt = w((t) => t.key === "ArrowDown"), Wt = w((t) => t.key === "ArrowLeft"), Kt = w((t) => t.key === "ArrowRight"), Xt = w((t) => t.key === "Enter"), Yt = w((t) => t.key === "Tab"), Ut = w((t) => t.key === "Escape"), Jt = w((t) => t.key === "Backspace"), Zt = w((t) => t.key === "Space"), Qt = w((t) => t.button === 0), er = w((t) => t.button === 2), tr = w((t) => t.button === 1), rr = (t, e) => w((r) => e != null && e.meta && !r.metaKey || e != null && e.ctrl && !r.ctrlKey || e != null && e.alt && !r.altKey || e != null && e.shift && !r.shiftKey ? !1 : r.key === t), nr = w((t) => t.target === t.currentTarget); | ||
function sr(t) { | ||
let e; | ||
const ze = A((e) => e.key === "ArrowUp"), Be = A((e) => e.key === "ArrowDown"), qe = A((e) => e.key === "ArrowLeft"), Ge = A((e) => e.key === "ArrowRight"), We = A((e) => e.key === "Enter"), Ke = A((e) => e.key === "Tab"), Xe = A((e) => e.key === "Escape"), Ye = A((e) => e.key === "Backspace"), Ue = A((e) => e.key === "Space"), Je = A((e) => e.button === 0), Ze = A((e) => e.button === 2), Qe = A((e) => e.button === 1), tr = (e, t) => A((r) => t != null && t.meta && !r.metaKey || t != null && t.ctrl && !r.ctrlKey || t != null && t.alt && !r.altKey || t != null && t.shift && !r.shiftKey ? !1 : r.key === e), er = A((e) => e.target === e.currentTarget); | ||
function rr(e) { | ||
let t; | ||
function r(s) { | ||
if (e !== void 0) | ||
if (t !== void 0) | ||
throw new Error("event transfer can only have one target"); | ||
e = s; | ||
t = s; | ||
} | ||
function n(s) { | ||
if (e) { | ||
let i = t ? t(s) : s; | ||
if (t) { | ||
let i = e ? e(s) : s; | ||
if (i === s) { | ||
@@ -1301,3 +1203,3 @@ const o = s.constructor; | ||
} | ||
i && e.dispatchEvent(i); | ||
i && t.dispatchEvent(i); | ||
} else | ||
@@ -1311,75 +1213,75 @@ console.warn("target is not ready"); | ||
} | ||
function ir(t) { | ||
return (e) => { | ||
function nr(e) { | ||
return (t) => { | ||
var n; | ||
const r = document.getSelection() && document.getSelection().rangeCount > 0 ? (n = document.getSelection()) == null ? void 0 : n.getRangeAt(0) : void 0; | ||
t(e, r); | ||
e(t, r); | ||
}; | ||
} | ||
function or(t) { | ||
return (e) => { | ||
e.preventDefault(), t(e); | ||
function sr(e) { | ||
return (t) => { | ||
t.preventDefault(), e(t); | ||
}; | ||
} | ||
function ar(t) { | ||
return (e) => { | ||
e.stopPropagation(), t(e); | ||
function ir(e) { | ||
return (t) => { | ||
t.stopPropagation(), e(t); | ||
}; | ||
} | ||
function cr({ contextType: t, value: e, children: r }, { context: n }) { | ||
return n.set(t, e), r; | ||
function or({ contextType: e, value: t, children: r }, { context: n }) { | ||
return n.set(e, t), r; | ||
} | ||
function It(t) { | ||
const e = { | ||
name: t, | ||
function $e(e) { | ||
const t = { | ||
name: e, | ||
Provider({ value: r, children: n }, { context: s }) { | ||
return s.set(e, r), n; | ||
return s.set(t, r), n; | ||
}, | ||
valueType: null | ||
}; | ||
return e; | ||
return t; | ||
} | ||
const $t = It("Form"); | ||
function Nt({ name: t, children: e, onChange: r, onSubmit: n, onClear: s, onReset: i, values: o }, { | ||
const ke = $e("Form"); | ||
function He({ name: e, children: t, onChange: r, onSubmit: n, onClear: s, onReset: i, values: o }, { | ||
createElement: a, | ||
context: c | ||
}) { | ||
const u = {}, p = (m, C, x) => { | ||
x ? (o.get(m) || o.set(m, new _([])), u[m] || (u[m] = []), o.get(m).push(C.value)(u[m]).push(C)) : (o.set(m, C.value), u[m] = C); | ||
}, d = (m, C, x) => { | ||
const h = {}, p = (l, S, x) => { | ||
x ? (o.get(l) || o.set(l, new _([])), h[l] || (h[l] = []), o.get(l).push(S.value)(h[l]).push(S)) : (o.set(l, S.value), h[l] = S); | ||
}, f = (l, S, x) => { | ||
if (x) { | ||
const E = o.get(m), N = E.findIndex((b) => b === C.value); | ||
N() > -1 && E.splice(N(), 1); | ||
const D = u[m].findIndex((b) => b === C); | ||
D > -1 && u[m].splice(D, 1); | ||
const T = o.get(l), v = T.findIndex((y) => y === S.value); | ||
v() > -1 && T.splice(v(), 1); | ||
const R = h[l].findIndex((y) => y === S); | ||
R > -1 && h[l].splice(R, 1); | ||
} else | ||
o.delete(m), delete u[m]; | ||
}, l = () => { | ||
o.delete(l), delete h[l]; | ||
}, m = () => { | ||
n == null || n(o); | ||
}, h = () => { | ||
Object.values(u).forEach((m) => { | ||
Array.isArray(m) ? m.forEach((C) => C.reset()) : m.reset(); | ||
}, d = () => { | ||
Object.values(h).forEach((l) => { | ||
Array.isArray(l) ? l.forEach((S) => S.reset()) : l.reset(); | ||
}), i == null || i(); | ||
}, f = () => { | ||
Object.values(u).forEach((m) => { | ||
Array.isArray(m) ? m.forEach((C) => C.clear()) : m.clear(); | ||
}, g = () => { | ||
Object.values(h).forEach((l) => { | ||
Array.isArray(l) ? l.forEach((S) => S.clear()) : l.clear(); | ||
}), s == null || s(); | ||
}, y = () => { | ||
}, u = () => { | ||
r == null || r(o); | ||
}; | ||
return c.set($t, { name: t, register: p, unregister: d, onChange: y, submit: l, reset: h, clear: f }), e; | ||
return c.set(ke, { name: e, register: p, unregister: f, onChange: u, submit: m, reset: d, clear: g }), t; | ||
} | ||
Nt.propTypes = { | ||
name: v.string.isRequired, | ||
values: v.rxMap(), | ||
children: v.any.isRequired, | ||
onChange: v.function, | ||
onSubmit: v.function, | ||
onClear: v.function, | ||
onReset: v.function | ||
He.propTypes = { | ||
name: H.string.isRequired, | ||
values: H.rxMap(), | ||
children: H.any.isRequired, | ||
onChange: H.function, | ||
onSubmit: H.function, | ||
onClear: H.function, | ||
onReset: H.function | ||
}; | ||
const lr = Symbol("ModalContext"); | ||
function hr(t) { | ||
return (e, r) => { | ||
if (e === window) { | ||
const ar = Symbol("ModalContext"); | ||
function cr(e) { | ||
return (t, r) => { | ||
if (t === window) { | ||
(() => { | ||
@@ -1396,3 +1298,3 @@ const o = { | ||
} | ||
const n = e, s = () => { | ||
const n = t, s = () => { | ||
const i = n.getBoundingClientRect(), o = { | ||
@@ -1406,5 +1308,5 @@ top: i.top, | ||
}; | ||
if (Array.isArray(t)) { | ||
if (Array.isArray(e)) { | ||
const i = []; | ||
return t.forEach((o) => { | ||
return e.forEach((o) => { | ||
const a = () => s(); | ||
@@ -1415,3 +1317,3 @@ o.target.addEventListener(o.event, a), i.push(() => o.target.removeEventListener(o.event, a)); | ||
}; | ||
} else if (t === "requestAnimationFrame") { | ||
} else if (e === "requestAnimationFrame") { | ||
const i = window.requestAnimationFrame(s); | ||
@@ -1421,3 +1323,3 @@ return () => { | ||
}; | ||
} else if (t === "requestIdleCallback") { | ||
} else if (e === "requestIdleCallback") { | ||
const i = window.requestIdleCallback(s); | ||
@@ -1427,4 +1329,4 @@ return () => { | ||
}; | ||
} else if (t.type === "interval") { | ||
const i = window.setInterval(s, t.duration || 1e3); | ||
} else if (e.type === "interval") { | ||
const i = window.setInterval(s, e.duration || 1e3); | ||
return () => { | ||
@@ -1434,16 +1336,16 @@ window.clearInterval(i); | ||
} else | ||
A(!1, "invalid options.position"); | ||
b(!1, "invalid options.position"); | ||
}; | ||
} | ||
const Q = /* @__PURE__ */ new WeakMap(), de = new ResizeObserver((t) => { | ||
t.forEach((e) => { | ||
const r = e.target, n = Q.get(r); | ||
const Z = /* @__PURE__ */ new WeakMap(), dt = new ResizeObserver((e) => { | ||
e.forEach((t) => { | ||
const r = t.target, n = Z.get(r); | ||
if (n) { | ||
const s = { | ||
width: e.contentRect.width, | ||
height: e.contentRect.height, | ||
borderBoxWidth: e.borderBoxSize[0].inlineSize, | ||
borderBoxHeight: e.borderBoxSize[0].blockSize, | ||
contentBoxWidth: e.contentBoxSize[0].inlineSize, | ||
contentBoxHeight: e.contentBoxSize[0].blockSize | ||
width: t.contentRect.width, | ||
height: t.contentRect.height, | ||
borderBoxWidth: t.borderBoxSize[0].inlineSize, | ||
borderBoxHeight: t.borderBoxSize[0].blockSize, | ||
contentBoxWidth: t.contentBoxSize[0].inlineSize, | ||
contentBoxHeight: t.contentBoxSize[0].blockSize | ||
}; | ||
@@ -1454,4 +1356,4 @@ z(s, n()) || n(s); | ||
}); | ||
function ur(t, e) { | ||
if (t === window) { | ||
function hr(e, t) { | ||
if (e === window) { | ||
const r = () => { | ||
@@ -1462,48 +1364,48 @@ const n = { | ||
}; | ||
return z(n, e()) || e(n), n; | ||
return z(n, t()) || t(n), n; | ||
}; | ||
return window.addEventListener("resize", r), r(), () => { | ||
e(null), window.removeEventListener("resize", r); | ||
t(null), window.removeEventListener("resize", r); | ||
}; | ||
} else { | ||
de.observe(t), Q.set(t, e); | ||
const r = t.getBoundingClientRect(); | ||
return e({ | ||
dt.observe(e), Z.set(e, t); | ||
const r = e.getBoundingClientRect(); | ||
return t({ | ||
width: r.width, | ||
height: r.height | ||
}), () => { | ||
de.unobserve(t), Q.delete(t), e(null); | ||
dt.unobserve(e), Z.delete(e), t(null); | ||
}; | ||
} | ||
} | ||
function fr(t, e) { | ||
function lr(e, t) { | ||
const r = () => { | ||
e(!0); | ||
t(!0); | ||
}, n = () => { | ||
e(!1); | ||
t(!1); | ||
}; | ||
return t.addEventListener("focusin", r), t.addEventListener("focusout", n), () => { | ||
t.removeEventListener("focusin", r), t.removeEventListener("focusout", n); | ||
return e.addEventListener("focusin", r), e.addEventListener("focusout", n), () => { | ||
e.removeEventListener("focusin", r), e.removeEventListener("focusout", n); | ||
}; | ||
} | ||
const Dt = "dragmove"; | ||
function dr(t) { | ||
const e = (t == null ? void 0 : t.container) || document.body, r = (t == null ? void 0 : t.customEventName) || Dt; | ||
const Oe = "dragmove"; | ||
function ur(e) { | ||
const t = (e == null ? void 0 : e.container) || document.body, r = (e == null ? void 0 : e.customEventName) || Oe; | ||
return function(s) { | ||
const i = (o) => { | ||
const a = o.clientX, c = o.clientY; | ||
let u = a, p = c; | ||
const d = (l) => { | ||
const h = { | ||
clientX: l.clientX, | ||
clientY: l.clientY, | ||
deltaXFromStart: l.clientX - a, | ||
deltaYFromStart: l.clientY - c, | ||
deltaX: l.clientX - u, | ||
deltaY: l.clientY - p | ||
let h = a, p = c; | ||
const f = (m) => { | ||
const d = { | ||
clientX: m.clientX, | ||
clientY: m.clientY, | ||
deltaXFromStart: m.clientX - a, | ||
deltaYFromStart: m.clientY - c, | ||
deltaX: m.clientX - h, | ||
deltaY: m.clientY - p | ||
}; | ||
s.dispatchEvent(new CustomEvent(r, { detail: h })); | ||
s.dispatchEvent(new CustomEvent(r, { detail: d })); | ||
}; | ||
e.addEventListener("mousemove", d), e.addEventListener("mouseup", () => { | ||
e.removeEventListener("mousemove", d); | ||
t.addEventListener("mousemove", f), t.addEventListener("mouseup", () => { | ||
t.removeEventListener("mousemove", f); | ||
}, { once: !0 }); | ||
@@ -1516,6 +1418,6 @@ }; | ||
} | ||
function pr(t) { | ||
function fr(e) { | ||
return function(r, n) { | ||
const s = (i) => { | ||
if (!t()) | ||
if (!e()) | ||
return; | ||
@@ -1539,6 +1441,6 @@ const o = { clientX: i.clientX, offsetX: 0, clientY: i.clientY, offsetY: 0 }, a = (c) => { | ||
} | ||
function mr(t) { | ||
function dr(e) { | ||
return function(r, n) { | ||
const s = (i) => { | ||
n(t(r)), document.addEventListener("mouseup", () => { | ||
n(e(r)), document.addEventListener("mouseup", () => { | ||
n(null); | ||
@@ -1552,73 +1454,73 @@ }, { once: !0 }); | ||
} | ||
function yr(t, e) { | ||
function pr(e, t) { | ||
const r = () => { | ||
e({ | ||
scrollTop: t.scrollTop, | ||
scrollLeft: t.scrollLeft, | ||
scrollWidth: t.scrollWidth, | ||
scrollHeight: t.scrollHeight | ||
t({ | ||
scrollTop: e.scrollTop, | ||
scrollLeft: e.scrollLeft, | ||
scrollWidth: e.scrollWidth, | ||
scrollHeight: e.scrollHeight | ||
}); | ||
}; | ||
return t.addEventListener("scroll", r), () => { | ||
t.removeEventListener("scroll", r); | ||
return e.addEventListener("scroll", r), () => { | ||
e.removeEventListener("scroll", r); | ||
}; | ||
} | ||
export { | ||
V as ComponentHost, | ||
cr as ContextProvider, | ||
Dt as DEFAULT_DRAG_MOVE_EVENT, | ||
Et as DataContext, | ||
Nt as Form, | ||
$t as FormContext, | ||
we as Fragment, | ||
lr as ModalContext, | ||
Ct as N_ATTR, | ||
pt as Portal, | ||
v as PropTypes, | ||
Z as StaticHost, | ||
xt as StaticHostConfig, | ||
M as StyleSize, | ||
ve as autoUnit, | ||
zt as bindProps, | ||
It as createContext, | ||
g as createElement, | ||
Vt as createElementNS, | ||
sr as createEventTransfer, | ||
R as createHost, | ||
dr as createOnDragMove, | ||
pr as createReactiveDragPosition, | ||
mr as createReactiveDragTarget, | ||
hr as createReactivePosition, | ||
mt as createRef, | ||
vt as createRoot, | ||
yt as createRxRef, | ||
jt as dispatchEvent, | ||
w as eventAlias, | ||
_t as jsx, | ||
Gt as jsxDEV, | ||
Ft as jsxs, | ||
U as mergeProp, | ||
gt as mergeProps, | ||
Jt as onBackspaceKey, | ||
qt as onDownKey, | ||
Ut as onESCKey, | ||
Xt as onEnterKey, | ||
rr as onKey, | ||
Wt as onLeftKey, | ||
Qt as onLeftMouseDown, | ||
tr as onMiddleMouseDown, | ||
Kt as onRightKey, | ||
er as onRightMouseDown, | ||
nr as onSelf, | ||
Zt as onSpaceKey, | ||
Yt as onTabKey, | ||
Bt as onUpKey, | ||
fr as reactiveFocused, | ||
yr as reactiveScrollPosition, | ||
ur as reactiveSize, | ||
kt as setAutoUnitType, | ||
ir as withCurrentRange, | ||
or as withPreventDefault, | ||
ar as withStopPropagation | ||
I as ComponentHost, | ||
or as ContextProvider, | ||
Oe as DEFAULT_DRAG_MOVE_EVENT, | ||
ye as DataContext, | ||
He as Form, | ||
ke as FormContext, | ||
F as Fragment, | ||
ar as ModalContext, | ||
ge as N_ATTR, | ||
fe as Portal, | ||
H as PropTypes, | ||
J as StaticHost, | ||
Pe as StaticHostConfig, | ||
N as StyleSize, | ||
kt as autoUnit, | ||
_e as bindProps, | ||
$e as createContext, | ||
w as createElement, | ||
Ie as createElementNS, | ||
rr as createEventTransfer, | ||
O as createHost, | ||
ur as createOnDragMove, | ||
fr as createReactiveDragPosition, | ||
dr as createReactiveDragTarget, | ||
cr as createReactivePosition, | ||
de as createRef, | ||
Le as createRoot, | ||
pe as createRxRef, | ||
Me as dispatchEvent, | ||
A as eventAlias, | ||
De as jsx, | ||
Fe as jsxDEV, | ||
je as jsxs, | ||
Y as mergeProp, | ||
me as mergeProps, | ||
Ye as onBackspaceKey, | ||
Be as onDownKey, | ||
Xe as onESCKey, | ||
We as onEnterKey, | ||
tr as onKey, | ||
qe as onLeftKey, | ||
Je as onLeftMouseDown, | ||
Qe as onMiddleMouseDown, | ||
Ge as onRightKey, | ||
Ze as onRightMouseDown, | ||
er as onSelf, | ||
Ue as onSpaceKey, | ||
Ke as onTabKey, | ||
ze as onUpKey, | ||
lr as reactiveFocused, | ||
pr as reactiveScrollPosition, | ||
hr as reactiveSize, | ||
Ve as setAutoUnitType, | ||
nr as withCurrentRange, | ||
sr as withPreventDefault, | ||
ir as withStopPropagation | ||
}; | ||
//# sourceMappingURL=axii.js.map |
{ | ||
"name": "axii", | ||
"version": "2.6.63", | ||
"version": "2.6.64", | ||
"description": "", | ||
@@ -38,2 +38,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@playwright/test": "^1.49.1", | ||
"@testing-library/user-event": "^14.5.2", | ||
@@ -40,0 +41,0 @@ "@types/node": "^22.9.3", |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
514739
9
2945