/** * Minimal AppRegistry for web, forked from react-native-web. * Original author: Nicolas Gallagher (Meta Platforms, Inc.) * Uses `react-dom/client` directly to avoid a hard dependency on react-native-web. */ import type { ComponentType, ReactNode } from 'react'; type ComponentProvider = () => ComponentType; type Runnable = { getApplication: (appParameters?: AppParameters) => { element: ReactNode; getStyleElement: (props?: Record) => ReactNode; }; run: (appParameters: AppParameters) => any; }; type AppParameters = { rootTag?: HTMLElement | null; initialProps?: Record; hydrate?: boolean; callback?: () => void; }; const runnables: Record = {}; // TODO: Remove react-native-web optional integration once we have a standalone web stylesheet solution. function tryRequireStyleSheet(): { getSheet?: () => { textContent: string; id: string } } | null { try { return require('react-native-web/dist/exports/StyleSheet'); } catch { return null; } } function tryRequireCreateSheet(): ((root?: HTMLElement) => any) | null { try { const mod = require('react-native-web/dist/exports/StyleSheet/dom'); return mod?.createSheet ?? null; } catch { return null; } } function registerComponent(appKey: string, componentProvider: ComponentProvider): string { runnables[appKey] = { getApplication: (appParameters?: AppParameters) => { const RootComponent = componentProvider(); const initialProps = appParameters?.initialProps ?? {}; const element = ; const getStyleElement = (props?: Record) => { const StyleSheet = tryRequireStyleSheet(); if (!StyleSheet?.getSheet) { return