@ersbeth/picoflow 0.0.1 → 0.1.0

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 (143) hide show
  1. package/api/doc/index.md +1 -1
  2. package/api/doc/picoflow.constant.md +55 -0
  3. package/api/doc/picoflow.derivation.md +1 -1
  4. package/api/doc/picoflow.effect.md +1 -1
  5. package/api/doc/picoflow.flowconstant._constructor_.md +49 -0
  6. package/api/doc/picoflow.flowconstant.get.md +25 -0
  7. package/api/doc/picoflow.flowconstant.md +88 -0
  8. package/api/doc/picoflow.flowderivation._constructor_.md +2 -2
  9. package/api/doc/picoflow.flowderivation.get.md +2 -2
  10. package/api/doc/picoflow.flowderivation.md +2 -2
  11. package/api/doc/picoflow.floweffect._constructor_.md +7 -2
  12. package/api/doc/picoflow.floweffect.dispose.md +3 -3
  13. package/api/doc/picoflow.floweffect.disposed.md +1 -1
  14. package/api/doc/picoflow.floweffect.md +4 -4
  15. package/api/doc/picoflow.flowgetter.md +2 -2
  16. package/api/doc/picoflow.flowmap._lastdeleted.md +1 -1
  17. package/api/doc/picoflow.flowmap._lastset.md +1 -1
  18. package/api/doc/picoflow.flowmap.delete.md +6 -2
  19. package/api/doc/picoflow.flowmap.md +5 -7
  20. package/api/doc/picoflow.flowmap.setat.md +6 -2
  21. package/api/doc/picoflow.flowobservable.get.md +3 -3
  22. package/api/doc/picoflow.flowobservable.md +18 -4
  23. package/api/doc/picoflow.flowobservable.subscribe.md +55 -0
  24. package/api/doc/picoflow.flowresource._constructor_.md +2 -18
  25. package/api/doc/picoflow.flowresource.fetch.md +1 -1
  26. package/api/doc/picoflow.flowresource.get.md +4 -4
  27. package/api/doc/picoflow.flowresource.md +4 -4
  28. package/api/doc/picoflow.flowresourceasync._constructor_.md +49 -0
  29. package/api/doc/picoflow.flowresourceasync.fetch.md +27 -0
  30. package/api/doc/picoflow.flowresourceasync.get.md +23 -0
  31. package/api/doc/picoflow.flowresourceasync.md +100 -0
  32. package/api/doc/picoflow.flowsignal.dispose.md +3 -7
  33. package/api/doc/picoflow.flowsignal.disposed.md +2 -2
  34. package/api/doc/picoflow.flowsignal.md +5 -5
  35. package/api/doc/picoflow.flowsignal.trigger.md +3 -7
  36. package/api/doc/picoflow.flowstate.md +4 -52
  37. package/api/doc/picoflow.flowstate.set.md +5 -5
  38. package/api/doc/picoflow.flowstream._constructor_.md +3 -19
  39. package/api/doc/picoflow.flowstream.dispose.md +1 -1
  40. package/api/doc/picoflow.flowstream.get.md +4 -4
  41. package/api/doc/picoflow.flowstream.md +5 -5
  42. package/api/doc/picoflow.flowstreamasync._constructor_.md +54 -0
  43. package/api/doc/picoflow.flowstreamasync.dispose.md +21 -0
  44. package/api/doc/picoflow.flowstreamasync.get.md +23 -0
  45. package/api/doc/picoflow.flowstreamasync.md +100 -0
  46. package/api/doc/picoflow.flowstreamdisposer.md +13 -0
  47. package/api/doc/picoflow.flowstreamsetter.md +13 -0
  48. package/api/doc/picoflow.flowstreamupdater.md +19 -0
  49. package/api/doc/picoflow.flowwatcher.md +1 -1
  50. package/api/doc/picoflow.map.md +1 -1
  51. package/api/doc/picoflow.md +80 -14
  52. package/api/doc/picoflow.resource.md +2 -18
  53. package/api/doc/picoflow.resourceasync.md +55 -0
  54. package/api/doc/picoflow.signal.md +1 -1
  55. package/api/doc/picoflow.state.md +3 -3
  56. package/api/doc/picoflow.stream.md +2 -18
  57. package/api/doc/picoflow.streamasync.md +55 -0
  58. package/api/picoflow.public.api.md +131 -0
  59. package/api-extractor.json +2 -1
  60. package/dist/picoflow.js +326 -302
  61. package/dist/types/advanced/index.d.ts +7 -0
  62. package/dist/types/advanced/index.d.ts.map +1 -0
  63. package/dist/types/{map.d.ts → advanced/map.d.ts} +12 -12
  64. package/dist/types/advanced/map.d.ts.map +1 -0
  65. package/dist/types/advanced/resource.d.ts +39 -0
  66. package/dist/types/advanced/resource.d.ts.map +1 -0
  67. package/dist/types/{resource.d.ts → advanced/resourceAsync.d.ts} +6 -11
  68. package/dist/types/advanced/resourceAsync.d.ts.map +1 -0
  69. package/dist/types/advanced/stream.d.ts +59 -0
  70. package/dist/types/advanced/stream.d.ts.map +1 -0
  71. package/dist/types/advanced/streamAsync.d.ts +43 -0
  72. package/dist/types/advanced/streamAsync.d.ts.map +1 -0
  73. package/dist/types/basic/constant.d.ts +32 -0
  74. package/dist/types/basic/constant.d.ts.map +1 -0
  75. package/dist/types/basic/derivation.d.ts +40 -0
  76. package/dist/types/basic/derivation.d.ts.map +1 -0
  77. package/dist/types/basic/effect.d.ts +56 -0
  78. package/dist/types/basic/effect.d.ts.map +1 -0
  79. package/dist/types/basic/index.d.ts +9 -0
  80. package/dist/types/basic/index.d.ts.map +1 -0
  81. package/dist/types/basic/observable.d.ts +34 -0
  82. package/dist/types/basic/observable.d.ts.map +1 -0
  83. package/dist/types/basic/signal.d.ts +37 -0
  84. package/dist/types/basic/signal.d.ts.map +1 -0
  85. package/dist/types/basic/state.d.ts +26 -0
  86. package/dist/types/basic/state.d.ts.map +1 -0
  87. package/dist/types/creators.d.ts +29 -13
  88. package/dist/types/creators.d.ts.map +1 -1
  89. package/dist/types/index.d.ts +3 -9
  90. package/dist/types/index.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/src/advanced/index.ts +10 -0
  93. package/src/{map.ts → advanced/map.ts} +14 -14
  94. package/src/advanced/resource.ts +56 -0
  95. package/src/{resource.ts → advanced/resourceAsync.ts} +9 -16
  96. package/src/advanced/stream.ts +87 -0
  97. package/src/advanced/streamAsync.ts +82 -0
  98. package/src/basic/constant.ts +64 -0
  99. package/src/basic/derivation.ts +86 -0
  100. package/src/basic/effect.ts +96 -0
  101. package/src/basic/index.ts +8 -0
  102. package/src/basic/observable.ts +51 -0
  103. package/src/basic/signal.ts +105 -0
  104. package/src/basic/state.ts +39 -0
  105. package/src/creators.ts +54 -15
  106. package/src/index.ts +21 -11
  107. package/test/constant.test.ts +46 -0
  108. package/test/derivation.test.ts +30 -6
  109. package/test/effect.test.ts +29 -0
  110. package/test/map.test.ts +38 -0
  111. package/test/resource.test.ts +18 -16
  112. package/test/resourceAsync.test.ts +108 -0
  113. package/test/signal.test.ts +18 -1
  114. package/test/state.test.ts +107 -2
  115. package/test/stream.test.ts +38 -13
  116. package/test/streamAsync.test.ts +194 -0
  117. package/tsconfig.json +3 -1
  118. package/api/doc/picoflow.flowdisposer.md +0 -13
  119. package/api/doc/picoflow.flowsetter.md +0 -13
  120. package/api/doc/picoflow.flowstate._constructor_.md +0 -49
  121. package/api/doc/picoflow.flowstate.get.md +0 -23
  122. package/api/doc/picoflow.flowupdater.md +0 -19
  123. package/api/picoflow.api.md +0 -145
  124. package/dist/types/derivation.d.ts +0 -58
  125. package/dist/types/derivation.d.ts.map +0 -1
  126. package/dist/types/effect.d.ts +0 -108
  127. package/dist/types/effect.d.ts.map +0 -1
  128. package/dist/types/map.d.ts.map +0 -1
  129. package/dist/types/observable.d.ts +0 -40
  130. package/dist/types/observable.d.ts.map +0 -1
  131. package/dist/types/resource.d.ts.map +0 -1
  132. package/dist/types/signal.d.ts +0 -111
  133. package/dist/types/signal.d.ts.map +0 -1
  134. package/dist/types/state.d.ts +0 -39
  135. package/dist/types/state.d.ts.map +0 -1
  136. package/dist/types/stream.d.ts +0 -71
  137. package/dist/types/stream.d.ts.map +0 -1
  138. package/src/derivation.ts +0 -96
  139. package/src/effect.ts +0 -152
  140. package/src/observable.ts +0 -50
  141. package/src/signal.ts +0 -166
  142. package/src/state.ts +0 -52
  143. package/src/stream.ts +0 -99
@@ -1,23 +0,0 @@
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
-
@@ -1,19 +0,0 @@
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
-
@@ -1,145 +0,0 @@
1
- ## API Report File for "picoflow"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- // @public
8
- export function derivation<T>(fn: (get: FlowGetter, watch: FlowWatcher) => T): FlowDerivation<T>;
9
-
10
- // @public
11
- export function effect(fn: (get: FlowGetter, watch: FlowWatcher) => void): FlowEffect;
12
-
13
- // @public
14
- export class FlowDerivation<T> extends FlowObservable<T> {
15
- constructor(compute: (get: FlowGetter, watch: FlowWatcher) => T);
16
- // @internal
17
- _exec(): void;
18
- get(): T;
19
- // @internal
20
- _notify(): void;
21
- // @internal
22
- _watch(): void;
23
- }
24
-
25
- // @public
26
- export type FlowDisposer = () => void;
27
-
28
- // @public
29
- export class FlowEffect {
30
- constructor(apply: (get: FlowGetter, watch: FlowWatcher) => void);
31
- dispose(): void;
32
- get disposed(): boolean;
33
- // @internal
34
- _exec(): void;
35
- // @internal
36
- _registerDependency(dependency: FlowSignal): void;
37
- // @internal
38
- _unregisterDependency(dependency: FlowSignal): void;
39
- }
40
-
41
- // @public
42
- export type FlowGetter = <T>(observable: FlowObservable<T>) => T;
43
-
44
- // @public
45
- export class FlowMap<K, V> extends FlowState<Map<K, V>> {
46
- $lastDeleted: FlowState<{
47
- key?: K;
48
- value?: V;
49
- }>;
50
- $lastSet: FlowState<{
51
- key?: K;
52
- value?: V;
53
- }>;
54
- delete(key: K): void;
55
- setAt(key: K, value: V): void;
56
- }
57
-
58
- // @public
59
- export abstract class FlowObservable<T> extends FlowSignal {
60
- abstract get(): T;
61
- // @internal
62
- _getFrom(listener: FlowObservable<unknown> | FlowEffect): T;
63
- // @internal
64
- protected _value: T;
65
- }
66
-
67
- // @public
68
- export class FlowResource<T> extends FlowObservable<T> {
69
- constructor(fetch: () => Promise<T>, initial: T);
70
- fetch(): Promise<void>;
71
- get(): T;
72
- }
73
-
74
- // @public
75
- export type FlowSetter<T> = (value: T) => void;
76
-
77
- // @public
78
- export class FlowSignal {
79
- // @internal (undocumented)
80
- protected _dependencies: Set<FlowSignal>;
81
- dispose(): void;
82
- get disposed(): boolean;
83
- // @internal (undocumented)
84
- protected _disposed: boolean;
85
- // @internal (undocumented)
86
- protected _effects: Set<FlowEffect>;
87
- // @internal (undocumented)
88
- protected _listeners: Set<FlowSignal>;
89
- // @internal
90
- _notify(): void;
91
- // @internal
92
- _registerDependency(dependency: FlowSignal): void;
93
- // @internal
94
- _registerEffect(effect: FlowEffect): void;
95
- // @internal
96
- _registerListener(signal: FlowSignal): void;
97
- trigger(): void;
98
- // @internal
99
- _unregisterDependency(dependency: FlowSignal): void;
100
- // @internal
101
- _unregisterEffect(effect: FlowEffect): void;
102
- // @internal
103
- _unregisterListener(signal: FlowSignal): void;
104
- // @internal
105
- _watch(): void;
106
- // @internal
107
- _watchFrom(listener: FlowSignal | FlowEffect): void;
108
- }
109
-
110
- // @public
111
- export class FlowState<T> extends FlowObservable<T> {
112
- constructor(value: T);
113
- get(): T;
114
- set(value: T): void;
115
- }
116
-
117
- // @public
118
- export class FlowStream<T> extends FlowObservable<T> {
119
- constructor(updater: FlowUpdater<T>, initial: T);
120
- dispose(): void;
121
- get(): T;
122
- }
123
-
124
- // @public
125
- export type FlowUpdater<T> = (set: FlowSetter<T>) => FlowDisposer;
126
-
127
- // @public
128
- export type FlowWatcher = (signal: FlowSignal) => void;
129
-
130
- // @public
131
- export function map<K extends string | number | symbol, V>(initial?: Record<K, V>): FlowMap<K, V>;
132
-
133
- // @public
134
- export function resource<T>(fn: () => Promise<T>, initial: T): FlowResource<T>;
135
-
136
- // @public
137
- export function signal(): FlowSignal;
138
-
139
- // @public
140
- export function state<T>(value: T): FlowState<T>;
141
-
142
- // @public
143
- export function stream<T>(updater: (set: (value: T) => void) => () => void, initial: T): FlowStream<T>;
144
-
145
- ```
@@ -1,58 +0,0 @@
1
- import { FlowGetter, FlowObservable } from './observable';
2
- import { FlowWatcher } from './signal';
3
- /**
4
- * Represents a reactive derivation whose value is computed based on other reactive signals.
5
- * @remarks
6
- * A FlowDerivation automatically tracks its dependencies and recomputes its value when needed.
7
- * @typeparam T - The type of the computed value.
8
- * @public
9
- */
10
- export declare class FlowDerivation<T> extends FlowObservable<T> {
11
- /**
12
- * Creates a new FlowDerivation.
13
- * @param compute - A function that computes the derived value. It is provided with a getter
14
- * and a watcher function to access observables and signals dependencies.
15
- * @public
16
- */
17
- constructor(compute: (get: FlowGetter, watch: FlowWatcher) => T);
18
- /**
19
- * Gets the current derived value.
20
- * @returns The current computed value.
21
- * @remarks
22
- * This method ensures that the derivation is up-to-date before returning the value.
23
- * @public
24
- */
25
- get(): T;
26
- /** @internal */
27
- private _initialized;
28
- /** @internal */
29
- private _dirty;
30
- /** @internal */
31
- private _trackedGet;
32
- /** @internal */
33
- private _trackedWatch;
34
- /** @internal */
35
- private _untrackedGet;
36
- /** @internal */
37
- private _untrackedWatch;
38
- /** @internal */
39
- private _trackedExec;
40
- /** @internal */
41
- private _untrackedExec;
42
- /**
43
- * @internal
44
- * Executes the compute function if necessary to update the derived value.
45
- */
46
- _exec(): void;
47
- /**
48
- * @internal
49
- * Marks the derivation as dirty and notifies downstream dependencies.
50
- */
51
- _notify(): void;
52
- /**
53
- * @internal
54
- * Ensures that the derivation is up-to-date when it is watched.
55
- */
56
- _watch(): void;
57
- }
58
- //# sourceMappingURL=derivation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"derivation.d.ts","sourceRoot":"","sources":["../../src/derivation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;GAMG;AACH,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAEpD;;;;;OAKG;gBACS,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,KAAK,CAAC;IAM/D;;;;;;OAMG;IACI,GAAG,IAAI,CAAC;IAOf,gBAAgB;IAChB,OAAO,CAAC,YAAY,CAAS;IAE7B,gBAAgB;IAChB,OAAO,CAAC,MAAM,CAAQ;IAEtB,gBAAgB;IAChB,OAAO,CAAC,WAAW,CAAyD;IAE5E,gBAAgB;IAChB,OAAO,CAAC,aAAa,CAAoD;IAEzE,gBAAgB;IAChB,OAAO,CAAC,aAAa,CAAgD;IAErE,gBAAgB;IAChB,OAAO,CAAC,eAAe,CAA4C;IAEnE,gBAAgB;IAChB,OAAO,CAAC,YAAY,CAAU;IAE9B,gBAAgB;IAChB,OAAO,CAAC,cAAc,CAAU;IAEhC;;;OAGG;IACH,KAAK,IAAI,IAAI;IAab;;;OAGG;IACM,OAAO,IAAI,IAAI;IAKxB;;;OAGG;IACM,MAAM,IAAI,IAAI;CAG1B"}
@@ -1,108 +0,0 @@
1
- import { FlowGetter } from './observable';
2
- import { FlowSignal, FlowWatcher } from './signal';
3
- /**
4
- * Represents a reactive effect that executes a side‐effect function
5
- * based on its tracked dependencies.
6
- *
7
- * @remarks
8
- * A FlowEffect runs an apply function to perform side effects. The apply function
9
- * is executed in two modes:
10
- * Initially, in a tracked mode to register dependencies.
11
- * Subsequently, in an untracked mode to only re-execute the effect .
12
- *
13
- * @public
14
- */
15
- export declare class FlowEffect {
16
- /**
17
- * Creates a new FlowEffect.
18
- *
19
- * @param apply - A function that performs the side effect. It receives a getter and a watcher
20
- * function to access and register dependencies on reactive observables and signals.
21
- *
22
- * @public
23
- */
24
- constructor(apply: (get: FlowGetter, watch: FlowWatcher) => void);
25
- /**
26
- * Disposes the effect, unregistering all its dependencies.
27
- *
28
- * @remarks
29
- * After disposal, the effect should no longer be used. Calling this method on an already
30
- * disposed effect will throw an error.
31
- *
32
- * @public
33
- */
34
- dispose(): void;
35
- /**
36
- * Indicates whether this effect has been disposed.
37
- *
38
- * @returns A boolean value indicating if the effect is disposed.
39
- *
40
- * @public
41
- */
42
- get disposed(): boolean;
43
- /**
44
- * @internal
45
- */
46
- private _disposed;
47
- /**
48
- * @internal
49
- */
50
- private _initialized;
51
- /**
52
- * @internal
53
- */
54
- private _dependencies;
55
- /**
56
- * @internal
57
- * A tracked getter that registers a dependency when accessing an observable.
58
- */
59
- private _trackedGet;
60
- /**
61
- * @internal
62
- * A tracked watcher that registers a dependency when watching a signal.
63
- */
64
- private _trackedWatch;
65
- /**
66
- * @internal
67
- * An untracked getter that simply retrieves the current value from an observable.
68
- */
69
- private _untrackedGet;
70
- /**
71
- * @internal
72
- * An untracked watcher that calls the default watch on a signal.
73
- */
74
- private _untrackedWatch;
75
- /**
76
- * @internal
77
- * Execution function used during initialization (tracked mode).
78
- */
79
- private _trackedExec;
80
- /**
81
- * @internal
82
- * Execution function used after initialization (untracked mode).
83
- */
84
- private _untrackedExec;
85
- /**
86
- * @internal
87
- * Executes the effect. If the effect has not been initialized, it runs in tracked mode;
88
- * otherwise, it runs in untracked mode.
89
- *
90
- * @throws Error if the effect has been disposed.
91
- */
92
- _exec(): void;
93
- /**
94
- * @internal
95
- * Registers a dependency on the given signal.
96
- *
97
- * @param dependency - The FlowSignal to register as a dependency.
98
- */
99
- _registerDependency(dependency: FlowSignal): void;
100
- /**
101
- * @internal
102
- * Unregisters the given dependency.
103
- *
104
- * @param dependency - The FlowSignal to unregister.
105
- */
106
- _unregisterDependency(dependency: FlowSignal): void;
107
- }
108
- //# sourceMappingURL=effect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,qBAAa,UAAU;IAGnB;;;;;;;OAOG;gBACS,KAAK,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI;IAMhE;;;;;;;;OAQG;IACI,OAAO,IAAI,IAAI;IAQtB;;;;;;OAMG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAID;;OAEG;IACH,OAAO,CAAC,SAAS,CAAS;IAE1B;;OAEG;IACH,OAAO,CAAC,YAAY,CAAS;IAE7B;;OAEG;IACH,OAAO,CAAC,aAAa,CAAyB;IAE9C;;;OAGG;IACH,OAAO,CAAC,WAAW,CAAyD;IAE5E;;;OAGG;IACH,OAAO,CAAC,aAAa,CAAoD;IAEzE;;;OAGG;IACH,OAAO,CAAC,aAAa,CAAgD;IAErE;;;OAGG;IACH,OAAO,CAAC,eAAe,CAA4C;IAEnE;;;OAGG;IACH,OAAO,CAAC,YAAY,CAAa;IAEjC;;;OAGG;IACH,OAAO,CAAC,cAAc,CAAa;IAEnC;;;;;;OAMG;IACH,KAAK,IAAI,IAAI;IASb;;;;;OAKG;IACH,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAKjD;;;;;OAKG;IACH,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;CAItD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,OAAO,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEnD;;;;;;;;OAQG;IACI,QAAQ,EAAE,SAAS,CAAC;QAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC,CAAqB;IAEvE;;;;;;;;OAQG;IACI,YAAY,EAAE,SAAS,CAAC;QAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC,CAAqB;IAE3E;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAOpC;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI;CAO9B"}
@@ -1,40 +0,0 @@
1
- import { FlowEffect } from './effect';
2
- import { FlowSignal } from './signal';
3
- /**
4
- * A function for retrieving the current value from a FlowObservable.
5
- * @typeparam T - The type of the value held by the observable.
6
- * @param atom - The FlowObservable from which to get the value.
7
- * @returns The current value of the observable.
8
- * @public
9
- */
10
- export type FlowGetter = <T>(observable: FlowObservable<T>) => T;
11
- /**
12
- * Represents a reactive observable that carries a value.
13
- * @typeparam T - The type of the value held by the observable.
14
- * @remarks
15
- * A FlowObservable extends the basic FlowSignal to store a value. Subclasses must
16
- * implement the abstract {@link FlowObservable.get} method to return the current value.
17
- * @public
18
- */
19
- export declare abstract class FlowObservable<T> extends FlowSignal {
20
- /**
21
- * Retrieves the current value of the observable.
22
- * @returns The current value.
23
- * @public
24
- */
25
- abstract get(): T;
26
- /**
27
- * @internal
28
- * Internal storage for the observable's value.
29
- */
30
- protected _value: T;
31
- /**
32
- * @internal
33
- * Retrieves the current value from the observable and registers a dependency
34
- * from the provided listener.
35
- * @param listener - The FlowObservable or FlowEffect that is accessing this observable.
36
- * @returns The current value, as returned by {@link FlowObservable.get}.
37
- */
38
- _getFrom(listener: FlowObservable<unknown> | FlowEffect): T;
39
- }
40
- //# sourceMappingURL=observable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../../src/observable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAEjE;;;;;;;GAOG;AACH,8BAAsB,cAAc,CAAC,CAAC,CAAE,SAAQ,UAAU;IAGtD;;;;OAIG;IACH,QAAQ,CAAC,GAAG,IAAI,CAAC;IAIjB;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAG,CAAC,CAAC;IAErB;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,UAAU,GAAG,CAAC;CAI9D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,qBAAa,YAAY,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAElD;;;;;OAKG;gBACS,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;IAM/C;;;;;OAKG;IACI,GAAG,IAAI,CAAC;IAKf;;;;;;;;OAQG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAUnC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAmB;CACpC"}
@@ -1,111 +0,0 @@
1
- import { FlowEffect } from './effect';
2
- /**
3
- * A function for watching a FlowSignal.
4
- * @param signal - The FlowSignal that is being observed.
5
- * @public
6
- */
7
- export type FlowWatcher = (signal: FlowSignal) => void;
8
- /**
9
- * Represents a reactive signal.
10
- * @remarks
11
- * A FlowSignal allows you to trigger notifications via {@link FlowSignal.trigger}
12
- * and to dispose the signal and all its registered dependencies, listeners, and effects via {@link FlowSignal.dispose}.
13
- * @public
14
- */
15
- export declare class FlowSignal {
16
- /**
17
- * Triggers the signal.
18
- * @remarks
19
- * This method notifies all registered listeners and causes associated effects to execute.
20
- * @throws Error if the signal is disposed.
21
- * @public
22
- */
23
- trigger(): void;
24
- /**
25
- * Disposes the signal.
26
- * @remarks
27
- * Disposing a signal will dispose all registered effects and listeners,
28
- * and unregister all dependencies. Once disposed, any further calls to the signal
29
- * will throw an error.
30
- * @throws Error if the signal is already disposed.
31
- * @public
32
- */
33
- dispose(): void;
34
- /**
35
- * Indicates whether the signal has been disposed.
36
- * @remarks
37
- * Once disposed, the signal should not be used.
38
- * @public
39
- */
40
- get disposed(): boolean;
41
- /**
42
- * @internal
43
- */
44
- protected _disposed: boolean;
45
- /**
46
- * @internal
47
- */
48
- protected _dependencies: Set<FlowSignal>;
49
- /**
50
- * @internal
51
- */
52
- protected _listeners: Set<FlowSignal>;
53
- /**
54
- * @internal
55
- */
56
- protected _effects: Set<FlowEffect>;
57
- /**
58
- * @internal
59
- * Internal method to watch the signal.
60
- * @throws Error if the signal is disposed.
61
- */
62
- _watch(): void;
63
- /**
64
- * @internal
65
- * Notifies all listeners and executes all registered effects.
66
- */
67
- _notify(): void;
68
- /**
69
- * @internal
70
- * Registers a dependency from the given listener and watches the signal.
71
- * @param listener - A FlowSignal or FlowEffect that will depend on this signal.
72
- */
73
- _watchFrom(listener: FlowSignal | FlowEffect): void;
74
- /**
75
- * @internal
76
- * Registers a dependency with the given FlowSignal.
77
- * @param dependency - The FlowSignal to register as a dependency.
78
- */
79
- _registerDependency(dependency: FlowSignal): void;
80
- /**
81
- * @internal
82
- * Unregisters the given dependency.
83
- * @param dependency - The FlowSignal to unregister.
84
- */
85
- _unregisterDependency(dependency: FlowSignal): void;
86
- /**
87
- * @internal
88
- * Registers a listener (another FlowSignal) to this signal.
89
- * @param signal - The FlowSignal to register as a listener.
90
- */
91
- _registerListener(signal: FlowSignal): void;
92
- /**
93
- * @internal
94
- * Unregisters the given listener.
95
- * @param signal - The FlowSignal to unregister.
96
- */
97
- _unregisterListener(signal: FlowSignal): void;
98
- /**
99
- * @internal
100
- * Registers a FlowEffect to this signal.
101
- * @param effect - The FlowEffect to register.
102
- */
103
- _registerEffect(effect: FlowEffect): void;
104
- /**
105
- * @internal
106
- * Unregisters the given FlowEffect.
107
- * @param effect - The FlowEffect to unregister.
108
- */
109
- _unregisterEffect(effect: FlowEffect): void;
110
- }
111
- //# sourceMappingURL=signal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/signal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAEvD;;;;;;GAMG;AACH,qBAAa,UAAU;IAGnB;;;;;;OAMG;IACI,OAAO,IAAI,IAAI;IAKtB;;;;;;;;OAQG;IACI,OAAO,IAAI,IAAI;IAUtB;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAID;;OAEG;IACH,SAAS,CAAC,SAAS,UAAS;IAE5B;;OAEG;IACH,SAAS,CAAC,aAAa,kBAAyB;IAEhD;;OAEG;IACH,SAAS,CAAC,UAAU,kBAAyB;IAE7C;;OAEG;IACH,SAAS,CAAC,QAAQ,kBAAyB;IAE3C;;;;OAIG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,OAAO,IAAI,IAAI;IAKf;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IAKnD;;;;OAIG;IACH,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAKjD;;;;OAIG;IACH,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAKnD;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAI3C;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAI7C;;;;OAIG;IACH,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAIzC;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAG9C"}
@@ -1,39 +0,0 @@
1
- import { FlowObservable } from './observable';
2
- /**
3
- * Represents a reactive state that holds a mutable value.
4
- *
5
- * @typeparam T - The type of the state value.
6
- *
7
- * @remarks
8
- * FlowState extends FlowObservable to provide a simple reactive state primitive.
9
- * Use the {@link FlowState.get} method to read the current state and {@link FlowState.set} to update it.
10
- * When the state is updated, subscribers are notified automatically.
11
- *
12
- * @public
13
- */
14
- export declare class FlowState<T> extends FlowObservable<T> {
15
- /**
16
- * Creates a new FlowState with the given initial value.
17
- * @param value - The initial value for the state.
18
- * @public
19
- */
20
- constructor(value: T);
21
- /**
22
- * Retrieves the current state value.
23
- * @returns The current value of the state.
24
- * @throws Error if the state has been disposed.
25
- * @public
26
- */
27
- get(): T;
28
- /**
29
- * Updates the state with a new value.
30
- * @param value - The new value to set.
31
- * @remarks
32
- * If the new value is identical to the current value, no update or notification occurs.
33
- * Otherwise, the state is updated and all subscribers are notified.
34
- * @throws Error if the state has been disposed.
35
- * @public
36
- */
37
- set(value: T): void;
38
- }
39
- //# sourceMappingURL=state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,qBAAa,SAAS,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAE/C;;;;OAIG;gBACS,KAAK,EAAE,CAAC;IAKpB;;;;;OAKG;IACH,GAAG,IAAI,CAAC;IAKR;;;;;;;;OAQG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;CAMtB"}
@@ -1,71 +0,0 @@
1
- import { FlowObservable } from './observable';
2
- /**
3
- * A function that sets a new value.
4
- * @typeparam T - The type of the value.
5
- * @public
6
- */
7
- export type FlowSetter<T> = (value: T) => void;
8
- /**
9
- * A function that disposes of a resource.
10
- * @public
11
- */
12
- export type FlowDisposer = () => void;
13
- /**
14
- * A function that performs updates on a stream.
15
- * @remarks
16
- * The updater receives a setter function that can be used to update the stream's value.
17
- * It should return a disposer function to clean up any resources or subscriptions.
18
- * @typeparam T - The type of the stream value.
19
- * @public
20
- */
21
- export type FlowUpdater<T> = (set: FlowSetter<T>) => FlowDisposer;
22
- /**
23
- * Represents a reactive stream that updates its value based on an updater function.
24
- *
25
- * @remarks
26
- * A FlowStream extends FlowObservable and encapsulates a mechanism for updating its value
27
- * via an external updater function. The updater is invoked during construction with a setter,
28
- * and it returns a disposer to be called when the stream is disposed.
29
- *
30
- * @typeparam T - The type of the stream's value.
31
- *
32
- * @public
33
- */
34
- export declare class FlowStream<T> extends FlowObservable<T> {
35
- /**
36
- * Creates a new FlowStream.
37
- * @param updater - A function that receives a setter to update the stream's value.
38
- * It should return a disposer function that will be called upon disposal.
39
- * @param initial - The initial value of the stream.
40
- * @public
41
- */
42
- constructor(updater: FlowUpdater<T>, initial: T);
43
- /**
44
- * Retrieves the current value of the stream.
45
- * @returns The current value.
46
- * @throws Error if the stream is disposed.
47
- * @public
48
- */
49
- get(): T;
50
- /**
51
- * Disposes the stream, releasing all resources.
52
- * @remarks
53
- * In addition to disposing the underlying observable, this method calls the disposer
54
- * returned by the updater.
55
- * @public
56
- */
57
- dispose(): void;
58
- /**
59
- * @internal
60
- * The disposer function returned by the updater.
61
- */
62
- private _disposer;
63
- /**
64
- * @internal
65
- * Updates the stream's value and notifies subscribers if the value changes.
66
- * @param value - The new value to set.
67
- * @internal
68
- */
69
- private _set;
70
- }
71
- //# sourceMappingURL=stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,qBAAa,UAAU,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAIhD;;;;;;OAMG;gBACS,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;IAQ/C;;;;;OAKG;IACI,GAAG,IAAI,CAAC;IAKf;;;;;;OAMG;IACa,OAAO,IAAI,IAAI;IAO/B;;;OAGG;IACH,OAAO,CAAC,SAAS,CAAe;IAEhC;;;;;OAKG;IACH,OAAO,CAAC,IAAI;CAMf"}