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