@devaccel-labs/app-comments-toolbar 1.1.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 (214) hide show
  1. package/README.md +148 -30
  2. package/dist/react.js +417 -64
  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 +7 -0
  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 +1 -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 +2 -0
  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 -3
  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 +64 -11
  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/screen.d.ts +47 -0
  82. package/dist/types/runtime/screenshot.d.ts +60 -8
  83. package/dist/types/runtime/session-source.d.ts +45 -0
  84. package/dist/types/runtime/session.d.ts +20 -18
  85. package/dist/types/runtime/shield.d.ts +9 -0
  86. package/dist/types/runtime/shot.d.ts +45 -0
  87. package/dist/types/runtime/sketch.d.ts +26 -0
  88. package/dist/types/runtime/styles.d.ts +1 -1
  89. package/dist/types/runtime/sync.d.ts +1 -0
  90. package/dist/types/runtime/thread-model.d.ts +18 -0
  91. package/dist/types/runtime/ticket-form-model.d.ts +57 -0
  92. package/dist/types/runtime/ticket-form.d.ts +9 -0
  93. package/dist/types/runtime/toolbar.d.ts +37 -1
  94. package/dist/types/runtime/ui-scale.d.ts +17 -0
  95. package/dist/types/runtime/update.d.ts +32 -8
  96. package/dist/types/runtime/use-debug-context.d.ts +27 -0
  97. package/dist/types/server/index.d.ts +22 -0
  98. package/dist/types/server/support.d.ts +20 -0
  99. package/dist/types/server.d.ts +2 -0
  100. package/dist/types/vite/plugin.d.ts +15 -0
  101. package/dist/vite.js +121 -41
  102. package/package.json +24 -11
  103. package/src/capture/api.ts +128 -0
  104. package/src/capture/editor.tsx +178 -0
  105. package/src/capture/ignore.ts +38 -0
  106. package/src/capture/index.ts +27 -0
  107. package/src/capture/picker.tsx +171 -0
  108. package/src/capture/picture.ts +90 -0
  109. package/src/capture/surface.tsx +185 -0
  110. package/src/compiler/annotate.ts +202 -0
  111. package/src/compiler/babel.d.ts +11 -0
  112. package/src/compiler/enabled.ts +55 -0
  113. package/src/compiler/index.ts +2 -0
  114. package/src/core/index.ts +8 -0
  115. package/src/core/resolve.ts +307 -0
  116. package/src/core/types.ts +58 -0
  117. package/src/debug-context.ts +47 -0
  118. package/src/dictation.ts +17 -0
  119. package/src/embed/controller.ts +215 -0
  120. package/src/embed/index.ts +68 -0
  121. package/src/embed/options.ts +100 -0
  122. package/src/help/index.ts +38 -0
  123. package/src/help/panel-index.ts +17 -0
  124. package/src/help/panel-styles.ts +123 -0
  125. package/src/help/panel.ts +840 -0
  126. package/src/help/pill-styles.ts +75 -0
  127. package/src/help/pill.ts +338 -0
  128. package/src/help/react.tsx +143 -0
  129. package/src/help/requests.ts +111 -0
  130. package/src/help/types.ts +124 -0
  131. package/src/help/wire.ts +55 -0
  132. package/src/native-wire.ts +124 -0
  133. package/src/native.ts +282 -0
  134. package/src/react.ts +27 -0
  135. package/src/replay.ts +13 -0
  136. package/src/runtime/api.ts +531 -0
  137. package/src/runtime/attachment-model.ts +42 -0
  138. package/src/runtime/attachments.tsx +1260 -0
  139. package/src/runtime/boot.ts +95 -0
  140. package/src/runtime/browser-label.ts +31 -0
  141. package/src/runtime/build-id.ts +10 -0
  142. package/src/runtime/capture-ui.tsx +306 -0
  143. package/src/runtime/capture.ts +508 -0
  144. package/src/runtime/clarity-model.ts +634 -0
  145. package/src/runtime/clarity-ui.tsx +454 -0
  146. package/src/runtime/client.ts +151 -0
  147. package/src/runtime/composer-size.tsx +146 -0
  148. package/src/runtime/dashboard.tsx +1130 -0
  149. package/src/runtime/debug-context-core.ts +681 -0
  150. package/src/runtime/debug-context-host.ts +56 -0
  151. package/src/runtime/debug-context-model.ts +1319 -0
  152. package/src/runtime/debug-context-redact.ts +259 -0
  153. package/src/runtime/debug-context.ts +613 -0
  154. package/src/runtime/details-model.ts +30 -0
  155. package/src/runtime/details.tsx +395 -0
  156. package/src/runtime/dictation-engine.ts +616 -0
  157. package/src/runtime/dictation-model.ts +79 -0
  158. package/src/runtime/dictation-ui.tsx +363 -0
  159. package/src/runtime/dictation.ts +271 -0
  160. package/src/runtime/dock.ts +108 -0
  161. package/src/runtime/draft-dock.tsx +124 -0
  162. package/src/runtime/draft-model.ts +251 -0
  163. package/src/runtime/draft-store.ts +149 -0
  164. package/src/runtime/edits.tsx +165 -0
  165. package/src/runtime/font.ts +42 -0
  166. package/src/runtime/format.ts +129 -0
  167. package/src/runtime/freshness.ts +23 -0
  168. package/src/runtime/handoff.ts +76 -0
  169. package/src/runtime/host-watch.ts +64 -0
  170. package/src/runtime/icons.tsx +295 -0
  171. package/src/runtime/idle.ts +20 -0
  172. package/src/runtime/index.ts +11 -0
  173. package/src/runtime/ink.ts +6 -0
  174. package/src/runtime/kind-model.ts +20 -0
  175. package/src/runtime/live-model.ts +32 -0
  176. package/src/runtime/loader.tsx +87 -0
  177. package/src/runtime/markup-editor.tsx +1333 -0
  178. package/src/runtime/markup-model.ts +485 -0
  179. package/src/runtime/markup.ts +382 -0
  180. package/src/runtime/members.ts +58 -0
  181. package/src/runtime/mention-parse.ts +56 -0
  182. package/src/runtime/mentions.tsx +205 -0
  183. package/src/runtime/page-background.ts +51 -0
  184. package/src/runtime/page-image.ts +1592 -0
  185. package/src/runtime/placement.ts +336 -0
  186. package/src/runtime/record.ts +402 -0
  187. package/src/runtime/redact.ts +30 -0
  188. package/src/runtime/related.ts +34 -0
  189. package/src/runtime/render-page.ts +2 -0
  190. package/src/runtime/replay-model.ts +232 -0
  191. package/src/runtime/replay.ts +173 -0
  192. package/src/runtime/runtime-version.ts +7 -0
  193. package/src/runtime/runtime.tsx +51 -0
  194. package/src/runtime/screen.ts +182 -0
  195. package/src/runtime/screenshot.ts +260 -0
  196. package/src/runtime/session-source.ts +112 -0
  197. package/src/runtime/session.ts +108 -0
  198. package/src/runtime/shield.ts +34 -0
  199. package/src/runtime/shot.tsx +422 -0
  200. package/src/runtime/sketch.ts +139 -0
  201. package/src/runtime/styles.ts +1541 -0
  202. package/src/runtime/sync.ts +300 -0
  203. package/src/runtime/thread-model.ts +71 -0
  204. package/src/runtime/ticket-form-model.ts +128 -0
  205. package/src/runtime/ticket-form.tsx +342 -0
  206. package/src/runtime/toolbar.tsx +4427 -0
  207. package/src/runtime/ui-scale.ts +75 -0
  208. package/src/runtime/update.ts +98 -0
  209. package/src/runtime/use-debug-context.ts +81 -0
  210. package/src/server/index.ts +133 -0
  211. package/src/server/support.ts +499 -0
  212. package/src/server.ts +4 -0
  213. package/src/vite/plugin.ts +102 -0
  214. package/src/vite.ts +1 -0
@@ -0,0 +1,295 @@
1
+ import { useId, type ReactNode } from "react";
2
+
3
+ function Icon({ children, size = 12 }: { children: ReactNode; size?: number }) {
4
+ return (
5
+ <svg
6
+ className="cs-icon"
7
+ width={size}
8
+ height={size}
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ strokeWidth={1.5}
13
+ strokeLinecap="round"
14
+ strokeLinejoin="round"
15
+ aria-hidden="true"
16
+ >
17
+ {children}
18
+ </svg>
19
+ );
20
+ }
21
+
22
+ export const AddComment = () => (
23
+ <Icon size={13}>
24
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
25
+ <path d="M12 7v6M9 10h6" />
26
+ </Icon>
27
+ );
28
+ export const Inbox = () => (
29
+ <Icon size={13}>
30
+ <polyline points="22 12 16 12 14 15 10 15 8 12 2 12" />
31
+ <path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
32
+ </Icon>
33
+ );
34
+ export const Eye = () => (
35
+ <Icon size={13}>
36
+ <path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" />
37
+ <circle cx="12" cy="12" r="3" />
38
+ </Icon>
39
+ );
40
+ export const EyeOff = () => (
41
+ <Icon size={13}>
42
+ <path d="M9.88 9.88a3 3 0 1 0 4.24 4.24" />
43
+ <path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68" />
44
+ <path d="M6.61 6.61A13.53 13.53 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61" />
45
+ <path d="M2 2l20 20" />
46
+ </Icon>
47
+ );
48
+ export const Lock = ({ size = 15 }: { size?: number }) => (
49
+ <Icon size={size}>
50
+ <rect width="16" height="10" x="4" y="11" rx="2" />
51
+ <path d="M8 11V7a4 4 0 0 1 8 0v4" />
52
+ </Icon>
53
+ );
54
+ export const Close = () => (
55
+ <Icon size={11}>
56
+ <path d="M18 6 6 18M6 6l12 12" />
57
+ </Icon>
58
+ );
59
+ export const Send = () => (
60
+ <Icon size={11}>
61
+ <path d="m5 12 7-7 7 7M12 19V5" />
62
+ </Icon>
63
+ );
64
+ export const Check = () => (
65
+ <Icon size={11}>
66
+ <polyline points="20 6 9 17 4 12" />
67
+ </Icon>
68
+ );
69
+ export const Target = () => (
70
+ <Icon size={11}>
71
+ <circle cx="12" cy="12" r="8" />
72
+ <circle cx="12" cy="12" r="2.5" />
73
+ </Icon>
74
+ );
75
+ export const Relink = () => (
76
+ <Icon size={11}>
77
+ <path d="M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 1 1 0 10h-2M8 12h8" />
78
+ </Icon>
79
+ );
80
+ export const Undo = () => (
81
+ <Icon size={11}>
82
+ <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
83
+ <path d="M3 3v5h5" />
84
+ </Icon>
85
+ );
86
+ export const Pencil = ({ size = 10 }: { size?: number }) => (
87
+ <Icon size={size}>
88
+ <path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" />
89
+ </Icon>
90
+ );
91
+ export const Scribble = () => (
92
+ <Icon size={13}>
93
+ <path d="M4 17c2-6 5-11 7-11 3 0-4 12-1 12 2 0 4-5 6-5 1.5 0 0 4 1.5 4 1 0 2-1 2.5-2" />
94
+ </Icon>
95
+ );
96
+ export const Cursor = () => (
97
+ <Icon size={11}>
98
+ <path d="m4 4 7.07 17 2.51-7.39L21 11.07z" />
99
+ </Icon>
100
+ );
101
+ export const Paperclip = () => (
102
+ <Icon size={11}>
103
+ <path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" />
104
+ </Icon>
105
+ );
106
+ export const Record = () => (
107
+ <Icon size={11}>
108
+ <circle cx="12" cy="12" r="7" />
109
+ <circle cx="12" cy="12" r="3" fill="currentColor" stroke="none" />
110
+ </Icon>
111
+ );
112
+ export const Mic = () => (
113
+ <Icon size={11}>
114
+ <rect x="9" y="3" width="6" height="11" rx="3" />
115
+ <path d="M5 11a7 7 0 0 0 14 0M12 18v3" />
116
+ </Icon>
117
+ );
118
+ export const Camera = ({ size = 11 }: { size?: number }) => (
119
+ <Icon size={size}>
120
+ <path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z" />
121
+ <circle cx="12" cy="13" r="3" />
122
+ </Icon>
123
+ );
124
+ export const FileIcon = () => (
125
+ <Icon size={11}>
126
+ <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z" />
127
+ <polyline points="14 2 14 8 20 8" />
128
+ </Icon>
129
+ );
130
+ export const Back = () => (
131
+ <Icon>
132
+ <path d="m15 18-6-6 6-6" />
133
+ </Icon>
134
+ );
135
+ export const Ellipsis = () => (
136
+ <Icon size={11}>
137
+ <circle cx="6" cy="12" r="1.25" fill="currentColor" stroke="none" />
138
+ <circle cx="12" cy="12" r="1.25" fill="currentColor" stroke="none" />
139
+ <circle cx="18" cy="12" r="1.25" fill="currentColor" stroke="none" />
140
+ </Icon>
141
+ );
142
+ export const ChevronLeft = () => (
143
+ <Icon size={14}>
144
+ <path d="m15 18-6-6 6-6" />
145
+ </Icon>
146
+ );
147
+ export const ChevronRight = () => (
148
+ <Icon size={14}>
149
+ <path d="m9 18 6-6-6-6" />
150
+ </Icon>
151
+ );
152
+ export const Play = () => (
153
+ <Icon size={11}>
154
+ <polygon points="8 5 19 12 8 19" fill="currentColor" stroke="none" />
155
+ </Icon>
156
+ );
157
+ export const Plane = () => (
158
+ <Icon size={13}>
159
+ <path d="m22 2-7 20-4-9-9-4Z" />
160
+ <path d="M22 2 11 13" />
161
+ </Icon>
162
+ );
163
+ export const Bubble = () => (
164
+ <Icon size={14}>
165
+ <path d="M12 18.2a6.6 6.6 0 1 0-5.7-3.2L4.2 18.4l3.1-1.3A6.6 6.6 0 0 0 12 18.2z" />
166
+ <circle cx="9.1" cy="11.4" r="0.75" fill="currentColor" stroke="none" />
167
+ <circle cx="12" cy="11.4" r="0.75" fill="currentColor" stroke="none" />
168
+ <circle cx="14.9" cy="11.4" r="0.75" fill="currentColor" stroke="none" />
169
+ </Icon>
170
+ );
171
+ /** A pin that a slash draws through when `hidden`; the slash also cuts a gap in the pin behind it. */
172
+ export function Pins({ hidden }: { hidden: boolean }) {
173
+ const mask = `cs-pins-${useId().replace(/[^\w-]/g, "")}`;
174
+ const slash = hidden ? "cs-slash is-on" : "cs-slash";
175
+ return (
176
+ <Icon size={13}>
177
+ <mask id={mask} maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
178
+ <rect width="24" height="24" fill="#fff" />
179
+ <path className={slash} d="M3 3l18 18" stroke="#000" strokeWidth={5} />
180
+ </mask>
181
+ <g mask={`url(#${mask})`}>
182
+ <path d="M12 21s-6.5-5.6-6.5-11a6.5 6.5 0 0 1 13 0c0 5.4-6.5 11-6.5 11z" />
183
+ <circle cx="12" cy="10" r="2.4" />
184
+ </g>
185
+ <path className={slash} d="M3 3l18 18" />
186
+ </Icon>
187
+ );
188
+ }
189
+ export const User = () => (
190
+ <Icon size={12}>
191
+ <circle cx="12" cy="8" r="3.75" />
192
+ <path d="M4.5 20a7.5 7.5 0 0 1 15 0" />
193
+ </Icon>
194
+ );
195
+ export const Gear = () => (
196
+ <Icon size={12}>
197
+ <circle cx="12" cy="12" r="3" />
198
+ <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" />
199
+ </Icon>
200
+ );
201
+ export const Copy = () => (
202
+ <Icon size={11}>
203
+ <rect x="9" y="9" width="11" height="11" rx="2" />
204
+ <path d="M5 15V6a2 2 0 0 1 2-2h9" />
205
+ </Icon>
206
+ );
207
+ export const Clock = () => (
208
+ <Icon size={12}>
209
+ <circle cx="12" cy="12" r="8" />
210
+ <path d="M12 8v4.5l3 2" />
211
+ </Icon>
212
+ );
213
+ export const Board = () => (
214
+ <Icon size={12}>
215
+ <rect x="3" y="3" width="7.5" height="7.5" rx="1.5" />
216
+ <rect x="13.5" y="3" width="7.5" height="4.5" rx="1.5" />
217
+ <rect x="13.5" y="10.5" width="7.5" height="10.5" rx="1.5" />
218
+ <rect x="3" y="13.5" width="7.5" height="7.5" rx="1.5" />
219
+ </Icon>
220
+ );
221
+ export const ChevronDown = () => (
222
+ <Icon size={11}>
223
+ <path d="m6 9 6 6 6-6" />
224
+ </Icon>
225
+ );
226
+ export const Search = () => (
227
+ <Icon size={11}>
228
+ <circle cx="11" cy="11" r="6" />
229
+ <path d="m20 20-3.2-3.2" />
230
+ </Icon>
231
+ );
232
+ export const ZoomOut = () => (
233
+ <Icon size={11}>
234
+ <circle cx="11" cy="11" r="6.5" />
235
+ <path d="m16 16 4.5 4.5M8.5 11h5" />
236
+ </Icon>
237
+ );
238
+ export const ZoomIn = () => (
239
+ <Icon size={11}>
240
+ <circle cx="11" cy="11" r="6.5" />
241
+ <path d="m16 16 4.5 4.5M11 8.5v5M8.5 11h5" />
242
+ </Icon>
243
+ );
244
+ export const Reply = () => (
245
+ <Icon size={11}>
246
+ <path d="M9 13 4 8.5 9 4" />
247
+ <path d="M4 8.5h8.5a4.5 4.5 0 0 1 0 9H12" />
248
+ </Icon>
249
+ );
250
+ export const Markup = () => (
251
+ <Icon size={12}>
252
+ <path d="M15.5 3.5a2.1 2.1 0 0 1 3 3l-8.6 8.6-4 1 1-4Z" />
253
+ <path d="M3 21c1.7-2.6 3.4-3.4 5.1-2.8 1.5.6 2.8.4 4-1.2" />
254
+ </Icon>
255
+ );
256
+ export const Highlighter = () => (
257
+ <Icon size={12}>
258
+ <path d="M9 14 4.5 9.5a1.5 1.5 0 0 1 0-2.1l5-5a1.5 1.5 0 0 1 2.1 0L16 6.8z" />
259
+ <path d="m9 14 3.5 3.5M3 21h7" />
260
+ <path d="m15.5 8 3.6 3.6-6.4 6.4H8.4z" />
261
+ </Icon>
262
+ );
263
+ export const ArrowTool = () => (
264
+ <Icon size={12}>
265
+ <path d="M4 20 20 4" />
266
+ <path d="M20 4h-6.5M20 4v6.5" />
267
+ </Icon>
268
+ );
269
+ export const Square = () => (
270
+ <Icon size={12}>
271
+ <rect x="3.5" y="3.5" width="17" height="17" rx="2.5" />
272
+ </Icon>
273
+ );
274
+ export const Circle = () => (
275
+ <Icon size={12}>
276
+ <circle cx="12" cy="12" r="8.5" />
277
+ </Icon>
278
+ );
279
+ export const TextTool = () => (
280
+ <Icon size={12}>
281
+ <path d="M5 5h14M12 5v14M8.5 19h7" />
282
+ </Icon>
283
+ );
284
+ export const Redo = () => (
285
+ <Icon size={11}>
286
+ <path d="M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
287
+ <path d="M21 3v5h-5" />
288
+ </Icon>
289
+ );
290
+ export const Trash = () => (
291
+ <Icon size={11}>
292
+ <path d="M4 7h16M10 4h4M6 7l1 13h10l1-13" />
293
+ <path d="M10 11v6M14 11v6" />
294
+ </Icon>
295
+ );
@@ -0,0 +1,20 @@
1
+ export type IdleDeadline = { didTimeout: boolean; timeRemaining(): number };
2
+
3
+ /** How long a fallback idle slice may run where the browser has no requestIdleCallback (Safari). */
4
+ const FALLBACK_SLICE_MS = 8;
5
+
6
+ /** Runs `task` when the browser is next idle, or after `timeout` ms at the latest. Returns a cancel function. */
7
+ export function whenIdle(task: (deadline: IdleDeadline) => void, timeout: number): () => void {
8
+ if (typeof requestIdleCallback === "function") {
9
+ const id = requestIdleCallback(task, { timeout });
10
+ return () => cancelIdleCallback(id);
11
+ }
12
+ const id = setTimeout(
13
+ () => {
14
+ const end = performance.now() + FALLBACK_SLICE_MS;
15
+ task({ didTimeout: false, timeRemaining: () => Math.max(0, end - performance.now()) });
16
+ },
17
+ Math.min(timeout, 200),
18
+ );
19
+ return () => clearTimeout(id);
20
+ }
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ export { CommentToolbar } from "./loader.js";
4
+ export type { ToolbarPosition, ToolbarProps, ToolbarTheme } from "./toolbar.js";
5
+ export { queryCacheSummary, reportToolbarError } from "./debug-context-host.js";
6
+ export type {
7
+ DebugContextConfig,
8
+ DebugContextOptions,
9
+ DebugSignal,
10
+ HostContext,
11
+ } from "./debug-context-model.js";
@@ -0,0 +1,6 @@
1
+ /** A point in px, and the toolbar's ink colours. DOM-free; shared by sketches and markup. */
2
+ export type Point = { x: number; y: number };
3
+
4
+ /** Ink colour, and the halo under it that keeps a stroke readable on dark and busy pages. */
5
+ export const INK = "#ff3b30";
6
+ export const INK_HALO = "rgba(255, 255, 255, 0.85)";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * What kind of report a new comment is, when the person says: `POST /v1/threads` takes it as `kind`. Left
3
+ * unsaid, nothing is sent and the service decides with the title. DOM-free.
4
+ *
5
+ * The kinds mirror `ClarityKind` in `packages/contract/src/clarity.ts`; the toolbar bundle does not import the
6
+ * contract package. `tests/kind-composer.spec.tsx` holds the two in step.
7
+ */
8
+
9
+ export type ReportKind = "bug" | "feedback" | "discussion";
10
+
11
+ export const REPORT_KINDS: readonly { readonly kind: ReportKind; readonly label: string }[] = [
12
+ { kind: "bug", label: "Bug" },
13
+ { kind: "feedback", label: "Feedback" },
14
+ { kind: "discussion", label: "Discussion" },
15
+ ];
16
+
17
+ /** `value` as a kind, or null: a stored draft holds whatever an older or newer build wrote. */
18
+ export function readReportKind(value: unknown): ReportKind | null {
19
+ return REPORT_KINDS.some((item) => item.kind === value) ? (value as ReportKind) : null;
20
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The live socket's protocol and timing, shared by the web toolbar's `useThreadsSync` (`./sync.ts`) and native
3
+ * clients: what a message means, the keepalive, the push batch, and the reconnect backoff. DOM-free.
4
+ */
5
+ export type LiveMessage = { type: "changed" } | { type: "build"; build: string } | { type: "pong" };
6
+
7
+ /**
8
+ * What the worker sent over the live socket: "changed" (threads moved; also anything unrecognised, so an older
9
+ * worker's pushes still refresh), a build announcement, or the keepalive answer.
10
+ */
11
+ export function parseLiveMessage(data: unknown): LiveMessage {
12
+ if (data === "pong") return { type: "pong" };
13
+ if (typeof data === "string" && data.startsWith("{")) {
14
+ try {
15
+ const parsed = JSON.parse(data) as { type?: unknown; build?: unknown };
16
+ if (parsed.type === "build" && typeof parsed.build === "string" && parsed.build)
17
+ return { type: "build", build: parsed.build };
18
+ } catch {
19
+ // Not JSON after all: treated as a change below.
20
+ }
21
+ }
22
+ return { type: "changed" };
23
+ }
24
+
25
+ /** If the live socket hasn't opened by then, fetch anyway instead of waiting on a slow handshake. */
26
+ export const OPEN_WAIT_MS = 2_000;
27
+ /** After this many handshakes in a row that never opened (a CSP block, say), retry only every RETRY_LATER_MS. */
28
+ export const MAX_QUICK_RETRIES = 4;
29
+ export const RETRY_LATER_MS = 5 * 60_000;
30
+ export const KEEPALIVE_MS = 25_000;
31
+ /** Pushes that arrive together cause one refetch. */
32
+ export const PUSH_BATCH_MS = 120;
@@ -0,0 +1,87 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { bootToolbar } from "./boot.js";
3
+ import { captureHandoff } from "./handoff.js";
4
+ import { watchHost } from "./host-watch.js";
5
+ import type { RuntimeProps, ToolbarHandle } from "./runtime.js";
6
+ import { sessionFor } from "./session.js";
7
+ import type { DebugContextConfig, HostBuild } from "./debug-context-model.js";
8
+ import type { ToolbarProps } from "./toolbar.js";
9
+
10
+ /** The build the Vite plugin stamped into this bundle (`commentService()`), when it did. */
11
+ declare const __COMMENT_TOOL_HOST_BUILD__: HostBuild | undefined;
12
+ const stampedBuild: HostBuild | undefined =
13
+ typeof __COMMENT_TOOL_HOST_BUILD__ === "object" ? __COMMENT_TOOL_HOST_BUILD__ : undefined;
14
+
15
+ /** The host's debug context with the stamped build as its `build`, unless the host gave one. */
16
+ function withStampedBuild(config: DebugContextConfig | undefined): DebugContextConfig | undefined {
17
+ if (!config || !stampedBuild) return config;
18
+ const options = config === true ? {} : config;
19
+ return options.build ? config : { ...options, build: stampedBuild };
20
+ }
21
+
22
+ captureHandoff();
23
+
24
+ const now = (task: () => void) => {
25
+ task();
26
+ return () => {};
27
+ };
28
+
29
+ /**
30
+ * Renders nothing and does nothing during render. Once the page is idle it asks the session route whether
31
+ * comments are on, and only then loads and mounts the toolbar (`./boot.ts`, which the script-tag loader runs
32
+ * too). While the toolbar is not on the page the route is asked again when a sign-in may have happened
33
+ * (`./host-watch.ts`); once it is, the toolbar follows the host's sign-in itself.
34
+ */
35
+ export function CommentToolbar({
36
+ sessionPath = "/api/comment-service/session",
37
+ pollMs,
38
+ position,
39
+ theme,
40
+ navigate,
41
+ screen,
42
+ debugContext,
43
+ }: ToolbarProps) {
44
+ const handle = useRef<ToolbarHandle | null>(null);
45
+ const navigateRef = useRef(navigate);
46
+ const propsRef = useRef<RuntimeProps>({});
47
+
48
+ useEffect(() => {
49
+ navigateRef.current = navigate;
50
+ propsRef.current = {
51
+ sessionPath,
52
+ pollMs,
53
+ position,
54
+ theme,
55
+ navigate: navigate ? (href) => navigateRef.current?.(href) : undefined,
56
+ screen,
57
+ debugContext: withStampedBuild(debugContext),
58
+ getSession: sessionFor(sessionPath),
59
+ };
60
+ handle.current?.update(propsRef.current);
61
+ }, [debugContext, navigate, pollMs, position, screen, sessionPath, theme]);
62
+
63
+ useEffect(() => {
64
+ const boot = (refresh: boolean, wait?: typeof now) =>
65
+ bootToolbar({
66
+ getSession: () => sessionFor(sessionPath)({ refresh }),
67
+ props: () => propsRef.current,
68
+ onMount: (mounted) => {
69
+ handle.current = mounted;
70
+ },
71
+ ...(wait ? { wait } : {}),
72
+ });
73
+ let stop = boot(false);
74
+ const watch = watchHost(() => {
75
+ if (handle.current) return;
76
+ stop();
77
+ stop = boot(true, now);
78
+ });
79
+ return () => {
80
+ watch.stop();
81
+ handle.current = null;
82
+ stop();
83
+ };
84
+ }, [sessionPath]);
85
+
86
+ return null;
87
+ }