@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.
- 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 +157 -0
- package/overrides/react-native-web/useElementLayout.ts +152 -0
- package/package.json +80 -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 +129 -0
- package/src/client/app/appFocus.ts +97 -0
- package/src/client/app/console.ts +118 -0
- package/src/client/app/fonts.ts +76 -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 +23 -0
- package/src/devices/catalog.ts +223 -0
- package/src/devices/types.ts +83 -0
- package/src/node/appInfo.ts +188 -0
- package/src/node/appSource.ts +140 -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/fonts.ts +377 -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 +169 -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 +254 -0
- package/src/node/worklets.ts +86 -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 +519 -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,519 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react'
|
|
2
|
+
import { DEFAULT_DEVICE_ID, DEVICES } from '../devices/catalog.ts'
|
|
3
|
+
import type { Appearance, Device, DeviceHardware, Insets, Orientation, Platform } from '../devices/types.ts'
|
|
4
|
+
import type { EventInput, Level } from '../node/events/shared.ts'
|
|
5
|
+
import type { CameraFacing, CameraFeed, CapturedPhoto } from './media.ts'
|
|
6
|
+
|
|
7
|
+
export type { Appearance, Cutout, Device, DeviceHardware, Insets, Orientation, Platform } from '../devices/types.ts'
|
|
8
|
+
export type { Actor, EventInput, Level, SimEvent } from '../node/events/shared.ts'
|
|
9
|
+
export * from './clock.ts'
|
|
10
|
+
export * from './media.ts'
|
|
11
|
+
export * from './records.ts'
|
|
12
|
+
export * from './timezone.ts'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The simulator's state, as the device would report it to the app.
|
|
16
|
+
*/
|
|
17
|
+
export type SimState = {
|
|
18
|
+
device: Device
|
|
19
|
+
orientation: Orientation
|
|
20
|
+
/** The device's appearance setting, Light or Dark in Settings. System UI outside the app (Android's keyboard) follows it. */
|
|
21
|
+
appearance: Appearance
|
|
22
|
+
/**
|
|
23
|
+
* The appearance the app's views get: the device's, unless the app pins one, as `UIUserInterfaceStyle` (Expo's
|
|
24
|
+
* `userInterfaceStyle`) or `Appearance.setColorScheme` do. What the app draws, and what iOS draws in its windows (the
|
|
25
|
+
* keyboard, alerts), follows this.
|
|
26
|
+
*/
|
|
27
|
+
appAppearance: Appearance
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** An app's `userInterfaceStyle`: a pinned appearance, or `automatic` to follow the device. */
|
|
31
|
+
export type UserInterfaceStyle = Appearance | 'automatic'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The colour of a system bar's content. `light` is light content, for dark backgrounds. `auto` follows the
|
|
35
|
+
* appearance (light content in dark mode), as expo-status-bar's and react-native-screens' `auto` resolve it.
|
|
36
|
+
* `default` is iOS's `UIStatusBarStyleDefault`: since iOS 17 the status bar picks light or dark from the content under
|
|
37
|
+
* it, so the shell reads that content; Android, and the navigation bar, treat it as `auto`.
|
|
38
|
+
*/
|
|
39
|
+
export type StatusBarStyle = 'light' | 'dark' | 'auto' | 'default'
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* What the app asks of the status bar. `screenStyle` is the focused navigator screen's `statusBarStyle`: while one is
|
|
43
|
+
* set it wins over the `StatusBar` components' `style`, as a view controller's preference does on iOS.
|
|
44
|
+
*/
|
|
45
|
+
export type StatusBarUpdate = { style?: StatusBarStyle; hidden?: boolean; screenStyle?: StatusBarStyle | null }
|
|
46
|
+
|
|
47
|
+
export type DialogButton = { text: string; style?: 'default' | 'cancel' | 'destructive' }
|
|
48
|
+
|
|
49
|
+
/** What a permission is for. The shell words its prompt from this, as each OS words its own. */
|
|
50
|
+
export type PermissionKind =
|
|
51
|
+
| 'camera'
|
|
52
|
+
| 'microphone'
|
|
53
|
+
| 'photos'
|
|
54
|
+
| 'location'
|
|
55
|
+
| 'location-background'
|
|
56
|
+
| 'contacts'
|
|
57
|
+
| 'calendar'
|
|
58
|
+
| 'reminders'
|
|
59
|
+
| 'notifications'
|
|
60
|
+
| 'tracking'
|
|
61
|
+
| 'motion'
|
|
62
|
+
| 'face-id'
|
|
63
|
+
|
|
64
|
+
export type PermissionStatus = 'undetermined' | 'granted' | 'denied'
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A system dialog the shell draws over the app, in the platform's style.
|
|
68
|
+
*
|
|
69
|
+
* - `alert`: `Alert.alert`, with an optional text field (`Alert.prompt`).
|
|
70
|
+
* - `action-sheet`: iOS's action sheet, or Android's bottom sheet.
|
|
71
|
+
* - `permission`: the OS's permission prompt. Button 0 denies; 1 allows; for location, 2 allows once.
|
|
72
|
+
* - `biometric`: Face ID, Touch ID or Android's biometric prompt for `sensor` (by default, what the device has). The
|
|
73
|
+
* shell adds controls for what the sensor sees. Button 0 is a match, 1 a failed match, 2 a cancel.
|
|
74
|
+
* - `photo-picker`: the system photo picker over `photos` and `albums`. Button 1 picks `selected` (asset ids), 0 cancels.
|
|
75
|
+
* - `camera`: the system camera app, seeing `feeds`. Button 1 uses the `photo` taken, 0 cancels.
|
|
76
|
+
*/
|
|
77
|
+
export type Dialog =
|
|
78
|
+
| {
|
|
79
|
+
kind: 'alert'
|
|
80
|
+
title: string
|
|
81
|
+
message?: string
|
|
82
|
+
buttons: DialogButton[]
|
|
83
|
+
input?: { secure?: boolean; defaultValue?: string; placeholder?: string }
|
|
84
|
+
}
|
|
85
|
+
| { kind: 'action-sheet'; title?: string; message?: string; buttons: DialogButton[] }
|
|
86
|
+
| { kind: 'permission'; permission: PermissionKind; message?: string }
|
|
87
|
+
| { kind: 'biometric'; reason?: string; cancelLabel?: string; sensor?: BiometricSensor }
|
|
88
|
+
| { kind: 'store-review' }
|
|
89
|
+
| { kind: 'share'; url: string; title?: string; mimeType?: string }
|
|
90
|
+
| {
|
|
91
|
+
kind: 'compose'
|
|
92
|
+
channel: 'sms' | 'mail'
|
|
93
|
+
recipients: string[]
|
|
94
|
+
ccRecipients?: string[]
|
|
95
|
+
bccRecipients?: string[]
|
|
96
|
+
subject?: string
|
|
97
|
+
body?: string
|
|
98
|
+
attachments?: string[]
|
|
99
|
+
}
|
|
100
|
+
| {
|
|
101
|
+
kind: 'photo-picker'
|
|
102
|
+
multiple: boolean
|
|
103
|
+
limit: number
|
|
104
|
+
ordered?: boolean
|
|
105
|
+
mediaTypes: ('images' | 'videos' | 'livePhotos')[]
|
|
106
|
+
photos: PickerPhoto[]
|
|
107
|
+
albums: { id: string; title: string; assetIds: string[] }[]
|
|
108
|
+
}
|
|
109
|
+
| { kind: 'camera'; facing: CameraFacing; feeds: Record<CameraFacing, CameraFeed> }
|
|
110
|
+
|
|
111
|
+
export type BiometricSensor = 'face' | 'touch' | 'fingerprint'
|
|
112
|
+
|
|
113
|
+
/** A photo the picker shows: its asset id, and a small image for the grid. */
|
|
114
|
+
export type PickerPhoto = { id: string; filename: string; thumbnail: string; favorite: boolean }
|
|
115
|
+
|
|
116
|
+
export type DialogResult = { button: number; text?: string; selected?: string[]; photo?: CapturedPhoto }
|
|
117
|
+
|
|
118
|
+
export type HapticKind =
|
|
119
|
+
| 'light'
|
|
120
|
+
| 'medium'
|
|
121
|
+
| 'heavy'
|
|
122
|
+
| 'soft'
|
|
123
|
+
| 'rigid'
|
|
124
|
+
| 'selection'
|
|
125
|
+
| 'success'
|
|
126
|
+
| 'warning'
|
|
127
|
+
| 'error'
|
|
128
|
+
|
|
129
|
+
/** Which of the app's haptic calls made a haptic: expo-haptics' impact, notification, selection or Android call. */
|
|
130
|
+
export type HapticCall = { method: 'impact' | 'notification' | 'selection' } | { method: 'android'; type: string }
|
|
131
|
+
|
|
132
|
+
export type SimNotification = { id: string; title?: string; subtitle?: string; body?: string; data?: unknown }
|
|
133
|
+
|
|
134
|
+
/** What the app's config (`app.json`) says, as far as the simulator draws it. */
|
|
135
|
+
export type FirebaseOptions = {
|
|
136
|
+
apiKey?: string
|
|
137
|
+
appId?: string
|
|
138
|
+
projectId?: string
|
|
139
|
+
messagingSenderId?: string
|
|
140
|
+
storageBucket?: string
|
|
141
|
+
databaseURL?: string
|
|
142
|
+
clientId?: string
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type AppInfo = {
|
|
146
|
+
name: string
|
|
147
|
+
slug: string
|
|
148
|
+
version: string
|
|
149
|
+
bundleId: string
|
|
150
|
+
/** The app icon's URL. */
|
|
151
|
+
icon?: string
|
|
152
|
+
splash: { backgroundColor: string; darkBackgroundColor?: string; image?: string; imageWidth: number } | null
|
|
153
|
+
/** iOS usage descriptions, by Info.plist key (`NSCameraUsageDescription`). */
|
|
154
|
+
usageDescriptions: Record<string, string>
|
|
155
|
+
/** The app's resolved Expo config (`app.config.ts` or `app.json`), as `expo-constants` gives it in `expoConfig`. */
|
|
156
|
+
config?: Record<string, any>
|
|
157
|
+
/**
|
|
158
|
+
* The Firebase options a native build reads from the app's `GoogleService-Info.plist` (iOS) and
|
|
159
|
+
* `google-services.json` (Android), when the Expo config names them.
|
|
160
|
+
*/
|
|
161
|
+
googleServices?: { ios?: FirebaseOptions; android?: FirebaseOptions }
|
|
162
|
+
/** The packages the app depends on, from its `package.json`. */
|
|
163
|
+
dependencies?: string[]
|
|
164
|
+
/** The appearance the app pins by platform, from its Expo config's `userInterfaceStyle`. */
|
|
165
|
+
userInterfaceStyle?: { ios: UserInterfaceStyle; android: UserInterfaceStyle }
|
|
166
|
+
/** The fonts a native build embeds, by platform, under the names each platform gives them (`src/node/fonts.ts`). */
|
|
167
|
+
fonts?: BundledFonts
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** One `@font-face`: a font file under a family name, for a weight (or a range, `1 1000`) and a style. */
|
|
171
|
+
export type BundledFont = { family: string; url: string; weight: string; style: 'normal' | 'italic' }
|
|
172
|
+
export type BundledFonts = { ios: BundledFont[]; android: BundledFont[] }
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The shell's side of the simulator. It lives on the shell's window; the app reaches it through `window.parent`,
|
|
176
|
+
* which works because both share an origin. Overrides talk to it through this module and keep no state of their
|
|
177
|
+
* own, because a module an override imports can be loaded twice: once in the pre-bundle, once as source.
|
|
178
|
+
*/
|
|
179
|
+
export interface SimHost {
|
|
180
|
+
getState(): SimState
|
|
181
|
+
subscribe(listener: () => void): () => void
|
|
182
|
+
/** What the app's status bar components ask for. The last call wins. */
|
|
183
|
+
setStatusBar(update: StatusBarUpdate): void
|
|
184
|
+
app: AppInfo
|
|
185
|
+
showDialog(dialog: Dialog): Promise<DialogResult>
|
|
186
|
+
haptic(kind: HapticKind, call?: HapticCall): void
|
|
187
|
+
getPermission(kind: PermissionKind): PermissionStatus
|
|
188
|
+
setPermission(kind: PermissionKind, status: PermissionStatus): void
|
|
189
|
+
/** Shows a notification banner. Resolves true when it is tapped, false when it goes away. */
|
|
190
|
+
notify(notification: SimNotification): Promise<boolean>
|
|
191
|
+
/** The splash screen: kept up until `hideSplash` once `preventAutoHideSplash` is called, else hidden on first render. */
|
|
192
|
+
preventAutoHideSplash(): void
|
|
193
|
+
hideSplash(options?: { fade?: boolean; duration?: number }): void
|
|
194
|
+
/** The app rendered for the first time. */
|
|
195
|
+
appRendered(): void
|
|
196
|
+
/** Rotates to and holds an orientation, as `expo-screen-orientation`'s locks do; null lets the user rotate. */
|
|
197
|
+
setOrientationLock(lock: Orientation | null): void
|
|
198
|
+
getOrientationLock(): Orientation | null
|
|
199
|
+
/** Android's navigation bar: the colour of its handle or buttons, and whether it shows. */
|
|
200
|
+
setNavigationBar(update: { style?: StatusBarStyle; hidden?: boolean }): void
|
|
201
|
+
/** Plugins' state and events, which their panels and their overrides share. */
|
|
202
|
+
plugins: PluginHost
|
|
203
|
+
getNavigationBar(): { style: StatusBarStyle; hidden: boolean }
|
|
204
|
+
/** Adds an event to the simulator's log. `maxString` (default 1 KB) is the longest string kept in `data`. */
|
|
205
|
+
log(input: EventInput & { maxString?: number }): void
|
|
206
|
+
/**
|
|
207
|
+
* Stops the app (its frame is removed, so its pages unload and its databases close), runs `work` while no app is
|
|
208
|
+
* running, then launches it fresh. The shell's own; absent from the fallback host.
|
|
209
|
+
*/
|
|
210
|
+
relaunch?(work?: () => Promise<void>): Promise<void>
|
|
211
|
+
/** Every permission back to not asked, as the toolbar's button does. The shell's own. */
|
|
212
|
+
resetPermissions?(): void
|
|
213
|
+
/** `Appearance.setColorScheme`: pins the app's appearance until the next launch; null follows the config again. */
|
|
214
|
+
setAppColorScheme?(scheme: Appearance | null): void
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The shell's plugin state, by plugin id. Values are plain JSON, so they read the same from the app's window.
|
|
219
|
+
*/
|
|
220
|
+
export interface PluginHost {
|
|
221
|
+
/** The plugin's state, or undefined when no plugin with that id is loaded. */
|
|
222
|
+
get(id: string): Record<string, unknown> | undefined
|
|
223
|
+
set(id: string, patch: Record<string, unknown>): void
|
|
224
|
+
subscribe(id: string, listener: () => void): () => void
|
|
225
|
+
/** Sends an event on the plugin's channel. `from` says which side sent it, so each side hears only the other. */
|
|
226
|
+
emit(id: string, event: string, payload: unknown, from: 'app' | 'shell'): void
|
|
227
|
+
on(id: string, event: string, listener: (payload: unknown) => void, side: 'app' | 'shell'): () => void
|
|
228
|
+
/** How many listeners one side has for an event. */
|
|
229
|
+
listenerCount(id: string, event: string, side: 'app' | 'shell'): number
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
declare global {
|
|
233
|
+
interface Window {
|
|
234
|
+
__webSimHost?: SimHost
|
|
235
|
+
__webSimBackListeners?: Set<() => boolean>
|
|
236
|
+
/** On the window of a phone popped out of the shell's tab: the shell's own window. */
|
|
237
|
+
__webSimShell?: Window
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
let fallback: SimHost | null = null
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A host for the app opened on its own, outside the shell: the default device, never changing.
|
|
245
|
+
*/
|
|
246
|
+
function fallbackHost(): SimHost {
|
|
247
|
+
const state: SimState = {
|
|
248
|
+
device: DEVICES.find((device) => device.id === DEFAULT_DEVICE_ID)!,
|
|
249
|
+
orientation: 'portrait',
|
|
250
|
+
appearance: 'light',
|
|
251
|
+
appAppearance: 'light',
|
|
252
|
+
}
|
|
253
|
+
const permissions = new Map<PermissionKind, PermissionStatus>()
|
|
254
|
+
return {
|
|
255
|
+
getState: () => state,
|
|
256
|
+
subscribe: () => () => undefined,
|
|
257
|
+
setStatusBar: () => undefined,
|
|
258
|
+
app: { name: document.title, slug: 'app', version: '1.0.0', bundleId: 'com.example.app', splash: null, usageDescriptions: {} },
|
|
259
|
+
showDialog: (dialog) => {
|
|
260
|
+
if (dialog.kind === 'alert') {
|
|
261
|
+
window.alert([dialog.title, dialog.message].filter(Boolean).join('\n\n'))
|
|
262
|
+
}
|
|
263
|
+
return Promise.resolve({ button: dialog.kind === 'permission' ? 1 : 0 })
|
|
264
|
+
},
|
|
265
|
+
haptic: () => undefined,
|
|
266
|
+
getPermission: (kind) => permissions.get(kind) ?? 'undetermined',
|
|
267
|
+
setPermission: (kind, status) => permissions.set(kind, status),
|
|
268
|
+
notify: () => Promise.resolve(false),
|
|
269
|
+
preventAutoHideSplash: () => undefined,
|
|
270
|
+
hideSplash: () => undefined,
|
|
271
|
+
appRendered: () => undefined,
|
|
272
|
+
setOrientationLock: () => undefined,
|
|
273
|
+
getOrientationLock: () => null,
|
|
274
|
+
setNavigationBar: () => undefined,
|
|
275
|
+
plugins: {
|
|
276
|
+
get: () => undefined,
|
|
277
|
+
set: () => undefined,
|
|
278
|
+
subscribe: () => () => undefined,
|
|
279
|
+
emit: () => undefined,
|
|
280
|
+
on: () => () => undefined,
|
|
281
|
+
listenerCount: () => 0,
|
|
282
|
+
},
|
|
283
|
+
getNavigationBar: () => ({ style: 'auto', hidden: false }),
|
|
284
|
+
log: () => undefined,
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* The shell's window, which outlives the app's, so state kept on it lasts across reloads. Usually the app's parent;
|
|
290
|
+
* while the phone is popped out into its own window, that window points back to the shell's.
|
|
291
|
+
*/
|
|
292
|
+
export function shellWindow(): Window {
|
|
293
|
+
try {
|
|
294
|
+
const parent = window.parent
|
|
295
|
+
if (parent !== window && parent.__webSimHost !== undefined) {
|
|
296
|
+
return parent.__webSimShell ?? parent
|
|
297
|
+
}
|
|
298
|
+
} catch {
|
|
299
|
+
// A parent on another origin.
|
|
300
|
+
}
|
|
301
|
+
return window
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function getHost(): SimHost {
|
|
305
|
+
if (window.__webSimHost !== undefined) {
|
|
306
|
+
return window.__webSimHost
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
if (window.parent !== window && window.parent.__webSimHost !== undefined) {
|
|
310
|
+
return window.parent.__webSimHost
|
|
311
|
+
}
|
|
312
|
+
} catch {
|
|
313
|
+
// A parent on another origin.
|
|
314
|
+
}
|
|
315
|
+
fallback ??= fallbackHost()
|
|
316
|
+
return fallback
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export function getState(): SimState {
|
|
320
|
+
return getHost().getState()
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function subscribe(listener: () => void): () => void {
|
|
324
|
+
return getHost().subscribe(listener)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export function useSimState(): SimState {
|
|
328
|
+
return useSyncExternalStore(subscribe, getState)
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export function platform(): Platform {
|
|
332
|
+
return getState().device.platform
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** The screen's size in the current orientation. */
|
|
336
|
+
export function screenSize(state: SimState = getState()): { width: number; height: number } {
|
|
337
|
+
const { width, height } = state.device.screen
|
|
338
|
+
return state.orientation === 'portrait' ? { width, height } : { width: height, height: width }
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function insets(state: SimState = getState()): Insets {
|
|
342
|
+
return state.device.insets[state.orientation]
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* A value every copy of an override shares for the shell's session, such as the battery's level: kept on the host,
|
|
347
|
+
* made by `create` on first use, gone when the shell reloads.
|
|
348
|
+
*/
|
|
349
|
+
export function sessionValue<T>(key: string, create: () => T): T {
|
|
350
|
+
const host = getHost() as SimHost & { __webSimSession?: Map<string, unknown> }
|
|
351
|
+
host.__webSimSession ??= new Map()
|
|
352
|
+
if (!host.__webSimSession.has(key)) {
|
|
353
|
+
host.__webSimSession.set(key, create())
|
|
354
|
+
}
|
|
355
|
+
return host.__webSimSession.get(key) as T
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* What the device reports about its hardware, with generic values for a device the catalogue does not describe.
|
|
360
|
+
*/
|
|
361
|
+
export function hardware(device: Device = getState().device): DeviceHardware & { modelName: string } {
|
|
362
|
+
const ios = device.platform === 'ios'
|
|
363
|
+
return {
|
|
364
|
+
brand: ios ? 'Apple' : 'generic',
|
|
365
|
+
manufacturer: ios ? 'Apple' : 'unknown',
|
|
366
|
+
osBuildId: ios ? '23A341' : 'AP4A.250205.002',
|
|
367
|
+
yearClass: 2024,
|
|
368
|
+
totalMemory: 8 * 1024 ** 3,
|
|
369
|
+
totalStorage: 128 * 1024 ** 3,
|
|
370
|
+
cpuArchitectures: [ios ? 'arm64e' : 'arm64-v8a'],
|
|
371
|
+
...device.hardware,
|
|
372
|
+
modelName: device.hardware?.modelName ?? device.label,
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export function setStatusBar(update: StatusBarUpdate): void {
|
|
377
|
+
getHost().setStatusBar(update)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Android's back button. Listeners run newest first until one returns true, as `BackHandler` runs them.
|
|
382
|
+
*/
|
|
383
|
+
export function addBackListener(listener: () => boolean): () => void {
|
|
384
|
+
const listeners = (window.__webSimBackListeners ??= new Set())
|
|
385
|
+
listeners.add(listener)
|
|
386
|
+
return () => listeners.delete(listener)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Presses back in the app's window: the listeners first, then the browser history, which expo-router and React
|
|
391
|
+
* Navigation keep in step with the screens on the web. Returns whether anything handled it.
|
|
392
|
+
*/
|
|
393
|
+
export function pressBack(appWindow: Window = window): boolean {
|
|
394
|
+
const listeners = [...(appWindow.__webSimBackListeners ?? [])].reverse()
|
|
395
|
+
if (listeners.some((listener) => listener())) {
|
|
396
|
+
return true
|
|
397
|
+
}
|
|
398
|
+
if (appWindow.history.length > 1) {
|
|
399
|
+
appWindow.history.back()
|
|
400
|
+
return true
|
|
401
|
+
}
|
|
402
|
+
return false
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export function app(): AppInfo {
|
|
406
|
+
return getHost().app
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export function showDialog(dialog: Dialog): Promise<DialogResult> {
|
|
410
|
+
return getHost().showDialog(dialog)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export function haptic(kind: HapticKind, call?: HapticCall): void {
|
|
414
|
+
getHost().haptic(kind, call)
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export function notify(notification: SimNotification): Promise<boolean> {
|
|
418
|
+
return getHost().notify(notification)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* The shape Expo's permission APIs answer with. On iOS a denied permission cannot be asked for again; on Android it
|
|
423
|
+
* can, until the user picks "Don't allow" twice, which is simplified here to the same rule.
|
|
424
|
+
*/
|
|
425
|
+
export type PermissionResponse = {
|
|
426
|
+
status: PermissionStatus
|
|
427
|
+
granted: boolean
|
|
428
|
+
canAskAgain: boolean
|
|
429
|
+
expires: 'never'
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export function permissionResponse(status: PermissionStatus): PermissionResponse {
|
|
433
|
+
return { status, granted: status === 'granted', canAskAgain: status === 'undetermined', expires: 'never' }
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export function getPermission(kind: PermissionKind): PermissionResponse {
|
|
437
|
+
return permissionResponse(getHost().getPermission(kind))
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Asks for a permission as the OS does: the prompt shows only while it is undetermined, and the answer is kept
|
|
442
|
+
* until the simulator's permissions are reset. `message` is the iOS usage description, when the module has one.
|
|
443
|
+
*/
|
|
444
|
+
export async function requestPermission(kind: PermissionKind, message?: string): Promise<PermissionResponse> {
|
|
445
|
+
const host = getHost()
|
|
446
|
+
const current = host.getPermission(kind)
|
|
447
|
+
if (current !== 'undetermined') {
|
|
448
|
+
return permissionResponse(current)
|
|
449
|
+
}
|
|
450
|
+
const { button } = await host.showDialog({ kind: 'permission', permission: kind, message })
|
|
451
|
+
const status: PermissionStatus = button === 0 ? 'denied' : 'granted'
|
|
452
|
+
host.setPermission(kind, status)
|
|
453
|
+
return permissionResponse(status)
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* An override's handle on its plugin: the state the plugin's panel shows and changes, and the events between them.
|
|
458
|
+
* The state is the plugin's `initialState` until the panel changes it; outside the shell, `fallback`.
|
|
459
|
+
*
|
|
460
|
+
* ```ts
|
|
461
|
+
* const battery = plugin('battery', { level: 1, charging: false })
|
|
462
|
+
* battery.get().level
|
|
463
|
+
* battery.subscribe(() => emitLevel(battery.get().level))
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
466
|
+
export function plugin<S extends Record<string, unknown>>(id: string, fallback: S) {
|
|
467
|
+
const host = () => getHost().plugins
|
|
468
|
+
const get = (): S => (host().get(id) as S | undefined) ?? fallback
|
|
469
|
+
const subscribe = (listener: () => void) => host().subscribe(id, listener)
|
|
470
|
+
return {
|
|
471
|
+
get,
|
|
472
|
+
set: (patch: Partial<S>) => host().set(id, patch),
|
|
473
|
+
subscribe,
|
|
474
|
+
/** Calls `listener` with each new state, and returns its removal. */
|
|
475
|
+
watch(listener: (state: S, previous: S) => void): () => void {
|
|
476
|
+
let previous = get()
|
|
477
|
+
return subscribe(() => {
|
|
478
|
+
const next = get()
|
|
479
|
+
if (next !== previous) {
|
|
480
|
+
const last = previous
|
|
481
|
+
previous = next
|
|
482
|
+
listener(next, last)
|
|
483
|
+
}
|
|
484
|
+
})
|
|
485
|
+
},
|
|
486
|
+
use: (): S => useSyncExternalStore(subscribe, get),
|
|
487
|
+
/** Sends an event to the plugin's shell side. */
|
|
488
|
+
emit: (event: string, payload?: unknown) => host().emit(id, event, payload, 'app'),
|
|
489
|
+
/** Listens to events the plugin's panel or the CLI sends. */
|
|
490
|
+
on: (event: string, listener: (payload: unknown) => void) => host().on(id, event, listener, 'app'),
|
|
491
|
+
/** Adds an event to the simulator's log under the plugin's id: `log('request', ...)` logs `network.request`. */
|
|
492
|
+
log: (kind: string, summary: string, data?: unknown, options?: LogOptions) => log(kind.startsWith(`${id}.`) ? kind : `${id}.${kind}`, summary, data, options),
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export type LogOptions = { level?: Level; span?: string; cause?: string; maxString?: number }
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Adds an event to the simulator's log, which `web-sim logs` and the shell show. `kind` is dotted and source-first
|
|
500
|
+
* (`notifications.scheduled`); `summary` is one readable line; `data` is any value, copied as JSON with long strings
|
|
501
|
+
* cut. Events logged here are the app's (`actor: app`).
|
|
502
|
+
*
|
|
503
|
+
* ```ts
|
|
504
|
+
* log('notifications.scheduled', 'Reminder in 30 s', { identifier, trigger }, { span: identifier })
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
507
|
+
export function log(kind: string, summary: string, data?: unknown, options?: LogOptions): void {
|
|
508
|
+
getHost().log?.({ kind, summary, data, actor: 'app', ...options })
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/** A line in a log a plugin keeps in its state: what the app asked for, or wrote. */
|
|
512
|
+
export type LogEntry = { time: number; text: string }
|
|
513
|
+
|
|
514
|
+
/** Adds an entry to a log, keeping the newest `max`. A repeat of the last entry replaces it, with the new time. */
|
|
515
|
+
export function appendLog(entries: LogEntry[], text: string, max = 20): LogEntry[] {
|
|
516
|
+
const last = entries.at(-1)
|
|
517
|
+
const base = last !== undefined && last.text === text ? entries.slice(0, -1) : entries
|
|
518
|
+
return [...base, { time: Date.now(), text }].slice(-max)
|
|
519
|
+
}
|