Buckets:
| import { WorkerPoolManager } from "@pierre/diffs/worker" | |
| import ShikiWorkerUrl from "@pierre/diffs/worker/worker.js?worker&url" | |
| export type WorkerPoolStyle = "unified" | "split" | |
| export function workerFactory(): Worker { | |
| return new Worker(ShikiWorkerUrl, { type: "module" }) | |
| } | |
| function createPool(lineDiffType: "none" | "word-alt") { | |
| const pool = new WorkerPoolManager( | |
| { | |
| workerFactory, | |
| // poolSize defaults to 8. More workers = more parallelism but | |
| // also more memory. Too many can actually slow things down. | |
| // NOTE: 2 is probably better for OpenCode, as I think 8 might be | |
| // a bit overkill, especially because Safari has a significantly slower | |
| // boot up time for workers | |
| poolSize: 2, | |
| }, | |
| { | |
| theme: "OpenCode", | |
| lineDiffType, | |
| preferredHighlighter: "shiki-wasm", | |
| }, | |
| ) | |
| void pool.initialize() | |
| return pool | |
| } | |
| let unified: WorkerPoolManager | undefined | |
| let split: WorkerPoolManager | undefined | |
| export function getWorkerPool(style: WorkerPoolStyle | undefined): WorkerPoolManager | undefined { | |
| if (typeof window === "undefined") return | |
| if (style === "split") { | |
| if (!split) split = createPool("word-alt") | |
| return split | |
| } | |
| if (!unified) unified = createPool("none") | |
| return unified | |
| } | |
| export function getWorkerPools() { | |
| return { | |
| unified: getWorkerPool("unified"), | |
| split: getWorkerPool("split"), | |
| } | |
| } | |
Xet Storage Details
- Size:
- 1.41 kB
- Xet hash:
- 73cac16c122e4e94824b36e975ebaaa729183541eaf298734a9cd65d5864d7ad
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.