@inertiajs/svelte 3.3.1 → 3.5.0
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/createInertiaApp.js +17 -4
- package/dist/env.d.ts +7 -0
- package/dist/useHttp.svelte.js +2 -3
- package/package.json +4 -4
package/dist/createInertiaApp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { buildSSRBody, getInitialPageFromDOM, http as httpModule, router, setupProgress, } from '@inertiajs/core';
|
|
1
|
+
import { buildSSRBody, createHeadManager, exposeInterceptors, getInitialPageFromDOM, http as httpModule, resolveServerHead, router, setupProgress, } from '@inertiajs/core';
|
|
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 = {}, nonce, http, layout, withApp, } = {}) {
|
|
5
|
+
export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page, defaults = {}, nonce, http, layout, serverHead, withApp, dev = !!import.meta.env?.DEV, } = {}) {
|
|
6
6
|
config.replace(defaults);
|
|
7
7
|
if (nonce) {
|
|
8
8
|
config.set('nonce', nonce);
|
|
@@ -10,6 +10,9 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
|
|
|
10
10
|
if (http) {
|
|
11
11
|
httpModule.setClient(http);
|
|
12
12
|
}
|
|
13
|
+
if (dev) {
|
|
14
|
+
exposeInterceptors();
|
|
15
|
+
}
|
|
13
16
|
const isServer = typeof window === 'undefined';
|
|
14
17
|
const resolveComponent = (name, page) => Promise.resolve(resolve(name, page));
|
|
15
18
|
if (isServer && !page) {
|
|
@@ -39,11 +42,14 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
|
|
|
39
42
|
const body = buildSSRBody(id, page, svelteApp.body);
|
|
40
43
|
return {
|
|
41
44
|
body,
|
|
42
|
-
head: [svelteApp.head],
|
|
45
|
+
head: [...resolveServerHead(page, serverHead), svelteApp.head],
|
|
43
46
|
};
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
const initialPage = page || getInitialPageFromDOM(id);
|
|
50
|
+
const serverHeadManager = !isServer && serverHead
|
|
51
|
+
? createHeadManager(false, (title) => title, () => { }, resolveServerHead(initialPage, serverHead))
|
|
52
|
+
: null;
|
|
47
53
|
const [initialComponent] = await Promise.all([
|
|
48
54
|
resolveComponent(initialPage.component, initialPage),
|
|
49
55
|
router.decryptHistory().catch(() => { }),
|
|
@@ -58,7 +64,7 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
|
|
|
58
64
|
const body = buildSSRBody(id, initialPage, svelteApp.body);
|
|
59
65
|
return {
|
|
60
66
|
body,
|
|
61
|
-
head: [svelteApp.head],
|
|
67
|
+
head: [...resolveServerHead(initialPage, serverHead), svelteApp.head],
|
|
62
68
|
};
|
|
63
69
|
}
|
|
64
70
|
return;
|
|
@@ -79,6 +85,13 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
|
|
|
79
85
|
mount(App, { target, props, context });
|
|
80
86
|
}
|
|
81
87
|
}
|
|
88
|
+
if (serverHeadManager) {
|
|
89
|
+
const syncServerHead = (event) => {
|
|
90
|
+
serverHeadManager.updateServerHead(resolveServerHead(event.detail.page, serverHead));
|
|
91
|
+
};
|
|
92
|
+
router.on('navigate', syncServerHead);
|
|
93
|
+
router.on('clientVisit', syncServerHead);
|
|
94
|
+
}
|
|
82
95
|
if (progress) {
|
|
83
96
|
setupProgress(progress);
|
|
84
97
|
}
|
package/dist/env.d.ts
ADDED
package/dist/useHttp.svelte.js
CHANGED
|
@@ -101,10 +101,9 @@ export default function useHttp(...args) {
|
|
|
101
101
|
const processedErrors = (withAllErrors.enabled() ? validationErrors : toSimpleValidationErrors(validationErrors));
|
|
102
102
|
form.clearErrors().setError(processedErrors);
|
|
103
103
|
options.onError?.(processedErrors);
|
|
104
|
+
return undefined;
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
-
options.onHttpException?.(error.response);
|
|
107
|
-
}
|
|
106
|
+
options.onHttpException?.(error.response);
|
|
108
107
|
throw error;
|
|
109
108
|
}
|
|
110
109
|
if (error instanceof HttpCancelledError || (error instanceof Error && error.name === 'AbortError')) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/svelte",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Svelte adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"axios": "^1.17.0",
|
|
44
44
|
"es-check": "9.5.3",
|
|
45
45
|
"publint": "^0.3.17",
|
|
46
|
-
"svelte": "^5.
|
|
46
|
+
"svelte": "^5.56.4",
|
|
47
47
|
"svelte-check": "^4.4.8",
|
|
48
48
|
"tslib": "^2.8.1",
|
|
49
49
|
"typescript": "^6.0.3",
|
|
50
|
-
"vite": "^8.0.
|
|
50
|
+
"vite": "^8.0.16"
|
|
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.5.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "pnpm package && svelte-check --tsconfig ./tsconfig.json && publint",
|