Skip to content

Commit

Permalink
feat: expose font types from @nuxt/fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 9, 2024
1 parent e4e8b0e commit a824bed
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
3 changes: 1 addition & 2 deletions playground/providers/custom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TODO: expose types publicly
import type { FontProvider } from '../../src/types'
import type { FontProvider } from '@nuxt/fonts'

const resolvableFonts = new Set<string>()
export default {
Expand Down
22 changes: 16 additions & 6 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ import { FontFamilyInjectionPlugin, type FontFaceResolution } from './plugins/tr
import { generateFontFace } from './css/render'
import type { GenericCSSFamily } from './css/parse'
import { setupPublicAssetStrategy } from './assets'
import type { FontFamilyManualOverride, FontFamilyProviderOverride, FontProvider, ModuleOptions } from './types'
import type { FontFamilyManualOverride, FontFamilyProviderOverride, FontProvider, ModuleHooks, ModuleOptions } from './types'
import { logger } from './logger'

export type { ModuleOptions } from './types'
export type {
FontProvider,
FontFaceData,
FontFallback,
FontFamilyManualOverride,
FontFamilyOverrides,
FontFamilyProviderOverride,
FontProviderName,
NormalizedFontFaceData,
ResolveFontFacesOptions,
LocalFontSource,
RemoteFontSource,
FontSource,
ModuleOptions
} from './types'

const defaultValues = {
weights: [400],
Expand Down Expand Up @@ -222,10 +236,6 @@ async function resolveProviders (_providers: ModuleOptions['providers'] = {}) {
return providers as Record<string, FontProvider>
}

export interface ModuleHooks {
'fonts:providers': (providers: FontProvider) => void | Promise<void>
}

declare module '@nuxt/schema' {
interface NuxtHooks extends ModuleHooks {}
}
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,7 @@ export interface ModuleOptions {
// TODO: support default provider
// provider?: FontProviderName
}

export interface ModuleHooks {
'fonts:providers': (providers: FontProvider) => void | Promise<void>
}

0 comments on commit a824bed

Please sign in to comment.