inertiax-svelte 1.1.2 → 2.0.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/package.json +1 -1
- package/src/Render.svelte +25 -9
- package/src/createInertiaApp.js +1 -2
- package/src/SSR.svelte +0 -8
package/package.json
CHANGED
package/src/Render.svelte
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script context="module">
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
export const h = (component, props, children) => {
|
|
3
4
|
return {
|
|
4
5
|
component,
|
|
5
6
|
...(props ? { props } : {}),
|
|
6
|
-
...(
|
|
7
|
+
...(children ? { children } : {}),
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
</script>
|
|
@@ -11,13 +12,28 @@
|
|
|
11
12
|
<script>
|
|
12
13
|
import store from './store'
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
let {component, props = {}, children = []} = $props()
|
|
16
|
+
|
|
17
|
+
let key = $state(new Date().getTime())
|
|
18
|
+
|
|
19
|
+
let prev = component
|
|
20
|
+
|
|
21
|
+
function updateKey(component) {
|
|
22
|
+
if (prev !== component) {
|
|
23
|
+
prev = component
|
|
24
|
+
key = new Date().getTime()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
$effect(() => updateKey(component))
|
|
15
29
|
</script>
|
|
16
30
|
|
|
17
31
|
{#if $store.component}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
{#key key}
|
|
33
|
+
<svelte:component this={component} {...props}>
|
|
34
|
+
{#each children as child, index (component && component.length === index ? $store.key : null)}
|
|
35
|
+
<svelte:self {...child} />
|
|
36
|
+
{/each}
|
|
37
|
+
</svelte:component>
|
|
38
|
+
{/key}
|
|
39
|
+
{/if}
|
package/src/createInertiaApp.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { router, setupProgress } from 'inertiax-core'
|
|
2
2
|
import { render } from 'svelte/server';
|
|
3
3
|
import App from './App.svelte'
|
|
4
|
-
import SSR from './SSR.svelte'
|
|
5
4
|
import store from './store'
|
|
6
5
|
|
|
7
6
|
export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page }) {
|
|
@@ -51,7 +50,7 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
|
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
if (isServer) {
|
|
54
|
-
const { html, head } = render(
|
|
53
|
+
const { html, head } = render(App)
|
|
55
54
|
|
|
56
55
|
return {
|
|
57
56
|
body: html,
|