@githumbi/grabby 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 +11 -0
- package/LICENSE +22 -0
- package/README.md +262 -0
- package/builders.json +14 -0
- package/dist/angular/index.d.ts +279 -0
- package/dist/angular/index.js +5145 -0
- package/dist/angular/index.js.map +1 -0
- package/dist/babel-plugin/index.cjs +95 -0
- package/dist/babel-plugin/index.cjs.map +1 -0
- package/dist/babel-plugin/index.d.cts +28 -0
- package/dist/babel-plugin/index.d.ts +28 -0
- package/dist/babel-plugin/index.js +60 -0
- package/dist/babel-plugin/index.js.map +1 -0
- package/dist/builder/builders/application/index.js +141 -0
- package/dist/builder/builders/application/index.js.map +1 -0
- package/dist/builder/builders/application/schema.json +7 -0
- package/dist/builder/builders/dev-server/index.js +137 -0
- package/dist/builder/builders/dev-server/index.js.map +1 -0
- package/dist/builder/builders/dev-server/schema.json +26 -0
- package/dist/builder/index.js +2 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/package.json +1 -0
- package/dist/chunk-6CBIOKZV.cjs +45 -0
- package/dist/chunk-6CBIOKZV.cjs.map +1 -0
- package/dist/chunk-M3DOFJA7.js +45 -0
- package/dist/chunk-M3DOFJA7.js.map +1 -0
- package/dist/cli/index.js +406 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.cjs +5081 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +96 -0
- package/dist/core/index.d.ts +96 -0
- package/dist/core/index.js +5081 -0
- package/dist/core/index.js.map +1 -0
- package/dist/esbuild-plugin/index.cjs +134 -0
- package/dist/esbuild-plugin/index.cjs.map +1 -0
- package/dist/esbuild-plugin/index.d.cts +21 -0
- package/dist/esbuild-plugin/index.d.ts +21 -0
- package/dist/esbuild-plugin/index.js +96 -0
- package/dist/esbuild-plugin/index.js.map +1 -0
- package/dist/export/index.cjs +166 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +86 -0
- package/dist/export/index.d.ts +86 -0
- package/dist/export/index.js +137 -0
- package/dist/export/index.js.map +1 -0
- package/dist/grabby.global.js +635 -0
- package/dist/live/index.cjs +30 -0
- package/dist/live/index.cjs.map +1 -0
- package/dist/live/index.d.cts +20 -0
- package/dist/live/index.d.ts +20 -0
- package/dist/live/index.js +30 -0
- package/dist/live/index.js.map +1 -0
- package/dist/loader.global.js +1 -0
- package/dist/plugin/index.cjs +229 -0
- package/dist/plugin/index.cjs.map +1 -0
- package/dist/plugin/index.d.cts +76 -0
- package/dist/plugin/index.d.ts +76 -0
- package/dist/plugin/index.js +186 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/react/index.d.ts +290 -0
- package/dist/react/index.js +5110 -0
- package/dist/react/index.js.map +1 -0
- package/dist/types-CMgpkvBz.d.cts +265 -0
- package/dist/types-CMgpkvBz.d.ts +265 -0
- package/package.json +191 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @githumbi/grabby
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
First release as Grabby (formerly angular-grab).
|
|
6
|
+
|
|
7
|
+
- Compact, kind-aware capture (action, field, text, media, container, section) with screenshots, instead of full outerHTML. Form values are never captured and text is redacted.
|
|
8
|
+
- Comments collect in a panel; **Copy all** offers compact, standard or detailed exports with a token estimate, then **Copy & clear** (with Undo) or **Copy, keep comments**.
|
|
9
|
+
- Adapters for React, Angular, Vue 2 and 3, Svelte 4 and 5 and plain HTML, detected per element; one build plugin for Vite, webpack, Rspack, Rollup, Rolldown and esbuild.
|
|
10
|
+
- Live-site mode: feedback links, commenter name or anonymous, a 500-byte loader, and delivery to `@githumbi/grabby-server` with retries.
|
|
11
|
+
- UI isolated in a shadow root, safe under CSP and Trusted Types. Default shortcut is Option/Alt+G.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Nate Richardson
|
|
4
|
+
Copyright (c) 2026 Githumbi
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# Grabby
|
|
2
|
+
|
|
3
|
+
**Point at any part of your UI, say what should change, and hand it to your AI coding agent.**
|
|
4
|
+
|
|
5
|
+
Grabby adds a small toolbar to your app. Click an element, type a comment, and Grabby records where that element lives in your code (component, `file:line`), what it is (a button, a form field, a card…), the few styles that matter, and a screenshot. Collect as many comments as you like, then **Copy all** and paste into Claude, Cursor, Copilot or ChatGPT, or let your agent read them directly over MCP.
|
|
6
|
+
|
|
7
|
+
It works on `localhost` while you build, and on your deployed site to collect feedback from clients, teammates or testers, with each comment tagged by who left it.
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
# UI feedback · 2 comments
|
|
11
|
+
localhost:5173 · React · page /pricing · 1440×900 · 2026-09-26
|
|
12
|
+
|
|
13
|
+
## src/components/PlanCard.tsx · PlanCard
|
|
14
|
+
1. Highlight the Pro plan button
|
|
15
|
+
- `<button class="btn">Choose Pro</button>` (action) line 15
|
|
16
|
+
- styles: bg #2563eb · color #fff · weight 600 · padding 10px 14px · radius 8px
|
|
17
|
+
- inside: App (App.tsx:11)
|
|
18
|
+
2. Stack the cards vertically on mobile
|
|
19
|
+
- `<article class="card">(4 elements)</article>` (container) line 9
|
|
20
|
+
- heading: Starter · contains: heading, p, list, button · size: 225×234
|
|
21
|
+
- layout: padding 20px · bg #fff · radius 12px · border 1px solid #e2e8f0
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
That's the whole export: no page dumps, around 150–300 tokens per comment.
|
|
25
|
+
|
|
26
|
+
- [Quick start](#quick-start)
|
|
27
|
+
- [Using it](#using-it)
|
|
28
|
+
- [What gets captured](#what-gets-captured)
|
|
29
|
+
- [Feedback on a live site](#feedback-on-a-live-site)
|
|
30
|
+
- [Connect your AI agent](#connect-your-ai-agent)
|
|
31
|
+
- [Framework support](#framework-support)
|
|
32
|
+
- [Configuration](#configuration)
|
|
33
|
+
- [Security and privacy](#security-and-privacy)
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx grabby init
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`init` detects your framework, bundler and package manager, shows exactly which files it will change, and asks before touching anything. Or set it up by hand:
|
|
42
|
+
|
|
43
|
+
**React, Vue, Solid, Preact (Vite)**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm add -D @githumbi/grabby
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// vite.config.ts
|
|
51
|
+
import grabby from '@githumbi/grabby/plugin';
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
plugins: [grabby.vite(), react()], // grabby first
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
// src/main.tsx (or main.ts)
|
|
60
|
+
import { initGrabby } from '@githumbi/grabby';
|
|
61
|
+
|
|
62
|
+
if (import.meta.env.DEV) initGrabby();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The plugin adds `file:line:col` to every element in development only. Production builds contain neither the stamps nor Grabby. Using webpack, Rspack, Rollup or esbuild? Use `grabby.webpack()`, `grabby.rspack()`, and so on.
|
|
66
|
+
|
|
67
|
+
**Svelte / SvelteKit.** No plugin needed, since Svelte's dev build already records locations. Just call `initGrabby()`.
|
|
68
|
+
|
|
69
|
+
**Angular (17+)**
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
// app.config.ts
|
|
73
|
+
import { provideGrabby } from '@githumbi/grabby/angular';
|
|
74
|
+
|
|
75
|
+
export const appConfig: ApplicationConfig = {
|
|
76
|
+
providers: [provideGrabby()],
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
In `angular.json`, swap the builders to `@githumbi/grabby:application` and `@githumbi/grabby:dev-server`. `npx grabby init` does both.
|
|
81
|
+
|
|
82
|
+
**Next.js**
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
// next.config.js
|
|
86
|
+
const grabby = require('@githumbi/grabby/plugin').default;
|
|
87
|
+
module.exports = { webpack: (config) => { config.plugins.unshift(grabby.webpack()); return config; } };
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
// a client component in your root layout
|
|
92
|
+
'use client';
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (process.env.NODE_ENV === 'development') import('@githumbi/grabby').then((g) => g.initGrabby());
|
|
95
|
+
}, []);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Any site, no build step**
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<script src="https://cdn.jsdelivr.net/npm/@githumbi/grabby@0.1.0/dist/grabby.global.js" defer></script>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Using it
|
|
105
|
+
|
|
106
|
+
1. Press **Option+G** (Mac) or **Alt+G**, or click the hand icon, to enter selection mode.
|
|
107
|
+
2. Hover to see each element's component and file. Click one. Clicking an icon inside a button selects the button; hold **Shift** to pick the exact inner element.
|
|
108
|
+
3. Type what should change and press **Enter**. Grabby saves it with a screenshot. Nothing is copied yet.
|
|
109
|
+
4. Keep going. The badge counts your comments; the list shows them with thumbnails. Click one to edit it.
|
|
110
|
+
5. **Copy all** opens a preview. Choose a detail level, edit the text if you like, then:
|
|
111
|
+
- **Copy & clear**: copy, and start fresh next time (with Undo, in case).
|
|
112
|
+
- **Copy, keep comments**: copy and keep them.
|
|
113
|
+
|
|
114
|
+
| Key | |
|
|
115
|
+
|---|---|
|
|
116
|
+
| Option+G / Alt+G | Toggle selection mode |
|
|
117
|
+
| F | Freeze the page while selecting, to grab menus, tooltips and hover states |
|
|
118
|
+
| Enter / Shift+Enter | Save comment / new line |
|
|
119
|
+
| Esc | Cancel, close the panel, or leave selection mode |
|
|
120
|
+
| ⌘/Ctrl+Enter | Copy & clear, in the Copy dialog |
|
|
121
|
+
|
|
122
|
+
## What gets captured
|
|
123
|
+
|
|
124
|
+
Grabby looks at *what kind* of element you clicked and keeps only what matters for it:
|
|
125
|
+
|
|
126
|
+
| Kind | Captured |
|
|
127
|
+
|---|---|
|
|
128
|
+
| **Action**: button, link, tab | label, href path, state (disabled, expanded, selected), custom styles |
|
|
129
|
+
| **Form field** | label, type, placeholder, required/invalid. **Never the value.** |
|
|
130
|
+
| **Text** | text (up to 120 chars), font size, weight, colour, line height |
|
|
131
|
+
| **Media** | alt text (or that it's missing), file name, rendered vs natural size |
|
|
132
|
+
| **Container / card** | heading, a summary of what's inside ("heading, 3× PlanCard, button"), layout styles |
|
|
133
|
+
| **Page section** | page title, viewport, regions and components on the page. No HTML. |
|
|
134
|
+
|
|
135
|
+
Every comment also carries the component, source file and line, up to three of *your* components above it (library frames are skipped), a trimmed HTML preview capped at 300 characters, and a screenshot. Styles are compared against browser defaults, so only the values your code set are reported.
|
|
136
|
+
|
|
137
|
+
The export names the page once, groups comments by file, and skips anything already visible in the preview. **Compact** is one line per comment; **Detailed** adds ancestors, position and all custom styles for tricky layout bugs. Twenty mixed comments fit comfortably under 6k tokens at the default level.
|
|
138
|
+
|
|
139
|
+
Screenshots are never pasted into the text; they'd crowd out the context window. They stay in the browser (and on your collector, if you use one), and `pull` and MCP give your agent the image file.
|
|
140
|
+
|
|
141
|
+
## Feedback on a live site
|
|
142
|
+
|
|
143
|
+
Collect comments from clients, stakeholders or testers on your deployed site. Ordinary visitors see nothing; reviewers open a feedback link.
|
|
144
|
+
|
|
145
|
+
**1. Run a collector.** It's small, has no database or native dependencies, and runs anywhere Node 20 or Docker does.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npx @githumbi/grabby-server init --origin https://your-site.com
|
|
149
|
+
npx @githumbi/grabby-server start --public
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`init` prints a **project key** (public, goes in your site) and an **admin token** (secret, for you). To deploy with Docker, Fly.io, Render or Railway, see [packages/server](packages/server/README.md).
|
|
153
|
+
|
|
154
|
+
**2. Add Grabby to the site.** The loader is under 500 bytes gzipped and fetches the rest only for reviewers:
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
<script
|
|
158
|
+
src="https://cdn.jsdelivr.net/npm/@githumbi/grabby@0.1.0/dist/loader.global.js"
|
|
159
|
+
data-mode="live"
|
|
160
|
+
data-server="https://feedback.your-site.com"
|
|
161
|
+
data-project-key="pk_…"
|
|
162
|
+
defer
|
|
163
|
+
></script>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Pin an exact version. To guard against a compromised CDN, add Subresource Integrity: `integrity` and `crossorigin="anonymous"` on the loader tag cover the loader, and `data-integrity` covers the full build it fetches. jsDelivr shows both hashes on the package's file pages.
|
|
167
|
+
|
|
168
|
+
or with a bundler:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { initGrabbyLive } from '@githumbi/grabby/live';
|
|
172
|
+
|
|
173
|
+
initGrabbyLive({ server: 'https://feedback.your-site.com', projectKey: 'pk_…' });
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**3. Share the feedback link:** `https://your-site.com/?grabby=pk_…`
|
|
177
|
+
|
|
178
|
+
Reviewers get a **Comment** button and a short three-step tip. After their first comment, Grabby asks who it's from: a name, or **Post anonymously**. The choice is remembered, and anonymous reviewers still get a stable id, so you can tell "Anonymous 3f9a" from "Anonymous b21c". If your app already knows who's signed in, skip the question with `grabby.identify({ id, name })`. Each comment is sent as soon as it's saved: it's kept in the browser first and retried until it reaches your collector, so a bad connection doesn't lose it. The toolbar shows how many were sent, and closing the tab with a half-typed or unsent comment brings up the browser's "Leave site?" prompt. When they're done, reviewers press **Finish review** to see what reached you; **Done** clears their list and keeps the toolbar for another round. They leave feedback mode with ✕, which opens the same summary first if anything is still sending.
|
|
179
|
+
|
|
180
|
+
**4. Pull the feedback into your agent:**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npx @githumbi/grabby-server pull --server https://feedback.your-site.com --token sk_…
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
This prints every open comment, grouped by file and labelled by author, and saves the screenshots to `./.grabby/screenshots/` where your agent can open them. The comments are then marked resolved, so the next pull shows only new feedback. Use `--keep` to leave them open or `--delete` to remove them.
|
|
187
|
+
|
|
188
|
+
## Connect your AI agent
|
|
189
|
+
|
|
190
|
+
- **Copy all**: paste into any chat or agent.
|
|
191
|
+
- **MCP**: run `npx grabby add mcp`. Your agent gets `grabby_list_comments`, `grabby_get_comment` (with the screenshot), `grabby_resolve` and `grabby_stats`. Locally it also collects comments: set `initGrabby({ server: 'http://localhost:3456' })`. Against a deployed collector, add `--server <url> --token <sk_…>` to the MCP command.
|
|
192
|
+
- **`pull`**: prints the same export as Copy all, for scripts and terminal agents.
|
|
193
|
+
|
|
194
|
+
## Framework support
|
|
195
|
+
|
|
196
|
+
| Stack | Component names | Source location | Setup |
|
|
197
|
+
|---|---|---|---|
|
|
198
|
+
| React (incl. 19), Preact, Solid | fiber (React), plugin stamps | exact `file:line:col` | build plugin |
|
|
199
|
+
| Vue 3 and 2 | component instance | exact line (plugin), or file | build plugin |
|
|
200
|
+
| Svelte 4 and 5 | from file | exact `file:line:col` | none |
|
|
201
|
+
| Angular 17+ | `ng` debug API | component file and line | builders |
|
|
202
|
+
| Anything else, plain HTML | `data-component="Name"` | unique CSS selector | none |
|
|
203
|
+
|
|
204
|
+
Grabby tries each adapter per element, so it copes with apps that mount late and pages that mix frameworks. You can write your own adapter; see `FrameworkAdapter` in the types.
|
|
205
|
+
|
|
206
|
+
## Configuration
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
initGrabby({
|
|
210
|
+
activationKey: 'Alt+G', // shortcut; 'toggle' or 'hold' via activationMode
|
|
211
|
+
detailLevel: 'standard', // default for Copy all: 'compact' | 'standard' | 'detailed'
|
|
212
|
+
copyOnComment: false, // also copy each comment as soon as it's saved
|
|
213
|
+
screenshots: true,
|
|
214
|
+
captureQueryParams: [], // query params worth keeping in the page route, e.g. ['tab']
|
|
215
|
+
persistHistory: true, // keep comments across reloads (localStorage)
|
|
216
|
+
|
|
217
|
+
mode: 'local', // 'live' for deployed sites (see above)
|
|
218
|
+
server: undefined, // collector URL
|
|
219
|
+
projectKey: undefined, // public project key (live)
|
|
220
|
+
identity: undefined, // 'ask' | 'anonymous' | 'none'; defaults: 'ask' live, 'none' local
|
|
221
|
+
webhookUrl: undefined, // also POST each comment as JSON (https or localhost only)
|
|
222
|
+
|
|
223
|
+
devOnly: true, // local mode is a no-op in production builds
|
|
224
|
+
styleNonce: undefined, // CSP nonce, for browsers without constructable stylesheets
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The API: `activate()`, `deactivate()`, `toggle()`, `show()`, `hide()`, `getComments()`, `exportComments({ level, ids })`, `deleteComment(id)`, `clearComments()`, `identify(user)`, `registerPlugin(plugin)`, `dispose()`. Plugins can hook `onComment`, `onScreenshot`, `onCopySuccess`, `transformCopyContent` and more.
|
|
229
|
+
|
|
230
|
+
Mark parts of your page:
|
|
231
|
+
|
|
232
|
+
- `data-grabby-ignore`: can't be selected and is left out of screenshots.
|
|
233
|
+
- `data-grabby-mask`: its text is replaced by `[masked]` and it's blurred in screenshots. Use it for account numbers, personal data, anything sensitive.
|
|
234
|
+
- `data-component="Checkout"`: names a component on plain-HTML pages.
|
|
235
|
+
|
|
236
|
+
## Security and privacy
|
|
237
|
+
|
|
238
|
+
- **Form values are never captured.** Neither are hidden inputs, inline event handlers or inline styles. Captured text is scrubbed of email addresses, long numbers (cards, accounts), JWTs and bearer tokens, and routes drop their query string and token-bearing hashes unless you allow a parameter.
|
|
239
|
+
- **The UI is isolated** in a shadow root and built without `innerHTML`, so page CSS can't break it and nothing a user types can run as code. It works under strict CSP (`style-src 'self'`) and Trusted Types.
|
|
240
|
+
- **The collector** stays on localhost unless started with `--public`, and then refuses to start without an admin token, a project key and a list of allowed sites. The public key can only add comments; reading, resolving and deleting need the admin token. Input is validated and size-capped, screenshots are checked by their bytes, only the browser that wrote a comment can attach its screenshot, and requests are rate-limited. Locally, it rejects DNS-rebinding attempts.
|
|
241
|
+
- **Comments are user input.** MCP results tell your agent to treat them as data, not instructions. Review what an agent does with feedback from people you don't know.
|
|
242
|
+
|
|
243
|
+
Report vulnerabilities privately; see [SECURITY.md](SECURITY.md).
|
|
244
|
+
|
|
245
|
+
## Packages
|
|
246
|
+
|
|
247
|
+
| | |
|
|
248
|
+
|---|---|
|
|
249
|
+
| [`@githumbi/grabby`](packages/grabby) | The toolbar, framework adapters, build plugin, CLI |
|
|
250
|
+
| [`@githumbi/grabby-server`](packages/server) | Self-hosted collector, MCP server, `pull` |
|
|
251
|
+
|
|
252
|
+
## Contributing
|
|
253
|
+
|
|
254
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). The [examples](examples) folder has a small app for each framework.
|
|
255
|
+
|
|
256
|
+
## Credits
|
|
257
|
+
|
|
258
|
+
Grabby began as a fork of angular-grab by Nate Richardson. The freeze mode follows techniques from [react-grab](https://github.com/aidenybai/react-grab), and screenshots use [modern-screenshot](https://github.com/qq15725/modern-screenshot).
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
MIT
|
package/builders.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"builders": {
|
|
3
|
+
"application": {
|
|
4
|
+
"implementation": "./dist/builder/builders/application/index",
|
|
5
|
+
"schema": "./dist/builder/builders/application/schema.json",
|
|
6
|
+
"description": "Build an Angular application with grabby source injection"
|
|
7
|
+
},
|
|
8
|
+
"dev-server": {
|
|
9
|
+
"implementation": "./dist/builder/builders/dev-server/index",
|
|
10
|
+
"schema": "./dist/builder/builders/dev-server/schema.json",
|
|
11
|
+
"description": "Serve an Angular application with grabby source injection"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare function resolveComponent(element: Element): {
|
|
4
|
+
name: string | null;
|
|
5
|
+
hostElement: Element | null;
|
|
6
|
+
stack: Array<{
|
|
7
|
+
name: string;
|
|
8
|
+
hostElement: Element | null;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
declare function resolveSource(element: Element): {
|
|
13
|
+
filePath: string | null;
|
|
14
|
+
line: number | null;
|
|
15
|
+
column: number | null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Teaches Grabby about one UI framework: how to name the component that owns
|
|
20
|
+
* an element, and where that element was written. Adapters only read what the
|
|
21
|
+
* framework already leaves on DOM nodes in development builds, so none of
|
|
22
|
+
* them import the framework itself.
|
|
23
|
+
*/
|
|
24
|
+
interface FrameworkAdapter {
|
|
25
|
+
/** Shown in exports, e.g. "React", "Vue". */
|
|
26
|
+
name: string;
|
|
27
|
+
resolveComponent: ComponentResolver;
|
|
28
|
+
resolveSource?: SourceResolver;
|
|
29
|
+
/** Drops framework-generated classes (scoping hashes and the like). */
|
|
30
|
+
cleanClasses?: (classes: string[]) => string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type ThemeMode = 'light';
|
|
34
|
+
/** What kind of UI the comment is about; decides which facts get captured. */
|
|
35
|
+
type TargetKind = 'action' | 'field' | 'text' | 'media' | 'container' | 'section';
|
|
36
|
+
/** How much context the export includes. */
|
|
37
|
+
type DetailLevel = 'compact' | 'standard' | 'detailed';
|
|
38
|
+
interface SourceLocation {
|
|
39
|
+
file: string;
|
|
40
|
+
line: number | null;
|
|
41
|
+
column: number | null;
|
|
42
|
+
}
|
|
43
|
+
interface StackFrame {
|
|
44
|
+
name: string;
|
|
45
|
+
file: string | null;
|
|
46
|
+
line: number | null;
|
|
47
|
+
}
|
|
48
|
+
/** The compact, serialisable description of the element a comment is about. */
|
|
49
|
+
interface GrabbyTarget {
|
|
50
|
+
kind: TargetKind;
|
|
51
|
+
tag: string;
|
|
52
|
+
component: string | null;
|
|
53
|
+
source: SourceLocation | null;
|
|
54
|
+
/** Up to 3 of the app's own component frames, innermost first. */
|
|
55
|
+
stack: StackFrame[];
|
|
56
|
+
/** Unique CSS selector. Exported only when there is no source location. */
|
|
57
|
+
selector: string;
|
|
58
|
+
/** Trimmed opening tag plus a text excerpt, at most ~300 characters. */
|
|
59
|
+
preview: string;
|
|
60
|
+
/** Kind-specific facts for the standard export, in display order. */
|
|
61
|
+
facts: Record<string, string>;
|
|
62
|
+
/** Extra facts only shown at the detailed level. */
|
|
63
|
+
extra: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
interface CommentAuthor {
|
|
66
|
+
name: string | null;
|
|
67
|
+
anonymous: boolean;
|
|
68
|
+
/** Stable random id per browser, so anonymous commenters stay distinguishable. */
|
|
69
|
+
sessionId: string;
|
|
70
|
+
/** The host app's own user id, when it called `identify()`. */
|
|
71
|
+
userId?: string;
|
|
72
|
+
}
|
|
73
|
+
interface PageInfo {
|
|
74
|
+
/** Pathname only; query strings are dropped unless allowlisted. */
|
|
75
|
+
route: string;
|
|
76
|
+
title: string;
|
|
77
|
+
viewport: [number, number];
|
|
78
|
+
}
|
|
79
|
+
interface ScreenshotRef {
|
|
80
|
+
/** Key of the image in this browser's IndexedDB. */
|
|
81
|
+
localId?: string;
|
|
82
|
+
/** Where a server stored it, once uploaded. */
|
|
83
|
+
url?: string;
|
|
84
|
+
width: number;
|
|
85
|
+
height: number;
|
|
86
|
+
}
|
|
87
|
+
interface GrabbyComment {
|
|
88
|
+
id: string;
|
|
89
|
+
createdAt: number;
|
|
90
|
+
updatedAt: number;
|
|
91
|
+
status: 'open' | 'resolved';
|
|
92
|
+
comment: string;
|
|
93
|
+
author: CommentAuthor;
|
|
94
|
+
page: PageInfo;
|
|
95
|
+
target: GrabbyTarget;
|
|
96
|
+
screenshot: ScreenshotRef | null;
|
|
97
|
+
framework: string;
|
|
98
|
+
/** Delivery to a Grabby server, when one is configured. Browser-only. */
|
|
99
|
+
sync?: 'pending' | 'sent' | 'failed';
|
|
100
|
+
}
|
|
101
|
+
interface GrabbyOptions {
|
|
102
|
+
/** Keyboard shortcut to activate. Default: "Alt+G" (Option+G on Mac) */
|
|
103
|
+
activationKey: string;
|
|
104
|
+
/** Whether activation requires hold or toggle. Default: 'toggle' */
|
|
105
|
+
activationMode: 'hold' | 'toggle';
|
|
106
|
+
/** Milliseconds to hold before activating in hold mode. Default: 0 */
|
|
107
|
+
keyHoldDuration: number;
|
|
108
|
+
/** Master on/off switch. Default: true */
|
|
109
|
+
enabled: boolean;
|
|
110
|
+
/** Allow activation while focused in input/textarea. Default: false */
|
|
111
|
+
enableInInputs: boolean;
|
|
112
|
+
/** Only activate in dev mode. Default: true */
|
|
113
|
+
devOnly: boolean;
|
|
114
|
+
/** Show the floating mini toolbar. Default: true */
|
|
115
|
+
showToolbar: boolean;
|
|
116
|
+
/** Theme mode for all UI. Default: 'light' */
|
|
117
|
+
themeMode: ThemeMode;
|
|
118
|
+
/**
|
|
119
|
+
* 'local' (default): for developers on their own machine; dev builds only.
|
|
120
|
+
* 'live': for collecting feedback on a deployed site. Grabby stays hidden
|
|
121
|
+
* until someone opens a feedback link (?grabby=<projectKey>), and works in
|
|
122
|
+
* production builds.
|
|
123
|
+
*/
|
|
124
|
+
mode: 'local' | 'live';
|
|
125
|
+
/**
|
|
126
|
+
* A grabby-server URL. Comments are saved in the browser and delivered
|
|
127
|
+
* there (with retries), where you pull them or your agent reads them over
|
|
128
|
+
* MCP. Locally: 'http://localhost:3456'.
|
|
129
|
+
*/
|
|
130
|
+
server?: string;
|
|
131
|
+
/** The project's public key from `grabby-server init`. Required for a public server. */
|
|
132
|
+
projectKey?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Who a comment is from. 'ask' prompts for a name (or anonymous) on the
|
|
135
|
+
* first comment; 'anonymous' never asks; 'none' skips identity entirely.
|
|
136
|
+
* Default: 'ask' in live mode, 'none' locally.
|
|
137
|
+
*/
|
|
138
|
+
identity?: 'ask' | 'anonymous' | 'none';
|
|
139
|
+
/** Also POST each comment as JSON to this URL (https, or http://localhost). */
|
|
140
|
+
webhookUrl?: string;
|
|
141
|
+
/** Persist comments across page refresh via localStorage. Default: true */
|
|
142
|
+
persistHistory: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Also copy each comment to the clipboard as soon as it's saved. Default:
|
|
145
|
+
* false: comments collect until you use Copy all.
|
|
146
|
+
*/
|
|
147
|
+
copyOnComment: boolean;
|
|
148
|
+
/** Default detail level for exports. Default: 'standard' */
|
|
149
|
+
detailLevel: DetailLevel;
|
|
150
|
+
/** Capture a screenshot of the commented element. Default: true */
|
|
151
|
+
screenshots: boolean;
|
|
152
|
+
/** Query parameters worth keeping in the recorded route, e.g. ['tab']. Default: [] */
|
|
153
|
+
captureQueryParams: string[];
|
|
154
|
+
/**
|
|
155
|
+
* Framework adapters to try, in order. Default: every built-in adapter
|
|
156
|
+
* (Angular, React, Vue, Svelte, then plain HTML), detected per element.
|
|
157
|
+
*/
|
|
158
|
+
adapters?: FrameworkAdapter[];
|
|
159
|
+
/**
|
|
160
|
+
* CSP nonce for Grabby's `<style>` elements. Only used in browsers without
|
|
161
|
+
* constructable stylesheets; elsewhere styles need no CSP allowance.
|
|
162
|
+
*/
|
|
163
|
+
styleNonce?: string;
|
|
164
|
+
}
|
|
165
|
+
interface PluginHooks {
|
|
166
|
+
onActivate?: () => void;
|
|
167
|
+
onDeactivate?: () => void;
|
|
168
|
+
onElementHover?: (element: Element) => void;
|
|
169
|
+
onElementSelect?: (element: Element) => void;
|
|
170
|
+
/**
|
|
171
|
+
* A comment was saved. Fires whether or not anything reached the clipboard,
|
|
172
|
+
* so use this to persist or forward comments.
|
|
173
|
+
*/
|
|
174
|
+
onComment?: (comment: GrabbyComment, element: Element | null) => void;
|
|
175
|
+
/** A saved comment gained its screenshot (it's captured asynchronously). */
|
|
176
|
+
onScreenshot?: (comment: GrabbyComment, image: Blob) => void;
|
|
177
|
+
onCopySuccess?: (text: string, comments: GrabbyComment[]) => void;
|
|
178
|
+
onCopyError?: (error: Error) => void;
|
|
179
|
+
/** Rewrite exported text before it reaches the clipboard. */
|
|
180
|
+
transformCopyContent?: (text: string, comments: GrabbyComment[]) => string;
|
|
181
|
+
}
|
|
182
|
+
interface Theme {
|
|
183
|
+
overlayBorderColor: string;
|
|
184
|
+
overlayBgColor: string;
|
|
185
|
+
labelBgColor: string;
|
|
186
|
+
labelTextColor: string;
|
|
187
|
+
toastBgColor: string;
|
|
188
|
+
toastTextColor: string;
|
|
189
|
+
toolbarBgColor: string;
|
|
190
|
+
toolbarTextColor: string;
|
|
191
|
+
toolbarAccentColor: string;
|
|
192
|
+
popoverBgColor: string;
|
|
193
|
+
popoverTextColor: string;
|
|
194
|
+
popoverBorderColor: string;
|
|
195
|
+
}
|
|
196
|
+
interface Plugin {
|
|
197
|
+
name: string;
|
|
198
|
+
hooks?: PluginHooks;
|
|
199
|
+
theme?: Partial<Theme>;
|
|
200
|
+
options?: Partial<GrabbyOptions>;
|
|
201
|
+
setup?: (api: GrabbyAPI) => PluginCleanup | void;
|
|
202
|
+
}
|
|
203
|
+
type PluginCleanup = () => void;
|
|
204
|
+
type ComponentResolver = (element: Element) => {
|
|
205
|
+
name: string | null;
|
|
206
|
+
hostElement: Element | null;
|
|
207
|
+
/**
|
|
208
|
+
* Owning components, innermost first. An entry can carry its own location
|
|
209
|
+
* when the framework knows it; otherwise it's resolved from `hostElement`.
|
|
210
|
+
*/
|
|
211
|
+
stack?: Array<{
|
|
212
|
+
name: string;
|
|
213
|
+
hostElement: Element | null;
|
|
214
|
+
filePath?: string | null;
|
|
215
|
+
line?: number | null;
|
|
216
|
+
}>;
|
|
217
|
+
} | null;
|
|
218
|
+
type SourceResolver = (element: Element) => {
|
|
219
|
+
filePath: string | null;
|
|
220
|
+
line: number | null;
|
|
221
|
+
column: number | null;
|
|
222
|
+
} | null;
|
|
223
|
+
interface GrabbyAPI {
|
|
224
|
+
activate(): void;
|
|
225
|
+
deactivate(): void;
|
|
226
|
+
toggle(): void;
|
|
227
|
+
isActive(): boolean;
|
|
228
|
+
setOptions(opts: Partial<GrabbyOptions>): void;
|
|
229
|
+
registerPlugin(plugin: Plugin): void;
|
|
230
|
+
unregisterPlugin(name: string): void;
|
|
231
|
+
setComponentResolver(resolver: ComponentResolver): void;
|
|
232
|
+
setSourceResolver(resolver: SourceResolver): void;
|
|
233
|
+
showToolbar(): void;
|
|
234
|
+
hideToolbar(): void;
|
|
235
|
+
setThemeMode(mode: ThemeMode): void;
|
|
236
|
+
/** Open comments, newest first. */
|
|
237
|
+
getComments(): GrabbyComment[];
|
|
238
|
+
/** Export text for the given (default: all) comments at a detail level. */
|
|
239
|
+
exportComments(options?: {
|
|
240
|
+
level?: DetailLevel;
|
|
241
|
+
ids?: string[];
|
|
242
|
+
}): string;
|
|
243
|
+
deleteComment(id: string): void;
|
|
244
|
+
clearComments(): void;
|
|
245
|
+
/**
|
|
246
|
+
* Tell Grabby who is signed in, so commenters aren't asked for a name.
|
|
247
|
+
* Pass null on sign-out.
|
|
248
|
+
*/
|
|
249
|
+
identify(user: {
|
|
250
|
+
id?: string;
|
|
251
|
+
name: string;
|
|
252
|
+
} | null): void;
|
|
253
|
+
/** Show Grabby. In live mode this starts a feedback session for this tab. */
|
|
254
|
+
show(): void;
|
|
255
|
+
/** Hide Grabby. In live mode this ends the feedback session. */
|
|
256
|
+
hide(): void;
|
|
257
|
+
dispose(): void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Names come from Angular's dev-mode `ng` debug API; locations from the
|
|
262
|
+
* component source map the Grabby builders inject at build time.
|
|
263
|
+
*/
|
|
264
|
+
declare const angularAdapter: FrameworkAdapter;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Initialize Grabby. The Angular adapter is one of the defaults, so this only
|
|
268
|
+
* adds a singleton on top of `init`. Idempotent: later calls return the same
|
|
269
|
+
* instance.
|
|
270
|
+
*/
|
|
271
|
+
declare function initGrabby(options?: Partial<GrabbyOptions>): GrabbyAPI;
|
|
272
|
+
declare function getGrabbyApi(): GrabbyAPI | null;
|
|
273
|
+
declare function registerGrabbyPlugin(plugin: Plugin): void;
|
|
274
|
+
declare function disposeGrabby(): void;
|
|
275
|
+
|
|
276
|
+
declare const GRABBY_API: InjectionToken<GrabbyAPI>;
|
|
277
|
+
declare function provideGrabby(options?: Partial<GrabbyOptions>): EnvironmentProviders;
|
|
278
|
+
|
|
279
|
+
export { GRABBY_API, angularAdapter, disposeGrabby, getGrabbyApi, initGrabby, provideGrabby, registerGrabbyPlugin, resolveComponent, resolveSource };
|