Skip to content

Commit 7b64ac6

Browse files
committed
feat: deprecate enabled option
1 parent eca8ff1 commit 7b64ac6

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/module.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,32 @@ export default defineNuxtModule<ModuleOptions>({
1414
version,
1515
},
1616
setup(options, nuxt) {
17-
if (typeof options.refreshOnResize === 'boolean') {
17+
if (typeof options.enabled === 'boolean' || typeof options.refreshOnResize === 'boolean') {
1818
const logger = useLogger('@nuxtjs/device')
1919

20-
logger.warn('\'refreshOnResize\' option is deprecated. It will be removed in the next major release.')
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+
}
2127
}
2228

23-
if (!options.enabled) {
29+
if (options.enabled === false) {
2430
return
2531
}
2632

2733
nuxt.options.runtimeConfig.public.device = defu(nuxt.options.runtimeConfig.public.device, {
28-
enabled: true,
2934
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,
3036
refreshOnResize: false,
3137
})
3238

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

35-
addPlugin(resolve('runtime/plugin'))
41+
addPlugin(resolve('./runtime/plugin'))
3642

37-
addImportsDir(resolve('runtime/composables'))
43+
addImportsDir(resolve('./runtime/composables'))
3844
},
3945
})

src/types.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
export interface ModuleOptions {
2-
/**
3-
* Whether to enable the module conditionally.
4-
* @default true
5-
*/
6-
enabled?: boolean
7-
82
/**
93
* Device Module Default User Agent
104
* @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'
115
*/
126
defaultUserAgent?: string
137

8+
/**
9+
* Whether to enable the module conditionally.
10+
* @default true
11+
* @deprecated
12+
*/
13+
enabled?: boolean
14+
1415
/**
1516
* Refresh Device Module Values On Window Resize
1617
* @default false
@@ -41,6 +42,6 @@ export type Device = {
4142

4243
declare module '@nuxt/schema' {
4344
interface PublicRuntimeConfig {
44-
device: ModuleOptions
45+
device: Required<ModuleOptions>
4546
}
4647
}

0 commit comments

Comments
 (0)