Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/nuxt/src/app/components/nuxt-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { defineComponent, h, ref, resolveComponent, PropType, computed, DefineCo
import { RouteLocationRaw, Router } from 'vue-router'
import { hasProtocol } from 'ufo'

import { navigateTo, useRouter, useNuxtApp } from '#app'
import { navigateTo, useRouter } from '../composables/router'
import { useNuxtApp } from '../nuxt'

const firstNonUndefined = <T>(...args: (T | undefined)[]) => args.find(arg => arg !== undefined)

Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/asyncData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { onBeforeMount, onServerPrefetch, onUnmounted, ref, getCurrentInstance, watch, unref } from 'vue'
import type { Ref, WatchSource } from 'vue'
import { NuxtApp, useNuxtApp } from '#app'
import { NuxtApp, useNuxtApp } from '../nuxt'

export type _Transform<Input = any, Output = any> = (input: Input) => Output

Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { appendHeader } from 'h3'
import type { CompatibilityEvent } from 'h3'
import destr from 'destr'
import { isEqual } from 'ohash'
import { useNuxtApp } from '../nuxt'
import { useRequestEvent } from './ssr'
import { useNuxtApp } from '#app'

type _CookieOptions = Omit<CookieSerializeOptions & CookieParseOptions, 'decode' | 'encode'>

Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createError as _createError, H3Error } from 'h3'
import { toRef } from 'vue'
import { useNuxtApp } from '#app'
import { useNuxtApp } from '../nuxt'

export const useError = () => toRef(useNuxtApp().payload, 'error')

Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/hydrate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useNuxtApp } from '#app'
import { useNuxtApp } from '../nuxt'

/**
* Allows full control of the hydration cycle to set and receive data from the server.
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/payload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseURL, joinURL } from 'ufo'
import { useNuxtApp } from '../nuxt'
import { useHead } from '#app'
import { useHead } from '..'

interface LoadPayloadOptions {
fresh?: boolean
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/preload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Component } from 'vue'
import { useNuxtApp } from '#app'
import { useNuxtApp } from '../nuxt'

/**
* Preload a component or components that have been globally registered.
Expand Down
4 changes: 3 additions & 1 deletion packages/nuxt/src/app/composables/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { getCurrentInstance, inject } from 'vue'
import type { Router, RouteLocationNormalizedLoaded, NavigationGuard, RouteLocationNormalized, RouteLocationRaw, NavigationFailure, RouteLocationPathRaw } from 'vue-router'
import { sendRedirect } from 'h3'
import { hasProtocol, joinURL, parseURL } from 'ufo'
import { useNuxtApp, useRuntimeConfig, useState, createError, NuxtError } from '#app'
import { useNuxtApp, useRuntimeConfig } from '../nuxt'
import { createError, NuxtError } from './error'
import { useState } from './state'

export const useRouter = () => {
return useNuxtApp()?.$router as Router
Expand Down
3 changes: 1 addition & 2 deletions packages/nuxt/src/app/composables/ssr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-redeclare */
import type { CompatibilityEvent } from 'h3'
import { useNuxtApp } from '#app'
import { NuxtApp } from '#app/nuxt'
import { useNuxtApp, NuxtApp } from '../nuxt'

export function useRequestHeaders<K extends string = string> (include: K[]): Record<K, string | undefined>
export function useRequestHeaders (): Readonly<Record<string, string | undefined>>
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isRef, toRef } from 'vue'
import type { Ref } from 'vue'
import { useNuxtApp } from '#app'
import { useNuxtApp } from '../nuxt'

/**
* Create a global reactive ref that will be hydrated but not shared across ssr requests
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/test/nuxt-link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ vi.mock('vue', async () => {
})

// Mocks Nuxt `useRouter()`
vi.mock('#app', () => ({
vi.mock('../src/app/composables/router', () => ({
useRouter: () => ({ resolve: ({ to }: { to: string }) => ({ href: to }) })
}))

Expand Down