sibujs 1.3.0 → 1.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 (87) hide show
  1. package/README.md +105 -119
  2. package/dist/browser.cjs +53 -14
  3. package/dist/browser.d.cts +14 -9
  4. package/dist/browser.d.ts +14 -9
  5. package/dist/browser.js +4 -4
  6. package/dist/build.cjs +125 -135
  7. package/dist/build.d.cts +1 -1
  8. package/dist/build.d.ts +1 -1
  9. package/dist/build.js +11 -91
  10. package/dist/cdn.global.js +6 -6
  11. package/dist/chunk-5ZYQ6KDD.js +154 -0
  12. package/dist/chunk-6BMPXPUW.js +26 -0
  13. package/dist/chunk-7GRNSCFT.js +1097 -0
  14. package/dist/chunk-BGTHZHJ5.js +1016 -0
  15. package/dist/chunk-BMPL52BF.js +654 -0
  16. package/dist/chunk-CNZ35WI2.js +178 -0
  17. package/dist/chunk-GJPXRJ45.js +37 -0
  18. package/dist/chunk-JCDUJN2F.js +2779 -0
  19. package/dist/chunk-K4G4ZQNR.js +286 -0
  20. package/dist/chunk-M4NLBH4I.js +725 -0
  21. package/dist/chunk-MB6QFH3I.js +2776 -0
  22. package/dist/chunk-MYRV7VDM.js +742 -0
  23. package/dist/chunk-NZIIMDWI.js +84 -0
  24. package/dist/chunk-P3XWXJZU.js +282 -0
  25. package/dist/chunk-PDZQY43A.js +616 -0
  26. package/dist/chunk-RJ46C3CS.js +1293 -0
  27. package/dist/chunk-SFKNRVCU.js +292 -0
  28. package/dist/chunk-TDGZL5CU.js +365 -0
  29. package/dist/chunk-UHNL42EF.js +2730 -0
  30. package/dist/chunk-VAPYJN4X.js +368 -0
  31. package/dist/chunk-VQDZK23A.js +1023 -0
  32. package/dist/chunk-VQNQZCWJ.js +61 -0
  33. package/dist/chunk-XHK6BDAJ.js +76 -0
  34. package/dist/chunk-XUEEGU5O.js +409 -0
  35. package/dist/chunk-ZWKZCBO6.js +317 -0
  36. package/dist/contracts-ey_Qh8ef.d.cts +239 -0
  37. package/dist/contracts-ey_Qh8ef.d.ts +239 -0
  38. package/dist/contracts-xo5ckdRP.d.cts +240 -0
  39. package/dist/contracts-xo5ckdRP.d.ts +240 -0
  40. package/dist/customElement-BL3Uo8dL.d.cts +318 -0
  41. package/dist/customElement-BL3Uo8dL.d.ts +318 -0
  42. package/dist/data.cjs +52 -11
  43. package/dist/data.js +6 -6
  44. package/dist/devtools.cjs +22 -24
  45. package/dist/devtools.d.cts +1 -1
  46. package/dist/devtools.d.ts +1 -1
  47. package/dist/devtools.js +26 -28
  48. package/dist/ecosystem.cjs +31 -6
  49. package/dist/ecosystem.d.cts +4 -4
  50. package/dist/ecosystem.d.ts +4 -4
  51. package/dist/ecosystem.js +7 -7
  52. package/dist/extras.cjs +305 -131
  53. package/dist/extras.d.cts +3 -3
  54. package/dist/extras.d.ts +3 -3
  55. package/dist/extras.js +21 -29
  56. package/dist/index.cjs +124 -56
  57. package/dist/index.d.cts +60 -72
  58. package/dist/index.d.ts +60 -72
  59. package/dist/index.js +10 -14
  60. package/dist/motion.cjs +13 -2
  61. package/dist/motion.d.cts +1 -1
  62. package/dist/motion.d.ts +1 -1
  63. package/dist/motion.js +3 -3
  64. package/dist/patterns.cjs +91 -46
  65. package/dist/patterns.d.cts +46 -60
  66. package/dist/patterns.d.ts +46 -60
  67. package/dist/patterns.js +6 -14
  68. package/dist/performance.cjs +97 -12
  69. package/dist/performance.d.cts +6 -1
  70. package/dist/performance.d.ts +6 -1
  71. package/dist/performance.js +5 -3
  72. package/dist/plugins.cjs +20 -14
  73. package/dist/plugins.d.cts +3 -3
  74. package/dist/plugins.d.ts +3 -3
  75. package/dist/plugins.js +17 -19
  76. package/dist/ssr.cjs +9 -0
  77. package/dist/ssr.d.cts +1 -1
  78. package/dist/ssr.d.ts +1 -1
  79. package/dist/ssr.js +7 -7
  80. package/dist/testing.js +2 -2
  81. package/dist/ui.cjs +130 -53
  82. package/dist/ui.d.cts +13 -16
  83. package/dist/ui.d.ts +13 -16
  84. package/dist/ui.js +7 -9
  85. package/dist/widgets.cjs +31 -6
  86. package/dist/widgets.js +5 -5
  87. package/package.json +1 -1
package/dist/devtools.js CHANGED
@@ -33,11 +33,11 @@ import {
33
33
  trackCleanup,
34
34
  walkDependencyGraph,
35
35
  withErrorTracking
36
- } from "./chunk-77L6NL3X.js";
37
- import "./chunk-CHF5OHIA.js";
36
+ } from "./chunk-7GRNSCFT.js";
37
+ import "./chunk-VQNQZCWJ.js";
38
38
  import "./chunk-EUZND3CB.js";
39
- import "./chunk-WZSPOOER.js";
40
- import "./chunk-ZD6OAMTH.js";
39
+ import "./chunk-NZIIMDWI.js";
40
+ import "./chunk-K4G4ZQNR.js";
41
41
  import {
42
42
  isDev
43
43
  } from "./chunk-5X6PP2UK.js";
@@ -100,55 +100,53 @@ function createTraceProfiler() {
100
100
  }
101
101
  const start = typeof performance !== "undefined" ? performance.now() : Date.now();
102
102
  let recording = true;
103
- const onEffectStart = (payload) => {
103
+ function now() {
104
+ return (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
105
+ }
106
+ const onEffectCreate = (payload) => {
104
107
  if (!recording) return;
105
- const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
106
- const label = payload.name ?? "effect";
107
108
  events.push({
108
- name: label,
109
+ name: payload.name ?? "effect",
109
110
  cat: "effect",
110
- ph: "B",
111
- ts: Math.floor(now * 1e3),
111
+ ph: "I",
112
+ ts: Math.floor(now() * 1e3),
112
113
  tid: 0,
113
114
  pid: 0
114
115
  });
115
116
  };
116
- const onEffectEnd = (payload) => {
117
+ const onEffectDestroy = (payload) => {
117
118
  if (!recording) return;
118
- const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
119
- const label = payload.name ?? "effect";
120
119
  events.push({
121
- name: label,
120
+ name: payload.name ?? "effect:destroy",
122
121
  cat: "effect",
123
- ph: "E",
124
- ts: Math.floor(now * 1e3),
122
+ ph: "I",
123
+ ts: Math.floor(now() * 1e3),
125
124
  tid: 0,
126
125
  pid: 0
127
126
  });
128
127
  };
129
- const onSignalSet = (payload) => {
128
+ const onSignalUpdate = (payload) => {
130
129
  if (!recording) return;
131
- const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
132
- const label = payload.name ?? "signal";
130
+ const p = payload;
133
131
  events.push({
134
- name: label,
132
+ name: p.name ?? "signal",
135
133
  cat: "signal",
136
134
  ph: "I",
137
- ts: Math.floor(now * 1e3),
135
+ ts: Math.floor(now() * 1e3),
138
136
  tid: 0,
139
137
  pid: 0,
140
- args: payload.args
138
+ args: p.oldValue !== void 0 ? { oldValue: String(p.oldValue), newValue: String(p.newValue) } : void 0
141
139
  });
142
140
  };
143
- const offStart = hook.on("effect:start", onEffectStart);
144
- const offEnd = hook.on("effect:end", onEffectEnd);
145
- const offSet = hook.on("signal:set", onSignalSet);
141
+ const offCreate = hook.on("effect:create", onEffectCreate);
142
+ const offDestroy = hook.on("effect:destroy", onEffectDestroy);
143
+ const offUpdate = hook.on("signal:update", onSignalUpdate);
146
144
  function stop() {
147
145
  if (!recording) return events;
148
146
  recording = false;
149
- offStart();
150
- offEnd();
151
- offSet();
147
+ offCreate();
148
+ offDestroy();
149
+ offUpdate();
152
150
  return events;
153
151
  }
154
152
  function stopTrace() {
@@ -126,12 +126,21 @@ function queueSignalNotification(signal2) {
126
126
  }
127
127
  }
128
128
  }
129
+ var MAX_DRAIN_ITERATIONS = 1e3;
129
130
  function drainNotificationQueue() {
130
131
  if (notifyDepth > 0) return;
131
132
  notifyDepth++;
132
133
  try {
133
134
  let i = 0;
134
135
  while (i < pendingQueue.length) {
136
+ if (i >= MAX_DRAIN_ITERATIONS) {
137
+ if (typeof console !== "undefined") {
138
+ console.error(
139
+ `[SibuJS] Notification queue exceeded ${MAX_DRAIN_ITERATIONS} iterations \u2014 likely an effect that writes to a signal it reads. Breaking to prevent infinite loop.`
140
+ );
141
+ }
142
+ break;
143
+ }
135
144
  safeInvoke(pendingQueue[i]);
136
145
  i++;
137
146
  }
@@ -436,21 +445,37 @@ function derived(getter, options) {
436
445
  cs._v = getter();
437
446
  }, markDirty);
438
447
  const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
448
+ let evaluating = false;
439
449
  function computedGetter() {
450
+ if (evaluating) {
451
+ throw new Error(
452
+ `[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
453
+ );
454
+ }
440
455
  if (trackingSuspended) {
441
456
  if (cs._d) {
442
- cs._d = false;
443
- cs._v = getter();
457
+ evaluating = true;
458
+ try {
459
+ cs._d = false;
460
+ cs._v = getter();
461
+ } finally {
462
+ evaluating = false;
463
+ }
444
464
  }
445
465
  return cs._v;
446
466
  }
447
467
  recordDependency(cs);
448
468
  if (cs._d) {
449
469
  const oldValue = cs._v;
450
- track(() => {
451
- cs._d = false;
452
- cs._v = getter();
453
- }, markDirty);
470
+ evaluating = true;
471
+ try {
472
+ track(() => {
473
+ cs._d = false;
474
+ cs._v = getter();
475
+ }, markDirty);
476
+ } finally {
477
+ evaluating = false;
478
+ }
454
479
  if (hook && oldValue !== cs._v) {
455
480
  hook.emit("computed:update", { signal: cs, oldValue, newValue: cs._v });
456
481
  }
@@ -48,7 +48,7 @@ interface MobXAdapterAPI {
48
48
  *
49
49
  * const mobx = inject<MobXAdapterAPI>("mobx");
50
50
  * const todoCount = mobx.fromMobX(() => todoStore.todos.length);
51
- * div({ nodes: () => `Todos: ${todoCount()}` });
51
+ * div(() => `Todos: ${todoCount()}`);
52
52
  * ```
53
53
  */
54
54
  declare function mobXAdapter(options: MobXAdapterOptions): SibuPlugin;
@@ -90,7 +90,7 @@ interface ReduxAdapterAPI<S = unknown> {
90
90
  *
91
91
  * const redux = inject<ReduxAdapterAPI>("redux");
92
92
  * const count = redux.useSelector(s => s.counter);
93
- * div({ nodes: () => `Count: ${count()}` });
93
+ * div(() => `Count: ${count()}`);
94
94
  * ```
95
95
  */
96
96
  declare function reduxAdapter<S>(options: ReduxAdapterOptions<S>): SibuPlugin;
@@ -133,7 +133,7 @@ interface ZustandAdapterAPI<S> {
133
133
  *
134
134
  * const zs = inject<ZustandAdapterAPI>("zustand");
135
135
  * const bears = zs.useSelector(s => s.bears);
136
- * div({ nodes: () => `Bears: ${bears()}` });
136
+ * div(() => `Bears: ${bears()}`);
137
137
  * ```
138
138
  */
139
139
  declare function zustandAdapter<S>(options: ZustandAdapterOptions<S>): SibuPlugin;
@@ -204,7 +204,7 @@ type AdaptedComponent = (props?: AdaptedComponentProps) => Element;
204
204
  * });
205
205
  *
206
206
  * const { Button } = adapter.components;
207
- * Button({ variant: "raised", nodes: "Click me" });
207
+ * Button({ variant: "raised" }, "Click me");
208
208
  * ```
209
209
  */
210
210
  declare function componentAdapter(config: AdapterConfig): {
@@ -48,7 +48,7 @@ interface MobXAdapterAPI {
48
48
  *
49
49
  * const mobx = inject<MobXAdapterAPI>("mobx");
50
50
  * const todoCount = mobx.fromMobX(() => todoStore.todos.length);
51
- * div({ nodes: () => `Todos: ${todoCount()}` });
51
+ * div(() => `Todos: ${todoCount()}`);
52
52
  * ```
53
53
  */
54
54
  declare function mobXAdapter(options: MobXAdapterOptions): SibuPlugin;
@@ -90,7 +90,7 @@ interface ReduxAdapterAPI<S = unknown> {
90
90
  *
91
91
  * const redux = inject<ReduxAdapterAPI>("redux");
92
92
  * const count = redux.useSelector(s => s.counter);
93
- * div({ nodes: () => `Count: ${count()}` });
93
+ * div(() => `Count: ${count()}`);
94
94
  * ```
95
95
  */
96
96
  declare function reduxAdapter<S>(options: ReduxAdapterOptions<S>): SibuPlugin;
@@ -133,7 +133,7 @@ interface ZustandAdapterAPI<S> {
133
133
  *
134
134
  * const zs = inject<ZustandAdapterAPI>("zustand");
135
135
  * const bears = zs.useSelector(s => s.bears);
136
- * div({ nodes: () => `Bears: ${bears()}` });
136
+ * div(() => `Bears: ${bears()}`);
137
137
  * ```
138
138
  */
139
139
  declare function zustandAdapter<S>(options: ZustandAdapterOptions<S>): SibuPlugin;
@@ -204,7 +204,7 @@ type AdaptedComponent = (props?: AdaptedComponentProps) => Element;
204
204
  * });
205
205
  *
206
206
  * const { Button } = adapter.components;
207
- * Button({ variant: "raised", nodes: "Click me" });
207
+ * Button({ variant: "raised" }, "Click me");
208
208
  * ```
209
209
  */
210
210
  declare function componentAdapter(config: AdapterConfig): {
package/dist/ecosystem.js CHANGED
@@ -7,16 +7,16 @@ import {
7
7
  mobXAdapter,
8
8
  reduxAdapter,
9
9
  zustandAdapter
10
- } from "./chunk-BTU3TJDS.js";
10
+ } from "./chunk-TDGZL5CU.js";
11
11
  import "./chunk-K5ZUMYVS.js";
12
- import "./chunk-F3FA4F32.js";
13
- import "./chunk-PTQJDMRT.js";
14
- import "./chunk-NEKUBFPT.js";
12
+ import "./chunk-SFKNRVCU.js";
13
+ import "./chunk-5ZYQ6KDD.js";
14
+ import "./chunk-XHK6BDAJ.js";
15
15
  import "./chunk-CMBFNA7L.js";
16
- import "./chunk-CHF5OHIA.js";
16
+ import "./chunk-VQNQZCWJ.js";
17
17
  import "./chunk-EUZND3CB.js";
18
- import "./chunk-WZSPOOER.js";
19
- import "./chunk-ZD6OAMTH.js";
18
+ import "./chunk-NZIIMDWI.js";
19
+ import "./chunk-K4G4ZQNR.js";
20
20
  import "./chunk-5X6PP2UK.js";
21
21
  export {
22
22
  antdAdapter,