@capacitor/haptics 1.0.1 → 1.1.2
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 +49 -0
- package/CapacitorHaptics.podspec +3 -3
- package/README.md +3 -3
- package/dist/docs.json +1 -1
- package/dist/esm/definitions.d.ts +1 -1
- package/dist/plugin.js +1 -1
- package/ios/Plugin/Haptics.swift +36 -0
- package/ios/Plugin/HapticsPlugin.swift +2 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,55 @@
|
|
|
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.1.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.1.1...@capacitor/haptics@1.1.2) (2021-10-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* remove postpublish scripts ([#656](https://github.com/ionic-team/capacitor-plugins/issues/656)) ([ed6ac49](https://github.com/ionic-team/capacitor-plugins/commit/ed6ac499ebf4a47525071ccbfc36c27503e11f60))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.1.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.1.0...@capacitor/haptics@1.1.1) (2021-10-13)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* correct addListeners links ([#655](https://github.com/ionic-team/capacitor-plugins/issues/655)) ([f9871e7](https://github.com/ionic-team/capacitor-plugins/commit/f9871e7bd53478addb21155e148829f550c0e457))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [1.1.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.0.3...@capacitor/haptics@1.1.0) (2021-09-27)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **haptics:** Implement duration for vibration ([#618](https://github.com/ionic-team/capacitor-plugins/issues/618)) ([78e6b68](https://github.com/ionic-team/capacitor-plugins/commit/78e6b6886fa50318b1bfbe229e7318e521e3c245))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [1.0.3](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.0.2...@capacitor/haptics@1.0.3) (2021-09-01)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @capacitor/haptics
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## [1.0.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.0.1...@capacitor/haptics@1.0.2) (2021-06-23)
|
|
48
|
+
|
|
49
|
+
**Note:** Version bump only for package @capacitor/haptics
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
6
55
|
## [1.0.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/haptics@1.0.0...@capacitor/haptics@1.0.1) (2021-06-09)
|
|
7
56
|
|
|
8
57
|
**Note:** Version bump only for package @capacitor/haptics
|
package/CapacitorHaptics.podspec
CHANGED
|
@@ -7,10 +7,10 @@ Pod::Spec.new do |s|
|
|
|
7
7
|
s.version = package['version']
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.license = package['license']
|
|
10
|
-
s.homepage =
|
|
10
|
+
s.homepage = 'https://capacitorjs.com'
|
|
11
11
|
s.author = package['author']
|
|
12
|
-
s.source = { :git => package['
|
|
13
|
-
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
12
|
+
s.source = { :git => 'https://github.com/ionic-team/capacitor-plugins.git', :tag => package['name'] + '@' + package['version'] }
|
|
13
|
+
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}', 'haptics/ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '12.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
package/README.md
CHANGED
|
@@ -169,9 +169,9 @@ For example, call this when a user has lifted their finger from a control
|
|
|
169
169
|
|
|
170
170
|
#### VibrateOptions
|
|
171
171
|
|
|
172
|
-
| Prop | Type | Description
|
|
173
|
-
| -------------- | ------------------- |
|
|
174
|
-
| **`duration`** | <code>number</code> | Duration of the vibration in milliseconds. Not supported in iOS. | <code>300</code> | 1.0.0 |
|
|
172
|
+
| Prop | Type | Description | Default | Since |
|
|
173
|
+
| -------------- | ------------------- | ----------------------------------------------------------------------------- | ---------------- | ----- |
|
|
174
|
+
| **`duration`** | <code>number</code> | Duration of the vibration in milliseconds. Not supported in iOS 12 and older. | <code>300</code> | 1.0.0 |
|
|
175
175
|
|
|
176
176
|
|
|
177
177
|
### Enums
|
package/dist/docs.json
CHANGED
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
"name": "since"
|
|
197
197
|
}
|
|
198
198
|
],
|
|
199
|
-
"docs": "Duration of the vibration in milliseconds.\n\nNot supported in iOS.",
|
|
199
|
+
"docs": "Duration of the vibration in milliseconds.\n\nNot supported in iOS 12 and older.",
|
|
200
200
|
"complexTypes": [],
|
|
201
201
|
"type": "number"
|
|
202
202
|
}
|
package/dist/plugin.js
CHANGED
package/ios/Plugin/Haptics.swift
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AudioToolbox
|
|
2
2
|
import UIKit
|
|
3
|
+
import CoreHaptics
|
|
3
4
|
|
|
4
5
|
@objc public class Haptics: NSObject {
|
|
5
6
|
|
|
@@ -34,4 +35,39 @@ import UIKit
|
|
|
34
35
|
@objc public func vibrate() {
|
|
35
36
|
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
|
|
36
37
|
}
|
|
38
|
+
|
|
39
|
+
@objc public func vibrate(_ duration: Double) {
|
|
40
|
+
if #available(iOS 13, *) {
|
|
41
|
+
if CHHapticEngine.capabilitiesForHardware().supportsHaptics {
|
|
42
|
+
do {
|
|
43
|
+
let engine = try CHHapticEngine()
|
|
44
|
+
try engine.start()
|
|
45
|
+
engine.resetHandler = { [] in
|
|
46
|
+
do {
|
|
47
|
+
try engine.start()
|
|
48
|
+
} catch {
|
|
49
|
+
self.vibrate()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let intensity = CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0)
|
|
53
|
+
let sharpness = CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0)
|
|
54
|
+
|
|
55
|
+
let continuousEvent = CHHapticEvent(eventType: .hapticContinuous,
|
|
56
|
+
parameters: [intensity, sharpness],
|
|
57
|
+
relativeTime: 0.0,
|
|
58
|
+
duration: duration)
|
|
59
|
+
let pattern = try CHHapticPattern(events: [continuousEvent], parameters: [])
|
|
60
|
+
let player = try engine.makePlayer(with: pattern)
|
|
61
|
+
|
|
62
|
+
try player.start(atTime: 0)
|
|
63
|
+
} catch {
|
|
64
|
+
vibrate()
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
vibrate()
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
vibrate()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
37
73
|
}
|
|
@@ -56,8 +56,9 @@ public class HapticsPlugin: CAPPlugin {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
@objc public func vibrate(_ call: CAPPluginCall) {
|
|
59
|
+
let duration = call.getDouble("duration", 300)/1000
|
|
59
60
|
DispatchQueue.main.async {
|
|
60
|
-
self.implementation.vibrate()
|
|
61
|
+
self.implementation.vibrate(duration)
|
|
61
62
|
}
|
|
62
63
|
call.resolve()
|
|
63
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/haptics",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "The Haptics API provides physical feedback to the user through touch or vibration.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -41,12 +41,13 @@
|
|
|
41
41
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
|
42
42
|
"clean": "rimraf ./dist",
|
|
43
43
|
"watch": "tsc --watch",
|
|
44
|
-
"prepublishOnly": "npm run build"
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"publish:cocoapod": "pod trunk push ./CapacitorHaptics.podspec --allow-warnings"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@capacitor/android": "^3.0.0",
|
|
48
49
|
"@capacitor/core": "^3.0.0",
|
|
49
|
-
"@capacitor/docgen": "0.0.
|
|
50
|
+
"@capacitor/docgen": "0.0.18",
|
|
50
51
|
"@capacitor/ios": "^3.0.0",
|
|
51
52
|
"@ionic/eslint-config": "^0.3.0",
|
|
52
53
|
"@ionic/prettier-config": "~1.0.1",
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"publishConfig": {
|
|
79
80
|
"access": "public"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "eadbffd4bf9f0859bd301a639ab4e0c3337ea8db"
|
|
82
83
|
}
|