Vendor onig WASM dependency

Instead of letting `starry-night` fetch the `vscode-oniguruma` WASM, we
fetch it from the `node_modules` folder and do the same in the e2e
tests.
For this to work we need to update `starry-night` to version `1.5.0`

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-01-05 14:51:26 +01:00
parent c3c3d06380
commit 4b58539eff
5 changed files with 16 additions and 20 deletions
+11 -8
View File
@@ -1,14 +1,15 @@
import type { Root } from "@wooorm/starry-night";
import type { ElementContent } from "hast";
import { createStarryNight, common } from "@wooorm/starry-night";
import sourceTsx from "@wooorm/starry-night/lang/source.tsx";
import sourceSvelte from "@wooorm/starry-night/lang/source.svelte.js";
import sourceSolidity from "@wooorm/starry-night/lang/source.solidity.js";
import sourceToml from "@wooorm/starry-night/lang/source.toml";
import sourceErlang from "@wooorm/starry-night/lang/source.erlang.js";
import sourceDockerfile from "@wooorm/starry-night/lang/source.dockerfile";
import onigurumaWASMUrl from "vscode-oniguruma/release/onig.wasm?url";
import sourceAsciiDoc from "@wooorm/starry-night/lang/text.html.asciidoc";
import sourceDockerfile from "@wooorm/starry-night/lang/source.dockerfile";
import sourceErlang from "@wooorm/starry-night/lang/source.erlang.js";
import sourceSolidity from "@wooorm/starry-night/lang/source.solidity.js";
import sourceSvelte from "@wooorm/starry-night/lang/source.svelte.js";
import sourceToml from "@wooorm/starry-night/lang/source.toml";
import sourceTsx from "@wooorm/starry-night/lang/source.tsx";
import { createStarryNight, common } from "@wooorm/starry-night";
export type MaybeHighlighted = Root | undefined;
@@ -37,7 +38,9 @@ export async function highlight(
grammar: string,
): Promise<MaybeHighlighted> {
if (starryNight === undefined) {
starryNight = await createStarryNight(grammars);
starryNight = await createStarryNight(grammars, {
getOnigurumaUrlFetch: () => new URL(onigurumaWASMUrl, import.meta.url),
});
}
const scope = starryNight.flagToScope(grammar);
return starryNight.highlight(content, scope ?? "text.raw");