Skip to content

Commit 57a658a

Browse files
committed
fix: move runtime types to src/runtime/ dir
1 parent 5ef111d commit 57a658a

File tree

5 files changed

+34
-35
lines changed

5 files changed

+34
-35
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Device } from '../../types'
1+
import type { Device } from '../types'
22
import { useNuxtApp } from '#imports'
33

44
export const useDevice = (): Device => useNuxtApp().$device

src/runtime/generateFlags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import crawlers from 'crawler-user-agents'
2-
import type { Device } from '../types'
2+
import type { Device } from './types'
33

44
// eslint-disable-next-line
55
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

src/runtime/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Device } from '../types'
1+
import type { Device } from './types'
22
import generateFlags from './generateFlags'
33
import { defineNuxtPlugin, reactive, useRequestHeaders, useRuntimeConfig } from '#imports'
44

src/runtime/types.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export type Device = {
2+
userAgent: string
3+
isDesktop: boolean
4+
isIos: boolean
5+
isAndroid: boolean
6+
isMobile: boolean
7+
isMobileOrTablet: boolean
8+
isDesktopOrTablet: boolean
9+
isTablet: boolean
10+
isWindows: boolean
11+
isMacOS: boolean
12+
isApple: boolean
13+
isSafari: boolean
14+
isFirefox: boolean
15+
isEdge: boolean
16+
isChrome: boolean
17+
isSamsung: boolean
18+
isCrawler: boolean
19+
}
20+
21+
declare module '#app' {
22+
interface NuxtApp {
23+
$device: Device
24+
}
25+
}
26+
27+
declare module 'vue' {
28+
interface ComponentCustomProperties {
29+
$device: Device
30+
}
31+
}

src/types.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,8 @@ export interface ModuleOptions {
2020
refreshOnResize?: boolean
2121
}
2222

23-
export type Device = {
24-
userAgent: string
25-
isDesktop: boolean
26-
isIos: boolean
27-
isAndroid: boolean
28-
isMobile: boolean
29-
isMobileOrTablet: boolean
30-
isDesktopOrTablet: boolean
31-
isTablet: boolean
32-
isWindows: boolean
33-
isMacOS: boolean
34-
isApple: boolean
35-
isSafari: boolean
36-
isFirefox: boolean
37-
isEdge: boolean
38-
isChrome: boolean
39-
isSamsung: boolean
40-
isCrawler: boolean
41-
}
42-
4323
declare module '@nuxt/schema' {
4424
interface PublicRuntimeConfig {
4525
device: Required<ModuleOptions>
4626
}
4727
}
48-
49-
declare module '#app' {
50-
interface NuxtApp {
51-
$device: Device
52-
}
53-
}
54-
55-
declare module 'vue' {
56-
interface ComponentCustomProperties {
57-
$device: Device
58-
}
59-
}

0 commit comments

Comments
 (0)