@aperture-browser/session-element 0.0.0-nightly.99.75d2f316d627 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -19
- package/dist/aperture-session.js +26 -8
- package/dist/index.d.ts +14 -13
- package/package.json +8 -8
- package/dist/aperture--a4Khxe6.js +0 -29
- package/dist/aperture-session-view.js +0 -5
- package/dist/attribute-access.d.ts +0 -6
- package/dist/headless.d.ts +0 -47
|
@@ -1,5 +0,0 @@
|
|
|
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--a4Khxe6.js";var u=e(r(),1),d=i(),f=s(),p={status:`loading`,role:null,connection:`idle`,tabs:[],activeTabId:null},m=`
|
|
2
|
-
:host { display: block; position: relative; overflow: hidden; }
|
|
3
|
-
:host([hidden]) { display: none; }
|
|
4
|
-
.mount { display: flex; height: 100%; }
|
|
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};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type SessionAccess } from "@aperture-browser/session-react/headless";
|
|
2
|
-
/**
|
|
3
|
-
* Resolves the `token` and `base-url` attributes to session access. A new access object
|
|
4
|
-
* reconnects the session, so the previous one is reused while both attributes are unchanged.
|
|
5
|
-
*/
|
|
6
|
-
export declare function attributeAccess(): (element: HTMLElement) => SessionAccess | null;
|
package/dist/headless.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type SessionAccess } from "@aperture-browser/session-react/headless";
|
|
2
|
-
export interface ApertureTab {
|
|
3
|
-
readonly id: string;
|
|
4
|
-
readonly title: string;
|
|
5
|
-
readonly url: string;
|
|
6
|
-
readonly loading: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface ApertureSessionSnapshot {
|
|
9
|
-
readonly status: "invalid" | "loading" | "denied" | "expired" | "unavailable" | "ready";
|
|
10
|
-
readonly role: "owner" | "editor" | "viewer" | null;
|
|
11
|
-
readonly connection: "idle" | "connecting" | "connected" | "disconnected" | "error";
|
|
12
|
-
readonly tabs: readonly ApertureTab[];
|
|
13
|
-
readonly activeTabId: string | null;
|
|
14
|
-
}
|
|
15
|
-
export interface ApertureNotice {
|
|
16
|
-
readonly level: "error" | "success";
|
|
17
|
-
readonly message: string;
|
|
18
|
-
}
|
|
19
|
-
export declare class ApertureSessionViewElement extends HTMLElement {
|
|
20
|
-
#private;
|
|
21
|
-
static readonly observedAttributes: string[];
|
|
22
|
-
get access(): SessionAccess | null;
|
|
23
|
-
set access(access: SessionAccess | null);
|
|
24
|
-
get snapshot(): ApertureSessionSnapshot;
|
|
25
|
-
navigate(url: string): Promise<void>;
|
|
26
|
-
back(): Promise<void>;
|
|
27
|
-
forward(): Promise<void>;
|
|
28
|
-
reload(): Promise<void>;
|
|
29
|
-
stop(): Promise<void>;
|
|
30
|
-
openTab(url?: string): Promise<string | null>;
|
|
31
|
-
closeTab(tabId: string): Promise<void>;
|
|
32
|
-
activateTab(tabId: string): Promise<void>;
|
|
33
|
-
reconnect(): void;
|
|
34
|
-
whenConnected(): Promise<ApertureSessionSnapshot>;
|
|
35
|
-
connectedCallback(): void;
|
|
36
|
-
disconnectedCallback(): void;
|
|
37
|
-
attributeChangedCallback(): void;
|
|
38
|
-
}
|
|
39
|
-
declare global {
|
|
40
|
-
interface HTMLElementTagNameMap {
|
|
41
|
-
"aperture-session-view": ApertureSessionViewElement;
|
|
42
|
-
}
|
|
43
|
-
interface HTMLElementEventMap {
|
|
44
|
-
"aperture-change": CustomEvent<ApertureSessionSnapshot>;
|
|
45
|
-
"aperture-notice": CustomEvent<ApertureNotice>;
|
|
46
|
-
}
|
|
47
|
-
}
|