@mmstack/primitives 22.0.1 → 22.0.2

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.
@@ -2423,9 +2423,44 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
2423
2423
  * has a `unique symbol` type, so the same symbol serves as both the property key written
2424
2424
  * by {@link opaque} and the type-level brand carried by {@link Opaque}.
2425
2425
  */
2426
- const OPAQUE = Symbol('MMSTACK::OPAQUE');
2427
- const IS_STORE = Symbol('MMSTACK::IS_STORE');
2428
- const SCOPE_PARENT = Symbol('MMSTACK::SCOPE_PARENT');
2426
+ const OPAQUE = Symbol('@mmstack/primitives::store/OPAQUE');
2427
+ /**
2428
+ * Marks a plain object as opaque so {@link store} treats it as an indivisible leaf
2429
+ * (returned whole, never deep-proxied) — the same way it treats a `Date` or `RegExp`.
2430
+ * The marker is a non-enumerable symbol, so it never appears in spreads or iteration.
2431
+ * Idempotent. Call before freezing (`defineProperty` fails on a frozen object).
2432
+ *
2433
+ * @example
2434
+ * const s = store({ config: opaque({ theme: 'dark', nested: { a: 1 } }) });
2435
+ * s.config(); // the whole object, not a child store
2436
+ * s.config.set(opaque({ theme: 'light', nested: { a: 2 } }));
2437
+ */
2438
+ function opaque(value) {
2439
+ if (value[OPAQUE] !== true)
2440
+ Object.defineProperty(value, OPAQUE, { value: true, enumerable: false });
2441
+ return value;
2442
+ }
2443
+ /**
2444
+ * Type guard companion to {@link opaque}: returns `true` when `value` carries the
2445
+ * {@link OPAQUE} brand, narrowing it to {@link Opaque}. This is the same check the
2446
+ * store uses to route opaque values to its leaf branch (alongside `Date`/`RegExp`).
2447
+ *
2448
+ * @internal Exposed for advanced/niche interop only — not part of the supported public
2449
+ * surface and may change without a major version bump. Reach for {@link opaque} for
2450
+ * normal usage.
2451
+ *
2452
+ * @example
2453
+ * if (isOpaque(value)) {
2454
+ * // value: Opaque<object> — `store` would treat it as an indivisible leaf
2455
+ * }
2456
+ */
2457
+ function isOpaque(value) {
2458
+ return (typeof value === 'object' &&
2459
+ value !== null &&
2460
+ value[OPAQUE] === true);
2461
+ }
2462
+ const IS_STORE = Symbol('@mmstack/primitives::store/IS_STORE');
2463
+ const SCOPE_PARENT = Symbol('@mmstack/primitives::store/SCOPE_PARENT');
2429
2464
  /**
2430
2465
  * @internal
2431
2466
  * Test-only handle on the proxy cache (deliberately NOT re-exported from the public barrel).
@@ -2459,10 +2494,8 @@ function isStore(value) {
2459
2494
  value[IS_STORE] === true);
2460
2495
  }
2461
2496
  function isRecord(value) {
2462
- if (value === null || typeof value !== 'object')
2497
+ if (value === null || typeof value !== 'object' || isOpaque(value))
2463
2498
  return false;
2464
- if (value[OPAQUE] === true)
2465
- return false; // opaque → leaf
2466
2499
  const proto = Object.getPrototypeOf(value);
2467
2500
  return proto === Object.prototype || proto === null;
2468
2501
  }
@@ -2790,12 +2823,7 @@ function scopedStore(parent, seed, kind, injector) {
2790
2823
  return hasOwnKey(localValue(), prop) || hasOwnKey(parentValue(), prop);
2791
2824
  },
2792
2825
  ownKeys() {
2793
- return [
2794
- ...new Set([
2795
- ...Reflect.ownKeys(parentValue()),
2796
- ...Reflect.ownKeys(localValue()),
2797
- ]),
2798
- ];
2826
+ return Reflect.ownKeys(untracked(view));
2799
2827
  },
2800
2828
  getOwnPropertyDescriptor(_, prop) {
2801
2829
  if (hasOwnKey(localValue(), prop) || hasOwnKey(parentValue(), prop))
@@ -2822,22 +2850,6 @@ function store(value, opt) {
2822
2850
  function mutableStore(value, opt) {
2823
2851
  return toStore(mutable(value, opt), opt?.injector, opt?.vivify ?? false);
2824
2852
  }
2825
- /**
2826
- * Marks a plain object as opaque so {@link store} treats it as an indivisible leaf
2827
- * (returned whole, never deep-proxied) — the same way it treats a `Date` or `RegExp`.
2828
- * The marker is a non-enumerable symbol, so it never appears in spreads or iteration.
2829
- * Idempotent. Call before freezing (`defineProperty` fails on a frozen object).
2830
- *
2831
- * @example
2832
- * const s = store({ config: opaque({ theme: 'dark', nested: { a: 1 } }) });
2833
- * s.config(); // the whole object, not a child store
2834
- * s.config.set(opaque({ theme: 'light', nested: { a: 2 } }));
2835
- */
2836
- function opaque(value) {
2837
- if (value[OPAQUE] !== true)
2838
- Object.defineProperty(value, OPAQUE, { value: true, enumerable: false });
2839
- return value;
2840
- }
2841
2853
 
2842
2854
  // Internal dummy store for server-side rendering
2843
2855
  const noopStore = {
@@ -3317,5 +3329,5 @@ function withHistory(sourceOrValue, opt) {
3317
3329
  * Generated bundle index. Do not edit.
3318
3330
  */
3319
3331
 
3320
- 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 };
3332
+ 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 };
3321
3333
  //# sourceMappingURL=mmstack-primitives.mjs.map