From 0620da4351eff342fdaaf3f3e43554ca36fa2cf5 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 23 Mar 2020 12:07:26 +0000 Subject: [PATCH 1/4] Add webpack stats which will be used by CI and stored to artifacts Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .gitignore | 1 + package.json | 2 ++ webpack.config.js | 3 +++ 3 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index c1a042341a..4dd3a26213 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ electron/pub /config.local*.json /src/component-index.js /.tmp +/webpack-stats.json diff --git a/package.json b/package.json index c4f4942cab..50f6808e6d 100644 --- a/package.json +++ b/package.json @@ -37,11 +37,13 @@ "reskindex:watch-react": "node scripts/yarn-sub.js matrix-react-sdk reskindex:watch", "clean": "rimraf lib webapp electron_app/dist", "build": "yarn clean && yarn build:genfiles && yarn build:compile && yarn build:types && yarn build:bundle", + "build-stats": "yarn clean && yarn build:genfiles && yarn build:compile && yarn build:types && yarn build:bundle-stats", "build:res": "node scripts/copy-res.js", "build:genfiles": "yarn reskindex && yarn build:res", "build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js", "build:compile": "babel -d lib --verbose --extensions \".ts,.js,.tsx\" src", "build:bundle": "cross-env NODE_ENV=production webpack -p --progress --bail --mode production", + "build:bundle-stats": "cross-env NODE_ENV=production webpack -p --progress --bail --mode production --json > webpack-stats.json", "build:electron": "yarn build && yarn install:electron && electron-builder -wml --ia32 --x64", "build:electron:linux": "yarn build && electron-builder -l --x64", "build:electron:macos": "yarn build && electron-builder -m --x64", diff --git a/webpack.config.js b/webpack.config.js index f54655b5bd..d62b6f0755 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -93,6 +93,9 @@ module.exports = (env, argv) => { // same goes for js-sdk - we don't need two copies. "matrix-js-sdk": path.resolve(__dirname, 'node_modules/matrix-js-sdk'), + // and prop-types and sanitize-html + "prop-types": path.resolve(__dirname, 'node_modules/prop-types'), + "sanitize-html": path.resolve(__dirname, 'node_modules/sanitize-html'), // Define a variable so the i18n stuff can load "$webapp": path.resolve(__dirname, 'webapp'), From 350a52b44e99b82077feb8031e28e93b51f7d30f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 23 Mar 2020 10:38:10 -0600 Subject: [PATCH 2/4] Remove useless app preloading from Jitsi widget wrapper We should always have conference information, and if we don't then the widget is invalid. --- src/vector/jitsi/index.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/vector/jitsi/index.ts b/src/vector/jitsi/index.ts index 5ca99dbd3f..8e90f71442 100644 --- a/src/vector/jitsi/index.ts +++ b/src/vector/jitsi/index.ts @@ -20,7 +20,6 @@ require("./index.scss"); import * as qs from 'querystring'; import { Capability, WidgetApi } from "matrix-react-sdk/src/widgets/WidgetApi"; import SdkConfig from "matrix-react-sdk/src/SdkConfig"; -import { loadConfig, preparePlatform } from "../initial-load"; // Dev note: we use raw JS without many dependencies to reduce bundle size. // We do not need all of React to render a Jitsi conference. @@ -61,12 +60,8 @@ let widgetApi: WidgetApi; await widgetApi.setAlwaysOnScreen(false); }); - // Bootstrap ourselves for loading the script and such - preparePlatform(); - await loadConfig(); - // Populate the Jitsi params now - jitsiDomain = qsParam('conferenceDomain', true) || SdkConfig.get()['jitsi']['preferredDomain']; + jitsiDomain = qsParam('conferenceDomain', false); conferenceId = qsParam('conferenceId'); displayName = qsParam('displayName', true); avatarUrl = qsParam('avatarUrl', true); // http not mxc From 4087ba0c5c630eb5c5119e3ea2c79de07d10ef18 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 24 Mar 2020 09:14:59 -0600 Subject: [PATCH 3/4] Revert "Remove useless app preloading from Jitsi widget wrapper" --- src/vector/jitsi/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vector/jitsi/index.ts b/src/vector/jitsi/index.ts index 8e90f71442..5ca99dbd3f 100644 --- a/src/vector/jitsi/index.ts +++ b/src/vector/jitsi/index.ts @@ -20,6 +20,7 @@ require("./index.scss"); import * as qs from 'querystring'; import { Capability, WidgetApi } from "matrix-react-sdk/src/widgets/WidgetApi"; import SdkConfig from "matrix-react-sdk/src/SdkConfig"; +import { loadConfig, preparePlatform } from "../initial-load"; // Dev note: we use raw JS without many dependencies to reduce bundle size. // We do not need all of React to render a Jitsi conference. @@ -60,8 +61,12 @@ let widgetApi: WidgetApi; await widgetApi.setAlwaysOnScreen(false); }); + // Bootstrap ourselves for loading the script and such + preparePlatform(); + await loadConfig(); + // Populate the Jitsi params now - jitsiDomain = qsParam('conferenceDomain', false); + jitsiDomain = qsParam('conferenceDomain', true) || SdkConfig.get()['jitsi']['preferredDomain']; conferenceId = qsParam('conferenceId'); displayName = qsParam('displayName', true); avatarUrl = qsParam('avatarUrl', true); // http not mxc From bde5679d11a9f62a11c891328291af4cfcfbb6d2 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 24 Mar 2020 09:54:15 -0600 Subject: [PATCH 4/4] Ask for Riot config over postMessage for the Jitsi widget Fixes https://github.com/vector-im/riot-web/issues/12839 by not using the app load order that doesn't detect the right platform anyways. --- src/vector/jitsi/index.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/vector/jitsi/index.ts b/src/vector/jitsi/index.ts index 5ca99dbd3f..75b017a269 100644 --- a/src/vector/jitsi/index.ts +++ b/src/vector/jitsi/index.ts @@ -19,8 +19,6 @@ require("./index.scss"); import * as qs from 'querystring'; import { Capability, WidgetApi } from "matrix-react-sdk/src/widgets/WidgetApi"; -import SdkConfig from "matrix-react-sdk/src/SdkConfig"; -import { loadConfig, preparePlatform } from "../initial-load"; // Dev note: we use raw JS without many dependencies to reduce bundle size. // We do not need all of React to render a Jitsi conference. @@ -54,28 +52,26 @@ let widgetApi: WidgetApi; // Set this up as early as possible because Riot will be hitting it almost immediately. widgetApi = new WidgetApi(qsParam('parentUrl'), qsParam('widgetId'), [ Capability.AlwaysOnScreen, + Capability.GetRiotWebConfig, ]); - - widgetApi.waitReady().then(async () => { - // Start off by ensuring we're not stuck on screen - await widgetApi.setAlwaysOnScreen(false); - }); - - // Bootstrap ourselves for loading the script and such - preparePlatform(); - await loadConfig(); + widgetApi.expectingExplicitReady = true; // Populate the Jitsi params now - jitsiDomain = qsParam('conferenceDomain', true) || SdkConfig.get()['jitsi']['preferredDomain']; + jitsiDomain = qsParam('conferenceDomain'); conferenceId = qsParam('conferenceId'); displayName = qsParam('displayName', true); avatarUrl = qsParam('avatarUrl', true); // http not mxc userId = qsParam('userId'); + await widgetApi.waitReady(); + await widgetApi.setAlwaysOnScreen(false); // start off as detachable from the screen + + const riotConfig = await widgetApi.getRiotConfig(); + // Get the Jitsi Meet API loaded up as fast as possible, but ensure that the widget's postMessage // receiver (WidgetApi) is up and running first. const scriptTag = document.createElement("script"); - scriptTag.src = SdkConfig.get()['jitsi']['externalApiUrl']; + scriptTag.src = riotConfig['jitsi']['externalApiUrl']; document.body.appendChild(scriptTag); // TODO: register widgetApi listeners for PTT controls (https://github.com/vector-im/riot-web/issues/12795)