@mmstack/primitives 21.0.25 → 21.0.27

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.
@@ -2399,6 +2399,12 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
2399
2399
  return untracked(() => state.asReadonly());
2400
2400
  }
2401
2401
 
2402
+ /**
2403
+ * Runtime marker + compile-time brand for an opaque value. A `const`-declared `Symbol`
2404
+ * has a `unique symbol` type, so the same symbol serves as both the property key written
2405
+ * by {@link opaque} and the type-level brand carried by {@link Opaque}.
2406
+ */
2407
+ const OPAQUE = Symbol('MMSTACK::OPAQUE');
2402
2408
  const IS_STORE = Symbol('MMSTACK::IS_STORE');
2403
2409
  const SCOPE_PARENT = Symbol('MMSTACK::SCOPE_PARENT');
2404
2410
  /**
@@ -2436,6 +2442,8 @@ function isStore(value) {
2436
2442
  function isRecord(value) {
2437
2443
  if (value === null || typeof value !== 'object')
2438
2444
  return false;
2445
+ if (value[OPAQUE] === true)
2446
+ return false; // opaque → leaf
2439
2447
  const proto = Object.getPrototypeOf(value);
2440
2448
  return proto === Object.prototype || proto === null;
2441
2449
  }
@@ -2793,6 +2801,22 @@ function store(value, opt) {
2793
2801
  function mutableStore(value, opt) {
2794
2802
  return toStore(mutable(value, opt), opt?.injector, opt?.vivify ?? false);
2795
2803
  }
2804
+ /**
2805
+ * Marks a plain object as opaque so {@link store} treats it as an indivisible leaf
2806
+ * (returned whole, never deep-proxied) — the same way it treats a `Date` or `RegExp`.
2807
+ * The marker is a non-enumerable symbol, so it never appears in spreads or iteration.
2808
+ * Idempotent. Call before freezing (`defineProperty` fails on a frozen object).
2809
+ *
2810
+ * @example
2811
+ * const s = store({ config: opaque({ theme: 'dark', nested: { a: 1 } }) });
2812
+ * s.config(); // the whole object, not a child store
2813
+ * s.config.set(opaque({ theme: 'light', nested: { a: 2 } }));
2814
+ */
2815
+ function opaque(value) {
2816
+ if (value[OPAQUE] !== true)
2817
+ Object.defineProperty(value, OPAQUE, { value: true, enumerable: false });
2818
+ return value;
2819
+ }
2796
2820
 
2797
2821
  // Internal dummy store for server-side rendering
2798
2822
  const noopStore = {
@@ -3268,5 +3292,5 @@ function withHistory(sourceOrValue, opt) {
3268
3292
  * Generated bundle index. Do not edit.
3269
3293
  */
3270
3294
 
3271
- 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 };
3295
+ 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 };
3272
3296
  //# sourceMappingURL=mmstack-primitives.mjs.map