diff --git a/package.json b/package.json index 555096f7..d51775e2 100644 --- a/package.json +++ b/package.json @@ -64,8 +64,6 @@ "favico.js": "^0.3.10", "gemini-scrollbar": "github:matrix-org/gemini-scrollbar#91e1e566", "gfm.css": "^1.1.2", - "go-sqlite-js": "^0.1.0", - "go-http-js-libp2p": "^0.1.0", "highlight.js": "^9.13.1", "matrix-js-sdk": "3.0.0", "matrix-react-sdk": "1.7.6", @@ -76,6 +74,7 @@ "react": "^16.9.0", "react-dom": "^16.9.0", "sanitize-html": "^1.19.1", + "sql.js": "^1.2.1", "ua-parser-js": "^0.7.19", "url": "^0.11.0" }, diff --git a/src/vector/dendrite-sw.js b/src/vector/dendrite-sw.js index 18e303f7..6d7e5624 100644 --- a/src/vector/dendrite-sw.js +++ b/src/vector/dendrite-sw.js @@ -16,11 +16,11 @@ const bundle_path = self.location.href.replace("/dendrite_sw.js", "") -const version = "0.0.1" +const version = "0.0.3" self.importScripts(`${bundle_path}/wasm_exec.js`, `${bundle_path}/go_http_bridge.js`, - `${bundle_path}/sqlite_bridge.js`) + `${bundle_path}/sqlitejs.js`) function initDendrite() { console.log(`dendrite-sw.js: v${version} SW init`) @@ -41,7 +41,7 @@ function initDendrite() { } const go = new Go(); - return sqlite_bridge.init(config).then(()=>{ + return sqlitejs.init(config).then(()=>{ console.log(`dendrite-sw.js: v${version} starting dendrite.wasm...`) return WebAssembly.instantiateStreaming(fetch(`${bundle_path}/../../dendrite.wasm`), go.importObject) }).then((result) => { diff --git a/src/vector/dendrite.wasm b/src/vector/dendrite.wasm index acb42814..91394a89 100755 Binary files a/src/vector/dendrite.wasm and b/src/vector/dendrite.wasm differ diff --git a/src/vector/sqlitejs.js b/src/vector/sqlitejs.js new file mode 100644 index 00000000..4a8282e2 --- /dev/null +++ b/src/vector/sqlitejs.js @@ -0,0 +1,22 @@ +// Copyright 2020 The Matrix.org Foundation C.I.C. +// +// 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. + +import initSqlJs from 'sql.js' + +export function init(config) { + return initSqlJs(config).then(SQL => { + global._go_sqlite = SQL; + console.log("Loaded sqlite") + }) +} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 98c3bd4a..727d55e9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -35,9 +35,9 @@ module.exports = (env, argv) => { "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-sqlite-js/js/bridge.js", + "sqlitejs": "./src/vector/sqlitejs.js", "go_http_bridge": "./node_modules/go-http-js-libp2p/js/bridge.js", - "sql_wasm": "./node_modules/go-sqlite-js/node_modules/sql.js/dist/sql-wasm.wasm", + "sql_wasm": "./node_modules/sql.js/dist/sql-wasm.wasm", "dendrite_wasm": "./src/vector/dendrite.wasm", "wasm_exec": "./src/vector/wasm_exec.js", @@ -364,6 +364,7 @@ module.exports = (env, argv) => { // tedious in Riot since that can take a while. hot: false, inline: false, + writeToDisk: true, }, }; }; diff --git a/yarn.lock b/yarn.lock index 4ad9edec..6d7c0af4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11116,6 +11116,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= +sql.js@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/sql.js/-/sql.js-1.2.1.tgz#17881611a6aee06d25d0ea2f35b4609ba80f788b" + integrity sha512-i4jlJPfyUG7AAALlgNzZ8ZDMtJq+Q4InuZv/YZ2BjuNfglDKWL+cf65ncXZgoabTz/5Z000ZkbPPM23yzEJbRA== + srcset@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/srcset/-/srcset-1.0.0.tgz#a5669de12b42f3b1d5e83ed03c71046fc48f41ef"