@jasonshimmy/custom-elements-runtime 3.1.3 → 3.2.1
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/{css-utils-Cg4o1MqY.js → css-utils-CC43BbEy.js} +20 -21
- package/dist/css-utils-CC43BbEy.js.map +1 -0
- package/dist/{css-utils-RqkyBWft.cjs → css-utils-mgjmH8qX.cjs} +5 -4
- package/dist/css-utils-mgjmH8qX.cjs.map +1 -0
- package/dist/custom-elements-runtime.cjs.js +4 -3
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.colors.cjs.js +3 -2
- package/dist/custom-elements-runtime.colors.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.colors.es.js +3 -2
- package/dist/custom-elements-runtime.colors.es.js.map +1 -1
- package/dist/custom-elements-runtime.directive-enhancements.cjs.js +3 -2
- package/dist/custom-elements-runtime.directive-enhancements.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.directive-enhancements.es.js +86 -100
- package/dist/custom-elements-runtime.directive-enhancements.es.js.map +1 -1
- package/dist/custom-elements-runtime.directives.cjs.js +3 -2
- package/dist/custom-elements-runtime.directives.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.directives.es.js +40 -43
- package/dist/custom-elements-runtime.directives.es.js.map +1 -1
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js +7 -6
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.dom-jit-css.es.js +58 -76
- package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -1
- package/dist/custom-elements-runtime.es.js +162 -186
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js +3 -2
- package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.es.js +48 -103
- package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
- package/dist/custom-elements-runtime.jit-css.cjs.js +3 -2
- package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.jit-css.es.js +29 -30
- package/dist/custom-elements-runtime.jit-css.es.js.map +1 -1
- package/dist/custom-elements-runtime.router.cjs.js +19 -18
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.router.es.js +554 -571
- package/dist/custom-elements-runtime.router.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js +5 -2
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.es.js +54 -45
- package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr.cjs.js +1 -4
- package/dist/custom-elements-runtime.ssr.es.js +11 -175
- package/dist/custom-elements-runtime.store.cjs.js +3 -2
- package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.store.es.js +17 -11
- package/dist/custom-elements-runtime.store.es.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.cjs.js +3 -2
- package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.es.js +55 -120
- package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
- package/dist/custom-elements-runtime.vite-plugin.cjs.js +3 -2
- package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.vite-plugin.es.js +54 -75
- package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -1
- package/dist/hooks-_3xP4G2N.js +1189 -0
- package/dist/hooks-_3xP4G2N.js.map +1 -0
- package/dist/hooks-fYQgZk2g.cjs +7 -0
- package/dist/hooks-fYQgZk2g.cjs.map +1 -0
- package/dist/logger-BYIN7ysT.cjs +3 -0
- package/dist/logger-BYIN7ysT.cjs.map +1 -0
- package/dist/logger-L25axmB-.js +41 -0
- package/dist/logger-L25axmB-.js.map +1 -0
- package/dist/namespace-helpers-Bf7rm9JV.cjs +3 -0
- package/dist/namespace-helpers-Bf7rm9JV.cjs.map +1 -0
- package/dist/namespace-helpers-BucDdgz_.js +61 -0
- package/dist/namespace-helpers-BucDdgz_.js.map +1 -0
- package/dist/reset.css +1 -1
- package/dist/runtime/ssr-context.d.ts +1 -13
- package/dist/runtime/vdom-ssr-dsd.d.ts +14 -0
- package/dist/ssr-B3lxl1vr.js +165 -0
- package/dist/ssr-B3lxl1vr.js.map +1 -0
- package/dist/ssr-DtD9e5iA.cjs +5 -0
- package/dist/ssr-DtD9e5iA.cjs.map +1 -0
- package/dist/ssr-middleware.d.ts +18 -2
- package/dist/ssr.d.ts +3 -4
- package/dist/style-Bjn8zDiZ.cjs +56 -0
- package/dist/style-Bjn8zDiZ.cjs.map +1 -0
- package/dist/{style-BmyOIMcU.js → style-DuDoj_xK.js} +724 -876
- package/dist/style-DuDoj_xK.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/template-compiler-BB4JJdqk.cjs +23 -0
- package/dist/template-compiler-BB4JJdqk.cjs.map +1 -0
- package/dist/template-compiler-Cs5axmn4.js +3236 -0
- package/dist/template-compiler-Cs5axmn4.js.map +1 -0
- package/dist/variables.css +1 -1
- package/package.json +7 -7
- package/dist/css-utils-Cg4o1MqY.js.map +0 -1
- package/dist/css-utils-RqkyBWft.cjs.map +0 -1
- package/dist/custom-elements-runtime.ssr.cjs.js.map +0 -1
- package/dist/custom-elements-runtime.ssr.es.js.map +0 -1
- package/dist/hooks-x8M4knLc.cjs +0 -6
- package/dist/hooks-x8M4knLc.cjs.map +0 -1
- package/dist/hooks-xWZhQHco.js +0 -1465
- package/dist/hooks-xWZhQHco.js.map +0 -1
- package/dist/logger-BvkEbVM4.js +0 -48
- package/dist/logger-BvkEbVM4.js.map +0 -1
- package/dist/logger-CSALKaYm.cjs +0 -2
- package/dist/logger-CSALKaYm.cjs.map +0 -1
- package/dist/namespace-helpers-D4wC2-qA.js +0 -61
- package/dist/namespace-helpers-D4wC2-qA.js.map +0 -1
- package/dist/namespace-helpers-ckeEOxpR.cjs +0 -2
- package/dist/namespace-helpers-ckeEOxpR.cjs.map +0 -1
- package/dist/style-BmyOIMcU.js.map +0 -1
- package/dist/style-D40DsIqJ.cjs +0 -55
- package/dist/style-D40DsIqJ.cjs.map +0 -1
- package/dist/template-compiler-CTUhEHr8.cjs +0 -22
- package/dist/template-compiler-CTUhEHr8.cjs.map +0 -1
- package/dist/template-compiler-ZhSg1yPh.js +0 -3724
- package/dist/template-compiler-ZhSg1yPh.js.map +0 -1
|
@@ -1,142 +1,120 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
new CustomEvent("cer:hydrate", { bubbles: !0, composed: !0 })
|
|
11
|
-
);
|
|
1
|
+
import { i as G, n as J, r as b, t as m } from "./logger-L25axmB-.js";
|
|
2
|
+
import { B as T, H as W, I as Y, J as Z, L as X, R as F, U as Q, V as f, Y as ee, Z as te, _ as k, a as ne, d as A, f as re, g as I, h as oe, i as D, l as se, m as ie, n as ae, o as U, p as ce, r as le, s as ue, u as de, v as he, w as me, y as fe, z as pe } from "./hooks-_3xP4G2N.js";
|
|
3
|
+
import { n as g, r as p, t as l } from "./template-compiler-Cs5axmn4.js";
|
|
4
|
+
import { o as ve } from "./css-utils-CC43BbEy.js";
|
|
5
|
+
function Ce(e = document) {
|
|
6
|
+
typeof CustomEvent > "u" || (e instanceof Document ? e.documentElement : e).dispatchEvent(new CustomEvent("cer:hydrate", {
|
|
7
|
+
bubbles: !0,
|
|
8
|
+
composed: !0
|
|
9
|
+
}));
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
function z(e, t,
|
|
15
|
-
return
|
|
11
|
+
var x = 100, O = 3e4;
|
|
12
|
+
function z(e, t, r) {
|
|
13
|
+
return r === "jitCacheHitRate" ? e < t * 0.5 ? "critical" : e < t ? "warning" : "healthy" : e > t * 2 ? "critical" : e > t ? "warning" : "healthy";
|
|
16
14
|
}
|
|
17
15
|
function K(e) {
|
|
18
16
|
const t = [];
|
|
19
|
-
return e.memoryUsage?.status !== "healthy" && t.push(
|
|
20
|
-
"Consider reducing component complexity or implementing better memory cleanup"
|
|
21
|
-
), e.averageRenderTime?.status !== "healthy" && t.push(
|
|
22
|
-
"Optimize component render functions - consider lazy loading or virtualization"
|
|
23
|
-
), e.jitCacheHitRate?.status !== "healthy" && t.push(
|
|
24
|
-
"JIT CSS cache performance is poor - review CSS patterns for optimization"
|
|
25
|
-
), e.componentErrorRate?.status !== "healthy" && t.push(
|
|
26
|
-
"High component error rate detected - review error handling and component logic"
|
|
27
|
-
), e.activeReactiveStates?.status !== "healthy" && t.push(
|
|
28
|
-
"High number of reactive states - consider state consolidation or cleanup"
|
|
29
|
-
), e.memoryLeakIndicator?.status !== "healthy" && t.push(
|
|
30
|
-
"Potential memory leak detected - review component cleanup and event listener management"
|
|
31
|
-
), t;
|
|
17
|
+
return e.memoryUsage?.status !== "healthy" && t.push("Consider reducing component complexity or implementing better memory cleanup"), e.averageRenderTime?.status !== "healthy" && t.push("Optimize component render functions - consider lazy loading or virtualization"), e.jitCacheHitRate?.status !== "healthy" && t.push("JIT CSS cache performance is poor - review CSS patterns for optimization"), e.componentErrorRate?.status !== "healthy" && t.push("High component error rate detected - review error handling and component logic"), e.activeReactiveStates?.status !== "healthy" && t.push("High number of reactive states - consider state consolidation or cleanup"), e.memoryLeakIndicator?.status !== "healthy" && t.push("Potential memory leak detected - review component cleanup and event listener management"), t;
|
|
32
18
|
}
|
|
33
|
-
function
|
|
19
|
+
function N() {
|
|
34
20
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
35
|
-
let
|
|
36
|
-
function n(
|
|
37
|
-
e.set(
|
|
38
|
-
name:
|
|
21
|
+
let r = null;
|
|
22
|
+
function n(o, s, i) {
|
|
23
|
+
e.set(o, {
|
|
24
|
+
name: o,
|
|
39
25
|
value: s,
|
|
40
|
-
threshold:
|
|
26
|
+
threshold: i,
|
|
41
27
|
status: "healthy",
|
|
42
28
|
lastUpdated: Date.now(),
|
|
43
29
|
history: []
|
|
44
30
|
});
|
|
45
31
|
}
|
|
46
|
-
function
|
|
32
|
+
function c() {
|
|
47
33
|
n("activeComponents", 0, 1e3), n("componentCreateRate", 0, 50), n("componentErrorRate", 0, 0.1), n("memoryUsage", 0, 50 * 1024 * 1024), n("memoryGrowthRate", 0, 1024 * 1024), n("averageRenderTime", 0, 16), n("slowRenderCount", 0, 10), n("jitCacheHitRate", 100, 80), n("activeReactiveStates", 0, 5e3), n("dependencyUpdates", 0, 100), n("memoryLeakIndicator", 0, 0.1);
|
|
48
34
|
}
|
|
49
|
-
function
|
|
50
|
-
const
|
|
51
|
-
|
|
35
|
+
function a(o, s) {
|
|
36
|
+
const i = e.get(o);
|
|
37
|
+
i && (i.value = s, i.lastUpdated = Date.now(), i.history.push(s), i.history.length > x && i.history.shift(), i.status = z(s, i.threshold, o));
|
|
52
38
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
39
|
+
function h() {
|
|
40
|
+
const o = {};
|
|
55
41
|
let s = "healthy";
|
|
56
|
-
for (const [
|
|
57
|
-
|
|
42
|
+
for (const [i, u] of e)
|
|
43
|
+
o[i] = { ...u }, u.status === "critical" ? s = "critical" : u.status === "warning" && s === "healthy" && (s = "warning");
|
|
58
44
|
return {
|
|
59
45
|
overall: s,
|
|
60
|
-
metrics:
|
|
46
|
+
metrics: o,
|
|
61
47
|
timestamp: Date.now(),
|
|
62
|
-
recommendations: K(
|
|
48
|
+
recommendations: K(o)
|
|
63
49
|
};
|
|
64
50
|
}
|
|
65
|
-
function
|
|
51
|
+
function C() {
|
|
66
52
|
if ("memory" in performance && performance.memory) {
|
|
67
|
-
const
|
|
68
|
-
|
|
53
|
+
const o = performance.memory;
|
|
54
|
+
a("memoryUsage", o.usedJSHeapSize);
|
|
69
55
|
const s = e.get("memoryUsage");
|
|
70
56
|
if (s && s.history.length > 1) {
|
|
71
|
-
const
|
|
72
|
-
|
|
57
|
+
const i = s.history[s.history.length - 2], u = s.history[s.history.length - 1];
|
|
58
|
+
a("memoryGrowthRate", Math.max(0, u - i));
|
|
73
59
|
}
|
|
74
60
|
}
|
|
75
61
|
}
|
|
76
|
-
function w(
|
|
77
|
-
for (const s of t)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
62
|
+
function w(o) {
|
|
63
|
+
for (const s of t) try {
|
|
64
|
+
s(o);
|
|
65
|
+
} catch (i) {
|
|
66
|
+
m("Error in health monitor listener:", i);
|
|
67
|
+
}
|
|
83
68
|
}
|
|
84
69
|
function E() {
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
w(
|
|
88
|
-
"🚨 Runtime Health: Critical issues detected",
|
|
89
|
-
r.recommendations
|
|
90
|
-
) : r.overall === "warning" && I(
|
|
91
|
-
"⚠️ Runtime Health: Performance warnings",
|
|
92
|
-
r.recommendations
|
|
93
|
-
);
|
|
70
|
+
C();
|
|
71
|
+
const o = h();
|
|
72
|
+
w(o), o.overall === "critical" ? m("🚨 Runtime Health: Critical issues detected", o.recommendations) : o.overall === "warning" && b("⚠️ Runtime Health: Performance warnings", o.recommendations);
|
|
94
73
|
}
|
|
95
74
|
function S() {
|
|
96
|
-
typeof window > "u" || (
|
|
75
|
+
typeof window > "u" || (r = setInterval(E, O));
|
|
97
76
|
}
|
|
98
77
|
function _() {
|
|
99
|
-
|
|
78
|
+
r !== null && (clearInterval(r), r = null);
|
|
100
79
|
}
|
|
101
|
-
function R(
|
|
102
|
-
t.add(
|
|
80
|
+
function R(o) {
|
|
81
|
+
t.add(o);
|
|
103
82
|
}
|
|
104
|
-
function H(
|
|
105
|
-
t.delete(
|
|
83
|
+
function H(o) {
|
|
84
|
+
t.delete(o);
|
|
106
85
|
}
|
|
107
|
-
function M(
|
|
108
|
-
const s = e.get(
|
|
86
|
+
function M(o) {
|
|
87
|
+
const s = e.get(o);
|
|
109
88
|
return s ? [...s.history] : [];
|
|
110
89
|
}
|
|
111
|
-
function
|
|
112
|
-
for (const
|
|
90
|
+
function L() {
|
|
91
|
+
for (const o of e.values()) o.history = [];
|
|
113
92
|
}
|
|
114
|
-
return
|
|
115
|
-
updateMetric:
|
|
116
|
-
getHealthReport:
|
|
93
|
+
return c(), S(), {
|
|
94
|
+
updateMetric: a,
|
|
95
|
+
getHealthReport: h,
|
|
117
96
|
addListener: R,
|
|
118
97
|
removeListener: H,
|
|
119
98
|
stop: _,
|
|
120
99
|
getMetricHistory: M,
|
|
121
|
-
clearHistory:
|
|
100
|
+
clearHistory: L
|
|
122
101
|
};
|
|
123
102
|
}
|
|
124
|
-
|
|
125
|
-
function
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
function V(e, t) {
|
|
129
|
-
C().updateMetric(e, t);
|
|
103
|
+
var d = null;
|
|
104
|
+
function v() {
|
|
105
|
+
return d || (d = N()), d;
|
|
130
106
|
}
|
|
131
|
-
function
|
|
132
|
-
|
|
107
|
+
function we(e, t) {
|
|
108
|
+
v().updateMetric(e, t);
|
|
133
109
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
110
|
+
function Ee() {
|
|
111
|
+
return v().getHealthReport();
|
|
136
112
|
}
|
|
137
113
|
function $() {
|
|
114
|
+
typeof window > "u" || typeof customElements > "u" || customElements.get("cer-keep-alive") || customElements.define("cer-keep-alive", j());
|
|
115
|
+
}
|
|
116
|
+
function j() {
|
|
138
117
|
return class extends HTMLElement {
|
|
139
|
-
/** Preserved component instances keyed by tag[:id]. */
|
|
140
118
|
_cache = /* @__PURE__ */ new Map();
|
|
141
119
|
_slot = null;
|
|
142
120
|
_slotListener = null;
|
|
@@ -146,51 +124,45 @@ function $() {
|
|
|
146
124
|
disconnectedCallback() {
|
|
147
125
|
this._slot && this._slotListener && this._slot.removeEventListener("slotchange", this._slotListener), this._slotListener = null;
|
|
148
126
|
}
|
|
149
|
-
/**
|
|
150
|
-
* Evict a cached element by its cache key (`tagName` or `tagName:id`).
|
|
151
|
-
* The evicted element is disconnected and removed from the cache.
|
|
152
|
-
*/
|
|
153
127
|
clearCache(t) {
|
|
154
128
|
t ? this._cache.delete(t) : this._cache.clear();
|
|
155
129
|
}
|
|
156
130
|
_handleSlotChange() {
|
|
157
131
|
if (!this._slot) return;
|
|
158
132
|
const t = this._slot.assignedElements({ flatten: !0 });
|
|
159
|
-
for (const
|
|
160
|
-
const n = this._buildCacheKey(
|
|
161
|
-
if (!this._cache.has(n))
|
|
162
|
-
this._cache.set(n, o);
|
|
133
|
+
for (const r of t) {
|
|
134
|
+
const n = this._buildCacheKey(r);
|
|
135
|
+
if (!this._cache.has(n)) this._cache.set(n, r);
|
|
163
136
|
else {
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
137
|
+
const c = this._cache.get(n);
|
|
138
|
+
if (c !== r) try {
|
|
139
|
+
r.parentNode?.replaceChild(c, r);
|
|
140
|
+
} catch {
|
|
141
|
+
this._cache.set(n, r);
|
|
142
|
+
}
|
|
171
143
|
}
|
|
172
144
|
}
|
|
173
145
|
}
|
|
174
146
|
_buildCacheKey(t) {
|
|
175
|
-
const
|
|
176
|
-
return n ? `${
|
|
147
|
+
const r = t.tagName.toLowerCase(), n = t.getAttribute("id");
|
|
148
|
+
return n ? `${r}:${n}` : r;
|
|
177
149
|
}
|
|
178
150
|
};
|
|
179
151
|
}
|
|
180
|
-
function
|
|
181
|
-
typeof customElements < "u" && customElements.get("cer-suspense") ||
|
|
152
|
+
function P() {
|
|
153
|
+
typeof customElements < "u" && customElements.get("cer-suspense") || g("cer-suspense", () => {
|
|
182
154
|
const { pending: e } = k({ pending: !1 });
|
|
183
155
|
return e ? l`<slot name="fallback"><span>Loading…</span></slot>` : l`<slot></slot>`;
|
|
184
156
|
});
|
|
185
157
|
}
|
|
186
|
-
function
|
|
187
|
-
typeof customElements < "u" && customElements.get("cer-error-boundary") ||
|
|
158
|
+
function q() {
|
|
159
|
+
typeof customElements < "u" && customElements.get("cer-error-boundary") || g("cer-error-boundary", () => {
|
|
188
160
|
const e = f(!1), t = f("");
|
|
189
|
-
return
|
|
190
|
-
e.value = !0, t.value =
|
|
191
|
-
}),
|
|
192
|
-
_cerHandleChildError: (
|
|
193
|
-
e.peek() || (e.value = !0, t.value =
|
|
161
|
+
return I((r) => {
|
|
162
|
+
e.value = !0, t.value = r.message;
|
|
163
|
+
}), A({
|
|
164
|
+
_cerHandleChildError: (r) => {
|
|
165
|
+
e.peek() || (e.value = !0, t.value = r instanceof Error ? r.message : String(r));
|
|
194
166
|
},
|
|
195
167
|
reset: () => {
|
|
196
168
|
e.value = !1, t.value = "";
|
|
@@ -203,46 +175,49 @@ function P() {
|
|
|
203
175
|
>` : l`<slot></slot>`;
|
|
204
176
|
});
|
|
205
177
|
}
|
|
206
|
-
function
|
|
207
|
-
|
|
178
|
+
function _e() {
|
|
179
|
+
P(), q(), $();
|
|
208
180
|
}
|
|
209
|
-
function
|
|
210
|
-
if (typeof document > "u")
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
181
|
+
function Re(e) {
|
|
182
|
+
if (typeof document > "u") return {
|
|
183
|
+
portal: () => {
|
|
184
|
+
},
|
|
185
|
+
destroy: () => {
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
if (U()) return {
|
|
189
|
+
portal: () => {
|
|
190
|
+
},
|
|
191
|
+
destroy: () => {
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
if (D()) {
|
|
195
|
+
const t = T.getOrCreateState(null), r = t.peek();
|
|
196
|
+
if (r !== null) return r;
|
|
197
|
+
const n = y(e, () => t.initSilent(null));
|
|
198
|
+
return t.initSilent(n), n;
|
|
224
199
|
}
|
|
225
|
-
return
|
|
200
|
+
return y(e);
|
|
226
201
|
}
|
|
227
|
-
function
|
|
228
|
-
const
|
|
229
|
-
if (!
|
|
230
|
-
return console.warn(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
202
|
+
function y(e, t) {
|
|
203
|
+
const r = typeof e == "string" ? document.querySelector(e) : e;
|
|
204
|
+
if (!r)
|
|
205
|
+
return console.warn(`[useTeleport] Target "${String(e)}" not found in the document. Teleported content will not be rendered.`), {
|
|
206
|
+
portal: () => {
|
|
207
|
+
},
|
|
208
|
+
destroy: () => {
|
|
209
|
+
}
|
|
210
|
+
};
|
|
235
211
|
const n = document.createElement("cer-teleport");
|
|
236
|
-
n.dataset.cerTeleport = "",
|
|
237
|
-
const
|
|
212
|
+
n.dataset.cerTeleport = "", r.appendChild(n);
|
|
213
|
+
const c = {};
|
|
238
214
|
return {
|
|
239
|
-
portal(
|
|
240
|
-
|
|
241
|
-
p(n, h, void 0, i);
|
|
215
|
+
portal(a) {
|
|
216
|
+
p(n, a == null ? [] : Array.isArray(a) ? a : [a], void 0, c);
|
|
242
217
|
},
|
|
243
218
|
destroy() {
|
|
244
219
|
try {
|
|
245
|
-
p(n, [], void 0,
|
|
220
|
+
p(n, [], void 0, c);
|
|
246
221
|
} catch {
|
|
247
222
|
}
|
|
248
223
|
n.parentNode && n.parentNode.removeChild(n), t?.();
|
|
@@ -250,47 +225,48 @@ function g(e, t) {
|
|
|
250
225
|
};
|
|
251
226
|
}
|
|
252
227
|
export {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
228
|
+
X as ReactiveState,
|
|
229
|
+
g as component,
|
|
230
|
+
F as computed,
|
|
231
|
+
ae as createComposable,
|
|
232
|
+
N as createHealthMonitor,
|
|
233
|
+
ve as css,
|
|
234
|
+
me as decodeEntities,
|
|
235
|
+
le as defineModel,
|
|
236
|
+
J as devLog,
|
|
237
|
+
Z as flushDOMUpdates,
|
|
238
|
+
D as getCurrentComponentContext,
|
|
239
|
+
v as getHealthMonitor,
|
|
240
|
+
Ee as getHealthStatus,
|
|
266
241
|
l as html,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
242
|
+
Ce as hydrateApp,
|
|
243
|
+
ne as inject,
|
|
244
|
+
pe as isReactiveState,
|
|
245
|
+
ee as nextTick,
|
|
271
246
|
ue as provide,
|
|
272
247
|
f as ref,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
248
|
+
_e as registerBuiltinComponents,
|
|
249
|
+
q as registerErrorBoundary,
|
|
250
|
+
$ as registerKeepAlive,
|
|
251
|
+
P as registerSuspense,
|
|
252
|
+
te as scheduleWithPriority,
|
|
253
|
+
G as setDevMode,
|
|
254
|
+
Y as unsafeHTML,
|
|
255
|
+
we as updateHealthMetric,
|
|
256
|
+
se as useDesignTokens,
|
|
257
|
+
de as useEmit,
|
|
258
|
+
A as useExpose,
|
|
259
|
+
re as useGlobalStyle,
|
|
260
|
+
ce as useOnAttributeChanged,
|
|
261
|
+
ie as useOnConnected,
|
|
262
|
+
oe as useOnDisconnected,
|
|
263
|
+
I as useOnError,
|
|
289
264
|
k as useProps,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
265
|
+
he as useSlots,
|
|
266
|
+
fe as useStyle,
|
|
267
|
+
Re as useTeleport,
|
|
268
|
+
W as watch,
|
|
269
|
+
Q as watchEffect
|
|
295
270
|
};
|
|
296
|
-
|
|
271
|
+
|
|
272
|
+
//# sourceMappingURL=custom-elements-runtime.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-elements-runtime.es.js","sources":["../src/lib/runtime/hydration.ts","../src/lib/runtime/monitoring/health-monitor.ts","../src/lib/keep-alive.ts","../src/lib/runtime/builtin-components.ts","../src/lib/teleport.ts"],"sourcesContent":["/**\n * Client-side hydration helpers.\n *\n * When the server renders with `dsd: true`, each custom element's shadow DOM\n * is already present in the HTML via a Declarative Shadow DOM template. The\n * browser parses that template and attaches the shadow root before any\n * JavaScript runs. When the JS bundle loads, the custom element constructors\n * detect the existing shadow root and skip the `attachShadow()` call, then\n * hydrate (attach reactivity to) the existing DOM on `connectedCallback`.\n *\n * `hydrateApp` is a signal/entry point for this process. In most cases custom\n * elements self-hydrate automatically on connection — this function is useful\n * when you need to explicitly trigger or defer the hydration of a subtree.\n */\n\n/**\n * Trigger hydration for all registered custom elements within `root`.\n *\n * In practice, custom elements self-hydrate as soon as their class definition\n * is registered and the element is connected to the DOM. Call `hydrateApp`\n * after importing and calling `component()` for all your components to signal\n * that the page is ready for reactive activation.\n *\n * @param root - The root element to hydrate. Defaults to `document`.\n *\n * @example\n * ```ts\n * import { component, hydrateApp } from '@jasonshimmy/custom-elements-runtime';\n * import './components'; // registers all components via component()\n *\n * hydrateApp(); // activate all DSD-rendered components on the page\n * ```\n */\nexport function hydrateApp(root: Element | Document = document): void {\n if (typeof CustomEvent === 'undefined') return;\n const target =\n root instanceof Document ? root.documentElement : (root as Element);\n target.dispatchEvent(\n new CustomEvent('cer:hydrate', { bubbles: true, composed: true }),\n );\n}\n","/**\n * Runtime Health Monitoring System\n * Tracks framework health metrics and provides early warning for potential issues\n */\n\nimport { devWarn, devError } from '../logger';\n\ninterface HealthMetric {\n name: string;\n value: number;\n threshold: number;\n status: 'healthy' | 'warning' | 'critical';\n lastUpdated: number;\n history: number[];\n}\n\ninterface HealthReport {\n overall: 'healthy' | 'warning' | 'critical';\n metrics: Record<string, HealthMetric>;\n timestamp: number;\n recommendations: string[];\n}\nexport type { HealthReport };\n\n/**\n * Public interface for a health monitor instance.\n * All state is managed internally via closures — no class syntax.\n */\nexport interface HealthMonitorInstance {\n /** Update a specific health metric value */\n updateMetric(name: string, value: number): void;\n /** Get the current health report */\n getHealthReport(): HealthReport;\n /** Add a listener to be notified when a health check runs */\n addListener(listener: (report: HealthReport) => void): void;\n /** Remove a previously registered listener */\n removeListener(listener: (report: HealthReport) => void): void;\n /** Stop the periodic health monitoring timer */\n stop(): void;\n /** Get historical values for a specific metric */\n getMetricHistory(name: string): number[];\n /** Clear all metric history */\n clearHistory(): void;\n}\n\nconst MAX_HISTORY_SIZE = 100;\nconst CHECK_INTERVAL = 30_000; // 30 seconds\n\nfunction calcStatus(\n value: number,\n threshold: number,\n metricName: string,\n): 'healthy' | 'warning' | 'critical' {\n if (metricName === 'jitCacheHitRate') {\n if (value < threshold * 0.5) return 'critical';\n if (value < threshold) return 'warning';\n return 'healthy';\n }\n if (value > threshold * 2) return 'critical';\n if (value > threshold) return 'warning';\n return 'healthy';\n}\n\nfunction buildRecommendations(metrics: Record<string, HealthMetric>): string[] {\n const out: string[] = [];\n if (metrics.memoryUsage?.status !== 'healthy')\n out.push(\n 'Consider reducing component complexity or implementing better memory cleanup',\n );\n if (metrics.averageRenderTime?.status !== 'healthy')\n out.push(\n 'Optimize component render functions - consider lazy loading or virtualization',\n );\n if (metrics.jitCacheHitRate?.status !== 'healthy')\n out.push(\n 'JIT CSS cache performance is poor - review CSS patterns for optimization',\n );\n if (metrics.componentErrorRate?.status !== 'healthy')\n out.push(\n 'High component error rate detected - review error handling and component logic',\n );\n if (metrics.activeReactiveStates?.status !== 'healthy')\n out.push(\n 'High number of reactive states - consider state consolidation or cleanup',\n );\n if (metrics.memoryLeakIndicator?.status !== 'healthy')\n out.push(\n 'Potential memory leak detected - review component cleanup and event listener management',\n );\n return out;\n}\n\n/**\n * Create a new health monitor instance.\n * All mutable state lives in closures — no `class` or `this`.\n */\nexport function createHealthMonitor(): HealthMonitorInstance {\n const metricsMap = new Map<string, HealthMetric>();\n const listeners = new Set<(report: HealthReport) => void>();\n let intervalId: ReturnType<typeof setInterval> | null = null;\n\n function addMetric(name: string, value: number, threshold: number): void {\n metricsMap.set(name, {\n name,\n value,\n threshold,\n status: 'healthy',\n lastUpdated: Date.now(),\n history: [],\n });\n }\n\n function initializeMetrics(): void {\n addMetric('activeComponents', 0, 1000);\n addMetric('componentCreateRate', 0, 50);\n addMetric('componentErrorRate', 0, 0.1);\n addMetric('memoryUsage', 0, 50 * 1024 * 1024);\n addMetric('memoryGrowthRate', 0, 1024 * 1024);\n addMetric('averageRenderTime', 0, 16);\n addMetric('slowRenderCount', 0, 10);\n addMetric('jitCacheHitRate', 100, 80);\n addMetric('activeReactiveStates', 0, 5000);\n addMetric('dependencyUpdates', 0, 100);\n addMetric('memoryLeakIndicator', 0, 0.1);\n }\n\n function updateMetric(name: string, value: number): void {\n const metric = metricsMap.get(name);\n if (!metric) return;\n metric.value = value;\n metric.lastUpdated = Date.now();\n metric.history.push(value);\n if (metric.history.length > MAX_HISTORY_SIZE) metric.history.shift();\n metric.status = calcStatus(value, metric.threshold, name);\n }\n\n function getHealthReport(): HealthReport {\n const snapshot: Record<string, HealthMetric> = {};\n let overall: 'healthy' | 'warning' | 'critical' = 'healthy';\n for (const [name, metric] of metricsMap) {\n snapshot[name] = { ...metric };\n if (metric.status === 'critical') overall = 'critical';\n else if (metric.status === 'warning' && overall === 'healthy')\n overall = 'warning';\n }\n return {\n overall,\n metrics: snapshot,\n timestamp: Date.now(),\n recommendations: buildRecommendations(snapshot),\n };\n }\n\n function updateMemoryMetrics(): void {\n if (\n 'memory' in performance &&\n (performance as Record<string, unknown>).memory\n ) {\n const mem = (performance as Record<string, unknown>).memory as {\n usedJSHeapSize: number;\n };\n updateMetric('memoryUsage', mem.usedJSHeapSize);\n const m = metricsMap.get('memoryUsage');\n if (m && m.history.length > 1) {\n const prev = m.history[m.history.length - 2];\n const curr = m.history[m.history.length - 1];\n updateMetric('memoryGrowthRate', Math.max(0, curr - prev));\n }\n }\n }\n\n function notifyListeners(report: HealthReport): void {\n for (const listener of listeners) {\n try {\n listener(report);\n } catch (e) {\n devError('Error in health monitor listener:', e);\n }\n }\n }\n\n function performHealthCheck(): void {\n updateMemoryMetrics();\n const report = getHealthReport();\n notifyListeners(report);\n if (report.overall === 'critical')\n devError(\n '🚨 Runtime Health: Critical issues detected',\n report.recommendations,\n );\n else if (report.overall === 'warning')\n devWarn(\n '⚠️ Runtime Health: Performance warnings',\n report.recommendations,\n );\n }\n\n function startMonitoring(): void {\n if (typeof window === 'undefined') return;\n intervalId = setInterval(performHealthCheck, CHECK_INTERVAL);\n }\n\n function stop(): void {\n if (intervalId !== null) {\n clearInterval(intervalId);\n intervalId = null;\n }\n }\n\n function addListener(listener: (report: HealthReport) => void): void {\n listeners.add(listener);\n }\n function removeListener(listener: (report: HealthReport) => void): void {\n listeners.delete(listener);\n }\n function getMetricHistory(name: string): number[] {\n const m = metricsMap.get(name);\n return m ? [...m.history] : [];\n }\n function clearHistory(): void {\n for (const m of metricsMap.values()) m.history = [];\n }\n\n initializeMetrics();\n startMonitoring();\n\n return {\n updateMetric,\n getHealthReport,\n addListener,\n removeListener,\n stop,\n getMetricHistory,\n clearHistory,\n };\n}\n\n// Global singleton\nlet _monitor: HealthMonitorInstance | null = null;\n\n/**\n * Get the global health monitor singleton instance.\n */\nexport function getHealthMonitor(): HealthMonitorInstance {\n if (!_monitor) _monitor = createHealthMonitor();\n return _monitor;\n}\n\n/**\n * Update a health metric from anywhere in the framework.\n */\nexport function updateHealthMetric(name: string, value: number): void {\n getHealthMonitor().updateMetric(name, value);\n}\n\n/**\n * Get the current health status report.\n */\nexport function getHealthStatus(): HealthReport {\n return getHealthMonitor().getHealthReport();\n}\n","/**\n * keep-alive.ts\n *\n * Preserves component state when a component is removed from and later\n * re-inserted into the DOM. By default, custom elements lose all JavaScript\n * state when `disconnectedCallback` fires. `cer-keep-alive` intercepts\n * that lifecycle and keeps the child element alive in memory, re-attaching\n * it when a matching component is re-inserted.\n *\n * ## Usage\n *\n * Wrap any custom element with `<cer-keep-alive>`:\n * ```html\n * <cer-keep-alive>\n * <my-counter></my-counter>\n * </cer-keep-alive>\n * ```\n *\n * Or register it programmatically:\n * ```ts\n * import { registerKeepAlive } from '@jasonshimmy/custom-elements-runtime';\n * registerKeepAlive(); // registers <cer-keep-alive> globally\n * ```\n *\n * ## How it works\n *\n * `cer-keep-alive` uses a slotted layout. When a slotted child component is\n * about to leave the DOM (via a re-render of a parent), KeepAlive intercepts\n * `slotchange` events and preserves the detached child element in an internal\n * cache keyed by tag name. When the same tag re-appears in the slot, the\n * cached element is re-inserted, restoring all JavaScript state.\n *\n * ## Limitations\n *\n * - The first slot child per tag name is cached. Multiple children with the\n * same tag use separate cache entries keyed by their `id` attribute.\n * - Only components registered with the same tag name are matched.\n * - Cache entries can be manually evicted with `clearCache()`.\n */\n\n/** Cache key = tagName[:id] */\ntype CacheKey = string;\n\n/**\n * Register the `<cer-keep-alive>` custom element.\n * Safe to call multiple times — subsequent calls are no-ops.\n *\n * @example\n * ```ts\n * import { registerKeepAlive } from '@jasonshimmy/custom-elements-runtime';\n * registerKeepAlive();\n * ```\n */\nexport function registerKeepAlive(): void {\n if (\n typeof window === 'undefined' ||\n typeof customElements === 'undefined' ||\n customElements.get('cer-keep-alive')\n ) {\n return;\n }\n\n customElements.define('cer-keep-alive', createKeepAliveClass());\n}\n\nfunction createKeepAliveClass(): CustomElementConstructor {\n return class CerKeepAlive extends HTMLElement {\n /** Preserved component instances keyed by tag[:id]. */\n private _cache = new Map<CacheKey, Element>();\n private _slot: HTMLSlotElement | null = null;\n private _slotListener: (() => void) | null = null;\n\n connectedCallback(): void {\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n }\n\n if (!this.shadowRoot!.querySelector('slot')) {\n this.shadowRoot!.innerHTML = '<slot></slot>';\n }\n\n this._slot = this.shadowRoot!.querySelector('slot');\n if (this._slot) {\n this._slotListener = () => this._handleSlotChange();\n this._slot.addEventListener('slotchange', this._slotListener);\n // Process current slotted content\n this._handleSlotChange();\n }\n }\n\n disconnectedCallback(): void {\n if (this._slot && this._slotListener) {\n this._slot.removeEventListener('slotchange', this._slotListener);\n }\n this._slotListener = null;\n }\n\n /**\n * Evict a cached element by its cache key (`tagName` or `tagName:id`).\n * The evicted element is disconnected and removed from the cache.\n */\n clearCache(key?: CacheKey): void {\n if (key) {\n this._cache.delete(key);\n } else {\n this._cache.clear();\n }\n }\n\n private _handleSlotChange(): void {\n if (!this._slot) return;\n\n const slottedElements = this._slot.assignedElements({ flatten: true });\n\n for (const child of slottedElements) {\n const cacheKey = this._buildCacheKey(child);\n\n if (!this._cache.has(cacheKey)) {\n // New element — cache it so we can restore it later\n this._cache.set(cacheKey, child);\n } else {\n const cached = this._cache.get(cacheKey)!;\n if (cached !== child) {\n // A different instance appeared for the same slot.\n // Replace it with the cached instance to restore state.\n try {\n child.parentNode?.replaceChild(cached, child);\n } catch {\n // If replacement fails, update the cache with the new element\n this._cache.set(cacheKey, child);\n }\n }\n }\n }\n }\n\n private _buildCacheKey(el: Element): CacheKey {\n const tag = el.tagName.toLowerCase();\n const id = el.getAttribute('id');\n return id ? `${tag}:${id}` : tag;\n }\n };\n}\n","/**\n * Built-in utility components provided by the custom-elements runtime.\n *\n * These components are registered automatically when this module is imported.\n * They are designed to be minimal, tree-shakeable, and zero-dependency.\n *\n * Included components:\n * - `<cer-suspense>` — Shows a fallback while async work is pending\n * - `<cer-error-boundary>` — Catches render errors and shows a fallback UI\n * - `<cer-keep-alive>` — Preserves component state across DOM removal/re-insertion\n */\n\nimport { component } from './component';\nimport { html } from './template-compiler';\nimport { ref } from './reactive';\nimport { useProps, useOnError, useExpose } from './hooks';\nimport { registerKeepAlive } from '../keep-alive';\n\n// ── cer-suspense ──────────────────────────────────────────────────────────────\n\n/**\n * A built-in component that conditionally renders either the default slot\n * content or the `fallback` slot content, controlled by the `pending` prop.\n *\n * Use the `pending` attribute/property to signal that async work is in\n * progress; the component will swap to the `fallback` slot until `pending`\n * becomes falsy.\n *\n * @example\n * ```html\n * <cer-suspense pending>\n * <!-- shown when pending=false -->\n * <my-async-content></my-async-content>\n *\n * <!-- shown while pending=true -->\n * <div slot=\"fallback\">Loading…</div>\n * </cer-suspense>\n * ```\n *\n * @example Programmatic usage\n * ```ts\n * component('my-data-loader', () => {\n * const pending = ref(true);\n * useOnConnected(async () => {\n * await fetchData();\n * pending.value = false;\n * });\n * return html`\n * <cer-suspense pending=\"${pending.value}\">\n * <my-data-view></my-data-view>\n * <div slot=\"fallback\">Loading data…</div>\n * </cer-suspense>\n * `;\n * });\n * ```\n */\nexport function registerSuspense(): void {\n if (typeof customElements !== 'undefined' && customElements.get('cer-suspense')) return;\n\n component('cer-suspense', () => {\n const { pending } = useProps({ pending: false });\n\n return pending\n ? html`<slot name=\"fallback\"><span>Loading…</span></slot>`\n : html`<slot></slot>`;\n });\n}\n\n// ── cer-error-boundary ────────────────────────────────────────────────────────\n\n/**\n * A built-in component that catches errors thrown during child component\n * rendering and displays a fallback UI instead of crashing the page.\n *\n * Errors are caught via the `useOnError` lifecycle hook. Once an error is\n * caught the component switches to showing the `fallback` named slot (or a\n * default \"Something went wrong\" message if no fallback slot is provided).\n *\n * Call the custom `reset()` method on the element to clear the error and\n * attempt re-rendering the default slot.\n *\n * @example\n * ```html\n * <cer-error-boundary>\n * <my-risky-component></my-risky-component>\n *\n * <div slot=\"fallback\">\n * <p>Something went wrong. <button onclick=\"this.closest('cer-error-boundary').reset()\">Retry</button></p>\n * </div>\n * </cer-error-boundary>\n * ```\n */\nexport function registerErrorBoundary(): void {\n if (typeof customElements !== 'undefined' && customElements.get('cer-error-boundary')) return;\n\n component('cer-error-boundary', () => {\n const hasError = ref(false);\n const errorMessage = ref('');\n\n useOnError((err: Error) => {\n hasError.value = true;\n errorMessage.value = err.message;\n });\n\n // Expose a reset() method so parent templates can call\n // `errorBoundaryRef.value.reset()` to clear the error and retry.\n // Also expose an internal `_cerHandleChildError` receiver so that the\n // component runtime can propagate uncaught errors from slotted child\n // components up to the nearest ancestor <cer-error-boundary>.\n useExpose({\n _cerHandleChildError: (err: unknown) => {\n // Use peek() to read the current value without registering a reactive\n // dependency — the child component's render context may be active when\n // this handler runs, and we must not accidentally subscribe the child\n // to this boundary's internal state.\n if (!hasError.peek()) {\n hasError.value = true;\n errorMessage.value = err instanceof Error ? err.message : String(err);\n }\n },\n reset: () => {\n hasError.value = false;\n errorMessage.value = '';\n },\n });\n\n return hasError.value\n ? html`<slot name=\"fallback\"\n ><div role=\"alert\">\n <strong>Something went wrong.</strong>\n ${errorMessage.value ? html`<p>${errorMessage.value}</p>` : html``}\n </div></slot\n >`\n : html`<slot></slot>`;\n });\n}\n\n// ── Auto-register all components ─────────────────────────────────────────────\n\n/**\n * Register all built-in components (`cer-suspense`, `cer-error-boundary`,\n * `cer-keep-alive`).\n * Safe to call multiple times — each registration is guarded by a\n * `customElements.get()` check.\n */\nexport function registerBuiltinComponents(): void {\n registerSuspense();\n registerErrorBoundary();\n registerKeepAlive();\n}\n","/**\n * teleport.ts\n *\n * Renders virtual DOM content into an arbitrary DOM target located outside\n * the current component's Shadow Root. Useful for modals, tooltips, popovers,\n * and any UI that must visually escape the component boundary.\n *\n * @example\n * ```ts\n * import { component, html, ref, useOnDisconnected, useTeleport } from '@jasonshimmy/custom-elements-runtime';\n *\n * component('modal-trigger', () => {\n * const isOpen = ref(false);\n *\n * // Render modal content into <body> outside the shadow root\n * const { portal, destroy } = useTeleport('#modal-root');\n * useOnDisconnected(destroy);\n *\n * // Call portal() to update the teleported content on each render\n * if (isOpen.value) {\n * portal(html`<div class=\"modal\">\n * <h2>Hello</h2>\n * <button @click=\"${() => (isOpen.value = false)}\">Close</button>\n * </div>`);\n * } else {\n * portal(null);\n * }\n *\n * return html`\n * <button @click=\"${() => (isOpen.value = true)}\">Open modal</button>\n * `;\n * });\n * ```\n */\n\nimport type { VNode, VDomRefs } from './runtime/types';\nimport { vdomRenderer } from './runtime/vdom';\nimport { reactiveSystem } from './runtime/reactive';\nimport { getCurrentComponentContext, isDiscoveryRender } from './runtime/hooks';\n\n/** Handle returned by {@link useTeleport} for managing a portal. */\nexport interface TeleportHandle {\n /**\n * Render (or clear) content at the teleport target.\n * Pass `null` or `undefined` to remove previously rendered content.\n */\n portal(content: VNode | VNode[] | null | undefined): void;\n\n /**\n * Destroy the teleport container and clean up all rendered content.\n * Call this in `useOnDisconnected` to prevent memory leaks.\n */\n destroy(): void;\n}\n\n/**\n * Create a teleport portal that renders content outside the current Shadow Root.\n *\n * @param target - A CSS selector string or an `Element` reference to render into.\n * @returns A {@link TeleportHandle} with `portal()` (update content) and `destroy()` (cleanup).\n *\n * @example\n * ```ts\n * import { component, html, useOnDisconnected, useTeleport } from '@jasonshimmy/custom-elements-runtime';\n *\n * component('my-tooltip', () => {\n * const { portal, destroy } = useTeleport('body');\n * useOnDisconnected(destroy);\n *\n * portal(html`<div class=\"tooltip\">Tooltip content</div>`);\n * return html`<span>Hover me</span>`;\n * });\n * ```\n */\nexport function useTeleport(target: string | Element): TeleportHandle {\n // SSR guard\n if (typeof document === 'undefined') {\n return { portal: () => {}, destroy: () => {} };\n }\n\n // During discovery render the component is not yet mounted — return a no-op\n // handle so the library can detect props/hooks without side-effects.\n if (isDiscoveryRender()) {\n return { portal: () => {}, destroy: () => {} };\n }\n\n // If called inside a component render, use the reactive state-index slot\n // mechanism to ensure the same handle is returned on every re-render of the\n // same component instance. Without this, each re-render would create a new\n // <cer-teleport> container in the target, leaking all but the last one.\n const ctx = getCurrentComponentContext();\n if (ctx) {\n // getOrCreateState uses an incrementing stateIndex that is reset to 0 at\n // the start of each render, so the same call site always gets the same slot.\n const slot = reactiveSystem.getOrCreateState<TeleportHandle | null>(null);\n const existing = slot.peek();\n if (existing !== null) {\n return existing;\n }\n // First render: create the handle and store it without triggering a\n // reactive update (initSilent bypasses triggerUpdate).\n // Pass a slot-invalidation callback so that destroy() clears the slot,\n // allowing a reconnected component to create a fresh container.\n const handle = _createTeleportHandle(target, () => slot.initSilent(null));\n slot.initSilent(handle);\n return handle;\n }\n\n // Outside a component context (e.g. called directly in tests or scripts):\n // fall through to a non-cached, non-stable handle.\n return _createTeleportHandle(target);\n}\n\n/** Internal: create a fresh teleport handle pointing at `target`.\n * @param onDestroy - Optional callback invoked after cleanup in destroy(), used\n * to invalidate a cached slot so the next render creates a fresh handle.\n */\nfunction _createTeleportHandle(\n target: string | Element,\n onDestroy?: () => void,\n): TeleportHandle {\n const targetEl =\n typeof target === 'string'\n ? (document.querySelector(target) as Element | null)\n : target;\n\n if (!targetEl) {\n console.warn(\n `[useTeleport] Target \"${String(target)}\" not found in the document. ` +\n 'Teleported content will not be rendered.',\n );\n return { portal: () => {}, destroy: () => {} };\n }\n\n // Create a dedicated container so we never clobber sibling content.\n const container = document.createElement('cer-teleport');\n container.dataset.cerTeleport = '';\n targetEl.appendChild(container);\n\n // Shared refs bag — passed consistently so ref directives work across updates.\n const refs: VDomRefs = {};\n\n const handle: TeleportHandle = {\n portal(content: VNode | VNode[] | null | undefined): void {\n const nodes: VNode[] =\n content == null ? [] : Array.isArray(content) ? content : [content];\n // vdomRenderer stores _prevVNode/_prevDom on the root object for diffing.\n // Casting to ShadowRoot is safe: we only access properties that exist on\n // HTMLElement (firstChild, appendChild, replaceChild, childNodes).\n vdomRenderer(container as unknown as ShadowRoot, nodes, undefined, refs);\n },\n\n destroy(): void {\n // Render empty nodes to clean up event listeners and refs.\n try {\n vdomRenderer(container as unknown as ShadowRoot, [], undefined, refs);\n } catch {\n /* best-effort cleanup */\n }\n if (container.parentNode) {\n container.parentNode.removeChild(container);\n }\n // Invalidate the cached slot so that if the component reconnects and\n // re-renders, useTeleport() creates a fresh container rather than\n // reusing this destroyed one.\n onDestroy?.();\n },\n };\n\n return handle;\n}\n"],"names":["hydrateApp","root","MAX_HISTORY_SIZE","CHECK_INTERVAL","calcStatus","value","threshold","metricName","buildRecommendations","metrics","out","createHealthMonitor","metricsMap","listeners","intervalId","addMetric","name","initializeMetrics","updateMetric","metric","getHealthReport","snapshot","overall","updateMemoryMetrics","mem","m","prev","curr","notifyListeners","report","listener","e","devError","performHealthCheck","devWarn","startMonitoring","stop","addListener","removeListener","getMetricHistory","clearHistory","_monitor","getHealthMonitor","updateHealthMetric","getHealthStatus","registerKeepAlive","createKeepAliveClass","key","slottedElements","child","cacheKey","cached","el","tag","id","registerSuspense","component","pending","useProps","html","registerErrorBoundary","hasError","ref","errorMessage","useOnError","err","useExpose","registerBuiltinComponents","useTeleport","target","isDiscoveryRender","getCurrentComponentContext","slot","reactiveSystem","existing","handle","_createTeleportHandle","onDestroy","targetEl","container","refs","content","nodes","vdomRenderer"],"mappings":";;;;;;AAiCO,SAASA,EAAWC,IAA2B,UAAgB;AACpE,MAAI,OAAO,cAAgB,IAAa;AAGxC,GADEA,aAAgB,WAAWA,EAAK,kBAAmBA,GAC9C;AAAA,IACL,IAAI,YAAY,eAAe,EAAE,SAAS,IAAM,UAAU,IAAM;AAAA,EAAA;AAEpE;ACKA,MAAMC,IAAmB,KACnBC,IAAiB;AAEvB,SAASC,EACPC,GACAC,GACAC,GACoC;AACpC,SAAIA,MAAe,oBACbF,IAAQC,IAAY,MAAY,aAChCD,IAAQC,IAAkB,YACvB,YAELD,IAAQC,IAAY,IAAU,aAC9BD,IAAQC,IAAkB,YACvB;AACT;AAEA,SAASE,EAAqBC,GAAiD;AAC7E,QAAMC,IAAgB,CAAA;AACtB,SAAID,EAAQ,aAAa,WAAW,aAClCC,EAAI;AAAA,IACF;AAAA,EAAA,GAEAD,EAAQ,mBAAmB,WAAW,aACxCC,EAAI;AAAA,IACF;AAAA,EAAA,GAEAD,EAAQ,iBAAiB,WAAW,aACtCC,EAAI;AAAA,IACF;AAAA,EAAA,GAEAD,EAAQ,oBAAoB,WAAW,aACzCC,EAAI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EAAK,KAAA;AACtB,QAAIE,MAAa;AACf,aAAOA;AAMT,UAAMC,IAASC,EAAsBP,GAAQ,MAAMG,EAAK,WAAW,IAAI,CAAC;AACxE,WAAAA,EAAK,WAAWG,CAAM,GACfA;AAAA,EACT;AAIA,SAAOC,EAAsBP,CAAM;AACrC;AAMA,SAASO,EACPP,GACAQ,GACgB;AAChB,QAAMC,IACJ,OAAOT,KAAW,WACb,SAAS,cAAcA,CAAM,IAC9BA;AAEN,MAAI,CAACS;AACH,mBAAQ;AAAA,MACN,yBAAyB,OAAOT,CAAM,CAAC;AAAA,IAAA,GAGlC,EAAE,QAAQ,MAAM;AAAA,IAAC,GAAG,SAAS,MAAM;AAAA,IAAC,EAAA;AAI7C,QAAMU,IAAY,SAAS,cAAc,cAAc;AACvD,EAAAA,EAAU,QAAQ,cAAc,IAChCD,EAAS,YAAYC,CAAS;AAG9B,QAAMC,IAAiB,CAAA;AA6BvB,SA3B+B;AAAA,IAC7B,OAAOC,GAAmD;AACxD,YAAMC,IACJD,KAAW,OAAO,KAAK,MAAM,QAAQA,CAAO,IAAIA,IAAU,CAACA,CAAO;AAIpE,MAAAE,EAAaJ,GAAoCG,GAAO,QAAWF,CAAI;AAAA,IACzE;AAAA,IAEA,UAAgB;AAEd,UAAI;AACF,QAAAG,EAAaJ,GAAoC,CAAA,GAAI,QAAWC,CAAI;AAAA,MACtE,QAAQ;AAAA,MAER;AACA,MAAID,EAAU,cACZA,EAAU,WAAW,YAAYA,CAAS,GAK5CF,IAAA;AAAA,IACF;AAAA,EAAA;AAIJ;"}
|
|
1
|
+
{"version":3,"file":"custom-elements-runtime.es.js","names":[],"sources":["../src/lib/runtime/hydration.ts","../src/lib/runtime/monitoring/health-monitor.ts","../src/lib/keep-alive.ts","../src/lib/runtime/builtin-components.ts","../src/lib/teleport.ts"],"sourcesContent":["/**\n * Client-side hydration helpers.\n *\n * When the server renders with `dsd: true`, each custom element's shadow DOM\n * is already present in the HTML via a Declarative Shadow DOM template. The\n * browser parses that template and attaches the shadow root before any\n * JavaScript runs. When the JS bundle loads, the custom element constructors\n * detect the existing shadow root and skip the `attachShadow()` call, then\n * hydrate (attach reactivity to) the existing DOM on `connectedCallback`.\n *\n * `hydrateApp` is a signal/entry point for this process. In most cases custom\n * elements self-hydrate automatically on connection — this function is useful\n * when you need to explicitly trigger or defer the hydration of a subtree.\n */\n\n/**\n * Trigger hydration for all registered custom elements within `root`.\n *\n * In practice, custom elements self-hydrate as soon as their class definition\n * is registered and the element is connected to the DOM. Call `hydrateApp`\n * after importing and calling `component()` for all your components to signal\n * that the page is ready for reactive activation.\n *\n * @param root - The root element to hydrate. Defaults to `document`.\n *\n * @example\n * ```ts\n * import { component, hydrateApp } from '@jasonshimmy/custom-elements-runtime';\n * import './components'; // registers all components via component()\n *\n * hydrateApp(); // activate all DSD-rendered components on the page\n * ```\n */\nexport function hydrateApp(root: Element | Document = document): void {\n if (typeof CustomEvent === 'undefined') return;\n const target =\n root instanceof Document ? root.documentElement : (root as Element);\n target.dispatchEvent(\n new CustomEvent('cer:hydrate', { bubbles: true, composed: true }),\n );\n}\n","/**\n * Runtime Health Monitoring System\n * Tracks framework health metrics and provides early warning for potential issues\n */\n\nimport { devWarn, devError } from '../logger';\n\ninterface HealthMetric {\n name: string;\n value: number;\n threshold: number;\n status: 'healthy' | 'warning' | 'critical';\n lastUpdated: number;\n history: number[];\n}\n\ninterface HealthReport {\n overall: 'healthy' | 'warning' | 'critical';\n metrics: Record<string, HealthMetric>;\n timestamp: number;\n recommendations: string[];\n}\nexport type { HealthReport };\n\n/**\n * Public interface for a health monitor instance.\n * All state is managed internally via closures — no class syntax.\n */\nexport interface HealthMonitorInstance {\n /** Update a specific health metric value */\n updateMetric(name: string, value: number): void;\n /** Get the current health report */\n getHealthReport(): HealthReport;\n /** Add a listener to be notified when a health check runs */\n addListener(listener: (report: HealthReport) => void): void;\n /** Remove a previously registered listener */\n removeListener(listener: (report: HealthReport) => void): void;\n /** Stop the periodic health monitoring timer */\n stop(): void;\n /** Get historical values for a specific metric */\n getMetricHistory(name: string): number[];\n /** Clear all metric history */\n clearHistory(): void;\n}\n\nconst MAX_HISTORY_SIZE = 100;\nconst CHECK_INTERVAL = 30_000; // 30 seconds\n\nfunction calcStatus(\n value: number,\n threshold: number,\n metricName: string,\n): 'healthy' | 'warning' | 'critical' {\n if (metricName === 'jitCacheHitRate') {\n if (value < threshold * 0.5) return 'critical';\n if (value < threshold) return 'warning';\n return 'healthy';\n }\n if (value > threshold * 2) return 'critical';\n if (value > threshold) return 'warning';\n return 'healthy';\n}\n\nfunction buildRecommendations(metrics: Record<string, HealthMetric>): string[] {\n const out: string[] = [];\n if (metrics.memoryUsage?.status !== 'healthy')\n out.push(\n 'Consider reducing component complexity or implementing better memory cleanup',\n );\n if (metrics.averageRenderTime?.status !== 'healthy')\n out.push(\n 'Optimize component render functions - consider lazy loading or virtualization',\n );\n if (metrics.jitCacheHitRate?.status !== 'healthy')\n out.push(\n 'JIT CSS cache performance is poor - review CSS patterns for optimization',\n );\n if (metrics.componentErrorRate?.status !== 'healthy')\n out.push(\n 'High component error rate detected - review error handling and component logic',\n );\n if (metrics.activeReactiveStates?.status !== 'healthy')\n out.push(\n 'High number of reactive states - consider state consolidation or cleanup',\n );\n if (metrics.memoryLeakIndicator?.status !== 'healthy')\n out.push(\n 'Potential memory leak detected - review component cleanup and event listener management',\n );\n return out;\n}\n\n/**\n * Create a new health monitor instance.\n * All mutable state lives in closures — no `class` or `this`.\n */\nexport function createHealthMonitor(): HealthMonitorInstance {\n const metricsMap = new Map<string, HealthMetric>();\n const listeners = new Set<(report: HealthReport) => void>();\n let intervalId: ReturnType<typeof setInterval> | null = null;\n\n function addMetric(name: string, value: number, threshold: number): void {\n metricsMap.set(name, {\n name,\n value,\n threshold,\n status: 'healthy',\n lastUpdated: Date.now(),\n history: [],\n });\n }\n\n function initializeMetrics(): void {\n addMetric('activeComponents', 0, 1000);\n addMetric('componentCreateRate', 0, 50);\n addMetric('componentErrorRate', 0, 0.1);\n addMetric('memoryUsage', 0, 50 * 1024 * 1024);\n addMetric('memoryGrowthRate', 0, 1024 * 1024);\n addMetric('averageRenderTime', 0, 16);\n addMetric('slowRenderCount', 0, 10);\n addMetric('jitCacheHitRate', 100, 80);\n addMetric('activeReactiveStates', 0, 5000);\n addMetric('dependencyUpdates', 0, 100);\n addMetric('memoryLeakIndicator', 0, 0.1);\n }\n\n function updateMetric(name: string, value: number): void {\n const metric = metricsMap.get(name);\n if (!metric) return;\n metric.value = value;\n metric.lastUpdated = Date.now();\n metric.history.push(value);\n if (metric.history.length > MAX_HISTORY_SIZE) metric.history.shift();\n metric.status = calcStatus(value, metric.threshold, name);\n }\n\n function getHealthReport(): HealthReport {\n const snapshot: Record<string, HealthMetric> = {};\n let overall: 'healthy' | 'warning' | 'critical' = 'healthy';\n for (const [name, metric] of metricsMap) {\n snapshot[name] = { ...metric };\n if (metric.status === 'critical') overall = 'critical';\n else if (metric.status === 'warning' && overall === 'healthy')\n overall = 'warning';\n }\n return {\n overall,\n metrics: snapshot,\n timestamp: Date.now(),\n recommendations: buildRecommendations(snapshot),\n };\n }\n\n function updateMemoryMetrics(): void {\n if (\n 'memory' in performance &&\n (performance as Record<string, unknown>).memory\n ) {\n const mem = (performance as Record<string, unknown>).memory as {\n usedJSHeapSize: number;\n };\n updateMetric('memoryUsage', mem.usedJSHeapSize);\n const m = metricsMap.get('memoryUsage');\n if (m && m.history.length > 1) {\n const prev = m.history[m.history.length - 2];\n const curr = m.history[m.history.length - 1];\n updateMetric('memoryGrowthRate', Math.max(0, curr - prev));\n }\n }\n }\n\n function notifyListeners(report: HealthReport): void {\n for (const listener of listeners) {\n try {\n listener(report);\n } catch (e) {\n devError('Error in health monitor listener:', e);\n }\n }\n }\n\n function performHealthCheck(): void {\n updateMemoryMetrics();\n const report = getHealthReport();\n notifyListeners(report);\n if (report.overall === 'critical')\n devError(\n '🚨 Runtime Health: Critical issues detected',\n report.recommendations,\n );\n else if (report.overall === 'warning')\n devWarn(\n '⚠️ Runtime Health: Performance warnings',\n report.recommendations,\n );\n }\n\n function startMonitoring(): void {\n if (typeof window === 'undefined') return;\n intervalId = setInterval(performHealthCheck, CHECK_INTERVAL);\n }\n\n function stop(): void {\n if (intervalId !== null) {\n clearInterval(intervalId);\n intervalId = null;\n }\n }\n\n function addListener(listener: (report: HealthReport) => void): void {\n listeners.add(listener);\n }\n function removeListener(listener: (report: HealthReport) => void): void {\n listeners.delete(listener);\n }\n function getMetricHistory(name: string): number[] {\n const m = metricsMap.get(name);\n return m ? [...m.history] : [];\n }\n function clearHistory(): void {\n for (const m of metricsMap.values()) m.history = [];\n }\n\n initializeMetrics();\n startMonitoring();\n\n return {\n updateMetric,\n getHealthReport,\n addListener,\n removeListener,\n stop,\n getMetricHistory,\n clearHistory,\n };\n}\n\n// Global singleton\nlet _monitor: HealthMonitorInstance | null = null;\n\n/**\n * Get the global health monitor singleton instance.\n */\nexport function getHealthMonitor(): HealthMonitorInstance {\n if (!_monitor) _monitor = createHealthMonitor();\n return _monitor;\n}\n\n/**\n * Update a health metric from anywhere in the framework.\n */\nexport function updateHealthMetric(name: string, value: number): void {\n getHealthMonitor().updateMetric(name, value);\n}\n\n/**\n * Get the current health status report.\n */\nexport function getHealthStatus(): HealthReport {\n return getHealthMonitor().getHealthReport();\n}\n","/**\n * keep-alive.ts\n *\n * Preserves component state when a component is removed from and later\n * re-inserted into the DOM. By default, custom elements lose all JavaScript\n * state when `disconnectedCallback` fires. `cer-keep-alive` intercepts\n * that lifecycle and keeps the child element alive in memory, re-attaching\n * it when a matching component is re-inserted.\n *\n * ## Usage\n *\n * Wrap any custom element with `<cer-keep-alive>`:\n * ```html\n * <cer-keep-alive>\n * <my-counter></my-counter>\n * </cer-keep-alive>\n * ```\n *\n * Or register it programmatically:\n * ```ts\n * import { registerKeepAlive } from '@jasonshimmy/custom-elements-runtime';\n * registerKeepAlive(); // registers <cer-keep-alive> globally\n * ```\n *\n * ## How it works\n *\n * `cer-keep-alive` uses a slotted layout. When a slotted child component is\n * about to leave the DOM (via a re-render of a parent), KeepAlive intercepts\n * `slotchange` events and preserves the detached child element in an internal\n * cache keyed by tag name. When the same tag re-appears in the slot, the\n * cached element is re-inserted, restoring all JavaScript state.\n *\n * ## Limitations\n *\n * - The first slot child per tag name is cached. Multiple children with the\n * same tag use separate cache entries keyed by their `id` attribute.\n * - Only components registered with the same tag name are matched.\n * - Cache entries can be manually evicted with `clearCache()`.\n */\n\n/** Cache key = tagName[:id] */\ntype CacheKey = string;\n\n/**\n * Register the `<cer-keep-alive>` custom element.\n * Safe to call multiple times — subsequent calls are no-ops.\n *\n * @example\n * ```ts\n * import { registerKeepAlive } from '@jasonshimmy/custom-elements-runtime';\n * registerKeepAlive();\n * ```\n */\nexport function registerKeepAlive(): void {\n if (\n typeof window === 'undefined' ||\n typeof customElements === 'undefined' ||\n customElements.get('cer-keep-alive')\n ) {\n return;\n }\n\n customElements.define('cer-keep-alive', createKeepAliveClass());\n}\n\nfunction createKeepAliveClass(): CustomElementConstructor {\n return class CerKeepAlive extends HTMLElement {\n /** Preserved component instances keyed by tag[:id]. */\n private _cache = new Map<CacheKey, Element>();\n private _slot: HTMLSlotElement | null = null;\n private _slotListener: (() => void) | null = null;\n\n connectedCallback(): void {\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n }\n\n if (!this.shadowRoot!.querySelector('slot')) {\n this.shadowRoot!.innerHTML = '<slot></slot>';\n }\n\n this._slot = this.shadowRoot!.querySelector('slot');\n if (this._slot) {\n this._slotListener = () => this._handleSlotChange();\n this._slot.addEventListener('slotchange', this._slotListener);\n // Process current slotted content\n this._handleSlotChange();\n }\n }\n\n disconnectedCallback(): void {\n if (this._slot && this._slotListener) {\n this._slot.removeEventListener('slotchange', this._slotListener);\n }\n this._slotListener = null;\n }\n\n /**\n * Evict a cached element by its cache key (`tagName` or `tagName:id`).\n * The evicted element is disconnected and removed from the cache.\n */\n clearCache(key?: CacheKey): void {\n if (key) {\n this._cache.delete(key);\n } else {\n this._cache.clear();\n }\n }\n\n private _handleSlotChange(): void {\n if (!this._slot) return;\n\n const slottedElements = this._slot.assignedElements({ flatten: true });\n\n for (const child of slottedElements) {\n const cacheKey = this._buildCacheKey(child);\n\n if (!this._cache.has(cacheKey)) {\n // New element — cache it so we can restore it later\n this._cache.set(cacheKey, child);\n } else {\n const cached = this._cache.get(cacheKey)!;\n if (cached !== child) {\n // A different instance appeared for the same slot.\n // Replace it with the cached instance to restore state.\n try {\n child.parentNode?.replaceChild(cached, child);\n } catch {\n // If replacement fails, update the cache with the new element\n this._cache.set(cacheKey, child);\n }\n }\n }\n }\n }\n\n private _buildCacheKey(el: Element): CacheKey {\n const tag = el.tagName.toLowerCase();\n const id = el.getAttribute('id');\n return id ? `${tag}:${id}` : tag;\n }\n };\n}\n","/**\n * Built-in utility components provided by the custom-elements runtime.\n *\n * These components are registered automatically when this module is imported.\n * They are designed to be minimal, tree-shakeable, and zero-dependency.\n *\n * Included components:\n * - `<cer-suspense>` — Shows a fallback while async work is pending\n * - `<cer-error-boundary>` — Catches render errors and shows a fallback UI\n * - `<cer-keep-alive>` — Preserves component state across DOM removal/re-insertion\n */\n\nimport { component } from './component';\nimport { html } from './template-compiler';\nimport { ref } from './reactive';\nimport { useProps, useOnError, useExpose } from './hooks';\nimport { registerKeepAlive } from '../keep-alive';\n\n// ── cer-suspense ──────────────────────────────────────────────────────────────\n\n/**\n * A built-in component that conditionally renders either the default slot\n * content or the `fallback` slot content, controlled by the `pending` prop.\n *\n * Use the `pending` attribute/property to signal that async work is in\n * progress; the component will swap to the `fallback` slot until `pending`\n * becomes falsy.\n *\n * @example\n * ```html\n * <cer-suspense pending>\n * <!-- shown when pending=false -->\n * <my-async-content></my-async-content>\n *\n * <!-- shown while pending=true -->\n * <div slot=\"fallback\">Loading…</div>\n * </cer-suspense>\n * ```\n *\n * @example Programmatic usage\n * ```ts\n * component('my-data-loader', () => {\n * const pending = ref(true);\n * useOnConnected(async () => {\n * await fetchData();\n * pending.value = false;\n * });\n * return html`\n * <cer-suspense pending=\"${pending.value}\">\n * <my-data-view></my-data-view>\n * <div slot=\"fallback\">Loading data…</div>\n * </cer-suspense>\n * `;\n * });\n * ```\n */\nexport function registerSuspense(): void {\n if (typeof customElements !== 'undefined' && customElements.get('cer-suspense')) return;\n\n component('cer-suspense', () => {\n const { pending } = useProps({ pending: false });\n\n return pending\n ? html`<slot name=\"fallback\"><span>Loading…</span></slot>`\n : html`<slot></slot>`;\n });\n}\n\n// ── cer-error-boundary ────────────────────────────────────────────────────────\n\n/**\n * A built-in component that catches errors thrown during child component\n * rendering and displays a fallback UI instead of crashing the page.\n *\n * Errors are caught via the `useOnError` lifecycle hook. Once an error is\n * caught the component switches to showing the `fallback` named slot (or a\n * default \"Something went wrong\" message if no fallback slot is provided).\n *\n * Call the custom `reset()` method on the element to clear the error and\n * attempt re-rendering the default slot.\n *\n * @example\n * ```html\n * <cer-error-boundary>\n * <my-risky-component></my-risky-component>\n *\n * <div slot=\"fallback\">\n * <p>Something went wrong. <button onclick=\"this.closest('cer-error-boundary').reset()\">Retry</button></p>\n * </div>\n * </cer-error-boundary>\n * ```\n */\nexport function registerErrorBoundary(): void {\n if (typeof customElements !== 'undefined' && customElements.get('cer-error-boundary')) return;\n\n component('cer-error-boundary', () => {\n const hasError = ref(false);\n const errorMessage = ref('');\n\n useOnError((err: Error) => {\n hasError.value = true;\n errorMessage.value = err.message;\n });\n\n // Expose a reset() method so parent templates can call\n // `errorBoundaryRef.value.reset()` to clear the error and retry.\n // Also expose an internal `_cerHandleChildError` receiver so that the\n // component runtime can propagate uncaught errors from slotted child\n // components up to the nearest ancestor <cer-error-boundary>.\n useExpose({\n _cerHandleChildError: (err: unknown) => {\n // Use peek() to read the current value without registering a reactive\n // dependency — the child component's render context may be active when\n // this handler runs, and we must not accidentally subscribe the child\n // to this boundary's internal state.\n if (!hasError.peek()) {\n hasError.value = true;\n errorMessage.value = err instanceof Error ? err.message : String(err);\n }\n },\n reset: () => {\n hasError.value = false;\n errorMessage.value = '';\n },\n });\n\n return hasError.value\n ? html`<slot name=\"fallback\"\n ><div role=\"alert\">\n <strong>Something went wrong.</strong>\n ${errorMessage.value ? html`<p>${errorMessage.value}</p>` : html``}\n </div></slot\n >`\n : html`<slot></slot>`;\n });\n}\n\n// ── Auto-register all components ─────────────────────────────────────────────\n\n/**\n * Register all built-in components (`cer-suspense`, `cer-error-boundary`,\n * `cer-keep-alive`).\n * Safe to call multiple times — each registration is guarded by a\n * `customElements.get()` check.\n */\nexport function registerBuiltinComponents(): void {\n registerSuspense();\n registerErrorBoundary();\n registerKeepAlive();\n}\n","/**\n * teleport.ts\n *\n * Renders virtual DOM content into an arbitrary DOM target located outside\n * the current component's Shadow Root. Useful for modals, tooltips, popovers,\n * and any UI that must visually escape the component boundary.\n *\n * @example\n * ```ts\n * import { component, html, ref, useOnDisconnected, useTeleport } from '@jasonshimmy/custom-elements-runtime';\n *\n * component('modal-trigger', () => {\n * const isOpen = ref(false);\n *\n * // Render modal content into <body> outside the shadow root\n * const { portal, destroy } = useTeleport('#modal-root');\n * useOnDisconnected(destroy);\n *\n * // Call portal() to update the teleported content on each render\n * if (isOpen.value) {\n * portal(html`<div class=\"modal\">\n * <h2>Hello</h2>\n * <button @click=\"${() => (isOpen.value = false)}\">Close</button>\n * </div>`);\n * } else {\n * portal(null);\n * }\n *\n * return html`\n * <button @click=\"${() => (isOpen.value = true)}\">Open modal</button>\n * `;\n * });\n * ```\n */\n\nimport type { VNode, VDomRefs } from './runtime/types';\nimport { vdomRenderer } from './runtime/vdom';\nimport { reactiveSystem } from './runtime/reactive';\nimport { getCurrentComponentContext, isDiscoveryRender } from './runtime/hooks';\n\n/** Handle returned by {@link useTeleport} for managing a portal. */\nexport interface TeleportHandle {\n /**\n * Render (or clear) content at the teleport target.\n * Pass `null` or `undefined` to remove previously rendered content.\n */\n portal(content: VNode | VNode[] | null | undefined): void;\n\n /**\n * Destroy the teleport container and clean up all rendered content.\n * Call this in `useOnDisconnected` to prevent memory leaks.\n */\n destroy(): void;\n}\n\n/**\n * Create a teleport portal that renders content outside the current Shadow Root.\n *\n * @param target - A CSS selector string or an `Element` reference to render into.\n * @returns A {@link TeleportHandle} with `portal()` (update content) and `destroy()` (cleanup).\n *\n * @example\n * ```ts\n * import { component, html, useOnDisconnected, useTeleport } from '@jasonshimmy/custom-elements-runtime';\n *\n * component('my-tooltip', () => {\n * const { portal, destroy } = useTeleport('body');\n * useOnDisconnected(destroy);\n *\n * portal(html`<div class=\"tooltip\">Tooltip content</div>`);\n * return html`<span>Hover me</span>`;\n * });\n * ```\n */\nexport function useTeleport(target: string | Element): TeleportHandle {\n // SSR guard\n if (typeof document === 'undefined') {\n return { portal: () => {}, destroy: () => {} };\n }\n\n // During discovery render the component is not yet mounted — return a no-op\n // handle so the library can detect props/hooks without side-effects.\n if (isDiscoveryRender()) {\n return { portal: () => {}, destroy: () => {} };\n }\n\n // If called inside a component render, use the reactive state-index slot\n // mechanism to ensure the same handle is returned on every re-render of the\n // same component instance. Without this, each re-render would create a new\n // <cer-teleport> container in the target, leaking all but the last one.\n const ctx = getCurrentComponentContext();\n if (ctx) {\n // getOrCreateState uses an incrementing stateIndex that is reset to 0 at\n // the start of each render, so the same call site always gets the same slot.\n const slot = reactiveSystem.getOrCreateState<TeleportHandle | null>(null);\n const existing = slot.peek();\n if (existing !== null) {\n return existing;\n }\n // First render: create the handle and store it without triggering a\n // reactive update (initSilent bypasses triggerUpdate).\n // Pass a slot-invalidation callback so that destroy() clears the slot,\n // allowing a reconnected component to create a fresh container.\n const handle = _createTeleportHandle(target, () => slot.initSilent(null));\n slot.initSilent(handle);\n return handle;\n }\n\n // Outside a component context (e.g. called directly in tests or scripts):\n // fall through to a non-cached, non-stable handle.\n return _createTeleportHandle(target);\n}\n\n/** Internal: create a fresh teleport handle pointing at `target`.\n * @param onDestroy - Optional callback invoked after cleanup in destroy(), used\n * to invalidate a cached slot so the next render creates a fresh handle.\n */\nfunction _createTeleportHandle(\n target: string | Element,\n onDestroy?: () => void,\n): TeleportHandle {\n const targetEl =\n typeof target === 'string'\n ? (document.querySelector(target) as Element | null)\n : target;\n\n if (!targetEl) {\n console.warn(\n `[useTeleport] Target \"${String(target)}\" not found in the document. ` +\n 'Teleported content will not be rendered.',\n );\n return { portal: () => {}, destroy: () => {} };\n }\n\n // Create a dedicated container so we never clobber sibling content.\n const container = document.createElement('cer-teleport');\n container.dataset.cerTeleport = '';\n targetEl.appendChild(container);\n\n // Shared refs bag — passed consistently so ref directives work across updates.\n const refs: VDomRefs = {};\n\n const handle: TeleportHandle = {\n portal(content: VNode | VNode[] | null | undefined): void {\n const nodes: VNode[] =\n content == null ? [] : Array.isArray(content) ? content : [content];\n // vdomRenderer stores _prevVNode/_prevDom on the root object for diffing.\n // Casting to ShadowRoot is safe: we only access properties that exist on\n // HTMLElement (firstChild, appendChild, replaceChild, childNodes).\n vdomRenderer(container as unknown as ShadowRoot, nodes, undefined, refs);\n },\n\n destroy(): void {\n // Render empty nodes to clean up event listeners and refs.\n try {\n vdomRenderer(container as unknown as ShadowRoot, [], undefined, refs);\n } catch {\n /* best-effort cleanup */\n }\n if (container.parentNode) {\n container.parentNode.removeChild(container);\n }\n // Invalidate the cached slot so that if the component reconnects and\n // re-renders, useTeleport() creates a fresh container rather than\n // reusing this destroyed one.\n onDestroy?.();\n },\n };\n\n return handle;\n}\n"],"mappings":";;;;AAiCA,SAAgB,GAAW,IAA2B,UAAgB;AACpE,EAAI,OAAO,cAAgB,QAEzB,aAAgB,WAAW,EAAK,kBAAmB,GAC9C,cACL,IAAI,YAAY,eAAe;AAAA,IAAE,SAAS;AAAA,IAAM,UAAU;AAAA,GAAM,CAAC;;ACOrE,IAAM,IAAmB,KACnB,IAAiB;AAEvB,SAAS,EACP,GACA,GACA,GACoC;AACpC,SAAI,MAAe,oBACb,IAAQ,IAAY,MAAY,aAChC,IAAQ,IAAkB,YACvB,YAEL,IAAQ,IAAY,IAAU,aAC9B,IAAQ,IAAkB,YACvB;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