Skip to content

Commit

Permalink
Add inertiajs#1864 to the Svelte 5 adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesst20 committed May 12, 2024
1 parent 3f53ae7 commit 9bd87b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/svelte5/src/lib/createInertiaApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export default async function createInertiaApp({
const isServer = typeof window === 'undefined'
const el = isServer ? null : document.getElementById(id)
const initialPage: Page = page || JSON.parse(el?.dataset?.page || '{}')
const resolveComponent = (name: string) => Promise.resolve(resolve(name))
const resolveComponent = (name: string, page: Page) => Promise.resolve(resolve(name, page))

await resolveComponent(initialPage.component).then((initialComponent) => {
await resolveComponent(initialPage.component, initialPage).then((initialComponent) => {
store.component = initialComponent as InertiaComponentType
store.page = initialPage
})
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte5/src/lib/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PageProps } from '@inertiajs/core'
import type { Page, PageProps } from '@inertiajs/core'
import type { ComponentType } from 'svelte'

export type ComponentResolver = (name: string) => ComponentType | Promise<ComponentType>
export type ComponentResolver = (name: string, page: Page) => ComponentType | Promise<ComponentType>

export interface InertiaComponentType extends ComponentType {
default: InertiaComponentType
Expand Down

0 comments on commit 9bd87b3

Please sign in to comment.