@capawesome/capacitor-haptics 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.
Files changed (45) hide show
  1. package/CapawesomeCapacitorHaptics.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +28 -0
  4. package/README.md +457 -0
  5. package/android/build.gradle +58 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/Haptics.java +284 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/HapticsPlugin.java +239 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/classes/CustomException.java +20 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/classes/CustomExceptions.java +18 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/classes/options/ImpactOptions.java +24 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/classes/options/NotificationOptions.java +24 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/classes/options/PerformAndroidHapticOptions.java +29 -0
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/classes/options/PlayPatternOptions.java +89 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/classes/options/VibrateOptions.java +26 -0
  16. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/classes/results/IsAvailableResult.java +22 -0
  17. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/interfaces/Callback.java +5 -0
  18. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/interfaces/EmptyCallback.java +5 -0
  19. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/interfaces/NonEmptyResultCallback.java +7 -0
  20. package/android/src/main/java/io/capawesome/capacitorjs/plugins/haptics/interfaces/Result.java +7 -0
  21. package/android/src/main/res/.gitkeep +0 -0
  22. package/dist/docs.json +665 -0
  23. package/dist/esm/definitions.d.ts +363 -0
  24. package/dist/esm/definitions.js +150 -0
  25. package/dist/esm/definitions.js.map +1 -0
  26. package/dist/esm/index.d.ts +4 -0
  27. package/dist/esm/index.js +7 -0
  28. package/dist/esm/index.js.map +1 -0
  29. package/dist/esm/web.d.ts +21 -0
  30. package/dist/esm/web.js +100 -0
  31. package/dist/esm/web.js.map +1 -0
  32. package/dist/plugin.cjs.js +263 -0
  33. package/dist/plugin.cjs.js.map +1 -0
  34. package/dist/plugin.js +266 -0
  35. package/dist/plugin.js.map +1 -0
  36. package/ios/Plugin/Classes/Options/ImpactOptions.swift +29 -0
  37. package/ios/Plugin/Classes/Options/NotificationOptions.swift +25 -0
  38. package/ios/Plugin/Classes/Options/PlayPatternOptions.swift +54 -0
  39. package/ios/Plugin/Classes/Results/IsAvailableResult.swift +16 -0
  40. package/ios/Plugin/Enums/CustomError.swift +50 -0
  41. package/ios/Plugin/Haptics.swift +115 -0
  42. package/ios/Plugin/HapticsPlugin.swift +155 -0
  43. package/ios/Plugin/Info.plist +24 -0
  44. package/ios/Plugin/Protocols/Result.swift +5 -0
  45. package/package.json +96 -0
package/dist/docs.json ADDED
@@ -0,0 +1,665 @@
1
+ {
2
+ "api": {
3
+ "name": "HapticsPlugin",
4
+ "slug": "hapticsplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "impact",
10
+ "signature": "(options?: ImpactOptions | undefined) => Promise<void>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "ImpactOptions | undefined"
16
+ }
17
+ ],
18
+ "returns": "Promise<void>",
19
+ "tags": [
20
+ {
21
+ "name": "since",
22
+ "text": "0.1.0"
23
+ }
24
+ ],
25
+ "docs": "Trigger an impact haptic feedback.\n\nUse this to simulate a physical impact, for example when user\ninterface elements collide or a drag operation snaps into place.\n\nOn Android, the impact style is mapped to a best-effort vibration effect.",
26
+ "complexTypes": [
27
+ "ImpactOptions"
28
+ ],
29
+ "slug": "impact"
30
+ },
31
+ {
32
+ "name": "isAvailable",
33
+ "signature": "() => Promise<IsAvailableResult>",
34
+ "parameters": [],
35
+ "returns": "Promise<IsAvailableResult>",
36
+ "tags": [
37
+ {
38
+ "name": "since",
39
+ "text": "0.1.0"
40
+ }
41
+ ],
42
+ "docs": "Check if haptic feedback is available on the device.\n\nOn Android, this checks whether the device has a vibrator.\nOn iOS, this checks whether the device supports haptic event playback.\nOn the web, this checks whether the Vibration API is supported.",
43
+ "complexTypes": [
44
+ "IsAvailableResult"
45
+ ],
46
+ "slug": "isavailable"
47
+ },
48
+ {
49
+ "name": "notification",
50
+ "signature": "(options?: NotificationOptions | undefined) => Promise<void>",
51
+ "parameters": [
52
+ {
53
+ "name": "options",
54
+ "docs": "",
55
+ "type": "NotificationOptions | undefined"
56
+ }
57
+ ],
58
+ "returns": "Promise<void>",
59
+ "tags": [
60
+ {
61
+ "name": "since",
62
+ "text": "0.1.0"
63
+ }
64
+ ],
65
+ "docs": "Trigger a notification haptic feedback.\n\nUse this to communicate that a task or action has succeeded, failed,\nor produced a warning.\n\nOn Android, the notification type is mapped to a best-effort vibration\neffect.",
66
+ "complexTypes": [
67
+ "NotificationOptions"
68
+ ],
69
+ "slug": "notification"
70
+ },
71
+ {
72
+ "name": "performAndroidHaptic",
73
+ "signature": "(options: PerformAndroidHapticOptions) => Promise<void>",
74
+ "parameters": [
75
+ {
76
+ "name": "options",
77
+ "docs": "",
78
+ "type": "PerformAndroidHapticOptions"
79
+ }
80
+ ],
81
+ "returns": "Promise<void>",
82
+ "tags": [
83
+ {
84
+ "name": "since",
85
+ "text": "0.1.0"
86
+ }
87
+ ],
88
+ "docs": "Perform a predefined Android haptic feedback effect.\n\nIn contrast to the other methods, this method does not use the vibrator\nbut the semantic haptic feedback constants of the Android view system.\nThis respects the user's haptic feedback settings.\n\nOnly available on Android.",
89
+ "complexTypes": [
90
+ "PerformAndroidHapticOptions"
91
+ ],
92
+ "slug": "performandroidhaptic"
93
+ },
94
+ {
95
+ "name": "playPattern",
96
+ "signature": "(options: PlayPatternOptions) => Promise<void>",
97
+ "parameters": [
98
+ {
99
+ "name": "options",
100
+ "docs": "",
101
+ "type": "PlayPatternOptions"
102
+ }
103
+ ],
104
+ "returns": "Promise<void>",
105
+ "tags": [
106
+ {
107
+ "name": "since",
108
+ "text": "0.1.0"
109
+ }
110
+ ],
111
+ "docs": "Play a custom haptic pattern composed of individual haptic events.\n\nOn iOS, the pattern is played using Core Haptics with full support for\nintensity and sharpness. This requires a device with haptic event\nplayback support (for example an iPhone with a Taptic Engine).\nOtherwise, the call rejects as unavailable.\n\nOn Android, the pattern is played using vibration effects. Intensity is\nonly respected on devices with amplitude control.\n\nOn the web, the pattern is approximated using the Vibration API.",
112
+ "complexTypes": [
113
+ "PlayPatternOptions"
114
+ ],
115
+ "slug": "playpattern"
116
+ },
117
+ {
118
+ "name": "selectionChanged",
119
+ "signature": "() => Promise<void>",
120
+ "parameters": [],
121
+ "returns": "Promise<void>",
122
+ "tags": [
123
+ {
124
+ "name": "since",
125
+ "text": "0.1.0"
126
+ }
127
+ ],
128
+ "docs": "Trigger a selection changed haptic feedback.\n\nCall this method after `selectionStart()` whenever the selection changes.\n\nOn the web, this method does nothing.",
129
+ "complexTypes": [],
130
+ "slug": "selectionchanged"
131
+ },
132
+ {
133
+ "name": "selectionEnd",
134
+ "signature": "() => Promise<void>",
135
+ "parameters": [],
136
+ "returns": "Promise<void>",
137
+ "tags": [
138
+ {
139
+ "name": "since",
140
+ "text": "0.1.0"
141
+ }
142
+ ],
143
+ "docs": "End a selection session.\n\nCall this method when the user finishes a selection interaction.\n\nOn the web, this method does nothing.",
144
+ "complexTypes": [],
145
+ "slug": "selectionend"
146
+ },
147
+ {
148
+ "name": "selectionStart",
149
+ "signature": "() => Promise<void>",
150
+ "parameters": [],
151
+ "returns": "Promise<void>",
152
+ "tags": [
153
+ {
154
+ "name": "since",
155
+ "text": "0.1.0"
156
+ }
157
+ ],
158
+ "docs": "Start a selection session.\n\nCall this method when the user starts a selection interaction, for\nexample when a picker starts scrolling. It prepares the haptic hardware\nto reduce the latency of subsequent `selectionChanged()` calls.\n\nOn the web, this method does nothing.",
159
+ "complexTypes": [],
160
+ "slug": "selectionstart"
161
+ },
162
+ {
163
+ "name": "vibrate",
164
+ "signature": "(options?: VibrateOptions | undefined) => Promise<void>",
165
+ "parameters": [
166
+ {
167
+ "name": "options",
168
+ "docs": "",
169
+ "type": "VibrateOptions | undefined"
170
+ }
171
+ ],
172
+ "returns": "Promise<void>",
173
+ "tags": [
174
+ {
175
+ "name": "since",
176
+ "text": "0.1.0"
177
+ }
178
+ ],
179
+ "docs": "Vibrate the device.",
180
+ "complexTypes": [
181
+ "VibrateOptions"
182
+ ],
183
+ "slug": "vibrate"
184
+ }
185
+ ],
186
+ "properties": []
187
+ },
188
+ "interfaces": [
189
+ {
190
+ "name": "ImpactOptions",
191
+ "slug": "impactoptions",
192
+ "docs": "",
193
+ "tags": [
194
+ {
195
+ "text": "0.1.0",
196
+ "name": "since"
197
+ }
198
+ ],
199
+ "methods": [],
200
+ "properties": [
201
+ {
202
+ "name": "style",
203
+ "tags": [
204
+ {
205
+ "text": "0.1.0",
206
+ "name": "since"
207
+ },
208
+ {
209
+ "text": "ImpactStyle.Medium",
210
+ "name": "default"
211
+ }
212
+ ],
213
+ "docs": "The style of the impact.",
214
+ "complexTypes": [
215
+ "ImpactStyle"
216
+ ],
217
+ "type": "ImpactStyle"
218
+ }
219
+ ]
220
+ },
221
+ {
222
+ "name": "IsAvailableResult",
223
+ "slug": "isavailableresult",
224
+ "docs": "",
225
+ "tags": [
226
+ {
227
+ "text": "0.1.0",
228
+ "name": "since"
229
+ }
230
+ ],
231
+ "methods": [],
232
+ "properties": [
233
+ {
234
+ "name": "available",
235
+ "tags": [
236
+ {
237
+ "text": "0.1.0",
238
+ "name": "since"
239
+ },
240
+ {
241
+ "text": "true",
242
+ "name": "example"
243
+ }
244
+ ],
245
+ "docs": "Whether or not haptic feedback is available on the device.",
246
+ "complexTypes": [],
247
+ "type": "boolean"
248
+ }
249
+ ]
250
+ },
251
+ {
252
+ "name": "NotificationOptions",
253
+ "slug": "notificationoptions",
254
+ "docs": "",
255
+ "tags": [
256
+ {
257
+ "text": "0.1.0",
258
+ "name": "since"
259
+ }
260
+ ],
261
+ "methods": [],
262
+ "properties": [
263
+ {
264
+ "name": "type",
265
+ "tags": [
266
+ {
267
+ "text": "0.1.0",
268
+ "name": "since"
269
+ },
270
+ {
271
+ "text": "NotificationType.Success",
272
+ "name": "default"
273
+ }
274
+ ],
275
+ "docs": "The type of the notification.",
276
+ "complexTypes": [
277
+ "NotificationType"
278
+ ],
279
+ "type": "NotificationType"
280
+ }
281
+ ]
282
+ },
283
+ {
284
+ "name": "PerformAndroidHapticOptions",
285
+ "slug": "performandroidhapticoptions",
286
+ "docs": "",
287
+ "tags": [
288
+ {
289
+ "text": "0.1.0",
290
+ "name": "since"
291
+ }
292
+ ],
293
+ "methods": [],
294
+ "properties": [
295
+ {
296
+ "name": "type",
297
+ "tags": [
298
+ {
299
+ "text": "0.1.0",
300
+ "name": "since"
301
+ }
302
+ ],
303
+ "docs": "The Android haptic feedback effect to perform.",
304
+ "complexTypes": [
305
+ "AndroidHapticType"
306
+ ],
307
+ "type": "AndroidHapticType"
308
+ }
309
+ ]
310
+ },
311
+ {
312
+ "name": "PlayPatternOptions",
313
+ "slug": "playpatternoptions",
314
+ "docs": "",
315
+ "tags": [
316
+ {
317
+ "text": "0.1.0",
318
+ "name": "since"
319
+ }
320
+ ],
321
+ "methods": [],
322
+ "properties": [
323
+ {
324
+ "name": "events",
325
+ "tags": [
326
+ {
327
+ "text": "0.1.0",
328
+ "name": "since"
329
+ }
330
+ ],
331
+ "docs": "The haptic events that make up the pattern.",
332
+ "complexTypes": [
333
+ "HapticEvent"
334
+ ],
335
+ "type": "HapticEvent[]"
336
+ }
337
+ ]
338
+ },
339
+ {
340
+ "name": "HapticEvent",
341
+ "slug": "hapticevent",
342
+ "docs": "",
343
+ "tags": [
344
+ {
345
+ "text": "0.1.0",
346
+ "name": "since"
347
+ }
348
+ ],
349
+ "methods": [],
350
+ "properties": [
351
+ {
352
+ "name": "duration",
353
+ "tags": [
354
+ {
355
+ "text": "0.1.0",
356
+ "name": "since"
357
+ },
358
+ {
359
+ "text": "0.5",
360
+ "name": "example"
361
+ }
362
+ ],
363
+ "docs": "The duration of the event in seconds.\n\nIf omitted, the event is a transient tap.",
364
+ "complexTypes": [],
365
+ "type": "number | undefined"
366
+ },
367
+ {
368
+ "name": "intensity",
369
+ "tags": [
370
+ {
371
+ "text": "0.1.0",
372
+ "name": "since"
373
+ },
374
+ {
375
+ "text": "1.0",
376
+ "name": "example"
377
+ }
378
+ ],
379
+ "docs": "The intensity of the event as a value between `0` and `1`.\n\nOn Android, the intensity is only respected on devices with amplitude\ncontrol.",
380
+ "complexTypes": [],
381
+ "type": "number"
382
+ },
383
+ {
384
+ "name": "sharpness",
385
+ "tags": [
386
+ {
387
+ "text": "0.1.0",
388
+ "name": "since"
389
+ },
390
+ {
391
+ "text": "0.5",
392
+ "name": "default"
393
+ },
394
+ {
395
+ "text": "0.7",
396
+ "name": "example"
397
+ }
398
+ ],
399
+ "docs": "The sharpness of the event as a value between `0` and `1`.\n\nA lower value results in a rounder, softer feedback while a higher value\nresults in a crisper, more precise feedback.\n\nOnly available on iOS.",
400
+ "complexTypes": [],
401
+ "type": "number | undefined"
402
+ },
403
+ {
404
+ "name": "time",
405
+ "tags": [
406
+ {
407
+ "text": "0.1.0",
408
+ "name": "since"
409
+ },
410
+ {
411
+ "text": "0.2",
412
+ "name": "example"
413
+ }
414
+ ],
415
+ "docs": "The relative time at which the event occurs, in seconds.",
416
+ "complexTypes": [],
417
+ "type": "number"
418
+ }
419
+ ]
420
+ },
421
+ {
422
+ "name": "VibrateOptions",
423
+ "slug": "vibrateoptions",
424
+ "docs": "",
425
+ "tags": [
426
+ {
427
+ "text": "0.1.0",
428
+ "name": "since"
429
+ }
430
+ ],
431
+ "methods": [],
432
+ "properties": [
433
+ {
434
+ "name": "duration",
435
+ "tags": [
436
+ {
437
+ "text": "0.1.0",
438
+ "name": "since"
439
+ },
440
+ {
441
+ "text": "300",
442
+ "name": "default"
443
+ },
444
+ {
445
+ "text": "500",
446
+ "name": "example"
447
+ }
448
+ ],
449
+ "docs": "The duration of the vibration in milliseconds.\n\nOnly available on Android and Web.",
450
+ "complexTypes": [],
451
+ "type": "number | undefined"
452
+ }
453
+ ]
454
+ }
455
+ ],
456
+ "enums": [
457
+ {
458
+ "name": "ImpactStyle",
459
+ "slug": "impactstyle",
460
+ "members": [
461
+ {
462
+ "name": "Heavy",
463
+ "value": "'HEAVY'",
464
+ "tags": [
465
+ {
466
+ "text": "0.1.0",
467
+ "name": "since"
468
+ }
469
+ ],
470
+ "docs": "A collision between large, heavy user interface elements."
471
+ },
472
+ {
473
+ "name": "Light",
474
+ "value": "'LIGHT'",
475
+ "tags": [
476
+ {
477
+ "text": "0.1.0",
478
+ "name": "since"
479
+ }
480
+ ],
481
+ "docs": "A collision between small, light user interface elements."
482
+ },
483
+ {
484
+ "name": "Medium",
485
+ "value": "'MEDIUM'",
486
+ "tags": [
487
+ {
488
+ "text": "0.1.0",
489
+ "name": "since"
490
+ }
491
+ ],
492
+ "docs": "A collision between moderately sized user interface elements."
493
+ },
494
+ {
495
+ "name": "Rigid",
496
+ "value": "'RIGID'",
497
+ "tags": [
498
+ {
499
+ "text": "0.1.0",
500
+ "name": "since"
501
+ }
502
+ ],
503
+ "docs": "A collision between hard or inflexible user interface elements."
504
+ },
505
+ {
506
+ "name": "Soft",
507
+ "value": "'SOFT'",
508
+ "tags": [
509
+ {
510
+ "text": "0.1.0",
511
+ "name": "since"
512
+ }
513
+ ],
514
+ "docs": "A collision between soft or flexible user interface elements."
515
+ }
516
+ ]
517
+ },
518
+ {
519
+ "name": "NotificationType",
520
+ "slug": "notificationtype",
521
+ "members": [
522
+ {
523
+ "name": "Error",
524
+ "value": "'ERROR'",
525
+ "tags": [
526
+ {
527
+ "text": "0.1.0",
528
+ "name": "since"
529
+ }
530
+ ],
531
+ "docs": "A task or action has failed."
532
+ },
533
+ {
534
+ "name": "Success",
535
+ "value": "'SUCCESS'",
536
+ "tags": [
537
+ {
538
+ "text": "0.1.0",
539
+ "name": "since"
540
+ }
541
+ ],
542
+ "docs": "A task or action has completed successfully."
543
+ },
544
+ {
545
+ "name": "Warning",
546
+ "value": "'WARNING'",
547
+ "tags": [
548
+ {
549
+ "text": "0.1.0",
550
+ "name": "since"
551
+ }
552
+ ],
553
+ "docs": "A task or action has produced a warning."
554
+ }
555
+ ]
556
+ },
557
+ {
558
+ "name": "AndroidHapticType",
559
+ "slug": "androidhaptictype",
560
+ "members": [
561
+ {
562
+ "name": "ClockTick",
563
+ "value": "'CLOCK_TICK'",
564
+ "tags": [
565
+ {
566
+ "text": "0.1.0",
567
+ "name": "since"
568
+ }
569
+ ],
570
+ "docs": "The user has pressed either an hour or minute tick of a clock."
571
+ },
572
+ {
573
+ "name": "Confirm",
574
+ "value": "'CONFIRM'",
575
+ "tags": [
576
+ {
577
+ "text": "0.1.0",
578
+ "name": "since"
579
+ }
580
+ ],
581
+ "docs": "The confirmation of a user's action.\n\nOn Android 10 and older, `ContextClick` is performed instead."
582
+ },
583
+ {
584
+ "name": "ContextClick",
585
+ "value": "'CONTEXT_CLICK'",
586
+ "tags": [
587
+ {
588
+ "text": "0.1.0",
589
+ "name": "since"
590
+ }
591
+ ],
592
+ "docs": "The user has performed a context click on an object."
593
+ },
594
+ {
595
+ "name": "KeyboardTap",
596
+ "value": "'KEYBOARD_TAP'",
597
+ "tags": [
598
+ {
599
+ "text": "0.1.0",
600
+ "name": "since"
601
+ }
602
+ ],
603
+ "docs": "The user has pressed a virtual or software keyboard key."
604
+ },
605
+ {
606
+ "name": "LongPress",
607
+ "value": "'LONG_PRESS'",
608
+ "tags": [
609
+ {
610
+ "text": "0.1.0",
611
+ "name": "since"
612
+ }
613
+ ],
614
+ "docs": "The user has performed a long press on an object."
615
+ },
616
+ {
617
+ "name": "Reject",
618
+ "value": "'REJECT'",
619
+ "tags": [
620
+ {
621
+ "text": "0.1.0",
622
+ "name": "since"
623
+ }
624
+ ],
625
+ "docs": "The rejection or failure of a user's action.\n\nOn Android 10 and older, `LongPress` is performed instead."
626
+ },
627
+ {
628
+ "name": "ToggleOff",
629
+ "value": "'TOGGLE_OFF'",
630
+ "tags": [
631
+ {
632
+ "text": "0.1.0",
633
+ "name": "since"
634
+ }
635
+ ],
636
+ "docs": "The user has toggled a switch or button into the off position.\n\nOn Android 13 and older, `ClockTick` is performed instead."
637
+ },
638
+ {
639
+ "name": "ToggleOn",
640
+ "value": "'TOGGLE_ON'",
641
+ "tags": [
642
+ {
643
+ "text": "0.1.0",
644
+ "name": "since"
645
+ }
646
+ ],
647
+ "docs": "The user has toggled a switch or button into the on position.\n\nOn Android 13 and older, `ClockTick` is performed instead."
648
+ },
649
+ {
650
+ "name": "VirtualKey",
651
+ "value": "'VIRTUAL_KEY'",
652
+ "tags": [
653
+ {
654
+ "text": "0.1.0",
655
+ "name": "since"
656
+ }
657
+ ],
658
+ "docs": "The user has pressed on a virtual on-screen key."
659
+ }
660
+ ]
661
+ }
662
+ ],
663
+ "typeAliases": [],
664
+ "pluginConfigs": []
665
+ }