@inertiajs/core 2.2.7 → 2.2.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 +100 -35
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +114 -49
- package/dist/index.js.map +4 -4
- package/package.json +5 -5
- package/types/debug.d.ts +1 -1
- package/types/head.d.ts +2 -7
- package/types/navigationEvents.d.ts +5 -2
- package/types/page.d.ts +10 -6
- package/types/requestParams.d.ts +1 -1
- package/types/router.d.ts +1 -1
- package/types/scroll.d.ts +1 -0
- package/types/types.d.ts +53 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A framework for creating server-driven single page apps.",
|
|
6
6
|
"contributors": [
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/deepmerge": "^2.2.3",
|
|
54
|
-
"@types/node": "^18.19.
|
|
54
|
+
"@types/node": "^18.19.130",
|
|
55
55
|
"@types/nprogress": "^0.2.3",
|
|
56
56
|
"@types/qs": "^6.14.0",
|
|
57
|
-
"es-check": "^9.
|
|
58
|
-
"esbuild": "^0.25.
|
|
57
|
+
"es-check": "^9.4.4",
|
|
58
|
+
"esbuild": "^0.25.11",
|
|
59
59
|
"esbuild-node-externals": "^1.18.0",
|
|
60
|
-
"typescript": "^5.9.
|
|
60
|
+
"typescript": "^5.9.3"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "pnpm clean && ./build.js && tsc",
|
package/types/debug.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const stackTrace: (autolog?: boolean) =>
|
|
1
|
+
export declare const stackTrace: (autolog?: boolean) => string | undefined;
|
package/types/head.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
createProvider: () => {
|
|
4
|
-
update: (elements: string[]) => void;
|
|
5
|
-
disconnect: () => void;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
1
|
+
import { HeadManager, HeadManagerOnUpdateCallback, HeadManagerTitleCallback } from '.';
|
|
2
|
+
export default function createHeadManager(isServer: boolean, titleCallback: HeadManagerTitleCallback, onUpdate: HeadManagerOnUpdateCallback): HeadManager;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
type MouseNavigationEvent = Pick<MouseEvent, 'altKey' | 'ctrlKey' | 'shiftKey' | 'metaKey' | 'button' | 'currentTarget' | 'defaultPrevented' | 'target'>;
|
|
2
|
+
type KeyboardNavigationEvent = Pick<KeyboardEvent, 'currentTarget' | 'defaultPrevented' | 'key' | 'target'>;
|
|
1
3
|
/**
|
|
2
4
|
* Determine if this mouse event should be intercepted for navigation purposes.
|
|
3
5
|
* Links with modifier keys or non-left clicks should not be intercepted.
|
|
4
6
|
* Content editable elements and prevented events are ignored.
|
|
5
7
|
*/
|
|
6
|
-
export declare function shouldIntercept(event:
|
|
8
|
+
export declare function shouldIntercept(event: MouseNavigationEvent): boolean;
|
|
7
9
|
/**
|
|
8
10
|
* Determine if this keyboard event should trigger a navigation request.
|
|
9
11
|
* Enter triggers navigation for both links and buttons currently.
|
|
10
12
|
* Space only triggers navigation for buttons specifically.
|
|
11
13
|
*/
|
|
12
|
-
export declare function shouldNavigate(event:
|
|
14
|
+
export declare function shouldNavigate(event: KeyboardNavigationEvent): boolean;
|
|
15
|
+
export {};
|
package/types/page.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Component, Page, PageEvent, PageHandler, PageResolver,
|
|
1
|
+
import { Component, Page, PageEvent, PageHandler, PageResolver, RouterInitParams } from './types';
|
|
2
2
|
declare class CurrentPage {
|
|
3
3
|
protected page: Page;
|
|
4
|
-
protected swapComponent: PageHandler
|
|
4
|
+
protected swapComponent: PageHandler<any>;
|
|
5
5
|
protected resolveComponent: PageResolver;
|
|
6
6
|
protected componentId: {};
|
|
7
7
|
protected listeners: {
|
|
@@ -11,10 +11,14 @@ declare class CurrentPage {
|
|
|
11
11
|
protected isFirstPageLoad: boolean;
|
|
12
12
|
protected cleared: boolean;
|
|
13
13
|
protected pendingDeferredProps: Pick<Page, 'deferredProps' | 'url' | 'component'> | null;
|
|
14
|
-
init({ initialPage, swapComponent, resolveComponent }: RouterInitParams): this;
|
|
15
|
-
set(page: Page, { replace, preserveScroll, preserveState, }?:
|
|
14
|
+
init<ComponentType = Component>({ initialPage, swapComponent, resolveComponent, }: RouterInitParams<ComponentType>): this;
|
|
15
|
+
set(page: Page, { replace, preserveScroll, preserveState, }?: {
|
|
16
|
+
replace?: boolean;
|
|
17
|
+
preserveScroll?: boolean;
|
|
18
|
+
preserveState?: boolean;
|
|
19
|
+
}): Promise<void>;
|
|
16
20
|
setQuietly(page: Page, { preserveState, }?: {
|
|
17
|
-
preserveState?:
|
|
21
|
+
preserveState?: boolean;
|
|
18
22
|
}): Promise<unknown>;
|
|
19
23
|
clear(): void;
|
|
20
24
|
isCleared(): boolean;
|
|
@@ -25,7 +29,7 @@ declare class CurrentPage {
|
|
|
25
29
|
swap({ component, page, preserveState, }: {
|
|
26
30
|
component: Component;
|
|
27
31
|
page: Page;
|
|
28
|
-
preserveState:
|
|
32
|
+
preserveState: boolean;
|
|
29
33
|
}): Promise<unknown>;
|
|
30
34
|
resolve(component: string): Promise<Component>;
|
|
31
35
|
isTheSame(page: Page): boolean;
|
package/types/requestParams.d.ts
CHANGED
|
@@ -31,5 +31,5 @@ export declare class RequestParams {
|
|
|
31
31
|
merge(toMerge: Partial<ActiveVisit>): void;
|
|
32
32
|
protected wrapCallback(params: ActiveVisit, name: keyof VisitCallbacks): (...args: any[]) => void;
|
|
33
33
|
protected recordCallback(name: keyof VisitCallbacks, args: any[]): void;
|
|
34
|
-
|
|
34
|
+
static resolvePreserveOption(value: PreserveStateOption, page: Page): boolean;
|
|
35
35
|
}
|
package/types/router.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ActiveVisit, ClientSideVisitOptions, Component, GlobalEvent, GlobalEven
|
|
|
3
3
|
export declare class Router {
|
|
4
4
|
protected syncRequestStream: RequestStream;
|
|
5
5
|
protected asyncRequestStream: RequestStream;
|
|
6
|
-
init({ initialPage, resolveComponent, swapComponent }: RouterInitParams): void;
|
|
6
|
+
init<ComponentType = Component>({ initialPage, resolveComponent, swapComponent, }: RouterInitParams<ComponentType>): void;
|
|
7
7
|
get<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
8
8
|
post<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
9
9
|
put<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
package/types/scroll.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare class Scroll {
|
|
|
4
4
|
protected static regions(): NodeListOf<Element>;
|
|
5
5
|
static reset(): void;
|
|
6
6
|
static restore(scrollRegions: ScrollRegion[]): void;
|
|
7
|
+
static restoreScrollRegions(scrollRegions: ScrollRegion[]): void;
|
|
7
8
|
static restoreDocument(): void;
|
|
8
9
|
static onScroll(event: Event): void;
|
|
9
10
|
static onWindowScroll(): void;
|
package/types/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare module 'axios' {
|
|
|
7
7
|
}
|
|
8
8
|
export type DefaultInertiaConfig = {
|
|
9
9
|
errorValueType: string;
|
|
10
|
+
sharedPageProps: PageProps;
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
13
|
* Designed to allow overriding of some core types using TypeScript
|
|
@@ -18,6 +19,10 @@ export type DefaultInertiaConfig = {
|
|
|
18
19
|
* declare module '@inertiajs/core' {
|
|
19
20
|
* export interface InertiaConfig {
|
|
20
21
|
* errorValueType: string[]
|
|
22
|
+
* sharedPageProps: {
|
|
23
|
+
* auth: { user: User | null }
|
|
24
|
+
* flash: { success?: string; error?: string }
|
|
25
|
+
* }
|
|
21
26
|
* }
|
|
22
27
|
* }
|
|
23
28
|
* ```
|
|
@@ -26,6 +31,7 @@ export interface InertiaConfig {
|
|
|
26
31
|
}
|
|
27
32
|
export type InertiaConfigFor<Key extends keyof DefaultInertiaConfig> = Key extends keyof InertiaConfig ? InertiaConfig[Key] : DefaultInertiaConfig[Key];
|
|
28
33
|
export type ErrorValue = InertiaConfigFor<'errorValueType'>;
|
|
34
|
+
export type SharedPageProps = InertiaConfigFor<'sharedPageProps'>;
|
|
29
35
|
export type Errors = Record<string, ErrorValue>;
|
|
30
36
|
export type ErrorBag = Record<string, Errors>;
|
|
31
37
|
export type FormDataConvertibleValue = Blob | FormDataEntryValue | Date | boolean | number | null | undefined;
|
|
@@ -97,16 +103,20 @@ export interface ClientSideVisitOptions<TProps = Page['props']> {
|
|
|
97
103
|
onSuccess?: (page: Page) => void;
|
|
98
104
|
}
|
|
99
105
|
export type PageResolver = (name: string) => Component;
|
|
100
|
-
export type PageHandler = ({ component, page, preserveState, }: {
|
|
101
|
-
component:
|
|
106
|
+
export type PageHandler<ComponentType = Component> = ({ component, page, preserveState, }: {
|
|
107
|
+
component: ComponentType;
|
|
102
108
|
page: Page;
|
|
103
|
-
preserveState:
|
|
109
|
+
preserveState: boolean;
|
|
104
110
|
}) => Promise<unknown>;
|
|
105
111
|
export type PreserveStateOption = boolean | 'errors' | ((page: Page) => boolean);
|
|
106
112
|
export type Progress = AxiosProgressEvent;
|
|
107
113
|
export type LocationVisit = {
|
|
108
114
|
preserveScroll: boolean;
|
|
109
115
|
};
|
|
116
|
+
export type CancelToken = {
|
|
117
|
+
cancel: VoidFunction;
|
|
118
|
+
};
|
|
119
|
+
export type CancelTokenCallback = (cancelToken: CancelToken) => void;
|
|
110
120
|
export type Visit<T extends RequestPayload = RequestPayload> = {
|
|
111
121
|
method: Method;
|
|
112
122
|
data: T;
|
|
@@ -230,11 +240,7 @@ export type GlobalEventTrigger<TEventName extends GlobalEventNames<T>, T extends
|
|
|
230
240
|
export type GlobalEventCallback<TEventName extends GlobalEventNames<T>, T extends RequestPayload = RequestPayload> = (...params: GlobalEventParameters<TEventName, T>) => GlobalEventResult<TEventName, T>;
|
|
231
241
|
export type InternalEvent = 'missingHistoryItem' | 'loadDeferredProps';
|
|
232
242
|
export type VisitCallbacks<T extends RequestPayload = RequestPayload> = {
|
|
233
|
-
onCancelToken:
|
|
234
|
-
({ cancel }: {
|
|
235
|
-
cancel: VoidFunction;
|
|
236
|
-
}): void;
|
|
237
|
-
};
|
|
243
|
+
onCancelToken: CancelTokenCallback;
|
|
238
244
|
onBefore: GlobalEventCallback<'before', T>;
|
|
239
245
|
onBeforeUpdate: GlobalEventCallback<'beforeUpdate', T>;
|
|
240
246
|
onStart: GlobalEventCallback<'start', T>;
|
|
@@ -253,10 +259,10 @@ export type PollOptions = {
|
|
|
253
259
|
autoStart?: boolean;
|
|
254
260
|
};
|
|
255
261
|
export type VisitHelperOptions<T extends RequestPayload = RequestPayload> = Omit<VisitOptions<T>, 'method' | 'data'>;
|
|
256
|
-
export type RouterInitParams = {
|
|
262
|
+
export type RouterInitParams<ComponentType = Component> = {
|
|
257
263
|
initialPage: Page;
|
|
258
264
|
resolveComponent: PageResolver;
|
|
259
|
-
swapComponent: PageHandler
|
|
265
|
+
swapComponent: PageHandler<ComponentType>;
|
|
260
266
|
};
|
|
261
267
|
export type PendingVisitOptions = {
|
|
262
268
|
url: URL;
|
|
@@ -272,19 +278,51 @@ export type InternalActiveVisit = ActiveVisit & {
|
|
|
272
278
|
};
|
|
273
279
|
export type VisitId = unknown;
|
|
274
280
|
export type Component = unknown;
|
|
275
|
-
|
|
281
|
+
interface CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn> {
|
|
282
|
+
resolve: TComponentResolver;
|
|
283
|
+
setup: (options: TSetupOptions) => TSetupReturn;
|
|
284
|
+
title?: HeadManagerTitleCallback;
|
|
285
|
+
}
|
|
286
|
+
export interface CreateInertiaAppOptionsForCSR<SharedProps extends PageProps, TComponentResolver, TSetupOptions, TSetupReturn> extends CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn> {
|
|
287
|
+
id?: string;
|
|
288
|
+
page?: Page<SharedProps>;
|
|
289
|
+
progress?: false | {
|
|
290
|
+
delay?: number;
|
|
291
|
+
color?: string;
|
|
292
|
+
includeCSS?: boolean;
|
|
293
|
+
showSpinner?: boolean;
|
|
294
|
+
};
|
|
295
|
+
render?: undefined;
|
|
296
|
+
}
|
|
297
|
+
export interface CreateInertiaAppOptionsForSSR<SharedProps extends PageProps, TComponentResolver, TSetupOptions, TSetupReturn> extends CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn> {
|
|
298
|
+
id?: undefined;
|
|
299
|
+
page: Page<SharedProps>;
|
|
300
|
+
progress?: undefined;
|
|
301
|
+
render: unknown;
|
|
302
|
+
}
|
|
303
|
+
export type InertiaAppSSRResponse = {
|
|
276
304
|
head: string[];
|
|
277
305
|
body: string;
|
|
278
|
-
}
|
|
306
|
+
};
|
|
307
|
+
export type InertiaAppResponse = Promise<InertiaAppSSRResponse | void>;
|
|
308
|
+
export type HeadManagerTitleCallback = (title: string) => string;
|
|
309
|
+
export type HeadManagerOnUpdateCallback = (elements: string[]) => void;
|
|
310
|
+
export type HeadManager = {
|
|
311
|
+
forceUpdate: () => void;
|
|
312
|
+
createProvider: () => {
|
|
313
|
+
reconnect: () => void;
|
|
314
|
+
update: HeadManagerOnUpdateCallback;
|
|
315
|
+
disconnect: () => void;
|
|
316
|
+
};
|
|
317
|
+
};
|
|
279
318
|
export type LinkPrefetchOption = 'mount' | 'hover' | 'click';
|
|
280
319
|
export type CacheForOption = number | string;
|
|
281
320
|
export type PrefetchOptions = {
|
|
282
321
|
cacheFor: CacheForOption | CacheForOption[];
|
|
283
322
|
cacheTags: string | string[];
|
|
284
323
|
};
|
|
285
|
-
export interface LinkComponentBaseProps extends Partial<Pick<Visit<RequestPayload>, 'data' | 'method' | 'replace' | 'preserveScroll' | 'preserveState' | 'preserveUrl' | 'only' | 'except' | 'headers' | 'queryStringArrayFormat' | 'async'> &
|
|
324
|
+
export interface LinkComponentBaseProps extends Partial<Pick<Visit<RequestPayload>, 'data' | 'method' | 'replace' | 'preserveScroll' | 'preserveState' | 'preserveUrl' | 'only' | 'except' | 'headers' | 'queryStringArrayFormat' | 'async'> & VisitCallbacks & {
|
|
286
325
|
href: string | UrlMethodPair;
|
|
287
|
-
onCancelToken: (cancelToken: import('axios').CancelTokenSource) => void;
|
|
288
326
|
prefetch: boolean | LinkPrefetchOption | LinkPrefetchOption[];
|
|
289
327
|
cacheFor: CacheForOption | CacheForOption[];
|
|
290
328
|
cacheTags: string | string[];
|
|
@@ -428,7 +466,7 @@ export interface InfiniteScrollRef {
|
|
|
428
466
|
hasNext: () => boolean;
|
|
429
467
|
}
|
|
430
468
|
export interface InfiniteScrollComponentBaseProps {
|
|
431
|
-
data
|
|
469
|
+
data: string;
|
|
432
470
|
buffer?: number;
|
|
433
471
|
as?: string;
|
|
434
472
|
manual?: boolean;
|