sibujs 1.1.0 → 1.3.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 (94) hide show
  1. package/README.md +29 -25
  2. package/dist/browser.cjs +804 -2
  3. package/dist/browser.d.cts +591 -1
  4. package/dist/browser.d.ts +591 -1
  5. package/dist/browser.js +50 -8
  6. package/dist/build.cjs +706 -161
  7. package/dist/build.js +21 -12
  8. package/dist/cdn.global.js +188 -7
  9. package/dist/chunk-2BYQDGN3.js +742 -0
  10. package/dist/chunk-32DY64NT.js +282 -0
  11. package/dist/chunk-3AIRKM3B.js +1263 -0
  12. package/dist/chunk-3X2YG6YM.js +505 -0
  13. package/dist/chunk-5X6PP2UK.js +28 -0
  14. package/dist/chunk-77L6NL3X.js +1097 -0
  15. package/dist/chunk-B7SWRFUT.js +332 -0
  16. package/dist/chunk-BGN5ZMP4.js +26 -0
  17. package/dist/chunk-BTU3TJDS.js +365 -0
  18. package/dist/chunk-CHF5OHIA.js +61 -0
  19. package/dist/chunk-CMBFNA7L.js +27 -0
  20. package/dist/chunk-DAHRH4ON.js +331 -0
  21. package/dist/chunk-EBGIRKQY.js +616 -0
  22. package/dist/chunk-EUZND3CB.js +27 -0
  23. package/dist/chunk-F3FA4F32.js +292 -0
  24. package/dist/chunk-GCOK2LC3.js +282 -0
  25. package/dist/chunk-JAKHTMQU.js +1000 -0
  26. package/dist/chunk-JCI5M6U6.js +956 -0
  27. package/dist/chunk-KQPDEVVS.js +398 -0
  28. package/dist/chunk-NEKUBFPT.js +60 -0
  29. package/dist/chunk-NYVAC6P5.js +37 -0
  30. package/dist/chunk-OUZZEE4S.js +365 -0
  31. package/dist/chunk-P6W3STU4.js +2249 -0
  32. package/dist/chunk-PTQJDMRT.js +146 -0
  33. package/dist/chunk-QWZG56ET.js +2744 -0
  34. package/dist/chunk-TSOKIX5Z.js +654 -0
  35. package/dist/chunk-VMVDTCXB.js +712 -0
  36. package/dist/chunk-VRW3FULF.js +725 -0
  37. package/dist/chunk-WZSPOOER.js +84 -0
  38. package/dist/chunk-YT6HQ6AM.js +14 -0
  39. package/dist/chunk-ZD6OAMTH.js +277 -0
  40. package/dist/contracts-DDrwxvJ-.d.cts +245 -0
  41. package/dist/contracts-DDrwxvJ-.d.ts +245 -0
  42. package/dist/data.cjs +35 -2
  43. package/dist/data.d.cts +7 -0
  44. package/dist/data.d.ts +7 -0
  45. package/dist/data.js +9 -8
  46. package/dist/devtools.cjs +122 -0
  47. package/dist/devtools.d.cts +69 -461
  48. package/dist/devtools.d.ts +69 -461
  49. package/dist/devtools.js +127 -6
  50. package/dist/ecosystem.cjs +68 -23
  51. package/dist/ecosystem.d.cts +1 -1
  52. package/dist/ecosystem.d.ts +1 -1
  53. package/dist/ecosystem.js +10 -9
  54. package/dist/extras.cjs +1252 -82
  55. package/dist/extras.d.cts +5 -5
  56. package/dist/extras.d.ts +5 -5
  57. package/dist/extras.js +69 -24
  58. package/dist/index.cjs +708 -161
  59. package/dist/index.d.cts +397 -17
  60. package/dist/index.d.ts +397 -17
  61. package/dist/index.js +39 -17
  62. package/dist/introspect-BumjnBKr.d.cts +477 -0
  63. package/dist/introspect-CZrlcaYy.d.ts +477 -0
  64. package/dist/introspect-Cb0zgpi2.d.cts +477 -0
  65. package/dist/introspect-Y2xNXGSf.d.ts +477 -0
  66. package/dist/motion.js +4 -4
  67. package/dist/patterns.cjs +51 -2
  68. package/dist/patterns.d.cts +18 -8
  69. package/dist/patterns.d.ts +18 -8
  70. package/dist/patterns.js +7 -7
  71. package/dist/performance.js +4 -4
  72. package/dist/plugins.cjs +473 -98
  73. package/dist/plugins.d.cts +27 -4
  74. package/dist/plugins.d.ts +27 -4
  75. package/dist/plugins.js +156 -37
  76. package/dist/ssr-4PBXAOO3.js +40 -0
  77. package/dist/ssr-Do_SiVoL.d.cts +201 -0
  78. package/dist/ssr-Do_SiVoL.d.ts +201 -0
  79. package/dist/ssr.cjs +357 -77
  80. package/dist/ssr.d.cts +10 -1
  81. package/dist/ssr.d.ts +10 -1
  82. package/dist/ssr.js +13 -10
  83. package/dist/tagFactory-DaJ0YWX6.d.cts +47 -0
  84. package/dist/tagFactory-DaJ0YWX6.d.ts +47 -0
  85. package/dist/testing.cjs +233 -2
  86. package/dist/testing.d.cts +42 -1
  87. package/dist/testing.d.ts +42 -1
  88. package/dist/testing.js +129 -2
  89. package/dist/ui.cjs +374 -3
  90. package/dist/ui.d.cts +252 -2
  91. package/dist/ui.d.ts +252 -2
  92. package/dist/ui.js +328 -8
  93. package/dist/widgets.js +7 -7
  94. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -22,12 +22,14 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  DynamicComponent: () => DynamicComponent,
24
24
  ErrorBoundary: () => ErrorBoundary,
25
+ ErrorDisplay: () => ErrorDisplay,
25
26
  Fragment: () => Fragment,
26
27
  KeepAlive: () => KeepAlive,
27
28
  Loading: () => Loading,
28
29
  Portal: () => Portal,
29
30
  SVG_NS: () => SVG_NS,
30
31
  Suspense: () => Suspense,
32
+ __resetIdCounter: () => __resetIdCounter,
31
33
  a: () => a,
32
34
  abbr: () => abbr,
33
35
  action: () => action,
@@ -36,6 +38,7 @@ __export(index_exports, {
36
38
  array: () => array,
37
39
  article: () => article,
38
40
  aside: () => aside,
41
+ asyncDerived: () => asyncDerived,
39
42
  audio: () => audio,
40
43
  autoResize: () => autoResize,
41
44
  b: () => b,
@@ -63,12 +66,14 @@ __export(index_exports, {
63
66
  colgroup: () => colgroup,
64
67
  context: () => context,
65
68
  copyOnClick: () => copyOnClick,
69
+ createId: () => createId,
66
70
  customElement: () => customElement,
67
71
  data: () => data,
68
72
  datalist: () => datalist,
69
73
  dd: () => dd,
70
74
  deepEqual: () => deepEqual,
71
75
  deepSignal: () => deepSignal,
76
+ defer: () => defer,
72
77
  defs: () => defs,
73
78
  del: () => del,
74
79
  derived: () => derived,
@@ -136,6 +141,7 @@ __export(index_exports, {
136
141
  meter: () => meter,
137
142
  mount: () => mount,
138
143
  nav: () => nav,
144
+ nextTick: () => nextTick,
139
145
  noscript: () => noscript,
140
146
  object: () => object,
141
147
  ol: () => ol,
@@ -181,6 +187,8 @@ __export(index_exports, {
181
187
  span: () => span,
182
188
  stop: () => stop,
183
189
  store: () => store,
190
+ strict: () => strict,
191
+ strictEffect: () => strictEffect,
184
192
  strong: () => strong,
185
193
  style: () => style,
186
194
  sub: () => sub,
@@ -202,6 +210,7 @@ __export(index_exports, {
202
210
  title: () => title,
203
211
  tr: () => tr,
204
212
  track: () => track2,
213
+ transition: () => transition,
205
214
  trapFocus: () => trapFocus,
206
215
  tspan: () => tspan,
207
216
  u: () => u,
@@ -521,7 +530,20 @@ function cleanup(subscriber) {
521
530
 
522
531
  // src/reactivity/bindAttribute.ts
523
532
  var _isDev3 = isDev();
533
+ function isEventHandlerAttr(name) {
534
+ if (name.length < 3) return false;
535
+ const lower = name.toLowerCase();
536
+ return lower[0] === "o" && lower[1] === "n" && lower.charCodeAt(2) >= 97 && lower.charCodeAt(2) <= 122;
537
+ }
524
538
  function bindAttribute(el, attr, getter) {
539
+ if (isEventHandlerAttr(attr)) {
540
+ if (_isDev3)
541
+ devWarn(
542
+ `bindAttribute: refusing to bind event-handler attribute "${attr}". Use on:{ ${attr.slice(2)}: fn } instead.`
543
+ );
544
+ return () => {
545
+ };
546
+ }
525
547
  function commit() {
526
548
  let value;
527
549
  try {
@@ -601,11 +623,11 @@ function bindChildNode(placeholder, getter) {
601
623
  if (_isDev4) devWarn(`bindChildNode: getter threw: ${err instanceof Error ? err.message : String(err)}`);
602
624
  return;
603
625
  }
604
- for (let i2 = 0; i2 < lastNodes.length; i2++) {
605
- const node = lastNodes[i2];
606
- if (node.parentNode) node.parentNode.removeChild(node);
607
- }
608
626
  if (result == null || typeof result === "boolean") {
627
+ for (let i2 = 0; i2 < lastNodes.length; i2++) {
628
+ const node = lastNodes[i2];
629
+ if (node.parentNode) node.parentNode.removeChild(node);
630
+ }
609
631
  lastNodes.length = 0;
610
632
  return;
611
633
  }
@@ -614,24 +636,46 @@ function bindChildNode(placeholder, getter) {
614
636
  lastNodes.length = 0;
615
637
  return;
616
638
  }
617
- const anchor = placeholder.nextSibling;
618
- let count = 0;
639
+ let newNodes;
619
640
  if (Array.isArray(result)) {
620
- if (lastNodes.length < result.length) lastNodes = new Array(result.length);
641
+ newNodes = [];
621
642
  for (let i2 = 0; i2 < result.length; i2++) {
622
643
  const item = result[i2];
623
644
  if (item == null || typeof item === "boolean") continue;
624
- const node = item instanceof Node ? item : document.createTextNode(String(item));
625
- parent.insertBefore(node, anchor);
626
- lastNodes[count++] = node;
645
+ newNodes.push(item instanceof Node ? item : document.createTextNode(String(item)));
627
646
  }
628
647
  } else {
629
- if (lastNodes.length < 1) lastNodes = [null];
630
648
  const node = result instanceof Node ? result : document.createTextNode(String(result));
631
- parent.insertBefore(node, anchor);
632
- lastNodes[count++] = node;
649
+ newNodes = [node];
650
+ }
651
+ const reused = lastNodes.length > 0 && newNodes.length > 0 ? /* @__PURE__ */ new Set() : void 0;
652
+ if (reused) {
653
+ for (let i2 = 0; i2 < newNodes.length; i2++) {
654
+ for (let j = 0; j < lastNodes.length; j++) {
655
+ if (newNodes[i2] === lastNodes[j]) {
656
+ reused.add(newNodes[i2]);
657
+ break;
658
+ }
659
+ }
660
+ }
661
+ }
662
+ for (let i2 = 0; i2 < lastNodes.length; i2++) {
663
+ const node = lastNodes[i2];
664
+ if (reused?.has(node)) continue;
665
+ if (node.parentNode) node.parentNode.removeChild(node);
666
+ }
667
+ const anchor = placeholder.nextSibling;
668
+ for (let i2 = 0; i2 < newNodes.length; i2++) {
669
+ const node = newNodes[i2];
670
+ if (reused?.has(node) && node.parentNode === parent) {
671
+ if (node.nextSibling !== anchor) {
672
+ parent.insertBefore(node, anchor);
673
+ }
674
+ } else {
675
+ parent.insertBefore(node, anchor);
676
+ }
633
677
  }
634
- lastNodes.length = count;
678
+ lastNodes = newNodes;
635
679
  }
636
680
  return track(commit);
637
681
  }
@@ -809,16 +853,20 @@ function appendChildren(el, nodes) {
809
853
  var tagFactory = (tag, ns) => (first, second) => {
810
854
  const el = ns ? document.createElementNS(ns, tag) : document.createElement(tag);
811
855
  if (first === void 0) return el;
812
- if (second === void 0 && typeof first === "string") {
856
+ if (typeof first === "string") {
857
+ if (second !== void 0) {
858
+ el.setAttribute("class", first);
859
+ appendChildren(el, second);
860
+ return el;
861
+ }
813
862
  el.textContent = first;
814
863
  return el;
815
864
  }
816
- if (second !== void 0) {
817
- el.setAttribute("class", first);
818
- appendChildren(el, second);
865
+ if (typeof first === "number") {
866
+ el.textContent = String(first);
819
867
  return el;
820
868
  }
821
- if (Array.isArray(first) || first instanceof Node) {
869
+ if (Array.isArray(first) || first instanceof Node || typeof first === "function") {
822
870
  appendChildren(el, first);
823
871
  return el;
824
872
  }
@@ -827,7 +875,7 @@ var tagFactory = (tag, ns) => (first, second) => {
827
875
  if (pClass != null) applyClass(el, pClass);
828
876
  const pId = props.id;
829
877
  if (pId != null) el.id = pId;
830
- const pNodes = props.nodes;
878
+ const pNodes = second !== void 0 ? second : props.nodes;
831
879
  if (pNodes != null) appendChildren(el, pNodes);
832
880
  const pOn = props.on;
833
881
  if (pOn) {
@@ -852,12 +900,18 @@ var tagFactory = (tag, ns) => (first, second) => {
852
900
  // already handled above / below
853
901
  default: {
854
902
  const value = props[key];
855
- if (value == null || value === false) continue;
903
+ if (value == null) continue;
856
904
  if (key[0] === "o" && key[1] === "n") continue;
857
905
  if (typeof value === "function") {
858
906
  registerDisposer(el, bindAttribute(el, key, value));
859
- } else if (value === true) {
860
- el.setAttribute(key, "");
907
+ } else if (typeof value === "boolean") {
908
+ if (key in el && (key === "checked" || key === "disabled" || key === "selected")) {
909
+ el[key] = value;
910
+ } else if (value) {
911
+ el.setAttribute(key, "");
912
+ } else {
913
+ el.removeAttribute(key);
914
+ }
861
915
  } else {
862
916
  const str = String(value);
863
917
  el.setAttribute(key, isUrlAttribute(key) ? sanitizeUrl(str) : str);
@@ -1905,6 +1959,16 @@ function setGlobalErrorHandler(handler) {
1905
1959
  globalErrorHandler = handler;
1906
1960
  }
1907
1961
 
1962
+ // src/core/rendering/createId.ts
1963
+ var idCounter = 0;
1964
+ function createId(prefix = "sibu") {
1965
+ idCounter++;
1966
+ return `${prefix}-${idCounter}`;
1967
+ }
1968
+ function __resetIdCounter() {
1969
+ idCounter = 0;
1970
+ }
1971
+
1908
1972
  // src/reactivity/batch.ts
1909
1973
  var batchDepth = 0;
1910
1974
  var pendingSignals = /* @__PURE__ */ new Set();
@@ -1985,11 +2049,12 @@ function disableSSR() {
1985
2049
  ssrMode = false;
1986
2050
  }
1987
2051
  function withSSR(fn) {
2052
+ const wasSSR = ssrMode;
1988
2053
  enableSSR();
1989
2054
  try {
1990
2055
  return fn();
1991
2056
  } finally {
1992
- disableSSR();
2057
+ if (!wasSSR) disableSSR();
1993
2058
  }
1994
2059
  }
1995
2060
 
@@ -2439,6 +2504,47 @@ function writable(get, set, options) {
2439
2504
  return [getter, setter];
2440
2505
  }
2441
2506
 
2507
+ // src/core/signals/asyncDerived.ts
2508
+ function asyncDerived(factory, initial) {
2509
+ const [value, setValue] = signal(initial);
2510
+ const [loading, setLoading] = signal(false);
2511
+ const [error, setError] = signal(null);
2512
+ const [tick, setTick] = signal(0);
2513
+ let runId = 0;
2514
+ effect(() => {
2515
+ tick();
2516
+ const currentRun = ++runId;
2517
+ setLoading(true);
2518
+ setError(null);
2519
+ let promise;
2520
+ try {
2521
+ promise = factory();
2522
+ } catch (err) {
2523
+ setError(err);
2524
+ setLoading(false);
2525
+ return;
2526
+ }
2527
+ promise.then(
2528
+ (result) => {
2529
+ if (currentRun !== runId) return;
2530
+ setValue(result);
2531
+ setLoading(false);
2532
+ },
2533
+ (err) => {
2534
+ if (currentRun !== runId) return;
2535
+ setError(err);
2536
+ setLoading(false);
2537
+ }
2538
+ );
2539
+ });
2540
+ return {
2541
+ value,
2542
+ loading,
2543
+ error,
2544
+ refresh: () => setTick((n) => n + 1)
2545
+ };
2546
+ }
2547
+
2442
2548
  // src/core/rendering/lifecycle.ts
2443
2549
  function safeCall(cb, hookName) {
2444
2550
  try {
@@ -2517,6 +2623,116 @@ function context(defaultValue) {
2517
2623
  };
2518
2624
  }
2519
2625
 
2626
+ // src/core/strict.ts
2627
+ function strict(fn) {
2628
+ const result = fn();
2629
+ if (isDev()) {
2630
+ queueMicrotask(() => {
2631
+ try {
2632
+ fn();
2633
+ } catch (err) {
2634
+ console.warn("[Sibu strict] second run threw:", err);
2635
+ }
2636
+ });
2637
+ }
2638
+ return result;
2639
+ }
2640
+ function strictEffect(fn) {
2641
+ if (!isDev()) {
2642
+ return effect(fn);
2643
+ }
2644
+ const firstTeardown = effect(fn);
2645
+ let secondTeardown = null;
2646
+ queueMicrotask(() => {
2647
+ try {
2648
+ secondTeardown = effect(fn);
2649
+ } catch (err) {
2650
+ console.warn("[Sibu strictEffect] second run threw:", err);
2651
+ }
2652
+ });
2653
+ return () => {
2654
+ firstTeardown();
2655
+ if (secondTeardown) secondTeardown();
2656
+ };
2657
+ }
2658
+
2659
+ // src/reactivity/nextTick.ts
2660
+ function nextTick() {
2661
+ return new Promise((resolve) => {
2662
+ queueMicrotask(() => {
2663
+ if (typeof requestAnimationFrame === "function") {
2664
+ requestAnimationFrame(() => resolve());
2665
+ } else {
2666
+ resolve();
2667
+ }
2668
+ });
2669
+ });
2670
+ }
2671
+
2672
+ // src/reactivity/concurrent.ts
2673
+ function defer(getter) {
2674
+ const [value, setValue] = signal(getter());
2675
+ let pending = false;
2676
+ let latest = value();
2677
+ const flush = () => {
2678
+ pending = false;
2679
+ setValue(latest);
2680
+ };
2681
+ const schedule = () => {
2682
+ if (pending) return;
2683
+ pending = true;
2684
+ queueMicrotask(() => {
2685
+ if (typeof requestAnimationFrame === "function") {
2686
+ requestAnimationFrame(flush);
2687
+ } else {
2688
+ flush();
2689
+ }
2690
+ });
2691
+ };
2692
+ track(() => {
2693
+ latest = getter();
2694
+ schedule();
2695
+ });
2696
+ return value;
2697
+ }
2698
+ var IDLE_FALLBACK_MS = 16;
2699
+ function scheduleIdle(fn) {
2700
+ const g2 = globalThis;
2701
+ if (typeof g2.requestIdleCallback === "function") {
2702
+ g2.requestIdleCallback(fn, { timeout: IDLE_FALLBACK_MS * 4 });
2703
+ return;
2704
+ }
2705
+ if (typeof requestAnimationFrame === "function") {
2706
+ requestAnimationFrame(() => fn());
2707
+ return;
2708
+ }
2709
+ setTimeout(fn, IDLE_FALLBACK_MS);
2710
+ }
2711
+ function transition() {
2712
+ const [pending, setPending] = signal(false);
2713
+ function start(fn) {
2714
+ setPending(true);
2715
+ scheduleIdle(() => {
2716
+ let result;
2717
+ try {
2718
+ result = fn();
2719
+ } catch {
2720
+ setPending(false);
2721
+ return;
2722
+ }
2723
+ if (result && typeof result.then === "function") {
2724
+ result.then(
2725
+ () => setPending(false),
2726
+ () => setPending(false)
2727
+ );
2728
+ } else {
2729
+ setPending(false);
2730
+ }
2731
+ });
2732
+ }
2733
+ return { pending, start };
2734
+ }
2735
+
2520
2736
  // src/core/rendering/lazy.ts
2521
2737
  function lazy(importFn) {
2522
2738
  let cached = null;
@@ -2575,8 +2791,446 @@ function Suspense({ nodes, fallback }) {
2575
2791
  return container;
2576
2792
  }
2577
2793
 
2578
- // src/components/ErrorBoundary.ts
2794
+ // src/components/ErrorDisplay.ts
2579
2795
  var _isDev8 = isDev();
2796
+ var STYLES = `
2797
+ .sibu-error-display {
2798
+ border: 1px solid var(--sibu-err-border, #e5484d);
2799
+ border-radius: 10px;
2800
+ margin: 12px 0;
2801
+ background: #0f0f1a;
2802
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
2803
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
2804
+ color: #e5e7eb;
2805
+ overflow: hidden;
2806
+ }
2807
+ .sibu-error-display[data-severity="warning"] { --sibu-err-border: #d97706; --sibu-err-accent: #d97706; }
2808
+ .sibu-error-display[data-severity="info"] { --sibu-err-border: #3b82f6; --sibu-err-accent: #3b82f6; }
2809
+ .sibu-error-display { --sibu-err-accent: #e5484d; }
2810
+
2811
+ .sibu-error-display .sibu-err-header {
2812
+ display: flex;
2813
+ align-items: center;
2814
+ gap: 10px;
2815
+ padding: 12px 18px;
2816
+ background: var(--sibu-err-accent);
2817
+ color: white;
2818
+ user-select: none;
2819
+ }
2820
+ .sibu-error-display .sibu-err-icon {
2821
+ font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
2822
+ font-weight: bold;
2823
+ font-size: 1.05em;
2824
+ padding: 2px 8px;
2825
+ background: rgba(0, 0, 0, 0.22);
2826
+ border-radius: 4px;
2827
+ letter-spacing: 0.02em;
2828
+ }
2829
+ .sibu-error-display .sibu-err-title {
2830
+ margin: 0;
2831
+ font-size: 0.98em;
2832
+ font-weight: 600;
2833
+ flex: 1;
2834
+ text-overflow: ellipsis;
2835
+ overflow: hidden;
2836
+ white-space: nowrap;
2837
+ }
2838
+ .sibu-error-display .sibu-err-timestamp {
2839
+ font-size: 0.75em;
2840
+ opacity: 0.85;
2841
+ font-family: 'SF Mono', 'JetBrains Mono', monospace;
2842
+ }
2843
+
2844
+ .sibu-error-display .sibu-err-body {
2845
+ padding: 16px 18px;
2846
+ }
2847
+ .sibu-error-display .sibu-err-message {
2848
+ font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
2849
+ margin: 0 0 14px;
2850
+ color: #fecaca;
2851
+ word-break: break-word;
2852
+ font-size: 0.9em;
2853
+ line-height: 1.55;
2854
+ padding: 10px 12px;
2855
+ background: rgba(229, 72, 77, 0.08);
2856
+ border-left: 3px solid var(--sibu-err-accent);
2857
+ border-radius: 4px;
2858
+ }
2859
+
2860
+ .sibu-error-display .sibu-err-section {
2861
+ margin-top: 14px;
2862
+ border-radius: 6px;
2863
+ border: 1px solid #2a2a3e;
2864
+ background: #0a0a14;
2865
+ overflow: hidden;
2866
+ }
2867
+ .sibu-error-display .sibu-err-section-head {
2868
+ display: flex;
2869
+ align-items: center;
2870
+ justify-content: space-between;
2871
+ padding: 6px 12px;
2872
+ background: #16162a;
2873
+ border-bottom: 1px solid #2a2a3e;
2874
+ font-size: 0.72em;
2875
+ color: #8b8fa3;
2876
+ text-transform: uppercase;
2877
+ letter-spacing: 0.08em;
2878
+ font-weight: 600;
2879
+ }
2880
+ .sibu-error-display .sibu-err-copy-btn {
2881
+ background: transparent;
2882
+ border: 1px solid #3a3a4e;
2883
+ border-radius: 4px;
2884
+ color: #a0a3b8;
2885
+ cursor: pointer;
2886
+ padding: 2px 10px;
2887
+ font-size: 0.95em;
2888
+ font-family: inherit;
2889
+ transition: all 0.12s ease;
2890
+ }
2891
+ .sibu-error-display .sibu-err-copy-btn:hover {
2892
+ background: #2a2a3e;
2893
+ color: #e5e7eb;
2894
+ border-color: #4a4a5e;
2895
+ }
2896
+
2897
+ .sibu-error-display .sibu-err-stack {
2898
+ margin: 0;
2899
+ padding: 10px 12px;
2900
+ overflow-x: auto;
2901
+ font-family: 'SF Mono', 'JetBrains Mono', monospace;
2902
+ font-size: 0.8em;
2903
+ line-height: 1.7;
2904
+ }
2905
+ .sibu-error-display .sibu-err-frame {
2906
+ display: flex;
2907
+ gap: 10px;
2908
+ padding: 1px 0;
2909
+ }
2910
+ .sibu-error-display .sibu-err-line {
2911
+ display: inline-block;
2912
+ min-width: 2.2ch;
2913
+ color: #4b5066;
2914
+ text-align: right;
2915
+ user-select: none;
2916
+ flex-shrink: 0;
2917
+ }
2918
+ .sibu-error-display .sibu-err-fn {
2919
+ color: #7dd3fc;
2920
+ font-weight: 500;
2921
+ }
2922
+ .sibu-error-display .sibu-err-loc {
2923
+ color: #6b7280;
2924
+ white-space: nowrap;
2925
+ }
2926
+ .sibu-error-display .sibu-err-cause-label {
2927
+ margin: 12px 0 6px;
2928
+ color: #a0a3b8;
2929
+ font-size: 0.75em;
2930
+ text-transform: uppercase;
2931
+ letter-spacing: 0.05em;
2932
+ }
2933
+
2934
+ .sibu-error-display .sibu-err-meta {
2935
+ margin: 0;
2936
+ padding: 10px 12px;
2937
+ font-family: 'SF Mono', 'JetBrains Mono', monospace;
2938
+ font-size: 0.78em;
2939
+ color: #a0a3b8;
2940
+ display: grid;
2941
+ grid-template-columns: minmax(120px, auto) 1fr;
2942
+ gap: 4px 16px;
2943
+ }
2944
+ .sibu-error-display .sibu-err-meta dt { color: #6b7280; }
2945
+ .sibu-error-display .sibu-err-meta dd { margin: 0; color: #d1d5db; word-break: break-word; }
2946
+
2947
+ .sibu-error-display .sibu-err-actions {
2948
+ display: flex;
2949
+ gap: 8px;
2950
+ margin-top: 16px;
2951
+ }
2952
+ .sibu-error-display .sibu-err-btn {
2953
+ display: inline-flex;
2954
+ align-items: center;
2955
+ gap: 6px;
2956
+ padding: 8px 18px;
2957
+ border: none;
2958
+ border-radius: 6px;
2959
+ cursor: pointer;
2960
+ font-size: 13px;
2961
+ font-weight: 500;
2962
+ transition: all 0.12s ease;
2963
+ font-family: inherit;
2964
+ }
2965
+ .sibu-error-display .sibu-err-btn-retry {
2966
+ background: var(--sibu-err-accent);
2967
+ color: white;
2968
+ }
2969
+ .sibu-error-display .sibu-err-btn-retry:hover { filter: brightness(1.1); }
2970
+ .sibu-error-display .sibu-err-btn-reload {
2971
+ background: #1f2133;
2972
+ color: #d1d5db;
2973
+ border: 1px solid #3a3a4e;
2974
+ }
2975
+ .sibu-error-display .sibu-err-btn-reload:hover { background: #2a2b40; }
2976
+ `;
2977
+ var _stylesInjected = false;
2978
+ function injectStyles() {
2979
+ if (_stylesInjected || typeof document === "undefined") return;
2980
+ const el = style({ nodes: STYLES });
2981
+ document.head.appendChild(el);
2982
+ _stylesInjected = true;
2983
+ }
2984
+ function parseStack(stack) {
2985
+ const frames = [];
2986
+ const lines = stack.split("\n");
2987
+ for (const raw of lines) {
2988
+ const line2 = raw.trim();
2989
+ const chrome = line2.match(/^at\s+(?:(.+?)\s+\((.+)\)|(.+))$/);
2990
+ if (chrome) {
2991
+ frames.push({ fn: chrome[1] || "(anonymous)", loc: chrome[2] || chrome[3] || "" });
2992
+ continue;
2993
+ }
2994
+ const ff = line2.match(/^(.+?)@(.+)$/);
2995
+ if (ff) {
2996
+ frames.push({ fn: ff[1] || "(anonymous)", loc: ff[2] || "" });
2997
+ }
2998
+ }
2999
+ return frames;
3000
+ }
3001
+ function normalizeError(err) {
3002
+ if (err instanceof Error) {
3003
+ const code2 = err.code ?? err.name ?? "ERROR";
3004
+ const message = err.message || "Unknown error";
3005
+ const stack = err.stack ?? "";
3006
+ const frames = parseStack(stack);
3007
+ const rawCause = err.cause;
3008
+ const cause = rawCause != null ? normalizeError(rawCause) : null;
3009
+ return { code: code2, message, stack, frames, cause };
3010
+ }
3011
+ return {
3012
+ code: "NON_ERROR",
3013
+ message: typeof err === "string" ? err : JSON.stringify(err),
3014
+ stack: "",
3015
+ frames: [],
3016
+ cause: null
3017
+ };
3018
+ }
3019
+ function buildCopyText(err, meta2) {
3020
+ const lines = [];
3021
+ lines.push(`[${err.code}] ${err.message}`);
3022
+ if (err.stack) {
3023
+ lines.push("");
3024
+ lines.push(err.stack);
3025
+ }
3026
+ if (err.cause) {
3027
+ lines.push("");
3028
+ lines.push("Caused by:");
3029
+ lines.push(` [${err.cause.code}] ${err.cause.message}`);
3030
+ if (err.cause.stack) {
3031
+ const indented = err.cause.stack.split("\n").map((l) => ` ${l}`).join("\n");
3032
+ lines.push(indented);
3033
+ }
3034
+ }
3035
+ if (meta2 && Object.keys(meta2).length > 0) {
3036
+ lines.push("");
3037
+ lines.push("Metadata:");
3038
+ for (const [k, v] of Object.entries(meta2)) {
3039
+ lines.push(` ${k}: ${String(v)}`);
3040
+ }
3041
+ }
3042
+ lines.push("");
3043
+ lines.push(`At: ${(/* @__PURE__ */ new Date()).toISOString()}`);
3044
+ if (typeof navigator !== "undefined" && navigator.userAgent) {
3045
+ lines.push(`UA: ${navigator.userAgent}`);
3046
+ }
3047
+ return lines.join("\n");
3048
+ }
3049
+ function renderFrames(frames) {
3050
+ const rows = frames.map(
3051
+ (f, i2) => div({
3052
+ class: "sibu-err-frame",
3053
+ nodes: [
3054
+ span({ class: "sibu-err-line", nodes: String(i2 + 1) }),
3055
+ span({ class: "sibu-err-fn", nodes: f.fn }),
3056
+ span({ class: "sibu-err-loc", nodes: ` \u2014 ${f.loc}` })
3057
+ ]
3058
+ })
3059
+ );
3060
+ return pre({ class: "sibu-err-stack", nodes: rows });
3061
+ }
3062
+ function renderCauseChain(cause) {
3063
+ if (!cause) return [];
3064
+ return [
3065
+ div({ class: "sibu-err-cause-label", nodes: "Caused by" }),
3066
+ div({
3067
+ class: "sibu-err-section",
3068
+ nodes: [
3069
+ div({
3070
+ class: "sibu-err-section-head",
3071
+ nodes: [span({ nodes: `[${cause.code}] ${cause.message}` }), span({ nodes: "" })]
3072
+ }),
3073
+ cause.frames.length > 0 ? renderFrames(cause.frames) : div({ class: "sibu-err-stack", nodes: "(no stack)" })
3074
+ ]
3075
+ }),
3076
+ ...renderCauseChain(cause.cause)
3077
+ ];
3078
+ }
3079
+ function renderMetadata(meta2) {
3080
+ const rows = [];
3081
+ for (const [k, v] of Object.entries(meta2)) {
3082
+ rows.push(document.createElement("dt"));
3083
+ rows[rows.length - 1].textContent = k;
3084
+ const dd2 = document.createElement("dd");
3085
+ dd2.textContent = v == null ? "(null)" : String(v);
3086
+ rows.push(dd2);
3087
+ }
3088
+ const dl2 = document.createElement("dl");
3089
+ dl2.className = "sibu-err-meta";
3090
+ for (const r of rows) dl2.appendChild(r);
3091
+ return dl2;
3092
+ }
3093
+ function ErrorDisplay(props) {
3094
+ injectStyles();
3095
+ const severity = props.severity ?? "error";
3096
+ const normalized = normalizeError(props.error);
3097
+ const showDetails = props.alwaysShowDetails ?? _isDev8;
3098
+ const headline = props.title ?? normalized.message;
3099
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
3100
+ const [copyLabel, setCopyLabel] = signal("Copy");
3101
+ const copyBtn = button({
3102
+ class: "sibu-err-copy-btn",
3103
+ nodes: () => copyLabel(),
3104
+ on: {
3105
+ click: () => {
3106
+ const text2 = buildCopyText(normalized, props.metadata);
3107
+ if (typeof navigator !== "undefined" && navigator.clipboard) {
3108
+ navigator.clipboard.writeText(text2).then(
3109
+ () => {
3110
+ setCopyLabel("Copied!");
3111
+ setTimeout(() => setCopyLabel("Copy"), 1500);
3112
+ },
3113
+ () => {
3114
+ setCopyLabel("Copy failed");
3115
+ setTimeout(() => setCopyLabel("Copy"), 1500);
3116
+ }
3117
+ );
3118
+ }
3119
+ }
3120
+ }
3121
+ });
3122
+ const header2 = div({
3123
+ class: "sibu-err-header",
3124
+ nodes: [
3125
+ code({ class: "sibu-err-icon", nodes: normalized.code }),
3126
+ h3({ class: "sibu-err-title", nodes: headline }),
3127
+ span({ class: "sibu-err-timestamp", nodes: timestamp })
3128
+ ]
3129
+ });
3130
+ const bodyChildren = [p({ class: "sibu-err-message", nodes: normalized.message })];
3131
+ if (showDetails && normalized.frames.length > 0) {
3132
+ bodyChildren.push(
3133
+ div({
3134
+ class: "sibu-err-section",
3135
+ nodes: [
3136
+ div({
3137
+ class: "sibu-err-section-head",
3138
+ nodes: [span({ nodes: "Stack Trace" }), copyBtn]
3139
+ }),
3140
+ renderFrames(normalized.frames)
3141
+ ]
3142
+ })
3143
+ );
3144
+ } else if (showDetails) {
3145
+ bodyChildren.push(
3146
+ div({
3147
+ class: "sibu-err-section",
3148
+ nodes: [
3149
+ div({
3150
+ class: "sibu-err-section-head",
3151
+ nodes: [span({ nodes: "Details" }), copyBtn]
3152
+ }),
3153
+ div({ class: "sibu-err-stack", nodes: "(no stack available)" })
3154
+ ]
3155
+ })
3156
+ );
3157
+ }
3158
+ if (showDetails) {
3159
+ bodyChildren.push(...renderCauseChain(normalized.cause));
3160
+ }
3161
+ if (showDetails && props.metadata && Object.keys(props.metadata).length > 0) {
3162
+ bodyChildren.push(
3163
+ div({
3164
+ class: "sibu-err-section",
3165
+ nodes: [
3166
+ div({ class: "sibu-err-section-head", nodes: [span({ nodes: "Metadata" })] }),
3167
+ renderMetadata(props.metadata)
3168
+ ]
3169
+ })
3170
+ );
3171
+ }
3172
+ if (showDetails && typeof navigator !== "undefined" && navigator.userAgent) {
3173
+ bodyChildren.push(
3174
+ div({
3175
+ class: "sibu-err-section",
3176
+ nodes: [
3177
+ div({ class: "sibu-err-section-head", nodes: [span({ nodes: "Environment" })] }),
3178
+ div({
3179
+ class: "sibu-err-meta",
3180
+ nodes: (() => {
3181
+ const dl2 = document.createElement("dl");
3182
+ dl2.className = "sibu-err-meta";
3183
+ const entries = [
3184
+ ["User Agent", navigator.userAgent],
3185
+ ["URL", typeof location !== "undefined" ? location.href : "(n/a)"],
3186
+ ["Timestamp", (/* @__PURE__ */ new Date()).toISOString()]
3187
+ ];
3188
+ for (const [k, v] of entries) {
3189
+ const dt2 = document.createElement("dt");
3190
+ dt2.textContent = k;
3191
+ const dd2 = document.createElement("dd");
3192
+ dd2.textContent = v;
3193
+ dl2.appendChild(dt2);
3194
+ dl2.appendChild(dd2);
3195
+ }
3196
+ return dl2;
3197
+ })()
3198
+ })
3199
+ ]
3200
+ })
3201
+ );
3202
+ }
3203
+ const actionButtons = [];
3204
+ if (props.onRetry) {
3205
+ actionButtons.push(
3206
+ button({
3207
+ class: "sibu-err-btn sibu-err-btn-retry",
3208
+ nodes: props.retryLabel ?? "Retry",
3209
+ on: { click: props.onRetry }
3210
+ })
3211
+ );
3212
+ }
3213
+ if (!props.hideReload && typeof location !== "undefined") {
3214
+ actionButtons.push(
3215
+ button({
3216
+ class: "sibu-err-btn sibu-err-btn-reload",
3217
+ nodes: "Reload Page",
3218
+ on: { click: () => location.reload() }
3219
+ })
3220
+ );
3221
+ }
3222
+ if (actionButtons.length > 0) {
3223
+ bodyChildren.push(div({ class: "sibu-err-actions", nodes: actionButtons }));
3224
+ }
3225
+ const body2 = div({ class: "sibu-err-body", nodes: bodyChildren });
3226
+ return div({
3227
+ class: "sibu-error-display",
3228
+ "data-severity": severity,
3229
+ nodes: [header2, body2]
3230
+ });
3231
+ }
3232
+
3233
+ // src/components/ErrorBoundary.ts
2580
3234
  var errorBoundaryStyles = `
2581
3235
  .sibu-error-boundary {
2582
3236
  position: relative;
@@ -2733,7 +3387,7 @@ var errorBoundaryStyles = `
2733
3387
  }
2734
3388
  `;
2735
3389
  var stylesInjected = false;
2736
- function injectStyles() {
3390
+ function injectStyles2() {
2737
3391
  if (!stylesInjected && typeof document !== "undefined") {
2738
3392
  const styleElement = style({ nodes: errorBoundaryStyles });
2739
3393
  document.head.appendChild(styleElement);
@@ -2753,37 +3407,8 @@ function getMemoizedFallback(fallbackFn, error, retry) {
2753
3407
  }
2754
3408
  return cache2.get(key);
2755
3409
  }
2756
- function parseStack(err) {
2757
- const stack = err.stack || "";
2758
- const lines = stack.split("\n");
2759
- const frames = [];
2760
- let source2 = "";
2761
- for (const line2 of lines) {
2762
- const trimmed = line2.trim();
2763
- const chromeMatch = trimmed.match(/^at\s+(?:(.+?)\s+\((.+)\)|(.+))$/);
2764
- if (chromeMatch) {
2765
- const fn = chromeMatch[1] || "(anonymous)";
2766
- const loc = chromeMatch[2] || chromeMatch[3] || "";
2767
- frames.push({ fn, loc });
2768
- if (!source2 && fn !== "(anonymous)" && !fn.startsWith("Object.") && !fn.startsWith("Module.")) {
2769
- source2 = fn;
2770
- }
2771
- continue;
2772
- }
2773
- const firefoxMatch = trimmed.match(/^(.+?)@(.+)$/);
2774
- if (firefoxMatch) {
2775
- const fn = firefoxMatch[1] || "(anonymous)";
2776
- const loc = firefoxMatch[2] || "";
2777
- frames.push({ fn, loc });
2778
- if (!source2 && fn !== "(anonymous)") {
2779
- source2 = fn;
2780
- }
2781
- }
2782
- }
2783
- return { source: source2, frames };
2784
- }
2785
- function ErrorBoundary({ nodes, fallback, onError }) {
2786
- injectStyles();
3410
+ function ErrorBoundary({ nodes, fallback, onError, resetKeys }) {
3411
+ injectStyles2();
2787
3412
  const [error, setError] = signal(null);
2788
3413
  const retry = () => {
2789
3414
  if (fallback) {
@@ -2791,6 +3416,22 @@ function ErrorBoundary({ nodes, fallback, onError }) {
2791
3416
  }
2792
3417
  setError(null);
2793
3418
  };
3419
+ if (resetKeys && resetKeys.length > 0) {
3420
+ let initialized = false;
3421
+ effect(() => {
3422
+ for (const k of resetKeys) {
3423
+ try {
3424
+ k();
3425
+ } catch {
3426
+ }
3427
+ }
3428
+ if (!initialized) {
3429
+ initialized = true;
3430
+ return;
3431
+ }
3432
+ if (error() !== null) retry();
3433
+ });
3434
+ }
2794
3435
  const handleError = (e) => {
2795
3436
  const errorObj = e instanceof Error ? e : new Error(String(e));
2796
3437
  setError(errorObj);
@@ -2798,110 +3439,7 @@ function ErrorBoundary({ nodes, fallback, onError }) {
2798
3439
  return errorObj;
2799
3440
  };
2800
3441
  const defaultFallback = (err, retryFn) => {
2801
- if (!_isDev8) {
2802
- return div({
2803
- class: "sibu-error-fallback",
2804
- nodes: [
2805
- div({
2806
- class: "sibu-error-header",
2807
- nodes: [h3({ nodes: "Something went wrong", class: "sibu-error-title" })]
2808
- }),
2809
- div({
2810
- class: "sibu-error-body",
2811
- nodes: [
2812
- p({ nodes: "An unexpected error occurred. Please try again.", class: "sibu-error-message" }),
2813
- div({
2814
- class: "sibu-error-actions",
2815
- nodes: [
2816
- button({
2817
- nodes: "Retry",
2818
- class: "sibu-error-btn sibu-error-btn-retry",
2819
- on: { click: retryFn }
2820
- }),
2821
- button({
2822
- nodes: "Reload Page",
2823
- class: "sibu-error-btn sibu-error-btn-reload",
2824
- on: { click: () => location.reload() }
2825
- })
2826
- ]
2827
- })
2828
- ]
2829
- })
2830
- ]
2831
- });
2832
- }
2833
- const { source: source2, frames } = parseStack(err);
2834
- const fullText = `${err.message}
2835
-
2836
- ${err.stack || ""}`;
2837
- const copyBtn = button({
2838
- nodes: "Copy",
2839
- class: "sibu-error-copy-btn",
2840
- on: {
2841
- click: () => {
2842
- navigator.clipboard.writeText(fullText).then(() => {
2843
- copyBtn.textContent = "Copied!";
2844
- setTimeout(() => {
2845
- copyBtn.textContent = "Copy";
2846
- }, 1500);
2847
- });
2848
- }
2849
- }
2850
- });
2851
- const stackLines = frames.map(
2852
- (f, i2) => div({
2853
- nodes: [
2854
- span({ class: "sibu-line-num", nodes: String(i2 + 1) }),
2855
- span({ class: "sibu-stack-fn", nodes: f.fn }),
2856
- span({ class: "sibu-stack-loc", nodes: ` ${f.loc}` })
2857
- ]
2858
- })
2859
- );
2860
- return div({
2861
- class: "sibu-error-fallback",
2862
- nodes: [
2863
- div({
2864
- class: "sibu-error-header",
2865
- nodes: [
2866
- h3({ nodes: source2 ? `Error in ${source2}` : "Something went wrong", class: "sibu-error-title" }),
2867
- ...source2 ? [] : [span()]
2868
- ]
2869
- }),
2870
- div({
2871
- class: "sibu-error-body",
2872
- nodes: [
2873
- p({ nodes: err.message, class: "sibu-error-message" }),
2874
- ...frames.length > 0 ? [
2875
- div({
2876
- class: "sibu-error-stack-container",
2877
- nodes: [
2878
- div({
2879
- class: "sibu-error-stack-label",
2880
- nodes: [span({ nodes: "Stack Trace" }), copyBtn]
2881
- }),
2882
- div({ class: "sibu-error-stack", nodes: [pre({ nodes: stackLines })] })
2883
- ]
2884
- })
2885
- ] : [],
2886
- div({
2887
- class: "sibu-error-actions",
2888
- nodes: [
2889
- button({
2890
- nodes: "Retry",
2891
- class: "sibu-error-btn sibu-error-btn-retry",
2892
- on: { click: retryFn }
2893
- }),
2894
- button({
2895
- nodes: "Reload Page",
2896
- class: "sibu-error-btn sibu-error-btn-reload",
2897
- on: { click: () => location.reload() }
2898
- })
2899
- ]
2900
- })
2901
- ]
2902
- })
2903
- ]
2904
- });
3442
+ return ErrorDisplay({ error: err, severity: "error", onRetry: retryFn });
2905
3443
  };
2906
3444
  const tryRenderFallback = (err) => {
2907
3445
  const fn = fallback || defaultFallback;
@@ -3055,12 +3593,14 @@ function Loading(props = {}) {
3055
3593
  0 && (module.exports = {
3056
3594
  DynamicComponent,
3057
3595
  ErrorBoundary,
3596
+ ErrorDisplay,
3058
3597
  Fragment,
3059
3598
  KeepAlive,
3060
3599
  Loading,
3061
3600
  Portal,
3062
3601
  SVG_NS,
3063
3602
  Suspense,
3603
+ __resetIdCounter,
3064
3604
  a,
3065
3605
  abbr,
3066
3606
  action,
@@ -3069,6 +3609,7 @@ function Loading(props = {}) {
3069
3609
  array,
3070
3610
  article,
3071
3611
  aside,
3612
+ asyncDerived,
3072
3613
  audio,
3073
3614
  autoResize,
3074
3615
  b,
@@ -3096,12 +3637,14 @@ function Loading(props = {}) {
3096
3637
  colgroup,
3097
3638
  context,
3098
3639
  copyOnClick,
3640
+ createId,
3099
3641
  customElement,
3100
3642
  data,
3101
3643
  datalist,
3102
3644
  dd,
3103
3645
  deepEqual,
3104
3646
  deepSignal,
3647
+ defer,
3105
3648
  defs,
3106
3649
  del,
3107
3650
  derived,
@@ -3169,6 +3712,7 @@ function Loading(props = {}) {
3169
3712
  meter,
3170
3713
  mount,
3171
3714
  nav,
3715
+ nextTick,
3172
3716
  noscript,
3173
3717
  object,
3174
3718
  ol,
@@ -3214,6 +3758,8 @@ function Loading(props = {}) {
3214
3758
  span,
3215
3759
  stop,
3216
3760
  store,
3761
+ strict,
3762
+ strictEffect,
3217
3763
  strong,
3218
3764
  style,
3219
3765
  sub,
@@ -3235,6 +3781,7 @@ function Loading(props = {}) {
3235
3781
  title,
3236
3782
  tr,
3237
3783
  track,
3784
+ transition,
3238
3785
  trapFocus,
3239
3786
  tspan,
3240
3787
  u,