Remove go-sqlite-js and just use sql.js directly

This commit is contained in:
Kegan Dougal 2020-03-26 10:35:40 +00:00
parent d80285d971
commit 6f43a14c43
6 changed files with 34 additions and 7 deletions

View File

@ -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"
},

View File

@ -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) => {

Binary file not shown.

22
src/vector/sqlitejs.js Normal file
View File

@ -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")
})
}

View File

@ -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,
},
};
};

View File

@ -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"