diff options
| author | David Hill <[email protected]> | 2025-12-02 17:00:45 +0000 |
|---|---|---|
| committer | David Hill <[email protected]> | 2025-12-02 17:00:45 +0000 |
| commit | 58b30d678a910378a554b2ab580da4a2e17796cd (patch) | |
| tree | 6be6118d39755712ffb875f4771ddfe35256b43a /packages/ui/src/components/code.tsx | |
| parent | 408cdaf5e05dacc0675a15205fa2c80e667d2f03 (diff) | |
| parent | cae23cde09b5e0fa2c15a240135e2d2e4f864613 (diff) | |
| download | opencode-58b30d678a910378a554b2ab580da4a2e17796cd.tar.gz opencode-58b30d678a910378a554b2ab580da4a2e17796cd.zip | |
Merge branch 'dev' of https://github.com/sst/opencode into dev
Diffstat (limited to 'packages/ui/src/components/code.tsx')
| -rw-r--r-- | packages/ui/src/components/code.tsx | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/packages/ui/src/components/code.tsx b/packages/ui/src/components/code.tsx index 788baf549..b4b772816 100644 --- a/packages/ui/src/components/code.tsx +++ b/packages/ui/src/components/code.tsx @@ -1,6 +1,22 @@ import { type FileContents, File, FileOptions, LineAnnotation } from "@pierre/precision-diffs" import { ComponentProps, createEffect, splitProps } from "solid-js" -import { createDefaultOptions, styleVariables } from "./pierre" +import { createDefaultOptions, styleVariables } from "../pierre" +import { getOrCreateWorkerPoolSingleton } from "@pierre/precision-diffs/worker" +import { workerFactory } from "../pierre/worker" + +const workerPool = getOrCreateWorkerPoolSingleton({ + poolOptions: { + workerFactory, + // poolSize defaults to 8. More workers = more parallelism but + // also more memory. Too many can actually slow things down. + // poolSize: 8, + }, + highlighterOptions: { + theme: "OpenCode", + // Optionally preload languages to avoid lazy-loading delays + // langs: ["typescript", "javascript", "css", "html"], + }, +}) export type CodeProps<T = {}> = FileOptions<T> & { file: FileContents @@ -14,10 +30,13 @@ export function Code<T>(props: CodeProps<T>) { const [local, others] = splitProps(props, ["file", "class", "classList", "annotations"]) createEffect(() => { - const instance = new File<T>({ - ...createDefaultOptions<T>("unified"), - ...others, - }) + const instance = new File<T>( + { + ...createDefaultOptions<T>("unified"), + ...others, + }, + workerPool, + ) container.innerHTML = "" instance.render({ |
