inertiax-core 10.2.2 → 11.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.js +5337 -16
- package/dist/index.js.map +4 -4
- package/dist/server.js +312 -1
- package/dist/server.js.map +4 -4
- package/dist/ssrErrors.js +197 -0
- package/dist/ssrErrors.js.map +7 -0
- package/package.json +42 -26
- package/readme.md +2 -2
- package/types/axiosHttpClient.d.ts +13 -0
- package/types/config.d.ts +24 -0
- package/types/debug.d.ts +1 -1
- package/types/dialog.d.ts +8 -0
- package/types/domUtils.d.ts +4 -0
- package/types/eventHandler.d.ts +11 -10
- package/types/events.d.ts +4 -2
- package/types/files.d.ts +1 -0
- package/types/formData.d.ts +2 -2
- package/types/formObject.d.ts +5 -0
- package/types/head.d.ts +2 -7
- package/types/history.d.ts +49 -37
- package/types/http.d.ts +38 -0
- package/types/httpErrors.d.ts +17 -0
- package/types/httpHandlers.d.ts +15 -0
- package/types/index.d.ts +22 -5
- package/types/infiniteScroll/data.d.ts +19 -0
- package/types/infiniteScroll/elements.d.ts +15 -0
- package/types/infiniteScroll/queryString.d.ts +13 -0
- package/types/infiniteScroll/scrollPreservation.d.ts +18 -0
- package/types/infiniteScroll.d.ts +12 -0
- package/types/initialVisit.d.ts +6 -5
- package/types/intersectionObservers.d.ts +7 -0
- package/types/layout.d.ts +32 -0
- package/types/navigationEvents.d.ts +15 -0
- package/types/objectUtils.d.ts +2 -1
- package/types/page.d.ts +80 -10
- package/types/partialReload.d.ts +6 -0
- package/types/poll.d.ts +18 -3
- package/types/polls.d.ts +4 -2
- package/types/prefetched.d.ts +7 -2
- package/types/progress-component.d.ts +2 -2
- package/types/progress.d.ts +16 -8
- package/types/queryString.d.ts +13 -0
- package/types/request.d.ts +18 -6
- package/types/requestParams.d.ts +6 -4
- package/types/requestStream.d.ts +8 -4
- package/types/resetFormFields.d.ts +2 -0
- package/types/response.d.ts +28 -5
- package/types/router.d.ts +58 -34
- package/types/scroll.d.ts +9 -5
- package/types/server.d.ts +3 -1
- package/types/ssrErrors.d.ts +29 -0
- package/types/ssrUtils.d.ts +2 -0
- package/types/time.d.ts +2 -1
- package/types/types.d.ts +496 -83
- package/types/url.d.ts +10 -3
- package/types/useFormUtils.d.ts +48 -0
- package/types/xhrHttpClient.d.ts +12 -0
- package/dist/index.esm.js +0 -68
- package/dist/index.esm.js.map +0 -7
- package/dist/server.esm.js +0 -2
- package/dist/server.esm.js.map +0 -7
- package/types/modal.d.ts +0 -8
- package/types/shouldIntercept.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inertiax-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A framework for creating server-driven single page apps.",
|
|
6
6
|
"contributors": [
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"Sebastian De Deyne <sebastiandedeyne@gmail.com>",
|
|
10
10
|
"Stefan Buhrmester <stefan@buhrmi.de>"
|
|
11
11
|
],
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://inertiajs.com/",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/buhrmi/inertiax.git",
|
|
16
|
-
"directory": "packages/
|
|
15
|
+
"url": "git+https://github.com/buhrmi/inertiax.git",
|
|
16
|
+
"directory": "packages/inertia"
|
|
17
17
|
},
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/buhrmi/inertiax/issues"
|
|
@@ -28,41 +28,57 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./types/index.d.ts",
|
|
31
|
-
"import": "./dist/index.
|
|
32
|
-
"require": "./dist/index.js"
|
|
31
|
+
"import": "./dist/index.js"
|
|
33
32
|
},
|
|
34
33
|
"./server": {
|
|
35
34
|
"types": "./types/server.d.ts",
|
|
36
|
-
"import": "./dist/server.
|
|
37
|
-
|
|
35
|
+
"import": "./dist/server.js"
|
|
36
|
+
},
|
|
37
|
+
"./ssrErrors": {
|
|
38
|
+
"types": "./types/ssrErrors.d.ts",
|
|
39
|
+
"import": "./dist/ssrErrors.js"
|
|
38
40
|
}
|
|
39
41
|
},
|
|
40
42
|
"typesVersions": {
|
|
41
43
|
"*": {
|
|
42
44
|
"server": [
|
|
43
45
|
"types/server.d.ts"
|
|
46
|
+
],
|
|
47
|
+
"ssrErrors": [
|
|
48
|
+
"types/ssrErrors.d.ts"
|
|
44
49
|
]
|
|
45
50
|
}
|
|
46
51
|
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"dev": "./build.js --watch",
|
|
49
|
-
"build": "npm run clean && ./build.js && tsc --emitDeclarationOnly",
|
|
50
|
-
"clean": "rm -rf types && rm -rf dist",
|
|
51
|
-
"prepublishOnly": "npm run build",
|
|
52
|
-
"test": "vitest"
|
|
53
|
-
},
|
|
54
52
|
"dependencies": {
|
|
55
|
-
"
|
|
56
|
-
"es-toolkit": "^1.
|
|
57
|
-
"
|
|
53
|
+
"@jridgewell/trace-mapping": "^0.3.31",
|
|
54
|
+
"es-toolkit": "^1.33.0",
|
|
55
|
+
"laravel-precognition": "^2.0.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"axios": "^1.15.2"
|
|
59
|
+
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"axios": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
58
64
|
},
|
|
59
65
|
"devDependencies": {
|
|
60
|
-
"@types/
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"esbuild": "^
|
|
65
|
-
"
|
|
66
|
-
"
|
|
66
|
+
"@types/node": "^24.10.13",
|
|
67
|
+
"axios": "^1.15.2",
|
|
68
|
+
"es-check": "^9.6.4",
|
|
69
|
+
"esbuild": "^0.27.3",
|
|
70
|
+
"esbuild-node-externals": "^1.20.1",
|
|
71
|
+
"typescript": "^6.0.3",
|
|
72
|
+
"vitest": "^4.1.2"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"build": "pnpm clean && ./build.js && tsc",
|
|
76
|
+
"build:with-deps": "./build.js --with-deps",
|
|
77
|
+
"clean": "rm -rf types && rm -rf dist",
|
|
78
|
+
"dev": "pnpx concurrently -c \"#ffcf00,#3178c6\" \"pnpm dev:build\" \"pnpm dev:types\" --names build,types",
|
|
79
|
+
"dev:build": "./build.js --watch",
|
|
80
|
+
"dev:types": "tsc --watch --preserveWatchOutput",
|
|
81
|
+
"es2022-check": "pnpm build:with-deps && es-check es2022 \"dist/index.js\" --checkFeatures --module --noCache --verbose",
|
|
82
|
+
"test": "vitest run"
|
|
67
83
|
}
|
|
68
|
-
}
|
|
84
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Inertia
|
|
1
|
+
# Inertia.js
|
|
2
2
|
|
|
3
|
-
Inertia
|
|
3
|
+
Inertia.js lets you quickly build modern single-page Svelte apps using classic server-side routing and controllers.
|
|
4
4
|
|
|
5
5
|
Visit [inertiajs.com](https://inertiajs.com/) to learn more.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
import { HttpClient, HttpRequestConfig, HttpResponse } from './types';
|
|
3
|
+
export declare class AxiosHttpClient implements HttpClient {
|
|
4
|
+
private axiosInstance;
|
|
5
|
+
constructor(instance?: AxiosInstance);
|
|
6
|
+
private getAxios;
|
|
7
|
+
request(config: HttpRequestConfig): Promise<HttpResponse>;
|
|
8
|
+
protected doRequest(config: HttpRequestConfig): Promise<HttpResponse>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create an Axios HTTP client adapter
|
|
12
|
+
*/
|
|
13
|
+
export declare function axiosAdapter(instance?: AxiosInstance): HttpClient;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InertiaAppConfig } from './types';
|
|
2
|
+
type ConfigKeys<T> = T extends Function ? never : string extends keyof T ? string : Extract<keyof T, string> | {
|
|
3
|
+
[Key in Extract<keyof T, string>]: T[Key] extends object ? `${Key}.${ConfigKeys<T[Key]> & string}` : never;
|
|
4
|
+
}[Extract<keyof T, string>];
|
|
5
|
+
type ConfigValue<T, K extends ConfigKeys<T>> = K extends `${infer P}.${infer Rest}` ? P extends keyof T ? Rest extends ConfigKeys<T[P]> ? ConfigValue<T[P], Rest> : never : never : K extends keyof T ? T[K] : never;
|
|
6
|
+
type ConfigSetObject<T> = {
|
|
7
|
+
[K in ConfigKeys<T>]?: ConfigValue<T, K>;
|
|
8
|
+
};
|
|
9
|
+
type FirstLevelOptional<T> = {
|
|
10
|
+
[K in keyof T]?: T[K] extends object ? {
|
|
11
|
+
[P in keyof T[K]]?: T[K][P];
|
|
12
|
+
} : T[K];
|
|
13
|
+
};
|
|
14
|
+
export declare class Config<TConfig extends {} = {}> {
|
|
15
|
+
protected config: FirstLevelOptional<TConfig>;
|
|
16
|
+
protected defaults: TConfig;
|
|
17
|
+
constructor(defaults: TConfig);
|
|
18
|
+
extend<TExtension extends {}>(defaults?: TExtension): Config<TConfig & TExtension>;
|
|
19
|
+
replace(newConfig: FirstLevelOptional<TConfig>): void;
|
|
20
|
+
get<K extends ConfigKeys<TConfig>>(key: K): ConfigValue<TConfig, K>;
|
|
21
|
+
set<K extends ConfigKeys<TConfig>>(keyOrValues: K | Partial<ConfigSetObject<TConfig>>, value?: ConfigValue<TConfig, K>): void;
|
|
22
|
+
}
|
|
23
|
+
export declare const config: Config<InertiaAppConfig>;
|
|
24
|
+
export {};
|
package/types/debug.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const stackTrace: (autolog?: boolean) =>
|
|
1
|
+
export declare const stackTrace: (autolog?: boolean) => string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const getScrollableParent: (element: HTMLElement | null) => HTMLElement | null;
|
|
2
|
+
export declare const getElementsInViewportFromCollection: (elements: HTMLElement[], referenceElement?: HTMLElement) => HTMLElement[];
|
|
3
|
+
export declare const requestAnimationFrame: (cb: () => void, times?: number) => void;
|
|
4
|
+
export declare const getInitialPageFromDOM: <T>(id: string) => T | null;
|
package/types/eventHandler.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { GlobalEvent, GlobalEventNames, GlobalEventResult, InternalEvent } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
interface PopStateEvent {
|
|
4
|
-
skipInertia?: boolean;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
2
|
declare class EventHandler {
|
|
3
|
+
protected initialized: boolean;
|
|
8
4
|
protected internalListeners: {
|
|
9
5
|
event: InternalEvent;
|
|
10
|
-
listener:
|
|
6
|
+
listener: (...args: any[]) => void;
|
|
11
7
|
}[];
|
|
8
|
+
protected popstateHandlers: Map<string, (state: any) => void>;
|
|
9
|
+
protected pageshowHandlers: Map<string, () => void>;
|
|
12
10
|
init(): void;
|
|
13
|
-
onGlobalEvent<TEventName extends GlobalEventNames>(
|
|
14
|
-
on(event: InternalEvent, callback:
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
onGlobalEvent<TEventName extends GlobalEventNames>(type: TEventName, callback: (event: GlobalEvent<TEventName>) => GlobalEventResult<TEventName>): VoidFunction;
|
|
12
|
+
on(event: InternalEvent, callback: (...args: any[]) => void): VoidFunction;
|
|
13
|
+
registerPopstateHandler(frameId: string, callback: (state: any) => void): VoidFunction;
|
|
14
|
+
registerPageshowHandler(frameId: string, callback: () => void): VoidFunction;
|
|
15
|
+
onMissingHistoryItem(frameId?: string): void;
|
|
16
|
+
fireInternalEvent(event: InternalEvent, ...args: any[]): void;
|
|
17
17
|
protected registerListener(type: string, listener: EventListener): VoidFunction;
|
|
18
|
+
protected handlePageshowEvent(event: PageTransitionEvent): void;
|
|
18
19
|
protected handlePopstateEvent(event: PopStateEvent): void;
|
|
19
20
|
}
|
|
20
21
|
export declare const eventHandler: EventHandler;
|
package/types/events.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { GlobalEventTrigger } from './types';
|
|
2
2
|
export declare const fireBeforeEvent: GlobalEventTrigger<'before'>;
|
|
3
3
|
export declare const fireErrorEvent: GlobalEventTrigger<'error'>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const fireNetworkErrorEvent: GlobalEventTrigger<'networkError'>;
|
|
5
5
|
export declare const fireFinishEvent: GlobalEventTrigger<'finish'>;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const fireHttpExceptionEvent: GlobalEventTrigger<'httpException'>;
|
|
7
|
+
export declare const fireBeforeUpdateEvent: GlobalEventTrigger<'beforeUpdate'>;
|
|
7
8
|
export declare const fireNavigateEvent: GlobalEventTrigger<'navigate'>;
|
|
8
9
|
export declare const fireProgressEvent: GlobalEventTrigger<'progress'>;
|
|
9
10
|
export declare const fireStartEvent: GlobalEventTrigger<'start'>;
|
|
10
11
|
export declare const fireSuccessEvent: GlobalEventTrigger<'success'>;
|
|
11
12
|
export declare const firePrefetchedEvent: GlobalEventTrigger<'prefetched'>;
|
|
12
13
|
export declare const firePrefetchingEvent: GlobalEventTrigger<'prefetching'>;
|
|
14
|
+
export declare const fireFlashEvent: GlobalEventTrigger<'flash'>;
|
package/types/files.d.ts
CHANGED
package/types/formData.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FormDataConvertible } from './types';
|
|
1
|
+
import type { FormDataConvertible, QueryStringArrayFormatOption } from './types';
|
|
2
2
|
export declare const isFormData: (value: any) => value is FormData;
|
|
3
|
-
export declare function objectToFormData(source: Record<string, FormDataConvertible>, form?: FormData, parentKey?: string | null): FormData;
|
|
3
|
+
export declare function objectToFormData(source: Record<string, FormDataConvertible>, form?: FormData, parentKey?: string | null, queryStringArrayFormat?: QueryStringArrayFormatOption): FormData;
|
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;
|
package/types/history.d.ts
CHANGED
|
@@ -1,52 +1,64 @@
|
|
|
1
|
-
import { Page, ScrollRegion
|
|
1
|
+
import { Page, ScrollRegion } from './types';
|
|
2
|
+
type FrameHistoryState = {
|
|
3
|
+
page: Page | ArrayBuffer;
|
|
4
|
+
scrollRegions?: ScrollRegion[];
|
|
5
|
+
documentScrollPosition?: ScrollRegion;
|
|
6
|
+
};
|
|
7
|
+
type InertiaHistoryState = {
|
|
8
|
+
frames: Record<string, FrameHistoryState>;
|
|
9
|
+
};
|
|
2
10
|
declare class History {
|
|
3
11
|
rememberedState: "rememberedState";
|
|
4
12
|
scrollRegions: "scrollRegions";
|
|
5
13
|
preserveUrl: boolean;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
protected
|
|
13
|
-
protected
|
|
14
|
-
remember(
|
|
15
|
-
restore(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}): void;
|
|
20
|
-
pushState(frame: string, page: Page, cb?: (() => void) | null): void;
|
|
21
|
-
removeFrame(frame: string): void;
|
|
22
|
-
protected getFramesData(frames: Frames, encrypt: boolean): Promise<Frames | ArrayBuffer>;
|
|
14
|
+
protected current: Map<string, Partial<Page<import("./types").PageProps>>>;
|
|
15
|
+
protected initialState: Map<string, Partial<Page<import("./types").PageProps>> | null>;
|
|
16
|
+
protected getCurrent(frameId: string): Partial<Page>;
|
|
17
|
+
protected setCurrentState(page: Partial<Page>, frameId: string): void;
|
|
18
|
+
protected getInitial(frameId: string): Partial<Page> | null;
|
|
19
|
+
protected setInitial(page: Partial<Page> | null, frameId: string): void;
|
|
20
|
+
protected getWindowState(): InertiaHistoryState;
|
|
21
|
+
protected getFrameState(frameId?: string): FrameHistoryState | null;
|
|
22
|
+
remember(data: unknown, key: string, frameId?: string): void;
|
|
23
|
+
restore(key: string, frameId?: string): unknown;
|
|
24
|
+
pushState(page: Page, cb?: (() => void) | null, frameId?: string, browserUrl?: string): void;
|
|
25
|
+
protected clonePageProps(page: Page): Page;
|
|
26
|
+
protected getPageData(page: Page): Promise<Page | ArrayBuffer>;
|
|
23
27
|
processQueue(): Promise<void>;
|
|
24
|
-
decrypt(
|
|
25
|
-
protected decryptPageData(
|
|
26
|
-
saveScrollPositions(scrollRegions: ScrollRegion[]): void;
|
|
27
|
-
saveDocumentScrollPosition(scrollRegion: ScrollRegion): void;
|
|
28
|
-
getScrollRegions(): ScrollRegion[];
|
|
29
|
-
getDocumentScrollPosition(): ScrollRegion;
|
|
30
|
-
replaceState(
|
|
28
|
+
decrypt(page?: Page | ArrayBuffer | null, frameId?: string): Promise<Page>;
|
|
29
|
+
protected decryptPageData(pageData: ArrayBuffer | Page | null): Promise<Page | null>;
|
|
30
|
+
saveScrollPositions(scrollRegions: ScrollRegion[], frameId?: string): void;
|
|
31
|
+
saveDocumentScrollPosition(scrollRegion: ScrollRegion, frameId?: string): void;
|
|
32
|
+
getScrollRegions(frameId?: string): ScrollRegion[];
|
|
33
|
+
getDocumentScrollPosition(frameId?: string): ScrollRegion;
|
|
34
|
+
replaceState(page: Page, cb?: (() => void) | null, frameId?: string, browserUrl?: string): void;
|
|
35
|
+
protected isHistoryThrottleError(error: unknown): error is Error & {
|
|
36
|
+
name: 'SecurityError';
|
|
37
|
+
};
|
|
38
|
+
protected isQuotaExceededError(error: unknown): error is Error & {
|
|
39
|
+
name: 'QuotaExceededError';
|
|
40
|
+
};
|
|
41
|
+
protected withThrottleProtection<T = void>(cb: () => T): Promise<T | undefined>;
|
|
31
42
|
protected doReplaceState(data: {
|
|
32
|
-
|
|
43
|
+
page: Page | ArrayBuffer;
|
|
33
44
|
scrollRegions?: ScrollRegion[];
|
|
34
45
|
documentScrollPosition?: ScrollRegion;
|
|
35
|
-
|
|
36
|
-
}, url?: string): void;
|
|
46
|
+
}, url?: string, frameId?: string): Promise<void>;
|
|
37
47
|
protected doPushState(data: {
|
|
38
|
-
|
|
48
|
+
page: Page | ArrayBuffer;
|
|
39
49
|
scrollRegions?: ScrollRegion[];
|
|
40
50
|
documentScrollPosition?: ScrollRegion;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
}, url: string, frameId?: string): Promise<void>;
|
|
52
|
+
getState<T>(key: keyof Page, defaultValue?: T, frameId?: string): any;
|
|
53
|
+
deleteState(key: keyof Page, frameId?: string): void;
|
|
54
|
+
clearInitialState(key: keyof Page, frameId?: string): void;
|
|
55
|
+
browserHasHistoryEntry(frameId?: string): boolean;
|
|
46
56
|
clear(): void;
|
|
47
|
-
setCurrent(
|
|
48
|
-
isValidState(state: any): boolean;
|
|
49
|
-
getAllState(): Page;
|
|
57
|
+
setCurrent(page: Page, frameId?: string): void;
|
|
58
|
+
isValidState(state: any, frameId?: string): boolean;
|
|
59
|
+
getAllState(frameId?: string): Page;
|
|
60
|
+
getStateForFrame(state: any, frameId?: string): FrameHistoryState | null;
|
|
61
|
+
deleteFrame(frameId: string): void;
|
|
50
62
|
}
|
|
51
63
|
export declare const history: History;
|
|
52
64
|
export {};
|
package/types/http.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { HttpClient, HttpClientOptions } from './types';
|
|
2
|
+
export declare const http: {
|
|
3
|
+
/**
|
|
4
|
+
* Get the current HTTP client
|
|
5
|
+
*/
|
|
6
|
+
getClient(): HttpClient;
|
|
7
|
+
/**
|
|
8
|
+
* Set the HTTP client to use for all Inertia requests
|
|
9
|
+
*/
|
|
10
|
+
setClient(clientOrOptions: HttpClient | HttpClientOptions): void;
|
|
11
|
+
/**
|
|
12
|
+
* Register a request handler that runs before each request
|
|
13
|
+
*/
|
|
14
|
+
onRequest: (handler: import("./types").HttpRequestHandler) => () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Register a response handler that runs after each successful response
|
|
17
|
+
*/
|
|
18
|
+
onResponse: (handler: import("./types").HttpResponseHandler) => () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Register an error handler that runs when a request fails
|
|
21
|
+
*/
|
|
22
|
+
onError: (handler: import("./types").HttpErrorHandler) => () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Process a request config through all registered request handlers.
|
|
25
|
+
* For use by custom HttpClient implementations.
|
|
26
|
+
*/
|
|
27
|
+
processRequest: (config: import("./types").HttpRequestConfig) => Promise<import("./types").HttpRequestConfig>;
|
|
28
|
+
/**
|
|
29
|
+
* Process a response through all registered response handlers.
|
|
30
|
+
* For use by custom HttpClient implementations.
|
|
31
|
+
*/
|
|
32
|
+
processResponse: (response: import("./types").HttpResponse) => Promise<import("./types").HttpResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Process an error through all registered error handlers.
|
|
35
|
+
* For use by custom HttpClient implementations.
|
|
36
|
+
*/
|
|
37
|
+
processError: (error: import("./httpErrors").HttpResponseError | import("./httpErrors").HttpNetworkError | import("./httpErrors").HttpCancelledError) => Promise<void>;
|
|
38
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpResponse } from './types';
|
|
2
|
+
export declare class HttpError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly url?: string;
|
|
5
|
+
constructor(message: string, code: string, url?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class HttpResponseError extends HttpError {
|
|
8
|
+
readonly response: HttpResponse;
|
|
9
|
+
constructor(message: string, response: HttpResponse, url?: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class HttpCancelledError extends HttpError {
|
|
12
|
+
constructor(message?: string, url?: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class HttpNetworkError extends HttpError {
|
|
15
|
+
readonly cause?: Error;
|
|
16
|
+
constructor(message: string, url?: string, cause?: Error);
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpCancelledError, HttpNetworkError, HttpResponseError } from './httpErrors';
|
|
2
|
+
import { HttpErrorHandler, HttpRequestConfig, HttpRequestHandler, HttpResponse, HttpResponseHandler } from './types';
|
|
3
|
+
declare class HttpHandlers {
|
|
4
|
+
protected requestHandlers: HttpRequestHandler[];
|
|
5
|
+
protected responseHandlers: HttpResponseHandler[];
|
|
6
|
+
protected errorHandlers: HttpErrorHandler[];
|
|
7
|
+
onRequest(handler: HttpRequestHandler): () => void;
|
|
8
|
+
onResponse(handler: HttpResponseHandler): () => void;
|
|
9
|
+
onError(handler: HttpErrorHandler): () => void;
|
|
10
|
+
processRequest(config: HttpRequestConfig): Promise<HttpRequestConfig>;
|
|
11
|
+
processResponse(response: HttpResponse): Promise<HttpResponse>;
|
|
12
|
+
processError(error: HttpResponseError | HttpNetworkError | HttpCancelledError): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare const httpHandlers: HttpHandlers;
|
|
15
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
import { Config } from './config';
|
|
1
2
|
import { Router } from './router';
|
|
2
|
-
export {
|
|
3
|
+
export { UseFormUtils } from './useFormUtils';
|
|
4
|
+
export { axiosAdapter } from './axiosHttpClient';
|
|
5
|
+
export { config } from './config';
|
|
6
|
+
export { getInitialPageFromDOM, getScrollableParent } from './domUtils';
|
|
7
|
+
export { hasFiles } from './files';
|
|
8
|
+
export { objectToFormData } from './formData';
|
|
9
|
+
export { formDataToObject } from './formObject';
|
|
3
10
|
export { default as createHeadManager } from './head';
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
11
|
+
export { http } from './http';
|
|
12
|
+
export { HttpCancelledError, HttpError, HttpNetworkError, HttpResponseError } from './httpErrors';
|
|
13
|
+
export { default as useInfiniteScroll } from './infiniteScroll';
|
|
14
|
+
export { createLayoutPropsStore, isPropsObject, isPropsObjectOrCallback, normalizeLayouts, type LayoutCallbackReturn, type LayoutDefinition, type LayoutPropsStore, } from './layout';
|
|
15
|
+
export { shouldIntercept, shouldNavigate } from './navigationEvents';
|
|
16
|
+
export { isPathOrSubPath, partialReloadRequestsProp, partialReloadRequestsSomeProps } from './partialReload';
|
|
17
|
+
export { progress, default as setupProgress } from './progress';
|
|
18
|
+
export { FormComponentResetSymbol, resetFormFields } from './resetFormFields';
|
|
19
|
+
export { buildSSRBody } from './ssrUtils';
|
|
6
20
|
export * from './types';
|
|
7
|
-
export { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash } from './url';
|
|
8
|
-
export {
|
|
21
|
+
export { hrefToUrl, isSameUrlWithoutQueryOrHash, isUrlMethodPair, mergeDataIntoQueryString, resolveUrlMethodPairComponent, urlHasProtocol, urlToString, urlWithoutHash, } from './url';
|
|
22
|
+
export { XhrHttpClient, xhrHttpClient } from './xhrHttpClient';
|
|
23
|
+
export { type Config, type Router };
|
|
24
|
+
export declare const router: Router;
|
|
25
|
+
export declare function createRouter(frameId?: string): Router;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UseInfiniteScrollDataManager } from '../types';
|
|
2
|
+
export type InfiniteScrollPageIdentifier = string | number | null;
|
|
3
|
+
export type InfiniteScrollOnCompleteDetails = {
|
|
4
|
+
page: InfiniteScrollPageIdentifier;
|
|
5
|
+
completed: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const useInfiniteScrollData: (options: {
|
|
8
|
+
getPropName: () => string;
|
|
9
|
+
onBeforeUpdate: () => void;
|
|
10
|
+
onBeforePreviousRequest: () => void;
|
|
11
|
+
onBeforeNextRequest: () => void;
|
|
12
|
+
onCompletePreviousRequest: (
|
|
13
|
+
/** @deprecated Use `details.page` instead. The positional `loadedPage` argument will be removed in the next major version. */
|
|
14
|
+
loadedPage: InfiniteScrollPageIdentifier, details: InfiniteScrollOnCompleteDetails) => void;
|
|
15
|
+
onCompleteNextRequest: (
|
|
16
|
+
/** @deprecated Use `details.page` instead. The positional `loadedPage` argument will be removed in the next major version. */
|
|
17
|
+
loadedPage: InfiniteScrollPageIdentifier, details: InfiniteScrollOnCompleteDetails) => void;
|
|
18
|
+
onReset?: () => void;
|
|
19
|
+
}) => UseInfiniteScrollDataManager;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UseInfiniteScrollElementManager } from '../types';
|
|
2
|
+
export declare const getPageFromElement: (element: HTMLElement) => string | undefined;
|
|
3
|
+
export declare const useInfiniteScrollElementManager: (options: {
|
|
4
|
+
shouldFetchNext: () => boolean;
|
|
5
|
+
shouldFetchPrevious: () => boolean;
|
|
6
|
+
getTriggerMargin: () => number;
|
|
7
|
+
getStartElement: () => HTMLElement;
|
|
8
|
+
getEndElement: () => HTMLElement;
|
|
9
|
+
getItemsElement: () => HTMLElement;
|
|
10
|
+
getScrollableParent: () => HTMLElement | null;
|
|
11
|
+
onPreviousTriggered: () => void;
|
|
12
|
+
onNextTriggered: () => void;
|
|
13
|
+
onItemIntersected: (element: HTMLElement) => void;
|
|
14
|
+
getPropName: () => string;
|
|
15
|
+
}) => UseInfiniteScrollElementManager;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* As users scroll through infinite content, this system updates the URL to reflect
|
|
3
|
+
* which page they're currently viewing. It uses a "most visible page" calculation
|
|
4
|
+
* so that the URL reflects whichever page has the most visible items.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useInfiniteScrollQueryString: (options: {
|
|
7
|
+
getPageName: () => string;
|
|
8
|
+
getItemsElement: () => HTMLElement;
|
|
9
|
+
shouldPreserveUrl: () => boolean;
|
|
10
|
+
}) => {
|
|
11
|
+
onItemIntersected: (itemElement: HTMLElement) => void;
|
|
12
|
+
cancel: () => boolean;
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When loading content "before" the current viewport (e.g. loading page 1 when viewing page 2),
|
|
3
|
+
* new content is prepended to the DOM, which naturally pushes existing content down and
|
|
4
|
+
* disrupts the user's scroll position. This system maintains visual stability by:
|
|
5
|
+
*
|
|
6
|
+
* 1. Capturing a reference element and its position before the update
|
|
7
|
+
* 2. After new content is added, calculating how far that reference element moved
|
|
8
|
+
* 3. Adjusting scroll position to keep the reference element in the same visual location
|
|
9
|
+
*/
|
|
10
|
+
export declare const useInfiniteScrollPreservation: (options: {
|
|
11
|
+
getScrollableParent: () => HTMLElement | null;
|
|
12
|
+
getItemsElement: () => HTMLElement;
|
|
13
|
+
}) => {
|
|
14
|
+
createCallbacks: () => {
|
|
15
|
+
captureScrollPosition: () => void;
|
|
16
|
+
restoreScrollPosition: () => void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UseInfiniteScrollOptions, UseInfiniteScrollProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Core infinite scroll composable that orchestrates data fetching, DOM management,
|
|
4
|
+
* scroll preservation, and URL synchronization.
|
|
5
|
+
*
|
|
6
|
+
* This is the main entry point that coordinates four sub-systems:
|
|
7
|
+
* - Data management: Handles pagination state and server requests
|
|
8
|
+
* - Element management: DOM observation and intersection detection
|
|
9
|
+
* - Query string sync: Updates URL as user scrolls through pages
|
|
10
|
+
* - Scroll preservation: Maintains scroll position during content updates
|
|
11
|
+
*/
|
|
12
|
+
export default function useInfiniteScroll(options: UseInfiniteScrollOptions): UseInfiniteScrollProps;
|
package/types/initialVisit.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare class InitialVisit {
|
|
2
|
-
static handle(): void;
|
|
3
|
-
protected static clearRememberedStateOnReload(): void;
|
|
4
|
-
protected static handleBackForward(): boolean;
|
|
2
|
+
static handle(frameId?: string): void;
|
|
3
|
+
protected static clearRememberedStateOnReload(frameId?: string): void;
|
|
4
|
+
protected static handleBackForward(frameId?: string): boolean;
|
|
5
5
|
/**
|
|
6
6
|
* @link https://inertiajs.com/redirects#external-redirects
|
|
7
7
|
*/
|
|
8
|
-
protected static handleLocation(): boolean;
|
|
9
|
-
protected static handleDefault(): void;
|
|
8
|
+
protected static handleLocation(frameId?: string): boolean;
|
|
9
|
+
protected static handleDefault(frameId?: string): void;
|
|
10
|
+
protected static fireInitialEvents(frameId?: string): void;
|
|
10
11
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type IntersectionObserverCallback = (entry: IntersectionObserverEntry) => void;
|
|
2
|
+
interface IntersectionObserverManager {
|
|
3
|
+
new: (callback: IntersectionObserverCallback, options?: IntersectionObserverInit) => IntersectionObserver;
|
|
4
|
+
flushAll: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const useIntersectionObservers: () => IntersectionObserverManager;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LayoutProps, NamedLayoutProps } from './types';
|
|
2
|
+
export interface LayoutDefinition<Component> {
|
|
3
|
+
component: Component;
|
|
4
|
+
props: Record<string, unknown>;
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
export type LayoutCallbackReturn<C> = C | [C, Record<string, unknown>?] | C[] | (C | [C, Record<string, unknown>?])[] | {
|
|
8
|
+
component: C;
|
|
9
|
+
props?: Record<string, unknown>;
|
|
10
|
+
} | Record<string, C | [C, Record<string, unknown>?] | {
|
|
11
|
+
component: C;
|
|
12
|
+
props?: Record<string, unknown>;
|
|
13
|
+
}> | Partial<LayoutProps>;
|
|
14
|
+
export interface LayoutPropsStore {
|
|
15
|
+
set(props: Partial<LayoutProps>): void;
|
|
16
|
+
setFor<K extends keyof NamedLayoutProps>(name: K, props: Partial<NamedLayoutProps[K]>): void;
|
|
17
|
+
get(): {
|
|
18
|
+
shared: Record<string, unknown>;
|
|
19
|
+
named: Record<string, Record<string, unknown>>;
|
|
20
|
+
};
|
|
21
|
+
reset(): void;
|
|
22
|
+
subscribe(callback: () => void): () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function createLayoutPropsStore(): LayoutPropsStore;
|
|
25
|
+
type ComponentCheck<T> = (value: unknown) => value is T;
|
|
26
|
+
export declare function isPropsObject<T>(value: unknown, isComponent: ComponentCheck<T>): boolean;
|
|
27
|
+
export declare function isPropsObjectOrCallback<T>(value: unknown, isComponent: ComponentCheck<T>): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes layout definitions into a consistent structure.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeLayouts<T>(layout: unknown, isComponent: ComponentCheck<T>, isRenderFunction?: (value: unknown) => boolean): LayoutDefinition<T>[];
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type MouseNavigationEvent = Pick<MouseEvent, 'altKey' | 'ctrlKey' | 'shiftKey' | 'metaKey' | 'button' | 'currentTarget' | 'defaultPrevented' | 'target'>;
|
|
2
|
+
type KeyboardNavigationEvent = Pick<KeyboardEvent, 'currentTarget' | 'defaultPrevented' | 'key' | 'target'>;
|
|
3
|
+
/**
|
|
4
|
+
* Determine if this mouse event should be intercepted for navigation purposes.
|
|
5
|
+
* Links with modifier keys or non-left clicks should not be intercepted.
|
|
6
|
+
* Content editable elements and prevented events are ignored.
|
|
7
|
+
*/
|
|
8
|
+
export declare function shouldIntercept(event: MouseNavigationEvent): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Determine if this keyboard event should trigger a navigation request.
|
|
11
|
+
* Enter triggers navigation for both links and buttons currently.
|
|
12
|
+
* Space only triggers navigation for buttons specifically.
|
|
13
|
+
*/
|
|
14
|
+
export declare function shouldNavigate(event: KeyboardNavigationEvent): boolean;
|
|
15
|
+
export {};
|
package/types/objectUtils.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const stripTopLevelUndefined: <T extends Record<string, unknown>>(obj: T) => T;
|
|
2
|
+
export declare const objectsAreEqual: <T extends Record<string, any>>(obj1: T, obj2: T, excludeKeys: { [K in keyof T]: K; }[keyof T][]) => boolean;
|