@capacitor/motion 1.0.0 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,52 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.5](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/motion@1.0.4...@capacitor/motion@1.0.5) (2022-01-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * inline source code in esm map files ([#760](https://github.com/ionic-team/capacitor-plugins/issues/760)) ([a960489](https://github.com/ionic-team/capacitor-plugins/commit/a960489a19db0182b90d187a50deff9dfbe51038))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.0.4](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/motion@1.0.3...@capacitor/motion@1.0.4) (2021-11-17)
18
+
19
+ **Note:** Version bump only for package @capacitor/motion
20
+
21
+
22
+
23
+
24
+
25
+ ## [1.0.3](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/motion@1.0.2...@capacitor/motion@1.0.3) (2021-10-13)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
31
+
32
+
33
+
34
+
35
+
36
+ ## [1.0.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/motion@1.0.1...@capacitor/motion@1.0.2) (2021-06-23)
37
+
38
+ **Note:** Version bump only for package @capacitor/motion
39
+
40
+
41
+
42
+
43
+
44
+ ## [1.0.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/motion@1.0.0...@capacitor/motion@1.0.1) (2021-06-09)
45
+
46
+ **Note:** Version bump only for package @capacitor/motion
47
+
48
+
49
+
50
+
51
+
6
52
  # [1.0.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/motion@0.3.8...@capacitor/motion@1.0.0) (2021-05-19)
7
53
 
8
54
  **Note:** Version bump only for package @capacitor/motion
package/README.md CHANGED
@@ -16,8 +16,12 @@ permission before using this API. To request permission, prompt the user for
16
16
  permission on any user-initiated action (such as a button click):
17
17
 
18
18
  ```typescript
19
+ import { PluginListenerHandle } from '@capacitor/core';
19
20
  import { Motion } from '@capacitor/motion';
20
21
 
22
+
23
+ let accelHandler: PluginListenerHandle;
24
+
21
25
  myButton.addEventListener('click', async () => {
22
26
  try {
23
27
  await DeviceMotionEvent.requestPermission();
@@ -27,10 +31,22 @@ myButton.addEventListener('click', async () => {
27
31
  }
28
32
 
29
33
  // Once the user approves, can start listening:
30
- Motion.addListener('accel', event => {
34
+ accelHandler = await Motion.addListener('accel', event => {
31
35
  console.log('Device motion event:', event);
32
36
  });
33
37
  });
38
+
39
+ // Stop the acceleration listener
40
+ const stopAcceleration = () => {
41
+ if (accelHandler) {
42
+ accelHandler.remove();
43
+ }
44
+ };
45
+
46
+ // Remove all listeners
47
+ const removeListeners = () => {
48
+ Motion.removeAllListeners();
49
+ };
34
50
  ```
35
51
 
36
52
  See the
@@ -41,8 +57,8 @@ API to understand the data supplied in the 'accel' event.
41
57
 
42
58
  <docgen-index>
43
59
 
44
- * [`addListener('accel', ...)`](#addlisteneraccel-)
45
- * [`addListener('orientation', ...)`](#addlistenerorientation-)
60
+ * [`addListener('accel', ...)`](#addlisteneraccel)
61
+ * [`addListener('orientation', ...)`](#addlistenerorientation)
46
62
  * [`removeAllListeners()`](#removealllisteners)
47
63
  * [Interfaces](#interfaces)
48
64
  * [Type Aliases](#type-aliases)
package/dist/docs.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "PluginListenerHandle",
33
33
  "AccelListener"
34
34
  ],
35
- "slug": "addlisteneraccel-"
35
+ "slug": "addlisteneraccel"
36
36
  },
37
37
  {
38
38
  "name": "addListener",
@@ -61,7 +61,7 @@
61
61
  "PluginListenerHandle",
62
62
  "OrientationListener"
63
63
  ],
64
- "slug": "addlistenerorientation-"
64
+ "slug": "addlistenerorientation"
65
65
  },
66
66
  {
67
67
  "name": "removeAllListeners",
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface MotionPlugin {\n /**\n * Add a listener for accelerometer data\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'accel',\n listenerFunc: AccelListener,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Add a listener for device orientation change (compass heading, etc.)\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'orientation',\n listenerFunc: OrientationListener,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Remove all the listeners that are attached to this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n\nexport type AccelListener = (event: AccelListenerEvent) => void;\nexport type OrientationListener = (event: OrientationListenerEvent) => void;\nexport type OrientationListenerEvent = RotationRate;\n\nexport interface RotationRate {\n /**\n * The amount of rotation around the Z axis, in degrees per second.\n *\n * @since 1.0.0\n */\n alpha: number;\n\n /**\n * The amount of rotation around the X axis, in degrees per second.\n *\n * @since 1.0.0\n */\n beta: number;\n\n /**\n * The amount of rotation around the Y axis, in degrees per second.\n *\n * @since 1.0.0\n */\n gamma: number;\n}\n\nexport interface Acceleration {\n /**\n * The amount of acceleration along the X axis.\n *\n * @since 1.0.0\n */\n x: number;\n\n /**\n * The amount of acceleration along the Y axis.\n *\n * @since 1.0.0\n */\n y: number;\n\n /**\n * The amount of acceleration along the Z axis.\n *\n * @since 1.0.0\n */\n z: number;\n}\n\nexport interface AccelListenerEvent {\n /**\n * An object giving the acceleration of the device on the three axis X, Y and Z. Acceleration is expressed in m/s\n *\n * @since 1.0.0\n */\n acceleration: Acceleration;\n\n /**\n * An object giving the acceleration of the device on the three axis X, Y and Z with the effect of gravity. Acceleration is expressed in m/s\n *\n * @since 1.0.0\n */\n accelerationIncludingGravity: Acceleration;\n\n /**\n * An object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma. Rotation rate is expressed in degrees per seconds.\n *\n * @since 1.0.0\n */\n rotationRate: RotationRate;\n\n /**\n * A number representing the interval of time, in milliseconds, at which data is obtained from the device.\n *\n * @since 1.0.0\n */\n interval: number;\n}\n\n/**\n * @deprecated Use `AccelListener`.\n * @since 1.0.0\n */\nexport type MotionWatchAccelCallback = AccelListener;\n\n/**\n * @deprecated Use `AccelListenerEvent`.\n * @since 1.0.0\n */\nexport type MotionEventResult = AccelListenerEvent;\n\n/**\n * @deprecated Use `OrientationListener`.\n * @since 1.0.0\n */\nexport type MotionWatchOrientationCallback = OrientationListener;\n\n/**\n * @deprecated Use `OrientationListenerEvent`.\n * @since 1.0.0\n */\nexport type MotionOrientationEventResult = OrientationListenerEvent;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,MAAM,GAAG,cAAc,CAAe,QAAQ,EAAE;IACpD,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IACvD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;CACxD,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,MAAM,GAAG,cAAc,CAAe,QAAQ,EAAE;IACpD,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IACvD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;CACxD,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { MotionPlugin } from './definitions';\n\nconst Motion = registerPlugin<MotionPlugin>('Motion', {\n android: () => import('./web').then(m => new m.MotionWeb()),\n ios: () => import('./web').then(m => new m.MotionWeb()),\n web: () => import('./web').then(m => new m.MotionWeb()),\n});\n\nexport * from './definitions';\nexport { Motion };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrD,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;IAClE,CAAC;CACF"}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACrD,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;IAClE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { MotionPlugin } from './definitions';\n\nexport class MotionWeb extends WebPlugin implements MotionPlugin {\n constructor() {\n super();\n this.registerWindowListener('devicemotion', 'accel');\n this.registerWindowListener('deviceorientation', 'orientation');\n }\n}\n"]}
package/dist/plugin.js CHANGED
@@ -26,5 +26,5 @@ var capacitorMotion = (function (exports, core) {
26
26
 
27
27
  return exports;
28
28
 
29
- }({}, capacitorExports));
29
+ })({}, capacitorExports);
30
30
  //# sourceMappingURL=plugin.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/motion",
3
- "version": "1.0.0",
3
+ "version": "1.0.5",
4
4
  "description": "The Motion API tracks accelerometer and device orientation (compass heading, etc.)",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -39,10 +39,10 @@
39
39
  "prepublishOnly": "npm run build"
40
40
  },
41
41
  "devDependencies": {
42
- "@capacitor/android": "3.0.0",
43
- "@capacitor/core": "3.0.0",
44
- "@capacitor/docgen": "0.0.16",
45
- "@capacitor/ios": "3.0.0",
42
+ "@capacitor/android": "^3.0.0",
43
+ "@capacitor/core": "^3.0.0",
44
+ "@capacitor/docgen": "0.0.18",
45
+ "@capacitor/ios": "^3.0.0",
46
46
  "@ionic/eslint-config": "^0.3.0",
47
47
  "@ionic/prettier-config": "~1.0.1",
48
48
  "eslint": "^7.11.0",
@@ -53,7 +53,7 @@
53
53
  "typescript": "~4.1.5"
54
54
  },
55
55
  "peerDependencies": {
56
- "@capacitor/core": "3.0.0"
56
+ "@capacitor/core": "^3.0.0"
57
57
  },
58
58
  "prettier": "@ionic/prettier-config",
59
59
  "eslintConfig": {
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "d264b9e6547d97e86258e067bd37254311d9f1a5"
66
+ "gitHead": "f18ee6482e1ec8e5fb0290d51f598397133af990"
67
67
  }