@jasonshimmy/custom-elements-runtime 2.5.2 → 2.5.5

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.
Files changed (94) hide show
  1. package/README.md +115 -40
  2. package/dist/css/colors.d.ts +14 -0
  3. package/dist/custom-elements-runtime.cjs.js +6 -1
  4. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  5. package/dist/custom-elements-runtime.colors.cjs.js +2 -0
  6. package/dist/custom-elements-runtime.colors.cjs.js.map +1 -0
  7. package/dist/custom-elements-runtime.colors.es.js +279 -0
  8. package/dist/custom-elements-runtime.colors.es.js.map +1 -0
  9. package/dist/custom-elements-runtime.directive-enhancements.es.js +1 -1
  10. package/dist/custom-elements-runtime.es.js +258 -166
  11. package/dist/custom-elements-runtime.es.js.map +1 -1
  12. package/dist/custom-elements-runtime.event-bus.cjs.js +1 -1
  13. package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
  14. package/dist/custom-elements-runtime.event-bus.es.js +28 -25
  15. package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
  16. package/dist/custom-elements-runtime.router.cjs.js +20 -20
  17. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  18. package/dist/custom-elements-runtime.router.es.js +549 -531
  19. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  20. package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
  21. package/dist/custom-elements-runtime.ssr.es.js +12 -8
  22. package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
  23. package/dist/custom-elements-runtime.store.cjs.js +1 -1
  24. package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
  25. package/dist/custom-elements-runtime.store.es.js +5 -5
  26. package/dist/custom-elements-runtime.store.es.js.map +1 -1
  27. package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
  28. package/dist/custom-elements-runtime.transitions.es.js +1 -1
  29. package/dist/event-bus.d.ts +17 -4
  30. package/dist/index.d.ts +13 -5
  31. package/dist/keep-alive.d.ts +50 -0
  32. package/dist/{logger-BuUYv7C_.js → logger-BvkEbVM4.js} +15 -11
  33. package/dist/logger-BvkEbVM4.js.map +1 -0
  34. package/dist/logger-CSALKaYm.cjs +2 -0
  35. package/dist/logger-CSALKaYm.cjs.map +1 -0
  36. package/dist/namespace-helpers-4qeKVqQw.cjs +5 -0
  37. package/dist/namespace-helpers-4qeKVqQw.cjs.map +1 -0
  38. package/dist/namespace-helpers-DcD_6_K1.js +989 -0
  39. package/dist/namespace-helpers-DcD_6_K1.js.map +1 -0
  40. package/dist/router/active-proxy.d.ts +5 -0
  41. package/dist/router/component-loader.d.ts +11 -0
  42. package/dist/router/instance.d.ts +11 -0
  43. package/dist/router/matcher.d.ts +14 -0
  44. package/dist/router/path-utils.d.ts +48 -0
  45. package/dist/router/types.d.ts +134 -0
  46. package/dist/router.d.ts +6 -208
  47. package/dist/runtime/builtin-components.d.ts +78 -0
  48. package/dist/runtime/component/element-class.d.ts +4 -0
  49. package/dist/runtime/component/factory.d.ts +39 -0
  50. package/dist/runtime/component/registry.d.ts +16 -0
  51. package/dist/runtime/component.d.ts +3 -50
  52. package/dist/runtime/discovery-state.d.ts +30 -0
  53. package/dist/runtime/hooks.d.ts +115 -0
  54. package/dist/runtime/logger.d.ts +19 -1
  55. package/dist/runtime/monitoring/health-monitor.d.ts +22 -65
  56. package/dist/runtime/reactive.d.ts +39 -7
  57. package/dist/runtime/render.d.ts +20 -4
  58. package/dist/runtime/scheduler.d.ts +69 -2
  59. package/dist/runtime/template-compiler/impl.d.ts +14 -0
  60. package/dist/runtime/template-compiler/lru-cache.d.ts +20 -0
  61. package/dist/runtime/template-compiler/props-parser.d.ts +15 -0
  62. package/dist/runtime/template-compiler/vnode-utils.d.ts +5 -0
  63. package/dist/runtime/template-compiler.d.ts +5 -28
  64. package/dist/runtime/types.d.ts +10 -0
  65. package/dist/runtime/vdom-directives.d.ts +71 -0
  66. package/dist/runtime/vdom-helpers.d.ts +126 -0
  67. package/dist/runtime/vdom-patch.d.ts +67 -0
  68. package/dist/runtime/vdom.d.ts +16 -140
  69. package/dist/ssr.d.ts +2 -1
  70. package/dist/teleport.d.ts +68 -0
  71. package/dist/template-compiler-CA4YRaBu.cjs +23 -0
  72. package/dist/template-compiler-CA4YRaBu.cjs.map +1 -0
  73. package/dist/template-compiler-CJFwjLCP.js +3981 -0
  74. package/dist/template-compiler-CJFwjLCP.js.map +1 -0
  75. package/dist/transitions-DPZiuXb9.cjs +330 -0
  76. package/dist/transitions-DPZiuXb9.cjs.map +1 -0
  77. package/dist/{transitions-Bx0Nc9zR.js → transitions-Di5wW9yc.js} +1072 -632
  78. package/dist/transitions-Di5wW9yc.js.map +1 -0
  79. package/dist/transitions.d.ts +1 -1
  80. package/package.json +18 -11
  81. package/dist/logger-BuUYv7C_.js.map +0 -1
  82. package/dist/logger-DiXdWaF-.cjs +0 -2
  83. package/dist/logger-DiXdWaF-.cjs.map +0 -1
  84. package/dist/namespace-helpers-BCVTzhAO.cjs +0 -5
  85. package/dist/namespace-helpers-BCVTzhAO.cjs.map +0 -1
  86. package/dist/namespace-helpers-CF28TyaG.js +0 -786
  87. package/dist/namespace-helpers-CF28TyaG.js.map +0 -1
  88. package/dist/template-compiler-CXHEnaBh.cjs +0 -17
  89. package/dist/template-compiler-CXHEnaBh.cjs.map +0 -1
  90. package/dist/template-compiler-DD_VZrte.js +0 -3729
  91. package/dist/template-compiler-DD_VZrte.js.map +0 -1
  92. package/dist/transitions-Bx0Nc9zR.js.map +0 -1
  93. package/dist/transitions-DfcqL-X4.cjs +0 -302
  94. package/dist/transitions-DfcqL-X4.cjs.map +0 -1
@@ -1,195 +1,287 @@
1
- import { c as y, h as g, u as M, d as v, a as w, b as H, e as R, g as S, f as C } from "./template-compiler-DD_VZrte.js";
2
- import { c as x, d as z, f as U, r as k, u as E, w as L } from "./namespace-helpers-CF28TyaG.js";
3
- import { c as O } from "./transitions-Bx0Nc9zR.js";
4
- import { d as o, a as h } from "./logger-BuUYv7C_.js";
5
- import { s as T } from "./logger-BuUYv7C_.js";
6
- class m {
7
- metrics = /* @__PURE__ */ new Map();
8
- maxHistorySize = 100;
9
- checkInterval = 3e4;
10
- // 30 seconds
11
- intervalId = null;
12
- listeners = /* @__PURE__ */ new Set();
13
- constructor() {
14
- this.initializeMetrics(), this.startMonitoring();
15
- }
16
- /**
17
- * Initialize default health metrics
18
- */
19
- initializeMetrics() {
20
- this.addMetric("activeComponents", 0, 1e3, []), this.addMetric("componentCreateRate", 0, 50, []), this.addMetric("componentErrorRate", 0, 0.1, []), this.addMetric("memoryUsage", 0, 50 * 1024 * 1024, []), this.addMetric("memoryGrowthRate", 0, 1024 * 1024, []), this.addMetric("averageRenderTime", 0, 16, []), this.addMetric("slowRenderCount", 0, 10, []), this.addMetric("jitCacheHitRate", 100, 80, []), this.addMetric("activeReactiveStates", 0, 5e3, []), this.addMetric("dependencyUpdates", 0, 100, []), this.addMetric("memoryLeakIndicator", 0, 0.1, []);
21
- }
22
- /**
23
- * Add a new health metric
24
- */
25
- addMetric(t, e, r, a) {
26
- this.metrics.set(t, {
27
- name: t,
28
- value: e,
29
- threshold: r,
1
+ import { c as v, u as b, a as T, h as l, b as x, g as k, v as m, i as A } from "./template-compiler-CJFwjLCP.js";
2
+ import { d as ee, e as te, p as ne, f as re, j as oe, k as se, l as ie, m as ae, n as ce } from "./template-compiler-CJFwjLCP.js";
3
+ import { r as p, a as I } from "./namespace-helpers-DcD_6_K1.js";
4
+ import { R as ue, c as he, d as de, f as fe, i as me, n as pe, s as ye, u as ge, w as ve, b as Ce } from "./namespace-helpers-DcD_6_K1.js";
5
+ import { c as Se } from "./transitions-Di5wW9yc.js";
6
+ import { d as y, a as O } from "./logger-BvkEbVM4.js";
7
+ import { b as Re, s as Ee } from "./logger-BvkEbVM4.js";
8
+ const U = 100, D = 3e4;
9
+ function K(e, t, r) {
10
+ return r === "jitCacheHitRate" ? e < t * 0.5 ? "critical" : e < t ? "warning" : "healthy" : e > t * 2 ? "critical" : e > t ? "warning" : "healthy";
11
+ }
12
+ function z(e) {
13
+ const t = [];
14
+ return e.memoryUsage?.status !== "healthy" && t.push(
15
+ "Consider reducing component complexity or implementing better memory cleanup"
16
+ ), e.averageRenderTime?.status !== "healthy" && t.push(
17
+ "Optimize component render functions - consider lazy loading or virtualization"
18
+ ), e.jitCacheHitRate?.status !== "healthy" && t.push(
19
+ "JIT CSS cache performance is poor - review CSS patterns for optimization"
20
+ ), e.componentErrorRate?.status !== "healthy" && t.push(
21
+ "High component error rate detected - review error handling and component logic"
22
+ ), e.activeReactiveStates?.status !== "healthy" && t.push(
23
+ "High number of reactive states - consider state consolidation or cleanup"
24
+ ), e.memoryLeakIndicator?.status !== "healthy" && t.push(
25
+ "Potential memory leak detected - review component cleanup and event listener management"
26
+ ), t;
27
+ }
28
+ function j() {
29
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
30
+ let r = null;
31
+ function n(o, s, i) {
32
+ e.set(o, {
33
+ name: o,
34
+ value: s,
35
+ threshold: i,
30
36
  status: "healthy",
31
37
  lastUpdated: Date.now(),
32
- history: [...a]
38
+ history: []
33
39
  });
34
40
  }
35
- /**
36
- * Update a specific health metric
37
- */
38
- updateMetric(t, e) {
39
- const r = this.metrics.get(t);
40
- r && (r.value = e, r.lastUpdated = Date.now(), r.history.push(e), r.history.length > this.maxHistorySize && r.history.shift(), r.status = this.calculateStatus(e, r.threshold, t));
41
+ function a() {
42
+ 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);
41
43
  }
42
- /**
43
- * Calculate health status based on value and threshold
44
- */
45
- calculateStatus(t, e, r) {
46
- return r === "jitCacheHitRate" ? t < e * 0.5 ? "critical" : t < e ? "warning" : "healthy" : t > e * 2 ? "critical" : t > e ? "warning" : "healthy";
44
+ function h(o, s) {
45
+ const i = e.get(o);
46
+ i && (i.value = s, i.lastUpdated = Date.now(), i.history.push(s), i.history.length > U && i.history.shift(), i.status = K(s, i.threshold, o));
47
47
  }
48
- /**
49
- * Get current health report
50
- */
51
- getHealthReport() {
52
- const t = {};
53
- let e = "healthy";
54
- for (const [a, i] of this.metrics)
55
- t[a] = { ...i }, i.status === "critical" ? e = "critical" : i.status === "warning" && e === "healthy" && (e = "warning");
56
- const r = this.generateRecommendations(t);
48
+ function c() {
49
+ const o = {};
50
+ let s = "healthy";
51
+ for (const [i, u] of e)
52
+ o[i] = { ...u }, u.status === "critical" ? s = "critical" : u.status === "warning" && s === "healthy" && (s = "warning");
57
53
  return {
58
- overall: e,
59
- metrics: t,
54
+ overall: s,
55
+ metrics: o,
60
56
  timestamp: Date.now(),
61
- recommendations: r
57
+ recommendations: z(o)
62
58
  };
63
59
  }
64
- /**
65
- * Generate actionable recommendations based on metrics
66
- */
67
- generateRecommendations(t) {
68
- const e = [];
69
- return t.memoryUsage?.status !== "healthy" && e.push(
70
- "Consider reducing component complexity or implementing better memory cleanup"
71
- ), t.averageRenderTime?.status !== "healthy" && e.push(
72
- "Optimize component render functions - consider lazy loading or virtualization"
73
- ), t.jitCacheHitRate?.status !== "healthy" && e.push(
74
- "JIT CSS cache performance is poor - review CSS patterns for optimization"
75
- ), t.componentErrorRate?.status !== "healthy" && e.push(
76
- "High component error rate detected - review error handling and component logic"
77
- ), t.activeReactiveStates?.status !== "healthy" && e.push(
78
- "High number of reactive states - consider state consolidation or cleanup"
79
- ), t.memoryLeakIndicator?.status !== "healthy" && e.push(
80
- "Potential memory leak detected - review component cleanup and event listener management"
81
- ), e;
60
+ function d() {
61
+ if ("memory" in performance && performance.memory) {
62
+ const o = performance.memory;
63
+ h("memoryUsage", o.usedJSHeapSize);
64
+ const s = e.get("memoryUsage");
65
+ if (s && s.history.length > 1) {
66
+ const i = s.history[s.history.length - 2], u = s.history[s.history.length - 1];
67
+ h("memoryGrowthRate", Math.max(0, u - i));
68
+ }
69
+ }
82
70
  }
83
- /**
84
- * Start periodic health monitoring
85
- */
86
- startMonitoring() {
87
- typeof window > "u" || (this.intervalId = window.setInterval(() => {
88
- this.performHealthCheck();
89
- }, this.checkInterval));
71
+ function w(o) {
72
+ for (const s of t)
73
+ try {
74
+ s(o);
75
+ } catch (i) {
76
+ y("Error in health monitor listener:", i);
77
+ }
90
78
  }
91
- /**
92
- * Perform comprehensive health check
93
- */
94
- performHealthCheck() {
95
- this.updateMemoryMetrics();
96
- const t = this.getHealthReport();
97
- this.notifyListeners(t), t.overall === "critical" ? o(
79
+ function S() {
80
+ d();
81
+ const o = c();
82
+ w(o), o.overall === "critical" ? y(
98
83
  "🚨 Runtime Health: Critical issues detected",
99
- t.recommendations
100
- ) : t.overall === "warning" && h(
84
+ o.recommendations
85
+ ) : o.overall === "warning" && O(
101
86
  "⚠️ Runtime Health: Performance warnings",
102
- t.recommendations
87
+ o.recommendations
103
88
  );
104
89
  }
105
- /**
106
- * Update memory-related metrics
107
- */
108
- updateMemoryMetrics() {
109
- if ("memory" in performance && performance.memory) {
110
- const t = performance.memory;
111
- this.updateMetric("memoryUsage", t.usedJSHeapSize);
112
- const e = this.metrics.get("memoryUsage");
113
- if (e && e.history.length > 1) {
114
- const r = e.history[e.history.length - 2], i = e.history[e.history.length - 1] - r;
115
- this.updateMetric("memoryGrowthRate", Math.max(0, i));
116
- }
117
- }
118
- }
119
- /**
120
- * Add health report listener
121
- */
122
- addListener(t) {
123
- this.listeners.add(t);
90
+ function _() {
91
+ typeof window > "u" || (r = setInterval(S, D));
124
92
  }
125
- /**
126
- * Remove health report listener
127
- */
128
- removeListener(t) {
129
- this.listeners.delete(t);
93
+ function R() {
94
+ r !== null && (clearInterval(r), r = null);
130
95
  }
131
- /**
132
- * Notify all listeners of health report
133
- */
134
- notifyListeners(t) {
135
- for (const e of this.listeners)
136
- try {
137
- e(t);
138
- } catch (r) {
139
- o("Error in health monitor listener:", r);
140
- }
96
+ function E(o) {
97
+ t.add(o);
141
98
  }
142
- /**
143
- * Stop health monitoring
144
- */
145
- stop() {
146
- this.intervalId !== null && (clearInterval(this.intervalId), this.intervalId = null);
99
+ function H(o) {
100
+ t.delete(o);
147
101
  }
148
- /**
149
- * Get specific metric history for analysis
150
- */
151
- getMetricHistory(t) {
152
- const e = this.metrics.get(t);
153
- return e ? [...e.history] : [];
102
+ function M(o) {
103
+ const s = e.get(o);
104
+ return s ? [...s.history] : [];
154
105
  }
155
- /**
156
- * Clear all metrics history
157
- */
158
- clearHistory() {
159
- for (const t of this.metrics.values())
160
- t.history = [];
106
+ function L() {
107
+ for (const o of e.values()) o.history = [];
161
108
  }
109
+ return a(), _(), {
110
+ updateMetric: h,
111
+ getHealthReport: c,
112
+ addListener: E,
113
+ removeListener: H,
114
+ stop: R,
115
+ getMetricHistory: M,
116
+ clearHistory: L
117
+ };
118
+ }
119
+ let f = null;
120
+ function C() {
121
+ return f || (f = j()), f;
122
+ }
123
+ function W(e, t) {
124
+ C().updateMetric(e, t);
162
125
  }
163
- let s = null;
164
- function c() {
165
- return s || (s = new m()), s;
126
+ function V() {
127
+ return C().getHealthReport();
166
128
  }
167
- function d(n, t) {
168
- c().updateMetric(n, t);
129
+ function N() {
130
+ typeof window > "u" || typeof customElements > "u" || customElements.get("cer-keep-alive") || customElements.define("cer-keep-alive", $());
169
131
  }
170
- function u() {
171
- return c().getHealthReport();
132
+ function $() {
133
+ return class extends HTMLElement {
134
+ /** Preserved component instances keyed by tag[:id]. */
135
+ _cache = /* @__PURE__ */ new Map();
136
+ _slot = null;
137
+ _slotListener = null;
138
+ connectedCallback() {
139
+ this.shadowRoot || this.attachShadow({ mode: "open" }), this.shadowRoot.querySelector("slot") || (this.shadowRoot.innerHTML = "<slot></slot>"), this._slot = this.shadowRoot.querySelector("slot"), this._slot && (this._slotListener = () => this._handleSlotChange(), this._slot.addEventListener("slotchange", this._slotListener), this._handleSlotChange());
140
+ }
141
+ disconnectedCallback() {
142
+ this._slot && this._slotListener && this._slot.removeEventListener("slotchange", this._slotListener), this._slotListener = null;
143
+ }
144
+ /**
145
+ * Evict a cached element by its cache key (`tagName` or `tagName:id`).
146
+ * The evicted element is disconnected and removed from the cache.
147
+ */
148
+ clearCache(t) {
149
+ t ? this._cache.delete(t) : this._cache.clear();
150
+ }
151
+ _handleSlotChange() {
152
+ if (!this._slot) return;
153
+ const t = this._slot.assignedElements({ flatten: !0 });
154
+ for (const r of t) {
155
+ const n = this._buildCacheKey(r);
156
+ if (!this._cache.has(n))
157
+ this._cache.set(n, r);
158
+ else {
159
+ const a = this._cache.get(n);
160
+ if (a !== r)
161
+ try {
162
+ r.parentNode?.replaceChild(a, r);
163
+ } catch {
164
+ this._cache.set(n, r);
165
+ }
166
+ }
167
+ }
168
+ }
169
+ _buildCacheKey(t) {
170
+ const r = t.tagName.toLowerCase(), n = t.getAttribute("id");
171
+ return n ? `${r}:${n}` : r;
172
+ }
173
+ };
174
+ }
175
+ function P() {
176
+ customElements.get("cer-suspense") || v("cer-suspense", () => {
177
+ const { pending: e } = x({ pending: !1 });
178
+ return e ? l`<slot name="fallback"><span>Loading…</span></slot>` : l`<slot></slot>`;
179
+ });
180
+ }
181
+ function q() {
182
+ customElements.get("cer-error-boundary") || v("cer-error-boundary", () => {
183
+ const e = p(!1), t = p("");
184
+ return b((r) => {
185
+ e.value = !0, t.value = r.message;
186
+ }), T({
187
+ _cerHandleChildError: (r) => {
188
+ e.peek() || (e.value = !0, t.value = r instanceof Error ? r.message : String(r));
189
+ },
190
+ reset: () => {
191
+ e.value = !1, t.value = "";
192
+ }
193
+ }), e.value ? l`<slot name="fallback"
194
+ ><div role="alert">
195
+ <strong>Something went wrong.</strong>
196
+ ${t.value ? l`<p>${t.value}</p>` : l``}
197
+ </div></slot
198
+ >` : l`<slot></slot>`;
199
+ });
200
+ }
201
+ function Y() {
202
+ P(), q(), N();
203
+ }
204
+ function Z(e) {
205
+ if (typeof document > "u")
206
+ return { portal: () => {
207
+ }, destroy: () => {
208
+ } };
209
+ if (A())
210
+ return { portal: () => {
211
+ }, destroy: () => {
212
+ } };
213
+ if (k()) {
214
+ const r = I.getOrCreateState(null), n = r.peek();
215
+ if (n !== null)
216
+ return n;
217
+ const a = g(e, () => r.initSilent(null));
218
+ return r.initSilent(a), a;
219
+ }
220
+ return g(e);
221
+ }
222
+ function g(e, t) {
223
+ const r = typeof e == "string" ? document.querySelector(e) : e;
224
+ if (!r)
225
+ return console.warn(
226
+ `[useTeleport] Target "${String(e)}" not found in the document. Teleported content will not be rendered.`
227
+ ), { portal: () => {
228
+ }, destroy: () => {
229
+ } };
230
+ const n = document.createElement("cer-teleport");
231
+ n.dataset.cerTeleport = "", r.appendChild(n);
232
+ const a = {};
233
+ return {
234
+ portal(c) {
235
+ const d = c == null ? [] : Array.isArray(c) ? c : [c];
236
+ m(n, d, void 0, a);
237
+ },
238
+ destroy() {
239
+ try {
240
+ m(n, [], void 0, a);
241
+ } catch {
242
+ }
243
+ n.parentNode && n.parentNode.removeChild(n), t?.();
244
+ }
245
+ };
172
246
  }
173
247
  export {
174
- y as component,
175
- x as computed,
176
- O as css,
177
- z as decodeEntities,
178
- U as flushDOMUpdates,
179
- c as getHealthMonitor,
180
- u as getHealthStatus,
181
- g as html,
182
- k as ref,
183
- T as setDevMode,
184
- E as unsafeHTML,
185
- d as updateHealthMetric,
186
- M as useEmit,
187
- v as useOnAttributeChanged,
188
- w as useOnConnected,
189
- H as useOnDisconnected,
190
- R as useOnError,
191
- S as useProps,
192
- C as useStyle,
193
- L as watch
248
+ ue as ReactiveState,
249
+ v as component,
250
+ he as computed,
251
+ ee as createComposable,
252
+ j as createHealthMonitor,
253
+ Se as css,
254
+ de as decodeEntities,
255
+ Re as devLog,
256
+ fe as flushDOMUpdates,
257
+ k as getCurrentComponentContext,
258
+ C as getHealthMonitor,
259
+ V as getHealthStatus,
260
+ l as html,
261
+ te as inject,
262
+ me as isReactiveState,
263
+ pe as nextTick,
264
+ ne as provide,
265
+ p as ref,
266
+ Y as registerBuiltinComponents,
267
+ q as registerErrorBoundary,
268
+ N as registerKeepAlive,
269
+ P as registerSuspense,
270
+ ye as scheduleWithPriority,
271
+ Ee as setDevMode,
272
+ ge as unsafeHTML,
273
+ W as updateHealthMetric,
274
+ re as useEmit,
275
+ T as useExpose,
276
+ oe as useOnAttributeChanged,
277
+ se as useOnConnected,
278
+ ie as useOnDisconnected,
279
+ b as useOnError,
280
+ x as useProps,
281
+ ae as useSlots,
282
+ ce as useStyle,
283
+ Z as useTeleport,
284
+ ve as watch,
285
+ Ce as watchEffect
194
286
  };
195
287
  //# sourceMappingURL=custom-elements-runtime.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-elements-runtime.es.js","sources":["../src/lib/runtime/monitoring/health-monitor.ts"],"sourcesContent":["/**\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}\n\nexport class HealthMonitor {\n private metrics = new Map<string, HealthMetric>();\n private readonly maxHistorySize = 100;\n private readonly checkInterval = 30000; // 30 seconds\n private intervalId: number | null = null;\n private listeners = new Set<(report: HealthReport) => void>();\n\n constructor() {\n this.initializeMetrics();\n this.startMonitoring();\n }\n\n /**\n * Initialize default health metrics\n */\n private initializeMetrics(): void {\n // Component metrics\n this.addMetric('activeComponents', 0, 1000, []);\n this.addMetric('componentCreateRate', 0, 50, []); // Components per second\n this.addMetric('componentErrorRate', 0, 0.1, []); // Error rate percentage\n\n // Memory metrics\n this.addMetric('memoryUsage', 0, 50 * 1024 * 1024, []); // 50MB threshold\n this.addMetric('memoryGrowthRate', 0, 1024 * 1024, []); // 1MB/check threshold\n\n // Performance metrics\n this.addMetric('averageRenderTime', 0, 16, []); // 16ms for 60fps\n this.addMetric('slowRenderCount', 0, 10, []); // Renders >16ms per check\n this.addMetric('jitCacheHitRate', 100, 80, []); // Cache hit rate percentage\n\n // Reactive system metrics\n this.addMetric('activeReactiveStates', 0, 5000, []);\n this.addMetric('dependencyUpdates', 0, 100, []); // Updates per check\n this.addMetric('memoryLeakIndicator', 0, 0.1, []); // Growth without cleanup\n }\n\n /**\n * Add a new health metric\n */\n private addMetric(\n name: string,\n value: number,\n threshold: number,\n history: number[],\n ): void {\n this.metrics.set(name, {\n name,\n value,\n threshold,\n status: 'healthy',\n lastUpdated: Date.now(),\n history: [...history],\n });\n }\n\n /**\n * Update a specific health metric\n */\n updateMetric(name: string, value: number): void {\n const metric = this.metrics.get(name);\n if (!metric) return;\n\n metric.value = value;\n metric.lastUpdated = Date.now();\n\n // Update history\n metric.history.push(value);\n if (metric.history.length > this.maxHistorySize) {\n metric.history.shift();\n }\n\n // Update status based on threshold\n metric.status = this.calculateStatus(value, metric.threshold, name);\n }\n\n /**\n * Calculate health status based on value and threshold\n */\n private calculateStatus(\n value: number,\n threshold: number,\n metricName: string,\n ): 'healthy' | 'warning' | 'critical' {\n // Special handling for different metric types\n if (metricName === 'jitCacheHitRate') {\n // Lower is worse for cache hit rate\n if (value < threshold * 0.5) return 'critical';\n if (value < threshold) return 'warning';\n return 'healthy';\n }\n\n // Default: higher is worse\n if (value > threshold * 2) return 'critical';\n if (value > threshold) return 'warning';\n return 'healthy';\n }\n\n /**\n * Get current health report\n */\n getHealthReport(): HealthReport {\n const metrics: Record<string, HealthMetric> = {};\n let overallStatus: 'healthy' | 'warning' | 'critical' = 'healthy';\n\n // Collect all metrics\n for (const [name, metric] of this.metrics) {\n metrics[name] = { ...metric };\n\n // Determine overall status (worst metric wins)\n if (metric.status === 'critical') {\n overallStatus = 'critical';\n } else if (metric.status === 'warning' && overallStatus === 'healthy') {\n overallStatus = 'warning';\n }\n }\n\n const recommendations = this.generateRecommendations(metrics);\n\n return {\n overall: overallStatus,\n metrics,\n timestamp: Date.now(),\n recommendations,\n };\n }\n\n /**\n * Generate actionable recommendations based on metrics\n */\n private generateRecommendations(\n metrics: Record<string, HealthMetric>,\n ): string[] {\n const recommendations: string[] = [];\n\n if (metrics.memoryUsage?.status !== 'healthy') {\n recommendations.push(\n 'Consider reducing component complexity or implementing better memory cleanup',\n );\n }\n\n if (metrics.averageRenderTime?.status !== 'healthy') {\n recommendations.push(\n 'Optimize component render functions - consider lazy loading or virtualization',\n );\n }\n\n if (metrics.jitCacheHitRate?.status !== 'healthy') {\n recommendations.push(\n 'JIT CSS cache performance is poor - review CSS patterns for optimization',\n );\n }\n\n if (metrics.componentErrorRate?.status !== 'healthy') {\n recommendations.push(\n 'High component error rate detected - review error handling and component logic',\n );\n }\n\n if (metrics.activeReactiveStates?.status !== 'healthy') {\n recommendations.push(\n 'High number of reactive states - consider state consolidation or cleanup',\n );\n }\n\n if (metrics.memoryLeakIndicator?.status !== 'healthy') {\n recommendations.push(\n 'Potential memory leak detected - review component cleanup and event listener management',\n );\n }\n\n return recommendations;\n }\n\n /**\n * Start periodic health monitoring\n */\n private startMonitoring(): void {\n if (typeof window === 'undefined') return; // Skip in SSR\n\n this.intervalId = window.setInterval(() => {\n this.performHealthCheck();\n }, this.checkInterval);\n }\n\n /**\n * Perform comprehensive health check\n */\n private performHealthCheck(): void {\n // Update memory metrics\n this.updateMemoryMetrics();\n\n // Generate and emit health report\n const report = this.getHealthReport();\n this.notifyListeners(report);\n\n // Log critical issues\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\n /**\n * Update memory-related metrics\n */\n private updateMemoryMetrics(): void {\n if (\n 'memory' in performance &&\n (performance as Record<string, unknown>).memory\n ) {\n const memory = (performance as Record<string, unknown>).memory as {\n usedJSHeapSize: number;\n totalJSHeapSize: number;\n jsHeapSizeLimit: number;\n };\n this.updateMetric('memoryUsage', memory.usedJSHeapSize);\n\n // Calculate memory growth rate\n const memoryMetric = this.metrics.get('memoryUsage');\n if (memoryMetric && memoryMetric.history.length > 1) {\n const previous = memoryMetric.history[memoryMetric.history.length - 2];\n const current = memoryMetric.history[memoryMetric.history.length - 1];\n const growthRate = current - previous;\n this.updateMetric('memoryGrowthRate', Math.max(0, growthRate));\n }\n }\n }\n\n /**\n * Add health report listener\n */\n addListener(listener: (report: HealthReport) => void): void {\n this.listeners.add(listener);\n }\n\n /**\n * Remove health report listener\n */\n removeListener(listener: (report: HealthReport) => void): void {\n this.listeners.delete(listener);\n }\n\n /**\n * Notify all listeners of health report\n */\n private notifyListeners(report: HealthReport): void {\n for (const listener of this.listeners) {\n try {\n listener(report);\n } catch (error) {\n devError('Error in health monitor listener:', error);\n }\n }\n }\n\n /**\n * Stop health monitoring\n */\n stop(): void {\n if (this.intervalId !== null) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n }\n }\n\n /**\n * Get specific metric history for analysis\n */\n getMetricHistory(name: string): number[] {\n const metric = this.metrics.get(name);\n return metric ? [...metric.history] : [];\n }\n\n /**\n * Clear all metrics history\n */\n clearHistory(): void {\n for (const metric of this.metrics.values()) {\n metric.history = [];\n }\n }\n}\n\n// Global health monitor instance\nlet healthMonitor: HealthMonitor | null = null;\n\n/**\n * Get the global health monitor instance\n */\nexport function getHealthMonitor(): HealthMonitor {\n if (!healthMonitor) {\n healthMonitor = new HealthMonitor();\n }\n return healthMonitor;\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 current health status\n */\nexport function getHealthStatus(): HealthReport {\n return getHealthMonitor().getHealthReport();\n}\n"],"names":["HealthMonitor","name","value","threshold","history","metric","metricName","metrics","overallStatus","recommendations","report","devError","devWarn","memory","memoryMetric","previous","growthRate","listener","error","healthMonitor","getHealthMonitor","updateHealthMetric","getHealthStatus"],"mappings":";;;;;AAuBO,MAAMA,EAAc;AAAA,EACjB,8BAAc,IAAA;AAAA,EACL,iBAAiB;AAAA,EACjB,gBAAgB;AAAA;AAAA,EACzB,aAA4B;AAAA,EAC5B,gCAAgB,IAAA;AAAA,EAExB,cAAc;AACZ,SAAK,kBAAA,GACL,KAAK,gBAAA;AAAA,EACP;AAAA;AAAA;AAAA;AAAA,EAKQ,oBAA0B;AAEhC,SAAK,UAAU,oBAAoB,GAAG,KAAM,CAAA,CAAE,GAC9C,KAAK,UAAU,uBAAuB,GAAG,IAAI,CAAA,CAAE,GAC/C,KAAK,UAAU,sBAAsB,GAAG,KAAK,CAAA,CAAE,GAG/C,KAAK,UAAU,eAAe,GAAG,KAAK,OAAO,MAAM,EAAE,GACrD,KAAK,UAAU,oBAAoB,GAAG,OAAO,MAAM,EAAE,GAGrD,KAAK,UAAU,qBAAqB,GAAG,IAAI,CAAA,CAAE,GAC7C,KAAK,UAAU,mBAAmB,GAAG,IAAI,CAAA,CAAE,GAC3C,KAAK,UAAU,mBAAmB,KAAK,IAAI,CAAA,CAAE,GAG7C,KAAK,UAAU,wBAAwB,GAAG,KAAM,CAAA,CAAE,GAClD,KAAK,UAAU,qBAAqB,GAAG,KAAK,CAAA,CAAE,GAC9C,KAAK,UAAU,uBAAuB,GAAG,KAAK,CAAA,CAAE;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA,EAKQ,UACNC,GACAC,GACAC,GACAC,GACM;AACN,SAAK,QAAQ,IAAIH,GAAM;AAAA,MACrB,MAAAA;AAAA,MACA,OAAAC;AAAA,MACA,WAAAC;AAAA,MACA,QAAQ;AAAA,MACR,aAAa,KAAK,IAAA;AAAA,MAClB,SAAS,CAAC,GAAGC,CAAO;AAAA,IAAA,CACrB;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,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AOA,CAAQ;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKQ,gBAAgBP,GAA4B;AAClD,eAAWO,KAAY,KAAK;AAC1B,UAAI;AACF,QAAAA,EAASP,CAAM;AAAA,MACjB,SAASQ,GAAO;AACd,QAAAP,EAAS,qCAAqCO,CAAK;AAAA,MACrD;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA,EAKA,OAAa;AACX,IAAI,KAAK,eAAe,SACtB,cAAc,KAAK,UAAU,GAC7B,KAAK,aAAa;AAAA,EAEtB;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiBjB,GAAwB;AACvC,UAAMI,IAAS,KAAK,QAAQ,IAAIJ,CAAI;AACpC,WAAOI,IAAS,CAAC,GAAGA,EAAO,OAAO,IAAI,CAAA;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA,EAKA,eAAqB;AACnB,eAAWA,KAAU,KAAK,QAAQ,OAAA;AAChC,MAAAA,EAAO,UAAU,CAAA;AAAA,EAErB;AACF;AAGA,IAAIc,IAAsC;AAKnC,SAASC,IAAkC;AAChD,SAAKD,MACHA,IAAgB,IAAInB,EAAA,IAEfmB;AACT;AAKO,SAASE,EAAmBpB,GAAcC,GAAqB;AACpE,EAAAkB,IAAmB,aAAanB,GAAMC,CAAK;AAC7C;AAKO,SAASoB,IAAgC;AAC9C,SAAOF,EAAA,EAAmB,gBAAA;AAC5B;"}
1
+ {"version":3,"file":"custom-elements-runtime.es.js","sources":["../src/lib/runtime/monitoring/health-monitor.ts","../src/lib/keep-alive.ts","../src/lib/runtime/builtin-components.ts","../src/lib/teleport.ts"],"sourcesContent":["/**\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 (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 (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":["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":";;;;;;;AA6CA,MAAMA,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;AAAA,IACF;AAAA,EAAA,GAEAD,EAAQ,sBAAsB,WAAW,aAC3CC,EAAI;AAAA,IACF;AAAA,EAAA,GAEAD,EAAQ,qBAAqB,WAAW,aAC1CC,EAAI;AAAA,IACF;AAAA,EAAA,GAEGA;AACT;AAMO,SAASC,IAA6C;AAC3D,QAAMC,wBAAiB,IAAA,GACjBC,wBAAgB,IAAA;AACtB,MAAIC,IAAoD;AAExD,WAASC,EAAUC,GAAcX,GAAeC,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AyB,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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./logger-DiXdWaF-.cjs");class r extends EventTarget{handlers={};static instance;eventCounters=new Map;static getInstance(){return r.instance||(r.instance=new r),r.instance}emit(t,e){const n=Date.now(),o=this.eventCounters.get(t);if(!o||n-o.window>1e3)this.eventCounters.set(t,{count:1,window:n});else if(o.count++,o.count>50&&o.count>100)return;this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!1,cancelable:!0}));const c=this.handlers[t];c&&c.forEach(l=>{try{l(e)}catch(u){a.devError(`Error in global event handler for "${t}":`,u)}})}on(t,e){return this.handlers[t]||(this.handlers[t]=new Set),this.handlers[t].add(e),()=>this.off(t,e)}off(t,e){const n=this.handlers[t];n&&n.delete(e)}offAll(t){delete this.handlers[t]}listen(t,e,n){return this.addEventListener(t,e,n),()=>this.removeEventListener(t,e)}once(t,e){return new Promise(n=>{const o=this.on(t,c=>{o(),e(c),n(c)})})}getActiveEvents(){return Object.keys(this.handlers).filter(t=>this.handlers[t]&&this.handlers[t].size>0)}clear(){this.handlers={}}getHandlerCount(t){return this.handlers[t]?.size||0}getEventStats(){const t={};for(const[e,n]of this.eventCounters.entries())t[e]={count:n.count,handlersCount:this.getHandlerCount(e)};return t}resetEventCounters(){this.eventCounters.clear()}}const i=new Proxy({},{get(s,t){const e=r.getInstance(),n=e[t];return typeof n=="function"?n.bind(e):n},apply(s,t,e){return r.getInstance().apply(t,e)}}),h=(s,t)=>i.emit(s,t),d=(s,t)=>i.on(s,t),f=(s,t)=>i.off(s,t),g=(s,t)=>i.once(s,t),v=(s,t,e)=>i.listen(s,t,e);exports.GlobalEventBus=r;exports.emit=h;exports.eventBus=i;exports.listen=v;exports.off=f;exports.on=d;exports.once=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./logger-CSALKaYm.cjs");class o extends EventTarget{handlers={};static instance;eventCounters=new Map;static getInstance(){return o.instance||(o.instance=new o),o.instance}emit(t,e){const n=Date.now(),r=this.eventCounters.get(t);if(!r||n-r.window>1e3)this.eventCounters.set(t,{count:1,window:n});else if(r.count++,r.count>50&&r.count>100)return;this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!1,cancelable:!0}));const c=this.handlers[t];c&&c.forEach(u=>{try{u(e)}catch(l){h.devError(`Error in global event handler for "${t}":`,l)}})}on(t,e){return this.handlers[t]||(this.handlers[t]=new Set),this.handlers[t].add(e),()=>this.off(t,e)}off(t,e){const n=this.handlers[t];n&&n.delete(e)}offAll(t){delete this.handlers[t]}listen(t,e,n){return this.addEventListener(t,e,n),()=>this.removeEventListener(t,e)}once(t,e){if(e!==void 0){const n=this.on(t,r=>{n(),e(r)})}else return new Promise(n=>{const r=this.on(t,c=>{r(),n(c)})})}getActiveEvents(){return Object.keys(this.handlers).filter(t=>this.handlers[t]&&this.handlers[t].size>0)}clear(){this.handlers={}}getHandlerCount(t){return this.handlers[t]?.size||0}getEventStats(){const t={};for(const[e,n]of this.eventCounters.entries())t[e]={count:n.count,handlersCount:this.getHandlerCount(e)};return t}resetEventCounters(){this.eventCounters.clear()}}const i=new Proxy({},{get(s,t){const e=o.getInstance(),n=e[t];return typeof n=="function"?n.bind(e):n},apply(){throw new TypeError("eventBus is not a callable function")}}),a=(s,t)=>i.emit(s,t),f=(s,t)=>i.on(s,t),d=(s,t)=>i.off(s,t);function g(s,t){return t!==void 0?i.once(s,t):i.once(s)}const v=(s,t,e)=>i.listen(s,t,e);exports.GlobalEventBus=o;exports.emit=a;exports.eventBus=i;exports.listen=v;exports.off=d;exports.on=f;exports.once=g;
2
2
  //# sourceMappingURL=custom-elements-runtime.event-bus.cjs.js.map