Skip to content

Commit daa8cca

Browse files
Merge branch 'main' into renovate/major-vitest-monorepo
2 parents d23acc2 + b20e980 commit daa8cca

5 files changed

Lines changed: 3 additions & 81 deletions

File tree

README.md

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ See [demo on CodeSandbox](https://codesandbox.io/s/github/nuxt-community/device-
1414
## Installation
1515

1616
```bash
17-
npx nuxi@latest module add device
17+
npx nuxt module add device
1818
```
1919

20-
> [!NOTE]
21-
> You can find the Nuxt 2 version of the module on the [`2.x` branch](https://github.com/nuxt-modules/device/tree/2.x).
22-
2320
## Flags
2421

2522
You can use the following flags to detect the device type:
@@ -84,17 +81,6 @@ definePageMeta({
8481
</script>
8582
```
8683

87-
<!-- ### Adding a Custom Flag
88-
89-
You can add other flags to `$device` by adding a [Nuxt plugin](https://nuxtjs.org/docs/2.x/directory-structure/plugins):
90-
91-
```js
92-
// plugins/custom-flag.js
93-
export default function ({ $device }) {
94-
$device.isCustom = $device.userAgent.includes('Custom-Agent') ? true : false
95-
}
96-
``` -->
97-
9884
### Options
9985

10086
#### `defaultUserAgent`
@@ -103,24 +89,6 @@ Sets the default value for the `user-agent` header (useful when running `npm run
10389

10490
Default: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36`
10591

106-
#### `enabled`
107-
108-
Enables the module conditionally.
109-
110-
Default: `true`
111-
112-
> [!WARNING]
113-
> This option is deprecated. It will be removed in the next major release.
114-
115-
#### `refreshOnResize`
116-
117-
Refreshes flags on window resize.
118-
119-
Default: `false`
120-
121-
> [!WARNING]
122-
> This option is deprecated. It will be removed in the next major release.
123-
12492
## Amazon CloudFront Support
12593

12694
If the user agent is `Amazon CloudFront`, the module checks for the following headers:

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
"description": "Device detection module for Nuxt",
55
"repository": {
66
"type": "git",
7-
"url": "git+https://github.com/nuxt-modules/device"
7+
"url": "git+https://github.com/nuxt-modules/device.git"
88
},
99
"license": "MIT",
10-
"author": "Shinji Yamada <dotneet@gmail.com>",
1110
"type": "module",
1211
"exports": {
1312
".": {

src/module.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defu } from 'defu'
2-
import { defineNuxtModule, addPlugin, addImportsDir, createResolver, useLogger, addTemplate } from '@nuxt/kit'
2+
import { defineNuxtModule, addPlugin, addImportsDir, createResolver, addTemplate } from '@nuxt/kit'
33
import crawlers from 'crawler-user-agents' with { type: 'json' }
44
import { name, version } from '../package.json'
55
import type { ModuleOptions } from './types'
@@ -14,26 +14,8 @@ export default defineNuxtModule<ModuleOptions>({
1414
version,
1515
},
1616
setup(options, nuxt) {
17-
if (typeof options.enabled === 'boolean' || typeof options.refreshOnResize === 'boolean') {
18-
const logger = useLogger('@nuxtjs/device')
19-
20-
if (typeof options.enabled === 'boolean') {
21-
logger.warn('\'enabled\' option is deprecated. It will be removed in the next major release.')
22-
}
23-
24-
if (typeof options.refreshOnResize === 'boolean') {
25-
logger.warn('\'refreshOnResize\' option is deprecated. It will be removed in the next major release.')
26-
}
27-
}
28-
29-
if (options.enabled === false) {
30-
return
31-
}
32-
3317
nuxt.options.runtimeConfig.public.device = defu(nuxt.options.runtimeConfig.public.device, {
3418
defaultUserAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36',
35-
enabled: true,
36-
refreshOnResize: false,
3719
})
3820

3921
const { resolve } = createResolver(import.meta.url)

src/runtime/plugin.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ export default defineNuxtPlugin(() => {
2020
const userAgent = navigator.userAgent || defaultUserAgent
2121

2222
flags = reactive(generateFlags(userAgent))
23-
24-
if (runtimeConfig.public.device.refreshOnResize) {
25-
window.addEventListener('resize', () => {
26-
setTimeout(() => {
27-
const newFlags = generateFlags(navigator.userAgent || userAgent)
28-
29-
Object.entries(newFlags).forEach(([key, value]) => {
30-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31-
(flags as any)[key] = value
32-
})
33-
}, 50)
34-
})
35-
}
3623
}
3724

3825
return {

src/types.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,6 @@ export interface ModuleOptions {
44
* @default 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36'
55
*/
66
defaultUserAgent?: string
7-
8-
/**
9-
* Enables the module conditionally.
10-
* @default true
11-
* @deprecated
12-
*/
13-
enabled?: boolean
14-
15-
/**
16-
* Refreshes flags on window resize.
17-
* @default false
18-
* @deprecated
19-
*/
20-
refreshOnResize?: boolean
217
}
228

239
declare module '@nuxt/schema' {

0 commit comments

Comments
 (0)