@mmstack/primitives 21.0.26 → 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.
|
@@ -311,7 +311,8 @@ function debounced(initial, opt) {
|
|
|
311
311
|
*/
|
|
312
312
|
function debounce(source, opt) {
|
|
313
313
|
const ms = opt?.ms ?? 0;
|
|
314
|
-
const trigger = signal(false,
|
|
314
|
+
const trigger = signal(false, /* @ts-ignore */
|
|
315
|
+
...(ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []));
|
|
315
316
|
let timeout;
|
|
316
317
|
try {
|
|
317
318
|
const destroyRef = opt?.destroyRef ?? inject(DestroyRef, { optional: true });
|
|
@@ -661,7 +662,8 @@ function createItemSignal(source, index, setter, opt) {
|
|
|
661
662
|
}
|
|
662
663
|
function indexArray(source, map, opt = {}) {
|
|
663
664
|
const data = isSignal(source) ? source : computed(source);
|
|
664
|
-
const len = computed(() => data().length,
|
|
665
|
+
const len = computed(() => data().length, /* @ts-ignore */
|
|
666
|
+
...(ngDevMode ? [{ debugName: "len" }] : /* istanbul ignore next */ []));
|
|
665
667
|
const setter = createSetter(data);
|
|
666
668
|
const writableData = isWritableSignal(data)
|
|
667
669
|
? data
|
|
@@ -789,7 +791,8 @@ function keyArray(source, mapFn, options = {}) {
|
|
|
789
791
|
for (j = 0; j < newLen; j++) {
|
|
790
792
|
item = newItems[j];
|
|
791
793
|
items[j] = item;
|
|
792
|
-
const indexSignal = signal(j,
|
|
794
|
+
const indexSignal = signal(j, /* @ts-ignore */
|
|
795
|
+
...(ngDevMode ? [{ debugName: "indexSignal" }] : /* istanbul ignore next */ []));
|
|
793
796
|
newIndexes[j] = indexSignal;
|
|
794
797
|
newMapped[j] = mapFn(item, indexSignal);
|
|
795
798
|
}
|
|
@@ -839,7 +842,8 @@ function keyArray(source, mapFn, options = {}) {
|
|
|
839
842
|
newIndexes[j].set(j);
|
|
840
843
|
}
|
|
841
844
|
else {
|
|
842
|
-
const indexSignal = signal(j,
|
|
845
|
+
const indexSignal = signal(j, /* @ts-ignore */
|
|
846
|
+
...(ngDevMode ? [{ debugName: "indexSignal" }] : /* istanbul ignore next */ []));
|
|
843
847
|
newIndexes[j] = indexSignal;
|
|
844
848
|
newMapped[j] = mapFn(newItems[j], indexSignal);
|
|
845
849
|
}
|
|
@@ -1276,7 +1280,8 @@ function clipboard(debugName = 'clipboard') {
|
|
|
1276
1280
|
!navigator.clipboard) {
|
|
1277
1281
|
const sig = computed(() => '', { debugName });
|
|
1278
1282
|
sig.copy = () => Promise.resolve();
|
|
1279
|
-
sig.isSupported = computed(() => false,
|
|
1283
|
+
sig.isSupported = computed(() => false, /* @ts-ignore */
|
|
1284
|
+
...(ngDevMode ? [{ debugName: "isSupported" }] : /* istanbul ignore next */ []));
|
|
1280
1285
|
return sig;
|
|
1281
1286
|
}
|
|
1282
1287
|
const state = signal('', { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), debugName });
|
|
@@ -1295,7 +1300,8 @@ function clipboard(debugName = 'clipboard') {
|
|
|
1295
1300
|
await navigator.clipboard.writeText(value);
|
|
1296
1301
|
state.set(value);
|
|
1297
1302
|
};
|
|
1298
|
-
sig.isSupported = computed(() => true,
|
|
1303
|
+
sig.isSupported = computed(() => true, /* @ts-ignore */
|
|
1304
|
+
...(ngDevMode ? [{ debugName: "isSupported" }] : /* istanbul ignore next */ []));
|
|
1299
1305
|
return sig;
|
|
1300
1306
|
}
|
|
1301
1307
|
|
|
@@ -1368,7 +1374,9 @@ function elementSize(target = inject(ElementRef), opt) {
|
|
|
1368
1374
|
return;
|
|
1369
1375
|
let observer = null;
|
|
1370
1376
|
observer = new ResizeObserver(([entry]) => {
|
|
1377
|
+
// eslint-disable-next-line no-useless-assignment
|
|
1371
1378
|
let width = 0;
|
|
1379
|
+
// eslint-disable-next-line no-useless-assignment
|
|
1372
1380
|
let height = 0;
|
|
1373
1381
|
const boxOption = opt?.box ?? 'border-box';
|
|
1374
1382
|
if (boxOption === 'border-box' && entry.borderBoxSize?.length > 0) {
|
|
@@ -1458,7 +1466,8 @@ function elementVisibility(target = inject(ElementRef), opt) {
|
|
|
1458
1466
|
const base = computed(() => undefined, {
|
|
1459
1467
|
debugName: opt?.debugName,
|
|
1460
1468
|
});
|
|
1461
|
-
base.visible = computed(() => false,
|
|
1469
|
+
base.visible = computed(() => false, /* @ts-ignore */
|
|
1470
|
+
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
1462
1471
|
return base;
|
|
1463
1472
|
}
|
|
1464
1473
|
const state = signal(undefined, {
|
|
@@ -1495,7 +1504,8 @@ function elementVisibility(target = inject(ElementRef), opt) {
|
|
|
1495
1504
|
if (!s)
|
|
1496
1505
|
return false;
|
|
1497
1506
|
return s.isIntersecting;
|
|
1498
|
-
},
|
|
1507
|
+
}, /* @ts-ignore */
|
|
1508
|
+
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
1499
1509
|
return base;
|
|
1500
1510
|
}
|
|
1501
1511
|
|
|
@@ -1577,15 +1587,19 @@ function geolocation(opt) {
|
|
|
1577
1587
|
const sig = computed(() => null, {
|
|
1578
1588
|
debugName: opt?.debugName ?? 'geolocation',
|
|
1579
1589
|
});
|
|
1580
|
-
sig.error = computed(() => null,
|
|
1581
|
-
|
|
1590
|
+
sig.error = computed(() => null, /* @ts-ignore */
|
|
1591
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
1592
|
+
sig.loading = computed(() => false, /* @ts-ignore */
|
|
1593
|
+
...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
1582
1594
|
return sig;
|
|
1583
1595
|
}
|
|
1584
1596
|
const position = signal(null, {
|
|
1585
1597
|
debugName: opt?.debugName ?? 'geolocation',
|
|
1586
1598
|
});
|
|
1587
|
-
const error = signal(null,
|
|
1588
|
-
|
|
1599
|
+
const error = signal(null, /* @ts-ignore */
|
|
1600
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
1601
|
+
const loading = signal(true, /* @ts-ignore */
|
|
1602
|
+
...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
1589
1603
|
const onSuccess = (p) => {
|
|
1590
1604
|
position.set(p);
|
|
1591
1605
|
error.set(null);
|
|
@@ -1636,13 +1650,15 @@ function idle(opt) {
|
|
|
1636
1650
|
const sig = computed(() => false, {
|
|
1637
1651
|
debugName: opt?.debugName ?? 'idle',
|
|
1638
1652
|
});
|
|
1639
|
-
sig.since = computed(() => serverDate$1,
|
|
1653
|
+
sig.since = computed(() => serverDate$1, /* @ts-ignore */
|
|
1654
|
+
...(ngDevMode ? [{ debugName: "since" }] : /* istanbul ignore next */ []));
|
|
1640
1655
|
return sig;
|
|
1641
1656
|
}
|
|
1642
1657
|
const ms = opt?.ms ?? 60_000;
|
|
1643
1658
|
const events = opt?.events ?? DEFAULT_EVENTS;
|
|
1644
1659
|
const state = signal(false, { debugName: opt?.debugName ?? 'idle' });
|
|
1645
|
-
const since = signal(new Date(),
|
|
1660
|
+
const since = signal(new Date(), /* @ts-ignore */
|
|
1661
|
+
...(ngDevMode ? [{ debugName: "since" }] : /* istanbul ignore next */ []));
|
|
1646
1662
|
let timer;
|
|
1647
1663
|
const goIdle = () => {
|
|
1648
1664
|
if (state())
|
|
@@ -1840,7 +1856,8 @@ function throttle(source, opt) {
|
|
|
1840
1856
|
const ms = opt?.ms ?? 0;
|
|
1841
1857
|
const leading = opt?.leading ?? false;
|
|
1842
1858
|
const trailing = opt?.trailing ?? true;
|
|
1843
|
-
const trigger = signal(false,
|
|
1859
|
+
const trigger = signal(false, /* @ts-ignore */
|
|
1860
|
+
...(ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []));
|
|
1844
1861
|
const fire = () => trigger.update((c) => !c);
|
|
1845
1862
|
let timeout;
|
|
1846
1863
|
let pendingTrailing = false;
|
|
@@ -2007,11 +2024,13 @@ function networkStatus(debugName = 'networkStatus') {
|
|
|
2007
2024
|
const sig = computed(() => true, {
|
|
2008
2025
|
debugName,
|
|
2009
2026
|
});
|
|
2010
|
-
sig.since = computed(() => serverDate,
|
|
2027
|
+
sig.since = computed(() => serverDate, /* @ts-ignore */
|
|
2028
|
+
...(ngDevMode ? [{ debugName: "since" }] : /* istanbul ignore next */ []));
|
|
2011
2029
|
return sig;
|
|
2012
2030
|
}
|
|
2013
2031
|
const state = signal(navigator.onLine, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), debugName });
|
|
2014
|
-
const since = signal(new Date(),
|
|
2032
|
+
const since = signal(new Date(), /* @ts-ignore */
|
|
2033
|
+
...(ngDevMode ? [{ debugName: "since" }] : /* istanbul ignore next */ []));
|
|
2015
2034
|
const goOnline = () => {
|
|
2016
2035
|
state.set(true);
|
|
2017
2036
|
since.set(new Date());
|
|
@@ -2399,6 +2418,12 @@ function signalFromEvent(target, eventName, initial, projectOrOpt, maybeOpt) {
|
|
|
2399
2418
|
return untracked(() => state.asReadonly());
|
|
2400
2419
|
}
|
|
2401
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');
|
|
2402
2427
|
const IS_STORE = Symbol('MMSTACK::IS_STORE');
|
|
2403
2428
|
const SCOPE_PARENT = Symbol('MMSTACK::SCOPE_PARENT');
|
|
2404
2429
|
/**
|
|
@@ -2436,6 +2461,8 @@ function isStore(value) {
|
|
|
2436
2461
|
function isRecord(value) {
|
|
2437
2462
|
if (value === null || typeof value !== 'object')
|
|
2438
2463
|
return false;
|
|
2464
|
+
if (value[OPAQUE] === true)
|
|
2465
|
+
return false; // opaque → leaf
|
|
2439
2466
|
const proto = Object.getPrototypeOf(value);
|
|
2440
2467
|
return proto === Object.prototype || proto === null;
|
|
2441
2468
|
}
|
|
@@ -2470,7 +2497,8 @@ function toArrayStore(source, injector, vivify) {
|
|
|
2470
2497
|
if (!Array.isArray(v))
|
|
2471
2498
|
return 0;
|
|
2472
2499
|
return v.length;
|
|
2473
|
-
},
|
|
2500
|
+
}, /* @ts-ignore */
|
|
2501
|
+
...(ngDevMode ? [{ debugName: "lengthSignal" }] : /* istanbul ignore next */ []));
|
|
2474
2502
|
return new Proxy(source, {
|
|
2475
2503
|
has(_, prop) {
|
|
2476
2504
|
if (prop === 'length')
|
|
@@ -2717,7 +2745,8 @@ function scopedStore(parent, seed, kind, injector) {
|
|
|
2717
2745
|
const view = computed(() => ({
|
|
2718
2746
|
...parent(),
|
|
2719
2747
|
...local(),
|
|
2720
|
-
}),
|
|
2748
|
+
}), /* @ts-ignore */
|
|
2749
|
+
...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
|
|
2721
2750
|
const splitSet = (next) => {
|
|
2722
2751
|
const lv = localValue();
|
|
2723
2752
|
const pv = parentValue();
|
|
@@ -2793,6 +2822,22 @@ function store(value, opt) {
|
|
|
2793
2822
|
function mutableStore(value, opt) {
|
|
2794
2823
|
return toStore(mutable(value, opt), opt?.injector, opt?.vivify ?? false);
|
|
2795
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
|
+
}
|
|
2796
2841
|
|
|
2797
2842
|
// Internal dummy store for server-side rendering
|
|
2798
2843
|
const noopStore = {
|
|
@@ -2981,10 +3026,10 @@ class MessageBus {
|
|
|
2981
3026
|
this.channel.removeEventListener('message', listener);
|
|
2982
3027
|
this.listeners.delete(id);
|
|
2983
3028
|
}
|
|
2984
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2985
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
3029
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: MessageBus, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3030
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: MessageBus, providedIn: 'root' });
|
|
2986
3031
|
}
|
|
2987
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
3032
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: MessageBus, decorators: [{
|
|
2988
3033
|
type: Injectable,
|
|
2989
3034
|
args: [{
|
|
2990
3035
|
providedIn: 'root',
|
|
@@ -3058,7 +3103,8 @@ function tabSync(sig, opt) {
|
|
|
3058
3103
|
return;
|
|
3059
3104
|
}
|
|
3060
3105
|
post(val);
|
|
3061
|
-
},
|
|
3106
|
+
}, /* @ts-ignore */
|
|
3107
|
+
...(ngDevMode ? [{ debugName: "effectRef" }] : /* istanbul ignore next */ []));
|
|
3062
3108
|
inject(DestroyRef).onDestroy(() => {
|
|
3063
3109
|
effectRef.destroy();
|
|
3064
3110
|
unsub();
|
|
@@ -3258,9 +3304,12 @@ function withHistory(sourceOrValue, opt) {
|
|
|
3258
3304
|
history.set([]);
|
|
3259
3305
|
redoArray.set([]);
|
|
3260
3306
|
};
|
|
3261
|
-
internal.canUndo = computed(() => history().length > 0,
|
|
3262
|
-
|
|
3263
|
-
internal.
|
|
3307
|
+
internal.canUndo = computed(() => history().length > 0, /* @ts-ignore */
|
|
3308
|
+
...(ngDevMode ? [{ debugName: "canUndo" }] : /* istanbul ignore next */ []));
|
|
3309
|
+
internal.canRedo = computed(() => redoArray().length > 0, /* @ts-ignore */
|
|
3310
|
+
...(ngDevMode ? [{ debugName: "canRedo" }] : /* istanbul ignore next */ []));
|
|
3311
|
+
internal.canClear = computed(() => internal.canUndo() || internal.canRedo(), /* @ts-ignore */
|
|
3312
|
+
...(ngDevMode ? [{ debugName: "canClear" }] : /* istanbul ignore next */ []));
|
|
3264
3313
|
return internal;
|
|
3265
3314
|
}
|
|
3266
3315
|
|
|
@@ -3268,5 +3317,5 @@ function withHistory(sourceOrValue, opt) {
|
|
|
3268
3317
|
* Generated bundle index. Do not edit.
|
|
3269
3318
|
*/
|
|
3270
3319
|
|
|
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 };
|
|
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 };
|
|
3272
3321
|
//# sourceMappingURL=mmstack-primitives.mjs.map
|