preact-sigma 6.1.1 → 6.1.2
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 +1 -1
- package/dist/index.mjs +1 -1
- package/dist/persist.d.mts +1 -1
- package/dist/persist.mjs +1 -1
- package/dist/{sigma-c48-qjsH.d.mts → sigma-CfLLgWDX.d.mts} +2 -2
- package/dist/{sigma-0X8yJrUR.mjs → sigma-yp6KR1lk.mjs} +4 -3
- package/docs/persist.md +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SigmaState, c as query, d as Draft, f as Immutable, i as SigmaRef, l as setAutoFreeze, m as Cleanup, n as Sigma, o as SigmaTarget, p as typeSymbol, r as SigmaDefinition, s as castProtected, t as Protected, u as sigma } from "./sigma-
|
|
1
|
+
import { a as SigmaState, c as query, d as Draft, f as Immutable, i as SigmaRef, l as setAutoFreeze, m as Cleanup, n as Sigma, o as SigmaTarget, p as typeSymbol, r as SigmaDefinition, s as castProtected, t as Protected, u as sigma } from "./sigma-CfLLgWDX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/defaults.d.ts
|
|
4
4
|
/**
|
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-yp6KR1lk.mjs";
|
|
2
2
|
import { useEffect, useRef } from "preact/hooks";
|
|
3
3
|
//#region src/defaults.ts
|
|
4
4
|
/**
|
package/dist/persist.d.mts
CHANGED
package/dist/persist.mjs
CHANGED
|
@@ -149,8 +149,8 @@ declare const sigma: Readonly<{
|
|
|
149
149
|
<TState extends object, TKey extends Extract<keyof TState, string>>(instance: Sigma<TState>, key: TKey, listener: (value: Immutable<TState[TKey]>) => void): Cleanup;
|
|
150
150
|
}; /** Returns the readonly signal backing one top-level state key. */
|
|
151
151
|
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. */
|
|
152
|
-
captureState<TState extends object>(instance: Sigma<TState>): Immutable<TState>; /** Publishes a plain-object snapshot
|
|
153
|
-
replaceState<TState extends object>(target: Sigma<TState>, nextState: TState): void;
|
|
152
|
+
captureState<TState extends object>(instance: Sigma<TState>): Immutable<TState>; /** Publishes a plain-object snapshot, including readonly captured snapshots, as committed state. */
|
|
153
|
+
replaceState<TState extends object>(target: Sigma<TState>, nextState: TState | Immutable<TState>): void;
|
|
154
154
|
}>;
|
|
155
155
|
/**
|
|
156
156
|
* Marks a class method as a committed-state reactive read with arguments instead of an action.
|
|
@@ -443,12 +443,13 @@ const sigma = /* @__PURE__ */ Object.freeze({
|
|
|
443
443
|
if (activeDraft) throw new Error(`[preact-sigma] replaceState() cannot run while an action has unpublished changes.`);
|
|
444
444
|
const instance = getActionInstance(target);
|
|
445
445
|
const baseState = createSnapshot(instance);
|
|
446
|
-
|
|
447
|
-
|
|
446
|
+
const replacement = nextState;
|
|
447
|
+
if (!hasStateChanges(baseState, replacement)) return;
|
|
448
|
+
const { inversePatches, patches } = hasPatchListeners(instance) ? createReplacementPatches(baseState, replacement) : {
|
|
448
449
|
inversePatches: void 0,
|
|
449
450
|
patches: void 0
|
|
450
451
|
};
|
|
451
|
-
publishState(instance,
|
|
452
|
+
publishState(instance, replacement, baseState, patches, inversePatches);
|
|
452
453
|
}
|
|
453
454
|
});
|
|
454
455
|
/**
|
package/docs/persist.md
CHANGED
|
@@ -56,7 +56,7 @@ Use the persist module when those primitives are the right boundary, but you do
|
|
|
56
56
|
## Constraints
|
|
57
57
|
|
|
58
58
|
- Persistence helpers are trusted external model owners. Restore and hydrate helpers may replace committed state even when they receive a protected consumer view.
|
|
59
|
-
- `sigma.replaceState(...)` requires a plain object replacement snapshot. In supported TypeScript usage, pass the class's full `TState` shape.
|
|
59
|
+
- `sigma.replaceState(...)` requires a plain object replacement snapshot. In supported TypeScript usage, pass the class's full `TState` or `Immutable<TState>` shape.
|
|
60
60
|
- Custom partial persistence codecs should reconstruct a full replacement snapshot before restore finishes.
|
|
61
61
|
- Nested sigma-state values are stored only if the chosen codec and payload format support them explicitly.
|
|
62
62
|
- Async restore failures reject through `restore(...)` or the `restored` promise from `hydrate(...)`.
|