@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,146 @@
1
+ import { useEffect, useLayoutEffect, useRef, type KeyboardEvent } from "react";
2
+
3
+ /** The composer's size the person dragged it to. Kept in the toolbar prefs, so every new comment opens at it. */
4
+ export type ComposerSize = { width: number; height: number };
5
+
6
+ /** The composer's own width; it never gets narrower than it is by default. */
7
+ export const COMPOSER_MIN_WIDTH = 240;
8
+ export const COMPOSER_MIN_HEIGHT = 100;
9
+ export const COMPOSER_MAX_WIDTH = 720;
10
+ const KEY_STEP = 16;
11
+ const MARGIN = 6;
12
+
13
+ export function clampComposerSize(
14
+ size: ComposerSize,
15
+ room: { width: number; height: number },
16
+ ): ComposerSize {
17
+ const maxWidth = Math.max(
18
+ COMPOSER_MIN_WIDTH,
19
+ Math.min(COMPOSER_MAX_WIDTH, room.width - MARGIN * 2),
20
+ );
21
+ const maxHeight = Math.max(COMPOSER_MIN_HEIGHT, room.height - MARGIN * 2);
22
+ return {
23
+ width: Math.round(Math.max(COMPOSER_MIN_WIDTH, Math.min(maxWidth, size.width))),
24
+ height: Math.round(Math.max(COMPOSER_MIN_HEIGHT, Math.min(maxHeight, size.height))),
25
+ };
26
+ }
27
+
28
+ /** A saved size, or nothing when the stored value is missing or malformed. */
29
+ export function readComposerSize(value: unknown): ComposerSize | undefined {
30
+ if (typeof value !== "object" || value === null) return undefined;
31
+ const width: unknown = Reflect.get(value, "width");
32
+ const height: unknown = Reflect.get(value, "height");
33
+ if (typeof width !== "number" || typeof height !== "number") return undefined;
34
+ if (!Number.isFinite(width) || !Number.isFinite(height)) return undefined;
35
+ return { width, height };
36
+ }
37
+
38
+ function cardSize(grip: HTMLElement): ComposerSize | null {
39
+ const card = grip.parentElement;
40
+ return card ? { width: card.offsetWidth, height: card.offsetHeight } : null;
41
+ }
42
+
43
+ /**
44
+ * The composer's resize handle, in its bottom-right corner. Dragging right widens it and dragging down makes it
45
+ * taller (the top stays put); arrow keys do the same in steps; a double-click goes back to the default.
46
+ */
47
+ export function ResizeGrip(props: {
48
+ room: () => { width: number; height: number };
49
+ /** Every step of a drag. */
50
+ onResize: (size: ComposerSize) => void;
51
+ /** The drag ended (or a key was pressed) at `size`: save it. Not called for a press that didn't move. */
52
+ onEnd: (size: ComposerSize) => void;
53
+ onReset: () => void;
54
+ }) {
55
+ const { room, onEnd, onReset } = props;
56
+ const grip = useRef<HTMLSpanElement>(null);
57
+ const latest = useRef(props);
58
+ useLayoutEffect(() => {
59
+ latest.current = props;
60
+ });
61
+ useEffect(() => {
62
+ // The toolbar's shield (`shield.ts`) stops presses at the window in the capture phase, before they reach
63
+ // the grip or React, so the drag is tracked from window capture listeners of its own.
64
+ let drag: {
65
+ pointer: number;
66
+ x: number;
67
+ y: number;
68
+ from: ComposerSize;
69
+ last: ComposerSize;
70
+ } | null = null;
71
+ const down = (event: PointerEvent) => {
72
+ const node = grip.current;
73
+ if (!node || event.button !== 0 || event.target !== node) return;
74
+ const from = cardSize(node);
75
+ if (!from) return;
76
+ event.preventDefault();
77
+ drag = { pointer: event.pointerId, x: event.clientX, y: event.clientY, from, last: from };
78
+ };
79
+ const move = (event: PointerEvent) => {
80
+ if (!drag || event.pointerId !== drag.pointer) return;
81
+ const size = clampComposerSize(
82
+ {
83
+ width: drag.from.width + event.clientX - drag.x,
84
+ height: drag.from.height + (event.clientY - drag.y),
85
+ },
86
+ latest.current.room(),
87
+ );
88
+ if (size.width === drag.last.width && size.height === drag.last.height) return;
89
+ drag.last = size;
90
+ latest.current.onResize(size);
91
+ };
92
+ const end = (event: PointerEvent) => {
93
+ if (!drag || event.pointerId !== drag.pointer) return;
94
+ const { from, last } = drag;
95
+ drag = null;
96
+ if (last !== from) latest.current.onEnd(last);
97
+ };
98
+ window.addEventListener("pointerdown", down, true);
99
+ window.addEventListener("pointermove", move, true);
100
+ window.addEventListener("pointerup", end, true);
101
+ window.addEventListener("pointercancel", end, true);
102
+ return () => {
103
+ window.removeEventListener("pointerdown", down, true);
104
+ window.removeEventListener("pointermove", move, true);
105
+ window.removeEventListener("pointerup", end, true);
106
+ window.removeEventListener("pointercancel", end, true);
107
+ };
108
+ }, []);
109
+ return (
110
+ <span
111
+ ref={grip}
112
+ className="cs-resize-grip"
113
+ data-cs-ui="composer-resize"
114
+ role="separator"
115
+ aria-orientation="horizontal"
116
+ aria-label="Resize. Drag, or use the arrow keys. Double-click to reset."
117
+ title="Drag to resize · double-click to reset"
118
+ tabIndex={0}
119
+ onDoubleClick={(event) => {
120
+ event.preventDefault();
121
+ onReset();
122
+ }}
123
+ onKeyDown={(event: KeyboardEvent<HTMLSpanElement>) => {
124
+ const delta: Partial<Record<string, [number, number]>> = {
125
+ ArrowRight: [KEY_STEP, 0],
126
+ ArrowLeft: [-KEY_STEP, 0],
127
+ ArrowUp: [0, -KEY_STEP],
128
+ ArrowDown: [0, KEY_STEP],
129
+ };
130
+ if (event.key === "Home") {
131
+ event.preventDefault();
132
+ onReset();
133
+ return;
134
+ }
135
+ const step = delta[event.key];
136
+ const from = step ? cardSize(event.currentTarget) : null;
137
+ if (!step || !from) return;
138
+ event.preventDefault();
139
+ event.stopPropagation();
140
+ onEnd(
141
+ clampComposerSize({ width: from.width + step[0], height: from.height + step[1] }, room()),
142
+ );
143
+ }}
144
+ />
145
+ );
146
+ }