Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08c283a

Browse filesBrowse files
committed
Merge branch 'main' into useFetch
2 parents 600fcc9 + 5dd2a1e commit 08c283a
Copy full SHA for 08c283a

File tree

552 files changed

+8307
-4840
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner

552 files changed

+8307
-4840
lines changed

‎.github/ISSUE_TEMPLATE/bug_report.yml

Copy file name to clipboardExpand all lines: .github/ISSUE_TEMPLATE/bug_report.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: 🐞 Bug report
22
description: Report an issue with VueUse
33
labels: [pending triage]
4+
type: Bug
45
title: 'BUG | `functionName` | '
56
body:
67
- type: markdown

‎.github/ISSUE_TEMPLATE/feature_request.yml

Copy file name to clipboardExpand all lines: .github/ISSUE_TEMPLATE/feature_request.yml
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
name: 🚀 New feature proposal
22
description: Propose a new feature to be added to VueUse
3-
labels: [enhancement]
4-
title: 'REQUEST | `functionName` | '
3+
type: Feature
4+
title: '`functionName` | '
55
body:
66
- type: markdown
77
attributes:
88
value: |
99
Thanks for your interest in the project and taking the time to fill out this feature report!
1010
1111
Please follow the one of the following title formats:
12-
- ``REQUEST | `functionName` | Short Description`` - if related to a specific function
13-
- `REQUEST | Short Description` - if it's a general feature request
12+
- `` `functionName` | Short Description `` - if related to a specific function
13+
- `Short Description` - if it's a general feature request
1414
1515
For example:
1616
```
17-
REQUEST | \`useFetch\` | Support for custom headers
17+
`useFetch` | Support for custom headers
1818
```
1919
20-
> **Warning**: **⚠️ Slowing down new functions**
20+
> [!Warning]
21+
>
22+
> **Slowing down new functions**
2123
>
2224
> As the VueUse audience continues to grow, we have been inundated with an overwhelming number of feature requests and pull requests. As a result, maintaining the project has become increasingly challenging and has stretched our capacity to its limits. As such, in the near future, we may need to slow down our acceptance of new features and prioritize the stability and quality of existing functions. **Please note that new features for VueUse may not be accepted at this time.** If you have any new ideas, we suggest that you first incorporate them into your own codebase, iterate on them to suit your needs, and assess their generalizability. If you strongly believe that your ideas are beneficial to the community, you may submit a pull request along with your use cases, and we would be happy to review and discuss them. Thank you for your understanding.
2325
- type: textarea

‎.github/workflows/ci.yml

Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
strategy:
4545
matrix:
46-
node: [18.x, 20.x]
46+
node: [20.x, 22.x]
4747
fail-fast: false
4848

4949
steps:
@@ -64,15 +64,21 @@ jobs:
6464
- name: Install
6565
run: nci
6666

67+
- name: Install Playwright Browsers
68+
run: pnpm exec playwright install --with-deps
69+
6770
- name: Build
6871
run: nr build
6972

7073
- name: Typecheck
7174
run: nr typecheck
7275

73-
- name: Test Vue 3
74-
run: pnpm run test
76+
- name: unit tests
77+
run: pnpm run test:unit
78+
79+
- name: browser tests
80+
run: pnpm run test:browser
7581

76-
- if: matrix.node == '18.x'
82+
- if: matrix.node == '22.x'
7783
name: Playground Smoke Test
7884
run: cd playgrounds && bash ./build.sh

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ types
2222
coverage
2323
.eslintcache
2424
.vitepress/cache
25+
26+
packages/**/__screenshots__

‎CONTRIBUTING.md

Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ We use VitePress for rapid development and documenting. You can start it locally
2222
pnpm dev
2323
```
2424

25+
### Testing
26+
27+
```bash
28+
pnpm test:unit # to run unit tests
29+
```
30+
31+
If you want to use experimental browser tests, you need to install playwright dependencies first.
32+
33+
```bash
34+
nlx playwright install --with-deps
35+
```
36+
37+
and then run
38+
39+
```bash
40+
pnpm test:browser
41+
```
42+
2543
## Contributing
2644

2745
### Existing functions

‎eslint.config.js

Copy file name to clipboardExpand all lines: eslint.config.js
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { resolve } from 'node:path'
22
import { fileURLToPath } from 'node:url'
33
import antfu from '@antfu/eslint-config'
4+
import { createSimplePlugin } from 'eslint-factory'
5+
import { createAutoInsert } from 'eslint-plugin-unimport'
46

57
const dir = fileURLToPath(new URL('.', import.meta.url))
68
const restricted = [
@@ -122,4 +124,33 @@ export default antfu(
122124
'no-restricted-imports': 'off',
123125
},
124126
},
127+
createAutoInsert({
128+
imports: [
129+
{
130+
from: 'vue',
131+
name: 'shallowRef',
132+
},
133+
{
134+
from: 'vue',
135+
name: 'ref',
136+
as: 'deepRef',
137+
},
138+
],
139+
}),
140+
createSimplePlugin({
141+
name: 'no-ref',
142+
exclude: ['**/*.md', '**/*.md/**'],
143+
create(context) {
144+
return {
145+
CallExpression(node) {
146+
if (node.callee.type === 'Identifier' && node.callee.name === 'ref') {
147+
context.report({
148+
node,
149+
message: 'Usage of ref() is restricted. Use shallowRef() or deepRef() instead.',
150+
})
151+
}
152+
},
153+
}
154+
},
155+
}),
125156
)

‎netlify.toml

Copy file name to clipboardExpand all lines: netlify.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ command = "pnpm run install-fonts && pnpm run docs:build"
44

55
[build.environment]
66
NODE_OPTIONS = "--max_old_space_size=4096"
7-
NODE_VERSION = "18"
7+
NODE_VERSION = "22"
88

99
[[redirects]]
1010
from = "https://vueuse.js.org/*"

‎package.json

Copy file name to clipboardExpand all lines: package.json
+19-8Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "@vueuse/monorepo",
33
"type": "module",
4-
"version": "12.2.0",
4+
"version": "12.6.1",
55
"private": true,
6-
"packageManager": "pnpm@9.15.1",
6+
"packageManager": "pnpm@10.4.0",
77
"description": "Collection of essential Vue Composition Utilities",
88
"author": "Anthony Fu<https://github.com/antfu>",
99
"license": "MIT",
1010
"scripts": {
1111
"build": "nr update && pnpm -r run build",
1212
"build:redirects": "tsx scripts/redirects.ts",
13-
"build:types": "tsc --emitDeclarationOnly",
13+
"build:types": "vue-tsc --emitDeclarationOnly",
1414
"clean": "tsx scripts/clean.ts",
1515
"dev": "nr update && nr docs",
1616
"docs": "vitepress dev packages --open",
@@ -23,9 +23,13 @@
2323
"release": "bumpp --execute=\"npm run release:prepare\" --all",
2424
"release:prepare": "npm run build:types && npm run update",
2525
"size": "tsx scripts/export-size.ts",
26-
"test": "vitest",
27-
"test:cov": "vitest run --coverage",
28-
"typecheck": "tsc --noEmit",
26+
"test": "nr test:unit",
27+
"test:cov": "vitest run --coverage --project=\"browser (chromium)\" --project=unit",
28+
"test:browser": "vitest --project=\"browser*\"",
29+
"test:firefox": "vitest --project=\"browser (firefox)\"",
30+
"test:chromium": "vitest --project=\"browser (chromium)\"",
31+
"test:unit": "vitest --project unit",
32+
"typecheck": "vue-tsc --noEmit",
2933
"update": "nr -C packages/metadata update && tsx scripts/update.ts",
3034
"update:full": "nr update && nr build:types",
3135
"watch": "pnpm -r --parallel run build --watch",
@@ -45,6 +49,8 @@
4549
"@types/remove-markdown": "catalog:",
4650
"@types/semver": "catalog:",
4751
"@vite-pwa/vitepress": "catalog:",
52+
"@vitejs/plugin-vue": "catalog:",
53+
"@vitest/browser": "catalog:",
4854
"@vitest/coverage-v8": "catalog:",
4955
"@vitest/ui": "catalog:",
5056
"@vue/compiler-sfc": "catalog:",
@@ -61,7 +67,9 @@
6167
"consola": "catalog:",
6268
"esbuild-register": "catalog:",
6369
"eslint": "catalog:",
70+
"eslint-factory": "^0.1.2",
6471
"eslint-plugin-format": "catalog:",
72+
"eslint-plugin-unimport": "^0.1.2",
6573
"export-size": "catalog:",
6674
"fake-indexeddb": "catalog:",
6775
"firebase": "catalog:",
@@ -77,6 +85,7 @@
7785
"node-fetch": "catalog:",
7886
"node-fetch-native": "catalog:",
7987
"ofetch": "catalog:",
88+
"playwright": "catalog:",
8089
"pnpm": "catalog:",
8190
"postcss": "catalog:",
8291
"postcss-nested": "catalog:",
@@ -101,7 +110,9 @@
101110
"vite-plugin-inspect": "catalog:",
102111
"vitepress": "catalog:",
103112
"vitest": "catalog:",
104-
"vue": "catalog:"
113+
"vitest-browser-vue": "catalog:",
114+
"vue": "catalog:",
115+
"vue-tsc": "catalog:"
105116
},
106117
"pnpm": {
107118
"neverBuiltDependencies": [
@@ -128,7 +139,7 @@
128139
"pre-commit": "npx lint-staged"
129140
},
130141
"lint-staged": {
131-
"*.{js,ts,tsx,vue,md}": [
142+
"*.{js,ts,tsx,vue,md,json}": [
132143
"eslint --cache --fix"
133144
]
134145
}

‎packages/.test/index.ts

Copy file name to clipboard
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import process from 'node:process'
2-
import './polyfillFetch'
32

43
export const isBelowNode18 = Number(process.version.slice(1).split('.')[0]) < 18
54

65
export * from './mount'
76
export * from './nextTick'
8-
export * from './retry'

‎packages/.test/mount.ts

Copy file name to clipboardExpand all lines: packages/.test/mount.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { InjectionKey, Ref } from 'vue'
2-
import { createApp, defineComponent, h, provide, ref } from 'vue'
2+
import { createApp, defineComponent, h, provide, shallowRef } from 'vue'
33

44
type InstanceType<V> = V extends { new (...arg: any[]): infer X } ? X : never
55
type VM<V> = InstanceType<V> & { unmount: () => void }
@@ -38,7 +38,7 @@ export function useInjectedSetup<V>(setup: () => V) {
3838
const Provider = defineComponent({
3939
components: Comp,
4040
setup() {
41-
provide(Key, ref(1))
41+
provide(Key, shallowRef(1))
4242
},
4343
render() {
4444
return h('div', [])

‎packages/.test/polyfillFetch.ts

Copy file name to clipboardExpand all lines: packages/.test/polyfillFetch.ts
-6Lines changed: 0 additions & 6 deletions
This file was deleted.

‎packages/.test/polyfillIndexedDb.ts

Copy file name to clipboardExpand all lines: packages/.test/polyfillIndexedDb.ts
-4Lines changed: 0 additions & 4 deletions
This file was deleted.

‎packages/.test/polyfillMatchMedia.ts

Copy file name to clipboardExpand all lines: packages/.test/polyfillMatchMedia.ts
-16Lines changed: 0 additions & 16 deletions
This file was deleted.

‎packages/.test/retry.ts

Copy file name to clipboardExpand all lines: packages/.test/retry.ts
-29Lines changed: 0 additions & 29 deletions
This file was deleted.

‎packages/.test/setup.ts

Copy file name to clipboard
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
import { beforeEach } from 'vitest'
2-
import './polyfillFetch'
31
import './polyfillPointerEvents'
4-
import './polyfillIndexedDb'
5-
import './polyfillMatchMedia'
6-
7-
beforeEach(() => {
8-
document.body.innerHTML = ''
9-
document.head.innerHTML = ''
10-
})

‎packages/.vitepress/config.ts

Copy file name to clipboardExpand all lines: packages/.vitepress/config.ts
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ const Learn = [
4444
{ text: 'Official Vue Certification', link: 'https://certification.vuejs.org/?utm_source=vueuse&utm_medium=website&utm_campaign=affiliate&utm_content=guide&banner_type=text&friend=VUEUSE' },
4545
]
4646

47+
const Resources = [
48+
{ text: 'Team & Contributors', link: '/team' },
49+
{ text: 'Learn', items: Learn },
50+
]
51+
4752
const DefaultSideBar = [
4853
{ text: 'Guide', items: Guide },
4954
{ text: 'Core Functions', items: CoreCategories },
@@ -99,7 +104,6 @@ export default withPwa(defineConfig({
99104
text: 'Guide',
100105
items: [
101106
{ text: 'Guide', items: Guide },
102-
{ text: 'Learn', items: Learn },
103107
{ text: 'Links', items: Links },
104108
],
105109
},
@@ -118,8 +122,8 @@ export default withPwa(defineConfig({
118122
],
119123
},
120124
{
121-
text: 'Add-ons',
122-
link: '/add-ons',
125+
text: 'Resources',
126+
items: Resources,
123127
},
124128
{
125129
text: 'Playground',

‎packages/.vitepress/plugins/markdownTransform.ts

Copy file name to clipboardExpand all lines: packages/.vitepress/plugins/markdownTransform.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function MarkdownTransform(): Plugin {
2828
if (ending === ']') // already a link
2929
return _
3030
const fn = getFunction(name)!
31-
return `[\`${fn.name}\`](${fn.docs}) `
31+
return `[\`${fn.name}\`](${fn.docs})${ending}`
3232
},
3333
)
3434
// convert links to relative

‎packages/.vitepress/theme/components/Changelog.vue

Copy file name to clipboardExpand all lines: packages/.vitepress/theme/components/Changelog.vue
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const info = computed(() => functions.find(i => i.name === props.fn))
1111
1212
const allCommits = changelog as CommitInfo[]
1313
14-
const names = computed(() => [props.fn, ...info.value.alias || []])
14+
const names = computed(() => [props.fn, ...info.value?.alias || []])
1515
const commits = computed(() => {
1616
const related = allCommits
1717
.filter(c => c.version || c.functions?.some(i => names.value.includes(i)))

‎packages/.vitepress/theme/components/DemoContainer.vue

Copy file name to clipboardExpand all lines: packages/.vitepress/theme/components/DemoContainer.vue
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
2-
import { onErrorCaptured, ref } from 'vue'
2+
import { ref as deepRef, onErrorCaptured } from 'vue'
33
4-
const error = ref<Error | null>(null)
4+
const error = deepRef<Error | null>(null)
55
66
onErrorCaptured((err) => {
77
error.value = err

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.