@monster-orange/den-ui 0.5.1 → 0.6.6
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 +334 -1
- package/bin/den-ui-parity.mjs +365 -0
- package/inventory/nav-inventory.d.ts +89 -0
- package/inventory/nav-inventory.js +590 -0
- package/inventory/reference/den-chromium-1280.json +5137 -0
- package/inventory/reference/den-chromium-390.json +3653 -0
- package/inventory/reference/den-webkit-1280.json +5137 -0
- package/inventory/reference/den-webkit-390.json +3653 -0
- package/package.json +33 -3
- package/src/busy-words.d.ts +2 -0
- package/src/busy-words.js +6 -0
- package/src/busy.css +155 -0
- package/src/busy.d.ts +80 -0
- package/src/busy.js +105 -35
- package/src/dialog.css +103 -0
- package/src/dialog.d.ts +44 -0
- package/src/dialog.js +95 -30
- package/src/icons.d.ts +4 -0
- package/src/icons.js +43 -0
- package/src/kit.d.ts +146 -0
- package/src/kit.js +224 -0
- package/src/report-shot.d.ts +47 -0
- package/src/report-shot.js +255 -0
- package/src/report.css +387 -0
- package/src/report.d.ts +61 -0
- package/src/report.js +909 -0
- package/src/shell-client.d.ts +31 -0
- package/src/shell-client.js +240 -0
- package/src/shell-html.d.ts +91 -0
- package/src/shell-html.js +289 -0
- package/src/shell.css +558 -0
- package/src/strings.d.ts +18 -0
- package/src/strings.js +514 -0
- package/src/time.d.ts +18 -0
- package/src/time.js +14 -2
- package/src/tokens.css +13 -5
- package/src/update-pill.d.ts +17 -0
- package/src/version.d.ts +7 -0
- package/src/version.js +31 -0
- package/src/whatsnew.css +235 -0
- package/src/whatsnew.d.ts +36 -0
- package/src/whatsnew.js +411 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* den-ui: the Report form's screenshot, and its mask.
|
|
3
|
+
*
|
|
4
|
+
* capture() takes the page as the person sees it, with any dialog, drawer
|
|
5
|
+
* or menu that is open, before the form opens (the form itself is left
|
|
6
|
+
* out). It uses html-to-image (MIT; the product serves it and names its
|
|
7
|
+
* URL with configureShots({ library })), loaded the first time. It never throws: a
|
|
8
|
+
* page that can't be captured, or that takes longer than `seconds`, gives
|
|
9
|
+
* null, and the form offers to send without one.
|
|
10
|
+
*
|
|
11
|
+
* Masks are rectangles in fractions of the image (0..1), so they hold at
|
|
12
|
+
* any size the image is shown at. masked() draws them in black onto a
|
|
13
|
+
* copy: what is sent is the copy, never the original.
|
|
14
|
+
*
|
|
15
|
+
* The screenshot never goes to the product's server. GitHub's API can't attach an
|
|
16
|
+
* image, so after sending it is saved as a file and copied, and the person
|
|
17
|
+
* pastes it into the issue.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
let LIB = "";
|
|
21
|
+
let lib = null;
|
|
22
|
+
|
|
23
|
+
/** Where html-to-image is (a URL on the product's own origin). */
|
|
24
|
+
export function configureShots({ library } = {}) {
|
|
25
|
+
if (library && library !== LIB) {
|
|
26
|
+
LIB = library;
|
|
27
|
+
lib = null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function loadLib() {
|
|
32
|
+
if (lib) return lib;
|
|
33
|
+
lib = new Promise((ok, no) => {
|
|
34
|
+
if (window.htmlToImage) return ok(window.htmlToImage);
|
|
35
|
+
if (!LIB) return no(new Error("html-to-image: no library configured"));
|
|
36
|
+
const sc = document.createElement("script");
|
|
37
|
+
sc.src = LIB;
|
|
38
|
+
sc.onload = () =>
|
|
39
|
+
window.htmlToImage
|
|
40
|
+
? ok(window.htmlToImage)
|
|
41
|
+
: no(new Error("html-to-image"));
|
|
42
|
+
sc.onerror = () => no(new Error("html-to-image"));
|
|
43
|
+
document.head.append(sc);
|
|
44
|
+
});
|
|
45
|
+
lib.catch(() => (lib = null));
|
|
46
|
+
return lib;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function timeout(ms) {
|
|
50
|
+
return new Promise((_, no) =>
|
|
51
|
+
setTimeout(() => no(new Error("capture timed out")), ms),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The page as shown now, as a canvas the size of the window, or null.
|
|
57
|
+
* `skip(el)`: elements to leave out (the form).
|
|
58
|
+
*/
|
|
59
|
+
export async function capture({ seconds = 15, skip = () => false } = {}) {
|
|
60
|
+
try {
|
|
61
|
+
const h2i = await Promise.race([loadLib(), timeout(seconds * 1000)]);
|
|
62
|
+
const root = document.documentElement;
|
|
63
|
+
const canvas = await Promise.race([
|
|
64
|
+
h2i.toCanvas(root, {
|
|
65
|
+
width: window.innerWidth,
|
|
66
|
+
height: window.innerHeight,
|
|
67
|
+
pixelRatio: 1,
|
|
68
|
+
// The page's own fonts are already there: not fetched again.
|
|
69
|
+
skipFonts: true,
|
|
70
|
+
backgroundColor: getComputedStyle(document.body).backgroundColor,
|
|
71
|
+
filter: (n) => !(n.nodeType === 1 && skip(n)),
|
|
72
|
+
}),
|
|
73
|
+
timeout(seconds * 1000),
|
|
74
|
+
]);
|
|
75
|
+
return canvas && canvas.width > 0 && canvas.height > 0 ? canvas : null;
|
|
76
|
+
} catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** A copy of `canvas` with each mask (fractions of it) filled black. */
|
|
82
|
+
export function masked(canvas, masks) {
|
|
83
|
+
const out = document.createElement("canvas");
|
|
84
|
+
out.width = canvas.width;
|
|
85
|
+
out.height = canvas.height;
|
|
86
|
+
const g = out.getContext("2d");
|
|
87
|
+
g.drawImage(canvas, 0, 0);
|
|
88
|
+
// Black in every theme: a mask hides, it is not a theme colour.
|
|
89
|
+
g.fillStyle = "black";
|
|
90
|
+
for (const m of masks)
|
|
91
|
+
g.fillRect(
|
|
92
|
+
Math.floor(m.x * out.width),
|
|
93
|
+
Math.floor(m.y * out.height),
|
|
94
|
+
Math.ceil(m.w * out.width),
|
|
95
|
+
Math.ceil(m.h * out.height),
|
|
96
|
+
);
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** A mask from two points (fractions), the right way round, clamped. */
|
|
101
|
+
export function rectOf(a, b) {
|
|
102
|
+
const c = (v) => Math.min(1, Math.max(0, v));
|
|
103
|
+
const x = c(Math.min(a.x, b.x));
|
|
104
|
+
const y = c(Math.min(a.y, b.y));
|
|
105
|
+
return {
|
|
106
|
+
x,
|
|
107
|
+
y,
|
|
108
|
+
w: c(Math.max(a.x, b.x)) - x,
|
|
109
|
+
h: c(Math.max(a.y, b.y)) - y,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** A mask from the keyboard form: percentages, clamped to the image. */
|
|
114
|
+
export function rectOfPercent(x, y, w, h) {
|
|
115
|
+
const n = (v) => Math.min(100, Math.max(0, Number(v) || 0)) / 100;
|
|
116
|
+
const r = { x: n(x), y: n(y), w: n(w), h: n(h) };
|
|
117
|
+
r.w = Math.min(r.w, 1 - r.x);
|
|
118
|
+
r.h = Math.min(r.h, 1 - r.y);
|
|
119
|
+
return r;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function toBlob(canvas) {
|
|
123
|
+
return new Promise((ok) => canvas.toBlob(ok, "image/png"));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* After sending: the masked screenshot copied (where the browser allows
|
|
128
|
+
* it) and saved as a file. Which of the two worked.
|
|
129
|
+
*/
|
|
130
|
+
export async function saveAndCopy(canvas, name = "report-screenshot.png") {
|
|
131
|
+
const blob = await toBlob(canvas);
|
|
132
|
+
const out = { copied: false, saved: false };
|
|
133
|
+
if (!blob) return out;
|
|
134
|
+
try {
|
|
135
|
+
if (navigator.clipboard?.write && typeof ClipboardItem === "function") {
|
|
136
|
+
await navigator.clipboard.write([
|
|
137
|
+
new ClipboardItem({ "image/png": blob }),
|
|
138
|
+
]);
|
|
139
|
+
out.copied = true;
|
|
140
|
+
}
|
|
141
|
+
} catch {
|
|
142
|
+
/* not allowed here: the file is still saved */
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const url = URL.createObjectURL(blob);
|
|
146
|
+
const a = document.createElement("a");
|
|
147
|
+
a.href = url;
|
|
148
|
+
a.download = name;
|
|
149
|
+
a.hidden = true;
|
|
150
|
+
document.body.append(a);
|
|
151
|
+
a.click();
|
|
152
|
+
a.remove();
|
|
153
|
+
setTimeout(() => URL.revokeObjectURL(url), 60_000);
|
|
154
|
+
out.saved = true;
|
|
155
|
+
} catch {
|
|
156
|
+
/* no download here */
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** An image (a Blob or a data: URL) back as a canvas, or null. */
|
|
162
|
+
export async function canvasOf(src) {
|
|
163
|
+
let url = "";
|
|
164
|
+
try {
|
|
165
|
+
url = typeof src === "string" ? src : URL.createObjectURL(src);
|
|
166
|
+
const img = new Image();
|
|
167
|
+
await new Promise((ok, no) => {
|
|
168
|
+
img.onload = ok;
|
|
169
|
+
img.onerror = no;
|
|
170
|
+
img.src = url;
|
|
171
|
+
});
|
|
172
|
+
const c = document.createElement("canvas");
|
|
173
|
+
c.width = img.naturalWidth;
|
|
174
|
+
c.height = img.naturalHeight;
|
|
175
|
+
c.getContext("2d").drawImage(img, 0, 0);
|
|
176
|
+
return c.width && c.height ? c : null;
|
|
177
|
+
} catch {
|
|
178
|
+
return null;
|
|
179
|
+
} finally {
|
|
180
|
+
if (url && typeof src !== "string") URL.revokeObjectURL(url);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/*
|
|
185
|
+
* Finish later's screenshot stays in this browser (IndexedDB), keyed by
|
|
186
|
+
* the draft's id, with its masks: the draft's text is on the product's server, the
|
|
187
|
+
* picture never is. Storage off or full: the draft keeps its text only.
|
|
188
|
+
*/
|
|
189
|
+
const DB = "den-report";
|
|
190
|
+
const STORE = "shots";
|
|
191
|
+
|
|
192
|
+
function openDb() {
|
|
193
|
+
return new Promise((ok, no) => {
|
|
194
|
+
const r = indexedDB.open(DB, 1);
|
|
195
|
+
r.onupgradeneeded = () => r.result.createObjectStore(STORE);
|
|
196
|
+
r.onsuccess = () => ok(r.result);
|
|
197
|
+
r.onerror = () => no(r.error);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async function inStore(mode, f) {
|
|
202
|
+
const db = await openDb();
|
|
203
|
+
try {
|
|
204
|
+
return await new Promise((ok, no) => {
|
|
205
|
+
const tx = db.transaction(STORE, mode);
|
|
206
|
+
const req = f(tx.objectStore(STORE));
|
|
207
|
+
tx.oncomplete = () => ok(req.result);
|
|
208
|
+
tx.onerror = () => no(tx.error);
|
|
209
|
+
tx.onabort = () => no(tx.error);
|
|
210
|
+
});
|
|
211
|
+
} finally {
|
|
212
|
+
db.close();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Keeps a draft's screenshot (the original) and its masks. */
|
|
217
|
+
export async function keepShot(id, canvas, masks, noShot) {
|
|
218
|
+
try {
|
|
219
|
+
const blob = await toBlob(canvas);
|
|
220
|
+
if (!blob) return false;
|
|
221
|
+
await inStore("readwrite", (s) =>
|
|
222
|
+
s.put({ blob, masks, noShot: !!noShot }, id),
|
|
223
|
+
);
|
|
224
|
+
return true;
|
|
225
|
+
} catch {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** A kept screenshot: { canvas, masks, noShot }, or null. */
|
|
231
|
+
export async function loadShot(id) {
|
|
232
|
+
try {
|
|
233
|
+
const v = await inStore("readonly", (s) => s.get(id));
|
|
234
|
+
if (!v || !v.blob) return null;
|
|
235
|
+
const canvas = await canvasOf(v.blob);
|
|
236
|
+
return canvas
|
|
237
|
+
? {
|
|
238
|
+
canvas,
|
|
239
|
+
masks: Array.isArray(v.masks) ? v.masks : [],
|
|
240
|
+
noShot: !!v.noShot,
|
|
241
|
+
}
|
|
242
|
+
: null;
|
|
243
|
+
} catch {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Forgets a draft's screenshot (sent or discarded). */
|
|
249
|
+
export async function dropShot(id) {
|
|
250
|
+
try {
|
|
251
|
+
await inStore("readwrite", (s) => s.delete(id));
|
|
252
|
+
} catch {
|
|
253
|
+
/* nothing kept */
|
|
254
|
+
}
|
|
255
|
+
}
|
package/src/report.css
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* den-ui Report form (report.js): one dialog, three steps (Write,
|
|
3
|
+
* Include, Review and send). Tokens only.
|
|
4
|
+
* <link rel="stylesheet" href="/kit/report.css">
|
|
5
|
+
*/
|
|
6
|
+
.fb-dlg {
|
|
7
|
+
font-family: var(--sans);
|
|
8
|
+
width: min(640px, calc(100vw - 32px));
|
|
9
|
+
max-width: 100%;
|
|
10
|
+
max-height: calc(100vh - 32px);
|
|
11
|
+
padding: 0;
|
|
12
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
13
|
+
border-radius: 12px;
|
|
14
|
+
background: var(--raised, var(--surface, var(--bg)));
|
|
15
|
+
color: var(--text);
|
|
16
|
+
box-shadow: var(--shadow);
|
|
17
|
+
overflow: auto;
|
|
18
|
+
}
|
|
19
|
+
.fb-dlg::backdrop {
|
|
20
|
+
background: var(--kit-backdrop);
|
|
21
|
+
}
|
|
22
|
+
.fb-b {
|
|
23
|
+
padding: 16px 18px;
|
|
24
|
+
display: grid;
|
|
25
|
+
gap: 10px;
|
|
26
|
+
}
|
|
27
|
+
.fb-b h2 {
|
|
28
|
+
font-size: 17px;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
margin: 0;
|
|
31
|
+
outline: none;
|
|
32
|
+
}
|
|
33
|
+
.fb-b p {
|
|
34
|
+
margin: 0;
|
|
35
|
+
font-size: 13px;
|
|
36
|
+
line-height: 1.5;
|
|
37
|
+
}
|
|
38
|
+
.fb-sub {
|
|
39
|
+
color: var(--muted);
|
|
40
|
+
}
|
|
41
|
+
.fb-steps {
|
|
42
|
+
font: 11px var(--mono);
|
|
43
|
+
color: var(--muted);
|
|
44
|
+
display: flex;
|
|
45
|
+
gap: 6px;
|
|
46
|
+
flex-wrap: wrap;
|
|
47
|
+
}
|
|
48
|
+
.fb-steps b {
|
|
49
|
+
color: var(--text);
|
|
50
|
+
}
|
|
51
|
+
.fb-h {
|
|
52
|
+
font: 11px var(--mono);
|
|
53
|
+
text-transform: uppercase;
|
|
54
|
+
letter-spacing: 0.04em;
|
|
55
|
+
color: var(--muted);
|
|
56
|
+
margin-top: 4px;
|
|
57
|
+
}
|
|
58
|
+
.fb-kinds {
|
|
59
|
+
display: flex;
|
|
60
|
+
gap: 6px;
|
|
61
|
+
flex-wrap: wrap;
|
|
62
|
+
}
|
|
63
|
+
.fb-kinds label {
|
|
64
|
+
display: inline-flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
gap: 6px;
|
|
67
|
+
min-height: 34px;
|
|
68
|
+
padding: 0 12px;
|
|
69
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
70
|
+
border-radius: 999px;
|
|
71
|
+
font-size: 13px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
.fb-kinds input:checked + span {
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
}
|
|
77
|
+
.fb-b label.fb-f {
|
|
78
|
+
display: grid;
|
|
79
|
+
gap: 4px;
|
|
80
|
+
font-size: 13px;
|
|
81
|
+
}
|
|
82
|
+
.fb-b input[type="text"],
|
|
83
|
+
.fb-b textarea {
|
|
84
|
+
font: 13px var(--sans);
|
|
85
|
+
padding: 7px 9px;
|
|
86
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
87
|
+
border-radius: 6px;
|
|
88
|
+
background: var(--bg);
|
|
89
|
+
color: var(--text);
|
|
90
|
+
width: 100%;
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
}
|
|
93
|
+
.fb-b textarea {
|
|
94
|
+
min-height: 76px;
|
|
95
|
+
resize: vertical;
|
|
96
|
+
}
|
|
97
|
+
.fb-tools {
|
|
98
|
+
display: flex;
|
|
99
|
+
gap: 8px;
|
|
100
|
+
flex-wrap: wrap;
|
|
101
|
+
align-items: center;
|
|
102
|
+
font-size: 13px;
|
|
103
|
+
}
|
|
104
|
+
.fb-b details {
|
|
105
|
+
border: 1px solid var(--border);
|
|
106
|
+
border-radius: 6px;
|
|
107
|
+
padding: 6px 8px;
|
|
108
|
+
font-size: 13px;
|
|
109
|
+
}
|
|
110
|
+
.fb-b summary {
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: 8px;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
}
|
|
116
|
+
.fb-b summary .fb-i {
|
|
117
|
+
margin-inline-start: auto;
|
|
118
|
+
width: 20px;
|
|
119
|
+
height: 20px;
|
|
120
|
+
border-radius: 50%;
|
|
121
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
122
|
+
display: inline-grid;
|
|
123
|
+
place-items: center;
|
|
124
|
+
font: 11px var(--mono);
|
|
125
|
+
}
|
|
126
|
+
.fb-b pre {
|
|
127
|
+
margin: 6px 0 0;
|
|
128
|
+
font: 12px/1.5 var(--mono);
|
|
129
|
+
background: var(--sunken, var(--bg));
|
|
130
|
+
padding: 8px;
|
|
131
|
+
border-radius: 4px;
|
|
132
|
+
white-space: pre-wrap;
|
|
133
|
+
overflow-wrap: anywhere;
|
|
134
|
+
max-height: 220px;
|
|
135
|
+
overflow: auto;
|
|
136
|
+
}
|
|
137
|
+
.fb-dest {
|
|
138
|
+
display: flex;
|
|
139
|
+
gap: 8px;
|
|
140
|
+
align-items: center;
|
|
141
|
+
flex-wrap: wrap;
|
|
142
|
+
font-size: 13px;
|
|
143
|
+
}
|
|
144
|
+
.fb-pill {
|
|
145
|
+
font: 11px var(--mono);
|
|
146
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
147
|
+
border-radius: 999px;
|
|
148
|
+
padding: 1px 8px;
|
|
149
|
+
}
|
|
150
|
+
.fb-warn {
|
|
151
|
+
border-inline-start: 3px solid var(--warn);
|
|
152
|
+
background: color-mix(in srgb, var(--warn) 10%, transparent);
|
|
153
|
+
padding: 8px 10px;
|
|
154
|
+
border-radius: 4px;
|
|
155
|
+
font-size: 13px;
|
|
156
|
+
}
|
|
157
|
+
.fb-err {
|
|
158
|
+
color: var(--bad, var(--err));
|
|
159
|
+
font-size: 13px;
|
|
160
|
+
}
|
|
161
|
+
.fb-code {
|
|
162
|
+
border: 1px dashed var(--border-strong, var(--border));
|
|
163
|
+
border-radius: 6px;
|
|
164
|
+
padding: 10px;
|
|
165
|
+
text-align: center;
|
|
166
|
+
font: 600 22px var(--mono);
|
|
167
|
+
letter-spacing: 0.14em;
|
|
168
|
+
}
|
|
169
|
+
.fb-fine {
|
|
170
|
+
font-size: 12px;
|
|
171
|
+
color: var(--muted);
|
|
172
|
+
}
|
|
173
|
+
.fb-btns {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-wrap: wrap;
|
|
176
|
+
gap: 8px;
|
|
177
|
+
margin-top: 14px;
|
|
178
|
+
}
|
|
179
|
+
.fb-btns button,
|
|
180
|
+
.fb-btns a {
|
|
181
|
+
min-height: 40px;
|
|
182
|
+
padding: 0 14px;
|
|
183
|
+
border-radius: 0.2rem;
|
|
184
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
185
|
+
background: var(--surface, var(--bg));
|
|
186
|
+
color: var(--text);
|
|
187
|
+
font: 13px var(--sans);
|
|
188
|
+
cursor: pointer;
|
|
189
|
+
display: inline-flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
text-decoration: none;
|
|
192
|
+
}
|
|
193
|
+
.fb-btns .fb-pri {
|
|
194
|
+
background: var(--accent-fill, var(--accent));
|
|
195
|
+
border-color: var(--accent-fill, var(--accent));
|
|
196
|
+
color: var(--on-accent);
|
|
197
|
+
}
|
|
198
|
+
.fb-btns button:focus-visible,
|
|
199
|
+
.fb-btns a:focus-visible {
|
|
200
|
+
outline: 2px solid var(--accent-text, var(--accent));
|
|
201
|
+
outline-offset: 2px;
|
|
202
|
+
}
|
|
203
|
+
.fb-ico {
|
|
204
|
+
width: 16px;
|
|
205
|
+
height: 16px;
|
|
206
|
+
flex: none;
|
|
207
|
+
}
|
|
208
|
+
.fb-shot {
|
|
209
|
+
border: 1px solid var(--border);
|
|
210
|
+
border-radius: 6px;
|
|
211
|
+
overflow: hidden;
|
|
212
|
+
background: var(--sunken, var(--bg));
|
|
213
|
+
line-height: 0;
|
|
214
|
+
}
|
|
215
|
+
.fb-shot canvas,
|
|
216
|
+
.fb-shot img {
|
|
217
|
+
width: 100%;
|
|
218
|
+
height: auto;
|
|
219
|
+
display: block;
|
|
220
|
+
cursor: crosshair;
|
|
221
|
+
touch-action: none;
|
|
222
|
+
}
|
|
223
|
+
.fb-shot img {
|
|
224
|
+
cursor: default;
|
|
225
|
+
}
|
|
226
|
+
.fb-kbd input[type="number"] {
|
|
227
|
+
width: 5em;
|
|
228
|
+
font: 13px var(--sans);
|
|
229
|
+
padding: 4px 6px;
|
|
230
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
231
|
+
border-radius: 6px;
|
|
232
|
+
background: var(--bg);
|
|
233
|
+
color: var(--text);
|
|
234
|
+
}
|
|
235
|
+
.fb-masks {
|
|
236
|
+
margin: 6px 0 0;
|
|
237
|
+
padding-inline-start: 18px;
|
|
238
|
+
font-size: 13px;
|
|
239
|
+
display: grid;
|
|
240
|
+
gap: 4px;
|
|
241
|
+
}
|
|
242
|
+
.fb-lk {
|
|
243
|
+
justify-self: start;
|
|
244
|
+
background: none;
|
|
245
|
+
border: 0;
|
|
246
|
+
padding: 0;
|
|
247
|
+
color: var(--accent-text, var(--accent));
|
|
248
|
+
font: 13px var(--sans);
|
|
249
|
+
text-decoration: underline;
|
|
250
|
+
cursor: pointer;
|
|
251
|
+
}
|
|
252
|
+
.fb-my {
|
|
253
|
+
width: min(560px, calc(100vw - 32px));
|
|
254
|
+
}
|
|
255
|
+
.fb-tabs {
|
|
256
|
+
display: flex;
|
|
257
|
+
gap: 6px;
|
|
258
|
+
flex-wrap: wrap;
|
|
259
|
+
}
|
|
260
|
+
.fb-tabs button {
|
|
261
|
+
min-height: 32px;
|
|
262
|
+
padding: 0 12px;
|
|
263
|
+
border-radius: 999px;
|
|
264
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
265
|
+
background: var(--surface, var(--bg));
|
|
266
|
+
color: var(--text);
|
|
267
|
+
font: 13px var(--sans);
|
|
268
|
+
cursor: pointer;
|
|
269
|
+
}
|
|
270
|
+
.fb-tabs button[aria-selected="true"] {
|
|
271
|
+
background: var(--accent-fill, var(--accent));
|
|
272
|
+
border-color: var(--accent-fill, var(--accent));
|
|
273
|
+
color: var(--on-accent);
|
|
274
|
+
font-weight: 600;
|
|
275
|
+
}
|
|
276
|
+
.fb-list {
|
|
277
|
+
list-style: none;
|
|
278
|
+
margin: 0;
|
|
279
|
+
padding: 0;
|
|
280
|
+
display: grid;
|
|
281
|
+
}
|
|
282
|
+
.fb-row {
|
|
283
|
+
display: flex;
|
|
284
|
+
gap: 10px;
|
|
285
|
+
align-items: center;
|
|
286
|
+
padding: 8px 2px;
|
|
287
|
+
border-bottom: 1px solid var(--border);
|
|
288
|
+
font-size: 13px;
|
|
289
|
+
}
|
|
290
|
+
.fb-row:last-child {
|
|
291
|
+
border-bottom: 0;
|
|
292
|
+
}
|
|
293
|
+
.fb-row > div {
|
|
294
|
+
flex: 1;
|
|
295
|
+
min-width: 0;
|
|
296
|
+
display: grid;
|
|
297
|
+
gap: 2px;
|
|
298
|
+
}
|
|
299
|
+
.fb-row b {
|
|
300
|
+
overflow-wrap: anywhere;
|
|
301
|
+
}
|
|
302
|
+
.fb-row a {
|
|
303
|
+
color: var(--accent-text, var(--accent));
|
|
304
|
+
white-space: nowrap;
|
|
305
|
+
}
|
|
306
|
+
.fb-row button {
|
|
307
|
+
min-height: 32px;
|
|
308
|
+
padding: 0 10px;
|
|
309
|
+
border-radius: 0.2rem;
|
|
310
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
311
|
+
background: var(--surface, var(--bg));
|
|
312
|
+
color: var(--text);
|
|
313
|
+
font: 13px var(--sans);
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
}
|
|
316
|
+
.fb-dot {
|
|
317
|
+
width: 8px;
|
|
318
|
+
height: 8px;
|
|
319
|
+
border-radius: 50%;
|
|
320
|
+
background: var(--accent-text, var(--accent));
|
|
321
|
+
flex: none;
|
|
322
|
+
}
|
|
323
|
+
.fb-nodot {
|
|
324
|
+
width: 8px;
|
|
325
|
+
flex: none;
|
|
326
|
+
}
|
|
327
|
+
.fb-tools button {
|
|
328
|
+
min-height: 32px;
|
|
329
|
+
padding: 0 10px;
|
|
330
|
+
border-radius: 0.2rem;
|
|
331
|
+
border: 1px solid var(--border-strong, var(--border));
|
|
332
|
+
background: var(--surface, var(--bg));
|
|
333
|
+
color: var(--text);
|
|
334
|
+
font: 13px var(--sans);
|
|
335
|
+
cursor: pointer;
|
|
336
|
+
}
|
|
337
|
+
@media (max-width: 600px) {
|
|
338
|
+
.fb-dlg {
|
|
339
|
+
width: 100%;
|
|
340
|
+
max-width: 100%;
|
|
341
|
+
margin: 0;
|
|
342
|
+
inset: auto 0 0 0;
|
|
343
|
+
transform: none;
|
|
344
|
+
border-radius: 12px 12px 0 0;
|
|
345
|
+
max-height: 92vh;
|
|
346
|
+
}
|
|
347
|
+
.fb-b {
|
|
348
|
+
padding: 14px;
|
|
349
|
+
}
|
|
350
|
+
.fb-btns {
|
|
351
|
+
flex-direction: column;
|
|
352
|
+
position: sticky;
|
|
353
|
+
bottom: -14px;
|
|
354
|
+
background: var(--raised, var(--surface, var(--bg)));
|
|
355
|
+
padding-bottom: 14px;
|
|
356
|
+
}
|
|
357
|
+
.fb-btns button,
|
|
358
|
+
.fb-btns a {
|
|
359
|
+
width: 100%;
|
|
360
|
+
justify-content: center;
|
|
361
|
+
}
|
|
362
|
+
.fb-steps .fb-wide {
|
|
363
|
+
display: none;
|
|
364
|
+
}
|
|
365
|
+
.fb-shot {
|
|
366
|
+
text-align: center;
|
|
367
|
+
}
|
|
368
|
+
.fb-shot canvas,
|
|
369
|
+
.fb-shot img {
|
|
370
|
+
max-height: 45vh;
|
|
371
|
+
width: auto;
|
|
372
|
+
max-width: 100%;
|
|
373
|
+
display: inline-block;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
@media (min-width: 601px) {
|
|
377
|
+
.fb-steps .fb-narrow {
|
|
378
|
+
display: none;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
.kit-offscreen {
|
|
382
|
+
position: fixed;
|
|
383
|
+
opacity: 0;
|
|
384
|
+
top: 0;
|
|
385
|
+
left: 0;
|
|
386
|
+
pointer-events: none;
|
|
387
|
+
}
|
package/src/report.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface ReportForm {
|
|
2
|
+
kind?: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
/** The adapter's answer for the fuller calls. */
|
|
8
|
+
export interface Answer<T = Record<string, unknown>> {
|
|
9
|
+
status: number;
|
|
10
|
+
data: T;
|
|
11
|
+
}
|
|
12
|
+
export type Headers = Record<string, string>;
|
|
13
|
+
export interface ReportAdapter {
|
|
14
|
+
/** The simple way: "Filed as #N" with its link. */
|
|
15
|
+
fileReport?: (
|
|
16
|
+
payload: ReportForm & {
|
|
17
|
+
preview?: { title: string; body: string } | null;
|
|
18
|
+
/** The masked screenshot, a PNG data URL; null with "Don't include". */
|
|
19
|
+
shot: string | null;
|
|
20
|
+
},
|
|
21
|
+
) => Promise<{ number: number; url?: string } | { error: string }>;
|
|
22
|
+
info?: () => Promise<{
|
|
23
|
+
repos?: { repo: string }[];
|
|
24
|
+
maxPerHour?: number;
|
|
25
|
+
captureSeconds?: number;
|
|
26
|
+
}>;
|
|
27
|
+
diagnostics?: () => Promise<{ sections?: Record<string, string> }>;
|
|
28
|
+
preview?: (form: ReportForm, h: Headers) => Promise<Answer>;
|
|
29
|
+
send?: (form: ReportForm, h: Headers) => Promise<Answer>;
|
|
30
|
+
githubSend?: (form: ReportForm, h: Headers) => Promise<Answer>;
|
|
31
|
+
githubPoll?: (id: string) => Promise<Answer>;
|
|
32
|
+
saveDraft?: (form: ReportForm, h: Headers) => Promise<Answer>;
|
|
33
|
+
}
|
|
34
|
+
export interface ReportOptions {
|
|
35
|
+
lang?: string | (() => string);
|
|
36
|
+
adapter?: ReportAdapter | null;
|
|
37
|
+
busy?: (
|
|
38
|
+
action: string,
|
|
39
|
+
run: (headers: Headers) => Promise<unknown>,
|
|
40
|
+
opts?: object,
|
|
41
|
+
) => Promise<unknown>;
|
|
42
|
+
mine?: () => void;
|
|
43
|
+
page?: () => string;
|
|
44
|
+
screenshot?: boolean;
|
|
45
|
+
library?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function configureReport(o?: ReportOptions): void;
|
|
48
|
+
/** The kit's own preview of a report: its title and body as text. */
|
|
49
|
+
export declare function localPreview(f: ReportForm & { diag?: object }): {
|
|
50
|
+
title: string;
|
|
51
|
+
body: string;
|
|
52
|
+
};
|
|
53
|
+
export declare function copyReport(text: string): Promise<void>;
|
|
54
|
+
/** What the browser can tell (page, size, language, …), by section. */
|
|
55
|
+
export declare function clientSections(win?: Window): Record<string, string>;
|
|
56
|
+
export declare function openReport(opts?: {
|
|
57
|
+
prefill?: { kind?: string; title?: string; description?: string };
|
|
58
|
+
/** Focus goes back here on close (default: what opened it). */
|
|
59
|
+
opener?: Element | null;
|
|
60
|
+
draft?: string;
|
|
61
|
+
}): Promise<unknown>;
|