From 154c8e337819c7d7ebf4ff4dd55db0d10607620b Mon Sep 17 00:00:00 2001 From: Hippo Date: Fri, 8 Nov 2024 14:53:08 +0100 Subject: Update `astro-expressive-code` to v0.38 (#2551) Co-authored-by: Chris Swithinbank --- .changeset/kind-ravens-cross.md | 7 ++ .../integrations/expressive-code/index.ts | 6 +- packages/starlight/package.json | 6 +- packages/starlight/vitest.config.ts | 9 +- pnpm-lock.yaml | 130 ++++++++++++++++----- 5 files changed, 121 insertions(+), 37 deletions(-) create mode 100644 .changeset/kind-ravens-cross.md diff --git a/.changeset/kind-ravens-cross.md b/.changeset/kind-ravens-cross.md new file mode 100644 index 00000000..6546b39d --- /dev/null +++ b/.changeset/kind-ravens-cross.md @@ -0,0 +1,7 @@ +--- +'@astrojs/starlight': minor +--- + +Updates the `astro-expressive-code` dependency to the latest version (0.38). + +The new version allows using `ec.config.mjs` to selectively override individual Expressive Code styles and settings provided by Starlight themes and plugins, speeds up Shiki language loading, and adds the config option `expressiveCode.shiki.injectLangsIntoNestedCodeBlocks`. See the [Expressive Code release notes](https://expressive-code.com/releases/#0380) for full details. diff --git a/packages/starlight/integrations/expressive-code/index.ts b/packages/starlight/integrations/expressive-code/index.ts index c3fd3854..e0bb6eeb 100644 --- a/packages/starlight/integrations/expressive-code/index.ts +++ b/packages/starlight/integrations/expressive-code/index.ts @@ -8,6 +8,7 @@ import type { AstroIntegration } from 'astro'; import type { StarlightConfig } from '../../types'; import type { createTranslationSystemFromFs } from '../../utils/translations-fs'; import { pathToLocale } from '../shared/pathToLocale'; +import { slugToLocale } from '../shared/slugToLocale'; import { applyStarlightUiThemeColors, preprocessThemes, @@ -152,7 +153,10 @@ export function getStarlightEcConfigPreprocessor({ }, ...otherStyleOverrides, }, - getBlockLocale: ({ file }) => pathToLocale(file.path, { starlightConfig, astroConfig }), + getBlockLocale: ({ file }) => + file.url + ? slugToLocale(file.url.pathname.slice(1), starlightConfig) + : pathToLocale(file.path, { starlightConfig, astroConfig }), plugins, ...rest, }; diff --git a/packages/starlight/package.json b/packages/starlight/package.json index afd7cc7a..5a3c14f0 100644 --- a/packages/starlight/package.json +++ b/packages/starlight/package.json @@ -181,8 +181,8 @@ "@types/node": "^18.16.19", "@vitest/coverage-v8": "^1.6.0", "astro": "^4.15.3", - "vitest": "^1.6.0", - "linkedom": "^0.18.4" + "linkedom": "^0.18.4", + "vitest": "^1.6.0" }, "dependencies": { "@astrojs/mdx": "^3.1.3", @@ -190,7 +190,7 @@ "@pagefind/default-ui": "^1.0.3", "@types/hast": "^3.0.4", "@types/mdast": "^4.0.4", - "astro-expressive-code": "^0.35.6", + "astro-expressive-code": "^0.38.3", "bcp-47": "^2.1.0", "hast-util-from-html": "^2.0.1", "hast-util-select": "^6.0.2", diff --git a/packages/starlight/vitest.config.ts b/packages/starlight/vitest.config.ts index 2b1e1a48..1066fb9c 100644 --- a/packages/starlight/vitest.config.ts +++ b/packages/starlight/vitest.config.ts @@ -20,11 +20,10 @@ export default defineConfig({ 'index.ts', ], thresholds: { - autoUpdate: true, - lines: 89.26, - functions: 92.78, - branches: 92.48, - statements: 89.26, + lines: 88, + functions: 90, + branches: 90, + statements: 88, }, }, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f403311f..a5c38e11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -177,8 +177,8 @@ importers: specifier: ^4.0.4 version: 4.0.4 astro-expressive-code: - specifier: ^0.35.6 - version: 0.35.6(astro@4.15.3) + specifier: ^0.38.3 + version: 0.38.3(astro@4.15.3) bcp-47: specifier: ^2.1.0 version: 2.1.0 @@ -1354,12 +1354,12 @@ packages: requiresBuild: true optional: true - /@expressive-code/core@0.35.6: - resolution: {integrity: sha512-xGqCkmfkgT7lr/rvmfnYdDSeTdCSp1otAHgoFS6wNEeO7wGDPpxdosVqYiIcQ8CfWUABh/pGqWG90q+MV3824A==} + /@expressive-code/core@0.38.3: + resolution: {integrity: sha512-s0/OtdRpBONwcn23O8nVwDNQqpBGKscysejkeBkwlIeHRLZWgiTVrusT5Idrdz1d8cW5wRk9iGsAIQmwDPXgJg==} dependencies: '@ctrl/tinycolor': 4.1.0 hast-util-select: 6.0.2 - hast-util-to-html: 9.0.1 + hast-util-to-html: 9.0.3 hast-util-to-text: 4.0.2 hastscript: 9.0.0 postcss: 8.4.45 @@ -1368,23 +1368,23 @@ packages: unist-util-visit-parents: 6.0.1 dev: false - /@expressive-code/plugin-frames@0.35.6: - resolution: {integrity: sha512-CqjSWjDJ3wabMJZfL9ZAzH5UAGKg7KWsf1TBzr4xvUbZvWoBtLA/TboBML0U1Ls8h/4TRCIvR4VEb8dv5+QG3w==} + /@expressive-code/plugin-frames@0.38.3: + resolution: {integrity: sha512-qL2oC6FplmHNQfZ8ZkTR64/wKo9x0c8uP2WDftR/ydwN/yhe1ed7ZWYb8r3dezxsls+tDokCnN4zYR594jbpvg==} dependencies: - '@expressive-code/core': 0.35.6 + '@expressive-code/core': 0.38.3 dev: false - /@expressive-code/plugin-shiki@0.35.6: - resolution: {integrity: sha512-xm+hzi9BsmhkDUGuyAWIydOAWer7Cs9cj8FM0t4HXaQ+qCubprT6wJZSKUxuvFJIUsIOqk1xXFaJzGJGnWtKMg==} + /@expressive-code/plugin-shiki@0.38.3: + resolution: {integrity: sha512-kqHnglZeesqG3UKrb6e9Fq5W36AZ05Y9tCREmSN2lw8LVTqENIeCIkLDdWtQ5VoHlKqwUEQFTVlRehdwoY7Gmw==} dependencies: - '@expressive-code/core': 0.35.6 - shiki: 1.16.2 + '@expressive-code/core': 0.38.3 + shiki: 1.22.2 dev: false - /@expressive-code/plugin-text-markers@0.35.6: - resolution: {integrity: sha512-/k9eWVZSCs+uEKHR++22Uu6eIbHWEciVHbIuD8frT8DlqTtHYaaiwHPncO6KFWnGDz5i/gL7oyl6XmOi/E6GVg==} + /@expressive-code/plugin-text-markers@0.38.3: + resolution: {integrity: sha512-dPK3+BVGTbTmGQGU3Fkj3jZ3OltWUAlxetMHI6limUGCWBCucZiwoZeFM/WmqQa71GyKRzhBT+iEov6kkz2xVA==} dependencies: - '@expressive-code/core': 0.35.6 + '@expressive-code/core': 0.38.3 dev: false /@hapi/hoek@9.3.0: @@ -1911,9 +1911,46 @@ packages: '@shikijs/vscode-textmate': 9.2.0 '@types/hast': 3.0.4 + /@shikijs/core@1.22.2: + resolution: {integrity: sha512-bvIQcd8BEeR1yFvOYv6HDiyta2FFVePbzeowf5pPS1avczrPK+cjmaxxh0nx5QzbON7+Sv0sQfQVciO7bN72sg==} + dependencies: + '@shikijs/engine-javascript': 1.22.2 + '@shikijs/engine-oniguruma': 1.22.2 + '@shikijs/types': 1.22.2 + '@shikijs/vscode-textmate': 9.3.0 + '@types/hast': 3.0.4 + hast-util-to-html: 9.0.3 + dev: false + + /@shikijs/engine-javascript@1.22.2: + resolution: {integrity: sha512-iOvql09ql6m+3d1vtvP8fLCVCK7BQD1pJFmHIECsujB0V32BJ0Ab6hxk1ewVSMFA58FI0pR2Had9BKZdyQrxTw==} + dependencies: + '@shikijs/types': 1.22.2 + '@shikijs/vscode-textmate': 9.3.0 + oniguruma-to-js: 0.4.3 + dev: false + + /@shikijs/engine-oniguruma@1.22.2: + resolution: {integrity: sha512-GIZPAGzQOy56mGvWMoZRPggn0dTlBf1gutV5TdceLCZlFNqWmuc7u+CzD0Gd9vQUTgLbrt0KLzz6FNprqYAxlA==} + dependencies: + '@shikijs/types': 1.22.2 + '@shikijs/vscode-textmate': 9.3.0 + dev: false + + /@shikijs/types@1.22.2: + resolution: {integrity: sha512-NCWDa6LGZqTuzjsGfXOBWfjS/fDIbDdmVDug+7ykVe1IKT4c1gakrvlfFYp5NhAXH/lyqLM8wsAPo5wNy73Feg==} + dependencies: + '@shikijs/vscode-textmate': 9.3.0 + '@types/hast': 3.0.4 + dev: false + /@shikijs/vscode-textmate@9.2.0: resolution: {integrity: sha512-5FinaOp6Vdh/dl4/yaOTh0ZeKch+rYS8DUb38V3GMKYVkdqzxw53lViRKUYkVILRiVQT7dcPC7VvAKOR73zVtQ==} + /@shikijs/vscode-textmate@9.3.0: + resolution: {integrity: sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==} + dev: false + /@sideway/address@4.1.5: resolution: {integrity: sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q==} dependencies: @@ -2409,13 +2446,13 @@ packages: hasBin: true dev: false - /astro-expressive-code@0.35.6(astro@4.15.3): - resolution: {integrity: sha512-1U4KrvFuodaCV3z4I1bIR16SdhQlPkolGsYTtiANxPZUVv/KitGSCTjzksrkPonn1XuwVqvnwmUUVzTLWngnBA==} + /astro-expressive-code@0.38.3(astro@4.15.3): + resolution: {integrity: sha512-Tvdc7RV0G92BbtyEOsfJtXU35w41CkM94fOAzxbQP67Wj5jArfserJ321FO4XA7WG9QMV0GIBmQq77NBIRDzpQ==} peerDependencies: - astro: ^4.0.0-beta || ^3.3.0 + astro: ^4.0.0-beta || ^5.0.0-beta || ^3.3.0 dependencies: astro: 4.15.3(@types/node@18.16.19)(typescript@5.4.5) - rehype-expressive-code: 0.35.6 + rehype-expressive-code: 0.38.3 dev: false /astro@4.15.3(@types/node@18.16.19)(typescript@5.4.5): @@ -3484,13 +3521,13 @@ packages: engines: {node: '>=6'} dev: false - /expressive-code@0.35.6: - resolution: {integrity: sha512-+mx+TPTbMqgo0mL92Xh9QgjW0kSQIsEivMgEcOnaqKqL7qCw8Vkqc5Rg/di7ZYw4aMUSr74VTc+w8GQWu05j1g==} + /expressive-code@0.38.3: + resolution: {integrity: sha512-COM04AiUotHCKJgWdn7NtW2lqu8OW8owAidMpkXt1qxrZ9Q2iC7+tok/1qIn2ocGnczvr9paIySgGnEwFeEQ8Q==} dependencies: - '@expressive-code/core': 0.35.6 - '@expressive-code/plugin-frames': 0.35.6 - '@expressive-code/plugin-shiki': 0.35.6 - '@expressive-code/plugin-text-markers': 0.35.6 + '@expressive-code/core': 0.38.3 + '@expressive-code/plugin-frames': 0.38.3 + '@expressive-code/plugin-shiki': 0.38.3 + '@expressive-code/plugin-text-markers': 0.38.3 dev: false /extend-shallow@2.0.1: @@ -4052,6 +4089,22 @@ packages: stringify-entities: 4.0.3 zwitch: 2.0.4 + /hast-util-to-html@9.0.3: + resolution: {integrity: sha512-M17uBDzMJ9RPCqLMO92gNNUDuBSq10a25SDBI08iCCxmorf4Yy6sYHK57n9WAbRAAaU+DuR4W6GN9K4DFZesYg==} + dependencies: + '@types/hast': 3.0.4 + '@types/unist': 3.0.0 + ccount: 2.0.1 + comma-separated-tokens: 2.0.3 + hast-util-whitespace: 3.0.0 + html-void-elements: 3.0.0 + mdast-util-to-hast: 13.0.2 + property-information: 6.2.0 + space-separated-tokens: 2.0.2 + stringify-entities: 4.0.3 + zwitch: 2.0.4 + dev: false + /hast-util-to-jsx-runtime@2.3.0: resolution: {integrity: sha512-H/y0+IWPdsLLS738P8tDnrQ8Z+dj12zQQ6WC11TIM21C8WFVoIxcqWXf2H3hiTVZjF1AWqoimGwrTWecWrnmRQ==} dependencies: @@ -5581,6 +5634,12 @@ packages: dependencies: mimic-function: 5.0.1 + /oniguruma-to-js@0.4.3: + resolution: {integrity: sha512-X0jWUcAlxORhOqqBREgPMgnshB7ZGYszBNspP+tS9hPD3l13CdaXcHbgImoHUHlrvGx/7AvFEkTRhAGYh+jzjQ==} + dependencies: + regex: 4.3.3 + dev: false + /opentype.js@1.3.4: resolution: {integrity: sha512-d2JE9RP/6uagpQAVtJoF0pJJA/fgai89Cc50Yp0EJHk+eLp6QQ7gBoblsnubRULNY132I0J1QKMJ+JTbMqz4sw==} engines: {node: '>= 8.0.0'} @@ -6224,6 +6283,10 @@ packages: resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} dev: false + /regex@4.3.3: + resolution: {integrity: sha512-r/AadFO7owAq1QJVeZ/nq9jNS1vyZt+6t1p/E59B56Rn2GCya+gr1KSyOzNL/er+r+B7phv5jG2xU2Nz1YkmJg==} + dev: false + /regexp.prototype.flags@1.5.0: resolution: {integrity: sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==} engines: {node: '>= 0.4'} @@ -6233,10 +6296,10 @@ packages: functions-have-names: 1.2.3 dev: true - /rehype-expressive-code@0.35.6: - resolution: {integrity: sha512-pPdE+pRcRw01kxMOwHQjuRxgwlblZt5+wAc3w2aPGgmcnn57wYjn07iKO7zaznDxYVxMYVvYlnL+R3vWFQS4Gw==} + /rehype-expressive-code@0.38.3: + resolution: {integrity: sha512-RYSSDkMBikoTbycZPkcWp6ELneANT4eTpND1DSRJ6nI2eVFUwTBDCvE2vO6jOOTaavwnPiydi4i/87NRyjpdOA==} dependencies: - expressive-code: 0.35.6 + expressive-code: 0.38.3 dev: false /rehype-format@5.0.0: @@ -6639,6 +6702,17 @@ packages: '@shikijs/vscode-textmate': 9.2.0 '@types/hast': 3.0.4 + /shiki@1.22.2: + resolution: {integrity: sha512-3IZau0NdGKXhH2bBlUk4w1IHNxPh6A5B2sUpyY+8utLu2j/h1QpFkAaUA1bAMxOWWGtTWcAh531vnS4NJKS/lA==} + dependencies: + '@shikijs/core': 1.22.2 + '@shikijs/engine-javascript': 1.22.2 + '@shikijs/engine-oniguruma': 1.22.2 + '@shikijs/types': 1.22.2 + '@shikijs/vscode-textmate': 9.3.0 + '@types/hast': 3.0.4 + dev: false + /side-channel@1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: -- cgit