Skip to content

Commit

Permalink
added another version to try keep using wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
eric2788 committed Jan 8, 2024
1 parent 1526962 commit 528daec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
Binary file added assets/brotli-dec.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@plasmohq/storage": "^1.9.0",
"@react-hooks-library/core": "^0.5.1",
"autoprefixer": "^10.4.16",
"brotli": "^1.3.3",
"brotli-dec-wasm": "^2.1.0",
"dexie": "^3.2.4",
"dexie-react-hooks": "^1.1.7",
"hash-wasm": "^4.11.0",
Expand All @@ -41,7 +41,6 @@
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "4.1.1",
"@types/brotli": "^1.3.4",
"@types/chrome": "^0.0.254",
"@types/glob": "^8.1.0",
"@types/node": "20.9.0",
Expand Down
14 changes: 13 additions & 1 deletion src/adapters/websocket-hook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { injectFuncAsListener } from "~utils/event"
import { sendBLiveMessage } from "~utils/messaging"
import decompress from "brotli/decompress"
import wasmUrl from "raw:~assets/brotli-dec.wasm"
import init from 'brotli-dec-wasm/pkg/index'

var decompress = null

const loadWasm = init(wasmUrl).then(output => {
decompress = output.decompress
console.info('wasm loaded.')
})



// @名称 bliveproxy
// @版本 0.4
Expand Down Expand Up @@ -170,6 +180,8 @@ async function hook() {
return
}

await loadWasm

console.log('injecting websocket..')
abortController = new AbortController()
return new Promise((res, rej) => {
Expand Down
19 changes: 5 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2207,13 +2207,6 @@
resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==

"@types/brotli@^1.3.4":
version "1.3.4"
resolved "https://registry.yarnpkg.com/@types/brotli/-/brotli-1.3.4.tgz#3eefc5493218a99141771f351142dd640efde5d8"
integrity sha512-cKYjgaS2DMdCKF7R0F5cgx1nfBYObN2ihIuPGQ4/dlIY6RpV7OWNwe9L8V4tTVKL2eZqOkNM9FM/rgTvLf4oXw==
dependencies:
"@types/node" "*"

"@types/chrome@^0.0.254":
version "0.0.254"
resolved "https://registry.yarnpkg.com/@types/chrome/-/chrome-0.0.254.tgz#f1caadc129134f71bfaa29f9f0295939048da173"
Expand Down Expand Up @@ -2539,7 +2532,7 @@ base-x@^3.0.8:
dependencies:
safe-buffer "^5.0.1"

base64-js@^1.1.2, base64-js@^1.3.1:
base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
Expand Down Expand Up @@ -2583,12 +2576,10 @@ braces@^3.0.2, braces@~3.0.2:
dependencies:
fill-range "^7.0.1"

brotli@^1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/brotli/-/brotli-1.3.3.tgz#7365d8cc00f12cf765d2b2c898716bcf4b604d48"
integrity sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==
dependencies:
base64-js "^1.1.2"
brotli-dec-wasm@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/brotli-dec-wasm/-/brotli-dec-wasm-2.1.0.tgz#d0a7f4887ec12123e689e93a30f2c5b3cde98aa7"
integrity sha512-ibXultYwKMk+8Zy2utgLuIcoTjwkrV1I1QkNToLndgVJq73JuUwJiUix2A28L6X9dMCJByyylzgcqW7KoRHGEQ==

[email protected]:
version "4.21.10"
Expand Down

0 comments on commit 528daec

Please sign in to comment.