From 9b09d57c04f2734976d6bd166c7232e6dad019cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yae=CC=88l=20GUILLOUX?= Date: Mon, 10 May 2021 20:43:58 +0200 Subject: [PATCH] :label: (types) move docus runtime instance into src/types --- src/core/runtime/docus.ts | 15 +++++---------- src/types/core.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/core/runtime/docus.ts b/src/core/runtime/docus.ts index 685430f1b..a72d354d1 100644 --- a/src/core/runtime/docus.ts +++ b/src/core/runtime/docus.ts @@ -1,6 +1,5 @@ -import { reactive, Ref, toRefs } from '@nuxtjs/composition-api' -import type { DefaultThemeSettings } from '../../defaultTheme' -import { DocusSettings, PermissiveContext, DocusState, DocusAddonContext, DocusNavigation } from '../../types' +import { reactive, toRefs } from '@nuxtjs/composition-api' +import { DocusSettings, PermissiveContext, DocusState, DocusAddonContext, DocusRuntimeInstance } from '../../types' import { useDocusApi } from './composables/api' import { useDocusNavigation } from './composables/navigation' import { clientAsyncData, docusInit } from './composables/helpers' @@ -9,13 +8,6 @@ import { useDocusReleases } from './composables/releases' import { useDocusStyle } from './composables/style' import { useDocusAddons } from './composables/addons' -export type DocusRuntimeInstance = { - settings: Ref> - navigation: Ref - theme: Ref - [key: string]: any -} & ReturnType - let docusInstance: DocusRuntimeInstance /** @@ -29,6 +21,8 @@ export const createDocus = async ( // Nuxt instance proxy let $nuxt: any + const { ssrContext } = context + // State const state = reactive({ settings: null, @@ -45,6 +39,7 @@ export const createDocus = async ( // Create Docus Addons context const docusAddonContext: DocusAddonContext = { + ssrContext, $nuxt, context, state, diff --git a/src/types/core.ts b/src/types/core.ts index c7b59743f..88608e8ac 100644 --- a/src/types/core.ts +++ b/src/types/core.ts @@ -1,4 +1,5 @@ import { Context } from '@nuxt/types' +import { Ref } from '@nuxtjs/composition-api' import { MetaInfo } from 'vue-meta' import { useDocusApi } from '../core/runtime/composables/api' import { DefaultThemeSettings } from '../defaultTheme/index.d' @@ -106,6 +107,7 @@ export interface DocusSettings { } export interface DocusAddonContext { + ssrContext: Context['ssrContext'] context: PermissiveContext state: DocusState settings: DocusSettings @@ -113,6 +115,12 @@ export interface DocusAddonContext { api: ReturnType $nuxt?: any } +export type DocusRuntimeInstance = { + settings: Ref> + navigation: Ref + theme: Ref + [key: string]: any +} & ReturnType export interface Colors { [key: string]: string | Colors