Skip to content

Commit

Permalink
fix: move runtime types to src/runtime/ dir
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianGlowala committed Aug 29, 2024
1 parent 5ef111d commit 57a658a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/runtime/composables/useDevice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Device } from '../../types'
import type { Device } from '../types'
import { useNuxtApp } from '#imports'

export const useDevice = (): Device => useNuxtApp().$device
2 changes: 1 addition & 1 deletion src/runtime/generateFlags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import crawlers from 'crawler-user-agents'
import type { Device } from '../types'
import type { Device } from './types'

// eslint-disable-next-line
const REGEX_MOBILE1 = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|FBAN|FBAV|fennec|hiptop|iemobile|ip(hone|od)|Instagram|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Device } from '../types'
import type { Device } from './types'
import generateFlags from './generateFlags'
import { defineNuxtPlugin, reactive, useRequestHeaders, useRuntimeConfig } from '#imports'

Expand Down
31 changes: 31 additions & 0 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export type Device = {
userAgent: string
isDesktop: boolean
isIos: boolean
isAndroid: boolean
isMobile: boolean
isMobileOrTablet: boolean
isDesktopOrTablet: boolean
isTablet: boolean
isWindows: boolean
isMacOS: boolean
isApple: boolean
isSafari: boolean
isFirefox: boolean
isEdge: boolean
isChrome: boolean
isSamsung: boolean
isCrawler: boolean
}

declare module '#app' {
interface NuxtApp {
$device: Device
}
}

declare module 'vue' {
interface ComponentCustomProperties {
$device: Device
}
}
32 changes: 0 additions & 32 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,8 @@ export interface ModuleOptions {
refreshOnResize?: boolean
}

export type Device = {
userAgent: string
isDesktop: boolean
isIos: boolean
isAndroid: boolean
isMobile: boolean
isMobileOrTablet: boolean
isDesktopOrTablet: boolean
isTablet: boolean
isWindows: boolean
isMacOS: boolean
isApple: boolean
isSafari: boolean
isFirefox: boolean
isEdge: boolean
isChrome: boolean
isSamsung: boolean
isCrawler: boolean
}

declare module '@nuxt/schema' {
interface PublicRuntimeConfig {
device: Required<ModuleOptions>
}
}

declare module '#app' {
interface NuxtApp {
$device: Device
}
}

declare module 'vue' {
interface ComponentCustomProperties {
$device: Device
}
}

0 comments on commit 57a658a

Please sign in to comment.