@mmstack/primitives 22.0.0 → 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.
|
@@ -2418,8 +2418,49 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
|
|
|
2418
2418
|
return untracked(() => state.asReadonly());
|
|
2419
2419
|
}
|
|
2420
2420
|
|
|
2421
|
-
|
|
2422
|
-
|
|
2421
|
+
/**
|
|
2422
|
+
* Runtime marker + compile-time brand for an opaque value. A `const`-declared `Symbol`
|
|
2423
|
+
* has a `unique symbol` type, so the same symbol serves as both the property key written
|
|
2424
|
+
* by {@link opaque} and the type-level brand carried by {@link Opaque}.
|
|
2425
|
+
*/
|
|
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');
|
|
2423
2464
|
/**
|
|
2424
2465
|
* @internal
|
|
2425
2466
|
* Test-only handle on the proxy cache (deliberately NOT re-exported from the public barrel).
|
|
@@ -2453,7 +2494,7 @@ function isStore(value) {
|
|
|
2453
2494
|
value[IS_STORE] === true);
|
|
2454
2495
|
}
|
|
2455
2496
|
function isRecord(value) {
|
|
2456
|
-
if (value === null || typeof value !== 'object')
|
|
2497
|
+
if (value === null || typeof value !== 'object' || isOpaque(value))
|
|
2457
2498
|
return false;
|
|
2458
2499
|
const proto = Object.getPrototypeOf(value);
|
|
2459
2500
|
return proto === Object.prototype || proto === null;
|
|
@@ -2782,12 +2823,7 @@ function scopedStore(parent, seed, kind, injector) {
|
|
|
2782
2823
|
return hasOwnKey(localValue(), prop) || hasOwnKey(parentValue(), prop);
|
|
2783
2824
|
},
|
|
2784
2825
|
ownKeys() {
|
|
2785
|
-
return
|
|
2786
|
-
...new Set([
|
|
2787
|
-
...Reflect.ownKeys(parentValue()),
|
|
2788
|
-
...Reflect.ownKeys(localValue()),
|
|
2789
|
-
]),
|
|
2790
|
-
];
|
|
2826
|
+
return Reflect.ownKeys(untracked(view));
|
|
2791
2827
|
},
|
|
2792
2828
|
getOwnPropertyDescriptor(_, prop) {
|
|
2793
2829
|
if (hasOwnKey(localValue(), prop) || hasOwnKey(parentValue(), prop))
|
|
@@ -3293,5 +3329,5 @@ function withHistory(sourceOrValue, opt) {
|
|
|
3293
3329
|
* Generated bundle index. Do not edit.
|
|
3294
3330
|
*/
|
|
3295
3331
|
|
|
3296
|
-
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 };
|
|
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 };
|
|
3297
3333
|
//# sourceMappingURL=mmstack-primitives.mjs.map
|