@inertiajs/svelte 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.
@@ -1,6 +1,6 @@
1
1
  import { type CreateInertiaAppOptionsForCSR, type InertiaAppResponse, type PageProps } from '@inertiajs/core';
2
2
  import App, { type InertiaAppProps } from './components/App.svelte';
3
- import type { ComponentResolver } from './types';
3
+ import type { ComponentResolver, SvelteInertiaAppConfig } from './types';
4
4
  type SvelteRenderResult = {
5
5
  html: string;
6
6
  head: string;
@@ -13,6 +13,6 @@ type SetupOptions<SharedProps extends PageProps> = {
13
13
  App: typeof App;
14
14
  props: InertiaAppProps<SharedProps>;
15
15
  };
16
- type InertiaAppOptions<SharedProps extends PageProps> = CreateInertiaAppOptionsForCSR<SharedProps, ComponentResolver, SetupOptions<SharedProps>, SvelteRenderResult | void>;
17
- export default function createInertiaApp<SharedProps extends PageProps = PageProps>({ id, resolve, setup, progress, page, }: InertiaAppOptions<SharedProps>): InertiaAppResponse;
16
+ type InertiaAppOptions<SharedProps extends PageProps> = CreateInertiaAppOptionsForCSR<SharedProps, ComponentResolver, SetupOptions<SharedProps>, SvelteRenderResult | void, SvelteInertiaAppConfig>;
17
+ export default function createInertiaApp<SharedProps extends PageProps = PageProps>({ id, resolve, setup, progress, page, defaults, }: InertiaAppOptions<SharedProps>): InertiaAppResponse;
18
18
  export {};
@@ -1,7 +1,9 @@
1
1
  import { router, setupProgress, } from '@inertiajs/core';
2
2
  import { escape } from 'lodash-es';
3
3
  import App, {} from './components/App.svelte';
4
- export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page, }) {
4
+ import { config } from './index';
5
+ export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page, defaults = {}, }) {
6
+ config.replace(defaults);
5
7
  const isServer = typeof window === 'undefined';
6
8
  const el = isServer ? null : document.getElementById(id);
7
9
  const initialPage = page || JSON.parse(el?.dataset.page || '{}');
package/dist/index.d.ts CHANGED
@@ -7,8 +7,9 @@ export { default as WhenVisible } from './components/WhenVisible.svelte';
7
7
  export { default as createInertiaApp } from './createInertiaApp';
8
8
  export { default as inertia } from './link';
9
9
  export { default as page, usePage } from './page';
10
- export { type ResolvedComponent } from './types';
10
+ export { type ResolvedComponent, type SvelteInertiaAppConfig } from './types';
11
11
  export { default as useForm, type InertiaForm, type InertiaFormProps } from './useForm';
12
12
  export { default as usePoll } from './usePoll';
13
13
  export { default as usePrefetch } from './usePrefetch';
14
14
  export { default as useRemember } from './useRemember';
15
+ export declare const config: import("@inertiajs/core").Config<import("@inertiajs/core").InertiaAppConfig>;
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { config as coreConfig } from '@inertiajs/core';
1
2
  export { progress, router } from '@inertiajs/core';
2
3
  export { default as Deferred } from './components/Deferred.svelte';
3
4
  export { default as Form } from './components/Form.svelte';
@@ -12,3 +13,4 @@ export { default as useForm } from './useForm';
12
13
  export { default as usePoll } from './usePoll';
13
14
  export { default as usePrefetch } from './usePrefetch';
14
15
  export { default as useRemember } from './useRemember';
16
+ export const config = coreConfig.extend({});
package/dist/link.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { isUrlMethodPair, mergeDataIntoQueryString, router, shouldIntercept, shouldNavigate, } from '@inertiajs/core';
2
+ import { config } from '.';
2
3
  function link(node, initialParams = {}) {
3
4
  let inFlightCount = 0;
4
5
  let hoverTimeout;
@@ -69,7 +70,7 @@ function link(node, initialParams = {}) {
69
70
  if (prefetchModes.length === 1 && prefetchModes[0] === 'click') {
70
71
  return 0;
71
72
  }
72
- return 30_000;
73
+ return config.get('prefetch.cacheFor');
73
74
  })();
74
75
  cacheTags = Array.isArray(cacheTagValues) ? cacheTagValues : [cacheTagValues];
75
76
  method = isUrlMethodPair(params.href) ? params.href.method : params.method?.toLowerCase() || 'get';
package/dist/types.d.ts CHANGED
@@ -7,3 +7,4 @@ export type ResolvedComponent = {
7
7
  default: ComponentType;
8
8
  layout?: LayoutType;
9
9
  };
10
+ export type SvelteInertiaAppConfig = {};
package/dist/useForm.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { router } from '@inertiajs/core';
2
2
  import { cloneDeep, get, has, isEqual, set } from 'lodash-es';
3
3
  import { writable } from 'svelte/store';
4
+ import { config } from '.';
4
5
  export default function useForm(rememberKeyOrData, maybeData) {
5
6
  const rememberKey = typeof rememberKeyOrData === 'string' ? rememberKeyOrData : null;
6
7
  const inputData = (typeof rememberKeyOrData === 'string' ? maybeData : rememberKeyOrData) ?? {};
@@ -128,7 +129,7 @@ export default function useForm(rememberKeyOrData, maybeData) {
128
129
  this.clearErrors();
129
130
  setFormState('wasSuccessful', true);
130
131
  setFormState('recentlySuccessful', true);
131
- recentlySuccessfulTimeoutId = setTimeout(() => setFormState('recentlySuccessful', false), 2000);
132
+ recentlySuccessfulTimeoutId = setTimeout(() => setFormState('recentlySuccessful', false), config.get('form.recentlySuccessfulDuration'));
132
133
  const onSuccess = options.onSuccess ? await options.onSuccess(page) : null;
133
134
  if (!defaultsCalledInOnSuccess) {
134
135
  store.update((form) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inertiajs/svelte",
3
- "version": "2.2.9",
3
+ "version": "2.2.11",
4
4
  "license": "MIT",
5
5
  "description": "The Svelte adapter for Inertia.js",
6
6
  "contributors": [
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "@types/lodash-es": "^4.17.12",
56
56
  "lodash-es": "^4.17.21",
57
- "@inertiajs/core": "2.2.9"
57
+ "@inertiajs/core": "2.2.11"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "pnpm package && svelte-check --tsconfig ./tsconfig.json && publint",