@inertiajs/core 2.3.4 → 2.3.5
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 +50 -16
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +50 -16
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/types/history.d.ts +8 -1
- package/types/page.d.ts +1 -0
- package/types/types.d.ts +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -787,6 +787,7 @@ var CurrentPage = class {
|
|
|
787
787
|
this.isFirstPageLoad = true;
|
|
788
788
|
this.cleared = false;
|
|
789
789
|
this.pendingDeferredProps = null;
|
|
790
|
+
this.historyQuotaExceeded = false;
|
|
790
791
|
}
|
|
791
792
|
init({
|
|
792
793
|
initialPage,
|
|
@@ -798,6 +799,9 @@ var CurrentPage = class {
|
|
|
798
799
|
this.swapComponent = swapComponent;
|
|
799
800
|
this.resolveComponent = resolveComponent;
|
|
800
801
|
this.onFlashCallback = onFlash;
|
|
802
|
+
eventHandler.on("historyQuotaExceeded", () => {
|
|
803
|
+
this.historyQuotaExceeded = true;
|
|
804
|
+
});
|
|
801
805
|
return this;
|
|
802
806
|
}
|
|
803
807
|
set(page2, {
|
|
@@ -847,6 +851,10 @@ var CurrentPage = class {
|
|
|
847
851
|
this.fireEventsFor("firstLoad");
|
|
848
852
|
}
|
|
849
853
|
this.isFirstPageLoad = false;
|
|
854
|
+
if (this.historyQuotaExceeded) {
|
|
855
|
+
this.historyQuotaExceeded = false;
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
850
858
|
return this.swap({
|
|
851
859
|
component,
|
|
852
860
|
page: page2,
|
|
@@ -1128,9 +1136,27 @@ var History = class {
|
|
|
1128
1136
|
});
|
|
1129
1137
|
});
|
|
1130
1138
|
}
|
|
1139
|
+
isHistoryThrottleError(error) {
|
|
1140
|
+
return error instanceof Error && error.name === "SecurityError" && (error.message.includes("history.pushState") || error.message.includes("history.replaceState"));
|
|
1141
|
+
}
|
|
1142
|
+
isQuotaExceededError(error) {
|
|
1143
|
+
return error instanceof Error && error.name === "QuotaExceededError";
|
|
1144
|
+
}
|
|
1145
|
+
withThrottleProtection(cb) {
|
|
1146
|
+
return Promise.resolve().then(() => {
|
|
1147
|
+
try {
|
|
1148
|
+
return cb();
|
|
1149
|
+
} catch (error) {
|
|
1150
|
+
if (!this.isHistoryThrottleError(error)) {
|
|
1151
|
+
throw error;
|
|
1152
|
+
}
|
|
1153
|
+
console.error(error.message);
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1131
1157
|
doReplaceState(data, url) {
|
|
1132
|
-
return
|
|
1133
|
-
|
|
1158
|
+
return this.withThrottleProtection(() => {
|
|
1159
|
+
window.history.replaceState(
|
|
1134
1160
|
{
|
|
1135
1161
|
...data,
|
|
1136
1162
|
scrollRegions: data.scrollRegions ?? window.history.state?.scrollRegions,
|
|
@@ -1138,11 +1164,20 @@ var History = class {
|
|
|
1138
1164
|
},
|
|
1139
1165
|
"",
|
|
1140
1166
|
url
|
|
1141
|
-
)
|
|
1142
|
-
);
|
|
1167
|
+
);
|
|
1168
|
+
});
|
|
1143
1169
|
}
|
|
1144
1170
|
doPushState(data, url) {
|
|
1145
|
-
return
|
|
1171
|
+
return this.withThrottleProtection(() => {
|
|
1172
|
+
try {
|
|
1173
|
+
window.history.pushState(data, "", url);
|
|
1174
|
+
} catch (error) {
|
|
1175
|
+
if (!this.isQuotaExceededError(error)) {
|
|
1176
|
+
throw error;
|
|
1177
|
+
}
|
|
1178
|
+
eventHandler.fireInternalEvent("historyQuotaExceeded", url);
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1146
1181
|
}
|
|
1147
1182
|
getState(key, defaultValue) {
|
|
1148
1183
|
return this.current?.[key] ?? defaultValue;
|
|
@@ -1158,8 +1193,8 @@ var History = class {
|
|
|
1158
1193
|
delete this.initialState[key];
|
|
1159
1194
|
}
|
|
1160
1195
|
}
|
|
1161
|
-
|
|
1162
|
-
return !!
|
|
1196
|
+
browserHasHistoryEntry() {
|
|
1197
|
+
return !isServer && !!window.history.state?.page;
|
|
1163
1198
|
}
|
|
1164
1199
|
clear() {
|
|
1165
1200
|
SessionStorage.remove(historySessionStorageKeys.key);
|
|
@@ -1289,7 +1324,7 @@ var InitialVisit = class {
|
|
|
1289
1324
|
}
|
|
1290
1325
|
}
|
|
1291
1326
|
static handleBackForward() {
|
|
1292
|
-
if (!navigationType.isBackForward() || !history.
|
|
1327
|
+
if (!navigationType.isBackForward() || !history.browserHasHistoryEntry()) {
|
|
1293
1328
|
return false;
|
|
1294
1329
|
}
|
|
1295
1330
|
const scrollRegions = history.getScrollRegions();
|
|
@@ -2168,6 +2203,9 @@ var Router = class {
|
|
|
2168
2203
|
eventHandler.on("loadDeferredProps", (deferredProps) => {
|
|
2169
2204
|
this.loadDeferredProps(deferredProps);
|
|
2170
2205
|
});
|
|
2206
|
+
eventHandler.on("historyQuotaExceeded", (url) => {
|
|
2207
|
+
window.location.href = url;
|
|
2208
|
+
});
|
|
2171
2209
|
}
|
|
2172
2210
|
get(url, data = {}, options = {}) {
|
|
2173
2211
|
return this.visit(url, { ...options, method: "get", data });
|
|
@@ -3395,17 +3433,11 @@ function useInfiniteScroll(options) {
|
|
|
3395
3433
|
// After successful request, tag new server content
|
|
3396
3434
|
onCompletePreviousRequest: (loadedPage) => {
|
|
3397
3435
|
options.onCompletePreviousRequest();
|
|
3398
|
-
requestAnimationFrame(() =>
|
|
3399
|
-
elementManager.processServerLoadedElements(loadedPage);
|
|
3400
|
-
elementManager.refreshTriggers();
|
|
3401
|
-
}, 2);
|
|
3436
|
+
requestAnimationFrame(() => elementManager.processServerLoadedElements(loadedPage), 2);
|
|
3402
3437
|
},
|
|
3403
3438
|
onCompleteNextRequest: (loadedPage) => {
|
|
3404
3439
|
options.onCompleteNextRequest();
|
|
3405
|
-
requestAnimationFrame(() =>
|
|
3406
|
-
elementManager.processServerLoadedElements(loadedPage);
|
|
3407
|
-
elementManager.refreshTriggers();
|
|
3408
|
-
}, 2);
|
|
3440
|
+
requestAnimationFrame(() => elementManager.processServerLoadedElements(loadedPage), 2);
|
|
3409
3441
|
}
|
|
3410
3442
|
});
|
|
3411
3443
|
const addScrollPreservationCallbacks = (reloadOptions) => {
|
|
@@ -3438,10 +3470,12 @@ function useInfiniteScroll(options) {
|
|
|
3438
3470
|
}
|
|
3439
3471
|
originalFetchPrevious(reloadOptions);
|
|
3440
3472
|
};
|
|
3473
|
+
const removeEventListener = router.on("success", () => requestAnimationFrame(elementManager.refreshTriggers, 2));
|
|
3441
3474
|
return {
|
|
3442
3475
|
dataManager,
|
|
3443
3476
|
elementManager,
|
|
3444
3477
|
flush: () => {
|
|
3478
|
+
removeEventListener();
|
|
3445
3479
|
dataManager.removeEventListener();
|
|
3446
3480
|
elementManager.flushAll();
|
|
3447
3481
|
queryStringManager.cancel();
|