mirror of
https://github.com/vector-im/element-call.git
synced 2026-01-18 02:32:27 +00:00
cleanup changes godot->sdk add docs
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
## url parameters
|
||||
widgetId = $matrix_widget_id
|
||||
perParticipantE2EE = true
|
||||
userId = $matrix_user_id
|
||||
deviceId = $org.matrix.msc3819.matrix_device_id
|
||||
baseUrl = $org.matrix.msc4039.matrix_base_url
|
||||
|
||||
parentUrl = // will be inserted automatically
|
||||
|
||||
http://localhost?widgetId=&perParticipantE2EE=true&userId=&deviceId=&baseUrl=&roomId=
|
||||
|
||||
->
|
||||
|
||||
http://localhost:3000?widgetId=$matrix_widget_id&perParticipantE2EE=true&userId=$matrix_user_id&deviceId=$org.matrix.msc3819.matrix_device_id&baseUrl=$org.matrix.msc4039.matrix_base_url&roomId=$matrix_room_id
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB |
10
index.html
10
index.html
@@ -43,15 +43,5 @@
|
||||
<% if (packageType !== "full") { %>
|
||||
<div id="root"></div>
|
||||
<% } %>
|
||||
|
||||
<!-- Godot export -->
|
||||
<% if (packageType === "godot") { %>
|
||||
<canvas id="canvas"></canvas>
|
||||
<script src="$GODOT_URL"></script>
|
||||
<script>
|
||||
var engine = new Engine($GODOT_CONFIG);
|
||||
engine.startGame();
|
||||
</script>
|
||||
<% } %>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
"build:embedded": "yarn build:full --config vite-embedded.config.js",
|
||||
"build:embedded:production": "yarn build:embedded",
|
||||
"build:embedded:development": "yarn build:embedded --mode development",
|
||||
"build:godot": "yarn build:full --config vite-godot.config.js",
|
||||
"build:godot:development": "yarn build:godot --mode development",
|
||||
"build:sdk": "yarn build:full --config vite-sdk.config.js",
|
||||
"build:sdk:development": "yarn build:sdk --mode development",
|
||||
"serve": "vite preview",
|
||||
"prettier:check": "prettier -c .",
|
||||
"prettier:format": "prettier -w .",
|
||||
|
||||
35
sdk/README.md
Normal file
35
sdk/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# SDK mode
|
||||
|
||||
EC can be build in sdk mode. This will result in a compiled js file that can be imported in very simple webapps.
|
||||
|
||||
It allows to use matrixRTC in combination with livekit without relying on element call.
|
||||
|
||||
This is done by instantiating the call view model and exposing some useful behaviors (observables) and methods.
|
||||
|
||||
This folder contains an example index.html file that showcases the sdk in use (hosted on localhost:8123 with a webserver ellowing cors (for example `npx serve -l 81234 --cors`)) as a godot engine HTML export template.
|
||||
|
||||
## Widgets
|
||||
|
||||
The sdk mode is particularly interesting to be used in widgets where you do not need to pay attention to matrix login/cs api ...
|
||||
To create a widget see the example index.html file in this folder. And add it to EW via:
|
||||
`/addwidget <widgetUrl>` (see **url parameters** for more details on `<widgetUrl>`)
|
||||
|
||||
### url parameters
|
||||
|
||||
```
|
||||
widgetId = $matrix_widget_id
|
||||
perParticipantE2EE = true
|
||||
userId = $matrix_user_id
|
||||
deviceId = $org.matrix.msc3819.matrix_device_id
|
||||
baseUrl = $org.matrix.msc4039.matrix_base_url
|
||||
```
|
||||
|
||||
`parentUrl = // will be inserted automatically`
|
||||
|
||||
Full template use as `<widgetUrl>`:
|
||||
|
||||
```
|
||||
http://localhost:3000?widgetId=$matrix_widget_id&perParticipantE2EE=true&userId=$matrix_user_id&deviceId=$org.matrix.msc3819.matrix_device_id&baseUrl=$org.matrix.msc4039.matrix_base_url&roomId=$matrix_room_id
|
||||
```
|
||||
|
||||
the `$` prefixed variables will be replaced by EW on widget instantiation. (e.g. `$matrix_user_id` -> `@user:example.com` (url encoding will also be applied automatically by EW) -> `%40user%3Aexample.com`)
|
||||
@@ -5,6 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file contains helper functions and types for the MatrixRTC SDK.
|
||||
*/
|
||||
|
||||
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
|
||||
import { scan } from "rxjs";
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<title>Godot MatrixRTC Widget</title>
|
||||
<meta charset="utf-8" />
|
||||
<script type="module">
|
||||
// TODO use the url where the matrixrtc-ec-godot.js file from dist is hosted
|
||||
import { createMatrixRTCSdk } from "http://localhost:8123/matrixrtc-ec-godot.js";
|
||||
// TODO use the url where the matrixrtc-sdk.js file from dist is hosted
|
||||
import { createMatrixRTCSdk } from "http://localhost:8123/matrixrtc-sdk.js";
|
||||
|
||||
try {
|
||||
console.log("Hello from index.html");
|
||||
@@ -5,7 +5,19 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
// import { type InitResult } from "../src/ClientContext";
|
||||
/**
|
||||
* This file is the entrypoint for the sdk build of element call: `yarn build:sdk`
|
||||
* use in widgets.
|
||||
* It exposes the `createMatrixRTCSdk` which creates the `MatrixRTCSdk` interface (see below) that
|
||||
* can be used to join a rtc session and exchange realtime data.
|
||||
* It takes care of all the tricky bits:
|
||||
* - sending delayed events
|
||||
* - finding the right sfu
|
||||
* - handling the media stream
|
||||
* - sending join/leave state or sticky events
|
||||
* - setting up encryption and scharing keys
|
||||
*/
|
||||
|
||||
import { map, type Observable, of, Subject, switchMap, tap } from "rxjs";
|
||||
import { MatrixRTCSessionEvent } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { type TextStreamInfo } from "livekit-client/dist/src/room/types";
|
||||
@@ -40,6 +52,7 @@ interface MatrixRTCSdk {
|
||||
members$: Behavior<MatrixLivekitMember[]>;
|
||||
sendData?: (data: unknown) => Promise<void>;
|
||||
}
|
||||
|
||||
export async function createMatrixRTCSdk(): Promise<MatrixRTCSdk> {
|
||||
logger.info("Hello");
|
||||
const client = await widget.client;
|
||||
@@ -262,8 +262,8 @@ export interface CallViewModel {
|
||||
participantCount$: Behavior<number>;
|
||||
/** Participants sorted by livekit room so they can be used in the audio rendering */
|
||||
livekitRoomItems$: Behavior<LivekitRoomItem[]>;
|
||||
/** use the layout instead, this is just for the godot export. */
|
||||
userMedia$: Behavior<UserMedia[]>;
|
||||
/** use the layout instead, this is just for the sdk export. */
|
||||
matrixLivekitMembers$: Behavior<MatrixLivekitMember[]>;
|
||||
localMatrixLivekitMember$: Behavior<LocalMatrixLivekitMember | null>;
|
||||
/** List of participants raising their hand */
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"./src/**/*.ts",
|
||||
"./src/**/*.tsx",
|
||||
"./playwright/**/*.ts",
|
||||
"./godot/**/*.ts"
|
||||
"./sdk/**/*.ts"
|
||||
],
|
||||
"exclude": ["**.test.ts"]
|
||||
}
|
||||
|
||||
@@ -14,17 +14,17 @@ const base = "./";
|
||||
// Config for embedded deployments (possibly hosted under a non-root path)
|
||||
export default defineConfig((env) =>
|
||||
mergeConfig(
|
||||
fullConfig({ ...env, packageType: "godot" }),
|
||||
fullConfig({ ...env, packageType: "sdk" }),
|
||||
defineConfig({
|
||||
base, // Use relative URLs to allow the app to be hosted under any path
|
||||
// publicDir: false, // Don't serve the public directory which only contains the favicon
|
||||
build: {
|
||||
manifest: true,
|
||||
lib: {
|
||||
entry: "./godot/main.ts",
|
||||
name: "matrixrtc-ec-godot",
|
||||
entry: "./sdk/main.ts",
|
||||
name: "matrixrtc-sdk",
|
||||
// the proper extensions will be added
|
||||
fileName: "matrixrtc-ec-godot",
|
||||
fileName: "matrixrtc-sdk",
|
||||
},
|
||||
},
|
||||
plugins: [nodePolyfills()],
|
||||
@@ -27,7 +27,7 @@ import * as fs from "node:fs";
|
||||
export default ({
|
||||
mode,
|
||||
packageType,
|
||||
}: ConfigEnv & { packageType?: "full" | "embedded" | "godot" }): UserConfig => {
|
||||
}: ConfigEnv & { packageType?: "full" | "embedded" | "sdk" }): UserConfig => {
|
||||
const env = loadEnv(mode, process.cwd());
|
||||
// Environment variables with the VITE_ prefix are accessible at runtime.
|
||||
// So, we set this to allow for build/package specific behavior.
|
||||
@@ -68,7 +68,7 @@ export default ({
|
||||
|
||||
plugins.push(
|
||||
createHtmlPlugin({
|
||||
entry: packageType === "godot" ? "godot/main.ts" : "src/main.tsx",
|
||||
entry: packageType === "sdk" ? "sdk/main.ts" : "src/main.tsx",
|
||||
inject: {
|
||||
data: {
|
||||
brand: env.VITE_PRODUCT_NAME || "Element Call",
|
||||
@@ -126,7 +126,7 @@ export default ({
|
||||
return "assets/[name]-[hash][extname]";
|
||||
},
|
||||
manualChunks:
|
||||
packageType !== "godot"
|
||||
packageType !== "sdk"
|
||||
? {
|
||||
// we should be able to remove this one https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/pull/167 lands
|
||||
"matrix-sdk-crypto-wasm": [
|
||||
|
||||
Reference in New Issue
Block a user