@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,47 @@
1
+ /**
2
+ * Which screen of the host app an address is, and so which threads' pins belong on the page. DOM-free.
3
+ *
4
+ * A thread stores the address it was left on (`url`: path, query and hash) next to its `route` (the path). Two
5
+ * addresses are one screen when they have the same path, the same hash route (a hash that starts with `#/` or
6
+ * `#!/`, as hash routers write them; any other hash is a place on the page and does not count), and the same
7
+ * values for every query parameter that names a screen.
8
+ *
9
+ * Without a rule from the host, every query parameter names a screen except the ones that never do: tracking
10
+ * (`utm_*`, `gclid`, …), paging, sorting, searching and filtering by their usual names, and the toolbar's own.
11
+ * A host whose screens differ by fewer parameters names them (`{ params: ["view"] }`), and one whose screens
12
+ * are not in the address that way names each screen itself with a function.
13
+ *
14
+ * A thread whose address is a bare path (no query, no hash route) was stored before addresses were kept, or was
15
+ * left where the path was all there was: it shows on every screen at that path, as every thread did before. A
16
+ * host function decides for those too.
17
+ */
18
+ /** What the host says identifies a screen: the query parameters that do, or a function that names it. */
19
+ export type ScreenRule = {
20
+ readonly params: readonly string[];
21
+ } | ((address: URL) => string);
22
+ /**
23
+ * The screen `url` is, as a string two addresses of one screen share. A host function that throws names
24
+ * nothing, and the address is read by the parameters instead.
25
+ */
26
+ export declare function screenKey(url: URL, rule?: ScreenRule | null): string;
27
+ /** True for an address that is only a path: no query and no hash route. */
28
+ export declare function isBarePath(address: string): boolean;
29
+ /** The address a thread was left on, as the toolbar reads it: its `url`, else its `route`. */
30
+ export type Placed = {
31
+ readonly route: string;
32
+ readonly url?: string | null;
33
+ };
34
+ export type Here = {
35
+ /** The page's path, which anchors are captured and resolved against. */
36
+ readonly route: string;
37
+ /** The screen the page is on. */
38
+ readonly key: string;
39
+ /** Whether `thread` was left on this screen, so its pin belongs here. */
40
+ has(thread: Placed): boolean;
41
+ };
42
+ /**
43
+ * The screen at `href` (the page's whole address), and which threads belong on it. A thread is only ever on
44
+ * a screen at its own path, because its anchor is found among that path's elements. One whose `url` is not a
45
+ * page of this app (a native app's screen) belongs here by its `route` alone, as before.
46
+ */
47
+ export declare function screenAt(href: string, rule?: ScreenRule | null): Here;
@@ -1,12 +1,66 @@
1
+ import type { Sketch } from "../core/index.js";
1
2
  import type { Capture } from "./client.js";
2
3
  /** The page, viewport and browser a screenshot is being taken in. */
3
4
  export declare function describeCapture(url: string): Capture;
4
- /** The visible page as a canvas, toolbar left out. `timeout` bounds a slow frame. */
5
+ /** A box in CSS pixels from the top-left of the viewport. */
6
+ export type Frame = {
7
+ left: number;
8
+ top: number;
9
+ width: number;
10
+ height: number;
11
+ };
12
+ export type Viewport = {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ /** `rect` as a frame, or null when none of it is inside the viewport. */
17
+ export declare function frameOf(rect: DOMRect | Frame, viewport: Viewport): Frame | null;
18
+ /** The ring drawn around `frame`, in output pixels, when the picture is `scale` output pixels per CSS pixel. */
19
+ export declare function ringFor(frame: Frame, scale: number, origin?: {
20
+ left: number;
21
+ top: number;
22
+ }): {
23
+ x: number;
24
+ y: number;
25
+ w: number;
26
+ h: number;
27
+ };
28
+ /**
29
+ * The part of the viewport a crop around `frame` shows: the element and its drawing with room around them, at
30
+ * least `CROP_MIN`, never beyond the viewport, centred on the element as far as the viewport allows.
31
+ */
32
+ export declare function cropFor(frame: Frame, viewport: Viewport, sketch?: Sketch): Frame;
33
+ /**
34
+ * The page as it was at one instant: a copy of its DOM and, if an element was being pointed at, that element's
35
+ * box in the viewport at the same instant. Drawing the copy happens later and takes a while; measuring the
36
+ * element then instead would put its ring wherever the element had moved to in the meantime.
37
+ */
38
+ export type PageShot = {
39
+ /** The highlighted element's box when the page was copied; null when nothing was, or it was off screen. */
40
+ frame: Frame | null;
41
+ viewport: Viewport;
42
+ /** Device pixels per CSS pixel the drawing is made at. */
43
+ scale: number;
44
+ /** The drawing, made once on the first request and shared by every picture cut from this shot. */
45
+ render: () => Promise<HTMLCanvasElement>;
46
+ };
47
+ /**
48
+ * Copies the visible page now, synchronously, with `highlight`'s box measured at the same moment. The toolbar is
49
+ * left out. Nothing is drawn until `render` is first called (see `shotPage`, `shotAround`).
50
+ */
51
+ export declare function takeShot(highlight?: Element | null, timeout?: number): PageShot;
52
+ /** The visible page as a canvas, toolbar left out, drawn from the page as it is now. `timeout` bounds a slow frame. */
5
53
  export declare function renderViewport(scale: number, timeout?: number): Promise<HTMLCanvasElement>;
6
- /** The whole visible page as a JPEG, toolbar left out. If `highlight` is on screen it's outlined. */
7
- export declare function capturePage(highlight?: Element | null): Promise<Blob | null>;
8
54
  /**
9
- * Capture what the person sees around `element`, with the toolbar left out, the rest dimmed,
10
- * and the element outlined. Returns a JPEG data URL, or null if the element isn't on screen or capture fails.
55
+ * The whole visible page as a JPEG, from `shot`. If the shot framed an element it's outlined, or `sketch`
56
+ * (drawn against it) is painted on instead.
57
+ */
58
+ export declare function shotPage(shot: PageShot, sketch?: Sketch): Promise<Blob | null>;
59
+ /**
60
+ * What the person saw around the framed element, cut from `shot`, with the rest dimmed and the element
61
+ * outlined, or with `sketch` painted on instead. A JPEG data URL, or null when nothing was framed or the
62
+ * page couldn't be drawn.
11
63
  */
12
- export declare function captureAround(element: Element): Promise<string | null>;
64
+ export declare function shotAround(shot: PageShot, sketch?: Sketch): Promise<string | null>;
65
+ /** `shotAround` for the page as it is now. */
66
+ export declare function captureAround(element: Element, sketch?: Sketch): Promise<string | null>;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The host session (which comment service, project and environment, and the 15-minute host token) and the
3
+ * cache that reuses it until the token is about to expire. DOM-free: the web toolbar loads the session route
4
+ * with `fetch` from the page (`./session.ts`); native clients load it with the app's own bearer auth.
5
+ */
6
+ export type Session = {
7
+ apiUrl: string;
8
+ project: string;
9
+ environment: string;
10
+ hostToken: string;
11
+ /**
12
+ * Native clients only: their app origin (`<scheme>://app`), sent as `x-comment-service-origin` on every
13
+ * request. Web leaves it unset; the browser sends `Origin`.
14
+ */
15
+ clientOrigin?: string;
16
+ /**
17
+ * Web, script-tag loader only (`../embed`): the origin the session route says `embed.js` may be loaded from
18
+ * when that is not `apiUrl`'s origin. Without it the loader mounts nothing for such a session.
19
+ */
20
+ loaderOrigin?: string;
21
+ };
22
+ /** Returns this page's session, or null when comments are off. `refresh` skips the cached one. */
23
+ export type GetSession = (options?: {
24
+ refresh?: boolean;
25
+ }) => Promise<Session | null>;
26
+ export declare function readJwt(token: string): {
27
+ exp?: number;
28
+ typ?: string;
29
+ name?: string;
30
+ email?: string;
31
+ memberId?: string;
32
+ origin?: string;
33
+ } | null;
34
+ export declare function sessionFrom(payload: unknown): Session | null;
35
+ /**
36
+ * The session route answered, and its answer was "comments are off" with a reason (`{ enabled: false, error }`),
37
+ * most often because nobody is signed in. Not a failure to reach it.
38
+ */
39
+ export declare class SessionOff extends Error {
40
+ }
41
+ /**
42
+ * Reads the session route at most once at a time and reuses the answer until its host token is about to expire.
43
+ * "Comments are off" is kept for the source's lifetime. A failed request is not kept, so the next call retries.
44
+ */
45
+ export declare function sessionSource(path: string, load: (path: string) => Promise<unknown>, now?: () => number): GetSession;
@@ -1,21 +1,12 @@
1
- export type Session = {
2
- apiUrl: string;
3
- project: string;
4
- environment: string;
5
- hostToken: string;
6
- };
7
- /** Returns this page's session, or null when comments are off. `refresh` skips the cached one. */
8
- export type GetSession = (options?: {
9
- refresh?: boolean;
10
- }) => Promise<Session | null>;
11
- export declare function readJwt(token: string): {
12
- exp?: number;
13
- typ?: string;
14
- name?: string;
15
- email?: string;
16
- memberId?: string;
17
- } | null;
18
- export declare function sessionFrom(payload: unknown): Session | null;
1
+ import { type GetSession, type Session } from "./session-source.js";
2
+ export { readJwt, sessionFrom, SessionOff } from "./session-source.js";
3
+ export type { GetSession, Session } from "./session-source.js";
4
+ /**
5
+ * Forgets every toolbar sign-in this page's origin holds. Run when the host app says nobody is signed in: a
6
+ * sign-in is kept per browser, not per person of the host app, so the next person to sign in to the app must
7
+ * not find the last one's.
8
+ */
9
+ export declare function forgetSignIns(storage?: Storage): void;
19
10
  /**
20
11
  * Reads the session route at most once at a time and reuses the answer until its host token is about to expire.
21
12
  * "Comments are off" is kept for the page's lifetime. A failed request is not kept, so the next call retries.
@@ -23,3 +14,14 @@ export declare function sessionFrom(payload: unknown): Session | null;
23
14
  export declare function sessionSource(path: string, load?: (path: string) => Promise<unknown>, now?: () => number): GetSession;
24
15
  /** The page-wide session source for a session route path. */
25
16
  export declare function sessionFor(path: string): GetSession;
17
+ /** What the host app says now: comments are on (with the session), off, or it could not be asked. */
18
+ export type HostAnswer = {
19
+ readonly state: "on";
20
+ readonly session: Session;
21
+ } | {
22
+ readonly state: "off";
23
+ } | {
24
+ readonly state: "unknown";
25
+ };
26
+ /** Asks the session route again, past any kept answer, or takes the kept one when `fresh` is false. */
27
+ export declare function askHost(get: GetSession, fresh?: boolean): Promise<HostAnswer>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Keeps the page from reacting to the toolbar. Presses on the toolbar never reach the page, so an open menu,
3
+ * popover, or dialog does not treat them as an outside press, and buttons do not pull focus out of it. Focus
4
+ * moving into the toolbar is hidden from document-level focus traps (Radix FocusScope listens for focusin and
5
+ * focusout on document), which would otherwise pull it straight back into an open modal so the composer never
6
+ * takes input. The focus listeners sit on document, so the page's and the toolbar's own React handlers still
7
+ * run; call this before any app dialog opens so stopImmediatePropagation runs ahead of the trap's listeners.
8
+ */
9
+ export declare function shieldFromPage(): () => void;
@@ -0,0 +1,45 @@
1
+ import { type ReactNode } from "react";
2
+ import { type Pending, type PreviewFile } from "./attachments.js";
3
+ import { type MarkupShape } from "./markup.js";
4
+ import { type MarkupResult } from "./markup-editor.js";
5
+ import { type ReplayEvent } from "./replay.js";
6
+ /** The captures a draft holds: pictures (marked up on the stage) and clips. */
7
+ export type ShotCapture = PreviewFile;
8
+ /**
9
+ * The flattened picture `item` needs before it is sent, given the shapes drawn on it: null when the file already
10
+ * shows them, the original when every shape is gone, else a fresh flatten. Rejects when the image can't be read.
11
+ */
12
+ export declare function flattenCapture(item: Pending, shapes: MarkupShape[]): Promise<MarkupResult | null>;
13
+ /** Where an event sits on a clip's timeline, 0..1, or null when it falls outside the clip. */
14
+ export declare function timelinePosition(event: ReplayEvent, clip: {
15
+ startedAt: number;
16
+ durationMs: number;
17
+ }): number | null;
18
+ /**
19
+ * A draft of captures as a comment: the selected capture fills the surface (a picture with the markup tools live
20
+ * on it, or a clip playing), the others sit in a filmstrip, and the composer (`children`) is a column beside it.
21
+ * Nothing has to be typed, and there is no Done to press: posting flattens whatever was drawn (see the composer's
22
+ * submit in `toolbar.tsx`). "Another page" and "Record" minimise the surface to the dock so the draft can collect
23
+ * more from elsewhere in the app.
24
+ */
25
+ export declare function ShotSurface({ captures, selectedId, shapes, savedAt, onSelect, onRemove, onShapes, onAnother, onRecord, onDictate, dictating, onMinimise, onDiscard, confirmDiscard, onSubmit, children, }: {
26
+ captures: ShotCapture[];
27
+ selectedId: string | null;
28
+ /** Shapes drawn on each picture so far, by capture id; a picture not listed shows its flattened shapes. */
29
+ shapes: ReadonlyMap<string, MarkupShape[]>;
30
+ savedAt: number | null;
31
+ onSelect: (id: string) => void;
32
+ onRemove: (id: string) => void;
33
+ onShapes: (id: string, shapes: MarkupShape[]) => void;
34
+ onAnother: () => void;
35
+ onRecord: () => void;
36
+ /** Starts (or stops) typing what the person says into the comment; absent when dictation is not available. */
37
+ onDictate?: (() => void) | undefined;
38
+ dictating?: boolean | undefined;
39
+ onMinimise: () => void;
40
+ onDiscard: () => void;
41
+ confirmDiscard: boolean;
42
+ /** Cmd+Enter on the picture: post, as it does in the comment box. */
43
+ onSubmit: () => void;
44
+ children: ReactNode;
45
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import type { Sketch } from "../core/index.js";
2
+ import { type Point } from "./ink.js";
3
+ export { INK, INK_HALO, type Point } from "./ink.js";
4
+ export type InkBox = {
5
+ left: number;
6
+ top: number;
7
+ right: number;
8
+ bottom: number;
9
+ };
10
+ /** Drops points within `tolerance` px of the line through their neighbours (Ramer–Douglas–Peucker). */
11
+ export declare function simplify(points: Point[], tolerance?: number): Point[];
12
+ export declare function inkBox(points: Point[]): InkBox;
13
+ export declare function isTap(box: InkBox): boolean;
14
+ /**
15
+ * The element a drawing is about: under the middle of the drawing, widened to the nearest ancestor that covers
16
+ * a fair share of it. Circling a button picks the button; circling a whole card picks the card.
17
+ */
18
+ export declare function elementUnder(box: InkBox): Element | null;
19
+ /** Strokes in viewport coordinates, stored relative to `element`'s box. */
20
+ export declare function sketchFor(element: Element, strokes: Point[][]): Sketch;
21
+ /** The drawing's box, relative to the element it is stored against. */
22
+ export declare function sketchBox(sketch: Sketch): InkBox;
23
+ /** A smooth SVG path through a flat x, y list: quadratic curves through each pair of midpoints. */
24
+ export declare function pathData(path: number[], dx?: number, dy?: number): string;
25
+ /** Paints `sketch` on a canvas, given where its element's top-left corner lands and the canvas scale. */
26
+ export declare function paintSketch(ctx: CanvasRenderingContext2D, sketch: Sketch, origin: Point, scale: number): void;