From b28f195759e9763b44b3b9600d03ead7dd437302 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Fri, 16 Aug 2024 22:42:15 +0200 Subject: [PATCH] Starlight sidebar support (#167) --- .changeset/two-queens-sing.md | 5 + README.md | 8 +- components/starlight/StarlightConnector.astro | 4 + package-lock.json | 111 ++++++++++++++---- package.json | 8 +- 5 files changed, 106 insertions(+), 30 deletions(-) create mode 100644 .changeset/two-queens-sing.md diff --git a/.changeset/two-queens-sing.md b/.changeset/two-queens-sing.md new file mode 100644 index 0000000..665b5d0 --- /dev/null +++ b/.changeset/two-queens-sing.md @@ -0,0 +1,5 @@ +--- +'astro-vtbot': patch +--- + +Starlight support: Honor the persisted sidebar state introduced with Starlight v0.26.0 diff --git a/README.md b/README.md index 2b5b8d4..7a5fcc5 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,14 @@ A current deployment of tech demos and the documentation can be found at https:/ ## !!! NEW TRICKS ✨ IN THE BAG 👜 !!! -This release introduces an updated version of the Inspection Chamber, now packed with new, shiny displays and knobs. The Chamber is steadily maturing, evolving from a cool prototype into a cool, reliable tool. +V1.18.5 throws a colorful mix of things into the bag. Most notable is support for Starlight's persisted sidebar state, but also various improvements to the chamber and view transition name encoding. See the changelog for details! -See your view transitions like never before: examine every detail, reveal, debug, and optimize! Now, drill down into the effects of each pseudo-element introduced by the view transition API and even selectively toggle individual animations to better understand what’s happening! +## Recently Learned Tricks ## +> V1.18.4 introduced an updated version of the Inspection Chamber, now packed with new, shiny displays and knobs. The Chamber is steadily maturing, evolving from a cool prototype into a cool, reliable tool. + +> See your view transitions like never before: examine every detail, reveal, debug, and optimize! Now, drill down into the effects of each pseudo-element introduced by the view transition API and even selectively toggle individual animations to better understand what’s happening! -## Recently Learned Tricks ## > Summon the Inspection Chamber as a component ([<InspectionChamber />](https://events-3bg.pages.dev/library/InspectionChamber/)) or [install The Bag as an integration!](hhttps://events-3bg.pages.dev/library/Installation/#installing-as-an-astro-integration) and access the Chamber from the devToolbar! diff --git a/components/starlight/StarlightConnector.astro b/components/starlight/StarlightConnector.astro index 395474f..b425253 100644 --- a/components/starlight/StarlightConnector.astro +++ b/components/starlight/StarlightConnector.astro @@ -112,6 +112,10 @@ oldContent?.removeAttribute('data-vtbot-replace'); newContent?.removeAttribute('data-vtbot-replace'); } + + [...newDoc.scripts] + .filter((s) => (s.textContent ?? '').includes('sl-sidebar-state-persist')) + .forEach((s) => (s.setAttribute("data-astro-rerun",""))); } else { /* check for known extensions */ updateMultiSidebar(document); diff --git a/package-lock.json b/package-lock.json index 6f560b9..9dd8839 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,17 +9,17 @@ "version": "1.8.4", "license": "ISC", "dependencies": { - "@vtbag/inspection-chamber": "^1.0.6" + "@vtbag/inspection-chamber": "^1.0.7" }, "devDependencies": { "@astrojs/check": "^0.9.2", - "@astrojs/starlight": "^0.25.5", + "@astrojs/starlight": "^0.26.0", "@changesets/changelog-github": "0.5.0", "@changesets/cli": "^2.27.7", "@playwright/test": "^1.46.0", "@types/dom-view-transitions": "^1.0.5", - "@types/node": "^22.2.0", - "astro": "^4.13.3", + "@types/node": "^22.4.0", + "astro": "^4.14.2", "prettier": "^3.3.3", "prettier-plugin-astro": "^0.14.1", "typescript": "^5.5.4" @@ -191,9 +191,9 @@ } }, "node_modules/@astrojs/starlight": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@astrojs/starlight/-/starlight-0.25.5.tgz", - "integrity": "sha512-JQsfoqRUX/HBpOW8LWPdiIxcfXZ5HOvi4Dz4Ez61U99hDyX3Ix2Q+pmsek1sH5R1MHWx/wlki2VPEqidtKXyiQ==", + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/@astrojs/starlight/-/starlight-0.26.0.tgz", + "integrity": "sha512-xg5XT2NaRkM62Rp1qgcEivmJh/D+kZyzU3jJKNZFsZWshNYk67SB9nTOxeYJTmrGt4bILxTKLu9Kj+jPD/DJ0w==", "dev": true, "dependencies": { "@astrojs/mdx": "^3.1.3", @@ -1964,6 +1964,12 @@ "node": ">= 8" } }, + "node_modules/@oslojs/encoding": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@oslojs/encoding/-/encoding-0.4.1.tgz", + "integrity": "sha512-hkjo6MuIK/kQR5CrGNdAPZhS01ZCXuWDRJ187zh6qqF2+yMHZpD9fAYpX8q2bOO6Ryhl3XpCT6kUX76N8hhm4Q==", + "dev": true + }, "node_modules/@pagefind/default-ui": { "version": "1.1.0", "dev": true, @@ -1996,6 +2002,34 @@ "node": ">=18" } }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.20.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.20.0.tgz", @@ -2335,12 +2369,12 @@ } }, "node_modules/@types/node": { - "version": "22.2.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz", - "integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.0.tgz", + "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", "dev": true, "dependencies": { - "undici-types": "~6.13.0" + "undici-types": "~6.19.2" } }, "node_modules/@types/sax": { @@ -2475,9 +2509,9 @@ "dev": true }, "node_modules/@vtbag/inspection-chamber": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@vtbag/inspection-chamber/-/inspection-chamber-1.0.6.tgz", - "integrity": "sha512-eNbn9EL+Ed1nkXpts4xrhpgImrHSGBfS0VUh8wBWeS2mo7nDsyQWJb7UyCS29cUe5vj1kniU07sB/nkVdeFR2g==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@vtbag/inspection-chamber/-/inspection-chamber-1.0.7.tgz", + "integrity": "sha512-sZD4v3xE5VNkFWgeTQa4h/3MpdMhd3wrENhCu8gB89xlJ+Yw5agVpuidVsRLlk5jh4IVsv1XNFiDMwiVnFMB8g==", "funding": { "type": "github", "url": "https://github.com/sponsors/martrapp" @@ -2647,12 +2681,12 @@ } }, "node_modules/astro": { - "version": "4.13.3", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.13.3.tgz", - "integrity": "sha512-MyhmM0v5sphiVwxAm5jjKxWeuPZijWPJ8Ajdign9QzEmLWSH8vUYIJWx/dWRQ6vF1I0jXrksoj3wtw5nzXt9nw==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.14.2.tgz", + "integrity": "sha512-x9VeYx8Ih6kYKBMVwwsfRzsZVq30+SUhiawnYQ6+46qQnEx3zH05KcH24HsJMe6dVpHD8HdH7CWR5C4o7Q/jeg==", "dev": true, "dependencies": { - "@astrojs/compiler": "^2.10.1", + "@astrojs/compiler": "^2.10.2", "@astrojs/internal-helpers": "0.4.1", "@astrojs/markdown-remark": "5.2.0", "@astrojs/telemetry": "3.1.0", @@ -2662,6 +2696,8 @@ "@babel/plugin-transform-react-jsx": "^7.25.2", "@babel/traverse": "^7.25.3", "@babel/types": "^7.25.2", + "@oslojs/encoding": "^0.4.1", + "@rollup/pluginutils": "^5.1.0", "@types/babel__core": "^7.20.5", "@types/cookie": "^0.6.0", "acorn": "^8.12.1", @@ -2692,7 +2728,9 @@ "js-yaml": "^4.1.0", "kleur": "^4.1.5", "magic-string": "^0.30.11", + "micromatch": "^4.0.7", "mrmime": "^2.0.0", + "neotraverse": "^0.6.9", "ora": "^8.0.1", "p-limit": "^6.1.0", "p-queue": "^8.0.1", @@ -2707,12 +2745,14 @@ "tsconfck": "^3.1.1", "unist-util-visit": "^5.0.0", "vfile": "^6.0.2", - "vite": "^5.3.5", + "vite": "^5.4.0", "vitefu": "^0.2.5", "which-pm": "^3.0.0", + "xxhash-wasm": "^1.0.2", "yargs-parser": "^21.1.1", "zod": "^3.23.8", - "zod-to-json-schema": "^3.23.2" + "zod-to-json-schema": "^3.23.2", + "zod-to-ts": "^1.2.0" }, "bin": { "astro": "astro.js" @@ -6057,6 +6097,15 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/neotraverse": { + "version": "0.6.18", + "resolved": "https://registry.npmjs.org/neotraverse/-/neotraverse-0.6.18.tgz", + "integrity": "sha512-Z4SmBUweYa09+o6pG+eASabEpP6QkQ70yHj351pQoEXIs8uHbaU2DWVmzBANKgflPa47A50PtB2+NgRpQvr7vA==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, "node_modules/nlcst-to-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/nlcst-to-string/-/nlcst-to-string-4.0.0.tgz", @@ -7698,9 +7747,9 @@ } }, "node_modules/undici-types": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", - "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", + "version": "6.19.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", + "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", "dev": true }, "node_modules/unified": { @@ -8372,6 +8421,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/xxhash-wasm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.0.2.tgz", + "integrity": "sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A==", + "dev": true + }, "node_modules/y18n": { "version": "5.0.8", "dev": true, @@ -8477,6 +8532,16 @@ "zod": "^3.23.3" } }, + "node_modules/zod-to-ts": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/zod-to-ts/-/zod-to-ts-1.2.0.tgz", + "integrity": "sha512-x30XE43V+InwGpvTySRNz9kB7qFU8DlyEy7BsSTCHPH1R0QasMmHWZDCzYm6bVXtj/9NNJAZF3jW8rzFvH5OFA==", + "dev": true, + "peerDependencies": { + "typescript": "^4.9.4 || ^5.0.2", + "zod": "^3" + } + }, "node_modules/zwitch": { "version": "2.0.4", "dev": true, diff --git a/package.json b/package.json index 336b1d9..9a1c978 100644 --- a/package.json +++ b/package.json @@ -73,17 +73,17 @@ "release": "changeset publish" }, "dependencies": { - "@vtbag/inspection-chamber": "^1.0.6" + "@vtbag/inspection-chamber": "^1.0.7" }, "devDependencies": { "@astrojs/check": "^0.9.2", - "@astrojs/starlight": "^0.25.5", + "@astrojs/starlight": "^0.26.0", "@changesets/changelog-github": "0.5.0", "@changesets/cli": "^2.27.7", "@playwright/test": "^1.46.0", "@types/dom-view-transitions": "^1.0.5", - "@types/node": "^22.2.0", - "astro": "^4.13.3", + "@types/node": "^22.4.0", + "astro": "^4.14.2", "prettier": "^3.3.3", "prettier-plugin-astro": "^0.14.1", "typescript": "^5.5.4"