-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Reload HTML files individually (#23)
- Loading branch information
Showing
9 changed files
with
104 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
import { logger } from '../utils/logger'; | ||
import { setupWebSocket } from '../utils/setupWebSocket'; | ||
|
||
if (__COMMAND__ === 'serve') { | ||
try { | ||
setupWebSocket((message) => { | ||
if (message.event === 'wxt:reload-page') { | ||
// We need to remove the initial slash from the path to compare correctly | ||
// "popup.html" === "/popup.html".substring(1) | ||
if (message.data === location.pathname.substring(1)) { | ||
location.reload(); | ||
} | ||
} | ||
}); | ||
} catch (err) { | ||
logger.error('Failed to setup web socket connection with dev server', err); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import definition from 'virtual:user-content-script'; | ||
import { logger } from '../utils/logger'; | ||
|
||
(async () => { | ||
try { | ||
await definition.main(); | ||
} catch (err) { | ||
console.error('The content script crashed on startup!\n\n', err); | ||
logger.error('The content script crashed on startup!', err); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters