Use extension popup instead of content script for mirroring sender

This commit is contained in:
hensm
2022-09-08 12:43:47 +01:00
parent bd5c1c8da8
commit b897cbb64b
12 changed files with 269 additions and 117 deletions

View File

@@ -3,6 +3,10 @@ import messaging, { Message } from "../messaging";
import type { ReceiverDevice } from "../types";
import pageMessenging from "./pageMessenging";
// Ensure extension-side is initialized first
void pageMessenging.extension;
import CastSDK from "./sdk";
export type CastPort = TypedMessagePort<Message>;
@@ -41,7 +45,10 @@ export function ensureInit(opts: EnsureInitOpts): Promise<CastPort> {
* will be the internal extension URL, whereas in a content
* script, it will be the content page URL.
*/
if (window.location.protocol === "moz-extension:") {
if (
window.location.protocol === "moz-extension:" &&
window.location.pathname === "_generated_background_page.html"
) {
const { default: castManager } = await import(
"../background/castManager"
);