preact-sigma 6.1.3 → 6.1.4
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/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as SigmaRef, c as castProtected, d as sigma, f as Draft, h as Cleanup, i as SigmaDefinition, l as query, m as typeSymbol, n as ReadableSigma, o as SigmaState, p as Immutable, r as Sigma, s as SigmaTarget, t as Protected, u as setAutoFreeze } from "./sigma-BfaJUPWw.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/defaults.d.ts
|
|
4
4
|
/**
|
|
@@ -58,4 +58,4 @@ type UseSigmaArgs<T extends Sigma<any>> = T extends {
|
|
|
58
58
|
*/
|
|
59
59
|
declare function useSigma<T extends Sigma<any>>(...args: UseSigmaArgs<T>): Protected<T>;
|
|
60
60
|
//#endregion
|
|
61
|
-
export { type Draft, type Immutable, InferEventType, InferListener, Listenable, Protected, Sigma, SigmaDefinition, SigmaListenable, SigmaRef, SigmaState, SigmaTarget, UseSigmaArgs, UseSigmaOptions, castProtected, listen, mergeDefaults, query, setAutoFreeze, sigma, useListener, useSigma };
|
|
61
|
+
export { type Draft, type Immutable, InferEventType, InferListener, Listenable, Protected, ReadableSigma, Sigma, SigmaDefinition, SigmaListenable, SigmaRef, SigmaState, SigmaTarget, UseSigmaArgs, UseSigmaOptions, castProtected, listen, mergeDefaults, query, setAutoFreeze, sigma, useListener, useSigma };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as setAutoFreeze, c as listenersSymbol, i as query, n as SigmaTarget, o as sigma, r as castProtected, t as Sigma } from "./sigma-
|
|
1
|
+
import { a as setAutoFreeze, c as listenersSymbol, i as query, n as SigmaTarget, o as sigma, r as castProtected, t as Sigma } from "./sigma-DEKK3bHd.mjs";
|
|
2
2
|
import { useEffect, useRef } from "preact/hooks";
|
|
3
3
|
//#region src/defaults.ts
|
|
4
4
|
/**
|
package/dist/persist.d.mts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as ReadableSigma, p as Immutable, r as Sigma } from "./sigma-BfaJUPWw.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/persist.d.ts
|
|
4
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
5
|
-
/**
|
|
6
|
-
* Sigma instance or protected consumer view accepted by persistence helpers.
|
|
7
|
-
*
|
|
8
|
-
* Restore and hydrate helpers may replace committed state through this trusted owner boundary.
|
|
9
|
-
*/
|
|
10
|
-
type PersistInstance<TState extends object> = Sigma<TState> | Protected<Sigma<TState>>;
|
|
11
5
|
/** Decode-time context passed to persistence codecs. */
|
|
12
6
|
interface PersistDecodeContext<TState extends object> {
|
|
13
7
|
/** Storage key used to read the record being decoded. */
|
|
@@ -114,19 +108,19 @@ interface SyncHydrationHandle extends PersistenceHandle {
|
|
|
114
108
|
readonly restored: RestoreResult;
|
|
115
109
|
}
|
|
116
110
|
/** Restores committed state from a persisted record through an async store. */
|
|
117
|
-
declare function restore<TState extends object, TKey extends keyof TState>(instance:
|
|
118
|
-
declare function restore<TState extends object, TStored = Immutable<TState>>(instance:
|
|
111
|
+
declare function restore<TState extends object, TKey extends keyof TState>(instance: ReadableSigma<TState>, options: PickPersistOptions<TState, TKey>): Promise<RestoreResult>;
|
|
112
|
+
declare function restore<TState extends object, TStored = Immutable<TState>>(instance: ReadableSigma<TState>, options: PersistOptions<TState, TStored>): Promise<RestoreResult>;
|
|
119
113
|
/** Restores committed state from a persisted record through a sync store. */
|
|
120
|
-
declare function restoreSync<TState extends object, TKey extends keyof TState>(instance:
|
|
121
|
-
declare function restoreSync<TState extends object, TStored = Immutable<TState>>(instance:
|
|
114
|
+
declare function restoreSync<TState extends object, TKey extends keyof TState>(instance: ReadableSigma<TState>, options: SyncPickPersistOptions<TState, TKey>): RestoreResult;
|
|
115
|
+
declare function restoreSync<TState extends object, TStored = Immutable<TState>>(instance: ReadableSigma<TState>, options: SyncPersistOptions<TState, TStored>): RestoreResult;
|
|
122
116
|
/** Persists future committed state changes for one sigma instance. */
|
|
123
|
-
declare function persist<TState extends object, TKey extends keyof TState>(instance:
|
|
124
|
-
declare function persist<TState extends object, TStored = Immutable<TState>>(instance:
|
|
117
|
+
declare function persist<TState extends object, TKey extends keyof TState>(instance: ReadableSigma<TState>, options: PickPersistOptions<TState, TKey>): PersistenceHandle;
|
|
118
|
+
declare function persist<TState extends object, TStored = Immutable<TState>>(instance: ReadableSigma<TState>, options: PersistOptions<TState, TStored>): PersistenceHandle;
|
|
125
119
|
/** Restores state, then begins persisting future committed changes. */
|
|
126
|
-
declare function hydrate<TState extends object, TKey extends keyof TState>(instance:
|
|
127
|
-
declare function hydrate<TState extends object, TStored = Immutable<TState>>(instance:
|
|
120
|
+
declare function hydrate<TState extends object, TKey extends keyof TState>(instance: ReadableSigma<TState>, options: PickPersistOptions<TState, TKey>): HydrationHandle;
|
|
121
|
+
declare function hydrate<TState extends object, TStored = Immutable<TState>>(instance: ReadableSigma<TState>, options: PersistOptions<TState, TStored>): HydrationHandle;
|
|
128
122
|
/** Restores state synchronously, then begins persisting future committed changes. */
|
|
129
|
-
declare function hydrateSync<TState extends object, TKey extends keyof TState>(instance:
|
|
130
|
-
declare function hydrateSync<TState extends object, TStored = Immutable<TState>>(instance:
|
|
123
|
+
declare function hydrateSync<TState extends object, TKey extends keyof TState>(instance: ReadableSigma<TState>, options: SyncPickPersistOptions<TState, TKey>): SyncHydrationHandle;
|
|
124
|
+
declare function hydrateSync<TState extends object, TStored = Immutable<TState>>(instance: ReadableSigma<TState>, options: SyncPersistOptions<TState, TStored>): SyncHydrationHandle;
|
|
131
125
|
//#endregion
|
|
132
126
|
export { HydrationHandle, PersistCodec, PersistDecodeContext, PersistErrorContext, PersistOptions, PersistRecord, PersistSchedule, PersistStore, PersistenceHandle, PickPersistOptions, RestoreResult, SyncHydrationHandle, SyncPersistOptions, SyncPersistStore, SyncPickPersistOptions, hydrate, hydrateSync, persist, restore, restoreSync };
|
package/dist/persist.mjs
CHANGED
|
@@ -75,6 +75,7 @@ declare function setAutoFreeze(autoFreeze: boolean): void;
|
|
|
75
75
|
type SigmaRef<T extends object = {}> = T & {
|
|
76
76
|
[refSymbol]?: true;
|
|
77
77
|
};
|
|
78
|
+
type ReadableSigma<TState extends object> = Sigma<TState> | Protected<Sigma<TState>>;
|
|
78
79
|
/** Definition shape used by helper types that need both state and event maps. */
|
|
79
80
|
type SigmaDefinition = {
|
|
80
81
|
state: object;
|
|
@@ -150,7 +151,7 @@ declare const sigma: Readonly<{
|
|
|
150
151
|
<TState extends object, TKey extends Extract<keyof TState, string>>(instance: Sigma<TState>, key: TKey, listener: (value: Immutable<TState[TKey]>) => void): Cleanup;
|
|
151
152
|
}; /** Returns the readonly signal backing one top-level state key. */
|
|
152
153
|
getSignal<TState extends object, TKey extends Extract<keyof TState, string>>(instance: Sigma<TState>, key: TKey): ReadonlySignal<Immutable<TState[TKey]>>; /** Captures the current committed top-level state snapshot. */
|
|
153
|
-
captureState<TState extends object>(instance:
|
|
154
|
+
captureState<TState extends object>(instance: ReadableSigma<TState>): Immutable<TState>; /** Publishes a plain-object snapshot, including readonly captured snapshots, as committed state. */
|
|
154
155
|
replaceState<TState extends object>(target: Sigma<TState>, nextState: TState | Immutable<TState>): void;
|
|
155
156
|
}>;
|
|
156
157
|
/**
|
|
@@ -171,4 +172,4 @@ type Protected<T extends Sigma<any>> = BrandProtected<T extends {
|
|
|
171
172
|
};
|
|
172
173
|
} ? { readonly [K in keyof T as K extends ProtectedKey ? never : K]: K extends typeof typeSymbol ? T[K] : K extends keyof TState ? Immutable<T[K]> : T[K] extends AnyFunction ? (...params: Parameters<T[K]>) => Immutable<ReturnType<T[K]>> : Immutable<T[K]> } : never>;
|
|
173
174
|
//#endregion
|
|
174
|
-
export {
|
|
175
|
+
export { SigmaRef as a, castProtected as c, sigma as d, Draft as f, Cleanup as h, SigmaDefinition as i, query as l, typeSymbol as m, ReadableSigma as n, SigmaState as o, Immutable as p, Sigma as r, SigmaTarget as s, Protected as t, setAutoFreeze as u };
|
|
@@ -114,9 +114,11 @@ function getStateSignal(instance, key) {
|
|
|
114
114
|
return instance[key + signalSuffix];
|
|
115
115
|
}
|
|
116
116
|
function createSnapshot(instance) {
|
|
117
|
-
|
|
117
|
+
const source = instance;
|
|
118
|
+
if (source[snapshotSymbol]) return source[snapshotSymbol];
|
|
118
119
|
const state = {};
|
|
119
|
-
for (const key in
|
|
120
|
+
for (const key in source) if (isStateKey(source, key)) state[key] = getStateSignal(source, key).value;
|
|
121
|
+
source[snapshotSymbol] = state;
|
|
120
122
|
return state;
|
|
121
123
|
}
|
|
122
124
|
function createDraft(instance) {
|