forked from matrix/element-web
make it work
This commit is contained in:
parent
8a41f956f6
commit
349d3e3d47
|
@ -170,6 +170,20 @@ export async function loadApp() {
|
|||
throw new Error("Missing indexeddb worker script!");
|
||||
}
|
||||
MatrixClientPeg.setIndexedDbWorkerScript(window.vector_indexeddb_worker_script);
|
||||
|
||||
// load dendrite, if available
|
||||
if (window.vector_dendrite_worker_script && 'serviceWorker' in navigator) {
|
||||
window.addEventListener('load', ()=>{
|
||||
navigator.serviceWorker.register(window.vector_dendrite_worker_script).then(function(registration) {
|
||||
// Registration was successful
|
||||
console.log('ServiceWorker registration successful with scope: ', registration.scope)
|
||||
}, (err)=>{
|
||||
// registration failed :(
|
||||
console.log('ServiceWorker registration failed: ', err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
CallHandler.setConferenceHandler(VectorConferenceHandler);
|
||||
|
||||
window.addEventListener('hashchange', onHashChange);
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
self.importScripts("wasm_exec.js", "bundles/go_http_bridge.js", "bundles/sqlite_bridge.js")
|
||||
const bundle_path = self.location.href.replace("/dendrite_sw.js", "")
|
||||
|
||||
self.importScripts(`${bundle_path}/wasm_exec.js`,
|
||||
`${bundle_path}/go_http_bridge.js`,
|
||||
`${bundle_path}/sqlite_bridge.js`)
|
||||
|
||||
self.addEventListener('install', function(event) {
|
||||
console.log("installing SW")
|
||||
|
@ -24,13 +28,13 @@ self.addEventListener('activate', function(event) {
|
|||
console.log("SW activated")
|
||||
|
||||
const config = {
|
||||
locateFile: filename => 'sql_wasm.wasm'
|
||||
locateFile: filename => `${bundle_path}/../../sql-wasm.wasm`
|
||||
}
|
||||
|
||||
event.waitUntil(
|
||||
sqlite_bridge.init(config).then(()=>{
|
||||
const go = new Go()
|
||||
WebAssembly.instantiateStreaming(fetch('dendrite.wasm'), go.importObject).then((result) => {
|
||||
WebAssembly.instantiateStreaming(fetch(`${bundle_path}/../../dendrite.wasm`), go.importObject).then((result) => {
|
||||
go.run(result.instance)
|
||||
});
|
||||
})
|
||||
|
|
|
@ -38,14 +38,15 @@
|
|||
<section id="matrixchat" style="height: 100%; overflow: auto;"></section>
|
||||
<noscript>Sorry, Riot requires JavaScript to be enabled.</noscript> <!-- TODO: Translate this? -->
|
||||
<script>
|
||||
window.vector_indexeddb_worker_script = '<%= htmlWebpackPlugin.files.chunks['indexeddb-worker'].entry %>';
|
||||
window.vector_dendrite_worker_script = '<%= htmlWebpackPlugin.files.chunks['dendrite-sw'].entry %>';
|
||||
window.vector_indexeddb_worker_script = '<%= htmlWebpackPlugin.files.chunks['indexeddb_worker'].entry %>';
|
||||
window.vector_dendrite_worker_script = '<%= htmlWebpackPlugin.files.chunks['dendrite_sw'].entry %>';
|
||||
</script>
|
||||
<script src="<%= htmlWebpackPlugin.files.chunks['bundle'].entry %>"></script>
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('sw.js');
|
||||
}
|
||||
// not needed if we have a dendrite SW
|
||||
// if ('serviceWorker' in navigator) {
|
||||
// navigator.serviceWorker.register('sw.js');
|
||||
// }
|
||||
</script>
|
||||
<img src="<%= require('matrix-react-sdk/res/img/warning.svg') %>" width="24" height="23" style="visibility: hidden; position: absolute; top: 0px; left: 0px;"/>
|
||||
<img src="<%= require('matrix-react-sdk/res/img/e2e/warning.svg') %>" width="24" height="23" style="visibility: hidden; position: absolute; top: 0px; left: 0px;"/>
|
||||
|
|
|
@ -27,7 +27,10 @@
|
|||
}
|
||||
|
||||
if (!global.fs && global.require) {
|
||||
global.fs = require("fs");
|
||||
// XXX: require("fs") apparently returns {} in vector-web for webpack reasons
|
||||
// so remove this so the polyfill below kicks in.
|
||||
//
|
||||
//global.fs = require("fs");
|
||||
}
|
||||
|
||||
if (!global.fs) {
|
||||
|
|
|
@ -32,13 +32,14 @@ module.exports = (env, argv) => {
|
|||
|
||||
entry: {
|
||||
"bundle": "./src/vector/index.js",
|
||||
"indexeddb-worker": "./src/vector/indexeddb-worker.js",
|
||||
"dendrite-sw": "./src/vector/dendrite-sw.js",
|
||||
"indexeddb_worker": "./src/vector/indexeddb-worker.js",
|
||||
"dendrite_sw": "./src/vector/dendrite-sw.js",
|
||||
"mobileguide": "./src/vector/mobile_guide/index.js",
|
||||
"sqlite_bridge": "./node_modules/go-sqlite3-js/js/bridge.js",
|
||||
"go_http_bridge": "./node_modules/go-http-js-libp2p/js/bridge.js",
|
||||
"sql_wasm": "./node_modules/go-sqlite3-js/node_modules/sql.js/dist/sql-wasm.wasm",
|
||||
"dendrite_wasm": "./src/vector/dendrite.wasm",
|
||||
"wasm_exec": "./src/vector/wasm_exec.js",
|
||||
|
||||
// CSS themes
|
||||
"theme-light": "./node_modules/matrix-react-sdk/res/themes/light/css/light.scss",
|
||||
|
@ -232,8 +233,8 @@ module.exports = (env, argv) => {
|
|||
loader: "file-loader",
|
||||
type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
|
||||
options: {
|
||||
// fixme - we should have a hash in this for cachebusting, but haven't figured
|
||||
// out a way yet to pass the resulting path from webpack into dendrite-sw
|
||||
// fixme: reintroduce [hash] once we can figure out how to pass it into the
|
||||
// dendrite service worker nicely
|
||||
name: '[name].[ext]',
|
||||
outputPath: '.',
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue