feat: migrate to starlight

This commit is contained in:
DuroCodes
2024-05-06 17:15:30 -04:00
parent 767acedea7
commit bb190f2d81
15140 changed files with 2828326 additions and 35408 deletions

21
node_modules/expressive-code/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Tibor Schiemann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

62
node_modules/expressive-code/README.md generated vendored Normal file
View File

@@ -0,0 +1,62 @@
# expressive-code [![NPM version](https://img.shields.io/npm/v/expressive-code.svg)](https://www.npmjs.com/package/expressive-code) [![NPM downloads](https://img.shields.io/npm/dm/expressive-code.svg)](https://npmjs.org/package/expressive-code)
A framework-agnostic wrapper package that provides convenient access to the key packages of Expressive Code, an engine for presenting source code on the web.
Instead of having to install and manage multiple Expressive Code packages separately, this package includes both the core engine and all default plugins as dependencies and exports them.
Included packages:
- [@expressive-code/core](https://github.com/expressive-code/expressive-code/blob/main/packages/%40expressive-code/core/README.md)
- [@expressive-code/plugin-frames](https://github.com/expressive-code/expressive-code/blob/main/packages/%40expressive-code/plugin-frames/README.md)
- [@expressive-code/plugin-shiki](https://github.com/expressive-code/expressive-code/blob/main/packages/%40expressive-code/plugin-shiki/README.md)
- [@expressive-code/plugin-text-markers](https://github.com/expressive-code/expressive-code/blob/main/packages/%40expressive-code/plugin-text-markers/README.md)
## When should I use this?
Using this package directly is **only recommended for advanced use cases**, e.g. to create integrations of Expressive Code into other tools and frameworks.
If you just want to render code blocks on your website, you should use one of the higher-level packages instead, e.g. [`astro-expressive-code`](https://www.npmjs.com/package/astro-expressive-code) or [`rehype-expressive-code`](https://www.npmjs.com/package/rehype-expressive-code) for code blocks in markdown / MDX documents.
## Documentation
[Read the Expressive Code docs](https://expressive-code.com/) to learn more about the features provided by Expressive Code.
## Installation
```bash
npm install expressive-code
```
## Usage example
```js
import { ExpressiveCode, ExpressiveCodeConfig } from 'expressive-code'
import { toHtml } from 'expressive-code/hast'
const ec = new ExpressiveCode()
// Get base styles that should be included on the page
// (they are independent of the rendered code blocks)
const baseStyles = await ec.getBaseStyles()
// Render some example code to AST
const { renderedGroupAst, styles } = await ec.render({
code: 'console.log("Hello world!")',
language: 'js',
meta: '',
})
// Convert the rendered AST to HTML
let htmlContent = toHtml(renderedGroupAst)
// Collect styles and add them before the HTML content
const stylesToPrepend: string[] = []
stylesToPrepend.push(baseStyles)
stylesToPrepend.push(...styles)
if (stylesToPrepend.length) {
htmlContent = `<style>${[...stylesToPrepend].join('')}</style>${htmlContent}`
}
// Output HTML to the console
console.log(htmlContent)
```

1
node_modules/expressive-code/dist/hast.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from '@expressive-code/core/hast';

3
node_modules/expressive-code/dist/hast.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
// src/hast.ts
export * from "@expressive-code/core/hast";
//# sourceMappingURL=hast.js.map

1
node_modules/expressive-code/dist/hast.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/hast.ts"],"sourcesContent":["export * from '@expressive-code/core/hast'\n"],"mappings":";AAAA,cAAc;","names":[]}

37
node_modules/expressive-code/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,37 @@
import { ExpressiveCodeEngineConfig, ExpressiveCodeEngine } from '@expressive-code/core';
export * from '@expressive-code/core';
import { PluginFramesOptions } from '@expressive-code/plugin-frames';
export * from '@expressive-code/plugin-frames';
import { PluginShikiOptions } from '@expressive-code/plugin-shiki';
export * from '@expressive-code/plugin-shiki';
export * from '@expressive-code/plugin-text-markers';
interface ExpressiveCodeConfig extends ExpressiveCodeEngineConfig {
/**
* The Shiki plugin adds syntax highlighting to code blocks.
*
* This plugin is enabled by default. Set this to `false` to disable it.
* You can also configure the plugin by setting this to an options object.
*/
shiki?: PluginShikiOptions | boolean | undefined;
/**
* The Text Markers plugin allows to highlight lines and inline ranges
* in code blocks in various styles (e.g. marked, inserted, deleted).
*
* This plugin is enabled by default. Set this to `false` to disable it.
*/
textMarkers?: boolean | undefined;
/**
* The Frames plugin adds an editor or terminal frame around code blocks,
* including an optional title displayed as a tab or window caption.
*
* This plugin is enabled by default. Set this to `false` to disable it.
* You can also configure the plugin by setting this to an options object.
*/
frames?: PluginFramesOptions | boolean | undefined;
}
declare class ExpressiveCode extends ExpressiveCodeEngine {
constructor({ shiki, textMarkers, frames, ...baseConfig }?: ExpressiveCodeConfig);
}
export { ExpressiveCode, ExpressiveCodeConfig };

45
node_modules/expressive-code/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
// src/index.ts
import { ExpressiveCodeEngine } from "@expressive-code/core";
import { pluginFrames } from "@expressive-code/plugin-frames";
import { pluginShiki } from "@expressive-code/plugin-shiki";
import { pluginTextMarkers } from "@expressive-code/plugin-text-markers";
export * from "@expressive-code/core";
export * from "@expressive-code/plugin-frames";
export * from "@expressive-code/plugin-shiki";
export * from "@expressive-code/plugin-text-markers";
var ExpressiveCode = class extends ExpressiveCodeEngine {
constructor({ shiki, textMarkers, frames, ...baseConfig } = {}) {
const pluginsToPrepend = [];
const baseConfigPlugins = baseConfig.plugins?.flat() || [];
const notPresentInPlugins = (name) => baseConfigPlugins.every((plugin) => plugin.name !== name);
if (shiki !== false && notPresentInPlugins("Shiki")) {
pluginsToPrepend.push(pluginShiki(shiki !== true ? shiki : void 0));
}
if (textMarkers !== false && notPresentInPlugins("TextMarkers")) {
if (typeof textMarkers === "object" && textMarkers.styleOverrides) {
throw new Error(
`The Expressive Code config option "textMarkers" can no longer be an object,
but only undefined or a boolean. Please move any style settings into the
top-level "styleOverrides" object below the new "textMarkers" key.`.replace(/\s+/g, " ")
);
}
pluginsToPrepend.push(pluginTextMarkers());
}
if (frames !== false && notPresentInPlugins("Frames")) {
if (typeof frames === "object" && frames.styleOverrides) {
throw new Error(
`The config option "frames" no longer has its own "styleOverrides" object.
Please move any style settings into the top-level "styleOverrides" object
below the new "frames" key.`.replace(/\s+/g, " ")
);
}
pluginsToPrepend.push(pluginFrames(frames !== true ? frames : void 0));
}
const pluginsWithDefaults = [...pluginsToPrepend, ...baseConfig.plugins || []];
super({ ...baseConfig, plugins: pluginsWithDefaults });
}
};
export {
ExpressiveCode
};
//# sourceMappingURL=index.js.map

1
node_modules/expressive-code/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ExpressiveCodeEngine, ExpressiveCodeEngineConfig, ExpressiveCodePlugin } from '@expressive-code/core'\nimport { PluginFramesOptions, pluginFrames } from '@expressive-code/plugin-frames'\nimport { PluginShikiOptions } from '@expressive-code/plugin-shiki'\nimport { pluginShiki } from '@expressive-code/plugin-shiki'\nimport { pluginTextMarkers } from '@expressive-code/plugin-text-markers'\n\nexport * from '@expressive-code/core'\nexport * from '@expressive-code/plugin-frames'\nexport * from '@expressive-code/plugin-shiki'\nexport * from '@expressive-code/plugin-text-markers'\n\nexport interface ExpressiveCodeConfig extends ExpressiveCodeEngineConfig {\n\t/**\n\t * The Shiki plugin adds syntax highlighting to code blocks.\n\t *\n\t * This plugin is enabled by default. Set this to `false` to disable it.\n\t * You can also configure the plugin by setting this to an options object.\n\t */\n\tshiki?: PluginShikiOptions | boolean | undefined\n\t/**\n\t * The Text Markers plugin allows to highlight lines and inline ranges\n\t * in code blocks in various styles (e.g. marked, inserted, deleted).\n\t *\n\t * This plugin is enabled by default. Set this to `false` to disable it.\n\t */\n\ttextMarkers?: boolean | undefined\n\t/**\n\t * The Frames plugin adds an editor or terminal frame around code blocks,\n\t * including an optional title displayed as a tab or window caption.\n\t *\n\t * This plugin is enabled by default. Set this to `false` to disable it.\n\t * You can also configure the plugin by setting this to an options object.\n\t */\n\tframes?: PluginFramesOptions | boolean | undefined\n}\n\nexport class ExpressiveCode extends ExpressiveCodeEngine {\n\tconstructor({ shiki, textMarkers, frames, ...baseConfig }: ExpressiveCodeConfig = {}) {\n\t\t// Collect all default plugins with their configuration,\n\t\t// but skip those that were disabled or already added to plugins\n\t\tconst pluginsToPrepend: ExpressiveCodePlugin[] = []\n\t\tconst baseConfigPlugins = baseConfig.plugins?.flat() || []\n\t\tconst notPresentInPlugins = (name: string) => baseConfigPlugins.every((plugin) => plugin.name !== name)\n\t\tif (shiki !== false && notPresentInPlugins('Shiki')) {\n\t\t\tpluginsToPrepend.push(pluginShiki(shiki !== true ? shiki : undefined))\n\t\t}\n\t\tif (textMarkers !== false && notPresentInPlugins('TextMarkers')) {\n\t\t\tif (typeof textMarkers === 'object' && (textMarkers as { styleOverrides: unknown }).styleOverrides) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The Expressive Code config option \"textMarkers\" can no longer be an object,\n\t\t\t\t\tbut only undefined or a boolean. Please move any style settings into the\n\t\t\t\t\ttop-level \"styleOverrides\" object below the new \"textMarkers\" key.`.replace(/\\s+/g, ' ')\n\t\t\t\t)\n\t\t\t}\n\t\t\tpluginsToPrepend.push(pluginTextMarkers())\n\t\t}\n\t\tif (frames !== false && notPresentInPlugins('Frames')) {\n\t\t\tif (typeof frames === 'object' && (frames as { styleOverrides: unknown }).styleOverrides) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The config option \"frames\" no longer has its own \"styleOverrides\" object.\n\t\t\t\t\tPlease move any style settings into the top-level \"styleOverrides\" object\n\t\t\t\t\tbelow the new \"frames\" key.`.replace(/\\s+/g, ' ')\n\t\t\t\t)\n\t\t\t}\n\t\t\tpluginsToPrepend.push(pluginFrames(frames !== true ? frames : undefined))\n\t\t}\n\t\t// Create a new plugins array with the default plugins prepended\n\t\tconst pluginsWithDefaults = [...pluginsToPrepend, ...(baseConfig.plugins || [])]\n\t\t// Call the base constructor with the new plugins array\n\t\tsuper({ ...baseConfig, plugins: pluginsWithDefaults })\n\t}\n}\n"],"mappings":";AAAA,SAAS,4BAA8E;AACvF,SAA8B,oBAAoB;AAElD,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAElC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AA2BP,IAAM,iBAAN,cAA6B,qBAAqB;AAAA,EACxD,YAAY,EAAE,OAAO,aAAa,QAAQ,GAAG,WAAW,IAA0B,CAAC,GAAG;AAGrF,UAAM,mBAA2C,CAAC;AAClD,UAAM,oBAAoB,WAAW,SAAS,KAAK,KAAK,CAAC;AACzD,UAAM,sBAAsB,CAAC,SAAiB,kBAAkB,MAAM,CAAC,WAAW,OAAO,SAAS,IAAI;AACtG,QAAI,UAAU,SAAS,oBAAoB,OAAO,GAAG;AACpD,uBAAiB,KAAK,YAAY,UAAU,OAAO,QAAQ,MAAS,CAAC;AAAA,IACtE;AACA,QAAI,gBAAgB,SAAS,oBAAoB,aAAa,GAAG;AAChE,UAAI,OAAO,gBAAgB,YAAa,YAA4C,gBAAgB;AACnG,cAAM,IAAI;AAAA,UACT;AAAA;AAAA,yEAEoE,QAAQ,QAAQ,GAAG;AAAA,QACxF;AAAA,MACD;AACA,uBAAiB,KAAK,kBAAkB,CAAC;AAAA,IAC1C;AACA,QAAI,WAAW,SAAS,oBAAoB,QAAQ,GAAG;AACtD,UAAI,OAAO,WAAW,YAAa,OAAuC,gBAAgB;AACzF,cAAM,IAAI;AAAA,UACT;AAAA;AAAA,kCAE6B,QAAQ,QAAQ,GAAG;AAAA,QACjD;AAAA,MACD;AACA,uBAAiB,KAAK,aAAa,WAAW,OAAO,SAAS,MAAS,CAAC;AAAA,IACzE;AAEA,UAAM,sBAAsB,CAAC,GAAG,kBAAkB,GAAI,WAAW,WAAW,CAAC,CAAE;AAE/E,UAAM,EAAE,GAAG,YAAY,SAAS,oBAAoB,CAAC;AAAA,EACtD;AACD;","names":[]}

51
node_modules/expressive-code/package.json generated vendored Normal file
View File

@@ -0,0 +1,51 @@
{
"name": "expressive-code",
"version": "0.35.3",
"description": "A text marking & annotation engine for presenting source code on the web.",
"keywords": [],
"author": "Tibor Schiemann",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/expressive-code/expressive-code.git",
"directory": "packages/expressive-code"
},
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./hast": {
"types": "./dist/hast.d.ts",
"default": "./dist/hast.js"
}
},
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"hast": [
"dist/hast.d.ts"
]
}
},
"files": [
"dist"
],
"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"
},
"scripts": {
"build": "tsup ./src/index.ts ./src/hast.ts --format esm --dts --sourcemap --clean",
"coverage": "vitest run --coverage",
"test": "vitest run --reporter verbose",
"test-short": "vitest run --reporter basic",
"test-watch": "vitest --reporter verbose",
"watch": "pnpm build --watch src"
}
}