@mmstack/primitives 22.0.0 → 22.0.1
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,6 +2418,12 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
|
|
|
2418
2418
|
return untracked(() => state.asReadonly());
|
|
2419
2419
|
}
|
|
2420
2420
|
|
|
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::OPAQUE');
|
|
2421
2427
|
const IS_STORE = Symbol('MMSTACK::IS_STORE');
|
|
2422
2428
|
const SCOPE_PARENT = Symbol('MMSTACK::SCOPE_PARENT');
|
|
2423
2429
|
/**
|
|
@@ -2455,6 +2461,8 @@ function isStore(value) {
|
|
|
2455
2461
|
function isRecord(value) {
|
|
2456
2462
|
if (value === null || typeof value !== 'object')
|
|
2457
2463
|
return false;
|
|
2464
|
+
if (value[OPAQUE] === true)
|
|
2465
|
+
return false; // opaque → leaf
|
|
2458
2466
|
const proto = Object.getPrototypeOf(value);
|
|
2459
2467
|
return proto === Object.prototype || proto === null;
|
|
2460
2468
|
}
|
|
@@ -2814,6 +2822,22 @@ function store(value, opt) {
|
|
|
2814
2822
|
function mutableStore(value, opt) {
|
|
2815
2823
|
return toStore(mutable(value, opt), opt?.injector, opt?.vivify ?? false);
|
|
2816
2824
|
}
|
|
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
|
+
}
|
|
2817
2841
|
|
|
2818
2842
|
// Internal dummy store for server-side rendering
|
|
2819
2843
|
const noopStore = {
|
|
@@ -3293,5 +3317,5 @@ function withHistory(sourceOrValue, opt) {
|
|
|
3293
3317
|
* Generated bundle index. Do not edit.
|
|
3294
3318
|
*/
|
|
3295
3319
|
|
|
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 };
|
|
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 };
|
|
3297
3321
|
//# sourceMappingURL=mmstack-primitives.mjs.map
|