@vitrinka/web 0.7.2 → 0.8.1
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 +162 -0
- package/README.md +130 -23
- package/build/hud.iife.js +15 -15
- package/build/one.iife.js +1 -1
- package/build/recorder/api.d.ts +5 -3
- package/build/recorder/api.js +5 -3
- 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/link.js +1 -1
- package/build/recorder/storage/index.d.ts +1 -1
- package/build/recorder/storage/index.js +3 -2
- package/build/recorder/storage/lock.js +85 -3
- 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 +13 -1
- package/build/report/engine.js +31 -4
- package/build/report/face.d.ts +23 -0
- package/build/report/face.js +92 -0
- package/build/report/i18n.d.ts +77 -3
- package/build/report/i18n.js +127 -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 +223 -53
- package/build/report/widget.d.ts +122 -3
- package/build/report/widget.js +1125 -107
- package/build/report/wire.d.ts +59 -9
- package/build/report/wire.js +114 -14
- package/build/report-widget.mjs +232 -62
- package/package.json +1 -1
package/build/report/i18n.d.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* first-time reporter does not know the word.
|
|
9
9
|
*/
|
|
10
10
|
export type Locale = 'cs' | 'en';
|
|
11
|
+
export type ReportKind = 'bug' | 'suggestion' | 'question' | 'other';
|
|
12
|
+
export declare const REPORT_KINDS: readonly ReportKind[];
|
|
11
13
|
export interface Strings {
|
|
12
14
|
button: string;
|
|
13
15
|
title: string;
|
|
@@ -32,7 +34,11 @@ export interface Strings {
|
|
|
32
34
|
incIdentity: string;
|
|
33
35
|
incMarks: string;
|
|
34
36
|
showWhere: string;
|
|
35
|
-
|
|
37
|
+
/** The reporter's own word for what this is (vt-8020 D11) — a hint Eve reads, never the category. */
|
|
38
|
+
kinds: Record<ReportKind, string>;
|
|
39
|
+
kindsLabel: string;
|
|
40
|
+
/** The marks' list in the card while there are none yet. */
|
|
41
|
+
linesEmpty: string;
|
|
36
42
|
notify: string;
|
|
37
43
|
send: string;
|
|
38
44
|
sending: string;
|
|
@@ -50,8 +56,13 @@ export interface Strings {
|
|
|
50
56
|
hide: string;
|
|
51
57
|
};
|
|
52
58
|
toolbar: string;
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
/** The marking bar's one plain line. */
|
|
60
|
+
barLead: string;
|
|
61
|
+
/** Leaves marking and drops the marks of this pass (vt-8020 D12). */
|
|
62
|
+
cancelMarking: string;
|
|
63
|
+
discardMarks: (n: number) => string;
|
|
64
|
+
discard: string;
|
|
65
|
+
keep: string;
|
|
55
66
|
coach: string;
|
|
56
67
|
coachMore: string;
|
|
57
68
|
/** The marking layer's name, for assistive technology. */
|
|
@@ -70,6 +81,69 @@ export interface Strings {
|
|
|
70
81
|
needModifier: string;
|
|
71
82
|
removeShortcut: string;
|
|
72
83
|
back: string;
|
|
84
|
+
account: string;
|
|
85
|
+
menu: string;
|
|
86
|
+
anonymous: string;
|
|
87
|
+
anonymousHint: string;
|
|
88
|
+
signedInByApp: string;
|
|
89
|
+
linkVitrinka: string;
|
|
90
|
+
linkedAs: (who: string) => string;
|
|
91
|
+
unlink: string;
|
|
92
|
+
myReports: string;
|
|
93
|
+
recentRecordings: string;
|
|
94
|
+
record: string;
|
|
95
|
+
/** Why Record waits: the switch to the pill would lose the unsent report. */
|
|
96
|
+
recordHasDraft: string;
|
|
97
|
+
openVitrinka: string;
|
|
98
|
+
openPortal: string;
|
|
99
|
+
loading: string;
|
|
100
|
+
listFailed: string;
|
|
101
|
+
noReports: string;
|
|
102
|
+
noRecordings: string;
|
|
103
|
+
fromThisBrowser: string;
|
|
104
|
+
/** A report's step as the portal names it; an unknown key shows as is. */
|
|
105
|
+
steps: Record<string, string>;
|
|
106
|
+
waiting: string;
|
|
107
|
+
sentQueued: string;
|
|
108
|
+
linkCode: string;
|
|
109
|
+
linkHint: string;
|
|
110
|
+
linkWaiting: string;
|
|
111
|
+
linkExpired: string;
|
|
112
|
+
linkFailed: string;
|
|
113
|
+
attach: string;
|
|
114
|
+
removeFile: (name: string) => string;
|
|
115
|
+
fileTooBig: (name: string, cap: string) => string;
|
|
116
|
+
tooManyFiles: (n: number) => string;
|
|
117
|
+
fileType: (name: string, types: string) => string;
|
|
118
|
+
/** The default caps' types as a person reads them (the rest show as configured). */
|
|
119
|
+
typeNames: {
|
|
120
|
+
image: string;
|
|
121
|
+
pdf: string;
|
|
122
|
+
text: string;
|
|
123
|
+
office: string;
|
|
124
|
+
};
|
|
125
|
+
incFiles: string;
|
|
126
|
+
errorFiles: string;
|
|
127
|
+
moveHint: string;
|
|
128
|
+
size: string;
|
|
129
|
+
sizes: {
|
|
130
|
+
sm: string;
|
|
131
|
+
md: string;
|
|
132
|
+
lg: string;
|
|
133
|
+
};
|
|
134
|
+
techDetails: string;
|
|
135
|
+
techVersion: string;
|
|
136
|
+
techWindow: string;
|
|
137
|
+
techCapture: string;
|
|
138
|
+
techBuffer: string;
|
|
139
|
+
techServer: string;
|
|
140
|
+
captureOn: string;
|
|
141
|
+
captureOff: string;
|
|
142
|
+
captureStarting: string;
|
|
143
|
+
bufferMemory: string;
|
|
144
|
+
bufferBrowser: string;
|
|
145
|
+
/** "5 minutes" for a capture window of `sec` seconds. */
|
|
146
|
+
windowLength: (sec: number) => string;
|
|
73
147
|
}
|
|
74
148
|
export declare function strings(locale: Locale): Strings;
|
|
75
149
|
/** `cs`, `cs-CZ`, `CS` → cs; `en-GB` → en; anything else → null. */
|
package/build/report/i18n.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const REPORT_KINDS = ['bug', 'suggestion', 'question', 'other'];
|
|
1
2
|
/** Czech plural: 1 · 2–4 · 5+ (and 0). */
|
|
2
3
|
function csPlural(n, one, few, many) {
|
|
3
4
|
if (n === 1)
|
|
@@ -34,7 +35,9 @@ const en = {
|
|
|
34
35
|
incIdentity: 'Your name and email from this app',
|
|
35
36
|
incMarks: 'The places you marked, with your notes',
|
|
36
37
|
showWhere: 'Show us where',
|
|
37
|
-
|
|
38
|
+
kinds: { bug: 'Bug', suggestion: 'Suggestion', question: 'Question', other: 'Other' },
|
|
39
|
+
kindsLabel: 'What is it?',
|
|
40
|
+
linesEmpty: 'Each place you mark gets a line here for its note.',
|
|
38
41
|
notify: 'Email me when it’s fixed',
|
|
39
42
|
send: 'Send',
|
|
40
43
|
sending: 'Sending…',
|
|
@@ -47,8 +50,11 @@ const en = {
|
|
|
47
50
|
seeReport: 'See your report',
|
|
48
51
|
tools: { circle: 'Circle', box: 'Box', arrow: 'Arrow', hide: 'Hide' },
|
|
49
52
|
toolbar: 'Marking tools',
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
barLead: 'Mark where the problem is',
|
|
54
|
+
cancelMarking: 'Cancel',
|
|
55
|
+
discardMarks: (n) => (n === 1 ? 'Discard 1 mark?' : `Discard ${n} marks?`),
|
|
56
|
+
discard: 'Discard',
|
|
57
|
+
keep: 'Keep',
|
|
52
58
|
coach: 'Click, hold and move around the problem.',
|
|
53
59
|
coachMore: 'You can mark more than one place.',
|
|
54
60
|
marking: 'Marking',
|
|
@@ -65,6 +71,61 @@ const en = {
|
|
|
65
71
|
needModifier: 'Add Ctrl, Alt or ⌘ — a key on its own would get in the way of typing',
|
|
66
72
|
removeShortcut: 'Remove',
|
|
67
73
|
back: 'Back',
|
|
74
|
+
account: 'Your account',
|
|
75
|
+
menu: 'Menu',
|
|
76
|
+
anonymous: 'Not signed in',
|
|
77
|
+
anonymousHint: 'The team checks your report before it’s filed.',
|
|
78
|
+
signedInByApp: 'Signed in by this app',
|
|
79
|
+
linkVitrinka: 'Link your vitrinka account',
|
|
80
|
+
linkedAs: (who) => `Linked to vitrinka as ${who}`,
|
|
81
|
+
unlink: 'Unlink',
|
|
82
|
+
myReports: 'My reports',
|
|
83
|
+
recentRecordings: 'Recent recordings',
|
|
84
|
+
record: 'Record',
|
|
85
|
+
recordHasDraft: 'Send or clear the report you started first',
|
|
86
|
+
openVitrinka: 'Open vitrinka',
|
|
87
|
+
openPortal: 'Open the report portal',
|
|
88
|
+
loading: 'Loading…',
|
|
89
|
+
listFailed: 'Couldn’t load — try again',
|
|
90
|
+
noReports: 'No reports yet.',
|
|
91
|
+
noRecordings: 'No recordings yet.',
|
|
92
|
+
fromThisBrowser: 'Sent from this browser',
|
|
93
|
+
steps: { received: 'Received', planned: 'Planned', in_progress: 'In progress', fixed: 'Fixed', done: 'Done' },
|
|
94
|
+
waiting: 'Waiting for approval',
|
|
95
|
+
sentQueued: 'The team checks it before it’s filed.',
|
|
96
|
+
linkCode: 'Your code',
|
|
97
|
+
linkHint: 'Approve this code in vitrinka — on this device or another one where you’re signed in.',
|
|
98
|
+
linkWaiting: 'Waiting for approval…',
|
|
99
|
+
linkExpired: 'The code expired.',
|
|
100
|
+
linkFailed: 'Linking didn’t work.',
|
|
101
|
+
attach: 'Attach a file',
|
|
102
|
+
removeFile: (name) => `Remove ${name}`,
|
|
103
|
+
fileTooBig: (name, cap) => `${name} is over the ${cap} limit`,
|
|
104
|
+
tooManyFiles: (n) => (n === 1 ? 'Up to 1 file per report' : `Up to ${n} files per report`),
|
|
105
|
+
fileType: (name, types) => `${name} can’t be attached — ${types} only`,
|
|
106
|
+
typeNames: { image: 'images', pdf: 'PDF', text: 'text files', office: 'office documents' },
|
|
107
|
+
incFiles: 'The files you attached',
|
|
108
|
+
errorFiles: 'Your report arrived, a file not yet — try again to attach it',
|
|
109
|
+
moveHint: 'Click, hold and move it to another corner, or press Alt and an arrow key.',
|
|
110
|
+
size: 'Size',
|
|
111
|
+
sizes: { sm: 'Small', md: 'Medium', lg: 'Large' },
|
|
112
|
+
techDetails: 'Technical details',
|
|
113
|
+
techVersion: 'Version',
|
|
114
|
+
techWindow: 'Capture window',
|
|
115
|
+
techCapture: 'Capture',
|
|
116
|
+
techBuffer: 'Buffer',
|
|
117
|
+
techServer: 'Server',
|
|
118
|
+
captureOn: 'Running',
|
|
119
|
+
captureOff: 'Off',
|
|
120
|
+
captureStarting: 'Starting…',
|
|
121
|
+
bufferMemory: 'In memory',
|
|
122
|
+
bufferBrowser: 'In this browser',
|
|
123
|
+
windowLength: (sec) => {
|
|
124
|
+
if (sec < 60)
|
|
125
|
+
return sec === 1 ? '1 second' : `${sec} seconds`;
|
|
126
|
+
const min = Math.round(sec / 60);
|
|
127
|
+
return min === 1 ? '1 minute' : `${min} minutes`;
|
|
128
|
+
},
|
|
68
129
|
};
|
|
69
130
|
const cs = {
|
|
70
131
|
button: 'Nahlásit problém',
|
|
@@ -95,7 +156,9 @@ const cs = {
|
|
|
95
156
|
incIdentity: 'Vaše jméno a e-mail z této aplikace',
|
|
96
157
|
incMarks: 'Místa, která jste označili, i s poznámkami',
|
|
97
158
|
showWhere: 'Ukažte nám kde',
|
|
98
|
-
|
|
159
|
+
kinds: { bug: 'Chyba', suggestion: 'Návrh', question: 'Dotaz', other: 'Jiné' },
|
|
160
|
+
kindsLabel: 'Co to je?',
|
|
161
|
+
linesEmpty: 'Každé označené místo tu dostane řádek pro poznámku.',
|
|
99
162
|
notify: 'Pošlete mi e-mail, až to bude opravené',
|
|
100
163
|
send: 'Odeslat',
|
|
101
164
|
sending: 'Odesílám…',
|
|
@@ -108,8 +171,11 @@ const cs = {
|
|
|
108
171
|
seeReport: 'Zobrazit hlášení',
|
|
109
172
|
tools: { circle: 'Kruh', box: 'Obdélník', arrow: 'Šipka', hide: 'Skrýt' },
|
|
110
173
|
toolbar: 'Nástroje pro označení',
|
|
111
|
-
|
|
112
|
-
|
|
174
|
+
barLead: 'Označte, kde je problém',
|
|
175
|
+
cancelMarking: 'Zrušit',
|
|
176
|
+
discardMarks: (n) => csPlural(n, 'Zahodit 1 značku?', `Zahodit ${n} značky?`, `Zahodit ${n} značek?`),
|
|
177
|
+
discard: 'Zahodit',
|
|
178
|
+
keep: 'Ponechat',
|
|
113
179
|
coach: 'Klikněte, podržte a veďte kolem problému.',
|
|
114
180
|
coachMore: 'Označit můžete i více míst.',
|
|
115
181
|
marking: 'Označování',
|
|
@@ -126,6 +192,61 @@ const cs = {
|
|
|
126
192
|
needModifier: 'Přidejte Ctrl, Alt nebo ⌘ — samotná klávesa by překážela při psaní',
|
|
127
193
|
removeShortcut: 'Odebrat',
|
|
128
194
|
back: 'Zpět',
|
|
195
|
+
account: 'Váš účet',
|
|
196
|
+
menu: 'Nabídka',
|
|
197
|
+
anonymous: 'Nepřihlášeno',
|
|
198
|
+
anonymousHint: 'Hlášení nejdřív zkontroluje tým.',
|
|
199
|
+
signedInByApp: 'Přihlášen touto aplikací',
|
|
200
|
+
linkVitrinka: 'Propojit s vitrinkou',
|
|
201
|
+
linkedAs: (who) => `Propojeno s vitrinkou jako ${who}`,
|
|
202
|
+
unlink: 'Odpojit',
|
|
203
|
+
myReports: 'Moje hlášení',
|
|
204
|
+
recentRecordings: 'Nedávné nahrávky',
|
|
205
|
+
record: 'Nahrávat',
|
|
206
|
+
recordHasDraft: 'Odešlete nebo smažte rozepsané hlášení',
|
|
207
|
+
openVitrinka: 'Otevřít vitrinku',
|
|
208
|
+
openPortal: 'Otevřít portál hlášení',
|
|
209
|
+
loading: 'Načítám…',
|
|
210
|
+
listFailed: 'Nepodařilo se načíst — zkuste to znovu',
|
|
211
|
+
noReports: 'Zatím žádná hlášení.',
|
|
212
|
+
noRecordings: 'Zatím žádné nahrávky.',
|
|
213
|
+
fromThisBrowser: 'Odesláno z tohoto prohlížeče',
|
|
214
|
+
steps: { received: 'Přijato', planned: 'Naplánováno', in_progress: 'Řešíme', fixed: 'Opraveno', done: 'Hotovo' },
|
|
215
|
+
waiting: 'Čeká na schválení',
|
|
216
|
+
sentQueued: 'Než ho zařadíme, tým ho zkontroluje.',
|
|
217
|
+
linkCode: 'Váš kód',
|
|
218
|
+
linkHint: 'Schvalte kód ve vitrince — na tomto nebo jiném zařízení, kde jste přihlášeni.',
|
|
219
|
+
linkWaiting: 'Čekám na schválení…',
|
|
220
|
+
linkExpired: 'Kód vypršel.',
|
|
221
|
+
linkFailed: 'Propojení se nepodařilo.',
|
|
222
|
+
attach: 'Přiložit soubor',
|
|
223
|
+
removeFile: (name) => `Odebrat ${name}`,
|
|
224
|
+
fileTooBig: (name, cap) => `${name} přesahuje limit ${cap}`,
|
|
225
|
+
tooManyFiles: (n) => csPlural(n, 'Nejvýš 1 soubor na hlášení', `Nejvýš ${n} soubory na hlášení`, `Nejvýš ${n} souborů na hlášení`),
|
|
226
|
+
fileType: (name, types) => `${name} nelze přiložit — jen ${types}`,
|
|
227
|
+
typeNames: { image: 'obrázky', pdf: 'PDF', text: 'textové soubory', office: 'kancelářské dokumenty' },
|
|
228
|
+
incFiles: 'Soubory, které jste přiložili',
|
|
229
|
+
errorFiles: 'Hlášení dorazilo, soubor zatím ne — zkuste to znovu a přiložíme ho',
|
|
230
|
+
moveHint: 'Klikněte, podržte a veďte ho do jiného rohu, nebo stiskněte Alt a šipku.',
|
|
231
|
+
size: 'Velikost',
|
|
232
|
+
sizes: { sm: 'Malá', md: 'Střední', lg: 'Velká' },
|
|
233
|
+
techDetails: 'Technické údaje',
|
|
234
|
+
techVersion: 'Verze',
|
|
235
|
+
techWindow: 'Okno záznamu',
|
|
236
|
+
techCapture: 'Záznam',
|
|
237
|
+
techBuffer: 'Vyrovnávací paměť',
|
|
238
|
+
techServer: 'Server',
|
|
239
|
+
captureOn: 'Běží',
|
|
240
|
+
captureOff: 'Vypnutý',
|
|
241
|
+
captureStarting: 'Spouští se…',
|
|
242
|
+
bufferMemory: 'V paměti',
|
|
243
|
+
bufferBrowser: 'V tomto prohlížeči',
|
|
244
|
+
windowLength: (sec) => {
|
|
245
|
+
if (sec < 60)
|
|
246
|
+
return csPlural(sec, '1 sekunda', `${sec} sekundy`, `${sec} sekund`);
|
|
247
|
+
const min = Math.round(sec / 60);
|
|
248
|
+
return csPlural(min, '1 minuta', `${min} minuty`, `${min} minut`);
|
|
249
|
+
},
|
|
129
250
|
};
|
|
130
251
|
const CATALOGS = { cs, en };
|
|
131
252
|
export function strings(locale) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the one card sits while the reporter marks (vt-8020 D10 A): parked in
|
|
3
|
+
* a corner of the viewport, clear of the top bar, and moved only when a mark
|
|
4
|
+
* lands under it — then to the corner that covers the least of the marks. The
|
|
5
|
+
* card never jumps between equally good corners: the current one wins a tie.
|
|
6
|
+
*/
|
|
7
|
+
import type { Rect } from './markers';
|
|
8
|
+
export type Corner = 'br' | 'bl' | 'tr' | 'tl';
|
|
9
|
+
export interface Frame {
|
|
10
|
+
vw: number;
|
|
11
|
+
vh: number;
|
|
12
|
+
/** The card's fixed size. */
|
|
13
|
+
w: number;
|
|
14
|
+
h: number;
|
|
15
|
+
/**
|
|
16
|
+
* Clear space kept at the top (the marking bar), at the bottom and at the
|
|
17
|
+
* sides — the widget takes them from where the card rests when marking
|
|
18
|
+
* starts, so starting never moves it.
|
|
19
|
+
*/
|
|
20
|
+
top: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
edge: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function cornerRect(c: Corner, f: Frame): Rect;
|
|
25
|
+
/** The corner the card should be in: `current` while it covers no mark, else the least-covering one. */
|
|
26
|
+
export declare function pickCorner(current: Corner, marks: readonly Rect[], f: Frame): Corner;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const ORDER = ['br', 'bl', 'tr', 'tl'];
|
|
2
|
+
/** Breathing room around a mark: a card touching a mark's stroke still hides it. */
|
|
3
|
+
const PAD = 12;
|
|
4
|
+
export function cornerRect(c, f) {
|
|
5
|
+
const x = c === 'br' || c === 'tr' ? f.vw - f.w - f.edge : f.edge;
|
|
6
|
+
const y = c === 'br' || c === 'bl' ? f.vh - f.h - f.bottom : f.top;
|
|
7
|
+
return { x: Math.max(f.edge, x), y: Math.max(f.top, y), w: f.w, h: f.h };
|
|
8
|
+
}
|
|
9
|
+
function overlap(a, b) {
|
|
10
|
+
const w = Math.min(a.x + a.w, b.x + b.w + PAD) - Math.max(a.x, b.x - PAD);
|
|
11
|
+
const h = Math.min(a.y + a.h, b.y + b.h + PAD) - Math.max(a.y, b.y - PAD);
|
|
12
|
+
return w > 0 && h > 0 ? w * h : 0;
|
|
13
|
+
}
|
|
14
|
+
function covered(c, marks, f) {
|
|
15
|
+
const r = cornerRect(c, f);
|
|
16
|
+
return marks.reduce((sum, m) => sum + overlap(r, m), 0);
|
|
17
|
+
}
|
|
18
|
+
/** The corner the card should be in: `current` while it covers no mark, else the least-covering one. */
|
|
19
|
+
export function pickCorner(current, marks, f) {
|
|
20
|
+
const here = covered(current, marks, f);
|
|
21
|
+
if (here === 0)
|
|
22
|
+
return current;
|
|
23
|
+
let best = current;
|
|
24
|
+
let bestCover = here;
|
|
25
|
+
for (const c of ORDER) {
|
|
26
|
+
const cover = covered(c, marks, f);
|
|
27
|
+
if (cover < bestCover) {
|
|
28
|
+
best = c;
|
|
29
|
+
bestCover = cover;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return best;
|
|
33
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading back what the reporter sent (vt-8020 D4), on the widget's own
|
|
3
|
+
* publishable key: the host's signed token is traded once for a short-lived
|
|
4
|
+
* reporter session, which then lists the reporter's reports and their news.
|
|
5
|
+
* A `vkb_` key alone reads nothing — every list call carries the session.
|
|
6
|
+
*
|
|
7
|
+
* POST /api/v1/report/session {token} → {reporter, session, expiresAt, portalUrl?}
|
|
8
|
+
* GET /api/v1/report/mine?cursor= X-Vitrinka-Reporter → {reports, nextCursor}
|
|
9
|
+
* GET /api/v1/report/updates?cursor= X-Vitrinka-Reporter → {updates, nextCursor}
|
|
10
|
+
*/
|
|
11
|
+
import { type ApiTarget } from '../recorder/api';
|
|
12
|
+
export interface Reporter {
|
|
13
|
+
id: string;
|
|
14
|
+
email: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ReporterSession {
|
|
18
|
+
reporter: Reporter;
|
|
19
|
+
session: string;
|
|
20
|
+
/** ISO time the session stops being accepted. */
|
|
21
|
+
expiresAt: string;
|
|
22
|
+
/** The project's reporter portal, when one is bound. */
|
|
23
|
+
portalUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
/** One of the reporter's reports, as the portal projects it. */
|
|
26
|
+
export interface MyReport {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
/** Received · Planned · In progress · Fixed · Done, as the server words the step key. */
|
|
30
|
+
step: string;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
url: string;
|
|
34
|
+
}
|
|
35
|
+
export interface MyReports {
|
|
36
|
+
reports: MyReport[];
|
|
37
|
+
nextCursor?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function openSession(target: ApiTarget, token: string): Promise<ReporterSession>;
|
|
40
|
+
/** Still good for at least a minute more. */
|
|
41
|
+
export declare function sessionLive(s: ReporterSession | null, now?: number): s is ReporterSession;
|
|
42
|
+
export declare function listMine(target: ApiTarget, session: string, cursor?: string): Promise<MyReports>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading back what the reporter sent (vt-8020 D4), on the widget's own
|
|
3
|
+
* publishable key: the host's signed token is traded once for a short-lived
|
|
4
|
+
* reporter session, which then lists the reporter's reports and their news.
|
|
5
|
+
* A `vkb_` key alone reads nothing — every list call carries the session.
|
|
6
|
+
*
|
|
7
|
+
* POST /api/v1/report/session {token} → {reporter, session, expiresAt, portalUrl?}
|
|
8
|
+
* GET /api/v1/report/mine?cursor= X-Vitrinka-Reporter → {reports, nextCursor}
|
|
9
|
+
* GET /api/v1/report/updates?cursor= X-Vitrinka-Reporter → {updates, nextCursor}
|
|
10
|
+
*/
|
|
11
|
+
import { VitrinkaApiError } from '../recorder/api';
|
|
12
|
+
async function call(method, path, target, body, session) {
|
|
13
|
+
const res = await fetch(target.url + path, {
|
|
14
|
+
method,
|
|
15
|
+
mode: 'cors',
|
|
16
|
+
credentials: 'omit',
|
|
17
|
+
headers: {
|
|
18
|
+
authorization: `Bearer ${target.key}`,
|
|
19
|
+
...(session ? { 'x-vitrinka-reporter': session } : {}),
|
|
20
|
+
...(body !== undefined ? { 'content-type': 'application/json' } : {}),
|
|
21
|
+
},
|
|
22
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
23
|
+
});
|
|
24
|
+
const text = await res.text();
|
|
25
|
+
if (!res.ok)
|
|
26
|
+
throw new VitrinkaApiError(`${method} ${path} → ${res.status}: ${text}`, res.status);
|
|
27
|
+
return (text ? JSON.parse(text) : {});
|
|
28
|
+
}
|
|
29
|
+
export function openSession(target, token) {
|
|
30
|
+
return call('POST', '/api/v1/report/session', target, { token });
|
|
31
|
+
}
|
|
32
|
+
/** Still good for at least a minute more. */
|
|
33
|
+
export function sessionLive(s, now = Date.now()) {
|
|
34
|
+
return s !== null && Date.parse(s.expiresAt) - now > 60_000;
|
|
35
|
+
}
|
|
36
|
+
export function listMine(target, session, cursor) {
|
|
37
|
+
const q = cursor ? `?cursor=${encodeURIComponent(cursor)}` : '';
|
|
38
|
+
return call('GET', `/api/v1/report/mine${q}`, target, undefined, session);
|
|
39
|
+
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* `face: 'recorder'` (QA Studio D6): the same engine with the recorder pill
|
|
3
3
|
* as its face — `VitrinkaRecorderRoot` + `VitrinkaRecorderPill` rendered
|
|
4
4
|
* into a detached root of their own. Loaded lazily by the npm entry only, so
|
|
5
|
-
* a report-only host never pays for React or the recorder.
|
|
5
|
+
* a report-only host never pays for React or the recorder. Mounted by a
|
|
6
|
+
* member's Record switch (vt-8020 D8) it gets no key — the device link
|
|
7
|
+
* authenticates — and `onReportFace`, the pill's way back.
|
|
6
8
|
*/
|
|
7
9
|
import { createElement } from 'react';
|
|
8
10
|
import { createRoot } from 'react-dom/client';
|
|
@@ -12,7 +14,9 @@ export function mountRecorderFace(opts) {
|
|
|
12
14
|
container.hidden = true;
|
|
13
15
|
document.body.append(container);
|
|
14
16
|
const root = createRoot(container);
|
|
15
|
-
root.render(createElement(VitrinkaRecorderRoot,
|
|
17
|
+
root.render(createElement(VitrinkaRecorderRoot,
|
|
18
|
+
// '' rather than undefined: an absent key would fall back to a baked NEXT_PUBLIC_VITRINKA_KEY.
|
|
19
|
+
{ url: opts.base, recorderKey: opts.key ?? '', appVersion: opts.appVersion, sanitizeUrl: opts.sanitizeUrl }, createElement(VitrinkaRecorderPill, { onReportFace: opts.onReportFace })));
|
|
16
20
|
return () => {
|
|
17
21
|
root.unmount();
|
|
18
22
|
container.remove();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this browser sent (vt-8020 D4): an anonymous or unsigned reporter has
|
|
3
|
+
* no server list to read, so the widget keeps its own — title, time, filed or
|
|
4
|
+
* waiting, and the story link when the server minted one. Scoped to the
|
|
5
|
+
* vitrinka base and the page's host, newest first, capped.
|
|
6
|
+
*/
|
|
7
|
+
export interface SentReport {
|
|
8
|
+
title: string;
|
|
9
|
+
/** Epoch ms. */
|
|
10
|
+
at: number;
|
|
11
|
+
status: 'filed' | 'quarantined';
|
|
12
|
+
url?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const MAX_SENT = 20;
|
|
15
|
+
export declare function readSent(base: string, host: string): SentReport[];
|
|
16
|
+
export declare function noteSent(base: string, host: string, row: SentReport): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const MAX_SENT = 20;
|
|
2
|
+
const PREFIX = 'vitrinka.report.sent:';
|
|
3
|
+
function keyOf(base, host) {
|
|
4
|
+
return `${PREFIX}${base}|${host}`;
|
|
5
|
+
}
|
|
6
|
+
function store() {
|
|
7
|
+
try {
|
|
8
|
+
return globalThis.localStorage ?? null;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null; // storage blocked (sandboxed frame, privacy mode): the list just stays empty
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function readSent(base, host) {
|
|
15
|
+
const raw = store()?.getItem(keyOf(base, host));
|
|
16
|
+
if (!raw)
|
|
17
|
+
return [];
|
|
18
|
+
try {
|
|
19
|
+
const rows = JSON.parse(raw);
|
|
20
|
+
if (!Array.isArray(rows))
|
|
21
|
+
return [];
|
|
22
|
+
return rows.filter((r) => typeof r?.title === 'string' && typeof r?.at === 'number' && (r.status === 'filed' || r.status === 'quarantined'));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function noteSent(base, host, row) {
|
|
29
|
+
const s = store();
|
|
30
|
+
if (!s)
|
|
31
|
+
return;
|
|
32
|
+
const rows = [row, ...readSent(base, host)].slice(0, MAX_SENT);
|
|
33
|
+
try {
|
|
34
|
+
s.setItem(keyOf(base, host), JSON.stringify(rows));
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
console.warn('vitrinka: could not remember the sent report on this browser', e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reporter's own settings beyond the shortcut (vt-8020 D9): the widget's
|
|
3
|
+
* size and the technical details a support conversation asks for. Each
|
|
4
|
+
* setting is one localStorage key of this origin — the reporter's, on this
|
|
5
|
+
* browser, never sent anywhere.
|
|
6
|
+
*
|
|
7
|
+
* Size is the pill's vocabulary (sm · md · lg, the same factors): ONE factor,
|
|
8
|
+
* `--vr-scale` on the widget's root, scales the button, the card and the
|
|
9
|
+
* marking bar — fonts and boxes together, so the card keeps its proportions.
|
|
10
|
+
*/
|
|
11
|
+
import type { ReportConfig } from './engine';
|
|
12
|
+
import type { Strings } from './i18n';
|
|
13
|
+
export type WidgetSize = 'sm' | 'md' | 'lg';
|
|
14
|
+
export declare const SIZES: readonly WidgetSize[];
|
|
15
|
+
export declare const SIZE_SCALE: Readonly<Record<WidgetSize, number>>;
|
|
16
|
+
export declare const SIZE_KEY = "vitrinka.report.size";
|
|
17
|
+
/** One stored preference; null when unset or unreadable. */
|
|
18
|
+
export declare function readPref(key: string): string | null;
|
|
19
|
+
export declare function writePref(key: string, value: string): void;
|
|
20
|
+
export declare function readSize(): WidgetSize;
|
|
21
|
+
export interface TechInput {
|
|
22
|
+
/** The package version (recorder/version.ts). */
|
|
23
|
+
version: string;
|
|
24
|
+
base: string;
|
|
25
|
+
/** null until the report config answered. */
|
|
26
|
+
config: ReportConfig | null;
|
|
27
|
+
/** False when another widget runs the page's one capture engine. */
|
|
28
|
+
engine: boolean;
|
|
29
|
+
locale: string;
|
|
30
|
+
}
|
|
31
|
+
/** The read-only technical details, label → value: version, capture window, capture, buffer, server. */
|
|
32
|
+
export declare function techDetails(t: TechInput, s: Strings): [string, string][];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { formatBytes } from './attachments';
|
|
2
|
+
export const SIZES = ['sm', 'md', 'lg'];
|
|
3
|
+
export const SIZE_SCALE = { sm: 0.88, md: 1, lg: 1.18 };
|
|
4
|
+
export const SIZE_KEY = 'vitrinka.report.size';
|
|
5
|
+
function store() {
|
|
6
|
+
try {
|
|
7
|
+
return globalThis.localStorage ?? null;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null; // storage blocked (sandboxed frame, privacy mode): the defaults stand
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** One stored preference; null when unset or unreadable. */
|
|
14
|
+
export function readPref(key) {
|
|
15
|
+
return store()?.getItem(key) ?? null;
|
|
16
|
+
}
|
|
17
|
+
export function writePref(key, value) {
|
|
18
|
+
try {
|
|
19
|
+
store()?.setItem(key, value);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.warn(`vitrinka: could not remember ${key} on this browser`, e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function readSize() {
|
|
26
|
+
const v = readPref(SIZE_KEY);
|
|
27
|
+
return SIZES.find((s) => s === v) ?? 'md';
|
|
28
|
+
}
|
|
29
|
+
/** The read-only technical details, label → value: version, capture window, capture, buffer, server. */
|
|
30
|
+
export function techDetails(t, s) {
|
|
31
|
+
const c = t.config;
|
|
32
|
+
const capture = !t.engine || c?.capturing === false ? s.captureOff : c ? s.captureOn : s.captureStarting;
|
|
33
|
+
let host = t.base;
|
|
34
|
+
try {
|
|
35
|
+
host = new URL(t.base).host;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// not a URL: show it as configured
|
|
39
|
+
}
|
|
40
|
+
return [
|
|
41
|
+
[s.techVersion, `@vitrinka/web ${t.version}`],
|
|
42
|
+
[s.techWindow, c ? s.windowLength(c.profile.windowSec) : '—'],
|
|
43
|
+
[s.techCapture, capture],
|
|
44
|
+
[s.techBuffer, c ? `${c.profile.storage === 'browser' ? s.bufferBrowser : s.bufferMemory} · ${formatBytes(c.profile.maxBytes, t.locale)}` : '—'],
|
|
45
|
+
[s.techServer, host],
|
|
46
|
+
];
|
|
47
|
+
}
|