@mmstack/primitives 20.5.9 → 20.5.10

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.
@@ -2410,9 +2410,44 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
2410
2410
  * has a `unique symbol` type, so the same symbol serves as both the property key written
2411
2411
  * by {@link opaque} and the type-level brand carried by {@link Opaque}.
2412
2412
  */
2413
- const OPAQUE = Symbol('MMSTACK::OPAQUE');
2414
- const IS_STORE = Symbol('MMSTACK::IS_STORE');
2415
- const SCOPE_PARENT = Symbol('MMSTACK::SCOPE_PARENT');
2413
+ const OPAQUE = Symbol('@mmstack/primitives::store/OPAQUE');
2414
+ /**
2415
+ * Marks a plain object as opaque so {@link store} treats it as an indivisible leaf
2416
+ * (returned whole, never deep-proxied) — the same way it treats a `Date` or `RegExp`.
2417
+ * The marker is a non-enumerable symbol, so it never appears in spreads or iteration.
2418
+ * Idempotent. Call before freezing (`defineProperty` fails on a frozen object).
2419
+ *
2420
+ * @example
2421
+ * const s = store({ config: opaque({ theme: 'dark', nested: { a: 1 } }) });
2422
+ * s.config(); // the whole object, not a child store
2423
+ * s.config.set(opaque({ theme: 'light', nested: { a: 2 } }));
2424
+ */
2425
+ function opaque(value) {
2426
+ if (value[OPAQUE] !== true)
2427
+ Object.defineProperty(value, OPAQUE, { value: true, enumerable: false });
2428
+ return value;
2429
+ }
2430
+ /**
2431
+ * Type guard companion to {@link opaque}: returns `true` when `value` carries the
2432
+ * {@link OPAQUE} brand, narrowing it to {@link Opaque}. This is the same check the
2433
+ * store uses to route opaque values to its leaf branch (alongside `Date`/`RegExp`).
2434
+ *
2435
+ * @internal Exposed for advanced/niche interop only — not part of the supported public
2436
+ * surface and may change without a major version bump. Reach for {@link opaque} for
2437
+ * normal usage.
2438
+ *
2439
+ * @example
2440
+ * if (isOpaque(value)) {
2441
+ * // value: Opaque<object> — `store` would treat it as an indivisible leaf
2442
+ * }
2443
+ */
2444
+ function isOpaque(value) {
2445
+ return (typeof value === 'object' &&
2446
+ value !== null &&
2447
+ value[OPAQUE] === true);
2448
+ }
2449
+ const IS_STORE = Symbol('@mmstack/primitives::store/IS_STORE');
2450
+ const SCOPE_PARENT = Symbol('@mmstack/primitives::store/SCOPE_PARENT');
2416
2451
  /**
2417
2452
  * @internal
2418
2453
  * Test-only handle on the proxy cache (deliberately NOT re-exported from the public barrel).
@@ -2446,10 +2481,8 @@ function isStore(value) {
2446
2481
  value[IS_STORE] === true);
2447
2482
  }
2448
2483
  function isRecord(value) {
2449
- if (value === null || typeof value !== 'object')
2484
+ if (value === null || typeof value !== 'object' || isOpaque(value))
2450
2485
  return false;
2451
- if (value[OPAQUE] === true)
2452
- return false; // opaque → leaf
2453
2486
  const proto = Object.getPrototypeOf(value);
2454
2487
  return proto === Object.prototype || proto === null;
2455
2488
  }
@@ -2775,12 +2808,7 @@ function scopedStore(parent, seed, kind, injector) {
2775
2808
  return hasOwnKey(localValue(), prop) || hasOwnKey(parentValue(), prop);
2776
2809
  },
2777
2810
  ownKeys() {
2778
- return [
2779
- ...new Set([
2780
- ...Reflect.ownKeys(parentValue()),
2781
- ...Reflect.ownKeys(localValue()),
2782
- ]),
2783
- ];
2811
+ return Reflect.ownKeys(untracked(view));
2784
2812
  },
2785
2813
  getOwnPropertyDescriptor(_, prop) {
2786
2814
  if (hasOwnKey(localValue(), prop) || hasOwnKey(parentValue(), prop))
@@ -2807,22 +2835,6 @@ function store(value, opt) {
2807
2835
  function mutableStore(value, opt) {
2808
2836
  return toStore(mutable(value, opt), opt?.injector, opt?.vivify ?? false);
2809
2837
  }
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
- }
2826
2838
 
2827
2839
  // Internal dummy store for server-side rendering
2828
2840
  const noopStore = {
@@ -3307,5 +3319,5 @@ function withHistory(sourceOrValue, opt) {
3307
3319
  * Generated bundle index. Do not edit.
3308
3320
  */
3309
3321
 
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 };
3322
+ 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 };
3311
3323
  //# sourceMappingURL=mmstack-primitives.mjs.map