const iframe = document.querySelector<HTMLIFrameElement>("#run-cloud-ios");
window.addEventListener("message", (event) => {
if (event.source !== iframe?.contentWindow) return;
const data = event.data;
if (!data || typeof data !== "object") return;
if (data.type === "ios-simulator:status") {
console.log({
streaming: data.streaming === true,
appLaunched: data.appLaunched === true,
reactNative: data.reactNative === true,
bundleId: typeof data.bundleId === "string" ? data.bundleId : null,
});
}
if (data.type === "ios-simulator:auth-error") {
// The signed URL or iframe cookie is invalid or expired.
}
if (
data.type === "ios-simulator:session-ended" ||
data.type === "ios-simulator:session-restart-requested"
) {
// Hide the old iframe and create a fresh run.cloud session.
}
});