Skip to content

Commit

Permalink
rename onBeforeMountApp to onBeforeRenderClient
Browse files Browse the repository at this point in the history
Signed-off-by: Chris-Robin Ennen <chris-robin@ennen.dev>
  • Loading branch information
4350pChris committed Jun 3, 2024
1 parent aaa51f7 commit f77ddfc
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/vike-vue-pinia/renderer/+config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: 'vike-vue-pinia',
onCreateApp: 'import:vike-vue-pinia/renderer/installPinia:installPinia',
onAfterRenderSSRApp: 'import:vike-vue-pinia/renderer/dehydratePinia:dehydratePinia',
onBeforeMountApp: 'import:vike-vue-pinia/renderer/hydratePinia:hydratePinia',
onBeforeRenderClient: 'import:vike-vue-pinia/renderer/hydratePinia:hydratePinia',
}

declare global {
Expand Down
4 changes: 2 additions & 2 deletions packages/vike-vue-pinia/renderer/hydratePinia.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { OnBeforeMountAppSync } from 'vike-vue/types'
import type { onBeforeRenderClientSync } from 'vike-vue/types'

export { hydratePinia }

const hydratePinia: OnBeforeMountAppSync = ({ pinia, fromHtmlRenderer }): ReturnType<OnBeforeMountAppSync> => {
const hydratePinia: onBeforeRenderClientSync = ({ pinia, fromHtmlRenderer }): ReturnType<onBeforeRenderClientSync> => {
const { piniaInitialState } = fromHtmlRenderer

if (!pinia || !piniaInitialState) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vike-vue-query/renderer/+config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: 'vike-vue-query',
onCreateApp: 'import:vike-vue-query/renderer/installVueQuery:installVueQuery',
onAfterRenderSSRApp: 'import:vike-vue-query/renderer/dehydrateVueQuery:dehydrateVueQuery',
onBeforeMountApp: 'import:vike-vue-query/renderer/hydrateVueQuery:hydrateVueQuery',
onBeforeRenderClient: 'import:vike-vue-query/renderer/hydrateVueQuery:hydrateVueQuery',
meta: {
queryClientConfig: {
env: {
Expand Down
7 changes: 5 additions & 2 deletions packages/vike-vue-query/renderer/hydrateVueQuery.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { hydrate } from '@tanstack/vue-query'
import type { OnBeforeMountAppSync } from 'vike-vue/types'
import type { onBeforeRenderClientSync } from 'vike-vue/types'

export { hydrateVueQuery }

const hydrateVueQuery: OnBeforeMountAppSync = ({ queryClient, fromHtmlRenderer }): ReturnType<OnBeforeMountAppSync> => {
const hydrateVueQuery: onBeforeRenderClientSync = ({
queryClient,
fromHtmlRenderer,
}): ReturnType<onBeforeRenderClientSync> => {
const { vueQueryInitialState } = fromHtmlRenderer

if (!queryClient || !vueQueryInitialState) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vike-vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Vike and Vue.
* [`onCreateApp()`](https://vike.dev/onCreateApp): Allows you to extend the Vue app, typically for registering a Vue
plugin.
* `onAfterRenderSSRApp()`: Called right after rendering the app on the server. Usually used for dehydration of state management libraries.
* `onBeforeMountApp()`: Called before mounting the app on the client. Usually used for hydration of state management libraries.
* `onBeforeRenderClient()`: Called before mounting the app on the client. Usually used for hydration of state management libraries.

## Settings

Expand Down
8 changes: 4 additions & 4 deletions packages/vike-vue/src/hooks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export type {
OnCreateAppAsync,
OnAfterRenderSSRAppSync,
OnAfterRenderSSRAppAsync,
OnBeforeMountAppSync,
OnBeforeMountAppAsync,
OnBeforeRenderClientSync,
OnBeforeRenderClientAsync,
}

import type { PageContext } from 'vike/types'
Expand Down Expand Up @@ -48,10 +48,10 @@ type OnAfterRenderSSRAppAsync = (pageContext: PageContext) => Promise<PageContex
*
* Typically used for hydrating state management libraries.
*/
type OnBeforeMountAppSync = (pageContext: PageContext) => void
type OnBeforeRenderClientSync = (pageContext: PageContext) => void
/**
* Hook called right before mounting the page's root Vue component.
*
* Typically used for hydrating state management libraries.
*/
type OnBeforeMountAppAsync = (pageContext: PageContext) => Promise<void>
type OnBeforeRenderClientAsync = (pageContext: PageContext) => Promise<void>
4 changes: 2 additions & 2 deletions packages/vike-vue/src/renderer/onRenderClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ const onRenderClient: OnRenderClientAsync = async (pageContext): ReturnType<OnRe
app = res.app
objectAssign(pageContext, { app })

await callCumulativeHooks(pageContext.config.onBeforeMountApp, pageContext)
await callCumulativeHooks(pageContext.config.onBeforeRenderClient, pageContext)

app.mount(container)
} else {
// Client-side navigation

await callCumulativeHooks(pageContext.config.onBeforeRenderClient, pageContext)
await changePage!(pageContext)

const title = getHeadSetting('title', pageContext) || ''
Expand Down
6 changes: 3 additions & 3 deletions packages/vike-vue/src/types/PageContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { App, defineComponent } from 'vue'
import type {
OnAfterRenderSSRAppAsync,
OnAfterRenderSSRAppSync,
OnBeforeMountAppAsync,
OnBeforeMountAppSync,
OnBeforeRenderClientAsync,
OnBeforeRenderClientSync,
OnCreateAppAsync,
OnCreateAppSync,
} from '../hooks/types'
Expand All @@ -28,7 +28,7 @@ declare global {
interface ConfigResolved {
onCreateApp?: Array<OnCreateAppSync | OnCreateAppAsync>
onAfterRenderSSRApp?: Array<OnAfterRenderSSRAppSync | OnAfterRenderSSRAppAsync>
onBeforeMountApp?: Array<OnBeforeMountAppSync | OnBeforeMountAppAsync>
onBeforeRenderClient?: Array<OnBeforeRenderClientSync | OnBeforeRenderClientAsync>
}
}
}

0 comments on commit f77ddfc

Please sign in to comment.