2021-10-06 12:37:45 +00:00
|
|
|
import Vue from 'vue'
|
2021-09-25 08:24:37 +00:00
|
|
|
import { createHooks } from 'hookable/dist/index.mjs'
|
|
|
|
import { setNuxtInstance } from '#app'
|
|
|
|
|
|
|
|
export default (ctx, inject) => {
|
|
|
|
const nuxt = {
|
2021-10-06 12:37:45 +00:00
|
|
|
app: {
|
|
|
|
component: Vue.component.bind(Vue),
|
|
|
|
config: {
|
|
|
|
globalProperties: {}
|
|
|
|
},
|
|
|
|
directive: Vue.directive.bind(Vue),
|
|
|
|
mixin: Vue.mixin.bind(Vue),
|
|
|
|
mount: () => {},
|
|
|
|
provide: inject,
|
|
|
|
unmount: () => {},
|
|
|
|
use (vuePlugin) {
|
|
|
|
vuePlugin.install(this)
|
|
|
|
},
|
|
|
|
version: Vue.version
|
|
|
|
},
|
2021-09-25 08:24:37 +00:00
|
|
|
provide: inject,
|
|
|
|
globalName: 'nuxt',
|
|
|
|
payload: process.client ? ctx.nuxtState : ctx.ssrContext.nuxt,
|
|
|
|
isHydrating: ctx.isHMR,
|
|
|
|
legacyNuxt: ctx.app
|
|
|
|
}
|
2021-10-06 12:37:45 +00:00
|
|
|
|
2021-09-25 08:24:37 +00:00
|
|
|
nuxt.hooks = createHooks()
|
|
|
|
nuxt.hook = nuxt.hooks.hook
|
|
|
|
nuxt.callHook = nuxt.hooks.callHook
|
|
|
|
|
|
|
|
if (!Array.isArray(ctx.app.created)) {
|
|
|
|
ctx.app.created = [ctx.app.created]
|
|
|
|
}
|
|
|
|
|
2021-10-06 12:37:45 +00:00
|
|
|
if (process.server) {
|
|
|
|
nuxt.ssrContext = ctx.ssrContext
|
|
|
|
}
|
|
|
|
|
2021-09-25 08:24:37 +00:00
|
|
|
ctx.app.created.push(function () {
|
|
|
|
nuxt.legacyApp = this
|
|
|
|
})
|
|
|
|
|
|
|
|
setNuxtInstance(nuxt)
|
|
|
|
|
|
|
|
inject('_nuxtApp', nuxt)
|
|
|
|
}
|