inertiax-svelte 5.0.13 → 5.0.14
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/app.html +12 -0
- package/dist/components/Deferred.svelte +12 -7
- package/dist/components/Deferred.svelte.d.ts +29 -19
- package/dist/components/Frame.svelte +4 -3
- package/dist/components/Frame.svelte.d.ts +15 -30
- package/dist/components/Link.svelte +31 -20
- package/dist/components/Link.svelte.d.ts +59 -50
- package/dist/components/Render.svelte +41 -13
- package/dist/components/Render.svelte.d.ts +21 -19
- package/dist/components/WhenVisible.svelte +75 -59
- package/dist/components/WhenVisible.svelte.d.ts +33 -23
- package/dist/createInertiaApp.js +3 -2
- package/dist/index.js +0 -1
- package/dist/store.d.ts +2 -0
- package/dist/usePoll.js +0 -1
- package/dist/usePrefetch.d.ts +2 -0
- package/dist/usePrefetch.js +0 -1
- package/dist/useRemember.d.ts +2 -0
- package/dist/useRemember.js +0 -1
- package/package.json +6 -6
package/dist/app.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
%sveltekit.head%
|
|
8
|
+
</head>
|
|
9
|
+
<body data-sveltekit-preload-data="hover">
|
|
10
|
+
<div>%sveltekit.body%</div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from 'svelte'
|
|
3
|
+
|
|
4
|
+
const { page } = getContext('inertia')
|
|
5
|
+
|
|
6
|
+
export let data: string | string[]
|
|
7
|
+
|
|
8
|
+
const keys = Array.isArray(data) ? data : [data]
|
|
9
|
+
|
|
10
|
+
if (!$$slots.fallback) {
|
|
11
|
+
throw new Error('`<Deferred>` requires a `<svelte:fragment slot="fallback">` slot')
|
|
12
|
+
}
|
|
8
13
|
</script>
|
|
9
14
|
|
|
10
15
|
{#if keys.every((key) => $page.props[key] !== undefined)}
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
5
11
|
};
|
|
6
|
-
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
};
|
|
9
|
-
slots: {
|
|
10
|
-
default: {};
|
|
11
|
-
fallback: {};
|
|
12
|
-
};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type DeferredProps = typeof __propDef.props;
|
|
17
|
-
export type DeferredEvents = typeof __propDef.events;
|
|
18
|
-
export type DeferredSlots = typeof __propDef.slots;
|
|
19
|
-
export default class Deferred extends SvelteComponent<DeferredProps, DeferredEvents, DeferredSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
20
13
|
}
|
|
21
|
-
|
|
14
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
15
|
+
default: any;
|
|
16
|
+
} ? Props extends Record<string, never> ? any : {
|
|
17
|
+
children?: any;
|
|
18
|
+
} : {});
|
|
19
|
+
declare const Deferred: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
+
data: string | string[];
|
|
21
|
+
}, {
|
|
22
|
+
default: {};
|
|
23
|
+
fallback: {};
|
|
24
|
+
}>, {
|
|
25
|
+
[evt: string]: CustomEvent<any>;
|
|
26
|
+
}, {
|
|
27
|
+
default: {};
|
|
28
|
+
fallback: {};
|
|
29
|
+
}, {}, string>;
|
|
30
|
+
type Deferred = InstanceType<typeof Deferred>;
|
|
31
|
+
export default Deferred;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { BROWSER } from 'esm-env';
|
|
2
3
|
import { onDestroy, onMount, setContext } from 'svelte'
|
|
3
4
|
import { toStore } from 'svelte/store';
|
|
4
5
|
import { Router } from 'inertiax-core';
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
url,
|
|
14
15
|
makeRequest = true,
|
|
15
16
|
|
|
17
|
+
children,
|
|
16
18
|
version
|
|
17
19
|
} = $props()
|
|
18
20
|
|
|
@@ -108,8 +110,7 @@
|
|
|
108
110
|
document.addEventListener('click', clickhandler)
|
|
109
111
|
})
|
|
110
112
|
|
|
111
|
-
onDestroy(function() {
|
|
112
|
-
if (import.meta.env.SSR) return
|
|
113
|
+
if (BROWSER) onDestroy(function() {
|
|
113
114
|
document.removeEventListener('click', clickhandler)
|
|
114
115
|
})
|
|
115
116
|
</script>
|
|
@@ -120,7 +121,7 @@
|
|
|
120
121
|
{#if resolvedProps}
|
|
121
122
|
<Render {...resolvedProps} />
|
|
122
123
|
{:else}
|
|
123
|
-
|
|
124
|
+
{@render children?.()}
|
|
124
125
|
{/if}
|
|
125
126
|
</div>
|
|
126
127
|
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
/// <reference types="svelte" />
|
|
3
|
+
export default Frame;
|
|
4
|
+
declare const Frame: import("svelte").Component<{
|
|
5
|
+
name?: unknown;
|
|
6
|
+
renderLayout?: unknown;
|
|
7
|
+
component: unknown;
|
|
8
|
+
props: unknown;
|
|
9
|
+
url: unknown;
|
|
10
|
+
makeRequest?: boolean | undefined;
|
|
11
|
+
children: unknown;
|
|
12
|
+
version: unknown;
|
|
6
13
|
}, {
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
}> {
|
|
11
|
-
get router(): Router;
|
|
12
|
-
}
|
|
13
|
-
export type FrameProps = typeof __propDef.props;
|
|
14
|
-
export type FrameEvents = typeof __propDef.events;
|
|
15
|
-
export type FrameSlots = typeof __propDef.slots;
|
|
16
|
-
import { Router } from 'inertiax-core';
|
|
17
|
-
import { SvelteComponent } from "svelte";
|
|
18
|
-
declare const __propDef: {
|
|
19
|
-
props: {
|
|
20
|
-
router?: Router | undefined;
|
|
21
|
-
};
|
|
22
|
-
events: {
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
};
|
|
25
|
-
slots: {
|
|
26
|
-
default: {};
|
|
27
|
-
};
|
|
28
|
-
exports?: undefined;
|
|
29
|
-
bindings?: undefined;
|
|
30
|
-
};
|
|
31
|
-
export {};
|
|
14
|
+
router: Router;
|
|
15
|
+
}, "">;
|
|
16
|
+
import { Router } from "inertiax-core";
|
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type {
|
|
3
|
+
CacheForOption,
|
|
4
|
+
FormDataConvertible,
|
|
5
|
+
LinkPrefetchOption,
|
|
6
|
+
Method,
|
|
7
|
+
PreserveStateOption,
|
|
8
|
+
} from 'inertiax-core'
|
|
9
|
+
import { inertia } from '../index'
|
|
10
|
+
|
|
11
|
+
export let href: string
|
|
12
|
+
export let as: keyof HTMLElementTagNameMap = 'a'
|
|
13
|
+
export let data: Record<string, FormDataConvertible> = {}
|
|
14
|
+
export let method: Method = 'get'
|
|
15
|
+
export let replace: boolean = false
|
|
16
|
+
export let preserveScroll: PreserveStateOption = false
|
|
17
|
+
export let preserveState: PreserveStateOption | null = null
|
|
18
|
+
export let only: string[] = []
|
|
19
|
+
export let except: string[] = []
|
|
20
|
+
export let headers: Record<string, string> = {}
|
|
21
|
+
export let queryStringArrayFormat: 'brackets' | 'indices' = 'brackets'
|
|
22
|
+
export let async: boolean = false
|
|
23
|
+
export let prefetch: boolean | LinkPrefetchOption | LinkPrefetchOption[] = false
|
|
24
|
+
export let cacheFor: CacheForOption | CacheForOption[] = 0
|
|
25
|
+
|
|
26
|
+
$: asProp = method !== 'get' ? 'button' : as.toLowerCase()
|
|
27
|
+
$: elProps =
|
|
28
|
+
{
|
|
29
|
+
a: { href },
|
|
30
|
+
button: { type: 'button' },
|
|
31
|
+
}[asProp] || {}
|
|
21
32
|
</script>
|
|
22
33
|
|
|
23
34
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
@@ -1,53 +1,62 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { CacheForOption, FormDataConvertible, LinkPrefetchOption, Method, PreserveStateOption } from 'inertiax-core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
only?: string[] | undefined;
|
|
14
|
-
except?: string[] | undefined;
|
|
15
|
-
headers?: Record<string, string> | undefined;
|
|
16
|
-
queryStringArrayFormat?: ("brackets" | "indices") | undefined;
|
|
17
|
-
async?: boolean | undefined;
|
|
18
|
-
prefetch?: (boolean | LinkPrefetchOption | LinkPrefetchOption[]) | undefined;
|
|
19
|
-
cacheFor?: (CacheForOption | CacheForOption[]) | undefined;
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
20
12
|
};
|
|
21
|
-
|
|
22
|
-
focus: FocusEvent;
|
|
23
|
-
blur: FocusEvent;
|
|
24
|
-
click: MouseEvent;
|
|
25
|
-
dblclick: MouseEvent;
|
|
26
|
-
mousedown: MouseEvent;
|
|
27
|
-
mousemove: MouseEvent;
|
|
28
|
-
mouseout: MouseEvent;
|
|
29
|
-
mouseover: MouseEvent;
|
|
30
|
-
mouseup: MouseEvent;
|
|
31
|
-
'cancel-token': MouseEvent | UIEvent | Event | KeyboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
32
|
-
before: MouseEvent | UIEvent | Event | KeyboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
33
|
-
start: MouseEvent | UIEvent | Event | KeyboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
34
|
-
progress: ProgressEvent<EventTarget>;
|
|
35
|
-
finish: MouseEvent | UIEvent | Event | KeyboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
36
|
-
cancel: Event;
|
|
37
|
-
success: MouseEvent | UIEvent | Event | KeyboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | ClipboardEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
38
|
-
error: ErrorEvent;
|
|
39
|
-
} & {
|
|
40
|
-
[evt: string]: CustomEvent<any>;
|
|
41
|
-
};
|
|
42
|
-
slots: {
|
|
43
|
-
default: {};
|
|
44
|
-
};
|
|
45
|
-
exports?: undefined;
|
|
46
|
-
bindings?: undefined;
|
|
47
|
-
};
|
|
48
|
-
export type LinkProps = typeof __propDef.props;
|
|
49
|
-
export type LinkEvents = typeof __propDef.events;
|
|
50
|
-
export type LinkSlots = typeof __propDef.slots;
|
|
51
|
-
export default class Link extends SvelteComponent<LinkProps, LinkEvents, LinkSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
52
14
|
}
|
|
53
|
-
|
|
15
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
16
|
+
default: any;
|
|
17
|
+
} ? Props extends Record<string, never> ? any : {
|
|
18
|
+
children?: any;
|
|
19
|
+
} : {});
|
|
20
|
+
declare const Link: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
21
|
+
[x: string]: any;
|
|
22
|
+
href: string;
|
|
23
|
+
as?: keyof HTMLElementTagNameMap | undefined;
|
|
24
|
+
data?: Record<string, FormDataConvertible> | undefined;
|
|
25
|
+
method?: Method | undefined;
|
|
26
|
+
replace?: boolean | undefined;
|
|
27
|
+
preserveScroll?: PreserveStateOption | undefined;
|
|
28
|
+
preserveState?: PreserveStateOption | null | undefined;
|
|
29
|
+
only?: string[] | undefined;
|
|
30
|
+
except?: string[] | undefined;
|
|
31
|
+
headers?: Record<string, string> | undefined;
|
|
32
|
+
queryStringArrayFormat?: "indices" | "brackets" | undefined;
|
|
33
|
+
async?: boolean | undefined;
|
|
34
|
+
prefetch?: boolean | LinkPrefetchOption | LinkPrefetchOption[] | undefined;
|
|
35
|
+
cacheFor?: CacheForOption | CacheForOption[] | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
default: {};
|
|
38
|
+
}>, {
|
|
39
|
+
focus: FocusEvent;
|
|
40
|
+
blur: FocusEvent;
|
|
41
|
+
click: MouseEvent;
|
|
42
|
+
dblclick: MouseEvent;
|
|
43
|
+
mousedown: MouseEvent;
|
|
44
|
+
mousemove: MouseEvent;
|
|
45
|
+
mouseout: MouseEvent;
|
|
46
|
+
mouseover: MouseEvent;
|
|
47
|
+
mouseup: MouseEvent;
|
|
48
|
+
'cancel-token': MouseEvent | UIEvent | Event | KeyboardEvent | ClipboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
49
|
+
before: MouseEvent | UIEvent | Event | KeyboardEvent | ClipboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
50
|
+
start: MouseEvent | UIEvent | Event | KeyboardEvent | ClipboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
51
|
+
progress: ProgressEvent<EventTarget>;
|
|
52
|
+
finish: MouseEvent | UIEvent | Event | KeyboardEvent | ClipboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
53
|
+
cancel: Event;
|
|
54
|
+
success: MouseEvent | UIEvent | Event | KeyboardEvent | ClipboardEvent | AnimationEvent | InputEvent | FocusEvent | CompositionEvent | DragEvent | ErrorEvent | FormDataEvent | PointerEvent | ProgressEvent<EventTarget> | SecurityPolicyViolationEvent | SubmitEvent | TouchEvent | TransitionEvent | WheelEvent;
|
|
55
|
+
error: ErrorEvent;
|
|
56
|
+
} & {
|
|
57
|
+
[evt: string]: CustomEvent<any>;
|
|
58
|
+
}, {
|
|
59
|
+
default: {};
|
|
60
|
+
}, {}, string>;
|
|
61
|
+
type Link = InstanceType<typeof Link>;
|
|
62
|
+
export default Link;
|
|
@@ -1,18 +1,46 @@
|
|
|
1
|
-
<script context="module"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
import type { PageProps } from 'inertiax-core'
|
|
3
|
+
import type { ComponentType } from 'svelte'
|
|
4
|
+
|
|
5
|
+
export type RenderProps = {
|
|
6
|
+
component: ComponentType
|
|
7
|
+
props?: PageProps
|
|
8
|
+
children?: RenderProps[]
|
|
9
|
+
key?: number | null
|
|
10
|
+
} | null
|
|
11
|
+
|
|
12
|
+
export type RenderFunction = {
|
|
13
|
+
(component: ComponentType, props?: PageProps, children?: RenderProps[], key?: number | null): RenderProps
|
|
14
|
+
(component: ComponentType, children?: RenderProps[], key?: number | null): RenderProps
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const h: RenderFunction = (component, propsOrChildren, childrenOrKey, key: number | null = null) => {
|
|
18
|
+
const hasProps = typeof propsOrChildren === 'object' && propsOrChildren !== null && !Array.isArray(propsOrChildren)
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
component,
|
|
22
|
+
key: hasProps ? key : typeof childrenOrKey === 'number' ? childrenOrKey : null,
|
|
23
|
+
props: hasProps ? propsOrChildren : {},
|
|
24
|
+
children: hasProps
|
|
25
|
+
? ((Array.isArray(childrenOrKey)
|
|
26
|
+
? childrenOrKey
|
|
27
|
+
: childrenOrKey !== null
|
|
28
|
+
? [childrenOrKey]
|
|
29
|
+
: []) as RenderProps[])
|
|
30
|
+
: ((Array.isArray(propsOrChildren)
|
|
31
|
+
? propsOrChildren
|
|
32
|
+
: propsOrChildren !== null
|
|
33
|
+
? [propsOrChildren]
|
|
34
|
+
: []) as RenderProps[]),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
10
37
|
</script>
|
|
11
38
|
|
|
12
|
-
<script>
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
39
|
+
<script lang="ts">
|
|
40
|
+
export let component: ComponentType
|
|
41
|
+
export let props: PageProps = {}
|
|
42
|
+
export let children: RenderProps[] = []
|
|
43
|
+
export let key: number | null = null
|
|
16
44
|
</script>
|
|
17
45
|
|
|
18
46
|
{#if component}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { PageProps } from 'inertiax-core';
|
|
3
2
|
import type { ComponentType } from 'svelte';
|
|
4
3
|
export type RenderProps = {
|
|
@@ -12,23 +11,26 @@ export type RenderFunction = {
|
|
|
12
11
|
(component: ComponentType, children?: RenderProps[], key?: number | null): RenderProps;
|
|
13
12
|
};
|
|
14
13
|
export declare const h: RenderFunction;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
15
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: Props & {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
21
24
|
};
|
|
22
|
-
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
};
|
|
25
|
-
slots: {};
|
|
26
|
-
exports?: {} | undefined;
|
|
27
|
-
bindings?: string | undefined;
|
|
28
|
-
};
|
|
29
|
-
type RenderProps_ = typeof __propDef.props;
|
|
30
|
-
export type RenderEvents = typeof __propDef.events;
|
|
31
|
-
export type RenderSlots = typeof __propDef.slots;
|
|
32
|
-
export default class Render extends SvelteComponent<RenderProps_, RenderEvents, RenderSlots> {
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
33
26
|
}
|
|
34
|
-
|
|
27
|
+
declare const Render: $$__sveltets_2_IsomorphicComponent<{
|
|
28
|
+
component: ComponentType;
|
|
29
|
+
props?: PageProps | undefined;
|
|
30
|
+
children?: RenderProps[] | undefined;
|
|
31
|
+
key?: number | null | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
[evt: string]: CustomEvent<any>;
|
|
34
|
+
}, {}, {}, string>;
|
|
35
|
+
type Render = InstanceType<typeof Render>;
|
|
36
|
+
export default Render;
|
|
@@ -1,65 +1,81 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export let
|
|
6
|
-
export let
|
|
7
|
-
export let
|
|
8
|
-
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
onFinish: (event) => {
|
|
37
|
-
loaded = true;
|
|
38
|
-
fetching = false;
|
|
39
|
-
reloadParams.onFinish?.(event);
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type ReloadOptions } from 'inertiax-core'
|
|
3
|
+
import { getContext, onDestroy, onMount } from 'svelte'
|
|
4
|
+
|
|
5
|
+
export let data: string | string[] = ''
|
|
6
|
+
export let params: ReloadOptions = {}
|
|
7
|
+
export let buffer: number = 0
|
|
8
|
+
export let as: keyof HTMLElementTagNameMap = 'div'
|
|
9
|
+
export let always: boolean = false
|
|
10
|
+
|
|
11
|
+
const { router } = getContext('inertia')
|
|
12
|
+
|
|
13
|
+
let loaded = false
|
|
14
|
+
let fetching = false
|
|
15
|
+
let el: HTMLElement
|
|
16
|
+
let observer: IntersectionObserver | null = null
|
|
17
|
+
|
|
18
|
+
onMount(() => {
|
|
19
|
+
if (!el) {
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
observer = new IntersectionObserver(
|
|
24
|
+
(entries) => {
|
|
25
|
+
if (!entries[0].isIntersecting) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!always) {
|
|
30
|
+
observer?.disconnect()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (fetching) {
|
|
34
|
+
return
|
|
40
35
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
|
|
37
|
+
fetching = true
|
|
38
|
+
|
|
39
|
+
const reloadParams = getReloadParams()
|
|
40
|
+
|
|
41
|
+
router.reload({
|
|
42
|
+
...reloadParams,
|
|
43
|
+
onStart: (event) => {
|
|
44
|
+
fetching = true
|
|
45
|
+
reloadParams.onStart?.(event)
|
|
46
|
+
},
|
|
47
|
+
onFinish: (event) => {
|
|
48
|
+
loaded = true
|
|
49
|
+
fetching = false
|
|
50
|
+
reloadParams.onFinish?.(event)
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
rootMargin: `${buffer}px`,
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
observer.observe(el)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
onDestroy(() => {
|
|
63
|
+
observer?.disconnect()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
function getReloadParams(): Partial<ReloadOptions> {
|
|
67
|
+
if (data !== '') {
|
|
68
|
+
return {
|
|
69
|
+
only: (Array.isArray(data) ? data : [data]) as string[],
|
|
70
|
+
}
|
|
45
71
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function getReloadParams() {
|
|
53
|
-
if (data !== "") {
|
|
54
|
-
return {
|
|
55
|
-
only: Array.isArray(data) ? data : [data]
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
if (!params.data) {
|
|
59
|
-
throw new Error("You must provide either a `data` or `params` prop.");
|
|
72
|
+
|
|
73
|
+
if (!params.data) {
|
|
74
|
+
throw new Error('You must provide either a `data` or `params` prop.')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return params
|
|
60
78
|
}
|
|
61
|
-
return params;
|
|
62
|
-
}
|
|
63
79
|
</script>
|
|
64
80
|
|
|
65
81
|
{#if always || !loaded}
|
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import { type ReloadOptions } from 'inertiax-core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
10
12
|
};
|
|
11
|
-
|
|
12
|
-
[evt: string]: CustomEvent<any>;
|
|
13
|
-
};
|
|
14
|
-
slots: {
|
|
15
|
-
default: {};
|
|
16
|
-
fallback: {};
|
|
17
|
-
};
|
|
18
|
-
exports?: {} | undefined;
|
|
19
|
-
bindings?: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
export type WhenVisibleProps = typeof __propDef.props;
|
|
22
|
-
export type WhenVisibleEvents = typeof __propDef.events;
|
|
23
|
-
export type WhenVisibleSlots = typeof __propDef.slots;
|
|
24
|
-
export default class WhenVisible extends SvelteComponent<WhenVisibleProps, WhenVisibleEvents, WhenVisibleSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
25
14
|
}
|
|
26
|
-
|
|
15
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
16
|
+
default: any;
|
|
17
|
+
} ? Props extends Record<string, never> ? any : {
|
|
18
|
+
children?: any;
|
|
19
|
+
} : {});
|
|
20
|
+
declare const WhenVisible: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
21
|
+
data?: string | string[] | undefined;
|
|
22
|
+
params?: ReloadOptions | undefined;
|
|
23
|
+
buffer?: number | undefined;
|
|
24
|
+
as?: keyof HTMLElementTagNameMap | undefined;
|
|
25
|
+
always?: boolean | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
default: {};
|
|
28
|
+
fallback: {};
|
|
29
|
+
}>, {
|
|
30
|
+
[evt: string]: CustomEvent<any>;
|
|
31
|
+
}, {
|
|
32
|
+
default: {};
|
|
33
|
+
fallback: {};
|
|
34
|
+
}, {}, string>;
|
|
35
|
+
type WhenVisible = InstanceType<typeof WhenVisible>;
|
|
36
|
+
export default WhenVisible;
|
package/dist/createInertiaApp.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { setupProgress, Router, History } from 'inertiax-core';
|
|
2
2
|
import escape from 'html-escape';
|
|
3
3
|
import Frame from './components/Frame.svelte';
|
|
4
|
+
import { BROWSER } from 'esm-env';
|
|
4
5
|
export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page, }) {
|
|
5
|
-
const el =
|
|
6
|
+
const el = BROWSER && document.getElementById(id);
|
|
6
7
|
const initialState = page || JSON.parse(el?.dataset?.page || '{}');
|
|
7
8
|
// Router.setVersion(initialState.version);
|
|
8
9
|
Router.resolveComponent = (name) => Promise.resolve(resolve(name));
|
|
9
|
-
if (
|
|
10
|
+
if (!BROWSER) {
|
|
10
11
|
const { render } = await dynamicImport('svelte/server');
|
|
11
12
|
const { html, head } = await (async () => {
|
|
12
13
|
return render(Frame, {
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ export { default as Frame } from './components/Frame.svelte';
|
|
|
2
2
|
export { default as Deferred } from './components/Deferred.svelte';
|
|
3
3
|
export { default as WhenVisible } from './components/WhenVisible.svelte';
|
|
4
4
|
export { default as createInertiaApp } from './createInertiaApp';
|
|
5
|
-
export {} from './types';
|
|
6
5
|
export { default as useForm } from './useForm';
|
|
7
6
|
export { default as usePoll } from './usePoll';
|
|
8
7
|
export { default as usePrefetch } from './usePrefetch';
|
package/dist/store.d.ts
CHANGED
package/dist/usePoll.js
CHANGED
package/dist/usePrefetch.d.ts
CHANGED
package/dist/usePrefetch.js
CHANGED
package/dist/useRemember.d.ts
CHANGED
package/dist/useRemember.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inertiax-svelte",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Svelte adapter for Inertia X",
|
|
6
6
|
"contributors": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"url": "https://github.com/buhrmi/inertiax/issues"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"dev": "
|
|
22
|
-
"build": "
|
|
23
|
-
"package": "svelte-kit sync && svelte-package --input src",
|
|
24
|
-
"prepublishOnly": "
|
|
21
|
+
"dev": "bun run package -- --watch",
|
|
22
|
+
"build": "bun run package && bunx publint",
|
|
23
|
+
"package": "bunx svelte-kit sync && bunx svelte-package --input src",
|
|
24
|
+
"prepublishOnly": "bun run build",
|
|
25
25
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
26
26
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
|
27
27
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@sveltejs/adapter-auto": "^3.2.0",
|
|
53
53
|
"@sveltejs/kit": "^2.5.26",
|
|
54
54
|
"@sveltejs/package": "^2.3.5",
|
|
55
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
55
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
|
|
56
56
|
"@types/html-escape": "^2.0.2",
|
|
57
57
|
"@types/lodash": "^4.17.7",
|
|
58
58
|
"axios": "^1.7.6",
|