sibujs 1.0.0-beta.7 → 1.0.1

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 (105) hide show
  1. package/dist/browser.cjs +47 -25
  2. package/dist/browser.js +4 -3
  3. package/dist/build.cjs +281 -62
  4. package/dist/build.js +10 -9
  5. package/dist/cdn.global.js +4 -4
  6. package/dist/chunk-24WSRM54.js +2002 -0
  7. package/dist/chunk-2GLUWW3D.js +567 -0
  8. package/dist/chunk-3CRQALYP.js +877 -0
  9. package/dist/chunk-526ENZ77.js +58 -0
  10. package/dist/chunk-5KBEED6D.js +361 -0
  11. package/dist/chunk-5M7LJFWV.js +271 -0
  12. package/dist/chunk-5ZFVYPDG.js +97 -0
  13. package/dist/chunk-6EYXAMBN.js +1857 -0
  14. package/dist/chunk-6HLLIF3K.js +398 -0
  15. package/dist/chunk-6J6S4NI7.js +398 -0
  16. package/dist/chunk-6NBHAKHS.js +1997 -0
  17. package/dist/chunk-7LS3ITZB.js +567 -0
  18. package/dist/chunk-7TQKR4PP.js +294 -0
  19. package/dist/chunk-ANRSGGFC.js +725 -0
  20. package/dist/chunk-BWBWJYBK.js +271 -0
  21. package/dist/chunk-CZUGLNJS.js +37 -0
  22. package/dist/chunk-DB243LB7.js +877 -0
  23. package/dist/chunk-DGUYCZJH.js +654 -0
  24. package/dist/chunk-DTCOOBMX.js +725 -0
  25. package/dist/chunk-FGOEVHY3.js +60 -0
  26. package/dist/chunk-FYIGTFXO.js +712 -0
  27. package/dist/chunk-GXIM4TC3.js +346 -0
  28. package/dist/chunk-HGMJFBC7.js +654 -0
  29. package/dist/chunk-HKUNBYN6.js +949 -0
  30. package/dist/chunk-HS6OOE3Q.js +365 -0
  31. package/dist/chunk-HZWNWUPJ.js +466 -0
  32. package/dist/chunk-I6EZTMPB.js +949 -0
  33. package/dist/chunk-IK3NFZOA.js +466 -0
  34. package/dist/chunk-JRWAHOMS.js +41 -0
  35. package/dist/chunk-KALKXPC3.js +297 -0
  36. package/dist/chunk-KKUV25KB.js +361 -0
  37. package/dist/chunk-L36YN45V.js +949 -0
  38. package/dist/chunk-LHNJSLC6.js +297 -0
  39. package/dist/chunk-MBINISSE.js +35 -0
  40. package/dist/chunk-MGYRVG2A.js +282 -0
  41. package/dist/chunk-MJ4LVHGX.js +712 -0
  42. package/dist/chunk-MLN3JZ2E.js +398 -0
  43. package/dist/chunk-N6IZB6KJ.js +567 -0
  44. package/dist/chunk-NMRUZALC.js +1097 -0
  45. package/dist/chunk-NMTRH4Q3.js +97 -0
  46. package/dist/chunk-OEGAHDEU.js +1094 -0
  47. package/dist/chunk-ONCYDOK6.js +466 -0
  48. package/dist/chunk-OWLQ4HZI.js +282 -0
  49. package/dist/chunk-OZS4YOOP.js +59 -0
  50. package/dist/chunk-PZEGYCF5.js +61 -0
  51. package/dist/chunk-QUGIYF3F.js +712 -0
  52. package/dist/chunk-QVKGGB2S.js +300 -0
  53. package/dist/chunk-QYSW3K7A.js +282 -0
  54. package/dist/chunk-RUAJTILD.js +26 -0
  55. package/dist/chunk-S6YEHFC7.js +654 -0
  56. package/dist/chunk-SDLZDHKP.js +107 -0
  57. package/dist/chunk-SU63HSUU.js +58 -0
  58. package/dist/chunk-T2SPHHYU.js +365 -0
  59. package/dist/chunk-UATXXETW.js +278 -0
  60. package/dist/chunk-UXDIPRCG.js +26 -0
  61. package/dist/chunk-V4G5Y6YM.js +1094 -0
  62. package/dist/chunk-VAA4FG3Z.js +365 -0
  63. package/dist/chunk-VUXB655T.js +1999 -0
  64. package/dist/chunk-XZGY5ZJ4.js +35 -0
  65. package/dist/chunk-Y6GP4QGG.js +276 -0
  66. package/dist/chunk-YECR7UIA.js +347 -0
  67. package/dist/chunk-Z65KYU7I.js +26 -0
  68. package/dist/chunk-Z6GZHJW5.js +877 -0
  69. package/dist/data.cjs +47 -25
  70. package/dist/data.js +6 -5
  71. package/dist/devtools.cjs +46 -24
  72. package/dist/devtools.js +4 -3
  73. package/dist/ecosystem.cjs +65 -31
  74. package/dist/ecosystem.js +7 -6
  75. package/dist/extras.cjs +172 -45
  76. package/dist/extras.d.cts +1 -1
  77. package/dist/extras.d.ts +1 -1
  78. package/dist/extras.js +23 -20
  79. package/dist/index.cjs +291 -63
  80. package/dist/index.d.cts +196 -7
  81. package/dist/index.d.ts +196 -7
  82. package/dist/index.js +32 -13
  83. package/dist/motion.cjs +82 -15
  84. package/dist/motion.d.cts +43 -1
  85. package/dist/motion.d.ts +43 -1
  86. package/dist/motion.js +5 -2
  87. package/dist/patterns.cjs +52 -25
  88. package/dist/patterns.d.cts +15 -0
  89. package/dist/patterns.d.ts +15 -0
  90. package/dist/patterns.js +5 -4
  91. package/dist/performance.cjs +29 -15
  92. package/dist/performance.js +3 -2
  93. package/dist/plugins.cjs +127 -41
  94. package/dist/plugins.js +9 -8
  95. package/dist/ssr-GEOEYQV7.js +35 -0
  96. package/dist/ssr-WKUPVSSK.js +36 -0
  97. package/dist/ssr.cjs +111 -42
  98. package/dist/ssr.d.cts +9 -3
  99. package/dist/ssr.d.ts +9 -3
  100. package/dist/ssr.js +8 -7
  101. package/dist/ui.cjs +49 -24
  102. package/dist/ui.js +6 -5
  103. package/dist/widgets.cjs +36 -22
  104. package/dist/widgets.js +5 -4
  105. package/package.json +1 -1
package/dist/browser.cjs CHANGED
@@ -36,7 +36,24 @@ __export(browser_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(browser_exports);
38
38
 
39
+ // src/core/dev.ts
40
+ function isDev() {
41
+ return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : true;
42
+ }
43
+ var _isDev = isDev();
44
+ function devAssert(condition, message) {
45
+ if (_isDev && !condition) {
46
+ throw new Error(`[Sibu] ${message}`);
47
+ }
48
+ }
49
+ function devWarn(message) {
50
+ if (_isDev) {
51
+ console.warn(`[Sibu] ${message}`);
52
+ }
53
+ }
54
+
39
55
  // src/reactivity/track.ts
56
+ var _isDev2 = isDev();
40
57
  var subscriberStack = new Array(32);
41
58
  var stackCapacity = 32;
42
59
  var stackTop = -1;
@@ -46,6 +63,13 @@ var SUBS = "__s";
46
63
  var notifyDepth = 0;
47
64
  var pendingQueue = [];
48
65
  var pendingSet = /* @__PURE__ */ new Set();
66
+ function safeInvoke(sub) {
67
+ try {
68
+ sub();
69
+ } catch (err) {
70
+ if (_isDev2) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
71
+ }
72
+ }
49
73
  function track(effectFn, subscriber) {
50
74
  if (!subscriber) subscriber = effectFn;
51
75
  cleanup(subscriber);
@@ -112,7 +136,7 @@ function drainNotificationQueue() {
112
136
  try {
113
137
  let i = 0;
114
138
  while (i < pendingQueue.length) {
115
- pendingQueue[i]();
139
+ safeInvoke(pendingQueue[i]);
116
140
  i++;
117
141
  }
118
142
  } finally {
@@ -176,11 +200,11 @@ function notifySubscribers(signal2) {
176
200
  if (first._c) {
177
201
  propagateDirty(first);
178
202
  } else {
179
- first();
203
+ safeInvoke(first);
180
204
  }
181
205
  let i = 0;
182
206
  while (i < pendingQueue.length) {
183
- pendingQueue[i]();
207
+ safeInvoke(pendingQueue[i]);
184
208
  i++;
185
209
  }
186
210
  } finally {
@@ -217,13 +241,13 @@ function notifySubscribers(signal2) {
217
241
  for (let i2 = 0; i2 < directCount; i2++) {
218
242
  if (!pendingQueue[i2]._c) {
219
243
  if (!pendingSet.has(pendingQueue[i2])) {
220
- pendingQueue[i2]();
244
+ safeInvoke(pendingQueue[i2]);
221
245
  }
222
246
  }
223
247
  }
224
248
  let i = directCount;
225
249
  while (i < pendingQueue.length) {
226
- pendingQueue[i]();
250
+ safeInvoke(pendingQueue[i]);
227
251
  i++;
228
252
  }
229
253
  } finally {
@@ -266,7 +290,7 @@ var pendingSignals = /* @__PURE__ */ new Set();
266
290
  function batch(fn) {
267
291
  batchDepth++;
268
292
  try {
269
- fn();
293
+ return fn();
270
294
  } finally {
271
295
  batchDepth--;
272
296
  if (batchDepth === 0) {
@@ -287,23 +311,13 @@ function flushBatch() {
287
311
  drainNotificationQueue();
288
312
  }
289
313
 
290
- // src/core/dev.ts
291
- function isDev() {
292
- return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : true;
293
- }
294
- var _isDev = isDev();
295
- function devAssert(condition, message) {
296
- if (_isDev && !condition) {
297
- throw new Error(`[Sibu] ${message}`);
298
- }
299
- }
300
-
301
314
  // src/core/signals/signal.ts
302
315
  var _g = globalThis;
303
- var _isDev2 = isDev();
316
+ var _isDev3 = isDev();
304
317
  function signal(initial, options) {
305
318
  const state = { value: initial };
306
- const debugName = _isDev2 ? options?.name : void 0;
319
+ const debugName = _isDev3 ? options?.name : void 0;
320
+ const equalsFn = options?.equals;
307
321
  if (debugName) {
308
322
  state.__name = debugName;
309
323
  }
@@ -315,8 +329,8 @@ function signal(initial, options) {
315
329
  if (debugName) get.__name = debugName;
316
330
  function set(next) {
317
331
  const newValue = typeof next === "function" ? next(state.value) : next;
318
- if (Object.is(newValue, state.value)) return;
319
- if (_isDev2) {
332
+ if (equalsFn ? equalsFn(state.value, newValue) : Object.is(newValue, state.value)) return;
333
+ if (_isDev3) {
320
334
  const oldValue = state.value;
321
335
  state.value = newValue;
322
336
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
@@ -328,7 +342,7 @@ function signal(initial, options) {
328
342
  notifySubscribers(state);
329
343
  }
330
344
  }
331
- if (_isDev2) {
345
+ if (_isDev3) {
332
346
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
333
347
  if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
334
348
  }
@@ -362,17 +376,25 @@ function isSSR() {
362
376
 
363
377
  // src/core/signals/effect.ts
364
378
  var _g2 = globalThis;
365
- function effect(effectFn) {
379
+ function effect(effectFn, options) {
366
380
  devAssert(typeof effectFn === "function", "effect: argument must be a function.");
367
381
  if (isSSR()) return () => {
368
382
  };
383
+ const onError = options?.onError;
384
+ const wrappedFn = onError ? () => {
385
+ try {
386
+ effectFn();
387
+ } catch (err) {
388
+ onError(err);
389
+ }
390
+ } : effectFn;
369
391
  let cleanupHandle = () => {
370
392
  };
371
393
  const subscriber = () => {
372
394
  cleanupHandle();
373
- cleanupHandle = track(effectFn, subscriber);
395
+ cleanupHandle = track(wrappedFn, subscriber);
374
396
  };
375
- cleanupHandle = track(effectFn, subscriber);
397
+ cleanupHandle = track(wrappedFn, subscriber);
376
398
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
377
399
  if (hook) hook.emit("effect:create", { effectFn });
378
400
  return () => {
package/dist/browser.js CHANGED
@@ -12,10 +12,11 @@ import {
12
12
  resize,
13
13
  scroll,
14
14
  title
15
- } from "./chunk-OXYMB6VB.js";
16
- import "./chunk-3GZTRYSY.js";
15
+ } from "./chunk-ONCYDOK6.js";
16
+ import "./chunk-PZEGYCF5.js";
17
17
  import "./chunk-CHJ27IGK.js";
18
- import "./chunk-QZWTKX5K.js";
18
+ import "./chunk-YECR7UIA.js";
19
+ import "./chunk-4MYMUBRS.js";
19
20
  import "./chunk-MLKGABMK.js";
20
21
  export {
21
22
  battery,