Repository navigation
Conversation
|
For direct compositions such as I noticed this while looking at these parts of the PR description:
In this PR, In Is this wrapper-composition behavior intentional? I'm wondering whether Hono wants to define these semantics independently, or whether direct compositions should behave closer to If supporting nested prop-marker composition is out of scope for this PR, another option might be to reject it explicitly instead of implicitly applying the inner prop type's behavior. For example: export const always = <T>(data: T): T => {
if (isDeferred(data) || isMerge(data) || isScroll(data)) {
throw new TypeError('always() cannot wrap another prop type')
}
const marker: AlwaysProp<T> = {
[ALWAYS_MARKER]: true,
data,
}
return marker as unknown as T
}Since |

Overview
Adds
always(), a prop wrapper that bypasses partial reload filtering. This is item ① from #2110, and the foundation the shared data work (②) builds on.Motivation
Partial reloads narrow the response down to the props listed in
X-Inertia-Partial-Data(or everything except the ones inX-Inertia-Partial-Except). Cross-cutting props — validation errors, flash messages, the authenticated user — are still needed by the page even when the client asked for a single prop, and there is currently no way to express that.Parity with inertia-laravel
AlwaysPropshort circuits on the first condition ofshouldIncludeInPartialResponse, so it bypasses both theonlyand theexceptheader. This PR matches that.There is no
alwaysentry inbuildMetadata(), so nothing is added to the page object.Implementation
Same marker approach as
defer()/merge()/scroll(). The renderer unwraps the marker at the top of the prop loop, skips the filter, and lets the inner value fall through to the existing resolution path. As a resultalways(() => ...)still resolves lazily andalways(merge(...))still emits its merge metadata. Wrapping a plain value keeps the synchronous fast path intact.always(defer(...))is not supported:AlwaysPropis notDeferrablein inertia-laravel either, and "always present on the initial response" and "never present on the initial response" cannot both hold. This is documented in the README.Related
Item ① of #2110. Item ② (
share) is being worked on by @nkfr26 in #2124 — shared data needs this to behave correctly under partial reloads, which is exactly why Laravel wrapserrorsinalways().The author should do the following, if applicable
pnpm changesetat the top of this repo and push the changeset