diff --git a/.eslintrc.js b/.eslintrc.js index 55c7a7e4251..c55ad660cc8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -57,7 +57,7 @@ module.exports = { }, }, { - files: ['**/*.md', '**/*.md/*.*', 'demo.vue', 'scripts/*.ts', '*.test.ts'], + files: ['**/*.md', '**/*.md/*.*', 'demo.vue', 'demo.client.vue', 'scripts/*.ts', '*.test.ts'], rules: { 'no-alert': 'off', 'no-console': 'off', diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000000..30cba0b4291 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,14 @@ +daysUntilStale: 60 +daysUntilClose: 7 +exemptLabels: + - pinned + - security + - no-stale + - no stale + - pr welcome +staleLabel: stale +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +closeComment: false diff --git a/.gitignore b/.gitignore index af36a040b8b..b12cc22831d 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ packages/public/badge-* packages/*/index.mjs playgrounds/*/pnpm-lock.yaml types +coverage +.eslintcache diff --git a/.npmrc b/.npmrc index cf040424558..3e721a916e3 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,3 @@ shamefully-hoist=true strict-peer-dependencies=false +side-effects-cache=false \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8fccef99be3..55159f5c645 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ packages ### Function Folder -A function folder typicality contains these 4 files: +A function folder typically contains these 4 files: > You can find the template under `packages/core/_template/` diff --git a/package.json b/package.json index bf30c32c819..55d2f46aa5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vueuse/monorepo", - "version": "9.2.0", + "version": "9.4.0", "private": true, "packageManager": "pnpm@7.6.0", "description": "Collection of essential Vue Composition Utilities", @@ -16,7 +16,7 @@ "docs": "vue-demi-switch 3 && vitepress dev packages --open", "docs:build": "nr update:full && vitepress build packages && nr build:redirects && esno scripts/post-docs.ts", "docs:serve": "vitepress serve packages", - "lint": "eslint .", + "lint": "eslint --cache .", "lint:fix": "nr lint --fix", "publish:ci": "esno scripts/publish.ts", "install-fonts": "gfi install Inter && gfi install Fira Code", @@ -27,6 +27,7 @@ "test:2": "vue-demi-switch 2.7 vue2 && vitest run --silent", "test:3": "vue-demi-switch 3 && vitest run", "test:all": "nr test:3 && nr test:2 && vue-demi-switch 3", + "test:cov": "vitest run --coverage", "typecheck": "tsc --noEmit", "types:fix": "esno scripts/fix-types.ts", "update": "nr -C packages/metadata update && esno scripts/update.ts", @@ -34,71 +35,73 @@ "watch": "esno scripts/build.ts --watch" }, "devDependencies": { - "@antfu/eslint-config": "^0.26.3", - "@antfu/ni": "^0.18.0", - "@iconify/json": "^2.1.103", - "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-replace": "^4.0.0", + "@antfu/eslint-config": "^0.27.0", + "@antfu/ni": "^0.18.2", + "@iconify/json": "^2.1.122", + "@rollup/plugin-json": "^5.0.0", + "@rollup/plugin-replace": "^5.0.0", "@type-challenges/utils": "^0.1.1", "@types/fs-extra": "^9.0.13", "@types/js-yaml": "^4.0.5", "@types/md5": "^2.3.2", - "@types/node": "^18.7.15", - "@types/prettier": "^2.7.0", + "@types/node": "^18.11.0", + "@types/prettier": "^2.7.1", "@types/semver": "^7.3.12", - "@types/sharp": "^0.30.5", - "@vitest/ui": "^0.23.1", - "@vue/compiler-sfc": "^3.2.38", - "@vue/test-utils": "^2.0.2", + "@types/sharp": "^0.31.0", + "@vitest/coverage-c8": "^0.24.3", + "@vitest/ui": "^0.24.3", + "@vue/compiler-sfc": "^3.2.41", + "@vue/test-utils": "^2.1.0", "@vueuse/core": "workspace:*", "@vueuse/integrations": "workspace:*", "@vueuse/math": "workspace:*", + "@vueuse/rxjs": "workspace:*", "@vueuse/shared": "workspace:*", - "axios": "^0.27.2", + "axios": "^1.1.3", "bumpp": "^8.2.1", "consola": "^2.15.3", "cross-env": "^7.0.3", "esbuild-register": "^3.3.3", - "eslint": "^8.23.0", + "eslint": "^8.25.0", "esno": "^0.16.3", "export-size": "^0.5.2", - "fast-glob": "^3.2.11", - "firebase": "^9.9.4", + "fast-glob": "^3.2.12", + "firebase": "^9.12.1", "fs-extra": "^10.1.0", "fuse.js": "^6.6.2", "google-font-installer": "^1.2.0", "gray-matter": "^4.0.3", "js-yaml": "^4.1.0", - "jsdom": "^20.0.0", + "jsdom": "^20.0.1", "lint-staged": "^13.0.3", "markdown-table": "^3.0.2", "md5": "^2.3.0", - "msw": "^0.47.0", + "msw": "^0.47.4", "node-fetch": "^3.2.10", - "ohmyfetch": "^0.4.18", - "pnpm": "^7.11.0", - "postcss": "^8.4.16", - "postcss-nested": "^5.0.6", + "ohmyfetch": "^0.4.19", + "pnpm": "^7.13.5", + "postcss": "^8.4.18", + "postcss-nested": "^6.0.0", "prettier": "^2.7.1", "prism-theme-vars": "^0.2.4", "remove-markdown": "^0.5.0", "rimraf": "^3.0.2", - "rollup": "^2.79.0", - "rollup-plugin-dts": "^4.2.2", + "rollup": "^3.2.2", + "rollup-plugin-dts": "^5.0.0", "rollup-plugin-esbuild": "^4.10.1", - "sharp": "^0.31.0", - "simple-git": "^3.14.0", + "sharp": "^0.31.1", + "simple-git": "^3.14.1", "simple-git-hooks": "^2.8.0", - "typescript": "4.8.2", - "unocss": "^0.45.15", - "unplugin-icons": "^0.14.9", - "unplugin-vue-components": "^0.22.4", - "vite": "^3.1.0", - "vite-plugin-inspect": "^0.6.1", - "vite-plugin-pwa": "^0.12.6", - "vitepress": "^1.0.0-alpha.13", - "vitest": "^0.23.1", - "vue": "^3.2.38", + "typescript": "4.8.4", + "unocss": "^0.45.29", + "unplugin-icons": "^0.14.12", + "unplugin-vue-components": "^0.22.8", + "vite": "^3.1.8", + "vite-plugin-inspect": "^0.7.5", + "vite-plugin-pwa": "^0.13.1", + "vitepress": "^1.0.0-alpha.21", + "vitest": "^0.24.3", + "vue": "^3.2.41", "vue2": "npm:vue@^2.7.10" }, "pnpm": { @@ -106,7 +109,8 @@ "electron" ], "overrides": { - "vue-demi": "0.13.2" + "vue-demi": "0.13.11", + "vite": "^3.1.6" } }, "simple-git-hooks": { @@ -114,7 +118,7 @@ }, "lint-staged": { "*.{js,ts,tsx,vue,md}": [ - "eslint --fix" + "eslint --cache --fix" ] } } diff --git a/packages/.vitepress/config.ts b/packages/.vitepress/config.ts index 8f89dbc3599..81a9ba8253c 100644 --- a/packages/.vitepress/config.ts +++ b/packages/.vitepress/config.ts @@ -1,6 +1,6 @@ import { defineConfig } from 'vitepress' +import { addonCategoryNames, categoryNames, coreCategoryNames, metadata } from '../metadata/metadata' import { currentVersion, versions } from '../../meta/versions' -import { addonCategoryNames, categoryNames, coreCategoryNames, metadata } from '../../packages/metadata/metadata' const Guide = [ { text: 'Get Started', link: '/guide/' }, @@ -31,6 +31,7 @@ const Links = [ { text: 'Ecosystem', link: '/ecosystem' }, { text: 'Export Size', link: '/export-size' }, { text: 'Recent Updated', link: '/functions.html#sort=updated' }, + { text: 'Premium Video Course', link: 'https://vueschool.io/courses/vueuse-for-everyone?friend=vueuse' }, ] const DefaultSideBar = [ diff --git a/packages/.vitepress/plugins/markdownTransform.ts b/packages/.vitepress/plugins/markdownTransform.ts index b83b828c235..c2d85437b0e 100644 --- a/packages/.vitepress/plugins/markdownTransform.ts +++ b/packages/.vitepress/plugins/markdownTransform.ts @@ -32,7 +32,9 @@ export function MarkdownTransform(): Plugin { // convert links to relative code = code.replace(/https?:\/\/vueuse\.org\//g, '/') - const [pkg, name, i] = id.split('/').slice(-3) + const [pkg, _name, i] = id.split('/').slice(-3) + + const name = functionNames.find(n => n.toLowerCase() === _name.toLowerCase()) || _name if (functionNames.includes(name) && i === 'index.md') { const frontmatterEnds = code.indexOf('---\n\n') + 4 @@ -63,7 +65,8 @@ const GITHUB_BLOB_URL = 'https://github.com/vueuse/vueuse/blob/main/packages' export async function getFunctionMarkdown(pkg: string, name: string) { const URL = `${GITHUB_BLOB_URL}/${pkg}/${name}` - const hasDemo = fs.existsSync(join(DIR_SRC, pkg, name, 'demo.vue')) + const dirname = join(DIR_SRC, pkg, name) + const demoPath = ['demo.vue', 'demo.client.vue'].find(i => fs.existsSync(join(dirname, i))) const types = await getTypeDefinition(pkg, name) let typingSection = '' @@ -75,7 +78,7 @@ export async function getFunctionMarkdown(pkg: string, name: string) { ## Type Declarations
-Show Type Declarations +Show Type Declarations ${code} @@ -86,7 +89,7 @@ ${code} const links = ([ ['Source', `${URL}/index.ts`], - hasDemo ? ['Demo', `${URL}/demo.vue`] : undefined, + demoPath ? ['Demo', `${URL}/${demoPath}`] : undefined, ['Docs', `${URL}/index.md`], ]) .filter(i => i) @@ -103,16 +106,38 @@ ${code} ` - const demoSection = hasDemo - ? ` + + const demoSection = demoPath + ? demoPath.endsWith('.client.vue') + ? ` + + +## Demo + + + + + + + + + + +` + : ` ## Demo - + ` diff --git a/packages/.vitepress/plugins/utils.ts b/packages/.vitepress/plugins/utils.ts index 7481b862574..a4ab8d937fc 100644 --- a/packages/.vitepress/plugins/utils.ts +++ b/packages/.vitepress/plugins/utils.ts @@ -6,6 +6,7 @@ export const stringify = reactify( skipInvalid: true, forceQuotes: true, condenseFlow: true, + noCompatMode: true, quotingType: '\'', }), ) diff --git a/packages/.vitepress/theme/components/Contributors.vue b/packages/.vitepress/theme/components/Contributors.vue index 6c69ea2537c..63daae5b777 100644 --- a/packages/.vitepress/theme/components/Contributors.vue +++ b/packages/.vitepress/theme/components/Contributors.vue @@ -3,7 +3,6 @@ import _contributors from '/virtual-contributors' import { computed } from 'vue' import type { ContributorInfo } from '../@vueuse/metadata' -import { renderCommitMessage } from '../utils' const props = defineProps<{ fn: string }>() diff --git a/packages/.vitepress/theme/components/CourseLink.vue b/packages/.vitepress/theme/components/CourseLink.vue new file mode 100644 index 00000000000..ead580ce6c7 --- /dev/null +++ b/packages/.vitepress/theme/components/CourseLink.vue @@ -0,0 +1,12 @@ + + + diff --git a/packages/.vitepress/theme/components/FunctionInfo.vue b/packages/.vitepress/theme/components/FunctionInfo.vue index 1c3663eeda9..413515bf788 100644 --- a/packages/.vitepress/theme/components/FunctionInfo.vue +++ b/packages/.vitepress/theme/components/FunctionInfo.vue @@ -6,7 +6,6 @@ import exportSizes from '../../../export-size.json' const props = defineProps<{ fn: string }>() const info = computed(() => functions.find(i => i.name === props.fn)) -const format = (ts: number) => ago(-1, 'day') const lastUpdated = useTimeAgo(new Date(info.value?.lastUpdated || 0)) const link = computed(() => `/functions\#category=${encodeURIComponent(info.value.category)}`) diff --git a/packages/.vitepress/theme/components/FunctionsList.vue b/packages/.vitepress/theme/components/FunctionsList.vue index 2e23e857add..5e34d4ba800 100644 --- a/packages/.vitepress/theme/components/FunctionsList.vue +++ b/packages/.vitepress/theme/components/FunctionsList.vue @@ -1,5 +1,6 @@ diff --git a/packages/.vitepress/theme/components/TeamMember.vue b/packages/.vitepress/theme/components/TeamMember.vue index 2fb97146a61..012a5f2d0a2 100644 --- a/packages/.vitepress/theme/components/TeamMember.vue +++ b/packages/.vitepress/theme/components/TeamMember.vue @@ -45,9 +45,9 @@ defineProps<{ :aria-label="`Sponsor ${data.name}`" /> -
+