@agent-native/toolkit 0.11.2 → 0.12.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 (66) hide show
  1. package/README.md +19 -0
  2. package/agent-native.eject.json +38 -0
  3. package/dist/canvas-annotations/CanvasCommentPins.d.ts +68 -0
  4. package/dist/canvas-annotations/CanvasCommentPins.d.ts.map +1 -0
  5. package/dist/canvas-annotations/CanvasCommentPins.js +513 -0
  6. package/dist/canvas-annotations/CanvasCommentPins.js.map +1 -0
  7. package/dist/canvas-annotations/DrawOverlay.d.ts +108 -0
  8. package/dist/canvas-annotations/DrawOverlay.d.ts.map +1 -0
  9. package/dist/canvas-annotations/DrawOverlay.js +746 -0
  10. package/dist/canvas-annotations/DrawOverlay.js.map +1 -0
  11. package/dist/canvas-annotations/DrawOverlay.spec.d.ts +2 -0
  12. package/dist/canvas-annotations/DrawOverlay.spec.d.ts.map +1 -0
  13. package/dist/canvas-annotations/DrawOverlay.spec.js +111 -0
  14. package/dist/canvas-annotations/DrawOverlay.spec.js.map +1 -0
  15. package/dist/canvas-annotations/index.d.ts +4 -0
  16. package/dist/canvas-annotations/index.d.ts.map +1 -0
  17. package/dist/canvas-annotations/index.js +3 -0
  18. package/dist/canvas-annotations/index.js.map +1 -0
  19. package/dist/canvas-annotations/types.d.ts +8 -0
  20. package/dist/canvas-annotations/types.d.ts.map +1 -0
  21. package/dist/canvas-annotations/types.js +2 -0
  22. package/dist/canvas-annotations/types.js.map +1 -0
  23. package/dist/canvas-interactions/canvas-interactions.d.ts +334 -0
  24. package/dist/canvas-interactions/canvas-interactions.d.ts.map +1 -0
  25. package/dist/canvas-interactions/canvas-interactions.js +451 -0
  26. package/dist/canvas-interactions/canvas-interactions.js.map +1 -0
  27. package/dist/canvas-interactions/canvas-interactions.spec.d.ts +2 -0
  28. package/dist/canvas-interactions/canvas-interactions.spec.d.ts.map +1 -0
  29. package/dist/canvas-interactions/canvas-interactions.spec.js +538 -0
  30. package/dist/canvas-interactions/canvas-interactions.spec.js.map +1 -0
  31. package/dist/canvas-interactions/index.d.ts +2 -0
  32. package/dist/canvas-interactions/index.d.ts.map +1 -0
  33. package/dist/canvas-interactions/index.js +2 -0
  34. package/dist/canvas-interactions/index.js.map +1 -0
  35. package/dist/design-tweaks/scrub-input-utils.d.ts +61 -0
  36. package/dist/design-tweaks/scrub-input-utils.d.ts.map +1 -0
  37. package/dist/design-tweaks/scrub-input-utils.js +235 -0
  38. package/dist/design-tweaks/scrub-input-utils.js.map +1 -0
  39. package/dist/design-tweaks/scrub-input.d.ts +66 -0
  40. package/dist/design-tweaks/scrub-input.d.ts.map +1 -0
  41. package/dist/design-tweaks/scrub-input.js +313 -0
  42. package/dist/design-tweaks/scrub-input.js.map +1 -0
  43. package/dist/design-tweaks/visual-style-controls.d.ts +2 -12
  44. package/dist/design-tweaks/visual-style-controls.d.ts.map +1 -1
  45. package/dist/design-tweaks/visual-style-controls.js +3 -107
  46. package/dist/design-tweaks/visual-style-controls.js.map +1 -1
  47. package/dist/design-tweaks/visual-style-controls.spec.js +26 -0
  48. package/dist/design-tweaks/visual-style-controls.spec.js.map +1 -1
  49. package/dist/index.d.ts +1 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/package.json +29 -1
  54. package/src/canvas-annotations/CanvasCommentPins.tsx +861 -0
  55. package/src/canvas-annotations/DrawOverlay.spec.tsx +145 -0
  56. package/src/canvas-annotations/DrawOverlay.tsx +1233 -0
  57. package/src/canvas-annotations/index.ts +15 -0
  58. package/src/canvas-annotations/types.ts +14 -0
  59. package/src/canvas-interactions/canvas-interactions.spec.ts +688 -0
  60. package/src/canvas-interactions/canvas-interactions.ts +933 -0
  61. package/src/canvas-interactions/index.ts +67 -0
  62. package/src/design-tweaks/scrub-input-utils.ts +311 -0
  63. package/src/design-tweaks/scrub-input.tsx +491 -0
  64. package/src/design-tweaks/visual-style-controls.spec.tsx +60 -0
  65. package/src/design-tweaks/visual-style-controls.tsx +23 -168
  66. package/src/index.ts +1 -0
@@ -0,0 +1,108 @@
1
+ import type { CanvasAnnotationTranslate } from "./types.js";
2
+ export interface DrawAnnotation {
3
+ id: string;
4
+ type: "path" | "text";
5
+ /** SVG path data for "path" type */
6
+ pathData?: string;
7
+ /** Text content for "text" type */
8
+ text?: string;
9
+ /** Annotation color (hex) */
10
+ color: string;
11
+ /** Stroke width for paths, font weight reference for text */
12
+ lineWidth: number;
13
+ /** Position relative to the canvas (text annotations only) */
14
+ position: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ /**
19
+ * Creation timestamp (Date.now()) — used for unified undo ordering across
20
+ * strokes and text annotations. Optional so existing callers of DrawAnnotation
21
+ * don't need to supply it.
22
+ */
23
+ createdAt?: number;
24
+ }
25
+ export interface DrawOverlayProps {
26
+ translate: CanvasAnnotationTranslate;
27
+ /** Whether the overlay is currently visible (toggled from the toolbar) */
28
+ visible: boolean;
29
+ /** When false, canvas clicks pass through to sibling tools while the toolbar stays usable. */
30
+ canvasInteractive?: boolean;
31
+ /** Extra queued annotations owned by sibling tools, such as comment pins. */
32
+ queuedAnnotationCount?: number;
33
+ /**
34
+ * Current zoom level (percentage, e.g. 100 = 100%). Used to convert
35
+ * getBoundingClientRect() visual-space coordinates to layout-space so that
36
+ * strokes and text labels stay anchored to their painted position across
37
+ * zoom changes.
38
+ */
39
+ zoom?: number;
40
+ /** Called when the user submits the queued strokes/text to the agent */
41
+ onSend: (annotations: DrawAnnotation[], instruction: string, canvasSize: {
42
+ width: number;
43
+ height: number;
44
+ }) => void;
45
+ /** Called when the user cancels / closes the draw mode */
46
+ onClose: () => void;
47
+ /**
48
+ * True while the caller is capturing/compositing/uploading the annotated
49
+ * screenshot for a just-submitted drawing (see the design app's
50
+ * design-canvas/annotation-snapshot.ts). Disables Send and swaps its icon
51
+ * for a spinner so a slow capture can't be triggered twice from the same
52
+ * drawing. The entire overlay becomes inert while true so edits made after
53
+ * the submitted snapshot cannot be erased when that submission is later
54
+ * confirmed and the caller clears the batch.
55
+ */
56
+ sending?: boolean;
57
+ /**
58
+ * Bump this (e.g. a counter) exactly when the caller wants to discard the
59
+ * current strokes/text annotations — after `onClose` or a confirmed Send.
60
+ * Strokes/text are intentionally NOT cleared merely because `visible`
61
+ * turns false: `visible` can toggle off for reasons that have nothing to
62
+ * do with the user wanting to discard their work (switching tools, views,
63
+ * or side panels), and doing so silently would destroy annotations the
64
+ * user never got a chance to send. Only an in-progress (uncommitted)
65
+ * gesture is reset on hide; a pending text label is committed so its typed
66
+ * content survives.
67
+ */
68
+ clearSignal?: number;
69
+ /**
70
+ * Identity of the canvas this annotation batch belongs to. When the host
71
+ * reuses one DrawOverlay instance for a different screen, the old batch is
72
+ * cleared with a warning instead of being silently reinterpreted against
73
+ * the new screen's pixels and submitted with the wrong screenshot.
74
+ */
75
+ scopeKey?: string;
76
+ /**
77
+ * Keep the canvas DOM/bitmap alive while hidden. Use for the one active
78
+ * editor overlay whose work must survive mode/view toggles; leave false for
79
+ * large preview grids so every dormant screen does not allocate a canvas
80
+ * and ResizeObserver.
81
+ */
82
+ retainSurfaceWhenHidden?: boolean;
83
+ }
84
+ /**
85
+ * Draw-to-prompt overlay for the slide canvas.
86
+ *
87
+ * Mirrors claude.ai/design's "Draw mode": the user sketches on the canvas,
88
+ * adds a one-line text instruction, hits Send, and the strokes + instruction
89
+ * are forwarded to the agent. The agent receives the path geometry along with
90
+ * the canvas size so it can interpret position semantically (e.g. "move the
91
+ * title here").
92
+ *
93
+ * This component is canvas-agnostic — it overlays absolutely-positioned over
94
+ * its parent, so the parent (a slide editor or design canvas) only needs to
95
+ * be `position: relative`.
96
+ *
97
+ * Coordinate model
98
+ * ----------------
99
+ * All stroke points and text positions are stored as fractions (0..1) of the
100
+ * canvas's visual rect (getBoundingClientRect). This makes them stable across
101
+ * zoom and resize. When rendering:
102
+ * - Canvas strokes: multiply by rect.width / rect.height (visual pixels).
103
+ * - CSS text labels: multiply by rect.width/scale / rect.height/scale
104
+ * (layout pixels inside the scaled wrapper).
105
+ * - pathData in send(): layout pixels = fraction * rect.width / scale.
106
+ */
107
+ export declare function DrawOverlay({ translate, visible, canvasInteractive, queuedAnnotationCount, zoom, onSend, onClose, sending, clearSignal, scopeKey, retainSurfaceWhenHidden, }: DrawOverlayProps): import("react").JSX.Element | null;
108
+ //# sourceMappingURL=DrawOverlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrawOverlay.d.ts","sourceRoot":"","sources":["../../src/canvas-annotations/DrawOverlay.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,yBAAyB,CAAC;IACrC,0EAA0E;IAC1E,OAAO,EAAE,OAAO,CAAC;IACjB,8FAA8F;IAC9F,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,6EAA6E;IAC7E,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,MAAM,EAAE,CACN,WAAW,EAAE,cAAc,EAAE,EAC7B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAC1C,IAAI,CAAC;IACV,0DAA0D;IAC1D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAiHD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,SAAS,EACT,OAAO,EACP,iBAAwB,EACxB,qBAAyB,EACzB,IAAU,EACV,MAAM,EACN,OAAO,EACP,OAAe,EACf,WAAW,EACX,QAAQ,EACR,uBAA+B,GAChC,EAAE,gBAAgB,sCAq7BlB"}