From 328350bc19ac030e0d0022391fca9937bbe7de37 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Wed, 6 Nov 2024 17:16:23 +0800 Subject: [PATCH] chore: fix types --- .../plugin-theme-data/package.json | 2 +- plugins/search/plugin-docsearch/package.json | 1 - .../client/composables/useDocSearchSlim.ts | 5 +- .../src/client/helpers/docsearch.ts | 4 +- .../plugin-docsearch/src/shared/types.ts | 8 ++- pnpm-lock.yaml | 66 ++++++++++--------- 6 files changed, 47 insertions(+), 39 deletions(-) diff --git a/plugins/development/plugin-theme-data/package.json b/plugins/development/plugin-theme-data/package.json index aa0c2164a1..d4b07cb597 100644 --- a/plugins/development/plugin-theme-data/package.json +++ b/plugins/development/plugin-theme-data/package.json @@ -37,7 +37,7 @@ "copy": "cpx \"src/**/*.d.ts\" lib" }, "dependencies": { - "@vue/devtools-api": "^7.6.2", + "@vue/devtools-api": "^7.6.3", "vue": "^3.5.12" }, "peerDependencies": { diff --git a/plugins/search/plugin-docsearch/package.json b/plugins/search/plugin-docsearch/package.json index fe332df41b..a4ee1e78ea 100644 --- a/plugins/search/plugin-docsearch/package.json +++ b/plugins/search/plugin-docsearch/package.json @@ -42,7 +42,6 @@ "dependencies": { "@docsearch/css": "^3.7.0", "@docsearch/js": "^3.7.0", - "@docsearch/react": "^3.7.0", "@vuepress/helper": "workspace:*", "@vueuse/core": "^11.2.0", "ts-debounce": "^4.0.0", diff --git a/plugins/search/plugin-docsearch/src/client/composables/useDocSearchSlim.ts b/plugins/search/plugin-docsearch/src/client/composables/useDocSearchSlim.ts index 6b64be2aa3..d0a80dfe1c 100644 --- a/plugins/search/plugin-docsearch/src/client/composables/useDocSearchSlim.ts +++ b/plugins/search/plugin-docsearch/src/client/composables/useDocSearchSlim.ts @@ -1,7 +1,7 @@ -import type { DocSearchProps } from '@docsearch/react' import { debounce } from 'ts-debounce' import { useRouter } from 'vuepress/client' import { removeLeadingSlash, resolveRoutePathFromUrl } from 'vuepress/shared' +import type { DocSearchProps } from '../../shared/index.js' declare const __DOCSEARCH_INDEX_BASE__: string @@ -65,10 +65,11 @@ export const useDocSearchShim = (): Partial => { // add search debounce transformSearchClient: (searchClient) => { const searchWithDebounce = debounce(searchClient.search, 500) + return { ...searchClient, search: async (...args) => searchWithDebounce(...args), } }, - } as Partial + } } diff --git a/plugins/search/plugin-docsearch/src/client/helpers/docsearch.ts b/plugins/search/plugin-docsearch/src/client/helpers/docsearch.ts index eb05203f32..b478bb0823 100644 --- a/plugins/search/plugin-docsearch/src/client/helpers/docsearch.ts +++ b/plugins/search/plugin-docsearch/src/client/helpers/docsearch.ts @@ -1,9 +1,8 @@ -import type { DocSearchProps } from '@docsearch/react' import { deepAssign, isFunction } from '@vuepress/helper/client' import type { App, ComputedRef, InjectionKey, MaybeRefOrGetter, Ref } from 'vue' import { computed, inject, isRef, ref, watch } from 'vue' import { useRouteLocale } from 'vuepress/client' -import type { DocSearchOptions } from '../../shared/index.js' +import type { DocSearchOptions, DocSearchProps } from '../../shared/index.js' declare const __VUEPRESS_DEV__: boolean declare const __DOCSEARCH_OPTIONS__: DocSearchOptions @@ -41,6 +40,7 @@ export const defineDocSearchConfig = ( docsearch.value = deepAssign({}, docSearchOptions, value) }) } else { + // @ts-expect-error: Types loop back docsearch.value = deepAssign({}, docSearchOptions, options) } } diff --git a/plugins/search/plugin-docsearch/src/shared/types.ts b/plugins/search/plugin-docsearch/src/shared/types.ts index 3cef9764b6..43e89bcf8e 100644 --- a/plugins/search/plugin-docsearch/src/shared/types.ts +++ b/plugins/search/plugin-docsearch/src/shared/types.ts @@ -1,6 +1,12 @@ -import type { DocSearchProps } from '@docsearch/react' +import type docsearch from '@docsearch/js' import type { LocaleConfig } from 'vuepress/shared' +export type DocSearchProps = typeof docsearch extends ( + options: infer T, +) => unknown + ? T + : never + export type DocSearchLocaleOptions = Partial< Pick< DocSearchProps, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e3fb1f40da..06c527ff5c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -450,8 +450,8 @@ importers: plugins/development/plugin-theme-data: dependencies: '@vue/devtools-api': - specifier: ^7.6.2 - version: 7.6.2 + specifier: ^7.6.3 + version: 7.6.3 vue: specifier: ^3.5.12 version: 3.5.12(typescript@5.6.3) @@ -954,9 +954,6 @@ importers: '@docsearch/js': specifier: ^3.7.0 version: 3.7.0(@algolia/client-search@5.12.0)(search-insights@2.13.0) - '@docsearch/react': - specifier: ^3.7.0 - version: 3.7.0(@algolia/client-search@5.12.0)(search-insights@2.13.0) '@vuepress/helper': specifier: workspace:* version: link:../../../tools/helper @@ -2255,8 +2252,8 @@ packages: resolution: {integrity: sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==} engines: {node: '>=18.18'} - '@humanwhocodes/retry@0.4.0': - resolution: {integrity: sha512-xnRgu9DxZbkWak/te3fcytNyp8MTbuiZIaueg2rgEvBuN55n04nwLYLU9TX/VVlusc9L2ZNXi99nUFNkHXtr5g==} + '@humanwhocodes/retry@0.4.1': + resolution: {integrity: sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==} engines: {node: '>=18.18'} '@hutson/parse-repository-url@5.0.0': @@ -3240,8 +3237,8 @@ packages: '@types/prismjs@1.26.5': resolution: {integrity: sha512-AUZTa7hQ2KY5L7AmtSiqxlhWxb4ina0yd8hNbl4TWuqnv/pFP0nDMb3YrfSBf4hJVGLh2YEIBfKaBW/9UEl6IQ==} - '@types/qs@6.9.16': - resolution: {integrity: sha512-7i+zxXdPD0T4cKDuxCUXJ4wHcsJLwENa6Z3dCu8cfCK743OGy5Nu1RmAGqDPsoTDINVEcdXKRvR/zre+P2Ku1A==} + '@types/qs@6.9.17': + resolution: {integrity: sha512-rX4/bPcfmvxHDv0XjfJELTTr+iB+tn032nPILqHm5wbthUUUuVtNGGqzhya9XUxjTP8Fpr0qYgSZZKxGY++svQ==} '@types/range-parser@1.2.7': resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==} @@ -3413,14 +3410,14 @@ packages: '@vue/devtools-api@6.6.4': resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==} - '@vue/devtools-api@7.6.2': - resolution: {integrity: sha512-NCT0ujqlwAhoFvCsAG7G5qS8w/A/dhvFSt2BhmNxyqgpYDrf9CG1zYyWLQkE3dsZ+5lCT6ULUic2VKNaE07Vzg==} + '@vue/devtools-api@7.6.3': + resolution: {integrity: sha512-H2TRzFA9hNezdtM6I0y3RCMhIg5T3gib/p9qI2IAS8gB9tvkAv4JZHAZZl5BZHhO7btuHkvHzU5qpO/vdsjYMg==} - '@vue/devtools-kit@7.6.2': - resolution: {integrity: sha512-k61BxHRmcTtIQZFouF9QWt9nCCNtSdw12lhg8VNtHq5/XOBGD+ewiK27a40UJ8UPYoCJvi80hbvbYr5E/Zeu1g==} + '@vue/devtools-kit@7.6.3': + resolution: {integrity: sha512-ETsFc8GlOp04rSFN79tB2TpVloWfsSx9BoCSElV3w3CaJTSBfz42KsIi5Ka+dNTJs1jY7QVLTDeoBmUGgA9h2A==} - '@vue/devtools-shared@7.6.2': - resolution: {integrity: sha512-lcjyJ7hCC0W0kNwnCGMLVTMvDLoZgjcq9BvboPgS+6jQyDul7fpzRSKTGtGhCHoxrDox7qBAKGbAl2Rcf7GE1A==} + '@vue/devtools-shared@7.6.3': + resolution: {integrity: sha512-wJW5QF27i16+sNQIaes8QoEZg1eqEgF83GkiPUlEQe9k7ZoHXHV7PRrnrxOKem42sIHPU813J2V/ZK1uqTJe6g==} '@vue/reactivity@3.5.12': resolution: {integrity: sha512-UzaN3Da7xnJXdz4Okb/BGbAaomRHc3RdoWqTzlvd9+WBR5m3J39J1fGcHes7U3za0ruYn/iYy/a1euhMEHvTAg==} @@ -4467,8 +4464,8 @@ packages: engines: {node: '>=0.10.0'} hasBin: true - electron-to-chromium@1.5.51: - resolution: {integrity: sha512-kKeWV57KSS8jH4alKt/jKnvHPmJgBxXzGUSbMd4eQF+iOsVPl7bz2KUmu6eo80eMP8wVioTfTyTzdMgM15WXNg==} + electron-to-chromium@1.5.52: + resolution: {integrity: sha512-xtoijJTZ+qeucLBDNztDOuQBE1ksqjvNjvqFoST3nGC7fSpqJ+X6BdTBaY5BHG+IhWWmpc6b/KfpeuEDupEPOQ==} emoji-regex@10.4.0: resolution: {integrity: sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==} @@ -5928,6 +5925,9 @@ packages: mdn-data@2.12.1: resolution: {integrity: sha512-rsfnCbOHjqrhWxwt5/wtSLzpoKTzW7OXdT5lLOIH1OTYhWu9rRJveGq0sKvDZODABH7RX+uoR+DYcpFnq4Tf6Q==} + mdn-data@2.12.2: + resolution: {integrity: sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==} + mdurl@2.0.0: resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==} @@ -9492,7 +9492,7 @@ snapshots: '@humanwhocodes/retry@0.3.1': {} - '@humanwhocodes/retry@0.4.0': {} + '@humanwhocodes/retry@0.4.1': {} '@hutson/parse-repository-url@5.0.0': {} @@ -10576,14 +10576,14 @@ snapshots: '@types/express-serve-static-core@4.19.6': dependencies: '@types/node': 22.9.0 - '@types/qs': 6.9.16 + '@types/qs': 6.9.17 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 '@types/express-serve-static-core@5.0.1': dependencies: '@types/node': 22.9.0 - '@types/qs': 6.9.16 + '@types/qs': 6.9.17 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 @@ -10591,7 +10591,7 @@ snapshots: dependencies: '@types/body-parser': 1.19.5 '@types/express-serve-static-core': 4.19.6 - '@types/qs': 6.9.16 + '@types/qs': 6.9.17 '@types/serve-static': 1.15.7 '@types/fs-extra@11.0.4': @@ -10672,7 +10672,7 @@ snapshots: '@types/prismjs@1.26.5': {} - '@types/qs@6.9.16': {} + '@types/qs@6.9.17': {} '@types/range-parser@1.2.7': {} @@ -10903,13 +10903,13 @@ snapshots: '@vue/devtools-api@6.6.4': {} - '@vue/devtools-api@7.6.2': + '@vue/devtools-api@7.6.3': dependencies: - '@vue/devtools-kit': 7.6.2 + '@vue/devtools-kit': 7.6.3 - '@vue/devtools-kit@7.6.2': + '@vue/devtools-kit@7.6.3': dependencies: - '@vue/devtools-shared': 7.6.2 + '@vue/devtools-shared': 7.6.3 birpc: 0.2.19 hookable: 5.5.3 mitt: 3.0.1 @@ -10917,7 +10917,7 @@ snapshots: speakingurl: 14.0.1 superjson: 2.2.1 - '@vue/devtools-shared@7.6.2': + '@vue/devtools-shared@7.6.3': dependencies: rfdc: 1.4.1 @@ -11049,7 +11049,7 @@ snapshots: '@vuepress/client@2.0.0-rc.18(typescript@5.6.3)': dependencies: - '@vue/devtools-api': 7.6.2 + '@vue/devtools-api': 7.6.3 '@vuepress/shared': 2.0.0-rc.18 vue: 3.5.12(typescript@5.6.3) vue-router: 4.4.5(vue@3.5.12(typescript@5.6.3)) @@ -11474,7 +11474,7 @@ snapshots: browserslist@4.24.2: dependencies: caniuse-lite: 1.0.30001677 - electron-to-chromium: 1.5.51 + electron-to-chromium: 1.5.52 node-releases: 2.0.18 update-browserslist-db: 1.1.1(browserslist@4.24.2) @@ -12199,7 +12199,7 @@ snapshots: dependencies: jake: 10.9.2 - electron-to-chromium@1.5.51: {} + electron-to-chromium@1.5.52: {} emoji-regex@10.4.0: {} @@ -12484,7 +12484,7 @@ snapshots: '@eslint/plugin-kit': 0.2.2 '@humanfs/node': 0.16.6 '@humanwhocodes/module-importer': 1.0.1 - '@humanwhocodes/retry': 0.4.0 + '@humanwhocodes/retry': 0.4.1 '@types/estree': 1.0.6 '@types/json-schema': 7.0.15 ajv: 6.12.6 @@ -13841,6 +13841,8 @@ snapshots: mdn-data@2.12.1: {} + mdn-data@2.12.2: {} + mdurl@2.0.0: {} media-typer@0.3.0: {} @@ -15493,7 +15495,7 @@ snapshots: css-tree: 3.0.1 is-plain-object: 5.0.0 known-css-properties: 0.34.0 - mdn-data: 2.12.1 + mdn-data: 2.12.2 postcss-media-query-parser: 0.2.3 postcss-resolve-nested-selector: 0.1.6 postcss-selector-parser: 6.1.2