@ersbeth/picoflow 2.0.2 → 2.0.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 (152) hide show
  1. package/README.md +10 -0
  2. package/SKILL.md +106 -0
  3. package/package.json +5 -1
  4. package/.gitlab-ci.yml +0 -24
  5. package/.vscode/settings.json +0 -5
  6. package/CHANGELOG.md +0 -94
  7. package/biome.json +0 -47
  8. package/docs/.vitepress/config.mts +0 -145
  9. package/docs/api/functions/array.md +0 -35
  10. package/docs/api/functions/constant.md +0 -33
  11. package/docs/api/functions/constantAsync.md +0 -69
  12. package/docs/api/functions/derivation.md +0 -34
  13. package/docs/api/functions/derivationAsync.md +0 -34
  14. package/docs/api/functions/from.md +0 -129
  15. package/docs/api/functions/isDisposable.md +0 -27
  16. package/docs/api/functions/map.md +0 -36
  17. package/docs/api/functions/signal.md +0 -21
  18. package/docs/api/functions/state.md +0 -67
  19. package/docs/api/functions/stateAsync.md +0 -69
  20. package/docs/api/functions/subscribe.md +0 -40
  21. package/docs/api/functions/writableDerivation.md +0 -33
  22. package/docs/api/functions/writableDerivationAsync.md +0 -34
  23. package/docs/api/index.md +0 -61
  24. package/docs/api/interfaces/FlowArray.md +0 -439
  25. package/docs/api/interfaces/FlowConstant.md +0 -220
  26. package/docs/api/interfaces/FlowConstantAsync.md +0 -221
  27. package/docs/api/interfaces/FlowDerivation.md +0 -241
  28. package/docs/api/interfaces/FlowDerivationAsync.md +0 -242
  29. package/docs/api/interfaces/FlowDisposable.md +0 -59
  30. package/docs/api/interfaces/FlowEffect.md +0 -64
  31. package/docs/api/interfaces/FlowMap.md +0 -374
  32. package/docs/api/interfaces/FlowObservable.md +0 -155
  33. package/docs/api/interfaces/FlowSignal.md +0 -156
  34. package/docs/api/interfaces/FlowState.md +0 -269
  35. package/docs/api/interfaces/FlowStateAsync.md +0 -268
  36. package/docs/api/interfaces/FlowSubscribable.md +0 -55
  37. package/docs/api/interfaces/FlowTracker.md +0 -61
  38. package/docs/api/interfaces/FlowValue.md +0 -222
  39. package/docs/api/interfaces/FlowWritableDerivation.md +0 -292
  40. package/docs/api/interfaces/FlowWritableDerivationAsync.md +0 -293
  41. package/docs/api/type-aliases/DerivationFunction.md +0 -28
  42. package/docs/api/type-aliases/DerivationFunctionAsync.md +0 -28
  43. package/docs/api/type-aliases/FlowArrayAction.md +0 -60
  44. package/docs/api/type-aliases/FlowDataTracker.md +0 -33
  45. package/docs/api/type-aliases/FlowMapAction.md +0 -48
  46. package/docs/api/type-aliases/FlowOnDataListener.md +0 -33
  47. package/docs/api/type-aliases/FlowOnErrorListener.md +0 -27
  48. package/docs/api/type-aliases/FlowOnPendingListener.md +0 -21
  49. package/docs/api/type-aliases/FlowReadonly.md +0 -22
  50. package/docs/api/type-aliases/InitFunction.md +0 -21
  51. package/docs/api/type-aliases/InitFunctionAsync.md +0 -21
  52. package/docs/api/type-aliases/NotPromise.md +0 -21
  53. package/docs/api/type-aliases/UpdateFunction.md +0 -27
  54. package/docs/api/type-aliases/UpdateFunctionAsync.md +0 -27
  55. package/docs/api/typedoc-sidebar.json +0 -65
  56. package/docs/examples/examples.md +0 -2311
  57. package/docs/examples/patterns.md +0 -649
  58. package/docs/guide/advanced/architecture.md +0 -1234
  59. package/docs/guide/advanced/disposal.md +0 -426
  60. package/docs/guide/advanced/migration-v1.md +0 -464
  61. package/docs/guide/advanced/migration-v2.md +0 -204
  62. package/docs/guide/advanced/solidjs.md +0 -135
  63. package/docs/guide/introduction/concepts.md +0 -57
  64. package/docs/guide/introduction/conventions.md +0 -30
  65. package/docs/guide/introduction/getting-started.md +0 -139
  66. package/docs/guide/introduction/lifecycle.md +0 -368
  67. package/docs/guide/primitives/array.md +0 -286
  68. package/docs/guide/primitives/constant.md +0 -207
  69. package/docs/guide/primitives/derivations.md +0 -281
  70. package/docs/guide/primitives/effects.md +0 -372
  71. package/docs/guide/primitives/map.md +0 -265
  72. package/docs/guide/primitives/overview.md +0 -92
  73. package/docs/guide/primitives/signal.md +0 -222
  74. package/docs/guide/primitives/state.md +0 -272
  75. package/docs/index.md +0 -47
  76. package/docs/public/logo.svg +0 -1
  77. package/src/api/base/flowDisposable.ts +0 -44
  78. package/src/api/base/flowObservable.ts +0 -28
  79. package/src/api/base/flowSubscribable.ts +0 -87
  80. package/src/api/base/flowTracker.ts +0 -7
  81. package/src/api/base/index.ts +0 -4
  82. package/src/api/index.ts +0 -2
  83. package/src/api/nodes/async/flowConstantAsync.ts +0 -36
  84. package/src/api/nodes/async/flowDerivationAsync.ts +0 -42
  85. package/src/api/nodes/async/flowStateAsync.ts +0 -47
  86. package/src/api/nodes/async/flowWritableDerivationAsync.ts +0 -33
  87. package/src/api/nodes/async/index.ts +0 -4
  88. package/src/api/nodes/collections/flowArray.ts +0 -155
  89. package/src/api/nodes/collections/flowMap.ts +0 -115
  90. package/src/api/nodes/collections/index.ts +0 -2
  91. package/src/api/nodes/flowEffect.ts +0 -42
  92. package/src/api/nodes/flowSignal.ts +0 -28
  93. package/src/api/nodes/flowValue.ts +0 -37
  94. package/src/api/nodes/index.ts +0 -7
  95. package/src/api/nodes/sync/flowConstant.ts +0 -33
  96. package/src/api/nodes/sync/flowDerivation.ts +0 -41
  97. package/src/api/nodes/sync/flowState.ts +0 -45
  98. package/src/api/nodes/sync/flowWritableDerivation.ts +0 -31
  99. package/src/api/nodes/sync/index.ts +0 -4
  100. package/src/api/nodes/utils.ts +0 -24
  101. package/src/base/disposable.ts +0 -18
  102. package/src/base/executionStack.ts +0 -42
  103. package/src/base/index.ts +0 -5
  104. package/src/base/node.ts +0 -98
  105. package/src/base/observable.ts +0 -92
  106. package/src/base/observer.ts +0 -51
  107. package/src/converters/index.ts +0 -1
  108. package/src/converters/solid.ts +0 -109
  109. package/src/index.ts +0 -2
  110. package/src/nodes/arrayNode.ts +0 -180
  111. package/src/nodes/effectNode.ts +0 -58
  112. package/src/nodes/index.ts +0 -7
  113. package/src/nodes/mapNode.ts +0 -125
  114. package/src/nodes/signalNode.ts +0 -19
  115. package/src/nodes/valueAsyncNode.ts +0 -85
  116. package/src/nodes/valueNode.ts +0 -148
  117. package/src/nodes/valueSyncNode.ts +0 -125
  118. package/src/schedulers/asyncResolver.ts +0 -78
  119. package/src/schedulers/asyncScheduler.ts +0 -66
  120. package/src/schedulers/index.ts +0 -4
  121. package/src/schedulers/pendingError.ts +0 -13
  122. package/src/schedulers/scheduler.ts +0 -9
  123. package/src/schedulers/syncResolver.ts +0 -69
  124. package/src/schedulers/syncScheduler.ts +0 -55
  125. package/test/base/pendingError.test.ts +0 -67
  126. package/test/converters/solid.derivation.browser.test.tsx +0 -69
  127. package/test/converters/solid.node.test.ts +0 -654
  128. package/test/converters/solid.state.browser.test.tsx +0 -1592
  129. package/test/reactivity/flowSignal.test.ts +0 -226
  130. package/test/reactivity/nodes/async/asyncScheduler/asyncResolver.test.ts +0 -593
  131. package/test/reactivity/nodes/async/asyncScheduler/asyncScheduler.test.ts +0 -317
  132. package/test/reactivity/nodes/async/flowConstantAsync.test.ts +0 -652
  133. package/test/reactivity/nodes/async/flowDerivation.test.ts +0 -898
  134. package/test/reactivity/nodes/async/flowDerivationAsync.test.ts +0 -1716
  135. package/test/reactivity/nodes/async/flowStateAsync.test.ts +0 -708
  136. package/test/reactivity/nodes/async/flowWritableDerivationAsync.test.ts +0 -614
  137. package/test/reactivity/nodes/collections/flowArray.asyncStates.test.ts +0 -1289
  138. package/test/reactivity/nodes/collections/flowArray.scalars.test.ts +0 -961
  139. package/test/reactivity/nodes/collections/flowArray.states.test.ts +0 -1035
  140. package/test/reactivity/nodes/collections/flowMap.asyncStates.test.ts +0 -960
  141. package/test/reactivity/nodes/collections/flowMap.scalars.test.ts +0 -775
  142. package/test/reactivity/nodes/collections/flowMap.states.test.ts +0 -958
  143. package/test/reactivity/nodes/sync/flowConstant.test.ts +0 -377
  144. package/test/reactivity/nodes/sync/flowDerivation.test.ts +0 -896
  145. package/test/reactivity/nodes/sync/flowState.test.ts +0 -341
  146. package/test/reactivity/nodes/sync/flowWritableDerivation.test.ts +0 -603
  147. package/test/vitest.d.ts +0 -10
  148. package/tsconfig.json +0 -37
  149. package/typedoc.json +0 -37
  150. package/vite.config.ts +0 -31
  151. package/vitest.browser.config.ts +0 -21
  152. package/vitest.config.ts +0 -17
@@ -1,341 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import { state, subscribe } from "~";
3
-
4
- describe("flowState", () => {
5
- describe("unit", () => {
6
- describe("initialization", () => {
7
- it("should initialize with direct value", async () => {
8
- const $state = state(1);
9
- expect(await $state.pick()).toBe(1);
10
- });
11
- });
12
-
13
- describe("set", () => {
14
- it("should update value with direct value", async () => {
15
- const $state = state(1);
16
- expect(await $state.pick()).toBe(1);
17
-
18
- $state.set(2);
19
- expect(await $state.pick()).toBe(2);
20
- });
21
-
22
- it("should update value with updater function", async () => {
23
- const $state = state(1);
24
- expect(await $state.pick()).toBe(1);
25
-
26
- $state.set((current) => (current !== undefined ? current + 1 : 0));
27
- expect(await $state.pick()).toBe(2);
28
- });
29
-
30
- it("should not notify when set with same value", async () => {
31
- const $state = state(1);
32
- const onData = vi.fn();
33
- $state.subscribe(onData);
34
-
35
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
36
-
37
- $state.set(1);
38
-
39
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
40
- });
41
-
42
- it("should notify when set with different value", async () => {
43
- const $state = state(1);
44
- const onData = vi.fn();
45
- $state.subscribe(onData);
46
-
47
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
48
- expect(onData).toHaveBeenLastCalledWith(1);
49
- $state.set(2);
50
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
51
- expect(onData).toHaveBeenLastCalledWith(2);
52
- });
53
-
54
- it("should not notify when updater returns same value", async () => {
55
- const $state = state(5);
56
- const onData = vi.fn();
57
- $state.subscribe(onData);
58
-
59
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
60
-
61
- $state.set((current) => current ?? 0);
62
-
63
- // Wait to ensure no additional calls
64
- await new Promise((resolve) => setTimeout(resolve, 50));
65
- expect(onData).toHaveBeenCalledTimes(1);
66
- });
67
-
68
- it("should notify when updater returns different value", async () => {
69
- const $state = state(5);
70
- const onData = vi.fn();
71
- $state.subscribe(onData);
72
-
73
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
74
-
75
- await $state.set((current) => (current ? current + 1 : 0));
76
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
77
- expect(onData).toHaveBeenLastCalledWith(6);
78
- });
79
- });
80
-
81
- describe("subscribe", () => {
82
- it("should call onData immediately with current value", async () => {
83
- const $state = state(55);
84
- const onData = vi.fn();
85
-
86
- $state.subscribe(onData);
87
-
88
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
89
- expect(onData).toHaveBeenLastCalledWith(55);
90
- });
91
-
92
- it("should call onData when value is updated", async () => {
93
- const $state = state(65);
94
- const onData = vi.fn();
95
-
96
- $state.subscribe(onData);
97
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
98
-
99
- $state.set(70);
100
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
101
- expect(onData).toHaveBeenLastCalledWith(70);
102
- });
103
-
104
- it("should not call onData when updated with same value", async () => {
105
- const $state = state(75);
106
- const onData = vi.fn();
107
-
108
- $state.subscribe(onData);
109
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
110
-
111
- $state.set(80);
112
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
113
-
114
- $state.set(80);
115
- await new Promise((resolve) => setTimeout(resolve, 50));
116
- expect(onData).toHaveBeenCalledTimes(2);
117
- });
118
- });
119
-
120
- describe("nesting", () => {
121
- it("should handle nested states", async () => {
122
- const $stateA = state(1);
123
- const $stateB = state(2);
124
- const $stateC = state({
125
- a: $stateA,
126
- b: $stateB,
127
- });
128
-
129
- const value = await $stateC.pick();
130
- expect(value.a).toBe($stateA);
131
- expect(value.b).toBe($stateB);
132
- });
133
-
134
- it("should handle state with complex object values", async () => {
135
- const complexObj = {
136
- nested: { deep: { value: 42 } },
137
- array: [1, 2, 3],
138
- };
139
- const $state = state(complexObj);
140
- const value = await $state.pick();
141
- expect(value).toBe(complexObj);
142
- expect(value.nested.deep.value).toBe(42);
143
- expect(value.array).toEqual([1, 2, 3]);
144
- });
145
- });
146
-
147
- describe("error handling", () => {
148
- describe("disposed state", () => {
149
- it("should throw error when set is called after disposal", async () => {
150
- const $state = state(1);
151
-
152
- await $state.pick();
153
- await $state.set(2);
154
- $state.dispose();
155
-
156
- expect(() => $state.set(3)).toThrow("[PicoFlow] Primitive is disposed");
157
- });
158
-
159
- it("should throw error when trigger is called after disposal", () => {
160
- const $state = state(1);
161
- $state.dispose();
162
- expect(() => $state.trigger()).toThrow("[PicoFlow] Primitive is disposed");
163
- });
164
- });
165
- });
166
- });
167
-
168
- describe("with effect", () => {
169
- describe("get", () => {
170
- it("should call effect with initial value", async () => {
171
- const $state = state(1);
172
- const onData = vi.fn();
173
- subscribe((t) => $state.get(t), onData);
174
-
175
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
176
- expect(onData).toHaveBeenLastCalledWith(1);
177
- });
178
-
179
- it("should call effect when value is updated", async () => {
180
- const $state = state(1);
181
- const onData = vi.fn();
182
- subscribe((t) => $state.get(t), onData);
183
-
184
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
185
- expect(onData).toHaveBeenLastCalledWith(1);
186
-
187
- $state.set(2);
188
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
189
- expect(onData).toHaveBeenLastCalledWith(2);
190
- });
191
-
192
- it("should not call effect when updated with same value", async () => {
193
- const $state = state(1);
194
- const onData = vi.fn();
195
- subscribe((t) => $state.get(t), onData);
196
-
197
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
198
-
199
- $state.set(2);
200
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
201
- expect(onData).toHaveBeenLastCalledWith(2);
202
-
203
- $state.set(2);
204
- await new Promise((resolve) => setTimeout(resolve, 50));
205
- expect(onData).toHaveBeenCalledTimes(2);
206
- });
207
-
208
- it("should not call effect after effect is disposed", async () => {
209
- const $state = state(1);
210
- const onData = vi.fn();
211
- const $effect = subscribe((t) => $state.get(t), onData);
212
-
213
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
214
- expect(onData).toHaveBeenLastCalledWith(1);
215
-
216
- $state.set(2);
217
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
218
- expect(onData).toHaveBeenLastCalledWith(2);
219
-
220
- $effect.dispose();
221
-
222
- $state.set(3);
223
- await new Promise((resolve) => setTimeout(resolve, 50));
224
- expect(onData).toHaveBeenCalledTimes(2);
225
- });
226
-
227
- it("should support effect depending on multiple states", async () => {
228
- const $stateA = state(5);
229
- const $stateB = state(10);
230
- const onData = vi.fn();
231
-
232
- subscribe(
233
- (t) => ({ a: $stateA.get(t), b: $stateB.get(t) }),
234
- (data) => onData(data.a, data.b),
235
- );
236
-
237
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
238
- expect(onData).toHaveBeenLastCalledWith(5, 10);
239
-
240
- $stateA.set(6);
241
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
242
- expect(onData).toHaveBeenLastCalledWith(6, 10);
243
-
244
- $stateB.set(11);
245
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(3));
246
- expect(onData).toHaveBeenLastCalledWith(6, 11);
247
- });
248
- });
249
-
250
- describe("watch", () => {
251
- it("should register dependency when watch is used in effect", async () => {
252
- const $state = state(400);
253
- const onData = vi.fn();
254
-
255
- subscribe((t) => $state.watch(t), onData);
256
-
257
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
258
- });
259
-
260
- it("should trigger re-runs when state changes after watch", async () => {
261
- const $state = state(500);
262
- const onData = vi.fn();
263
-
264
- subscribe((t) => $state.watch(t), onData);
265
-
266
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
267
-
268
- await $state.set(600);
269
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
270
- });
271
- });
272
-
273
- describe("error handling", () => {
274
- describe("disposed state", () => {
275
- it("should throw error when triggering a disposed state", () => {
276
- const $state = state(1);
277
-
278
- $state.dispose();
279
-
280
- expect(() => $state.trigger()).toThrow("[PicoFlow] Primitive is disposed");
281
- });
282
-
283
- it("should throw error when setting a disposed state", () => {
284
- const $state = state(1);
285
-
286
- $state.dispose();
287
-
288
- expect(() => $state.set(2)).toThrow("[PicoFlow] Primitive is disposed");
289
- });
290
- });
291
- });
292
-
293
- describe("complex cases", () => {
294
- it("should handle nested states in effects", async () => {
295
- const $stateA = state(1);
296
- const $stateB = state(2);
297
- const $stateC = state({
298
- a: $stateA,
299
- b: $stateB,
300
- });
301
-
302
- const onData = vi.fn();
303
- subscribe((t) => $stateC.get(t).a.get(t), onData);
304
-
305
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
306
- expect(onData).toHaveBeenLastCalledWith(1);
307
-
308
- await $stateA.set(3);
309
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
310
- expect(onData).toHaveBeenLastCalledWith(3);
311
- });
312
-
313
- it("should handle effect depending on multiple states", async () => {
314
- const $stateA = state(10);
315
- const $stateB = state(20);
316
- const $stateC = state(30);
317
- const onData = vi.fn();
318
-
319
- subscribe(
320
- (t) => ({
321
- a: $stateA.get(t),
322
- b: $stateB.get(t),
323
- c: $stateC.get(t),
324
- }),
325
- (data) => onData(data.a, data.b, data.c),
326
- );
327
-
328
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
329
- expect(onData).toHaveBeenLastCalledWith(10, 20, 30);
330
-
331
- $stateA.set(11);
332
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
333
- expect(onData).toHaveBeenLastCalledWith(11, 20, 30);
334
-
335
- $stateB.set(21);
336
- await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(3));
337
- expect(onData).toHaveBeenLastCalledWith(11, 21, 30);
338
- });
339
- });
340
- });
341
- });