sibujs 3.3.2 → 3.3.3

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 (73) hide show
  1. package/dist/browser.cjs +21 -4
  2. package/dist/browser.js +4 -4
  3. package/dist/build.cjs +10 -3
  4. package/dist/build.js +11 -11
  5. package/dist/cdn.global.js +7 -7
  6. package/dist/{chunk-N5TQVEKE.js → chunk-23VT3KZB.js} +1 -1
  7. package/dist/{chunk-IQJ36UTJ.js → chunk-25LY5SRH.js} +31 -24
  8. package/dist/{chunk-6TCOWMGY.js → chunk-5K6RVA2S.js} +1 -1
  9. package/dist/{chunk-YUBEOWII.js → chunk-5Y34FWED.js} +16 -5
  10. package/dist/chunk-7ZHH77QA.js +9 -0
  11. package/dist/{chunk-G6N3LMO2.js → chunk-F3HO2MP7.js} +1 -1
  12. package/dist/{chunk-FJIRS3FM.js → chunk-F7HW2NI5.js} +1 -3
  13. package/dist/{chunk-AEOLHSSQ.js → chunk-IEYFHN5V.js} +72 -25
  14. package/dist/{chunk-FJO2ZL4Q.js → chunk-IQN5W7GE.js} +73 -16
  15. package/dist/{chunk-JCQG2I2G.js → chunk-IWFE4AHO.js} +1 -1
  16. package/dist/{chunk-2ARSB7NG.js → chunk-MYXEBADX.js} +27 -20
  17. package/dist/{chunk-A7CZH3GN.js → chunk-QCQQ2N5H.js} +41 -20
  18. package/dist/{chunk-Q46YIQYW.js → chunk-QTOOBABV.js} +22 -5
  19. package/dist/{chunk-ZEUP4TUD.js → chunk-RZKGMHH4.js} +6 -6
  20. package/dist/{chunk-QCFBIVIQ.js → chunk-SBPUXWCE.js} +1 -1
  21. package/dist/{chunk-RLTFJYDN.js → chunk-TBDTU7UO.js} +1 -1
  22. package/dist/{chunk-P7C7SEJV.js → chunk-TVCCXPU2.js} +5 -5
  23. package/dist/{chunk-4NJEAPLI.js → chunk-UOMYIAG6.js} +1 -1
  24. package/dist/{chunk-655B7MMR.js → chunk-WFUUT6TG.js} +15 -8
  25. package/dist/{chunk-YUR5SX7F.js → chunk-WTFMV2RU.js} +70 -59
  26. package/dist/{chunk-3JHCYHWN.js → chunk-WWV3SJ3L.js} +19 -13
  27. package/dist/{chunk-62V653X2.js → chunk-Y35NQNLG.js} +79 -44
  28. package/dist/{chunk-5VH3GIDX.js → chunk-ZXCZWMZT.js} +1 -1
  29. package/dist/data.cjs +16 -2
  30. package/dist/data.js +7 -6
  31. package/dist/devtools.cjs +71 -21
  32. package/dist/devtools.d.cts +12 -5
  33. package/dist/devtools.d.ts +12 -5
  34. package/dist/devtools.js +6 -5
  35. package/dist/ecosystem.cjs +11 -2
  36. package/dist/ecosystem.js +10 -9
  37. package/dist/extras.cjs +454 -250
  38. package/dist/extras.d.cts +1 -1
  39. package/dist/extras.d.ts +1 -1
  40. package/dist/extras.js +26 -22
  41. package/dist/index.cjs +10 -3
  42. package/dist/index.d.cts +4 -1
  43. package/dist/index.d.ts +4 -1
  44. package/dist/index.js +19 -19
  45. package/dist/motion.cjs +223 -204
  46. package/dist/motion.d.cts +8 -1
  47. package/dist/motion.d.ts +8 -1
  48. package/dist/motion.js +6 -3
  49. package/dist/patterns.cjs +13 -6
  50. package/dist/patterns.d.cts +4 -1
  51. package/dist/patterns.d.ts +4 -1
  52. package/dist/patterns.js +5 -5
  53. package/dist/performance.cjs +70 -56
  54. package/dist/performance.js +6 -5
  55. package/dist/plugins.cjs +98 -42
  56. package/dist/plugins.d.cts +2 -1
  57. package/dist/plugins.d.ts +2 -1
  58. package/dist/plugins.js +90 -37
  59. package/dist/ssr.cjs +112 -91
  60. package/dist/ssr.d.cts +8 -1
  61. package/dist/ssr.d.ts +8 -1
  62. package/dist/ssr.js +9 -8
  63. package/dist/testing.cjs +18 -4
  64. package/dist/testing.js +18 -7
  65. package/dist/ui.cjs +322 -281
  66. package/dist/ui.d.cts +0 -20
  67. package/dist/ui.d.ts +0 -20
  68. package/dist/ui.js +28 -22
  69. package/dist/widgets.cjs +75 -13
  70. package/dist/widgets.d.cts +6 -1
  71. package/dist/widgets.d.ts +6 -1
  72. package/dist/widgets.js +7 -6
  73. package/package.json +1 -1
package/dist/devtools.cjs CHANGED
@@ -609,7 +609,7 @@ function forEachSubscriber(signal2, visit) {
609
609
 
610
610
  // src/reactivity/track.ts
611
611
  var _isDev3 = isDev();
612
- var _runtimeVersion = true ? "3.3.2" : "dev";
612
+ var _runtimeVersion = true ? "3.3.3" : "dev";
613
613
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
614
614
  function resolveReactiveApi() {
615
615
  const g = globalThis;
@@ -785,6 +785,12 @@ function signal(initial, options) {
785
785
  return [get, set];
786
786
  }
787
787
 
788
+ // src/utils/globalSingleton.ts
789
+ function globalSingleton(key, create) {
790
+ const g = globalThis;
791
+ return g[key] ?? (g[key] = create());
792
+ }
793
+
788
794
  // src/utils/sanitize.ts
789
795
  function stripHtml(html) {
790
796
  const input = String(html);
@@ -822,10 +828,50 @@ function createGlobalHook() {
822
828
  listeners.set(event, set);
823
829
  }
824
830
  set.add(fn);
831
+ return () => {
832
+ set?.delete(fn);
833
+ };
825
834
  },
826
835
  off(event, fn) {
827
836
  listeners.get(event)?.delete(fn);
828
837
  },
838
+ getSignalNodes() {
839
+ const out = [];
840
+ for (const [, node] of nodes) {
841
+ let value = "";
842
+ try {
843
+ const ref = node.ref;
844
+ let raw;
845
+ if (node.type === "effect") {
846
+ raw = void 0;
847
+ } else if (node.type === "computed" && ref) {
848
+ raw = ref._v;
849
+ } else if (ref && "value" in ref) {
850
+ raw = ref.value;
851
+ }
852
+ if (raw === void 0) value = "undefined";
853
+ else if (raw === null) value = "null";
854
+ else if (typeof raw === "object") value = JSON.stringify(raw);
855
+ else value = String(raw);
856
+ } catch {
857
+ value = "?";
858
+ }
859
+ if (value.length > 200) value = `${value.slice(0, 200)}...`;
860
+ out.push({
861
+ id: String(node.id),
862
+ name: node.name || null,
863
+ kind: node.type === "computed" ? "derived" : node.type,
864
+ value,
865
+ // Edge identities aren't tracked by this registry (only a subscriber
866
+ // count, via node.ref.__sc) — left empty until the core exposes the
867
+ // dependency graph. The node inventory itself is real.
868
+ subscribers: [],
869
+ dependencies: [],
870
+ evalCount: 0
871
+ });
872
+ }
873
+ return out;
874
+ },
829
875
  emit(event, payload) {
830
876
  events.push({ event, payload, ts: Date.now() });
831
877
  if (events.length > 2e3) events.splice(0, events.length - 2e3);
@@ -851,34 +897,38 @@ function getOrCreateHook() {
851
897
  }
852
898
  return g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
853
899
  }
854
- var activeDevTools = null;
855
- var nextNodeId = 0;
856
- var inferNameArmed = false;
900
+ var _dt = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.devtools.state.v1"), () => ({
901
+ active: null,
902
+ nextNodeId: 0,
903
+ // Gate for inferName(): only `true` while devtools are initialized AND in dev
904
+ // mode — otherwise skip the Error-stack walk so prod hot paths don't allocate.
905
+ inferNameArmed: false
906
+ }));
857
907
  function getActiveDevTools() {
858
- return activeDevTools;
908
+ return _dt.active;
859
909
  }
860
910
  function initDevTools(config) {
861
911
  const maxEvents = config?.maxEvents ?? 1e3;
862
912
  const enabled = config?.enabled ?? isDev();
863
913
  const expose = config?.expose ?? isDev();
864
914
  if (!enabled) return createNoopApi();
865
- inferNameArmed = true;
915
+ _dt.inferNameArmed = true;
866
916
  const hook = getOrCreateHook();
867
- nextNodeId = 0;
917
+ _dt.nextNodeId = 0;
868
918
  const eventLog = [];
869
919
  hook.on("signal:create", (payload) => {
870
920
  const p = payload;
871
- nextNodeId++;
921
+ _dt.nextNodeId++;
872
922
  const name = inferName();
873
923
  const node = {
874
- id: nextNodeId,
924
+ id: _dt.nextNodeId,
875
925
  type: "signal",
876
926
  name,
877
927
  ref: p.signal,
878
928
  getter: p.getter,
879
929
  createdAt: Date.now()
880
930
  };
881
- hook.nodes.set(nextNodeId, node);
931
+ hook.nodes.set(_dt.nextNodeId, node);
882
932
  emit();
883
933
  });
884
934
  hook.on("signal:update", (payload) => {
@@ -898,17 +948,17 @@ function initDevTools(config) {
898
948
  });
899
949
  hook.on("computed:create", (payload) => {
900
950
  const p = payload;
901
- nextNodeId++;
951
+ _dt.nextNodeId++;
902
952
  const name = inferName();
903
953
  const node = {
904
- id: nextNodeId,
954
+ id: _dt.nextNodeId,
905
955
  type: "computed",
906
956
  name,
907
957
  ref: p.signal,
908
958
  getter: p.getter,
909
959
  createdAt: Date.now()
910
960
  };
911
- hook.nodes.set(nextNodeId, node);
961
+ hook.nodes.set(_dt.nextNodeId, node);
912
962
  emit();
913
963
  });
914
964
  hook.on("computed:update", (payload) => {
@@ -925,11 +975,11 @@ function initDevTools(config) {
925
975
  emit();
926
976
  });
927
977
  hook.on("effect:create", (payload) => {
928
- nextNodeId++;
978
+ _dt.nextNodeId++;
929
979
  const name = inferName();
930
980
  const p = payload;
931
- const node = { id: nextNodeId, type: "effect", name, ref: p.effectFn, createdAt: Date.now() };
932
- hook.nodes.set(nextNodeId, node);
981
+ const node = { id: _dt.nextNodeId, type: "effect", name, ref: p.effectFn, createdAt: Date.now() };
982
+ hook.nodes.set(_dt.nextNodeId, node);
933
983
  emit();
934
984
  });
935
985
  hook.on("effect:run", (payload) => {
@@ -1086,8 +1136,8 @@ function initDevTools(config) {
1086
1136
  hook.components.clear();
1087
1137
  hook.events.length = 0;
1088
1138
  isActive = false;
1089
- inferNameArmed = false;
1090
- activeDevTools = null;
1139
+ _dt.inferNameArmed = false;
1140
+ _dt.active = null;
1091
1141
  const g = globalThis;
1092
1142
  if (g.__SIBU__) {
1093
1143
  delete g.__SIBU__.devtools;
@@ -1255,7 +1305,7 @@ function initDevTools(config) {
1255
1305
  w.__SIBU_DEVTOOLS_VERSION__ = () => changeVersion;
1256
1306
  w.__SIBU_DEVTOOLS_DATA__ = buildData;
1257
1307
  }
1258
- activeDevTools = api;
1308
+ _dt.active = api;
1259
1309
  if (typeof document !== "undefined") {
1260
1310
  domObserver = new MutationObserver((mutations) => {
1261
1311
  let changed = false;
@@ -1331,7 +1381,7 @@ function initDevTools(config) {
1331
1381
  return api;
1332
1382
  }
1333
1383
  function inferName() {
1334
- if (!inferNameArmed || !isDev()) return "anonymous";
1384
+ if (!_dt.inferNameArmed || !isDev()) return "anonymous";
1335
1385
  try {
1336
1386
  const stack = new Error().stack || "";
1337
1387
  for (const line of stack.split("\n")) {
@@ -1412,7 +1462,7 @@ function devState(name, initial) {
1412
1462
  const oldValue = get();
1413
1463
  set(next);
1414
1464
  const newValue = get();
1415
- const dt = activeDevTools;
1465
+ const dt = _dt.active;
1416
1466
  if (dt?.isEnabled() && !Object.is(oldValue, newValue)) {
1417
1467
  dt.record({ type: "state-change", component, key, oldValue, newValue, timestamp: Date.now() });
1418
1468
  }
@@ -24,12 +24,19 @@ interface SignalGraphSnapshot {
24
24
  edgeCount: number;
25
25
  }
26
26
  /**
27
- * Capture a synchronous snapshot of the reactive graph. The hook
28
- * provides a `getSignalNodes()` iterator that the core reactivity
29
- * layer populates; this function walks it and produces a serializable
30
- * view with dependency counts.
27
+ * Capture a synchronous snapshot of the reactive graph from the devtools hook's
28
+ * `getSignalNodes()`, producing a serializable view.
31
29
  *
32
- * Returns an empty snapshot when devtools are not enabled.
30
+ * Returns an empty snapshot when devtools are not enabled (`initDevTools()` has
31
+ * not run, so no hook / node registry exists).
32
+ *
33
+ * Coverage note: the default devtools hook reports the live node **inventory**
34
+ * (id / name / kind / current value) — useful for inspecting state and for
35
+ * leak-detection (how many signals/effects are alive). It does not yet report
36
+ * the dependency **edges**: the lightweight registry tracks only a subscriber
37
+ * *count*, not subscriber/dependency identities, so `subscribers`/`dependencies`
38
+ * are empty and `edgeCount` is 0 unless a richer hook supplies them. Wiring real
39
+ * edges requires the reactive core to expose its dependency sets.
33
40
  */
34
41
  declare function captureSignalGraph(): SignalGraphSnapshot;
35
42
  /**
@@ -24,12 +24,19 @@ interface SignalGraphSnapshot {
24
24
  edgeCount: number;
25
25
  }
26
26
  /**
27
- * Capture a synchronous snapshot of the reactive graph. The hook
28
- * provides a `getSignalNodes()` iterator that the core reactivity
29
- * layer populates; this function walks it and produces a serializable
30
- * view with dependency counts.
27
+ * Capture a synchronous snapshot of the reactive graph from the devtools hook's
28
+ * `getSignalNodes()`, producing a serializable view.
31
29
  *
32
- * Returns an empty snapshot when devtools are not enabled.
30
+ * Returns an empty snapshot when devtools are not enabled (`initDevTools()` has
31
+ * not run, so no hook / node registry exists).
32
+ *
33
+ * Coverage note: the default devtools hook reports the live node **inventory**
34
+ * (id / name / kind / current value) — useful for inspecting state and for
35
+ * leak-detection (how many signals/effects are alive). It does not yet report
36
+ * the dependency **edges**: the lightweight registry tracks only a subscriber
37
+ * *count*, not subscriber/dependency identities, so `subscribers`/`dependencies`
38
+ * are empty and `edgeCount` is 0 unless a richer hook supplies them. Wiring real
39
+ * edges requires the reactive core to expose its dependency sets.
33
40
  */
34
41
  declare function captureSignalGraph(): SignalGraphSnapshot;
35
42
  /**
package/dist/devtools.js CHANGED
@@ -35,13 +35,14 @@ import {
35
35
  trackCleanup,
36
36
  walkDependencyGraph,
37
37
  withErrorTracking
38
- } from "./chunk-AEOLHSSQ.js";
39
- import "./chunk-5VGSK6D2.js";
38
+ } from "./chunk-IEYFHN5V.js";
39
+ import "./chunk-7ZHH77QA.js";
40
40
  import "./chunk-L3GAGWCC.js";
41
- import "./chunk-N5TQVEKE.js";
41
+ import "./chunk-23VT3KZB.js";
42
42
  import "./chunk-S3NFJO6L.js";
43
- import "./chunk-JCQG2I2G.js";
44
- import "./chunk-4NJEAPLI.js";
43
+ import "./chunk-5VGSK6D2.js";
44
+ import "./chunk-IWFE4AHO.js";
45
+ import "./chunk-UOMYIAG6.js";
45
46
  import {
46
47
  isDev
47
48
  } from "./chunk-COY6PUD2.js";
@@ -469,7 +469,7 @@ function forEachSubscriber(signal2, visit) {
469
469
 
470
470
  // src/reactivity/track.ts
471
471
  var _isDev3 = isDev();
472
- var _runtimeVersion = true ? "3.3.2" : "dev";
472
+ var _runtimeVersion = true ? "3.3.3" : "dev";
473
473
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
474
474
  function resolveReactiveApi() {
475
475
  const g = globalThis;
@@ -801,6 +801,12 @@ function signal(initial, options) {
801
801
  return [get, set];
802
802
  }
803
803
 
804
+ // src/utils/globalSingleton.ts
805
+ function globalSingleton(key, create) {
806
+ const g = globalThis;
807
+ return g[key] ?? (g[key] = create());
808
+ }
809
+
804
810
  // src/plugins/plugin.ts
805
811
  function createPluginRegistry() {
806
812
  const installedPlugins = /* @__PURE__ */ new Set();
@@ -880,7 +886,10 @@ function createPluginRegistry() {
880
886
  };
881
887
  return registry;
882
888
  }
883
- var defaultRegistry = createPluginRegistry();
889
+ var _defaults = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.plugins.defaultRegistry.v1"), () => ({
890
+ registry: createPluginRegistry(),
891
+ touched: false
892
+ }));
884
893
  function createPlugin(name, install) {
885
894
  return { name, install };
886
895
  }
package/dist/ecosystem.js CHANGED
@@ -7,17 +7,18 @@ import {
7
7
  mobXAdapter,
8
8
  reduxAdapter,
9
9
  zustandAdapter
10
- } from "./chunk-P7C7SEJV.js";
11
- import "./chunk-3JHCYHWN.js";
12
- import "./chunk-ZEUP4TUD.js";
13
- import "./chunk-QCFBIVIQ.js";
14
- import "./chunk-G6N3LMO2.js";
15
- import "./chunk-5VGSK6D2.js";
10
+ } from "./chunk-TVCCXPU2.js";
11
+ import "./chunk-WWV3SJ3L.js";
12
+ import "./chunk-7ZHH77QA.js";
13
+ import "./chunk-RZKGMHH4.js";
14
+ import "./chunk-SBPUXWCE.js";
15
+ import "./chunk-F3HO2MP7.js";
16
16
  import "./chunk-L3GAGWCC.js";
17
- import "./chunk-N5TQVEKE.js";
17
+ import "./chunk-23VT3KZB.js";
18
18
  import "./chunk-S3NFJO6L.js";
19
- import "./chunk-JCQG2I2G.js";
20
- import "./chunk-4NJEAPLI.js";
19
+ import "./chunk-5VGSK6D2.js";
20
+ import "./chunk-IWFE4AHO.js";
21
+ import "./chunk-UOMYIAG6.js";
21
22
  import "./chunk-COY6PUD2.js";
22
23
  export {
23
24
  antdAdapter,