bare-pointer 0.1.3 → 0.1.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/index.js CHANGED
@@ -52,6 +52,15 @@ module.exports = class Pointer {
52
52
 
53
53
  if (this._backend.tap) {
54
54
  this._backend.tap(view, ...point)
55
+
56
+ // A tap can be posted to an event queue rather than delivered at once.
57
+ if (this._backend.pending !== undefined) {
58
+ for (let frames = 0; this._backend.pending(view); frames++) {
59
+ if (frames === 60) throw new Error('The tap was not delivered')
60
+
61
+ await this._frame(view)
62
+ }
63
+ }
55
64
  } else {
56
65
  this._backend.down(view, ...point)
57
66
 
package/lib/darwin.js CHANGED
@@ -2,7 +2,11 @@ const AnimationFrameProvider = require('bare-animation-frame')
2
2
  const AppKitApplication = require('bare-app-kit/application')
3
3
  const AppKitEvent = require('bare-app-kit/event')
4
4
 
5
- const { TYPE } = AppKitEvent
5
+ const { TYPE, MASK } = AppKitEvent
6
+
7
+ // A run loop mode of its own, so that nothing else runs while the event queue
8
+ // is read.
9
+ const MODE = 'to.holepunch.bare.pointer'
6
10
 
7
11
  module.exports = class DarwinPointer {
8
12
  constructor() {
@@ -65,6 +69,21 @@ module.exports = class DarwinPointer {
65
69
  AppKitApplication.postEvent(this._event(TYPE.LEFT_MOUSE_UP, window, point))
66
70
  }
67
71
 
72
+ pending(view) {
73
+ const window = view.window
74
+
75
+ if (window === null) return false
76
+
77
+ const event = AppKitApplication.nextEventMatchingMask(
78
+ MASK.LEFT_MOUSE_DOWN | MASK.LEFT_MOUSE_UP,
79
+ null,
80
+ MODE,
81
+ false
82
+ )
83
+
84
+ return event !== null && event.windowNumber === window.windowNumber
85
+ }
86
+
68
87
  destroy() {}
69
88
 
70
89
  _send(type, view, x, y) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-pointer",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Simulated pointer input for testing Bare apps",
5
5
  "exports": {
6
6
  "./package": "./package.json",
@@ -48,7 +48,7 @@
48
48
  "homepage": "https://github.com/holepunchto/bare-pointer#readme",
49
49
  "dependencies": {
50
50
  "bare-animation-frame": "^0.1.1",
51
- "bare-app-kit": "^0.3.1",
51
+ "bare-app-kit": "^0.3.3",
52
52
  "bare-ndk": "^0.3.4",
53
53
  "bare-ui-kit-touch": "^0.1.0",
54
54
  "bare-user32": "^0.1.1",