Merge branch 'main' into patch-21

This commit is contained in:
Michael Brevard 2024-04-09 21:49:35 +03:00 committed by GitHub
commit 2fa63ccfff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 303 additions and 137 deletions

View File

@ -117,7 +117,7 @@ export default defineNuxtPlugin({
### Plugins With Dependencies
If a plugin needs to await a parallel plugin before it runs, you can add the plugin's name to the `dependsOn` array.
If a plugin needs to wait for another plugin before it runs, you can add the plugin's name to the `dependsOn` array.
```ts twoslash [plugins/depending-on-my-plugin.ts]
export default defineNuxtPlugin({

View File

@ -45,14 +45,14 @@
},
"devDependencies": {
"@eslint/js": "9.0.0",
"@nuxt/eslint-config": "0.3.1",
"@nuxt/eslint-config": "0.3.4",
"@nuxt/kit": "workspace:*",
"@nuxt/test-utils": "3.12.0",
"@nuxt/webpack-builder": "workspace:*",
"@testing-library/vue": "8.0.3",
"@types/eslint__js": "8.42.3",
"@types/fs-extra": "11.0.4",
"@types/node": "20.12.5",
"@types/node": "20.12.6",
"@types/semver": "7.5.8",
"@vitest/coverage-v8": "1.4.0",
"@vue/test-utils": "2.4.5",
@ -63,7 +63,7 @@
"eslint": "9.0.0",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint-plugin-perfectionist": "2.8.0",
"eslint-typegen": "0.2.0",
"eslint-typegen": "0.2.2",
"execa": "8.0.1",
"fs-extra": "11.2.0",
"globby": "14.0.1",

View File

@ -36,6 +36,8 @@ export type KeyOfRes<Transform extends _Transform> = KeysOf<ReturnType<Transform
export type MultiWatchSources = (WatchSource<unknown> | object)[]
export type NoInfer<T> = [T][T extends any ? 0 : never]
export interface AsyncDataOptions<
ResT,
DataT = ResT,
@ -61,7 +63,7 @@ export interface AsyncDataOptions<
* A `null` or `undefined` return value will trigger a fetch.
* Default is `key => nuxt.isHydrating ? nuxt.payload.data[key] : nuxt.static.data[key]` which only caches data when payloadExtraction is enabled.
*/
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT
getCachedData?: (key: string, nuxtApp: NuxtApp) => NoInfer<DataT>
/**
* A function that can be used to alter handler function result after resolving.
* Do not use it along with the `pick` option.

View File

@ -2,9 +2,9 @@ import { getRequestURL } from 'h3'
import { useRequestEvent } from './ssr'
/** @since 3.5.0 */
export function useRequestURL () {
export function useRequestURL (opts?: Parameters<typeof getRequestURL>[1]) {
if (import.meta.server) {
return getRequestURL(useRequestEvent()!)
return getRequestURL(useRequestEvent()!, opts)
}
return new URL(window.location.href)
}

View File

@ -17,6 +17,7 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
},
defaults: {
autoImport: true,
scan: true,
presets: defaultPresets,
global: false,
imports: [],
@ -51,31 +52,37 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
// composables/ dirs from all layers
let composablesDirs: string[] = []
for (const layer of nuxt.options._layers) {
composablesDirs.push(resolve(layer.config.srcDir, 'composables'))
composablesDirs.push(resolve(layer.config.srcDir, 'utils'))
for (const dir of (layer.config.imports?.dirs ?? [])) {
if (!dir) {
if (options.scan) {
for (const layer of nuxt.options._layers) {
// Layer disabled scanning for itself
if (layer.config?.imports?.scan === false) {
continue
}
composablesDirs.push(resolve(layer.config.srcDir, dir))
composablesDirs.push(resolve(layer.config.srcDir, 'composables'))
composablesDirs.push(resolve(layer.config.srcDir, 'utils'))
for (const dir of (layer.config.imports?.dirs ?? [])) {
if (!dir) {
continue
}
composablesDirs.push(resolve(layer.config.srcDir, dir))
}
}
await nuxt.callHook('imports:dirs', composablesDirs)
composablesDirs = composablesDirs.map(dir => normalize(dir))
// Restart nuxt when composable directories are added/removed
nuxt.hook('builder:watch', (event, relativePath) => {
if (!['addDir', 'unlinkDir'].includes(event)) { return }
const path = resolve(nuxt.options.srcDir, relativePath)
if (composablesDirs.includes(path)) {
logger.info(`Directory \`${relativePath}/\` ${event === 'addDir' ? 'created' : 'removed'}`)
return nuxt.callHook('restart')
}
})
}
await nuxt.callHook('imports:dirs', composablesDirs)
composablesDirs = composablesDirs.map(dir => normalize(dir))
// Restart nuxt when composable directories are added/removed
nuxt.hook('builder:watch', (event, relativePath) => {
if (!['addDir', 'unlinkDir'].includes(event)) { return }
const path = resolve(nuxt.options.srcDir, relativePath)
if (composablesDirs.includes(path)) {
logger.info(`Directory \`${relativePath}/\` ${event === 'addDir' ? 'created' : 'removed'}`)
return nuxt.callHook('restart')
}
})
// Support for importing from '#imports'
addTemplate({
filename: 'imports.mjs',
@ -101,14 +108,18 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
await ctx.modifyDynamicImports(async (imports) => {
// Clear old imports
imports.length = 0
// Scan `composables/`
const composableImports = await scanDirExports(composablesDirs, {
fileFilter: file => !isIgnored(file),
})
for (const i of composableImports) {
i.priority = i.priority || priorities.find(([dir]) => i.from.startsWith(dir))?.[1]
// Scan for `composables/` and `utils/` directories
if (options.scan) {
const scannedImports = await scanDirExports(composablesDirs, {
fileFilter: file => !isIgnored(file),
})
for (const i of scannedImports) {
i.priority = i.priority || priorities.find(([dir]) => i.from.startsWith(dir))?.[1]
}
imports.push(...scannedImports)
}
imports.push(...composableImports)
// Modules extending
await nuxt.callHook('imports:extend', imports)
return imports
@ -127,7 +138,7 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
// Watch composables/ directory
nuxt.hook('builder:watch', async (_, relativePath) => {
const path = resolve(nuxt.options.srcDir, relativePath)
if (composablesDirs.some(dir => dir === path || path.startsWith(dir + '/'))) {
if (options.scan && composablesDirs.some(dir => dir === path || path.startsWith(dir + '/'))) {
await regenerateImports()
}
})

View File

@ -15,6 +15,13 @@ export interface ImportsOptions extends UnimportOptions {
*/
dirs?: string[]
/**
* Enabled scan for local directories for auto imports.
* When this is disabled, `dirs` options will be ignored.
* @default true
*/
scan?: boolean
/**
* Assign auto imported utilities to `globalThis` instead of using built time transformation.
* @default false

View File

@ -28,7 +28,7 @@
"@nuxt/friendly-errors-webpack-plugin": "^2.6.0",
"@nuxt/kit": "workspace:*",
"autoprefixer": "^10.4.19",
"css-loader": "^7.0.0",
"css-loader": "^7.1.0",
"css-minimizer-webpack-plugin": "^6.0.0",
"cssnano": "^6.1.2",
"defu": "^6.1.4",

View File

@ -23,8 +23,8 @@ importers:
specifier: 9.0.0
version: 9.0.0
'@nuxt/eslint-config':
specifier: 0.3.1
version: 0.3.1(eslint@9.0.0)(typescript@5.4.4)
specifier: 0.3.4
version: 0.3.4(eslint@9.0.0)(typescript@5.4.4)
'@nuxt/kit':
specifier: workspace:*
version: link:packages/kit
@ -44,8 +44,8 @@ importers:
specifier: 11.0.4
version: 11.0.4
'@types/node':
specifier: 20.12.5
version: 20.12.5
specifier: 20.12.6
version: 20.12.6
'@types/semver':
specifier: 7.5.8
version: 7.5.8
@ -77,8 +77,8 @@ importers:
specifier: 2.8.0
version: 2.8.0(eslint@9.0.0)(typescript@5.4.4)
eslint-typegen:
specifier: 0.2.0
version: 0.2.0
specifier: 0.2.2
version: 0.2.2(eslint@9.0.0)
execa:
specifier: 8.0.1
version: 8.0.1
@ -138,7 +138,7 @@ importers:
version: 1.5.3
vitest:
specifier: 1.4.0
version: 1.4.0(@types/node@20.12.5)(happy-dom@14.7.1)
version: 1.4.0(@types/node@20.12.6)(happy-dom@14.7.1)
vitest-environment-nuxt:
specifier: 1.0.0
version: 1.0.0(@testing-library/vue@8.0.3)(@vue/test-utils@2.4.5)(h3@1.11.1)(happy-dom@14.7.1)(playwright-core@1.43.0)(vite@5.2.8)(vitest@1.4.0)(vue-router@4.3.0)(vue@3.4.21)
@ -229,10 +229,10 @@ importers:
version: 2.0.0(typescript@5.4.4)
vite:
specifier: 5.2.8
version: 5.2.8(@types/node@20.12.5)
version: 5.2.8(@types/node@20.12.6)
vitest:
specifier: 1.4.0
version: 1.4.0(@types/node@20.12.5)(happy-dom@14.7.1)
version: 1.4.0(@types/node@20.12.6)(happy-dom@14.7.1)
webpack:
specifier: 5.91.0
version: 5.91.0
@ -528,7 +528,7 @@ importers:
version: 1.9.0
vite:
specifier: 5.2.8
version: 5.2.8(@types/node@20.12.5)
version: 5.2.8(@types/node@20.12.6)
vue:
specifier: 3.4.21
version: 3.4.21(typescript@5.4.4)
@ -642,10 +642,10 @@ importers:
version: 1.10.1
vite:
specifier: 5.2.8
version: 5.2.8(@types/node@20.12.5)
version: 5.2.8(@types/node@20.12.6)
vite-node:
specifier: ^1.4.0
version: 1.4.0(@types/node@20.12.5)
version: 1.4.0(@types/node@20.12.6)
vite-plugin-checker:
specifier: ^0.6.4
version: 0.6.4(eslint@9.0.0)(typescript@5.4.4)(vite@5.2.8)(vue-tsc@2.0.11)
@ -684,8 +684,8 @@ importers:
specifier: ^10.4.19
version: 10.4.19(postcss@8.4.38)
css-loader:
specifier: ^7.0.0
version: 7.0.0(webpack@5.91.0)
specifier: ^7.1.0
version: 7.1.0(webpack@5.91.0)
css-minimizer-webpack-plugin:
specifier: ^6.0.0
version: 6.0.0(webpack@5.91.0)
@ -871,7 +871,7 @@ importers:
version: 1.3.4
vitest:
specifier: 1.0.2
version: 1.0.2(@types/node@20.12.5)(happy-dom@14.7.1)
version: 1.0.2(@types/node@20.12.6)(happy-dom@14.7.1)
vue:
specifier: 3.4.21
version: 3.4.21(typescript@5.4.4)
@ -1908,6 +1908,11 @@ packages:
eslint: 9.0.0
eslint-visitor-keys: 3.4.3
/@eslint-community/regexpp@4.10.0:
resolution: {integrity: sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
dev: true
/@eslint-community/regexpp@4.9.1:
resolution: {integrity: sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
@ -2033,7 +2038,7 @@ packages:
'@jest/schemas': 29.6.3
'@types/istanbul-lib-coverage': 2.0.5
'@types/istanbul-reports': 3.0.3
'@types/node': 20.12.5
'@types/node': 20.12.6
'@types/yargs': 17.0.28
chalk: 4.1.2
dev: false
@ -2311,24 +2316,24 @@ packages:
- vue
dev: false
/@nuxt/eslint-config@0.3.1(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-+dCRPXbq+/uB7cZn3HnhaVOyte1t21YHvtMj9MRa0ekAbY/G73DQztPVAnyh6yWaV1RtwvDBN6pf3o1SRRNbyg==}
/@nuxt/eslint-config@0.3.4(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-O5Tpf4znp3n/GRP/8nBiHgdecJewdsweiat0OAkbcItxiioogQJ+VgUSNOsq5EHznJkX7umLQCeEOXd1YeKgvg==}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
dependencies:
'@eslint/js': 9.0.0
'@nuxt/eslint-plugin': 0.3.1(eslint@9.0.0)(typescript@5.4.4)
'@nuxt/eslint-plugin': 0.3.4(eslint@9.0.0)(typescript@5.4.4)
'@rushstack/eslint-patch': 1.10.1
'@stylistic/eslint-plugin': 1.7.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/eslint-plugin': 7.5.0(@typescript-eslint/parser@7.5.0)(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/parser': 7.5.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/eslint-plugin': 7.6.0(@typescript-eslint/parser@7.6.0)(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/parser': 7.6.0(eslint@9.0.0)(typescript@5.4.4)
eslint: 9.0.0
eslint-config-flat-gitignore: 0.1.5
eslint-flat-config-utils: 0.2.1
eslint-plugin-import-x: 0.5.0(eslint@9.0.0)(typescript@5.4.4)
eslint-plugin-jsdoc: 48.2.3(eslint@9.0.0)
eslint-plugin-unicorn: 52.0.0(eslint@9.0.0)
eslint-plugin-vue: 9.24.0(eslint@9.0.0)
eslint-plugin-vue: 9.24.1(eslint@9.0.0)
globals: 15.0.0
pathe: 1.1.2
tslib: 2.6.2
@ -2338,13 +2343,13 @@ packages:
- typescript
dev: true
/@nuxt/eslint-plugin@0.3.1(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-TflfVtPm2KNaa/jWCiffpiiiOJVDoS8oE2vAHdbu4BAPWmjonde4DCfrKbaEG4tUVnaOkGio3S1hkNmXllye4w==}
/@nuxt/eslint-plugin@0.3.4(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-WqGnD7aJCS43dMlnhKfTKoJrglLz+vIFfSUmCrdRXHXnhHV/o6YGvm18VHjshZNFXVm2x3/NqYn2vPrj5AGjuA==}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
dependencies:
'@typescript-eslint/types': 7.5.0
'@typescript-eslint/utils': 7.5.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/types': 7.6.0
'@typescript-eslint/utils': 7.6.0(eslint@9.0.0)(typescript@5.4.4)
eslint: 9.0.0
transitivePeerDependencies:
- supports-color
@ -2453,8 +2458,8 @@ packages:
ufo: 1.5.3
unenv: 1.9.0
unplugin: 1.10.1
vite: 5.2.8(@types/node@20.12.5)
vitest: 1.4.0(@types/node@20.12.5)(happy-dom@14.7.1)
vite: 5.2.8(@types/node@20.12.6)
vitest: 1.4.0(@types/node@20.12.6)(happy-dom@14.7.1)
vitest-environment-nuxt: 1.0.0(@testing-library/vue@8.0.3)(@vue/test-utils@2.4.5)(h3@1.11.1)(happy-dom@14.7.1)(playwright-core@1.43.0)(vite@5.2.8)(vitest@1.4.0)(vue-router@4.3.0)(vue@3.4.21)
vue: 3.4.21(typescript@5.4.4)
vue-router: 4.3.0(vue@3.4.21)
@ -3100,7 +3105,7 @@ packages:
engines: {node: ^16.14.0 || >=18.0.0}
dependencies:
'@tufjs/canonical-json': 2.0.0
minimatch: 9.0.3
minimatch: 9.0.4
dev: false
/@types/aria-query@5.0.4:
@ -3114,7 +3119,7 @@ packages:
/@types/connect@3.4.37:
resolution: {integrity: sha512-zBUSRqkfZ59OcwXon4HVxhx5oWCJmc0OtBTK05M+p0dYjgN6iTwIL2T/WbsQZrEsdnwaF9cWQ+azOnpPvIqY3Q==}
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
dev: true
/@types/debug@4.1.12:
@ -3170,7 +3175,7 @@ packages:
/@types/http-proxy@1.17.14:
resolution: {integrity: sha512-SSrD0c1OQzlFX7pGu1eXxSEjemej64aaNPRhhVYUGqXh0BtldAAx37MG8btcumvpgKyZp1F5Gn3JkktdxiFv6w==}
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
/@types/istanbul-lib-coverage@2.0.5:
resolution: {integrity: sha512-zONci81DZYCZjiLe0r6equvZut0b+dBRPBN5kBDjsONnutYNtJMoWQ9uR2RkL1gLG9NMTzvf+29e5RFfPbeKhQ==}
@ -3193,7 +3198,7 @@ packages:
/@types/jsonfile@6.1.2:
resolution: {integrity: sha512-8t92P+oeW4d/CRQfJaSqEwXujrhH4OEeHRjGU3v1Q8mUS8GPF3yiX26sw4svv6faL2HfBtGTe2xWIoVgN3dy9w==}
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
dev: true
/@types/lodash-es@4.17.12:
@ -3219,7 +3224,7 @@ packages:
/@types/node-sass@4.11.6:
resolution: {integrity: sha512-Qkf5Fs9zzsXchenUY7oVdIHyv8FtPgqIXqOJzhh3FDqpYjqvc/gtZ3hlZVFmKQhl7wyI4+WkRbYufYC5pfY7iw==}
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
dev: true
/@types/node@20.12.5:
@ -3227,6 +3232,11 @@ packages:
dependencies:
undici-types: 5.26.5
/@types/node@20.12.6:
resolution: {integrity: sha512-3KurE8taB8GCvZBPngVbp0lk5CKi8M9f9k1rsADh0Evdz5SzJ+Q+Hx9uHoFGsLnLnd1xmkDQr2hVhlA0Mn0lKQ==}
dependencies:
undici-types: 5.26.5
/@types/normalize-package-data@2.4.4:
resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==}
dev: true
@ -3310,7 +3320,7 @@ packages:
/@types/webpack-sources@3.2.1:
resolution: {integrity: sha512-iLC3Fsx62ejm3ST3PQ8vBMC54Rb3EoCprZjeJGI5q+9QjfDLGt9jeg/k245qz1G9AQnORGk0vqPicJFPT1QODQ==}
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
'@types/source-list-map': 0.1.4
source-map: 0.7.4
dev: true
@ -3325,7 +3335,7 @@ packages:
/@types/webpack@4.41.34:
resolution: {integrity: sha512-CN2aOGrR3zbMc2v+cKqzaClYP1ldkpPOgtdNvgX+RmlWCSWxHxpzz6WSCVQZRkF8D60ROlkRzAoEpgjWQ+bd2g==}
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
'@types/tapable': 1.0.10
'@types/uglify-js': 3.17.3
'@types/webpack-sources': 3.2.1
@ -3343,8 +3353,8 @@ packages:
'@types/yargs-parser': 21.0.1
dev: false
/@typescript-eslint/eslint-plugin@7.5.0(@typescript-eslint/parser@7.5.0)(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-HpqNTH8Du34nLxbKgVMGljZMG0rJd2O9ecvr2QLYp+7512ty1j42KnsFwspPXg1Vh8an9YImf6CokUBltisZFQ==}
/@typescript-eslint/eslint-plugin@7.6.0(@typescript-eslint/parser@7.6.0)(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-gKmTNwZnblUdnTIJu3e9kmeRRzV2j1a/LUO27KNNAnIC5zjy1aSvXSRp4rVNlmAoHlQ7HzX42NbKpcSr4jF80A==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
'@typescript-eslint/parser': ^7.0.0
@ -3354,26 +3364,26 @@ packages:
typescript:
optional: true
dependencies:
'@eslint-community/regexpp': 4.9.1
'@typescript-eslint/parser': 7.5.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/scope-manager': 7.5.0
'@typescript-eslint/type-utils': 7.5.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/utils': 7.5.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/visitor-keys': 7.5.0
'@eslint-community/regexpp': 4.10.0
'@typescript-eslint/parser': 7.6.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/scope-manager': 7.6.0
'@typescript-eslint/type-utils': 7.6.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/utils': 7.6.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/visitor-keys': 7.6.0
debug: 4.3.4
eslint: 9.0.0
graphemer: 1.4.0
ignore: 5.3.1
natural-compare: 1.4.0
semver: 7.6.0
ts-api-utils: 1.0.3(typescript@5.4.4)
ts-api-utils: 1.3.0(typescript@5.4.4)
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/parser@7.5.0(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-cj+XGhNujfD2/wzR1tabNsidnYRaFfEkcULdcIyVBYcXjBvBKOes+mpMBP7hMpOyk+gBcfXsrg4NBGAStQyxjQ==}
/@typescript-eslint/parser@7.6.0(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-usPMPHcwX3ZoPWnBnhhorc14NJw9J4HpSXQX4urF2TPKG0au0XhJoZyX62fmvdHONUkmyUe74Hzm1//XA+BoYg==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
eslint: ^8.56.0
@ -3382,10 +3392,10 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/scope-manager': 7.5.0
'@typescript-eslint/types': 7.5.0
'@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4)
'@typescript-eslint/visitor-keys': 7.5.0
'@typescript-eslint/scope-manager': 7.6.0
'@typescript-eslint/types': 7.6.0
'@typescript-eslint/typescript-estree': 7.6.0(typescript@5.4.4)
'@typescript-eslint/visitor-keys': 7.6.0
debug: 4.3.4
eslint: 9.0.0
typescript: 5.4.4
@ -3401,16 +3411,16 @@ packages:
'@typescript-eslint/visitor-keys': 6.21.0
dev: true
/@typescript-eslint/scope-manager@7.5.0:
resolution: {integrity: sha512-Z1r7uJY0MDeUlql9XJ6kRVgk/sP11sr3HKXn268HZyqL7i4cEfrdFuSSY/0tUqT37l5zT0tJOsuDP16kio85iA==}
/@typescript-eslint/scope-manager@7.6.0:
resolution: {integrity: sha512-ngttyfExA5PsHSx0rdFgnADMYQi+Zkeiv4/ZxGYUWd0nLs63Ha0ksmp8VMxAIC0wtCFxMos7Lt3PszJssG/E6w==}
engines: {node: ^18.18.0 || >=20.0.0}
dependencies:
'@typescript-eslint/types': 7.5.0
'@typescript-eslint/visitor-keys': 7.5.0
'@typescript-eslint/types': 7.6.0
'@typescript-eslint/visitor-keys': 7.6.0
dev: true
/@typescript-eslint/type-utils@7.5.0(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-A021Rj33+G8mx2Dqh0nMO9GyjjIBK3MqgVgZ2qlKf6CJy51wY/lkkFqq3TqqnH34XyAHUkq27IjlUkWlQRpLHw==}
/@typescript-eslint/type-utils@7.6.0(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-NxAfqAPNLG6LTmy7uZgpK8KcuiS2NZD/HlThPXQRGwz6u7MDBWRVliEEl1Gj6U7++kVJTpehkhZzCJLMK66Scw==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
eslint: ^8.56.0
@ -3419,11 +3429,11 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4)
'@typescript-eslint/utils': 7.5.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/typescript-estree': 7.6.0(typescript@5.4.4)
'@typescript-eslint/utils': 7.6.0(eslint@9.0.0)(typescript@5.4.4)
debug: 4.3.4
eslint: 9.0.0
ts-api-utils: 1.0.3(typescript@5.4.4)
ts-api-utils: 1.3.0(typescript@5.4.4)
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
@ -3434,8 +3444,8 @@ packages:
engines: {node: ^16.0.0 || >=18.0.0}
dev: true
/@typescript-eslint/types@7.5.0:
resolution: {integrity: sha512-tv5B4IHeAdhR7uS4+bf8Ov3k793VEVHd45viRRkehIUZxm0WF82VPiLgHzA/Xl4TGPg1ZD49vfxBKFPecD5/mg==}
/@typescript-eslint/types@7.6.0:
resolution: {integrity: sha512-h02rYQn8J+MureCvHVVzhl69/GAfQGPQZmOMjG1KfCl7o3HtMSlPaPUAPu6lLctXI5ySRGIYk94clD/AUMCUgQ==}
engines: {node: ^18.18.0 || >=20.0.0}
dev: true
@ -3455,14 +3465,14 @@ packages:
is-glob: 4.0.3
minimatch: 9.0.3
semver: 7.6.0
ts-api-utils: 1.0.3(typescript@5.4.4)
ts-api-utils: 1.3.0(typescript@5.4.4)
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/typescript-estree@7.5.0(typescript@5.4.4):
resolution: {integrity: sha512-YklQQfe0Rv2PZEueLTUffiQGKQneiIEKKnfIqPIOxgM9lKSZFCjT5Ad4VqRKj/U4+kQE3fa8YQpskViL7WjdPQ==}
/@typescript-eslint/typescript-estree@7.6.0(typescript@5.4.4):
resolution: {integrity: sha512-+7Y/GP9VuYibecrCQWSKgl3GvUM5cILRttpWtnAu8GNL9j11e4tbuGZmZjJ8ejnKYyBRb2ddGQ3rEFCq3QjMJw==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
typescript: '*'
@ -3470,14 +3480,14 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/types': 7.5.0
'@typescript-eslint/visitor-keys': 7.5.0
'@typescript-eslint/types': 7.6.0
'@typescript-eslint/visitor-keys': 7.6.0
debug: 4.3.4
globby: 11.1.0
is-glob: 4.0.3
minimatch: 9.0.3
minimatch: 9.0.4
semver: 7.6.0
ts-api-utils: 1.0.3(typescript@5.4.4)
ts-api-utils: 1.3.0(typescript@5.4.4)
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
@ -3502,8 +3512,8 @@ packages:
- typescript
dev: true
/@typescript-eslint/utils@7.5.0(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-3vZl9u0R+/FLQcpy2EHyRGNqAS/ofJ3Ji8aebilfJe+fobK8+LbIFmrHciLVDxjDoONmufDcnVSF38KwMEOjzw==}
/@typescript-eslint/utils@7.6.0(eslint@9.0.0)(typescript@5.4.4):
resolution: {integrity: sha512-x54gaSsRRI+Nwz59TXpCsr6harB98qjXYzsRxGqvA5Ue3kQH+FxS7FYU81g/omn22ML2pZJkisy6Q+ElK8pBCA==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
eslint: ^8.56.0
@ -3511,9 +3521,9 @@ packages:
'@eslint-community/eslint-utils': 4.4.0(eslint@9.0.0)
'@types/json-schema': 7.0.15
'@types/semver': 7.5.8
'@typescript-eslint/scope-manager': 7.5.0
'@typescript-eslint/types': 7.5.0
'@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.4)
'@typescript-eslint/scope-manager': 7.6.0
'@typescript-eslint/types': 7.6.0
'@typescript-eslint/typescript-estree': 7.6.0(typescript@5.4.4)
eslint: 9.0.0
semver: 7.6.0
transitivePeerDependencies:
@ -3529,11 +3539,11 @@ packages:
eslint-visitor-keys: 3.4.3
dev: true
/@typescript-eslint/visitor-keys@7.5.0:
resolution: {integrity: sha512-mcuHM/QircmA6O7fy6nn2w/3ditQkj+SgtOc8DW3uQ10Yfj42amm2i+6F2K4YAOPNNTmE6iM1ynM6lrSwdendA==}
/@typescript-eslint/visitor-keys@7.6.0:
resolution: {integrity: sha512-4eLB7t+LlNUmXzfOu1VAIAdkjbu5xNSerURS9X/S5TUKWFRpXRQZbmtPqgKmYx8bj3J0irtQXSiWAOY82v+cgw==}
engines: {node: ^18.18.0 || >=20.0.0}
dependencies:
'@typescript-eslint/types': 7.5.0
'@typescript-eslint/types': 7.6.0
eslint-visitor-keys: 3.4.3
dev: true
@ -3832,7 +3842,7 @@ packages:
'@babel/core': 7.24.1
'@babel/plugin-transform-typescript': 7.24.1(@babel/core@7.24.1)
'@vue/babel-plugin-jsx': 1.1.5(@babel/core@7.24.1)
vite: 5.2.8(@types/node@20.12.5)
vite: 5.2.8(@types/node@20.12.6)
vue: 3.4.21(typescript@5.4.4)
transitivePeerDependencies:
- supports-color
@ -3866,7 +3876,7 @@ packages:
strip-literal: 2.1.0
test-exclude: 6.0.0
v8-to-istanbul: 9.2.0
vitest: 1.4.0(@types/node@20.12.5)(happy-dom@14.7.1)
vitest: 1.4.0(@types/node@20.12.6)(happy-dom@14.7.1)
transitivePeerDependencies:
- supports-color
dev: true
@ -5289,8 +5299,8 @@ packages:
postcss: 8.4.38
dev: false
/css-loader@7.0.0(webpack@5.91.0):
resolution: {integrity: sha512-WrO4FVoamxt5zY9CauZjoJgXRi/LZKIk+Ta7YvpSGr5r/eMYPNp5/T9ODlMe4/1rF5DYlycG1avhV4g3A/tiAw==}
/css-loader@7.1.0(webpack@5.91.0):
resolution: {integrity: sha512-VFNj47MAG84MqYDdh9puJG0h98Xs7gEYaX0aeGkfjYqBLB0seOE325sVbqWwaNu3hMZwEP4bB+F4gvF+A63qMA==}
engines: {node: '>= 18.12.0'}
peerDependencies:
'@rspack/core': 0.x || 1.x
@ -6012,14 +6022,14 @@ packages:
peerDependencies:
eslint: ^8.56.0 || ^9.0.0-0
dependencies:
'@typescript-eslint/utils': 7.5.0(eslint@9.0.0)(typescript@5.4.4)
'@typescript-eslint/utils': 7.6.0(eslint@9.0.0)(typescript@5.4.4)
debug: 4.3.4
doctrine: 3.0.0
eslint: 9.0.0
eslint-import-resolver-node: 0.3.9
get-tsconfig: 4.7.3
is-glob: 4.0.3
minimatch: 9.0.3
minimatch: 9.0.4
semver: 7.6.0
transitivePeerDependencies:
- supports-color
@ -6105,11 +6115,11 @@ packages:
- supports-color
dev: true
/eslint-plugin-vue@9.24.0(eslint@9.0.0):
resolution: {integrity: sha512-9SkJMvF8NGMT9aQCwFc5rj8Wo1XWSMSHk36i7ZwdI614BU7sIOR28ZjuFPKp8YGymZN12BSEbiSwa7qikp+PBw==}
/eslint-plugin-vue@9.24.1(eslint@9.0.0):
resolution: {integrity: sha512-wk3SuwmS1pZdcuJlokGYEi/buDOwD6KltvhIZyOnpJ/378dcQ4zchu9PAMbbLAaydCz1iYc5AozszcOOgZIIOg==}
engines: {node: ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.2.0 || ^7.0.0 || ^8.0.0
eslint: ^6.2.0 || ^7.0.0 || ^8.0.0 || ^9.0.0
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@9.0.0)
eslint: 9.0.0
@ -6146,10 +6156,13 @@ packages:
esrecurse: 4.3.0
estraverse: 5.3.0
/eslint-typegen@0.2.0:
resolution: {integrity: sha512-zaAQemIb3RfMjxCMv+sgoXAAhrMZDlx8rZ35zaIUS7ebZHvj1QjjspQnHnZ8UA/7U00u9tI+Lv1pjX1A73HHPQ==}
/eslint-typegen@0.2.2(eslint@9.0.0):
resolution: {integrity: sha512-hgKW5octZPdbnOvzWYjzdk3fD8P8n2c7RvmYlVF3zLFjkf2wyvAf9QRt/r8a7jYzqh6lZrVgr81XOe5jwz3z9g==}
peerDependencies:
eslint: ^8.45.0 || ^9.0.0
dependencies:
'@types/eslint': 8.56.7
eslint: 9.0.0
json-schema-to-typescript-lite: 14.0.0
ohash: 1.1.3
dev: true
@ -7069,7 +7082,7 @@ packages:
resolution: {integrity: sha512-C7FfFoTA+bI10qfeydT8aZbvr91vAEU+2W5BZUlzPec47oNb07SsOfwYrtxuvOYdUApPP/Qlh4DtAO51Ekk2QA==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dependencies:
minimatch: 9.0.3
minimatch: 9.0.4
dev: false
/ignore@5.3.1:
@ -7474,7 +7487,7 @@ packages:
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
'@jest/types': 29.6.3
'@types/node': 20.12.5
'@types/node': 20.12.6
chalk: 4.1.2
ci-info: 3.9.0
graceful-fs: 4.2.11
@ -7485,7 +7498,7 @@ packages:
resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==}
engines: {node: '>= 10.13.0'}
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
merge-stream: 2.0.0
supports-color: 8.1.1
@ -7493,7 +7506,7 @@ packages:
resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
jest-util: 29.7.0
merge-stream: 2.0.0
supports-color: 8.1.1
@ -8447,6 +8460,12 @@ packages:
dependencies:
brace-expansion: 2.0.1
/minimatch@9.0.4:
resolution: {integrity: sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==}
engines: {node: '>=16 || 14 >=14.17'}
dependencies:
brace-expansion: 2.0.1
/minimist@1.2.8:
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
@ -10951,9 +10970,9 @@ packages:
resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==}
dev: true
/ts-api-utils@1.0.3(typescript@5.4.4):
resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==}
engines: {node: '>=16.13.0'}
/ts-api-utils@1.3.0(typescript@5.4.4):
resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==}
engines: {node: '>=16'}
peerDependencies:
typescript: '>=4.2.0'
dependencies:
@ -11500,7 +11519,7 @@ packages:
vite: 5.2.8(@types/node@20.12.5)
dev: false
/vite-node@1.0.2(@types/node@20.12.5):
/vite-node@1.0.2(@types/node@20.12.6):
resolution: {integrity: sha512-h7BbMJf46fLvFW/9Ygo3snkIBEHFh6fHpB4lge98H5quYrDhPFeI3S0LREz328uqPWSnii2yeJXktQ+Pmqk5BQ==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
@ -11509,7 +11528,7 @@ packages:
debug: 4.3.4
pathe: 1.1.2
picocolors: 1.0.0
vite: 5.2.8(@types/node@20.12.5)
vite: 5.2.8(@types/node@20.12.6)
transitivePeerDependencies:
- '@types/node'
- less
@ -11540,6 +11559,27 @@ packages:
- sugarss
- supports-color
- terser
dev: true
/vite-node@1.4.0(@types/node@20.12.6):
resolution: {integrity: sha512-VZDAseqjrHgNd4Kh8icYHWzTKSCZMhia7GyHfhtzLW33fZlG9SwsB6CEhgyVOWkJfJ2pFLrp/Gj1FSfAiqH9Lw==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
dependencies:
cac: 6.7.14
debug: 4.3.4
pathe: 1.1.2
picocolors: 1.0.0
vite: 5.2.8(@types/node@20.12.6)
transitivePeerDependencies:
- '@types/node'
- less
- lightningcss
- sass
- stylus
- sugarss
- supports-color
- terser
/vite-plugin-checker@0.6.4(eslint@9.0.0)(typescript@5.4.4)(vite@5.2.8)(vue-tsc@2.0.11):
resolution: {integrity: sha512-2zKHH5oxr+ye43nReRbC2fny1nyARwhxdm0uNYp/ERy4YvU9iZpNOsueoi/luXw5gnpqRSvjcEPxXbS153O2wA==}
@ -11585,7 +11625,7 @@ packages:
strip-ansi: 6.0.1
tiny-invariant: 1.3.1
typescript: 5.4.4
vite: 5.2.8(@types/node@20.12.5)
vite: 5.2.8(@types/node@20.12.6)
vscode-languageclient: 7.0.0
vscode-languageserver: 7.0.0
vscode-languageserver-textdocument: 1.0.11
@ -11673,6 +11713,41 @@ packages:
optionalDependencies:
fsevents: 2.3.3
/vite@5.2.8(@types/node@20.12.6):
resolution: {integrity: sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
peerDependencies:
'@types/node': ^18.0.0 || >=20.0.0
less: '*'
lightningcss: ^1.21.0
sass: '*'
stylus: '*'
sugarss: '*'
terser: ^5.4.0
peerDependenciesMeta:
'@types/node':
optional: true
less:
optional: true
lightningcss:
optional: true
sass:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
dependencies:
'@types/node': 20.12.6
esbuild: 0.20.2
postcss: 8.4.38
rollup: 4.14.1
optionalDependencies:
fsevents: 2.3.3
/vitest-environment-nuxt@1.0.0(@testing-library/vue@8.0.3)(@vue/test-utils@2.4.5)(h3@1.11.1)(happy-dom@14.7.1)(playwright-core@1.43.0)(vite@5.2.8)(vitest@1.4.0)(vue-router@4.3.0)(vue@3.4.21):
resolution: {integrity: sha512-AWMO9h4HdbaFdPWZw34gALFI8gbBiOpvfbyeZwHIPfh4kWg/TwElYHvYMQ61WPUlCGaS5LebfHkaI0WPyb//Iw==}
dependencies:
@ -11694,7 +11769,7 @@ packages:
- vue-router
dev: true
/vitest@1.0.2(@types/node@20.12.5)(happy-dom@14.7.1):
/vitest@1.0.2(@types/node@20.12.6)(happy-dom@14.7.1):
resolution: {integrity: sha512-F3NVwwpXfRSDnJmyv+ALPwSRVt0zDkRRE18pwUHSUPXAlWQ47rY1dc99ziMW5bBHyqwK2ERjMisLNoef64qk9w==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
@ -11719,7 +11794,7 @@ packages:
jsdom:
optional: true
dependencies:
'@types/node': 20.12.5
'@types/node': 20.12.6
'@vitest/expect': 1.0.2
'@vitest/runner': 1.0.2
'@vitest/snapshot': 1.0.2
@ -11739,8 +11814,8 @@ packages:
strip-literal: 1.3.0
tinybench: 2.5.1
tinypool: 0.8.2
vite: 5.2.8(@types/node@20.12.5)
vite-node: 1.0.2(@types/node@20.12.5)
vite: 5.2.8(@types/node@20.12.6)
vite-node: 1.0.2(@types/node@20.12.6)
why-is-node-running: 2.2.2
transitivePeerDependencies:
- less
@ -11809,6 +11884,63 @@ packages:
- terser
dev: true
/vitest@1.4.0(@types/node@20.12.6)(happy-dom@14.7.1):
resolution: {integrity: sha512-gujzn0g7fmwf83/WzrDTnncZt2UiXP41mHuFYFrdwaLRVQ6JYQEiME2IfEjU3vcFL3VKa75XhI3lFgn+hfVsQw==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@types/node': ^18.0.0 || >=20.0.0
'@vitest/browser': 1.4.0
'@vitest/ui': 1.4.0
happy-dom: '*'
jsdom: '*'
peerDependenciesMeta:
'@edge-runtime/vm':
optional: true
'@types/node':
optional: true
'@vitest/browser':
optional: true
'@vitest/ui':
optional: true
happy-dom:
optional: true
jsdom:
optional: true
dependencies:
'@types/node': 20.12.6
'@vitest/expect': 1.4.0
'@vitest/runner': 1.4.0
'@vitest/snapshot': 1.4.0
'@vitest/spy': 1.4.0
'@vitest/utils': 1.4.0
acorn-walk: 8.3.2
chai: 4.3.10
debug: 4.3.4
execa: 8.0.1
happy-dom: 14.7.1
local-pkg: 0.5.0
magic-string: 0.30.9
pathe: 1.1.2
picocolors: 1.0.0
std-env: 3.7.0
strip-literal: 2.1.0
tinybench: 2.5.1
tinypool: 0.8.2
vite: 5.2.8(@types/node@20.12.6)
vite-node: 1.4.0(@types/node@20.12.6)
why-is-node-running: 2.2.2
transitivePeerDependencies:
- less
- lightningcss
- sass
- stylus
- sugarss
- supports-color
- terser
dev: true
/void-elements@3.1.0:
resolution: {integrity: sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==}
engines: {node: '>=0.10.0'}

View File

@ -512,6 +512,20 @@ describe('composables', () => {
expectTypeOf(notTypedData.value!.content).toEqualTypeOf<string[]>()
expectTypeOf(notTypedData.value!.untypedKey).toEqualTypeOf<any>()
})
it('correctly types returns when using with getCachedData', () => {
expectTypeOf(useAsyncData('test', () => Promise.resolve({ foo: 1 }), {
getCachedData: key => useNuxtApp().payload.data[key],
}).data).toEqualTypeOf<Ref<{ foo: number } | null>>()
useAsyncData('test', () => Promise.resolve({ foo: 1 }), {
// @ts-expect-error cached data should return the same as value of fetcher
getCachedData: () => ({ bar: 2 }),
})
useAsyncData<{ foo: number }, unknown, { foo: number }>('test', () => Promise.resolve({ foo: 1 }), {
// @ts-expect-error cached data should return the same as asserted type of `useAsyncData`
getCachedData: () => ({ bar: 2 }),
})
})
})
describe('app config', () => {