add more code highlight languages & split out hljs
This commit is contained in:
parent
baedcbaab7
commit
ef0cfbd72d
7 changed files with 45 additions and 15 deletions
|
@ -3,9 +3,19 @@ import { build } from "@char/aftercare/esbuild";
|
||||||
if (import.meta.main) {
|
if (import.meta.main) {
|
||||||
const watch = Deno.args.includes("--watch");
|
const watch = Deno.args.includes("--watch");
|
||||||
await build({
|
await build({
|
||||||
in: ["./client/main.tsx"],
|
in: ["./client/main.tsx", "./client/deps/hljs.ts"],
|
||||||
outDir: "./client/web/dist",
|
outDir: "./client/web/dist",
|
||||||
watch,
|
watch,
|
||||||
|
plugins: [
|
||||||
|
{
|
||||||
|
name: "deps-external",
|
||||||
|
setup: build => {
|
||||||
|
build.onResolve({ filter: /^deps\// }, args => {
|
||||||
|
return { path: args.path.replace(/.ts$/, ".js"), external: true };
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
extraOptions: {
|
extraOptions: {
|
||||||
splitting: true,
|
splitting: true,
|
||||||
},
|
},
|
||||||
|
|
19
client/deps/hljs.ts
Normal file
19
client/deps/hljs.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import hljs from "npm:highlight.js/lib/core";
|
||||||
|
|
||||||
|
import bash from "npm:highlight.js/lib/languages/bash";
|
||||||
|
import css from "npm:highlight.js/lib/languages/css";
|
||||||
|
import javascript from "npm:highlight.js/lib/languages/javascript";
|
||||||
|
import python from "npm:highlight.js/lib/languages/python";
|
||||||
|
import rust from "npm:highlight.js/lib/languages/rust";
|
||||||
|
import typescript from "npm:highlight.js/lib/languages/typescript";
|
||||||
|
import xml from "npm:highlight.js/lib/languages/xml";
|
||||||
|
|
||||||
|
hljs.registerLanguage("bash", bash);
|
||||||
|
hljs.registerLanguage("css", css);
|
||||||
|
hljs.registerLanguage("javascript", javascript);
|
||||||
|
hljs.registerLanguage("python", python);
|
||||||
|
hljs.registerLanguage("rust", rust);
|
||||||
|
hljs.registerLanguage("typescript", typescript);
|
||||||
|
hljs.registerLanguage("html", xml);
|
||||||
|
|
||||||
|
export default hljs;
|
|
@ -1,13 +1,4 @@
|
||||||
import hljs from "npm:highlight.js/lib/core";
|
import hljs from "deps/hljs.ts";
|
||||||
import javascript from "npm:highlight.js/lib/languages/javascript";
|
|
||||||
import python from "npm:highlight.js/lib/languages/python";
|
|
||||||
import rust from "npm:highlight.js/lib/languages/rust";
|
|
||||||
import typescript from "npm:highlight.js/lib/languages/typescript";
|
|
||||||
|
|
||||||
hljs.registerLanguage("javascript", javascript);
|
|
||||||
hljs.registerLanguage("rust", rust);
|
|
||||||
hljs.registerLanguage("python", python);
|
|
||||||
hljs.registerLanguage("typescript", typescript);
|
|
||||||
|
|
||||||
export class ChatResponse {
|
export class ChatResponse {
|
||||||
element = (<article className="assistant" />);
|
element = (<article className="assistant" />);
|
||||||
|
|
|
@ -30,7 +30,6 @@ nav {
|
||||||
|
|
||||||
form input {
|
form input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:is(section, article, header) {
|
:is(section, article, header) {
|
||||||
|
|
|
@ -10,4 +10,11 @@
|
||||||
<noscript>turn on js :(</noscript>
|
<noscript>turn on js :(</noscript>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<script type="importmap">
|
||||||
|
{
|
||||||
|
"imports": {
|
||||||
|
"deps/": "/dist/deps/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<script type="module" src="/dist/main.js"></script>
|
<script type="module" src="/dist/main.js"></script>
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
"run": "deno task client:build --watch & deno task server:run"
|
"run": "deno task client:build --watch & deno task server:run"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"@char/aftercare": "jsr:@char/aftercare@^0.3.0"
|
"@char/aftercare": "jsr:@char/aftercare@^0.3.0",
|
||||||
|
"deps/": "./client/deps/"
|
||||||
},
|
},
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["deno.window", "deno.unstable", "dom"],
|
"lib": ["deno.window", "deno.unstable", "dom"],
|
||||||
|
|
|
@ -72,5 +72,8 @@ async def connect_to_conversation(ws: WebSocket):
|
||||||
await ws.send_text(json({"d": response_tid})) # done
|
await ws.send_text(json({"d": response_tid})) # done
|
||||||
(await response.to_sync_response()).log_to_db(db)
|
(await response.to_sync_response()).log_to_db(db)
|
||||||
|
|
||||||
if conversation.name:
|
if not conversation.name:
|
||||||
await ws.send_text(json({"n": conversation.name}))
|
new_conversation_name = llm.cli.load_conversation(conversation.id).name
|
||||||
|
if new_conversation_name:
|
||||||
|
conversation.name = new_conversation_name
|
||||||
|
await ws.send_text(json({"n": new_conversation_name}))
|
||||||
|
|
Loading…
Reference in a new issue