@inertiajs/core 2.1.1 → 2.1.2
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 +33 -5
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +33 -5
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/types/index.d.ts +1 -1
- package/types/prefetched.d.ts +2 -1
- package/types/router.d.ts +14 -13
- package/types/types.d.ts +14 -9
- package/types/url.d.ts +2 -1
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export { default as createHeadManager } from './head';
|
|
|
6
6
|
export { hide as hideProgress, reveal as revealProgress, default as setupProgress } from './progress';
|
|
7
7
|
export { default as shouldIntercept } from './shouldIntercept';
|
|
8
8
|
export * from './types';
|
|
9
|
-
export { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash } from './url';
|
|
9
|
+
export { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash, isUrlMethodPair } from './url';
|
|
10
10
|
export { type Router };
|
|
11
11
|
export declare const router: Router;
|
package/types/prefetched.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ declare class PrefetchedRequests {
|
|
|
5
5
|
protected inFlightRequests: InFlightPrefetch[];
|
|
6
6
|
protected removalTimers: PrefetchRemovalTimer[];
|
|
7
7
|
protected currentUseId: string | null;
|
|
8
|
-
add(params: ActiveVisit, sendFunc: (params: InternalActiveVisit) => void, { cacheFor }: PrefetchOptions): Promise<void> | Promise<Response>;
|
|
8
|
+
add(params: ActiveVisit, sendFunc: (params: InternalActiveVisit) => void, { cacheFor, cacheTags }: PrefetchOptions): Promise<void> | Promise<Response>;
|
|
9
9
|
removeAll(): void;
|
|
10
|
+
removeByTags(tags: string[]): void;
|
|
10
11
|
remove(params: ActiveVisit): void;
|
|
11
12
|
protected removeFromInFlight(params: ActiveVisit): void;
|
|
12
13
|
protected extractStaleValues(cacheFor: PrefetchOptions['cacheFor']): [number, number];
|
package/types/router.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { RequestStream } from './requestStream';
|
|
2
|
-
import { ActiveVisit, ClientSideVisitOptions, Component, GlobalEvent, GlobalEventNames, GlobalEventResult, InFlightPrefetch, Page, PendingVisit, PendingVisitOptions, PollOptions, PrefetchedResponse, PrefetchOptions, ReloadOptions, RequestPayload, RouterInitParams,
|
|
2
|
+
import { ActiveVisit, ClientSideVisitOptions, Component, GlobalEvent, GlobalEventNames, GlobalEventResult, InFlightPrefetch, Page, PendingVisit, PendingVisitOptions, PollOptions, PrefetchedResponse, PrefetchOptions, ReloadOptions, RequestPayload, RouterInitParams, UrlMethodPair, VisitCallbacks, VisitHelperOptions, VisitOptions } from './types';
|
|
3
3
|
export declare class Router {
|
|
4
4
|
protected syncRequestStream: RequestStream;
|
|
5
5
|
protected asyncRequestStream: RequestStream;
|
|
6
6
|
init({ initialPage, resolveComponent, swapComponent }: RouterInitParams): void;
|
|
7
|
-
get<T extends RequestPayload = RequestPayload>(url: URL | string, data?: T, options?: VisitHelperOptions<T>): void;
|
|
8
|
-
post<T extends RequestPayload = RequestPayload>(url: URL | string, data?: T, options?: VisitHelperOptions<T>): void;
|
|
9
|
-
put<T extends RequestPayload = RequestPayload>(url: URL | string, data?: T, options?: VisitHelperOptions<T>): void;
|
|
10
|
-
patch<T extends RequestPayload = RequestPayload>(url: URL | string, data?: T, options?: VisitHelperOptions<T>): void;
|
|
11
|
-
delete<T extends RequestPayload = RequestPayload>(url: URL | string, options?: Omit<VisitOptions<T>, 'method'>): void;
|
|
7
|
+
get<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
8
|
+
post<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
9
|
+
put<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
10
|
+
patch<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
11
|
+
delete<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, options?: Omit<VisitOptions<T>, 'method'>): void;
|
|
12
12
|
reload<T extends RequestPayload = RequestPayload>(options?: ReloadOptions<T>): void;
|
|
13
13
|
remember(data: unknown, key?: string): void;
|
|
14
14
|
restore(key?: string): unknown;
|
|
@@ -19,12 +19,13 @@ export declare class Router {
|
|
|
19
19
|
stop: VoidFunction;
|
|
20
20
|
start: VoidFunction;
|
|
21
21
|
};
|
|
22
|
-
visit<T extends RequestPayload = RequestPayload>(href: string | URL, options?: VisitOptions<T>): void;
|
|
23
|
-
getCached(href: string | URL, options?: VisitOptions): InFlightPrefetch | PrefetchedResponse | null;
|
|
24
|
-
flush(href: string | URL, options?: VisitOptions): void;
|
|
22
|
+
visit<T extends RequestPayload = RequestPayload>(href: string | URL | UrlMethodPair, options?: VisitOptions<T>): void;
|
|
23
|
+
getCached(href: string | URL | UrlMethodPair, options?: VisitOptions): InFlightPrefetch | PrefetchedResponse | null;
|
|
24
|
+
flush(href: string | URL | UrlMethodPair, options?: VisitOptions): void;
|
|
25
25
|
flushAll(): void;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
flushByCacheTags(tags: string | string[]): void;
|
|
27
|
+
getPrefetching(href: string | URL | UrlMethodPair, options?: VisitOptions): InFlightPrefetch | PrefetchedResponse | null;
|
|
28
|
+
prefetch(href: string | URL | UrlMethodPair, options?: VisitOptions, prefetchOptions?: Partial<PrefetchOptions>): void;
|
|
28
29
|
clearHistory(): void;
|
|
29
30
|
decryptHistory(): Promise<Page>;
|
|
30
31
|
resolveComponent(component: string): Promise<Component>;
|
|
@@ -33,8 +34,8 @@ export declare class Router {
|
|
|
33
34
|
protected clientVisit<TProps = Page['props']>(params: ClientSideVisitOptions<TProps>, { replace }?: {
|
|
34
35
|
replace?: boolean;
|
|
35
36
|
}): void;
|
|
36
|
-
protected getPrefetchParams(href: string | URL, options: VisitOptions): ActiveVisit;
|
|
37
|
-
protected getPendingVisit(href: string | URL, options: VisitOptions, pendingVisitOptions?: Partial<PendingVisitOptions>): PendingVisit;
|
|
37
|
+
protected getPrefetchParams(href: string | URL | UrlMethodPair, options: VisitOptions): ActiveVisit;
|
|
38
|
+
protected getPendingVisit(href: string | URL | UrlMethodPair, options: VisitOptions, pendingVisitOptions?: Partial<PendingVisitOptions>): PendingVisit;
|
|
38
39
|
protected getVisitEvents(options: VisitOptions): VisitCallbacks;
|
|
39
40
|
protected loadDeferredProps(): void;
|
|
40
41
|
}
|
package/types/types.d.ts
CHANGED
|
@@ -116,6 +116,7 @@ export type Visit<T extends RequestPayload = RequestPayload> = {
|
|
|
116
116
|
fresh: boolean;
|
|
117
117
|
reset: string[];
|
|
118
118
|
preserveUrl: boolean;
|
|
119
|
+
invalidateCacheTags: string | string[];
|
|
119
120
|
};
|
|
120
121
|
export type GlobalEventsMap<T extends RequestPayload = RequestPayload> = {
|
|
121
122
|
before: {
|
|
@@ -262,15 +263,14 @@ export type LinkPrefetchOption = 'mount' | 'hover' | 'click';
|
|
|
262
263
|
export type CacheForOption = number | string;
|
|
263
264
|
export type PrefetchOptions = {
|
|
264
265
|
cacheFor: CacheForOption | CacheForOption[];
|
|
266
|
+
cacheTags: string | string[];
|
|
265
267
|
};
|
|
266
268
|
export interface LinkComponentBaseProps extends Partial<Pick<Visit<RequestPayload>, 'data' | 'method' | 'replace' | 'preserveScroll' | 'preserveState' | 'only' | 'except' | 'headers' | 'queryStringArrayFormat' | 'async'> & Omit<VisitCallbacks, 'onCancelToken'> & {
|
|
267
|
-
href: string |
|
|
268
|
-
url: string;
|
|
269
|
-
method: Method;
|
|
270
|
-
};
|
|
269
|
+
href: string | UrlMethodPair;
|
|
271
270
|
onCancelToken: (cancelToken: import('axios').CancelTokenSource) => void;
|
|
272
271
|
prefetch: boolean | LinkPrefetchOption | LinkPrefetchOption[];
|
|
273
272
|
cacheFor: CacheForOption | CacheForOption[];
|
|
273
|
+
cacheTags: string | string[];
|
|
274
274
|
}> {
|
|
275
275
|
}
|
|
276
276
|
type PrefetchObject = {
|
|
@@ -290,6 +290,7 @@ export type PrefetchedResponse = PrefetchObject & {
|
|
|
290
290
|
timestamp: number;
|
|
291
291
|
singleUse: boolean;
|
|
292
292
|
inFlight: false;
|
|
293
|
+
tags: string[];
|
|
293
294
|
};
|
|
294
295
|
export type PrefetchRemovalTimer = {
|
|
295
296
|
params: ActiveVisit;
|
|
@@ -310,17 +311,21 @@ export type ProgressSettings = {
|
|
|
310
311
|
includeCSS: boolean;
|
|
311
312
|
color: string;
|
|
312
313
|
};
|
|
314
|
+
export type UrlMethodPair = {
|
|
315
|
+
url: string;
|
|
316
|
+
method: Method;
|
|
317
|
+
};
|
|
313
318
|
export type FormComponentOptions = Pick<VisitOptions, 'preserveScroll' | 'preserveState' | 'preserveUrl' | 'replace' | 'only' | 'except' | 'reset'>;
|
|
314
|
-
export type FormComponentProps = Partial<Pick<Visit, 'headers' | 'queryStringArrayFormat' | 'errorBag' | 'showProgress'> & Omit<VisitCallbacks, 'onPrefetched' | 'onPrefetching'>> & {
|
|
319
|
+
export type FormComponentProps = Partial<Pick<Visit, 'headers' | 'queryStringArrayFormat' | 'errorBag' | 'showProgress' | 'invalidateCacheTags'> & Omit<VisitCallbacks, 'onPrefetched' | 'onPrefetching'>> & {
|
|
315
320
|
method?: Method | Uppercase<Method>;
|
|
316
|
-
action?: string |
|
|
317
|
-
url: string;
|
|
318
|
-
method: Method;
|
|
319
|
-
};
|
|
321
|
+
action?: string | UrlMethodPair;
|
|
320
322
|
transform?: (data: Record<string, FormDataConvertible>) => Record<string, FormDataConvertible>;
|
|
321
323
|
options?: FormComponentOptions;
|
|
322
324
|
onSubmitComplete?: (props: FormComponentonSubmitCompleteArguments) => void;
|
|
323
325
|
disableWhileProcessing?: boolean;
|
|
326
|
+
resetOnSuccess?: boolean | string[];
|
|
327
|
+
resetOnError?: boolean | string[];
|
|
328
|
+
setDefaultsOnSuccess?: boolean;
|
|
324
329
|
};
|
|
325
330
|
export type FormComponentMethods = {
|
|
326
331
|
clearErrors: (...fields: string[]) => void;
|
package/types/url.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormDataConvertible, Method, RequestPayload, VisitOptions } from './types';
|
|
1
|
+
import { FormDataConvertible, Method, RequestPayload, UrlMethodPair, VisitOptions } from './types';
|
|
2
2
|
export declare function hrefToUrl(href: string | URL): URL;
|
|
3
3
|
export declare const transformUrlAndData: (href: string | URL, data: RequestPayload, method: Method, forceFormData: VisitOptions['forceFormData'], queryStringArrayFormat: VisitOptions['queryStringArrayFormat']) => [URL, RequestPayload];
|
|
4
4
|
type MergeDataIntoQueryStringDataReturnType<T extends RequestPayload> = T extends Record<string, FormDataConvertible> ? Record<string, FormDataConvertible> : RequestPayload;
|
|
@@ -6,4 +6,5 @@ export declare function mergeDataIntoQueryString<T extends RequestPayload>(metho
|
|
|
6
6
|
export declare function urlWithoutHash(url: URL | Location): URL;
|
|
7
7
|
export declare const setHashIfSameUrl: (originUrl: URL | Location, destinationUrl: URL | Location) => void;
|
|
8
8
|
export declare const isSameUrlWithoutHash: (url1: URL | Location, url2: URL | Location) => boolean;
|
|
9
|
+
export declare function isUrlMethodPair(href: unknown): href is UrlMethodPair;
|
|
9
10
|
export {};
|