From 45bf7ec905b6b369a0c3231c38774768e941d560 Mon Sep 17 00:00:00 2001 From: Grace Date: Fri, 22 May 2026 16:27:03 +0100 Subject: [PATCH] Add broadcast channel shim to fix iOS <15.4 crash --- src/broadcast-channel.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/broadcast-channel.ts b/src/broadcast-channel.ts index 2cded3a78..a9f37abae 100644 --- a/src/broadcast-channel.ts +++ b/src/broadcast-channel.ts @@ -9,6 +9,19 @@ export interface BroadcastChannelData { projectIds: string[]; settings?: boolean; } +class NoOpBroadcastChannel { + constructor() {} + postMessage(_data: unknown) {} + addEventListener(_type: string, _handler: (e: MessageEvent) => void) {} + removeEventListener(_type: string, _handler: (e: MessageEvent) => void) {} + close() {} +} // Used to keep project state synced between open tabs / windows. -export const broadcastChannel = new BroadcastChannel("ml"); +// Broadcast channel is not supported for older browsers/iOS versions, so a +// no-op version is used to avoid throwing an error. +// TODO: Revisit making project state syncing work for older web browsers. +export const broadcastChannel = + typeof BroadcastChannel === "undefined" + ? new NoOpBroadcastChannel() + : new BroadcastChannel("ml");