@vitrinka/web 0.9.1 → 0.9.3
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 +45 -0
- package/README.md +15 -6
- package/build/hud.iife.js +15 -15
- package/build/one.iife.js +1 -1
- package/build/recorder/hud/host-style.d.ts +1 -1
- package/build/recorder/hud/host-style.js +1 -1
- package/build/recorder/hud/host.d.ts +3 -2
- package/build/recorder/hud/host.js +6 -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/reader.d.ts +19 -2
- package/build/report/reader.js +32 -3
- package/build/report/widget.d.ts +33 -10
- package/build/report/widget.js +95 -35
- package/build/report/wire.d.ts +37 -3
- package/build/report/wire.js +60 -11
- package/build/report-widget.mjs +9 -9
- package/package.json +1 -1
package/build/one.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var{defineProperty:
|
|
1
|
+
(()=>{var{defineProperty:E,getOwnPropertyNames:z,getOwnPropertyDescriptor:K}=Object,B=Object.prototype.hasOwnProperty;function j(e){return this[e]}var G=(e)=>{var n=(S??=new WeakMap).get(e),t;if(n)return n;if(n=E({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var o of z(e))if(!B.call(n,o))E(n,o,{get:j.bind(e,o),enumerable:!(t=K(e,o))||t.enumerable})}return S.set(e,n),n},S;var J=(e)=>e;function W(e,n){this[e]=J.bind(null,n)}var F=(e,n)=>{for(var t in n)E(e,t,{get:n[t],enumerable:!0,configurable:!0,set:W.bind(n,t)})};var cn={};var _={};F(_,{ACK_EVENT:()=>C,COMMAND_EVENT:()=>x,HELLO_EVENT:()=>c,LEAD_ATTR:()=>l,ONE_VERSION:()=>u,PAGE_ATTR:()=>d,announce:()=>H,answeredBy:()=>D,ask:()=>M,documentEnv:()=>Z,holderAnswers:()=>V,isLive:()=>k,markPage:()=>rn,nonce:()=>h,pageMarked:()=>an,parseAck:()=>N,parseClaim:()=>L,parseCommand:()=>P,parseHello:()=>A,readClaim:()=>b,releaseClaim:()=>tn,sendCommand:()=>ln,serializeClaim:()=>I,serveCommands:()=>dn,serveHello:()=>un,takeClaim:()=>nn,unmarkPage:()=>sn,updateClaim:()=>en,watchClaim:()=>on});function w(e,n,t,o={}){let i=e,r=i.__zone_symbol__addEventListener??e.addEventListener,a=i.__zone_symbol__removeEventListener??e.removeEventListener,m=o.capture??!1;return r.call(e,n,t,{capture:m,passive:!1}),()=>a.call(e,n,t,m)}var u=1,d="data-vitrinka-page",l="data-vitrinka-lead",c="vitrinka:hello",x="vitrinka:command",C="vitrinka:ack";function Z(){let n=globalThis.document?.documentElement;if(!n||typeof globalThis.dispatchEvent!=="function")return null;return{root:n,bus:globalThis}}function h(e){return`${e}.${Math.random().toString(36).slice(2,10)}`}var q=["page","extension"],Q=["starting","recording","paused","stopping","saved"],U=["pause","stop","note"],X=["not_recording","stopping","not_here","bad_command"];function v(e){if(typeof e!=="string")return null;try{let n=JSON.parse(e);return n!==null&&typeof n==="object"&&!Array.isArray(n)?n:null}catch{return null}}var s=(e)=>typeof e==="string",f=(e)=>s(e)&&q.includes(e),T=(e)=>s(e)&&Q.includes(e),g=(e)=>typeof e==="number"&&Number.isInteger(e)&&e>=1;function L(e){let n=v(e);if(!n||!g(n.v)||!f(n.by)||!s(n.id)||!n.id||!T(n.state))return null;return{v:n.v,by:n.by,id:n.id,state:n.state,sessionId:s(n.sessionId)?n.sessionId:Number.isFinite(n.sessionId)?String(n.sessionId):"",since:typeof n.since==="number"?n.since:0}}function I(e){return JSON.stringify({v:e.v,by:e.by,id:e.id,state:e.state,sessionId:e.sessionId,since:e.since})}function k(e){return e!==void 0&&e!==null&&e!=="saved"}function Y(e){if(e===null||typeof e!=="object"||Array.isArray(e))return null;let n=e;if(!f(n.by)||!T(n.state))return null;return{by:n.by,state:n.state,here:n.here===!0,...s(n.id)&&n.id?{id:n.id}:{}}}function A(e){let n=v(e);if(!n||!g(n.v)||!f(n.from)||!s(n.inst)||!n.inst)return null;let t=Y(n.live);return{v:n.v,from:n.from,inst:n.inst,...n.ask===!0?{ask:!0}:{},...n.live!==void 0?{live:t}:{},...n.gone===!0?{gone:!0}:{}}}function P(e){let n=v(e);if(!n||!g(n.v)||!f(n.from)||!s(n.inst)||!n.inst||!s(n.id)||!n.id)return null;if(!s(n.op)||!U.includes(n.op))return null;return{v:n.v,from:n.from,inst:n.inst,id:n.id,op:n.op,...s(n.text)?{text:n.text}:{}}}function N(e){let n=v(e);if(!n||!g(n.v)||!f(n.from)||!s(n.inst)||!s(n.id)||typeof n.ok!=="boolean")return null;return{v:n.v,from:n.from,inst:n.inst,id:n.id,ok:n.ok,...s(n.code)&&X.includes(n.code)?{code:n.code}:{},...s(n.error)?{error:n.error}:{}}}function b(e){return L(e.root.getAttribute(l))}function R(e,n){let t=I(n);if(e.root.getAttribute(l)!==t)e.root.setAttribute(l,t)}function nn(e,n,t){let o=b(e);if(o&&o.id!==t.id&&k(o.state)&&V(e,n,o))return{ok:!1,holder:o};let i={v:u,by:n.from,id:t.id,state:t.state,sessionId:t.sessionId??"",since:o?.id===t.id&&k(o.state)?o.since:Date.now()};return R(e,i),{ok:!0,claim:i}}function en(e,n,t){let o=b(e);if(o?.id!==n)return!1;return R(e,{...o,v:u,state:t.state,sessionId:t.sessionId??o.sessionId}),!0}function tn(e,n){if(b(e)?.id!==n)return!1;return e.root.removeAttribute(l),!0}function on(e,n){if(e.watch)return e.watch(n);if(typeof MutationObserver!=="function"||typeof Node>"u"||!(e.root instanceof Node))return()=>{return};let t=new MutationObserver(n);return t.observe(e.root,{attributes:!0,attributeFilter:[l]}),()=>t.disconnect()}function rn(e,n){if(e.root.getAttribute(d)!==n)e.root.setAttribute(d,n)}function sn(e){e.root.removeAttribute(d)}function an(e){return e.root.getAttribute(d)!==null}function y(e,n,t){e.bus.dispatchEvent(new CustomEvent(n,{detail:JSON.stringify(t)}))}function O(e,n,t){return w(e.bus,n,(o)=>t(o.detail))}function M(e,n){let t=[],o=O(e,c,(i)=>{let r=A(i);if(r&&!r.ask&&r.inst!==n.inst)t.push(r)});try{y(e,c,{v:u,from:n.from,inst:n.inst,ask:!0})}finally{o()}return t}function H(e,n,t,o={}){y(e,c,{v:u,from:n.from,inst:n.inst,live:t,...o.gone?{gone:!0}:{}})}function un(e,n,t,o,i={}){return O(e,c,(r)=>{let a=A(r);if(!a||a.inst===n.inst)return;if(!a.ask)o?.(a);else if(i.answerIf?.()??!0)H(e,n,t())})}function D(e,n){return e.some((t)=>t.live?.here===!0&&(t.live.id?t.live.id===n.id:t.from===n.by))}function V(e,n,t){return D(M(e,n),t)}function ln(e,n,t,o){let i=h("c"),r=null,a=O(e,C,(m)=>{let p=N(m);if(p&&p.id===i&&p.inst!==n.inst&&!r)r=p});try{y(e,x,{v:u,from:n.from,inst:n.inst,id:i,op:t,...o!==void 0?{text:o}:{}})}finally{a()}return r}function dn(e,n,t){return O(e,x,(o)=>{let i=P(o);if(!i||i.inst===n.inst)return;let r=t(i);if(!r)return;y(e,C,{v:u,from:n.from,inst:n.inst,id:i.id,...r})})}globalThis.VitrinkaOne=Object.freeze({..._});})();
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* into) never pulls the HUD's React sheets in through styles.ts.
|
|
11
11
|
*/
|
|
12
12
|
export declare const HOST_STYLE: string;
|
|
13
|
-
/**
|
|
13
|
+
/** A dialog-associated top-layer popover uses the same viewport-origin box. */
|
|
14
14
|
export declare const SHEET_HOST_STYLE: string;
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export const HOST_STYLE = 'all:initial;position:fixed;z-index:2147483647;inset:0 auto auto 0;margin:0;padding:0;border:0;' +
|
|
13
13
|
'background:transparent;overflow:visible;width:0;height:0;pointer-events:none;color-scheme:normal;';
|
|
14
|
-
/**
|
|
14
|
+
/** A dialog-associated top-layer popover uses the same viewport-origin box. */
|
|
15
15
|
export const SHEET_HOST_STYLE = HOST_STYLE;
|
|
@@ -29,8 +29,9 @@ export declare function createHudHost(): HudHost;
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function sheetTarget(): Element | null;
|
|
31
31
|
/**
|
|
32
|
-
* A sheet host
|
|
33
|
-
*
|
|
32
|
+
* A sheet host stays in the dialog's focus/inert subtree, but its manual
|
|
33
|
+
* popover paints in the browser's top layer: fixed children keep the viewport
|
|
34
|
+
* as their containing block, never the dialog's transform, filter or clipping.
|
|
34
35
|
*/
|
|
35
36
|
export declare function createSheetHost(target: Element): {
|
|
36
37
|
mount: HTMLElement;
|
|
@@ -236,8 +236,9 @@ export function sheetTarget() {
|
|
|
236
236
|
return aria[aria.length - 1] ?? null;
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
|
-
* A sheet host
|
|
240
|
-
*
|
|
239
|
+
* A sheet host stays in the dialog's focus/inert subtree, but its manual
|
|
240
|
+
* popover paints in the browser's top layer: fixed children keep the viewport
|
|
241
|
+
* as their containing block, never the dialog's transform, filter or clipping.
|
|
241
242
|
*/
|
|
242
243
|
export function createSheetHost(target) {
|
|
243
244
|
const el = document.createElement('div');
|
|
@@ -249,7 +250,10 @@ export function createSheetHost(target) {
|
|
|
249
250
|
root.append(mount);
|
|
250
251
|
shield(el);
|
|
251
252
|
const releaseGuard = holdKeyGuard();
|
|
253
|
+
if (typeof el.showPopover === 'function')
|
|
254
|
+
el.popover = 'manual';
|
|
252
255
|
target.append(el);
|
|
256
|
+
el.showPopover?.();
|
|
253
257
|
return {
|
|
254
258
|
mount,
|
|
255
259
|
destroy: () => {
|
|
@@ -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.3";
|
|
3
|
+
export declare const RECORDER_ID = "web/0.9.3";
|
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);
|
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;
|
|
@@ -108,10 +110,10 @@ export declare class ReportWidget {
|
|
|
108
110
|
private readonly e;
|
|
109
111
|
constructor(opts: WidgetOptions);
|
|
110
112
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
113
|
+
* Associate with the topmost open dialog so its inert/focus rules leave
|
|
114
|
+
* reporting usable. The sheet host's top-layer popover keeps the button,
|
|
115
|
+
* card and marks anchored to the viewport, independent of the dialog's box.
|
|
116
|
+
* The one DOM tree moves with its draft and marks; focus survives the move.
|
|
115
117
|
*/
|
|
116
118
|
private followDialog;
|
|
117
119
|
open(): void;
|
|
@@ -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
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';
|
|
@@ -477,9 +478,11 @@ export class ReportWidget {
|
|
|
477
478
|
/** Swaps this widget for the recorder pill; set only for a linked member (setRecordSwitch). */
|
|
478
479
|
recordSwitch = null;
|
|
479
480
|
menu = null;
|
|
480
|
-
/** 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). */
|
|
481
482
|
session = null;
|
|
482
|
-
|
|
483
|
+
sessionKey = '';
|
|
484
|
+
/** The member link this widget last saw for its base ('' none): a change is another person's session (linkChanged). */
|
|
485
|
+
linkSeen = '';
|
|
483
486
|
/** The vitrinka member this browser is linked to (vt-8020 D3), read with the link's own token. */
|
|
484
487
|
member = null;
|
|
485
488
|
mine = { rows: [], state: 'ok' };
|
|
@@ -540,10 +543,10 @@ export class ReportWidget {
|
|
|
540
543
|
this.followDialog();
|
|
541
544
|
}
|
|
542
545
|
/**
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
546
|
+
* Associate with the topmost open dialog so its inert/focus rules leave
|
|
547
|
+
* reporting usable. The sheet host's top-layer popover keeps the button,
|
|
548
|
+
* card and marks anchored to the viewport, independent of the dialog's box.
|
|
549
|
+
* The one DOM tree moves with its draft and marks; focus survives the move.
|
|
547
550
|
*/
|
|
548
551
|
followDialog() {
|
|
549
552
|
const target = this.activeDialog();
|
|
@@ -775,6 +778,7 @@ export class ReportWidget {
|
|
|
775
778
|
on(e.accPortal, 'click', fromMenu(() => undefined));
|
|
776
779
|
on(e.accLink, 'click', fromMenu(() => this.startLinkFlow()));
|
|
777
780
|
on(e.accUnlink, 'click', () => {
|
|
781
|
+
// clearLink notifies: linkChanged drops the session and the list read with the link, a response in flight included.
|
|
778
782
|
clearLink();
|
|
779
783
|
this.member = null;
|
|
780
784
|
this.paint();
|
|
@@ -911,6 +915,9 @@ export class ReportWidget {
|
|
|
911
915
|
this.paint();
|
|
912
916
|
}));
|
|
913
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()));
|
|
914
921
|
// The recorder took the page's capture over: stop saying minutes are attached.
|
|
915
922
|
if (this.engine)
|
|
916
923
|
this.offs.push(this.engine.onChange(() => this.paint()));
|
|
@@ -975,46 +982,88 @@ export class ReportWidget {
|
|
|
975
982
|
const first = pop?.querySelector('button:not([hidden]), a:not([hidden])');
|
|
976
983
|
first?.focus();
|
|
977
984
|
}
|
|
978
|
-
/**
|
|
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
|
+
*/
|
|
979
990
|
async refreshWho() {
|
|
980
|
-
const
|
|
981
|
-
if (!
|
|
991
|
+
const token = this.whoToken();
|
|
992
|
+
if (!token) {
|
|
982
993
|
this.session = null;
|
|
983
|
-
this.
|
|
994
|
+
this.sessionKey = '';
|
|
984
995
|
return null;
|
|
985
996
|
}
|
|
986
|
-
|
|
997
|
+
const member = memberTokenFor(this.opts.base);
|
|
998
|
+
const key = sessionKey(token, member);
|
|
999
|
+
if (this.sessionKey === key && sessionLive(this.session))
|
|
987
1000
|
return this.session;
|
|
988
|
-
this.
|
|
1001
|
+
this.sessionKey = key;
|
|
989
1002
|
let opened = null;
|
|
990
1003
|
try {
|
|
991
|
-
opened = await openSession(this.target(),
|
|
1004
|
+
opened = await openSession(this.target(), token, member);
|
|
992
1005
|
}
|
|
993
1006
|
catch (e) {
|
|
994
1007
|
console.warn('vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only', e);
|
|
995
1008
|
}
|
|
996
|
-
// The person changed while the trade was in flight (whoChanged): this session is someone else's now.
|
|
997
|
-
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)
|
|
998
1011
|
return null;
|
|
999
1012
|
this.session = opened;
|
|
1000
1013
|
this.paint();
|
|
1001
|
-
|
|
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));
|
|
1002
1022
|
}
|
|
1003
1023
|
/**
|
|
1004
|
-
* identify()
|
|
1005
|
-
* the previous person never stay on screen for the
|
|
1006
|
-
* 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.
|
|
1007
1027
|
*/
|
|
1008
1028
|
whoChanged() {
|
|
1009
|
-
if (this.
|
|
1029
|
+
if (this.whoKey() !== this.sessionKey) {
|
|
1010
1030
|
this.session = null;
|
|
1011
|
-
this.
|
|
1031
|
+
this.sessionKey = '';
|
|
1012
1032
|
this.mine = { rows: [], state: 'ok' };
|
|
1013
1033
|
if (this.isOpen)
|
|
1014
1034
|
void (this.view === 'reports' ? this.loadReports() : this.refreshWho());
|
|
1015
1035
|
}
|
|
1016
1036
|
this.paint();
|
|
1017
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
|
+
}
|
|
1018
1067
|
async refreshMember() {
|
|
1019
1068
|
// The browser-wide link goes only to the vitrinka it was minted on: its token never reaches another widget's base.
|
|
1020
1069
|
const link = memberLinked(this.opts.base) ? readLink() : null;
|
|
@@ -1025,16 +1074,23 @@ export class ReportWidget {
|
|
|
1025
1074
|
}
|
|
1026
1075
|
return;
|
|
1027
1076
|
}
|
|
1077
|
+
let member;
|
|
1078
|
+
let mode;
|
|
1028
1079
|
try {
|
|
1029
1080
|
const me = await api('GET', '/api/v1/recorder/me', undefined, { target: { url: this.opts.base, key: link.token } });
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
rememberDisplayMode(me.displayMode);
|
|
1081
|
+
member = { email: me.user?.email ?? '', name: me.user?.name ?? '', workspace: me.workspace?.slug ?? link.workspace };
|
|
1082
|
+
mode = me.displayMode;
|
|
1033
1083
|
}
|
|
1034
1084
|
catch (e) {
|
|
1035
1085
|
console.warn('vitrinka: the linked vitrinka account could not be read', e);
|
|
1036
|
-
|
|
1086
|
+
member = { email: '', name: '', workspace: link.workspace };
|
|
1037
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);
|
|
1038
1094
|
this.paint();
|
|
1039
1095
|
}
|
|
1040
1096
|
async openReports() {
|
|
@@ -1042,10 +1098,10 @@ export class ReportWidget {
|
|
|
1042
1098
|
await this.loadReports();
|
|
1043
1099
|
}
|
|
1044
1100
|
async loadReports() {
|
|
1045
|
-
const asked = this.
|
|
1101
|
+
const asked = this.whoKey();
|
|
1046
1102
|
const session = await this.refreshWho();
|
|
1047
|
-
// The person changed meanwhile: whoChanged already reloads for the next one.
|
|
1048
|
-
if (this.
|
|
1103
|
+
// The person or the member link changed meanwhile: whoChanged already reloads for the next one.
|
|
1104
|
+
if (this.whoKey() !== asked)
|
|
1049
1105
|
return;
|
|
1050
1106
|
if (!session) {
|
|
1051
1107
|
this.mine = { rows: [], state: 'ok' };
|
|
@@ -1062,8 +1118,8 @@ export class ReportWidget {
|
|
|
1062
1118
|
console.warn('vitrinka: My reports could not be loaded', e);
|
|
1063
1119
|
mine = { rows: [], state: 'failed' };
|
|
1064
1120
|
}
|
|
1065
|
-
// A list read for the previous person is dropped; whoChanged already reloads for the next one.
|
|
1066
|
-
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)
|
|
1067
1123
|
return;
|
|
1068
1124
|
this.mine = mine;
|
|
1069
1125
|
this.paint();
|
|
@@ -1077,7 +1133,7 @@ export class ReportWidget {
|
|
|
1077
1133
|
if (!(e instanceof VitrinkaApiError) || e.status !== 401)
|
|
1078
1134
|
throw e;
|
|
1079
1135
|
this.session = null;
|
|
1080
|
-
this.
|
|
1136
|
+
this.sessionKey = '';
|
|
1081
1137
|
const renewed = await this.refreshWho();
|
|
1082
1138
|
if (!renewed)
|
|
1083
1139
|
throw e;
|
|
@@ -1104,10 +1160,10 @@ export class ReportWidget {
|
|
|
1104
1160
|
signal: flow.abort.signal,
|
|
1105
1161
|
});
|
|
1106
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.
|
|
1107
1164
|
storeLink({ ...linked, base });
|
|
1108
1165
|
this.linkFlow = null;
|
|
1109
1166
|
this.show('describe');
|
|
1110
|
-
await this.refreshMember();
|
|
1111
1167
|
}
|
|
1112
1168
|
catch (e) {
|
|
1113
1169
|
if (flow.abort.signal.aborted)
|
|
@@ -1626,6 +1682,7 @@ export class ReportWidget {
|
|
|
1626
1682
|
// -- sending --------------------------------------------------------------
|
|
1627
1683
|
envelope(description, capture) {
|
|
1628
1684
|
const who = this.who();
|
|
1685
|
+
const member = memberTokenFor(this.opts.base);
|
|
1629
1686
|
const loc = globalThis.location;
|
|
1630
1687
|
return {
|
|
1631
1688
|
title: titleOf(description),
|
|
@@ -1643,6 +1700,8 @@ export class ReportWidget {
|
|
|
1643
1700
|
markers: toWire(this.markers),
|
|
1644
1701
|
locale: this.locale,
|
|
1645
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 } : {}),
|
|
1646
1705
|
};
|
|
1647
1706
|
}
|
|
1648
1707
|
/** The words the report goes with: the description, else the first mark's note — either one is enough to send. */
|
|
@@ -1684,7 +1743,8 @@ export class ReportWidget {
|
|
|
1684
1743
|
const capture = engine ? await prepareCapture(() => engine.build(frozen, this.markers, marked)) : EMPTY_CAPTURE;
|
|
1685
1744
|
this.job = new ReportJob(capture, globalThis.location?.host ?? '', { url: this.opts.base, key: this.opts.key }, this.files);
|
|
1686
1745
|
}
|
|
1687
|
-
|
|
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));
|
|
1688
1748
|
noteSent(this.opts.base, globalThis.location?.host ?? '', {
|
|
1689
1749
|
title: titleOf(description),
|
|
1690
1750
|
at: Date.now(),
|