@mmstack/primitives 22.0.1 → 22.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmstack/primitives",
3
- "version": "22.0.1",
3
+ "version": "22.0.2",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "signals",
@@ -2002,6 +2002,33 @@ declare function signalFromEvent<TEvent extends Event, U>(target: ResolvableTarg
2002
2002
  * by {@link opaque} and the type-level brand carried by {@link Opaque}.
2003
2003
  */
2004
2004
  declare const OPAQUE: unique symbol;
2005
+ /**
2006
+ * Marks a plain object as opaque so {@link store} treats it as an indivisible leaf
2007
+ * (returned whole, never deep-proxied) — the same way it treats a `Date` or `RegExp`.
2008
+ * The marker is a non-enumerable symbol, so it never appears in spreads or iteration.
2009
+ * Idempotent. Call before freezing (`defineProperty` fails on a frozen object).
2010
+ *
2011
+ * @example
2012
+ * const s = store({ config: opaque({ theme: 'dark', nested: { a: 1 } }) });
2013
+ * s.config(); // the whole object, not a child store
2014
+ * s.config.set(opaque({ theme: 'light', nested: { a: 2 } }));
2015
+ */
2016
+ declare function opaque<T extends object>(value: T): Opaque<T>;
2017
+ /**
2018
+ * Type guard companion to {@link opaque}: returns `true` when `value` carries the
2019
+ * {@link OPAQUE} brand, narrowing it to {@link Opaque}. This is the same check the
2020
+ * store uses to route opaque values to its leaf branch (alongside `Date`/`RegExp`).
2021
+ *
2022
+ * @internal Exposed for advanced/niche interop only — not part of the supported public
2023
+ * surface and may change without a major version bump. Reach for {@link opaque} for
2024
+ * normal usage.
2025
+ *
2026
+ * @example
2027
+ * if (isOpaque(value)) {
2028
+ * // value: Opaque<object> — `store` would treat it as an indivisible leaf
2029
+ * }
2030
+ */
2031
+ declare function isOpaque(value: unknown): value is Opaque<object>;
2005
2032
  /**
2006
2033
  * An object marked via {@link opaque} — the store treats it as an indivisible leaf
2007
2034
  * (like a `Date`), returning it whole instead of deep-proxying its keys.
@@ -2010,7 +2037,7 @@ type Opaque<T> = T & {
2010
2037
  readonly [OPAQUE]: true;
2011
2038
  };
2012
2039
  /** @internal Strips the opaque brand from the value a leaf signal carries. */
2013
- type Unwrap<T> = T extends {
2040
+ type UnwrapOpqaue<T> = T extends {
2014
2041
  readonly [OPAQUE]: true;
2015
2042
  } ? Omit<T, typeof OPAQUE> : T;
2016
2043
  type BaseType = string | number | boolean | symbol | undefined | null | Function | Date | RegExp | {
@@ -2082,11 +2109,11 @@ type MutableSignalStoreObject<T> = Simplify<Readonly<{
2082
2109
  <L extends AnyRecord>(props: L): MutableSignalStore<Simplify<Omit<NonNullable<T>, keyof L> & L>>;
2083
2110
  };
2084
2111
  }>;
2085
- type SignalStore<T> = Signal<Unwrap<T>> & (IsAny<T> extends true ? SignalStoreObject<T> : NonNullable<T> extends BaseType ? unknown : NonNullable<T> extends Array<any> ? SignalArrayStore<NonNullable<T>> : SignalStoreObject<T>);
2086
- type WritableSignalStore<T> = WritableSignal<Unwrap<T>> & {
2112
+ type SignalStore<T> = Signal<UnwrapOpqaue<T>> & (IsAny<T> extends true ? SignalStoreObject<T> : NonNullable<T> extends BaseType ? unknown : NonNullable<T> extends Array<any> ? SignalArrayStore<NonNullable<T>> : SignalStoreObject<T>);
2113
+ type WritableSignalStore<T> = WritableSignal<UnwrapOpqaue<T>> & {
2087
2114
  readonly asReadonlyStore: () => SignalStore<T>;
2088
2115
  } & (IsAny<T> extends true ? WritableSignalStoreObject<T> : NonNullable<T> extends BaseType ? unknown : NonNullable<T> extends Array<any> ? WritableArrayStore<NonNullable<T>> : WritableSignalStoreObject<T>);
2089
- type MutableSignalStore<T> = MutableSignal<Unwrap<T>> & {
2116
+ type MutableSignalStore<T> = MutableSignal<UnwrapOpqaue<T>> & {
2090
2117
  readonly asReadonlyStore: () => SignalStore<T>;
2091
2118
  } & (IsAny<T> extends true ? MutableSignalStoreObject<T> : NonNullable<T> extends BaseType ? unknown : NonNullable<T> extends Array<any> ? MutableArrayStore<NonNullable<T>> : MutableSignalStoreObject<T>);
2092
2119
  declare function toStore<T extends AnyRecord>(source: MutableSignal<T>, injector?: Injector, vivify?: Vivify): MutableSignalStore<T>;
@@ -2128,18 +2155,6 @@ declare function mutableStore<T extends AnyRecord>(value: T, opt?: CreateSignalO
2128
2155
  */
2129
2156
  vivify?: Vivify;
2130
2157
  }): MutableSignalStore<T>;
2131
- /**
2132
- * Marks a plain object as opaque so {@link store} treats it as an indivisible leaf
2133
- * (returned whole, never deep-proxied) — the same way it treats a `Date` or `RegExp`.
2134
- * The marker is a non-enumerable symbol, so it never appears in spreads or iteration.
2135
- * Idempotent. Call before freezing (`defineProperty` fails on a frozen object).
2136
- *
2137
- * @example
2138
- * const s = store({ config: opaque({ theme: 'dark', nested: { a: 1 } }) });
2139
- * s.config(); // the whole object, not a child store
2140
- * s.config.set(opaque({ theme: 'light', nested: { a: 2 } }));
2141
- */
2142
- declare function opaque<T extends object>(value: T): Opaque<T>;
2143
2158
 
2144
2159
  /**
2145
2160
  * Interface for storage mechanisms compatible with the `stored` signal.
@@ -2568,5 +2583,5 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
2568
2583
  */
2569
2584
  declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
2570
2585
 
2571
- export { batteryStatus, chunked, clipboard, combineWith, debounce, debounced, derived, distinct, elementSize, elementVisibility, filter, filterWith, focusWithin, geolocation, idle, indexArray, isDerivation, isMutable, 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 };
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 };
2572
2587
  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 };