inertiax-core 2.6.2 → 5.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/dist/index.esm.js +6 -6
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +6 -6
- package/dist/index.js.map +4 -4
- package/package.json +10 -7
- package/types/debug.d.ts +1 -0
- package/types/encryption.d.ts +6 -0
- package/types/eventHandler.d.ts +17 -0
- package/types/events.d.ts +2 -0
- package/types/formData.d.ts +1 -0
- package/types/history.d.ts +26 -0
- package/types/index.d.ts +2 -4
- package/types/initialVisit.d.ts +10 -0
- package/types/navigationType.d.ts +9 -0
- package/types/objectUtils.d.ts +1 -0
- package/types/page.d.ts +45 -0
- package/types/poll.d.ts +13 -0
- package/types/polls.d.ts +14 -0
- package/types/prefetched.d.ts +23 -0
- package/types/progress.d.ts +2 -0
- package/types/request.d.ts +22 -0
- package/types/requestParams.d.ts +34 -0
- package/types/requestStream.d.ts +18 -0
- package/types/response.d.ts +31 -0
- package/types/router.d.ts +31 -56
- package/types/scroll.d.ts +8 -0
- package/types/sessionStorage.d.ts +10 -0
- package/types/shouldIntercept.d.ts +1 -1
- package/types/time.d.ts +1 -0
- package/types/types.d.ts +93 -18
- package/types/url.d.ts +4 -1
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Router } from './router';
|
|
2
1
|
export { default as createHeadManager } from './head';
|
|
3
|
-
export { default as setupProgress } from './progress';
|
|
2
|
+
export { hide as hideProgress, reveal as revealProgress, default as setupProgress } from './progress';
|
|
4
3
|
export { default as shouldIntercept } from './shouldIntercept';
|
|
5
4
|
export * from './types';
|
|
6
5
|
export { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash } from './url';
|
|
7
|
-
export {
|
|
8
|
-
export declare const router: Router;
|
|
6
|
+
export { Router } from './router';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class InitialVisit {
|
|
2
|
+
static handle(): void;
|
|
3
|
+
protected static clearRememberedStateOnReload(): void;
|
|
4
|
+
protected static handleBackForward(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* @link https://inertiajs.com/redirects#external-redirects
|
|
7
|
+
*/
|
|
8
|
+
protected static handleLocation(): boolean;
|
|
9
|
+
protected static handleDefault(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const objectsAreEqual: <T>(obj1: T, obj2: T, excludeKeys: { [K in keyof T]: K; }[keyof T][]) => boolean;
|
package/types/page.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Frame, Component, Page, PageEvent, FrameHandler, PreserveStateOption, RouterInitParams, VisitOptions } from './types';
|
|
2
|
+
declare class CurrentPage {
|
|
3
|
+
protected page: Page;
|
|
4
|
+
protected swappers: {
|
|
5
|
+
[frame: string]: FrameHandler;
|
|
6
|
+
};
|
|
7
|
+
protected componentId: {};
|
|
8
|
+
protected listeners: {
|
|
9
|
+
event: PageEvent;
|
|
10
|
+
callback: VoidFunction;
|
|
11
|
+
}[];
|
|
12
|
+
protected isFirstPageLoad: boolean;
|
|
13
|
+
protected cleared: boolean;
|
|
14
|
+
init({ frame, initialState, swapComponent }: RouterInitParams): this;
|
|
15
|
+
set(page: Page, { replace, preserveScroll, preserveState, }?: Partial<Pick<VisitOptions, 'replace' | 'preserveScroll' | 'preserveState'>>): Promise<void>;
|
|
16
|
+
setQuietly(page: Page, { preserveState, }?: {
|
|
17
|
+
preserveState?: PreserveStateOption;
|
|
18
|
+
}): Promise<unknown>;
|
|
19
|
+
setFrame(name: string, frame: Frame, options?: Partial<VisitOptions>): Promise<void>;
|
|
20
|
+
clear(): void;
|
|
21
|
+
isCleared(): boolean;
|
|
22
|
+
frame(name: string): Frame;
|
|
23
|
+
get(): Page;
|
|
24
|
+
merge(data: Partial<Page>): void;
|
|
25
|
+
setUrlHash(hash: string): void;
|
|
26
|
+
remember(frame: string, data: Frame['rememberedState']): void;
|
|
27
|
+
scrollRegions(regions: Page['scrollRegions']): void;
|
|
28
|
+
swap({ components, page, preserveState, }: {
|
|
29
|
+
components: {
|
|
30
|
+
[name: string]: Component;
|
|
31
|
+
};
|
|
32
|
+
page: Page;
|
|
33
|
+
preserveState: PreserveStateOption;
|
|
34
|
+
}): Promise<unknown>;
|
|
35
|
+
resolve(frames: {
|
|
36
|
+
[name: string]: Frame;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
[name: string]: Component;
|
|
39
|
+
}>;
|
|
40
|
+
isTheSame(name: string, frame: Frame): boolean;
|
|
41
|
+
on(event: PageEvent, callback: VoidFunction): VoidFunction;
|
|
42
|
+
fireEventsFor(event: PageEvent): void;
|
|
43
|
+
}
|
|
44
|
+
export declare const page: CurrentPage;
|
|
45
|
+
export {};
|
package/types/poll.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PollOptions } from './types';
|
|
2
|
+
export declare class Poll {
|
|
3
|
+
protected id: number | null;
|
|
4
|
+
protected throttle: boolean;
|
|
5
|
+
protected keepAlive: boolean;
|
|
6
|
+
protected cb: VoidFunction;
|
|
7
|
+
protected interval: number;
|
|
8
|
+
protected cbCount: number;
|
|
9
|
+
constructor(interval: number, cb: VoidFunction, options: PollOptions);
|
|
10
|
+
stop(): void;
|
|
11
|
+
start(): void;
|
|
12
|
+
isInBackground(hidden: boolean): void;
|
|
13
|
+
}
|
package/types/polls.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Poll } from './poll';
|
|
2
|
+
import { PollOptions } from './types';
|
|
3
|
+
declare class Polls {
|
|
4
|
+
protected polls: Poll[];
|
|
5
|
+
constructor();
|
|
6
|
+
add(interval: number, cb: VoidFunction, options: PollOptions): {
|
|
7
|
+
stop: VoidFunction;
|
|
8
|
+
start: VoidFunction;
|
|
9
|
+
};
|
|
10
|
+
clear(): void;
|
|
11
|
+
protected setupVisibilityListener(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const polls: Polls;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Response } from './response';
|
|
2
|
+
import { ActiveVisit, CacheForOption, InFlightPrefetch, InternalActiveVisit, PrefetchedResponse, PrefetchOptions, PrefetchRemovalTimer } from './types';
|
|
3
|
+
declare class PrefetchedRequests {
|
|
4
|
+
protected cached: PrefetchedResponse[];
|
|
5
|
+
protected inFlightRequests: InFlightPrefetch[];
|
|
6
|
+
protected removalTimers: PrefetchRemovalTimer[];
|
|
7
|
+
protected currentUseId: string | null;
|
|
8
|
+
add(params: ActiveVisit, sendFunc: (params: InternalActiveVisit) => void, { cacheFor }: PrefetchOptions): Promise<void> | Promise<Response>;
|
|
9
|
+
removeAll(): void;
|
|
10
|
+
remove(params: ActiveVisit): void;
|
|
11
|
+
protected extractStaleValues(cacheFor: PrefetchOptions['cacheFor']): [number, number];
|
|
12
|
+
protected cacheForToStaleAndExpires(cacheFor: PrefetchOptions['cacheFor']): [CacheForOption, CacheForOption];
|
|
13
|
+
protected clearTimer(params: ActiveVisit): void;
|
|
14
|
+
protected scheduleForRemoval(params: ActiveVisit, expiresIn: number): void;
|
|
15
|
+
get(params: ActiveVisit): InFlightPrefetch | PrefetchedResponse | null;
|
|
16
|
+
use(prefetched: PrefetchedResponse | InFlightPrefetch, params: ActiveVisit): Promise<void | undefined>;
|
|
17
|
+
protected removeSingleUseItems(params: ActiveVisit): void;
|
|
18
|
+
findCached(params: ActiveVisit): PrefetchedResponse | null;
|
|
19
|
+
findInFlight(params: ActiveVisit): InFlightPrefetch | null;
|
|
20
|
+
protected paramsAreEqual(params1: ActiveVisit, params2: ActiveVisit): boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare const prefetchedRequests: PrefetchedRequests;
|
|
23
|
+
export {};
|
package/types/progress.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AxiosProgressEvent, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { RequestParams } from './requestParams';
|
|
3
|
+
import { Response } from './response';
|
|
4
|
+
import { ActiveVisit, Page } from './types';
|
|
5
|
+
export declare class Request {
|
|
6
|
+
protected page: Page;
|
|
7
|
+
protected response: Response;
|
|
8
|
+
protected cancelToken: AbortController;
|
|
9
|
+
protected requestParams: RequestParams;
|
|
10
|
+
protected requestHasFinished: boolean;
|
|
11
|
+
constructor(params: ActiveVisit, page: Page);
|
|
12
|
+
static create(params: ActiveVisit, page: Page): Request;
|
|
13
|
+
send(): Promise<void | undefined>;
|
|
14
|
+
protected finish(): void;
|
|
15
|
+
protected fireFinishEvents(): void;
|
|
16
|
+
cancel({ cancelled, interrupted }: {
|
|
17
|
+
cancelled?: boolean;
|
|
18
|
+
interrupted?: boolean;
|
|
19
|
+
}): void;
|
|
20
|
+
protected onProgress(progress: AxiosProgressEvent): void;
|
|
21
|
+
protected getHeaders(): AxiosRequestConfig['headers'];
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { Response } from './response';
|
|
3
|
+
import { ActiveVisit, InternalActiveVisit, Page, PreserveStateOption, VisitCallbacks } from './types';
|
|
4
|
+
export declare class RequestParams {
|
|
5
|
+
protected callbacks: {
|
|
6
|
+
name: keyof VisitCallbacks;
|
|
7
|
+
args: any[];
|
|
8
|
+
}[];
|
|
9
|
+
protected params: InternalActiveVisit;
|
|
10
|
+
constructor(params: InternalActiveVisit);
|
|
11
|
+
static create(params: ActiveVisit): RequestParams;
|
|
12
|
+
data(): import("./types").RequestPayload;
|
|
13
|
+
queryParams(): import("./types").RequestPayload;
|
|
14
|
+
isPartial(): boolean;
|
|
15
|
+
onCancelToken(cb: VoidFunction): void;
|
|
16
|
+
markAsFinished(): void;
|
|
17
|
+
markAsCancelled({ cancelled, interrupted }: {
|
|
18
|
+
cancelled?: boolean | undefined;
|
|
19
|
+
interrupted?: boolean | undefined;
|
|
20
|
+
}): void;
|
|
21
|
+
wasCancelledAtAll(): boolean;
|
|
22
|
+
onFinish(): void;
|
|
23
|
+
onStart(): void;
|
|
24
|
+
onPrefetching(): void;
|
|
25
|
+
onPrefetchResponse(response: Response): void;
|
|
26
|
+
all(): InternalActiveVisit;
|
|
27
|
+
headers(): AxiosRequestConfig['headers'];
|
|
28
|
+
setPreserveOptions(page: Page): void;
|
|
29
|
+
runCallbacks(): void;
|
|
30
|
+
merge(toMerge: Partial<ActiveVisit>): void;
|
|
31
|
+
protected wrapCallback(params: ActiveVisit, name: keyof VisitCallbacks): (...args: any[]) => void;
|
|
32
|
+
protected recordCallback(name: keyof VisitCallbacks, args: any[]): void;
|
|
33
|
+
protected resolvePreserveOption(value: PreserveStateOption, page: Page): boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Request } from './request';
|
|
2
|
+
export declare class RequestStream {
|
|
3
|
+
protected requests: Request[];
|
|
4
|
+
protected maxConcurrent: number;
|
|
5
|
+
protected interruptible: boolean;
|
|
6
|
+
constructor({ maxConcurrent, interruptible }: {
|
|
7
|
+
maxConcurrent: number;
|
|
8
|
+
interruptible: boolean;
|
|
9
|
+
});
|
|
10
|
+
send(request: Request): void;
|
|
11
|
+
interruptInFlight(): void;
|
|
12
|
+
cancelInFlight(): void;
|
|
13
|
+
protected cancel({ cancelled, interrupted }: {
|
|
14
|
+
cancelled?: boolean | undefined;
|
|
15
|
+
interrupted?: boolean | undefined;
|
|
16
|
+
} | undefined, force: boolean): void;
|
|
17
|
+
protected shouldCancel(force: boolean): boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { RequestParams } from './requestParams';
|
|
3
|
+
import { ActiveVisit, ErrorBag, Errors, Page, Frame } from './types';
|
|
4
|
+
export declare class Response {
|
|
5
|
+
protected requestParams: RequestParams;
|
|
6
|
+
protected response: AxiosResponse;
|
|
7
|
+
protected originatingPage: Page;
|
|
8
|
+
constructor(requestParams: RequestParams, response: AxiosResponse, originatingPage: Page);
|
|
9
|
+
static create(params: RequestParams, response: AxiosResponse, originatingPage: Page): Response;
|
|
10
|
+
handlePrefetch(): Promise<void>;
|
|
11
|
+
handle(): Promise<void>;
|
|
12
|
+
process(): Promise<boolean | void>;
|
|
13
|
+
mergeParams(params: ActiveVisit): void;
|
|
14
|
+
protected handleNonInertiaResponse(): Promise<boolean | void>;
|
|
15
|
+
protected isInertiaResponse(): boolean;
|
|
16
|
+
protected hasStatus(status: number): boolean;
|
|
17
|
+
protected getHeader(header: string): string;
|
|
18
|
+
protected hasHeader(header: string): boolean;
|
|
19
|
+
protected isLocationVisit(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @link https://inertiajs.com/redirects#external-redirects
|
|
22
|
+
*/
|
|
23
|
+
protected locationVisit(url: URL): boolean | void;
|
|
24
|
+
protected setFrame(): Promise<void>;
|
|
25
|
+
protected getDataFromResponse(response: any): any;
|
|
26
|
+
protected shouldSetFrame(pageResponse: Frame): boolean;
|
|
27
|
+
protected pageUrl(pageResponse: Frame): string;
|
|
28
|
+
protected mergeProps(pageResponse: Frame): void;
|
|
29
|
+
protected setRememberedState(pageResponse: Frame): Promise<void>;
|
|
30
|
+
protected getScopedErrors(errors: Errors & ErrorBag): Errors;
|
|
31
|
+
}
|
package/types/router.d.ts
CHANGED
|
@@ -1,61 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActiveVisit, GlobalEvent, GlobalEventNames, GlobalEventResult,
|
|
1
|
+
import { RequestStream } from './requestStream';
|
|
2
|
+
import { ActiveVisit, GlobalEvent, GlobalEventNames, GlobalEventResult, InFlightPrefetch, Page, PendingVisit, PendingVisitOptions, PollOptions, PrefetchedResponse, PrefetchOptions, ReloadOptions, RequestPayload, PageResolver, RouterInitParams, Visit, VisitCallbacks, VisitHelperOptions, VisitOptions } from './types';
|
|
3
3
|
export declare class Router {
|
|
4
|
-
|
|
5
|
-
protected
|
|
6
|
-
protected
|
|
7
|
-
protected
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
protected setNavigationType(): void;
|
|
16
|
-
protected clearRememberedStateOnReload(): void;
|
|
17
|
-
protected handleInitialPageVisit(page: Page): void;
|
|
18
|
-
protected setupEventListeners(): void;
|
|
19
|
-
protected scrollRegions(): NodeListOf<Element>;
|
|
20
|
-
protected handleScrollEvent(event: Event): void;
|
|
21
|
-
protected saveScrollPositions(): void;
|
|
22
|
-
protected resetScrollPositions(): void;
|
|
23
|
-
protected restoreScrollPositions(): void;
|
|
24
|
-
protected isBackForwardVisit(): boolean;
|
|
25
|
-
protected handleBackForwardVisit(page: Page): void;
|
|
26
|
-
protected locationVisit(url: URL, preserveScroll: LocationVisit['preserveScroll']): boolean | void;
|
|
27
|
-
protected isLocationVisit(): boolean;
|
|
28
|
-
protected handleLocationVisit(page: Page): void;
|
|
29
|
-
protected isLocationVisitResponse(response: AxiosResponse): boolean;
|
|
30
|
-
protected isInertiaResponse(response: AxiosResponse): boolean;
|
|
31
|
-
protected createVisitId(): VisitId;
|
|
32
|
-
protected cancelVisit(activeVisit: ActiveVisit, { cancelled, interrupted }: {
|
|
33
|
-
cancelled?: boolean;
|
|
34
|
-
interrupted?: boolean;
|
|
35
|
-
}): void;
|
|
36
|
-
protected finishVisit(visit: ActiveVisit): void;
|
|
37
|
-
protected resolvePreserveOption(value: PreserveStateOption, page: Page): boolean | string;
|
|
38
|
-
cancel(): void;
|
|
39
|
-
visit(href: string | URL, { method, data, replace, preserveScroll, preserveState, preserveURL, only, headers, errorBag, forceFormData, target, component, hint, onCancelToken, onBefore, onStart, onProgress, onFinish, onCancel, onSuccess, onError, transformProps, queryStringArrayFormat, }?: VisitOptions): void;
|
|
40
|
-
protected setPage(page: Page, { visitId, replace, preserveURL, preserveScroll, preserveState, target, }?: {
|
|
41
|
-
visitId?: VisitId;
|
|
42
|
-
replace?: boolean;
|
|
43
|
-
preserveURL?: boolean;
|
|
44
|
-
preserveScroll?: PreserveStateOption;
|
|
45
|
-
preserveState?: PreserveStateOption;
|
|
46
|
-
target?: string | null;
|
|
47
|
-
}): Promise<Page>;
|
|
48
|
-
protected pushState(page: Page): void;
|
|
49
|
-
protected replaceState(page: Page): void;
|
|
50
|
-
protected handlePopstateEvent(event: PopStateEvent): void;
|
|
51
|
-
get(url: URL | string, data?: RequestPayload, options?: Exclude<VisitOptions, 'method' | 'data'>): void;
|
|
52
|
-
reload(options?: Exclude<VisitOptions, 'preserveScroll' | 'preserveState'>): void;
|
|
53
|
-
replace(url: URL | string, options?: Exclude<VisitOptions, 'replace'>): void;
|
|
54
|
-
post(url: URL | string, data?: RequestPayload, options?: Exclude<VisitOptions, 'method' | 'data'>): void;
|
|
55
|
-
put(url: URL | string, data?: RequestPayload, options?: Exclude<VisitOptions, 'method' | 'data'>): void;
|
|
56
|
-
patch(url: URL | string, data?: RequestPayload, options?: Exclude<VisitOptions, 'method' | 'data'>): void;
|
|
57
|
-
delete(url: URL | string, options?: Exclude<VisitOptions, 'method'>): void;
|
|
4
|
+
static resolveComponent: PageResolver;
|
|
5
|
+
protected frame: string;
|
|
6
|
+
protected syncRequestStream: RequestStream;
|
|
7
|
+
protected asyncRequestStream: RequestStream;
|
|
8
|
+
constructor({ frame, initialState, swapComponent }: RouterInitParams);
|
|
9
|
+
get(url: URL | string, data?: RequestPayload, options?: VisitHelperOptions): void;
|
|
10
|
+
post(url: URL | string, data?: RequestPayload, options?: VisitHelperOptions): void;
|
|
11
|
+
put(url: URL | string, data?: RequestPayload, options?: VisitHelperOptions): void;
|
|
12
|
+
patch(url: URL | string, data?: RequestPayload, options?: VisitHelperOptions): void;
|
|
13
|
+
delete(url: URL | string, options?: Omit<VisitOptions, 'method'>): void;
|
|
14
|
+
reload(options?: ReloadOptions): void;
|
|
58
15
|
remember(data: unknown, key?: string): void;
|
|
59
16
|
restore(key?: string): unknown;
|
|
60
17
|
on<TEventName extends GlobalEventNames>(type: TEventName, callback: (event: GlobalEvent<TEventName>) => GlobalEventResult<TEventName>): VoidFunction;
|
|
18
|
+
cancel(): void;
|
|
19
|
+
cancelAll(): void;
|
|
20
|
+
poll(interval: number, requestOptions?: ReloadOptions, options?: PollOptions): {
|
|
21
|
+
stop: VoidFunction;
|
|
22
|
+
start: VoidFunction;
|
|
23
|
+
};
|
|
24
|
+
visit(href: string | URL, options?: VisitOptions): void;
|
|
25
|
+
getCached(href: string | URL, options?: VisitOptions): InFlightPrefetch | PrefetchedResponse | null;
|
|
26
|
+
flush(href: string | URL, options?: VisitOptions): void;
|
|
27
|
+
flushAll(): void;
|
|
28
|
+
getPrefetching(href: string | URL, options?: VisitOptions): InFlightPrefetch | PrefetchedResponse | null;
|
|
29
|
+
prefetch(href: string | URL, options: Partial<Visit & VisitCallbacks> | undefined, { cacheFor }: PrefetchOptions): void;
|
|
30
|
+
clearHistory(): void;
|
|
31
|
+
decryptHistory(): Promise<Page>;
|
|
32
|
+
protected getPrefetchParams(href: string | URL, options: VisitOptions): ActiveVisit;
|
|
33
|
+
protected getPendingVisit(href: string | URL, options: VisitOptions, pendingVisitOptions?: Partial<PendingVisitOptions>): PendingVisit;
|
|
34
|
+
protected getVisitEvents(options: VisitOptions): VisitCallbacks;
|
|
35
|
+
protected loadDeferredProps(): void;
|
|
61
36
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class SessionStorage {
|
|
2
|
+
static locationVisitKey: string;
|
|
3
|
+
static set(key: string, value: any): void;
|
|
4
|
+
static get(key: string): any;
|
|
5
|
+
static merge(key: string, value: any): void;
|
|
6
|
+
static remove(key: string): void;
|
|
7
|
+
static removeNested(key: string, nestedKey: string): void;
|
|
8
|
+
static exists(key: string): boolean;
|
|
9
|
+
static clear(): void;
|
|
10
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function shouldIntercept(event: KeyboardEvent): boolean;
|
|
1
|
+
export default function shouldIntercept(event: MouseEvent | KeyboardEvent): boolean;
|
package/types/time.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const timeToMs: (time: string | number) => number;
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosProgressEvent, AxiosResponse } from 'axios';
|
|
2
|
+
import { Response } from './response';
|
|
2
3
|
declare module 'axios' {
|
|
3
4
|
interface AxiosProgressEvent {
|
|
4
5
|
percentage: number | undefined;
|
|
@@ -14,29 +15,38 @@ export type RequestPayload = Record<string, FormDataConvertible> | FormData;
|
|
|
14
15
|
export interface PageProps {
|
|
15
16
|
[key: string]: unknown;
|
|
16
17
|
}
|
|
17
|
-
export interface
|
|
18
|
+
export interface Frame<SharedProps extends PageProps = PageProps> {
|
|
18
19
|
component: string;
|
|
19
20
|
props: PageProps & SharedProps & {
|
|
20
21
|
errors: Errors & ErrorBag;
|
|
22
|
+
deferred?: Record<string, VisitOptions['only']>;
|
|
21
23
|
};
|
|
22
24
|
url: string;
|
|
23
|
-
|
|
25
|
+
deferredProps?: Record<string, VisitOptions['only']>;
|
|
26
|
+
mergeProps?: string[];
|
|
27
|
+
/** @internal */
|
|
28
|
+
rememberedState?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export interface Page {
|
|
31
|
+
frames: {
|
|
32
|
+
[name: string]: Frame;
|
|
33
|
+
};
|
|
24
34
|
version: string | null;
|
|
35
|
+
clearHistory?: boolean;
|
|
36
|
+
encryptHistory?: boolean;
|
|
25
37
|
/** @internal */
|
|
26
38
|
scrollRegions: Array<{
|
|
27
39
|
top: number;
|
|
28
40
|
left: number;
|
|
29
41
|
}>;
|
|
30
|
-
/** @internal */
|
|
31
|
-
rememberedState: Record<string, unknown>;
|
|
32
42
|
}
|
|
33
43
|
export type PageResolver = (name: string) => Component;
|
|
34
|
-
export type
|
|
44
|
+
export type FrameHandler = ({ component, frame, preserveState, }: {
|
|
35
45
|
component: Component;
|
|
36
|
-
|
|
46
|
+
frame: Frame;
|
|
37
47
|
preserveState: PreserveStateOption;
|
|
38
48
|
}) => Promise<unknown>;
|
|
39
|
-
export type PreserveStateOption = boolean |
|
|
49
|
+
export type PreserveStateOption = boolean | 'errors' | ((page: Page) => boolean);
|
|
40
50
|
export type Progress = AxiosProgressEvent;
|
|
41
51
|
export type LocationVisit = {
|
|
42
52
|
preserveScroll: boolean;
|
|
@@ -45,18 +55,21 @@ export type Visit = {
|
|
|
45
55
|
method: Method;
|
|
46
56
|
data: RequestPayload;
|
|
47
57
|
replace: boolean;
|
|
48
|
-
preserveURL: boolean;
|
|
49
58
|
preserveScroll: PreserveStateOption;
|
|
50
59
|
preserveState: PreserveStateOption;
|
|
51
|
-
transformProps: (props: PageProps) => void;
|
|
52
60
|
only: Array<string>;
|
|
61
|
+
except: Array<string>;
|
|
53
62
|
headers: Record<string, string>;
|
|
54
63
|
errorBag: string | null;
|
|
55
64
|
forceFormData: boolean;
|
|
56
|
-
target: string | null;
|
|
57
|
-
hint: string | null;
|
|
58
|
-
component: string | null;
|
|
59
65
|
queryStringArrayFormat: 'indices' | 'brackets';
|
|
66
|
+
async: boolean;
|
|
67
|
+
showProgress: boolean;
|
|
68
|
+
prefetch: boolean;
|
|
69
|
+
fresh: boolean;
|
|
70
|
+
reset: string[];
|
|
71
|
+
preserveUrl: boolean;
|
|
72
|
+
frame: string;
|
|
60
73
|
};
|
|
61
74
|
export type GlobalEventsMap = {
|
|
62
75
|
before: {
|
|
@@ -127,7 +140,24 @@ export type GlobalEventsMap = {
|
|
|
127
140
|
};
|
|
128
141
|
result: boolean | void;
|
|
129
142
|
};
|
|
143
|
+
prefetched: {
|
|
144
|
+
parameters: [AxiosResponse, ActiveVisit];
|
|
145
|
+
details: {
|
|
146
|
+
response: AxiosResponse;
|
|
147
|
+
fetchedAt: number;
|
|
148
|
+
visit: ActiveVisit;
|
|
149
|
+
};
|
|
150
|
+
result: void;
|
|
151
|
+
};
|
|
152
|
+
prefetching: {
|
|
153
|
+
parameters: [ActiveVisit];
|
|
154
|
+
details: {
|
|
155
|
+
visit: ActiveVisit;
|
|
156
|
+
};
|
|
157
|
+
result: void;
|
|
158
|
+
};
|
|
130
159
|
};
|
|
160
|
+
export type PageEvent = 'newComponent' | 'firstLoad';
|
|
131
161
|
export type GlobalEventNames = keyof GlobalEventsMap;
|
|
132
162
|
export type GlobalEvent<TEventName extends GlobalEventNames> = CustomEvent<GlobalEventDetails<TEventName>>;
|
|
133
163
|
export type GlobalEventParameters<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['parameters'];
|
|
@@ -135,7 +165,7 @@ export type GlobalEventResult<TEventName extends GlobalEventNames> = GlobalEvent
|
|
|
135
165
|
export type GlobalEventDetails<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['details'];
|
|
136
166
|
export type GlobalEventTrigger<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
|
|
137
167
|
export type GlobalEventCallback<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
|
|
138
|
-
export type
|
|
168
|
+
export type VisitCallbacks = {
|
|
139
169
|
onCancelToken: {
|
|
140
170
|
({ cancel }: {
|
|
141
171
|
cancel: VoidFunction;
|
|
@@ -148,16 +178,33 @@ export type VisitOptions = Partial<Visit & {
|
|
|
148
178
|
onCancel: GlobalEventCallback<'cancel'>;
|
|
149
179
|
onSuccess: GlobalEventCallback<'success'>;
|
|
150
180
|
onError: GlobalEventCallback<'error'>;
|
|
151
|
-
|
|
152
|
-
|
|
181
|
+
onPrefetched: GlobalEventCallback<'prefetched'>;
|
|
182
|
+
onPrefetching: GlobalEventCallback<'prefetching'>;
|
|
183
|
+
};
|
|
184
|
+
export type VisitOptions = Partial<Visit & VisitCallbacks>;
|
|
185
|
+
export type ReloadOptions = Omit<VisitOptions, 'preserveScroll' | 'preserveState'>;
|
|
186
|
+
export type PollOptions = {
|
|
187
|
+
keepAlive?: boolean;
|
|
188
|
+
autoStart?: boolean;
|
|
189
|
+
};
|
|
190
|
+
export type VisitHelperOptions = Omit<VisitOptions, 'method' | 'data'>;
|
|
191
|
+
export type RouterInitParams = {
|
|
192
|
+
frame: string;
|
|
193
|
+
initialState: Frame & {
|
|
194
|
+
version: string | null;
|
|
195
|
+
};
|
|
196
|
+
swapComponent: FrameHandler;
|
|
197
|
+
};
|
|
198
|
+
export type PendingVisitOptions = {
|
|
153
199
|
url: URL;
|
|
154
200
|
completed: boolean;
|
|
155
201
|
cancelled: boolean;
|
|
156
202
|
interrupted: boolean;
|
|
157
|
-
noProgress: boolean;
|
|
158
203
|
};
|
|
159
|
-
export type
|
|
160
|
-
|
|
204
|
+
export type PendingVisit = Visit & PendingVisitOptions;
|
|
205
|
+
export type ActiveVisit = PendingVisit & Required<VisitOptions>;
|
|
206
|
+
export type InternalActiveVisit = ActiveVisit & {
|
|
207
|
+
onPrefetchResponse?: (response: Response) => void;
|
|
161
208
|
};
|
|
162
209
|
export type VisitId = unknown;
|
|
163
210
|
export type Component = unknown;
|
|
@@ -165,6 +212,33 @@ export type InertiaAppResponse = Promise<{
|
|
|
165
212
|
head: string[];
|
|
166
213
|
body: string;
|
|
167
214
|
} | void>;
|
|
215
|
+
export type LinkPrefetchOption = 'mount' | 'hover' | 'click';
|
|
216
|
+
export type CacheForOption = number | string;
|
|
217
|
+
export type PrefetchOptions = {
|
|
218
|
+
cacheFor: CacheForOption | CacheForOption[];
|
|
219
|
+
};
|
|
220
|
+
type PrefetchObject = {
|
|
221
|
+
params: ActiveVisit;
|
|
222
|
+
response: Promise<Response>;
|
|
223
|
+
};
|
|
224
|
+
export type InFlightPrefetch = PrefetchObject & {
|
|
225
|
+
staleTimestamp: null;
|
|
226
|
+
inFlight: true;
|
|
227
|
+
};
|
|
228
|
+
export type PrefetchCancellationToken = {
|
|
229
|
+
isCancelled: boolean;
|
|
230
|
+
cancel: () => void;
|
|
231
|
+
};
|
|
232
|
+
export type PrefetchedResponse = PrefetchObject & {
|
|
233
|
+
staleTimestamp: number;
|
|
234
|
+
timestamp: number;
|
|
235
|
+
singleUse: boolean;
|
|
236
|
+
inFlight: false;
|
|
237
|
+
};
|
|
238
|
+
export type PrefetchRemovalTimer = {
|
|
239
|
+
params: ActiveVisit;
|
|
240
|
+
timer: number;
|
|
241
|
+
};
|
|
168
242
|
declare global {
|
|
169
243
|
interface DocumentEventMap {
|
|
170
244
|
'inertia:before': GlobalEvent<'before'>;
|
|
@@ -178,3 +252,4 @@ declare global {
|
|
|
178
252
|
'inertia:navigate': GlobalEvent<'navigate'>;
|
|
179
253
|
}
|
|
180
254
|
}
|
|
255
|
+
export {};
|
package/types/url.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { FormDataConvertible, Method } from './types';
|
|
1
|
+
import { FormDataConvertible, Method, RequestPayload, VisitOptions } from './types';
|
|
2
2
|
export declare function hrefToUrl(href: string | URL): URL;
|
|
3
|
+
export declare const transformUrlAndData: (href: string | URL, data: RequestPayload, method: Method, forceFormData: VisitOptions['forceFormData'], queryStringArrayFormat: VisitOptions['queryStringArrayFormat']) => [URL, RequestPayload];
|
|
3
4
|
export declare function mergeDataIntoQueryString(method: Method, href: URL | string, data: Record<string, FormDataConvertible>, qsArrayFormat?: 'indices' | 'brackets'): [string, Record<string, FormDataConvertible>];
|
|
4
5
|
export declare function urlWithoutHash(url: URL | Location): URL;
|
|
6
|
+
export declare const setHashIfSameUrl: (originUrl: URL | Location, destinationUrl: URL | Location) => void;
|
|
7
|
+
export declare const isSameUrlWithoutHash: (url1: URL | Location, url2: URL | Location) => boolean;
|