@ersbeth/picoflow 0.2.1 → 0.2.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 (41) hide show
  1. package/api/doc/picoflow.from.md +55 -0
  2. package/api/doc/picoflow.from_1.md +55 -0
  3. package/api/doc/picoflow.from_2.md +55 -0
  4. package/api/doc/picoflow.from_3.md +55 -0
  5. package/api/doc/picoflow.from_4.md +55 -0
  6. package/api/doc/picoflow.from_5.md +55 -0
  7. package/api/doc/picoflow.md +121 -0
  8. package/api/doc/picoflow.solidderivation._constructor_.md +49 -0
  9. package/api/doc/picoflow.solidderivation.get.md +13 -0
  10. package/api/doc/picoflow.solidderivation.md +94 -0
  11. package/api/doc/picoflow.solidgetter.md +13 -0
  12. package/api/doc/picoflow.solidobservable.get.md +13 -0
  13. package/api/doc/picoflow.solidobservable.md +57 -0
  14. package/api/doc/picoflow.solidresource._constructor_.md +49 -0
  15. package/api/doc/picoflow.solidresource.get.md +13 -0
  16. package/api/doc/picoflow.solidresource.latest.md +13 -0
  17. package/api/doc/picoflow.solidresource.md +157 -0
  18. package/api/doc/picoflow.solidresource.refetch.md +13 -0
  19. package/api/doc/picoflow.solidresource.state.md +13 -0
  20. package/api/doc/picoflow.solidstate._constructor_.md +49 -0
  21. package/api/doc/picoflow.solidstate.get.md +13 -0
  22. package/api/doc/picoflow.solidstate.md +115 -0
  23. package/api/doc/picoflow.solidstate.set.md +13 -0
  24. package/api/picoflow.public.api.md +52 -0
  25. package/dist/picoflow.js +844 -2
  26. package/dist/types/basic/derivation.d.ts.map +1 -1
  27. package/dist/types/index.d.ts +3 -5
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/solid/converters.d.ts +64 -0
  30. package/dist/types/solid/converters.d.ts.map +1 -0
  31. package/dist/types/solid/index.d.ts +3 -0
  32. package/dist/types/solid/index.d.ts.map +1 -0
  33. package/dist/types/solid/primitives.d.ts +88 -0
  34. package/dist/types/solid/primitives.d.ts.map +1 -0
  35. package/package.json +4 -1
  36. package/src/basic/derivation.ts +18 -1
  37. package/src/index.ts +18 -12
  38. package/src/solid/converters.ts +159 -0
  39. package/src/solid/index.ts +2 -0
  40. package/src/solid/primitives.ts +109 -0
  41. package/test/derivation.test.ts +98 -0
@@ -0,0 +1,57 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidObservable](./picoflow.solidobservable.md)
4
+
5
+ ## SolidObservable interface
6
+
7
+ Interface for a Solid-style observable value.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export interface SolidObservable<T>
13
+ ```
14
+
15
+ ## Properties
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Property
20
+
21
+
22
+ </th><th>
23
+
24
+ Modifiers
25
+
26
+
27
+ </th><th>
28
+
29
+ Type
30
+
31
+
32
+ </th><th>
33
+
34
+ Description
35
+
36
+
37
+ </th></tr></thead>
38
+ <tbody><tr><td>
39
+
40
+ [get](./picoflow.solidobservable.get.md)
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td><td>
47
+
48
+ () =&gt; T
49
+
50
+
51
+ </td><td>
52
+
53
+ Returns the current value.
54
+
55
+
56
+ </td></tr>
57
+ </tbody></table>
@@ -0,0 +1,49 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidResource](./picoflow.solidresource.md) &gt; [(constructor)](./picoflow.solidresource._constructor_.md)
4
+
5
+ ## SolidResource.(constructor)
6
+
7
+ Creates a new SolidResource from a fetcher function.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ constructor(fetcher: ResourceFetcher<true, T, unknown>);
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
+ fetcher
36
+
37
+
38
+ </td><td>
39
+
40
+ ResourceFetcher&lt;true, T, unknown&gt;
41
+
42
+
43
+ </td><td>
44
+
45
+ The async fetcher function.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidResource](./picoflow.solidresource.md) &gt; [get](./picoflow.solidresource.get.md)
4
+
5
+ ## SolidResource.get property
6
+
7
+ Returns the current value (or undefined if not yet loaded).
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ readonly get: () => T | undefined;
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidResource](./picoflow.solidresource.md) &gt; [latest](./picoflow.solidresource.latest.md)
4
+
5
+ ## SolidResource.latest property
6
+
7
+ Returns the latest successfully loaded value (or undefined).
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ readonly latest: () => T | undefined;
13
+ ```
@@ -0,0 +1,157 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidResource](./picoflow.solidresource.md)
4
+
5
+ ## SolidResource class
6
+
7
+ Solid-style resource, similar to an async resource or data loader.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare class SolidResource<T> implements SolidObservable<T | undefined>
13
+ ```
14
+ **Implements:** [SolidObservable](./picoflow.solidobservable.md)<!-- -->&lt;T \| undefined&gt;
15
+
16
+ ## Constructors
17
+
18
+ <table><thead><tr><th>
19
+
20
+ Constructor
21
+
22
+
23
+ </th><th>
24
+
25
+ Modifiers
26
+
27
+
28
+ </th><th>
29
+
30
+ Description
31
+
32
+
33
+ </th></tr></thead>
34
+ <tbody><tr><td>
35
+
36
+ [(constructor)(fetcher)](./picoflow.solidresource._constructor_.md)
37
+
38
+
39
+ </td><td>
40
+
41
+
42
+ </td><td>
43
+
44
+ Creates a new SolidResource from a fetcher function.
45
+
46
+
47
+ </td></tr>
48
+ </tbody></table>
49
+
50
+ ## Properties
51
+
52
+ <table><thead><tr><th>
53
+
54
+ Property
55
+
56
+
57
+ </th><th>
58
+
59
+ Modifiers
60
+
61
+
62
+ </th><th>
63
+
64
+ Type
65
+
66
+
67
+ </th><th>
68
+
69
+ Description
70
+
71
+
72
+ </th></tr></thead>
73
+ <tbody><tr><td>
74
+
75
+ [get](./picoflow.solidresource.get.md)
76
+
77
+
78
+ </td><td>
79
+
80
+ `readonly`
81
+
82
+
83
+ </td><td>
84
+
85
+ () =&gt; T \| undefined
86
+
87
+
88
+ </td><td>
89
+
90
+ Returns the current value (or undefined if not yet loaded).
91
+
92
+
93
+ </td></tr>
94
+ <tr><td>
95
+
96
+ [latest](./picoflow.solidresource.latest.md)
97
+
98
+
99
+ </td><td>
100
+
101
+ `readonly`
102
+
103
+
104
+ </td><td>
105
+
106
+ () =&gt; T \| undefined
107
+
108
+
109
+ </td><td>
110
+
111
+ Returns the latest successfully loaded value (or undefined).
112
+
113
+
114
+ </td></tr>
115
+ <tr><td>
116
+
117
+ [refetch](./picoflow.solidresource.refetch.md)
118
+
119
+
120
+ </td><td>
121
+
122
+ `readonly`
123
+
124
+
125
+ </td><td>
126
+
127
+ () =&gt; void
128
+
129
+
130
+ </td><td>
131
+
132
+ Triggers a refetch of the resource.
133
+
134
+
135
+ </td></tr>
136
+ <tr><td>
137
+
138
+ [state](./picoflow.solidresource.state.md)
139
+
140
+
141
+ </td><td>
142
+
143
+ `readonly`
144
+
145
+
146
+ </td><td>
147
+
148
+ () =&gt; 'unresolved' \| 'pending' \| 'errored' \| 'ready' \| 'refreshing'
149
+
150
+
151
+ </td><td>
152
+
153
+ Returns the current resource state.
154
+
155
+
156
+ </td></tr>
157
+ </tbody></table>
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidResource](./picoflow.solidresource.md) &gt; [refetch](./picoflow.solidresource.refetch.md)
4
+
5
+ ## SolidResource.refetch property
6
+
7
+ Triggers a refetch of the resource.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ readonly refetch: () => void;
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidResource](./picoflow.solidresource.md) &gt; [state](./picoflow.solidresource.state.md)
4
+
5
+ ## SolidResource.state property
6
+
7
+ Returns the current resource state.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ readonly state: () => 'unresolved' | 'pending' | 'errored' | 'ready' | 'refreshing';
13
+ ```
@@ -0,0 +1,49 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidState](./picoflow.solidstate.md) &gt; [(constructor)](./picoflow.solidstate._constructor_.md)
4
+
5
+ ## SolidState.(constructor)
6
+
7
+ Creates a new SolidState with the given initial value.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ constructor(initialValue: 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
+ initialValue
36
+
37
+
38
+ </td><td>
39
+
40
+ T
41
+
42
+
43
+ </td><td>
44
+
45
+ The initial value.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidState](./picoflow.solidstate.md) &gt; [get](./picoflow.solidstate.get.md)
4
+
5
+ ## SolidState.get property
6
+
7
+ Returns the current value.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ readonly get: () => T;
13
+ ```
@@ -0,0 +1,115 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidState](./picoflow.solidstate.md)
4
+
5
+ ## SolidState class
6
+
7
+ Solid-style state container, similar to a writable signal.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare class SolidState<T> implements SolidObservable<T>
13
+ ```
14
+ **Implements:** [SolidObservable](./picoflow.solidobservable.md)<!-- -->&lt;T&gt;
15
+
16
+ ## Constructors
17
+
18
+ <table><thead><tr><th>
19
+
20
+ Constructor
21
+
22
+
23
+ </th><th>
24
+
25
+ Modifiers
26
+
27
+
28
+ </th><th>
29
+
30
+ Description
31
+
32
+
33
+ </th></tr></thead>
34
+ <tbody><tr><td>
35
+
36
+ [(constructor)(initialValue)](./picoflow.solidstate._constructor_.md)
37
+
38
+
39
+ </td><td>
40
+
41
+
42
+ </td><td>
43
+
44
+ Creates a new SolidState with the given initial value.
45
+
46
+
47
+ </td></tr>
48
+ </tbody></table>
49
+
50
+ ## Properties
51
+
52
+ <table><thead><tr><th>
53
+
54
+ Property
55
+
56
+
57
+ </th><th>
58
+
59
+ Modifiers
60
+
61
+
62
+ </th><th>
63
+
64
+ Type
65
+
66
+
67
+ </th><th>
68
+
69
+ Description
70
+
71
+
72
+ </th></tr></thead>
73
+ <tbody><tr><td>
74
+
75
+ [get](./picoflow.solidstate.get.md)
76
+
77
+
78
+ </td><td>
79
+
80
+ `readonly`
81
+
82
+
83
+ </td><td>
84
+
85
+ () =&gt; T
86
+
87
+
88
+ </td><td>
89
+
90
+ Returns the current value.
91
+
92
+
93
+ </td></tr>
94
+ <tr><td>
95
+
96
+ [set](./picoflow.solidstate.set.md)
97
+
98
+
99
+ </td><td>
100
+
101
+ `readonly`
102
+
103
+
104
+ </td><td>
105
+
106
+ (param: [SolidGetter](./picoflow.solidgetter.md)<!-- -->&lt;T&gt;) =&gt; void
107
+
108
+
109
+ </td><td>
110
+
111
+ Sets the value or updates it using a getter function.
112
+
113
+
114
+ </td></tr>
115
+ </tbody></table>
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [SolidState](./picoflow.solidstate.md) &gt; [set](./picoflow.solidstate.set.md)
4
+
5
+ ## SolidState.set property
6
+
7
+ Sets the value or updates it using a getter function.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ readonly set: (param: SolidGetter<T>) => void;
13
+ ```
@@ -4,6 +4,8 @@
4
4
 
5
5
  ```ts
6
6
 
7
+ import { ResourceFetcher } from 'solid-js';
8
+
7
9
  // @public
8
10
  export function array<T>(initial?: T[]): FlowArray<T>;
9
11
 
@@ -165,6 +167,26 @@ export type FlowStreamUpdater<T> = (set: FlowStreamSetter<T>) => FlowStreamDispo
165
167
  // @public
166
168
  export type FlowWatcher = (signal: FlowSignal) => void;
167
169
 
170
+ // Warning: (ae-forgotten-export) The symbol "NotPromise" needs to be exported by the entry point index.d.ts
171
+ //
172
+ // @public
173
+ export function from<T>(flow: FlowObservable<Promise<NotPromise<T>>>): SolidResource<NotPromise<T>>;
174
+
175
+ // @public
176
+ export function from<T>(flow: FlowObservable<NotPromise<T>>): SolidDerivation<NotPromise<T>>;
177
+
178
+ // @public
179
+ export function from<T>(flow: FlowObservable<Promise<NotPromise<T>>> | FlowObservable<NotPromise<T>>): SolidDerivation<NotPromise<T>> | SolidResource<NotPromise<T>>;
180
+
181
+ // @public
182
+ export function from<T>(flow: (get: FlowGetter) => NotPromise<T>): SolidDerivation<NotPromise<T>>;
183
+
184
+ // @public
185
+ export function from<T>(flow: (get: FlowGetter) => Promise<NotPromise<T>>): SolidResource<NotPromise<T>>;
186
+
187
+ // @public
188
+ export function from<T>(flow: ((get: FlowGetter) => NotPromise<T>) | ((get: FlowGetter) => Promise<NotPromise<T>>)): SolidDerivation<T> | SolidResource<T>;
189
+
168
190
  // @public
169
191
  export function isDisposable(obj: unknown): obj is FlowDisposable;
170
192
 
@@ -180,6 +202,36 @@ export function resourceAsync<T>(fn: () => Promise<T>): FlowResourceAsync<T>;
180
202
  // @public
181
203
  export function signal(): FlowSignal;
182
204
 
205
+ // @public
206
+ export class SolidDerivation<T> implements SolidObservable<T> {
207
+ constructor(calculator: SolidGetter<T>);
208
+ readonly get: () => T;
209
+ }
210
+
211
+ // @public
212
+ export type SolidGetter<T> = ((previous: T) => T) | T;
213
+
214
+ // @public
215
+ export interface SolidObservable<T> {
216
+ get: () => T;
217
+ }
218
+
219
+ // @public
220
+ export class SolidResource<T> implements SolidObservable<T | undefined> {
221
+ constructor(fetcher: ResourceFetcher<true, T, unknown>);
222
+ readonly get: () => T | undefined;
223
+ readonly latest: () => T | undefined;
224
+ readonly refetch: () => void;
225
+ readonly state: () => 'unresolved' | 'pending' | 'errored' | 'ready' | 'refreshing';
226
+ }
227
+
228
+ // @public
229
+ export class SolidState<T> implements SolidObservable<T> {
230
+ constructor(initialValue: T);
231
+ readonly get: () => T;
232
+ readonly set: (param: SolidGetter<T>) => void;
233
+ }
234
+
183
235
  // @public
184
236
  export function state<T>(value: T | (() => T)): FlowState<T>;
185
237