UNPKG

@manapotion/core

Version:

443 lines (422 loc) 15.2 kB
import * as zustand_vanilla from 'zustand/vanilla'; type Browser = { readonly isFullscreen: boolean; readonly isPageVisible: boolean; readonly isPageFocused: boolean; readonly isDesktop: boolean; readonly isMobile: boolean; readonly isPortrait: boolean; readonly isLandscape: boolean; readonly width: number; readonly height: number; readonly pointerLockSupported: boolean; }; declare const browserStore: Omit<zustand_vanilla.StoreApi<Browser>, "setState"> & { setState(partial: Browser | Partial<Browser> | ((state: Browser) => Browser | Partial<Browser>), replace?: false | undefined, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; setState(state: Browser | ((state: Browser) => Browser), replace: true, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; }; declare const getBrowser: () => Browser; type Keyboard = { readonly codes: Record<string, boolean>; readonly keys: Record<string, boolean>; readonly ctrl: boolean; readonly shift: boolean; readonly alt: boolean; readonly meta: boolean; }; declare const keyboardStore: Omit<zustand_vanilla.StoreApi<Keyboard>, "setState"> & { setState(partial: Keyboard | Partial<Keyboard> | ((state: Keyboard) => Keyboard | Partial<Keyboard>), replace?: false | undefined, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; setState(state: Keyboard | ((state: Keyboard) => Keyboard), replace: true, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; }; declare const getKeyboard: () => Keyboard; declare const resetKeyboard: () => void; type MousePosition = { readonly x: number; readonly y: number; }; type MouseMovement = { readonly x: number; readonly y: number; }; type MouseWheel = { readonly y: number; }; type MouseButtons = { readonly left: boolean; readonly middle: boolean; readonly right: boolean; }; type Mouse = { readonly locked: boolean; readonly position: MousePosition; readonly movement: MouseMovement; readonly wheel: MouseWheel; readonly buttons: MouseButtons; }; declare const mouseStore: Omit<zustand_vanilla.StoreApi<Mouse>, "setState"> & { setState(partial: Mouse | Partial<Mouse> | ((state: Mouse) => Mouse | Partial<Mouse>), replace?: false | undefined, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; setState(state: Mouse | ((state: Mouse) => Mouse), replace: true, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; }; declare const getMouse: () => Mouse; declare const resetMouse: () => void; type Joystick = { isActive: boolean; identifier: number | null; origin: { x: number | null; y: number | null; angle: number | null; distance: number | null; distanceRatio: number | null; }; follow: { x: number | null; y: number | null; angle: number | null; distance: number | null; distanceRatio: number | null; }; current: { x: number | null; y: number | null; }; movement: { x: number; y: number; }; }; declare const createJoystick: () => Joystick; type Joysticks = { movement: Joystick; rotation: Joystick; }; declare const joysticksStore: Omit<zustand_vanilla.StoreApi<Joysticks>, "setState"> & { setState(partial: Joysticks | Partial<Joysticks> | ((state: Joysticks) => Joysticks | Partial<Joysticks>), replace?: false | undefined, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; setState(state: Joysticks | ((state: Joysticks) => Joysticks), replace: true, action?: (string | { [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; type: string; }) | undefined): void; }; declare const getJoysticks: () => Joysticks; declare const resetJoysticks: () => void; type MainLoopState = { time: number; delta: number; timeRunning: number; callbackCount: number; }; type MainLoopEffectCallback = (callback: MainLoopState) => void; type MainLoopEffectOptions = { throttle?: number; stage?: number; }; declare const addMainLoopEffect: (callback: MainLoopEffectCallback, options?: MainLoopEffectOptions) => () => void; declare const pauseMainLoop: () => void; declare const resumeMainLoop: () => void; declare const enterFullscreen: () => any; declare const exitFullscreen: () => any; type OrientationLockType = 'any' | 'landscape' | 'landscape-primary' | 'landscape-secondary' | 'natural' | 'portrait' | 'portrait-primary' | 'portrait-secondary'; declare const lockOrientation: (type: OrientationLockType) => any; declare const unlockOrientation: () => void; declare const lockKeys: (keys: string[]) => any; declare const unlockKeys: () => any; declare const lockPointer: (options?: PointerLockOptions) => false | Promise<void>; declare const unlockPointer: () => false | void; declare const tailwindTheme: { screens: { '5xs': string; '4xs': string; '3xs': string; '2xs': string; xs: string; sm: string; md: string; lg: string; xl: string; '2xl': string; '3xl': string; '4xl': string; '5xl': string; }; extend: { screens: { 'max-5xs': { raw: string; }; 'max-4xs': { raw: string; }; 'max-3xs': { raw: string; }; 'max-2xs': { raw: string; }; 'max-xs': { raw: string; }; 'max-sm': { raw: string; }; 'max-md': { raw: string; }; 'max-lg': { raw: string; }; 'max-xl': { raw: string; }; 'max-2xl': { raw: string; }; 'max-3xl': { raw: string; }; 'max-4xl': { raw: string; }; 'max-5xl': { raw: string; }; '5xs-h': { raw: string; }; '4xs-h': { raw: string; }; '3xs-h': { raw: string; }; '2xs-h': { raw: string; }; 'xs-h': { raw: string; }; 'sm-h': { raw: string; }; 'md-h': { raw: string; }; 'lg-h': { raw: string; }; 'xl-h': { raw: string; }; '2xl-h': { raw: string; }; '3xl-h': { raw: string; }; '4xl-h': { raw: string; }; '5xl-h': { raw: string; }; 'max-5xs-h': { raw: string; }; 'max-4xs-h': { raw: string; }; 'max-3xs-h': { raw: string; }; 'max-2xs-h': { raw: string; }; 'max-xs-h': { raw: string; }; 'max-sm-h': { raw: string; }; 'max-md-h': { raw: string; }; 'max-lg-h': { raw: string; }; 'max-xl-h': { raw: string; }; 'max-2xl-h': { raw: string; }; 'max-3xl-h': { raw: string; }; 'max-4xl-h': { raw: string; }; 'max-5xl-h': { raw: string; }; mobile: { raw: string; }; desktop: { raw: string; }; }; }; }; type JoystickAreaProps = { joystick: Joystick; mode?: 'origin' | 'follow'; element: HTMLElement; maxFollowDistance?: number; maxOriginDistance?: number; onStart?: (joystick: Joystick) => void; onMove?: (joystick: Joystick) => void; onEnd?: (joystick: Joystick) => void; }; declare const mountJoystickArea: ({ joystick, mode, maxFollowDistance, maxOriginDistance, element, onStart, onEnd, onMove, }: JoystickAreaProps) => () => void; type DeviceTypeChangePayload = { isDesktop: boolean; isMobile: boolean; }; type DeviceTypeListenerProps = { onDeviceTypeChange?: (payload: DeviceTypeChangePayload) => void; }; declare const mountDeviceTypeListener: ({ onDeviceTypeChange }: DeviceTypeListenerProps) => () => void; type FullscreenChangePayload = { isFullscreen: boolean; }; type FullscreenListenerProps = { onFullscreenChange?: (payload: FullscreenChangePayload) => void; }; declare const mountFullscreenListener: ({ onFullscreenChange }: FullscreenListenerProps) => () => void; type KeyState = { code: string; key: string; ctrl: boolean; shift: boolean; alt: boolean; meta: boolean; }; type KeyDownPayload = KeyState; type KeyUpPayload = KeyState; type KeyboardListenerProps = { onKeyDown?: (payload: KeyDownPayload) => void; onKeyUp?: (payload: KeyUpPayload) => void; }; declare const mountKeyboardListener: ({ onKeyUp, onKeyDown }: KeyboardListenerProps) => () => void; type LeftMouseButtonDownPayload = Record<string, never>; type MiddleMouseButtonDownPayload = Record<string, never>; type RightMouseButtonDownPayload = Record<string, never>; type LeftMouseButtonUpPayload = Record<string, never>; type MiddleMouseButtonUpPayload = Record<string, never>; type RightMouseButtonUpPayload = Record<string, never>; type MouseButtonsListenerProps = { onLeftMouseButtonDown?: (payload: LeftMouseButtonDownPayload) => void; onMiddleMouseButtonDown?: (payload: MiddleMouseButtonDownPayload) => void; onRightMouseButtonDown?: (payload: RightMouseButtonDownPayload) => void; onLeftMouseButtonUp?: (payload: LeftMouseButtonUpPayload) => void; onMiddleMouseButtonUp?: (payload: MiddleMouseButtonUpPayload) => void; onRightMouseButtonUp?: (payload: RightMouseButtonUpPayload) => void; }; declare const mountMouseButtonsListener: ({ onLeftMouseButtonDown, onMiddleMouseButtonDown, onRightMouseButtonDown, onLeftMouseButtonUp, onMiddleMouseButtonUp, onRightMouseButtonUp, }: MouseButtonsListenerProps) => () => void; type MouseMovePayload = { position: { x: number; y: number; }; movement: { x: number; y: number; }; }; type MouseMoveListenerProps = { mouseMovementResetDelay?: number; onMouseMove?: (payload: MouseMovePayload) => void; }; declare const mountMouseMoveListener: ({ onMouseMove, mouseMovementResetDelay, }: MouseMoveListenerProps) => () => void; type MouseScrollPayload = { y: number; }; type MouseScrollListenerProps = { onScroll?: (payload: MouseScrollPayload) => void; mouseScrollResetDelay?: number; }; declare const mountMouseScrollListener: ({ onScroll, mouseScrollResetDelay, }: MouseScrollListenerProps) => () => void; type PageFocusChangePayload = { isPageFocused: boolean; }; type PageFocusListenerProps = { onPageFocusChange?: (payload: PageFocusChangePayload) => void; }; declare const mountPageFocusListener: ({ onPageFocusChange }: PageFocusListenerProps) => () => void; type PageVisibilityPayload = { isPageVisible: boolean; }; type PageVisibilityListenerProps = { onPageVisibilityChange?: (payload: PageVisibilityPayload) => void; }; declare const mountPageVisibilityListener: ({ onPageVisibilityChange, }: PageVisibilityListenerProps) => () => void; type PointerLockChangePayload = { isPointerLocked: boolean; }; type PointerLockListenerProps = { onPointerLockChange?: (isPointerLocked: PointerLockChangePayload) => void; }; declare const mountPointerLockListener: ({ onPointerLockChange }: PointerLockListenerProps) => () => void; type ResizePayload = { width: number; height: number; }; type ResizeListenerProps = { onResize?: (payload: ResizePayload) => void; }; declare const mountResizeListener: ({ onResize }: ResizeListenerProps) => () => void; type ScreenOrientationChangePayload = { isLandscape: boolean; isPortrait: boolean; }; type ScreenOrientationListenerProps = { onScreenOrientationChange?: (payload: ScreenOrientationChangePayload) => void; }; declare const mountScreenOrientationListener: ({ onScreenOrientationChange, }: ScreenOrientationListenerProps) => () => void; export { type Browser, type DeviceTypeChangePayload, type DeviceTypeListenerProps, type FullscreenChangePayload, type FullscreenListenerProps, type Joystick, type JoystickAreaProps, type Joysticks, type KeyDownPayload, type KeyUpPayload, type Keyboard, type KeyboardListenerProps, type LeftMouseButtonDownPayload, type LeftMouseButtonUpPayload, type MainLoopEffectCallback, type MainLoopEffectOptions, type MainLoopState, type MiddleMouseButtonDownPayload, type MiddleMouseButtonUpPayload, type Mouse, type MouseButtons, type MouseButtonsListenerProps, type MouseMoveListenerProps, type MouseMovePayload, type MouseMovement, type MousePosition, type MouseScrollListenerProps, type MouseScrollPayload, type MouseWheel, type PageFocusChangePayload, type PageFocusListenerProps, type PageVisibilityListenerProps, type PageVisibilityPayload, type PointerLockChangePayload, type PointerLockListenerProps, type ResizeListenerProps, type ResizePayload, type RightMouseButtonDownPayload, type RightMouseButtonUpPayload, type ScreenOrientationChangePayload, type ScreenOrientationListenerProps, addMainLoopEffect, browserStore, createJoystick, enterFullscreen, exitFullscreen, getBrowser, getJoysticks, getKeyboard, getMouse, joysticksStore, keyboardStore, lockKeys, lockOrientation, lockPointer, mountDeviceTypeListener, mountFullscreenListener, mountJoystickArea, mountKeyboardListener, mountMouseButtonsListener, mountMouseMoveListener, mountMouseScrollListener, mountPageFocusListener, mountPageVisibilityListener, mountPointerLockListener, mountResizeListener, mountScreenOrientationListener, mouseStore, pauseMainLoop, resetJoysticks, resetKeyboard, resetMouse, resumeMainLoop, tailwindTheme, unlockKeys, unlockOrientation, unlockPointer };