()
| 17 | const updatePlatform = Platform.OS === 'android' ? 'android' : 'ios'; |
| 18 | |
| 19 | function App() { |
| 20 | const { |
| 21 | checkUpdate, |
| 22 | client: contextClient, |
| 23 | packageVersion, |
| 24 | currentHash, |
| 25 | lastError, |
| 26 | progress: { received, total } = {}, |
| 27 | currentVersionInfo, |
| 28 | } = useUpdate(); |
| 29 | const client = contextClient!; |
| 30 | const [lastEvent, setLastEvent] = useState('idle'); |
| 31 | const [lastEventData, setLastEventData] = useState('(empty)'); |
| 32 | const [lastEventVersion, setLastEventVersion] = useState('(none)'); |
| 33 | const [lastCheckStatus, setLastCheckStatus] = useState('(none)'); |
| 34 | const [lastCheckResult, setLastCheckResult] = useState('(none)'); |
| 35 | const [selectedStrategy, setSelectedStrategy] = |
| 36 | useState<UpdateStrategyMode>('silentAndNow'); |
| 37 | const bundleLabelGlobal = globalThis as typeof globalThis & { |
| 38 | __RNU_E2E_BUNDLE_LABEL?: string; |
| 39 | }; |
| 40 | const bundleLabel = |
| 41 | bundleLabelGlobal.__RNU_E2E_BUNDLE_LABEL || LOCAL_UPDATE_LABELS.base; |
| 42 | |
| 43 | const applyStrategy = (strategy: UpdateStrategyMode) => { |
| 44 | client.setOptions({ updateStrategy: strategy }); |
| 45 | setSelectedStrategy(strategy); |
| 46 | }; |
| 47 | |
| 48 | useEffect(() => { |
| 49 | const listener = (type: string, data?: Record<string, unknown>) => { |
| 50 | setLastEvent(type); |
| 51 | const message = JSON.stringify(data ?? {}); |
| 52 | setLastEventData(message || '(empty)'); |
| 53 | setLastEventVersion( |
| 54 | typeof data?.newVersion === 'string' ? data.newVersion : '(none)', |
| 55 | ); |
| 56 | }; |
| 57 | const checkListener = (state: { |
| 58 | status: string; |
| 59 | resultKind: string; |
| 60 | hash?: string; |
| 61 | }) => { |
| 62 | setLastCheckStatus(state.status); |
| 63 | setLastCheckResult( |
| 64 | state.hash ? `${state.resultKind}:${state.hash}` : state.resultKind, |
| 65 | ); |
| 66 | }; |
| 67 | eventListener = listener; |
| 68 | checkStateListener = checkListener; |
| 69 | return () => { |
| 70 | if (eventListener === listener) { |
| 71 | eventListener = null; |
| 72 | } |
| 73 | if (checkStateListener === checkListener) { |
| 74 | checkStateListener = null; |
| 75 | } |
| 76 | }; |
nothing calls this directly
no test coverage detected