pinpoints 0.1.4
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/LICENSE +22 -0
- package/README.md +187 -0
- package/out/browser/browserSessionManager.d.ts +19 -0
- package/out/browser/browserSessionManager.d.ts.map +1 -0
- package/out/browser/browserSessionManager.js +169 -0
- package/out/browser/browserSessionManager.js.map +1 -0
- package/out/cli/index.d.ts +3 -0
- package/out/cli/index.d.ts.map +1 -0
- package/out/cli/index.js +564 -0
- package/out/cli/index.js.map +1 -0
- package/out/core/pickerToolbar.d.ts +9 -0
- package/out/core/pickerToolbar.d.ts.map +1 -0
- package/out/core/pickerToolbar.js +475 -0
- package/out/core/pickerToolbar.js.map +1 -0
- package/out/export/contextFormatter.d.ts +9 -0
- package/out/export/contextFormatter.d.ts.map +1 -0
- package/out/export/contextFormatter.js +151 -0
- package/out/export/contextFormatter.js.map +1 -0
- package/out/extension.d.ts +4 -0
- package/out/extension.d.ts.map +1 -0
- package/out/extension.js +95 -0
- package/out/extension.js.map +1 -0
- package/out/extraction/domExtractor.d.ts +10 -0
- package/out/extraction/domExtractor.d.ts.map +1 -0
- package/out/extraction/domExtractor.js +72 -0
- package/out/extraction/domExtractor.js.map +1 -0
- package/out/extraction/layoutExtractor.d.ts +11 -0
- package/out/extraction/layoutExtractor.d.ts.map +1 -0
- package/out/extraction/layoutExtractor.js +107 -0
- package/out/extraction/layoutExtractor.js.map +1 -0
- package/out/extraction/redactor.d.ts +9 -0
- package/out/extraction/redactor.d.ts.map +1 -0
- package/out/extraction/redactor.js +78 -0
- package/out/extraction/redactor.js.map +1 -0
- package/out/extraction/screenshotExtractor.d.ts +7 -0
- package/out/extraction/screenshotExtractor.d.ts.map +1 -0
- package/out/extraction/screenshotExtractor.js +104 -0
- package/out/extraction/screenshotExtractor.js.map +1 -0
- package/out/extraction/selectorExtractor.d.ts +16 -0
- package/out/extraction/selectorExtractor.d.ts.map +1 -0
- package/out/extraction/selectorExtractor.js +172 -0
- package/out/extraction/selectorExtractor.js.map +1 -0
- package/out/extraction/styleExtractor.d.ts +10 -0
- package/out/extraction/styleExtractor.d.ts.map +1 -0
- package/out/extraction/styleExtractor.js +96 -0
- package/out/extraction/styleExtractor.js.map +1 -0
- package/out/picker/pickerController.d.ts +33 -0
- package/out/picker/pickerController.d.ts.map +1 -0
- package/out/picker/pickerController.js +979 -0
- package/out/picker/pickerController.js.map +1 -0
- package/out/schemas/index.d.ts +418 -0
- package/out/schemas/index.d.ts.map +1 -0
- package/out/schemas/index.js +128 -0
- package/out/schemas/index.js.map +1 -0
- package/out/source/sourceLocator.d.ts +7 -0
- package/out/source/sourceLocator.d.ts.map +1 -0
- package/out/source/sourceLocator.js +37 -0
- package/out/source/sourceLocator.js.map +1 -0
- package/out/source/sourceMapResolver.d.ts +17 -0
- package/out/source/sourceMapResolver.d.ts.map +1 -0
- package/out/source/sourceMapResolver.js +204 -0
- package/out/source/sourceMapResolver.js.map +1 -0
- package/out/source/workspaceGrep.d.ts +30 -0
- package/out/source/workspaceGrep.d.ts.map +1 -0
- package/out/source/workspaceGrep.js +237 -0
- package/out/source/workspaceGrep.js.map +1 -0
- package/out/testPaste.d.ts +1 -0
- package/out/testPaste.d.ts.map +1 -0
- package/out/testPaste.js +3 -0
- package/out/testPaste.js.map +1 -0
- package/out/ui/statusBarManager.d.ts +14 -0
- package/out/ui/statusBarManager.d.ts.map +1 -0
- package/out/ui/statusBarManager.js +89 -0
- package/out/ui/statusBarManager.js.map +1 -0
- package/package.json +132 -0
- package/resources/fonts/icons.css +19 -0
- package/resources/fonts/icons.html +69 -0
- package/resources/fonts/icons.json +3 -0
- package/resources/fonts/icons.ts +13 -0
- package/resources/fonts/icons.woff +0 -0
- package/resources/icon.png +0 -0
- package/resources/icons/pinpoint-logo.svg +4 -0
- package/resources/logo.svg +97 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.injectPickerToolbar = injectPickerToolbar;
|
|
4
|
+
async function injectPickerToolbar(page, options) {
|
|
5
|
+
const { logoSvg, initialMode, initialTarget, showTargets = true } = options;
|
|
6
|
+
await page.evaluate((args) => {
|
|
7
|
+
const { logoSvg, initialMode, initialTarget, showTargets } = args;
|
|
8
|
+
if (document.getElementById('pinpoint-module'))
|
|
9
|
+
return;
|
|
10
|
+
const btnBase = `
|
|
11
|
+
height: 36px;
|
|
12
|
+
padding: 0;
|
|
13
|
+
background: transparent;
|
|
14
|
+
border: none;
|
|
15
|
+
border-radius: 9999px;
|
|
16
|
+
color: rgba(255, 255, 255, 0.6);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
transition: color 0.2s ease;
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
position: relative;
|
|
23
|
+
z-index: 1;
|
|
24
|
+
width: 36px;
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
`;
|
|
27
|
+
// Create floating toolbar that doesn't affect page layout
|
|
28
|
+
const moduleContainer = document.createElement('div');
|
|
29
|
+
moduleContainer.id = 'pinpoint-module';
|
|
30
|
+
moduleContainer.style.cssText =
|
|
31
|
+
'position: absolute; top: 0; left: 0; width: 0; height: 0; pointer-events: none; overflow: visible; z-index: 2147483647;';
|
|
32
|
+
moduleContainer.innerHTML = `
|
|
33
|
+
<div id="pinpoint-tooltip" style="
|
|
34
|
+
position: fixed;
|
|
35
|
+
z-index: 9999999999;
|
|
36
|
+
background: rgba(0, 0, 0, 0.85);
|
|
37
|
+
color: #fff;
|
|
38
|
+
font-size: 11px;
|
|
39
|
+
font-weight: 500;
|
|
40
|
+
padding: 4px 10px;
|
|
41
|
+
border-radius: 6px;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
opacity: 0;
|
|
45
|
+
transition: opacity 0.15s ease;
|
|
46
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
47
|
+
"></div>
|
|
48
|
+
<div id="pinpoint-toolbar" style="
|
|
49
|
+
pointer-events: auto;
|
|
50
|
+
position: fixed;
|
|
51
|
+
bottom: 24px;
|
|
52
|
+
left: 50%;
|
|
53
|
+
transform: translateX(-50%);
|
|
54
|
+
z-index: 999999999;
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: row;
|
|
57
|
+
align-items: center;
|
|
58
|
+
gap: 2px;
|
|
59
|
+
padding: 6px 10px;
|
|
60
|
+
background: rgba(30, 30, 30, 0.92);
|
|
61
|
+
backdrop-filter: blur(16px);
|
|
62
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
63
|
+
border-radius: 9999px;
|
|
64
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
|
|
65
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
66
|
+
user-select: none;
|
|
67
|
+
transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), gap 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
68
|
+
">
|
|
69
|
+
<!-- Toggle button (always visible) -->
|
|
70
|
+
<button id="pinpoint-toggle" title="Capture mode active (click or Esc to interact)" style="
|
|
71
|
+
height: 36px;
|
|
72
|
+
width: 36px;
|
|
73
|
+
padding: 0;
|
|
74
|
+
background: rgba(14, 165, 233, 0.2);
|
|
75
|
+
border: none;
|
|
76
|
+
border-radius: 9999px;
|
|
77
|
+
color: #0ea5e9;
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
">
|
|
85
|
+
<span id="pinpoint-logo-slot" style="display:flex;align-items:center;justify-content:center;pointer-events:none;"></span>
|
|
86
|
+
</button>
|
|
87
|
+
|
|
88
|
+
<!-- Collapsible content -->
|
|
89
|
+
<div id="pinpoint-toolbar-content" style="
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: row;
|
|
92
|
+
align-items: center;
|
|
93
|
+
gap: 2px;
|
|
94
|
+
overflow: hidden;
|
|
95
|
+
transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
|
|
96
|
+
max-width: 600px;
|
|
97
|
+
opacity: 1;
|
|
98
|
+
">
|
|
99
|
+
|
|
100
|
+
<!-- Drag handle -->
|
|
101
|
+
<div id="pinpoint-drag" title="Drag to reposition" style="
|
|
102
|
+
width: 28px;
|
|
103
|
+
height: 36px;
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
cursor: grab;
|
|
108
|
+
color: rgba(255, 255, 255, 0.3);
|
|
109
|
+
flex-shrink: 0;
|
|
110
|
+
">
|
|
111
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
|
|
112
|
+
<circle cx="9" cy="6" r="1.5"/><circle cx="15" cy="6" r="1.5"/>
|
|
113
|
+
<circle cx="9" cy="12" r="1.5"/><circle cx="15" cy="12" r="1.5"/>
|
|
114
|
+
<circle cx="9" cy="18" r="1.5"/><circle cx="15" cy="18" r="1.5"/>
|
|
115
|
+
</svg>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<!-- Mode buttons -->
|
|
119
|
+
<div id="pinpoint-modes" style="
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: row;
|
|
122
|
+
align-items: center;
|
|
123
|
+
gap: 2px;
|
|
124
|
+
position: relative;
|
|
125
|
+
">
|
|
126
|
+
<div id="pinpoint-mode-slider" style="
|
|
127
|
+
position: absolute;
|
|
128
|
+
top: 0;
|
|
129
|
+
left: 0;
|
|
130
|
+
height: 100%;
|
|
131
|
+
background: rgba(255, 255, 255, 0.15);
|
|
132
|
+
border-radius: 9999px;
|
|
133
|
+
z-index: 0;
|
|
134
|
+
pointer-events: none;
|
|
135
|
+
width: 36px;
|
|
136
|
+
transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
137
|
+
"></div>
|
|
138
|
+
<button data-mode="pick" title="Quick Fix" style="${btnBase}">
|
|
139
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink:0;">
|
|
140
|
+
<circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/><circle cx="5" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>
|
|
141
|
+
</svg>
|
|
142
|
+
</button>
|
|
143
|
+
<button data-mode="full" title="Full" style="${btnBase}">
|
|
144
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink:0;">
|
|
145
|
+
<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="12" cy="12" r="3"/>
|
|
146
|
+
</svg>
|
|
147
|
+
</button>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<!-- Divider -->
|
|
151
|
+
<div style="width: 1px; height: 20px; background: rgba(255, 255, 255, 0.15); margin: 0 6px; flex-shrink: 0;"></div>
|
|
152
|
+
|
|
153
|
+
<!-- Target buttons -->
|
|
154
|
+
<div id="pinpoint-targets" style="
|
|
155
|
+
display: flex;
|
|
156
|
+
flex-direction: row;
|
|
157
|
+
align-items: center;
|
|
158
|
+
gap: 2px;
|
|
159
|
+
position: relative;
|
|
160
|
+
">
|
|
161
|
+
<div id="pinpoint-target-slider" style="
|
|
162
|
+
position: absolute;
|
|
163
|
+
top: 0;
|
|
164
|
+
left: 0;
|
|
165
|
+
height: 100%;
|
|
166
|
+
background: rgba(255, 255, 255, 0.15);
|
|
167
|
+
border-radius: 9999px;
|
|
168
|
+
z-index: 0;
|
|
169
|
+
pointer-events: none;
|
|
170
|
+
width: 36px;
|
|
171
|
+
transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
172
|
+
"></div>
|
|
173
|
+
<button data-target="claude-code" title="Claude Code" style="${btnBase}">
|
|
174
|
+
<svg width="18" height="18" viewBox="0 0 16 16" fill="currentColor" style="flex-shrink:0;">
|
|
175
|
+
<path d="m3.127 10.604 3.135-1.76.053-.153-.053-.085H6.11l-.525-.032-1.791-.048-1.554-.065-1.505-.08-.38-.081L0 7.832l.036-.234.32-.214.455.04 1.009.069 1.513.105 1.097.064 1.626.17h.259l.036-.105-.089-.065-.068-.064-1.566-1.062-1.695-1.121-.887-.646-.48-.327-.243-.306-.104-.67.435-.48.585.04.15.04.593.456 1.267.981 1.654 1.218.242.202.097-.068.012-.049-.109-.181-.9-1.626-.96-1.655-.428-.686-.113-.411a2 2 0 0 1-.068-.484l.496-.674L4.446 0l.662.089.279.242.411.94.666 1.48 1.033 2.014.302.597.162.553.06.17h.105v-.097l.085-1.134.157-1.392.154-1.792.052-.504.25-.605.497-.327.387.186.319.456-.045.294-.19 1.23-.37 1.93-.243 1.29h.142l.161-.16.654-.868 1.097-1.372.484-.545.565-.601.363-.287h.686l.505.751-.226.775-.707.895-.585.759-.839 1.13-.524.904.048.072.125-.012 1.897-.403 1.024-.186 1.223-.21.553.258.06.263-.218.536-1.307.323-1.533.307-2.284.54-.028.02.032.04 1.029.098.44.024h1.077l2.005.15.525.346.315.424-.053.323-.807.411-3.631-.863-.872-.218h-.12v.073l.726.71 1.331 1.202 1.667 1.55.084.383-.214.302-.226-.032-1.464-1.101-.565-.497-1.28-1.077h-.084v.113l.295.432 1.557 2.34.08.718-.112.234-.404.141-.444-.08-.911-1.28-.94-1.44-.759-1.291-.093.053-.448 4.821-.21.246-.484.186-.403-.307-.214-.496.214-.98.258-1.28.21-1.016.19-1.263.112-.42-.008-.028-.092.012-.953 1.307-1.448 1.957-1.146 1.227-.274.109-.477-.247.045-.44.266-.39 1.586-2.018.956-1.25.617-.723-.004-.105h-.036l-4.212 2.736-.75.096-.324-.302.04-.496.154-.162 1.267-.871z"/>
|
|
176
|
+
</svg>
|
|
177
|
+
</button>
|
|
178
|
+
<button data-target="copilot-chat" title="Copilot Chat" style="${btnBase}">
|
|
179
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink:0;">
|
|
180
|
+
<path d="M4 18v-5.5c0 -.667 .167 -1.333 .5 -2"/>
|
|
181
|
+
<path d="M12 7.5c0 -1 -.01 -4.07 -4 -3.5c-3.5 .5 -4 2.5 -4 3.5c0 1.5 0 4 3 4c4 0 5 -2.5 5 -4"/>
|
|
182
|
+
<path d="M4 12c-1.333 .667 -2 1.333 -2 2c0 1 0 3 1.5 4c3 2 6.5 3 8.5 3s5.499 -1 8.5 -3c1.5 -1 1.5 -3 1.5 -4c0 -.667 -.667 -1.333 -2 -2"/>
|
|
183
|
+
<path d="M20 18v-5.5c0 -.667 -.167 -1.333 -.5 -2"/>
|
|
184
|
+
<path d="M12 7.5l0 -.297l.01 -.269l.027 -.298l.013 -.105l.033 -.215c.014 -.073 .029 -.146 .046 -.22l.06 -.223c.336 -1.118 1.262 -2.237 3.808 -1.873c2.838 .405 3.703 1.797 3.93 2.842l.036 .204c0 .033 .01 .066 .013 .098l.016 .185l0 .171l0 .49l-.015 .394l-.02 .271c-.122 1.366 -.655 2.845 -2.962 2.845c-3.256 0 -4.524 -1.656 -4.883 -3.081l-.053 -.242a3.865 3.865 0 0 1 -.036 -.235l-.021 -.227a3.518 3.518 0 0 1 -.007 -.215l.005 0"/>
|
|
185
|
+
<path d="M10 15v2"/><path d="M14 15v2"/>
|
|
186
|
+
</svg>
|
|
187
|
+
</button>
|
|
188
|
+
<button data-target="clipboard" title="Clipboard" style="${btnBase}">
|
|
189
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink:0;">
|
|
190
|
+
<rect x="8" y="2" width="8" height="4" rx="1"/><path d="M16 4h2a2 2 0 012 2v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2h2"/>
|
|
191
|
+
</svg>
|
|
192
|
+
</button>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
`;
|
|
197
|
+
document.body.appendChild(moduleContainer);
|
|
198
|
+
if (!showTargets) {
|
|
199
|
+
const targetGroup = document.getElementById('pinpoint-targets');
|
|
200
|
+
if (targetGroup) {
|
|
201
|
+
const maybeDivider = targetGroup.previousElementSibling;
|
|
202
|
+
if (maybeDivider && maybeDivider.tagName.toLowerCase() === 'div') {
|
|
203
|
+
maybeDivider.remove();
|
|
204
|
+
}
|
|
205
|
+
targetGroup.remove();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Inject logo SVG from file and size it to fit the button
|
|
209
|
+
const logoSlot = document.getElementById('pinpoint-logo-slot');
|
|
210
|
+
logoSlot.innerHTML = logoSvg;
|
|
211
|
+
const svgEl = logoSlot.querySelector('svg');
|
|
212
|
+
if (svgEl) {
|
|
213
|
+
svgEl.setAttribute('width', '22');
|
|
214
|
+
svgEl.setAttribute('height', '22');
|
|
215
|
+
svgEl.style.flexShrink = '0';
|
|
216
|
+
svgEl.style.pointerEvents = 'none';
|
|
217
|
+
const paths = svgEl.querySelectorAll('path');
|
|
218
|
+
paths.forEach((p, i) => {
|
|
219
|
+
if (i === 0) {
|
|
220
|
+
// Outer pin silhouette — fills with currentColor (mode-driven)
|
|
221
|
+
p.setAttribute('fill', 'currentColor');
|
|
222
|
+
p.removeAttribute('stroke');
|
|
223
|
+
p.removeAttribute('stroke-width');
|
|
224
|
+
p.removeAttribute('stroke-linejoin');
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// Inner details — dark cutout so they read against the colored fill
|
|
228
|
+
const cutout = 'rgba(20,20,20,0.92)';
|
|
229
|
+
if (p.getAttribute('fill') === 'none') {
|
|
230
|
+
p.setAttribute('stroke', cutout);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
p.setAttribute('fill', cutout);
|
|
234
|
+
p.removeAttribute('stroke');
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
const toolbar = document.getElementById('pinpoint-toolbar');
|
|
240
|
+
const modes = document.getElementById('pinpoint-modes');
|
|
241
|
+
const targets = document.getElementById('pinpoint-targets');
|
|
242
|
+
const modeSlider = document.getElementById('pinpoint-mode-slider');
|
|
243
|
+
const targetSlider = document.getElementById('pinpoint-target-slider');
|
|
244
|
+
const tooltip = document.getElementById('pinpoint-tooltip');
|
|
245
|
+
// Slider update helper — sets position; CSS transition handles the animation
|
|
246
|
+
function updateSlider(slider, activeBtn) {
|
|
247
|
+
slider.style.left = activeBtn.offsetLeft + 'px';
|
|
248
|
+
slider.style.width = activeBtn.offsetWidth + 'px';
|
|
249
|
+
}
|
|
250
|
+
// Tooltip helper
|
|
251
|
+
function showTooltip(btn, text) {
|
|
252
|
+
tooltip.textContent = text;
|
|
253
|
+
tooltip.style.opacity = '1';
|
|
254
|
+
const btnRect = btn.getBoundingClientRect();
|
|
255
|
+
const tipWidth = tooltip.offsetWidth;
|
|
256
|
+
tooltip.style.left = btnRect.left + btnRect.width / 2 - tipWidth / 2 + 'px';
|
|
257
|
+
tooltip.style.top = btnRect.top - 32 + 'px';
|
|
258
|
+
}
|
|
259
|
+
function hideTooltip() {
|
|
260
|
+
tooltip.style.opacity = '0';
|
|
261
|
+
}
|
|
262
|
+
// Shared state
|
|
263
|
+
let lastEl = null;
|
|
264
|
+
// Interact/Capture toggle
|
|
265
|
+
let isInteractMode = false;
|
|
266
|
+
const toggleBtn = document.getElementById('pinpoint-toggle');
|
|
267
|
+
const toolbarContent = document.getElementById('pinpoint-toolbar-content');
|
|
268
|
+
const shortcutLabel = 'Esc';
|
|
269
|
+
function setInteractMode(interact) {
|
|
270
|
+
isInteractMode = interact;
|
|
271
|
+
if (interact) {
|
|
272
|
+
// Collapsed: hide content, compact circle
|
|
273
|
+
toolbarContent.style.maxWidth = '0';
|
|
274
|
+
toolbarContent.style.opacity = '0';
|
|
275
|
+
toolbar.style.padding = '6px';
|
|
276
|
+
toolbar.style.gap = '0';
|
|
277
|
+
// Collapsed: main logo color
|
|
278
|
+
toggleBtn.style.background = '#ABFF06';
|
|
279
|
+
// Always black icon
|
|
280
|
+
toggleBtn.style.color = '#000000';
|
|
281
|
+
// Clear any hover highlight
|
|
282
|
+
if (lastEl) {
|
|
283
|
+
lastEl.style.outline = '';
|
|
284
|
+
lastEl = null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
// Expanded: show content, restore padding
|
|
289
|
+
toolbarContent.style.maxWidth = '600px';
|
|
290
|
+
toolbarContent.style.opacity = '1';
|
|
291
|
+
toolbar.style.padding = '6px 10px';
|
|
292
|
+
toolbar.style.gap = '2px';
|
|
293
|
+
// Expanded: use main logo color
|
|
294
|
+
toggleBtn.style.background = '#ABFF06';
|
|
295
|
+
// Always black icon
|
|
296
|
+
toggleBtn.style.color = '#000000';
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// Apply initial visual state
|
|
300
|
+
setInteractMode(isInteractMode);
|
|
301
|
+
toggleBtn.addEventListener('click', (e) => {
|
|
302
|
+
e.stopPropagation();
|
|
303
|
+
setInteractMode(!isInteractMode);
|
|
304
|
+
});
|
|
305
|
+
toggleBtn.addEventListener('mouseenter', () => {
|
|
306
|
+
const label = isInteractMode
|
|
307
|
+
? `Switch to Capture (${shortcutLabel})`
|
|
308
|
+
: `Switch to Interact (${shortcutLabel})`;
|
|
309
|
+
showTooltip(toggleBtn, label);
|
|
310
|
+
});
|
|
311
|
+
toggleBtn.addEventListener('mouseleave', () => {
|
|
312
|
+
hideTooltip();
|
|
313
|
+
});
|
|
314
|
+
document.addEventListener('keydown', (e) => {
|
|
315
|
+
const ke = e;
|
|
316
|
+
if (ke.key === 'Escape') {
|
|
317
|
+
ke.preventDefault();
|
|
318
|
+
ke.stopPropagation();
|
|
319
|
+
setInteractMode(!isInteractMode);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
// Drag logic
|
|
323
|
+
const dragHandle = document.getElementById('pinpoint-drag');
|
|
324
|
+
let isDragging = false;
|
|
325
|
+
let dragOffsetX = 0;
|
|
326
|
+
let dragOffsetY = 0;
|
|
327
|
+
dragHandle.addEventListener('mousedown', (e) => {
|
|
328
|
+
const me = e;
|
|
329
|
+
isDragging = true;
|
|
330
|
+
dragHandle.style.cursor = 'grabbing';
|
|
331
|
+
const rect = toolbar.getBoundingClientRect();
|
|
332
|
+
dragOffsetX = me.clientX - rect.left;
|
|
333
|
+
dragOffsetY = me.clientY - rect.top;
|
|
334
|
+
toolbar.style.left = rect.left + 'px';
|
|
335
|
+
toolbar.style.bottom = 'auto';
|
|
336
|
+
toolbar.style.top = rect.top + 'px';
|
|
337
|
+
toolbar.style.transform = 'none';
|
|
338
|
+
me.preventDefault();
|
|
339
|
+
me.stopPropagation();
|
|
340
|
+
});
|
|
341
|
+
document.addEventListener('mousemove', (e) => {
|
|
342
|
+
if (!isDragging)
|
|
343
|
+
return;
|
|
344
|
+
const me = e;
|
|
345
|
+
let newX = me.clientX - dragOffsetX;
|
|
346
|
+
let newY = me.clientY - dragOffsetY;
|
|
347
|
+
const rect = toolbar.getBoundingClientRect();
|
|
348
|
+
newX = Math.max(0, Math.min(window.innerWidth - rect.width, newX));
|
|
349
|
+
newY = Math.max(0, Math.min(window.innerHeight - rect.height, newY));
|
|
350
|
+
toolbar.style.left = newX + 'px';
|
|
351
|
+
toolbar.style.top = newY + 'px';
|
|
352
|
+
me.preventDefault();
|
|
353
|
+
me.stopPropagation();
|
|
354
|
+
});
|
|
355
|
+
document.addEventListener('mouseup', (e) => {
|
|
356
|
+
if (isDragging) {
|
|
357
|
+
isDragging = false;
|
|
358
|
+
dragHandle.style.cursor = 'grab';
|
|
359
|
+
e.preventDefault();
|
|
360
|
+
e.stopPropagation();
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
// Mode buttons
|
|
364
|
+
window.pinPointMode = initialMode || 'pick';
|
|
365
|
+
const modeButtons = modes.querySelectorAll('button');
|
|
366
|
+
let activeModeBtn = Array.from(modeButtons).find((btn) => btn.getAttribute('data-mode') === window.pinPointMode) || modeButtons[0];
|
|
367
|
+
// Initialize active mode button
|
|
368
|
+
activeModeBtn.style.color = '#ffffff';
|
|
369
|
+
updateSlider(modeSlider, activeModeBtn);
|
|
370
|
+
modeButtons.forEach((btn) => {
|
|
371
|
+
btn.addEventListener('click', (e) => {
|
|
372
|
+
e.stopPropagation();
|
|
373
|
+
const mode = btn.getAttribute('data-mode');
|
|
374
|
+
window.pinPointMode = mode;
|
|
375
|
+
console.log('PINPOINT_MODE_CHANGED:', mode);
|
|
376
|
+
if (activeModeBtn !== btn) {
|
|
377
|
+
activeModeBtn.style.color = 'rgba(255, 255, 255, 0.6)';
|
|
378
|
+
activeModeBtn = btn;
|
|
379
|
+
activeModeBtn.style.color = '#ffffff';
|
|
380
|
+
updateSlider(modeSlider, activeModeBtn);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
btn.addEventListener('mouseenter', () => {
|
|
384
|
+
if (btn !== activeModeBtn) {
|
|
385
|
+
btn.style.color = 'rgba(255, 255, 255, 0.9)';
|
|
386
|
+
showTooltip(btn, btn.getAttribute('title') || '');
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
btn.addEventListener('mouseleave', () => {
|
|
390
|
+
if (btn !== activeModeBtn) {
|
|
391
|
+
btn.style.color = 'rgba(255, 255, 255, 0.6)';
|
|
392
|
+
}
|
|
393
|
+
hideTooltip();
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
if (showTargets && targets && targetSlider) {
|
|
397
|
+
// Target buttons
|
|
398
|
+
const targetButtons = targets.querySelectorAll('button');
|
|
399
|
+
let activeTargetBtn = Array.from(targetButtons).find((btn) => btn.getAttribute('data-target') === initialTarget) ||
|
|
400
|
+
targetButtons[0];
|
|
401
|
+
// Initialize active target button
|
|
402
|
+
activeTargetBtn.style.color = '#ffffff';
|
|
403
|
+
updateSlider(targetSlider, activeTargetBtn);
|
|
404
|
+
targetButtons.forEach((btn) => {
|
|
405
|
+
btn.addEventListener('click', (e) => {
|
|
406
|
+
e.stopPropagation();
|
|
407
|
+
const target = btn.getAttribute('data-target');
|
|
408
|
+
console.log('PINPOINT_TARGET_CHANGED:', target);
|
|
409
|
+
if (activeTargetBtn !== btn) {
|
|
410
|
+
activeTargetBtn.style.color = 'rgba(255, 255, 255, 0.6)';
|
|
411
|
+
activeTargetBtn = btn;
|
|
412
|
+
activeTargetBtn.style.color = '#ffffff';
|
|
413
|
+
updateSlider(targetSlider, activeTargetBtn);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
btn.addEventListener('mouseenter', () => {
|
|
417
|
+
if (btn !== activeTargetBtn) {
|
|
418
|
+
btn.style.color = 'rgba(255, 255, 255, 0.9)';
|
|
419
|
+
showTooltip(btn, btn.getAttribute('title') || '');
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
btn.addEventListener('mouseleave', () => {
|
|
423
|
+
if (btn !== activeTargetBtn) {
|
|
424
|
+
btn.style.color = 'rgba(255, 255, 255, 0.6)';
|
|
425
|
+
}
|
|
426
|
+
hideTooltip();
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
// Hover highlight + click handler
|
|
431
|
+
document.addEventListener('mousemove', (e) => {
|
|
432
|
+
if (isDragging)
|
|
433
|
+
return;
|
|
434
|
+
if (isInteractMode)
|
|
435
|
+
return;
|
|
436
|
+
// Use elementFromPoint instead of e.target for more reliable hit testing,
|
|
437
|
+
// especially with complex layouts or overlays
|
|
438
|
+
const target = document.elementFromPoint(e.clientX, e.clientY);
|
|
439
|
+
if (!target)
|
|
440
|
+
return;
|
|
441
|
+
const el = target;
|
|
442
|
+
// Skip highlighting the module itself
|
|
443
|
+
if (el.closest('#pinpoint-module'))
|
|
444
|
+
return;
|
|
445
|
+
if (lastEl && lastEl !== el && lastEl !== window.__pinpoint_clicked) {
|
|
446
|
+
lastEl.style.outline = '';
|
|
447
|
+
}
|
|
448
|
+
el.style.outline = '3px solid #0ea5e9';
|
|
449
|
+
el.style.outlineOffset = '2px';
|
|
450
|
+
lastEl = el;
|
|
451
|
+
}, true);
|
|
452
|
+
document.addEventListener('click', (e) => {
|
|
453
|
+
if (isDragging)
|
|
454
|
+
return;
|
|
455
|
+
if (isInteractMode)
|
|
456
|
+
return;
|
|
457
|
+
const target = document.elementFromPoint(e.clientX, e.clientY);
|
|
458
|
+
if (!target)
|
|
459
|
+
return;
|
|
460
|
+
const el = target;
|
|
461
|
+
// Don't capture if clicking the module
|
|
462
|
+
if (el.closest('#pinpoint-module'))
|
|
463
|
+
return;
|
|
464
|
+
e.preventDefault();
|
|
465
|
+
e.stopPropagation();
|
|
466
|
+
window.__pinpoint_clicked = el;
|
|
467
|
+
console.log('PINPOINT_SELECTED:', JSON.stringify({
|
|
468
|
+
tag: el.tagName,
|
|
469
|
+
class: el.className,
|
|
470
|
+
id: el.id,
|
|
471
|
+
}));
|
|
472
|
+
}, true);
|
|
473
|
+
}, { logoSvg, initialMode, initialTarget, showTargets });
|
|
474
|
+
}
|
|
475
|
+
//# sourceMappingURL=pickerToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickerToolbar.js","sourceRoot":"","sources":["../../src/core/pickerToolbar.ts"],"names":[],"mappings":";;AASA,kDAigBC;AAjgBM,KAAK,UAAU,mBAAmB,CACvC,IAAoB,EACpB,OAA6B;IAE7B,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAE5E,MAAM,IAAI,CAAC,QAAQ,CAAC,CA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,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC;gBAAE,OAAO;YAE3C,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,CAAC,CAAC,eAAe,EAAE,CAAC;YACnB,MAAc,CAAC,kBAAkB,GAAG,EAAE,CAAC;YACxC,OAAO,CAAC,GAAG,CACT,oBAAoB,EACpB,IAAI,CAAC,SAAS,CAAC;gBACb,GAAG,EAAE,EAAE,CAAC,OAAO;gBACf,KAAK,EAAE,EAAE,CAAC,SAAS;gBACnB,EAAE,EAAE,EAAE,CAAC,EAAE;aACV,CAAC,CACH,CAAC;QACJ,CAAC,EACD,IAAI,CACL,CAAC;IACJ,CAAC,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MaxContext, CaptureMode } from '../schemas';
|
|
2
|
+
export declare class ContextFormatter {
|
|
3
|
+
formatForChat(captures: MaxContext[], mode: CaptureMode, workspaceRoot: string): string;
|
|
4
|
+
private formatSingleElement;
|
|
5
|
+
private formatMultipleElements;
|
|
6
|
+
private extractComponentName;
|
|
7
|
+
private escapeMarkdown;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=contextFormatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextFormatter.d.ts","sourceRoot":"","sources":["../../src/export/contextFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAErD,qBAAa,gBAAgB;IAC3B,aAAa,CACX,QAAQ,EAAE,UAAU,EAAE,EACtB,IAAI,EAAE,WAAW,EACjB,aAAa,EAAE,MAAM,GACpB,MAAM;IAQT,OAAO,CAAC,mBAAmB;IAuE3B,OAAO,CAAC,sBAAsB;IAwC9B,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,cAAc;CASvB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ContextFormatter = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
class ContextFormatter {
|
|
39
|
+
formatForChat(captures, mode, workspaceRoot) {
|
|
40
|
+
if (captures.length === 1) {
|
|
41
|
+
return this.formatSingleElement(captures[0], mode, workspaceRoot);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return this.formatMultipleElements(captures, mode, workspaceRoot);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
formatSingleElement(context, mode, workspaceRoot) {
|
|
48
|
+
let text = `## UI Element Context\n\n`;
|
|
49
|
+
// Selector
|
|
50
|
+
text += `### Selected Element\n`;
|
|
51
|
+
text += `**Selector:** \`${context.selectors.primary.selector}\`\n`;
|
|
52
|
+
if (context.identity.role) {
|
|
53
|
+
text += `**Role:** ${context.identity.role}\n`;
|
|
54
|
+
}
|
|
55
|
+
if (context.identity.text) {
|
|
56
|
+
text += `**Text:** ${this.escapeMarkdown(context.identity.text)}\n`;
|
|
57
|
+
}
|
|
58
|
+
text += `\n`;
|
|
59
|
+
// Component name
|
|
60
|
+
const componentName = context.reactComponent
|
|
61
|
+
|| (context.sourceLocation && this.extractComponentName(context.sourceLocation.filePath));
|
|
62
|
+
if (componentName) {
|
|
63
|
+
text += `**Component:** \`${componentName}\`\n`;
|
|
64
|
+
}
|
|
65
|
+
// DOM
|
|
66
|
+
text += `### Element Structure\n`;
|
|
67
|
+
text += `\`\`\`html\n`;
|
|
68
|
+
text += `${context.dom.element.html}\n`;
|
|
69
|
+
text += `\`\`\`\n\n`;
|
|
70
|
+
// Layout
|
|
71
|
+
text += `### Layout\n`;
|
|
72
|
+
text += `- **Position:** top: ${context.layout.bbox.top}px, left: ${context.layout.bbox.left}px\n`;
|
|
73
|
+
text += `- **Size:** ${context.layout.bbox.width}px × ${context.layout.bbox.height}px\n`;
|
|
74
|
+
text += `- **Viewport:** ${context.layout.viewport?.width}px × ${context.layout.viewport?.height}px\n`;
|
|
75
|
+
text += `\n`;
|
|
76
|
+
// Styles
|
|
77
|
+
if (context.styles.diff && Object.keys(context.styles.diff).length > 0) {
|
|
78
|
+
text += `### Key Styles\n`;
|
|
79
|
+
Object.entries(context.styles.diff).forEach(([prop, value]) => {
|
|
80
|
+
text += `- **${prop}:** \`${value}\`\n`;
|
|
81
|
+
});
|
|
82
|
+
text += `\n`;
|
|
83
|
+
}
|
|
84
|
+
// Source file if detected
|
|
85
|
+
if (context.sourceLocation) {
|
|
86
|
+
const relPath = path.relative(workspaceRoot, context.sourceLocation.filePath);
|
|
87
|
+
text += `### Source File\n`;
|
|
88
|
+
text += `**File:** \`${relPath}\``;
|
|
89
|
+
if (context.sourceLocation.line) {
|
|
90
|
+
text += ` (line ${context.sourceLocation.line})`;
|
|
91
|
+
}
|
|
92
|
+
text += `\n`;
|
|
93
|
+
}
|
|
94
|
+
// Screenshot only in full mode
|
|
95
|
+
if (mode === 'full' && context.visual?.path) {
|
|
96
|
+
const relPath = path.relative(workspaceRoot, context.visual.path);
|
|
97
|
+
text += `### Screenshot\n`;
|
|
98
|
+
text += `@${relPath}\n\n`;
|
|
99
|
+
}
|
|
100
|
+
// Footer for user to add instruction
|
|
101
|
+
text += `---\n`;
|
|
102
|
+
return text;
|
|
103
|
+
}
|
|
104
|
+
formatMultipleElements(contexts, mode, workspaceRoot) {
|
|
105
|
+
let text = `## UI Element Comparison\n\n`;
|
|
106
|
+
text += `**Elements:** ${contexts.length}\n\n`;
|
|
107
|
+
contexts.forEach((context, index) => {
|
|
108
|
+
text += `### Element ${index + 1}\n`;
|
|
109
|
+
text += `**Selector:** \`${context.selectors.primary.selector}\`\n`;
|
|
110
|
+
if (context.identity.text) {
|
|
111
|
+
text += `**Text:** ${this.escapeMarkdown(context.identity.text)}\n`;
|
|
112
|
+
}
|
|
113
|
+
// Component name
|
|
114
|
+
const componentName = context.reactComponent
|
|
115
|
+
|| (context.sourceLocation && this.extractComponentName(context.sourceLocation.filePath));
|
|
116
|
+
if (componentName) {
|
|
117
|
+
text += `**Component:** \`${componentName}\`\n`;
|
|
118
|
+
}
|
|
119
|
+
text += `**Structure:**\n`;
|
|
120
|
+
text += `\`\`\`html\n`;
|
|
121
|
+
text += `${context.dom.element.html}\n`;
|
|
122
|
+
text += `\`\`\`\n\n`;
|
|
123
|
+
// Screenshot only in full mode
|
|
124
|
+
if (mode === 'full' && context.visual?.path) {
|
|
125
|
+
const relPath = path.relative(workspaceRoot, context.visual.path);
|
|
126
|
+
text += `**Screenshot:** @${relPath}\n\n`;
|
|
127
|
+
}
|
|
128
|
+
text += `---\n\n`;
|
|
129
|
+
});
|
|
130
|
+
return text;
|
|
131
|
+
}
|
|
132
|
+
extractComponentName(filePath) {
|
|
133
|
+
const basename = path.basename(filePath, path.extname(filePath));
|
|
134
|
+
// Skip index files - not useful as component names
|
|
135
|
+
if (basename === 'index')
|
|
136
|
+
return undefined;
|
|
137
|
+
// Return PascalCase names (likely React components) or any meaningful name
|
|
138
|
+
return basename;
|
|
139
|
+
}
|
|
140
|
+
escapeMarkdown(text) {
|
|
141
|
+
return text
|
|
142
|
+
.replace(/\\/g, '\\\\')
|
|
143
|
+
.replace(/`/g, '\\`')
|
|
144
|
+
.replace(/\*/g, '\\*')
|
|
145
|
+
.replace(/_/g, '\\_')
|
|
146
|
+
.replace(/\[/g, '\\[')
|
|
147
|
+
.replace(/\]/g, '\\]');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.ContextFormatter = ContextFormatter;
|
|
151
|
+
//# sourceMappingURL=contextFormatter.js.map
|