@@ -14,12 +14,12 @@ import { hasAPI, parseEndpoint, getBackgroundPageType } from "./utils";
1414export const context : RuntimeContext = hasAPI ( "devtools" )
1515 ? "devtools"
1616 : hasAPI ( "tabs" )
17- ? getBackgroundPageType ( )
18- : hasAPI ( "extension" )
19- ? "content-script"
20- : typeof document !== "undefined"
21- ? "window"
22- : null ;
17+ ? getBackgroundPageType ( )
18+ : hasAPI ( "extension" )
19+ ? "content-script"
20+ : typeof document !== "undefined"
21+ ? "window"
22+ : null ;
2323
2424const runtimeId : string = uuid ( ) ;
2525export const openTransactions = new Map <
@@ -51,7 +51,7 @@ export const allowWindowMessaging = (nsps: string): void => {
5151 namespace = nsps ;
5252} ;
5353const handleInboundMessage = async (
54- message : IInternalMessage
54+ message : IInternalMessage ,
5555) : Promise < void > => {
5656 const { transactionId, messageID, messageType } = message ;
5757
@@ -63,7 +63,7 @@ const handleInboundMessage = async (
6363 const dehydratedErr = err as Record < string , string > ;
6464 const errCtr = self [ dehydratedErr . name ] as any ;
6565 const hydratedErr = new ( typeof errCtr === "function" ? errCtr : Error ) (
66- dehydratedErr . message
66+ dehydratedErr . message ,
6767 ) ;
6868 Object . keys ( dehydratedErr ) . forEach ( ( prop ) => {
6969 hydratedErr [ prop ] = dehydratedErr [ prop ] ;
@@ -93,7 +93,7 @@ const handleInboundMessage = async (
9393 } else {
9494 noHandlerFoundError = true ;
9595 throw new Error (
96- `[webext-bridge] No handler registered in '${ context } ' to accept messages with id '${ messageID } '`
96+ `[webext-bridge] No handler registered in '${ context } ' to accept messages with id '${ messageID } '` ,
9797 ) ;
9898 }
9999 } catch ( error ) {
@@ -128,7 +128,7 @@ const handleInboundMessage = async (
128128const initIntercoms = ( ) => {
129129 if ( context === null )
130130 throw new Error (
131- "Unable to detect runtime context i.e webext-bridge can't figure out what to do"
131+ "Unable to detect runtime context i.e webext-bridge can't figure out what to do" ,
132132 ) ;
133133
134134 if ( context === "window" || context === "content-script" )
@@ -245,7 +245,7 @@ const initIntercoms = () => {
245245
246246initIntercoms ( ) ;
247247export const routeMessage = (
248- message : IInternalMessage
248+ message : IInternalMessage ,
249249) : void | Promise < void > => {
250250 const { origin, destination } = message ;
251251 if ( message . hops . includes ( runtimeId ) ) return ;
@@ -275,7 +275,7 @@ export const routeMessage = (
275275 routeMessageThroughWindow ( window , message ) ;
276276 } else if (
277277 [ "devtools" , "content-script" , "popup" , "options" , "new-window" ] . includes (
278- context
278+ context ,
279279 )
280280 ) {
281281 if ( destination . context === "background" ) message . destination = null ;
@@ -320,7 +320,7 @@ export const routeMessage = (
320320
321321// eslint-disable-next-line @typescript-eslint/no-empty-function
322322const assertInternalMessage : ( x : unknown ) => asserts x = (
323- _msg : any
323+ _msg : any ,
324324) : asserts _msg is IInternalMessage => {
325325 // todo
326326} ;
@@ -373,7 +373,7 @@ const routeMessageThroughWindow = (win: Window, msg: IInternalMessage) => {
373373 context,
374374 payload : msg ,
375375 } ,
376- "*"
376+ "*" ,
377377 ) ;
378378 } ;
379379 win . postMessage (
@@ -383,7 +383,7 @@ const routeMessageThroughWindow = (win: Window, msg: IInternalMessage) => {
383383 context,
384384 } ,
385385 "*" ,
386- [ channel . port2 ]
386+ [ channel . port2 ] ,
387387 ) ;
388388} ;
389389
@@ -393,7 +393,7 @@ function ensureNamespaceSet() {
393393 'webext-bridge uses window.postMessage to talk with other "window"(s), for message routing and stuff,' +
394394 "which is global/conflicting operation in case there are other scripts using webext-bridge. " +
395395 "Call Bridge#setNamespace(nsps) to isolate your app. Example: setNamespace('com.facebook.react-devtools'). " +
396- "Make sure to use same namespace across all your scripts whereever window.postMessage is likely to be used`"
396+ "Make sure to use same namespace across all your scripts whereever window.postMessage is likely to be used`" ,
397397 ) ;
398398 }
399399}
0 commit comments