@daybook/feedback 1.2.2 → 1.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 +51 -1
- package/dist/feedback.js +126 -50
- package/dist/index.d.ts +2 -0
- package/dist/index.js +47 -3
- package/dist/snapshot.d.ts +58 -0
- package/dist/snapshot.js +238 -0
- package/dist/types.d.ts +23 -0
- package/dist/widget.d.ts +45 -4
- package/dist/widget.js +275 -59
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { BreadcrumbTrail } from './breadcrumbs.js';
|
|
|
2
2
|
import { IngestClient } from './client.js';
|
|
3
3
|
import { captureContext } from './context.js';
|
|
4
4
|
import { captureScreenshot } from './screenshot.js';
|
|
5
|
+
import { captureSnapshot } from './snapshot.js';
|
|
5
6
|
import { FeedbackWidget } from './widget.js';
|
|
6
7
|
/**
|
|
7
8
|
* Where reports go unless the host says otherwise.
|
|
@@ -16,6 +17,8 @@ import { FeedbackWidget } from './widget.js';
|
|
|
16
17
|
*/
|
|
17
18
|
export const DEFAULT_API_URL = 'https://api.daybook.team';
|
|
18
19
|
export { captureAnchor, resolveAnchor } from './anchor.js';
|
|
20
|
+
/** Draws the launcher into an element you own, for a settings screen that previews a theme. */
|
|
21
|
+
export { previewLauncher } from './widget.js';
|
|
19
22
|
/**
|
|
20
23
|
* In-app feedback for the web.
|
|
21
24
|
*
|
|
@@ -249,9 +252,34 @@ export class DaybookFeedback {
|
|
|
249
252
|
const screenshot = input.withScreenshot
|
|
250
253
|
? await captureScreenshot(this.options.redact !== false, () => this.widget?.conceal() ?? (() => { }))
|
|
251
254
|
: null;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
/*
|
|
256
|
+
* The page itself, as markup rather than as a picture.
|
|
257
|
+
*
|
|
258
|
+
* Always, and with no prompt: it is the page's own state read by script already running on it,
|
|
259
|
+
* so there is nothing to ask permission for. It goes as an attachment rather than in `context`
|
|
260
|
+
* because context is capped at 64KB server-side and an oversized one is dropped WHOLE — a
|
|
261
|
+
* snapshot in there would silently take the breadcrumbs and the device with it.
|
|
262
|
+
*
|
|
263
|
+
* A screenshot is for a person; this is for whatever reads the report first, which is now
|
|
264
|
+
* usually not a person. Classes, computed style, what is stacked over what and what had focus
|
|
265
|
+
* are all things a PNG makes somebody squint at and an assistant cannot recover at all.
|
|
266
|
+
*/
|
|
267
|
+
const snapshot = this.options.dom === false
|
|
268
|
+
? null
|
|
269
|
+
: captureSnapshot(input.anchor, this.options.redact !== false);
|
|
270
|
+
/*
|
|
271
|
+
* Order matters, because the server takes the first five and drops the rest without saying so.
|
|
272
|
+
*
|
|
273
|
+
* The reporter's own files lead: they chose them, and a file somebody deliberately attached
|
|
274
|
+
* disappearing is the one loss they would notice. Then the screenshot, which they ticked a box
|
|
275
|
+
* for. The snapshot is last because it is the only one nobody asked for — and on the crowded
|
|
276
|
+
* report where it is dropped, the reporter has attached four things and said plenty.
|
|
277
|
+
*/
|
|
278
|
+
const uploads = [
|
|
279
|
+
...input.files,
|
|
280
|
+
...(screenshot ? [screenshot] : []),
|
|
281
|
+
...(snapshot ? [asUpload(snapshot)] : []),
|
|
282
|
+
];
|
|
255
283
|
const request = {
|
|
256
284
|
message: input.message,
|
|
257
285
|
kind: input.kind,
|
|
@@ -291,6 +319,22 @@ export class DaybookFeedback {
|
|
|
291
319
|
}
|
|
292
320
|
}
|
|
293
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* The snapshot as a file to upload.
|
|
324
|
+
*
|
|
325
|
+
* JSON rather than the raw HTML, because the markup is only part of it — the computed styles, the
|
|
326
|
+
* floating layers and what had focus are the parts a picture could never carry, and they need
|
|
327
|
+
* somewhere to live. Named for what it is, so a triager scanning five attachments knows which one
|
|
328
|
+
* nobody chose to attach.
|
|
329
|
+
*/
|
|
330
|
+
function asUpload(snapshot) {
|
|
331
|
+
const body = JSON.stringify(snapshot);
|
|
332
|
+
return {
|
|
333
|
+
blob: new Blob([body], { type: 'application/json' }),
|
|
334
|
+
filename: 'page-snapshot.json',
|
|
335
|
+
contentType: 'application/json',
|
|
336
|
+
};
|
|
337
|
+
}
|
|
294
338
|
export function init(options) {
|
|
295
339
|
return new DaybookFeedback(options).start();
|
|
296
340
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Anchor } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The snapshot, and the ORDER OF THESE FIELDS IS LOAD-BEARING.
|
|
4
|
+
*
|
|
5
|
+
* Whatever reads a report first reads this file inlined beside it, and inlining is bounded — the
|
|
6
|
+
* server extracts the head of a text attachment, not all of it. So the fields are in ascending order
|
|
7
|
+
* of size and descending order of value: the note, then where and when, then the things a picture
|
|
8
|
+
* could never carry, and the markup last. A reader who gets only the first few kilobytes still gets
|
|
9
|
+
* every answer except the tail of the document, and the whole file is behind the attachment's own
|
|
10
|
+
* download URL for anybody who needs it.
|
|
11
|
+
*
|
|
12
|
+
* Put `html` anywhere but last and a truncated read is a truncated document and nothing else.
|
|
13
|
+
*/
|
|
14
|
+
export interface DomSnapshot {
|
|
15
|
+
/** For whoever opens this cold, human or otherwise. */
|
|
16
|
+
note: string;
|
|
17
|
+
capturedAtUtc: string;
|
|
18
|
+
url: string;
|
|
19
|
+
title: string;
|
|
20
|
+
/** Whether values were described rather than reproduced. Says how to read the snapshot. */
|
|
21
|
+
redacted: boolean;
|
|
22
|
+
/** True when the markup hit the cap. What is there is still the top of the document. */
|
|
23
|
+
truncated: boolean;
|
|
24
|
+
scroll: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
/** What the keyboard was in, which no screenshot shows. */
|
|
29
|
+
focus: string | null;
|
|
30
|
+
/** The pinned element, its ancestors, and what their styles actually resolved to. */
|
|
31
|
+
anchor?: {
|
|
32
|
+
selector: string;
|
|
33
|
+
path: {
|
|
34
|
+
selector: string;
|
|
35
|
+
computed: Record<string, string>;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
/** Everything floating over the page right now: dialogs, drawers, toasts, someone's chat bubble. */
|
|
39
|
+
layers: {
|
|
40
|
+
selector: string;
|
|
41
|
+
zIndex: string;
|
|
42
|
+
rect: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
w: number;
|
|
46
|
+
h: number;
|
|
47
|
+
};
|
|
48
|
+
}[];
|
|
49
|
+
/** Where the page's CSS came from. Cross-origin sheets cannot be read, and say so. */
|
|
50
|
+
stylesheets: {
|
|
51
|
+
href: string | null;
|
|
52
|
+
rules: number | 'unreadable';
|
|
53
|
+
}[];
|
|
54
|
+
/** Last, deliberately. See the note above the interface. */
|
|
55
|
+
html: string;
|
|
56
|
+
}
|
|
57
|
+
/** The whole snapshot. Never throws — a report without one beats no report. */
|
|
58
|
+
export declare function captureSnapshot(anchor: Anchor | null, redacted: boolean): DomSnapshot | null;
|
package/dist/snapshot.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { redactValue, PRIVATE_ATTRIBUTE } from './redact.js';
|
|
2
|
+
/**
|
|
3
|
+
* The page as a machine can read it: markup, classes, computed style, and what is floating on top.
|
|
4
|
+
*
|
|
5
|
+
* A screenshot is for a person. It is a flat picture, and everything a triager wants to know from it
|
|
6
|
+
* — which element, which classes, what the computed style actually resolved to, what is stacked over
|
|
7
|
+
* what — has to be inferred by looking, and cannot be inferred at all by anything that is not
|
|
8
|
+
* looking. Most feedback now passes an assistant before it passes a person, and to an assistant a
|
|
9
|
+
* PNG is nearly opaque while a DOM is the whole answer.
|
|
10
|
+
*
|
|
11
|
+
* So this is captured on every report, with no prompt and no permission: it is the page's own state,
|
|
12
|
+
* read by script that is already running on the page.
|
|
13
|
+
*
|
|
14
|
+
* <h3>What is deliberately not in it</h3>
|
|
15
|
+
*
|
|
16
|
+
* Script bodies. They are the application bundle, they are megabytes, and the report is about what
|
|
17
|
+
* the page IS rather than how it got there.
|
|
18
|
+
*
|
|
19
|
+
* Input values, unless redaction is off. The rule is the one the rest of the SDK follows: a value is
|
|
20
|
+
* described, never reproduced — `[7 chars]`, or `[redacted]` where the field's name suggests a
|
|
21
|
+
* secret. A DOM snapshot is the single easiest way to ship somebody's half-typed password to a
|
|
22
|
+
* server, and it will not be.
|
|
23
|
+
*
|
|
24
|
+
* Anything under data-daybook-private, which is stripped to a marker rather than emptied, so a
|
|
25
|
+
* reader can see that something was there and was withheld.
|
|
26
|
+
*
|
|
27
|
+
* <h3>What it costs the page</h3>
|
|
28
|
+
*
|
|
29
|
+
* One pass over the tree and a getComputedStyle on the anchor's ancestors — microseconds, and it
|
|
30
|
+
* runs after the reporter presses Send rather than while they are typing. The whole thing is bounded
|
|
31
|
+
* and truncates rather than growing: a page that is somehow fifty megabytes of markup produces a
|
|
32
|
+
* snapshot the same size as any other, with a flag saying so.
|
|
33
|
+
*/
|
|
34
|
+
/** The most markup we will send. Past this the tail is repetition — a table of ten thousand rows. */
|
|
35
|
+
const MAX_HTML = 400000;
|
|
36
|
+
/** No single attribute is this interesting. Caps a base64 data: URI, which is the usual offender. */
|
|
37
|
+
const MAX_ATTRIBUTE = 300;
|
|
38
|
+
/** Long enough for a paragraph, short enough that an article body does not become the snapshot. */
|
|
39
|
+
const MAX_TEXT = 600;
|
|
40
|
+
/** Inline stylesheets are worth having; an entire framework inlined into the head is not. */
|
|
41
|
+
const MAX_STYLE = 8000;
|
|
42
|
+
/** Nothing inside these tells a reader anything about the page's state. */
|
|
43
|
+
const SKIPPED = new Set(['SCRIPT', 'NOSCRIPT', 'TEMPLATE']);
|
|
44
|
+
/** Style properties that explain how something looks, without dumping all three hundred of them. */
|
|
45
|
+
const INTERESTING = [
|
|
46
|
+
'display', 'position', 'z-index', 'opacity', 'visibility', 'overflow',
|
|
47
|
+
'width', 'height', 'margin', 'padding', 'box-sizing',
|
|
48
|
+
'color', 'background-color', 'border', 'border-radius', 'box-shadow',
|
|
49
|
+
'font-family', 'font-size', 'font-weight', 'line-height', 'text-align', 'white-space',
|
|
50
|
+
'flex-direction', 'justify-content', 'align-items', 'gap', 'grid-template-columns',
|
|
51
|
+
'transform', 'transition', 'pointer-events', 'cursor',
|
|
52
|
+
];
|
|
53
|
+
const NOTE = 'The page at the moment this was reported. Field values are described rather than '
|
|
54
|
+
+ 'reproduced when redacted is true, and data-daybook-private subtrees are withheld. html is last '
|
|
55
|
+
+ 'because only the head of this file is inlined beside the report — download the attachment for '
|
|
56
|
+
+ 'the rest of it.';
|
|
57
|
+
/** A CSS-ish path to an element, good enough to find it again and short enough to read. */
|
|
58
|
+
function selectorFor(element) {
|
|
59
|
+
const parts = [];
|
|
60
|
+
let node = element;
|
|
61
|
+
for (let depth = 0; node && depth < 4 && node.nodeType === 1; depth += 1) {
|
|
62
|
+
let part = node.localName;
|
|
63
|
+
if (node.id) {
|
|
64
|
+
parts.unshift(`${part}#${node.id}`);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
const classes = Array.from(node.classList).slice(0, 3).join('.');
|
|
68
|
+
if (classes)
|
|
69
|
+
part += `.${classes}`;
|
|
70
|
+
parts.unshift(part);
|
|
71
|
+
node = node.parentElement;
|
|
72
|
+
}
|
|
73
|
+
return parts.join(' > ');
|
|
74
|
+
}
|
|
75
|
+
const attributeValue = (name, value) => value.length > MAX_ATTRIBUTE ? `${value.slice(0, MAX_ATTRIBUTE)}…[${value.length}]` : value;
|
|
76
|
+
const escape = (text) => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
77
|
+
/**
|
|
78
|
+
* The value of a field, as the report is allowed to describe it.
|
|
79
|
+
*
|
|
80
|
+
* Checked boxes and selected options are kept as-is: they are a choice among options the markup
|
|
81
|
+
* already lists, not something somebody typed, and "which radio was selected" is frequently the bug.
|
|
82
|
+
*/
|
|
83
|
+
function fieldValue(element, redacted) {
|
|
84
|
+
const input = element;
|
|
85
|
+
if (element.localName === 'input' && (input.type === 'checkbox' || input.type === 'radio')) {
|
|
86
|
+
return input.checked ? 'checked' : 'unchecked';
|
|
87
|
+
}
|
|
88
|
+
const value = input.value;
|
|
89
|
+
if (typeof value !== 'string' || value === '')
|
|
90
|
+
return null;
|
|
91
|
+
return redacted ? redactValue(value, input.name || input.id || input.type) : value;
|
|
92
|
+
}
|
|
93
|
+
/** Serialises one node, appending to `out`, and answers whether there is still room. */
|
|
94
|
+
function write(node, out, size, redacted) {
|
|
95
|
+
if (size.used > MAX_HTML)
|
|
96
|
+
return false;
|
|
97
|
+
if (node.nodeType === 3) {
|
|
98
|
+
const text = (node.textContent ?? '').replace(/\s+/g, ' ');
|
|
99
|
+
if (!text.trim())
|
|
100
|
+
return true;
|
|
101
|
+
const clipped = text.length > MAX_TEXT ? `${text.slice(0, MAX_TEXT)}…` : text;
|
|
102
|
+
out.push(escape(clipped));
|
|
103
|
+
size.used += clipped.length;
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (node.nodeType !== 1)
|
|
107
|
+
return true;
|
|
108
|
+
const element = node;
|
|
109
|
+
const tag = element.tagName;
|
|
110
|
+
// Our own widget is not the page. A report whose DOM is half feedback composer is a report about
|
|
111
|
+
// the wrong thing.
|
|
112
|
+
if (element.hasAttribute('data-daybook-feedback'))
|
|
113
|
+
return true;
|
|
114
|
+
if (SKIPPED.has(tag))
|
|
115
|
+
return true;
|
|
116
|
+
const name = element.localName;
|
|
117
|
+
if (redacted && element.hasAttribute(PRIVATE_ATTRIBUTE)) {
|
|
118
|
+
out.push(`<${name} ${PRIVATE_ATTRIBUTE}>[withheld]</${name}>`);
|
|
119
|
+
size.used += 32;
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
const attributes = [];
|
|
123
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
124
|
+
if (attribute.name === 'value')
|
|
125
|
+
continue;
|
|
126
|
+
attributes.push(`${attribute.name}="${escape(attributeValue(attribute.name, attribute.value))}"`);
|
|
127
|
+
}
|
|
128
|
+
const value = fieldValue(element, redacted);
|
|
129
|
+
if (value !== null)
|
|
130
|
+
attributes.push(`value="${escape(value)}"`);
|
|
131
|
+
const open = attributes.length > 0 ? `<${name} ${attributes.join(' ')}>` : `<${name}>`;
|
|
132
|
+
out.push(open);
|
|
133
|
+
size.used += open.length;
|
|
134
|
+
if (name === 'style') {
|
|
135
|
+
const css = element.textContent ?? '';
|
|
136
|
+
const clipped = css.length > MAX_STYLE ? `${css.slice(0, MAX_STYLE)}\n/* …${css.length} chars */` : css;
|
|
137
|
+
out.push(clipped);
|
|
138
|
+
size.used += clipped.length;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
for (const child of Array.from(element.childNodes)) {
|
|
142
|
+
if (!write(child, out, size, redacted))
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
out.push(`</${name}>`);
|
|
147
|
+
size.used += name.length + 3;
|
|
148
|
+
return size.used <= MAX_HTML;
|
|
149
|
+
}
|
|
150
|
+
/** Whatever is floating over the page: our own furniture excluded, since we know about ours. */
|
|
151
|
+
function layers() {
|
|
152
|
+
const found = [];
|
|
153
|
+
for (const element of Array.from(document.body?.querySelectorAll('*') ?? []).slice(0, 4000)) {
|
|
154
|
+
const style = getComputedStyle(element);
|
|
155
|
+
if (style.position !== 'fixed' && style.position !== 'sticky')
|
|
156
|
+
continue;
|
|
157
|
+
if (style.visibility === 'hidden' || style.display === 'none' || Number(style.opacity) === 0)
|
|
158
|
+
continue;
|
|
159
|
+
const rect = element.getBoundingClientRect();
|
|
160
|
+
if (rect.width < 4 || rect.height < 4)
|
|
161
|
+
continue;
|
|
162
|
+
if (element.closest('[data-daybook-feedback]'))
|
|
163
|
+
continue;
|
|
164
|
+
found.push({
|
|
165
|
+
selector: selectorFor(element),
|
|
166
|
+
zIndex: style.zIndex,
|
|
167
|
+
rect: { x: Math.round(rect.x), y: Math.round(rect.y), w: Math.round(rect.width), h: Math.round(rect.height) },
|
|
168
|
+
});
|
|
169
|
+
if (found.length >= 20)
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
return found;
|
|
173
|
+
}
|
|
174
|
+
/** The anchored element and its ancestors, with the styles that decide how it looks. */
|
|
175
|
+
function anchorPath(anchor) {
|
|
176
|
+
if (!anchor?.selector)
|
|
177
|
+
return undefined;
|
|
178
|
+
let element = null;
|
|
179
|
+
try {
|
|
180
|
+
element = document.querySelector(anchor.selector);
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
if (!element)
|
|
186
|
+
return undefined;
|
|
187
|
+
const path = [];
|
|
188
|
+
for (let node = element; node && path.length < 5; node = node.parentElement) {
|
|
189
|
+
const style = getComputedStyle(node);
|
|
190
|
+
const computed = {};
|
|
191
|
+
for (const property of INTERESTING) {
|
|
192
|
+
const value = style.getPropertyValue(property);
|
|
193
|
+
if (value)
|
|
194
|
+
computed[property] = value;
|
|
195
|
+
}
|
|
196
|
+
path.push({ selector: selectorFor(node), computed });
|
|
197
|
+
}
|
|
198
|
+
return { selector: anchor.selector, path };
|
|
199
|
+
}
|
|
200
|
+
function stylesheets() {
|
|
201
|
+
return Array.from(document.styleSheets).slice(0, 40).map((sheet) => {
|
|
202
|
+
try {
|
|
203
|
+
// Reading rules from a cross-origin sheet throws, and that is worth recording: a triager
|
|
204
|
+
// looking at markup with no matching CSS should know the CSS was unreadable, not absent.
|
|
205
|
+
return { href: sheet.href, rules: sheet.cssRules.length };
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return { href: sheet.href, rules: 'unreadable' };
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** The whole snapshot. Never throws — a report without one beats no report. */
|
|
213
|
+
export function captureSnapshot(anchor, redacted) {
|
|
214
|
+
try {
|
|
215
|
+
const out = [];
|
|
216
|
+
const size = { used: 0 };
|
|
217
|
+
write(document.documentElement, out, size, redacted);
|
|
218
|
+
return {
|
|
219
|
+
note: NOTE,
|
|
220
|
+
capturedAtUtc: new Date().toISOString(),
|
|
221
|
+
url: location.href,
|
|
222
|
+
title: document.title,
|
|
223
|
+
redacted,
|
|
224
|
+
truncated: size.used > MAX_HTML,
|
|
225
|
+
scroll: { x: Math.round(window.scrollX), y: Math.round(window.scrollY) },
|
|
226
|
+
focus: document.activeElement && document.activeElement !== document.body
|
|
227
|
+
? selectorFor(document.activeElement)
|
|
228
|
+
: null,
|
|
229
|
+
anchor: anchorPath(anchor),
|
|
230
|
+
layers: layers(),
|
|
231
|
+
stylesheets: stylesheets(),
|
|
232
|
+
html: out.join(''),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -106,8 +106,20 @@ export type ReporterStatus = 'Approved' | 'Pending' | 'Blocked' | 'Anonymous';
|
|
|
106
106
|
export interface FeedbackTheme {
|
|
107
107
|
accent?: string;
|
|
108
108
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
109
|
+
/** The word on the button. Defaults to "Feedback". */
|
|
109
110
|
launcherLabel?: string;
|
|
110
111
|
cornerRadius?: 'none' | 'sm' | 'md' | 'lg';
|
|
112
|
+
/**
|
|
113
|
+
* The shape of the launcher.
|
|
114
|
+
*
|
|
115
|
+
* pill filled and round, with the label — the default
|
|
116
|
+
* pill-icon the same, with a speech bubble in front of it
|
|
117
|
+
* icon the bubble on its own, for a corner that is already busy
|
|
118
|
+
* text no fill, underlined label, for a page that would be shouted over
|
|
119
|
+
* outline the accent as a border rather than a fill
|
|
120
|
+
*/
|
|
121
|
+
buttonStyle?: 'pill' | 'pill-icon' | 'icon' | 'text' | 'outline';
|
|
122
|
+
/** Follows the reader's own setting unless overruled. Defaults to auto. */
|
|
111
123
|
colorScheme?: 'auto' | 'light' | 'dark';
|
|
112
124
|
}
|
|
113
125
|
export interface FeedbackOptions {
|
|
@@ -173,6 +185,17 @@ export interface FeedbackOptions {
|
|
|
173
185
|
redact?: boolean;
|
|
174
186
|
/** Console errors, failed requests and navigation. On by default, capped and redacted. */
|
|
175
187
|
breadcrumbs?: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Attach the page's DOM to every report — markup, classes, computed style for the pinned element,
|
|
190
|
+
* and what is floating over the page. On by default, and it needs no permission: it is the page's
|
|
191
|
+
* own state, read by script already running on it.
|
|
192
|
+
*
|
|
193
|
+
* It obeys `redact`, so field values are described rather than reproduced and anything marked
|
|
194
|
+
* data-daybook-private is withheld. What it does carry is the page's visible text, because that is
|
|
195
|
+
* what the page is. On a screen showing somebody's personal data, decide whether that belongs in a
|
|
196
|
+
* report before leaving this on.
|
|
197
|
+
*/
|
|
198
|
+
dom?: boolean;
|
|
176
199
|
/** Keyboard shortcut to enter pick mode. Defaults to "f". Set null to disable. */
|
|
177
200
|
hotkey?: string | null;
|
|
178
201
|
/**
|
package/dist/widget.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export declare class FeedbackWidget {
|
|
|
39
39
|
private launcherLabel;
|
|
40
40
|
/** The corner the workspace chose, if it chose one. The init option outranks it. */
|
|
41
41
|
private themePlacement;
|
|
42
|
+
/** Which of the five shapes the launcher takes. */
|
|
43
|
+
private buttonStyle;
|
|
42
44
|
/** How far the host page's own floating buttons push us out of that corner. */
|
|
43
45
|
private clearance;
|
|
44
46
|
/** Where the widget lives: the caller's choice, then the workspace's, then the bottom right. */
|
|
@@ -102,13 +104,36 @@ export declare class FeedbackWidget {
|
|
|
102
104
|
/** Whether the composer offers screen capture at all, and whether it starts ticked. */
|
|
103
105
|
private capture;
|
|
104
106
|
/**
|
|
105
|
-
* Takes the widget off the screen and hands back the undo.
|
|
107
|
+
* Takes the widget off the screen, rings what the report is about, and hands back the undo.
|
|
106
108
|
*
|
|
107
|
-
* For the screen capture.
|
|
108
|
-
*
|
|
109
|
-
*
|
|
109
|
+
* For the screen capture. It is `visibility`, not `display`, because removing the panel from
|
|
110
|
+
* layout would reflow the host page underneath it and the picture would be of a page that never
|
|
111
|
+
* existed.
|
|
112
|
+
*
|
|
113
|
+
* The UI hides but the host element stays visible, because the ring is drawn inside it. That is
|
|
114
|
+
* the whole reason to do it here rather than on the page: a report used to arrive as a selector,
|
|
115
|
+
* a text snapshot and a picture of a whole screen, leaving whoever read it to work out which of
|
|
116
|
+
* forty things on that screen the sentence was about. Now the picture says.
|
|
110
117
|
*/
|
|
111
118
|
conceal(): () => void;
|
|
119
|
+
/**
|
|
120
|
+
* A ring over the pinned element, drawn in our own shadow root.
|
|
121
|
+
*
|
|
122
|
+
* Not on the element itself. Setting a style on somebody else's node means fighting their
|
|
123
|
+
* specificity, risking a reflow that changes the picture being taken, and owning the undo — and
|
|
124
|
+
* the undo is the part that bites: hidePrivate already exists to blur private fields for a frame,
|
|
125
|
+
* and its comment is about exactly this, that a page left permanently altered because a capture
|
|
126
|
+
* threw is worse than the bug being reported. A rectangle in our own layer touches nothing.
|
|
127
|
+
*
|
|
128
|
+
* No scrim over the rest, tempting as it is. A screenshot is also the record of what the page
|
|
129
|
+
* looked like, and dimming it changes the colours in a report that may well be about the colours.
|
|
130
|
+
* The ring is doubled — red, white, red — so it carries on a dark page and on a light one without
|
|
131
|
+
* altering either.
|
|
132
|
+
*
|
|
133
|
+
* Resolved at capture time rather than at pick time: the composer may have been open for a while,
|
|
134
|
+
* and where the element is NOW is where the picture will show it.
|
|
135
|
+
*/
|
|
136
|
+
private ringAnchor;
|
|
112
137
|
/**
|
|
113
138
|
* Where the reporter dragged the panel to, if they did — for this report only.
|
|
114
139
|
*
|
|
@@ -190,3 +215,19 @@ export declare class FeedbackWidget {
|
|
|
190
215
|
* selection, and a selection made inside a shadow root is not the document's.
|
|
191
216
|
*/
|
|
192
217
|
export declare function copyText(text: string): Promise<boolean>;
|
|
218
|
+
/**
|
|
219
|
+
* Draws the launcher, and only the launcher, inside an element you own.
|
|
220
|
+
*
|
|
221
|
+
* For a settings screen that has to show what a theme will look like before anybody saves it. It is
|
|
222
|
+
* the real button with the real stylesheet in a real shadow root: a second implementation in the
|
|
223
|
+
* console's own CSS would be a picture of the widget rather than the widget, and would begin lying
|
|
224
|
+
* the first time either one changed.
|
|
225
|
+
*
|
|
226
|
+
* Nothing else comes with it — no handshake, no listeners, no page-level positioning — so it is
|
|
227
|
+
* safe to call ten times on one screen. Call it again to change the theme; it replaces what it drew.
|
|
228
|
+
*/
|
|
229
|
+
export declare function previewLauncher(into: HTMLElement, theme?: FeedbackTheme): void;
|
|
230
|
+
/** The button shapes a workspace can choose between. Anything else falls back to the first. */
|
|
231
|
+
declare const BUTTON_STYLES: readonly ["pill", "pill-icon", "icon", "text", "outline"];
|
|
232
|
+
export type ButtonStyle = (typeof BUTTON_STYLES)[number];
|
|
233
|
+
export {};
|