@ersbeth/picoflow 0.1.0 → 0.2.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 (48) hide show
  1. package/api/doc/picoflow.array.md +55 -0
  2. package/api/doc/picoflow.flowarray._constructor_.md +49 -0
  3. package/api/doc/picoflow.flowarray._lastaction.md +13 -0
  4. package/api/doc/picoflow.flowarray.clear.md +17 -0
  5. package/api/doc/picoflow.flowarray.dispose.md +55 -0
  6. package/api/doc/picoflow.flowarray.get.md +19 -0
  7. package/api/doc/picoflow.flowarray.length.md +13 -0
  8. package/api/doc/picoflow.flowarray.md +273 -0
  9. package/api/doc/picoflow.flowarray.pop.md +17 -0
  10. package/api/doc/picoflow.flowarray.push.md +53 -0
  11. package/api/doc/picoflow.flowarray.set.md +53 -0
  12. package/api/doc/picoflow.flowarray.setitem.md +69 -0
  13. package/api/doc/picoflow.flowarray.shift.md +17 -0
  14. package/api/doc/picoflow.flowarray.splice.md +85 -0
  15. package/api/doc/picoflow.flowarray.unshift.md +53 -0
  16. package/api/doc/picoflow.flowarrayaction.md +37 -0
  17. package/api/doc/picoflow.flowdisposable.dispose.md +55 -0
  18. package/api/doc/picoflow.flowdisposable.md +43 -0
  19. package/api/doc/picoflow.flowsignal.dispose.md +39 -1
  20. package/api/doc/picoflow.flowsignal.md +3 -2
  21. package/api/doc/picoflow.isdisposable.md +55 -0
  22. package/api/doc/picoflow.md +70 -0
  23. package/api/picoflow.public.api.md +63 -2
  24. package/dist/picoflow.js +188 -4
  25. package/dist/types/advanced/array.d.ts +116 -0
  26. package/dist/types/advanced/array.d.ts.map +1 -0
  27. package/dist/types/advanced/index.d.ts +2 -0
  28. package/dist/types/advanced/index.d.ts.map +1 -1
  29. package/dist/types/basic/disposable.d.ts +23 -0
  30. package/dist/types/basic/disposable.d.ts.map +1 -0
  31. package/dist/types/basic/index.d.ts +2 -0
  32. package/dist/types/basic/index.d.ts.map +1 -1
  33. package/dist/types/basic/signal.d.ts +5 -2
  34. package/dist/types/basic/signal.d.ts.map +1 -1
  35. package/dist/types/creators.d.ts +9 -0
  36. package/dist/types/creators.d.ts.map +1 -1
  37. package/dist/types/index.d.ts +6 -3
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/advanced/array.ts +224 -0
  41. package/src/advanced/index.ts +2 -0
  42. package/src/basic/disposable.ts +27 -0
  43. package/src/basic/index.ts +2 -0
  44. package/src/basic/observable.ts +2 -2
  45. package/src/basic/signal.ts +17 -5
  46. package/src/creators.ts +12 -0
  47. package/src/index.ts +13 -3
  48. package/test/array.test.ts +620 -0
@@ -0,0 +1,85 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [FlowArray](./picoflow.flowarray.md) &gt; [splice](./picoflow.flowarray.splice.md)
4
+
5
+ ## FlowArray.splice() method
6
+
7
+ Changes the content of the array.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ splice(start: number, deleteCount: number, ...newItems: 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
+ start
36
+
37
+
38
+ </td><td>
39
+
40
+ number
41
+
42
+
43
+ </td><td>
44
+
45
+ The starting index.
46
+
47
+
48
+ </td></tr>
49
+ <tr><td>
50
+
51
+ deleteCount
52
+
53
+
54
+ </td><td>
55
+
56
+ number
57
+
58
+
59
+ </td><td>
60
+
61
+ Number of items to remove.
62
+
63
+
64
+ </td></tr>
65
+ <tr><td>
66
+
67
+ newItems
68
+
69
+
70
+ </td><td>
71
+
72
+ T\[\]
73
+
74
+
75
+ </td><td>
76
+
77
+ New items to add.
78
+
79
+
80
+ </td></tr>
81
+ </tbody></table>
82
+ **Returns:**
83
+
84
+ void
85
+
@@ -0,0 +1,53 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [FlowArray](./picoflow.flowarray.md) &gt; [unshift](./picoflow.flowarray.unshift.md)
4
+
5
+ ## FlowArray.unshift() method
6
+
7
+ Inserts an item at the beginning of the array.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ unshift(item: 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
+ item
36
+
37
+
38
+ </td><td>
39
+
40
+ T
41
+
42
+
43
+ </td><td>
44
+
45
+ The item to insert.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+ **Returns:**
51
+
52
+ void
53
+
@@ -0,0 +1,37 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [FlowArrayAction](./picoflow.flowarrayaction.md)
4
+
5
+ ## FlowArrayAction type
6
+
7
+ Represents the actions that can be performed on a FlowArray.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type FlowArrayAction<T> = {
13
+ type: "set";
14
+ items: T[];
15
+ } | {
16
+ type: "setItem";
17
+ index: number;
18
+ item: T;
19
+ } | {
20
+ type: "push";
21
+ item: T;
22
+ } | {
23
+ type: "pop";
24
+ } | {
25
+ type: "unshift";
26
+ item: T;
27
+ } | {
28
+ type: "shift";
29
+ } | {
30
+ type: "splice";
31
+ start: number;
32
+ deleteCount: number;
33
+ items: T[];
34
+ } | {
35
+ type: "clear";
36
+ };
37
+ ```
@@ -0,0 +1,55 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [FlowDisposable](./picoflow.flowdisposable.md) &gt; [dispose](./picoflow.flowdisposable.dispose.md)
4
+
5
+ ## FlowDisposable.dispose() method
6
+
7
+ Disposes resources held by this object.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ dispose(options?: {
13
+ self: boolean;
14
+ }): void;
15
+ ```
16
+
17
+ ## Parameters
18
+
19
+ <table><thead><tr><th>
20
+
21
+ Parameter
22
+
23
+
24
+ </th><th>
25
+
26
+ Type
27
+
28
+
29
+ </th><th>
30
+
31
+ Description
32
+
33
+
34
+ </th></tr></thead>
35
+ <tbody><tr><td>
36
+
37
+ options
38
+
39
+
40
+ </td><td>
41
+
42
+ { self: boolean; }
43
+
44
+
45
+ </td><td>
46
+
47
+ _(Optional)_ Options to specify disposal behavior.
48
+
49
+
50
+ </td></tr>
51
+ </tbody></table>
52
+ **Returns:**
53
+
54
+ void
55
+
@@ -0,0 +1,43 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [FlowDisposable](./picoflow.flowdisposable.md)
4
+
5
+ ## FlowDisposable interface
6
+
7
+ Represents an object with a disposable lifecycle.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export interface FlowDisposable
13
+ ```
14
+
15
+ ## Remarks
16
+
17
+ Objects implementing this interface require explicit resource disposal.
18
+
19
+ ## Methods
20
+
21
+ <table><thead><tr><th>
22
+
23
+ Method
24
+
25
+
26
+ </th><th>
27
+
28
+ Description
29
+
30
+
31
+ </th></tr></thead>
32
+ <tbody><tr><td>
33
+
34
+ [dispose(options)](./picoflow.flowdisposable.dispose.md)
35
+
36
+
37
+ </td><td>
38
+
39
+ Disposes resources held by this object.
40
+
41
+
42
+ </td></tr>
43
+ </tbody></table>
@@ -9,8 +9,46 @@ Disposes the FlowSignal. Cleans up all registered effects, listeners, and depend
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- dispose(): void;
12
+ dispose(options?: {
13
+ self: boolean;
14
+ }): void;
13
15
  ```
16
+
17
+ ## Parameters
18
+
19
+ <table><thead><tr><th>
20
+
21
+ Parameter
22
+
23
+
24
+ </th><th>
25
+
26
+ Type
27
+
28
+
29
+ </th><th>
30
+
31
+ Description
32
+
33
+
34
+ </th></tr></thead>
35
+ <tbody><tr><td>
36
+
37
+ options
38
+
39
+
40
+ </td><td>
41
+
42
+ { self: boolean; }
43
+
44
+
45
+ </td><td>
46
+
47
+ _(Optional)_
48
+
49
+
50
+ </td></tr>
51
+ </tbody></table>
14
52
  **Returns:**
15
53
 
16
54
  void
@@ -9,8 +9,9 @@ Represents a reactive signal.
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export declare class FlowSignal
12
+ export declare class FlowSignal implements FlowDisposable
13
13
  ```
14
+ **Implements:** [FlowDisposable](./picoflow.flowdisposable.md)
14
15
 
15
16
  ## Remarks
16
17
 
@@ -82,7 +83,7 @@ Description
82
83
  </th></tr></thead>
83
84
  <tbody><tr><td>
84
85
 
85
- [dispose()](./picoflow.flowsignal.dispose.md)
86
+ [dispose(options)](./picoflow.flowsignal.dispose.md)
86
87
 
87
88
 
88
89
  </td><td>
@@ -0,0 +1,55 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@ersbeth/picoflow](./picoflow.md) &gt; [isDisposable](./picoflow.isdisposable.md)
4
+
5
+ ## isDisposable() function
6
+
7
+ Checks whether an object implements the FlowDisposable interface.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare function isDisposable(obj: unknown): obj is FlowDisposable;
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
+ obj
36
+
37
+
38
+ </td><td>
39
+
40
+ unknown
41
+
42
+
43
+ </td><td>
44
+
45
+ The object to test.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+ **Returns:**
51
+
52
+ obj is [FlowDisposable](./picoflow.flowdisposable.md)
53
+
54
+ True if the object has a dispose method, otherwise false.
55
+
@@ -21,6 +21,17 @@ Description
21
21
  </th></tr></thead>
22
22
  <tbody><tr><td>
23
23
 
24
+ [FlowArray](./picoflow.flowarray.md)
25
+
26
+
27
+ </td><td>
28
+
29
+ Represents a reactive array.
30
+
31
+
32
+ </td></tr>
33
+ <tr><td>
34
+
24
35
  [FlowConstant](./picoflow.flowconstant.md)
25
36
 
26
37
 
@@ -172,6 +183,17 @@ Description
172
183
  </th></tr></thead>
173
184
  <tbody><tr><td>
174
185
 
186
+ [array(initial)](./picoflow.array.md)
187
+
188
+
189
+ </td><td>
190
+
191
+ Creates a new reactive array.
192
+
193
+
194
+ </td></tr>
195
+ <tr><td>
196
+
175
197
  [constant(value)](./picoflow.constant.md)
176
198
 
177
199
 
@@ -202,6 +224,17 @@ Creates a new reactive derivation whose value is computed based on other reactiv
202
224
  Creates a new reactive effect that executes a side-effect function based on its dependencies.
203
225
 
204
226
 
227
+ </td></tr>
228
+ <tr><td>
229
+
230
+ [isDisposable(obj)](./picoflow.isdisposable.md)
231
+
232
+
233
+ </td><td>
234
+
235
+ Checks whether an object implements the FlowDisposable interface.
236
+
237
+
205
238
  </td></tr>
206
239
  <tr><td>
207
240
 
@@ -279,6 +312,32 @@ Creates a new reactive stream.
279
312
  Creates a new reactive asynchronous stream.
280
313
 
281
314
 
315
+ </td></tr>
316
+ </tbody></table>
317
+
318
+ ## Interfaces
319
+
320
+ <table><thead><tr><th>
321
+
322
+ Interface
323
+
324
+
325
+ </th><th>
326
+
327
+ Description
328
+
329
+
330
+ </th></tr></thead>
331
+ <tbody><tr><td>
332
+
333
+ [FlowDisposable](./picoflow.flowdisposable.md)
334
+
335
+
336
+ </td><td>
337
+
338
+ Represents an object with a disposable lifecycle.
339
+
340
+
282
341
  </td></tr>
283
342
  </tbody></table>
284
343
 
@@ -297,6 +356,17 @@ Description
297
356
  </th></tr></thead>
298
357
  <tbody><tr><td>
299
358
 
359
+ [FlowArrayAction](./picoflow.flowarrayaction.md)
360
+
361
+
362
+ </td><td>
363
+
364
+ Represents the actions that can be performed on a FlowArray.
365
+
366
+
367
+ </td></tr>
368
+ <tr><td>
369
+
300
370
  [FlowGetter](./picoflow.flowgetter.md)
301
371
 
302
372
 
@@ -4,6 +4,9 @@
4
4
 
5
5
  ```ts
6
6
 
7
+ // @public
8
+ export function array<T>(initial?: T[]): FlowArray<T>;
9
+
7
10
  // @public
8
11
  export function constant<T>(value: T | (() => T)): FlowConstant<T>;
9
12
 
@@ -13,6 +16,52 @@ export function derivation<T>(fn: (get: FlowGetter, watch: FlowWatcher) => T): F
13
16
  // @public
14
17
  export function effect(fn: (get: FlowGetter, watch: FlowWatcher) => void): FlowEffect;
15
18
 
19
+ // @public
20
+ export class FlowArray<T> extends FlowObservable<T[]> {
21
+ $lastAction: FlowState<FlowArrayAction<T>>;
22
+ constructor(value?: T[]);
23
+ clear(): void;
24
+ dispose(options?: {
25
+ self: boolean;
26
+ }): void;
27
+ get(): T[];
28
+ get length(): number;
29
+ pop(): void;
30
+ push(item: T): void;
31
+ set(items: T[]): void;
32
+ setItem(index: number, item: T): void;
33
+ shift(): void;
34
+ splice(start: number, deleteCount: number, ...newItems: T[]): void;
35
+ unshift(item: T): void;
36
+ }
37
+
38
+ // @public
39
+ export type FlowArrayAction<T> = {
40
+ type: "set";
41
+ items: T[];
42
+ } | {
43
+ type: "setItem";
44
+ index: number;
45
+ item: T;
46
+ } | {
47
+ type: "push";
48
+ item: T;
49
+ } | {
50
+ type: "pop";
51
+ } | {
52
+ type: "unshift";
53
+ item: T;
54
+ } | {
55
+ type: "shift";
56
+ } | {
57
+ type: "splice";
58
+ start: number;
59
+ deleteCount: number;
60
+ items: T[];
61
+ } | {
62
+ type: "clear";
63
+ };
64
+
16
65
  // @public
17
66
  export class FlowConstant<T> extends FlowObservable<T> {
18
67
  constructor(value: T | (() => T));
@@ -25,6 +74,13 @@ export class FlowDerivation<T> extends FlowObservable<T> {
25
74
  get(): T;
26
75
  }
27
76
 
77
+ // @public
78
+ export interface FlowDisposable {
79
+ dispose(options?: {
80
+ self: boolean;
81
+ }): void;
82
+ }
83
+
28
84
  // @public
29
85
  export class FlowEffect {
30
86
  constructor(apply: (get: FlowGetter, watch: FlowWatcher) => void);
@@ -70,8 +126,10 @@ export class FlowResourceAsync<T> extends FlowObservable<Promise<T>> {
70
126
  }
71
127
 
72
128
  // @public
73
- export class FlowSignal {
74
- dispose(): void;
129
+ export class FlowSignal implements FlowDisposable {
130
+ dispose(options?: {
131
+ self: boolean;
132
+ }): void;
75
133
  get disposed(): boolean;
76
134
  trigger(): void;
77
135
  }
@@ -107,6 +165,9 @@ export type FlowStreamUpdater<T> = (set: FlowStreamSetter<T>) => FlowStreamDispo
107
165
  // @public
108
166
  export type FlowWatcher = (signal: FlowSignal) => void;
109
167
 
168
+ // @public
169
+ export function isDisposable(obj: unknown): obj is FlowDisposable;
170
+
110
171
  // @public
111
172
  export function map<K extends string | number | symbol, V>(initial?: Record<K, V>): FlowMap<K, V>;
112
173