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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SibuJS
2
2
 
3
- A lightweight, function-based frontend framework with fine-grained reactivity, direct DOM rendering, and zero compilation. **No Virtual DOM. No magic.**
3
+ A function-based frontend framework with fine-grained reactivity, direct DOM rendering, and zero compilation. **No Virtual DOM. No magic.**
4
4
 
5
5
  [NPM](https://www.npmjs.com/package/sibujs) · [License](https://github.com/hexplus/sibujs/blob/main/LICENSE)
6
6
 
@@ -147,6 +147,10 @@ The lean core: reactivity, rendering, and components. Everything below imports f
147
147
  ### Islands & Progressive Enhancement
148
148
  - **`enhance` / `enhanceAll`** — attach fine-grained reactivity to existing server-rendered HTML with no build step (the third rendering mode alongside `mount` and `hydrate`).
149
149
  - **`island` / `registerIsland` / `hydrateIslands`** — hydrate isolated interactive regions on demand.
150
+ - **`ctx.each`** — bind many elements the server already rendered (a board, a table, a keyboard) from one descriptor, with no new DOM.
151
+ - **`external`** — reactive integration with state SibuJS does not own: a domain engine, a canvas, an editor, a socket cache. `track()` where you read, `invalidate()` where you mutate.
152
+
153
+ Guides: [islands & progressive enhancement](docs/islands.md) · [external mutable state and update granularity](docs/architecture/external-state.md) · [running islands inside another framework's page](docs/interop.md). Reference application: [`examples/chess/`](examples/chess/).
150
154
 
151
155
  ---
152
156
 
@@ -196,13 +200,37 @@ Utilities for testing components and reactivity.
196
200
  ### `sibujs/cdn` — Script-tag bundle
197
201
  Self-registering IIFE build exposing `window.Sibu`, for use without a bundler.
198
202
 
203
+ There are two builds. Load **exactly one** — they both define `window.Sibu`, so
204
+ loading both leaves whichever came last in charge.
205
+
206
+ Development, with every diagnostic live:
207
+
208
+ ```html
209
+ <script src="https://unpkg.com/sibujs@latest/dist/cdn.dev.global.js"></script>
210
+ ```
211
+
212
+ Production, with diagnostics compiled out rather than merely disabled:
213
+
199
214
  ```html
200
215
  <script src="https://unpkg.com/sibujs@latest/dist/cdn.global.js"></script>
216
+ ```
217
+
218
+ Either way, the API is on `window.Sibu`:
219
+
220
+ ```html
201
221
  <script>
202
222
  const { signal, effect, div, mount } = window.Sibu;
203
223
  </script>
204
224
  ```
205
225
 
226
+ Develop against `cdn.dev.global.js` and swap the one line to ship. The runtime
227
+ behaviour is identical; only the warnings differ.
228
+
229
+ A bundled app needs neither file — import from `"sibujs"` and let your bundler
230
+ define `__SIBU_DEV__` per build (the Vite and webpack plugins in `sibujs/build`
231
+ do this for you). The two CDN files exist because a `<script>` tag has no
232
+ bundler to make that choice.
233
+
206
234
  ---
207
235
 
208
236
  ## Ecosystem
package/dist/browser.cjs CHANGED
@@ -60,23 +60,17 @@ __export(browser_exports, {
60
60
  module.exports = __toCommonJS(browser_exports);
61
61
 
62
62
  // src/core/dev.ts
63
- function isDev() {
64
- return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
65
- // The bare `__SIBU_DEV__` is a bundler define that only exists in
66
- // production builds; under the test runner it is always undefined, so
67
- // this branch is unreachable here.
68
- /* v8 ignore next 2 */
69
- typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
70
- );
71
- }
72
- var _isDev = isDev();
63
+ var DEV = typeof __SIBU_DEV__ !== "undefined" ? !!__SIBU_DEV__ : typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
64
+ // safe default: off in browser, on in test/dev Node
65
+ typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
66
+ );
73
67
  function devAssert(condition, message) {
74
- if (_isDev && !condition) {
68
+ if ((typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) && !condition) {
75
69
  throw new Error(`[SibuJS] ${message}`);
76
70
  }
77
71
  }
78
72
  function devWarn(message) {
79
- if (_isDev) {
73
+ if (typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) {
80
74
  console.warn(`[SibuJS] ${message}`);
81
75
  }
82
76
  }
@@ -387,7 +381,14 @@ function reactiveBinding(commit, ownerNode) {
387
381
  subscriber._disposed = false;
388
382
  subscriber._errorPhase = "binding";
389
383
  subscriber._errorNode = ownerNode;
390
- run();
384
+ try {
385
+ run();
386
+ } catch (err) {
387
+ subscriber._disposed = true;
388
+ subscriber._errorNode = void 0;
389
+ cleanup(subscriber);
390
+ throw err;
391
+ }
391
392
  return subscriber._dispose ?? (subscriber._dispose = () => {
392
393
  subscriber._disposed = true;
393
394
  subscriber._errorNode = void 0;
@@ -618,17 +619,16 @@ function forEachSubscriber(signal2, visit) {
618
619
  }
619
620
 
620
621
  // src/reactivity/track.ts
621
- var _isDev2 = isDev();
622
- var _runtimeVersion = true ? "4.0.1" : "dev";
622
+ var _runtimeVersion = true ? "4.2.0" : "dev";
623
623
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
624
624
  function resolveReactiveApi() {
625
625
  const g = globalThis;
626
626
  const existing = g[REGISTRY_KEY];
627
627
  if (existing) {
628
- if (_isDev2 && !existing.__dupWarned) {
628
+ if (DEV && !existing.__dupWarned) {
629
629
  existing.__dupWarned = true;
630
630
  devWarn(
631
- `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']).`
631
+ `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.`
632
632
  );
633
633
  }
634
634
  return existing;
@@ -727,7 +727,6 @@ var isBatching = API2.isBatching;
727
727
 
728
728
  // src/core/signals/signal.ts
729
729
  var _g = globalThis;
730
- var _isDev3 = isDev();
731
730
  function signal(initial, options) {
732
731
  const state2 = {
733
732
  value: initial,
@@ -740,7 +739,7 @@ function signal(initial, options) {
740
739
  _d: false,
741
740
  _validate: void 0
742
741
  };
743
- const debugName = _isDev3 ? options?.name : void 0;
742
+ const debugName = DEV ? options?.name : void 0;
744
743
  const equalsFn = options?.equals;
745
744
  if (debugName) state2.__name = debugName;
746
745
  function get() {
@@ -757,7 +756,7 @@ function signal(initial, options) {
757
756
  if (equalsFn(prev, newValue)) return;
758
757
  state2.value = newValue;
759
758
  state2.__v++;
760
- if (_isDev3) {
759
+ if (DEV) {
761
760
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
762
761
  if (hook) hook.emit("signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
763
762
  }
@@ -765,7 +764,7 @@ function signal(initial, options) {
765
764
  notifySubscribers2(state2);
766
765
  }
767
766
  };
768
- } else if (_isDev3) {
767
+ } else if (DEV) {
769
768
  set = (next) => {
770
769
  const prev = state2.value;
771
770
  const newValue = typeof next === "function" ? next(prev) : next;
@@ -790,7 +789,7 @@ function signal(initial, options) {
790
789
  }
791
790
  };
792
791
  }
793
- if (_isDev3) {
792
+ if (DEV) {
794
793
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
795
794
  if (hook) hook.emit("signal:create", { signal: state2, name: debugName, getter: get, initial });
796
795
  }
package/dist/browser.js CHANGED
@@ -35,15 +35,15 @@ import {
35
35
  visibility,
36
36
  wakeLock,
37
37
  windowSize
38
- } from "./chunk-IKVUUE7D.js";
38
+ } from "./chunk-KE4KWRDY.js";
39
39
  import "./chunk-H3SRKIYX.js";
40
40
  import "./chunk-52XFPGSN.js";
41
41
  import "./chunk-7ZHH77QA.js";
42
- import "./chunk-XDOMTQHM.js";
43
- import "./chunk-TIRZCERI.js";
44
- import "./chunk-TVURNWDK.js";
45
- import "./chunk-JYXQCELN.js";
46
- import "./chunk-VPP2FONR.js";
42
+ import "./chunk-7VEC3UD2.js";
43
+ import "./chunk-5DXA2J44.js";
44
+ import "./chunk-HECVW343.js";
45
+ import "./chunk-7ALC7KGE.js";
46
+ import "./chunk-2WLZ6757.js";
47
47
  export {
48
48
  animationFrame,
49
49
  battery,