From 7ebcb7015d143a7d46e26b6b3b90a406a02041be Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 26 Jul 2024 13:02:40 +0200 Subject: [PATCH 01/13] Skip unnecessary disconnect & recreation of IntersectionObserver --- packages/starlight/components/TableOfContents/starlight-toc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/starlight/components/TableOfContents/starlight-toc.ts b/packages/starlight/components/TableOfContents/starlight-toc.ts index 7a35ac3bba6..201c130ef90 100644 --- a/packages/starlight/components/TableOfContents/starlight-toc.ts +++ b/packages/starlight/components/TableOfContents/starlight-toc.ts @@ -73,8 +73,8 @@ export class StarlightTOC extends HTMLElement { let observer: IntersectionObserver | undefined; const observe = () => { - if (observer) observer.disconnect(); observer = new IntersectionObserver(setCurrent, { rootMargin: this.getRootMargin() }); + if (observer) return; toObserve.forEach((h) => observer!.observe(h)); }; observe(); From 1fb6c17d72f7da20f828ed883c5196b7ee11c38d Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 26 Jul 2024 13:07:17 +0200 Subject: [PATCH 02/13] Get height of navigation UI asynchronously --- .../TableOfContents/starlight-toc.ts | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/starlight/components/TableOfContents/starlight-toc.ts b/packages/starlight/components/TableOfContents/starlight-toc.ts index 201c130ef90..eebca05dcdc 100644 --- a/packages/starlight/components/TableOfContents/starlight-toc.ts +++ b/packages/starlight/components/TableOfContents/starlight-toc.ts @@ -72,9 +72,9 @@ export class StarlightTOC extends HTMLElement { const toObserve = document.querySelectorAll('main [id], main [id] ~ *, main .content > *'); let observer: IntersectionObserver | undefined; - const observe = () => { - observer = new IntersectionObserver(setCurrent, { rootMargin: this.getRootMargin() }); + const observe = async () => { if (observer) return; + observer = new IntersectionObserver(setCurrent, { rootMargin: await this.getRootMargin() }); toObserve.forEach((h) => observer!.observe(h)); }; observe(); @@ -89,17 +89,38 @@ export class StarlightTOC extends HTMLElement { }); } - private getRootMargin(): `-${number}px 0% ${number}px` { - const navBarHeight = document.querySelector('header')?.getBoundingClientRect().height || 0; - // `` only exists in mobile ToC, so will fall back to 0 in large viewport component. - const mobileTocHeight = this.querySelector('summary')?.getBoundingClientRect().height || 0; + private async getRootMargin(): Promise<`-${number}px 0% ${number}px`> { + const [navBar, mobileToC] = await this.getNavHeights(); /** Start intersections at nav height + 2rem padding. */ - const top = navBarHeight + mobileTocHeight + 32; + const top = navBar + mobileToC + 32; /** End intersections `53px` later. This is slightly more than the maximum `margin-top` in Markdown content. */ const bottom = top + 53; const height = document.documentElement.clientHeight; return `-${top}px 0% ${bottom - height}px`; } + + /** + * Asynchronously get the height of Starlight’s navigation elements. + * By avoiding a direct `getBoundingClientRect()` call, this code doesn’t force an immediate style reflow. + */ + private getNavHeights(): Promise { + return new Promise((resolve) => { + const heights: NavHeights = [0, 0]; + const observer = new IntersectionObserver((entries) => { + for (const entry of entries) { + const key = ({ HEADER: 0, SUMMARY: 1 } as const)[entry.target.tagName]; + if (key !== undefined) heights[key] = entry.boundingClientRect.height; + } + observer.disconnect(); + resolve(heights); + }); + const elements = [document.querySelector('header'), this.querySelector('summary')].filter( + (el): el is HTMLElement => !!el + ); + for (const el of elements) observer.observe(el); + }); + } } +type NavHeights = [navBar: number, mobileToC: number]; customElements.define('starlight-toc', StarlightTOC); From c39dc1459987bfebf4fd7436f0936192b70e0a97 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 26 Jul 2024 17:26:59 +0200 Subject: [PATCH 03/13] [REVERT ME] Patch Expressive Code --- package.json | 7 ++++++- patches/@expressive-code__core@0.35.3.patch | 13 +++++++++++++ pnpm-lock.yaml | 16 +++++++++++----- 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 patches/@expressive-code__core@0.35.3.patch diff --git a/package.json b/package.json index db0e25204da..e72c0d0bd4a 100644 --- a/package.json +++ b/package.json @@ -42,5 +42,10 @@ "limit": "14.5 kB", "gzip": true } - ] + ], + "pnpm": { + "patchedDependencies": { + "@expressive-code/core@0.35.3": "patches/@expressive-code__core@0.35.3.patch" + } + } } diff --git a/patches/@expressive-code__core@0.35.3.patch b/patches/@expressive-code__core@0.35.3.patch new file mode 100644 index 00000000000..5089420aba7 --- /dev/null +++ b/patches/@expressive-code__core@0.35.3.patch @@ -0,0 +1,13 @@ +diff --git a/dist/index.js b/dist/index.js +index e76155763991b1aedc9b45f2ea36b16d84bc7d00..8cc3d2d7d540df9f6071291cfc7012fda857cefc 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -4161,7 +4161,7 @@ function resolveStyleVariants({ + } + + // src/internal/tabindex-js-module.min.ts +-var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()},250)})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(i(n),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; ++var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;console.log("checking if tabindex is needed for ", e);let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&cancelIdleCallback(t),t=requestIdleCallback(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()})})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(requestIdleCallback(()=>i(n)),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; + + // src/internal/core-plugins.ts + var corePlugins = [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index da143b366db..926434a6f6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + '@expressive-code/core@0.35.3': + hash: vg7xnmezxmns67tpnazoslvstq + path: patches/@expressive-code__core@0.35.3.patch + importers: .: @@ -1467,7 +1472,7 @@ packages: requiresBuild: true optional: true - /@expressive-code/core@0.35.3: + /@expressive-code/core@0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq): resolution: {integrity: sha512-SYamcarAjufYhbuK/kfvJSvAXLsfnM7DKc78R7Dq4B73R5bKQK2m5zR0l57tXr4yp2C5Z8lu5xZncdwWxcmPdg==} dependencies: '@ctrl/tinycolor': 4.1.0 @@ -1480,24 +1485,25 @@ packages: unist-util-visit: 5.0.0 unist-util-visit-parents: 6.0.1 dev: false + patched: true /@expressive-code/plugin-frames@0.35.3: resolution: {integrity: sha512-QYytMq6IsaHgTofQ5b6d+CnbxkqLdikSF2hC+IL/ZZwPYHYZoUlmjIwmJZhY4/hHqJGELrtZsyVdlt06RntgmA==} dependencies: - '@expressive-code/core': 0.35.3 + '@expressive-code/core': 0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq) dev: false /@expressive-code/plugin-shiki@0.35.3: resolution: {integrity: sha512-aFQBPepv0zhVXqJFAvfQ4vXYv/meJKiqmEEKSxdjAfwXllIV49PDlnGEXmbGYjR4hUQQjbfDgzAbrbfePc3YVQ==} dependencies: - '@expressive-code/core': 0.35.3 + '@expressive-code/core': 0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq) shiki: 1.6.4 dev: false /@expressive-code/plugin-text-markers@0.35.3: resolution: {integrity: sha512-gDdnQrfDRXw5Y+PKHJDkpAUdf2pthYOthGcgy3JB8GOTQ3EL1h+755Ct/bGc4MR6jn+dgnQP47uHMWQaccvN6Q==} dependencies: - '@expressive-code/core': 0.35.3 + '@expressive-code/core': 0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq) dev: false /@hapi/hoek@9.3.0: @@ -3517,7 +3523,7 @@ packages: /expressive-code@0.35.3: resolution: {integrity: sha512-XjWWUCxS4uQjPoRM98R7SNWWIYlFEaOeHm1piWv+c7coHCekuWno81thsc3g/UJ+DajNtOEsIQIAAcsBQZ8LMg==} dependencies: - '@expressive-code/core': 0.35.3 + '@expressive-code/core': 0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq) '@expressive-code/plugin-frames': 0.35.3 '@expressive-code/plugin-shiki': 0.35.3 '@expressive-code/plugin-text-markers': 0.35.3 From c58042bfb9774a2eae94fedf823e9dd1225d1888 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Sat, 27 Jul 2024 00:41:14 +0200 Subject: [PATCH 04/13] Remove console.log from EC patch --- patches/@expressive-code__core@0.35.3.patch | 2 +- pnpm-lock.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/patches/@expressive-code__core@0.35.3.patch b/patches/@expressive-code__core@0.35.3.patch index 5089420aba7..1c862c24d6b 100644 --- a/patches/@expressive-code__core@0.35.3.patch +++ b/patches/@expressive-code__core@0.35.3.patch @@ -7,7 +7,7 @@ index e76155763991b1aedc9b45f2ea36b16d84bc7d00..8cc3d2d7d540df9f6071291cfc7012fd // src/internal/tabindex-js-module.min.ts -var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()},250)})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(i(n),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; -+var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;console.log("checking if tabindex is needed for ", e);let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&cancelIdleCallback(t),t=requestIdleCallback(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()})})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(requestIdleCallback(()=>i(n)),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; ++var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&cancelIdleCallback(t),t=requestIdleCallback(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()})})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(requestIdleCallback(()=>i(n)),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; // src/internal/core-plugins.ts var corePlugins = [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 926434a6f6c..b28c66c69de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: patchedDependencies: '@expressive-code/core@0.35.3': - hash: vg7xnmezxmns67tpnazoslvstq + hash: bdxbvsfdxpjxlgg7zkrapx7cuq path: patches/@expressive-code__core@0.35.3.patch importers: @@ -1472,7 +1472,7 @@ packages: requiresBuild: true optional: true - /@expressive-code/core@0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq): + /@expressive-code/core@0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq): resolution: {integrity: sha512-SYamcarAjufYhbuK/kfvJSvAXLsfnM7DKc78R7Dq4B73R5bKQK2m5zR0l57tXr4yp2C5Z8lu5xZncdwWxcmPdg==} dependencies: '@ctrl/tinycolor': 4.1.0 @@ -1490,20 +1490,20 @@ packages: /@expressive-code/plugin-frames@0.35.3: resolution: {integrity: sha512-QYytMq6IsaHgTofQ5b6d+CnbxkqLdikSF2hC+IL/ZZwPYHYZoUlmjIwmJZhY4/hHqJGELrtZsyVdlt06RntgmA==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq) + '@expressive-code/core': 0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq) dev: false /@expressive-code/plugin-shiki@0.35.3: resolution: {integrity: sha512-aFQBPepv0zhVXqJFAvfQ4vXYv/meJKiqmEEKSxdjAfwXllIV49PDlnGEXmbGYjR4hUQQjbfDgzAbrbfePc3YVQ==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq) + '@expressive-code/core': 0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq) shiki: 1.6.4 dev: false /@expressive-code/plugin-text-markers@0.35.3: resolution: {integrity: sha512-gDdnQrfDRXw5Y+PKHJDkpAUdf2pthYOthGcgy3JB8GOTQ3EL1h+755Ct/bGc4MR6jn+dgnQP47uHMWQaccvN6Q==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq) + '@expressive-code/core': 0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq) dev: false /@hapi/hoek@9.3.0: @@ -3523,7 +3523,7 @@ packages: /expressive-code@0.35.3: resolution: {integrity: sha512-XjWWUCxS4uQjPoRM98R7SNWWIYlFEaOeHm1piWv+c7coHCekuWno81thsc3g/UJ+DajNtOEsIQIAAcsBQZ8LMg==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=vg7xnmezxmns67tpnazoslvstq) + '@expressive-code/core': 0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq) '@expressive-code/plugin-frames': 0.35.3 '@expressive-code/plugin-shiki': 0.35.3 '@expressive-code/plugin-text-markers': 0.35.3 From 84139f484c53ed9b71f5176e58446c56c7f7604b Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Sat, 27 Jul 2024 00:58:33 +0200 Subject: [PATCH 05/13] Simplify ToC optimization to just use requestIdleCallback --- .../TableOfContents/starlight-toc.ts | 46 ++++++------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/packages/starlight/components/TableOfContents/starlight-toc.ts b/packages/starlight/components/TableOfContents/starlight-toc.ts index eebca05dcdc..b7d4eb2bf18 100644 --- a/packages/starlight/components/TableOfContents/starlight-toc.ts +++ b/packages/starlight/components/TableOfContents/starlight-toc.ts @@ -1,7 +1,7 @@ import { PAGE_TITLE_ID } from '../../constants'; export class StarlightTOC extends HTMLElement { - private _current = this.querySelector('a[aria-current="true"]') as HTMLAnchorElement | null; + private _current = this.querySelector('a[aria-current="true"]'); private minH = parseInt(this.dataset.minH || '2', 10); private maxH = parseInt(this.dataset.maxH || '3', 10); @@ -12,9 +12,15 @@ export class StarlightTOC extends HTMLElement { this._current = link; } + private onIdle = (cb: IdleRequestCallback) => + (window.requestIdleCallback || ((cb) => setTimeout(cb, 1)))(cb); + constructor() { super(); + this.onIdle(() => this.init()); + } + private init = (): void => { /** All the links in the table of contents. */ const links = [...this.querySelectorAll('a')]; @@ -74,53 +80,31 @@ export class StarlightTOC extends HTMLElement { let observer: IntersectionObserver | undefined; const observe = async () => { if (observer) return; - observer = new IntersectionObserver(setCurrent, { rootMargin: await this.getRootMargin() }); + observer = new IntersectionObserver(setCurrent, { rootMargin: this.getRootMargin() }); toObserve.forEach((h) => observer!.observe(h)); }; observe(); - const onIdle = window.requestIdleCallback || ((cb) => setTimeout(cb, 1)); let timeout: NodeJS.Timeout; window.addEventListener('resize', () => { // Disable intersection observer while window is resizing. if (observer) observer.disconnect(); clearTimeout(timeout); - timeout = setTimeout(() => onIdle(observe), 200); + timeout = setTimeout(() => this.onIdle(observe), 200); }); - } + }; - private async getRootMargin(): Promise<`-${number}px 0% ${number}px`> { - const [navBar, mobileToC] = await this.getNavHeights(); + private getRootMargin(): `-${number}px 0% ${number}px` { + const navBarHeight = document.querySelector('header')?.getBoundingClientRect().height || 0; + // `` only exists in mobile ToC, so will fall back to 0 in large viewport component. + const mobileTocHeight = this.querySelector('summary')?.getBoundingClientRect().height || 0; /** Start intersections at nav height + 2rem padding. */ - const top = navBar + mobileToC + 32; + const top = navBarHeight + mobileTocHeight + 32; /** End intersections `53px` later. This is slightly more than the maximum `margin-top` in Markdown content. */ const bottom = top + 53; const height = document.documentElement.clientHeight; return `-${top}px 0% ${bottom - height}px`; } - - /** - * Asynchronously get the height of Starlight’s navigation elements. - * By avoiding a direct `getBoundingClientRect()` call, this code doesn’t force an immediate style reflow. - */ - private getNavHeights(): Promise { - return new Promise((resolve) => { - const heights: NavHeights = [0, 0]; - const observer = new IntersectionObserver((entries) => { - for (const entry of entries) { - const key = ({ HEADER: 0, SUMMARY: 1 } as const)[entry.target.tagName]; - if (key !== undefined) heights[key] = entry.boundingClientRect.height; - } - observer.disconnect(); - resolve(heights); - }); - const elements = [document.querySelector('header'), this.querySelector('summary')].filter( - (el): el is HTMLElement => !!el - ); - for (const el of elements) observer.observe(el); - }); - } } -type NavHeights = [navBar: number, mobileToC: number]; customElements.define('starlight-toc', StarlightTOC); From 58b083a7286bc2959f2da3caaea775cbca0a4139 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Sat, 27 Jul 2024 01:41:01 +0200 Subject: [PATCH 06/13] Remove redundant call from EC script to match EC PR --- patches/@expressive-code__core@0.35.3.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/@expressive-code__core@0.35.3.patch b/patches/@expressive-code__core@0.35.3.patch index 1c862c24d6b..3f1980aac1a 100644 --- a/patches/@expressive-code__core@0.35.3.patch +++ b/patches/@expressive-code__core@0.35.3.patch @@ -7,7 +7,7 @@ index e76155763991b1aedc9b45f2ea36b16d84bc7d00..8cc3d2d7d540df9f6071291cfc7012fd // src/internal/tabindex-js-module.min.ts -var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()},250)})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(i(n),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; -+var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&cancelIdleCallback(t),t=requestIdleCallback(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()})})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(requestIdleCallback(()=>i(n)),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; ++var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&cancelIdleCallback(t),t=requestIdleCallback(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()})})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&r.observe(n)})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; // src/internal/core-plugins.ts var corePlugins = [ From e569712b776612dd640be5835c9ee9ba5780d893 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Sat, 27 Jul 2024 01:42:29 +0200 Subject: [PATCH 07/13] Fix lockfile --- pnpm-lock.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b28c66c69de..a09e3fde86f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: patchedDependencies: '@expressive-code/core@0.35.3': - hash: bdxbvsfdxpjxlgg7zkrapx7cuq + hash: 6w5hb7opdve6h3wqr2l3vxsd3q path: patches/@expressive-code__core@0.35.3.patch importers: @@ -1472,7 +1472,7 @@ packages: requiresBuild: true optional: true - /@expressive-code/core@0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq): + /@expressive-code/core@0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q): resolution: {integrity: sha512-SYamcarAjufYhbuK/kfvJSvAXLsfnM7DKc78R7Dq4B73R5bKQK2m5zR0l57tXr4yp2C5Z8lu5xZncdwWxcmPdg==} dependencies: '@ctrl/tinycolor': 4.1.0 @@ -1490,20 +1490,20 @@ packages: /@expressive-code/plugin-frames@0.35.3: resolution: {integrity: sha512-QYytMq6IsaHgTofQ5b6d+CnbxkqLdikSF2hC+IL/ZZwPYHYZoUlmjIwmJZhY4/hHqJGELrtZsyVdlt06RntgmA==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq) + '@expressive-code/core': 0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q) dev: false /@expressive-code/plugin-shiki@0.35.3: resolution: {integrity: sha512-aFQBPepv0zhVXqJFAvfQ4vXYv/meJKiqmEEKSxdjAfwXllIV49PDlnGEXmbGYjR4hUQQjbfDgzAbrbfePc3YVQ==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq) + '@expressive-code/core': 0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q) shiki: 1.6.4 dev: false /@expressive-code/plugin-text-markers@0.35.3: resolution: {integrity: sha512-gDdnQrfDRXw5Y+PKHJDkpAUdf2pthYOthGcgy3JB8GOTQ3EL1h+755Ct/bGc4MR6jn+dgnQP47uHMWQaccvN6Q==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq) + '@expressive-code/core': 0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q) dev: false /@hapi/hoek@9.3.0: @@ -3523,7 +3523,7 @@ packages: /expressive-code@0.35.3: resolution: {integrity: sha512-XjWWUCxS4uQjPoRM98R7SNWWIYlFEaOeHm1piWv+c7coHCekuWno81thsc3g/UJ+DajNtOEsIQIAAcsBQZ8LMg==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=bdxbvsfdxpjxlgg7zkrapx7cuq) + '@expressive-code/core': 0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q) '@expressive-code/plugin-frames': 0.35.3 '@expressive-code/plugin-shiki': 0.35.3 '@expressive-code/plugin-text-markers': 0.35.3 From 50d7d3f25bf2d02d4e35d1bc8c084ce708a5fdbd Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Sat, 27 Jul 2024 19:24:57 +0200 Subject: [PATCH 08/13] Update EC patch with latest changes from EC PR --- patches/@expressive-code__core@0.35.3.patch | 2 +- pnpm-lock.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/patches/@expressive-code__core@0.35.3.patch b/patches/@expressive-code__core@0.35.3.patch index 3f1980aac1a..438f8d836c7 100644 --- a/patches/@expressive-code__core@0.35.3.patch +++ b/patches/@expressive-code__core@0.35.3.patch @@ -7,7 +7,7 @@ index e76155763991b1aedc9b45f2ea36b16d84bc7d00..8cc3d2d7d540df9f6071291cfc7012fd // src/internal/tabindex-js-module.min.ts -var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()},250)})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(i(n),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; -+var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&cancelIdleCallback(t),t=requestIdleCallback(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()})})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&r.observe(n)})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; ++var tabindex_js_module_min_default = 'try{(()=>{function c(e){if(!e)return;let t=e.getAttribute("tabindex")!==null,n=e.scrollWidth>e.clientWidth;n&&!t?e.setAttribute("tabindex","0"):!n&&t&&e.removeAttribute("tabindex")}var u=window.requestIdleCallback||(e=>setTimeout(e,1)),i=window.cancelIdleCallback||clearTimeout;function l(e){let t=new Set,n,r;return new ResizeObserver(a=>{a.forEach(o=>t.add(o.target)),n&&clearTimeout(n),r&&i(r),n=setTimeout(()=>{r&&i(r),r=u(()=>{t.forEach(o=>e(o)),t.clear()})},250)})}function s(e,t){e.querySelectorAll?.(".expressive-code pre > code").forEach(n=>{let r=n.parentElement;r&&t.observe(r)})}var d=l(c);s(document,d);var b=new MutationObserver(e=>e.forEach(t=>t.addedNodes.forEach(n=>{s(n,d)})));b.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; // src/internal/core-plugins.ts var corePlugins = [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a09e3fde86f..adea59c36ae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: patchedDependencies: '@expressive-code/core@0.35.3': - hash: 6w5hb7opdve6h3wqr2l3vxsd3q + hash: i74jz37aez3jkdc67hpgke7tpy path: patches/@expressive-code__core@0.35.3.patch importers: @@ -1472,7 +1472,7 @@ packages: requiresBuild: true optional: true - /@expressive-code/core@0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q): + /@expressive-code/core@0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy): resolution: {integrity: sha512-SYamcarAjufYhbuK/kfvJSvAXLsfnM7DKc78R7Dq4B73R5bKQK2m5zR0l57tXr4yp2C5Z8lu5xZncdwWxcmPdg==} dependencies: '@ctrl/tinycolor': 4.1.0 @@ -1490,20 +1490,20 @@ packages: /@expressive-code/plugin-frames@0.35.3: resolution: {integrity: sha512-QYytMq6IsaHgTofQ5b6d+CnbxkqLdikSF2hC+IL/ZZwPYHYZoUlmjIwmJZhY4/hHqJGELrtZsyVdlt06RntgmA==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q) + '@expressive-code/core': 0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy) dev: false /@expressive-code/plugin-shiki@0.35.3: resolution: {integrity: sha512-aFQBPepv0zhVXqJFAvfQ4vXYv/meJKiqmEEKSxdjAfwXllIV49PDlnGEXmbGYjR4hUQQjbfDgzAbrbfePc3YVQ==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q) + '@expressive-code/core': 0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy) shiki: 1.6.4 dev: false /@expressive-code/plugin-text-markers@0.35.3: resolution: {integrity: sha512-gDdnQrfDRXw5Y+PKHJDkpAUdf2pthYOthGcgy3JB8GOTQ3EL1h+755Ct/bGc4MR6jn+dgnQP47uHMWQaccvN6Q==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q) + '@expressive-code/core': 0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy) dev: false /@hapi/hoek@9.3.0: @@ -3523,7 +3523,7 @@ packages: /expressive-code@0.35.3: resolution: {integrity: sha512-XjWWUCxS4uQjPoRM98R7SNWWIYlFEaOeHm1piWv+c7coHCekuWno81thsc3g/UJ+DajNtOEsIQIAAcsBQZ8LMg==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=6w5hb7opdve6h3wqr2l3vxsd3q) + '@expressive-code/core': 0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy) '@expressive-code/plugin-frames': 0.35.3 '@expressive-code/plugin-shiki': 0.35.3 '@expressive-code/plugin-text-markers': 0.35.3 From 1f7759c62f605d58555f3f10569adc01baa0c6d9 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Sat, 27 Jul 2024 20:00:59 +0200 Subject: [PATCH 09/13] Try to fix up patch --- patches/@expressive-code__core@0.35.3.patch | 2 +- pnpm-lock.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/patches/@expressive-code__core@0.35.3.patch b/patches/@expressive-code__core@0.35.3.patch index 438f8d836c7..95cd0be5916 100644 --- a/patches/@expressive-code__core@0.35.3.patch +++ b/patches/@expressive-code__core@0.35.3.patch @@ -1,5 +1,5 @@ diff --git a/dist/index.js b/dist/index.js -index e76155763991b1aedc9b45f2ea36b16d84bc7d00..8cc3d2d7d540df9f6071291cfc7012fda857cefc 100644 +index e76155763991b1aedc9b45f2ea36b16d84bc7d00..5c2ad68258457ed67560a5a598e5ca2bb19b8d49 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4161,7 +4161,7 @@ function resolveStyleVariants({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index adea59c36ae..0f517fec3c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: patchedDependencies: '@expressive-code/core@0.35.3': - hash: i74jz37aez3jkdc67hpgke7tpy + hash: a4jdmznzpper5ud4lhm4x4pe5e path: patches/@expressive-code__core@0.35.3.patch importers: @@ -1472,7 +1472,7 @@ packages: requiresBuild: true optional: true - /@expressive-code/core@0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy): + /@expressive-code/core@0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e): resolution: {integrity: sha512-SYamcarAjufYhbuK/kfvJSvAXLsfnM7DKc78R7Dq4B73R5bKQK2m5zR0l57tXr4yp2C5Z8lu5xZncdwWxcmPdg==} dependencies: '@ctrl/tinycolor': 4.1.0 @@ -1490,20 +1490,20 @@ packages: /@expressive-code/plugin-frames@0.35.3: resolution: {integrity: sha512-QYytMq6IsaHgTofQ5b6d+CnbxkqLdikSF2hC+IL/ZZwPYHYZoUlmjIwmJZhY4/hHqJGELrtZsyVdlt06RntgmA==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy) + '@expressive-code/core': 0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e) dev: false /@expressive-code/plugin-shiki@0.35.3: resolution: {integrity: sha512-aFQBPepv0zhVXqJFAvfQ4vXYv/meJKiqmEEKSxdjAfwXllIV49PDlnGEXmbGYjR4hUQQjbfDgzAbrbfePc3YVQ==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy) + '@expressive-code/core': 0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e) shiki: 1.6.4 dev: false /@expressive-code/plugin-text-markers@0.35.3: resolution: {integrity: sha512-gDdnQrfDRXw5Y+PKHJDkpAUdf2pthYOthGcgy3JB8GOTQ3EL1h+755Ct/bGc4MR6jn+dgnQP47uHMWQaccvN6Q==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy) + '@expressive-code/core': 0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e) dev: false /@hapi/hoek@9.3.0: @@ -3523,7 +3523,7 @@ packages: /expressive-code@0.35.3: resolution: {integrity: sha512-XjWWUCxS4uQjPoRM98R7SNWWIYlFEaOeHm1piWv+c7coHCekuWno81thsc3g/UJ+DajNtOEsIQIAAcsBQZ8LMg==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=i74jz37aez3jkdc67hpgke7tpy) + '@expressive-code/core': 0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e) '@expressive-code/plugin-frames': 0.35.3 '@expressive-code/plugin-shiki': 0.35.3 '@expressive-code/plugin-text-markers': 0.35.3 From 3e6ee937a46b7f831ba7f38cf8f5929faaedbffa Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Thu, 1 Aug 2024 14:54:47 +0200 Subject: [PATCH 10/13] Remove expressive-code patch --- package.json | 7 +------ patches/@expressive-code__core@0.35.3.patch | 13 ------------- pnpm-lock.yaml | 16 +++++----------- 3 files changed, 6 insertions(+), 30 deletions(-) delete mode 100644 patches/@expressive-code__core@0.35.3.patch diff --git a/package.json b/package.json index e72c0d0bd4a..db0e25204da 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,5 @@ "limit": "14.5 kB", "gzip": true } - ], - "pnpm": { - "patchedDependencies": { - "@expressive-code/core@0.35.3": "patches/@expressive-code__core@0.35.3.patch" - } - } + ] } diff --git a/patches/@expressive-code__core@0.35.3.patch b/patches/@expressive-code__core@0.35.3.patch deleted file mode 100644 index 95cd0be5916..00000000000 --- a/patches/@expressive-code__core@0.35.3.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/dist/index.js b/dist/index.js -index e76155763991b1aedc9b45f2ea36b16d84bc7d00..5c2ad68258457ed67560a5a598e5ca2bb19b8d49 100644 ---- a/dist/index.js -+++ b/dist/index.js -@@ -4161,7 +4161,7 @@ function resolveStyleVariants({ - } - - // src/internal/tabindex-js-module.min.ts --var tabindex_js_module_min_default = 'try{(()=>{function i(e){if(!e)return;let r=e.getAttribute("tabindex")!==null,t=e.scrollWidth>e.clientWidth;t&&!r?e.setAttribute("tabindex","0"):!t&&r&&e.removeAttribute("tabindex")}function a(e){let r=new Set,t;return new ResizeObserver(u=>{u.forEach(o=>r.add(o.target)),t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,r.forEach(o=>e(o)),r.clear()},250)})}function s(e,r){e.querySelectorAll?.(".expressive-code pre > code").forEach(t=>{let n=t.parentElement;n&&(i(n),r.observe(n))})}var d=a(i);s(document,d);var c=new MutationObserver(e=>e.forEach(r=>r.addedNodes.forEach(t=>{s(t,d)})));c.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; -+var tabindex_js_module_min_default = 'try{(()=>{function c(e){if(!e)return;let t=e.getAttribute("tabindex")!==null,n=e.scrollWidth>e.clientWidth;n&&!t?e.setAttribute("tabindex","0"):!n&&t&&e.removeAttribute("tabindex")}var u=window.requestIdleCallback||(e=>setTimeout(e,1)),i=window.cancelIdleCallback||clearTimeout;function l(e){let t=new Set,n,r;return new ResizeObserver(a=>{a.forEach(o=>t.add(o.target)),n&&clearTimeout(n),r&&i(r),n=setTimeout(()=>{r&&i(r),r=u(()=>{t.forEach(o=>e(o)),t.clear()})},250)})}function s(e,t){e.querySelectorAll?.(".expressive-code pre > code").forEach(n=>{let r=n.parentElement;r&&t.observe(r)})}var d=l(c);s(document,d);var b=new MutationObserver(e=>e.forEach(t=>t.addedNodes.forEach(n=>{s(n,d)})));b.observe(document.body,{childList:!0,subtree:!0});document.addEventListener("astro:page-load",()=>{s(document,d)});})();}catch(e){console.error("[EC] tabindex-js-module failed:",e)}'; - - // src/internal/core-plugins.ts - var corePlugins = [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0f517fec3c6..da143b366db 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,11 +4,6 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -patchedDependencies: - '@expressive-code/core@0.35.3': - hash: a4jdmznzpper5ud4lhm4x4pe5e - path: patches/@expressive-code__core@0.35.3.patch - importers: .: @@ -1472,7 +1467,7 @@ packages: requiresBuild: true optional: true - /@expressive-code/core@0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e): + /@expressive-code/core@0.35.3: resolution: {integrity: sha512-SYamcarAjufYhbuK/kfvJSvAXLsfnM7DKc78R7Dq4B73R5bKQK2m5zR0l57tXr4yp2C5Z8lu5xZncdwWxcmPdg==} dependencies: '@ctrl/tinycolor': 4.1.0 @@ -1485,25 +1480,24 @@ packages: unist-util-visit: 5.0.0 unist-util-visit-parents: 6.0.1 dev: false - patched: true /@expressive-code/plugin-frames@0.35.3: resolution: {integrity: sha512-QYytMq6IsaHgTofQ5b6d+CnbxkqLdikSF2hC+IL/ZZwPYHYZoUlmjIwmJZhY4/hHqJGELrtZsyVdlt06RntgmA==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e) + '@expressive-code/core': 0.35.3 dev: false /@expressive-code/plugin-shiki@0.35.3: resolution: {integrity: sha512-aFQBPepv0zhVXqJFAvfQ4vXYv/meJKiqmEEKSxdjAfwXllIV49PDlnGEXmbGYjR4hUQQjbfDgzAbrbfePc3YVQ==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e) + '@expressive-code/core': 0.35.3 shiki: 1.6.4 dev: false /@expressive-code/plugin-text-markers@0.35.3: resolution: {integrity: sha512-gDdnQrfDRXw5Y+PKHJDkpAUdf2pthYOthGcgy3JB8GOTQ3EL1h+755Ct/bGc4MR6jn+dgnQP47uHMWQaccvN6Q==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e) + '@expressive-code/core': 0.35.3 dev: false /@hapi/hoek@9.3.0: @@ -3523,7 +3517,7 @@ packages: /expressive-code@0.35.3: resolution: {integrity: sha512-XjWWUCxS4uQjPoRM98R7SNWWIYlFEaOeHm1piWv+c7coHCekuWno81thsc3g/UJ+DajNtOEsIQIAAcsBQZ8LMg==} dependencies: - '@expressive-code/core': 0.35.3(patch_hash=a4jdmznzpper5ud4lhm4x4pe5e) + '@expressive-code/core': 0.35.3 '@expressive-code/plugin-frames': 0.35.3 '@expressive-code/plugin-shiki': 0.35.3 '@expressive-code/plugin-text-markers': 0.35.3 From 9b258274c119b3a39a88b1fc201dba68f9834158 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Thu, 1 Aug 2024 14:56:29 +0200 Subject: [PATCH 11/13] Update expressive-code to the latest patch --- packages/starlight/package.json | 2 +- pnpm-lock.yaml | 50 ++++++++++++++++----------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/starlight/package.json b/packages/starlight/package.json index 6c8e76011eb..992b5be90ab 100644 --- a/packages/starlight/package.json +++ b/packages/starlight/package.json @@ -192,7 +192,7 @@ "@pagefind/default-ui": "^1.0.3", "@types/hast": "^3.0.4", "@types/mdast": "^4.0.4", - "astro-expressive-code": "^0.35.3", + "astro-expressive-code": "^0.35.4", "bcp-47": "^2.1.0", "hast-util-from-html": "^2.0.1", "hast-util-select": "^6.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index da143b366db..2d6de67001f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -146,8 +146,8 @@ importers: specifier: ^4.0.4 version: 4.0.4 astro-expressive-code: - specifier: ^0.35.3 - version: 0.35.3(astro@4.10.2) + specifier: ^0.35.4 + version: 0.35.4(astro@4.10.2) bcp-47: specifier: ^2.1.0 version: 2.1.0 @@ -1467,8 +1467,8 @@ packages: requiresBuild: true optional: true - /@expressive-code/core@0.35.3: - resolution: {integrity: sha512-SYamcarAjufYhbuK/kfvJSvAXLsfnM7DKc78R7Dq4B73R5bKQK2m5zR0l57tXr4yp2C5Z8lu5xZncdwWxcmPdg==} + /@expressive-code/core@0.35.4: + resolution: {integrity: sha512-Vq8KeVKjCvBbgapQgwHZiHG3XmgN6itt3fCcIexz2RnoYpkv765AlpTlBGwEooXCEN++Pf0OFDer0l7G6vYO2Q==} dependencies: '@ctrl/tinycolor': 4.1.0 hast-util-select: 6.0.2 @@ -1481,23 +1481,23 @@ packages: unist-util-visit-parents: 6.0.1 dev: false - /@expressive-code/plugin-frames@0.35.3: - resolution: {integrity: sha512-QYytMq6IsaHgTofQ5b6d+CnbxkqLdikSF2hC+IL/ZZwPYHYZoUlmjIwmJZhY4/hHqJGELrtZsyVdlt06RntgmA==} + /@expressive-code/plugin-frames@0.35.4: + resolution: {integrity: sha512-f72vp6qqynqItFrIcDmDSbdHae23X47PEwma5kCOcaA3oKcSasb39L1SpDKWePw3TEpqE577zky+gVdGdblE+A==} dependencies: - '@expressive-code/core': 0.35.3 + '@expressive-code/core': 0.35.4 dev: false - /@expressive-code/plugin-shiki@0.35.3: - resolution: {integrity: sha512-aFQBPepv0zhVXqJFAvfQ4vXYv/meJKiqmEEKSxdjAfwXllIV49PDlnGEXmbGYjR4hUQQjbfDgzAbrbfePc3YVQ==} + /@expressive-code/plugin-shiki@0.35.4: + resolution: {integrity: sha512-cJn38L6dO8FvlN2/L1Pwfb6dK/EznvrjceGyjBclxXvNit0TsmInlpQQ2DonSRSFexZTt92kLYGbBTgIcRBMyw==} dependencies: - '@expressive-code/core': 0.35.3 + '@expressive-code/core': 0.35.4 shiki: 1.6.4 dev: false - /@expressive-code/plugin-text-markers@0.35.3: - resolution: {integrity: sha512-gDdnQrfDRXw5Y+PKHJDkpAUdf2pthYOthGcgy3JB8GOTQ3EL1h+755Ct/bGc4MR6jn+dgnQP47uHMWQaccvN6Q==} + /@expressive-code/plugin-text-markers@0.35.4: + resolution: {integrity: sha512-n4bRnRfSOwP78Xaoza6yBfyrr4qOYmG5Iz9vpcwnhs/RDULundv2oNgPVbW9KUSvmlJKrLeJAIJE1MGEh2/PcQ==} dependencies: - '@expressive-code/core': 0.35.3 + '@expressive-code/core': 0.35.4 dev: false /@hapi/hoek@9.3.0: @@ -2466,13 +2466,13 @@ packages: hasBin: true dev: false - /astro-expressive-code@0.35.3(astro@4.10.2): - resolution: {integrity: sha512-f1L1m3J3EzZHDEox6TXmuKo5fTSbaNxE/HU0S0UQmvlCowtOKnU/LOsoDwsbQSYGKz+fdLRPsCjFMiKqEoyfcw==} + /astro-expressive-code@0.35.4(astro@4.10.2): + resolution: {integrity: sha512-axzDLTcv8PsaLHe66G8SH4muiary6W5R7dXaLYTRYgLED7Ra7FSxLd17g9kfiD1Qz9OXIEw+8/xkTzABKdbLNw==} peerDependencies: astro: ^4.0.0-beta || ^3.3.0 dependencies: astro: 4.10.2(@types/node@18.16.19)(typescript@5.4.5) - rehype-expressive-code: 0.35.3 + rehype-expressive-code: 0.35.4 dev: false /astro@4.10.2(@types/node@18.16.19)(typescript@5.4.5): @@ -3514,13 +3514,13 @@ packages: engines: {node: '>=6'} dev: false - /expressive-code@0.35.3: - resolution: {integrity: sha512-XjWWUCxS4uQjPoRM98R7SNWWIYlFEaOeHm1piWv+c7coHCekuWno81thsc3g/UJ+DajNtOEsIQIAAcsBQZ8LMg==} + /expressive-code@0.35.4: + resolution: {integrity: sha512-ps7Ln7QdEUVo+97ipuV6IzfciOk/2+mZXNVlYX/UiCkUwv+pdL0+oe50+DIF/fhWlFYh4Sf8tCrwi1YASxsrsA==} dependencies: - '@expressive-code/core': 0.35.3 - '@expressive-code/plugin-frames': 0.35.3 - '@expressive-code/plugin-shiki': 0.35.3 - '@expressive-code/plugin-text-markers': 0.35.3 + '@expressive-code/core': 0.35.4 + '@expressive-code/plugin-frames': 0.35.4 + '@expressive-code/plugin-shiki': 0.35.4 + '@expressive-code/plugin-text-markers': 0.35.4 dev: false /extend-shallow@2.0.1: @@ -6175,10 +6175,10 @@ packages: functions-have-names: 1.2.3 dev: true - /rehype-expressive-code@0.35.3: - resolution: {integrity: sha512-kj43Rg+WzYUs8RRr6XyBr60pnrIZEgbmn9yJoV6qka1UDpcx7r8icn6Q2uSAgaLtlEUy+HCPgQJraOZrA53LOQ==} + /rehype-expressive-code@0.35.4: + resolution: {integrity: sha512-HHYBTmZY5HBAO+bSP3wcin9gRGPnIio8fsFNP08a0CqjULjQNKMbUnda9Qot2VEh3o/jZ/vbuwNOTl2G3yG+bA==} dependencies: - expressive-code: 0.35.3 + expressive-code: 0.35.4 dev: false /rehype-format@5.0.0: From e30867c0f20e424d6b335df0015b784c92bab773 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Thu, 1 Aug 2024 14:58:52 +0200 Subject: [PATCH 12/13] Remove unnecessary `async` --- packages/starlight/components/TableOfContents/starlight-toc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/starlight/components/TableOfContents/starlight-toc.ts b/packages/starlight/components/TableOfContents/starlight-toc.ts index b7d4eb2bf18..2fd940f0477 100644 --- a/packages/starlight/components/TableOfContents/starlight-toc.ts +++ b/packages/starlight/components/TableOfContents/starlight-toc.ts @@ -78,7 +78,7 @@ export class StarlightTOC extends HTMLElement { const toObserve = document.querySelectorAll('main [id], main [id] ~ *, main .content > *'); let observer: IntersectionObserver | undefined; - const observe = async () => { + const observe = () => { if (observer) return; observer = new IntersectionObserver(setCurrent, { rootMargin: this.getRootMargin() }); toObserve.forEach((h) => observer!.observe(h)); From 395d6ddd932a8147f87fd19ab09d94a8e4d604dd Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Thu, 1 Aug 2024 15:28:07 +0200 Subject: [PATCH 13/13] Add changeset --- .changeset/bright-planets-accept.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/bright-planets-accept.md diff --git a/.changeset/bright-planets-accept.md b/.changeset/bright-planets-accept.md new file mode 100644 index 00000000000..29dca10a5be --- /dev/null +++ b/.changeset/bright-planets-accept.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Improves page load performance on slower devices