From 9bd87b33c075332201c971ca6ce476b7f7df94c8 Mon Sep 17 00:00:00 2001 From: James St-Pierre Date: Sun, 12 May 2024 13:08:41 -0400 Subject: [PATCH] Add inertiajs#1864 to the Svelte 5 adapter --- packages/svelte5/src/lib/createInertiaApp.ts | 4 ++-- packages/svelte5/src/lib/types.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/svelte5/src/lib/createInertiaApp.ts b/packages/svelte5/src/lib/createInertiaApp.ts index 5986fd871..7cec633b4 100644 --- a/packages/svelte5/src/lib/createInertiaApp.ts +++ b/packages/svelte5/src/lib/createInertiaApp.ts @@ -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 }) diff --git a/packages/svelte5/src/lib/types.d.ts b/packages/svelte5/src/lib/types.d.ts index 55374d34c..542a764c6 100644 --- a/packages/svelte5/src/lib/types.d.ts +++ b/packages/svelte5/src/lib/types.d.ts @@ -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 +export type ComponentResolver = (name: string, page: Page) => ComponentType | Promise export interface InertiaComponentType extends ComponentType { default: InertiaComponentType