@mmstack/primitives 21.0.27 → 21.0.28

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