@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.
- package/README.md +13 -2
- package/bin/cli.ts +255 -0
- package/bin/web-sim.js +39 -0
- package/overrides/@backpackapp-io/react-native-toast/overrides.ts +15 -0
- package/overrides/@react-native-firebase/app/overrides.ts +34 -0
- package/overrides/@tiktok-for-business/react-native-sdk/NativeTiktokSdk.ts +29 -0
- package/overrides/@tiktok-for-business/react-native-sdk/overrides.ts +9 -0
- package/overrides/expo-application/ExpoApplication.ts +81 -0
- package/overrides/expo-application/overrides.ts +16 -0
- package/overrides/expo-background-task/ExpoBackgroundTaskModule.ts +30 -0
- package/overrides/expo-background-task/overrides.ts +9 -0
- package/overrides/expo-constants/ExponentConstants.ts +66 -0
- package/overrides/expo-constants/overrides.ts +9 -0
- package/overrides/expo-device/ExpoDevice.ts +104 -0
- package/overrides/expo-device/overrides.ts +9 -0
- package/overrides/expo-glass-effect/GlassContainer.tsx +9 -0
- package/overrides/expo-glass-effect/GlassView.tsx +95 -0
- package/overrides/expo-glass-effect/availability.ts +14 -0
- package/overrides/expo-glass-effect/overrides.ts +14 -0
- package/overrides/expo-haptics/Haptics.ts +67 -0
- package/overrides/expo-haptics/overrides.ts +5 -0
- package/overrides/expo-mail-composer/ExpoMailComposer.ts +40 -0
- package/overrides/expo-mail-composer/overrides.ts +9 -0
- package/overrides/expo-mesh-gradient/MeshGradientView.tsx +44 -0
- package/overrides/expo-mesh-gradient/overrides.ts +9 -0
- package/overrides/expo-modules-core/overrides.ts +12 -0
- package/overrides/expo-navigation-bar/ExpoNavigationBar.ts +29 -0
- package/overrides/expo-navigation-bar/NavigationBar.ts +43 -0
- package/overrides/expo-navigation-bar/overrides.ts +12 -0
- package/overrides/expo-router/NativeStackView.tsx +74 -0
- package/overrides/expo-router/NativeTabsView.tsx +263 -0
- package/overrides/expo-router/SafeAreaProvider.ts +6 -0
- package/overrides/expo-router/overrides.ts +23 -0
- package/overrides/expo-router/statusBarRequests.ts +51 -0
- package/overrides/expo-screen-orientation/ExpoScreenOrientation.ts +173 -0
- package/overrides/expo-screen-orientation/overrides.ts +21 -0
- package/overrides/expo-sharing/SharingNativeModule.ts +21 -0
- package/overrides/expo-sharing/overrides.ts +9 -0
- package/overrides/expo-sms/ExpoSMS.ts +24 -0
- package/overrides/expo-sms/overrides.ts +9 -0
- package/overrides/expo-splash-screen/SplashScreen.ts +25 -0
- package/overrides/expo-splash-screen/overrides.ts +5 -0
- package/overrides/expo-status-bar/StatusBar.tsx +44 -0
- package/overrides/expo-status-bar/overrides.ts +5 -0
- package/overrides/expo-store-review/ExpoStoreReview.ts +18 -0
- package/overrides/expo-store-review/overrides.ts +9 -0
- package/overrides/expo-symbols/SymbolView.tsx +192 -0
- package/overrides/expo-symbols/overrides.ts +9 -0
- package/overrides/expo-system-ui/ExpoSystemUI.ts +34 -0
- package/overrides/expo-system-ui/overrides.ts +9 -0
- package/overrides/expo-task-manager/ExpoTaskManager.ts +39 -0
- package/overrides/expo-task-manager/overrides.ts +9 -0
- package/overrides/expo-tracking-transparency/ExpoTrackingTransparency.ts +30 -0
- package/overrides/expo-tracking-transparency/overrides.ts +11 -0
- package/overrides/expo-video/ExpoVideo.ts +16 -0
- package/overrides/expo-video/overrides.ts +9 -0
- package/overrides/lottie-react-native/LottieView.tsx +87 -0
- package/overrides/lottie-react-native/overrides.ts +9 -0
- package/overrides/react-native-pager-view/PagerViewNativeComponent.tsx +254 -0
- package/overrides/react-native-pager-view/overrides.ts +9 -0
- package/overrides/react-native-reanimated/overrides.ts +28 -0
- package/overrides/react-native-safe-area-context/NativeSafeAreaProvider.tsx +40 -0
- package/overrides/react-native-safe-area-context/overrides.ts +12 -0
- package/overrides/react-native-share/NativeRNShare.ts +22 -0
- package/overrides/react-native-share/overrides.ts +12 -0
- package/overrides/react-native-share/platform.ts +14 -0
- package/overrides/react-native-turbo-image/TurboImage.tsx +101 -0
- package/overrides/react-native-turbo-image/overrides.ts +9 -0
- package/overrides/react-native-web/RefreshControl.tsx +57 -0
- package/overrides/react-native-web/overrides.ts +153 -0
- package/overrides/react-native-web/useElementLayout.ts +140 -0
- package/package.json +78 -4
- package/plugins/battery/overrides/expo-battery/ExpoBattery.ts +57 -0
- package/plugins/battery/overrides/expo-battery/overrides.ts +9 -0
- package/plugins/battery/plugin.ts +8 -0
- package/plugins/battery/shell.tsx +56 -0
- package/plugins/battery/state.ts +11 -0
- package/plugins/biometrics/overrides/expo-local-authentication/ExpoLocalAuthentication.ts +90 -0
- package/plugins/biometrics/overrides/expo-local-authentication/overrides.ts +11 -0
- package/plugins/biometrics/plugin.ts +8 -0
- package/plugins/biometrics/shell.tsx +88 -0
- package/plugins/biometrics/state.ts +41 -0
- package/plugins/brightness/app.ts +5 -0
- package/plugins/brightness/overrides/expo-brightness/Brightness.ts +98 -0
- package/plugins/brightness/overrides/expo-brightness/overrides.ts +10 -0
- package/plugins/brightness/plugin.ts +9 -0
- package/plugins/brightness/shell.tsx +55 -0
- package/plugins/brightness/state.ts +19 -0
- package/plugins/calendar/calendar.ts +299 -0
- package/plugins/calendar/overrides/expo-calendar/ExpoCalendar.ts +358 -0
- package/plugins/calendar/overrides/expo-calendar/LegacyExpoCalendar.ts +163 -0
- package/plugins/calendar/overrides/expo-calendar/overrides.ts +14 -0
- package/plugins/calendar/plugin.ts +8 -0
- package/plugins/calendar/shell.tsx +123 -0
- package/plugins/camera/overrides/expo-camera/ExpoCamera.tsx +269 -0
- package/plugins/camera/overrides/expo-camera/ExpoCameraManager.ts +56 -0
- package/plugins/camera/overrides/expo-camera/overrides.ts +12 -0
- package/plugins/camera/plugin.ts +9 -0
- package/plugins/camera/shell.tsx +107 -0
- package/plugins/camera/state.ts +61 -0
- package/plugins/clipboard/overrides/expo-clipboard/ExpoClipboard.ts +138 -0
- package/plugins/clipboard/overrides/expo-clipboard/overrides.ts +9 -0
- package/plugins/clipboard/plugin.ts +8 -0
- package/plugins/clipboard/shell.tsx +122 -0
- package/plugins/clipboard/state.ts +93 -0
- package/plugins/clock/app.ts +25 -0
- package/plugins/clock/plugin.ts +8 -0
- package/plugins/clock/shell.tsx +225 -0
- package/plugins/clock/state.ts +12 -0
- package/plugins/contacts/contacts.ts +125 -0
- package/plugins/contacts/overrides/expo-contacts/ExpoContacts.ts +153 -0
- package/plugins/contacts/overrides/expo-contacts/ExpoContactsNext.ts +232 -0
- package/plugins/contacts/overrides/expo-contacts/overrides.ts +12 -0
- package/plugins/contacts/plugin.ts +8 -0
- package/plugins/contacts/shell.tsx +109 -0
- package/plugins/home-indicator/app.ts +5 -0
- package/plugins/home-indicator/plugin.ts +9 -0
- package/plugins/home-indicator/requests.ts +48 -0
- package/plugins/home-indicator/shell.tsx +68 -0
- package/plugins/home-indicator/state.ts +31 -0
- package/plugins/keep-awake/app.ts +5 -0
- package/plugins/keep-awake/overrides/expo-keep-awake/ExpoKeepAwake.ts +27 -0
- package/plugins/keep-awake/overrides/expo-keep-awake/overrides.ts +9 -0
- package/plugins/keep-awake/plugin.ts +9 -0
- package/plugins/keep-awake/shell.tsx +80 -0
- package/plugins/keep-awake/state.ts +12 -0
- package/plugins/keyboard/Keyboard.tsx +354 -0
- package/plugins/keyboard/app.ts +90 -0
- package/plugins/keyboard/controller.ts +384 -0
- package/plugins/keyboard/fields.ts +244 -0
- package/plugins/keyboard/icons.tsx +283 -0
- package/plugins/keyboard/keyboard.css +362 -0
- package/plugins/keyboard/layouts/android.ts +175 -0
- package/plugins/keyboard/layouts/index.ts +10 -0
- package/plugins/keyboard/layouts/ios.ts +219 -0
- package/plugins/keyboard/layouts/types.ts +80 -0
- package/plugins/keyboard/overrides/react-native-keyboard-controller/KeyboardController.tsx +470 -0
- package/plugins/keyboard/overrides/react-native-keyboard-controller/overrides.ts +9 -0
- package/plugins/keyboard/plugin.ts +13 -0
- package/plugins/keyboard/shell.tsx +133 -0
- package/plugins/keyboard/state.ts +92 -0
- package/plugins/keyboard/suggestions.ts +63 -0
- package/plugins/keyboard/taps.ts +77 -0
- package/plugins/keyboard/typing.ts +112 -0
- package/plugins/locale/app.ts +232 -0
- package/plugins/locale/locale.ts +143 -0
- package/plugins/locale/overrides/expo-localization/ExpoLocalization.ts +41 -0
- package/plugins/locale/overrides/expo-localization/overrides.ts +9 -0
- package/plugins/locale/plugin.ts +9 -0
- package/plugins/locale/shell.tsx +147 -0
- package/plugins/locale/state.ts +36 -0
- package/plugins/location/geo.ts +56 -0
- package/plugins/location/overrides/expo-location/ExpoLocation.ts +235 -0
- package/plugins/location/overrides/expo-location/overrides.ts +11 -0
- package/plugins/location/places.ts +38 -0
- package/plugins/location/plugin.ts +8 -0
- package/plugins/location/shell.tsx +188 -0
- package/plugins/location/state.ts +51 -0
- package/plugins/motion/overrides/expo-sensors/DeviceSensor.ts +169 -0
- package/plugins/motion/overrides/expo-sensors/ExponentPedometer.ts +54 -0
- package/plugins/motion/overrides/expo-sensors/overrides.ts +14 -0
- package/plugins/motion/plugin.ts +8 -0
- package/plugins/motion/sensors.ts +116 -0
- package/plugins/motion/shell.tsx +136 -0
- package/plugins/motion/state.ts +46 -0
- package/plugins/network/app.ts +400 -0
- package/plugins/network/overrides/expo-network/ExpoNetwork.ts +51 -0
- package/plugins/network/overrides/expo-network/overrides.ts +9 -0
- package/plugins/network/plugin.ts +8 -0
- package/plugins/network/shell.tsx +67 -0
- package/plugins/network/state.ts +29 -0
- package/plugins/notifications/center.ts +255 -0
- package/plugins/notifications/content.ts +36 -0
- package/plugins/notifications/overrides/expo-notifications/NotificationsModule.ts +175 -0
- package/plugins/notifications/overrides/expo-notifications/channels.ts +108 -0
- package/plugins/notifications/overrides/expo-notifications/getDevicePushTokenAsync.ts +19 -0
- package/plugins/notifications/overrides/expo-notifications/getExpoPushTokenAsync.ts +16 -0
- package/plugins/notifications/overrides/expo-notifications/overrides.ts +36 -0
- package/plugins/notifications/plugin.ts +8 -0
- package/plugins/notifications/shell.tsx +192 -0
- package/plugins/notifications/state.ts +56 -0
- package/plugins/notifications/tokens.ts +47 -0
- package/plugins/notifications/trigger.ts +107 -0
- package/plugins/permissions/plugin.ts +6 -0
- package/plugins/permissions/shell.tsx +50 -0
- package/plugins/permissions/state.ts +38 -0
- package/plugins/photos/appLibrary.ts +114 -0
- package/plugins/photos/library.ts +322 -0
- package/plugins/photos/overrides/expo-image-picker/ExponentImagePicker.ts +153 -0
- package/plugins/photos/overrides/expo-image-picker/overrides.ts +13 -0
- package/plugins/photos/overrides/expo-media-library/ExpoMediaLibrary.ts +235 -0
- package/plugins/photos/overrides/expo-media-library/NativeMediaLibraryModule.ts +318 -0
- package/plugins/photos/overrides/expo-media-library/overrides.ts +19 -0
- package/plugins/photos/plugin.ts +8 -0
- package/plugins/photos/samples.ts +367 -0
- package/plugins/photos/shell.tsx +164 -0
- package/plugins/photos/state.ts +88 -0
- package/plugins/storage/files.ts +351 -0
- package/plugins/storage/overrides/expo-file-system/ExpoFileSystem.ts +770 -0
- package/plugins/storage/overrides/expo-file-system/ExponentFileSystem.ts +196 -0
- package/plugins/storage/overrides/expo-file-system/overrides.ts +13 -0
- package/plugins/storage/overrides/expo-secure-store/ExpoSecureStore.ts +75 -0
- package/plugins/storage/overrides/expo-secure-store/overrides.ts +9 -0
- package/plugins/storage/plugin.ts +8 -0
- package/plugins/storage/reset.ts +136 -0
- package/plugins/storage/secure.ts +71 -0
- package/plugins/storage/shell.tsx +365 -0
- package/plugins/storage/state.ts +13 -0
- package/src/client/app/appDocument.ts +113 -0
- package/src/client/app/appFocus.ts +97 -0
- package/src/client/app/console.ts +118 -0
- package/src/client/app/fonts.ts +59 -0
- package/src/client/app/main.tsx +99 -0
- package/src/client/app/routeContext.ts +45 -0
- package/src/client/app/touch.ts +640 -0
- package/src/client/entry.ts +20 -0
- package/src/client/modules.d.ts +8 -0
- package/src/client/react-native/app.ts +57 -0
- package/src/client/react-native/deep.ts +13 -0
- package/src/client/react-native/keyboard.tsx +192 -0
- package/src/client/react-native/library.ts +256 -0
- package/src/client/shell/Cookies.tsx +95 -0
- package/src/client/shell/LogDrawer.tsx +415 -0
- package/src/client/shell/PhotoPicker.tsx +174 -0
- package/src/client/shell/PluginOverlays.tsx +42 -0
- package/src/client/shell/PluginPanels.tsx +82 -0
- package/src/client/shell/ResetApp.tsx +87 -0
- package/src/client/shell/Resizer.tsx +99 -0
- package/src/client/shell/Shell.tsx +531 -0
- package/src/client/shell/SystemBars.tsx +376 -0
- package/src/client/shell/SystemCamera.tsx +181 -0
- package/src/client/shell/SystemOverlay.tsx +422 -0
- package/src/client/shell/SystemSheets.tsx +462 -0
- package/src/client/shell/backdrop.ts +229 -0
- package/src/client/shell/control.ts +91 -0
- package/src/client/shell/events.ts +226 -0
- package/src/client/shell/geometry.ts +68 -0
- package/src/client/shell/host.ts +492 -0
- package/src/client/shell/icons.tsx +34 -0
- package/src/client/shell/logFeed.ts +102 -0
- package/src/client/shell/main.tsx +22 -0
- package/src/client/shell/permissionCopy.ts +169 -0
- package/src/client/shell/plugins.ts +266 -0
- package/src/client/shell/popout.ts +185 -0
- package/src/client/shell/popover.ts +27 -0
- package/src/client/shell/shell.css +878 -0
- package/src/client/shell/statusTime.ts +31 -0
- package/src/client/shell/tooltips.ts +104 -0
- package/src/client/virtual.d.ts +21 -0
- package/src/devices/catalog.ts +223 -0
- package/src/devices/types.ts +83 -0
- package/src/node/appInfo.ts +186 -0
- package/src/node/appSource.ts +138 -0
- package/src/node/config.ts +180 -0
- package/src/node/control.ts +144 -0
- package/src/node/doctor.ts +199 -0
- package/src/node/events/cli.ts +206 -0
- package/src/node/events/shared.ts +238 -0
- package/src/node/events/store.ts +266 -0
- package/src/node/index.ts +5 -0
- package/src/node/overrides/define.ts +56 -0
- package/src/node/overrides/packages.ts +136 -0
- package/src/node/overrides/platformPatch.ts +56 -0
- package/src/node/overrides/plugin.ts +166 -0
- package/src/node/overrides/registry.ts +258 -0
- package/src/node/paths.ts +18 -0
- package/src/node/platform.ts +171 -0
- package/src/node/plugins.ts +98 -0
- package/src/node/proxy.ts +421 -0
- package/src/node/server.ts +253 -0
- package/src/plugin/index.ts +33 -0
- package/src/plugin/types.ts +127 -0
- package/src/plugin/ui.tsx +562 -0
- package/src/runtime/clock.ts +112 -0
- package/src/runtime/draw.ts +196 -0
- package/src/runtime/index.ts +513 -0
- package/src/runtime/media.ts +379 -0
- package/src/runtime/records.ts +76 -0
- package/src/runtime/timezone.ts +81 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState, type ReactNode } from 'react'
|
|
3
|
+
import { type LayoutChangeEvent, View, type ViewStyle } from 'react-native'
|
|
4
|
+
|
|
5
|
+
type ScrollState = 'idle' | 'dragging' | 'settling'
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
children?: ReactNode
|
|
9
|
+
style?: ViewStyle
|
|
10
|
+
initialPage?: number
|
|
11
|
+
scrollEnabled?: boolean
|
|
12
|
+
orientation?: 'horizontal' | 'vertical'
|
|
13
|
+
layoutDirection?: 'ltr' | 'rtl'
|
|
14
|
+
pageMargin?: number
|
|
15
|
+
onPageScroll?: (event: { nativeEvent: { position: number; offset: number } }) => void
|
|
16
|
+
onPageSelected?: (event: { nativeEvent: { position: number } }) => void
|
|
17
|
+
onPageScrollStateChanged?: (event: { nativeEvent: { pageScrollState: ScrollState } }) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type PagerHandle = {
|
|
21
|
+
setPage(page: number): void
|
|
22
|
+
setPageWithoutAnimation(page: number): void
|
|
23
|
+
setScrollEnabledImperatively(enabled: boolean): void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** How far a drag goes before it is a page swipe, and not a press or a vertical scroll. */
|
|
27
|
+
const SLOP = 8
|
|
28
|
+
/** A release this fast (px/ms) turns the page even short of halfway. */
|
|
29
|
+
const FLING = 0.4
|
|
30
|
+
const SETTLE_MS = 300
|
|
31
|
+
|
|
32
|
+
const easeOut = (t: number) => 1 - (1 - t) ** 3
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The pager's native view: the pages in a row, one page wide each, moved by a transform. A drag along the pager's
|
|
36
|
+
* axis follows the pointer and settles on the nearest page, or the next one when flung; the events carry the same
|
|
37
|
+
* `position` and `offset` as on a device.
|
|
38
|
+
*/
|
|
39
|
+
const PagerViewNativeComponent = forwardRef<PagerHandle, Props>(function PagerViewNativeComponent(props, ref) {
|
|
40
|
+
const { children, style, initialPage = 0, scrollEnabled = true, orientation = 'horizontal', pageMargin = 0 } = props
|
|
41
|
+
const vertical = orientation === 'vertical'
|
|
42
|
+
const count = Children.count(children)
|
|
43
|
+
const [size, setSize] = useState({ width: 0, height: 0 })
|
|
44
|
+
const pageLength = (vertical ? size.height : size.width) + pageMargin
|
|
45
|
+
const track = useRef<HTMLElement | null>(null)
|
|
46
|
+
const container = useRef<HTMLElement | null>(null)
|
|
47
|
+
const state = useRef({ position: initialPage, selected: initialPage, enabled: scrollEnabled, scroll: 'idle' as ScrollState, frame: 0 })
|
|
48
|
+
const propsRef = useRef(props)
|
|
49
|
+
propsRef.current = props
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
state.current.enabled = scrollEnabled
|
|
53
|
+
}, [scrollEnabled])
|
|
54
|
+
|
|
55
|
+
const setScrollState = (next: ScrollState) => {
|
|
56
|
+
if (state.current.scroll !== next) {
|
|
57
|
+
state.current.scroll = next
|
|
58
|
+
propsRef.current.onPageScrollStateChanged?.({ nativeEvent: { pageScrollState: next } })
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Moves the row to a fractional page and reports it. */
|
|
63
|
+
const moveTo = useCallback(
|
|
64
|
+
(position: number) => {
|
|
65
|
+
state.current.position = position
|
|
66
|
+
const node = track.current
|
|
67
|
+
if (node !== null) {
|
|
68
|
+
const distance = -position * pageLength
|
|
69
|
+
node.style.transform = vertical ? `translateY(${distance}px)` : `translateX(${distance}px)`
|
|
70
|
+
}
|
|
71
|
+
const page = Math.floor(position + 1e-6)
|
|
72
|
+
propsRef.current.onPageScroll?.({ nativeEvent: { position: page, offset: Math.max(0, position - page) } })
|
|
73
|
+
},
|
|
74
|
+
[pageLength, vertical],
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
const select = (page: number) => {
|
|
78
|
+
if (state.current.selected !== page) {
|
|
79
|
+
state.current.selected = page
|
|
80
|
+
propsRef.current.onPageSelected?.({ nativeEvent: { position: page } })
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const settle = useCallback(
|
|
85
|
+
(target: number, animated: boolean) => {
|
|
86
|
+
const page = Math.max(0, Math.min(count - 1, target))
|
|
87
|
+
cancelAnimationFrame(state.current.frame)
|
|
88
|
+
const from = state.current.position
|
|
89
|
+
if (!animated || from === page) {
|
|
90
|
+
moveTo(page)
|
|
91
|
+
select(page)
|
|
92
|
+
setScrollState('idle')
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
setScrollState('settling')
|
|
96
|
+
// Like ViewPager2, the new page is selected as the pager starts settling on it.
|
|
97
|
+
select(page)
|
|
98
|
+
const start = performance.now()
|
|
99
|
+
const step = (now: number) => {
|
|
100
|
+
const t = Math.min(1, (now - start) / SETTLE_MS)
|
|
101
|
+
moveTo(from + (page - from) * easeOut(t))
|
|
102
|
+
if (t < 1) {
|
|
103
|
+
state.current.frame = requestAnimationFrame(step)
|
|
104
|
+
} else {
|
|
105
|
+
setScrollState('idle')
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
state.current.frame = requestAnimationFrame(step)
|
|
109
|
+
},
|
|
110
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
+
[count, moveTo],
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
useImperativeHandle(ref, () => ({
|
|
115
|
+
setPage: (page) => settle(page, true),
|
|
116
|
+
setPageWithoutAnimation: (page) => settle(page, false),
|
|
117
|
+
setScrollEnabledImperatively: (enabled) => {
|
|
118
|
+
state.current.enabled = enabled
|
|
119
|
+
},
|
|
120
|
+
}))
|
|
121
|
+
|
|
122
|
+
// Keeps the current page in place when the pager is laid out or resized.
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (pageLength > 0) {
|
|
125
|
+
moveTo(state.current.position)
|
|
126
|
+
}
|
|
127
|
+
}, [pageLength, moveTo])
|
|
128
|
+
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
const node = container.current
|
|
131
|
+
if (node === null || pageLength <= 0) {
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
let drag: { id: number; x: number; y: number; from: number; active: boolean; samples: { t: number; d: number }[] } | null = null
|
|
135
|
+
const along = (event: PointerEvent) => (vertical ? event.clientY : event.clientX)
|
|
136
|
+
const across = (event: PointerEvent) => (vertical ? event.clientX : event.clientY)
|
|
137
|
+
|
|
138
|
+
const onDown = (event: PointerEvent) => {
|
|
139
|
+
if (!state.current.enabled || event.button !== 0 || drag !== null) {
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
drag = { id: event.pointerId, x: along(event), y: across(event), from: state.current.position, active: false, samples: [] }
|
|
143
|
+
}
|
|
144
|
+
const onMove = (event: PointerEvent) => {
|
|
145
|
+
if (drag === null || event.pointerId !== drag.id) {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
const delta = along(event) - drag.x
|
|
149
|
+
if (!drag.active) {
|
|
150
|
+
if (Math.abs(across(event) - drag.y) > SLOP) {
|
|
151
|
+
drag = null
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
if (Math.abs(delta) < SLOP) {
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
drag.active = true
|
|
158
|
+
cancelAnimationFrame(state.current.frame)
|
|
159
|
+
drag.from = state.current.position
|
|
160
|
+
node.setPointerCapture(event.pointerId)
|
|
161
|
+
setScrollState('dragging')
|
|
162
|
+
}
|
|
163
|
+
event.preventDefault()
|
|
164
|
+
event.stopPropagation()
|
|
165
|
+
drag.samples.push({ t: event.timeStamp, d: delta })
|
|
166
|
+
drag.samples = drag.samples.filter((sample) => event.timeStamp - sample.t < 100)
|
|
167
|
+
const raw = drag.from - delta / pageLength
|
|
168
|
+
// Past the first and last page the pager resists, as overdrag does.
|
|
169
|
+
const position = raw < 0 ? raw / 3 : raw > count - 1 ? count - 1 + (raw - (count - 1)) / 3 : raw
|
|
170
|
+
moveTo(position)
|
|
171
|
+
}
|
|
172
|
+
const onUp = (event: PointerEvent) => {
|
|
173
|
+
if (drag === null || event.pointerId !== drag.id) {
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
const { active, samples, from } = drag
|
|
177
|
+
drag = null
|
|
178
|
+
if (!active) {
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
const first = samples[0]
|
|
182
|
+
const last = samples[samples.length - 1]
|
|
183
|
+
const velocity = first !== undefined && last !== undefined && last.t > first.t ? (last.d - first.d) / (last.t - first.t) : 0
|
|
184
|
+
const position = state.current.position
|
|
185
|
+
let target = Math.round(position)
|
|
186
|
+
if (Math.abs(velocity) > FLING) {
|
|
187
|
+
target = velocity < 0 ? Math.floor(position) + 1 : Math.ceil(position) - 1
|
|
188
|
+
}
|
|
189
|
+
// A swipe turns at most one page from where it started.
|
|
190
|
+
settle(Math.max(Math.round(from) - 1, Math.min(Math.round(from) + 1, target)), true)
|
|
191
|
+
}
|
|
192
|
+
// A click that ends a swipe is not a press on the page.
|
|
193
|
+
const onClick = (event: MouseEvent) => {
|
|
194
|
+
if (state.current.scroll !== 'idle') {
|
|
195
|
+
event.stopPropagation()
|
|
196
|
+
event.preventDefault()
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
node.addEventListener('pointerdown', onDown, true)
|
|
200
|
+
node.addEventListener('pointermove', onMove, true)
|
|
201
|
+
node.addEventListener('pointerup', onUp, true)
|
|
202
|
+
node.addEventListener('pointercancel', onUp, true)
|
|
203
|
+
node.addEventListener('click', onClick, true)
|
|
204
|
+
return () => {
|
|
205
|
+
node.removeEventListener('pointerdown', onDown, true)
|
|
206
|
+
node.removeEventListener('pointermove', onMove, true)
|
|
207
|
+
node.removeEventListener('pointerup', onUp, true)
|
|
208
|
+
node.removeEventListener('pointercancel', onUp, true)
|
|
209
|
+
node.removeEventListener('click', onClick, true)
|
|
210
|
+
}
|
|
211
|
+
}, [pageLength, vertical, count, moveTo, settle])
|
|
212
|
+
|
|
213
|
+
const onLayout = (event: LayoutChangeEvent) => {
|
|
214
|
+
const { width, height } = event.nativeEvent.layout
|
|
215
|
+
setSize((previous) => (previous.width === width && previous.height === height ? previous : { width, height }))
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<View ref={container as never} style={[{ overflow: 'hidden' }, style]} onLayout={onLayout}>
|
|
220
|
+
<View
|
|
221
|
+
ref={track as never}
|
|
222
|
+
style={{
|
|
223
|
+
flexDirection: vertical ? 'column' : 'row',
|
|
224
|
+
position: 'absolute',
|
|
225
|
+
top: 0,
|
|
226
|
+
left: 0,
|
|
227
|
+
width: vertical ? size.width : pageLength * count,
|
|
228
|
+
height: vertical ? pageLength * count : size.height,
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
{Children.map(children, (child) => (
|
|
232
|
+
<View
|
|
233
|
+
style={{
|
|
234
|
+
width: size.width,
|
|
235
|
+
height: size.height,
|
|
236
|
+
marginRight: vertical ? 0 : pageMargin,
|
|
237
|
+
marginBottom: vertical ? pageMargin : 0,
|
|
238
|
+
}}
|
|
239
|
+
>
|
|
240
|
+
{child}
|
|
241
|
+
</View>
|
|
242
|
+
))}
|
|
243
|
+
</View>
|
|
244
|
+
</View>
|
|
245
|
+
)
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
export default PagerViewNativeComponent
|
|
249
|
+
|
|
250
|
+
export const Commands = {
|
|
251
|
+
setPage: (view: PagerHandle | null, page: number) => view?.setPage(page),
|
|
252
|
+
setPageWithoutAnimation: (view: PagerHandle | null, page: number) => view?.setPageWithoutAnimation(page),
|
|
253
|
+
setScrollEnabledImperatively: (view: PagerHandle | null, enabled: boolean) => view?.setScrollEnabledImperatively(enabled),
|
|
254
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineOverrides } from '../../src/node/overrides/define.ts'
|
|
2
|
+
|
|
3
|
+
export default defineOverrides('react-native-pager-view', [
|
|
4
|
+
{
|
|
5
|
+
versions: '>=9 <10',
|
|
6
|
+
note: 'pages side by side, swiped by dragging and snapped like ViewPager2 / UIPageViewController; without it every page draws on top of the others',
|
|
7
|
+
files: { 'lib/module/PagerViewNativeComponent.ts': './PagerViewNativeComponent.tsx' },
|
|
8
|
+
},
|
|
9
|
+
])
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineOverrides } from '../../src/node/overrides/define.ts'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* On the web, Reanimated fades an exiting view out as an absolute copy: it moves the view's children into the copy
|
|
5
|
+
* and places the copy by measuring its parent. The emptied view has already shrunk by then, so a parent that centres
|
|
6
|
+
* its content moves, and the copy lands off by that much (a production app's rotating chat placeholder jumped up 13pt on every
|
|
7
|
+
* change). Holding the view at its size until React removes it keeps the parent where it was drawn.
|
|
8
|
+
*/
|
|
9
|
+
const HOLD_SIZE = `const heldRect = element.getBoundingClientRect();
|
|
10
|
+
element.style.width = heldRect.width + 'px';
|
|
11
|
+
element.style.height = heldRect.height + 'px';
|
|
12
|
+
element.style.flexShrink = '0';
|
|
13
|
+
while (element.firstChild) {
|
|
14
|
+
dummy.appendChild(element.firstChild);
|
|
15
|
+
}`
|
|
16
|
+
|
|
17
|
+
export default defineOverrides('react-native-reanimated', [
|
|
18
|
+
{
|
|
19
|
+
versions: '>=4.7.1 <4.8',
|
|
20
|
+
note: 'an exiting view keeps its size while its copy fades out, so a centring parent does not move it (tested on 4.7.1)',
|
|
21
|
+
patch: [
|
|
22
|
+
{
|
|
23
|
+
file: 'lib/module/layoutReanimation/web/componentUtils.js',
|
|
24
|
+
replace: (source) => source.replace('while (element.firstChild) {\n dummy.appendChild(element.firstChild);\n }', HOLD_SIZE),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
])
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { View, type ViewProps } from 'react-native'
|
|
3
|
+
import { insets, screenSize, subscribe } from 'web-sim/runtime'
|
|
4
|
+
|
|
5
|
+
type InsetsChange = {
|
|
6
|
+
nativeEvent: {
|
|
7
|
+
insets: { top: number; right: number; bottom: number; left: number }
|
|
8
|
+
frame: { x: number; y: number; width: number; height: number }
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The provider's native view reports the device's insets for its orientation, and again when it rotates or the
|
|
14
|
+
* device changes. The library's web provider reads CSS `env(safe-area-inset-*)`, which is zero in a frame.
|
|
15
|
+
*/
|
|
16
|
+
export function NativeSafeAreaProvider({
|
|
17
|
+
children,
|
|
18
|
+
style,
|
|
19
|
+
onInsetsChange,
|
|
20
|
+
ref,
|
|
21
|
+
}: ViewProps & { onInsetsChange: (event: InsetsChange) => void; ref?: React.Ref<never> }) {
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const report = () => {
|
|
24
|
+
const { width, height } = screenSize()
|
|
25
|
+
onInsetsChange({ nativeEvent: { insets: { ...insets() }, frame: { x: 0, y: 0, width, height } } })
|
|
26
|
+
}
|
|
27
|
+
report()
|
|
28
|
+
window.addEventListener('resize', report)
|
|
29
|
+
const unsubscribe = subscribe(report)
|
|
30
|
+
return () => {
|
|
31
|
+
window.removeEventListener('resize', report)
|
|
32
|
+
unsubscribe()
|
|
33
|
+
}
|
|
34
|
+
}, [onInsetsChange])
|
|
35
|
+
return (
|
|
36
|
+
<View ref={ref} style={style}>
|
|
37
|
+
{children}
|
|
38
|
+
</View>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineOverrides } from '../../src/node/overrides/define.ts'
|
|
2
|
+
|
|
3
|
+
export default defineOverrides('react-native-safe-area-context', [
|
|
4
|
+
{
|
|
5
|
+
versions: '>=4.10 <6',
|
|
6
|
+
note: 'insets from the simulated device',
|
|
7
|
+
files: {
|
|
8
|
+
'lib/module/NativeSafeAreaProvider.web.js': './NativeSafeAreaProvider.tsx',
|
|
9
|
+
'lib/commonjs/NativeSafeAreaProvider.web.js': './NativeSafeAreaProvider.tsx',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
])
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { showDialog } from 'web-sim/runtime'
|
|
2
|
+
|
|
3
|
+
type ShareOptions = { url?: string; urls?: string[]; message?: string; title?: string; subject?: string; type?: string; social?: string }
|
|
4
|
+
|
|
5
|
+
/** Generic targets on the sheet, so the result names the one picked, as the native module does. */
|
|
6
|
+
async function share(options: ShareOptions): Promise<{ success: boolean; message: string }> {
|
|
7
|
+
const url = options.url ?? options.urls?.[0] ?? options.message ?? ''
|
|
8
|
+
const { button } = await showDialog({ kind: 'share', url, title: options.title ?? options.subject, mimeType: options.type })
|
|
9
|
+
return button < 0 ? { success: false, message: 'CANCELED' } : { success: true, message: 'OK' }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The share sheet in place of the native module. `shareSingle` to a named app opens the same sheet: the simulator has
|
|
14
|
+
* no Instagram or WhatsApp to hand off to. No social app counts as installed.
|
|
15
|
+
*/
|
|
16
|
+
export default {
|
|
17
|
+
getConstants: () => ({}),
|
|
18
|
+
open: share,
|
|
19
|
+
shareSingle: share,
|
|
20
|
+
isPackageInstalled: async () => false,
|
|
21
|
+
isBase64File: async () => false,
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineOverrides } from '../../src/node/overrides/define.ts'
|
|
2
|
+
|
|
3
|
+
export default defineOverrides('react-native-share', [
|
|
4
|
+
{
|
|
5
|
+
versions: '>=12.3 <13',
|
|
6
|
+
note: "the platform's share sheet for open and shareSingle; the package has no web build",
|
|
7
|
+
files: {
|
|
8
|
+
'lib/module/codegenSpec/NativeRNShare.js': './NativeRNShare.ts',
|
|
9
|
+
'lib/module/helpers/platform.js': './platform.ts',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
])
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getState } from 'web-sim/runtime'
|
|
2
|
+
|
|
3
|
+
/** The library's platform checks, against the simulated device rather than the web. */
|
|
4
|
+
export function isIOS() {
|
|
5
|
+
return getState().device.platform === 'ios'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isAndroid() {
|
|
9
|
+
return getState().device.platform === 'android'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getAndroidVersion() {
|
|
13
|
+
return Number.parseInt(getState().device.osVersion, 10)
|
|
14
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { forwardRef, useEffect, useState } from 'react'
|
|
3
|
+
import { type ColorValue, View, type ViewStyle } from 'react-native'
|
|
4
|
+
|
|
5
|
+
type ResizeMode = 'contain' | 'cover' | 'stretch' | 'center'
|
|
6
|
+
|
|
7
|
+
type Event<T> = { nativeEvent: T }
|
|
8
|
+
|
|
9
|
+
type TurboImageProps = {
|
|
10
|
+
source: { uri: string; headers?: unknown; cacheKey?: string }
|
|
11
|
+
style?: ViewStyle
|
|
12
|
+
resizeMode?: ResizeMode
|
|
13
|
+
fadeDuration?: number
|
|
14
|
+
rounded?: boolean
|
|
15
|
+
blur?: number
|
|
16
|
+
monochrome?: ColorValue | number
|
|
17
|
+
tint?: ColorValue | number
|
|
18
|
+
onStart?: (event: Event<{ state: 'running' }>) => void
|
|
19
|
+
onSuccess?: (event: Event<{ width: number; height: number; source: string }>) => void
|
|
20
|
+
onFailure?: (event: Event<{ error: string }>) => void
|
|
21
|
+
onCompletion?: (event: Event<{ state: 'completed' | 'cancelled' }>) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const OBJECT_FIT: Record<ResizeMode, 'contain' | 'cover' | 'fill' | 'none'> = { contain: 'contain', cover: 'cover', stretch: 'fill', center: 'none' }
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Nuke (iOS) and Coil (Android) in place: an `<img>` that fades in once loaded and reports the same load events.
|
|
28
|
+
* Placeholders (blurhash, thumbhash, a cached image) aren't drawn.
|
|
29
|
+
*/
|
|
30
|
+
const TurboImageView = forwardRef<View, TurboImageProps>((props, ref) => {
|
|
31
|
+
const { source, style, resizeMode = 'contain', fadeDuration = 0, rounded, blur, monochrome, onStart, onSuccess, onFailure, onCompletion } = props
|
|
32
|
+
const [loaded, setLoaded] = useState(false)
|
|
33
|
+
const uri = source?.uri
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setLoaded(false)
|
|
37
|
+
if (uri) {
|
|
38
|
+
onStart?.({ nativeEvent: { state: 'running' } })
|
|
39
|
+
}
|
|
40
|
+
// Only a new image starts a new load.
|
|
41
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
+
}, [uri])
|
|
43
|
+
|
|
44
|
+
const filters = [blur ? `blur(${blur}px)` : '', monochrome !== undefined && monochrome !== null ? 'grayscale(1)' : ''].filter(Boolean)
|
|
45
|
+
return (
|
|
46
|
+
<View ref={ref as never} style={[{ overflow: 'hidden' }, style, rounded ? { borderRadius: 9999999 } : null]}>
|
|
47
|
+
{uri ? (
|
|
48
|
+
<img
|
|
49
|
+
key={uri}
|
|
50
|
+
src={uri}
|
|
51
|
+
alt=""
|
|
52
|
+
draggable={false}
|
|
53
|
+
onLoad={(event) => {
|
|
54
|
+
const image = event.currentTarget
|
|
55
|
+
setLoaded(true)
|
|
56
|
+
onSuccess?.({ nativeEvent: { width: image.naturalWidth, height: image.naturalHeight, source: uri } })
|
|
57
|
+
onCompletion?.({ nativeEvent: { state: 'completed' } })
|
|
58
|
+
}}
|
|
59
|
+
onError={() => {
|
|
60
|
+
onFailure?.({ nativeEvent: { error: `Failed to load ${uri}` } })
|
|
61
|
+
onCompletion?.({ nativeEvent: { state: 'completed' } })
|
|
62
|
+
}}
|
|
63
|
+
style={{
|
|
64
|
+
position: 'absolute', top: 0, left: 0,
|
|
65
|
+
width: '100%',
|
|
66
|
+
height: '100%',
|
|
67
|
+
objectFit: OBJECT_FIT[resizeMode],
|
|
68
|
+
opacity: loaded || fadeDuration === 0 ? 1 : 0,
|
|
69
|
+
transition: fadeDuration > 0 ? `opacity ${fadeDuration}ms` : undefined,
|
|
70
|
+
filter: filters.length > 0 ? filters.join(' ') : undefined,
|
|
71
|
+
pointerEvents: 'none',
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
) : null}
|
|
75
|
+
</View>
|
|
76
|
+
)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const prefetched = new Map<string, HTMLImageElement>()
|
|
80
|
+
|
|
81
|
+
const TurboImage = Object.assign(TurboImageView, {
|
|
82
|
+
prefetch: async (sources: { uri: string }[]) => {
|
|
83
|
+
for (const { uri } of sources) {
|
|
84
|
+
const image = new Image()
|
|
85
|
+
image.src = uri
|
|
86
|
+
prefetched.set(uri, image)
|
|
87
|
+
}
|
|
88
|
+
return true
|
|
89
|
+
},
|
|
90
|
+
dispose: async (sources: { uri: string }[]) => {
|
|
91
|
+
for (const { uri } of sources) {
|
|
92
|
+
prefetched.delete(uri)
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
clearMemoryCache: async () => {
|
|
96
|
+
prefetched.clear()
|
|
97
|
+
},
|
|
98
|
+
clearDiskCache: async () => {},
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
export default TurboImage
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineOverrides } from '../../src/node/overrides/define.ts'
|
|
2
|
+
|
|
3
|
+
export default defineOverrides('react-native-turbo-image', [
|
|
4
|
+
{
|
|
5
|
+
versions: '>=1.24 <1.25',
|
|
6
|
+
note: 'images drawn as <img>, with fade-in, blur, monochrome and the load events; the package has no web build',
|
|
7
|
+
files: { 'lib/module/TurboImage.js': './TurboImage.tsx' },
|
|
8
|
+
},
|
|
9
|
+
])
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef } from 'react'
|
|
2
|
+
// Compiled in react-native-web's `dist/exports/RefreshControl`, where this is its own View.
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import View from '../View'
|
|
5
|
+
|
|
6
|
+
type RefreshControlProps = {
|
|
7
|
+
refreshing: boolean
|
|
8
|
+
onRefresh?: () => void
|
|
9
|
+
enabled?: boolean
|
|
10
|
+
tintColor?: unknown
|
|
11
|
+
title?: string
|
|
12
|
+
titleColor?: unknown
|
|
13
|
+
colors?: unknown
|
|
14
|
+
progressBackgroundColor?: unknown
|
|
15
|
+
progressViewOffset?: number
|
|
16
|
+
size?: unknown
|
|
17
|
+
[prop: string]: unknown
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The scroll view's parent, as in react-native-web, marked for the app frame's drag scrolling
|
|
22
|
+
* (`src/client/app/touch.ts`), which draws the spinner and calls `onRefresh` when the list is pulled far enough. It
|
|
23
|
+
* hears `refreshing` change from the `websimrefreshing` event, and asks for a refresh with `websimrefresh`.
|
|
24
|
+
*/
|
|
25
|
+
export default function RefreshControl(props: RefreshControlProps) {
|
|
26
|
+
const { colors, enabled, onRefresh, progressBackgroundColor, progressViewOffset, refreshing, size, tintColor, title, titleColor, dataSet, ...rest } =
|
|
27
|
+
props
|
|
28
|
+
const ref = useRef<HTMLElement | null>(null)
|
|
29
|
+
const onRefreshRef = useRef(onRefresh)
|
|
30
|
+
onRefreshRef.current = onRefresh
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const node = ref.current
|
|
34
|
+
const refresh = () => onRefreshRef.current?.()
|
|
35
|
+
node?.addEventListener('websimrefresh', refresh)
|
|
36
|
+
return () => node?.removeEventListener('websimrefresh', refresh)
|
|
37
|
+
}, [])
|
|
38
|
+
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
ref.current?.dispatchEvent(new CustomEvent('websimrefreshing', { bubbles: true }))
|
|
41
|
+
}, [refreshing])
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<View
|
|
45
|
+
{...rest}
|
|
46
|
+
ref={ref}
|
|
47
|
+
dataSet={{
|
|
48
|
+
...(dataSet as object | undefined),
|
|
49
|
+
webSimRefresh: enabled === false ? 'disabled' : 'enabled',
|
|
50
|
+
webSimRefreshing: refreshing ? 'true' : 'false',
|
|
51
|
+
webSimRefreshTint: typeof tintColor === 'string' ? tintColor : undefined,
|
|
52
|
+
webSimRefreshTitle: typeof title === 'string' && title !== '' ? title : undefined,
|
|
53
|
+
webSimRefreshTitleColor: typeof titleColor === 'string' ? titleColor : undefined,
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
)
|
|
57
|
+
}
|