@capgo/capacitor-shake 7.1.29 → 7.2.4
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/README.md +32 -4
- package/android/src/main/java/ee/forgr/capacitor/shake/CapacitorShakePlugin.java +15 -0
- package/dist/docs.json +59 -6
- package/dist/esm/definitions.d.ts +45 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorShakePlugin/CapacitorShakePlugin.swift +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ npx cap sync
|
|
|
23
23
|
<docgen-index>
|
|
24
24
|
|
|
25
25
|
* [`addListener('shake', ...)`](#addlistenershake-)
|
|
26
|
+
* [`getPluginVersion()`](#getpluginversion)
|
|
26
27
|
* [Interfaces](#interfaces)
|
|
27
28
|
|
|
28
29
|
</docgen-index>
|
|
@@ -30,19 +31,46 @@ npx cap sync
|
|
|
30
31
|
<docgen-api>
|
|
31
32
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
32
33
|
|
|
34
|
+
Capacitor Shake Plugin interface for detecting shake gestures on mobile devices.
|
|
35
|
+
This plugin allows you to listen for shake events and get plugin version information.
|
|
36
|
+
|
|
33
37
|
### addListener('shake', ...)
|
|
34
38
|
|
|
35
39
|
```typescript
|
|
36
40
|
addListener(eventName: 'shake', listenerFunc: () => void) => Promise<PluginListenerHandle>
|
|
37
41
|
```
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
Listen for shake event on the device.
|
|
44
|
+
|
|
45
|
+
Registers a listener that will be called whenever a shake gesture is detected.
|
|
46
|
+
The shake detection uses the device's accelerometer to identify shake patterns.
|
|
47
|
+
|
|
48
|
+
| Param | Type | Description |
|
|
49
|
+
| ------------------ | -------------------------- | --------------------------------------------------- |
|
|
50
|
+
| **`eventName`** | <code>'shake'</code> | The shake change event name. Must be 'shake'. |
|
|
51
|
+
| **`listenerFunc`** | <code>() => void</code> | Callback function invoked when the phone is shaken. |
|
|
43
52
|
|
|
44
53
|
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
45
54
|
|
|
55
|
+
**Since:** 1.0.0
|
|
56
|
+
|
|
57
|
+
--------------------
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### getPluginVersion()
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
getPluginVersion() => Promise<{ version: string; }>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Get the native Capacitor plugin version.
|
|
67
|
+
|
|
68
|
+
Returns the current version of the native plugin implementation.
|
|
69
|
+
|
|
70
|
+
**Returns:** <code>Promise<{ version: string; }></code>
|
|
71
|
+
|
|
72
|
+
**Since:** 1.0.0
|
|
73
|
+
|
|
46
74
|
--------------------
|
|
47
75
|
|
|
48
76
|
|
|
@@ -5,12 +5,16 @@ import android.hardware.SensorManager;
|
|
|
5
5
|
import android.util.Log;
|
|
6
6
|
import com.getcapacitor.JSObject;
|
|
7
7
|
import com.getcapacitor.Plugin;
|
|
8
|
+
import com.getcapacitor.PluginCall;
|
|
9
|
+
import com.getcapacitor.PluginMethod;
|
|
8
10
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
11
|
import com.squareup.seismic.ShakeDetector;
|
|
10
12
|
|
|
11
13
|
@CapacitorPlugin(name = "CapacitorShake")
|
|
12
14
|
public class CapacitorShakePlugin extends Plugin implements ShakeDetector.Listener {
|
|
13
15
|
|
|
16
|
+
private final String PLUGIN_VERSION = "7.2.4";
|
|
17
|
+
|
|
14
18
|
@Override
|
|
15
19
|
public void load() {
|
|
16
20
|
super.load();
|
|
@@ -42,4 +46,15 @@ public class CapacitorShakePlugin extends Plugin implements ShakeDetector.Listen
|
|
|
42
46
|
JSObject ret = new JSObject();
|
|
43
47
|
notifyListeners("shake", ret);
|
|
44
48
|
}
|
|
49
|
+
|
|
50
|
+
@PluginMethod
|
|
51
|
+
public void getPluginVersion(final PluginCall call) {
|
|
52
|
+
try {
|
|
53
|
+
final JSObject ret = new JSObject();
|
|
54
|
+
ret.put("version", this.PLUGIN_VERSION);
|
|
55
|
+
call.resolve(ret);
|
|
56
|
+
} catch (final Exception e) {
|
|
57
|
+
call.reject("Could not get plugin version", e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
45
60
|
}
|
package/dist/docs.json
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
"api": {
|
|
3
3
|
"name": "CapacitorShakePlugin",
|
|
4
4
|
"slug": "capacitorshakeplugin",
|
|
5
|
-
"docs": "",
|
|
6
|
-
"tags": [
|
|
5
|
+
"docs": "Capacitor Shake Plugin interface for detecting shake gestures on mobile devices.\nThis plugin allows you to listen for shake events and get plugin version information.",
|
|
6
|
+
"tags": [
|
|
7
|
+
{
|
|
8
|
+
"text": "1.0.0",
|
|
9
|
+
"name": "since"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
7
12
|
"methods": [
|
|
8
13
|
{
|
|
9
14
|
"name": "addListener",
|
|
@@ -11,22 +16,70 @@
|
|
|
11
16
|
"parameters": [
|
|
12
17
|
{
|
|
13
18
|
"name": "eventName",
|
|
14
|
-
"docs": "",
|
|
19
|
+
"docs": "The shake change event name. Must be 'shake'.",
|
|
15
20
|
"type": "'shake'"
|
|
16
21
|
},
|
|
17
22
|
{
|
|
18
23
|
"name": "listenerFunc",
|
|
19
|
-
"docs": "",
|
|
24
|
+
"docs": "Callback function invoked when the phone is shaken.",
|
|
20
25
|
"type": "() => void"
|
|
21
26
|
}
|
|
22
27
|
],
|
|
23
28
|
"returns": "Promise<PluginListenerHandle>",
|
|
24
|
-
"tags": [
|
|
25
|
-
|
|
29
|
+
"tags": [
|
|
30
|
+
{
|
|
31
|
+
"name": "since",
|
|
32
|
+
"text": "1.0.0"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "param",
|
|
36
|
+
"text": "eventName The shake change event name. Must be 'shake'."
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "param",
|
|
40
|
+
"text": "listenerFunc Callback function invoked when the phone is shaken."
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "returns",
|
|
44
|
+
"text": "A promise that resolves to a listener handle that can be used to remove the listener."
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "example",
|
|
48
|
+
"text": "```typescript\nconst listener = await CapacitorShake.addListener('shake', () => {\n console.log('Shake detected!');\n});\n\n// To remove the listener:\nawait listener.remove();\n```"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"docs": "Listen for shake event on the device.\n\nRegisters a listener that will be called whenever a shake gesture is detected.\nThe shake detection uses the device's accelerometer to identify shake patterns.",
|
|
26
52
|
"complexTypes": [
|
|
27
53
|
"PluginListenerHandle"
|
|
28
54
|
],
|
|
29
55
|
"slug": "addlistenershake-"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "getPluginVersion",
|
|
59
|
+
"signature": "() => Promise<{ version: string; }>",
|
|
60
|
+
"parameters": [],
|
|
61
|
+
"returns": "Promise<{ version: string; }>",
|
|
62
|
+
"tags": [
|
|
63
|
+
{
|
|
64
|
+
"name": "since",
|
|
65
|
+
"text": "1.0.0"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "returns",
|
|
69
|
+
"text": "A promise that resolves with an object containing the version string."
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "throws",
|
|
73
|
+
"text": "An error if something went wrong retrieving the version."
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "example",
|
|
77
|
+
"text": "```typescript\nconst { version } = await CapacitorShake.getPluginVersion();\nconsole.log('Plugin version:', version);\n```"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"docs": "Get the native Capacitor plugin version.\n\nReturns the current version of the native plugin implementation.",
|
|
81
|
+
"complexTypes": [],
|
|
82
|
+
"slug": "getpluginversion"
|
|
30
83
|
}
|
|
31
84
|
],
|
|
32
85
|
"properties": []
|
|
@@ -1,4 +1,49 @@
|
|
|
1
1
|
import type { PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* Capacitor Shake Plugin interface for detecting shake gestures on mobile devices.
|
|
4
|
+
* This plugin allows you to listen for shake events and get plugin version information.
|
|
5
|
+
*
|
|
6
|
+
* @since 1.0.0
|
|
7
|
+
*/
|
|
2
8
|
export interface CapacitorShakePlugin {
|
|
9
|
+
/**
|
|
10
|
+
* Listen for shake event on the device.
|
|
11
|
+
*
|
|
12
|
+
* Registers a listener that will be called whenever a shake gesture is detected.
|
|
13
|
+
* The shake detection uses the device's accelerometer to identify shake patterns.
|
|
14
|
+
*
|
|
15
|
+
* @since 1.0.0
|
|
16
|
+
* @param eventName The shake change event name. Must be 'shake'.
|
|
17
|
+
* @param listenerFunc Callback function invoked when the phone is shaken.
|
|
18
|
+
* @returns {Promise<PluginListenerHandle>} A promise that resolves to a listener handle that can be used to remove the listener.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const listener = await CapacitorShake.addListener('shake', () => {
|
|
23
|
+
* console.log('Shake detected!');
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // To remove the listener:
|
|
27
|
+
* await listener.remove();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
3
30
|
addListener(eventName: 'shake', listenerFunc: () => void): Promise<PluginListenerHandle>;
|
|
31
|
+
/**
|
|
32
|
+
* Get the native Capacitor plugin version.
|
|
33
|
+
*
|
|
34
|
+
* Returns the current version of the native plugin implementation.
|
|
35
|
+
*
|
|
36
|
+
* @since 1.0.0
|
|
37
|
+
* @returns {Promise<{ version: string }>} A promise that resolves with an object containing the version string.
|
|
38
|
+
* @throws An error if something went wrong retrieving the version.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const { version } = await CapacitorShake.getPluginVersion();
|
|
43
|
+
* console.log('Plugin version:', version);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
getPluginVersion(): Promise<{
|
|
47
|
+
version: string;
|
|
48
|
+
}>;
|
|
4
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface CapacitorShakePlugin {\n addListener(eventName: 'shake', listenerFunc: () => void): Promise<PluginListenerHandle>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Capacitor Shake Plugin interface for detecting shake gestures on mobile devices.\n * This plugin allows you to listen for shake events and get plugin version information.\n *\n * @since 1.0.0\n */\nexport interface CapacitorShakePlugin {\n /**\n * Listen for shake event on the device.\n *\n * Registers a listener that will be called whenever a shake gesture is detected.\n * The shake detection uses the device's accelerometer to identify shake patterns.\n *\n * @since 1.0.0\n * @param eventName The shake change event name. Must be 'shake'.\n * @param listenerFunc Callback function invoked when the phone is shaken.\n * @returns {Promise<PluginListenerHandle>} A promise that resolves to a listener handle that can be used to remove the listener.\n *\n * @example\n * ```typescript\n * const listener = await CapacitorShake.addListener('shake', () => {\n * console.log('Shake detected!');\n * });\n *\n * // To remove the listener:\n * await listener.remove();\n * ```\n */\n addListener(eventName: 'shake', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * Returns the current version of the native plugin implementation.\n *\n * @since 1.0.0\n * @returns {Promise<{ version: string }>} A promise that resolves with an object containing the version string.\n * @throws An error if something went wrong retrieving the version.\n *\n * @example\n * ```typescript\n * const { version } = await CapacitorShake.getPluginVersion();\n * console.log('Plugin version:', version);\n * ```\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -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,iBAAkB,SAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorShakePlugin } from './definitions';\n\nexport class CapacitorShakeWeb extends WebPlugin implements CapacitorShakePlugin {\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorShake = registerPlugin('CapacitorShake', {\n web: () => import('./web').then((m) => new m.CapacitorShakeWeb()),\n});\nexport * from './definitions';\nexport { CapacitorShake };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorShakeWeb extends WebPlugin {\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACrE,CAAC;;ACFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorShake = registerPlugin('CapacitorShake', {\n web: () => import('./web').then((m) => new m.CapacitorShakeWeb()),\n});\nexport * from './definitions';\nexport { CapacitorShake };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorShakeWeb extends WebPlugin {\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACrE,CAAC;;ACFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorShake = registerPlugin('CapacitorShake', {\n web: () => import('./web').then((m) => new m.CapacitorShakeWeb()),\n});\nexport * from './definitions';\nexport { CapacitorShake };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorShakeWeb extends WebPlugin {\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrE,CAAC;;ICFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorShake = registerPlugin('CapacitorShake', {\n web: () => import('./web').then((m) => new m.CapacitorShakeWeb()),\n});\nexport * from './definitions';\nexport { CapacitorShake };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorShakeWeb extends WebPlugin {\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrE,CAAC;;ICFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -20,9 +20,11 @@ extension UIWindow {
|
|
|
20
20
|
*/
|
|
21
21
|
@objc(CapacitorShakePlugin)
|
|
22
22
|
public class CapacitorShakePlugin: CAPPlugin, CAPBridgedPlugin {
|
|
23
|
+
private let PLUGIN_VERSION: String = "7.2.4"
|
|
23
24
|
public let identifier = "CapacitorShakePlugin"
|
|
24
25
|
public let jsName = "CapacitorShake"
|
|
25
26
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
27
|
+
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
|
|
26
28
|
]
|
|
27
29
|
|
|
28
30
|
override public func load() {
|
|
@@ -41,4 +43,9 @@ public class CapacitorShakePlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
41
43
|
print("Shake detected")
|
|
42
44
|
notifyListeners("shake", data: [:])
|
|
43
45
|
}
|
|
46
|
+
|
|
47
|
+
@objc func getPluginVersion(_ call: CAPPluginCall) {
|
|
48
|
+
call.resolve(["version": self.PLUGIN_VERSION])
|
|
49
|
+
}
|
|
50
|
+
|
|
44
51
|
}
|