diff options
author | Eric Bailey <git@esb.lol> | 2023-12-12 13:19:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 11:19:27 -0800 |
commit | e7141a77d87a25162bf9c075310e097c84017920 (patch) | |
tree | f948783bf7aea9d78a03af65c38be0470ade9f8b /src | |
parent | c6ab6e8b8e81c1e2d72973a420cfea7aecc6e425 (diff) | |
download | voidsky-e7141a77d87a25162bf9c075310e097c84017920.tar.zst |
Stub broadcast channel for unspported contexts (#2175)
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/broadcast/index.ts | 13 | ||||
-rw-r--r-- | src/lib/broadcast/index.web.ts | 3 | ||||
-rw-r--r-- | src/lib/broadcast/stub.ts | 11 |
3 files changed, 15 insertions, 12 deletions
diff --git a/src/lib/broadcast/index.ts b/src/lib/broadcast/index.ts index aa3aef580..6871db389 100644 --- a/src/lib/broadcast/index.ts +++ b/src/lib/broadcast/index.ts @@ -1,11 +1,2 @@ -export default class BroadcastChannel { - constructor(public name: string) {} - postMessage(_data: any) {} - close() {} - onmessage: (event: MessageEvent) => void = () => {} - addEventListener(_type: string, _listener: (event: MessageEvent) => void) {} - removeEventListener( - _type: string, - _listener: (event: MessageEvent) => void, - ) {} -} +import Stub from '#/lib/broadcast/stub' +export default Stub diff --git a/src/lib/broadcast/index.web.ts b/src/lib/broadcast/index.web.ts index 33b3548ad..ca202ec80 100644 --- a/src/lib/broadcast/index.web.ts +++ b/src/lib/broadcast/index.web.ts @@ -1 +1,2 @@ -export default BroadcastChannel +import Stub from '#/lib/broadcast/stub' +export default 'BroadcastChannel' in window ? window.BroadcastChannel : Stub diff --git a/src/lib/broadcast/stub.ts b/src/lib/broadcast/stub.ts new file mode 100644 index 000000000..aa3aef580 --- /dev/null +++ b/src/lib/broadcast/stub.ts @@ -0,0 +1,11 @@ +export default class BroadcastChannel { + constructor(public name: string) {} + postMessage(_data: any) {} + close() {} + onmessage: (event: MessageEvent) => void = () => {} + addEventListener(_type: string, _listener: (event: MessageEvent) => void) {} + removeEventListener( + _type: string, + _listener: (event: MessageEvent) => void, + ) {} +} |