@capacitor/haptics 4.0.0-beta.0 → 4.0.0-beta.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 CHANGED
@@ -3,6 +3,14 @@
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
+ # [4.0.0-beta.2](https://github.com/ionic-team/capacitor-plugins/compare/4.0.0-beta.0...4.0.0-beta.2) (2022-07-08)
7
+
8
+ **Note:** Version bump only for package @capacitor/haptics
9
+
10
+
11
+
12
+
13
+
6
14
  # 4.0.0-beta.0 (2022-06-27)
7
15
 
8
16
 
package/README.md CHANGED
@@ -171,9 +171,9 @@ For example, call this when a user has lifted their finger from a control
171
171
 
172
172
  #### VibrateOptions
173
173
 
174
- | Prop | Type | Description | Default | Since |
175
- | -------------- | ------------------- | ----------------------------------------------------------------------------- | ---------------- | ----- |
176
- | **`duration`** | <code>number</code> | Duration of the vibration in milliseconds. Not supported in iOS 12 and older. | <code>300</code> | 1.0.0 |
174
+ | Prop | Type | Description | Default | Since |
175
+ | -------------- | ------------------- | ------------------------------------------ | ---------------- | ----- |
176
+ | **`duration`** | <code>number</code> | Duration of the vibration in milliseconds. | <code>300</code> | 1.0.0 |
177
177
 
178
178
 
179
179
  ### 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 12 and older.",
199
+ "docs": "Duration of the vibration in milliseconds.",
200
200
  "complexTypes": [],
201
201
  "type": "number"
202
202
  }
@@ -105,8 +105,6 @@ export interface VibrateOptions {
105
105
  /**
106
106
  * Duration of the vibration in milliseconds.
107
107
  *
108
- * Not supported in iOS 12 and older.
109
- *
110
108
  * @default 300
111
109
  * @since 1.0.0
112
110
  */
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA2DA,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;;;OAIG;IACH,8BAAe,CAAA;IAEf;;;;OAIG;IACH,gCAAiB,CAAA;IAEjB;;;;OAIG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB;AAcD,MAAM,CAAN,IAAY,gBAqBX;AArBD,WAAY,gBAAgB;IAC1B;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,mCAAe,CAAA;AACjB,CAAC,EArBW,gBAAgB,KAAhB,gBAAgB,QAqB3B;AA0BD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC","sourcesContent":["export interface HapticsPlugin {\n /**\n * Trigger a haptics \"impact\" feedback\n *\n * @since 1.0.0\n */\n impact(options?: ImpactOptions): Promise<void>;\n\n /**\n * Trigger a haptics \"notification\" feedback\n *\n * @since 1.0.0\n */\n notification(options?: NotificationOptions): Promise<void>;\n\n /**\n * Vibrate the device\n *\n * @since 1.0.0\n */\n vibrate(options?: VibrateOptions): Promise<void>;\n\n /**\n * Trigger a selection started haptic hint\n *\n * @since 1.0.0\n */\n selectionStart(): Promise<void>;\n\n /**\n * Trigger a selection changed haptic hint. If a selection was\n * started already, this will cause the device to provide haptic\n * feedback\n *\n * @since 1.0.0\n */\n selectionChanged(): Promise<void>;\n\n /**\n * If selectionStart() was called, selectionEnd() ends the selection.\n * For example, call this when a user has lifted their finger from a control\n *\n * @since 1.0.0\n */\n selectionEnd(): Promise<void>;\n}\n\nexport interface ImpactOptions {\n /**\n * Impact Feedback Style\n *\n * The mass of the objects in the collision simulated by a [UIImpactFeedbackGenerator](https://developer.apple.com/documentation/uikit/uiimpactfeedbackstyle) object.\n *\n * @default ImpactStyle.Heavy\n * @since 1.0.0\n */\n style: ImpactStyle;\n}\n\nexport enum ImpactStyle {\n /**\n * A collision between large, heavy user interface elements\n *\n * @since 1.0.0\n */\n Heavy = 'HEAVY',\n\n /**\n * A collision between moderately sized user interface elements\n *\n * @since 1.0.0\n */\n Medium = 'MEDIUM',\n\n /**\n * A collision between small, light user interface elements\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n}\n\nexport interface NotificationOptions {\n /**\n * Notification Feedback Type\n *\n * The type of notification feedback generated by a [UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbacktype) object.\n *\n * @default NotificationType.SUCCESS\n * @since 1.0.0\n */\n type: NotificationType;\n}\n\nexport enum NotificationType {\n /**\n * A notification feedback type indicating that a task has completed successfully\n *\n * @since 1.0.0\n */\n Success = 'SUCCESS',\n\n /**\n * A notification feedback type indicating that a task has produced a warning\n *\n * @since 1.0.0\n */\n Warning = 'WARNING',\n\n /**\n * A notification feedback type indicating that a task has failed\n *\n * @since 1.0.0\n */\n Error = 'ERROR',\n}\n\nexport interface VibrateOptions {\n /**\n * Duration of the vibration in milliseconds.\n *\n * Not supported in iOS 12 and older.\n *\n * @default 300\n * @since 1.0.0\n */\n duration: number;\n}\n\n/**\n * @deprecated Use `ImpactOptions`.\n * @since 1.0.0\n */\nexport type HapticsImpactOptions = ImpactOptions;\n\n/**\n * @deprecated Use `NotificationOptions`.\n * @since 1.0.0\n */\nexport type HapticsNotificationOptions = NotificationOptions;\n\n/**\n * @deprecated Use `NotificationType`.\n * @since 1.0.0\n */\nexport const HapticsNotificationType = NotificationType;\n\n/**\n * @deprecated Use `ImpactStyle`.\n * @since 1.0.0\n */\nexport const HapticsImpactStyle = ImpactStyle;\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA2DA,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;;;OAIG;IACH,8BAAe,CAAA;IAEf;;;;OAIG;IACH,gCAAiB,CAAA;IAEjB;;;;OAIG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB;AAcD,MAAM,CAAN,IAAY,gBAqBX;AArBD,WAAY,gBAAgB;IAC1B;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,mCAAe,CAAA;AACjB,CAAC,EArBW,gBAAgB,KAAhB,gBAAgB,QAqB3B;AAwBD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC","sourcesContent":["export interface HapticsPlugin {\n /**\n * Trigger a haptics \"impact\" feedback\n *\n * @since 1.0.0\n */\n impact(options?: ImpactOptions): Promise<void>;\n\n /**\n * Trigger a haptics \"notification\" feedback\n *\n * @since 1.0.0\n */\n notification(options?: NotificationOptions): Promise<void>;\n\n /**\n * Vibrate the device\n *\n * @since 1.0.0\n */\n vibrate(options?: VibrateOptions): Promise<void>;\n\n /**\n * Trigger a selection started haptic hint\n *\n * @since 1.0.0\n */\n selectionStart(): Promise<void>;\n\n /**\n * Trigger a selection changed haptic hint. If a selection was\n * started already, this will cause the device to provide haptic\n * feedback\n *\n * @since 1.0.0\n */\n selectionChanged(): Promise<void>;\n\n /**\n * If selectionStart() was called, selectionEnd() ends the selection.\n * For example, call this when a user has lifted their finger from a control\n *\n * @since 1.0.0\n */\n selectionEnd(): Promise<void>;\n}\n\nexport interface ImpactOptions {\n /**\n * Impact Feedback Style\n *\n * The mass of the objects in the collision simulated by a [UIImpactFeedbackGenerator](https://developer.apple.com/documentation/uikit/uiimpactfeedbackstyle) object.\n *\n * @default ImpactStyle.Heavy\n * @since 1.0.0\n */\n style: ImpactStyle;\n}\n\nexport enum ImpactStyle {\n /**\n * A collision between large, heavy user interface elements\n *\n * @since 1.0.0\n */\n Heavy = 'HEAVY',\n\n /**\n * A collision between moderately sized user interface elements\n *\n * @since 1.0.0\n */\n Medium = 'MEDIUM',\n\n /**\n * A collision between small, light user interface elements\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n}\n\nexport interface NotificationOptions {\n /**\n * Notification Feedback Type\n *\n * The type of notification feedback generated by a [UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbacktype) object.\n *\n * @default NotificationType.SUCCESS\n * @since 1.0.0\n */\n type: NotificationType;\n}\n\nexport enum NotificationType {\n /**\n * A notification feedback type indicating that a task has completed successfully\n *\n * @since 1.0.0\n */\n Success = 'SUCCESS',\n\n /**\n * A notification feedback type indicating that a task has produced a warning\n *\n * @since 1.0.0\n */\n Warning = 'WARNING',\n\n /**\n * A notification feedback type indicating that a task has failed\n *\n * @since 1.0.0\n */\n Error = 'ERROR',\n}\n\nexport interface VibrateOptions {\n /**\n * Duration of the vibration in milliseconds.\n *\n * @default 300\n * @since 1.0.0\n */\n duration: number;\n}\n\n/**\n * @deprecated Use `ImpactOptions`.\n * @since 1.0.0\n */\nexport type HapticsImpactOptions = ImpactOptions;\n\n/**\n * @deprecated Use `NotificationOptions`.\n * @since 1.0.0\n */\nexport type HapticsNotificationOptions = NotificationOptions;\n\n/**\n * @deprecated Use `NotificationType`.\n * @since 1.0.0\n */\nexport const HapticsNotificationType = NotificationType;\n\n/**\n * @deprecated Use `ImpactStyle`.\n * @since 1.0.0\n */\nexport const HapticsImpactStyle = ImpactStyle;\n"]}
@@ -37,33 +37,29 @@ import CoreHaptics
37
37
  }
38
38
 
39
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
- }
40
+ if CHHapticEngine.capabilitiesForHardware().supportsHaptics {
41
+ do {
42
+ let engine = try CHHapticEngine()
43
+ try engine.start()
44
+ engine.resetHandler = { [] in
45
+ do {
46
+ try engine.start()
47
+ } catch {
48
+ self.vibrate()
51
49
  }
52
- let intensity = CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0)
53
- let sharpness = CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0)
50
+ }
51
+ let intensity = CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0)
52
+ let sharpness = CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0)
54
53
 
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)
54
+ let continuousEvent = CHHapticEvent(eventType: .hapticContinuous,
55
+ parameters: [intensity, sharpness],
56
+ relativeTime: 0.0,
57
+ duration: duration)
58
+ let pattern = try CHHapticPattern(events: [continuousEvent], parameters: [])
59
+ let player = try engine.makePlayer(with: pattern)
61
60
 
62
- try player.start(atTime: 0)
63
- } catch {
64
- vibrate()
65
- }
66
- } else {
61
+ try player.start(atTime: 0)
62
+ } catch {
67
63
  vibrate()
68
64
  }
69
65
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/haptics",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.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",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "fd7db8285f72990522da0adc889514c9804b6dae"
82
+ "gitHead": "32240b675c12a774920c07a86b4483ecec7a9c8d"
83
83
  }