@mmstack/primitives 19.3.8 → 19.3.9
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.
- package/fesm2022/mmstack-primitives.mjs +25 -1
- package/fesm2022/mmstack-primitives.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/lib/store.d.ts +35 -4
- package/package.json +1 -1
|
@@ -2402,6 +2402,12 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
|
|
|
2402
2402
|
return untracked(() => state.asReadonly());
|
|
2403
2403
|
}
|
|
2404
2404
|
|
|
2405
|
+
/**
|
|
2406
|
+
* Runtime marker + compile-time brand for an opaque value. A `const`-declared `Symbol`
|
|
2407
|
+
* has a `unique symbol` type, so the same symbol serves as both the property key written
|
|
2408
|
+
* by {@link opaque} and the type-level brand carried by {@link Opaque}.
|
|
2409
|
+
*/
|
|
2410
|
+
const OPAQUE = Symbol('MMSTACK::OPAQUE');
|
|
2405
2411
|
const IS_STORE = Symbol('MMSTACK::IS_STORE');
|
|
2406
2412
|
const SCOPE_PARENT = Symbol('MMSTACK::SCOPE_PARENT');
|
|
2407
2413
|
/**
|
|
@@ -2439,6 +2445,8 @@ function isStore(value) {
|
|
|
2439
2445
|
function isRecord(value) {
|
|
2440
2446
|
if (value === null || typeof value !== 'object')
|
|
2441
2447
|
return false;
|
|
2448
|
+
if (value[OPAQUE] === true)
|
|
2449
|
+
return false; // opaque → leaf
|
|
2442
2450
|
const proto = Object.getPrototypeOf(value);
|
|
2443
2451
|
return proto === Object.prototype || proto === null;
|
|
2444
2452
|
}
|
|
@@ -2796,6 +2804,22 @@ function store(value, opt) {
|
|
|
2796
2804
|
function mutableStore(value, opt) {
|
|
2797
2805
|
return toStore(mutable(value, opt), opt?.injector, opt?.vivify ?? false);
|
|
2798
2806
|
}
|
|
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
|
+
}
|
|
2799
2823
|
|
|
2800
2824
|
// Internal dummy store for server-side rendering
|
|
2801
2825
|
const noopStore = {
|
|
@@ -3273,5 +3297,5 @@ function withHistory(sourceOrValue, opt) {
|
|
|
3273
3297
|
* Generated bundle index. Do not edit.
|
|
3274
3298
|
*/
|
|
3275
3299
|
|
|
3276
|
-
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 };
|
|
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 };
|
|
3277
3301
|
//# sourceMappingURL=mmstack-primitives.mjs.map
|