@capgo/capacitor-shake 0.0.1

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.
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapgoCapacitorShake'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @capgo/capacitor-shake
2
+
3
+ Detect shake gesture in device
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @capgo/capacitor-shake
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`addListener('shake', ...)`](#addlistenershake)
17
+ * [Interfaces](#interfaces)
18
+
19
+ </docgen-index>
20
+
21
+ <docgen-api>
22
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
23
+
24
+ ### addListener('shake', ...)
25
+
26
+ ```typescript
27
+ addListener(eventName: 'shake', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
28
+ ```
29
+
30
+ | Param | Type |
31
+ | ------------------ | -------------------------- |
32
+ | **`eventName`** | <code>'shake'</code> |
33
+ | **`listenerFunc`** | <code>() =&gt; void</code> |
34
+
35
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt; & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
36
+
37
+ --------------------
38
+
39
+
40
+ ### Interfaces
41
+
42
+
43
+ #### PluginListenerHandle
44
+
45
+ | Prop | Type |
46
+ | ------------ | ----------------------------------------- |
47
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
48
+
49
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:7.2.1'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
22
+ defaultConfig {
23
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
24
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
25
+ versionCode 1
26
+ versionName "1.0"
27
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28
+ }
29
+ buildTypes {
30
+ release {
31
+ minifyEnabled false
32
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
+ }
34
+ }
35
+ lintOptions {
36
+ abortOnError false
37
+ }
38
+ compileOptions {
39
+ sourceCompatibility JavaVersion.VERSION_11
40
+ targetCompatibility JavaVersion.VERSION_11
41
+ }
42
+ }
43
+
44
+ repositories {
45
+ google()
46
+ mavenCentral()
47
+ }
48
+
49
+
50
+ dependencies {
51
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
52
+ implementation project(':capacitor-android')
53
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
54
+ implementation 'com.squareup:seismic:1.0.3'
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="ee.forgr.capacitor.shake">
3
+ </manifest>
@@ -0,0 +1,17 @@
1
+ package ee.forgr.capacitor.shake;
2
+
3
+ import com.getcapacitor.JSObject;
4
+ import com.getcapacitor.Plugin;
5
+ import com.getcapacitor.PluginCall;
6
+ import com.getcapacitor.PluginMethod;
7
+ import com.getcapacitor.annotation.CapacitorPlugin;
8
+ import com.squareup.seismic.ShakeDetector;
9
+
10
+ @CapacitorPlugin(name = "CapacitorShake")
11
+ public class CapacitorShakePlugin extends Plugin implements ShakeDetector.Listener {
12
+
13
+ @Override public void hearShake() {
14
+ JSObject ret = new JSObject();
15
+ notifyListeners("shake", ret);
16
+ }
17
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "api": {
3
+ "name": "CapacitorShakePlugin",
4
+ "slug": "capacitorshakeplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "addListener",
10
+ "signature": "(eventName: 'shake', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle",
11
+ "parameters": [
12
+ {
13
+ "name": "eventName",
14
+ "docs": "",
15
+ "type": "'shake'"
16
+ },
17
+ {
18
+ "name": "listenerFunc",
19
+ "docs": "",
20
+ "type": "() => void"
21
+ }
22
+ ],
23
+ "returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
24
+ "tags": [],
25
+ "docs": "",
26
+ "complexTypes": [
27
+ "PluginListenerHandle"
28
+ ],
29
+ "slug": "addlistenershake"
30
+ }
31
+ ],
32
+ "properties": []
33
+ },
34
+ "interfaces": [
35
+ {
36
+ "name": "PluginListenerHandle",
37
+ "slug": "pluginlistenerhandle",
38
+ "docs": "",
39
+ "tags": [],
40
+ "methods": [],
41
+ "properties": [
42
+ {
43
+ "name": "remove",
44
+ "tags": [],
45
+ "docs": "",
46
+ "complexTypes": [],
47
+ "type": "() => Promise<void>"
48
+ }
49
+ ]
50
+ }
51
+ ],
52
+ "enums": [],
53
+ "typeAliases": [],
54
+ "pluginConfigs": []
55
+ }
@@ -0,0 +1,4 @@
1
+ import type { PluginListenerHandle } from "@capacitor/core";
2
+ export interface CapacitorShakePlugin {
3
+ addListener(eventName: 'shake', listenerFunc: () => void): Promise<PluginListenerHandle> & PluginListenerHandle;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +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(\n eventName: 'shake',\n listenerFunc: () => void\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { CapacitorShakePlugin } from './definitions';
2
+ declare const CapacitorShake: CapacitorShakePlugin;
3
+ export * from './definitions';
4
+ export { CapacitorShake };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const CapacitorShake = registerPlugin('CapacitorShake', {
3
+ web: () => import('./web').then(m => new m.CapacitorShakeWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { CapacitorShake };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,cAAc,GAAG,cAAc,CAAuB,gBAAgB,EAAE;IAC5E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;CAChE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapacitorShakePlugin } from './definitions';\n\nconst CapacitorShake = registerPlugin<CapacitorShakePlugin>('CapacitorShake', {\n web: () => import('./web').then(m => new m.CapacitorShakeWeb()),\n});\n\nexport * from './definitions';\nexport { CapacitorShake };\n"]}
@@ -0,0 +1,4 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { CapacitorShakePlugin } from './definitions';
3
+ export declare class CapacitorShakeWeb extends WebPlugin implements CapacitorShakePlugin {
4
+ }
@@ -0,0 +1,4 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class CapacitorShakeWeb extends WebPlugin {
3
+ }
4
+ //# sourceMappingURL=web.js.map
@@ -0,0 +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,iBACX,SAAQ,SAAS;CAIlB","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorShakePlugin } from './definitions';\n\nexport class CapacitorShakeWeb\n extends WebPlugin\n implements CapacitorShakePlugin\n{\n \n}\n"]}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const CapacitorShake = core.registerPlugin('CapacitorShake', {
8
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorShakeWeb()),
9
+ });
10
+
11
+ class CapacitorShakeWeb extends core.WebPlugin {
12
+ }
13
+
14
+ var web = /*#__PURE__*/Object.freeze({
15
+ __proto__: null,
16
+ CapacitorShakeWeb: CapacitorShakeWeb
17
+ });
18
+
19
+ exports.CapacitorShake = CapacitorShake;
20
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +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,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,23 @@
1
+ var capacitorCapacitorShake = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const CapacitorShake = core.registerPlugin('CapacitorShake', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorShakeWeb()),
6
+ });
7
+
8
+ class CapacitorShakeWeb extends core.WebPlugin {
9
+ }
10
+
11
+ var web = /*#__PURE__*/Object.freeze({
12
+ __proto__: null,
13
+ CapacitorShakeWeb: CapacitorShakeWeb
14
+ });
15
+
16
+ exports.CapacitorShake = CapacitorShake;
17
+
18
+ Object.defineProperty(exports, '__esModule', { value: true });
19
+
20
+ return exports;
21
+
22
+ })({}, capacitorExports);
23
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +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,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(CapacitorShakePlugin, "CapacitorShake",
7
+ CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
+ )
@@ -0,0 +1,41 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ extension UIDevice {
5
+ static let deviceDidShakeNotification = Notification.Name(rawValue: "deviceDidShakeNotification")
6
+ }
7
+
8
+ // Override the default behavior of shake gestures to send our notification instead.
9
+ extension UIWindow {
10
+ open override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
11
+ if motion == .motionShake {
12
+ NotificationCenter.default.post(name: UIDevice.deviceDidShakeNotification, object: nil)
13
+ }
14
+ }
15
+ }
16
+
17
+
18
+ /**
19
+ * Please read the Capacitor iOS Plugin Development Guide
20
+ * here: https://capacitorjs.com/docs/plugins/ios
21
+ */
22
+ @objc(CapacitorShakePlugin)
23
+ public class CapacitorShakePlugin: CAPPlugin {
24
+
25
+ override public func load() {
26
+ NotificationCenter.default.addObserver(
27
+ self,
28
+ selector: #selector(self.shaked),
29
+ name: UIDevice.deviceDidShakeNotification,
30
+ object: nil)
31
+ }
32
+
33
+ deinit {
34
+ NotificationCenter.default.removeObserver(self)
35
+ }
36
+
37
+ @objc private func shaked() {
38
+ print("Shake detected")
39
+ notifyListeners("shake", data: [:])
40
+ }
41
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@capgo/capacitor-shake",
3
+ "version": "0.0.1",
4
+ "description": "Detect shake gesture in device",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Plugin/",
14
+ "CapgoCapacitorShake.podspec"
15
+ ],
16
+ "author": "Martin Donadieu <martindonadieu@gmail.com>",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/Cap-go/capacitor-shake.git.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/Cap-go/capacitor-shake.git/issues"
24
+ },
25
+ "keywords": [
26
+ "capacitor",
27
+ "plugin",
28
+ "shake",
29
+ "gesture",
30
+ "accelerometer",
31
+ "acceleration",
32
+ "detection",
33
+ "native"
34
+ ],
35
+ "scripts": {
36
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
37
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
38
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
39
+ "verify:web": "npm run build",
40
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
41
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
42
+ "eslint": "eslint . --ext ts",
43
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
44
+ "swiftlint": "node-swiftlint",
45
+ "docgen": "docgen --api CapacitorShakePlugin --output-readme README.md --output-json dist/docs.json",
46
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
47
+ "clean": "rimraf ./dist",
48
+ "watch": "tsc --watch",
49
+ "prepublishOnly": "npm run build"
50
+ },
51
+ "devDependencies": {
52
+ "@capacitor/android": "^4.0.0",
53
+ "@capacitor/core": "^4.0.0",
54
+ "@capacitor/docgen": "^0.0.18",
55
+ "@capacitor/ios": "^4.0.0",
56
+ "@ionic/eslint-config": "^0.3.0",
57
+ "@ionic/prettier-config": "^1.0.1",
58
+ "@ionic/swiftlint-config": "^1.1.2",
59
+ "eslint": "^7.11.0",
60
+ "prettier": "~2.3.0",
61
+ "prettier-plugin-java": "~1.0.2",
62
+ "rimraf": "^3.0.2",
63
+ "rollup": "^2.32.0",
64
+ "swiftlint": "^1.0.1",
65
+ "typescript": "~4.1.5"
66
+ },
67
+ "peerDependencies": {
68
+ "@capacitor/core": "^4.0.0"
69
+ },
70
+ "prettier": "@ionic/prettier-config",
71
+ "swiftlint": "@ionic/swiftlint-config",
72
+ "eslintConfig": {
73
+ "extends": "@ionic/eslint-config/recommended"
74
+ },
75
+ "capacitor": {
76
+ "ios": {
77
+ "src": "ios"
78
+ },
79
+ "android": {
80
+ "src": "android"
81
+ }
82
+ }
83
+ }