deictic 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +144 -0
  3. package/dist/annotations/client.d.ts +4 -0
  4. package/dist/annotations/client.d.ts.map +1 -0
  5. package/dist/annotations/client.js +497 -0
  6. package/dist/annotations/client.js.map +1 -0
  7. package/dist/annotations/index.d.ts +110 -0
  8. package/dist/annotations/index.d.ts.map +1 -0
  9. package/dist/annotations/index.js +22 -0
  10. package/dist/annotations/index.js.map +1 -0
  11. package/dist/astro.d.ts +29 -0
  12. package/dist/astro.d.ts.map +1 -0
  13. package/dist/astro.js +24 -0
  14. package/dist/astro.js.map +1 -0
  15. package/dist/bun.d.ts +12 -0
  16. package/dist/bun.d.ts.map +1 -0
  17. package/dist/bun.js +67 -0
  18. package/dist/bun.js.map +1 -0
  19. package/dist/client/index.d.ts +93 -0
  20. package/dist/client/index.d.ts.map +1 -0
  21. package/dist/client/index.js +1329 -0
  22. package/dist/client/index.js.map +1 -0
  23. package/dist/endpoints.js +354 -0
  24. package/dist/endpoints.js.map +1 -0
  25. package/dist/index.d.ts +220 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +10 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/index2.d.ts +23 -0
  30. package/dist/index3.d.ts +98 -0
  31. package/dist/index3.d.ts.map +1 -0
  32. package/dist/index4.d.ts +74 -0
  33. package/dist/index4.d.ts.map +1 -0
  34. package/dist/index5.d.ts +70 -0
  35. package/dist/index5.d.ts.map +1 -0
  36. package/dist/integration.d.ts +19 -0
  37. package/dist/integration.d.ts.map +1 -0
  38. package/dist/integration.js +277 -0
  39. package/dist/integration.js.map +1 -0
  40. package/dist/kept.js +23 -0
  41. package/dist/kept.js.map +1 -0
  42. package/dist/loader.d.ts +15 -0
  43. package/dist/loader.d.ts.map +1 -0
  44. package/dist/loader.js +17 -0
  45. package/dist/loader.js.map +1 -0
  46. package/dist/marks.js +14 -0
  47. package/dist/marks.js.map +1 -0
  48. package/dist/next.d.ts +17 -0
  49. package/dist/next.d.ts.map +1 -0
  50. package/dist/next.js +150 -0
  51. package/dist/next.js.map +1 -0
  52. package/dist/playwright.js +105 -0
  53. package/dist/playwright.js.map +1 -0
  54. package/dist/recommended/index.d.ts +25 -0
  55. package/dist/recommended/index.d.ts.map +1 -0
  56. package/dist/recommended/index.js +19 -0
  57. package/dist/recommended/index.js.map +1 -0
  58. package/dist/recordings/client.d.ts +4 -0
  59. package/dist/recordings/client.d.ts.map +1 -0
  60. package/dist/recordings/client.js +376 -0
  61. package/dist/recordings/client.js.map +1 -0
  62. package/dist/recordings/index.d.ts +2 -0
  63. package/dist/recordings/index.js +3 -0
  64. package/dist/recordings.js +235 -0
  65. package/dist/recordings.js.map +1 -0
  66. package/dist/screenshots/client.d.ts +23 -0
  67. package/dist/screenshots/client.d.ts.map +1 -0
  68. package/dist/screenshots/client.js +76 -0
  69. package/dist/screenshots/client.js.map +1 -0
  70. package/dist/screenshots/dom.d.ts +4 -0
  71. package/dist/screenshots/dom.d.ts.map +1 -0
  72. package/dist/screenshots/dom.js +92 -0
  73. package/dist/screenshots/dom.js.map +1 -0
  74. package/dist/screenshots/index.d.ts +2 -0
  75. package/dist/screenshots/index.js +98 -0
  76. package/dist/screenshots/index.js.map +1 -0
  77. package/dist/screenshots/rrweb.d.ts +9 -0
  78. package/dist/screenshots/rrweb.d.ts.map +1 -0
  79. package/dist/screenshots/rrweb.js +60 -0
  80. package/dist/screenshots/rrweb.js.map +1 -0
  81. package/dist/shortcut.js +63 -0
  82. package/dist/shortcut.js.map +1 -0
  83. package/dist/tailwind/client.d.ts +4 -0
  84. package/dist/tailwind/client.d.ts.map +1 -0
  85. package/dist/tailwind/client.js +613 -0
  86. package/dist/tailwind/client.js.map +1 -0
  87. package/dist/tailwind/index.d.ts +2 -0
  88. package/dist/tailwind/index.js +557 -0
  89. package/dist/tailwind/index.js.map +1 -0
  90. package/dist/tasks/client.d.ts +6 -0
  91. package/dist/tasks/client.d.ts.map +1 -0
  92. package/dist/tasks/client.js +642 -0
  93. package/dist/tasks/client.js.map +1 -0
  94. package/dist/tasks/index.d.ts +159 -0
  95. package/dist/tasks/index.d.ts.map +1 -0
  96. package/dist/tasks/index.js +348 -0
  97. package/dist/tasks/index.js.map +1 -0
  98. package/dist/vite.d.ts +17 -0
  99. package/dist/vite.d.ts.map +1 -0
  100. package/dist/vite.js +44 -0
  101. package/dist/vite.js.map +1 -0
  102. package/dist/voice/client.d.ts +4 -0
  103. package/dist/voice/client.d.ts.map +1 -0
  104. package/dist/voice/client.js +66 -0
  105. package/dist/voice/client.js.map +1 -0
  106. package/dist/voice/index.d.ts +47 -0
  107. package/dist/voice/index.d.ts.map +1 -0
  108. package/dist/voice/index.js +74 -0
  109. package/dist/voice/index.js.map +1 -0
  110. package/dist/waveform.js +93 -0
  111. package/dist/waveform.js.map +1 -0
  112. package/dist/webpack.d.ts +50 -0
  113. package/dist/webpack.d.ts.map +1 -0
  114. package/dist/webpack.js +78 -0
  115. package/dist/webpack.js.map +1 -0
  116. package/package.json +307 -7
  117. package/skills/deictic/SKILL.md +47 -0
  118. package/skills/deictic/references/install.md +81 -0
  119. package/skills/deictic/references/recordings.md +83 -0
  120. package/skills/deictic/references/tasks.md +79 -0
  121. package/skills/deictic/references/watch.md +43 -0
  122. package/skills/deictic/scripts/frame.mjs +62 -0
  123. package/skills/deictic/scripts/lib.mjs +193 -0
  124. package/skills/deictic/scripts/recording.mjs +186 -0
  125. package/skills/deictic/scripts/task.mjs +84 -0
  126. package/skills/deictic/scripts/transcribe.mjs +93 -0
  127. package/skills/deictic/scripts/voice.mjs +50 -0
  128. package/skills/deictic/scripts/watch.mjs +51 -0
  129. package/src/astro.ts +34 -0
  130. package/src/bun.ts +79 -0
  131. package/src/client/index.ts +833 -0
  132. package/src/client/lightbox.ts +256 -0
  133. package/src/client/style.ts +243 -0
  134. package/src/client/tooltip.ts +78 -0
  135. package/src/client/waveform.ts +98 -0
  136. package/src/index.ts +240 -0
  137. package/src/loader.ts +28 -0
  138. package/src/next.ts +133 -0
  139. package/src/plugins/annotations/client.ts +301 -0
  140. package/src/plugins/annotations/draw.ts +169 -0
  141. package/src/plugins/annotations/index.ts +105 -0
  142. package/src/plugins/annotations/svg.ts +61 -0
  143. package/src/plugins/recommended/index.ts +35 -0
  144. package/src/plugins/recordings/client.ts +315 -0
  145. package/src/plugins/recordings/index.ts +174 -0
  146. package/src/plugins/recordings/marks.ts +11 -0
  147. package/src/plugins/recordings/ours.ts +70 -0
  148. package/src/plugins/recordings/replay.ts +139 -0
  149. package/src/plugins/screenshots/client.ts +63 -0
  150. package/src/plugins/screenshots/dom.ts +79 -0
  151. package/src/plugins/screenshots/index.ts +194 -0
  152. package/src/plugins/screenshots/playwright.ts +119 -0
  153. package/src/plugins/screenshots/rrweb.ts +45 -0
  154. package/src/plugins/tailwind/catalog.ts +396 -0
  155. package/src/plugins/tailwind/client.ts +669 -0
  156. package/src/plugins/tailwind/index.ts +267 -0
  157. package/src/plugins/tasks/client.ts +622 -0
  158. package/src/plugins/tasks/index.ts +513 -0
  159. package/src/plugins/voice/client.ts +57 -0
  160. package/src/plugins/voice/index.ts +114 -0
  161. package/src/shortcut.ts +83 -0
  162. package/src/tools/astro.ts +81 -0
  163. package/src/tools/editor.ts +22 -0
  164. package/src/tools/endpoints.ts +163 -0
  165. package/src/tools/history.ts +203 -0
  166. package/src/tools/integration.ts +106 -0
  167. package/src/tools/kept.ts +21 -0
  168. package/src/tools/locate.ts +94 -0
  169. package/src/tools/plugins.ts +41 -0
  170. package/src/tools/source.ts +72 -0
  171. package/src/vite.ts +62 -0
  172. package/src/webpack.ts +107 -0
  173. package/index.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/plugins/tasks/client.ts"],"sourcesContent":["/**\n * The tasks panel: the tasks already about this element and their state, and a field to add one. Each\n * task's ID opens it on the board, where the board has a page; one no one has claimed yet can be edited\n * in place (its words) or deleted (canceled on the board), both changes the popup's undo takes back.\n * Ctrl+Enter or Add sends it with the page's URL, the viewport and the element as it rendered, which\n * the source can't tell; and where the annotations plugin is loaded, what's marked on the page.\n *\n * Where the screenshots plugin is loaded, a shot of the page goes with it, unless that's unticked. With\n * the annotations plugin too, Annotate takes the shot now and opens it to draw on: saved, it's a chip\n * under the field, which opens it again to change the marks, and Add another takes one more. Any chip\n * (a recording's too) takes the box's place; removing the last brings it back unticked, so a task goes\n * without a shot unless asked again.\n *\n * Where the recordings plugin is loaded, Record leaves the popup (`away`) to record the page, keeping\n * what's typed and attached, and comes back with the recording as a chip too, which plays it back.\n * Where the voice plugin is, Voice records the mic here in the panel: stopped, it's a chip that plays it.\n */\nimport { liveWaveform } from '#src/client/waveform.ts';\nimport { defineClientPlugin, type LightboxItem, type Target } from '#src/index.ts';\n\n// For `use()`'s types: the plugins may not be loaded, and nothing of them runs here.\nimport type { Annotation, Annotations, Picture } from '#src/plugins/annotations/index.ts';\nimport type { Recording } from '#src/plugins/recordings/index.ts';\nimport type { Shot } from '#src/plugins/screenshots/index.ts';\nimport type { Clip, Take } from '#src/plugins/voice/index.ts';\n\nimport type { Change, Marks, Model, Op, Task, TaskAdded } from './index.ts';\n\nconst STYLE = `\n.tasks { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }\n.tasks li { display: flex; gap: 6px; align-items: baseline; }\n.tasks .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.tasks .state { font: 11px ui-monospace, monospace; color: var(--deictic-muted); }\n.tasks .state.completed { color: #4ade80; }\n.tasks .state.failed { color: var(--deictic-problem); }\n.tasks a { color: inherit; text-decoration: none; }\n.tasks a:hover { text-decoration: underline; }\n.tasks .act { align-self: center; display: inline-flex; padding: 2px; border: 0; color: var(--deictic-muted); }\n.tasks .act:hover { color: var(--deictic-fg); }\n.tasks .act svg { width: 12px; height: 12px; }\n.tasks li.editing { display: grid; }\n.tasks li.editing .row { margin-top: 0; }\n.tasks li.editing .actions { display: flex; gap: 6px; }\ntextarea { min-height: 64px; resize: vertical; font: 13px/1.4 system-ui, sans-serif; }\n.row { display: flex; gap: 6px; margin-top: 8px; justify-content: space-between; align-items: center; }\n.hint { color: var(--deictic-muted); font-size: 12px; }\n.hint a { color: inherit; }\n.hint a:hover { color: var(--deictic-fg); }\n.shot { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--deictic-muted); }\n.shot label { display: flex; gap: 6px; align-items: center; }\n.shot input { width: auto; margin: 0; }\n.shot .actions { display: flex; gap: 6px; margin-left: auto; }\n.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; font-size: 12px; }\n.chip { display: inline-flex; align-items: center; border: 1px solid var(--deictic-line); border-radius: 6px; }\n.chip button { border: 0; }\n.chip .open { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 2px; }\n.chip img { display: block; height: 28px; border-radius: 4px; }\n.chip .play { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 4px; background: var(--deictic-line); }\n.chip .play svg { width: 12px; height: 12px; }\n.chip .remove { padding: 0 6px; color: var(--deictic-muted); }\n.chip .remove:hover { color: var(--deictic-fg); }\n.voice-on { display: inline-flex; align-items: center; gap: 4px; color: #fff; background: #ef4444; border-color: #ef4444; font-variant-numeric: tabular-nums; }\n.voice-on .wave { width: 36px; height: 14px; }\n.shot-problem { margin-top: 4px; font-size: 12px; color: var(--deictic-problem); }\n.shot-problem:empty { display: none; }\n.shot[hidden], .chips[hidden], label[hidden] { display: none; }\n`;\n\nconst ICON = (path: string) =>\n `<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"${path}\"/></svg>`;\nconst EDIT = ICON('M4 20h4L19 9l-4-4L4 16z');\nconst DELETE = ICON('M4 7h16M10 7V4h4v3M6 7l1 13h10l1-13');\nconst PLAY = '<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M7 4v16l13-8z\" fill=\"currentColor\"/></svg>';\n\n/** Marks as a task tells of them: how many, and what the notes say. */\nfunction marksOf(list: readonly Annotation[]): Marks {\n return { count: list.length, notes: list.flatMap(({ shape }) => (shape.kind === 'note' ? [shape.text] : [])) };\n}\n\n/** The page's annotations for the op, where there are any. */\nfunction annotationsOf(marks: Annotations | undefined): Pick<Op, 'annotations'> {\n const list = marks?.list() ?? [];\n return list.length === 0 ? {} : { annotations: marksOf(list) };\n}\n\n/** An annotated shot: the shot as taken, the marks drawn on it, and the PNG of both. */\ninterface Drawn {\n shot: Shot;\n marks: Annotation[];\n png: Blob;\n}\n\n/** A drawn shot as the panel shows it, with a URL for its thumbnail, revoked with it. */\ninterface Chip extends Drawn {\n url: string;\n}\n\n/** What the panel keeps while it's away recording: what's typed, ticked and attached. */\ninterface Kept {\n text: string;\n attach: boolean;\n drawn: Drawn[];\n recordings: Recording[];\n voices: Clip[];\n}\n\nconst clock = (ms: number) => {\n const s = Math.round(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;\n};\n\nconst messageOf = (e: unknown) => (e instanceof Error ? e.message : String(e));\n\n/**\n * `#shadow-root > div.panel > div.head > button.tab:nth-of-type(2)`: where `inner` is inside `outer`, through\n * shadow roots, by tag, classes and, among siblings alike, place, for whoever finds it in the code.\n */\nfunction pathTo(inner: Element, outer: Element): string {\n const steps: string[] = [];\n for (let at: Element | undefined = inner; at !== undefined && at !== outer;) {\n const nameOf = (el: Element) => `${el.localName}${[...el.classList].map((c) => `.${c}`).join('')}`;\n const name = nameOf(at);\n const siblings = at.parentElement === null ? [] : [...at.parentElement.children];\n // Its place only where a sibling reads the same.\n const same = siblings.filter((c) => nameOf(c) === name).length > 1;\n const alike = siblings.filter((c) => c.localName === at!.localName);\n steps.unshift(same ? `${name}:nth-of-type(${alike.indexOf(at) + 1})` : name);\n if (at.parentElement !== null) {\n at = at.parentElement;\n } else {\n const root = at.getRootNode();\n if (!(root instanceof ShadowRoot)) break;\n steps.unshift('#shadow-root');\n at = root.host;\n }\n }\n return steps.join(' > ');\n}\n\nfunction element<K extends keyof HTMLElementTagNameMap>(tag: K, props: Partial<HTMLElementTagNameMap[K]> = {}): HTMLElementTagNameMap[K] {\n return Object.assign(document.createElement(tag), props);\n}\n\n/** The event the page hears of each added task by, on `window`: its `detail` is a `TaskAdded`. */\nexport const TASK_ADDED = 'deictic:task';\n\n/** Tells the page of a task just added: the newest of the element's tasks, as the board answered them. */\nfunction announce(model: Model, op: Op, target: Target): void {\n const task = model.tasks.at(-1);\n if (task === undefined) return;\n const marks = (op.annotations?.count ?? 0) + (op.screenshots ?? []).reduce((n, shot) => n + (shot.marks?.count ?? 0), 0);\n const detail: TaskAdded = {\n id: task.id,\n title: task.title,\n state: task.state,\n channel: model.channel,\n target,\n page: op.page,\n attached: {\n screenshots: op.screenshots?.length ?? 0,\n recordings: op.recordings?.length ?? 0,\n voice: op.voice?.length ?? 0,\n marks,\n },\n };\n window.dispatchEvent(new CustomEvent(TASK_ADDED, { detail }));\n}\n\nexport default defineClientPlugin<Model, Change>({\n name: 'tasks',\n label: 'Task',\n mount: (panel, context) => {\n const style = element('style', { textContent: STYLE });\n const list = element('ul', { className: 'tasks' });\n const text = element('textarea', { placeholder: 'What should change here?' });\n const add = element('button', { type: 'button', className: 'primary', textContent: 'Add task' });\n const hint = element('span', { className: 'hint' });\n const row = element('div', { className: 'row' });\n row.append(hint, add);\n panel.append(style, list, text);\n\n const shots = context.use('screenshots');\n const notes = context.use('annotations');\n const recorder = context.use('recordings');\n const voice = context.use('voice');\n // Closes an open editor with the panel.\n const aborts = new AbortController();\n\n const attach = element('input', { type: 'checkbox', checked: true });\n const toggle = element('label', { hidden: shots === undefined });\n toggle.append(attach, 'Attach a screenshot');\n const annotate = element('button', { type: 'button', textContent: 'Annotate', title: 'Take the screenshot now and draw on it' });\n const record = element('button', {\n type: 'button',\n textContent: 'Record',\n title: 'Record the page, with a toolbar to draw on it, then come back here',\n });\n const speak = element('button', { type: 'button', textContent: 'Voice', title: 'Record your voice, here' });\n const actions = element('span', { className: 'actions' });\n actions.append(...(shots !== undefined && notes !== undefined ? [annotate] : []));\n const shot = element('div', { className: 'shot' });\n shot.append(toggle, actions);\n const chipsEl = element('div', { className: 'chips' });\n const another = element('button', { type: 'button', textContent: 'Add another', title: 'Take another screenshot and draw on it' });\n const problem = element('div', { className: 'shot-problem' });\n if (shots !== undefined || recorder !== undefined || voice !== undefined) panel.append(shot, chipsEl, problem);\n panel.append(row);\n\n let chips: Chip[] = [];\n let recordings: Recording[] = [];\n let voices: Clip[] = [];\n let busy = false;\n const attachedCount = () => chips.length + recordings.length + voices.length;\n // A task goes with words, or with something attached that says it; not while one is going.\n let sending = false;\n const able = () => (add.disabled = sending || (text.value.trim() === '' && attachedCount() === 0));\n // Record and Voice, where their plugins are: beside Annotate, or after the chips while the box is away.\n const more = () => [...(recorder !== undefined ? [record] : []), ...(voice !== undefined ? [speak] : [])];\n const chip = (content: (string | Node)[], title: string, at: number, remove: string, drop: () => void) => {\n const opener = element('button', { type: 'button', className: 'open', title });\n opener.append(...content);\n // Every attachment in one lightbox, opened at this one, growing out of its chip.\n opener.addEventListener('click', () => context.lightbox(viewed(), { at, from: el }));\n const remover = element('button', { type: 'button', className: 'remove', textContent: '×', title: remove });\n remover.addEventListener('click', drop);\n const el = element('span', { className: 'chip' });\n el.append(opener, remover);\n return el;\n };\n const shotName = (i: number) => `Screenshot ${i + 1}`;\n const recordingName = (i: number) => (recordings.length === 1 ? 'Recording' : `Recording ${i + 1}`);\n const voiceName = (i: number) => (voices.length === 1 ? 'Voice' : `Voice ${i + 1}`);\n /** What's attached, as the lightbox shows it, in the chips' order. */\n const viewed = (): LightboxItem[] => [\n ...chips.map((c, i) => ({\n kind: 'image' as const,\n url: c.url,\n title: shotName(i),\n actions: [{ label: 'Change marks', title: 'Draw on it again', run: () => void draw(c) }],\n })),\n ...recordings.map((r, i) => ({\n kind: 'page' as const,\n // The replay filling the frame, without a header of its own: the lightbox names it.\n url: `${r.url}${r.url.includes('?') ? '&' : '?'}embed`,\n title: `${recordingName(i)} · ${clock(r.duration)}`,\n actions: [\n { label: 'New tab', title: 'Play it back in a tab of its own', run: () => void window.open(r.url, '_blank', 'noopener') },\n ],\n })),\n ...voices.map((v, i) => ({ kind: 'audio' as const, url: v.url, title: `${voiceName(i)} · ${clock(v.duration)}` })),\n ];\n const showChips = () => {\n // The box stands for a shot taken as the task goes, so it's away while anything else is attached.\n const attached = attachedCount() > 0;\n shot.hidden = attached;\n chipsEl.hidden = !attached;\n if (!busy) another.textContent = chips.length > 0 ? 'Add another' : 'Annotate';\n if (!attached) actions.append(...more());\n chipsEl.replaceChildren(\n ...chips.map((c, i) => {\n const thumb = element('img', { src: c.url, alt: '' });\n return chip([thumb, shotName(i)], `Open ${shotName(i).toLowerCase()}`, i, `Remove ${shotName(i).toLowerCase()}`, () =>\n dropShot(c),\n );\n }),\n ...recordings.map((r, i) => {\n const play = element('span', { className: 'play', innerHTML: PLAY });\n return chip(\n [play, `${recordingName(i)} ${clock(r.duration)}${r.voice === undefined ? '' : ' · voice'}`],\n `Play ${recordingName(i).toLowerCase()} back`,\n chips.length + i,\n `Remove ${recordingName(i).toLowerCase()}`,\n () => {\n recordings = recordings.filter((x) => x !== r);\n dropped();\n },\n );\n }),\n ...voices.map((v, i) => {\n const play = element('span', { className: 'play', innerHTML: PLAY });\n return chip(\n [play, `${voiceName(i)} ${clock(v.duration)}`],\n `Play ${voiceName(i).toLowerCase()}`,\n chips.length + recordings.length + i,\n `Remove ${voiceName(i).toLowerCase()}`,\n () => {\n voices = voices.filter((x) => x !== v);\n dropped();\n },\n );\n }),\n ...(attached && shots !== undefined && notes !== undefined ? [another] : []),\n ...(attached ? more() : []),\n );\n able();\n mark();\n };\n const dropShot = (c: Chip) => {\n URL.revokeObjectURL(c.url);\n chips = chips.filter((x) => x !== c);\n dropped();\n };\n // Back to the box, unticked, once the last is gone: what was attached is, so nothing is until it's asked for again.\n const dropped = () => {\n if (attachedCount() === 0) attach.checked = false;\n showChips();\n };\n const toChip = (drawn: Drawn): Chip => ({ ...drawn, url: URL.createObjectURL(drawn.png) });\n const reset = () => {\n for (const c of chips) URL.revokeObjectURL(c.url);\n chips = [];\n recordings = [];\n voices = [];\n attach.checked = true;\n showChips();\n };\n\n /** Takes a shot and opens it to draw on, or opens a chip's again: saved, it's a chip. */\n const draw = async (old?: Chip) => {\n if (shots === undefined || notes === undefined || busy) return;\n busy = true;\n const was = { annotate: annotate.textContent, another: another.textContent };\n annotate.textContent = another.textContent = old === undefined ? 'Capturing…' : was.another;\n problem.textContent = '';\n try {\n const taken = old?.shot ?? (await shots.capture(context.element));\n annotate.textContent = was.annotate;\n another.textContent = was.another;\n const picture: Picture = { url: taken.url, ...taken.size };\n const marks = await notes.edit(picture, old?.marks ?? [], { signal: aborts.signal });\n if (marks === undefined) return;\n const next = toChip({ shot: taken, marks, png: await notes.flatten(picture, marks) });\n if (old === undefined) {\n chips = [...chips, next];\n } else {\n URL.revokeObjectURL(old.url);\n chips = chips.map((c) => (c === old ? next : c));\n }\n showChips();\n } catch (e) {\n problem.textContent = messageOf(e);\n } finally {\n annotate.textContent = was.annotate;\n another.textContent = was.another;\n busy = false;\n showChips();\n }\n };\n annotate.addEventListener('click', () => void draw());\n another.addEventListener('click', () => void draw());\n record.addEventListener('click', () => {\n if (recorder === undefined || busy) return;\n // A take going on is kept first, as a chip, to come back to with the rest.\n void speakOff().then(() => {\n const drawn = chips.map(({ url: _, ...d }) => d);\n const kept: Kept = { text: text.value, attach: attach.checked, drawn, recordings, voices };\n context.away(kept, () => recorder.record());\n });\n });\n\n // The mic, here: Voice starts a take, the same button (now its time) stops it, and it's a chip.\n let take: Take | undefined;\n let ticking: ReturnType<typeof setInterval> | undefined;\n let stopWave: (() => void) | undefined;\n const speakOn = async () => {\n if (voice === undefined) return;\n problem.textContent = '';\n speak.disabled = true;\n try {\n take = await voice.start();\n } catch (e) {\n problem.textContent = messageOf(e);\n return;\n } finally {\n speak.disabled = false;\n }\n const started = take.started;\n // The time, the mic's live waveform, so it's plain it hears, and what a click does.\n const time = element('span', { className: 'time' });\n const wave = element('canvas', { className: 'wave' });\n speak.replaceChildren('● ', time, wave, 'Stop');\n stopWave = liveWaveform(wave, take.stream, { played: '#fff', rest: 'rgb(255 255 255 / 0.4)' });\n const tick = () => (time.textContent = clock(Date.now() - started));\n speak.classList.add('voice-on');\n speak.title = 'Stop, and attach it';\n tick();\n ticking = setInterval(tick, 250);\n mark();\n };\n const speakOff = async () => {\n const ending = take;\n if (ending === undefined) return;\n take = undefined;\n clearInterval(ticking);\n stopWave?.();\n stopWave = undefined;\n speak.classList.remove('voice-on');\n speak.textContent = 'Saving…';\n try {\n voices = [...voices, await ending.stop()];\n } catch (e) {\n problem.textContent = messageOf(e);\n } finally {\n speak.textContent = 'Voice';\n speak.title = 'Record your voice, here';\n showChips();\n }\n };\n speak.addEventListener('click', () => void (take === undefined ? speakOn() : speakOff()));\n\n // The task whose words are open to change, by ID, and the tasks as last read.\n let editing: string | undefined;\n // The Save of a listed task whose words were changed and not kept yet.\n let edited: HTMLElement | undefined;\n /** Tells the popup what leaving now would lose: a listed task's changed words, or a new one's, typed, attached or being spoken. */\n const mark = () => context.unsaved(edited ?? (text.value.trim() !== '' || attachedCount() > 0 || take !== undefined ? add : undefined));\n let shown = context.model;\n /** Asks for a change to a listed task and shows the tasks as they are after; the panel's status says why not. */\n const change = async (op: Change) => {\n try {\n editing = undefined;\n render(await context.apply(op));\n } catch {\n render(shown);\n }\n };\n /** A task's words in a field of their own: Save or Ctrl+Enter keeps them, Cancel or Esc leaves them. */\n const editor = (t: Task) => {\n // Marked a modal while it's open, so Esc is its and not the popup's.\n const item = element('li', { className: 'editing' });\n item.dataset['deicticModal'] = '';\n const field = element('textarea', { value: t.text });\n const save = element('button', { type: 'button', className: 'primary', textContent: 'Save' });\n const leave = element('button', { type: 'button', textContent: 'Cancel' });\n const buttons = element('div', { className: 'row' });\n const right = element('span', { className: 'actions' });\n right.append(leave, save);\n buttons.append(element('code', { textContent: `#${t.id}` }), right);\n item.append(field, buttons);\n const done = () => {\n editing = undefined;\n render(shown);\n };\n const keep = () => {\n if (field.value.trim() === '') return;\n if (field.value.trim() === t.text) return done();\n save.disabled = true;\n void change({ edit: t.id, text: field.value });\n };\n field.addEventListener('input', () => {\n save.disabled = field.value.trim() === '';\n edited = field.value.trim() === t.text ? undefined : save;\n mark();\n });\n field.addEventListener('keydown', (e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n done();\n }\n if (e.key !== 'Enter' || !(e.ctrlKey || e.metaKey)) return;\n e.preventDefault();\n keep();\n });\n save.addEventListener('click', keep);\n leave.addEventListener('click', done);\n queueMicrotask(() => field.focus());\n return item;\n };\n const render = (model: Model) => {\n shown = model;\n // A task being changed is drawn again with its words as they were.\n edited = undefined;\n const { channel, link, tasks } = model;\n const name =\n link === undefined\n ? element('span')\n : element('a', { href: link, target: '_blank', rel: 'noreferrer', title: 'Open the channel on the board' });\n name.textContent = `#${channel}`;\n hint.replaceChildren('to ', name);\n list.replaceChildren(\n ...tasks.map((t) => {\n if (t.id === editing && t.open) return editor(t);\n const item = element('li');\n const id = element('code', { textContent: `#${t.id}` });\n const title = element('span', { className: 'title', textContent: t.title, title: t.title });\n const state = element('span', { className: `state ${t.state}`, textContent: t.state });\n if (t.link === undefined) {\n item.append(id, title, state);\n } else {\n const to = element('a', { href: t.link, target: '_blank', rel: 'noreferrer', title: 'Open the task on the board' });\n to.append(id);\n item.append(to, title, state);\n }\n if (!t.open) return item;\n const edit = element('button', { type: 'button', className: 'act', innerHTML: EDIT, title: 'Edit the task' });\n edit.addEventListener('click', () => {\n editing = t.id;\n render(shown);\n });\n const remove = element('button', { type: 'button', className: 'act', innerHTML: DELETE, title: 'Delete the task' });\n remove.addEventListener('click', () => {\n remove.disabled = true;\n void change({ remove: t.id });\n });\n item.append(edit, remove);\n return item;\n }),\n );\n able();\n mark();\n };\n\n /** The shots to attach: each chip's PNG, kept as a shot, or a shot taken now where the box is ticked. */\n const screenshotsOf = async (): Promise<Op['screenshots']> => {\n if (shots === undefined) return undefined;\n if (chips.length > 0) {\n add.textContent = 'Uploading…';\n return Promise.all(\n chips.map(async ({ shot: taken, marks, png }) => ({\n id: (await shots.upload(png, taken)).id,\n box: taken.box,\n ...(marks.length === 0 ? {} : { marks: marksOf(marks) }),\n })),\n );\n }\n // With a recording attached the box is away, so no shot is asked for.\n if (!attach.checked || recordings.length > 0) return undefined;\n add.textContent = 'Capturing…';\n const { id, box } = await shots.capture(context.element);\n return [{ id, box }];\n };\n\n const send = async () => {\n if (busy || sending) return;\n // A take still going is kept first: it may be all there is to send.\n await speakOff();\n if (able()) return;\n sending = true;\n able();\n problem.textContent = '';\n let screenshots: Op['screenshots'];\n try {\n screenshots = await screenshotsOf();\n } catch (e) {\n // Said under the shots, which stay as they are: untick the box, or remove the chips, to send without.\n problem.textContent = messageOf(e);\n add.textContent = 'Add task';\n sending = false;\n able();\n return;\n }\n add.textContent = 'Add task';\n const { element: el, elements } = context;\n try {\n const op: Op = {\n text: text.value,\n page: location.href,\n viewport: { width: innerWidth, height: innerHeight },\n ...(context.pointed === undefined\n ? {}\n : { pointed: { path: pathTo(context.pointed, el), html: context.pointed.outerHTML.slice(0, 4000) } }),\n count: elements.length,\n ...(screenshots === undefined ? {} : { screenshots }),\n ...(recordings.length === 0\n ? {}\n : {\n recordings: recordings.map(({ id, duration, url, voice: clips }) => ({\n id,\n duration,\n replay: new URL(url, location.href).href,\n ...(clips === undefined ? {} : { voice: clips.map((c) => c.id) }),\n })),\n }),\n ...(voices.length === 0 ? {} : { voice: voices.map(({ id, duration }) => ({ id, duration })) }),\n ...annotationsOf(notes),\n };\n const model = await context.apply(op);\n render(model);\n announce(model, op, context.target);\n text.value = '';\n reset();\n } catch {\n // The panel's status says why; what was typed and drawn stays, to send again.\n }\n sending = false;\n able();\n };\n\n // Back from recording: what was kept, and the recording, or why there's none.\n const back = context.resumed;\n if (back !== undefined) {\n const kept = back.state as Kept;\n text.value = kept.text;\n attach.checked = kept.attach;\n chips = kept.drawn.map(toChip);\n recordings = [...kept.recordings, ...(back.result === undefined ? [] : [back.result as Recording])];\n voices = kept.voices;\n if (back.problem !== undefined) problem.textContent = back.problem;\n }\n\n text.addEventListener('input', () => {\n able();\n mark();\n });\n text.addEventListener('keydown', (e) => {\n if (e.key !== 'Enter' || !(e.ctrlKey || e.metaKey)) return;\n e.preventDefault();\n void send();\n });\n add.addEventListener('click', () => void send());\n showChips();\n render(context.model);\n text.focus();\n return () => {\n aborts.abort();\n take?.cancel();\n clearInterval(ticking);\n stopWave?.();\n for (const c of chips) URL.revokeObjectURL(c.url);\n };\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCd,MAAM,QAAQ,SACZ,0JAA0J,KAAK;AACjK,MAAM,OAAO,KAAK,yBAAyB;AAC3C,MAAM,SAAS,KAAK,qCAAqC;AACzD,MAAM,OAAO;;AAGb,SAAS,QAAQ,MAAoC;CACnD,OAAO;EAAE,OAAO,KAAK;EAAQ,OAAO,KAAK,SAAS,EAAE,YAAa,MAAM,SAAS,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,CAAE;CAAE;AAC/G;;AAGA,SAAS,cAAc,OAAyD;CAC9E,MAAM,OAAO,OAAO,KAAK,KAAK,CAAC;CAC/B,OAAO,KAAK,WAAW,IAAI,CAAC,IAAI,EAAE,aAAa,QAAQ,IAAI,EAAE;AAC/D;AAuBA,MAAM,SAAS,OAAe;CAC5B,MAAM,IAAI,KAAK,MAAM,KAAK,GAAI;CAC9B,OAAO,GAAG,KAAK,MAAM,IAAI,EAAE,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC,CAA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M;GACb,MAAM,OAAO;GACb,cAAc,OAAO;GACrB,WAAW;GACX,KAAK,MAAM,KAAK,OAAO,IAAI,gBAAgB,EAAE,GAAG;EAClD;CACF;AACF,CAAC"}
@@ -0,0 +1,159 @@
1
+ import { Board } from "@vercel/board";
2
+ import { C as Shortcut, v as Target } from "../index.js";
3
+ import { t as Box } from "../index3.js";
4
+ /** What the plugin uses of a board: `board()` from `@vercel/board` is one. */
5
+ export type TaskBoard = Pick<Board, 'tasks' | 'thread' | 'discovery' | 'upload' | 'edit'>;
6
+ export interface TasksOptions {
7
+ /**
8
+ * The board, as `@vercel/board`'s `board()` answers it: by default the one `BOARD_URL` names (`npx vb serve`
9
+ * runs one on this machine), or your team's default board, through `vercel login`.
10
+ */
11
+ board?: TaskBoard;
12
+ /** The channel tasks go to: `deictic` by default. */
13
+ channel?: string;
14
+ /**
15
+ * The project the tasks are about, as the `deictic.project` label, to tell them apart on a board several
16
+ * projects share: by default the `name` in the root's `package.json`, and no label where it has none.
17
+ */
18
+ project?: string;
19
+ /** Labels every task gets besides deictic's own, for whoever works them to filter by (`vb tail --label`). None by default. */
20
+ labels?: Record<string, string>;
21
+ /**
22
+ * Where the panel links the channel to, for a person to see its tasks, and with `task`, where it links
23
+ * that task's ID to. By default the board's own pages when it's one `vb serve` runs on this machine
24
+ * (`http://127.0.0.1:4100/c/deictic`, and `?thread=<id>` on it), and none for another board, whose pages
25
+ * deictic can't know.
26
+ */
27
+ link?: (channel: string, task?: string) => string | undefined;
28
+ /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */
29
+ shortcut?: Shortcut;
30
+ }
31
+ export interface Task {
32
+ id: string;
33
+ /** The first line of what was typed. */
34
+ title: string;
35
+ /** What was typed, whole: what an edit changes. */
36
+ text: string;
37
+ state: string;
38
+ /** Whether it can still be edited or deleted: no one has claimed it. */
39
+ open: boolean;
40
+ /** Its page on the board, when there's one to link to. */
41
+ link?: string;
42
+ }
43
+ export interface Model {
44
+ channel: string;
45
+ /** The channel's page, when there's one to link to. */
46
+ link?: string;
47
+ /** Tasks about this element, oldest first, canceled ones left out. */
48
+ tasks: Task[];
49
+ }
50
+ /**
51
+ * What the Task tab asks for: a new task (an `Op`), other words for one it lists (`edit` is its ID), or
52
+ * that one deleted (`remove` is its ID), which cancels it on the board.
53
+ */
54
+ export type Change = Op | {
55
+ edit: string;
56
+ text: string;
57
+ } | {
58
+ remove: string;
59
+ };
60
+ /** A new task: what the page knows and the source doesn't. */
61
+ export interface Op {
62
+ text: string;
63
+ /** The page's URL. */
64
+ page: string;
65
+ viewport: {
66
+ width: number;
67
+ height: number;
68
+ };
69
+ /**
70
+ * What was under the pointer inside the element, where nothing marked it (a dependency's markup, or a
71
+ * shadow root's): its path from the element, and its HTML, cut short.
72
+ */
73
+ pointed?: {
74
+ path: string;
75
+ html: string;
76
+ };
77
+ /** How many elements on the page come from the same place in the source. */
78
+ count: number;
79
+ /**
80
+ * Shots the screenshots plugin took of it, to attach, where that plugin is loaded: each with where the
81
+ * element is in it, and the marks drawn on it in the panel, where there are any.
82
+ */
83
+ screenshots?: {
84
+ id: string;
85
+ box: Box;
86
+ marks?: Marks;
87
+ }[];
88
+ /**
89
+ * Recordings the recordings plugin made, to attach, where that plugin is loaded: how long each ran,
90
+ * where it plays back, and the voice plugin's clips of the mic in it, attached too.
91
+ */
92
+ recordings?: {
93
+ id: string;
94
+ duration: number;
95
+ replay: string;
96
+ voice?: string[];
97
+ }[];
98
+ /** Voice notes the voice plugin kept, to attach, where that plugin is loaded, and how long each runs. */
99
+ voice?: {
100
+ id: string;
101
+ duration: number;
102
+ }[];
103
+ /** The page's annotations, where that plugin is loaded and there are any: how many, and their notes' text. */
104
+ annotations?: Marks;
105
+ }
106
+ /**
107
+ * A task the Task tab just added, as the page hears of it: the `detail` of a `deictic:task` event on `window`, for a
108
+ * page that shows its own tasks (deictic's playground lists them as a board does).
109
+ */
110
+ export interface TaskAdded {
111
+ id: string;
112
+ /** The first line of what was typed. */
113
+ title: string;
114
+ state: string;
115
+ channel: string;
116
+ /** The element: its file, line and column, and its tag. */
117
+ target: Target;
118
+ /** The page's URL. */
119
+ page: string;
120
+ /** How many of each were attached; `marks` counts those drawn on shots and on the page. */
121
+ attached: {
122
+ screenshots: number;
123
+ recordings: number;
124
+ voice: number;
125
+ marks: number;
126
+ };
127
+ }
128
+ /** Marks, as a task tells of them: how many, and what the notes among them say. */
129
+ export interface Marks {
130
+ count: number;
131
+ notes: string[];
132
+ }
133
+ export interface Added {
134
+ channel: string;
135
+ id: string;
136
+ text: string;
137
+ labels: Record<string, string>;
138
+ /** What's attached, by the board's IDs: kept, so a redo attaches the same without uploading it again. */
139
+ attachments?: string[];
140
+ }
141
+ /** A task's words changed: its message's whole text before and after. */
142
+ export interface Edited {
143
+ kind: 'edited';
144
+ id: string;
145
+ before: string;
146
+ after: string;
147
+ }
148
+ /**
149
+ * A task deleted in the panel: canceled on the board, for good, as a board has it. So it's kept whole, and
150
+ * an undo adds it again, as a new task whose ID the record then has.
151
+ */
152
+ export interface Removed extends Added {
153
+ kind: 'removed';
154
+ }
155
+ /** What the history keeps of a change: a task added has no `kind`, as it had none before there were others. */
156
+ export type Kept = Added | Edited | Removed;
157
+ export declare function tasks(options?: TasksOptions): import("deictic").ServerPlugin<Model, Change, Kept, unknown>;
158
+ export { tasks as default };
159
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/tasks/index.ts"],"mappings":";;;;YAuBY,YAAY,KAAK;iBAEZ;;;;;EAKf,QAAQ;;EAER;;;;;EAKA;;EAEA,SAAS;;;;;;;EAOT,QAAQ,iBAAiB;;EAEzB,WAAW;;iBAGI;EACf;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;iBAGe;EACf;;EAEA;;EAEA,OAAO;;;;;;YAOG,SAAS;EAAO;EAAc;;EAAmB;;;iBAG5C;EACf;;EAEA;EACA;IAAY;IAAe;;;;;;EAK3B;IAAY;IAAc;;;EAE1B;;;;;EAKA;IAAgB;IAAY,KAAK;IAAK,QAAQ;;;;;;EAK9C;IAAe;IAAY;IAAkB;IAAgB;;;EAE7D;IAAU;IAAY;;;EAEtB,cAAc;;;;;;iBAOC;EACf;;EAEA;EACA;EACA;;EAEA,QAAQ;;EAER;;EAEA;IAAY;IAAqB;IAAoB;IAAe;;;;iBAIrD;EACf;EACA;;iBAGe;EACf;EACA;EACA;EACA,QAAQ;;EAER;;;iBAIe;EACf;EACA;EACA;EACA;;;;;;iBAOe,gBAAgB;EAC/B;;;YAIU,OAAO,QAAQ,SAAS;wBAOpB,MAAM,UAAS,iCAAiB,aAAA,OAAA,QAAA"}
@@ -0,0 +1,348 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { Refusal, definePlugin } from "../index.js";
4
+ // src/plugins/tasks/index.ts
5
+ /**
6
+ * `deictic/tasks`: open its tab on an element to add a task about it to a Vercel Board
7
+ * (`@vercel/board`). The task says what to change, in the words typed, and where: the element's file,
8
+ * line and tag, the page and the project, all as labels beside the short facts (viewport, how many, where
9
+ * it is in the shot). Whatever works the board's tasks (a person, or an agent of theirs claiming them) takes it
10
+ * from there; deictic only adds them.
11
+ *
12
+ * Adding one is a change like any other: undo cancels the task, while no one has claimed it, and redo
13
+ * adds it again, as a new task. Each task carries `deictic.at=<file:line:column>`, so the panel
14
+ * lists the ones about the element clicked, until its line moves.
15
+ */
16
+ const AT = "deictic.at";
17
+ /** What parts what was typed from the rest of a task's text. */
18
+ const REST = "\n---\n";
19
+ const OPEN = /* @__PURE__ */ new Set([
20
+ "waiting",
21
+ "ready",
22
+ "blocked"
23
+ ]);
24
+ function tasks(options = {}) {
25
+ const channel = options.channel ?? "deictic";
26
+ let team;
27
+ const boardOf = () => team ??= options.board ? Promise.resolve(options.board) : import("@vercel/board").then((m) => m.board());
28
+ let link;
29
+ const linkOf = () => link ??= (options.link ? Promise.resolve(options.link(channel)) : boardOf().then((b) => localPage(b, channel))).catch(() => {
30
+ link = void 0;
31
+ });
32
+ /** A task's page: what `link` says, or its thread on the channel's own page on this machine. */
33
+ const taskLink = (page, id) => options.link ? options.link(channel, id) : page === void 0 ? void 0 : `${page}?thread=${encodeURIComponent(id)}`;
34
+ /**
35
+ * One of this channel's tasks about an element, while it's still open: the page names it by ID, so
36
+ * nothing else on the board is its to change, nor a task someone has taken up.
37
+ */
38
+ const openTask = async (team, id, verb) => {
39
+ const { message } = await team.thread(id);
40
+ if (message.channel !== channel || message.labels[AT] === void 0) throw new Refusal(`#${id} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);
41
+ const { task } = message;
42
+ if (task !== void 0 && !OPEN.has(task.state)) throw new Refusal(`task ${id} is ${task.state}${task.claim ? ` by ${task.claim.actor}` : ""} now: ${verb} it on the board if you still mean to`);
43
+ return message;
44
+ };
45
+ /** Cancels an open task of ours, and answers it as it was. */
46
+ const cancel = async (id, reason) => {
47
+ const team = await boardOf();
48
+ const message = await openTask(team, id, "cancel");
49
+ await team.tasks.cancel(id, reason);
50
+ return message;
51
+ };
52
+ /** Puts a task's text from one to the other, unless it reads as neither any more. */
53
+ const rewrite = async (id, from, to) => {
54
+ const team = await boardOf();
55
+ const message = await openTask(team, id, "edit");
56
+ if (message.text === to) return;
57
+ if (message.text !== from) throw new Refusal(`task ${id} has been edited since: change it on the board`);
58
+ await team.edit(id, to, { revision: message.revision });
59
+ };
60
+ const create = async (record) => {
61
+ const { task } = await (await boardOf()).tasks.create(record.channel, {
62
+ text: record.text,
63
+ labels: record.labels,
64
+ ...record.attachments === void 0 ? {} : { attachments: record.attachments }
65
+ });
66
+ return {
67
+ ...record,
68
+ id: task.id
69
+ };
70
+ };
71
+ let context;
72
+ let project = options.project;
73
+ /** The screenshots and recordings to attach, uploaded to the board, or nothing when there are none. */
74
+ const attach = async (op) => {
75
+ const files = [
76
+ ...(op.screenshots ?? []).map(({ id }) => {
77
+ const shot = context?.use("screenshots")?.read(id);
78
+ if (shot === void 0) throw new Refusal(`screenshot ${id} isn't kept any more: take it again`);
79
+ return shot;
80
+ }),
81
+ ...(op.recordings ?? []).map(({ id }) => {
82
+ const recording = context?.use("recordings")?.read(id);
83
+ if (recording === void 0) throw new Refusal(`recording ${id} isn't kept any more: record it again`);
84
+ return recording;
85
+ }),
86
+ ...[...(op.recordings ?? []).flatMap((r) => r.voice ?? []), ...(op.voice ?? []).map((v) => v.id)].map((id) => {
87
+ const clip = context?.use("voice")?.read(id);
88
+ if (clip === void 0) throw new Refusal(`voice clip ${id} isn't kept any more: record it again`);
89
+ return clip;
90
+ })
91
+ ];
92
+ if (files.length === 0) return void 0;
93
+ const team = await boardOf();
94
+ return Promise.all(files.map(async (file) => (await team.upload(file)).id));
95
+ };
96
+ return definePlugin({
97
+ name: "tasks",
98
+ client: "deictic/tasks/client",
99
+ shortcut: options.shortcut,
100
+ setup: (given) => {
101
+ context = given;
102
+ project ??= nameOf(given.root);
103
+ },
104
+ read: (_source, target) => asked(async () => {
105
+ const [{ tasks: found }, page] = await Promise.all([(await boardOf()).tasks.list({
106
+ channel,
107
+ label: { [AT]: atOf(target) },
108
+ state: "all"
109
+ }), linkOf()]);
110
+ return {
111
+ channel,
112
+ ...page === void 0 ? {} : { link: page },
113
+ tasks: found.map(({ message }) => {
114
+ const text = message.text.split(REST, 1)[0];
115
+ const state = message.task?.state ?? "ready";
116
+ const to = taskLink(page, message.id);
117
+ return {
118
+ id: message.id,
119
+ title: text.split("\n", 1)[0],
120
+ text,
121
+ state,
122
+ open: OPEN.has(state),
123
+ ...to === void 0 ? {} : { link: to }
124
+ };
125
+ }).filter((t) => t.state !== "canceled")
126
+ };
127
+ }),
128
+ apply: (source, target, op) => {
129
+ if ("remove" in op) return asked(async () => {
130
+ const message = await cancel(op.remove, "deleted in deictic");
131
+ const labels = Object.fromEntries(Object.entries(message.labels).filter(([key]) => !key.startsWith("board.")));
132
+ const attachments = message.attachments.map((a) => a.id);
133
+ return { done: {
134
+ kind: "removed",
135
+ channel,
136
+ id: op.remove,
137
+ text: message.text,
138
+ labels,
139
+ ...attachments.length === 0 ? {} : { attachments }
140
+ } };
141
+ });
142
+ if (op.text.trim() === "" && ("edit" in op || shown(op) === void 0)) throw new Refusal("say what should change first");
143
+ if ("edit" in op) return asked(async () => {
144
+ const before = (await openTask(await boardOf(), op.edit, "edit")).text;
145
+ const rest = before.includes(REST) ? before.slice(before.indexOf(REST)) : "";
146
+ const after = clip(op.text.trim(), 1e4 - rest.length) + rest;
147
+ await rewrite(op.edit, before, after);
148
+ return { done: {
149
+ kind: "edited",
150
+ id: op.edit,
151
+ before,
152
+ after
153
+ } };
154
+ });
155
+ const labels = {
156
+ ...options.labels,
157
+ ...project === void 0 ? {} : { "deictic.project": clip(project, LABEL) },
158
+ ...labelsOf(source, target, op)
159
+ };
160
+ return asked(async () => {
161
+ const attachments = await attach(op);
162
+ return { done: await create({
163
+ channel,
164
+ text: textOf(op),
165
+ labels,
166
+ ...attachments === void 0 ? {} : { attachments }
167
+ }) };
168
+ });
169
+ },
170
+ undo: (record) => asked(async () => {
171
+ if (!("kind" in record)) {
172
+ await cancel(record.id, "undone in deictic");
173
+ return;
174
+ }
175
+ if (record.kind === "edited") {
176
+ await rewrite(record.id, record.after, record.before);
177
+ return;
178
+ }
179
+ const { kind, id: _, ...task } = record;
180
+ return {
181
+ kind,
182
+ ...await create(task)
183
+ };
184
+ }),
185
+ redo: (record) => asked(async () => {
186
+ if (!("kind" in record)) {
187
+ const { id: _, ...added } = record;
188
+ return create(added);
189
+ }
190
+ if (record.kind === "edited") {
191
+ await rewrite(record.id, record.before, record.after);
192
+ return record;
193
+ }
194
+ await cancel(record.id, "deleted in deictic");
195
+ return record;
196
+ }),
197
+ describe: (op, before) => {
198
+ const named = (id) => `task "${clip(before.tasks.find((t) => t.id === id)?.title ?? `#${id}`, 60)}"`;
199
+ if ("remove" in op) return `delete ${named(op.remove)}`;
200
+ if ("edit" in op) return `edit ${named(op.edit)}`;
201
+ return `task "${clip(wordsOf(op).split("\n", 1)[0], 60)}"`;
202
+ }
203
+ });
204
+ }
205
+ /**
206
+ * The channel's page on a board `vb serve` runs on this machine, which serves its pages beside its API:
207
+ * `/api/board` there, `/c/<channel>` beside it. Nothing for any other board.
208
+ */
209
+ async function localPage(team, channel) {
210
+ const url = new URL((await team.discovery()).url);
211
+ if (![
212
+ "127.0.0.1",
213
+ "localhost",
214
+ "[::1]"
215
+ ].includes(url.hostname) || !url.pathname.endsWith("/api/board")) return void 0;
216
+ return `${url.origin}${url.pathname.slice(0, -10)}/c/${channel.split("/").map(encodeURIComponent).join("/")}`;
217
+ }
218
+ const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
219
+ const said = (notes) => notes.length === 0 ? "" : `; the notes say: ${notes.map((n) => JSON.stringify(n)).join(", ")}`;
220
+ /** What was marked on the page: how many marks, and what the notes say. */
221
+ function annotated({ count, notes }, shots, recordings) {
222
+ const where = [...shots === 0 ? [] : [shots === 1 ? "the screenshot" : "the screenshots"], ...recordings === 0 ? [] : [recordings === 1 ? "the recording" : "the recordings"]];
223
+ const drawn = where.length === 0 ? "" : `, drawn in ${where.join(" and ")}`;
224
+ return `${plural(count, "mark")} on the page${drawn}${said(notes)}`;
225
+ }
226
+ /** How long each recording ran, and where it plays back, while the dev server keeps it. */
227
+ function recordingsOf(recordings) {
228
+ return recordings.map(({ duration, replay, voice }, i) => {
229
+ const name = recordings.length === 1 ? "A recording" : `Recording ${i + 1}`;
230
+ const spoken = voice === void 0 || voice.length === 0 ? "" : `, with the voice (${voice.map((id) => `voice-${id}`).join(", ")})`;
231
+ return `${name}, ${clock(duration)} long, attached as rrweb events${spoken}; it replays at ${replay}`;
232
+ });
233
+ }
234
+ /** How long each voice note runs, and the attachment it's in. */
235
+ function voicesOf(voice) {
236
+ return voice.map(({ id, duration }, i) => {
237
+ return `${voice.length === 1 ? "A voice note" : `Voice note ${i + 1}`}, ${clock(duration)} long, attached as voice-${id}`;
238
+ });
239
+ }
240
+ const clock = (ms) => {
241
+ const s = Math.round(ms / 1e3);
242
+ return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
243
+ };
244
+ /**
245
+ * What was drawn on each shot, and with several, where the element is in each: nothing marks it there. One
246
+ * shot's place is the `deictic.position` and `deictic.size` labels, so a shot with no marks has no line.
247
+ */
248
+ function shotsOf(shots) {
249
+ const [only] = shots;
250
+ if (shots.length === 1 && only !== void 0) {
251
+ const { marks } = only;
252
+ return marks === void 0 || marks.count === 0 ? [] : [`The screenshot has ${plural(marks.count, "mark")} drawn on it${said(marks.notes)}`];
253
+ }
254
+ return shots.map(({ box, marks }, i) => {
255
+ const drawn = marks === void 0 || marks.count === 0 ? "" : `, with ${plural(marks.count, "mark")} drawn on it${said(marks.notes)}`;
256
+ const [x, y, width, height] = boxOf(box);
257
+ return `In screenshot ${i + 1} at x ${x}, y ${y}, ${width}×${height}${drawn}`;
258
+ });
259
+ }
260
+ /** A box as `x,y,width,height`, in whole CSS pixels from the shot's top left. */
261
+ const boxOf = ({ x, y, width, height }) => [
262
+ x,
263
+ y,
264
+ width,
265
+ height
266
+ ].map(Math.round);
267
+ /** A label's value: a board holds 256 characters. */
268
+ const LABEL = 256;
269
+ /** The project's name: the `name` in the root's `package.json`, or nothing where it has none. */
270
+ function nameOf(root) {
271
+ try {
272
+ const { name } = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
273
+ return typeof name === "string" && name !== "" ? name : void 0;
274
+ } catch {
275
+ return;
276
+ }
277
+ }
278
+ /**
279
+ * The facts about the element, as labels: short values a script reads without parsing the text, and a watch
280
+ * filters by. `deictic.line` is the opening tag's first line as the task saw it, to tell later that it moved.
281
+ * `deictic.url` is the page's whole URL, where a label holds it: `textOf` says a longer one.
282
+ */
283
+ function labelsOf({ code, element }, target, op) {
284
+ const [shot] = op.screenshots ?? [];
285
+ return {
286
+ [AT]: atOf(target),
287
+ "deictic.tag": target.tag,
288
+ "deictic.line": clip(code.slice(element.start, element.end).split("\n", 1)[0].trim(), LABEL),
289
+ "deictic.page": clip(new URL(op.page).pathname, LABEL),
290
+ ...op.page.length <= LABEL ? { "deictic.url": op.page } : {},
291
+ "deictic.viewport": `${op.viewport.width}x${op.viewport.height}`,
292
+ "deictic.count": String(op.count),
293
+ ...op.screenshots?.length === 1 && shot !== void 0 ? placeOf(shot.box) : {}
294
+ };
295
+ }
296
+ /** Where the element is in the one shot, from its top left, and how big: `87,387` and `138x32`, as the viewport is written. */
297
+ function placeOf(box) {
298
+ const [x, y, width, height] = boxOf(box);
299
+ return {
300
+ "deictic.position": `${x},${y}`,
301
+ "deictic.size": `${width}x${height}`
302
+ };
303
+ }
304
+ const atOf = ({ loc }) => `${loc.file}:${loc.line}:${loc.column}`;
305
+ /**
306
+ * The task's text: what was typed, and after a `---` only what no label holds: what's attached and drawn, what
307
+ * was pointed at inside the element, and a URL too long for one. A board holds 10,000 characters.
308
+ */
309
+ function textOf(op) {
310
+ const more = [
311
+ ...op.page.length <= LABEL ? [] : [op.page],
312
+ ...shotsOf(op.screenshots ?? []),
313
+ ...recordingsOf(op.recordings ?? []),
314
+ ...voicesOf(op.voice ?? []),
315
+ ...op.annotations === void 0 ? [] : [annotated(op.annotations, op.screenshots?.length ?? 0, op.recordings?.length ?? 0)],
316
+ ...op.pointed === void 0 ? [] : [`Pointed at, inside it: \`${op.pointed.path}\``, fence(op.pointed.html, "html")]
317
+ ];
318
+ const tail = more.length === 0 ? "" : REST + more.join("\n");
319
+ return clip(wordsOf(op), 1e4 - tail.length) + tail;
320
+ }
321
+ /** The task's words: what was typed, or where nothing was, a line that sends the reader to what's attached. */
322
+ const wordsOf = (op) => op.text.trim() === "" ? shown(op) ?? "" : op.text.trim();
323
+ /** `See the recording and the voice note`: what stands for the words of a task sent with none, where something is attached. */
324
+ function shown(op) {
325
+ const named = (count, word) => count === void 0 || count === 0 ? [] : [`the ${word}${count === 1 ? "" : "s"}`];
326
+ const attached = [
327
+ ...named(op.screenshots?.length, "screenshot"),
328
+ ...named(op.recordings?.length, "recording"),
329
+ ...named(op.voice?.length, "voice note")
330
+ ];
331
+ return attached.length === 0 ? void 0 : `See ${new Intl.ListFormat("en", { type: "conjunction" }).format(attached)}`;
332
+ }
333
+ const fence = (text, lang) => `\`\`\`\`${lang}\n${clip(text, 1500)}\n\`\`\`\``;
334
+ const clip = (text, max) => text.length <= max ? text : `${text.slice(0, max - 1)}…`;
335
+ /** The board's answer, or a `Refusal` saying what to do when there's no board to ask or it said no. */
336
+ async function asked(ask) {
337
+ try {
338
+ return await ask();
339
+ } catch (e) {
340
+ if (e instanceof Refusal) throw e;
341
+ const { code, message, hint } = e;
342
+ if (typeof code === "string") throw new Refusal(`the board says: ${message}${hint === void 0 ? "" : ` (${hint})`}`, { cause: e });
343
+ throw new Refusal(`can't reach the board (${message ?? String(e)}): run \`npx vb serve\` and set BOARD_URL for the dev server, or \`vercel login\``, { cause: e });
344
+ }
345
+ }
346
+ export { tasks as default, tasks };
347
+
348
+ //# sourceMappingURL=index.js.map