@devaccel-labs/app-comments-toolbar 1.0.0 → 1.3.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 (220) hide show
  1. package/README.md +152 -18
  2. package/dist/react.js +516 -61
  3. package/dist/server.js +342 -14
  4. package/dist/types/capture/api.d.ts +30 -0
  5. package/dist/types/capture/editor.d.ts +10 -0
  6. package/dist/types/capture/ignore.d.ts +19 -0
  7. package/dist/types/capture/index.d.ts +1 -0
  8. package/dist/types/capture/picker.d.ts +9 -0
  9. package/dist/types/capture/picture.d.ts +29 -0
  10. package/dist/types/capture/surface.d.ts +39 -0
  11. package/dist/types/core/index.d.ts +2 -2
  12. package/dist/types/core/resolve.d.ts +2 -1
  13. package/dist/types/core/types.d.ts +11 -0
  14. package/dist/types/debug-context.d.ts +7 -0
  15. package/dist/types/dictation.d.ts +9 -0
  16. package/dist/types/embed/controller.d.ts +61 -0
  17. package/dist/types/embed/index.d.ts +1 -0
  18. package/dist/types/embed/options.d.ts +35 -0
  19. package/dist/types/help/index.d.ts +1 -0
  20. package/dist/types/help/panel-index.d.ts +1 -0
  21. package/dist/types/help/panel-styles.d.ts +1 -0
  22. package/dist/types/help/panel.d.ts +4 -0
  23. package/dist/types/help/pill-styles.d.ts +11 -0
  24. package/dist/types/help/pill.d.ts +44 -0
  25. package/dist/types/help/react.d.ts +12 -0
  26. package/dist/types/help/requests.d.ts +2 -0
  27. package/dist/types/help/types.d.ts +119 -0
  28. package/dist/types/help/wire.d.ts +61 -0
  29. package/dist/types/native-wire.d.ts +63 -0
  30. package/dist/types/native.d.ts +43 -0
  31. package/dist/types/react.d.ts +8 -1
  32. package/dist/types/replay.d.ts +6 -0
  33. package/dist/types/runtime/api.d.ts +250 -0
  34. package/dist/types/runtime/attachment-model.d.ts +16 -0
  35. package/dist/types/runtime/attachments.d.ts +43 -7
  36. package/dist/types/runtime/boot.d.ts +39 -0
  37. package/dist/types/runtime/browser-label.d.ts +5 -0
  38. package/dist/types/runtime/build-id.d.ts +7 -0
  39. package/dist/types/runtime/capture-ui.d.ts +45 -21
  40. package/dist/types/runtime/clarity-model.d.ts +260 -0
  41. package/dist/types/runtime/clarity-ui.d.ts +62 -0
  42. package/dist/types/runtime/client.d.ts +6 -197
  43. package/dist/types/runtime/composer-size.d.ts +30 -0
  44. package/dist/types/runtime/dashboard.d.ts +17 -2
  45. package/dist/types/runtime/debug-context-core.d.ts +88 -0
  46. package/dist/types/runtime/debug-context-host.d.ts +39 -0
  47. package/dist/types/runtime/debug-context-model.d.ts +352 -0
  48. package/dist/types/runtime/debug-context-redact.d.ts +48 -0
  49. package/dist/types/runtime/debug-context.d.ts +36 -0
  50. package/dist/types/runtime/details-model.d.ts +7 -0
  51. package/dist/types/runtime/details.d.ts +7 -5
  52. package/dist/types/runtime/dictation-engine.d.ts +98 -0
  53. package/dist/types/runtime/dictation-model.d.ts +28 -0
  54. package/dist/types/runtime/dictation-ui.d.ts +56 -0
  55. package/dist/types/runtime/dictation.d.ts +66 -0
  56. package/dist/types/runtime/draft-dock.d.ts +32 -0
  57. package/dist/types/runtime/draft-model.d.ts +104 -0
  58. package/dist/types/runtime/draft-store.d.ts +15 -0
  59. package/dist/types/runtime/edits.d.ts +1 -1
  60. package/dist/types/runtime/font.d.ts +16 -0
  61. package/dist/types/runtime/format.d.ts +30 -1
  62. package/dist/types/runtime/host-watch.d.ts +20 -0
  63. package/dist/types/runtime/icons.d.ts +16 -2
  64. package/dist/types/runtime/index.d.ts +3 -1
  65. package/dist/types/runtime/ink.d.ts +8 -0
  66. package/dist/types/runtime/kind-model.d.ts +14 -0
  67. package/dist/types/runtime/live-model.d.ts +25 -0
  68. package/dist/types/runtime/loader.d.ts +5 -11
  69. package/dist/types/runtime/markup-editor.d.ts +54 -0
  70. package/dist/types/runtime/markup-model.d.ts +126 -0
  71. package/dist/types/runtime/markup.d.ts +69 -0
  72. package/dist/types/runtime/mention-parse.d.ts +18 -0
  73. package/dist/types/runtime/mentions.d.ts +4 -4
  74. package/dist/types/runtime/page-background.d.ts +9 -0
  75. package/dist/types/runtime/page-image.d.ts +123 -0
  76. package/dist/types/runtime/placement.d.ts +6 -3
  77. package/dist/types/runtime/record.d.ts +18 -2
  78. package/dist/types/runtime/related.d.ts +1 -1
  79. package/dist/types/runtime/replay-model.d.ts +80 -0
  80. package/dist/types/runtime/replay.d.ts +5 -38
  81. package/dist/types/runtime/runtime.d.ts +6 -0
  82. package/dist/types/runtime/screen.d.ts +47 -0
  83. package/dist/types/runtime/screenshot.d.ts +60 -6
  84. package/dist/types/runtime/session-source.d.ts +45 -0
  85. package/dist/types/runtime/session.d.ts +20 -18
  86. package/dist/types/runtime/shield.d.ts +9 -0
  87. package/dist/types/runtime/shot.d.ts +45 -0
  88. package/dist/types/runtime/sketch.d.ts +26 -0
  89. package/dist/types/runtime/styles.d.ts +1 -1
  90. package/dist/types/runtime/sync.d.ts +1 -0
  91. package/dist/types/runtime/thread-model.d.ts +18 -0
  92. package/dist/types/runtime/ticket-form-model.d.ts +57 -0
  93. package/dist/types/runtime/ticket-form.d.ts +9 -0
  94. package/dist/types/runtime/toolbar.d.ts +37 -1
  95. package/dist/types/runtime/ui-scale.d.ts +17 -0
  96. package/dist/types/runtime/update.d.ts +37 -0
  97. package/dist/types/runtime/use-debug-context.d.ts +27 -0
  98. package/dist/types/server/index.d.ts +22 -0
  99. package/dist/types/server/support.d.ts +20 -0
  100. package/dist/types/server.d.ts +2 -0
  101. package/dist/types/vite/plugin.d.ts +15 -0
  102. package/dist/vite.js +121 -41
  103. package/package.json +26 -13
  104. package/src/capture/api.ts +128 -0
  105. package/src/capture/editor.tsx +178 -0
  106. package/src/capture/ignore.ts +38 -0
  107. package/src/capture/index.ts +27 -0
  108. package/src/capture/picker.tsx +171 -0
  109. package/src/capture/picture.ts +90 -0
  110. package/src/capture/surface.tsx +185 -0
  111. package/src/compiler/annotate.ts +202 -0
  112. package/src/compiler/babel.d.ts +11 -0
  113. package/src/compiler/enabled.ts +55 -0
  114. package/src/compiler/index.ts +2 -0
  115. package/src/core/index.ts +8 -0
  116. package/src/core/resolve.ts +307 -0
  117. package/src/core/types.ts +58 -0
  118. package/src/debug-context.ts +47 -0
  119. package/src/dictation.ts +17 -0
  120. package/src/embed/controller.ts +215 -0
  121. package/src/embed/index.ts +68 -0
  122. package/src/embed/options.ts +100 -0
  123. package/src/help/index.ts +38 -0
  124. package/src/help/panel-index.ts +17 -0
  125. package/src/help/panel-styles.ts +123 -0
  126. package/src/help/panel.ts +840 -0
  127. package/src/help/pill-styles.ts +75 -0
  128. package/src/help/pill.ts +338 -0
  129. package/src/help/react.tsx +143 -0
  130. package/src/help/requests.ts +111 -0
  131. package/src/help/types.ts +124 -0
  132. package/src/help/wire.ts +55 -0
  133. package/src/native-wire.ts +124 -0
  134. package/src/native.ts +282 -0
  135. package/src/react.ts +27 -0
  136. package/src/replay.ts +13 -0
  137. package/src/runtime/api.ts +531 -0
  138. package/src/runtime/attachment-model.ts +42 -0
  139. package/src/runtime/attachments.tsx +1260 -0
  140. package/src/runtime/boot.ts +95 -0
  141. package/src/runtime/browser-label.ts +31 -0
  142. package/src/runtime/build-id.ts +10 -0
  143. package/src/runtime/capture-ui.tsx +306 -0
  144. package/src/runtime/capture.ts +508 -0
  145. package/src/runtime/clarity-model.ts +634 -0
  146. package/src/runtime/clarity-ui.tsx +454 -0
  147. package/src/runtime/client.ts +151 -0
  148. package/src/runtime/composer-size.tsx +146 -0
  149. package/src/runtime/dashboard.tsx +1130 -0
  150. package/src/runtime/debug-context-core.ts +681 -0
  151. package/src/runtime/debug-context-host.ts +56 -0
  152. package/src/runtime/debug-context-model.ts +1319 -0
  153. package/src/runtime/debug-context-redact.ts +259 -0
  154. package/src/runtime/debug-context.ts +613 -0
  155. package/src/runtime/details-model.ts +30 -0
  156. package/src/runtime/details.tsx +395 -0
  157. package/src/runtime/dictation-engine.ts +616 -0
  158. package/src/runtime/dictation-model.ts +79 -0
  159. package/src/runtime/dictation-ui.tsx +363 -0
  160. package/src/runtime/dictation.ts +271 -0
  161. package/src/runtime/dock.ts +108 -0
  162. package/src/runtime/draft-dock.tsx +124 -0
  163. package/src/runtime/draft-model.ts +251 -0
  164. package/src/runtime/draft-store.ts +149 -0
  165. package/src/runtime/edits.tsx +165 -0
  166. package/src/runtime/font.ts +42 -0
  167. package/src/runtime/format.ts +129 -0
  168. package/src/runtime/freshness.ts +23 -0
  169. package/src/runtime/handoff.ts +76 -0
  170. package/src/runtime/host-watch.ts +64 -0
  171. package/src/runtime/icons.tsx +295 -0
  172. package/src/runtime/idle.ts +20 -0
  173. package/src/runtime/index.ts +11 -0
  174. package/src/runtime/ink.ts +6 -0
  175. package/src/runtime/kind-model.ts +20 -0
  176. package/src/runtime/live-model.ts +32 -0
  177. package/src/runtime/loader.tsx +87 -0
  178. package/src/runtime/markup-editor.tsx +1333 -0
  179. package/src/runtime/markup-model.ts +485 -0
  180. package/src/runtime/markup.ts +382 -0
  181. package/src/runtime/members.ts +58 -0
  182. package/src/runtime/mention-parse.ts +56 -0
  183. package/src/runtime/mentions.tsx +205 -0
  184. package/src/runtime/page-background.ts +51 -0
  185. package/src/runtime/page-image.ts +1592 -0
  186. package/src/runtime/placement.ts +336 -0
  187. package/src/runtime/record.ts +402 -0
  188. package/src/runtime/redact.ts +30 -0
  189. package/src/runtime/related.ts +34 -0
  190. package/src/runtime/render-page.ts +2 -0
  191. package/src/runtime/replay-model.ts +232 -0
  192. package/src/runtime/replay.ts +173 -0
  193. package/src/runtime/runtime-version.ts +7 -0
  194. package/src/runtime/runtime.tsx +51 -0
  195. package/src/runtime/screen.ts +182 -0
  196. package/src/runtime/screenshot.ts +260 -0
  197. package/src/runtime/session-source.ts +112 -0
  198. package/src/runtime/session.ts +108 -0
  199. package/src/runtime/shield.ts +34 -0
  200. package/src/runtime/shot.tsx +422 -0
  201. package/src/runtime/sketch.ts +139 -0
  202. package/src/runtime/styles.ts +1541 -0
  203. package/src/runtime/sync.ts +300 -0
  204. package/src/runtime/thread-model.ts +71 -0
  205. package/src/runtime/ticket-form-model.ts +128 -0
  206. package/src/runtime/ticket-form.tsx +342 -0
  207. package/src/runtime/toolbar.tsx +4427 -0
  208. package/src/runtime/ui-scale.ts +75 -0
  209. package/src/runtime/update.ts +98 -0
  210. package/src/runtime/use-debug-context.ts +81 -0
  211. package/src/server/index.ts +133 -0
  212. package/src/server/support.ts +499 -0
  213. package/src/server.ts +4 -0
  214. package/src/vite/plugin.ts +102 -0
  215. package/src/vite.ts +1 -0
  216. package/dist/chunks/chunk-CSKXLF33.js +0 -153
  217. package/dist/chunks/chunk-HUM5FQII.js +0 -160
  218. package/dist/chunks/render-page-76MLIT6M.js +0 -1421
  219. package/dist/chunks/runtime-JX75TKER.js +0 -9267
  220. package/dist/chunks/screenshot-66ARTBGR.js +0 -12
@@ -0,0 +1,139 @@
1
+ import type { Sketch } from "../core/index.js";
2
+ import { elementAt } from "./capture.js";
3
+ import { INK, INK_HALO, type Point } from "./ink.js";
4
+
5
+ export { INK, INK_HALO, type Point } from "./ink.js";
6
+ export type InkBox = { left: number; top: number; right: number; bottom: number };
7
+
8
+ /** Most points one stroke keeps once simplified, so the anchor stays well under the service's size limit. */
9
+ const MAX_POINTS = 240;
10
+ /** A stroke smaller than this many pixels both ways is a tap, not a drawing. */
11
+ const MIN_SIZE = 6;
12
+ /** The drawn-on element must cover at least this share of the drawing's box, so circling a button picks the button. */
13
+ const COVER = 0.25;
14
+
15
+ /** Drops points within `tolerance` px of the line through their neighbours (Ramer–Douglas–Peucker). */
16
+ export function simplify(points: Point[], tolerance = 1.5): Point[] {
17
+ if (points.length < 3) return points;
18
+ const keep = new Uint8Array(points.length);
19
+ keep[0] = 1;
20
+ keep[points.length - 1] = 1;
21
+ const stack: Array<[number, number]> = [[0, points.length - 1]];
22
+ while (stack.length) {
23
+ const [first, last] = stack.pop()!;
24
+ const a = points[first]!;
25
+ const b = points[last]!;
26
+ const dx = b.x - a.x;
27
+ const dy = b.y - a.y;
28
+ const length = Math.hypot(dx, dy) || 1;
29
+ let far = 0;
30
+ let index = -1;
31
+ for (let i = first + 1; i < last; i += 1) {
32
+ const p = points[i]!;
33
+ const distance =
34
+ dx || dy
35
+ ? Math.abs(dy * p.x - dx * p.y + b.x * a.y - b.y * a.x) / length
36
+ : Math.hypot(p.x - a.x, p.y - a.y);
37
+ if (distance > far) {
38
+ far = distance;
39
+ index = i;
40
+ }
41
+ }
42
+ if (index > 0 && far > tolerance) {
43
+ keep[index] = 1;
44
+ stack.push([first, index], [index, last]);
45
+ }
46
+ }
47
+ const kept = points.filter((_, i) => keep[i]);
48
+ if (kept.length <= MAX_POINTS) return kept;
49
+ return simplify(kept, tolerance * 2);
50
+ }
51
+
52
+ export function inkBox(points: Point[]): InkBox {
53
+ let left = Infinity;
54
+ let top = Infinity;
55
+ let right = -Infinity;
56
+ let bottom = -Infinity;
57
+ for (const { x, y } of points) {
58
+ left = Math.min(left, x);
59
+ top = Math.min(top, y);
60
+ right = Math.max(right, x);
61
+ bottom = Math.max(bottom, y);
62
+ }
63
+ return { left, top, right, bottom };
64
+ }
65
+
66
+ export function isTap(box: InkBox) {
67
+ return box.right - box.left < MIN_SIZE && box.bottom - box.top < MIN_SIZE;
68
+ }
69
+
70
+ /**
71
+ * The element a drawing is about: under the middle of the drawing, widened to the nearest ancestor that covers
72
+ * a fair share of it. Circling a button picks the button; circling a whole card picks the card.
73
+ */
74
+ export function elementUnder(box: InkBox): Element | null {
75
+ let element = elementAt((box.left + box.right) / 2, (box.top + box.bottom) / 2);
76
+ const area = Math.max(1, (box.right - box.left) * (box.bottom - box.top));
77
+ while (element && element.parentElement && element.parentElement !== document.body) {
78
+ const rect = element.getBoundingClientRect();
79
+ if (rect.width * rect.height >= area * COVER) break;
80
+ element = element.parentElement;
81
+ }
82
+ return element;
83
+ }
84
+
85
+ /** Strokes in viewport coordinates, stored relative to `element`'s box. */
86
+ export function sketchFor(element: Element, strokes: Point[][]): Sketch {
87
+ const rect = element.getBoundingClientRect();
88
+ return {
89
+ w: Math.round(rect.width),
90
+ h: Math.round(rect.height),
91
+ paths: strokes.map((stroke) =>
92
+ stroke.flatMap(({ x, y }) => [Math.round(x - rect.left), Math.round(y - rect.top)]),
93
+ ),
94
+ };
95
+ }
96
+
97
+ /** The drawing's box, relative to the element it is stored against. */
98
+ export function sketchBox(sketch: Sketch): InkBox {
99
+ const points: Point[] = [];
100
+ for (const path of sketch.paths)
101
+ for (let i = 0; i + 1 < path.length; i += 2) points.push({ x: path[i]!, y: path[i + 1]! });
102
+ return inkBox(points);
103
+ }
104
+
105
+ /** A smooth SVG path through a flat x, y list: quadratic curves through each pair of midpoints. */
106
+ export function pathData(path: number[], dx = 0, dy = 0) {
107
+ if (path.length < 4) return "";
108
+ const x = (i: number) => path[i * 2]! + dx;
109
+ const y = (i: number) => path[i * 2 + 1]! + dy;
110
+ const count = path.length / 2;
111
+ let d = `M${x(0)} ${y(0)}`;
112
+ for (let i = 1; i < count - 1; i += 1) {
113
+ d += ` Q${x(i)} ${y(i)} ${(x(i) + x(i + 1)) / 2} ${(y(i) + y(i + 1)) / 2}`;
114
+ }
115
+ return `${d} L${x(count - 1)} ${y(count - 1)}`;
116
+ }
117
+
118
+ /** Paints `sketch` on a canvas, given where its element's top-left corner lands and the canvas scale. */
119
+ export function paintSketch(
120
+ ctx: CanvasRenderingContext2D,
121
+ sketch: Sketch,
122
+ origin: Point,
123
+ scale: number,
124
+ ) {
125
+ ctx.save();
126
+ ctx.lineCap = "round";
127
+ ctx.lineJoin = "round";
128
+ ctx.scale(scale, scale);
129
+ const shape = new Path2D(
130
+ sketch.paths.map((path) => pathData(path, origin.x, origin.y)).join(" "),
131
+ );
132
+ ctx.lineWidth = 6;
133
+ ctx.strokeStyle = INK_HALO;
134
+ ctx.stroke(shape);
135
+ ctx.lineWidth = 3;
136
+ ctx.strokeStyle = INK;
137
+ ctx.stroke(shape);
138
+ ctx.restore();
139
+ }