@rickcedwhat/playwright-smart-vision 0.2.0-next.872a27a → 0.2.0-next.ea65044
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/devtools.d.ts.map +1 -1
- package/dist/devtools.js +18 -59
- package/dist/devtools.js.map +1 -1
- package/package.json +1 -1
package/dist/devtools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAoQ7C,wBAAsB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAa9D"}
|
package/dist/devtools.js
CHANGED
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
import { writeScreenBuffer } from './configure.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!input || e.target !== input) return;
|
|
10
|
-
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
11
|
-
|
|
12
|
-
const start = input.selectionStart ?? input.value.length;
|
|
13
|
-
const end = input.selectionEnd ?? input.value.length;
|
|
14
|
-
|
|
15
|
-
if (e.key.length === 1) {
|
|
16
|
-
input.value = input.value.slice(0, start) + e.key + input.value.slice(end);
|
|
17
|
-
input.setSelectionRange(start + 1, start + 1);
|
|
18
|
-
} else if (e.key === 'Backspace') {
|
|
19
|
-
if (start !== end) {
|
|
20
|
-
input.value = input.value.slice(0, start) + input.value.slice(end);
|
|
21
|
-
input.setSelectionRange(start, start);
|
|
22
|
-
} else if (start > 0) {
|
|
23
|
-
input.value = input.value.slice(0, start - 1) + input.value.slice(end);
|
|
24
|
-
input.setSelectionRange(start - 1, start - 1);
|
|
2
|
+
const FAB_SCRIPT = `(function () {
|
|
3
|
+
if (!window.__ocrKeyboardShield) {
|
|
4
|
+
window.__ocrKeyboardShield = true;
|
|
5
|
+
const shield = (e) => {
|
|
6
|
+
const backdrop = document.getElementById('__ocr-modal-backdrop');
|
|
7
|
+
if (backdrop && backdrop.contains(e.target)) {
|
|
8
|
+
e.stopImmediatePropagation();
|
|
25
9
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
document.getElementById('__ocr-modal-backdrop')?.remove();
|
|
30
|
-
} else {
|
|
31
|
-
return;
|
|
10
|
+
};
|
|
11
|
+
for (const type of ['keydown', 'keyup', 'keypress']) {
|
|
12
|
+
document.addEventListener(type, shield, true);
|
|
32
13
|
}
|
|
14
|
+
}
|
|
33
15
|
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
e.stopImmediatePropagation();
|
|
36
|
-
}, true);
|
|
37
|
-
})();`;
|
|
38
|
-
const FAB_SCRIPT = `(function () {
|
|
39
16
|
if (window.__ocrDevtools) return;
|
|
40
17
|
window.__ocrDevtools = true;
|
|
41
18
|
|
|
@@ -53,6 +30,8 @@ const FAB_SCRIPT = `(function () {
|
|
|
53
30
|
right: 20px;
|
|
54
31
|
z-index: 2147483647;
|
|
55
32
|
font-family: system-ui, sans-serif;
|
|
33
|
+
display: block;
|
|
34
|
+
line-height: 0;
|
|
56
35
|
}
|
|
57
36
|
#__ocr-fab-btn {
|
|
58
37
|
width: 48px;
|
|
@@ -100,7 +79,6 @@ const FAB_SCRIPT = `(function () {
|
|
|
100
79
|
border: none;
|
|
101
80
|
color: #e2e8f0;
|
|
102
81
|
font-size: 13px;
|
|
103
|
-
line-height: 1.4;
|
|
104
82
|
cursor: pointer;
|
|
105
83
|
white-space: nowrap;
|
|
106
84
|
text-align: left;
|
|
@@ -185,9 +163,7 @@ const FAB_SCRIPT = `(function () {
|
|
|
185
163
|
}
|
|
186
164
|
}
|
|
187
165
|
|
|
188
|
-
fab
|
|
189
|
-
fab.addEventListener('mouseup', (e) => e.stopPropagation());
|
|
190
|
-
fab.addEventListener('click', (e) => e.stopPropagation());
|
|
166
|
+
isolateFromPage(fab);
|
|
191
167
|
|
|
192
168
|
(document.body || document.documentElement).appendChild(fab);
|
|
193
169
|
|
|
@@ -200,31 +176,16 @@ const FAB_SCRIPT = `(function () {
|
|
|
200
176
|
if (!fab.contains(e.target)) menu.classList.remove('open');
|
|
201
177
|
});
|
|
202
178
|
|
|
203
|
-
|
|
204
|
-
async function startCapture() {
|
|
205
|
-
if (capturing) return;
|
|
206
|
-
capturing = true;
|
|
179
|
+
captureBtn.addEventListener('click', async () => {
|
|
207
180
|
menu.classList.remove('open');
|
|
208
181
|
fab.style.display = 'none';
|
|
182
|
+
let b64;
|
|
209
183
|
try {
|
|
210
|
-
|
|
211
|
-
showModal(b64);
|
|
212
|
-
} catch (err) {
|
|
213
|
-
alert('Capture failed: ' + (err && err.message ? err.message : err));
|
|
184
|
+
b64 = await window.__ocrCapture();
|
|
214
185
|
} finally {
|
|
215
186
|
fab.style.display = '';
|
|
216
|
-
capturing = false;
|
|
217
187
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
captureBtn.addEventListener('mousedown', (e) => {
|
|
221
|
-
e.preventDefault();
|
|
222
|
-
e.stopPropagation();
|
|
223
|
-
startCapture();
|
|
224
|
-
});
|
|
225
|
-
captureBtn.addEventListener('click', (e) => {
|
|
226
|
-
e.preventDefault();
|
|
227
|
-
e.stopPropagation();
|
|
188
|
+
showModal(b64);
|
|
228
189
|
});
|
|
229
190
|
|
|
230
191
|
function showModal(b64) {
|
|
@@ -303,9 +264,7 @@ export async function injectDevtools(page) {
|
|
|
303
264
|
writeScreenBuffer(name, Buffer.from(b64, 'base64'));
|
|
304
265
|
});
|
|
305
266
|
// addInitScript covers future navigations; evaluate covers the already-loaded page.
|
|
306
|
-
await page.addInitScript(NAME_INPUT_SHIELD);
|
|
307
267
|
await page.addInitScript(FAB_SCRIPT);
|
|
308
|
-
await page.evaluate(NAME_INPUT_SHIELD);
|
|
309
268
|
await page.evaluate(FAB_SCRIPT);
|
|
310
269
|
}
|
|
311
270
|
//# sourceMappingURL=devtools.js.map
|
package/dist/devtools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.js","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,
|
|
1
|
+
{"version":3,"file":"devtools.js","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA+Pb,CAAC;AAEP,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAU;IAC7C,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,KAAK,IAAqB,EAAE;QACpE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,EAAE,IAAY,EAAE,GAAW,EAAiB,EAAE;QACxF,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,oFAAoF;IACpF,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACrC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rickcedwhat/playwright-smart-vision",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.ea65044",
|
|
4
4
|
"description": "Computer-vision and OCR-based element assertions for Playwright — local, fast, no GPT Vision required",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|