@mmstack/primitives 21.0.26 → 22.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmstack/primitives",
3
- "version": "21.0.26",
3
+ "version": "22.0.1",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "signals",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "homepage": "https://github.com/mihajm/mmstack/blob/master/packages/primitives",
18
18
  "peerDependencies": {
19
- "@angular/core": ">=21 <22",
20
- "@angular/common": ">=21 <22"
19
+ "@angular/core": ">=22 <23",
20
+ "@angular/common": ">=22 <23"
21
21
  },
22
22
  "sideEffects": false,
23
23
  "module": "fesm2022/mmstack-primitives.mjs",
@@ -1996,7 +1996,26 @@ 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
+ * An object marked via {@link opaque} — the store treats it as an indivisible leaf
2007
+ * (like a `Date`), returning it whole instead of deep-proxying its keys.
2008
+ */
2009
+ type Opaque<T> = T & {
2010
+ readonly [OPAQUE]: true;
2011
+ };
2012
+ /** @internal Strips the opaque brand from the value a leaf signal carries. */
2013
+ type Unwrap<T> = T extends {
2014
+ readonly [OPAQUE]: true;
2015
+ } ? Omit<T, typeof OPAQUE> : T;
2016
+ type BaseType = string | number | boolean | symbol | undefined | null | Function | Date | RegExp | {
2017
+ readonly [OPAQUE]: true;
2018
+ };
2000
2019
  type Key = string | number;
2001
2020
  type AnyRecord = Record<Key, any>;
2002
2021
  /**
@@ -2063,11 +2082,11 @@ type MutableSignalStoreObject<T> = Simplify<Readonly<{
2063
2082
  <L extends AnyRecord>(props: L): MutableSignalStore<Simplify<Omit<NonNullable<T>, keyof L> & L>>;
2064
2083
  };
2065
2084
  }>;
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> & {
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>> & {
2068
2087
  readonly asReadonlyStore: () => SignalStore<T>;
2069
2088
  } & (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> & {
2089
+ type MutableSignalStore<T> = MutableSignal<Unwrap<T>> & {
2071
2090
  readonly asReadonlyStore: () => SignalStore<T>;
2072
2091
  } & (IsAny<T> extends true ? MutableSignalStoreObject<T> : NonNullable<T> extends BaseType ? unknown : NonNullable<T> extends Array<any> ? MutableArrayStore<NonNullable<T>> : MutableSignalStoreObject<T>);
2073
2092
  declare function toStore<T extends AnyRecord>(source: MutableSignal<T>, injector?: Injector, vivify?: Vivify): MutableSignalStore<T>;
@@ -2109,6 +2128,18 @@ declare function mutableStore<T extends AnyRecord>(value: T, opt?: CreateSignalO
2109
2128
  */
2110
2129
  vivify?: Vivify;
2111
2130
  }): 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>;
2112
2143
 
2113
2144
  /**
2114
2145
  * Interface for storage mechanisms compatible with the `stored` signal.
@@ -2537,5 +2568,5 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
2537
2568
  */
2538
2569
  declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
2539
2570
 
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 };
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 };
2572
+ 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 };