@inertiajs/core 2.3.23 → 2.3.24
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/dist/index.esm.js +119 -25
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +119 -25
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/types/infiniteScroll/data.d.ts +11 -2
- package/types/modal.d.ts +1 -0
- package/types/poll.d.ts +18 -3
- package/types/polls.d.ts +4 -2
- package/types/router.d.ts +3 -1
- package/types/types.d.ts +9 -7
package/dist/index.js
CHANGED
|
@@ -1618,11 +1618,17 @@ var InitialVisit = class {
|
|
|
1618
1618
|
// src/poll.ts
|
|
1619
1619
|
var Poll = class {
|
|
1620
1620
|
constructor(interval, cb, options) {
|
|
1621
|
-
this.
|
|
1621
|
+
this.intervalId = null;
|
|
1622
|
+
this.timeoutId = null;
|
|
1622
1623
|
this.throttle = false;
|
|
1623
1624
|
this.keepAlive = false;
|
|
1624
1625
|
this.cbCount = 0;
|
|
1626
|
+
this.inFlight = false;
|
|
1627
|
+
this.currentCancel = null;
|
|
1628
|
+
this.stopped = true;
|
|
1629
|
+
this.instanceId = 0;
|
|
1625
1630
|
this.keepAlive = options.keepAlive ?? false;
|
|
1631
|
+
this.mode = options.mode ?? "overlap";
|
|
1626
1632
|
this.cb = cb;
|
|
1627
1633
|
this.interval = interval;
|
|
1628
1634
|
if (options.autoStart ?? true) {
|
|
@@ -1630,8 +1636,17 @@ var Poll = class {
|
|
|
1630
1636
|
}
|
|
1631
1637
|
}
|
|
1632
1638
|
stop() {
|
|
1633
|
-
|
|
1634
|
-
|
|
1639
|
+
this.stopped = true;
|
|
1640
|
+
this.instanceId++;
|
|
1641
|
+
this.inFlight = false;
|
|
1642
|
+
this.currentCancel = null;
|
|
1643
|
+
if (this.intervalId) {
|
|
1644
|
+
clearInterval(this.intervalId);
|
|
1645
|
+
this.intervalId = null;
|
|
1646
|
+
}
|
|
1647
|
+
if (this.timeoutId) {
|
|
1648
|
+
clearTimeout(this.timeoutId);
|
|
1649
|
+
this.timeoutId = null;
|
|
1635
1650
|
}
|
|
1636
1651
|
}
|
|
1637
1652
|
start() {
|
|
@@ -1639,14 +1654,12 @@ var Poll = class {
|
|
|
1639
1654
|
return;
|
|
1640
1655
|
}
|
|
1641
1656
|
this.stop();
|
|
1642
|
-
this.
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
}
|
|
1649
|
-
}, this.interval);
|
|
1657
|
+
this.stopped = false;
|
|
1658
|
+
if (this.mode === "rest") {
|
|
1659
|
+
this.scheduleNext();
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
this.intervalId = window.setInterval(() => this.tick(), this.interval);
|
|
1650
1663
|
}
|
|
1651
1664
|
isInBackground(hidden) {
|
|
1652
1665
|
this.throttle = this.keepAlive ? false : hidden;
|
|
@@ -1654,6 +1667,50 @@ var Poll = class {
|
|
|
1654
1667
|
this.cbCount = 0;
|
|
1655
1668
|
}
|
|
1656
1669
|
}
|
|
1670
|
+
scheduleNext() {
|
|
1671
|
+
if (this.stopped) {
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
this.timeoutId = window.setTimeout(() => {
|
|
1675
|
+
this.timeoutId = null;
|
|
1676
|
+
this.tick();
|
|
1677
|
+
}, this.interval);
|
|
1678
|
+
}
|
|
1679
|
+
tick() {
|
|
1680
|
+
if (!this.throttle || this.cbCount % 10 === 0) {
|
|
1681
|
+
this.fire();
|
|
1682
|
+
} else if (this.mode === "rest") {
|
|
1683
|
+
this.scheduleNext();
|
|
1684
|
+
}
|
|
1685
|
+
if (this.throttle) {
|
|
1686
|
+
this.cbCount++;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
fire() {
|
|
1690
|
+
if (this.inFlight && this.mode === "cancel") {
|
|
1691
|
+
this.currentCancel?.();
|
|
1692
|
+
}
|
|
1693
|
+
const instance = this.instanceId;
|
|
1694
|
+
this.cb({
|
|
1695
|
+
onStart: (cancel) => {
|
|
1696
|
+
if (instance !== this.instanceId) {
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
this.inFlight = true;
|
|
1700
|
+
this.currentCancel = cancel;
|
|
1701
|
+
},
|
|
1702
|
+
onFinish: () => {
|
|
1703
|
+
if (instance !== this.instanceId) {
|
|
1704
|
+
return;
|
|
1705
|
+
}
|
|
1706
|
+
this.inFlight = false;
|
|
1707
|
+
this.currentCancel = null;
|
|
1708
|
+
if (this.mode === "rest") {
|
|
1709
|
+
this.scheduleNext();
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1657
1714
|
};
|
|
1658
1715
|
|
|
1659
1716
|
// src/polls.ts
|
|
@@ -1662,12 +1719,19 @@ var Polls = class {
|
|
|
1662
1719
|
this.polls = [];
|
|
1663
1720
|
this.setupVisibilityListener();
|
|
1664
1721
|
}
|
|
1722
|
+
get count() {
|
|
1723
|
+
return this.polls.length;
|
|
1724
|
+
}
|
|
1665
1725
|
add(interval, cb, options) {
|
|
1666
1726
|
const poll = new Poll(interval, cb, options);
|
|
1667
1727
|
this.polls.push(poll);
|
|
1668
1728
|
return {
|
|
1669
1729
|
stop: () => poll.stop(),
|
|
1670
|
-
start: () => poll.start()
|
|
1730
|
+
start: () => poll.start(),
|
|
1731
|
+
destroy: () => {
|
|
1732
|
+
poll.stop();
|
|
1733
|
+
this.polls = this.polls.filter((p) => p !== poll);
|
|
1734
|
+
}
|
|
1671
1735
|
};
|
|
1672
1736
|
}
|
|
1673
1737
|
clear() {
|
|
@@ -1846,6 +1910,7 @@ var import_lodash_es4 = require("lodash-es");
|
|
|
1846
1910
|
var modal_default = {
|
|
1847
1911
|
modal: null,
|
|
1848
1912
|
listener: null,
|
|
1913
|
+
previousBodyOverflow: null,
|
|
1849
1914
|
createIframeAndPage(html) {
|
|
1850
1915
|
if (typeof html === "object") {
|
|
1851
1916
|
html = `All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.<hr>${JSON.stringify(
|
|
@@ -1876,6 +1941,7 @@ var modal_default = {
|
|
|
1876
1941
|
this.modal.addEventListener("click", () => this.hide());
|
|
1877
1942
|
this.modal.appendChild(iframe);
|
|
1878
1943
|
document.body.prepend(this.modal);
|
|
1944
|
+
this.previousBodyOverflow = document.body.style.overflow;
|
|
1879
1945
|
document.body.style.overflow = "hidden";
|
|
1880
1946
|
iframe.srcdoc = page2.outerHTML;
|
|
1881
1947
|
this.listener = this.hideOnEscape.bind(this);
|
|
@@ -1884,7 +1950,8 @@ var modal_default = {
|
|
|
1884
1950
|
hide() {
|
|
1885
1951
|
this.modal.outerHTML = "";
|
|
1886
1952
|
this.modal = null;
|
|
1887
|
-
document.body.style.overflow = "
|
|
1953
|
+
document.body.style.overflow = this.previousBodyOverflow ?? "";
|
|
1954
|
+
this.previousBodyOverflow = null;
|
|
1888
1955
|
document.removeEventListener("keydown", this.listener);
|
|
1889
1956
|
},
|
|
1890
1957
|
hideOnEscape(event) {
|
|
@@ -2485,6 +2552,9 @@ var Router = class {
|
|
|
2485
2552
|
cancel() {
|
|
2486
2553
|
this.syncRequestStream.cancelInFlight();
|
|
2487
2554
|
}
|
|
2555
|
+
get activePolls() {
|
|
2556
|
+
return polls.count;
|
|
2557
|
+
}
|
|
2488
2558
|
cancelAll({ async = true, prefetch = true, sync = true } = {}) {
|
|
2489
2559
|
if (async) {
|
|
2490
2560
|
this.asyncRequestStream.cancelInFlight({ prefetch });
|
|
@@ -2494,10 +2564,28 @@ var Router = class {
|
|
|
2494
2564
|
}
|
|
2495
2565
|
}
|
|
2496
2566
|
poll(interval, requestOptions = {}, options = {}) {
|
|
2497
|
-
return polls.add(
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2567
|
+
return polls.add(
|
|
2568
|
+
interval,
|
|
2569
|
+
({ onStart, onFinish }) => {
|
|
2570
|
+
const resolved = typeof requestOptions === "function" ? requestOptions() : requestOptions;
|
|
2571
|
+
this.reload({
|
|
2572
|
+
...resolved,
|
|
2573
|
+
onCancelToken: (token) => {
|
|
2574
|
+
onStart(token.cancel);
|
|
2575
|
+
resolved.onCancelToken?.(token);
|
|
2576
|
+
},
|
|
2577
|
+
onFinish: (visit) => {
|
|
2578
|
+
onFinish();
|
|
2579
|
+
resolved.onFinish?.(visit);
|
|
2580
|
+
}
|
|
2581
|
+
});
|
|
2582
|
+
},
|
|
2583
|
+
{
|
|
2584
|
+
autoStart: options.autoStart ?? true,
|
|
2585
|
+
keepAlive: options.keepAlive ?? false,
|
|
2586
|
+
mode: options.mode
|
|
2587
|
+
}
|
|
2588
|
+
);
|
|
2501
2589
|
}
|
|
2502
2590
|
visit(href, options = {}) {
|
|
2503
2591
|
const visit = this.getPendingVisit(href, {
|
|
@@ -3225,7 +3313,9 @@ var useInfiniteScrollData = (options) => {
|
|
|
3225
3313
|
},
|
|
3226
3314
|
onFinish: (visit) => {
|
|
3227
3315
|
state.loading = false;
|
|
3228
|
-
|
|
3316
|
+
const completed = visit.completed;
|
|
3317
|
+
const page3 = completed ? state.lastLoadedPage : null;
|
|
3318
|
+
side === "next" ? options.onCompleteNextRequest(page3, { page: page3, completed }) : options.onCompletePreviousRequest(page3, { page: page3, completed });
|
|
3229
3319
|
reloadOptions.onFinish?.(visit);
|
|
3230
3320
|
}
|
|
3231
3321
|
});
|
|
@@ -3577,13 +3667,17 @@ function useInfiniteScroll(options) {
|
|
|
3577
3667
|
// so they don't get confused with server-loaded content
|
|
3578
3668
|
onBeforeUpdate: elementManager.processManuallyAddedElements,
|
|
3579
3669
|
// After successful request, tag new server content
|
|
3580
|
-
onCompletePreviousRequest: (
|
|
3581
|
-
options.onCompletePreviousRequest();
|
|
3582
|
-
|
|
3670
|
+
onCompletePreviousRequest: (_, details) => {
|
|
3671
|
+
options.onCompletePreviousRequest(details);
|
|
3672
|
+
if (details.completed) {
|
|
3673
|
+
requestAnimationFrame(() => elementManager.processServerLoadedElements(details.page), 2);
|
|
3674
|
+
}
|
|
3583
3675
|
},
|
|
3584
|
-
onCompleteNextRequest: (
|
|
3585
|
-
options.onCompleteNextRequest();
|
|
3586
|
-
|
|
3676
|
+
onCompleteNextRequest: (_, details) => {
|
|
3677
|
+
options.onCompleteNextRequest(details);
|
|
3678
|
+
if (details.completed) {
|
|
3679
|
+
requestAnimationFrame(() => elementManager.processServerLoadedElements(details.page), 2);
|
|
3680
|
+
}
|
|
3587
3681
|
},
|
|
3588
3682
|
onReset: options.onDataReset
|
|
3589
3683
|
});
|
|
@@ -4006,7 +4100,7 @@ function setupProgress({
|
|
|
4006
4100
|
}
|
|
4007
4101
|
|
|
4008
4102
|
// src/resetFormFields.ts
|
|
4009
|
-
var FormComponentResetSymbol =
|
|
4103
|
+
var FormComponentResetSymbol = Symbol("FormComponentReset");
|
|
4010
4104
|
function isFormElement(element) {
|
|
4011
4105
|
return element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement;
|
|
4012
4106
|
}
|