sibujs 3.4.0 → 4.0.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 (98) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +118 -15
  3. package/dist/browser.cjs +410 -101
  4. package/dist/browser.d.cts +50 -5
  5. package/dist/browser.d.ts +50 -5
  6. package/dist/browser.js +8 -6
  7. package/dist/build.cjs +777 -385
  8. package/dist/build.js +15 -15
  9. package/dist/cdn.global.js +11 -7
  10. package/dist/{chunk-JCO7AHNU.js → chunk-3EKJK5FZ.js} +73 -34
  11. package/dist/chunk-4MFZMLUU.js +147 -0
  12. package/dist/chunk-52XFPGSN.js +123 -0
  13. package/dist/chunk-5INI7D2L.js +194 -0
  14. package/dist/{chunk-OAVXAFAY.js → chunk-6LG2T7LO.js} +5 -5
  15. package/dist/{chunk-OOUQUCNN.js → chunk-ACBT6UZS.js} +57 -22
  16. package/dist/{chunk-F7HW2NI5.js → chunk-AW6HPJ3L.js} +1 -1
  17. package/dist/chunk-DHDZ7IVN.js +109 -0
  18. package/dist/{chunk-JNGGM2XE.js → chunk-DQVUBVNX.js} +16 -25
  19. package/dist/{chunk-AXFWGY32.js → chunk-DR7H6UGM.js} +232 -67
  20. package/dist/{chunk-WSGLJYFI.js → chunk-E62UADKL.js} +9 -3
  21. package/dist/{chunk-3Z2NGWQI.js → chunk-ES2GERY2.js} +1 -1
  22. package/dist/{chunk-S3V6ZXPI.js → chunk-EWEE7NBF.js} +115 -41
  23. package/dist/{chunk-3DVGCW7O.js → chunk-F64ZPCFE.js} +8 -8
  24. package/dist/{chunk-APFRCIRI.js → chunk-GCSGGA3Q.js} +295 -198
  25. package/dist/{chunk-EX77FXTT.js → chunk-HYCCIYNS.js} +228 -51
  26. package/dist/{chunk-ELXMRSVN.js → chunk-NF3LYCQH.js} +259 -124
  27. package/dist/chunk-O3QQ3XOL.js +61 -0
  28. package/dist/{chunk-BUKYCWHX.js → chunk-PBQEW5VW.js} +14 -10
  29. package/dist/{chunk-H5FI5WDP.js → chunk-RRIDJQ5C.js} +3 -3
  30. package/dist/{chunk-S3NFJO6L.js → chunk-TIRZCERI.js} +36 -5
  31. package/dist/{chunk-ODXVQ3CS.js → chunk-VFHIVEPF.js} +309 -188
  32. package/dist/chunk-VPP2FONR.js +142 -0
  33. package/dist/{chunk-KZBEVFXZ.js → chunk-W55YHPEP.js} +5 -3
  34. package/dist/{chunk-FKQG7FTY.js → chunk-WN6WDFCB.js} +4 -4
  35. package/dist/{chunk-CEBWDD63.js → chunk-WOOMUJFT.js} +228 -86
  36. package/dist/{chunk-ITWCTZYH.js → chunk-Z2CE42DB.js} +19 -25
  37. package/dist/{contracts-ey_Qh8ef.d.cts → contracts-Hg6ITAEF.d.cts} +6 -6
  38. package/dist/{contracts-ey_Qh8ef.d.ts → contracts-Hg6ITAEF.d.ts} +6 -6
  39. package/dist/{customElement-CPfIrbvg.d.ts → customElement-CKLoO63w.d.cts} +73 -11
  40. package/dist/{customElement-CPfIrbvg.d.cts → customElement-CKLoO63w.d.ts} +73 -11
  41. package/dist/data.cjs +483 -205
  42. package/dist/data.d.cts +139 -7
  43. package/dist/data.d.ts +139 -7
  44. package/dist/data.js +9 -9
  45. package/dist/devtools.cjs +222 -87
  46. package/dist/devtools.js +8 -8
  47. package/dist/dispose-4FZ6OFXR.js +19 -0
  48. package/dist/ecosystem.cjs +419 -175
  49. package/dist/ecosystem.js +11 -11
  50. package/dist/extras.cjs +1981 -765
  51. package/dist/extras.d.cts +7 -7
  52. package/dist/extras.d.ts +7 -7
  53. package/dist/extras.js +29 -26
  54. package/dist/index.cjs +784 -385
  55. package/dist/index.d.cts +299 -28
  56. package/dist/index.d.ts +299 -28
  57. package/dist/index.js +33 -18
  58. package/dist/motion.cjs +180 -50
  59. package/dist/motion.d.cts +26 -0
  60. package/dist/motion.d.ts +26 -0
  61. package/dist/motion.js +5 -5
  62. package/dist/patterns.cjs +437 -170
  63. package/dist/patterns.d.cts +60 -13
  64. package/dist/patterns.d.ts +60 -13
  65. package/dist/patterns.js +7 -7
  66. package/dist/performance.cjs +333 -148
  67. package/dist/performance.d.cts +55 -7
  68. package/dist/performance.d.ts +55 -7
  69. package/dist/performance.js +9 -9
  70. package/dist/plugins.cjs +1374 -576
  71. package/dist/plugins.d.cts +227 -9
  72. package/dist/plugins.d.ts +227 -9
  73. package/dist/plugins.js +613 -321
  74. package/dist/{ssr-D62yFwuw.d.cts → ssr-BiPRdZ6n.d.cts} +44 -15
  75. package/dist/{ssr-D62yFwuw.d.ts → ssr-BiPRdZ6n.d.ts} +44 -15
  76. package/dist/{ssr-2PPULEK2.js → ssr-JFP5535P.js} +5 -4
  77. package/dist/ssr.cjs +1104 -443
  78. package/dist/ssr.d.cts +230 -20
  79. package/dist/ssr.d.ts +230 -20
  80. package/dist/ssr.js +15 -12
  81. package/dist/{startup-0Qv6aosO.d.cts → startup-BMpaiMhP.d.cts} +1 -1
  82. package/dist/{startup-0Qv6aosO.d.ts → startup-BMpaiMhP.d.ts} +1 -1
  83. package/dist/testing.cjs +205 -63
  84. package/dist/testing.d.cts +1 -1
  85. package/dist/testing.d.ts +1 -1
  86. package/dist/testing.js +8 -10
  87. package/dist/ui.cjs +640 -199
  88. package/dist/ui.d.cts +2 -2
  89. package/dist/ui.d.ts +2 -2
  90. package/dist/ui.js +10 -10
  91. package/dist/widgets.cjs +207 -82
  92. package/dist/widgets.js +9 -9
  93. package/package.json +12 -7
  94. package/dist/chunk-5VGSK6D2.js +0 -80
  95. package/dist/chunk-COY6PUD2.js +0 -34
  96. package/dist/chunk-K35BAR4P.js +0 -96
  97. package/dist/chunk-L3GAGWCC.js +0 -111
  98. package/dist/chunk-RT3IYFN2.js +0 -38
@@ -1,6 +1,6 @@
1
- export { C as ComponentProps, P as PropDef, a as PropSchema, R as RenderProp, V as Validator, b as assertType, c as compose, d as createGuard, e as createSlots, f as defineComponent, g as defineSlottedComponent, h as defineStrictComponent, v as validateProps, i as validators, w as withBoundary, j as withDefaults, k as withProps, l as withWrapper } from './contracts-ey_Qh8ef.cjs';
1
+ export { C as ComponentProps, P as PropDef, a as PropSchema, R as RenderProp, V as Validator, b as assertType, c as compose, d as createGuard, e as createSlots, f as defineComponent, g as defineSlottedComponent, h as defineStrictComponent, v as validateProps, i as validators, w as withBoundary, j as withDefaults, k as withProps, l as withWrapper } from './contracts-Hg6ITAEF.cjs';
2
2
 
3
- interface MachineConfig<S extends string, E extends string, C extends Record<string, unknown> = Record<string, unknown>> {
3
+ interface MachineConfig<S extends string, E extends string, C extends object = Record<string, unknown>> {
4
4
  initial: S;
5
5
  context?: C;
6
6
  states: {
@@ -17,7 +17,7 @@ interface MachineConfig<S extends string, E extends string, C extends Record<str
17
17
  };
18
18
  };
19
19
  }
20
- interface MachineReturn<S extends string, E extends string, C extends Record<string, unknown>> {
20
+ interface MachineReturn<S extends string, E extends string, C extends object> {
21
21
  state: () => S;
22
22
  context: () => C;
23
23
  send: (event: E) => void;
@@ -27,7 +27,7 @@ interface MachineReturn<S extends string, E extends string, C extends Record<str
27
27
  /**
28
28
  * machine creates a finite state machine with states, events, guards, and actions.
29
29
  */
30
- declare function machine<S extends string, E extends string, C extends Record<string, unknown> = Record<string, unknown>>(config: MachineConfig<S, E, C>): MachineReturn<S, E, C>;
30
+ declare function machine<S extends string, E extends string, C extends object = Record<string, unknown>>(config: MachineConfig<S, E, C>): MachineReturn<S, E, C>;
31
31
 
32
32
  /**
33
33
  * Creates a reactive state that automatically persists to localStorage
@@ -102,9 +102,18 @@ declare function persisted<T>(key: string, initial: T, options?: PersistOptions<
102
102
  *
103
103
  * Returns a named object with `value`, `pending`, and `update`.
104
104
  *
105
- * Concurrent safety: each operation is tagged with a version counter.
106
- * A failing operation only reverts if no newer operation has started since,
107
- * preventing stale snapshots from overwriting fresher optimistic state.
105
+ * CONCURRENCY MODEL last writer wins, deliberately.
106
+ *
107
+ * A scalar has exactly one logical row, so "which operation owns the value" and
108
+ * "which operation started last" are the same question. Each operation is tagged
109
+ * with a version counter and only settles the value if no newer operation has
110
+ * started since. That is a coherent model here precisely because there is
111
+ * nothing to be disjoint with.
112
+ *
113
+ * `optimisticList` deliberately does NOT share this design: an array has many
114
+ * independent rows, so a global version counter cannot tell "a newer operation
115
+ * changed the row I am about to revert" from "a newer operation changed a
116
+ * completely different row". See the note above `optimisticList`.
108
117
  *
109
118
  * @example
110
119
  * ```ts
@@ -124,9 +133,32 @@ declare function optimistic<T>(initialValue: T): {
124
133
  /**
125
134
  * optimisticList provides optimistic updates for array state.
126
135
  *
127
- * Uses functional updates (setItems(current => ...)) for the success path
128
- * to avoid losing changes made by concurrent operations. The failure path
129
- * uses a version guard so stale reverts don't overwrite newer state.
136
+ * CONCURRENCY MODEL per-row claim chains ordered by invocation.
137
+ *
138
+ * Every operation gets an id when it is invoked, and every row it touches gets
139
+ * a claim at that id's position in the row's stack. The newest claim is what
140
+ * `items()` shows. On settlement an operation touches only its own claim:
141
+ *
142
+ * - a failed `add` withdraws exactly the row it inserted, and marks it so a
143
+ * concurrent failed `remove` cannot reinstate it;
144
+ * - a successful `add` resolves its own claim; if a later operation has
145
+ * claimed the row since, that newer claim stays on top;
146
+ * - a failed `remove` makes its rows visible again, in their correct relative
147
+ * order and carrying whatever value they hold NOW;
148
+ * - a successful `remove` retires its rows; each record is dropped as soon as
149
+ * its last holder settles;
150
+ * - a failed `update` drops its claim, revealing whatever is beneath it;
151
+ * - a successful `update` resolves its claim in place, which becomes visible
152
+ * only once no newer claim sits above it.
153
+ *
154
+ * Operations on disjoint rows are completely independent. Where two operations
155
+ * touch the same row the later one is visible — including when the later one
156
+ * was started by a reactive subscriber, by the outer operation's own predicate,
157
+ * or by one of its patch's property getters.
158
+ *
159
+ * `pending()` is true while any operation is unsettled and becomes false exactly
160
+ * when the last one settles, in any settlement order. It is always published in
161
+ * the same batch as `items()`, so a subscriber never sees one without the other.
130
162
  *
131
163
  * @example
132
164
  * ```ts
@@ -170,7 +202,22 @@ declare function timeline<T>(initial: T, maxHistory?: number): TimeTravelReturn<
170
202
 
171
203
  type Middleware<S> = (state: S, action: string, payload: unknown, next: () => void) => void;
172
204
  type Selector<S, R> = (state: S) => R;
173
- interface GlobalStore<S extends Record<string, unknown>, A extends Record<string, (state: S, payload?: unknown) => Partial<S>>> {
205
+ /**
206
+ * Action-map constraint.
207
+ *
208
+ * `(state: S, payload?: unknown)` looks permissive but is the opposite: it
209
+ * requires every action to ACCEPT any `unknown` payload, so a typed action such
210
+ * as `add: (state, amount: number) => ...` is not assignable, and
211
+ * `Parameters<A[K]>[1]` — which `dispatch` already uses to type its payload —
212
+ * collapses to `unknown` for every action. The constraint therefore defeated the
213
+ * per-action payload typing the rest of this file is built around.
214
+ *
215
+ * A `never[]` rest parameter accepts any concrete parameter list while keeping
216
+ * `Parameters<A[K]>` intact, so `dispatch("add", 5)` is checked against the
217
+ * action's real signature. (TYPE-007)
218
+ */
219
+ type StoreActionMap<S> = Record<string, (state: S, ...args: never[]) => Partial<S>>;
220
+ interface GlobalStore<S extends object, A extends StoreActionMap<S>> {
174
221
  getState: () => S;
175
222
  select: <R>(selector: Selector<S, R>) => () => R;
176
223
  dispatch: <K extends keyof A>(action: K, payload?: Parameters<A[K]>[1]) => void;
@@ -181,10 +228,10 @@ interface GlobalStore<S extends Record<string, unknown>, A extends Record<string
181
228
  * globalStore creates a centralized state management store
182
229
  * with actions, selectors, and middleware support.
183
230
  */
184
- declare function globalStore<S extends Record<string, unknown>, A extends Record<string, (state: S, payload?: unknown) => Partial<S>>>(config: {
231
+ declare function globalStore<S extends object, A extends StoreActionMap<S>>(config: {
185
232
  state: S;
186
233
  actions: A;
187
234
  middleware?: Middleware<S>[];
188
235
  }): GlobalStore<S, A>;
189
236
 
190
- export { type GlobalStore, type MachineConfig, type MachineReturn, type Middleware, type PersistOptions, type Selector, type TimeTravelReturn, globalStore, machine, optimistic, optimisticList, persisted, timeline };
237
+ export { type GlobalStore, type MachineConfig, type MachineReturn, type Middleware, type PersistOptions, type Selector, type StoreActionMap, type TimeTravelReturn, globalStore, machine, optimistic, optimisticList, persisted, timeline };
@@ -1,6 +1,6 @@
1
- export { C as ComponentProps, P as PropDef, a as PropSchema, R as RenderProp, V as Validator, b as assertType, c as compose, d as createGuard, e as createSlots, f as defineComponent, g as defineSlottedComponent, h as defineStrictComponent, v as validateProps, i as validators, w as withBoundary, j as withDefaults, k as withProps, l as withWrapper } from './contracts-ey_Qh8ef.js';
1
+ export { C as ComponentProps, P as PropDef, a as PropSchema, R as RenderProp, V as Validator, b as assertType, c as compose, d as createGuard, e as createSlots, f as defineComponent, g as defineSlottedComponent, h as defineStrictComponent, v as validateProps, i as validators, w as withBoundary, j as withDefaults, k as withProps, l as withWrapper } from './contracts-Hg6ITAEF.js';
2
2
 
3
- interface MachineConfig<S extends string, E extends string, C extends Record<string, unknown> = Record<string, unknown>> {
3
+ interface MachineConfig<S extends string, E extends string, C extends object = Record<string, unknown>> {
4
4
  initial: S;
5
5
  context?: C;
6
6
  states: {
@@ -17,7 +17,7 @@ interface MachineConfig<S extends string, E extends string, C extends Record<str
17
17
  };
18
18
  };
19
19
  }
20
- interface MachineReturn<S extends string, E extends string, C extends Record<string, unknown>> {
20
+ interface MachineReturn<S extends string, E extends string, C extends object> {
21
21
  state: () => S;
22
22
  context: () => C;
23
23
  send: (event: E) => void;
@@ -27,7 +27,7 @@ interface MachineReturn<S extends string, E extends string, C extends Record<str
27
27
  /**
28
28
  * machine creates a finite state machine with states, events, guards, and actions.
29
29
  */
30
- declare function machine<S extends string, E extends string, C extends Record<string, unknown> = Record<string, unknown>>(config: MachineConfig<S, E, C>): MachineReturn<S, E, C>;
30
+ declare function machine<S extends string, E extends string, C extends object = Record<string, unknown>>(config: MachineConfig<S, E, C>): MachineReturn<S, E, C>;
31
31
 
32
32
  /**
33
33
  * Creates a reactive state that automatically persists to localStorage
@@ -102,9 +102,18 @@ declare function persisted<T>(key: string, initial: T, options?: PersistOptions<
102
102
  *
103
103
  * Returns a named object with `value`, `pending`, and `update`.
104
104
  *
105
- * Concurrent safety: each operation is tagged with a version counter.
106
- * A failing operation only reverts if no newer operation has started since,
107
- * preventing stale snapshots from overwriting fresher optimistic state.
105
+ * CONCURRENCY MODEL last writer wins, deliberately.
106
+ *
107
+ * A scalar has exactly one logical row, so "which operation owns the value" and
108
+ * "which operation started last" are the same question. Each operation is tagged
109
+ * with a version counter and only settles the value if no newer operation has
110
+ * started since. That is a coherent model here precisely because there is
111
+ * nothing to be disjoint with.
112
+ *
113
+ * `optimisticList` deliberately does NOT share this design: an array has many
114
+ * independent rows, so a global version counter cannot tell "a newer operation
115
+ * changed the row I am about to revert" from "a newer operation changed a
116
+ * completely different row". See the note above `optimisticList`.
108
117
  *
109
118
  * @example
110
119
  * ```ts
@@ -124,9 +133,32 @@ declare function optimistic<T>(initialValue: T): {
124
133
  /**
125
134
  * optimisticList provides optimistic updates for array state.
126
135
  *
127
- * Uses functional updates (setItems(current => ...)) for the success path
128
- * to avoid losing changes made by concurrent operations. The failure path
129
- * uses a version guard so stale reverts don't overwrite newer state.
136
+ * CONCURRENCY MODEL per-row claim chains ordered by invocation.
137
+ *
138
+ * Every operation gets an id when it is invoked, and every row it touches gets
139
+ * a claim at that id's position in the row's stack. The newest claim is what
140
+ * `items()` shows. On settlement an operation touches only its own claim:
141
+ *
142
+ * - a failed `add` withdraws exactly the row it inserted, and marks it so a
143
+ * concurrent failed `remove` cannot reinstate it;
144
+ * - a successful `add` resolves its own claim; if a later operation has
145
+ * claimed the row since, that newer claim stays on top;
146
+ * - a failed `remove` makes its rows visible again, in their correct relative
147
+ * order and carrying whatever value they hold NOW;
148
+ * - a successful `remove` retires its rows; each record is dropped as soon as
149
+ * its last holder settles;
150
+ * - a failed `update` drops its claim, revealing whatever is beneath it;
151
+ * - a successful `update` resolves its claim in place, which becomes visible
152
+ * only once no newer claim sits above it.
153
+ *
154
+ * Operations on disjoint rows are completely independent. Where two operations
155
+ * touch the same row the later one is visible — including when the later one
156
+ * was started by a reactive subscriber, by the outer operation's own predicate,
157
+ * or by one of its patch's property getters.
158
+ *
159
+ * `pending()` is true while any operation is unsettled and becomes false exactly
160
+ * when the last one settles, in any settlement order. It is always published in
161
+ * the same batch as `items()`, so a subscriber never sees one without the other.
130
162
  *
131
163
  * @example
132
164
  * ```ts
@@ -170,7 +202,22 @@ declare function timeline<T>(initial: T, maxHistory?: number): TimeTravelReturn<
170
202
 
171
203
  type Middleware<S> = (state: S, action: string, payload: unknown, next: () => void) => void;
172
204
  type Selector<S, R> = (state: S) => R;
173
- interface GlobalStore<S extends Record<string, unknown>, A extends Record<string, (state: S, payload?: unknown) => Partial<S>>> {
205
+ /**
206
+ * Action-map constraint.
207
+ *
208
+ * `(state: S, payload?: unknown)` looks permissive but is the opposite: it
209
+ * requires every action to ACCEPT any `unknown` payload, so a typed action such
210
+ * as `add: (state, amount: number) => ...` is not assignable, and
211
+ * `Parameters<A[K]>[1]` — which `dispatch` already uses to type its payload —
212
+ * collapses to `unknown` for every action. The constraint therefore defeated the
213
+ * per-action payload typing the rest of this file is built around.
214
+ *
215
+ * A `never[]` rest parameter accepts any concrete parameter list while keeping
216
+ * `Parameters<A[K]>` intact, so `dispatch("add", 5)` is checked against the
217
+ * action's real signature. (TYPE-007)
218
+ */
219
+ type StoreActionMap<S> = Record<string, (state: S, ...args: never[]) => Partial<S>>;
220
+ interface GlobalStore<S extends object, A extends StoreActionMap<S>> {
174
221
  getState: () => S;
175
222
  select: <R>(selector: Selector<S, R>) => () => R;
176
223
  dispatch: <K extends keyof A>(action: K, payload?: Parameters<A[K]>[1]) => void;
@@ -181,10 +228,10 @@ interface GlobalStore<S extends Record<string, unknown>, A extends Record<string
181
228
  * globalStore creates a centralized state management store
182
229
  * with actions, selectors, and middleware support.
183
230
  */
184
- declare function globalStore<S extends Record<string, unknown>, A extends Record<string, (state: S, payload?: unknown) => Partial<S>>>(config: {
231
+ declare function globalStore<S extends object, A extends StoreActionMap<S>>(config: {
185
232
  state: S;
186
233
  actions: A;
187
234
  middleware?: Middleware<S>[];
188
235
  }): GlobalStore<S, A>;
189
236
 
190
- export { type GlobalStore, type MachineConfig, type MachineReturn, type Middleware, type PersistOptions, type Selector, type TimeTravelReturn, globalStore, machine, optimistic, optimisticList, persisted, timeline };
237
+ export { type GlobalStore, type MachineConfig, type MachineReturn, type Middleware, type PersistOptions, type Selector, type StoreActionMap, type TimeTravelReturn, globalStore, machine, optimistic, optimisticList, persisted, timeline };
package/dist/patterns.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  optimisticList,
6
6
  persisted,
7
7
  timeline
8
- } from "./chunk-CEBWDD63.js";
8
+ } from "./chunk-WOOMUJFT.js";
9
9
  import {
10
10
  RenderProp,
11
11
  assertType,
@@ -23,12 +23,12 @@ import {
23
23
  withWrapper
24
24
  } from "./chunk-VJE6DDYM.js";
25
25
  import "./chunk-H3SRKIYX.js";
26
- import "./chunk-ITWCTZYH.js";
27
- import "./chunk-BUKYCWHX.js";
28
- import "./chunk-S3NFJO6L.js";
29
- import "./chunk-KZBEVFXZ.js";
30
- import "./chunk-OOUQUCNN.js";
31
- import "./chunk-COY6PUD2.js";
26
+ import "./chunk-Z2CE42DB.js";
27
+ import "./chunk-PBQEW5VW.js";
28
+ import "./chunk-TIRZCERI.js";
29
+ import "./chunk-W55YHPEP.js";
30
+ import "./chunk-ACBT6UZS.js";
31
+ import "./chunk-VPP2FONR.js";
32
32
  export {
33
33
  RenderProp,
34
34
  assertType,