@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.
- package/README.md +10 -0
- package/SKILL.md +106 -0
- package/package.json +5 -1
- package/.gitlab-ci.yml +0 -24
- package/.vscode/settings.json +0 -5
- package/CHANGELOG.md +0 -94
- package/biome.json +0 -47
- package/docs/.vitepress/config.mts +0 -145
- package/docs/api/functions/array.md +0 -35
- package/docs/api/functions/constant.md +0 -33
- package/docs/api/functions/constantAsync.md +0 -69
- package/docs/api/functions/derivation.md +0 -34
- package/docs/api/functions/derivationAsync.md +0 -34
- package/docs/api/functions/from.md +0 -129
- package/docs/api/functions/isDisposable.md +0 -27
- package/docs/api/functions/map.md +0 -36
- package/docs/api/functions/signal.md +0 -21
- package/docs/api/functions/state.md +0 -67
- package/docs/api/functions/stateAsync.md +0 -69
- package/docs/api/functions/subscribe.md +0 -40
- package/docs/api/functions/writableDerivation.md +0 -33
- package/docs/api/functions/writableDerivationAsync.md +0 -34
- package/docs/api/index.md +0 -61
- package/docs/api/interfaces/FlowArray.md +0 -439
- package/docs/api/interfaces/FlowConstant.md +0 -220
- package/docs/api/interfaces/FlowConstantAsync.md +0 -221
- package/docs/api/interfaces/FlowDerivation.md +0 -241
- package/docs/api/interfaces/FlowDerivationAsync.md +0 -242
- package/docs/api/interfaces/FlowDisposable.md +0 -59
- package/docs/api/interfaces/FlowEffect.md +0 -64
- package/docs/api/interfaces/FlowMap.md +0 -374
- package/docs/api/interfaces/FlowObservable.md +0 -155
- package/docs/api/interfaces/FlowSignal.md +0 -156
- package/docs/api/interfaces/FlowState.md +0 -269
- package/docs/api/interfaces/FlowStateAsync.md +0 -268
- package/docs/api/interfaces/FlowSubscribable.md +0 -55
- package/docs/api/interfaces/FlowTracker.md +0 -61
- package/docs/api/interfaces/FlowValue.md +0 -222
- package/docs/api/interfaces/FlowWritableDerivation.md +0 -292
- package/docs/api/interfaces/FlowWritableDerivationAsync.md +0 -293
- package/docs/api/type-aliases/DerivationFunction.md +0 -28
- package/docs/api/type-aliases/DerivationFunctionAsync.md +0 -28
- package/docs/api/type-aliases/FlowArrayAction.md +0 -60
- package/docs/api/type-aliases/FlowDataTracker.md +0 -33
- package/docs/api/type-aliases/FlowMapAction.md +0 -48
- package/docs/api/type-aliases/FlowOnDataListener.md +0 -33
- package/docs/api/type-aliases/FlowOnErrorListener.md +0 -27
- package/docs/api/type-aliases/FlowOnPendingListener.md +0 -21
- package/docs/api/type-aliases/FlowReadonly.md +0 -22
- package/docs/api/type-aliases/InitFunction.md +0 -21
- package/docs/api/type-aliases/InitFunctionAsync.md +0 -21
- package/docs/api/type-aliases/NotPromise.md +0 -21
- package/docs/api/type-aliases/UpdateFunction.md +0 -27
- package/docs/api/type-aliases/UpdateFunctionAsync.md +0 -27
- package/docs/api/typedoc-sidebar.json +0 -65
- package/docs/examples/examples.md +0 -2311
- package/docs/examples/patterns.md +0 -649
- package/docs/guide/advanced/architecture.md +0 -1234
- package/docs/guide/advanced/disposal.md +0 -426
- package/docs/guide/advanced/migration-v1.md +0 -464
- package/docs/guide/advanced/migration-v2.md +0 -204
- package/docs/guide/advanced/solidjs.md +0 -135
- package/docs/guide/introduction/concepts.md +0 -57
- package/docs/guide/introduction/conventions.md +0 -30
- package/docs/guide/introduction/getting-started.md +0 -139
- package/docs/guide/introduction/lifecycle.md +0 -368
- package/docs/guide/primitives/array.md +0 -286
- package/docs/guide/primitives/constant.md +0 -207
- package/docs/guide/primitives/derivations.md +0 -281
- package/docs/guide/primitives/effects.md +0 -372
- package/docs/guide/primitives/map.md +0 -265
- package/docs/guide/primitives/overview.md +0 -92
- package/docs/guide/primitives/signal.md +0 -222
- package/docs/guide/primitives/state.md +0 -272
- package/docs/index.md +0 -47
- package/docs/public/logo.svg +0 -1
- package/src/api/base/flowDisposable.ts +0 -44
- package/src/api/base/flowObservable.ts +0 -28
- package/src/api/base/flowSubscribable.ts +0 -87
- package/src/api/base/flowTracker.ts +0 -7
- package/src/api/base/index.ts +0 -4
- package/src/api/index.ts +0 -2
- package/src/api/nodes/async/flowConstantAsync.ts +0 -36
- package/src/api/nodes/async/flowDerivationAsync.ts +0 -42
- package/src/api/nodes/async/flowStateAsync.ts +0 -47
- package/src/api/nodes/async/flowWritableDerivationAsync.ts +0 -33
- package/src/api/nodes/async/index.ts +0 -4
- package/src/api/nodes/collections/flowArray.ts +0 -155
- package/src/api/nodes/collections/flowMap.ts +0 -115
- package/src/api/nodes/collections/index.ts +0 -2
- package/src/api/nodes/flowEffect.ts +0 -42
- package/src/api/nodes/flowSignal.ts +0 -28
- package/src/api/nodes/flowValue.ts +0 -37
- package/src/api/nodes/index.ts +0 -7
- package/src/api/nodes/sync/flowConstant.ts +0 -33
- package/src/api/nodes/sync/flowDerivation.ts +0 -41
- package/src/api/nodes/sync/flowState.ts +0 -45
- package/src/api/nodes/sync/flowWritableDerivation.ts +0 -31
- package/src/api/nodes/sync/index.ts +0 -4
- package/src/api/nodes/utils.ts +0 -24
- package/src/base/disposable.ts +0 -18
- package/src/base/executionStack.ts +0 -42
- package/src/base/index.ts +0 -5
- package/src/base/node.ts +0 -98
- package/src/base/observable.ts +0 -92
- package/src/base/observer.ts +0 -51
- package/src/converters/index.ts +0 -1
- package/src/converters/solid.ts +0 -109
- package/src/index.ts +0 -2
- package/src/nodes/arrayNode.ts +0 -180
- package/src/nodes/effectNode.ts +0 -58
- package/src/nodes/index.ts +0 -7
- package/src/nodes/mapNode.ts +0 -125
- package/src/nodes/signalNode.ts +0 -19
- package/src/nodes/valueAsyncNode.ts +0 -85
- package/src/nodes/valueNode.ts +0 -148
- package/src/nodes/valueSyncNode.ts +0 -125
- package/src/schedulers/asyncResolver.ts +0 -78
- package/src/schedulers/asyncScheduler.ts +0 -66
- package/src/schedulers/index.ts +0 -4
- package/src/schedulers/pendingError.ts +0 -13
- package/src/schedulers/scheduler.ts +0 -9
- package/src/schedulers/syncResolver.ts +0 -69
- package/src/schedulers/syncScheduler.ts +0 -55
- package/test/base/pendingError.test.ts +0 -67
- package/test/converters/solid.derivation.browser.test.tsx +0 -69
- package/test/converters/solid.node.test.ts +0 -654
- package/test/converters/solid.state.browser.test.tsx +0 -1592
- package/test/reactivity/flowSignal.test.ts +0 -226
- package/test/reactivity/nodes/async/asyncScheduler/asyncResolver.test.ts +0 -593
- package/test/reactivity/nodes/async/asyncScheduler/asyncScheduler.test.ts +0 -317
- package/test/reactivity/nodes/async/flowConstantAsync.test.ts +0 -652
- package/test/reactivity/nodes/async/flowDerivation.test.ts +0 -898
- package/test/reactivity/nodes/async/flowDerivationAsync.test.ts +0 -1716
- package/test/reactivity/nodes/async/flowStateAsync.test.ts +0 -708
- package/test/reactivity/nodes/async/flowWritableDerivationAsync.test.ts +0 -614
- package/test/reactivity/nodes/collections/flowArray.asyncStates.test.ts +0 -1289
- package/test/reactivity/nodes/collections/flowArray.scalars.test.ts +0 -961
- package/test/reactivity/nodes/collections/flowArray.states.test.ts +0 -1035
- package/test/reactivity/nodes/collections/flowMap.asyncStates.test.ts +0 -960
- package/test/reactivity/nodes/collections/flowMap.scalars.test.ts +0 -775
- package/test/reactivity/nodes/collections/flowMap.states.test.ts +0 -958
- package/test/reactivity/nodes/sync/flowConstant.test.ts +0 -377
- package/test/reactivity/nodes/sync/flowDerivation.test.ts +0 -896
- package/test/reactivity/nodes/sync/flowState.test.ts +0 -341
- package/test/reactivity/nodes/sync/flowWritableDerivation.test.ts +0 -603
- package/test/vitest.d.ts +0 -10
- package/tsconfig.json +0 -37
- package/typedoc.json +0 -37
- package/vite.config.ts +0 -31
- package/vitest.browser.config.ts +0 -21
- package/vitest.config.ts +0 -17
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { signal, subscribe } from "~";
|
|
3
|
-
|
|
4
|
-
describe("FlowSignal", () => {
|
|
5
|
-
describe("unit", () => {
|
|
6
|
-
describe("disposal", () => {
|
|
7
|
-
it("should have disposed property set to false initially and true after disposal", () => {
|
|
8
|
-
const $signal = signal();
|
|
9
|
-
expect($signal.disposed).toBe(false);
|
|
10
|
-
$signal.dispose();
|
|
11
|
-
expect($signal.disposed).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("should throw error when disposed twice", () => {
|
|
15
|
-
const $signal = signal();
|
|
16
|
-
$signal.dispose();
|
|
17
|
-
expect(() => $signal.dispose()).toThrow("[PicoFlow] Primitive is disposed");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should dispose signal successfully", () => {
|
|
21
|
-
const $signal = signal();
|
|
22
|
-
expect(() => $signal.dispose()).not.toThrow();
|
|
23
|
-
expect($signal.disposed).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should accept self option without throwing", () => {
|
|
27
|
-
const $signal = signal();
|
|
28
|
-
expect(() => $signal.dispose()).not.toThrow();
|
|
29
|
-
expect($signal.disposed).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("should accept default options without throwing", () => {
|
|
33
|
-
const $signal = signal();
|
|
34
|
-
expect(() => $signal.dispose()).not.toThrow();
|
|
35
|
-
expect($signal.disposed).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe("trigger", () => {
|
|
40
|
-
it("should return void when triggered", () => {
|
|
41
|
-
const $signal = signal();
|
|
42
|
-
const result = $signal.trigger();
|
|
43
|
-
expect(result).toBeUndefined();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should throw error when trigger is called after disposal", () => {
|
|
47
|
-
const $signal = signal();
|
|
48
|
-
$signal.dispose();
|
|
49
|
-
expect(() => $signal.trigger()).toThrow("[PicoFlow] Primitive is disposed");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should allow multiple triggers", () => {
|
|
53
|
-
const $signal = signal();
|
|
54
|
-
$signal.trigger();
|
|
55
|
-
$signal.trigger();
|
|
56
|
-
$signal.trigger();
|
|
57
|
-
// Should not throw
|
|
58
|
-
expect(true).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("integration", () => {
|
|
64
|
-
describe("with effects", () => {
|
|
65
|
-
describe("watch", () => {
|
|
66
|
-
it("should register effect when watch is called", async () => {
|
|
67
|
-
const $signal = signal();
|
|
68
|
-
const onData = vi.fn();
|
|
69
|
-
subscribe((t) => $signal.watch(t), onData);
|
|
70
|
-
|
|
71
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
|
|
72
|
-
expect(onData).toHaveBeenCalledTimes(1);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("should throw error when watch is called after signal disposal", async () => {
|
|
76
|
-
const $signal = signal();
|
|
77
|
-
const onData1 = vi.fn();
|
|
78
|
-
subscribe((t) => $signal.watch(t), onData1);
|
|
79
|
-
|
|
80
|
-
await vi.waitFor(() => expect(onData1).toHaveBeenCalledTimes(1));
|
|
81
|
-
|
|
82
|
-
$signal.dispose();
|
|
83
|
-
|
|
84
|
-
const onData2 = vi.fn();
|
|
85
|
-
const onError = vi.fn();
|
|
86
|
-
|
|
87
|
-
subscribe((t) => $signal.watch(t), onData2, onError);
|
|
88
|
-
|
|
89
|
-
await vi.waitFor(() => expect(onError).toHaveBeenCalledTimes(1));
|
|
90
|
-
expect(onData2).toHaveBeenCalledTimes(0);
|
|
91
|
-
expect(onError).toHaveBeenLastCalledWith(expect.any(Error));
|
|
92
|
-
|
|
93
|
-
expect(() => $signal.trigger()).toThrow("[PicoFlow] Primitive is disposed");
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
describe("trigger", () => {
|
|
98
|
-
it("should notify effects when triggered", async () => {
|
|
99
|
-
const $signal = signal();
|
|
100
|
-
const onData = vi.fn();
|
|
101
|
-
subscribe((t) => $signal.watch(t), onData);
|
|
102
|
-
|
|
103
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
|
|
104
|
-
|
|
105
|
-
$signal.trigger();
|
|
106
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
|
|
107
|
-
|
|
108
|
-
$signal.trigger();
|
|
109
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(3));
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("should notify multiple effects when triggered", async () => {
|
|
113
|
-
const $signal = signal();
|
|
114
|
-
const onData1 = vi.fn();
|
|
115
|
-
const onData2 = vi.fn();
|
|
116
|
-
const onData3 = vi.fn();
|
|
117
|
-
|
|
118
|
-
subscribe((t) => $signal.watch(t), onData1);
|
|
119
|
-
|
|
120
|
-
subscribe((t) => $signal.watch(t), onData2);
|
|
121
|
-
|
|
122
|
-
subscribe((t) => $signal.watch(t), onData3);
|
|
123
|
-
|
|
124
|
-
await vi.waitFor(() => {
|
|
125
|
-
expect(onData1).toHaveBeenCalledTimes(1);
|
|
126
|
-
expect(onData2).toHaveBeenCalledTimes(1);
|
|
127
|
-
expect(onData3).toHaveBeenCalledTimes(1);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
$signal.trigger();
|
|
131
|
-
await vi.waitFor(() => {
|
|
132
|
-
expect(onData1).toHaveBeenCalledTimes(2);
|
|
133
|
-
expect(onData2).toHaveBeenCalledTimes(2);
|
|
134
|
-
expect(onData3).toHaveBeenCalledTimes(2);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("should not notify effects after they are disposed", async () => {
|
|
139
|
-
const $signal = signal();
|
|
140
|
-
const onData = vi.fn();
|
|
141
|
-
const $effect = subscribe((t) => $signal.watch(t), onData);
|
|
142
|
-
|
|
143
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
|
|
144
|
-
|
|
145
|
-
$signal.trigger();
|
|
146
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
|
|
147
|
-
|
|
148
|
-
$effect.dispose();
|
|
149
|
-
|
|
150
|
-
$signal.trigger();
|
|
151
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("should notify effects multiple times on multiple triggers", async () => {
|
|
155
|
-
const $signal = signal();
|
|
156
|
-
const onData = vi.fn();
|
|
157
|
-
subscribe((t) => $signal.watch(t), onData);
|
|
158
|
-
|
|
159
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
|
|
160
|
-
|
|
161
|
-
$signal.trigger();
|
|
162
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(2));
|
|
163
|
-
|
|
164
|
-
$signal.trigger();
|
|
165
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(3));
|
|
166
|
-
|
|
167
|
-
$signal.trigger();
|
|
168
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(4));
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("should execute effects asynchronously when triggered", async () => {
|
|
172
|
-
const $signal = signal();
|
|
173
|
-
const onData = vi.fn();
|
|
174
|
-
|
|
175
|
-
subscribe(
|
|
176
|
-
(t) => $signal.watch(t),
|
|
177
|
-
() => onData("effect-executed"),
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
onData("after-initial-effect");
|
|
181
|
-
$signal.trigger();
|
|
182
|
-
onData("trigger-called");
|
|
183
|
-
|
|
184
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(4));
|
|
185
|
-
|
|
186
|
-
expect(onData).toHaveBeenNthCalledWith(1, "effect-executed");
|
|
187
|
-
expect(onData).toHaveBeenNthCalledWith(2, "after-initial-effect");
|
|
188
|
-
expect(onData).toHaveBeenNthCalledWith(3, "trigger-called");
|
|
189
|
-
expect(onData).toHaveBeenNthCalledWith(4, "effect-executed");
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
describe("dispose", () => {
|
|
194
|
-
it("should not dispose effects when signal is disposed", async () => {
|
|
195
|
-
const $signal = signal();
|
|
196
|
-
const onData = vi.fn();
|
|
197
|
-
const $effect = subscribe((t) => $signal.watch(t), onData);
|
|
198
|
-
|
|
199
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
|
|
200
|
-
expect($effect.disposed).toBe(false);
|
|
201
|
-
|
|
202
|
-
$signal.dispose();
|
|
203
|
-
|
|
204
|
-
expect($effect.disposed).toBe(false);
|
|
205
|
-
expect($signal.disposed).toBe(true);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it("should unregister effects when signal is disposed with self option", async () => {
|
|
209
|
-
const $signal = signal();
|
|
210
|
-
const onData = vi.fn();
|
|
211
|
-
const $effect = subscribe((t) => $signal.watch(t), onData);
|
|
212
|
-
|
|
213
|
-
await vi.waitFor(() => expect(onData).toHaveBeenCalledTimes(1));
|
|
214
|
-
|
|
215
|
-
$signal.dispose();
|
|
216
|
-
|
|
217
|
-
// Effect should still be active but not notified
|
|
218
|
-
expect($effect.disposed).toBe(false);
|
|
219
|
-
|
|
220
|
-
// But signal is disposed so trigger will fail
|
|
221
|
-
expect(() => $signal.trigger()).toThrow("[PicoFlow] Primitive is disposed");
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
});
|