Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
reinink committed Sep 27, 2024
1 parent a65e404 commit fd39b40
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 45 deletions.
48 changes: 25 additions & 23 deletions packages/core/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { default as Axios, AxiosResponse } from 'axios'
import debounce from './debounce'
import {
fireBeforeEvent,
fireErrorEvent,
fireExceptionEvent,
fireFinishEvent,
fireInvalidEvent,
fireNavigateEvent,
fireProgressEvent,
fireStartEvent,
fireSuccessEvent,
fireBeforeEvent,
fireErrorEvent,
fireExceptionEvent,
fireFinishEvent,
fireInvalidEvent,
fireNavigateEvent,
fireProgressEvent,
fireStartEvent,
fireSuccessEvent,
} from './events'
import { hasFiles } from './files'
import { objectToFormData } from './formData'
import modal from './modal'
import {
ActiveVisit,
GlobalEvent,
GlobalEventNames,
GlobalEventResult,
LocationVisit,
Page,
PageHandler,
PageResolver,
PendingVisit,
PreserveStateOption,
RequestPayload,
VisitId,
VisitOptions,
ActiveVisit,
GlobalEvent,
GlobalEventNames,
GlobalEventResult,
LocationVisit,
Page,
PageHandler,
PageResolver,
PendingVisit,
PreserveStateOption,
RequestPayload,
VisitId,
VisitOptions,
} from './types'
import { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash } from './url'

Expand Down Expand Up @@ -76,7 +76,9 @@ export class Router {

protected setNavigationType(): void {
this.navigationType =
window.performance && window.performance.getEntriesByType && window.performance.getEntriesByType('navigation').length > 0
window.performance &&
window.performance.getEntriesByType &&
window.performance.getEntriesByType('navigation').length > 0
? (window.performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming).type
: 'navigate'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { router as Router } from '@inertiajs/core'

export const router = Router
export { default as createInertiaApp } from './createInertiaApp'
export { default as Head } from './Head'
export { InertiaLinkProps, default as Link } from './Link'
export { default as createInertiaApp } from './createInertiaApp'
export { InertiaFormProps, default as useForm } from './useForm'
export { default as usePage } from './usePage'
export { default as useRemember } from './useRemember'
3 changes: 1 addition & 2 deletions packages/svelte/src/lib/components/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
layout: ComponentType,
child: RenderProps,
pageProps: PageProps,
key: number | null
key: number | null,
): RenderProps {
if (Array.isArray(layout)) {
return layout
Expand All @@ -58,4 +58,3 @@
{#if props}
<Render {...props} />
{/if}

14 changes: 6 additions & 8 deletions packages/svelte/src/lib/createInertiaApp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VERSION } from 'svelte/compiler'
import { router, setupProgress, type InertiaAppResponse, type Page } from '@inertiajs/core'
import type { ComponentType } from 'svelte'
import escape from 'html-escape'
import type { ComponentType } from 'svelte'
import { VERSION } from 'svelte/compiler'
import App from './components/App.svelte'
import store from './store'
import type { ComponentResolver, ResolvedComponent } from './types'
Expand Down Expand Up @@ -100,15 +100,13 @@ export default async function createInertiaApp({
})
}

/**
* Loads the module dynamically during execution instead of at build time.
*
* The @vite-ignore directive prevents Vite from analyzing or pre-bundling this import.
**/
// Loads the module dynamically during execution instead of at
// build time. The `@vite-ignore` flag prevents Vite from
// analyzing or pre-bundling this import.
async function dynamicImport(module: string) {
try {
return await import(/* @vite-ignore */ module)
} catch {
return null
}
}
}
2 changes: 1 addition & 1 deletion packages/svelte/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export { default as createInertiaApp } from './createInertiaApp'
export { default as inertia } from './link'
export { default as page } from './page'
export { default as remember } from './remember'
export { type InertiaFormProps, type InertiaForm, default as useForm } from './useForm'
export { default as useForm, type InertiaForm, type InertiaFormProps } from './useForm'
17 changes: 9 additions & 8 deletions packages/svelte/src/lib/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function useForm<TForm extends FormDataType>(
): Writable<InertiaForm<TForm>> {
const rememberKey = typeof rememberKeyOrData === 'string' ? rememberKeyOrData : null
const inputData = typeof rememberKeyOrData === 'string' ? maybeData : rememberKeyOrData
const data: TForm = typeof inputData === 'function' ? inputData() : inputData as TForm
const data: TForm = typeof inputData === 'function' ? inputData() : (inputData as TForm)
const restored = rememberKey
? (router.restore(rememberKey) as { data: TForm; errors: Record<keyof TForm, string> } | null)
: null
Expand Down Expand Up @@ -92,12 +92,13 @@ export default function useForm<TForm extends FormDataType>(
return this
},
defaults(fieldOrFields?: keyof TForm | Partial<TForm>, maybeValue?: FormDataConvertible) {
defaults = typeof fieldOrFields === 'undefined'
? cloneDeep(this.data())
: Object.assign(
cloneDeep(defaults),
typeof fieldOrFields === 'string' ? { [fieldOrFields]: maybeValue } : fieldOrFields,
)
defaults =
typeof fieldOrFields === 'undefined'
? cloneDeep(this.data())
: Object.assign(
cloneDeep(defaults),
typeof fieldOrFields === 'string' ? { [fieldOrFields]: maybeValue } : fieldOrFields,
)

return this
},
Expand Down Expand Up @@ -257,4 +258,4 @@ export default function useForm<TForm extends FormDataType>(
})

return store
}
}
2 changes: 1 addition & 1 deletion packages/vue2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export { default as createInertiaApp } from './createInertiaApp'
export { default as Head } from './head'
export { InertiaLinkProps, default as Link } from './link'
export * from './types'
export { InertiaFormProps, InertiaForm, default as useForm } from './useForm'
export { InertiaForm, InertiaFormProps, default as useForm } from './useForm'
2 changes: 1 addition & 1 deletion packages/vue3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export { default as createInertiaApp } from './createInertiaApp'
export { default as Head } from './head'
export { InertiaLinkProps, default as Link } from './link'
export * from './types'
export { InertiaFormProps, InertiaForm, default as useForm } from './useForm'
export { InertiaForm, InertiaFormProps, default as useForm } from './useForm'
export { default as useRemember } from './useRemember'

0 comments on commit fd39b40

Please sign in to comment.