@inertiajs/core 3.0.3 → 3.1.0
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 +57 -10
- 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/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
|
@@ -860,6 +860,9 @@ function decode(value) {
|
|
|
860
860
|
}
|
|
861
861
|
function set2(target, key, value) {
|
|
862
862
|
const keys = parseKey(key);
|
|
863
|
+
if (keys.some((k) => k === "__proto__")) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
863
866
|
let current = target;
|
|
864
867
|
while (keys.length > 1) {
|
|
865
868
|
const segment = keys.shift();
|
|
@@ -1015,7 +1018,7 @@ var CurrentPage = class {
|
|
|
1015
1018
|
resolveComponent,
|
|
1016
1019
|
onFlash
|
|
1017
1020
|
}) {
|
|
1018
|
-
this.page = { ...initialPage, flash: initialPage.flash ?? {} };
|
|
1021
|
+
this.page = { ...initialPage, flash: initialPage.flash ?? {}, rescuedProps: initialPage.rescuedProps ?? [] };
|
|
1019
1022
|
this.swapComponent = swapComponent;
|
|
1020
1023
|
this.resolveComponent = resolveComponent;
|
|
1021
1024
|
this.onFlashCallback = onFlash;
|
|
@@ -2184,6 +2187,7 @@ var dialog_default = {
|
|
|
2184
2187
|
iframe.style.borderRadius = "5px";
|
|
2185
2188
|
iframe.style.width = "100%";
|
|
2186
2189
|
iframe.style.height = "100%";
|
|
2190
|
+
iframe.setAttribute("sandbox", "allow-scripts");
|
|
2187
2191
|
return { iframe, page: page2 };
|
|
2188
2192
|
},
|
|
2189
2193
|
show(html) {
|
|
@@ -2210,6 +2214,10 @@ var dialog_default = {
|
|
|
2210
2214
|
outline: none;
|
|
2211
2215
|
}
|
|
2212
2216
|
`;
|
|
2217
|
+
const nonce = config.get("nonce");
|
|
2218
|
+
if (nonce) {
|
|
2219
|
+
dialogStyleElement.nonce = nonce;
|
|
2220
|
+
}
|
|
2213
2221
|
document.head.appendChild(dialogStyleElement);
|
|
2214
2222
|
dialog.addEventListener("click", (event) => {
|
|
2215
2223
|
if (event.target === dialog) {
|
|
@@ -2224,15 +2232,31 @@ var dialog_default = {
|
|
|
2224
2232
|
document.body.prepend(dialog);
|
|
2225
2233
|
dialog.showModal();
|
|
2226
2234
|
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();
|
|
2235
|
+
iframe.srcdoc = page2.outerHTML;
|
|
2233
2236
|
}
|
|
2234
2237
|
};
|
|
2235
2238
|
|
|
2239
|
+
// src/partialReload.ts
|
|
2240
|
+
var isPathOrSubPath = (path, candidate) => {
|
|
2241
|
+
return path === candidate || path.startsWith(`${candidate}.`);
|
|
2242
|
+
};
|
|
2243
|
+
var partialReloadRequestsProp = (visit, prop) => {
|
|
2244
|
+
const { only, except } = visit;
|
|
2245
|
+
if (only.length === 0 && except.length === 0) {
|
|
2246
|
+
return false;
|
|
2247
|
+
}
|
|
2248
|
+
if (only.length > 0 && !only.some((candidate) => isPathOrSubPath(prop, candidate))) {
|
|
2249
|
+
return false;
|
|
2250
|
+
}
|
|
2251
|
+
if (except.length > 0 && except.some((candidate) => isPathOrSubPath(prop, candidate))) {
|
|
2252
|
+
return false;
|
|
2253
|
+
}
|
|
2254
|
+
return true;
|
|
2255
|
+
};
|
|
2256
|
+
var partialReloadRequestsSomeProps = (visit, props) => {
|
|
2257
|
+
return props.some((prop) => partialReloadRequestsProp(visit, prop));
|
|
2258
|
+
};
|
|
2259
|
+
|
|
2236
2260
|
// src/response.ts
|
|
2237
2261
|
var queue2 = new Queue();
|
|
2238
2262
|
var Response = class _Response {
|
|
@@ -2310,7 +2334,7 @@ var Response = class _Response {
|
|
|
2310
2334
|
getPageResponse() {
|
|
2311
2335
|
const data = this.getDataFromResponse(this.response.data);
|
|
2312
2336
|
if (typeof data === "object") {
|
|
2313
|
-
return this.response.data = { ...data, flash: data.flash ?? {} };
|
|
2337
|
+
return this.response.data = { ...data, flash: data.flash ?? {}, rescuedProps: data.rescuedProps ?? [] };
|
|
2314
2338
|
}
|
|
2315
2339
|
return this.response.data = data;
|
|
2316
2340
|
}
|
|
@@ -2538,6 +2562,16 @@ var Response = class _Response {
|
|
|
2538
2562
|
if (currentOriginalDeferred && Object.keys(currentOriginalDeferred).length > 0) {
|
|
2539
2563
|
pageResponse.initialDeferredProps = currentOriginalDeferred;
|
|
2540
2564
|
}
|
|
2565
|
+
pageResponse.rescuedProps = this.mergeRescuedProps(pageResponse);
|
|
2566
|
+
}
|
|
2567
|
+
mergeRescuedProps(pageResponse) {
|
|
2568
|
+
const currentRescued = page.get().rescuedProps ?? [];
|
|
2569
|
+
const incomingRescued = pageResponse.rescuedProps ?? [];
|
|
2570
|
+
const newRescued = new Set(
|
|
2571
|
+
currentRescued.filter((prop) => !partialReloadRequestsProp(this.requestParams.all(), prop))
|
|
2572
|
+
);
|
|
2573
|
+
incomingRescued.forEach((prop) => newRescued.add(prop));
|
|
2574
|
+
return Array.from(newRescued);
|
|
2541
2575
|
}
|
|
2542
2576
|
/**
|
|
2543
2577
|
* By default, the Laravel adapter shares validation errors via Inertia::always(),
|
|
@@ -3160,6 +3194,7 @@ var Router = class {
|
|
|
3160
3194
|
errors: {}
|
|
3161
3195
|
},
|
|
3162
3196
|
flash: {},
|
|
3197
|
+
rescuedProps: [],
|
|
3163
3198
|
clearHistory: false,
|
|
3164
3199
|
encryptHistory: current.encryptHistory,
|
|
3165
3200
|
sharedProps: current.sharedProps,
|
|
@@ -3693,7 +3728,7 @@ function createHeadManager(isServer3, titleCallback, onUpdate) {
|
|
|
3693
3728
|
return carry;
|
|
3694
3729
|
}
|
|
3695
3730
|
if (element.indexOf("<title ") === 0) {
|
|
3696
|
-
const title2 = element.match(/(<title [^>]+>)(.*?)(<\/title>)/);
|
|
3731
|
+
const title2 = element.match(/(<title [^>]+>)(.*?)(<\/title>)/s);
|
|
3697
3732
|
carry.title = title2 ? `${title2[1]}${titleCallback(title2[2])}${title2[3]}` : element;
|
|
3698
3733
|
return carry;
|
|
3699
3734
|
}
|
|
@@ -4565,6 +4600,10 @@ var queue4 = /* @__PURE__ */ (() => {
|
|
|
4565
4600
|
})();
|
|
4566
4601
|
var injectCSS = (color) => {
|
|
4567
4602
|
const element = document.createElement("style");
|
|
4603
|
+
const nonce = config.get("nonce");
|
|
4604
|
+
if (nonce) {
|
|
4605
|
+
element.nonce = nonce;
|
|
4606
|
+
}
|
|
4568
4607
|
element.textContent = `
|
|
4569
4608
|
#${baseComponentSelector} {
|
|
4570
4609
|
pointer-events: none;
|
|
@@ -4761,7 +4800,12 @@ function setupProgress({
|
|
|
4761
4800
|
popover = null
|
|
4762
4801
|
} = {}) {
|
|
4763
4802
|
addEventListeners(delay);
|
|
4764
|
-
progress_component_default.configure({
|
|
4803
|
+
progress_component_default.configure({
|
|
4804
|
+
showSpinner,
|
|
4805
|
+
includeCSS,
|
|
4806
|
+
color,
|
|
4807
|
+
popover
|
|
4808
|
+
});
|
|
4765
4809
|
}
|
|
4766
4810
|
|
|
4767
4811
|
// src/resetFormFields.ts
|
|
@@ -4929,6 +4973,7 @@ export {
|
|
|
4929
4973
|
hasFiles,
|
|
4930
4974
|
hrefToUrl,
|
|
4931
4975
|
http,
|
|
4976
|
+
isPathOrSubPath,
|
|
4932
4977
|
isPropsObject,
|
|
4933
4978
|
isPropsObjectOrCallback,
|
|
4934
4979
|
isSameUrlWithoutQueryOrHash,
|
|
@@ -4936,6 +4981,8 @@ export {
|
|
|
4936
4981
|
mergeDataIntoQueryString,
|
|
4937
4982
|
normalizeLayouts,
|
|
4938
4983
|
objectToFormData,
|
|
4984
|
+
partialReloadRequestsProp,
|
|
4985
|
+
partialReloadRequestsSomeProps,
|
|
4939
4986
|
progress,
|
|
4940
4987
|
resetFormFields,
|
|
4941
4988
|
resolveUrlMethodPairComponent,
|