@tamagui/react-native-use-responder-events 1.114.4 → 1.115.0

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,262 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var ResponderSystem_exports = {};
33
+ __export(ResponderSystem_exports, {
34
+ addNode: () => addNode,
35
+ attachListeners: () => attachListeners,
36
+ getResponderNode: () => getResponderNode,
37
+ removeNode: () => removeNode,
38
+ terminateResponder: () => terminateResponder
39
+ });
40
+ module.exports = __toCommonJS(ResponderSystem_exports);
41
+ var import_createResponderEvent = __toESM(require("./createResponderEvent.cjs")),
42
+ import_ResponderTouchHistoryStore = require("./ResponderTouchHistoryStore.cjs"),
43
+ import_types = require("./types.cjs"),
44
+ import_utils = require("./utils.cjs"),
45
+ import_utils2 = require("./utils.cjs");
46
+ const emptyObject = {},
47
+ startRegistration = ["onStartShouldSetResponderCapture", "onStartShouldSetResponder", {
48
+ bubbles: !0
49
+ }],
50
+ moveRegistration = ["onMoveShouldSetResponderCapture", "onMoveShouldSetResponder", {
51
+ bubbles: !0
52
+ }],
53
+ scrollRegistration = ["onScrollShouldSetResponderCapture", "onScrollShouldSetResponder", {
54
+ bubbles: !1
55
+ }],
56
+ shouldSetResponderEvents = {
57
+ touchstart: startRegistration,
58
+ mousedown: startRegistration,
59
+ touchmove: moveRegistration,
60
+ mousemove: moveRegistration,
61
+ scroll: scrollRegistration
62
+ },
63
+ emptyResponder = {
64
+ id: null,
65
+ idPath: null,
66
+ node: null
67
+ },
68
+ responderListenersMap = /* @__PURE__ */new Map();
69
+ let isEmulatingMouseEvents = !1,
70
+ trackedTouchCount = 0,
71
+ currentResponder = {
72
+ id: null,
73
+ node: null,
74
+ idPath: null
75
+ };
76
+ const responderTouchHistoryStore = new import_ResponderTouchHistoryStore.ResponderTouchHistoryStore();
77
+ function changeCurrentResponder(responder) {
78
+ currentResponder = responder;
79
+ }
80
+ function getResponderConfig(id) {
81
+ const config = responderListenersMap.get(id);
82
+ return config ?? emptyObject;
83
+ }
84
+ function eventListener(domEvent) {
85
+ const eventType = domEvent.type,
86
+ eventTarget = domEvent.target;
87
+ if (eventType === "touchstart" && (isEmulatingMouseEvents = !0), (eventType === "touchmove" || trackedTouchCount > 1) && (isEmulatingMouseEvents = !1),
88
+ // Ignore browser emulated mouse events
89
+ eventType === "mousedown" && isEmulatingMouseEvents || eventType === "mousemove" && isEmulatingMouseEvents ||
90
+ // Ignore mousemove if a mousedown didn't occur first
91
+ eventType === "mousemove" && trackedTouchCount < 1) return;
92
+ if (isEmulatingMouseEvents && eventType === "mouseup") {
93
+ trackedTouchCount === 0 && (isEmulatingMouseEvents = !1);
94
+ return;
95
+ }
96
+ const isStartEvent = (0, import_types.isStartish)(eventType) && (0, import_utils2.isPrimaryPointerDown)(domEvent),
97
+ isMoveEvent = (0, import_types.isMoveish)(eventType),
98
+ isEndEvent = (0, import_types.isEndish)(eventType),
99
+ isScrollEvent = (0, import_types.isScroll)(eventType),
100
+ isSelectionChangeEvent = (0, import_types.isSelectionChange)(eventType),
101
+ responderEvent = (0, import_createResponderEvent.default)(domEvent, responderTouchHistoryStore);
102
+ (isStartEvent || isMoveEvent || isEndEvent) && (domEvent.touches ? trackedTouchCount = domEvent.touches.length : isStartEvent ? trackedTouchCount = 1 : isEndEvent && (trackedTouchCount = 0), responderTouchHistoryStore.recordTouchTrack(eventType, responderEvent.nativeEvent));
103
+ let eventPaths = (0, import_utils2.getResponderPaths)(domEvent),
104
+ wasNegotiated = !1,
105
+ wantsResponder;
106
+ if (isStartEvent || isMoveEvent || isScrollEvent && trackedTouchCount > 0) {
107
+ const currentResponderIdPath = currentResponder.idPath,
108
+ eventIdPath = eventPaths.idPath;
109
+ if (currentResponderIdPath != null && eventIdPath != null) {
110
+ const lowestCommonAncestor = (0, import_utils2.getLowestCommonAncestor)(currentResponderIdPath, eventIdPath);
111
+ if (lowestCommonAncestor != null) {
112
+ const index = eventIdPath.indexOf(lowestCommonAncestor) + (lowestCommonAncestor === currentResponder.id ? 1 : 0);
113
+ eventPaths = {
114
+ idPath: eventIdPath.slice(index),
115
+ nodePath: eventPaths.nodePath.slice(index)
116
+ };
117
+ } else eventPaths = null;
118
+ }
119
+ eventPaths != null && (wantsResponder = findWantsResponder(eventPaths, domEvent, responderEvent), wantsResponder != null && (attemptTransfer(responderEvent, wantsResponder), wasNegotiated = !0));
120
+ }
121
+ if (currentResponder.id != null && currentResponder.node != null) {
122
+ const {
123
+ id,
124
+ node
125
+ } = currentResponder,
126
+ {
127
+ onResponderStart,
128
+ onResponderMove,
129
+ onResponderEnd,
130
+ onResponderRelease,
131
+ onResponderTerminate,
132
+ onResponderTerminationRequest
133
+ } = getResponderConfig(id);
134
+ if (responderEvent.bubbles = !1, responderEvent.cancelable = !1, responderEvent.currentTarget = node, isStartEvent) onResponderStart != null && (responderEvent.dispatchConfig.registrationName = "onResponderStart", onResponderStart(responderEvent));else if (isMoveEvent) onResponderMove != null && (responderEvent.dispatchConfig.registrationName = "onResponderMove", onResponderMove(responderEvent));else {
135
+ const isTerminateEvent = (0, import_types.isCancelish)(eventType) ||
136
+ // native context menu
137
+ eventType === "contextmenu" ||
138
+ // window blur
139
+ eventType === "blur" && eventTarget === window ||
140
+ // responder (or ancestors) blur
141
+ eventType === "blur" && eventTarget.contains(node) && domEvent.relatedTarget !== node ||
142
+ // native scroll without using a pointer
143
+ isScrollEvent && trackedTouchCount === 0 ||
144
+ // native scroll on node that is parent of the responder (allow siblings to scroll)
145
+ isScrollEvent && eventTarget.contains(node) && eventTarget !== node ||
146
+ // native select/selectionchange on node
147
+ isSelectionChangeEvent && (0, import_utils2.hasValidSelection)(domEvent),
148
+ isReleaseEvent = isEndEvent && !isTerminateEvent && !(0, import_utils2.hasTargetTouches)(node, domEvent.touches);
149
+ if (isEndEvent && onResponderEnd != null && (responderEvent.dispatchConfig.registrationName = "onResponderEnd", onResponderEnd(responderEvent)), isReleaseEvent && (onResponderRelease != null && (responderEvent.dispatchConfig.registrationName = "onResponderRelease", onResponderRelease(responderEvent)), changeCurrentResponder(emptyResponder)), isTerminateEvent) {
150
+ let shouldTerminate = !0;
151
+ (eventType === "contextmenu" || eventType === "scroll" || eventType === "selectionchange") && (wasNegotiated ? shouldTerminate = !1 : onResponderTerminationRequest != null && (responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest", onResponderTerminationRequest(responderEvent) === !1 && (shouldTerminate = !1))), shouldTerminate && (onResponderTerminate != null && (responderEvent.dispatchConfig.registrationName = "onResponderTerminate", onResponderTerminate(responderEvent)), changeCurrentResponder(emptyResponder), isEmulatingMouseEvents = !1, trackedTouchCount = 0);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ function findWantsResponder(eventPaths, domEvent, responderEvent) {
157
+ const shouldSetCallbacks = shouldSetResponderEvents[domEvent.type];
158
+ if (shouldSetCallbacks != null) {
159
+ const {
160
+ idPath,
161
+ nodePath
162
+ } = eventPaths,
163
+ shouldSetCallbackCaptureName = shouldSetCallbacks[0],
164
+ shouldSetCallbackBubbleName = shouldSetCallbacks[1],
165
+ {
166
+ bubbles
167
+ } = shouldSetCallbacks[2],
168
+ check = (id, node, callbackName) => {
169
+ const shouldSetCallback = getResponderConfig(id)[callbackName];
170
+ if (shouldSetCallback != null && (responderEvent.currentTarget = node, shouldSetCallback(responderEvent) === !0)) {
171
+ const prunedIdPath = idPath.slice(idPath.indexOf(id));
172
+ return {
173
+ id,
174
+ node,
175
+ idPath: prunedIdPath
176
+ };
177
+ }
178
+ };
179
+ for (let i = idPath.length - 1; i >= 0; i--) {
180
+ const id = idPath[i],
181
+ node = nodePath[i],
182
+ result = check(id, node, shouldSetCallbackCaptureName);
183
+ if (result != null) return result;
184
+ if (responderEvent.isPropagationStopped() === !0) return;
185
+ }
186
+ if (bubbles) for (let i = 0; i < idPath.length; i++) {
187
+ const id = idPath[i],
188
+ node = nodePath[i],
189
+ result = check(id, node, shouldSetCallbackBubbleName);
190
+ if (result != null) return result;
191
+ if (responderEvent.isPropagationStopped() === !0) return;
192
+ } else {
193
+ const id = idPath[0],
194
+ node = nodePath[0];
195
+ if (domEvent.target === node) return check(id, node, shouldSetCallbackBubbleName);
196
+ }
197
+ }
198
+ }
199
+ function attemptTransfer(responderEvent, wantsResponder) {
200
+ const {
201
+ id: currentId,
202
+ node: currentNode
203
+ } = currentResponder,
204
+ {
205
+ id,
206
+ node
207
+ } = wantsResponder,
208
+ {
209
+ onResponderGrant,
210
+ onResponderReject
211
+ } = getResponderConfig(id);
212
+ if (responderEvent.bubbles = !1, responderEvent.cancelable = !1, responderEvent.currentTarget = node, currentId == null) onResponderGrant != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderGrant", onResponderGrant(responderEvent)), changeCurrentResponder(wantsResponder);else {
213
+ const {
214
+ onResponderTerminate,
215
+ onResponderTerminationRequest
216
+ } = getResponderConfig(currentId);
217
+ let allowTransfer = !0;
218
+ onResponderTerminationRequest != null && (responderEvent.currentTarget = currentNode, responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest", onResponderTerminationRequest(responderEvent) === !1 && (allowTransfer = !1)), allowTransfer ? (onResponderTerminate != null && (responderEvent.currentTarget = currentNode, responderEvent.dispatchConfig.registrationName = "onResponderTerminate", onResponderTerminate(responderEvent)), onResponderGrant != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderGrant", onResponderGrant(responderEvent)), changeCurrentResponder(wantsResponder)) : onResponderReject != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderReject", onResponderReject(responderEvent));
219
+ }
220
+ }
221
+ const documentEventsCapturePhase = ["blur", "scroll"],
222
+ documentEventsBubblePhase = [
223
+ // mouse
224
+ "mousedown", "mousemove", "mouseup", "dragstart",
225
+ // touch
226
+ "touchstart", "touchmove", "touchend", "touchcancel",
227
+ // other
228
+ "contextmenu", "select", "selectionchange"],
229
+ isTamaguiResponderActive = Symbol();
230
+ function attachListeners() {
231
+ import_utils.canUseDOM && !window[isTamaguiResponderActive] && (window.addEventListener("blur", eventListener), documentEventsBubblePhase.forEach(eventType => {
232
+ document.addEventListener(eventType, eventListener);
233
+ }), documentEventsCapturePhase.forEach(eventType => {
234
+ document.addEventListener(eventType, eventListener, !0);
235
+ }), window[isTamaguiResponderActive] = !0);
236
+ }
237
+ function addNode(id, node, config) {
238
+ (0, import_utils2.setResponderId)(node, id), responderListenersMap.set(id, config);
239
+ }
240
+ function removeNode(id) {
241
+ currentResponder.id === id && terminateResponder(), responderListenersMap.has(id) && responderListenersMap.delete(id);
242
+ }
243
+ function terminateResponder() {
244
+ const {
245
+ id,
246
+ node
247
+ } = currentResponder;
248
+ if (id != null && node != null) {
249
+ const {
250
+ onResponderTerminate
251
+ } = getResponderConfig(id);
252
+ if (onResponderTerminate != null) {
253
+ const event = (0, import_createResponderEvent.default)({}, responderTouchHistoryStore);
254
+ event.currentTarget = node, onResponderTerminate(event);
255
+ }
256
+ changeCurrentResponder(emptyResponder);
257
+ }
258
+ isEmulatingMouseEvents = !1, trackedTouchCount = 0;
259
+ }
260
+ function getResponderNode() {
261
+ return currentResponder.node;
262
+ }
@@ -3,21 +3,27 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
15
21
  var ResponderTouchHistoryStore_exports = {};
16
22
  __export(ResponderTouchHistoryStore_exports, {
17
23
  ResponderTouchHistoryStore: () => ResponderTouchHistoryStore
18
24
  });
19
25
  module.exports = __toCommonJS(ResponderTouchHistoryStore_exports);
20
- var import_types = require("./types");
26
+ var import_types = require("./types.cjs");
21
27
  class ResponderTouchHistoryStore {
22
28
  _touchHistory = {
23
29
  touchBank: [],
@@ -31,17 +37,14 @@ class ResponderTouchHistoryStore {
31
37
  };
32
38
  recordTouchTrack(topLevelType, nativeEvent) {
33
39
  const touchHistory = this._touchHistory;
34
- if ((0, import_types.isMoveish)(topLevelType))
35
- nativeEvent.changedTouches.forEach((touch) => recordTouchMove(touch, touchHistory));
36
- else if ((0, import_types.isStartish)(topLevelType))
37
- nativeEvent.changedTouches.forEach((touch) => recordTouchStart(touch, touchHistory)), touchHistory.numberActiveTouches = nativeEvent.touches.length, touchHistory.numberActiveTouches === 1 && (touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier);
38
- else if ((0, import_types.isEndish)(topLevelType) && (nativeEvent.changedTouches.forEach((touch) => recordTouchEnd(touch, touchHistory)), touchHistory.numberActiveTouches = nativeEvent.touches.length, touchHistory.numberActiveTouches === 1)) {
39
- const { touchBank } = touchHistory;
40
- for (let i = 0; i < touchBank.length; i++)
41
- if (touchBank[i]?.touchActive) {
42
- touchHistory.indexOfSingleActiveTouch = i;
43
- break;
44
- }
40
+ if ((0, import_types.isMoveish)(topLevelType)) nativeEvent.changedTouches.forEach(touch => recordTouchMove(touch, touchHistory));else if ((0, import_types.isStartish)(topLevelType)) nativeEvent.changedTouches.forEach(touch => recordTouchStart(touch, touchHistory)), touchHistory.numberActiveTouches = nativeEvent.touches.length, touchHistory.numberActiveTouches === 1 && (touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier);else if ((0, import_types.isEndish)(topLevelType) && (nativeEvent.changedTouches.forEach(touch => recordTouchEnd(touch, touchHistory)), touchHistory.numberActiveTouches = nativeEvent.touches.length, touchHistory.numberActiveTouches === 1)) {
41
+ const {
42
+ touchBank
43
+ } = touchHistory;
44
+ for (let i = 0; i < touchBank.length; i++) if (touchBank[i]?.touchActive) {
45
+ touchHistory.indexOfSingleActiveTouch = i;
46
+ break;
47
+ }
45
48
  process.env.NODE_ENV === "development" && (touchBank[touchHistory.indexOfSingleActiveTouch]?.touchActive || console.error("Cannot find single active touch."));
46
49
  }
47
50
  }
@@ -70,36 +73,27 @@ function createTouchRecord(touch) {
70
73
  function resetTouchRecord(touchRecord, touch) {
71
74
  touchRecord.touchActive = !0, touchRecord.startPageX = touch.pageX, touchRecord.startPageY = touch.pageY, touchRecord.startTimeStamp = timestampForTouch(touch), touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch), touchRecord.previousPageX = touch.pageX, touchRecord.previousPageY = touch.pageY, touchRecord.previousTimeStamp = timestampForTouch(touch);
72
75
  }
73
- function getTouchIdentifier({ identifier }) {
74
- return identifier == null && console.error("Touch object is missing identifier."), process.env.NODE_ENV === "development" && identifier > MAX_TOUCH_BANK && console.error(
75
- "Touch identifier %s is greater than maximum supported %s which causes performance issues backfilling array locations for all of the indices.",
76
- identifier,
77
- MAX_TOUCH_BANK
78
- ), identifier;
76
+ function getTouchIdentifier({
77
+ identifier
78
+ }) {
79
+ return identifier == null && console.error("Touch object is missing identifier."), process.env.NODE_ENV === "development" && identifier > MAX_TOUCH_BANK && console.error("Touch identifier %s is greater than maximum supported %s which causes performance issues backfilling array locations for all of the indices.", identifier, MAX_TOUCH_BANK), identifier;
79
80
  }
80
81
  function recordTouchStart(touch, touchHistory) {
81
- const identifier = getTouchIdentifier(touch), touchRecord = touchHistory.touchBank[identifier];
82
+ const identifier = getTouchIdentifier(touch),
83
+ touchRecord = touchHistory.touchBank[identifier];
82
84
  touchRecord ? resetTouchRecord(touchRecord, touch) : touchHistory.touchBank[identifier] = createTouchRecord(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
83
85
  }
84
86
  function recordTouchMove(touch, touchHistory) {
85
87
  const touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
86
- touchRecord ? (touchRecord.touchActive = !0, touchRecord.previousPageX = touchRecord.currentPageX, touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp, touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch)) : console.warn(
87
- `Cannot record touch move without a touch start.
88
- `,
89
- `Touch Move: ${printTouch(touch)}
90
- `,
91
- `Touch Bank: ${printTouchBank(touchHistory)}`
92
- );
88
+ touchRecord ? (touchRecord.touchActive = !0, touchRecord.previousPageX = touchRecord.currentPageX, touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp, touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch)) : console.warn(`Cannot record touch move without a touch start.
89
+ `, `Touch Move: ${printTouch(touch)}
90
+ `, `Touch Bank: ${printTouchBank(touchHistory)}`);
93
91
  }
94
92
  function recordTouchEnd(touch, touchHistory) {
95
93
  const touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
96
- touchRecord ? (touchRecord.touchActive = !1, touchRecord.previousPageX = touchRecord.currentPageX, touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp, touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch)) : console.warn(
97
- `Cannot record touch end without a touch start.
98
- `,
99
- `Touch End: ${printTouch(touch)}
100
- `,
101
- `Touch Bank: ${printTouchBank(touchHistory)}`
102
- );
94
+ touchRecord ? (touchRecord.touchActive = !1, touchRecord.previousPageX = touchRecord.currentPageX, touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp, touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch)) : console.warn(`Cannot record touch end without a touch start.
95
+ `, `Touch End: ${printTouch(touch)}
96
+ `, `Touch Bank: ${printTouchBank(touchHistory)}`);
103
97
  }
104
98
  function printTouch(touch) {
105
99
  return JSON.stringify({
@@ -110,8 +104,9 @@ function printTouch(touch) {
110
104
  });
111
105
  }
112
106
  function printTouchBank(touchHistory) {
113
- const { touchBank } = touchHistory;
107
+ const {
108
+ touchBank
109
+ } = touchHistory;
114
110
  let printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
115
111
  return touchBank.length > MAX_TOUCH_BANK && (printed += ` (original size: ${touchBank.length})`), printed;
116
- }
117
- //# sourceMappingURL=ResponderTouchHistoryStore.js.map
112
+ }
@@ -3,31 +3,52 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
15
21
  var createResponderEvent_exports = {};
16
22
  __export(createResponderEvent_exports, {
17
23
  default: () => createResponderEvent
18
24
  });
19
25
  module.exports = __toCommonJS(createResponderEvent_exports);
20
- var import_utils = require("./utils");
21
- const emptyFunction = () => {
22
- }, emptyObject = {}, emptyArray = [];
26
+ var import_utils = require("./utils.cjs");
27
+ const emptyFunction = () => {},
28
+ emptyObject = {},
29
+ emptyArray = [];
23
30
  function normalizeIdentifier(identifier) {
24
31
  return identifier > 20 ? identifier % 20 : identifier;
25
32
  }
26
33
  function createResponderEvent(domEvent, responderTouchHistoryStore) {
27
- let rect, propagationWasStopped = !1, changedTouches, touches;
28
- const domEventChangedTouches = domEvent.changedTouches, domEventType = domEvent.type, metaKey = domEvent.metaKey === !0, shiftKey = domEvent.shiftKey === !0, force = domEventChangedTouches?.[0].force || 0, identifier = normalizeIdentifier(domEventChangedTouches?.[0].identifier || 0), clientX = domEventChangedTouches?.[0].clientX || domEvent.clientX, clientY = domEventChangedTouches?.[0].clientY || domEvent.clientY, pageX = domEventChangedTouches?.[0].pageX || domEvent.pageX, pageY = domEventChangedTouches?.[0].pageY || domEvent.pageY, preventDefault = typeof domEvent.preventDefault == "function" ? domEvent.preventDefault.bind(domEvent) : emptyFunction, timestamp = domEvent.timeStamp;
34
+ let rect,
35
+ propagationWasStopped = !1,
36
+ changedTouches,
37
+ touches;
38
+ const domEventChangedTouches = domEvent.changedTouches,
39
+ domEventType = domEvent.type,
40
+ metaKey = domEvent.metaKey === !0,
41
+ shiftKey = domEvent.shiftKey === !0,
42
+ force = domEventChangedTouches?.[0].force || 0,
43
+ identifier = normalizeIdentifier(domEventChangedTouches?.[0].identifier || 0),
44
+ clientX = domEventChangedTouches?.[0].clientX || domEvent.clientX,
45
+ clientY = domEventChangedTouches?.[0].clientY || domEvent.clientY,
46
+ pageX = domEventChangedTouches?.[0].pageX || domEvent.pageX,
47
+ pageY = domEventChangedTouches?.[0].pageY || domEvent.pageY,
48
+ preventDefault = typeof domEvent.preventDefault == "function" ? domEvent.preventDefault.bind(domEvent) : emptyFunction,
49
+ timestamp = domEvent.timeStamp;
29
50
  function normalizeTouches(touches2) {
30
- return Array.prototype.slice.call(touches2).map((touch) => ({
51
+ return Array.prototype.slice.call(touches2).map(touch => ({
31
52
  force: touch.force,
32
53
  identifier: normalizeIdentifier(touch.identifier),
33
54
  get locationX() {
@@ -42,25 +63,21 @@ function createResponderEvent(domEvent, responderTouchHistoryStore) {
42
63
  timestamp
43
64
  }));
44
65
  }
45
- if (domEventChangedTouches != null)
46
- changedTouches = normalizeTouches(domEventChangedTouches), touches = normalizeTouches(domEvent.touches);
47
- else {
48
- const emulatedTouches = [
49
- {
50
- force,
51
- identifier,
52
- get locationX() {
53
- return locationX(clientX);
54
- },
55
- get locationY() {
56
- return locationY(clientY);
57
- },
58
- pageX,
59
- pageY,
60
- target: domEvent.target,
61
- timestamp
62
- }
63
- ];
66
+ if (domEventChangedTouches != null) changedTouches = normalizeTouches(domEventChangedTouches), touches = normalizeTouches(domEvent.touches);else {
67
+ const emulatedTouches = [{
68
+ force,
69
+ identifier,
70
+ get locationX() {
71
+ return locationX(clientX);
72
+ },
73
+ get locationY() {
74
+ return locationY(clientY);
75
+ },
76
+ pageX,
77
+ pageY,
78
+ target: domEvent.target,
79
+ timestamp
80
+ }];
64
81
  changedTouches = emulatedTouches, touches = domEventType === "mouseup" || domEventType === "dragstart" ? emptyArray : emulatedTouches;
65
82
  }
66
83
  const responderEvent = {
@@ -109,13 +126,10 @@ function createResponderEvent(domEvent, responderTouchHistoryStore) {
109
126
  touchHistory: responderTouchHistoryStore.touchHistory
110
127
  };
111
128
  function locationX(x) {
112
- if (rect = rect || (0, import_utils.getBoundingClientRect)(responderEvent.currentTarget), rect)
113
- return x - rect.left;
129
+ if (rect = rect || (0, import_utils.getBoundingClientRect)(responderEvent.currentTarget), rect) return x - rect.left;
114
130
  }
115
131
  function locationY(y) {
116
- if (rect = rect || (0, import_utils.getBoundingClientRect)(responderEvent.currentTarget), rect)
117
- return y - rect.top;
132
+ if (rect = rect || (0, import_utils.getBoundingClientRect)(responderEvent.currentTarget), rect) return y - rect.top;
118
133
  }
119
134
  return responderEvent;
120
- }
121
- //# sourceMappingURL=createResponderEvent.js.map
135
+ }
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./useResponderEvents.cjs"), module.exports);
@@ -3,15 +3,21 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
15
21
  var types_exports = {};
16
22
  __export(types_exports, {
17
23
  BLUR: () => BLUR,
@@ -36,7 +42,20 @@ __export(types_exports, {
36
42
  isStartish: () => isStartish
37
43
  });
38
44
  module.exports = __toCommonJS(types_exports);
39
- const BLUR = "blur", CONTEXT_MENU = "contextmenu", FOCUS_OUT = "focusout", MOUSE_DOWN = "mousedown", MOUSE_MOVE = "mousemove", MOUSE_UP = "mouseup", MOUSE_CANCEL = "dragstart", TOUCH_START = "touchstart", TOUCH_MOVE = "touchmove", TOUCH_END = "touchend", TOUCH_CANCEL = "touchcancel", SCROLL = "scroll", SELECT = "select", SELECTION_CHANGE = "selectionchange";
45
+ const BLUR = "blur",
46
+ CONTEXT_MENU = "contextmenu",
47
+ FOCUS_OUT = "focusout",
48
+ MOUSE_DOWN = "mousedown",
49
+ MOUSE_MOVE = "mousemove",
50
+ MOUSE_UP = "mouseup",
51
+ MOUSE_CANCEL = "dragstart",
52
+ TOUCH_START = "touchstart",
53
+ TOUCH_MOVE = "touchmove",
54
+ TOUCH_END = "touchend",
55
+ TOUCH_CANCEL = "touchcancel",
56
+ SCROLL = "scroll",
57
+ SELECT = "select",
58
+ SELECTION_CHANGE = "selectionchange";
40
59
  function isStartish(eventType) {
41
60
  return eventType === TOUCH_START || eventType === MOUSE_DOWN;
42
61
  }
@@ -54,5 +73,4 @@ function isScroll(eventType) {
54
73
  }
55
74
  function isSelectionChange(eventType) {
56
75
  return eventType === SELECT || eventType === SELECTION_CHANGE;
57
- }
58
- //# sourceMappingURL=types.js.map
76
+ }
@@ -2,34 +2,49 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
6
7
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")), __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ },
20
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")),
21
+ __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
15
22
  // If the importer is in node compatibility mode or this is not an ESM
16
23
  // file that has been converted to a CommonJS file using a Babel-
17
24
  // compatible transform (i.e. "__esModule" has not been set), then set
18
25
  // "default" to the CommonJS "module.exports" for node compatibility.
19
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
20
- mod
21
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
+ value: mod,
28
+ enumerable: !0
29
+ }) : target, mod)),
30
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
31
+ value: !0
32
+ }), mod);
22
33
  var useResponderEvents_exports = {};
23
34
  __export(useResponderEvents_exports, {
24
35
  getResponderConfigIfDefined: () => getResponderConfigIfDefined,
25
36
  useResponderEvents: () => useResponderEvents
26
37
  });
27
38
  module.exports = __toCommonJS(useResponderEvents_exports);
28
- var React = __toESM(require("react")), ResponderSystem = __toESM(require("./ResponderSystem"));
29
- __reExport(useResponderEvents_exports, require("./utils"), module.exports);
30
- const emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
39
+ var React = __toESM(require("react")),
40
+ ResponderSystem = __toESM(require("./ResponderSystem.cjs"));
41
+ __reExport(useResponderEvents_exports, require("./utils.cjs"), module.exports);
42
+ const emptyObject = {},
43
+ Attached = /* @__PURE__ */new WeakMap(),
44
+ Ids = /* @__PURE__ */new WeakMap();
31
45
  function useResponderEvents(hostRef, configIn = emptyObject) {
32
- const config = getResponderConfigIfDefined(configIn), node = hostRef?.current?.host || hostRef?.current;
46
+ const config = getResponderConfigIfDefined(configIn),
47
+ node = hostRef?.current?.host || hostRef?.current;
33
48
  React.useEffect(() => {
34
49
  if (config === emptyObject) return;
35
50
  ResponderSystem.attachListeners(), Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
@@ -77,5 +92,4 @@ function getResponderConfigIfDefined({
77
92
  onStartShouldSetResponder,
78
93
  onStartShouldSetResponderCapture
79
94
  } : emptyObject;
80
- }
81
- //# sourceMappingURL=useResponderEvents.js.map
95
+ }
@@ -3,15 +3,21 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
15
21
  var utils_exports = {};
16
22
  __export(utils_exports, {
17
23
  canUseDOM: () => canUseDOM,
@@ -25,10 +31,11 @@ __export(utils_exports, {
25
31
  setResponderId: () => setResponderId
26
32
  });
27
33
  module.exports = __toCommonJS(utils_exports);
28
- const keyName = "__reactResponderId", canUseDOM = !!(typeof window < "u" && window.document && window.document.createElement), getBoundingClientRect = (node) => {
29
- if (node && node.nodeType === 1 && node.getBoundingClientRect)
30
- return node.getBoundingClientRect();
31
- };
34
+ const keyName = "__reactResponderId",
35
+ canUseDOM = !!(typeof window < "u" && window.document && window.document.createElement),
36
+ getBoundingClientRect = node => {
37
+ if (node && node.nodeType === 1 && node.getBoundingClientRect) return node.getBoundingClientRect();
38
+ };
32
39
  function getEventPath(domEvent) {
33
40
  if (domEvent.type === "selectionchange") {
34
41
  const target = window.getSelection()?.anchorNode;
@@ -38,8 +45,7 @@ function getEventPath(domEvent) {
38
45
  }
39
46
  function composedPathFallback(target) {
40
47
  const path = [];
41
- for (; target != null && target !== document.body; )
42
- path.push(target), target = target.parentNode;
48
+ for (; target != null && target !== document.body;) path.push(target), target = target.parentNode;
43
49
  return path;
44
50
  }
45
51
  function getResponderId(node) {
@@ -49,39 +55,45 @@ function setResponderId(node, id) {
49
55
  node != null && (node[keyName] = id);
50
56
  }
51
57
  function getResponderPaths(domEvent) {
52
- const idPath = [], nodePath = [], eventPath = getEventPath(domEvent);
58
+ const idPath = [],
59
+ nodePath = [],
60
+ eventPath = getEventPath(domEvent);
53
61
  for (let i = 0; i < eventPath.length; i++) {
54
- const node = eventPath[i], id = getResponderId(node);
62
+ const node = eventPath[i],
63
+ id = getResponderId(node);
55
64
  id != null && (idPath.push(id), nodePath.push(node));
56
65
  }
57
- return { idPath, nodePath };
66
+ return {
67
+ idPath,
68
+ nodePath
69
+ };
58
70
  }
59
71
  function getLowestCommonAncestor(pathA, pathB) {
60
- let pathALength = pathA.length, pathBLength = pathB.length;
72
+ let pathALength = pathA.length,
73
+ pathBLength = pathB.length;
61
74
  if (
62
- // If either path is empty
63
- pathALength === 0 || pathBLength === 0 || // If the last elements aren't the same there can't be a common ancestor
64
- // that is connected to the responder system
65
- pathA[pathALength - 1] !== pathB[pathBLength - 1]
66
- )
67
- return null;
68
- let itemA = pathA[0], indexA = 0, itemB = pathB[0], indexB = 0;
75
+ // If either path is empty
76
+ pathALength === 0 || pathBLength === 0 ||
77
+ // If the last elements aren't the same there can't be a common ancestor
78
+ // that is connected to the responder system
79
+ pathA[pathALength - 1] !== pathB[pathBLength - 1]) return null;
80
+ let itemA = pathA[0],
81
+ indexA = 0,
82
+ itemB = pathB[0],
83
+ indexB = 0;
69
84
  pathALength - pathBLength > 0 && (indexA = pathALength - pathBLength, itemA = pathA[indexA], pathALength = pathBLength), pathBLength - pathALength > 0 && (indexB = pathBLength - pathALength, itemB = pathB[indexB], pathBLength = pathALength);
70
85
  let depth = pathALength;
71
- for (; depth--; ) {
72
- if (itemA === itemB)
73
- return itemA;
86
+ for (; depth--;) {
87
+ if (itemA === itemB) return itemA;
74
88
  itemA = pathA[indexA++], itemB = pathB[indexB++];
75
89
  }
76
90
  return null;
77
91
  }
78
92
  function hasTargetTouches(target, touches) {
79
- if (!touches || touches.length === 0)
80
- return !1;
93
+ if (!touches || touches.length === 0) return !1;
81
94
  for (let i = 0; i < touches.length; i++) {
82
95
  const node = touches[i].target;
83
- if (node != null && target.contains(node))
84
- return !0;
96
+ if (node != null && target.contains(node)) return !0;
85
97
  }
86
98
  return !1;
87
99
  }
@@ -89,14 +101,26 @@ function hasValidSelection(domEvent) {
89
101
  return domEvent.type === "selectionchange" ? isSelectionValid() : domEvent.type === "select";
90
102
  }
91
103
  function isPrimaryPointerDown(domEvent) {
92
- const { altKey, button, buttons, ctrlKey, type } = domEvent, isTouch = type === "touchstart" || type === "touchmove", isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1), isPrimaryMouseMove = type === "mousemove" && buttons === 1, noModifiers = altKey === !1 && ctrlKey === !1;
104
+ const {
105
+ altKey,
106
+ button,
107
+ buttons,
108
+ ctrlKey,
109
+ type
110
+ } = domEvent,
111
+ isTouch = type === "touchstart" || type === "touchmove",
112
+ isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1),
113
+ isPrimaryMouseMove = type === "mousemove" && buttons === 1,
114
+ noModifiers = altKey === !1 && ctrlKey === !1;
93
115
  return !!(isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers);
94
116
  }
95
117
  function isSelectionValid() {
96
118
  const selection = window.getSelection();
97
119
  if (!selection) return !1;
98
- const string = selection.toString(), anchorNode = selection.anchorNode, focusNode = selection.focusNode, isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
120
+ const string = selection.toString(),
121
+ anchorNode = selection.anchorNode,
122
+ focusNode = selection.focusNode,
123
+ isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
99
124
  return string.length >= 1 && string !== `
100
125
  ` && !!isTextNode;
101
- }
102
- //# sourceMappingURL=utils.js.map
126
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/react-native-use-responder-events",
3
- "version": "1.114.4",
3
+ "version": "1.115.0",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -24,11 +24,11 @@
24
24
  "react-native": "./dist/cjs/index.native.js",
25
25
  "types": "./types/index.d.ts",
26
26
  "import": "./dist/esm/index.mjs",
27
- "require": "./dist/cjs/index.js"
27
+ "require": "./dist/cjs/index.cjs"
28
28
  }
29
29
  },
30
30
  "devDependencies": {
31
- "@tamagui/build": "1.114.4",
31
+ "@tamagui/build": "1.115.0",
32
32
  "react": "^18.2.0 || ^19.0.0"
33
33
  },
34
34
  "publishConfig": {
@@ -1,213 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var ResponderSystem_exports = {};
24
- __export(ResponderSystem_exports, {
25
- addNode: () => addNode,
26
- attachListeners: () => attachListeners,
27
- getResponderNode: () => getResponderNode,
28
- removeNode: () => removeNode,
29
- terminateResponder: () => terminateResponder
30
- });
31
- module.exports = __toCommonJS(ResponderSystem_exports);
32
- var import_createResponderEvent = __toESM(require("./createResponderEvent")), import_ResponderTouchHistoryStore = require("./ResponderTouchHistoryStore"), import_types = require("./types"), import_utils = require("./utils"), import_utils2 = require("./utils");
33
- const emptyObject = {}, startRegistration = [
34
- "onStartShouldSetResponderCapture",
35
- "onStartShouldSetResponder",
36
- { bubbles: !0 }
37
- ], moveRegistration = [
38
- "onMoveShouldSetResponderCapture",
39
- "onMoveShouldSetResponder",
40
- { bubbles: !0 }
41
- ], scrollRegistration = [
42
- "onScrollShouldSetResponderCapture",
43
- "onScrollShouldSetResponder",
44
- { bubbles: !1 }
45
- ], shouldSetResponderEvents = {
46
- touchstart: startRegistration,
47
- mousedown: startRegistration,
48
- touchmove: moveRegistration,
49
- mousemove: moveRegistration,
50
- scroll: scrollRegistration
51
- }, emptyResponder = { id: null, idPath: null, node: null }, responderListenersMap = /* @__PURE__ */ new Map();
52
- let isEmulatingMouseEvents = !1, trackedTouchCount = 0, currentResponder = {
53
- id: null,
54
- node: null,
55
- idPath: null
56
- };
57
- const responderTouchHistoryStore = new import_ResponderTouchHistoryStore.ResponderTouchHistoryStore();
58
- function changeCurrentResponder(responder) {
59
- currentResponder = responder;
60
- }
61
- function getResponderConfig(id) {
62
- const config = responderListenersMap.get(id);
63
- return config ?? emptyObject;
64
- }
65
- function eventListener(domEvent) {
66
- const eventType = domEvent.type, eventTarget = domEvent.target;
67
- if (eventType === "touchstart" && (isEmulatingMouseEvents = !0), (eventType === "touchmove" || trackedTouchCount > 1) && (isEmulatingMouseEvents = !1), // Ignore browser emulated mouse events
68
- eventType === "mousedown" && isEmulatingMouseEvents || eventType === "mousemove" && isEmulatingMouseEvents || // Ignore mousemove if a mousedown didn't occur first
69
- eventType === "mousemove" && trackedTouchCount < 1)
70
- return;
71
- if (isEmulatingMouseEvents && eventType === "mouseup") {
72
- trackedTouchCount === 0 && (isEmulatingMouseEvents = !1);
73
- return;
74
- }
75
- const isStartEvent = (0, import_types.isStartish)(eventType) && (0, import_utils2.isPrimaryPointerDown)(domEvent), isMoveEvent = (0, import_types.isMoveish)(eventType), isEndEvent = (0, import_types.isEndish)(eventType), isScrollEvent = (0, import_types.isScroll)(eventType), isSelectionChangeEvent = (0, import_types.isSelectionChange)(eventType), responderEvent = (0, import_createResponderEvent.default)(domEvent, responderTouchHistoryStore);
76
- (isStartEvent || isMoveEvent || isEndEvent) && (domEvent.touches ? trackedTouchCount = domEvent.touches.length : isStartEvent ? trackedTouchCount = 1 : isEndEvent && (trackedTouchCount = 0), responderTouchHistoryStore.recordTouchTrack(
77
- eventType,
78
- responderEvent.nativeEvent
79
- ));
80
- let eventPaths = (0, import_utils2.getResponderPaths)(domEvent), wasNegotiated = !1, wantsResponder;
81
- if (isStartEvent || isMoveEvent || isScrollEvent && trackedTouchCount > 0) {
82
- const currentResponderIdPath = currentResponder.idPath, eventIdPath = eventPaths.idPath;
83
- if (currentResponderIdPath != null && eventIdPath != null) {
84
- const lowestCommonAncestor = (0, import_utils2.getLowestCommonAncestor)(
85
- currentResponderIdPath,
86
- eventIdPath
87
- );
88
- if (lowestCommonAncestor != null) {
89
- const index = eventIdPath.indexOf(lowestCommonAncestor) + (lowestCommonAncestor === currentResponder.id ? 1 : 0);
90
- eventPaths = {
91
- idPath: eventIdPath.slice(index),
92
- nodePath: eventPaths.nodePath.slice(index)
93
- };
94
- } else
95
- eventPaths = null;
96
- }
97
- eventPaths != null && (wantsResponder = findWantsResponder(eventPaths, domEvent, responderEvent), wantsResponder != null && (attemptTransfer(responderEvent, wantsResponder), wasNegotiated = !0));
98
- }
99
- if (currentResponder.id != null && currentResponder.node != null) {
100
- const { id, node } = currentResponder, {
101
- onResponderStart,
102
- onResponderMove,
103
- onResponderEnd,
104
- onResponderRelease,
105
- onResponderTerminate,
106
- onResponderTerminationRequest
107
- } = getResponderConfig(id);
108
- if (responderEvent.bubbles = !1, responderEvent.cancelable = !1, responderEvent.currentTarget = node, isStartEvent)
109
- onResponderStart != null && (responderEvent.dispatchConfig.registrationName = "onResponderStart", onResponderStart(responderEvent));
110
- else if (isMoveEvent)
111
- onResponderMove != null && (responderEvent.dispatchConfig.registrationName = "onResponderMove", onResponderMove(responderEvent));
112
- else {
113
- const isTerminateEvent = (0, import_types.isCancelish)(eventType) || // native context menu
114
- eventType === "contextmenu" || // window blur
115
- eventType === "blur" && eventTarget === window || // responder (or ancestors) blur
116
- eventType === "blur" && eventTarget.contains(node) && domEvent.relatedTarget !== node || // native scroll without using a pointer
117
- isScrollEvent && trackedTouchCount === 0 || // native scroll on node that is parent of the responder (allow siblings to scroll)
118
- isScrollEvent && eventTarget.contains(node) && eventTarget !== node || // native select/selectionchange on node
119
- isSelectionChangeEvent && (0, import_utils2.hasValidSelection)(domEvent), isReleaseEvent = isEndEvent && !isTerminateEvent && !(0, import_utils2.hasTargetTouches)(node, domEvent.touches);
120
- if (isEndEvent && onResponderEnd != null && (responderEvent.dispatchConfig.registrationName = "onResponderEnd", onResponderEnd(responderEvent)), isReleaseEvent && (onResponderRelease != null && (responderEvent.dispatchConfig.registrationName = "onResponderRelease", onResponderRelease(responderEvent)), changeCurrentResponder(emptyResponder)), isTerminateEvent) {
121
- let shouldTerminate = !0;
122
- (eventType === "contextmenu" || eventType === "scroll" || eventType === "selectionchange") && (wasNegotiated ? shouldTerminate = !1 : onResponderTerminationRequest != null && (responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest", onResponderTerminationRequest(responderEvent) === !1 && (shouldTerminate = !1))), shouldTerminate && (onResponderTerminate != null && (responderEvent.dispatchConfig.registrationName = "onResponderTerminate", onResponderTerminate(responderEvent)), changeCurrentResponder(emptyResponder), isEmulatingMouseEvents = !1, trackedTouchCount = 0);
123
- }
124
- }
125
- }
126
- }
127
- function findWantsResponder(eventPaths, domEvent, responderEvent) {
128
- const shouldSetCallbacks = shouldSetResponderEvents[domEvent.type];
129
- if (shouldSetCallbacks != null) {
130
- const { idPath, nodePath } = eventPaths, shouldSetCallbackCaptureName = shouldSetCallbacks[0], shouldSetCallbackBubbleName = shouldSetCallbacks[1], { bubbles } = shouldSetCallbacks[2], check = (id, node, callbackName) => {
131
- const shouldSetCallback = getResponderConfig(id)[callbackName];
132
- if (shouldSetCallback != null && (responderEvent.currentTarget = node, shouldSetCallback(responderEvent) === !0)) {
133
- const prunedIdPath = idPath.slice(idPath.indexOf(id));
134
- return { id, node, idPath: prunedIdPath };
135
- }
136
- };
137
- for (let i = idPath.length - 1; i >= 0; i--) {
138
- const id = idPath[i], node = nodePath[i], result = check(id, node, shouldSetCallbackCaptureName);
139
- if (result != null)
140
- return result;
141
- if (responderEvent.isPropagationStopped() === !0)
142
- return;
143
- }
144
- if (bubbles)
145
- for (let i = 0; i < idPath.length; i++) {
146
- const id = idPath[i], node = nodePath[i], result = check(id, node, shouldSetCallbackBubbleName);
147
- if (result != null)
148
- return result;
149
- if (responderEvent.isPropagationStopped() === !0)
150
- return;
151
- }
152
- else {
153
- const id = idPath[0], node = nodePath[0];
154
- if (domEvent.target === node)
155
- return check(id, node, shouldSetCallbackBubbleName);
156
- }
157
- }
158
- }
159
- function attemptTransfer(responderEvent, wantsResponder) {
160
- const { id: currentId, node: currentNode } = currentResponder, { id, node } = wantsResponder, { onResponderGrant, onResponderReject } = getResponderConfig(id);
161
- if (responderEvent.bubbles = !1, responderEvent.cancelable = !1, responderEvent.currentTarget = node, currentId == null)
162
- onResponderGrant != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderGrant", onResponderGrant(responderEvent)), changeCurrentResponder(wantsResponder);
163
- else {
164
- const { onResponderTerminate, onResponderTerminationRequest } = getResponderConfig(currentId);
165
- let allowTransfer = !0;
166
- onResponderTerminationRequest != null && (responderEvent.currentTarget = currentNode, responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest", onResponderTerminationRequest(responderEvent) === !1 && (allowTransfer = !1)), allowTransfer ? (onResponderTerminate != null && (responderEvent.currentTarget = currentNode, responderEvent.dispatchConfig.registrationName = "onResponderTerminate", onResponderTerminate(responderEvent)), onResponderGrant != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderGrant", onResponderGrant(responderEvent)), changeCurrentResponder(wantsResponder)) : onResponderReject != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderReject", onResponderReject(responderEvent));
167
- }
168
- }
169
- const documentEventsCapturePhase = ["blur", "scroll"], documentEventsBubblePhase = [
170
- // mouse
171
- "mousedown",
172
- "mousemove",
173
- "mouseup",
174
- "dragstart",
175
- // touch
176
- "touchstart",
177
- "touchmove",
178
- "touchend",
179
- "touchcancel",
180
- // other
181
- "contextmenu",
182
- "select",
183
- "selectionchange"
184
- ], isTamaguiResponderActive = Symbol();
185
- function attachListeners() {
186
- import_utils.canUseDOM && !window[isTamaguiResponderActive] && (window.addEventListener("blur", eventListener), documentEventsBubblePhase.forEach((eventType) => {
187
- document.addEventListener(eventType, eventListener);
188
- }), documentEventsCapturePhase.forEach((eventType) => {
189
- document.addEventListener(eventType, eventListener, !0);
190
- }), window[isTamaguiResponderActive] = !0);
191
- }
192
- function addNode(id, node, config) {
193
- (0, import_utils2.setResponderId)(node, id), responderListenersMap.set(id, config);
194
- }
195
- function removeNode(id) {
196
- currentResponder.id === id && terminateResponder(), responderListenersMap.has(id) && responderListenersMap.delete(id);
197
- }
198
- function terminateResponder() {
199
- const { id, node } = currentResponder;
200
- if (id != null && node != null) {
201
- const { onResponderTerminate } = getResponderConfig(id);
202
- if (onResponderTerminate != null) {
203
- const event = (0, import_createResponderEvent.default)({}, responderTouchHistoryStore);
204
- event.currentTarget = node, onResponderTerminate(event);
205
- }
206
- changeCurrentResponder(emptyResponder);
207
- }
208
- isEmulatingMouseEvents = !1, trackedTouchCount = 0;
209
- }
210
- function getResponderNode() {
211
- return currentResponder.node;
212
- }
213
- //# sourceMappingURL=ResponderSystem.js.map
package/dist/cjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- __reExport(src_exports, require("./useResponderEvents"), module.exports);
15
- //# sourceMappingURL=index.js.map
File without changes
File without changes
File without changes