preact-sigma 6.1.0 → 6.1.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.
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-CadB76LN.mjs";
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-c48-qjsH.mjs";
2
2
 
3
3
  //#region src/defaults.d.ts
4
4
  /**
@@ -1,7 +1,13 @@
1
- import { f as Immutable, n as Sigma } from "./sigma-CadB76LN.mjs";
1
+ import { f as Immutable, n as Sigma, t as Protected } from "./sigma-c48-qjsH.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>>;
5
11
  /** Decode-time context passed to persistence codecs. */
6
12
  interface PersistDecodeContext<TState extends object> {
7
13
  /** Storage key used to read the record being decoded. */
@@ -108,19 +114,19 @@ interface SyncHydrationHandle extends PersistenceHandle {
108
114
  readonly restored: RestoreResult;
109
115
  }
110
116
  /** Restores committed state from a persisted record through an async store. */
111
- declare function restore<TState extends object, TKey extends keyof TState>(instance: Sigma<TState>, options: PickPersistOptions<TState, TKey>): Promise<RestoreResult>;
112
- declare function restore<TState extends object, TStored = Immutable<TState>>(instance: Sigma<TState>, options: PersistOptions<TState, TStored>): Promise<RestoreResult>;
117
+ declare function restore<TState extends object, TKey extends keyof TState>(instance: PersistInstance<TState>, options: PickPersistOptions<TState, TKey>): Promise<RestoreResult>;
118
+ declare function restore<TState extends object, TStored = Immutable<TState>>(instance: PersistInstance<TState>, options: PersistOptions<TState, TStored>): Promise<RestoreResult>;
113
119
  /** Restores committed state from a persisted record through a sync store. */
114
- declare function restoreSync<TState extends object, TKey extends keyof TState>(instance: Sigma<TState>, options: SyncPickPersistOptions<TState, TKey>): RestoreResult;
115
- declare function restoreSync<TState extends object, TStored = Immutable<TState>>(instance: Sigma<TState>, options: SyncPersistOptions<TState, TStored>): RestoreResult;
120
+ declare function restoreSync<TState extends object, TKey extends keyof TState>(instance: PersistInstance<TState>, options: SyncPickPersistOptions<TState, TKey>): RestoreResult;
121
+ declare function restoreSync<TState extends object, TStored = Immutable<TState>>(instance: PersistInstance<TState>, options: SyncPersistOptions<TState, TStored>): RestoreResult;
116
122
  /** Persists future committed state changes for one sigma instance. */
117
- declare function persist<TState extends object, TKey extends keyof TState>(instance: Sigma<TState>, options: PickPersistOptions<TState, TKey>): PersistenceHandle;
118
- declare function persist<TState extends object, TStored = Immutable<TState>>(instance: Sigma<TState>, options: PersistOptions<TState, TStored>): PersistenceHandle;
123
+ declare function persist<TState extends object, TKey extends keyof TState>(instance: PersistInstance<TState>, options: PickPersistOptions<TState, TKey>): PersistenceHandle;
124
+ declare function persist<TState extends object, TStored = Immutable<TState>>(instance: PersistInstance<TState>, options: PersistOptions<TState, TStored>): PersistenceHandle;
119
125
  /** Restores state, then begins persisting future committed changes. */
120
- declare function hydrate<TState extends object, TKey extends keyof TState>(instance: Sigma<TState>, options: PickPersistOptions<TState, TKey>): HydrationHandle;
121
- declare function hydrate<TState extends object, TStored = Immutable<TState>>(instance: Sigma<TState>, options: PersistOptions<TState, TStored>): HydrationHandle;
126
+ declare function hydrate<TState extends object, TKey extends keyof TState>(instance: PersistInstance<TState>, options: PickPersistOptions<TState, TKey>): HydrationHandle;
127
+ declare function hydrate<TState extends object, TStored = Immutable<TState>>(instance: PersistInstance<TState>, options: PersistOptions<TState, TStored>): HydrationHandle;
122
128
  /** Restores state synchronously, then begins persisting future committed changes. */
123
- declare function hydrateSync<TState extends object, TKey extends keyof TState>(instance: Sigma<TState>, options: SyncPickPersistOptions<TState, TKey>): SyncHydrationHandle;
124
- declare function hydrateSync<TState extends object, TStored = Immutable<TState>>(instance: Sigma<TState>, options: SyncPersistOptions<TState, TStored>): SyncHydrationHandle;
129
+ declare function hydrateSync<TState extends object, TKey extends keyof TState>(instance: PersistInstance<TState>, options: SyncPickPersistOptions<TState, TKey>): SyncHydrationHandle;
130
+ declare function hydrateSync<TState extends object, TStored = Immutable<TState>>(instance: PersistInstance<TState>, options: SyncPersistOptions<TState, TStored>): SyncHydrationHandle;
125
131
  //#endregion
126
132
  export { HydrationHandle, PersistCodec, PersistDecodeContext, PersistErrorContext, PersistOptions, PersistRecord, PersistSchedule, PersistStore, PersistenceHandle, PickPersistOptions, RestoreResult, SyncHydrationHandle, SyncPersistOptions, SyncPersistStore, SyncPickPersistOptions, hydrate, hydrateSync, persist, restore, restoreSync };
@@ -168,6 +168,6 @@ type Protected<T extends Sigma<any>> = BrandProtected<T extends {
168
168
  [typeSymbol]: {
169
169
  state: infer TState extends object;
170
170
  };
171
- } ? { [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>;
171
+ } ? { 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>;
172
172
  //#endregion
173
173
  export { SigmaState as a, query as c, Draft as d, Immutable as f, SigmaRef as i, setAutoFreeze as l, Cleanup as m, Sigma as n, SigmaTarget as o, typeSymbol as p, SigmaDefinition as r, castProtected as s, Protected as t, sigma as u };
package/docs/persist.md CHANGED
@@ -29,6 +29,7 @@ Use the persist module when those primitives are the right boundary, but you do
29
29
 
30
30
  ## Core Pieces
31
31
 
32
+ - Instance: a raw `Sigma` instance or a protected consumer view returned by `castProtected(...)` or `useSigma(...)`.
32
33
  - Store: owns `get`, `set`, and `delete` for persisted records. These names match [Keyv](https://github.com/jaredwray/keyv) and `Map`.
33
34
  - Codec: owns payload shape, versioning, and migration logic between stored data and a full committed snapshot.
34
35
  - Pick options: persist selected top-level keys without writing a custom codec.
@@ -54,6 +55,7 @@ Use the persist module when those primitives are the right boundary, but you do
54
55
 
55
56
  ## Constraints
56
57
 
58
+ - Persistence helpers are trusted external model owners. Restore and hydrate helpers may replace committed state even when they receive a protected consumer view.
57
59
  - `sigma.replaceState(...)` requires a plain object replacement snapshot. In supported TypeScript usage, pass the class's full `TState` shape.
58
60
  - Custom partial persistence codecs should reconstruct a full replacement snapshot before restore finishes.
59
61
  - Nested sigma-state values are stored only if the chosen codec and payload format support them explicitly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preact-sigma",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "keywords": [],
5
5
  "license": "MIT",
6
6
  "author": "Alec Larson",