fix widget api appliaction capabilities

This commit is contained in:
Timo K
2026-01-25 14:24:52 +01:00
parent 31823dbd53
commit 112420cb5b
3 changed files with 15 additions and 17 deletions

View File

@@ -21,7 +21,7 @@ in the repository root.
It will create a `dist` folder containing the compiled js file. It will create a `dist` folder containing the compiled js file.
This file needs to be hosted. Locally (via `npx serve -l 81234 --cors`) or on a remote server. This file needs to be hosted. Locally (via `npx serve -l 1234 --cors`) or on a remote server.
Now you just need to add the widget to element web via: Now you just need to add the widget to element web via:

View File

@@ -12,15 +12,12 @@ Please see LICENSE in the repository root for full details.
import { logger as rootLogger } from "matrix-js-sdk/lib/logger"; import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
import { scan } from "rxjs"; import { scan } from "rxjs";
import { widget as _widget } from "../src/widget"; import { type WidgetHelpers } from "../src/widget";
import { type LivekitRoomItem } from "../src/state/CallViewModel/CallViewModel"; import { type LivekitRoomItem } from "../src/state/CallViewModel/CallViewModel";
export const logger = rootLogger.getChild("[MatrixRTCSdk]"); export const logger = rootLogger.getChild("[MatrixRTCSdk]");
if (!_widget) throw Error("No widget. This webapp can only start as a widget"); export const tryMakeSticky = (widget: WidgetHelpers): void => {
export const widget = _widget;
export const tryMakeSticky = (): void => {
logger.info("try making sticky MatrixRTCSdk"); logger.info("try making sticky MatrixRTCSdk");
void widget.api void widget.api
.setAlwaysOnScreen(true) .setAlwaysOnScreen(true)

View File

@@ -50,14 +50,12 @@ import { getUrlParams } from "../src/UrlParams";
import { MuteStates } from "../src/state/MuteStates"; import { MuteStates } from "../src/state/MuteStates";
import { MediaDevices } from "../src/state/MediaDevices"; import { MediaDevices } from "../src/state/MediaDevices";
import { E2eeType } from "../src/e2ee/e2eeType"; import { E2eeType } from "../src/e2ee/e2eeType";
import { currentAndPrev, logger, TEXT_LK_TOPIC, tryMakeSticky } from "./helper";
import { import {
currentAndPrev, ElementWidgetActions,
logger, widget as _widget,
TEXT_LK_TOPIC, initializeWidget,
tryMakeSticky, } from "../src/widget";
widget,
} from "./helper";
import { ElementWidgetActions, initializeWidget } from "../src/widget";
import { type Connection } from "../src/state/CallViewModel/remoteMembers/Connection"; import { type Connection } from "../src/state/CallViewModel/remoteMembers/Connection";
interface MatrixRTCSdk { interface MatrixRTCSdk {
@@ -87,8 +85,11 @@ interface MatrixRTCSdk {
export async function createMatrixRTCSdk( export async function createMatrixRTCSdk(
application: string = "m.call", application: string = "m.call",
id: string = "", id: string = "",
sticky: boolean = false,
): Promise<MatrixRTCSdk> { ): Promise<MatrixRTCSdk> {
initializeWidget(); initializeWidget(application);
const widget = _widget;
if (!widget) throw Error("No widget. This webapp can only start as a widget");
const client = await widget.client; const client = await widget.client;
logger.info("client created"); logger.info("client created");
const scope = new ObservableScope(); const scope = new ObservableScope();
@@ -100,8 +101,8 @@ export async function createMatrixRTCSdk(
const mediaDevices = new MediaDevices(scope); const mediaDevices = new MediaDevices(scope);
const muteStates = new MuteStates(scope, mediaDevices, { const muteStates = new MuteStates(scope, mediaDevices, {
audioEnabled: true, audioEnabled: false,
videoEnabled: true, videoEnabled: false,
}); });
const slot = { application, id }; const slot = { application, id };
const rtcSession = new MatrixRTCSession(client, room, slot); const rtcSession = new MatrixRTCSession(client, room, slot);
@@ -267,7 +268,7 @@ export async function createMatrixRTCSdk(
return { return {
join: (): void => { join: (): void => {
// first lets try making the widget sticky // first lets try making the widget sticky
tryMakeSticky(); if (sticky) tryMakeSticky(widget);
callViewModel.join(); callViewModel.join();
}, },
leave: (): void => { leave: (): void => {