@mmstack/primitives 22.0.0 → 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.0",
3
+ "version": "22.0.2",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "signals",
@@ -1996,7 +1996,53 @@ type ResolvableTarget = EventTargetLike | Signal<EventTargetLike | null>;
1996
1996
  declare function signalFromEvent<TEvent extends Event>(target: ResolvableTarget, eventName: string, initial: TEvent | null, opt?: SignalFromEventOptions): Signal<TEvent | null>;
1997
1997
  declare function signalFromEvent<TEvent extends Event, U>(target: ResolvableTarget, eventName: string, initial: U, project: (event: TEvent) => U, opt?: SignalFromEventOptions): Signal<U>;
1998
1998
 
1999
- type BaseType = string | number | boolean | symbol | undefined | null | Function | Date | RegExp;
1999
+ /**
2000
+ * Runtime marker + compile-time brand for an opaque value. A `const`-declared `Symbol`
2001
+ * has a `unique symbol` type, so the same symbol serves as both the property key written
2002
+ * by {@link opaque} and the type-level brand carried by {@link Opaque}.
2003
+ */
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>;
2032
+ /**
2033
+ * An object marked via {@link opaque} — the store treats it as an indivisible leaf
2034
+ * (like a `Date`), returning it whole instead of deep-proxying its keys.
2035
+ */
2036
+ type Opaque<T> = T & {
2037
+ readonly [OPAQUE]: true;
2038
+ };
2039
+ /** @internal Strips the opaque brand from the value a leaf signal carries. */
2040
+ type UnwrapOpqaue<T> = T extends {
2041
+ readonly [OPAQUE]: true;
2042
+ } ? Omit<T, typeof OPAQUE> : T;
2043
+ type BaseType = string | number | boolean | symbol | undefined | null | Function | Date | RegExp | {
2044
+ readonly [OPAQUE]: true;
2045
+ };
2000
2046
  type Key = string | number;
2001
2047
  type AnyRecord = Record<Key, any>;
2002
2048
  /**
@@ -2063,11 +2109,11 @@ type MutableSignalStoreObject<T> = Simplify<Readonly<{
2063
2109
  <L extends AnyRecord>(props: L): MutableSignalStore<Simplify<Omit<NonNullable<T>, keyof L> & L>>;
2064
2110
  };
2065
2111
  }>;
2066
- type SignalStore<T> = Signal<T> & (IsAny<T> extends true ? SignalStoreObject<T> : NonNullable<T> extends BaseType ? unknown : NonNullable<T> extends Array<any> ? SignalArrayStore<NonNullable<T>> : SignalStoreObject<T>);
2067
- type WritableSignalStore<T> = WritableSignal<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>> & {
2068
2114
  readonly asReadonlyStore: () => SignalStore<T>;
2069
2115
  } & (IsAny<T> extends true ? WritableSignalStoreObject<T> : NonNullable<T> extends BaseType ? unknown : NonNullable<T> extends Array<any> ? WritableArrayStore<NonNullable<T>> : WritableSignalStoreObject<T>);
2070
- type MutableSignalStore<T> = MutableSignal<T> & {
2116
+ type MutableSignalStore<T> = MutableSignal<UnwrapOpqaue<T>> & {
2071
2117
  readonly asReadonlyStore: () => SignalStore<T>;
2072
2118
  } & (IsAny<T> extends true ? MutableSignalStoreObject<T> : NonNullable<T> extends BaseType ? unknown : NonNullable<T> extends Array<any> ? MutableArrayStore<NonNullable<T>> : MutableSignalStoreObject<T>);
2073
2119
  declare function toStore<T extends AnyRecord>(source: MutableSignal<T>, injector?: Injector, vivify?: Vivify): MutableSignalStore<T>;
@@ -2537,5 +2583,5 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
2537
2583
  */
2538
2584
  declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
2539
2585
 
2540
- 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, 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 };
2541
- 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, PipeableSignal, ScreenOrientation, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SignalFromEventOptions, SignalStore, SignalWithHistory, StoredSignal, ThrottledSignal, UntilOptions, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore };
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 };
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 };