@mmstack/primitives 20.5.8 → 20.5.9

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.
@@ -2405,6 +2405,12 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
2405
2405
  return untracked(() => state.asReadonly());
2406
2406
  }
2407
2407
 
2408
+ /**
2409
+ * Runtime marker + compile-time brand for an opaque value. A `const`-declared `Symbol`
2410
+ * has a `unique symbol` type, so the same symbol serves as both the property key written
2411
+ * by {@link opaque} and the type-level brand carried by {@link Opaque}.
2412
+ */
2413
+ const OPAQUE = Symbol('MMSTACK::OPAQUE');
2408
2414
  const IS_STORE = Symbol('MMSTACK::IS_STORE');
2409
2415
  const SCOPE_PARENT = Symbol('MMSTACK::SCOPE_PARENT');
2410
2416
  /**
@@ -2442,6 +2448,8 @@ function isStore(value) {
2442
2448
  function isRecord(value) {
2443
2449
  if (value === null || typeof value !== 'object')
2444
2450
  return false;
2451
+ if (value[OPAQUE] === true)
2452
+ return false; // opaque → leaf
2445
2453
  const proto = Object.getPrototypeOf(value);
2446
2454
  return proto === Object.prototype || proto === null;
2447
2455
  }
@@ -2799,6 +2807,22 @@ function store(value, opt) {
2799
2807
  function mutableStore(value, opt) {
2800
2808
  return toStore(mutable(value, opt), opt?.injector, opt?.vivify ?? false);
2801
2809
  }
2810
+ /**
2811
+ * Marks a plain object as opaque so {@link store} treats it as an indivisible leaf
2812
+ * (returned whole, never deep-proxied) — the same way it treats a `Date` or `RegExp`.
2813
+ * The marker is a non-enumerable symbol, so it never appears in spreads or iteration.
2814
+ * Idempotent. Call before freezing (`defineProperty` fails on a frozen object).
2815
+ *
2816
+ * @example
2817
+ * const s = store({ config: opaque({ theme: 'dark', nested: { a: 1 } }) });
2818
+ * s.config(); // the whole object, not a child store
2819
+ * s.config.set(opaque({ theme: 'light', nested: { a: 2 } }));
2820
+ */
2821
+ function opaque(value) {
2822
+ if (value[OPAQUE] !== true)
2823
+ Object.defineProperty(value, OPAQUE, { value: true, enumerable: false });
2824
+ return value;
2825
+ }
2802
2826
 
2803
2827
  // Internal dummy store for server-side rendering
2804
2828
  const noopStore = {
@@ -3283,5 +3307,5 @@ function withHistory(sourceOrValue, opt) {
3283
3307
  * Generated bundle index. Do not edit.
3284
3308
  */
3285
3309
 
3286
- 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 };
3310
+ 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 };
3287
3311
  //# sourceMappingURL=mmstack-primitives.mjs.map