From f24379095dc03a2201ab0d47c17a284d16c4d609 Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Sat, 5 Nov 2022 11:39:30 -0600 Subject: [PATCH 1/3] docs(theme) use slots instead of prepend hack --- docs/.vitepress/scripts/dynamic-component.ts | 24 ----- docs/.vitepress/theme/FeathersLayout.vue | 103 ++++++------------- 2 files changed, 33 insertions(+), 94 deletions(-) delete mode 100644 docs/.vitepress/scripts/dynamic-component.ts diff --git a/docs/.vitepress/scripts/dynamic-component.ts b/docs/.vitepress/scripts/dynamic-component.ts deleted file mode 100644 index 074b5deeb4..0000000000 --- a/docs/.vitepress/scripts/dynamic-component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { h, render } from 'vue' - -/** - * Renders the provided `Component` using the same rendering context as the provided `app` instance. - * Refer to https://github.com/vuejs/core/issues/2097#issuecomment-707975628 - */ -export const prependDynamicComponent = function (app, Component, id, props, el) { - const firstTwoIds = [el.children?.[0], el.children?.[1]].map((el) => el?.id) - if (firstTwoIds.includes(id)) { - return - } - - const childTree: any = h(Component, props) - childTree.appContext = app._context - - // Creating a wrapper element here is clunky and ideally wouldn't be necessary - const div = document.createElement('div') - div.id = id - el.prepend(div) - - render(childTree, div) - - return childTree.component.proxy -} diff --git a/docs/.vitepress/theme/FeathersLayout.vue b/docs/.vitepress/theme/FeathersLayout.vue index c4211998ac..88db2b4b97 100644 --- a/docs/.vitepress/theme/FeathersLayout.vue +++ b/docs/.vitepress/theme/FeathersLayout.vue @@ -2,87 +2,50 @@ import DefaultTheme from 'vitepress/theme' import Footer from '../../components/Footer.vue' import { useGlobalLanguage, useGlobalDb } from './store' - -import { watch, onMounted, getCurrentInstance, nextTick } from 'vue' import Select from '../components/Select.vue' -import { prependDynamicComponent } from '../scripts/dynamic-component' -import { useRoute } from 'vitepress' const { Layout } = DefaultTheme -const route = useRoute() -const instance = getCurrentInstance() const activeGlobalLanguage = useGlobalLanguage() const activeGlobalDb = useGlobalDb() -/** - * Add the Global Language Select to the Left Nav. We watch for route changes to - * make sure the select is put in place when navigating from and to the home page. - */ -onMounted(() => { - const { app } = instance!.appContext - watch( - route, - () => { - // Use `nextTick` to wait until the sidebar has rendered - nextTick(() => { - const sidebar = document.querySelector('.VPSidebar') - if (sidebar) { - // Add the Database Adapter selector. Show only in the "Basics" guide - prependDynamicComponent( - app, - Select, - 'GlobalDbSelect', - { - value: activeGlobalDb.value, - label: 'Database', - onUpdateValue: (val: string) => { - if (activeGlobalDb.value !== val) { - activeGlobalDb.value = val - document.body.setAttribute('data-db', val) - // works around an SSR bug where the select resets to its SSR-hydrated state after a route change. - window.location = window.location - } - }, - showOnRoutePrefix: ['/guides/basics'], - options: [ - { value: 'sql', text: 'SQL' }, - { value: 'mongodb', text: 'MongoDB' } - ] - }, - sidebar - ) - // Always show the Language Select - prependDynamicComponent( - app, - Select, - 'GlobalLanguageSelect', - { - value: activeGlobalLanguage.value, - label: 'Code Language', - onUpdateValue: (val: string) => { - activeGlobalLanguage.value = val - document.body.setAttribute('data-language', val) - }, - options: [ - { value: 'ts', text: 'TypeScript' }, - { value: 'js', text: 'JavaScript' } - ] - }, - sidebar - ) - } - }) - }, - { immediate: true } - ) -}) +const handleGlobalLanguageUpdate = (val: string) => { + activeGlobalLanguage.value = val + document.body.setAttribute('data-language', val) +} +const handleGlobalDbUpdate = (val: string) => { + if (activeGlobalDb.value !== val) { + activeGlobalDb.value = val + document.body.setAttribute('data-db', val) + } +} From 804735d2ed59cd9ad93b1b49fb7563f55d3a193d Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Tue, 8 Nov 2022 14:24:55 -0700 Subject: [PATCH 2/3] chore: update deps --- docs/package-lock.json | 160 ++++++++++++++++++++++++++++++++--------- docs/package.json | 8 +-- 2 files changed, 129 insertions(+), 39 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index 88009e675b..5c4629daaf 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -8,7 +8,7 @@ "dependencies": { "@vueuse/core": "^9.4.0", "date-fns": "^2.29.3", - "element-plus": "^2.2.19", + "element-plus": "^2.2.20", "vue": "^3.2.41" }, "devDependencies": { @@ -22,13 +22,13 @@ "esno": "^0.16.3", "fast-glob": "^3.2.12", "https-localhost": "^4.7.1", - "sass": "^1.55.0", + "sass": "^1.56.0", "sitemap": "^7.1.1", "unocss": "^0.46.3", "unplugin-auto-import": "^0.11.4", "unplugin-vue-components": "^0.22.9", - "vite-plugin-pwa": "^0.13.1", - "vitepress": "^1.0.0-alpha.27", + "vite-plugin-pwa": "^0.13.3", + "vitepress": "^1.0.0-alpha.28", "workbox-window": "^6.5.4" } }, @@ -3842,9 +3842,9 @@ "license": "ISC" }, "node_modules/element-plus": { - "version": "2.2.19", - "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.2.19.tgz", - "integrity": "sha512-uN0gt9lUus/IHzu5J6vkbYoYJgUtU05osdtFv9RO27bHKOG5GN7dH6uA3OKfkQQ6R2sV8ZxY1rc9PH1X8Dgrow==", + "version": "2.2.20", + "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.2.20.tgz", + "integrity": "sha512-ludShd3f5kNRY4FLzeoNitLcwZ4qs2M/zwKeyeE7rUzZJAQ0BZtcT3SvZoEoBLmgxw9jHoonl4WIwon4UzhyRA==", "dependencies": { "@ctrl/tinycolor": "^3.4.1", "@element-plus/icons-vue": "^2.0.6", @@ -6302,9 +6302,9 @@ "license": "MIT" }, "node_modules/sass": { - "version": "1.55.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.55.0.tgz", - "integrity": "sha512-Pk+PMy7OGLs9WaxZGJMn7S96dvlyVBwwtToX895WmCpAOr5YiJYEUJfiJidMuKb613z2xNWcXCHEuOvjZbqC6A==", + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.56.0.tgz", + "integrity": "sha512-WFJ9XrpkcnqZcYuLRJh5qiV6ibQOR4AezleeEjTjMsCocYW59dEG19U3fwTTXxzi2Ed3yjPBp727hbbj53pHFw==", "dev": true, "dependencies": { "chokidar": ">=3.0.0 <4.0.0", @@ -7337,9 +7337,9 @@ } }, "node_modules/vite": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/vite/-/vite-3.2.2.tgz", - "integrity": "sha512-pLrhatFFOWO9kS19bQ658CnRYzv0WLbsPih6R+iFeEEhDOuYgYCX2rztUViMz/uy/V8cLCJvLFeiOK7RJEzHcw==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-3.2.3.tgz", + "integrity": "sha512-h8jl1TZ76eGs3o2dIBSsvXDLb1m/Ec1iej8ZMdz+PsaFUsftZeWe2CZOI3qogEsMNaywc17gu0q6cQDzh/weCQ==", "dev": true, "dependencies": { "esbuild": "^0.15.9", @@ -7357,6 +7357,7 @@ "fsevents": "~2.3.2" }, "peerDependencies": { + "@types/node": ">= 14", "less": "*", "sass": "*", "stylus": "*", @@ -7364,6 +7365,9 @@ "terser": "^5.4.0" }, "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, "less": { "optional": true }, @@ -7382,10 +7386,12 @@ } }, "node_modules/vite-plugin-pwa": { - "version": "0.13.1", + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.13.3.tgz", + "integrity": "sha512-cjWXpZ7slAY14OKz7M8XdgTIi9wjf6OD6NkhiMAc+ogxnbUrecUwLdRtfGPCPsN2ftut5gaN1jTghb11p6IQAA==", "dev": true, - "license": "MIT", "dependencies": { + "@rollup/plugin-replace": "^4.0.0", "debug": "^4.3.4", "fast-glob": "^3.2.11", "pretty-bytes": "^6.0.0", @@ -7402,6 +7408,36 @@ "workbox-window": "^6.5.4" } }, + "node_modules/vite-plugin-pwa/node_modules/@rollup/plugin-replace": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-4.0.0.tgz", + "integrity": "sha512-+rumQFiaNac9y64OHtkHGmdjm7us9bo1PlbgQfdihQtuNxzjpaB064HbRnewUOggLQxVCCyINfStkgmBeQpv1g==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "magic-string": "^0.25.7" + }, + "peerDependencies": { + "rollup": "^1.20.0 || ^2.0.0" + } + }, + "node_modules/vite-plugin-pwa/node_modules/@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "dependencies": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0" + } + }, "node_modules/vite-plugin-pwa/node_modules/debug": { "version": "4.3.4", "dev": true, @@ -7418,6 +7454,21 @@ } } }, + "node_modules/vite-plugin-pwa/node_modules/estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, + "node_modules/vite-plugin-pwa/node_modules/magic-string": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", + "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", + "dev": true, + "dependencies": { + "sourcemap-codec": "^1.4.8" + } + }, "node_modules/vite-plugin-pwa/node_modules/ms": { "version": "2.1.2", "dev": true, @@ -7475,19 +7526,19 @@ } }, "node_modules/vitepress": { - "version": "1.0.0-alpha.27", - "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.0-alpha.27.tgz", - "integrity": "sha512-7/PwlIRZANvB2uyi8oi4oMXuH84g2/pAaoymb+ObBCs60m0oVxKMPO28w7R/svqSnnE+bNDOuLzTCXt7gn513g==", + "version": "1.0.0-alpha.28", + "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.0-alpha.28.tgz", + "integrity": "sha512-pvbLssDMgLUN1terajmPlFBxHSDGO4DqwexKbjFyr7LeELerVuwGrG6F2J1hxmwOlbpLd1kHXEDqGm9JX/kTDQ==", "dev": true, "dependencies": { "@docsearch/css": "^3.3.0", "@docsearch/js": "^3.3.0", - "@vitejs/plugin-vue": "^3.1.2", + "@vitejs/plugin-vue": "^3.2.0", "@vue/devtools-api": "^6.4.5", "@vueuse/core": "^9.4.0", "body-scroll-lock": "4.0.0-beta.0", "shiki": "^0.11.1", - "vite": "^3.1.8", + "vite": "^3.2.3", "vue": "^3.2.41" }, "bin": { @@ -10450,9 +10501,9 @@ "dev": true }, "element-plus": { - "version": "2.2.19", - "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.2.19.tgz", - "integrity": "sha512-uN0gt9lUus/IHzu5J6vkbYoYJgUtU05osdtFv9RO27bHKOG5GN7dH6uA3OKfkQQ6R2sV8ZxY1rc9PH1X8Dgrow==", + "version": "2.2.20", + "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.2.20.tgz", + "integrity": "sha512-ludShd3f5kNRY4FLzeoNitLcwZ4qs2M/zwKeyeE7rUzZJAQ0BZtcT3SvZoEoBLmgxw9jHoonl4WIwon4UzhyRA==", "requires": { "@ctrl/tinycolor": "^3.4.1", "@element-plus/icons-vue": "^2.0.6", @@ -12010,9 +12061,9 @@ "dev": true }, "sass": { - "version": "1.55.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.55.0.tgz", - "integrity": "sha512-Pk+PMy7OGLs9WaxZGJMn7S96dvlyVBwwtToX895WmCpAOr5YiJYEUJfiJidMuKb613z2xNWcXCHEuOvjZbqC6A==", + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.56.0.tgz", + "integrity": "sha512-WFJ9XrpkcnqZcYuLRJh5qiV6ibQOR4AezleeEjTjMsCocYW59dEG19U3fwTTXxzi2Ed3yjPBp727hbbj53pHFw==", "dev": true, "requires": { "chokidar": ">=3.0.0 <4.0.0", @@ -12683,9 +12734,9 @@ "dev": true }, "vite": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/vite/-/vite-3.2.2.tgz", - "integrity": "sha512-pLrhatFFOWO9kS19bQ658CnRYzv0WLbsPih6R+iFeEEhDOuYgYCX2rztUViMz/uy/V8cLCJvLFeiOK7RJEzHcw==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-3.2.3.tgz", + "integrity": "sha512-h8jl1TZ76eGs3o2dIBSsvXDLb1m/Ec1iej8ZMdz+PsaFUsftZeWe2CZOI3qogEsMNaywc17gu0q6cQDzh/weCQ==", "dev": true, "requires": { "esbuild": "^0.15.9", @@ -12731,9 +12782,12 @@ } }, "vite-plugin-pwa": { - "version": "0.13.1", + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.13.3.tgz", + "integrity": "sha512-cjWXpZ7slAY14OKz7M8XdgTIi9wjf6OD6NkhiMAc+ogxnbUrecUwLdRtfGPCPsN2ftut5gaN1jTghb11p6IQAA==", "dev": true, "requires": { + "@rollup/plugin-replace": "^4.0.0", "debug": "^4.3.4", "fast-glob": "^3.2.11", "pretty-bytes": "^6.0.0", @@ -12742,6 +12796,27 @@ "workbox-window": "^6.5.4" }, "dependencies": { + "@rollup/plugin-replace": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-4.0.0.tgz", + "integrity": "sha512-+rumQFiaNac9y64OHtkHGmdjm7us9bo1PlbgQfdihQtuNxzjpaB064HbRnewUOggLQxVCCyINfStkgmBeQpv1g==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "magic-string": "^0.25.7" + } + }, + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + } + }, "debug": { "version": "4.3.4", "dev": true, @@ -12749,6 +12824,21 @@ "ms": "2.1.2" } }, + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, + "magic-string": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", + "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", + "dev": true, + "requires": { + "sourcemap-codec": "^1.4.8" + } + }, "ms": { "version": "2.1.2", "dev": true @@ -12756,19 +12846,19 @@ } }, "vitepress": { - "version": "1.0.0-alpha.27", - "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.0-alpha.27.tgz", - "integrity": "sha512-7/PwlIRZANvB2uyi8oi4oMXuH84g2/pAaoymb+ObBCs60m0oVxKMPO28w7R/svqSnnE+bNDOuLzTCXt7gn513g==", + "version": "1.0.0-alpha.28", + "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.0-alpha.28.tgz", + "integrity": "sha512-pvbLssDMgLUN1terajmPlFBxHSDGO4DqwexKbjFyr7LeELerVuwGrG6F2J1hxmwOlbpLd1kHXEDqGm9JX/kTDQ==", "dev": true, "requires": { "@docsearch/css": "^3.3.0", "@docsearch/js": "^3.3.0", - "@vitejs/plugin-vue": "^3.1.2", + "@vitejs/plugin-vue": "^3.2.0", "@vue/devtools-api": "^6.4.5", "@vueuse/core": "^9.4.0", "body-scroll-lock": "4.0.0-beta.0", "shiki": "^0.11.1", - "vite": "^3.1.8", + "vite": "^3.2.3", "vue": "^3.2.41" } }, diff --git a/docs/package.json b/docs/package.json index 467f111c5f..fae70a2569 100644 --- a/docs/package.json +++ b/docs/package.json @@ -12,7 +12,7 @@ "dependencies": { "@vueuse/core": "^9.4.0", "date-fns": "^2.29.3", - "element-plus": "^2.2.19", + "element-plus": "^2.2.20", "vue": "^3.2.41" }, "devDependencies": { @@ -26,13 +26,13 @@ "esno": "^0.16.3", "fast-glob": "^3.2.12", "https-localhost": "^4.7.1", - "sass": "^1.55.0", + "sass": "^1.56.0", "sitemap": "^7.1.1", "unocss": "^0.46.3", "unplugin-auto-import": "^0.11.4", "unplugin-vue-components": "^0.22.9", - "vite-plugin-pwa": "^0.13.1", - "vitepress": "^1.0.0-alpha.27", + "vite-plugin-pwa": "^0.13.3", + "vitepress": "^1.0.0-alpha.28", "workbox-window": "^6.5.4" } } From a47d999a051ca16fd7c0b6857116acbe7177b974 Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Tue, 8 Nov 2022 14:42:42 -0700 Subject: [PATCH 3/3] docs(theme): always show database select --- docs/.vitepress/theme/FeathersLayout.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/.vitepress/theme/FeathersLayout.vue b/docs/.vitepress/theme/FeathersLayout.vue index 88db2b4b97..f1e23bcd8c 100644 --- a/docs/.vitepress/theme/FeathersLayout.vue +++ b/docs/.vitepress/theme/FeathersLayout.vue @@ -38,7 +38,6 @@ const handleGlobalDbUpdate = (val: string) => { id="GlobalDbSelect" :value="activeGlobalDb" label="Database" - :showOnRoutePrefix="['/guides/basics']" :options="[ { value: 'sql', text: 'SQL' }, { value: 'mongodb', text: 'MongoDB' }