@inertiajs/svelte 3.0.3 → 3.1.1
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,34 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { isSameUrlWithoutQueryOrHash, router } from '@inertiajs/core'
|
|
2
|
+
import { isSameUrlWithoutQueryOrHash, router, partialReloadRequestsSomeProps } from '@inertiajs/core'
|
|
3
3
|
import { get } from 'es-toolkit/compat'
|
|
4
4
|
import { page } from '../index'
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
data: string | string[]
|
|
8
|
+
rescue?: import('svelte').Snippet<[{ reloading: boolean }]>
|
|
8
9
|
fallback?: import('svelte').Snippet
|
|
9
10
|
children?: import('svelte').Snippet<[{ reloading: boolean }]>
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
let { data, fallback, children }: Props = $props()
|
|
13
|
+
let { data, rescue, fallback, children }: Props = $props()
|
|
13
14
|
|
|
14
15
|
const keys = $derived(Array.isArray(data) ? data : [data])
|
|
16
|
+
const rescuedKeys = $derived(new Set(page.rescuedProps))
|
|
15
17
|
const loaded = $derived(keys.every((key) => typeof get(page.props, key) !== 'undefined'))
|
|
18
|
+
const failed = $derived(keys.some((key) => rescuedKeys.has(key)))
|
|
16
19
|
|
|
17
20
|
let reloading = $state(false)
|
|
18
21
|
const activeReloads = new Set<object>()
|
|
19
22
|
|
|
20
|
-
const keysAreBeingReloaded = (only: string[], except: string[], keys: string[]): boolean => {
|
|
21
|
-
if (only.length === 0 && except.length === 0) {
|
|
22
|
-
return true
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (only.length > 0) {
|
|
26
|
-
return keys.some((key) => only.includes(key))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return keys.some((key) => !except.includes(key))
|
|
30
|
-
}
|
|
31
|
-
|
|
32
23
|
$effect(() => {
|
|
33
24
|
const removeStartListener = router.on('start', (e) => {
|
|
34
25
|
const visit = e.detail.visit
|
|
@@ -36,7 +27,7 @@
|
|
|
36
27
|
if (
|
|
37
28
|
visit.preserveState === true &&
|
|
38
29
|
isSameUrlWithoutQueryOrHash(visit.url, window.location) &&
|
|
39
|
-
|
|
30
|
+
partialReloadRequestsSomeProps(visit, keys)
|
|
40
31
|
) {
|
|
41
32
|
activeReloads.add(visit)
|
|
42
33
|
reloading = true
|
|
@@ -66,8 +57,10 @@
|
|
|
66
57
|
})
|
|
67
58
|
</script>
|
|
68
59
|
|
|
69
|
-
{#if loaded}
|
|
60
|
+
{#if loaded && !failed}
|
|
70
61
|
{@render children?.({ reloading })}
|
|
62
|
+
{:else if failed && rescue}
|
|
63
|
+
{@render rescue?.({ reloading })}
|
|
71
64
|
{:else}
|
|
72
65
|
{@render fallback?.()}
|
|
73
66
|
{/if}
|
package/dist/createInertiaApp.js
CHANGED
|
@@ -2,8 +2,11 @@ import { buildSSRBody, getInitialPageFromDOM, http as httpModule, router, setupP
|
|
|
2
2
|
import { hydrate, mount } from 'svelte';
|
|
3
3
|
import App, {} from './components/App.svelte';
|
|
4
4
|
import { config } from './index';
|
|
5
|
-
export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page, defaults = {}, http, layout, withApp, } = {}) {
|
|
5
|
+
export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page, defaults = {}, nonce, http, layout, withApp, } = {}) {
|
|
6
6
|
config.replace(defaults);
|
|
7
|
+
if (nonce) {
|
|
8
|
+
config.set('nonce', nonce);
|
|
9
|
+
}
|
|
7
10
|
if (http) {
|
|
8
11
|
httpModule.setClient(http);
|
|
9
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/svelte",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Svelte adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@sveltejs/adapter-auto": "^7.0.1",
|
|
40
|
-
"@sveltejs/kit": "^2.
|
|
40
|
+
"@sveltejs/kit": "^2.58.0",
|
|
41
41
|
"@sveltejs/package": "^2.5.7",
|
|
42
42
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
43
|
-
"axios": "^1.
|
|
43
|
+
"axios": "^1.15.2",
|
|
44
44
|
"es-check": "9.5.3",
|
|
45
45
|
"publint": "^0.3.17",
|
|
46
46
|
"svelte": "^5.53.5",
|
|
47
47
|
"svelte-check": "^4.4.3",
|
|
48
48
|
"tslib": "^2.8.1",
|
|
49
49
|
"typescript": "^5.9.3",
|
|
50
|
-
"vite": "^8.0.
|
|
50
|
+
"vite": "^8.0.10"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"svelte": "^5.0.0"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"es-toolkit": "^1.33.0",
|
|
57
57
|
"laravel-precognition": "^2.0.0",
|
|
58
|
-
"@inertiajs/core": "3.
|
|
58
|
+
"@inertiajs/core": "3.1.1"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "pnpm package && svelte-check --tsconfig ./tsconfig.json && publint",
|