spot: update version, unload offscreen when background is reloaded

This commit is contained in:
nick-delirium 2024-09-10 16:21:07 +02:00
parent a89eeca148
commit d3b6511e55
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
3 changed files with 12 additions and 11 deletions

View file

@ -3,7 +3,7 @@ import { WebRequest } from "webextension-polyfill";
export default defineBackground(() => {
const CHECK_INT = 60 * 1000;
const PING_INT = 30 * 1000;
const VER = '1.0.0';
const VER = '1.0.3';
const messages = {
popup: {
@ -1126,15 +1126,16 @@ export default defineBackground(() => {
(c: { contextType: string }) => c.contextType === "OFFSCREEN_DOCUMENT",
);
if (!offscreenDocument) {
await browser.offscreen.createDocument({
url: "offscreen.html",
reasons: ["DISPLAY_MEDIA", "USER_MEDIA", "BLOBS"],
justification: "Recording from chrome.tabCapture API",
});
} else {
recording = offscreenDocument.documentUrl.endsWith("#recording");
if (offscreenDocument) {
await browser.offscreen.closeDocument()
}
await browser.offscreen.createDocument({
url: "offscreen.html",
reasons: ["DISPLAY_MEDIA", "USER_MEDIA", "BLOBS"],
justification: "Recording from chrome.tabCapture API",
});
return recording;
}
async function sendToActiveTab(message: {

View file

@ -112,6 +112,7 @@ class ScreenRecorder {
mimeType: this.settings.mimeType,
audioBitsPerSecond: this.settings.audioBitsPerSecond,
videoBitsPerSecond: this.settings.videoBitsPerSecond,
videoKeyFrameIntervalDuration: 1000,
});
this.mRecorder.ondataavailable = this._handleDataAvailable;
@ -296,7 +297,6 @@ class ScreenRecorder {
let recorder = new ScreenRecorder();
recorder.init(getRecordingSettings("720p"));
browser.runtime.onMessage.addListener((message, _, respond) => {
if (message.target === "offscreen") {
if (message.type === "offscr:start-recording") {

View file

@ -2,7 +2,7 @@
"name": "wxt-starter",
"description": "manifest.json description",
"private": true,
"version": "1.0.2",
"version": "1.0.3",
"type": "module",
"scripts": {
"dev": "wxt",