2021-07-17 05:38:44 +08:00
|
|
|
/*
|
2022-06-01 23:48:17 +08:00
|
|
|
Copyright 2021-2022 New Vector Ltd
|
2021-07-17 05:38:44 +08:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-06-01 22:55:02 +08: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.
|
|
|
|
import "matrix-js-sdk/src/browser-index";
|
|
|
|
|
2022-10-27 20:55:04 +08:00
|
|
|
import React, { StrictMode } from "react";
|
|
|
|
import { createRoot } from "react-dom/client";
|
2021-10-07 02:38:26 +08:00
|
|
|
import { createBrowserHistory } from "history";
|
2022-06-01 23:48:17 +08:00
|
|
|
|
|
|
|
import "./index.css";
|
|
|
|
import App from "./App";
|
2022-04-08 05:22:36 +08:00
|
|
|
import { init as initRageshake } from "./settings/rageshake";
|
2022-11-05 01:29:40 +08:00
|
|
|
import { Initializer } from "./initializer";
|
2022-02-02 07:11:06 +08:00
|
|
|
|
2022-04-08 05:22:36 +08:00
|
|
|
initRageshake();
|
2021-10-07 02:38:26 +08:00
|
|
|
|
2022-11-10 06:23:22 +08:00
|
|
|
console.info(`Element Call ${import.meta.env.VITE_APP_VERSION || "dev"}`);
|
2022-02-17 03:29:43 +08:00
|
|
|
|
2022-10-27 20:55:04 +08:00
|
|
|
const root = createRoot(document.getElementById("root")!);
|
|
|
|
|
2022-10-27 20:41:24 +08:00
|
|
|
let fatalError: Error | null = null;
|
|
|
|
|
2022-07-03 22:36:16 +08:00
|
|
|
if (!window.isSecureContext) {
|
2022-10-27 20:41:24 +08:00
|
|
|
fatalError = new Error(
|
2022-07-03 22:36:16 +08: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" +
|
|
|
|
"https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts"
|
|
|
|
);
|
2022-10-27 20:41:24 +08:00
|
|
|
} else if (!navigator.mediaDevices) {
|
|
|
|
fatalError = new Error("Your browser does not support WebRTC.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fatalError !== null) {
|
2022-10-27 20:55:04 +08:00
|
|
|
root.render(fatalError.message);
|
2022-10-27 20:41:24 +08:00
|
|
|
throw fatalError; // Stop the app early
|
2022-07-03 22:36:16 +08:00
|
|
|
}
|
|
|
|
|
2022-11-05 01:29:40 +08:00
|
|
|
Initializer.initBeforeReact();
|
2021-11-18 09:52:31 +08:00
|
|
|
|
2021-10-07 02:38:26 +08:00
|
|
|
const history = createBrowserHistory();
|
|
|
|
|
2022-10-27 20:55:04 +08:00
|
|
|
root.render(
|
|
|
|
<StrictMode>
|
2022-07-21 03:43:11 +08:00
|
|
|
<App history={history} />
|
2022-10-27 20:55:04 +08:00
|
|
|
</StrictMode>
|
2021-07-17 05:38:44 +08:00
|
|
|
);
|