@ersbeth/picoflow 2.1.0 → 2.3.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.
- package/README.md +22 -0
- package/SKILL.md +11 -1
- package/dist/picoflow.js +449 -299
- package/dist/types/api/base/flowConfig.d.ts +17 -0
- package/dist/types/api/base/flowDisposable.d.ts +0 -1
- package/dist/types/api/base/flowErrors.d.ts +1 -0
- package/dist/types/api/base/flowObservable.d.ts +0 -1
- package/dist/types/api/base/flowPrimitiveOptions.d.ts +14 -0
- package/dist/types/api/base/flowSubscribable.d.ts +0 -1
- package/dist/types/api/base/flowTracker.d.ts +0 -1
- package/dist/types/api/base/index.d.ts +3 -1
- package/dist/types/api/index.d.ts +0 -1
- package/dist/types/api/nodes/async/flowConstantAsync.d.ts +4 -3
- package/dist/types/api/nodes/async/flowDerivationAsync.d.ts +3 -3
- package/dist/types/api/nodes/async/flowStateAsync.d.ts +4 -3
- package/dist/types/api/nodes/async/flowWritableDerivationAsync.d.ts +3 -2
- package/dist/types/api/nodes/async/index.d.ts +0 -1
- package/dist/types/api/nodes/collections/flowArray.d.ts +3 -2
- package/dist/types/api/nodes/collections/flowMap.d.ts +3 -2
- package/dist/types/api/nodes/collections/index.d.ts +0 -1
- package/dist/types/api/nodes/flowEffect.d.ts +0 -1
- package/dist/types/api/nodes/flowSignal.d.ts +3 -2
- package/dist/types/api/nodes/flowValue.d.ts +0 -1
- package/dist/types/api/nodes/index.d.ts +0 -1
- package/dist/types/api/nodes/sync/flowConstant.d.ts +3 -2
- package/dist/types/api/nodes/sync/flowDerivation.d.ts +3 -2
- package/dist/types/api/nodes/sync/flowState.d.ts +4 -3
- package/dist/types/api/nodes/sync/flowWritableDerivation.d.ts +3 -2
- package/dist/types/api/nodes/sync/index.d.ts +0 -1
- package/dist/types/api/nodes/utils.d.ts +0 -1
- package/dist/types/base/dependenciesRegistry.d.ts +1 -0
- package/dist/types/base/dependentsRegistry.d.ts +1 -0
- package/dist/types/base/disposable.d.ts +8 -4
- package/dist/types/base/errors.d.ts +31 -0
- package/dist/types/base/executionStack.d.ts +5 -9
- package/dist/types/base/index.d.ts +3 -1
- package/dist/types/base/node.d.ts +4 -4
- package/dist/types/base/observable.d.ts +1 -2
- package/dist/types/base/observer.d.ts +10 -2
- package/dist/types/converters/index.d.ts +0 -1
- package/dist/types/converters/solid.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/nodes/actionNode.d.ts +1 -23
- package/dist/types/nodes/arrayNode.d.ts +1 -26
- package/dist/types/nodes/effectNode.d.ts +1 -32
- package/dist/types/nodes/index.d.ts +0 -1
- package/dist/types/nodes/mapNode.d.ts +1 -20
- package/dist/types/nodes/signalNode.d.ts +1 -10
- package/dist/types/nodes/valueAsyncNode.d.ts +1 -23
- package/dist/types/nodes/valueNode.d.ts +1 -20
- package/dist/types/nodes/valueSyncNode.d.ts +1 -23
- package/dist/types/schedulers/asyncResolver.d.ts +1 -19
- package/dist/types/schedulers/asyncScheduler.d.ts +1 -21
- package/dist/types/schedulers/index.d.ts +0 -1
- package/dist/types/schedulers/pendingError.d.ts +1 -9
- package/dist/types/schedulers/scheduler.d.ts +1 -10
- package/dist/types/schedulers/syncResolver.d.ts +1 -18
- package/dist/types/schedulers/syncScheduler.d.ts +1 -19
- package/package.json +14 -11
- package/dist/types/api/base/flowDisposable.d.ts.map +0 -1
- package/dist/types/api/base/flowObservable.d.ts.map +0 -1
- package/dist/types/api/base/flowSubscribable.d.ts.map +0 -1
- package/dist/types/api/base/flowTracker.d.ts.map +0 -1
- package/dist/types/api/base/index.d.ts.map +0 -1
- package/dist/types/api/index.d.ts.map +0 -1
- package/dist/types/api/nodes/async/flowConstantAsync.d.ts.map +0 -1
- package/dist/types/api/nodes/async/flowDerivationAsync.d.ts.map +0 -1
- package/dist/types/api/nodes/async/flowStateAsync.d.ts.map +0 -1
- package/dist/types/api/nodes/async/flowWritableDerivationAsync.d.ts.map +0 -1
- package/dist/types/api/nodes/async/index.d.ts.map +0 -1
- package/dist/types/api/nodes/collections/flowArray.d.ts.map +0 -1
- package/dist/types/api/nodes/collections/flowMap.d.ts.map +0 -1
- package/dist/types/api/nodes/collections/index.d.ts.map +0 -1
- package/dist/types/api/nodes/flowEffect.d.ts.map +0 -1
- package/dist/types/api/nodes/flowSignal.d.ts.map +0 -1
- package/dist/types/api/nodes/flowValue.d.ts.map +0 -1
- package/dist/types/api/nodes/index.d.ts.map +0 -1
- package/dist/types/api/nodes/sync/flowConstant.d.ts.map +0 -1
- package/dist/types/api/nodes/sync/flowDerivation.d.ts.map +0 -1
- package/dist/types/api/nodes/sync/flowState.d.ts.map +0 -1
- package/dist/types/api/nodes/sync/flowWritableDerivation.d.ts.map +0 -1
- package/dist/types/api/nodes/sync/index.d.ts.map +0 -1
- package/dist/types/api/nodes/utils.d.ts.map +0 -1
- package/dist/types/base/disposable.d.ts.map +0 -1
- package/dist/types/base/executionStack.d.ts.map +0 -1
- package/dist/types/base/index.d.ts.map +0 -1
- package/dist/types/base/node.d.ts.map +0 -1
- package/dist/types/base/observable.d.ts.map +0 -1
- package/dist/types/base/observer.d.ts.map +0 -1
- package/dist/types/converters/index.d.ts.map +0 -1
- package/dist/types/converters/solid.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/nodes/actionNode.d.ts.map +0 -1
- package/dist/types/nodes/arrayNode.d.ts.map +0 -1
- package/dist/types/nodes/effectNode.d.ts.map +0 -1
- package/dist/types/nodes/index.d.ts.map +0 -1
- package/dist/types/nodes/mapNode.d.ts.map +0 -1
- package/dist/types/nodes/signalNode.d.ts.map +0 -1
- package/dist/types/nodes/valueAsyncNode.d.ts.map +0 -1
- package/dist/types/nodes/valueNode.d.ts.map +0 -1
- package/dist/types/nodes/valueSyncNode.d.ts.map +0 -1
- package/dist/types/schedulers/asyncResolver.d.ts.map +0 -1
- package/dist/types/schedulers/asyncScheduler.d.ts.map +0 -1
- package/dist/types/schedulers/index.d.ts.map +0 -1
- package/dist/types/schedulers/pendingError.d.ts.map +0 -1
- package/dist/types/schedulers/scheduler.d.ts.map +0 -1
- package/dist/types/schedulers/syncResolver.d.ts.map +0 -1
- package/dist/types/schedulers/syncScheduler.d.ts.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Installs a global handler for errors that escape the reactive flush.
|
|
3
|
+
*
|
|
4
|
+
* All reactive work — recomputing derivations, running effects — happens inside an
|
|
5
|
+
* asynchronous flush. Without this hook, an error escaping the flush (an effect callback
|
|
6
|
+
* that throws with no `onError`, or a feedback loop between two effects) becomes an
|
|
7
|
+
* uncaught exception, which terminates a Node process. Installing a handler here makes
|
|
8
|
+
* that error catchable instead.
|
|
9
|
+
*
|
|
10
|
+
* Defaults to `console.error`. The handler replaces any previously installed handler —
|
|
11
|
+
* it is not additive.
|
|
12
|
+
*
|
|
13
|
+
* @param handler - Called with the error that escaped the flush.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare function onFlushError(handler: (error: unknown) => void): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PicoFlowCycleError, PicoFlowDisposedError, PicoFlowError, PicoFlowInternalError } from '../../base/errors.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional per-instance settings accepted by the primitive factories (`state`, `derivation`,
|
|
3
|
+
* `array`, `map`, `signal`, …).
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface FlowPrimitiveOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Identifies this primitive in error messages, e.g. `"[PicoFlow] Primitive \"$count\" is disposed"`
|
|
10
|
+
* instead of the unnamed `"[PicoFlow] Primitive is disposed"`. Purely diagnostic — has no effect
|
|
11
|
+
* on reactive behavior.
|
|
12
|
+
*/
|
|
13
|
+
name?: string;
|
|
14
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export * from './flowConfig.js';
|
|
1
2
|
export * from './flowDisposable.js';
|
|
3
|
+
export * from './flowErrors.js';
|
|
2
4
|
export * from './flowObservable.js';
|
|
5
|
+
export * from './flowPrimitiveOptions.js';
|
|
3
6
|
export * from './flowSubscribable.js';
|
|
4
7
|
export * from './flowTracker.js';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { FlowValue } from '../flowValue.js';
|
|
2
3
|
/** Function that initializes a value asynchronously. */
|
|
3
4
|
export type InitFunctionAsync<T> = () => Promise<T>;
|
|
@@ -22,10 +23,10 @@ export interface FlowConstantAsync<T> extends FlowValue<T> {
|
|
|
22
23
|
* reactive values, such as loading configuration or fetching initial data.
|
|
23
24
|
*
|
|
24
25
|
* @param value - Promise to resolve, or async function that returns a promise on first access
|
|
26
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
25
27
|
* @returns A FlowConstantAsync that provides read-only access to the resolved value
|
|
26
28
|
*
|
|
27
29
|
* @public
|
|
28
30
|
*/
|
|
29
|
-
export declare function constantAsync<T>(value: Promise<T
|
|
30
|
-
export declare function constantAsync<T>(initializer: InitFunctionAsync<T
|
|
31
|
-
//# sourceMappingURL=flowConstantAsync.d.ts.map
|
|
31
|
+
export declare function constantAsync<T>(value: Promise<T>, options?: FlowPrimitiveOptions): FlowConstantAsync<T>;
|
|
32
|
+
export declare function constantAsync<T>(initializer: InitFunctionAsync<T>, options?: FlowPrimitiveOptions): FlowConstantAsync<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlowTracker } from '../../base/index.js';
|
|
1
|
+
import { FlowPrimitiveOptions, FlowTracker } from '../../base/index.js';
|
|
2
2
|
import { FlowValue } from '../flowValue.js';
|
|
3
3
|
import { NotPromise } from '../utils.js';
|
|
4
4
|
/** Function that derives a value asynchronously from dependencies and optionally the previous value. */
|
|
@@ -29,9 +29,9 @@ export interface FlowDerivationAsync<T> extends FlowValue<T> {
|
|
|
29
29
|
* retry once resolved. Use for derived data from async sources like filtered API results or computed database queries.
|
|
30
30
|
*
|
|
31
31
|
* @param compute - Async function that accesses dependencies and returns a promise of the derived value
|
|
32
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
32
33
|
* @returns A FlowDerivationAsync that provides read-only access to the resolved computed value
|
|
33
34
|
*
|
|
34
35
|
* @public
|
|
35
36
|
*/
|
|
36
|
-
export declare function derivationAsync<T>(compute: DerivationFunctionAsync<T
|
|
37
|
-
//# sourceMappingURL=flowDerivationAsync.d.ts.map
|
|
37
|
+
export declare function derivationAsync<T>(compute: DerivationFunctionAsync<T>, options?: FlowPrimitiveOptions): FlowDerivationAsync<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { FlowValue } from '../flowValue.js';
|
|
2
3
|
import { NotPromise } from '../utils.js';
|
|
3
4
|
import { InitFunctionAsync } from './flowConstantAsync.js';
|
|
@@ -32,10 +33,10 @@ export interface FlowStateAsync<T> extends FlowValue<T> {
|
|
|
32
33
|
* application logic, such as loading user profiles, fetching search results, or any async state updates.
|
|
33
34
|
*
|
|
34
35
|
* @param value - Initial promise to resolve, or lazy async initializer function
|
|
36
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
35
37
|
* @returns A FlowStateAsync that can be read and modified with promises
|
|
36
38
|
*
|
|
37
39
|
* @public
|
|
38
40
|
*/
|
|
39
|
-
export declare function stateAsync<T>(value: Promise<T
|
|
40
|
-
export declare function stateAsync<T>(initializer: InitFunctionAsync<T
|
|
41
|
-
//# sourceMappingURL=flowStateAsync.d.ts.map
|
|
41
|
+
export declare function stateAsync<T>(value: Promise<T>, options?: FlowPrimitiveOptions): FlowStateAsync<T>;
|
|
42
|
+
export declare function stateAsync<T>(initializer: InitFunctionAsync<T>, options?: FlowPrimitiveOptions): FlowStateAsync<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { DerivationFunctionAsync, FlowDerivationAsync } from './flowDerivationAsync.js';
|
|
2
3
|
import { FlowStateAsync } from './flowStateAsync.js';
|
|
3
4
|
/**
|
|
@@ -22,9 +23,9 @@ export interface FlowWritableDerivationAsync<T> extends FlowStateAsync<T>, FlowD
|
|
|
22
23
|
* such as editable async calculated fields or user-correctable async totals.
|
|
23
24
|
*
|
|
24
25
|
* @param compute - Async function that accesses dependencies and returns a promise of the derived value
|
|
26
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
25
27
|
* @returns A FlowWritableDerivationAsync that provides both reactive async computation and manual control
|
|
26
28
|
*
|
|
27
29
|
* @public
|
|
28
30
|
*/
|
|
29
|
-
export declare function writableDerivationAsync<T>(compute: DerivationFunctionAsync<T
|
|
30
|
-
//# sourceMappingURL=flowWritableDerivationAsync.d.ts.map
|
|
31
|
+
export declare function writableDerivationAsync<T>(compute: DerivationFunctionAsync<T>, options?: FlowPrimitiveOptions): FlowWritableDerivationAsync<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { FlowState } from '../sync/flowState.js';
|
|
2
3
|
/**
|
|
3
4
|
* Discriminated union representing all possible array mutation operations.
|
|
@@ -129,9 +130,9 @@ export interface FlowArray<T> extends FlowState<T[]> {
|
|
|
129
130
|
* needs array-like operations with automatic change propagation.
|
|
130
131
|
*
|
|
131
132
|
* @param initial - Optional initial array of items
|
|
133
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
132
134
|
* @returns A FlowArray with reactive mutation methods
|
|
133
135
|
*
|
|
134
136
|
* @public
|
|
135
137
|
*/
|
|
136
|
-
export declare function array<T>(initial?: T[]): FlowArray<T>;
|
|
137
|
-
//# sourceMappingURL=flowArray.d.ts.map
|
|
138
|
+
export declare function array<T>(initial?: T[], options?: FlowPrimitiveOptions): FlowArray<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { FlowState } from '../sync/flowState.js';
|
|
2
3
|
/**
|
|
3
4
|
* Discriminated union representing all possible map mutation operations.
|
|
@@ -91,9 +92,9 @@ export interface FlowMap<K, V> extends FlowState<Map<K, V>> {
|
|
|
91
92
|
* data that needs reactive updates.
|
|
92
93
|
*
|
|
93
94
|
* @param initial - Optional initial entries as a Record or Map
|
|
95
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
94
96
|
* @returns A FlowMap with reactive mutation methods
|
|
95
97
|
*
|
|
96
98
|
* @public
|
|
97
99
|
*/
|
|
98
|
-
export declare function map<K extends string | number | symbol, V>(initial?: Record<K, V> | Map<K, V
|
|
99
|
-
//# sourceMappingURL=flowMap.d.ts.map
|
|
100
|
+
export declare function map<K extends string | number | symbol, V>(initial?: Record<K, V> | Map<K, V>, options?: FlowPrimitiveOptions): FlowMap<K, V>;
|
|
@@ -26,4 +26,3 @@ export interface FlowEffect extends FlowDisposable {
|
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
28
|
export declare function subscribe<T>(data: FlowDataTracker<T>, onData: FlowOnDataListener<T>, onError?: FlowOnErrorListener, onPending?: FlowOnPendingListener): FlowEffect;
|
|
29
|
-
//# sourceMappingURL=flowEffect.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FlowObservable } from '../base/flowObservable.js';
|
|
2
|
+
import { FlowPrimitiveOptions } from '../base/flowPrimitiveOptions.js';
|
|
2
3
|
/**
|
|
3
4
|
* Manual trigger that notifies subscribers without carrying data.
|
|
4
5
|
*
|
|
@@ -17,9 +18,9 @@ export interface FlowSignal extends FlowObservable<void> {
|
|
|
17
18
|
* and reactive computations that depend on the signal. Unlike state or derivations, signals don't
|
|
18
19
|
* carry data values - they simply represent that an event occurred.
|
|
19
20
|
*
|
|
21
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
20
22
|
* @returns A FlowSignal that can be triggered manually and subscribed to
|
|
21
23
|
*
|
|
22
24
|
* @public
|
|
23
25
|
*/
|
|
24
|
-
export declare function signal(): FlowSignal;
|
|
25
|
-
//# sourceMappingURL=flowSignal.d.ts.map
|
|
26
|
+
export declare function signal(options?: FlowPrimitiveOptions): FlowSignal;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { FlowValue } from '../flowValue.js';
|
|
2
3
|
import { NotPromise } from '../utils.js';
|
|
3
4
|
/** Function that initializes a value. */
|
|
@@ -21,9 +22,9 @@ export interface FlowConstant<T> extends FlowValue<T> {
|
|
|
21
22
|
* in the reactive graph. Useful for expensive one-time computations or static configuration.
|
|
22
23
|
*
|
|
23
24
|
* @param initializer - Function that computes the constant value on first access
|
|
25
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
24
26
|
* @returns A FlowConstant that provides read-only access to the cached value
|
|
25
27
|
*
|
|
26
28
|
* @public
|
|
27
29
|
*/
|
|
28
|
-
export declare function constant<T>(initializer: InitFunction<T
|
|
29
|
-
//# sourceMappingURL=flowConstant.d.ts.map
|
|
30
|
+
export declare function constant<T>(initializer: InitFunction<T>, options?: FlowPrimitiveOptions): FlowConstant<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { FlowTracker } from '../../base/flowTracker.js';
|
|
2
3
|
import { FlowValue } from '../flowValue.js';
|
|
3
4
|
import { NotPromise } from '../utils.js';
|
|
@@ -28,9 +29,9 @@ export interface FlowDerivation<T> extends FlowValue<T> {
|
|
|
28
29
|
* synchronized with source state.
|
|
29
30
|
*
|
|
30
31
|
* @param compute - Function that accesses dependencies and computes the derived value
|
|
32
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
31
33
|
* @returns A FlowDerivation that provides read-only access to the computed value
|
|
32
34
|
*
|
|
33
35
|
* @public
|
|
34
36
|
*/
|
|
35
|
-
export declare function derivation<T>(compute: DerivationFunction<T
|
|
36
|
-
//# sourceMappingURL=flowDerivation.d.ts.map
|
|
37
|
+
export declare function derivation<T>(compute: DerivationFunction<T>, options?: FlowPrimitiveOptions): FlowDerivation<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { FlowValue } from '../flowValue.js';
|
|
2
3
|
import { NotPromise } from '../utils.js';
|
|
3
4
|
import { InitFunction } from './flowConstant.js';
|
|
@@ -30,10 +31,10 @@ export interface FlowState<T> extends FlowValue<T> {
|
|
|
30
31
|
* changes through user actions, external events, or application logic rather than derived computations.
|
|
31
32
|
*
|
|
32
33
|
* @param value - Initial value for the state, or lazy initializer function
|
|
34
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
33
35
|
* @returns A FlowState that can be read and modified
|
|
34
36
|
*
|
|
35
37
|
* @public
|
|
36
38
|
*/
|
|
37
|
-
export declare function state<T>(value: NotPromise<T
|
|
38
|
-
export declare function state<T>(initializer: InitFunction<T
|
|
39
|
-
//# sourceMappingURL=flowState.d.ts.map
|
|
39
|
+
export declare function state<T>(value: NotPromise<T>, options?: FlowPrimitiveOptions): FlowState<T>;
|
|
40
|
+
export declare function state<T>(initializer: InitFunction<T>, options?: FlowPrimitiveOptions): FlowState<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FlowPrimitiveOptions } from '../../base/flowPrimitiveOptions.js';
|
|
1
2
|
import { DerivationFunction, FlowDerivation } from './flowDerivation.js';
|
|
2
3
|
import { FlowState } from './flowState.js';
|
|
3
4
|
/**
|
|
@@ -20,9 +21,9 @@ export interface FlowWritableDerivation<T> extends FlowState<T>, FlowDerivation<
|
|
|
20
21
|
* derived but need occasional manual adjustments, such as editable calculated fields or user-correctable totals.
|
|
21
22
|
*
|
|
22
23
|
* @param compute - Function that accesses dependencies and computes the derived value
|
|
24
|
+
* @param options - Optional settings; `name` identifies this primitive in error messages
|
|
23
25
|
* @returns A FlowWritableDerivation that provides both reactive computation and manual control
|
|
24
26
|
*
|
|
25
27
|
* @public
|
|
26
28
|
*/
|
|
27
|
-
export declare function writableDerivation<T>(compute: DerivationFunction<T
|
|
28
|
-
//# sourceMappingURL=flowWritableDerivation.d.ts.map
|
|
29
|
+
export declare function writableDerivation<T>(compute: DerivationFunction<T>, options?: FlowPrimitiveOptions): FlowWritableDerivation<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { FlowDisposable } from '../api/index.js';
|
|
2
|
+
import { PicoFlowDisposedError } from './errors.js';
|
|
2
3
|
/**
|
|
3
4
|
* Base implementation of the disposable pattern for reactive primitives.
|
|
4
|
-
*
|
|
5
|
+
* Concrete subclasses implement `dispose()` and are expected to throw if disposed multiple times.
|
|
5
6
|
*/
|
|
6
|
-
export declare class Disposable implements FlowDisposable {
|
|
7
|
+
export declare abstract class Disposable implements FlowDisposable {
|
|
7
8
|
protected _disposed: boolean;
|
|
9
|
+
protected readonly _name?: string;
|
|
10
|
+
constructor(name?: string);
|
|
8
11
|
get disposed(): boolean;
|
|
9
|
-
|
|
12
|
+
/** Builds the disposed-primitive error, naming the primitive when a `name` was given at creation. */
|
|
13
|
+
protected _disposedError(): PicoFlowDisposedError;
|
|
14
|
+
abstract dispose(): void;
|
|
10
15
|
}
|
|
11
|
-
//# sourceMappingURL=disposable.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for every typed error picoflow throws, so a consumer can `catch` a picoflow-specific
|
|
3
|
+
* failure with a single `instanceof PicoFlowError` check without matching on message text.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare class PicoFlowError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Thrown when a disposed primitive (or its underlying scheduler) is read, written, or otherwise
|
|
11
|
+
* used after `dispose()`.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class PicoFlowDisposedError extends PicoFlowError {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when the reactive flush detects a feedback loop that exceeds the maximum step guard.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare class PicoFlowCycleError extends PicoFlowError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Thrown when a node reaches a state its own implementation considers unreachable. Reaching this
|
|
26
|
+
* indicates a picoflow bug rather than a misuse of the public API.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare class PicoFlowInternalError extends PicoFlowError {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
@@ -11,20 +11,17 @@ export declare class ExecutionStack {
|
|
|
11
11
|
private static readonly _effectQueue;
|
|
12
12
|
private static _executionScheduled?;
|
|
13
13
|
private static _coalesceResetScheduled;
|
|
14
|
+
/** Per-effect resets accumulated for the microtask scheduled below, so notifying more than one
|
|
15
|
+
* effect in the same sync turn doesn't discard every reset after the first (A2-SEM-5). */
|
|
16
|
+
private static _coalesceResets;
|
|
17
|
+
/** Routes any error escaping the flush loop; defaults to logging rather than crashing (A2-SEM-2, A2-SEC-1). */
|
|
18
|
+
private static _onFlushError;
|
|
14
19
|
/**
|
|
15
20
|
* True once the current synchronous call stack has finished and microtasks have started.
|
|
16
21
|
* EffectNode uses this to treat microtask notifications (e.g. async resolve) differently
|
|
17
22
|
* from coalesced sync-batch notifications.
|
|
18
23
|
*/
|
|
19
24
|
private static _pastSyncTurn;
|
|
20
|
-
/** @internal Used by EffectNode to distinguish sync-batch from microtask notifications. */
|
|
21
|
-
static get pastSyncTurn(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* @internal Runs after the current sync turn ends (queueMicrotask).
|
|
24
|
-
* Marks pastSyncTurn so the next coalesced effect notify can bump its epoch,
|
|
25
|
-
* and resets per-effect coalesce flags via onReset.
|
|
26
|
-
*/
|
|
27
|
-
static scheduleCoalesceReset(onReset: () => void): void;
|
|
28
25
|
static pushPending(node: IObserver): void;
|
|
29
26
|
static pushEffect(effect: IObserver): void;
|
|
30
27
|
private static _beginSyncTurn;
|
|
@@ -32,4 +29,3 @@ export declare class ExecutionStack {
|
|
|
32
29
|
private static _drain;
|
|
33
30
|
private static _execute;
|
|
34
31
|
}
|
|
35
|
-
//# sourceMappingURL=executionStack.d.ts.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from './dependenciesRegistry.js';
|
|
2
|
+
export * from './dependentsRegistry.js';
|
|
1
3
|
export * from './disposable.js';
|
|
4
|
+
export * from './errors.js';
|
|
2
5
|
export * from './executionStack.js';
|
|
3
6
|
export * from './node.js';
|
|
4
7
|
export * from './observable.js';
|
|
5
8
|
export * from './observer.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -6,8 +6,8 @@ import { IObserver } from './observer.js';
|
|
|
6
6
|
* Base implementation for reactive nodes that propagate changes through the dependency graph.
|
|
7
7
|
*/
|
|
8
8
|
export declare abstract class Node<T> extends Disposable implements IObservable<T>, IObserver {
|
|
9
|
-
private
|
|
10
|
-
private
|
|
9
|
+
private _dependenciesRegistry;
|
|
10
|
+
private _dependentsRegistry;
|
|
11
11
|
protected _status: ObservableStatus;
|
|
12
12
|
get status(): ObservableStatus;
|
|
13
13
|
set status(status: ObservableStatus);
|
|
@@ -16,12 +16,12 @@ export declare abstract class Node<T> extends Disposable implements IObservable<
|
|
|
16
16
|
clearDependencies(): void;
|
|
17
17
|
registerDependent(dependent: IObserver): void;
|
|
18
18
|
unregisterDependent(dependent: IObserver): void;
|
|
19
|
+
markDependencyDisposed(): void;
|
|
19
20
|
notifyDependents(): void;
|
|
20
21
|
watch(tracker: FlowTracker): void;
|
|
21
22
|
trigger(): void;
|
|
22
|
-
notify(): void;
|
|
23
23
|
dispose(): void;
|
|
24
|
+
abstract notify(): void;
|
|
24
25
|
abstract execute(): void;
|
|
25
26
|
abstract subscribe(onValue: FlowOnDataListener<T>, onError?: FlowOnErrorListener, onPending?: FlowOnPendingListener): FlowEffect;
|
|
26
27
|
}
|
|
27
|
-
//# sourceMappingURL=node.d.ts.map
|
|
@@ -20,7 +20,7 @@ export interface IObservable<T> extends FlowObservable<T> {
|
|
|
20
20
|
* Base implementation managing the dependency graph for reactive observables.
|
|
21
21
|
*/
|
|
22
22
|
export declare abstract class Observable<T> extends Disposable implements IObservable<T> {
|
|
23
|
-
private
|
|
23
|
+
private _dependentsRegistry;
|
|
24
24
|
protected _status: ObservableStatus;
|
|
25
25
|
get status(): ObservableStatus;
|
|
26
26
|
set status(status: ObservableStatus);
|
|
@@ -32,4 +32,3 @@ export declare abstract class Observable<T> extends Disposable implements IObser
|
|
|
32
32
|
dispose(): void;
|
|
33
33
|
abstract subscribe(onValue: FlowOnDataListener<T>, onError?: FlowOnErrorListener, onPending?: FlowOnPendingListener): FlowEffect;
|
|
34
34
|
}
|
|
35
|
-
//# sourceMappingURL=observable.d.ts.map
|
|
@@ -9,12 +9,21 @@ export interface IObserver {
|
|
|
9
9
|
clearDependencies(): void;
|
|
10
10
|
notify(): void;
|
|
11
11
|
execute(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Called by a dependency's `dispose()` on each of its remaining dependents, so an
|
|
14
|
+
* observer already queued for the next flush can skip that run instead of reading
|
|
15
|
+
* through the now-disposed dependency and throwing (A2-SEM-1).
|
|
16
|
+
*/
|
|
17
|
+
markDependencyDisposed(): void;
|
|
12
18
|
}
|
|
13
19
|
/**
|
|
14
20
|
* Base implementation managing dependency tracking for reactive observers.
|
|
15
21
|
*/
|
|
16
22
|
export declare abstract class Observer extends Disposable implements IObserver {
|
|
17
|
-
private
|
|
23
|
+
private _dependenciesRegistry;
|
|
24
|
+
/** Set when a dependency disposed while this observer was queued; consumed by the next execute(). */
|
|
25
|
+
protected _dependencyDisposed: boolean;
|
|
26
|
+
markDependencyDisposed(): void;
|
|
18
27
|
registerDependency(dependency: IObservable<unknown>): void;
|
|
19
28
|
unregisterDependency(dependency: IObservable<unknown>): void;
|
|
20
29
|
clearDependencies(): void;
|
|
@@ -22,4 +31,3 @@ export declare abstract class Observer extends Disposable implements IObserver {
|
|
|
22
31
|
abstract notify(): void;
|
|
23
32
|
abstract execute(): void;
|
|
24
33
|
}
|
|
25
|
-
//# sourceMappingURL=observer.d.ts.map
|
|
@@ -47,4 +47,3 @@ import { FlowTracker, FlowValue, NotPromise } from '../api/index.js';
|
|
|
47
47
|
*/
|
|
48
48
|
export declare function from<T>(flow: FlowValue<T>): Resource<T>;
|
|
49
49
|
export declare function from<T>(flow: (t: FlowTracker) => NotPromise<T>): Resource<T>;
|
|
50
|
-
//# sourceMappingURL=solid.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ValueSyncNode } from './valueSyncNode.js';
|
|
3
|
-
/**
|
|
4
|
-
* Reactive state that tracks the latest action while delivering every emitted action
|
|
5
|
-
* to `.subscribe()` callbacks, including multiple mutations within the same batch.
|
|
6
|
-
*
|
|
7
|
-
* Two read models:
|
|
8
|
-
* - get() / pick(): last-write-wins snapshot (current action value).
|
|
9
|
-
* - subscribe(): event stream — one onData call per emitted action, even when several
|
|
10
|
-
* mutations happen before the next flush. Each subscriber owns its own queue so
|
|
11
|
-
* delivery is not shared or stolen between subscribers.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare class ActionNode<T extends NotPromise<unknown>> extends ValueSyncNode<T> {
|
|
16
|
-
private _slots;
|
|
17
|
-
private _enqueueForSubscribers;
|
|
18
|
-
set(value: NotPromise<T>): void;
|
|
19
|
-
set(updater: UpdateFunction<T>): void;
|
|
20
|
-
subscribe(onValue: FlowOnDataListener<T>, onError?: FlowOnErrorListener, onPending?: FlowOnPendingListener): FlowEffect;
|
|
21
|
-
dispose(): void;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=actionNode.d.ts.map
|
|
1
|
+
export {};
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ActionNode } from './actionNode.js';
|
|
3
|
-
import { ValueSyncNode } from './valueSyncNode.js';
|
|
4
|
-
/**
|
|
5
|
-
* Internal implementation of reactive array with mutation tracking.
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare class ArrayNode<T> extends ValueSyncNode<T[]> implements FlowArray<T> {
|
|
9
|
-
$lastAction: ActionNode<FlowArrayAction<T>>;
|
|
10
|
-
protected _value: T[];
|
|
11
|
-
constructor(value?: T[]);
|
|
12
|
-
get(tracker: FlowTracker): T[];
|
|
13
|
-
pick(): Promise<T[]>;
|
|
14
|
-
get length(): number;
|
|
15
|
-
set(items: NotPromise<T[]>): T[];
|
|
16
|
-
set(updater: UpdateFunction<T[]>): T[];
|
|
17
|
-
update(index: number, item: T): T | undefined;
|
|
18
|
-
push(item: T): void;
|
|
19
|
-
pop(): T | undefined;
|
|
20
|
-
unshift(item: T): void;
|
|
21
|
-
shift(): T | undefined;
|
|
22
|
-
splice(start: number, deleteCount: number, ...newItems: T[]): T[];
|
|
23
|
-
clear(): T[];
|
|
24
|
-
dispose(): void;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=arrayNode.d.ts.map
|
|
1
|
+
export {};
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Observer } from '../base/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Reactive effect that automatically re-executes when its dependencies change.
|
|
5
|
-
*
|
|
6
|
-
* Scheduling uses epoch-based coalescing:
|
|
7
|
-
* - Multiple dependency changes in the same synchronous turn produce one queue entry
|
|
8
|
-
* but may still require multiple runs when notifications arrive in later microtasks
|
|
9
|
-
* (e.g. async pending → resolved).
|
|
10
|
-
* - Re-notifications during execute() (cascading effects) enqueue a fresh run because
|
|
11
|
-
* _queued is cleared at the start of execute().
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare class EffectNode<T> extends Observer implements FlowEffect {
|
|
16
|
-
private _data;
|
|
17
|
-
private _onData;
|
|
18
|
-
private _onError?;
|
|
19
|
-
private _onPending?;
|
|
20
|
-
/** True while this effect is already waiting in the effect queue for the next flush. */
|
|
21
|
-
private _queued;
|
|
22
|
-
/** Guards the single coalesced bump of _notifyEpoch while _queued during one sync turn. */
|
|
23
|
-
private _coalescedWhileQueued;
|
|
24
|
-
/** Monotonic count of notifications that must eventually be executed. */
|
|
25
|
-
private _notifyEpoch;
|
|
26
|
-
/** How many notification epochs have been executed so far. */
|
|
27
|
-
private _executedEpoch;
|
|
28
|
-
constructor(data: FlowDataTracker<T>, onData: FlowOnDataListener<T>, onError?: FlowOnErrorListener, onPending?: FlowOnPendingListener);
|
|
29
|
-
notify(): void;
|
|
30
|
-
execute(): void;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=effectNode.d.ts.map
|
|
1
|
+
export {};
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ActionNode } from './actionNode.js';
|
|
3
|
-
import { ValueSyncNode } from './valueSyncNode.js';
|
|
4
|
-
/**
|
|
5
|
-
* Internal implementation of reactive map with mutation tracking.
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare class MapNode<K, V> extends ValueSyncNode<Map<K, V>> implements FlowMap<K, V> {
|
|
9
|
-
$lastAction: ActionNode<FlowMapAction<K, V>>;
|
|
10
|
-
protected _value: Map<K, V>;
|
|
11
|
-
constructor(value?: Map<K, V>);
|
|
12
|
-
add(key: K, value: V): void;
|
|
13
|
-
update(key: K, value: V): V;
|
|
14
|
-
delete(key: K): V;
|
|
15
|
-
set(map: NotPromise<Map<K, V>>): Map<K, V>;
|
|
16
|
-
set(updater: UpdateFunction<Map<K, V>>): Map<K, V>;
|
|
17
|
-
clear(): Map<K, V>;
|
|
18
|
-
dispose(): void;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=mapNode.d.ts.map
|
|
1
|
+
export {};
|