@inertiajs/core 1.0.0-beta.2 → 1.0.0-beta.4

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/types/types.d.ts CHANGED
@@ -1,173 +1,176 @@
1
- import { AxiosResponse, CancelTokenSource } from 'axios';
2
- export declare type Errors = Record<string, string>;
3
- export declare type ErrorBag = Record<string, Errors>;
4
- export declare type FormDataConvertible = Array<FormDataConvertible> | Blob | FormDataEntryValue | Date | boolean | number | null | undefined;
5
- export declare enum Method {
6
- GET = "get",
7
- POST = "post",
8
- PUT = "put",
9
- PATCH = "patch",
10
- DELETE = "delete"
11
- }
12
- export declare type RequestPayload = Record<string, FormDataConvertible> | FormData;
13
- export interface PageProps {
14
- [key: string]: unknown;
15
- }
16
- export interface Page<SharedProps = PageProps> {
17
- component: string;
18
- props: PageProps & SharedProps & {
19
- errors: Errors & ErrorBag;
20
- };
21
- url: string;
22
- version: string | null;
23
- scrollRegions: Array<{
24
- top: number;
25
- left: number;
26
- }>;
27
- rememberedState: Record<string, unknown>;
28
- resolvedErrors: Errors;
29
- }
30
- export declare type PageResolver = (name: string) => Component;
31
- export declare type PageHandler = ({ component, page, preserveState, }: {
32
- component: Component;
33
- page: Page;
34
- preserveState: PreserveStateOption;
35
- }) => Promise<unknown>;
36
- export declare type PreserveStateOption = boolean | string | ((page: Page) => boolean);
37
- export declare type Progress = ProgressEvent & {
38
- percentage: number;
39
- };
40
- export declare type LocationVisit = {
41
- preserveScroll: boolean;
42
- };
43
- export declare type Visit = {
44
- method: Method;
45
- data: RequestPayload;
46
- replace: boolean;
47
- preserveScroll: PreserveStateOption;
48
- preserveState: PreserveStateOption;
49
- only: Array<string>;
50
- headers: Record<string, string>;
51
- errorBag: string | null;
52
- forceFormData: boolean;
53
- queryStringArrayFormat: 'indices' | 'brackets';
54
- };
55
- export declare type GlobalEventsMap = {
56
- before: {
57
- parameters: [PendingVisit];
58
- details: {
59
- visit: PendingVisit;
60
- };
61
- result: boolean | void;
62
- };
63
- start: {
64
- parameters: [PendingVisit];
65
- details: {
66
- visit: PendingVisit;
67
- };
68
- result: void;
69
- };
70
- progress: {
71
- parameters: [Progress | undefined];
72
- details: {
73
- progress: Progress | undefined;
74
- };
75
- result: void;
76
- };
77
- finish: {
78
- parameters: [ActiveVisit];
79
- details: {
80
- visit: ActiveVisit;
81
- };
82
- result: void;
83
- };
84
- cancel: {
85
- parameters: [];
86
- details: {};
87
- result: void;
88
- };
89
- navigate: {
90
- parameters: [Page];
91
- details: {
92
- page: Page;
93
- };
94
- result: void;
95
- };
96
- success: {
97
- parameters: [Page];
98
- details: {
99
- page: Page;
100
- };
101
- result: void;
102
- };
103
- error: {
104
- parameters: [Errors];
105
- details: {
106
- errors: Errors;
107
- };
108
- result: void;
109
- };
110
- invalid: {
111
- parameters: [AxiosResponse];
112
- details: {
113
- response: AxiosResponse;
114
- };
115
- result: boolean | void;
116
- };
117
- exception: {
118
- parameters: [Error];
119
- details: {
120
- exception: Error;
121
- };
122
- result: boolean | void;
123
- };
124
- };
125
- export declare type GlobalEventNames = keyof GlobalEventsMap;
126
- export declare type GlobalEvent<TEventName extends GlobalEventNames> = CustomEvent<GlobalEventDetails<TEventName>>;
127
- export declare type GlobalEventParameters<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['parameters'];
128
- export declare type GlobalEventResult<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['result'];
129
- export declare type GlobalEventDetails<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['details'];
130
- export declare type GlobalEventTrigger<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
131
- export declare type GlobalEventCallback<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
132
- export declare type VisitOptions = Partial<Visit & {
133
- onCancelToken: {
134
- ({ cancel }: {
135
- cancel: VoidFunction;
136
- }): void;
137
- };
138
- onBefore: GlobalEventCallback<'before'>;
139
- onStart: GlobalEventCallback<'start'>;
140
- onProgress: GlobalEventCallback<'progress'>;
141
- onFinish: GlobalEventCallback<'finish'>;
142
- onCancel: GlobalEventCallback<'cancel'>;
143
- onSuccess: GlobalEventCallback<'success'>;
144
- onError: GlobalEventCallback<'error'>;
145
- }>;
146
- export declare type PendingVisit = Visit & {
147
- url: URL;
148
- completed: boolean;
149
- cancelled: boolean;
150
- interrupted: boolean;
151
- };
152
- export declare type ActiveVisit = PendingVisit & Required<VisitOptions> & {
153
- cancelToken: CancelTokenSource;
154
- };
155
- export declare type VisitId = unknown;
156
- export declare type Component = unknown;
157
- export declare type InertiaAppResponse = Promise<{
158
- head: string[];
159
- body: string;
160
- } | void>;
161
- declare global {
162
- interface DocumentEventMap {
163
- 'inertia:before': GlobalEvent<'before'>;
164
- 'inertia:start': GlobalEvent<'start'>;
165
- 'inertia:progress': GlobalEvent<'progress'>;
166
- 'inertia:success': GlobalEvent<'success'>;
167
- 'inertia:error': GlobalEvent<'error'>;
168
- 'inertia:invalid': GlobalEvent<'invalid'>;
169
- 'inertia:exception': GlobalEvent<'exception'>;
170
- 'inertia:finish': GlobalEvent<'finish'>;
171
- 'inertia:navigate': GlobalEvent<'navigate'>;
172
- }
173
- }
1
+ import { AxiosProgressEvent, AxiosResponse } from 'axios';
2
+ declare module 'axios' {
3
+ interface AxiosProgressEvent {
4
+ percentage: number | undefined;
5
+ }
6
+ }
7
+ export type Errors = Record<string, string>;
8
+ export type ErrorBag = Record<string, Errors>;
9
+ export type FormDataConvertible = Array<FormDataConvertible> | Blob | FormDataEntryValue | Date | boolean | number | null | undefined;
10
+ export declare enum Method {
11
+ GET = "get",
12
+ POST = "post",
13
+ PUT = "put",
14
+ PATCH = "patch",
15
+ DELETE = "delete"
16
+ }
17
+ export type RequestPayload = Record<string, FormDataConvertible> | FormData;
18
+ export interface PageProps {
19
+ [key: string]: unknown;
20
+ }
21
+ export interface Page<SharedProps = PageProps> {
22
+ component: string;
23
+ props: PageProps & SharedProps & {
24
+ errors: Errors & ErrorBag;
25
+ };
26
+ url: string;
27
+ version: string | null;
28
+ scrollRegions: Array<{
29
+ top: number;
30
+ left: number;
31
+ }>;
32
+ rememberedState: Record<string, unknown>;
33
+ resolvedErrors: Errors;
34
+ }
35
+ export type PageResolver = (name: string) => Component;
36
+ export type PageHandler = ({ component, page, preserveState, }: {
37
+ component: Component;
38
+ page: Page;
39
+ preserveState: PreserveStateOption;
40
+ }) => Promise<unknown>;
41
+ export type PreserveStateOption = boolean | string | ((page: Page) => boolean);
42
+ export type Progress = AxiosProgressEvent;
43
+ export type LocationVisit = {
44
+ preserveScroll: boolean;
45
+ };
46
+ export type Visit = {
47
+ method: Method;
48
+ data: RequestPayload;
49
+ replace: boolean;
50
+ preserveScroll: PreserveStateOption;
51
+ preserveState: PreserveStateOption;
52
+ only: Array<string>;
53
+ headers: Record<string, string>;
54
+ errorBag: string | null;
55
+ forceFormData: boolean;
56
+ queryStringArrayFormat: 'indices' | 'brackets';
57
+ };
58
+ export type GlobalEventsMap = {
59
+ before: {
60
+ parameters: [PendingVisit];
61
+ details: {
62
+ visit: PendingVisit;
63
+ };
64
+ result: boolean | void;
65
+ };
66
+ start: {
67
+ parameters: [PendingVisit];
68
+ details: {
69
+ visit: PendingVisit;
70
+ };
71
+ result: void;
72
+ };
73
+ progress: {
74
+ parameters: [Progress | undefined];
75
+ details: {
76
+ progress: Progress | undefined;
77
+ };
78
+ result: void;
79
+ };
80
+ finish: {
81
+ parameters: [ActiveVisit];
82
+ details: {
83
+ visit: ActiveVisit;
84
+ };
85
+ result: void;
86
+ };
87
+ cancel: {
88
+ parameters: [];
89
+ details: {};
90
+ result: void;
91
+ };
92
+ navigate: {
93
+ parameters: [Page];
94
+ details: {
95
+ page: Page;
96
+ };
97
+ result: void;
98
+ };
99
+ success: {
100
+ parameters: [Page];
101
+ details: {
102
+ page: Page;
103
+ };
104
+ result: void;
105
+ };
106
+ error: {
107
+ parameters: [Errors];
108
+ details: {
109
+ errors: Errors;
110
+ };
111
+ result: void;
112
+ };
113
+ invalid: {
114
+ parameters: [AxiosResponse];
115
+ details: {
116
+ response: AxiosResponse;
117
+ };
118
+ result: boolean | void;
119
+ };
120
+ exception: {
121
+ parameters: [Error];
122
+ details: {
123
+ exception: Error;
124
+ };
125
+ result: boolean | void;
126
+ };
127
+ };
128
+ export type GlobalEventNames = keyof GlobalEventsMap;
129
+ export type GlobalEvent<TEventName extends GlobalEventNames> = CustomEvent<GlobalEventDetails<TEventName>>;
130
+ export type GlobalEventParameters<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['parameters'];
131
+ export type GlobalEventResult<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['result'];
132
+ export type GlobalEventDetails<TEventName extends GlobalEventNames> = GlobalEventsMap[TEventName]['details'];
133
+ export type GlobalEventTrigger<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
134
+ export type GlobalEventCallback<TEventName extends GlobalEventNames> = (...params: GlobalEventParameters<TEventName>) => GlobalEventResult<TEventName>;
135
+ export type VisitOptions = Partial<Visit & {
136
+ onCancelToken: {
137
+ ({ cancel }: {
138
+ cancel: VoidFunction;
139
+ }): void;
140
+ };
141
+ onBefore: GlobalEventCallback<'before'>;
142
+ onStart: GlobalEventCallback<'start'>;
143
+ onProgress: GlobalEventCallback<'progress'>;
144
+ onFinish: GlobalEventCallback<'finish'>;
145
+ onCancel: GlobalEventCallback<'cancel'>;
146
+ onSuccess: GlobalEventCallback<'success'>;
147
+ onError: GlobalEventCallback<'error'>;
148
+ }>;
149
+ export type PendingVisit = Visit & {
150
+ url: URL;
151
+ completed: boolean;
152
+ cancelled: boolean;
153
+ interrupted: boolean;
154
+ };
155
+ export type ActiveVisit = PendingVisit & Required<VisitOptions> & {
156
+ cancelToken: AbortController;
157
+ };
158
+ export type VisitId = unknown;
159
+ export type Component = unknown;
160
+ export type InertiaAppResponse = Promise<{
161
+ head: string[];
162
+ body: string;
163
+ } | void>;
164
+ declare global {
165
+ interface DocumentEventMap {
166
+ 'inertia:before': GlobalEvent<'before'>;
167
+ 'inertia:start': GlobalEvent<'start'>;
168
+ 'inertia:progress': GlobalEvent<'progress'>;
169
+ 'inertia:success': GlobalEvent<'success'>;
170
+ 'inertia:error': GlobalEvent<'error'>;
171
+ 'inertia:invalid': GlobalEvent<'invalid'>;
172
+ 'inertia:exception': GlobalEvent<'exception'>;
173
+ 'inertia:finish': GlobalEvent<'finish'>;
174
+ 'inertia:navigate': GlobalEvent<'navigate'>;
175
+ }
176
+ }
package/types/url.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FormDataConvertible, Method } from './types';
2
- export declare function hrefToUrl(href: string | URL): URL;
3
- export declare function mergeDataIntoQueryString(method: Method, href: URL | string, data: Record<string, FormDataConvertible>, qsArrayFormat?: 'indices' | 'brackets'): [string, Record<string, FormDataConvertible>];
4
- export declare function urlWithoutHash(url: URL | Location): URL;
1
+ import { FormDataConvertible, Method } from './types';
2
+ export declare function hrefToUrl(href: string | URL): URL;
3
+ export declare function mergeDataIntoQueryString(method: Method, href: URL | string, data: Record<string, FormDataConvertible>, qsArrayFormat?: 'indices' | 'brackets'): [string, Record<string, FormDataConvertible>];
4
+ export declare function urlWithoutHash(url: URL | Location): URL;