@mikuexe/annotator-react 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - Initial MVP
4
+
5
+ ### Added
6
+
7
+ - React `SourceAnnotator` overlay for selecting live DOM elements and attaching notes.
8
+ - Clipboard output as Markdown, JSON, or both.
9
+ - Source-aware capture through `@mikuexe/annotator-react/register`, `bippy`, and `element-source`.
10
+ - Graceful fallback output when React source data is unavailable.
11
+ - Sonner copy success/error toasts, with `renderToaster={false}` for host-owned toaster setups.
12
+ - ESM and CommonJS package entrypoints for the main API and `./register`.
13
+
14
+ ### Package behavior
15
+
16
+ - Published files are limited to `dist/`, `README.md`, `CHANGELOG.md`, `LICENSE`, and `package.json`.
17
+ - Runtime dependencies are externalized to avoid bundling React or host app dependencies.
18
+ - Built main entrypoints include a `"use client"` directive for React Server Component/client-boundary tooling.
19
+
20
+ ### Known constraints
21
+
22
+ - Vite-first support; Next.js usage is documented but not fully validated.
23
+ - `@mikuexe/annotator-react/register` must import before React loads.
24
+ - Source capture quality depends on React owner/source metadata availability.
25
+ - No persistence, accounts, screenshots, backend sync, or collaboration features in this MVP.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ExecMD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # @mikuexe/annotator-react
2
+
3
+ React devtool overlay for source-aware UI annotations. Select live DOM elements, write notes, then copy an agent-ready Markdown prompt.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @mikuexe/annotator-react
9
+ ```
10
+
11
+ Peer deps:
12
+
13
+ ```bash
14
+ npm install react react-dom
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ `register` must be the first import in your app entry, before React loads.
20
+
21
+ ```tsx
22
+ // src/main.tsx
23
+ import "@mikuexe/annotator-react/register";
24
+
25
+ import { createRoot } from "react-dom/client";
26
+ import { SourceAnnotator } from "@mikuexe/annotator-react";
27
+ import { App } from "./App";
28
+
29
+ createRoot(document.getElementById("root")!).render(
30
+ <>
31
+ <App />
32
+ <SourceAnnotator />
33
+ </>,
34
+ );
35
+ ```
36
+
37
+ `SourceAnnotator` is a client component: render it only from browser/client React trees. In Next.js, place it behind a client boundary such as a file with `"use client"`.
38
+
39
+ Click **Annotate**, select an element, write a note, then click **Collect**.
40
+
41
+ ## API
42
+
43
+ ```ts
44
+ type SourceAnnotatorProps = {
45
+ enabled?: boolean;
46
+ hotkey?: string; // default: "alt+a"
47
+ output?: "markdown" | "json" | "both"; // default: "markdown"
48
+ onCollect?: (payload: AnnotationCollection) => void;
49
+ renderToaster?: boolean; // default: true
50
+ };
51
+ ```
52
+
53
+ `onCollect(payload)` fires after the clipboard write succeeds.
54
+
55
+ ### Sonner toaster ownership
56
+
57
+ By default, `SourceAnnotator` renders its own Sonner `<Toaster />` so copy success and failure toasts work without host setup. If your app already renders a Sonner toaster, disable the internal one to avoid duplicate toaster roots:
58
+
59
+ ```tsx
60
+ <SourceAnnotator renderToaster={false} />
61
+ ```
62
+
63
+ ## Output modes
64
+
65
+ Default output is Markdown only:
66
+
67
+ ```tsx
68
+ <SourceAnnotator />
69
+ ```
70
+
71
+ Opt into structured JSON:
72
+
73
+ ```tsx
74
+ <SourceAnnotator output="both" />
75
+ <SourceAnnotator output="json" />
76
+ ```
77
+
78
+ Markdown includes available fields only. Missing source data is omitted instead of printed as `Unavailable`.
79
+
80
+ Example copied Markdown:
81
+
82
+ ```md
83
+ Please update the UI based on these source-linked annotations.
84
+
85
+ Collected at: 2026-04-25T00:00:00.000Z
86
+
87
+ ## Annotation 1
88
+
89
+ ID: ann-1
90
+ Note: Make this CTA full width.
91
+ Source: src/App.tsx:42:7
92
+ Nearest React component: ActionButton
93
+ React owner path: ActionButton › HeroSection › App
94
+ React source stack:
95
+ - src/App.tsx:42:7 (ActionButton)
96
+ - src/App.tsx:18:3 (HeroSection)
97
+ Element tag: button
98
+ Element HTML: <button class="primary-cta" type="button">Start annotation pass</button>
99
+ Element text: Start annotation pass
100
+ Selector: #root main.app-shell section.hero button.primary-cta:nth-of-type(1)
101
+ ```
102
+
103
+ ## Captured data
104
+
105
+ ```ts
106
+ type Annotation = {
107
+ id: string;
108
+ note: string;
109
+ source: {
110
+ filePath: string;
111
+ lineNumber: number | null;
112
+ columnNumber: number | null;
113
+ componentName: string | null;
114
+ } | null;
115
+ sourceStack: Annotation["source"][];
116
+ componentPath: string[];
117
+ element: {
118
+ tagName: string;
119
+ text: string;
120
+ html: string;
121
+ selector: string;
122
+ };
123
+ };
124
+ ```
125
+
126
+ ## How source capture works
127
+
128
+ `@mikuexe/annotator-react/register` installs the React DevTools hook through `bippy/install-hook-only`. `element-source` then uses React ownership data to resolve selected DOM elements back to React components/source.
129
+
130
+ If source resolution fails, annotations still include DOM context: tag, HTML, text, selector, and any nearest React component/owner path that could be resolved.
131
+
132
+ ## Local example
133
+
134
+ ```bash
135
+ cd examples/vite-react
136
+ npm install
137
+ npm run dev
138
+ ```
139
+
140
+ The example app aliases linked source to one React copy in Vite to avoid duplicate-React invalid hook errors during local development.
141
+
142
+ ## Package scripts
143
+
144
+ ```bash
145
+ npm run check # typecheck + unit tests + build
146
+ npm run check:all # check + example build + npm pack dry-run
147
+ npm run pack:dry-run # inspect npm package contents
148
+ ```
149
+
150
+ ## Publish support
151
+
152
+ Package support links currently target `https://github.com/mikuexe/annotator-react`. Confirm `repository`, `homepage`, and `bugs` in `package.json` point at the final public repo before publishing.
153
+
154
+
155
+ ## Current constraints
156
+
157
+ - Vite-first support.
158
+ - React-first API; not framework agnostic.
159
+ - No backend, accounts, persistence, screenshots, or collaboration in v1.
160
+ - Next.js support is not validated yet.
161
+ - Source capture depends on `register` running before React imports.