sibujs 1.2.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 (89) 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 +654 -144
  7. package/dist/build.js +14 -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-BGN5ZMP4.js +26 -0
  16. package/dist/chunk-BTU3TJDS.js +365 -0
  17. package/dist/chunk-CHF5OHIA.js +61 -0
  18. package/dist/chunk-CMBFNA7L.js +27 -0
  19. package/dist/chunk-DAHRH4ON.js +331 -0
  20. package/dist/chunk-EBGIRKQY.js +616 -0
  21. package/dist/chunk-EUZND3CB.js +27 -0
  22. package/dist/chunk-F3FA4F32.js +292 -0
  23. package/dist/chunk-JAKHTMQU.js +1000 -0
  24. package/dist/chunk-JCI5M6U6.js +956 -0
  25. package/dist/chunk-KQPDEVVS.js +398 -0
  26. package/dist/chunk-NEKUBFPT.js +60 -0
  27. package/dist/chunk-NYVAC6P5.js +37 -0
  28. package/dist/chunk-PTQJDMRT.js +146 -0
  29. package/dist/chunk-QWZG56ET.js +2744 -0
  30. package/dist/chunk-TSOKIX5Z.js +654 -0
  31. package/dist/chunk-VRW3FULF.js +725 -0
  32. package/dist/chunk-WZSPOOER.js +84 -0
  33. package/dist/chunk-YT6HQ6AM.js +14 -0
  34. package/dist/chunk-ZD6OAMTH.js +277 -0
  35. package/dist/contracts-DDrwxvJ-.d.cts +245 -0
  36. package/dist/contracts-DDrwxvJ-.d.ts +245 -0
  37. package/dist/data.cjs +35 -2
  38. package/dist/data.d.cts +7 -0
  39. package/dist/data.d.ts +7 -0
  40. package/dist/data.js +9 -8
  41. package/dist/devtools.cjs +122 -0
  42. package/dist/devtools.d.cts +69 -461
  43. package/dist/devtools.d.ts +69 -461
  44. package/dist/devtools.js +127 -6
  45. package/dist/ecosystem.cjs +23 -6
  46. package/dist/ecosystem.d.cts +1 -1
  47. package/dist/ecosystem.d.ts +1 -1
  48. package/dist/ecosystem.js +10 -9
  49. package/dist/extras.cjs +1207 -65
  50. package/dist/extras.d.cts +5 -5
  51. package/dist/extras.d.ts +5 -5
  52. package/dist/extras.js +69 -24
  53. package/dist/index.cjs +663 -144
  54. package/dist/index.d.cts +397 -17
  55. package/dist/index.d.ts +397 -17
  56. package/dist/index.js +39 -17
  57. package/dist/introspect-BumjnBKr.d.cts +477 -0
  58. package/dist/introspect-CZrlcaYy.d.ts +477 -0
  59. package/dist/introspect-Cb0zgpi2.d.cts +477 -0
  60. package/dist/introspect-Y2xNXGSf.d.ts +477 -0
  61. package/dist/motion.js +4 -4
  62. package/dist/patterns.cjs +51 -2
  63. package/dist/patterns.d.cts +18 -8
  64. package/dist/patterns.d.ts +18 -8
  65. package/dist/patterns.js +7 -7
  66. package/dist/performance.js +4 -4
  67. package/dist/plugins.cjs +428 -81
  68. package/dist/plugins.d.cts +27 -4
  69. package/dist/plugins.d.ts +27 -4
  70. package/dist/plugins.js +156 -37
  71. package/dist/ssr-4PBXAOO3.js +40 -0
  72. package/dist/ssr-Do_SiVoL.d.cts +201 -0
  73. package/dist/ssr-Do_SiVoL.d.ts +201 -0
  74. package/dist/ssr.cjs +312 -60
  75. package/dist/ssr.d.cts +10 -1
  76. package/dist/ssr.d.ts +10 -1
  77. package/dist/ssr.js +13 -10
  78. package/dist/tagFactory-DaJ0YWX6.d.cts +47 -0
  79. package/dist/tagFactory-DaJ0YWX6.d.ts +47 -0
  80. package/dist/testing.cjs +233 -2
  81. package/dist/testing.d.cts +42 -1
  82. package/dist/testing.d.ts +42 -1
  83. package/dist/testing.js +129 -2
  84. package/dist/ui.cjs +374 -3
  85. package/dist/ui.d.cts +252 -2
  86. package/dist/ui.d.ts +252 -2
  87. package/dist/ui.js +328 -8
  88. package/dist/widgets.js +7 -7
  89. package/package.json +1 -1
package/dist/build.cjs CHANGED
@@ -1059,12 +1059,14 @@ var index_exports = {};
1059
1059
  __export(index_exports, {
1060
1060
  DynamicComponent: () => DynamicComponent,
1061
1061
  ErrorBoundary: () => ErrorBoundary,
1062
+ ErrorDisplay: () => ErrorDisplay,
1062
1063
  Fragment: () => Fragment,
1063
1064
  KeepAlive: () => KeepAlive,
1064
1065
  Loading: () => Loading,
1065
1066
  Portal: () => Portal,
1066
1067
  SVG_NS: () => SVG_NS,
1067
1068
  Suspense: () => Suspense,
1069
+ __resetIdCounter: () => __resetIdCounter,
1068
1070
  a: () => a,
1069
1071
  abbr: () => abbr,
1070
1072
  action: () => action,
@@ -1073,6 +1075,7 @@ __export(index_exports, {
1073
1075
  array: () => array,
1074
1076
  article: () => article,
1075
1077
  aside: () => aside,
1078
+ asyncDerived: () => asyncDerived,
1076
1079
  audio: () => audio,
1077
1080
  autoResize: () => autoResize,
1078
1081
  b: () => b,
@@ -1100,12 +1103,14 @@ __export(index_exports, {
1100
1103
  colgroup: () => colgroup,
1101
1104
  context: () => context,
1102
1105
  copyOnClick: () => copyOnClick,
1106
+ createId: () => createId,
1103
1107
  customElement: () => customElement,
1104
1108
  data: () => data,
1105
1109
  datalist: () => datalist,
1106
1110
  dd: () => dd,
1107
1111
  deepEqual: () => deepEqual,
1108
1112
  deepSignal: () => deepSignal,
1113
+ defer: () => defer,
1109
1114
  defs: () => defs,
1110
1115
  del: () => del,
1111
1116
  derived: () => derived,
@@ -1173,6 +1178,7 @@ __export(index_exports, {
1173
1178
  meter: () => meter,
1174
1179
  mount: () => mount,
1175
1180
  nav: () => nav,
1181
+ nextTick: () => nextTick,
1176
1182
  noscript: () => noscript,
1177
1183
  object: () => object,
1178
1184
  ol: () => ol,
@@ -1218,6 +1224,8 @@ __export(index_exports, {
1218
1224
  span: () => span,
1219
1225
  stop: () => stop,
1220
1226
  store: () => store,
1227
+ strict: () => strict,
1228
+ strictEffect: () => strictEffect,
1221
1229
  strong: () => strong,
1222
1230
  style: () => style,
1223
1231
  sub: () => sub,
@@ -1239,6 +1247,7 @@ __export(index_exports, {
1239
1247
  title: () => title,
1240
1248
  tr: () => tr,
1241
1249
  track: () => track2,
1250
+ transition: () => transition,
1242
1251
  trapFocus: () => trapFocus,
1243
1252
  tspan: () => tspan,
1244
1253
  u: () => u,
@@ -1557,7 +1566,20 @@ function cleanup(subscriber) {
1557
1566
 
1558
1567
  // src/reactivity/bindAttribute.ts
1559
1568
  var _isDev3 = isDev();
1569
+ function isEventHandlerAttr(name) {
1570
+ if (name.length < 3) return false;
1571
+ const lower = name.toLowerCase();
1572
+ return lower[0] === "o" && lower[1] === "n" && lower.charCodeAt(2) >= 97 && lower.charCodeAt(2) <= 122;
1573
+ }
1560
1574
  function bindAttribute(el, attr, getter) {
1575
+ if (isEventHandlerAttr(attr)) {
1576
+ if (_isDev3)
1577
+ devWarn(
1578
+ `bindAttribute: refusing to bind event-handler attribute "${attr}". Use on:{ ${attr.slice(2)}: fn } instead.`
1579
+ );
1580
+ return () => {
1581
+ };
1582
+ }
1561
1583
  function commit() {
1562
1584
  let value;
1563
1585
  try {
@@ -1867,16 +1889,20 @@ function appendChildren(el, nodes) {
1867
1889
  var tagFactory = (tag, ns) => (first, second) => {
1868
1890
  const el = ns ? document.createElementNS(ns, tag) : document.createElement(tag);
1869
1891
  if (first === void 0) return el;
1870
- if (second === void 0 && typeof first === "string") {
1892
+ if (typeof first === "string") {
1893
+ if (second !== void 0) {
1894
+ el.setAttribute("class", first);
1895
+ appendChildren(el, second);
1896
+ return el;
1897
+ }
1871
1898
  el.textContent = first;
1872
1899
  return el;
1873
1900
  }
1874
- if (second !== void 0) {
1875
- el.setAttribute("class", first);
1876
- appendChildren(el, second);
1901
+ if (typeof first === "number") {
1902
+ el.textContent = String(first);
1877
1903
  return el;
1878
1904
  }
1879
- if (Array.isArray(first) || first instanceof Node) {
1905
+ if (Array.isArray(first) || first instanceof Node || typeof first === "function") {
1880
1906
  appendChildren(el, first);
1881
1907
  return el;
1882
1908
  }
@@ -1885,7 +1911,7 @@ var tagFactory = (tag, ns) => (first, second) => {
1885
1911
  if (pClass != null) applyClass(el, pClass);
1886
1912
  const pId = props.id;
1887
1913
  if (pId != null) el.id = pId;
1888
- const pNodes = props.nodes;
1914
+ const pNodes = second !== void 0 ? second : props.nodes;
1889
1915
  if (pNodes != null) appendChildren(el, pNodes);
1890
1916
  const pOn = props.on;
1891
1917
  if (pOn) {
@@ -2969,6 +2995,16 @@ function setGlobalErrorHandler(handler) {
2969
2995
  globalErrorHandler = handler;
2970
2996
  }
2971
2997
 
2998
+ // src/core/rendering/createId.ts
2999
+ var idCounter = 0;
3000
+ function createId(prefix = "sibu") {
3001
+ idCounter++;
3002
+ return `${prefix}-${idCounter}`;
3003
+ }
3004
+ function __resetIdCounter() {
3005
+ idCounter = 0;
3006
+ }
3007
+
2972
3008
  // src/reactivity/batch.ts
2973
3009
  var batchDepth = 0;
2974
3010
  var pendingSignals = /* @__PURE__ */ new Set();
@@ -3049,11 +3085,12 @@ function disableSSR() {
3049
3085
  ssrMode = false;
3050
3086
  }
3051
3087
  function withSSR(fn) {
3088
+ const wasSSR = ssrMode;
3052
3089
  enableSSR();
3053
3090
  try {
3054
3091
  return fn();
3055
3092
  } finally {
3056
- disableSSR();
3093
+ if (!wasSSR) disableSSR();
3057
3094
  }
3058
3095
  }
3059
3096
 
@@ -3503,6 +3540,47 @@ function writable(get, set, options) {
3503
3540
  return [getter, setter];
3504
3541
  }
3505
3542
 
3543
+ // src/core/signals/asyncDerived.ts
3544
+ function asyncDerived(factory, initial) {
3545
+ const [value, setValue] = signal(initial);
3546
+ const [loading, setLoading] = signal(false);
3547
+ const [error, setError] = signal(null);
3548
+ const [tick, setTick] = signal(0);
3549
+ let runId = 0;
3550
+ effect(() => {
3551
+ tick();
3552
+ const currentRun = ++runId;
3553
+ setLoading(true);
3554
+ setError(null);
3555
+ let promise;
3556
+ try {
3557
+ promise = factory();
3558
+ } catch (err) {
3559
+ setError(err);
3560
+ setLoading(false);
3561
+ return;
3562
+ }
3563
+ promise.then(
3564
+ (result) => {
3565
+ if (currentRun !== runId) return;
3566
+ setValue(result);
3567
+ setLoading(false);
3568
+ },
3569
+ (err) => {
3570
+ if (currentRun !== runId) return;
3571
+ setError(err);
3572
+ setLoading(false);
3573
+ }
3574
+ );
3575
+ });
3576
+ return {
3577
+ value,
3578
+ loading,
3579
+ error,
3580
+ refresh: () => setTick((n) => n + 1)
3581
+ };
3582
+ }
3583
+
3506
3584
  // src/core/rendering/lifecycle.ts
3507
3585
  function safeCall(cb, hookName) {
3508
3586
  try {
@@ -3581,6 +3659,116 @@ function context(defaultValue) {
3581
3659
  };
3582
3660
  }
3583
3661
 
3662
+ // src/core/strict.ts
3663
+ function strict(fn) {
3664
+ const result = fn();
3665
+ if (isDev()) {
3666
+ queueMicrotask(() => {
3667
+ try {
3668
+ fn();
3669
+ } catch (err) {
3670
+ console.warn("[Sibu strict] second run threw:", err);
3671
+ }
3672
+ });
3673
+ }
3674
+ return result;
3675
+ }
3676
+ function strictEffect(fn) {
3677
+ if (!isDev()) {
3678
+ return effect(fn);
3679
+ }
3680
+ const firstTeardown = effect(fn);
3681
+ let secondTeardown = null;
3682
+ queueMicrotask(() => {
3683
+ try {
3684
+ secondTeardown = effect(fn);
3685
+ } catch (err) {
3686
+ console.warn("[Sibu strictEffect] second run threw:", err);
3687
+ }
3688
+ });
3689
+ return () => {
3690
+ firstTeardown();
3691
+ if (secondTeardown) secondTeardown();
3692
+ };
3693
+ }
3694
+
3695
+ // src/reactivity/nextTick.ts
3696
+ function nextTick() {
3697
+ return new Promise((resolve) => {
3698
+ queueMicrotask(() => {
3699
+ if (typeof requestAnimationFrame === "function") {
3700
+ requestAnimationFrame(() => resolve());
3701
+ } else {
3702
+ resolve();
3703
+ }
3704
+ });
3705
+ });
3706
+ }
3707
+
3708
+ // src/reactivity/concurrent.ts
3709
+ function defer(getter) {
3710
+ const [value, setValue] = signal(getter());
3711
+ let pending = false;
3712
+ let latest = value();
3713
+ const flush = () => {
3714
+ pending = false;
3715
+ setValue(latest);
3716
+ };
3717
+ const schedule = () => {
3718
+ if (pending) return;
3719
+ pending = true;
3720
+ queueMicrotask(() => {
3721
+ if (typeof requestAnimationFrame === "function") {
3722
+ requestAnimationFrame(flush);
3723
+ } else {
3724
+ flush();
3725
+ }
3726
+ });
3727
+ };
3728
+ track(() => {
3729
+ latest = getter();
3730
+ schedule();
3731
+ });
3732
+ return value;
3733
+ }
3734
+ var IDLE_FALLBACK_MS = 16;
3735
+ function scheduleIdle(fn) {
3736
+ const g2 = globalThis;
3737
+ if (typeof g2.requestIdleCallback === "function") {
3738
+ g2.requestIdleCallback(fn, { timeout: IDLE_FALLBACK_MS * 4 });
3739
+ return;
3740
+ }
3741
+ if (typeof requestAnimationFrame === "function") {
3742
+ requestAnimationFrame(() => fn());
3743
+ return;
3744
+ }
3745
+ setTimeout(fn, IDLE_FALLBACK_MS);
3746
+ }
3747
+ function transition() {
3748
+ const [pending, setPending] = signal(false);
3749
+ function start(fn) {
3750
+ setPending(true);
3751
+ scheduleIdle(() => {
3752
+ let result;
3753
+ try {
3754
+ result = fn();
3755
+ } catch {
3756
+ setPending(false);
3757
+ return;
3758
+ }
3759
+ if (result && typeof result.then === "function") {
3760
+ result.then(
3761
+ () => setPending(false),
3762
+ () => setPending(false)
3763
+ );
3764
+ } else {
3765
+ setPending(false);
3766
+ }
3767
+ });
3768
+ }
3769
+ return { pending, start };
3770
+ }
3771
+
3584
3772
  // src/core/rendering/lazy.ts
3585
3773
  function lazy(importFn) {
3586
3774
  let cached = null;
@@ -3639,8 +3827,446 @@ function Suspense({ nodes, fallback }) {
3639
3827
  return container;
3640
3828
  }
3641
3829
 
3642
- // src/components/ErrorBoundary.ts
3830
+ // src/components/ErrorDisplay.ts
3643
3831
  var _isDev8 = isDev();
3832
+ var STYLES = `
3833
+ .sibu-error-display {
3834
+ border: 1px solid var(--sibu-err-border, #e5484d);
3835
+ border-radius: 10px;
3836
+ margin: 12px 0;
3837
+ background: #0f0f1a;
3838
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
3839
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
3840
+ color: #e5e7eb;
3841
+ overflow: hidden;
3842
+ }
3843
+ .sibu-error-display[data-severity="warning"] { --sibu-err-border: #d97706; --sibu-err-accent: #d97706; }
3844
+ .sibu-error-display[data-severity="info"] { --sibu-err-border: #3b82f6; --sibu-err-accent: #3b82f6; }
3845
+ .sibu-error-display { --sibu-err-accent: #e5484d; }
3846
+
3847
+ .sibu-error-display .sibu-err-header {
3848
+ display: flex;
3849
+ align-items: center;
3850
+ gap: 10px;
3851
+ padding: 12px 18px;
3852
+ background: var(--sibu-err-accent);
3853
+ color: white;
3854
+ user-select: none;
3855
+ }
3856
+ .sibu-error-display .sibu-err-icon {
3857
+ font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
3858
+ font-weight: bold;
3859
+ font-size: 1.05em;
3860
+ padding: 2px 8px;
3861
+ background: rgba(0, 0, 0, 0.22);
3862
+ border-radius: 4px;
3863
+ letter-spacing: 0.02em;
3864
+ }
3865
+ .sibu-error-display .sibu-err-title {
3866
+ margin: 0;
3867
+ font-size: 0.98em;
3868
+ font-weight: 600;
3869
+ flex: 1;
3870
+ text-overflow: ellipsis;
3871
+ overflow: hidden;
3872
+ white-space: nowrap;
3873
+ }
3874
+ .sibu-error-display .sibu-err-timestamp {
3875
+ font-size: 0.75em;
3876
+ opacity: 0.85;
3877
+ font-family: 'SF Mono', 'JetBrains Mono', monospace;
3878
+ }
3879
+
3880
+ .sibu-error-display .sibu-err-body {
3881
+ padding: 16px 18px;
3882
+ }
3883
+ .sibu-error-display .sibu-err-message {
3884
+ font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
3885
+ margin: 0 0 14px;
3886
+ color: #fecaca;
3887
+ word-break: break-word;
3888
+ font-size: 0.9em;
3889
+ line-height: 1.55;
3890
+ padding: 10px 12px;
3891
+ background: rgba(229, 72, 77, 0.08);
3892
+ border-left: 3px solid var(--sibu-err-accent);
3893
+ border-radius: 4px;
3894
+ }
3895
+
3896
+ .sibu-error-display .sibu-err-section {
3897
+ margin-top: 14px;
3898
+ border-radius: 6px;
3899
+ border: 1px solid #2a2a3e;
3900
+ background: #0a0a14;
3901
+ overflow: hidden;
3902
+ }
3903
+ .sibu-error-display .sibu-err-section-head {
3904
+ display: flex;
3905
+ align-items: center;
3906
+ justify-content: space-between;
3907
+ padding: 6px 12px;
3908
+ background: #16162a;
3909
+ border-bottom: 1px solid #2a2a3e;
3910
+ font-size: 0.72em;
3911
+ color: #8b8fa3;
3912
+ text-transform: uppercase;
3913
+ letter-spacing: 0.08em;
3914
+ font-weight: 600;
3915
+ }
3916
+ .sibu-error-display .sibu-err-copy-btn {
3917
+ background: transparent;
3918
+ border: 1px solid #3a3a4e;
3919
+ border-radius: 4px;
3920
+ color: #a0a3b8;
3921
+ cursor: pointer;
3922
+ padding: 2px 10px;
3923
+ font-size: 0.95em;
3924
+ font-family: inherit;
3925
+ transition: all 0.12s ease;
3926
+ }
3927
+ .sibu-error-display .sibu-err-copy-btn:hover {
3928
+ background: #2a2a3e;
3929
+ color: #e5e7eb;
3930
+ border-color: #4a4a5e;
3931
+ }
3932
+
3933
+ .sibu-error-display .sibu-err-stack {
3934
+ margin: 0;
3935
+ padding: 10px 12px;
3936
+ overflow-x: auto;
3937
+ font-family: 'SF Mono', 'JetBrains Mono', monospace;
3938
+ font-size: 0.8em;
3939
+ line-height: 1.7;
3940
+ }
3941
+ .sibu-error-display .sibu-err-frame {
3942
+ display: flex;
3943
+ gap: 10px;
3944
+ padding: 1px 0;
3945
+ }
3946
+ .sibu-error-display .sibu-err-line {
3947
+ display: inline-block;
3948
+ min-width: 2.2ch;
3949
+ color: #4b5066;
3950
+ text-align: right;
3951
+ user-select: none;
3952
+ flex-shrink: 0;
3953
+ }
3954
+ .sibu-error-display .sibu-err-fn {
3955
+ color: #7dd3fc;
3956
+ font-weight: 500;
3957
+ }
3958
+ .sibu-error-display .sibu-err-loc {
3959
+ color: #6b7280;
3960
+ white-space: nowrap;
3961
+ }
3962
+ .sibu-error-display .sibu-err-cause-label {
3963
+ margin: 12px 0 6px;
3964
+ color: #a0a3b8;
3965
+ font-size: 0.75em;
3966
+ text-transform: uppercase;
3967
+ letter-spacing: 0.05em;
3968
+ }
3969
+
3970
+ .sibu-error-display .sibu-err-meta {
3971
+ margin: 0;
3972
+ padding: 10px 12px;
3973
+ font-family: 'SF Mono', 'JetBrains Mono', monospace;
3974
+ font-size: 0.78em;
3975
+ color: #a0a3b8;
3976
+ display: grid;
3977
+ grid-template-columns: minmax(120px, auto) 1fr;
3978
+ gap: 4px 16px;
3979
+ }
3980
+ .sibu-error-display .sibu-err-meta dt { color: #6b7280; }
3981
+ .sibu-error-display .sibu-err-meta dd { margin: 0; color: #d1d5db; word-break: break-word; }
3982
+
3983
+ .sibu-error-display .sibu-err-actions {
3984
+ display: flex;
3985
+ gap: 8px;
3986
+ margin-top: 16px;
3987
+ }
3988
+ .sibu-error-display .sibu-err-btn {
3989
+ display: inline-flex;
3990
+ align-items: center;
3991
+ gap: 6px;
3992
+ padding: 8px 18px;
3993
+ border: none;
3994
+ border-radius: 6px;
3995
+ cursor: pointer;
3996
+ font-size: 13px;
3997
+ font-weight: 500;
3998
+ transition: all 0.12s ease;
3999
+ font-family: inherit;
4000
+ }
4001
+ .sibu-error-display .sibu-err-btn-retry {
4002
+ background: var(--sibu-err-accent);
4003
+ color: white;
4004
+ }
4005
+ .sibu-error-display .sibu-err-btn-retry:hover { filter: brightness(1.1); }
4006
+ .sibu-error-display .sibu-err-btn-reload {
4007
+ background: #1f2133;
4008
+ color: #d1d5db;
4009
+ border: 1px solid #3a3a4e;
4010
+ }
4011
+ .sibu-error-display .sibu-err-btn-reload:hover { background: #2a2b40; }
4012
+ `;
4013
+ var _stylesInjected = false;
4014
+ function injectStyles() {
4015
+ if (_stylesInjected || typeof document === "undefined") return;
4016
+ const el = style({ nodes: STYLES });
4017
+ document.head.appendChild(el);
4018
+ _stylesInjected = true;
4019
+ }
4020
+ function parseStack(stack) {
4021
+ const frames = [];
4022
+ const lines = stack.split("\n");
4023
+ for (const raw of lines) {
4024
+ const line2 = raw.trim();
4025
+ const chrome = line2.match(/^at\s+(?:(.+?)\s+\((.+)\)|(.+))$/);
4026
+ if (chrome) {
4027
+ frames.push({ fn: chrome[1] || "(anonymous)", loc: chrome[2] || chrome[3] || "" });
4028
+ continue;
4029
+ }
4030
+ const ff = line2.match(/^(.+?)@(.+)$/);
4031
+ if (ff) {
4032
+ frames.push({ fn: ff[1] || "(anonymous)", loc: ff[2] || "" });
4033
+ }
4034
+ }
4035
+ return frames;
4036
+ }
4037
+ function normalizeError(err) {
4038
+ if (err instanceof Error) {
4039
+ const code2 = err.code ?? err.name ?? "ERROR";
4040
+ const message = err.message || "Unknown error";
4041
+ const stack = err.stack ?? "";
4042
+ const frames = parseStack(stack);
4043
+ const rawCause = err.cause;
4044
+ const cause = rawCause != null ? normalizeError(rawCause) : null;
4045
+ return { code: code2, message, stack, frames, cause };
4046
+ }
4047
+ return {
4048
+ code: "NON_ERROR",
4049
+ message: typeof err === "string" ? err : JSON.stringify(err),
4050
+ stack: "",
4051
+ frames: [],
4052
+ cause: null
4053
+ };
4054
+ }
4055
+ function buildCopyText(err, meta2) {
4056
+ const lines = [];
4057
+ lines.push(`[${err.code}] ${err.message}`);
4058
+ if (err.stack) {
4059
+ lines.push("");
4060
+ lines.push(err.stack);
4061
+ }
4062
+ if (err.cause) {
4063
+ lines.push("");
4064
+ lines.push("Caused by:");
4065
+ lines.push(` [${err.cause.code}] ${err.cause.message}`);
4066
+ if (err.cause.stack) {
4067
+ const indented = err.cause.stack.split("\n").map((l) => ` ${l}`).join("\n");
4068
+ lines.push(indented);
4069
+ }
4070
+ }
4071
+ if (meta2 && Object.keys(meta2).length > 0) {
4072
+ lines.push("");
4073
+ lines.push("Metadata:");
4074
+ for (const [k, v] of Object.entries(meta2)) {
4075
+ lines.push(` ${k}: ${String(v)}`);
4076
+ }
4077
+ }
4078
+ lines.push("");
4079
+ lines.push(`At: ${(/* @__PURE__ */ new Date()).toISOString()}`);
4080
+ if (typeof navigator !== "undefined" && navigator.userAgent) {
4081
+ lines.push(`UA: ${navigator.userAgent}`);
4082
+ }
4083
+ return lines.join("\n");
4084
+ }
4085
+ function renderFrames(frames) {
4086
+ const rows = frames.map(
4087
+ (f, i2) => div({
4088
+ class: "sibu-err-frame",
4089
+ nodes: [
4090
+ span({ class: "sibu-err-line", nodes: String(i2 + 1) }),
4091
+ span({ class: "sibu-err-fn", nodes: f.fn }),
4092
+ span({ class: "sibu-err-loc", nodes: ` \u2014 ${f.loc}` })
4093
+ ]
4094
+ })
4095
+ );
4096
+ return pre({ class: "sibu-err-stack", nodes: rows });
4097
+ }
4098
+ function renderCauseChain(cause) {
4099
+ if (!cause) return [];
4100
+ return [
4101
+ div({ class: "sibu-err-cause-label", nodes: "Caused by" }),
4102
+ div({
4103
+ class: "sibu-err-section",
4104
+ nodes: [
4105
+ div({
4106
+ class: "sibu-err-section-head",
4107
+ nodes: [span({ nodes: `[${cause.code}] ${cause.message}` }), span({ nodes: "" })]
4108
+ }),
4109
+ cause.frames.length > 0 ? renderFrames(cause.frames) : div({ class: "sibu-err-stack", nodes: "(no stack)" })
4110
+ ]
4111
+ }),
4112
+ ...renderCauseChain(cause.cause)
4113
+ ];
4114
+ }
4115
+ function renderMetadata(meta2) {
4116
+ const rows = [];
4117
+ for (const [k, v] of Object.entries(meta2)) {
4118
+ rows.push(document.createElement("dt"));
4119
+ rows[rows.length - 1].textContent = k;
4120
+ const dd2 = document.createElement("dd");
4121
+ dd2.textContent = v == null ? "(null)" : String(v);
4122
+ rows.push(dd2);
4123
+ }
4124
+ const dl2 = document.createElement("dl");
4125
+ dl2.className = "sibu-err-meta";
4126
+ for (const r of rows) dl2.appendChild(r);
4127
+ return dl2;
4128
+ }
4129
+ function ErrorDisplay(props) {
4130
+ injectStyles();
4131
+ const severity = props.severity ?? "error";
4132
+ const normalized = normalizeError(props.error);
4133
+ const showDetails = props.alwaysShowDetails ?? _isDev8;
4134
+ const headline = props.title ?? normalized.message;
4135
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
4136
+ const [copyLabel, setCopyLabel] = signal("Copy");
4137
+ const copyBtn = button({
4138
+ class: "sibu-err-copy-btn",
4139
+ nodes: () => copyLabel(),
4140
+ on: {
4141
+ click: () => {
4142
+ const text2 = buildCopyText(normalized, props.metadata);
4143
+ if (typeof navigator !== "undefined" && navigator.clipboard) {
4144
+ navigator.clipboard.writeText(text2).then(
4145
+ () => {
4146
+ setCopyLabel("Copied!");
4147
+ setTimeout(() => setCopyLabel("Copy"), 1500);
4148
+ },
4149
+ () => {
4150
+ setCopyLabel("Copy failed");
4151
+ setTimeout(() => setCopyLabel("Copy"), 1500);
4152
+ }
4153
+ );
4154
+ }
4155
+ }
4156
+ }
4157
+ });
4158
+ const header2 = div({
4159
+ class: "sibu-err-header",
4160
+ nodes: [
4161
+ code({ class: "sibu-err-icon", nodes: normalized.code }),
4162
+ h3({ class: "sibu-err-title", nodes: headline }),
4163
+ span({ class: "sibu-err-timestamp", nodes: timestamp })
4164
+ ]
4165
+ });
4166
+ const bodyChildren = [p({ class: "sibu-err-message", nodes: normalized.message })];
4167
+ if (showDetails && normalized.frames.length > 0) {
4168
+ bodyChildren.push(
4169
+ div({
4170
+ class: "sibu-err-section",
4171
+ nodes: [
4172
+ div({
4173
+ class: "sibu-err-section-head",
4174
+ nodes: [span({ nodes: "Stack Trace" }), copyBtn]
4175
+ }),
4176
+ renderFrames(normalized.frames)
4177
+ ]
4178
+ })
4179
+ );
4180
+ } else if (showDetails) {
4181
+ bodyChildren.push(
4182
+ div({
4183
+ class: "sibu-err-section",
4184
+ nodes: [
4185
+ div({
4186
+ class: "sibu-err-section-head",
4187
+ nodes: [span({ nodes: "Details" }), copyBtn]
4188
+ }),
4189
+ div({ class: "sibu-err-stack", nodes: "(no stack available)" })
4190
+ ]
4191
+ })
4192
+ );
4193
+ }
4194
+ if (showDetails) {
4195
+ bodyChildren.push(...renderCauseChain(normalized.cause));
4196
+ }
4197
+ if (showDetails && props.metadata && Object.keys(props.metadata).length > 0) {
4198
+ bodyChildren.push(
4199
+ div({
4200
+ class: "sibu-err-section",
4201
+ nodes: [
4202
+ div({ class: "sibu-err-section-head", nodes: [span({ nodes: "Metadata" })] }),
4203
+ renderMetadata(props.metadata)
4204
+ ]
4205
+ })
4206
+ );
4207
+ }
4208
+ if (showDetails && typeof navigator !== "undefined" && navigator.userAgent) {
4209
+ bodyChildren.push(
4210
+ div({
4211
+ class: "sibu-err-section",
4212
+ nodes: [
4213
+ div({ class: "sibu-err-section-head", nodes: [span({ nodes: "Environment" })] }),
4214
+ div({
4215
+ class: "sibu-err-meta",
4216
+ nodes: (() => {
4217
+ const dl2 = document.createElement("dl");
4218
+ dl2.className = "sibu-err-meta";
4219
+ const entries = [
4220
+ ["User Agent", navigator.userAgent],
4221
+ ["URL", typeof location !== "undefined" ? location.href : "(n/a)"],
4222
+ ["Timestamp", (/* @__PURE__ */ new Date()).toISOString()]
4223
+ ];
4224
+ for (const [k, v] of entries) {
4225
+ const dt2 = document.createElement("dt");
4226
+ dt2.textContent = k;
4227
+ const dd2 = document.createElement("dd");
4228
+ dd2.textContent = v;
4229
+ dl2.appendChild(dt2);
4230
+ dl2.appendChild(dd2);
4231
+ }
4232
+ return dl2;
4233
+ })()
4234
+ })
4235
+ ]
4236
+ })
4237
+ );
4238
+ }
4239
+ const actionButtons = [];
4240
+ if (props.onRetry) {
4241
+ actionButtons.push(
4242
+ button({
4243
+ class: "sibu-err-btn sibu-err-btn-retry",
4244
+ nodes: props.retryLabel ?? "Retry",
4245
+ on: { click: props.onRetry }
4246
+ })
4247
+ );
4248
+ }
4249
+ if (!props.hideReload && typeof location !== "undefined") {
4250
+ actionButtons.push(
4251
+ button({
4252
+ class: "sibu-err-btn sibu-err-btn-reload",
4253
+ nodes: "Reload Page",
4254
+ on: { click: () => location.reload() }
4255
+ })
4256
+ );
4257
+ }
4258
+ if (actionButtons.length > 0) {
4259
+ bodyChildren.push(div({ class: "sibu-err-actions", nodes: actionButtons }));
4260
+ }
4261
+ const body2 = div({ class: "sibu-err-body", nodes: bodyChildren });
4262
+ return div({
4263
+ class: "sibu-error-display",
4264
+ "data-severity": severity,
4265
+ nodes: [header2, body2]
4266
+ });
4267
+ }
4268
+
4269
+ // src/components/ErrorBoundary.ts
3644
4270
  var errorBoundaryStyles = `
3645
4271
  .sibu-error-boundary {
3646
4272
  position: relative;
@@ -3797,7 +4423,7 @@ var errorBoundaryStyles = `
3797
4423
  }
3798
4424
  `;
3799
4425
  var stylesInjected = false;
3800
- function injectStyles() {
4426
+ function injectStyles2() {
3801
4427
  if (!stylesInjected && typeof document !== "undefined") {
3802
4428
  const styleElement = style({ nodes: errorBoundaryStyles });
3803
4429
  document.head.appendChild(styleElement);
@@ -3817,37 +4443,8 @@ function getMemoizedFallback(fallbackFn, error, retry) {
3817
4443
  }
3818
4444
  return cache2.get(key);
3819
4445
  }
3820
- function parseStack(err) {
3821
- const stack = err.stack || "";
3822
- const lines = stack.split("\n");
3823
- const frames = [];
3824
- let source2 = "";
3825
- for (const line2 of lines) {
3826
- const trimmed = line2.trim();
3827
- const chromeMatch = trimmed.match(/^at\s+(?:(.+?)\s+\((.+)\)|(.+))$/);
3828
- if (chromeMatch) {
3829
- const fn = chromeMatch[1] || "(anonymous)";
3830
- const loc = chromeMatch[2] || chromeMatch[3] || "";
3831
- frames.push({ fn, loc });
3832
- if (!source2 && fn !== "(anonymous)" && !fn.startsWith("Object.") && !fn.startsWith("Module.")) {
3833
- source2 = fn;
3834
- }
3835
- continue;
3836
- }
3837
- const firefoxMatch = trimmed.match(/^(.+?)@(.+)$/);
3838
- if (firefoxMatch) {
3839
- const fn = firefoxMatch[1] || "(anonymous)";
3840
- const loc = firefoxMatch[2] || "";
3841
- frames.push({ fn, loc });
3842
- if (!source2 && fn !== "(anonymous)") {
3843
- source2 = fn;
3844
- }
3845
- }
3846
- }
3847
- return { source: source2, frames };
3848
- }
3849
- function ErrorBoundary({ nodes, fallback, onError }) {
3850
- injectStyles();
4446
+ function ErrorBoundary({ nodes, fallback, onError, resetKeys }) {
4447
+ injectStyles2();
3851
4448
  const [error, setError] = signal(null);
3852
4449
  const retry = () => {
3853
4450
  if (fallback) {
@@ -3855,6 +4452,22 @@ function ErrorBoundary({ nodes, fallback, onError }) {
3855
4452
  }
3856
4453
  setError(null);
3857
4454
  };
4455
+ if (resetKeys && resetKeys.length > 0) {
4456
+ let initialized = false;
4457
+ effect(() => {
4458
+ for (const k of resetKeys) {
4459
+ try {
4460
+ k();
4461
+ } catch {
4462
+ }
4463
+ }
4464
+ if (!initialized) {
4465
+ initialized = true;
4466
+ return;
4467
+ }
4468
+ if (error() !== null) retry();
4469
+ });
4470
+ }
3858
4471
  const handleError = (e) => {
3859
4472
  const errorObj = e instanceof Error ? e : new Error(String(e));
3860
4473
  setError(errorObj);
@@ -3862,110 +4475,7 @@ function ErrorBoundary({ nodes, fallback, onError }) {
3862
4475
  return errorObj;
3863
4476
  };
3864
4477
  const defaultFallback = (err, retryFn) => {
3865
- if (!_isDev8) {
3866
- return div({
3867
- class: "sibu-error-fallback",
3868
- nodes: [
3869
- div({
3870
- class: "sibu-error-header",
3871
- nodes: [h3({ nodes: "Something went wrong", class: "sibu-error-title" })]
3872
- }),
3873
- div({
3874
- class: "sibu-error-body",
3875
- nodes: [
3876
- p({ nodes: "An unexpected error occurred. Please try again.", class: "sibu-error-message" }),
3877
- div({
3878
- class: "sibu-error-actions",
3879
- nodes: [
3880
- button({
3881
- nodes: "Retry",
3882
- class: "sibu-error-btn sibu-error-btn-retry",
3883
- on: { click: retryFn }
3884
- }),
3885
- button({
3886
- nodes: "Reload Page",
3887
- class: "sibu-error-btn sibu-error-btn-reload",
3888
- on: { click: () => location.reload() }
3889
- })
3890
- ]
3891
- })
3892
- ]
3893
- })
3894
- ]
3895
- });
3896
- }
3897
- const { source: source2, frames } = parseStack(err);
3898
- const fullText = `${err.message}
3899
-
3900
- ${err.stack || ""}`;
3901
- const copyBtn = button({
3902
- nodes: "Copy",
3903
- class: "sibu-error-copy-btn",
3904
- on: {
3905
- click: () => {
3906
- navigator.clipboard.writeText(fullText).then(() => {
3907
- copyBtn.textContent = "Copied!";
3908
- setTimeout(() => {
3909
- copyBtn.textContent = "Copy";
3910
- }, 1500);
3911
- });
3912
- }
3913
- }
3914
- });
3915
- const stackLines = frames.map(
3916
- (f, i2) => div({
3917
- nodes: [
3918
- span({ class: "sibu-line-num", nodes: String(i2 + 1) }),
3919
- span({ class: "sibu-stack-fn", nodes: f.fn }),
3920
- span({ class: "sibu-stack-loc", nodes: ` ${f.loc}` })
3921
- ]
3922
- })
3923
- );
3924
- return div({
3925
- class: "sibu-error-fallback",
3926
- nodes: [
3927
- div({
3928
- class: "sibu-error-header",
3929
- nodes: [
3930
- h3({ nodes: source2 ? `Error in ${source2}` : "Something went wrong", class: "sibu-error-title" }),
3931
- ...source2 ? [] : [span()]
3932
- ]
3933
- }),
3934
- div({
3935
- class: "sibu-error-body",
3936
- nodes: [
3937
- p({ nodes: err.message, class: "sibu-error-message" }),
3938
- ...frames.length > 0 ? [
3939
- div({
3940
- class: "sibu-error-stack-container",
3941
- nodes: [
3942
- div({
3943
- class: "sibu-error-stack-label",
3944
- nodes: [span({ nodes: "Stack Trace" }), copyBtn]
3945
- }),
3946
- div({ class: "sibu-error-stack", nodes: [pre({ nodes: stackLines })] })
3947
- ]
3948
- })
3949
- ] : [],
3950
- div({
3951
- class: "sibu-error-actions",
3952
- nodes: [
3953
- button({
3954
- nodes: "Retry",
3955
- class: "sibu-error-btn sibu-error-btn-retry",
3956
- on: { click: retryFn }
3957
- }),
3958
- button({
3959
- nodes: "Reload Page",
3960
- class: "sibu-error-btn sibu-error-btn-reload",
3961
- on: { click: () => location.reload() }
3962
- })
3963
- ]
3964
- })
3965
- ]
3966
- })
3967
- ]
3968
- });
4478
+ return ErrorDisplay({ error: err, severity: "error", onRetry: retryFn });
3969
4479
  };
3970
4480
  const tryRenderFallback = (err) => {
3971
4481
  const fn = fallback || defaultFallback;