@blacklizard/inertia-express 1.2.0 → 3.0.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/README.md +153 -23
- package/dist/core/index.d.ts +2 -538
- package/dist/core/index.js +2 -646
- package/dist/core-ChQbBw-k.js +1499 -0
- package/dist/core-ChQbBw-k.js.map +1 -0
- package/dist/express/index.d.ts +17 -3
- package/dist/express/index.d.ts.map +1 -1
- package/dist/express/index.js +59 -17
- package/dist/express/index.js.map +1 -1
- package/dist/index-PWaujyMo.d.ts +1133 -0
- package/dist/index-PWaujyMo.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js.map +0 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,538 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Inertia.js v3 protocol types.
|
|
4
|
-
*
|
|
5
|
-
* Reference: https://inertiajs.com/the-protocol
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Free-form bag of page props handed to the client component.
|
|
9
|
-
*/
|
|
10
|
-
type PageProps = Record<string, unknown>;
|
|
11
|
-
/**
|
|
12
|
-
* The page object returned to the Inertia client (for `X-Inertia` requests)
|
|
13
|
-
* or embedded into the initial HTML response on first load.
|
|
14
|
-
*/
|
|
15
|
-
interface InertiaPage<TProps extends PageProps = PageProps> {
|
|
16
|
-
component: string;
|
|
17
|
-
props: TProps;
|
|
18
|
-
url: string;
|
|
19
|
-
version: string | null;
|
|
20
|
-
/**
|
|
21
|
-
* v3: instructs the client to clear browser history state on this visit.
|
|
22
|
-
*/
|
|
23
|
-
clearHistory: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* v3: instructs the client to encrypt history state for this page.
|
|
26
|
-
*/
|
|
27
|
-
encryptHistory: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* v3: keys whose props should be deferred and fetched in a follow-up partial reload.
|
|
30
|
-
* Grouped by deferred-load group name.
|
|
31
|
-
*/
|
|
32
|
-
deferredProps?: Record<string, string[]>;
|
|
33
|
-
/**
|
|
34
|
-
* v3: keys whose props should be merged (appended) on the client rather than replaced.
|
|
35
|
-
*/
|
|
36
|
-
mergeProps?: string[];
|
|
37
|
-
/**
|
|
38
|
-
* v3: keys whose props should be *deep*-merged on the client (recursive merge
|
|
39
|
-
* rather than shallow append).
|
|
40
|
-
*/
|
|
41
|
-
deepMergeProps?: string[];
|
|
42
|
-
/**
|
|
43
|
-
* v3: dotted `prop.field` paths telling the client which field to match on
|
|
44
|
-
* when merging arrays of objects (used to dedupe rather than blindly append).
|
|
45
|
-
*/
|
|
46
|
-
matchPropsOn?: string[];
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* A prop value that is evaluated lazily on every visit.
|
|
50
|
-
*/
|
|
51
|
-
type LazyProp<T = unknown> = (() => T | Promise<T>) & {
|
|
52
|
-
__inertia_lazy: true;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* A prop value that is only sent on partial reloads when explicitly requested
|
|
56
|
-
* (i.e. its key appears in `X-Inertia-Partial-Data`). On full visits the prop
|
|
57
|
-
* is omitted entirely.
|
|
58
|
-
*/
|
|
59
|
-
type OptionalProp<T = unknown> = (() => T | Promise<T>) & {
|
|
60
|
-
__inertia_optional: true;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* A prop that is omitted on the initial visit and instead loaded by an
|
|
64
|
-
* automatic follow-up partial reload after the page mounts. Grouped by
|
|
65
|
-
* `group` so several deferred props can be loaded in a single round-trip.
|
|
66
|
-
*/
|
|
67
|
-
type DeferredProp<T = unknown> = (() => T | Promise<T>) & {
|
|
68
|
-
__inertia_deferred: true;
|
|
69
|
-
group: string;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* A prop that is always included in the response — on full visits and on
|
|
73
|
-
* partial reloads — regardless of `X-Inertia-Partial-Data` /
|
|
74
|
-
* `X-Inertia-Partial-Except` filtering.
|
|
75
|
-
*/
|
|
76
|
-
type AlwaysProp<T = unknown> = (() => T | Promise<T>) & {
|
|
77
|
-
__inertia_always: true;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* A prop value the client should *append* to existing data rather than
|
|
81
|
-
* replace (useful for paginated lists).
|
|
82
|
-
*/
|
|
83
|
-
type MergeProp<T = unknown> = T & {
|
|
84
|
-
__inertia_merge: true;
|
|
85
|
-
__inertia_match_on?: string[];
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* A prop value the client should recursively *deep*-merge into existing data
|
|
89
|
-
* rather than shallow-append.
|
|
90
|
-
*/
|
|
91
|
-
type DeepMergeProp<T = unknown> = T & {
|
|
92
|
-
__inertia_deep_merge: true;
|
|
93
|
-
__inertia_match_on?: string[];
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Any value accepted as a page prop: a plain JSON value, or one of the
|
|
97
|
-
* wrapper types ({@link LazyProp}, {@link OptionalProp}, {@link DeferredProp},
|
|
98
|
-
* {@link AlwaysProp}, {@link MergeProp}, {@link DeepMergeProp}). Structurally
|
|
99
|
-
* this is `unknown` — the wrappers are documented here for discoverability.
|
|
100
|
-
*/
|
|
101
|
-
type PropValue = unknown;
|
|
102
|
-
/**
|
|
103
|
-
* Globally shared props: either a static object merged into every page, or
|
|
104
|
-
* a (possibly async) function that returns one for the current request.
|
|
105
|
-
*/
|
|
106
|
-
type SharedPropsInput<TReq = unknown> = PageProps | ((req: TReq) => PageProps | Promise<PageProps>);
|
|
107
|
-
/**
|
|
108
|
-
* Per-response overrides for history-related page flags.
|
|
109
|
-
*/
|
|
110
|
-
interface RenderOptions {
|
|
111
|
-
/**
|
|
112
|
-
* Override `clearHistory` for this response.
|
|
113
|
-
*/
|
|
114
|
-
clearHistory?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Override `encryptHistory` for this response.
|
|
117
|
-
*/
|
|
118
|
-
encryptHistory?: boolean;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Normalized view of an incoming HTTP request from the perspective of the
|
|
122
|
-
* Inertia v3 protocol. Produced by {@link parseInertiaRequest}.
|
|
123
|
-
*/
|
|
124
|
-
interface InertiaRequestInfo {
|
|
125
|
-
isInertia: boolean;
|
|
126
|
-
version: string | null;
|
|
127
|
-
partialComponent: string | null;
|
|
128
|
-
partialOnly: string[] | null;
|
|
129
|
-
partialExcept: string[] | null;
|
|
130
|
-
errorBag: string | null;
|
|
131
|
-
resetKeys: string[] | null;
|
|
132
|
-
method: string;
|
|
133
|
-
url: string;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Asset version source: a literal string, `null` (disables checks), or a
|
|
137
|
-
* (possibly async) function that derives a version per request.
|
|
138
|
-
*/
|
|
139
|
-
type VersionResolver<TReq = unknown> = string | null | (() => string | null | Promise<string | null>) | ((req: TReq) => string | null | Promise<string | null>);
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region src/core/cache.d.ts
|
|
142
|
-
/**
|
|
143
|
-
* Pluggable storage interface for the SSR view cache.
|
|
144
|
-
*
|
|
145
|
-
* Implementations live outside the core package — see
|
|
146
|
-
* `createMemoryCacheStore` in `@blacklizard/inertia-express` and
|
|
147
|
-
* `createRedisCacheStore` in `@blacklizard/inertia-cache-redis`.
|
|
148
|
-
*
|
|
149
|
-
* Values are arbitrary JSON — usually `SsrCacheEntry` (`{ head, body, ... }`).
|
|
150
|
-
* The store should not interpret them.
|
|
151
|
-
*/
|
|
152
|
-
interface SsrCacheStore {
|
|
153
|
-
get: (key: string) => Promise<SsrCacheEntry | null>;
|
|
154
|
-
set: (key: string, value: SsrCacheEntry, ttlSeconds: number) => Promise<void>;
|
|
155
|
-
delete: (key: string) => Promise<void>;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* What we actually store per cache hit. Includes everything needed to
|
|
159
|
-
* reconstruct the HTML response without re-running the SSR renderer.
|
|
160
|
-
*/
|
|
161
|
-
interface SsrCacheEntry {
|
|
162
|
-
head: string | string[];
|
|
163
|
-
body: string;
|
|
164
|
-
bodyIsFullRoot?: boolean;
|
|
165
|
-
/** ISO timestamp when this entry was stored. Useful for debugging. */
|
|
166
|
-
storedAt: string;
|
|
167
|
-
/**
|
|
168
|
-
* The page object the entry corresponds to. Lets a custom rootView see
|
|
169
|
-
* the same structure on a cache hit as on a fresh render.
|
|
170
|
-
*/
|
|
171
|
-
page: InertiaPage;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Stable JSON encoding: keys sorted recursively, undefined dropped, NaN/Inf
|
|
175
|
-
* normalized. Two equal-by-value objects always produce the same string,
|
|
176
|
-
* so they hash to the same cache key.
|
|
177
|
-
*
|
|
178
|
-
* @param value Arbitrary JSON-shaped input.
|
|
179
|
-
*/
|
|
180
|
-
declare function canonicalStringify(value: unknown): string;
|
|
181
|
-
/**
|
|
182
|
-
* Inputs to {@link computeSsrCacheKey}.
|
|
183
|
-
*/
|
|
184
|
-
interface ComputeCacheKeyInput {
|
|
185
|
-
/** Cache namespace, e.g. `"inertia:ssr"`. */
|
|
186
|
-
prefix: string;
|
|
187
|
-
/** Asset version. Becomes part of the key so deploys auto-invalidate. */
|
|
188
|
-
version: string | null;
|
|
189
|
-
/** Component name being rendered. */
|
|
190
|
-
component: string;
|
|
191
|
-
/** Final, fully-resolved props (post shared-merge, post-lazy evaluation). */
|
|
192
|
-
props: PageProps;
|
|
193
|
-
/** Optional extra discriminator (locale, theme, A/B bucket, etc.). */
|
|
194
|
-
discriminator?: string;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Build the cache key for an SSR cache entry.
|
|
198
|
-
*
|
|
199
|
-
* Shape: `${prefix}:${version}:${component}:${sha256(props[+discriminator])}`
|
|
200
|
-
*
|
|
201
|
-
* Including `version` in the key namespace means a deploy that bumps the
|
|
202
|
-
* asset version atomically retires every old key — no flush, no race.
|
|
203
|
-
*
|
|
204
|
-
* @param input Prefix, version, component, resolved props, optional discriminator.
|
|
205
|
-
*/
|
|
206
|
-
declare function computeSsrCacheKey(input: ComputeCacheKeyInput): string;
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/core/errors.d.ts
|
|
209
|
-
/**
|
|
210
|
-
* Flat map of `field → first error message`, the shape the Inertia client
|
|
211
|
-
* expects under `props.errors`.
|
|
212
|
-
*/
|
|
213
|
-
type ValidationErrors = Record<string, string>;
|
|
214
|
-
/**
|
|
215
|
-
* Apply error-bag scoping to a flat errors object, matching the official
|
|
216
|
-
* Inertia behavior. When `bag` is set, errors are namespaced under
|
|
217
|
-
* `props.errors[bag]`. When `bag` is null, errors live at `props.errors`.
|
|
218
|
-
*
|
|
219
|
-
* @param errors Flat field-to-message map.
|
|
220
|
-
* @param bag Optional error-bag name (e.g. `"createUser"`); null for top-level.
|
|
221
|
-
*/
|
|
222
|
-
declare function scopeErrors(errors: ValidationErrors, bag: string | null): PageProps;
|
|
223
|
-
//#endregion
|
|
224
|
-
//#region src/core/headers.d.ts
|
|
225
|
-
/**
|
|
226
|
-
* Canonical Inertia v3 protocol header names.
|
|
227
|
-
*
|
|
228
|
-
* The Inertia client sends these headers on every visit. The server uses
|
|
229
|
-
* them to decide between a full HTML response and a JSON page response,
|
|
230
|
-
* and to scope partial reloads.
|
|
231
|
-
*/
|
|
232
|
-
declare const INERTIA_HEADERS: {
|
|
233
|
-
readonly inertia: "x-inertia";
|
|
234
|
-
readonly version: "x-inertia-version";
|
|
235
|
-
readonly partialComponent: "x-inertia-partial-component";
|
|
236
|
-
readonly partialData: "x-inertia-partial-data";
|
|
237
|
-
readonly partialExcept: "x-inertia-partial-except";
|
|
238
|
-
readonly errorBag: "x-inertia-error-bag";
|
|
239
|
-
readonly reset: "x-inertia-reset";
|
|
240
|
-
readonly location: "x-inertia-location";
|
|
241
|
-
};
|
|
242
|
-
type HeaderRecord = Record<string, string | string[] | undefined>;
|
|
243
|
-
/**
|
|
244
|
-
* Parse a request's headers into a normalized {@link InertiaRequestInfo}.
|
|
245
|
-
*
|
|
246
|
-
* @param input Headers, HTTP method, and request URL. Method is uppercased in
|
|
247
|
-
* the returned object; the URL is passed through unchanged.
|
|
248
|
-
*/
|
|
249
|
-
declare function parseInertiaRequest(input: {
|
|
250
|
-
headers: HeaderRecord;
|
|
251
|
-
method: string;
|
|
252
|
-
url: string;
|
|
253
|
-
}): InertiaRequestInfo;
|
|
254
|
-
//#endregion
|
|
255
|
-
//#region src/core/html.d.ts
|
|
256
|
-
/**
|
|
257
|
-
* Encode an Inertia page object for embedding inside a
|
|
258
|
-
* `<script type="application/json" data-page="...">` tag — the Inertia v3
|
|
259
|
-
* initial-page transport that the client reads via `getInitialPageFromDOM`.
|
|
260
|
-
*
|
|
261
|
-
* Every `<` is replaced with its JSON unicode escape so the payload cannot
|
|
262
|
-
* terminate the surrounding `</script>` element or open an HTML comment. The
|
|
263
|
-
* escape is transparent — JSON.parse decodes it back to `<`.
|
|
264
|
-
*
|
|
265
|
-
* @param page Resolved Inertia page object.
|
|
266
|
-
*/
|
|
267
|
-
declare function encodePageScript(page: InertiaPage): string;
|
|
268
|
-
/**
|
|
269
|
-
* Inputs to {@link renderDefaultHtml}.
|
|
270
|
-
*/
|
|
271
|
-
interface DefaultRootViewInput {
|
|
272
|
-
page: InertiaPage;
|
|
273
|
-
/** Optional `<title>` for the document. */
|
|
274
|
-
title?: string;
|
|
275
|
-
/** Optional <head> content (meta tags, links, etc.). */
|
|
276
|
-
head?: string;
|
|
277
|
-
/** ID of the SPA root element. Defaults to `app`. */
|
|
278
|
-
rootId?: string;
|
|
279
|
-
/** Path to the client entry script, e.g. `/assets/app.js`. */
|
|
280
|
-
scriptSrc?: string;
|
|
281
|
-
/**
|
|
282
|
-
* Pre-rendered SSR HTML for the root element's *inner* content. When set,
|
|
283
|
-
* the inner HTML of the root div is replaced with this string so the
|
|
284
|
-
* client hydrates over server-rendered markup.
|
|
285
|
-
*/
|
|
286
|
-
ssrBody?: string;
|
|
287
|
-
/**
|
|
288
|
-
* Pre-rendered SSR HTML representing the entire root element. When set,
|
|
289
|
-
* `ssrBody`, `rootId`, and the page `<script>` tag are ignored — the
|
|
290
|
-
* provided string is inserted into `<body>` as-is. Use this when your
|
|
291
|
-
* SSR renderer already returns the full root element + page script (the
|
|
292
|
-
* Inertia v3 SSR servers do).
|
|
293
|
-
*/
|
|
294
|
-
ssrFull?: string;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Minimal default HTML shell for use when no custom root view is provided.
|
|
298
|
-
* Real apps should plug in a template engine (pug, ejs, react-dom/server,
|
|
299
|
-
* etc.) and embed `encodePageScript(page)` themselves.
|
|
300
|
-
*
|
|
301
|
-
* The initial page object is emitted as a
|
|
302
|
-
* `<script type="application/json" data-page="...">` tag, the Inertia v3
|
|
303
|
-
* transport that the client reads on boot.
|
|
304
|
-
*
|
|
305
|
-
* @param input Page object plus optional title/head/rootId/scriptSrc/SSR markup
|
|
306
|
-
* — see {@link DefaultRootViewInput}.
|
|
307
|
-
*/
|
|
308
|
-
declare function renderDefaultHtml(input: DefaultRootViewInput): string;
|
|
309
|
-
/**
|
|
310
|
-
* Inputs to {@link renderErrorPage}.
|
|
311
|
-
*/
|
|
312
|
-
interface ErrorPageInput {
|
|
313
|
-
/** HTTP status code to surface to the user. */
|
|
314
|
-
status: number;
|
|
315
|
-
/** Optional message; falls back to a default for the status, then a generic line. */
|
|
316
|
-
message?: string;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Render a minimal, SPA-less standalone HTML error page. Used as the hard
|
|
320
|
-
* fallback when no client `Error` component can be resolved (e.g. a plain
|
|
321
|
-
* browser load, or an SSR/render failure on the Inertia path), so a user
|
|
322
|
-
* never receives a raw JSON error or a blank page.
|
|
323
|
-
*
|
|
324
|
-
* @param input HTTP status plus an optional override message — see {@link ErrorPageInput}.
|
|
325
|
-
*/
|
|
326
|
-
declare function renderErrorPage(input: ErrorPageInput): string;
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/core/page.d.ts
|
|
329
|
-
/**
|
|
330
|
-
* Inputs to {@link createPage} — the fields of an {@link InertiaPage} plus
|
|
331
|
-
* optional history flags and v3 prop-key metadata.
|
|
332
|
-
*/
|
|
333
|
-
interface CreatePageInput<TProps extends PageProps = PageProps> {
|
|
334
|
-
component: string;
|
|
335
|
-
props: TProps;
|
|
336
|
-
url: string;
|
|
337
|
-
version: string | null;
|
|
338
|
-
clearHistory?: boolean;
|
|
339
|
-
encryptHistory?: boolean;
|
|
340
|
-
deferredProps?: Record<string, string[]>;
|
|
341
|
-
mergeProps?: string[];
|
|
342
|
-
deepMergeProps?: string[];
|
|
343
|
-
matchPropsOn?: string[];
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Build a normalized Inertia v3 page object. `clearHistory` and `encryptHistory`
|
|
347
|
-
* default to `false`. Empty/absent `deferredProps` / `mergeProps` /
|
|
348
|
-
* `deepMergeProps` / `matchPropsOn` are dropped so the JSON over the wire stays
|
|
349
|
-
* compact.
|
|
350
|
-
*
|
|
351
|
-
* @param input Required page fields plus the optional v3 extras.
|
|
352
|
-
*/
|
|
353
|
-
declare function createPage<TProps extends PageProps>(input: CreatePageInput<TProps>): InertiaPage<TProps>;
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/core/props.d.ts
|
|
356
|
-
/**
|
|
357
|
-
* Wrap a value-producing function as a "lazy" prop.
|
|
358
|
-
*
|
|
359
|
-
* Lazy props are evaluated on every visit (full or partial) when included.
|
|
360
|
-
* They are NOT skipped on the initial visit — use {@link optional} for that.
|
|
361
|
-
*
|
|
362
|
-
* @param fn Producer called (and awaited) when the prop is included.
|
|
363
|
-
*/
|
|
364
|
-
declare function lazy<T>(fn: () => T | Promise<T>): LazyProp<T>;
|
|
365
|
-
/**
|
|
366
|
-
* Wrap a value-producing function as an "optional" prop.
|
|
367
|
-
*
|
|
368
|
-
* Optional props are omitted from the initial response and only included
|
|
369
|
-
* when explicitly requested via `X-Inertia-Partial-Data`.
|
|
370
|
-
*
|
|
371
|
-
* @param fn Producer called (and awaited) on partial reloads that request the key.
|
|
372
|
-
*/
|
|
373
|
-
declare function optional<T>(fn: () => T | Promise<T>): OptionalProp<T>;
|
|
374
|
-
/**
|
|
375
|
-
* Wrap a value-producing function as a "deferred" prop.
|
|
376
|
-
*
|
|
377
|
-
* Deferred props are omitted from the initial visit. The client receives
|
|
378
|
-
* the list of deferred prop keys (grouped by `group`) in the page object
|
|
379
|
-
* and triggers an automatic partial reload to fetch them.
|
|
380
|
-
*
|
|
381
|
-
* @param fn Producer called (and awaited) on the deferred follow-up reload.
|
|
382
|
-
* @param group Load-group name; keys in the same group are fetched in one round-trip.
|
|
383
|
-
*/
|
|
384
|
-
declare function defer<T>(fn: () => T | Promise<T>, group?: string): DeferredProp<T>;
|
|
385
|
-
/**
|
|
386
|
-
* Wrap a value-producing function as an "always" prop.
|
|
387
|
-
*
|
|
388
|
-
* Always props are included on every response — full visits and partial
|
|
389
|
-
* reloads alike — regardless of `X-Inertia-Partial-Data` /
|
|
390
|
-
* `X-Inertia-Partial-Except` filtering.
|
|
391
|
-
*
|
|
392
|
-
* @param fn Producer called (and awaited) on every visit.
|
|
393
|
-
*/
|
|
394
|
-
declare function always<T>(fn: () => T | Promise<T>): AlwaysProp<T>;
|
|
395
|
-
/**
|
|
396
|
-
* Mark a value as a "merge" prop. The Inertia client will append the new
|
|
397
|
-
* value to the existing prop (typically used for paginated arrays).
|
|
398
|
-
*
|
|
399
|
-
* Pass `matchOn` (a field name or list of field names) to have the client
|
|
400
|
-
* dedupe array items on that field instead of blindly appending.
|
|
401
|
-
*
|
|
402
|
-
* @param value Object or array to tag (mutated in place via non-enumerable properties).
|
|
403
|
-
* @param matchOn Optional field name(s) to dedupe on.
|
|
404
|
-
*/
|
|
405
|
-
declare function merge<T extends object>(value: T, matchOn?: string | string[]): MergeProp<T>;
|
|
406
|
-
/**
|
|
407
|
-
* Mark a value as a "deep merge" prop. The Inertia client recursively merges
|
|
408
|
-
* the new value into the existing prop rather than shallow-appending.
|
|
409
|
-
*
|
|
410
|
-
* Pass `matchOn` (a field name or list of field names) to have the client
|
|
411
|
-
* dedupe array items on that field.
|
|
412
|
-
*
|
|
413
|
-
* @param value Object or array to tag (mutated in place via non-enumerable properties).
|
|
414
|
-
* @param matchOn Optional field name(s) to dedupe on.
|
|
415
|
-
*/
|
|
416
|
-
declare function deepMerge<T extends object>(value: T, matchOn?: string | string[]): DeepMergeProp<T>;
|
|
417
|
-
/**
|
|
418
|
-
* Inputs to {@link resolveProps}.
|
|
419
|
-
*/
|
|
420
|
-
interface ResolvePropsInput {
|
|
421
|
-
/** Props passed to `res.inertia(component, props)`. */
|
|
422
|
-
props: PageProps;
|
|
423
|
-
/** Globally shared props after evaluation. */
|
|
424
|
-
shared: PageProps;
|
|
425
|
-
/** The component name being rendered. */
|
|
426
|
-
component: string;
|
|
427
|
-
/** Parsed Inertia request info. */
|
|
428
|
-
request: InertiaRequestInfo;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Result of {@link resolveProps}: the evaluated props plus the per-key
|
|
432
|
-
* metadata the caller needs to populate the page object.
|
|
433
|
-
*/
|
|
434
|
-
interface ResolvePropsResult {
|
|
435
|
-
props: PageProps;
|
|
436
|
-
/** Deferred prop key map by group, for the initial visit. */
|
|
437
|
-
deferred: Record<string, string[]>;
|
|
438
|
-
/** Shallow-merge prop key list. */
|
|
439
|
-
merge: string[];
|
|
440
|
-
/** Deep-merge prop key list. */
|
|
441
|
-
deepMerge: string[];
|
|
442
|
-
/** Dotted `prop.field` match-on paths for merge/deep-merge props. */
|
|
443
|
-
matchOn: string[];
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Combine shared + page props, then apply partial-reload filtering and
|
|
447
|
-
* lazy/optional/deferred evaluation per the Inertia v3 protocol.
|
|
448
|
-
*
|
|
449
|
-
* Resolution order matches the official adapters:
|
|
450
|
-
* 1. Merge shared and page props (page wins on collision).
|
|
451
|
-
* 2. Determine if this is a partial reload for the same component.
|
|
452
|
-
* 3. For non-partial visits: drop optional and deferred props; keep everything
|
|
453
|
-
* else (lazy props are evaluated).
|
|
454
|
-
* 4. For partial visits: keep only keys in `partialOnly` (if set), then drop
|
|
455
|
-
* keys in `partialExcept`. Optional props are now eligible.
|
|
456
|
-
* 5. Evaluate every remaining function-shaped prop
|
|
457
|
-
* (lazy/optional/deferred/always) by calling it and awaiting the result.
|
|
458
|
-
* Independent props are evaluated in parallel via `Promise.all`.
|
|
459
|
-
* 6. Collect merge / deep-merge / match-on keys, excluding any key the client
|
|
460
|
-
* listed in `X-Inertia-Reset` — those props are reset (replaced) rather
|
|
461
|
-
* than appended.
|
|
462
|
-
*
|
|
463
|
-
* @param input Page + shared props, the component name, and parsed request info.
|
|
464
|
-
*/
|
|
465
|
-
declare function resolveProps(input: ResolvePropsInput): Promise<ResolvePropsResult>;
|
|
466
|
-
//#endregion
|
|
467
|
-
//#region src/core/redirects.d.ts
|
|
468
|
-
/**
|
|
469
|
-
* Status code Inertia uses for "soft" redirects after PUT/PATCH/DELETE so the
|
|
470
|
-
* follow-up GET is forced to also be a GET on every browser.
|
|
471
|
-
*/
|
|
472
|
-
declare const INERTIA_REDIRECT_STATUS = 303;
|
|
473
|
-
/**
|
|
474
|
-
* Status code used for the `X-Inertia-Location` external redirect
|
|
475
|
-
* mechanism. The client intercepts the 409 and performs a window.location
|
|
476
|
-
* navigation rather than a fetch.
|
|
477
|
-
*/
|
|
478
|
-
declare const INERTIA_LOCATION_STATUS = 409;
|
|
479
|
-
/**
|
|
480
|
-
* Decide which status code to use for a redirect produced by an Inertia
|
|
481
|
-
* request. After a non-GET/HEAD form submission the response must be 303
|
|
482
|
-
* so the client's follow-up request becomes a GET.
|
|
483
|
-
*
|
|
484
|
-
* @param method HTTP method of the inbound request (case-insensitive).
|
|
485
|
-
* @param fallback Status code to use for GET/HEAD/POST. Defaults to 302.
|
|
486
|
-
*/
|
|
487
|
-
declare function inertiaRedirectStatus(method: string, fallback?: number): number;
|
|
488
|
-
//#endregion
|
|
489
|
-
//#region src/core/render.d.ts
|
|
490
|
-
/**
|
|
491
|
-
* Inputs to {@link buildPage}. `TReq` is the framework's request type so
|
|
492
|
-
* `shared` (when a function) receives the correct argument shape.
|
|
493
|
-
*/
|
|
494
|
-
interface BuildPageInput<TReq = unknown> {
|
|
495
|
-
component: string;
|
|
496
|
-
props: PageProps;
|
|
497
|
-
request: InertiaRequestInfo;
|
|
498
|
-
req: TReq;
|
|
499
|
-
shared: SharedPropsInput<TReq> | undefined;
|
|
500
|
-
version: string | null;
|
|
501
|
-
options?: RenderOptions;
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Build the final {@link InertiaPage} object given a controller's component
|
|
505
|
-
* + props, the request info, and configured shared props / version.
|
|
506
|
-
*
|
|
507
|
-
* Returned page is suitable for either:
|
|
508
|
-
* - JSON serialization on `X-Inertia` requests, or
|
|
509
|
-
* - embedding into the root HTML view via a `<script>` page tag.
|
|
510
|
-
*
|
|
511
|
-
* @param input Component, props, parsed request, shared resolver, version, and
|
|
512
|
-
* optional `clearHistory` / `encryptHistory` flags.
|
|
513
|
-
*/
|
|
514
|
-
declare function buildPage<TReq>(input: BuildPageInput<TReq>): Promise<InertiaPage>;
|
|
515
|
-
//#endregion
|
|
516
|
-
//#region src/core/versioning.d.ts
|
|
517
|
-
/**
|
|
518
|
-
* Resolve a version value (string, async function, or null) against a request.
|
|
519
|
-
*
|
|
520
|
-
* Returns `null` when no version is configured — in which case asset version
|
|
521
|
-
* mismatch detection is disabled.
|
|
522
|
-
*
|
|
523
|
-
* @param resolver Static version string, a (possibly async) function, or undefined.
|
|
524
|
-
* @param req Request passed to the resolver when it is a function.
|
|
525
|
-
*/
|
|
526
|
-
declare function resolveVersion<TReq>(resolver: VersionResolver<TReq> | undefined, req: TReq): Promise<string | null>;
|
|
527
|
-
/**
|
|
528
|
-
* Returns true if the client's version (`X-Inertia-Version`) does not match
|
|
529
|
-
* the server's current version. Mismatches on GET requests should trigger a
|
|
530
|
-
* full reload via the `X-Inertia-Location` mechanism.
|
|
531
|
-
*
|
|
532
|
-
* @param serverVersion Currently configured server version; `null` disables checks.
|
|
533
|
-
* @param clientVersion Value of the `X-Inertia-Version` header; `null` is treated as empty.
|
|
534
|
-
*/
|
|
535
|
-
declare function isVersionMismatch(serverVersion: string | null, clientVersion: string | null): boolean;
|
|
536
|
-
//#endregion
|
|
537
|
-
export { type AlwaysProp, BuildPageInput, ComputeCacheKeyInput, CreatePageInput, type DeepMergeProp, DefaultRootViewInput, type DeferredProp, ErrorPageInput, INERTIA_HEADERS, INERTIA_LOCATION_STATUS, INERTIA_REDIRECT_STATUS, type InertiaPage, type InertiaRequestInfo, type LazyProp, type MergeProp, type OptionalProp, type PageProps, type PropValue, type RenderOptions, ResolvePropsInput, ResolvePropsResult, type SharedPropsInput, SsrCacheEntry, SsrCacheStore, ValidationErrors, type VersionResolver, always, buildPage, canonicalStringify, computeSsrCacheKey, createPage, deepMerge, defer, encodePageScript, inertiaRedirectStatus, isVersionMismatch, lazy, merge, optional, parseInertiaRequest, renderDefaultHtml, renderErrorPage, resolveProps, resolveVersion, scopeErrors };
|
|
538
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { $ as OnceMetadata, A as leadsToOnly, B as renderErrorPage, C as once, D as PropKind, E as PropDescriptor, F as createPage, G as unpackDotProps, H as parseInertiaRequest, I as DefaultRootViewInput, J as SsrCacheStore, K as ComputeCacheKeyInput, L as ErrorPageInput, M as matchesOnly, N as pathIsSameOrDescendant, O as PropSource, P as CreatePageInput, Q as InertiaRequestInfo, R as encodePageScript, S as merge, T as scroll, U as ValidationErrors, V as INERTIA_HEADERS, W as scopeErrors, X as computeSsrCacheKey, Y as canonicalStringify, Z as InertiaPage, _ as ScrollProp, a as INERTIA_LOCATION_STATUS, at as SharedPropsInput, b as defer, c as PropsResolver, d as resolveProps, et as PageProps, f as AlwaysProp, g as OptionalProp, h as OnceProp, i as buildPage, it as ScrollMetadata, j as matchesExcept, k as ScrollOptions, l as ResolvePropsInput, m as MergeProp, n as resolveVersion, nt as RenderOptions, o as INERTIA_REDIRECT_STATUS, ot as VersionResolver, p as DeferProp, q as SsrCacheEntry, r as BuildPageInput, rt as RescueHandler, s as inertiaRedirectStatus, t as isVersionMismatch, tt as PropsMetadata, u as ResolvePropsResult, v as always, w as optional, x as isPropDescriptor, y as deepMerge, z as renderDefaultHtml } from "../index-PWaujyMo.js";
|
|
2
|
+
export { AlwaysProp, BuildPageInput, ComputeCacheKeyInput, CreatePageInput, DefaultRootViewInput, DeferProp, ErrorPageInput, INERTIA_HEADERS, INERTIA_LOCATION_STATUS, INERTIA_REDIRECT_STATUS, type InertiaPage, type InertiaRequestInfo, MergeProp, type OnceMetadata, OnceProp, OptionalProp, type PageProps, PropDescriptor, type PropKind, type PropSource, type PropsMetadata, PropsResolver, type RenderOptions, type RescueHandler, ResolvePropsInput, ResolvePropsResult, type ScrollMetadata, type ScrollOptions, ScrollProp, type SharedPropsInput, SsrCacheEntry, SsrCacheStore, ValidationErrors, type VersionResolver, always, buildPage, canonicalStringify, computeSsrCacheKey, createPage, deepMerge, defer, encodePageScript, inertiaRedirectStatus, isPropDescriptor, isVersionMismatch, leadsToOnly, matchesExcept, matchesOnly, merge, once, optional, parseInertiaRequest, pathIsSameOrDescendant, renderDefaultHtml, renderErrorPage, resolveProps, resolveVersion, scopeErrors, scroll, unpackDotProps };
|