@inertiajs/core 2.3.8 → 2.3.9
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 +43 -14
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +43 -14
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/types/request.d.ts +3 -2
- package/types/requestParams.d.ts +1 -0
- package/types/requestStream.d.ts +6 -4
- package/types/router.d.ts +6 -1
- package/types/types.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -874,6 +874,9 @@ var CurrentPage = class {
|
|
|
874
874
|
component: page2.component,
|
|
875
875
|
url: page2.url
|
|
876
876
|
};
|
|
877
|
+
if (page2.initialDeferredProps === void 0) {
|
|
878
|
+
page2.initialDeferredProps = page2.deferredProps;
|
|
879
|
+
}
|
|
877
880
|
}
|
|
878
881
|
this.componentId = {};
|
|
879
882
|
const componentId = this.componentId;
|
|
@@ -1334,10 +1337,21 @@ var EventHandler = class {
|
|
|
1334
1337
|
this.onMissingHistoryItem();
|
|
1335
1338
|
return;
|
|
1336
1339
|
}
|
|
1337
|
-
router.cancelAll();
|
|
1340
|
+
router.cancelAll({ prefetch: false });
|
|
1338
1341
|
page.setQuietly(data, { preserveState: false }).then(() => {
|
|
1339
1342
|
Scroll.restore(history.getScrollRegions());
|
|
1340
1343
|
fireNavigateEvent(page.get());
|
|
1344
|
+
const pendingDeferred = {};
|
|
1345
|
+
const pageProps = page.get().props;
|
|
1346
|
+
for (const [group, props] of Object.entries(data.initialDeferredProps ?? data.deferredProps ?? {})) {
|
|
1347
|
+
const missing = props.filter((prop) => pageProps[prop] === void 0);
|
|
1348
|
+
if (missing.length > 0) {
|
|
1349
|
+
pendingDeferred[group] = missing;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
if (Object.keys(pendingDeferred).length > 0) {
|
|
1353
|
+
this.fireInternalEvent("loadDeferredProps", pendingDeferred);
|
|
1354
|
+
}
|
|
1341
1355
|
});
|
|
1342
1356
|
}).catch(() => {
|
|
1343
1357
|
this.onMissingHistoryItem();
|
|
@@ -1570,6 +1584,9 @@ var RequestParams = class _RequestParams {
|
|
|
1570
1584
|
isPartial() {
|
|
1571
1585
|
return this.params.only.length > 0 || this.params.except.length > 0 || this.params.reset.length > 0;
|
|
1572
1586
|
}
|
|
1587
|
+
isPrefetch() {
|
|
1588
|
+
return this.params.prefetch === true;
|
|
1589
|
+
}
|
|
1573
1590
|
isDeferredPropsRequest() {
|
|
1574
1591
|
return this.params.deferredProps === true;
|
|
1575
1592
|
}
|
|
@@ -2023,6 +2040,10 @@ var Response = class _Response {
|
|
|
2023
2040
|
...page.get().flash,
|
|
2024
2041
|
...this.requestParams.isDeferredPropsRequest() ? {} : pageResponse.flash
|
|
2025
2042
|
};
|
|
2043
|
+
const currentOriginalDeferred = page.get().initialDeferredProps;
|
|
2044
|
+
if (currentOriginalDeferred && Object.keys(currentOriginalDeferred).length > 0) {
|
|
2045
|
+
pageResponse.initialDeferredProps = currentOriginalDeferred;
|
|
2046
|
+
}
|
|
2026
2047
|
}
|
|
2027
2048
|
mergeOrMatchItems(existingItems, newItems, matchProp, matchPropsOn, shouldAppend = true) {
|
|
2028
2049
|
const items = Array.isArray(existingItems) ? existingItems : [];
|
|
@@ -2096,6 +2117,9 @@ var Request = class _Request {
|
|
|
2096
2117
|
static create(params, page2) {
|
|
2097
2118
|
return new _Request(params, page2);
|
|
2098
2119
|
}
|
|
2120
|
+
isPrefetch() {
|
|
2121
|
+
return this.requestParams.isPrefetch();
|
|
2122
|
+
}
|
|
2099
2123
|
async send() {
|
|
2100
2124
|
this.requestParams.onCancelToken(() => this.cancel({ cancelled: true }));
|
|
2101
2125
|
fireStartEvent(this.requestParams.all());
|
|
@@ -2212,20 +2236,17 @@ var RequestStream = class {
|
|
|
2212
2236
|
interruptInFlight() {
|
|
2213
2237
|
this.cancel({ interrupted: true }, false);
|
|
2214
2238
|
}
|
|
2215
|
-
cancelInFlight() {
|
|
2216
|
-
this.cancel({ cancelled: true }
|
|
2239
|
+
cancelInFlight({ prefetch = true } = {}) {
|
|
2240
|
+
this.requests.filter((request) => prefetch || !request.isPrefetch()).forEach((request) => request.cancel({ cancelled: true }));
|
|
2217
2241
|
}
|
|
2218
|
-
cancel({ cancelled = false, interrupted = false } = {}, force) {
|
|
2219
|
-
if (!this.shouldCancel(
|
|
2242
|
+
cancel({ cancelled = false, interrupted = false } = {}, force = false) {
|
|
2243
|
+
if (!force && !this.shouldCancel()) {
|
|
2220
2244
|
return;
|
|
2221
2245
|
}
|
|
2222
2246
|
const request = this.requests.shift();
|
|
2223
|
-
request?.cancel({
|
|
2247
|
+
request?.cancel({ cancelled, interrupted });
|
|
2224
2248
|
}
|
|
2225
|
-
shouldCancel(
|
|
2226
|
-
if (force) {
|
|
2227
|
-
return true;
|
|
2228
|
-
}
|
|
2249
|
+
shouldCancel() {
|
|
2229
2250
|
return this.interruptible && this.requests.length >= this.maxConcurrent;
|
|
2230
2251
|
}
|
|
2231
2252
|
};
|
|
@@ -2315,11 +2336,14 @@ var Router = class {
|
|
|
2315
2336
|
}
|
|
2316
2337
|
return eventHandler.onGlobalEvent(type, callback);
|
|
2317
2338
|
}
|
|
2339
|
+
/**
|
|
2340
|
+
* @deprecated Use cancelAll() instead.
|
|
2341
|
+
*/
|
|
2318
2342
|
cancel() {
|
|
2319
2343
|
this.syncRequestStream.cancelInFlight();
|
|
2320
2344
|
}
|
|
2321
|
-
cancelAll() {
|
|
2322
|
-
this.asyncRequestStream.cancelInFlight();
|
|
2345
|
+
cancelAll({ prefetch = true } = {}) {
|
|
2346
|
+
this.asyncRequestStream.cancelInFlight({ prefetch });
|
|
2323
2347
|
this.syncRequestStream.cancelInFlight();
|
|
2324
2348
|
}
|
|
2325
2349
|
poll(interval, requestOptions = {}, options = {}) {
|
|
@@ -2337,8 +2361,12 @@ var Router = class {
|
|
|
2337
2361
|
if (events.onBefore(visit) === false || !fireBeforeEvent(visit)) {
|
|
2338
2362
|
return;
|
|
2339
2363
|
}
|
|
2340
|
-
|
|
2341
|
-
|
|
2364
|
+
if (!isSameUrlWithoutHash(visit.url, hrefToUrl(page.get().url))) {
|
|
2365
|
+
this.asyncRequestStream.cancelInFlight({ prefetch: false });
|
|
2366
|
+
}
|
|
2367
|
+
if (!visit.async) {
|
|
2368
|
+
this.syncRequestStream.interruptInFlight();
|
|
2369
|
+
}
|
|
2342
2370
|
if (!page.isCleared() && !visit.preserveUrl) {
|
|
2343
2371
|
Scroll.save();
|
|
2344
2372
|
}
|
|
@@ -2352,6 +2380,7 @@ var Router = class {
|
|
|
2352
2380
|
prefetchedRequests.use(prefetched, requestParams);
|
|
2353
2381
|
} else {
|
|
2354
2382
|
progress.reveal(true);
|
|
2383
|
+
const requestStream = visit.async ? this.asyncRequestStream : this.syncRequestStream;
|
|
2355
2384
|
requestStream.send(Request.create(requestParams, page.get()));
|
|
2356
2385
|
}
|
|
2357
2386
|
}
|