Skip to content

Commit 4e327b7

Browse files
fix(extension): use string literal for ContextType, define __TARGET__ in Chrome build, guard tabCapture
1 parent 186ecba commit 4e327b7

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎apps/chrome-extension/src/background/recorder-host.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const getRecorderContexts = async () => {
1717
return new Promise<Array<{ documentUrl?: string }>>((resolve) => {
1818
chrome.runtime.getContexts(
1919
{
20-
contextTypes: [chrome.runtime.ContextType.OFFSCREEN_DOCUMENT],
20+
contextTypes: ["OFFSCREEN_DOCUMENT" as chrome.runtime.ContextType],
2121
documentUrls: [recorderUrl],
2222
},
2323
(contexts) => resolve(contexts),

‎apps/chrome-extension/src/background/service-worker.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { capabilities } from "../platform/capabilities";
12
import { EXTENSION_PROTOCOL } from "../platform/extension-protocol";
23
import {
34
ApiRequestError,
@@ -250,6 +251,10 @@ const sendOffscreen = async (
250251

251252
const getTabStreamId = (tabId: number) =>
252253
new Promise<string>((resolve, reject) => {
254+
if (!capabilities.supportsTabCapture) {
255+
reject(new Error("Tab capture is not supported on this browser"));
256+
return;
257+
}
253258
chrome.tabCapture.getMediaStreamId({ targetTabId: tabId }, (streamId) => {
254259
if (chrome.runtime.lastError) {
255260
reject(

‎apps/chrome-extension/vite.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { defineConfig } from "vite";
44

55
export default defineConfig({
66
plugins: [react()],
7+
define: {
8+
__TARGET__: JSON.stringify("chrome"),
9+
},
710
build: {
811
emptyOutDir: false,
912
outDir: "dist",

0 commit comments

Comments
 (0)