fitbit-sdk-types
Advanced tools
Comparing version 4.0.0 to 4.0.1
{ | ||
"name": "fitbit-sdk-types", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"author": "Sergio Morchón Poveda <sergio.morchon@outlook.com>", | ||
@@ -5,0 +5,0 @@ "description": "Types for Fitbit SDK.", |
@@ -8,6 +8,13 @@ declare module 'accelerometer' { | ||
interface Accelerometer | ||
extends Sensor<AccelerometerReading>, | ||
AccelerometerReading {} | ||
class Accelerometer extends SensorBase {} | ||
interface BatchedAccelerometerReading | ||
extends BatchedSensorReading<AccelerometerReading> {} | ||
type AccelerometerConstructor = new (options?: SensorOptions) => Sensor< | ||
AccelerometerReading, | ||
BatchedAccelerometerReading | ||
>; | ||
const Accelerometer: void | AccelerometerConstructor; | ||
export { AccelerometerReading, BatchedAccelerometerReading, Accelerometer }; | ||
} |
@@ -5,4 +5,14 @@ declare module 'barometer' { | ||
} | ||
interface Barometer extends Sensor<BarometerReading>, BarometerReading {} | ||
class Barometer extends SensorBase {} | ||
interface BatchedBarometerReading | ||
extends BatchedSensorReading<BarometerReading> {} | ||
type BarometerConstructor = new (options?: SensorOptions) => Sensor< | ||
BarometerReading, | ||
BatchedBarometerReading | ||
>; | ||
const Barometer: void | BarometerConstructor; | ||
export { BarometerReading, BatchedBarometerReading, Barometer }; | ||
} |
@@ -5,6 +5,11 @@ declare module 'body-presence' { | ||
} | ||
interface BodyPresenceSensor extends Sensor<BodyPresenceReading> {} | ||
class BodyPresenceSensor extends SensorBase { | ||
readonly present: boolean; | ||
} | ||
type BodyPresenceConstructor = new (options?: SensorOptions) => Sensor< | ||
BodyPresenceReading, | ||
never | ||
>; | ||
const BodyPresenceSensor: void | BodyPresenceConstructor; | ||
export { BodyPresenceReading, BodyPresenceSensor }; | ||
} |
@@ -7,4 +7,14 @@ declare module 'gyroscope' { | ||
} | ||
interface Gyroscope extends Sensor<GyroscopeReading>, GyroscopeReading {} | ||
class Gyroscope extends SensorBase {} | ||
interface BatchedGyroscopeReading | ||
extends BatchedSensorReading<GyroscopeReading> {} | ||
type GyroscopeConstructor = new (options?: SensorOptions) => Sensor< | ||
GyroscopeReading, | ||
BatchedGyroscopeReading | ||
>; | ||
const Gyroscope: void | GyroscopeConstructor; | ||
export { GyroscopeReading, BatchedGyroscopeReading, Gyroscope }; | ||
} |
@@ -5,6 +5,18 @@ declare module 'heart-rate' { | ||
} | ||
interface HeartRateSensor | ||
extends Sensor<HeartRateSensorReading>, | ||
HeartRateSensorReading {} | ||
class HeartRateSensor extends SensorBase {} | ||
interface BatchedHeartRateSensorReading | ||
extends BatchedSensorReading<HeartRateSensorReading> {} | ||
type HeartRateSensorConstructor = new (options?: SensorOptions) => Sensor< | ||
HeartRateSensorReading, | ||
BatchedHeartRateSensorReading | ||
>; | ||
const HeartRateSensor: void | HeartRateSensorConstructor; | ||
export { | ||
HeartRateSensorReading, | ||
BatchedHeartRateSensorReading, | ||
HeartRateSensor, | ||
}; | ||
} |
declare module 'orientation' { | ||
type Quaternion = [number, number, number, number]; | ||
interface BatchedOrientationSensorReading | ||
extends BatchedSensorReading< | ||
SensorReading & { | ||
readonly i: number; | ||
readonly j: number; | ||
readonly k: number; | ||
readonly scalar: number; | ||
} | ||
> {} | ||
interface OrientationSensorReading extends SensorReading { | ||
readonly i: number; | ||
readonly j: number; | ||
readonly k: number; | ||
readonly scalar: number; | ||
} | ||
interface OrientationSensor extends Sensor<OrientationSensorReading> { | ||
readonly quaternion: Quaternion | null; | ||
readonly timestamp: number | null; | ||
} | ||
class OrientationSensor extends SensorBase {} | ||
type OrientationSensorConstructor = new (options?: SensorOptions) => Sensor< | ||
OrientationSensorReading, | ||
BatchedOrientationSensorReading | ||
>; | ||
const OrientationSensor: void | OrientationSensorConstructor; | ||
export { | ||
BatchedOrientationSensorReading, | ||
OrientationSensorReading, | ||
OrientationSensor, | ||
}; | ||
} |
@@ -1,2 +0,2 @@ | ||
type BatchedReading<Reading> = { | ||
type BatchedSensorReading<Reading> = { | ||
[P in keyof Reading]: Reading[P] extends number | ||
@@ -11,23 +11,17 @@ ? Float32Array | ||
interface Sensor<Reading extends SensorReading, EventMap = {}> | ||
extends EventTarget< | ||
EventMap & { | ||
activate: Event; | ||
error: SensorErrorEvent; | ||
reading: Event; | ||
} | ||
> { | ||
onactivate: (event: Event) => void; | ||
onerror: (event: SensorErrorEvent) => void; | ||
onreading: (event: Event) => void; | ||
readonly readings: BatchedReading<Reading>; | ||
readonly activated: boolean; | ||
start(): void; | ||
stop(): void; | ||
} | ||
type Sensor<Reading extends SensorReading, BatchedReading> = Reading & | ||
EventTarget<{ | ||
activate: Event; | ||
error: SensorErrorEvent; | ||
reading: Event; | ||
}> & { | ||
onactivate: (event: Event) => void; | ||
onerror: (event: SensorErrorEvent) => void; | ||
onreading: (event: Event) => void; | ||
readonly readings: BatchedReading; | ||
readonly activated: boolean; | ||
start(): void; | ||
stop(): void; | ||
}; | ||
declare class SensorBase { | ||
constructor(options?: SensorOptions); | ||
} | ||
interface SensorErrorEvent { | ||
@@ -34,0 +28,0 @@ readonly defaultPrevented: boolean; |
47405
1543