You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2017/01/20 08:39:29 UTC

cordova-plugin-device-motion git commit: CB-12369: Add plugin typings from DefinitelyTyped

Repository: cordova-plugin-device-motion
Updated Branches:
  refs/heads/master ecee70968 -> 78b0ec866


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/78b0ec86
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/78b0ec86
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/78b0ec86

Branch: refs/heads/master
Commit: 78b0ec866fe99cae03c049fc9dccb4cf58b70111
Parents: ecee709
Author: Nikita Matrosov <v-...@microsoft.com>
Authored: Thu Jan 19 15:54:13 2017 +0300
Committer: Vladimir Kotikov <ko...@gmail.com>
Committed: Fri Jan 20 11:10:03 2017 +0300

----------------------------------------------------------------------
 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/78b0ec86/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/78b0ec86/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