@vitrinka/web 0.9.2 → 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/build/one.iife.js CHANGED
@@ -1 +1 @@
1
- (()=>{var{defineProperty:H,getOwnPropertyNames:w,getOwnPropertyDescriptor:d}=Object,p=Object.prototype.hasOwnProperty;function E(k){return this[k]}var f=(k)=>{var j=(x??=new WeakMap).get(k),q;if(j)return j;if(j=H({},"__esModule",{value:!0}),k&&typeof k==="object"||typeof k==="function"){for(var F of w(k))if(!p.call(j,F))H(j,F,{get:E.bind(k,F),enumerable:!(q=d(k,F))||q.enumerable})}return x.set(k,j),j},x;var c=(k)=>k;function b(k,j){this[k]=c.bind(null,j)}var l=(k,j)=>{for(var q in j)H(k,q,{get:j[q],enumerable:!0,configurable:!0,set:b.bind(j,q)})};var Yj={};var g={};l(g,{watchClaim:()=>qj,updateClaim:()=>jj,unmarkPage:()=>Jj,takeClaim:()=>e,serveHello:()=>Uj,serveCommands:()=>Xj,serializeClaim:()=>o,sendCommand:()=>Wj,releaseClaim:()=>kj,readClaim:()=>P,parseHello:()=>S,parseCommand:()=>i,parseClaim:()=>y,parseAck:()=>N,pageMarked:()=>Qj,nonce:()=>L,markPage:()=>Fj,isLive:()=>I,holderAnswers:()=>h,documentEnv:()=>s,ask:()=>_,answeredBy:()=>A,announce:()=>T,PAGE_ATTR:()=>Z,ONE_VERSION:()=>X,LEAD_ATTR:()=>Y,HELLO_EVENT:()=>$,COMMAND_EVENT:()=>u,ACK_EVENT:()=>C});function O(k,j,q,F={}){let J=k,Q=J.__zone_symbol__addEventListener??k.addEventListener,W=J.__zone_symbol__removeEventListener??k.removeEventListener,z=F.capture??!1;return Q.call(k,j,q,{capture:z,passive:!1}),()=>W.call(k,j,q,z)}var X=1,Z="data-vitrinka-page",Y="data-vitrinka-lead",$="vitrinka:hello",u="vitrinka:command",C="vitrinka:ack";function s(){let j=globalThis.document?.documentElement;if(!j||typeof globalThis.dispatchEvent!=="function")return null;return{root:j,bus:globalThis}}function L(k){return`${k}.${Math.random().toString(36).slice(2,10)}`}var t=["page","extension"],a=["starting","recording","paused","stopping","saved"],n=["pause","stop","note"],v=["not_recording","stopping","not_here","bad_command"];function K(k){if(typeof k!=="string")return null;try{let j=JSON.parse(k);return j!==null&&typeof j==="object"&&!Array.isArray(j)?j:null}catch{return null}}var U=(k)=>typeof k==="string",B=(k)=>U(k)&&t.includes(k),R=(k)=>U(k)&&a.includes(k),M=(k)=>typeof k==="number"&&Number.isInteger(k)&&k>=1;function y(k){let j=K(k);if(!j||!M(j.v)||!B(j.by)||!U(j.id)||!j.id||!R(j.state))return null;return{v:j.v,by:j.by,id:j.id,state:j.state,sessionId:U(j.sessionId)?j.sessionId:Number.isFinite(j.sessionId)?String(j.sessionId):"",since:typeof j.since==="number"?j.since:0}}function o(k){return JSON.stringify({v:k.v,by:k.by,id:k.id,state:k.state,sessionId:k.sessionId,since:k.since})}function I(k){return k!==void 0&&k!==null&&k!=="saved"}function r(k){if(k===null||typeof k!=="object"||Array.isArray(k))return null;let j=k;if(!B(j.by)||!R(j.state))return null;return{by:j.by,state:j.state,here:j.here===!0,...U(j.id)&&j.id?{id:j.id}:{}}}function S(k){let j=K(k);if(!j||!M(j.v)||!B(j.from)||!U(j.inst)||!j.inst)return null;let q=r(j.live);return{v:j.v,from:j.from,inst:j.inst,...j.ask===!0?{ask:!0}:{},...j.live!==void 0?{live:q}:{},...j.gone===!0?{gone:!0}:{}}}function i(k){let j=K(k);if(!j||!M(j.v)||!B(j.from)||!U(j.inst)||!j.inst||!U(j.id)||!j.id)return null;if(!U(j.op)||!n.includes(j.op))return null;return{v:j.v,from:j.from,inst:j.inst,id:j.id,op:j.op,...U(j.text)?{text:j.text}:{}}}function N(k){let j=K(k);if(!j||!M(j.v)||!B(j.from)||!U(j.inst)||!U(j.id)||typeof j.ok!=="boolean")return null;return{v:j.v,from:j.from,inst:j.inst,id:j.id,ok:j.ok,...U(j.code)&&v.includes(j.code)?{code:j.code}:{},...U(j.error)?{error:j.error}:{}}}function P(k){return y(k.root.getAttribute(Y))}function m(k,j){let q=o(j);if(k.root.getAttribute(Y)!==q)k.root.setAttribute(Y,q)}function e(k,j,q){let F=P(k);if(F&&F.id!==q.id&&I(F.state)&&h(k,j,F))return{ok:!1,holder:F};let J={v:X,by:j.from,id:q.id,state:q.state,sessionId:q.sessionId??"",since:F?.id===q.id&&I(F.state)?F.since:Date.now()};return m(k,J),{ok:!0,claim:J}}function jj(k,j,q){let F=P(k);if(F?.id!==j)return!1;return m(k,{...F,v:X,state:q.state,sessionId:q.sessionId??F.sessionId}),!0}function kj(k,j){if(P(k)?.id!==j)return!1;return k.root.removeAttribute(Y),!0}function qj(k,j){if(k.watch)return k.watch(j);if(typeof MutationObserver!=="function"||typeof Node>"u"||!(k.root instanceof Node))return()=>{return};let q=new MutationObserver(j);return q.observe(k.root,{attributes:!0,attributeFilter:[Y]}),()=>q.disconnect()}function Fj(k,j){if(k.root.getAttribute(Z)!==j)k.root.setAttribute(Z,j)}function Jj(k){k.root.removeAttribute(Z)}function Qj(k){return k.root.getAttribute(Z)!==null}function V(k,j,q){k.bus.dispatchEvent(new CustomEvent(j,{detail:JSON.stringify(q)}))}function D(k,j,q){return O(k.bus,j,(F)=>q(F.detail))}function _(k,j){let q=[],F=D(k,$,(J)=>{let Q=S(J);if(Q&&!Q.ask&&Q.inst!==j.inst)q.push(Q)});try{V(k,$,{v:X,from:j.from,inst:j.inst,ask:!0})}finally{F()}return q}function T(k,j,q,F={}){V(k,$,{v:X,from:j.from,inst:j.inst,live:q,...F.gone?{gone:!0}:{}})}function Uj(k,j,q,F,J={}){return D(k,$,(Q)=>{let W=S(Q);if(!W||W.inst===j.inst)return;if(!W.ask)F?.(W);else if(J.answerIf?.()??!0)T(k,j,q())})}function A(k,j){return k.some((q)=>q.live?.here===!0&&(q.live.id?q.live.id===j.id:q.from===j.by))}function h(k,j,q){return A(_(k,j),q)}function Wj(k,j,q,F){let J=L("c"),Q=null,W=D(k,C,(z)=>{let G=N(z);if(G&&G.id===J&&G.inst!==j.inst&&!Q)Q=G});try{V(k,u,{v:X,from:j.from,inst:j.inst,id:J,op:q,...F!==void 0?{text:F}:{}})}finally{W()}return Q}function Xj(k,j,q){return D(k,u,(F)=>{let J=i(F);if(!J||J.inst===j.inst)return;let Q=q(J);if(!Q)return;V(k,C,{v:X,from:j.from,inst:j.inst,id:J.id,...Q})})}globalThis.VitrinkaOne=Object.freeze({...g});})();
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
- /** Inline style of a sheet host portaled into a dialog — the same 0×0 origin box. */
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
- /** Inline style of a sheet host portaled into a dialog — the same 0×0 origin box. */
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: its own open shadow root (so the HUD stylesheet applies
33
- * inside a foreign dialog too), shielded, appended to `target`.
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: its own open shadow root (so the HUD stylesheet applies
240
- * inside a foreign dialog too), shielded, appended to `target`.
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.2";
3
- export declare const RECORDER_ID = "web/0.9.2";
2
+ export declare const RECORDER_VERSION = "0.9.3";
3
+ export declare const RECORDER_ID = "web/0.9.3";
@@ -1,3 +1,3 @@
1
1
  /** Sent as `meta.recorder` and written as `data-vitrinka-page`; bumped with the package version. */
2
- export const RECORDER_VERSION = '0.9.2';
2
+ export const RECORDER_VERSION = '0.9.3';
3
3
  export const RECORDER_ID = `web/${RECORDER_VERSION}`;
@@ -110,10 +110,10 @@ export declare class ReportWidget {
110
110
  private readonly e;
111
111
  constructor(opts: WidgetOptions);
112
112
  /**
113
- * Live inside the topmost open dialog while there is one (the recorder's
114
- * sheet path, hud/host.ts): a modal makes everything outside it inert and
115
- * its focus trap pulls focus back. The one DOM tree moves, so the draft,
116
- * the marks and their notes go along; focus is restored after the move.
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.
117
117
  */
118
118
  private followDialog;
119
119
  open(): void;
@@ -543,10 +543,10 @@ export class ReportWidget {
543
543
  this.followDialog();
544
544
  }
545
545
  /**
546
- * Live inside the topmost open dialog while there is one (the recorder's
547
- * sheet path, hud/host.ts): a modal makes everything outside it inert and
548
- * its focus trap pulls focus back. The one DOM tree moves, so the draft,
549
- * the marks and their notes go along; focus is restored after the move.
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.
550
550
  */
551
551
  followDialog() {
552
552
  const target = this.activeDialog();