From e7b91220b63345024b0c7fa42b9b3e82da69ccaa Mon Sep 17 00:00:00 2001 From: Lubos Date: Sun, 17 Aug 2025 20:26:13 +0800 Subject: [PATCH] docs: fix versioned clients and plugins --- docs/.vitepress/config/index.ts | 19 +- docs/.vitepress/config/shared.ts | 19 ++ .../theme/{ => components}/Layout.vue | 0 docs/.vitepress/theme/custom.css | 8 + docs/.vitepress/theme/index.ts | 2 +- docs/tsconfig.json | 1 + patches/vitepress.patch | 288 ++++++++++++++++++ pnpm-lock.yaml | 24 +- 8 files changed, 331 insertions(+), 30 deletions(-) rename docs/.vitepress/theme/{ => components}/Layout.vue (100%) create mode 100644 patches/vitepress.patch diff --git a/docs/.vitepress/config/index.ts b/docs/.vitepress/config/index.ts index 164d2221d..000275a7e 100644 --- a/docs/.vitepress/config/index.ts +++ b/docs/.vitepress/config/index.ts @@ -1,9 +1,7 @@ -import path from 'node:path'; - import { defineConfig } from 'vitepress'; -import en from './en'; -import shared from './shared'; +import en from './en.js'; +import shared from './shared.js'; export default defineConfig({ ...shared, @@ -11,17 +9,4 @@ export default defineConfig({ ...shared.locales, root: { label: 'English', ...en }, }, - vite: { - ...shared.vite, - resolve: { - ...shared.vite?.resolve, - alias: { - ...shared.vite?.resolve?.alias, - '@components': path.resolve(__dirname, '..', 'theme', 'components'), - '@data': path.resolve(__dirname, '..', '..', 'data'), - '@versions': path.resolve(__dirname, '..', 'theme', 'versions'), - }, - preserveSymlinks: true, - }, - }, }); diff --git a/docs/.vitepress/config/shared.ts b/docs/.vitepress/config/shared.ts index 615d391ca..9d3b52609 100644 --- a/docs/.vitepress/config/shared.ts +++ b/docs/.vitepress/config/shared.ts @@ -1,3 +1,5 @@ +import path from 'node:path'; + import { defineConfig, type HeadConfig } from 'vitepress'; import llmstxt from 'vitepress-plugin-llms'; @@ -115,5 +117,22 @@ export default defineConfig({ }, }), ], + resolve: { + alias: [ + { + find: '@components', + replacement: path.resolve(__dirname, '..', 'theme', 'components'), + }, + { + find: '@data', + replacement: path.resolve(__dirname, '..', '..', 'data'), + }, + { + find: '@versions', + replacement: path.resolve(__dirname, '..', 'theme', 'versions'), + }, + ], + preserveSymlinks: true, + }, }, }); diff --git a/docs/.vitepress/theme/Layout.vue b/docs/.vitepress/theme/components/Layout.vue similarity index 100% rename from docs/.vitepress/theme/Layout.vue rename to docs/.vitepress/theme/components/Layout.vue diff --git a/docs/.vitepress/theme/custom.css b/docs/.vitepress/theme/custom.css index d0f16a4ec..d5395014e 100644 --- a/docs/.vitepress/theme/custom.css +++ b/docs/.vitepress/theme/custom.css @@ -415,3 +415,11 @@ footer.VPDocFooter > .edit-info > .last-updated { /* don't render last updated date */ display: none; } + +.DocSearch-Modal { + display: flex; +} + +.DocSearch-Footer { + position: initial; +} diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 37e486cc9..cbf7d3177 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -5,7 +5,7 @@ import DefaultTheme from 'vitepress/theme'; // custom CSS must be imported after default theme to correctly apply styles import './custom.css'; -import Layout from './Layout.vue'; +import Layout from './components/Layout.vue'; export default { Layout, diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 174e77795..f68274494 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "baseUrl": ".", "esModuleInterop": true, + "module": "nodenext", "paths": { "@components/*": ["./.vitepress/theme/components/*"], "@data": ["./data/*"], diff --git a/patches/vitepress.patch b/patches/vitepress.patch new file mode 100644 index 000000000..b6f6db6bb --- /dev/null +++ b/patches/vitepress.patch @@ -0,0 +1,288 @@ +diff --git a/dist/client/shared.js b/dist/client/shared.js +index f65eb22fe2b0dfeb9bd823c00c737f5035f2c891..16a45edcf11b71881b31f1203add291a2c447d22 100644 +--- a/dist/client/shared.js ++++ b/dist/client/shared.js +@@ -16,6 +16,7 @@ export const notFoundPageData = { + lastUpdated: 0, + isNotFound: true + }; ++const versionedPaths = ['clients', 'plugins']; + export function isActive(currentPath, matchPath, asRegex = false) { + if (matchPath === undefined) { + return false; +@@ -24,8 +25,19 @@ export function isActive(currentPath, matchPath, asRegex = false) { + if (asRegex) { + return new RegExp(matchPath).test(currentPath); + } +- if (normalize(matchPath) !== currentPath) { +- return false; ++ const normalizedMatchPath = normalize(matchPath); ++ if (normalizedMatchPath !== currentPath) { ++ const currentPathParts = currentPath.split('/'); ++ if (currentPathParts.length > 3 && ++ versionedPaths.some((entry) => entry === currentPathParts[2])) { ++ currentPath = currentPathParts.slice(0, 4).join('/'); ++ if (normalizedMatchPath !== currentPath) { ++ return false; ++ } ++ } ++ else { ++ return false; ++ } + } + const hashMatch = matchPath.match(HASH_RE); + if (hashMatch) { +diff --git a/dist/node/chunk-CwUP9ZhX.js b/dist/node/chunk-CwUP9ZhX.js +index e8b4954d00f247fb852096bb1f8f077fcfc1f93f..8db594d1bdaac76359656a95ac96cd98161b1062 100644 +--- a/dist/node/chunk-CwUP9ZhX.js ++++ b/dist/node/chunk-CwUP9ZhX.js +@@ -2053,7 +2053,7 @@ function requireBrowser () { + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } +- }; ++ }; + } (browser, browser.exports)); + return browser.exports; + } +@@ -2328,7 +2328,7 @@ function requireNode () { + formatters.O = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts); +- }; ++ }; + } (node, node.exports)); + return node.exports; + } +@@ -3522,7 +3522,7 @@ function requireFs () { + 'fs.realpath.native is not a function. Is fs being monkey-patched?', + 'Warning', 'fs-extra-WARN0003' + ); +- } ++ } + } (fs$1)); + return fs$1; + } +@@ -6185,7 +6185,7 @@ class AST { + const aps = addPatternStart; + // check if we have a possibility of matching . or .., + // and prevent that. +- const needNoTrav = ++ const needNoTrav = + // dots are allowed, and the pattern starts with [ or . + (dot && aps.has(src.charAt(0))) || + // the pattern starts with \., and then [ or . +@@ -8616,11 +8616,11 @@ class LRUCache { + b.__abortController instanceof AC); + } + async fetch(k, fetchOptions = {}) { +- const { ++ const { + // get options +- allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, ++ allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, + // set options +- ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL, ++ ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL, + // fetch exclusive options + noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions; + if (!this.#hasFetchMethod) { +@@ -14468,7 +14468,7 @@ function requireUtils$4 () { + } + + return last; +- }; ++ }; + } (utils$5)); + return utils$5; + } +@@ -17226,7 +17226,7 @@ function requireDist$1 () { + exports.fdir = void 0; + const builder_1 = requireBuilder(); + Object.defineProperty(exports, "fdir", { enumerable: true, get: function () { return builder_1.Builder; } }); +- __exportStar(requireTypes$1(), exports); ++ __exportStar(requireTypes$1(), exports); + } (dist$1)); + return dist$1; + } +@@ -18267,6 +18267,7 @@ const notFoundPageData = { + lastUpdated: 0, + isNotFound: true + }; ++const versionedPaths = ["clients", "plugins"]; + function isActive(currentPath, matchPath, asRegex = false) { + if (matchPath === void 0) { + return false; +@@ -18275,8 +18276,17 @@ function isActive(currentPath, matchPath, asRegex = false) { + if (asRegex) { + return new RegExp(matchPath).test(currentPath); + } +- if (normalize$1(matchPath) !== currentPath) { +- return false; ++ const normalizedMatchPath = normalize$1(matchPath); ++ if (normalizedMatchPath !== currentPath) { ++ const currentPathParts = currentPath.split("/"); ++ if (currentPathParts.length > 3 && versionedPaths.some((entry) => entry === currentPathParts[2])) { ++ currentPath = currentPathParts.slice(0, 4).join("/"); ++ if (normalizedMatchPath !== currentPath) { ++ return false; ++ } ++ } else { ++ return false; ++ } + } + const hashMatch = matchPath.match(HASH_RE); + if (hashMatch) { +@@ -23631,7 +23641,7 @@ function requireEngines () { + stringify: function() { + throw new Error('stringifying JavaScript is not supported'); + } +- }; ++ }; + } (engines)); + return engines.exports; + } +@@ -23731,7 +23741,7 @@ function requireUtils$2 () { + exports.startsWith = function(str, substr, len) { + if (typeof len !== 'number') len = substr.length; + return str.slice(0, len) === substr; +- }; ++ }; + } (utils$3)); + return utils$3; + } +@@ -25043,7 +25053,7 @@ const decodeMap = new Map([ + /** + * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point. + */ +-const fromCodePoint$1 = ++const fromCodePoint$1 = + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins + (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : function (codePoint) { + let output = ""; +@@ -25135,7 +25145,7 @@ var DecodingMode; + class EntityDecoder { + constructor( + /** The tree used to decode entities. */ +- decodeTree, ++ decodeTree, + /** + * The function that is called when a codepoint is decoded. + * +@@ -25145,7 +25155,7 @@ class EntityDecoder { + * @param codepoint The decoded codepoint. + * @param consumed The number of bytes consumed by the decoder. + */ +- emitCodePoint, ++ emitCodePoint, + /** An object that is used to produce errors. */ + errors) { + this.decodeTree = decodeTree; +@@ -25458,7 +25468,7 @@ function getDecoder(decodeTree) { + while ((offset = str.indexOf("&", offset)) >= 0) { + ret += str.slice(lastIndex, offset); + decoder.startEntity(decodeMode); +- const len = decoder.write(str, ++ const len = decoder.write(str, + // Skip the "&" + offset + 1); + if (len < 0) { +@@ -38931,7 +38941,7 @@ class SignalExit extends SignalExitBase { + const process$1 = globalThis.process; + // wrap so that we call the method on the actual handler, without + // exporting it directly. +-const { ++const { + /** + * Called when the process is exiting, whether via signal, explicit + * exit, or running out of stuff to do. +@@ -41070,7 +41080,7 @@ function requireEastasianwidth () { + eawLen += charLen; + } + return result; +- }; ++ }; + } (eastasianwidth)); + return eastasianwidth.exports; + } +@@ -42826,7 +42836,7 @@ function requireTypes () { + IndexTagNames["sitemapindex"] = "sitemapindex"; + IndexTagNames["loc"] = "loc"; + IndexTagNames["lastmod"] = "lastmod"; +- })(exports.IndexTagNames || (exports.IndexTagNames = {})); ++ })(exports.IndexTagNames || (exports.IndexTagNames = {})); + } (types)); + return types; + } +@@ -42840,7 +42850,7 @@ function requireSitemapXml () { + hasRequiredSitemapXml = 1; + Object.defineProperty(sitemapXml, "__esModule", { value: true }); + sitemapXml.element = sitemapXml.ctag = sitemapXml.otag = sitemapXml.text = void 0; +- const invalidXMLUnicodeRegex = ++ const invalidXMLUnicodeRegex = + // eslint-disable-next-line no-control-regex + /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u0084\u0086-\u009F\uD800-\uDFFF\uFDD0-\uFDDF\u{1FFFE}-\u{1FFFF}\u{2FFFE}-\u{2FFFF}\u{3FFFE}-\u{3FFFF}\u{4FFFE}-\u{4FFFF}\u{5FFFE}-\u{5FFFF}\u{6FFFE}-\u{6FFFF}\u{7FFFE}-\u{7FFFF}\u{8FFFE}-\u{8FFFF}\u{9FFFE}-\u{9FFFF}\u{AFFFE}-\u{AFFFF}\u{BFFFE}-\u{BFFFF}\u{CFFFE}-\u{CFFFF}\u{DFFFE}-\u{DFFFF}\u{EFFFE}-\u{EFFFF}\u{FFFFE}-\u{FFFFF}\u{10FFFE}-\u{10FFFF}]/gu; + const amp = /&/g; +@@ -43586,7 +43596,7 @@ function requireSitemapStream () { + }); + }); + } +- exports.streamToPromise = streamToPromise; ++ exports.streamToPromise = streamToPromise; + } (sitemapStream)); + return sitemapStream; + } +@@ -43809,7 +43819,7 @@ function requireSitemapIndexStream () { + }); + } + } +- exports.SitemapAndIndexStream = SitemapAndIndexStream; ++ exports.SitemapAndIndexStream = SitemapAndIndexStream; + } (sitemapIndexStream)); + return sitemapIndexStream; + } +@@ -45470,7 +45480,7 @@ function requireSax () { + } + }()); + } +- })(exports); ++ })(exports); + } (sax)); + return sax; + } +@@ -46277,7 +46287,7 @@ function requireSitemapSimple () { + } + }; + exports.simpleSitemapAndIndex = simpleSitemapAndIndex; +- exports.default = exports.simpleSitemapAndIndex; ++ exports.default = exports.simpleSitemapAndIndex; + } (sitemapSimple)); + return sitemapSimple; + } +@@ -46333,7 +46343,7 @@ function requireDist () { + Object.defineProperty(exports, "XMLToSitemapIndexStream", { enumerable: true, get: function () { return sitemap_index_parser_1.XMLToSitemapIndexStream; } }); + Object.defineProperty(exports, "IndexObjectStreamToJSON", { enumerable: true, get: function () { return sitemap_index_parser_1.IndexObjectStreamToJSON; } }); + var sitemap_simple_1 = requireSitemapSimple(); +- Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function () { return sitemap_simple_1.simpleSitemapAndIndex; } }); ++ Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function () { return sitemap_simple_1.simpleSitemapAndIndex; } }); + } (dist)); + return dist; + } +@@ -48930,7 +48940,7 @@ function requireLodash_template () { + return false; + } + +- module.exports = template; ++ module.exports = template; + } (lodash_template, lodash_template.exports)); + return lodash_template.exports; + } +@@ -49165,7 +49175,7 @@ function requirePostcssPrefixSelector () { + + return { + postcssPlugin: 'postcss-prefix-selector', +- prepare(result) { ++ prepare(result) { + const root = result.root; + const file = root.source.input.file; + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7d8bd3cb2..0e7658b80 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17817,7 +17817,7 @@ snapshots: '@vue-macros/common@1.16.1(vue@3.5.13(typescript@5.8.3))': dependencies: - '@vue/compiler-sfc': 3.5.13 + '@vue/compiler-sfc': 3.5.18 ast-kit: 1.4.2 local-pkg: 1.1.1 magic-string-ast: 0.7.1 @@ -17838,7 +17838,7 @@ snapshots: '@babel/types': 7.26.10 '@vue/babel-helper-vue-transform-on': 1.4.0 '@vue/babel-plugin-resolve-type': 1.4.0(@babel/core@7.26.10) - '@vue/shared': 3.5.13 + '@vue/shared': 3.5.18 optionalDependencies: '@babel/core': 7.26.10 transitivePeerDependencies: @@ -17851,13 +17851,13 @@ snapshots: '@babel/helper-module-imports': 7.25.9 '@babel/helper-plugin-utils': 7.26.5 '@babel/parser': 7.26.10 - '@vue/compiler-sfc': 3.5.13 + '@vue/compiler-sfc': 3.5.18 transitivePeerDependencies: - supports-color '@vue/compiler-core@3.5.13': dependencies: - '@babel/parser': 7.26.10 + '@babel/parser': 7.28.3 '@vue/shared': 3.5.13 entities: 4.5.0 estree-walker: 2.0.2 @@ -17883,14 +17883,14 @@ snapshots: '@vue/compiler-sfc@3.5.13': dependencies: - '@babel/parser': 7.26.10 + '@babel/parser': 7.28.3 '@vue/compiler-core': 3.5.13 '@vue/compiler-dom': 3.5.13 '@vue/compiler-ssr': 3.5.13 '@vue/shared': 3.5.13 estree-walker: 2.0.2 magic-string: 0.30.17 - postcss: 8.5.4 + postcss: 8.5.6 source-map-js: 1.2.1 '@vue/compiler-sfc@3.5.18': @@ -18012,9 +18012,9 @@ snapshots: '@vue/language-core@2.2.0(typescript@5.8.3)': dependencies: '@volar/language-core': 2.4.12 - '@vue/compiler-dom': 3.5.13 + '@vue/compiler-dom': 3.5.18 '@vue/compiler-vue2': 2.7.16 - '@vue/shared': 3.5.13 + '@vue/shared': 3.5.18 alien-signals: 0.4.14 minimatch: 9.0.5 muggle-string: 0.4.1 @@ -18403,7 +18403,7 @@ snapshots: ast-kit@1.4.2: dependencies: - '@babel/parser': 7.26.10 + '@babel/parser': 7.28.3 pathe: 2.0.3 ast-types-flow@0.0.8: {} @@ -22576,7 +22576,7 @@ snapshots: '@unhead/shared': 1.11.20 '@unhead/ssr': 1.11.20 '@unhead/vue': 1.11.20(vue@3.5.13(typescript@5.8.3)) - '@vue/shared': 3.5.13 + '@vue/shared': 3.5.18 acorn: 8.14.0 c12: 2.0.1(magicast@0.3.5) chokidar: 4.0.3 @@ -22696,7 +22696,7 @@ snapshots: '@unhead/shared': 1.11.20 '@unhead/ssr': 1.11.20 '@unhead/vue': 1.11.20(vue@3.5.13(typescript@5.8.3)) - '@vue/shared': 3.5.13 + '@vue/shared': 3.5.18 acorn: 8.14.0 c12: 2.0.1(magicast@0.3.5) chokidar: 4.0.3 @@ -25894,7 +25894,7 @@ snapshots: '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.26.10) '@babel/plugin-transform-typescript': 7.26.8(@babel/core@7.26.10) '@vue/babel-plugin-jsx': 1.4.0(@babel/core@7.26.10) - '@vue/compiler-dom': 3.5.13 + '@vue/compiler-dom': 3.5.18 kolorist: 1.8.0 magic-string: 0.30.17 vite: 7.1.2(@types/node@22.10.5)(jiti@2.4.2)(less@4.2.2)(sass@1.85.0)(terser@5.39.0)(yaml@2.8.0) -- 2.51.2