@mmstack/primitives 22.0.2 → 22.0.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/package.json
CHANGED
|
@@ -2028,7 +2028,32 @@ declare function opaque<T extends object>(value: T): Opaque<T>;
|
|
|
2028
2028
|
* // value: Opaque<object> — `store` would treat it as an indivisible leaf
|
|
2029
2029
|
* }
|
|
2030
2030
|
*/
|
|
2031
|
-
declare function isOpaque(value: unknown): value is Opaque<
|
|
2031
|
+
declare function isOpaque<T = object>(value: unknown): value is Opaque<T>;
|
|
2032
|
+
/**
|
|
2033
|
+
* @internal Runtime brand carrying a store node's lazily-built leaf probe. Exported (like
|
|
2034
|
+
* {@link OPAQUE}) only so the `{ readonly [LEAF]: () => boolean }` brand on the store types is
|
|
2035
|
+
* nameable in the emitted declarations — not part of the supported surface; use {@link isLeaf}.
|
|
2036
|
+
*/
|
|
2037
|
+
declare const LEAF: unique symbol;
|
|
2038
|
+
/**
|
|
2039
|
+
* Reports whether a store node is currently a **leaf** — a terminal value the store does not
|
|
2040
|
+
* descend into (a primitive, `Date`, `RegExp`, {@link opaque} object, class instance, or a
|
|
2041
|
+
* `null`/`undefined` hole when vivification is off) rather than a record/array substore.
|
|
2042
|
+
*
|
|
2043
|
+
* Leaf-ness reflects the node's **live** value: the probe is reactive and memoized, so calling
|
|
2044
|
+
* `isLeaf` inside a `computed`/`effect` re-evaluates when the node's shape changes.
|
|
2045
|
+
*
|
|
2046
|
+
* @internal Exposed for advanced/niche interop only — not part of the supported public surface
|
|
2047
|
+
* and may change without a major version bump.
|
|
2048
|
+
*
|
|
2049
|
+
* @example
|
|
2050
|
+
* const s = store({ name: 'Ada', address: { city: 'London' } });
|
|
2051
|
+
* isLeaf(s.name); // true
|
|
2052
|
+
* isLeaf(s.address); // false — a substore
|
|
2053
|
+
*/
|
|
2054
|
+
declare function isLeaf<T = unknown>(value: unknown): value is Signal<T> & {
|
|
2055
|
+
readonly [LEAF]: () => boolean;
|
|
2056
|
+
};
|
|
2032
2057
|
/**
|
|
2033
2058
|
* An object marked via {@link opaque} — the store treats it as an indivisible leaf
|
|
2034
2059
|
* (like a `Date`), returning it whole instead of deep-proxying its keys.
|
|
@@ -2040,7 +2065,7 @@ type Opaque<T> = T & {
|
|
|
2040
2065
|
type UnwrapOpqaue<T> = T extends {
|
|
2041
2066
|
readonly [OPAQUE]: true;
|
|
2042
2067
|
} ? Omit<T, typeof OPAQUE> : T;
|
|
2043
|
-
type BaseType = string | number | boolean | symbol | undefined | null | Function | Date | RegExp | {
|
|
2068
|
+
type BaseType = string | number | boolean | symbol | bigint | undefined | null | Function | Date | RegExp | {
|
|
2044
2069
|
readonly [OPAQUE]: true;
|
|
2045
2070
|
};
|
|
2046
2071
|
type Key = string | number;
|
|
@@ -2109,16 +2134,22 @@ type MutableSignalStoreObject<T> = Simplify<Readonly<{
|
|
|
2109
2134
|
<L extends AnyRecord>(props: L): MutableSignalStore<Simplify<Omit<NonNullable<T>, keyof L> & L>>;
|
|
2110
2135
|
};
|
|
2111
2136
|
}>;
|
|
2112
|
-
type SignalStore<T> = Signal<UnwrapOpqaue<T>> & (IsAny<T> extends true ? SignalStoreObject<T> : NonNullable<T> extends BaseType ?
|
|
2137
|
+
type SignalStore<T> = Signal<UnwrapOpqaue<T>> & (IsAny<T> extends true ? SignalStoreObject<T> : NonNullable<T> extends BaseType ? {
|
|
2138
|
+
readonly [LEAF]: () => boolean;
|
|
2139
|
+
} : NonNullable<T> extends Array<any> ? SignalArrayStore<NonNullable<T>> : SignalStoreObject<T>);
|
|
2113
2140
|
type WritableSignalStore<T> = WritableSignal<UnwrapOpqaue<T>> & {
|
|
2114
2141
|
readonly asReadonlyStore: () => SignalStore<T>;
|
|
2115
|
-
} & (IsAny<T> extends true ? WritableSignalStoreObject<T> : NonNullable<T> extends BaseType ?
|
|
2142
|
+
} & (IsAny<T> extends true ? WritableSignalStoreObject<T> : NonNullable<T> extends BaseType ? {
|
|
2143
|
+
readonly [LEAF]: () => boolean;
|
|
2144
|
+
} : NonNullable<T> extends Array<any> ? WritableArrayStore<NonNullable<T>> : WritableSignalStoreObject<T>);
|
|
2116
2145
|
type MutableSignalStore<T> = MutableSignal<UnwrapOpqaue<T>> & {
|
|
2117
2146
|
readonly asReadonlyStore: () => SignalStore<T>;
|
|
2118
|
-
} & (IsAny<T> extends true ? MutableSignalStoreObject<T> : NonNullable<T> extends BaseType ?
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
declare function toStore<T extends AnyRecord>(source:
|
|
2147
|
+
} & (IsAny<T> extends true ? MutableSignalStoreObject<T> : NonNullable<T> extends BaseType ? {
|
|
2148
|
+
readonly [LEAF]: () => boolean;
|
|
2149
|
+
} : NonNullable<T> extends Array<any> ? MutableArrayStore<NonNullable<T>> : MutableSignalStoreObject<T>);
|
|
2150
|
+
declare function toStore<T extends AnyRecord>(source: MutableSignal<T>, injector?: Injector, vivify?: Vivify, noUnionLeaves?: boolean): MutableSignalStore<T>;
|
|
2151
|
+
declare function toStore<T extends AnyRecord>(source: WritableSignal<T>, injector?: Injector, vivify?: Vivify, noUnionLeaves?: boolean): WritableSignalStore<T>;
|
|
2152
|
+
declare function toStore<T extends AnyRecord>(source: Signal<T>, injector?: Injector, vivify?: Vivify, noUnionLeaves?: boolean): SignalStore<T>;
|
|
2122
2153
|
/**
|
|
2123
2154
|
* Creates a WritableSignalStore from a value.
|
|
2124
2155
|
* @see {@link toStore}
|
|
@@ -2136,6 +2167,14 @@ declare function store<T extends AnyRecord>(value: T, opt?: CreateSignalOptions<
|
|
|
2136
2167
|
* explicit `'object'`/`'array'`, or a `() => container` factory. See {@link Vivify}.
|
|
2137
2168
|
*/
|
|
2138
2169
|
vivify?: Vivify;
|
|
2170
|
+
/**
|
|
2171
|
+
* Performance opt-in: promise that no node ever switches between leaf and substore (i.e. no
|
|
2172
|
+
* unions mixing a primitive with an object/array). With this on, each node's leaf-ness is
|
|
2173
|
+
* resolved once on the first {@link isLeaf} probe and cached as a constant, skipping the
|
|
2174
|
+
* reactive `computed`. If a node's shape does change anyway, {@link isLeaf} keeps its first
|
|
2175
|
+
* answer. Off by default.
|
|
2176
|
+
*/
|
|
2177
|
+
noUnionLeaves?: boolean;
|
|
2139
2178
|
}): WritableSignalStore<T>;
|
|
2140
2179
|
/**
|
|
2141
2180
|
* Creates a MutableSignalStore from a value.
|
|
@@ -2154,6 +2193,14 @@ declare function mutableStore<T extends AnyRecord>(value: T, opt?: CreateSignalO
|
|
|
2154
2193
|
* explicit `'object'`/`'array'`, or a `() => container` factory. See {@link Vivify}.
|
|
2155
2194
|
*/
|
|
2156
2195
|
vivify?: Vivify;
|
|
2196
|
+
/**
|
|
2197
|
+
* Performance opt-in: promise that no node ever switches between leaf and substore (i.e. no
|
|
2198
|
+
* unions mixing a primitive with an object/array). With this on, each node's leaf-ness is
|
|
2199
|
+
* resolved once on the first {@link isLeaf} probe and cached as a constant, skipping the
|
|
2200
|
+
* reactive `computed`. If a node's shape does change anyway, {@link isLeaf} keeps its first
|
|
2201
|
+
* answer. Off by default.
|
|
2202
|
+
*/
|
|
2203
|
+
noUnionLeaves?: boolean;
|
|
2157
2204
|
}): MutableSignalStore<T>;
|
|
2158
2205
|
|
|
2159
2206
|
/**
|
|
@@ -2583,5 +2630,5 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
|
|
|
2583
2630
|
*/
|
|
2584
2631
|
declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
|
|
2585
2632
|
|
|
2586
|
-
export { batteryStatus, chunked, clipboard, combineWith, debounce, debounced, derived, distinct, elementSize, elementVisibility, filter, filterWith, focusWithin, geolocation, idle, indexArray, isDerivation, isMutable, isOpaque, isStore, keyArray, map, mapArray, mapObject, mediaQuery, mousePosition, mutable, mutableStore, nestedEffect, networkStatus, opaque, orientation, pageVisibility, pairwise, pipeable, piped, pooled, pooledArray, pooledMap, pooledSet, prefersDarkMode, prefersReducedMotion, scan, scrollPosition, select, sensor, sensors, signalFromEvent, startWith, store, stored, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, until, windowSize, withHistory };
|
|
2633
|
+
export { batteryStatus, chunked, clipboard, combineWith, debounce, debounced, derived, distinct, elementSize, elementVisibility, filter, filterWith, focusWithin, geolocation, idle, indexArray, isDerivation, isLeaf, isMutable, isOpaque, isStore, keyArray, map, mapArray, mapObject, mediaQuery, mousePosition, mutable, mutableStore, nestedEffect, networkStatus, opaque, orientation, pageVisibility, pairwise, pipeable, piped, pooled, pooledArray, pooledMap, pooledSet, prefersDarkMode, prefersReducedMotion, scan, scrollPosition, select, sensor, sensors, signalFromEvent, startWith, store, stored, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, until, windowSize, withHistory };
|
|
2587
2634
|
export type { BatteryStatus, ClipboardSignal, Computation, CreateChunkedOptions, CreateDebouncedOptions, CreateHistoryOptions, CreatePooledOptions, CreateProvidedPooledOptions, CreateStoredOptions, CreateThrottledOptions, DebouncedSignal, DerivedSignal, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, GeolocationOptions, GeolocationSignal, IdleOptions, IdleSignal, MousePositionOptions, MousePositionSignal, MutableSignal, MutableSignalStore, NetworkStatusSignal, Opaque, PipeableSignal, ScreenOrientation, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SignalFromEventOptions, SignalStore, SignalWithHistory, StoredSignal, ThrottledSignal, UntilOptions, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore };
|