@inertiajs/core 2.3.4 → 2.3.6
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 +53 -18
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +53 -18
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
- package/types/history.d.ts +8 -1
- package/types/page.d.ts +1 -0
- package/types/types.d.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -792,12 +792,13 @@ function mergeDataIntoQueryString(method, href, data, qsArrayFormat = "brackets"
|
|
|
792
792
|
const hasHash = href.toString().includes("#");
|
|
793
793
|
const url = new URL(href.toString(), typeof window === "undefined" ? "http://localhost" : window.location.toString());
|
|
794
794
|
if (hasDataForQueryString) {
|
|
795
|
-
const
|
|
795
|
+
const hasIndices = /\[\d+\]/.test(url.search);
|
|
796
|
+
const parseOptions = { ignoreQueryPrefix: true, allowSparse: true };
|
|
796
797
|
url.search = qs.stringify(
|
|
797
798
|
{ ...qs.parse(url.search, parseOptions), ...data },
|
|
798
799
|
{
|
|
799
800
|
encodeValuesOnly: true,
|
|
800
|
-
arrayFormat: qsArrayFormat
|
|
801
|
+
arrayFormat: hasIndices ? "indices" : qsArrayFormat
|
|
801
802
|
}
|
|
802
803
|
);
|
|
803
804
|
}
|
|
@@ -844,6 +845,7 @@ var CurrentPage = class {
|
|
|
844
845
|
this.isFirstPageLoad = true;
|
|
845
846
|
this.cleared = false;
|
|
846
847
|
this.pendingDeferredProps = null;
|
|
848
|
+
this.historyQuotaExceeded = false;
|
|
847
849
|
}
|
|
848
850
|
init({
|
|
849
851
|
initialPage,
|
|
@@ -855,6 +857,9 @@ var CurrentPage = class {
|
|
|
855
857
|
this.swapComponent = swapComponent;
|
|
856
858
|
this.resolveComponent = resolveComponent;
|
|
857
859
|
this.onFlashCallback = onFlash;
|
|
860
|
+
eventHandler.on("historyQuotaExceeded", () => {
|
|
861
|
+
this.historyQuotaExceeded = true;
|
|
862
|
+
});
|
|
858
863
|
return this;
|
|
859
864
|
}
|
|
860
865
|
set(page2, {
|
|
@@ -904,6 +909,10 @@ var CurrentPage = class {
|
|
|
904
909
|
this.fireEventsFor("firstLoad");
|
|
905
910
|
}
|
|
906
911
|
this.isFirstPageLoad = false;
|
|
912
|
+
if (this.historyQuotaExceeded) {
|
|
913
|
+
this.historyQuotaExceeded = false;
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
907
916
|
return this.swap({
|
|
908
917
|
component,
|
|
909
918
|
page: page2,
|
|
@@ -1185,9 +1194,27 @@ var History = class {
|
|
|
1185
1194
|
});
|
|
1186
1195
|
});
|
|
1187
1196
|
}
|
|
1197
|
+
isHistoryThrottleError(error) {
|
|
1198
|
+
return error instanceof Error && error.name === "SecurityError" && (error.message.includes("history.pushState") || error.message.includes("history.replaceState"));
|
|
1199
|
+
}
|
|
1200
|
+
isQuotaExceededError(error) {
|
|
1201
|
+
return error instanceof Error && error.name === "QuotaExceededError";
|
|
1202
|
+
}
|
|
1203
|
+
withThrottleProtection(cb) {
|
|
1204
|
+
return Promise.resolve().then(() => {
|
|
1205
|
+
try {
|
|
1206
|
+
return cb();
|
|
1207
|
+
} catch (error) {
|
|
1208
|
+
if (!this.isHistoryThrottleError(error)) {
|
|
1209
|
+
throw error;
|
|
1210
|
+
}
|
|
1211
|
+
console.error(error.message);
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1188
1215
|
doReplaceState(data, url) {
|
|
1189
|
-
return
|
|
1190
|
-
|
|
1216
|
+
return this.withThrottleProtection(() => {
|
|
1217
|
+
window.history.replaceState(
|
|
1191
1218
|
{
|
|
1192
1219
|
...data,
|
|
1193
1220
|
scrollRegions: data.scrollRegions ?? window.history.state?.scrollRegions,
|
|
@@ -1195,11 +1222,20 @@ var History = class {
|
|
|
1195
1222
|
},
|
|
1196
1223
|
"",
|
|
1197
1224
|
url
|
|
1198
|
-
)
|
|
1199
|
-
);
|
|
1225
|
+
);
|
|
1226
|
+
});
|
|
1200
1227
|
}
|
|
1201
1228
|
doPushState(data, url) {
|
|
1202
|
-
return
|
|
1229
|
+
return this.withThrottleProtection(() => {
|
|
1230
|
+
try {
|
|
1231
|
+
window.history.pushState(data, "", url);
|
|
1232
|
+
} catch (error) {
|
|
1233
|
+
if (!this.isQuotaExceededError(error)) {
|
|
1234
|
+
throw error;
|
|
1235
|
+
}
|
|
1236
|
+
eventHandler.fireInternalEvent("historyQuotaExceeded", url);
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1203
1239
|
}
|
|
1204
1240
|
getState(key, defaultValue) {
|
|
1205
1241
|
return this.current?.[key] ?? defaultValue;
|
|
@@ -1215,8 +1251,8 @@ var History = class {
|
|
|
1215
1251
|
delete this.initialState[key];
|
|
1216
1252
|
}
|
|
1217
1253
|
}
|
|
1218
|
-
|
|
1219
|
-
return !!
|
|
1254
|
+
browserHasHistoryEntry() {
|
|
1255
|
+
return !isServer && !!window.history.state?.page;
|
|
1220
1256
|
}
|
|
1221
1257
|
clear() {
|
|
1222
1258
|
SessionStorage.remove(historySessionStorageKeys.key);
|
|
@@ -1346,7 +1382,7 @@ var InitialVisit = class {
|
|
|
1346
1382
|
}
|
|
1347
1383
|
}
|
|
1348
1384
|
static handleBackForward() {
|
|
1349
|
-
if (!navigationType.isBackForward() || !history.
|
|
1385
|
+
if (!navigationType.isBackForward() || !history.browserHasHistoryEntry()) {
|
|
1350
1386
|
return false;
|
|
1351
1387
|
}
|
|
1352
1388
|
const scrollRegions = history.getScrollRegions();
|
|
@@ -2225,6 +2261,9 @@ var Router = class {
|
|
|
2225
2261
|
eventHandler.on("loadDeferredProps", (deferredProps) => {
|
|
2226
2262
|
this.loadDeferredProps(deferredProps);
|
|
2227
2263
|
});
|
|
2264
|
+
eventHandler.on("historyQuotaExceeded", (url) => {
|
|
2265
|
+
window.location.href = url;
|
|
2266
|
+
});
|
|
2228
2267
|
}
|
|
2229
2268
|
get(url, data = {}, options = {}) {
|
|
2230
2269
|
return this.visit(url, { ...options, method: "get", data });
|
|
@@ -3452,17 +3491,11 @@ function useInfiniteScroll(options) {
|
|
|
3452
3491
|
// After successful request, tag new server content
|
|
3453
3492
|
onCompletePreviousRequest: (loadedPage) => {
|
|
3454
3493
|
options.onCompletePreviousRequest();
|
|
3455
|
-
requestAnimationFrame(() =>
|
|
3456
|
-
elementManager.processServerLoadedElements(loadedPage);
|
|
3457
|
-
elementManager.refreshTriggers();
|
|
3458
|
-
}, 2);
|
|
3494
|
+
requestAnimationFrame(() => elementManager.processServerLoadedElements(loadedPage), 2);
|
|
3459
3495
|
},
|
|
3460
3496
|
onCompleteNextRequest: (loadedPage) => {
|
|
3461
3497
|
options.onCompleteNextRequest();
|
|
3462
|
-
requestAnimationFrame(() =>
|
|
3463
|
-
elementManager.processServerLoadedElements(loadedPage);
|
|
3464
|
-
elementManager.refreshTriggers();
|
|
3465
|
-
}, 2);
|
|
3498
|
+
requestAnimationFrame(() => elementManager.processServerLoadedElements(loadedPage), 2);
|
|
3466
3499
|
}
|
|
3467
3500
|
});
|
|
3468
3501
|
const addScrollPreservationCallbacks = (reloadOptions) => {
|
|
@@ -3495,10 +3528,12 @@ function useInfiniteScroll(options) {
|
|
|
3495
3528
|
}
|
|
3496
3529
|
originalFetchPrevious(reloadOptions);
|
|
3497
3530
|
};
|
|
3531
|
+
const removeEventListener = router.on("success", () => requestAnimationFrame(elementManager.refreshTriggers, 2));
|
|
3498
3532
|
return {
|
|
3499
3533
|
dataManager,
|
|
3500
3534
|
elementManager,
|
|
3501
3535
|
flush: () => {
|
|
3536
|
+
removeEventListener();
|
|
3502
3537
|
dataManager.removeEventListener();
|
|
3503
3538
|
elementManager.flushAll();
|
|
3504
3539
|
queryStringManager.cancel();
|