loadWeei(options)
declare function loadWeei(options?: { releaseId?: string }): Promise<WeeiClient>;Resolves once Weei has loaded your site's settings and widgets. It does not wait for other participants to connect. Pass releaseId only to pin a specific release; otherwise the current release is used. See loader errors.
WeeiClient
interface WeeiClient {
readonly ready: Promise<void>;
setVisibility(show: boolean): void;
setUser(input: WeeiUserInput): Promise<WeeiUserIdentity>;
readonly widgetsApi: WeeiWidgetsApi;
addWidget(source: WeeiSiteWidgetSource): Promise<WeeiSiteWidgetHandle>;
readonly sdk: WeeiSdk;
readonly peers: WeeiPeersApi; // participants and connections
readonly rooms: WeeiRoomsApi; // the current room and meetings
readonly media: WeeiMediaApi; // camera, microphone, screen and participants' streams
onNotice(listener: (notice: WeeiNotice) => void): () => void;
}peers, rooms, media and onNotice() are described in Peers, rooms and media.
setVisibility(show)
Shows or hides all of Weei's UI on the page: the control panel, notifications, participant video tiles and the screen preview. Hidden, none of it is built; your page can use peers, rooms and media and onNotice() instead. Widget windows still open when your page opens them. Hiding does not disconnect anyone, and setVisibility(true) brings the UI back.
Until you call it, the UI follows your site settings. The control panel appears only if your site settings allow it for the current user, even after setVisibility(true).
const weei = await window.weeiReady;
weei.setVisibility(false);
weei.setVisibility(true);setUser(input)
interface WeeiUserInput {
id: string; // your user ID, 1–256 characters
displayName: string; // shown to other participants, 1–120 characters
token?: string; // identity token from your backend
}
interface WeeiUserIdentity {
peerId: string;
siteId: string;
userId?: string;
displayName: string;
authorized: boolean;
controlPanelAllowed?: boolean;
}const weei = await window.weeiReady;
const identity = await weei.setUser({ id: 'user-42', displayName: 'Ada Lovelace' });
console.log(identity.authorized);Without a valid token the user is not authorized; an ID and a name alone are not proof of identity. Rejects with Invalid user. for invalid input. Widget access is refreshed before the promise resolves.
widgetsApi
Opens and closes widgets and returns their APIs. See Built-in widgets.
addWidget(source)
type WeeiSiteWidgetSource =
| (new () => SiteWidget) // a class
| (() => SiteWidget) // a factory
| WeeiWidgetModule // an already imported module object
| string; // the URL of a widget module
interface WeeiWidgetModule {
widgetId: string;
apiVersion: number; // must match weei.sdk.moduleApiVersion
createWidget(): SiteWidget;
}
interface WeeiSiteWidgetHandle {
readonly widgetId: string;
remove(): void;
}Adds a widget your site supplies. Pass a class, a factory, an imported module object, or a module URL. Module objects must provide a matching widgetId, apiVersion and createWidget(). See Build a site widget.
sdk
RxJS and the core connectors of the loaded release, for site widgets. See weei.sdk.
One client per page
Create the client once and reuse it. It has no destroy(); do not create a new one on every route change.