@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,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `web-sim/shell`: what a plugin's shell module imports.
|
|
3
|
+
*/
|
|
4
|
+
export { defineShellPlugin } from './types.ts'
|
|
5
|
+
export type { OverlayProps, PanelProps, PluginContext, PluginState, ScreenEffect, ShellPlugin, StatusBarItems } from './types.ts'
|
|
6
|
+
export {
|
|
7
|
+
Button,
|
|
8
|
+
CodeBlock,
|
|
9
|
+
Copyable,
|
|
10
|
+
Field,
|
|
11
|
+
FileButton,
|
|
12
|
+
IconButton,
|
|
13
|
+
ImagePreview,
|
|
14
|
+
List,
|
|
15
|
+
ListItem,
|
|
16
|
+
Log,
|
|
17
|
+
NumberField,
|
|
18
|
+
Progress,
|
|
19
|
+
Readout,
|
|
20
|
+
readDataUrl,
|
|
21
|
+
Row,
|
|
22
|
+
Section,
|
|
23
|
+
Segmented,
|
|
24
|
+
Select,
|
|
25
|
+
Slider,
|
|
26
|
+
TextField,
|
|
27
|
+
Thumbnails,
|
|
28
|
+
Toggle,
|
|
29
|
+
Tree,
|
|
30
|
+
} from './ui.tsx'
|
|
31
|
+
export type { Thumbnail, TreeNode } from './ui.tsx'
|
|
32
|
+
export type { LogEntry, SimState } from '../runtime/index.ts'
|
|
33
|
+
export type { Appearance, Device, Insets, Orientation, Platform } from '../devices/types.ts'
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ComponentType } from 'react'
|
|
2
|
+
import type { Device, Insets, Orientation, Platform } from '../devices/types.ts'
|
|
3
|
+
import type { EventInput, Level } from '../node/events/shared.ts'
|
|
4
|
+
import type { Dialog, DialogResult, SimState } from '../runtime/index.ts'
|
|
5
|
+
|
|
6
|
+
export type PluginState = Record<string, unknown>
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What a plugin's actions, setup and panel get: its state, and its event channel to the overrides running in the
|
|
10
|
+
* app.
|
|
11
|
+
*/
|
|
12
|
+
export type PluginContext<S extends PluginState> = {
|
|
13
|
+
state(): S
|
|
14
|
+
set(patch: Partial<S>): void
|
|
15
|
+
/** Calls `listener` after each change to the state, from anywhere. Returns its removal. */
|
|
16
|
+
subscribe(listener: () => void): () => void
|
|
17
|
+
/** Sends an event to the app's side: the overrides listening with `plugin(id).on(event, ...)`. */
|
|
18
|
+
emit(event: string, payload?: unknown): void
|
|
19
|
+
/** Listens to events the app's side sends with `plugin(id).emit(event, ...)`. */
|
|
20
|
+
on(event: string, listener: (payload: unknown) => void): () => void
|
|
21
|
+
/** How many listeners the app's side has for an event, to tell whether the app is listening at all. */
|
|
22
|
+
listenerCount(event: string): number
|
|
23
|
+
sim(): SimState
|
|
24
|
+
/**
|
|
25
|
+
* Answers the open system dialogs of a kind as the user would, for actions that stand in for the user (a match on
|
|
26
|
+
* the biometric prompt). Returns how many it answered.
|
|
27
|
+
*/
|
|
28
|
+
answerDialog(kind: Dialog['kind'], result: DialogResult): number
|
|
29
|
+
/** Runs one of this plugin's actions, as part of whatever this context is doing. */
|
|
30
|
+
run(action: string, args?: unknown): unknown
|
|
31
|
+
/**
|
|
32
|
+
* Adds an event to the simulator's log, such as `push.received`; the kind is put under the plugin's id
|
|
33
|
+
* (`notifications.push.received`). Who caused it comes from the context: the panel, the CLI, the plugin's setup.
|
|
34
|
+
*/
|
|
35
|
+
log(kind: string, summary: string, data?: unknown, options?: Pick<EventInput, 'level' | 'span'> & { maxString?: number }): void
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** What plugins draw in the system bars: the status bar's items, the home indicator. Later plugins' items win. */
|
|
39
|
+
export type StatusBarItems = {
|
|
40
|
+
battery?: { level: number; charging: boolean; lowPower?: boolean }
|
|
41
|
+
connection?: 'wifi' | 'cellular' | 'none'
|
|
42
|
+
airplaneMode?: boolean
|
|
43
|
+
/** iOS's home indicator: hidden when the app has it auto-hidden and it has faded out, or when forced off. */
|
|
44
|
+
homeIndicator?: { hidden: boolean }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** How a plugin changes the drawn screen. Every plugin's effects combine: filters in order, any one blocking input. */
|
|
48
|
+
export type ScreenEffect = {
|
|
49
|
+
/** A CSS filter over the screen, such as `brightness(0.4)`. */
|
|
50
|
+
filter?: string
|
|
51
|
+
/** Covers the screen so presses never reach the app; they still reach `onPress`. */
|
|
52
|
+
blockInput?: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type PanelProps<S extends PluginState> = {
|
|
56
|
+
state: S
|
|
57
|
+
set(patch: Partial<S>): void
|
|
58
|
+
emit(event: string, payload?: unknown): void
|
|
59
|
+
run(action: string, args?: unknown): unknown
|
|
60
|
+
sim: SimState
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* What a plugin's `Overlay` gets: its state and context, and the screen it draws on. Sizes are in points, in the
|
|
65
|
+
* current orientation.
|
|
66
|
+
*/
|
|
67
|
+
export type OverlayProps<S extends PluginState> = {
|
|
68
|
+
state: S
|
|
69
|
+
context: PluginContext<S>
|
|
70
|
+
run(action: string, args?: unknown): unknown
|
|
71
|
+
sim: SimState
|
|
72
|
+
device: Device
|
|
73
|
+
orientation: Orientation
|
|
74
|
+
screen: { width: number; height: number }
|
|
75
|
+
insets: Insets
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The shell's half of a plugin: the state it keeps for the simulated phone, the panel that shows and changes it, and
|
|
80
|
+
* the actions the panel and the CLI can run. The app's half is the plugin's overrides, which read and change the same
|
|
81
|
+
* state through `plugin(id)` from `web-sim/runtime`.
|
|
82
|
+
*
|
|
83
|
+
* State is plain JSON. It is kept per app in the shell's localStorage unless `persist` is false, so a scenario set up
|
|
84
|
+
* in the panel survives reloads.
|
|
85
|
+
*/
|
|
86
|
+
export type ShellPlugin<S extends PluginState = PluginState> = {
|
|
87
|
+
id: string
|
|
88
|
+
title: string
|
|
89
|
+
icon?: ComponentType<{ size?: number }>
|
|
90
|
+
/** The platforms the panel shows on. Default both. */
|
|
91
|
+
platforms?: Platform[]
|
|
92
|
+
initialState: S
|
|
93
|
+
persist?: boolean
|
|
94
|
+
/**
|
|
95
|
+
* The level of the `<plugin>.state` event logged for each change to the state, or false for none. Default `debug`:
|
|
96
|
+
* shown by `web-sim logs <plugin>`, hidden from the plain `web-sim logs`.
|
|
97
|
+
*/
|
|
98
|
+
logState?: Level | false
|
|
99
|
+
/** State keys whose changes are never logged, for values that change many times a second. */
|
|
100
|
+
logIgnore?: string[]
|
|
101
|
+
Panel?: ComponentType<PanelProps<S>>
|
|
102
|
+
/** Named operations, run by the panel and by `web-sim run <plugin> <action> [json]`. */
|
|
103
|
+
actions?: Record<string, (context: PluginContext<S>, args: unknown) => unknown>
|
|
104
|
+
/** What the status bar shows for this plugin's state. */
|
|
105
|
+
statusBar?: (state: S, sim: SimState) => StatusBarItems
|
|
106
|
+
/** How the plugin's state changes the drawn screen (dims it, blanks it). */
|
|
107
|
+
screen?: (state: S, sim: SimState) => ScreenEffect
|
|
108
|
+
/** Runs on every press on the device's screen, in the app or on the system UI over it. */
|
|
109
|
+
onPress?: (context: PluginContext<S>) => void
|
|
110
|
+
/**
|
|
111
|
+
* Drawn on the device's screen: over the app, under the system bars (status bar, home indicator, navigation bar)
|
|
112
|
+
* and the system's dialogs. It fills the screen and takes no presses itself (`pointer-events: none`); what it
|
|
113
|
+
* draws sets `pointer-events: auto` to take them. The on-screen keyboard is one.
|
|
114
|
+
*/
|
|
115
|
+
Overlay?: ComponentType<OverlayProps<S>>
|
|
116
|
+
/** Runs once when the shell starts, for timers and listeners. Returns its cleanup. */
|
|
117
|
+
setup?: (context: PluginContext<S>) => void | (() => void)
|
|
118
|
+
/**
|
|
119
|
+
* Runs at each new app run (a launch or reload), after the last run's event listeners are dropped: for what
|
|
120
|
+
* belongs to one run, such as a pending answer from the app.
|
|
121
|
+
*/
|
|
122
|
+
appStarted?: (context: PluginContext<S>) => void
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function defineShellPlugin<S extends PluginState>(plugin: ShellPlugin<S>): ShellPlugin<S> {
|
|
126
|
+
return plugin
|
|
127
|
+
}
|