@aperture-browser/session-element 0.0.0-init.0 → 0.0.0-nightly.100.78b4e7ef6edc
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/README.md +9 -42
- package/dist/aperture-D6kGXqy-.js +29 -0
- package/dist/aperture-session-view.js +2 -2
- package/dist/aperture-session.js +8 -8
- package/dist/attribute-access.d.ts +6 -0
- package/dist/headless.d.ts +5 -2
- package/dist/index.d.ts +3 -0
- package/package.json +3 -3
- package/dist/aperture-t-Xm6-Va.js +0 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{N as e,c as t,i as n,j as r,k as i,n as a,r as o,s,t as c,x as l}from"./aperture-D6kGXqy-.js";var u=e(r(),1),d=i(),f=s(),p={status:`loading`,role:null,connection:`idle`,tabs:[],activeTabId:null},m=`
|
|
2
2
|
:host { display: block; position: relative; overflow: hidden; }
|
|
3
3
|
:host([hidden]) { display: none; }
|
|
4
4
|
.mount { display: flex; height: 100%; }
|
|
5
|
-
`;function
|
|
5
|
+
`;function h({access:e,onControl:t,onSnapshot:r,onNotice:i}){let{status:o,control:s}=a({access:e,onNotice:i}),c=(0,u.useMemo)(()=>({status:o,role:s.phase===`connected`?s.collaboration.role:null,connection:s.phase,tabs:s.targets.map(({id:e,title:t,url:n,loading:r})=>({id:e,title:t,url:n,loading:r})),activeTabId:s.activeTargetId}),[s.activeTargetId,s.phase,s.targets,s.collaboration.role,o]);return(0,u.useEffect)(()=>t(s)),(0,u.useEffect)(()=>r(c),[r,c]),o===`ready`?(0,f.jsx)(n,{control:s}):null}var g=class extends HTMLElement{static observedAttributes=[`token`,`base-url`];#e=null;#t=null;#n=c();get access(){return this.#t}set access(e){this.#t=e,this.#u()}#r=null;#i=p;get snapshot(){return this.#i}navigate(e){return this.#o(t=>t.navigate(e))}back(){return this.#o(e=>e.historyBack())}forward(){return this.#o(e=>e.historyForward())}reload(){return this.#o(e=>e.reload())}stop(){return this.#o(e=>e.stopLoading())}openTab(e){return this.#o(t=>t.createTarget(e))}closeTab(e){return this.#o(t=>t.closeTarget(e))}activateTab(e){return this.#o(t=>t.activateTarget(e)).then(async()=>{await this.#a(t=>t.activeTabId===e)})}reconnect(){this.#r?.reconnect()}whenConnected(){return this.#a(e=>e.connection===`connected`)}#a(e){return new Promise((n,r)=>{let i=()=>{let a=this.#i;if(e(a))n(a);else if(a.status===`invalid`||a.status===`denied`||a.connection===`error`||a.status===`expired`||a.status===`unavailable`)r(new t({message:`the session is ${a.status}`}));else return;this.removeEventListener(`aperture-change`,i)};this.addEventListener(`aperture-change`,i),i()})}#o(e){let n=this.#r;return n?l(e(n.commands)):Promise.reject(new t({message:`the session is not connected`}))}connectedCallback(){let e=this.shadowRoot??this.attachShadow({mode:`open`});e.replaceChildren();let t=document.createElement(`style`);t.textContent=m;let n=document.createElement(`div`);n.className=`mount`,e.append(t,n),this.#e=(0,d.createRoot)(n),this.#u()}disconnectedCallback(){this.#e?.unmount(),this.#e=null,this.#r=null}attributeChangedCallback(){this.#u()}#s=e=>{this.#r=e};#c=e=>{JSON.stringify(e)!==JSON.stringify(this.#i)&&(this.#i=e,this.dispatchEvent(new CustomEvent(`aperture-change`,{detail:e})))};#l=e=>{this.dispatchEvent(new CustomEvent(`aperture-notice`,{detail:e}))};#u(){let e=this.#t??this.#n(this),t=this.#t!==null||this.hasAttribute(`token`),n=e?.baseUrl;this.#e?.render(t?(0,f.jsx)(o,{baseUrl:n,children:(0,f.jsx)(h,{access:e,onControl:this.#s,onSnapshot:this.#c,onNotice:this.#l})},n??``):null)}};customElements.get(`aperture-session-view`)||customElements.define(`aperture-session-view`,g);export{g as ApertureSessionViewElement};
|