agentation 1.1.1 → 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.
- package/README.md +69 -0
- package/dist/index.d.mts +41 -27
- package/dist/index.d.ts +41 -27
- package/dist/index.js +260 -163
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +260 -163
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -33,9 +33,78 @@ The toolbar appears in the bottom-right corner. Click to activate, then click an
|
|
|
33
33
|
- **Area selection** – Drag to annotate any region, even empty space
|
|
34
34
|
- **Animation pause** – Freeze CSS animations to capture specific states
|
|
35
35
|
- **Structured output** – Copy markdown with selectors, positions, and context
|
|
36
|
+
- **Programmatic access** – Callback prop for direct integration with tools
|
|
36
37
|
- **Dark/light mode** – Matches your preference or set manually
|
|
37
38
|
- **Zero dependencies** – Pure CSS animations, no runtime libraries
|
|
38
39
|
|
|
40
|
+
## Props
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Default | Description |
|
|
43
|
+
|------|------|---------|-------------|
|
|
44
|
+
| `onAnnotationAdd` | `(annotation: Annotation) => void` | - | Called when an annotation is created |
|
|
45
|
+
| `onAnnotationDelete` | `(annotation: Annotation) => void` | - | Called when an annotation is deleted |
|
|
46
|
+
| `onAnnotationUpdate` | `(annotation: Annotation) => void` | - | Called when an annotation is edited |
|
|
47
|
+
| `onAnnotationsClear` | `(annotations: Annotation[]) => void` | - | Called when all annotations are cleared |
|
|
48
|
+
| `onCopy` | `(markdown: string) => void` | - | Callback with markdown output when copy is clicked |
|
|
49
|
+
| `copyToClipboard` | `boolean` | `true` | Set to false to prevent writing to clipboard |
|
|
50
|
+
|
|
51
|
+
### Programmatic Integration
|
|
52
|
+
|
|
53
|
+
Use callbacks to receive annotation data directly:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { Agentation, type Annotation } from 'agentation';
|
|
57
|
+
|
|
58
|
+
function App() {
|
|
59
|
+
const handleAnnotation = (annotation: Annotation) => {
|
|
60
|
+
// Structured data - no parsing needed
|
|
61
|
+
console.log(annotation.element); // "Button"
|
|
62
|
+
console.log(annotation.elementPath); // "body > div > button"
|
|
63
|
+
console.log(annotation.boundingBox); // { x, y, width, height }
|
|
64
|
+
console.log(annotation.cssClasses); // "btn btn-primary"
|
|
65
|
+
|
|
66
|
+
// Send to your agent, API, etc.
|
|
67
|
+
sendToAgent(annotation);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<>
|
|
72
|
+
<YourApp />
|
|
73
|
+
<Agentation
|
|
74
|
+
onAnnotationAdd={handleAnnotation}
|
|
75
|
+
copyToClipboard={false} // Don't write to clipboard
|
|
76
|
+
/>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Annotation Type
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
type Annotation = {
|
|
86
|
+
id: string;
|
|
87
|
+
x: number; // % of viewport width
|
|
88
|
+
y: number; // px from top (viewport if fixed)
|
|
89
|
+
comment: string; // User's note
|
|
90
|
+
element: string; // e.g., "Button"
|
|
91
|
+
elementPath: string; // e.g., "body > div > button"
|
|
92
|
+
timestamp: number;
|
|
93
|
+
|
|
94
|
+
// Optional metadata (when available)
|
|
95
|
+
selectedText?: string;
|
|
96
|
+
boundingBox?: { x: number; y: number; width: number; height: number };
|
|
97
|
+
nearbyText?: string;
|
|
98
|
+
cssClasses?: string;
|
|
99
|
+
nearbyElements?: string;
|
|
100
|
+
computedStyles?: string;
|
|
101
|
+
fullPath?: string;
|
|
102
|
+
accessibility?: string;
|
|
103
|
+
isMultiSelect?: boolean;
|
|
104
|
+
isFixed?: boolean;
|
|
105
|
+
};
|
|
106
|
+
```
|
|
107
|
+
|
|
39
108
|
## How it works
|
|
40
109
|
|
|
41
110
|
Agentation captures class names, selectors, and element positions so AI agents can `grep` for the exact code you're referring to. Instead of describing "the blue button in the sidebar," you give the agent `.sidebar > button.primary` and your feedback.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
|
+
type Annotation = {
|
|
5
|
+
id: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
comment: string;
|
|
9
|
+
element: string;
|
|
10
|
+
elementPath: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
selectedText?: string;
|
|
13
|
+
boundingBox?: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
nearbyText?: string;
|
|
20
|
+
cssClasses?: string;
|
|
21
|
+
nearbyElements?: string;
|
|
22
|
+
computedStyles?: string;
|
|
23
|
+
fullPath?: string;
|
|
24
|
+
accessibility?: string;
|
|
25
|
+
isMultiSelect?: boolean;
|
|
26
|
+
isFixed?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
4
29
|
type DemoAnnotation = {
|
|
5
30
|
selector: string;
|
|
6
31
|
comment: string;
|
|
@@ -10,8 +35,22 @@ type PageFeedbackToolbarCSSProps = {
|
|
|
10
35
|
demoAnnotations?: DemoAnnotation[];
|
|
11
36
|
demoDelay?: number;
|
|
12
37
|
enableDemoMode?: boolean;
|
|
38
|
+
/** Callback fired when an annotation is added. */
|
|
39
|
+
onAnnotationAdd?: (annotation: Annotation) => void;
|
|
40
|
+
/** Callback fired when an annotation is deleted. */
|
|
41
|
+
onAnnotationDelete?: (annotation: Annotation) => void;
|
|
42
|
+
/** Callback fired when an annotation comment is edited. */
|
|
43
|
+
onAnnotationUpdate?: (annotation: Annotation) => void;
|
|
44
|
+
/** Callback fired when all annotations are cleared. Receives the annotations that were cleared. */
|
|
45
|
+
onAnnotationsClear?: (annotations: Annotation[]) => void;
|
|
46
|
+
/** Callback fired when the copy button is clicked. Receives the markdown output. */
|
|
47
|
+
onCopy?: (markdown: string) => void;
|
|
48
|
+
/** Whether to copy to clipboard when the copy button is clicked. Defaults to true. */
|
|
49
|
+
copyToClipboard?: boolean;
|
|
13
50
|
};
|
|
14
|
-
|
|
51
|
+
/** Alias for PageFeedbackToolbarCSSProps */
|
|
52
|
+
type AgentationProps = PageFeedbackToolbarCSSProps;
|
|
53
|
+
declare function PageFeedbackToolbarCSS({ demoAnnotations, demoDelay, enableDemoMode, onAnnotationAdd, onAnnotationDelete, onAnnotationUpdate, onAnnotationsClear, onCopy, copyToClipboard, }?: PageFeedbackToolbarCSSProps): react.ReactPortal | null;
|
|
15
54
|
|
|
16
55
|
interface AnnotationPopupCSSProps {
|
|
17
56
|
/** Element name to display in header */
|
|
@@ -163,33 +202,8 @@ declare function identifyAnimationElement(target: HTMLElement): string;
|
|
|
163
202
|
*/
|
|
164
203
|
declare function getElementClasses(target: HTMLElement): string;
|
|
165
204
|
|
|
166
|
-
type Annotation = {
|
|
167
|
-
id: string;
|
|
168
|
-
x: number;
|
|
169
|
-
y: number;
|
|
170
|
-
comment: string;
|
|
171
|
-
element: string;
|
|
172
|
-
elementPath: string;
|
|
173
|
-
timestamp: number;
|
|
174
|
-
selectedText?: string;
|
|
175
|
-
boundingBox?: {
|
|
176
|
-
x: number;
|
|
177
|
-
y: number;
|
|
178
|
-
width: number;
|
|
179
|
-
height: number;
|
|
180
|
-
};
|
|
181
|
-
nearbyText?: string;
|
|
182
|
-
cssClasses?: string;
|
|
183
|
-
nearbyElements?: string;
|
|
184
|
-
computedStyles?: string;
|
|
185
|
-
fullPath?: string;
|
|
186
|
-
accessibility?: string;
|
|
187
|
-
isMultiSelect?: boolean;
|
|
188
|
-
isFixed?: boolean;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
205
|
declare function getStorageKey(pathname: string): string;
|
|
192
206
|
declare function loadAnnotations<T = Annotation>(pathname: string): T[];
|
|
193
207
|
declare function saveAnnotations<T = Annotation>(pathname: string, annotations: T[]): void;
|
|
194
208
|
|
|
195
|
-
export { PageFeedbackToolbarCSS as Agentation, AnimatedBunny, type Annotation, AnnotationPopupCSS, type AnnotationPopupCSSHandle, type AnnotationPopupCSSProps, type DemoAnnotation, IconChatEllipsis, IconCheck, IconCheckSmall, IconCheckSmallAnimated, IconCheckmark, IconCheckmarkCircle, IconCheckmarkLarge, IconClose, IconCopyAlt, IconCopyAnimated, IconEye, IconEyeAlt, IconEyeAnimated, IconEyeClosed, IconEyeMinus, IconGear, IconHelp, IconListSparkle, IconMoon, IconPause, IconPauseAlt, IconPausePlayAnimated, IconPlayAlt, IconPlus, IconSun, IconTrashAlt, IconXmark, IconXmarkLarge, PageFeedbackToolbarCSS, getElementClasses, getElementPath, getNearbyText, getStorageKey, identifyAnimationElement, identifyElement, loadAnnotations, saveAnnotations };
|
|
209
|
+
export { PageFeedbackToolbarCSS as Agentation, type AgentationProps, AnimatedBunny, type Annotation, AnnotationPopupCSS, type AnnotationPopupCSSHandle, type AnnotationPopupCSSProps, type DemoAnnotation, IconChatEllipsis, IconCheck, IconCheckSmall, IconCheckSmallAnimated, IconCheckmark, IconCheckmarkCircle, IconCheckmarkLarge, IconClose, IconCopyAlt, IconCopyAnimated, IconEye, IconEyeAlt, IconEyeAnimated, IconEyeClosed, IconEyeMinus, IconGear, IconHelp, IconListSparkle, IconMoon, IconPause, IconPauseAlt, IconPausePlayAnimated, IconPlayAlt, IconPlus, IconSun, IconTrashAlt, IconXmark, IconXmarkLarge, PageFeedbackToolbarCSS, getElementClasses, getElementPath, getNearbyText, getStorageKey, identifyAnimationElement, identifyElement, loadAnnotations, saveAnnotations };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
|
+
type Annotation = {
|
|
5
|
+
id: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
comment: string;
|
|
9
|
+
element: string;
|
|
10
|
+
elementPath: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
selectedText?: string;
|
|
13
|
+
boundingBox?: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
nearbyText?: string;
|
|
20
|
+
cssClasses?: string;
|
|
21
|
+
nearbyElements?: string;
|
|
22
|
+
computedStyles?: string;
|
|
23
|
+
fullPath?: string;
|
|
24
|
+
accessibility?: string;
|
|
25
|
+
isMultiSelect?: boolean;
|
|
26
|
+
isFixed?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
4
29
|
type DemoAnnotation = {
|
|
5
30
|
selector: string;
|
|
6
31
|
comment: string;
|
|
@@ -10,8 +35,22 @@ type PageFeedbackToolbarCSSProps = {
|
|
|
10
35
|
demoAnnotations?: DemoAnnotation[];
|
|
11
36
|
demoDelay?: number;
|
|
12
37
|
enableDemoMode?: boolean;
|
|
38
|
+
/** Callback fired when an annotation is added. */
|
|
39
|
+
onAnnotationAdd?: (annotation: Annotation) => void;
|
|
40
|
+
/** Callback fired when an annotation is deleted. */
|
|
41
|
+
onAnnotationDelete?: (annotation: Annotation) => void;
|
|
42
|
+
/** Callback fired when an annotation comment is edited. */
|
|
43
|
+
onAnnotationUpdate?: (annotation: Annotation) => void;
|
|
44
|
+
/** Callback fired when all annotations are cleared. Receives the annotations that were cleared. */
|
|
45
|
+
onAnnotationsClear?: (annotations: Annotation[]) => void;
|
|
46
|
+
/** Callback fired when the copy button is clicked. Receives the markdown output. */
|
|
47
|
+
onCopy?: (markdown: string) => void;
|
|
48
|
+
/** Whether to copy to clipboard when the copy button is clicked. Defaults to true. */
|
|
49
|
+
copyToClipboard?: boolean;
|
|
13
50
|
};
|
|
14
|
-
|
|
51
|
+
/** Alias for PageFeedbackToolbarCSSProps */
|
|
52
|
+
type AgentationProps = PageFeedbackToolbarCSSProps;
|
|
53
|
+
declare function PageFeedbackToolbarCSS({ demoAnnotations, demoDelay, enableDemoMode, onAnnotationAdd, onAnnotationDelete, onAnnotationUpdate, onAnnotationsClear, onCopy, copyToClipboard, }?: PageFeedbackToolbarCSSProps): react.ReactPortal | null;
|
|
15
54
|
|
|
16
55
|
interface AnnotationPopupCSSProps {
|
|
17
56
|
/** Element name to display in header */
|
|
@@ -163,33 +202,8 @@ declare function identifyAnimationElement(target: HTMLElement): string;
|
|
|
163
202
|
*/
|
|
164
203
|
declare function getElementClasses(target: HTMLElement): string;
|
|
165
204
|
|
|
166
|
-
type Annotation = {
|
|
167
|
-
id: string;
|
|
168
|
-
x: number;
|
|
169
|
-
y: number;
|
|
170
|
-
comment: string;
|
|
171
|
-
element: string;
|
|
172
|
-
elementPath: string;
|
|
173
|
-
timestamp: number;
|
|
174
|
-
selectedText?: string;
|
|
175
|
-
boundingBox?: {
|
|
176
|
-
x: number;
|
|
177
|
-
y: number;
|
|
178
|
-
width: number;
|
|
179
|
-
height: number;
|
|
180
|
-
};
|
|
181
|
-
nearbyText?: string;
|
|
182
|
-
cssClasses?: string;
|
|
183
|
-
nearbyElements?: string;
|
|
184
|
-
computedStyles?: string;
|
|
185
|
-
fullPath?: string;
|
|
186
|
-
accessibility?: string;
|
|
187
|
-
isMultiSelect?: boolean;
|
|
188
|
-
isFixed?: boolean;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
205
|
declare function getStorageKey(pathname: string): string;
|
|
192
206
|
declare function loadAnnotations<T = Annotation>(pathname: string): T[];
|
|
193
207
|
declare function saveAnnotations<T = Annotation>(pathname: string, annotations: T[]): void;
|
|
194
208
|
|
|
195
|
-
export { PageFeedbackToolbarCSS as Agentation, AnimatedBunny, type Annotation, AnnotationPopupCSS, type AnnotationPopupCSSHandle, type AnnotationPopupCSSProps, type DemoAnnotation, IconChatEllipsis, IconCheck, IconCheckSmall, IconCheckSmallAnimated, IconCheckmark, IconCheckmarkCircle, IconCheckmarkLarge, IconClose, IconCopyAlt, IconCopyAnimated, IconEye, IconEyeAlt, IconEyeAnimated, IconEyeClosed, IconEyeMinus, IconGear, IconHelp, IconListSparkle, IconMoon, IconPause, IconPauseAlt, IconPausePlayAnimated, IconPlayAlt, IconPlus, IconSun, IconTrashAlt, IconXmark, IconXmarkLarge, PageFeedbackToolbarCSS, getElementClasses, getElementPath, getNearbyText, getStorageKey, identifyAnimationElement, identifyElement, loadAnnotations, saveAnnotations };
|
|
209
|
+
export { PageFeedbackToolbarCSS as Agentation, type AgentationProps, AnimatedBunny, type Annotation, AnnotationPopupCSS, type AnnotationPopupCSSHandle, type AnnotationPopupCSSProps, type DemoAnnotation, IconChatEllipsis, IconCheck, IconCheckSmall, IconCheckSmallAnimated, IconCheckmark, IconCheckmarkCircle, IconCheckmarkLarge, IconClose, IconCopyAlt, IconCopyAnimated, IconEye, IconEyeAlt, IconEyeAnimated, IconEyeClosed, IconEyeMinus, IconGear, IconHelp, IconListSparkle, IconMoon, IconPause, IconPauseAlt, IconPausePlayAnimated, IconPlayAlt, IconPlus, IconSun, IconTrashAlt, IconXmark, IconXmarkLarge, PageFeedbackToolbarCSS, getElementClasses, getElementPath, getNearbyText, getStorageKey, identifyAnimationElement, identifyElement, loadAnnotations, saveAnnotations };
|