2021-07-16 21:38:44 +00:00
|
|
|
/*
|
2022-06-01 15:48:17 +00:00
|
|
|
Copyright 2021-2022 New Vector Ltd
|
2021-07-16 21:38:44 +00: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 14:55:02 +00: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";
|
|
|
|
|
2021-07-16 21:38:44 +00:00
|
|
|
import React from "react";
|
|
|
|
import ReactDOM from "react-dom";
|
2021-10-06 18:38:26 +00:00
|
|
|
import { createBrowserHistory } from "history";
|
|
|
|
import * as Sentry from "@sentry/react";
|
|
|
|
import { Integrations } from "@sentry/tracing";
|
2022-10-10 13:19:10 +00:00
|
|
|
import i18n from "i18next";
|
|
|
|
import { initReactI18next } from "react-i18next";
|
|
|
|
import Backend from "i18next-http-backend";
|
|
|
|
import LanguageDetector from "i18next-browser-languagedetector";
|
2022-06-01 15:48:17 +00:00
|
|
|
|
|
|
|
import "./index.css";
|
|
|
|
import App from "./App";
|
2022-04-07 21:22:36 +00:00
|
|
|
import { init as initRageshake } from "./settings/rageshake";
|
2022-10-10 13:19:10 +00:00
|
|
|
import { getUrlParams } from "./UrlParams";
|
2022-02-01 23:11:06 +00:00
|
|
|
|
2022-04-07 21:22:36 +00:00
|
|
|
initRageshake();
|
2021-10-06 18:38:26 +00:00
|
|
|
|
2022-02-16 19:29:43 +00:00
|
|
|
console.info(`matrix-video-chat ${import.meta.env.VITE_APP_VERSION || "dev"}`);
|
|
|
|
|
2022-07-03 14:36:16 +00:00
|
|
|
if (!window.isSecureContext) {
|
|
|
|
throw new Error(
|
|
|
|
"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"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-18 01:52:31 +00:00
|
|
|
if (import.meta.env.VITE_CUSTOM_THEME) {
|
|
|
|
const style = document.documentElement.style;
|
2022-06-01 15:48:17 +00:00
|
|
|
style.setProperty("--accent", import.meta.env.VITE_THEME_ACCENT as string);
|
|
|
|
style.setProperty(
|
|
|
|
"--accent-20",
|
|
|
|
import.meta.env.VITE_THEME_ACCENT_20 as string
|
|
|
|
);
|
|
|
|
style.setProperty("--alert", import.meta.env.VITE_THEME_ALERT as string);
|
|
|
|
style.setProperty(
|
|
|
|
"--alert-20",
|
|
|
|
import.meta.env.VITE_THEME_ALERT_20 as string
|
|
|
|
);
|
|
|
|
style.setProperty("--links", import.meta.env.VITE_THEME_LINKS as string);
|
|
|
|
style.setProperty(
|
|
|
|
"--primary-content",
|
|
|
|
import.meta.env.VITE_THEME_PRIMARY_CONTENT as string
|
|
|
|
);
|
|
|
|
style.setProperty(
|
|
|
|
"--secondary-content",
|
|
|
|
import.meta.env.VITE_THEME_SECONDARY_CONTENT as string
|
|
|
|
);
|
|
|
|
style.setProperty(
|
|
|
|
"--tertiary-content",
|
|
|
|
import.meta.env.VITE_THEME_TERTIARY_CONTENT as string
|
|
|
|
);
|
|
|
|
style.setProperty(
|
2022-06-14 16:00:26 +00:00
|
|
|
"--tertiary-content-20",
|
|
|
|
import.meta.env.VITE_THEME_TERTIARY_CONTENT_20 as string
|
|
|
|
);
|
|
|
|
style.setProperty(
|
2022-06-01 15:48:17 +00:00
|
|
|
"--quaternary-content",
|
|
|
|
import.meta.env.VITE_THEME_QUATERNARY_CONTENT as string
|
|
|
|
);
|
2021-11-18 02:05:41 +00:00
|
|
|
style.setProperty(
|
2022-06-01 15:48:17 +00:00
|
|
|
"--quinary-content",
|
|
|
|
import.meta.env.VITE_THEME_QUINARY_CONTENT as string
|
2021-11-18 02:05:41 +00:00
|
|
|
);
|
2022-06-01 15:48:17 +00:00
|
|
|
style.setProperty("--system", import.meta.env.VITE_THEME_SYSTEM as string);
|
2021-11-18 02:05:41 +00:00
|
|
|
style.setProperty(
|
2022-06-01 15:48:17 +00:00
|
|
|
"--background",
|
|
|
|
import.meta.env.VITE_THEME_BACKGROUND as string
|
2021-11-18 02:05:41 +00:00
|
|
|
);
|
2022-08-02 11:33:09 +00:00
|
|
|
style.setProperty(
|
|
|
|
"--background-85",
|
|
|
|
import.meta.env.VITE_THEME_BACKGROUND_85 as string
|
|
|
|
);
|
2021-11-18 01:52:31 +00:00
|
|
|
}
|
|
|
|
|
2021-10-06 18:38:26 +00:00
|
|
|
const history = createBrowserHistory();
|
|
|
|
|
|
|
|
Sentry.init({
|
2022-06-01 15:48:17 +00:00
|
|
|
dsn: import.meta.env.VITE_SENTRY_DSN as string,
|
|
|
|
environment:
|
|
|
|
(import.meta.env.VITE_SENTRY_ENVIRONMENT as string) ?? "production",
|
2021-10-06 18:38:26 +00:00
|
|
|
integrations: [
|
|
|
|
new Integrations.BrowserTracing({
|
|
|
|
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
tracesSampleRate: 1.0,
|
|
|
|
});
|
2021-07-16 21:22:03 +00:00
|
|
|
|
2022-10-10 13:19:10 +00:00
|
|
|
const languageDetector = new LanguageDetector();
|
|
|
|
languageDetector.addDetector({
|
|
|
|
name: "urlFragment",
|
|
|
|
// Look for a language code in the URL's fragment
|
|
|
|
lookup: () => getUrlParams().lang ?? undefined,
|
|
|
|
});
|
|
|
|
|
|
|
|
i18n
|
|
|
|
.use(Backend)
|
|
|
|
.use(languageDetector)
|
|
|
|
.use(initReactI18next)
|
|
|
|
.init({
|
|
|
|
fallbackLng: "en-GB",
|
|
|
|
defaultNS: "app",
|
|
|
|
keySeparator: false,
|
|
|
|
nsSeparator: false,
|
|
|
|
pluralSeparator: "|",
|
|
|
|
contextSeparator: "|",
|
|
|
|
interpolation: {
|
|
|
|
escapeValue: false, // React has built-in XSS protections
|
|
|
|
},
|
|
|
|
detection: {
|
|
|
|
// No localStorage detectors or caching here, since we don't have any way
|
|
|
|
// of letting the user manually select a language
|
|
|
|
order: ["urlFragment", "navigator"],
|
|
|
|
caches: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-07-16 21:22:03 +00:00
|
|
|
ReactDOM.render(
|
|
|
|
<React.StrictMode>
|
2022-07-20 19:43:11 +00:00
|
|
|
<App history={history} />
|
2021-07-16 21:22:03 +00:00
|
|
|
</React.StrictMode>,
|
2021-07-16 21:38:44 +00:00
|
|
|
document.getElementById("root")
|
|
|
|
);
|