@use-gesture/core
Advanced tools
Comparing version 10.2.18 to 10.2.19
# @use-gesture/core | ||
## 10.2.19 | ||
### Patch Changes | ||
- c7cb407bd: ts: Typescript 4.8 introduced a new mapping definition for NonNullable which breaks the package types. | ||
```ts | ||
// Native NonNullable Utility Type | ||
// definition on 4.7 and lower | ||
type NonNullable<T> = T extends null | undefined ? never : T | ||
// definition from 4.8 | ||
type NonNullable<T> = T & {} | ||
``` | ||
This fix reverts the definition of NonNullable so that it works. | ||
More information here: https://github.com/pmndrs/use-gesture/issues/501#issuecomment-1229486104 | ||
## 10.2.18 | ||
@@ -4,0 +23,0 @@ |
import { Controller } from '../Controller'; | ||
import { GestureKey, IngKey, State, Vector2 } from '../types'; | ||
import { NonUndefined } from '../types'; | ||
export interface Engine<Key extends GestureKey> { | ||
@@ -110,3 +111,3 @@ /** | ||
*/ | ||
start(event: NonNullable<State[Key]>['event']): void; | ||
start(event: NonUndefined<State[Key]>['event']): void; | ||
/** | ||
@@ -128,3 +129,3 @@ * Assign raw values to `state._values` and transformed values to | ||
*/ | ||
compute(event?: NonNullable<State[Key]>['event']): void; | ||
compute(event?: NonUndefined<State[Key]>['event']): void; | ||
/** | ||
@@ -131,0 +132,0 @@ * Fires the gesture handler. |
import { State } from './state'; | ||
import { Vector2, Target, PointerType } from './utils'; | ||
import { Vector2, Target, PointerType, NonUndefined } from './utils'; | ||
export declare type GestureKey = Exclude<keyof State, 'shared'>; | ||
@@ -42,3 +42,3 @@ export declare type CoordinatesKey = Exclude<GestureKey, 'pinch'>; | ||
*/ | ||
from?: Vector2 | ((state: NonNullable<State[T]>) => Vector2); | ||
from?: Vector2 | ((state: NonUndefined<State[T]>) => Vector2); | ||
/** | ||
@@ -45,0 +45,0 @@ * The handler will fire only when the gesture displacement is greater than |
import { GestureKey } from './config'; | ||
import { Vector2, WebKitGestureEvent } from './utils'; | ||
import { NonUndefined, Vector2, WebKitGestureEvent } from './utils'; | ||
export declare type IngKey = 'dragging' | 'wheeling' | 'moving' | 'hovering' | 'scrolling' | 'pinching'; | ||
@@ -268,2 +268,2 @@ export declare type SharedGestureState = { | ||
} | ||
export declare type FullGestureState<Key extends GestureKey> = SharedGestureState & NonNullable<State[Key]>; | ||
export declare type FullGestureState<Key extends GestureKey> = SharedGestureState & NonUndefined<State[Key]>; |
@@ -10,2 +10,3 @@ export declare type Vector2 = [number, number]; | ||
export declare type PointerType = 'mouse' | 'touch' | 'pen'; | ||
export declare type NonUndefined<T> = T extends undefined ? never : T; | ||
export declare type EventHandler<E extends Event = Event> = (event: E) => void; | ||
@@ -12,0 +13,0 @@ export interface DOMHandlers { |
{ | ||
"name": "@use-gesture/core", | ||
"version": "10.2.18", | ||
"version": "10.2.19", | ||
"description": "Core engine for receiving gestures", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,2 +6,3 @@ import { Controller } from '../Controller' | ||
import { GestureKey, IngKey, State, Vector2 } from '../types' | ||
import { NonUndefined } from '../types' | ||
@@ -183,3 +184,3 @@ /** | ||
*/ | ||
start(event: NonNullable<State[Key]>['event']) { | ||
start(event: NonUndefined<State[Key]>['event']) { | ||
const state = this.state | ||
@@ -227,3 +228,3 @@ const config = this.config | ||
*/ | ||
compute(event?: NonNullable<State[Key]>['event']) { | ||
compute(event?: NonUndefined<State[Key]>['event']) { | ||
const { state, config, shared } = this | ||
@@ -230,0 +231,0 @@ state.args = this.args |
import { State } from './state' | ||
import { Vector2, Target, PointerType } from './utils' | ||
import { Vector2, Target, PointerType, NonUndefined } from './utils' | ||
@@ -45,3 +45,3 @@ export type GestureKey = Exclude<keyof State, 'shared'> | ||
*/ | ||
from?: Vector2 | ((state: NonNullable<State[T]>) => Vector2) | ||
from?: Vector2 | ((state: NonUndefined<State[T]>) => Vector2) | ||
/** | ||
@@ -48,0 +48,0 @@ * The handler will fire only when the gesture displacement is greater than |
import { GestureKey } from './config' | ||
import { Vector2, WebKitGestureEvent } from './utils' | ||
import { NonUndefined, Vector2, WebKitGestureEvent } from './utils' | ||
@@ -265,2 +265,2 @@ export type IngKey = 'dragging' | 'wheeling' | 'moving' | 'hovering' | 'scrolling' | 'pinching' | ||
export type FullGestureState<Key extends GestureKey> = SharedGestureState & NonNullable<State[Key]> | ||
export type FullGestureState<Key extends GestureKey> = SharedGestureState & NonUndefined<State[Key]> |
@@ -6,6 +6,7 @@ export type Vector2 = [number, number] | ||
// rip off from React types | ||
// replaces NonUndefined from 4.7 and inferior versions | ||
export type NonUndefined<T> = T extends undefined ? never : T | ||
export type EventHandler<E extends Event = Event> = (event: E) => void | ||
// rip off from React types | ||
export interface DOMHandlers { | ||
@@ -12,0 +13,0 @@ // Clipboard Events |
342414
9677