preact-sigma 6.1.2 → 6.1.3
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-
|
|
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-Dki3T7re.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-Oviv0rzP.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
|
@@ -88,6 +88,7 @@ type SigmaState<T extends SigmaDefinition> = Sigma<T["state"]> & {
|
|
|
88
88
|
* Base class for signal-backed state models.
|
|
89
89
|
*
|
|
90
90
|
* `TState` is the source of typing for top-level state keys, subscriptions, signals, and replacement snapshots.
|
|
91
|
+
* The initial state passed to `super(...)` can use either the mutable `TState` shape or an immutable snapshot.
|
|
91
92
|
* Private class fields stay ordinary instance storage and are not signal-backed, captured,
|
|
92
93
|
* persisted, or used for reactive invalidation by themselves.
|
|
93
94
|
* Merge a same-named interface with the class when direct property reads should be typed on the instance.
|
|
@@ -99,7 +100,7 @@ declare abstract class Sigma<TState extends object> {
|
|
|
99
100
|
};
|
|
100
101
|
[snapshotSymbol]: Record<string, unknown> | undefined;
|
|
101
102
|
protected get [instanceSymbol](): this;
|
|
102
|
-
constructor(initialState: TState);
|
|
103
|
+
constructor(initialState: TState | Immutable<TState>);
|
|
103
104
|
/** Optional setup hook that owns side effects and returns cleanup resources. */
|
|
104
105
|
onSetup?(...args: any[]): readonly AnyResource[];
|
|
105
106
|
/** Runs `onSetup(...)` and returns a cleanup that disposes returned resources in reverse order. */
|
|
@@ -127,7 +128,7 @@ declare class SigmaTarget<TEvents extends object = {}, TState extends object = {
|
|
|
127
128
|
events: TEvents;
|
|
128
129
|
};
|
|
129
130
|
protected [listenersSymbol]: SigmaListenerMap;
|
|
130
|
-
constructor(state?: TState);
|
|
131
|
+
constructor(state?: TState | Immutable<TState>);
|
|
131
132
|
/**
|
|
132
133
|
* Emits a typed event.
|
|
133
134
|
*
|
|
@@ -322,6 +322,7 @@ function defineSignalProperty(instance, key, value) {
|
|
|
322
322
|
* Base class for signal-backed state models.
|
|
323
323
|
*
|
|
324
324
|
* `TState` is the source of typing for top-level state keys, subscriptions, signals, and replacement snapshots.
|
|
325
|
+
* The initial state passed to `super(...)` can use either the mutable `TState` shape or an immutable snapshot.
|
|
325
326
|
* Private class fields stay ordinary instance storage and are not signal-backed, captured,
|
|
326
327
|
* persisted, or used for reactive invalidation by themselves.
|
|
327
328
|
* Merge a same-named interface with the class when direct property reads should be typed on the instance.
|
|
@@ -333,8 +334,9 @@ var Sigma = class {
|
|
|
333
334
|
constructor(initialState) {
|
|
334
335
|
initializeType(this.constructor);
|
|
335
336
|
if (initialState === emptySentinel) return;
|
|
336
|
-
|
|
337
|
-
|
|
337
|
+
const state = initialState;
|
|
338
|
+
for (const key in state) {
|
|
339
|
+
const initialValue = state[key];
|
|
338
340
|
if (autoFreezeEnabled) freeze(initialValue, true);
|
|
339
341
|
defineSignalProperty(this, key, initialValue);
|
|
340
342
|
}
|