sibujs 4.5.0 → 4.6.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 (109) hide show
  1. package/dist/browser.cjs +309 -129
  2. package/dist/browser.d.cts +46 -14
  3. package/dist/browser.d.ts +46 -14
  4. package/dist/browser.js +8 -6
  5. package/dist/build.cjs +184 -72
  6. package/dist/build.js +15 -16
  7. package/dist/cdn.dev.global.js +12 -12
  8. package/dist/cdn.full.dev.global.js +11 -11
  9. package/dist/cdn.full.global.js +10 -10
  10. package/dist/cdn.global.js +12 -12
  11. package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
  12. package/dist/chunk-3ISI6ACU.js +44 -0
  13. package/dist/{chunk-ONOHFDLG.js → chunk-47M47FOM.js} +3 -3
  14. package/dist/chunk-5HZXGZ6T.js +24 -0
  15. package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
  16. package/dist/{chunk-UGRX3S57.js → chunk-5Q4R7HCL.js} +12 -3
  17. package/dist/{chunk-S373NSMK.js → chunk-7GQCWFOE.js} +150 -59
  18. package/dist/{chunk-FTIR4QW2.js → chunk-7NCARGJW.js} +6 -8
  19. package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
  20. package/dist/{chunk-VZKNK2V7.js → chunk-AIF3Z2T7.js} +296 -38
  21. package/dist/{chunk-4PMLNECI.js → chunk-BAAG6ZTI.js} +98 -29
  22. package/dist/{chunk-XZZOBQAY.js → chunk-D33YTSX5.js} +2 -2
  23. package/dist/{chunk-TBYTO6BS.js → chunk-DKGBBKOF.js} +136 -80
  24. package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
  25. package/dist/{chunk-GW3SCCZG.js → chunk-HYXDKS4N.js} +153 -110
  26. package/dist/chunk-J6FW5TV6.js +233 -0
  27. package/dist/{chunk-PCT43HW3.js → chunk-JSXPZCET.js} +1 -1
  28. package/dist/chunk-NYNYSPK7.js +318 -0
  29. package/dist/{chunk-RJE2BNI4.js → chunk-ORMZXBKQ.js} +108 -45
  30. package/dist/{chunk-OMJJM3KM.js → chunk-OXUY2A6L.js} +287 -130
  31. package/dist/{chunk-3JZ4L5TJ.js → chunk-PK6FK2G2.js} +181 -66
  32. package/dist/{chunk-RBTPLM32.js → chunk-QE4TTDU3.js} +2 -2
  33. package/dist/{chunk-2DCGACUU.js → chunk-SXXVZMKZ.js} +251 -66
  34. package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
  35. package/dist/{chunk-7LN645I6.js → chunk-UZQ6ALFS.js} +3 -3
  36. package/dist/{chunk-KEISJXBU.js → chunk-VVWPJ543.js} +6 -8
  37. package/dist/{chunk-RIXRAYIU.js → chunk-XC4MEKGA.js} +3 -3
  38. package/dist/{chunk-B3WHI2QA.js → chunk-XRRZKZYX.js} +55 -31
  39. package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
  40. package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
  41. package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
  42. package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
  43. package/dist/data.cjs +213 -117
  44. package/dist/data.d.cts +47 -9
  45. package/dist/data.d.ts +47 -9
  46. package/dist/data.js +12 -9
  47. package/dist/devtools.cjs +81 -57
  48. package/dist/devtools.js +7 -8
  49. package/dist/dispose-GEIG2KOF.js +28 -0
  50. package/dist/ecosystem.cjs +309 -104
  51. package/dist/ecosystem.d.cts +19 -3
  52. package/dist/ecosystem.d.ts +19 -3
  53. package/dist/ecosystem.js +12 -12
  54. package/dist/extras.cjs +2133 -863
  55. package/dist/extras.d.cts +10 -9
  56. package/dist/extras.d.ts +10 -9
  57. package/dist/extras.js +39 -28
  58. package/dist/index.cjs +184 -72
  59. package/dist/index.d.cts +22 -5
  60. package/dist/index.d.ts +22 -5
  61. package/dist/index.js +24 -27
  62. package/dist/motion.cjs +107 -41
  63. package/dist/motion.js +5 -5
  64. package/dist/patterns.cjs +317 -39
  65. package/dist/patterns.d.cts +27 -9
  66. package/dist/patterns.d.ts +27 -9
  67. package/dist/patterns.js +8 -8
  68. package/dist/performance.cjs +308 -216
  69. package/dist/performance.d.cts +2 -2
  70. package/dist/performance.d.ts +2 -2
  71. package/dist/performance.js +8 -9
  72. package/dist/plugin-DVgSnTfK.d.cts +112 -0
  73. package/dist/plugin-DVgSnTfK.d.ts +112 -0
  74. package/dist/plugins.cjs +549 -202
  75. package/dist/plugins.d.cts +3 -3
  76. package/dist/plugins.d.ts +3 -3
  77. package/dist/plugins.js +35 -23
  78. package/dist/signal-EotCj4hS.d.cts +110 -0
  79. package/dist/signal-EotCj4hS.d.ts +110 -0
  80. package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
  81. package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
  82. package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
  83. package/dist/ssr.cjs +176 -72
  84. package/dist/ssr.d.cts +9 -3
  85. package/dist/ssr.d.ts +9 -3
  86. package/dist/ssr.js +11 -12
  87. package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
  88. package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
  89. package/dist/{tagFactory-DVoDpHye.d.ts → tagFactory-DFstCLQV.d.cts} +2 -100
  90. package/dist/{tagFactory-DVoDpHye.d.cts → tagFactory-DkaNVUNV.d.ts} +2 -100
  91. package/dist/testing.cjs +2484 -2185
  92. package/dist/testing.d.cts +56 -5
  93. package/dist/testing.d.ts +56 -5
  94. package/dist/testing.js +580 -307
  95. package/dist/ui.cjs +707 -317
  96. package/dist/ui.d.cts +40 -7
  97. package/dist/ui.d.ts +40 -7
  98. package/dist/ui.js +151 -56
  99. package/dist/widgets.cjs +246 -278
  100. package/dist/widgets.js +9 -10
  101. package/package.json +1 -1
  102. package/dist/chunk-2WLZ6757.js +0 -149
  103. package/dist/chunk-CCSJMTRN.js +0 -15
  104. package/dist/chunk-QKRPLZ2V.js +0 -108
  105. package/dist/chunk-VUF4ALSW.js +0 -60
  106. package/dist/chunk-WWV3SJ3L.js +0 -131
  107. package/dist/dispose-46BOMMQJ.js +0 -19
  108. package/dist/plugin-D30wlGW5.d.cts +0 -71
  109. package/dist/plugin-D30wlGW5.d.ts +0 -71
@@ -1,9 +1,13 @@
1
1
  import {
2
- registerDisposer
3
- } from "./chunk-QKRPLZ2V.js";
2
+ adoptThenable
3
+ } from "./chunk-5HZXGZ6T.js";
4
4
  import {
5
5
  signal
6
- } from "./chunk-XZZOBQAY.js";
6
+ } from "./chunk-D33YTSX5.js";
7
+ import {
8
+ registerDisposer,
9
+ reportError
10
+ } from "./chunk-NYNYSPK7.js";
7
11
 
8
12
  // src/ui/transition.ts
9
13
  function transition(element, options = {}) {
@@ -32,6 +36,15 @@ function transition(element, options = {}) {
32
36
  resolvePrev();
33
37
  }
34
38
  }
39
+ function complete(callback, name, resolve) {
40
+ try {
41
+ callback?.();
42
+ } catch (error) {
43
+ reportError(error, { phase: "async", name, node: element });
44
+ } finally {
45
+ resolve();
46
+ }
47
+ }
35
48
  function enter() {
36
49
  return new Promise((resolve) => {
37
50
  cancelPending();
@@ -44,8 +57,7 @@ function transition(element, options = {}) {
44
57
  activeTimer = null;
45
58
  pendingResolve = null;
46
59
  if (enterClass) element.classList.remove(enterClass);
47
- onEnterDone?.();
48
- resolve();
60
+ complete(onEnterDone, "transition(onEnterDone)", resolve);
49
61
  };
50
62
  if (duration > 0) {
51
63
  pendingResolve = resolve;
@@ -66,8 +78,7 @@ function transition(element, options = {}) {
66
78
  activeTimer = null;
67
79
  pendingResolve = null;
68
80
  if (leaveClass) element.classList.remove(leaveClass);
69
- onLeaveDone?.();
70
- resolve();
81
+ complete(onLeaveDone, "transition(onLeaveDone)", resolve);
71
82
  };
72
83
  if (duration > 0) {
73
84
  pendingResolve = resolve;
@@ -274,18 +285,29 @@ async function sequence(steps) {
274
285
  function TransitionGroup(options) {
275
286
  const [elements, setElements] = signal([]);
276
287
  const positions = /* @__PURE__ */ new Map();
288
+ function runCallback(name, callback, el) {
289
+ const report = (error) => reportError(error, { phase: "async", name: `TransitionGroup.${name}`, node: el });
290
+ try {
291
+ adoptThenable(callback(el))?.then(void 0, report);
292
+ } catch (error) {
293
+ report(error);
294
+ }
295
+ }
277
296
  function add(el) {
278
297
  setElements((prev) => [...prev, el]);
279
- if (options.enter) {
280
- options.enter(el);
281
- }
298
+ if (options.enter) runCallback("enter", options.enter, el);
282
299
  }
283
300
  async function remove(el) {
284
- if (options.leave) {
285
- await options.leave(el);
301
+ try {
302
+ if (options.leave) {
303
+ await adoptThenable(options.leave(el));
304
+ }
305
+ } catch (error) {
306
+ reportError(error, { phase: "async", name: "TransitionGroup.leave", node: el });
307
+ } finally {
308
+ positions.delete(el);
309
+ setElements((prev) => prev.filter((e) => e !== el));
286
310
  }
287
- positions.delete(el);
288
- setElements((prev) => prev.filter((e) => e !== el));
289
311
  }
290
312
  function track(newElements) {
291
313
  const oldPositions = /* @__PURE__ */ new Map();
@@ -297,17 +319,13 @@ function TransitionGroup(options) {
297
319
  const currentSet = new Set(elements());
298
320
  for (const el of newElements) {
299
321
  if (!currentSet.has(el)) {
300
- if (options.enter) {
301
- options.enter(el);
302
- }
322
+ if (options.enter) runCallback("enter", options.enter, el);
303
323
  }
304
324
  }
305
325
  const newSet = new Set(newElements);
306
326
  for (const el of elements()) {
307
327
  if (!newSet.has(el)) {
308
- if (options.leave) {
309
- options.leave(el);
310
- }
328
+ if (options.leave) runCallback("leave", options.leave, el);
311
329
  }
312
330
  }
313
331
  setElements(newElements);
@@ -317,7 +335,7 @@ function TransitionGroup(options) {
317
335
  if (oldRect && typeof el.getBoundingClientRect === "function") {
318
336
  const newRect = el.getBoundingClientRect();
319
337
  if (oldRect.left !== newRect.left || oldRect.top !== newRect.top) {
320
- options.move(el);
338
+ runCallback("move", options.move, el);
321
339
  }
322
340
  }
323
341
  }
@@ -368,9 +386,13 @@ function springSignal(initial, options) {
368
386
  let target = initial;
369
387
  let rafId = null;
370
388
  let lastTime = 0;
389
+ let disposed = false;
390
+ const canAnimate = () => typeof requestAnimationFrame === "function";
371
391
  const REF_DT_MS = 1e3 / 60;
372
392
  const MAX_STEP_RATIO = 4;
373
393
  function tick(now) {
394
+ rafId = null;
395
+ if (disposed) return;
374
396
  if (lastTime === 0) lastTime = now;
375
397
  const rawDt = now - lastTime;
376
398
  lastTime = now;
@@ -383,23 +405,27 @@ function springSignal(initial, options) {
383
405
  if (Math.abs(current - target) < precision && Math.abs(velocity) < precision) {
384
406
  current = target;
385
407
  velocity = 0;
386
- rafId = null;
387
408
  lastTime = 0;
388
409
  setValue(current);
389
410
  return;
390
411
  }
391
412
  setValue(current);
413
+ if (disposed || rafId !== null) return;
392
414
  rafId = requestAnimationFrame(tick);
393
415
  }
416
+ function cancelFrame() {
417
+ if (rafId !== null) {
418
+ if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(rafId);
419
+ rafId = null;
420
+ }
421
+ }
394
422
  function set(newTarget) {
423
+ if (disposed) return;
395
424
  target = newTarget;
396
- if (prefersReducedMotion()) {
425
+ if (!canAnimate() || prefersReducedMotion()) {
397
426
  current = newTarget;
398
427
  velocity = 0;
399
- if (rafId !== null) {
400
- cancelAnimationFrame(rafId);
401
- rafId = null;
402
- }
428
+ cancelFrame();
403
429
  lastTime = 0;
404
430
  setValue(current);
405
431
  return;
@@ -410,10 +436,8 @@ function springSignal(initial, options) {
410
436
  }
411
437
  }
412
438
  function dispose() {
413
- if (rafId !== null) {
414
- cancelAnimationFrame(rafId);
415
- rafId = null;
416
- }
439
+ disposed = true;
440
+ cancelFrame();
417
441
  lastTime = 0;
418
442
  }
419
443
  return [value, set, dispose];
@@ -32,7 +32,15 @@ declare function withWrapper<P>(WrappedComponent: Component<P>, wrapper: (compon
32
32
  * Button("Click"); // type="button", disabled=false automatically
33
33
  * ```
34
34
  */
35
- declare function withDefaults<P extends object>(component: Component<P>, defaults: Partial<P>): Component<Partial<P>>;
35
+ /**
36
+ * Props accepted by a {@link withDefaults} component: every key that has a
37
+ * default becomes optional; every other key keeps its original required or
38
+ * optional status.
39
+ */
40
+ type WithDefaultsProps<P, D> = Omit<P, keyof D> & Partial<Pick<P, Extract<keyof P, keyof D>>>;
41
+ declare function withDefaults<P extends object, const D extends Partial<P> = Partial<P>>(component: Component<P>, defaults: D & {
42
+ [K in Exclude<keyof D, keyof P>]: never;
43
+ }): Component<WithDefaultsProps<P, D>>;
36
44
  /**
37
45
  * Composes multiple HOC wrappers into a single wrapper.
38
46
  * Applied from right to left (like function composition).
@@ -257,4 +265,4 @@ declare function assertType<T>(value: unknown, validator: Validator<T>, label?:
257
265
  */
258
266
  declare function createGuard<T>(validator: Validator<T>): (value: unknown) => value is T;
259
267
 
260
- export { type ComponentProps as C, type PropDef as P, RenderProp as R, type Validator as V, type PropSchema as a, assertType as b, compose as c, createGuard as d, createSlots as e, defineComponent as f, defineSlottedComponent as g, defineStrictComponent as h, validators as i, withDefaults as j, withProps as k, withWrapper as l, validateProps as v, withBoundary as w };
268
+ export { type ComponentProps as C, type PropDef as P, RenderProp as R, type Validator as V, type WithDefaultsProps as W, type PropSchema as a, assertType as b, compose as c, createGuard as d, createSlots as e, defineComponent as f, defineSlottedComponent as g, defineStrictComponent as h, validators as i, withDefaults as j, withProps as k, withWrapper as l, validateProps as v, withBoundary as w };
@@ -32,7 +32,15 @@ declare function withWrapper<P>(WrappedComponent: Component<P>, wrapper: (compon
32
32
  * Button("Click"); // type="button", disabled=false automatically
33
33
  * ```
34
34
  */
35
- declare function withDefaults<P extends object>(component: Component<P>, defaults: Partial<P>): Component<Partial<P>>;
35
+ /**
36
+ * Props accepted by a {@link withDefaults} component: every key that has a
37
+ * default becomes optional; every other key keeps its original required or
38
+ * optional status.
39
+ */
40
+ type WithDefaultsProps<P, D> = Omit<P, keyof D> & Partial<Pick<P, Extract<keyof P, keyof D>>>;
41
+ declare function withDefaults<P extends object, const D extends Partial<P> = Partial<P>>(component: Component<P>, defaults: D & {
42
+ [K in Exclude<keyof D, keyof P>]: never;
43
+ }): Component<WithDefaultsProps<P, D>>;
36
44
  /**
37
45
  * Composes multiple HOC wrappers into a single wrapper.
38
46
  * Applied from right to left (like function composition).
@@ -257,4 +265,4 @@ declare function assertType<T>(value: unknown, validator: Validator<T>, label?:
257
265
  */
258
266
  declare function createGuard<T>(validator: Validator<T>): (value: unknown) => value is T;
259
267
 
260
- export { type ComponentProps as C, type PropDef as P, RenderProp as R, type Validator as V, type PropSchema as a, assertType as b, compose as c, createGuard as d, createSlots as e, defineComponent as f, defineSlottedComponent as g, defineStrictComponent as h, validators as i, withDefaults as j, withProps as k, withWrapper as l, validateProps as v, withBoundary as w };
268
+ export { type ComponentProps as C, type PropDef as P, RenderProp as R, type Validator as V, type WithDefaultsProps as W, type PropSchema as a, assertType as b, compose as c, createGuard as d, createSlots as e, defineComponent as f, defineSlottedComponent as g, defineStrictComponent as h, validators as i, withDefaults as j, withProps as k, withWrapper as l, validateProps as v, withBoundary as w };
@@ -28,6 +28,16 @@ interface FormReturn<T extends object> {
28
28
  handleSubmit: (onSubmit: (values: T) => void | Promise<void>) => (e?: Event) => void;
29
29
  reset: () => void;
30
30
  setError: (field: keyof T, message: string) => void;
31
+ /**
32
+ * Release the form's derived graph: every field `error` and the `errors`,
33
+ * `isValid`, `isDirty`, `touched` and `values` aggregates. Call it when the
34
+ * form's owner goes away, e.g. `onCleanup(f.dispose, formElement)`.
35
+ *
36
+ * Afterwards the derived accessors are inert — they return their last
37
+ * settled values and never recompute — while field `value()`/`set()` keep
38
+ * working as plain signals. Idempotent.
39
+ */
40
+ dispose: () => void;
31
41
  }
32
42
  /**
33
43
  * Require a non-empty value. Rejects `null`, `undefined`, `""` and `[]`.
@@ -239,6 +249,12 @@ declare function FocusTrap(nodes: HTMLElement, options?: {
239
249
  * Supports two calling styles:
240
250
  * - String combo: hotkey("ctrl+shift+z", handler)
241
251
  * - Explicit flags: hotkey("z", handler, { ctrl: true, shift: true })
252
+ *
253
+ * Combo modifiers: `ctrl`/`control`, `shift`, `alt`/`option`,
254
+ * `meta`/`cmd`/`command`, and `mod` — Cmd on Apple platforms, Ctrl
255
+ * everywhere else. An unknown modifier throws, because dropping it would
256
+ * make the shortcut fire on the bare key. The `+` key is written as a
257
+ * trailing plus: `hotkey("+", h)`, `hotkey("ctrl++", h)`.
242
258
  */
243
259
  declare function hotkey(combo: string, handler: (e: KeyboardEvent) => void, options?: {
244
260
  ctrl?: boolean;
@@ -452,6 +468,11 @@ declare function pagination(options: {
452
468
  /**
453
469
  * eventBus creates a typed publish/subscribe event system.
454
470
  * No reactive state needed -- pure event dispatching.
471
+ *
472
+ * `emit()` delivers to the handlers registered when it starts. A throwing
473
+ * handler is reported through the runtime error pipeline and the remaining
474
+ * handlers still run. Handlers added during delivery receive the next event;
475
+ * handlers removed (or cleared) during delivery are skipped for the rest of it.
455
476
  */
456
477
  declare function eventBus<T extends object>(): {
457
478
  on: <K extends keyof T>(event: K, handler: (data: T[K]) => void) => () => void;
@@ -28,6 +28,16 @@ interface FormReturn<T extends object> {
28
28
  handleSubmit: (onSubmit: (values: T) => void | Promise<void>) => (e?: Event) => void;
29
29
  reset: () => void;
30
30
  setError: (field: keyof T, message: string) => void;
31
+ /**
32
+ * Release the form's derived graph: every field `error` and the `errors`,
33
+ * `isValid`, `isDirty`, `touched` and `values` aggregates. Call it when the
34
+ * form's owner goes away, e.g. `onCleanup(f.dispose, formElement)`.
35
+ *
36
+ * Afterwards the derived accessors are inert — they return their last
37
+ * settled values and never recompute — while field `value()`/`set()` keep
38
+ * working as plain signals. Idempotent.
39
+ */
40
+ dispose: () => void;
31
41
  }
32
42
  /**
33
43
  * Require a non-empty value. Rejects `null`, `undefined`, `""` and `[]`.
@@ -239,6 +249,12 @@ declare function FocusTrap(nodes: HTMLElement, options?: {
239
249
  * Supports two calling styles:
240
250
  * - String combo: hotkey("ctrl+shift+z", handler)
241
251
  * - Explicit flags: hotkey("z", handler, { ctrl: true, shift: true })
252
+ *
253
+ * Combo modifiers: `ctrl`/`control`, `shift`, `alt`/`option`,
254
+ * `meta`/`cmd`/`command`, and `mod` — Cmd on Apple platforms, Ctrl
255
+ * everywhere else. An unknown modifier throws, because dropping it would
256
+ * make the shortcut fire on the bare key. The `+` key is written as a
257
+ * trailing plus: `hotkey("+", h)`, `hotkey("ctrl++", h)`.
242
258
  */
243
259
  declare function hotkey(combo: string, handler: (e: KeyboardEvent) => void, options?: {
244
260
  ctrl?: boolean;
@@ -452,6 +468,11 @@ declare function pagination(options: {
452
468
  /**
453
469
  * eventBus creates a typed publish/subscribe event system.
454
470
  * No reactive state needed -- pure event dispatching.
471
+ *
472
+ * `emit()` delivers to the handlers registered when it starts. A throwing
473
+ * handler is reported through the runtime error pipeline and the remaining
474
+ * handlers still run. Handlers added during delivery receive the next event;
475
+ * handlers removed (or cleared) during delivery are skipped for the rest of it.
455
476
  */
456
477
  declare function eventBus<T extends object>(): {
457
478
  on: <K extends keyof T>(event: K, handler: (data: T[K]) => void) => () => void;