@a16n/web-sim 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/README.md +13 -2
  2. package/bin/cli.ts +255 -0
  3. package/bin/web-sim.js +39 -0
  4. package/overrides/@backpackapp-io/react-native-toast/overrides.ts +15 -0
  5. package/overrides/@react-native-firebase/app/overrides.ts +34 -0
  6. package/overrides/@tiktok-for-business/react-native-sdk/NativeTiktokSdk.ts +29 -0
  7. package/overrides/@tiktok-for-business/react-native-sdk/overrides.ts +9 -0
  8. package/overrides/expo-application/ExpoApplication.ts +81 -0
  9. package/overrides/expo-application/overrides.ts +16 -0
  10. package/overrides/expo-background-task/ExpoBackgroundTaskModule.ts +30 -0
  11. package/overrides/expo-background-task/overrides.ts +9 -0
  12. package/overrides/expo-constants/ExponentConstants.ts +66 -0
  13. package/overrides/expo-constants/overrides.ts +9 -0
  14. package/overrides/expo-device/ExpoDevice.ts +104 -0
  15. package/overrides/expo-device/overrides.ts +9 -0
  16. package/overrides/expo-glass-effect/GlassContainer.tsx +9 -0
  17. package/overrides/expo-glass-effect/GlassView.tsx +95 -0
  18. package/overrides/expo-glass-effect/availability.ts +14 -0
  19. package/overrides/expo-glass-effect/overrides.ts +14 -0
  20. package/overrides/expo-haptics/Haptics.ts +67 -0
  21. package/overrides/expo-haptics/overrides.ts +5 -0
  22. package/overrides/expo-mail-composer/ExpoMailComposer.ts +40 -0
  23. package/overrides/expo-mail-composer/overrides.ts +9 -0
  24. package/overrides/expo-mesh-gradient/MeshGradientView.tsx +44 -0
  25. package/overrides/expo-mesh-gradient/overrides.ts +9 -0
  26. package/overrides/expo-modules-core/overrides.ts +12 -0
  27. package/overrides/expo-navigation-bar/ExpoNavigationBar.ts +29 -0
  28. package/overrides/expo-navigation-bar/NavigationBar.ts +43 -0
  29. package/overrides/expo-navigation-bar/overrides.ts +12 -0
  30. package/overrides/expo-router/NativeStackView.tsx +74 -0
  31. package/overrides/expo-router/NativeTabsView.tsx +263 -0
  32. package/overrides/expo-router/SafeAreaProvider.ts +6 -0
  33. package/overrides/expo-router/overrides.ts +23 -0
  34. package/overrides/expo-router/statusBarRequests.ts +51 -0
  35. package/overrides/expo-screen-orientation/ExpoScreenOrientation.ts +173 -0
  36. package/overrides/expo-screen-orientation/overrides.ts +21 -0
  37. package/overrides/expo-sharing/SharingNativeModule.ts +21 -0
  38. package/overrides/expo-sharing/overrides.ts +9 -0
  39. package/overrides/expo-sms/ExpoSMS.ts +24 -0
  40. package/overrides/expo-sms/overrides.ts +9 -0
  41. package/overrides/expo-splash-screen/SplashScreen.ts +25 -0
  42. package/overrides/expo-splash-screen/overrides.ts +5 -0
  43. package/overrides/expo-status-bar/StatusBar.tsx +44 -0
  44. package/overrides/expo-status-bar/overrides.ts +5 -0
  45. package/overrides/expo-store-review/ExpoStoreReview.ts +18 -0
  46. package/overrides/expo-store-review/overrides.ts +9 -0
  47. package/overrides/expo-symbols/SymbolView.tsx +192 -0
  48. package/overrides/expo-symbols/overrides.ts +9 -0
  49. package/overrides/expo-system-ui/ExpoSystemUI.ts +34 -0
  50. package/overrides/expo-system-ui/overrides.ts +9 -0
  51. package/overrides/expo-task-manager/ExpoTaskManager.ts +39 -0
  52. package/overrides/expo-task-manager/overrides.ts +9 -0
  53. package/overrides/expo-tracking-transparency/ExpoTrackingTransparency.ts +30 -0
  54. package/overrides/expo-tracking-transparency/overrides.ts +11 -0
  55. package/overrides/expo-video/ExpoVideo.ts +16 -0
  56. package/overrides/expo-video/overrides.ts +9 -0
  57. package/overrides/lottie-react-native/LottieView.tsx +87 -0
  58. package/overrides/lottie-react-native/overrides.ts +9 -0
  59. package/overrides/react-native-pager-view/PagerViewNativeComponent.tsx +254 -0
  60. package/overrides/react-native-pager-view/overrides.ts +9 -0
  61. package/overrides/react-native-reanimated/overrides.ts +28 -0
  62. package/overrides/react-native-safe-area-context/NativeSafeAreaProvider.tsx +40 -0
  63. package/overrides/react-native-safe-area-context/overrides.ts +12 -0
  64. package/overrides/react-native-share/NativeRNShare.ts +22 -0
  65. package/overrides/react-native-share/overrides.ts +12 -0
  66. package/overrides/react-native-share/platform.ts +14 -0
  67. package/overrides/react-native-turbo-image/TurboImage.tsx +101 -0
  68. package/overrides/react-native-turbo-image/overrides.ts +9 -0
  69. package/overrides/react-native-web/RefreshControl.tsx +57 -0
  70. package/overrides/react-native-web/overrides.ts +153 -0
  71. package/overrides/react-native-web/useElementLayout.ts +140 -0
  72. package/package.json +78 -4
  73. package/plugins/battery/overrides/expo-battery/ExpoBattery.ts +57 -0
  74. package/plugins/battery/overrides/expo-battery/overrides.ts +9 -0
  75. package/plugins/battery/plugin.ts +8 -0
  76. package/plugins/battery/shell.tsx +56 -0
  77. package/plugins/battery/state.ts +11 -0
  78. package/plugins/biometrics/overrides/expo-local-authentication/ExpoLocalAuthentication.ts +90 -0
  79. package/plugins/biometrics/overrides/expo-local-authentication/overrides.ts +11 -0
  80. package/plugins/biometrics/plugin.ts +8 -0
  81. package/plugins/biometrics/shell.tsx +88 -0
  82. package/plugins/biometrics/state.ts +41 -0
  83. package/plugins/brightness/app.ts +5 -0
  84. package/plugins/brightness/overrides/expo-brightness/Brightness.ts +98 -0
  85. package/plugins/brightness/overrides/expo-brightness/overrides.ts +10 -0
  86. package/plugins/brightness/plugin.ts +9 -0
  87. package/plugins/brightness/shell.tsx +55 -0
  88. package/plugins/brightness/state.ts +19 -0
  89. package/plugins/calendar/calendar.ts +299 -0
  90. package/plugins/calendar/overrides/expo-calendar/ExpoCalendar.ts +358 -0
  91. package/plugins/calendar/overrides/expo-calendar/LegacyExpoCalendar.ts +163 -0
  92. package/plugins/calendar/overrides/expo-calendar/overrides.ts +14 -0
  93. package/plugins/calendar/plugin.ts +8 -0
  94. package/plugins/calendar/shell.tsx +123 -0
  95. package/plugins/camera/overrides/expo-camera/ExpoCamera.tsx +269 -0
  96. package/plugins/camera/overrides/expo-camera/ExpoCameraManager.ts +56 -0
  97. package/plugins/camera/overrides/expo-camera/overrides.ts +12 -0
  98. package/plugins/camera/plugin.ts +9 -0
  99. package/plugins/camera/shell.tsx +107 -0
  100. package/plugins/camera/state.ts +61 -0
  101. package/plugins/clipboard/overrides/expo-clipboard/ExpoClipboard.ts +138 -0
  102. package/plugins/clipboard/overrides/expo-clipboard/overrides.ts +9 -0
  103. package/plugins/clipboard/plugin.ts +8 -0
  104. package/plugins/clipboard/shell.tsx +122 -0
  105. package/plugins/clipboard/state.ts +93 -0
  106. package/plugins/clock/app.ts +25 -0
  107. package/plugins/clock/plugin.ts +8 -0
  108. package/plugins/clock/shell.tsx +225 -0
  109. package/plugins/clock/state.ts +12 -0
  110. package/plugins/contacts/contacts.ts +125 -0
  111. package/plugins/contacts/overrides/expo-contacts/ExpoContacts.ts +153 -0
  112. package/plugins/contacts/overrides/expo-contacts/ExpoContactsNext.ts +232 -0
  113. package/plugins/contacts/overrides/expo-contacts/overrides.ts +12 -0
  114. package/plugins/contacts/plugin.ts +8 -0
  115. package/plugins/contacts/shell.tsx +109 -0
  116. package/plugins/home-indicator/app.ts +5 -0
  117. package/plugins/home-indicator/plugin.ts +9 -0
  118. package/plugins/home-indicator/requests.ts +48 -0
  119. package/plugins/home-indicator/shell.tsx +68 -0
  120. package/plugins/home-indicator/state.ts +31 -0
  121. package/plugins/keep-awake/app.ts +5 -0
  122. package/plugins/keep-awake/overrides/expo-keep-awake/ExpoKeepAwake.ts +27 -0
  123. package/plugins/keep-awake/overrides/expo-keep-awake/overrides.ts +9 -0
  124. package/plugins/keep-awake/plugin.ts +9 -0
  125. package/plugins/keep-awake/shell.tsx +80 -0
  126. package/plugins/keep-awake/state.ts +12 -0
  127. package/plugins/keyboard/Keyboard.tsx +354 -0
  128. package/plugins/keyboard/app.ts +90 -0
  129. package/plugins/keyboard/controller.ts +384 -0
  130. package/plugins/keyboard/fields.ts +244 -0
  131. package/plugins/keyboard/icons.tsx +283 -0
  132. package/plugins/keyboard/keyboard.css +362 -0
  133. package/plugins/keyboard/layouts/android.ts +175 -0
  134. package/plugins/keyboard/layouts/index.ts +10 -0
  135. package/plugins/keyboard/layouts/ios.ts +219 -0
  136. package/plugins/keyboard/layouts/types.ts +80 -0
  137. package/plugins/keyboard/overrides/react-native-keyboard-controller/KeyboardController.tsx +470 -0
  138. package/plugins/keyboard/overrides/react-native-keyboard-controller/overrides.ts +9 -0
  139. package/plugins/keyboard/plugin.ts +13 -0
  140. package/plugins/keyboard/shell.tsx +133 -0
  141. package/plugins/keyboard/state.ts +92 -0
  142. package/plugins/keyboard/suggestions.ts +63 -0
  143. package/plugins/keyboard/taps.ts +77 -0
  144. package/plugins/keyboard/typing.ts +112 -0
  145. package/plugins/locale/app.ts +232 -0
  146. package/plugins/locale/locale.ts +143 -0
  147. package/plugins/locale/overrides/expo-localization/ExpoLocalization.ts +41 -0
  148. package/plugins/locale/overrides/expo-localization/overrides.ts +9 -0
  149. package/plugins/locale/plugin.ts +9 -0
  150. package/plugins/locale/shell.tsx +147 -0
  151. package/plugins/locale/state.ts +36 -0
  152. package/plugins/location/geo.ts +56 -0
  153. package/plugins/location/overrides/expo-location/ExpoLocation.ts +235 -0
  154. package/plugins/location/overrides/expo-location/overrides.ts +11 -0
  155. package/plugins/location/places.ts +38 -0
  156. package/plugins/location/plugin.ts +8 -0
  157. package/plugins/location/shell.tsx +188 -0
  158. package/plugins/location/state.ts +51 -0
  159. package/plugins/motion/overrides/expo-sensors/DeviceSensor.ts +169 -0
  160. package/plugins/motion/overrides/expo-sensors/ExponentPedometer.ts +54 -0
  161. package/plugins/motion/overrides/expo-sensors/overrides.ts +14 -0
  162. package/plugins/motion/plugin.ts +8 -0
  163. package/plugins/motion/sensors.ts +116 -0
  164. package/plugins/motion/shell.tsx +136 -0
  165. package/plugins/motion/state.ts +46 -0
  166. package/plugins/network/app.ts +400 -0
  167. package/plugins/network/overrides/expo-network/ExpoNetwork.ts +51 -0
  168. package/plugins/network/overrides/expo-network/overrides.ts +9 -0
  169. package/plugins/network/plugin.ts +8 -0
  170. package/plugins/network/shell.tsx +67 -0
  171. package/plugins/network/state.ts +29 -0
  172. package/plugins/notifications/center.ts +255 -0
  173. package/plugins/notifications/content.ts +36 -0
  174. package/plugins/notifications/overrides/expo-notifications/NotificationsModule.ts +175 -0
  175. package/plugins/notifications/overrides/expo-notifications/channels.ts +108 -0
  176. package/plugins/notifications/overrides/expo-notifications/getDevicePushTokenAsync.ts +19 -0
  177. package/plugins/notifications/overrides/expo-notifications/getExpoPushTokenAsync.ts +16 -0
  178. package/plugins/notifications/overrides/expo-notifications/overrides.ts +36 -0
  179. package/plugins/notifications/plugin.ts +8 -0
  180. package/plugins/notifications/shell.tsx +192 -0
  181. package/plugins/notifications/state.ts +56 -0
  182. package/plugins/notifications/tokens.ts +47 -0
  183. package/plugins/notifications/trigger.ts +107 -0
  184. package/plugins/permissions/plugin.ts +6 -0
  185. package/plugins/permissions/shell.tsx +50 -0
  186. package/plugins/permissions/state.ts +38 -0
  187. package/plugins/photos/appLibrary.ts +114 -0
  188. package/plugins/photos/library.ts +322 -0
  189. package/plugins/photos/overrides/expo-image-picker/ExponentImagePicker.ts +153 -0
  190. package/plugins/photos/overrides/expo-image-picker/overrides.ts +13 -0
  191. package/plugins/photos/overrides/expo-media-library/ExpoMediaLibrary.ts +235 -0
  192. package/plugins/photos/overrides/expo-media-library/NativeMediaLibraryModule.ts +318 -0
  193. package/plugins/photos/overrides/expo-media-library/overrides.ts +19 -0
  194. package/plugins/photos/plugin.ts +8 -0
  195. package/plugins/photos/samples.ts +367 -0
  196. package/plugins/photos/shell.tsx +164 -0
  197. package/plugins/photos/state.ts +88 -0
  198. package/plugins/storage/files.ts +351 -0
  199. package/plugins/storage/overrides/expo-file-system/ExpoFileSystem.ts +770 -0
  200. package/plugins/storage/overrides/expo-file-system/ExponentFileSystem.ts +196 -0
  201. package/plugins/storage/overrides/expo-file-system/overrides.ts +13 -0
  202. package/plugins/storage/overrides/expo-secure-store/ExpoSecureStore.ts +75 -0
  203. package/plugins/storage/overrides/expo-secure-store/overrides.ts +9 -0
  204. package/plugins/storage/plugin.ts +8 -0
  205. package/plugins/storage/reset.ts +136 -0
  206. package/plugins/storage/secure.ts +71 -0
  207. package/plugins/storage/shell.tsx +365 -0
  208. package/plugins/storage/state.ts +13 -0
  209. package/src/client/app/appDocument.ts +113 -0
  210. package/src/client/app/appFocus.ts +97 -0
  211. package/src/client/app/console.ts +118 -0
  212. package/src/client/app/fonts.ts +59 -0
  213. package/src/client/app/main.tsx +99 -0
  214. package/src/client/app/routeContext.ts +45 -0
  215. package/src/client/app/touch.ts +640 -0
  216. package/src/client/entry.ts +20 -0
  217. package/src/client/modules.d.ts +8 -0
  218. package/src/client/react-native/app.ts +57 -0
  219. package/src/client/react-native/deep.ts +13 -0
  220. package/src/client/react-native/keyboard.tsx +192 -0
  221. package/src/client/react-native/library.ts +256 -0
  222. package/src/client/shell/Cookies.tsx +95 -0
  223. package/src/client/shell/LogDrawer.tsx +415 -0
  224. package/src/client/shell/PhotoPicker.tsx +174 -0
  225. package/src/client/shell/PluginOverlays.tsx +42 -0
  226. package/src/client/shell/PluginPanels.tsx +82 -0
  227. package/src/client/shell/ResetApp.tsx +87 -0
  228. package/src/client/shell/Resizer.tsx +99 -0
  229. package/src/client/shell/Shell.tsx +531 -0
  230. package/src/client/shell/SystemBars.tsx +376 -0
  231. package/src/client/shell/SystemCamera.tsx +181 -0
  232. package/src/client/shell/SystemOverlay.tsx +422 -0
  233. package/src/client/shell/SystemSheets.tsx +462 -0
  234. package/src/client/shell/backdrop.ts +229 -0
  235. package/src/client/shell/control.ts +91 -0
  236. package/src/client/shell/events.ts +226 -0
  237. package/src/client/shell/geometry.ts +68 -0
  238. package/src/client/shell/host.ts +492 -0
  239. package/src/client/shell/icons.tsx +34 -0
  240. package/src/client/shell/logFeed.ts +102 -0
  241. package/src/client/shell/main.tsx +22 -0
  242. package/src/client/shell/permissionCopy.ts +169 -0
  243. package/src/client/shell/plugins.ts +266 -0
  244. package/src/client/shell/popout.ts +185 -0
  245. package/src/client/shell/popover.ts +27 -0
  246. package/src/client/shell/shell.css +878 -0
  247. package/src/client/shell/statusTime.ts +31 -0
  248. package/src/client/shell/tooltips.ts +104 -0
  249. package/src/client/virtual.d.ts +21 -0
  250. package/src/devices/catalog.ts +223 -0
  251. package/src/devices/types.ts +83 -0
  252. package/src/node/appInfo.ts +186 -0
  253. package/src/node/appSource.ts +138 -0
  254. package/src/node/config.ts +180 -0
  255. package/src/node/control.ts +144 -0
  256. package/src/node/doctor.ts +199 -0
  257. package/src/node/events/cli.ts +206 -0
  258. package/src/node/events/shared.ts +238 -0
  259. package/src/node/events/store.ts +266 -0
  260. package/src/node/index.ts +5 -0
  261. package/src/node/overrides/define.ts +56 -0
  262. package/src/node/overrides/packages.ts +136 -0
  263. package/src/node/overrides/platformPatch.ts +56 -0
  264. package/src/node/overrides/plugin.ts +166 -0
  265. package/src/node/overrides/registry.ts +258 -0
  266. package/src/node/paths.ts +18 -0
  267. package/src/node/platform.ts +171 -0
  268. package/src/node/plugins.ts +98 -0
  269. package/src/node/proxy.ts +421 -0
  270. package/src/node/server.ts +253 -0
  271. package/src/plugin/index.ts +33 -0
  272. package/src/plugin/types.ts +127 -0
  273. package/src/plugin/ui.tsx +562 -0
  274. package/src/runtime/clock.ts +112 -0
  275. package/src/runtime/draw.ts +196 -0
  276. package/src/runtime/index.ts +513 -0
  277. package/src/runtime/media.ts +379 -0
  278. package/src/runtime/records.ts +76 -0
  279. package/src/runtime/timezone.ts +81 -0
@@ -0,0 +1,263 @@
1
+ import type { CSSProperties, ReactNode } from 'react'
2
+ import { insets, platform, useSimState } from 'web-sim/runtime'
3
+
4
+ type IconSource = string | { uri?: string; default?: string } | null | undefined
5
+
6
+ type TabOptions = {
7
+ title?: string
8
+ badgeValue?: string
9
+ icon?: { src?: IconSource; renderingMode?: 'template' | 'original' }
10
+ selectedIcon?: { src?: IconSource; renderingMode?: 'template' | 'original' }
11
+ backgroundColor?: string
12
+ indicatorColor?: string
13
+ labelStyle?: { color?: string; fontSize?: number; fontWeight?: string; fontFamily?: string }
14
+ selectedLabelStyle?: { color?: string; fontSize?: number; fontWeight?: string }
15
+ badgeBackgroundColor?: string
16
+ badgeTextColor?: string
17
+ }
18
+
19
+ type Props = {
20
+ tabs: { name: string; options: TabOptions; contentRenderer: () => ReactNode }[]
21
+ focusedIndex: number
22
+ tintColor?: string
23
+ onTabChange: (event: { selectedKey: string; provenance: number; isNativeAction: boolean }) => void
24
+ }
25
+
26
+ /**
27
+ * `NativeTabs` as the simulated platform draws it: iOS's floating tab bar, or Android's Material navigation bar.
28
+ * expo-router's own web view is a tab strip across the top, as a website would have.
29
+ *
30
+ * Every tab stays laid out at full size, and the ones not selected are only hidden, as a tab bar controller's
31
+ * screens are: they keep their frames, onLayout and running animations. With display: none they would have no
32
+ * layout, and Reanimated's web entering animations, which never end there, pin their views at 0×0 when they time
33
+ * out, so a screen first shown later (the default template's welcome logo) drew in the wrong place.
34
+ */
35
+ export function NativeTabsView(props: Props) {
36
+ const { tabs, focusedIndex } = props
37
+ const { appAppearance: appearance } = useSimState()
38
+ const dark = appearance === 'dark'
39
+ const current = tabs[focusedIndex]?.options ?? {}
40
+ const select = (name: string) => props.onTabChange({ selectedKey: name, provenance: 0, isNativeAction: true })
41
+ const { bottom, left, right } = insets()
42
+ const isIos = platform() === 'ios'
43
+
44
+ return (
45
+ <div style={{ position: 'relative', flex: 1, display: 'flex', flexDirection: 'column', minHeight: 0 }}>
46
+ <div style={{ position: 'relative', flex: 1, minHeight: 0 }}>
47
+ {tabs.map((tab, index) => {
48
+ const selected = index === focusedIndex
49
+ return (
50
+ <div
51
+ key={tab.name}
52
+ aria-hidden={!selected}
53
+ inert={!selected}
54
+ style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', visibility: selected ? 'visible' : 'hidden' }}
55
+ >
56
+ {tab.contentRenderer()}
57
+ </div>
58
+ )
59
+ })}
60
+ </div>
61
+ {isIos ? (
62
+ <IosTabBar {...props} current={current} dark={dark} bottom={bottom} sides={{ left, right }} onSelect={select} />
63
+ ) : (
64
+ <AndroidNavigationBar {...props} current={current} dark={dark} bottom={bottom} sides={{ left, right }} onSelect={select} />
65
+ )}
66
+ </div>
67
+ )
68
+ }
69
+
70
+ type BarProps = Props & {
71
+ current: TabOptions
72
+ dark: boolean
73
+ bottom: number
74
+ sides: { left: number; right: number }
75
+ onSelect: (name: string) => void
76
+ }
77
+
78
+ function IosTabBar({ tabs, focusedIndex, tintColor, current, dark, bottom, sides, onSelect }: BarProps) {
79
+ const active = current.selectedLabelStyle?.color ?? tintColor ?? (dark ? '#ffffff' : '#0a84ff')
80
+ const inactive = current.labelStyle?.color ?? (dark ? 'rgba(255,255,255,0.6)' : 'rgba(0,0,0,0.6)')
81
+ const bar: CSSProperties = {
82
+ position: 'absolute',
83
+ left: 21 + sides.left,
84
+ right: 21 + sides.right,
85
+ bottom: Math.max(bottom - 13, 8),
86
+ height: 62,
87
+ display: 'flex',
88
+ padding: 4,
89
+ gap: 2,
90
+ boxSizing: 'border-box',
91
+ borderRadius: 31,
92
+ background: dark ? 'rgba(40,40,42,0.72)' : 'rgba(255,255,255,0.72)',
93
+ backdropFilter: 'blur(18px) saturate(1.8)',
94
+ WebkitBackdropFilter: 'blur(18px) saturate(1.8)',
95
+ boxShadow: dark
96
+ ? 'inset 0 0 0 0.5px rgba(255,255,255,0.15), 0 8px 24px rgba(0,0,0,0.4)'
97
+ : 'inset 0 0 0 0.5px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.12)',
98
+ }
99
+ return (
100
+ <div role="tablist" style={bar}>
101
+ {tabs.map((tab, index) => {
102
+ const selected = index === focusedIndex
103
+ const color = selected ? active : inactive
104
+ return (
105
+ <button
106
+ key={tab.name}
107
+ type="button"
108
+ role="tab"
109
+ aria-selected={selected}
110
+ data-testid={`tab-${tab.name}`}
111
+ onClick={() => onSelect(tab.name)}
112
+ style={{
113
+ ...RESET_BUTTON,
114
+ flex: 1,
115
+ borderRadius: 27,
116
+ background: selected ? (current.indicatorColor ?? (dark ? 'rgba(255,255,255,0.12)' : 'rgba(0,0,0,0.06)')) : 'transparent',
117
+ display: 'flex',
118
+ flexDirection: 'column',
119
+ alignItems: 'center',
120
+ justifyContent: 'center',
121
+ gap: 1,
122
+ color,
123
+ position: 'relative',
124
+ }}
125
+ >
126
+ <TabIcon option={selected ? (tab.options.selectedIcon ?? tab.options.icon) : tab.options.icon} color={color} size={26} />
127
+ <span style={{ fontSize: 10, fontWeight: 600, letterSpacing: 0.1, fontFamily: tab.options.labelStyle?.fontFamily }}>
128
+ {tab.options.title ?? tab.name}
129
+ </span>
130
+ <Badge value={tab.options.badgeValue} options={tab.options} offset={{ top: 4, left: '58%' }} />
131
+ </button>
132
+ )
133
+ })}
134
+ </div>
135
+ )
136
+ }
137
+
138
+ function AndroidNavigationBar({ tabs, focusedIndex, tintColor, current, dark, bottom, sides, onSelect }: BarProps) {
139
+ const active = current.selectedLabelStyle?.color ?? tintColor ?? (dark ? '#e3e2e6' : '#1b1b1f')
140
+ const inactive = current.labelStyle?.color ?? (dark ? '#c4c6d0' : '#44474e')
141
+ const indicator = current.indicatorColor ?? (dark ? '#3e4759' : '#d8e2ff')
142
+ return (
143
+ <div
144
+ role="tablist"
145
+ style={{
146
+ display: 'flex',
147
+ flex: 'none',
148
+ height: 80 + bottom,
149
+ paddingBottom: bottom,
150
+ paddingLeft: sides.left,
151
+ paddingRight: sides.right,
152
+ boxSizing: 'border-box',
153
+ background: current.backgroundColor ?? (dark ? '#1f1f23' : '#f3f3fa'),
154
+ }}
155
+ >
156
+ {tabs.map((tab, index) => {
157
+ const selected = index === focusedIndex
158
+ return (
159
+ <button
160
+ key={tab.name}
161
+ type="button"
162
+ role="tab"
163
+ aria-selected={selected}
164
+ data-testid={`tab-${tab.name}`}
165
+ onClick={() => onSelect(tab.name)}
166
+ style={{ ...RESET_BUTTON, flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4 }}
167
+ >
168
+ <span
169
+ style={{
170
+ width: 64,
171
+ height: 32,
172
+ borderRadius: 16,
173
+ display: 'grid',
174
+ placeItems: 'center',
175
+ position: 'relative',
176
+ background: selected ? indicator : 'transparent',
177
+ transition: 'background 0.2s',
178
+ }}
179
+ >
180
+ <TabIcon option={selected ? (tab.options.selectedIcon ?? tab.options.icon) : tab.options.icon} color={selected ? active : inactive} size={24} />
181
+ <Badge value={tab.options.badgeValue} options={tab.options} offset={{ top: 0, left: '56%' }} />
182
+ </span>
183
+ <span
184
+ style={{
185
+ fontSize: 12,
186
+ fontWeight: selected ? 700 : 500,
187
+ letterSpacing: 0.5,
188
+ color: selected ? active : inactive,
189
+ fontFamily: tab.options.labelStyle?.fontFamily ?? 'Roboto, system-ui, sans-serif',
190
+ }}
191
+ >
192
+ {tab.options.title ?? tab.name}
193
+ </span>
194
+ </button>
195
+ )
196
+ })}
197
+ </div>
198
+ )
199
+ }
200
+
201
+ function iconUrl(source: IconSource): string | null {
202
+ if (typeof source === 'string') {
203
+ return source
204
+ }
205
+ if (source !== null && typeof source === 'object') {
206
+ return source.uri ?? source.default ?? null
207
+ }
208
+ return null
209
+ }
210
+
211
+ /**
212
+ * A template icon is drawn in the label's colour, through the image's alpha, as iOS and Android tint them.
213
+ */
214
+ function TabIcon({ option, color, size }: { option: TabOptions['icon']; color: string; size: number }) {
215
+ const url = iconUrl(option?.src)
216
+ if (url === null) {
217
+ return <span style={{ width: size, height: size }} />
218
+ }
219
+ if (option?.renderingMode === 'original') {
220
+ return <img src={url} alt="" width={size} height={size} style={{ objectFit: 'contain' }} />
221
+ }
222
+ const mask = `url("${url}") center / contain no-repeat`
223
+ return <span style={{ width: size, height: size, background: color, WebkitMask: mask, mask }} />
224
+ }
225
+
226
+ function Badge({ value, options, offset }: { value?: string; options: TabOptions; offset: { top: number; left: string } }) {
227
+ if (!value) {
228
+ return null
229
+ }
230
+ const empty = value === ' '
231
+ return (
232
+ <span
233
+ style={{
234
+ position: 'absolute',
235
+ top: offset.top,
236
+ left: offset.left,
237
+ minWidth: empty ? 8 : 16,
238
+ height: empty ? 8 : 16,
239
+ padding: empty ? 0 : '0 4px',
240
+ boxSizing: 'border-box',
241
+ borderRadius: 8,
242
+ background: options.badgeBackgroundColor ?? '#ff3b30',
243
+ color: options.badgeTextColor ?? '#fff',
244
+ fontSize: 11,
245
+ fontWeight: 600,
246
+ lineHeight: '16px',
247
+ textAlign: 'center',
248
+ }}
249
+ >
250
+ {empty ? '' : value}
251
+ </span>
252
+ )
253
+ }
254
+
255
+ const RESET_BUTTON: CSSProperties = {
256
+ border: 0,
257
+ margin: 0,
258
+ padding: 0,
259
+ background: 'transparent',
260
+ font: 'inherit',
261
+ cursor: 'pointer',
262
+ WebkitTapHighlightColor: 'transparent',
263
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * expo-router's web build provides zero insets, so a server-rendered page hydrates without measuring. In the
3
+ * simulator the app is on a phone, so it gets the library's provider, as on native, which the
4
+ * react-native-safe-area-context override feeds the device's insets.
5
+ */
6
+ export { SafeAreaProvider } from 'react-native-safe-area-context'
@@ -0,0 +1,23 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ const SHARED = {
4
+ 'build/native-tabs/NativeTabsView.web.js': './NativeTabsView.tsx',
5
+ 'build/SafeAreaProvider.js': './SafeAreaProvider.ts',
6
+ }
7
+
8
+ export default defineOverrides('expo-router', [
9
+ {
10
+ versions: '>=58 <59',
11
+ note: "native tabs drawn as the platform tab bar; device safe-area insets; the native stack's autoHideHomeIndicator drives the home indicator and its statusBarStyle the status bar; its bundled React Navigation (headers, back button, tab bar, fonts) sees the device's platform, while expo-router's own linking stays on its web path",
12
+ platform: { device: ['build/react-navigation/'] },
13
+ files: {
14
+ ...SHARED,
15
+ 'build/react-navigation/native-stack/views/NativeStackView.js': './NativeStackView.tsx',
16
+ },
17
+ },
18
+ {
19
+ versions: '>=55 <58',
20
+ note: 'native tabs drawn as the platform tab bar; device safe-area insets',
21
+ files: SHARED,
22
+ },
23
+ ])
@@ -0,0 +1,51 @@
1
+ import { getState, setStatusBar, type StatusBarStyle } from 'web-sim/runtime'
2
+
3
+ /** A native stack screen's `statusBarStyle`, as react-native-screens takes it. */
4
+ export type ScreenStatusBarStyle = 'auto' | 'inverted' | 'light' | 'dark'
5
+
6
+ /**
7
+ * What the app's native stacks ask of the status bar. On iOS react-native-screens asks the deepest focused screen that
8
+ * sets `statusBarStyle` (`childViewControllerForStatusBarStyle`), falling back to its parents'; with none set, the
9
+ * `StatusBar` components' style holds. So each stack reports how deep it is, whether it is on the focused path, and
10
+ * what its focused screen asks; the deepest focused one that asks wins.
11
+ */
12
+ type Request = { depth: number; focused: boolean; style: ScreenStatusBarStyle | undefined }
13
+
14
+ const requests = new Map<string, Request>()
15
+ let scheduled = false
16
+
17
+ /** Sets (or, with null, drops) one stack's request. */
18
+ export function requestStatusBarStyle(id: string, request: Request | null): void {
19
+ if (request === null) {
20
+ requests.delete(id)
21
+ } else {
22
+ requests.set(id, request)
23
+ }
24
+ // Once per batch of changes: a navigation commits several stacks at once.
25
+ if (!scheduled) {
26
+ scheduled = true
27
+ queueMicrotask(apply)
28
+ }
29
+ }
30
+
31
+ function apply(): void {
32
+ scheduled = false
33
+ let winner: Request | null = null
34
+ for (const request of requests.values()) {
35
+ if (request.focused && request.style !== undefined && (winner === null || request.depth >= winner.depth)) {
36
+ winner = request
37
+ }
38
+ }
39
+ setStatusBar({ screenStyle: winner === null ? null : resolve(winner.style!) })
40
+ }
41
+
42
+ /**
43
+ * react-native-screens resolves `auto` and `inverted` from the appearance, never from the content under the bar:
44
+ * only `UIStatusBarStyleDefault` follows the content.
45
+ */
46
+ function resolve(style: ScreenStatusBarStyle): StatusBarStyle {
47
+ if (style === 'inverted') {
48
+ return getState().appAppearance === 'dark' ? 'dark' : 'light'
49
+ }
50
+ return style
51
+ }
@@ -0,0 +1,173 @@
1
+ import { CodedError, NativeModule, registerWebModule } from 'expo'
2
+ import { getHost, getState, shellWindow, subscribe, type Orientation as SimOrientation } from 'web-sim/runtime'
3
+
4
+ /**
5
+ * expo-screen-orientation's native module, on the simulated device: a lock rotates the device and holds it there,
6
+ * the user's rotations in the shell fire the change event, and the orientation reported is the device's.
7
+ */
8
+ const Orientation = { UNKNOWN: 0, PORTRAIT_UP: 1, PORTRAIT_DOWN: 2, LANDSCAPE_LEFT: 3, LANDSCAPE_RIGHT: 4 } as const
9
+ const Lock = {
10
+ DEFAULT: 0,
11
+ ALL: 1,
12
+ PORTRAIT: 2,
13
+ PORTRAIT_UP: 3,
14
+ PORTRAIT_DOWN: 4,
15
+ LANDSCAPE: 5,
16
+ LANDSCAPE_LEFT: 6,
17
+ LANDSCAPE_RIGHT: 7,
18
+ OTHER: 8,
19
+ UNKNOWN: 9,
20
+ } as const
21
+
22
+ /** The lock's detail, which the shell does not keep: it only knows portrait, landscape or free. */
23
+ type Kept = { lock: number; held: SimOrientation | null; platformLock?: number[] | number }
24
+
25
+ declare global {
26
+ interface Window {
27
+ __webSimScreenOrientation?: Kept
28
+ }
29
+ }
30
+
31
+ function held(lock: number): SimOrientation | null {
32
+ if (lock === Lock.PORTRAIT || lock === Lock.PORTRAIT_UP || lock === Lock.PORTRAIT_DOWN) {
33
+ return 'portrait'
34
+ }
35
+ if (lock === Lock.LANDSCAPE || lock === Lock.LANDSCAPE_LEFT || lock === Lock.LANDSCAPE_RIGHT) {
36
+ return 'landscape'
37
+ }
38
+ return null
39
+ }
40
+
41
+ function currentLock(): number {
42
+ const shellLock = getHost().getOrientationLock()
43
+ const kept = shellWindow().__webSimScreenOrientation
44
+ // A lock the shell no longer holds (a new run, or the app unlocked) is forgotten.
45
+ if (kept !== undefined && kept.held === shellLock) {
46
+ return kept.lock
47
+ }
48
+ return shellLock === 'portrait' ? Lock.PORTRAIT_UP : shellLock === 'landscape' ? Lock.LANDSCAPE : Lock.DEFAULT
49
+ }
50
+
51
+ function currentOrientation(): number {
52
+ const lock = currentLock()
53
+ const platformLock = shellWindow().__webSimScreenOrientation?.platformLock
54
+ if (getState().orientation === 'portrait') {
55
+ const down = lock === Lock.PORTRAIT_DOWN || (lock === Lock.OTHER && (platformLock === 9 || (Array.isArray(platformLock) && platformLock.every((item) => item === Orientation.PORTRAIT_DOWN))))
56
+ return down ? Orientation.PORTRAIT_DOWN : Orientation.PORTRAIT_UP
57
+ }
58
+ const right =
59
+ lock === Lock.LANDSCAPE_RIGHT ||
60
+ (lock === Lock.OTHER && (platformLock === 8 || (Array.isArray(platformLock) && platformLock.every((item) => item === Orientation.LANDSCAPE_RIGHT))))
61
+ return right ? Orientation.LANDSCAPE_RIGHT : Orientation.LANDSCAPE_LEFT
62
+ }
63
+
64
+ /** iPhones with a notch or the Dynamic Island do not turn upside down. */
65
+ function supports(lock: number): boolean {
66
+ const { device } = getState()
67
+ if (lock === Lock.OTHER || lock === Lock.UNKNOWN) {
68
+ return false
69
+ }
70
+ return !(lock === Lock.PORTRAIT_DOWN && device.platform === 'ios' && device.cutout.kind !== 'none')
71
+ }
72
+
73
+ /** iOS's size classes: compact width in portrait; landscape is compact height, and regular width on the largest. */
74
+ function sizeClasses() {
75
+ const { device, orientation } = getState()
76
+ if (device.platform !== 'ios') {
77
+ return {}
78
+ }
79
+ if (orientation === 'portrait') {
80
+ return { horizontalSizeClass: 1, verticalSizeClass: 2 }
81
+ }
82
+ return { horizontalSizeClass: device.screen.width >= 414 ? 2 : 1, verticalSizeClass: 1 }
83
+ }
84
+
85
+ class ExpoScreenOrientation extends NativeModule<{ expoDidUpdateDimensions: (event: unknown) => void }> {
86
+ unsubscribe: (() => void) | null = null
87
+
88
+ startObserving() {
89
+ let last = getState().orientation
90
+ this.unsubscribe ??= subscribe(() => {
91
+ const { orientation } = getState()
92
+ if (orientation !== last) {
93
+ last = orientation
94
+ this.emit('expoDidUpdateDimensions', {
95
+ orientationLock: currentLock(),
96
+ orientationInfo: { orientation: currentOrientation(), ...sizeClasses() },
97
+ })
98
+ }
99
+ })
100
+ }
101
+
102
+ stopObserving() {
103
+ this.unsubscribe?.()
104
+ this.unsubscribe = null
105
+ }
106
+
107
+ async lockAsync(lock: number) {
108
+ if (!Object.values(Lock).includes(lock as never) || lock === Lock.UNKNOWN) {
109
+ throw new TypeError(`Invalid Orientation Lock: ${lock}`)
110
+ }
111
+ if (!supports(lock)) {
112
+ throw new CodedError('ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK', `This device does not support the orientation lock ${lock}.`)
113
+ }
114
+ shellWindow().__webSimScreenOrientation = { lock, held: held(lock) }
115
+ getHost().setOrientationLock(held(lock))
116
+ }
117
+
118
+ /** iOS: an array of orientations. Android: an `ActivityInfo.SCREEN_ORIENTATION_*` constant. */
119
+ async lockPlatformAsync(value: number[] | number) {
120
+ let orientation: SimOrientation | null = null
121
+ if (Array.isArray(value)) {
122
+ const portrait = value.every((item) => item === Orientation.PORTRAIT_UP || item === Orientation.PORTRAIT_DOWN)
123
+ const landscape = value.every((item) => item === Orientation.LANDSCAPE_LEFT || item === Orientation.LANDSCAPE_RIGHT)
124
+ orientation = value.length === 0 ? null : portrait ? 'portrait' : landscape ? 'landscape' : null
125
+ } else {
126
+ orientation = [1, 7, 9, 12].includes(value) ? 'portrait' : [0, 6, 8, 11].includes(value) ? 'landscape' : null
127
+ }
128
+ shellWindow().__webSimScreenOrientation = { lock: Lock.OTHER, held: orientation, platformLock: value }
129
+ getHost().setOrientationLock(orientation)
130
+ }
131
+
132
+ async unlockAsync() {
133
+ shellWindow().__webSimScreenOrientation = { lock: Lock.DEFAULT, held: null }
134
+ getHost().setOrientationLock(null)
135
+ }
136
+
137
+ async getOrientationAsync() {
138
+ return currentOrientation()
139
+ }
140
+
141
+ async getOrientationLockAsync() {
142
+ return currentLock()
143
+ }
144
+
145
+ async getPlatformOrientationLockAsync() {
146
+ const lock = currentLock()
147
+ const kept = shellWindow().__webSimScreenOrientation
148
+ if (lock === Lock.OTHER && kept?.platformLock !== undefined) {
149
+ return kept.platformLock
150
+ }
151
+ if (getState().device.platform === 'android') {
152
+ // ActivityInfo.SCREEN_ORIENTATION_*: UNSPECIFIED -1, PORTRAIT 1, LANDSCAPE 0, SENSOR_PORTRAIT 7, SENSOR_LANDSCAPE 6.
153
+ const constants: Record<number, number> = { [Lock.PORTRAIT]: 7, [Lock.PORTRAIT_UP]: 1, [Lock.PORTRAIT_DOWN]: 9, [Lock.LANDSCAPE]: 6, [Lock.LANDSCAPE_LEFT]: 0, [Lock.LANDSCAPE_RIGHT]: 8, [Lock.ALL]: 10 }
154
+ return constants[lock] ?? -1
155
+ }
156
+ const portrait = [Orientation.PORTRAIT_UP]
157
+ const landscape = [Orientation.LANDSCAPE_LEFT, Orientation.LANDSCAPE_RIGHT]
158
+ const masks: Record<number, number[]> = {
159
+ [Lock.PORTRAIT]: portrait,
160
+ [Lock.PORTRAIT_UP]: portrait,
161
+ [Lock.LANDSCAPE]: landscape,
162
+ [Lock.LANDSCAPE_LEFT]: [Orientation.LANDSCAPE_LEFT],
163
+ [Lock.LANDSCAPE_RIGHT]: [Orientation.LANDSCAPE_RIGHT],
164
+ }
165
+ return masks[lock] ?? [...portrait, ...landscape]
166
+ }
167
+
168
+ async supportsOrientationLockAsync(lock: number) {
169
+ return supports(lock)
170
+ }
171
+ }
172
+
173
+ export default registerWebModule(ExpoScreenOrientation, 'ExpoScreenOrientation')
@@ -0,0 +1,21 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-screen-orientation', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'locks rotate and hold the simulated device; rotating in the shell fires the change listeners',
7
+ files: { 'build/ExpoScreenOrientation.web.js': './ExpoScreenOrientation.ts' },
8
+ patch: [
9
+ {
10
+ // The JS layer picks the platform's options for `lockPlatformAsync` and its listener by `Platform.OS`, which
11
+ // is 'web' in a dependency: it should see the simulated device's.
12
+ file: 'build/ScreenOrientation.js',
13
+ replace: (source) =>
14
+ source.replace(
15
+ "import { Platform, UnavailabilityError } from 'expo';",
16
+ "import { UnavailabilityError } from 'expo';\nimport { platform as simPlatform } from 'web-sim/runtime';\nconst Platform = { get OS() { return simPlatform(); } };",
17
+ ),
18
+ },
19
+ ],
20
+ },
21
+ ])
@@ -0,0 +1,21 @@
1
+ import { showDialog } from 'web-sim/runtime'
2
+
3
+ /**
4
+ * Sharing from the app: the platform's share sheet, with generic targets. Resolves once the user picks a target or
5
+ * closes the sheet, as the device does. Nothing is shared into the app.
6
+ */
7
+ export default {
8
+ async isAvailableAsync() {
9
+ return true
10
+ },
11
+ async shareAsync(url: string, options: { dialogTitle?: string; mimeType?: string } = {}) {
12
+ await showDialog({ kind: 'share', url, title: options.dialogTitle, mimeType: options.mimeType })
13
+ },
14
+ getSharedPayloads() {
15
+ return []
16
+ },
17
+ async getResolvedSharedPayloadsAsync() {
18
+ return []
19
+ },
20
+ clearSharedPayloads() {},
21
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-sharing', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'the iOS share sheet or the Android sharesheet, with generic targets; no incoming shares',
7
+ files: { 'build/SharingNativeModule.web.js': './SharingNativeModule.ts' },
8
+ },
9
+ ])
@@ -0,0 +1,24 @@
1
+ import { platform, showDialog } from 'web-sim/runtime'
2
+
3
+ /**
4
+ * The message compose sheet, prefilled with the recipients, body and attachments. iOS reports whether the message was
5
+ * sent; Android hands it to the messaging app and never knows, so it always answers 'unknown'.
6
+ */
7
+ export default {
8
+ async isAvailableAsync() {
9
+ return true
10
+ },
11
+ async sendSMSAsync(addresses: string[], message: string, options: { attachments?: { uri: string; filename?: string }[] } = {}) {
12
+ const { button } = await showDialog({
13
+ kind: 'compose',
14
+ channel: 'sms',
15
+ recipients: addresses,
16
+ body: message,
17
+ attachments: options.attachments?.map((attachment) => attachment.filename ?? attachment.uri),
18
+ })
19
+ if (platform() === 'android') {
20
+ return { result: 'unknown' as const }
21
+ }
22
+ return { result: button === 1 ? ('sent' as const) : ('cancelled' as const) }
23
+ },
24
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-sms', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'a prefilled message compose sheet in the platform style',
7
+ files: { 'build/ExpoSMS.js': './ExpoSMS.ts' },
8
+ },
9
+ ])
@@ -0,0 +1,25 @@
1
+ import { getHost } from 'web-sim/runtime'
2
+
3
+ /**
4
+ * The splash screen from `app.json`, drawn by the shell over the app at launch. It hides on the app's first render,
5
+ * or, once `preventAutoHideAsync` is called, when the app hides it.
6
+ */
7
+ let options: { duration?: number; fade?: boolean } = {}
8
+
9
+ export function setOptions(next: { duration?: number; fade?: boolean }) {
10
+ options = { ...options, ...next }
11
+ }
12
+
13
+ export function preventAutoHideAsync(): Promise<boolean> {
14
+ getHost().preventAutoHideSplash()
15
+ return Promise.resolve(true)
16
+ }
17
+
18
+ export function hide() {
19
+ getHost().hideSplash(options)
20
+ }
21
+
22
+ export function hideAsync(): Promise<void> {
23
+ hide()
24
+ return Promise.resolve()
25
+ }
@@ -0,0 +1,5 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-splash-screen', [
4
+ { versions: '>=0.27 <59', replace: './SplashScreen.ts', note: 'draws the splash from app.json until hidden' },
5
+ ])