@mmstack/primitives 21.0.26 → 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.
|
@@ -2399,8 +2399,49 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
|
|
|
2399
2399
|
return untracked(() => state.asReadonly());
|
|
2400
2400
|
}
|
|
2401
2401
|
|
|
2402
|
-
|
|
2403
|
-
|
|
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/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');
|
|
2404
2445
|
/**
|
|
2405
2446
|
* @internal
|
|
2406
2447
|
* Test-only handle on the proxy cache (deliberately NOT re-exported from the public barrel).
|
|
@@ -2434,7 +2475,7 @@ function isStore(value) {
|
|
|
2434
2475
|
value[IS_STORE] === true);
|
|
2435
2476
|
}
|
|
2436
2477
|
function isRecord(value) {
|
|
2437
|
-
if (value === null || typeof value !== 'object')
|
|
2478
|
+
if (value === null || typeof value !== 'object' || isOpaque(value))
|
|
2438
2479
|
return false;
|
|
2439
2480
|
const proto = Object.getPrototypeOf(value);
|
|
2440
2481
|
return proto === Object.prototype || proto === null;
|
|
@@ -2761,12 +2802,7 @@ function scopedStore(parent, seed, kind, injector) {
|
|
|
2761
2802
|
return hasOwnKey(localValue(), prop) || hasOwnKey(parentValue(), prop);
|
|
2762
2803
|
},
|
|
2763
2804
|
ownKeys() {
|
|
2764
|
-
return
|
|
2765
|
-
...new Set([
|
|
2766
|
-
...Reflect.ownKeys(parentValue()),
|
|
2767
|
-
...Reflect.ownKeys(localValue()),
|
|
2768
|
-
]),
|
|
2769
|
-
];
|
|
2805
|
+
return Reflect.ownKeys(untracked(view));
|
|
2770
2806
|
},
|
|
2771
2807
|
getOwnPropertyDescriptor(_, prop) {
|
|
2772
2808
|
if (hasOwnKey(localValue(), prop) || hasOwnKey(parentValue(), prop))
|
|
@@ -3268,5 +3304,5 @@ function withHistory(sourceOrValue, opt) {
|
|
|
3268
3304
|
* Generated bundle index. Do not edit.
|
|
3269
3305
|
*/
|
|
3270
3306
|
|
|
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 };
|
|
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 };
|
|
3272
3308
|
//# sourceMappingURL=mmstack-primitives.mjs.map
|