@jasonshimmy/custom-elements-runtime 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +118 -81
  2. package/dist/custom-elements-runtime.cjs.js +3 -3
  3. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  4. package/dist/custom-elements-runtime.es.js +77 -72
  5. package/dist/custom-elements-runtime.es.js.map +1 -1
  6. package/dist/custom-elements-runtime.jit-css.cjs.js +1 -1
  7. package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -1
  8. package/dist/custom-elements-runtime.jit-css.es.js +25 -26
  9. package/dist/custom-elements-runtime.jit-css.es.js.map +1 -1
  10. package/dist/custom-elements-runtime.router.cjs.js +8 -8
  11. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  12. package/dist/custom-elements-runtime.router.es.js +134 -134
  13. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  14. package/dist/custom-elements-runtime.ssr-middleware.cjs.js +2 -0
  15. package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -0
  16. package/dist/custom-elements-runtime.ssr-middleware.es.js +63 -0
  17. package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -0
  18. package/dist/custom-elements-runtime.ssr.cjs.js +3 -1
  19. package/dist/custom-elements-runtime.ssr.cjs.js.map +1 -1
  20. package/dist/custom-elements-runtime.ssr.es.js +137 -39
  21. package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
  22. package/dist/custom-elements-runtime.vite-plugin.cjs.js +1 -1
  23. package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -1
  24. package/dist/custom-elements-runtime.vite-plugin.es.js +81 -49
  25. package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -1
  26. package/dist/hooks-B50HhrHh.cjs +6 -0
  27. package/dist/hooks-B50HhrHh.cjs.map +1 -0
  28. package/dist/hooks-Cze3o-F7.js +1462 -0
  29. package/dist/hooks-Cze3o-F7.js.map +1 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/namespace-helpers-D4wC2-qA.js +61 -0
  32. package/dist/namespace-helpers-D4wC2-qA.js.map +1 -0
  33. package/dist/namespace-helpers-ckeEOxpR.cjs +2 -0
  34. package/dist/namespace-helpers-ckeEOxpR.cjs.map +1 -0
  35. package/dist/router/matcher.d.ts +14 -0
  36. package/dist/runtime/component/factory.d.ts +16 -2
  37. package/dist/runtime/hydration.d.ts +33 -0
  38. package/dist/runtime/ssr-context.d.ts +45 -0
  39. package/dist/runtime/types.d.ts +18 -0
  40. package/dist/runtime/vdom-ssr-dsd.d.ts +58 -0
  41. package/dist/ssr-middleware.d.ts +125 -0
  42. package/dist/ssr.d.ts +95 -33
  43. package/dist/template-compiler-Cshhqxyd.cjs +23 -0
  44. package/dist/template-compiler-Cshhqxyd.cjs.map +1 -0
  45. package/dist/{template-compiler-B5uN1EQw.js → template-compiler-DtpNsqE-.js} +1296 -1283
  46. package/dist/template-compiler-DtpNsqE-.js.map +1 -0
  47. package/dist/vite-plugin.d.ts +94 -4
  48. package/package.json +6 -1
  49. package/dist/helpers-CweFZFWU.js +0 -987
  50. package/dist/helpers-CweFZFWU.js.map +0 -1
  51. package/dist/helpers-DeWjSmOl.cjs +0 -5
  52. package/dist/helpers-DeWjSmOl.cjs.map +0 -1
  53. package/dist/hooks-BrrLKSub.cjs +0 -3
  54. package/dist/hooks-BrrLKSub.cjs.map +0 -1
  55. package/dist/hooks-DyShDHKo.js +0 -403
  56. package/dist/hooks-DyShDHKo.js.map +0 -1
  57. package/dist/namespace-helpers-CnpZ5__p.js +0 -45
  58. package/dist/namespace-helpers-CnpZ5__p.js.map +0 -1
  59. package/dist/namespace-helpers-CyIDtI97.cjs +0 -2
  60. package/dist/namespace-helpers-CyIDtI97.cjs.map +0 -1
  61. package/dist/template-compiler-B5uN1EQw.js.map +0 -1
  62. package/dist/template-compiler-Cx623BSB.cjs +0 -23
  63. package/dist/template-compiler-Cx623BSB.cjs.map +0 -1
@@ -1,987 +0,0 @@
1
- import { a as d, d as w } from "./logger-BvkEbVM4.js";
2
- function N() {
3
- const s = (() => {
4
- try {
5
- return globalThis.process?.env?.NODE_ENV;
6
- } catch {
7
- return;
8
- }
9
- })(), e = (() => {
10
- try {
11
- if (typeof window > "u")
12
- return { vitest: !1, cypress: !1 };
13
- const t = window;
14
- return {
15
- vitest: !!t.__vitest__,
16
- cypress: !!t.Cypress
17
- };
18
- } catch {
19
- return { vitest: !1, cypress: !1 };
20
- }
21
- })();
22
- return {
23
- isTest: s === "test" || e.vitest || e.cypress,
24
- isVitest: e.vitest,
25
- isCypress: e.cypress
26
- };
27
- }
28
- class L {
29
- pendingUpdates = /* @__PURE__ */ new Map();
30
- isFlushScheduled = !1;
31
- isFlushing = !1;
32
- testEnv;
33
- lastCleanup = 0;
34
- CLEANUP_INTERVAL = 300 * 1e3;
35
- // 5 minutes
36
- MAX_PENDING_SIZE = 1e4;
37
- // Prevent memory bloat
38
- // Idle / time-sliced priority support
39
- pendingIdleUpdates = /* @__PURE__ */ new Map();
40
- idleCallbackHandle = null;
41
- constructor() {
42
- this.testEnv = N(), this.schedulePeriodicCleanup();
43
- }
44
- /**
45
- * Schedule an update to be executed in the next microtask
46
- * Uses component identity to deduplicate multiple render requests for the same component
47
- */
48
- schedule(e, n) {
49
- const t = n || e;
50
- this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(t, e), this.isFlushScheduled || this.scheduleFlush();
51
- }
52
- /**
53
- * Schedule the flush operation based on environment
54
- */
55
- scheduleFlush() {
56
- this.isFlushScheduled = !0, this.testEnv.isTest && !this.isFlushing ? this.flush() : queueMicrotask(() => this.flush());
57
- }
58
- /**
59
- * Execute all pending updates with priority ordering
60
- */
61
- flush() {
62
- if (this.isFlushing)
63
- return;
64
- this.isFlushing = !0;
65
- const e = this.pendingUpdates;
66
- this.pendingUpdates = /* @__PURE__ */ new Map(), this.isFlushScheduled = !1;
67
- try {
68
- for (const n of e.values())
69
- try {
70
- n();
71
- } catch (t) {
72
- w("Error in batched update:", t);
73
- }
74
- } finally {
75
- this.isFlushing = !1;
76
- }
77
- }
78
- /**
79
- * Force flush any pending DOM updates immediately. This is useful in
80
- * test environments or callers that require synchronous guarantees after
81
- * state changes. Prefer relying on the scheduler's automatic flush when
82
- * possible; use this only when a caller needs to synchronously observe
83
- * rendered DOM changes.
84
- */
85
- flushImmediately() {
86
- this.pendingUpdates.size !== 0 && (this.isFlushScheduled = !1, this.flush());
87
- }
88
- /**
89
- * Get the number of pending updates
90
- */
91
- get pendingCount() {
92
- return this.pendingUpdates.size;
93
- }
94
- /**
95
- * Check if there are pending updates
96
- */
97
- get hasPendingUpdates() {
98
- return this.pendingUpdates.size > 0;
99
- }
100
- /**
101
- * Check if currently flushing updates
102
- */
103
- get isFlushingUpdates() {
104
- return this.isFlushing;
105
- }
106
- /**
107
- * Schedule periodic cleanup to prevent memory leaks
108
- */
109
- schedulePeriodicCleanup() {
110
- if (this.testEnv.isTest) return;
111
- const e = () => {
112
- this.performPeriodicCleanup(), this.testEnv.isTest || setTimeout(e, this.CLEANUP_INTERVAL);
113
- };
114
- setTimeout(e, this.CLEANUP_INTERVAL);
115
- }
116
- /**
117
- * Perform periodic cleanup of stale entries
118
- */
119
- performPeriodicCleanup() {
120
- const e = Date.now();
121
- e - this.lastCleanup < this.CLEANUP_INTERVAL || (this.pendingUpdates.size > 100 && d(
122
- `Scheduler has ${this.pendingUpdates.size} pending updates. Consider investigating.`
123
- ), this.lastCleanup = e);
124
- }
125
- /**
126
- * Emergency cleanup when pending updates exceed safe limits.
127
- * @param queue - The specific map to trim; defaults to the normal queue.
128
- */
129
- performEmergencyCleanup(e = this.pendingUpdates) {
130
- d(
131
- "Scheduler emergency cleanup: too many pending updates, clearing oldest entries"
132
- );
133
- const n = Array.from(e.entries()), t = Math.floor(n.length / 2);
134
- for (let r = 0; r < t; r++)
135
- e.delete(n[r][0]);
136
- }
137
- /**
138
- * Schedule an update with an explicit priority level.
139
- *
140
- * - `'immediate'` — Runs synchronously before returning.
141
- * - `'normal'` — Default microtask batching (same as `schedule()`).
142
- * - `'idle'` — Deferred to browser idle time via `requestIdleCallback`
143
- * with time-slicing to avoid blocking the main thread.
144
- * Falls back to a 5 ms `setTimeout` when
145
- * `requestIdleCallback` is unavailable (e.g. Safari < 16).
146
- *
147
- * @example Defer a low-priority analytics flush
148
- * ```ts
149
- * scheduleWithPriority(() => flushAnalytics(), 'idle');
150
- * ```
151
- */
152
- scheduleWithPriority(e, n = "normal", t) {
153
- if (n === "immediate") {
154
- try {
155
- e();
156
- } catch (i) {
157
- w("Error in immediate update:", i);
158
- }
159
- return;
160
- }
161
- if (n === "idle") {
162
- const i = t ?? e;
163
- this.pendingIdleUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(this.pendingIdleUpdates), this.pendingIdleUpdates.set(i, e), this.scheduleIdleFlush();
164
- return;
165
- }
166
- const r = t ?? e;
167
- this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(r, e), this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
168
- }
169
- /**
170
- * Schedule a flush of idle-priority updates.
171
- * Uses `requestIdleCallback` when available; falls back to a short `setTimeout`.
172
- */
173
- scheduleIdleFlush() {
174
- if (this.idleCallbackHandle === null) {
175
- if (this.testEnv.isTest) {
176
- this.idleCallbackHandle = setTimeout(() => {
177
- this.idleCallbackHandle = null, this.flushIdleUpdates(null);
178
- }, 0);
179
- return;
180
- }
181
- if (typeof requestIdleCallback < "u") {
182
- const e = requestIdleCallback(
183
- (n) => {
184
- this.idleCallbackHandle = null, this.flushIdleUpdates(n);
185
- },
186
- { timeout: 2e3 }
187
- );
188
- this.idleCallbackHandle = e;
189
- } else
190
- this.idleCallbackHandle = setTimeout(() => {
191
- this.idleCallbackHandle = null;
192
- const e = Date.now();
193
- this.flushIdleUpdates({
194
- timeRemaining: () => Math.max(0, 50 - (Date.now() - e)),
195
- didTimeout: !1
196
- });
197
- }, 5);
198
- }
199
- }
200
- /**
201
- * Process pending idle-priority updates in a time-sliced manner.
202
- * Yields back to the browser when the deadline's `timeRemaining()` reaches
203
- * zero and reschedules any unprocessed work.
204
- */
205
- flushIdleUpdates(e) {
206
- const n = Array.from(this.pendingIdleUpdates.entries());
207
- this.pendingIdleUpdates = /* @__PURE__ */ new Map();
208
- for (let t = 0; t < n.length; t++) {
209
- if (e && !e.didTimeout && e.timeRemaining() <= 0) {
210
- for (let r = t; r < n.length; r++)
211
- this.pendingIdleUpdates.set(n[r][0], n[r][1]);
212
- this.scheduleIdleFlush();
213
- return;
214
- }
215
- try {
216
- n[t][1]();
217
- } catch (r) {
218
- w("Error in idle update:", r);
219
- }
220
- }
221
- }
222
- }
223
- const p = new L();
224
- function x(s, e) {
225
- p.schedule(s, e);
226
- }
227
- function V(s, e = "normal", n) {
228
- p.scheduleWithPriority(s, e, n);
229
- }
230
- function q() {
231
- p.flushImmediately();
232
- }
233
- function $() {
234
- return new Promise((s) => {
235
- let n = 0;
236
- for (; p.hasPendingUpdates && n < 100; )
237
- p.flushImmediately(), n++;
238
- n >= 100 && d(
239
- "[nextTick] Maximum flush iterations reached — possible circular update loop. Check for watchers or computed values that unconditionally mutate reactive state."
240
- ), queueMicrotask(s);
241
- });
242
- }
243
- const T = /* @__PURE__ */ new WeakSet();
244
- class P {
245
- static cache = /* @__PURE__ */ new WeakMap();
246
- static arrayHandlerCache = /* @__PURE__ */ new WeakMap();
247
- static objectHandlerCache = /* @__PURE__ */ new WeakMap();
248
- /**
249
- * Get or create a reactive proxy for an object
250
- */
251
- static getOrCreateProxy(e, n, t = !1) {
252
- const r = this.cache.get(e);
253
- if (r)
254
- return r;
255
- const i = t ? this.getOrCreateArrayHandler(n) : this.getOrCreateObjectHandler(n), a = new Proxy(e, i);
256
- try {
257
- A.markAsProxy(a);
258
- } catch {
259
- }
260
- return this.cache.set(e, a), a;
261
- }
262
- /**
263
- * Get or create a cached array handler
264
- */
265
- static getOrCreateArrayHandler(e) {
266
- if (!this.arrayHandlerCache.has(e)) {
267
- const n = {
268
- get: (t, r, i) => {
269
- const a = Reflect.get(t, r, i);
270
- return typeof a == "function" && typeof r == "string" && [
271
- "push",
272
- "pop",
273
- "shift",
274
- "unshift",
275
- "splice",
276
- "sort",
277
- "reverse",
278
- "fill",
279
- "copyWithin"
280
- ].includes(r) ? function(...l) {
281
- const h = a.apply(t, l);
282
- return e.triggerUpdate(), h;
283
- } : a !== null && typeof a == "object" && typeof r == "string" ? e.makeReactiveValue(a) : a;
284
- },
285
- set: (t, r, i) => (t[r] = e.makeReactiveValue(i), e.triggerUpdate(), !0),
286
- deleteProperty: (t, r) => (delete t[r], e.triggerUpdate(), !0)
287
- };
288
- this.arrayHandlerCache.set(e, n);
289
- }
290
- return this.arrayHandlerCache.get(e);
291
- }
292
- /**
293
- * Get or create a cached object handler
294
- */
295
- static getOrCreateObjectHandler(e) {
296
- if (!this.objectHandlerCache.has(e)) {
297
- const n = {
298
- get: (t, r, i) => {
299
- const a = Reflect.get(t, r, i);
300
- return a !== null && typeof a == "object" && typeof r == "string" ? e.makeReactiveValue(a) : a;
301
- },
302
- set: (t, r, i) => (t[r] = e.makeReactiveValue(i), e.triggerUpdate(), !0),
303
- deleteProperty: (t, r) => (delete t[r], e.triggerUpdate(), !0)
304
- };
305
- this.objectHandlerCache.set(e, n);
306
- }
307
- return this.objectHandlerCache.get(e);
308
- }
309
- /**
310
- * Check if an object already has a cached proxy
311
- */
312
- static hasProxy(e) {
313
- return this.cache.has(e);
314
- }
315
- /**
316
- * Clear all cached proxies (useful for testing)
317
- */
318
- static clear() {
319
- this.cache = /* @__PURE__ */ new WeakMap(), this.arrayHandlerCache = /* @__PURE__ */ new WeakMap(), this.objectHandlerCache = /* @__PURE__ */ new WeakMap();
320
- }
321
- /**
322
- * Get cache statistics (for debugging)
323
- * Note: WeakMap doesn't provide size, so this is limited
324
- */
325
- static getStats() {
326
- return {
327
- hasCachedProxies: this.cache instanceof WeakMap
328
- };
329
- }
330
- }
331
- class A {
332
- // Cache a stable reactiveContext object keyed by onUpdate -> makeReactive
333
- // This allows handler caches in ReactiveProxyCache to reuse handlers
334
- // for identical reactive contexts instead of creating a new context object
335
- // on each createReactiveProxy call.
336
- static contextCache = /* @__PURE__ */ new WeakMap();
337
- /**
338
- * Create an optimized reactive proxy with minimal overhead
339
- */
340
- static createReactiveProxy(e, n, t) {
341
- try {
342
- if (T.has(e)) return e;
343
- } catch {
344
- }
345
- const r = Array.isArray(e);
346
- let i = this.contextCache.get(n);
347
- i || (i = /* @__PURE__ */ new WeakMap(), this.contextCache.set(n, i));
348
- let a = i.get(t);
349
- return a || (a = {
350
- triggerUpdate: n,
351
- makeReactiveValue: t
352
- }, i.set(t, a)), P.getOrCreateProxy(e, a, r);
353
- }
354
- /**
355
- * Mark an object as a proxy (for optimization)
356
- */
357
- static markAsProxy(e) {
358
- if (e)
359
- try {
360
- T.add(e);
361
- } catch {
362
- }
363
- }
364
- }
365
- let C = !1;
366
- function R() {
367
- return C;
368
- }
369
- function X() {
370
- C && d(
371
- "[CER] beginDiscoveryRender() called while a discovery render is already active. This usually means a component was registered inside another component's render function. Ensure component() calls are at module top-level."
372
- ), C = !0;
373
- }
374
- function G() {
375
- C = !1;
376
- }
377
- let F = 0;
378
- function S(s) {
379
- return `${s}-${++F}`;
380
- }
381
- class W {
382
- // Use a stack to support nested callers (component render -> watcher)
383
- // so that watchers can temporarily become the "current component" while
384
- // establishing dependencies without clobbering the outer component id.
385
- currentComponentStack = [];
386
- // Consolidated component data: stores dependencies, render function, state index, and last warning time
387
- componentData = /* @__PURE__ */ new Map();
388
- // Flat storage: compound key `${componentId}:${stateIndex}` -> ReactiveState
389
- stateStorage = /* @__PURE__ */ new Map();
390
- trackingDisabled = !1;
391
- /**
392
- * Set the current component being rendered for dependency tracking
393
- */
394
- setCurrentComponent(e, n) {
395
- if (this.currentComponentStack.push(e), !this.componentData.has(e))
396
- this.componentData.set(e, {
397
- dependencies: /* @__PURE__ */ new Set(),
398
- renderFn: n,
399
- stateIndex: 0,
400
- lastWarnTime: 0,
401
- watchers: /* @__PURE__ */ new Map()
402
- });
403
- else {
404
- const t = this.componentData.get(e);
405
- if (t.watchers && t.watchers.size) {
406
- for (const r of t.watchers.values())
407
- try {
408
- this.cleanup(r);
409
- } catch {
410
- }
411
- t.watchers.clear();
412
- }
413
- t.renderFn = n, t.stateIndex = 0;
414
- }
415
- }
416
- /**
417
- * Clear the current component after rendering
418
- */
419
- clearCurrentComponent() {
420
- this.currentComponentStack.pop();
421
- }
422
- /**
423
- * Get the current component id (top of stack) or null
424
- */
425
- getCurrentComponentId() {
426
- return this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
427
- }
428
- /**
429
- * Register a watcher id under a component so it can be cleaned up on re-render
430
- */
431
- registerWatcher(e, n) {
432
- const t = this.componentData.get(e);
433
- t && t.watchers.set(n, n);
434
- }
435
- /**
436
- * Temporarily disable dependency tracking
437
- */
438
- disableTracking() {
439
- this.trackingDisabled = !0;
440
- }
441
- /**
442
- * Re-enable dependency tracking
443
- */
444
- enableTracking() {
445
- this.trackingDisabled = !1;
446
- }
447
- /**
448
- * Check if a component is currently rendering
449
- */
450
- isRenderingComponent() {
451
- return this.currentComponentStack.length > 0;
452
- }
453
- /**
454
- * Return whether we should emit a render-time warning for the current component.
455
- * This throttles warnings to avoid spamming the console for legitimate rapid updates.
456
- */
457
- shouldEmitRenderWarning() {
458
- const e = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
459
- if (!e) return !0;
460
- const n = this.componentData.get(e);
461
- if (!n) return !0;
462
- const t = Date.now();
463
- return t - n.lastWarnTime < 1e3 ? !1 : (n.lastWarnTime = t, !0);
464
- }
465
- /**
466
- * Execute a function with tracking disabled
467
- */
468
- withoutTracking(e) {
469
- const n = this.trackingDisabled;
470
- this.trackingDisabled = !0;
471
- try {
472
- return e();
473
- } finally {
474
- this.trackingDisabled = n;
475
- }
476
- }
477
- /**
478
- * Get or create a state instance for the current component
479
- */
480
- getOrCreateState(e) {
481
- const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
482
- if (!n)
483
- return new _(e);
484
- const t = this.componentData.get(n);
485
- if (!t)
486
- return new _(e);
487
- const r = `${n}:${t.stateIndex++}`;
488
- let i = this.stateStorage.get(r);
489
- return i || (i = new _(e), this.stateStorage.set(r, i)), i;
490
- }
491
- /**
492
- * Track a dependency for the current component
493
- */
494
- trackDependency(e) {
495
- if (this.trackingDisabled) return;
496
- const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
497
- if (!n) return;
498
- const t = this.componentData.get(n);
499
- t && (t.dependencies.add(e), e.addDependent(n));
500
- }
501
- /**
502
- * Re-register all reactive dependencies that `fromId` tracks into the
503
- * currently-active (outer) component context.
504
- *
505
- * Used by `computed()` to forward its dep-set to the consuming component
506
- * without re-executing the getter function a second time.
507
- */
508
- propagateDependencies(e) {
509
- if (this.trackingDisabled) return;
510
- const n = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
511
- if (!n || n === e) return;
512
- const t = this.componentData.get(e);
513
- if (!t) return;
514
- const r = this.componentData.get(n);
515
- if (r)
516
- for (const i of t.dependencies)
517
- r.dependencies.add(i), i.addDependent(n);
518
- }
519
- /**
520
- * Trigger updates for all components that depend on a state
521
- */
522
- triggerUpdate(e) {
523
- const n = e.getDependents();
524
- for (const t of n) {
525
- const r = this.componentData.get(t);
526
- r && x(r.renderFn, t);
527
- }
528
- }
529
- /**
530
- * Clean up component dependencies when component is destroyed
531
- */
532
- cleanup(e) {
533
- const n = this.componentData.get(e);
534
- if (n) {
535
- for (const r of n.dependencies)
536
- r.removeDependent(e);
537
- this.componentData.delete(e);
538
- }
539
- const t = e + ":";
540
- for (const r of this.stateStorage.keys())
541
- r.startsWith(t) && this.stateStorage.delete(r);
542
- }
543
- }
544
- const c = new W();
545
- class _ {
546
- _value;
547
- /** The unwrapped value last assigned — used for Object.is equality checks. */
548
- _rawValue;
549
- dependents = /* @__PURE__ */ new Set();
550
- constructor(e) {
551
- this._rawValue = e, this._value = this.makeReactive(e);
552
- try {
553
- Object.defineProperty(this, /* @__PURE__ */ Symbol.for("@cer/ReactiveState"), {
554
- value: !0,
555
- enumerable: !1,
556
- configurable: !1
557
- });
558
- } catch {
559
- }
560
- }
561
- get value() {
562
- return c.trackDependency(this), this._value;
563
- }
564
- set value(e) {
565
- Object.is(e, this._rawValue) || (c.isRenderingComponent() && c.shouldEmitRenderWarning() && d(
566
- `🚨 State modification detected during render! This can cause infinite loops.
567
- • Move state updates to event handlers
568
- • Use watchEffect/watch for side effects
569
- • Ensure computed properties don't modify state`
570
- ), this._rawValue = e, this._value = this.makeReactive(e), c.triggerUpdate(this));
571
- }
572
- /**
573
- * Read the current value without registering a reactive dependency.
574
- * Useful for internal infrastructure (e.g. stable hook slots) that must
575
- * inspect the stored value without re-triggering the containing component.
576
- * @internal
577
- */
578
- peek() {
579
- return this._value;
580
- }
581
- /**
582
- * Set the initial value without triggering any reactive updates or warnings.
583
- * Only intended for internal/infrastructure use (e.g. storing a stable hook
584
- * handle in a reactive slot without causing a spurious re-render).
585
- * The value is stored as-is without reactive proxy wrapping so that opaque
586
- * objects (e.g. TeleportHandle) are not accidentally instrumented.
587
- * @internal
588
- */
589
- initSilent(e) {
590
- this._rawValue = e, this._value = e;
591
- }
592
- addDependent(e) {
593
- this.dependents.add(e);
594
- }
595
- removeDependent(e) {
596
- this.dependents.delete(e);
597
- }
598
- getDependents() {
599
- return this.dependents;
600
- }
601
- makeReactive(e) {
602
- return e === null || typeof e != "object" || e instanceof Node || e instanceof Element || e instanceof HTMLElement ? e : A.createReactiveProxy(
603
- e,
604
- () => c.triggerUpdate(this),
605
- (n) => this.makeReactive(n)
606
- );
607
- }
608
- }
609
- function Z(s) {
610
- return c.getOrCreateState(
611
- s === void 0 ? null : s
612
- );
613
- }
614
- function E(s) {
615
- if (!s || typeof s != "object") return !1;
616
- try {
617
- const e = /* @__PURE__ */ Symbol.for("@cer/ReactiveState");
618
- return Object.prototype.hasOwnProperty.call(s, e);
619
- } catch {
620
- return !1;
621
- }
622
- }
623
- function B(s) {
624
- let e, n = !0;
625
- const t = S("computed"), r = () => {
626
- n = !0;
627
- };
628
- try {
629
- const i = c.getCurrentComponentId();
630
- i && c.registerWatcher(i, t);
631
- } catch {
632
- }
633
- return c.setCurrentComponent(t, r), e = s(), c.clearCurrentComponent(), n = !1, {
634
- get value() {
635
- return n && (c.setCurrentComponent(t, r), e = s(), c.clearCurrentComponent(), n = !1), c.propagateDependencies(t), e;
636
- }
637
- };
638
- }
639
- function K(s) {
640
- if (R()) return () => {
641
- };
642
- const e = S("effect");
643
- try {
644
- const t = c.getCurrentComponentId();
645
- t && c.registerWatcher(t, e);
646
- } catch {
647
- }
648
- const n = () => {
649
- c.setCurrentComponent(e, n);
650
- try {
651
- s();
652
- } finally {
653
- c.clearCurrentComponent();
654
- }
655
- };
656
- return n(), () => {
657
- c.cleanup(e);
658
- };
659
- }
660
- const b = 50;
661
- function k(s, e = /* @__PURE__ */ new WeakMap(), n = 0) {
662
- if (s === null || typeof s != "object") return s;
663
- const t = s;
664
- if (e.has(t)) return e.get(t);
665
- if (n > b)
666
- return d(
667
- `[watch] Deep clone exceeded ${b} nesting levels. Returning a reference at this depth instead of cloning further. Consider restructuring your state or switching to a shallow watch.`
668
- ), s;
669
- if (typeof Node < "u" && t instanceof Node) return s;
670
- if (t instanceof Date) return new Date(t.getTime());
671
- if (Array.isArray(t)) {
672
- const i = [];
673
- e.set(t, i);
674
- for (let a = 0; a < t.length; a++)
675
- i.push(k(t[a], e, n + 1));
676
- return i;
677
- }
678
- const r = {};
679
- e.set(t, r);
680
- for (const i of Object.keys(t))
681
- try {
682
- r[i] = k(
683
- t[i],
684
- e,
685
- n + 1
686
- );
687
- } catch {
688
- }
689
- return r;
690
- }
691
- function J(s, e, n) {
692
- if (R()) return () => {
693
- };
694
- let t;
695
- const r = E(s) ? () => s.value : s, i = S("watch");
696
- try {
697
- const o = c.getCurrentComponentId();
698
- o && c.registerWatcher(o, i);
699
- } catch {
700
- }
701
- const a = () => {
702
- c.setCurrentComponent(i, a);
703
- const o = r();
704
- if (c.clearCurrentComponent(), n?.deep) {
705
- const l = c.withoutTracking(
706
- () => k(o)
707
- );
708
- e(l, t), t = l;
709
- } else o !== t && (e(o, t), t = o);
710
- };
711
- return c.setCurrentComponent(i, a), t = r(), c.clearCurrentComponent(), n?.deep && (t = c.withoutTracking(() => k(t))), n && n.immediate && e(t, void 0), () => {
712
- c.cleanup(i);
713
- };
714
- }
715
- const Q = (s) => {
716
- try {
717
- s();
718
- } catch {
719
- }
720
- }, g = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), M = 500;
721
- let f, U, v = !1, D = !1, I;
722
- const O = !!globalThis.process?.versions?.node;
723
- function Y(s) {
724
- if (g.has(s))
725
- return g.get(s);
726
- const e = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
727
- return g.size < M && g.set(s, e), e;
728
- }
729
- function ee(s) {
730
- if (m.has(s))
731
- return m.get(s);
732
- const e = s.replace(/-([a-z])/g, (n, t) => t.toUpperCase());
733
- return m.size < M && m.set(s, e), e;
734
- }
735
- function te(s) {
736
- if (typeof s == "string") {
737
- if (y.has(s))
738
- return y.get(s);
739
- const e = s.replace(
740
- /[&<>"']/g,
741
- (n) => ({
742
- "&": "&amp;",
743
- "<": "&lt;",
744
- ">": "&gt;",
745
- '"': "&quot;",
746
- "'": "&#39;"
747
- })[n]
748
- );
749
- return e !== s && y.size < M && y.set(s, e), e;
750
- }
751
- return s;
752
- }
753
- function u(s) {
754
- if (!s) return "";
755
- const e = String(s);
756
- if (typeof document < "u" && typeof document.createElement == "function") {
757
- const o = e.replace(/</g, "").replace(/>/g, ""), l = I || (I = document.createElement("div"));
758
- try {
759
- u._el = l;
760
- } catch {
761
- }
762
- return l.innerHTML = o, (l.textContent || "").replace(new RegExp("", "g"), "<").replace(new RegExp("", "g"), ">");
763
- }
764
- const n = {
765
- lt: "<",
766
- gt: ">",
767
- amp: "&",
768
- quot: '"',
769
- apos: "'",
770
- nbsp: " "
771
- }, t = f ?? u._namedMap;
772
- let r = t;
773
- if (!r && O)
774
- try {
775
- const i = globalThis.require;
776
- if (typeof i == "function") {
777
- const a = [
778
- "@jasonshimmy/custom-elements-runtime/entities.json",
779
- // installed package export
780
- "../../entities.json",
781
- // dist/runtime -> ../../entities.json
782
- "../../../entities.json",
783
- // src/lib/runtime -> ../../../entities.json
784
- "../entities.json",
785
- "./entities.json"
786
- ];
787
- for (const o of a)
788
- try {
789
- const l = i(o);
790
- if (l && typeof l == "object") {
791
- r = l;
792
- break;
793
- }
794
- } catch {
795
- }
796
- }
797
- } catch {
798
- }
799
- if (!r) {
800
- r = n, v = !0;
801
- try {
802
- u._usedFallback = !0;
803
- } catch {
804
- }
805
- const i = u._namedMapLoader ?? U;
806
- i && i().then((a) => {
807
- f = a;
808
- try {
809
- u._namedMap = a;
810
- } catch {
811
- }
812
- }).catch(() => {
813
- });
814
- }
815
- if ((v || u._usedFallback) && !(D || u._warnedFallback)) {
816
- D = !0;
817
- try {
818
- u._warnedFallback = !0;
819
- } catch {
820
- }
821
- try {
822
- d(
823
- "decodeEntities: using small SSR fallback entity map. Register the full entities.json via registerEntityMap(entities) on the server to enable full HTML5 named-entity decoding."
824
- );
825
- } catch {
826
- }
827
- }
828
- return e.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (i, a) => {
829
- if (a.charCodeAt(0) === 35) {
830
- const h = (a.charAt(1) || "").toLowerCase() === "x" ? parseInt(a.slice(2), 16) : parseInt(a.slice(1), 10);
831
- return Number.isNaN(h) ? `&${a};` : String.fromCodePoint(h);
832
- }
833
- const o = r[a] ?? (t && t[a]);
834
- return o !== void 0 ? o : `&${a};`;
835
- });
836
- }
837
- async function H() {
838
- const s = [
839
- "@jasonshimmy",
840
- "custom-elements-runtime",
841
- "entities.json"
842
- ].join("/");
843
- try {
844
- const e = await import(
845
- /* @vite-ignore */
846
- s
847
- );
848
- return e && (e.default || e);
849
- } catch {
850
- try {
851
- const e = [
852
- s,
853
- // try package export via dynamic import too (best for installed packages)
854
- "./entities.json",
855
- "../../entities.json",
856
- "../../../entities.json"
857
- ];
858
- for (const n of e)
859
- try {
860
- const t = await import(
861
- /* @vite-ignore */
862
- n
863
- );
864
- if (t)
865
- return t && (t.default || t);
866
- } catch {
867
- }
868
- return {
869
- lt: "<",
870
- gt: ">",
871
- amp: "&",
872
- quot: '"',
873
- apos: "'",
874
- nbsp: " "
875
- };
876
- } catch {
877
- return {
878
- lt: "<",
879
- gt: ">",
880
- amp: "&",
881
- quot: '"',
882
- apos: "'",
883
- nbsp: " "
884
- };
885
- }
886
- }
887
- }
888
- U = H;
889
- u._namedMapLoader = H;
890
- function ne(s, e) {
891
- !s || typeof s != "object" || f && !e?.overwrite || (f = s);
892
- }
893
- function se() {
894
- f = void 0;
895
- }
896
- function re(s) {
897
- const e = String(s);
898
- return { __unsafeHTML: e, __rawHTML: e };
899
- }
900
- function ie(s) {
901
- return !!s && (typeof s.__unsafeHTML == "string" || typeof s.__rawHTML == "string");
902
- }
903
- function ae(s, e) {
904
- if (typeof e == "string") {
905
- if (e === "") return;
906
- const n = e.split(".");
907
- let t = s;
908
- for (const r of n) {
909
- if (t == null || typeof t != "object") {
910
- t = void 0;
911
- break;
912
- }
913
- t = t[r];
914
- }
915
- return E(t) ? t.value : t;
916
- }
917
- return e;
918
- }
919
- function ce(s, e, n) {
920
- const t = String(e).split("."), r = t.pop();
921
- if (!r) return;
922
- const i = t.reduce(
923
- (a, o) => (a[o] == null && (a[o] = {}), a[o]),
924
- s
925
- );
926
- E(i[r]) ? i[r].value = n : i[r] = n;
927
- }
928
- function j(s) {
929
- try {
930
- if (s && typeof s == "object") {
931
- if (E(s)) return s.value;
932
- if ("value" in s) {
933
- const e = s.value;
934
- return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : s;
935
- }
936
- }
937
- } catch {
938
- }
939
- return s;
940
- }
941
- function oe(s) {
942
- const e = j(s);
943
- if (e == null) return null;
944
- const n = typeof e;
945
- return n === "string" || n === "number" || n === "boolean" ? String(e) : null;
946
- }
947
- function le(s) {
948
- if (!s || typeof s != "string") return !1;
949
- if (s === "class" || s.endsWith("Class")) return !0;
950
- if (s.includes("-"))
951
- try {
952
- if (s.split("-").some((n) => n === "class")) return !0;
953
- } catch {
954
- }
955
- return !1;
956
- }
957
- export {
958
- R as A,
959
- _ as R,
960
- c as a,
961
- K as b,
962
- B as c,
963
- u as d,
964
- te as e,
965
- q as f,
966
- se as g,
967
- ne as h,
968
- E as i,
969
- ae as j,
970
- ce as k,
971
- H as l,
972
- Q as m,
973
- $ as n,
974
- oe as o,
975
- ee as p,
976
- le as q,
977
- Z as r,
978
- V as s,
979
- Y as t,
980
- re as u,
981
- x as v,
982
- J as w,
983
- X as x,
984
- G as y,
985
- ie as z
986
- };
987
- //# sourceMappingURL=helpers-CweFZFWU.js.map