@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 22 lines 870 Bytes
Raw
1 import { createHighlighter } from "@pierre/highlights";
2
3 // The highlighter's line-record API, which `Highlighter` does not declare.
4 interface LineRecordHighlighter {
5 writeInput(input: string): number;
6 tokenizeLineRecords(language: number, byteLength: number): Uint32Array;
7 }
8
9 /**
10 * Stands in for the T3Highlights hybrid object with the WebAssembly build it is
11 * compiled from. Return it from a mocked `NitroModules.createHybridObject`.
12 */
13 export function createWasmHighlightsModule() {
14 const highlighter = createHighlighter() as unknown as LineRecordHighlighter;
15 return {
16 tokenize(source: string, language: number): ArrayBuffer {
17 const records = highlighter.tokenizeLineRecords(language, highlighter.writeInput(source));
18 // The view points into WebAssembly memory that the next call reuses.
19 return records.slice().buffer;
20 },
21 };
22 }