@ersbeth/picoflow 0.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 (90) hide show
  1. package/.vscode/settings.json +5 -0
  2. package/README.md +151 -0
  3. package/api/doc/index.md +31 -0
  4. package/api/doc/picoflow.derivation.md +55 -0
  5. package/api/doc/picoflow.effect.md +55 -0
  6. package/api/doc/picoflow.flowderivation._constructor_.md +49 -0
  7. package/api/doc/picoflow.flowderivation.get.md +23 -0
  8. package/api/doc/picoflow.flowderivation.md +86 -0
  9. package/api/doc/picoflow.flowdisposer.md +13 -0
  10. package/api/doc/picoflow.floweffect._constructor_.md +49 -0
  11. package/api/doc/picoflow.floweffect.dispose.md +21 -0
  12. package/api/doc/picoflow.floweffect.disposed.md +13 -0
  13. package/api/doc/picoflow.floweffect.md +131 -0
  14. package/api/doc/picoflow.flowgetter.md +15 -0
  15. package/api/doc/picoflow.flowmap._lastdeleted.md +21 -0
  16. package/api/doc/picoflow.flowmap._lastset.md +21 -0
  17. package/api/doc/picoflow.flowmap.delete.md +57 -0
  18. package/api/doc/picoflow.flowmap.md +135 -0
  19. package/api/doc/picoflow.flowmap.setat.md +73 -0
  20. package/api/doc/picoflow.flowobservable.get.md +19 -0
  21. package/api/doc/picoflow.flowobservable.md +54 -0
  22. package/api/doc/picoflow.flowresource._constructor_.md +65 -0
  23. package/api/doc/picoflow.flowresource.fetch.md +27 -0
  24. package/api/doc/picoflow.flowresource.get.md +23 -0
  25. package/api/doc/picoflow.flowresource.md +100 -0
  26. package/api/doc/picoflow.flowsetter.md +13 -0
  27. package/api/doc/picoflow.flowsignal.dispose.md +25 -0
  28. package/api/doc/picoflow.flowsignal.disposed.md +18 -0
  29. package/api/doc/picoflow.flowsignal.md +111 -0
  30. package/api/doc/picoflow.flowsignal.trigger.md +25 -0
  31. package/api/doc/picoflow.flowstate._constructor_.md +49 -0
  32. package/api/doc/picoflow.flowstate.get.md +23 -0
  33. package/api/doc/picoflow.flowstate.md +100 -0
  34. package/api/doc/picoflow.flowstate.set.md +61 -0
  35. package/api/doc/picoflow.flowstream._constructor_.md +65 -0
  36. package/api/doc/picoflow.flowstream.dispose.md +21 -0
  37. package/api/doc/picoflow.flowstream.get.md +23 -0
  38. package/api/doc/picoflow.flowstream.md +100 -0
  39. package/api/doc/picoflow.flowupdater.md +19 -0
  40. package/api/doc/picoflow.flowwatcher.md +15 -0
  41. package/api/doc/picoflow.map.md +59 -0
  42. package/api/doc/picoflow.md +287 -0
  43. package/api/doc/picoflow.resource.md +71 -0
  44. package/api/doc/picoflow.signal.md +19 -0
  45. package/api/doc/picoflow.state.md +55 -0
  46. package/api/doc/picoflow.stream.md +71 -0
  47. package/api/picoflow.api.md +145 -0
  48. package/api-extractor.json +60 -0
  49. package/biome.json +34 -0
  50. package/dist/picoflow.js +572 -0
  51. package/dist/types/creators.d.ts +70 -0
  52. package/dist/types/creators.d.ts.map +1 -0
  53. package/dist/types/derivation.d.ts +58 -0
  54. package/dist/types/derivation.d.ts.map +1 -0
  55. package/dist/types/effect.d.ts +108 -0
  56. package/dist/types/effect.d.ts.map +1 -0
  57. package/dist/types/index.d.ts +18 -0
  58. package/dist/types/index.d.ts.map +1 -0
  59. package/dist/types/map.d.ts +75 -0
  60. package/dist/types/map.d.ts.map +1 -0
  61. package/dist/types/observable.d.ts +40 -0
  62. package/dist/types/observable.d.ts.map +1 -0
  63. package/dist/types/resource.d.ts +46 -0
  64. package/dist/types/resource.d.ts.map +1 -0
  65. package/dist/types/signal.d.ts +111 -0
  66. package/dist/types/signal.d.ts.map +1 -0
  67. package/dist/types/state.d.ts +39 -0
  68. package/dist/types/state.d.ts.map +1 -0
  69. package/dist/types/stream.d.ts +71 -0
  70. package/dist/types/stream.d.ts.map +1 -0
  71. package/package.json +40 -0
  72. package/src/creators.ts +101 -0
  73. package/src/derivation.ts +96 -0
  74. package/src/effect.ts +152 -0
  75. package/src/index.ts +30 -0
  76. package/src/map.ts +83 -0
  77. package/src/observable.ts +50 -0
  78. package/src/resource.ts +64 -0
  79. package/src/signal.ts +166 -0
  80. package/src/state.ts +52 -0
  81. package/src/stream.ts +99 -0
  82. package/test/derivation.test.ts +422 -0
  83. package/test/map.test.ts +106 -0
  84. package/test/resource.test.ts +127 -0
  85. package/test/signal.test.ts +59 -0
  86. package/test/state.test.ts +89 -0
  87. package/test/stream.test.ts +171 -0
  88. package/tsconfig.json +22 -0
  89. package/vite.config.ts +26 -0
  90. package/vitest.config.ts +11 -0
@@ -0,0 +1,111 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowSignal](./picoflow.flowsignal.md)
4
+
5
+ ## FlowSignal class
6
+
7
+ Represents a reactive signal.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare class FlowSignal
13
+ ```
14
+
15
+ ## Remarks
16
+
17
+ A FlowSignal allows you to trigger notifications via [FlowSignal.trigger()](./picoflow.flowsignal.trigger.md) and to dispose the signal and all its registered dependencies, listeners, and effects via [FlowSignal.dispose()](./picoflow.flowsignal.dispose.md)<!-- -->.
18
+
19
+ ## Properties
20
+
21
+ <table><thead><tr><th>
22
+
23
+ Property
24
+
25
+
26
+ </th><th>
27
+
28
+ Modifiers
29
+
30
+
31
+ </th><th>
32
+
33
+ Type
34
+
35
+
36
+ </th><th>
37
+
38
+ Description
39
+
40
+
41
+ </th></tr></thead>
42
+ <tbody><tr><td>
43
+
44
+ [disposed](./picoflow.flowsignal.disposed.md)
45
+
46
+
47
+ </td><td>
48
+
49
+ `readonly`
50
+
51
+
52
+ </td><td>
53
+
54
+ boolean
55
+
56
+
57
+ </td><td>
58
+
59
+ Indicates whether the signal has been disposed.
60
+
61
+
62
+ </td></tr>
63
+ </tbody></table>
64
+
65
+ ## Methods
66
+
67
+ <table><thead><tr><th>
68
+
69
+ Method
70
+
71
+
72
+ </th><th>
73
+
74
+ Modifiers
75
+
76
+
77
+ </th><th>
78
+
79
+ Description
80
+
81
+
82
+ </th></tr></thead>
83
+ <tbody><tr><td>
84
+
85
+ [dispose()](./picoflow.flowsignal.dispose.md)
86
+
87
+
88
+ </td><td>
89
+
90
+
91
+ </td><td>
92
+
93
+ Disposes the signal.
94
+
95
+
96
+ </td></tr>
97
+ <tr><td>
98
+
99
+ [trigger()](./picoflow.flowsignal.trigger.md)
100
+
101
+
102
+ </td><td>
103
+
104
+
105
+ </td><td>
106
+
107
+ Triggers the signal.
108
+
109
+
110
+ </td></tr>
111
+ </tbody></table>
@@ -0,0 +1,25 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowSignal](./picoflow.flowsignal.md) &gt; [trigger](./picoflow.flowsignal.trigger.md)
4
+
5
+ ## FlowSignal.trigger() method
6
+
7
+ Triggers the signal.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ trigger(): void;
13
+ ```
14
+ **Returns:**
15
+
16
+ void
17
+
18
+ ## Exceptions
19
+
20
+ Error if the signal is disposed.
21
+
22
+ ## Remarks
23
+
24
+ This method notifies all registered listeners and causes associated effects to execute.
25
+
@@ -0,0 +1,49 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowState](./picoflow.flowstate.md) &gt; [(constructor)](./picoflow.flowstate._constructor_.md)
4
+
5
+ ## FlowState.(constructor)
6
+
7
+ Creates a new FlowState with the given initial value.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ constructor(value: T);
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ value
36
+
37
+
38
+ </td><td>
39
+
40
+ T
41
+
42
+
43
+ </td><td>
44
+
45
+ The initial value for the state.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
@@ -0,0 +1,23 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowState](./picoflow.flowstate.md) &gt; [get](./picoflow.flowstate.get.md)
4
+
5
+ ## FlowState.get() method
6
+
7
+ Retrieves the current state value.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get(): T;
13
+ ```
14
+ **Returns:**
15
+
16
+ T
17
+
18
+ The current value of the state.
19
+
20
+ ## Exceptions
21
+
22
+ Error if the state has been disposed.
23
+
@@ -0,0 +1,100 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowState](./picoflow.flowstate.md)
4
+
5
+ ## FlowState class
6
+
7
+ Represents a reactive state that holds a mutable value.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare class FlowState<T> extends FlowObservable<T>
13
+ ```
14
+ **Extends:** [FlowObservable](./picoflow.flowobservable.md)<!-- -->&lt;T&gt;
15
+
16
+ ## Remarks
17
+
18
+ FlowState extends FlowObservable to provide a simple reactive state primitive. Use the [FlowState.get()](./picoflow.flowstate.get.md) method to read the current state and [FlowState.set()](./picoflow.flowstate.set.md) to update it. When the state is updated, subscribers are notified automatically.
19
+
20
+ ## Constructors
21
+
22
+ <table><thead><tr><th>
23
+
24
+ Constructor
25
+
26
+
27
+ </th><th>
28
+
29
+ Modifiers
30
+
31
+
32
+ </th><th>
33
+
34
+ Description
35
+
36
+
37
+ </th></tr></thead>
38
+ <tbody><tr><td>
39
+
40
+ [(constructor)(value)](./picoflow.flowstate._constructor_.md)
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td><td>
47
+
48
+ Creates a new FlowState with the given initial value.
49
+
50
+
51
+ </td></tr>
52
+ </tbody></table>
53
+
54
+ ## Methods
55
+
56
+ <table><thead><tr><th>
57
+
58
+ Method
59
+
60
+
61
+ </th><th>
62
+
63
+ Modifiers
64
+
65
+
66
+ </th><th>
67
+
68
+ Description
69
+
70
+
71
+ </th></tr></thead>
72
+ <tbody><tr><td>
73
+
74
+ [get()](./picoflow.flowstate.get.md)
75
+
76
+
77
+ </td><td>
78
+
79
+
80
+ </td><td>
81
+
82
+ Retrieves the current state value.
83
+
84
+
85
+ </td></tr>
86
+ <tr><td>
87
+
88
+ [set(value)](./picoflow.flowstate.set.md)
89
+
90
+
91
+ </td><td>
92
+
93
+
94
+ </td><td>
95
+
96
+ Updates the state with a new value.
97
+
98
+
99
+ </td></tr>
100
+ </tbody></table>
@@ -0,0 +1,61 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowState](./picoflow.flowstate.md) &gt; [set](./picoflow.flowstate.set.md)
4
+
5
+ ## FlowState.set() method
6
+
7
+ Updates the state with a new value.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ set(value: T): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ value
36
+
37
+
38
+ </td><td>
39
+
40
+ T
41
+
42
+
43
+ </td><td>
44
+
45
+ The new value to set.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+ **Returns:**
51
+
52
+ void
53
+
54
+ ## Exceptions
55
+
56
+ Error if the state has been disposed.
57
+
58
+ ## Remarks
59
+
60
+ If the new value is identical to the current value, no update or notification occurs. Otherwise, the state is updated and all subscribers are notified.
61
+
@@ -0,0 +1,65 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowStream](./picoflow.flowstream.md) &gt; [(constructor)](./picoflow.flowstream._constructor_.md)
4
+
5
+ ## FlowStream.(constructor)
6
+
7
+ Creates a new FlowStream.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ constructor(updater: FlowUpdater<T>, initial: T);
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ updater
36
+
37
+
38
+ </td><td>
39
+
40
+ [FlowUpdater](./picoflow.flowupdater.md)<!-- -->&lt;T&gt;
41
+
42
+
43
+ </td><td>
44
+
45
+ A function that receives a setter to update the stream's value. It should return a disposer function that will be called upon disposal.
46
+
47
+
48
+ </td></tr>
49
+ <tr><td>
50
+
51
+ initial
52
+
53
+
54
+ </td><td>
55
+
56
+ T
57
+
58
+
59
+ </td><td>
60
+
61
+ The initial value of the stream.
62
+
63
+
64
+ </td></tr>
65
+ </tbody></table>
@@ -0,0 +1,21 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowStream](./picoflow.flowstream.md) &gt; [dispose](./picoflow.flowstream.dispose.md)
4
+
5
+ ## FlowStream.dispose() method
6
+
7
+ Disposes the stream, releasing all resources.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ dispose(): void;
13
+ ```
14
+ **Returns:**
15
+
16
+ void
17
+
18
+ ## Remarks
19
+
20
+ In addition to disposing the underlying observable, this method calls the disposer returned by the updater.
21
+
@@ -0,0 +1,23 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowStream](./picoflow.flowstream.md) &gt; [get](./picoflow.flowstream.get.md)
4
+
5
+ ## FlowStream.get() method
6
+
7
+ Retrieves the current value of the stream.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get(): T;
13
+ ```
14
+ **Returns:**
15
+
16
+ T
17
+
18
+ The current value.
19
+
20
+ ## Exceptions
21
+
22
+ Error if the stream is disposed.
23
+
@@ -0,0 +1,100 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowStream](./picoflow.flowstream.md)
4
+
5
+ ## FlowStream class
6
+
7
+ Represents a reactive stream that updates its value based on an updater function.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare class FlowStream<T> extends FlowObservable<T>
13
+ ```
14
+ **Extends:** [FlowObservable](./picoflow.flowobservable.md)<!-- -->&lt;T&gt;
15
+
16
+ ## Remarks
17
+
18
+ A FlowStream extends FlowObservable and encapsulates a mechanism for updating its value via an external updater function. The updater is invoked during construction with a setter, and it returns a disposer to be called when the stream is disposed.
19
+
20
+ ## Constructors
21
+
22
+ <table><thead><tr><th>
23
+
24
+ Constructor
25
+
26
+
27
+ </th><th>
28
+
29
+ Modifiers
30
+
31
+
32
+ </th><th>
33
+
34
+ Description
35
+
36
+
37
+ </th></tr></thead>
38
+ <tbody><tr><td>
39
+
40
+ [(constructor)(updater, initial)](./picoflow.flowstream._constructor_.md)
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td><td>
47
+
48
+ Creates a new FlowStream.
49
+
50
+
51
+ </td></tr>
52
+ </tbody></table>
53
+
54
+ ## Methods
55
+
56
+ <table><thead><tr><th>
57
+
58
+ Method
59
+
60
+
61
+ </th><th>
62
+
63
+ Modifiers
64
+
65
+
66
+ </th><th>
67
+
68
+ Description
69
+
70
+
71
+ </th></tr></thead>
72
+ <tbody><tr><td>
73
+
74
+ [dispose()](./picoflow.flowstream.dispose.md)
75
+
76
+
77
+ </td><td>
78
+
79
+
80
+ </td><td>
81
+
82
+ Disposes the stream, releasing all resources.
83
+
84
+
85
+ </td></tr>
86
+ <tr><td>
87
+
88
+ [get()](./picoflow.flowstream.get.md)
89
+
90
+
91
+ </td><td>
92
+
93
+
94
+ </td><td>
95
+
96
+ Retrieves the current value of the stream.
97
+
98
+
99
+ </td></tr>
100
+ </tbody></table>
@@ -0,0 +1,19 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowUpdater](./picoflow.flowupdater.md)
4
+
5
+ ## FlowUpdater type
6
+
7
+ A function that performs updates on a stream.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type FlowUpdater<T> = (set: FlowSetter<T>) => FlowDisposer;
13
+ ```
14
+ **References:** [FlowSetter](./picoflow.flowsetter.md)<!-- -->, [FlowDisposer](./picoflow.flowdisposer.md)
15
+
16
+ ## Remarks
17
+
18
+ The updater receives a setter function that can be used to update the stream's value. It should return a disposer function to clean up any resources or subscriptions.
19
+
@@ -0,0 +1,15 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [FlowWatcher](./picoflow.flowwatcher.md)
4
+
5
+ ## FlowWatcher type
6
+
7
+ A function for watching a FlowSignal.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type FlowWatcher = (signal: FlowSignal) => void;
13
+ ```
14
+ **References:** [FlowSignal](./picoflow.flowsignal.md)
15
+
@@ -0,0 +1,59 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [picoflow](./picoflow.md) &gt; [map](./picoflow.map.md)
4
+
5
+ ## map() function
6
+
7
+ Creates a new reactive map state.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare function map<K extends string | number | symbol, V>(initial?: Record<K, V>): FlowMap<K, V>;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ initial
36
+
37
+
38
+ </td><td>
39
+
40
+ Record&lt;K, V&gt;
41
+
42
+
43
+ </td><td>
44
+
45
+ _(Optional)_ An optional record of key-value pairs to initialize the map.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+ **Returns:**
51
+
52
+ [FlowMap](./picoflow.flowmap.md)<!-- -->&lt;K, V&gt;
53
+
54
+ A new instance of [FlowMap](./picoflow.flowmap.md)<!-- -->.
55
+
56
+ ## Remarks
57
+
58
+ The initial record is converted to a native Map before being used.
59
+