Skip to content

Commit 74443fd

Browse files
committed
fixup! feat(web-extension): detect bg script when on firefox
1 parent 3a260ee commit 74443fd

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

packages/web-extension/src/messaging/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { ChannelName, ConsumeRemoteApiOptions, ExposeApiProps, MessengerDependen
33
import { FinalizationRegistryDestructor, isBackgroundProcess } from './util';
44
import { consumeMessengerRemoteApi, exposeMessengerApi } from './remoteApi';
55
import { createNonBackgroundMessenger } from './NonBackgroundMessenger';
6-
import { runtime } from 'webextension-polyfill';
76

87
export * from './BackgroundMessenger';
98
export * from './NonBackgroundMessenger';
@@ -16,7 +15,7 @@ export * from './errors';
1615

1716
export type BaseChannel = { baseChannel: ChannelName };
1817

19-
const isInBackgroundProcess = isBackgroundProcess(runtime);
18+
const isInBackgroundProcess = isBackgroundProcess();
2019

2120
const getBackgroundMessenger = (() => {
2221
let backgroundMessenger: BackgroundMessenger | null = null;

packages/web-extension/src/messaging/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export interface MessengerPort {
6060
export interface MinimalRuntime {
6161
connect(connectInfo: Runtime.ConnectConnectInfoType): MessengerPort;
6262
onConnect: MinimalEvent<(port: MessengerPort) => void>;
63-
getBackgroundPage?: unknown;
6463
lastError?: unknown;
6564
}
6665

packages/web-extension/src/messaging/util.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
FactoryCallMessage,
1010
InternalMsg,
1111
MethodRequest,
12-
MinimalRuntime,
1312
RequestMessage,
1413
ResponseMessage
1514
} from './types';
@@ -79,5 +78,5 @@ export class FinalizationRegistryDestructor implements Destructor {
7978
}
8079
}
8180

82-
export const isBackgroundProcess = (runtime: MinimalRuntime) =>
83-
typeof window === 'undefined' || typeof runtime.getBackgroundPage === 'function';
81+
export const isBackgroundProcess = () =>
82+
typeof window === 'undefined' || typeof (window as any).chrome?.runtime?.getBackgroundPage === 'function';

0 commit comments

Comments
 (0)