From 306174c4d81d2c29758332f5c99cf84008d23b18 Mon Sep 17 00:00:00 2001 From: Luke Nelson Date: Fri, 19 Apr 2024 15:58:19 +0100 Subject: [PATCH] docs: add `@since` annotations to exported functions (#25365) --- packages/kit/src/utils.ts | 1 + packages/nuxt/src/app/nuxt.ts | 10 ++++++++++ packages/nuxt/src/app/utils.ts | 1 + packages/nuxt/src/pages/runtime/utils.ts | 1 + packages/nuxt/src/utils.ts | 1 + packages/vite/src/utils/index.ts | 1 + packages/webpack/src/utils/index.ts | 1 + 7 files changed, 16 insertions(+) diff --git a/packages/kit/src/utils.ts b/packages/kit/src/utils.ts index 4cc2040ad9..72b096120b 100644 --- a/packages/kit/src/utils.ts +++ b/packages/kit/src/utils.ts @@ -1,3 +1,4 @@ +/** @since 3.9.0 */ export function toArray (value: T | T[]): T[] { return Array.isArray(value) ? value : [value] } diff --git a/packages/nuxt/src/app/nuxt.ts b/packages/nuxt/src/app/nuxt.ts index ef4735a338..bd35446756 100644 --- a/packages/nuxt/src/app/nuxt.ts +++ b/packages/nuxt/src/app/nuxt.ts @@ -233,6 +233,7 @@ export interface CreateOptions { globalName?: NuxtApp['globalName'] } +/** @since 3.0.0 */ export function createNuxtApp (options: CreateOptions) { let hydratingCount = 0 const nuxtApp: NuxtApp = { @@ -349,6 +350,7 @@ export function createNuxtApp (options: CreateOptions) { return nuxtApp } +/** @since 3.0.0 */ export async function applyPlugin (nuxtApp: NuxtApp, plugin: Plugin & ObjectPlugin) { if (plugin.hooks) { nuxtApp.hooks.addHooks(plugin.hooks) @@ -363,6 +365,7 @@ export async function applyPlugin (nuxtApp: NuxtApp, plugin: Plugin & ObjectPlug } } +/** @since 3.0.0 */ export async function applyPlugins (nuxtApp: NuxtApp, plugins: Array>) { const resolvedPlugins: string[] = [] const unresolvedPlugins: [Set, Plugin & ObjectPlugin][] = [] @@ -413,6 +416,7 @@ export async function applyPlugins (nuxtApp: NuxtApp, plugins: Array> (plugin: Plugin | ObjectPlugin): Plugin & ObjectPlugin { if (typeof plugin === 'function') { return plugin } @@ -425,6 +429,7 @@ export function defineNuxtPlugin> (plugin: Plu /* @__NO_SIDE_EFFECTS__ */ export const definePayloadPlugin = defineNuxtPlugin +/** @since 3.0.0 */ export function isNuxtPlugin (plugin: unknown) { return typeof plugin === 'function' && NuxtPluginIndicator in plugin } @@ -433,6 +438,7 @@ export function isNuxtPlugin (plugin: unknown) { * Ensures that the setup function passed in has access to the Nuxt instance via `useNuxtApp`. * @param nuxt A Nuxt instance * @param setup The function to call + * @since 3.0.0 */ export function callWithNuxt any> (nuxt: NuxtApp | _NuxtApp, setup: T, args?: Parameters) { const fn: () => ReturnType = () => args ? setup(...args as Parameters) : setup() @@ -450,6 +456,7 @@ export function callWithNuxt any> (nuxt: NuxtApp | * Returns the current Nuxt instance. * * Returns `null` if Nuxt instance is unavailable. + * @since 3.10.0 */ export function tryUseNuxtApp (): NuxtApp | null { let nuxtAppInstance @@ -467,6 +474,7 @@ export function tryUseNuxtApp (): NuxtApp | null { * Returns the current Nuxt instance. * * Throws an error if Nuxt instance is unavailable. + * @since 3.0.0 */ export function useNuxtApp (): NuxtApp { const nuxtAppInstance = tryUseNuxtApp() @@ -482,6 +490,7 @@ export function useNuxtApp (): NuxtApp { return nuxtAppInstance } +/** @since 3.0.0 */ /* @__NO_SIDE_EFFECTS__ */ export function useRuntimeConfig (_event?: H3Event): RuntimeConfig { return useNuxtApp().$config @@ -491,6 +500,7 @@ function defineGetter (obj: Record, Object.defineProperty(obj, key, { get: () => val }) } +/** @since 3.0.0 */ export function defineAppConfig (config: C): C { return config } diff --git a/packages/nuxt/src/app/utils.ts b/packages/nuxt/src/app/utils.ts index 4cc2040ad9..72b096120b 100644 --- a/packages/nuxt/src/app/utils.ts +++ b/packages/nuxt/src/app/utils.ts @@ -1,3 +1,4 @@ +/** @since 3.9.0 */ export function toArray (value: T | T[]): T[] { return Array.isArray(value) ? value : [value] } diff --git a/packages/nuxt/src/pages/runtime/utils.ts b/packages/nuxt/src/pages/runtime/utils.ts index 3a16247191..e9566b971d 100644 --- a/packages/nuxt/src/pages/runtime/utils.ts +++ b/packages/nuxt/src/pages/runtime/utils.ts @@ -22,6 +22,7 @@ export const wrapInKeepAlive = (props: any, children: any) => { return { default: () => import.meta.client && props ? h(KeepAlive, props === true ? {} : props, children) : children } } +/** @since 3.9.0 */ export function toArray (value: T | T[]): T[] { return Array.isArray(value) ? value : [value] } diff --git a/packages/nuxt/src/utils.ts b/packages/nuxt/src/utils.ts index d56642dc25..03fd928135 100644 --- a/packages/nuxt/src/utils.ts +++ b/packages/nuxt/src/utils.ts @@ -1,5 +1,6 @@ import { promises as fsp } from 'node:fs' +/** @since 3.9.0 */ export function toArray (value: T | T[]): T[] { return Array.isArray(value) ? value : [value] } diff --git a/packages/vite/src/utils/index.ts b/packages/vite/src/utils/index.ts index 0feb1b5ca5..55e17df086 100644 --- a/packages/vite/src/utils/index.ts +++ b/packages/vite/src/utils/index.ts @@ -27,6 +27,7 @@ export function matchWithStringOrRegex (value: string, matcher: string | RegExp) return false } +/** @since 3.9.0 */ export function toArray (value: T | T[]): T[] { return Array.isArray(value) ? value : [value] } diff --git a/packages/webpack/src/utils/index.ts b/packages/webpack/src/utils/index.ts index 4cc2040ad9..72b096120b 100644 --- a/packages/webpack/src/utils/index.ts +++ b/packages/webpack/src/utils/index.ts @@ -1,3 +1,4 @@ +/** @since 3.9.0 */ export function toArray (value: T | T[]): T[] { return Array.isArray(value) ? value : [value] }