Skip to content

Commit

Permalink
fix: inject lag on watch
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Jul 23, 2024
1 parent 312d76f commit 3fae0d4
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/extension/src/scripts/chrome/hot-reload.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import browser from "webextension-polyfill";
import { keccak256 } from "ethereum-cryptography/keccak";
import { bufferToHex } from "@enkryptcom/utils";
const filesToMonitor = {
content: {
path: "scripts/contentscript.js",
hash: "",
length: 0,
},
inject: {
path: "scripts/inject.js",
hash: "",
length: 0,
},
background: {
path: "scripts/background.js",
hash: "",
length: 0,
},
action: {
path: "action.html",
hash: "",
length: 0,
},
index: {
path: "index.html",
hash: "",
length: 0,
},
manifest: {
path: "manifest.json",
hash: "",
length: 0,
},
};
const checkFilesChanged = async () => {
Expand All @@ -34,10 +32,10 @@ const checkFilesChanged = async () => {
await fetch(exturl)
.then((res) => res.text())
.then((content) => {
const hash = bufferToHex(keccak256(Buffer.from(content)));
if (value.hash !== hash) {
const length = content.length;
if (value.length !== length) {
filesChanged = true;
value.hash = hash;
value.length = length;
}
});
}
Expand Down

1 comment on commit 3fae0d4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.