Fix Olm import

This commit is contained in:
Robert Long 2022-04-27 13:38:16 -07:00
commit 3d54047f87
4 changed files with 9 additions and 20 deletions

View file

@ -9,6 +9,7 @@
}, },
"dependencies": { "dependencies": {
"@juggle/resize-observer": "^3.3.1", "@juggle/resize-observer": "^3.3.1",
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"@react-aria/button": "^3.3.4", "@react-aria/button": "^3.3.4",
"@react-aria/dialog": "^3.1.4", "@react-aria/dialog": "^3.1.4",
"@react-aria/focus": "^3.5.0", "@react-aria/focus": "^3.5.0",
@ -34,7 +35,6 @@
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#robertlong/group-call", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#robertlong/group-call",
"mermaid": "^8.13.8", "mermaid": "^8.13.8",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"olm": "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz",
"pako": "^2.0.4", "pako": "^2.0.4",
"postcss-preset-env": "^6.7.0", "postcss-preset-env": "^6.7.0",
"re-resizable": "^6.9.0", "re-resizable": "^6.9.0",

View file

@ -15,7 +15,6 @@
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/node_modules/olm/olm.js"></script>
</body> </body>
</html> </html>

View file

@ -4,8 +4,8 @@ import {
GroupCallType, GroupCallType,
} from "matrix-js-sdk/src/browser-index"; } from "matrix-js-sdk/src/browser-index";
import IndexedDBWorker from "./IndexedDBWorker?worker"; import IndexedDBWorker from "./IndexedDBWorker?worker";
import olmJsPath from "olm/olm.js?url"; import Olm from "@matrix-org/olm";
import olmWasmPath from "olm/olm.wasm?url"; import olmWasmPath from "@matrix-org/olm/olm.wasm?url";
export const defaultHomeserver = export const defaultHomeserver =
import.meta.env.VITE_DEFAULT_HOMESERVER || import.meta.env.VITE_DEFAULT_HOMESERVER ||
@ -28,19 +28,9 @@ function waitForSync(client) {
}); });
} }
function addScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.setAttribute("src", src);
script.onload = resolve;
script.onerror = reject;
document.body.appendChild(script);
});
}
export async function initClient(clientOptions) { export async function initClient(clientOptions) {
await addScript(olmJsPath); window.OLM_OPTIONS = {};
await window.Olm.init({ locateFile: () => olmWasmPath }); await Olm.init({ locateFile: () => olmWasmPath });
let indexedDB; let indexedDB;

View file

@ -1320,6 +1320,10 @@
resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.3.1.tgz#b50a781709c81e10701004214340f25475a171a0" resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.3.1.tgz#b50a781709c81e10701004214340f25475a171a0"
integrity sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw== integrity sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw==
"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz":
version "3.2.8"
resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz#8d53636d045e1776e2a2ec6613e57330dd9ce856"
"@mdx-js/mdx@^1.6.22": "@mdx-js/mdx@^1.6.22":
version "1.6.22" version "1.6.22"
resolved "https://registry.yarnpkg.com/@mdx-js/mdx/-/mdx-1.6.22.tgz#8a723157bf90e78f17dc0f27995398e6c731f1ba" resolved "https://registry.yarnpkg.com/@mdx-js/mdx/-/mdx-1.6.22.tgz#8a723157bf90e78f17dc0f27995398e6c731f1ba"
@ -8631,10 +8635,6 @@ objectorarray@^1.0.5:
resolved "https://registry.yarnpkg.com/objectorarray/-/objectorarray-1.0.5.tgz#2c05248bbefabd8f43ad13b41085951aac5e68a5" resolved "https://registry.yarnpkg.com/objectorarray/-/objectorarray-1.0.5.tgz#2c05248bbefabd8f43ad13b41085951aac5e68a5"
integrity sha512-eJJDYkhJFFbBBAxeh8xW+weHlkI28n2ZdQV/J/DNfWfSKlGEf2xcfAbZTv3riEXHAhL9SVOTs2pRmXiSTf78xg== integrity sha512-eJJDYkhJFFbBBAxeh8xW+weHlkI28n2ZdQV/J/DNfWfSKlGEf2xcfAbZTv3riEXHAhL9SVOTs2pRmXiSTf78xg==
"olm@https://packages.matrix.org/npm/olm/olm-3.2.1.tgz":
version "3.2.1"
resolved "https://packages.matrix.org/npm/olm/olm-3.2.1.tgz#d623d76f99c3518dde68be8c86618d68bc7b004a"
on-finished@~2.3.0: on-finished@~2.3.0:
version "2.3.0" version "2.3.0"
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"