@hex1b/web-terminal 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +243 -0
  3. package/dist/fonts/cascadia-mono-nf/CascadiaMonoNF.woff2 +0 -0
  4. package/dist/fonts/cascadia-mono-nf/LICENSE.txt +94 -0
  5. package/dist/fonts/cascadia-mono-nf/README.md +29 -0
  6. package/dist/history-state.d.ts +27 -0
  7. package/dist/history-state.d.ts.map +1 -0
  8. package/dist/history-state.js +194 -0
  9. package/dist/history-state.js.map +1 -0
  10. package/dist/index.d.ts +5 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +4 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/input-policy.d.ts +42 -0
  15. package/dist/input-policy.d.ts.map +1 -0
  16. package/dist/input-policy.js +143 -0
  17. package/dist/input-policy.js.map +1 -0
  18. package/dist/mouse-input.d.ts +26 -0
  19. package/dist/mouse-input.d.ts.map +1 -0
  20. package/dist/mouse-input.js +356 -0
  21. package/dist/mouse-input.js.map +1 -0
  22. package/dist/protocol.d.ts +17 -0
  23. package/dist/protocol.d.ts.map +1 -0
  24. package/dist/protocol.js +270 -0
  25. package/dist/protocol.js.map +1 -0
  26. package/dist/renderer.d.ts +113 -0
  27. package/dist/renderer.d.ts.map +1 -0
  28. package/dist/renderer.js +595 -0
  29. package/dist/renderer.js.map +1 -0
  30. package/dist/selection-input.d.ts +36 -0
  31. package/dist/selection-input.d.ts.map +1 -0
  32. package/dist/selection-input.js +69 -0
  33. package/dist/selection-input.js.map +1 -0
  34. package/dist/selection-ui.d.ts +24 -0
  35. package/dist/selection-ui.d.ts.map +1 -0
  36. package/dist/selection-ui.js +113 -0
  37. package/dist/selection-ui.js.map +1 -0
  38. package/dist/terminal-font.d.ts +23 -0
  39. package/dist/terminal-font.d.ts.map +1 -0
  40. package/dist/terminal-font.js +85 -0
  41. package/dist/terminal-font.js.map +1 -0
  42. package/dist/terminal-sizing.d.ts +8 -0
  43. package/dist/terminal-sizing.d.ts.map +1 -0
  44. package/dist/terminal-sizing.js +38 -0
  45. package/dist/terminal-sizing.js.map +1 -0
  46. package/dist/terminal-theme.d.ts +2 -0
  47. package/dist/terminal-theme.d.ts.map +1 -0
  48. package/dist/terminal-theme.js +39 -0
  49. package/dist/terminal-theme.js.map +1 -0
  50. package/dist/terminal-worker.d.ts +2 -0
  51. package/dist/terminal-worker.d.ts.map +1 -0
  52. package/dist/terminal-worker.js +285 -0
  53. package/dist/terminal-worker.js.map +1 -0
  54. package/dist/types.d.ts +312 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/dist/types.js +2 -0
  57. package/dist/types.js.map +1 -0
  58. package/dist/validation.d.ts +3 -0
  59. package/dist/validation.d.ts.map +1 -0
  60. package/dist/validation.js +7 -0
  61. package/dist/validation.js.map +1 -0
  62. package/dist/web-terminal.d.ts +51 -0
  63. package/dist/web-terminal.d.ts.map +1 -0
  64. package/dist/web-terminal.js +728 -0
  65. package/dist/web-terminal.js.map +1 -0
  66. package/dist/wire-types.d.ts +218 -0
  67. package/dist/wire-types.d.ts.map +1 -0
  68. package/dist/wire-types.js +2 -0
  69. package/dist/wire-types.js.map +1 -0
  70. package/package.json +42 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mouse-input.js","sourceRoot":"","sources":["../src/mouse-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAM/D,MAAM,OAAO,GAAkD,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1G,MAAM,cAAc,GAA6B,CAAC,MAAM,EAAE,QA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,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAEnC,OAAO;QACL,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,YAAY;YACxC,IAAI,OAAO,KAAK,WAAW,IAAI,IAAI,KAAK,QAAQ,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;gBAC9E,IAAI,SAAS,EAAE,CAAC;oBACd,SAAS,GAAG,EAAE,GAAG,SAAS;wBACxB,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC;wBACzC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC;qBACvC,CAAC;gBACJ,CAAC;gBACD,kEAAkE;gBAClE,IAAI,OAAO,KAAK,WAAW,IAAI,IAAI,KAAK,QAAQ;oBAAE,MAAM,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC;gBAC7E,OAAO,GAAG,WAAW,CAAC;gBACtB,IAAI,GAAG,QAAQ,CAAC;gBAChB,QAAQ,GAAG,YAAY,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,MAAM,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC;QACtB,OAAO;YACL,MAAM,CAAC,KAAK,CAAC,CAAC;YACd,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { cellPoint, WheelAccumulator, SelectionGesture } from \"./selection-input.js\";\nimport { InputRoute, inputModifiers } from \"./input-policy.js\";\nimport type { GestureState } from \"./selection-input.js\";\nimport type { InputDecision, InputRouteValue, MouseTrackingMode, PointerButton, SelectionMode,\n TerminalInput, TerminalPoint } from \"./types.js\";\nimport type { CellPosition, MouseButton, MouseCommand } from \"./wire-types.js\";\n\nconst buttons: readonly (readonly [PointerButton, number])[] = [[\"left\", 1], [\"middle\", 4], [\"right\", 2]];\nconst pointerButtons: readonly PointerButton[] = [\"left\", \"middle\", \"right\"];\ninterface SelectionClick { point: TerminalPoint; mode: SelectionMode; extend: boolean; dragged: boolean }\ninterface MouseInspection {\n state?: () => Omit<GestureState, \"tracking\">;\n begin?: (point: TerminalPoint, selection: { mode: SelectionMode; extend: boolean }) => void;\n extend?: (point: TerminalPoint) => void;\n scroll?: (delta: number, endpoint?: TerminalPoint) => void;\n end?: (cancelled: boolean) => void;\n resolve?: (input: TerminalInput) => InputDecision;\n execute?: (decision: Extract<InputDecision, { action: unknown }>, input: TerminalInput) => void;\n}\nexport interface MouseCapture {\n update(columns: number, rows: number, tracking: MouseTrackingMode): void;\n cancel(): void;\n dispose(): void;\n}\n\n/** Capture input intent only; the server chooses and encodes the mouse protocol. */\nexport function captureMouse(canvas: HTMLCanvasElement, send: (command: MouseCommand) => void,\n focus: () => void, inspection: MouseInspection = {}): MouseCapture {\n const listeners = new AbortController();\n const options = { signal: listeners.signal };\n let columns = 1, rows = 1;\n let tracking: MouseTrackingMode = 0;\n let pointerId: number | null = null;\n const pressed = new Set<PointerButton>();\n let lastPoint: CellPosition | undefined;\n let pendingMove: MouseCommand | undefined;\n let lastMove: string | undefined;\n let scheduled: number | undefined;\n const wheel = new WheelAccumulator();\n const gesture = new SelectionGesture();\n let wheelOwner: \"local\" | \"app\" | undefined;\n let pointerEvent: PointerEvent | undefined;\n let autoScroll: ReturnType<typeof setTimeout> | undefined;\n let click = { count: 0, time: 0, x: -1, y: -1 };\n let selectionClick: SelectionClick | undefined;\n let completedClick: SelectionClick | undefined;\n let routedGesture: InputRouteValue | undefined;\n let contextMenuRoute: InputRouteValue | undefined;\n const state = () => ({ tracking, ...inspection.state?.() });\n\n function point(event: MouseEvent, clamp = false): CellPosition | null {\n return cellPoint(event, canvas.getBoundingClientRect(), columns, rows, clamp);\n }\n\n function updateAutoScroll() {\n clearTimeout(autoScroll);\n autoScroll = undefined;\n if (gesture.owner !== \"local\" || !pointerEvent) return;\n const bounds = canvas.getBoundingClientRect();\n const distance = pointerEvent.clientY < bounds.top ? pointerEvent.clientY - bounds.top\n : pointerEvent.clientY >= bounds.bottom ? pointerEvent.clientY - bounds.bottom + 1 : 0;\n if (!distance) return;\n autoScroll = setTimeout(() => {\n autoScroll = undefined;\n if (!pointerEvent) return;\n const position = point(pointerEvent, true);\n if (gesture.owner === \"local\" && position) {\n if (selectionClick) selectionClick.dragged = true;\n click.count = 0;\n const lines = Math.sign(distance) * Math.min(8, Math.max(1, Math.ceil(Math.abs(distance) / (bounds.height / rows))));\n inspection.scroll?.(lines, gesture.scrollPoint(position));\n updateAutoScroll();\n }\n }, 60);\n }\n\n function flushMove() {\n if (scheduled !== undefined) cancelAnimationFrame(scheduled);\n scheduled = undefined;\n if (pendingMove) send(pendingMove);\n pendingMove = undefined;\n }\n\n function changeButtons(event: PointerEvent, position: CellPosition): void {\n for (const [button, mask] of buttons) {\n const down = (event.buttons & mask) !== 0;\n if (down === pressed.has(button)) continue;\n flushMove();\n if (down) pressed.add(button);\n else pressed.delete(button);\n if (down || tracking !== 9)\n send({ type: \"mouse\", action: down ? \"down\" : \"up\", button, ...position });\n lastMove = undefined;\n }\n }\n\n function cancel(report = true, cancelled = true) {\n inspection.end?.(cancelled);\n clearTimeout(autoScroll);\n autoScroll = undefined;\n pointerEvent = undefined;\n selectionClick = undefined;\n completedClick = undefined;\n gesture.end();\n routedGesture = undefined;\n if (report) flushMove();\n else {\n if (scheduled !== undefined) cancelAnimationFrame(scheduled);\n scheduled = undefined;\n pendingMove = undefined;\n }\n if (report && tracking !== 9 && lastPoint) {\n for (const button of pressed)\n send({ type: \"mouse\", action: \"up\", button, ...lastPoint });\n }\n pressed.clear();\n const captured = pointerId;\n pointerId = null;\n if (captured !== null && canvas.hasPointerCapture(captured))\n canvas.releasePointerCapture(captured);\n lastMove = undefined;\n wheel.reset();\n wheelOwner = undefined;\n }\n\n canvas.addEventListener(\"pointerdown\", event => {\n if (event.defaultPrevented && pointerId === null) return;\n if (event.pointerType !== \"mouse\" || ![0, 1, 2].includes(event.button)) return;\n const position = point(event);\n if (!position) return;\n if (pointerId !== null) {\n if (routedGesture !== InputRoute.Browser) event.preventDefault();\n if ((gesture.owner === \"app\" || routedGesture === InputRoute.Application) && pointerId === event.pointerId)\n changeButtons(event, position);\n return;\n }\n focus();\n const input: TerminalInput = { type: \"pointer\", button: pointerButtons[event.button],\n point: Object.freeze({ ...position }), ...inputModifiers(event) };\n const decision = inspection.resolve?.(input) ?? { route: InputRoute.Continue };\n const route = decision.action !== undefined ? InputRoute.Consume : decision.route;\n contextMenuRoute = event.button === 2 ? route : undefined;\n if (route !== InputRoute.Continue) {\n completedClick = selectionClick = undefined;\n click.count = 0;\n routedGesture = route;\n pointerId = event.pointerId;\n lastPoint = position;\n canvas.setPointerCapture(pointerId);\n if (route !== InputRoute.Browser) event.preventDefault();\n if (route === InputRoute.Application) flushMove();\n else {\n if (scheduled !== undefined) cancelAnimationFrame(scheduled);\n scheduled = undefined;\n pendingMove = undefined;\n }\n if (route === InputRoute.Application) changeButtons(event, position);\n if (decision.action !== undefined) inspection.execute?.(decision, input);\n return;\n }\n // Keep focus on the hidden keyboard input instead of the canvas.\n event.preventDefault();\n if (event.metaKey) return;\n const now = performance.now();\n click.count = now - click.time < 500 && position.x === click.x && position.y === click.y\n ? click.count % 3 + 1 : 1;\n click = { count: click.count, time: now, x: position.x, y: position.y };\n const start = gesture.begin({ button: event.button, shiftKey: event.shiftKey, altKey: event.altKey,\n detail: event.detail || click.count }, position, state());\n if (!start) return;\n pointerId = event.pointerId;\n pointerEvent = event;\n lastPoint = position;\n completedClick = undefined;\n canvas.setPointerCapture(pointerId);\n if (start.owner === \"local\") {\n if (scheduled !== undefined) cancelAnimationFrame(scheduled);\n scheduled = undefined;\n pendingMove = undefined;\n lastMove = undefined;\n selectionClick = { point: position, mode: start.mode, extend: start.extend, dragged: false };\n inspection.begin?.(position, start);\n }\n else changeButtons(event, position);\n }, options);\n\n canvas.addEventListener(\"pointermove\", event => {\n if (event.pointerType !== \"mouse\") return;\n if (pointerId === null && event.buttons) return;\n if (pointerId !== null && pointerId !== event.pointerId) return;\n const position = point(event, pointerId !== null);\n if (!position) return;\n lastPoint = position;\n if (routedGesture && routedGesture !== InputRoute.Application) return;\n if (gesture.owner === \"local\") {\n pointerEvent = event;\n const previous = gesture.endpoint;\n const endpoint = gesture.move(position);\n if (endpoint && previous && (endpoint.x !== previous.x || endpoint.y !== previous.y)) {\n click.count = 0;\n if (selectionClick) selectionClick.dragged = true;\n inspection.extend?.(endpoint);\n }\n updateAutoScroll();\n return;\n }\n if (!tracking || (!routedGesture && gesture.owner === null && (state().historical || state().readOnly || event.shiftKey))) return;\n if (pointerId === event.pointerId) changeButtons(event, position);\n if (event.metaKey || (tracking !== 1003 && !(tracking === 1002 && pressed.size))) return;\n const button = buttons.find(([name]) => pressed.has(name))?.[0] ?? \"none\";\n const move: MouseCommand = { type: \"mouse\", action: \"move\", button, ...position };\n const key = JSON.stringify(move);\n if (key === lastMove) return;\n lastMove = key;\n pendingMove = move;\n if (scheduled === undefined) scheduled = requestAnimationFrame(flushMove);\n }, options);\n\n canvas.addEventListener(\"pointerup\", event => {\n if (pointerId !== event.pointerId) return;\n const position = point(event, true) ?? lastPoint;\n if (routedGesture) {\n if (routedGesture === InputRoute.Application && position) changeButtons(event, position);\n if (event.buttons === 0) cancel(routedGesture === InputRoute.Application);\n return;\n }\n if (gesture.owner === \"local\") {\n if (position && gesture.endpoint && (position.x !== gesture.endpoint.x || position.y !== gesture.endpoint.y)) {\n if (selectionClick) selectionClick.dragged = true;\n const endpoint = gesture.move(position);\n if (endpoint) inspection.extend?.(endpoint);\n }\n const completed = selectionClick;\n cancel(false, false);\n completedClick = completed;\n return;\n }\n if (position) changeButtons(event, position);\n if (!pressed.size) cancel();\n }, options);\n canvas.addEventListener(\"click\", event => {\n const completed = completedClick;\n completedClick = undefined;\n if (!completed || completed.dragged || !Number.isInteger(event.detail) || event.detail < 1) return;\n click.count = event.detail;\n // Some browsers expose native multiclick counts only on click, not pointerdown.\n const mode = event.detail >= 3 ? \"line\" : event.detail === 2 ? \"word\" : \"character\";\n if (!completed.extend && completed.mode !== \"rectangle\" && mode !== completed.mode)\n inspection.begin?.(completed.point, { mode, extend: false });\n }, options);\n canvas.addEventListener(\"pointercancel\", () => cancel(), options);\n canvas.addEventListener(\"lostpointercapture\", () => {\n if (pointerId !== null) cancel();\n }, options);\n window.addEventListener(\"blur\", () => cancel(), options);\n canvas.addEventListener(\"contextmenu\", event => {\n if (contextMenuRoute !== undefined && contextMenuRoute !== InputRoute.Continue) {\n const route = contextMenuRoute;\n contextMenuRoute = undefined;\n if (route !== InputRoute.Browser) event.preventDefault();\n return;\n }\n if (tracking || gesture.owner === \"local\") event.preventDefault();\n }, options);\n canvas.addEventListener(\"wheel\", event => {\n const input: TerminalInput = { type: \"wheel\", deltaX: event.deltaX, deltaY: event.deltaY,\n deltaMode: event.deltaMode, point: point(event), ...inputModifiers(event) };\n const decision: InputDecision = pointerId === null\n ? inspection.resolve?.(input) ?? { route: InputRoute.Continue }\n : { route: routedGesture ?? InputRoute.Continue };\n if (decision.route === InputRoute.Browser) return;\n if (decision.action !== undefined || decision.route === InputRoute.Consume) {\n event.preventDefault();\n if (decision.action !== undefined) inspection.execute?.(decision, input);\n return;\n }\n // Ctrl+wheel (including trackpad pinch) remains browser zoom.\n if (decision.route !== InputRoute.Application && (event.ctrlKey || event.metaKey)) return;\n const owner = decision.route === InputRoute.Application ? \"app\" : gesture.wheelOwner(event, state());\n if (owner === \"app\" && tracking === 9) return;\n const position = point(gesture.owner === \"local\" && pointerEvent ? pointerEvent : event, gesture.owner === \"local\");\n if (!position) return;\n event.preventDefault();\n flushMove();\n const bounds = canvas.getBoundingClientRect();\n if (wheelOwner !== owner) wheel.reset();\n wheelOwner = owner;\n const { x: horizontal, y: vertical } = wheel.take(event, bounds, rows);\n if (owner === \"local\") {\n if (vertical) {\n if (selectionClick) selectionClick.dragged = true;\n click.count = 0;\n inspection.scroll?.(vertical, gesture.scrollPoint(position));\n }\n return;\n }\n const wheelDirections: [number, MouseButton, MouseButton][] = [\n [vertical, \"wheelUp\", \"wheelDown\"],\n [horizontal, \"wheelLeft\", \"wheelRight\"]\n ];\n for (const [steps, negative, positive] of wheelDirections) {\n if (steps) send({\n type: \"mouse\", action: \"wheel\", button: steps < 0 ? negative : positive,\n count: Math.min(32, Math.abs(steps)), ...position\n });\n }\n }, { ...options, passive: false });\n\n return {\n update(nextColumns, nextRows, nextTracking) {\n if (columns !== nextColumns || rows !== nextRows || tracking !== nextTracking) {\n if (lastPoint) {\n lastPoint = { ...lastPoint,\n x: Math.min(lastPoint.x, nextColumns - 1),\n y: Math.min(lastPoint.y, nextRows - 1)\n };\n }\n // Application mode changes do not transfer ownership mid-gesture.\n if (columns !== nextColumns || rows !== nextRows) cancel(nextTracking !== 0);\n columns = nextColumns;\n rows = nextRows;\n tracking = nextTracking;\n }\n },\n cancel() { cancel(); },\n dispose() {\n cancel(false);\n listeners.abort();\n }\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { HistoryMetadata, TerminalCell, TerminalFrame } from "./wire-types.js";
2
+ export declare const LIMITS: Readonly<{
3
+ commandBytes: number;
4
+ frameBytes: number;
5
+ metadataBytes: number;
6
+ cells: 262144;
7
+ images: 4096;
8
+ placements: 16384;
9
+ textureBytes: number;
10
+ }>;
11
+ export declare function assertCommandSize(command: unknown): void;
12
+ export declare function validateHistory(history: unknown, columns: number, rows: number): asserts history is HistoryMetadata | null;
13
+ /** Decode one complete, experimental HWT1 message, checking every boundary before reading. */
14
+ export declare function decodeFrame(buffer: unknown): TerminalFrame;
15
+ /** Mirror text, not ANSI; continuation cells are already represented by their lead glyph. */
16
+ export declare function screenText(cells: readonly (TerminalCell | undefined)[], columns: number, rows: number): string;
17
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,eAAe,EAAiB,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIlH,eAAO,MAAM,MAAM;;;;;;;;EAQjB,CAAC;AAKH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAGxD;AAyBD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,GAAG,IAAI,CAqC1H;AAmGD,8FAA8F;AAC9F,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,CAiD1D;AAED,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAY9G"}
@@ -0,0 +1,270 @@
1
+ import { isRecord } from "./validation.js";
2
+ // Binary validation is deliberately independent of the GPU and the transport.
3
+ export const LIMITS = Object.freeze({
4
+ commandBytes: 64 * 1024,
5
+ frameBytes: 96 * 1024 * 1024,
6
+ metadataBytes: 8 * 1024 * 1024,
7
+ cells: 262144,
8
+ images: 4096,
9
+ placements: 16384,
10
+ textureBytes: 256 * 1024 * 1024,
11
+ });
12
+ const utf8 = new TextDecoder("utf-8", { fatal: true });
13
+ const utf8Encoder = new TextEncoder();
14
+ export function assertCommandSize(command) {
15
+ if (utf8Encoder.encode(JSON.stringify(command)).byteLength > LIMITS.commandBytes)
16
+ throw new RangeError("Terminal input exceeds the 64 KiB message limit. Send a smaller amount of text.");
17
+ }
18
+ function integer(value, name, min = 0, max = Number.MAX_SAFE_INTEGER) {
19
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min || value > max) {
20
+ throw new Error(`Invalid ${name}: ${String(value)}`);
21
+ }
22
+ return value;
23
+ }
24
+ function array(value, name, limit) {
25
+ if (!Array.isArray(value) || value.length > limit)
26
+ throw new Error(`Invalid ${name}`);
27
+ }
28
+ function key(value) {
29
+ if (typeof value !== "string" || !value.length || value.length > 1024) {
30
+ throw new Error("Invalid image key");
31
+ }
32
+ }
33
+ function rowId(value, name) {
34
+ if (typeof value !== "string" || !/^[1-9][0-9]{0,18}$/u.test(value) || BigInt(value) > 9223372036854775807n) {
35
+ throw new Error(`Invalid ${name}`);
36
+ }
37
+ }
38
+ export function validateHistory(history, columns, rows) {
39
+ if (history === null)
40
+ return;
41
+ if (!isRecord(history))
42
+ throw new Error("Missing history metadata");
43
+ rowId(history.generation, "history generation");
44
+ if (history.buffer !== "main" && history.buffer !== "alternate")
45
+ throw new Error("Invalid history buffer");
46
+ const totalRows = integer(history.totalRows, "history total rows", rows, 2147483647);
47
+ const liveTop = integer(history.liveTop, "history live top", 0, totalRows - rows);
48
+ if (liveTop !== totalRows - rows)
49
+ throw new Error("Inconsistent history extent");
50
+ integer(history.top, "history top", 0, liveTop);
51
+ if (typeof history.following !== "boolean" || (history.following && history.top !== history.liveTop)) {
52
+ throw new Error("Invalid history following state");
53
+ }
54
+ integer(history.requestId, "viewport request id");
55
+ array(history.rowIds, "viewport row ids", rows);
56
+ if (history.rowIds.length !== rows || new Set(history.rowIds).size !== rows)
57
+ throw new Error("Invalid viewport row ids");
58
+ for (const id of history.rowIds)
59
+ rowId(id, "viewport row id");
60
+ const selection = history.selection;
61
+ if (!isRecord(selection) || typeof selection.status !== "string" ||
62
+ !["none", "valid", "invalidated"].includes(selection.status))
63
+ throw new Error("Invalid selection status");
64
+ integer(selection.requestId, "selection request id");
65
+ if (typeof selection.mode !== "string" || !["character", "word", "line", "rectangle"].includes(selection.mode))
66
+ throw new Error("Invalid selection mode");
67
+ array(selection.ranges, "selection ranges", rows);
68
+ let previousRow = -1;
69
+ for (const range of selection.ranges) {
70
+ if (!isRecord(range))
71
+ throw new Error("Invalid selection range");
72
+ const row = integer(range.row, "selection range row", previousRow + 1, rows - 1);
73
+ const startColumn = integer(range.startColumn, "selection start column", 0, columns - 1);
74
+ integer(range.endColumn, "selection end column", startColumn + 1, columns);
75
+ previousRow = row;
76
+ }
77
+ validateSelectionText(selection);
78
+ if (selection.status !== "valid" && selection.ranges.length)
79
+ throw new Error("Inactive selection has highlight ranges");
80
+ if (history.copy !== null) {
81
+ if (!isRecord(history.copy))
82
+ throw new Error("Missing copy metadata");
83
+ integer(history.copy.requestId, "copy request id", 1);
84
+ validateSelectionText(history.copy);
85
+ }
86
+ }
87
+ function validateSelectionText(selection) {
88
+ if (typeof selection.status !== "string" || !["none", "valid", "invalidated"].includes(selection.status) ||
89
+ (selection.status === "valid"
90
+ ? typeof selection.text !== "string" || selection.text.length > LIMITS.metadataBytes
91
+ : selection.text !== null)) {
92
+ throw new Error("Invalid selection text");
93
+ }
94
+ }
95
+ function validateMetadata(metadata) {
96
+ if (!isRecord(metadata) || metadata.version !== 1 || typeof metadata.full !== "boolean") {
97
+ throw new Error("Unsupported frame metadata version");
98
+ }
99
+ integer(metadata.revision, "revision", 1);
100
+ integer(metadata.baseRevision, "base revision");
101
+ const columns = integer(metadata.columns, "columns", 1, 1024);
102
+ const rows = integer(metadata.rows, "rows", 1, 512);
103
+ if (typeof metadata.mouseTracking !== "number" || ![0, 9, 1000, 1002, 1003].includes(metadata.mouseTracking)) {
104
+ throw new Error("Unsupported mouse tracking mode");
105
+ }
106
+ if (!isRecord(metadata.peer) || typeof metadata.peer.isPrimary !== "boolean")
107
+ throw new Error("Invalid peer state");
108
+ for (const field of ["id", "primaryId"]) {
109
+ const id = metadata.peer[field];
110
+ if (id !== null && (typeof id !== "string" || !id.length || id.length > 256)) {
111
+ throw new Error(`Invalid peer ${field}`);
112
+ }
113
+ }
114
+ if (metadata.peer.id !== null && metadata.peer.isPrimary !== (metadata.peer.id === metadata.peer.primaryId)) {
115
+ throw new Error("Inconsistent primary peer state");
116
+ }
117
+ integer(columns * rows, "cell count", 1, LIMITS.cells);
118
+ validateHistory(metadata.history, columns, rows);
119
+ if (metadata.cellWidth !== 10 || metadata.cellHeight !== 20) {
120
+ throw new Error("This spike requires server geometry of 10 × 20 logical pixels");
121
+ }
122
+ for (const field of ["defaultBackground", "defaultForeground"]) {
123
+ if (metadata[field] !== undefined)
124
+ integer(metadata[field], field, 0, 0xffffffff);
125
+ }
126
+ if (!isRecord(metadata.cursor) || typeof metadata.cursor.visible !== "boolean")
127
+ throw new Error("Invalid cursor");
128
+ integer(metadata.cursor.x, "cursor x", -1, 1024);
129
+ integer(metadata.cursor.y, "cursor y", -1, 512);
130
+ const shapes = ["Default", "BlinkingBlock", "SteadyBlock", "BlinkingUnderline", "SteadyUnderline", "BlinkingBar", "SteadyBar"];
131
+ if (typeof metadata.cursor.shape === "string")
132
+ metadata.cursor.shape = shapes.indexOf(metadata.cursor.shape);
133
+ integer(metadata.cursor.shape, "cursor shape", 0, 6);
134
+ array(metadata.images, "images", LIMITS.images);
135
+ array(metadata.retainedImages, "retained image keys", LIMITS.images);
136
+ array(metadata.placements, "placements", LIMITS.placements);
137
+ array(metadata.warnings, "warnings", 256);
138
+ if (metadata.warnings.some(w => typeof w !== "string"))
139
+ throw new Error("Invalid warning");
140
+ if (!isRecord(metadata.stats))
141
+ throw new Error("Invalid server metrics");
142
+ for (const field of ["workloadBytes", "outputBatches", "captureMs", "elapsedMs"]) {
143
+ const metric = metadata.stats[field];
144
+ if (typeof metric !== "number" || !Number.isFinite(metric) || metric < 0) {
145
+ throw new Error(`Invalid server metric ${field}`);
146
+ }
147
+ }
148
+ const retained = new Set();
149
+ for (const imageKey of metadata.retainedImages) {
150
+ key(imageKey);
151
+ if (retained.has(imageKey))
152
+ throw new Error("Duplicate retained image key");
153
+ retained.add(imageKey);
154
+ }
155
+ const imageKeys = new Set();
156
+ let decodedImageBytes = 0;
157
+ for (const image of metadata.images) {
158
+ if (!isRecord(image))
159
+ throw new Error("Invalid image");
160
+ key(image.key);
161
+ if (imageKeys.has(image.key) || !retained.has(image.key))
162
+ throw new Error("Inconsistent new image keys");
163
+ imageKeys.add(image.key);
164
+ const width = integer(image.width, "image width", 1, 16384);
165
+ const height = integer(image.height, "image height", 1, 16384);
166
+ const byteLength = integer(image.byteLength, "image byte length", 1, LIMITS.frameBytes);
167
+ if (image.format !== "rgba" && image.format !== "png")
168
+ throw new Error("Unsupported image format");
169
+ if (image.format === "rgba" && byteLength !== width * height * 4) {
170
+ throw new Error("RGBA image size mismatch");
171
+ }
172
+ decodedImageBytes += width * height * 4;
173
+ if (decodedImageBytes > LIMITS.textureBytes)
174
+ throw new Error("New images exceed decoded texture budget");
175
+ }
176
+ for (const placement of metadata.placements) {
177
+ if (!isRecord(placement))
178
+ throw new Error("Invalid placement");
179
+ key(placement.key);
180
+ if (!retained.has(placement.key))
181
+ throw new Error("Placement references an unretained image");
182
+ if (placement.kind !== "kgp" && placement.kind !== "sixel")
183
+ throw new Error("Invalid placement kind");
184
+ for (const field of ["x", "y", "width", "height", "sourceX", "sourceY", "sourceWidth", "sourceHeight", "clipX", "clipY", "clipWidth", "clipHeight", "z"]) {
185
+ const coordinate = placement[field];
186
+ if (typeof coordinate !== "number" || !Number.isFinite(coordinate) || Math.abs(coordinate) > 2147483648) {
187
+ throw new Error(`Invalid placement ${field}`);
188
+ }
189
+ }
190
+ for (const field of ["width", "height", "sourceWidth", "sourceHeight", "clipWidth", "clipHeight"]) {
191
+ const coordinate = placement[field];
192
+ if (typeof coordinate !== "number" || coordinate < 0)
193
+ throw new Error(`Negative placement ${field}`);
194
+ }
195
+ }
196
+ }
197
+ /** Decode one complete, experimental HWT1 message, checking every boundary before reading. */
198
+ export function decodeFrame(buffer) {
199
+ if (!(buffer instanceof ArrayBuffer) || buffer.byteLength > LIMITS.frameBytes) {
200
+ throw new Error("Invalid or oversized binary frame");
201
+ }
202
+ const view = new DataView(buffer);
203
+ let offset = 0;
204
+ const requireBytes = (count) => {
205
+ if (count < 0 || count > view.byteLength - offset)
206
+ throw new Error("Truncated HWT1 frame");
207
+ };
208
+ const u32 = () => { requireBytes(4); const n = view.getUint32(offset, true); offset += 4; return n; };
209
+ if (u32() !== 0x31545748)
210
+ throw new Error("Unsupported frame magic (expected HWT1)");
211
+ const metadataLength = integer(u32(), "metadata length", 2, LIMITS.metadataBytes);
212
+ requireBytes(metadataLength);
213
+ const metadata = JSON.parse(utf8.decode(new Uint8Array(buffer, offset, metadataLength)));
214
+ offset += metadataLength;
215
+ validateMetadata(metadata);
216
+ const cellCount = metadata.columns * metadata.rows;
217
+ const changedCount = integer(u32(), "changed cell count", 0, cellCount);
218
+ if (changedCount > Math.floor((view.byteLength - offset) / 22))
219
+ throw new Error("Truncated cell records");
220
+ if (metadata.full && changedCount !== cellCount)
221
+ throw new Error("Incomplete full frame");
222
+ const cells = [];
223
+ const seen = new Set();
224
+ for (let i = 0; i < changedCount; i++) {
225
+ requireBytes(22);
226
+ const index = u32();
227
+ if (index >= cellCount || seen.has(index))
228
+ throw new Error("Invalid or duplicate cell index");
229
+ seen.add(index);
230
+ const foreground = u32();
231
+ const background = u32();
232
+ const underlineColor = u32();
233
+ const attributes = view.getUint16(offset, true);
234
+ const width = view.getUint8(offset + 2);
235
+ const underlineStyle = view.getUint8(offset + 3);
236
+ const textLength = view.getUint16(offset + 4, true);
237
+ offset += 6;
238
+ if (underlineStyle > 5)
239
+ throw new Error("Unsupported underline style");
240
+ requireBytes(textLength);
241
+ const text = utf8.decode(new Uint8Array(buffer, offset, textLength));
242
+ offset += textLength;
243
+ cells.push({ index, foreground, background, underlineColor, attributes, width, underlineStyle, text });
244
+ }
245
+ const imageBytes = metadata.images.reduce((total, image) => total + image.byteLength, 0);
246
+ if (imageBytes !== view.byteLength - offset)
247
+ throw new Error("Image payload length mismatch");
248
+ const images = metadata.images.map(image => {
249
+ const bytes = new Uint8Array(buffer, offset, image.byteLength);
250
+ offset += image.byteLength;
251
+ return { ...image, bytes };
252
+ });
253
+ return { metadata, cells, images };
254
+ }
255
+ /** Mirror text, not ANSI; continuation cells are already represented by their lead glyph. */
256
+ export function screenText(cells, columns, rows) {
257
+ const lines = [];
258
+ for (let y = 0; y < rows; y++) {
259
+ let line = "";
260
+ for (let x = 0; x < columns; x++) {
261
+ const cell = cells[y * columns + x];
262
+ if (!cell || cell.width === 0)
263
+ continue;
264
+ line += cell.attributes & 64 ? " ".repeat(cell.width) : (cell.text || " ");
265
+ }
266
+ lines.push(line.replace(/ +$/u, ""));
267
+ }
268
+ return lines.join("\n");
269
+ }
270
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAClC,YAAY,EAAE,EAAE,GAAG,IAAI;IACvB,UAAU,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC5B,aAAa,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IAC9B,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE,KAAK;IACjB,YAAY,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;CAChC,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACvD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,GAAG,MAAM,CAAC,YAAY;QAC9E,MAAM,IAAI,UAAU,CAAC,iFAAiF,CAAC,CAAC;AAC5G,CAAC;AAED,SAAS,OAAO,CAAC,KAAc,EAAE,IAAY,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC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C,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;QAC3B,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CAAC,KAA4C,EAAE,OAAe,EAAE,IAAY;IACpG,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC;gBAAE,SAAS;YACxC,IAAI,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;QAC7E,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import type { FrameMetadata, HistoryMetadata, SelectionText, TerminalCell, TerminalFrame } from \"./wire-types.js\";\nimport { isRecord } from \"./validation.js\";\n\n// Binary validation is deliberately independent of the GPU and the transport.\nexport const LIMITS = Object.freeze({\n commandBytes: 64 * 1024,\n frameBytes: 96 * 1024 * 1024,\n metadataBytes: 8 * 1024 * 1024,\n cells: 262144,\n images: 4096,\n placements: 16384,\n textureBytes: 256 * 1024 * 1024,\n});\n\nconst utf8 = new TextDecoder(\"utf-8\", { fatal: true });\nconst utf8Encoder = new TextEncoder();\n\nexport function assertCommandSize(command: unknown): void {\n if (utf8Encoder.encode(JSON.stringify(command)).byteLength > LIMITS.commandBytes)\n throw new RangeError(\"Terminal input exceeds the 64 KiB message limit. Send a smaller amount of text.\");\n}\n\nfunction integer(value: unknown, name: string, min = 0, max = Number.MAX_SAFE_INTEGER): number {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < min || value > max) {\n throw new Error(`Invalid ${name}: ${String(value)}`);\n }\n return value;\n}\n\nfunction array(value: unknown, name: string, limit: number): asserts value is unknown[] {\n if (!Array.isArray(value) || value.length > limit) throw new Error(`Invalid ${name}`);\n}\n\nfunction key(value: unknown): asserts value is string {\n if (typeof value !== \"string\" || !value.length || value.length > 1024) {\n throw new Error(\"Invalid image key\");\n }\n}\n\nfunction rowId(value: unknown, name: string): asserts value is string {\n if (typeof value !== \"string\" || !/^[1-9][0-9]{0,18}$/u.test(value) || BigInt(value) > 9223372036854775807n) {\n throw new Error(`Invalid ${name}`);\n }\n}\n\nexport function validateHistory(history: unknown, columns: number, rows: number): asserts history is HistoryMetadata | null {\n if (history === null) return;\n if (!isRecord(history)) throw new Error(\"Missing history metadata\");\n rowId(history.generation, \"history generation\");\n if (history.buffer !== \"main\" && history.buffer !== \"alternate\") throw new Error(\"Invalid history buffer\");\n const totalRows = integer(history.totalRows, \"history total rows\", rows, 2147483647);\n const liveTop = integer(history.liveTop, \"history live top\", 0, totalRows - rows);\n if (liveTop !== totalRows - rows) throw new Error(\"Inconsistent history extent\");\n integer(history.top, \"history top\", 0, liveTop);\n if (typeof history.following !== \"boolean\" || (history.following && history.top !== history.liveTop)) {\n throw new Error(\"Invalid history following state\");\n }\n integer(history.requestId, \"viewport request id\");\n array(history.rowIds, \"viewport row ids\", rows);\n if (history.rowIds.length !== rows || new Set(history.rowIds).size !== rows) throw new Error(\"Invalid viewport row ids\");\n for (const id of history.rowIds) rowId(id, \"viewport row id\");\n const selection = history.selection;\n if (!isRecord(selection) || typeof selection.status !== \"string\" ||\n ![\"none\", \"valid\", \"invalidated\"].includes(selection.status)) throw new Error(\"Invalid selection status\");\n integer(selection.requestId, \"selection request id\");\n if (typeof selection.mode !== \"string\" || ![\"character\", \"word\", \"line\", \"rectangle\"].includes(selection.mode)) throw new Error(\"Invalid selection mode\");\n array(selection.ranges, \"selection ranges\", rows);\n let previousRow = -1;\n for (const range of selection.ranges) {\n if (!isRecord(range)) throw new Error(\"Invalid selection range\");\n const row = integer(range.row, \"selection range row\", previousRow + 1, rows - 1);\n const startColumn = integer(range.startColumn, \"selection start column\", 0, columns - 1);\n integer(range.endColumn, \"selection end column\", startColumn + 1, columns);\n previousRow = row;\n }\n validateSelectionText(selection);\n if (selection.status !== \"valid\" && selection.ranges.length) throw new Error(\"Inactive selection has highlight ranges\");\n if (history.copy !== null) {\n if (!isRecord(history.copy)) throw new Error(\"Missing copy metadata\");\n integer(history.copy.requestId, \"copy request id\", 1);\n validateSelectionText(history.copy);\n }\n}\n\nfunction validateSelectionText(selection: Record<string, unknown>): asserts selection is Record<string, unknown> & SelectionText {\n if (typeof selection.status !== \"string\" || ![\"none\", \"valid\", \"invalidated\"].includes(selection.status) ||\n (selection.status === \"valid\"\n ? typeof selection.text !== \"string\" || selection.text.length > LIMITS.metadataBytes\n : selection.text !== null)) {\n throw new Error(\"Invalid selection text\");\n }\n}\n\nfunction validateMetadata(metadata: unknown): asserts metadata is FrameMetadata {\n if (!isRecord(metadata) || metadata.version !== 1 || typeof metadata.full !== \"boolean\") {\n throw new Error(\"Unsupported frame metadata version\");\n }\n integer(metadata.revision, \"revision\", 1);\n integer(metadata.baseRevision, \"base revision\");\n const columns = integer(metadata.columns, \"columns\", 1, 1024);\n const rows = integer(metadata.rows, \"rows\", 1, 512);\n if (typeof metadata.mouseTracking !== \"number\" || ![0, 9, 1000, 1002, 1003].includes(metadata.mouseTracking)) {\n throw new Error(\"Unsupported mouse tracking mode\");\n }\n if (!isRecord(metadata.peer) || typeof metadata.peer.isPrimary !== \"boolean\") throw new Error(\"Invalid peer state\");\n for (const field of [\"id\", \"primaryId\"]) {\n const id = metadata.peer[field];\n if (id !== null && (typeof id !== \"string\" || !id.length || id.length > 256)) {\n throw new Error(`Invalid peer ${field}`);\n }\n }\n if (metadata.peer.id !== null && metadata.peer.isPrimary !== (metadata.peer.id === metadata.peer.primaryId)) {\n throw new Error(\"Inconsistent primary peer state\");\n }\n integer(columns * rows, \"cell count\", 1, LIMITS.cells);\n validateHistory(metadata.history, columns, rows);\n if (metadata.cellWidth !== 10 || metadata.cellHeight !== 20) {\n throw new Error(\"This spike requires server geometry of 10 × 20 logical pixels\");\n }\n for (const field of [\"defaultBackground\", \"defaultForeground\"]) {\n if (metadata[field] !== undefined) integer(metadata[field], field, 0, 0xffffffff);\n }\n if (!isRecord(metadata.cursor) || typeof metadata.cursor.visible !== \"boolean\") throw new Error(\"Invalid cursor\");\n integer(metadata.cursor.x, \"cursor x\", -1, 1024);\n integer(metadata.cursor.y, \"cursor y\", -1, 512);\n const shapes = [\"Default\", \"BlinkingBlock\", \"SteadyBlock\", \"BlinkingUnderline\", \"SteadyUnderline\", \"BlinkingBar\", \"SteadyBar\"];\n if (typeof metadata.cursor.shape === \"string\") metadata.cursor.shape = shapes.indexOf(metadata.cursor.shape);\n integer(metadata.cursor.shape, \"cursor shape\", 0, 6);\n array(metadata.images, \"images\", LIMITS.images);\n array(metadata.retainedImages, \"retained image keys\", LIMITS.images);\n array(metadata.placements, \"placements\", LIMITS.placements);\n array(metadata.warnings, \"warnings\", 256);\n if (metadata.warnings.some(w => typeof w !== \"string\")) throw new Error(\"Invalid warning\");\n if (!isRecord(metadata.stats)) throw new Error(\"Invalid server metrics\");\n for (const field of [\"workloadBytes\", \"outputBatches\", \"captureMs\", \"elapsedMs\"]) {\n const metric = metadata.stats[field];\n if (typeof metric !== \"number\" || !Number.isFinite(metric) || metric < 0) {\n throw new Error(`Invalid server metric ${field}`);\n }\n }\n const retained = new Set<string>();\n for (const imageKey of metadata.retainedImages) {\n key(imageKey);\n if (retained.has(imageKey)) throw new Error(\"Duplicate retained image key\");\n retained.add(imageKey);\n }\n const imageKeys = new Set<string>();\n let decodedImageBytes = 0;\n for (const image of metadata.images) {\n if (!isRecord(image)) throw new Error(\"Invalid image\");\n key(image.key);\n if (imageKeys.has(image.key) || !retained.has(image.key)) throw new Error(\"Inconsistent new image keys\");\n imageKeys.add(image.key);\n const width = integer(image.width, \"image width\", 1, 16384);\n const height = integer(image.height, \"image height\", 1, 16384);\n const byteLength = integer(image.byteLength, \"image byte length\", 1, LIMITS.frameBytes);\n if (image.format !== \"rgba\" && image.format !== \"png\") throw new Error(\"Unsupported image format\");\n if (image.format === \"rgba\" && byteLength !== width * height * 4) {\n throw new Error(\"RGBA image size mismatch\");\n }\n decodedImageBytes += width * height * 4;\n if (decodedImageBytes > LIMITS.textureBytes) throw new Error(\"New images exceed decoded texture budget\");\n }\n for (const placement of metadata.placements) {\n if (!isRecord(placement)) throw new Error(\"Invalid placement\");\n key(placement.key);\n if (!retained.has(placement.key)) throw new Error(\"Placement references an unretained image\");\n if (placement.kind !== \"kgp\" && placement.kind !== \"sixel\") throw new Error(\"Invalid placement kind\");\n for (const field of [\"x\", \"y\", \"width\", \"height\", \"sourceX\", \"sourceY\", \"sourceWidth\", \"sourceHeight\", \"clipX\", \"clipY\", \"clipWidth\", \"clipHeight\", \"z\"]) {\n const coordinate = placement[field];\n if (typeof coordinate !== \"number\" || !Number.isFinite(coordinate) || Math.abs(coordinate) > 2147483648) {\n throw new Error(`Invalid placement ${field}`);\n }\n }\n for (const field of [\"width\", \"height\", \"sourceWidth\", \"sourceHeight\", \"clipWidth\", \"clipHeight\"]) {\n const coordinate = placement[field];\n if (typeof coordinate !== \"number\" || coordinate < 0) throw new Error(`Negative placement ${field}`);\n }\n }\n}\n\n/** Decode one complete, experimental HWT1 message, checking every boundary before reading. */\nexport function decodeFrame(buffer: unknown): TerminalFrame {\n if (!(buffer instanceof ArrayBuffer) || buffer.byteLength > LIMITS.frameBytes) {\n throw new Error(\"Invalid or oversized binary frame\");\n }\n const view = new DataView(buffer);\n let offset = 0;\n const requireBytes = (count: number) => {\n if (count < 0 || count > view.byteLength - offset) throw new Error(\"Truncated HWT1 frame\");\n };\n const u32 = () => { requireBytes(4); const n = view.getUint32(offset, true); offset += 4; return n; };\n if (u32() !== 0x31545748) throw new Error(\"Unsupported frame magic (expected HWT1)\");\n const metadataLength = integer(u32(), \"metadata length\", 2, LIMITS.metadataBytes);\n requireBytes(metadataLength);\n const metadata: unknown = JSON.parse(utf8.decode(new Uint8Array(buffer, offset, metadataLength)));\n offset += metadataLength;\n validateMetadata(metadata);\n const cellCount = metadata.columns * metadata.rows;\n const changedCount = integer(u32(), \"changed cell count\", 0, cellCount);\n if (changedCount > Math.floor((view.byteLength - offset) / 22)) throw new Error(\"Truncated cell records\");\n if (metadata.full && changedCount !== cellCount) throw new Error(\"Incomplete full frame\");\n const cells = [];\n const seen = new Set();\n for (let i = 0; i < changedCount; i++) {\n requireBytes(22);\n const index = u32();\n if (index >= cellCount || seen.has(index)) throw new Error(\"Invalid or duplicate cell index\");\n seen.add(index);\n const foreground = u32();\n const background = u32();\n const underlineColor = u32();\n const attributes = view.getUint16(offset, true);\n const width = view.getUint8(offset + 2);\n const underlineStyle = view.getUint8(offset + 3);\n const textLength = view.getUint16(offset + 4, true);\n offset += 6;\n if (underlineStyle > 5) throw new Error(\"Unsupported underline style\");\n requireBytes(textLength);\n const text = utf8.decode(new Uint8Array(buffer, offset, textLength));\n offset += textLength;\n cells.push({ index, foreground, background, underlineColor, attributes, width, underlineStyle, text });\n }\n const imageBytes = metadata.images.reduce((total, image) => total + image.byteLength, 0);\n if (imageBytes !== view.byteLength - offset) throw new Error(\"Image payload length mismatch\");\n const images = metadata.images.map(image => {\n const bytes = new Uint8Array(buffer, offset, image.byteLength);\n offset += image.byteLength;\n return { ...image, bytes };\n });\n return { metadata, cells, images };\n}\n\n/** Mirror text, not ANSI; continuation cells are already represented by their lead glyph. */\nexport function screenText(cells: readonly (TerminalCell | undefined)[], columns: number, rows: number): string {\n const lines = [];\n for (let y = 0; y < rows; y++) {\n let line = \"\";\n for (let x = 0; x < columns; x++) {\n const cell = cells[y * columns + x];\n if (!cell || cell.width === 0) continue;\n line += cell.attributes & 64 ? \" \".repeat(cell.width) : (cell.text || \" \");\n }\n lines.push(line.replace(/ +$/u, \"\"));\n }\n return lines.join(\"\\n\");\n}\n"]}
@@ -0,0 +1,113 @@
1
+ import type { FontMetrics, LoadedFont, NormalizedFont } from "./terminal-font.js";
2
+ import type { TerminalFont, TerminalSize } from "./types.js";
3
+ import type { FrameImage, FrameMetadata, ImagePlacement, TerminalCell } from "./wire-types.js";
4
+ type Vector4 = [number, number, number, number];
5
+ interface TextureResource {
6
+ texture: GPUTexture;
7
+ bindGroup: GPUBindGroup;
8
+ width: number;
9
+ height: number;
10
+ }
11
+ interface Shelf {
12
+ x: number;
13
+ y: number;
14
+ rowHeight: number;
15
+ }
16
+ interface GlyphPlacement {
17
+ key: string;
18
+ cell: TerminalCell;
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ }
24
+ interface Glyph {
25
+ colored: boolean;
26
+ u0: number;
27
+ v0: number;
28
+ u1: number;
29
+ v1: number;
30
+ }
31
+ interface Batch {
32
+ resource: TextureResource;
33
+ start: number;
34
+ count: number;
35
+ }
36
+ /** WebGPU instanced quads; Canvas2D is used only to rasterize reusable glyphs. */
37
+ export declare class TerminalRenderer {
38
+ canvas: OffscreenCanvas;
39
+ scale: number;
40
+ backingScale: number;
41
+ device: GPUDevice;
42
+ fontConfiguration: NormalizedFont;
43
+ fontMetrics: Map<number, FontMetrics>;
44
+ context: GPUCanvasContext;
45
+ images: Map<string, TextureResource>;
46
+ glyphs: Map<string, Glyph>;
47
+ imageUploadBytes: number;
48
+ imagePayloadBytes: number;
49
+ glyphUploadBytes: number;
50
+ atlasRebuilds: number;
51
+ textureBytes: number;
52
+ instances: Float32Array<ArrayBuffer>;
53
+ instanceBuffer: GPUBuffer | null;
54
+ instanceBufferBytes: number;
55
+ disposed: boolean;
56
+ columns: number;
57
+ rows: number;
58
+ font: LoadedFont;
59
+ format: GPUTextureFormat;
60
+ uniform: GPUBuffer;
61
+ sampler: GPUSampler;
62
+ pipeline: GPURenderPipeline;
63
+ rasterCanvas: OffscreenCanvas;
64
+ raster: OffscreenCanvasRenderingContext2D;
65
+ atlas: TextureResource;
66
+ glyphKeyUnits: number;
67
+ shelf: Shelf;
68
+ canvasLimited: boolean;
69
+ width: number;
70
+ height: number;
71
+ quadCount: number;
72
+ batches: Batch[];
73
+ static create(canvas: OffscreenCanvas, scale: number, onFatal: (error: Error | GPUError) => void, font: TerminalFont): Promise<TerminalRenderer>;
74
+ constructor(canvas: OffscreenCanvas, scale: number, device: GPUDevice, font: NormalizedFont);
75
+ initialize(): Promise<void>;
76
+ createTexture(width: number, height: number, label: string): TextureResource;
77
+ resetAtlas(size: number): void;
78
+ resize(columns: number, rows: number, viewport?: TerminalSize): void;
79
+ /** Call only between submissions. Missing/over-budget resources terminate the session. */
80
+ updateImages(incoming: readonly FrameImage[], retainedKeys: readonly string[]): Promise<void>;
81
+ prepareGlyphs(cells: readonly (TerminalCell | undefined)[]): void;
82
+ uploadGlyph({ key, cell, x, y, width, height }: GlyphPlacement): void;
83
+ /** Clip geometry and UVs together. Only adjacent compatible textures may coalesce. */
84
+ quad(resource: TextureResource, x: number, y: number, width: number, height: number, color: Vector4, mode?: number, uv?: Vector4, clip?: Vector4): void;
85
+ solid(x: number, y: number, width: number, height: number, color: Vector4): void;
86
+ placement(placement: ImagePlacement): void;
87
+ decorations(cell: TerminalCell, x: number, y: number, width: number, foreground: Vector4): void;
88
+ render(cells: readonly (TerminalCell | undefined)[], metadata: FrameMetadata, blinkOn: boolean): {
89
+ cpuMs: number;
90
+ quads: number;
91
+ drawCalls: number;
92
+ };
93
+ metrics(): {
94
+ fontFamily: string;
95
+ rasterScale: number;
96
+ backingScale: number;
97
+ backingWidth: number;
98
+ backingHeight: number;
99
+ imageCount: number;
100
+ textureBytes: number;
101
+ atlasGlyphs: number;
102
+ atlasBytes: number;
103
+ atlasRebuilds: number;
104
+ imageUploadBytes: number;
105
+ imagePayloadBytes: number;
106
+ glyphUploadBytes: number;
107
+ instanceBufferBytes: number;
108
+ };
109
+ idle(): Promise<void>;
110
+ dispose(): void;
111
+ }
112
+ export {};
113
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/F,KAAK,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAChD,UAAU,eAAe;IAAG,OAAO,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACzG,UAAU,KAAK;IAAG,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAC3D,UAAU,cAAc;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAA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