@graview/guest 0.2.15 → 0.2.17

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.
Files changed (103) hide show
  1. package/README.md +110 -11
  2. package/client.js +1 -1
  3. package/dist/channel.d.ts +9 -0
  4. package/dist/channel.d.ts.map +1 -1
  5. package/dist/channel.js +24 -0
  6. package/dist/channel.js.map +1 -1
  7. package/dist/client.generated.d.ts.map +1 -1
  8. package/dist/client.generated.js +2 -2
  9. package/dist/client.generated.js.map +1 -1
  10. package/dist/guest.d.ts.map +1 -1
  11. package/dist/guest.js +35 -0
  12. package/dist/guest.js.map +1 -1
  13. package/dist/headless/describe.d.ts +3 -0
  14. package/dist/headless/describe.d.ts.map +1 -1
  15. package/dist/headless/describe.js +15 -0
  16. package/dist/headless/describe.js.map +1 -1
  17. package/dist/headless/index.d.ts +3 -0
  18. package/dist/headless/index.d.ts.map +1 -1
  19. package/dist/headless/index.js +1 -0
  20. package/dist/headless/index.js.map +1 -1
  21. package/dist/headless/judge.js +2 -2
  22. package/dist/headless/judge.js.map +1 -1
  23. package/dist/headless/protocol.d.ts +3 -0
  24. package/dist/headless/protocol.d.ts.map +1 -1
  25. package/dist/headless/protocol.js.map +1 -1
  26. package/dist/headless/runtime.generated.d.ts.map +1 -1
  27. package/dist/headless/runtime.generated.js +1 -1
  28. package/dist/headless/runtime.generated.js.map +1 -1
  29. package/dist/host/embed-player.d.ts +16 -0
  30. package/dist/host/embed-player.d.ts.map +1 -0
  31. package/dist/host/embed-player.js +248 -0
  32. package/dist/host/embed-player.js.map +1 -0
  33. package/dist/host/embeds.d.ts +48 -0
  34. package/dist/host/embeds.d.ts.map +1 -0
  35. package/dist/host/embeds.js +153 -0
  36. package/dist/host/embeds.js.map +1 -0
  37. package/dist/host/frame.d.ts +12 -0
  38. package/dist/host/frame.d.ts.map +1 -1
  39. package/dist/host/frame.js +136 -5
  40. package/dist/host/frame.js.map +1 -1
  41. package/dist/host/media.d.ts +3 -0
  42. package/dist/host/media.d.ts.map +1 -1
  43. package/dist/host/media.js +23 -0
  44. package/dist/host/media.js.map +1 -1
  45. package/dist/host/mine.d.ts +11 -1
  46. package/dist/host/mine.d.ts.map +1 -1
  47. package/dist/host/mine.js +111 -15
  48. package/dist/host/mine.js.map +1 -1
  49. package/dist/host/open-draw.d.ts +1 -1
  50. package/dist/host/open-draw.d.ts.map +1 -1
  51. package/dist/host/open-draw.js +2 -0
  52. package/dist/host/open-draw.js.map +1 -1
  53. package/dist/host/problems.d.ts +1 -1
  54. package/dist/host/problems.d.ts.map +1 -1
  55. package/dist/host/problems.js +6 -0
  56. package/dist/host/problems.js.map +1 -1
  57. package/dist/host/react.d.ts +17 -0
  58. package/dist/host/react.d.ts.map +1 -1
  59. package/dist/host/react.js +77 -11
  60. package/dist/host/react.js.map +1 -1
  61. package/dist/host/session.d.ts +18 -0
  62. package/dist/host/session.d.ts.map +1 -1
  63. package/dist/host/session.js +38 -4
  64. package/dist/host/session.js.map +1 -1
  65. package/dist/host/view-ahead.d.ts +21 -0
  66. package/dist/host/view-ahead.d.ts.map +1 -0
  67. package/dist/host/view-ahead.js +29 -0
  68. package/dist/host/view-ahead.js.map +1 -0
  69. package/dist/host/view-runtime.generated.d.ts.map +1 -1
  70. package/dist/host/view-runtime.generated.js +1 -1
  71. package/dist/host/view-runtime.generated.js.map +1 -1
  72. package/dist/host/view-script.d.ts +1 -0
  73. package/dist/host/view-script.d.ts.map +1 -1
  74. package/dist/host/view-script.js +1 -1
  75. package/dist/host/view-script.js.map +1 -1
  76. package/dist/host/view.d.ts +30 -0
  77. package/dist/host/view.d.ts.map +1 -1
  78. package/dist/host/view.js +203 -22
  79. package/dist/host/view.js.map +1 -1
  80. package/dist/host/views.d.ts +2 -0
  81. package/dist/host/views.d.ts.map +1 -1
  82. package/dist/host/views.js +1 -0
  83. package/dist/host/views.js.map +1 -1
  84. package/dist/host/worker-react.d.ts +3 -0
  85. package/dist/host/worker-react.d.ts.map +1 -1
  86. package/dist/host/worker-react.js +114 -24
  87. package/dist/host/worker-react.js.map +1 -1
  88. package/dist/host/worker.d.ts +4 -0
  89. package/dist/host/worker.d.ts.map +1 -1
  90. package/dist/host/worker.js +4 -0
  91. package/dist/host/worker.js.map +1 -1
  92. package/dist/open-kit.d.ts +1 -1
  93. package/dist/open-kit.d.ts.map +1 -1
  94. package/dist/open-kit.js +8 -2
  95. package/dist/open-kit.js.map +1 -1
  96. package/dist/protocol.d.ts +13 -0
  97. package/dist/protocol.d.ts.map +1 -1
  98. package/dist/protocol.js +8 -0
  99. package/dist/protocol.js.map +1 -1
  100. package/dist/worker/view-global.d.ts.map +1 -1
  101. package/dist/worker/view-global.js +64 -17
  102. package/dist/worker/view-global.js.map +1 -1
  103. package/package.json +3 -3
package/README.md CHANGED
@@ -45,7 +45,10 @@ pictures it asked for) and asked for its height — or stayed quiet for a
45
45
  moment after, if it never asks — and `data-guest-view-failed="silent"` when
46
46
  it does not say it is ready in `limits.readyMs` (eight seconds by default).
47
47
  It is `aria-busy` until one or the other; a guest that says it is ready
48
- after all is drawn then.
48
+ after all is drawn then. A frame that loads its page again — taken out of
49
+ the page and put back where the browser cannot move it as it is (no
50
+ `Element.moveBefore`), as the one face does taking in the page it is on —
51
+ loses its mark and is busy again until the new page has drawn.
49
52
 
50
53
  ## In the guest
51
54
 
@@ -61,7 +64,11 @@ guest.autoSize();
61
64
  ```
62
65
 
63
66
  The frame takes each height it asks for, up to `limits.maxHeight` (4,000px
64
- by default). A page sized by its own frame (`height: 100vh`) asks for a
67
+ by default); a height past it is given that most, and the host's
68
+ `{ onProblem }` is told once (`taller-than-allowed`). Its place flows with
69
+ the page, as tall as the frame, as a worker view's does;
70
+ `guestView({ flows: false })` keeps the place's frame, most of the window
71
+ tall and scrolling inside itself, for a fixed canvas. A page sized by its own frame (`height: 100vh`) asks for a
65
72
  little more each time the frame grows. A height that tracks the frame's
66
73
  own a few times running is refused for a moment: content that grows asks
67
74
  another meanwhile and is taken; otherwise the height is given after all,
@@ -135,9 +142,9 @@ drawn once they are read, or after two seconds, saying which did not come.
135
142
  What is not lent is said to the host's `{ onProblem }` (`guestView` says it in the console).
136
143
 
137
144
  `title` names the frame for assistive technology. Registered with the same
138
- title, the guest is a place on both faces: listed by `placesOf`, at
139
- `/places/the-price-sheet` on the routed face and `#view=the-price-sheet` in
140
- the scene. `props.places` lists the app's places, and
145
+ title, the guest is a place: listed by `placesOf`, at
146
+ `/places/the-price-sheet` as a page, and standing on its district on the
147
+ Map (`#view=the-price-sheet` on the Scene's own face). `props.places` lists the app's places, and
141
148
  `guest.navigate({ place: "the-packages" })` goes to one.
142
149
 
143
150
  ### One client, served or inlined
@@ -451,8 +458,8 @@ attaches to (the members the face hands it, or every one the viewer sees)
451
458
  and the kinds and edges it reads: a record the viewer may not see is in
452
459
  none of it, and a kind it did not ask to read is not handed to it however
453
460
  visible. Every record's `label` is filled as the host labels it — for a
454
- frame guest too. A titled view is a named place on the Graview face and
455
- the pages face, by its title; whatever the registry drew for that kind
461
+ frame guest too. A titled view is a named place, by its title, as a page
462
+ and on the Map; whatever the registry drew for that kind
456
463
  before is drawn if the view fails. A view of one record (`cardinality:
457
464
  "one"`) is drawn above the record's own fields, which stay editable: on
458
465
  the scene the record drawn at full is the view and then the record's
@@ -595,16 +602,16 @@ place the app has. `graview.navigate("offer:coaching")` and
595
602
  string is a record the viewer may see first, then a place by that slug, so
596
603
  `graview.navigate("the-packages")` goes to the place. The Scene and the
597
604
  home are places by name too (FR-235): `data-place="overview"` goes to the
598
- Scene's overview and `data-place="home"` to the front page, on either
599
- face; a kind's list by its slug. What a view may name is one vocabulary,
605
+ Map (the Scene's overview) and `data-place="home"` to the front page, on
606
+ every face; a kind's list by its slug. What a view may name is one vocabulary,
600
607
  `placeNamesOf` on `@graview/core/navigate`, read alike by the headless
601
608
  check and the page. A destination that
602
609
  is neither goes nowhere and says why — in the view's console, and to the
603
610
  host's problems (the onProblem option on `mountWorkerView` and on a registered view's
604
611
  definition) — naming the places there are. The
605
612
  props list the app's places (`places`, each with its slug and title). On
606
- the Graview face a record is focused and chosen and a place is drawn; on
607
- the pages face each goes to its own address — through `useGoTo` in
613
+ the Scene's own face a record is focused and chosen and a place is drawn; on
614
+ the routed face each goes to its own address — through `useGoTo` in
608
615
  `@graview/react`, which the routed face provides — and an `<a data-record>`
609
616
  or `<a data-place>` carries that address as its `href` (`GoTo.href`, or
610
617
  the address option on `mountWorkerView`): a plain click, a tap and Enter are followed
@@ -691,6 +698,49 @@ nothing and `onProblem` says why; a headless run says the same among its
691
698
  problems, and lists a reel it plays in `videos` with `app: "reel"` in
692
699
  place of `record` and `field`.
693
700
 
701
+ #### A video on YouTube or Vimeo
702
+
703
+ A view names the video, by provider and id or by its watch address, and
704
+ the host draws all of it (HQ f-view-video-embeds):
705
+
706
+ ```html
707
+ <graview-video data-provider="youtube" data-video="dQw4w9WgXcQ" data-start="1m30s" title="The keynote" poster="${talk.photo.src}"></graview-video>
708
+ <graview-video data-watch="${talk.link}" title="${talk.label}"></graview-video>
709
+ ```
710
+
711
+ The providers are a closed list (`EMBED_PROVIDERS`: YouTube's no-cookie
712
+ player and Vimeo's). What the view says is read down to a checked id — an
713
+ unlisted Vimeo video's key after a slash — and whole seconds to start at,
714
+ and the host builds the only address the player may have
715
+ (`https://www.youtube-nocookie.com/embed/<id>`,
716
+ `https://player.vimeo.com/video/<id>`); the rest of a watch address is
717
+ dropped. Anything else draws nothing and is said to `onProblem` as
718
+ `embed-refused`, and by a headless run among its problems with the same
719
+ `code`.
720
+
721
+ A poster and a play button stand first: the host's own ground with the
722
+ `title`, or `poster`, a picture the view may draw already, judged as an
723
+ `<img src>` is. Nothing is asked of the provider until a person presses
724
+ play. Then the player is a sandboxed frame (its scripts and its own
725
+ storage) in the box the poster stood in, `data-shape` `16:9` (a Short
726
+ `9:16`), `4:3`, `1:1` or `9:16`, so nothing moves; it is told the page's
727
+ origin alone, which YouTube's player needs. It plays on across the view's
728
+ redraws, and goes back to its poster when another plays, or when it is
729
+ hidden or off the page. A link out stands below it throughout, and printed
730
+ it is the poster and the address. In the Scene's card it is the poster and
731
+ the link.
732
+
733
+ A host whose page has a policy allows the two frames (`frame-src
734
+ https://www.youtube-nocookie.com https://player.vimeo.com`,
735
+ `EMBED_ORIGINS`); where it does not, a pressed video says so and keeps its
736
+ link, and `onProblem` hears `embed-not-allowed`. `embeds: { providers:
737
+ ["vimeo"] }` on `mountWorkerView`, a registered view's definition or
738
+ `runWorkerViewHeadless` plays from that one alone, and `{ providers: [] }`
739
+ from none: a provider turned off is drawn as its link. A headless run
740
+ lists each in `videos` with `provider` and `link`. A frame guest has no
741
+ `<graview-video>`; what its own document frames is its sandbox's and its
742
+ own policy's to allow.
743
+
694
744
  ### Files a person drops on it
695
745
 
696
746
  A worker view takes files a person drops on what it drew (FR-193). Its
@@ -875,6 +925,52 @@ timed per push. A view that busies its own worker for just under
875
925
  reader's machine for as long as it is shown. That is the worker's thread,
876
926
  not the page's; the page stays responsive.
877
927
 
928
+ ### A page left and gone back to
929
+
930
+ A view registered with `registerWorkerView`, `workerHome` or `guestView` and
931
+ drawn as a page of its own is kept as its page is left and put back as it
932
+ is gone back to, before the page is painted: no new worker, and nothing
933
+ asked of the host again. What the person typed and where it was scrolled
934
+ are as they were. What changed meanwhile is pushed and drawn in place; a
935
+ press made before that is drawn waits for it, and is applied only where its
936
+ control still asks for the same thing.
937
+
938
+ The provider keeps at most six, for five minutes after each page was left,
939
+ in memory alone. One is taken back only for the same definition, store and
940
+ seat, and every one is let go as the store, the seat, the registry or being
941
+ signed in changes and as the provider goes. One is let go of by itself
942
+ where it fails and where a record it shows is no longer its seat's to see,
943
+ and a view is drawn anew where anything it stood with would not be handed
944
+ to it now. While its page is away the view is handed nothing (a frame is
945
+ kept up), an act it asks for and a value it would keep are refused, and a navigate of
946
+ its goes nowhere.
947
+ A draft, a preview on the Scene and a view that has not drawn are not kept.
948
+
949
+ A face says which view is its page's own (`PageOfItsOwn`, the routed face and
950
+ the one face do); a row, a card or a panel is never kept. A frame is kept
951
+ only where its host says it may be (`guestView({ keeps: true })`), since its
952
+ document runs on out of sight, and where the
953
+ browser can move one without loading it again (`Element.moveBefore`: Chrome
954
+ 133, Firefox 144); elsewhere it is loaded again. A kept frame is told it is
955
+ off the page and back (`{ type: "away", away }` over its port): the client
956
+ pauses the `<video>` and `<audio>` in its document that are playing and
957
+ plays them again on return, and the guest's code hears both, for a sound of
958
+ its own making (Web Audio, a `new Audio()` never put in the document, media
959
+ in a shadow root):
960
+
961
+ ```ts
962
+ guest.onAway((away) => (away ? music.suspend() : music.resume()));
963
+ ```
964
+
965
+ A host that mounts views by hand has the same in `rest` and `wake` on what
966
+ `mountWorkerView` and `mountGuestView` answer. A first visit waits for
967
+ the view's code and for what its host keeps for the viewer (`graview.mine`).
968
+ Both are fetched ahead where a person comes to a link or a bar place by a
969
+ pointer, a finger or the keyboard, and the code of the first four places
970
+ once the page is idle: each view once, at most 24 a page, only what the seat
971
+ may go to, and nothing where the browser says to save data. Nothing of the
972
+ view runs ahead of its page.
973
+
878
974
  ### What a view's host says went wrong, by a code
879
975
 
880
976
  Every problem a view's host reports is a sentence for a person and, beside
@@ -895,6 +991,7 @@ view, the relation and the kind — so a host files a standing fault once. The l
895
991
  |------|-----------------|
896
992
  | `part-failed` | A part (`graview.part`) threw or took too long; its note is drawn in its place. |
897
993
  | `held-by-growth-guard` | A frame guest grew only with its own frame, and is held at a height. |
994
+ | `taller-than-allowed` | A frame guest asked to be taller than its host allows (`limits.maxHeight`), and is drawn at that height. |
898
995
  | `far-kind-not-handed` | A relation the view reads joins a kind its manifest never hands it. |
899
996
  | `views-stylesheet-draws-nothing` | The app's stylesheet for its views draws nothing in the open kit. |
900
997
  | `face-not-lent` | A face the app lends its views is not lent: past the most, a name it may not take, or from nowhere this host serves faces. |
@@ -911,6 +1008,8 @@ view, the relation and the kind — so a host files a standing fault once. The l
911
1008
  | `jump-goes-nowhere` | A jump within the view names no element it drew. |
912
1009
  | `file-link-goes-nowhere` | A file link is not followed: it is not an `<a>`, names no record the view was shown, or names no field holding a file. |
913
1010
  | `media-not-drawn` | A record's video or the full-screen viewer is not drawn. |
1011
+ | `embed-refused` | A video on a provider the view named is refused: a provider not on the list, or no id of a video. |
1012
+ | `embed-not-allowed` | The page's policy allows no frame from the provider's player, so the video's link stands alone. |
914
1013
  | `drop-not-offered` | A drop target the view drew is not offered. |
915
1014
  | `gestures-not-declared` | The view listens for a gesture its manifest does not say it hears. |
916
1015
  | `press-refused` | A press was refused, and the note beside it could not be drawn. |
package/client.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! @graview/guest/client.js — a frame guest's client (GraviewGuest.connect). Generated from src/client-script.ts. Elastic License 2.0. */
2
- "use strict";var GraviewGuest=(()=>{var k=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var a in t)k(e,a,{get:t[a],enumerable:!0})},z=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!P.call(e,o)&&o!==a&&k(e,o,{get:()=>t[o],enumerable:!(i=N(t,o))||i.enumerable});return e};var U=e=>z(k({},"__esModule",{value:!0}),e);var L={};B(L,{connect:()=>F,protocol:()=>E});var E=1;function T(e){if(typeof e=="string")return{type:"navigate",to:e};let{place:t,record:a,where:i,section:o}=e??{},u={...i===void 0?{}:{where:i},...o===void 0?{}:{section:String(o)}};return typeof t=="string"?{type:"navigate",place:t,...u}:typeof a=="string"?{type:"navigate",to:a,...u}:void 0}function S(e){let t=e;return typeof e=="object"&&e!==null&&t.graview==="host-hello"&&typeof t.nonce=="string"}function H(e,t={}){let a,i="",o,u=0,d=new Set,l=new Map,c=[],r=s=>{a?a.postMessage({...s,nonce:i}):c.push(s)},v=s=>{let n=s.data;if(!(!n||typeof n!="object")){if(n.type==="props"){o=n.props;for(let y of d)y(n.props)}else n.type==="answer"?(l.get(n.id)?.(n),l.delete(n.id)):n.type==="event"&&typeof n.listener=="number"?t.onEvent?.(n):n.type==="heartbeat"&&typeof n.beat=="number"&&r({type:"heartbeat",beat:n.beat});t.onMessage?.(n)}},g=()=>{},R=s=>{if(a||!e.fromHost(s)||!S(s.data)||s.data.protocol!==1)return;let n=s.ports[0];if(n){a=n,i=s.data.nonce,a.onmessage=v,a.start?.(),g();for(let y of c.splice(0))r(y)}};g=e.listen(R),e.ready({graview:"guest-ready",protocol:1});let f,M={get props(){return o},subscribe(s){return d.add(s),()=>d.delete(s)},act(s,n={}){let y=u+=1;return new Promise(p=>{l.set(y,p),r({type:"act",id:y,name:s,args:n})})},navigate(s){let n=T(s);n&&r(n)},size(s){r({type:"size",height:s})},autoSize(s){let n=s??globalThis.document?.documentElement,y=globalThis.ResizeObserver;if(!n||!y||typeof n.getBoundingClientRect!="function")return()=>{};f?.disconnect();let p=new y(()=>M.size(Math.ceil(n.getBoundingClientRect().height)));return p.observe(n),f=p,()=>p.disconnect()},close(){f?.disconnect(),g(),a?.close(),d.clear()}};return{guest:M,send:r}}function A(e,t){let a=e.document,i="",o=0,u=0,d=g=>{if(o=0,g-u<16)return l();let R=[],f=[],M=new Map,s=y=>Math.round(y*10)/10;for(let y of a.querySelectorAll("[data-record]")){if(f.length>=200)break;let p=y.getAttribute("data-record");if(!p)continue;f.push(p);let{left:m,top:b,right:w,bottom:x}=y.getBoundingClientRect();for(let h=y.parentElement;h;h=h.parentElement){let G=M.get(h);if(G===void 0){let O=e.getComputedStyle(h);M.set(h,G=O.overflowX!=="visible"||O.overflowY!=="visible"?h.getBoundingClientRect():null)}G&&(m=Math.max(m,G.left),b=Math.max(b,G.top),w=Math.min(w,G.right),x=Math.min(x,G.bottom))}m=Math.max(m,0),b=Math.max(b,0),w=Math.min(w,e.innerWidth),x=Math.min(x,e.innerHeight),w-m>=1&&x-b>=1&&R.push({id:p,x:s(m),y:s(b),width:s(w-m),height:s(x-b)})}let n=JSON.stringify([R,f]);n!==i&&(i=n,u=g,t(R,f))},l=()=>{o||=e.requestAnimationFrame(d)},c=new e.MutationObserver(l);c.observe(a.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let r=new e.ResizeObserver(l);r.observe(a.documentElement);let v=["scroll","resize","load"];for(let g of v)e.addEventListener(g,l,!0);return l(),()=>{for(let g of v)e.removeEventListener(g,l,!0);c.disconnect(),r.disconnect(),e.cancelAnimationFrame(o)}}var W=/^data:font\/(?:woff2|woff|ttf|otf);base64,[A-Za-z0-9+/]+=*$/;function q(){let e=[];return t=>{if(t.type!=="fonts"||!Array.isArray(t.fonts))return;let a=globalThis,i=a.FontFace,o=a.document?.fonts;if(!i||!o)return;let u=e;e=[];for(let d of t.fonts.slice(0,8)){if(typeof d?.family!="string"||typeof d.src!="string"||!W.test(d.src))continue;let l=`url(${JSON.stringify(d.src)})`,c={display:"swap",...typeof d.weight=="string"?{weight:d.weight}:{},...typeof d.style=="string"?{style:d.style}:{}},r=new i(d.family,l,c);r.status==="error"&&(r=new i(JSON.stringify(d.family),l,c)),o.add(r),e.push(r),r.load().catch(()=>o.delete(r))}for(let d of u)o.delete(d)}}function F(e={}){let t=e.window??globalThis,a=q(),i,o=t,u=()=>{!i&&o.document&&"ResizeObserver"in o&&"MutationObserver"in o&&"requestAnimationFrame"in o&&(i=A(o,(r,v)=>d.send({type:"records",boxes:r,shows:v})))},d=H({listen(r){return t.addEventListener("message",r),()=>t.removeEventListener("message",r)},fromHost:r=>r.source===t.parent&&(e.hostOrigin===void 0||r.origin===e.hostOrigin),ready:r=>t.parent?.postMessage(r,"*")},{onMessage:r=>{a(r),u()}}),{guest:l}=d,c=l.close;return l.close=()=>(i?.(),c()),l}return U(L);})();
2
+ "use strict";var GraviewGuest=(()=>{var k=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var o in t)k(e,o,{get:t[o],enumerable:!0})},z=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _(t))!P.call(e,s)&&s!==o&&k(e,s,{get:()=>t[s],enumerable:!(i=N(t,s))||i.enumerable});return e};var L=e=>z(k({},"__esModule",{value:!0}),e);var W={};B(W,{connect:()=>F,protocol:()=>M});var M=1;function T(e){if(typeof e=="string")return{type:"navigate",to:e};let{place:t,record:o,where:i,section:s}=e??{},a={...i===void 0?{}:{where:i},...s===void 0?{}:{section:String(s)}};return typeof t=="string"?{type:"navigate",place:t,...a}:typeof o=="string"?{type:"navigate",to:o,...a}:void 0}function S(e){let t=e;return typeof e=="object"&&e!==null&&t.graview==="host-hello"&&typeof t.nonce=="string"}function A(e,t={}){let o,i="",s,a=0,d=new Set,u=new Set,f=!1,c=new Map,y=[],g=r=>{o?o.postMessage({...r,nonce:i}):y.push(r)},x=r=>{let n=r.data;if(!(!n||typeof n!="object")){if(n.type==="props"){s=n.props;for(let l of d)l(n.props)}else n.type==="answer"?(c.get(n.id)?.(n),c.delete(n.id)):n.type==="event"&&typeof n.listener=="number"?t.onEvent?.(n):n.type==="away"&&typeof n.away=="boolean"?f=n.away:n.type==="heartbeat"&&typeof n.beat=="number"&&g({type:"heartbeat",beat:n.beat});if(t.onMessage?.(n),n.type==="away"&&typeof n.away=="boolean")for(let l of[...u])try{l(n.away)}catch(p){console.error(p)}}},m=()=>{},E=r=>{if(o||!e.fromHost(r)||!S(r.data)||r.data.protocol!==1)return;let n=r.ports[0];if(n){o=n,i=r.data.nonce,o.onmessage=x,o.start?.(),m();for(let l of y.splice(0))g(l)}};m=e.listen(E),e.ready({graview:"guest-ready",protocol:1});let b,R={get props(){return s},subscribe(r){return d.add(r),()=>d.delete(r)},get away(){return f},onAway(r){return u.add(r),()=>void u.delete(r)},act(r,n={}){let l=a+=1;return new Promise(p=>{c.set(l,p),g({type:"act",id:l,name:r,args:n})})},navigate(r){let n=T(r);n&&g(n)},size(r){g({type:"size",height:r})},autoSize(r){let n=r??globalThis.document?.documentElement,l=globalThis.ResizeObserver;if(!n||!l||typeof n.getBoundingClientRect!="function")return()=>{};b?.disconnect();let p=new l(()=>R.size(Math.ceil(n.getBoundingClientRect().height)));return p.observe(n),b=p,()=>p.disconnect()},close(){b?.disconnect(),m(),o?.close(),d.clear(),u.clear()}};return{guest:R,send:g}}function H(e,t){let o=e.document,i="",s=0,a=0,d=g=>{if(s=0,g-a<16)return u();let x=[],m=[],E=new Map,b=r=>Math.round(r*10)/10;for(let r of o.querySelectorAll("[data-record]")){if(m.length>=200)break;let n=r.getAttribute("data-record");if(!n)continue;m.push(n);let{left:l,top:p,right:v,bottom:G}=r.getBoundingClientRect();for(let h=r.parentElement;h;h=h.parentElement){let w=E.get(h);if(w===void 0){let O=e.getComputedStyle(h);E.set(h,w=O.overflowX!=="visible"||O.overflowY!=="visible"?h.getBoundingClientRect():null)}w&&(l=Math.max(l,w.left),p=Math.max(p,w.top),v=Math.min(v,w.right),G=Math.min(G,w.bottom))}l=Math.max(l,0),p=Math.max(p,0),v=Math.min(v,e.innerWidth),G=Math.min(G,e.innerHeight),v-l>=1&&G-p>=1&&x.push({id:n,x:b(l),y:b(p),width:b(v-l),height:b(G-p)})}let R=JSON.stringify([x,m]);R!==i&&(i=R,a=g,t(x,m))},u=()=>{s||=e.requestAnimationFrame(d)},f=new e.MutationObserver(u);f.observe(o.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let c=new e.ResizeObserver(u);c.observe(o.documentElement);let y=["scroll","resize","load"];for(let g of y)e.addEventListener(g,u,!0);return u(),()=>{for(let g of y)e.removeEventListener(g,u,!0);f.disconnect(),c.disconnect(),e.cancelAnimationFrame(s)}}var U=/^data:font\/(?:woff2|woff|ttf|otf);base64,[A-Za-z0-9+/]+=*$/;function q(){let e=[];return t=>{if(t.type!=="fonts"||!Array.isArray(t.fonts))return;let o=globalThis,i=o.FontFace,s=o.document?.fonts;if(!i||!s)return;let a=e;e=[];for(let d of t.fonts.slice(0,8)){if(typeof d?.family!="string"||typeof d.src!="string"||!U.test(d.src))continue;let u=`url(${JSON.stringify(d.src)})`,f={display:"swap",...typeof d.weight=="string"?{weight:d.weight}:{},...typeof d.style=="string"?{style:d.style}:{}},c=new i(d.family,u,f);c.status==="error"&&(c=new i(JSON.stringify(d.family),u,f)),s.add(c),e.push(c),c.load().catch(()=>s.delete(c))}for(let d of a)s.delete(d)}}function D(e){let t=[];return o=>{if(o.type!=="away"||typeof o.away!="boolean")return;let i=e();if(!i)return;if(o.away){for(let a of i.querySelectorAll("video, audio"))a.paused||(a.pause(),t.push(a));return}let s=t;t=[];for(let a of s)a.isConnected&&a.paused&&a.play()?.catch(()=>{})}}function F(e={}){let t=e.window??globalThis,o=q(),i=D(()=>t.document),s,a=t,d=()=>{!s&&a.document&&"ResizeObserver"in a&&"MutationObserver"in a&&"requestAnimationFrame"in a&&(s=H(a,(y,g)=>u.send({type:"records",boxes:y,shows:g})))},u=A({listen(y){return t.addEventListener("message",y),()=>t.removeEventListener("message",y)},fromHost:y=>y.source===t.parent&&(e.hostOrigin===void 0||y.origin===e.hostOrigin),ready:y=>t.parent?.postMessage(y,"*")},{onMessage:y=>{o(y),i(y),d()}}),{guest:f}=u,c=f.close;return f.close=()=>(s?.(),c()),f}return L(W);})();
package/dist/channel.d.ts CHANGED
@@ -9,6 +9,15 @@ export interface Guest {
9
9
  readonly props: GuestProps | undefined;
10
10
  /** Called with every push. Returns the unsubscribe. */
11
11
  subscribe(listener: (props: GuestProps) => void): () => void;
12
+ /** Whether the host has it off the page, out of sight: a frame kept for a return, its page left. */
13
+ readonly away: boolean;
14
+ /**
15
+ * Called as the host takes it off the page (`true`) and puts it back
16
+ * (`false`). The frame's client pauses its playing `<video>` and
17
+ * `<audio>` itself; a sound of the guest's own making (Web Audio) is
18
+ * its to stop here. Returns the stop.
19
+ */
20
+ onAway(listener: (away: boolean) => void): () => void;
12
21
  /** Ask for an act by name — or several of it, as one change and one undo, with a list of arguments (FR-193). Resolves with the host's answer; never rejects for a refusal. */
13
22
  act(name: string, args?: Readonly<Record<string, unknown>> | readonly Readonly<Record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AI,CAAC;IAC/C,mIAAmI;IACnI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CAChD,GACL;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAgHxD"}
package/dist/channel.js CHANGED
@@ -10,6 +10,8 @@ export function openGuest(link, hooks = {}) {
10
10
  let props;
11
11
  let next = 0;
12
12
  const listeners = new Set();
13
+ const awayListeners = new Set();
14
+ let away = false;
13
15
  const waiting = new Map();
14
16
  const queued = [];
15
17
  const send = (request) => {
@@ -34,11 +36,25 @@ export function openGuest(link, hooks = {}) {
34
36
  else if (message.type === "event" && typeof message.listener === "number") {
35
37
  hooks.onEvent?.(message);
36
38
  }
39
+ else if (message.type === "away" && typeof message.away === "boolean") {
40
+ away = message.away;
41
+ }
37
42
  else if (message.type === "heartbeat" && typeof message.beat === "number") {
38
43
  /* The runtime answers, so only a blocked event loop goes quiet. */
39
44
  send({ type: "heartbeat", beat: message.beat });
40
45
  }
41
46
  hooks.onMessage?.(message);
47
+ /* Heard by the guest's code once the client has done its own with it (its media paused): a listener that throws stops nothing of that. */
48
+ if (message.type === "away" && typeof message.away === "boolean") {
49
+ for (const listener of [...awayListeners]) {
50
+ try {
51
+ listener(message.away);
52
+ }
53
+ catch (error) {
54
+ console.error(error);
55
+ }
56
+ }
57
+ }
42
58
  };
43
59
  let stop = () => { };
44
60
  const hello = (event) => {
@@ -70,6 +86,13 @@ export function openGuest(link, hooks = {}) {
70
86
  listeners.add(listener);
71
87
  return () => listeners.delete(listener);
72
88
  },
89
+ get away() {
90
+ return away;
91
+ },
92
+ onAway(listener) {
93
+ awayListeners.add(listener);
94
+ return () => void awayListeners.delete(listener);
95
+ },
73
96
  act(name, args = {}) {
74
97
  const id = (next += 1);
75
98
  return new Promise((resolve) => {
@@ -101,6 +124,7 @@ export function openGuest(link, hooks = {}) {
101
124
  stop();
102
125
  port?.close();
103
126
  listeners.clear();
127
+ awayListeners.clear();
104
128
  },
105
129
  };
106
130
  return { guest, send };
@@ -1 +1 @@
1
- {"version":3,"file":"channel.js","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,GAOhB,MAAM,eAAe,CAAC;AA+CvB;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,IAAe,EACf,QAII,EAAE;IAEN,IAAI,IAA6B,CAAC;IAClC,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,KAA6B,CAAC;IAClC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,SAAS,GAAG,IAAI,GAAG,EAA+B,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkD,CAAC;IAC1E,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,EAAE;QAC/B,IAAI,CAAC,IAAI;YAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;;YAC3B,IAAI,CAAC,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,CAAC,KAAmB,EAAE,EAAE;QACvC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAmB,CAAC;QAC1C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO;QACpD,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC7B,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YACtB,KAAK,MAAM,QAAQ,IAAI,SAAS;gBAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5D,CAAC;aAAM,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrC,OAAO,CAAC,GAAG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,MAA8D,CAAC"}
1
+ {"version":3,"file":"client.generated.d.ts","sourceRoot":"","sources":["../src/client.generated.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,EAAE,MAA2xK,CAAC;AACvzK,mCAAmC;AACnC,eAAO,MAAM,mBAAmB,EAAE,MAA8D,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * The frame guest's client as one classic script (FR-88), as text a host
4
4
  * inlines, and its hash for a policy that names it.
5
5
  */
6
- export const GUEST_CLIENT = "/*! @graview/guest/client.js — a frame guest's client (GraviewGuest.connect). Generated from src/client-script.ts. Elastic License 2.0. */\n\"use strict\";var GraviewGuest=(()=>{var k=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var a in t)k(e,a,{get:t[a],enumerable:!0})},z=(e,t,a,i)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let o of _(t))!P.call(e,o)&&o!==a&&k(e,o,{get:()=>t[o],enumerable:!(i=N(t,o))||i.enumerable});return e};var U=e=>z(k({},\"__esModule\",{value:!0}),e);var L={};B(L,{connect:()=>F,protocol:()=>E});var E=1;function T(e){if(typeof e==\"string\")return{type:\"navigate\",to:e};let{place:t,record:a,where:i,section:o}=e??{},u={...i===void 0?{}:{where:i},...o===void 0?{}:{section:String(o)}};return typeof t==\"string\"?{type:\"navigate\",place:t,...u}:typeof a==\"string\"?{type:\"navigate\",to:a,...u}:void 0}function S(e){let t=e;return typeof e==\"object\"&&e!==null&&t.graview===\"host-hello\"&&typeof t.nonce==\"string\"}function H(e,t={}){let a,i=\"\",o,u=0,d=new Set,l=new Map,c=[],r=s=>{a?a.postMessage({...s,nonce:i}):c.push(s)},v=s=>{let n=s.data;if(!(!n||typeof n!=\"object\")){if(n.type===\"props\"){o=n.props;for(let y of d)y(n.props)}else n.type===\"answer\"?(l.get(n.id)?.(n),l.delete(n.id)):n.type===\"event\"&&typeof n.listener==\"number\"?t.onEvent?.(n):n.type===\"heartbeat\"&&typeof n.beat==\"number\"&&r({type:\"heartbeat\",beat:n.beat});t.onMessage?.(n)}},g=()=>{},R=s=>{if(a||!e.fromHost(s)||!S(s.data)||s.data.protocol!==1)return;let n=s.ports[0];if(n){a=n,i=s.data.nonce,a.onmessage=v,a.start?.(),g();for(let y of c.splice(0))r(y)}};g=e.listen(R),e.ready({graview:\"guest-ready\",protocol:1});let f,M={get props(){return o},subscribe(s){return d.add(s),()=>d.delete(s)},act(s,n={}){let y=u+=1;return new Promise(p=>{l.set(y,p),r({type:\"act\",id:y,name:s,args:n})})},navigate(s){let n=T(s);n&&r(n)},size(s){r({type:\"size\",height:s})},autoSize(s){let n=s??globalThis.document?.documentElement,y=globalThis.ResizeObserver;if(!n||!y||typeof n.getBoundingClientRect!=\"function\")return()=>{};f?.disconnect();let p=new y(()=>M.size(Math.ceil(n.getBoundingClientRect().height)));return p.observe(n),f=p,()=>p.disconnect()},close(){f?.disconnect(),g(),a?.close(),d.clear()}};return{guest:M,send:r}}function A(e,t){let a=e.document,i=\"\",o=0,u=0,d=g=>{if(o=0,g-u<16)return l();let R=[],f=[],M=new Map,s=y=>Math.round(y*10)/10;for(let y of a.querySelectorAll(\"[data-record]\")){if(f.length>=200)break;let p=y.getAttribute(\"data-record\");if(!p)continue;f.push(p);let{left:m,top:b,right:w,bottom:x}=y.getBoundingClientRect();for(let h=y.parentElement;h;h=h.parentElement){let G=M.get(h);if(G===void 0){let O=e.getComputedStyle(h);M.set(h,G=O.overflowX!==\"visible\"||O.overflowY!==\"visible\"?h.getBoundingClientRect():null)}G&&(m=Math.max(m,G.left),b=Math.max(b,G.top),w=Math.min(w,G.right),x=Math.min(x,G.bottom))}m=Math.max(m,0),b=Math.max(b,0),w=Math.min(w,e.innerWidth),x=Math.min(x,e.innerHeight),w-m>=1&&x-b>=1&&R.push({id:p,x:s(m),y:s(b),width:s(w-m),height:s(x-b)})}let n=JSON.stringify([R,f]);n!==i&&(i=n,u=g,t(R,f))},l=()=>{o||=e.requestAnimationFrame(d)},c=new e.MutationObserver(l);c.observe(a.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let r=new e.ResizeObserver(l);r.observe(a.documentElement);let v=[\"scroll\",\"resize\",\"load\"];for(let g of v)e.addEventListener(g,l,!0);return l(),()=>{for(let g of v)e.removeEventListener(g,l,!0);c.disconnect(),r.disconnect(),e.cancelAnimationFrame(o)}}var W=/^data:font\\/(?:woff2|woff|ttf|otf);base64,[A-Za-z0-9+/]+=*$/;function q(){let e=[];return t=>{if(t.type!==\"fonts\"||!Array.isArray(t.fonts))return;let a=globalThis,i=a.FontFace,o=a.document?.fonts;if(!i||!o)return;let u=e;e=[];for(let d of t.fonts.slice(0,8)){if(typeof d?.family!=\"string\"||typeof d.src!=\"string\"||!W.test(d.src))continue;let l=`url(${JSON.stringify(d.src)})`,c={display:\"swap\",...typeof d.weight==\"string\"?{weight:d.weight}:{},...typeof d.style==\"string\"?{style:d.style}:{}},r=new i(d.family,l,c);r.status===\"error\"&&(r=new i(JSON.stringify(d.family),l,c)),o.add(r),e.push(r),r.load().catch(()=>o.delete(r))}for(let d of u)o.delete(d)}}function F(e={}){let t=e.window??globalThis,a=q(),i,o=t,u=()=>{!i&&o.document&&\"ResizeObserver\"in o&&\"MutationObserver\"in o&&\"requestAnimationFrame\"in o&&(i=A(o,(r,v)=>d.send({type:\"records\",boxes:r,shows:v})))},d=H({listen(r){return t.addEventListener(\"message\",r),()=>t.removeEventListener(\"message\",r)},fromHost:r=>r.source===t.parent&&(e.hostOrigin===void 0||r.origin===e.hostOrigin),ready:r=>t.parent?.postMessage(r,\"*\")},{onMessage:r=>{a(r),u()}}),{guest:l}=d,c=l.close;return l.close=()=>(i?.(),c()),l}return U(L);})();\n";
6
+ export const GUEST_CLIENT = "/*! @graview/guest/client.js — a frame guest's client (GraviewGuest.connect). Generated from src/client-script.ts. Elastic License 2.0. */\n\"use strict\";var GraviewGuest=(()=>{var k=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var o in t)k(e,o,{get:t[o],enumerable:!0})},z=(e,t,o,i)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let s of _(t))!P.call(e,s)&&s!==o&&k(e,s,{get:()=>t[s],enumerable:!(i=N(t,s))||i.enumerable});return e};var L=e=>z(k({},\"__esModule\",{value:!0}),e);var W={};B(W,{connect:()=>F,protocol:()=>M});var M=1;function T(e){if(typeof e==\"string\")return{type:\"navigate\",to:e};let{place:t,record:o,where:i,section:s}=e??{},a={...i===void 0?{}:{where:i},...s===void 0?{}:{section:String(s)}};return typeof t==\"string\"?{type:\"navigate\",place:t,...a}:typeof o==\"string\"?{type:\"navigate\",to:o,...a}:void 0}function S(e){let t=e;return typeof e==\"object\"&&e!==null&&t.graview===\"host-hello\"&&typeof t.nonce==\"string\"}function A(e,t={}){let o,i=\"\",s,a=0,d=new Set,u=new Set,f=!1,c=new Map,y=[],g=r=>{o?o.postMessage({...r,nonce:i}):y.push(r)},x=r=>{let n=r.data;if(!(!n||typeof n!=\"object\")){if(n.type===\"props\"){s=n.props;for(let l of d)l(n.props)}else n.type===\"answer\"?(c.get(n.id)?.(n),c.delete(n.id)):n.type===\"event\"&&typeof n.listener==\"number\"?t.onEvent?.(n):n.type===\"away\"&&typeof n.away==\"boolean\"?f=n.away:n.type===\"heartbeat\"&&typeof n.beat==\"number\"&&g({type:\"heartbeat\",beat:n.beat});if(t.onMessage?.(n),n.type===\"away\"&&typeof n.away==\"boolean\")for(let l of[...u])try{l(n.away)}catch(p){console.error(p)}}},m=()=>{},E=r=>{if(o||!e.fromHost(r)||!S(r.data)||r.data.protocol!==1)return;let n=r.ports[0];if(n){o=n,i=r.data.nonce,o.onmessage=x,o.start?.(),m();for(let l of y.splice(0))g(l)}};m=e.listen(E),e.ready({graview:\"guest-ready\",protocol:1});let b,R={get props(){return s},subscribe(r){return d.add(r),()=>d.delete(r)},get away(){return f},onAway(r){return u.add(r),()=>void u.delete(r)},act(r,n={}){let l=a+=1;return new Promise(p=>{c.set(l,p),g({type:\"act\",id:l,name:r,args:n})})},navigate(r){let n=T(r);n&&g(n)},size(r){g({type:\"size\",height:r})},autoSize(r){let n=r??globalThis.document?.documentElement,l=globalThis.ResizeObserver;if(!n||!l||typeof n.getBoundingClientRect!=\"function\")return()=>{};b?.disconnect();let p=new l(()=>R.size(Math.ceil(n.getBoundingClientRect().height)));return p.observe(n),b=p,()=>p.disconnect()},close(){b?.disconnect(),m(),o?.close(),d.clear(),u.clear()}};return{guest:R,send:g}}function H(e,t){let o=e.document,i=\"\",s=0,a=0,d=g=>{if(s=0,g-a<16)return u();let x=[],m=[],E=new Map,b=r=>Math.round(r*10)/10;for(let r of o.querySelectorAll(\"[data-record]\")){if(m.length>=200)break;let n=r.getAttribute(\"data-record\");if(!n)continue;m.push(n);let{left:l,top:p,right:v,bottom:G}=r.getBoundingClientRect();for(let h=r.parentElement;h;h=h.parentElement){let w=E.get(h);if(w===void 0){let O=e.getComputedStyle(h);E.set(h,w=O.overflowX!==\"visible\"||O.overflowY!==\"visible\"?h.getBoundingClientRect():null)}w&&(l=Math.max(l,w.left),p=Math.max(p,w.top),v=Math.min(v,w.right),G=Math.min(G,w.bottom))}l=Math.max(l,0),p=Math.max(p,0),v=Math.min(v,e.innerWidth),G=Math.min(G,e.innerHeight),v-l>=1&&G-p>=1&&x.push({id:n,x:b(l),y:b(p),width:b(v-l),height:b(G-p)})}let R=JSON.stringify([x,m]);R!==i&&(i=R,a=g,t(x,m))},u=()=>{s||=e.requestAnimationFrame(d)},f=new e.MutationObserver(u);f.observe(o.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let c=new e.ResizeObserver(u);c.observe(o.documentElement);let y=[\"scroll\",\"resize\",\"load\"];for(let g of y)e.addEventListener(g,u,!0);return u(),()=>{for(let g of y)e.removeEventListener(g,u,!0);f.disconnect(),c.disconnect(),e.cancelAnimationFrame(s)}}var U=/^data:font\\/(?:woff2|woff|ttf|otf);base64,[A-Za-z0-9+/]+=*$/;function q(){let e=[];return t=>{if(t.type!==\"fonts\"||!Array.isArray(t.fonts))return;let o=globalThis,i=o.FontFace,s=o.document?.fonts;if(!i||!s)return;let a=e;e=[];for(let d of t.fonts.slice(0,8)){if(typeof d?.family!=\"string\"||typeof d.src!=\"string\"||!U.test(d.src))continue;let u=`url(${JSON.stringify(d.src)})`,f={display:\"swap\",...typeof d.weight==\"string\"?{weight:d.weight}:{},...typeof d.style==\"string\"?{style:d.style}:{}},c=new i(d.family,u,f);c.status===\"error\"&&(c=new i(JSON.stringify(d.family),u,f)),s.add(c),e.push(c),c.load().catch(()=>s.delete(c))}for(let d of a)s.delete(d)}}function D(e){let t=[];return o=>{if(o.type!==\"away\"||typeof o.away!=\"boolean\")return;let i=e();if(!i)return;if(o.away){for(let a of i.querySelectorAll(\"video, audio\"))a.paused||(a.pause(),t.push(a));return}let s=t;t=[];for(let a of s)a.isConnected&&a.paused&&a.play()?.catch(()=>{})}}function F(e={}){let t=e.window??globalThis,o=q(),i=D(()=>t.document),s,a=t,d=()=>{!s&&a.document&&\"ResizeObserver\"in a&&\"MutationObserver\"in a&&\"requestAnimationFrame\"in a&&(s=H(a,(y,g)=>u.send({type:\"records\",boxes:y,shows:g})))},u=A({listen(y){return t.addEventListener(\"message\",y),()=>t.removeEventListener(\"message\",y)},fromHost:y=>y.source===t.parent&&(e.hostOrigin===void 0||y.origin===e.hostOrigin),ready:y=>t.parent?.postMessage(y,\"*\")},{onMessage:y=>{o(y),i(y),d()}}),{guest:f}=u,c=f.close;return f.close=()=>(s?.(),c()),f}return L(W);})();\n";
7
7
  /** For `script-src 'sha256-…'`. */
8
- export const GUEST_CLIENT_SHA256 = "sha256-XhO5MCu65T5iCNL7YLXGj8WsNNALHvNcqDcUvx+dvKk=";
8
+ export const GUEST_CLIENT_SHA256 = "sha256-O5M2iMMcJB59hOTK/gwnFrnZIHE/8aQ3qpYg86eM/WI=";
9
9
  //# sourceMappingURL=client.generated.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.generated.js","sourceRoot":"","sources":["../src/client.generated.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAW,otJAAotJ,CAAC;AACzvJ,mCAAmC;AACnC,MAAM,CAAC,MAAM,mBAAmB,GAAW,qDAAqD,CAAC"}
1
+ {"version":3,"file":"client.generated.js","sourceRoot":"","sources":["../src/client.generated.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAW,kxKAAkxK,CAAC;AACvzK,mCAAmC;AACnC,MAAM,CAAC,MAAM,mBAAmB,GAAW,qDAAqD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"guest.d.ts","sourceRoot":"","sources":["../src/guest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrD,8DAA8D;AAC9D,UAAU,WAAW;IACnB,QAAQ,CAAC,MAAM,EAAE;QAAE,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACtF,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI,CAAC;IACjF,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI,CAAC;CACrF;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,YAAY,EAAE,KAAK,EAAE,CAAC;AAqCtB;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,KAAK,CA6BrE"}
1
+ {"version":3,"file":"guest.d.ts","sourceRoot":"","sources":["../src/guest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrD,8DAA8D;AAC9D,UAAU,WAAW;IACnB,QAAQ,CAAC,MAAM,EAAE;QAAE,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACtF,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI,CAAC;IACjF,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI,CAAC;CACrF;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,YAAY,EAAE,KAAK,EAAE,CAAC;AAkEtB;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,KAAK,CA+BrE"}
package/dist/guest.js CHANGED
@@ -38,6 +38,39 @@ function frameFonts() {
38
38
  faces.delete(face);
39
39
  };
40
40
  }
41
+ /**
42
+ * WHAT IT PLAYS STOPS WHERE NOBODY SEES IT (Graview HQ
43
+ * feature:f-kept-frame-told-off-page): a frame kept for a return is moved,
44
+ * still running, off the page as its page is left. Told so, the client
45
+ * pauses every `<video>` and `<audio>` of the document that is playing, and
46
+ * told it is back, plays again what it paused that still stands paused.
47
+ * A sound of the guest's own making — Web Audio, a `new Audio()` never put
48
+ * in the document, media in a shadow root — is its to stop (`guest.onAway`).
49
+ */
50
+ function mediaAway(document) {
51
+ let paused = [];
52
+ return (message) => {
53
+ if (message.type !== "away" || typeof message.away !== "boolean")
54
+ return;
55
+ const here = document();
56
+ if (!here)
57
+ return;
58
+ if (message.away) {
59
+ for (const media of here.querySelectorAll("video, audio")) {
60
+ if (media.paused)
61
+ continue;
62
+ media.pause();
63
+ paused.push(media);
64
+ }
65
+ return;
66
+ }
67
+ const again = paused;
68
+ paused = [];
69
+ for (const media of again)
70
+ if (media.isConnected && media.paused)
71
+ void media.play()?.catch(() => undefined);
72
+ };
73
+ }
41
74
  /**
42
75
  * Connect a guest view to its host: say it is ready, take the first hello
43
76
  * from the parent, and talk only over the port that came with it.
@@ -45,6 +78,7 @@ function frameFonts() {
45
78
  export function connectGuest(options = {}) {
46
79
  const at = options.window ?? globalThis;
47
80
  const fonts = frameFonts();
81
+ const media = mediaAway(() => at.document);
48
82
  /* Where its records are, said once the host has said hello, and again as they move (record-report.ts): what a line to each is drawn from. A window that lays nothing out says nothing. */
49
83
  let reporting;
50
84
  const laidOut = at;
@@ -62,6 +96,7 @@ export function connectGuest(options = {}) {
62
96
  }, {
63
97
  onMessage: (message) => {
64
98
  fonts(message);
99
+ media(message);
65
100
  report();
66
101
  },
67
102
  });
package/dist/guest.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"guest.js","sourceRoot":"","sources":["../src/guest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAsBnD,sFAAsF;AACtF,MAAM,SAAS,GAAG,6DAA6D,CAAC;AAEhF;;;;;;GAMG;AACH,SAAS,UAAU;IACjB,IAAI,IAAI,GAAe,EAAE,CAAC;IAC1B,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO;QACtE,MAA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AAG,MAAM,CAAC;IACzB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC1B,KAAK,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { DescribedPart, DescribedProblem, DescribedVideo } from "@graview/core/describe";
2
2
  import type { GuestProps } from "../protocol.js";
3
3
  import { type NamedPlace } from "../host/links-words.js";
4
+ import { type EmbedHost } from "../host/embeds.js";
4
5
  import { TreeElement } from "./tree.js";
5
6
  export interface DescribeDrawingContext {
6
7
  /** What the view was shown: a record a link or a row names is looked up here, and only here. */
@@ -14,6 +15,8 @@ export interface DescribeDrawingContext {
14
15
  readonly kind: string;
15
16
  readonly field: string;
16
17
  }[];
18
+ /** The providers the live host plays a video from (HQ f-view-video-embeds): every one unsaid. */
19
+ readonly embeds?: EmbedHost;
17
20
  }
18
21
  export interface DescribedDrawing {
19
22
  readonly parts: readonly DescribedPart[];
@@ -1 +1 @@
1
- {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/headless/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7G,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAyC,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhG,OAAO,EAAE,WAAW,EAA2B,MAAM,WAAW,CAAC;AAoBjE,MAAM,WAAW,sBAAsB;IACrC,gGAAgG;IAChG,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,kJAAkJ;IAClJ,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAA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E;IACnE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,+GAA+G;IAC/G,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;CAC5C;AAKD,mIAAmI;AACnI,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,EAAE,EAAE,CAAC;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,cAAc,CAoBrW;AASD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQvE;AAsHD,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB,GAAG,gBAAgB,CAgRpG"}
@@ -1,4 +1,5 @@
1
1
  import { placeNamed, placesSaid, unsureOfViews } from "../host/links-words.js";
2
+ import { embedLink, embedPlays, EMBED_WORDS, embedTitle, namedEmbed, namesEmbed } from "../host/embeds.js";
2
3
  import { notPressable } from "../host/pressable.js";
3
4
  import { TreeElement, TreeText } from "./tree.js";
4
5
  /** The sources a browser plays (what a host's upload transcodes to): a QuickTime HEVC `.mov` is not one. */
@@ -404,6 +405,20 @@ export function describeDrawing(root, context) {
404
405
  }
405
406
  /* A record's video the host plays (0.1.37): said by what it shows and how long it is, from the record the view was shown. */
406
407
  case "graview-video": {
408
+ /* A video on YouTube or Vimeo (HQ f-view-video-embeds): read as the page reads it, and refused in the same words, with a code. */
409
+ const saidBy = (name) => element.getAttribute(name);
410
+ if (namesEmbed(saidBy)) {
411
+ const named = namedEmbed(saidBy);
412
+ if ("why" in named) {
413
+ problems.push({ at: "drawing <graview-video>", says: `Not drawn: it ${named.why}.`, code: "embed-refused" });
414
+ return [];
415
+ }
416
+ const text = embedTitle(saidBy, named.embed);
417
+ const provider = EMBED_WORDS[named.embed.provider];
418
+ const plays = embedPlays(named.embed.provider, context.embeds);
419
+ videos.push({ provider: named.embed.provider, link: embedLink(named.embed), text, name: named.embed.id, source: provider, poster: element.getAttribute("poster") !== null, autoplay: false, cover: false, playable: plays, ...(plays ? {} : { why: `this host plays no ${provider} video in a view: its link is drawn alone` }) });
420
+ return [{ t: "text", text: plays ? `${text}, a ${provider} video, played where it stands once pressed` : `${text}: watch on ${provider}`, tone: "picture" }];
421
+ }
407
422
  /* The app's own video (HQ f-view-names-app-video): said from the facts the view was handed, never a record's. */
408
423
  if (element.getAttribute("data-app") !== null) {
409
424
  const app = element.getAttribute("data-app") ?? "";