@inertiajs/core 3.0.3 → 3.1.1
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.js +68 -12
- package/dist/index.js.map +3 -3
- package/dist/server.js +2 -2
- package/dist/server.js.map +2 -2
- package/package.json +3 -3
- package/types/index.d.ts +1 -0
- package/types/objectUtils.d.ts +1 -0
- package/types/partialReload.d.ts +6 -0
- package/types/response.d.ts +1 -0
- package/types/server.d.ts +1 -0
- package/types/types.d.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -281,6 +281,15 @@ import { cloneDeep } from "es-toolkit";
|
|
|
281
281
|
import { get as get2 } from "es-toolkit/compat";
|
|
282
282
|
|
|
283
283
|
// src/objectUtils.ts
|
|
284
|
+
var stripTopLevelUndefined = (obj) => {
|
|
285
|
+
const result = {};
|
|
286
|
+
for (const key of Object.keys(obj)) {
|
|
287
|
+
if (obj[key] !== void 0) {
|
|
288
|
+
result[key] = obj[key];
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return result;
|
|
292
|
+
};
|
|
284
293
|
var objectsAreEqual = (obj1, obj2, excludeKeys) => {
|
|
285
294
|
if (obj1 === obj2) {
|
|
286
295
|
return true;
|
|
@@ -860,6 +869,9 @@ function decode(value) {
|
|
|
860
869
|
}
|
|
861
870
|
function set2(target, key, value) {
|
|
862
871
|
const keys = parseKey(key);
|
|
872
|
+
if (keys.some((k) => k === "__proto__")) {
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
863
875
|
let current = target;
|
|
864
876
|
while (keys.length > 1) {
|
|
865
877
|
const segment = keys.shift();
|
|
@@ -1015,7 +1027,7 @@ var CurrentPage = class {
|
|
|
1015
1027
|
resolveComponent,
|
|
1016
1028
|
onFlash
|
|
1017
1029
|
}) {
|
|
1018
|
-
this.page = { ...initialPage, flash: initialPage.flash ?? {} };
|
|
1030
|
+
this.page = { ...initialPage, flash: initialPage.flash ?? {}, rescuedProps: initialPage.rescuedProps ?? [] };
|
|
1019
1031
|
this.swapComponent = swapComponent;
|
|
1020
1032
|
this.resolveComponent = resolveComponent;
|
|
1021
1033
|
this.onFlashCallback = onFlash;
|
|
@@ -2184,6 +2196,7 @@ var dialog_default = {
|
|
|
2184
2196
|
iframe.style.borderRadius = "5px";
|
|
2185
2197
|
iframe.style.width = "100%";
|
|
2186
2198
|
iframe.style.height = "100%";
|
|
2199
|
+
iframe.setAttribute("sandbox", "allow-scripts");
|
|
2187
2200
|
return { iframe, page: page2 };
|
|
2188
2201
|
},
|
|
2189
2202
|
show(html) {
|
|
@@ -2210,6 +2223,10 @@ var dialog_default = {
|
|
|
2210
2223
|
outline: none;
|
|
2211
2224
|
}
|
|
2212
2225
|
`;
|
|
2226
|
+
const nonce = config.get("nonce");
|
|
2227
|
+
if (nonce) {
|
|
2228
|
+
dialogStyleElement.nonce = nonce;
|
|
2229
|
+
}
|
|
2213
2230
|
document.head.appendChild(dialogStyleElement);
|
|
2214
2231
|
dialog.addEventListener("click", (event) => {
|
|
2215
2232
|
if (event.target === dialog) {
|
|
@@ -2224,15 +2241,31 @@ var dialog_default = {
|
|
|
2224
2241
|
document.body.prepend(dialog);
|
|
2225
2242
|
dialog.showModal();
|
|
2226
2243
|
dialog.focus();
|
|
2227
|
-
|
|
2228
|
-
throw new Error("iframe not yet ready.");
|
|
2229
|
-
}
|
|
2230
|
-
iframe.contentWindow.document.open();
|
|
2231
|
-
iframe.contentWindow.document.write(page2.outerHTML);
|
|
2232
|
-
iframe.contentWindow.document.close();
|
|
2244
|
+
iframe.srcdoc = page2.outerHTML;
|
|
2233
2245
|
}
|
|
2234
2246
|
};
|
|
2235
2247
|
|
|
2248
|
+
// src/partialReload.ts
|
|
2249
|
+
var isPathOrSubPath = (path, candidate) => {
|
|
2250
|
+
return path === candidate || path.startsWith(`${candidate}.`);
|
|
2251
|
+
};
|
|
2252
|
+
var partialReloadRequestsProp = (visit, prop) => {
|
|
2253
|
+
const { only, except } = visit;
|
|
2254
|
+
if (only.length === 0 && except.length === 0) {
|
|
2255
|
+
return false;
|
|
2256
|
+
}
|
|
2257
|
+
if (only.length > 0 && !only.some((candidate) => isPathOrSubPath(prop, candidate))) {
|
|
2258
|
+
return false;
|
|
2259
|
+
}
|
|
2260
|
+
if (except.length > 0 && except.some((candidate) => isPathOrSubPath(prop, candidate))) {
|
|
2261
|
+
return false;
|
|
2262
|
+
}
|
|
2263
|
+
return true;
|
|
2264
|
+
};
|
|
2265
|
+
var partialReloadRequestsSomeProps = (visit, props) => {
|
|
2266
|
+
return props.some((prop) => partialReloadRequestsProp(visit, prop));
|
|
2267
|
+
};
|
|
2268
|
+
|
|
2236
2269
|
// src/response.ts
|
|
2237
2270
|
var queue2 = new Queue();
|
|
2238
2271
|
var Response = class _Response {
|
|
@@ -2310,7 +2343,7 @@ var Response = class _Response {
|
|
|
2310
2343
|
getPageResponse() {
|
|
2311
2344
|
const data = this.getDataFromResponse(this.response.data);
|
|
2312
2345
|
if (typeof data === "object") {
|
|
2313
|
-
return this.response.data = { ...data, flash: data.flash ?? {} };
|
|
2346
|
+
return this.response.data = { ...data, flash: data.flash ?? {}, rescuedProps: data.rescuedProps ?? [] };
|
|
2314
2347
|
}
|
|
2315
2348
|
return this.response.data = data;
|
|
2316
2349
|
}
|
|
@@ -2538,6 +2571,16 @@ var Response = class _Response {
|
|
|
2538
2571
|
if (currentOriginalDeferred && Object.keys(currentOriginalDeferred).length > 0) {
|
|
2539
2572
|
pageResponse.initialDeferredProps = currentOriginalDeferred;
|
|
2540
2573
|
}
|
|
2574
|
+
pageResponse.rescuedProps = this.mergeRescuedProps(pageResponse);
|
|
2575
|
+
}
|
|
2576
|
+
mergeRescuedProps(pageResponse) {
|
|
2577
|
+
const currentRescued = page.get().rescuedProps ?? [];
|
|
2578
|
+
const incomingRescued = pageResponse.rescuedProps ?? [];
|
|
2579
|
+
const newRescued = new Set(
|
|
2580
|
+
currentRescued.filter((prop) => !partialReloadRequestsProp(this.requestParams.all(), prop))
|
|
2581
|
+
);
|
|
2582
|
+
incomingRescued.forEach((prop) => newRescued.add(prop));
|
|
2583
|
+
return Array.from(newRescued);
|
|
2541
2584
|
}
|
|
2542
2585
|
/**
|
|
2543
2586
|
* By default, the Laravel adapter shares validation errors via Inertia::always(),
|
|
@@ -3160,6 +3203,7 @@ var Router = class {
|
|
|
3160
3203
|
errors: {}
|
|
3161
3204
|
},
|
|
3162
3205
|
flash: {},
|
|
3206
|
+
rescuedProps: [],
|
|
3163
3207
|
clearHistory: false,
|
|
3164
3208
|
encryptHistory: current.encryptHistory,
|
|
3165
3209
|
sharedProps: current.sharedProps,
|
|
@@ -3215,8 +3259,8 @@ var Router = class {
|
|
|
3215
3259
|
viewTransition: false,
|
|
3216
3260
|
component: null,
|
|
3217
3261
|
pageProps: null,
|
|
3218
|
-
...options,
|
|
3219
|
-
...configuredOptions
|
|
3262
|
+
...stripTopLevelUndefined(options),
|
|
3263
|
+
...stripTopLevelUndefined(configuredOptions)
|
|
3220
3264
|
};
|
|
3221
3265
|
const [url, _data] = transformUrlAndData(
|
|
3222
3266
|
href,
|
|
@@ -3693,7 +3737,7 @@ function createHeadManager(isServer3, titleCallback, onUpdate) {
|
|
|
3693
3737
|
return carry;
|
|
3694
3738
|
}
|
|
3695
3739
|
if (element.indexOf("<title ") === 0) {
|
|
3696
|
-
const title2 = element.match(/(<title [^>]+>)(.*?)(<\/title>)/);
|
|
3740
|
+
const title2 = element.match(/(<title [^>]+>)(.*?)(<\/title>)/s);
|
|
3697
3741
|
carry.title = title2 ? `${title2[1]}${titleCallback(title2[2])}${title2[3]}` : element;
|
|
3698
3742
|
return carry;
|
|
3699
3743
|
}
|
|
@@ -4565,6 +4609,10 @@ var queue4 = /* @__PURE__ */ (() => {
|
|
|
4565
4609
|
})();
|
|
4566
4610
|
var injectCSS = (color) => {
|
|
4567
4611
|
const element = document.createElement("style");
|
|
4612
|
+
const nonce = config.get("nonce");
|
|
4613
|
+
if (nonce) {
|
|
4614
|
+
element.nonce = nonce;
|
|
4615
|
+
}
|
|
4568
4616
|
element.textContent = `
|
|
4569
4617
|
#${baseComponentSelector} {
|
|
4570
4618
|
pointer-events: none;
|
|
@@ -4761,7 +4809,12 @@ function setupProgress({
|
|
|
4761
4809
|
popover = null
|
|
4762
4810
|
} = {}) {
|
|
4763
4811
|
addEventListeners(delay);
|
|
4764
|
-
progress_component_default.configure({
|
|
4812
|
+
progress_component_default.configure({
|
|
4813
|
+
showSpinner,
|
|
4814
|
+
includeCSS,
|
|
4815
|
+
color,
|
|
4816
|
+
popover
|
|
4817
|
+
});
|
|
4765
4818
|
}
|
|
4766
4819
|
|
|
4767
4820
|
// src/resetFormFields.ts
|
|
@@ -4929,6 +4982,7 @@ export {
|
|
|
4929
4982
|
hasFiles,
|
|
4930
4983
|
hrefToUrl,
|
|
4931
4984
|
http,
|
|
4985
|
+
isPathOrSubPath,
|
|
4932
4986
|
isPropsObject,
|
|
4933
4987
|
isPropsObjectOrCallback,
|
|
4934
4988
|
isSameUrlWithoutQueryOrHash,
|
|
@@ -4936,6 +4990,8 @@ export {
|
|
|
4936
4990
|
mergeDataIntoQueryString,
|
|
4937
4991
|
normalizeLayouts,
|
|
4938
4992
|
objectToFormData,
|
|
4993
|
+
partialReloadRequestsProp,
|
|
4994
|
+
partialReloadRequestsSomeProps,
|
|
4939
4995
|
progress,
|
|
4940
4996
|
resetFormFields,
|
|
4941
4997
|
resolveUrlMethodPairComponent,
|