sibujs 4.3.0 → 4.5.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 (77) hide show
  1. package/README.md +34 -4
  2. package/dist/browser.cjs +31 -2
  3. package/dist/browser.d.cts +15 -2
  4. package/dist/browser.d.ts +15 -2
  5. package/dist/browser.js +4 -4
  6. package/dist/build.cjs +92 -13
  7. package/dist/build.js +10 -10
  8. package/dist/cdn.dev.global.js +10 -10
  9. package/dist/cdn.full.dev.global.js +400 -0
  10. package/dist/cdn.full.global.js +398 -0
  11. package/dist/cdn.global.js +10 -10
  12. package/dist/{chunk-GZYQNIPS.js → chunk-2DCGACUU.js} +16 -9
  13. package/dist/{chunk-7BPN4MXR.js → chunk-3JZ4L5TJ.js} +10 -4
  14. package/dist/{chunk-R4EF7V3K.js → chunk-4PMLNECI.js} +4 -4
  15. package/dist/{chunk-IYHM4FWD.js → chunk-7LN645I6.js} +1 -1
  16. package/dist/{chunk-RE6KLGMV.js → chunk-B3WHI2QA.js} +1 -1
  17. package/dist/{chunk-ZVYNIUOG.js → chunk-FTIR4QW2.js} +13 -3
  18. package/dist/{chunk-G7GPNB6N.js → chunk-GW3SCCZG.js} +4 -4
  19. package/dist/{chunk-XGCZ45NH.js → chunk-KEISJXBU.js} +2 -2
  20. package/dist/{chunk-UD6YE2GW.js → chunk-OMJJM3KM.js} +2 -2
  21. package/dist/{chunk-7UBG6LDP.js → chunk-ONOHFDLG.js} +9 -1
  22. package/dist/{chunk-7UK6BSAT.js → chunk-PCT43HW3.js} +1 -1
  23. package/dist/{chunk-VJE6DDYM.js → chunk-R25EFXXC.js} +40 -26
  24. package/dist/{chunk-3E5YNK2F.js → chunk-RBTPLM32.js} +46 -8
  25. package/dist/{chunk-7BJLKDBI.js → chunk-RIXRAYIU.js} +1 -1
  26. package/dist/{chunk-7GQIRV27.js → chunk-RJE2BNI4.js} +3 -3
  27. package/dist/{chunk-2LSY4WDM.js → chunk-S373NSMK.js} +18 -13
  28. package/dist/{chunk-AAHT6AKT.js → chunk-TBYTO6BS.js} +2 -2
  29. package/dist/{chunk-TSL64O5L.js → chunk-UGRX3S57.js} +31 -2
  30. package/dist/{chunk-L4B3Y3OM.js → chunk-VUF4ALSW.js} +1 -1
  31. package/dist/{chunk-USS5ENJ2.js → chunk-VZKNK2V7.js} +9 -4
  32. package/dist/{chunk-MYA5HEK5.js → chunk-XZZOBQAY.js} +1 -1
  33. package/dist/{contracts-Hg6ITAEF.d.cts → contracts-DBdg9J_a.d.cts} +25 -4
  34. package/dist/{contracts-Hg6ITAEF.d.ts → contracts-DBdg9J_a.d.ts} +25 -4
  35. package/dist/{customElement-CNZxEB9G.d.ts → customElement-OB9CIsc5.d.cts} +38 -10
  36. package/dist/{customElement-CNZxEB9G.d.cts → customElement-OB9CIsc5.d.ts} +38 -10
  37. package/dist/data.cjs +81 -9
  38. package/dist/data.js +6 -6
  39. package/dist/devtools.cjs +41 -2
  40. package/dist/devtools.js +4 -4
  41. package/dist/ecosystem.cjs +83 -9
  42. package/dist/ecosystem.d.cts +13 -5
  43. package/dist/ecosystem.d.ts +13 -5
  44. package/dist/ecosystem.js +7 -7
  45. package/dist/extras.cjs +150 -40
  46. package/dist/extras.d.cts +3 -3
  47. package/dist/extras.d.ts +3 -3
  48. package/dist/extras.js +20 -20
  49. package/dist/index.cjs +92 -13
  50. package/dist/index.d.cts +24 -151
  51. package/dist/index.d.ts +24 -151
  52. package/dist/index.js +10 -10
  53. package/dist/motion.cjs +31 -2
  54. package/dist/motion.js +3 -3
  55. package/dist/patterns.cjs +116 -36
  56. package/dist/patterns.d.cts +6 -1
  57. package/dist/patterns.d.ts +6 -1
  58. package/dist/patterns.js +6 -6
  59. package/dist/performance.cjs +31 -2
  60. package/dist/performance.js +4 -4
  61. package/dist/plugins.cjs +39 -2
  62. package/dist/plugins.js +6 -6
  63. package/dist/ssr.cjs +39 -2
  64. package/dist/ssr.js +7 -7
  65. package/dist/tagFactory-DVoDpHye.d.cts +215 -0
  66. package/dist/tagFactory-DVoDpHye.d.ts +215 -0
  67. package/dist/testing.cjs +31 -2
  68. package/dist/testing.js +2 -2
  69. package/dist/ui.cjs +128 -39
  70. package/dist/ui.d.cts +2 -2
  71. package/dist/ui.d.ts +2 -2
  72. package/dist/ui.js +7 -7
  73. package/dist/widgets.cjs +75 -9
  74. package/dist/widgets.js +6 -6
  75. package/package.json +8 -2
  76. package/dist/tagFactory-Bzupt4Pj.d.cts +0 -55
  77. package/dist/tagFactory-Bzupt4Pj.d.ts +0 -55
package/dist/widgets.cjs CHANGED
@@ -291,6 +291,15 @@ function untracked(fn) {
291
291
  var subscriberEpochCounter = 0;
292
292
  function retrack(effectFn, subscriber) {
293
293
  const prev = currentSubscriber;
294
+ let savedDepth = 0;
295
+ let savedSuspendSub = null;
296
+ if (trackingSuspended) {
297
+ savedDepth = suspendDepth;
298
+ savedSuspendSub = suspendSavedSub;
299
+ suspendDepth = 0;
300
+ suspendSavedSub = null;
301
+ trackingSuspended = false;
302
+ }
294
303
  currentSubscriber = subscriber;
295
304
  const sub = subscriber;
296
305
  const epoch = ++subscriberEpochCounter;
@@ -305,6 +314,11 @@ function retrack(effectFn, subscriber) {
305
314
  effectFn();
306
315
  } finally {
307
316
  currentSubscriber = prev;
317
+ if (savedDepth !== 0) {
318
+ suspendDepth = savedDepth;
319
+ suspendSavedSub = savedSuspendSub;
320
+ trackingSuspended = true;
321
+ }
308
322
  let node = sub.depsHead ?? null;
309
323
  while (node !== null) {
310
324
  const next = node.subNext;
@@ -324,11 +338,25 @@ function track(effectFn, subscriber) {
324
338
  if (!subscriber) return reactiveBinding(effectFn);
325
339
  cleanup(subscriber);
326
340
  const prev = currentSubscriber;
341
+ let savedDepth = 0;
342
+ let savedSuspendSub = null;
343
+ if (trackingSuspended) {
344
+ savedDepth = suspendDepth;
345
+ savedSuspendSub = suspendSavedSub;
346
+ suspendDepth = 0;
347
+ suspendSavedSub = null;
348
+ trackingSuspended = false;
349
+ }
327
350
  currentSubscriber = subscriber;
328
351
  try {
329
352
  effectFn();
330
353
  } finally {
331
354
  currentSubscriber = prev;
355
+ if (savedDepth !== 0) {
356
+ suspendDepth = savedDepth;
357
+ suspendSavedSub = savedSuspendSub;
358
+ trackingSuspended = true;
359
+ }
332
360
  const sub2 = subscriber;
333
361
  for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
334
362
  const sig = n.sig;
@@ -499,8 +527,9 @@ function propagateDirty(sub) {
499
527
  if (s._c) {
500
528
  const nSig = s._sig;
501
529
  if (nSig) {
502
- if (!nSig._d) {
530
+ if (!nSig._d || nSig._f === true) {
503
531
  nSig._d = true;
532
+ nSig._f = false;
504
533
  stack.push(nSig);
505
534
  }
506
535
  } else {
@@ -600,7 +629,7 @@ function forEachSubscriber(signal2, visit) {
600
629
  }
601
630
 
602
631
  // src/reactivity/track.ts
603
- var _runtimeVersion = true ? "4.3.0" : "dev";
632
+ var _runtimeVersion = true ? "4.5.0" : "dev";
604
633
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
605
634
  function resolveReactiveApi() {
606
635
  const g = globalThis;
@@ -664,10 +693,14 @@ function derived(getter, options) {
664
693
  const cs = {};
665
694
  cs._d = false;
666
695
  cs._init = false;
696
+ cs._f = false;
667
697
  cs._g = getter;
668
698
  cs.__v = 0;
699
+ let evaluating = false;
700
+ let disposed = false;
701
+ let pendingError;
669
702
  const markDirty = () => {
670
- if (cs._d) return;
703
+ if (cs._d || disposed) return;
671
704
  cs._d = true;
672
705
  };
673
706
  markDirty._c = 1;
@@ -690,33 +723,53 @@ function derived(getter, options) {
690
723
  }
691
724
  }, markDirty);
692
725
  const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
693
- let evaluating = false;
694
726
  const validate = () => {
695
- if (!cs._d) return;
727
+ if (!cs._d || disposed || pendingError !== void 0) return;
696
728
  const oldValue = cs._v;
697
729
  evaluating = true;
698
730
  try {
699
731
  retrack2(recompute, markDirty);
700
732
  if (!Object.is(oldValue, cs._v)) cs.__v++;
733
+ } catch (err) {
734
+ pendingError = { error: err };
735
+ cs.__v++;
736
+ if (disposed) cs._d = true;
737
+ else cs._f = true;
701
738
  } finally {
702
739
  evaluating = false;
740
+ if (disposed) cleanup2(markDirty);
703
741
  }
704
- if (hook && !Object.is(oldValue, cs._v)) {
742
+ if (hook && !disposed && !Object.is(oldValue, cs._v)) {
705
743
  hook.emit("computed:update", { signal: cs, oldValue, newValue: cs._v });
706
744
  }
707
745
  };
708
746
  cs._validate = validate;
747
+ const throwPending = () => {
748
+ const { error } = pendingError;
749
+ pendingError = void 0;
750
+ if (disposed) cs._d = false;
751
+ throw error;
752
+ };
709
753
  function computedGetter() {
710
754
  if (evaluating) {
711
755
  throw new Error(
712
756
  `[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
713
757
  );
714
758
  }
715
- if (isTrackingSuspended2()) {
716
- if (cs._d) validate();
759
+ if (isTrackingSuspended2() || disposed) {
760
+ if (cs._d) {
761
+ validate();
762
+ if (pendingError !== void 0) throwPending();
763
+ }
717
764
  return cs._v;
718
765
  }
719
- if (cs._d) validate();
766
+ if (cs._d) {
767
+ validate();
768
+ if (pendingError !== void 0) {
769
+ recordDependency2(cs);
770
+ throwPending();
771
+ }
772
+ }
720
773
  recordDependency2(cs);
721
774
  return cs._v;
722
775
  }
@@ -725,6 +778,19 @@ function derived(getter, options) {
725
778
  cs.__name = debugName;
726
779
  }
727
780
  computedGetter.__signal = cs;
781
+ computedGetter.dispose = () => {
782
+ if (disposed) return;
783
+ disposed = true;
784
+ cs._d = pendingError !== void 0;
785
+ cleanup2(markDirty);
786
+ const h = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
787
+ if (h) {
788
+ try {
789
+ h.emit("computed:destroy", { signal: cs, getter: computedGetter });
790
+ } catch {
791
+ }
792
+ }
793
+ };
728
794
  if (hook) hook.emit("computed:create", { signal: cs, name: debugName, getter: computedGetter });
729
795
  return computedGetter;
730
796
  }
package/dist/widgets.js CHANGED
@@ -8,15 +8,15 @@ import {
8
8
  select,
9
9
  tabs,
10
10
  tooltip
11
- } from "./chunk-G7GPNB6N.js";
12
- import "./chunk-IYHM4FWD.js";
11
+ } from "./chunk-GW3SCCZG.js";
12
+ import "./chunk-7LN645I6.js";
13
13
  import "./chunk-CCSJMTRN.js";
14
- import "./chunk-3E5YNK2F.js";
14
+ import "./chunk-RBTPLM32.js";
15
15
  import "./chunk-IXKSNWV5.js";
16
- import "./chunk-7BJLKDBI.js";
16
+ import "./chunk-RIXRAYIU.js";
17
17
  import "./chunk-5DXA2J44.js";
18
- import "./chunk-MYA5HEK5.js";
19
- import "./chunk-TSL64O5L.js";
18
+ import "./chunk-XZZOBQAY.js";
19
+ import "./chunk-UGRX3S57.js";
20
20
  import "./chunk-2WLZ6757.js";
21
21
  export {
22
22
  accordion,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sibujs",
3
- "version": "4.3.0",
4
- "description": "A lightweight, function-based frontend framework that combines the best of React, Svelte, and Vue — with zero VDOM and maximum simplicity. Designed for developers who want fine-grained reactivity and full control without compilation or magic.",
3
+ "version": "4.5.0",
4
+ "description": "A function-based frontend framework with fine-grained reactivity and no virtual DOM. Tag factories return live DOM nodes you can hold and mutate, signals update only what changed, and nothing needs a compiler — it runs from a script tag or a bundler.",
5
5
  "keywords": [
6
6
  "frontend",
7
7
  "framework",
@@ -133,6 +133,12 @@
133
133
  },
134
134
  "./cdn-dev": {
135
135
  "default": "./dist/cdn.dev.global.js"
136
+ },
137
+ "./cdn-full": {
138
+ "default": "./dist/cdn.full.global.js"
139
+ },
140
+ "./cdn-full-dev": {
141
+ "default": "./dist/cdn.full.dev.global.js"
136
142
  }
137
143
  },
138
144
  "publishConfig": {
@@ -1,55 +0,0 @@
1
- /**
2
- * Canonical disposer/teardown signature used across the framework.
3
- *
4
- * Returned by `effect()`, `track()`, widget `bind()` methods, and other
5
- * subscription/lifecycle helpers. All disposers MUST be idempotent — calling
6
- * twice should be a no-op rather than an error.
7
- */
8
- type Dispose = () => void;
9
- type NodeChild = Node | Element | Text | Comment | string | number | boolean | (() => NodeChild) | null | undefined;
10
- type NodeChildren = NodeChild | NodeChild[] | NodeChild[][] | (() => NodeChild | NodeChild[]);
11
-
12
- declare const SVG_NS = "http://www.w3.org/2000/svg";
13
- interface TagProps {
14
- id?: string;
15
- class?: string | (() => string) | Record<string, boolean | (() => boolean)>;
16
- style?: Record<string, string | number | (() => string | number)> | string | (() => string);
17
- ref?: {
18
- current: Element | null;
19
- };
20
- nodes?: NodeChildren;
21
- on?: Record<string, (ev: Event) => void>;
22
- /** Called with the element after creation — useful for imperative bindings */
23
- onElement?: (el: HTMLElement) => void;
24
- [attr: string]: unknown;
25
- }
26
- /**
27
- * Factory for creating HTML or SVG elements with reactive props and nodes.
28
- *
29
- * Calling conventions:
30
- *
31
- * tag() empty element
32
- * tag("text") element with text content
33
- * tag(42) element with numeric text content
34
- * tag([childA, childB]) element with children (array)
35
- * tag(node) element wrapping a single existing node
36
- * tag(getter) element with a reactive child
37
- * tag("className", children) positional: class + children
38
- * tag({ ...props }) full props object (children via props.nodes)
39
- * tag({ ...props }, children) props + children (no need for `nodes:` key!)
40
- *
41
- * The last form is the "deeply-nested shorthand" the codebase favours:
42
- *
43
- * div({ class: "card" }, [
44
- * h1({ class: "title" }, "Hello"),
45
- * p({ class: "body" }, "World"),
46
- * div({ class: "row" }, [
47
- * span({ id: "x" }, "child"),
48
- * ]),
49
- * ])
50
- *
51
- * `children` overrides `props.nodes` when both are present.
52
- */
53
- declare const tagFactory: (tag: string, ns?: string) => (first?: TagProps | NodeChildren, second?: NodeChildren) => Element;
54
-
55
- export { type Dispose as D, type NodeChild as N, SVG_NS as S, type TagProps as T, type NodeChildren as a, tagFactory as t };
@@ -1,55 +0,0 @@
1
- /**
2
- * Canonical disposer/teardown signature used across the framework.
3
- *
4
- * Returned by `effect()`, `track()`, widget `bind()` methods, and other
5
- * subscription/lifecycle helpers. All disposers MUST be idempotent — calling
6
- * twice should be a no-op rather than an error.
7
- */
8
- type Dispose = () => void;
9
- type NodeChild = Node | Element | Text | Comment | string | number | boolean | (() => NodeChild) | null | undefined;
10
- type NodeChildren = NodeChild | NodeChild[] | NodeChild[][] | (() => NodeChild | NodeChild[]);
11
-
12
- declare const SVG_NS = "http://www.w3.org/2000/svg";
13
- interface TagProps {
14
- id?: string;
15
- class?: string | (() => string) | Record<string, boolean | (() => boolean)>;
16
- style?: Record<string, string | number | (() => string | number)> | string | (() => string);
17
- ref?: {
18
- current: Element | null;
19
- };
20
- nodes?: NodeChildren;
21
- on?: Record<string, (ev: Event) => void>;
22
- /** Called with the element after creation — useful for imperative bindings */
23
- onElement?: (el: HTMLElement) => void;
24
- [attr: string]: unknown;
25
- }
26
- /**
27
- * Factory for creating HTML or SVG elements with reactive props and nodes.
28
- *
29
- * Calling conventions:
30
- *
31
- * tag() empty element
32
- * tag("text") element with text content
33
- * tag(42) element with numeric text content
34
- * tag([childA, childB]) element with children (array)
35
- * tag(node) element wrapping a single existing node
36
- * tag(getter) element with a reactive child
37
- * tag("className", children) positional: class + children
38
- * tag({ ...props }) full props object (children via props.nodes)
39
- * tag({ ...props }, children) props + children (no need for `nodes:` key!)
40
- *
41
- * The last form is the "deeply-nested shorthand" the codebase favours:
42
- *
43
- * div({ class: "card" }, [
44
- * h1({ class: "title" }, "Hello"),
45
- * p({ class: "body" }, "World"),
46
- * div({ class: "row" }, [
47
- * span({ id: "x" }, "child"),
48
- * ]),
49
- * ])
50
- *
51
- * `children` overrides `props.nodes` when both are present.
52
- */
53
- declare const tagFactory: (tag: string, ns?: string) => (first?: TagProps | NodeChildren, second?: NodeChildren) => Element;
54
-
55
- export { type Dispose as D, type NodeChild as N, SVG_NS as S, type TagProps as T, type NodeChildren as a, tagFactory as t };