@elurjs/core 3.6.1 → 3.7.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/async.cjs +1 -1
- package/dist/lib/async.js +1 -1
- package/dist/lib/component.cjs +1 -2
- package/dist/lib/component.js +2 -66
- package/dist/lib/context.cjs +1 -1
- package/dist/lib/context.js +35 -23
- package/dist/lib/devtools.cjs +1 -1
- package/dist/lib/devtools.js +1 -1
- package/dist/lib/elur/async.cjs +1 -1
- package/dist/lib/elur/async.cjs.map +1 -1
- package/dist/lib/elur/async.js +1 -1
- package/dist/lib/elur/component.cjs +1 -2
- package/dist/lib/elur/component.d.cts +1 -17
- package/dist/lib/elur/component.d.ts +1 -17
- package/dist/lib/elur/component.js +2 -66
- package/dist/lib/elur/context.cjs +1 -1
- package/dist/lib/elur/context.cjs.map +1 -1
- package/dist/lib/elur/context.d.cts +5 -0
- package/dist/lib/elur/context.d.ts +5 -0
- package/dist/lib/elur/context.js +35 -23
- package/dist/lib/elur/context.js.map +1 -1
- package/dist/lib/elur/devtools.cjs +1 -1
- package/dist/lib/elur/devtools.cjs.map +1 -1
- package/dist/lib/elur/devtools.js +1 -1
- package/dist/lib/elur/form.cjs +1 -1
- package/dist/lib/elur/form.cjs.map +1 -1
- package/dist/lib/elur/form.js +1 -1
- package/dist/lib/elur/hydrate/index.cjs +1 -2
- package/dist/lib/elur/hydrate/index.d.cts +1 -13
- package/dist/lib/elur/hydrate/index.d.ts +1 -13
- package/dist/lib/elur/hydrate/index.js +2 -410
- package/dist/lib/elur/lifecycle.cjs +1 -1
- package/dist/lib/elur/lifecycle.cjs.map +1 -1
- package/dist/lib/elur/lifecycle.d.cts +27 -0
- package/dist/lib/elur/lifecycle.d.ts +27 -0
- package/dist/lib/elur/lifecycle.js +4 -0
- package/dist/lib/elur/lifecycle.js.map +1 -1
- package/dist/lib/elur/next/component.d.cts +281 -0
- package/dist/lib/elur/next/component.d.ts +281 -0
- package/dist/lib/elur/next/dom-write.d.cts +18 -0
- package/dist/lib/elur/next/dom-write.d.ts +18 -0
- package/dist/lib/elur/next/hydrate.d.cts +14 -0
- package/dist/lib/elur/next/hydrate.d.ts +14 -0
- package/dist/lib/elur/next/keyed-diff.d.cts +46 -0
- package/dist/lib/elur/next/keyed-diff.d.ts +46 -0
- package/dist/lib/elur/next/mount-helpers.d.cts +25 -0
- package/dist/lib/elur/next/mount-helpers.d.ts +25 -0
- package/dist/lib/elur/next/mount.d.cts +29 -0
- package/dist/lib/elur/next/mount.d.ts +29 -0
- package/dist/lib/elur/next/node-binding.d.cts +6 -0
- package/dist/lib/elur/next/node-binding.d.ts +6 -0
- package/dist/lib/elur/next/reactivity.d.cts +193 -0
- package/dist/lib/elur/next/reactivity.d.ts +193 -0
- package/dist/lib/elur/next-2/component.cjs +2 -0
- package/dist/lib/elur/next-2/component.cjs.map +1 -0
- package/dist/lib/elur/next-2/component.d.cts +283 -0
- package/dist/lib/elur/next-2/component.d.ts +283 -0
- package/dist/lib/elur/next-2/component.js +340 -0
- package/dist/lib/elur/next-2/component.js.map +1 -0
- package/dist/lib/elur/next-2/dom-write.cjs +2 -0
- package/dist/lib/elur/next-2/dom-write.cjs.map +1 -0
- package/dist/lib/elur/next-2/dom-write.d.cts +18 -0
- package/dist/lib/elur/next-2/dom-write.d.ts +18 -0
- package/dist/lib/elur/next-2/dom-write.js +31 -0
- package/dist/lib/elur/next-2/dom-write.js.map +1 -0
- package/dist/lib/elur/next-2/hydrate.cjs +2 -0
- package/dist/lib/elur/next-2/hydrate.cjs.map +1 -0
- package/dist/lib/elur/next-2/hydrate.d.cts +30 -0
- package/dist/lib/elur/next-2/hydrate.d.ts +30 -0
- package/dist/lib/elur/next-2/hydrate.js +449 -0
- package/dist/lib/elur/next-2/hydrate.js.map +1 -0
- package/dist/lib/elur/next-2/keyed-diff.cjs +2 -0
- package/dist/lib/elur/next-2/keyed-diff.cjs.map +1 -0
- package/dist/lib/elur/next-2/keyed-diff.d.cts +79 -0
- package/dist/lib/elur/next-2/keyed-diff.d.ts +79 -0
- package/dist/lib/elur/next-2/keyed-diff.js +208 -0
- package/dist/lib/elur/next-2/keyed-diff.js.map +1 -0
- package/dist/lib/elur/next-2/mount-helpers.cjs +2 -0
- package/dist/lib/elur/next-2/mount-helpers.cjs.map +1 -0
- package/dist/lib/elur/next-2/mount-helpers.d.cts +25 -0
- package/dist/lib/elur/next-2/mount-helpers.d.ts +25 -0
- package/dist/lib/elur/next-2/mount-helpers.js +87 -0
- package/dist/lib/elur/next-2/mount-helpers.js.map +1 -0
- package/dist/lib/elur/next-2/mount.cjs +2 -0
- package/dist/lib/elur/next-2/mount.cjs.map +1 -0
- package/dist/lib/elur/next-2/mount.d.cts +29 -0
- package/dist/lib/elur/next-2/mount.d.ts +29 -0
- package/dist/lib/elur/next-2/mount.js +34 -0
- package/dist/lib/elur/next-2/mount.js.map +1 -0
- package/dist/lib/elur/next-2/node-binding.cjs +2 -0
- package/dist/lib/elur/next-2/node-binding.cjs.map +1 -0
- package/dist/lib/elur/next-2/node-binding.d.cts +6 -0
- package/dist/lib/elur/next-2/node-binding.d.ts +6 -0
- package/dist/lib/elur/next-2/node-binding.js +130 -0
- package/dist/lib/elur/next-2/node-binding.js.map +1 -0
- package/dist/lib/elur/next-2/reactivity.cjs +2 -0
- package/dist/lib/elur/next-2/reactivity.cjs.map +1 -0
- package/dist/lib/elur/next-2/reactivity.d.cts +220 -0
- package/dist/lib/elur/next-2/reactivity.d.ts +220 -0
- package/dist/lib/elur/next-2/reactivity.js +614 -0
- package/dist/lib/elur/next-2/reactivity.js.map +1 -0
- package/dist/lib/elur/next-2/scheduler.cjs +2 -0
- package/dist/lib/elur/next-2/scheduler.cjs.map +1 -0
- package/dist/lib/elur/next-2/scheduler.d.cts +23 -0
- package/dist/lib/elur/next-2/scheduler.d.ts +23 -0
- package/dist/lib/elur/next-2/scheduler.js +26 -0
- package/dist/lib/elur/next-2/scheduler.js.map +1 -0
- package/dist/lib/elur/plugins.cjs +1 -1
- package/dist/lib/elur/plugins.cjs.map +1 -1
- package/dist/lib/elur/plugins.js +1 -1
- package/dist/lib/elur/reactivity.cjs +1 -2
- package/dist/lib/elur/reactivity.d.cts +1 -67
- package/dist/lib/elur/reactivity.d.ts +1 -67
- package/dist/lib/elur/reactivity.js +2 -218
- package/dist/lib/elur/router.cjs +2 -2
- package/dist/lib/elur/router.cjs.map +1 -1
- package/dist/lib/elur/router.js +2 -2
- package/dist/lib/elur/router.js.map +1 -1
- package/dist/lib/elur/server/index.cjs +1 -1
- package/dist/lib/elur/server/index.cjs.map +1 -1
- package/dist/lib/elur/server/index.js +180 -108
- package/dist/lib/elur/server/index.js.map +1 -1
- package/dist/lib/elur/store.cjs +1 -1
- package/dist/lib/elur/store.cjs.map +1 -1
- package/dist/lib/elur/store.js +10 -4
- package/dist/lib/elur/store.js.map +1 -1
- package/dist/lib/elur/template/bindings.cjs +1 -1
- package/dist/lib/elur/template/bindings.cjs.map +1 -1
- package/dist/lib/elur/template/bindings.js +98 -84
- package/dist/lib/elur/template/bindings.js.map +1 -1
- package/dist/lib/elur/template/dom-write.d.cts +1 -5
- package/dist/lib/elur/template/dom-write.d.ts +1 -5
- package/dist/lib/elur/template/error-boundary.cjs +1 -1
- package/dist/lib/elur/template/error-boundary.cjs.map +1 -1
- package/dist/lib/elur/template/error-boundary.js +56 -50
- package/dist/lib/elur/template/error-boundary.js.map +1 -1
- package/dist/lib/elur/template/html.cjs +1 -1
- package/dist/lib/elur/template/html.cjs.map +1 -1
- package/dist/lib/elur/template/html.js +40 -37
- package/dist/lib/elur/template/html.js.map +1 -1
- package/dist/lib/elur/template/index.cjs +1 -1
- package/dist/lib/elur/template/index.d.cts +2 -1
- package/dist/lib/elur/template/index.d.ts +2 -1
- package/dist/lib/elur/template/index.js +13 -12
- package/dist/lib/elur/template/keyed-diff.d.cts +1 -32
- package/dist/lib/elur/template/keyed-diff.d.ts +1 -32
- package/dist/lib/elur/template/keyed.cjs +1 -1
- package/dist/lib/elur/template/keyed.cjs.map +1 -1
- package/dist/lib/elur/template/keyed.d.cts +10 -2
- package/dist/lib/elur/template/keyed.d.ts +10 -2
- package/dist/lib/elur/template/keyed.js +12 -1
- package/dist/lib/elur/template/keyed.js.map +1 -1
- package/dist/lib/elur/template/mount-helpers.d.cts +1 -29
- package/dist/lib/elur/template/mount-helpers.d.ts +1 -29
- package/dist/lib/elur/template/node-binding.d.cts +1 -6
- package/dist/lib/elur/template/node-binding.d.ts +1 -6
- package/dist/lib/elur/template/portal.cjs +1 -1
- package/dist/lib/elur/template/portal.cjs.map +1 -1
- package/dist/lib/elur/template/portal.js +1 -1
- package/dist/lib/elur/template/transitions.cjs +1 -1
- package/dist/lib/elur/template/transitions.cjs.map +1 -1
- package/dist/lib/elur/template/transitions.js +2 -2
- package/dist/lib/elur/template/types.cjs +1 -1
- package/dist/lib/elur/template/types.cjs.map +1 -1
- package/dist/lib/elur/template/types.d.cts +55 -0
- package/dist/lib/elur/template/types.d.ts +55 -0
- package/dist/lib/elur/template/types.js +5 -1
- package/dist/lib/elur/template/types.js.map +1 -1
- package/dist/lib/elur.cjs +1 -1
- package/dist/lib/elur.js +2 -2
- package/dist/lib/form.cjs +1 -1
- package/dist/lib/form.js +1 -1
- package/dist/lib/hydrate.cjs +1 -2
- package/dist/lib/hydrate.js +2 -410
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/lifecycle.cjs +1 -1
- package/dist/lib/lifecycle.js +4 -0
- package/dist/lib/plugins.cjs +1 -1
- package/dist/lib/plugins.js +1 -1
- package/dist/lib/router.cjs +2 -2
- package/dist/lib/router.js +2 -2
- package/dist/lib/server.cjs +1 -1
- package/dist/lib/server.js +180 -108
- package/dist/lib/signals.cjs +1 -2
- package/dist/lib/signals.js +2 -218
- package/dist/lib/store.cjs +1 -1
- package/dist/lib/store.js +10 -4
- package/dist/lib/template.cjs +1 -1
- package/dist/lib/template.js +13 -12
- package/package.json +7 -9
- package/dist/lib/elur/component.cjs.map +0 -1
- package/dist/lib/elur/component.js.map +0 -1
- package/dist/lib/elur/hydrate/index.cjs.map +0 -1
- package/dist/lib/elur/hydrate/index.js.map +0 -1
- package/dist/lib/elur/reactivity.cjs.map +0 -1
- package/dist/lib/elur/reactivity.js.map +0 -1
- package/dist/lib/elur/template/dom-write.cjs +0 -2
- package/dist/lib/elur/template/dom-write.cjs.map +0 -1
- package/dist/lib/elur/template/dom-write.js +0 -16
- package/dist/lib/elur/template/dom-write.js.map +0 -1
- package/dist/lib/elur/template/keyed-diff.cjs +0 -2
- package/dist/lib/elur/template/keyed-diff.cjs.map +0 -1
- package/dist/lib/elur/template/keyed-diff.js +0 -100
- package/dist/lib/elur/template/keyed-diff.js.map +0 -1
- package/dist/lib/elur/template/mount-helpers.cjs +0 -2
- package/dist/lib/elur/template/mount-helpers.cjs.map +0 -1
- package/dist/lib/elur/template/mount-helpers.js +0 -132
- package/dist/lib/elur/template/mount-helpers.js.map +0 -1
- package/dist/lib/elur/template/node-binding.cjs +0 -2
- package/dist/lib/elur/template/node-binding.cjs.map +0 -1
- package/dist/lib/elur/template/node-binding.js +0 -95
- package/dist/lib/elur/template/node-binding.js.map +0 -1
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { Signal as e, _bindSignal as t, createRoot as n, effect as r } from "./reactivity.js";
|
|
2
|
+
import { ELUR_RENDER_PROTOCOL as i, ELUR_TEMPLATE_DESCRIPTOR as a, isDerivedBinding as o, isElurTemplate as s, isKeyedList as c } from "../template/types.js";
|
|
3
|
+
import { isElurComponent as l } from "../../lifecycle.js";
|
|
4
|
+
import { _captureContextSnapshot as u, _popComponentContext as d, _pushComponentContext as f } from "../../context.js";
|
|
5
|
+
import { ComponentInstance as p, isComponentInvocation as m } from "./component.js";
|
|
6
|
+
import { _mountComponent as h } from "./mount-helpers.js";
|
|
7
|
+
import { deserializeRepeatKey as g, normalizeRepeatKey as _, serializeRepeatKey as v } from "../template/keyed.js";
|
|
8
|
+
import { createKeyedMount as y, reconcileKeyedList as b } from "./keyed-diff.js";
|
|
9
|
+
import { sanitizeUrl as x } from "../template/sanitize.js";
|
|
10
|
+
import { activateDelegatedEvent as S, isDelegableEvent as C } from "../template/bindings.js";
|
|
11
|
+
//#region src/elur/next-2/hydrate.ts
|
|
12
|
+
function w(e, t, n = {}) {
|
|
13
|
+
try {
|
|
14
|
+
if (m(e)) {
|
|
15
|
+
let r = new p(e);
|
|
16
|
+
return r._hydrate({
|
|
17
|
+
parent: t,
|
|
18
|
+
bounds: null,
|
|
19
|
+
mismatch: n.mismatch,
|
|
20
|
+
render: (e) => {
|
|
21
|
+
if (s(e)) {
|
|
22
|
+
let r = e[a];
|
|
23
|
+
return r || z(n, -1, "descriptor", "Component template has no hydration descriptor"), E(r, t, n);
|
|
24
|
+
}
|
|
25
|
+
return e?._render?.(t, null);
|
|
26
|
+
}
|
|
27
|
+
}), { unmount: () => r.unmount() };
|
|
28
|
+
}
|
|
29
|
+
if (l(e)) return T(e, t, n);
|
|
30
|
+
let r = e[a];
|
|
31
|
+
return r || z(n, -1, "descriptor", "Template has no hydration descriptor"), { unmount: E(r, t, n) };
|
|
32
|
+
} catch (r) {
|
|
33
|
+
if (n.mismatch === "throw") throw r;
|
|
34
|
+
if (n.mismatch !== "remount" && console.warn("[elur] Hydration mismatch; remounting root:", r), t.replaceChildren(), m(e)) {
|
|
35
|
+
let n = new p(e);
|
|
36
|
+
return n.mount(t, null), { unmount: () => n.unmount() };
|
|
37
|
+
}
|
|
38
|
+
return { unmount: l(e) ? h(e, t, null) : e._render(t, null) };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function T(e, t, n) {
|
|
42
|
+
f();
|
|
43
|
+
let r = () => {};
|
|
44
|
+
try {
|
|
45
|
+
try {
|
|
46
|
+
e.onInit?.();
|
|
47
|
+
} catch (t) {
|
|
48
|
+
if (e.onError) e.onError(t);
|
|
49
|
+
else throw t;
|
|
50
|
+
}
|
|
51
|
+
let i = e.render()[a];
|
|
52
|
+
i || z(n, -1, "descriptor", "Component template has no hydration descriptor"), r = E(i, t, n);
|
|
53
|
+
} finally {
|
|
54
|
+
d();
|
|
55
|
+
}
|
|
56
|
+
let i = e.onMount?.();
|
|
57
|
+
return { unmount() {
|
|
58
|
+
e.onUnmount?.(), typeof i == "function" && i(), r();
|
|
59
|
+
} };
|
|
60
|
+
}
|
|
61
|
+
function E(e, t, n, r) {
|
|
62
|
+
if (e.hydrate) {
|
|
63
|
+
let i = e.hydrate(t, e.values, n, r);
|
|
64
|
+
return typeof i == "function" ? i : () => {};
|
|
65
|
+
}
|
|
66
|
+
let i = D(t, r), a = [];
|
|
67
|
+
for (let t = 0; t < e.contexts.length; t++) {
|
|
68
|
+
let r = e.contexts[t], o = e.values[t];
|
|
69
|
+
if (r.type === "event") {
|
|
70
|
+
let e = i.events.get(t);
|
|
71
|
+
e || z(n, t, "event", `Missing event marker ${t}`), e.removeAttribute(`data-elur-e-${t}`), a.push(A(e, r.eventName, r.modifiers, o));
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (r.type === "attr") {
|
|
75
|
+
let e = i.attributes.get(t);
|
|
76
|
+
e || z(n, t, "attribute", `Missing attribute marker ${t}`), e.removeAttribute(`data-elur-a-${t}`), a.push(j(e, r.attrName, r.url === !0, o));
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
let s = i.nodes.get(t);
|
|
80
|
+
s || z(n, t, "node", `Missing node marker ${t}`);
|
|
81
|
+
let c = M(s, o, n, i.keyed.get(t), i.arrayItems.get(t));
|
|
82
|
+
c && a.push(c);
|
|
83
|
+
}
|
|
84
|
+
return () => {
|
|
85
|
+
for (let e = a.length - 1; e >= 0; e--) a[e]();
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function D(e, t) {
|
|
89
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = [], l = [], u = [], d = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT), f;
|
|
90
|
+
for (; f = d.nextNode();) {
|
|
91
|
+
if (t && !k(f, t)) continue;
|
|
92
|
+
if (f.nodeType === Node.COMMENT_NODE) {
|
|
93
|
+
let e = f, t = /^elur-(\d+)$/.exec(e.data);
|
|
94
|
+
if (t) {
|
|
95
|
+
let n = Number(t[1]);
|
|
96
|
+
c.length === 0 && r.set(n, e), c.push(n);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
let i = /^elur-end-(\d+)$/.exec(e.data);
|
|
100
|
+
if (i) {
|
|
101
|
+
let t = Number(i[1]);
|
|
102
|
+
if (c.pop() === t && c.length === 0) {
|
|
103
|
+
let i = r.get(t);
|
|
104
|
+
i && n.set(t, {
|
|
105
|
+
start: i,
|
|
106
|
+
end: e
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
let a = /^elur-ki:(.+)$/.exec(e.data);
|
|
112
|
+
if (a) {
|
|
113
|
+
let t = a[1];
|
|
114
|
+
l.length === 0 && c.length === 1 ? l.push({
|
|
115
|
+
start: e,
|
|
116
|
+
serializedKey: t,
|
|
117
|
+
parentIndex: c[c.length - 1]
|
|
118
|
+
}) : l.push({
|
|
119
|
+
start: e,
|
|
120
|
+
serializedKey: t,
|
|
121
|
+
parentIndex: -1
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (e.data === "elur-ke") {
|
|
126
|
+
let t = l.pop();
|
|
127
|
+
if (t) {
|
|
128
|
+
if (t.parentIndex >= 0) {
|
|
129
|
+
let n = o.get(t.parentIndex) ?? [];
|
|
130
|
+
n.push({
|
|
131
|
+
start: t.start,
|
|
132
|
+
end: e,
|
|
133
|
+
serializedKey: t.serializedKey
|
|
134
|
+
}), o.set(t.parentIndex, n);
|
|
135
|
+
}
|
|
136
|
+
} else throw Error("[elur] Hydration marker mismatch: orphan keyed end marker (elur-ke)");
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (e.data === "elur-ai") {
|
|
140
|
+
u.length === 0 && c.length === 1 ? u.push({
|
|
141
|
+
start: e,
|
|
142
|
+
parentIndex: c[c.length - 1]
|
|
143
|
+
}) : u.push({
|
|
144
|
+
start: e,
|
|
145
|
+
parentIndex: -1
|
|
146
|
+
});
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (e.data === "elur-aiend") {
|
|
150
|
+
let t = u.pop();
|
|
151
|
+
if (t && t.parentIndex >= 0) {
|
|
152
|
+
let n = s.get(t.parentIndex) ?? [];
|
|
153
|
+
n.push({
|
|
154
|
+
start: t.start,
|
|
155
|
+
end: e
|
|
156
|
+
}), s.set(t.parentIndex, n);
|
|
157
|
+
}
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (c.length > 0) continue;
|
|
163
|
+
let e = f;
|
|
164
|
+
for (let t of Array.from(e.attributes)) {
|
|
165
|
+
let n = /^data-elur-e-(\d+)$/.exec(t.name);
|
|
166
|
+
n && a.set(Number(n[1]), e);
|
|
167
|
+
let r = /^data-elur-a-(\d+)$/.exec(t.name);
|
|
168
|
+
r && i.set(Number(r[1]), e);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
nodes: n,
|
|
173
|
+
attributes: i,
|
|
174
|
+
events: a,
|
|
175
|
+
keyed: o,
|
|
176
|
+
arrayItems: s
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function O(e, t, n, r, i) {
|
|
180
|
+
return M(e, t, n ?? {}, r, i);
|
|
181
|
+
}
|
|
182
|
+
function k(e, t) {
|
|
183
|
+
let n = document.createRange();
|
|
184
|
+
return n.setStartAfter(t.start), n.setEndBefore(t.end), n.intersectsNode(e);
|
|
185
|
+
}
|
|
186
|
+
function A(e, t, n, r) {
|
|
187
|
+
if (typeof r != "function") throw TypeError(`Event "${t}" requires a function`);
|
|
188
|
+
let i = r;
|
|
189
|
+
if (C(t) && !n.includes("capture") && !n.includes("once") && document.body.contains(e)) return S(e, t, n, i);
|
|
190
|
+
let a = {
|
|
191
|
+
once: n.includes("once"),
|
|
192
|
+
capture: n.includes("capture"),
|
|
193
|
+
passive: n.includes("passive")
|
|
194
|
+
}, o = (e) => {
|
|
195
|
+
n.includes("prevent") && e.preventDefault(), n.includes("stop") && e.stopPropagation(), !(n.includes("self") && e.target !== e.currentTarget) && i(e);
|
|
196
|
+
};
|
|
197
|
+
return e.addEventListener(t, o, a), () => e.removeEventListener(t, o, a);
|
|
198
|
+
}
|
|
199
|
+
function j(n, i, a, s) {
|
|
200
|
+
if (i === "ref") {
|
|
201
|
+
let e = s;
|
|
202
|
+
return e.el = n, () => {
|
|
203
|
+
e.el = null;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
let c = (i === "value" || i === "checked" || i === "selected") && i in n, l = !0, u = !1, d = (e) => {
|
|
207
|
+
if (c) if (!l) n[i] = e ?? "";
|
|
208
|
+
else {
|
|
209
|
+
let t = n[i];
|
|
210
|
+
if (String(t) !== String(e ?? "") && !u) {
|
|
211
|
+
u = !0;
|
|
212
|
+
let e = i === "checked" || i === "selected" ? "change" : "input";
|
|
213
|
+
queueMicrotask(() => {
|
|
214
|
+
u = !1, n.dispatchEvent(new Event(e, { bubbles: !0 }));
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else if (e == null || e === !1) n.removeAttribute(i);
|
|
219
|
+
else {
|
|
220
|
+
let t = a ? x(String(e)) : String(e);
|
|
221
|
+
n.setAttribute(i, t);
|
|
222
|
+
}
|
|
223
|
+
l = !1;
|
|
224
|
+
};
|
|
225
|
+
return o(s) && (s = s.get), s instanceof e ? t(s, d) : typeof s == "function" ? r(() => d(s())) : (d(s), () => {});
|
|
226
|
+
}
|
|
227
|
+
function M(n, i, a, s, l) {
|
|
228
|
+
if (o(i) && (i = i.get), i instanceof e) {
|
|
229
|
+
let e = L(n);
|
|
230
|
+
e || (e = document.createTextNode(""), n.end.parentNode.insertBefore(e, n.end));
|
|
231
|
+
let r = e;
|
|
232
|
+
return t(i, (e) => {
|
|
233
|
+
r.nodeValue = e == null || e === !1 ? "" : String(e);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (typeof i != "function") return N(n, i, a, s, l);
|
|
237
|
+
let d = !0, f, p = L(n), m = null, h = u(), g = y(h), _ = (e) => {
|
|
238
|
+
console.warn(`[elur] repeat(): duplicate key "${e}". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`);
|
|
239
|
+
}, v = r(() => {
|
|
240
|
+
let e = i();
|
|
241
|
+
if (c(e)) {
|
|
242
|
+
if (d && !m) {
|
|
243
|
+
let t = P(e, s, a);
|
|
244
|
+
m = {
|
|
245
|
+
state: t.state,
|
|
246
|
+
prevOrder: t.prevOrder
|
|
247
|
+
}, f = t.cleanup, b({
|
|
248
|
+
zoneStart: n.start,
|
|
249
|
+
anchor: n.end,
|
|
250
|
+
state: m.state,
|
|
251
|
+
prevOrder: m.prevOrder,
|
|
252
|
+
list: e,
|
|
253
|
+
mount: g,
|
|
254
|
+
ctxSnapshot: h,
|
|
255
|
+
onDuplicateKey: _
|
|
256
|
+
}), p = null, d = !1;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
m || (f?.(), R(n), m = {
|
|
260
|
+
state: /* @__PURE__ */ new Map(),
|
|
261
|
+
prevOrder: []
|
|
262
|
+
}, f = () => {
|
|
263
|
+
for (let e of m.state.values()) e.cleanup();
|
|
264
|
+
}), b({
|
|
265
|
+
zoneStart: n.start,
|
|
266
|
+
anchor: n.end,
|
|
267
|
+
state: m.state,
|
|
268
|
+
prevOrder: m.prevOrder,
|
|
269
|
+
list: e,
|
|
270
|
+
mount: g,
|
|
271
|
+
ctxSnapshot: h,
|
|
272
|
+
onDuplicateKey: _
|
|
273
|
+
}), p = null, d = !1;
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
m && (f?.(), R(n), m = null, f = void 0), typeof e == "string" || typeof e == "number" || typeof e == "bigint" ? p ? p.nodeValue !== String(e) && (p.nodeValue = String(e)) : (p = document.createTextNode(String(e)), n.end.parentNode.insertBefore(p, n.end)) : d ? f = N(n, e, a, s, l) : (f?.(), R(n), f = I(n, e), p = L(n)), d = !1;
|
|
277
|
+
});
|
|
278
|
+
return () => {
|
|
279
|
+
v(), f?.();
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function N(e, t, n, r, o) {
|
|
283
|
+
if (c(t)) {
|
|
284
|
+
let i = u(), a = P(t, r, n);
|
|
285
|
+
return b({
|
|
286
|
+
zoneStart: e.start,
|
|
287
|
+
anchor: e.end,
|
|
288
|
+
state: a.state,
|
|
289
|
+
prevOrder: a.prevOrder,
|
|
290
|
+
list: t,
|
|
291
|
+
mount: y(i),
|
|
292
|
+
ctxSnapshot: i,
|
|
293
|
+
onDuplicateKey: (e) => {
|
|
294
|
+
console.warn(`[elur] repeat(): duplicate key "${e}". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`);
|
|
295
|
+
}
|
|
296
|
+
}), a.cleanup;
|
|
297
|
+
}
|
|
298
|
+
if (Array.isArray(t)) {
|
|
299
|
+
let r = [], i = o !== void 0 && o.length > 0;
|
|
300
|
+
for (let a = 0; a < t.length; a++) {
|
|
301
|
+
let s = t[a], c = o?.[a];
|
|
302
|
+
if (i && c) {
|
|
303
|
+
let e = N(c, s, n);
|
|
304
|
+
e && r.push(e);
|
|
305
|
+
} else if (i) {
|
|
306
|
+
let t = I(e, s);
|
|
307
|
+
t && r.push(t);
|
|
308
|
+
} else {
|
|
309
|
+
let t = N(e, s, n);
|
|
310
|
+
t && r.push(t);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return r.length ? () => {
|
|
314
|
+
for (let e = r.length - 1; e >= 0; e--) r[e]();
|
|
315
|
+
} : void 0;
|
|
316
|
+
}
|
|
317
|
+
if (s(t)) {
|
|
318
|
+
let r = t[a];
|
|
319
|
+
return r || z(n, -1, "descriptor", "Nested template has no hydration descriptor"), E(r, e.start.parentNode, n, e);
|
|
320
|
+
}
|
|
321
|
+
if (l(t)) {
|
|
322
|
+
f();
|
|
323
|
+
let r;
|
|
324
|
+
try {
|
|
325
|
+
try {
|
|
326
|
+
t.onInit?.();
|
|
327
|
+
} catch (e) {
|
|
328
|
+
if (t.onError) t.onError(e);
|
|
329
|
+
else throw e;
|
|
330
|
+
}
|
|
331
|
+
let i = t.render()[a];
|
|
332
|
+
i || z(n, -1, "descriptor", "Nested component has no hydration descriptor");
|
|
333
|
+
let o = E(i, e.start.parentNode, n, e), s = t.onMount?.();
|
|
334
|
+
r = () => {
|
|
335
|
+
t.onUnmount?.(), typeof s == "function" && s(), o();
|
|
336
|
+
};
|
|
337
|
+
} finally {
|
|
338
|
+
d();
|
|
339
|
+
}
|
|
340
|
+
return r;
|
|
341
|
+
}
|
|
342
|
+
if (typeof t == "object" && t) {
|
|
343
|
+
let r = t[i];
|
|
344
|
+
if (r?.hydrateDom) return r.hydrateDom({
|
|
345
|
+
parent: e.start.parentNode,
|
|
346
|
+
bounds: e,
|
|
347
|
+
context: n.context,
|
|
348
|
+
render: (t) => N(e, t, n)
|
|
349
|
+
}) ?? void 0;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function P(e, t, r) {
|
|
353
|
+
let i = /* @__PURE__ */ new Map(), a = [];
|
|
354
|
+
if (!t || t.length === 0) return {
|
|
355
|
+
state: i,
|
|
356
|
+
prevOrder: a,
|
|
357
|
+
cleanup: () => {}
|
|
358
|
+
};
|
|
359
|
+
let o = /* @__PURE__ */ new Map();
|
|
360
|
+
for (let t = 0; t < e.items.length; t++) {
|
|
361
|
+
let n = _(e.keyFn(e.items[t], t), t), r = v(n);
|
|
362
|
+
o.has(r) && console.warn(`[elur] repeat(): duplicate client key "${n}" during hydration. Keys must be unique; entries after the first leak.`), o.set(r, t);
|
|
363
|
+
}
|
|
364
|
+
for (let s of t) {
|
|
365
|
+
let t = o.get(s.serializedKey);
|
|
366
|
+
if (t === void 0) {
|
|
367
|
+
F(s);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
let c = e.items[t], l = _(e.keyFn(c, t), t);
|
|
371
|
+
if (v(l) !== s.serializedKey && console.warn(`[elur] repeat(): hydration key mismatch at index ${t} (${g(s.serializedKey)} != ${l}). The SSR item is adopted by position.`), i.has(l)) {
|
|
372
|
+
console.warn(`[elur] repeat(): duplicate key "${l}" during hydration; removing duplicate SSR node.`), F(s);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
let u = e.renderFn(c, t), d, f = n((e) => (d = N({
|
|
376
|
+
start: s.start,
|
|
377
|
+
end: s.end
|
|
378
|
+
}, u, r), e));
|
|
379
|
+
i.set(l, {
|
|
380
|
+
start: s.start,
|
|
381
|
+
end: s.end,
|
|
382
|
+
cleanup: () => {
|
|
383
|
+
d?.(), f();
|
|
384
|
+
},
|
|
385
|
+
item: c
|
|
386
|
+
}), a.push(l);
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
state: i,
|
|
390
|
+
prevOrder: a,
|
|
391
|
+
cleanup: () => {
|
|
392
|
+
for (let e of i.values()) e.cleanup();
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function F(e) {
|
|
397
|
+
let t = e.start.nextSibling;
|
|
398
|
+
for (; t && t !== e.end;) {
|
|
399
|
+
let e = t.nextSibling;
|
|
400
|
+
t.parentNode?.removeChild(t), t = e;
|
|
401
|
+
}
|
|
402
|
+
e.start.parentNode?.removeChild(e.start), e.end.parentNode?.removeChild(e.end);
|
|
403
|
+
}
|
|
404
|
+
function I(e, t) {
|
|
405
|
+
if (t == null || t === !1 || t === !0) return;
|
|
406
|
+
if (Array.isArray(t)) {
|
|
407
|
+
let n = [];
|
|
408
|
+
for (let r of t) {
|
|
409
|
+
let t = I(e, r);
|
|
410
|
+
t && n.push(t);
|
|
411
|
+
}
|
|
412
|
+
return n.length ? () => {
|
|
413
|
+
for (let e = n.length - 1; e >= 0; e--) n[e]();
|
|
414
|
+
} : void 0;
|
|
415
|
+
}
|
|
416
|
+
if (s(t)) return t._render(e.end.parentNode, e.end);
|
|
417
|
+
if (l(t)) return t.render()._render(e.end.parentNode, e.end);
|
|
418
|
+
let n = document.createTextNode(String(t));
|
|
419
|
+
return e.end.parentNode.insertBefore(n, e.end), () => n.parentNode?.removeChild(n);
|
|
420
|
+
}
|
|
421
|
+
function L(e) {
|
|
422
|
+
let t = e.start.nextSibling;
|
|
423
|
+
for (; t && t !== e.end;) {
|
|
424
|
+
if (t.nodeType === Node.TEXT_NODE) return t;
|
|
425
|
+
t = t.nextSibling;
|
|
426
|
+
}
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
function R(e) {
|
|
430
|
+
let t = e.start.nextSibling;
|
|
431
|
+
for (; t && t !== e.end;) {
|
|
432
|
+
let e = t.nextSibling;
|
|
433
|
+
t.parentNode?.removeChild(t), t = e;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function z(e, t, n, r) {
|
|
437
|
+
let i = {
|
|
438
|
+
index: t,
|
|
439
|
+
kind: n,
|
|
440
|
+
message: r
|
|
441
|
+
};
|
|
442
|
+
e.onMismatch?.(i);
|
|
443
|
+
let a = /* @__PURE__ */ Error(`[elur] Hydration marker mismatch: ${r}`);
|
|
444
|
+
throw Object.assign(a, { mismatch: i }), a;
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
447
|
+
export { O as _hydrateNodeRange, w as hydrate };
|
|
448
|
+
|
|
449
|
+
//# sourceMappingURL=hydrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrate.js","names":[],"sources":["../../../../src/elur/next-2/hydrate.ts"],"sourcesContent":["import { _captureContextSnapshot, _popComponentContext, _pushComponentContext } from \"../context.js\";\nimport { isElurComponent, type ElurComponent } from \"../lifecycle.js\";\nimport { effect, createRoot, Signal, _bindSignal } from \"./reactivity.js\";\nimport { isDerivedBinding } from \"../template/types.js\";\nimport {\n ComponentInstance,\n isComponentInvocation,\n type ComponentInvocation,\n} from \"./component.js\";\nimport { sanitizeUrl } from \"../template/sanitize.js\";\nimport { activateDelegatedEvent, isDelegableEvent } from \"../template/bindings.js\";\nimport {\n isKeyedList,\n isElurTemplate,\n ELUR_RENDER_PROTOCOL,\n ELUR_TEMPLATE_DESCRIPTOR,\n type KEntry,\n type ElurMountHandle,\n type ElurRef,\n type ElurTemplate,\n type TemplateDescriptor,\n} from \"../template/types.js\";\nimport {\n deserializeRepeatKey,\n normalizeRepeatKey,\n serializeRepeatKey,\n type RepeatKey,\n} from \"../template/keyed.js\";\nimport { createKeyedMount, reconcileKeyedList } from \"./keyed-diff.js\";\nimport { _mountComponent } from \"./mount-helpers.js\";\n\nexport interface HydrateOptions {\n mismatch?: \"throw\" | \"warn-remount\" | \"remount\";\n onMismatch?: (error: HydrationMismatch) => void;\n context?: unknown;\n}\n\nexport interface HydrationMismatch {\n index: number;\n kind: \"node\" | \"attribute\" | \"event\" | \"descriptor\" | \"keyed\";\n message: string;\n}\n\ninterface MarkerRange {\n start: Comment;\n end: Comment;\n}\n\ninterface KeyedMarkerRange {\n start: Comment;\n end: Comment;\n serializedKey: string;\n}\n\ninterface ScannedMarkers {\n nodes: Map<number, MarkerRange>;\n attributes: Map<number, Element>;\n events: Map<number, Element>;\n keyed: Map<number, KeyedMarkerRange[]>;\n arrayItems: Map<number, MarkerRange[]>;\n}\n\nexport function hydrate(\n value: ElurTemplate | ElurComponent | ComponentInvocation<any>,\n container: Element,\n options: HydrateOptions = {},\n): ElurMountHandle {\n try {\n // A.18 — componentes funcionales: setup una vez + adoptar DOM SSR;\n // mismatch → el kernel remonta reusando el renderable.\n if (isComponentInvocation(value)) {\n const inst = new ComponentInstance(value);\n inst._hydrate({\n parent: container,\n bounds: null,\n mismatch: options.mismatch,\n render: (nested) => {\n if (isElurTemplate(nested)) {\n const d = nested[ELUR_TEMPLATE_DESCRIPTOR];\n if (!d) {\n throwMismatch(options, -1, \"descriptor\", \"Component template has no hydration descriptor\");\n }\n return hydrateDescriptor(d!, container, options);\n }\n return (nested as { _render?: (p: Node, b: Node | null) => () => void })\n ?._render?.(container, null);\n },\n });\n return { unmount: () => inst.unmount() };\n }\n if (isElurComponent(value)) return hydrateComponent(value, container, options);\n const descriptor = value[ELUR_TEMPLATE_DESCRIPTOR];\n if (!descriptor) throwMismatch(options, -1, \"descriptor\", \"Template has no hydration descriptor\");\n const cleanup = hydrateDescriptor(descriptor!, container, options);\n return { unmount: cleanup };\n } catch (error) {\n if (options.mismatch === \"throw\") throw error;\n if (options.mismatch !== \"remount\") console.warn(\"[elur] Hydration mismatch; remounting root:\", error);\n container.replaceChildren();\n if (isComponentInvocation(value)) {\n // A.18 — remount root por el kernel tras mismatch top-level.\n const inst = new ComponentInstance(value);\n inst.mount(container, null);\n return { unmount: () => inst.unmount() };\n }\n const cleanup = isElurComponent(value)\n ? _mountComponent(value, container, null)\n : value._render(container, null);\n return { unmount: cleanup };\n }\n}\n\nfunction hydrateComponent(\n component: ElurComponent,\n container: Element,\n options: HydrateOptions,\n): ElurMountHandle {\n _pushComponentContext();\n let cleanup = () => { };\n try {\n try {\n component.onInit?.();\n } catch (error) {\n if (component.onError) component.onError(error);\n else throw error;\n }\n const template = component.render();\n const descriptor = template[ELUR_TEMPLATE_DESCRIPTOR];\n if (!descriptor) throwMismatch(options, -1, \"descriptor\", \"Component template has no hydration descriptor\");\n cleanup = hydrateDescriptor(descriptor!, container, options);\n } finally {\n _popComponentContext();\n }\n const mountCleanup = component.onMount?.();\n return {\n unmount() {\n component.onUnmount?.();\n if (typeof mountCleanup === \"function\") mountCleanup();\n cleanup();\n },\n };\n}\n\nfunction hydrateDescriptor(\n descriptor: TemplateDescriptor,\n root: ParentNode,\n options: HydrateOptions,\n bounds?: MarkerRange,\n): () => void {\n // C.13: descriptor compilado — activación por posición, sin scan global.\n if (descriptor.hydrate) {\n const cleanup = descriptor.hydrate(root, descriptor.values, options, bounds);\n return typeof cleanup === \"function\" ? cleanup : () => { };\n }\n const markers = scanMarkers(root, bounds);\n const cleanups: Array<() => void> = [];\n\n for (let index = 0; index < descriptor.contexts.length; index++) {\n const context = descriptor.contexts[index];\n const value = descriptor.values[index];\n if (context.type === \"event\") {\n const element = markers.events.get(index);\n if (!element) throwMismatch(options, index, \"event\", `Missing event marker ${index}`);\n element!.removeAttribute(`data-elur-e-${index}`);\n cleanups.push(activateEvent(element!, context.eventName, context.modifiers, value));\n continue;\n }\n if (context.type === \"attr\") {\n const element = markers.attributes.get(index);\n if (!element) throwMismatch(options, index, \"attribute\", `Missing attribute marker ${index}`);\n element!.removeAttribute(`data-elur-a-${index}`);\n cleanups.push(activateAttribute(element!, context.attrName, context.url === true, value));\n continue;\n }\n\n const range = markers.nodes.get(index);\n if (!range) throwMismatch(options, index, \"node\", `Missing node marker ${index}`);\n const cleanup = activateNode(range!, value, options, markers.keyed.get(index), markers.arrayItems.get(index));\n if (cleanup) cleanups.push(cleanup);\n }\n\n return () => {\n for (let index = cleanups.length - 1; index >= 0; index--) cleanups[index]();\n };\n}\n\nfunction scanMarkers(root: ParentNode, bounds?: MarkerRange): ScannedMarkers {\n const nodes = new Map<number, MarkerRange>();\n const starts = new Map<number, Comment>();\n const attributes = new Map<number, Element>();\n const events = new Map<number, Element>();\n const keyed = new Map<number, KeyedMarkerRange[]>();\n const arrayItems = new Map<number, MarkerRange[]>();\n const stack: number[] = [];\n const keyedStack: Array<{ start: Comment; serializedKey: string; parentIndex: number }> = [];\n const arrayStack: Array<{ start: Comment; parentIndex: number }> = [];\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT);\n let current: Node | null;\n\n while ((current = walker.nextNode())) {\n if (bounds && !isInsideRange(current, bounds)) continue;\n if (current.nodeType === Node.COMMENT_NODE) {\n const comment = current as Comment;\n const startMatch = /^elur-(\\d+)$/.exec(comment.data);\n if (startMatch) {\n const index = Number(startMatch[1]);\n if (stack.length === 0) starts.set(index, comment);\n stack.push(index);\n continue;\n }\n const endMatch = /^elur-end-(\\d+)$/.exec(comment.data);\n if (endMatch) {\n const index = Number(endMatch[1]);\n const active = stack.pop();\n if (active === index && stack.length === 0) {\n const start = starts.get(index);\n if (start) nodes.set(index, { start, end: comment });\n }\n continue;\n }\n const keyedStartMatch = /^elur-ki:(.+)$/.exec(comment.data);\n if (keyedStartMatch) {\n const serializedKey = keyedStartMatch[1];\n if (keyedStack.length === 0 && stack.length === 1) {\n keyedStack.push({ start: comment, serializedKey, parentIndex: stack[stack.length - 1] });\n } else {\n keyedStack.push({ start: comment, serializedKey, parentIndex: -1 });\n }\n continue;\n }\n if (comment.data === \"elur-ke\") {\n const active = keyedStack.pop();\n if (active) {\n if (active.parentIndex >= 0) {\n const list = keyed.get(active.parentIndex) ?? [];\n list.push({ start: active.start, end: comment, serializedKey: active.serializedKey });\n keyed.set(active.parentIndex, list);\n }\n } else {\n throw new Error(\"[elur] Hydration marker mismatch: orphan keyed end marker (elur-ke)\");\n }\n continue;\n }\n if (comment.data === \"elur-ai\") {\n if (arrayStack.length === 0 && stack.length === 1) {\n arrayStack.push({ start: comment, parentIndex: stack[stack.length - 1] });\n } else {\n arrayStack.push({ start: comment, parentIndex: -1 });\n }\n continue;\n }\n if (comment.data === \"elur-aiend\") {\n const active = arrayStack.pop();\n if (active && active.parentIndex >= 0) {\n const list = arrayItems.get(active.parentIndex) ?? [];\n list.push({ start: active.start, end: comment });\n arrayItems.set(active.parentIndex, list);\n }\n continue;\n }\n continue;\n }\n if (stack.length > 0) continue;\n const element = current as Element;\n for (const attribute of Array.from(element.attributes)) {\n const eventMatch = /^data-elur-e-(\\d+)$/.exec(attribute.name);\n if (eventMatch) events.set(Number(eventMatch[1]), element);\n const attributeMatch = /^data-elur-a-(\\d+)$/.exec(attribute.name);\n if (attributeMatch) attributes.set(Number(attributeMatch[1]), element);\n }\n }\n\n return { nodes, attributes, events, keyed, arrayItems };\n}\n\n/**\n * @internal — C.13: activación de un binding de nodo durante hidratación\n * compilada. El runtime del plugin localiza los markers por posición y\n * delega aquí — misma semántica que el path de markers globales.\n */\nexport function _hydrateNodeRange(\n range: { start: Comment; end: Comment },\n value: unknown,\n options?: HydrateOptions,\n keyedItems?: Array<{ start: Comment; end: Comment; serializedKey: string }>,\n arrayItems?: Array<{ start: Comment; end: Comment }>,\n): (() => void) | undefined {\n return activateNode(range, value, options ?? {}, keyedItems, arrayItems);\n}\n\nfunction isInsideRange(node: Node, range: MarkerRange): boolean {\n const domRange = document.createRange();\n domRange.setStartAfter(range.start);\n domRange.setEndBefore(range.end);\n return domRange.intersectsNode(node);\n}\n\nfunction activateEvent(\n element: Element,\n eventName: string,\n modifiers: readonly string[],\n value: unknown,\n): () => void {\n if (typeof value !== \"function\") throw new TypeError(`Event \"${eventName}\" requires a function`);\n const rawHandler = value as EventListener;\n\n // Use global delegation for delegable events without capture/once mods,\n // matching the mount-time behavior in bindings.ts. The element must be\n // connected to the document for delegation to work (events bubble to\n // document where the delegated listener is registered).\n const canDelegate =\n isDelegableEvent(eventName) &&\n !modifiers.includes(\"capture\") &&\n !modifiers.includes(\"once\") &&\n document.body.contains(element);\n\n if (canDelegate) {\n return activateDelegatedEvent(element, eventName, modifiers, rawHandler);\n }\n\n // Non-delegable events or disconnected elements: use addEventListener directly.\n const options: AddEventListenerOptions = {\n once: modifiers.includes(\"once\"),\n capture: modifiers.includes(\"capture\"),\n passive: modifiers.includes(\"passive\"),\n };\n const listener = (event: Event) => {\n if (modifiers.includes(\"prevent\")) event.preventDefault();\n if (modifiers.includes(\"stop\")) event.stopPropagation();\n if (modifiers.includes(\"self\") && event.target !== event.currentTarget) return;\n rawHandler(event);\n };\n element.addEventListener(eventName, listener, options);\n return () => element.removeEventListener(eventName, listener, options);\n}\n\nfunction activateAttribute(\n element: Element,\n name: string,\n url: boolean,\n value: unknown,\n): () => void {\n if (name === \"ref\") {\n const reference = value as ElurRef<Element>;\n reference.el = element;\n return () => { reference.el = null; };\n }\n\n const isProperty = (name === \"value\" || name === \"checked\" || name === \"selected\") && name in element;\n let firstRun = true;\n let pendingSync = false;\n const update = (resolved: unknown) => {\n if (isProperty) {\n if (!firstRun) {\n (element as any)[name] = resolved ?? \"\";\n } else {\n // Interaction before hydration: the DOM may hold a value the\n // user (or a hydration race with lazy island directives like\n // \"visible\") wrote before the binding activated. The DOM is\n // authoritative; keep it and propagate it to reactive model\n // sources once every handler is attached (microtask) so a\n // late @input/@change listener picks up the real value.\n const current = (element as any)[name];\n const model = resolved ?? \"\";\n if (String(current) !== String(model) && !pendingSync) {\n pendingSync = true;\n const eventName = name === \"checked\" || name === \"selected\" ? \"change\" : \"input\";\n queueMicrotask(() => {\n pendingSync = false;\n element.dispatchEvent(new Event(eventName, { bubbles: true }));\n });\n }\n }\n } else if (resolved === null || resolved === undefined || resolved === false) {\n element.removeAttribute(name);\n } else {\n const serialized = url ? sanitizeUrl(String(resolved)) : String(resolved);\n element.setAttribute(name, serialized);\n }\n firstRun = false;\n };\n\n // C.7 T2: desenvolver el pack derivado a getter — el effect trackea las\n // deps dinámicamente (semántica idéntica al path genérico).\n if (isDerivedBinding(value)) value = value.get;\n if (value instanceof Signal) {\n // C.6 T1: binding directo — la primera escritura pasa por el mismo\n // path firstRun (el DOM es autoritativo para props interactivos).\n return _bindSignal(value, update);\n }\n if (typeof value === \"function\") {\n return effect(() => update((value as () => unknown)()));\n }\n update(value);\n return () => { };\n}\n\nfunction activateNode(\n range: MarkerRange,\n value: unknown,\n options: HydrateOptions,\n keyedItems?: KeyedMarkerRange[],\n arrayItems?: MarkerRange[],\n): (() => void) | undefined {\n // C.7 T2: desenvolver el pack derivado a getter — cae en el path de\n // function con tracking dinámico.\n if (isDerivedBinding(value)) value = value.get;\n // C.6 T1: el valor ES la señal — adoptar el text node SSR y suscribirlo\n // directo (sin effect ni getter). Si no hay text node, crearlo.\n if (value instanceof Signal) {\n let sigText = findTextNode(range);\n if (!sigText) {\n sigText = document.createTextNode(\"\");\n range.end.parentNode!.insertBefore(sigText, range.end);\n }\n const node = sigText;\n return _bindSignal(value, (v) => {\n node.nodeValue = v == null || v === false ? \"\" : String(v);\n });\n }\n\n if (typeof value !== \"function\") return hydrateNodeValue(range, value, options, keyedItems, arrayItems);\n\n let firstRun = true;\n let nestedCleanup: (() => void) | undefined;\n let textNode = findTextNode(range);\n let keyed: { state: Map<RepeatKey, KEntry>; prevOrder: RepeatKey[] } | null = null;\n const ctxSnapshot = _captureContextSnapshot();\n const keyedMount = createKeyedMount(ctxSnapshot);\n\n const warnDuplicate = (key: RepeatKey) => {\n console.warn(`[elur] repeat(): duplicate key \"${key}\". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`);\n };\n\n const dispose = effect(() => {\n const resolved = (value as () => unknown)();\n\n if (isKeyedList(resolved)) {\n if (firstRun && !keyed) {\n // First resolution is a keyed list: adopt the SSR markers when\n // present. Afterwards we converge with the current model, which\n // handles count/ordering drift without recreating surviving nodes.\n const adopted = adoptKeyedRange(resolved, keyedItems, options);\n keyed = { state: adopted.state, prevOrder: adopted.prevOrder };\n nestedCleanup = adopted.cleanup;\n reconcileKeyedList({\n zoneStart: range.start,\n anchor: range.end,\n state: keyed.state,\n prevOrder: keyed.prevOrder,\n list: resolved,\n mount: keyedMount,\n ctxSnapshot,\n onDuplicateKey: warnDuplicate,\n });\n textNode = null;\n firstRun = false;\n return;\n }\n if (!keyed) {\n // The binding became keyed after another value: the SSR markers\n // were already consumed (or never existed), so mount fresh.\n nestedCleanup?.();\n clearRange(range);\n keyed = { state: new Map(), prevOrder: [] };\n nestedCleanup = () => {\n for (const entry of keyed!.state.values()) entry.cleanup();\n };\n }\n reconcileKeyedList({\n zoneStart: range.start,\n anchor: range.end,\n state: keyed.state,\n prevOrder: keyed.prevOrder,\n list: resolved,\n mount: keyedMount,\n ctxSnapshot,\n onDuplicateKey: warnDuplicate,\n });\n textNode = null;\n firstRun = false;\n return;\n }\n\n // Non-keyed value: tear down any keyed zone first.\n if (keyed) {\n nestedCleanup?.();\n clearRange(range);\n keyed = null;\n nestedCleanup = undefined;\n }\n\n if (typeof resolved === \"string\" || typeof resolved === \"number\" || typeof resolved === \"bigint\") {\n if (!textNode) {\n textNode = document.createTextNode(String(resolved));\n range.end.parentNode!.insertBefore(textNode, range.end);\n } else if (textNode.nodeValue !== String(resolved)) {\n textNode.nodeValue = String(resolved);\n }\n } else if (firstRun) {\n nestedCleanup = hydrateNodeValue(range, resolved, options, keyedItems, arrayItems);\n } else {\n nestedCleanup?.();\n clearRange(range);\n nestedCleanup = mountNodeValue(range, resolved);\n textNode = findTextNode(range);\n }\n firstRun = false;\n });\n\n return () => {\n dispose();\n nestedCleanup?.();\n };\n}\n\nfunction hydrateNodeValue(\n range: MarkerRange,\n value: unknown,\n options: HydrateOptions,\n keyedItems?: KeyedMarkerRange[],\n arrayItems?: MarkerRange[],\n): (() => void) | undefined {\n if (isKeyedList(value)) {\n const ctxSnapshot = _captureContextSnapshot();\n const adopted = adoptKeyedRange(value, keyedItems, options);\n reconcileKeyedList({\n zoneStart: range.start,\n anchor: range.end,\n state: adopted.state,\n prevOrder: adopted.prevOrder,\n list: value,\n mount: createKeyedMount(ctxSnapshot),\n ctxSnapshot,\n onDuplicateKey: (key) => {\n console.warn(`[elur] repeat(): duplicate key \"${key}\". Keys must be unique; the previous entry leaks (orphaned nodes + live effects).`);\n },\n });\n return adopted.cleanup;\n }\n if (Array.isArray(value)) {\n const cleanups: Array<() => void> = [];\n const hasMarkers = arrayItems !== undefined && arrayItems.length > 0;\n for (let index = 0; index < value.length; index++) {\n const item = value[index];\n const itemBounds = arrayItems?.[index];\n if (hasMarkers && itemBounds) {\n // Hydrate each item within its own SSR-delimited range so\n // repeated marker indices across items never collide.\n const cleanup = hydrateNodeValue(itemBounds, item, options);\n if (cleanup) cleanups.push(cleanup);\n } else if (hasMarkers) {\n // Client item with no SSR slot: mount it fresh at the end.\n const cleanup = mountNodeValue(range, item);\n if (cleanup) cleanups.push(cleanup);\n } else {\n const cleanup = hydrateNodeValue(range, item, options);\n if (cleanup) cleanups.push(cleanup);\n }\n }\n return cleanups.length ? () => { for (let i = cleanups.length - 1; i >= 0; i--) cleanups[i](); } : undefined;\n }\n if (isElurTemplate(value)) {\n const descriptor = value[ELUR_TEMPLATE_DESCRIPTOR];\n if (!descriptor) throwMismatch(options, -1, \"descriptor\", \"Nested template has no hydration descriptor\");\n return hydrateDescriptor(descriptor!, range.start.parentNode as ParentNode, options, range);\n }\n if (isElurComponent(value)) {\n _pushComponentContext();\n let result: (() => void) | undefined;\n try {\n try {\n value.onInit?.();\n } catch (error) {\n if (value.onError) value.onError(error);\n else throw error;\n }\n const template = value.render();\n const descriptor = template[ELUR_TEMPLATE_DESCRIPTOR];\n if (!descriptor) throwMismatch(options, -1, \"descriptor\", \"Nested component has no hydration descriptor\");\n const cleanup = hydrateDescriptor(descriptor!, range.start.parentNode as ParentNode, options, range);\n const mountCleanup = value.onMount?.();\n result = () => {\n value.onUnmount?.();\n if (typeof mountCleanup === \"function\") mountCleanup();\n cleanup();\n };\n } finally {\n _popComponentContext();\n }\n return result;\n }\n if (value != null && typeof value === \"object\") {\n const protocol = (value as Record<PropertyKey, unknown>)[ELUR_RENDER_PROTOCOL] as\n | { hydrateDom?: (ctx: import(\"../template/types.js\").HydrationProtocolContext) => (() => void) | void }\n | undefined;\n if (protocol?.hydrateDom) {\n return protocol.hydrateDom({\n parent: range.start.parentNode!,\n bounds: range,\n context: options.context,\n render: (nested) => hydrateNodeValue(range, nested, options),\n }) ?? undefined;\n }\n }\n return undefined;\n}\n\nfunction adoptKeyedRange(\n list: import(\"../template/types.js\").KeyedList,\n keyedItems: KeyedMarkerRange[] | undefined,\n options: HydrateOptions,\n): { state: Map<RepeatKey, KEntry>; prevOrder: RepeatKey[]; cleanup: () => void } {\n const state = new Map<RepeatKey, KEntry>();\n const prevOrder: RepeatKey[] = [];\n\n if (!keyedItems || keyedItems.length === 0) {\n return { state, prevOrder, cleanup: () => { } };\n }\n\n const clientByKey = new Map<string, number>();\n for (let j = 0; j < list.items.length; j++) {\n const key = normalizeRepeatKey(list.keyFn(list.items[j], j), j);\n const serialized = serializeRepeatKey(key);\n if (clientByKey.has(serialized)) {\n console.warn(\n `[elur] repeat(): duplicate client key \"${key}\" during hydration. ` +\n \"Keys must be unique; entries after the first leak.\",\n );\n }\n clientByKey.set(serialized, j);\n }\n\n for (const marker of keyedItems) {\n const clientIndex = clientByKey.get(marker.serializedKey);\n if (clientIndex === undefined) {\n // SSR item not present in the client model → remove its DOM.\n removeKeyedMarker(marker);\n continue;\n }\n const item = list.items[clientIndex];\n const key = normalizeRepeatKey(list.keyFn(item, clientIndex), clientIndex);\n if (serializeRepeatKey(key) !== marker.serializedKey) {\n console.warn(\n `[elur] repeat(): hydration key mismatch at index ${clientIndex} ` +\n `(${deserializeRepeatKey(marker.serializedKey)} != ${key}). The SSR item is adopted by position.`,\n );\n }\n if (state.has(key)) {\n console.warn(`[elur] repeat(): duplicate key \"${key}\" during hydration; removing duplicate SSR node.`);\n removeKeyedMarker(marker);\n continue;\n }\n const rendered = list.renderFn(item, clientIndex);\n // next/: bindings del item bajo su propio owner — sobreviven a\n // re-evals del effect de la lista y mueren con entry.cleanup().\n let inner: (() => void) | undefined;\n const disposeOwner = createRoot((dispose) => {\n inner = hydrateNodeValue(\n { start: marker.start, end: marker.end },\n rendered,\n options,\n );\n return dispose;\n });\n const cleanup = () => { inner?.(); disposeOwner(); };\n // C.16.1: guardar el item — reconcileKeyedList lo usa para detectar\n // \"misma key, objeto nuevo\" y remontar. Sin él, el primer update\n // remontaría los nodos SSR adoptados (pérdida de identidad).\n state.set(key, { start: marker.start, end: marker.end, cleanup, item } as KEntry);\n prevOrder.push(key);\n }\n\n return {\n state,\n prevOrder,\n cleanup: () => {\n for (const entry of state.values()) entry.cleanup();\n },\n };\n}\n\nfunction removeKeyedMarker(marker: KeyedMarkerRange): void {\n let node: Node | null = marker.start.nextSibling;\n while (node && node !== marker.end) {\n const next = node.nextSibling;\n node.parentNode?.removeChild(node);\n node = next;\n }\n marker.start.parentNode?.removeChild(marker.start);\n marker.end.parentNode?.removeChild(marker.end);\n}\n\nfunction mountNodeValue(range: MarkerRange, value: unknown): (() => void) | undefined {\n if (value === null || value === undefined || value === false || value === true) return undefined;\n if (Array.isArray(value)) {\n const cleanups: Array<() => void> = [];\n for (const item of value) {\n const cleanup = mountNodeValue(range, item);\n if (cleanup) cleanups.push(cleanup);\n }\n return cleanups.length ? () => { for (let i = cleanups.length - 1; i >= 0; i--) cleanups[i](); } : undefined;\n }\n if (isElurTemplate(value)) return value._render(range.end.parentNode!, range.end);\n if (isElurComponent(value)) return value.render()._render(range.end.parentNode!, range.end);\n const node = document.createTextNode(String(value));\n range.end.parentNode!.insertBefore(node, range.end);\n return () => node.parentNode?.removeChild(node);\n}\n\nfunction findTextNode(range: MarkerRange): Text | null {\n let node = range.start.nextSibling;\n while (node && node !== range.end) {\n if (node.nodeType === Node.TEXT_NODE) return node as Text;\n node = node.nextSibling;\n }\n return null;\n}\n\nfunction clearRange(range: MarkerRange): void {\n let node = range.start.nextSibling;\n while (node && node !== range.end) {\n const next = node.nextSibling;\n node.parentNode?.removeChild(node);\n node = next;\n }\n}\n\nfunction throwMismatch(\n options: HydrateOptions,\n index: number,\n kind: HydrationMismatch[\"kind\"],\n message: string,\n): never {\n const mismatch = { index, kind, message } satisfies HydrationMismatch;\n options.onMismatch?.(mismatch);\n const error = new Error(`[elur] Hydration marker mismatch: ${message}`);\n Object.assign(error, { mismatch });\n throw error;\n}"],"mappings":";;;;;;;;;;;AA8DA,SAAgB,EACZ,GACA,GACA,IAA0B,EAAE,EACb;AACf,KAAI;AAGA,MAAI,EAAsB,EAAM,EAAE;GAC9B,IAAM,IAAO,IAAI,EAAkB,EAAM;AAiB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AAE,QAAO,EAAM,QAAQ,EAAM,IAAI,YAAa,EAAM,IAAI;AACjF,KAAI,EAAgB,EAAM,CAAE,QAAO,EAAM,QAAQ,CAAC,QAAQ,EAAM,IAAI,YAAa,EAAM,IAAI;CAC3F,IAAM,IAAO,SAAS,eAAe,OAAO,EAAM,CAAC;AAEnD,QADA,EAAM,IAAI,WAAY,aAAa,GAAM,EAAM,IAAI,QACtC,EAAK,YAAY,YAAY,EAAK;;AAGnD,SAAS,EAAa,GAAiC;CACnD,IAAI,IAAO,EAAM,MAAM;AACvB,QAAO,KAAQ,MAAS,EAAM,MAAK;AAC/B,MAAI,EAAK,aAAa,KAAK,UAAW,QAAO;AAC7C,MAAO,EAAK;;AAEhB,QAAO;;AAGX,SAAS,EAAW,GAA0B;CAC1C,IAAI,IAAO,EAAM,MAAM;AACvB,QAAO,KAAQ,MAAS,EAAM,MAAK;EAC/B,IAAM,IAAO,EAAK;AAElB,EADA,EAAK,YAAY,YAAY,EAAK,EAClC,IAAO;;;AAIf,SAAS,EACL,GACA,GACA,GACA,GACK;CACL,IAAM,IAAW;EAAE;EAAO;EAAM;EAAS;AACzC,GAAQ,aAAa,EAAS;CAC9B,IAAM,IAAQ,gBAAI,MAAM,qCAAqC,IAAU;AAEvE,OADA,OAAO,OAAO,GAAO,EAAE,aAAU,CAAC,EAC5B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./reactivity.cjs`),t=require(`../template/types.cjs`),n=require(`../../lifecycle.cjs`),r=require(`./component.cjs`),i=require(`./mount-helpers.cjs`),a=require(`../template/keyed.cjs`);function o(a){return(o,s,c)=>{let l,u=e.createRoot(e=>{if(n.isElurComponent(o))l=i._mountComponentWithCtx(o,s,c,a);else if(r.isComponentInvocation(o)){let e=new r.ComponentInstance(o);e.mount(s,c,{ctxSnapshot:a}),l=()=>e.unmount()}else if(t.isElurTemplate(o))l=o._render(s,c);else if(o!=null&&o!==!1){let e=document.createTextNode(String(o));s.insertBefore(e,c),l=()=>e.parentNode?.removeChild(e)}return e});return()=>{l?.(),u()}}}function s(e,t,n){let r=document.createTextNode(``),i=document.createTextNode(``);t.appendChild(r),t.appendChild(i);let a=n(e,t,i),o=r.nextSibling;return o!==null&&o!==i&&o===i.previousSibling?(t.removeChild(r),t.removeChild(i),{start:o,end:o,cleanup:a}):{start:r,end:i,cleanup:a}}var c=typeof Element<`u`&&`moveBefore`in Element.prototype?(e,t,n)=>e.moveBefore(t,n):(e,t,n)=>e.insertBefore(t,n);function l(t){let{zoneStart:n,anchor:r,prevOrder:i,list:o,mount:l}=t,u=t.state,d=o.live===!0,f=t=>{let n=o.items[t];if(!d)return{rendered:o.renderFn(n,t)};let r=e.signal(n),i=e.signal(t);return{rendered:o.renderItem(()=>r.value,()=>i.value),itemSig:r,indexSig:i}},p=r.parentNode;if(!p)return;let m=(e,t,n)=>{let r=u.get(e);r.cleanup();let i=r.start;for(;i;){let e=i===r.end?null:i.nextSibling;if(i.parentNode?.removeChild(i),!e)break;i=e}let a=document.createDocumentFragment(),{rendered:c}=f(t),d=s(c,a,l);u.set(e,{...d,item:o.items[t]}),p.insertBefore(a,n)},h=(e,t)=>{let n=u.get(e);n&&!n.itemSig&&!a._keyedItemsEqual(n.item,o.items[t])&&m(e,t,n.end.nextSibling)},g=o.items.map((e,t)=>o.keyFn(e,t)),_=new Set(g),v=!1;if(u.size>0){for(let e of u.keys())if(_.has(e)){v=!0;break}}if(!v){if(u.size>0){let e=n.nextSibling;for(;e&&e!==r;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}for(let e of u.values())e.cleanup();u.clear()}if(g.length>0){let n=document.createDocumentFragment();e.batch(()=>{for(let e=0;e<g.length;e++){let r=g[e],i=o.items[e],{rendered:a,itemSig:c,indexSig:d}=f(e),p=s(a,n,l);u.has(r)&&t.onDuplicateKey?.(r),u.set(r,{...p,item:i,itemSig:c,indexSig:d})}}),p.insertBefore(n,r)}i.length=0,i.push(...g);return}let y=(t,n)=>{let r=u.get(t);if(r?.itemSig){let t=o.items[n],i=a._keyedItemsEqual(r.item,t);r.item=t,(!i||r.indexSig.peek()!==n)&&e.batch(()=>{r.itemSig.value=t,r.indexSig.value=n})}};{let n=0,a=Math.min(i.length,g.length);for(;n<a&&i[n]===g[n];)n++;let c=i.length-1,d=g.length-1;for(;c>=n&&d>=n&&i[c]===g[d];)c--,d--;if(n>c||n>d){for(let e=0;e<n;e++)y(g[e],e);for(let e=d+1;e<g.length;e++)y(g[e],e);for(let e=0;e<n;e++)h(g[e],e);for(let e=d+1;e<g.length;e++)h(g[e],e);if(n<=c)for(let e=n;e<=c;e++){let t=i[e],n=u.get(t);n.cleanup();let r=n.start;for(;r;){let e=r===n.end?null:r.nextSibling;if(r.parentNode?.removeChild(r),!e)break;r=e}u.delete(t)}if(n<=d){let a=n<i.length?u.get(i[n]).start:r,c=document.createDocumentFragment();e.batch(()=>{for(let e=n;e<=d;e++){let n=g[e],{rendered:r,itemSig:i,indexSig:a}=f(e),d=s(r,c,l);u.has(n)&&t.onDuplicateKey?.(n),u.set(n,{...d,item:o.items[e],itemSig:i,indexSig:a})}}),p.insertBefore(c,a)}i.length=0,i.push(...g);return}}let b=new Map;for(let e=0;e<g.length;e++)b.set(g[e],e);let x=new Int32Array(g.length),S=!1,C=0;for(let e=0;e<i.length;e++){let t=i[e],n=b.get(t);if(n===void 0){let e=u.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}u.delete(t)}else x[n]=e+1,n>=C?C=n:S=!0}let w=S?a.getSequence(x):[],T=w.length-1,E=r;for(let n=g.length-1;n>=0;n--){let r=g[n];if(x[n]===0){let e=o.items[n],i=document.createDocumentFragment(),{rendered:a,itemSig:c,indexSig:d}=f(n),m=s(a,i,l);u.has(r)&&t.onDuplicateKey?.(r),u.set(r,{...m,item:e,itemSig:c,indexSig:d}),p.insertBefore(i,E),E=m.start}else{let t=u.get(r);if(t.itemSig){let r=o.items[n],i=a._keyedItemsEqual(t.item,r);t.item=r,(!i||t.indexSig.peek()!==n)&&e.batch(()=>{t.itemSig.value=r,t.indexSig.value=n})}else if(!a._keyedItemsEqual(t.item,o.items[n])){m(r,n,E),t=u.get(r),S&&T>=0&&n===w[T]&&T--,E=t.start;continue}if(S)if(T<0||n!==w[T]){let e=t.start;for(;e;){let n=e===t.end?null:e.nextSibling;if(c(p,e,E),!n)break;e=n}}else T--;E=t.start}}i.length=0,i.push(...g)}exports.createKeyedMount=o,exports.reconcileKeyedList=l;
|
|
2
|
+
//# sourceMappingURL=keyed-diff.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyed-diff.cjs","names":[],"sources":["../../../../src/elur/next-2/keyed-diff.ts"],"sourcesContent":["import { batch, createRoot, signal, type Signal } from \"./reactivity.js\";\nimport { isElurComponent } from \"../lifecycle.js\";\nimport { ComponentInstance, isComponentInvocation } from \"./component.js\";\nimport { _mountComponentWithCtx } from \"../template/mount-helpers.js\";\nimport { isElurTemplate, type KEntry, type KeyedList } from \"../template/types.js\";\nimport { getSequence, _keyedItemsEqual, type RepeatKey } from \"../template/keyed.js\";\nimport { _captureContextSnapshot } from \"../context.js\";\n\n// =============================================================================\n// --- next/ — keyed list reconciliation con ownership por item ---\n// Fork de ../template/keyed-diff.ts: igual que el actual, pero cada item monta\n// bajo su propio root owner (createRoot del grafo next). Sus effects internos\n// pertenecen al item y no al effect del repeat — así sobreviven a re-orders\n// y se destruyen con entry.cleanup() al removerse (A.11/B.10 del plan).\n// =============================================================================\n\n/**\n * C.16.1: lista keyed \"live\" — renderItem recibe accessors (`getItem`,\n * `getIndex`) en vez del item capturado. Misma key + objeto nuevo → las\n * señales del item se actualizan y los bindings re-corren sin remount,\n * preservando identidad de DOM y estado del item.\n */\nexport interface LiveKeyedList<T = unknown> {\n readonly __isKeyedList: true;\n readonly live: true;\n readonly items: T[];\n readonly keyFn: (item: T, index: number) => string | number;\n readonly renderItem: (getItem: () => T, getIndex: () => number) => unknown;\n}\n\nexport function repeatLive<T>(\n items: T[],\n keyFn: (item: T, index: number) => string | number,\n renderItem: (getItem: () => T, getIndex: () => number) => unknown,\n): LiveKeyedList<T> {\n return { __isKeyedList: true as const, live: true as const, items, keyFn, renderItem };\n}\n\n/**\n * Mounts a single keyed item's rendered value before `endMarker` inside `parent`.\n * Used by the DOM renderer and the hydration renderer so both engines share the\n * exact same reconciliation semantics.\n */\nexport function createKeyedMount(\n ctxSnapshot: Map<unknown, unknown>[],\n): (rendered: unknown, parent: Node, endMarker: Node) => () => void {\n return (rendered: unknown, parent: Node, endMarker: Node): (() => void) => {\n let inner: (() => void) | void;\n const disposeOwner = createRoot((dispose) => {\n if (isElurComponent(rendered)) {\n inner = _mountComponentWithCtx(rendered, parent, endMarker, ctxSnapshot);\n } else if (isComponentInvocation(rendered)) {\n // Invocación funcional: montar por el kernel — setup una vez,\n // owner propio dentro del root del item.\n const inst = new ComponentInstance(rendered);\n inst.mount(parent, endMarker, { ctxSnapshot });\n inner = () => inst.unmount();\n } else if (isElurTemplate(rendered)) {\n inner = rendered._render(parent, endMarker);\n } else if (rendered != null && rendered !== false) {\n const node = document.createTextNode(String(rendered));\n parent.insertBefore(node, endMarker);\n inner = () => node.parentNode?.removeChild(node);\n }\n return dispose;\n });\n return () => {\n inner?.();\n disposeOwner();\n };\n };\n}\n\n/**\n * Entry con contenido single-node: los markers start/end se eliminan y el\n * nodo mismo actúa como ambos bounds — 2 nodos menos por entry y menos\n * trabajo en remove/move/clear. Multi-nodo/vacío conserva los markers.\n */\nfunction createKeyedEntry(\n rendered: unknown,\n frag: DocumentFragment,\n mount: (rendered: unknown, parent: Node, endMarker: Node) => () => void,\n): { start: Comment; end: Comment; cleanup: () => void } {\n const start = document.createTextNode(\"\") as unknown as Comment;\n const end = document.createTextNode(\"\") as unknown as Comment;\n frag.appendChild(start);\n frag.appendChild(end);\n const cleanup = mount(rendered, frag, end);\n const first = start.nextSibling;\n if (first !== null && first !== end && first === end.previousSibling) {\n frag.removeChild(start);\n frag.removeChild(end);\n return { start: first as unknown as Comment, end: first as unknown as Comment, cleanup };\n }\n return { start, end, cleanup };\n}\n\n/**\n * `moveBefore` (Chrome 133+) mueve un nodo sin desconectarlo — preserva\n * iframes, focus y animaciones en reorders. Fallback a insertBefore.\n */\nconst moveNode: (parent: Node, node: Node, before: Node | null) => void =\n typeof Element !== \"undefined\" && \"moveBefore\" in Element.prototype\n ? (parent, node, before) => (parent as Element).moveBefore(node, before)\n : (parent, node, before) => parent.insertBefore(node, before);\n\n/**\n * C.16.1: entry con el item que la originó — detecta el caso\n * \"misma key, objeto nuevo\" (el renderFn capturó el item viejo).\n */\ninterface KeyedItemEntry extends KEntry {\n item: unknown;\n /** C.16.1 live: señal por item (sólo en repeatLive). */\n itemSig?: import(\"./reactivity.js\").Signal<unknown>;\n indexSig?: import(\"./reactivity.js\").Signal<number>;\n}\n\nexport interface KeyedDiffOptions {\n /** Node marking the start of the keyed zone. */\n zoneStart: Node;\n /** End boundary; new content is inserted before this node. */\n anchor: Node;\n /** Live map of key → entry (start/end markers + cleanup). */\n state: Map<RepeatKey, KEntry>;\n /** Key order from the previous reconciliation pass. */\n prevOrder: RepeatKey[];\n /** The current keyed list value (clásica o live). */\n list: KeyedList | LiveKeyedList;\n /** Mounts a freshly rendered item into the DOM. */\n mount: (rendered: unknown, parent: Node, endMarker: Node) => () => void;\n /** Context snapshot for component mounts inside the effect. */\n ctxSnapshot?: Map<unknown, unknown>[];\n /** Called when a duplicate key is encountered. */\n onDuplicateKey?: (key: RepeatKey) => void;\n}\n\n/**\n * Reconciles a keyed list between `zoneStart` and `anchor` using the same LIS\n * algorithm used by the DOM renderer. Total replacement (O(1)) when no key\n * survives; otherwise remove/insert/move with minimal DOM operations.\n */\nexport function reconcileKeyedList(opts: KeyedDiffOptions): void {\n const { zoneStart, anchor, prevOrder, list, mount } = opts;\n const state = opts.state as Map<RepeatKey, KeyedItemEntry>;\n const live = (list as LiveKeyedList).live === true;\n // Render del item i-ésimo: live → accessors + señales; clásico → valor.\n const renderItem = (i: number): { rendered: unknown; itemSig?: Signal<unknown>; indexSig?: Signal<number> } => {\n const item = list.items[i];\n if (!live) return { rendered: (list as KeyedList).renderFn(item as never, i) };\n const itemSig = signal<unknown>(item);\n const indexSig = signal<number>(i);\n const rendered = (list as LiveKeyedList).renderItem(\n () => itemSig.value as never,\n () => indexSig.value,\n );\n return { rendered, itemSig, indexSig };\n };\n const parent = anchor.parentNode;\n if (!parent) return;\n\n /**\n * C.16.4 (clásico): entry cuya key sobrevivió pero cuyo item fue\n * reemplazado por otro objeto → remount in-place (los bindings\n * capturaron el item viejo). Las live no pasan por aquí: sus\n * bindings leen itemSig y se actualizan por señal.\n */\n const remountItem = (key: RepeatKey, i: number, ref: Node | null): void => {\n const entry = state.get(key)!;\n entry.cleanup();\n let node: Node | null = entry.start;\n while (node) {\n const next: ChildNode | null = node === entry.end ? null : node.nextSibling;\n node.parentNode?.removeChild(node);\n if (!next) break;\n node = next;\n }\n const frag = document.createDocumentFragment();\n const { rendered } = renderItem(i);\n const ne = createKeyedEntry(rendered, frag, mount);\n state.set(key, { ...ne, item: list.items[i] });\n parent.insertBefore(frag, ref);\n };\n const remountIfReplaced = (key: RepeatKey, i: number): void => {\n const entry = state.get(key);\n if (entry && !entry.itemSig && !_keyedItemsEqual(entry.item, list.items[i])) {\n remountItem(key, i, entry.end.nextSibling);\n }\n };\n\n const newKeyOrder: RepeatKey[] = list.items.map((item, idx) => list.keyFn(item as never, idx));\n const newKeySet = new Set(newKeyOrder);\n\n let anyKeysSurvive = false;\n if (state.size > 0) {\n for (const k of state.keys()) {\n if (newKeySet.has(k)) {\n anyKeysSurvive = true;\n break;\n }\n }\n }\n\n // 1. Initial render or total replacement (O(1) path)\n if (!anyKeysSurvive) {\n if (state.size > 0) {\n // Sibling walk — Range.deleteContents es patológico en\n // happy-dom sobre zonas de miles de nodos.\n let node: Node | null = zoneStart.nextSibling;\n while (node && node !== anchor) {\n const next = node.nextSibling;\n node.parentNode?.removeChild(node);\n node = next;\n }\n for (const entry of state.values()) entry.cleanup();\n state.clear();\n }\n\n if (newKeyOrder.length > 0) {\n const frag = document.createDocumentFragment();\n batch(() => {\n for (let i = 0; i < newKeyOrder.length; i++) {\n const key = newKeyOrder[i];\n const item = list.items[i];\n const { rendered, itemSig, indexSig } = renderItem(i);\n const entry = createKeyedEntry(rendered, frag, mount);\n if (state.has(key)) opts.onDuplicateKey?.(key);\n state.set(key, { ...entry, item, itemSig, indexSig });\n }\n });\n parent.insertBefore(frag, anchor);\n }\n prevOrder.length = 0;\n prevOrder.push(...newKeyOrder);\n return;\n }\n\n // C.16.2: fast paths — prefix/suffix comunes sin Map/LIS. Si cubren el\n // diff completo (append, prepend, truncate, insert/remove en el medio)\n // terminamos aquí; si el medio tiene moves, cae al camino LIS completo.\n const updateLiveEntry = (key: RepeatKey, i: number) => {\n const e = state.get(key);\n if (e?.itemSig) {\n const it = list.items[i];\n const sameItem = _keyedItemsEqual(e.item, it);\n e.item = it;\n if (!sameItem || e.indexSig!.peek() !== i) {\n batch(() => {\n e.itemSig!.value = it;\n e.indexSig!.value = i;\n });\n }\n }\n };\n {\n let pi = 0;\n const minLen = Math.min(prevOrder.length, newKeyOrder.length);\n while (pi < minLen && prevOrder[pi] === newKeyOrder[pi]) pi++;\n let pj = prevOrder.length - 1;\n let nk = newKeyOrder.length - 1;\n while (pj >= pi && nk >= pi && prevOrder[pj] === newKeyOrder[nk]) {\n pj--;\n nk--;\n }\n if (pi > pj || pi > nk) {\n // Cubierto por prefix+suffix: el medio es sólo insertar o borrar.\n for (let m = 0; m < pi; m++) updateLiveEntry(newKeyOrder[m], m);\n for (let m = nk + 1; m < newKeyOrder.length; m++) {\n updateLiveEntry(newKeyOrder[m], m);\n }\n // C.16.4: mismos checks para listas clásicas (remount in-place).\n for (let m = 0; m < pi; m++) remountIfReplaced(newKeyOrder[m], m);\n for (let m = nk + 1; m < newKeyOrder.length; m++) {\n remountIfReplaced(newKeyOrder[m], m);\n }\n if (pi <= pj) {\n // Borrar prev[pi..pj]\n for (let m = pi; m <= pj; m++) {\n const key = prevOrder[m];\n const entry = state.get(key)!;\n entry.cleanup();\n let node: Node | null = entry.start;\n while (node) {\n const next: ChildNode | null = node === entry.end ? null : node.nextSibling;\n node.parentNode?.removeChild(node);\n if (!next) break;\n node = next;\n }\n state.delete(key);\n }\n }\n if (pi <= nk) {\n // Insertar new[pi..nk] antes del primer item del suffix\n // (prevOrder[pi] sobrevivió — si no hay suffix, anchor).\n const refNode = pi < prevOrder.length\n ? state.get(prevOrder[pi])!.start\n : anchor;\n const frag = document.createDocumentFragment();\n batch(() => {\n for (let m = pi; m <= nk; m++) {\n const key = newKeyOrder[m];\n const { rendered, itemSig, indexSig } = renderItem(m);\n const entry = createKeyedEntry(rendered, frag, mount);\n if (state.has(key)) opts.onDuplicateKey?.(key);\n state.set(key, { ...entry, item: list.items[m], itemSig, indexSig });\n }\n });\n parent.insertBefore(frag, refNode);\n }\n prevOrder.length = 0;\n prevOrder.push(...newKeyOrder);\n return;\n }\n }\n\n // 2. Reconciliation with LIS\n const keyToNewIndex = new Map<RepeatKey, number>();\n for (let i = 0; i < newKeyOrder.length; i++) {\n keyToNewIndex.set(newKeyOrder[i], i);\n }\n\n const newIndexToOldIndexMap = new Int32Array(newKeyOrder.length);\n let moved = false;\n let maxNewIndexSoFar = 0;\n\n for (let i = 0; i < prevOrder.length; i++) {\n const key = prevOrder[i];\n const newIndex = keyToNewIndex.get(key);\n\n if (newIndex === undefined) {\n const entry = state.get(key)!;\n entry.cleanup();\n let node: Node | null = entry.start;\n while (node) {\n const next: ChildNode | null = node === entry.end ? null : node.nextSibling;\n node.parentNode?.removeChild(node);\n if (!next) break;\n node = next;\n }\n state.delete(key);\n } else {\n newIndexToOldIndexMap[newIndex] = i + 1;\n if (newIndex >= maxNewIndexSoFar) {\n maxNewIndexSoFar = newIndex;\n } else {\n moved = true;\n }\n }\n }\n\n const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : [];\n let j = increasingNewIndexSequence.length - 1;\n let insertionPoint: Node = anchor;\n\n for (let i = newKeyOrder.length - 1; i >= 0; i--) {\n const key = newKeyOrder[i];\n const isNew = newIndexToOldIndexMap[i] === 0;\n\n if (isNew) {\n const it = list.items[i];\n const frag = document.createDocumentFragment();\n const { rendered, itemSig, indexSig } = renderItem(i);\n const entry = createKeyedEntry(rendered, frag, mount);\n if (state.has(key)) opts.onDuplicateKey?.(key);\n state.set(key, { ...entry, item: it, itemSig, indexSig });\n parent.insertBefore(frag, insertionPoint);\n insertionPoint = entry.start;\n } else {\n let entry = state.get(key)!;\n // C.16.1 (live): misma key + objeto nuevo → actualizar las\n // señales del item — bindings re-corren, DOM preservado.\n if (entry.itemSig) {\n const newItem = list.items[i];\n const sameItem = _keyedItemsEqual(entry.item, newItem);\n entry.item = newItem;\n if (!sameItem || entry.indexSig!.peek() !== i) {\n batch(() => {\n entry.itemSig!.value = newItem;\n entry.indexSig!.value = i;\n });\n }\n } else if (!_keyedItemsEqual(entry.item, list.items[i])) {\n // C.16.4 (clásico): mismo caso sin accessors → remount.\n // Insertar antes de insertionPoint equivale a su posición\n // final en el walk reverso; se conserva el bookkeeping LIS.\n remountItem(key, i, insertionPoint);\n entry = state.get(key)!;\n if (moved && j >= 0 && i === increasingNewIndexSequence[j]) j--;\n insertionPoint = entry.start;\n continue;\n }\n if (moved) {\n if (j < 0 || i !== increasingNewIndexSequence[j]) {\n let node: Node | null = entry.start;\n while (node) {\n const next: ChildNode | null = node === entry.end ? null : node.nextSibling;\n moveNode(parent, node, insertionPoint);\n if (!next) break;\n node = next;\n }\n } else {\n j--;\n }\n }\n insertionPoint = entry.start;\n }\n }\n\n prevOrder.length = 0;\n prevOrder.push(...newKeyOrder);\n}\n\n// =============================================================================\n// B.12.7 — liveList(): lista con mutación incremental (deltas, estilo DBSP)\n// =============================================================================\n\ninterface DeltaEntry<T> {\n key: RepeatKey;\n item: T;\n itemSig: Signal<T>;\n indexSig: Signal<number>;\n start: Node;\n end: Node;\n cleanup: () => void;\n}\n\n/**\n * B.12.7: lista keyed mutable — los mutadores aplican deltas directos al DOM\n * (insert/remove/set/move) sin re-correr la reconciliación. La renderFn recibe\n * accessors como `repeatLive` — set() actualiza la señal del item sin remount.\n *\n * ```ts\n * const list = liveList({ key: u => u.id, render: (getItem) => html`<li>${() => getItem().name}</li>` });\n * html`<ul>${list}</ul>` // monta la zona vacía\n * list.push({id:1,name:\"a\"}); // inserta sin diff\n * list.set(1, {id:1,name:\"b\"}); // actualiza in-place\n * list.remove(1);\n * ```\n */\nexport interface DeltaList<T, K = string | number> {\n readonly __isKeyedList: true;\n readonly delta: true;\n readonly items: readonly T[];\n readonly length: number;\n /** @internal — monta la zona (markers + entries) antes de `anchor`. */\n _mount(parent: Node, anchor: Node): void;\n push(item: T): number;\n insert(index: number, item: T): void;\n remove(key: K): boolean;\n set(key: K, item: T): boolean;\n move(key: K, toIndex: number): void;\n clear(): void;\n /** @internal — dispone todo el subárbol. */\n _dispose(): void;\n}\n\nexport function liveList<T, K extends string | number>(opts: {\n key: (item: T) => K;\n render: (getItem: () => T, getIndex: () => number) => unknown;\n}): DeltaList<T, K> {\n const entries: DeltaEntry<T>[] = [];\n const byKey = new Map<K, DeltaEntry<T>>();\n let parent: Node | null = null;\n let zoneEnd: Node | null = null;\n let mountFn: ((r: unknown, p: Node, e: Node) => () => void) | null = null;\n\n const api: DeltaList<T, K> = {\n __isKeyedList: true as const,\n delta: true as const,\n get items() { return entries.map((e) => e.item); },\n get length() { return entries.length; },\n\n _mount(p: Node, anchor: Node): void {\n if (parent) return; // ya montada — idempotente\n parent = p;\n zoneEnd = anchor;\n mountFn = createKeyedMount(_captureContextSnapshot());\n },\n\n push(item: T): number {\n api.insert(entries.length, item);\n return entries.length - 1;\n },\n\n insert(index: number, item: T): void {\n if (!parent || !zoneEnd || !mountFn) {\n throw new Error(\"[elur-next2] liveList: la lista no está montada (úsala en un binding primero).\");\n }\n const key = opts.key(item);\n if (byKey.has(key)) {\n console.warn(`[elur] liveList: duplicate key \"${key}\".`);\n return;\n }\n index = Math.max(0, Math.min(index, entries.length));\n const sMarker = document.createTextNode(\"\");\n const eMarker = document.createTextNode(\"\");\n const ref = index < entries.length ? entries[index].start : zoneEnd;\n parent.insertBefore(sMarker, ref);\n parent.insertBefore(eMarker, ref);\n const itemSig = signal(item);\n const indexSig = signal(index);\n const rendered = opts.render(() => itemSig.value, () => indexSig.value);\n const cleanup = mountFn(rendered, parent, eMarker);\n const entry: DeltaEntry<T> = { key, item, itemSig, indexSig, start: sMarker, end: eMarker, cleanup };\n entries.splice(index, 0, entry);\n byKey.set(key, entry);\n // Deltas de índice para los desplazados.\n for (let i = index + 1; i < entries.length; i++) entries[i].indexSig.value = i;\n },\n\n remove(key: K): boolean {\n const entry = byKey.get(key);\n if (!entry || !parent) return false;\n const i = entries.indexOf(entry);\n entry.cleanup();\n let node: Node | null = entry.start;\n while (node) {\n const next: ChildNode | null = node === entry.end ? null : node.nextSibling;\n parent.removeChild(node);\n if (!next) break;\n node = next;\n }\n entries.splice(i, 1);\n byKey.delete(key);\n for (let j = i; j < entries.length; j++) entries[j].indexSig.value = j;\n return true;\n },\n\n set(key: K, item: T): boolean {\n const entry = byKey.get(key);\n if (!entry) return false;\n entry.item = item;\n entry.itemSig.value = item;\n return true;\n },\n\n move(key: K, toIndex: number): void {\n const entry = byKey.get(key);\n if (!entry || !parent) return;\n const from = entries.indexOf(entry);\n toIndex = Math.max(0, Math.min(toIndex, entries.length - 1));\n if (from === toIndex) return;\n const ref = toIndex > from ? entries[toIndex].end.nextSibling : entries[toIndex].start;\n let node: Node | null = entry.start;\n while (node) {\n const next: ChildNode | null = node === entry.end ? null : node.nextSibling;\n moveNode(parent, node, ref);\n if (!next) break;\n node = next;\n }\n entries.splice(from, 1);\n entries.splice(toIndex, 0, entry);\n const lo = Math.min(from, toIndex), hi = Math.max(from, toIndex);\n for (let i = lo; i <= hi; i++) entries[i].indexSig.value = i;\n },\n\n clear(): void {\n // Bulk: las entries son contiguas en el DOM entre\n // entries[0].start y zoneEnd — sibling walk por nodos (O(n);\n // Range.deleteContents es patológico en happy-dom y el walk\n // evita indexOf+splice+deltas por fila = O(n²)).\n if (parent && zoneEnd && entries.length > 0) {\n let node: Node | null = entries[0].start;\n while (node && node !== zoneEnd) {\n const nextNode: Node | null = node.nextSibling;\n node.parentNode?.removeChild(node);\n node = nextNode;\n }\n }\n for (const e of entries) e.cleanup();\n entries.length = 0;\n byKey.clear();\n },\n\n _dispose(): void {\n api.clear();\n parent = null;\n zoneEnd = null;\n },\n };\n return api;\n}\n"],"mappings":"yMA2CA,SAAgB,EACZ,EACgE,CAChE,OAAQ,EAAmB,EAAc,IAAkC,CACvE,IAAI,EACE,EAAe,EAAA,WAAY,GAAY,CACzC,GAAI,EAAA,gBAAgB,EAAS,CACzB,EAAQ,EAAA,uBAAuB,EAAU,EAAQ,EAAW,EAAY,SACjE,EAAA,sBAAsB,EAAS,CAAE,CAGxC,IAAM,EAAO,IAAI,EAAA,kBAAkB,EAAS,CAC5C,EAAK,MAAM,EAAQ,EAAW,CAAE,cAAa,CAAC,CAC9C,MAAc,EAAK,SAAS,SACrB,EAAA,eAAe,EAAS,CAC/B,EAAQ,EAAS,QAAQ,EAAQ,EAAU,SACpC,GAAY,MAAQ,IAAa,GAAO,CAC/C,IAAM,EAAO,SAAS,eAAe,OAAO,EAAS,CAAC,CACtD,EAAO,aAAa,EAAM,EAAU,CACpC,MAAc,EAAK,YAAY,YAAY,EAAK,CAEpD,OAAO,GACT,CACF,UAAa,CACT,KAAS,CACT,GAAc,GAU1B,SAAS,EACL,EACA,EACA,EACqD,CACrD,IAAM,EAAQ,SAAS,eAAe,GAAG,CACnC,EAAM,SAAS,eAAe,GAAG,CACvC,EAAK,YAAY,EAAM,CACvB,EAAK,YAAY,EAAI,CACrB,IAAM,EAAU,EAAM,EAAU,EAAM,EAAI,CACpC,EAAQ,EAAM,YAMpB,OALI,IAAU,M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