This commit is contained in:
jlkiri 2020-12-27 21:47:59 +09:00
parent 134c767484
commit 908a7bda9a
3 changed files with 171 additions and 173 deletions

View File

@ -12,7 +12,7 @@ function wait_highlight(...args) {
try { try {
const subChannel = new MessageChannel(); const subChannel = new MessageChannel();
worker.postMessage({ signal, port: subChannel.port1, args }, [ worker.postMessage({ signal, port: subChannel.port1, args }, [
subChannel.port1 subChannel.port1,
]); ]);
Atomics.wait(signal, 0, 0); Atomics.wait(signal, 0, 0);
return receiveMessageOnPort(subChannel.port2).message.result; return receiveMessageOnPort(subChannel.port2).message.result;

View File

@ -3,19 +3,17 @@ const shiki = require("shiki");
const path = require("path"); const path = require("path");
async function shiki_highlight(code, lang) { async function shiki_highlight(code, lang) {
const highlighter = await const highlighter = await shiki.getHighlighter({
shiki theme: "nord",
.getHighlighter({
theme: 'nord',
langs: [ langs: [
{ {
id: "kdl", id: "kdl",
scopeName: "source.kdl", scopeName: "source.kdl",
path: path.join(process.cwd(), "kdl.tmLanguage.json") path: path.join(process.cwd(), "kdl.tmLanguage.json"),
} },
] ],
}) });
return highlighter.codeToHtml(code, lang) return highlighter.codeToHtml(code, lang);
} }
parentPort.addListener("message", async ({ signal, port, args }) => { parentPort.addListener("message", async ({ signal, port, args }) => {