Merge branch 'develop' into Libera.Chatbridge

This commit is contained in:
Richard van der Hoff 2024-07-08 12:43:55 +01:00 committed by GitHub
commit 700886c0e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 23 additions and 98 deletions

View file

@ -37,6 +37,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
# Workaround for yarn install timeouts, especially on Windows # Workaround for yarn install timeouts, especially on Windows
- run: yarn config set network-timeout 300000 - run: yarn config set network-timeout 300000

View file

@ -26,6 +26,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
- name: Install Dependencies - name: Install Dependencies
run: "./scripts/layered.sh" run: "./scripts/layered.sh"

View file

@ -21,6 +21,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
- name: Install Dependencies - name: Install Dependencies
run: "./scripts/layered.sh" run: "./scripts/layered.sh"
@ -43,6 +44,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
# Does not need branch matching as only analyses this layer # Does not need branch matching as only analyses this layer
- name: Install Deps - name: Install Deps
@ -60,6 +62,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
# Needs branch matching as it inherits .stylelintrc.js from matrix-react-sdk # Needs branch matching as it inherits .stylelintrc.js from matrix-react-sdk
- name: Install Dependencies - name: Install Dependencies
@ -77,6 +80,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
# Does not need branch matching as only analyses this layer # Does not need branch matching as only analyses this layer
- name: Install Deps - name: Install Deps
@ -94,6 +98,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
- name: Install Deps - name: Install Deps
run: "scripts/layered.sh" run: "scripts/layered.sh"

View file

@ -23,6 +23,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
- name: Install Dependencies - name: Install Dependencies
run: "./scripts/layered.sh" run: "./scripts/layered.sh"

View file

@ -13,6 +13,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
cache: "yarn" cache: "yarn"
node-version: "lts/*"
- name: Install Deps - name: Install Deps
run: "yarn install --frozen-lockfile" run: "yarn install --frozen-lockfile"

View file

@ -71,7 +71,6 @@
"@types/react": "17.0.80" "@types/react": "17.0.80"
}, },
"dependencies": { "dependencies": {
"@matrix-org/olm": "3.2.15",
"@matrix-org/react-sdk-module-api": "^2.3.0", "@matrix-org/react-sdk-module-api": "^2.3.0",
"jsrsasign": "^11.0.0", "jsrsasign": "^11.0.0",
"katex": "^0.16.0", "katex": "^0.16.0",

View file

@ -81,31 +81,6 @@
<img src="<%= require('matrix-react-sdk/res/img/format/quote.svg').default %>" aria-hidden alt="" width="25" height="22" style="visibility: hidden; position: absolute; top: 0px; left: 0px;"/> <img src="<%= require('matrix-react-sdk/res/img/format/quote.svg').default %>" aria-hidden alt="" width="25" height="22" style="visibility: hidden; position: absolute; top: 0px; left: 0px;"/>
<img src="<%= require('matrix-react-sdk/res/img/format/strikethrough.svg').default %>" aria-hidden alt="" width="25" height="22" style="visibility: hidden; position: absolute; top: 0px; left: 0px;"/> <img src="<%= require('matrix-react-sdk/res/img/format/strikethrough.svg').default %>" aria-hidden alt="" width="25" height="22" style="visibility: hidden; position: absolute; top: 0px; left: 0px;"/>
<audio id="messageAudio">
<source src="media/message.ogg" type="audio/ogg" />
<source src="media/message.mp3" type="audio/mpeg" />
</audio>
<audio id="ringAudio" loop>
<source src="media/ring.ogg" type="audio/ogg" />
<source src="media/ring.mp3" type="audio/mpeg" />
</audio>
<audio id="ringbackAudio" loop>
<source src="media/ringback.ogg" type="audio/ogg" />
<source src="media/ringback.mp3" type="audio/mpeg" />
</audio>
<audio id="callendAudio">
<source src="media/callend.ogg" type="audio/ogg" />
<source src="media/callend.mp3" type="audio/mpeg" />
</audio>
<audio id="busyAudio">
<source src="media/busy.ogg" type="audio/ogg" />
<source src="media/busy.mp3" type="audio/mpeg" />
</audio>
<audio id="errorAudio">
<source src="media/error.ogg" type="audio/ogg" />
<source src="media/error.mp3" type="audio/mpeg" />
</audio>
<audio id="remoteAudio"></audio>
<!-- let CSS themes pass constants to the app --> <!-- let CSS themes pass constants to the app -->
<div id="mx_theme_accentColor"></div><div id="mx_theme_secondaryAccentColor"></div><div id="mx_theme_tertiaryAccentColor"></div> <div id="mx_theme_accentColor"></div><div id="mx_theme_secondaryAccentColor"></div><div id="mx_theme_tertiaryAccentColor"></div>

View file

@ -56,8 +56,8 @@ function checkBrowserFeatures(): boolean {
return false; return false;
} }
// Custom checks atop Modernizr because it doesn't have ES2018/ES2019 checks // Custom checks atop Modernizr because it doesn't have checks in it for
// in it for some features we depend on. // some features we depend on.
// Modernizr requires rules to be lowercase with no punctuation. // Modernizr requires rules to be lowercase with no punctuation.
// ES2018: http://262.ecma-international.org/9.0/#sec-promise.prototype.finally // ES2018: http://262.ecma-international.org/9.0/#sec-promise.prototype.finally
window.Modernizr.addTest("promiseprototypefinally", () => typeof window.Promise?.prototype?.finally === "function"); window.Modernizr.addTest("promiseprototypefinally", () => typeof window.Promise?.prototype?.finally === "function");
@ -70,6 +70,13 @@ function checkBrowserFeatures(): boolean {
); );
// ES2019: http://262.ecma-international.org/10.0/#sec-object.fromentries // ES2019: http://262.ecma-international.org/10.0/#sec-object.fromentries
window.Modernizr.addTest("objectfromentries", () => typeof window.Object?.fromEntries === "function"); window.Modernizr.addTest("objectfromentries", () => typeof window.Object?.fromEntries === "function");
// ES2024: https://tc39.es/ecma262/2024/#sec-get-regexp.prototype.unicodesets
window.Modernizr.addTest(
"regexpunicodesets",
() => window.RegExp?.prototype && "unicodeSets" in window.RegExp.prototype,
);
// ES2024: https://402.ecma-international.org/9.0/#sec-intl.segmenter
window.Modernizr.addTest("intlsegmenter", () => typeof window.Intl?.Segmenter === "function");
const featureList = Object.keys(window.Modernizr) as Array<keyof ModernizrStatic>; const featureList = Object.keys(window.Modernizr) as Array<keyof ModernizrStatic>;
@ -105,7 +112,6 @@ async function start(): Promise<void> {
rageshakePromise, rageshakePromise,
setupLogStorage, setupLogStorage,
preparePlatform, preparePlatform,
loadOlm,
loadConfig, loadConfig,
loadLanguage, loadLanguage,
loadTheme, loadTheme,
@ -143,7 +149,6 @@ async function start(): Promise<void> {
} }
} }
const loadOlmPromise = loadOlm();
// set the platform for react sdk // set the platform for react sdk
preparePlatform(); preparePlatform();
// load config requires the platform to be ready // load config requires the platform to be ready
@ -210,7 +215,6 @@ async function start(): Promise<void> {
// app load critical path starts here // app load critical path starts here
// assert things started successfully // assert things started successfully
// ################################## // ##################################
await loadOlmPromise;
await loadModulesPromise; await loadModulesPromise;
await loadThemePromise; await loadThemePromise;
await loadLanguagePromise; await loadLanguagePromise;

View file

@ -17,10 +17,6 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import olmWasmPath from "@matrix-org/olm/olm.wasm";
import Olm from "@matrix-org/olm";
import * as ReactDOM from "react-dom"; import * as ReactDOM from "react-dom";
import * as React from "react"; import * as React from "react";
import * as languageHandler from "matrix-react-sdk/src/languageHandler"; import * as languageHandler from "matrix-react-sdk/src/languageHandler";
@ -76,48 +72,6 @@ export async function loadConfig(): Promise<void> {
} }
} }
export function loadOlm(): Promise<void> {
/* Load Olm. We try the WebAssembly version first, and then the legacy,
* asm.js version if that fails. For this reason we need to wait for this
* to finish before continuing to load the rest of the app. In future
* we could somehow pass a promise down to react-sdk and have it wait on
* that so olm can be loading in parallel with the rest of the app.
*
* We also need to tell the Olm js to look for its wasm file at the same
* level as index.html. It really should be in the same place as the js,
* ie. in the bundle directory, but as far as I can tell this is
* completely impossible with webpack. We do, however, use a hashed
* filename to avoid caching issues.
*/
return Olm.init({
locateFile: () => olmWasmPath,
})
.then(() => {
logger.log("Using WebAssembly Olm");
})
.catch((wasmLoadError) => {
logger.log("Failed to load Olm: trying legacy version", wasmLoadError);
return new Promise((resolve, reject) => {
const s = document.createElement("script");
s.src = "olm_legacy.js"; // XXX: This should be cache-busted too
s.onload = resolve;
s.onerror = reject;
document.body.appendChild(s);
})
.then(() => {
// Init window.Olm, ie. the one just loaded by the script tag,
// not 'Olm' which is still the failed wasm version.
return window.Olm.init();
})
.then(() => {
logger.log("Using legacy Olm");
})
.catch((legacyLoadError) => {
logger.log("Both WebAssembly and asm.js Olm failed!", legacyLoadError);
});
});
}
export async function loadLanguage(): Promise<void> { export async function loadLanguage(): Promise<void> {
const prefLang = SettingsStore.getValue("language", null, /*excludeDefault=*/ true); const prefLang = SettingsStore.getValue("language", null, /*excludeDefault=*/ true);
let langs: string[] = []; let langs: string[] = [];

View file

@ -274,10 +274,6 @@ module.exports = (env, argv) => {
// there is no need for webpack to parse them - they can just be // there is no need for webpack to parse them - they can just be
// included as-is. // included as-is.
/highlight\.js[\\/]lib[\\/]languages/, /highlight\.js[\\/]lib[\\/]languages/,
// olm takes ages for webpack to process, and it's already heavily
// optimised, so there is little to gain by us uglifying it.
/olm[\\/](javascript[\\/])?olm\.js$/,
], ],
rules: [ rules: [
useHMR && { useHMR && {
@ -443,20 +439,6 @@ module.exports = (env, argv) => {
}, },
], ],
}, },
{
// the olm library wants to load its own wasm, rather than have webpack do it.
// We therefore use the `file-loader` to tell webpack to dump the contents to
// a separate file and return the name, and override the default `type` for `.wasm` files
// (which is `webassembly/experimental` under webpack 4) to stop webpack trying to interpret
// the filename as webassembly. (see also https://github.com/webpack/webpack/issues/6725)
test: /olm\.wasm$/,
loader: "file-loader",
type: "javascript/auto",
options: {
name: "[name].[hash:7].[ext]",
outputPath: ".",
},
},
{ {
// Fix up the name of the opus-recorder worker (react-sdk dependency). // Fix up the name of the opus-recorder worker (react-sdk dependency).
// We more or less just want it to be clear it's for opus and not something else. // We more or less just want it to be clear it's for opus and not something else.
@ -498,8 +480,11 @@ module.exports = (env, argv) => {
}, },
}, },
{ {
// Same deal as olm.wasm: the decoderWorker wants to load the wasm artifact // The decoderWorker wants to load its own wasm, rather than have webpack do it.
// itself. // We therefore use the `file-loader` to tell webpack to dump the contents to
// a separate file and return the name, and override the default `type` for `.wasm` files
// (which is `webassembly/experimental` under webpack 4) to stop webpack trying to interpret
// the filename as webassembly. (see also https://github.com/webpack/webpack/issues/6725)
test: /decoderWorker\.min\.wasm$/, test: /decoderWorker\.min\.wasm$/,
loader: "file-loader", loader: "file-loader",
type: "javascript/auto", type: "javascript/auto",
@ -750,7 +735,6 @@ module.exports = (env, argv) => {
{ from: "vector-icons/**", context: path.resolve(__dirname, "res") }, { from: "vector-icons/**", context: path.resolve(__dirname, "res") },
{ from: "decoder-ring/**", context: path.resolve(__dirname, "res") }, { from: "decoder-ring/**", context: path.resolve(__dirname, "res") },
{ from: "media/**", context: path.resolve(__dirname, "node_modules/matrix-react-sdk/res/") }, { from: "media/**", context: path.resolve(__dirname, "node_modules/matrix-react-sdk/res/") },
"node_modules/@matrix-org/olm/olm_legacy.js",
{ from: "config.json", noErrorOnMissing: true }, { from: "config.json", noErrorOnMissing: true },
"contribute.json", "contribute.json",
], ],