@vitrinka/web 0.9.0 → 0.9.2
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 +47 -0
- package/README.md +9 -2
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/face.d.ts +14 -0
- package/build/report/face.js +18 -0
- package/build/report/keybind.d.ts +2 -0
- package/build/report/keybind.js +4 -0
- package/build/report/reader.d.ts +19 -2
- package/build/report/reader.js +32 -3
- package/build/report/widget.d.ts +29 -6
- package/build/report/widget.js +96 -34
- package/build/report/wire.d.ts +37 -3
- package/build/report/wire.js +60 -11
- package/build/report-widget.mjs +5 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @vitrinka/web
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
- **A linked member co-owns what they report.** When this browser holds a
|
|
6
|
+
vitrinka member link for the widget's `base`, Report a problem proves it
|
|
7
|
+
to the server: the link's token rides in the body of the report
|
|
8
|
+
(`memberToken` on `POST /api/v1/reports`) and of the reporter session
|
|
9
|
+
(`POST /api/v1/report/session {token, memberToken}`), so the member owns
|
|
10
|
+
the report beside the reporter and finds it in **My reports**. Your
|
|
11
|
+
`vkb_` key stays the bearer. A link minted on another vitrinka is never
|
|
12
|
+
sent, and neither is a `vkr_` key your build passes. With a reporter your
|
|
13
|
+
server signed and a linked member, My reports lists what vitrinka returns
|
|
14
|
+
for the two: the reporter's reports and the member's. Without a signed
|
|
15
|
+
reporter there is still no session, and My reports stays this browser's
|
|
16
|
+
list.
|
|
17
|
+
- **A link vitrinka refuses never costs the report.** Either call may come
|
|
18
|
+
back with `memberError`: the link was revoked, belongs to another
|
|
19
|
+
workspace, or its person is no longer a member. The report files anyway,
|
|
20
|
+
and the console says why once. A revoked link, or one whose person left,
|
|
21
|
+
is forgotten, as a link a session door answers 401 is. A link for another
|
|
22
|
+
workspace stays.
|
|
23
|
+
- **Linking, unlinking or relinking opens a fresh session.** The reporter
|
|
24
|
+
session and the My reports list it read were held for your token alone.
|
|
25
|
+
They are now held for your token and the member link together, so
|
|
26
|
+
**Unlink** (cs **Odpojit**), a new link, or a change in another tab drops
|
|
27
|
+
both, a list still loading included, and an open My reports reloads.
|
|
28
|
+
|
|
29
|
+
Upgrading:
|
|
30
|
+
|
|
31
|
+
- **The server side ships in vitrinka first.** An older vitrinka refuses
|
|
32
|
+
the unknown `memberToken` by name; the widget then sends the report, or
|
|
33
|
+
opens the session, again without it, once, as 0.8.0 does for `type`. The
|
|
34
|
+
link is ignored: the report files as the reporter's alone and My reports
|
|
35
|
+
reads as before. The widget now reads that refusal for the field it
|
|
36
|
+
names, never for a field the server lists as accepted, so the reporter's
|
|
37
|
+
`type` stays.
|
|
38
|
+
|
|
39
|
+
## 0.9.1
|
|
40
|
+
|
|
41
|
+
- **The button keeps its name with a shortcut set.** 0.9.0's default
|
|
42
|
+
shortcut put its chord on the button, and the chord became part of the
|
|
43
|
+
button's accessible name: "Report a problem Alt+Shift+A" (cs "Nahlásit
|
|
44
|
+
problém Alt+Shift+A"). A screen reader read the glyphs as the name, and a
|
|
45
|
+
host test that found the button by name — Voke's did — found nothing. The
|
|
46
|
+
chord is now painted for the eye only, and assistive technology hears it
|
|
47
|
+
from `aria-keyshortcuts` (`Alt+Shift+A` beside the button's Alt+arrow
|
|
48
|
+
moves). Since 0.9.0.
|
|
49
|
+
|
|
3
50
|
## 0.9.0
|
|
4
51
|
|
|
5
52
|
- **Box first, and the default.** The marking bar reads **Box · Circle ·
|
package/README.md
CHANGED
|
@@ -432,7 +432,10 @@ portal**. A list opens inside the card with ← back.
|
|
|
432
432
|
/api/v1/report/session`, renewed when it lapses) and reads `GET
|
|
433
433
|
/api/v1/report/mine` with it (header `X-Vitrinka-Reporter`): each report
|
|
434
434
|
with its step — Received, Planned, In progress, Fixed, Done — linked to
|
|
435
|
-
its page. The `vkb_` key alone reads nothing.
|
|
435
|
+
its page. The `vkb_` key alone reads nothing. When the browser also holds
|
|
436
|
+
a member link for the widget's `base` (below), the trade proves it too,
|
|
437
|
+
and the list is what vitrinka returns for the two: the reporter's
|
|
438
|
+
reports and the member's.
|
|
436
439
|
- **An asserted email, or anonymous**: this browser's own sends — the last
|
|
437
440
|
20 for this vitrinka and this site, filed or "Waiting for approval",
|
|
438
441
|
marked "Sent from this browser" (`localStorage`). A signed reporter gets
|
|
@@ -444,7 +447,11 @@ account from the account popover with the pill's flow: a short code,
|
|
|
444
447
|
browser's own `vkr_` token, kept where the pill keeps its link
|
|
445
448
|
(`vitrinka.recorder.link`, with the `base` it was minted on), so linking
|
|
446
449
|
here links the pill on this site and **Unlink** forgets it for both.
|
|
447
|
-
Reporters never need it: your token vouches for them.
|
|
450
|
+
Reporters never need it: your token vouches for them. Every report sent
|
|
451
|
+
from a linked browser proves the link (`memberToken` in the body, your
|
|
452
|
+
`vkb_` key still the bearer), so the member co-owns it and finds it in My
|
|
453
|
+
reports. A link vitrinka refuses never stops the report: one revoked, or
|
|
454
|
+
whose person is no longer a member, is forgotten.
|
|
448
455
|
|
|
449
456
|
**The face switch** (npm entry only). A browser holding a member link for
|
|
450
457
|
the widget's `base` gets **Record** and **Recent recordings** in the ⋯
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Sent as `meta.recorder` and written as `data-vitrinka-page`; bumped with the package version. */
|
|
2
|
-
export declare const RECORDER_VERSION = "0.9.
|
|
3
|
-
export declare const RECORDER_ID = "web/0.9.
|
|
2
|
+
export declare const RECORDER_VERSION = "0.9.2";
|
|
3
|
+
export declare const RECORDER_ID = "web/0.9.2";
|
package/build/report/face.d.ts
CHANGED
|
@@ -7,6 +7,20 @@ export declare const FACE_KEY = "vitrinka.report.face";
|
|
|
7
7
|
* workspace `base` addresses (any, for a bare origin).
|
|
8
8
|
*/
|
|
9
9
|
export declare function memberLinked(base: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The member link a report and a reporter session prove to `base` (vt-8020):
|
|
12
|
+
* the stored link's own token wherever `memberLinked` holds, else ''. Never a
|
|
13
|
+
* link minted on another vitrinka, and never a `vkr_` key the host configured
|
|
14
|
+
* — that is a build's, kept in the recorder's config, not in the link.
|
|
15
|
+
*/
|
|
16
|
+
export declare function memberTokenFor(base: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* vitrinka's `memberError` says the link is gone for good — revoked, or its
|
|
19
|
+
* person no longer a member — rather than only not good here (another
|
|
20
|
+
* workspace). A gone link is forgotten as a 401 on a session door forgets it;
|
|
21
|
+
* any other answer keeps it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function memberLinkGone(err: string): boolean;
|
|
10
24
|
/** The face this browser last picked here; null when it never picked (or storage is blocked). */
|
|
11
25
|
export declare function rememberedFace(): ReportFace | null;
|
|
12
26
|
export declare function rememberFace(face: ReportFace): void;
|
package/build/report/face.js
CHANGED
|
@@ -46,6 +46,24 @@ export function memberLinked(base) {
|
|
|
46
46
|
return false; // not a URL: no link can be for it
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* The member link a report and a reporter session prove to `base` (vt-8020):
|
|
51
|
+
* the stored link's own token wherever `memberLinked` holds, else ''. Never a
|
|
52
|
+
* link minted on another vitrinka, and never a `vkr_` key the host configured
|
|
53
|
+
* — that is a build's, kept in the recorder's config, not in the link.
|
|
54
|
+
*/
|
|
55
|
+
export function memberTokenFor(base) {
|
|
56
|
+
return memberLinked(base) ? (readLink()?.token ?? '') : '';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* vitrinka's `memberError` says the link is gone for good — revoked, or its
|
|
60
|
+
* person no longer a member — rather than only not good here (another
|
|
61
|
+
* workspace). A gone link is forgotten as a 401 on a session door forgets it;
|
|
62
|
+
* any other answer keeps it.
|
|
63
|
+
*/
|
|
64
|
+
export function memberLinkGone(err) {
|
|
65
|
+
return /revoked|not[\s_-]?(?:a[\s_-])?member|no longer a member/i.test(err);
|
|
66
|
+
}
|
|
49
67
|
/** The face this browser last picked here; null when it never picked (or storage is blocked). */
|
|
50
68
|
export function rememberedFace() {
|
|
51
69
|
const v = store()?.getItem(FACE_KEY);
|
|
@@ -23,6 +23,8 @@ export declare function matchesKeybind(e: KeyPress, b: Keybind): boolean;
|
|
|
23
23
|
export declare function isMacPlatform(): boolean;
|
|
24
24
|
/** ⌃⌥⇧⌘R on a Mac, Ctrl+Alt+Shift+R elsewhere. */
|
|
25
25
|
export declare function keybindLabel(b: Keybind, mac?: boolean): string;
|
|
26
|
+
/** The chord in `aria-keyshortcuts` words (Control, Alt, Shift, Meta): what assistive technology announces. */
|
|
27
|
+
export declare function keybindAria(b: Keybind): string;
|
|
26
28
|
/**
|
|
27
29
|
* ⌥⇧A on a Mac, Shift+Alt+A elsewhere (vt-8020): the recorder pill's annotate
|
|
28
30
|
* chord, so "flag it here" is one key in either face — one face is on screen at
|
package/build/report/keybind.js
CHANGED
|
@@ -65,6 +65,10 @@ export function keybindLabel(b, mac = isMacPlatform()) {
|
|
|
65
65
|
return `${b.ctrl ? '⌃' : ''}${b.alt ? '⌥' : ''}${b.shift ? '⇧' : ''}${b.meta ? '⌘' : ''}${key}`;
|
|
66
66
|
return [b.ctrl && 'Ctrl', b.alt && 'Alt', b.shift && 'Shift', b.meta && 'Meta', key].filter(Boolean).join('+');
|
|
67
67
|
}
|
|
68
|
+
/** The chord in `aria-keyshortcuts` words (Control, Alt, Shift, Meta): what assistive technology announces. */
|
|
69
|
+
export function keybindAria(b) {
|
|
70
|
+
return [b.ctrl && 'Control', b.alt && 'Alt', b.shift && 'Shift', b.meta && 'Meta', keyLabel(b.code)].filter(Boolean).join('+');
|
|
71
|
+
}
|
|
68
72
|
function parseKeybind(raw) {
|
|
69
73
|
if (!raw)
|
|
70
74
|
return null;
|
package/build/report/reader.d.ts
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
* publishable key: the host's signed token is traded once for a short-lived
|
|
4
4
|
* reporter session, which then lists the reporter's reports and their news.
|
|
5
5
|
* A `vkb_` key alone reads nothing — every list call carries the session.
|
|
6
|
+
* A browser linked to a vitrinka member on the widget's base proves the link
|
|
7
|
+
* in the trade too (`memberToken`, vt-8020): the session then lists the
|
|
8
|
+
* reporter's reports and the member's, as the server joins them.
|
|
6
9
|
*
|
|
7
|
-
* POST /api/v1/report/session {token} → {reporter, session, expiresAt, portalUrl?}
|
|
10
|
+
* POST /api/v1/report/session {token, memberToken?} → {reporter, session, expiresAt, portalUrl?, memberError?}
|
|
8
11
|
* GET /api/v1/report/mine?cursor= X-Vitrinka-Reporter → {reports, nextCursor}
|
|
9
12
|
* GET /api/v1/report/updates?cursor= X-Vitrinka-Reporter → {updates, nextCursor}
|
|
10
13
|
*/
|
|
@@ -21,6 +24,8 @@ export interface ReporterSession {
|
|
|
21
24
|
expiresAt: string;
|
|
22
25
|
/** The project's reporter portal, when one is bound. */
|
|
23
26
|
portalUrl?: string;
|
|
27
|
+
/** The server did not take the member link the trade carried (revoked, another workspace, no longer a member); the session is the reporter's alone. */
|
|
28
|
+
memberError?: string;
|
|
24
29
|
}
|
|
25
30
|
/** One of the reporter's reports, as the portal projects it. */
|
|
26
31
|
export interface MyReport {
|
|
@@ -36,7 +41,19 @@ export interface MyReports {
|
|
|
36
41
|
reports: MyReport[];
|
|
37
42
|
nextCursor?: string;
|
|
38
43
|
}
|
|
39
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Trade the host's token for a reporter session, proving `memberToken` beside
|
|
46
|
+
* it when there is one. A vitrinka older than the field refuses it by name:
|
|
47
|
+
* the session is the reporter's alone then, never lost — the trade goes again
|
|
48
|
+
* without it, once.
|
|
49
|
+
*/
|
|
50
|
+
export declare function openSession(target: ApiTarget, token: string, memberToken?: string): Promise<ReporterSession>;
|
|
51
|
+
/**
|
|
52
|
+
* Whose session a widget holds: the host's signed token and the member link
|
|
53
|
+
* the trade proved — '' without a host token, which opens none. Linking,
|
|
54
|
+
* unlinking or relinking is another key, so another session and list.
|
|
55
|
+
*/
|
|
56
|
+
export declare function sessionKey(hostToken: string, memberToken: string): string;
|
|
40
57
|
/** Still good for at least a minute more. */
|
|
41
58
|
export declare function sessionLive(s: ReporterSession | null, now?: number): s is ReporterSession;
|
|
42
59
|
export declare function listMine(target: ApiTarget, session: string, cursor?: string): Promise<MyReports>;
|
package/build/report/reader.js
CHANGED
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
* publishable key: the host's signed token is traded once for a short-lived
|
|
4
4
|
* reporter session, which then lists the reporter's reports and their news.
|
|
5
5
|
* A `vkb_` key alone reads nothing — every list call carries the session.
|
|
6
|
+
* A browser linked to a vitrinka member on the widget's base proves the link
|
|
7
|
+
* in the trade too (`memberToken`, vt-8020): the session then lists the
|
|
8
|
+
* reporter's reports and the member's, as the server joins them.
|
|
6
9
|
*
|
|
7
|
-
* POST /api/v1/report/session {token} → {reporter, session, expiresAt, portalUrl?}
|
|
10
|
+
* POST /api/v1/report/session {token, memberToken?} → {reporter, session, expiresAt, portalUrl?, memberError?}
|
|
8
11
|
* GET /api/v1/report/mine?cursor= X-Vitrinka-Reporter → {reports, nextCursor}
|
|
9
12
|
* GET /api/v1/report/updates?cursor= X-Vitrinka-Reporter → {updates, nextCursor}
|
|
10
13
|
*/
|
|
11
14
|
import { VitrinkaApiError } from '../recorder/api';
|
|
15
|
+
import { refusedField } from './wire';
|
|
12
16
|
async function call(method, path, target, body, session) {
|
|
13
17
|
const res = await fetch(target.url + path, {
|
|
14
18
|
method,
|
|
@@ -26,8 +30,33 @@ async function call(method, path, target, body, session) {
|
|
|
26
30
|
throw new VitrinkaApiError(`${method} ${path} → ${res.status}: ${text}`, res.status);
|
|
27
31
|
return (text ? JSON.parse(text) : {});
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Trade the host's token for a reporter session, proving `memberToken` beside
|
|
35
|
+
* it when there is one. A vitrinka older than the field refuses it by name:
|
|
36
|
+
* the session is the reporter's alone then, never lost — the trade goes again
|
|
37
|
+
* without it, once.
|
|
38
|
+
*/
|
|
39
|
+
export async function openSession(target, token, memberToken = '') {
|
|
40
|
+
const path = '/api/v1/report/session';
|
|
41
|
+
if (!memberToken)
|
|
42
|
+
return call('POST', path, target, { token });
|
|
43
|
+
try {
|
|
44
|
+
return await call('POST', path, target, { token, memberToken });
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (refusedField(e) !== 'memberToken')
|
|
48
|
+
throw e;
|
|
49
|
+
console.warn('vitrinka: this server takes no member link yet — the reporter session opens without it');
|
|
50
|
+
return call('POST', path, target, { token });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Whose session a widget holds: the host's signed token and the member link
|
|
55
|
+
* the trade proved — '' without a host token, which opens none. Linking,
|
|
56
|
+
* unlinking or relinking is another key, so another session and list.
|
|
57
|
+
*/
|
|
58
|
+
export function sessionKey(hostToken, memberToken) {
|
|
59
|
+
return hostToken ? JSON.stringify([hostToken, memberToken]) : '';
|
|
31
60
|
}
|
|
32
61
|
/** Still good for at least a minute more. */
|
|
33
62
|
export function sessionLive(s, now = Date.now()) {
|
package/build/report/widget.d.ts
CHANGED
|
@@ -82,9 +82,11 @@ export declare class ReportWidget {
|
|
|
82
82
|
/** Swaps this widget for the recorder pill; set only for a linked member (setRecordSwitch). */
|
|
83
83
|
private recordSwitch;
|
|
84
84
|
private menu;
|
|
85
|
-
/** The reporter session the host's signed token was traded for (vt-8020 D4), and that token. */
|
|
85
|
+
/** The reporter session the host's signed token was traded for (vt-8020 D4), and whose it is: that token and the member link it proved (reader.ts sessionKey). */
|
|
86
86
|
private session;
|
|
87
|
-
private
|
|
87
|
+
private sessionKey;
|
|
88
|
+
/** The member link this widget last saw for its base ('' none): a change is another person's session (linkChanged). */
|
|
89
|
+
private linkSeen;
|
|
88
90
|
/** The vitrinka member this browser is linked to (vt-8020 D3), read with the link's own token. */
|
|
89
91
|
private member;
|
|
90
92
|
private mine;
|
|
@@ -131,14 +133,35 @@ export declare class ReportWidget {
|
|
|
131
133
|
private show;
|
|
132
134
|
private target;
|
|
133
135
|
private toggleMenu;
|
|
134
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* The host's signed token traded once for a reporter session, with the
|
|
138
|
+
* member link beside it when this browser holds one for the base; renewed
|
|
139
|
+
* only when it is about to lapse. Answers the session in force.
|
|
140
|
+
*/
|
|
135
141
|
private refreshWho;
|
|
142
|
+
/** Whose session the widget should hold now (reader.ts sessionKey). */
|
|
143
|
+
private whoKey;
|
|
136
144
|
/**
|
|
137
|
-
* identify()
|
|
138
|
-
* the previous person never stay on screen for the
|
|
139
|
-
* reports reloads for whoever is here now.
|
|
145
|
+
* identify(), the page-wide identity or the member link moved: a session
|
|
146
|
+
* and a list read for the previous person never stay on screen for the
|
|
147
|
+
* next one, and an open My reports reloads for whoever is here now.
|
|
140
148
|
*/
|
|
141
149
|
private whoChanged;
|
|
150
|
+
/**
|
|
151
|
+
* The stored link moved (watchMemberLink: Unlink, the link flow, another
|
|
152
|
+
* tab, a refused link forgotten). Only a change of this base's link counts;
|
|
153
|
+
* the recorder's other notifications pass. The member the popover named was
|
|
154
|
+
* the previous link's: an open card reads the new link's (refreshMember).
|
|
155
|
+
*/
|
|
156
|
+
private linkChanged;
|
|
157
|
+
/**
|
|
158
|
+
* vitrinka did not take the member link a report or a session proved
|
|
159
|
+
* (`memberError`): they stand as the reporter's alone. A link revoked, or
|
|
160
|
+
* whose person is no longer a member, is forgotten as a 401 on a session
|
|
161
|
+
* door forgets it (recorder/link.ts) — only the one that was sent, never a
|
|
162
|
+
* link made since. Any other answer keeps it.
|
|
163
|
+
*/
|
|
164
|
+
private memberRefused;
|
|
142
165
|
private refreshMember;
|
|
143
166
|
private openReports;
|
|
144
167
|
private loadReports;
|
package/build/report/widget.js
CHANGED
|
@@ -33,17 +33,18 @@ import { clearLink, defaultLinkLabel, readLink, storeLink } from '../recorder/co
|
|
|
33
33
|
import { readRecents } from '../recorder/recents';
|
|
34
34
|
import { createHudHost, createSheetHost, insideHud, sheetTarget } from '../recorder/hud/host';
|
|
35
35
|
import { listen } from '../recorder/hud/listen';
|
|
36
|
+
import { forgetLink } from '../recorder/link';
|
|
36
37
|
import { RECORDER_VERSION } from '../recorder/version';
|
|
37
38
|
import { admit, DEFAULT_ATTACHMENT_CAPS, formatBytes, pastedName, typesLabel } from './attachments';
|
|
38
39
|
import { cornerToward, DRAG_THRESHOLD, nearestCorner, readDock, saveDock } from './drag';
|
|
39
|
-
import { memberLinked, rememberDisplayMode } from './face';
|
|
40
|
+
import { memberLinked, memberLinkGone, memberTokenFor, rememberDisplayMode, watchMemberLink } from './face';
|
|
40
41
|
import { acquireEngine, releaseEngine } from './engine';
|
|
41
42
|
import { browserLocale, parseLocale, REPORT_KINDS, strings } from './i18n';
|
|
42
43
|
import { normalizeIdentity, onSharedIdentity, sharedIdentity } from './identity';
|
|
43
|
-
import { keybindLabel, loadKeybind, matchesKeybind, readKeybindPress, saveKeybind, watchKeybind } from './keybind';
|
|
44
|
+
import { keybindAria, keybindLabel, loadKeybind, matchesKeybind, readKeybindPress, saveKeybind, watchKeybind } from './keybind';
|
|
44
45
|
import { arrowEnds, arrowHead, isMark, rectBetween, renumber, toWire, } from './markers';
|
|
45
46
|
import { coachSide, cornerRect, pickCorner } from './place';
|
|
46
|
-
import { listMine, openSession, sessionLive } from './reader';
|
|
47
|
+
import { listMine, openSession, sessionKey, sessionLive } from './reader';
|
|
47
48
|
import { noteSent, readSent } from './sent';
|
|
48
49
|
import { COACH_KEY, readCoach, readSize, SIZE_KEY, SIZE_SCALE, SIZES, techDetails, writePref } from './settings';
|
|
49
50
|
import { REPORT_CSS } from './styles';
|
|
@@ -241,7 +242,9 @@ export function hitsOpener(ev, sel) {
|
|
|
241
242
|
/** The widget's DOM, built once into the HUD host's shadow mount. */
|
|
242
243
|
function buildDom(mount) {
|
|
243
244
|
const fabLabel = h('span');
|
|
244
|
-
|
|
245
|
+
// The chord is painted for the eye only: in the name it would rename the button ("Report a problem Alt+Shift+A");
|
|
246
|
+
// assistive technology hears it from aria-keyshortcuts (paint).
|
|
247
|
+
const fabKbd = h('kbd', { 'aria-hidden': 'true' });
|
|
245
248
|
const fab = h('button', { class: 'fab', type: 'button', part: 'button', 'aria-haspopup': 'dialog' }, fabLabel, fabKbd);
|
|
246
249
|
const title = h('h2', { id: 'vr-title' });
|
|
247
250
|
// Who you are, at a glance (vt-8020 D5 A): the chip opens the account popover, ⋯ the menu.
|
|
@@ -475,9 +478,11 @@ export class ReportWidget {
|
|
|
475
478
|
/** Swaps this widget for the recorder pill; set only for a linked member (setRecordSwitch). */
|
|
476
479
|
recordSwitch = null;
|
|
477
480
|
menu = null;
|
|
478
|
-
/** The reporter session the host's signed token was traded for (vt-8020 D4), and that token. */
|
|
481
|
+
/** The reporter session the host's signed token was traded for (vt-8020 D4), and whose it is: that token and the member link it proved (reader.ts sessionKey). */
|
|
479
482
|
session = null;
|
|
480
|
-
|
|
483
|
+
sessionKey = '';
|
|
484
|
+
/** The member link this widget last saw for its base ('' none): a change is another person's session (linkChanged). */
|
|
485
|
+
linkSeen = '';
|
|
481
486
|
/** The vitrinka member this browser is linked to (vt-8020 D3), read with the link's own token. */
|
|
482
487
|
member = null;
|
|
483
488
|
mine = { rows: [], state: 'ok' };
|
|
@@ -773,6 +778,7 @@ export class ReportWidget {
|
|
|
773
778
|
on(e.accPortal, 'click', fromMenu(() => undefined));
|
|
774
779
|
on(e.accLink, 'click', fromMenu(() => this.startLinkFlow()));
|
|
775
780
|
on(e.accUnlink, 'click', () => {
|
|
781
|
+
// clearLink notifies: linkChanged drops the session and the list read with the link, a response in flight included.
|
|
776
782
|
clearLink();
|
|
777
783
|
this.member = null;
|
|
778
784
|
this.paint();
|
|
@@ -909,6 +915,9 @@ export class ReportWidget {
|
|
|
909
915
|
this.paint();
|
|
910
916
|
}));
|
|
911
917
|
this.offs.push(onSharedIdentity(() => this.whoChanged()));
|
|
918
|
+
// Linked, unlinked or relinked — here, in the link flow, or in another tab: the session belongs to the pairing it proved.
|
|
919
|
+
this.linkSeen = memberTokenFor(this.opts.base);
|
|
920
|
+
this.offs.push(watchMemberLink(() => this.linkChanged()));
|
|
912
921
|
// The recorder took the page's capture over: stop saying minutes are attached.
|
|
913
922
|
if (this.engine)
|
|
914
923
|
this.offs.push(this.engine.onChange(() => this.paint()));
|
|
@@ -973,46 +982,88 @@ export class ReportWidget {
|
|
|
973
982
|
const first = pop?.querySelector('button:not([hidden]), a:not([hidden])');
|
|
974
983
|
first?.focus();
|
|
975
984
|
}
|
|
976
|
-
/**
|
|
985
|
+
/**
|
|
986
|
+
* The host's signed token traded once for a reporter session, with the
|
|
987
|
+
* member link beside it when this browser holds one for the base; renewed
|
|
988
|
+
* only when it is about to lapse. Answers the session in force.
|
|
989
|
+
*/
|
|
977
990
|
async refreshWho() {
|
|
978
|
-
const
|
|
979
|
-
if (!
|
|
991
|
+
const token = this.whoToken();
|
|
992
|
+
if (!token) {
|
|
980
993
|
this.session = null;
|
|
981
|
-
this.
|
|
994
|
+
this.sessionKey = '';
|
|
982
995
|
return null;
|
|
983
996
|
}
|
|
984
|
-
|
|
997
|
+
const member = memberTokenFor(this.opts.base);
|
|
998
|
+
const key = sessionKey(token, member);
|
|
999
|
+
if (this.sessionKey === key && sessionLive(this.session))
|
|
985
1000
|
return this.session;
|
|
986
|
-
this.
|
|
1001
|
+
this.sessionKey = key;
|
|
987
1002
|
let opened = null;
|
|
988
1003
|
try {
|
|
989
|
-
opened = await openSession(this.target(),
|
|
1004
|
+
opened = await openSession(this.target(), token, member);
|
|
990
1005
|
}
|
|
991
1006
|
catch (e) {
|
|
992
1007
|
console.warn('vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only', e);
|
|
993
1008
|
}
|
|
994
|
-
// The person changed while the trade was in flight (whoChanged): this session is someone else's now.
|
|
995
|
-
if (this.
|
|
1009
|
+
// The person or the member link changed while the trade was in flight (whoChanged): this session is someone else's now.
|
|
1010
|
+
if (this.sessionKey !== key)
|
|
996
1011
|
return null;
|
|
997
1012
|
this.session = opened;
|
|
998
1013
|
this.paint();
|
|
999
|
-
|
|
1014
|
+
// A link forgotten here moves the key (linkChanged), and the session for the reporter alone is opened instead.
|
|
1015
|
+
if (opened?.memberError)
|
|
1016
|
+
this.memberRefused(opened.memberError, member);
|
|
1017
|
+
return this.sessionKey === key ? this.session : null;
|
|
1018
|
+
}
|
|
1019
|
+
/** Whose session the widget should hold now (reader.ts sessionKey). */
|
|
1020
|
+
whoKey() {
|
|
1021
|
+
return sessionKey(this.whoToken(), memberTokenFor(this.opts.base));
|
|
1000
1022
|
}
|
|
1001
1023
|
/**
|
|
1002
|
-
* identify()
|
|
1003
|
-
* the previous person never stay on screen for the
|
|
1004
|
-
* reports reloads for whoever is here now.
|
|
1024
|
+
* identify(), the page-wide identity or the member link moved: a session
|
|
1025
|
+
* and a list read for the previous person never stay on screen for the
|
|
1026
|
+
* next one, and an open My reports reloads for whoever is here now.
|
|
1005
1027
|
*/
|
|
1006
1028
|
whoChanged() {
|
|
1007
|
-
if (this.
|
|
1029
|
+
if (this.whoKey() !== this.sessionKey) {
|
|
1008
1030
|
this.session = null;
|
|
1009
|
-
this.
|
|
1031
|
+
this.sessionKey = '';
|
|
1010
1032
|
this.mine = { rows: [], state: 'ok' };
|
|
1011
1033
|
if (this.isOpen)
|
|
1012
1034
|
void (this.view === 'reports' ? this.loadReports() : this.refreshWho());
|
|
1013
1035
|
}
|
|
1014
1036
|
this.paint();
|
|
1015
1037
|
}
|
|
1038
|
+
/**
|
|
1039
|
+
* The stored link moved (watchMemberLink: Unlink, the link flow, another
|
|
1040
|
+
* tab, a refused link forgotten). Only a change of this base's link counts;
|
|
1041
|
+
* the recorder's other notifications pass. The member the popover named was
|
|
1042
|
+
* the previous link's: an open card reads the new link's (refreshMember).
|
|
1043
|
+
*/
|
|
1044
|
+
linkChanged() {
|
|
1045
|
+
const now = memberTokenFor(this.opts.base);
|
|
1046
|
+
if (now === this.linkSeen)
|
|
1047
|
+
return;
|
|
1048
|
+
this.linkSeen = now;
|
|
1049
|
+
this.member = null;
|
|
1050
|
+
if (now && this.isOpen)
|
|
1051
|
+
void this.refreshMember();
|
|
1052
|
+
this.whoChanged();
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* vitrinka did not take the member link a report or a session proved
|
|
1056
|
+
* (`memberError`): they stand as the reporter's alone. A link revoked, or
|
|
1057
|
+
* whose person is no longer a member, is forgotten as a 401 on a session
|
|
1058
|
+
* door forgets it (recorder/link.ts) — only the one that was sent, never a
|
|
1059
|
+
* link made since. Any other answer keeps it.
|
|
1060
|
+
*/
|
|
1061
|
+
memberRefused(err, sent) {
|
|
1062
|
+
const gone = memberLinkGone(err);
|
|
1063
|
+
console.warn(`vitrinka: vitrinka did not take this browser’s member link (${err}) — ${gone ? 'it is forgotten; link the account again' : 'it stays linked, and the reporter alone owns what goes with it'}`);
|
|
1064
|
+
if (gone && sent && readLink()?.token === sent)
|
|
1065
|
+
forgetLink();
|
|
1066
|
+
}
|
|
1016
1067
|
async refreshMember() {
|
|
1017
1068
|
// The browser-wide link goes only to the vitrinka it was minted on: its token never reaches another widget's base.
|
|
1018
1069
|
const link = memberLinked(this.opts.base) ? readLink() : null;
|
|
@@ -1023,16 +1074,23 @@ export class ReportWidget {
|
|
|
1023
1074
|
}
|
|
1024
1075
|
return;
|
|
1025
1076
|
}
|
|
1077
|
+
let member;
|
|
1078
|
+
let mode;
|
|
1026
1079
|
try {
|
|
1027
1080
|
const me = await api('GET', '/api/v1/recorder/me', undefined, { target: { url: this.opts.base, key: link.token } });
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
rememberDisplayMode(me.displayMode);
|
|
1081
|
+
member = { email: me.user?.email ?? '', name: me.user?.name ?? '', workspace: me.workspace?.slug ?? link.workspace };
|
|
1082
|
+
mode = me.displayMode;
|
|
1031
1083
|
}
|
|
1032
1084
|
catch (e) {
|
|
1033
1085
|
console.warn('vitrinka: the linked vitrinka account could not be read', e);
|
|
1034
|
-
|
|
1086
|
+
member = { email: '', name: '', workspace: link.workspace };
|
|
1035
1087
|
}
|
|
1088
|
+
// The link moved while vitrinka answered (linkChanged): this member, and their mode, are the previous link's.
|
|
1089
|
+
if (memberTokenFor(this.opts.base) !== link.token)
|
|
1090
|
+
return;
|
|
1091
|
+
this.member = member;
|
|
1092
|
+
// A dev-mode member starts on the pill next mount (face.ts startFace).
|
|
1093
|
+
rememberDisplayMode(mode);
|
|
1036
1094
|
this.paint();
|
|
1037
1095
|
}
|
|
1038
1096
|
async openReports() {
|
|
@@ -1040,10 +1098,10 @@ export class ReportWidget {
|
|
|
1040
1098
|
await this.loadReports();
|
|
1041
1099
|
}
|
|
1042
1100
|
async loadReports() {
|
|
1043
|
-
const asked = this.
|
|
1101
|
+
const asked = this.whoKey();
|
|
1044
1102
|
const session = await this.refreshWho();
|
|
1045
|
-
// The person changed meanwhile: whoChanged already reloads for the next one.
|
|
1046
|
-
if (this.
|
|
1103
|
+
// The person or the member link changed meanwhile: whoChanged already reloads for the next one.
|
|
1104
|
+
if (this.whoKey() !== asked)
|
|
1047
1105
|
return;
|
|
1048
1106
|
if (!session) {
|
|
1049
1107
|
this.mine = { rows: [], state: 'ok' };
|
|
@@ -1060,8 +1118,8 @@ export class ReportWidget {
|
|
|
1060
1118
|
console.warn('vitrinka: My reports could not be loaded', e);
|
|
1061
1119
|
mine = { rows: [], state: 'failed' };
|
|
1062
1120
|
}
|
|
1063
|
-
// A list read for the previous person is dropped; whoChanged already reloads for the next one.
|
|
1064
|
-
if (this.
|
|
1121
|
+
// A list read for the previous person or link is dropped; whoChanged already reloads for the next one.
|
|
1122
|
+
if (this.whoKey() !== asked)
|
|
1065
1123
|
return;
|
|
1066
1124
|
this.mine = mine;
|
|
1067
1125
|
this.paint();
|
|
@@ -1075,7 +1133,7 @@ export class ReportWidget {
|
|
|
1075
1133
|
if (!(e instanceof VitrinkaApiError) || e.status !== 401)
|
|
1076
1134
|
throw e;
|
|
1077
1135
|
this.session = null;
|
|
1078
|
-
this.
|
|
1136
|
+
this.sessionKey = '';
|
|
1079
1137
|
const renewed = await this.refreshWho();
|
|
1080
1138
|
if (!renewed)
|
|
1081
1139
|
throw e;
|
|
@@ -1102,10 +1160,10 @@ export class ReportWidget {
|
|
|
1102
1160
|
signal: flow.abort.signal,
|
|
1103
1161
|
});
|
|
1104
1162
|
// The link names the vitrinka it belongs to: face.ts offers the pill only on that base.
|
|
1163
|
+
// Storing it notifies: linkChanged reads the new member for an open card.
|
|
1105
1164
|
storeLink({ ...linked, base });
|
|
1106
1165
|
this.linkFlow = null;
|
|
1107
1166
|
this.show('describe');
|
|
1108
|
-
await this.refreshMember();
|
|
1109
1167
|
}
|
|
1110
1168
|
catch (e) {
|
|
1111
1169
|
if (flow.abort.signal.aborted)
|
|
@@ -1624,6 +1682,7 @@ export class ReportWidget {
|
|
|
1624
1682
|
// -- sending --------------------------------------------------------------
|
|
1625
1683
|
envelope(description, capture) {
|
|
1626
1684
|
const who = this.who();
|
|
1685
|
+
const member = memberTokenFor(this.opts.base);
|
|
1627
1686
|
const loc = globalThis.location;
|
|
1628
1687
|
return {
|
|
1629
1688
|
title: titleOf(description),
|
|
@@ -1641,6 +1700,8 @@ export class ReportWidget {
|
|
|
1641
1700
|
markers: toWire(this.markers),
|
|
1642
1701
|
locale: this.locale,
|
|
1643
1702
|
...(this.kind ? { type: this.kind } : {}),
|
|
1703
|
+
// A member linked on this base co-owns the report; the `vkb_` key stays the bearer.
|
|
1704
|
+
...(member ? { memberToken: member } : {}),
|
|
1644
1705
|
};
|
|
1645
1706
|
}
|
|
1646
1707
|
/** The words the report goes with: the description, else the first mark's note — either one is enough to send. */
|
|
@@ -1682,7 +1743,8 @@ export class ReportWidget {
|
|
|
1682
1743
|
const capture = engine ? await prepareCapture(() => engine.build(frozen, this.markers, marked)) : EMPTY_CAPTURE;
|
|
1683
1744
|
this.job = new ReportJob(capture, globalThis.location?.host ?? '', { url: this.opts.base, key: this.opts.key }, this.files);
|
|
1684
1745
|
}
|
|
1685
|
-
|
|
1746
|
+
// A refused member link is handled when the create answers, even if a later leg then fails.
|
|
1747
|
+
this.result = await this.job.run(this.envelope(description, this.job.capture), (err, sent) => this.memberRefused(err, sent));
|
|
1686
1748
|
noteSent(this.opts.base, globalThis.location?.host ?? '', {
|
|
1687
1749
|
title: titleOf(description),
|
|
1688
1750
|
at: Date.now(),
|
|
@@ -1902,7 +1964,7 @@ export class ReportWidget {
|
|
|
1902
1964
|
e.fabLabel.textContent = s.button;
|
|
1903
1965
|
e.fab.setAttribute('aria-expanded', String(this.isOpen));
|
|
1904
1966
|
e.fab.setAttribute('aria-description', s.moveHint);
|
|
1905
|
-
e.fab.setAttribute('aria-keyshortcuts', 'Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight
|
|
1967
|
+
e.fab.setAttribute('aria-keyshortcuts', `${this.keybind ? `${keybindAria(this.keybind)} ` : ''}Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight`);
|
|
1906
1968
|
e.fabKbd.hidden = !this.keybind;
|
|
1907
1969
|
e.fabKbd.textContent = this.keybind ? keybindLabel(this.keybind) : '';
|
|
1908
1970
|
// The one card stays up while marking (vt-8020 D10): its note lines and Send are where the reporter finishes.
|