@trungtnm/agent-annotator 0.2.0 → 0.3.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/README.md +43 -17
- package/dist/index.d.ts +51 -2
- package/dist/index.js +416 -138
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,32 +1,125 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
// src/annotator.tsx
|
|
4
|
-
import { useCallback, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
4
|
+
import { useCallback, useEffect as useEffect3, useMemo, useRef as useRef3, useState as useState3 } from "react";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
|
|
7
|
-
// src/
|
|
7
|
+
// src/redaction.ts
|
|
8
8
|
var REDACTED = "[redacted]";
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
var COUNTRY_RULES = {
|
|
10
|
+
vn: {
|
|
11
|
+
label: "Vietnam",
|
|
12
|
+
covers: "phone numbers, 12-digit citizen IDs (CCCD)",
|
|
13
|
+
keys: [/cccd|cmnd|zalo/],
|
|
14
|
+
values: [
|
|
15
|
+
// +84 or 0, then 9–10 digits, optionally grouped by spaces or dots.
|
|
16
|
+
/(?<!\d)(?:\+?84|0)(?:[\s.]?\d){9,10}(?!\d)/g,
|
|
17
|
+
// CCCD: 12 digits, starting with the 0 of a province code.
|
|
18
|
+
/(?<!\d)0\d{11}(?!\d)/g
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
us: {
|
|
22
|
+
label: "United States",
|
|
23
|
+
covers: "phone numbers, Social Security numbers written with dashes",
|
|
24
|
+
// `ssn` only at either end of the key: in the middle it is "claSSName".
|
|
25
|
+
keys: [/^ssn|ssn$|socialsecurity/],
|
|
26
|
+
values: [
|
|
27
|
+
// SSN with its dashes, minus the ranges never issued.
|
|
28
|
+
/(?<!\d)(?!000|666|9\d\d)\d{3}-(?!00)\d{2}-(?!0000)\d{4}(?!\d)/g,
|
|
29
|
+
// NANP: optional +1, area code and exchange each starting 2–9, then 4 digits.
|
|
30
|
+
/(?<![\d+])(?:\+1[\s.-]?)?(?:\([2-9]\d{2}\)\s?|[2-9]\d{2}[\s.-]?)[2-9]\d{2}[\s.-]?\d{4}(?!\d)/g
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
sg: {
|
|
34
|
+
label: "Singapore",
|
|
35
|
+
covers: "phone numbers with +65 or a space or dash, NRIC/FIN numbers",
|
|
36
|
+
keys: [/nric/],
|
|
37
|
+
values: [
|
|
38
|
+
/\b[STFGM]\d{7}[A-Z]\b/g,
|
|
39
|
+
// 8 digits starting 3, 6, 8 or 9: with +65, or split 4-4, so a bare amount survives.
|
|
40
|
+
/(?<!\d)(?:\+65[\s-]?[3689]\d{3}[\s-]?\d{4}|[3689]\d{3}[\s-]\d{4})(?!\d)/g
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var COUNTRIES = Object.keys(COUNTRY_RULES);
|
|
45
|
+
var DEFAULT_REDACTION = { enabled: true, countries: ["vn"], patterns: [] };
|
|
46
|
+
var SHARED_KEY = /(nationalid|citizenid|identitynumber|idnumber|idcard|passport|phone|mobile|msisdn|email|fullname|(debtor|borrower|customer|guarantor|contact|person|holder|relative|spouse|recipient|payer)name|address|dob|dateofbirth|birthday|birthdate|bankaccount|accountnumber|cardnumber|password|passwd|secret|token|otp|apikey|authorization|cookie|signature)/;
|
|
47
|
+
var EMAIL = /[^\s@<>()[\]"']+@[^\s@<>()[\]"']+\.[a-z]{2,}/gi;
|
|
48
|
+
function createRedactor(settings) {
|
|
49
|
+
if (!settings.enabled) return { enabled: false, isPiiKey: () => false, text: (text) => text };
|
|
50
|
+
const rules = settings.countries.map((country) => COUNTRY_RULES[country]);
|
|
51
|
+
const keys = [SHARED_KEY, ...rules.flatMap((rule) => rule.keys)];
|
|
52
|
+
const values = [
|
|
53
|
+
EMAIL,
|
|
54
|
+
...rules.flatMap((rule) => rule.values),
|
|
55
|
+
...settings.patterns.filter((source) => source.trim() !== "").map((source) => compilePattern(source)).filter((pattern) => pattern instanceof RegExp)
|
|
56
|
+
];
|
|
57
|
+
return {
|
|
58
|
+
enabled: true,
|
|
59
|
+
isPiiKey: (key) => {
|
|
60
|
+
const normalised = key.toLowerCase().replace(/[\s_-]/g, "");
|
|
61
|
+
return keys.some((pattern) => pattern.test(normalised));
|
|
62
|
+
},
|
|
63
|
+
text: (text) => values.reduce((out, pattern) => out.replace(pattern, REDACTED), text)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
var DEFAULT_REDACTOR = createRedactor(DEFAULT_REDACTION);
|
|
67
|
+
function compilePattern(source) {
|
|
68
|
+
const literal = /^\/(.+)\/([a-z]*)$/s.exec(source);
|
|
69
|
+
const body = literal?.[1] ?? source;
|
|
70
|
+
const flags = new Set(literal?.[2] ?? "");
|
|
71
|
+
flags.add("g");
|
|
72
|
+
let pattern;
|
|
73
|
+
try {
|
|
74
|
+
pattern = new RegExp(body, [...flags].join(""));
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return error instanceof Error ? error.message : "Invalid pattern";
|
|
77
|
+
}
|
|
78
|
+
if (pattern.test("")) return "Matches empty text";
|
|
79
|
+
pattern.lastIndex = 0;
|
|
80
|
+
return pattern;
|
|
19
81
|
}
|
|
20
|
-
function
|
|
21
|
-
return
|
|
82
|
+
function resolveRedaction(options) {
|
|
83
|
+
return {
|
|
84
|
+
enabled: options?.enabled ?? DEFAULT_REDACTION.enabled,
|
|
85
|
+
countries: (options?.countries ?? DEFAULT_REDACTION.countries).filter((country) => country in COUNTRY_RULES),
|
|
86
|
+
patterns: (options?.patterns ?? DEFAULT_REDACTION.patterns).map(
|
|
87
|
+
(pattern) => typeof pattern === "string" ? pattern : `/${pattern.source}/${pattern.flags.replace("g", "")}`
|
|
88
|
+
)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function readRedaction(key) {
|
|
92
|
+
try {
|
|
93
|
+
const raw = window.localStorage.getItem(key);
|
|
94
|
+
if (raw === null) return null;
|
|
95
|
+
const value = JSON.parse(raw);
|
|
96
|
+
if (typeof value.enabled !== "boolean" || !Array.isArray(value.countries) || !Array.isArray(value.patterns)) return null;
|
|
97
|
+
return {
|
|
98
|
+
enabled: value.enabled,
|
|
99
|
+
countries: value.countries.filter((country) => typeof country === "string" && country in COUNTRY_RULES),
|
|
100
|
+
patterns: value.patterns.filter((pattern) => typeof pattern === "string")
|
|
101
|
+
};
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function writeRedaction(key, settings) {
|
|
107
|
+
try {
|
|
108
|
+
if (settings === null) window.localStorage.removeItem(key);
|
|
109
|
+
else window.localStorage.setItem(key, JSON.stringify(settings));
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
22
112
|
}
|
|
113
|
+
|
|
114
|
+
// src/serialize.ts
|
|
23
115
|
var DEFAULT_LIMITS = { depth: 4, keys: 25, items: 5, string: 160 };
|
|
24
116
|
var SKIPPED_KEYS = /* @__PURE__ */ new Set(["children", "ref", "key", "$$typeof", "_owner", "_store"]);
|
|
25
117
|
var REACT_ELEMENT_TYPES = /* @__PURE__ */ new Set([/* @__PURE__ */ Symbol.for("react.transitional.element"), /* @__PURE__ */ Symbol.for("react.element")]);
|
|
26
|
-
function toSnapshot(value, limits = DEFAULT_LIMITS) {
|
|
27
|
-
return walk(value, 0, limits, /* @__PURE__ */ new Set());
|
|
118
|
+
function toSnapshot(value, limits = DEFAULT_LIMITS, redactor = DEFAULT_REDACTOR) {
|
|
119
|
+
return walk(value, 0, { limits, redactor }, /* @__PURE__ */ new Set());
|
|
28
120
|
}
|
|
29
|
-
function walk(value, depth,
|
|
121
|
+
function walk(value, depth, walker, path) {
|
|
122
|
+
const { limits, redactor } = walker;
|
|
30
123
|
switch (typeof value) {
|
|
31
124
|
case "undefined":
|
|
32
125
|
return "<undefined>";
|
|
@@ -37,7 +130,7 @@ function walk(value, depth, limits, path) {
|
|
|
37
130
|
case "bigint":
|
|
38
131
|
return `${value}n`;
|
|
39
132
|
case "string":
|
|
40
|
-
return truncate(
|
|
133
|
+
return truncate(redactor.text(value), limits.string);
|
|
41
134
|
case "symbol":
|
|
42
135
|
return value.toString();
|
|
43
136
|
case "function":
|
|
@@ -48,12 +141,12 @@ function walk(value, depth, limits, path) {
|
|
|
48
141
|
if (value === null) return null;
|
|
49
142
|
const object = value;
|
|
50
143
|
if (path.has(object)) return "<circular>";
|
|
51
|
-
const summary = summarise(object);
|
|
144
|
+
const summary = summarise(object, redactor);
|
|
52
145
|
if (summary !== null) return summary;
|
|
53
146
|
path.add(object);
|
|
54
147
|
try {
|
|
55
|
-
if (Array.isArray(object)) return walkList(object, object.length, depth,
|
|
56
|
-
if (object instanceof Set) return { "<Set>": walkList([...object], object.size, depth,
|
|
148
|
+
if (Array.isArray(object)) return walkList(object, object.length, depth, walker, path);
|
|
149
|
+
if (object instanceof Set) return { "<Set>": walkList([...object], object.size, depth, walker, path) };
|
|
57
150
|
if (object instanceof Map) {
|
|
58
151
|
if (depth >= limits.depth) return `<Map(${object.size})>`;
|
|
59
152
|
const entries = {};
|
|
@@ -63,23 +156,25 @@ function walk(value, depth, limits, path) {
|
|
|
63
156
|
entries["\u2026"] = `+${object.size - kept}`;
|
|
64
157
|
break;
|
|
65
158
|
}
|
|
66
|
-
const name = typeof key === "string" ? key : String(walk(key, limits.depth,
|
|
67
|
-
entries[name] = isPiiKey(name) ? redactWhole(entry) : walk(entry, depth + 1,
|
|
159
|
+
const name = typeof key === "string" ? key : String(walk(key, limits.depth, walker, path));
|
|
160
|
+
entries[name] = redactor.isPiiKey(name) ? redactWhole(entry) : walk(entry, depth + 1, walker, path);
|
|
68
161
|
kept += 1;
|
|
69
162
|
}
|
|
70
163
|
return { "<Map>": entries };
|
|
71
164
|
}
|
|
72
|
-
return walkObject(object, depth,
|
|
165
|
+
return walkObject(object, depth, walker, path);
|
|
73
166
|
} finally {
|
|
74
167
|
path.delete(object);
|
|
75
168
|
}
|
|
76
169
|
}
|
|
77
|
-
function walkList(items, size, depth,
|
|
170
|
+
function walkList(items, size, depth, walker, path) {
|
|
171
|
+
const { limits } = walker;
|
|
78
172
|
if (depth >= limits.depth) return `<Array(${size})>`;
|
|
79
|
-
const kept = items.slice(0, limits.items).map((item) => walk(item, depth + 1,
|
|
173
|
+
const kept = items.slice(0, limits.items).map((item) => walk(item, depth + 1, walker, path));
|
|
80
174
|
return size > limits.items ? [...kept, `\u2026 +${size - limits.items}`] : kept;
|
|
81
175
|
}
|
|
82
|
-
function walkObject(object, depth,
|
|
176
|
+
function walkObject(object, depth, walker, path) {
|
|
177
|
+
const { limits, redactor } = walker;
|
|
83
178
|
const keys = Object.keys(object).filter((key) => !SKIPPED_KEYS.has(key) && !key.startsWith("__react"));
|
|
84
179
|
if (depth >= limits.depth) return keys.length === 0 ? {} : `{\u2026${keys.length} keys}`;
|
|
85
180
|
const out = {};
|
|
@@ -91,7 +186,7 @@ function walkObject(object, depth, limits, path) {
|
|
|
91
186
|
out[key] = "<getter threw>";
|
|
92
187
|
continue;
|
|
93
188
|
}
|
|
94
|
-
out[key] = isPiiKey(key) ? redactWhole(entry) : walk(entry, depth + 1,
|
|
189
|
+
out[key] = redactor.isPiiKey(key) ? redactWhole(entry) : walk(entry, depth + 1, walker, path);
|
|
95
190
|
}
|
|
96
191
|
if (keys.length > limits.keys) out["\u2026"] = `+${keys.length - limits.keys} keys`;
|
|
97
192
|
return out;
|
|
@@ -102,12 +197,12 @@ function redactWhole(value) {
|
|
|
102
197
|
if (value === "") return "";
|
|
103
198
|
return REDACTED;
|
|
104
199
|
}
|
|
105
|
-
function summarise(object) {
|
|
200
|
+
function summarise(object, redactor) {
|
|
106
201
|
if (REACT_ELEMENT_TYPES.has(object.$$typeof)) {
|
|
107
202
|
return `<${typeName(object.type)} />`;
|
|
108
203
|
}
|
|
109
204
|
if (object instanceof Date) return Number.isNaN(object.getTime()) ? "<Invalid Date>" : object.toISOString();
|
|
110
|
-
if (object instanceof Error) return `<${object.name}: ${truncate(
|
|
205
|
+
if (object instanceof Error) return `<${object.name}: ${truncate(redactor.text(object.message), 120)}>`;
|
|
111
206
|
if (object instanceof RegExp) return object.toString();
|
|
112
207
|
if (typeof Node !== "undefined" && object instanceof Node) return `<${nodeLabel(object)}>`;
|
|
113
208
|
if (typeof object.then === "function") return "<Promise>";
|
|
@@ -204,13 +299,13 @@ function accessibleName(element) {
|
|
|
204
299
|
if (labels && labels.length > 0) return Array.from(labels, (node) => visibleText(node)).join(" ");
|
|
205
300
|
return element.getAttribute("alt") ?? element.getAttribute("title") ?? visibleText(element);
|
|
206
301
|
}
|
|
207
|
-
function clean(text, max) {
|
|
208
|
-
return truncate(
|
|
302
|
+
function clean(text, max, redactor) {
|
|
303
|
+
return truncate(redactor.text(text.replace(/\s+/g, " ").trim()), max);
|
|
209
304
|
}
|
|
210
|
-
function describeAccessibility(element) {
|
|
305
|
+
function describeAccessibility(element, redactor = DEFAULT_REDACTOR) {
|
|
211
306
|
const role = roleOf(element);
|
|
212
307
|
if (role === null) return null;
|
|
213
|
-
const name = clean(accessibleName(element), 80);
|
|
308
|
+
const name = clean(accessibleName(element), 80, redactor);
|
|
214
309
|
const states = [];
|
|
215
310
|
if (element.disabled === true || element.getAttribute("aria-disabled") === "true") {
|
|
216
311
|
states.push("disabled");
|
|
@@ -232,24 +327,24 @@ function sectionLabel(section2) {
|
|
|
232
327
|
const title = section2.querySelector(SECTION_TITLE);
|
|
233
328
|
return title === null ? null : visibleText(title);
|
|
234
329
|
}
|
|
235
|
-
function sectionPath(element) {
|
|
330
|
+
function sectionPath(element, redactor = DEFAULT_REDACTOR) {
|
|
236
331
|
const labels = [];
|
|
237
332
|
for (let current = element.parentElement?.closest(SECTIONS) ?? null; current !== null && labels.length < MAX_SECTIONS; current = current.parentElement?.closest(SECTIONS) ?? null) {
|
|
238
333
|
const label = sectionLabel(current);
|
|
239
|
-
if (label) labels.unshift(clean(label, 50));
|
|
334
|
+
if (label) labels.unshift(clean(label, 50, redactor));
|
|
240
335
|
}
|
|
241
336
|
const pageHeading = element.ownerDocument.querySelector("h1");
|
|
242
337
|
if (pageHeading && !pageHeading.contains(element)) {
|
|
243
|
-
const heading = clean(visibleText(pageHeading), 50);
|
|
338
|
+
const heading = clean(visibleText(pageHeading), 50, redactor);
|
|
244
339
|
if (heading && labels[0] !== heading) labels.unshift(heading);
|
|
245
340
|
}
|
|
246
341
|
const path = labels.filter((label) => label !== "");
|
|
247
342
|
return path.length === 0 ? null : path.join(" \u203A ");
|
|
248
343
|
}
|
|
249
|
-
function nearbyText(element) {
|
|
344
|
+
function nearbyText(element, redactor = DEFAULT_REDACTOR) {
|
|
250
345
|
const before = visibleText(element.previousElementSibling);
|
|
251
346
|
const after = visibleText(element.nextElementSibling);
|
|
252
|
-
const parts = [clean(before, 60), clean(after, 60)];
|
|
347
|
+
const parts = [clean(before, 60, redactor), clean(after, 60, redactor)];
|
|
253
348
|
if (parts[0] === "" && parts[1] === "") return null;
|
|
254
349
|
return `before: "${parts[0]}" \xB7 after: "${parts[1]}"`;
|
|
255
350
|
}
|
|
@@ -408,29 +503,29 @@ var DESCRIBED_ATTRIBUTES = [
|
|
|
408
503
|
"alt",
|
|
409
504
|
...TEST_ID_ATTRIBUTES
|
|
410
505
|
];
|
|
411
|
-
function describeElement(element) {
|
|
506
|
+
function describeElement(element, redactor = DEFAULT_REDACTOR) {
|
|
412
507
|
const parts = [element.tagName.toLowerCase()];
|
|
413
508
|
for (const attribute of DESCRIBED_ATTRIBUTES) {
|
|
414
509
|
const value = element.getAttribute(attribute);
|
|
415
|
-
if (value) parts.push(`${attribute}="${truncate(
|
|
510
|
+
if (value) parts.push(`${attribute}="${truncate(redactor.text(value), 60)}"`);
|
|
416
511
|
}
|
|
417
512
|
const className = element.getAttribute("class");
|
|
418
513
|
if (className) parts.push(`class="${truncate(className.trim().replace(/\s+/g, " "), 120)}"`);
|
|
419
514
|
return `<${parts.join(" ")}>`;
|
|
420
515
|
}
|
|
421
|
-
function elementText(element, max = 120) {
|
|
516
|
+
function elementText(element, max = 120, redactor = DEFAULT_REDACTOR) {
|
|
422
517
|
const raw = element instanceof HTMLElement && typeof element.innerText === "string" ? element.innerText : element.textContent;
|
|
423
518
|
const text = (raw ?? "").replace(/\s+/g, " ").trim();
|
|
424
|
-
return truncate(
|
|
519
|
+
return truncate(redactor.text(text), max);
|
|
425
520
|
}
|
|
426
|
-
function controlValue(element) {
|
|
521
|
+
function controlValue(element, redactor = DEFAULT_REDACTOR) {
|
|
427
522
|
if (element instanceof HTMLInputElement) {
|
|
428
523
|
if (element.type === "password") return REDACTED;
|
|
429
524
|
if (element.type === "checkbox" || element.type === "radio") return element.checked ? "checked" : "unchecked";
|
|
430
|
-
return truncate(
|
|
525
|
+
return truncate(redactor.text(element.value), 120);
|
|
431
526
|
}
|
|
432
527
|
if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) {
|
|
433
|
-
return truncate(
|
|
528
|
+
return truncate(redactor.text(element.value), 120);
|
|
434
529
|
}
|
|
435
530
|
return null;
|
|
436
531
|
}
|
|
@@ -713,6 +808,7 @@ var DATA_COMPONENTS = 2;
|
|
|
713
808
|
var LOCATED_COMPONENTS = 4;
|
|
714
809
|
async function captureElement(element, resolve, options = {}) {
|
|
715
810
|
const win = element.ownerDocument.defaultView ?? window;
|
|
811
|
+
const redactor = options.redactor ?? DEFAULT_REDACTOR;
|
|
716
812
|
const fiber = fiberOf(element);
|
|
717
813
|
const components = fiber === null ? [] : componentAncestors(fiber);
|
|
718
814
|
const sites = [fiber, ...components.slice(0, LOCATED_COMPONENTS)].map(
|
|
@@ -735,15 +831,15 @@ async function captureElement(element, resolve, options = {}) {
|
|
|
735
831
|
},
|
|
736
832
|
element: {
|
|
737
833
|
tag: element.tagName.toLowerCase(),
|
|
738
|
-
opening: describeElement(element),
|
|
834
|
+
opening: describeElement(element, redactor),
|
|
739
835
|
selector: cssSelector(element),
|
|
740
|
-
text: elementText(element),
|
|
741
|
-
value: controlValue(element),
|
|
836
|
+
text: elementText(element, void 0, redactor),
|
|
837
|
+
value: controlValue(element, redactor),
|
|
742
838
|
rect: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
743
839
|
styles: notableStyles(win.getComputedStyle(element)),
|
|
744
|
-
accessibility: describeAccessibility(element),
|
|
745
|
-
section: sectionPath(element),
|
|
746
|
-
nearby: nearbyText(element)
|
|
840
|
+
accessibility: describeAccessibility(element, redactor),
|
|
841
|
+
section: sectionPath(element, redactor),
|
|
842
|
+
nearby: nearbyText(element, redactor)
|
|
747
843
|
},
|
|
748
844
|
viewport: { width: win.innerWidth, height: win.innerHeight, devicePixelRatio: win.devicePixelRatio },
|
|
749
845
|
jsx: locate(sites[0]),
|
|
@@ -753,8 +849,8 @@ async function captureElement(element, resolve, options = {}) {
|
|
|
753
849
|
})),
|
|
754
850
|
data: components.slice(0, options.dataComponents ?? DATA_COMPONENTS).map((component) => ({
|
|
755
851
|
component: componentName(component),
|
|
756
|
-
props: toSnapshot(component.memoizedProps),
|
|
757
|
-
state: toSnapshot(componentState(component))
|
|
852
|
+
props: toSnapshot(component.memoizedProps, DEFAULT_LIMITS, redactor),
|
|
853
|
+
state: toSnapshot(componentState(component), DEFAULT_LIMITS, redactor)
|
|
758
854
|
}))
|
|
759
855
|
};
|
|
760
856
|
}
|
|
@@ -847,6 +943,8 @@ var PATHS = {
|
|
|
847
943
|
crop: ["M6 2v14a2 2 0 0 0 2 2h14", "M18 22V8a2 2 0 0 0-2-2H2"],
|
|
848
944
|
cropOff: ["M6 2v14a2 2 0 0 0 2 2h14", "M18 22V8a2 2 0 0 0-2-2H2", "M3 3l18 18"],
|
|
849
945
|
collapse: ["M9 6l6 6-6 6"],
|
|
946
|
+
shield: ["M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z", "M9 12l2 2 4-4"],
|
|
947
|
+
shieldOff: ["M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z", "M3 3l18 18"],
|
|
850
948
|
ruler: ["M3 17L17 3l4 4L7 21z", "M7 13l2 2", "M10 10l2 2", "M13 7l2 2"]
|
|
851
949
|
};
|
|
852
950
|
function Icon(props) {
|
|
@@ -1267,7 +1365,9 @@ function Panel(props) {
|
|
|
1267
1365
|
/* @__PURE__ */ jsxs2("div", { style: { padding: 10, display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
1268
1366
|
/* @__PURE__ */ jsxs2("label", { style: { ...FONT2, display: "flex", gap: 6, alignItems: "center", fontSize: 12, color: MUTED, cursor: "pointer", flex: 1 }, children: [
|
|
1269
1367
|
/* @__PURE__ */ jsx3("input", { type: "checkbox", checked: props.includeData, onChange: (event) => props.onIncludeData(event.target.checked) }),
|
|
1270
|
-
"Include props/state (
|
|
1368
|
+
"Include props/state (",
|
|
1369
|
+
props.redactionOn ? "personal data redacted" : "redaction off",
|
|
1370
|
+
")"
|
|
1271
1371
|
] }),
|
|
1272
1372
|
/* @__PURE__ */ jsx3("button", { type: "button", onClick: props.onClear, style: { ...BUTTON, color: "#B42318" }, children: "Clear all" })
|
|
1273
1373
|
] })
|
|
@@ -1467,6 +1567,16 @@ function Toolbar(props) {
|
|
|
1467
1567
|
onClick: props.onScreenshot
|
|
1468
1568
|
}
|
|
1469
1569
|
),
|
|
1570
|
+
/* @__PURE__ */ jsx3(
|
|
1571
|
+
ToolButton,
|
|
1572
|
+
{
|
|
1573
|
+
icon: props.redactionOn ? "shield" : "shieldOff",
|
|
1574
|
+
label: "Redaction settings",
|
|
1575
|
+
hint: props.redactionOn ? "Personal data is redacted from the prompt. Choose countries or add your own patterns." : "Redaction is OFF: new comments carry personal data as the page shows it.",
|
|
1576
|
+
pressed: props.settingsOpen,
|
|
1577
|
+
onClick: props.onToggleSettings
|
|
1578
|
+
}
|
|
1579
|
+
),
|
|
1470
1580
|
/* @__PURE__ */ jsx3(Divider, {}),
|
|
1471
1581
|
/* @__PURE__ */ jsx3(
|
|
1472
1582
|
Tooltip,
|
|
@@ -1633,6 +1743,135 @@ function keyCaps(shortcut) {
|
|
|
1633
1743
|
return shortcut.split("+").map((key) => names[key] ?? key);
|
|
1634
1744
|
}
|
|
1635
1745
|
|
|
1746
|
+
// src/redaction-panel.tsx
|
|
1747
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1748
|
+
var LABEL = { ...FONT2, display: "flex", gap: 8, alignItems: "flex-start", cursor: "pointer" };
|
|
1749
|
+
function RedactionPanel(props) {
|
|
1750
|
+
const { settings } = props;
|
|
1751
|
+
const off = !settings.enabled;
|
|
1752
|
+
const update = (patch) => props.onChange({ ...settings, ...patch });
|
|
1753
|
+
const toggleCountry = (country, on) => update({ countries: COUNTRIES.filter((each) => each === country ? on : settings.countries.includes(each)) });
|
|
1754
|
+
const errors = settings.patterns.flatMap((source, index) => {
|
|
1755
|
+
if (source.trim() === "") return [];
|
|
1756
|
+
const compiled = compilePattern(source);
|
|
1757
|
+
return typeof compiled === "string" ? [`Line ${index + 1}: ${compiled}`] : [];
|
|
1758
|
+
});
|
|
1759
|
+
return /* @__PURE__ */ jsxs3(
|
|
1760
|
+
"div",
|
|
1761
|
+
{
|
|
1762
|
+
role: "dialog",
|
|
1763
|
+
"aria-label": "Redaction settings",
|
|
1764
|
+
style: {
|
|
1765
|
+
...FONT2,
|
|
1766
|
+
position: "fixed",
|
|
1767
|
+
right: 16,
|
|
1768
|
+
bottom: 72,
|
|
1769
|
+
width: 340,
|
|
1770
|
+
maxHeight: "70vh",
|
|
1771
|
+
overflowY: "auto",
|
|
1772
|
+
background: "#FFFFFF",
|
|
1773
|
+
border: `1px solid ${LINE}`,
|
|
1774
|
+
borderRadius: 10,
|
|
1775
|
+
boxShadow: "0 8px 24px rgba(0,0,0,0.18)",
|
|
1776
|
+
zIndex: Z + 2,
|
|
1777
|
+
boxSizing: "border-box"
|
|
1778
|
+
},
|
|
1779
|
+
children: [
|
|
1780
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", alignItems: "center", padding: "8px 10px", borderBottom: `1px solid ${LINE}` }, children: [
|
|
1781
|
+
/* @__PURE__ */ jsx4("strong", { style: { ...FONT2, fontWeight: 600 }, children: "Personal data redaction" }),
|
|
1782
|
+
/* @__PURE__ */ jsx4("button", { type: "button", onClick: props.onClose, "aria-label": "Close redaction settings", style: { ...BUTTON, marginLeft: "auto", padding: "2px 8px" }, children: "Close" })
|
|
1783
|
+
] }),
|
|
1784
|
+
/* @__PURE__ */ jsxs3("div", { style: { ...FONT2, padding: 10, display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
1785
|
+
/* @__PURE__ */ jsxs3("label", { style: { ...LABEL, alignItems: "center" }, children: [
|
|
1786
|
+
/* @__PURE__ */ jsx4(
|
|
1787
|
+
"input",
|
|
1788
|
+
{
|
|
1789
|
+
type: "checkbox",
|
|
1790
|
+
role: "switch",
|
|
1791
|
+
checked: settings.enabled,
|
|
1792
|
+
"aria-checked": settings.enabled,
|
|
1793
|
+
onChange: (event) => update({ enabled: event.target.checked })
|
|
1794
|
+
}
|
|
1795
|
+
),
|
|
1796
|
+
/* @__PURE__ */ jsx4("span", { style: { ...FONT2, fontWeight: 600 }, children: "Redact personal data" })
|
|
1797
|
+
] }),
|
|
1798
|
+
/* @__PURE__ */ jsx4("p", { style: { ...FONT2, margin: 0, fontSize: 12, color: off ? "#B42318" : MUTED }, children: off ? "Off: new comments carry props, state and page text exactly as the page shows them. Password fields stay hidden." : "Values under keys like phone, email, name, address, ID, password or token, and every e-mail address, become [redacted]." }),
|
|
1799
|
+
/* @__PURE__ */ jsxs3("fieldset", { disabled: off, style: { ...FONT2, margin: 0, padding: 0, border: 0, opacity: off ? 0.5 : 1 }, children: [
|
|
1800
|
+
/* @__PURE__ */ jsx4("legend", { style: { ...FONT2, padding: 0, marginBottom: 6, fontWeight: 600 }, children: "Number formats" }),
|
|
1801
|
+
/* @__PURE__ */ jsx4("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: COUNTRIES.map((country) => /* @__PURE__ */ jsxs3("label", { style: LABEL, children: [
|
|
1802
|
+
/* @__PURE__ */ jsx4(
|
|
1803
|
+
"input",
|
|
1804
|
+
{
|
|
1805
|
+
type: "checkbox",
|
|
1806
|
+
checked: settings.countries.includes(country),
|
|
1807
|
+
onChange: (event) => toggleCountry(country, event.target.checked),
|
|
1808
|
+
style: { marginTop: 3 }
|
|
1809
|
+
}
|
|
1810
|
+
),
|
|
1811
|
+
/* @__PURE__ */ jsxs3("span", { style: FONT2, children: [
|
|
1812
|
+
COUNTRY_RULES[country].label,
|
|
1813
|
+
/* @__PURE__ */ jsx4("span", { style: { ...FONT2, display: "block", fontSize: 11, color: MUTED }, children: COUNTRY_RULES[country].covers })
|
|
1814
|
+
] })
|
|
1815
|
+
] }, country)) })
|
|
1816
|
+
] }),
|
|
1817
|
+
/* @__PURE__ */ jsxs3("fieldset", { disabled: off, style: { ...FONT2, margin: 0, padding: 0, border: 0, opacity: off ? 0.5 : 1 }, children: [
|
|
1818
|
+
/* @__PURE__ */ jsx4("legend", { style: { ...FONT2, padding: 0, marginBottom: 4, fontWeight: 600 }, children: "Your own patterns" }),
|
|
1819
|
+
/* @__PURE__ */ jsxs3("label", { htmlFor: "agent-annotator-patterns", style: { ...FONT2, display: "block", fontSize: 11, color: MUTED, marginBottom: 4 }, children: [
|
|
1820
|
+
"One regular expression per line, e.g. ",
|
|
1821
|
+
/* @__PURE__ */ jsxs3("code", { children: [
|
|
1822
|
+
"INV-\\d",
|
|
1823
|
+
"{6}"
|
|
1824
|
+
] }),
|
|
1825
|
+
" or ",
|
|
1826
|
+
/* @__PURE__ */ jsx4("code", { children: "/acct[0-9]+/i" }),
|
|
1827
|
+
"."
|
|
1828
|
+
] }),
|
|
1829
|
+
/* @__PURE__ */ jsx4(
|
|
1830
|
+
"textarea",
|
|
1831
|
+
{
|
|
1832
|
+
id: "agent-annotator-patterns",
|
|
1833
|
+
value: settings.patterns.join("\n"),
|
|
1834
|
+
onChange: (event) => update({ patterns: event.target.value === "" ? [] : event.target.value.split("\n") }),
|
|
1835
|
+
rows: 3,
|
|
1836
|
+
spellCheck: false,
|
|
1837
|
+
"aria-invalid": errors.length > 0,
|
|
1838
|
+
style: {
|
|
1839
|
+
...FONT2,
|
|
1840
|
+
width: "100%",
|
|
1841
|
+
boxSizing: "border-box",
|
|
1842
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
1843
|
+
fontSize: 12,
|
|
1844
|
+
padding: 6,
|
|
1845
|
+
border: `1px solid ${errors.length > 0 ? "#B42318" : LINE}`,
|
|
1846
|
+
borderRadius: 6,
|
|
1847
|
+
resize: "vertical"
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
),
|
|
1851
|
+
errors.length > 0 ? /* @__PURE__ */ jsx4("ul", { role: "alert", style: { ...FONT2, margin: "4px 0 0", paddingLeft: 16, fontSize: 11, color: "#B42318" }, children: errors.map((error) => /* @__PURE__ */ jsxs3("li", { children: [
|
|
1852
|
+
error,
|
|
1853
|
+
" \u2014 skipped"
|
|
1854
|
+
] }, error)) }) : null
|
|
1855
|
+
] }),
|
|
1856
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
1857
|
+
/* @__PURE__ */ jsx4("span", { style: { ...FONT2, flex: 1, fontSize: 11, color: MUTED }, children: "Applies to comments made from now on. Saved in this browser." }),
|
|
1858
|
+
/* @__PURE__ */ jsx4(
|
|
1859
|
+
"button",
|
|
1860
|
+
{
|
|
1861
|
+
type: "button",
|
|
1862
|
+
onClick: props.onReset,
|
|
1863
|
+
disabled: !props.customised,
|
|
1864
|
+
style: { ...BUTTON, color: props.customised ? ACCENT : MUTED, cursor: props.customised ? "pointer" : "default" },
|
|
1865
|
+
children: "Use app defaults"
|
|
1866
|
+
}
|
|
1867
|
+
)
|
|
1868
|
+
] })
|
|
1869
|
+
] })
|
|
1870
|
+
]
|
|
1871
|
+
}
|
|
1872
|
+
);
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1636
1875
|
// src/page-tools.ts
|
|
1637
1876
|
var OWN_SELECTOR = "[data-dev-annotator]";
|
|
1638
1877
|
var MAX_AREA_ELEMENTS = 8;
|
|
@@ -1694,11 +1933,11 @@ function buildPrompt(annotations, options) {
|
|
|
1694
1933
|
const first = annotations[0]?.targets[0]?.page;
|
|
1695
1934
|
const origin = first === void 0 ? "" : new URL(first.url).origin;
|
|
1696
1935
|
const lines = [
|
|
1697
|
-
`#
|
|
1936
|
+
`# Change requests: ${options.appName} (${annotations.length} ${annotations.length === 1 ? "comment" : "comments"})`,
|
|
1698
1937
|
"",
|
|
1699
1938
|
`Dev environment ${origin}, recorded ${formatTime(options.now)}.` + (options.appDir ? ` The app lives in \`${options.appDir}\`; file paths are from the repo root.` : ""),
|
|
1700
1939
|
"",
|
|
1701
|
-
"Work through the comments below one by one. Each names the selected element, where its JSX is in the source, the components around it" + (options.includeData ? ", and their props/state when the comment was made" : "") + `. The element's JSX location is exact; a component's "rendered at" location may point at an earlier render branch when React reused the component, so check it against the code. Open the source file before editing. If the line numbers have drifted, search by selector, element text and component name.
|
|
1940
|
+
"Work through the comments below one by one. Each names the selected element, where its JSX is in the source, the components around it" + (options.includeData ? ", and their props/state when the comment was made" : "") + `. The element's JSX location is exact; a component's "rendered at" location may point at an earlier render branch when React reused the component, so check it against the code. Open the source file before editing. If the line numbers have drifted, search by selector, element text and component name. ` + redactionNote(annotations) + "When done, summarise the changes by comment number."
|
|
1702
1941
|
];
|
|
1703
1942
|
annotations.forEach((annotation, index) => {
|
|
1704
1943
|
lines.push("", "---", "", ...section(annotation, index + 1, options));
|
|
@@ -1706,6 +1945,12 @@ function buildPrompt(annotations, options) {
|
|
|
1706
1945
|
return `${lines.join("\n")}
|
|
1707
1946
|
`;
|
|
1708
1947
|
}
|
|
1948
|
+
function redactionNote(annotations) {
|
|
1949
|
+
const raw = annotations.flatMap((annotation, index) => annotation.redacted === false ? [index + 1] : []);
|
|
1950
|
+
if (raw.length === annotations.length && raw.length > 0) return "";
|
|
1951
|
+
const except = raw.length === 0 ? "" : ` (except in comment${raw.length === 1 ? "" : "s"} ${raw.join(", ")}, recorded with redaction off)`;
|
|
1952
|
+
return `Personal data has been replaced with \`${REDACTED}\`${except}; never treat it as a real value. `;
|
|
1953
|
+
}
|
|
1709
1954
|
var KIND_NOTE = {
|
|
1710
1955
|
element: null,
|
|
1711
1956
|
text: null,
|
|
@@ -1935,13 +2180,13 @@ import {
|
|
|
1935
2180
|
} from "react";
|
|
1936
2181
|
|
|
1937
2182
|
// src/callout-tip.tsx
|
|
1938
|
-
import { jsx as
|
|
2183
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1939
2184
|
var FONT3 = 'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
|
|
1940
2185
|
var RED = "#E5484D";
|
|
1941
2186
|
var LOOP = "3.2s";
|
|
1942
2187
|
var KEY_TIMES = "0;0.12;0.55;0.85;1";
|
|
1943
2188
|
function CalloutTip(props) {
|
|
1944
|
-
return /* @__PURE__ */
|
|
2189
|
+
return /* @__PURE__ */ jsxs4(
|
|
1945
2190
|
"div",
|
|
1946
2191
|
{
|
|
1947
2192
|
role: "note",
|
|
@@ -1961,7 +2206,7 @@ function CalloutTip(props) {
|
|
|
1961
2206
|
zIndex: 2
|
|
1962
2207
|
},
|
|
1963
2208
|
children: [
|
|
1964
|
-
/* @__PURE__ */
|
|
2209
|
+
/* @__PURE__ */ jsx5(
|
|
1965
2210
|
"span",
|
|
1966
2211
|
{
|
|
1967
2212
|
"aria-hidden": "true",
|
|
@@ -1978,10 +2223,10 @@ function CalloutTip(props) {
|
|
|
1978
2223
|
}
|
|
1979
2224
|
}
|
|
1980
2225
|
),
|
|
1981
|
-
/* @__PURE__ */
|
|
1982
|
-
/* @__PURE__ */
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
2226
|
+
/* @__PURE__ */ jsx5(Demo, {}),
|
|
2227
|
+
/* @__PURE__ */ jsx5("strong", { style: { display: "block", marginTop: 10, font: `600 13px/1.35 ${FONT3}`, color: "#FFFFFF" }, children: props.nudge ? "Tip: drag instead of clicking" : "Drag to point at something" }),
|
|
2228
|
+
/* @__PURE__ */ jsx5("span", { style: { display: "block", marginTop: 4, color: "#C9C5BE" }, children: props.nudge ? "Press on what you mean and drag to where the text goes: the box gets a tail pointing there." : "Press on what you mean, drag to where the text goes, then type. A plain click makes a box without a tail." }),
|
|
2229
|
+
/* @__PURE__ */ jsx5(
|
|
1985
2230
|
"button",
|
|
1986
2231
|
{
|
|
1987
2232
|
type: "button",
|
|
@@ -2007,24 +2252,24 @@ function CalloutTip(props) {
|
|
|
2007
2252
|
function Demo() {
|
|
2008
2253
|
const x = "52;52;172;172;52";
|
|
2009
2254
|
const y = "70;70;27;27;70";
|
|
2010
|
-
return /* @__PURE__ */
|
|
2011
|
-
/* @__PURE__ */
|
|
2012
|
-
/* @__PURE__ */
|
|
2013
|
-
/* @__PURE__ */
|
|
2014
|
-
/* @__PURE__ */
|
|
2015
|
-
/* @__PURE__ */
|
|
2016
|
-
/* @__PURE__ */
|
|
2017
|
-
/* @__PURE__ */
|
|
2255
|
+
return /* @__PURE__ */ jsxs4("svg", { width: "240", height: "96", viewBox: "0 0 240 96", "aria-hidden": "true", style: { display: "block", borderRadius: 6, background: "#F6F3EE" }, children: [
|
|
2256
|
+
/* @__PURE__ */ jsx5("rect", { x: "16", y: "56", width: "74", height: "28", rx: "4", fill: "#E6E0D6" }),
|
|
2257
|
+
/* @__PURE__ */ jsx5("rect", { x: "24", y: "64", width: "40", height: "5", rx: "2", fill: "#B9B2A6" }),
|
|
2258
|
+
/* @__PURE__ */ jsx5("rect", { x: "24", y: "73", width: "56", height: "4", rx: "2", fill: "#CFC8BC" }),
|
|
2259
|
+
/* @__PURE__ */ jsxs4("line", { x1: "52", y1: "70", x2: "52", y2: "70", stroke: RED, strokeWidth: "3", strokeLinecap: "round", children: [
|
|
2260
|
+
/* @__PURE__ */ jsx5("animate", { attributeName: "x2", values: x, keyTimes: KEY_TIMES, dur: LOOP, repeatCount: "indefinite" }),
|
|
2261
|
+
/* @__PURE__ */ jsx5("animate", { attributeName: "y2", values: y, keyTimes: KEY_TIMES, dur: LOOP, repeatCount: "indefinite" }),
|
|
2262
|
+
/* @__PURE__ */ jsx5("animate", { attributeName: "opacity", values: "0;1;1;1;0", keyTimes: KEY_TIMES, dur: LOOP, calcMode: "discrete", repeatCount: "indefinite" })
|
|
2018
2263
|
] }),
|
|
2019
|
-
/* @__PURE__ */
|
|
2020
|
-
/* @__PURE__ */
|
|
2021
|
-
/* @__PURE__ */
|
|
2022
|
-
/* @__PURE__ */
|
|
2264
|
+
/* @__PURE__ */ jsxs4("g", { opacity: "0", children: [
|
|
2265
|
+
/* @__PURE__ */ jsx5("rect", { x: "128", y: "13", width: "92", height: "28", rx: "5", fill: RED }),
|
|
2266
|
+
/* @__PURE__ */ jsx5("text", { x: "174", y: "31.5", textAnchor: "middle", fill: "#FFFFFF", style: { font: `600 12px ${FONT3}` }, children: "Too tight" }),
|
|
2267
|
+
/* @__PURE__ */ jsx5("animate", { attributeName: "opacity", values: "0;0;1;0;0", keyTimes: KEY_TIMES, dur: LOOP, calcMode: "discrete", repeatCount: "indefinite" })
|
|
2023
2268
|
] }),
|
|
2024
|
-
/* @__PURE__ */
|
|
2025
|
-
/* @__PURE__ */
|
|
2026
|
-
/* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
2269
|
+
/* @__PURE__ */ jsx5("circle", { cx: "52", cy: "70", r: "0", fill: "none", stroke: "#1F1E1D", strokeWidth: "1.5", children: /* @__PURE__ */ jsx5("animate", { attributeName: "r", values: "0;11;0;0;0", keyTimes: KEY_TIMES, dur: LOOP, repeatCount: "indefinite" }) }),
|
|
2270
|
+
/* @__PURE__ */ jsxs4("g", { children: [
|
|
2271
|
+
/* @__PURE__ */ jsx5("path", { d: "M0 0 L0 15 L4 11 L7 18 L10 17 L7 10 L12 10 Z", fill: "#FFFFFF", stroke: "#1F1E1D", strokeWidth: "1.2", strokeLinejoin: "round" }),
|
|
2272
|
+
/* @__PURE__ */ jsx5("animateTransform", { attributeName: "transform", type: "translate", values: "52 70;52 70;172 27;172 27;52 70", keyTimes: KEY_TIMES, dur: LOOP, repeatCount: "indefinite" })
|
|
2028
2273
|
] })
|
|
2029
2274
|
] });
|
|
2030
2275
|
}
|
|
@@ -2486,7 +2731,7 @@ function drawMark(context, base, mark, width, imageWidth, pixelRatio) {
|
|
|
2486
2731
|
}
|
|
2487
2732
|
|
|
2488
2733
|
// src/screenshot-editor.tsx
|
|
2489
|
-
import { jsx as
|
|
2734
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2490
2735
|
var TOOLS = [
|
|
2491
2736
|
{ tool: "select", icon: "select", label: "Select & move", key: "V", detail: "Click a mark to select it, drag to move it, Delete to remove it. Double-click text to edit it." },
|
|
2492
2737
|
{ tool: "arrow", icon: "arrow", label: "Arrow", key: "A", detail: "Hold Shift to snap to 45\xB0." },
|
|
@@ -2983,7 +3228,7 @@ function ScreenshotEditor(props) {
|
|
|
2983
3228
|
const cursor = panning ? "grabbing" : spaceHeld ? "grab" : tool === "select" ? drag !== null ? "grabbing" : hovering ? "move" : "default" : "crosshair";
|
|
2984
3229
|
const custom = !COLORS.includes(color.toUpperCase());
|
|
2985
3230
|
const textLayout = text === null ? null : calloutLayout({ at: text.at, text: text.value, weight: text.weight }, image.width, measureText());
|
|
2986
|
-
return /* @__PURE__ */
|
|
3231
|
+
return /* @__PURE__ */ jsxs5(
|
|
2987
3232
|
"div",
|
|
2988
3233
|
{
|
|
2989
3234
|
ref: dialogRef,
|
|
@@ -2992,14 +3237,14 @@ function ScreenshotEditor(props) {
|
|
|
2992
3237
|
"aria-label": "Screenshot editor",
|
|
2993
3238
|
style: { ...FONT2, position: "fixed", inset: 0, display: "flex", flexDirection: "column", background: "#0E0E0E", zIndex: Z + 5 },
|
|
2994
3239
|
children: [
|
|
2995
|
-
/* @__PURE__ */
|
|
3240
|
+
/* @__PURE__ */ jsxs5(
|
|
2996
3241
|
"div",
|
|
2997
3242
|
{
|
|
2998
3243
|
role: "toolbar",
|
|
2999
3244
|
"aria-label": "Markup tools",
|
|
3000
3245
|
style: { display: "flex", alignItems: "center", gap: 2, padding: "8px 12px", background: INK, borderBottom: "1px solid rgba(255,255,255,0.12)", flexWrap: "wrap", rowGap: 6 },
|
|
3001
3246
|
children: [
|
|
3002
|
-
TOOLS.map((entry) => /* @__PURE__ */
|
|
3247
|
+
TOOLS.map((entry) => /* @__PURE__ */ jsx6(
|
|
3003
3248
|
BarButton,
|
|
3004
3249
|
{
|
|
3005
3250
|
icon: entry.icon,
|
|
@@ -3011,8 +3256,8 @@ function ScreenshotEditor(props) {
|
|
|
3011
3256
|
},
|
|
3012
3257
|
entry.tool
|
|
3013
3258
|
)),
|
|
3014
|
-
/* @__PURE__ */
|
|
3015
|
-
COLORS.map((swatch) => /* @__PURE__ */
|
|
3259
|
+
/* @__PURE__ */ jsx6(Divider2, {}),
|
|
3260
|
+
COLORS.map((swatch) => /* @__PURE__ */ jsx6(Tooltip, { label: COLOR_NAMES[swatch] ?? swatch, placement: "below", children: (describedBy) => /* @__PURE__ */ jsx6(
|
|
3016
3261
|
"button",
|
|
3017
3262
|
{
|
|
3018
3263
|
type: "button",
|
|
@@ -3023,8 +3268,8 @@ function ScreenshotEditor(props) {
|
|
|
3023
3268
|
style: swatchStyle(swatch, color.toUpperCase() === swatch)
|
|
3024
3269
|
}
|
|
3025
3270
|
) }, swatch)),
|
|
3026
|
-
/* @__PURE__ */
|
|
3027
|
-
/* @__PURE__ */
|
|
3271
|
+
/* @__PURE__ */ jsx6(Tooltip, { label: "Custom colour", detail: "Pick any colour.", placement: "below", children: (describedBy) => /* @__PURE__ */ jsxs5("span", { style: { position: "relative", display: "inline-flex" }, children: [
|
|
3272
|
+
/* @__PURE__ */ jsx6(
|
|
3028
3273
|
"span",
|
|
3029
3274
|
{
|
|
3030
3275
|
"aria-hidden": "true",
|
|
@@ -3034,7 +3279,7 @@ function ScreenshotEditor(props) {
|
|
|
3034
3279
|
}
|
|
3035
3280
|
}
|
|
3036
3281
|
),
|
|
3037
|
-
/* @__PURE__ */
|
|
3282
|
+
/* @__PURE__ */ jsx6(
|
|
3038
3283
|
"input",
|
|
3039
3284
|
{
|
|
3040
3285
|
ref: customColorRef,
|
|
@@ -3047,8 +3292,8 @@ function ScreenshotEditor(props) {
|
|
|
3047
3292
|
}
|
|
3048
3293
|
)
|
|
3049
3294
|
] }) }),
|
|
3050
|
-
/* @__PURE__ */
|
|
3051
|
-
WEIGHTS.map((entry) => /* @__PURE__ */
|
|
3295
|
+
/* @__PURE__ */ jsx6(Divider2, {}),
|
|
3296
|
+
WEIGHTS.map((entry) => /* @__PURE__ */ jsx6(Tooltip, { label: `${entry.label} stroke`, shortcut: [String(entry.weight)], placement: "below", children: (describedBy) => /* @__PURE__ */ jsx6(
|
|
3052
3297
|
"button",
|
|
3053
3298
|
{
|
|
3054
3299
|
type: "button",
|
|
@@ -3057,13 +3302,13 @@ function ScreenshotEditor(props) {
|
|
|
3057
3302
|
"aria-describedby": describedBy,
|
|
3058
3303
|
"aria-pressed": weight === entry.weight,
|
|
3059
3304
|
style: { ...iconButton(weight === entry.weight), width: 30, minWidth: 30 },
|
|
3060
|
-
children: /* @__PURE__ */
|
|
3305
|
+
children: /* @__PURE__ */ jsx6("span", { "aria-hidden": "true", style: { width: entry.dot, height: entry.dot, borderRadius: entry.dot, background: "#FFFFFF" } })
|
|
3061
3306
|
}
|
|
3062
3307
|
) }, entry.weight)),
|
|
3063
|
-
/* @__PURE__ */
|
|
3064
|
-
/* @__PURE__ */
|
|
3065
|
-
/* @__PURE__ */
|
|
3066
|
-
/* @__PURE__ */
|
|
3308
|
+
/* @__PURE__ */ jsx6(Divider2, {}),
|
|
3309
|
+
/* @__PURE__ */ jsx6(BarButton, { icon: "undo", label: "Undo", shortcut: [MOD_KEY, "Z"], disabled: history.past.length === 0, onClick: undo }),
|
|
3310
|
+
/* @__PURE__ */ jsx6(BarButton, { icon: "redo", label: "Redo", shortcut: [MOD_KEY, "\u21E7", "Z"], disabled: history.future.length === 0, onClick: redo }),
|
|
3311
|
+
/* @__PURE__ */ jsx6(
|
|
3067
3312
|
BarButton,
|
|
3068
3313
|
{
|
|
3069
3314
|
icon: "eraser",
|
|
@@ -3078,8 +3323,8 @@ function ScreenshotEditor(props) {
|
|
|
3078
3323
|
}
|
|
3079
3324
|
}
|
|
3080
3325
|
),
|
|
3081
|
-
/* @__PURE__ */
|
|
3082
|
-
/* @__PURE__ */
|
|
3326
|
+
/* @__PURE__ */ jsx6(BarButton, { icon: "trash", label: "Clear all marks", disabled: marks.length === 0, onClick: () => commit(NO_MARKS) }),
|
|
3327
|
+
/* @__PURE__ */ jsx6(
|
|
3083
3328
|
BarButton,
|
|
3084
3329
|
{
|
|
3085
3330
|
icon: "cropOff",
|
|
@@ -3089,9 +3334,9 @@ function ScreenshotEditor(props) {
|
|
|
3089
3334
|
onClick: () => commitCrop(null)
|
|
3090
3335
|
}
|
|
3091
3336
|
),
|
|
3092
|
-
/* @__PURE__ */
|
|
3093
|
-
/* @__PURE__ */
|
|
3094
|
-
/* @__PURE__ */
|
|
3337
|
+
/* @__PURE__ */ jsx6("span", { style: { flex: 1, minWidth: 8 } }),
|
|
3338
|
+
/* @__PURE__ */ jsx6(BarButton, { icon: "zoomOut", label: "Zoom out", shortcut: [MOD_KEY, "\u2212"], disabled: percent <= MIN_ZOOM * 1.01, onClick: () => zoomStep(-1) }),
|
|
3339
|
+
/* @__PURE__ */ jsx6(Tooltip, { label: zoom === null ? "Actual size" : "Fit to window", shortcut: zoom === null ? [MOD_KEY, "1"] : [MOD_KEY, "0"], placement: "below", children: (describedBy) => /* @__PURE__ */ jsx6(
|
|
3095
3340
|
"button",
|
|
3096
3341
|
{
|
|
3097
3342
|
type: "button",
|
|
@@ -3099,18 +3344,18 @@ function ScreenshotEditor(props) {
|
|
|
3099
3344
|
"aria-label": `Zoom ${Math.round(percent * 100)}%`,
|
|
3100
3345
|
"aria-describedby": describedBy,
|
|
3101
3346
|
style: { ...iconButton(false), minWidth: 54, padding: "0 6px", fontVariantNumeric: "tabular-nums" },
|
|
3102
|
-
children: /* @__PURE__ */
|
|
3347
|
+
children: /* @__PURE__ */ jsxs5("span", { style: { ...FONT2, color: "inherit", fontWeight: 600, fontSize: 12 }, children: [
|
|
3103
3348
|
Math.round(percent * 100),
|
|
3104
3349
|
"%"
|
|
3105
3350
|
] })
|
|
3106
3351
|
}
|
|
3107
3352
|
) }),
|
|
3108
|
-
/* @__PURE__ */
|
|
3109
|
-
/* @__PURE__ */
|
|
3110
|
-
/* @__PURE__ */
|
|
3111
|
-
/* @__PURE__ */
|
|
3112
|
-
/* @__PURE__ */
|
|
3113
|
-
/* @__PURE__ */
|
|
3353
|
+
/* @__PURE__ */ jsx6(BarButton, { icon: "zoomIn", label: "Zoom in", shortcut: [MOD_KEY, "+"], disabled: percent >= MAX_ZOOM * 0.99, onClick: () => zoomStep(1) }),
|
|
3354
|
+
/* @__PURE__ */ jsx6(BarButton, { icon: "fit", label: "Fit to window", shortcut: [MOD_KEY, "0"], pressed: zoom === null, onClick: () => zoomTo(null) }),
|
|
3355
|
+
/* @__PURE__ */ jsx6(Divider2, {}),
|
|
3356
|
+
/* @__PURE__ */ jsx6(BarButton, { icon: "copy", label: "Copy image", shortcut: [MOD_KEY, "C"], text: "Copy", primary: true, onClick: () => void run("copy") }),
|
|
3357
|
+
/* @__PURE__ */ jsx6(BarButton, { icon: "download", label: "Save as PNG", detail: fileName, shortcut: [MOD_KEY, "S"], text: "Save", onClick: () => void run("save") }),
|
|
3358
|
+
/* @__PURE__ */ jsx6(
|
|
3114
3359
|
BarButton,
|
|
3115
3360
|
{
|
|
3116
3361
|
icon: "close",
|
|
@@ -3124,9 +3369,9 @@ function ScreenshotEditor(props) {
|
|
|
3124
3369
|
]
|
|
3125
3370
|
}
|
|
3126
3371
|
),
|
|
3127
|
-
showTip && tipAt !== null ? /* @__PURE__ */
|
|
3128
|
-
/* @__PURE__ */
|
|
3129
|
-
/* @__PURE__ */
|
|
3372
|
+
showTip && tipAt !== null ? /* @__PURE__ */ jsx6(CalloutTip, { left: tipAt.left, top: tipAt.top, nudge: tipNudge, onDismiss: learnCallout }) : null,
|
|
3373
|
+
/* @__PURE__ */ jsx6("div", { ref: areaRef, style: { position: "relative", flex: 1, minHeight: 0, overflow: "auto" }, children: /* @__PURE__ */ jsx6("div", { style: { display: "flex", minWidth: "100%", minHeight: "100%", width: "max-content", height: "max-content" }, children: /* @__PURE__ */ jsxs5("div", { style: { position: "relative", margin: "auto", width: board.width * scale, height: board.height * scale, flex: "none" }, children: [
|
|
3374
|
+
/* @__PURE__ */ jsx6(
|
|
3130
3375
|
"canvas",
|
|
3131
3376
|
{
|
|
3132
3377
|
ref: canvasRef,
|
|
@@ -3150,7 +3395,7 @@ function ScreenshotEditor(props) {
|
|
|
3150
3395
|
}
|
|
3151
3396
|
}
|
|
3152
3397
|
),
|
|
3153
|
-
text === null || textLayout === null ? null : /* @__PURE__ */
|
|
3398
|
+
text === null || textLayout === null ? null : /* @__PURE__ */ jsx6(
|
|
3154
3399
|
"textarea",
|
|
3155
3400
|
{
|
|
3156
3401
|
"aria-label": "Callout text",
|
|
@@ -3194,7 +3439,7 @@ function ScreenshotEditor(props) {
|
|
|
3194
3439
|
}
|
|
3195
3440
|
)
|
|
3196
3441
|
] }) }) }),
|
|
3197
|
-
/* @__PURE__ */
|
|
3442
|
+
/* @__PURE__ */ jsx6(
|
|
3198
3443
|
"div",
|
|
3199
3444
|
{
|
|
3200
3445
|
"aria-hidden": "true",
|
|
@@ -3249,10 +3494,10 @@ function iconButton(pressed) {
|
|
|
3249
3494
|
};
|
|
3250
3495
|
}
|
|
3251
3496
|
function Divider2() {
|
|
3252
|
-
return /* @__PURE__ */
|
|
3497
|
+
return /* @__PURE__ */ jsx6("span", { "aria-hidden": "true", style: { width: 1, height: 20, margin: "0 6px", background: "rgba(255,255,255,0.18)" } });
|
|
3253
3498
|
}
|
|
3254
3499
|
function BarButton(props) {
|
|
3255
|
-
return /* @__PURE__ */
|
|
3500
|
+
return /* @__PURE__ */ jsx6(Tooltip, { label: props.label, ...props.detail === void 0 ? {} : { detail: props.detail }, ...props.shortcut === void 0 ? {} : { shortcut: props.shortcut }, placement: "below", children: (describedBy) => /* @__PURE__ */ jsxs5(
|
|
3256
3501
|
"button",
|
|
3257
3502
|
{
|
|
3258
3503
|
type: "button",
|
|
@@ -3269,8 +3514,8 @@ function BarButton(props) {
|
|
|
3269
3514
|
background: props.danger ? "#B42318" : props.primary ? ACCENT : props.pressed ? "rgba(255,255,255,0.2)" : "transparent"
|
|
3270
3515
|
},
|
|
3271
3516
|
children: [
|
|
3272
|
-
/* @__PURE__ */
|
|
3273
|
-
props.text === void 0 ? null : /* @__PURE__ */
|
|
3517
|
+
/* @__PURE__ */ jsx6(Icon, { name: props.icon }),
|
|
3518
|
+
props.text === void 0 ? null : /* @__PURE__ */ jsx6("span", { style: { ...FONT2, color: "inherit", fontWeight: 600 }, children: props.text })
|
|
3274
3519
|
]
|
|
3275
3520
|
}
|
|
3276
3521
|
) });
|
|
@@ -3309,7 +3554,7 @@ function boardAround(content, image, area, scale) {
|
|
|
3309
3554
|
}
|
|
3310
3555
|
|
|
3311
3556
|
// src/annotator.tsx
|
|
3312
|
-
import { jsx as
|
|
3557
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3313
3558
|
var ISOLATED = ["pointerdown", "pointerup", "mousedown", "mouseup", "dblclick"];
|
|
3314
3559
|
var REFLOW_MS = 400;
|
|
3315
3560
|
var MIN_AREA = 8;
|
|
@@ -3326,6 +3571,13 @@ var KIND_LABEL = {
|
|
|
3326
3571
|
function DevAnnotator(props) {
|
|
3327
3572
|
const { appName, appDir } = props;
|
|
3328
3573
|
const storageKey = `agent-annotator:${appName}`;
|
|
3574
|
+
const redactionKey = `agent-annotator:redaction:${appName}`;
|
|
3575
|
+
const redactionDefaults = resolveRedaction(props.redaction);
|
|
3576
|
+
const [savedRedaction, setSavedRedaction] = useState3(() => readRedaction(redactionKey));
|
|
3577
|
+
const redaction = savedRedaction ?? redactionDefaults;
|
|
3578
|
+
const redactionJson = JSON.stringify(redaction);
|
|
3579
|
+
const redactor = useMemo(() => createRedactor(JSON.parse(redactionJson)), [redactionJson]);
|
|
3580
|
+
const [settingsOpen, setSettingsOpen] = useState3(false);
|
|
3329
3581
|
const [resolveFrames] = useState3(() => props.resolveFrames ?? createNextResolver());
|
|
3330
3582
|
const [active, setActive] = useState3(false);
|
|
3331
3583
|
const [items, setItems] = useState3(() => restore(storageKey));
|
|
@@ -3363,12 +3615,13 @@ function DevAnnotator(props) {
|
|
|
3363
3615
|
const several = selection.elements.length > 1;
|
|
3364
3616
|
const captures = Promise.all(
|
|
3365
3617
|
selection.elements.map(
|
|
3366
|
-
(element) => captureElement(element, resolveFrames, { dataComponents: several ? 1 : 2 })
|
|
3618
|
+
(element) => captureElement(element, resolveFrames, { dataComponents: several ? 1 : 2, redactor })
|
|
3367
3619
|
)
|
|
3368
3620
|
);
|
|
3369
|
-
|
|
3621
|
+
const screened = selection.selectedText === void 0 ? {} : { selectedText: truncate(redactor.text(selection.selectedText), 500) };
|
|
3622
|
+
setDraft({ ...selection, ...screened, captures, comment: "", redacted: redactor.enabled, editingId: null });
|
|
3370
3623
|
},
|
|
3371
|
-
[resolveFrames]
|
|
3624
|
+
[resolveFrames, redactor]
|
|
3372
3625
|
);
|
|
3373
3626
|
useEffect3(() => {
|
|
3374
3627
|
if (!active) return void 0;
|
|
@@ -3537,7 +3790,8 @@ function DevAnnotator(props) {
|
|
|
3537
3790
|
targets,
|
|
3538
3791
|
...draft.selectedText === void 0 ? {} : { selectedText: draft.selectedText },
|
|
3539
3792
|
...draft.area === void 0 ? {} : { area: draft.area },
|
|
3540
|
-
...draft.areaInContainer === void 0 ? {} : { areaInContainer: draft.areaInContainer }
|
|
3793
|
+
...draft.areaInContainer === void 0 ? {} : { areaInContainer: draft.areaInContainer },
|
|
3794
|
+
...draft.redacted ? {} : { redacted: false }
|
|
3541
3795
|
};
|
|
3542
3796
|
setItems((current) => [...current, { annotation, elements: draft.elements }]);
|
|
3543
3797
|
setPanelOpen(true);
|
|
@@ -3557,6 +3811,7 @@ function DevAnnotator(props) {
|
|
|
3557
3811
|
...annotation.selectedText === void 0 ? {} : { selectedText: annotation.selectedText },
|
|
3558
3812
|
captures: Promise.resolve(annotation.targets),
|
|
3559
3813
|
comment: annotation.comment,
|
|
3814
|
+
redacted: annotation.redacted !== false,
|
|
3560
3815
|
editingId: id
|
|
3561
3816
|
});
|
|
3562
3817
|
};
|
|
@@ -3628,15 +3883,15 @@ function DevAnnotator(props) {
|
|
|
3628
3883
|
const item = items[number - 1];
|
|
3629
3884
|
if (item !== void 0) editItem(item.annotation.id);
|
|
3630
3885
|
};
|
|
3631
|
-
const overlay = capturing ? /* @__PURE__ */
|
|
3632
|
-
active && !hintHidden ? /* @__PURE__ */
|
|
3633
|
-
active && hover !== null && hover.element !== draftElement && dragBox === null ? /* @__PURE__ */
|
|
3634
|
-
group.map((element, index) => /* @__PURE__ */
|
|
3635
|
-
dragBox !== null ? /* @__PURE__ */
|
|
3636
|
-
draft?.area !== void 0 ? /* @__PURE__ */
|
|
3637
|
-
draft !== null && draft.kind !== "area" ? draft.elements.filter((element) => element.isConnected).map((element, index) => /* @__PURE__ */
|
|
3638
|
-
callouts !== null ? /* @__PURE__ */
|
|
3639
|
-
draft !== null ? /* @__PURE__ */
|
|
3886
|
+
const overlay = capturing ? /* @__PURE__ */ jsx7("div", { "data-dev-annotator": "", children: /* @__PURE__ */ jsx7(Callouts, { callouts: callouts ?? [], onEdit: null }) }) : /* @__PURE__ */ jsxs6("div", { "data-dev-annotator": "", children: [
|
|
3887
|
+
active && !hintHidden ? /* @__PURE__ */ jsx7(Hint, { onDismiss: () => hideHint(true) }) : null,
|
|
3888
|
+
active && hover !== null && hover.element !== draftElement && dragBox === null ? /* @__PURE__ */ jsx7(Highlight, { box: boxOf(hover.element), label: hover.label, strong: false }) : null,
|
|
3889
|
+
group.map((element, index) => /* @__PURE__ */ jsx7(Highlight, { box: boxOf(element), label: `#${index + 1}`, strong: true }, index)),
|
|
3890
|
+
dragBox !== null ? /* @__PURE__ */ jsx7(AreaBox, { box: { top: dragBox.y, left: dragBox.x, width: dragBox.width, height: dragBox.height } }) : null,
|
|
3891
|
+
draft?.area !== void 0 ? /* @__PURE__ */ jsx7(AreaBox, { box: { top: draft.area.y, left: draft.area.x, width: draft.area.width, height: draft.area.height } }) : null,
|
|
3892
|
+
draft !== null && draft.kind !== "area" ? draft.elements.filter((element) => element.isConnected).map((element, index) => /* @__PURE__ */ jsx7(Highlight, { box: boxOf(element), label: index === 0 ? draft.label : `#${index + 1}`, strong: true }, index)) : null,
|
|
3893
|
+
callouts !== null ? /* @__PURE__ */ jsx7(Callouts, { callouts, onEdit: editNumber }) : onScreen.map((target) => /* @__PURE__ */ jsx7(Pin, { box: target.box, number: target.number, onClick: () => editNumber(target.number) }, target.number)),
|
|
3894
|
+
draft !== null ? /* @__PURE__ */ jsx7(
|
|
3640
3895
|
Editor,
|
|
3641
3896
|
{
|
|
3642
3897
|
anchor: draft.area === void 0 ? draftBox : areaBox(draft.area),
|
|
@@ -3653,11 +3908,28 @@ function DevAnnotator(props) {
|
|
|
3653
3908
|
}
|
|
3654
3909
|
}
|
|
3655
3910
|
) : null,
|
|
3656
|
-
|
|
3911
|
+
settingsOpen && !collapsed ? /* @__PURE__ */ jsx7(
|
|
3912
|
+
RedactionPanel,
|
|
3913
|
+
{
|
|
3914
|
+
settings: redaction,
|
|
3915
|
+
customised: savedRedaction !== null,
|
|
3916
|
+
onChange: (next) => {
|
|
3917
|
+
setSavedRedaction(next);
|
|
3918
|
+
writeRedaction(redactionKey, next);
|
|
3919
|
+
},
|
|
3920
|
+
onReset: () => {
|
|
3921
|
+
setSavedRedaction(null);
|
|
3922
|
+
writeRedaction(redactionKey, null);
|
|
3923
|
+
},
|
|
3924
|
+
onClose: () => setSettingsOpen(false)
|
|
3925
|
+
}
|
|
3926
|
+
) : null,
|
|
3927
|
+
panelOpen && !settingsOpen && !collapsed && items.length > 0 ? /* @__PURE__ */ jsx7(
|
|
3657
3928
|
Panel,
|
|
3658
3929
|
{
|
|
3659
3930
|
entries,
|
|
3660
3931
|
includeData,
|
|
3932
|
+
redactionOn: redaction.enabled,
|
|
3661
3933
|
onIncludeData: setIncludeData,
|
|
3662
3934
|
onEdit: editItem,
|
|
3663
3935
|
onClear: () => {
|
|
@@ -3667,7 +3939,7 @@ function DevAnnotator(props) {
|
|
|
3667
3939
|
onClose: () => setPanelOpen(false)
|
|
3668
3940
|
}
|
|
3669
3941
|
) : null,
|
|
3670
|
-
/* @__PURE__ */
|
|
3942
|
+
/* @__PURE__ */ jsx7(
|
|
3671
3943
|
Toolbar,
|
|
3672
3944
|
{
|
|
3673
3945
|
active,
|
|
@@ -3677,6 +3949,9 @@ function DevAnnotator(props) {
|
|
|
3677
3949
|
showComments,
|
|
3678
3950
|
capturing,
|
|
3679
3951
|
collapsed,
|
|
3952
|
+
redactionOn: redaction.enabled,
|
|
3953
|
+
settingsOpen,
|
|
3954
|
+
onToggleSettings: () => setSettingsOpen(!settingsOpen),
|
|
3680
3955
|
onToggleCollapsed: () => {
|
|
3681
3956
|
setCollapsed(!collapsed);
|
|
3682
3957
|
writeFlag(COLLAPSED_KEY, !collapsed);
|
|
@@ -3690,8 +3965,8 @@ function DevAnnotator(props) {
|
|
|
3690
3965
|
onCopy: () => void copyPrompt()
|
|
3691
3966
|
}
|
|
3692
3967
|
),
|
|
3693
|
-
notice !== null ? /* @__PURE__ */
|
|
3694
|
-
shot !== null ? /* @__PURE__ */
|
|
3968
|
+
notice !== null ? /* @__PURE__ */ jsx7(Toast, { notice, onDismiss: () => setNotice(null) }) : null,
|
|
3969
|
+
shot !== null ? /* @__PURE__ */ jsx7(ScreenshotEditor, { image: shot.image, fileName: shot.fileName, onClose: () => setShot(null), onNotice: setNotice }) : null
|
|
3695
3970
|
] });
|
|
3696
3971
|
return createPortal(overlay, document.body);
|
|
3697
3972
|
}
|
|
@@ -3713,7 +3988,7 @@ function selectedText() {
|
|
|
3713
3988
|
const node = selection.getRangeAt(0).commonAncestorContainer;
|
|
3714
3989
|
const element = node instanceof Element ? node : node.parentElement;
|
|
3715
3990
|
if (element === null || element.closest(OWN_SELECTOR) !== null) return null;
|
|
3716
|
-
return { element, text
|
|
3991
|
+
return { element, text };
|
|
3717
3992
|
}
|
|
3718
3993
|
function liveArea(item, container) {
|
|
3719
3994
|
const offset = item.annotation.areaInContainer;
|
|
@@ -3722,10 +3997,10 @@ function liveArea(item, container) {
|
|
|
3722
3997
|
return { x: origin.left + offset.x, y: origin.top + offset.y, width: offset.width, height: offset.height };
|
|
3723
3998
|
}
|
|
3724
3999
|
function liveElement(item) {
|
|
3725
|
-
const [element] = item.elements;
|
|
3726
|
-
if (element?.isConnected) return element;
|
|
3727
4000
|
const first = item.annotation.targets[0];
|
|
3728
4001
|
if (first === void 0 || window.location.pathname !== first.page.pathname) return null;
|
|
4002
|
+
const [element] = item.elements;
|
|
4003
|
+
if (element?.isConnected) return element;
|
|
3729
4004
|
try {
|
|
3730
4005
|
return document.querySelector(first.element.selector);
|
|
3731
4006
|
} catch {
|
|
@@ -3769,7 +4044,10 @@ async function writeClipboard(text) {
|
|
|
3769
4044
|
area.remove();
|
|
3770
4045
|
}
|
|
3771
4046
|
export {
|
|
4047
|
+
COUNTRIES,
|
|
4048
|
+
DEFAULT_REDACTION,
|
|
3772
4049
|
DevAnnotator,
|
|
4050
|
+
REDACTED,
|
|
3773
4051
|
buildPrompt,
|
|
3774
4052
|
createNextResolver
|
|
3775
4053
|
};
|