openfox 1.6.64 → 1.6.66
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/dist/{auto-compaction-XYMFQXXX.js → auto-compaction-ASDCDWKT.js} +3 -2
- package/dist/{chat-handler-24P6R3SB.js → chat-handler-647QWEHP.js} +5 -4
- package/dist/{chunk-YF3ERP7E.js → chunk-7XO4OW2P.js} +2 -2
- package/dist/{chunk-JY7BGPTB.js → chunk-GFE5Y2UE.js} +26 -9
- package/dist/chunk-NRUMWHLX.js +294 -0
- package/dist/{chunk-OXQGLKLE.js → chunk-PCCYGUYA.js} +2 -2
- package/dist/{chunk-7TMH3MPE.js → chunk-PU4AOT3E.js} +7 -280
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/inspect-proxy-M5222JOC.js +10 -0
- package/dist/{orchestrator-TEL2CUIT.js → orchestrator-UEDPSWG6.js} +4 -3
- package/dist/package.json +1 -1
- package/dist/{processor-GSMNLIRM.js → processor-TSSCNWED.js} +2 -2
- package/dist/{serve-55UYT2JO.js → serve-QTGMR7OM.js} +5 -4
- package/dist/server/index.js +4 -3
- package/dist/server/public/__inspect__.js +9 -11
- package/dist/{tools-TSGPRFT2.js → tools-AQEL6ZJG.js} +3 -2
- package/dist/web/__inspect__.js +269 -0
- package/dist/web/assets/{index-BcXvYLYn.js → index-KbZgYzd8.js} +2 -2
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
window.__foxInspectMode = false;
|
|
5
|
+
window.__foxSessionId = null;
|
|
6
|
+
window.__foxSessionTitle = null;
|
|
7
|
+
window.__foxInspectEnabled = true;
|
|
8
|
+
window.__foxSentPending = false;
|
|
9
|
+
window.__foxPopupOpen = false;
|
|
10
|
+
window.__foxHighlightedEl = null;
|
|
11
|
+
|
|
12
|
+
var overlayStyle = document.createElement('style');
|
|
13
|
+
overlayStyle.textContent = [
|
|
14
|
+
'#__fox-overlay{position:fixed;bottom:16px;right:16px;z-index:2147483647;font-family:system-ui,sans-serif;font-size:13px;pointer-events:none}',
|
|
15
|
+
'#__fox-widget{background:#1e1e1e;color:#e0e0e0;padding:8px 12px;border-radius:8px;box-shadow:0 4px 20px rgba(0,0,0,.4);display:flex;align-items:center;gap:10px;pointer-events:auto}',
|
|
16
|
+
'#__fox-widget .__fox-label{font-size:12px;font-weight:500;color:#888}',
|
|
17
|
+
'#__fox-toggle{background:#3b82f6;color:#fff;border:none;padding:4px 10px;border-radius:4px;cursor:pointer;font-size:12px;font-family:inherit}',
|
|
18
|
+
'#__fox-toggle:hover{background:#2563eb}',
|
|
19
|
+
'#__fox-toggle.__fox-active{background:#ef4444}',
|
|
20
|
+
'#__fox-toggle.__fox-active:hover{background:#dc2626}',
|
|
21
|
+
'.__fox-highlight{outline:2px solid #3b82f6!important;outline-offset:1px!important}',
|
|
22
|
+
'#__fox-popup{position:fixed;background:#1e1e1e;color:#e0e0e0;padding:12px;border-radius:8px;box-shadow:0 4px 20px rgba(0,0,0,.5);z-index:2147483647;min-width:300px;max-width:400px;pointer-events:auto;font-family:system-ui,sans-serif}',
|
|
23
|
+
'#__fox-popup .__fox-selector{font-family:monospace;font-size:11px;color:#888;background:#2a2a2a;padding:4px 8px;border-radius:4px;word-break:break-all;margin-bottom:8px;max-height:80px;overflow:auto}',
|
|
24
|
+
'#__fox-popup .__fox-tag{font-size:12px;color:#aaa;margin-bottom:8px}',
|
|
25
|
+
'#__fox-popup .__fox-tag span{color:#3b82f6}',
|
|
26
|
+
'#__fox-popup textarea{width:100%;background:#2a2a2a;color:#e0e0e0;border:1px solid #444;border-radius:4px;padding:6px 8px;font-size:12px;resize:vertical;min-height:60px;box-sizing:border-box;font-family:inherit}',
|
|
27
|
+
'#__fox-popup textarea:focus{border-color:#3b82f6;outline:none}',
|
|
28
|
+
'#__fox-popup .__fox-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:8px}',
|
|
29
|
+
'#__fox-popup button.__fox-send{background:#3b82f6;color:#fff;border:none;padding:6px 14px;border-radius:4px;cursor:pointer;font-size:12px;font-family:inherit}',
|
|
30
|
+
'#__fox-popup button.__fox-send:hover{background:#2563eb}',
|
|
31
|
+
'#__fox-popup button.__fox-cancel{background:transparent;color:#888;border:1px solid #444;padding:6px 14px;border-radius:4px;cursor:pointer;font-size:12px;font-family:inherit}',
|
|
32
|
+
'#__fox-popup button.__fox-cancel:hover{color:#aaa;border-color:#666}',
|
|
33
|
+
'#__fox-popup .__fox-hint{font-size:11px;color:#666;margin-top:6px;line-height:1.4}'
|
|
34
|
+
].join('\n');
|
|
35
|
+
|
|
36
|
+
var overlay = document.createElement('div');
|
|
37
|
+
overlay.id = '__fox-overlay';
|
|
38
|
+
overlay.innerHTML = '<div id="__fox-widget">' +
|
|
39
|
+
'<span class="__fox-label">OpenFox</span>' +
|
|
40
|
+
'<button id="__fox-toggle">Send feedback</button>' +
|
|
41
|
+
'</div>';
|
|
42
|
+
|
|
43
|
+
var toggleBtn;
|
|
44
|
+
|
|
45
|
+
function setInspectMode(enabled) {
|
|
46
|
+
window.__foxInspectMode = enabled;
|
|
47
|
+
if (toggleBtn) {
|
|
48
|
+
toggleBtn.textContent = enabled ? 'Exit inspect' : 'Send feedback';
|
|
49
|
+
toggleBtn.classList.toggle('__fox-active', enabled);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function clearHighlights() {
|
|
54
|
+
if (window.__foxHighlightedEl) {
|
|
55
|
+
window.__foxHighlightedEl.classList.remove('__fox-highlight');
|
|
56
|
+
window.__foxHighlightedEl = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function generateXPath(el) {
|
|
61
|
+
if (!el || el.nodeType !== Node.ELEMENT_NODE) return '';
|
|
62
|
+
var parts = [];
|
|
63
|
+
while (el && el.nodeType === Node.ELEMENT_NODE && el !== document.documentElement) {
|
|
64
|
+
var index = 1;
|
|
65
|
+
var sibling = el.previousSibling;
|
|
66
|
+
while (sibling) {
|
|
67
|
+
if (sibling.nodeType === Node.ELEMENT_NODE && sibling.nodeName === el.nodeName) index++;
|
|
68
|
+
sibling = sibling.previousSibling;
|
|
69
|
+
}
|
|
70
|
+
parts.unshift(el.nodeName.toLowerCase() + '[' + index + ']');
|
|
71
|
+
el = el.parentNode;
|
|
72
|
+
}
|
|
73
|
+
return '/' + parts.join('/');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function stripSvgAndGetText(el) {
|
|
77
|
+
try {
|
|
78
|
+
var clone = el.cloneNode(true);
|
|
79
|
+
var svgs = clone.querySelectorAll('svg');
|
|
80
|
+
for (var i = 0; i < svgs.length; i++) {
|
|
81
|
+
svgs[i].remove();
|
|
82
|
+
}
|
|
83
|
+
var text = (clone.textContent || '').replace(/\s+/g, ' ').trim();
|
|
84
|
+
return text.slice(0, 500) || null;
|
|
85
|
+
} catch (e) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function buildElementData(el) {
|
|
91
|
+
var attrs = {};
|
|
92
|
+
if (el.attributes) {
|
|
93
|
+
for (var i = 0; i < el.attributes.length; i++) {
|
|
94
|
+
var attr = el.attributes[i];
|
|
95
|
+
if (attr.name !== 'class' && attr.name !== 'id') {
|
|
96
|
+
attrs[attr.name] = attr.value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
var rect = el.getBoundingClientRect();
|
|
101
|
+
var tagName = el.tagName ? el.tagName.toLowerCase() : '';
|
|
102
|
+
// Avoid capturing the highlight overlay in xpath/outerHTML
|
|
103
|
+
if (el.classList && el.classList.contains('__fox-highlight')) {
|
|
104
|
+
var parent = el.parentNode;
|
|
105
|
+
if (parent) {
|
|
106
|
+
return buildElementData(parent);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
tag: tagName,
|
|
111
|
+
id: el.id || null,
|
|
112
|
+
className: (typeof el.className === 'string' ? el.className : '') || null,
|
|
113
|
+
xpath: generateXPath(el),
|
|
114
|
+
text: (el.innerText || '').slice(0, 500) || null,
|
|
115
|
+
textContent: stripSvgAndGetText(el),
|
|
116
|
+
outerHTML: (el.outerHTML || '').slice(0, 1000) || '',
|
|
117
|
+
rect: { x: rect.left, y: rect.top, width: rect.width, height: rect.height },
|
|
118
|
+
attributes: attrs
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function showPopup(el, x, y) {
|
|
123
|
+
var existing = document.getElementById('__fox-popup');
|
|
124
|
+
if (existing) existing.remove();
|
|
125
|
+
|
|
126
|
+
window.__foxPopupOpen = true;
|
|
127
|
+
var data = buildElementData(el);
|
|
128
|
+
var viewportWidth = window.innerWidth;
|
|
129
|
+
var viewportHeight = window.innerHeight;
|
|
130
|
+
|
|
131
|
+
var left = x + 10;
|
|
132
|
+
var top = y + 10;
|
|
133
|
+
if (left + 340 > viewportWidth) left = x - 350;
|
|
134
|
+
if (top + 280 > viewportHeight) top = y - 290;
|
|
135
|
+
if (left < 8) left = 8;
|
|
136
|
+
if (top < 8) top = 8;
|
|
137
|
+
|
|
138
|
+
var popup = document.createElement('div');
|
|
139
|
+
popup.id = '__fox-popup';
|
|
140
|
+
popup.style.left = left + 'px';
|
|
141
|
+
popup.style.top = top + 'px';
|
|
142
|
+
|
|
143
|
+
var tagDisplay = data.tag + (data.id ? '#' + data.id : (data.className ? '.' + data.className.split(' ')[0] : ''));
|
|
144
|
+
|
|
145
|
+
popup.innerHTML =
|
|
146
|
+
'<div class="__fox-tag">Element: <span>' + tagDisplay + '</span></div>' +
|
|
147
|
+
'<div class="__fox-selector">' + data.xpath + '</div>' +
|
|
148
|
+
'<textarea placeholder="What\'s wrong with this element?"></textarea>' +
|
|
149
|
+
'<div class="__fox-hint">Sending to: ' + (window.__foxSessionTitle || window.__foxSessionId || 'none') + '. To target a different session, close this, navigate to that session in OpenFox, and reopen the inspect window.</div>' +
|
|
150
|
+
'<div class="__fox-actions">' +
|
|
151
|
+
'<button class="__fox-cancel">Cancel</button>' +
|
|
152
|
+
'<button class="__fox-send">Send to Agent</button>' +
|
|
153
|
+
'</div>';
|
|
154
|
+
|
|
155
|
+
document.body.appendChild(popup);
|
|
156
|
+
|
|
157
|
+
var textarea = popup.querySelector('textarea');
|
|
158
|
+
textarea.focus();
|
|
159
|
+
|
|
160
|
+
textarea.addEventListener('keydown', function(ke) {
|
|
161
|
+
if (ke.key === 'Enter' && !ke.shiftKey) {
|
|
162
|
+
ke.preventDefault();
|
|
163
|
+
popup.querySelector('.__fox-send').click();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
popup.querySelector('.__fox-cancel').addEventListener('click', function(e) {
|
|
168
|
+
e.stopPropagation();
|
|
169
|
+
window.__foxPopupOpen = false;
|
|
170
|
+
popup.remove();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
popup.querySelector('.__fox-send').addEventListener('click', function(e) {
|
|
174
|
+
e.stopPropagation();
|
|
175
|
+
if (window.__foxSentPending) return;
|
|
176
|
+
window.__foxSentPending = true;
|
|
177
|
+
setTimeout(function() { window.__foxSentPending = false; }, 3000);
|
|
178
|
+
var annotation = textarea.value.trim();
|
|
179
|
+
window.__foxPopupOpen = false;
|
|
180
|
+
popup.remove();
|
|
181
|
+
clearHighlights();
|
|
182
|
+
setInspectMode(false);
|
|
183
|
+
|
|
184
|
+
fetch('/__openfox_feedback', {
|
|
185
|
+
method: 'POST',
|
|
186
|
+
headers: { 'Content-Type': 'application/json' },
|
|
187
|
+
body: JSON.stringify({
|
|
188
|
+
sessionId: window.__foxSessionId,
|
|
189
|
+
element: data,
|
|
190
|
+
annotation: annotation,
|
|
191
|
+
pageUrl: window.location.href
|
|
192
|
+
})
|
|
193
|
+
}).catch(function(err) {
|
|
194
|
+
console.error('Failed to send feedback:', err);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
popup.addEventListener('click', function(e) { e.stopPropagation(); });
|
|
199
|
+
|
|
200
|
+
document.addEventListener('keydown', function escHandler(e) {
|
|
201
|
+
if (e.key === 'Escape') {
|
|
202
|
+
window.__foxPopupOpen = false;
|
|
203
|
+
popup.remove();
|
|
204
|
+
clearHighlights();
|
|
205
|
+
setInspectMode(false);
|
|
206
|
+
document.removeEventListener('keydown', escHandler);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
document.addEventListener('mouseover', function(e) {
|
|
212
|
+
if (!window.__foxInspectMode || window.__foxPopupOpen) return;
|
|
213
|
+
if (e.target === document.documentElement || e.target === document.body) return;
|
|
214
|
+
if (overlay.contains(e.target)) return;
|
|
215
|
+
clearHighlights();
|
|
216
|
+
e.target.classList.add('__fox-highlight');
|
|
217
|
+
window.__foxHighlightedEl = e.target;
|
|
218
|
+
}, true);
|
|
219
|
+
|
|
220
|
+
document.addEventListener('click', function(e) {
|
|
221
|
+
if (!window.__foxInspectMode) return;
|
|
222
|
+
if (overlay.contains(e.target)) return;
|
|
223
|
+
if (document.getElementById('__fox-popup')) return;
|
|
224
|
+
|
|
225
|
+
e.preventDefault();
|
|
226
|
+
e.stopPropagation();
|
|
227
|
+
var el = window.__foxHighlightedEl;
|
|
228
|
+
if (!el) return;
|
|
229
|
+
showPopup(el, e.clientX, e.clientY);
|
|
230
|
+
}, true);
|
|
231
|
+
|
|
232
|
+
document.addEventListener('keydown', function(e) {
|
|
233
|
+
if (e.key === 'Escape' && window.__foxInspectMode) {
|
|
234
|
+
setInspectMode(false);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
window.addEventListener('message', function(e) {
|
|
239
|
+
if (e.data && e.data.type === 'setFoxSessionId') {
|
|
240
|
+
window.__foxSessionId = e.data.sessionId;
|
|
241
|
+
}
|
|
242
|
+
if (e.data && e.data.type === 'setFoxSessionTitle') {
|
|
243
|
+
window.__foxSessionTitle = e.data.sessionTitle;
|
|
244
|
+
}
|
|
245
|
+
if (e.data && e.data.type === 'setFoxInspectEnabled') {
|
|
246
|
+
window.__foxInspectEnabled = e.data.enabled;
|
|
247
|
+
overlay.style.display = e.data.enabled ? '' : 'none';
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
function init() {
|
|
252
|
+
if (window.__foxInspectInit) return;
|
|
253
|
+
window.__foxInspectInit = true;
|
|
254
|
+
document.head.appendChild(overlayStyle);
|
|
255
|
+
document.body.appendChild(overlay);
|
|
256
|
+
toggleBtn = document.getElementById('__fox-toggle');
|
|
257
|
+
toggleBtn.addEventListener('click', function(e) {
|
|
258
|
+
e.stopPropagation();
|
|
259
|
+
setInspectMode(!window.__foxInspectMode);
|
|
260
|
+
});
|
|
261
|
+
overlay.style.display = window.__foxInspectEnabled ? '' : 'none';
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (document.body) {
|
|
265
|
+
init();
|
|
266
|
+
} else {
|
|
267
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
268
|
+
}
|
|
269
|
+
})();
|