cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [2/6] cordova-plugin-device-motion git commit: CB-12369: Add plugin typings from DefinitelyTyped
Date Fri, 03 Mar 2017 00:26:08 GMT
CB-12369: Add plugin typings from DefinitelyTyped

 This closes #50


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/commit/df3002e5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/df3002e5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/df3002e5

Branch: refs/heads/1.2.x
Commit: df3002e55a5df343490c45c63b6d1e411da0b9e2
Parents: 8e44d34
Author: Nikita Matrosov <v-nimatr@microsoft.com>
Authored: Thu Jan 19 15:54:13 2017 +0300
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Thu Mar 2 16:25:52 2017 -0800

----------------------------------------------------------------------
 package.json     |  1 +
 types/index.d.ts | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/df3002e5/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index c569cea..946da3d 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
   "name": "cordova-plugin-device-motion",
   "version": "1.2.4-dev",
   "description": "Cordova Device Motion Plugin",
+  "types": "./types/index.d.ts",
   "cordova": {
     "id": "cordova-plugin-device-motion",
     "platforms": [

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/df3002e5/types/index.d.ts
----------------------------------------------------------------------
diff --git a/types/index.d.ts b/types/index.d.ts
new file mode 100644
index 0000000..ae38803
--- /dev/null
+++ b/types/index.d.ts
@@ -0,0 +1,77 @@
+// Type definitions for Apache Cordova Device Motion plugin
+// Project: https://github.com/apache/cordova-plugin-device-motion
+// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// 
+// Copyright (c) Microsoft Open Technologies Inc
+// Licensed under the MIT license.
+
+interface Navigator {
+    /**
+     * This plugin provides access to the device's accelerometer. The accelerometer is a
motion sensor
+     * that detects the change (delta) in movement relative to the current device orientation,
+     * in three dimensions along the x, y, and z axis.
+     */
+    accelerometer: Accelerometer;
+}
+
+/**
+ * This plugin provides access to the device's accelerometer. The accelerometer is a motion
sensor
+ * that detects the change (delta) in movement relative to the current device orientation,
+ * in three dimensions along the x, y, and z axis.
+ */
+interface Accelerometer {
+    /**
+     * Stop watching the Acceleration referenced by the watchID parameter.
+     * @param watchID The ID returned by navigator.accelerometer.watchAcceleration.
+     */
+    clearWatch(watchID: WatchHandle): void;
+    /**
+     * Get the current acceleration along the x, y, and z axes.
+     * These acceleration values are returned to the accelerometerSuccess callback function.
+     * @param accelerometerSuccess Success callback that gets the Acceleration object.
+     * @param accelerometerError Success callback
+     */
+    getCurrentAcceleration(
+        accelerometerSuccess: (acceleration: Acceleration) => void,
+        accelerometerError: () => void): void;
+    /**
+     * Retrieves the device's current Acceleration at a regular interval, executing the
+     * accelerometerSuccess callback function each time. Specify the interval in milliseconds
+     * via the acceleratorOptions object's frequency parameter.
+     * The returned watch ID references the accelerometer's watch interval, and can be used
+     * with navigator.accelerometer.clearWatch to stop watching the accelerometer.
+     * @param  accelerometerSuccess Callback, that called at every time interval and passes
an Acceleration object.
+     * @param  accelerometerError   Error callback.
+     * @param  accelerometerOptions Object with options for watchAcceleration
+     */
+    watchAcceleration(
+        accelerometerSuccess: (acceleration: Acceleration) => void,
+        accelerometerError: () => void,
+        accelerometerOptions?: AccelerometerOptions): WatchHandle;
+}
+
+/**
+ * Contains Accelerometer data captured at a specific point in time. Acceleration values
include
+ * the effect of gravity (9.81 m/s^2), so that when a device lies flat and facing up, x,
y, and z
+ * values returned should be 0, 0, and 9.81.
+ */
+interface Acceleration {
+    /** Amount of acceleration on the x-axis. (in m/s^2) */
+    x: number;
+    /** Amount of acceleration on the y-axis. (in m/s^2) */
+    y: number;
+    /** Amount of acceleration on the z-axis. (in m/s^2) */
+    z: number;
+    /** Creation timestamp in milliseconds. */
+    timestamp: number;
+}
+
+/** Object with options for watchAcceleration */
+interface AccelerometerOptions {
+    /** How often to retrieve the Acceleration in milliseconds. (Default: 10000) */
+    frequency?: number;
+}
+
+/** Abstract type for watch IDs used by Accelerometer. Values of these type are actually
`number` at runtime.*/
+interface WatchHandle { }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message