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/devtools.js CHANGED
@@ -33,14 +33,133 @@ import {
33
33
  trackCleanup,
34
34
  walkDependencyGraph,
35
35
  withErrorTracking
36
- } from "./chunk-7BF6TK55.js";
37
- import "./chunk-6SA3QQES.js";
38
- import "./chunk-CHJ27IGK.js";
39
- import "./chunk-V2XTI523.js";
40
- import "./chunk-UNXCEF6S.js";
41
- import "./chunk-MLKGABMK.js";
36
+ } from "./chunk-77L6NL3X.js";
37
+ import "./chunk-CHF5OHIA.js";
38
+ import "./chunk-EUZND3CB.js";
39
+ import "./chunk-WZSPOOER.js";
40
+ import "./chunk-ZD6OAMTH.js";
41
+ import {
42
+ isDev
43
+ } from "./chunk-5X6PP2UK.js";
44
+
45
+ // src/devtools/signalGraph.ts
46
+ function getHook() {
47
+ if (!isDev()) return null;
48
+ const g = globalThis;
49
+ return g.__SIBU_DEVTOOLS_GLOBAL_HOOK__ ?? null;
50
+ }
51
+ function captureSignalGraph() {
52
+ const hook = getHook();
53
+ if (!hook || typeof hook.getSignalNodes !== "function") {
54
+ return { capturedAt: Date.now(), nodes: [], edgeCount: 0 };
55
+ }
56
+ const nodes = [];
57
+ let edgeCount = 0;
58
+ for (const n of hook.getSignalNodes()) {
59
+ nodes.push({
60
+ id: n.id,
61
+ name: n.name,
62
+ kind: n.kind,
63
+ value: n.value,
64
+ subscribers: [...n.subscribers],
65
+ dependencies: [...n.dependencies],
66
+ evalCount: n.evalCount
67
+ });
68
+ edgeCount += n.dependencies.length;
69
+ }
70
+ return { capturedAt: Date.now(), nodes, edgeCount };
71
+ }
72
+ function diffSignalGraphs(before, after) {
73
+ const beforeById = new Map(before.nodes.map((n) => [n.id, n]));
74
+ const afterById = new Map(after.nodes.map((n) => [n.id, n]));
75
+ const added = [];
76
+ const removed = [];
77
+ const reevaluated = [];
78
+ for (const [id, node] of afterById) {
79
+ if (!beforeById.has(id)) {
80
+ added.push(node);
81
+ continue;
82
+ }
83
+ const prev = beforeById.get(id);
84
+ if (prev && prev.evalCount !== node.evalCount) reevaluated.push(node);
85
+ }
86
+ for (const [id, node] of beforeById) {
87
+ if (!afterById.has(id)) removed.push(node);
88
+ }
89
+ return { added, removed, reevaluated };
90
+ }
91
+ function createTraceProfiler() {
92
+ const events = [];
93
+ const hook = getHook();
94
+ if (!hook) {
95
+ return {
96
+ stop: () => events,
97
+ stopTrace: () => JSON.stringify({ traceEvents: events }),
98
+ isRecording: () => false
99
+ };
100
+ }
101
+ const start = typeof performance !== "undefined" ? performance.now() : Date.now();
102
+ let recording = true;
103
+ const onEffectStart = (payload) => {
104
+ if (!recording) return;
105
+ const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
106
+ const label = payload.name ?? "effect";
107
+ events.push({
108
+ name: label,
109
+ cat: "effect",
110
+ ph: "B",
111
+ ts: Math.floor(now * 1e3),
112
+ tid: 0,
113
+ pid: 0
114
+ });
115
+ };
116
+ const onEffectEnd = (payload) => {
117
+ if (!recording) return;
118
+ const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
119
+ const label = payload.name ?? "effect";
120
+ events.push({
121
+ name: label,
122
+ cat: "effect",
123
+ ph: "E",
124
+ ts: Math.floor(now * 1e3),
125
+ tid: 0,
126
+ pid: 0
127
+ });
128
+ };
129
+ const onSignalSet = (payload) => {
130
+ if (!recording) return;
131
+ const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
132
+ const label = payload.name ?? "signal";
133
+ events.push({
134
+ name: label,
135
+ cat: "signal",
136
+ ph: "I",
137
+ ts: Math.floor(now * 1e3),
138
+ tid: 0,
139
+ pid: 0,
140
+ args: payload.args
141
+ });
142
+ };
143
+ const offStart = hook.on("effect:start", onEffectStart);
144
+ const offEnd = hook.on("effect:end", onEffectEnd);
145
+ const offSet = hook.on("signal:set", onSignalSet);
146
+ function stop() {
147
+ if (!recording) return events;
148
+ recording = false;
149
+ offStart();
150
+ offEnd();
151
+ offSet();
152
+ return events;
153
+ }
154
+ function stopTrace() {
155
+ stop();
156
+ return JSON.stringify({ traceEvents: events, displayTimeUnit: "ms" });
157
+ }
158
+ return { stop, stopTrace, isRecording: () => recording };
159
+ }
42
160
  export {
43
161
  SibuError,
162
+ captureSignalGraph,
44
163
  checkLeaks,
45
164
  clearDebugValues,
46
165
  clearHMRState,
@@ -49,9 +168,11 @@ export {
49
168
  createErrorReporter,
50
169
  createHMRBoundary,
51
170
  createProfiler,
171
+ createTraceProfiler,
52
172
  debugLog,
53
173
  debugValue,
54
174
  devState,
175
+ diffSignalGraphs,
55
176
  disableDebug,
56
177
  enableDebug,
57
178
  formatError,
@@ -539,7 +539,20 @@ function isUrlAttribute(attr) {
539
539
 
540
540
  // src/reactivity/bindAttribute.ts
541
541
  var _isDev4 = isDev();
542
+ function isEventHandlerAttr(name) {
543
+ if (name.length < 3) return false;
544
+ const lower = name.toLowerCase();
545
+ return lower[0] === "o" && lower[1] === "n" && lower.charCodeAt(2) >= 97 && lower.charCodeAt(2) <= 122;
546
+ }
542
547
  function bindAttribute(el, attr, getter) {
548
+ if (isEventHandlerAttr(attr)) {
549
+ if (_isDev4)
550
+ devWarn(
551
+ `bindAttribute: refusing to bind event-handler attribute "${attr}". Use on:{ ${attr.slice(2)}: fn } instead.`
552
+ );
553
+ return () => {
554
+ };
555
+ }
543
556
  function commit() {
544
557
  let value;
545
558
  try {
@@ -582,11 +595,11 @@ function bindChildNode(placeholder, getter) {
582
595
  if (_isDev5) devWarn(`bindChildNode: getter threw: ${err instanceof Error ? err.message : String(err)}`);
583
596
  return;
584
597
  }
585
- for (let i = 0; i < lastNodes.length; i++) {
586
- const node = lastNodes[i];
587
- if (node.parentNode) node.parentNode.removeChild(node);
588
- }
589
598
  if (result == null || typeof result === "boolean") {
599
+ for (let i = 0; i < lastNodes.length; i++) {
600
+ const node = lastNodes[i];
601
+ if (node.parentNode) node.parentNode.removeChild(node);
602
+ }
590
603
  lastNodes.length = 0;
591
604
  return;
592
605
  }
@@ -595,24 +608,46 @@ function bindChildNode(placeholder, getter) {
595
608
  lastNodes.length = 0;
596
609
  return;
597
610
  }
598
- const anchor = placeholder.nextSibling;
599
- let count = 0;
611
+ let newNodes;
600
612
  if (Array.isArray(result)) {
601
- if (lastNodes.length < result.length) lastNodes = new Array(result.length);
613
+ newNodes = [];
602
614
  for (let i = 0; i < result.length; i++) {
603
615
  const item = result[i];
604
616
  if (item == null || typeof item === "boolean") continue;
605
- const node = item instanceof Node ? item : document.createTextNode(String(item));
606
- parent.insertBefore(node, anchor);
607
- lastNodes[count++] = node;
617
+ newNodes.push(item instanceof Node ? item : document.createTextNode(String(item)));
608
618
  }
609
619
  } else {
610
- if (lastNodes.length < 1) lastNodes = [null];
611
620
  const node = result instanceof Node ? result : document.createTextNode(String(result));
612
- parent.insertBefore(node, anchor);
613
- lastNodes[count++] = node;
621
+ newNodes = [node];
622
+ }
623
+ const reused = lastNodes.length > 0 && newNodes.length > 0 ? /* @__PURE__ */ new Set() : void 0;
624
+ if (reused) {
625
+ for (let i = 0; i < newNodes.length; i++) {
626
+ for (let j = 0; j < lastNodes.length; j++) {
627
+ if (newNodes[i] === lastNodes[j]) {
628
+ reused.add(newNodes[i]);
629
+ break;
630
+ }
631
+ }
632
+ }
614
633
  }
615
- lastNodes.length = count;
634
+ for (let i = 0; i < lastNodes.length; i++) {
635
+ const node = lastNodes[i];
636
+ if (reused?.has(node)) continue;
637
+ if (node.parentNode) node.parentNode.removeChild(node);
638
+ }
639
+ const anchor = placeholder.nextSibling;
640
+ for (let i = 0; i < newNodes.length; i++) {
641
+ const node = newNodes[i];
642
+ if (reused?.has(node) && node.parentNode === parent) {
643
+ if (node.nextSibling !== anchor) {
644
+ parent.insertBefore(node, anchor);
645
+ }
646
+ } else {
647
+ parent.insertBefore(node, anchor);
648
+ }
649
+ }
650
+ lastNodes = newNodes;
616
651
  }
617
652
  return track(commit);
618
653
  }
@@ -759,16 +794,20 @@ function appendChildren(el, nodes) {
759
794
  var tagFactory = (tag, ns) => (first, second) => {
760
795
  const el = ns ? document.createElementNS(ns, tag) : document.createElement(tag);
761
796
  if (first === void 0) return el;
762
- if (second === void 0 && typeof first === "string") {
797
+ if (typeof first === "string") {
798
+ if (second !== void 0) {
799
+ el.setAttribute("class", first);
800
+ appendChildren(el, second);
801
+ return el;
802
+ }
763
803
  el.textContent = first;
764
804
  return el;
765
805
  }
766
- if (second !== void 0) {
767
- el.setAttribute("class", first);
768
- appendChildren(el, second);
806
+ if (typeof first === "number") {
807
+ el.textContent = String(first);
769
808
  return el;
770
809
  }
771
- if (Array.isArray(first) || first instanceof Node) {
810
+ if (Array.isArray(first) || first instanceof Node || typeof first === "function") {
772
811
  appendChildren(el, first);
773
812
  return el;
774
813
  }
@@ -777,7 +816,7 @@ var tagFactory = (tag, ns) => (first, second) => {
777
816
  if (pClass != null) applyClass(el, pClass);
778
817
  const pId = props.id;
779
818
  if (pId != null) el.id = pId;
780
- const pNodes = props.nodes;
819
+ const pNodes = second !== void 0 ? second : props.nodes;
781
820
  if (pNodes != null) appendChildren(el, pNodes);
782
821
  const pOn = props.on;
783
822
  if (pOn) {
@@ -802,12 +841,18 @@ var tagFactory = (tag, ns) => (first, second) => {
802
841
  // already handled above / below
803
842
  default: {
804
843
  const value = props[key];
805
- if (value == null || value === false) continue;
844
+ if (value == null) continue;
806
845
  if (key[0] === "o" && key[1] === "n") continue;
807
846
  if (typeof value === "function") {
808
847
  registerDisposer(el, bindAttribute(el, key, value));
809
- } else if (value === true) {
810
- el.setAttribute(key, "");
848
+ } else if (typeof value === "boolean") {
849
+ if (key in el && (key === "checked" || key === "disabled" || key === "selected")) {
850
+ el[key] = value;
851
+ } else if (value) {
852
+ el.setAttribute(key, "");
853
+ } else {
854
+ el.removeAttribute(key);
855
+ }
811
856
  } else {
812
857
  const str = String(value);
813
858
  el.setAttribute(key, isUrlAttribute(key) ? sanitizeUrl(str) : str);
@@ -1,5 +1,5 @@
1
1
  import { S as SibuPlugin } from './plugin-Bek4RhJY.cjs';
2
- import { T as TagProps } from './tagFactory-Dl8QCLga.cjs';
2
+ import { T as TagProps } from './tagFactory-DaJ0YWX6.cjs';
3
3
 
4
4
  /** MobX autorun disposer function type. */
5
5
  type MobXReactionDisposer = () => void;
@@ -1,5 +1,5 @@
1
1
  import { S as SibuPlugin } from './plugin-Bek4RhJY.js';
2
- import { T as TagProps } from './tagFactory-Dl8QCLga.js';
2
+ import { T as TagProps } from './tagFactory-DaJ0YWX6.js';
3
3
 
4
4
  /** MobX autorun disposer function type. */
5
5
  type MobXReactionDisposer = () => void;
package/dist/ecosystem.js CHANGED
@@ -7,16 +7,17 @@ import {
7
7
  mobXAdapter,
8
8
  reduxAdapter,
9
9
  zustandAdapter
10
- } from "./chunk-EVCZO745.js";
10
+ } from "./chunk-BTU3TJDS.js";
11
11
  import "./chunk-K5ZUMYVS.js";
12
- import "./chunk-WADYRCO2.js";
13
- import "./chunk-23VV7YD3.js";
14
- import "./chunk-L6JRBDNS.js";
15
- import "./chunk-6SA3QQES.js";
16
- import "./chunk-CHJ27IGK.js";
17
- import "./chunk-V2XTI523.js";
18
- import "./chunk-UNXCEF6S.js";
19
- import "./chunk-MLKGABMK.js";
12
+ import "./chunk-F3FA4F32.js";
13
+ import "./chunk-PTQJDMRT.js";
14
+ import "./chunk-NEKUBFPT.js";
15
+ import "./chunk-CMBFNA7L.js";
16
+ import "./chunk-CHF5OHIA.js";
17
+ import "./chunk-EUZND3CB.js";
18
+ import "./chunk-WZSPOOER.js";
19
+ import "./chunk-ZD6OAMTH.js";
20
+ import "./chunk-5X6PP2UK.js";
20
21
  export {
21
22
  antdAdapter,
22
23
  chakraAdapter,