@a16n/web-sim 0.0.0-stage → 0.1.1

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 (281) 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 +157 -0
  71. package/overrides/react-native-web/useElementLayout.ts +152 -0
  72. package/package.json +80 -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 +129 -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 +76 -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 +23 -0
  250. package/src/devices/catalog.ts +223 -0
  251. package/src/devices/types.ts +83 -0
  252. package/src/node/appInfo.ts +188 -0
  253. package/src/node/appSource.ts +140 -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/fonts.ts +377 -0
  261. package/src/node/index.ts +5 -0
  262. package/src/node/overrides/define.ts +56 -0
  263. package/src/node/overrides/packages.ts +136 -0
  264. package/src/node/overrides/platformPatch.ts +56 -0
  265. package/src/node/overrides/plugin.ts +169 -0
  266. package/src/node/overrides/registry.ts +258 -0
  267. package/src/node/paths.ts +18 -0
  268. package/src/node/platform.ts +171 -0
  269. package/src/node/plugins.ts +98 -0
  270. package/src/node/proxy.ts +421 -0
  271. package/src/node/server.ts +254 -0
  272. package/src/node/worklets.ts +86 -0
  273. package/src/plugin/index.ts +33 -0
  274. package/src/plugin/types.ts +127 -0
  275. package/src/plugin/ui.tsx +562 -0
  276. package/src/runtime/clock.ts +112 -0
  277. package/src/runtime/draw.ts +196 -0
  278. package/src/runtime/index.ts +519 -0
  279. package/src/runtime/media.ts +379 -0
  280. package/src/runtime/records.ts +76 -0
  281. package/src/runtime/timezone.ts +81 -0
@@ -0,0 +1,44 @@
1
+ import { useEffect } from 'react'
2
+ import { getState, setStatusBar } from 'web-sim/runtime'
3
+
4
+ type Style = 'auto' | 'inverted' | 'light' | 'dark'
5
+
6
+ /**
7
+ * `light` means light content, for dark backgrounds. `inverted` is the opposite of what `auto` would pick.
8
+ */
9
+ function resolve(style: Style): 'auto' | 'light' | 'dark' {
10
+ if (style === 'inverted') {
11
+ return getState().appAppearance === 'dark' ? 'dark' : 'light'
12
+ }
13
+ return style
14
+ }
15
+
16
+ export function StatusBar({ style = 'auto', hidden }: { style?: Style; hidden?: boolean }) {
17
+ useEffect(() => {
18
+ setStatusBar({ style: resolve(style), hidden })
19
+ }, [style, hidden])
20
+ return null
21
+ }
22
+
23
+ export function setStatusBarStyle(style: Style) {
24
+ setStatusBar({ style: resolve(style) })
25
+ }
26
+
27
+ export function setStatusBarHidden(hidden: boolean) {
28
+ setStatusBar({ hidden })
29
+ }
30
+
31
+ export function setStatusBarBackgroundColor() {}
32
+ export function setStatusBarNetworkActivityIndicatorVisible() {}
33
+ export function setStatusBarTranslucent() {}
34
+
35
+ /**
36
+ * The edge of iPhone Duo's vertical status bar (iOS 27.1). No simulated device has one, so the bar is always
37
+ * horizontal. expo-router's headers read it from version 58.
38
+ */
39
+ export function useVerticalBarEdgeIOS(): null {
40
+ return null
41
+ }
42
+
43
+ StatusBar.getVerticalBarEdgeIOS = (): null => null
44
+ StatusBar.setVerticalBarBehaviorIOS = () => {}
@@ -0,0 +1,5 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-status-bar', [
4
+ { versions: '>=1', replace: './StatusBar.tsx', note: 'drives the simulated status bar' },
5
+ ])
@@ -0,0 +1,18 @@
1
+ import { platform, showDialog } from 'web-sim/runtime'
2
+
3
+ /**
4
+ * The store's in-app review: the App Store's rating prompt on iOS, Google Play's review sheet on Android. Always
5
+ * shown, as in a development build; a store build may show it at most three times a year.
6
+ */
7
+ export default {
8
+ async isAvailableAsync() {
9
+ return true
10
+ },
11
+ async requestReview() {
12
+ const shown = showDialog({ kind: 'store-review' })
13
+ // iOS returns as soon as it asks for the prompt; Play's flow resolves once the user is done with it.
14
+ if (platform() === 'android') {
15
+ await shown
16
+ }
17
+ },
18
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-store-review', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: "the App Store rating prompt or Google Play's in-app review sheet",
7
+ files: { 'build/ExpoStoreReview.js': './ExpoStoreReview.ts' },
8
+ },
9
+ ])
@@ -0,0 +1,192 @@
1
+ import type { CSSProperties, ReactNode } from 'react'
2
+ import { type ColorValue, View, type ViewProps } from 'react-native'
3
+ import { useSimState } from 'web-sim/runtime'
4
+ // Compiled in the package's `build` folder, where this resolves to the codepoints the package ships.
5
+ // @ts-ignore
6
+ import codepoints from './android/symbols.json'
7
+
8
+ type SymbolWeight = 'unspecified' | 'ultraLight' | 'thin' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'heavy' | 'black'
9
+ type SymbolType = 'monochrome' | 'hierarchical' | 'palette' | 'multicolor'
10
+ type AnimationSpec = { effect?: { type: 'bounce' | 'pulse' | 'scale' }; repeating?: boolean; repeatCount?: number; speed?: number }
11
+
12
+ type SymbolViewProps = {
13
+ name: string | { ios?: string; android?: string; web?: string }
14
+ fallback?: ReactNode
15
+ type?: SymbolType
16
+ scale?: 'default' | 'unspecified' | 'small' | 'medium' | 'large'
17
+ weight?: SymbolWeight | { ios: SymbolWeight; android: unknown }
18
+ colors?: ColorValue | ColorValue[]
19
+ size?: number
20
+ tintColor?: ColorValue
21
+ resizeMode?: string
22
+ animationSpec?: AnimationSpec
23
+ } & ViewProps
24
+
25
+ const FONT_FAMILY = 'Material Symbols Rounded'
26
+ const FONT_CSS =
27
+ 'https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block'
28
+
29
+ /**
30
+ * The SF Symbols apps use most, by their nearest Material Symbol. A name ending in `.fill` uses the same symbol,
31
+ * filled. SF Symbols themselves are licensed only for Apple platforms, so none are drawn here.
32
+ */
33
+ const SF_TO_MATERIAL: Record<string, string> = {
34
+ house: 'home', gear: 'settings', gearshape: 'settings', 'gearshape.2': 'settings', heart: 'favorite',
35
+ magnifyingglass: 'search', plus: 'add', 'plus.circle': 'add_circle', 'plus.square': 'add_box', minus: 'remove',
36
+ 'minus.circle': 'do_not_disturb_on', xmark: 'close', 'xmark.circle': 'cancel', checkmark: 'check',
37
+ 'checkmark.circle': 'check_circle', 'checkmark.seal': 'verified', star: 'star', person: 'person',
38
+ 'person.circle': 'account_circle', 'person.crop.circle': 'account_circle', 'person.2': 'group',
39
+ 'person.3': 'groups', 'person.badge.plus': 'person_add', bell: 'notifications', 'bell.slash': 'notifications_off',
40
+ trash: 'delete', 'square.and.arrow.up': 'ios_share', 'square.and.arrow.down': 'download', paperplane: 'send',
41
+ envelope: 'mail', phone: 'call', message: 'chat_bubble', 'bubble.left': 'chat_bubble',
42
+ 'bubble.left.and.bubble.right': 'forum', camera: 'photo_camera', photo: 'image', 'photo.on.rectangle': 'photo_library',
43
+ calendar: 'calendar_today', clock: 'schedule', alarm: 'alarm', location: 'near_me', map: 'map',
44
+ mappin: 'location_on', 'mappin.and.ellipse': 'location_on', bookmark: 'bookmark', cart: 'shopping_cart',
45
+ bag: 'shopping_bag', creditcard: 'credit_card', lock: 'lock', 'lock.open': 'lock_open', key: 'key', eye: 'visibility',
46
+ 'eye.slash': 'visibility_off', 'info.circle': 'info', 'exclamationmark.triangle': 'warning',
47
+ 'exclamationmark.circle': 'error', 'questionmark.circle': 'help', 'chevron.right': 'chevron_right',
48
+ 'chevron.left': 'chevron_left', 'chevron.up': 'expand_less', 'chevron.down': 'expand_more',
49
+ 'arrow.right': 'arrow_forward', 'arrow.left': 'arrow_back', 'arrow.up': 'arrow_upward', 'arrow.down': 'arrow_downward',
50
+ 'arrow.up.right': 'north_east', 'arrow.up.right.square': 'open_in_new', 'arrow.clockwise': 'refresh',
51
+ 'arrow.counterclockwise': 'replay', 'arrow.triangle.2.circlepath': 'sync', 'arrow.uturn.backward': 'undo',
52
+ 'arrow.uturn.forward': 'redo', ellipsis: 'more_horiz', 'ellipsis.circle': 'more_horiz', 'line.3.horizontal': 'menu',
53
+ 'line.3.horizontal.decrease': 'filter_list', 'slider.horizontal.3': 'tune', 'list.bullet': 'format_list_bulleted',
54
+ 'square.grid.2x2': 'grid_view', pencil: 'edit', 'square.and.pencil': 'edit_square', doc: 'description',
55
+ 'doc.text': 'description', 'doc.on.doc': 'content_copy', 'square.on.square': 'content_copy', folder: 'folder',
56
+ link: 'link', paperclip: 'attach_file', mic: 'mic', 'mic.slash': 'mic_off', 'speaker.wave.2': 'volume_up',
57
+ 'speaker.slash': 'volume_off', play: 'play_arrow', pause: 'pause', stop: 'stop', forward: 'fast_forward',
58
+ backward: 'fast_rewind', 'music.note': 'music_note', video: 'videocam', wifi: 'wifi', 'battery.100': 'battery_full',
59
+ bolt: 'bolt', 'sun.max': 'light_mode', moon: 'dark_mode', cloud: 'cloud', flame: 'local_fire_department', leaf: 'eco',
60
+ globe: 'language', 'hand.thumbsup': 'thumb_up', 'hand.thumbsdown': 'thumb_down', gift: 'redeem', tag: 'sell',
61
+ flag: 'flag', 'chart.bar': 'bar_chart', 'chart.pie': 'pie_chart', 'cup.and.saucer': 'local_cafe',
62
+ 'fork.knife': 'restaurant', car: 'directions_car', airplane: 'flight', tray: 'inbox', archivebox: 'archive',
63
+ printer: 'print', qrcode: 'qr_code', faceid: 'face', touchid: 'fingerprint', sparkles: 'auto_awesome',
64
+ 'wand.and.stars': 'auto_fix_high', 'square.and.arrow.up.on.square': 'ios_share', 'house.circle': 'home',
65
+ 'rectangle.portrait.and.arrow.right': 'logout', 'person.crop.circle.badge.plus': 'person_add',
66
+ 'cart.badge.plus': 'add_shopping_cart', 'heart.text.square': 'favorite', 'safari': 'explore', 'compass.drawing': 'explore',
67
+ 'chevron.left.forwardslash.chevron.right': 'code', 'hammer': 'build', 'wrench': 'build', 'cube': 'deployed_code',
68
+ 'shippingbox': 'package_2', 'timer': 'timer', 'stopwatch': 'timer', 'hourglass': 'hourglass_empty',
69
+ }
70
+
71
+ const WEIGHTS: Record<SymbolWeight, number> = {
72
+ unspecified: 400, ultraLight: 100, thin: 200, light: 300, regular: 400, medium: 500, semibold: 600, bold: 700, heavy: 700, black: 700,
73
+ }
74
+
75
+ const SCALES = { default: 1, unspecified: 1, small: 0.84, medium: 1, large: 1.2 }
76
+
77
+ const symbols = codepoints as Record<string, number>
78
+
79
+ /** The Material Symbol to draw, and whether it is filled. */
80
+ function resolve(name: SymbolViewProps['name'], android: boolean): { symbol: string; fill: boolean } | null {
81
+ if (typeof name === 'object') {
82
+ // An iPhone draws the SF Symbol, so on iOS its nearest Material Symbol comes first.
83
+ const sf = !android && name.ios !== undefined ? resolve(name.ios, android) : null
84
+ if (sf !== null) {
85
+ return sf
86
+ }
87
+ const material = android ? (name.android ?? name.web) : (name.web ?? name.android)
88
+ if (material !== undefined && material in symbols) {
89
+ return { symbol: material, fill: false }
90
+ }
91
+ return name.ios === undefined ? null : resolve(name.ios, android)
92
+ }
93
+ const fill = /\.fill(?=$|\.)/.test(name)
94
+ let base = name.replace(/\.fill(?=$|\.)/g, '')
95
+ // `heart.circle` is drawn as `heart` when it has no entry of its own.
96
+ while (base !== '') {
97
+ const material = SF_TO_MATERIAL[base] ?? (base in symbols ? base : undefined)
98
+ if (material !== undefined) {
99
+ return { symbol: material, fill }
100
+ }
101
+ base = base.includes('.') ? base.slice(0, base.lastIndexOf('.')) : ''
102
+ }
103
+ return null
104
+ }
105
+
106
+ function ensureFont(): void {
107
+ if (document.getElementById('web-sim-material-symbols') !== null) {
108
+ return
109
+ }
110
+ const link = document.createElement('link')
111
+ link.id = 'web-sim-material-symbols'
112
+ link.rel = 'stylesheet'
113
+ link.href = FONT_CSS
114
+ document.head.appendChild(link)
115
+ const keyframes = document.createElement('style')
116
+ keyframes.textContent = `
117
+ @keyframes web-sim-symbol-bounce { 0%, 100% { transform: translateY(0) } 35% { transform: translateY(-18%) } 65% { transform: translateY(4%) } }
118
+ @keyframes web-sim-symbol-pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.35 } }
119
+ @keyframes web-sim-symbol-scale { 0%, 100% { transform: scale(1) } 50% { transform: scale(1.22) } }`
120
+ document.head.appendChild(keyframes)
121
+ }
122
+
123
+ function animation(spec: AnimationSpec | undefined): string | undefined {
124
+ const effect = spec?.effect?.type
125
+ if (effect === undefined) {
126
+ return undefined
127
+ }
128
+ const count = spec?.repeating ? 'infinite' : String(spec?.repeatCount ?? 1)
129
+ return `web-sim-symbol-${effect} ${0.9 / (spec?.speed ?? 1)}s ease-in-out ${count}`
130
+ }
131
+
132
+ function color(value: ColorValue | undefined): string | undefined {
133
+ return typeof value === 'string' ? value : undefined
134
+ }
135
+
136
+ export function SymbolView({
137
+ name,
138
+ fallback,
139
+ type = 'monochrome',
140
+ scale = 'default',
141
+ weight,
142
+ colors,
143
+ size = 24,
144
+ tintColor,
145
+ resizeMode: _resizeMode,
146
+ animationSpec,
147
+ style,
148
+ ...viewProps
149
+ }: SymbolViewProps) {
150
+ const { device, appAppearance: appearance } = useSimState()
151
+ const android = device.platform === 'android'
152
+ const resolved = resolve(name, android)
153
+ if (resolved === null) {
154
+ return <>{fallback}</>
155
+ }
156
+ ensureFont()
157
+ const palette = (Array.isArray(colors) ? colors : colors === undefined ? [] : [colors]).map(color)
158
+ const defaultColor = android ? (appearance === 'dark' ? '#AAC7FF' : '#415F91') : appearance === 'dark' ? '#0A84FF' : '#007AFF'
159
+ const primary = color(tintColor) ?? palette[0] ?? defaultColor
160
+ const wght = WEIGHTS[(typeof weight === 'object' ? weight.ios : weight) ?? 'regular'] ?? 400
161
+ const fontSize = size * SCALES[scale]
162
+ const glyph = String.fromCodePoint(symbols[resolved.symbol])
163
+ const layer = (fill: boolean, layerColor: string, opacity = 1): CSSProperties => ({
164
+ position: 'absolute',
165
+ inset: 0,
166
+ display: 'flex',
167
+ alignItems: 'center',
168
+ justifyContent: 'center',
169
+ fontFamily: `'${FONT_FAMILY}'`,
170
+ fontSize,
171
+ lineHeight: 1,
172
+ fontWeight: 'normal',
173
+ fontStyle: 'normal',
174
+ color: layerColor,
175
+ opacity,
176
+ fontVariationSettings: `'FILL' ${fill ? 1 : 0}, 'wght' ${wght}, 'GRAD' 0, 'opsz' ${Math.min(48, Math.max(20, fontSize))}`,
177
+ userSelect: 'none',
178
+ pointerEvents: 'none',
179
+ whiteSpace: 'nowrap',
180
+ })
181
+ // Material Symbols have one layer. Hierarchical and palette symbols are drawn as the filled shape, faint or in the
182
+ // second colour, under the outline.
183
+ const layered = type === 'hierarchical' || (type === 'palette' && palette.length > 1)
184
+ return (
185
+ <View {...viewProps} style={[{ width: size, height: size }, style]}>
186
+ <span aria-hidden style={{ position: 'absolute', inset: 0, animation: animation(animationSpec) }}>
187
+ {layered && <span style={layer(true, type === 'palette' ? (palette[1] ?? primary) : primary, type === 'palette' ? 1 : 0.3)}>{glyph}</span>}
188
+ <span style={layer(resolved.fill && !layered, primary)}>{glyph}</span>
189
+ </span>
190
+ </View>
191
+ )
192
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-symbols', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'symbols drawn from Material Symbols, with SF Symbol names mapped to their nearest Material ones',
7
+ files: { 'build/SymbolView.js': './SymbolView.tsx' },
8
+ },
9
+ ])
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The root view's background colour, which shows behind the app's views. The app's document is the device's screen,
3
+ * so it is the document's background. Read back in hex, as the device reports it, or null until it is set.
4
+ */
5
+ const SET = 'webSimSystemUiBackground'
6
+
7
+ function hex(color: string): string | null {
8
+ const match = /rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?\)/.exec(color)
9
+ if (match === null) {
10
+ return null
11
+ }
12
+ const [r, g, b] = [match[1], match[2], match[3]].map((part) => Math.round(Number(part)).toString(16).padStart(2, '0'))
13
+ const alpha = match[4] === undefined ? 1 : Number(match[4])
14
+ return `#${r}${g}${b}${alpha < 1 ? Math.round(alpha * 255).toString(16).padStart(2, '0') : ''}`.toUpperCase()
15
+ }
16
+
17
+ export default {
18
+ async getBackgroundColorAsync(): Promise<string | null> {
19
+ if (document.documentElement.dataset[SET] === undefined) {
20
+ return null
21
+ }
22
+ return hex(getComputedStyle(document.documentElement).backgroundColor)
23
+ },
24
+ async setBackgroundColorAsync(color: string | null) {
25
+ const root = document.documentElement
26
+ if (color === null) {
27
+ root.style.removeProperty('background-color')
28
+ delete root.dataset[SET]
29
+ return
30
+ }
31
+ root.style.backgroundColor = color
32
+ root.dataset[SET] = ''
33
+ },
34
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-system-ui', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: "the root view's background colour behind the app, read back in hex",
7
+ files: { 'build/ExpoSystemUI.web.js': './ExpoSystemUI.ts' },
8
+ },
9
+ ])
@@ -0,0 +1,39 @@
1
+ import { sessionValue } from 'web-sim/runtime'
2
+
3
+ export type RegisteredTask = { taskName: string; taskType: string; options: Record<string, unknown> }
4
+
5
+ /** The tasks the app has registered, shared with the modules that register them (expo-background-task). */
6
+ export function registeredTasks(): Map<string, RegisteredTask> {
7
+ return sessionValue('expo-task-manager.tasks', () => new Map<string, RegisteredTask>())
8
+ }
9
+
10
+ /**
11
+ * The native task manager's bookkeeping. The OS never wakes the simulated app in the background, so a registered
12
+ * task is listed but not run.
13
+ */
14
+ export default {
15
+ get EVENT_NAME() {
16
+ return 'TaskManager.executeTask'
17
+ },
18
+ addListener() {},
19
+ removeListeners() {},
20
+ async isAvailableAsync() {
21
+ return true
22
+ },
23
+ async isTaskRegisteredAsync(taskName: string) {
24
+ return registeredTasks().has(taskName)
25
+ },
26
+ async getTaskOptionsAsync(taskName: string) {
27
+ return registeredTasks().get(taskName)?.options ?? null
28
+ },
29
+ async getRegisteredTasksAsync() {
30
+ return [...registeredTasks().values()]
31
+ },
32
+ async unregisterTaskAsync(taskName: string) {
33
+ registeredTasks().delete(taskName)
34
+ },
35
+ async unregisterAllTasksAsync() {
36
+ registeredTasks().clear()
37
+ },
38
+ async notifyTaskFinishedAsync() {},
39
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-task-manager', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'registered tasks kept for the session, so the registration calls answer as on a device; tasks never run',
7
+ files: { 'build/ExpoTaskManager.web.js': './ExpoTaskManager.ts' },
8
+ },
9
+ ])
@@ -0,0 +1,30 @@
1
+ import { getPermission, platform, requestPermission } from 'web-sim/runtime'
2
+
3
+ const NO_ID = '00000000-0000-0000-0000-000000000000'
4
+
5
+ /** The advertising ID: iOS shares it only once tracking is allowed; Android always has one. */
6
+ function advertisingId(): string {
7
+ if (platform() === 'android') {
8
+ return '38400000-8cf0-11bd-b23e-10b96e40000d'
9
+ }
10
+ return getPermission('tracking').granted ? 'A1B2C3D4-E5F6-4711-8899-AABBCCDDEEFF' : NO_ID
11
+ }
12
+
13
+ /**
14
+ * The tracking module on the simulated phone. The module's JS layer answers for Android itself (granted, no prompt);
15
+ * on iOS the permission goes through the simulator's App Tracking Transparency prompt.
16
+ */
17
+ export default {
18
+ async getPermissionsAsync() {
19
+ return getPermission('tracking')
20
+ },
21
+ async requestPermissionsAsync() {
22
+ return requestPermission('tracking')
23
+ },
24
+ getAdvertisingId() {
25
+ return advertisingId()
26
+ },
27
+ async getAdvertisingIdAsync() {
28
+ return advertisingId()
29
+ },
30
+ }
@@ -0,0 +1,11 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+ import { simulatedPlatform } from '../../src/node/overrides/platformPatch.ts'
3
+
4
+ export default defineOverrides('expo-tracking-transparency', [
5
+ {
6
+ versions: '>=58 <59',
7
+ note: "iOS's App Tracking Transparency prompt; Android grants tracking without one",
8
+ files: { 'build/ExpoTrackingTransparency.js': './ExpoTrackingTransparency.ts' },
9
+ patch: [simulatedPlatform('build/TrackingTransparency.js')],
10
+ },
11
+ ])
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `VideoModule.js` has no web variant and calls these on the native module, which the web build doesn't define.
3
+ * Phones support Picture in Picture; the cache is a size the app sets and reads back.
4
+ */
5
+ let cacheSize = 1024 * 1024 * 1024
6
+
7
+ export default {
8
+ VideoThumbnail: () => {},
9
+ isPictureInPictureSupported: () => true,
10
+ async clearVideoCacheAsync() {},
11
+ async setVideoCacheSizeAsync(sizeBytes: number) {
12
+ cacheSize = sizeBytes
13
+ },
14
+ getCurrentVideoCacheSize: () => 0,
15
+ getVideoCacheSize: () => cacheSize,
16
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-video', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'the module functions its web build leaves out (Picture in Picture support, the video cache), which throw',
7
+ files: { 'build/ExpoVideo.web.js': './ExpoVideo.ts' },
8
+ },
9
+ ])
@@ -0,0 +1,87 @@
1
+ 'use client'
2
+ import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'
3
+ import { View, type ViewStyle } from 'react-native'
4
+
5
+ type LottieJson = { ip?: number; op?: number; fr?: number }
6
+
7
+ type LottieViewProps = {
8
+ source?: unknown
9
+ style?: ViewStyle
10
+ webStyle?: ViewStyle
11
+ speed?: number
12
+ loop?: boolean
13
+ autoPlay?: boolean
14
+ onAnimationLoaded?: () => void
15
+ onAnimationFinish?: (isCancelled: boolean) => void
16
+ onAnimationLoop?: () => void
17
+ }
18
+
19
+ /** The animation's length in milliseconds, when the source is Lottie JSON. */
20
+ function durationOf(source: unknown, speed: number): number | null {
21
+ if (typeof source !== 'object' || source === null) {
22
+ return null
23
+ }
24
+ const { ip = 0, op, fr } = source as LottieJson
25
+ return op === undefined || fr === undefined || fr <= 0 ? null : ((op - ip) / fr / Math.abs(speed || 1)) * 1000
26
+ }
27
+
28
+ /**
29
+ * Takes the animation's place and keeps its timing, without drawing it: lottie-react-native's web build needs
30
+ * @lottiefiles/dotlottie-react, which apps that ship only to phones don't install. It reports loaded at once and, for
31
+ * JSON sources, finishes (or loops) after the animation's length, so code waiting on `onAnimationFinish` goes on.
32
+ */
33
+ export const LottieView = forwardRef<unknown, LottieViewProps>(
34
+ ({ source, style, webStyle, speed = 1, loop = true, autoPlay = false, onAnimationLoaded, onAnimationFinish, onAnimationLoop }, ref) => {
35
+ const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
36
+ const callbacks = useRef({ onAnimationFinish, onAnimationLoop })
37
+ callbacks.current = { onAnimationFinish, onAnimationLoop }
38
+
39
+ const stop = () => {
40
+ if (timer.current !== null) {
41
+ clearTimeout(timer.current)
42
+ timer.current = null
43
+ }
44
+ }
45
+ const play = () => {
46
+ stop()
47
+ const duration = durationOf(source, speed)
48
+ if (duration === null) {
49
+ return
50
+ }
51
+ const tick = () => {
52
+ if (loop) {
53
+ callbacks.current.onAnimationLoop?.()
54
+ timer.current = setTimeout(tick, duration)
55
+ } else {
56
+ timer.current = null
57
+ callbacks.current.onAnimationFinish?.(false)
58
+ }
59
+ }
60
+ timer.current = setTimeout(tick, duration)
61
+ }
62
+
63
+ useEffect(() => {
64
+ onAnimationLoaded?.()
65
+ if (autoPlay) {
66
+ play()
67
+ }
68
+ return stop
69
+ // Restarts only for a new animation, as the native view does.
70
+ // eslint-disable-next-line react-hooks/exhaustive-deps
71
+ }, [source])
72
+
73
+ useImperativeHandle(ref, () => ({
74
+ play,
75
+ reset: stop,
76
+ pause: () => {
77
+ if (timer.current !== null) {
78
+ stop()
79
+ callbacks.current.onAnimationFinish?.(true)
80
+ }
81
+ },
82
+ resume: play,
83
+ }))
84
+
85
+ return <View style={[style, webStyle]} />
86
+ },
87
+ )
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('lottie-react-native', [
4
+ {
5
+ versions: '>=7.5 <7.6',
6
+ note: "a still stand-in: the web build needs @lottiefiles/dotlottie-react, an optional peer apps rarely install",
7
+ files: { 'lib/module/LottieView/index.web.js': './LottieView.tsx' },
8
+ },
9
+ ])