@vitrinka/web 0.7.1 → 0.8.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/CHANGELOG.md +128 -0
- package/README.md +117 -19
- package/build/hud.iife.js +11 -11
- package/build/recorder/config.d.ts +6 -2
- package/build/recorder/hud/Hud.d.ts +3 -1
- package/build/recorder/hud/Hud.js +2 -2
- package/build/recorder/hud/Menu.d.ts +7 -1
- package/build/recorder/hud/Menu.js +2 -2
- package/build/recorder/hud/host.d.ts +13 -0
- package/build/recorder/hud/host.js +96 -1
- package/build/recorder/hud/icons.d.ts +2 -0
- package/build/recorder/hud/icons.js +4 -0
- package/build/recorder/hud/mount.d.ts +2 -0
- package/build/recorder/hud/mount.js +1 -0
- package/build/recorder/index.d.ts +6 -0
- package/build/recorder/index.js +3 -0
- package/build/recorder/lead.js +12 -2
- package/build/recorder/link.js +1 -1
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/attachments.d.ts +56 -0
- package/build/report/attachments.js +91 -0
- package/build/report/drag.d.ts +18 -0
- package/build/report/drag.js +34 -0
- package/build/report/element.d.ts +11 -2
- package/build/report/element.js +106 -15
- package/build/report/engine.d.ts +5 -1
- package/build/report/engine.js +7 -1
- package/build/report/face.d.ts +23 -0
- package/build/report/face.js +92 -0
- package/build/report/i18n.d.ts +75 -3
- package/build/report/i18n.js +125 -6
- package/build/report/place.d.ts +26 -0
- package/build/report/place.js +33 -0
- package/build/report/reader.d.ts +42 -0
- package/build/report/reader.js +39 -0
- package/build/report/recorder-face.js +6 -2
- package/build/report/sent.d.ts +16 -0
- package/build/report/sent.js +39 -0
- package/build/report/settings.d.ts +32 -0
- package/build/report/settings.js +47 -0
- package/build/report/styles.d.ts +1 -1
- package/build/report/styles.js +216 -52
- package/build/report/widget.d.ts +109 -3
- package/build/report/widget.js +1063 -99
- package/build/report/wire.d.ts +20 -9
- package/build/report/wire.js +44 -9
- package/build/report-widget.mjs +223 -59
- package/package.json +1 -1
package/build/report/wire.d.ts
CHANGED
|
@@ -4,20 +4,23 @@
|
|
|
4
4
|
*
|
|
5
5
|
* POST /api/v1/reports envelope → {id, custody}
|
|
6
6
|
* PATCH /api/v1/reports/{id} {title?, description?, markers?, notify?}
|
|
7
|
+
* POST /api/v1/reports/{id}/attachment?name=<name>
|
|
8
|
+
* one file, raw body under its own Content-Type → {id, name, size, type}
|
|
7
9
|
* POST /api/v1/reports/{id}/chunk?seq=N raw rrweb event array (≤ 4 MiB, N from 1) → {blobKey}
|
|
8
10
|
* POST /api/v1/reports/{id}/events {events: [{seq, ts, tabHost, kind: "rrweb", payload, blobKey}]}
|
|
9
11
|
* POST /api/v1/reports/{id}/submit {} → {status: "filed" | "quarantined", reportUrl?}
|
|
10
12
|
*
|
|
11
|
-
* LEG-RESUMABLE: a job remembers which legs landed
|
|
12
|
-
* failed one
|
|
13
|
-
* after the report was created rides a
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* LEG-RESUMABLE: a job remembers which legs landed — each file, each chunk —
|
|
14
|
+
* so a retry resumes the failed one: one report, never a duplicate, never a
|
|
15
|
+
* file twice. Text the reporter changed after the report was created rides a
|
|
16
|
+
* PATCH. A file or a capture leg the server refuses for good (a permanent
|
|
17
|
+
* 4xx) is skipped with a warning: the report still files, without it. The
|
|
18
|
+
* reporter's files go before the replay — they are what they chose to send.
|
|
19
|
+
* `reportUrl` is the server's — shown as returned, never composed.
|
|
17
20
|
*/
|
|
18
21
|
import { type ApiTarget } from '../recorder/api';
|
|
19
22
|
import { type BuiltCapture, type ConsoleEntry, type NetEntry } from './engine';
|
|
20
|
-
import type { Locale } from './i18n';
|
|
23
|
+
import type { Locale, ReportKind } from './i18n';
|
|
21
24
|
import type { Identity } from './identity';
|
|
22
25
|
import type { WireMarker } from './markers';
|
|
23
26
|
export interface ReportEnv {
|
|
@@ -44,6 +47,8 @@ export interface ReportEnvelope {
|
|
|
44
47
|
/** The widget's language (the reporter reads mail and the portal in it). */
|
|
45
48
|
locale: Locale;
|
|
46
49
|
notify?: boolean;
|
|
50
|
+
/** The reporter's own word for it (vt-8020 D11), absent when they picked none. */
|
|
51
|
+
type?: ReportKind;
|
|
47
52
|
}
|
|
48
53
|
export interface SubmitReply {
|
|
49
54
|
status: 'filed' | 'quarantined';
|
|
@@ -53,6 +58,7 @@ export declare class ReportJob {
|
|
|
53
58
|
readonly capture: BuiltCapture;
|
|
54
59
|
private readonly tabHost;
|
|
55
60
|
private readonly target;
|
|
61
|
+
readonly files: readonly File[];
|
|
56
62
|
id: string;
|
|
57
63
|
custody: 'direct' | 'quarantined' | '';
|
|
58
64
|
/** The editable fields as the server last received them. */
|
|
@@ -60,9 +66,14 @@ export declare class ReportJob {
|
|
|
60
66
|
private readonly blobKeys;
|
|
61
67
|
private rowsPosted;
|
|
62
68
|
private skipCapture;
|
|
63
|
-
/**
|
|
64
|
-
|
|
69
|
+
/** The files (by index) the server has — landed or refused for good. */
|
|
70
|
+
private readonly filesDone;
|
|
71
|
+
/** `target`: the widget's own base and key — never whatever another widget configured. `files`: the reporter's attachments, fixed for the job. */
|
|
72
|
+
constructor(capture: BuiltCapture, tabHost: string, target: ApiTarget, files?: readonly File[]);
|
|
73
|
+
/** A file has not landed yet: the attachment leg is what a retry resumes. */
|
|
74
|
+
get filesPending(): boolean;
|
|
65
75
|
/** Run the legs from wherever the last run stopped; rejects with the failing leg's error. */
|
|
66
76
|
run(env: ReportEnvelope): Promise<SubmitReply>;
|
|
77
|
+
private sendFiles;
|
|
67
78
|
private sendCapture;
|
|
68
79
|
}
|
package/build/report/wire.js
CHANGED
|
@@ -4,16 +4,19 @@
|
|
|
4
4
|
*
|
|
5
5
|
* POST /api/v1/reports envelope → {id, custody}
|
|
6
6
|
* PATCH /api/v1/reports/{id} {title?, description?, markers?, notify?}
|
|
7
|
+
* POST /api/v1/reports/{id}/attachment?name=<name>
|
|
8
|
+
* one file, raw body under its own Content-Type → {id, name, size, type}
|
|
7
9
|
* POST /api/v1/reports/{id}/chunk?seq=N raw rrweb event array (≤ 4 MiB, N from 1) → {blobKey}
|
|
8
10
|
* POST /api/v1/reports/{id}/events {events: [{seq, ts, tabHost, kind: "rrweb", payload, blobKey}]}
|
|
9
11
|
* POST /api/v1/reports/{id}/submit {} → {status: "filed" | "quarantined", reportUrl?}
|
|
10
12
|
*
|
|
11
|
-
* LEG-RESUMABLE: a job remembers which legs landed
|
|
12
|
-
* failed one
|
|
13
|
-
* after the report was created rides a
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* LEG-RESUMABLE: a job remembers which legs landed — each file, each chunk —
|
|
14
|
+
* so a retry resumes the failed one: one report, never a duplicate, never a
|
|
15
|
+
* file twice. Text the reporter changed after the report was created rides a
|
|
16
|
+
* PATCH. A file or a capture leg the server refuses for good (a permanent
|
|
17
|
+
* 4xx) is skipped with a warning: the report still files, without it. The
|
|
18
|
+
* reporter's files go before the replay — they are what they chose to send.
|
|
19
|
+
* `reportUrl` is the server's — shown as returned, never composed.
|
|
17
20
|
*/
|
|
18
21
|
import { api, permanentStatus, uploadTo, VitrinkaApiError } from '../recorder/api';
|
|
19
22
|
import { EVENTS_PER_POST } from './engine';
|
|
@@ -21,6 +24,7 @@ export class ReportJob {
|
|
|
21
24
|
capture;
|
|
22
25
|
tabHost;
|
|
23
26
|
target;
|
|
27
|
+
files;
|
|
24
28
|
id = '';
|
|
25
29
|
custody = '';
|
|
26
30
|
/** The editable fields as the server last received them. */
|
|
@@ -28,11 +32,18 @@ export class ReportJob {
|
|
|
28
32
|
blobKeys = new Map();
|
|
29
33
|
rowsPosted = 0;
|
|
30
34
|
skipCapture = false;
|
|
31
|
-
/**
|
|
32
|
-
|
|
35
|
+
/** The files (by index) the server has — landed or refused for good. */
|
|
36
|
+
filesDone = new Set();
|
|
37
|
+
/** `target`: the widget's own base and key — never whatever another widget configured. `files`: the reporter's attachments, fixed for the job. */
|
|
38
|
+
constructor(capture, tabHost, target, files = []) {
|
|
33
39
|
this.capture = capture;
|
|
34
40
|
this.tabHost = tabHost;
|
|
35
41
|
this.target = target;
|
|
42
|
+
this.files = files;
|
|
43
|
+
}
|
|
44
|
+
/** A file has not landed yet: the attachment leg is what a retry resumes. */
|
|
45
|
+
get filesPending() {
|
|
46
|
+
return this.filesDone.size < this.files.length;
|
|
36
47
|
}
|
|
37
48
|
/** Run the legs from wherever the last run stopped; rejects with the failing leg's error. */
|
|
38
49
|
async run(env) {
|
|
@@ -40,7 +51,14 @@ export class ReportJob {
|
|
|
40
51
|
const edits = { title: env.title, description: env.description, markers: env.markers, notify: env.notify ?? false };
|
|
41
52
|
const editsKey = JSON.stringify(edits);
|
|
42
53
|
if (!this.id) {
|
|
43
|
-
const res = await api('POST', '/api/v1/reports', env, to)
|
|
54
|
+
const res = await api('POST', '/api/v1/reports', env, to).catch((e) => {
|
|
55
|
+
// A vitrinka older than the report type refuses the unknown field: the hint is optional, the report is not.
|
|
56
|
+
if (env.type === undefined || !(e instanceof VitrinkaApiError) || e.status !== 400 || !/\btype\b/.test(e.message))
|
|
57
|
+
throw e;
|
|
58
|
+
console.warn('vitrinka: this server takes no report type yet — sending the report without it');
|
|
59
|
+
const { type: _dropped, ...rest } = env;
|
|
60
|
+
return api('POST', '/api/v1/reports', rest, to);
|
|
61
|
+
});
|
|
44
62
|
if (typeof res.id !== 'string' || !res.id)
|
|
45
63
|
throw new Error('vitrinka: the server filed the report without an id');
|
|
46
64
|
this.id = res.id;
|
|
@@ -51,6 +69,7 @@ export class ReportJob {
|
|
|
51
69
|
await api('PATCH', `/api/v1/reports/${encodeURIComponent(this.id)}`, edits, to);
|
|
52
70
|
this.sent = editsKey;
|
|
53
71
|
}
|
|
72
|
+
await this.sendFiles();
|
|
54
73
|
if (!this.skipCapture) {
|
|
55
74
|
try {
|
|
56
75
|
await this.sendCapture();
|
|
@@ -68,6 +87,22 @@ export class ReportJob {
|
|
|
68
87
|
...(typeof reply.reportUrl === 'string' && reply.reportUrl ? { reportUrl: reply.reportUrl } : {}),
|
|
69
88
|
};
|
|
70
89
|
}
|
|
90
|
+
async sendFiles() {
|
|
91
|
+
const id = encodeURIComponent(this.id);
|
|
92
|
+
for (const [i, f] of this.files.entries()) {
|
|
93
|
+
if (this.filesDone.has(i))
|
|
94
|
+
continue;
|
|
95
|
+
try {
|
|
96
|
+
await uploadTo(`/api/v1/reports/${id}/attachment?name=${encodeURIComponent(f.name)}`, f.type || 'application/octet-stream', f, this.target);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
if (!(e instanceof VitrinkaApiError) || !permanentStatus(e.status))
|
|
100
|
+
throw e;
|
|
101
|
+
console.warn(`vitrinka: the server refused ${f.name} — the report goes without it`, e);
|
|
102
|
+
}
|
|
103
|
+
this.filesDone.add(i);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
71
106
|
async sendCapture() {
|
|
72
107
|
const id = encodeURIComponent(this.id);
|
|
73
108
|
const { chunks, truncated } = this.capture;
|