deictic 0.11.0 → 0.12.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/API.md CHANGED
@@ -483,6 +483,9 @@ export default defineClientPlugin<Model, Op>({
483
483
  tasks do. Text edits without it are refused.
484
484
  - `pointing(context)` on the page half draws what the plugin has on the page while a shortcut's keys are held, and
485
485
  answers what takes it away: tasks pins each task where its element is.
486
+ - `tag(context, at)` on the page half answers a tag of the plugin's own for what's under the pointer, at `at` in the
487
+ window's pixels, or nothing: `{ text, color }`, drawn in the caption after deictic's, white on `color` (deictic's
488
+ accent unset). prosebook's names the string's catalog key. It's asked on every move while pointing: keep it quick.
486
489
  - `pressed(context, element)` on the page half hears a shortcut's press on a marked element as it goes down, before
487
490
  the page's own handlers and before the popup takes the pointer and the focus: screenshots keeps the page as it is
488
491
  then. Keep it quick: the press waits on it.
@@ -8,7 +8,7 @@
8
8
  * Everything drawn sits in one shadow root, so neither the page's styles nor ours cross over. A
9
9
  * panel's undo and redo are its tab's on its element: the latest change that plugin made there.
10
10
  */
11
- import { C as Target, S as Standalone, c as LightboxItem, i as ClientPlugin, j as Shortcut } from "../shared/index.js";
11
+ import { M as Shortcut, S as Standalone, c as LightboxItem, i as ClientPlugin, w as Target } from "../shared/index.js";
12
12
  /**
13
13
  * Waveforms: a clip's, read off its audio, drawn as bars with what's played in the accent; and a mic's live,
14
14
  * a meter scrolling left as it hears. For the lightbox's player and whatever records the mic (the task
@@ -431,7 +431,7 @@ function spotlight(root) {
431
431
  textContent: text
432
432
  });
433
433
  return {
434
- point({ el, pointed, target, names, count }, glide = true) {
434
+ point({ el, pointed, target, names, count, tags = [] }, glide = true) {
435
435
  pointing = true;
436
436
  const box = el.getBoundingClientRect();
437
437
  const r = grown(box);
@@ -458,10 +458,19 @@ function spotlight(root) {
458
458
  from: `${target.loc.file}:${target.loc.line}`,
459
459
  opens: names.join(" / ")
460
460
  };
461
- const saying = JSON.stringify([texts, dim]);
461
+ const saying = JSON.stringify([
462
+ texts,
463
+ dim,
464
+ tags
465
+ ]);
462
466
  if (saying !== said) {
463
467
  said = saying;
464
- caption.replaceChildren(part("tag", texts.tag), ...texts.inside === "" ? [] : [part("dim", texts.inside)], part("", texts.from), ...dim.map((text) => part("dim", text)), ...names.length === 0 ? [] : [part("opens", texts.opens)]);
468
+ caption.replaceChildren(part("tag", texts.tag), ...tags.map(({ text, color }) => {
469
+ const own = part("tag", text);
470
+ if (color !== void 0) own.style.background = color;
471
+ own.style.color = "#fff";
472
+ return own;
473
+ }), ...texts.inside === "" ? [] : [part("dim", texts.inside)], part("", texts.from), ...dim.map((text) => part("dim", text)), ...names.length === 0 ? [] : [part("opens", texts.opens)]);
465
474
  }
466
475
  caption.classList.toggle("below", r.top < 40);
467
476
  caption.style.translate = `${Math.min(0, document.documentElement.clientWidth - 8 - r.left - caption.offsetWidth)}px`;
@@ -1721,12 +1730,24 @@ function start({ base, shortcut: own, plugins: given, server }) {
1721
1730
  const name = plugin.label ?? plugin.name;
1722
1731
  return [shortcut.button === "left" ? name : `${name} (${shortcut.button})`];
1723
1732
  });
1733
+ const at = pointer;
1734
+ const tags = given.flatMap(({ plugin }) => {
1735
+ if (plugin.tag === void 0) return [];
1736
+ try {
1737
+ const tag = plugin.tag(contextOf(plugin.name), at);
1738
+ return tag === void 0 ? [] : [tag];
1739
+ } catch (e) {
1740
+ report(failed(plugin.name, "tag what was pointed at", e));
1741
+ return [];
1742
+ }
1743
+ });
1724
1744
  lighting.point({
1725
1745
  el,
1726
1746
  ...hit?.pointed === void 0 ? {} : { pointed: hit.pointed },
1727
1747
  target,
1728
1748
  names,
1729
- count: sameAs(el).length
1749
+ count: sameAs(el).length,
1750
+ tags
1730
1751
  }, glide);
1731
1752
  };
1732
1753
  const update = (e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["KEY","button","LINGER","place","MARGIN"],"sources":["../../src/client/away.ts","../../src/client/lightbox.ts","../../src/client/lighting.ts","../../src/client/style.ts","../../src/client/tools.ts","../../src/client/tooltip.ts","../../src/client/tray.ts","../../src/client/index.ts"],"sourcesContent":["/**\n * A panel's `away`, kept past a page load: the tab, the element's place and the state it left, for the\n * next page to come back with when what it left for carries on there (a recording does).\n *\n * The state may hold what JSON can't (a drawn screenshot is a `Blob`), so it's in IndexedDB, which is the\n * origin's: the tab's session storage holds the key, so each tab comes back to its own.\n */\nimport type { Point, Target } from '#src/index.ts';\n\n/** What the next page needs to come back: which tab, on what, with what. */\nexport interface Away {\n tab: string;\n target: Target;\n /** The spot in the element the popup was on, where it was on one. */\n at?: Point;\n state: unknown;\n}\n\nconst KEY = 'deictic:away';\nconst STORE = 'away';\n/** How long one nobody came back to is kept, in milliseconds: its tab was closed. */\nconst STALE = 24 * 60 * 60 * 1000;\n\n/** One at a time, in the order asked: a `drop` right after a `keep` must not run before it. */\nlet last: Promise<unknown> = Promise.resolve();\n\nfunction store<T>(mode: IDBTransactionMode, work: (store: IDBObjectStore) => IDBRequest<T>): Promise<T> {\n const next = last\n .catch(() => {})\n .then(\n () =>\n new Promise<T>((done, fail) => {\n const opening = indexedDB.open('deictic', 1);\n opening.addEventListener('upgradeneeded', () => opening.result.createObjectStore(STORE));\n opening.addEventListener('error', () => fail(opening.error));\n opening.addEventListener('success', () => {\n const db = opening.result;\n const transaction = db.transaction(STORE, mode);\n transaction.addEventListener('complete', () => db.close());\n transaction.addEventListener('abort', () => db.close());\n try {\n const request = work(transaction.objectStore(STORE));\n request.addEventListener('error', () => fail(request.error));\n request.addEventListener('success', () => done(request.result));\n } catch (e) {\n // What can't be copied throws as it's put, here, where nothing would hear it.\n fail(e);\n }\n });\n }),\n );\n last = next;\n return next;\n}\n\nconst keyOf = (): string | undefined => {\n try {\n return sessionStorage.getItem(KEY) ?? undefined;\n } catch {\n // Storage can be off: nothing is kept past the page, then.\n return undefined;\n }\n};\n\n/** Keeps it for the tab's next page. A state that can't be copied (it holds a function, an element) isn't kept, and a page load loses it. */\nexport function keepAway(away: Away): void {\n try {\n const key = keyOf() ?? crypto.randomUUID();\n sessionStorage.setItem(KEY, key);\n void store('readwrite', (s) => {\n // Those of tabs long closed go as a new one comes.\n const walk = s.openCursor();\n walk.addEventListener('success', () => {\n const cursor = walk.result;\n if (cursor === null) return;\n if (Date.now() - (cursor.value as { at: number }).at > STALE) cursor.delete();\n cursor.continue();\n });\n return s.put({ ...away, at: Date.now() }, key);\n }).catch(() => {});\n } catch {\n // Not kept, then.\n }\n}\n\n/** What the page before this left, if it left anything. */\nexport async function keptAway(): Promise<Away | undefined> {\n const key = keyOf();\n if (key === undefined) return undefined;\n try {\n return await store<Away | undefined>('readonly', (s) => s.get(key));\n } catch {\n return undefined;\n }\n}\n\n/** It's come back, or there's nothing to come back for. */\nexport function dropAway(): void {\n const key = keyOf();\n if (key === undefined) return;\n try {\n sessionStorage.removeItem(KEY);\n } catch {\n // It was readable, so this doesn't happen; and a stale one is dropped by the page that finds it.\n }\n void store('readwrite', (s) => s.delete(key)).catch(() => {});\n}\n","/**\n * The lightbox: what a panel has attached (a capture, a recording's replay, a voice clip), big, over everything,\n * one at a time, ← and → between them. It grows out of the element that opened it and shrinks back into it, or\n * fades where motion is reduced. A sound plays in a player of its own: play, its waveform with what's played\n * lit (click or drag it to seek), and the time. It's a modal (`data-deictic-modal`): Esc closes it, not the popup.\n */\nimport type { LightboxItem, LightboxOptions } from '#src/index.ts';\n\nimport { div, reduced } from './dom.ts';\nimport { type Colors, drawBars, peaksOf } from './waveform.ts';\n\nconst EASE = 'cubic-bezier(0.2, 0.8, 0.2, 1)';\nconst PLAY = '<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M7 4v16l13-8z\" fill=\"currentColor\"/></svg>';\nconst PAUSE = '<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 4h4v16H6zM14 4h4v16h-4z\" fill=\"currentColor\"/></svg>';\n\nconst clock = (s: number) => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, '0')}`;\n\n/**\n * Opens it in `root`. `pinned` draws it where `root` is in the page instead, with no backdrop, motion or keys, and\n * actions that don't close it: for a page of deictic's own states (`lightboxIn`).\n */\nexport function openLightbox(\n root: ShadowRoot,\n items: LightboxItem[],\n { at = 0, from, pinned = false }: LightboxOptions & { pinned?: boolean } = {},\n): { close: () => void } {\n const box = div(pinned ? 'lightbox pinned' : 'lightbox');\n if (!pinned) {\n box.dataset.deicticModal = '';\n box.setAttribute('role', 'dialog');\n box.setAttribute('aria-modal', 'true');\n }\n const backdrop = div('lb-backdrop');\n const stage = div('lb-stage');\n const head = div('lb-head');\n const title = div('lb-title');\n const count = div('lb-count');\n const actions = div('lb-actions');\n const close = button('×', 'Close (Esc)', 'lb-close');\n head.append(title, count, actions, close);\n const body = div('lb-body');\n stage.append(head, body);\n // Drawn, not glyphs: a font's ‹ and › sit off the middle of a round button, each font its own way.\n const prev = button('', 'Previous (←)', 'lb-prev');\n prev.innerHTML = chevron('M15 6l-6 6 6 6');\n const next = button('', 'Next (→)', 'lb-next');\n next.innerHTML = chevron('M9 6l6 6-6 6');\n box.append(backdrop, stage, ...(items.length > 1 ? [prev, next] : []));\n root.append(box);\n\n let index = Math.min(Math.max(0, at), items.length - 1);\n let leave: (() => void) | undefined;\n let closing = false;\n\n const show = (i: number, animate: boolean) => {\n leave?.();\n leave = undefined;\n index = (i + items.length) % items.length;\n const item = items[index]!;\n box.setAttribute('aria-label', item.title);\n title.textContent = item.title;\n count.textContent = items.length > 1 ? `${index + 1} / ${items.length}` : '';\n actions.replaceChildren(\n ...(item.actions ?? []).map((a) => {\n const b = button(a.label, a.title ?? '', '');\n b.addEventListener('click', () => {\n if (!pinned) done();\n a.run();\n });\n return b;\n }),\n );\n // A sound plays as it opens, but not on a page that only shows the lightbox.\n const content = contentOf(item, !pinned);\n body.replaceChildren(content.element);\n leave = content.leave;\n if (animate && !reduced()) body.animate({ opacity: [0, 1] }, { duration: 160, easing: 'ease-out' });\n };\n\n /** The transform that puts the stage where `from` is: what it grows from and shrinks back to. */\n const fromRect = () => {\n if (from === undefined || !from.isConnected) return undefined;\n const f = from.getBoundingClientRect();\n const s = stage.getBoundingClientRect();\n if (f.width === 0 || s.width === 0) return undefined;\n return `translate(${f.left - s.left}px, ${f.top - s.top}px) scale(${f.width / s.width}, ${f.height / s.height})`;\n };\n\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') done();\n else if (e.key === 'ArrowLeft' && items.length > 1) show(index - 1, true);\n else if (e.key === 'ArrowRight' && items.length > 1) show(index + 1, true);\n else return;\n // The popup, under it, waits for its own Esc.\n e.preventDefault();\n e.stopImmediatePropagation();\n };\n if (!pinned) addEventListener('keydown', onKey, true);\n\n function done() {\n if (closing) return;\n closing = true;\n removeEventListener('keydown', onKey, true);\n leave?.();\n if (pinned) return box.remove();\n const gone = () => {\n box.remove();\n if (from instanceof HTMLElement && from.isConnected) from.focus({ preventScroll: true });\n };\n if (reduced()) return gone();\n const to = fromRect();\n backdrop.animate({ opacity: [1, 0] }, { duration: 200, easing: 'ease-in', fill: 'forwards' });\n stage\n .animate(\n to === undefined\n ? { opacity: [1, 0], transform: ['none', 'scale(0.96)'] }\n : { transform: ['none', to], opacity: [1, 1, 0], offset: [0, 0.8, 1] },\n { duration: 220, easing: EASE, fill: 'forwards' },\n )\n .finished.then(gone, gone);\n }\n\n backdrop.addEventListener('click', done);\n close.addEventListener('click', done);\n prev.addEventListener('click', () => show(index - 1, true));\n next.addEventListener('click', () => show(index + 1, true));\n\n show(index, false);\n if (pinned) {\n close.hidden = true;\n return { close: done };\n }\n close.focus({ preventScroll: true });\n if (reduced()) {\n box.animate({ opacity: [0, 1] }, { duration: 150 });\n } else {\n backdrop.animate({ opacity: [0, 1] }, { duration: 240, easing: 'ease-out' });\n const grow = fromRect();\n stage.animate(\n grow === undefined\n ? { opacity: [0, 1], transform: ['scale(0.96)', 'none'] }\n : { transform: [grow, 'none'], opacity: [0, 1, 1], offset: [0, 0.2, 1] },\n { duration: 280, easing: EASE },\n );\n }\n return { close: done };\n}\n\n/** An item, drawn: what goes in the body, and what to stop when it's left (a sound playing). */\nfunction contentOf(item: LightboxItem, autoplay: boolean): { element: HTMLElement; leave?: () => void } {\n switch (item.kind) {\n case 'image': {\n const img = Object.assign(document.createElement('img'), { src: item.url, alt: item.title, className: 'lb-image', draggable: false });\n return { element: img };\n }\n case 'page': {\n const frame = Object.assign(document.createElement('iframe'), { src: item.url, title: item.title, className: 'lb-page' });\n frame.allow = 'autoplay; fullscreen';\n return { element: frame };\n }\n case 'audio':\n return player(item.url, autoplay);\n }\n}\n\n/** A sound: play and pause, its waveform with what's played lit, and the time. With `autoplay`, it starts playing. */\nfunction player(url: string, autoplay: boolean): { element: HTMLElement; leave: () => void } {\n const el = div('lb-audio');\n const play = button('', 'Play (Space)', 'lb-play');\n const wave = Object.assign(document.createElement('canvas'), { className: 'lb-wave' });\n wave.setAttribute('role', 'slider');\n wave.setAttribute('aria-label', 'Where in the clip');\n wave.tabIndex = 0;\n const time = div('lb-time');\n el.append(play, wave, time);\n const audio = new Audio(url);\n const colors: Colors = { played: '#3ddc7c', rest: '#52525b' };\n // Flat until the clip's read: the bars rise when its peaks are in.\n let peaks: number[] = Array<number>(120).fill(0.05);\n let frame = 0;\n // MediaRecorder's webm says no length until it's played through; reading the peaks gives it sooner.\n let length = 0;\n const lengthOf = () => (Number.isFinite(audio.duration) && audio.duration > 0 ? audio.duration : length);\n const draw = () => {\n const total = lengthOf();\n drawBars(wave, peaks, total > 0 ? audio.currentTime / total : 0, colors);\n time.textContent = `${clock(audio.currentTime)} / ${total > 0 ? clock(total) : '–:––'}`;\n wave.setAttribute('aria-valuenow', String(Math.round(audio.currentTime)));\n };\n const loop = () => {\n draw();\n frame = audio.paused ? 0 : requestAnimationFrame(loop);\n };\n const state = () => {\n play.innerHTML = audio.paused ? PLAY : PAUSE;\n play.title = audio.paused ? 'Play (Space)' : 'Pause (Space)';\n if (!audio.paused && frame === 0) frame = requestAnimationFrame(loop);\n draw();\n };\n audio.addEventListener('play', state);\n audio.addEventListener('pause', state);\n audio.addEventListener('ended', state);\n audio.addEventListener('loadedmetadata', draw);\n const toggle = () => void (audio.paused ? audio.play().catch(() => {}) : audio.pause());\n play.addEventListener('click', toggle);\n const seek = (e: PointerEvent) => {\n const r = wave.getBoundingClientRect();\n const total = lengthOf();\n if (total > 0) audio.currentTime = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width)) * total;\n draw();\n };\n wave.addEventListener('pointerdown', (e) => {\n wave.setPointerCapture(e.pointerId);\n seek(e);\n });\n wave.addEventListener('pointermove', (e) => {\n if (wave.hasPointerCapture(e.pointerId)) seek(e);\n });\n el.addEventListener('keydown', (e) => {\n if (e.key !== ' ') return;\n e.preventDefault();\n toggle();\n });\n void peaksOf(url, 120).then(\n (read) => {\n peaks = read.peaks;\n length = read.duration;\n draw();\n },\n // Undecodable here: the player still plays it, over flat bars.\n () => {},\n );\n state();\n if (autoplay) void audio.play().catch(() => state());\n // The canvas has its size once it's in the page.\n requestAnimationFrame(draw);\n return {\n element: el,\n leave: () => {\n audio.pause();\n cancelAnimationFrame(frame);\n },\n };\n}\n\nconst chevron = (d: string) =>\n `<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"${d}\"/></svg>`;\n\nfunction button(text: string, title: string, className: string): HTMLButtonElement {\n const el = document.createElement('button');\n el.type = 'button';\n el.textContent = text;\n el.title = title;\n el.className = className;\n return el;\n}\n","/**\n * What the overlay draws on the page itself: the element under the pointer while a shortcut's keys are held, and\n * the one the popup is open on.\n *\n * It uses the whole page: it dims around the element, which stays lit in a ring, with guides from its edges across\n * the window and a caption saying what it is. The light glides from one element to the next. While the popup is\n * open the element stays lit, tied to the popup by a line that follows both. Nothing here takes the pointer, and\n * the page comes back to full light once the pointer has been out on it a moment.\n */\nimport type { Point, Target } from '#src/index.ts';\n\nimport { named } from './component.ts';\nimport { div, nameOf, place, reduced } from './dom.ts';\n\n/** What's pointed at while a shortcut's keys are held. */\nexport interface Pointed {\n /** The marked element. */\n el: Element;\n /** What's under the pointer inside it, where that differs. */\n pointed?: Element;\n target: Target;\n /**\n * The tabs that plugins' own shortcuts would open, each by its label: several where they share keys and differ by\n * button, and none for deictic's own shortcut alone.\n */\n names: string[];\n /** How many elements on the page are from its place in the source. */\n count: number;\n}\n\nexport interface Lighting {\n /** Shows what's pointed at. Not `glide`: it moved with the page, which nothing eases. */\n point(at: Pointed, glide?: boolean): void;\n hide(): void;\n /** Marks the element the popup (`panel`) is open on, or the spot `at` in it, for as long as it is. Answers what ends it. */\n hold(element: Element, panel: HTMLElement, at?: Point): () => void;\n}\n\n/**\n * How far from the element its ring is, in pixels: the ring glows, and a border, an outline or a ring tried on the\n * element has to show apart from it.\n */\nexport const CLEAR = 8;\n\nconst grown = (r: DOMRect) => new DOMRect(r.left - CLEAR, r.top - CLEAR, r.width + 2 * CLEAR, r.height + 2 * CLEAR);\n\n/** How far around a spot its light reaches, in pixels: a circle that shows what's under the point. */\nconst SPOT = 16;\n\n/** A spot in an element, as the box its light fills. */\nexport function spotOf(element: Element, at: Point): DOMRect {\n const r = element.getBoundingClientRect();\n return new DOMRect(r.left + at.x - SPOT, r.top + at.y - SPOT, 2 * SPOT, 2 * SPOT);\n}\n\n/** How long the pointer is out on the page, in milliseconds, before the page gets its light back. */\nconst LINGER = 700;\n/** How long the light takes from one element to the next, in milliseconds: as the styles have it. */\nconst GLIDE = 240;\n/** How far from a corner the line to the popup starts and ends, in pixels. */\nconst INSET = 22;\n\n// The ring and the line, drawn as strokes: a dash can run along a stroke (the line is drawn out to the popup, and\n// a light goes along it, once), which no border can. Wide faint strokes under them are the glow, as a filter over\n// the whole window would be drawn again with every frame of it.\nconst LIT = `<svg aria-hidden=\"true\">\n<rect class=\"halo\"/><rect class=\"lock\"/>\n<path class=\"halo\" pathLength=\"1\"/><path class=\"tether\" pathLength=\"1\"/><path class=\"flow\" pathLength=\"1\"/>\n<circle r=\"3\"/><circle r=\"3\"/></svg>`;\n\nconst clamp = (n: number, low: number, high: number) => Math.max(low, Math.min(n, high));\n\n/** The light's corner for an element, as far out as the light is: a pill stays a pill, a square corner is eased a little. */\nfunction radiusOf(el: Element, r: DOMRect): number {\n // A computed radius is a length or a percentage, and two of them where the corner is an ellipse: the first, then.\n const [first = '0px'] = getComputedStyle(el).borderTopLeftRadius.split(' ');\n const n = Number.parseFloat(first);\n const least = Math.min(r.width, r.height);\n return Math.min(first.endsWith('%') ? (n / 100) * least : n + CLEAR, least / 2);\n}\n\n/**\n * The line from the lit box to the popup: an S from side to side where the popup is beside it, else down or up to\n * it, and none where they overlap. It ends on the popup level with the box's middle, as near as the popup reaches.\n */\nfunction tetherOf(e: DOMRect, p: DOMRect): { d: string; ends: [number, number][] } | undefined {\n for (const [near, far, low, high] of [\n ['left', 'right', 'top', 'bottom'],\n ['top', 'bottom', 'left', 'right'],\n ] as const) {\n const way = p[near] >= e[far] ? 1 : p[far] <= e[near] ? -1 : 0;\n if (way === 0) continue;\n const a1 = way > 0 ? e[far] : e[near];\n const a2 = way > 0 ? p[near] : p[far];\n const inset = (r: DOMRect) => Math.min(INSET, (r[high] - r[low]) / 2);\n const b2 = clamp((e[low] + e[high]) / 2, p[low] + inset(p), p[high] - inset(p));\n const b1 = clamp(b2, e[low] + inset(e), e[high] - inset(e));\n const bend = (a2 - a1) / 2;\n const at = (a: number, b: number): [number, number] => (near === 'left' ? [a, b] : [b, a]);\n const points = [at(a1, b1), at(a1 + bend, b1), at(a2 - bend, b2), at(a2, b2)].map(([x, y]) => `${x} ${y}`);\n return { d: `M${points[0]}C${points.slice(1).join(' ')}`, ends: [at(a1, b1), at(a2, b2)] };\n }\n return undefined;\n}\n\nexport function spotlight(root: ShadowRoot): Lighting {\n // Under the marks a page keeps (annotations'), which are drawn as bright as ever.\n const veil = div('veil');\n const aim = div('aim');\n const ring = div('ring');\n const caption = div('caption');\n ring.append(caption);\n const guides = { left: div('guide gx'), right: div('guide gx'), top: div('guide gy'), bottom: div('guide gy') };\n const inner = div('inner');\n aim.append(...Object.values(guides), ring);\n root.append(veil, aim, inner);\n\n let pointing = false;\n let held = false;\n let said = '';\n // Not at once: a press that opens the popup hides what's pointed at and holds the same element in one go, and\n // the popup moving to another element lets one go and holds the next. The light stays on through both, and glides.\n const dark = () =>\n queueMicrotask(() => {\n if (!pointing && !held) veil.classList.remove('shown');\n });\n const light = (r: DOMRect, radius: number, glide: boolean) => {\n veil.classList.toggle('glide', glide && veil.classList.contains('shown'));\n place(veil, r);\n veil.style.borderRadius = `${radius}px`;\n veil.classList.add('shown');\n };\n const part = (className: string, text: string) => Object.assign(document.createElement('span'), { className, textContent: text });\n\n return {\n point({ el, pointed, target, names, count }, glide = true) {\n pointing = true;\n const box = el.getBoundingClientRect();\n const r = grown(box);\n const radius = radiusOf(el, r);\n aim.classList.toggle('glide', glide && aim.classList.contains('shown'));\n place(ring, r);\n ring.style.borderRadius = `${radius}px`;\n guides.left.style.translate = `${r.left}px`;\n guides.right.style.translate = `${r.right - 1}px`;\n guides.top.style.translate = `0 ${r.top}px`;\n guides.bottom.style.translate = `0 ${r.bottom - 1}px`;\n // The popup's element keeps the light while it's open: another pointed at then has the ring alone.\n if (!held) light(r, radius, glide);\n inner.classList.toggle('shown', pointed !== undefined);\n if (pointed !== undefined) place(inner, pointed.getBoundingClientRect());\n\n // What it is, where it's from, how big, how many share its place, what's pointed at in it, and the tab a\n // plugin's own shortcut opens.\n const dim = [\n `${Math.round(box.width)}×${Math.round(box.height)}`,\n ...(count > 1 ? [`×${count}`] : []),\n ...(pointed === undefined ? [] : [`› ${nameOf(pointed)}`]),\n ];\n // By the component that wrote it, where the page says which: its name alone for its only element, and with\n // the tag for one of several.\n const { component, sole } = named(el);\n const texts = {\n tag: `<${component ?? target.tag}>`,\n inside: component === undefined || sole ? '' : `<${target.tag}>`,\n from: `${target.loc.file}:${target.loc.line}`,\n opens: names.join(' / '),\n };\n const saying = JSON.stringify([texts, dim]);\n if (saying !== said) {\n said = saying;\n caption.replaceChildren(\n part('tag', texts.tag),\n ...(texts.inside === '' ? [] : [part('dim', texts.inside)]),\n part('', texts.from),\n ...dim.map((text) => part('dim', text)),\n ...(names.length === 0 ? [] : [part('opens', texts.opens)]),\n );\n }\n caption.classList.toggle('below', r.top < 40);\n // Kept in the window: a caption is longer than most of what it names.\n caption.style.translate = `${Math.min(0, document.documentElement.clientWidth - 8 - r.left - caption.offsetWidth)}px`;\n aim.classList.add('shown');\n },\n hide() {\n pointing = false;\n aim.classList.remove('shown');\n inner.classList.remove('shown');\n dark();\n },\n hold(element, panel, at) {\n held = true;\n const lit = div('lit');\n lit.innerHTML = LIT;\n root.append(lit);\n const rects = [...lit.querySelectorAll('rect')];\n const paths = [...lit.querySelectorAll('path')];\n const dots = [...lit.querySelectorAll('circle')];\n // A ring that leaves the element as the popup opens on it, once.\n const pulse = reduced() ? undefined : div('pulse');\n if (pulse !== undefined) {\n root.append(pulse);\n pulse.addEventListener('animationend', () => pulse.remove());\n }\n\n let frame = 0;\n let was: string | undefined;\n // The first place may be a glide, from the element lit before; after it the light keeps to its element as the\n // page moves it, each frame, with no easing to fall behind by.\n let first = true;\n const settled = setTimeout(() => veil.classList.remove('glide'), GLIDE);\n const follow = () => {\n frame = requestAnimationFrame(follow);\n const on = element.isConnected;\n const e = at === undefined ? grown(element.getBoundingClientRect()) : spotOf(element, at);\n const p = panel.getBoundingClientRect();\n const now = on ? [e.left, e.top, e.width, e.height, p.left, p.top, p.width, p.height].join() : '';\n if (now === was) return;\n was = now;\n lit.classList.toggle('shown', on);\n // An element that's not on the page has nothing to light: the page stays as it is.\n if (!on) return veil.classList.remove('shown');\n const radius = at === undefined ? radiusOf(element, e) : SPOT;\n if (first) light(e, radius, true);\n else place(veil, e);\n veil.style.borderRadius = `${radius}px`;\n if (first && pulse !== undefined) {\n place(pulse, e);\n pulse.style.borderRadius = `${radius}px`;\n }\n first = false;\n for (const rect of rects) {\n for (const [name, value] of Object.entries({ x: e.left, y: e.top, width: e.width, height: e.height, rx: radius }))\n rect.setAttribute(name, String(value));\n }\n // From what of the element is in the window: one scrolled out of it is tied from the edge it left by.\n const width = document.documentElement.clientWidth;\n const height = document.documentElement.clientHeight;\n const [left, right] = [clamp(e.left, 0, width), clamp(e.right, 0, width)];\n const [top, bottom] = [clamp(e.top, 0, height), clamp(e.bottom, 0, height)];\n const tie = tetherOf(new DOMRect(left, top, right - left, bottom - top), p);\n lit.classList.toggle('tied', tie !== undefined);\n if (tie === undefined) return;\n for (const path of paths) path.setAttribute('d', tie.d);\n for (const [i, dot] of dots.entries()) {\n dot.setAttribute('cx', String(tie.ends[i]![0]));\n dot.setAttribute('cy', String(tie.ends[i]![1]));\n }\n };\n follow();\n\n // The page dims for what's being done in the popup, and no longer: with the pointer out on the page a\n // moment, it's the page that's looked at, and it gets its light back until the pointer is in the overlay again.\n let lift: ReturnType<typeof setTimeout> | undefined;\n const moved = (e: PointerEvent) => {\n if (!e.composedPath().includes(root.host)) {\n lift ??= setTimeout(() => veil.classList.add('lifted'), LINGER);\n return;\n }\n clearTimeout(lift);\n lift = undefined;\n veil.classList.remove('lifted');\n };\n window.addEventListener('pointermove', moved, { capture: true, passive: true });\n\n return () => {\n held = false;\n cancelAnimationFrame(frame);\n clearTimeout(settled);\n clearTimeout(lift);\n window.removeEventListener('pointermove', moved, true);\n lit.remove();\n pulse?.remove();\n veil.classList.remove('lifted');\n dark();\n };\n },\n };\n}\n","/**\n * The overlay's styles, in its shadow root. Panels style their bodies with the same custom\n * properties, so a plugin's panel looks like the rest without styles of its own for the basics.\n */\nexport const STYLE = `\n:host {\n --deictic-accent: #12b358;\n --deictic-on-accent: #04130b;\n --deictic-bg: #18181b;\n --deictic-fg: #f4f4f5;\n --deictic-muted: #a1a1aa;\n --deictic-line: #3f3f46;\n --deictic-problem: #f87171;\n all: initial;\n /* Inherited by everything in the root: a thumb and no track, on whatever the panel's background is. */\n scrollbar-color: var(--deictic-line) transparent;\n}\n/* The host takes no room in the page: everything in it is fixed, so nothing of deictic's moves or scrolls it. */\n:host(deictic-overlay) { display: contents; }\n/* What's under the pointer inside the lit element, where that differs. */\n.inner {\n position: fixed;\n display: none;\n z-index: 2147483646;\n pointer-events: none;\n box-sizing: border-box;\n outline: 1px dashed var(--deictic-accent);\n}\n.inner.shown { display: block; }\n/* Glass, over a page that's dimmed around what it's about. */\n.panel {\n --deictic-line: rgb(255 255 255 / 0.14);\n position: fixed;\n z-index: 2147483647;\n width: min(440px, calc(100vw - 16px));\n max-height: 60vh;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n border: 1px solid rgb(255 255 255 / 0.1);\n border-radius: 14px;\n box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4), 0 24px 64px -12px rgb(0 0 0 / 0.55), 0 0 56px -12px rgb(18 179 88 / 0.35),\n inset 0 1px 0 rgb(255 255 255 / 0.08);\n font: 13px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n background: linear-gradient(rgb(39 39 42 / 0.9), rgb(24 24 27 / 0.94));\n backdrop-filter: blur(24px) saturate(1.8);\n}\n.panel.pinned { position: relative; z-index: auto; width: min(440px, 100%); max-height: none; }\n@keyframes deictic-in {\n from { opacity: 0; translate: 0 4px; }\n}\n.head {\n position: relative;\n display: flex;\n align-items: center;\n gap: 2px;\n padding: 8px 8px 6px;\n}\n/* Over the page the head is what the popup is dragged by; no touch scrolling starts there. */\n.panel:not(.pinned) .head { cursor: grab; touch-action: none; user-select: none; }\n.panel.dragging .head, .panel.dragging .head button { cursor: grabbing; }\n.head .tab {\n position: relative;\n border: 0;\n border-radius: 8px;\n padding: 4px 10px;\n font-weight: 600;\n color: var(--deictic-muted);\n}\n.head .tab:hover { color: var(--deictic-fg); }\n.head .tab[aria-selected='true'] { color: var(--deictic-fg); }\n/* A pill behind the shown tab, slid to the next one shown. */\n.head .thumb {\n position: absolute;\n left: 0;\n top: 8px;\n bottom: 6px;\n border-radius: 8px;\n background: rgb(255 255 255 / 0.1);\n box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);\n pointer-events: none;\n}\n.head .end { margin-left: auto; }\n.bar {\n display: flex;\n align-items: center;\n gap: 2px;\n padding: 0 10px 8px 12px;\n border-bottom: 1px solid rgb(255 255 255 / 0.08);\n}\n.bar .where {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n margin-right: auto;\n font: 12px ui-monospace, monospace;\n color: var(--deictic-muted);\n text-decoration: none;\n}\n.bar .where span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.bar .where .tag { flex: none; color: var(--deictic-accent); }\n.bar .where svg { flex: none; }\n.bar .where:hover, .bar .where:focus-visible { color: var(--deictic-fg); }\n.bar .where:hover span { text-decoration: underline; }\n.bar .absent { flex: none; margin-right: 6px; font-size: 12px; color: var(--deictic-muted); }\n/* The page dims around the element (lighting.ts), by a shadow far wider than any window. */\n.veil {\n position: fixed;\n z-index: 2147483644;\n box-sizing: border-box;\n pointer-events: none;\n box-shadow: 0 0 0 200vmax rgb(9 9 11 / 0.5);\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.2s, visibility 0s 0.2s;\n}\n/* A moment late: Alt is pressed for much else, and a page that dimmed with every press would flicker. */\n.veil.shown { opacity: 1; visibility: visible; transition: opacity 0.3s 0.08s; }\n.veil.shown.lifted { opacity: 0; transition: opacity 0.6s; }\n.aim {\n position: fixed;\n inset: 0;\n z-index: 2147483646;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.12s, visibility 0s 0.12s;\n}\n.aim.shown { opacity: 1; visibility: visible; transition: opacity 0.12s; }\n.ring {\n position: absolute;\n box-sizing: border-box;\n border: 1.5px solid var(--deictic-accent);\n box-shadow: 0 0 0 4px rgb(18 179 88 / 0.14), 0 0 32px rgb(18 179 88 / 0.5), inset 0 0 24px rgb(18 179 88 / 0.1);\n}\n/* From the element's edges across the window: what it lines up with, anywhere on the page. */\n.guide { position: absolute; left: 0; top: 0; opacity: 0.35; }\n.guide.gx { width: 1px; height: 100%; background: linear-gradient(transparent, var(--deictic-accent) 20% 80%, transparent); }\n.guide.gy { width: 100%; height: 1px; background: linear-gradient(90deg, transparent, var(--deictic-accent) 20% 80%, transparent); }\n.caption {\n position: absolute;\n left: -1.5px;\n bottom: calc(100% + 8px);\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 3px 10px 3px 3px;\n border: 1px solid rgb(255 255 255 / 0.12);\n border-radius: 999px;\n font: 12px/20px ui-monospace, monospace;\n white-space: nowrap;\n color: var(--deictic-fg);\n background: rgb(24 24 27 / 0.86);\n backdrop-filter: blur(12px) saturate(1.6);\n box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);\n}\n.caption.below { top: calc(100% + 8px); bottom: auto; }\n.caption .tag { padding: 0 8px; border-radius: 999px; font-weight: 600; color: var(--deictic-on-accent); background: var(--deictic-accent); }\n.caption .dim { color: var(--deictic-muted); }\n.caption .opens { padding-left: 8px; border-left: 1px solid rgb(255 255 255 / 0.16); font: 600 12px/20px system-ui, sans-serif; color: var(--deictic-accent); }\n.lit { position: fixed; inset: 0; z-index: 2147483646; display: none; pointer-events: none; }\n.lit.shown { display: block; }\n.lit svg { display: block; width: 100%; height: 100%; fill: none; stroke: var(--deictic-accent); stroke-linecap: round; }\n.lit .halo { stroke-width: 7; opacity: 0.16; }\n.lit .lock, .lit .tether { stroke-width: 1.5; }\n.lit .flow { stroke: #eafff3; stroke-width: 2; opacity: 0; }\n.lit circle { fill: var(--deictic-accent); stroke: none; }\n.lit:not(.tied) path, .lit:not(.tied) circle { display: none; }\n.pulse {\n position: fixed;\n z-index: 2147483646;\n box-sizing: border-box;\n pointer-events: none;\n outline: 2px solid var(--deictic-accent);\n animation: deictic-pulse 0.5s ease-out forwards;\n}\n@media (prefers-reduced-motion: no-preference) {\n .head .thumb.moves { transition: left 0.22s cubic-bezier(0.3, 0.7, 0.2, 1), width 0.22s cubic-bezier(0.3, 0.7, 0.2, 1); }\n /* The light goes from one element to the next, not out and on again. */\n .veil.shown.glide {\n transition: opacity 0.3s, left 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), top 0.24s cubic-bezier(0.3, 0.7, 0.2, 1),\n width 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), height 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), border-radius 0.24s;\n }\n .aim.glide .ring {\n transition: left 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), top 0.24s cubic-bezier(0.3, 0.7, 0.2, 1),\n width 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), height 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), border-radius 0.24s;\n }\n .aim.glide .guide { transition: translate 0.24s cubic-bezier(0.3, 0.7, 0.2, 1); }\n .panel:not(.pinned) { animation: deictic-rise 0.32s cubic-bezier(0.2, 0.9, 0.25, 1.1) backwards; }\n /* Once, as the popup opens: the line drawn out to the popup, with a light along it. */\n .lit .tether, .lit path.halo { stroke-dasharray: 1; animation: deictic-draw 0.4s 0.1s ease-out backwards; }\n .lit .flow { stroke-dasharray: 0.14 1; animation: deictic-flow 0.8s 0.45s ease-out; }\n .lit circle:last-of-type { animation: deictic-in 0.2s 0.45s backwards; }\n}\n@keyframes deictic-rise {\n from { opacity: 0; scale: 0.94; filter: blur(6px); }\n}\n@keyframes deictic-draw {\n from { stroke-dashoffset: 1; }\n}\n@keyframes deictic-flow {\n from { stroke-dashoffset: 0.14; opacity: 1; }\n to { stroke-dashoffset: -1; opacity: 0; }\n}\n@keyframes deictic-pulse {\n to { outline-offset: 14px; outline-color: transparent; }\n}\n/* The tool panel (tools.ts): the plugins' tools in a bar on an edge of the window, there while it's of use. */\n.tool-panel {\n position: fixed;\n z-index: 2147483647;\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 6px 8px;\n border: 1px solid rgb(255 255 255 / 0.1);\n border-radius: 12px;\n font: 13px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n background: linear-gradient(rgb(39 39 42 / 0.92), rgb(24 24 27 / 0.96));\n backdrop-filter: blur(24px) saturate(1.8);\n box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4), 0 16px 40px -8px rgb(0 0 0 / 0.55), inset 0 1px 0 rgb(255 255 255 / 0.08);\n user-select: none;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.15s, visibility 0s 0.15s;\n}\n.tool-panel.shown { opacity: 1; visibility: visible; transition: opacity 0.15s; }\n.tool-panel.vertical, .tool-panel.vertical .tool-group { flex-direction: column; }\n.tool-panel .tool-group { display: flex; align-items: center; gap: 4px; }\n/* Groups of one section side by side, as close as the tools in a group are: the bar's gap is for between sections. */\n.tool-panel .tool-group + .tool-group { margin-left: -2px; }\n.tool-panel.vertical .tool-group + .tool-group { margin: -2px 0 0; }\n.tool-panel .grip { display: inline-flex; padding: 2px; color: var(--deictic-muted); cursor: grab; touch-action: none; }\n.tool-panel .grip:active { cursor: grabbing; }\n.tool-panel .grip svg { width: 16px; height: 16px; }\n.tool-panel .sep { align-self: stretch; width: 1px; background: rgb(255 255 255 / 0.12); }\n.tool-panel.vertical .sep { width: auto; height: 1px; }\n/* A group with nothing to show now (a plugin's, hidden) has no line of its own either. */\n.tool-panel .sep:has(+ [hidden]) { display: none; }\n.tool-panel [hidden] { display: none; }\n.tool-panel button.icon { width: 28px; height: 26px; border-radius: 6px; color: var(--deictic-fg); }\n.tool-panel button.icon svg { width: 16px; height: 16px; }\n.tool-panel button[aria-pressed='true'], .tool-panel button[aria-pressed='true']:hover {\n color: var(--deictic-on-accent);\n background: var(--deictic-accent);\n}\n.tool-panel button.problem { color: var(--deictic-problem); }\n/*\n * The drawer (drawer.ts): on the window's side, as tall as what's in it, there while it's of use. Its\n * sections are the plugins', each with its own styles; these are what they share.\n */\n.drawer {\n position: fixed;\n top: 12px;\n right: 12px;\n z-index: 2147483646;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n width: 296px;\n max-width: calc(100vw - 24px);\n max-height: calc(100vh - 24px);\n border: 1px solid rgb(255 255 255 / 0.1);\n border-radius: 12px;\n font: 12px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n background: linear-gradient(rgb(39 39 42 / 0.92), rgb(24 24 27 / 0.96));\n backdrop-filter: blur(24px) saturate(1.8);\n box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4), 0 16px 40px -8px rgb(0 0 0 / 0.55), inset 0 1px 0 rgb(255 255 255 / 0.08);\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.15s, visibility 0s 0.15s;\n}\n.drawer.left { right: auto; left: 12px; }\n.drawer.shown { opacity: 1; visibility: visible; transition: opacity 0.15s; }\n.drawer.emptied { transition: none; }\n.drawer [hidden] { display: none; }\n.drawer-sections, .drawer-view { display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 10px; overflow-y: auto; scrollbar-width: thin; }\n.drawer-view { gap: 8px; }\n.drawer-section h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font: 600 10px/1.4 system-ui, sans-serif; letter-spacing: 0.06em; text-transform: uppercase; color: var(--deictic-muted); }\n.drawer-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }\n.drawer-row { display: flex; align-items: center; gap: 2px; padding-right: 4px; border: 1px solid rgb(255 255 255 / 0.08); border-radius: 8px; background: rgb(255 255 255 / 0.04); }\n.drawer-row:hover { border-color: rgb(255 255 255 / 0.16); }\n/* A row one height whether it has a picture, and the picture one size, loaded or not: nothing moves as one comes. */\n.drawer-open { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; height: 32px; padding: 0 6px; border: 0; text-align: left; font-size: 12px; }\n.drawer-open img { flex: none; display: block; width: 36px; height: 24px; object-fit: cover; border-radius: 4px; background: rgb(255 255 255 / 0.08); }\n.drawer-open svg { flex: none; width: 12px; height: 12px; }\n.drawer-head { display: flex; align-items: center; gap: 6px; margin: -4px 24px 0 -4px; }\n/* Folding it away: the button in its corner, and the pill it folds to, which counts what's in it. */\n.drawer-fold { position: absolute; top: 6px; right: 6px; z-index: 1; width: 22px; height: 22px; border-radius: 6px; color: var(--deictic-muted); }\n.drawer-fold svg { width: 14px; height: 14px; }\n.drawer-sections > .drawer-section:first-child h3 { margin-right: 22px; }\n.drawer-pill { display: none; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: inherit; font: 600 12px/1 system-ui, sans-serif; color: var(--deictic-fg); }\n.drawer-pill svg { width: 16px; height: 16px; }\n.drawer-pill.news span { padding: 2px 6px; border-radius: 8px; color: var(--deictic-on-accent); background: var(--deictic-accent); }\n.drawer.folded { width: auto; }\n.drawer.folded > :not(.drawer-pill) { display: none; }\n.drawer.folded .drawer-pill { display: inline-flex; }\n.drawer-title { font-weight: 600; }\n/* What a tool that picks a point takes the pointer with, over the page and under the popup. */\n.tool-surface { position: fixed; inset: 0; z-index: 2147483645; cursor: crosshair; }\n.lightbox {\n position: fixed;\n inset: 0;\n z-index: 2147483647;\n display: flex;\n align-items: center;\n justify-content: center;\n font: 13px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n}\n.lb-backdrop { position: absolute; inset: 0; background: rgb(9 9 11 / 0.72); backdrop-filter: blur(2px); }\n.lb-stage {\n position: relative;\n display: flex;\n flex-direction: column;\n max-width: 92vw;\n max-height: 90vh;\n border: 1px solid var(--deictic-line);\n border-radius: 10px;\n background: var(--deictic-bg);\n box-shadow: 0 24px 64px rgb(0 0 0 / 0.5);\n transform-origin: 0 0;\n overflow: hidden;\n}\n.lb-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--deictic-line); }\n.lb-title { font-weight: 600; }\n.lb-count { color: var(--deictic-muted); font-size: 12px; font-variant-numeric: tabular-nums; }\n.lb-actions { display: flex; gap: 6px; margin-left: auto; }\n.lb-body { display: flex; justify-content: center; min-height: 0; background: #09090b; }\n.lb-image { display: block; max-width: 92vw; max-height: calc(90vh - 48px); object-fit: contain; }\n.lb-page { display: block; width: min(1280px, 92vw); height: min(860px, calc(90vh - 48px)); border: 0; background: #18181b; }\n.lb-audio { display: flex; align-items: center; gap: 12px; width: min(640px, 86vw); padding: 20px 16px; }\n.lb-play {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n color: var(--deictic-on-accent);\n background: var(--deictic-accent);\n}\n.lb-play svg { width: 16px; height: 16px; }\n.lb-wave { flex: 1; min-width: 0; height: 56px; cursor: pointer; border-radius: 4px; }\n.lb-wave:focus-visible { outline: 1px solid var(--deictic-accent); outline-offset: 2px; }\n.lb-time { flex: none; min-width: 9ch; text-align: right; font: 12px ui-monospace, monospace; color: var(--deictic-muted); }\n.lb-prev, .lb-next {\n position: absolute;\n top: 50%;\n translate: 0 -50%;\n width: 40px;\n height: 40px;\n padding: 0;\n border: 1px solid var(--deictic-line);\n border-radius: 50%;\n display: grid;\n place-items: center;\n background: var(--deictic-bg);\n}\n.lb-prev svg, .lb-next svg { width: 20px; height: 20px; }\n.lb-prev { left: 16px; }\n.lb-next { right: 16px; }\n.lightbox.pinned { position: relative; inset: auto; z-index: auto; display: block; padding: 0 64px; }\n.lightbox.pinned .lb-stage { max-width: 100%; max-height: none; }\n.lightbox.pinned .lb-page { width: 100%; height: 420px; }\n.lightbox.pinned .lb-image { max-width: 100%; max-height: 420px; }\n.lightbox.pinned .lb-backdrop { display: none; }\n.lightbox.pinned .lb-audio { width: 100%; box-sizing: border-box; }\n.lightbox.pinned .lb-close { display: none; }\n.tip {\n position: fixed;\n left: 0;\n top: 0;\n z-index: 2147483647;\n max-width: 280px;\n padding: 3px 6px;\n border: 1px solid var(--deictic-line);\n border-radius: 4px;\n font: 12px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n background: #09090b;\n box-shadow: 0 4px 12px rgb(0 0 0 / 0.3);\n pointer-events: none;\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.12s;\n}\n.tip.shown { visibility: visible; opacity: 1; }\n/* A control's keys, after its name: caps, as on a keyboard. */\n.tip kbd {\n display: inline-block;\n box-sizing: border-box;\n min-width: 18px;\n margin-left: 3px;\n padding: 0 4px;\n border: 1px solid var(--deictic-line);\n border-bottom-width: 2px;\n border-radius: 4px;\n font: 11px/15px ui-monospace, monospace;\n text-align: center;\n color: var(--deictic-fg);\n background: rgb(255 255 255 / 0.08);\n}\n.tip kbd:first-of-type { margin-left: 6px; }\n.tip kbd:first-child { margin-left: 0; }\nbutton {\n font: inherit;\n color: inherit;\n background: transparent;\n border: 1px solid var(--deictic-line);\n border-radius: 4px;\n padding: 1px 7px;\n cursor: pointer;\n}\nbutton:hover { border-color: var(--deictic-muted); }\nbutton:disabled { opacity: 0.5; cursor: default; }\nbutton:disabled:hover { border-color: var(--deictic-line); }\n/* One ring for whatever the keyboard lands on, in place of each browser's own. */\nbutton:focus-visible, a:focus-visible { outline: 1px solid var(--deictic-accent); outline-offset: 1px; }\nbutton.icon {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 22px;\n height: 22px;\n padding: 0;\n border: 0;\n color: var(--deictic-muted);\n}\nbutton.icon svg { width: 14px; height: 14px; }\nbutton.icon:hover:not(:disabled) { color: var(--deictic-fg); background: rgb(255 255 255 / 0.08); }\nbutton.primary {\n background: var(--deictic-accent);\n border-color: var(--deictic-accent);\n color: var(--deictic-on-accent);\n box-shadow: 0 4px 16px -4px rgb(18 179 88 / 0.6);\n}\ninput, textarea {\n box-sizing: border-box;\n width: 100%;\n font: 12px ui-monospace, monospace;\n color: inherit;\n background: rgb(0 0 0 / 0.35);\n border: 1px solid var(--deictic-line);\n border-radius: 6px;\n padding: 4px 6px;\n}\ninput:focus, textarea:focus { outline: 1px solid var(--deictic-accent); }\ncode { font: 12px ui-monospace, monospace; }\n/* Border-box, as the popup holds the body's height by its whole box while a tab reads. */\n.body { box-sizing: border-box; padding: 12px; overflow: auto; }\n.status { padding: 0 12px 10px; font-size: 12px; color: var(--deictic-muted); }\n.status:empty { display: none; }\n.status.problem { color: var(--deictic-problem); }\n`;\n","/**\n * The tool panel: a bar of the plugins' tools, docked to an edge of the window, that its grip drags to any other.\n * It shows while a shortcut's keys are held, as the page dims to point on, and stays for as long as it's in use: a\n * tool has the page (`hold`), something goes on that its controls end (`keep`, a recording), or the pointer is on it.\n *\n * A plugin adds its controls as a group (`add`), each a button named by its `title`, with its key in\n * `aria-keyshortcuts`: the panel hears the keys, so a tool's key is its button's click. One tool has the page at a\n * time. The pointer, the panel's own, is none of them: the page is the page's.\n */\nimport type { Spot, ToolPanel } from '#src/index.ts';\n\nimport { controlFor, div } from './dom.ts';\n\ntype Edge = 'top' | 'bottom' | 'left' | 'right';\n/** Where the bar is: the edge it's docked to, and how far along it, from 0 to 1. */\ninterface Dock {\n edge: Edge;\n along: number;\n}\n\nconst DOCK = 'deictic:tools';\nconst MARGIN = 12;\n/** How long the panel outlasts the keys, in milliseconds: time to get the pointer to it. */\nconst LINGER = 600;\n\nconst svg = (paths: string) =>\n `<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">${paths}</svg>`;\nconst GRIP = svg(\n '<circle cx=\"9\" cy=\"6\" r=\"1\"/><circle cx=\"15\" cy=\"6\" r=\"1\"/><circle cx=\"9\" cy=\"12\" r=\"1\"/><circle cx=\"15\" cy=\"12\" r=\"1\"/><circle cx=\"9\" cy=\"18\" r=\"1\"/><circle cx=\"15\" cy=\"18\" r=\"1\"/>',\n);\nconst POINTER = svg('<path d=\"M5 3l14 7-6 2-2 6z\"/>');\n\nfunction storedDock(): Dock {\n try {\n const dock = JSON.parse(localStorage.getItem(DOCK) ?? 'null') as Dock | null;\n if (dock !== null && ['top', 'bottom', 'left', 'right'].includes(dock.edge) && dock.along >= 0 && dock.along <= 1) return dock;\n } catch {\n // Storage can be off, or hold something else: the default, then.\n }\n return { edge: 'bottom', along: 0.5 };\n}\n\n/** Puts the bar on its edge, laid out along it, and how far along. */\nfunction place(bar: HTMLElement, { edge, along }: Dock): void {\n const vertical = edge === 'left' || edge === 'right';\n bar.classList.toggle('vertical', vertical);\n // Said too, for whatever reads it: the overlay's tooltip puts a tip beside a tool of a bar that runs down.\n bar.setAttribute('aria-orientation', vertical ? 'vertical' : 'horizontal');\n const { width, height } = bar.getBoundingClientRect();\n const across = (room: number, size: number) => `${MARGIN + along * Math.max(0, room - size - MARGIN * 2)}px`;\n Object.assign(bar.style, {\n left: edge === 'left' ? `${MARGIN}px` : edge === 'right' ? `${innerWidth - width - MARGIN}px` : across(innerWidth, width),\n top: edge === 'top' ? `${MARGIN}px` : edge === 'bottom' ? `${innerHeight - height - MARGIN}px` : across(innerHeight, height),\n });\n}\n\n/** Dragging the bar by its grip, freely; let go, it docks to the nearest edge. */\nfunction draggable(bar: HTMLElement, grip: HTMLElement, docked: (dock: Dock) => void): void {\n grip.addEventListener('pointerdown', (e) => {\n if (e.button !== 0) return;\n e.preventDefault();\n grip.setPointerCapture(e.pointerId);\n const start = bar.getBoundingClientRect();\n const dx = e.clientX - start.left;\n const dy = e.clientY - start.top;\n const move = (m: PointerEvent) => {\n bar.style.left = `${m.clientX - dx}px`;\n bar.style.top = `${m.clientY - dy}px`;\n };\n const up = () => {\n grip.removeEventListener('pointermove', move);\n const r = bar.getBoundingClientRect();\n const x = r.left + r.width / 2;\n const y = r.top + r.height / 2;\n const away: [Edge, number][] = [\n ['left', x],\n ['right', innerWidth - x],\n ['top', y],\n ['bottom', innerHeight - y],\n ];\n const [edge] = away.reduce((a, b) => (b[1] < a[1] ? b : a));\n const ratio = (at: number, room: number) => Math.min(1, Math.max(0, at / room));\n docked({ edge, along: edge === 'left' || edge === 'right' ? ratio(y, innerHeight) : ratio(x, innerWidth) });\n };\n grip.addEventListener('pointermove', move);\n grip.addEventListener('pointerup', up, { once: true });\n });\n}\n\nexport interface Tools extends ToolPanel {\n /** Whether a shortcut's keys are held: the panel shows while they are. */\n point: (on: boolean) => void;\n /** The edge of the window it's docked to. */\n edge: () => Edge;\n}\n\nexport interface ToolsOptions {\n /** The marked element at a point of the window, or the nearest to it, and where the point is in it. */\n spotAt: (x: number, y: number) => Spot | undefined;\n /** Whether a point of the page is being picked: what's under the pointer is lit meanwhile, as pointing lights it. */\n aim: (on: boolean) => void;\n}\n\nexport function toolPanel(root: ShadowRoot, { spotAt, aim }: ToolsOptions): Tools {\n const bar = div('tool-panel');\n bar.setAttribute('role', 'toolbar');\n bar.setAttribute('aria-label', 'deictic tools');\n const grip = Object.assign(document.createElement('span'), { className: 'grip', title: 'Drag to any edge', innerHTML: GRIP });\n const pointer = Object.assign(document.createElement('button'), {\n type: 'button',\n className: 'icon',\n title: 'Pointer',\n innerHTML: POINTER,\n });\n pointer.setAttribute('aria-label', 'Pointer');\n pointer.setAttribute('aria-keyshortcuts', 'V');\n bar.append(grip, pointer);\n // Each plugin's group as it was added: where each goes is worked out from all of them (`order`), as a later one\n // may belong before an earlier one.\n const added: { group: HTMLElement; section?: string; last: boolean }[] = [];\n /**\n * The groups in their places: those of no section, then each section (in the order its first group came, its groups\n * side by side), then those of none that asked to be `last`. Within a section, its `last` ones are at its end. A\n * line between each.\n */\n const order = () => {\n const plain = added.filter((a) => a.section === undefined);\n const sections = [...new Set(added.flatMap((a) => a.section ?? []))].map((name) => {\n const of = added.filter((a) => a.section === name);\n // Named on each, for a plugin's styles to tell its section's other groups by (a recording hides them).\n for (const a of of) a.group.dataset.section = name;\n return [...of.filter((a) => !a.last), ...of.filter((a) => a.last)].map((a) => a.group);\n });\n const blocks = [\n ...plain.filter((a) => !a.last).map((a) => [a.group]),\n ...sections,\n ...plain.filter((a) => a.last).map((a) => [a.group]),\n ];\n for (const sep of bar.querySelectorAll(':scope > .sep')) sep.remove();\n for (const block of blocks) bar.append(Object.assign(document.createElement('span'), { className: 'sep' }), ...block);\n };\n root.append(bar);\n\n let dock = storedDock();\n const replace = () => place(bar, dock);\n addEventListener('resize', replace);\n draggable(bar, grip, (next) => {\n dock = next;\n replace();\n try {\n localStorage.setItem(DOCK, JSON.stringify(dock));\n } catch {\n // Not kept, then: the next page has it at the bottom.\n }\n });\n\n let pointing = false;\n let over = false;\n let keeps = 0;\n // The tool that has the page, as what makes it let go.\n let holder: (() => void) | undefined;\n let leaving: ReturnType<typeof setTimeout> | undefined;\n const shown = () => bar.classList.contains('shown');\n const show = () => {\n clearTimeout(leaving);\n leaving = undefined;\n pointer.setAttribute('aria-pressed', String(holder === undefined));\n const on = pointing || over || keeps > 0 || holder !== undefined;\n if (on === shown()) return;\n if (!on) {\n // Not at once: the keys are let go on the way to it.\n leaving = setTimeout(() => bar.classList.remove('shown'), LINGER);\n return;\n }\n bar.classList.add('shown');\n // Its groups may have changed size since it was last shown.\n replace();\n };\n bar.addEventListener('pointerenter', () => {\n over = true;\n show();\n });\n bar.addEventListener('pointerleave', () => {\n over = false;\n show();\n });\n // Laid out again as its groups change: a recording's controls come and go.\n new ResizeObserver(() => shown() && replace()).observe(bar);\n\n const letGo = () => {\n const left = holder;\n holder = undefined;\n left?.();\n show();\n };\n pointer.addEventListener('click', letGo);\n\n window.addEventListener(\n 'keydown',\n (e) => {\n if (e.repeat || !(pointing || holder !== undefined)) return;\n // A modal of ours has the keys while it's there: a note being typed, a picture drawn on, the lightbox.\n if (root.querySelector('[data-deictic-modal]') !== null) return;\n const [target] = e.composedPath();\n const typing = target instanceof HTMLElement && target.matches('input, textarea, select, [contenteditable]');\n // Esc is the tool's before the popup's, from the popup's field too (a task being typed while marks are drawn).\n if (e.key === 'Escape' && holder !== undefined) {\n e.preventDefault();\n e.stopImmediatePropagation();\n return letGo();\n }\n // What's typed in a field of ours is the field's (a note, a task's words). A field of the page's has its keys\n // too while they're only held to point: Alt with a letter types one there. Once a tool has the page, the page\n // isn't in use, and a field of its that still has the focus gets none.\n if (typing && (holder === undefined || target.getRootNode() === root)) return;\n // While the keys are held to point, a key alone is its tool whatever is held with it.\n const control = controlFor(bar, e, pointing);\n if (control === undefined) return;\n e.preventDefault();\n e.stopImmediatePropagation();\n control.click();\n },\n true,\n );\n\n const hold: ToolPanel['hold'] = (left) => {\n letGo();\n holder = left;\n show();\n return () => {\n if (holder !== left) return;\n holder = undefined;\n show();\n };\n };\n\n return {\n add: (group, options) => {\n added.push({ group, ...(options?.section === undefined ? {} : { section: options.section }), last: options?.last === true });\n order();\n },\n hold,\n keep: () => {\n keeps++;\n show();\n let kept = true;\n return () => {\n if (!kept) return;\n kept = false;\n keeps--;\n show();\n };\n },\n pick: () =>\n new Promise((done) => {\n // Over the page and under the popup and the panel: it takes the pointer, so the press is no click on the page.\n const surface = div('tool-surface');\n root.append(surface);\n const end = (spot: Spot | undefined) => {\n surface.remove();\n aim(false);\n done(spot);\n };\n const release = hold(() => end(undefined));\n aim(true);\n surface.addEventListener('pointerdown', (e) => {\n if (e.button !== 0) return;\n e.preventDefault();\n release();\n end(spotAt(e.clientX, e.clientY));\n });\n }),\n point: (on) => {\n pointing = on;\n show();\n },\n edge: () => dock.edge,\n };\n}\n","/**\n * One tooltip for everything deictic draws in a shadow root: whatever has a `title` (or `data-tip`) shows it\n * in a box of ours, soon after the pointer rests or focus lands, instead of the browser's, which comes late\n * and looks like nothing else here. Plugins only set `title`, as they would anywhere; the first hover moves\n * it to `data-tip`, so the browser's own stays away, and gives a textless control the title as its name.\n * The box is fixed in the root, so no panel's scrolling clips it.\n *\n * A control's keys (`aria-keyshortcuts`, as `Control+Z`) are in its tip too, each a keycap after the words, and a\n * tip of their own for a control whose text already names it.\n */\nconst DELAY = 300;\nconst KEYS = 'aria-keyshortcuts';\n/** A key as its cap reads, where that isn't its name. */\nconst CAPS: Record<string, string> = { Control: 'Ctrl', Meta: '⌘', Escape: 'Esc', Backspace: '⌫', Enter: '↵' };\n\n/** The first of a control's shortcuts, a cap for each key held together. */\nfunction capsOf(el: Element): HTMLElement[] {\n const [first = ''] = (el.getAttribute(KEYS) ?? '').split(' ');\n return first === '' ? [] : first.split('+').map((key) => Object.assign(document.createElement('kbd'), { textContent: CAPS[key] ?? key }));\n}\n\nexport function tooltips(root: ShadowRoot): void {\n const tip = document.createElement('div');\n tip.className = 'tip';\n tip.setAttribute('role', 'tooltip');\n root.append(tip);\n let timer = 0;\n let over: Element | undefined;\n\n const hide = () => {\n clearTimeout(timer);\n over = undefined;\n tip.classList.remove('shown');\n };\n const show = (el: Element) => {\n const text = el.getAttribute('data-tip') ?? '';\n const caps = capsOf(el);\n if ((text === '' && caps.length === 0) || !el.isConnected) return hide();\n tip.replaceChildren(text, ...caps);\n // Last in the root, over a modal or toolbar added since at the same z-index.\n if (tip !== root.lastElementChild) root.append(tip);\n tip.classList.add('shown');\n const r = el.getBoundingClientRect();\n const t = tip.getBoundingClientRect();\n // Beside it in a toolbar that runs down the window's side: below would be over the next tool.\n if (el.closest('[aria-orientation=\"vertical\"]') !== null) {\n const left = r.right + 6 + t.width > innerWidth - 8 ? r.left - 6 - t.width : r.right + 6;\n const top = Math.max(8, Math.min(r.top + r.height / 2 - t.height / 2, innerHeight - t.height - 8));\n Object.assign(tip.style, { left: `${left}px`, top: `${top}px` });\n return;\n }\n // Centred below it, kept on screen; above it where there's no room below.\n const left = Math.max(8, Math.min(r.left + r.width / 2 - t.width / 2, innerWidth - t.width - 8));\n const top = r.bottom + 6 + t.height > innerHeight - 8 ? r.top - 6 - t.height : r.bottom + 6;\n Object.assign(tip.style, { left: `${left}px`, top: `${top}px` });\n };\n /** The element with a tip around where the event happened, its `title` taken over the first time. */\n const tipped = (e: Event) => {\n for (const node of e.composedPath()) {\n if (!(node instanceof Element)) continue;\n if (node === tip) return undefined;\n // A frame's title is its name for assistive tech, not a tip; what's in it has tips of its own.\n if (node.localName === 'iframe') return undefined;\n const title = node.getAttribute('title');\n if (title !== null) {\n node.removeAttribute('title');\n if (title === '') continue;\n node.setAttribute('data-tip', title);\n // A control with no text of its own (an icon, ×, ↶) is known by its tip; one with text keeps its name.\n if (!node.hasAttribute('aria-label') && (node.textContent ?? '').trim().length <= 1) node.setAttribute('aria-label', title);\n else node.setAttribute('aria-description', title);\n }\n if (node.hasAttribute('data-tip') || node.hasAttribute(KEYS)) return node;\n }\n return undefined;\n };\n const enter = (e: Event) => {\n const el = tipped(e);\n if (el === over) return;\n hide();\n if (el === undefined) return;\n over = el;\n timer = window.setTimeout(() => show(el), e.type === 'focusin' ? 0 : DELAY);\n };\n root.addEventListener('pointerover', enter);\n root.addEventListener('focusin', (e) => {\n // Focus from the keyboard only: a click focuses too, and its tip is the pointer's.\n if ((e.target as Element).matches(':focus-visible')) enter(e);\n });\n root.addEventListener('pointerout', (e) => {\n const to = (e as PointerEvent).relatedTarget;\n if (over !== undefined && !(to instanceof Node && over.contains(to))) hide();\n });\n root.addEventListener('focusout', hide);\n // A press acts, and what it changes (a mic turned on) may change the tip: the next hover shows the new one.\n root.addEventListener('pointerdown', hide);\n addEventListener('scroll', hide, { capture: true, passive: true });\n}\n","/**\n * The tray: what plugins made on the page that nothing has taken yet (a shot, a recording, a voice clip), for\n * whatever takes it next, as a task does. Kept in the tab's session storage, as JSON, so it's still there on the\n * tab's next page: a recording that carried on to it ends there, and what was taken before it is with it.\n */\nimport type { Tray, TrayItem } from '#src/index.ts';\n\nconst KEY = 'deictic:tray';\n\nfunction stored(): TrayItem[] {\n try {\n const kept: unknown = JSON.parse(sessionStorage.getItem(KEY) ?? '[]');\n return Array.isArray(kept) ? (kept as TrayItem[]) : [];\n } catch {\n // Storage can be off, or hold something else: an empty tray, then.\n return [];\n }\n}\n\nexport function tray(): Tray {\n let items = stored();\n const listeners = new Set<() => void>();\n const changed = () => {\n try {\n sessionStorage.setItem(KEY, JSON.stringify(items));\n } catch {\n // Not kept past this page, then.\n }\n for (const listener of listeners) listener();\n };\n return {\n list: (plugin) => items.filter((item) => plugin === undefined || item.plugin === plugin),\n add: (plugin, id, value) => {\n items = [...items.filter((item) => item.plugin !== plugin || item.id !== id), { plugin, id, value }];\n changed();\n },\n remove: (plugin, id) => {\n const left = items.filter((item) => item.plugin !== plugin || (id !== undefined && item.id !== id));\n if (left.length === items.length) return;\n items = left;\n changed();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n","/**\n * `deictic/client`: the overlay the page loads in dev. Hold a shortcut's keys (Alt, deictic's own,\n * by default) and point: the page dims around the element under the pointer that the source marked\n * (`tools/locate.ts`), which stays lit, with its tag, its place and how many elements share it (`lighting.ts`).\n * Press the shortcut's button to open the popup beside it: a tab for each plugin with a panel, at the one used\n * last, or at a plugin's own where its shortcut was pressed.\n *\n * Everything drawn sits in one shadow root, so neither the page's styles nor ours cross over. A\n * panel's undo and redo are its tab's on its element: the latest change that plugin made there.\n */\nimport type {\n ClientContext,\n ClientPlugin,\n LightboxItem,\n PanelContext,\n Point,\n Problem,\n Resumed,\n Spot,\n Standalone,\n Target,\n} from '#src/index.ts';\nimport { gestureOf, type Shortcut } from '#src/shortcut.ts';\n\nimport { dropAway, keepAway, keptAway } from './away.ts';\nimport { named, tell } from './component.ts';\nimport { ATTRIBUTE, div, nameOf, POPUP_CLOSED, POPUP_OPENED, type PopupOpened, reduced, sameAs, targetOf } from './dom.ts';\nimport { drawerIn } from './drawer.ts';\nimport { openLightbox } from './lightbox.ts';\nimport { CLEAR, type Lighting, spotlight, spotOf } from './lighting.ts';\nimport { STYLE } from './style.ts';\nimport { toolPanel } from './tools.ts';\nimport { tooltips } from './tooltip.ts';\nimport { tray } from './tray.ts';\n\n// For a plugin's page half that records the mic, or shows a clip: the waveforms the lightbox draws.\nexport { drawBars, liveWaveform, peaksOf, type Colors } from './waveform.ts';\nexport { targetOf } from './dom.ts';\n\nexport interface StartOptions {\n /** The dev server's base URL, ending in `/`. */\n base: string;\n /** deictic's own shortcut, checked: it opens the popup at the tab used last. None where it's turned off. */\n shortcut?: Required<Shortcut>;\n /** Each plugin with a half in the page, and its own shortcut as the bundler's plugin checked it, where it has one. */\n plugins: { plugin: ClientPlugin; shortcut?: Required<Shortcut>; options?: unknown }[];\n /** What answers the requests where there's no dev server to: a `standalone` build's. */\n server?: Standalone;\n}\n\n/** A request to the endpoints, by its URL: to the dev server, or to what stands in for it. */\ntype Send = (url: string, init?: RequestInit) => Promise<Response>;\n\ntype Mount = (panel: HTMLElement, context: PanelContext<unknown, unknown>) => (() => void) | void;\n\n/** A plugin with a panel: a tab in the popup. */\ninterface Tab {\n plugin: ClientPlugin;\n mount: Mount;\n}\n\n/** An arrow pointing up and out: the link leaves the page for the editor. */\nconst OUT = icon('M7 17 17 7M8 7h9v9', 2.25);\n// Drawn, as the arrows and the cross of a system's font differ in size and weight from one to the next.\nconst UNDO = icon('M9 14 4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11');\nconst REDO = icon('m15 14 5-5-5-5M20 9H9.5a5.5 5.5 0 0 0 0 11H13');\nconst CLOSE = icon('M18 6 6 18M6 6l12 12');\n/** Where the tab used last is kept, for deictic's own shortcut to open it again. */\nconst LAST = 'deictic:tab';\n/** How long a read may take, in milliseconds, before the popup says it's reading. */\nconst SLOW = 200;\nconst STARTED = Symbol.for('deictic');\n\n/** The nearest marked element around `el`, out through shadow roots to their hosts. */\nfunction markedAround(el: Element): Element | undefined {\n for (let at: Element | undefined = el; at !== undefined;) {\n const marked = at.closest(`[${ATTRIBUTE}]`);\n if (marked !== null) return marked;\n const root = at.getRootNode();\n at = root instanceof ShadowRoot ? root.host : undefined;\n }\n return undefined;\n}\n\nfunction icon(path: string, width = 2): string {\n return `<svg viewBox=\"0 0 24 24\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"${width}\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"${path}\"/></svg>`;\n}\n\n/** What the overlay keeps once started, for `popupIn` to show the popup with. */\ninterface Started {\n base: string;\n send: Send;\n contextOf: (name: string) => ClientContext;\n tabs: Tab[];\n /** Opens the popup over the page on an element, at a tab or the one used last: `openPopup`. */\n open: (element: Element, tab?: string) => boolean;\n}\n\nlet started: Started | undefined;\n\n// The events the page hears as the popup opens and closes: kept beside the mark, where a plugin's page half reads them.\nexport { POPUP_CLOSED, POPUP_OPENED, type PopupOpened } from './dom.ts';\n\n/**\n * Opens the popup over the page on `element`, as deictic's own shortcut does: at `tab` (a plugin's name), or at the\n * tab used last. For a page that opens it from a gesture of its own, as deictic's site does on a plain click.\n * Answers whether it opened: not where no plugin has a tab, or `element` has no mark. The overlay must have started.\n */\nexport function openPopup(element: Element, { tab }: { tab?: string } = {}): boolean {\n if (started === undefined) throw new Error('deictic: the overlay has not started, so there is no popup to open');\n return started.open(element, tab);\n}\n\n/**\n * Shows the popup in `container`, open at a tab (`tab`, a plugin's name, or the first) on `element`, where\n * the page puts it rather than over the page: a page of the popup's states, to point at and fix, as deictic's\n * own site does. It's the real popup, its tabs and plugins working. Closing it, or a tab's `away`, opens it\n * again in place. It draws in `container`'s shadow root, made if there isn't one. Answers what removes it.\n * The overlay must have started (the dev server's client module starts it), and `element` be marked.\n */\nexport function popupIn(container: Element, { tab: name, element }: { tab?: string; element: Element }): () => void {\n if (started === undefined) throw new Error('deictic: the overlay has not started, so there is no popup to show');\n const target = targetOf(element);\n if (target === undefined) throw new Error(`deictic: ${nameOf(element)} has no ${ATTRIBUTE} mark to open the popup on`);\n const { base, send, contextOf, tabs } = started;\n // A tab shown here isn't one a person chose: the popup over the page keeps opening at theirs.\n const remember = () => {};\n const tab = tabs.find((t) => t.plugin.name === name) ?? tabs[0];\n if (tab === undefined) throw new Error('deictic: no plugin has a tab to show');\n const root = container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = `${STYLE}:host { display: block; }`;\n root.replaceChildren(style);\n tooltips(root);\n let panel: { close: () => void } | undefined;\n let gone = false;\n const open = (at: Tab, resumed?: Resumed) => {\n panel = openPanel({\n base,\n send,\n root,\n contextOf,\n tabs,\n tab: at,\n remember,\n element,\n target,\n onClose: (shown, leaving) => {\n panel = undefined;\n // Closed by its own × or Esc: open again, as the page is there to show it. Leaving for `away` comes back by `reopen`.\n if (!gone && !leaving) open(shown);\n },\n ...(resumed === undefined ? {} : { resumed }),\n reopen: (again, _, kept) => open(again, kept),\n });\n };\n open(tab);\n return () => {\n gone = true;\n panel?.close();\n style.remove();\n };\n}\n\n/**\n * Shows the lightbox in `container`, at `at`, where the page puts it rather than over everything: as `popupIn`\n * does the popup, for a page of deictic's own states. Its items step with its arrows; there's no backdrop, close\n * or keys, and an item's actions run without closing it. Answers what removes it.\n */\nexport function lightboxIn(container: Element, items: LightboxItem[], { at }: { at?: number } = {}): () => void {\n const root = container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = `${STYLE}:host { display: block; }`;\n root.replaceChildren(style);\n tooltips(root);\n const { close } = openLightbox(root, items, { ...(at === undefined ? {} : { at }), pinned: true });\n return () => {\n close();\n style.remove();\n };\n}\n\n/** Starts the overlay, once per page: the client module runs again when a module importing it is replaced. */\nexport function start({ base, shortcut: own, plugins: given, server }: StartOptions): void {\n const page = globalThis as { [STARTED]?: true };\n if (page[STARTED] === true) return;\n page[STARTED] = true;\n\n const host = document.createElement('deictic-overlay');\n const root = host.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = STYLE;\n root.append(style);\n tooltips(root);\n const lighting = spotlight(root);\n const kept = tray();\n // A tool has the page to pick a point on (`pick`): what's under the pointer is lit as while the keys are held.\n let picking = false;\n const tools = toolPanel(root, {\n spotAt: (x, y) => spotAt(x, y),\n aim: (on) => {\n picking = on;\n if (on) glance(true);\n else if (held.length === 0) hide();\n },\n });\n // Out from under the tool panel, where that's on the window's right.\n const drawer = drawerIn(root, { crowded: () => tools.edge() === 'right' });\n // What's typed in the popup is the popup's: the page hears a key from in here as one on the host, not in a field,\n // so its own shortcuts (a \"/\" to search, a \"j\" to step) would run on a task's words. Ours listen while capturing.\n for (const type of ['keydown', 'keypress', 'keyup'] as const) host.addEventListener(type, (e) => e.stopPropagation());\n document.documentElement.append(host);\n\n // Each plugin's API, set up before any panel opens. `use` reads it when asked, so a setup may keep\n // `use` for later, not call it: the plugin it asks for may not be set up yet.\n const apis = new Map<string, unknown>();\n const send: Send =\n server === undefined ? (url, init) => fetch(url, init) : async (url, init) => server(new Request(new URL(url, location.href), init));\n // To the dev server, which says it and hands it on (to the board, with tasks). Whether it got there is no one's to\n // know in the page: it's said in the console too.\n const report = (problem: Problem) => {\n console.error(`deictic${problem.plugin === undefined ? '' : `/${problem.plugin}`}: ${problem.message}`);\n const init = { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(problem) };\n send(`${base}__deictic/problem`, init).catch(() => {});\n };\n const optionsOf = new Map(given.map(({ plugin, options }) => [plugin.name, options]));\n const contextOf = (name: string): ClientContext => ({\n base,\n root,\n options: optionsOf.get(name),\n use: (other) => apis.get(other) as never,\n request: (route, init) => send(`${base}__deictic/plugins/${name}/${route}`, init),\n report: (problem) => report({ ...problem, plugin: name }),\n edit: async ({ file, line, column }) => {\n const res = await send(`${base}__deictic/open?${new URLSearchParams({ file, line: String(line), column: String(column) })}`);\n if (!res.ok) throw new Error(await res.text());\n },\n // Not from under something unsaved, which a press on the page wouldn't close either: its button shakes.\n open: (plugin, element, at) => panel?.guard() !== true && openAt(plugin, element, at),\n lightbox: (items, options) => openLightbox(root, items, options),\n drawer,\n light: (element) => {\n lit = element?.isConnected === true ? element : undefined;\n relight();\n },\n tools,\n tray: kept,\n });\n for (const { plugin } of given) {\n if (plugin.setup === undefined) continue;\n try {\n apis.set(plugin.name, plugin.setup(contextOf(plugin.name)));\n } catch (e) {\n // One plugin's failure is no reason to take the others down with it.\n report(failed(plugin.name, 'set up in the page, so it does nothing there until the page loads again', e));\n }\n }\n const tabs: Tab[] = given.flatMap(({ plugin }) => (plugin.mount === undefined ? [] : [{ plugin, mount: plugin.mount }]));\n started = {\n base,\n send,\n contextOf,\n tabs,\n // Not over a popup holding something unsaved: the press that asked shook its button (`openPanel`).\n open: (element, tab) => tabs.length > 0 && panel?.unsaved() !== true && openAt(tab ?? last().plugin.name, element),\n };\n const last = () => {\n let name: string | null = null;\n try {\n name = localStorage.getItem(LAST);\n } catch {\n // Storage can be off: the first tab, then.\n }\n return tabs.find((t) => t.plugin.name === name) ?? tabs[0]!;\n };\n const remember = (tab: Tab) => {\n try {\n localStorage.setItem(LAST, tab.plugin.name);\n } catch {\n // Not kept, then: the next open starts at the first tab.\n }\n };\n // What opens the popup, and at which tab: deictic's own shortcut at the one used last, each\n // plugin's at its own.\n const plugins = [\n ...(own === undefined || tabs.length === 0 ? [] : [{ shortcut: own, gesture: gestureOf(own), tab: last, named: false }]),\n ...given.flatMap(({ plugin, shortcut }) => {\n if (shortcut === undefined) return [];\n const tab = tabs.find((t) => t.plugin === plugin);\n if (tab !== undefined) return [{ shortcut, gesture: gestureOf(shortcut), tab: () => tab, named: true }];\n console.error(`deictic: ${plugin.name} has a shortcut, but its page half has no \\`mount\\` to draw a tab with`);\n return [];\n }),\n ];\n\n let pointer: { x: number; y: number } | undefined;\n let frame = 0;\n let panel: ReturnType<typeof openPanel> | undefined;\n\n /** The plugins whose keys are held: several, where they share keys and differ by button. */\n const heldBy = (e: MouseEvent | KeyboardEvent) => plugins.filter((p) => p.gesture.held(e));\n /** The plugin a press opens. */\n const pressedBy = (e: MouseEvent) => plugins.find((p) => p.gesture.held(e) && e.button === p.gesture.button);\n /**\n * The marked element at a point, and what's under the pointer inside it where that differs: down through\n * open shadow roots but the overlay's own, as a page showing the popup (`popupIn`) has it in one. `through` the\n * overlay, where it's the overlay that has the pointer: a tool's surface, while a point is picked.\n */\n const hitAt = (x: number, y: number, through = false) => {\n let under = (through ? document.elementsFromPoint(x, y).find((el) => el !== host) : document.elementFromPoint(x, y)) ?? undefined;\n while (under !== undefined && under !== host && under.shadowRoot !== null) {\n const inside = under.shadowRoot.elementFromPoint(x, y);\n if (inside === null || inside === under) break;\n under = inside;\n }\n const el = under === undefined || under === host ? undefined : markedAround(under);\n return el === undefined ? undefined : { el, pointed: under === el ? undefined : under };\n };\n // The plugins whose keys are held now, as the last event said: what's pointed at is shown while there are any.\n let held: typeof plugins = [];\n // What plugins show on the page while it's pointed on (`pointing`), each with what takes it away.\n let glanced: (() => void)[] | undefined;\n const glance = (on: boolean) => {\n if (on === (glanced !== undefined)) return;\n for (const end of glanced ?? []) end();\n glanced = !on\n ? undefined\n : given.flatMap(({ plugin }) => {\n try {\n return plugin.pointing === undefined ? [] : [plugin.pointing(contextOf(plugin.name))];\n } catch (e) {\n report(failed(plugin.name, 'show what it has on the page as it was pointed at', e));\n return [];\n }\n });\n };\n // An element a plugin lights from the overlay's own UI (`context.light`): lit while it says so, whatever the keys.\n let lit: Element | undefined;\n const relight = () => {\n const target = lit === undefined ? undefined : targetOf(lit);\n if (lit !== undefined && target !== undefined) return lighting.point({ el: lit, target, names: [], count: sameAs(lit).length });\n if (held.length > 0 || picking) return show(false);\n lighting.hide();\n };\n const hide = () => {\n held = [];\n tools.point(false);\n drawer.point(false);\n glance(false);\n relight();\n };\n /** The marked element at a point of the window, or the nearest to it where none is under it, and the point in it. */\n const spotAt = (x: number, y: number): Spot | undefined => {\n const away = (el: Element) => {\n const r = el.getBoundingClientRect();\n return r.width === 0 || r.height === 0\n ? Infinity\n : Math.hypot(Math.max(r.left - x, 0, x - r.right), Math.max(r.top - y, 0, y - r.bottom));\n };\n const nearest = () => {\n let found: { el: Element; far: number } | undefined;\n for (const el of document.querySelectorAll(`[${ATTRIBUTE}]`)) {\n const far = away(el);\n // The later of two as near is the inner one, or the one drawn over.\n if (far !== Infinity && (found === undefined || far <= found.far)) found = { el, far };\n }\n return found?.el;\n };\n const element = hitAt(x, y, true)?.el ?? nearest();\n if (element === undefined) return undefined;\n const r = element.getBoundingClientRect();\n return { element, at: { x: Math.round(x - r.left), y: Math.round(y - r.top) } };\n };\n const show = (glide: boolean) => {\n frame = 0;\n // On something of ours that takes the pointer (a task's pin, the tool panel): the light stays where it was, as\n // the pointer is on its way to a press there, not to another element.\n if (pointer !== undefined && !picking && held.length > 0 && document.elementFromPoint(pointer.x, pointer.y) === host) {\n if (lit !== undefined) relight();\n return;\n }\n const hit = pointer === undefined || (held.length === 0 && !picking) ? undefined : hitAt(pointer.x, pointer.y, picking);\n const el = hit?.el;\n const target = el === undefined ? undefined : targetOf(el);\n if (el === undefined || target === undefined) return lighting.hide();\n // A plugin's own shortcut says its tab, and its button where it isn't the left, which the keys alone don't tell\n // apart. deictic's own says nothing: it opens whichever tab was used last.\n const names = held.flatMap(({ tab, shortcut, named }) => {\n if (!named) return [];\n const { plugin } = tab();\n const name = plugin.label ?? plugin.name;\n return [shortcut.button === 'left' ? name : `${name} (${shortcut.button})`];\n });\n lighting.point({ el, ...(hit?.pointed === undefined ? {} : { pointed: hit.pointed }), target, names, count: sameAs(el).length }, glide);\n };\n const update = (e: MouseEvent | KeyboardEvent) => {\n held = heldBy(e);\n if (held.length === 0 && !picking) return hide();\n tools.point(held.length > 0);\n drawer.point(held.length > 0);\n glance(true);\n if (frame === 0) frame = requestAnimationFrame(() => show(true));\n };\n\n window.addEventListener(\n 'mousemove',\n (e) => {\n pointer = { x: e.clientX, y: e.clientY };\n update(e);\n },\n { capture: true, passive: true },\n );\n window.addEventListener('keydown', update, true);\n window.addEventListener('keyup', update, true);\n window.addEventListener('blur', hide);\n // The page scrolled under the pointer: another element is under it now, or the same one elsewhere.\n window.addEventListener(\n 'scroll',\n () => {\n if ((held.length > 0 || picking) && frame === 0) frame = requestAnimationFrame(() => show(false));\n },\n { capture: true, passive: true },\n );\n let press = {};\n let opened: object | undefined;\n // The page as it is under the press, for whoever keeps it (`pressed`): before the page's own handlers, which may\n // close what was open, and before the popup takes the pointer and the focus.\n window.addEventListener(\n 'pointerdown',\n (e) => {\n if (e.composedPath().includes(host) || pressedBy(e) === undefined) return;\n const hit = hitAt(e.clientX, e.clientY);\n if (hit === undefined) return;\n for (const { plugin } of given) {\n try {\n plugin.pressed?.(contextOf(plugin.name), hit.el);\n } catch (e) {\n report(failed(plugin.name, 'keep what the page showed as it was pressed', e));\n }\n }\n },\n true,\n );\n // Alt-click on a link would otherwise download it, and on a field focus it.\n window.addEventListener(\n 'mousedown',\n (e) => {\n press = {};\n if (e.composedPath().includes(host)) return;\n if (pressedBy(e) !== undefined && hitAt(e.clientX, e.clientY) !== undefined) e.preventDefault();\n },\n true,\n );\n // A press ends in `click`, `auxclick` or `contextmenu` by its button, and a right one in two of\n // them, in an order that varies by platform; on macOS Control-click is a left `contextmenu`. Each\n // is kept from the page, and the first opens the panel.\n const pressed = (e: MouseEvent) => {\n if (e.composedPath().includes(host)) return;\n const found = pressedBy(e);\n const hit = found === undefined ? undefined : hitAt(e.clientX, e.clientY);\n const target = hit === undefined ? undefined : targetOf(hit.el);\n if (found === undefined || hit === undefined || target === undefined) return;\n e.preventDefault();\n e.stopPropagation();\n if (opened === press) return;\n opened = press;\n // Still open after this press's pointerdown, outside it: it holds something unsaved, and shook its button.\n if (panel?.unsaved() === true) return;\n openTab(found.tab(), hit.el, target, undefined, hit.pointed);\n };\n const openTab = (tab: Tab, el: Element, target: Target, resumed?: Resumed, pointed?: Element, at?: Point) => {\n hide();\n panel?.close();\n panel = openPanel({\n base,\n send,\n root,\n contextOf,\n tabs,\n tab,\n remember,\n element: el,\n ...(pointed === undefined ? {} : { pointed }),\n ...(at === undefined ? {} : { at }),\n target,\n lighting,\n onClose: () => (panel = undefined),\n ...(resumed === undefined ? {} : { resumed }),\n reopen: (again, element, kept) => {\n // Rendered again while away, or gone from the page, which moved on: the popup comes back all the same, on\n // the element as it was left, since what it kept (a recording) is about it wherever the page is now.\n const found = element.isConnected ? element : (sameAs(element)[0] ?? element);\n openTab(\n again,\n found,\n targetOf(found) ?? target,\n kept,\n pointed?.isConnected === true && found === element ? pointed : undefined,\n at,\n );\n },\n });\n };\n // What the page before this left a panel for (`away`), where that carries on here: the popup comes back when\n // it's done, on the element where this page has it, and on a stand-in for it where it doesn't.\n void keptAway().then((away) => {\n if (away === undefined) return;\n const tab = tabs.find((t) => t.plugin.name === away.tab);\n const task = tab?.plugin.resume?.(contextOf(away.tab));\n if (tab === undefined || task === undefined) return dropAway();\n const back = (resumed: Resumed) => {\n dropAway();\n const { loc, tag } = away.target;\n const absent = document.createElement(tag);\n absent.setAttribute(ATTRIBUTE, `${loc.file}:${loc.line}:${loc.column}`);\n const found = sameAs(absent).find((el) => el.localName === tag);\n // The spot only where this page has the element: there's nowhere for it otherwise.\n openTab(tab, found ?? absent, away.target, resumed, undefined, found === undefined ? undefined : away.at);\n };\n task.then(\n (result) => back({ state: away.state, result }),\n (e: unknown) => back({ state: away.state, problem: messageOf(e) }),\n );\n });\n function openAt(name: string, given: Element, at?: Point): boolean {\n const tab = tabs.find((t) => t.plugin.name === name);\n const el = given.isConnected ? given : (sameAs(given)[0] ?? undefined);\n const target = el === undefined ? undefined : targetOf(el);\n if (tab === undefined || el === undefined || target === undefined) return false;\n openTab(tab, el, target, undefined, undefined, at);\n return true;\n }\n for (const type of ['click', 'auxclick', 'contextmenu'] as const) window.addEventListener(type, pressed, true);\n}\n\ninterface PanelOptions {\n base: string;\n send: Send;\n root: ShadowRoot;\n contextOf: (name: string) => ClientContext;\n tabs: Tab[];\n /** The tab it opens at. */\n tab: Tab;\n /** Keeps the tab shown, for deictic's own shortcut to open at next. */\n remember: (tab: Tab) => void;\n element: Element;\n /** What was under the pointer inside `element`, where that differs. */\n pointed?: Element;\n /** The spot in `element` it's opened on, where it's one: what's lit, and what it's beside. */\n at?: Point;\n target: Target;\n /**\n * Over the page, beside the element: what lights the element there. Without it the popup is shown where the\n * page put it (`popupIn`): nothing on the page is lit, and Esc leaves it alone.\n */\n lighting?: Lighting;\n /** Called as it closes: the tab it showed, and whether it's leaving for a tab's `away`, to come back by `reopen`. */\n onClose: (shown: Tab, leaving: boolean) => void;\n /** What the first tab's mount gets, coming back from `away`. */\n resumed?: Resumed;\n /** Opens the popup again, at a tab on an element, coming back from `away`. */\n reopen: (tab: Tab, element: Element, resumed: Resumed) => void;\n}\n\nfunction openPanel({\n base,\n send,\n root,\n contextOf,\n tabs,\n tab: first,\n remember,\n element,\n pointed,\n at: spot,\n target,\n lighting,\n onClose,\n resumed: coming,\n reopen,\n}: PanelOptions): {\n close: () => void;\n unsaved: () => boolean;\n /** Whether it holds something unsaved, whose button it then shakes: what asks before opening another over it. */\n guard: () => boolean;\n} {\n const pinned = lighting === undefined;\n // Given to the first tab's first mount only: another tab, or a remount after an undo, starts afresh.\n let resumed = coming;\n const panel = div('panel');\n // The tabs, then the element's place and undo and redo, which are the shown tab's on this element.\n const head = div('head');\n head.setAttribute('role', 'tablist');\n const bar = div('bar');\n const where = document.createElement('a');\n where.className = 'where';\n const file = document.createElement('span');\n file.textContent = `${target.loc.file}:${target.loc.line}`;\n // What it is too, as the caption said it while pointing, which is gone once the popup is open.\n const tag = Object.assign(document.createElement('span'), { className: 'tag', textContent: tell(named(element)) });\n // An arrow out, as it leaves the page for the editor; its title is the overlay's tooltip (`tooltip.ts`).\n where.append(tag, file);\n where.insertAdjacentHTML('beforeend', OUT);\n where.title = 'Open in editor';\n where.setAttribute('aria-label', `Open ${file.textContent} in the editor`);\n // The element's place, as a request's query names it.\n const at = { file: target.loc.file, line: String(target.loc.line), column: String(target.loc.column) };\n where.href = `${base}__deictic/open?${new URLSearchParams(at)}`;\n where.addEventListener('click', (e) => {\n e.preventDefault();\n void send(where.href);\n });\n // Off until the tab's history is read: there's nothing to take back on most elements.\n const undo = iconButton(UNDO, 'Undo', 'Nothing to undo');\n const redo = iconButton(REDO, 'Redo', 'Nothing to redo');\n undo.disabled = redo.disabled = true;\n const close = iconButton(CLOSE, 'Close', pinned ? 'Close' : 'Close (Esc)');\n const buttons = tabs.map((tab) => {\n const el = button(tab.plugin.label ?? tab.plugin.name, '');\n el.className = 'tab';\n el.setAttribute('role', 'tab');\n el.addEventListener('click', () => show(tab));\n return { tab, el };\n });\n // What marks the shown tab, behind it, and slides to the next one shown.\n const thumb = div('thumb');\n const slide = (to: HTMLElement) => {\n Object.assign(thumb.style, { left: `${to.offsetLeft}px`, width: `${to.offsetWidth}px` });\n // Laid out where it is before it may move: the first place is no slide from the head's corner.\n void thumb.offsetWidth;\n thumb.classList.add('moves');\n };\n close.classList.add('end');\n head.append(thumb, ...buttons.map((b) => b.el), close);\n bar.append(where, undo, redo);\n // Back from `away` on a page that doesn't have the element: said, as nothing on it is lit.\n if (!element.isConnected)\n where.after(Object.assign(document.createElement('span'), { className: 'absent', textContent: 'not on this page' }));\n const body = div('body');\n body.setAttribute('role', 'tabpanel');\n const status = div('status');\n panel.append(head, bar, body, status);\n root.append(panel);\n if (pinned) panel.classList.add('pinned');\n const release = pinned ? undefined : keepInView(panel, body, head, element, spot);\n // Its element, or the spot in it, lit for as long as it's open.\n const unmark = lighting?.hold(element, panel, spot);\n if (!pinned) window.dispatchEvent(new CustomEvent<PopupOpened>(POPUP_OPENED, { detail: { element, tab: first.plugin.name } }));\n\n let cleanup: (() => void) | void;\n // The button that keeps what the shown tab would lose, while there's something: `unsaved`, from the panel.\n let holding: HTMLElement | undefined;\n const say = (text: string, problem = false) => {\n status.textContent = text;\n status.classList.toggle('problem', problem);\n };\n const post = async <T>(route: string, body?: unknown): Promise<T> => {\n const res = await send(`${base}__deictic/${route}`, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body ?? {}),\n });\n const json = (await res.json()) as T & { problem?: string };\n if (!res.ok) throw new Error(json.problem ?? res.statusText);\n return json;\n };\n const unmount = () => {\n cleanup?.();\n cleanup = undefined;\n holding = undefined;\n body.replaceChildren();\n };\n // The change undone may be this tab's from before the panel opened: the panel reads its model again.\n const step = (route: 'undo' | 'redo') =>\n post<{ change: { label: string } }>(route, { plugin: current.plugin.name, target })\n .then(\n async ({ change }) => {\n await load();\n say(`${route === 'undo' ? 'Undid' : 'Redid'} ${change.label}`);\n },\n (e: unknown) => say(messageOf(e), true),\n )\n .finally(() => void steps());\n // Undo and redo as the tab's history on this element stands: off with nothing to take back or do again, else\n // saying what they would. Read as a tab shows, after each change made here, and as the pointer comes back, for a\n // change made elsewhere. One a later read overtook (another tab's) sets nothing.\n let asked = 0;\n const steps = async () => {\n const ask = ++asked;\n let history: { done: { label: string }[]; undone: { label: string }[] };\n try {\n const res = await send(`${base}__deictic/history?${new URLSearchParams({ plugin: current.plugin.name, ...at })}`);\n if (!res.ok || ask !== asked) return;\n history = (await res.json()) as typeof history;\n } catch {\n return;\n }\n const last = history.done.at(-1);\n const next = history.undone.at(-1);\n undo.disabled = last === undefined;\n undo.title = last === undefined ? 'Nothing to undo' : `Undo ${last.label}`;\n redo.disabled = next === undefined;\n redo.title = next === undefined ? 'Nothing to redo' : `Redo ${next.label}`;\n };\n panel.addEventListener('pointerenter', () => void steps());\n\n const done = (leaving = false) => {\n unmount();\n release?.();\n unmark?.();\n panel.remove();\n window.removeEventListener('keydown', onKey, true);\n window.removeEventListener('pointerdown', onOutside, true);\n if (!pinned) window.dispatchEvent(new CustomEvent(POPUP_CLOSED));\n onClose(current, leaving);\n };\n const onKey = (e: KeyboardEvent) => {\n // A plugin's modal over the popup (one marked `data-deictic-modal`) takes Esc for itself.\n if (e.key !== 'Escape' || root.querySelector('[data-deictic-modal]') !== null) return;\n // Esc is the popup's while it's open: a dialog of the page's that it's open in stays open.\n e.preventDefault();\n e.stopPropagation();\n done();\n };\n // A press on the page closes the popup, as it would a menu, unless that loses something: then the button that\n // keeps it shakes. Anything in the overlay is the popup's own: a modal, the lightbox, the surface marks are drawn on.\n const onOutside = (e: PointerEvent) => {\n if (e.composedPath().includes(root.host)) return;\n if (holding === undefined) return done();\n shake(holding);\n };\n if (!pinned) {\n window.addEventListener('keydown', onKey, true);\n window.addEventListener('pointerdown', onOutside, true);\n }\n undo.addEventListener('click', () => void step('undo'));\n redo.addEventListener('click', () => void step('redo'));\n close.addEventListener('click', () => done());\n\n let current = first;\n // A read that a later one overtook (another tab, or the same after an undo) mounts nothing.\n let reads = 0;\n const load = async () => {\n const { plugin, mount } = current;\n const read = ++reads;\n // The body keeps its height while it's empty, and \"Reading…\" waits for a read that takes long: one answered\n // at once, as most are, would otherwise fold the popup and open it again in a blink.\n body.style.minHeight = `${body.offsetHeight}px`;\n unmount();\n say('');\n const slow = setTimeout(() => read === reads && say('Reading…'), SLOW);\n let model: unknown;\n try {\n ({ model } = await post<{ model: unknown }>('read', { plugin: plugin.name, target }));\n } catch (e) {\n if (read !== reads) return;\n body.style.minHeight = '';\n say(messageOf(e), true);\n return;\n } finally {\n clearTimeout(slow);\n }\n if (read !== reads) return;\n body.style.minHeight = '';\n say('');\n const back = current === first ? resumed : undefined;\n resumed = undefined;\n try {\n cleanup = mount(body, {\n ...contextOf(plugin.name),\n ...(back === undefined ? {} : { resumed: back }),\n away: (state, task) => {\n const tab = current;\n done(true);\n // For the tab's next page too, should this one go before the task is done. Not one a page pinned: that's the page's own.\n if (!pinned) keepAway({ tab: tab.plugin.name, target, state, ...(spot === undefined ? {} : { at: spot }) });\n const back = (resumed: Resumed) => {\n if (!pinned) dropAway();\n reopen(tab, element, resumed);\n };\n void task().then(\n (result) => back({ state, result }),\n (e: unknown) => back({ state, problem: messageOf(e) }),\n );\n },\n element,\n ...(pointed === undefined ? {} : { pointed }),\n ...(spot === undefined ? {} : { at: spot }),\n elements: sameAs(element),\n target,\n model,\n apply: async (op, on = target) => {\n say('Writing…');\n try {\n const result = await post<{ model: unknown }>('apply', { plugin: plugin.name, target: on, op });\n say('');\n void steps();\n return result.model;\n } catch (e) {\n say(messageOf(e), true);\n throw e;\n }\n },\n close: () => done(),\n unsaved: (action) => {\n if (read === reads) holding = action;\n },\n });\n } catch (e) {\n say(messageOf(e), true);\n contextOf(plugin.name).report(failed(plugin.name, 'show its panel', e));\n }\n };\n const show = (tab: Tab) => {\n current = tab;\n for (const b of buttons) {\n b.el.setAttribute('aria-selected', String(b.tab === tab));\n if (b.tab === tab) slide(b.el);\n }\n remember(tab);\n void steps();\n void load();\n };\n show(first);\n const guard = () => {\n if (holding !== undefined) shake(holding);\n return holding !== undefined;\n };\n return { close: done, unsaved: () => holding !== undefined, guard };\n}\n\n/** Shakes a panel's button, in view: what a press outside does where closing would lose something. A blink where motion is reduced. */\nfunction shake(el: HTMLElement): void {\n el.scrollIntoView({ block: 'nearest' });\n if (reduced()) return void el.animate({ opacity: [1, 0.3, 1, 0.3, 1] }, 400);\n el.animate({ translate: ['0', '-5px', '5px', '-4px', '4px', '-2px', '0'] }, { duration: 360, easing: 'ease-out' });\n}\n\nconst MARGIN = 8;\n// Under this much room on either side, the panel overlaps the element rather than shrink to a sliver beside it.\nconst LEAST = 160;\n/** How far from the element the popup is, in pixels: room for the line between them. */\nconst APART = 32;\n\n/** How far a press on the head moves, in pixels, before it's a drag: a click there leaves the popup following. */\nconst SLACK = 3;\n\n/**\n * Keeps a panel beside `element` and inside the viewport, as its tabs fill it, the window resizes and the element\n * moves with the page: to its right, or its left, where there's the room, level with its top and as tall as the\n * window lets it be; else below, or above where it fits better, its height capped to the room there, so the body\n * scrolls rather than the panel leaving the window. Off the element either way (`APART`): it's what's lit, with\n * room for the line between them. Dragged by `handle`, it stays where it's put, in the window, and follows the\n * element no more. Fixed, so it never changes the page's own scrolling. Answers a release.\n */\nfunction keepInView(panel: HTMLElement, body: HTMLElement, handle: HTMLElement, element: Element, at?: Point): () => void {\n let frame = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n // What it's beside: the element, or the spot in it.\n const boxOf = () => (at === undefined ? element.getBoundingClientRect() : spotOf(element, at));\n // Where the element was last seen: one gone from the page leaves the popup where it was.\n let r = boxOf();\n // An element that's not on the page (back from `away`, on another) has no place to be beside: as if dragged to the\n // middle, toward the top.\n let moved: { left: number; top: number } | undefined = element.isConnected\n ? undefined\n : { left: (document.documentElement.clientWidth - panel.offsetWidth) / 2, top: document.documentElement.clientHeight / 5 };\n const fit = () => {\n cancelAnimationFrame(frame);\n clearTimeout(timer);\n frame = 0;\n timer = undefined;\n // The viewport without the page's scrollbars.\n const width = document.documentElement.clientWidth;\n const height = document.documentElement.clientHeight;\n // What the panel would take with no cap: its frame, and all of its body.\n const wanted = panel.offsetHeight - body.clientHeight + body.scrollHeight;\n if (moved !== undefined) {\n const room = Math.max(0, height - 2 * MARGIN);\n Object.assign(panel.style, {\n left: `${Math.max(MARGIN, Math.min(moved.left, width - MARGIN - panel.offsetWidth))}px`,\n top: `${Math.max(MARGIN, Math.min(moved.top, height - MARGIN - Math.min(wanted, room)))}px`,\n maxHeight: `${room}px`,\n });\n return;\n }\n const top = Math.min(Math.max(r.top, 0), height);\n const bottom = Math.min(Math.max(r.bottom, 0), height);\n const gap = APART;\n const right = width - MARGIN - panel.offsetWidth - (r.right + gap);\n const left = r.left - gap - panel.offsetWidth - MARGIN;\n if (right >= 0 || left >= 0) {\n const room = Math.max(0, height - 2 * MARGIN);\n Object.assign(panel.style, {\n left: `${right >= 0 ? r.right + gap : r.left - gap - panel.offsetWidth}px`,\n top: `${Math.max(MARGIN, Math.min(r.top - CLEAR, height - MARGIN - Math.min(wanted, room)))}px`,\n maxHeight: `${room}px`,\n // It grows out of the side the element is on, as it opens.\n transformOrigin: right >= 0 ? '0 24px' : '100% 24px',\n });\n return;\n }\n const below = height - bottom - gap - MARGIN;\n const above = top - gap - MARGIN;\n const cap = Math.max(0, Math.min(height * 0.6, height - 2 * MARGIN));\n let at: number;\n let room: number;\n if (Math.max(below, above) < LEAST) {\n room = height - 2 * MARGIN;\n at = Math.min(Math.max(bottom + gap, MARGIN), height - MARGIN - Math.min(wanted, room));\n } else if (wanted <= below || below >= above) {\n room = Math.min(below, cap);\n at = bottom + gap;\n } else {\n room = Math.min(above, cap);\n at = top - gap - Math.min(wanted, room);\n }\n Object.assign(panel.style, {\n left: `${Math.max(MARGIN, Math.min(r.left, width - MARGIN - panel.offsetWidth))}px`,\n top: `${at}px`,\n bottom: '',\n maxHeight: `${room}px`,\n transformOrigin: at < top ? '24px 100%' : '24px 0',\n });\n };\n // Not in the observers' callbacks, where a change of size is a \"ResizeObserver loop\" error on the page. The next\n // frame, or a moment later where there's none: a hidden tab draws no frames, and its popup still fits when shown.\n const later = () => {\n frame ||= requestAnimationFrame(fit);\n timer ??= setTimeout(fit, 50);\n };\n fit();\n // Read each frame, as nothing tells of an element moving: the page scrolls, its layout shifts, a panel previews.\n let watching = requestAnimationFrame(function watch() {\n if (moved !== undefined) return;\n watching = requestAnimationFrame(watch);\n if (!element.isConnected) return;\n const now = boxOf();\n if (now.left === r.left && now.top === r.top && now.width === r.width && now.height === r.height) return;\n r = now;\n fit();\n });\n // A drag starts on the head itself, not on a tab or the close in it.\n let from: { x: number; y: number; left: number; top: number } | undefined;\n const down = (e: PointerEvent) => {\n if (e.button !== 0 || (e.target as Element).closest('button') !== null) return;\n // Kept from the browser: no text selected along the way, and the field being typed in keeps its focus.\n e.preventDefault();\n const at = panel.getBoundingClientRect();\n from = { x: e.clientX, y: e.clientY, left: at.left, top: at.top };\n handle.setPointerCapture(e.pointerId);\n };\n const move = (e: PointerEvent) => {\n if (from === undefined) return;\n const x = e.clientX - from.x;\n const y = e.clientY - from.y;\n if (moved === undefined && Math.hypot(x, y) < SLACK) return;\n moved = { left: from.left + x, top: from.top + y };\n panel.classList.add('dragging');\n fit();\n };\n const up = () => {\n from = undefined;\n panel.classList.remove('dragging');\n };\n handle.addEventListener('pointerdown', down);\n handle.addEventListener('pointermove', move);\n handle.addEventListener('pointerup', up);\n handle.addEventListener('pointercancel', up);\n // A tab's content arrives after the panel opens, and changes as it's used, as does the status line. Both, as a\n // resize observer reports only while the page renders: a hidden tab's popup would keep its first place.\n const resized = new ResizeObserver(later);\n resized.observe(panel);\n const changed = new MutationObserver(later);\n changed.observe(panel, { childList: true, subtree: true, characterData: true });\n window.addEventListener('resize', later);\n return () => {\n cancelAnimationFrame(frame);\n cancelAnimationFrame(watching);\n clearTimeout(timer);\n resized.disconnect();\n changed.disconnect();\n window.removeEventListener('resize', later);\n };\n}\n\n/** A button that is a drawing: named for what it does, as its title, the tooltip, changes with what it would do. */\nfunction iconButton(svg: string, name: string, title: string): HTMLButtonElement {\n const el = button('', title);\n el.className = 'icon';\n el.innerHTML = svg;\n el.setAttribute('aria-label', name);\n return el;\n}\n\nfunction button(text: string, title: string): HTMLButtonElement {\n const el = document.createElement('button');\n el.type = 'button';\n el.textContent = text;\n el.title = title;\n return el;\n}\n\nconst messageOf = (e: unknown) => (e instanceof Error ? e.message : String(e));\n\n/** A plugin's page half that threw: a bug of the plugin's, to report where it's made. Its key is the first line of what it threw. */\nconst failed = (plugin: string, what: string, e: unknown): Problem => ({\n key: `page:${plugin}:${what.split(' ', 1)[0]}:${messageOf(e).split('\\n', 1)[0]!.slice(0, 200)}`,\n kind: 'bug',\n plugin,\n message: `${plugin} failed to ${what}: ${messageOf(e)}`,\n ...(e instanceof Error && e.stack !== undefined ? { details: e.stack } : {}),\n});\n"],"mappings":";;;;;;AAkBA,MAAMA,QAAM;AACZ,MAAM,QAAQ;;AAEd,MAAM,QAAQ;;AAGd,IAAI,OAAyB,QAAQ,QAAQ;AAE7C,SAAS,MAAS,MAA0B,MAA4D;CACtG,MAAM,OAAO,KACV,YAAY,CAAC,CAAC,CAAC,CACf,WAEG,IAAI,SAAY,MAAM,SAAS;EAC7B,MAAM,UAAU,UAAU,KAAK,WAAW,CAAC;EAC3C,QAAQ,iBAAiB,uBAAuB,QAAQ,OAAO,kBAAkB,KAAK,CAAC;EACvF,QAAQ,iBAAiB,eAAe,KAAK,QAAQ,KAAK,CAAC;EAC3D,QAAQ,iBAAiB,iBAAiB;GACxC,MAAM,KAAK,QAAQ;GACnB,MAAM,cAAc,GAAG,YAAY,OAAO,IAAI;GAC9C,YAAY,iBAAiB,kBAAkB,GAAG,MAAM,CAAC;GACzD,YAAY,iBAAiB,eAAe,GAAG,MAAM,CAAC;GACtD,IAAI;IACF,MAAM,UAAU,KAAK,YAAY,YAAY,KAAK,CAAC;IACnD,QAAQ,iBAAiB,eAAe,KAAK,QAAQ,KAAK,CAAC;IAC3D,QAAQ,iBAAiB,iBAAiB,KAAK,QAAQ,MAAM,CAAC;GAChE,SAAS,GAAG;IAEV,KAAK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iB,KAAK;CAC1C,QAAQ,QAAQ,OAAO;EAAE,WAAW;EAAM,SAAS;EAAM,eAAe;CAAK,CAAC;CAC9E,OAAO,iBAAiB,UAAU,KAAK;CACvC,aAAa;EACX,qBAAqB,KAAK;EAC1B,qBAAqB,QAAQ;EAC7B,aAAa,KAAK;EAClB,QAAQ,WAAW;EACnB,QAAQ,WAAW;EACnB,OAAO,oBAAoB,UAAU,KAAK;CAC5C;AACF;;AAGA,SAAS,WAAW,KAAa,MAAc,OAAkC;CAC/E,MAAM,KAAK,OAAO,IAAI,KAAK;CAC3B,GAAG,YAAY;CACf,GAAG,YAAY;CACf,GAAG,aAAa,cAAc,IAAI;CAClC,OAAO;AACT;AAEA,SAAS,OAAO,MAAc,OAAkC;CAC9D,MAAM,KAAK,SAAS,cAAc,QAAQ;CAC1C,GAAG,OAAO;CACV,GAAG,cAAc;CACjB,GAAG,QAAQ;CACX,OAAO;AACT;AAEA,MAAM,aAAa,MAAgB,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;;AAG5E,MAAM,UAAU,QAAgB,MAAc,OAAyB;CACrE,KAAK,QAAQ,OAAO,GAAG,KAAK,MAAM,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,EAAE,CAAE,MAAM,GAAG,GAAG;CAC5F,MAAM;CACN;CACA,SAAS,GAAG,OAAO,aAAa,KAAK,IAAI,UAAU,CAAC;CACpD,GAAI,aAAa,SAAS,EAAE,UAAU,KAAA,IAAY,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC5E"}
1
+ {"version":3,"file":"index.js","names":["KEY","button","LINGER","place","MARGIN"],"sources":["../../src/client/away.ts","../../src/client/lightbox.ts","../../src/client/lighting.ts","../../src/client/style.ts","../../src/client/tools.ts","../../src/client/tooltip.ts","../../src/client/tray.ts","../../src/client/index.ts"],"sourcesContent":["/**\n * A panel's `away`, kept past a page load: the tab, the element's place and the state it left, for the\n * next page to come back with when what it left for carries on there (a recording does).\n *\n * The state may hold what JSON can't (a drawn screenshot is a `Blob`), so it's in IndexedDB, which is the\n * origin's: the tab's session storage holds the key, so each tab comes back to its own.\n */\nimport type { Point, Target } from '#src/index.ts';\n\n/** What the next page needs to come back: which tab, on what, with what. */\nexport interface Away {\n tab: string;\n target: Target;\n /** The spot in the element the popup was on, where it was on one. */\n at?: Point;\n state: unknown;\n}\n\nconst KEY = 'deictic:away';\nconst STORE = 'away';\n/** How long one nobody came back to is kept, in milliseconds: its tab was closed. */\nconst STALE = 24 * 60 * 60 * 1000;\n\n/** One at a time, in the order asked: a `drop` right after a `keep` must not run before it. */\nlet last: Promise<unknown> = Promise.resolve();\n\nfunction store<T>(mode: IDBTransactionMode, work: (store: IDBObjectStore) => IDBRequest<T>): Promise<T> {\n const next = last\n .catch(() => {})\n .then(\n () =>\n new Promise<T>((done, fail) => {\n const opening = indexedDB.open('deictic', 1);\n opening.addEventListener('upgradeneeded', () => opening.result.createObjectStore(STORE));\n opening.addEventListener('error', () => fail(opening.error));\n opening.addEventListener('success', () => {\n const db = opening.result;\n const transaction = db.transaction(STORE, mode);\n transaction.addEventListener('complete', () => db.close());\n transaction.addEventListener('abort', () => db.close());\n try {\n const request = work(transaction.objectStore(STORE));\n request.addEventListener('error', () => fail(request.error));\n request.addEventListener('success', () => done(request.result));\n } catch (e) {\n // What can't be copied throws as it's put, here, where nothing would hear it.\n fail(e);\n }\n });\n }),\n );\n last = next;\n return next;\n}\n\nconst keyOf = (): string | undefined => {\n try {\n return sessionStorage.getItem(KEY) ?? undefined;\n } catch {\n // Storage can be off: nothing is kept past the page, then.\n return undefined;\n }\n};\n\n/** Keeps it for the tab's next page. A state that can't be copied (it holds a function, an element) isn't kept, and a page load loses it. */\nexport function keepAway(away: Away): void {\n try {\n const key = keyOf() ?? crypto.randomUUID();\n sessionStorage.setItem(KEY, key);\n void store('readwrite', (s) => {\n // Those of tabs long closed go as a new one comes.\n const walk = s.openCursor();\n walk.addEventListener('success', () => {\n const cursor = walk.result;\n if (cursor === null) return;\n if (Date.now() - (cursor.value as { at: number }).at > STALE) cursor.delete();\n cursor.continue();\n });\n return s.put({ ...away, at: Date.now() }, key);\n }).catch(() => {});\n } catch {\n // Not kept, then.\n }\n}\n\n/** What the page before this left, if it left anything. */\nexport async function keptAway(): Promise<Away | undefined> {\n const key = keyOf();\n if (key === undefined) return undefined;\n try {\n return await store<Away | undefined>('readonly', (s) => s.get(key));\n } catch {\n return undefined;\n }\n}\n\n/** It's come back, or there's nothing to come back for. */\nexport function dropAway(): void {\n const key = keyOf();\n if (key === undefined) return;\n try {\n sessionStorage.removeItem(KEY);\n } catch {\n // It was readable, so this doesn't happen; and a stale one is dropped by the page that finds it.\n }\n void store('readwrite', (s) => s.delete(key)).catch(() => {});\n}\n","/**\n * The lightbox: what a panel has attached (a capture, a recording's replay, a voice clip), big, over everything,\n * one at a time, ← and → between them. It grows out of the element that opened it and shrinks back into it, or\n * fades where motion is reduced. A sound plays in a player of its own: play, its waveform with what's played\n * lit (click or drag it to seek), and the time. It's a modal (`data-deictic-modal`): Esc closes it, not the popup.\n */\nimport type { LightboxItem, LightboxOptions } from '#src/index.ts';\n\nimport { div, reduced } from './dom.ts';\nimport { type Colors, drawBars, peaksOf } from './waveform.ts';\n\nconst EASE = 'cubic-bezier(0.2, 0.8, 0.2, 1)';\nconst PLAY = '<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M7 4v16l13-8z\" fill=\"currentColor\"/></svg>';\nconst PAUSE = '<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 4h4v16H6zM14 4h4v16h-4z\" fill=\"currentColor\"/></svg>';\n\nconst clock = (s: number) => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, '0')}`;\n\n/**\n * Opens it in `root`. `pinned` draws it where `root` is in the page instead, with no backdrop, motion or keys, and\n * actions that don't close it: for a page of deictic's own states (`lightboxIn`).\n */\nexport function openLightbox(\n root: ShadowRoot,\n items: LightboxItem[],\n { at = 0, from, pinned = false }: LightboxOptions & { pinned?: boolean } = {},\n): { close: () => void } {\n const box = div(pinned ? 'lightbox pinned' : 'lightbox');\n if (!pinned) {\n box.dataset.deicticModal = '';\n box.setAttribute('role', 'dialog');\n box.setAttribute('aria-modal', 'true');\n }\n const backdrop = div('lb-backdrop');\n const stage = div('lb-stage');\n const head = div('lb-head');\n const title = div('lb-title');\n const count = div('lb-count');\n const actions = div('lb-actions');\n const close = button('×', 'Close (Esc)', 'lb-close');\n head.append(title, count, actions, close);\n const body = div('lb-body');\n stage.append(head, body);\n // Drawn, not glyphs: a font's ‹ and › sit off the middle of a round button, each font its own way.\n const prev = button('', 'Previous (←)', 'lb-prev');\n prev.innerHTML = chevron('M15 6l-6 6 6 6');\n const next = button('', 'Next (→)', 'lb-next');\n next.innerHTML = chevron('M9 6l6 6-6 6');\n box.append(backdrop, stage, ...(items.length > 1 ? [prev, next] : []));\n root.append(box);\n\n let index = Math.min(Math.max(0, at), items.length - 1);\n let leave: (() => void) | undefined;\n let closing = false;\n\n const show = (i: number, animate: boolean) => {\n leave?.();\n leave = undefined;\n index = (i + items.length) % items.length;\n const item = items[index]!;\n box.setAttribute('aria-label', item.title);\n title.textContent = item.title;\n count.textContent = items.length > 1 ? `${index + 1} / ${items.length}` : '';\n actions.replaceChildren(\n ...(item.actions ?? []).map((a) => {\n const b = button(a.label, a.title ?? '', '');\n b.addEventListener('click', () => {\n if (!pinned) done();\n a.run();\n });\n return b;\n }),\n );\n // A sound plays as it opens, but not on a page that only shows the lightbox.\n const content = contentOf(item, !pinned);\n body.replaceChildren(content.element);\n leave = content.leave;\n if (animate && !reduced()) body.animate({ opacity: [0, 1] }, { duration: 160, easing: 'ease-out' });\n };\n\n /** The transform that puts the stage where `from` is: what it grows from and shrinks back to. */\n const fromRect = () => {\n if (from === undefined || !from.isConnected) return undefined;\n const f = from.getBoundingClientRect();\n const s = stage.getBoundingClientRect();\n if (f.width === 0 || s.width === 0) return undefined;\n return `translate(${f.left - s.left}px, ${f.top - s.top}px) scale(${f.width / s.width}, ${f.height / s.height})`;\n };\n\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') done();\n else if (e.key === 'ArrowLeft' && items.length > 1) show(index - 1, true);\n else if (e.key === 'ArrowRight' && items.length > 1) show(index + 1, true);\n else return;\n // The popup, under it, waits for its own Esc.\n e.preventDefault();\n e.stopImmediatePropagation();\n };\n if (!pinned) addEventListener('keydown', onKey, true);\n\n function done() {\n if (closing) return;\n closing = true;\n removeEventListener('keydown', onKey, true);\n leave?.();\n if (pinned) return box.remove();\n const gone = () => {\n box.remove();\n if (from instanceof HTMLElement && from.isConnected) from.focus({ preventScroll: true });\n };\n if (reduced()) return gone();\n const to = fromRect();\n backdrop.animate({ opacity: [1, 0] }, { duration: 200, easing: 'ease-in', fill: 'forwards' });\n stage\n .animate(\n to === undefined\n ? { opacity: [1, 0], transform: ['none', 'scale(0.96)'] }\n : { transform: ['none', to], opacity: [1, 1, 0], offset: [0, 0.8, 1] },\n { duration: 220, easing: EASE, fill: 'forwards' },\n )\n .finished.then(gone, gone);\n }\n\n backdrop.addEventListener('click', done);\n close.addEventListener('click', done);\n prev.addEventListener('click', () => show(index - 1, true));\n next.addEventListener('click', () => show(index + 1, true));\n\n show(index, false);\n if (pinned) {\n close.hidden = true;\n return { close: done };\n }\n close.focus({ preventScroll: true });\n if (reduced()) {\n box.animate({ opacity: [0, 1] }, { duration: 150 });\n } else {\n backdrop.animate({ opacity: [0, 1] }, { duration: 240, easing: 'ease-out' });\n const grow = fromRect();\n stage.animate(\n grow === undefined\n ? { opacity: [0, 1], transform: ['scale(0.96)', 'none'] }\n : { transform: [grow, 'none'], opacity: [0, 1, 1], offset: [0, 0.2, 1] },\n { duration: 280, easing: EASE },\n );\n }\n return { close: done };\n}\n\n/** An item, drawn: what goes in the body, and what to stop when it's left (a sound playing). */\nfunction contentOf(item: LightboxItem, autoplay: boolean): { element: HTMLElement; leave?: () => void } {\n switch (item.kind) {\n case 'image': {\n const img = Object.assign(document.createElement('img'), { src: item.url, alt: item.title, className: 'lb-image', draggable: false });\n return { element: img };\n }\n case 'page': {\n const frame = Object.assign(document.createElement('iframe'), { src: item.url, title: item.title, className: 'lb-page' });\n frame.allow = 'autoplay; fullscreen';\n return { element: frame };\n }\n case 'audio':\n return player(item.url, autoplay);\n }\n}\n\n/** A sound: play and pause, its waveform with what's played lit, and the time. With `autoplay`, it starts playing. */\nfunction player(url: string, autoplay: boolean): { element: HTMLElement; leave: () => void } {\n const el = div('lb-audio');\n const play = button('', 'Play (Space)', 'lb-play');\n const wave = Object.assign(document.createElement('canvas'), { className: 'lb-wave' });\n wave.setAttribute('role', 'slider');\n wave.setAttribute('aria-label', 'Where in the clip');\n wave.tabIndex = 0;\n const time = div('lb-time');\n el.append(play, wave, time);\n const audio = new Audio(url);\n const colors: Colors = { played: '#3ddc7c', rest: '#52525b' };\n // Flat until the clip's read: the bars rise when its peaks are in.\n let peaks: number[] = Array<number>(120).fill(0.05);\n let frame = 0;\n // MediaRecorder's webm says no length until it's played through; reading the peaks gives it sooner.\n let length = 0;\n const lengthOf = () => (Number.isFinite(audio.duration) && audio.duration > 0 ? audio.duration : length);\n const draw = () => {\n const total = lengthOf();\n drawBars(wave, peaks, total > 0 ? audio.currentTime / total : 0, colors);\n time.textContent = `${clock(audio.currentTime)} / ${total > 0 ? clock(total) : '–:––'}`;\n wave.setAttribute('aria-valuenow', String(Math.round(audio.currentTime)));\n };\n const loop = () => {\n draw();\n frame = audio.paused ? 0 : requestAnimationFrame(loop);\n };\n const state = () => {\n play.innerHTML = audio.paused ? PLAY : PAUSE;\n play.title = audio.paused ? 'Play (Space)' : 'Pause (Space)';\n if (!audio.paused && frame === 0) frame = requestAnimationFrame(loop);\n draw();\n };\n audio.addEventListener('play', state);\n audio.addEventListener('pause', state);\n audio.addEventListener('ended', state);\n audio.addEventListener('loadedmetadata', draw);\n const toggle = () => void (audio.paused ? audio.play().catch(() => {}) : audio.pause());\n play.addEventListener('click', toggle);\n const seek = (e: PointerEvent) => {\n const r = wave.getBoundingClientRect();\n const total = lengthOf();\n if (total > 0) audio.currentTime = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width)) * total;\n draw();\n };\n wave.addEventListener('pointerdown', (e) => {\n wave.setPointerCapture(e.pointerId);\n seek(e);\n });\n wave.addEventListener('pointermove', (e) => {\n if (wave.hasPointerCapture(e.pointerId)) seek(e);\n });\n el.addEventListener('keydown', (e) => {\n if (e.key !== ' ') return;\n e.preventDefault();\n toggle();\n });\n void peaksOf(url, 120).then(\n (read) => {\n peaks = read.peaks;\n length = read.duration;\n draw();\n },\n // Undecodable here: the player still plays it, over flat bars.\n () => {},\n );\n state();\n if (autoplay) void audio.play().catch(() => state());\n // The canvas has its size once it's in the page.\n requestAnimationFrame(draw);\n return {\n element: el,\n leave: () => {\n audio.pause();\n cancelAnimationFrame(frame);\n },\n };\n}\n\nconst chevron = (d: string) =>\n `<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"${d}\"/></svg>`;\n\nfunction button(text: string, title: string, className: string): HTMLButtonElement {\n const el = document.createElement('button');\n el.type = 'button';\n el.textContent = text;\n el.title = title;\n el.className = className;\n return el;\n}\n","/**\n * What the overlay draws on the page itself: the element under the pointer while a shortcut's keys are held, and\n * the one the popup is open on.\n *\n * It uses the whole page: it dims around the element, which stays lit in a ring, with guides from its edges across\n * the window and a caption saying what it is. The light glides from one element to the next. While the popup is\n * open the element stays lit, tied to the popup by a line that follows both. Nothing here takes the pointer, and\n * the page comes back to full light once the pointer has been out on it a moment.\n */\nimport type { Point, Tag, Target } from '#src/index.ts';\n\nimport { named } from './component.ts';\nimport { div, nameOf, place, reduced } from './dom.ts';\n\n/** What's pointed at while a shortcut's keys are held. */\nexport interface Pointed {\n /** The marked element. */\n el: Element;\n /** What's under the pointer inside it, where that differs. */\n pointed?: Element;\n target: Target;\n /**\n * The tabs that plugins' own shortcuts would open, each by its label: several where they share keys and differ by\n * button, and none for deictic's own shortcut alone.\n */\n names: string[];\n /** How many elements on the page are from its place in the source. */\n count: number;\n /** The plugins' own tags for what's under the pointer (`ClientPlugin.tag`), after deictic's. */\n tags?: Tag[];\n}\n\nexport interface Lighting {\n /** Shows what's pointed at. Not `glide`: it moved with the page, which nothing eases. */\n point(at: Pointed, glide?: boolean): void;\n hide(): void;\n /** Marks the element the popup (`panel`) is open on, or the spot `at` in it, for as long as it is. Answers what ends it. */\n hold(element: Element, panel: HTMLElement, at?: Point): () => void;\n}\n\n/**\n * How far from the element its ring is, in pixels: the ring glows, and a border, an outline or a ring tried on the\n * element has to show apart from it.\n */\nexport const CLEAR = 8;\n\nconst grown = (r: DOMRect) => new DOMRect(r.left - CLEAR, r.top - CLEAR, r.width + 2 * CLEAR, r.height + 2 * CLEAR);\n\n/** How far around a spot its light reaches, in pixels: a circle that shows what's under the point. */\nconst SPOT = 16;\n\n/** A spot in an element, as the box its light fills. */\nexport function spotOf(element: Element, at: Point): DOMRect {\n const r = element.getBoundingClientRect();\n return new DOMRect(r.left + at.x - SPOT, r.top + at.y - SPOT, 2 * SPOT, 2 * SPOT);\n}\n\n/** How long the pointer is out on the page, in milliseconds, before the page gets its light back. */\nconst LINGER = 700;\n/** How long the light takes from one element to the next, in milliseconds: as the styles have it. */\nconst GLIDE = 240;\n/** How far from a corner the line to the popup starts and ends, in pixels. */\nconst INSET = 22;\n\n// The ring and the line, drawn as strokes: a dash can run along a stroke (the line is drawn out to the popup, and\n// a light goes along it, once), which no border can. Wide faint strokes under them are the glow, as a filter over\n// the whole window would be drawn again with every frame of it.\nconst LIT = `<svg aria-hidden=\"true\">\n<rect class=\"halo\"/><rect class=\"lock\"/>\n<path class=\"halo\" pathLength=\"1\"/><path class=\"tether\" pathLength=\"1\"/><path class=\"flow\" pathLength=\"1\"/>\n<circle r=\"3\"/><circle r=\"3\"/></svg>`;\n\nconst clamp = (n: number, low: number, high: number) => Math.max(low, Math.min(n, high));\n\n/** The light's corner for an element, as far out as the light is: a pill stays a pill, a square corner is eased a little. */\nfunction radiusOf(el: Element, r: DOMRect): number {\n // A computed radius is a length or a percentage, and two of them where the corner is an ellipse: the first, then.\n const [first = '0px'] = getComputedStyle(el).borderTopLeftRadius.split(' ');\n const n = Number.parseFloat(first);\n const least = Math.min(r.width, r.height);\n return Math.min(first.endsWith('%') ? (n / 100) * least : n + CLEAR, least / 2);\n}\n\n/**\n * The line from the lit box to the popup: an S from side to side where the popup is beside it, else down or up to\n * it, and none where they overlap. It ends on the popup level with the box's middle, as near as the popup reaches.\n */\nfunction tetherOf(e: DOMRect, p: DOMRect): { d: string; ends: [number, number][] } | undefined {\n for (const [near, far, low, high] of [\n ['left', 'right', 'top', 'bottom'],\n ['top', 'bottom', 'left', 'right'],\n ] as const) {\n const way = p[near] >= e[far] ? 1 : p[far] <= e[near] ? -1 : 0;\n if (way === 0) continue;\n const a1 = way > 0 ? e[far] : e[near];\n const a2 = way > 0 ? p[near] : p[far];\n const inset = (r: DOMRect) => Math.min(INSET, (r[high] - r[low]) / 2);\n const b2 = clamp((e[low] + e[high]) / 2, p[low] + inset(p), p[high] - inset(p));\n const b1 = clamp(b2, e[low] + inset(e), e[high] - inset(e));\n const bend = (a2 - a1) / 2;\n const at = (a: number, b: number): [number, number] => (near === 'left' ? [a, b] : [b, a]);\n const points = [at(a1, b1), at(a1 + bend, b1), at(a2 - bend, b2), at(a2, b2)].map(([x, y]) => `${x} ${y}`);\n return { d: `M${points[0]}C${points.slice(1).join(' ')}`, ends: [at(a1, b1), at(a2, b2)] };\n }\n return undefined;\n}\n\nexport function spotlight(root: ShadowRoot): Lighting {\n // Under the marks a page keeps (annotations'), which are drawn as bright as ever.\n const veil = div('veil');\n const aim = div('aim');\n const ring = div('ring');\n const caption = div('caption');\n ring.append(caption);\n const guides = { left: div('guide gx'), right: div('guide gx'), top: div('guide gy'), bottom: div('guide gy') };\n const inner = div('inner');\n aim.append(...Object.values(guides), ring);\n root.append(veil, aim, inner);\n\n let pointing = false;\n let held = false;\n let said = '';\n // Not at once: a press that opens the popup hides what's pointed at and holds the same element in one go, and\n // the popup moving to another element lets one go and holds the next. The light stays on through both, and glides.\n const dark = () =>\n queueMicrotask(() => {\n if (!pointing && !held) veil.classList.remove('shown');\n });\n const light = (r: DOMRect, radius: number, glide: boolean) => {\n veil.classList.toggle('glide', glide && veil.classList.contains('shown'));\n place(veil, r);\n veil.style.borderRadius = `${radius}px`;\n veil.classList.add('shown');\n };\n const part = (className: string, text: string) => Object.assign(document.createElement('span'), { className, textContent: text });\n\n return {\n point({ el, pointed, target, names, count, tags = [] }, glide = true) {\n pointing = true;\n const box = el.getBoundingClientRect();\n const r = grown(box);\n const radius = radiusOf(el, r);\n aim.classList.toggle('glide', glide && aim.classList.contains('shown'));\n place(ring, r);\n ring.style.borderRadius = `${radius}px`;\n guides.left.style.translate = `${r.left}px`;\n guides.right.style.translate = `${r.right - 1}px`;\n guides.top.style.translate = `0 ${r.top}px`;\n guides.bottom.style.translate = `0 ${r.bottom - 1}px`;\n // The popup's element keeps the light while it's open: another pointed at then has the ring alone.\n if (!held) light(r, radius, glide);\n inner.classList.toggle('shown', pointed !== undefined);\n if (pointed !== undefined) place(inner, pointed.getBoundingClientRect());\n\n // What it is, where it's from, how big, how many share its place, what's pointed at in it, and the tab a\n // plugin's own shortcut opens.\n const dim = [\n `${Math.round(box.width)}×${Math.round(box.height)}`,\n ...(count > 1 ? [`×${count}`] : []),\n ...(pointed === undefined ? [] : [`› ${nameOf(pointed)}`]),\n ];\n // By the component that wrote it, where the page says which: its name alone for its only element, and with\n // the tag for one of several.\n const { component, sole } = named(el);\n const texts = {\n tag: `<${component ?? target.tag}>`,\n inside: component === undefined || sole ? '' : `<${target.tag}>`,\n from: `${target.loc.file}:${target.loc.line}`,\n opens: names.join(' / '),\n };\n const saying = JSON.stringify([texts, dim, tags]);\n if (saying !== said) {\n said = saying;\n caption.replaceChildren(\n part('tag', texts.tag),\n ...tags.map(({ text, color }) => {\n const own = part('tag', text);\n if (color !== undefined) own.style.background = color;\n own.style.color = '#fff';\n return own;\n }),\n ...(texts.inside === '' ? [] : [part('dim', texts.inside)]),\n part('', texts.from),\n ...dim.map((text) => part('dim', text)),\n ...(names.length === 0 ? [] : [part('opens', texts.opens)]),\n );\n }\n caption.classList.toggle('below', r.top < 40);\n // Kept in the window: a caption is longer than most of what it names.\n caption.style.translate = `${Math.min(0, document.documentElement.clientWidth - 8 - r.left - caption.offsetWidth)}px`;\n aim.classList.add('shown');\n },\n hide() {\n pointing = false;\n aim.classList.remove('shown');\n inner.classList.remove('shown');\n dark();\n },\n hold(element, panel, at) {\n held = true;\n const lit = div('lit');\n lit.innerHTML = LIT;\n root.append(lit);\n const rects = [...lit.querySelectorAll('rect')];\n const paths = [...lit.querySelectorAll('path')];\n const dots = [...lit.querySelectorAll('circle')];\n // A ring that leaves the element as the popup opens on it, once.\n const pulse = reduced() ? undefined : div('pulse');\n if (pulse !== undefined) {\n root.append(pulse);\n pulse.addEventListener('animationend', () => pulse.remove());\n }\n\n let frame = 0;\n let was: string | undefined;\n // The first place may be a glide, from the element lit before; after it the light keeps to its element as the\n // page moves it, each frame, with no easing to fall behind by.\n let first = true;\n const settled = setTimeout(() => veil.classList.remove('glide'), GLIDE);\n const follow = () => {\n frame = requestAnimationFrame(follow);\n const on = element.isConnected;\n const e = at === undefined ? grown(element.getBoundingClientRect()) : spotOf(element, at);\n const p = panel.getBoundingClientRect();\n const now = on ? [e.left, e.top, e.width, e.height, p.left, p.top, p.width, p.height].join() : '';\n if (now === was) return;\n was = now;\n lit.classList.toggle('shown', on);\n // An element that's not on the page has nothing to light: the page stays as it is.\n if (!on) return veil.classList.remove('shown');\n const radius = at === undefined ? radiusOf(element, e) : SPOT;\n if (first) light(e, radius, true);\n else place(veil, e);\n veil.style.borderRadius = `${radius}px`;\n if (first && pulse !== undefined) {\n place(pulse, e);\n pulse.style.borderRadius = `${radius}px`;\n }\n first = false;\n for (const rect of rects) {\n for (const [name, value] of Object.entries({ x: e.left, y: e.top, width: e.width, height: e.height, rx: radius }))\n rect.setAttribute(name, String(value));\n }\n // From what of the element is in the window: one scrolled out of it is tied from the edge it left by.\n const width = document.documentElement.clientWidth;\n const height = document.documentElement.clientHeight;\n const [left, right] = [clamp(e.left, 0, width), clamp(e.right, 0, width)];\n const [top, bottom] = [clamp(e.top, 0, height), clamp(e.bottom, 0, height)];\n const tie = tetherOf(new DOMRect(left, top, right - left, bottom - top), p);\n lit.classList.toggle('tied', tie !== undefined);\n if (tie === undefined) return;\n for (const path of paths) path.setAttribute('d', tie.d);\n for (const [i, dot] of dots.entries()) {\n dot.setAttribute('cx', String(tie.ends[i]![0]));\n dot.setAttribute('cy', String(tie.ends[i]![1]));\n }\n };\n follow();\n\n // The page dims for what's being done in the popup, and no longer: with the pointer out on the page a\n // moment, it's the page that's looked at, and it gets its light back until the pointer is in the overlay again.\n let lift: ReturnType<typeof setTimeout> | undefined;\n const moved = (e: PointerEvent) => {\n if (!e.composedPath().includes(root.host)) {\n lift ??= setTimeout(() => veil.classList.add('lifted'), LINGER);\n return;\n }\n clearTimeout(lift);\n lift = undefined;\n veil.classList.remove('lifted');\n };\n window.addEventListener('pointermove', moved, { capture: true, passive: true });\n\n return () => {\n held = false;\n cancelAnimationFrame(frame);\n clearTimeout(settled);\n clearTimeout(lift);\n window.removeEventListener('pointermove', moved, true);\n lit.remove();\n pulse?.remove();\n veil.classList.remove('lifted');\n dark();\n };\n },\n };\n}\n","/**\n * The overlay's styles, in its shadow root. Panels style their bodies with the same custom\n * properties, so a plugin's panel looks like the rest without styles of its own for the basics.\n */\nexport const STYLE = `\n:host {\n --deictic-accent: #12b358;\n --deictic-on-accent: #04130b;\n --deictic-bg: #18181b;\n --deictic-fg: #f4f4f5;\n --deictic-muted: #a1a1aa;\n --deictic-line: #3f3f46;\n --deictic-problem: #f87171;\n all: initial;\n /* Inherited by everything in the root: a thumb and no track, on whatever the panel's background is. */\n scrollbar-color: var(--deictic-line) transparent;\n}\n/* The host takes no room in the page: everything in it is fixed, so nothing of deictic's moves or scrolls it. */\n:host(deictic-overlay) { display: contents; }\n/* What's under the pointer inside the lit element, where that differs. */\n.inner {\n position: fixed;\n display: none;\n z-index: 2147483646;\n pointer-events: none;\n box-sizing: border-box;\n outline: 1px dashed var(--deictic-accent);\n}\n.inner.shown { display: block; }\n/* Glass, over a page that's dimmed around what it's about. */\n.panel {\n --deictic-line: rgb(255 255 255 / 0.14);\n position: fixed;\n z-index: 2147483647;\n width: min(440px, calc(100vw - 16px));\n max-height: 60vh;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n border: 1px solid rgb(255 255 255 / 0.1);\n border-radius: 14px;\n box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4), 0 24px 64px -12px rgb(0 0 0 / 0.55), 0 0 56px -12px rgb(18 179 88 / 0.35),\n inset 0 1px 0 rgb(255 255 255 / 0.08);\n font: 13px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n background: linear-gradient(rgb(39 39 42 / 0.9), rgb(24 24 27 / 0.94));\n backdrop-filter: blur(24px) saturate(1.8);\n}\n.panel.pinned { position: relative; z-index: auto; width: min(440px, 100%); max-height: none; }\n@keyframes deictic-in {\n from { opacity: 0; translate: 0 4px; }\n}\n.head {\n position: relative;\n display: flex;\n align-items: center;\n gap: 2px;\n padding: 8px 8px 6px;\n}\n/* Over the page the head is what the popup is dragged by; no touch scrolling starts there. */\n.panel:not(.pinned) .head { cursor: grab; touch-action: none; user-select: none; }\n.panel.dragging .head, .panel.dragging .head button { cursor: grabbing; }\n.head .tab {\n position: relative;\n border: 0;\n border-radius: 8px;\n padding: 4px 10px;\n font-weight: 600;\n color: var(--deictic-muted);\n}\n.head .tab:hover { color: var(--deictic-fg); }\n.head .tab[aria-selected='true'] { color: var(--deictic-fg); }\n/* A pill behind the shown tab, slid to the next one shown. */\n.head .thumb {\n position: absolute;\n left: 0;\n top: 8px;\n bottom: 6px;\n border-radius: 8px;\n background: rgb(255 255 255 / 0.1);\n box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);\n pointer-events: none;\n}\n.head .end { margin-left: auto; }\n.bar {\n display: flex;\n align-items: center;\n gap: 2px;\n padding: 0 10px 8px 12px;\n border-bottom: 1px solid rgb(255 255 255 / 0.08);\n}\n.bar .where {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n margin-right: auto;\n font: 12px ui-monospace, monospace;\n color: var(--deictic-muted);\n text-decoration: none;\n}\n.bar .where span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.bar .where .tag { flex: none; color: var(--deictic-accent); }\n.bar .where svg { flex: none; }\n.bar .where:hover, .bar .where:focus-visible { color: var(--deictic-fg); }\n.bar .where:hover span { text-decoration: underline; }\n.bar .absent { flex: none; margin-right: 6px; font-size: 12px; color: var(--deictic-muted); }\n/* The page dims around the element (lighting.ts), by a shadow far wider than any window. */\n.veil {\n position: fixed;\n z-index: 2147483644;\n box-sizing: border-box;\n pointer-events: none;\n box-shadow: 0 0 0 200vmax rgb(9 9 11 / 0.5);\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.2s, visibility 0s 0.2s;\n}\n/* A moment late: Alt is pressed for much else, and a page that dimmed with every press would flicker. */\n.veil.shown { opacity: 1; visibility: visible; transition: opacity 0.3s 0.08s; }\n.veil.shown.lifted { opacity: 0; transition: opacity 0.6s; }\n.aim {\n position: fixed;\n inset: 0;\n z-index: 2147483646;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.12s, visibility 0s 0.12s;\n}\n.aim.shown { opacity: 1; visibility: visible; transition: opacity 0.12s; }\n.ring {\n position: absolute;\n box-sizing: border-box;\n border: 1.5px solid var(--deictic-accent);\n box-shadow: 0 0 0 4px rgb(18 179 88 / 0.14), 0 0 32px rgb(18 179 88 / 0.5), inset 0 0 24px rgb(18 179 88 / 0.1);\n}\n/* From the element's edges across the window: what it lines up with, anywhere on the page. */\n.guide { position: absolute; left: 0; top: 0; opacity: 0.35; }\n.guide.gx { width: 1px; height: 100%; background: linear-gradient(transparent, var(--deictic-accent) 20% 80%, transparent); }\n.guide.gy { width: 100%; height: 1px; background: linear-gradient(90deg, transparent, var(--deictic-accent) 20% 80%, transparent); }\n.caption {\n position: absolute;\n left: -1.5px;\n bottom: calc(100% + 8px);\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 3px 10px 3px 3px;\n border: 1px solid rgb(255 255 255 / 0.12);\n border-radius: 999px;\n font: 12px/20px ui-monospace, monospace;\n white-space: nowrap;\n color: var(--deictic-fg);\n background: rgb(24 24 27 / 0.86);\n backdrop-filter: blur(12px) saturate(1.6);\n box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);\n}\n.caption.below { top: calc(100% + 8px); bottom: auto; }\n.caption .tag { padding: 0 8px; border-radius: 999px; font-weight: 600; color: var(--deictic-on-accent); background: var(--deictic-accent); }\n.caption .dim { color: var(--deictic-muted); }\n.caption .opens { padding-left: 8px; border-left: 1px solid rgb(255 255 255 / 0.16); font: 600 12px/20px system-ui, sans-serif; color: var(--deictic-accent); }\n.lit { position: fixed; inset: 0; z-index: 2147483646; display: none; pointer-events: none; }\n.lit.shown { display: block; }\n.lit svg { display: block; width: 100%; height: 100%; fill: none; stroke: var(--deictic-accent); stroke-linecap: round; }\n.lit .halo { stroke-width: 7; opacity: 0.16; }\n.lit .lock, .lit .tether { stroke-width: 1.5; }\n.lit .flow { stroke: #eafff3; stroke-width: 2; opacity: 0; }\n.lit circle { fill: var(--deictic-accent); stroke: none; }\n.lit:not(.tied) path, .lit:not(.tied) circle { display: none; }\n.pulse {\n position: fixed;\n z-index: 2147483646;\n box-sizing: border-box;\n pointer-events: none;\n outline: 2px solid var(--deictic-accent);\n animation: deictic-pulse 0.5s ease-out forwards;\n}\n@media (prefers-reduced-motion: no-preference) {\n .head .thumb.moves { transition: left 0.22s cubic-bezier(0.3, 0.7, 0.2, 1), width 0.22s cubic-bezier(0.3, 0.7, 0.2, 1); }\n /* The light goes from one element to the next, not out and on again. */\n .veil.shown.glide {\n transition: opacity 0.3s, left 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), top 0.24s cubic-bezier(0.3, 0.7, 0.2, 1),\n width 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), height 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), border-radius 0.24s;\n }\n .aim.glide .ring {\n transition: left 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), top 0.24s cubic-bezier(0.3, 0.7, 0.2, 1),\n width 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), height 0.24s cubic-bezier(0.3, 0.7, 0.2, 1), border-radius 0.24s;\n }\n .aim.glide .guide { transition: translate 0.24s cubic-bezier(0.3, 0.7, 0.2, 1); }\n .panel:not(.pinned) { animation: deictic-rise 0.32s cubic-bezier(0.2, 0.9, 0.25, 1.1) backwards; }\n /* Once, as the popup opens: the line drawn out to the popup, with a light along it. */\n .lit .tether, .lit path.halo { stroke-dasharray: 1; animation: deictic-draw 0.4s 0.1s ease-out backwards; }\n .lit .flow { stroke-dasharray: 0.14 1; animation: deictic-flow 0.8s 0.45s ease-out; }\n .lit circle:last-of-type { animation: deictic-in 0.2s 0.45s backwards; }\n}\n@keyframes deictic-rise {\n from { opacity: 0; scale: 0.94; filter: blur(6px); }\n}\n@keyframes deictic-draw {\n from { stroke-dashoffset: 1; }\n}\n@keyframes deictic-flow {\n from { stroke-dashoffset: 0.14; opacity: 1; }\n to { stroke-dashoffset: -1; opacity: 0; }\n}\n@keyframes deictic-pulse {\n to { outline-offset: 14px; outline-color: transparent; }\n}\n/* The tool panel (tools.ts): the plugins' tools in a bar on an edge of the window, there while it's of use. */\n.tool-panel {\n position: fixed;\n z-index: 2147483647;\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 6px 8px;\n border: 1px solid rgb(255 255 255 / 0.1);\n border-radius: 12px;\n font: 13px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n background: linear-gradient(rgb(39 39 42 / 0.92), rgb(24 24 27 / 0.96));\n backdrop-filter: blur(24px) saturate(1.8);\n box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4), 0 16px 40px -8px rgb(0 0 0 / 0.55), inset 0 1px 0 rgb(255 255 255 / 0.08);\n user-select: none;\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.15s, visibility 0s 0.15s;\n}\n.tool-panel.shown { opacity: 1; visibility: visible; transition: opacity 0.15s; }\n.tool-panel.vertical, .tool-panel.vertical .tool-group { flex-direction: column; }\n.tool-panel .tool-group { display: flex; align-items: center; gap: 4px; }\n/* Groups of one section side by side, as close as the tools in a group are: the bar's gap is for between sections. */\n.tool-panel .tool-group + .tool-group { margin-left: -2px; }\n.tool-panel.vertical .tool-group + .tool-group { margin: -2px 0 0; }\n.tool-panel .grip { display: inline-flex; padding: 2px; color: var(--deictic-muted); cursor: grab; touch-action: none; }\n.tool-panel .grip:active { cursor: grabbing; }\n.tool-panel .grip svg { width: 16px; height: 16px; }\n.tool-panel .sep { align-self: stretch; width: 1px; background: rgb(255 255 255 / 0.12); }\n.tool-panel.vertical .sep { width: auto; height: 1px; }\n/* A group with nothing to show now (a plugin's, hidden) has no line of its own either. */\n.tool-panel .sep:has(+ [hidden]) { display: none; }\n.tool-panel [hidden] { display: none; }\n.tool-panel button.icon { width: 28px; height: 26px; border-radius: 6px; color: var(--deictic-fg); }\n.tool-panel button.icon svg { width: 16px; height: 16px; }\n.tool-panel button[aria-pressed='true'], .tool-panel button[aria-pressed='true']:hover {\n color: var(--deictic-on-accent);\n background: var(--deictic-accent);\n}\n.tool-panel button.problem { color: var(--deictic-problem); }\n/*\n * The drawer (drawer.ts): on the window's side, as tall as what's in it, there while it's of use. Its\n * sections are the plugins', each with its own styles; these are what they share.\n */\n.drawer {\n position: fixed;\n top: 12px;\n right: 12px;\n z-index: 2147483646;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n width: 296px;\n max-width: calc(100vw - 24px);\n max-height: calc(100vh - 24px);\n border: 1px solid rgb(255 255 255 / 0.1);\n border-radius: 12px;\n font: 12px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n background: linear-gradient(rgb(39 39 42 / 0.92), rgb(24 24 27 / 0.96));\n backdrop-filter: blur(24px) saturate(1.8);\n box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4), 0 16px 40px -8px rgb(0 0 0 / 0.55), inset 0 1px 0 rgb(255 255 255 / 0.08);\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.15s, visibility 0s 0.15s;\n}\n.drawer.left { right: auto; left: 12px; }\n.drawer.shown { opacity: 1; visibility: visible; transition: opacity 0.15s; }\n.drawer.emptied { transition: none; }\n.drawer [hidden] { display: none; }\n.drawer-sections, .drawer-view { display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 10px; overflow-y: auto; scrollbar-width: thin; }\n.drawer-view { gap: 8px; }\n.drawer-section h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font: 600 10px/1.4 system-ui, sans-serif; letter-spacing: 0.06em; text-transform: uppercase; color: var(--deictic-muted); }\n.drawer-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }\n.drawer-row { display: flex; align-items: center; gap: 2px; padding-right: 4px; border: 1px solid rgb(255 255 255 / 0.08); border-radius: 8px; background: rgb(255 255 255 / 0.04); }\n.drawer-row:hover { border-color: rgb(255 255 255 / 0.16); }\n/* A row one height whether it has a picture, and the picture one size, loaded or not: nothing moves as one comes. */\n.drawer-open { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; height: 32px; padding: 0 6px; border: 0; text-align: left; font-size: 12px; }\n.drawer-open img { flex: none; display: block; width: 36px; height: 24px; object-fit: cover; border-radius: 4px; background: rgb(255 255 255 / 0.08); }\n.drawer-open svg { flex: none; width: 12px; height: 12px; }\n.drawer-head { display: flex; align-items: center; gap: 6px; margin: -4px 24px 0 -4px; }\n/* Folding it away: the button in its corner, and the pill it folds to, which counts what's in it. */\n.drawer-fold { position: absolute; top: 6px; right: 6px; z-index: 1; width: 22px; height: 22px; border-radius: 6px; color: var(--deictic-muted); }\n.drawer-fold svg { width: 14px; height: 14px; }\n.drawer-sections > .drawer-section:first-child h3 { margin-right: 22px; }\n.drawer-pill { display: none; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: inherit; font: 600 12px/1 system-ui, sans-serif; color: var(--deictic-fg); }\n.drawer-pill svg { width: 16px; height: 16px; }\n.drawer-pill.news span { padding: 2px 6px; border-radius: 8px; color: var(--deictic-on-accent); background: var(--deictic-accent); }\n.drawer.folded { width: auto; }\n.drawer.folded > :not(.drawer-pill) { display: none; }\n.drawer.folded .drawer-pill { display: inline-flex; }\n.drawer-title { font-weight: 600; }\n/* What a tool that picks a point takes the pointer with, over the page and under the popup. */\n.tool-surface { position: fixed; inset: 0; z-index: 2147483645; cursor: crosshair; }\n.lightbox {\n position: fixed;\n inset: 0;\n z-index: 2147483647;\n display: flex;\n align-items: center;\n justify-content: center;\n font: 13px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n}\n.lb-backdrop { position: absolute; inset: 0; background: rgb(9 9 11 / 0.72); backdrop-filter: blur(2px); }\n.lb-stage {\n position: relative;\n display: flex;\n flex-direction: column;\n max-width: 92vw;\n max-height: 90vh;\n border: 1px solid var(--deictic-line);\n border-radius: 10px;\n background: var(--deictic-bg);\n box-shadow: 0 24px 64px rgb(0 0 0 / 0.5);\n transform-origin: 0 0;\n overflow: hidden;\n}\n.lb-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--deictic-line); }\n.lb-title { font-weight: 600; }\n.lb-count { color: var(--deictic-muted); font-size: 12px; font-variant-numeric: tabular-nums; }\n.lb-actions { display: flex; gap: 6px; margin-left: auto; }\n.lb-body { display: flex; justify-content: center; min-height: 0; background: #09090b; }\n.lb-image { display: block; max-width: 92vw; max-height: calc(90vh - 48px); object-fit: contain; }\n.lb-page { display: block; width: min(1280px, 92vw); height: min(860px, calc(90vh - 48px)); border: 0; background: #18181b; }\n.lb-audio { display: flex; align-items: center; gap: 12px; width: min(640px, 86vw); padding: 20px 16px; }\n.lb-play {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n color: var(--deictic-on-accent);\n background: var(--deictic-accent);\n}\n.lb-play svg { width: 16px; height: 16px; }\n.lb-wave { flex: 1; min-width: 0; height: 56px; cursor: pointer; border-radius: 4px; }\n.lb-wave:focus-visible { outline: 1px solid var(--deictic-accent); outline-offset: 2px; }\n.lb-time { flex: none; min-width: 9ch; text-align: right; font: 12px ui-monospace, monospace; color: var(--deictic-muted); }\n.lb-prev, .lb-next {\n position: absolute;\n top: 50%;\n translate: 0 -50%;\n width: 40px;\n height: 40px;\n padding: 0;\n border: 1px solid var(--deictic-line);\n border-radius: 50%;\n display: grid;\n place-items: center;\n background: var(--deictic-bg);\n}\n.lb-prev svg, .lb-next svg { width: 20px; height: 20px; }\n.lb-prev { left: 16px; }\n.lb-next { right: 16px; }\n.lightbox.pinned { position: relative; inset: auto; z-index: auto; display: block; padding: 0 64px; }\n.lightbox.pinned .lb-stage { max-width: 100%; max-height: none; }\n.lightbox.pinned .lb-page { width: 100%; height: 420px; }\n.lightbox.pinned .lb-image { max-width: 100%; max-height: 420px; }\n.lightbox.pinned .lb-backdrop { display: none; }\n.lightbox.pinned .lb-audio { width: 100%; box-sizing: border-box; }\n.lightbox.pinned .lb-close { display: none; }\n.tip {\n position: fixed;\n left: 0;\n top: 0;\n z-index: 2147483647;\n max-width: 280px;\n padding: 3px 6px;\n border: 1px solid var(--deictic-line);\n border-radius: 4px;\n font: 12px/1.4 system-ui, sans-serif;\n color: var(--deictic-fg);\n background: #09090b;\n box-shadow: 0 4px 12px rgb(0 0 0 / 0.3);\n pointer-events: none;\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.12s;\n}\n.tip.shown { visibility: visible; opacity: 1; }\n/* A control's keys, after its name: caps, as on a keyboard. */\n.tip kbd {\n display: inline-block;\n box-sizing: border-box;\n min-width: 18px;\n margin-left: 3px;\n padding: 0 4px;\n border: 1px solid var(--deictic-line);\n border-bottom-width: 2px;\n border-radius: 4px;\n font: 11px/15px ui-monospace, monospace;\n text-align: center;\n color: var(--deictic-fg);\n background: rgb(255 255 255 / 0.08);\n}\n.tip kbd:first-of-type { margin-left: 6px; }\n.tip kbd:first-child { margin-left: 0; }\nbutton {\n font: inherit;\n color: inherit;\n background: transparent;\n border: 1px solid var(--deictic-line);\n border-radius: 4px;\n padding: 1px 7px;\n cursor: pointer;\n}\nbutton:hover { border-color: var(--deictic-muted); }\nbutton:disabled { opacity: 0.5; cursor: default; }\nbutton:disabled:hover { border-color: var(--deictic-line); }\n/* One ring for whatever the keyboard lands on, in place of each browser's own. */\nbutton:focus-visible, a:focus-visible { outline: 1px solid var(--deictic-accent); outline-offset: 1px; }\nbutton.icon {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 22px;\n height: 22px;\n padding: 0;\n border: 0;\n color: var(--deictic-muted);\n}\nbutton.icon svg { width: 14px; height: 14px; }\nbutton.icon:hover:not(:disabled) { color: var(--deictic-fg); background: rgb(255 255 255 / 0.08); }\nbutton.primary {\n background: var(--deictic-accent);\n border-color: var(--deictic-accent);\n color: var(--deictic-on-accent);\n box-shadow: 0 4px 16px -4px rgb(18 179 88 / 0.6);\n}\ninput, textarea {\n box-sizing: border-box;\n width: 100%;\n font: 12px ui-monospace, monospace;\n color: inherit;\n background: rgb(0 0 0 / 0.35);\n border: 1px solid var(--deictic-line);\n border-radius: 6px;\n padding: 4px 6px;\n}\ninput:focus, textarea:focus { outline: 1px solid var(--deictic-accent); }\ncode { font: 12px ui-monospace, monospace; }\n/* Border-box, as the popup holds the body's height by its whole box while a tab reads. */\n.body { box-sizing: border-box; padding: 12px; overflow: auto; }\n.status { padding: 0 12px 10px; font-size: 12px; color: var(--deictic-muted); }\n.status:empty { display: none; }\n.status.problem { color: var(--deictic-problem); }\n`;\n","/**\n * The tool panel: a bar of the plugins' tools, docked to an edge of the window, that its grip drags to any other.\n * It shows while a shortcut's keys are held, as the page dims to point on, and stays for as long as it's in use: a\n * tool has the page (`hold`), something goes on that its controls end (`keep`, a recording), or the pointer is on it.\n *\n * A plugin adds its controls as a group (`add`), each a button named by its `title`, with its key in\n * `aria-keyshortcuts`: the panel hears the keys, so a tool's key is its button's click. One tool has the page at a\n * time. The pointer, the panel's own, is none of them: the page is the page's.\n */\nimport type { Spot, ToolPanel } from '#src/index.ts';\n\nimport { controlFor, div } from './dom.ts';\n\ntype Edge = 'top' | 'bottom' | 'left' | 'right';\n/** Where the bar is: the edge it's docked to, and how far along it, from 0 to 1. */\ninterface Dock {\n edge: Edge;\n along: number;\n}\n\nconst DOCK = 'deictic:tools';\nconst MARGIN = 12;\n/** How long the panel outlasts the keys, in milliseconds: time to get the pointer to it. */\nconst LINGER = 600;\n\nconst svg = (paths: string) =>\n `<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">${paths}</svg>`;\nconst GRIP = svg(\n '<circle cx=\"9\" cy=\"6\" r=\"1\"/><circle cx=\"15\" cy=\"6\" r=\"1\"/><circle cx=\"9\" cy=\"12\" r=\"1\"/><circle cx=\"15\" cy=\"12\" r=\"1\"/><circle cx=\"9\" cy=\"18\" r=\"1\"/><circle cx=\"15\" cy=\"18\" r=\"1\"/>',\n);\nconst POINTER = svg('<path d=\"M5 3l14 7-6 2-2 6z\"/>');\n\nfunction storedDock(): Dock {\n try {\n const dock = JSON.parse(localStorage.getItem(DOCK) ?? 'null') as Dock | null;\n if (dock !== null && ['top', 'bottom', 'left', 'right'].includes(dock.edge) && dock.along >= 0 && dock.along <= 1) return dock;\n } catch {\n // Storage can be off, or hold something else: the default, then.\n }\n return { edge: 'bottom', along: 0.5 };\n}\n\n/** Puts the bar on its edge, laid out along it, and how far along. */\nfunction place(bar: HTMLElement, { edge, along }: Dock): void {\n const vertical = edge === 'left' || edge === 'right';\n bar.classList.toggle('vertical', vertical);\n // Said too, for whatever reads it: the overlay's tooltip puts a tip beside a tool of a bar that runs down.\n bar.setAttribute('aria-orientation', vertical ? 'vertical' : 'horizontal');\n const { width, height } = bar.getBoundingClientRect();\n const across = (room: number, size: number) => `${MARGIN + along * Math.max(0, room - size - MARGIN * 2)}px`;\n Object.assign(bar.style, {\n left: edge === 'left' ? `${MARGIN}px` : edge === 'right' ? `${innerWidth - width - MARGIN}px` : across(innerWidth, width),\n top: edge === 'top' ? `${MARGIN}px` : edge === 'bottom' ? `${innerHeight - height - MARGIN}px` : across(innerHeight, height),\n });\n}\n\n/** Dragging the bar by its grip, freely; let go, it docks to the nearest edge. */\nfunction draggable(bar: HTMLElement, grip: HTMLElement, docked: (dock: Dock) => void): void {\n grip.addEventListener('pointerdown', (e) => {\n if (e.button !== 0) return;\n e.preventDefault();\n grip.setPointerCapture(e.pointerId);\n const start = bar.getBoundingClientRect();\n const dx = e.clientX - start.left;\n const dy = e.clientY - start.top;\n const move = (m: PointerEvent) => {\n bar.style.left = `${m.clientX - dx}px`;\n bar.style.top = `${m.clientY - dy}px`;\n };\n const up = () => {\n grip.removeEventListener('pointermove', move);\n const r = bar.getBoundingClientRect();\n const x = r.left + r.width / 2;\n const y = r.top + r.height / 2;\n const away: [Edge, number][] = [\n ['left', x],\n ['right', innerWidth - x],\n ['top', y],\n ['bottom', innerHeight - y],\n ];\n const [edge] = away.reduce((a, b) => (b[1] < a[1] ? b : a));\n const ratio = (at: number, room: number) => Math.min(1, Math.max(0, at / room));\n docked({ edge, along: edge === 'left' || edge === 'right' ? ratio(y, innerHeight) : ratio(x, innerWidth) });\n };\n grip.addEventListener('pointermove', move);\n grip.addEventListener('pointerup', up, { once: true });\n });\n}\n\nexport interface Tools extends ToolPanel {\n /** Whether a shortcut's keys are held: the panel shows while they are. */\n point: (on: boolean) => void;\n /** The edge of the window it's docked to. */\n edge: () => Edge;\n}\n\nexport interface ToolsOptions {\n /** The marked element at a point of the window, or the nearest to it, and where the point is in it. */\n spotAt: (x: number, y: number) => Spot | undefined;\n /** Whether a point of the page is being picked: what's under the pointer is lit meanwhile, as pointing lights it. */\n aim: (on: boolean) => void;\n}\n\nexport function toolPanel(root: ShadowRoot, { spotAt, aim }: ToolsOptions): Tools {\n const bar = div('tool-panel');\n bar.setAttribute('role', 'toolbar');\n bar.setAttribute('aria-label', 'deictic tools');\n const grip = Object.assign(document.createElement('span'), { className: 'grip', title: 'Drag to any edge', innerHTML: GRIP });\n const pointer = Object.assign(document.createElement('button'), {\n type: 'button',\n className: 'icon',\n title: 'Pointer',\n innerHTML: POINTER,\n });\n pointer.setAttribute('aria-label', 'Pointer');\n pointer.setAttribute('aria-keyshortcuts', 'V');\n bar.append(grip, pointer);\n // Each plugin's group as it was added: where each goes is worked out from all of them (`order`), as a later one\n // may belong before an earlier one.\n const added: { group: HTMLElement; section?: string; last: boolean }[] = [];\n /**\n * The groups in their places: those of no section, then each section (in the order its first group came, its groups\n * side by side), then those of none that asked to be `last`. Within a section, its `last` ones are at its end. A\n * line between each.\n */\n const order = () => {\n const plain = added.filter((a) => a.section === undefined);\n const sections = [...new Set(added.flatMap((a) => a.section ?? []))].map((name) => {\n const of = added.filter((a) => a.section === name);\n // Named on each, for a plugin's styles to tell its section's other groups by (a recording hides them).\n for (const a of of) a.group.dataset.section = name;\n return [...of.filter((a) => !a.last), ...of.filter((a) => a.last)].map((a) => a.group);\n });\n const blocks = [\n ...plain.filter((a) => !a.last).map((a) => [a.group]),\n ...sections,\n ...plain.filter((a) => a.last).map((a) => [a.group]),\n ];\n for (const sep of bar.querySelectorAll(':scope > .sep')) sep.remove();\n for (const block of blocks) bar.append(Object.assign(document.createElement('span'), { className: 'sep' }), ...block);\n };\n root.append(bar);\n\n let dock = storedDock();\n const replace = () => place(bar, dock);\n addEventListener('resize', replace);\n draggable(bar, grip, (next) => {\n dock = next;\n replace();\n try {\n localStorage.setItem(DOCK, JSON.stringify(dock));\n } catch {\n // Not kept, then: the next page has it at the bottom.\n }\n });\n\n let pointing = false;\n let over = false;\n let keeps = 0;\n // The tool that has the page, as what makes it let go.\n let holder: (() => void) | undefined;\n let leaving: ReturnType<typeof setTimeout> | undefined;\n const shown = () => bar.classList.contains('shown');\n const show = () => {\n clearTimeout(leaving);\n leaving = undefined;\n pointer.setAttribute('aria-pressed', String(holder === undefined));\n const on = pointing || over || keeps > 0 || holder !== undefined;\n if (on === shown()) return;\n if (!on) {\n // Not at once: the keys are let go on the way to it.\n leaving = setTimeout(() => bar.classList.remove('shown'), LINGER);\n return;\n }\n bar.classList.add('shown');\n // Its groups may have changed size since it was last shown.\n replace();\n };\n bar.addEventListener('pointerenter', () => {\n over = true;\n show();\n });\n bar.addEventListener('pointerleave', () => {\n over = false;\n show();\n });\n // Laid out again as its groups change: a recording's controls come and go.\n new ResizeObserver(() => shown() && replace()).observe(bar);\n\n const letGo = () => {\n const left = holder;\n holder = undefined;\n left?.();\n show();\n };\n pointer.addEventListener('click', letGo);\n\n window.addEventListener(\n 'keydown',\n (e) => {\n if (e.repeat || !(pointing || holder !== undefined)) return;\n // A modal of ours has the keys while it's there: a note being typed, a picture drawn on, the lightbox.\n if (root.querySelector('[data-deictic-modal]') !== null) return;\n const [target] = e.composedPath();\n const typing = target instanceof HTMLElement && target.matches('input, textarea, select, [contenteditable]');\n // Esc is the tool's before the popup's, from the popup's field too (a task being typed while marks are drawn).\n if (e.key === 'Escape' && holder !== undefined) {\n e.preventDefault();\n e.stopImmediatePropagation();\n return letGo();\n }\n // What's typed in a field of ours is the field's (a note, a task's words). A field of the page's has its keys\n // too while they're only held to point: Alt with a letter types one there. Once a tool has the page, the page\n // isn't in use, and a field of its that still has the focus gets none.\n if (typing && (holder === undefined || target.getRootNode() === root)) return;\n // While the keys are held to point, a key alone is its tool whatever is held with it.\n const control = controlFor(bar, e, pointing);\n if (control === undefined) return;\n e.preventDefault();\n e.stopImmediatePropagation();\n control.click();\n },\n true,\n );\n\n const hold: ToolPanel['hold'] = (left) => {\n letGo();\n holder = left;\n show();\n return () => {\n if (holder !== left) return;\n holder = undefined;\n show();\n };\n };\n\n return {\n add: (group, options) => {\n added.push({ group, ...(options?.section === undefined ? {} : { section: options.section }), last: options?.last === true });\n order();\n },\n hold,\n keep: () => {\n keeps++;\n show();\n let kept = true;\n return () => {\n if (!kept) return;\n kept = false;\n keeps--;\n show();\n };\n },\n pick: () =>\n new Promise((done) => {\n // Over the page and under the popup and the panel: it takes the pointer, so the press is no click on the page.\n const surface = div('tool-surface');\n root.append(surface);\n const end = (spot: Spot | undefined) => {\n surface.remove();\n aim(false);\n done(spot);\n };\n const release = hold(() => end(undefined));\n aim(true);\n surface.addEventListener('pointerdown', (e) => {\n if (e.button !== 0) return;\n e.preventDefault();\n release();\n end(spotAt(e.clientX, e.clientY));\n });\n }),\n point: (on) => {\n pointing = on;\n show();\n },\n edge: () => dock.edge,\n };\n}\n","/**\n * One tooltip for everything deictic draws in a shadow root: whatever has a `title` (or `data-tip`) shows it\n * in a box of ours, soon after the pointer rests or focus lands, instead of the browser's, which comes late\n * and looks like nothing else here. Plugins only set `title`, as they would anywhere; the first hover moves\n * it to `data-tip`, so the browser's own stays away, and gives a textless control the title as its name.\n * The box is fixed in the root, so no panel's scrolling clips it.\n *\n * A control's keys (`aria-keyshortcuts`, as `Control+Z`) are in its tip too, each a keycap after the words, and a\n * tip of their own for a control whose text already names it.\n */\nconst DELAY = 300;\nconst KEYS = 'aria-keyshortcuts';\n/** A key as its cap reads, where that isn't its name. */\nconst CAPS: Record<string, string> = { Control: 'Ctrl', Meta: '⌘', Escape: 'Esc', Backspace: '⌫', Enter: '↵' };\n\n/** The first of a control's shortcuts, a cap for each key held together. */\nfunction capsOf(el: Element): HTMLElement[] {\n const [first = ''] = (el.getAttribute(KEYS) ?? '').split(' ');\n return first === '' ? [] : first.split('+').map((key) => Object.assign(document.createElement('kbd'), { textContent: CAPS[key] ?? key }));\n}\n\nexport function tooltips(root: ShadowRoot): void {\n const tip = document.createElement('div');\n tip.className = 'tip';\n tip.setAttribute('role', 'tooltip');\n root.append(tip);\n let timer = 0;\n let over: Element | undefined;\n\n const hide = () => {\n clearTimeout(timer);\n over = undefined;\n tip.classList.remove('shown');\n };\n const show = (el: Element) => {\n const text = el.getAttribute('data-tip') ?? '';\n const caps = capsOf(el);\n if ((text === '' && caps.length === 0) || !el.isConnected) return hide();\n tip.replaceChildren(text, ...caps);\n // Last in the root, over a modal or toolbar added since at the same z-index.\n if (tip !== root.lastElementChild) root.append(tip);\n tip.classList.add('shown');\n const r = el.getBoundingClientRect();\n const t = tip.getBoundingClientRect();\n // Beside it in a toolbar that runs down the window's side: below would be over the next tool.\n if (el.closest('[aria-orientation=\"vertical\"]') !== null) {\n const left = r.right + 6 + t.width > innerWidth - 8 ? r.left - 6 - t.width : r.right + 6;\n const top = Math.max(8, Math.min(r.top + r.height / 2 - t.height / 2, innerHeight - t.height - 8));\n Object.assign(tip.style, { left: `${left}px`, top: `${top}px` });\n return;\n }\n // Centred below it, kept on screen; above it where there's no room below.\n const left = Math.max(8, Math.min(r.left + r.width / 2 - t.width / 2, innerWidth - t.width - 8));\n const top = r.bottom + 6 + t.height > innerHeight - 8 ? r.top - 6 - t.height : r.bottom + 6;\n Object.assign(tip.style, { left: `${left}px`, top: `${top}px` });\n };\n /** The element with a tip around where the event happened, its `title` taken over the first time. */\n const tipped = (e: Event) => {\n for (const node of e.composedPath()) {\n if (!(node instanceof Element)) continue;\n if (node === tip) return undefined;\n // A frame's title is its name for assistive tech, not a tip; what's in it has tips of its own.\n if (node.localName === 'iframe') return undefined;\n const title = node.getAttribute('title');\n if (title !== null) {\n node.removeAttribute('title');\n if (title === '') continue;\n node.setAttribute('data-tip', title);\n // A control with no text of its own (an icon, ×, ↶) is known by its tip; one with text keeps its name.\n if (!node.hasAttribute('aria-label') && (node.textContent ?? '').trim().length <= 1) node.setAttribute('aria-label', title);\n else node.setAttribute('aria-description', title);\n }\n if (node.hasAttribute('data-tip') || node.hasAttribute(KEYS)) return node;\n }\n return undefined;\n };\n const enter = (e: Event) => {\n const el = tipped(e);\n if (el === over) return;\n hide();\n if (el === undefined) return;\n over = el;\n timer = window.setTimeout(() => show(el), e.type === 'focusin' ? 0 : DELAY);\n };\n root.addEventListener('pointerover', enter);\n root.addEventListener('focusin', (e) => {\n // Focus from the keyboard only: a click focuses too, and its tip is the pointer's.\n if ((e.target as Element).matches(':focus-visible')) enter(e);\n });\n root.addEventListener('pointerout', (e) => {\n const to = (e as PointerEvent).relatedTarget;\n if (over !== undefined && !(to instanceof Node && over.contains(to))) hide();\n });\n root.addEventListener('focusout', hide);\n // A press acts, and what it changes (a mic turned on) may change the tip: the next hover shows the new one.\n root.addEventListener('pointerdown', hide);\n addEventListener('scroll', hide, { capture: true, passive: true });\n}\n","/**\n * The tray: what plugins made on the page that nothing has taken yet (a shot, a recording, a voice clip), for\n * whatever takes it next, as a task does. Kept in the tab's session storage, as JSON, so it's still there on the\n * tab's next page: a recording that carried on to it ends there, and what was taken before it is with it.\n */\nimport type { Tray, TrayItem } from '#src/index.ts';\n\nconst KEY = 'deictic:tray';\n\nfunction stored(): TrayItem[] {\n try {\n const kept: unknown = JSON.parse(sessionStorage.getItem(KEY) ?? '[]');\n return Array.isArray(kept) ? (kept as TrayItem[]) : [];\n } catch {\n // Storage can be off, or hold something else: an empty tray, then.\n return [];\n }\n}\n\nexport function tray(): Tray {\n let items = stored();\n const listeners = new Set<() => void>();\n const changed = () => {\n try {\n sessionStorage.setItem(KEY, JSON.stringify(items));\n } catch {\n // Not kept past this page, then.\n }\n for (const listener of listeners) listener();\n };\n return {\n list: (plugin) => items.filter((item) => plugin === undefined || item.plugin === plugin),\n add: (plugin, id, value) => {\n items = [...items.filter((item) => item.plugin !== plugin || item.id !== id), { plugin, id, value }];\n changed();\n },\n remove: (plugin, id) => {\n const left = items.filter((item) => item.plugin !== plugin || (id !== undefined && item.id !== id));\n if (left.length === items.length) return;\n items = left;\n changed();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n","/**\n * `deictic/client`: the overlay the page loads in dev. Hold a shortcut's keys (Alt, deictic's own,\n * by default) and point: the page dims around the element under the pointer that the source marked\n * (`tools/locate.ts`), which stays lit, with its tag, its place and how many elements share it (`lighting.ts`).\n * Press the shortcut's button to open the popup beside it: a tab for each plugin with a panel, at the one used\n * last, or at a plugin's own where its shortcut was pressed.\n *\n * Everything drawn sits in one shadow root, so neither the page's styles nor ours cross over. A\n * panel's undo and redo are its tab's on its element: the latest change that plugin made there.\n */\nimport type {\n ClientContext,\n ClientPlugin,\n LightboxItem,\n PanelContext,\n Point,\n Problem,\n Resumed,\n Spot,\n Standalone,\n Target,\n} from '#src/index.ts';\nimport { gestureOf, type Shortcut } from '#src/shortcut.ts';\n\nimport { dropAway, keepAway, keptAway } from './away.ts';\nimport { named, tell } from './component.ts';\nimport { ATTRIBUTE, div, nameOf, POPUP_CLOSED, POPUP_OPENED, type PopupOpened, reduced, sameAs, targetOf } from './dom.ts';\nimport { drawerIn } from './drawer.ts';\nimport { openLightbox } from './lightbox.ts';\nimport { CLEAR, type Lighting, spotlight, spotOf } from './lighting.ts';\nimport { STYLE } from './style.ts';\nimport { toolPanel } from './tools.ts';\nimport { tooltips } from './tooltip.ts';\nimport { tray } from './tray.ts';\n\n// For a plugin's page half that records the mic, or shows a clip: the waveforms the lightbox draws.\nexport { drawBars, liveWaveform, peaksOf, type Colors } from './waveform.ts';\nexport { targetOf } from './dom.ts';\n\nexport interface StartOptions {\n /** The dev server's base URL, ending in `/`. */\n base: string;\n /** deictic's own shortcut, checked: it opens the popup at the tab used last. None where it's turned off. */\n shortcut?: Required<Shortcut>;\n /** Each plugin with a half in the page, and its own shortcut as the bundler's plugin checked it, where it has one. */\n plugins: { plugin: ClientPlugin; shortcut?: Required<Shortcut>; options?: unknown }[];\n /** What answers the requests where there's no dev server to: a `standalone` build's. */\n server?: Standalone;\n}\n\n/** A request to the endpoints, by its URL: to the dev server, or to what stands in for it. */\ntype Send = (url: string, init?: RequestInit) => Promise<Response>;\n\ntype Mount = (panel: HTMLElement, context: PanelContext<unknown, unknown>) => (() => void) | void;\n\n/** A plugin with a panel: a tab in the popup. */\ninterface Tab {\n plugin: ClientPlugin;\n mount: Mount;\n}\n\n/** An arrow pointing up and out: the link leaves the page for the editor. */\nconst OUT = icon('M7 17 17 7M8 7h9v9', 2.25);\n// Drawn, as the arrows and the cross of a system's font differ in size and weight from one to the next.\nconst UNDO = icon('M9 14 4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11');\nconst REDO = icon('m15 14 5-5-5-5M20 9H9.5a5.5 5.5 0 0 0 0 11H13');\nconst CLOSE = icon('M18 6 6 18M6 6l12 12');\n/** Where the tab used last is kept, for deictic's own shortcut to open it again. */\nconst LAST = 'deictic:tab';\n/** How long a read may take, in milliseconds, before the popup says it's reading. */\nconst SLOW = 200;\nconst STARTED = Symbol.for('deictic');\n\n/** The nearest marked element around `el`, out through shadow roots to their hosts. */\nfunction markedAround(el: Element): Element | undefined {\n for (let at: Element | undefined = el; at !== undefined;) {\n const marked = at.closest(`[${ATTRIBUTE}]`);\n if (marked !== null) return marked;\n const root = at.getRootNode();\n at = root instanceof ShadowRoot ? root.host : undefined;\n }\n return undefined;\n}\n\nfunction icon(path: string, width = 2): string {\n return `<svg viewBox=\"0 0 24 24\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"${width}\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"${path}\"/></svg>`;\n}\n\n/** What the overlay keeps once started, for `popupIn` to show the popup with. */\ninterface Started {\n base: string;\n send: Send;\n contextOf: (name: string) => ClientContext;\n tabs: Tab[];\n /** Opens the popup over the page on an element, at a tab or the one used last: `openPopup`. */\n open: (element: Element, tab?: string) => boolean;\n}\n\nlet started: Started | undefined;\n\n// The events the page hears as the popup opens and closes: kept beside the mark, where a plugin's page half reads them.\nexport { POPUP_CLOSED, POPUP_OPENED, type PopupOpened } from './dom.ts';\n\n/**\n * Opens the popup over the page on `element`, as deictic's own shortcut does: at `tab` (a plugin's name), or at the\n * tab used last. For a page that opens it from a gesture of its own, as deictic's site does on a plain click.\n * Answers whether it opened: not where no plugin has a tab, or `element` has no mark. The overlay must have started.\n */\nexport function openPopup(element: Element, { tab }: { tab?: string } = {}): boolean {\n if (started === undefined) throw new Error('deictic: the overlay has not started, so there is no popup to open');\n return started.open(element, tab);\n}\n\n/**\n * Shows the popup in `container`, open at a tab (`tab`, a plugin's name, or the first) on `element`, where\n * the page puts it rather than over the page: a page of the popup's states, to point at and fix, as deictic's\n * own site does. It's the real popup, its tabs and plugins working. Closing it, or a tab's `away`, opens it\n * again in place. It draws in `container`'s shadow root, made if there isn't one. Answers what removes it.\n * The overlay must have started (the dev server's client module starts it), and `element` be marked.\n */\nexport function popupIn(container: Element, { tab: name, element }: { tab?: string; element: Element }): () => void {\n if (started === undefined) throw new Error('deictic: the overlay has not started, so there is no popup to show');\n const target = targetOf(element);\n if (target === undefined) throw new Error(`deictic: ${nameOf(element)} has no ${ATTRIBUTE} mark to open the popup on`);\n const { base, send, contextOf, tabs } = started;\n // A tab shown here isn't one a person chose: the popup over the page keeps opening at theirs.\n const remember = () => {};\n const tab = tabs.find((t) => t.plugin.name === name) ?? tabs[0];\n if (tab === undefined) throw new Error('deictic: no plugin has a tab to show');\n const root = container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = `${STYLE}:host { display: block; }`;\n root.replaceChildren(style);\n tooltips(root);\n let panel: { close: () => void } | undefined;\n let gone = false;\n const open = (at: Tab, resumed?: Resumed) => {\n panel = openPanel({\n base,\n send,\n root,\n contextOf,\n tabs,\n tab: at,\n remember,\n element,\n target,\n onClose: (shown, leaving) => {\n panel = undefined;\n // Closed by its own × or Esc: open again, as the page is there to show it. Leaving for `away` comes back by `reopen`.\n if (!gone && !leaving) open(shown);\n },\n ...(resumed === undefined ? {} : { resumed }),\n reopen: (again, _, kept) => open(again, kept),\n });\n };\n open(tab);\n return () => {\n gone = true;\n panel?.close();\n style.remove();\n };\n}\n\n/**\n * Shows the lightbox in `container`, at `at`, where the page puts it rather than over everything: as `popupIn`\n * does the popup, for a page of deictic's own states. Its items step with its arrows; there's no backdrop, close\n * or keys, and an item's actions run without closing it. Answers what removes it.\n */\nexport function lightboxIn(container: Element, items: LightboxItem[], { at }: { at?: number } = {}): () => void {\n const root = container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = `${STYLE}:host { display: block; }`;\n root.replaceChildren(style);\n tooltips(root);\n const { close } = openLightbox(root, items, { ...(at === undefined ? {} : { at }), pinned: true });\n return () => {\n close();\n style.remove();\n };\n}\n\n/** Starts the overlay, once per page: the client module runs again when a module importing it is replaced. */\nexport function start({ base, shortcut: own, plugins: given, server }: StartOptions): void {\n const page = globalThis as { [STARTED]?: true };\n if (page[STARTED] === true) return;\n page[STARTED] = true;\n\n const host = document.createElement('deictic-overlay');\n const root = host.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = STYLE;\n root.append(style);\n tooltips(root);\n const lighting = spotlight(root);\n const kept = tray();\n // A tool has the page to pick a point on (`pick`): what's under the pointer is lit as while the keys are held.\n let picking = false;\n const tools = toolPanel(root, {\n spotAt: (x, y) => spotAt(x, y),\n aim: (on) => {\n picking = on;\n if (on) glance(true);\n else if (held.length === 0) hide();\n },\n });\n // Out from under the tool panel, where that's on the window's right.\n const drawer = drawerIn(root, { crowded: () => tools.edge() === 'right' });\n // What's typed in the popup is the popup's: the page hears a key from in here as one on the host, not in a field,\n // so its own shortcuts (a \"/\" to search, a \"j\" to step) would run on a task's words. Ours listen while capturing.\n for (const type of ['keydown', 'keypress', 'keyup'] as const) host.addEventListener(type, (e) => e.stopPropagation());\n document.documentElement.append(host);\n\n // Each plugin's API, set up before any panel opens. `use` reads it when asked, so a setup may keep\n // `use` for later, not call it: the plugin it asks for may not be set up yet.\n const apis = new Map<string, unknown>();\n const send: Send =\n server === undefined ? (url, init) => fetch(url, init) : async (url, init) => server(new Request(new URL(url, location.href), init));\n // To the dev server, which says it and hands it on (to the board, with tasks). Whether it got there is no one's to\n // know in the page: it's said in the console too.\n const report = (problem: Problem) => {\n console.error(`deictic${problem.plugin === undefined ? '' : `/${problem.plugin}`}: ${problem.message}`);\n const init = { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(problem) };\n send(`${base}__deictic/problem`, init).catch(() => {});\n };\n const optionsOf = new Map(given.map(({ plugin, options }) => [plugin.name, options]));\n const contextOf = (name: string): ClientContext => ({\n base,\n root,\n options: optionsOf.get(name),\n use: (other) => apis.get(other) as never,\n request: (route, init) => send(`${base}__deictic/plugins/${name}/${route}`, init),\n report: (problem) => report({ ...problem, plugin: name }),\n edit: async ({ file, line, column }) => {\n const res = await send(`${base}__deictic/open?${new URLSearchParams({ file, line: String(line), column: String(column) })}`);\n if (!res.ok) throw new Error(await res.text());\n },\n // Not from under something unsaved, which a press on the page wouldn't close either: its button shakes.\n open: (plugin, element, at) => panel?.guard() !== true && openAt(plugin, element, at),\n lightbox: (items, options) => openLightbox(root, items, options),\n drawer,\n light: (element) => {\n lit = element?.isConnected === true ? element : undefined;\n relight();\n },\n tools,\n tray: kept,\n });\n for (const { plugin } of given) {\n if (plugin.setup === undefined) continue;\n try {\n apis.set(plugin.name, plugin.setup(contextOf(plugin.name)));\n } catch (e) {\n // One plugin's failure is no reason to take the others down with it.\n report(failed(plugin.name, 'set up in the page, so it does nothing there until the page loads again', e));\n }\n }\n const tabs: Tab[] = given.flatMap(({ plugin }) => (plugin.mount === undefined ? [] : [{ plugin, mount: plugin.mount }]));\n started = {\n base,\n send,\n contextOf,\n tabs,\n // Not over a popup holding something unsaved: the press that asked shook its button (`openPanel`).\n open: (element, tab) => tabs.length > 0 && panel?.unsaved() !== true && openAt(tab ?? last().plugin.name, element),\n };\n const last = () => {\n let name: string | null = null;\n try {\n name = localStorage.getItem(LAST);\n } catch {\n // Storage can be off: the first tab, then.\n }\n return tabs.find((t) => t.plugin.name === name) ?? tabs[0]!;\n };\n const remember = (tab: Tab) => {\n try {\n localStorage.setItem(LAST, tab.plugin.name);\n } catch {\n // Not kept, then: the next open starts at the first tab.\n }\n };\n // What opens the popup, and at which tab: deictic's own shortcut at the one used last, each\n // plugin's at its own.\n const plugins = [\n ...(own === undefined || tabs.length === 0 ? [] : [{ shortcut: own, gesture: gestureOf(own), tab: last, named: false }]),\n ...given.flatMap(({ plugin, shortcut }) => {\n if (shortcut === undefined) return [];\n const tab = tabs.find((t) => t.plugin === plugin);\n if (tab !== undefined) return [{ shortcut, gesture: gestureOf(shortcut), tab: () => tab, named: true }];\n console.error(`deictic: ${plugin.name} has a shortcut, but its page half has no \\`mount\\` to draw a tab with`);\n return [];\n }),\n ];\n\n let pointer: { x: number; y: number } | undefined;\n let frame = 0;\n let panel: ReturnType<typeof openPanel> | undefined;\n\n /** The plugins whose keys are held: several, where they share keys and differ by button. */\n const heldBy = (e: MouseEvent | KeyboardEvent) => plugins.filter((p) => p.gesture.held(e));\n /** The plugin a press opens. */\n const pressedBy = (e: MouseEvent) => plugins.find((p) => p.gesture.held(e) && e.button === p.gesture.button);\n /**\n * The marked element at a point, and what's under the pointer inside it where that differs: down through\n * open shadow roots but the overlay's own, as a page showing the popup (`popupIn`) has it in one. `through` the\n * overlay, where it's the overlay that has the pointer: a tool's surface, while a point is picked.\n */\n const hitAt = (x: number, y: number, through = false) => {\n let under = (through ? document.elementsFromPoint(x, y).find((el) => el !== host) : document.elementFromPoint(x, y)) ?? undefined;\n while (under !== undefined && under !== host && under.shadowRoot !== null) {\n const inside = under.shadowRoot.elementFromPoint(x, y);\n if (inside === null || inside === under) break;\n under = inside;\n }\n const el = under === undefined || under === host ? undefined : markedAround(under);\n return el === undefined ? undefined : { el, pointed: under === el ? undefined : under };\n };\n // The plugins whose keys are held now, as the last event said: what's pointed at is shown while there are any.\n let held: typeof plugins = [];\n // What plugins show on the page while it's pointed on (`pointing`), each with what takes it away.\n let glanced: (() => void)[] | undefined;\n const glance = (on: boolean) => {\n if (on === (glanced !== undefined)) return;\n for (const end of glanced ?? []) end();\n glanced = !on\n ? undefined\n : given.flatMap(({ plugin }) => {\n try {\n return plugin.pointing === undefined ? [] : [plugin.pointing(contextOf(plugin.name))];\n } catch (e) {\n report(failed(plugin.name, 'show what it has on the page as it was pointed at', e));\n return [];\n }\n });\n };\n // An element a plugin lights from the overlay's own UI (`context.light`): lit while it says so, whatever the keys.\n let lit: Element | undefined;\n const relight = () => {\n const target = lit === undefined ? undefined : targetOf(lit);\n if (lit !== undefined && target !== undefined) return lighting.point({ el: lit, target, names: [], count: sameAs(lit).length });\n if (held.length > 0 || picking) return show(false);\n lighting.hide();\n };\n const hide = () => {\n held = [];\n tools.point(false);\n drawer.point(false);\n glance(false);\n relight();\n };\n /** The marked element at a point of the window, or the nearest to it where none is under it, and the point in it. */\n const spotAt = (x: number, y: number): Spot | undefined => {\n const away = (el: Element) => {\n const r = el.getBoundingClientRect();\n return r.width === 0 || r.height === 0\n ? Infinity\n : Math.hypot(Math.max(r.left - x, 0, x - r.right), Math.max(r.top - y, 0, y - r.bottom));\n };\n const nearest = () => {\n let found: { el: Element; far: number } | undefined;\n for (const el of document.querySelectorAll(`[${ATTRIBUTE}]`)) {\n const far = away(el);\n // The later of two as near is the inner one, or the one drawn over.\n if (far !== Infinity && (found === undefined || far <= found.far)) found = { el, far };\n }\n return found?.el;\n };\n const element = hitAt(x, y, true)?.el ?? nearest();\n if (element === undefined) return undefined;\n const r = element.getBoundingClientRect();\n return { element, at: { x: Math.round(x - r.left), y: Math.round(y - r.top) } };\n };\n const show = (glide: boolean) => {\n frame = 0;\n // On something of ours that takes the pointer (a task's pin, the tool panel): the light stays where it was, as\n // the pointer is on its way to a press there, not to another element.\n if (pointer !== undefined && !picking && held.length > 0 && document.elementFromPoint(pointer.x, pointer.y) === host) {\n if (lit !== undefined) relight();\n return;\n }\n const hit = pointer === undefined || (held.length === 0 && !picking) ? undefined : hitAt(pointer.x, pointer.y, picking);\n const el = hit?.el;\n const target = el === undefined ? undefined : targetOf(el);\n if (el === undefined || target === undefined) return lighting.hide();\n // A plugin's own shortcut says its tab, and its button where it isn't the left, which the keys alone don't tell\n // apart. deictic's own says nothing: it opens whichever tab was used last.\n const names = held.flatMap(({ tab, shortcut, named }) => {\n if (!named) return [];\n const { plugin } = tab();\n const name = plugin.label ?? plugin.name;\n return [shortcut.button === 'left' ? name : `${name} (${shortcut.button})`];\n });\n const at = pointer!;\n const tags = given.flatMap(({ plugin }) => {\n if (plugin.tag === undefined) return [];\n try {\n const tag = plugin.tag(contextOf(plugin.name), at);\n return tag === undefined ? [] : [tag];\n } catch (e) {\n report(failed(plugin.name, 'tag what was pointed at', e));\n return [];\n }\n });\n lighting.point(\n { el, ...(hit?.pointed === undefined ? {} : { pointed: hit.pointed }), target, names, count: sameAs(el).length, tags },\n glide,\n );\n };\n const update = (e: MouseEvent | KeyboardEvent) => {\n held = heldBy(e);\n if (held.length === 0 && !picking) return hide();\n tools.point(held.length > 0);\n drawer.point(held.length > 0);\n glance(true);\n if (frame === 0) frame = requestAnimationFrame(() => show(true));\n };\n\n window.addEventListener(\n 'mousemove',\n (e) => {\n pointer = { x: e.clientX, y: e.clientY };\n update(e);\n },\n { capture: true, passive: true },\n );\n window.addEventListener('keydown', update, true);\n window.addEventListener('keyup', update, true);\n window.addEventListener('blur', hide);\n // The page scrolled under the pointer: another element is under it now, or the same one elsewhere.\n window.addEventListener(\n 'scroll',\n () => {\n if ((held.length > 0 || picking) && frame === 0) frame = requestAnimationFrame(() => show(false));\n },\n { capture: true, passive: true },\n );\n let press = {};\n let opened: object | undefined;\n // The page as it is under the press, for whoever keeps it (`pressed`): before the page's own handlers, which may\n // close what was open, and before the popup takes the pointer and the focus.\n window.addEventListener(\n 'pointerdown',\n (e) => {\n if (e.composedPath().includes(host) || pressedBy(e) === undefined) return;\n const hit = hitAt(e.clientX, e.clientY);\n if (hit === undefined) return;\n for (const { plugin } of given) {\n try {\n plugin.pressed?.(contextOf(plugin.name), hit.el);\n } catch (e) {\n report(failed(plugin.name, 'keep what the page showed as it was pressed', e));\n }\n }\n },\n true,\n );\n // Alt-click on a link would otherwise download it, and on a field focus it.\n window.addEventListener(\n 'mousedown',\n (e) => {\n press = {};\n if (e.composedPath().includes(host)) return;\n if (pressedBy(e) !== undefined && hitAt(e.clientX, e.clientY) !== undefined) e.preventDefault();\n },\n true,\n );\n // A press ends in `click`, `auxclick` or `contextmenu` by its button, and a right one in two of\n // them, in an order that varies by platform; on macOS Control-click is a left `contextmenu`. Each\n // is kept from the page, and the first opens the panel.\n const pressed = (e: MouseEvent) => {\n if (e.composedPath().includes(host)) return;\n const found = pressedBy(e);\n const hit = found === undefined ? undefined : hitAt(e.clientX, e.clientY);\n const target = hit === undefined ? undefined : targetOf(hit.el);\n if (found === undefined || hit === undefined || target === undefined) return;\n e.preventDefault();\n e.stopPropagation();\n if (opened === press) return;\n opened = press;\n // Still open after this press's pointerdown, outside it: it holds something unsaved, and shook its button.\n if (panel?.unsaved() === true) return;\n openTab(found.tab(), hit.el, target, undefined, hit.pointed);\n };\n const openTab = (tab: Tab, el: Element, target: Target, resumed?: Resumed, pointed?: Element, at?: Point) => {\n hide();\n panel?.close();\n panel = openPanel({\n base,\n send,\n root,\n contextOf,\n tabs,\n tab,\n remember,\n element: el,\n ...(pointed === undefined ? {} : { pointed }),\n ...(at === undefined ? {} : { at }),\n target,\n lighting,\n onClose: () => (panel = undefined),\n ...(resumed === undefined ? {} : { resumed }),\n reopen: (again, element, kept) => {\n // Rendered again while away, or gone from the page, which moved on: the popup comes back all the same, on\n // the element as it was left, since what it kept (a recording) is about it wherever the page is now.\n const found = element.isConnected ? element : (sameAs(element)[0] ?? element);\n openTab(\n again,\n found,\n targetOf(found) ?? target,\n kept,\n pointed?.isConnected === true && found === element ? pointed : undefined,\n at,\n );\n },\n });\n };\n // What the page before this left a panel for (`away`), where that carries on here: the popup comes back when\n // it's done, on the element where this page has it, and on a stand-in for it where it doesn't.\n void keptAway().then((away) => {\n if (away === undefined) return;\n const tab = tabs.find((t) => t.plugin.name === away.tab);\n const task = tab?.plugin.resume?.(contextOf(away.tab));\n if (tab === undefined || task === undefined) return dropAway();\n const back = (resumed: Resumed) => {\n dropAway();\n const { loc, tag } = away.target;\n const absent = document.createElement(tag);\n absent.setAttribute(ATTRIBUTE, `${loc.file}:${loc.line}:${loc.column}`);\n const found = sameAs(absent).find((el) => el.localName === tag);\n // The spot only where this page has the element: there's nowhere for it otherwise.\n openTab(tab, found ?? absent, away.target, resumed, undefined, found === undefined ? undefined : away.at);\n };\n task.then(\n (result) => back({ state: away.state, result }),\n (e: unknown) => back({ state: away.state, problem: messageOf(e) }),\n );\n });\n function openAt(name: string, given: Element, at?: Point): boolean {\n const tab = tabs.find((t) => t.plugin.name === name);\n const el = given.isConnected ? given : (sameAs(given)[0] ?? undefined);\n const target = el === undefined ? undefined : targetOf(el);\n if (tab === undefined || el === undefined || target === undefined) return false;\n openTab(tab, el, target, undefined, undefined, at);\n return true;\n }\n for (const type of ['click', 'auxclick', 'contextmenu'] as const) window.addEventListener(type, pressed, true);\n}\n\ninterface PanelOptions {\n base: string;\n send: Send;\n root: ShadowRoot;\n contextOf: (name: string) => ClientContext;\n tabs: Tab[];\n /** The tab it opens at. */\n tab: Tab;\n /** Keeps the tab shown, for deictic's own shortcut to open at next. */\n remember: (tab: Tab) => void;\n element: Element;\n /** What was under the pointer inside `element`, where that differs. */\n pointed?: Element;\n /** The spot in `element` it's opened on, where it's one: what's lit, and what it's beside. */\n at?: Point;\n target: Target;\n /**\n * Over the page, beside the element: what lights the element there. Without it the popup is shown where the\n * page put it (`popupIn`): nothing on the page is lit, and Esc leaves it alone.\n */\n lighting?: Lighting;\n /** Called as it closes: the tab it showed, and whether it's leaving for a tab's `away`, to come back by `reopen`. */\n onClose: (shown: Tab, leaving: boolean) => void;\n /** What the first tab's mount gets, coming back from `away`. */\n resumed?: Resumed;\n /** Opens the popup again, at a tab on an element, coming back from `away`. */\n reopen: (tab: Tab, element: Element, resumed: Resumed) => void;\n}\n\nfunction openPanel({\n base,\n send,\n root,\n contextOf,\n tabs,\n tab: first,\n remember,\n element,\n pointed,\n at: spot,\n target,\n lighting,\n onClose,\n resumed: coming,\n reopen,\n}: PanelOptions): {\n close: () => void;\n unsaved: () => boolean;\n /** Whether it holds something unsaved, whose button it then shakes: what asks before opening another over it. */\n guard: () => boolean;\n} {\n const pinned = lighting === undefined;\n // Given to the first tab's first mount only: another tab, or a remount after an undo, starts afresh.\n let resumed = coming;\n const panel = div('panel');\n // The tabs, then the element's place and undo and redo, which are the shown tab's on this element.\n const head = div('head');\n head.setAttribute('role', 'tablist');\n const bar = div('bar');\n const where = document.createElement('a');\n where.className = 'where';\n const file = document.createElement('span');\n file.textContent = `${target.loc.file}:${target.loc.line}`;\n // What it is too, as the caption said it while pointing, which is gone once the popup is open.\n const tag = Object.assign(document.createElement('span'), { className: 'tag', textContent: tell(named(element)) });\n // An arrow out, as it leaves the page for the editor; its title is the overlay's tooltip (`tooltip.ts`).\n where.append(tag, file);\n where.insertAdjacentHTML('beforeend', OUT);\n where.title = 'Open in editor';\n where.setAttribute('aria-label', `Open ${file.textContent} in the editor`);\n // The element's place, as a request's query names it.\n const at = { file: target.loc.file, line: String(target.loc.line), column: String(target.loc.column) };\n where.href = `${base}__deictic/open?${new URLSearchParams(at)}`;\n where.addEventListener('click', (e) => {\n e.preventDefault();\n void send(where.href);\n });\n // Off until the tab's history is read: there's nothing to take back on most elements.\n const undo = iconButton(UNDO, 'Undo', 'Nothing to undo');\n const redo = iconButton(REDO, 'Redo', 'Nothing to redo');\n undo.disabled = redo.disabled = true;\n const close = iconButton(CLOSE, 'Close', pinned ? 'Close' : 'Close (Esc)');\n const buttons = tabs.map((tab) => {\n const el = button(tab.plugin.label ?? tab.plugin.name, '');\n el.className = 'tab';\n el.setAttribute('role', 'tab');\n el.addEventListener('click', () => show(tab));\n return { tab, el };\n });\n // What marks the shown tab, behind it, and slides to the next one shown.\n const thumb = div('thumb');\n const slide = (to: HTMLElement) => {\n Object.assign(thumb.style, { left: `${to.offsetLeft}px`, width: `${to.offsetWidth}px` });\n // Laid out where it is before it may move: the first place is no slide from the head's corner.\n void thumb.offsetWidth;\n thumb.classList.add('moves');\n };\n close.classList.add('end');\n head.append(thumb, ...buttons.map((b) => b.el), close);\n bar.append(where, undo, redo);\n // Back from `away` on a page that doesn't have the element: said, as nothing on it is lit.\n if (!element.isConnected)\n where.after(Object.assign(document.createElement('span'), { className: 'absent', textContent: 'not on this page' }));\n const body = div('body');\n body.setAttribute('role', 'tabpanel');\n const status = div('status');\n panel.append(head, bar, body, status);\n root.append(panel);\n if (pinned) panel.classList.add('pinned');\n const release = pinned ? undefined : keepInView(panel, body, head, element, spot);\n // Its element, or the spot in it, lit for as long as it's open.\n const unmark = lighting?.hold(element, panel, spot);\n if (!pinned) window.dispatchEvent(new CustomEvent<PopupOpened>(POPUP_OPENED, { detail: { element, tab: first.plugin.name } }));\n\n let cleanup: (() => void) | void;\n // The button that keeps what the shown tab would lose, while there's something: `unsaved`, from the panel.\n let holding: HTMLElement | undefined;\n const say = (text: string, problem = false) => {\n status.textContent = text;\n status.classList.toggle('problem', problem);\n };\n const post = async <T>(route: string, body?: unknown): Promise<T> => {\n const res = await send(`${base}__deictic/${route}`, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body ?? {}),\n });\n const json = (await res.json()) as T & { problem?: string };\n if (!res.ok) throw new Error(json.problem ?? res.statusText);\n return json;\n };\n const unmount = () => {\n cleanup?.();\n cleanup = undefined;\n holding = undefined;\n body.replaceChildren();\n };\n // The change undone may be this tab's from before the panel opened: the panel reads its model again.\n const step = (route: 'undo' | 'redo') =>\n post<{ change: { label: string } }>(route, { plugin: current.plugin.name, target })\n .then(\n async ({ change }) => {\n await load();\n say(`${route === 'undo' ? 'Undid' : 'Redid'} ${change.label}`);\n },\n (e: unknown) => say(messageOf(e), true),\n )\n .finally(() => void steps());\n // Undo and redo as the tab's history on this element stands: off with nothing to take back or do again, else\n // saying what they would. Read as a tab shows, after each change made here, and as the pointer comes back, for a\n // change made elsewhere. One a later read overtook (another tab's) sets nothing.\n let asked = 0;\n const steps = async () => {\n const ask = ++asked;\n let history: { done: { label: string }[]; undone: { label: string }[] };\n try {\n const res = await send(`${base}__deictic/history?${new URLSearchParams({ plugin: current.plugin.name, ...at })}`);\n if (!res.ok || ask !== asked) return;\n history = (await res.json()) as typeof history;\n } catch {\n return;\n }\n const last = history.done.at(-1);\n const next = history.undone.at(-1);\n undo.disabled = last === undefined;\n undo.title = last === undefined ? 'Nothing to undo' : `Undo ${last.label}`;\n redo.disabled = next === undefined;\n redo.title = next === undefined ? 'Nothing to redo' : `Redo ${next.label}`;\n };\n panel.addEventListener('pointerenter', () => void steps());\n\n const done = (leaving = false) => {\n unmount();\n release?.();\n unmark?.();\n panel.remove();\n window.removeEventListener('keydown', onKey, true);\n window.removeEventListener('pointerdown', onOutside, true);\n if (!pinned) window.dispatchEvent(new CustomEvent(POPUP_CLOSED));\n onClose(current, leaving);\n };\n const onKey = (e: KeyboardEvent) => {\n // A plugin's modal over the popup (one marked `data-deictic-modal`) takes Esc for itself.\n if (e.key !== 'Escape' || root.querySelector('[data-deictic-modal]') !== null) return;\n // Esc is the popup's while it's open: a dialog of the page's that it's open in stays open.\n e.preventDefault();\n e.stopPropagation();\n done();\n };\n // A press on the page closes the popup, as it would a menu, unless that loses something: then the button that\n // keeps it shakes. Anything in the overlay is the popup's own: a modal, the lightbox, the surface marks are drawn on.\n const onOutside = (e: PointerEvent) => {\n if (e.composedPath().includes(root.host)) return;\n if (holding === undefined) return done();\n shake(holding);\n };\n if (!pinned) {\n window.addEventListener('keydown', onKey, true);\n window.addEventListener('pointerdown', onOutside, true);\n }\n undo.addEventListener('click', () => void step('undo'));\n redo.addEventListener('click', () => void step('redo'));\n close.addEventListener('click', () => done());\n\n let current = first;\n // A read that a later one overtook (another tab, or the same after an undo) mounts nothing.\n let reads = 0;\n const load = async () => {\n const { plugin, mount } = current;\n const read = ++reads;\n // The body keeps its height while it's empty, and \"Reading…\" waits for a read that takes long: one answered\n // at once, as most are, would otherwise fold the popup and open it again in a blink.\n body.style.minHeight = `${body.offsetHeight}px`;\n unmount();\n say('');\n const slow = setTimeout(() => read === reads && say('Reading…'), SLOW);\n let model: unknown;\n try {\n ({ model } = await post<{ model: unknown }>('read', { plugin: plugin.name, target }));\n } catch (e) {\n if (read !== reads) return;\n body.style.minHeight = '';\n say(messageOf(e), true);\n return;\n } finally {\n clearTimeout(slow);\n }\n if (read !== reads) return;\n body.style.minHeight = '';\n say('');\n const back = current === first ? resumed : undefined;\n resumed = undefined;\n try {\n cleanup = mount(body, {\n ...contextOf(plugin.name),\n ...(back === undefined ? {} : { resumed: back }),\n away: (state, task) => {\n const tab = current;\n done(true);\n // For the tab's next page too, should this one go before the task is done. Not one a page pinned: that's the page's own.\n if (!pinned) keepAway({ tab: tab.plugin.name, target, state, ...(spot === undefined ? {} : { at: spot }) });\n const back = (resumed: Resumed) => {\n if (!pinned) dropAway();\n reopen(tab, element, resumed);\n };\n void task().then(\n (result) => back({ state, result }),\n (e: unknown) => back({ state, problem: messageOf(e) }),\n );\n },\n element,\n ...(pointed === undefined ? {} : { pointed }),\n ...(spot === undefined ? {} : { at: spot }),\n elements: sameAs(element),\n target,\n model,\n apply: async (op, on = target) => {\n say('Writing…');\n try {\n const result = await post<{ model: unknown }>('apply', { plugin: plugin.name, target: on, op });\n say('');\n void steps();\n return result.model;\n } catch (e) {\n say(messageOf(e), true);\n throw e;\n }\n },\n close: () => done(),\n unsaved: (action) => {\n if (read === reads) holding = action;\n },\n });\n } catch (e) {\n say(messageOf(e), true);\n contextOf(plugin.name).report(failed(plugin.name, 'show its panel', e));\n }\n };\n const show = (tab: Tab) => {\n current = tab;\n for (const b of buttons) {\n b.el.setAttribute('aria-selected', String(b.tab === tab));\n if (b.tab === tab) slide(b.el);\n }\n remember(tab);\n void steps();\n void load();\n };\n show(first);\n const guard = () => {\n if (holding !== undefined) shake(holding);\n return holding !== undefined;\n };\n return { close: done, unsaved: () => holding !== undefined, guard };\n}\n\n/** Shakes a panel's button, in view: what a press outside does where closing would lose something. A blink where motion is reduced. */\nfunction shake(el: HTMLElement): void {\n el.scrollIntoView({ block: 'nearest' });\n if (reduced()) return void el.animate({ opacity: [1, 0.3, 1, 0.3, 1] }, 400);\n el.animate({ translate: ['0', '-5px', '5px', '-4px', '4px', '-2px', '0'] }, { duration: 360, easing: 'ease-out' });\n}\n\nconst MARGIN = 8;\n// Under this much room on either side, the panel overlaps the element rather than shrink to a sliver beside it.\nconst LEAST = 160;\n/** How far from the element the popup is, in pixels: room for the line between them. */\nconst APART = 32;\n\n/** How far a press on the head moves, in pixels, before it's a drag: a click there leaves the popup following. */\nconst SLACK = 3;\n\n/**\n * Keeps a panel beside `element` and inside the viewport, as its tabs fill it, the window resizes and the element\n * moves with the page: to its right, or its left, where there's the room, level with its top and as tall as the\n * window lets it be; else below, or above where it fits better, its height capped to the room there, so the body\n * scrolls rather than the panel leaving the window. Off the element either way (`APART`): it's what's lit, with\n * room for the line between them. Dragged by `handle`, it stays where it's put, in the window, and follows the\n * element no more. Fixed, so it never changes the page's own scrolling. Answers a release.\n */\nfunction keepInView(panel: HTMLElement, body: HTMLElement, handle: HTMLElement, element: Element, at?: Point): () => void {\n let frame = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n // What it's beside: the element, or the spot in it.\n const boxOf = () => (at === undefined ? element.getBoundingClientRect() : spotOf(element, at));\n // Where the element was last seen: one gone from the page leaves the popup where it was.\n let r = boxOf();\n // An element that's not on the page (back from `away`, on another) has no place to be beside: as if dragged to the\n // middle, toward the top.\n let moved: { left: number; top: number } | undefined = element.isConnected\n ? undefined\n : { left: (document.documentElement.clientWidth - panel.offsetWidth) / 2, top: document.documentElement.clientHeight / 5 };\n const fit = () => {\n cancelAnimationFrame(frame);\n clearTimeout(timer);\n frame = 0;\n timer = undefined;\n // The viewport without the page's scrollbars.\n const width = document.documentElement.clientWidth;\n const height = document.documentElement.clientHeight;\n // What the panel would take with no cap: its frame, and all of its body.\n const wanted = panel.offsetHeight - body.clientHeight + body.scrollHeight;\n if (moved !== undefined) {\n const room = Math.max(0, height - 2 * MARGIN);\n Object.assign(panel.style, {\n left: `${Math.max(MARGIN, Math.min(moved.left, width - MARGIN - panel.offsetWidth))}px`,\n top: `${Math.max(MARGIN, Math.min(moved.top, height - MARGIN - Math.min(wanted, room)))}px`,\n maxHeight: `${room}px`,\n });\n return;\n }\n const top = Math.min(Math.max(r.top, 0), height);\n const bottom = Math.min(Math.max(r.bottom, 0), height);\n const gap = APART;\n const right = width - MARGIN - panel.offsetWidth - (r.right + gap);\n const left = r.left - gap - panel.offsetWidth - MARGIN;\n if (right >= 0 || left >= 0) {\n const room = Math.max(0, height - 2 * MARGIN);\n Object.assign(panel.style, {\n left: `${right >= 0 ? r.right + gap : r.left - gap - panel.offsetWidth}px`,\n top: `${Math.max(MARGIN, Math.min(r.top - CLEAR, height - MARGIN - Math.min(wanted, room)))}px`,\n maxHeight: `${room}px`,\n // It grows out of the side the element is on, as it opens.\n transformOrigin: right >= 0 ? '0 24px' : '100% 24px',\n });\n return;\n }\n const below = height - bottom - gap - MARGIN;\n const above = top - gap - MARGIN;\n const cap = Math.max(0, Math.min(height * 0.6, height - 2 * MARGIN));\n let at: number;\n let room: number;\n if (Math.max(below, above) < LEAST) {\n room = height - 2 * MARGIN;\n at = Math.min(Math.max(bottom + gap, MARGIN), height - MARGIN - Math.min(wanted, room));\n } else if (wanted <= below || below >= above) {\n room = Math.min(below, cap);\n at = bottom + gap;\n } else {\n room = Math.min(above, cap);\n at = top - gap - Math.min(wanted, room);\n }\n Object.assign(panel.style, {\n left: `${Math.max(MARGIN, Math.min(r.left, width - MARGIN - panel.offsetWidth))}px`,\n top: `${at}px`,\n bottom: '',\n maxHeight: `${room}px`,\n transformOrigin: at < top ? '24px 100%' : '24px 0',\n });\n };\n // Not in the observers' callbacks, where a change of size is a \"ResizeObserver loop\" error on the page. The next\n // frame, or a moment later where there's none: a hidden tab draws no frames, and its popup still fits when shown.\n const later = () => {\n frame ||= requestAnimationFrame(fit);\n timer ??= setTimeout(fit, 50);\n };\n fit();\n // Read each frame, as nothing tells of an element moving: the page scrolls, its layout shifts, a panel previews.\n let watching = requestAnimationFrame(function watch() {\n if (moved !== undefined) return;\n watching = requestAnimationFrame(watch);\n if (!element.isConnected) return;\n const now = boxOf();\n if (now.left === r.left && now.top === r.top && now.width === r.width && now.height === r.height) return;\n r = now;\n fit();\n });\n // A drag starts on the head itself, not on a tab or the close in it.\n let from: { x: number; y: number; left: number; top: number } | undefined;\n const down = (e: PointerEvent) => {\n if (e.button !== 0 || (e.target as Element).closest('button') !== null) return;\n // Kept from the browser: no text selected along the way, and the field being typed in keeps its focus.\n e.preventDefault();\n const at = panel.getBoundingClientRect();\n from = { x: e.clientX, y: e.clientY, left: at.left, top: at.top };\n handle.setPointerCapture(e.pointerId);\n };\n const move = (e: PointerEvent) => {\n if (from === undefined) return;\n const x = e.clientX - from.x;\n const y = e.clientY - from.y;\n if (moved === undefined && Math.hypot(x, y) < SLACK) return;\n moved = { left: from.left + x, top: from.top + y };\n panel.classList.add('dragging');\n fit();\n };\n const up = () => {\n from = undefined;\n panel.classList.remove('dragging');\n };\n handle.addEventListener('pointerdown', down);\n handle.addEventListener('pointermove', move);\n handle.addEventListener('pointerup', up);\n handle.addEventListener('pointercancel', up);\n // A tab's content arrives after the panel opens, and changes as it's used, as does the status line. Both, as a\n // resize observer reports only while the page renders: a hidden tab's popup would keep its first place.\n const resized = new ResizeObserver(later);\n resized.observe(panel);\n const changed = new MutationObserver(later);\n changed.observe(panel, { childList: true, subtree: true, characterData: true });\n window.addEventListener('resize', later);\n return () => {\n cancelAnimationFrame(frame);\n cancelAnimationFrame(watching);\n clearTimeout(timer);\n resized.disconnect();\n changed.disconnect();\n window.removeEventListener('resize', later);\n };\n}\n\n/** A button that is a drawing: named for what it does, as its title, the tooltip, changes with what it would do. */\nfunction iconButton(svg: string, name: string, title: string): HTMLButtonElement {\n const el = button('', title);\n el.className = 'icon';\n el.innerHTML = svg;\n el.setAttribute('aria-label', name);\n return el;\n}\n\nfunction button(text: string, title: string): HTMLButtonElement {\n const el = document.createElement('button');\n el.type = 'button';\n el.textContent = text;\n el.title = title;\n return el;\n}\n\nconst messageOf = (e: unknown) => (e instanceof Error ? e.message : String(e));\n\n/** A plugin's page half that threw: a bug of the plugin's, to report where it's made. Its key is the first line of what it threw. */\nconst failed = (plugin: string, what: string, e: unknown): Problem => ({\n key: `page:${plugin}:${what.split(' ', 1)[0]}:${messageOf(e).split('\\n', 1)[0]!.slice(0, 200)}`,\n kind: 'bug',\n plugin,\n message: `${plugin} failed to ${what}: ${messageOf(e)}`,\n ...(e instanceof Error && e.stack !== undefined ? { details: e.stack } : {}),\n});\n"],"mappings":";;;;;;AAkBA,MAAMA,QAAM;AACZ,MAAM,QAAQ;;AAEd,MAAM,QAAQ;;AAGd,IAAI,OAAyB,QAAQ,QAAQ;AAE7C,SAAS,MAAS,MAA0B,MAA4D;CACtG,MAAM,OAAO,KACV,YAAY,CAAC,CAAC,CAAC,CACf,WAEG,IAAI,SAAY,MAAM,SAAS;EAC7B,MAAM,UAAU,UAAU,KAAK,WAAW,CAAC;EAC3C,QAAQ,iBAAiB,uBAAuB,QAAQ,OAAO,kBAAkB,KAAK,CAAC;EACvF,QAAQ,iBAAiB,eAAe,KAAK,QAAQ,KAAK,CAAC;EAC3D,QAAQ,iBAAiB,iBAAiB;GACxC,MAAM,KAAK,QAAQ;GACnB,MAAM,cAAc,GAAG,YAAY,OAAO,IAAI;GAC9C,YAAY,iBAAiB,kBAAkB,GAAG,MAAM,CAAC;GACzD,YAAY,iBA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9D,MAAM,KAAK,SAAS,cAAc,QAAQ;CAC1C,GAAG,OAAO;CACV,GAAG,cAAc;CACjB,GAAG,QAAQ;CACX,OAAO;AACT;AAEA,MAAM,aAAa,MAAgB,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;;AAG5E,MAAM,UAAU,QAAgB,MAAc,OAAyB;CACrE,KAAK,QAAQ,OAAO,GAAG,KAAK,MAAM,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,EAAE,CAAE,MAAM,GAAG,GAAG;CAC5F,MAAM;CACN;CACA,SAAS,GAAG,OAAO,aAAa,KAAK,IAAI,UAAU,CAAC;CACpD,GAAI,aAAa,SAAS,EAAE,UAAU,KAAA,IAAY,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC5E"}
package/dist/index.d.ts CHANGED
@@ -19,5 +19,5 @@
19
19
  *
20
20
  * Both halves import from here, so the parser is imported for its types only: the browser must not load it.
21
21
  */
22
- import { A as Modifier, C as Target, D as TrayItem, E as Tray, O as defineClientPlugin, S as Standalone, T as ToolPanel, _ as ServerApis, a as Done, b as Source, c as LightboxItem, d as PanelContext, f as Point, g as Route, h as Resumed, i as ClientPlugin, j as Shortcut, k as definePlugin, l as LightboxOptions, m as Refusal, n as ClientApis, o as Drawer, p as Problem, r as ClientContext, s as LightboxAction, t as ApiOf, u as Loc, v as ServerContext, w as TextEdit, x as Spot, y as ServerPlugin } from "./shared/index.js";
23
- export { ApiOf, ClientApis, ClientContext, ClientPlugin, Done, Drawer, LightboxAction, LightboxItem, LightboxOptions, Loc, type Modifier, PanelContext, Point, Problem, Refusal, Resumed, Route, ServerApis, ServerContext, ServerPlugin, type Shortcut, Source, Spot, Standalone, Target, TextEdit, ToolPanel, Tray, TrayItem, defineClientPlugin, definePlugin };
22
+ import { A as definePlugin, C as Tag, D as Tray, E as ToolPanel, M as Shortcut, O as TrayItem, S as Standalone, T as TextEdit, _ as ServerApis, a as Done, b as Source, c as LightboxItem, d as PanelContext, f as Point, g as Route, h as Resumed, i as ClientPlugin, j as Modifier, k as defineClientPlugin, l as LightboxOptions, m as Refusal, n as ClientApis, o as Drawer, p as Problem, r as ClientContext, s as LightboxAction, t as ApiOf, u as Loc, v as ServerContext, w as Target, x as Spot, y as ServerPlugin } from "./shared/index.js";
23
+ export { ApiOf, ClientApis, ClientContext, ClientPlugin, Done, Drawer, LightboxAction, LightboxItem, LightboxOptions, Loc, type Modifier, PanelContext, Point, Problem, Refusal, Resumed, Route, ServerApis, ServerContext, ServerPlugin, type Shortcut, Source, Spot, Standalone, Tag, Target, TextEdit, ToolPanel, Tray, TrayItem, defineClientPlugin, definePlugin };
@@ -369,6 +369,12 @@ interface Resumed {
369
369
  /** Why the task failed: its error's message. */
370
370
  problem?: string;
371
371
  }
372
+ /** A plugin's own tag in the caption over what's pointed at, after deictic's: prosebook's names the string's key. */
373
+ interface Tag {
374
+ text: string;
375
+ /** Its background, a CSS color: deictic's accent unset. Its text is white. */
376
+ color?: string;
377
+ }
372
378
  interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {
373
379
  /** The server half's `name`. */
374
380
  name: string;
@@ -390,6 +396,11 @@ interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {
390
396
  * plugin pins each task where its element is. Answers what takes it away.
391
397
  */
392
398
  pointing?(context: ClientContext): () => void;
399
+ /**
400
+ * Its tag in the caption for what's under the pointer, at `at` in the window's CSS pixels, or nothing. Asked on
401
+ * every move while pointing, so it must be quick.
402
+ */
403
+ tag?(context: ClientContext, at: Point): Tag | undefined;
393
404
  /**
394
405
  * A shortcut's press on a marked element, before the page hears it and before the popup opens: the page as the
395
406
  * person saw it, a tooltip still open under the pointer, a menu still focused. Called as the press goes down, so
@@ -400,5 +411,5 @@ interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {
400
411
  mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;
401
412
  }
402
413
  declare const defineClientPlugin: <Model, Op, Api = unknown>(plugin: ClientPlugin<Model, Op, Api>) => ClientPlugin<Model, Op, Api>;
403
- export { Modifier as A, Target as C, TrayItem as D, Tray as E, defineClientPlugin as O, Standalone as S, ToolPanel as T, ServerApis as _, Done as a, Source as b, LightboxItem as c, PanelContext as d, Point as f, Route as g, Resumed as h, ClientPlugin as i, Shortcut as j, definePlugin as k, LightboxOptions as l, Refusal as m, ClientApis as n, Drawer as o, Problem as p, ClientContext as r, LightboxAction as s, ApiOf as t, Loc as u, ServerContext as v, TextEdit as w, Spot as x, ServerPlugin as y };
414
+ export { definePlugin as A, Tag as C, Tray as D, ToolPanel as E, Shortcut as M, TrayItem as O, Standalone as S, TextEdit as T, ServerApis as _, Done as a, Source as b, LightboxItem as c, PanelContext as d, Point as f, Route as g, Resumed as h, ClientPlugin as i, Modifier as j, defineClientPlugin as k, LightboxOptions as l, Refusal as m, ClientApis as n, Drawer as o, Problem as p, ClientContext as r, LightboxAction as s, ApiOf as t, Loc as u, ServerContext as v, Target as w, Spot as x, ServerPlugin as y };
404
415
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/shortcut.ts","../../src/index.ts"],"mappings":";;;;;;;;;;KAUY;UAEK;;EAEf,YAAY;;EAEZ;;;UCYe;EACf;EACA;EACA;;;UAIe;EACf,KAAK;EACL;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;;EAEf;EACA;;EAEA,SAAS;;EAET,SAAS;;EAET,KAAK;;;;;;;KAQK,cAAc,SAAS,YAAY,WAAW,QAAQ;;cAGrD,gBAAgB;EAClB;;;;;;UAOM,KAAK;EACpB,MAAM;;KAGH,MAAM,KAAK,IAAI,QAAQ;;;;;;UAOX;;;;;EAKf;;;;;EAKA;;EAEA;;EAEA;;EAEA;;;;;;UAQe;;UAIA;;KAGL,MAAM,MAAM,uBAAuB,mBAAmB,OAAO,KAAK;UAE7D;;EAEf;;;;;EAKA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;EAEA,MAAM,qBAAqB,MAAM,SAAS,MAAM,YAAY;;EAE5D,UAAU,eAAe,OAAO,gBAAgB,QAAQ;;EAExD,SAAS,SAAS;;;;;EAKlB,OAAO,OAAO,QAAQ;;;;;;;;EAQtB,OAAO,gBAAgB,SAAS,SAAS,KAAK;;EAE9C,OAAO;;EAEP,MAAM;;EAEN,QAAQ;;;;;EAKR,QAAQ,UAAU;;;;;EAKlB,WAAW,OAAO,gBAAgB,UAAU;IAAsB;;;;KAIxD;;EAEV;;EAEA,UAAU;;EACL;EAAe;;EAAkB;EAAc;;EAAkB;EAAe;;UAEtE;EACf;EACA;EACA;;UAGe;;EAEf;;EAEA,OAAO;;UAGQ,aAAa,OAAO,YAAY;;;;;;EAM/C,SAAS;;;;;EAKT,UAAU;;EAEV,KAAK;;EAEL,UAAU;EACV,QAAQ;EACR,OAAO;;;;;EAKP,MAAM,IAAI,IAAI,KAAK,SAAS,QAAQ;EACpC;;;;;;EAMA,UAAU,QAAQ;;;;;;;;;EASlB,OAAO,GAAG,gBAAgB,YAAY,QAAQ;;EAE9C,UAAU;;;UAIK;EACf;EACA;;EAEA;;;UAIe;EACf;;EAEA;;UAGe,aAAa,iBAAiB,cAAc;;EAE3D;;EAEA;;;;;EAKA,OAAO,SAAS,gBAAgB;;;;;;EAMhC,QAAQ,SAAS,gBAAgB;;;;;EAKjC,UAAU,SAAS;;;;;EAKnB,KAAK,SAAS,eAAe,IAAI,QAAQ;;;;;;EAMzC,SAAS,SAAS,eAAe,SAAS;;EAE1C,SAAS,OAAO,aAAa,SAAS,aAAa,OAAO;;cAG/C,qBAAsB,OAAO,IAAI,eAAa,QAAU,aAAa,OAAO,IAAI,SAAO,aAAa,OAAO,IAAI"}
@@ -1,4 +1,4 @@
1
- import { j as Shortcut } from "./index.js";
1
+ import { M as Shortcut } from "./index.js";
2
2
  /** A class as the panel shows it. */
3
3
  interface ClassInfo {
4
4
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { Board } from "@vercel/board";
2
- import { C as Target, f as Point, j as Shortcut, p as Problem } from "./index.js";
2
+ import { M as Shortcut, f as Point, p as Problem, w as Target } from "./index.js";
3
3
  import { t as Box } from "./index3.js";
4
4
  interface LocalOptions {
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { j as Shortcut, y as ServerPlugin } from "./index.js";
1
+ import { M as Shortcut, y as ServerPlugin } from "./index.js";
2
2
  import "magic-string";
3
3
  import "oxc-parser";
4
4
  interface DeicticOptions {
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "deictic";
3
- var version = "0.11.0";
3
+ var version = "0.12.0";
4
4
  var bugs = { "url": "https://github.com/gkurt/deictic/issues" };
5
5
  var peerDependencies = {
6
6
  "@rrweb/rrweb-plugin-console-record": "^2.2.2",
@@ -1 +1 @@
1
- {"version":3,"file":"src.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * `deictic`: what a plugin is. Every plugin is optional: deictic itself is the glue (the\n * transform that ties elements to source, the dev server's endpoints, the history, shortcuts and the\n * overlay's panel), and each plugin adds what it does on top.\n *\n * A plugin has two halves, each optional that meet over the dev server's endpoints (`tools/endpoints.ts`). The\n * server half runs beside the bundler and is the only one that reads source: it turns the element\n * under the pointer into a model its panel can show, and an op from that panel into text edits. It\n * never writes files; deictic does, so every plugin's changes land in one history and undo the\n * same way. A change that isn't to a file (a task added to a board) the plugin makes itself and\n * answers with what it did (`Done`): the history keeps that beside the files' changes and hands it\n * back to the plugin's own `undo` and `redo`.\n * The client half is a module the page loads, named by the server half's `client`, which draws the\n * panel and previews an op on the page before it is applied.\n *\n * A plugin may have no panel at all, only an API for others (screenshots, a recording) and routes of\n * its own on the dev server. Each half's `setup` answers its API, and `use(name)` reaches another\n * plugin's, on the same side; `needs` names the plugins it can't do without.\n *\n * Both halves import from here, so the parser is imported for its types only: the browser must not load it.\n */\nimport type { JSXOpeningElement, Program } from 'oxc-parser';\n\nimport type { Shortcut } from './shortcut.ts';\n\nexport type { Modifier, Shortcut } from './shortcut.ts';\n\n/** A place in the source: the file from the project's root, with `/`, and the line and column, from 1. */\nexport interface Loc {\n file: string;\n line: number;\n column: number;\n}\n\n/** An element the pointer picked: where its opening tag starts, and the tag, which the server checks is still there. */\nexport interface Target {\n loc: Loc;\n tag: string;\n}\n\n/** Text in a file to replace, by UTF-16 offsets. `file` is the target's unless named, from the project's root. */\nexport interface TextEdit {\n file?: string;\n start: number;\n end: number;\n text: string;\n}\n\n/** What a server half reads: the target's file, parsed, and its element. */\nexport interface Source {\n /** The target's file, from the project's root. */\n file: string;\n code: string;\n /** The file's module; for an `.astro` component, its frontmatter's. */\n program: Program;\n /** The target's opening tag. */\n element: JSXOpeningElement;\n /** Another file under the project's root, for plugins whose edits go elsewhere (a locale's messages). */\n read(file: string): string;\n}\n\n/**\n * What answers the overlay's requests in a page with no dev server behind it (`deictic/vite`'s `standalone`): the\n * default export of a module of the page's. A request is one the endpoints would get, under `<base>__deictic/`;\n * the answer is theirs too (`{ model }`, `{ model, change }`, `{ problem }` with a status that isn't ok).\n */\nexport type Standalone = (request: Request) => Response | Promise<Response>;\n\n/** An op a plugin won't make. The message says why and what to do instead; the panel shows it. */\nexport class Refusal extends Error {\n override name = 'Refusal';\n}\n\n/**\n * A change the plugin made itself, not to a file: what its `undo` and `redo` need to take it back and\n * make it again. JSON, since the history keeps it on disk across restarts of the dev server.\n */\nexport interface Done<Record = unknown> {\n done: Record;\n}\n\ntype Maybe<T> = T | Promise<T>;\n\n/**\n * Something of deictic's that went wrong, which nothing a person did in the page caused: a package the project\n * hasn't installed, a plugin that failed. The dev server says it, and hands it to each plugin with a `problem`\n * (tasks posts it to the board, for an agent to fix).\n */\nexport interface Problem {\n /**\n * What tells it apart, and the same problem again from a new one: `packages:rrweb`, `setup:tailwind`. Never a\n * time or an ID, so a problem that comes back is known.\n */\n key: string;\n /**\n * `setup`: the project's to fix, as `message` says (install a package, configure a plugin). `bug`: deictic's own, or\n * a plugin's, to report where it's made, not to patch where it's installed.\n */\n kind: 'setup' | 'bug';\n /** What went wrong, and the fix where there is one, as any problem message says it. */\n message: string;\n /** What more there is to look into: a stack. */\n details?: string;\n /** The plugin it's about, where it's one's: none for deictic's own. */\n plugin?: string;\n}\n\n/**\n * Each plugin's API to the others on the server, by name. A plugin adds its own, so `use` knows its type:\n * `declare module 'deictic' { interface ServerApis { screenshots: Screenshots } }`.\n */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ServerApis {}\n\n/** The same, in the page: `declare module 'deictic' { interface ClientApis { screenshots: Capture } }`. */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ClientApis {}\n\n/** A plugin's API, by its name: what its package declared, or `unknown` for one that declared none. */\nexport type ApiOf<Apis, Name extends string> = Name extends keyof Apis ? Apis[Name] : unknown;\n\nexport interface ServerContext {\n /** The project's root, as an absolute path. */\n root: string;\n /**\n * Another plugin's API, as its `setup` answered it, or nothing when it isn't loaded (or its `setup` failed,\n * which is reported). One the plugin `needs` always is loaded; any other may not be, so check.\n */\n use: <Name extends string>(name: Name) => ApiOf<ServerApis, Name> | undefined;\n /** Says a problem of the plugin's own, as deictic says its own: in the dev server's output, and to each plugin's `problem`. */\n report: (problem: Problem) => void;\n /**\n * Runs `callback` as the dev server closes, to undo what `setup` did beyond the plugin itself: a global it set, a\n * watcher or a server it started. Under Vite and webpack; a dev server that only ends with its process runs none.\n */\n onClose: (callback: () => Maybe<void>) => void;\n}\n\n/**\n * A route of the plugin's own, at `/__deictic/plugins/<name>/<route>`, and below it. A `GET` must\n * change nothing: anything else reaches it only from the page itself, which deictic checks.\n */\nexport type Route = (request: Request, context: ServerContext) => Maybe<Response>;\n\nexport interface ServerPlugin<Model = unknown, Op = unknown, Record = unknown, Api = unknown> {\n /** Ties the halves together; also the label of its changes in the history, and its routes' path. Lowercase, with `-`. */\n name: string;\n /** The module the page loads for this plugin's half there, which default-exports its `ClientPlugin`. */\n client?: string;\n /** What the page half gets as `context.options`: the user's options it needs there, as JSON. */\n clientOptions?: unknown;\n /** What opens its panel: its own default, which its options let the user change. A plugin with no panel has none. */\n shortcut?: Shortcut;\n /** The plugins it can't do without, by name: the dev server won't start without them. */\n needs?: string[];\n /**\n * The packages it imports that the project installs itself (optional peers), by name: as the dev server starts,\n * it says how to install any that's missing, rather than failing when first used.\n */\n packages?: string[];\n /** Runs once, as the dev server starts and before it answers anything. Answers the plugin's API to the others. */\n setup?(context: ServerContext): Maybe<Api>;\n /** Routes of its own, by their first segment under `/__deictic/plugins/<name>/`. */\n routes?: { [route: string]: Route };\n /**\n * The model its panel shows for an element. Without it, the panel gets none. `source` is a `Refusal` where the\n * element isn't to be found in its file (it doesn't parse, or the page runs other code than it has): throw it where\n * the plugin needs the source, or go on without it, as a task does.\n */\n read?(source: Source | Refusal, target: Target): Maybe<Model>;\n /** Text edits for deictic to write, which it refuses without the source, or a change the plugin made itself. */\n apply?(source: Source | Refusal, target: Target, op: Op): Maybe<TextEdit[] | Done<Record>>;\n /**\n * Takes back a change `apply` made itself, or throws a `Refusal` saying why it can't any more. It may\n * answer what the next redo needs, where that differs (what it put back has a new ID).\n */\n undo?(record: Record): Maybe<void | Record>;\n /** Makes it again after an undo, and answers what the next undo needs, which may differ (a new ID). */\n redo?(record: Record): Maybe<Record>;\n /** Says what an op does, for the history: `className: px-2 → px-4`. */\n describe?(op: Op, before: Model): string;\n /**\n * Hears each problem deictic or a plugin reports, on the server or in the page, after every `setup` has run: once\n * per `key` while the dev server runs. Its own failure is only said, never reported again.\n */\n problem?(problem: Problem): Maybe<void>;\n}\n\nexport const definePlugin = <Model, Op, Record = unknown, Api = unknown>(\n plugin: ServerPlugin<Model, Op, Record, Api>,\n): ServerPlugin<Model, Op, Record, Api> => plugin;\n\n/** Where something is in an element, in CSS pixels from its top left. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** A spot on the page: a marked element, and a point in it (or beside it, for the nearest to a point no marked element is under). */\nexport interface Spot {\n element: Element;\n at: Point;\n}\n\n/**\n * The tool panel: a bar docked to an edge of the window, which shows while a shortcut's keys are held and stays\n * while it's in use. A plugin adds its tools to it from its page half's `setup`.\n */\nexport interface ToolPanel {\n /**\n * Adds a plugin's controls, as one group, in the order plugins are loaded. Groups of one `section` sit together,\n * with no line between them, after the groups of none: the screenshots', recordings', voice's and tasks' are\n * `capture`. `last` puts a group at the end of its section, or after all the others for one of none. Each control is a button named by its `title`; its `aria-keyshortcuts`\n * (`B`, `Control+Z`) is the key the panel hears for it, alone or with the keys held to point, and what its tooltip\n * shows.\n */\n add: (group: HTMLElement, options?: { last?: boolean; section?: string }) => void;\n /**\n * Takes the page for a tool that works on it (drawing, picking a point): the tool that had it lets go first, and\n * the panel stays shown. `left` is called when another takes it, or Esc or the pointer tool gives the page back.\n * Answers what lets go of it, for the tool to call when it's done on its own.\n */\n hold: (left: () => void) => () => void;\n /** Keeps the panel shown while something goes on that its controls end (a recording). Answers what ends that. */\n keep: () => () => void;\n /**\n * Takes the page until a point of it is pressed, lighting what's under the pointer as pointing does: answers the\n * spot, the marked element there or the nearest to it, or nothing where the page was given back first.\n */\n pick: () => Promise<Spot | undefined>;\n}\n\n/**\n * The drawer: on the window's side, where what the plugins have for the page lands, a section each. It\n * shows while a shortcut's keys are held and a section has something, and stays while it's in use.\n */\nexport interface Drawer {\n /**\n * Adds a section, in the order added, or before the others with `first`. A section that has nothing to show sets\n * its own `hidden`: the drawer stays away while every one is. Folded away, the drawer counts what the sections\n * have: each says how many things it lists in `data-count`, and how many are unread in `data-unread`.\n */\n add: (section: HTMLElement, options?: { first?: boolean }) => void;\n /**\n * Opens one item in the drawer, in the sections' place, under `title` and a way back. The drawer stays while it's\n * open. `closed` is called when it's left, by the way back, Esc, or another item opening. Answers what closes it.\n */\n show: (view: HTMLElement, options?: { title?: string; closed?: () => void }) => () => void;\n /** Keeps the drawer up while something goes on in it; answers what lets it go. */\n keep: () => () => void;\n}\n\n/** Something a plugin made on the page that nothing has taken yet: a shot, a recording, a voice clip. */\nexport interface TrayItem {\n /** The plugin that made it. */\n plugin: string;\n /** Its ID, as that plugin has it. */\n id: string;\n /** What that plugin says of it, as JSON: the screenshots plugin's `Shot`, a `Recording`, a `Clip`. */\n value: unknown;\n}\n\n/**\n * What plugins made on the page from the tool panel, until something takes it: a task attaches what's there and\n * removes it. Kept for the tab's session, so it's there on the tab's next page too.\n */\nexport interface Tray {\n /** What's kept, oldest first: all of it, or one plugin's. */\n list: (plugin?: string) => TrayItem[];\n add: (plugin: string, id: string, value: unknown) => void;\n /** Takes one out, or all of a plugin's. */\n remove: (plugin: string, id?: string) => void;\n /** Hears every change from now on; answers what stops it. */\n subscribe: (listener: () => void) => () => void;\n}\n\nexport interface ClientContext {\n /** The dev server's base URL, ending in `/`. */\n base: string;\n /** deictic's shadow root, to draw in: neither the page's styles nor the overlay's cross over. */\n root: ShadowRoot;\n /** The server half's `clientOptions`, or nothing. */\n options: unknown;\n /** Another plugin's API in the page, as its `setup` answered it, or nothing when it isn't loaded. */\n use: <Name extends string>(name: Name) => ApiOf<ClientApis, Name> | undefined;\n /** Asks one of this plugin's own routes, from the page: `request('shots', { method: 'POST', body: blob })`. */\n request: (route: string, init?: RequestInit) => Promise<Response>;\n /** Says a problem of the plugin's own to the dev server, as the server half's `report` does: its `plugin` is this one. */\n report: (problem: Problem) => void;\n /**\n * Opens a place in a file under the root in the editor, as the popup's own link opens the element's: through the\n * dev server, or what answers in its place (`Standalone`). Rejects with why it couldn't.\n */\n edit: (place: Loc) => Promise<void>;\n /**\n * Opens the popup on an element at a plugin's tab, as its shortcut would, or with `at` on a spot in it: the\n * popup is then beside the spot, which is what's lit, and the tab's context has it. An element rendered again\n * since stands in for one no longer on the page. False when there's no such tab or no such element any more, and\n * while the open popup holds something unsaved, whose button then shakes. Not as `setup` runs, which is before the\n * popup can open.\n */\n open: (plugin: string, element: Element, at?: Point) => boolean;\n /** The tool panel, to add this plugin's tools to. */\n tools: ToolPanel;\n /** What was made from the tool panel and not taken yet. */\n tray: Tray;\n /** The drawer, to add this plugin's section to. */\n drawer: Drawer;\n /**\n * Lights an element on the page as pointing at it does, for something of the overlay's own that stands for it (a\n * task's row in the drawer, while the pointer is on it); none puts the light back as it was.\n */\n light: (element?: Element) => void;\n /**\n * Shows `items` in the lightbox over everything, at `at` (the first by default), stepping between them with\n * ← and →. With `from`, it grows out of that element (the chip clicked) and shrinks back into it on close.\n */\n lightbox: (items: LightboxItem[], options?: LightboxOptions) => { close: () => void };\n}\n\n/** What the lightbox shows: a picture, a page in a frame (a recording's replay), or a sound with its waveform. */\nexport type LightboxItem = {\n /** Its name, over it. */\n title: string;\n /** Buttons beside the name: each closes the lightbox and runs. */\n actions?: LightboxAction[];\n} & ({ kind: 'image'; url: string } | { kind: 'page'; url: string } | { kind: 'audio'; url: string });\n\nexport interface LightboxAction {\n label: string;\n title?: string;\n run: () => void;\n}\n\nexport interface LightboxOptions {\n /** The item it opens at. */\n at?: number;\n /** The element it grows out of, and goes back into. */\n from?: Element;\n}\n\nexport interface PanelContext<Model, Op> extends ClientContext {\n /**\n * The element clicked: the one the source marked, under the pointer or around what is. Back from `away`\n * it may be off the page (`isConnected` is false), where the page moved on without it: the element as it\n * was left, or after a page load an empty one of its tag and mark. `elements` is then empty.\n */\n element: Element;\n /**\n * What was under the pointer, where it isn't `element` but inside it: markup nothing marked, as a\n * dependency's, or in an open shadow root, as the popup's own on a page that shows it (`popupIn`).\n */\n pointed?: Element;\n /** The spot in `element` the popup was opened on, where it was (the tool panel's task tool), not the element as a whole. */\n at?: Point;\n /** Every element on the page from the same place in the source, the clicked one among them: the rows of a list. */\n elements: Element[];\n target: Target;\n model: Model;\n /**\n * Applies an op on disk, and reads the model again. Rejects with the server's reason, which the panel also shows.\n * On another element with `on`, whose model is then the one answered: for an op that's about that one.\n */\n apply(op: Op, on?: Target): Promise<Model>;\n close: () => void;\n /**\n * Says there's something here that leaving would lose (words typed, a change tried on the page), and the button\n * that keeps it: a click outside the popup then shakes that button, where it would have closed the popup.\n * `undefined` once there's nothing to lose. Forgotten as the panel unmounts.\n */\n unsaved: (action: HTMLElement | undefined) => void;\n /**\n * Leaves the popup to do something on the page, then comes back: closes it, runs `task` (a recording, a\n * pick of another element), and opens it again at this tab on this element. The next mount gets\n * `resumed`: the `state` kept now (what was typed, what's attached), and what `task` answered, or why\n * it failed. The state stays in the page, as it is: no need for JSON. It's also kept for the tab's next\n * page, as a structured clone, where it can be one: after a page load, the plugin's `resume` says whether\n * the task carries on, and the popup comes back there.\n */\n away: <T>(state: unknown, task: () => Promise<T>) => void;\n /** Set when this mount is the panel coming back from `away`. */\n resumed?: Resumed;\n}\n\n/** What a panel coming back from `away` gets: the state it kept, and the task's result or problem. */\nexport interface Resumed {\n state: unknown;\n result?: unknown;\n /** Why the task failed: its error's message. */\n problem?: string;\n}\n\nexport interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {\n /** The server half's `name`. */\n name: string;\n /** Shown over the element while its shortcut's keys are held, and atop the panel. */\n label?: string;\n /**\n * Runs once, as the page starts, before any panel opens (a recording starts here). Answers the\n * plugin's API to the others in the page, at once: one that needs time keeps its promises inside it.\n */\n setup?(context: ClientContext): Api;\n /**\n * Asked as a page starts where the page before it left this plugin's panel `away`: the task it left for,\n * where that carries on in this page (a recording does), or nothing where it ended with the page. When it's\n * done the popup opens at this tab with `resumed`, on the element where this page has it and without where not.\n */\n resume?(context: ClientContext): Promise<unknown> | undefined;\n /**\n * What it shows on the page while a shortcut's keys are held, and the page is dimmed to point on: the tasks\n * plugin pins each task where its element is. Answers what takes it away.\n */\n pointing?(context: ClientContext): () => void;\n /**\n * A shortcut's press on a marked element, before the page hears it and before the popup opens: the page as the\n * person saw it, a tooltip still open under the pointer, a menu still focused. Called as the press goes down, so\n * it must be quick; the screenshots plugin keeps what a shot needs here, and renders it later.\n */\n pressed?(context: ClientContext, element: Element): void;\n /** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */\n mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;\n}\n\nexport const defineClientPlugin = <Model, Op, Api = unknown>(plugin: ClientPlugin<Model, Op, Api>): ClientPlugin<Model, Op, Api> => plugin;\n"],"mappings":";;AAqEA,IAAa,UAAb,cAA6B,MAAM;CACxB,OAAO;AAClB;AAqHA,MAAa,gBACX,WACyC;AAyO3C,MAAa,sBAAgD,WAAuE"}
1
+ {"version":3,"file":"src.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * `deictic`: what a plugin is. Every plugin is optional: deictic itself is the glue (the\n * transform that ties elements to source, the dev server's endpoints, the history, shortcuts and the\n * overlay's panel), and each plugin adds what it does on top.\n *\n * A plugin has two halves, each optional that meet over the dev server's endpoints (`tools/endpoints.ts`). The\n * server half runs beside the bundler and is the only one that reads source: it turns the element\n * under the pointer into a model its panel can show, and an op from that panel into text edits. It\n * never writes files; deictic does, so every plugin's changes land in one history and undo the\n * same way. A change that isn't to a file (a task added to a board) the plugin makes itself and\n * answers with what it did (`Done`): the history keeps that beside the files' changes and hands it\n * back to the plugin's own `undo` and `redo`.\n * The client half is a module the page loads, named by the server half's `client`, which draws the\n * panel and previews an op on the page before it is applied.\n *\n * A plugin may have no panel at all, only an API for others (screenshots, a recording) and routes of\n * its own on the dev server. Each half's `setup` answers its API, and `use(name)` reaches another\n * plugin's, on the same side; `needs` names the plugins it can't do without.\n *\n * Both halves import from here, so the parser is imported for its types only: the browser must not load it.\n */\nimport type { JSXOpeningElement, Program } from 'oxc-parser';\n\nimport type { Shortcut } from './shortcut.ts';\n\nexport type { Modifier, Shortcut } from './shortcut.ts';\n\n/** A place in the source: the file from the project's root, with `/`, and the line and column, from 1. */\nexport interface Loc {\n file: string;\n line: number;\n column: number;\n}\n\n/** An element the pointer picked: where its opening tag starts, and the tag, which the server checks is still there. */\nexport interface Target {\n loc: Loc;\n tag: string;\n}\n\n/** Text in a file to replace, by UTF-16 offsets. `file` is the target's unless named, from the project's root. */\nexport interface TextEdit {\n file?: string;\n start: number;\n end: number;\n text: string;\n}\n\n/** What a server half reads: the target's file, parsed, and its element. */\nexport interface Source {\n /** The target's file, from the project's root. */\n file: string;\n code: string;\n /** The file's module; for an `.astro` component, its frontmatter's. */\n program: Program;\n /** The target's opening tag. */\n element: JSXOpeningElement;\n /** Another file under the project's root, for plugins whose edits go elsewhere (a locale's messages). */\n read(file: string): string;\n}\n\n/**\n * What answers the overlay's requests in a page with no dev server behind it (`deictic/vite`'s `standalone`): the\n * default export of a module of the page's. A request is one the endpoints would get, under `<base>__deictic/`;\n * the answer is theirs too (`{ model }`, `{ model, change }`, `{ problem }` with a status that isn't ok).\n */\nexport type Standalone = (request: Request) => Response | Promise<Response>;\n\n/** An op a plugin won't make. The message says why and what to do instead; the panel shows it. */\nexport class Refusal extends Error {\n override name = 'Refusal';\n}\n\n/**\n * A change the plugin made itself, not to a file: what its `undo` and `redo` need to take it back and\n * make it again. JSON, since the history keeps it on disk across restarts of the dev server.\n */\nexport interface Done<Record = unknown> {\n done: Record;\n}\n\ntype Maybe<T> = T | Promise<T>;\n\n/**\n * Something of deictic's that went wrong, which nothing a person did in the page caused: a package the project\n * hasn't installed, a plugin that failed. The dev server says it, and hands it to each plugin with a `problem`\n * (tasks posts it to the board, for an agent to fix).\n */\nexport interface Problem {\n /**\n * What tells it apart, and the same problem again from a new one: `packages:rrweb`, `setup:tailwind`. Never a\n * time or an ID, so a problem that comes back is known.\n */\n key: string;\n /**\n * `setup`: the project's to fix, as `message` says (install a package, configure a plugin). `bug`: deictic's own, or\n * a plugin's, to report where it's made, not to patch where it's installed.\n */\n kind: 'setup' | 'bug';\n /** What went wrong, and the fix where there is one, as any problem message says it. */\n message: string;\n /** What more there is to look into: a stack. */\n details?: string;\n /** The plugin it's about, where it's one's: none for deictic's own. */\n plugin?: string;\n}\n\n/**\n * Each plugin's API to the others on the server, by name. A plugin adds its own, so `use` knows its type:\n * `declare module 'deictic' { interface ServerApis { screenshots: Screenshots } }`.\n */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ServerApis {}\n\n/** The same, in the page: `declare module 'deictic' { interface ClientApis { screenshots: Capture } }`. */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ClientApis {}\n\n/** A plugin's API, by its name: what its package declared, or `unknown` for one that declared none. */\nexport type ApiOf<Apis, Name extends string> = Name extends keyof Apis ? Apis[Name] : unknown;\n\nexport interface ServerContext {\n /** The project's root, as an absolute path. */\n root: string;\n /**\n * Another plugin's API, as its `setup` answered it, or nothing when it isn't loaded (or its `setup` failed,\n * which is reported). One the plugin `needs` always is loaded; any other may not be, so check.\n */\n use: <Name extends string>(name: Name) => ApiOf<ServerApis, Name> | undefined;\n /** Says a problem of the plugin's own, as deictic says its own: in the dev server's output, and to each plugin's `problem`. */\n report: (problem: Problem) => void;\n /**\n * Runs `callback` as the dev server closes, to undo what `setup` did beyond the plugin itself: a global it set, a\n * watcher or a server it started. Under Vite and webpack; a dev server that only ends with its process runs none.\n */\n onClose: (callback: () => Maybe<void>) => void;\n}\n\n/**\n * A route of the plugin's own, at `/__deictic/plugins/<name>/<route>`, and below it. A `GET` must\n * change nothing: anything else reaches it only from the page itself, which deictic checks.\n */\nexport type Route = (request: Request, context: ServerContext) => Maybe<Response>;\n\nexport interface ServerPlugin<Model = unknown, Op = unknown, Record = unknown, Api = unknown> {\n /** Ties the halves together; also the label of its changes in the history, and its routes' path. Lowercase, with `-`. */\n name: string;\n /** The module the page loads for this plugin's half there, which default-exports its `ClientPlugin`. */\n client?: string;\n /** What the page half gets as `context.options`: the user's options it needs there, as JSON. */\n clientOptions?: unknown;\n /** What opens its panel: its own default, which its options let the user change. A plugin with no panel has none. */\n shortcut?: Shortcut;\n /** The plugins it can't do without, by name: the dev server won't start without them. */\n needs?: string[];\n /**\n * The packages it imports that the project installs itself (optional peers), by name: as the dev server starts,\n * it says how to install any that's missing, rather than failing when first used.\n */\n packages?: string[];\n /** Runs once, as the dev server starts and before it answers anything. Answers the plugin's API to the others. */\n setup?(context: ServerContext): Maybe<Api>;\n /** Routes of its own, by their first segment under `/__deictic/plugins/<name>/`. */\n routes?: { [route: string]: Route };\n /**\n * The model its panel shows for an element. Without it, the panel gets none. `source` is a `Refusal` where the\n * element isn't to be found in its file (it doesn't parse, or the page runs other code than it has): throw it where\n * the plugin needs the source, or go on without it, as a task does.\n */\n read?(source: Source | Refusal, target: Target): Maybe<Model>;\n /** Text edits for deictic to write, which it refuses without the source, or a change the plugin made itself. */\n apply?(source: Source | Refusal, target: Target, op: Op): Maybe<TextEdit[] | Done<Record>>;\n /**\n * Takes back a change `apply` made itself, or throws a `Refusal` saying why it can't any more. It may\n * answer what the next redo needs, where that differs (what it put back has a new ID).\n */\n undo?(record: Record): Maybe<void | Record>;\n /** Makes it again after an undo, and answers what the next undo needs, which may differ (a new ID). */\n redo?(record: Record): Maybe<Record>;\n /** Says what an op does, for the history: `className: px-2 → px-4`. */\n describe?(op: Op, before: Model): string;\n /**\n * Hears each problem deictic or a plugin reports, on the server or in the page, after every `setup` has run: once\n * per `key` while the dev server runs. Its own failure is only said, never reported again.\n */\n problem?(problem: Problem): Maybe<void>;\n}\n\nexport const definePlugin = <Model, Op, Record = unknown, Api = unknown>(\n plugin: ServerPlugin<Model, Op, Record, Api>,\n): ServerPlugin<Model, Op, Record, Api> => plugin;\n\n/** Where something is in an element, in CSS pixels from its top left. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** A spot on the page: a marked element, and a point in it (or beside it, for the nearest to a point no marked element is under). */\nexport interface Spot {\n element: Element;\n at: Point;\n}\n\n/**\n * The tool panel: a bar docked to an edge of the window, which shows while a shortcut's keys are held and stays\n * while it's in use. A plugin adds its tools to it from its page half's `setup`.\n */\nexport interface ToolPanel {\n /**\n * Adds a plugin's controls, as one group, in the order plugins are loaded. Groups of one `section` sit together,\n * with no line between them, after the groups of none: the screenshots', recordings', voice's and tasks' are\n * `capture`. `last` puts a group at the end of its section, or after all the others for one of none. Each control is a button named by its `title`; its `aria-keyshortcuts`\n * (`B`, `Control+Z`) is the key the panel hears for it, alone or with the keys held to point, and what its tooltip\n * shows.\n */\n add: (group: HTMLElement, options?: { last?: boolean; section?: string }) => void;\n /**\n * Takes the page for a tool that works on it (drawing, picking a point): the tool that had it lets go first, and\n * the panel stays shown. `left` is called when another takes it, or Esc or the pointer tool gives the page back.\n * Answers what lets go of it, for the tool to call when it's done on its own.\n */\n hold: (left: () => void) => () => void;\n /** Keeps the panel shown while something goes on that its controls end (a recording). Answers what ends that. */\n keep: () => () => void;\n /**\n * Takes the page until a point of it is pressed, lighting what's under the pointer as pointing does: answers the\n * spot, the marked element there or the nearest to it, or nothing where the page was given back first.\n */\n pick: () => Promise<Spot | undefined>;\n}\n\n/**\n * The drawer: on the window's side, where what the plugins have for the page lands, a section each. It\n * shows while a shortcut's keys are held and a section has something, and stays while it's in use.\n */\nexport interface Drawer {\n /**\n * Adds a section, in the order added, or before the others with `first`. A section that has nothing to show sets\n * its own `hidden`: the drawer stays away while every one is. Folded away, the drawer counts what the sections\n * have: each says how many things it lists in `data-count`, and how many are unread in `data-unread`.\n */\n add: (section: HTMLElement, options?: { first?: boolean }) => void;\n /**\n * Opens one item in the drawer, in the sections' place, under `title` and a way back. The drawer stays while it's\n * open. `closed` is called when it's left, by the way back, Esc, or another item opening. Answers what closes it.\n */\n show: (view: HTMLElement, options?: { title?: string; closed?: () => void }) => () => void;\n /** Keeps the drawer up while something goes on in it; answers what lets it go. */\n keep: () => () => void;\n}\n\n/** Something a plugin made on the page that nothing has taken yet: a shot, a recording, a voice clip. */\nexport interface TrayItem {\n /** The plugin that made it. */\n plugin: string;\n /** Its ID, as that plugin has it. */\n id: string;\n /** What that plugin says of it, as JSON: the screenshots plugin's `Shot`, a `Recording`, a `Clip`. */\n value: unknown;\n}\n\n/**\n * What plugins made on the page from the tool panel, until something takes it: a task attaches what's there and\n * removes it. Kept for the tab's session, so it's there on the tab's next page too.\n */\nexport interface Tray {\n /** What's kept, oldest first: all of it, or one plugin's. */\n list: (plugin?: string) => TrayItem[];\n add: (plugin: string, id: string, value: unknown) => void;\n /** Takes one out, or all of a plugin's. */\n remove: (plugin: string, id?: string) => void;\n /** Hears every change from now on; answers what stops it. */\n subscribe: (listener: () => void) => () => void;\n}\n\nexport interface ClientContext {\n /** The dev server's base URL, ending in `/`. */\n base: string;\n /** deictic's shadow root, to draw in: neither the page's styles nor the overlay's cross over. */\n root: ShadowRoot;\n /** The server half's `clientOptions`, or nothing. */\n options: unknown;\n /** Another plugin's API in the page, as its `setup` answered it, or nothing when it isn't loaded. */\n use: <Name extends string>(name: Name) => ApiOf<ClientApis, Name> | undefined;\n /** Asks one of this plugin's own routes, from the page: `request('shots', { method: 'POST', body: blob })`. */\n request: (route: string, init?: RequestInit) => Promise<Response>;\n /** Says a problem of the plugin's own to the dev server, as the server half's `report` does: its `plugin` is this one. */\n report: (problem: Problem) => void;\n /**\n * Opens a place in a file under the root in the editor, as the popup's own link opens the element's: through the\n * dev server, or what answers in its place (`Standalone`). Rejects with why it couldn't.\n */\n edit: (place: Loc) => Promise<void>;\n /**\n * Opens the popup on an element at a plugin's tab, as its shortcut would, or with `at` on a spot in it: the\n * popup is then beside the spot, which is what's lit, and the tab's context has it. An element rendered again\n * since stands in for one no longer on the page. False when there's no such tab or no such element any more, and\n * while the open popup holds something unsaved, whose button then shakes. Not as `setup` runs, which is before the\n * popup can open.\n */\n open: (plugin: string, element: Element, at?: Point) => boolean;\n /** The tool panel, to add this plugin's tools to. */\n tools: ToolPanel;\n /** What was made from the tool panel and not taken yet. */\n tray: Tray;\n /** The drawer, to add this plugin's section to. */\n drawer: Drawer;\n /**\n * Lights an element on the page as pointing at it does, for something of the overlay's own that stands for it (a\n * task's row in the drawer, while the pointer is on it); none puts the light back as it was.\n */\n light: (element?: Element) => void;\n /**\n * Shows `items` in the lightbox over everything, at `at` (the first by default), stepping between them with\n * ← and →. With `from`, it grows out of that element (the chip clicked) and shrinks back into it on close.\n */\n lightbox: (items: LightboxItem[], options?: LightboxOptions) => { close: () => void };\n}\n\n/** What the lightbox shows: a picture, a page in a frame (a recording's replay), or a sound with its waveform. */\nexport type LightboxItem = {\n /** Its name, over it. */\n title: string;\n /** Buttons beside the name: each closes the lightbox and runs. */\n actions?: LightboxAction[];\n} & ({ kind: 'image'; url: string } | { kind: 'page'; url: string } | { kind: 'audio'; url: string });\n\nexport interface LightboxAction {\n label: string;\n title?: string;\n run: () => void;\n}\n\nexport interface LightboxOptions {\n /** The item it opens at. */\n at?: number;\n /** The element it grows out of, and goes back into. */\n from?: Element;\n}\n\nexport interface PanelContext<Model, Op> extends ClientContext {\n /**\n * The element clicked: the one the source marked, under the pointer or around what is. Back from `away`\n * it may be off the page (`isConnected` is false), where the page moved on without it: the element as it\n * was left, or after a page load an empty one of its tag and mark. `elements` is then empty.\n */\n element: Element;\n /**\n * What was under the pointer, where it isn't `element` but inside it: markup nothing marked, as a\n * dependency's, or in an open shadow root, as the popup's own on a page that shows it (`popupIn`).\n */\n pointed?: Element;\n /** The spot in `element` the popup was opened on, where it was (the tool panel's task tool), not the element as a whole. */\n at?: Point;\n /** Every element on the page from the same place in the source, the clicked one among them: the rows of a list. */\n elements: Element[];\n target: Target;\n model: Model;\n /**\n * Applies an op on disk, and reads the model again. Rejects with the server's reason, which the panel also shows.\n * On another element with `on`, whose model is then the one answered: for an op that's about that one.\n */\n apply(op: Op, on?: Target): Promise<Model>;\n close: () => void;\n /**\n * Says there's something here that leaving would lose (words typed, a change tried on the page), and the button\n * that keeps it: a click outside the popup then shakes that button, where it would have closed the popup.\n * `undefined` once there's nothing to lose. Forgotten as the panel unmounts.\n */\n unsaved: (action: HTMLElement | undefined) => void;\n /**\n * Leaves the popup to do something on the page, then comes back: closes it, runs `task` (a recording, a\n * pick of another element), and opens it again at this tab on this element. The next mount gets\n * `resumed`: the `state` kept now (what was typed, what's attached), and what `task` answered, or why\n * it failed. The state stays in the page, as it is: no need for JSON. It's also kept for the tab's next\n * page, as a structured clone, where it can be one: after a page load, the plugin's `resume` says whether\n * the task carries on, and the popup comes back there.\n */\n away: <T>(state: unknown, task: () => Promise<T>) => void;\n /** Set when this mount is the panel coming back from `away`. */\n resumed?: Resumed;\n}\n\n/** What a panel coming back from `away` gets: the state it kept, and the task's result or problem. */\nexport interface Resumed {\n state: unknown;\n result?: unknown;\n /** Why the task failed: its error's message. */\n problem?: string;\n}\n\n/** A plugin's own tag in the caption over what's pointed at, after deictic's: prosebook's names the string's key. */\nexport interface Tag {\n text: string;\n /** Its background, a CSS color: deictic's accent unset. Its text is white. */\n color?: string;\n}\n\nexport interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {\n /** The server half's `name`. */\n name: string;\n /** Shown over the element while its shortcut's keys are held, and atop the panel. */\n label?: string;\n /**\n * Runs once, as the page starts, before any panel opens (a recording starts here). Answers the\n * plugin's API to the others in the page, at once: one that needs time keeps its promises inside it.\n */\n setup?(context: ClientContext): Api;\n /**\n * Asked as a page starts where the page before it left this plugin's panel `away`: the task it left for,\n * where that carries on in this page (a recording does), or nothing where it ended with the page. When it's\n * done the popup opens at this tab with `resumed`, on the element where this page has it and without where not.\n */\n resume?(context: ClientContext): Promise<unknown> | undefined;\n /**\n * What it shows on the page while a shortcut's keys are held, and the page is dimmed to point on: the tasks\n * plugin pins each task where its element is. Answers what takes it away.\n */\n pointing?(context: ClientContext): () => void;\n /**\n * Its tag in the caption for what's under the pointer, at `at` in the window's CSS pixels, or nothing. Asked on\n * every move while pointing, so it must be quick.\n */\n tag?(context: ClientContext, at: Point): Tag | undefined;\n /**\n * A shortcut's press on a marked element, before the page hears it and before the popup opens: the page as the\n * person saw it, a tooltip still open under the pointer, a menu still focused. Called as the press goes down, so\n * it must be quick; the screenshots plugin keeps what a shot needs here, and renders it later.\n */\n pressed?(context: ClientContext, element: Element): void;\n /** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */\n mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;\n}\n\nexport const defineClientPlugin = <Model, Op, Api = unknown>(plugin: ClientPlugin<Model, Op, Api>): ClientPlugin<Model, Op, Api> => plugin;\n"],"mappings":";;AAqEA,IAAa,UAAb,cAA6B,MAAM;CACxB,OAAO;AAClB;AAqHA,MAAa,gBACX,WACyC;AAqP3C,MAAa,sBAAgD,WAAuE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deictic",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Point at an element in your running app and leave a task about it for your agent.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -391,7 +391,21 @@ export function start({ base, shortcut: own, plugins: given, server }: StartOpti
391
391
  const name = plugin.label ?? plugin.name;
392
392
  return [shortcut.button === 'left' ? name : `${name} (${shortcut.button})`];
393
393
  });
394
- lighting.point({ el, ...(hit?.pointed === undefined ? {} : { pointed: hit.pointed }), target, names, count: sameAs(el).length }, glide);
394
+ const at = pointer!;
395
+ const tags = given.flatMap(({ plugin }) => {
396
+ if (plugin.tag === undefined) return [];
397
+ try {
398
+ const tag = plugin.tag(contextOf(plugin.name), at);
399
+ return tag === undefined ? [] : [tag];
400
+ } catch (e) {
401
+ report(failed(plugin.name, 'tag what was pointed at', e));
402
+ return [];
403
+ }
404
+ });
405
+ lighting.point(
406
+ { el, ...(hit?.pointed === undefined ? {} : { pointed: hit.pointed }), target, names, count: sameAs(el).length, tags },
407
+ glide,
408
+ );
395
409
  };
396
410
  const update = (e: MouseEvent | KeyboardEvent) => {
397
411
  held = heldBy(e);
@@ -7,7 +7,7 @@
7
7
  * open the element stays lit, tied to the popup by a line that follows both. Nothing here takes the pointer, and
8
8
  * the page comes back to full light once the pointer has been out on it a moment.
9
9
  */
10
- import type { Point, Target } from '#src/index.ts';
10
+ import type { Point, Tag, Target } from '#src/index.ts';
11
11
 
12
12
  import { named } from './component.ts';
13
13
  import { div, nameOf, place, reduced } from './dom.ts';
@@ -26,6 +26,8 @@ export interface Pointed {
26
26
  names: string[];
27
27
  /** How many elements on the page are from its place in the source. */
28
28
  count: number;
29
+ /** The plugins' own tags for what's under the pointer (`ClientPlugin.tag`), after deictic's. */
30
+ tags?: Tag[];
29
31
  }
30
32
 
31
33
  export interface Lighting {
@@ -133,7 +135,7 @@ export function spotlight(root: ShadowRoot): Lighting {
133
135
  const part = (className: string, text: string) => Object.assign(document.createElement('span'), { className, textContent: text });
134
136
 
135
137
  return {
136
- point({ el, pointed, target, names, count }, glide = true) {
138
+ point({ el, pointed, target, names, count, tags = [] }, glide = true) {
137
139
  pointing = true;
138
140
  const box = el.getBoundingClientRect();
139
141
  const r = grown(box);
@@ -166,11 +168,17 @@ export function spotlight(root: ShadowRoot): Lighting {
166
168
  from: `${target.loc.file}:${target.loc.line}`,
167
169
  opens: names.join(' / '),
168
170
  };
169
- const saying = JSON.stringify([texts, dim]);
171
+ const saying = JSON.stringify([texts, dim, tags]);
170
172
  if (saying !== said) {
171
173
  said = saying;
172
174
  caption.replaceChildren(
173
175
  part('tag', texts.tag),
176
+ ...tags.map(({ text, color }) => {
177
+ const own = part('tag', text);
178
+ if (color !== undefined) own.style.background = color;
179
+ own.style.color = '#fff';
180
+ return own;
181
+ }),
174
182
  ...(texts.inside === '' ? [] : [part('dim', texts.inside)]),
175
183
  part('', texts.from),
176
184
  ...dim.map((text) => part('dim', text)),
package/src/index.ts CHANGED
@@ -390,6 +390,13 @@ export interface Resumed {
390
390
  problem?: string;
391
391
  }
392
392
 
393
+ /** A plugin's own tag in the caption over what's pointed at, after deictic's: prosebook's names the string's key. */
394
+ export interface Tag {
395
+ text: string;
396
+ /** Its background, a CSS color: deictic's accent unset. Its text is white. */
397
+ color?: string;
398
+ }
399
+
393
400
  export interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {
394
401
  /** The server half's `name`. */
395
402
  name: string;
@@ -411,6 +418,11 @@ export interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {
411
418
  * plugin pins each task where its element is. Answers what takes it away.
412
419
  */
413
420
  pointing?(context: ClientContext): () => void;
421
+ /**
422
+ * Its tag in the caption for what's under the pointer, at `at` in the window's CSS pixels, or nothing. Asked on
423
+ * every move while pointing, so it must be quick.
424
+ */
425
+ tag?(context: ClientContext, at: Point): Tag | undefined;
414
426
  /**
415
427
  * A shortcut's press on a marked element, before the page hears it and before the popup opens: the page as the
416
428
  * person saw it, a tooltip still open under the pointer, a menu still focused. Called as the press goes down, so