The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import type { SharePayload } from "expo-sharing"; |
| 2 | |
| 3 | const IOS_APP_GROUP_UNAVAILABLE_ERROR_CODE = "ERR_FAILED_TO_RESOLVE_APP_GROUP_ID"; |
| 4 | |
| 5 | function errorCode(error: unknown): string | null { |
| 6 | if (typeof error !== "object" || error === null || !("code" in error)) { |
| 7 | return null; |
| 8 | } |
| 9 | return typeof error.code === "string" ? error.code : null; |
| 10 | } |
| 11 | |
| 12 | /** Personal Teams cannot include expo-sharing's App Group. */ |
| 13 | export function createIncomingSharePayloadReader(input: { |
| 14 | readonly platform: string; |
| 15 | readonly readPayloads: () => ReadonlyArray<SharePayload>; |
| 16 | }): () => ReadonlyArray<SharePayload> { |
| 17 | let isUnavailable = false; |
| 18 | |
| 19 | return () => { |
| 20 | if (isUnavailable) { |
| 21 | return []; |
| 22 | } |
| 23 | |
| 24 | try { |
| 25 | return input.readPayloads(); |
| 26 | } catch (error) { |
| 27 | if (input.platform === "ios" && errorCode(error) === IOS_APP_GROUP_UNAVAILABLE_ERROR_CODE) { |
| 28 | isUnavailable = true; |
| 29 | return []; |
| 30 | } |
| 31 | throw error; |
| 32 | } |
| 33 | }; |
| 34 | } |