@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,104 @@
1
+ import { getState, hardware, sessionValue } from 'web-sim/runtime'
2
+
3
+ /** `DeviceType` from `Device.types`. */
4
+ const PHONE = 1
5
+
6
+ /** Android's `PackageManager` features a modern phone reports. */
7
+ const ANDROID_FEATURES = [
8
+ 'android.hardware.bluetooth',
9
+ 'android.hardware.bluetooth_le',
10
+ 'android.hardware.camera',
11
+ 'android.hardware.camera.any',
12
+ 'android.hardware.camera.autofocus',
13
+ 'android.hardware.camera.flash',
14
+ 'android.hardware.camera.front',
15
+ 'android.hardware.faketouch',
16
+ 'android.hardware.fingerprint',
17
+ 'android.hardware.location',
18
+ 'android.hardware.location.gps',
19
+ 'android.hardware.location.network',
20
+ 'android.hardware.microphone',
21
+ 'android.hardware.nfc',
22
+ 'android.hardware.screen.landscape',
23
+ 'android.hardware.screen.portrait',
24
+ 'android.hardware.sensor.accelerometer',
25
+ 'android.hardware.sensor.barometer',
26
+ 'android.hardware.sensor.compass',
27
+ 'android.hardware.sensor.gyroscope',
28
+ 'android.hardware.sensor.light',
29
+ 'android.hardware.sensor.proximity',
30
+ 'android.hardware.sensor.stepcounter',
31
+ 'android.hardware.sensor.stepdetector',
32
+ 'android.hardware.telephony',
33
+ 'android.hardware.touchscreen',
34
+ 'android.hardware.touchscreen.multitouch',
35
+ 'android.hardware.usb.host',
36
+ 'android.hardware.wifi',
37
+ 'android.hardware.wifi.direct',
38
+ 'android.software.webview',
39
+ ]
40
+
41
+ /** When the simulated phone booted: a few days before the shell opened, the same for every copy of this module. */
42
+ function bootTime(): number {
43
+ return sessionValue('expo-device:boot', () => Date.now() - Math.round((2 + Math.random() * 3) * 86_400_000))
44
+ }
45
+
46
+ /**
47
+ * The native module as the simulated phone answers. Android-only methods exist only on Android, so the JS layer
48
+ * throws `UnavailabilityError` for them on iOS, as it does on an iPhone.
49
+ */
50
+ function createModule() {
51
+ const { device } = getState()
52
+ const info = hardware(device)
53
+ const ios = device.platform === 'ios'
54
+ const common = {
55
+ isDevice: true,
56
+ brand: info.brand,
57
+ manufacturer: info.manufacturer,
58
+ modelName: info.modelName,
59
+ modelId: ios ? (info.modelId ?? null) : null,
60
+ designName: ios ? null : (info.designName ?? null),
61
+ productName: ios ? null : (info.productName ?? null),
62
+ deviceType: PHONE,
63
+ deviceYearClass: info.yearClass,
64
+ totalMemory: info.totalMemory,
65
+ supportedCpuArchitectures: info.cpuArchitectures,
66
+ osName: ios ? 'iOS' : 'Android',
67
+ osVersion: ios ? device.osVersion : (info.osRelease ?? device.osVersion),
68
+ osBuildId: info.osBuildId,
69
+ osInternalBuildId: info.osBuildId,
70
+ osBuildFingerprint: ios ? null : (info.osBuildFingerprint ?? null),
71
+ platformApiLevel: ios ? null : Number(device.osVersion),
72
+ // iOS 16 and later give apps without the entitlement the generic name.
73
+ deviceName: ios ? 'iPhone' : info.modelName,
74
+ async getDeviceTypeAsync() {
75
+ return PHONE
76
+ },
77
+ async getUptimeAsync() {
78
+ return Date.now() - bootTime()
79
+ },
80
+ async isRootedExperimentalAsync() {
81
+ return false
82
+ },
83
+ }
84
+ if (ios) {
85
+ return common
86
+ }
87
+ return {
88
+ ...common,
89
+ async getMaxMemoryAsync() {
90
+ return 512 * 1024 * 1024
91
+ },
92
+ async isSideLoadingEnabledAsync() {
93
+ return false
94
+ },
95
+ async getPlatformFeaturesAsync() {
96
+ return ANDROID_FEATURES
97
+ },
98
+ async hasPlatformFeatureAsync(feature: string) {
99
+ return ANDROID_FEATURES.includes(feature)
100
+ },
101
+ }
102
+ }
103
+
104
+ export default createModule()
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-device', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'reports the simulated phone: model, OS and build, memory, CPU',
7
+ files: { 'build/ExpoDevice.web.js': './ExpoDevice.ts' },
8
+ },
9
+ ])
@@ -0,0 +1,9 @@
1
+ 'use client'
2
+ import { View, type ViewProps } from 'react-native'
3
+
4
+ /**
5
+ * Groups glass views. On iOS nearby glass shapes melt into each other; here they stay separate, each drawn as glass.
6
+ */
7
+ export default function GlassContainer({ spacing: _spacing, ...props }: ViewProps & { spacing?: number }) {
8
+ return <View {...props} />
9
+ }
@@ -0,0 +1,95 @@
1
+ 'use client'
2
+ import { useState } from 'react'
3
+ import { type ColorValue, View, type ViewProps, type ViewStyle } from 'react-native'
4
+ import { type SimState, useSimState } from 'web-sim/runtime'
5
+
6
+ type GlassStyle = 'clear' | 'regular' | 'none'
7
+
8
+ type GlassViewProps = {
9
+ glassEffectStyle?: GlassStyle | { style: GlassStyle; animate?: boolean; animationDuration?: number }
10
+ tintColor?: ColorValue
11
+ isInteractive?: boolean
12
+ colorScheme?: 'auto' | 'light' | 'dark'
13
+ } & ViewProps
14
+
15
+ /** As `isLiquidGlassAvailable` answers: iOS 26 and later. */
16
+ function liquidGlass(state: SimState): boolean {
17
+ return state.device.platform === 'ios' && Number.parseFloat(state.device.osVersion) >= 26
18
+ }
19
+
20
+ /**
21
+ * The look of iOS's liquid glass: what is behind it blurred and saturated, a faint fill, bright edges where light
22
+ * catches the rim, a sheen across the face, and a soft shadow under it.
23
+ */
24
+ function glass(style: GlassStyle, dark: boolean, tint: ColorValue | undefined, pressed: boolean): Record<string, unknown> {
25
+ const clear = style === 'clear'
26
+ const rim = dark ? 0.32 : 0.7
27
+ const layers = [
28
+ `linear-gradient(140deg, rgba(255,255,255,${dark ? 0.16 : 0.32}) 0%, rgba(255,255,255,0.04) 38%, rgba(255,255,255,0) 62%, rgba(255,255,255,${dark ? 0.06 : 0.14}) 100%)`,
29
+ ]
30
+ if (typeof tint === 'string') {
31
+ layers.push(`linear-gradient(color-mix(in srgb, ${tint} ${clear ? 30 : 50}%, transparent), color-mix(in srgb, ${tint} ${clear ? 30 : 50}%, transparent))`)
32
+ }
33
+ return {
34
+ backgroundColor: clear ? (dark ? 'rgba(30,30,34,0.12)' : 'rgba(255,255,255,0.08)') : dark ? 'rgba(38,38,42,0.42)' : 'rgba(250,250,252,0.32)',
35
+ experimental_backgroundImage: layers.join(', '),
36
+ backdropFilter: `blur(${clear ? 3 : 16}px) saturate(${clear ? 150 : 190}%) brightness(${pressed ? 1.18 : dark ? 0.96 : 1.06})`,
37
+ boxShadow: [
38
+ `inset 0 1px 1px rgba(255,255,255,${rim})`,
39
+ `inset 0 -1px 1px rgba(255,255,255,${rim * 0.35})`,
40
+ `inset 1px 0 1px rgba(255,255,255,${rim * 0.4})`,
41
+ `inset -1px 0 1px rgba(255,255,255,${rim * 0.4})`,
42
+ `inset 0 0 0 0.5px rgba(255,255,255,${dark ? 0.14 : 0.4})`,
43
+ `0 8px 24px rgba(0,0,0,${dark ? 0.35 : 0.12})`,
44
+ ].join(', '),
45
+ transform: pressed ? [{ scale: 1.03 }] : undefined,
46
+ }
47
+ }
48
+
49
+ export default function GlassView({
50
+ glassEffectStyle = 'regular',
51
+ tintColor,
52
+ isInteractive = false,
53
+ colorScheme = 'auto',
54
+ style,
55
+ onPointerDown,
56
+ onPointerUp,
57
+ onPointerCancel,
58
+ ...props
59
+ }: GlassViewProps) {
60
+ const state = useSimState()
61
+ const [pressed, setPressed] = useState(false)
62
+ const config = typeof glassEffectStyle === 'string' ? { style: glassEffectStyle } : glassEffectStyle
63
+ if (!liquidGlass(state) || config.style === 'none') {
64
+ return <View {...props} style={style} onPointerDown={onPointerDown} onPointerUp={onPointerUp} onPointerCancel={onPointerCancel} />
65
+ }
66
+ const dark = colorScheme === 'auto' ? state.appAppearance === 'dark' : colorScheme === 'dark'
67
+ const animate = typeof glassEffectStyle === 'object' && glassEffectStyle.animate
68
+ const transition = {
69
+ transitionProperty: 'background-color, backdrop-filter, box-shadow, transform',
70
+ transitionDuration: `${animate ? Math.round((glassEffectStyle.animationDuration ?? 0.35) * 1000) : isInteractive ? 160 : 0}ms`,
71
+ }
72
+ const press = (down: boolean) => {
73
+ if (isInteractive) {
74
+ setPressed(down)
75
+ }
76
+ }
77
+ return (
78
+ <View
79
+ {...props}
80
+ style={[{ ...glass(config.style, dark, tintColor, pressed && isInteractive), ...transition } as ViewStyle, style]}
81
+ onPointerDown={(event) => {
82
+ press(true)
83
+ onPointerDown?.(event)
84
+ }}
85
+ onPointerUp={(event) => {
86
+ press(false)
87
+ onPointerUp?.(event)
88
+ }}
89
+ onPointerCancel={(event) => {
90
+ press(false)
91
+ onPointerCancel?.(event)
92
+ }}
93
+ />
94
+ )
95
+ }
@@ -0,0 +1,14 @@
1
+ import { getState, type SimState } from 'web-sim/runtime'
2
+
3
+ /** Liquid glass came with iOS 26. Android has none, and the module draws a plain view there. */
4
+ export function liquidGlass(state: SimState = getState()): boolean {
5
+ return state.device.platform === 'ios' && Number.parseFloat(state.device.osVersion) >= 26
6
+ }
7
+
8
+ export function isLiquidGlassAvailable(): boolean {
9
+ return liquidGlass()
10
+ }
11
+
12
+ export function isGlassEffectAPIAvailable(): boolean {
13
+ return liquidGlass()
14
+ }
@@ -0,0 +1,14 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-glass-effect', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'liquid glass drawn with backdrop blur on iOS 26; a plain view on Android, as on the device',
7
+ files: {
8
+ 'build/GlassView.js': './GlassView.tsx',
9
+ 'build/GlassContainer.js': './GlassContainer.tsx',
10
+ 'build/isLiquidGlassAvailable.js': './availability.ts',
11
+ 'build/isGlassEffectAPIAvailable.js': './availability.ts',
12
+ },
13
+ },
14
+ ])
@@ -0,0 +1,67 @@
1
+ import { haptic, type HapticKind } from 'web-sim/runtime'
2
+
3
+ export const NotificationFeedbackType = {
4
+ Success: 'success',
5
+ Warning: 'warning',
6
+ Error: 'error',
7
+ } as const
8
+ export type NotificationFeedbackType = (typeof NotificationFeedbackType)[keyof typeof NotificationFeedbackType]
9
+
10
+ export const ImpactFeedbackStyle = {
11
+ Light: 'light',
12
+ Medium: 'medium',
13
+ Heavy: 'heavy',
14
+ Soft: 'soft',
15
+ Rigid: 'rigid',
16
+ } as const
17
+ export type ImpactFeedbackStyle = (typeof ImpactFeedbackStyle)[keyof typeof ImpactFeedbackStyle]
18
+
19
+ export const AndroidHaptics = {
20
+ Confirm: 'confirm',
21
+ Reject: 'reject',
22
+ Gesture_Start: 'gesture-start',
23
+ Gesture_End: 'gesture-end',
24
+ Toggle_On: 'toggle-on',
25
+ Toggle_Off: 'toggle-off',
26
+ Clock_Tick: 'clock-tick',
27
+ Context_Click: 'context-click',
28
+ Drag_Start: 'drag-start',
29
+ Keyboard_Tap: 'keyboard-tap',
30
+ Keyboard_Press: 'keyboard-press',
31
+ Keyboard_Release: 'keyboard-release',
32
+ Long_Press: 'long-press',
33
+ Virtual_Key: 'virtual-key',
34
+ Virtual_Key_Release: 'virtual-key-release',
35
+ No_Haptics: 'no-haptics',
36
+ Segment_Tick: 'segment-tick',
37
+ Segment_Frequent_Tick: 'segment-frequent-tick',
38
+ Text_Handle_Move: 'text-handle-move',
39
+ } as const
40
+ export type AndroidHaptics = (typeof AndroidHaptics)[keyof typeof AndroidHaptics]
41
+
42
+ /** Android's named haptics, as the nearest of the kinds the event log names. */
43
+ const ANDROID_KINDS: Partial<Record<AndroidHaptics, HapticKind>> = {
44
+ [AndroidHaptics.Confirm]: 'success',
45
+ [AndroidHaptics.Reject]: 'error',
46
+ [AndroidHaptics.Long_Press]: 'heavy',
47
+ [AndroidHaptics.Toggle_On]: 'medium',
48
+ [AndroidHaptics.Toggle_Off]: 'medium',
49
+ }
50
+
51
+ export async function notificationAsync(type: NotificationFeedbackType = NotificationFeedbackType.Success) {
52
+ haptic(type, { method: 'notification' })
53
+ }
54
+
55
+ export async function impactAsync(style: ImpactFeedbackStyle = ImpactFeedbackStyle.Medium) {
56
+ haptic(style, { method: 'impact' })
57
+ }
58
+
59
+ export async function selectionAsync() {
60
+ haptic('selection', { method: 'selection' })
61
+ }
62
+
63
+ export async function performAndroidHapticsAsync(type: AndroidHaptics) {
64
+ if (type !== AndroidHaptics.No_Haptics) {
65
+ haptic(ANDROID_KINDS[type] ?? 'light', { method: 'android', type })
66
+ }
67
+ }
@@ -0,0 +1,5 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-haptics', [
4
+ { versions: '>=12 <59', replace: './Haptics.ts', note: 'haptics recorded in the event log, one entry per call' },
5
+ ])
@@ -0,0 +1,40 @@
1
+ import { platform, showDialog } from 'web-sim/runtime'
2
+
3
+ /**
4
+ * The mail compose sheet, prefilled from the options. iOS reports sent, saved or cancelled; Android hands the mail to
5
+ * the mail app and always answers as if it were sent.
6
+ */
7
+ type Options = {
8
+ recipients?: string[]
9
+ ccRecipients?: string[]
10
+ bccRecipients?: string[]
11
+ subject?: string
12
+ body?: string
13
+ isHtml?: boolean
14
+ attachments?: string[]
15
+ }
16
+
17
+ export default {
18
+ getClients() {
19
+ return platform() === 'ios' ? [{ label: 'Mail', url: 'message://' }] : [{ label: 'Gmail', packageName: 'com.google.android.gm' }]
20
+ },
21
+ async isAvailableAsync() {
22
+ return true
23
+ },
24
+ async composeAsync(options: Options) {
25
+ const { button } = await showDialog({
26
+ kind: 'compose',
27
+ channel: 'mail',
28
+ recipients: options.recipients ?? [],
29
+ ccRecipients: options.ccRecipients,
30
+ bccRecipients: options.bccRecipients,
31
+ subject: options.subject,
32
+ body: options.body,
33
+ attachments: options.attachments,
34
+ })
35
+ if (platform() === 'android') {
36
+ return { status: 'sent' }
37
+ }
38
+ return { status: button === 1 ? 'sent' : button === 2 ? 'saved' : 'cancelled' }
39
+ },
40
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-mail-composer', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'a prefilled mail compose sheet in the platform style, instead of opening a mailto: link',
7
+ files: { 'build/ExpoMailComposer.web.js': './ExpoMailComposer.ts' },
8
+ },
9
+ ])
@@ -0,0 +1,44 @@
1
+ 'use client'
2
+ import { type ColorValue, View, type ViewProps } from 'react-native'
3
+
4
+ type MeshGradientViewProps = {
5
+ columns?: number
6
+ rows?: number
7
+ points?: number[][]
8
+ colors?: ColorValue[]
9
+ smoothsColors?: boolean
10
+ ignoresSafeArea?: boolean
11
+ mask?: boolean
12
+ resolution?: { x?: number; y?: number }
13
+ } & ViewProps
14
+
15
+ /**
16
+ * An approximation of SwiftUI's `MeshGradient`: each point of the grid is a radial gradient of its colour, fading out
17
+ * over about one cell, layered over the average of the colours. Close enough to read as the same gradient; the exact
18
+ * bilinear blend across cells isn't reproduced.
19
+ */
20
+ function meshBackground(columns: number, rows: number, points: number[][], colors: string[]): string {
21
+ const reach = Math.round(Math.max(100 / Math.max(columns - 1, 1), 100 / Math.max(rows - 1, 1)) * 1.1)
22
+ const layers = points.flatMap((point, index) => {
23
+ const color = colors[index]
24
+ if (color === undefined || point.length < 2) {
25
+ return []
26
+ }
27
+ return [`radial-gradient(circle at ${point[0] * 100}% ${point[1] * 100}%, ${color} 0%, transparent ${reach}%)`]
28
+ })
29
+ return layers.join(', ')
30
+ }
31
+
32
+ export default function MeshGradientView({ columns = 0, rows = 0, points = [], colors = [], mask, children, style, ...rest }: MeshGradientViewProps) {
33
+ const strings = colors.filter((color): color is string => typeof color === 'string')
34
+ const base = strings[Math.floor(strings.length / 2)] ?? 'transparent'
35
+ const image = meshBackground(columns, rows, points, strings)
36
+ return (
37
+ <View
38
+ {...rest}
39
+ style={[style, { backgroundColor: mask === true ? undefined : base, experimental_backgroundImage: mask === true ? undefined : image } as never]}
40
+ >
41
+ {children}
42
+ </View>
43
+ )
44
+ }
@@ -0,0 +1,9 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-mesh-gradient', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: 'the mesh drawn with CSS radial gradients, one per point; the package has no web build',
7
+ files: { 'build/MeshGradientView.js': './MeshGradientView.tsx' },
8
+ },
9
+ ])
@@ -0,0 +1,12 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-modules-core', [
4
+ {
5
+ versions: '>=1',
6
+ note: 'type-only imports esbuild rejects',
7
+ patch: [
8
+ // It imports TypeScript types as values. Babel leaves them undefined; esbuild refuses to bundle them.
9
+ { file: 'build/ts-declarations/global.js', replace: () => '' },
10
+ ],
11
+ },
12
+ ])
@@ -0,0 +1,29 @@
1
+ import { NativeModule, registerWebModule } from 'expo'
2
+ import { getHost } from 'web-sim/runtime'
3
+
4
+ /**
5
+ * Android's navigation bar module: the style (the colour of the handle or buttons) and visibility go to the drawn
6
+ * navigation bar. Since SDK 54 apps draw edge to edge, so there is no background colour to set.
7
+ */
8
+ type Visibility = 'visible' | 'hidden'
9
+
10
+ class ExpoNavigationBar extends NativeModule<{ 'ExpoNavigationBar.didChange': (event: { visibility: Visibility; rawVisibility: number }) => void }> {
11
+ async setStyle(style: 'light' | 'dark') {
12
+ getHost().setNavigationBar({ style })
13
+ }
14
+
15
+ async setHidden(hidden: boolean) {
16
+ const before = getHost().getNavigationBar().hidden
17
+ getHost().setNavigationBar({ hidden })
18
+ if (before !== hidden) {
19
+ // View.SYSTEM_UI_FLAG_HIDE_NAVIGATION is 2.
20
+ this.emit('ExpoNavigationBar.didChange', { visibility: hidden ? 'hidden' : 'visible', rawVisibility: hidden ? 2 : 0 })
21
+ }
22
+ }
23
+
24
+ async getVisibilityAsync(): Promise<Visibility> {
25
+ return getHost().getNavigationBar().hidden ? 'hidden' : 'visible'
26
+ }
27
+ }
28
+
29
+ export default registerWebModule(ExpoNavigationBar, 'ExpoNavigationBar')
@@ -0,0 +1,43 @@
1
+ import { platform } from 'web-sim/runtime'
2
+ // Resolved inside the package: its Android JS layer, which a browser never loads, and the stub every other platform
3
+ // gets.
4
+ // @ts-expect-error -- a file of the package, not of this folder
5
+ import * as android from './NavigationBar.android.js'
6
+ // @ts-expect-error -- the file this one replaces
7
+ import * as other from 'web-sim:original'
8
+
9
+ /**
10
+ * expo-navigation-bar's JS layer for the simulated platform: Android's, driving the drawn navigation bar through the
11
+ * native module, or the stub iOS gets, which warns and does nothing.
12
+ */
13
+ type Layer = typeof import('expo-navigation-bar')
14
+
15
+ function layer(): Layer {
16
+ return (platform() === 'android' ? android : other) as Layer
17
+ }
18
+
19
+ export function NavigationBar(props: Parameters<Layer['NavigationBar']>[0]) {
20
+ // The platform is fixed for a run: switching it reloads the app.
21
+ return layer().NavigationBar(props)
22
+ }
23
+ NavigationBar.setStyle = (style: Parameters<Layer['setStyle']>[0]) => layer().NavigationBar.setStyle(style)
24
+ NavigationBar.setHidden = (hidden: boolean) =>
25
+ (layer().NavigationBar as unknown as { setHidden?: (hidden: boolean) => void }).setHidden?.(hidden)
26
+
27
+ export const setStyle = NavigationBar.setStyle
28
+
29
+ export function addVisibilityListener(listener: Parameters<Layer['addVisibilityListener']>[0]) {
30
+ return layer().addVisibilityListener(listener)
31
+ }
32
+
33
+ export function setVisibilityAsync(visibility: Parameters<Layer['setVisibilityAsync']>[0]) {
34
+ return layer().setVisibilityAsync(visibility)
35
+ }
36
+
37
+ export function getVisibilityAsync() {
38
+ return layer().getVisibilityAsync()
39
+ }
40
+
41
+ export function useVisibility() {
42
+ return layer().useVisibility()
43
+ }
@@ -0,0 +1,12 @@
1
+ import { defineOverrides } from '../../src/node/overrides/define.ts'
2
+
3
+ export default defineOverrides('expo-navigation-bar', [
4
+ {
5
+ versions: '>=58 <59',
6
+ note: "Android's JS layer on Android, driving the drawn navigation bar's style and visibility; nothing on iOS",
7
+ files: {
8
+ 'build/NavigationBar.js': './NavigationBar.ts',
9
+ 'build/ExpoNavigationBar.js': './ExpoNavigationBar.ts',
10
+ },
11
+ },
12
+ ])
@@ -0,0 +1,74 @@
1
+ import { createContext, use, useEffect, useId, useState } from 'react'
2
+ // The package's own navigation core, for the screen this navigator sits in.
3
+ // @ts-expect-error -- a file of the package, not of this folder
4
+ import { NavigationContext } from '../../core'
5
+ // @ts-expect-error -- the file this one replaces
6
+ import { NativeStackView as Original } from 'web-sim:original'
7
+ import { requestAutoHidden } from '../../plugins/home-indicator/requests.ts'
8
+ import { requestStatusBarStyle, type ScreenStatusBarStyle } from './statusBarRequests.ts'
9
+
10
+ type Navigation = {
11
+ isFocused(): boolean
12
+ addListener(event: 'focus' | 'blur', listener: () => void): () => void
13
+ }
14
+
15
+ type Props = {
16
+ state: { index: number; routes: { key: string; name: string }[] }
17
+ descriptors: Record<string, { options: { autoHideHomeIndicator?: boolean; statusBarStyle?: ScreenStatusBarStyle } }>
18
+ }
19
+
20
+ /** How many native stacks this one sits in. */
21
+ const Depth = createContext(0)
22
+
23
+ /**
24
+ * The web native stack as it is, which ignores `autoHideHomeIndicator` and `statusBarStyle`, plus what iOS does with
25
+ * them: the focused screen of the deepest focused stack decides whether the home indicator auto-hides, and the deepest
26
+ * focused screen that sets a status bar style sets it.
27
+ */
28
+ export function NativeStackView(props: Props) {
29
+ const depth = use(Depth)
30
+ const parent = use(NavigationContext) as Navigation | undefined
31
+ const focused = useParentFocused(parent)
32
+ const id = useId()
33
+ const route = props.state.routes[props.state.index]
34
+ const options = route === undefined ? undefined : props.descriptors[route.key]?.options
35
+ const autoHidden = options?.autoHideHomeIndicator
36
+ const statusBarStyle = options?.statusBarStyle
37
+ useEffect(() => {
38
+ requestAutoHidden(id, { depth, focused, autoHidden, source: route?.name ?? '' })
39
+ }, [id, depth, focused, autoHidden, route?.name])
40
+ useEffect(() => {
41
+ requestStatusBarStyle(id, { depth, focused, style: statusBarStyle })
42
+ }, [id, depth, focused, statusBarStyle])
43
+ useEffect(
44
+ () => () => {
45
+ requestAutoHidden(id, null)
46
+ requestStatusBarStyle(id, null)
47
+ },
48
+ [id],
49
+ )
50
+ return (
51
+ <Depth value={depth + 1}>
52
+ <Original {...props} />
53
+ </Depth>
54
+ )
55
+ }
56
+
57
+ /** Whether the screen this stack sits in is focused: the root stack always is. */
58
+ function useParentFocused(parent: Navigation | undefined): boolean {
59
+ const [focused, setFocused] = useState(() => parent?.isFocused() ?? true)
60
+ useEffect(() => {
61
+ if (parent === undefined) {
62
+ setFocused(true)
63
+ return
64
+ }
65
+ setFocused(parent.isFocused())
66
+ const offFocus = parent.addListener('focus', () => setFocused(true))
67
+ const offBlur = parent.addListener('blur', () => setFocused(false))
68
+ return () => {
69
+ offFocus()
70
+ offBlur()
71
+ }
72
+ }, [parent])
73
+ return focused
74
+ }