From 3fae0d4c36eb7b8c2a0e8a30de8da1f93555d474 Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:25:27 -0700 Subject: [PATCH] fix: inject lag on watch --- .../src/scripts/chrome/hot-reload.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/extension/src/scripts/chrome/hot-reload.ts b/packages/extension/src/scripts/chrome/hot-reload.ts index 43fd1feb..fb027a66 100644 --- a/packages/extension/src/scripts/chrome/hot-reload.ts +++ b/packages/extension/src/scripts/chrome/hot-reload.ts @@ -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 () => { @@ -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; } }); }