vite-plugin-specter 0.1.0 → 0.1.2
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 +116 -0
- package/dist/client.js +2 -1
- package/dist/index.cjs +3 -2
- package/dist/index.js +3 -2
- package/extension/content.js +2 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Specter
|
|
2
|
+
|
|
3
|
+
**Hover any element on your dev site. See its styles. Copy to AI.**
|
|
4
|
+
|
|
5
|
+
Specter is a Vite plugin that adds an element inspector overlay to your dev server. Toggle it on, hover any element to see its styles, component name, and spacing. Copy with one shortcut and paste into your AI assistant for one-shot edits. Specter is automatically stripped from production builds.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Your project must use **Vite** as its dev server
|
|
10
|
+
- Works with React, Vue, Svelte, or plain HTML served through Vite
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -D vite-plugin-specter
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then add to your `vite.config.ts`:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { specter } from 'vite-plugin-specter';
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
plugins: [specter()]
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Start your dev server and you're done. Specter is stripped from production builds automatically.
|
|
29
|
+
|
|
30
|
+
## How to use
|
|
31
|
+
|
|
32
|
+
### Toggle on/off
|
|
33
|
+
|
|
34
|
+
Press **Ctrl+Option+Z** to enter Specter mode. A small zap icon appears at the bottom-left. Press again (or Esc) to exit.
|
|
35
|
+
|
|
36
|
+
### Inspect an element
|
|
37
|
+
|
|
38
|
+
Once active, just **hover** any element. A tooltip shows:
|
|
39
|
+
|
|
40
|
+
- HTML tag + React/Vue component name + dimensions
|
|
41
|
+
- Text content (truncated)
|
|
42
|
+
- Font: family, weight, size, line-height
|
|
43
|
+
- Color (with hex) and background
|
|
44
|
+
- Padding, margin, border-radius (if non-zero)
|
|
45
|
+
- Display + gap + flex direction
|
|
46
|
+
|
|
47
|
+
### Copy to clipboard
|
|
48
|
+
|
|
49
|
+
Press **Cmd+C** while hovering. The element info is copied in an AI-optimized format. Paste it into Claude, Cursor, or any AI assistant and say what you want changed.
|
|
50
|
+
|
|
51
|
+
### Measure mode
|
|
52
|
+
|
|
53
|
+
Tap **Option** to switch to Measure mode. Hover any element to see distance measurements to its surrounding neighbors (like Figma's spacing view). Tap **Option** again to return to Properties mode.
|
|
54
|
+
|
|
55
|
+
### Pin an element
|
|
56
|
+
|
|
57
|
+
In Measure mode, press **M** while hovering to pin that element. Then hover any other element to measure the gap or inset between the two. Press **Cmd+C** to copy the measurement. Press **Esc** to clear the pin.
|
|
58
|
+
|
|
59
|
+
### Multi-select
|
|
60
|
+
|
|
61
|
+
Press **P** while hovering an element to pick it. Numbered badges appear on each picked element. Press **Cmd+C** to copy all selected elements at once. Press **Esc** to clear the selection.
|
|
62
|
+
|
|
63
|
+
## Shortcut reference
|
|
64
|
+
|
|
65
|
+
| Action | Shortcut |
|
|
66
|
+
|--------|----------|
|
|
67
|
+
| Toggle Specter | **Ctrl+Option+Z** |
|
|
68
|
+
| Inspect element | Hover (while active) |
|
|
69
|
+
| Copy properties | **Cmd+C** |
|
|
70
|
+
| Switch to Measure mode | **Option** (tap) |
|
|
71
|
+
| Pin element for measuring | **M** (in Measure mode) |
|
|
72
|
+
| Pick element (multi-select) | **P** (in Properties mode) |
|
|
73
|
+
| Clear pin / clear selection | **Esc** |
|
|
74
|
+
| Exit Specter | **Esc** (when nothing selected/pinned) |
|
|
75
|
+
|
|
76
|
+
## Workflow with AI assistants
|
|
77
|
+
|
|
78
|
+
1. Toggle Specter (Ctrl+Option+Z)
|
|
79
|
+
2. Hover the element you want to change
|
|
80
|
+
3. Press **Cmd+C** to copy
|
|
81
|
+
4. Paste into your AI assistant's chat
|
|
82
|
+
5. Say what you want: "make this blue", "increase spacing", "fix the font weight"
|
|
83
|
+
|
|
84
|
+
No more "which element?", no more "what's the current value?". One paste gives your assistant everything it needs.
|
|
85
|
+
|
|
86
|
+
## Configuration
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
specter() // Default shortcuts
|
|
90
|
+
specter({ shortcuts: { activate: 'ctrl+shift+i' } }) // Custom activate shortcut
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The `activate` shortcut accepts any combination of `ctrl`, `alt`, `shift`, `meta`/`cmd`, and a key. Default is `ctrl+alt+z`.
|
|
94
|
+
|
|
95
|
+
## Optional: `data-style` attribute
|
|
96
|
+
|
|
97
|
+
Tag elements with `data-style="keyName"` to show the style object key in the inspector:
|
|
98
|
+
|
|
99
|
+
```jsx
|
|
100
|
+
<h1 data-style="pageTitle">Welcome</h1>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Uninstall
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm uninstall vite-plugin-specter
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Then remove `specter()` from your `vite.config.ts` plugins array and delete the import line.
|
|
110
|
+
|
|
111
|
+
## Package info
|
|
112
|
+
|
|
113
|
+
- **GitHub:** https://github.com/setugk/vite-plugin-specter
|
|
114
|
+
- **npm:** https://www.npmjs.com/package/vite-plugin-specter
|
|
115
|
+
- **Author:** Setu Kathawate
|
|
116
|
+
- **License:** MIT
|
package/dist/client.js
CHANGED
|
@@ -616,7 +616,8 @@
|
|
|
616
616
|
if (needMeta !== e.metaKey) return false;
|
|
617
617
|
if (!key) return false;
|
|
618
618
|
const eKey = e.key.toLowerCase();
|
|
619
|
-
|
|
619
|
+
const eCode = e.code.toLowerCase();
|
|
620
|
+
return eKey === key || eCode === `key${key}` || (key === 'period' && (eKey === '.' || eCode === 'period'));
|
|
620
621
|
}
|
|
621
622
|
|
|
622
623
|
// ─── Mouse ────────────────────────────────────────────────────────────────
|
package/dist/index.cjs
CHANGED
|
@@ -646,7 +646,8 @@ function getClientScript(options) {
|
|
|
646
646
|
if (needMeta !== e.metaKey) return false;
|
|
647
647
|
if (!key) return false;
|
|
648
648
|
const eKey = e.key.toLowerCase();
|
|
649
|
-
|
|
649
|
+
const eCode = e.code.toLowerCase();
|
|
650
|
+
return eKey === key || eCode === \`key\${key}\` || (key === 'period' && (eKey === '.' || eCode === 'period'));
|
|
650
651
|
}
|
|
651
652
|
|
|
652
653
|
// \u2500\u2500\u2500 Mouse \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -772,7 +773,7 @@ function specter(options = {}) {
|
|
|
772
773
|
apply: "serve",
|
|
773
774
|
transformIndexHtml(html) {
|
|
774
775
|
const script = getClientScript(options);
|
|
775
|
-
return html.replace("</body>", `<script>
|
|
776
|
+
return html.replace("</body>", () => `<script>
|
|
776
777
|
${script}
|
|
777
778
|
</script>
|
|
778
779
|
</body>`);
|
package/dist/index.js
CHANGED
|
@@ -619,7 +619,8 @@ function getClientScript(options) {
|
|
|
619
619
|
if (needMeta !== e.metaKey) return false;
|
|
620
620
|
if (!key) return false;
|
|
621
621
|
const eKey = e.key.toLowerCase();
|
|
622
|
-
|
|
622
|
+
const eCode = e.code.toLowerCase();
|
|
623
|
+
return eKey === key || eCode === \`key\${key}\` || (key === 'period' && (eKey === '.' || eCode === 'period'));
|
|
623
624
|
}
|
|
624
625
|
|
|
625
626
|
// \u2500\u2500\u2500 Mouse \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -745,7 +746,7 @@ function specter(options = {}) {
|
|
|
745
746
|
apply: "serve",
|
|
746
747
|
transformIndexHtml(html) {
|
|
747
748
|
const script = getClientScript(options);
|
|
748
|
-
return html.replace("</body>", `<script>
|
|
749
|
+
return html.replace("</body>", () => `<script>
|
|
749
750
|
${script}
|
|
750
751
|
</script>
|
|
751
752
|
</body>`);
|
package/extension/content.js
CHANGED
|
@@ -616,7 +616,8 @@
|
|
|
616
616
|
if (needMeta !== e.metaKey) return false;
|
|
617
617
|
if (!key) return false;
|
|
618
618
|
const eKey = e.key.toLowerCase();
|
|
619
|
-
|
|
619
|
+
const eCode = e.code.toLowerCase();
|
|
620
|
+
return eKey === key || eCode === `key${key}` || (key === 'period' && (eKey === '.' || eCode === 'period'));
|
|
620
621
|
}
|
|
621
622
|
|
|
622
623
|
// ─── Mouse ────────────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-specter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Dev-only element inspector overlay for Vite projects. Hover any element to see its styles, component name, and spacing — then copy to clipboard for AI assistants.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|