@inertiajs/core 2.2.9 → 2.2.11
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 +76 -19
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +81 -24
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/types/config.d.ts +19 -0
- package/types/index.d.ts +3 -1
- package/types/response.d.ts +1 -0
- package/types/time.d.ts +2 -1
- package/types/types.d.ts +18 -4
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
export declare class Config<TConfig extends {} = {}> {
|
|
10
|
+
protected config: Partial<TConfig>;
|
|
11
|
+
protected defaults: TConfig;
|
|
12
|
+
constructor(defaults: TConfig);
|
|
13
|
+
extend<TExtension extends {}>(defaults?: TExtension): Config<TConfig & TExtension>;
|
|
14
|
+
replace(newConfig: Partial<TConfig>): void;
|
|
15
|
+
get<K extends ConfigKeys<TConfig>>(key: K): ConfigValue<TConfig, K>;
|
|
16
|
+
set<K extends ConfigKeys<TConfig>>(keyOrValues: K | Partial<ConfigSetObject<TConfig>>, value?: ConfigValue<TConfig, K>): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const config: Config<InertiaAppConfig>;
|
|
19
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Config } from './config';
|
|
1
2
|
import { Router } from './router';
|
|
3
|
+
export { config } from './config';
|
|
2
4
|
export { getScrollableParent } from './domUtils';
|
|
3
5
|
export { objectToFormData } from './formData';
|
|
4
6
|
export { formDataToObject } from './formObject';
|
|
@@ -9,5 +11,5 @@ export { hide as hideProgress, progress, reveal as revealProgress, default as se
|
|
|
9
11
|
export { resetFormFields } from './resetFormFields';
|
|
10
12
|
export * from './types';
|
|
11
13
|
export { hrefToUrl, isUrlMethodPair, mergeDataIntoQueryString, urlHasProtocol, urlToString, urlWithoutHash, } from './url';
|
|
12
|
-
export { type Router };
|
|
14
|
+
export { type Config, type Router };
|
|
13
15
|
export declare const router: Router;
|
package/types/response.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare class Response {
|
|
|
26
26
|
protected getDataFromResponse(response: any): any;
|
|
27
27
|
protected shouldSetPage(pageResponse: Page): boolean;
|
|
28
28
|
protected pageUrl(pageResponse: Page): string;
|
|
29
|
+
protected preserveEqualProps(pageResponse: Page): void;
|
|
29
30
|
protected mergeProps(pageResponse: Page): void;
|
|
30
31
|
protected mergeOrMatchItems(existingItems: any[], newItems: any[], matchProp: string, matchPropsOn: string[], shouldAppend?: boolean): any[];
|
|
31
32
|
protected appendWithMatching(existingItems: any[], newItems: any[], newItemsMap: Map<any, any>, uniqueProperty: string): any[];
|
package/types/time.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { CacheForOption } from './types';
|
|
2
|
+
export declare const timeToMs: (time: CacheForOption) => number;
|
package/types/types.d.ts
CHANGED
|
@@ -278,12 +278,13 @@ export type InternalActiveVisit = ActiveVisit & {
|
|
|
278
278
|
};
|
|
279
279
|
export type VisitId = unknown;
|
|
280
280
|
export type Component = unknown;
|
|
281
|
-
interface CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn> {
|
|
281
|
+
interface CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn, TAdditionalInertiaAppConfig> {
|
|
282
282
|
resolve: TComponentResolver;
|
|
283
283
|
setup: (options: TSetupOptions) => TSetupReturn;
|
|
284
284
|
title?: HeadManagerTitleCallback;
|
|
285
|
+
defaults?: Partial<InertiaAppConfig & TAdditionalInertiaAppConfig>;
|
|
285
286
|
}
|
|
286
|
-
export interface CreateInertiaAppOptionsForCSR<SharedProps extends PageProps, TComponentResolver, TSetupOptions, TSetupReturn> extends CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn> {
|
|
287
|
+
export interface CreateInertiaAppOptionsForCSR<SharedProps extends PageProps, TComponentResolver, TSetupOptions, TSetupReturn, TAdditionalInertiaAppConfig> extends CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn, TAdditionalInertiaAppConfig> {
|
|
287
288
|
id?: string;
|
|
288
289
|
page?: Page<SharedProps>;
|
|
289
290
|
progress?: false | {
|
|
@@ -294,7 +295,7 @@ export interface CreateInertiaAppOptionsForCSR<SharedProps extends PageProps, TC
|
|
|
294
295
|
};
|
|
295
296
|
render?: undefined;
|
|
296
297
|
}
|
|
297
|
-
export interface CreateInertiaAppOptionsForSSR<SharedProps extends PageProps, TComponentResolver, TSetupOptions, TSetupReturn> extends CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn> {
|
|
298
|
+
export interface CreateInertiaAppOptionsForSSR<SharedProps extends PageProps, TComponentResolver, TSetupOptions, TSetupReturn, TAdditionalInertiaAppConfig> extends CreateInertiaAppOptions<TComponentResolver, TSetupOptions, TSetupReturn, TAdditionalInertiaAppConfig> {
|
|
298
299
|
id?: undefined;
|
|
299
300
|
page: Page<SharedProps>;
|
|
300
301
|
progress?: undefined;
|
|
@@ -316,11 +317,24 @@ export type HeadManager = {
|
|
|
316
317
|
};
|
|
317
318
|
};
|
|
318
319
|
export type LinkPrefetchOption = 'mount' | 'hover' | 'click';
|
|
319
|
-
export type
|
|
320
|
+
export type TimeUnit = 'ms' | 's' | 'm' | 'h' | 'd';
|
|
321
|
+
export type CacheForOption = number | `${number}${TimeUnit}` | string;
|
|
320
322
|
export type PrefetchOptions = {
|
|
321
323
|
cacheFor: CacheForOption | CacheForOption[];
|
|
322
324
|
cacheTags: string | string[];
|
|
323
325
|
};
|
|
326
|
+
export type InertiaAppConfig = {
|
|
327
|
+
form: {
|
|
328
|
+
recentlySuccessfulDuration: number;
|
|
329
|
+
};
|
|
330
|
+
future: {
|
|
331
|
+
preserveEqualProps: boolean;
|
|
332
|
+
};
|
|
333
|
+
prefetch: {
|
|
334
|
+
cacheFor: CacheForOption | CacheForOption[];
|
|
335
|
+
};
|
|
336
|
+
visitOptions?: (href: string, options: VisitOptions) => VisitOptions;
|
|
337
|
+
};
|
|
324
338
|
export interface LinkComponentBaseProps extends Partial<Pick<Visit<RequestPayload>, 'data' | 'method' | 'replace' | 'preserveScroll' | 'preserveState' | 'preserveUrl' | 'only' | 'except' | 'headers' | 'queryStringArrayFormat' | 'async'> & VisitCallbacks & {
|
|
325
339
|
href: string | UrlMethodPair;
|
|
326
340
|
prefetch: boolean | LinkPrefetchOption | LinkPrefetchOption[];
|