From c740ee80a01015d7b856af1f7425dc5c1ac28faf Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Mon, 18 Nov 2024 21:51:20 +0800 Subject: [PATCH 1/5] docs: update docs --- docs/plugins/search/docsearch.md | 8 +------- docs/plugins/search/search.md | 12 +----------- docs/zh/plugins/search/docsearch.md | 8 +------- docs/zh/plugins/search/search.md | 12 +----------- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/docs/plugins/search/docsearch.md b/docs/plugins/search/docsearch.md index 1b9711e557..def2d37e9f 100644 --- a/docs/plugins/search/docsearch.md +++ b/docs/plugins/search/docsearch.md @@ -428,10 +428,4 @@ You can customize styles via CSS variables that provided by [@docsearch/css](htt ## Components -### SearchBox - -- Details: - - This plugin will register a `` component globally, and you can use it without any props. - - Put this component to where you want to place the DocSearch button. For example, default theme puts this component to the end of the navbar. +- SearchBox diff --git a/docs/plugins/search/search.md b/docs/plugins/search/search.md index ae6092b04b..797740694f 100644 --- a/docs/plugins/search/search.md +++ b/docs/plugins/search/search.md @@ -147,14 +147,4 @@ You can customize the style of the search box via CSS variables: ## Components -### SearchBox - -- Details: - - This plugin will register a `` component globally, and you can use it without any props. - - Put this component to where you want to place the search box. For example, default theme puts this component to the end of the navbar. - -::: tip -This component is mainly used for theme development. You don't need to use it directly in most cases. -::: +- SearchBox diff --git a/docs/zh/plugins/search/docsearch.md b/docs/zh/plugins/search/docsearch.md index eb4c302f24..0f87d62282 100644 --- a/docs/zh/plugins/search/docsearch.md +++ b/docs/zh/plugins/search/docsearch.md @@ -427,10 +427,4 @@ const defineDocSearchConfig: (options: DocSearchClientOptions) => void ## 组件 -### SearchBox - -- 详情: - - 该插件会全局注册一个 `` 组件,你可以不传入任何 Props 来使用它。 - - 将该组件放置在你想要显示 DocSearch 按钮的地方。例如,默认主题将这个组件放在了导航栏的末尾。 +- SearchBox diff --git a/docs/zh/plugins/search/search.md b/docs/zh/plugins/search/search.md index 0d6013e3d4..42fbf43c11 100644 --- a/docs/zh/plugins/search/search.md +++ b/docs/zh/plugins/search/search.md @@ -147,14 +147,4 @@ export default { ## 组件 -### SearchBox - -- 详情: - - 该插件会全局注册一个 `` 组件,你可以不传入任何 Props 来使用它。 - - 将该组件放置在你想要显示搜索框的地方。例如,默认主题将这个组件放在了导航栏的末尾。 - -::: tip -该组件主要用于主题开发。在大多数情况下你不需要直接使用该组件。 -::: +- SearchBox From 02c9d3ac0047ecbcfdea9414f763cada7b569e87 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Mon, 18 Nov 2024 21:52:30 +0800 Subject: [PATCH 2/5] build: update tsconfig --- plugins/blog/plugin-comment/src/shims-css.d.ts | 3 --- plugins/blog/plugin-comment/tsconfig.build.json | 2 +- .../plugin-theme-data/tsconfig.build.json | 1 - .../plugin-back-to-top/src/client/shims.d.ts | 3 --- .../features/plugin-back-to-top/tsconfig.build.json | 3 ++- .../features/plugin-catalog/src/client/shims.d.ts | 3 --- plugins/features/plugin-catalog/tsconfig.build.json | 2 +- .../features/plugin-copy-code/src/client/shims.d.ts | 3 --- .../features/plugin-copy-code/tsconfig.build.json | 2 +- .../plugin-medium-zoom/src/client/shims.d.ts | 3 --- .../features/plugin-medium-zoom/tsconfig.build.json | 2 +- plugins/features/plugin-notice/src/client/shims.d.ts | 3 --- plugins/features/plugin-notice/tsconfig.build.json | 3 ++- .../features/plugin-nprogress/src/client/shims.d.ts | 3 --- .../features/plugin-nprogress/tsconfig.build.json | 3 ++- .../plugin-photo-swipe/src/client/shims.d.ts | 3 --- .../features/plugin-photo-swipe/tsconfig.build.json | 2 +- .../plugin-markdown-hint/src/client/shims.d.ts | 3 --- .../plugin-markdown-hint/tsconfig.build.json | 3 ++- .../plugin-markdown-tab/src/client/shims.d.ts | 3 --- .../markdown/plugin-markdown-tab/tsconfig.build.json | 3 ++- plugins/markdown/plugin-revealjs/src/shims.d.ts | 4 ---- plugins/markdown/plugin-revealjs/tsconfig.build.json | 3 ++- plugins/pwa/plugin-pwa/src/client/shims.d.ts | 3 --- plugins/pwa/plugin-pwa/tsconfig.build.json | 2 +- .../search/plugin-docsearch/src/client/shims.d.ts | 4 ---- plugins/search/plugin-docsearch/tsconfig.build.json | 2 +- plugins/search/plugin-search/tsconfig.build.json | 1 - plugins/tools/plugin-redirect/src/client/shims.d.ts | 3 --- plugins/tools/plugin-redirect/tsconfig.build.json | 2 +- themes/theme-default/src/client/shim.d.ts | 12 ++---------- themes/theme-default/tsconfig.build.json | 3 +-- tools/highlighter-helper/tsconfig.build.json | 1 - 33 files changed, 23 insertions(+), 73 deletions(-) delete mode 100644 plugins/blog/plugin-comment/src/shims-css.d.ts delete mode 100644 plugins/features/plugin-back-to-top/src/client/shims.d.ts delete mode 100644 plugins/features/plugin-catalog/src/client/shims.d.ts delete mode 100644 plugins/features/plugin-copy-code/src/client/shims.d.ts delete mode 100644 plugins/features/plugin-medium-zoom/src/client/shims.d.ts delete mode 100644 plugins/features/plugin-notice/src/client/shims.d.ts delete mode 100644 plugins/features/plugin-nprogress/src/client/shims.d.ts delete mode 100644 plugins/features/plugin-photo-swipe/src/client/shims.d.ts delete mode 100644 plugins/markdown/plugin-markdown-hint/src/client/shims.d.ts delete mode 100644 plugins/markdown/plugin-markdown-tab/src/client/shims.d.ts delete mode 100644 plugins/pwa/plugin-pwa/src/client/shims.d.ts delete mode 100644 plugins/tools/plugin-redirect/src/client/shims.d.ts diff --git a/plugins/blog/plugin-comment/src/shims-css.d.ts b/plugins/blog/plugin-comment/src/shims-css.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/blog/plugin-comment/src/shims-css.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/blog/plugin-comment/tsconfig.build.json b/plugins/blog/plugin-comment/tsconfig.build.json index 131c510e0f..f7f7fe795a 100644 --- a/plugins/blog/plugin-comment/tsconfig.build.json +++ b/plugins/blog/plugin-comment/tsconfig.build.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/development/plugin-theme-data/tsconfig.build.json b/plugins/development/plugin-theme-data/tsconfig.build.json index 154c993cba..c5132a703c 100644 --- a/plugins/development/plugin-theme-data/tsconfig.build.json +++ b/plugins/development/plugin-theme-data/tsconfig.build.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "baseUrl": ".", "paths": { "@internal/themeData": ["./src/client/themeData.d.ts"] }, diff --git a/plugins/features/plugin-back-to-top/src/client/shims.d.ts b/plugins/features/plugin-back-to-top/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/features/plugin-back-to-top/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/features/plugin-back-to-top/tsconfig.build.json b/plugins/features/plugin-back-to-top/tsconfig.build.json index 85b37d29a2..f7f7fe795a 100644 --- a/plugins/features/plugin-back-to-top/tsconfig.build.json +++ b/plugins/features/plugin-back-to-top/tsconfig.build.json @@ -2,7 +2,8 @@ "extends": "../../../tsconfig.build.json", "compilerOptions": { "rootDir": "./src", - "outDir": "./lib" + "outDir": "./lib", + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/features/plugin-catalog/src/client/shims.d.ts b/plugins/features/plugin-catalog/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/features/plugin-catalog/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/features/plugin-catalog/tsconfig.build.json b/plugins/features/plugin-catalog/tsconfig.build.json index 131c510e0f..f7f7fe795a 100644 --- a/plugins/features/plugin-catalog/tsconfig.build.json +++ b/plugins/features/plugin-catalog/tsconfig.build.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/features/plugin-copy-code/src/client/shims.d.ts b/plugins/features/plugin-copy-code/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/features/plugin-copy-code/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/features/plugin-copy-code/tsconfig.build.json b/plugins/features/plugin-copy-code/tsconfig.build.json index 131c510e0f..f7f7fe795a 100644 --- a/plugins/features/plugin-copy-code/tsconfig.build.json +++ b/plugins/features/plugin-copy-code/tsconfig.build.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/features/plugin-medium-zoom/src/client/shims.d.ts b/plugins/features/plugin-medium-zoom/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/features/plugin-medium-zoom/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/features/plugin-medium-zoom/tsconfig.build.json b/plugins/features/plugin-medium-zoom/tsconfig.build.json index 131c510e0f..f7f7fe795a 100644 --- a/plugins/features/plugin-medium-zoom/tsconfig.build.json +++ b/plugins/features/plugin-medium-zoom/tsconfig.build.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/features/plugin-notice/src/client/shims.d.ts b/plugins/features/plugin-notice/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/features/plugin-notice/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/features/plugin-notice/tsconfig.build.json b/plugins/features/plugin-notice/tsconfig.build.json index 85b37d29a2..f7f7fe795a 100644 --- a/plugins/features/plugin-notice/tsconfig.build.json +++ b/plugins/features/plugin-notice/tsconfig.build.json @@ -2,7 +2,8 @@ "extends": "../../../tsconfig.build.json", "compilerOptions": { "rootDir": "./src", - "outDir": "./lib" + "outDir": "./lib", + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/features/plugin-nprogress/src/client/shims.d.ts b/plugins/features/plugin-nprogress/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/features/plugin-nprogress/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/features/plugin-nprogress/tsconfig.build.json b/plugins/features/plugin-nprogress/tsconfig.build.json index 85b37d29a2..f7f7fe795a 100644 --- a/plugins/features/plugin-nprogress/tsconfig.build.json +++ b/plugins/features/plugin-nprogress/tsconfig.build.json @@ -2,7 +2,8 @@ "extends": "../../../tsconfig.build.json", "compilerOptions": { "rootDir": "./src", - "outDir": "./lib" + "outDir": "./lib", + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/features/plugin-photo-swipe/src/client/shims.d.ts b/plugins/features/plugin-photo-swipe/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/features/plugin-photo-swipe/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/features/plugin-photo-swipe/tsconfig.build.json b/plugins/features/plugin-photo-swipe/tsconfig.build.json index 131c510e0f..f7f7fe795a 100644 --- a/plugins/features/plugin-photo-swipe/tsconfig.build.json +++ b/plugins/features/plugin-photo-swipe/tsconfig.build.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/markdown/plugin-markdown-hint/src/client/shims.d.ts b/plugins/markdown/plugin-markdown-hint/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/markdown/plugin-markdown-hint/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/markdown/plugin-markdown-hint/tsconfig.build.json b/plugins/markdown/plugin-markdown-hint/tsconfig.build.json index 85b37d29a2..f7f7fe795a 100644 --- a/plugins/markdown/plugin-markdown-hint/tsconfig.build.json +++ b/plugins/markdown/plugin-markdown-hint/tsconfig.build.json @@ -2,7 +2,8 @@ "extends": "../../../tsconfig.build.json", "compilerOptions": { "rootDir": "./src", - "outDir": "./lib" + "outDir": "./lib", + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/markdown/plugin-markdown-tab/src/client/shims.d.ts b/plugins/markdown/plugin-markdown-tab/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/markdown/plugin-markdown-tab/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/markdown/plugin-markdown-tab/tsconfig.build.json b/plugins/markdown/plugin-markdown-tab/tsconfig.build.json index 85b37d29a2..f7f7fe795a 100644 --- a/plugins/markdown/plugin-markdown-tab/tsconfig.build.json +++ b/plugins/markdown/plugin-markdown-tab/tsconfig.build.json @@ -2,7 +2,8 @@ "extends": "../../../tsconfig.build.json", "compilerOptions": { "rootDir": "./src", - "outDir": "./lib" + "outDir": "./lib", + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/markdown/plugin-revealjs/src/shims.d.ts b/plugins/markdown/plugin-revealjs/src/shims.d.ts index 3a42a6ebf8..4003208c05 100644 --- a/plugins/markdown/plugin-revealjs/src/shims.d.ts +++ b/plugins/markdown/plugin-revealjs/src/shims.d.ts @@ -14,7 +14,3 @@ declare module '@temp/revealjs/index.js' { ...Promise<{ default: PluginFunction }>[], ] } - -declare module '*.css' { - export {} -} diff --git a/plugins/markdown/plugin-revealjs/tsconfig.build.json b/plugins/markdown/plugin-revealjs/tsconfig.build.json index 85b37d29a2..f7f7fe795a 100644 --- a/plugins/markdown/plugin-revealjs/tsconfig.build.json +++ b/plugins/markdown/plugin-revealjs/tsconfig.build.json @@ -2,7 +2,8 @@ "extends": "../../../tsconfig.build.json", "compilerOptions": { "rootDir": "./src", - "outDir": "./lib" + "outDir": "./lib", + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/pwa/plugin-pwa/src/client/shims.d.ts b/plugins/pwa/plugin-pwa/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/pwa/plugin-pwa/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/pwa/plugin-pwa/tsconfig.build.json b/plugins/pwa/plugin-pwa/tsconfig.build.json index 131c510e0f..f7f7fe795a 100644 --- a/plugins/pwa/plugin-pwa/tsconfig.build.json +++ b/plugins/pwa/plugin-pwa/tsconfig.build.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/plugins/search/plugin-docsearch/src/client/shims.d.ts b/plugins/search/plugin-docsearch/src/client/shims.d.ts index da7f174182..0ea686ef3b 100644 --- a/plugins/search/plugin-docsearch/src/client/shims.d.ts +++ b/plugins/search/plugin-docsearch/src/client/shims.d.ts @@ -1,7 +1,3 @@ declare module '@docsearch/css' { export {} } - -declare module '*.css' { - export {} -} diff --git a/plugins/search/plugin-docsearch/tsconfig.build.json b/plugins/search/plugin-docsearch/tsconfig.build.json index 499ef946fa..7149386567 100644 --- a/plugins/search/plugin-docsearch/tsconfig.build.json +++ b/plugins/search/plugin-docsearch/tsconfig.build.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"] } diff --git a/plugins/search/plugin-search/tsconfig.build.json b/plugins/search/plugin-search/tsconfig.build.json index 62d4c89381..332f839cd0 100644 --- a/plugins/search/plugin-search/tsconfig.build.json +++ b/plugins/search/plugin-search/tsconfig.build.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "baseUrl": ".", "paths": { "@internal/searchIndex": ["./src/client/searchIndex.d.ts"] }, diff --git a/plugins/tools/plugin-redirect/src/client/shims.d.ts b/plugins/tools/plugin-redirect/src/client/shims.d.ts deleted file mode 100644 index 390d0c9ff6..0000000000 --- a/plugins/tools/plugin-redirect/src/client/shims.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '*.css' { - export {} -} diff --git a/plugins/tools/plugin-redirect/tsconfig.build.json b/plugins/tools/plugin-redirect/tsconfig.build.json index 131c510e0f..f7f7fe795a 100644 --- a/plugins/tools/plugin-redirect/tsconfig.build.json +++ b/plugins/tools/plugin-redirect/tsconfig.build.json @@ -3,7 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [{ "path": "../../../tools/helper/tsconfig.build.json" }] diff --git a/themes/theme-default/src/client/shim.d.ts b/themes/theme-default/src/client/shim.d.ts index d66e02539a..b7176f864c 100644 --- a/themes/theme-default/src/client/shim.d.ts +++ b/themes/theme-default/src/client/shim.d.ts @@ -1,19 +1,11 @@ declare module '*.vue' { import type { ComponentOptions } from 'vue' - const comp: ComponentOptions - export default comp -} - -declare module '*.css' { - export {} + const component: ComponentOptions + export default component } declare module '*/styles/_variables.module.scss' { const cSSVariables: Record export default cSSVariables } - -declare module '*.scss' { - export {} -} diff --git a/themes/theme-default/tsconfig.build.json b/themes/theme-default/tsconfig.build.json index 2b6aeaf521..45c18b1a12 100644 --- a/themes/theme-default/tsconfig.build.json +++ b/themes/theme-default/tsconfig.build.json @@ -3,11 +3,10 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "baseUrl": ".", "paths": { "@theme/*": ["./src/client/components/*", "./src/client/composables/*.js"] }, - "types": ["vuepress/client-types"] + "types": ["vuepress/client-types", "vite/client", "webpack-env"] }, "include": ["./src"], "references": [ diff --git a/tools/highlighter-helper/tsconfig.build.json b/tools/highlighter-helper/tsconfig.build.json index 9e7c5d8194..78ad610eea 100644 --- a/tools/highlighter-helper/tsconfig.build.json +++ b/tools/highlighter-helper/tsconfig.build.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./lib", - "baseUrl": ".", "types": ["vuepress/client-types"] }, "include": ["./src"] From 99fe6f8519a4750ec34f5d1475c38169681d51ea Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Mon, 18 Nov 2024 21:52:48 +0800 Subject: [PATCH 3/5] chore: add define option for rollup --- scripts/rollup.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/rollup.ts b/scripts/rollup.ts index b97ad13ba7..951bee189b 100644 --- a/scripts/rollup.ts +++ b/scripts/rollup.ts @@ -21,11 +21,13 @@ export interface BundleOptions { inlineDynamicImports?: boolean moduleSideEffects?: ModuleSideEffectsOption preserveShebang?: boolean + define?: Record } export const rollupBundle = ( filePath: FileInfo | string, { + define, dts: enableDts = typeof filePath === 'object' ? !filePath.base.startsWith('cli/') && filePath.base !== 'cli' : !filePath.startsWith('cli/'), @@ -75,6 +77,7 @@ export const rollupBundle = ( charset: 'utf8', minify: true, target: 'node18.19.0', + define, }), ], From 13daf7efbdc34fae2f1287bfcff40d3858660172 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Mon, 18 Nov 2024 21:53:13 +0800 Subject: [PATCH 4/5] feat(helper): add env helpers --- tools/helper/src/client/utils/env.ts | 41 ++++++++++++++++++++++++++ tools/helper/src/client/utils/index.ts | 1 + 2 files changed, 42 insertions(+) create mode 100644 tools/helper/src/client/utils/env.ts diff --git a/tools/helper/src/client/utils/env.ts b/tools/helper/src/client/utils/env.ts new file mode 100644 index 0000000000..e00b83b4c0 --- /dev/null +++ b/tools/helper/src/client/utils/env.ts @@ -0,0 +1,41 @@ +export const checkIsMobile = (ua: string): boolean => + /\b(?:Android|iPhone)/i.test(ua) + +export const checkIsChromeWebView = (ua: string): boolean => + / wv\).+(chrome)\/([\w.]+)/i.test(ua) + +export const checkIsSafariMobile = (ua: string): boolean => + /version\/([\w.]+) .*mobile\/\w+ (safari)/i.test(ua) + +export const checkIsSafari = (ua: string): boolean => + /version\/([\w.]+) .*(mobile ?safari|safari)/i.test(ua) + +export const checkIsiPhone = (ua: string): boolean => + /\((ip(?:hone|od)[\w ]*);/i.test(ua) + +export const checkIsiPad = (ua: string): boolean => + [ + /\((ipad);[-\w),; ]+apple/i, + /applecoremedia\/[\w.]+ \((ipad)/i, + /\b(ipad)\d\d?,\d\d?[;\]].+ios/i, + ].some((item) => item.test(ua)) + +export const checkIsWindows = (ua: string): boolean => + [ + /microsoft (windows) (vista|xp)/i, + /(win(?=3|9|n)|win 9x )([nt\d.]+)/i, + /(windows) nt 6\.2; (arm)/i, + /(windows (?:phone(?: os)?|mobile))[/ ]?([\d.\w ]*)/i, + /(windows)[/ ]?([ntce\d. ]+\w)(?!.+xbox)/i, + ].some((item) => item.test(ua)) + +export const checkIsIOS = (ua: string): boolean => + [ + /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, + /cfnetwork\/.+darwin/i, + ].some((item) => item.test(ua)) + +export const checkIsMacOS = (ua: string): boolean => + [/(mac os x) ?([\w. ]*)/i, /(macintosh|mac_powerpc\b)(?!.+haiku)/i].some( + (item) => item.test(ua), + ) diff --git a/tools/helper/src/client/utils/index.ts b/tools/helper/src/client/utils/index.ts index 7b6a291b29..49547512a5 100644 --- a/tools/helper/src/client/utils/index.ts +++ b/tools/helper/src/client/utils/index.ts @@ -1,4 +1,5 @@ export * from './data.js' +export * from './env.js' export * from './getDarkmode.js' export * from './getHeaders.js' export * from './hasGlobalComponent.js' From f966926828f9670fe7f5b5288fdbdede6a77f26e Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Mon, 18 Nov 2024 21:53:42 +0800 Subject: [PATCH 5/5] chore(plugin-pwa): update exports --- plugins/pwa/plugin-pwa/src/client/components/icons.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pwa/plugin-pwa/src/client/components/icons.ts b/plugins/pwa/plugin-pwa/src/client/components/icons.ts index 90823c28f3..d78edceed7 100644 --- a/plugins/pwa/plugin-pwa/src/client/components/icons.ts +++ b/plugins/pwa/plugin-pwa/src/client/components/icons.ts @@ -1,7 +1,7 @@ import type { FunctionalComponent, VNode } from 'vue' import { h } from 'vue' -export interface SVGWrapperProps { +interface SVGWrapperProps { name?: string color?: string }