@neuroplastio/xterm-addon-hotty 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.
- package/LICENSE +73 -0
- package/README.md +358 -0
- package/dist/hotty-xterm.js +2906 -0
- package/dist/hotty-xterm.js.map +7 -0
- package/dist/types/addon.d.ts +170 -0
- package/dist/types/delta.d.ts +19 -0
- package/dist/types/hostcss.d.ts +48 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/network.d.ts +18 -0
- package/dist/types/resolver.d.ts +41 -0
- package/dist/types/resources.d.ts +32 -0
- package/dist/types/surface.d.ts +405 -0
- package/dist/types/touch.d.ts +37 -0
- package/dist/types/version.d.ts +10 -0
- package/dist/types/wire.d.ts +59 -0
- package/package.json +54 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/hostcss.ts", "../src/delta.ts", "../src/network.ts", "../src/resources.ts", "../src/touch.ts", "../src/resolver.ts", "../src/surface.ts", "../src/version.ts", "../src/wire.ts", "../src/addon.ts"],
|
|
4
|
+
"sourcesContent": ["// The host's stylesheet (PROTOCOL \u00A77): the terminal's look, handed to every\n// surface. It sits in a cascade layer, so any rule the program writes wins\n// over it, as it would over a user-agent sheet.\n\nimport type { ITheme } from \"@xterm/xterm\";\n\nexport interface Metrics {\n /** Cell size in CSS pixels. */\n cellW: number;\n cellH: number;\n fontFamily: string;\n fontSize: number;\n}\n\n// xterm.js's own defaults (src/browser/services/ThemeService.ts:23-24,\n// src/browser/Types.ts:181), for themes that leave colours out.\nconst DEFAULT_FG = \"#ffffff\";\nconst DEFAULT_BG = \"#000000\";\nconst ANSI_KEYS = [\"black\", \"red\", \"green\", \"yellow\", \"blue\", \"magenta\", \"cyan\", \"white\", \"brightBlack\", \"brightRed\", \"brightGreen\", \"brightYellow\", \"brightBlue\", \"brightMagenta\", \"brightCyan\", \"brightWhite\"] as const;\nconst DEFAULT_ANSI = [\"#2e3436\", \"#cc0000\", \"#4e9a06\", \"#c4a000\", \"#3465a4\", \"#75507b\", \"#06989a\", \"#d3d7cf\", \"#555753\", \"#ef2929\", \"#8ae234\", \"#fce94f\", \"#729fcf\", \"#ad7fa8\", \"#34e2e2\", \"#eeeeec\"];\n\nexport function palette(theme: ITheme | undefined) {\n const fg = theme?.foreground ?? DEFAULT_FG;\n const bg = theme?.background ?? DEFAULT_BG;\n const ansi = ANSI_KEYS.map((k, i) => theme?.[k] ?? DEFAULT_ANSI[i]!);\n return { fg, bg, ansi, dark: luminance(bg) < 0.5 };\n}\n\n/** The host stylesheet, the same for every surface. What scrolls is each\n * document's own (`scrollCss`). */\nexport function hostCss(theme: ITheme | undefined, m: Metrics): string {\n const p = palette(theme);\n const lines = [\n \"@layer hotty-host {\",\n \":root {\",\n ` color-scheme: ${p.dark ? \"dark\" : \"light\"};`,\n ` --hotty-fg: ${p.fg};`,\n ` --hotty-bg: ${p.bg};`,\n ...p.ansi.map((c, i) => ` --hotty-ansi-${i}: ${c};`),\n // The terminal's blue: plain blue is hard to read on a dark background.\n ` --hotty-accent: var(--hotty-ansi-${p.dark ? 12 : 4});`,\n ` --hotty-cell-w: ${m.cellW}px;`,\n ` --hotty-cell-h: ${m.cellH}px;`,\n ` --hotty-font: ${fontStack(m.fontFamily)};`,\n \" font-family: var(--hotty-font);\",\n ` font-size: ${m.fontSize}px;`,\n // An explicit line-height, so that `1rlh` is one terminal row.\n ` line-height: ${m.cellH}px;`,\n \" color: var(--hotty-fg);\",\n \" background: var(--hotty-bg);\",\n \" accent-color: var(--hotty-accent);\",\n \"}\",\n \"body { margin: 0; }\",\n // Controls in the terminal's colours (SPEC \u00A78), not the browser's: ansi-8\n // is the dim grey of borders, buttons, placeholders and what is disabled.\n // :where() keeps the base rule below the state rules after it, such as\n // :disabled.\n \":where(input:not([type=checkbox], [type=radio], [type=range]), textarea,\",\n \" select, button) {\",\n \" color: var(--hotty-fg);\",\n \" background: var(--hotty-bg);\",\n \" border: 1px solid var(--hotty-ansi-8);\",\n \"}\",\n \"button:enabled, input:is([type=button], [type=submit], [type=reset]):enabled {\",\n \" background: var(--hotty-ansi-8);\",\n \"}\",\n \"::placeholder, :disabled { color: var(--hotty-ansi-8); }\",\n \":focus-visible { outline: 1px solid var(--hotty-accent); }\",\n \":any-link { color: var(--hotty-accent); }\",\n \"::selection { color: var(--hotty-bg); background: var(--hotty-accent); }\",\n // An element that opts in to drags selects no text, whatever the\n // document's CSS (SPEC \u00A79.1, \u00A711): important in the host's layer, the\n // first, wins over every rule of the document's.\n \"[data-on~=drag], [data-on~=drag] * { -webkit-user-select: none !important; user-select: none !important; }\",\n // The rows a document needs are measured with no scrollbar of the root's\n // in the way (`r=auto`, `fit`, SPEC \u00A75.2).\n `:root[${MEASURE}] { overflow: hidden !important; }`,\n \"}\",\n ];\n return lines.join(\"\\n\");\n}\n\n/** The host's own attribute on the root while the rows a document needs are\n * measured. Under the addon's vendor prefix: `data-hotty-*` is the spec's\n * (\u00A715). */\nexport const MEASURE = \"data-xterm-hotty-measure\";\n\n/** The host's own attribute on an element of a document that scrolls along\n * one axis, whose `overflow` along the other is `auto` or `scroll`: that\n * axis is clipped as `overflow: hidden` clips it (SPEC \u00A75.3). */\nexport const CLIP = \"data-xterm-hotty-clip\";\n\n/** Set on the root while the addon reads which elements need `CLIP`: the\n * values the document gives them, without the host's. */\nexport const UNCLIPPED = \"data-xterm-hotty-unclipped\";\n\n/**\n * What scrolls in a document (SPEC \u00A75.1, \u00A75.3): the axes it asked for, a\n * bitmask (1 vertically, 2 horizontally). `pageScrolls`: the page scrolls,\n * not the terminal (the addon's `scroll` option), and the browser pans it\n * from a surface.\n *\n * - **None:** a surface is a fixed rectangle of cells, and nothing in it\n * scrolls: what does not fit is clipped. The browser pans nothing on a\n * touch (a drag is the terminal's, SPEC \u00A79; the surface forwards it),\n * unless the page scrolls, which the browser pans as from the cells.\n * Nothing shows a scrollbar, even with `overflow: auto`.\n * - **Along the axes asked for,** the document scrolls as a page does, with\n * the browser's scrollbars, inside the frame: they take pixels, never\n * cells. The browser pans those axes on a touch.\n * - **Along an axis not asked for,** the root and every element `CLIP`\n * marks are `overflow: hidden` there, important in the host's layer, so\n * that the document's CSS cannot undo it: no scrollbar, and nothing the\n * user does moves it.\n */\nexport function scrollCss(axes: number, pageScrolls: boolean): string {\n if (!axes) {\n return [\n \"@layer hotty-host {\",\n `:root { overflow: hidden; touch-action: ${pageScrolls ? \"manipulation\" : \"none\"}; }`,\n \"* { scrollbar-width: none !important; }\",\n \"::-webkit-scrollbar { display: none !important; }\",\n \"}\",\n ].join(\"\\n\");\n }\n const pan = pageScrolls ? \"manipulation\" : axes === 3 ? \"pan-x pan-y\" : axes === 1 ? \"pan-y\" : \"pan-x\";\n const lines = [\"@layer hotty-host {\", `:root { touch-action: ${pan}; }`];\n if (axes !== 3) {\n const clipped = axes === 1 ? \"overflow-x\" : \"overflow-y\";\n lines.push(`:root, :root:not([${UNCLIPPED}]) [${CLIP}] { ${clipped}: hidden !important; }`);\n }\n lines.push(\"}\");\n return lines.join(\"\\n\");\n}\n\nfunction fontStack(family: string): string {\n const f = family.trim();\n if (!f) return \"monospace\";\n // xterm's fontFamily is already a CSS font-family list.\n return /monospace\\s*$/.test(f) ? f : `${f}, monospace`;\n}\n\n/** Relative luminance of a `#rrggbb` (or `#rgb`) colour; 0 for anything else. */\nfunction luminance(color: string): number {\n let hex = color.trim().replace(/^#/, \"\");\n if (hex.length === 3) hex = hex.replace(/./g, (c) => c + c);\n if (!/^[0-9a-f]{6}/i.test(hex)) return 0;\n const [r, g, b] = [0, 2, 4].map((i) => {\n const c = parseInt(hex.slice(i, i + 2), 16) / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r! + 0.7152 * g! + 0.0722 * b!;\n}\n", "// Deltas (SPEC \u00A76): operations on one surface's document, addressed by\n// element id, and the morph that keeps element identity.\n//\n// SPEC \u00A76's rules (as hotty-blitz implements them), for the browser's DOM:\n// fragments parse inert in a <template>, which also accepts table rows and\n// list items without a context element; only what the morph keeps or inserts\n// reaches the live document, and a focused control keeps what the user typed.\n\nimport type { Resolver } from \"./resolver.ts\";\n\nexport class DeltaError extends Error {\n readonly code: string;\n constructor(code: string, detail: string) {\n super(detail);\n this.code = code;\n }\n}\n\nexport const OPS = [\"morph\", \"inner\", \"replace\", \"append\", \"prepend\", \"before\", \"after\", \"remove\", \"attr\", \"unattr\", \"text\", \"var\"];\n\nexport class Deltas {\n private readonly doc: Document;\n private readonly resolver: Resolver;\n\n constructor(doc: Document, resolver: Resolver) {\n this.doc = doc;\n this.resolver = resolver;\n }\n\n /** Parses a fragment inert, cleaned and resolved. */\n parse(html: string): Node[] {\n const t = this.doc.createElement(\"template\");\n t.innerHTML = html;\n this.resolver.adopt(t.content);\n return Array.from(t.content.childNodes);\n }\n\n apply(op: string, target: string | undefined, key: string | undefined, payload: string): void {\n const find = (): Element => {\n if (!target) throw new DeltaError(\"EINVAL\", `op=${op} needs t=<element id>`);\n const el = this.doc.getElementById(target);\n if (!el) throw new DeltaError(\"ENOTARGET\", target);\n return el;\n };\n const needKey = (): string => {\n if (!key) throw new DeltaError(\"EINVAL\", `op=${op} needs k=<name>`);\n return key;\n };\n switch (op) {\n case \"\":\n case \"morph\": {\n if (target === undefined) {\n const missing: string[] = [];\n for (const k of this.parse(payload)) {\n if (k.nodeType !== 1) continue;\n const id = (k as Element).getAttribute(\"id\");\n const old = id ? this.doc.getElementById(id) : null;\n if (old) this.morphNode(old, k);\n else missing.push(id ?? \"(element without id)\");\n }\n if (missing.length) throw new DeltaError(\"ENOTARGET\", missing.join(\",\"));\n return;\n }\n const t = find();\n const frag = this.parse(payload);\n const elements = frag.filter((n) => n.nodeType === 1);\n if (elements.length === 1) {\n this.morphNode(t, elements[0]!);\n } else {\n t.before(...frag);\n t.remove();\n }\n return;\n }\n case \"inner\":\n this.morphChildren(find(), this.parse(payload));\n return;\n case \"replace\": {\n const t = find();\n t.before(...this.parse(payload));\n t.remove();\n return;\n }\n case \"append\":\n case \"prepend\": {\n const t = find();\n const fresh: Node[] = [];\n // As Turbo: a child with the same id is morphed in place, not duplicated.\n for (const k of this.parse(payload)) {\n const id = k.nodeType === 1 ? (k as Element).getAttribute(\"id\") : null;\n const old = id ? this.doc.getElementById(id) : null;\n if (old && old.parentNode === t) this.morphNode(old, k);\n else fresh.push(k);\n }\n if (op === \"append\") t.append(...fresh);\n else t.prepend(...fresh);\n return;\n }\n case \"before\":\n find().before(...this.parse(payload));\n return;\n case \"after\":\n find().after(...this.parse(payload));\n return;\n case \"remove\":\n find().remove();\n return;\n case \"attr\": {\n const t = find();\n const name = needKey();\n this.resolver.set(t, name, payload);\n syncProperty(t, name, payload, this.doc.activeElement === t);\n return;\n }\n case \"unattr\": {\n const t = find();\n const name = needKey();\n this.resolver.remove(t, name);\n syncProperty(t, name, null, this.doc.activeElement === t);\n return;\n }\n case \"text\": {\n const t = find();\n if (t.localName === \"style\") this.resolver.setCss(t, payload);\n else if (t.childNodes.length === 1 && t.firstChild!.nodeType === 3) (t.firstChild as Text).data = payload;\n else t.textContent = payload;\n return;\n }\n case \"var\": {\n const t = find();\n const k = needKey();\n const name = k.startsWith(\"--\") ? k : `--${k}`;\n (t as HTMLElement).style?.setProperty(name, payload);\n return;\n }\n default:\n throw new DeltaError(\"EINVAL\", `unknown op=${op}`);\n }\n }\n\n /** Makes `old` (live) look like `neu` (parsed), keeping `old` where possible. Returns the node now in place. */\n morphNode(old: Node, neu: Node): Node {\n if (old.nodeType === 3 && neu.nodeType === 3) {\n if ((old as Text).data !== (neu as Text).data) (old as Text).data = (neu as Text).data;\n return old;\n }\n if (old.nodeType === 8 && neu.nodeType === 8) return old;\n if (old.nodeType === 1 && neu.nodeType === 1) {\n const a = old as Element;\n const b = neu as Element;\n const ia = a.getAttribute(\"id\");\n const ib = b.getAttribute(\"id\");\n if (a.localName === b.localName && a.namespaceURI === b.namespaceURI && (ia === ib || ia === null || ib === null)) {\n this.syncAttributes(a, b);\n if (a.localName === \"style\") {\n const css = this.resolver.cssOf(b);\n if (this.resolver.cssOf(a) !== css) this.resolver.setCss(a, css);\n } else {\n const kids = a.localName === \"template\" ? (b as HTMLTemplateElement).content.childNodes : b.childNodes;\n this.morphChildren(a.localName === \"template\" ? (a as HTMLTemplateElement).content : a, Array.from(kids));\n }\n return a;\n }\n }\n (old as ChildNode).replaceWith(neu);\n return neu;\n }\n\n private syncAttributes(old: Element, neu: Element) {\n const oldAttrs = this.resolver.attributes(old);\n const newAttrs = this.resolver.attributes(neu);\n // A control the user is editing keeps what they typed (idiomorph does the same).\n const focused = this.doc.activeElement === old;\n for (const [name, value] of newAttrs) {\n if (focused && name === \"value\") continue;\n const had = oldAttrs.find(([n]) => n === name);\n if (!had || had[1] !== value) {\n this.resolver.set(old, name, value);\n syncProperty(old, name, value, focused);\n }\n }\n for (const [name] of oldAttrs) {\n if (!newAttrs.some(([n]) => n === name)) {\n this.resolver.remove(old, name);\n syncProperty(old, name, null, focused);\n }\n }\n }\n\n /** Morphs the children of `parent` (live) into `kids` (parsed). */\n morphChildren(parent: Node, kids: Node[]): void {\n const oldKids = Array.from(parent.childNodes);\n const idOf = (n: Node) => (n.nodeType === 1 ? (n as Element).getAttribute(\"id\") : null);\n const newIds = new Set(kids.map(idOf).filter((x): x is string => x !== null));\n const used = new Set<Node>();\n const plan: [Node | null, Node][] = [];\n let cursor = 0;\n for (const nk of kids) {\n const id = idOf(nk);\n let match: Node | null = null;\n if (id !== null) {\n match = oldKids.find((ok) => !used.has(ok) && idOf(ok) === id) ?? null;\n } else {\n // Positional match on the same kind of node, skipping old children\n // whose id the new list still wants.\n for (let i = cursor; i < oldKids.length; i++) {\n const ok = oldKids[i]!;\n if (used.has(ok)) continue;\n const okId = idOf(ok);\n let same = false;\n if (okId !== null && newIds.has(okId)) same = false;\n else if (ok.nodeType === 1 && nk.nodeType === 1)\n same = okId === null && (ok as Element).localName === (nk as Element).localName && (ok as Element).namespaceURI === (nk as Element).namespaceURI;\n else same = ok.nodeType === nk.nodeType && (ok.nodeType === 3 || ok.nodeType === 8);\n if (same) {\n match = ok;\n cursor = i + 1;\n break;\n }\n }\n }\n if (match) used.add(match);\n plan.push([match, nk]);\n }\n for (const ok of oldKids) if (!used.has(ok)) (ok as ChildNode).remove();\n // Morph the kept nodes, insert the new ones, and put everything in order,\n // moving (not recreating) the kept ones.\n plan.forEach(([keep, nk], i) => {\n const want = keep ? this.morphNode(keep, nk) : nk;\n const current = parent.childNodes[i] ?? null;\n if (current !== want) move(parent, want, current);\n });\n }\n}\n\n/** Moves a node, keeping focus and state where the browser can (`moveBefore`). */\nfunction move(parent: Node, node: Node, before: Node | null) {\n const p = parent as Node & { moveBefore?: (n: Node, r: Node | null) => void };\n if (node.parentNode === parent && typeof p.moveBefore === \"function\") {\n try {\n p.moveBefore(node, before);\n return;\n } catch {\n /* fall through */\n }\n }\n parent.insertBefore(node, before);\n}\n\n/**\n * Attributes that only set a control's *default*: the program's value is the\n * live one unless the user is editing that control (SPEC \u00A76.2).\n */\nfunction syncProperty(el: Element, name: string, value: string | null, focused: boolean) {\n if (focused) return;\n const n = name.toLowerCase();\n if (n === \"value\" && \"value\" in el && (el.localName === \"input\" || el.localName === \"textarea\" || el.localName === \"select\")) {\n (el as HTMLInputElement).value = value ?? \"\";\n } else if (n === \"checked\" && el.localName === \"input\") {\n (el as HTMLInputElement).checked = value !== null;\n } else if (n === \"selected\" && el.localName === \"option\") {\n (el as HTMLOptionElement).selected = value !== null;\n }\n}\n", "// The network policy (SPEC \u00A77.2): what a surface may fetch from the network.\n//\n// The host's half is the embedder's `network` option; the document's half is\n// its `<meta name=\"hotty-network\">`. A URL may be fetched only when a source\n// in each half matches it, for the directive that covers it. The resolver\n// enforces the intersection per document; the iframe's CSP holds the host's\n// half on its own, so a reference the resolver misses can still reach\n// nothing the embedder did not grant.\n\nexport type Directive = \"img-src\" | \"media-src\" | \"font-src\" | \"style-src\";\nexport const DIRECTIVES: readonly Directive[] = [\"img-src\", \"media-src\", \"font-src\", \"style-src\"];\n\n/** Directive \u2192 sources: origins (`https://example.com`) or `https:`. */\nexport type Policy = Partial<Record<Directive, string[]>>;\n\n/** A source in canonical form, or null if it is not one HOTTY allows. */\nexport function source(s: string): string | null {\n const v = s.trim().toLowerCase();\n if (v === \"https:\") return v;\n let u: URL;\n try {\n u = new URL(v);\n } catch {\n return null;\n }\n if (u.protocol !== \"https:\" && u.protocol !== \"http:\") return null;\n // An origin: nothing after the host and port.\n if ((u.pathname !== \"/\" && u.pathname !== \"\") || u.search || u.hash || u.username || u.password) return null;\n if (!/^https?:\\/\\/[^/]+\\/?$/.test(v)) return null;\n return u.origin;\n}\n\n/** A policy with only valid directives and sources. */\nexport function clean(p: Policy | undefined): Policy {\n const out: Policy = {};\n for (const d of DIRECTIVES) {\n const srcs = (p?.[d] ?? []).map(source).filter((s): s is string => s !== null);\n if (srcs.length) out[d] = [...new Set(srcs)];\n }\n return out;\n}\n\n/** A document's request, from its `<meta name=\"hotty-network\">` content (CSP syntax). */\nexport function parse(content: string): Policy {\n const p: Policy = {};\n for (const part of content.split(\";\")) {\n const [name, ...srcs] = part.trim().split(/\\s+/);\n const d = (name ?? \"\").toLowerCase() as Directive;\n if (DIRECTIVES.includes(d)) p[d] = [...(p[d] ?? []), ...srcs];\n }\n return clean(p);\n}\n\nfunction matches(src: string, url: URL): boolean {\n if (src === \"https:\") return url.protocol === \"https:\";\n return url.origin === src;\n}\n\n/** What both halves allow: sources of the document that the host's cover. */\nexport function intersect(host: Policy, doc: Policy): Policy {\n const out: Policy = {};\n for (const d of DIRECTIVES) {\n const h = host[d] ?? [];\n const res = new Set<string>();\n for (const s of doc[d] ?? []) {\n if (s === \"https:\") {\n // The document asks for any HTTPS origin: it gets the host's HTTPS ones.\n for (const hs of h) if (hs === \"https:\" || hs.startsWith(\"https://\")) res.add(hs);\n } else if (h.some((hs) => matches(hs, new URL(s)))) {\n res.add(s);\n }\n }\n if (res.size) out[d] = [...res];\n }\n return out;\n}\n\n/** Whether a policy allows fetching an absolute URL for a directive. */\nexport function allows(p: Policy, d: Directive, url: string): boolean {\n let u: URL;\n try {\n u = new URL(url);\n } catch {\n return false;\n }\n return (p[d] ?? []).some((s) => matches(s, u));\n}\n\n/** A directive's sources as CSP source expressions. */\nexport function cspSources(p: Policy, d: Directive): string {\n return (p[d] ?? []).join(\" \");\n}\n\n/** The directive that covers an attribute of an element, if it fetches at all. */\nexport function directiveFor(tag: string, attr: string, rel = \"\"): Directive | null {\n if (attr === \"srcset\") return \"img-src\";\n if (attr === \"poster\") return \"img-src\";\n if (attr === \"src\") {\n if (tag === \"img\" || tag === \"input\" || tag === \"image\") return \"img-src\";\n if (tag === \"video\" || tag === \"audio\" || tag === \"source\" || tag === \"track\") return \"media-src\";\n }\n if ((attr === \"href\" || attr === \"xlink:href\") && (tag === \"image\" || tag === \"use\" || tag === \"feimage\")) return \"img-src\";\n if (attr === \"href\" && tag === \"link\" && rel.split(/\\s+/).includes(\"stylesheet\")) return \"style-src\";\n return null;\n}\n", "// Resources (PROTOCOL \u00A76): named bytes a document refers to as `cid:<name>`.\n//\n// The browser cannot load `cid:` URLs, so every reference is resolved to a\n// `blob:` URL before it reaches a live document, and the program's original\n// value is remembered so that morph compares against what the program wrote.\n// Stylesheets are rewritten too (their own `url(cid:\u2026)`), so a stylesheet's\n// blob depends on the resources it names; changing one re-resolves both.\n\nimport { allows, type Directive, type Policy } from \"./network.ts\";\n\nexport const INVALID = \"about:invalid\";\n\n/** The base URL no document declared (SPEC \u00A77.3): nothing under it loads. */\nexport const NO_BASE = \"https://hotty.invalid/\";\n\n/** What a document's references resolve against (SPEC \u00A77.2, \u00A77.3). */\nexport interface UrlContext {\n /** The document's base URL. */\n base: string;\n /** The effective network policy: the host's half and the document's. */\n policy: Policy;\n}\n\n/** A fetch the policy allows, as an absolute URL, or INVALID. Never relative:\n * a relative URL would resolve against the base in the browser, and reach\n * whatever the host's half (the CSP) allows, asked for or not. */\nfunction network(value: string, ctx: UrlContext | undefined, d: Directive): string {\n if (!ctx) return INVALID;\n let abs: string;\n try {\n abs = new URL(value, ctx.base).href;\n } catch {\n return INVALID;\n }\n return !abs.startsWith(NO_BASE) && allows(ctx.policy, d, abs) ? abs : INVALID;\n}\n\n/** Attributes that hold a URL, per element or globally. */\nconst URL_ATTRS = new Set([\"src\", \"href\", \"poster\", \"background\", \"data\", \"action\", \"formaction\", \"xlink:href\", \"srcset\", \"cite\", \"longdesc\", \"lowsrc\", \"manifest\", \"codebase\", \"usemap\", \"ping\"]);\n\nexport function isUrlAttr(name: string): boolean {\n return URL_ATTRS.has(name.toLowerCase());\n}\n\ninterface Entry {\n mime: string;\n bytes: Uint8Array;\n url: string | null;\n /** Resources this one's text names (stylesheets). */\n deps: Set<string>;\n}\n\nexport class Store {\n private entries = new Map<string, Entry>();\n private used = 0;\n readonly quota: number;\n /** Called with the names whose URL changed, so surfaces can re-resolve. */\n onChange: (names: Set<string>) => void = () => {};\n\n constructor(quota = 64 << 20) {\n this.quota = quota;\n }\n\n put(name: string, mime: string, bytes: Uint8Array): void {\n const old = this.entries.get(name);\n const next = this.used - (old?.bytes.length ?? 0) + bytes.length;\n if (next > this.quota) throw new Error(`resource store over quota (${next} > ${this.quota} bytes)`);\n this.used = next;\n this.entries.set(name, { mime, bytes, url: null, deps: new Set() });\n this.changed(name, old);\n }\n\n remove(name: string): boolean {\n const old = this.entries.get(name);\n if (!old) return false;\n this.used -= old.bytes.length;\n this.entries.delete(name);\n this.changed(name, old);\n return true;\n }\n\n /** The `blob:` URL for a resource, or `null` if there is none (yet). */\n url(name: string): string | null {\n const e = this.entries.get(name);\n if (!e) return null;\n if (e.url === null) {\n let bytes: Uint8Array = e.bytes;\n if (e.mime.startsWith(\"text/css\")) {\n e.deps.clear();\n const css = new TextDecoder().decode(e.bytes);\n bytes = new TextEncoder().encode(this.rewriteCss(css, e.deps));\n }\n e.url = URL.createObjectURL(new Blob([bytes as BlobPart], { type: e.mime }));\n }\n return e.url;\n }\n\n /** CSS text with every reference resolved; `names` collects the resources.\n * Without a context (a stylesheet resource, shared by surfaces with\n * different policies) nothing from the network is allowed. */\n rewriteCss(css: string, names: Set<string>, ctx?: UrlContext): string {\n const one = (raw: string, d: Directive[]): string => {\n const v = raw.trim();\n if (/^cid:/i.test(v)) {\n names.add(v.slice(4));\n return this.url(v.slice(4)) ?? INVALID;\n }\n if (/^data:/i.test(v) || /^blob:/i.test(v) || v.startsWith(\"#\")) return raw;\n // CSS does not say what a url() is for: an image or a font. The\n // resolver allows either; the CSP holds each to its own directive.\n for (const dir of d) {\n const r = network(v, ctx, dir);\n if (r !== INVALID) return r;\n }\n return INVALID;\n };\n return css\n .replace(/@import\\s+(?:url\\(\\s*)?(['\"])([^'\"]*)\\1\\s*\\)?/gi, (_m, _q, u: string) => `@import \"${one(u, [\"style-src\"])}\"`)\n .replace(/url\\(\\s*(['\"]?)([^'\")]*)\\1\\s*\\)/gi, (_m, _q, u: string) => `url(\"${one(u, [\"img-src\", \"font-src\"])}\")`);\n }\n\n /** Resolves one attribute value; `names` collects the resources it names.\n * `d` is the directive that covers the attribute, if it fetches. */\n resolveUrl(value: string, names: Set<string>, ctx?: UrlContext, d?: Directive | null): string {\n const v = value.trim();\n if (/^cid:/i.test(v)) {\n const name = v.slice(4);\n names.add(name);\n return this.url(name) ?? INVALID;\n }\n if (/^data:/i.test(v) || /^blob:/i.test(v) || v === \"\" || v.startsWith(\"#\")) return value;\n if (d) return network(v, ctx, d);\n // An attribute that does not fetch (cite, longdesc, a form's action):\n // relative stays relative, and an absolute URL fails closed.\n return /^[a-z][a-z0-9+.-]*:/i.test(v) ? INVALID : value;\n }\n\n private changed(name: string, old: Entry | undefined) {\n const names = new Set([name]);\n // Stylesheets naming this resource get new blobs too.\n for (const [other, e] of this.entries) {\n if (e.deps.has(name)) {\n if (e.url) URL.revokeObjectURL(e.url);\n e.url = null;\n names.add(other);\n }\n }\n this.onChange(names);\n // Revoked after surfaces moved to the new URL.\n if (old?.url) URL.revokeObjectURL(old.url);\n }\n}\n", "// Touch, for a terminal with surfaces in it (SPEC \u00A79): a drag scrolls, as a\n// wheel does, and keeps going after the finger lifts; a tap and a long press\n// stay where they land. A Touch listens on one document or element and turns\n// its drags into wheel events at the finger, for the terminal. On the cells it\n// also turns a tap into a click.\n\n/** How far a touch moves, in CSS pixels, before it is a drag, not a tap. */\nconst DRAG_SLOP = 8;\n/** A fling's speed is multiplied by this every millisecond. */\nconst FLING_DECAY = 0.996;\n/** A finger that rested this long before lifting does not fling. */\nconst REST_MS = 80;\n\nexport interface TouchHost {\n /** Scroll by dx, dy pixels, at a point in the page (a wheel event for the\n * terminal). */\n scroll(dx: number, dy: number, pageX: number, pageY: number): void;\n /** A tap at a point in the page, for a Touch that owns taps too. */\n tap?(pageX: number, pageY: number): void;\n /** The listened-to document's point in the page (an iframe's offset). */\n toPage(x: number, y: number): [number, number];\n /** Whether a drag that has just begun, scrolling by dx, dy pixels so far,\n * is this Touch's. One it declines is the browser's to its end. Absent:\n * every drag is. */\n claim?(dx: number, dy: number, e: TouchEvent): boolean;\n}\n\nexport class Touch {\n private touch: { id: number; x0: number; y0: number; x: number; y: number; t: number; t0: number; vx: number; vy: number; dragging: boolean } | null = null;\n private fling = 0;\n private readonly off: (() => void)[] = [];\n\n /**\n * `exclusive`: every touch here is this Touch's (the cells: xterm.js's own\n * touch handling, which listens on the document, never sees it). Otherwise\n * (a surface) a touch is left alone until it moves. `engage`, if given,\n * says on a touch's start whether it is this Touch's at all: one it\n * declines is the browser's, from start to end.\n */\n constructor(\n target: EventTarget,\n private readonly win: Window,\n private readonly host: TouchHost,\n private readonly exclusive = false,\n private readonly engage?: (e: TouchEvent) => boolean,\n ) {\n const on = (type: string, f: (e: TouchEvent) => void, passive: boolean) => {\n const l = (e: Event) => f(e as TouchEvent);\n target.addEventListener(type, l, { capture: true, passive });\n this.off.push(() => target.removeEventListener(type, l, { capture: true }));\n };\n on(\"touchstart\", (e) => this.start(e), true);\n on(\"touchmove\", (e) => this.move(e), false);\n on(\"touchend\", (e) => this.end(e), !exclusive);\n on(\"touchcancel\", (e) => {\n this.keep(e);\n this.touch = null;\n }, true);\n }\n\n dispose() {\n this.stopFling();\n for (const f of this.off) f();\n }\n\n private keep(e: TouchEvent) {\n if (this.exclusive) e.stopPropagation();\n }\n\n private start(e: TouchEvent) {\n this.keep(e);\n this.stopFling();\n const t = e.touches.length === 1 ? e.touches[0] : undefined;\n if (!t || (this.engage && !this.engage(e))) {\n this.touch = null;\n return;\n }\n const [x, y] = this.host.toPage(t.clientX, t.clientY);\n this.touch = { id: t.identifier, x0: x, y0: y, x, y, t: e.timeStamp, t0: e.timeStamp, vx: 0, vy: 0, dragging: false };\n }\n\n private move(e: TouchEvent) {\n this.keep(e);\n const s = this.touch;\n if (!s) return;\n if (e.touches.length !== 1) {\n this.touch = null; // two fingers: the browser's (a pinch)\n return;\n }\n const t = [...e.changedTouches].find((c) => c.identifier === s.id);\n if (!t) return;\n // In the page, not in the listened-to document: a surface moves as the\n // terminal scrolls, and the finger, in its own coordinates, with it.\n // Measured there, each step of the scroll would read as the finger\n // moving back, and scroll again.\n const [x, y] = this.host.toPage(t.clientX, t.clientY);\n if (!s.dragging && Math.hypot(x - s.x0, y - s.y0) < DRAG_SLOP) return;\n if (!s.dragging && this.host.claim && !this.host.claim(s.x0 - x, s.y0 - y, e)) {\n this.touch = null;\n return;\n }\n s.dragging = true;\n e.preventDefault();\n const dx = x - s.x;\n const dy = y - s.y;\n const dt = Math.max(1, e.timeStamp - s.t);\n s.vx = 0.7 * (dx / dt) + 0.3 * s.vx;\n s.vy = 0.7 * (dy / dt) + 0.3 * s.vy;\n s.x = x;\n s.y = y;\n s.t = e.timeStamp;\n this.host.scroll(-dx, -dy, x, y);\n }\n\n private end(e: TouchEvent) {\n this.keep(e);\n const s = this.touch;\n if (!s || ![...e.changedTouches].some((c) => c.identifier === s.id)) return;\n this.touch = null;\n if (s.dragging) {\n if (e.timeStamp - s.t < REST_MS) this.startFling(-s.vx, -s.vy, s.x, s.y);\n return;\n }\n if (this.host.tap && e.timeStamp - s.t0 < 500) {\n // The tap is the click: not the browser's own mouse events as well.\n e.preventDefault();\n this.host.tap(s.x, s.y);\n }\n }\n\n private startFling(vx: number, vy: number, x: number, y: number) {\n let last = this.win.performance.now();\n const step = (now: number) => {\n const dt = now - last;\n last = now;\n const decay = Math.pow(FLING_DECAY, dt);\n vx *= decay;\n vy *= decay;\n if (Math.abs(vx) < 0.02 && Math.abs(vy) < 0.02) {\n this.fling = 0;\n return;\n }\n this.host.scroll(vx * dt, vy * dt, x, y);\n this.fling = this.win.requestAnimationFrame(step);\n };\n this.fling = this.win.requestAnimationFrame(step);\n }\n\n private stopFling() {\n if (this.fling) this.win.cancelAnimationFrame(this.fling);\n this.fling = 0;\n }\n}\n", "// What may enter a surface's document, and what its URLs become.\n//\n// Everything the program sends is parsed inert (a <template>, or DOMParser\n// for whole documents), cleaned and resolved here, and only then adopted\n// (never cloned: the resolver remembers elements) into the live, sandboxed\n// document. The sandbox and the CSP already stop\n// scripts and requests; this is the first line, and it keeps the live DOM\n// free of things that could navigate, load or steal focus.\n\nimport { directiveFor } from \"./network.ts\";\nimport { INVALID, isUrlAttr, type Store, type UrlContext } from \"./resources.ts\";\n\n/** Elements that never enter a surface. */\nconst DROP = new Set([\"script\", \"iframe\", \"frame\", \"frameset\", \"object\", \"embed\", \"applet\", \"base\", \"meta\", \"portal\", \"fencedframe\"]);\n\n/** Attributes that never enter a surface (besides `on*` handlers). */\nconst DROP_ATTRS = new Set([\"srcdoc\", \"autofocus\", \"http-equiv\", \"ping\", \"nonce\", \"integrity\"]);\n\nexport class Resolver {\n /** The program's value of each attribute the resolver rewrote. */\n private orig = new WeakMap<Element, Map<string, string>>();\n /** The program's text of each `<style>` whose CSS names a resource. */\n private css = new WeakMap<Element, string>();\n /** Elements that name resources, and which. */\n private refs = new Map<Element, Set<string>>();\n /** Attributes the host set and the program did not write (a detached\n * surface's `disabled`, SPEC \u00A75.5): live, never reported. */\n private own = new WeakMap<Element, Set<string>>();\n private readonly store: Store;\n /** The document's base URL and effective network policy (set per a=doc). */\n ctx: UrlContext | undefined;\n\n constructor(store: Store) {\n this.store = store;\n }\n\n /** Cleans and resolves an inert subtree, in place. */\n adopt(root: Node): void {\n const walk = (node: Node) => {\n if (node.nodeType === 1) {\n const el = node as Element;\n if (!this.allowed(el)) {\n el.remove();\n return;\n }\n this.cleanAttributes(el);\n if (el.localName === \"style\") this.setCss(el, el.textContent ?? \"\");\n }\n for (const child of Array.from(node.childNodes)) walk(child);\n if (node.nodeType === 1 && (node as Element).localName === \"template\") {\n walk((node as HTMLTemplateElement).content);\n }\n };\n walk(root);\n }\n\n private allowed(el: Element): boolean {\n const name = el.localName;\n if (DROP.has(name)) return false;\n if (name === \"link\") {\n const rel = (el.getAttribute(\"rel\") ?? \"\").toLowerCase().split(/\\s+/);\n return rel.includes(\"stylesheet\");\n }\n return true;\n }\n\n private cleanAttributes(el: Element) {\n for (const a of Array.from(el.attributes)) {\n const n = a.name.toLowerCase();\n if (n.startsWith(\"on\") || DROP_ATTRS.has(n)) {\n el.removeAttribute(a.name);\n } else if (isUrlAttr(n) || n === \"style\") {\n this.set(el, a.name, a.value);\n }\n }\n }\n\n /** An attribute as the program wrote it. */\n get(el: Element, name: string): string | null {\n if (this.own.get(el)?.has(name)) return null;\n return this.orig.get(el)?.get(name) ?? el.getAttribute(name);\n }\n\n /** Every attribute as the program wrote it, in order. */\n attributes(el: Element): [string, string][] {\n const o = this.orig.get(el);\n const own = this.own.get(el);\n const out: [string, string][] = [];\n for (const a of Array.from(el.attributes)) if (!own?.has(a.name)) out.push([a.name, o?.get(a.name) ?? a.value]);\n return out;\n }\n\n /** Sets an attribute of the host's own, which the program does not see. */\n setOwn(el: Element, name: string, value: string): void {\n el.setAttribute(name, value);\n let own = this.own.get(el);\n if (!own) this.own.set(el, (own = new Set()));\n own.add(name);\n }\n\n /** Removes an attribute, if it is the host's own. */\n removeOwn(el: Element, name: string): void {\n if (!this.own.get(el)?.delete(name)) return;\n el.removeAttribute(name);\n }\n\n /** Sets an attribute to the program's value, resolving URLs and CSS. */\n set(el: Element, name: string, value: string): void {\n const n = name.toLowerCase();\n if (n.startsWith(\"on\") || DROP_ATTRS.has(n)) return;\n const names = new Set<string>();\n let live = value;\n if (n === \"style\") live = this.store.rewriteCss(value, names, this.ctx);\n else if (isUrlAttr(n)) {\n const d = directiveFor(el.localName, n, el.getAttribute(\"rel\") ?? \"\");\n live = n === \"srcset\" ? this.srcset(value, names) : this.store.resolveUrl(value, names, this.ctx, d);\n }\n // Links keep their href, resolved by the browser against the document's\n // base, so they show and copy as the links they are. They never navigate:\n // clicks are events (SPEC \u00A79), and the sandbox has no allow-popups.\n if ((el.localName === \"a\" || el.localName === \"area\") && n === \"href\") live = value;\n try {\n el.setAttribute(name, live);\n } catch {\n return; // an invalid attribute name from the parser's point of view\n }\n this.own.get(el)?.delete(n); // the program's now\n this.remember(el, name, value, live, names);\n }\n\n remove(el: Element, name: string): void {\n el.removeAttribute(name);\n this.orig.get(el)?.delete(name);\n this.own.get(el)?.delete(name.toLowerCase());\n }\n\n /** A `<style>`'s CSS as the program wrote it. */\n cssOf(el: Element): string {\n return this.css.get(el) ?? el.textContent ?? \"\";\n }\n\n setCss(el: Element, text: string): void {\n const names = new Set<string>();\n const live = this.store.rewriteCss(text, names, this.ctx);\n if (el.textContent !== live) el.textContent = live;\n // The program's text stands (SPEC \u00A77.1) whenever resolving changed it.\n if (live !== text) this.css.set(el, text);\n else this.css.delete(el);\n if (names.size > 0) this.track(el, names);\n }\n\n /** Re-resolves everything that names one of `names` (a resource changed);\n * whether anything did. */\n refresh(names: Set<string>): boolean {\n let any = false;\n for (const [el, uses] of Array.from(this.refs)) {\n if (!el.isConnected) {\n this.refs.delete(el);\n continue;\n }\n if (![...uses].some((u) => names.has(u))) continue;\n any = true;\n this.refs.delete(el);\n const o = this.orig.get(el);\n if (o) for (const [attr, value] of Array.from(o)) this.set(el, attr, value);\n const css = this.css.get(el);\n if (css !== undefined) this.setCss(el, css);\n }\n return any;\n }\n\n private srcset(value: string, names: Set<string>): string {\n return value\n .split(\",\")\n .map((part) => {\n const [url, ...rest] = part.trim().split(/\\s+/);\n return [this.store.resolveUrl(url ?? \"\", names, this.ctx, \"img-src\"), ...rest].join(\" \");\n })\n .join(\", \");\n }\n\n private remember(el: Element, name: string, value: string, live: string, names: Set<string>) {\n let o = this.orig.get(el);\n if (value !== live) {\n if (!o) this.orig.set(el, (o = new Map()));\n o.set(name, value);\n } else {\n o?.delete(name);\n }\n if (names.size > 0) this.track(el, names);\n }\n\n private track(el: Element, names: Set<string>) {\n const uses = this.refs.get(el) ?? new Set<string>();\n for (const n of names) uses.add(n);\n this.refs.set(el, uses);\n }\n}\n\nexport { INVALID };\n", "// A surface (PROTOCOL \u00A74): one document in one sandboxed iframe.\n//\n// The iframe is same-origin without scripts (`sandbox=\"allow-same-origin\n// allow-forms\"`), so the addon can change its document directly and nothing\n// inside it can run. Its CSP allows `data:` and `blob:` resources, inline\n// styles, and from the network only what the embedder granted (the host's\n// half of the network policy, SPEC \u00A77.2). `allow-forms` is there only so that\n// `submit` fires (a sandbox without it cancels submission before the event);\n// the submission itself is cancelled here and blocked by `form-action 'none'`.\n//\n// The iframe never moves in the DOM (moving an iframe reloads it): it sits\n// in the addon's layer, and placement only changes the position of its box.\n\nimport { Touch } from \"./touch.ts\";\nimport { CLIP, MEASURE, scrollCss, UNCLIPPED } from \"./hostcss.ts\";\nimport { Deltas } from \"./delta.ts\";\nimport { Resolver } from \"./resolver.ts\";\nimport { cspSources, intersect, parse, type Policy } from \"./network.ts\";\nimport { NO_BASE, type Store } from \"./resources.ts\";\n\n/** A surface's CSP: nothing from the network but what the host grants. The\n * `<base>` is the addon's own (a document's is read, then dropped), so any\n * http(s) base is allowed. */\nexport function csp(host: Policy): string {\n const with_ = (fixed: string, d: keyof Policy) => [fixed, cspSources(host, d)].filter(Boolean).join(\" \");\n return [\n \"default-src 'none'\",\n with_(\"img-src data: blob:\", \"img-src\"),\n with_(\"media-src data: blob:\", \"media-src\"),\n with_(\"font-src data: blob:\", \"font-src\"),\n with_(\"style-src 'unsafe-inline' blob:\", \"style-src\"),\n \"form-action 'none'\",\n \"base-uri http: https:\",\n ].join(\"; \");\n}\n\n/** A document's base URL (SPEC \u00A77.3): its first <base href>, if absolute http(s). */\nfunction baseOf(doc: Document): string {\n const href = doc.querySelector(\"base[href]\")?.getAttribute(\"href\") ?? \"\";\n try {\n const u = new URL(href);\n if (u.protocol === \"http:\" || u.protocol === \"https:\") return u.href;\n } catch {\n /* not absolute */\n }\n return NO_BASE;\n}\n\n/** What a surface needs from the addon. */\n/** A window of a surface, in cells from its top-left corner (SPEC \u00A75.2). */\nexport interface Window {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\nexport interface SurfaceHost {\n layer: HTMLElement;\n store: Store;\n /** Sends a HOTTY message (an event) to the program. */\n event(surface: string, kind: string, target: string, detail?: unknown): void;\n /** A key the surface does not use (a keydown or its keyup), for the\n * terminal to send to the program as if typed there (SPEC \u00A710.2). */\n key(e: KeyboardEvent): void;\n /** A key the browser keeps (the `browserKeys` option): the surface\n * leaves it to the browser rather than hand it to the terminal. */\n browserKey(e: KeyboardEvent): boolean;\n /** Gives the keyboard back to the terminal. */\n focusTerminal(): void;\n /** The host's half of the network policy (SPEC \u00A77.2). */\n policy: Policy;\n /** The page scrolls, not the terminal (the `scroll` option): wheels and\n * touch drags over the surface are left to the browser. */\n pageScrolls: boolean;\n /** The wheel gesture a wheel over a document that scrolls belongs to:\n * where it began decides where the rest of it goes (`decide`, called for\n * a gesture's first wheel), as a browser latches scrolling to what it\n * began on. A gesture begun over the cells stays the terminal's. */\n wheelGesture(surface: string, decide: () => Route): Route;\n /** Scrolls the page by dx, dy pixels, where the page scrolls: for a\n * gesture the browser would give an element of the document instead. */\n scrollPage(dx: number, dy: number): void;\n /** A hyperlink (SPEC \u00A79: a link with target=\"_blank\") was hovered, left\n * or clicked: the terminal's, as an OSC 8 hyperlink is. `box` is the\n * link's box in the page. */\n hyperlink(kind: \"activate\" | \"hover\" | \"leave\", e: MouseEvent, url: string, box: DOMRect): void;\n /** A wheel event over the surface, or a touch drag made one: the\n * terminal's (SPEC \u00A79), at a point in the page. */\n wheel(e: WheelEvent, pageX: number, pageY: number): void;\n /** A press with Alt held, a move of the gesture it began, or its release\n * (SPEC \u00A79.2): the program's, as on the cells beneath, at a point in the\n * page. */\n cells(kind: \"down\" | \"move\" | \"up\", e: MouseEvent, pageX: number, pageY: number): void;\n}\n\ntype Control = \"none\" | \"text\" | \"textarea\" | \"select\" | \"activatable\";\n\n/** A drag under way (SPEC \u00A79.1): the pointer it holds, the element that\n * started it, and the target, cell and keys the program heard of last. */\ninterface Drag {\n pointer: number;\n start: string;\n target: string;\n c: number;\n r: number;\n keys: string[];\n}\n\n/** The theme's colour scheme, as the host stylesheet declares it. */\nexport type Scheme = \"dark\" | \"light\";\n\n/** Where a gesture or a key that scrolls goes in a document that scrolls\n * (SPEC \u00A75.3): the document (an element of it that can still move that\n * way), the terminal, or nowhere (`overscroll-behavior` stopped it). */\nexport type Route = \"doc\" | \"terminal\" | \"stop\";\n\n/** An element's cells, as the user sees it (SPEC \u00A79: `area`). */\nexport interface Area {\n c: number;\n r: number;\n w: number;\n h: number;\n}\n\n/** A scroll by a key (SPEC \u00A75.3: the keys a browser scrolls with), along\n * `axis`, `sign` its way: by a line, a page, or to the end. */\ninterface KeyScroll {\n axis: Axis;\n sign: 1 | -1;\n by: \"line\" | \"page\" | \"end\";\n}\n\ntype Axis = \"x\" | \"y\";\n\n/** A line of a key's scroll, in CSS pixels, as Chromium has it. */\nconst LINE_PX = 40;\n/** The part of the box a page of a key's scroll moves, as Chromium has it. */\nconst PAGE_FRACTION = 0.875;\n\nconst TEXT_TYPES = new Set([\"text\", \"email\", \"password\", \"search\", \"tel\", \"url\", \"number\", \"date\", \"datetime-local\", \"month\", \"time\", \"week\"]);\n\n/** The form controls a detached surface disables (SPEC \u00A75.5). */\nconst CONTROLS = \"input, select, textarea, button\";\n\n/** The host's own attribute on a detached surface's hyperlinks, for its\n * stylesheet: whether a link is one depends on its `url` (SPEC \u00A79). Under\n * the addon's vendor prefix: `data-hotty-*` is the spec's (\u00A715). */\nconst HYPERLINK = \"data-xterm-hotty-hyperlink\";\n\n/**\n * A detached surface shows no pointer that promises a click (SPEC \u00A75.5),\n * whatever the document's `cursor` asks for, except over a hyperlink, which\n * is the terminal's and still opens. Over another link the pointer is the\n * one over text: `auto` would be the hand there. Important in the host's\n * layer, the first, so that it wins over the program's own rules.\n */\nconst DETACHED_CSS = `@layer hotty-host {\n* { cursor: auto !important; }\na[href], a[href] * { cursor: text !important; }\na[href][${HYPERLINK}], a[href][${HYPERLINK}] * { cursor: pointer !important; }\n}`;\n\nexport class Surface {\n readonly name: string;\n readonly box: HTMLDivElement;\n readonly frame: HTMLIFrameElement;\n readonly doc: Document;\n readonly resolver: Resolver;\n readonly deltas: Deltas;\n cols = 80;\n rows = 24;\n /** The part of the surface on screen, in cells (SPEC \u00A75.2). */\n win: Window = { x: 0, y: 0, w: 80, h: 24 };\n autoRows = false;\n private readonly host: SurfaceHost;\n private readonly hostStyle: HTMLStyleElement;\n /** Set while the program moves focus, so no `focus` event echoes back. */\n private programFocus = false;\n /** The document's base URL (SPEC \u00A77.3). */\n private base = NO_BASE;\n private keyboard = false;\n /** Detached (SPEC \u00A75.5): nothing in the surface reaches the program. */\n private detachedState = false;\n /** A press is on something that takes no focus (SPEC \u00A710.1): the focus\n * the browser gives the frame for it is not the surface's. */\n private pressNothing = false;\n /** The element a press focuses, until the browser is done with it. */\n private pressed: HTMLElement | null = null;\n /** A press of another button than the primary one, until the browser is\n * done with it: it neither takes nor gives back the keyboard. */\n private auxPress = false;\n private settling: ReturnType<typeof setTimeout> | null = null;\n /** A drag under way (SPEC \u00A79.1). */\n private drag: Drag | null = null;\n /** A drag just ended at a release: it reported its own click, so the\n * browser's, which follows in the same task, is not reported. */\n private dragReleased = false;\n /** The placement asked for presses (`p=1`, SPEC \u00A75.2). */\n presses = false;\n /** A mouse's or a pen's pointerdown came first: the mousedown that\n * follows is the same press, not a tap's. */\n private pointerPress = false;\n /** The pointer of a press with Alt held (SPEC \u00A79.2), until its release:\n * the gesture is the program's. */\n private altPointer: number | null = null;\n /** Such a gesture just ended at a release: the browser's click that\n * follows in the same task is not the surface's. */\n private altReleased = false;\n /** One cell, in CSS pixels: a drag's detail counts cells (SPEC \u00A79.1). */\n private cellW = 9;\n private cellH = 17;\n private css = \"\";\n /** Keys whose keydown went to the program, so their keyup follows. */\n private forwarded = new Set<string>();\n /** The rows the program heard last, while the placement asked for `fit`\n * (`f=1`, SPEC \u00A75.2); null when it did not. */\n private fitRows: number | null = null;\n /** The height may have changed since the last check. */\n private fitDirty = false;\n /** The frame a check waits for. */\n private fitFrame = 0;\n private fitObserver: ResizeObserver | null = null;\n /** The axes the document asked to scroll along (`scroll`, SPEC \u00A75.1): 1\n * vertically, 2 horizontally, 3 both; 0, nothing scrolls. */\n private axes = 0;\n /** Where the touch drag under way goes, once it has a direction. */\n private touchRoute: Route = \"terminal\";\n /** The box the wheel gesture under way scrolls, if it went to the\n * document: the gesture moves no other (`scrollWheel`). */\n private wheelBox: Element | null = null;\n /** Some element may carry `CLIP`. */\n private clipping = false;\n\n constructor(name: string, host: SurfaceHost, hostCss: string, scheme: Scheme) {\n this.name = name;\n this.host = host;\n this.box = document.createElement(\"div\");\n this.box.className = \"hotty-surface\";\n this.box.dataset.surface = name;\n Object.assign(this.box.style, {\n position: \"absolute\",\n left: \"0px\",\n top: \"0px\",\n overflow: \"hidden\",\n pointerEvents: \"auto\",\n visibility: \"hidden\",\n });\n this.frame = document.createElement(\"iframe\");\n this.frame.setAttribute(\"sandbox\", \"allow-same-origin allow-forms\");\n this.frame.setAttribute(\"title\", `HOTTY surface ${name}`);\n // The document is the whole surface; the box shows its window (SPEC \u00A75.2).\n // The frame's colour scheme is the document's (the host stylesheet's,\n // from the theme): were they to differ, the browser would paint the\n // frame an opaque canvas, and a document with a transparent background\n // could not show the cells beneath it.\n Object.assign(this.frame.style, {\n border: \"0\",\n position: \"absolute\",\n left: \"0px\",\n top: \"0px\",\n width: \"100%\",\n height: \"100%\",\n display: \"block\",\n colorScheme: scheme,\n });\n this.box.append(this.frame);\n host.layer.append(this.box);\n\n // The initial about:blank document exists as soon as the iframe is\n // connected; writing it through the parser makes the CSP <meta> a\n // parser-inserted policy, in force before any program markup arrives.\n const doc = this.frame.contentDocument;\n if (!doc) throw new Error(\"surface iframe has no document\");\n doc.open();\n doc.write(\n `<!doctype html><html><head><meta charset=\"utf-8\">` +\n `<meta http-equiv=\"Content-Security-Policy\" content=\"${csp(host.policy)}\">` +\n `<base href=\"${NO_BASE}\"><style id=\"hotty-host\"></style></head><body></body></html>`,\n );\n doc.close();\n this.doc = doc;\n this.hostStyle = doc.getElementById(\"hotty-host\") as HTMLStyleElement;\n this.css = hostCss;\n this.restyle();\n this.resolver = new Resolver(host.store);\n this.deltas = new Deltas(doc, this.resolver);\n this.listen();\n }\n\n setHostCss(css: string, scheme: Scheme) {\n this.css = css;\n this.restyle();\n if (this.frame.style.colorScheme !== scheme) this.frame.style.colorScheme = scheme;\n this.refit(); // the cell size or the font\n }\n\n private restyle() {\n const css = [this.css, scrollCss(this.axes, this.host.pageScrolls), ...(this.detachedState ? [DETACHED_CSS] : [])].join(\"\\n\");\n if (this.hostStyle.textContent !== css) this.hostStyle.textContent = css;\n this.clip();\n }\n\n /** Replaces the whole document (`a=doc`): its head's styles and its body.\n * `detached` (`d=1`) detaches the surface first; without it, the surface\n * is the program's again (SPEC \u00A75.1, \u00A75.5). `axes` (`scroll`) are the\n * axes it scrolls along, 0 for none (\u00A75.3). */\n setDocument(html: string, detached = false, axes = 0) {\n if (detached) this.detach();\n const scrolled = this.axes !== 0;\n this.axes = axes;\n const parsed = new DOMParser().parseFromString(html, \"text/html\");\n // The document's base and its network request (SPEC \u00A77.2, \u00A77.3) are read\n // before the resolver drops its <base> and <meta> elements; deltas can\n // add neither, so both hold until the next a=doc.\n this.base = baseOf(parsed);\n const request = parse(parsed.querySelector('meta[name=\"hotty-network\" i]')?.getAttribute(\"content\") ?? \"\");\n this.resolver.ctx = { base: this.base, policy: intersect(this.host.policy, request) };\n const ours = this.doc.head.querySelector(\"base\");\n if (ours && ours.getAttribute(\"href\") !== this.base) ours.setAttribute(\"href\", this.base);\n this.resolver.adopt(parsed.documentElement);\n const head = this.doc.head;\n for (const n of Array.from(head.childNodes)) {\n const el = n as Element;\n const ours = el.nodeType === 1 && (el.id === \"hotty-host\" || el.localName === \"meta\" || el.localName === \"base\");\n if (!ours) n.remove();\n }\n head.append(...Array.from(parsed.head.childNodes));\n this.copyAttributes(parsed.documentElement, this.doc.documentElement);\n this.copyAttributes(parsed.body, this.doc.body);\n this.doc.body.replaceChildren(...Array.from(parsed.body.childNodes));\n this.detachedState = detached;\n this.sync();\n // A new document starts at the top left (SPEC \u00A75.3). The root and the\n // body stay from one document to the next, and so would their offsets;\n // the previous document's are zero unless it scrolled.\n if (scrolled) {\n this.doc.documentElement.scrollTo(0, 0);\n this.doc.body.scrollTo(0, 0);\n }\n this.refit();\n }\n\n /** A delta (SPEC \u00A76). On a detached surface, the controls it adds are\n * disabled too, and so is one whose `disabled` it removes. */\n delta(op: string, target: string | undefined, key: string | undefined, payload: string) {\n try {\n this.deltas.apply(op, target, key, payload);\n } finally {\n if (this.detachedState) this.sync();\n else this.clip();\n this.refit();\n }\n }\n\n // --- Ownership (SPEC \u00A75.5) -----------------------------------------------\n\n get detached(): boolean {\n return this.detachedState;\n }\n\n /** `a=detach`: nothing in the surface reaches the program any more. A\n * surface that has the keyboard gives it back silently, with no `change`\n * and no `blur`, and its form controls act disabled. */\n detach() {\n if (!this.detachedState) {\n this.detachedState = true; // from here on, emit() sends nothing\n this.dropDrag(); // it ends with nothing more reported (SPEC \u00A79.1)\n const had = this.keyboard || this.frameFocused();\n this.keyboard = false;\n this.focusedControl()?.blur();\n if (had) this.giveBack();\n }\n this.sync();\n }\n\n /** Disables the form controls of a detached surface, as if each had the\n * `disabled` attribute, or enables those it disabled, and marks its\n * hyperlinks for the host's stylesheet. The attributes are the host's\n * own: the document reports the program's (SPEC \u00A716). */\n private sync() {\n const detached = this.detachedState;\n for (const el of Array.from(this.doc.querySelectorAll(CONTROLS))) {\n if (!detached) this.resolver.removeOwn(el, \"disabled\");\n else if (!el.hasAttribute(\"disabled\")) this.resolver.setOwn(el, \"disabled\", \"\");\n }\n for (const a of Array.from(this.doc.querySelectorAll(\"a\"))) {\n if (detached && this.isHyperlink(a)) {\n if (!a.hasAttribute(HYPERLINK)) this.resolver.setOwn(a, HYPERLINK, \"\");\n } else this.resolver.removeOwn(a, HYPERLINK);\n }\n this.restyle();\n }\n\n private copyAttributes(from: Element, to: Element) {\n for (const [name] of this.resolver.attributes(to)) {\n if (!from.hasAttribute(name)) this.resolver.remove(to, name);\n }\n for (const [name, value] of this.resolver.attributes(from)) this.resolver.set(to, name, value);\n }\n\n /** Rows the content needs at `cols` columns (`r=auto`). */\n contentRows(cols: number, cellW: number, cellH: number): number {\n // Laid out, unseen, whatever the surface was showing.\n Object.assign(this.box.style, { display: \"block\", visibility: \"hidden\" });\n return this.neededRows(cols, cellW, cellH);\n }\n\n /**\n * Rows the document needs at `cols` columns: `r=auto`'s, and `fit`'s\n * (SPEC \u00A75.2). The frame is laid out at the width a placement gives it\n * and a height of 1px, so the viewport adds nothing, then restored in the\n * same task: nothing is drawn in between.\n */\n private neededRows(cols: number, cellW: number, cellH: number): number {\n const f = this.frame.style;\n const [width, height] = [f.width, f.height];\n // A document that scrolls would show its root's scrollbar at 1px, and\n // lay its content out narrower: the root is measured clipped.\n const root = this.doc.documentElement;\n if (this.axes) this.resolver.setOwn(root, MEASURE, \"\");\n Object.assign(f, { width: `${Math.round(cols * cellW)}px`, height: \"1px\" });\n const h = root.scrollHeight;\n Object.assign(f, { width, height });\n if (this.axes) this.resolver.removeOwn(root, MEASURE);\n return Math.max(1, Math.min(1000, Math.ceil(h / cellH)));\n }\n\n /**\n * In a document that scrolls along one axis only, the elements whose\n * `overflow` along the other is `auto` or `scroll` are marked (`CLIP`), so\n * that the host stylesheet clips that axis as `overflow: hidden` does\n * (SPEC \u00A75.3): no scrollbar, and nothing the user does scrolls it. CSS\n * cannot select by a computed value, so the addon reads it, with its own\n * rule off (`UNCLIPPED`), each time the document or its style may have\n * changed: a document, a delta, the host stylesheet. Style only, no\n * layout, and only for a document with `scroll` of 1 or 2.\n */\n private clip() {\n const prop = this.axes === 1 ? \"overflowX\" : this.axes === 2 ? \"overflowY\" : null;\n if (!prop && !this.clipping) return;\n const marked = new Set(this.doc.querySelectorAll(`[${CLIP}]`));\n const want = new Set<Element>();\n if (prop) {\n const root = this.doc.documentElement;\n const win = this.frame.contentWindow!;\n this.resolver.setOwn(root, UNCLIPPED, \"\");\n for (const el of [this.doc.body, ...Array.from(this.doc.body.querySelectorAll(\"*\"))]) {\n if (/auto|scroll/.test(win.getComputedStyle(el)[prop])) want.add(el);\n }\n this.resolver.removeOwn(root, UNCLIPPED);\n }\n for (const el of marked) if (!want.has(el)) this.resolver.removeOwn(el, CLIP);\n for (const el of want) if (!marked.has(el)) this.resolver.setOwn(el, CLIP, \"\");\n this.clipping = want.size > 0;\n }\n\n // --- Fit (SPEC \u00A75.2: f=1 on a=place) --------------------------------------\n\n /**\n * `f=1` on the placement: from `rows`, the placement's own, the program\n * hears `fit` whenever the rows the document needs differ from those it\n * heard last. `null`: the placement did not ask (or is gone).\n *\n * What can change the height asks for a check in the next frame drawn:\n * a document, a delta, a resource (`refresh`), the host stylesheet (cell\n * size, font), an image, stylesheet or font loading, and, for whatever\n * else does (the user opening a `<details>`, say), the root's and the\n * body's boxes changing size. One check per frame, so one `fit` at most.\n */\n setFit(rows: number | null) {\n this.fitRows = rows;\n if (rows === null) {\n this.fitObserver?.disconnect();\n this.fitObserver = null;\n if (this.fitFrame) this.frame.ownerDocument.defaultView?.cancelAnimationFrame(this.fitFrame);\n this.fitFrame = 0;\n this.fitDirty = false;\n return;\n }\n if (!this.fitObserver) {\n this.fitObserver = new ResizeObserver(() => this.refit());\n this.fitObserver.observe(this.doc.documentElement);\n this.fitObserver.observe(this.doc.body);\n }\n this.refit();\n }\n\n /** The document's height may have changed: a check in the next frame\n * drawn. A surface out of view draws none; it checks once shown. */\n private refit() {\n if (this.fitRows === null) return;\n this.fitDirty = true;\n if (this.fitFrame || this.box.style.display === \"none\") return;\n this.fitFrame = this.frame.ownerDocument.defaultView!.requestAnimationFrame(() => {\n this.fitFrame = 0;\n this.checkFit();\n });\n }\n\n private checkFit() {\n if (this.fitRows === null || !this.fitDirty || this.box.style.display === \"none\") return;\n this.fitDirty = false;\n if (this.detachedState) return; // it sends no events (\u00A75.5)\n const rows = this.neededRows(this.cols, this.cellW, this.cellH);\n if (rows === this.fitRows) return;\n this.fitRows = rows;\n this.emit(\"fit\", \"\", { r: rows });\n }\n\n /** A resource changed (`a=res`, `a=del`): what names it resolves again. */\n refresh(names: Set<string>) {\n if (this.resolver.refresh(names)) this.refit();\n }\n\n /** The surface is `cols`\u00D7`rows` cells, and the box shows `win` of it:\n * the document keeps the whole size, offset by the window's corner. */\n setSize(cols: number, rows: number, cellW: number, cellH: number, win: Window = { x: 0, y: 0, w: cols, h: rows }) {\n this.cols = cols;\n this.rows = rows;\n this.win = win;\n this.cellW = cellW;\n this.cellH = cellH;\n Object.assign(this.frame.style, {\n left: `${-Math.round(win.x * cellW)}px`,\n top: `${-win.y * cellH}px`,\n width: `${Math.round(cols * cellW)}px`,\n height: `${rows * cellH}px`,\n });\n this.box.style.width = `${Math.round(win.w * cellW)}px`;\n this.box.style.height = `${win.h * cellH}px`;\n }\n\n /** The placement's z (SPEC \u00A75.2): CSS z-index on the box, so overlapping\n * boxes stack by it, and by their order in the layer at the same z. */\n setZ(z: number) {\n this.box.style.zIndex = String(z);\n }\n\n /** Shows the surface with its top-left corner at (x, y) in the screen's pixels. */\n show(x: number, y: number) {\n this.box.style.left = `${x}px`;\n this.box.style.top = `${y}px`;\n this.box.style.visibility = \"visible\";\n this.box.style.display = \"block\";\n if (this.fitDirty) this.refit(); // what changed while out of view\n }\n\n /** Out of view (its line left the screen): a drag under way ends\n * (SPEC \u00A79.1). */\n hide() {\n this.cancelDrag();\n this.dropAlt();\n this.box.style.display = \"none\";\n }\n\n /** No placement (hidden, or not placed yet): the document stays, and the\n * browser skips its style, layout and paint until it is placed again. */\n park() {\n this.box.style.display = \"none\";\n }\n\n destroy() {\n this.setFit(null);\n this.dropDrag();\n this.dropAlt();\n if (this.settling) clearTimeout(this.settling);\n if (this.keyboard || this.frameFocused()) this.host.focusTerminal();\n this.box.remove();\n }\n\n // --- Keyboard (PROTOCOL \u00A78, Q-0005) -------------------------------------\n\n hasKeyboard(): boolean {\n return this.keyboard;\n }\n\n /** `a=focus`: the surface takes the keyboard, at `target` if given. */\n focus(target?: string) {\n const el = target ? this.doc.getElementById(target) : null;\n if (target && !el) throw new Error(target);\n this.programFocus = true;\n try {\n this.frame.focus();\n this.frame.contentWindow?.focus();\n if (el) (el as HTMLElement).focus();\n else if (!this.focusedControl()) this.tabbable()[0]?.focus();\n this.keyboard = true;\n } finally {\n setTimeout(() => (this.programFocus = false), 0);\n }\n }\n\n /** `a=blur`, or the keyboard leaving: the edited control commits first. */\n blur() {\n this.commit();\n if (this.keyboard) this.giveBack();\n }\n\n /** The browser's focus goes from the frame to the terminal. The frame lets\n * go of it first: Firefox can leave the frame focused otherwise. */\n private giveBack() {\n this.frame.blur();\n this.host.focusTerminal();\n }\n\n private commit() {\n const active = this.focusedControl();\n if (active) active.blur(); // fires `change` if the value changed\n }\n\n private focusedControl(): HTMLElement | null {\n const a = this.doc.activeElement;\n return a && a !== this.doc.body && a !== this.doc.documentElement ? (a as HTMLElement) : null;\n }\n\n /** Whether the browser's focus is in this surface's frame. */\n private frameFocused(): boolean {\n return this.frame.ownerDocument.activeElement === this.frame;\n }\n\n /**\n * A press (SPEC \u00A710.1). On an element that takes focus, the focus that\n * follows gives the surface the keyboard (`onFocusIn`). On anything else,\n * or anywhere in a detached surface, it takes nothing: a surface that had\n * the keyboard gives it back (its control commits, then `blur`), and the\n * focus the browser gives the frame anyway goes back to the terminal.\n */\n private onPress(e: MouseEvent) {\n // A touch is a click only once it lifts, as a tap: its mousedown.\n if (e.type === \"pointerdown\" && (e as PointerEvent).pointerType === \"touch\") return;\n // Only a click (the primary button) moves the keyboard. Focus stays where\n // the browser puts it for the others: a context menu's Copy copies the\n // selection of the frame that has it.\n if (e.button !== 0) {\n this.auxPress = true;\n setTimeout(() => (this.auxPress = false), 0);\n return;\n }\n const el = this.detachedState ? null : focusTargetAt(e, this.hyper);\n if (el) {\n this.pressed = el;\n this.settle();\n return;\n }\n this.pressNothing = true;\n if (this.keyboard) {\n this.commit();\n this.keyboard = false;\n this.emit(\"blur\", \"\");\n }\n this.settle();\n }\n\n /**\n * Once the browser is done with a press (its default action focuses the\n * frame): an element that takes focus has it, even where the browser does\n * not focus one on a click (a button on a Mac, say); and focus the\n * surface does not hold goes back to the terminal. The frame keeps it\n * until then, so text selection starts as usual.\n */\n private settle() {\n if (this.settling) return;\n this.settling = setTimeout(() => {\n this.settling = null;\n const el = this.pressed;\n this.pressed = null;\n this.pressNothing = false;\n if (el && !this.keyboard && !this.detachedState && el.isConnected && this.doc.activeElement !== el) {\n this.frame.focus();\n el.focus({ preventScroll: true });\n }\n if (!this.keyboard && this.frameFocused()) this.giveBack();\n }, 0);\n }\n\n /** An element got focus: the surface takes the keyboard if the element is\n * one that takes focus, and the focus is neither the program's (no echo)\n * nor a detached surface's. */\n private onFocusIn(e: FocusEvent) {\n if (this.programFocus || this.auxPress) return;\n if (this.detachedState || this.pressNothing || !isElement(e.target as EventTarget) || !takesFocus(e.target as Element, this.hyper)) {\n this.settle();\n return;\n }\n if (this.keyboard) return;\n this.keyboard = true;\n this.emit(\"focus\", \"\");\n }\n\n private tabbable(): HTMLElement[] {\n const all = this.doc.querySelectorAll<HTMLElement>(\n \"a[href], button, input:not([type=hidden]), select, textarea, summary, [tabindex], [contenteditable=''], [contenteditable=true]\",\n );\n return Array.from(all).filter((el) => el.tabIndex >= 0 && !(el as HTMLButtonElement).disabled && el.getClientRects().length > 0);\n }\n\n private controlKind(el: Element | null): Control {\n if (!el) return \"none\";\n const tag = el.localName;\n if (tag === \"textarea\" || (el as HTMLElement).isContentEditable) return \"textarea\";\n if (tag === \"select\") return \"select\";\n if (tag === \"input\") {\n const type = ((el as HTMLInputElement).type || \"text\").toLowerCase();\n if (TEXT_TYPES.has(type)) return \"text\";\n return \"activatable\";\n }\n if (tag === \"button\" || tag === \"a\" || tag === \"summary\") return \"activatable\";\n return \"none\";\n }\n\n /** Whether the focused element uses the key; if not, the program gets it. */\n private consumes(e: KeyboardEvent, kind: Control): boolean {\n const plain = !e.ctrlKey && !e.altKey && !e.metaKey;\n const k = e.key;\n const printable = [...k].length === 1;\n if (k === \"Escape\") return false;\n switch (kind) {\n case \"text\":\n return (plain || (e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey)) &&\n (printable || [\"Backspace\", \"Delete\", \"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\", \"Enter\"].includes(k));\n case \"textarea\":\n return (plain || (e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey)) &&\n (printable || [\"Backspace\", \"Delete\", \"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\", \"Home\", \"End\", \"PageUp\", \"PageDown\", \"Enter\"].includes(k));\n case \"select\":\n return plain && (printable || [\"ArrowUp\", \"ArrowDown\", \"Home\", \"End\", \"PageUp\", \"PageDown\", \"Enter\", \" \"].includes(k));\n case \"activatable\":\n return plain && (k === \" \" || k === \"Enter\");\n default:\n return false;\n }\n }\n\n private onKey(e: KeyboardEvent) {\n if (e.isComposing || e.defaultPrevented) return;\n if (!this.keyboard) {\n // The frame has the browser's focus without the keyboard, for a moment\n // (a press that took nothing): every key is the terminal's.\n this.settle();\n if (this.host.browserKey(e)) return;\n this.forward(e);\n return;\n }\n if (e.key === \"Tab\" && !e.ctrlKey && !e.altKey && !e.metaKey) {\n // Tab moves between controls; past the last one it leaves the surface.\n const order = this.tabbable();\n const at = order.indexOf(this.doc.activeElement as HTMLElement);\n const leaving = order.length === 0 || (e.shiftKey ? at <= 0 : at === order.length - 1 || at < 0);\n if (leaving) {\n e.preventDefault();\n this.blur();\n }\n return;\n }\n if (this.consumes(e, this.controlKind(this.doc.activeElement))) return;\n if (this.host.browserKey(e)) return; // the browser's: reload, zoom, \u2026\n if (this.axes && this.scrollKey(e)) return;\n this.forward(e);\n }\n\n /**\n * A key a browser scrolls with, in a document that scrolls (SPEC \u00A75.3):\n * it scrolls the innermost box, from the focused element outward (from\n * the root when none is), that can still move that way. Where none can,\n * the key goes on to the program, as every key the surface does not use\n * does (\u00A710.2), unless `overscroll-behavior` stops it. The addon scrolls\n * the box itself: the browser's own action could be the focused\n * element's instead (a radio button's arrows, a number field's).\n */\n private scrollKey(e: KeyboardEvent): boolean {\n const k = keyScroll(e);\n if (!k) return false;\n const to = this.scroller(this.focusedControl(), k.axis, k.sign);\n if (to === \"terminal\") return false;\n e.preventDefault();\n if (to === \"stop\") return true;\n const y = k.axis === \"y\";\n const by = k.by === \"line\" ? LINE_PX : k.by === \"page\" ? Math.max(1, (y ? to.clientHeight : to.clientWidth) * PAGE_FRACTION) : y ? to.scrollHeight : to.scrollWidth;\n to.scrollBy(y ? { top: k.sign * by } : { left: k.sign * by });\n return true;\n }\n\n private forward(e: KeyboardEvent) {\n e.preventDefault();\n e.stopPropagation();\n this.forwarded.add(e.code);\n this.host.key(e);\n }\n\n /** The release of a key the program had: the program hears it too, if it\n * asked the terminal for releases (SPEC \u00A710.3). */\n private onKeyUp(e: KeyboardEvent) {\n if (!this.forwarded.delete(e.code)) return;\n e.preventDefault();\n e.stopPropagation();\n this.host.key(e);\n }\n\n // --- Drags (SPEC \u00A79.1) ----------------------------------------------------\n\n /**\n * A press of a mouse's or a pen's primary button on an element with\n * `drag` in its `data-on` (the nearest, from the pressed one outward, and\n * only if it has an id) starts a drag. The surface then holds the pointer\n * until the release: captured by its root element, which no delta\n * replaces, so every move comes here wherever it is (over the cells,\n * another surface, or outside the page), and nothing else hears it.\n */\n private onDragDown(e: PointerEvent) {\n // A press while a drag is under way: its release was lost.\n this.cancelDrag();\n if (this.detachedState || e.pointerType === \"touch\" || e.button !== 0 || !e.isPrimary) return;\n let start: Element | null = null;\n for (const n of e.composedPath()) {\n if (isElement(n) && listens(n, \"drag\")) {\n start = n;\n break;\n }\n }\n const id = start?.getAttribute(\"id\");\n if (!id) return;\n const [c, r] = this.cellOf(e);\n const keys = keysOf(e);\n this.drag = { pointer: e.pointerId, start: id, target: id, c, r, keys };\n this.emit(\"dragstart\", id, { c, r, keys });\n try {\n this.doc.documentElement.setPointerCapture(e.pointerId);\n } catch {\n /* the browser routes a pressed mouse to the frame anyway */\n }\n }\n\n /** A move during a drag: an event each time its target changes, and\n * while it has none, each time its cell does. */\n private onDragMove(e: PointerEvent) {\n const d = this.drag;\n if (!d || e.pointerId !== d.pointer) return;\n const [c, r] = this.cellOf(e);\n const target = this.dragTarget(this.elementAt(e, c, r));\n const keys = keysOf(e);\n if (target !== d.target || (target === \"\" && (c !== d.c || r !== d.r))) {\n this.emit(\"drag\", target, { c, r, keys });\n }\n Object.assign(d, { target, c, r, keys });\n }\n\n /** The release ends the drag, wherever it is. Where it began, it is the\n * click it would have been without the drag; anywhere else, no click. */\n private onDragUp(e: PointerEvent) {\n const d = this.drag;\n if (!d || e.pointerId !== d.pointer || e.button !== 0) return;\n this.drag = null;\n const [c, r] = this.cellOf(e);\n const at = this.elementAt(e, c, r);\n const target = this.dragTarget(at);\n this.emit(\"dragend\", target, { c, r, keys: keysOf(e) });\n // The browser's click goes where the capture was (the root), or to\n // where the press and the release meet: the drag reports its own.\n this.dragReleased = true;\n setTimeout(() => (this.dragReleased = false), 0);\n if (target === d.start && at) this.reportClick(ancestry(at));\n }\n\n /** The browser took the pointer away before the release. */\n private lostPointer(e: PointerEvent) {\n if (this.drag && e.pointerId === this.drag.pointer) this.cancelDrag();\n if (e.pointerId === this.altPointer) this.altPointer = null;\n }\n\n /**\n * Ends a drag under way without a release (SPEC \u00A79.1: its placement went\n * away, a new document came, or the pointer was lost): `dragend` with no\n * target, at the last cell the program heard of.\n */\n cancelDrag() {\n const d = this.drag;\n if (!d) return;\n this.dropDrag();\n this.emit(\"dragend\", \"\", { c: d.c, r: d.r, keys: d.keys });\n }\n\n /** Ends a drag under way, silently (a detached or deleted surface). */\n private dropDrag() {\n const d = this.drag;\n if (!d) return;\n this.drag = null;\n try {\n if (this.doc.documentElement.hasPointerCapture(d.pointer)) this.doc.documentElement.releasePointerCapture(d.pointer);\n } catch {\n /* already released */\n }\n }\n\n /** The surface's cell under the pointer, from its top left (the frame's\n * origin), counting on past its edges. */\n private cellOf(e: MouseEvent): [number, number] {\n return [Math.floor(e.clientX / this.cellW), Math.floor(e.clientY / this.cellH)];\n }\n\n /** The element under the pointer, if it is in the window (SPEC \u00A75.2). */\n private elementAt(e: MouseEvent, c: number, r: number): Element | null {\n const w = this.win;\n if (c < w.x || c >= w.x + w.w || r < w.y || r >= w.y + w.h) return null;\n return this.doc.elementFromPoint(e.clientX, e.clientY);\n }\n\n /** A drag's target: the nearest element with an id and `drag` in its\n * `data-on`, from `el` outward; \"\" where there is none. */\n private dragTarget(el: Element | null): string {\n for (let n = el; n; n = n.parentElement) {\n const id = n.getAttribute(\"id\");\n if (id && listens(n, \"drag\")) return id;\n }\n return \"\";\n }\n\n // --- Presses with Alt (SPEC \u00A79.2) ---------------------------------------\n\n /**\n * A press of a mouse's or a pen's primary button with Alt held is the\n * program's: the addon replays it on the cells beneath, and the surface\n * hears nothing of it (no press, drag, click, focus or selection; its\n * mousedown is cancelled). It holds the pointer until the release, as a\n * drag does, so every move and the release go to the cells, wherever the\n * pointer is. Whether it is the program's is decided here, at the press:\n * Alt let go later changes nothing.\n */\n private onAltDown(e: PointerEvent): boolean {\n if (e.pointerType === \"touch\" || e.button !== 0 || !e.altKey || !e.isPrimary) return false;\n this.cancelDrag(); // a drag whose release was lost\n this.dropAlt();\n this.pointerPress = true;\n this.altPointer = e.pointerId;\n // No longer hovered: a hyperlink under the pointer is left.\n this.onLeave(e);\n try {\n this.doc.documentElement.setPointerCapture(e.pointerId);\n } catch {\n /* the browser routes a pressed mouse to the frame anyway */\n }\n const [x, y] = this.toPage(e);\n this.host.cells(\"down\", e, x, y);\n return true;\n }\n\n private onAltMove(e: PointerEvent): boolean {\n if (e.pointerId !== this.altPointer) return false;\n const [x, y] = this.toPage(e);\n this.host.cells(\"move\", e, x, y);\n return true;\n }\n\n private onAltUp(e: PointerEvent): boolean {\n if (e.pointerId !== this.altPointer || e.button !== 0) return false;\n this.dropAlt();\n this.altReleased = true;\n setTimeout(() => (this.altReleased = false), 0);\n const [x, y] = this.toPage(e);\n this.host.cells(\"up\", e, x, y);\n return true;\n }\n\n /** Ends such a gesture without a release: the frame goes away. */\n private dropAlt() {\n const p = this.altPointer;\n if (p === null) return;\n this.altPointer = null;\n try {\n if (this.doc.documentElement.hasPointerCapture(p)) this.doc.documentElement.releasePointerCapture(p);\n } catch {\n /* already released */\n }\n }\n\n /** A point of the frame's document in the page. */\n private toPage(e: MouseEvent): [number, number] {\n const r = this.frame.getBoundingClientRect();\n return [r.left + e.clientX, r.top + e.clientY];\n }\n\n /** `press` (SPEC \u00A79), if the placement asked for it: `t` is the nearest\n * element with an id. A press on a hyperlink is the terminal's. */\n private reportPress(e: Event) {\n if (!this.presses) return;\n const link = this.linkIn(e);\n if (link && this.isHyperlink(link)) return;\n for (const n of e.composedPath()) {\n const id = isElement(n) ? n.getAttribute(\"id\") : null;\n if (id) {\n this.emit(\"press\", id, { area: this.areaOf(n as Element) });\n return;\n }\n }\n this.emit(\"press\", \"\");\n }\n\n /**\n * The cells an element's border box covers as the user sees it, scrolled\n * included (SPEC \u00A79: `area`), counted from the surface's top left cell:\n * whole, where it is clipped or scrolled away. An edge within half a\n * device pixel of a cell's is on it: layout rounds positions to fractions\n * of a pixel, and the user sees no less than a device pixel.\n */\n private areaOf(el: Element): Area {\n const b = el.getBoundingClientRect();\n const tol = 0.5 / (this.frame.ownerDocument.defaultView?.devicePixelRatio || 1);\n const c = Math.floor((b.left + tol) / this.cellW);\n const r = Math.floor((b.top + tol) / this.cellH);\n const right = Math.ceil((b.right - tol) / this.cellW);\n const bottom = Math.ceil((b.bottom - tol) / this.cellH);\n return { c, r, w: Math.max(0, right - c), h: Math.max(0, bottom - r) };\n }\n\n // --- Events for the program (PROTOCOL \u00A78) --------------------------------\n\n private listen() {\n const d = this.doc;\n const win = this.frame.contentWindow!;\n // A drag's start comes before what the press causes (SPEC \u00A79.1).\n d.addEventListener(\n \"pointerdown\",\n (e) => {\n if (this.onAltDown(e)) return;\n this.pointerPress = e.pointerType !== \"touch\";\n if (this.pointerPress && e.button === 0 && e.isPrimary) this.reportPress(e);\n this.onDragDown(e);\n this.onPress(e);\n },\n true,\n );\n d.addEventListener(\"pointermove\", (e) => this.onAltMove(e) || this.onDragMove(e), true);\n d.addEventListener(\"pointerup\", (e) => this.onAltUp(e) || this.onDragUp(e), true);\n d.addEventListener(\"pointercancel\", (e) => this.lostPointer(e), true);\n d.addEventListener(\"lostpointercapture\", (e) => this.lostPointer(e), true);\n d.addEventListener(\n \"mousedown\",\n (e) => {\n if (this.altPointer !== null) {\n // The program's press (SPEC \u00A79.2): no focus, no selection, no drag.\n e.preventDefault();\n e.stopImmediatePropagation();\n return;\n }\n // A press with no pointerdown before it is a tap's (SPEC \u00A79).\n if (!this.pointerPress && e.button === 0) this.reportPress(e);\n this.pointerPress = false;\n this.onPress(e);\n },\n true,\n );\n d.addEventListener(\"focusin\", (e) => this.onFocusIn(e), true);\n d.addEventListener(\"click\", (e) => this.onClick(e), true);\n d.addEventListener(\"auxclick\", (e) => this.onAuxClick(e), true);\n d.addEventListener(\"mouseover\", (e) => this.onOver(e), true);\n d.addEventListener(\"mouseout\", (e) => this.onOut(e), true);\n d.addEventListener(\"submit\", (e) => this.onSubmit(e as SubmitEvent), true);\n d.addEventListener(\"change\", (e) => this.onChange(e), true);\n d.addEventListener(\"input\", (e) => this.onInput(e), true);\n d.addEventListener(\"keydown\", (e) => this.onKey(e), true);\n d.addEventListener(\"keyup\", (e) => this.onKeyUp(e), true);\n d.addEventListener(\"dragstart\", (e) => e.preventDefault(), true);\n d.addEventListener(\"wheel\", (e) => this.onWheel(e), { capture: true, passive: false });\n d.addEventListener(\"scroll\", (e) => this.onScroll(e), true);\n // An image or a stylesheet that loads late, a resource's or one fetched\n // from the network (SPEC \u00A77.1, \u00A77.2), and a font: the height may change.\n d.addEventListener(\"load\", () => this.refit(), true);\n d.addEventListener(\"error\", () => this.refit(), true);\n d.fonts.addEventListener(\"loadingdone\", () => this.refit());\n // A touch drag is the terminal's, as a wheel is (SPEC \u00A79); taps and long\n // presses stay the surface's. Where the page scrolls, the browser\n // scrolls it from here, as from the cells, but for a drag on an element\n // it would scroll instead (`inScroller`).\n const toPage = (x: number, y: number): [number, number] => {\n const r = this.frame.getBoundingClientRect();\n return [r.left + x, r.top + y];\n };\n // A document that scrolls (SPEC \u00A75.3) is the browser's to pan: where it\n // can still move the way a drag goes, the drag is left to the browser,\n // which pans the document; where it cannot, the drag goes on to the\n // terminal, unless overscroll-behavior stops it. Where the page scrolls,\n // the browser chains the drag from the document to the page itself.\n if (this.host.pageScrolls) {\n new Touch(d, this.frame.ownerDocument.defaultView!, { scroll: (dx, dy) => this.host.scrollPage(dx, dy), toPage }, false, (e) =>\n !this.axes && this.inScroller(e.target),\n );\n } else {\n new Touch(d, this.frame.ownerDocument.defaultView!, {\n scroll: (dx, dy, x, y) => {\n if (this.touchRoute === \"terminal\") this.host.wheel(new WheelEvent(\"wheel\", { deltaX: dx, deltaY: dy, deltaMode: 0, clientX: x, clientY: y }), x, y);\n },\n toPage,\n claim: (dx, dy, e) => {\n this.touchRoute = this.axes ? this.gestureRoute(e.target, dx, dy) : \"terminal\";\n return this.touchRoute !== \"doc\";\n },\n });\n }\n // The frame's own focus gives no keyboard: an element in it that takes\n // focus does (`onFocusIn`), or the program (SPEC \u00A710.1).\n win.addEventListener(\"focus\", () => {\n if (!this.programFocus && !this.auxPress && !this.keyboard) this.settle();\n });\n win.addEventListener(\"blur\", () => {\n this.commit();\n if (this.keyboard) {\n this.keyboard = false;\n this.emit(\"blur\", \"\");\n }\n });\n }\n\n /**\n * Nothing in a surface scrolls, and a wheel over it is the terminal's\n * (SPEC \u00A75.3, \u00A79). Wheel events never leave an iframe, so without this\n * the terminal's scrollback (or, on the alternate screen, the program's\n * wheel input) would stall under the pointer. Ctrl and the wheel stay the\n * browser's: its zoom. Where the page scrolls (the `scroll` option), the\n * wheel is the browser's too: nothing in the frame scrolls, so it scrolls\n * the page, as over the cells; but over an element it would scroll\n * instead, the surface scrolls the page itself.\n */\n private onWheel(e: WheelEvent) {\n if (e.ctrlKey) return;\n if (this.axes) {\n this.scrollWheel(e);\n return;\n }\n if (this.host.pageScrolls) {\n if (!this.inScroller(e.target)) return;\n e.preventDefault();\n const px = e.deltaMode === WheelEvent.DOM_DELTA_PIXEL ? 1 : e.deltaMode === WheelEvent.DOM_DELTA_LINE ? 20 : 400;\n this.host.scrollPage(e.deltaX * px, e.deltaY * px);\n return;\n }\n e.preventDefault();\n const r = this.frame.getBoundingClientRect();\n this.host.wheel(e, r.left + e.clientX, r.top + e.clientY);\n }\n\n /** Whether a wheel or a touch at target would scroll an element of the\n * document, overflowing with `overflow: auto` or `scroll`: the browser\n * gives the gesture to it before the page, and nothing in a surface\n * scrolls (SPEC \u00A75.3), so the gesture would go nowhere. */\n private inScroller(target: EventTarget | null): boolean {\n for (let n = target && isElement(target) ? target : null; n; n = n.parentElement) {\n const s = n.ownerDocument.defaultView!.getComputedStyle(n);\n const y = /auto|scroll/.test(s.overflowY) && n.scrollHeight > n.clientHeight;\n const x = /auto|scroll/.test(s.overflowX) && n.scrollWidth > n.clientWidth;\n if (x || y) return true;\n }\n return false;\n }\n\n /**\n * A wheel over a document that scrolls (SPEC \u00A75.3). A gesture's first\n * wheel decides where all of it goes, as a browser latches scrolling to\n * what it began on: while an element under the pointer can still move\n * that way, the browser scrolls it; where none can, the gesture goes on\n * to the terminal, as over the cells beneath (\u00A79), unless\n * `overscroll-behavior` stops it. A gesture the document took goes no\n * further when it reaches the end there, as in a browser. Where the page\n * scrolls (the `scroll` option), the page is the terminal, and the\n * browser chains to it from the document natively. A wheel the browser\n * does not let the page cancel is the browser's already.\n */\n private scrollWheel(e: WheelEvent) {\n if (this.host.pageScrolls || !e.cancelable) return;\n const route = this.host.wheelGesture(this.name, () => {\n const to = this.gestureTarget(e.target, e.deltaX, e.deltaY);\n this.wheelBox = typeof to === \"string\" ? null : to;\n return typeof to === \"string\" ? to : \"doc\";\n });\n // The box the gesture began on, while it can still move: the browser's\n // own scrolling picks it again, the innermost under the pointer.\n const [axis, d] = mainAxis(e.deltaX, e.deltaY);\n if (route === \"doc\" && this.wheelBox && this.canMove(this.wheelBox, axis, d)) return;\n e.preventDefault();\n if (route !== \"terminal\") return;\n const r = this.frame.getBoundingClientRect();\n this.host.wheel(e, r.left + e.clientX, r.top + e.clientY);\n }\n\n /** Where a gesture that scrolls by dx, dy pixels at `target` goes, by its\n * main axis (SPEC \u00A75.3). */\n private gestureRoute(target: EventTarget | null, dx: number, dy: number): Route {\n const to = this.gestureTarget(target, dx, dy);\n return typeof to === \"string\" ? to : \"doc\";\n }\n\n private gestureTarget(target: EventTarget | null, dx: number, dy: number): Element | \"terminal\" | \"stop\" {\n const [axis, d] = mainAxis(dx, dy);\n return this.scroller(target && isElement(target) ? target : null, axis, d);\n }\n\n /** Whether a box that scrolls can still move along `axis`, `d`'s way. */\n private canMove(el: Element, axis: Axis, d: number): boolean {\n if (!d || !(this.axes & (axis === \"y\" ? 1 : 2))) return false;\n const [at, span] = axis === \"y\" ? [el.scrollTop, el.scrollHeight - el.clientHeight] : [el.scrollLeft, el.scrollWidth - el.clientWidth];\n // Across a right-to-left box, scrollLeft runs from -span to 0.\n const rtl = axis === \"x\" && this.frame.contentWindow!.getComputedStyle(el).direction === \"rtl\";\n const [min, max] = rtl ? [-span, 0] : [0, span];\n return d > 0 ? at < max - 0.5 : at > min + 0.5;\n }\n\n /**\n * What a scroll along `axis`, `d`'s way, from `from` (an element, or the\n * root for none) moves in a document that scrolls (SPEC \u00A75.3): the\n * innermost box, from `from` outward, that the user scrolls along it\n * (`overflow` `auto` or `scroll`; the root's, unless `hidden` or `clip`),\n * that overflows there, and that can still move that way. At a box that\n * cannot, the scroll stops if its `overscroll-behavior` is `contain` or\n * `none`, and goes on outward otherwise. Past the root, and along an axis\n * the document did not ask for, it is the terminal's.\n */\n private scroller(from: Element | null, axis: Axis, d: number): Element | \"terminal\" | \"stop\" {\n if (!d || !(this.axes & (axis === \"y\" ? 1 : 2))) return \"terminal\";\n const win = this.frame.contentWindow!;\n const root = this.doc.documentElement;\n const body = this.doc.body;\n const rootStyle = win.getComputedStyle(root);\n // The viewport takes the root's overflow, or the body's where the root's\n // is visible both ways; the body then scrolls nothing itself.\n const fromBody = rootStyle.overflowX === \"visible\" && rootStyle.overflowY === \"visible\";\n const prop = axis === \"y\" ? \"overflowY\" : \"overflowX\";\n for (let el: Element | null = from ?? root; el; el = el.parentElement) {\n if (el === body && fromBody) continue;\n const s = el === root ? rootStyle : win.getComputedStyle(el);\n const scrolls = el === root ? !/hidden|clip/.test((fromBody ? win.getComputedStyle(body) : s)[prop]) : /auto|scroll/.test(s[prop]);\n const span = axis === \"y\" ? el.scrollHeight - el.clientHeight : el.scrollWidth - el.clientWidth;\n if (!scrolls || span < 1) continue;\n if (this.canMove(el, axis, d)) return el;\n const stops = axis === \"y\" ? s.overscrollBehaviorY : s.overscrollBehaviorX;\n if (stops === \"contain\" || stops === \"none\") return \"stop\";\n }\n return \"terminal\";\n }\n\n /** Whatever the browser scrolled along an axis the document did not ask\n * for (a focused element into view, say) goes back to zero. A text\n * field's own text follows its caret (SPEC \u00A75.3). */\n private onScroll(e: Event) {\n if (this.axes === 3) return;\n const t = e.target;\n const el = t === this.doc ? this.doc.scrollingElement : t && isElement(t) ? t : null;\n if (!el || (t !== this.doc && (el.localName === \"input\" || el.localName === \"textarea\"))) return;\n const x = !(this.axes & 2) && el.scrollLeft !== 0;\n const y = !(this.axes & 1) && el.scrollTop !== 0;\n if (x || y) el.scrollTo(x ? 0 : el.scrollLeft, y ? 0 : el.scrollTop);\n }\n\n\n /** An event for the program (SPEC \u00A79); a detached surface sends none (\u00A75.5). */\n private emit(kind: string, target: string, detail?: unknown) {\n if (this.detachedState) return;\n this.host.event(this.name, kind, target, detail);\n }\n\n private linkIn(e: Event): Element | null {\n for (const n of e.composedPath()) {\n if (isElement(n) && n.localName === \"a\" && n.hasAttribute(\"href\")) return n;\n }\n return null;\n }\n\n /** A link's `url` (SPEC \u00A79): its href resolved against the document's\n * base, or \"\" under hotty.invalid or when it is no URL. */\n private urlOf(link: Element): string {\n const href = this.resolver.get(link, \"href\") ?? \"\";\n let url = \"\";\n try {\n url = new URL(href, this.base).href;\n } catch {\n /* not a URL */\n }\n return url.startsWith(NO_BASE) ? \"\" : url;\n }\n\n /** The link's box in the page (the iframe may be offset for a window). */\n private pageBox(el: Element): DOMRect {\n const f = this.frame.getBoundingClientRect();\n const r = el.getBoundingClientRect();\n return new DOMRect(f.left + r.left, f.top + r.top, r.width, r.height);\n }\n\n /** A hyperlink (SPEC \u00A79): a link with target=\"_blank\" and a `url`. One\n * without a url is the program's, as any other link. */\n private isHyperlink(link: Element): boolean {\n return link.getAttribute(\"target\") === \"_blank\" && this.urlOf(link) !== \"\";\n }\n\n private readonly hyper = (link: Element) => this.isHyperlink(link);\n\n /** A link's click (SPEC \u00A79). A hyperlink is the terminal's, as an OSC 8\n * one is, and not reported; any other link is the program's: an event,\n * with or without an id. The host opens nothing itself. */\n private onLink(link: Element, e: MouseEvent) {\n e.preventDefault();\n const url = this.urlOf(link);\n if (this.isHyperlink(link)) {\n if (e.button === 0) this.host.hyperlink(\"activate\", e, url, this.pageBox(link));\n return;\n }\n const detail: Record<string, unknown> = { href: this.resolver.get(link, \"href\") ?? \"\" };\n if (url) detail.url = url;\n detail.area = this.areaOf(link);\n this.emit(\"click\", link.getAttribute(\"id\") ?? \"\", detail);\n }\n\n /** Other buttons on a link do nothing: no navigation, no new tab. */\n private onAuxClick(e: MouseEvent) {\n if (this.linkIn(e)) e.preventDefault();\n }\n\n private hovered: { link: Element; url: string } | null = null;\n\n /** The pointer onto a hyperlink: the terminal hears it, as it does over\n * an OSC 8 one. */\n private onOver(e: MouseEvent) {\n if (this.altPointer !== null) return; // the program's gesture (SPEC \u00A79.2)\n const link = this.linkIn(e);\n const hyper = link && this.isHyperlink(link) ? link : null;\n if (hyper === this.hovered?.link) return;\n this.onLeave(e);\n const url = hyper ? this.urlOf(hyper) : \"\";\n if (hyper) {\n this.hovered = { link: hyper, url };\n this.host.hyperlink(\"hover\", e, url, this.pageBox(hyper));\n }\n }\n\n private onOut(e: MouseEvent) {\n if (this.altPointer !== null) return;\n const to = e.relatedTarget as Node | null;\n if (this.hovered && to && this.hovered.link.contains(to)) return;\n this.onLeave(e);\n }\n\n private onLeave(e: MouseEvent) {\n const h = this.hovered;\n if (!h) return;\n this.hovered = null;\n this.host.hyperlink(\"leave\", e, h.url, this.pageBox(h.link));\n }\n\n private onClick(e: MouseEvent) {\n const link = this.linkIn(e);\n if (this.altReleased) {\n // The release of a press with Alt held: the program's (SPEC \u00A79.2).\n this.altReleased = false;\n e.preventDefault();\n e.stopImmediatePropagation();\n return;\n }\n if (this.dragReleased) {\n // A drag's release: it reported its click itself (onDragUp).\n this.dragReleased = false;\n if (link) e.preventDefault();\n return;\n }\n if (link) {\n this.onLink(link, e);\n return;\n }\n this.reportClick(e.composedPath());\n }\n\n /** The click of the nearest element on `path` that reports one (SPEC \u00A79). */\n private reportClick(path: EventTarget[]) {\n for (const n of path) {\n if (!isElement(n)) continue;\n if (n.localName === \"a\" && n.hasAttribute(\"href\")) {\n // A link's own click (a drag's release on one): the program's, unless\n // it is a hyperlink, which is the terminal's.\n if (this.isHyperlink(n)) return;\n const url = this.urlOf(n);\n const detail: Record<string, unknown> = { href: this.resolver.get(n, \"href\") ?? \"\" };\n if (url) detail.url = url;\n detail.area = this.areaOf(n);\n this.emit(\"click\", n.getAttribute(\"id\") ?? \"\", detail);\n return;\n }\n const el = n;\n const tag = el.localName;\n const type = (el.getAttribute(\"type\") ?? \"\").toLowerCase();\n const wants = (el.getAttribute(\"data-on\") ?? \"\").split(/\\s+/).includes(\"click\");\n const reportable = tag === \"button\" || tag === \"a\" || tag === \"summary\" || (tag === \"input\" && [\"button\", \"submit\", \"reset\"].includes(type)) || wants;\n if (!reportable) continue;\n const id = el.getAttribute(\"id\");\n if (id) {\n const detail: Record<string, unknown> = {};\n const href = this.resolver.get(el, \"href\");\n if (href !== null) detail.href = href;\n const value = this.resolver.get(el, \"value\");\n if (value !== null) detail.value = value;\n detail.area = this.areaOf(el);\n this.emit(\"click\", id, detail);\n }\n break;\n }\n }\n\n private onSubmit(e: SubmitEvent) {\n e.preventDefault();\n const form = e.target as HTMLFormElement;\n const id = form.getAttribute(\"id\");\n if (!id) return;\n const fields: Record<string, string> = {};\n const data = new (this.frame.contentWindow as unknown as typeof globalThis).FormData(form, e.submitter ?? undefined);\n for (const [k, v] of data) if (typeof v === \"string\") fields[k] = v;\n this.emit(\"submit\", id, fields);\n }\n\n private onChange(e: Event) {\n const el = e.target as HTMLInputElement;\n const id = el.getAttribute?.(\"id\");\n if (!id) return;\n const type = (el.getAttribute(\"type\") ?? \"\").toLowerCase();\n if (el.localName === \"input\" && (type === \"checkbox\" || type === \"radio\")) {\n this.emit(\"change\", id, { checked: el.checked, value: this.resolver.get(el, \"value\") });\n } else if (\"value\" in el) {\n this.emit(\"change\", id, { value: el.value });\n }\n }\n\n private onInput(e: Event) {\n const el = e.target as HTMLInputElement;\n const id = el.getAttribute?.(\"id\");\n if (!id) return;\n const type = (el.getAttribute(\"type\") ?? \"\").toLowerCase();\n if (type === \"checkbox\" || type === \"radio\") return; // reported as `change`\n if ((el.getAttribute(\"data-on\") ?? \"\").split(/\\s+/).includes(\"input\") && \"value\" in el) {\n this.emit(\"input\", id, { value: el.value });\n }\n }\n}\n\n/** Elements from the iframe's realm fail `instanceof Element` here. */\nfunction isElement(n: EventTarget): n is Element {\n return (n as Node).nodeType === 1;\n}\n\n/** Whether `el`'s `data-on` lists `what`. */\nfunction listens(el: Element, what: string): boolean {\n return (el.getAttribute(\"data-on\") ?? \"\").split(/\\s+/).includes(what);\n}\n\n/** `el` and its ancestors, as an event's path would have them. */\nfunction ancestry(el: Element): Element[] {\n const out: Element[] = [];\n for (let n: Element | null = el; n; n = n.parentElement) out.push(n);\n return out;\n}\n\n/** The modifier keys held, in the spec's order (SPEC \u00A79.1). */\nfunction keysOf(e: MouseEvent): string[] {\n const keys: string[] = [];\n if (e.shiftKey) keys.push(\"shift\");\n if (e.ctrlKey) keys.push(\"ctrl\");\n if (e.altKey) keys.push(\"alt\");\n if (e.metaKey) keys.push(\"meta\");\n return keys;\n}\n\n/**\n * Whether a click focuses `el` (SPEC \u00A710.1), unless it is disabled: `input`,\n * `select`, `textarea` and `button`; a link with an href, except a\n * hyperlink (`hyper`), which is the terminal's whatever its tabindex; the\n * first summary of a details; an editing host; any element with a tabindex\n * of 0 or more.\n */\nfunction takesFocus(el: Element, hyper: (link: Element) => boolean): boolean {\n if (el.matches(\":disabled\")) return false;\n switch (el.localName) {\n case \"button\":\n case \"select\":\n case \"textarea\":\n return true;\n case \"input\":\n return (el as HTMLInputElement).type !== \"hidden\";\n case \"a\":\n case \"area\":\n if (el.hasAttribute(\"href\")) return !hyper(el);\n break;\n case \"summary\": {\n const d = el.parentElement;\n if (d?.localName === \"details\" && d.querySelector(\":scope > summary\") === el) return true;\n break;\n }\n }\n // An editing host: the element whose contenteditable makes it one.\n const ce = el.getAttribute(\"contenteditable\");\n if (ce !== null && ce.toLowerCase() !== \"false\" && (el as HTMLElement).isContentEditable) return true;\n return el.hasAttribute(\"tabindex\") && (el as HTMLElement).tabIndex >= 0;\n}\n\n/** The element a press focuses: the nearest one, from its target outward,\n * that takes focus, or a label's control; null if there is none, or if the\n * press is on a hyperlink. */\nfunction focusTargetAt(e: Event, hyper: (link: Element) => boolean): HTMLElement | null {\n for (const n of e.composedPath()) {\n if (!isElement(n)) continue;\n if (n.localName === \"a\" && n.hasAttribute(\"href\") && hyper(n)) return null;\n if (takesFocus(n, hyper)) return n as HTMLElement;\n const control = n.localName === \"label\" ? (n as HTMLLabelElement).control : null;\n if (control) return takesFocus(control, hyper) ? control : null;\n }\n return null;\n}\n\n/** A scroll's main axis, and its delta along it. */\nfunction mainAxis(dx: number, dy: number): [Axis, number] {\n return Math.abs(dy) >= Math.abs(dx) ? [\"y\", dy] : [\"x\", dx];\n}\n\n/** The scroll a key makes in a browser, if it makes one (SPEC \u00A75.3): the\n * arrows by a line, Page Up, Page Down, Space and Shift+Space by a page,\n * Home and End to the ends. */\nfunction keyScroll(e: KeyboardEvent): KeyScroll | null {\n if (e.ctrlKey || e.altKey || e.metaKey) return null;\n if (e.shiftKey) return e.key === \" \" ? { axis: \"y\", sign: -1, by: \"page\" } : null;\n switch (e.key) {\n case \"ArrowDown\":\n return { axis: \"y\", sign: 1, by: \"line\" };\n case \"ArrowUp\":\n return { axis: \"y\", sign: -1, by: \"line\" };\n case \"ArrowRight\":\n return { axis: \"x\", sign: 1, by: \"line\" };\n case \"ArrowLeft\":\n return { axis: \"x\", sign: -1, by: \"line\" };\n case \"PageDown\":\n case \" \":\n return { axis: \"y\", sign: 1, by: \"page\" };\n case \"PageUp\":\n return { axis: \"y\", sign: -1, by: \"page\" };\n case \"End\":\n return { axis: \"y\", sign: 1, by: \"end\" };\n case \"Home\":\n return { axis: \"y\", sign: -1, by: \"end\" };\n }\n return null;\n}\n", "/**\n * The addon's version, as its capabilities report it (SPEC \u00A74): package.json's,\n * which a unit test keeps this equal to. A program tells hosts apart by name\n * and version: under HOST every version takes `a=delta`. Before the scope, as\n * `xterm-addon-hotty`, 0.1.0 named no version and took `a=patch`, and 0.2.0\n * took `a=delta`.\n */\nexport const VERSION = \"0.1.0\";\n\n/** The host's name in its capabilities (SPEC \u00A74): the package's. */\nexport const HOST = \"@neuroplastio/xterm-addon-hotty\";\n", "// The HOTTY envelope (PROTOCOL \u00A72): OSC 7279 ; <control> ; <base64 payload> ST.\n//\n// xterm.js hands an OSC handler everything after `7279;`, so this module sees\n// `<control>[;<payload>]` strings. It parses controls, reassembles chunked\n// commands (`m=1`), decodes base64 and zlib (`o=z`), and encodes replies.\n\nexport const OSC = 7279;\n/** Largest base64 chunk a host sends (VTE ignores longer strings). */\nexport const CHUNK = 4096;\n/** Largest reassembled command, in base64 bytes. */\nexport const MAX_COMMAND = 16 << 20;\n\n/** `key=value` pairs separated by `:`, in order. */\nexport class Control {\n readonly pairs: [string, string][];\n\n constructor(pairs: [string, string][] = []) {\n this.pairs = pairs;\n }\n\n static parse(text: string): Control {\n const pairs: [string, string][] = [];\n if (text === \"\") return new Control(pairs);\n for (const part of text.split(\":\")) {\n const eq = part.indexOf(\"=\");\n if (eq <= 0) throw new Error(`bad control pair ${JSON.stringify(part)}`);\n pairs.push([part.slice(0, eq), part.slice(eq + 1)]);\n }\n return new Control(pairs);\n }\n\n get(key: string): string | undefined {\n for (const [k, v] of this.pairs) if (k === key) return v;\n return undefined;\n }\n\n set(key: string, value: string): this {\n const i = this.pairs.findIndex(([k]) => k === key);\n if (i >= 0) this.pairs[i] = [key, value];\n else this.pairs.push([key, value]);\n return this;\n }\n\n delete(key: string): this {\n const i = this.pairs.findIndex(([k]) => k === key);\n if (i >= 0) this.pairs.splice(i, 1);\n return this;\n }\n\n /** A continuation chunk carries nothing but `m` and `q`. */\n onlyChunkKeys(): boolean {\n return this.pairs.every(([k]) => k === \"m\" || k === \"q\");\n }\n\n encode(): string {\n return this.pairs.map(([k, v]) => `${k}=${clean(v)}`).join(\":\");\n }\n}\n\n/**\n * A control value is printable ASCII (SPEC \u00A73.2): each character it may not\n * hold (`:`, `;`, `=`, a control character, anything outside ASCII) becomes\n * one `_`, one per code point.\n */\nexport function clean(value: string): string {\n return value.replace(/[^\\x20-\\x7e]|[:;=]/gu, \"_\");\n}\n\nexport interface Command {\n control: Control;\n payload: Uint8Array;\n}\n\nexport type Decoded =\n | { kind: \"command\"; command: Command }\n | { kind: \"invalid\"; reason: string }\n | { kind: \"partial\" };\n\n/**\n * Reassembles chunked commands. Decoding is synchronous unless the payload is\n * zlib (`o=z`), which the browser only inflates asynchronously; the caller\n * then gets a Promise, and xterm's parser waits for it.\n */\nexport class Assembler {\n private partial: { control: Control; b64: string[]; size: number } | null = null;\n\n /** Feeds the data of one OSC 7279 sequence. */\n feed(data: string): Decoded[] | Promise<Decoded[]> {\n const semi = data.indexOf(\";\");\n const ctlText = semi < 0 ? data : data.slice(0, semi);\n const b64 = semi < 0 ? \"\" : data.slice(semi + 1);\n let control: Control;\n try {\n control = Control.parse(ctlText);\n } catch (e) {\n this.partial = null;\n return [{ kind: \"invalid\", reason: String((e as Error).message) }];\n }\n const more = control.get(\"m\") === \"1\";\n const partial = this.partial;\n this.partial = null;\n if (partial && control.onlyChunkKeys()) {\n partial.b64.push(b64);\n partial.size += b64.length;\n if (partial.size > MAX_COMMAND) return [{ kind: \"invalid\", reason: \"command too large\" }];\n if (more) {\n this.partial = partial;\n return [{ kind: \"partial\" }];\n }\n return settle([], emit(partial.control, partial.b64.join(\"\")));\n }\n const out: Decoded[] = [];\n if (partial) out.push({ kind: \"invalid\", reason: \"chunked command interrupted\" });\n if (more) {\n this.partial = { control, b64: [b64], size: b64.length };\n out.push({ kind: \"partial\" });\n return out;\n }\n return settle(out, emit(control, b64));\n }\n}\n\nfunction settle(out: Decoded[], d: Decoded | Promise<Decoded>): Decoded[] | Promise<Decoded[]> {\n if (d instanceof Promise) return d.then((x) => [...out, x]);\n out.push(d);\n return out;\n}\n\nfunction emit(control: Control, b64: string): Decoded | Promise<Decoded> {\n const fail = (e: unknown): Decoded => ({ kind: \"invalid\", reason: `bad payload: ${(e as Error).message}` });\n let bytes: Uint8Array;\n try {\n bytes = fromBase64(b64);\n } catch (e) {\n return fail(e);\n }\n const done = (payload: Uint8Array): Decoded => {\n control.delete(\"m\").delete(\"o\");\n return { kind: \"command\", command: { control, payload } };\n };\n if (control.get(\"o\") === \"z\") return inflate(bytes).then(done, fail);\n return done(bytes);\n}\n\nexport function fromBase64(b64: string): Uint8Array {\n const s = b64.replace(/\\s+/g, \"\");\n if (s === \"\") return new Uint8Array(0);\n const bin = atob(s);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n\nexport function toBase64(bytes: Uint8Array): string {\n let bin = \"\";\n for (let i = 0; i < bytes.length; i += 0x8000) {\n bin += String.fromCharCode(...bytes.subarray(i, i + 0x8000));\n }\n return btoa(bin);\n}\n\n/** zlib (RFC 1950), which `DecompressionStream` calls \"deflate\". */\nexport async function inflate(bytes: Uint8Array): Promise<Uint8Array> {\n const stream = new Blob([bytes as BlobPart]).stream().pipeThrough(new DecompressionStream(\"deflate\"));\n return new Uint8Array(await new Response(stream).arrayBuffer());\n}\n\nconst utf8 = new TextDecoder(\"utf-8\", { fatal: false });\nconst utf8Encoder = new TextEncoder();\n\nexport function text(bytes: Uint8Array): string {\n return utf8.decode(bytes);\n}\n\n/**\n * Encodes one message for the program: base64, chunked at `CHUNK`, each chunk\n * a complete OSC terminated by ST. Replies are small, so they are never\n * compressed (`o=z` is optional in both directions).\n */\nexport function encode(control: Control, payload: Uint8Array | string = new Uint8Array(0)): string {\n const bytes = typeof payload === \"string\" ? utf8Encoder.encode(payload) : payload;\n const b64 = toBase64(bytes);\n const osc = (ctl: string, chunk: string | null) =>\n `\\x1b]${OSC};${ctl}${chunk === null ? \"\" : `;${chunk}`}\\x1b\\\\`;\n if (b64.length <= CHUNK) return osc(control.encode(), b64 === \"\" ? null : b64);\n const quiet = control.get(\"q\");\n let out = \"\";\n for (let i = 0; i < b64.length; i += CHUNK) {\n const last = i + CHUNK >= b64.length;\n let ctl: Control;\n if (i === 0) {\n ctl = new Control([...control.pairs]).set(\"m\", \"1\");\n } else {\n ctl = new Control([[\"m\", last ? \"0\" : \"1\"]]);\n if (quiet !== undefined) ctl.set(\"q\", quiet);\n }\n out += osc(ctl.encode(), b64.slice(i, i + CHUNK));\n }\n return out;\n}\n\n/** Decodes messages the host sent (for tests and for programs written in JS). */\nexport async function decodeAll(stream: string): Promise<Command[]> {\n const a = new Assembler();\n const out: Command[] = [];\n const re = /\\x1b\\]7279;([^\\x07\\x1b]*)(?:\\x07|\\x1b\\\\)/g;\n for (const m of stream.matchAll(re)) {\n for (const d of await a.feed(m[1]!)) if (d.kind === \"command\") out.push(d.command);\n }\n return out;\n}\n", "// HOTTY for xterm.js: the addon.\n//\n// const term = new Terminal();\n// term.loadAddon(new HottyAddon());\n// term.open(element);\n//\n// Commands arrive on OSC 7279 (PROTOCOL \u00A72); replies and events leave through\n// `term.input(\u2026, false)`, the same path as typing, so they reach the program\n// on its stdin. Surfaces are sandboxed iframes in a layer over the screen.\n// On the normal buffer a surface hangs from a marker (public API, unlike\n// decorations, which need allowProposedApi): it scrolls with the text, stays\n// visible while any of its rows is, and dies when its line leaves the\n// scrollback. On the alternate buffer, where markers do not work (as\n// xterm.js's own image addon notes), it sits on fixed cells.\n\nimport type { IBufferRange, IDisposable, IMarker, ITerminalAddon, Terminal } from \"@xterm/xterm\";\nimport { hostCss, palette } from \"./hostcss.ts\";\nimport { OPS, DeltaError } from \"./delta.ts\";\nimport { clean, type Policy } from \"./network.ts\";\nimport { Store } from \"./resources.ts\";\nimport { type Route, type Scheme, Surface, type SurfaceHost } from \"./surface.ts\";\nimport { Touch } from \"./touch.ts\";\nimport { HOST, VERSION } from \"./version.ts\";\nimport { Assembler, Control, encode, OSC, text, type Command, type Decoded } from \"./wire.ts\";\n\nexport interface HottyOptions {\n /** Most surfaces at once (reported under `limits`). Default 64. */\n maxSurfaces?: number;\n /** Bytes of resources (reported under `limits`). Default 64 MB. */\n resourceQuota?: number;\n /** Called once per applied command batch, with timings, for measurements. */\n onFrame?: (f: FrameStats) => void;\n /** Called for commands that could not be decoded. */\n onInvalid?: (reason: string) => void;\n /**\n * What surfaces may fetch from the network: the host's half of the network\n * policy (SPEC \u00A77.2), directive to sources, e.g.\n * `{ \"img-src\": [\"https://example.com\"] }`. A document gets what it asks\n * for (`<meta name=\"hotty-network\">`) and this allows. Default: nothing.\n * The embedding page's own CSP must allow these sources too.\n */\n network?: Policy;\n /**\n * Touch on the whole terminal (SPEC \u00A79): a drag scrolls, over the cells\n * and the surfaces alike, and a tap on the cells is a click for the\n * program. This replaces xterm.js's own touch handling, which in 6.1 sends\n * wheel reports with no position (NaN) and turns taps into nothing.\n * Default true.\n */\n touch?: boolean;\n /**\n * What a wheel or a touch drag scrolls, over the cells and the surfaces\n * alike (SPEC \u00A79). `\"terminal\"` (the default): the terminal's scrollback,\n * or on the alternate screen the program's wheel input. `\"page\"`: the page\n * the terminal is in, for a page that shows a program's output whole, with\n * the terminal as tall as what it shows. Neither the addon nor xterm.js\n * takes a wheel or a touch then: the browser scrolls the page, natively,\n * and the program hears no wheel. `touch` does nothing in this mode.\n */\n scroll?: \"terminal\" | \"page\";\n /**\n * Keys the browser keeps: they never reach the program, from the terminal\n * or from a surface holding the keyboard, and the browser acts on them.\n * A terminal cannot know which keys a program binds, so these are the\n * browser's own. Default: `browserKeys`, which covers reload, zoom, full\n * screen, the developer tools, and on a Mac everything with Cmd.\n */\n browserKeys?: (e: KeyboardEvent) => boolean;\n}\n\nconst mac = typeof navigator !== \"undefined\" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);\n\n/** The browser's own keys (the default for `browserKeys`): reload (F5, Ctrl\n * or Cmd with R), zoom (Ctrl or Cmd with +, - or 0), full screen (F11), the\n * developer tools (F12, Ctrl+Shift with I, J or C), and on a Mac everything\n * with Cmd. */\nexport function browserKeys(e: KeyboardEvent): boolean {\n if (e.key === \"F5\" || e.key === \"F11\" || e.key === \"F12\") return true;\n if (mac && e.metaKey) return true;\n const mod = e.ctrlKey || e.metaKey;\n const k = e.key.toLowerCase();\n if (mod && !e.altKey && k === \"r\") return true;\n if (mod && [\"=\", \"+\", \"-\", \"0\"].includes(e.key)) return true;\n if (e.ctrlKey && e.shiftKey && [\"i\", \"j\", \"c\"].includes(k)) return true;\n return false;\n}\n\nexport interface FrameStats {\n commands: number;\n /** Milliseconds spent applying them. */\n applyMs: number;\n}\n\nexport interface Inspected {\n tag: string;\n attrs: Record<string, string>;\n text: string;\n children: [string, string | null, string][];\n}\n\n/** A wheel this soon after the one before belongs to the same gesture, in\n * milliseconds: a wheel's notches, or a touchpad's scroll and its momentum. */\nconst GESTURE_MS = 150;\n\n/** `drag` stands for `dragstart`, `drag` and `dragend` (SPEC \u00A74, \u00A79.1). */\nexport const EVENTS = [\"click\", \"change\", \"input\", \"submit\", \"press\", \"drag\", \"focus\", \"blur\", \"resize\", \"fit\"];\n\ninterface Placement {\n surface: Surface;\n kind: \"normal\" | \"alt\";\n col: number;\n row: number;\n marker?: IMarker;\n disposables: IDisposable[];\n}\n\nclass Failure extends Error {\n readonly code: string;\n constructor(code: string, detail: string) {\n super(detail);\n this.code = code;\n }\n}\n\ntype Reply = { extra?: [string, string][]; body?: string };\n\nexport class HottyAddon implements ITerminalAddon {\n private term!: Terminal;\n private readonly opts: Required<Pick<HottyOptions, \"maxSurfaces\" | \"resourceQuota\">> & HottyOptions;\n private readonly store: Store;\n private readonly surfaces = new Map<string, Surface>();\n private readonly placements = new Map<string, Placement>();\n private readonly assembler = new Assembler();\n private readonly disposables: IDisposable[] = [];\n private layer: HTMLDivElement | null = null;\n /** Commands held while synchronized output is on (PROTOCOL \u00A75). */\n private held: Command[] = [];\n private heldTimer: ReturnType<typeof setTimeout> | null = null;\n private css = \"\";\n private readonly policy: Policy;\n private metrics = { cellW: 0, cellH: 0, key: \"\" };\n private resizeTimer: ReturnType<typeof setTimeout> | null = null;\n /** A surface's key is being forwarded to the terminal (`key`), and the\n * terminal's own focus is held off meanwhile. A program in the page may\n * answer the key inside its dispatch, since xterm.js parses what follows\n * user input at once: a surface that gives the keyboard back then has\n * its focus carried out once the key is through. */\n private forwarding = false;\n private focusAfter = false;\n /** The wheel gesture under way: the surface its last wheel was over (\"\" for\n * the cells), where it goes, and when that wheel came. */\n private gesture: { surface: string; route: Route; at: number } | null = null;\n\n constructor(options: HottyOptions = {}) {\n this.opts = { maxSurfaces: 64, resourceQuota: 64 << 20, ...options };\n this.policy = clean(options.network);\n this.store = new Store(this.opts.resourceQuota);\n this.store.onChange = (names) => {\n for (const s of this.surfaces.values()) s.refresh(names);\n };\n }\n\n activate(term: Terminal): void {\n this.term = term;\n // The browser's keys: xterm.js leaves them alone, and the browser acts.\n term.attachCustomKeyEventHandler((e) => !this.browserKey(e));\n const p = term.parser;\n this.disposables.push(\n p.registerOscHandler(OSC, (data) => this.onOsc(data)),\n // `CSI ? 2026 l` ends a synchronized batch: apply what was held, then\n // let xterm handle the mode as usual.\n p.registerCsiHandler({ prefix: \"?\", final: \"l\" }, (params) => {\n if (params.some((x) => x === 2026)) this.release();\n return false;\n }),\n // RIS: every surface goes (PROTOCOL \u00A74).\n p.registerEscHandler({ final: \"c\" }, () => {\n this.reset();\n return false;\n }),\n term.buffer.onBufferChange((b) => this.onBufferChange(b.type)),\n term.onRender(() => {\n this.bindTouch();\n this.checkMetrics();\n }),\n term.onResize(() => this.checkMetrics()),\n term.onScroll(() => this.reposition()),\n term.onWriteParsed(() => this.reposition()),\n );\n }\n\n dispose(): void {\n this.cellTouch?.dispose();\n this.cellTouch = null;\n this.reset();\n for (const d of this.disposables) d.dispose();\n this.disposables.length = 0;\n this.layer?.remove();\n this.layer = null;\n }\n\n /**\n * An element of a surface as the program wrote it (tag, attributes, text,\n * child elements): the shape the shared conformance vectors check\n * (conformance/README.md). `null` if there is no such surface or element.\n */\n inspect(surface: string, id: string): Inspected | null {\n const s = this.surfaces.get(surface);\n const el = s?.doc.getElementById(id);\n if (!s || !el) return null;\n return {\n tag: el.localName,\n attrs: Object.fromEntries(s.resolver.attributes(el)),\n text: el.textContent ?? \"\",\n children: Array.from(el.children, (c): [string, string | null, string] => [c.localName, c.getAttribute(\"id\"), c.textContent ?? \"\"]),\n };\n }\n\n // --- Wire -----------------------------------------------------------------\n\n private onOsc(data: string): boolean | Promise<boolean> {\n const decoded = this.assembler.feed(data);\n // Only zlib makes decoding async; the parser waits for it, so order holds.\n if (decoded instanceof Promise) return decoded.then((d) => this.run(d)).then(() => true);\n const r = this.run(decoded);\n return r instanceof Promise ? r.then(() => true) : true;\n }\n\n private run(decoded: Decoded[]): void | Promise<void> {\n let chain: Promise<void> | undefined;\n for (const d of decoded) {\n if (d.kind === \"invalid\") this.opts.onInvalid?.(d.reason);\n if (d.kind !== \"command\") continue;\n const cmd = d.command;\n chain = sequence(chain, () => this.submit(cmd));\n }\n return chain;\n }\n\n private submit(cmd: Command): void | Promise<void> {\n if (this.term.modes.synchronizedOutputMode && cmd.control.get(\"a\") !== \"q\") {\n this.held.push(cmd);\n // xterm gives up on a batch that never ends after a second; so do we.\n this.heldTimer ??= setTimeout(() => this.release(), 1000);\n return;\n }\n return this.apply([cmd]);\n }\n\n private release() {\n if (this.heldTimer) clearTimeout(this.heldTimer);\n this.heldTimer = null;\n const batch = this.held;\n this.held = [];\n if (batch.length) void this.apply(batch);\n }\n\n private apply(batch: Command[]): void | Promise<void> {\n const t0 = performance.now();\n let chain: Promise<void> | undefined;\n for (const cmd of batch) chain = sequence(chain, () => this.handle(cmd));\n const done = () => this.opts.onFrame?.({ commands: batch.length, applyMs: performance.now() - t0 });\n if (chain) return chain.then(done);\n done();\n }\n\n private handle(cmd: Command): void | Promise<void> {\n const action = cmd.control.get(\"a\") ?? \"\";\n const quiet = Number(cmd.control.get(\"q\") ?? \"0\");\n const ok = (r: Reply | void) => {\n if (quiet === 0) this.reply(\"ok\", cmd, r ?? {});\n };\n const fail = (e: unknown) => {\n const code = e instanceof Failure || e instanceof DeltaError ? e.code : \"EINVAL\";\n const detail = e instanceof Error ? e.message : String(e);\n if (quiet < 2) this.reply(\"err\", cmd, { body: JSON.stringify({ code, detail }) });\n };\n try {\n const r = this.dispatch(action, cmd);\n if (r instanceof Promise) return r.then(ok, fail);\n ok(r);\n } catch (e) {\n fail(e);\n }\n }\n\n private reply(kind: \"ok\" | \"err\", cmd: Command, r: Reply) {\n const c = new Control().set(\"a\", kind);\n for (const k of [\"n\", \"s\"]) {\n const v = cmd.control.get(k);\n if (v !== undefined) c.set(k, v);\n }\n c.set(\"re\", cmd.control.get(\"a\") ?? \"\");\n for (const [k, v] of r.extra ?? []) c.set(k, v);\n this.send(encode(c, r.body ?? \"\"));\n }\n\n private send(message: string) {\n this.term.input(message, false);\n }\n\n // --- Commands (PROTOCOL \u00A73-\u00A76) -------------------------------------------\n\n private dispatch(action: string, cmd: Command): Reply | void | Promise<Reply | void> {\n const c = cmd.control;\n switch (action) {\n case \"q\":\n return { body: JSON.stringify(this.capabilities()) };\n case \"doc\": {\n const name = this.surfaceName(c);\n let s = this.surfaces.get(name);\n if (!s) {\n if (this.surfaces.size >= this.opts.maxSurfaces) throw new Failure(\"EQUOTA\", `at most ${this.opts.maxSurfaces} surfaces`);\n s = new Surface(name, this.host(), this.hostCss(), this.scheme());\n this.surfaces.set(name, s);\n }\n // A new document ends a drag under way (SPEC \u00A79.1); d=1 ends it\n // silently, detaching the surface.\n if (c.get(\"d\") !== \"1\") s.cancelDrag();\n // d=1: detached at once, for a document the program only shows (\u00A75.5).\n // scroll: the axes it scrolls along, a bitmask; anything else is none.\n const scroll = c.get(\"scroll\");\n s.setDocument(text(cmd.payload), c.get(\"d\") === \"1\", scroll === \"1\" || scroll === \"2\" || scroll === \"3\" ? Number(scroll) : 0);\n return;\n }\n case \"place\":\n return this.place(this.existing(c), c);\n case \"hide\": {\n // The document stays; the keyboard goes back to the terminal (\u00A75.4),\n // and a drag under way ends (\u00A79.1).\n const s = this.existing(c);\n s.cancelDrag();\n if (s.hasKeyboard()) s.blur();\n this.unplace(s.name);\n return;\n }\n case \"delta\": {\n const s = this.existing(c);\n s.delta(c.get(\"op\") ?? \"morph\", c.get(\"t\"), c.get(\"k\"), text(cmd.payload));\n return;\n }\n case \"res\": {\n const id = c.get(\"id\");\n if (!id) throw new Failure(\"EINVAL\", \"res needs id=<name>\");\n try {\n this.store.put(id, c.get(\"type\") ?? \"application/octet-stream\", cmd.payload);\n } catch (e) {\n throw new Failure(\"EQUOTA\", (e as Error).message);\n }\n return;\n }\n case \"del\": {\n const id = c.get(\"id\");\n if (id !== undefined) {\n this.store.remove(id);\n return;\n }\n const name = c.get(\"s\");\n if (name === undefined) {\n this.reset();\n return;\n }\n if (!this.surfaces.has(name)) throw new Failure(\"ENOENT\", `no surface ${name}`);\n this.remove(name);\n return;\n }\n case \"detach\":\n // The program is done with the surface: it reports nothing more,\n // and never takes the keyboard (\u00A75.5). Detaching twice does nothing.\n this.existing(c).detach();\n return;\n case \"focus\": {\n const s = this.existing(c);\n if (s.detached) throw new Failure(\"EDETACHED\", `surface ${s.name} is detached`);\n try {\n s.focus(c.get(\"t\"));\n } catch (e) {\n throw new Failure(\"ENOTARGET\", (e as Error).message);\n }\n return;\n }\n case \"blur\":\n this.existing(c).blur();\n return;\n case \"\":\n throw new Failure(\"EINVAL\", \"missing a=<action>\");\n default:\n throw new Failure(\"EINVAL\", `unknown action a=${action}`);\n }\n }\n\n private capabilities() {\n const { cellW, cellH } = this.cell();\n const scale = window.devicePixelRatio || 1;\n return {\n v: \"0.1\",\n ops: OPS,\n events: EVENTS,\n cell: { w: Math.round(cellW * scale), h: Math.round(cellH * scale) },\n scale,\n scheme: this.scheme(),\n limits: { resources: this.store.quota, surfaces: this.opts.maxSurfaces },\n net: this.policy,\n scroll: true,\n host: HOST,\n version: VERSION,\n };\n }\n\n private surfaceName(c: Control): string {\n const s = c.get(\"s\");\n if (s === undefined) throw new Failure(\"EINVAL\", \"missing s=<surface>\");\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(s)) throw new Failure(\"EINVAL\", `bad surface name ${JSON.stringify(s)}`);\n return s;\n }\n\n private existing(c: Control): Surface {\n const name = this.surfaceName(c);\n const s = this.surfaces.get(name);\n if (!s) throw new Failure(\"ENOENT\", `no surface ${name}`);\n return s;\n }\n\n private place(s: Surface, c: Control): Reply {\n const cols = Number(c.get(\"c\"));\n if (c.get(\"c\") === undefined || !Number.isInteger(cols)) throw new Failure(\"EINVAL\", \"place needs c=<cols>\");\n if (cols < 1 || cols > 1000) throw new Failure(\"EINVAL\", \"c out of range\");\n const { cellW, cellH } = this.cell();\n const r = c.get(\"r\");\n const auto = r === undefined || r === \"auto\";\n const rows = auto ? s.contentRows(cols, cellW, cellH) : Number(r);\n if (!Number.isInteger(rows) || rows < 1 || rows > 1000) throw new Failure(\"EINVAL\", \"r out of range\");\n // The window: the part of the surface the placement shows (\u00A75.2).\n const cell = (k: string, d: number) => {\n const v = c.get(k);\n if (v === undefined) return d;\n const n = Number(v);\n if (!Number.isInteger(n) || n < 0) throw new Failure(\"EINVAL\", `bad ${k}`);\n return n;\n };\n const x = cell(\"x\", 0);\n const y = cell(\"y\", 0);\n const win = { x, y, w: cell(\"w\", cols - x), h: cell(\"h\", rows - y) };\n if (win.w < 1 || win.h < 1 || x + win.w > cols || y + win.h > rows) {\n throw new Failure(\"EINVAL\", \"the window is not inside the surface\");\n }\n // Stacking (SPEC \u00A75.2): z, then the order the surfaces were created in,\n // which is the boxes' order in the layer.\n const z = c.get(\"z\") === undefined ? 0 : Number(c.get(\"z\"));\n if (!Number.isInteger(z) || z < -1000 || z > 1000) throw new Failure(\"EINVAL\", \"z is an integer from -1000 to 1000\");\n s.autoRows = auto;\n s.setSize(cols, rows, cellW, cellH, win);\n s.setZ(z);\n this.unplace(s.name);\n // Presses (SPEC \u00A75.2): like z, the placement's.\n s.presses = c.get(\"p\") === \"1\";\n // Fit (SPEC \u00A75.2): the placement's too, from its own rows. The\n // placement keeps its size: re-placing is the program's to do.\n s.setFit(c.get(\"f\") === \"1\" ? rows : null);\n\n const buf = this.term.buffer.active;\n const col = buf.cursorX;\n const row = buf.cursorY;\n const p: Placement = { surface: s, kind: buf.type === \"normal\" ? \"normal\" : \"alt\", col, row, disposables: [] };\n if (p.kind === \"normal\") {\n const marker = this.term.registerMarker(0);\n if (marker) {\n p.marker = marker;\n // Scrolled out of the scrollback: the placement dies (PROTOCOL \u00A74).\n p.disposables.push(marker.onDispose(() => this.unplace(s.name)));\n } else {\n p.kind = \"alt\";\n }\n }\n this.placements.set(s.name, p);\n this.position(p);\n\n if (c.get(\"C\") !== \"1\") this.moveCursorBelow(win.h);\n return { extra: [[\"c\", String(cols)], [\"r\", String(rows)]] };\n }\n\n /** As the native host: index `rows` times, then carriage return. */\n private moveCursorBelow(rows: number) {\n // Private, as the official image addon does it (addon-image ImageStorage.ts:230).\n const core = (this.term as unknown as { _core?: { _inputHandler?: { lineFeed(): void }; buffer?: { x: number } } })._core;\n const ih = core?._inputHandler;\n if (ih && core?.buffer) {\n for (let i = 0; i < rows; i++) ih.lineFeed();\n core.buffer.x = 0;\n }\n }\n\n /** Puts every placed surface where its cells are now. */\n private reposition() {\n for (const p of this.placements.values()) this.position(p);\n }\n\n private position(p: Placement) {\n const { cellW, cellH } = this.cell();\n const s = p.surface;\n let row = p.row;\n if (p.kind === \"normal\") {\n const buf = this.term.buffer.active;\n if (buf.type !== \"normal\" || !p.marker || p.marker.line < 0) {\n s.hide();\n return;\n }\n row = p.marker.line - buf.viewportY;\n }\n if (row + s.win.h <= 0 || row >= this.term.rows) {\n s.hide();\n return;\n }\n s.setSize(s.cols, s.rows, cellW, cellH, s.win);\n s.show(Math.round(p.col * cellW), row * cellH);\n }\n\n private unplace(name: string) {\n const p = this.placements.get(name);\n if (!p) return;\n this.placements.delete(name);\n for (const d of p.disposables) d.dispose();\n p.marker?.dispose();\n p.surface.presses = false;\n p.surface.setFit(null);\n p.surface.park();\n }\n\n private remove(name: string) {\n this.unplace(name);\n this.surfaces.get(name)?.destroy();\n this.surfaces.delete(name);\n }\n\n private reset() {\n for (const name of Array.from(this.surfaces.keys())) this.remove(name);\n this.held = [];\n }\n\n private onBufferChange(type: \"normal\" | \"alternate\") {\n for (const p of Array.from(this.placements.values())) {\n // Surfaces placed on the alternate screen die with it (PROTOCOL \u00A74).\n if (p.kind === \"alt\" && type === \"normal\") this.remove(p.surface.name);\n }\n this.reposition();\n }\n\n // --- Geometry and look ---------------------------------------------------\n\n private host(): SurfaceHost {\n return {\n layer: this.ensureLayer(),\n store: this.store,\n event: (surface, kind, target, detail) => {\n const c = new Control().set(\"a\", \"ev\").set(\"s\", surface).set(\"e\", kind).set(\"t\", target);\n this.send(encode(c, detail === undefined ? \"\" : JSON.stringify(detail)));\n },\n browserKey: (e) => this.browserKey(e),\n key: (e) => {\n // Through xterm.js's own keyboard handling, so the key is encoded\n // the way the program asked: DECCKM, modifyOtherKeys, the kitty\n // keyboard protocol. A printable key xterm.js leaves to keypress\n // (legacy input) gets one.\n const ta = this.term.textarea;\n if (!ta) return;\n const init = {\n key: e.key,\n code: e.code,\n location: e.location,\n repeat: e.repeat,\n ctrlKey: e.ctrlKey,\n altKey: e.altKey,\n shiftKey: e.shiftKey,\n metaKey: e.metaKey,\n keyCode: e.keyCode,\n which: e.which,\n bubbles: true,\n cancelable: true,\n };\n // xterm.js focuses the terminal on every keyup; the surface keeps\n // the keyboard, so its focus does nothing meanwhile.\n Object.defineProperty(ta, \"focus\", { value: () => {}, configurable: true });\n this.forwarding = true;\n try {\n const ev = new KeyboardEvent(e.type, init);\n ta.dispatchEvent(ev);\n if (e.type === \"keydown\" && !ev.defaultPrevented && [...e.key].length === 1) {\n const c = e.key.codePointAt(0)!;\n ta.dispatchEvent(new KeyboardEvent(\"keypress\", { ...init, charCode: c, keyCode: c, which: c }));\n }\n } finally {\n delete (ta as { focus?: unknown }).focus;\n this.forwarding = false;\n if (this.focusAfter) {\n this.focusAfter = false;\n this.term.focus();\n }\n }\n },\n focusTerminal: () => {\n if (this.forwarding) this.focusAfter = true;\n else this.term.focus();\n },\n policy: this.policy,\n pageScrolls: this.pageScrolls,\n scrollPage: (dx, dy) => this.scrollPage(dx, dy),\n wheelGesture: (surface, decide) => {\n const now = performance.now();\n const g = this.gesture;\n const same = g !== null && now - g.at < GESTURE_MS && (g.surface === surface || g.route === \"terminal\");\n const route = same ? g.route : decide();\n this.gesture = { surface, route, at: now };\n return route;\n },\n // A hyperlink (SPEC \u00A79) goes where xterm.js sends an OSC 8 one: the\n // terminal's linkHandler, or its confirm-then-open default, and only\n // for http and https unless the handler allows other schemes.\n hyperlink: (kind, e, url, box) => {\n const handler = this.term.options.linkHandler;\n if (!handler?.allowNonHttpProtocols) {\n try {\n if (![\"http:\", \"https:\"].includes(new URL(url).protocol)) return;\n } catch {\n return;\n }\n }\n const range = this.cellRange(box);\n if (kind === \"activate\") {\n if (handler) handler.activate(e, url, range);\n else openAfterConfirm(url);\n } else if (kind === \"hover\") handler?.hover?.(e, url, range);\n else handler?.leave?.(e, url, range);\n },\n // Replayed on the terminal's screen, where xterm handles it as its own:\n // scrollback, or mouse reports and arrow keys on the alternate screen.\n wheel: (e, x, y) => this.forwardWheel(e, x, y),\n cells: (kind, e, x, y) => this.pressCells(kind, e, x, y),\n };\n }\n\n private cellTouch: Touch | null = null;\n private pageScrollBound = false;\n\n /** Whether the page scrolls, not the terminal (the `scroll` option). */\n private get pageScrolls(): boolean {\n return this.opts.scroll === \"page\";\n }\n\n /**\n * Wheels and touches on the cells left to the browser, which scrolls the\n * page (`scroll: \"page\"`): they stop at the terminal's element, before\n * xterm.js, which would take them for its scrollback, or turn a drag into\n * arrow keys, and cancel the browser's scroll. Nothing here cancels it.\n */\n private bindPageScroll(el: HTMLElement) {\n if (this.pageScrollBound) return;\n this.pageScrollBound = true;\n const stop = (e: Event) => e.stopPropagation();\n for (const type of [\"wheel\", \"touchstart\", \"touchmove\", \"touchend\", \"touchcancel\"]) {\n el.addEventListener(type, stop, { capture: true, passive: true });\n this.disposables.push({ dispose: () => el.removeEventListener(type, stop, { capture: true }) });\n }\n }\n\n /** Scrolls what scrolls the terminal's page: its nearest ancestor that\n * scrolls, or the document. */\n private scrollPage(dx: number, dy: number) {\n let el = this.term.element?.parentElement ?? null;\n for (; el; el = el.parentElement) {\n const o = getComputedStyle(el).overflowY;\n if (/auto|scroll/.test(o) && el.scrollHeight > el.clientHeight) break;\n }\n (el ?? document.scrollingElement ?? document.documentElement).scrollBy(dx, dy);\n }\n\n private cellWheelBound = false;\n\n /** A wheel over the cells begins or goes on with a gesture of the\n * terminal's: a document that scrolls under the pointer as the terminal\n * scrolls takes none of it (`wheelGesture`). */\n private bindCellWheel(el: HTMLElement) {\n if (this.cellWheelBound) return;\n this.cellWheelBound = true;\n const wheel = (e: Event) => {\n if (e.isTrusted) this.gesture = { surface: \"\", route: \"terminal\", at: performance.now() };\n };\n el.addEventListener(\"wheel\", wheel, { capture: true, passive: true });\n this.disposables.push({ dispose: () => el.removeEventListener(\"wheel\", wheel, { capture: true }) });\n }\n\n /** Touch on the cells (the `touch` option), once the terminal is open. */\n private bindTouch() {\n const el = this.term.element;\n if (el && this.pageScrolls) return this.bindPageScroll(el);\n if (el) this.bindCellWheel(el);\n if (this.cellTouch || !el || this.opts.touch === false) return;\n const screen = () => el.querySelector(\".xterm-screen\");\n this.cellTouch = new Touch(\n el,\n el.ownerDocument.defaultView!,\n {\n scroll: (dx, dy, x, y) => this.forwardWheel(new WheelEvent(\"wheel\", { deltaX: dx, deltaY: dy, deltaMode: 0 }), x, y),\n // A tap is the press and release a click would make: xterm.js\n // reports them to the program as it reports a mouse.\n tap: (x, y) => {\n const at = { clientX: x, clientY: y, button: 0, bubbles: true, cancelable: true, view: el.ownerDocument.defaultView };\n screen()?.dispatchEvent(new MouseEvent(\"mousedown\", { ...at, buttons: 1 }));\n el.ownerDocument.dispatchEvent(new MouseEvent(\"mouseup\", { ...at, buttons: 0 }));\n },\n toPage: (x, y) => [x, y],\n },\n true,\n );\n }\n\n /** A wheel, at a point in the page, replayed on the terminal's screen,\n * where xterm.js handles it as its own: scrollback, or mouse reports and\n * arrow keys on the alternate screen. */\n private forwardWheel(e: WheelEvent, x: number, y: number) {\n const ev = new WheelEvent(\"wheel\", {\n deltaX: e.deltaX,\n deltaY: e.deltaY,\n deltaMode: e.deltaMode,\n clientX: x,\n clientY: y,\n shiftKey: e.shiftKey,\n altKey: e.altKey,\n metaKey: e.metaKey,\n bubbles: true,\n cancelable: true,\n });\n legacyWheelDelta(ev, e);\n this.term.element?.querySelector(\".xterm-screen\")?.dispatchEvent(ev);\n }\n\n /**\n * A press with Alt held on a surface, a move of its gesture, or its\n * release (SPEC \u00A79.2), replayed on the cells beneath, where xterm.js\n * handles them as its own mouse: a report to the program, with Alt, or\n * its selection (rectangular, with Alt). The press goes to the screen,\n * where xterm.js listens for presses; the moves and the release to its\n * document, where it listens while a button is held. The keyboard goes\n * back to the terminal first, as on a click on the cells (\u00A710.1): a\n * surface that had it sends `blur`.\n */\n private pressCells(kind: \"down\" | \"move\" | \"up\", e: MouseEvent, x: number, y: number) {\n const el = this.term.element;\n if (!el) return;\n const init: MouseEventInit = {\n clientX: x,\n clientY: y,\n screenX: e.screenX,\n screenY: e.screenY,\n button: 0,\n buttons: e.buttons,\n // xterm.js selects on a press whose detail is the click count.\n detail: kind === \"down\" ? e.detail || 1 : e.detail,\n altKey: e.altKey,\n ctrlKey: e.ctrlKey,\n shiftKey: e.shiftKey,\n metaKey: e.metaKey,\n bubbles: true,\n cancelable: true,\n view: el.ownerDocument.defaultView,\n };\n if (kind === \"down\") {\n for (const s of this.surfaces.values()) if (s.hasKeyboard()) s.blur();\n el.querySelector(\".xterm-screen\")?.dispatchEvent(new MouseEvent(\"mousedown\", init));\n return;\n }\n el.ownerDocument.dispatchEvent(new MouseEvent(kind === \"move\" ? \"mousemove\" : \"mouseup\", init));\n }\n\n private ensureLayer(): HTMLDivElement {\n if (this.layer?.isConnected) return this.layer;\n const screen = this.term.element?.querySelector(\".xterm-screen\");\n if (!screen) throw new Failure(\"EINVAL\", \"terminal is not open\");\n const layer = document.createElement(\"div\");\n layer.className = \"hotty-layer\";\n // The screen's size, clipping surfaces that are partly scrolled away.\n Object.assign(layer.style, { position: \"absolute\", inset: \"0\", overflow: \"hidden\", zIndex: \"6\", pointerEvents: \"none\" });\n screen.append(layer);\n this.layer = layer;\n return layer;\n }\n\n private browserKey(e: KeyboardEvent): boolean {\n return (this.opts.browserKeys ?? browserKeys)(e);\n }\n\n /** A box in the page as the buffer cells it covers (1-based, as xterm.js\n * gives an OSC 8 link's range). */\n private cellRange(box: DOMRect): IBufferRange {\n const screen = this.term.element?.querySelector(\".xterm-screen\")?.getBoundingClientRect();\n const { cellW, cellH } = this.cell();\n const top = this.term.buffer.active.viewportY;\n const at = (x: number, y: number) => ({\n x: Math.floor((x - (screen?.left ?? 0)) / cellW) + 1,\n y: top + Math.floor((y - (screen?.top ?? 0)) / cellH) + 1,\n });\n return { start: at(box.left, box.top), end: at(box.right - 1, box.bottom - 1) };\n }\n\n /** Cell size in CSS pixels (private in xterm.js), with a measured fallback. */\n private cell(): { cellW: number; cellH: number } {\n const dims = (this.term as unknown as { _core?: { _renderService?: { dimensions?: { css?: { cell?: { width: number; height: number } } } } } })._core?._renderService?.dimensions?.css?.cell;\n if (dims && dims.width > 0 && dims.height > 0) return { cellW: dims.width, cellH: dims.height };\n const screen = this.term.element?.querySelector(\".xterm-screen\") as HTMLElement | null;\n if (screen && this.term.cols > 0) return { cellW: screen.clientWidth / this.term.cols, cellH: screen.clientHeight / this.term.rows };\n return { cellW: 9, cellH: 17 };\n }\n\n private hostCss(): string {\n const { cellW, cellH } = this.cell();\n const o = this.term.options;\n this.css = hostCss(o.theme, { cellW, cellH, fontFamily: o.fontFamily ?? \"monospace\", fontSize: o.fontSize ?? 15 });\n return this.css;\n }\n\n private scheme(): Scheme {\n return palette(this.term.options.theme).dark ? \"dark\" : \"light\";\n }\n\n /** On every render: did the cell size, font or theme change? */\n private checkMetrics() {\n const { cellW, cellH } = this.cell();\n const o = this.term.options;\n const key = `${cellW}x${cellH}|${o.fontFamily}|${o.fontSize}|${JSON.stringify(o.theme ?? {})}`;\n if (key === this.metrics.key) return;\n const sizeChanged = this.metrics.cellW !== 0 && (cellW !== this.metrics.cellW || cellH !== this.metrics.cellH);\n this.metrics = { cellW, cellH, key };\n if (this.surfaces.size === 0) return;\n const css = this.hostCss();\n const scheme = this.scheme();\n for (const s of this.surfaces.values()) s.setHostCss(css, scheme);\n this.reposition();\n if (sizeChanged) {\n // Re-rendered with no program involvement; tell the program the new size.\n if (this.resizeTimer) clearTimeout(this.resizeTimer);\n this.resizeTimer = setTimeout(() => {\n for (const p of this.placements.values()) {\n const s = p.surface;\n if (s.detached) continue; // it sends no events (\u00A75.5)\n this.host().event(s.name, \"resize\", \"\", { w: Math.round(s.cols * cellW), h: s.rows * cellH });\n }\n }, 100);\n }\n }\n}\n\n/** Runs `f` after `chain`, synchronously when nothing before it was async. */\nfunction sequence(chain: Promise<void> | undefined, f: () => void | Promise<void>): Promise<void> | undefined {\n if (chain) return chain.then(f);\n const r = f();\n return r instanceof Promise ? r : undefined;\n}\n\n/** xterm.js's default for an OSC 8 link with no linkHandler, as it has it:\n * ask, then open without an opener. */\nfunction openAfterConfirm(uri: string): void {\n if (!confirm(`Do you want to navigate to ${uri}?\\n\\nWARNING: This link could potentially be dangerous`)) return;\n const w = window.open();\n if (!w) {\n console.warn(\"Opening link blocked as opener could not be cleared\");\n return;\n }\n try {\n w.opener = null;\n } catch {\n // Electron can throw\n }\n w.location.href = uri;\n}\n\n/**\n * xterm.js scrolls its scrollback with VS Code's scrollable, which reads the\n * legacy `wheelDeltaX`/`wheelDeltaY` wherever the browser has them (Chromium,\n * WebKit), before `deltaX`/`deltaY`. A real wheel's own values are kept. On\n * a constructed event (a touch drag's) they are the browser's guess: 0 in\n * some versions, in Chromium 15x the delta itself, with the sign of a wheel\n * the other way, so the drag scrolled backwards. Its values are worked out\n * here instead, so that the scrollback moves as far as the finger, and the\n * way it moves: the scrollable moves 50 pixels per 120 of wheelDelta.\n */\nfunction legacyWheelDelta(ev: WheelEvent, from: WheelEvent) {\n if (!(\"wheelDeltaY\" in WheelEvent.prototype)) return; // Firefox reads deltaY\n const legacy = from as WheelEvent & { wheelDeltaX?: number; wheelDeltaY?: number };\n const real = from.isTrusted;\n const pixels = from.deltaMode === WheelEvent.DOM_DELTA_PIXEL ? 1 : from.deltaMode === WheelEvent.DOM_DELTA_LINE ? 20 : 400;\n const x = (real && legacy.wheelDeltaX) || -from.deltaX * pixels * (120 / 50);\n const y = (real && legacy.wheelDeltaY) || -from.deltaY * pixels * (120 / 50);\n Object.defineProperty(ev, \"wheelDeltaX\", { value: x });\n Object.defineProperty(ev, \"wheelDeltaY\", { value: y });\n}\n"],
|
|
5
|
+
"mappings": ";AAgBA,IAAM,aAAa;AACnB,IAAM,aAAa;AACnB,IAAM,YAAY,CAAC,SAAS,OAAO,SAAS,UAAU,QAAQ,WAAW,QAAQ,SAAS,eAAe,aAAa,eAAe,gBAAgB,cAAc,iBAAiB,cAAc,aAAa;AAC/M,IAAM,eAAe,CAAC,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,WAAW,SAAS;AAE7L,SAAS,QAAQ,OAA2B;AACjD,QAAM,KAAK,OAAO,cAAc;AAChC,QAAM,KAAK,OAAO,cAAc;AAChC,QAAM,OAAO,UAAU,IAAI,CAAC,GAAG,MAAM,QAAQ,CAAC,KAAK,aAAa,CAAC,CAAE;AACnE,SAAO,EAAE,IAAI,IAAI,MAAM,MAAM,UAAU,EAAE,IAAI,IAAI;AACnD;AAIO,SAAS,QAAQ,OAA2B,GAAoB;AACrE,QAAM,IAAI,QAAQ,KAAK;AACvB,QAAM,QAA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