deictic 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/API.md +136 -30
  2. package/README.md +4 -3
  3. package/dist/annotations/client.d.ts +1 -1
  4. package/dist/annotations/client.d.ts.map +1 -1
  5. package/dist/annotations/client.js +161 -176
  6. package/dist/annotations/client.js.map +1 -1
  7. package/dist/annotations/index.d.ts +2 -11
  8. package/dist/client/index.d.ts +7 -6
  9. package/dist/client/index.d.ts.map +1 -1
  10. package/dist/client/index.js +1007 -192
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/index.d.ts +2 -2
  13. package/dist/recommended/index.d.ts +2 -2
  14. package/dist/recordings/client.d.ts.map +1 -1
  15. package/dist/recordings/client.js +82 -153
  16. package/dist/recordings/client.js.map +1 -1
  17. package/dist/screenshots/client.d.ts.map +1 -1
  18. package/dist/shared/annotations.js +3 -4
  19. package/dist/shared/annotations.js.map +1 -1
  20. package/dist/shared/board.js +1 -1
  21. package/dist/shared/client.js +45 -2
  22. package/dist/shared/client.js.map +1 -1
  23. package/dist/shared/component.js +62 -0
  24. package/dist/shared/component.js.map +1 -0
  25. package/dist/shared/dom.js +79 -0
  26. package/dist/shared/dom.js.map +1 -0
  27. package/dist/shared/drawer.js +217 -0
  28. package/dist/shared/drawer.js.map +1 -0
  29. package/dist/shared/index.d.ts +116 -7
  30. package/dist/shared/index.d.ts.map +1 -1
  31. package/dist/shared/index2.d.ts +9 -19
  32. package/dist/shared/index2.d.ts.map +1 -1
  33. package/dist/shared/index7.d.ts +103 -26
  34. package/dist/shared/index7.d.ts.map +1 -1
  35. package/dist/shared/index9.d.ts +1 -1
  36. package/dist/shared/integration.d.ts +1 -1
  37. package/dist/shared/packages.js +1 -1
  38. package/dist/shared/recording.js +31 -3
  39. package/dist/shared/recording.js.map +1 -1
  40. package/dist/shared/src.js.map +1 -1
  41. package/dist/shared/task.js +44 -29
  42. package/dist/shared/task.js.map +1 -1
  43. package/dist/shared/tasks.js +232 -62
  44. package/dist/shared/tasks.js.map +1 -1
  45. package/dist/shared/vb.js +1 -1
  46. package/dist/shared/voice2.js +6 -4
  47. package/dist/shared/voice2.js.map +1 -1
  48. package/dist/shared/watch.js +14 -14
  49. package/dist/shared/watch.js.map +1 -1
  50. package/dist/tasks/client.d.ts +2 -2
  51. package/dist/tasks/client.d.ts.map +1 -1
  52. package/dist/tasks/client.js +1829 -741
  53. package/dist/tasks/client.js.map +1 -1
  54. package/dist/tasks/index.d.ts +2 -2
  55. package/dist/voice/client.d.ts.map +1 -1
  56. package/dist/voice/client.js +154 -57
  57. package/dist/voice/client.js.map +1 -1
  58. package/package.json +1 -1
  59. package/skills/deictic/SKILL.md +22 -28
  60. package/src/cli/recording.ts +34 -3
  61. package/src/cli/task.ts +59 -30
  62. package/src/cli/voice.ts +9 -4
  63. package/src/cli/watch.ts +14 -13
  64. package/src/client/away.ts +3 -1
  65. package/src/client/component.ts +98 -0
  66. package/src/client/dom.ts +70 -0
  67. package/src/client/drawer.ts +258 -0
  68. package/src/client/index.ts +220 -128
  69. package/src/client/lightbox.ts +8 -8
  70. package/src/client/lighting.ts +279 -0
  71. package/src/client/style.ts +263 -44
  72. package/src/client/tools.ts +279 -0
  73. package/src/client/tooltip.ts +25 -5
  74. package/src/client/tray.ts +48 -0
  75. package/src/index.ts +113 -6
  76. package/src/plugins/annotations/client.ts +103 -129
  77. package/src/plugins/annotations/draw.ts +68 -72
  78. package/src/plugins/annotations/index.ts +12 -19
  79. package/src/plugins/recordings/client.ts +89 -167
  80. package/src/plugins/screenshots/client.ts +53 -2
  81. package/src/plugins/tasks/client.ts +219 -748
  82. package/src/plugins/tasks/composer.ts +797 -0
  83. package/src/plugins/tasks/drawer.ts +516 -0
  84. package/src/plugins/tasks/index.ts +360 -82
  85. package/src/plugins/tasks/pins.ts +275 -0
  86. package/src/plugins/tasks/store.ts +132 -0
  87. package/src/plugins/voice/client.ts +96 -5
  88. package/skills/deictic/references/recordings.md +0 -13
  89. package/skills/deictic/references/tasks.md +0 -22
  90. package/skills/deictic/references/watch.md +0 -17
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../../src/plugins/annotations/svg.ts","../../src/plugins/annotations/draw.ts","../../src/plugins/annotations/client.ts"],"sourcesContent":["/**\n * Annotations as SVG: the layer the page shows them in, and what a screenshot draws over itself. Shapes\n * only, no `foreignObject`, so a canvas that draws the SVG isn't tainted, and a browser rendering it\n * elsewhere needs nothing of the page.\n */\nimport type { Annotation, Area, Point } from './index.ts';\n\nexport const STROKE = 3;\nexport const FONT = 14;\nconst PAD = 6;\n\n/** How wide text is, in CSS pixels: measured where there's a canvas, guessed where there isn't. */\nexport type Measure = (text: string) => number;\n\nexport const guess: Measure = (text) => text.length * FONT * 0.6;\n\nconst escape = (text: string) => text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('\"', '&quot;');\nconst n = (value: number) => Math.round(value * 10) / 10;\n\n/** An arrow's path: its line, then its head, two strokes back from the tip either side of the line. */\nfunction arrow(from: Point, to: Point): string {\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const at = (p: Point) => `${n(p.x)},${n(p.y)}`;\n const side = (turn: number) => at({ x: to.x - 14 * Math.cos(angle + turn), y: to.y - 14 * Math.sin(angle + turn) });\n return `M${at(from)} L${at(to)} M${side(0.45)} L${at(to)} L${side(-0.45)}`;\n}\n\nfunction shapeOf({ shape, color }: Annotation, measure: Measure): string {\n const line = `fill=\"none\" stroke=\"${escape(color)}\" stroke-width=\"${STROKE}\" stroke-linecap=\"round\" stroke-linejoin=\"round\"`;\n switch (shape.kind) {\n case 'box':\n return `<rect x=\"${n(shape.x)}\" y=\"${n(shape.y)}\" width=\"${n(shape.width)}\" height=\"${n(shape.height)}\" rx=\"4\" ${line}/>`;\n case 'arrow':\n return `<path d=\"${arrow(shape.from, shape.to)}\" ${line}/>`;\n case 'pen':\n return `<polyline points=\"${shape.points.map((p) => `${n(p.x)},${n(p.y)}`).join(' ')}\" ${line}/>`;\n case 'note': {\n const lines = shape.text.split('\\n');\n const width = Math.max(...lines.map(measure)) + PAD * 2;\n const height = lines.length * FONT * 1.3 + PAD * 2;\n const text = lines\n .map(\n (l, i) => `<tspan x=\"${n(shape.at.x + PAD)}\" y=\"${n(shape.at.y + PAD + FONT * (i + 1) * 1.3 - FONT * 0.3)}\">${escape(l)}</tspan>`,\n )\n .join('');\n return (\n `<rect x=\"${n(shape.at.x)}\" y=\"${n(shape.at.y)}\" width=\"${n(width)}\" height=\"${n(height)}\" rx=\"4\" fill=\"${escape(color)}\"/>` +\n `<text font-family=\"system-ui, sans-serif\" font-size=\"${FONT}\" fill=\"#fff\">${text}</text>`\n );\n }\n }\n}\n\n/**\n * The annotations over `area` of the viewport, the page scrolled by `scroll`: an SVG `area`'s size,\n * whose view is that part of the page.\n */\nexport function toSvg(annotations: readonly Annotation[], area: Area, scroll: Point, measure: Measure = guess): string {\n const view = `${n(area.x + scroll.x)} ${n(area.y + scroll.y)} ${n(area.width)} ${n(area.height)}`;\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${n(area.width)}\" height=\"${n(area.height)}\" viewBox=\"${view}\">${annotations.map((a) => shapeOf(a, measure)).join('')}</svg>`;\n}\n","/**\n * Drawing with the pointer, wherever marks go: the page in annotate mode, or a picture in the editor.\n * Each says where an event is in its marks' coordinates; this is the toolbar and the gestures.\n */\nimport type { Point, Shape } from './index.ts';\nimport { FONT, guess, type Measure } from './svg.ts';\n\nexport const TOOLS_STYLE = `\n.annotations-tools { display: flex; flex-wrap: wrap; gap: 4px; }\n.annotations-tools .icon { display: inline-flex; align-items: center; justify-content: center; padding: 3px 5px; }\n.annotations-tools .icon svg { width: 16px; height: 16px; }\n.annotations-tools .gap { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--deictic-line); }\n.annotations-tools button[aria-pressed='true'] { background: var(--deictic-accent); border-color: var(--deictic-accent); color: var(--deictic-on-accent); }\n.annotations-tools .end { margin-left: auto; }\n.annotations-hint { margin: 6px 0 0; font-size: 12px; color: var(--deictic-muted); }\n`;\n\ntype Tool = 'pointer' | 'box' | 'arrow' | 'pen' | 'note';\nconst TOOLS: Tool[] = ['box', 'arrow', 'pen', 'note'];\nconst NAMES: Record<Tool, string> = {\n pointer: 'Use the page',\n box: 'Draw a box',\n arrow: 'Draw an arrow',\n pen: 'Draw freehand',\n note: 'Add a note',\n};\n\n/** Each icon's strokes, on a 24-pixel grid: drawn here, so the page half needs nothing to show them. */\nconst ICONS = {\n pointer: '<path d=\"M5 3l14 7-6 2-2 6z\"/>',\n box: '<rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\"/>',\n arrow: '<path d=\"M6 18 18 6M9 6h9v9\"/>',\n pen: '<path d=\"M4 20l1-4L16 5a2.1 2.1 0 0 1 3 3L8 19z\"/>',\n note: '<path d=\"M4 5h16v11H9l-5 4zM8 9h8M8 12h5\"/>',\n undo: '<path d=\"M9 14 4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3\"/>',\n clear: '<path d=\"M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3\"/>',\n} as const;\n\n/** A button that shows an icon, with its name as its tooltip and for a screen reader. */\nexport function iconButton(icon: keyof typeof ICONS, name: string, run: () => void): HTMLButtonElement {\n const el = button('', name, run);\n el.className = 'icon';\n el.setAttribute('aria-label', name);\n el.innerHTML = `<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">${ICONS[icon]}</svg>`;\n return el;\n}\n\n/** Text's width as the marks draw it, by a canvas's measure, which the guess stands in for without one. */\nexport function measurer(): Measure {\n const ctx = document.createElement('canvas').getContext('2d');\n if (ctx === null) return guess;\n ctx.font = `${FONT}px system-ui, sans-serif`;\n return (text) => ctx.measureText(text).width;\n}\n\nexport function button(label: string, title: string, run: () => void): HTMLButtonElement {\n const el = Object.assign(document.createElement('button'), { type: 'button', textContent: label, title });\n el.addEventListener('click', run);\n return el;\n}\n\nexport interface DrawingOptions {\n /** What takes the pointer to draw on. */\n surface: HTMLElement;\n /** Where an event is, in the coordinates the marks are kept in. */\n at: (e: PointerEvent) => Point;\n /** Shows the shape being drawn, or nothing once it's done. */\n preview: (shape: Shape | undefined) => void;\n add: (shape: Shape) => void;\n removeLast: () => void;\n clear: () => void;\n /**\n * Where the page stays usable between marks (a recording's toolbar): a pointer tool comes first and is\n * picked to start with, and this hears whether a drawing tool is picked, to let the surface take the\n * pointer only then.\n */\n drawing?: (on: boolean) => void;\n}\n\n/**\n * Draws on `surface` with the tool picked: answers the toolbar (the tools, then removing the last mark or all), for the\n * caller to add its own buttons to, and a hint for the tool.\n */\nexport function drawing({ surface, at, preview, add, removeLast, clear, drawing: on }: DrawingOptions) {\n const tools = document.createElement('div');\n tools.className = 'annotations-tools';\n const hint = document.createElement('p');\n hint.className = 'annotations-hint';\n\n let tool: Tool = on === undefined ? 'box' : 'pointer';\n const picks = (on === undefined ? TOOLS : (['pointer', ...TOOLS] as Tool[])).map((t) => ({\n t,\n el: iconButton(t, NAMES[t], () => pick(t)),\n }));\n const pick = (t: Tool) => {\n tool = t;\n for (const p of picks) p.el.setAttribute('aria-pressed', String(p.t === t));\n on?.(t !== 'pointer');\n hint.textContent =\n t === 'pointer'\n ? 'Use the page; pick a tool to draw.'\n : t === 'note'\n ? 'Click where the note goes, type it, Enter to place it.'\n : 'Drag to draw.';\n };\n const gap = document.createElement('span');\n gap.className = 'gap';\n tools.append(\n ...picks.map((p) => p.el),\n gap,\n iconButton('undo', 'Remove the last mark', removeLast),\n iconButton('clear', 'Remove every mark', clear),\n );\n pick(tool);\n\n surface.style.cursor = 'crosshair';\n const shapeFrom = (from: Point, to: Point, points: Point[]): Shape | undefined => {\n if (tool === 'pen') return points.length > 1 ? { kind: 'pen', points } : undefined;\n if (Math.hypot(to.x - from.x, to.y - from.y) < 4) return undefined;\n if (tool === 'arrow') return { kind: 'arrow', from, to };\n return {\n kind: 'box',\n x: Math.min(from.x, to.x),\n y: Math.min(from.y, to.y),\n width: Math.abs(to.x - from.x),\n height: Math.abs(to.y - from.y),\n };\n };\n\n surface.addEventListener('pointerdown', (e) => {\n if (e.button !== 0 || e.target instanceof HTMLInputElement) return;\n e.preventDefault();\n if (tool === 'note') return note(at(e), e);\n const from = at(e);\n const points = [from];\n surface.setPointerCapture(e.pointerId);\n const move = (m: PointerEvent) => {\n points.push(at(m));\n preview(shapeFrom(from, at(m), points));\n };\n const up = (u: PointerEvent) => {\n surface.removeEventListener('pointermove', move);\n preview(undefined);\n const shape = shapeFrom(from, at(u), points);\n if (shape !== undefined) add(shape);\n };\n surface.addEventListener('pointermove', move);\n surface.addEventListener('pointerup', up, { once: true });\n });\n\n /** A field where the note goes: Enter places what's typed, leaving it empty or blurring it places nothing. */\n const note = (point: Point, e: PointerEvent) => {\n const field = Object.assign(document.createElement('input'), { placeholder: 'Note, then Enter' });\n // Its own colours: on the page, outside the popup, it would take the page's text colour on deictic's dark field.\n field.style.cssText = `position:fixed;left:${e.clientX}px;top:${e.clientY}px;width:220px;pointer-events:auto;cursor:text;color:var(--deictic-fg);background:var(--deictic-bg);border-color:var(--deictic-accent)`;\n surface.append(field);\n const place = () => {\n const text = field.value.trim();\n field.remove();\n if (text !== '') add({ kind: 'note', at: point, text });\n };\n field.addEventListener('keydown', (k) => k.key === 'Enter' && place());\n field.addEventListener('blur', () => field.isConnected && place());\n // Now, not a frame later: the pointerdown's default is prevented, so no mousedown takes focus back.\n field.focus();\n };\n\n return { tools, hint };\n}\n","/**\n * Annotations in the page. `setup` keeps them (in the tab's session storage, per page) and shows them in a\n * layer of deictic's overlay that lets the pointer through; it answers the API other plugins `use`. The\n * panel is annotate mode: a toolbar, and while it's open a surface over the page that takes the pointer, so\n * drawing never clicks the page. Esc or Done leaves it; the marks stay.\n *\n * The layer is deictic's, so a screenshot leaves it out with the rest of the overlay and draws the marks\n * itself from `svg(area)`: one way to draw them, wherever a shot is rendered. `edit` draws on a picture\n * instead, a shot most often, in the same toolbar over everything, and `flatten` makes the PNG of it.\n */\nimport { defineClientPlugin } from '#src/index.ts';\n\nimport { button, drawing, measurer, TOOLS_STYLE } from './draw.ts';\nimport type { Annotation, AnnotationEvent, Annotations, Area, MarkSet, Picture, Point, Shape } from './index.ts';\nimport { type Measure, toSvg } from './svg.ts';\n\n/** Under deictic's outline and panels, over the page. */\nconst LAYER = 2147483645;\n/** Over everything of deictic's, the popup too. */\nconst TOP = 2147483647;\n\nconst scroll = (): Point => ({ x: scrollX, y: scrollY });\nconst viewport = (): Area => ({ x: 0, y: 0, width: document.documentElement.clientWidth, height: document.documentElement.clientHeight });\nconst mark = (shape: Shape, color: string): Annotation => ({ id: crypto.randomUUID(), color, shape, at: Date.now() });\n\n/** What's kept for this page in the tab's session, read as it can be. */\nfunction stored(key: string): Annotation[] {\n try {\n const kept: unknown = JSON.parse(sessionStorage.getItem(key) ?? '[]');\n return Array.isArray(kept) ? (kept as Annotation[]) : [];\n } catch {\n // Storage can be off, or hold something else: no marks is the page as it was.\n return [];\n }\n}\n\nfunction fixed(z: number): HTMLDivElement {\n const el = document.createElement('div');\n el.style.cssText = `position:fixed;inset:0;z-index:${z};pointer-events:none`;\n return el;\n}\n\nconst EDITOR_STYLE = `\n.annotations-editor { position: fixed; inset: 0; z-index: ${TOP}; box-sizing: border-box; padding: 16px; display: flex;\n flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgb(0 0 0 / 0.75);\n font: 13px/1.4 system-ui, sans-serif; color: var(--deictic-fg); }\n.annotations-editor .bar { box-sizing: border-box; width: min(100%, 720px); padding: 6px 8px; border: 1px solid var(--deictic-line);\n border-radius: 8px; background: var(--deictic-bg); }\n.annotations-editor .stage { position: relative; line-height: 0; box-shadow: 0 12px 32px rgb(0 0 0 / 0.5); touch-action: none; }\n.annotations-editor img { display: block; max-width: calc(100vw - 32px); max-height: calc(100vh - 120px); user-select: none; }\n.annotations-editor .marks { position: absolute; inset: 0; pointer-events: none; }\n`;\n\n/** Loads an image, decoded. */\nasync function image(src: string): Promise<HTMLImageElement> {\n const el = new Image();\n el.src = src;\n await el.decode();\n return el;\n}\n\n/** The marks over a whole picture, as an SVG whose view is the picture's CSS pixels. */\nconst over = (picture: Picture, marks: readonly Annotation[], measure?: Measure) =>\n toSvg(marks, { x: 0, y: 0, width: picture.width, height: picture.height }, { x: 0, y: 0 }, measure);\n\n/**\n * The picture over everything, to draw on: the marks on Save, nothing on Cancel, Esc or `signal`. It holds\n * Esc while it's open (`data-deictic-modal`), so Esc leaves it, not the popup under it.\n */\nfunction edit(\n root: ShadowRoot,\n picture: Picture,\n start: readonly Annotation[],\n { color, measure, signal }: { color: string; measure: Measure; signal?: AbortSignal },\n): Promise<Annotation[] | undefined> {\n return new Promise((resolve) => {\n let marks = [...start];\n const backdrop = document.createElement('div');\n backdrop.className = 'annotations-editor';\n backdrop.dataset.deicticModal = '';\n const style = document.createElement('style');\n style.textContent = TOOLS_STYLE + EDITOR_STYLE;\n const bar = document.createElement('div');\n bar.className = 'bar';\n const stage = document.createElement('div');\n stage.className = 'stage';\n const img = Object.assign(document.createElement('img'), { src: picture.url, alt: 'The screenshot', draggable: false });\n const layer = document.createElement('div');\n layer.className = 'marks';\n stage.append(img, layer);\n\n const show = (preview?: Shape) => {\n layer.innerHTML = over(picture, preview === undefined ? marks : [...marks, mark(preview, color)], measure);\n // Drawn at the size the picture shows at, whatever that is: the view is the picture's own pixels.\n const svg = layer.firstElementChild;\n svg?.setAttribute('width', '100%');\n svg?.setAttribute('height', '100%');\n };\n const { tools, hint } = drawing({\n surface: stage,\n at: (e) => {\n const r = stage.getBoundingClientRect();\n return { x: ((e.clientX - r.left) * picture.width) / r.width, y: ((e.clientY - r.top) * picture.height) / r.height };\n },\n preview: (shape) => show(shape),\n add: (shape) => {\n marks = [...marks, mark(shape, color)];\n show();\n },\n removeLast: () => {\n marks = marks.slice(0, -1);\n show();\n },\n clear: () => {\n marks = [];\n show();\n },\n });\n const end = (result: Annotation[] | undefined) => {\n backdrop.remove();\n window.removeEventListener('keydown', onKey, true);\n signal?.removeEventListener('abort', cancel);\n resolve(result);\n };\n const cancel = () => end(undefined);\n const onKey = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n e.stopPropagation();\n cancel();\n };\n const save = button('Save', 'Keep these marks', () => end(marks));\n save.classList.add('primary');\n const back = button('Cancel', 'Leave it as it was (Esc)', cancel);\n back.classList.add('end');\n tools.append(back, save);\n bar.append(tools, hint);\n backdrop.append(style, bar, stage);\n root.append(backdrop);\n window.addEventListener('keydown', onKey, true);\n signal?.addEventListener('abort', cancel);\n show();\n });\n}\n\n/**\n * Marks shown on the page, in a layer of the overlay that lets the pointer through, redrawn as it\n * scrolls. With a `key`, kept in the tab's session storage under it, per page; without, kept by nothing.\n */\nfunction marksOnPage(root: ShadowRoot, color: string, measure: Measure, key?: string): { marks: MarkSet; remove: () => void } {\n let list = key === undefined ? [] : stored(key);\n const listeners = new Set<(event: AnnotationEvent) => void>();\n const layer = fixed(LAYER);\n root.append(layer);\n\n let frame = 0;\n const draw = () => {\n frame = 0;\n layer.innerHTML = list.length === 0 ? '' : toSvg(list, viewport(), scroll(), measure);\n };\n const redraw = () => {\n if (frame === 0) frame = requestAnimationFrame(draw);\n };\n window.addEventListener('scroll', redraw, { capture: true, passive: true });\n window.addEventListener('resize', redraw, { passive: true });\n const changed = (event: AnnotationEvent) => {\n if (key !== undefined) {\n try {\n sessionStorage.setItem(key, JSON.stringify(list));\n } catch {\n // Not kept past a reload, then; the page still shows them.\n }\n }\n draw();\n for (const listener of listeners) listener(event);\n };\n draw();\n\n const marks: MarkSet = {\n list: () => [...list],\n add: (shape, given = color) => {\n const annotation = mark(shape, given);\n list = [...list, annotation];\n changed({ type: 'add', annotation });\n return annotation;\n },\n remove: (id) => {\n list = list.filter((a) => a.id !== id);\n changed({ type: 'remove', id });\n },\n clear: () => {\n list = [];\n changed({ type: 'clear' });\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n svg: (area) => (list.length === 0 ? undefined : toSvg(list, area, scroll(), measure)),\n };\n const remove = () => {\n window.removeEventListener('scroll', redraw, { capture: true });\n window.removeEventListener('resize', redraw);\n cancelAnimationFrame(frame);\n layer.remove();\n listeners.clear();\n };\n return { marks, remove };\n}\n\n/**\n * Drawing on the page: a surface over it, under the popup, and the toolbar. Where the page stays usable\n * (`usable`), the surface takes the pointer only while a drawing tool is picked.\n */\nfunction onPage(root: ShadowRoot, marks: MarkSet, color: string, usable: boolean) {\n const surface = fixed(LAYER + 1);\n surface.style.pointerEvents = usable ? 'none' : 'auto';\n const preview = fixed(0);\n surface.append(preview);\n root.append(surface);\n const { tools, hint } = drawing({\n surface,\n at: (e) => ({ x: e.clientX + scrollX, y: e.clientY + scrollY }),\n preview: (shape) => {\n preview.innerHTML = shape === undefined ? '' : toSvg([mark(shape, color)], viewport(), scroll());\n },\n add: (shape) => marks.add(shape),\n removeLast: () => {\n const last = marks.list().at(-1);\n if (last !== undefined) marks.remove(last.id);\n },\n clear: () => marks.clear(),\n ...(usable ? { drawing: (on: boolean) => (surface.style.pointerEvents = on ? 'auto' : 'none') } : {}),\n });\n return { tools, hint, surface };\n}\n\n/** The picture with the marks drawn over it, as a PNG at the picture's own resolution. */\nasync function flatten(picture: Picture, marks: readonly Annotation[], measure: Measure): Promise<Blob> {\n const base = await image(picture.url);\n const canvas = document.createElement('canvas');\n canvas.width = base.naturalWidth;\n canvas.height = base.naturalHeight;\n const ctx = canvas.getContext('2d');\n if (ctx === null) throw new Error(\"annotations: this browser won't draw to a canvas\");\n ctx.drawImage(base, 0, 0);\n if (marks.length > 0) {\n // Shapes only, no `foreignObject`, so drawing the SVG leaves the canvas readable.\n const svg = await image(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(over(picture, marks, measure))}`);\n ctx.drawImage(svg, 0, 0, canvas.width, canvas.height);\n }\n return new Promise((done, fail) =>\n canvas.toBlob((blob) => (blob === null ? fail(new Error('annotations: the picture drew nothing')) : done(blob)), 'image/png'),\n );\n}\n\nexport default defineClientPlugin<null, never, Annotations>({\n name: 'annotations',\n label: 'Annotate',\n setup: ({ root, options }) => {\n const color = (options as { color: string }).color;\n const measure = measurer();\n const page = marksOnPage(root, color, measure, `deictic:annotations:${location.pathname}`);\n\n const api: Annotations = {\n ...page.marks,\n edit: (picture, marks = [], { signal } = {}) => edit(root, picture, marks, { color, measure, ...(signal ? { signal } : {}) }),\n flatten: (picture, marks) => flatten(picture, marks, measure),\n tools: () => {\n // Its own marks, kept by nothing: they show while it's open, and go with it.\n const own = marksOnPage(root, color, measure);\n const { tools, surface } = onPage(root, own.marks, color, true);\n const element = document.createElement('div');\n element.append(Object.assign(document.createElement('style'), { textContent: TOOLS_STYLE }), tools);\n return {\n element,\n marks: own.marks,\n close: () => {\n surface.remove();\n own.remove();\n },\n };\n },\n };\n return api;\n },\n\n mount: (panel, { root, use, close, options }) => {\n const { color } = options as { color: string };\n const marks = use('annotations');\n if (marks === undefined) return;\n const style = document.createElement('style');\n style.textContent = TOOLS_STYLE;\n // Over the page while annotate mode is open: it takes the pointer, so drawing never clicks the page.\n const { tools, hint, surface } = onPage(root, marks, color, false);\n const done = button('Done', 'Leave annotate mode (Esc)', close);\n done.classList.add('primary', 'end');\n tools.append(done);\n panel.append(style, tools, hint);\n return () => surface.remove();\n },\n});\n"],"mappings":";AASA,MAAM,MAAM;AAKZ,MAAa,SAAkB,SAAS,KAAK,SAAA,KAAgB;AAE7D,MAAM,UAAU,SAAiB,KAAK,WAAW,KAAK,OAAO,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,WAAW,MAAK,QAAQ;AACvI,MAAM,KAAK,UAAkB,KAAK,MAAM,QAAQ,EAAE,IAAI;;AAGtD,SAAS,MAAM,MAAa,IAAmB;CAC7C,MAAM,QAAQ,KAAK,M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js","names":[],"sources":["../../src/plugins/annotations/svg.ts","../../src/plugins/annotations/draw.ts","../../src/plugins/annotations/client.ts"],"sourcesContent":["/**\n * Annotations as SVG: the layer the page shows them in, and what a screenshot draws over itself. Shapes\n * only, no `foreignObject`, so a canvas that draws the SVG isn't tainted, and a browser rendering it\n * elsewhere needs nothing of the page.\n */\nimport type { Annotation, Area, Point } from './index.ts';\n\nexport const STROKE = 3;\nexport const FONT = 14;\nconst PAD = 6;\n\n/** How wide text is, in CSS pixels: measured where there's a canvas, guessed where there isn't. */\nexport type Measure = (text: string) => number;\n\nexport const guess: Measure = (text) => text.length * FONT * 0.6;\n\nconst escape = (text: string) => text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('\"', '&quot;');\nconst n = (value: number) => Math.round(value * 10) / 10;\n\n/** An arrow's path: its line, then its head, two strokes back from the tip either side of the line. */\nfunction arrow(from: Point, to: Point): string {\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const at = (p: Point) => `${n(p.x)},${n(p.y)}`;\n const side = (turn: number) => at({ x: to.x - 14 * Math.cos(angle + turn), y: to.y - 14 * Math.sin(angle + turn) });\n return `M${at(from)} L${at(to)} M${side(0.45)} L${at(to)} L${side(-0.45)}`;\n}\n\nfunction shapeOf({ shape, color }: Annotation, measure: Measure): string {\n const line = `fill=\"none\" stroke=\"${escape(color)}\" stroke-width=\"${STROKE}\" stroke-linecap=\"round\" stroke-linejoin=\"round\"`;\n switch (shape.kind) {\n case 'box':\n return `<rect x=\"${n(shape.x)}\" y=\"${n(shape.y)}\" width=\"${n(shape.width)}\" height=\"${n(shape.height)}\" rx=\"4\" ${line}/>`;\n case 'arrow':\n return `<path d=\"${arrow(shape.from, shape.to)}\" ${line}/>`;\n case 'pen':\n return `<polyline points=\"${shape.points.map((p) => `${n(p.x)},${n(p.y)}`).join(' ')}\" ${line}/>`;\n case 'note': {\n const lines = shape.text.split('\\n');\n const width = Math.max(...lines.map(measure)) + PAD * 2;\n const height = lines.length * FONT * 1.3 + PAD * 2;\n const text = lines\n .map(\n (l, i) => `<tspan x=\"${n(shape.at.x + PAD)}\" y=\"${n(shape.at.y + PAD + FONT * (i + 1) * 1.3 - FONT * 0.3)}\">${escape(l)}</tspan>`,\n )\n .join('');\n return (\n `<rect x=\"${n(shape.at.x)}\" y=\"${n(shape.at.y)}\" width=\"${n(width)}\" height=\"${n(height)}\" rx=\"4\" fill=\"${escape(color)}\"/>` +\n `<text font-family=\"system-ui, sans-serif\" font-size=\"${FONT}\" fill=\"#fff\">${text}</text>`\n );\n }\n }\n}\n\n/**\n * The annotations over `area` of the viewport, the page scrolled by `scroll`: an SVG `area`'s size,\n * whose view is that part of the page.\n */\nexport function toSvg(annotations: readonly Annotation[], area: Area, scroll: Point, measure: Measure = guess): string {\n const view = `${n(area.x + scroll.x)} ${n(area.y + scroll.y)} ${n(area.width)} ${n(area.height)}`;\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${n(area.width)}\" height=\"${n(area.height)}\" viewBox=\"${view}\">${annotations.map((a) => shapeOf(a, measure)).join('')}</svg>`;\n}\n","/**\n * Drawing on the page with the pointer: the tools, as the tool panel has them, and the gestures.\n *\n * The tools say nothing in words: each is an icon whose tooltip is its name and its key (`aria-keyshortcuts`, which\n * the panel hears and the overlay's tooltip draws as keycaps). While one is picked it has the page (`hold`): the\n * surface takes the pointer, so drawing never clicks the page, until the panel gives the page back.\n */\nimport { MOD, toolButton } from '#src/client/dom.ts';\nimport type { ToolPanel } from '#src/index.ts';\n\nimport type { Point, Shape } from './index.ts';\nimport { FONT, guess, type Measure } from './svg.ts';\n\nconst STYLE = `\n.annotations-tools .gap { width: 1px; align-self: stretch; margin: 2px; background: rgb(255 255 255 / 0.12); }\n.tool-panel.vertical .annotations-tools .gap { width: auto; height: 1px; }\n`;\n\ntype Tool = 'box' | 'arrow' | 'pen' | 'note';\nconst TOOLS: Tool[] = ['box', 'arrow', 'pen', 'note'];\nconst NAMES: Record<Tool, string> = { box: 'Box', arrow: 'Arrow', pen: 'Pen', note: 'Note' };\n/** The key that picks each, alone. */\nconst KEYS: Record<Tool, string> = { box: 'M', arrow: 'A', pen: 'B', note: 'N' };\n\n/** Each icon's strokes, on a 24-pixel grid: drawn here, so the page half needs nothing to show them. */\nconst ICONS = {\n box: '<rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\"/>',\n arrow: '<path d=\"M6 18 18 6M9 6h9v9\"/>',\n pen: '<path d=\"M4 20l1-4L16 5a2.1 2.1 0 0 1 3 3L8 19z\"/>',\n note: '<path d=\"M4 5h16v11H9l-5 4zM8 9h8M8 12h5\"/>',\n undo: '<path d=\"M9 14 4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3\"/>',\n clear: '<path d=\"M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3\"/>',\n} as const;\n\n/** Text's width as the marks draw it, by a canvas's measure, which the guess stands in for without one. */\nexport function measurer(): Measure {\n const ctx = document.createElement('canvas').getContext('2d');\n if (ctx === null) return guess;\n ctx.font = `${FONT}px system-ui, sans-serif`;\n return (text) => ctx.measureText(text).width;\n}\n\nexport interface DrawingOptions {\n /** What takes the pointer to draw on, while a tool is picked. */\n surface: HTMLElement;\n /** Where an event is, in the coordinates the marks are kept in. */\n at: (e: PointerEvent) => Point;\n /** Shows the shape being drawn, or nothing once it's done. */\n preview: (shape: Shape | undefined) => void;\n add: (shape: Shape) => void;\n removeLast: () => void;\n clear: () => void;\n /** The tool panel's `hold`: a picked tool has the page until the panel gives it back. */\n hold: ToolPanel['hold'];\n}\n\nexport interface Drawing {\n /** The tools, as a group for the tool panel: the tools, then removing the last mark or all. */\n group: HTMLElement;\n /** Picks the tool used last, the box first: what a button elsewhere starts drawing with. */\n draw: () => void;\n}\n\n/** Draws on `surface` with the tool picked. */\nexport function drawing({ surface, at, preview, add, removeLast, clear, hold }: DrawingOptions): Drawing {\n const tools = document.createElement('div');\n tools.className = 'tool-group annotations-tools';\n\n // None until one is picked: the page is the page's.\n let tool: Tool | undefined;\n let last: Tool = 'box';\n let release: (() => void) | undefined;\n const picks = TOOLS.map((t) => ({ t, el: toolButton(ICONS[t], NAMES[t], KEYS[t], () => pick(t)) }));\n const show = () => {\n for (const p of picks) p.el.setAttribute('aria-pressed', String(p.t === tool));\n surface.style.pointerEvents = tool === undefined ? 'none' : 'auto';\n };\n const pick = (t: Tool) => {\n tool = t;\n last = t;\n // The page's, once: another of these tools takes over from the one that had it.\n release ??= hold(() => {\n tool = undefined;\n release = undefined;\n show();\n });\n show();\n };\n const gap = document.createElement('span');\n gap.className = 'gap';\n tools.append(\n Object.assign(document.createElement('style'), { textContent: STYLE }),\n ...picks.map((p) => p.el),\n gap,\n toolButton(ICONS.undo, 'Undo', `${MOD}+Z`, removeLast),\n // With Shift: it takes every mark, and nothing brings them back.\n toolButton(ICONS.clear, 'Clear', 'Shift+Backspace', clear),\n );\n show();\n\n surface.style.cursor = 'crosshair';\n const shapeFrom = (from: Point, to: Point, points: Point[]): Shape | undefined => {\n if (tool === 'pen') return points.length > 1 ? { kind: 'pen', points } : undefined;\n if (Math.hypot(to.x - from.x, to.y - from.y) < 4) return undefined;\n if (tool === 'arrow') return { kind: 'arrow', from, to };\n return {\n kind: 'box',\n x: Math.min(from.x, to.x),\n y: Math.min(from.y, to.y),\n width: Math.abs(to.x - from.x),\n height: Math.abs(to.y - from.y),\n };\n };\n\n surface.addEventListener('pointerdown', (e) => {\n if (e.button !== 0 || e.target instanceof HTMLInputElement) return;\n e.preventDefault();\n if (tool === 'note') return note(at(e), e);\n const from = at(e);\n const points = [from];\n surface.setPointerCapture(e.pointerId);\n const move = (m: PointerEvent) => {\n points.push(at(m));\n preview(shapeFrom(from, at(m), points));\n };\n const up = (u: PointerEvent) => {\n surface.removeEventListener('pointermove', move);\n preview(undefined);\n const shape = shapeFrom(from, at(u), points);\n if (shape !== undefined) add(shape);\n };\n surface.addEventListener('pointermove', move);\n surface.addEventListener('pointerup', up, { once: true });\n });\n\n /** A field where the note goes: Enter places what's typed, as does leaving it; Esc, or nothing typed, places nothing. */\n const note = (point: Point, e: PointerEvent) => {\n const field = Object.assign(document.createElement('input'), { placeholder: 'Note', ariaLabel: 'Note' });\n // Esc is the field's while it's there, not the popup's.\n field.dataset['deicticModal'] = '';\n // Its own colours: on the page, outside the popup, it would take the page's text colour on deictic's dark field.\n field.style.cssText = `position:fixed;left:${e.clientX}px;top:${e.clientY}px;width:220px;pointer-events:auto;cursor:text;color:var(--deictic-fg);background:var(--deictic-bg);border-color:var(--deictic-accent)`;\n surface.append(field);\n // Once: taking the field away blurs it, while it's still there to be asked.\n let over = false;\n const end = (placed: boolean) => {\n if (over) return;\n over = true;\n const text = field.value.trim();\n field.remove();\n if (placed && text !== '') add({ kind: 'note', at: point, text });\n };\n field.addEventListener('keydown', (k) => {\n if (k.key === 'Enter') end(true);\n if (k.key !== 'Escape') return;\n k.stopPropagation();\n end(false);\n });\n field.addEventListener('blur', () => end(true));\n // Now, not a frame later: the pointerdown's default is prevented, so no mousedown takes focus back.\n field.focus();\n };\n\n return { group: tools, draw: () => pick(last) };\n}\n","/**\n * Annotations in the page. `setup` keeps them (in the tab's session storage, per page) and shows them in a\n * layer of deictic's overlay that lets the pointer through; it adds the tools that draw them to the tool panel,\n * and answers the API other plugins `use`.\n *\n * The layer is deictic's, so a screenshot leaves it out with the rest of the overlay and draws the marks\n * itself from `svg(area)`: one way to draw them, wherever a shot is rendered. `edit` draws on a picture\n * instead, a shot most often, with the same tools in a bar over everything, and `flatten` makes the PNG of it.\n */\nimport { controlFor, MOD } from '#src/client/dom.ts';\nimport { defineClientPlugin } from '#src/index.ts';\n\nimport { drawing, measurer } from './draw.ts';\nimport type { Annotation, AnnotationEvent, Annotations, Area, Picture, Point, Shape } from './index.ts';\nimport { type Measure, toSvg } from './svg.ts';\n\n/** Under deictic's light and its popup, over the page. */\nconst LAYER = 2147483645;\n/** Over everything of deictic's, the popup too. */\nconst TOP = 2147483647;\n\nconst scroll = (): Point => ({ x: scrollX, y: scrollY });\nconst viewport = (): Area => ({ x: 0, y: 0, width: document.documentElement.clientWidth, height: document.documentElement.clientHeight });\nconst mark = (shape: Shape, color: string): Annotation => ({ id: crypto.randomUUID(), color, shape, at: Date.now() });\n\n/** What's kept for this page in the tab's session, read as it can be. */\nfunction stored(key: string): Annotation[] {\n try {\n const kept: unknown = JSON.parse(sessionStorage.getItem(key) ?? '[]');\n return Array.isArray(kept) ? (kept as Annotation[]) : [];\n } catch {\n // Storage can be off, or hold something else: no marks is the page as it was.\n return [];\n }\n}\n\nfunction fixed(z: number): HTMLDivElement {\n const el = document.createElement('div');\n el.style.cssText = `position:fixed;inset:0;z-index:${z};pointer-events:none`;\n return el;\n}\n\nconst EDITOR_STYLE = `\n.annotations-editor:focus { outline: none; }\n.annotations-editor { position: fixed; inset: 0; z-index: ${TOP}; box-sizing: border-box; padding: 16px; display: flex;\n flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgb(0 0 0 / 0.75);\n font: 13px/1.4 system-ui, sans-serif; color: var(--deictic-fg); }\n/* The tools as the tool panel has them, then Cancel and Save at its end. */\n.annotations-editor .edit-bar { display: flex; align-items: center; gap: 6px; box-sizing: border-box; width: min(100%, 720px);\n padding: 6px 8px; border: 1px solid var(--deictic-line); border-radius: 12px; background: var(--deictic-bg); }\n.annotations-editor .tool-group { display: flex; align-items: center; gap: 4px; margin-right: auto; }\n.annotations-editor button.icon { width: 28px; height: 26px; border-radius: 6px; color: var(--deictic-fg); }\n.annotations-editor button.icon svg { width: 16px; height: 16px; }\n.annotations-editor button[aria-pressed='true'], .annotations-editor button[aria-pressed='true']:hover {\n color: var(--deictic-on-accent); background: var(--deictic-accent); }\n.annotations-editor .edit-bar > button { padding: 3px 12px; border-radius: 6px; }\n.annotations-editor .stage { position: relative; line-height: 0; box-shadow: 0 12px 32px rgb(0 0 0 / 0.5); touch-action: none; }\n.annotations-editor img { display: block; max-width: calc(100vw - 32px); max-height: calc(100vh - 120px); user-select: none; }\n.annotations-editor .marks { position: absolute; inset: 0; pointer-events: none; }\n`;\n\n/** Loads an image, decoded. */\nasync function image(src: string): Promise<HTMLImageElement> {\n const el = new Image();\n el.src = src;\n await el.decode();\n return el;\n}\n\n/** The marks over a whole picture, as an SVG whose view is the picture's CSS pixels. */\nconst over = (picture: Picture, marks: readonly Annotation[], measure?: Measure) =>\n toSvg(marks, { x: 0, y: 0, width: picture.width, height: picture.height }, { x: 0, y: 0 }, measure);\n\n/**\n * The picture over everything, to draw on: the marks on Save, nothing on Cancel, Esc or `signal`. It's a modal\n * (`data-deictic-modal`) while it's open, so Esc leaves it, not the popup under it, and the tool panel leaves the\n * keys to it: its own bar hears them, as the panel hears its own.\n */\nfunction edit(\n root: ShadowRoot,\n picture: Picture,\n start: readonly Annotation[],\n { color, measure, signal }: { color: string; measure: Measure; signal?: AbortSignal },\n): Promise<Annotation[] | undefined> {\n return new Promise((resolve) => {\n let marks = [...start];\n const backdrop = document.createElement('div');\n backdrop.className = 'annotations-editor';\n backdrop.dataset['deicticModal'] = '';\n const bar = document.createElement('div');\n bar.className = 'edit-bar';\n bar.setAttribute('role', 'toolbar');\n const stage = document.createElement('div');\n stage.className = 'stage';\n const img = Object.assign(document.createElement('img'), { src: picture.url, alt: 'The screenshot', draggable: false });\n const layer = document.createElement('div');\n layer.className = 'marks';\n stage.append(img, layer);\n\n const show = (preview?: Shape) => {\n layer.innerHTML = over(picture, preview === undefined ? marks : [...marks, mark(preview, color)], measure);\n // Drawn at the size the picture shows at, whatever that is: the view is the picture's own pixels.\n const svg = layer.firstElementChild;\n svg?.setAttribute('width', '100%');\n svg?.setAttribute('height', '100%');\n };\n const { group, draw } = drawing({\n surface: stage,\n at: (e) => {\n const r = stage.getBoundingClientRect();\n return { x: ((e.clientX - r.left) * picture.width) / r.width, y: ((e.clientY - r.top) * picture.height) / r.height };\n },\n preview: (shape) => show(shape),\n add: (shape) => {\n marks = [...marks, mark(shape, color)];\n show();\n },\n removeLast: () => {\n marks = marks.slice(0, -1);\n show();\n },\n clear: () => {\n marks = [];\n show();\n },\n // The picture is the tools' for as long as it's open: nothing takes it from them.\n hold: () => () => {},\n });\n draw();\n // The focus is the editor's while it's open: a field under it (the task's words) would take what's typed.\n const focused = root.activeElement;\n backdrop.tabIndex = -1;\n const end = (result: Annotation[] | undefined) => {\n backdrop.remove();\n if (focused instanceof HTMLElement) focused.focus();\n window.removeEventListener('keydown', onKey, true);\n signal?.removeEventListener('abort', cancel);\n resolve(result);\n };\n const cancel = () => end(undefined);\n const onKey = (e: KeyboardEvent) => {\n // A note being typed has its keys to itself.\n if (e.repeat || e.composedPath()[0] instanceof HTMLInputElement) return;\n const control = controlFor(bar, e);\n if (control === undefined) return;\n e.preventDefault();\n e.stopImmediatePropagation();\n control.click();\n };\n const back = Object.assign(document.createElement('button'), { type: 'button', textContent: 'Cancel' });\n back.setAttribute('aria-keyshortcuts', 'Escape');\n back.addEventListener('click', cancel);\n const save = Object.assign(document.createElement('button'), { type: 'button', className: 'primary', textContent: 'Save' });\n save.setAttribute('aria-keyshortcuts', `${MOD}+Enter`);\n save.addEventListener('click', () => end(marks));\n bar.append(group, back, save);\n backdrop.append(Object.assign(document.createElement('style'), { textContent: EDITOR_STYLE }), bar, stage);\n root.append(backdrop);\n backdrop.focus();\n window.addEventListener('keydown', onKey, true);\n signal?.addEventListener('abort', cancel);\n show();\n });\n}\n\n/** The picture with the marks drawn over it, as a PNG at the picture's own resolution. */\nasync function flatten(picture: Picture, marks: readonly Annotation[], measure: Measure): Promise<Blob> {\n const base = await image(picture.url);\n const canvas = document.createElement('canvas');\n canvas.width = base.naturalWidth;\n canvas.height = base.naturalHeight;\n const ctx = canvas.getContext('2d');\n if (ctx === null) throw new Error(\"annotations: this browser won't draw to a canvas\");\n ctx.drawImage(base, 0, 0);\n if (marks.length > 0) {\n // Shapes only, no `foreignObject`, so drawing the SVG leaves the canvas readable.\n const svg = await image(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(over(picture, marks, measure))}`);\n ctx.drawImage(svg, 0, 0, canvas.width, canvas.height);\n }\n return new Promise((done, fail) =>\n canvas.toBlob((blob) => (blob === null ? fail(new Error('annotations: the picture drew nothing')) : done(blob)), 'image/png'),\n );\n}\n\n/**\n * The page's marks, shown in a layer of the overlay that lets the pointer through, redrawn as it scrolls, and kept\n * in the tab's session storage under `key`.\n */\nfunction marksOnPage(root: ShadowRoot, color: string, measure: Measure, key: string): Omit<Annotations, 'draw' | 'edit' | 'flatten'> {\n let list = stored(key);\n const listeners = new Set<(event: AnnotationEvent) => void>();\n const layer = fixed(LAYER);\n root.append(layer);\n\n let frame = 0;\n const draw = () => {\n frame = 0;\n layer.innerHTML = list.length === 0 ? '' : toSvg(list, viewport(), scroll(), measure);\n };\n const redraw = () => {\n if (frame === 0) frame = requestAnimationFrame(draw);\n };\n window.addEventListener('scroll', redraw, { capture: true, passive: true });\n window.addEventListener('resize', redraw, { passive: true });\n const changed = (event: AnnotationEvent) => {\n try {\n sessionStorage.setItem(key, JSON.stringify(list));\n } catch {\n // Not kept past a reload, then; the page still shows them.\n }\n draw();\n for (const listener of listeners) listener(event);\n };\n draw();\n\n return {\n list: () => [...list],\n add: (shape, given = color) => {\n const annotation = mark(shape, given);\n list = [...list, annotation];\n changed({ type: 'add', annotation });\n return annotation;\n },\n remove: (id) => {\n list = list.filter((a) => a.id !== id);\n changed({ type: 'remove', id });\n },\n clear: () => {\n if (list.length === 0) return;\n list = [];\n changed({ type: 'clear' });\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n svg: (area) => (list.length === 0 ? undefined : toSvg(list, area, scroll(), measure)),\n };\n}\n\nexport default defineClientPlugin<never, never, Annotations>({\n name: 'annotations',\n setup: ({ root, options, tools }) => {\n const color = (options as { color: string }).color;\n const measure = measurer();\n const marks = marksOnPage(root, color, measure, `deictic:annotations:${location.pathname}`);\n\n // Over the page, under the popup: it takes the pointer only while a tool is picked.\n const surface = fixed(LAYER + 1);\n const preview = fixed(0);\n surface.append(preview);\n root.append(surface);\n const { group, draw } = drawing({\n surface,\n at: (e) => ({ x: e.clientX + scrollX, y: e.clientY + scrollY }),\n preview: (shape) => {\n preview.innerHTML = shape === undefined ? '' : toSvg([mark(shape, color)], viewport(), scroll());\n },\n add: (shape) => marks.add(shape),\n removeLast: () => {\n const last = marks.list().at(-1);\n if (last !== undefined) marks.remove(last.id);\n },\n clear: () => marks.clear(),\n hold: tools.hold,\n });\n tools.add(group);\n return {\n ...marks,\n draw,\n edit: (picture, start = [], { signal } = {}) => edit(root, picture, start, { color, measure, ...(signal ? { signal } : {}) }),\n flatten: (picture, drawn) => flatten(picture, drawn, measure),\n };\n },\n});\n"],"mappings":";;AASA,MAAM,MAAM;AAKZ,MAAa,SAAkB,SAAS,KAAK,SAAA,KAAgB;AAE7D,MAAM,UAAU,SAAiB,KAAK,WAAW,KAAK,OAAO,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,WAAW,MAAK,QAAQ;AACvI,MAAM,KAAK,UAAkB,KAAK,MAAM,QAAQ,EAAE,IAAI;;AAGtD,SAAS,MAAM,MAAa,IAAmB;CAC7C,MAAM,QAAQ,KAAK,MAAM,GAAG,IAAI,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC;CACrD,MAAM,MAAM,MAAa,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC;CAC3C,MAAM,QAAQ,SAAiB,GAAG;EAAE,GAAG,GAAG,IAAI,KAAK,KAAK,IAAI,QAAQ,IAAI;EAAG,GAAG,GAAG,IAAI,KAAK,KAAK,IAAI,QAAQ,IAAI;CAAE,CAAC;CAClH,OAAO,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,KAAK,GAAI,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,KAAK,IAAK;AACzE;AAEA,SAAS,QAAQ,EAAE,OAAO,SAAqB,SAA0B;CACvE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@ -1,11 +1,2 @@
1
- /**
2
- * `deictic/annotations`: mark up the page itself. Its tab is annotate
3
- * mode over the page: boxes, arrows, a pen and notes, drawn where the page is, so they stay with
4
- * it as it scrolls. They're kept for the tab's session, per page, until cleared.
5
- *
6
- * They're data other plugins build on, through `use('annotations')` in the page: screenshots draw them
7
- * over the page (`svg(area)`), tasks repeat their notes, and a recording can keep each change as it
8
- * happens (`subscribe`). Nothing of it runs on the server.
9
- */
10
- import { a as Area, c as Point, i as AnnotationsOptions, l as Shape, n as AnnotationEvent, o as MarkSet, r as Annotations, s as Picture, t as Annotation, u as annotations } from "../shared/index2.js";
11
- export { Annotation, AnnotationEvent, Annotations, AnnotationsOptions, Area, MarkSet, Picture, Point, Shape, annotations, annotations as default };
1
+ import { a as Area, c as Shape, i as AnnotationsOptions, l as annotations, n as AnnotationEvent, o as Picture, r as Annotations, s as Point, t as Annotation } from "../shared/index2.js";
2
+ export { Annotation, AnnotationEvent, Annotations, AnnotationsOptions, Area, Picture, Point, Shape, annotations, annotations as default };
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * `deictic/client`: the overlay the page loads in dev. Hold a shortcut's keys (Alt, deictic's own,
3
- * by default) and point: the element under the pointer that the source marked (`tools/locate.ts`) is
4
- * outlined, with its tag, its place and how many elements share it. Press the shortcut's button to open
5
- * the popup there: a tab for each plugin with a panel, at the one used last, or at a plugin's own where
6
- * its shortcut was pressed.
3
+ * by default) and point: the page dims around the element under the pointer that the source marked
4
+ * (`tools/locate.ts`), which stays lit, with its tag, its place and how many elements share it (`lighting.ts`).
5
+ * Press the shortcut's button to open the popup beside it: a tab for each plugin with a panel, at the one used
6
+ * last, or at a plugin's own where its shortcut was pressed.
7
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 { i as ClientPlugin, s as LightboxItem, v as Standalone, w as Shortcut, y as Target } from "../shared/index.js";
11
+ import { A as Shortcut, S as Target, c as LightboxItem, i as ClientPlugin, x as Standalone } 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
@@ -35,6 +35,8 @@ export declare function drawBars(canvas: HTMLCanvasElement, peaks: readonly numb
35
35
  * It listens to `stream` on its own; the recording goes on as it was.
36
36
  */
37
37
  export declare function liveWaveform(canvas: HTMLCanvasElement, stream: MediaStream, colors: Colors): () => void;
38
+ /** An element's place in the source, as its mark has it, or nothing for one with none. */
39
+ export declare function targetOf(el: Element): Target | undefined;
38
40
  export interface StartOptions {
39
41
  /** The dev server's base URL, ending in `/`. */
40
42
  base: string;
@@ -49,7 +51,6 @@ export interface StartOptions {
49
51
  /** What answers the requests where there's no dev server to: a `standalone` build's. */
50
52
  server?: Standalone;
51
53
  }
52
- export declare function targetOf(el: Element): Target | undefined;
53
54
  /**
54
55
  * What the page hears on `window` as the popup opens over it on an element (its `detail` a `PopupOpened`) and as
55
56
  * it closes: for a page that moves on its own to hold still meanwhile, as deictic's site does. Not for one pinned.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/client/waveform.ts","../../src/client/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;wBAUsB,QAAQ,aAAa,eAAe;EAAU;EAAiB;;UAsBpE;;EAEf;;EAEA;;;wBAIc,SAAS,QAAQ,mBAAmB,0BAA0B,kBAAkB,QAAQ;;;;;wBAoBxF,aAAa,QAAQ,mBAAmB,QAAQ,aAAa,QAAQ;iBCvCpE;;EAEf;;EAEA,WAAW,SAAS;;EAEpB;IAAW,QAAQ;IAAc,WAAW,SAAS;IAAW;;;EAEhE,SAAS;;wBA2BK,SAAS,IAAI,UAAU;;;;;qBA2C1B;qBACA;iBAEI;;EAEf,SAAS;;EAET;;;;;;;wBAQc,UAAU,SAAS,WAAW;EAAS;;;;;;;;;wBAYvC,QAAQ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