2021-07-16 14:38:44 -07:00
|
|
|
/*
|
2024-09-06 10:22:13 +02:00
|
|
|
Copyright 2021-2024 New Vector Ltd.
|
2021-07-16 14:38:44 -07:00
|
|
|
|
2025-02-18 17:59:58 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-06 10:22:13 +02:00
|
|
|
Please see LICENSE in the repository root for full details.
|
2021-07-16 14:38:44 -07:00
|
|
|
*/
|
|
|
|
|
|
2022-06-01 15:55:02 +01:00
|
|
|
// We need to import this somewhere, once, so that the correct 'request'
|
|
|
|
|
// function gets set. It needs to be not in the same file as we use
|
|
|
|
|
// createClient, or the typescript transpiler gets confused about
|
|
|
|
|
// dependency references.
|
2025-03-13 13:58:43 +01:00
|
|
|
import "matrix-js-sdk/lib/browser-index";
|
2022-06-01 15:55:02 +01:00
|
|
|
|
2025-10-08 16:39:27 -04:00
|
|
|
import { StrictMode } from "react";
|
2022-10-27 08:55:04 -04:00
|
|
|
import { createRoot } from "react-dom/client";
|
2022-06-01 11:48:17 -04:00
|
|
|
import "./index.css";
|
2025-03-13 13:58:43 +01:00
|
|
|
import { logger } from "matrix-js-sdk/lib/logger";
|
2023-09-26 12:08:08 +01:00
|
|
|
import {
|
|
|
|
|
setLogExtension as setLKLogExtension,
|
2024-09-11 14:02:59 +01:00
|
|
|
setLogLevel as setLKLogLevel,
|
2023-09-26 12:08:08 +01:00
|
|
|
} from "livekit-client";
|
2023-09-21 16:50:31 +01:00
|
|
|
|
2023-09-22 18:05:13 -04:00
|
|
|
import { App } from "./App";
|
2022-04-07 14:22:36 -07:00
|
|
|
import { init as initRageshake } from "./settings/rageshake";
|
2022-11-04 18:29:40 +01:00
|
|
|
import { Initializer } from "./initializer";
|
2025-06-20 12:37:25 -04:00
|
|
|
import { AppViewModel } from "./state/AppViewModel";
|
2025-10-16 13:57:08 -04:00
|
|
|
import { globalScope } from "./state/ObservableScope";
|
2022-02-01 15:11:06 -08:00
|
|
|
|
2025-03-10 09:59:27 +01:00
|
|
|
window.setLKLogLevel = setLKLogLevel;
|
|
|
|
|
|
2024-09-10 09:49:35 +02:00
|
|
|
initRageshake().catch((e) => {
|
|
|
|
|
logger.error("Failed to initialize rageshake", e);
|
|
|
|
|
});
|
2025-05-27 17:38:45 +02:00
|
|
|
setLKLogLevel("info");
|
2024-09-11 14:02:59 +01:00
|
|
|
setLKLogExtension((level, msg, context) => {
|
|
|
|
|
// we pass a synthetic logger name of "livekit" to the rageshake to make it easier to read
|
|
|
|
|
global.mx_rage_logger.log(level, "livekit", msg, context);
|
|
|
|
|
});
|
2021-10-06 11:38:26 -07:00
|
|
|
|
2023-09-25 18:04:34 +01:00
|
|
|
logger.info(`Element Call ${import.meta.env.VITE_APP_VERSION || "dev"}`);
|
2022-02-16 11:29:43 -08:00
|
|
|
|
2022-10-27 08:55:04 -04:00
|
|
|
const root = createRoot(document.getElementById("root")!);
|
|
|
|
|
|
2022-10-27 08:41:24 -04:00
|
|
|
let fatalError: Error | null = null;
|
|
|
|
|
|
2022-07-03 10:36:16 -04:00
|
|
|
if (!window.isSecureContext) {
|
2022-10-27 08:41:24 -04:00
|
|
|
fatalError = new Error(
|
2022-07-03 10:36:16 -04:00
|
|
|
"This app cannot run in an insecure context. To fix this, access the app " +
|
|
|
|
|
"via a local loopback address, or serve it over HTTPS.\n" +
|
2023-10-11 10:42:04 -04:00
|
|
|
"https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts",
|
2022-07-03 10:36:16 -04:00
|
|
|
);
|
2022-10-27 08:41:24 -04:00
|
|
|
} else if (!navigator.mediaDevices) {
|
|
|
|
|
fatalError = new Error("Your browser does not support WebRTC.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fatalError !== null) {
|
2022-10-27 08:55:04 -04:00
|
|
|
root.render(fatalError.message);
|
2022-10-27 08:41:24 -04:00
|
|
|
throw fatalError; // Stop the app early
|
2022-07-03 10:36:16 -04:00
|
|
|
}
|
|
|
|
|
|
2024-11-14 19:06:38 +01:00
|
|
|
Initializer.initBeforeReact()
|
|
|
|
|
.then(() => {
|
|
|
|
|
root.render(
|
2025-10-08 16:39:27 -04:00
|
|
|
<StrictMode>
|
2025-11-14 16:41:18 -05:00
|
|
|
<App vm={new AppViewModel(globalScope)} />
|
2025-10-08 16:39:27 -04:00
|
|
|
</StrictMode>,
|
2024-11-14 19:06:38 +01:00
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
logger.error("Failed to initialize app", e);
|
|
|
|
|
root.render(e.message);
|
|
|
|
|
});
|