@hanzogui/react-native-use-responder-events 2.0.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.
- package/LICENSE +21 -0
- package/dist/cjs/ResponderSystem.cjs +251 -0
- package/dist/cjs/ResponderSystem.native.js +253 -0
- package/dist/cjs/ResponderSystem.native.js.map +1 -0
- package/dist/cjs/ResponderTouchHistoryStore.cjs +112 -0
- package/dist/cjs/ResponderTouchHistoryStore.native.js +156 -0
- package/dist/cjs/ResponderTouchHistoryStore.native.js.map +1 -0
- package/dist/cjs/createResponderEvent.cjs +135 -0
- package/dist/cjs/createResponderEvent.native.js +140 -0
- package/dist/cjs/createResponderEvent.native.js.map +1 -0
- package/dist/cjs/index.cjs +18 -0
- package/dist/cjs/index.native.js +21 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/types.cjs +76 -0
- package/dist/cjs/types.native.js +79 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/useResponderEvents.cjs +95 -0
- package/dist/cjs/useResponderEvents.native.js +102 -0
- package/dist/cjs/useResponderEvents.native.js.map +1 -0
- package/dist/cjs/utils.cjs +126 -0
- package/dist/cjs/utils.native.js +126 -0
- package/dist/cjs/utils.native.js.map +1 -0
- package/dist/esm/ResponderSystem.mjs +224 -0
- package/dist/esm/ResponderSystem.mjs.map +1 -0
- package/dist/esm/ResponderSystem.native.js +223 -0
- package/dist/esm/ResponderSystem.native.js.map +1 -0
- package/dist/esm/ResponderTouchHistoryStore.mjs +89 -0
- package/dist/esm/ResponderTouchHistoryStore.mjs.map +1 -0
- package/dist/esm/ResponderTouchHistoryStore.native.js +130 -0
- package/dist/esm/ResponderTouchHistoryStore.native.js.map +1 -0
- package/dist/esm/createResponderEvent.mjs +112 -0
- package/dist/esm/createResponderEvent.mjs.map +1 -0
- package/dist/esm/createResponderEvent.native.js +114 -0
- package/dist/esm/createResponderEvent.native.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +2 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/types.mjs +34 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +34 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/useResponderEvents.mjs +59 -0
- package/dist/esm/useResponderEvents.mjs.map +1 -0
- package/dist/esm/useResponderEvents.native.js +63 -0
- package/dist/esm/useResponderEvents.native.js.map +1 -0
- package/dist/esm/utils.mjs +95 -0
- package/dist/esm/utils.mjs.map +1 -0
- package/dist/esm/utils.native.js +92 -0
- package/dist/esm/utils.native.js.map +1 -0
- package/package.json +42 -0
- package/src/ResponderSystem.ts +555 -0
- package/src/ResponderTouchHistoryStore.ts +211 -0
- package/src/createResponderEvent.ts +190 -0
- package/src/index.ts +1 -0
- package/src/types.ts +78 -0
- package/src/useResponderEvents.ts +107 -0
- package/src/utils.ts +196 -0
- package/types/ResponderSystem.d.ts +47 -0
- package/types/ResponderSystem.d.ts.map +1 -0
- package/types/ResponderTouchHistoryStore.d.ts +37 -0
- package/types/ResponderTouchHistoryStore.d.ts.map +1 -0
- package/types/createResponderEvent.d.ts +36 -0
- package/types/createResponderEvent.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts +52 -0
- package/types/types.d.ts.map +1 -0
- package/types/useResponderEvents.d.ts +10 -0
- package/types/useResponderEvents.d.ts.map +1 -0
- package/types/utils.d.ts +38 -0
- package/types/utils.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
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);
|
|
21
|
+
var ResponderSystem_exports = {};
|
|
22
|
+
__export(ResponderSystem_exports, {
|
|
23
|
+
addNode: () => addNode,
|
|
24
|
+
attachListeners: () => attachListeners,
|
|
25
|
+
getResponderNode: () => getResponderNode,
|
|
26
|
+
removeNode: () => removeNode,
|
|
27
|
+
terminateResponder: () => terminateResponder
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(ResponderSystem_exports);
|
|
30
|
+
var import_createResponderEvent = require("./createResponderEvent.cjs"),
|
|
31
|
+
import_ResponderTouchHistoryStore = require("./ResponderTouchHistoryStore.cjs"),
|
|
32
|
+
import_types = require("./types.cjs"),
|
|
33
|
+
import_utils = require("./utils.cjs"),
|
|
34
|
+
import_utils2 = require("./utils.cjs");
|
|
35
|
+
const emptyObject = {},
|
|
36
|
+
startRegistration = ["onStartShouldSetResponderCapture", "onStartShouldSetResponder", {
|
|
37
|
+
bubbles: !0
|
|
38
|
+
}],
|
|
39
|
+
moveRegistration = ["onMoveShouldSetResponderCapture", "onMoveShouldSetResponder", {
|
|
40
|
+
bubbles: !0
|
|
41
|
+
}],
|
|
42
|
+
scrollRegistration = ["onScrollShouldSetResponderCapture", "onScrollShouldSetResponder", {
|
|
43
|
+
bubbles: !1
|
|
44
|
+
}],
|
|
45
|
+
shouldSetResponderEvents = {
|
|
46
|
+
touchstart: startRegistration,
|
|
47
|
+
mousedown: startRegistration,
|
|
48
|
+
touchmove: moveRegistration,
|
|
49
|
+
mousemove: moveRegistration,
|
|
50
|
+
scroll: scrollRegistration
|
|
51
|
+
},
|
|
52
|
+
emptyResponder = {
|
|
53
|
+
id: null,
|
|
54
|
+
idPath: null,
|
|
55
|
+
node: null
|
|
56
|
+
},
|
|
57
|
+
responderListenersMap = /* @__PURE__ */new Map();
|
|
58
|
+
let isEmulatingMouseEvents = !1,
|
|
59
|
+
trackedTouchCount = 0,
|
|
60
|
+
currentResponder = {
|
|
61
|
+
id: null,
|
|
62
|
+
node: null,
|
|
63
|
+
idPath: null
|
|
64
|
+
};
|
|
65
|
+
const responderTouchHistoryStore = new import_ResponderTouchHistoryStore.ResponderTouchHistoryStore();
|
|
66
|
+
function changeCurrentResponder(responder) {
|
|
67
|
+
currentResponder = responder;
|
|
68
|
+
}
|
|
69
|
+
function getResponderConfig(id) {
|
|
70
|
+
const config = responderListenersMap.get(id);
|
|
71
|
+
return config ?? emptyObject;
|
|
72
|
+
}
|
|
73
|
+
function eventListener(domEvent) {
|
|
74
|
+
const eventType = domEvent.type,
|
|
75
|
+
eventTarget = domEvent.target;
|
|
76
|
+
if (eventType === "touchstart" && (isEmulatingMouseEvents = !0), (eventType === "touchmove" || trackedTouchCount > 1) && (isEmulatingMouseEvents = !1),
|
|
77
|
+
// Ignore browser emulated mouse events
|
|
78
|
+
eventType === "mousedown" && isEmulatingMouseEvents || eventType === "mousemove" && isEmulatingMouseEvents ||
|
|
79
|
+
// Ignore mousemove if a mousedown didn't occur first
|
|
80
|
+
eventType === "mousemove" && trackedTouchCount < 1) return;
|
|
81
|
+
if (isEmulatingMouseEvents && eventType === "mouseup") {
|
|
82
|
+
trackedTouchCount === 0 && (isEmulatingMouseEvents = !1);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const isStartEvent = (0, import_types.isStartish)(eventType) && (0, import_utils2.isPrimaryPointerDown)(domEvent),
|
|
86
|
+
isMoveEvent = (0, import_types.isMoveish)(eventType),
|
|
87
|
+
isEndEvent = (0, import_types.isEndish)(eventType),
|
|
88
|
+
isScrollEvent = (0, import_types.isScroll)(eventType),
|
|
89
|
+
isSelectionChangeEvent = (0, import_types.isSelectionChange)(eventType),
|
|
90
|
+
responderEvent = (0, import_createResponderEvent.createResponderEvent)(domEvent, responderTouchHistoryStore);
|
|
91
|
+
(isStartEvent || isMoveEvent || isEndEvent) && (domEvent.touches ? trackedTouchCount = domEvent.touches.length : isStartEvent ? trackedTouchCount = 1 : isEndEvent && (trackedTouchCount = 0), responderTouchHistoryStore.recordTouchTrack(eventType, responderEvent.nativeEvent));
|
|
92
|
+
let eventPaths = (0, import_utils2.getResponderPaths)(domEvent),
|
|
93
|
+
wasNegotiated = !1,
|
|
94
|
+
wantsResponder;
|
|
95
|
+
if (isStartEvent || isMoveEvent || isScrollEvent && trackedTouchCount > 0) {
|
|
96
|
+
const currentResponderIdPath = currentResponder.idPath,
|
|
97
|
+
eventIdPath = eventPaths.idPath;
|
|
98
|
+
if (currentResponderIdPath != null && eventIdPath != null) {
|
|
99
|
+
const lowestCommonAncestor = (0, import_utils2.getLowestCommonAncestor)(currentResponderIdPath, eventIdPath);
|
|
100
|
+
if (lowestCommonAncestor != null) {
|
|
101
|
+
const index = eventIdPath.indexOf(lowestCommonAncestor) + (lowestCommonAncestor === currentResponder.id ? 1 : 0);
|
|
102
|
+
eventPaths = {
|
|
103
|
+
idPath: eventIdPath.slice(index),
|
|
104
|
+
nodePath: eventPaths.nodePath.slice(index)
|
|
105
|
+
};
|
|
106
|
+
} else eventPaths = null;
|
|
107
|
+
}
|
|
108
|
+
eventPaths != null && (wantsResponder = findWantsResponder(eventPaths, domEvent, responderEvent), wantsResponder != null && (attemptTransfer(responderEvent, wantsResponder), wasNegotiated = !0));
|
|
109
|
+
}
|
|
110
|
+
if (currentResponder.id != null && currentResponder.node != null) {
|
|
111
|
+
const {
|
|
112
|
+
id,
|
|
113
|
+
node
|
|
114
|
+
} = currentResponder,
|
|
115
|
+
{
|
|
116
|
+
onResponderStart,
|
|
117
|
+
onResponderMove,
|
|
118
|
+
onResponderEnd,
|
|
119
|
+
onResponderRelease,
|
|
120
|
+
onResponderTerminate,
|
|
121
|
+
onResponderTerminationRequest
|
|
122
|
+
} = getResponderConfig(id);
|
|
123
|
+
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 {
|
|
124
|
+
const isTerminateEvent = (0, import_types.isCancelish)(eventType) ||
|
|
125
|
+
// native context menu
|
|
126
|
+
eventType === "contextmenu" ||
|
|
127
|
+
// window blur
|
|
128
|
+
eventType === "blur" && eventTarget === window ||
|
|
129
|
+
// responder (or ancestors) blur
|
|
130
|
+
eventType === "blur" && eventTarget.contains(node) && domEvent.relatedTarget !== node ||
|
|
131
|
+
// native scroll without using a pointer
|
|
132
|
+
isScrollEvent && trackedTouchCount === 0 ||
|
|
133
|
+
// native scroll on node that is parent of the responder (allow siblings to scroll)
|
|
134
|
+
isScrollEvent && eventTarget.contains(node) && eventTarget !== node ||
|
|
135
|
+
// native select/selectionchange on node
|
|
136
|
+
isSelectionChangeEvent && (0, import_utils2.hasValidSelection)(domEvent),
|
|
137
|
+
isReleaseEvent = isEndEvent && !isTerminateEvent && !(0, import_utils2.hasTargetTouches)(node, domEvent.touches);
|
|
138
|
+
if (isEndEvent && onResponderEnd != null && (responderEvent.dispatchConfig.registrationName = "onResponderEnd", onResponderEnd(responderEvent)), isReleaseEvent && (onResponderRelease != null && (responderEvent.dispatchConfig.registrationName = "onResponderRelease", onResponderRelease(responderEvent)), changeCurrentResponder(emptyResponder)), isTerminateEvent) {
|
|
139
|
+
let shouldTerminate = !0;
|
|
140
|
+
(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);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function findWantsResponder(eventPaths, domEvent, responderEvent) {
|
|
146
|
+
const shouldSetCallbacks = shouldSetResponderEvents[domEvent.type];
|
|
147
|
+
if (shouldSetCallbacks != null) {
|
|
148
|
+
const {
|
|
149
|
+
idPath,
|
|
150
|
+
nodePath
|
|
151
|
+
} = eventPaths,
|
|
152
|
+
shouldSetCallbackCaptureName = shouldSetCallbacks[0],
|
|
153
|
+
shouldSetCallbackBubbleName = shouldSetCallbacks[1],
|
|
154
|
+
{
|
|
155
|
+
bubbles
|
|
156
|
+
} = shouldSetCallbacks[2],
|
|
157
|
+
check = (id, node, callbackName) => {
|
|
158
|
+
const shouldSetCallback = getResponderConfig(id)[callbackName];
|
|
159
|
+
if (shouldSetCallback != null && (responderEvent.currentTarget = node, shouldSetCallback(responderEvent) === !0)) {
|
|
160
|
+
const prunedIdPath = idPath.slice(idPath.indexOf(id));
|
|
161
|
+
return {
|
|
162
|
+
id,
|
|
163
|
+
node,
|
|
164
|
+
idPath: prunedIdPath
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
for (let i = idPath.length - 1; i >= 0; i--) {
|
|
169
|
+
const id = idPath[i],
|
|
170
|
+
node = nodePath[i],
|
|
171
|
+
result = check(id, node, shouldSetCallbackCaptureName);
|
|
172
|
+
if (result != null) return result;
|
|
173
|
+
if (responderEvent.isPropagationStopped() === !0) return;
|
|
174
|
+
}
|
|
175
|
+
if (bubbles) for (let i = 0; i < idPath.length; i++) {
|
|
176
|
+
const id = idPath[i],
|
|
177
|
+
node = nodePath[i],
|
|
178
|
+
result = check(id, node, shouldSetCallbackBubbleName);
|
|
179
|
+
if (result != null) return result;
|
|
180
|
+
if (responderEvent.isPropagationStopped() === !0) return;
|
|
181
|
+
} else {
|
|
182
|
+
const id = idPath[0],
|
|
183
|
+
node = nodePath[0];
|
|
184
|
+
if (domEvent.target === node) return check(id, node, shouldSetCallbackBubbleName);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function attemptTransfer(responderEvent, wantsResponder) {
|
|
189
|
+
const {
|
|
190
|
+
id: currentId,
|
|
191
|
+
node: currentNode
|
|
192
|
+
} = currentResponder,
|
|
193
|
+
{
|
|
194
|
+
id,
|
|
195
|
+
node
|
|
196
|
+
} = wantsResponder,
|
|
197
|
+
{
|
|
198
|
+
onResponderGrant,
|
|
199
|
+
onResponderReject
|
|
200
|
+
} = getResponderConfig(id);
|
|
201
|
+
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 {
|
|
202
|
+
const {
|
|
203
|
+
onResponderTerminate,
|
|
204
|
+
onResponderTerminationRequest
|
|
205
|
+
} = getResponderConfig(currentId);
|
|
206
|
+
let allowTransfer = !0;
|
|
207
|
+
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));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const documentEventsCapturePhase = ["blur", "scroll"],
|
|
211
|
+
documentEventsBubblePhase = [
|
|
212
|
+
// mouse
|
|
213
|
+
"mousedown", "mousemove", "mouseup", "dragstart",
|
|
214
|
+
// touch
|
|
215
|
+
"touchstart", "touchmove", "touchend", "touchcancel",
|
|
216
|
+
// other
|
|
217
|
+
"contextmenu", "select", "selectionchange"],
|
|
218
|
+
isGuiResponderActive = /* @__PURE__ */Symbol();
|
|
219
|
+
function attachListeners() {
|
|
220
|
+
import_utils.canUseDOM && !window[isGuiResponderActive] && (window.addEventListener("blur", eventListener), documentEventsBubblePhase.forEach(eventType => {
|
|
221
|
+
document.addEventListener(eventType, eventListener);
|
|
222
|
+
}), documentEventsCapturePhase.forEach(eventType => {
|
|
223
|
+
document.addEventListener(eventType, eventListener, !0);
|
|
224
|
+
}), window[isGuiResponderActive] = !0);
|
|
225
|
+
}
|
|
226
|
+
function addNode(id, node, config) {
|
|
227
|
+
(0, import_utils2.setResponderId)(node, id), responderListenersMap.set(id, config);
|
|
228
|
+
}
|
|
229
|
+
function removeNode(id) {
|
|
230
|
+
currentResponder.id === id && terminateResponder(), responderListenersMap.has(id) && responderListenersMap.delete(id);
|
|
231
|
+
}
|
|
232
|
+
function terminateResponder() {
|
|
233
|
+
const {
|
|
234
|
+
id,
|
|
235
|
+
node
|
|
236
|
+
} = currentResponder;
|
|
237
|
+
if (id != null && node != null) {
|
|
238
|
+
const {
|
|
239
|
+
onResponderTerminate
|
|
240
|
+
} = getResponderConfig(id);
|
|
241
|
+
if (onResponderTerminate != null) {
|
|
242
|
+
const event = (0, import_createResponderEvent.createResponderEvent)({}, responderTouchHistoryStore);
|
|
243
|
+
event.currentTarget = node, onResponderTerminate(event);
|
|
244
|
+
}
|
|
245
|
+
changeCurrentResponder(emptyResponder);
|
|
246
|
+
}
|
|
247
|
+
isEmulatingMouseEvents = !1, trackedTouchCount = 0;
|
|
248
|
+
}
|
|
249
|
+
function getResponderNode() {
|
|
250
|
+
return currentResponder.node;
|
|
251
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), 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 = require("./createResponderEvent.native.js"),
|
|
33
|
+
import_ResponderTouchHistoryStore = require("./ResponderTouchHistoryStore.native.js"),
|
|
34
|
+
import_types = require("./types.native.js"),
|
|
35
|
+
import_utils = require("./utils.native.js"),
|
|
36
|
+
import_utils2 = require("./utils.native.js"),
|
|
37
|
+
emptyObject = {},
|
|
38
|
+
startRegistration = ["onStartShouldSetResponderCapture", "onStartShouldSetResponder", {
|
|
39
|
+
bubbles: !0
|
|
40
|
+
}],
|
|
41
|
+
moveRegistration = ["onMoveShouldSetResponderCapture", "onMoveShouldSetResponder", {
|
|
42
|
+
bubbles: !0
|
|
43
|
+
}],
|
|
44
|
+
scrollRegistration = ["onScrollShouldSetResponderCapture", "onScrollShouldSetResponder", {
|
|
45
|
+
bubbles: !1
|
|
46
|
+
}],
|
|
47
|
+
shouldSetResponderEvents = {
|
|
48
|
+
touchstart: startRegistration,
|
|
49
|
+
mousedown: startRegistration,
|
|
50
|
+
touchmove: moveRegistration,
|
|
51
|
+
mousemove: moveRegistration,
|
|
52
|
+
scroll: scrollRegistration
|
|
53
|
+
},
|
|
54
|
+
emptyResponder = {
|
|
55
|
+
id: null,
|
|
56
|
+
idPath: null,
|
|
57
|
+
node: null
|
|
58
|
+
},
|
|
59
|
+
responderListenersMap = /* @__PURE__ */new Map(),
|
|
60
|
+
isEmulatingMouseEvents = !1,
|
|
61
|
+
trackedTouchCount = 0,
|
|
62
|
+
currentResponder = {
|
|
63
|
+
id: null,
|
|
64
|
+
node: null,
|
|
65
|
+
idPath: null
|
|
66
|
+
},
|
|
67
|
+
responderTouchHistoryStore = new import_ResponderTouchHistoryStore.ResponderTouchHistoryStore();
|
|
68
|
+
function changeCurrentResponder(responder) {
|
|
69
|
+
currentResponder = responder;
|
|
70
|
+
}
|
|
71
|
+
function getResponderConfig(id) {
|
|
72
|
+
var config = responderListenersMap.get(id);
|
|
73
|
+
return config ?? emptyObject;
|
|
74
|
+
}
|
|
75
|
+
function eventListener(domEvent) {
|
|
76
|
+
var eventType = domEvent.type,
|
|
77
|
+
eventTarget = domEvent.target;
|
|
78
|
+
if (eventType === "touchstart" && (isEmulatingMouseEvents = !0), (eventType === "touchmove" || trackedTouchCount > 1) && (isEmulatingMouseEvents = !1),
|
|
79
|
+
// Ignore browser emulated mouse events
|
|
80
|
+
!(eventType === "mousedown" && isEmulatingMouseEvents || eventType === "mousemove" && isEmulatingMouseEvents ||
|
|
81
|
+
// Ignore mousemove if a mousedown didn't occur first
|
|
82
|
+
eventType === "mousemove" && trackedTouchCount < 1)) {
|
|
83
|
+
if (isEmulatingMouseEvents && eventType === "mouseup") {
|
|
84
|
+
trackedTouchCount === 0 && (isEmulatingMouseEvents = !1);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
var isStartEvent = (0, import_types.isStartish)(eventType) && (0, import_utils2.isPrimaryPointerDown)(domEvent),
|
|
88
|
+
isMoveEvent = (0, import_types.isMoveish)(eventType),
|
|
89
|
+
isEndEvent = (0, import_types.isEndish)(eventType),
|
|
90
|
+
isScrollEvent = (0, import_types.isScroll)(eventType),
|
|
91
|
+
isSelectionChangeEvent = (0, import_types.isSelectionChange)(eventType),
|
|
92
|
+
responderEvent = (0, import_createResponderEvent.createResponderEvent)(domEvent, responderTouchHistoryStore);
|
|
93
|
+
(isStartEvent || isMoveEvent || isEndEvent) && (domEvent.touches ? trackedTouchCount = domEvent.touches.length : isStartEvent ? trackedTouchCount = 1 : isEndEvent && (trackedTouchCount = 0), responderTouchHistoryStore.recordTouchTrack(eventType, responderEvent.nativeEvent));
|
|
94
|
+
var eventPaths = (0, import_utils2.getResponderPaths)(domEvent),
|
|
95
|
+
wasNegotiated = !1,
|
|
96
|
+
wantsResponder;
|
|
97
|
+
if (isStartEvent || isMoveEvent || isScrollEvent && trackedTouchCount > 0) {
|
|
98
|
+
var currentResponderIdPath = currentResponder.idPath,
|
|
99
|
+
eventIdPath = eventPaths.idPath;
|
|
100
|
+
if (currentResponderIdPath != null && eventIdPath != null) {
|
|
101
|
+
var lowestCommonAncestor = (0, import_utils2.getLowestCommonAncestor)(currentResponderIdPath, eventIdPath);
|
|
102
|
+
if (lowestCommonAncestor != null) {
|
|
103
|
+
var indexOfLowestCommonAncestor = eventIdPath.indexOf(lowestCommonAncestor),
|
|
104
|
+
index = indexOfLowestCommonAncestor + (lowestCommonAncestor === currentResponder.id ? 1 : 0);
|
|
105
|
+
eventPaths = {
|
|
106
|
+
idPath: eventIdPath.slice(index),
|
|
107
|
+
nodePath: eventPaths.nodePath.slice(index)
|
|
108
|
+
};
|
|
109
|
+
} else eventPaths = null;
|
|
110
|
+
}
|
|
111
|
+
eventPaths != null && (wantsResponder = findWantsResponder(eventPaths, domEvent, responderEvent), wantsResponder != null && (attemptTransfer(responderEvent, wantsResponder), wasNegotiated = !0));
|
|
112
|
+
}
|
|
113
|
+
if (currentResponder.id != null && currentResponder.node != null) {
|
|
114
|
+
var {
|
|
115
|
+
id,
|
|
116
|
+
node
|
|
117
|
+
} = currentResponder,
|
|
118
|
+
{
|
|
119
|
+
onResponderStart,
|
|
120
|
+
onResponderMove,
|
|
121
|
+
onResponderEnd,
|
|
122
|
+
onResponderRelease,
|
|
123
|
+
onResponderTerminate,
|
|
124
|
+
onResponderTerminationRequest
|
|
125
|
+
} = getResponderConfig(id);
|
|
126
|
+
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 {
|
|
127
|
+
var isTerminateEvent = (0, import_types.isCancelish)(eventType) ||
|
|
128
|
+
// native context menu
|
|
129
|
+
eventType === "contextmenu" ||
|
|
130
|
+
// window blur
|
|
131
|
+
eventType === "blur" && eventTarget === window ||
|
|
132
|
+
// responder (or ancestors) blur
|
|
133
|
+
eventType === "blur" && eventTarget.contains(node) && domEvent.relatedTarget !== node ||
|
|
134
|
+
// native scroll without using a pointer
|
|
135
|
+
isScrollEvent && trackedTouchCount === 0 ||
|
|
136
|
+
// native scroll on node that is parent of the responder (allow siblings to scroll)
|
|
137
|
+
isScrollEvent && eventTarget.contains(node) && eventTarget !== node ||
|
|
138
|
+
// native select/selectionchange on node
|
|
139
|
+
isSelectionChangeEvent && (0, import_utils2.hasValidSelection)(domEvent),
|
|
140
|
+
isReleaseEvent = isEndEvent && !isTerminateEvent && !(0, import_utils2.hasTargetTouches)(node, domEvent.touches);
|
|
141
|
+
if (isEndEvent && onResponderEnd != null && (responderEvent.dispatchConfig.registrationName = "onResponderEnd", onResponderEnd(responderEvent)), isReleaseEvent && (onResponderRelease != null && (responderEvent.dispatchConfig.registrationName = "onResponderRelease", onResponderRelease(responderEvent)), changeCurrentResponder(emptyResponder)), isTerminateEvent) {
|
|
142
|
+
var shouldTerminate = !0;
|
|
143
|
+
(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);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function findWantsResponder(eventPaths, domEvent, responderEvent) {
|
|
150
|
+
var shouldSetCallbacks = shouldSetResponderEvents[domEvent.type];
|
|
151
|
+
if (shouldSetCallbacks != null) {
|
|
152
|
+
for (var {
|
|
153
|
+
idPath,
|
|
154
|
+
nodePath
|
|
155
|
+
} = eventPaths, shouldSetCallbackCaptureName = shouldSetCallbacks[0], shouldSetCallbackBubbleName = shouldSetCallbacks[1], {
|
|
156
|
+
bubbles
|
|
157
|
+
} = shouldSetCallbacks[2], check = function (id3, node3, callbackName) {
|
|
158
|
+
var config = getResponderConfig(id3),
|
|
159
|
+
shouldSetCallback = config[callbackName];
|
|
160
|
+
if (shouldSetCallback != null && (responderEvent.currentTarget = node3, shouldSetCallback(responderEvent) === !0)) {
|
|
161
|
+
var prunedIdPath = idPath.slice(idPath.indexOf(id3));
|
|
162
|
+
return {
|
|
163
|
+
id: id3,
|
|
164
|
+
node: node3,
|
|
165
|
+
idPath: prunedIdPath
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}, i = idPath.length - 1; i >= 0; i--) {
|
|
169
|
+
var id = idPath[i],
|
|
170
|
+
node = nodePath[i],
|
|
171
|
+
result = check(id, node, shouldSetCallbackCaptureName);
|
|
172
|
+
if (result != null) return result;
|
|
173
|
+
if (responderEvent.isPropagationStopped() === !0) return;
|
|
174
|
+
}
|
|
175
|
+
if (bubbles) for (var i1 = 0; i1 < idPath.length; i1++) {
|
|
176
|
+
var id1 = idPath[i1],
|
|
177
|
+
node1 = nodePath[i1],
|
|
178
|
+
result1 = check(id1, node1, shouldSetCallbackBubbleName);
|
|
179
|
+
if (result1 != null) return result1;
|
|
180
|
+
if (responderEvent.isPropagationStopped() === !0) return;
|
|
181
|
+
} else {
|
|
182
|
+
var id2 = idPath[0],
|
|
183
|
+
node2 = nodePath[0],
|
|
184
|
+
target = domEvent.target;
|
|
185
|
+
if (target === node2) return check(id2, node2, shouldSetCallbackBubbleName);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function attemptTransfer(responderEvent, wantsResponder) {
|
|
190
|
+
var {
|
|
191
|
+
id: currentId,
|
|
192
|
+
node: currentNode
|
|
193
|
+
} = currentResponder,
|
|
194
|
+
{
|
|
195
|
+
id,
|
|
196
|
+
node
|
|
197
|
+
} = wantsResponder,
|
|
198
|
+
{
|
|
199
|
+
onResponderGrant,
|
|
200
|
+
onResponderReject
|
|
201
|
+
} = getResponderConfig(id);
|
|
202
|
+
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 {
|
|
203
|
+
var {
|
|
204
|
+
onResponderTerminate,
|
|
205
|
+
onResponderTerminationRequest
|
|
206
|
+
} = getResponderConfig(currentId),
|
|
207
|
+
allowTransfer = !0;
|
|
208
|
+
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));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
var documentEventsCapturePhase = ["blur", "scroll"],
|
|
212
|
+
documentEventsBubblePhase = [
|
|
213
|
+
// mouse
|
|
214
|
+
"mousedown", "mousemove", "mouseup", "dragstart",
|
|
215
|
+
// touch
|
|
216
|
+
"touchstart", "touchmove", "touchend", "touchcancel",
|
|
217
|
+
// other
|
|
218
|
+
"contextmenu", "select", "selectionchange"],
|
|
219
|
+
isGuiResponderActive = /* @__PURE__ */Symbol();
|
|
220
|
+
function attachListeners() {
|
|
221
|
+
import_utils.canUseDOM && !window[isGuiResponderActive] && (window.addEventListener("blur", eventListener), documentEventsBubblePhase.forEach(function (eventType) {
|
|
222
|
+
document.addEventListener(eventType, eventListener);
|
|
223
|
+
}), documentEventsCapturePhase.forEach(function (eventType) {
|
|
224
|
+
document.addEventListener(eventType, eventListener, !0);
|
|
225
|
+
}), window[isGuiResponderActive] = !0);
|
|
226
|
+
}
|
|
227
|
+
function addNode(id, node, config) {
|
|
228
|
+
(0, import_utils2.setResponderId)(node, id), responderListenersMap.set(id, config);
|
|
229
|
+
}
|
|
230
|
+
function removeNode(id) {
|
|
231
|
+
currentResponder.id === id && terminateResponder(), responderListenersMap.has(id) && responderListenersMap.delete(id);
|
|
232
|
+
}
|
|
233
|
+
function terminateResponder() {
|
|
234
|
+
var {
|
|
235
|
+
id,
|
|
236
|
+
node
|
|
237
|
+
} = currentResponder;
|
|
238
|
+
if (id != null && node != null) {
|
|
239
|
+
var {
|
|
240
|
+
onResponderTerminate
|
|
241
|
+
} = getResponderConfig(id);
|
|
242
|
+
if (onResponderTerminate != null) {
|
|
243
|
+
var event = (0, import_createResponderEvent.createResponderEvent)({}, responderTouchHistoryStore);
|
|
244
|
+
event.currentTarget = node, onResponderTerminate(event);
|
|
245
|
+
}
|
|
246
|
+
changeCurrentResponder(emptyResponder);
|
|
247
|
+
}
|
|
248
|
+
isEmulatingMouseEvents = !1, trackedTouchCount = 0;
|
|
249
|
+
}
|
|
250
|
+
function getResponderNode() {
|
|
251
|
+
return currentResponder.node;
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=ResponderSystem.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","ResponderSystem_exports","__export","addNode","attachListeners","getResponderNode","removeNode","terminateResponder","module","exports","import_createResponderEvent","require","import_ResponderTouchHistoryStore","import_types","import_utils","import_utils2","emptyObject","startRegistration","bubbles","moveRegistration","scrollRegistration","shouldSetResponderEvents","touchstart","mousedown","touchmove","mousemove","scroll","emptyResponder","id","idPath","node","responderListenersMap","Map","isEmulatingMouseEvents","trackedTouchCount","currentResponder","responderTouchHistoryStore","ResponderTouchHistoryStore","changeCurrentResponder","responder","getResponderConfig","config","get","eventListener","domEvent","eventType","type","eventTarget","target","isStartEvent","isStartish","isPrimaryPointerDown","isMoveEvent","isMoveish","isEndEvent","isEndish","isScrollEvent","isScroll","isSelectionChangeEvent","isSelectionChange","responderEvent","createResponderEvent","touches","length","recordTouchTrack","nativeEvent","eventPaths","getResponderPaths","wasNegotiated","wantsResponder","currentResponderIdPath","eventIdPath","lowestCommonAncestor","getLowestCommonAncestor","indexOfLowestCommonAncestor","indexOf","index","slice","nodePath","findWantsResponder","attemptTransfer","onResponderStart","onResponderMove","onResponderEnd","onResponderRelease","onResponderTerminate","onResponderTerminationRequest","cancelable","currentTarget","dispatchConfig","registrationName","isTerminateEvent","isCancelish","window","contains","relatedTarget","hasValidSelection","isReleaseEvent","hasTargetTouches","shouldTerminate","shouldSetCallbacks","shouldSetCallbackCaptureName","shouldSetCallbackBubbleName","check","id3","node3","callbackName","shouldSetCallback","prunedIdPath","i","result","isPropagationStopped","i1","id1","node1","result1","id2","node2","currentId","currentNode","onResponderGrant","onResponderReject","allowTransfer","documentEventsCapturePhase","documentEventsBubblePhase","isGuiResponderActive","Symbol","canUseDOM","addEventListener","forEach","document","setResponderId","set","has","delete","event"],"sources":["../../src/ResponderSystem.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,OAAA,EAAAA,CAAA,KAAAA,OAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAOAC,MAAA,CAAAC,OAAA,GAAAb,YAAA,CAAAK,uBAAqC;AA8DrC,IAAAS,2BAIM,GAAAC,OAAA,mCAAoB;EAAAC,iCAAA,GAAAD,OAAA;EAAAE,YAAA,GAAAF,OAAA;EAAAG,YAAA,GAAAH,OAAA;EAAAI,aAAA,GAAAJ,OAAA;EAAAK,WAAA;EAAAC,iBAAA,IACxB,oCACA,6BACA;IAEIC,OAAA;EACJ;EACAC,gBAAA,IACA,iCAAgB,EAClB,0BAC2B,EACzB;IACAD,OAAA;EACA,EACF;EACME,kBAAA,IACJ,mCAAY,EACZ,4BAAW,EACX;IACAF,OAAA,EAAW;EACX,EACF;EAEMG,wBAAuB;IAG7BC,UAAI,EAAAL,iBAAyB;IAG3BM,SAAI,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;EACtC,OAAO8B,gBAAA,CAAiBL,IAAA;AAC1B","ignoreList":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
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);
|
|
21
|
+
var ResponderTouchHistoryStore_exports = {};
|
|
22
|
+
__export(ResponderTouchHistoryStore_exports, {
|
|
23
|
+
ResponderTouchHistoryStore: () => ResponderTouchHistoryStore
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ResponderTouchHistoryStore_exports);
|
|
26
|
+
var import_types = require("./types.cjs");
|
|
27
|
+
class ResponderTouchHistoryStore {
|
|
28
|
+
_touchHistory = {
|
|
29
|
+
touchBank: [],
|
|
30
|
+
//Array<TouchRecord>
|
|
31
|
+
numberActiveTouches: 0,
|
|
32
|
+
// If there is only one active touch, we remember its location. This prevents
|
|
33
|
+
// us having to loop through all of the touches all the time in the most
|
|
34
|
+
// common case.
|
|
35
|
+
indexOfSingleActiveTouch: -1,
|
|
36
|
+
mostRecentTimeStamp: 0
|
|
37
|
+
};
|
|
38
|
+
recordTouchTrack(topLevelType, nativeEvent) {
|
|
39
|
+
const touchHistory = this._touchHistory;
|
|
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
|
+
}
|
|
48
|
+
process.env.NODE_ENV === "development" && (touchBank[touchHistory.indexOfSingleActiveTouch]?.touchActive || console.error("Cannot find single active touch."));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
get touchHistory() {
|
|
52
|
+
return this._touchHistory;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const MAX_TOUCH_BANK = 20;
|
|
56
|
+
function timestampForTouch(touch) {
|
|
57
|
+
return touch.timeStamp || touch.timestamp;
|
|
58
|
+
}
|
|
59
|
+
function createTouchRecord(touch) {
|
|
60
|
+
return {
|
|
61
|
+
touchActive: !0,
|
|
62
|
+
startPageX: touch.pageX,
|
|
63
|
+
startPageY: touch.pageY,
|
|
64
|
+
startTimeStamp: timestampForTouch(touch),
|
|
65
|
+
currentPageX: touch.pageX,
|
|
66
|
+
currentPageY: touch.pageY,
|
|
67
|
+
currentTimeStamp: timestampForTouch(touch),
|
|
68
|
+
previousPageX: touch.pageX,
|
|
69
|
+
previousPageY: touch.pageY,
|
|
70
|
+
previousTimeStamp: timestampForTouch(touch)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function resetTouchRecord(touchRecord, touch) {
|
|
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);
|
|
75
|
+
}
|
|
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;
|
|
80
|
+
}
|
|
81
|
+
function recordTouchStart(touch, touchHistory) {
|
|
82
|
+
const identifier = getTouchIdentifier(touch),
|
|
83
|
+
touchRecord = touchHistory.touchBank[identifier];
|
|
84
|
+
touchRecord ? resetTouchRecord(touchRecord, touch) : touchHistory.touchBank[identifier] = createTouchRecord(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
85
|
+
}
|
|
86
|
+
function recordTouchMove(touch, touchHistory) {
|
|
87
|
+
const touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
|
|
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)}`);
|
|
91
|
+
}
|
|
92
|
+
function recordTouchEnd(touch, touchHistory) {
|
|
93
|
+
const touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
|
|
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)}`);
|
|
97
|
+
}
|
|
98
|
+
function printTouch(touch) {
|
|
99
|
+
return JSON.stringify({
|
|
100
|
+
identifier: touch.identifier,
|
|
101
|
+
pageX: touch.pageX,
|
|
102
|
+
pageY: touch.pageY,
|
|
103
|
+
timestamp: timestampForTouch(touch)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function printTouchBank(touchHistory) {
|
|
107
|
+
const {
|
|
108
|
+
touchBank
|
|
109
|
+
} = touchHistory;
|
|
110
|
+
let printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
|
111
|
+
return touchBank.length > MAX_TOUCH_BANK && (printed += ` (original size: ${touchBank.length})`), printed;
|
|
112
|
+
}
|