phase 0.5.3 → 0.5.4
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.
|
@@ -1361,12 +1361,16 @@ function createPointer(options) {
|
|
|
1361
1361
|
//#endregion
|
|
1362
1362
|
//#region src/core/_internal/pool/ro-pool.ts
|
|
1363
1363
|
let observer = null;
|
|
1364
|
+
let delivery = 0;
|
|
1364
1365
|
const callbacks = /* @__PURE__ */ new Map();
|
|
1366
|
+
const latestEntries = /* @__PURE__ */ new Map();
|
|
1365
1367
|
/**
|
|
1366
1368
|
* Observe an element via a singleton ResizeObserver.
|
|
1367
1369
|
* One RO instance for the entire page. An element may have any number of
|
|
1368
|
-
* subscribers; each receives every entry delivered after it subscribes
|
|
1369
|
-
* the
|
|
1370
|
+
* subscribers; each receives every entry delivered after it subscribes. A new
|
|
1371
|
+
* subscriber also receives the latest entry in a queued microtask unless it
|
|
1372
|
+
* cleans up or receives a native entry first. The callback's second argument
|
|
1373
|
+
* identifies native and replayed entries.
|
|
1370
1374
|
*
|
|
1371
1375
|
* Per-element `box` options are forwarded to `ResizeObserver.observe()`. A
|
|
1372
1376
|
* single RO holds one observation per target, so when subscribers disagree on
|
|
@@ -1380,12 +1384,18 @@ const callbacks = /* @__PURE__ */ new Map();
|
|
|
1380
1384
|
function observeResize(element, callback, box) {
|
|
1381
1385
|
let subscribers = callbacks.get(element);
|
|
1382
1386
|
if (!subscribers) {
|
|
1383
|
-
subscribers = /* @__PURE__ */ new
|
|
1387
|
+
subscribers = /* @__PURE__ */ new Map();
|
|
1384
1388
|
callbacks.set(element, subscribers);
|
|
1385
1389
|
}
|
|
1386
|
-
subscribers.
|
|
1390
|
+
const isNewSubscriber = !subscribers.has(callback);
|
|
1391
|
+
if (isNewSubscriber) subscribers.set(callback, delivery);
|
|
1387
1392
|
getObserver().observe(element, box ? { box } : void 0);
|
|
1388
1393
|
let disposed = false;
|
|
1394
|
+
const latestEntry = latestEntries.get(element);
|
|
1395
|
+
if (latestEntry && isNewSubscriber) queueMicrotask(() => {
|
|
1396
|
+
if (disposed || !callbacks.get(element)?.has(callback) || latestEntries.get(element) !== latestEntry) return;
|
|
1397
|
+
callback(latestEntry, "replay");
|
|
1398
|
+
});
|
|
1389
1399
|
return () => {
|
|
1390
1400
|
if (disposed) return;
|
|
1391
1401
|
disposed = true;
|
|
@@ -1394,6 +1404,7 @@ function observeResize(element, callback, box) {
|
|
|
1394
1404
|
current.delete(callback);
|
|
1395
1405
|
if (current.size > 0) return;
|
|
1396
1406
|
callbacks.delete(element);
|
|
1407
|
+
latestEntries.delete(element);
|
|
1397
1408
|
observer?.unobserve(element);
|
|
1398
1409
|
};
|
|
1399
1410
|
}
|
|
@@ -1402,12 +1413,17 @@ function getObserver() {
|
|
|
1402
1413
|
if (!observer) observer = new ResizeObserver((entries) => {
|
|
1403
1414
|
for (const entry of entries) {
|
|
1404
1415
|
const subscribers = callbacks.get(entry.target);
|
|
1405
|
-
if (
|
|
1406
|
-
for (const cb of subscribers) cb(entry);
|
|
1416
|
+
if (subscribers) dispatchEntry(entry, subscribers);
|
|
1407
1417
|
}
|
|
1408
1418
|
});
|
|
1409
1419
|
return observer;
|
|
1410
1420
|
}
|
|
1421
|
+
/** Cache and deliver one native entry without consuming subscribers added during delivery. */
|
|
1422
|
+
function dispatchEntry(entry, subscribers) {
|
|
1423
|
+
const currentDelivery = ++delivery;
|
|
1424
|
+
latestEntries.set(entry.target, entry);
|
|
1425
|
+
for (const [callback, joinedDelivery] of subscribers) if (joinedDelivery < currentDelivery) callback(entry, "native");
|
|
1426
|
+
}
|
|
1411
1427
|
//#endregion
|
|
1412
1428
|
//#region src/core/scroll/index.ts
|
|
1413
1429
|
/**
|
|
@@ -1511,11 +1527,15 @@ function createScroll(options) {
|
|
|
1511
1527
|
geometryDirty = true;
|
|
1512
1528
|
scheduleInput(flush);
|
|
1513
1529
|
}
|
|
1530
|
+
function onObservedResize(_entry, source) {
|
|
1531
|
+
if (source === "replay") return;
|
|
1532
|
+
onROResize();
|
|
1533
|
+
}
|
|
1514
1534
|
function attachListeners() {
|
|
1515
1535
|
if (listenersAttached) return;
|
|
1516
1536
|
listenersAttached = true;
|
|
1517
1537
|
target.addEventListener("scroll", onScrollEvent, { passive: true });
|
|
1518
|
-
unobserveRO = observeResize(scroller,
|
|
1538
|
+
unobserveRO = observeResize(scroller, onObservedResize);
|
|
1519
1539
|
if (pageDoc) window.addEventListener("resize", onROResize);
|
|
1520
1540
|
measure();
|
|
1521
1541
|
}
|
|
@@ -1797,4 +1817,4 @@ function createDebounce(options) {
|
|
|
1797
1817
|
//#endregion
|
|
1798
1818
|
export { isPhaseError as C, linkAbortSignal as E, invalidDurationError as S, serverContextError as T, subscribeMediaQuery as _, createPointer as a, PhaseError as b, prefersReducedMotion as c, subscribeDpr as d, createRenderState as f, readMediaQuery as g, createLifecycle as h, observeResize as i, whenIdle as l, createLoop as m, createThrottle as n, createMutation as o, createScrollProgress as p, createScroll as r, REDUCED_MOTION_QUERY as s, createDebounce as t, readDpr as u, createSight as v, missingContextError as w, conflictingTargetError as x, createTicker as y };
|
|
1799
1819
|
|
|
1800
|
-
//# sourceMappingURL=debounce-
|
|
1820
|
+
//# sourceMappingURL=debounce-BXaDKI4t.js.map
|