sibujs 4.0.1 → 4.2.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 (80) hide show
  1. package/README.md +29 -1
  2. package/dist/browser.cjs +21 -22
  3. package/dist/browser.js +6 -6
  4. package/dist/build.cjs +363 -110
  5. package/dist/build.js +15 -15
  6. package/dist/cdn.dev.global.js +398 -0
  7. package/dist/cdn.global.js +10 -10
  8. package/dist/{chunk-AD5YSZAN.js → chunk-2LOYNGBY.js} +2 -2
  9. package/dist/{chunk-VPP2FONR.js → chunk-2WLZ6757.js} +17 -10
  10. package/dist/{chunk-UNAYBND2.js → chunk-3VTSPNC5.js} +2 -2
  11. package/dist/{chunk-TIRZCERI.js → chunk-5DXA2J44.js} +1 -1
  12. package/dist/{chunk-QD4I7ZGZ.js → chunk-6ZGI3RBE.js} +149 -33
  13. package/dist/{chunk-JYXQCELN.js → chunk-7ALC7KGE.js} +13 -7
  14. package/dist/{chunk-XDOMTQHM.js → chunk-7VEC3UD2.js} +3 -3
  15. package/dist/{chunk-PTLJ7NQX.js → chunk-BMYYZWHX.js} +3 -3
  16. package/dist/{chunk-PHB3MCK4.js → chunk-BNKV4REK.js} +7 -8
  17. package/dist/{chunk-XET2RUJF.js → chunk-FOWBJZDL.js} +7 -8
  18. package/dist/{chunk-5BVKQX2F.js → chunk-GDUNQCCW.js} +4 -4
  19. package/dist/{chunk-TVURNWDK.js → chunk-HECVW343.js} +20 -9
  20. package/dist/{chunk-PHRH66Y7.js → chunk-HJEPKZ2O.js} +7 -8
  21. package/dist/{chunk-PJDSI2K7.js → chunk-HZEBO22J.js} +125 -42
  22. package/dist/{chunk-5INI7D2L.js → chunk-IXKSNWV5.js} +74 -11
  23. package/dist/{chunk-IKVUUE7D.js → chunk-KE4KWRDY.js} +3 -3
  24. package/dist/{chunk-AW6HPJ3L.js → chunk-KKLW7YWL.js} +1 -1
  25. package/dist/{chunk-XZMCVZW6.js → chunk-NEYWS4EX.js} +6 -6
  26. package/dist/{chunk-HYCCIYNS.js → chunk-NIOYEGBQ.js} +13 -14
  27. package/dist/{chunk-YLV26GAJ.js → chunk-OUWAIXIK.js} +3 -3
  28. package/dist/{chunk-E72G5JSK.js → chunk-P3DHXBR6.js} +1 -1
  29. package/dist/{chunk-J4WZMCIW.js → chunk-QCFLDD7C.js} +5 -5
  30. package/dist/{chunk-DHDZ7IVN.js → chunk-QKRPLZ2V.js} +7 -8
  31. package/dist/{chunk-52ERIVFD.js → chunk-QL4UREZO.js} +6 -6
  32. package/dist/{chunk-TNEHT3NG.js → chunk-SF3TB4K6.js} +8 -8
  33. package/dist/{chunk-HPXTUPJD.js → chunk-XZ2N525U.js} +6 -6
  34. package/dist/{customElement-CKLoO63w.d.ts → customElement-CNZxEB9G.d.cts} +77 -0
  35. package/dist/{customElement-CKLoO63w.d.cts → customElement-CNZxEB9G.d.ts} +77 -0
  36. package/dist/data.cjs +23 -25
  37. package/dist/data.js +9 -9
  38. package/dist/devtools.cjs +26 -23
  39. package/dist/devtools.d.cts +1 -1
  40. package/dist/devtools.d.ts +1 -1
  41. package/dist/devtools.js +8 -8
  42. package/dist/{dispose-4FZ6OFXR.js → dispose-46BOMMQJ.js} +2 -2
  43. package/dist/ecosystem.cjs +230 -68
  44. package/dist/ecosystem.js +11 -11
  45. package/dist/extras.cjs +251 -87
  46. package/dist/extras.d.cts +2 -2
  47. package/dist/extras.d.ts +2 -2
  48. package/dist/extras.js +25 -25
  49. package/dist/index.cjs +358 -104
  50. package/dist/index.d.cts +287 -34
  51. package/dist/index.d.ts +287 -34
  52. package/dist/index.js +17 -15
  53. package/dist/{introspect-RjLfIFpL.d.cts → introspect-D5xF-0Es.d.cts} +7 -0
  54. package/dist/{introspect-DOZfmC-4.d.ts → introspect-rSBIxEQi.d.ts} +7 -0
  55. package/dist/motion.cjs +21 -23
  56. package/dist/motion.js +5 -5
  57. package/dist/patterns.cjs +24 -25
  58. package/dist/patterns.d.cts +8 -0
  59. package/dist/patterns.d.ts +8 -0
  60. package/dist/patterns.js +7 -7
  61. package/dist/performance.cjs +24 -28
  62. package/dist/performance.js +9 -9
  63. package/dist/plugins.cjs +268 -87
  64. package/dist/plugins.d.cts +92 -0
  65. package/dist/plugins.d.ts +92 -0
  66. package/dist/plugins.js +18 -17
  67. package/dist/{ssr-JFP5535P.js → ssr-Y7XOEPEN.js} +5 -5
  68. package/dist/ssr.cjs +241 -80
  69. package/dist/ssr.js +12 -12
  70. package/dist/testing.cjs +19 -20
  71. package/dist/testing.js +5 -5
  72. package/dist/ui.cjs +106 -44
  73. package/dist/ui.d.cts +7 -1
  74. package/dist/ui.d.ts +7 -1
  75. package/dist/ui.js +10 -10
  76. package/dist/widgets.cjs +21 -22
  77. package/dist/widgets.d.cts +8 -0
  78. package/dist/widgets.d.ts +8 -0
  79. package/dist/widgets.js +9 -9
  80. package/package.json +11 -2
package/dist/devtools.cjs CHANGED
@@ -172,23 +172,22 @@ function checkLeaks() {
172
172
  }
173
173
 
174
174
  // src/core/dev.ts
175
+ var DEV = typeof __SIBU_DEV__ !== "undefined" ? !!__SIBU_DEV__ : typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
176
+ // safe default: off in browser, on in test/dev Node
177
+ typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
178
+ );
175
179
  function isDev() {
176
- return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
177
- // The bare `__SIBU_DEV__` is a bundler define that only exists in
178
- // production builds; under the test runner it is always undefined, so
179
- // this branch is unreachable here.
180
- /* v8 ignore next 2 */
181
- typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
182
- );
180
+ if (typeof globalThis.__SIBU_DEV__ !== "undefined") return !!globalThis.__SIBU_DEV__;
181
+ if (typeof __SIBU_DEV__ !== "undefined") return !!__SIBU_DEV__;
182
+ return typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
183
183
  }
184
- var _isDev = isDev();
185
184
  function devAssert(condition, message) {
186
- if (_isDev && !condition) {
185
+ if ((typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) && !condition) {
187
186
  throw new Error(`[SibuJS] ${message}`);
188
187
  }
189
188
  }
190
189
  function devWarn(message) {
191
- if (_isDev) {
190
+ if (typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) {
192
191
  console.warn(`[SibuJS] ${message}`);
193
192
  }
194
193
  }
@@ -499,7 +498,14 @@ function reactiveBinding(commit, ownerNode) {
499
498
  subscriber._disposed = false;
500
499
  subscriber._errorPhase = "binding";
501
500
  subscriber._errorNode = ownerNode;
502
- run();
501
+ try {
502
+ run();
503
+ } catch (err) {
504
+ subscriber._disposed = true;
505
+ subscriber._errorNode = void 0;
506
+ cleanup(subscriber);
507
+ throw err;
508
+ }
503
509
  return subscriber._dispose ?? (subscriber._dispose = () => {
504
510
  subscriber._disposed = true;
505
511
  subscriber._errorNode = void 0;
@@ -730,17 +736,16 @@ function forEachSubscriber(signal2, visit) {
730
736
  }
731
737
 
732
738
  // src/reactivity/track.ts
733
- var _isDev2 = isDev();
734
- var _runtimeVersion = true ? "4.0.1" : "dev";
739
+ var _runtimeVersion = true ? "4.2.0" : "dev";
735
740
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
736
741
  function resolveReactiveApi() {
737
742
  const g = globalThis;
738
743
  const existing = g[REGISTRY_KEY];
739
744
  if (existing) {
740
- if (_isDev2 && !existing.__dupWarned) {
745
+ if (DEV && !existing.__dupWarned) {
741
746
  existing.__dupWarned = true;
742
747
  devWarn(
743
- `Multiple instances of the reactive runtime detected on this page (active: ${existing.version}, duplicate: ${_runtimeVersion}). Reactivity still works \u2014 all copies share the first one \u2014 but de-duplicate sibujs in your bundler (e.g. Vite optimizeDeps.exclude: ['sibujs'] or resolve.dedupe: ['sibujs']).`
748
+ `Multiple instances of the reactive runtime detected on this page (active: ${existing.version}, duplicate: ${_runtimeVersion}). Reactivity is NOT broken and no bundler configuration is required: every copy routes through the first one via a global registry, so signal writes still reach subscribers registered by any copy. This is only a SIZE issue \u2014 the duplicate copy's bytes are downloaded and parsed for nothing. If you want them back, de-duplicate sibujs in your bundler (Vite: resolve.dedupe: ['sibujs']). Mismatched VERSIONS above are worth fixing regardless, since only the first one loaded is used.`
744
749
  );
745
750
  }
746
751
  return existing;
@@ -839,7 +844,6 @@ var isBatching = API2.isBatching;
839
844
 
840
845
  // src/core/signals/signal.ts
841
846
  var _g = globalThis;
842
- var _isDev3 = isDev();
843
847
  function signal(initial, options) {
844
848
  const state2 = {
845
849
  value: initial,
@@ -852,7 +856,7 @@ function signal(initial, options) {
852
856
  _d: false,
853
857
  _validate: void 0
854
858
  };
855
- const debugName = _isDev3 ? options?.name : void 0;
859
+ const debugName = DEV ? options?.name : void 0;
856
860
  const equalsFn = options?.equals;
857
861
  if (debugName) state2.__name = debugName;
858
862
  function get() {
@@ -869,7 +873,7 @@ function signal(initial, options) {
869
873
  if (equalsFn(prev, newValue)) return;
870
874
  state2.value = newValue;
871
875
  state2.__v++;
872
- if (_isDev3) {
876
+ if (DEV) {
873
877
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
874
878
  if (hook) hook.emit("signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
875
879
  }
@@ -877,7 +881,7 @@ function signal(initial, options) {
877
881
  notifySubscribers2(state2);
878
882
  }
879
883
  };
880
- } else if (_isDev3) {
884
+ } else if (DEV) {
881
885
  set = (next) => {
882
886
  const prev = state2.value;
883
887
  const newValue = typeof next === "function" ? next(prev) : next;
@@ -902,7 +906,7 @@ function signal(initial, options) {
902
906
  }
903
907
  };
904
908
  }
905
- if (_isDev3) {
909
+ if (DEV) {
906
910
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
907
911
  if (hook) hook.emit("signal:create", { signal: state2, name: debugName, getter: get, initial });
908
912
  }
@@ -1604,7 +1608,6 @@ function reportDrainRunaway(label, executed, remaining) {
1604
1608
  { executed, remaining }
1605
1609
  );
1606
1610
  }
1607
- var _isDev4 = isDev();
1608
1611
  var activeBindingCount = 0;
1609
1612
  function dispose(node) {
1610
1613
  const stack = [node];
@@ -1627,13 +1630,13 @@ function dispose(node) {
1627
1630
  if (!pending || pending.length === 0) break;
1628
1631
  const snapshot = pending.slice();
1629
1632
  elementDisposers.delete(current);
1630
- if (_isDev4) activeBindingCount -= snapshot.length;
1633
+ if (DEV) activeBindingCount -= snapshot.length;
1631
1634
  for (let i2 = 0; i2 < snapshot.length; i2++) {
1632
1635
  if (executed >= MAX_DRAIN_TEARDOWNS) {
1633
1636
  const rest = snapshot.slice(i2);
1634
1637
  const added = elementDisposers.get(current);
1635
1638
  elementDisposers.set(current, added ? rest.concat(added) : rest);
1636
- if (_isDev4) activeBindingCount += rest.length;
1639
+ if (DEV) activeBindingCount += rest.length;
1637
1640
  reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
1638
1641
  runaway = true;
1639
1642
  break;
@@ -1,4 +1,4 @@
1
- export { D as DevToolsEvent, a as DevtoolsOverlayOptions, P as ProfilerResult, R as ReactiveNodeInfo, S as SibuError, c as checkLeaks, b as clearDebugValues, d as clearHMRModule, e as clearHMRState, f as clearPerformanceData, g as createDevtoolsOverlay, h as createErrorReporter, i as createHMRBoundary, j as createProfiler, k as debugLog, l as debugValue, m as devState, n as disableDebug, o as enableDebug, p as exposeHMR, q as formatError, r as getActiveDevTools, s as getDebugValues, t as getDependencies, u as getPerformanceReport, v as getSignalName, w as getSubscriberCount, x as hmrState, y as initDevTools, z as inspectSignal, A as isDebugEnabled, B as isHMRAvailable, C as measureRender, E as perfTracker, F as registerHMR, G as runCleanups, H as startMeasure, I as trackCleanup, J as walkDependencyGraph, K as withErrorTracking } from './introspect-RjLfIFpL.cjs';
1
+ export { D as DevToolsEvent, a as DevtoolsOverlayOptions, P as ProfilerResult, R as ReactiveNodeInfo, S as SibuError, c as checkLeaks, b as clearDebugValues, d as clearHMRModule, e as clearHMRState, f as clearPerformanceData, g as createDevtoolsOverlay, h as createErrorReporter, i as createHMRBoundary, j as createProfiler, k as debugLog, l as debugValue, m as devState, n as disableDebug, o as enableDebug, p as exposeHMR, q as formatError, r as getActiveDevTools, s as getDebugValues, t as getDependencies, u as getPerformanceReport, v as getSignalName, w as getSubscriberCount, x as hmrState, y as initDevTools, z as inspectSignal, A as isDebugEnabled, B as isHMRAvailable, C as measureRender, E as perfTracker, F as registerHMR, G as runCleanups, H as startMeasure, I as trackCleanup, J as walkDependencyGraph, K as withErrorTracking } from './introspect-D5xF-0Es.cjs';
2
2
  import './signal-BnWpq6WB.cjs';
3
3
 
4
4
  interface SignalNodeSnapshot {
@@ -1,4 +1,4 @@
1
- export { D as DevToolsEvent, a as DevtoolsOverlayOptions, P as ProfilerResult, R as ReactiveNodeInfo, S as SibuError, c as checkLeaks, b as clearDebugValues, d as clearHMRModule, e as clearHMRState, f as clearPerformanceData, g as createDevtoolsOverlay, h as createErrorReporter, i as createHMRBoundary, j as createProfiler, k as debugLog, l as debugValue, m as devState, n as disableDebug, o as enableDebug, p as exposeHMR, q as formatError, r as getActiveDevTools, s as getDebugValues, t as getDependencies, u as getPerformanceReport, v as getSignalName, w as getSubscriberCount, x as hmrState, y as initDevTools, z as inspectSignal, A as isDebugEnabled, B as isHMRAvailable, C as measureRender, E as perfTracker, F as registerHMR, G as runCleanups, H as startMeasure, I as trackCleanup, J as walkDependencyGraph, K as withErrorTracking } from './introspect-DOZfmC-4.js';
1
+ export { D as DevToolsEvent, a as DevtoolsOverlayOptions, P as ProfilerResult, R as ReactiveNodeInfo, S as SibuError, c as checkLeaks, b as clearDebugValues, d as clearHMRModule, e as clearHMRState, f as clearPerformanceData, g as createDevtoolsOverlay, h as createErrorReporter, i as createHMRBoundary, j as createProfiler, k as debugLog, l as debugValue, m as devState, n as disableDebug, o as enableDebug, p as exposeHMR, q as formatError, r as getActiveDevTools, s as getDebugValues, t as getDependencies, u as getPerformanceReport, v as getSignalName, w as getSubscriberCount, x as hmrState, y as initDevTools, z as inspectSignal, A as isDebugEnabled, B as isHMRAvailable, C as measureRender, E as perfTracker, F as registerHMR, G as runCleanups, H as startMeasure, I as trackCleanup, J as walkDependencyGraph, K as withErrorTracking } from './introspect-rSBIxEQi.js';
2
2
  import './signal-BnWpq6WB.js';
3
3
 
4
4
  interface SignalNodeSnapshot {
package/dist/devtools.js CHANGED
@@ -35,17 +35,17 @@ import {
35
35
  trackCleanup,
36
36
  walkDependencyGraph,
37
37
  withErrorTracking
38
- } from "./chunk-52ERIVFD.js";
39
- import "./chunk-5INI7D2L.js";
38
+ } from "./chunk-QL4UREZO.js";
39
+ import "./chunk-IXKSNWV5.js";
40
40
  import "./chunk-7ZHH77QA.js";
41
- import "./chunk-XDOMTQHM.js";
42
- import "./chunk-TIRZCERI.js";
43
- import "./chunk-DHDZ7IVN.js";
44
- import "./chunk-TVURNWDK.js";
45
- import "./chunk-JYXQCELN.js";
41
+ import "./chunk-7VEC3UD2.js";
42
+ import "./chunk-5DXA2J44.js";
43
+ import "./chunk-QKRPLZ2V.js";
44
+ import "./chunk-HECVW343.js";
45
+ import "./chunk-7ALC7KGE.js";
46
46
  import {
47
47
  isDev
48
- } from "./chunk-VPP2FONR.js";
48
+ } from "./chunk-2WLZ6757.js";
49
49
 
50
50
  // src/devtools/signalGraph.ts
51
51
  function getHook() {
@@ -6,8 +6,8 @@ import {
6
6
  replaceChildrenSafely,
7
7
  reportDrainRunaway,
8
8
  unregisterDisposer
9
- } from "./chunk-DHDZ7IVN.js";
10
- import "./chunk-VPP2FONR.js";
9
+ } from "./chunk-QKRPLZ2V.js";
10
+ import "./chunk-2WLZ6757.js";
11
11
  export {
12
12
  MAX_DRAIN_TEARDOWNS,
13
13
  checkLeaks,