@tamagui/react-native-use-responder-events 2.7.7 → 3.0.0-beta.643.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/ResponderSystem.cjs +307 -344
  2. package/dist/cjs/ResponderSystem.native.cjs +357 -0
  3. package/dist/cjs/ResponderSystem.native.js +307 -343
  4. package/dist/cjs/ResponderSystem.native.js.map +1 -1
  5. package/dist/cjs/ResponderTouchHistoryStore.cjs +136 -149
  6. package/dist/cjs/ResponderTouchHistoryStore.native.cjs +217 -0
  7. package/dist/cjs/ResponderTouchHistoryStore.native.js +176 -189
  8. package/dist/cjs/ResponderTouchHistoryStore.native.js.map +1 -1
  9. package/dist/cjs/createResponderEvent.cjs +128 -132
  10. package/dist/cjs/createResponderEvent.native.cjs +147 -0
  11. package/dist/cjs/createResponderEvent.native.js +129 -132
  12. package/dist/cjs/createResponderEvent.native.js.map +1 -1
  13. package/dist/cjs/index.cjs +10 -11
  14. package/dist/cjs/index.native.cjs +21 -0
  15. package/dist/cjs/index.native.js +10 -10
  16. package/dist/cjs/index.native.js.map +1 -1
  17. package/dist/cjs/types.cjs +40 -41
  18. package/dist/cjs/types.native.cjs +79 -0
  19. package/dist/cjs/types.native.js +40 -40
  20. package/dist/cjs/types.native.js.map +1 -1
  21. package/dist/cjs/useResponderEvents.cjs +60 -85
  22. package/dist/cjs/useResponderEvents.native.cjs +87 -0
  23. package/dist/cjs/useResponderEvents.native.js +62 -86
  24. package/dist/cjs/useResponderEvents.native.js.map +1 -1
  25. package/dist/cjs/utils.cjs +123 -135
  26. package/dist/cjs/utils.native.cjs +160 -0
  27. package/dist/cjs/utils.native.js +124 -135
  28. package/dist/cjs/utils.native.js.map +1 -1
  29. package/dist/esm/ResponderSystem.mjs +291 -326
  30. package/dist/esm/ResponderSystem.mjs.map +1 -1
  31. package/dist/esm/ResponderSystem.native.js +291 -326
  32. package/dist/esm/ResponderSystem.native.js.map +1 -1
  33. package/dist/esm/ResponderTouchHistoryStore.mjs +123 -131
  34. package/dist/esm/ResponderTouchHistoryStore.mjs.map +1 -1
  35. package/dist/esm/ResponderTouchHistoryStore.native.js +163 -172
  36. package/dist/esm/ResponderTouchHistoryStore.native.js.map +1 -1
  37. package/dist/esm/createResponderEvent.mjs +115 -114
  38. package/dist/esm/createResponderEvent.mjs.map +1 -1
  39. package/dist/esm/createResponderEvent.native.js +116 -115
  40. package/dist/esm/createResponderEvent.native.js.map +1 -1
  41. package/dist/esm/index.js +1 -2
  42. package/dist/esm/index.mjs +1 -2
  43. package/dist/esm/index.native.js +1 -2
  44. package/dist/esm/types.mjs +7 -6
  45. package/dist/esm/types.mjs.map +1 -1
  46. package/dist/esm/types.native.js +7 -6
  47. package/dist/esm/types.native.js.map +1 -1
  48. package/dist/esm/useResponderEvents.mjs +45 -61
  49. package/dist/esm/useResponderEvents.mjs.map +1 -1
  50. package/dist/esm/useResponderEvents.native.js +47 -63
  51. package/dist/esm/useResponderEvents.native.js.map +1 -1
  52. package/dist/esm/utils.mjs +101 -111
  53. package/dist/esm/utils.mjs.map +1 -1
  54. package/dist/esm/utils.native.js +102 -112
  55. package/dist/esm/utils.native.js.map +1 -1
  56. package/package.json +2 -2
  57. package/types/ResponderTouchHistoryStore.d.ts.map +1 -1
  58. package/types/utils.d.ts.map +1 -1
  59. package/dist/esm/index.js.map +0 -1
  60. package/dist/esm/index.mjs.map +0 -1
  61. package/dist/esm/index.native.js.map +0 -1
@@ -1,204 +1,195 @@
1
1
  import { isEndish, isMoveish, isStartish } from "./types.native.js";
2
+
2
3
  function _class_call_check(instance, Constructor) {
3
- if (!(instance instanceof Constructor)) {
4
- throw new TypeError("Cannot call a class as a function");
5
- }
4
+ if (!(instance instanceof Constructor)) {
5
+ throw new TypeError("Cannot call a class as a function");
6
+ }
6
7
  }
7
8
  function _defineProperties(target, props) {
8
- for (var i = 0; i < props.length; i++) {
9
- var descriptor = props[i];
10
- descriptor.enumerable = descriptor.enumerable || false;
11
- descriptor.configurable = true;
12
- if ("value" in descriptor) descriptor.writable = true;
13
- Object.defineProperty(target, descriptor.key, descriptor);
14
- }
9
+ for (var i = 0; i < props.length; i++) {
10
+ var descriptor = props[i];
11
+ descriptor.enumerable = descriptor.enumerable || false;
12
+ descriptor.configurable = true;
13
+ if ("value" in descriptor) descriptor.writable = true;
14
+ Object.defineProperty(target, descriptor.key, descriptor);
15
+ }
15
16
  }
16
17
  function _create_class(Constructor, protoProps, staticProps) {
17
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
18
- if (staticProps) _defineProperties(Constructor, staticProps);
19
- return Constructor;
18
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
19
+ if (staticProps) _defineProperties(Constructor, staticProps);
20
+ return Constructor;
20
21
  }
21
22
  function _define_property(obj, key, value) {
22
- if (key in obj) {
23
- Object.defineProperty(obj, key, {
24
- value,
25
- enumerable: true,
26
- configurable: true,
27
- writable: true
28
- });
29
- } else {
30
- obj[key] = value;
31
- }
32
- return obj;
23
+ if (key in obj) {
24
+ Object.defineProperty(obj, key, {
25
+ value,
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true
29
+ });
30
+ } else {
31
+ obj[key] = value;
32
+ }
33
+ return obj;
33
34
  }
34
- var ResponderTouchHistoryStore = /* @__PURE__ */function () {
35
- "use strict";
36
-
37
- function ResponderTouchHistoryStore2() {
38
- _class_call_check(this, ResponderTouchHistoryStore2);
39
- _define_property(this, "_touchHistory", {
40
- touchBank: [],
41
- //Array<TouchRecord>
42
- numberActiveTouches: 0,
43
- // If there is only one active touch, we remember its location. This prevents
44
- // us having to loop through all of the touches all the time in the most
45
- // common case.
46
- indexOfSingleActiveTouch: -1,
47
- mostRecentTimeStamp: 0
48
- });
49
- }
50
- _create_class(ResponderTouchHistoryStore2, [{
51
- key: "recordTouchTrack",
52
- value: function recordTouchTrack(topLevelType, nativeEvent) {
53
- var touchHistory = this._touchHistory;
54
- if (isMoveish(topLevelType)) {
55
- nativeEvent.changedTouches.forEach(function (touch) {
56
- return recordTouchMove(touch, touchHistory);
57
- });
58
- } else if (isStartish(topLevelType)) {
59
- nativeEvent.changedTouches.forEach(function (touch) {
60
- return recordTouchStart(touch, touchHistory);
61
- });
62
- touchHistory.numberActiveTouches = nativeEvent.touches.length;
63
- if (touchHistory.numberActiveTouches === 1) {
64
- touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
65
- }
66
- } else if (isEndish(topLevelType)) {
67
- nativeEvent.changedTouches.forEach(function (touch) {
68
- return recordTouchEnd(touch, touchHistory);
69
- });
70
- touchHistory.numberActiveTouches = nativeEvent.touches.length;
71
- if (touchHistory.numberActiveTouches === 1) {
72
- var {
73
- touchBank
74
- } = touchHistory;
75
- for (var i = 0; i < touchBank.length; i++) {
76
- var touchTrackToCheck = touchBank[i];
77
- if (touchTrackToCheck === null || touchTrackToCheck === void 0 ? void 0 : touchTrackToCheck.touchActive) {
78
- touchHistory.indexOfSingleActiveTouch = i;
79
- break;
80
- }
81
- }
82
- if (process.env.NODE_ENV === "development") {
83
- var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
84
- if (!(activeRecord === null || activeRecord === void 0 ? void 0 : activeRecord.touchActive)) {
85
- console.error("Cannot find single active touch.");
86
- }
87
- }
88
- }
89
- }
90
- }
91
- }, {
92
- key: "touchHistory",
93
- get: function get() {
94
- return this._touchHistory;
95
- }
96
- }]);
97
- return ResponderTouchHistoryStore2;
98
- }();
35
+ var ResponderTouchHistoryStore = /* @__PURE__ */ (function() {
36
+ "use strict";
37
+ function ResponderTouchHistoryStore2() {
38
+ _class_call_check(this, ResponderTouchHistoryStore2);
39
+ _define_property(this, "_touchHistory", {
40
+ touchBank: [],
41
+ numberActiveTouches: 0,
42
+ indexOfSingleActiveTouch: -1,
43
+ mostRecentTimeStamp: 0
44
+ });
45
+ }
46
+ _create_class(ResponderTouchHistoryStore2, [{
47
+ key: "recordTouchTrack",
48
+ value: function recordTouchTrack(topLevelType, nativeEvent) {
49
+ var touchHistory = this._touchHistory;
50
+ if (isMoveish(topLevelType)) {
51
+ nativeEvent.changedTouches.forEach(function(touch) {
52
+ return recordTouchMove(touch, touchHistory);
53
+ });
54
+ } else if (isStartish(topLevelType)) {
55
+ nativeEvent.changedTouches.forEach(function(touch) {
56
+ return recordTouchStart(touch, touchHistory);
57
+ });
58
+ touchHistory.numberActiveTouches = nativeEvent.touches.length;
59
+ if (touchHistory.numberActiveTouches === 1) {
60
+ touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
61
+ }
62
+ } else if (isEndish(topLevelType)) {
63
+ nativeEvent.changedTouches.forEach(function(touch) {
64
+ return recordTouchEnd(touch, touchHistory);
65
+ });
66
+ touchHistory.numberActiveTouches = nativeEvent.touches.length;
67
+ if (touchHistory.numberActiveTouches === 1) {
68
+ var { touchBank } = touchHistory;
69
+ for (var i = 0; i < touchBank.length; i++) {
70
+ var touchTrackToCheck = touchBank[i];
71
+ if (touchTrackToCheck === null || touchTrackToCheck === void 0 ? void 0 : touchTrackToCheck.touchActive) {
72
+ touchHistory.indexOfSingleActiveTouch = i;
73
+ break;
74
+ }
75
+ }
76
+ if (process.env.NODE_ENV === "development") {
77
+ var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
78
+ if (!(activeRecord === null || activeRecord === void 0 ? void 0 : activeRecord.touchActive)) {
79
+ console.error("Cannot find single active touch.");
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }, {
86
+ key: "touchHistory",
87
+ get: function get() {
88
+ return this._touchHistory;
89
+ }
90
+ }]);
91
+ return ResponderTouchHistoryStore2;
92
+ })();
99
93
  var MAX_TOUCH_BANK = 20;
100
94
  function timestampForTouch(touch) {
101
- return touch["timeStamp"] || touch.timestamp;
95
+ return touch["timeStamp"] || touch.timestamp;
102
96
  }
103
97
  function createTouchRecord(touch) {
104
- return {
105
- touchActive: true,
106
- startPageX: touch.pageX,
107
- startPageY: touch.pageY,
108
- startTimeStamp: timestampForTouch(touch),
109
- currentPageX: touch.pageX,
110
- currentPageY: touch.pageY,
111
- currentTimeStamp: timestampForTouch(touch),
112
- previousPageX: touch.pageX,
113
- previousPageY: touch.pageY,
114
- previousTimeStamp: timestampForTouch(touch)
115
- };
98
+ return {
99
+ touchActive: true,
100
+ startPageX: touch.pageX,
101
+ startPageY: touch.pageY,
102
+ startTimeStamp: timestampForTouch(touch),
103
+ currentPageX: touch.pageX,
104
+ currentPageY: touch.pageY,
105
+ currentTimeStamp: timestampForTouch(touch),
106
+ previousPageX: touch.pageX,
107
+ previousPageY: touch.pageY,
108
+ previousTimeStamp: timestampForTouch(touch)
109
+ };
116
110
  }
117
111
  function resetTouchRecord(touchRecord, touch) {
118
- touchRecord.touchActive = true;
119
- touchRecord.startPageX = touch.pageX;
120
- touchRecord.startPageY = touch.pageY;
121
- touchRecord.startTimeStamp = timestampForTouch(touch);
122
- touchRecord.currentPageX = touch.pageX;
123
- touchRecord.currentPageY = touch.pageY;
124
- touchRecord.currentTimeStamp = timestampForTouch(touch);
125
- touchRecord.previousPageX = touch.pageX;
126
- touchRecord.previousPageY = touch.pageY;
127
- touchRecord.previousTimeStamp = timestampForTouch(touch);
112
+ touchRecord.touchActive = true;
113
+ touchRecord.startPageX = touch.pageX;
114
+ touchRecord.startPageY = touch.pageY;
115
+ touchRecord.startTimeStamp = timestampForTouch(touch);
116
+ touchRecord.currentPageX = touch.pageX;
117
+ touchRecord.currentPageY = touch.pageY;
118
+ touchRecord.currentTimeStamp = timestampForTouch(touch);
119
+ touchRecord.previousPageX = touch.pageX;
120
+ touchRecord.previousPageY = touch.pageY;
121
+ touchRecord.previousTimeStamp = timestampForTouch(touch);
128
122
  }
129
123
  function getTouchIdentifier(param) {
130
- var {
131
- identifier
132
- } = param;
133
- if (identifier == null) {
134
- console.error("Touch object is missing identifier.");
135
- }
136
- if (process.env.NODE_ENV === "development") {
137
- if (identifier > MAX_TOUCH_BANK) {
138
- 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);
139
- }
140
- }
141
- return identifier;
124
+ var { identifier } = param;
125
+ if (identifier == null) {
126
+ console.error("Touch object is missing identifier.");
127
+ }
128
+ if (process.env.NODE_ENV === "development") {
129
+ if (identifier > MAX_TOUCH_BANK) {
130
+ 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);
131
+ }
132
+ }
133
+ return identifier;
142
134
  }
143
135
  function recordTouchStart(touch, touchHistory) {
144
- var identifier = getTouchIdentifier(touch);
145
- var touchRecord = touchHistory.touchBank[identifier];
146
- if (touchRecord) {
147
- resetTouchRecord(touchRecord, touch);
148
- } else {
149
- touchHistory.touchBank[identifier] = createTouchRecord(touch);
150
- }
151
- touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
136
+ var identifier = getTouchIdentifier(touch);
137
+ var touchRecord = touchHistory.touchBank[identifier];
138
+ if (touchRecord) {
139
+ resetTouchRecord(touchRecord, touch);
140
+ } else {
141
+ touchHistory.touchBank[identifier] = createTouchRecord(touch);
142
+ }
143
+ touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
152
144
  }
153
145
  function recordTouchMove(touch, touchHistory) {
154
- var touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
155
- if (touchRecord) {
156
- touchRecord.touchActive = true;
157
- touchRecord.previousPageX = touchRecord.currentPageX;
158
- touchRecord.previousPageY = touchRecord.currentPageY;
159
- touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
160
- touchRecord.currentPageX = touch.pageX;
161
- touchRecord.currentPageY = touch.pageY;
162
- touchRecord.currentTimeStamp = timestampForTouch(touch);
163
- touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
164
- } else {
165
- console.warn("Cannot record touch move without a touch start.\n", `Touch Move: ${printTouch(touch)}
146
+ var touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
147
+ if (touchRecord) {
148
+ touchRecord.touchActive = true;
149
+ touchRecord.previousPageX = touchRecord.currentPageX;
150
+ touchRecord.previousPageY = touchRecord.currentPageY;
151
+ touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
152
+ touchRecord.currentPageX = touch.pageX;
153
+ touchRecord.currentPageY = touch.pageY;
154
+ touchRecord.currentTimeStamp = timestampForTouch(touch);
155
+ touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
156
+ } else {
157
+ console.warn("Cannot record touch move without a touch start.\n", `Touch Move: ${printTouch(touch)}
166
158
  `, `Touch Bank: ${printTouchBank(touchHistory)}`);
167
- }
159
+ }
168
160
  }
169
161
  function recordTouchEnd(touch, touchHistory) {
170
- var touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
171
- if (touchRecord) {
172
- touchRecord.touchActive = false;
173
- touchRecord.previousPageX = touchRecord.currentPageX;
174
- touchRecord.previousPageY = touchRecord.currentPageY;
175
- touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
176
- touchRecord.currentPageX = touch.pageX;
177
- touchRecord.currentPageY = touch.pageY;
178
- touchRecord.currentTimeStamp = timestampForTouch(touch);
179
- touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
180
- } else {
181
- console.warn("Cannot record touch end without a touch start.\n", `Touch End: ${printTouch(touch)}
162
+ var touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
163
+ if (touchRecord) {
164
+ touchRecord.touchActive = false;
165
+ touchRecord.previousPageX = touchRecord.currentPageX;
166
+ touchRecord.previousPageY = touchRecord.currentPageY;
167
+ touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
168
+ touchRecord.currentPageX = touch.pageX;
169
+ touchRecord.currentPageY = touch.pageY;
170
+ touchRecord.currentTimeStamp = timestampForTouch(touch);
171
+ touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
172
+ } else {
173
+ console.warn("Cannot record touch end without a touch start.\n", `Touch End: ${printTouch(touch)}
182
174
  `, `Touch Bank: ${printTouchBank(touchHistory)}`);
183
- }
175
+ }
184
176
  }
185
177
  function printTouch(touch) {
186
- return JSON.stringify({
187
- identifier: touch.identifier,
188
- pageX: touch.pageX,
189
- pageY: touch.pageY,
190
- timestamp: timestampForTouch(touch)
191
- });
178
+ return JSON.stringify({
179
+ identifier: touch.identifier,
180
+ pageX: touch.pageX,
181
+ pageY: touch.pageY,
182
+ timestamp: timestampForTouch(touch)
183
+ });
192
184
  }
193
185
  function printTouchBank(touchHistory) {
194
- var {
195
- touchBank
196
- } = touchHistory;
197
- var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
198
- if (touchBank.length > MAX_TOUCH_BANK) {
199
- printed += ` (original size: ${touchBank.length})`;
200
- }
201
- return printed;
186
+ var { touchBank } = touchHistory;
187
+ var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
188
+ if (touchBank.length > MAX_TOUCH_BANK) {
189
+ printed += ` (original size: ${touchBank.length})`;
190
+ }
191
+ return printed;
202
192
  }
193
+
203
194
  export { ResponderTouchHistoryStore };
204
195
  //# sourceMappingURL=ResponderTouchHistoryStore.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isEndish","isMoveish","isStartish","_class_call_check","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_create_class","protoProps","staticProps","prototype","_define_property","obj","value","ResponderTouchHistoryStore","ResponderTouchHistoryStore2","touchBank","numberActiveTouches","indexOfSingleActiveTouch","mostRecentTimeStamp","recordTouchTrack","topLevelType","nativeEvent","touchHistory","_touchHistory","changedTouches","forEach","touch","recordTouchMove","recordTouchStart","touches","identifier","recordTouchEnd","touchTrackToCheck","touchActive","process","env","NODE_ENV","activeRecord","console","error","get","MAX_TOUCH_BANK","timestampForTouch","timestamp","createTouchRecord","startPageX","pageX","startPageY","pageY","startTimeStamp","currentPageX","currentPageY","currentTimeStamp","previousPageX","previousPageY","previousTimeStamp","resetTouchRecord","touchRecord","getTouchIdentifier","param"],"sources":["../../src/ResponderTouch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AA,CAAAH,aAAA,GAAAG,WAAA,CAAAN,YAAA;IACAM,WAAO,CAAAF,iBAAA,GAAAE,WAAA,CAAAL,gBAAA;IACTK,WAAA,CAAAP,YAAA,GAAAxB,KAAA,CAAAoB,KAAA","ignoreList":[]}
1
+ {"version":3,"file":"ResponderTouchHistoryStore.native.js","names":[],"sources":["esm/ResponderTouchHistoryStore.native.js"],"sourcesContent":["import { isEndish, isMoveish, isStartish } from \"./types\";\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\nfunction _create_class(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\nfunction _define_property(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nvar ResponderTouchHistoryStore = /* @__PURE__ */ (function() {\n \"use strict\";\n function ResponderTouchHistoryStore2() {\n _class_call_check(this, ResponderTouchHistoryStore2);\n _define_property(this, \"_touchHistory\", {\n touchBank: [],\n //Array<TouchRecord>\n numberActiveTouches: 0,\n // If there is only one active touch, we remember its location. This prevents\n // us having to loop through all of the touches all the time in the most\n // common case.\n indexOfSingleActiveTouch: -1,\n mostRecentTimeStamp: 0\n });\n }\n _create_class(ResponderTouchHistoryStore2, [\n {\n key: \"recordTouchTrack\",\n value: function recordTouchTrack(topLevelType, nativeEvent) {\n var touchHistory = this._touchHistory;\n if (isMoveish(topLevelType)) {\n nativeEvent.changedTouches.forEach(function(touch) {\n return recordTouchMove(touch, touchHistory);\n });\n } else if (isStartish(topLevelType)) {\n nativeEvent.changedTouches.forEach(function(touch) {\n return recordTouchStart(touch, touchHistory);\n });\n touchHistory.numberActiveTouches = nativeEvent.touches.length;\n if (touchHistory.numberActiveTouches === 1) {\n touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;\n }\n } else if (isEndish(topLevelType)) {\n nativeEvent.changedTouches.forEach(function(touch) {\n return recordTouchEnd(touch, touchHistory);\n });\n touchHistory.numberActiveTouches = nativeEvent.touches.length;\n if (touchHistory.numberActiveTouches === 1) {\n var { touchBank } = touchHistory;\n for (var i = 0; i < touchBank.length; i++) {\n var touchTrackToCheck = touchBank[i];\n if (touchTrackToCheck === null || touchTrackToCheck === void 0 ? void 0 : touchTrackToCheck.touchActive) {\n touchHistory.indexOfSingleActiveTouch = i;\n break;\n }\n }\n if (process.env.NODE_ENV === \"development\") {\n var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];\n if (!(activeRecord === null || activeRecord === void 0 ? void 0 : activeRecord.touchActive)) {\n console.error(\"Cannot find single active touch.\");\n }\n }\n }\n }\n }\n },\n {\n key: \"touchHistory\",\n get: function get() {\n return this._touchHistory;\n }\n }\n ]);\n return ResponderTouchHistoryStore2;\n})();\nvar MAX_TOUCH_BANK = 20;\nfunction timestampForTouch(touch) {\n return touch[\"timeStamp\"] || touch.timestamp;\n}\nfunction createTouchRecord(touch) {\n return {\n touchActive: true,\n startPageX: touch.pageX,\n startPageY: touch.pageY,\n startTimeStamp: timestampForTouch(touch),\n currentPageX: touch.pageX,\n currentPageY: touch.pageY,\n currentTimeStamp: timestampForTouch(touch),\n previousPageX: touch.pageX,\n previousPageY: touch.pageY,\n previousTimeStamp: timestampForTouch(touch)\n };\n}\nfunction resetTouchRecord(touchRecord, touch) {\n touchRecord.touchActive = true;\n touchRecord.startPageX = touch.pageX;\n touchRecord.startPageY = touch.pageY;\n touchRecord.startTimeStamp = timestampForTouch(touch);\n touchRecord.currentPageX = touch.pageX;\n touchRecord.currentPageY = touch.pageY;\n touchRecord.currentTimeStamp = timestampForTouch(touch);\n touchRecord.previousPageX = touch.pageX;\n touchRecord.previousPageY = touch.pageY;\n touchRecord.previousTimeStamp = timestampForTouch(touch);\n}\nfunction getTouchIdentifier(param) {\n var { identifier } = param;\n if (identifier == null) {\n console.error(\"Touch object is missing identifier.\");\n }\n if (process.env.NODE_ENV === \"development\") {\n if (identifier > MAX_TOUCH_BANK) {\n 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);\n }\n }\n return identifier;\n}\nfunction recordTouchStart(touch, touchHistory) {\n var identifier = getTouchIdentifier(touch);\n var touchRecord = touchHistory.touchBank[identifier];\n if (touchRecord) {\n resetTouchRecord(touchRecord, touch);\n } else {\n touchHistory.touchBank[identifier] = createTouchRecord(touch);\n }\n touchHistory.mostRecentTimeStamp = timestampForTouch(touch);\n}\nfunction recordTouchMove(touch, touchHistory) {\n var touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];\n if (touchRecord) {\n touchRecord.touchActive = true;\n touchRecord.previousPageX = touchRecord.currentPageX;\n touchRecord.previousPageY = touchRecord.currentPageY;\n touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;\n touchRecord.currentPageX = touch.pageX;\n touchRecord.currentPageY = touch.pageY;\n touchRecord.currentTimeStamp = timestampForTouch(touch);\n touchHistory.mostRecentTimeStamp = timestampForTouch(touch);\n } else {\n console.warn(\"Cannot record touch move without a touch start.\\n\", `Touch Move: ${printTouch(touch)}\n`, `Touch Bank: ${printTouchBank(touchHistory)}`);\n }\n}\nfunction recordTouchEnd(touch, touchHistory) {\n var touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];\n if (touchRecord) {\n touchRecord.touchActive = false;\n touchRecord.previousPageX = touchRecord.currentPageX;\n touchRecord.previousPageY = touchRecord.currentPageY;\n touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;\n touchRecord.currentPageX = touch.pageX;\n touchRecord.currentPageY = touch.pageY;\n touchRecord.currentTimeStamp = timestampForTouch(touch);\n touchHistory.mostRecentTimeStamp = timestampForTouch(touch);\n } else {\n console.warn(\"Cannot record touch end without a touch start.\\n\", `Touch End: ${printTouch(touch)}\n`, `Touch Bank: ${printTouchBank(touchHistory)}`);\n }\n}\nfunction printTouch(touch) {\n return JSON.stringify({\n identifier: touch.identifier,\n pageX: touch.pageX,\n pageY: touch.pageY,\n timestamp: timestampForTouch(touch)\n });\n}\nfunction printTouchBank(touchHistory) {\n var { touchBank } = touchHistory;\n var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));\n if (touchBank.length > MAX_TOUCH_BANK) {\n printed += ` (original size: ${touchBank.length})`;\n }\n return printed;\n}\nexport {\n ResponderTouchHistoryStore\n};\n//# sourceMappingURL=ResponderTouchHistoryStore.js.map\n"],"mappings":";;;AACA,SAAS,kBAAkB,UAAU,aAAa;CAChD,IAAI,EAAE,oBAAoB,cAAc;EACtC,MAAM,IAAI,UAAU,mCAAmC;CACzD;AACF;AACA,SAAS,kBAAkB,QAAQ,OAAO;CACxC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,IAAI,aAAa,MAAM;EACvB,WAAW,aAAa,WAAW,cAAc;EACjD,WAAW,eAAe;EAC1B,IAAI,WAAW,YAAY,WAAW,WAAW;EACjD,OAAO,eAAe,QAAQ,WAAW,KAAK,UAAU;CAC1D;AACF;AACA,SAAS,cAAc,aAAa,YAAY,aAAa;CAC3D,IAAI,YAAY,kBAAkB,YAAY,WAAW,UAAU;CACnE,IAAI,aAAa,kBAAkB,aAAa,WAAW;CAC3D,OAAO;AACT;AACA,SAAS,iBAAiB,KAAK,KAAK,OAAO;CACzC,IAAI,OAAO,KAAK;EACd,OAAO,eAAe,KAAK,KAAK;GAC9B;GACA,YAAY;GACZ,cAAc;GACd,UAAU;EACZ,CAAC;CACH,OAAO;EACL,IAAI,OAAO;CACb;CACA,OAAO;AACT;AACA,I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
2
+
2
3
  const emptyFunction = () => {};
3
4
  const emptyObject = {};
4
5
  const emptyArray = [];
5
6
  function normalizeIdentifier(identifier) {
6
- return identifier > 20 ? identifier % 20 : identifier;
7
+ return identifier > 20 ? identifier % 20 : identifier;
7
8
  }
8
9
  function createResponderEvent(domEvent, responderTouchHistoryStore) {
9
- let rect;
10
- let propagationWasStopped = false;
11
- let changedTouches;
12
- let touches;
13
- const domEventChangedTouches = domEvent.changedTouches;
14
- const domEventType = domEvent.type;
15
- const metaKey = domEvent.metaKey === true;
16
- const shiftKey = domEvent.shiftKey === true;
17
- const force = domEventChangedTouches?.[0].force || 0;
18
- const identifier = normalizeIdentifier(domEventChangedTouches?.[0].identifier || 0);
19
- const clientX = domEventChangedTouches?.[0].clientX || domEvent.clientX;
20
- const clientY = domEventChangedTouches?.[0].clientY || domEvent.clientY;
21
- const pageX = domEventChangedTouches?.[0].pageX || domEvent.pageX;
22
- const pageY = domEventChangedTouches?.[0].pageY || domEvent.pageY;
23
- const preventDefault = typeof domEvent.preventDefault === "function" ? domEvent.preventDefault.bind(domEvent) : emptyFunction;
24
- const timestamp = domEvent.timeStamp;
25
- function normalizeTouches(touches2) {
26
- return Array.prototype.slice.call(touches2).map(touch => {
27
- return {
28
- force: touch.force,
29
- identifier: normalizeIdentifier(touch.identifier),
30
- get locationX() {
31
- return locationX(touch.clientX);
32
- },
33
- get locationY() {
34
- return locationY(touch.clientY);
35
- },
36
- pageX: touch.pageX,
37
- pageY: touch.pageY,
38
- target: touch.target,
39
- timestamp
40
- };
41
- });
42
- }
43
- if (domEventChangedTouches != null) {
44
- changedTouches = normalizeTouches(domEventChangedTouches);
45
- touches = normalizeTouches(domEvent.touches);
46
- } else {
47
- const emulatedTouches = [{
48
- force,
49
- identifier,
50
- get locationX() {
51
- return locationX(clientX);
52
- },
53
- get locationY() {
54
- return locationY(clientY);
55
- },
56
- pageX,
57
- pageY,
58
- target: domEvent.target,
59
- timestamp
60
- }];
61
- changedTouches = emulatedTouches;
62
- touches = domEventType === "mouseup" || domEventType === "dragstart" ? emptyArray : emulatedTouches;
63
- }
64
- const responderEvent = {
65
- bubbles: true,
66
- cancelable: true,
67
- // `currentTarget` is set before dispatch
68
- currentTarget: null,
69
- defaultPrevented: domEvent.defaultPrevented,
70
- dispatchConfig: emptyObject,
71
- eventPhase: domEvent.eventPhase,
72
- isDefaultPrevented() {
73
- return domEvent.defaultPrevented;
74
- },
75
- isPropagationStopped() {
76
- return propagationWasStopped;
77
- },
78
- isTrusted: domEvent.isTrusted,
79
- nativeEvent: {
80
- altKey: false,
81
- ctrlKey: false,
82
- metaKey,
83
- shiftKey,
84
- changedTouches,
85
- force,
86
- identifier,
87
- get locationX() {
88
- return locationX(clientX);
89
- },
90
- get locationY() {
91
- return locationY(clientY);
92
- },
93
- pageX,
94
- pageY,
95
- target: domEvent.target,
96
- timestamp,
97
- touches,
98
- type: domEventType
99
- },
100
- persist: emptyFunction,
101
- preventDefault,
102
- stopPropagation() {
103
- propagationWasStopped = true;
104
- },
105
- target: domEvent.target,
106
- timeStamp: timestamp,
107
- touchHistory: responderTouchHistoryStore.touchHistory
108
- };
109
- function locationX(x) {
110
- rect = rect || getBoundingClientRect(responderEvent.currentTarget);
111
- if (rect) {
112
- return x - rect.left;
113
- }
114
- }
115
- function locationY(y) {
116
- rect = rect || getBoundingClientRect(responderEvent.currentTarget);
117
- if (rect) {
118
- return y - rect.top;
119
- }
120
- }
121
- return responderEvent;
10
+ let rect;
11
+ let propagationWasStopped = false;
12
+ let changedTouches;
13
+ let touches;
14
+ const domEventChangedTouches = domEvent.changedTouches;
15
+ const domEventType = domEvent.type;
16
+ const metaKey = domEvent.metaKey === true;
17
+ const shiftKey = domEvent.shiftKey === true;
18
+ const force = domEventChangedTouches?.[0].force || 0;
19
+ const identifier = normalizeIdentifier(domEventChangedTouches?.[0].identifier || 0);
20
+ const clientX = domEventChangedTouches?.[0].clientX || domEvent.clientX;
21
+ const clientY = domEventChangedTouches?.[0].clientY || domEvent.clientY;
22
+ const pageX = domEventChangedTouches?.[0].pageX || domEvent.pageX;
23
+ const pageY = domEventChangedTouches?.[0].pageY || domEvent.pageY;
24
+ const preventDefault = typeof domEvent.preventDefault === "function" ? domEvent.preventDefault.bind(domEvent) : emptyFunction;
25
+ const timestamp = domEvent.timeStamp;
26
+ function normalizeTouches(touches2) {
27
+ return Array.prototype.slice.call(touches2).map((touch) => {
28
+ return {
29
+ force: touch.force,
30
+ identifier: normalizeIdentifier(touch.identifier),
31
+ get locationX() {
32
+ return locationX(touch.clientX);
33
+ },
34
+ get locationY() {
35
+ return locationY(touch.clientY);
36
+ },
37
+ pageX: touch.pageX,
38
+ pageY: touch.pageY,
39
+ target: touch.target,
40
+ timestamp
41
+ };
42
+ });
43
+ }
44
+ if (domEventChangedTouches != null) {
45
+ changedTouches = normalizeTouches(domEventChangedTouches);
46
+ touches = normalizeTouches(domEvent.touches);
47
+ } else {
48
+ const emulatedTouches = [{
49
+ force,
50
+ identifier,
51
+ get locationX() {
52
+ return locationX(clientX);
53
+ },
54
+ get locationY() {
55
+ return locationY(clientY);
56
+ },
57
+ pageX,
58
+ pageY,
59
+ target: domEvent.target,
60
+ timestamp
61
+ }];
62
+ changedTouches = emulatedTouches;
63
+ touches = domEventType === "mouseup" || domEventType === "dragstart" ? emptyArray : emulatedTouches;
64
+ }
65
+ const responderEvent = {
66
+ bubbles: true,
67
+ cancelable: true,
68
+ currentTarget: null,
69
+ defaultPrevented: domEvent.defaultPrevented,
70
+ dispatchConfig: emptyObject,
71
+ eventPhase: domEvent.eventPhase,
72
+ isDefaultPrevented() {
73
+ return domEvent.defaultPrevented;
74
+ },
75
+ isPropagationStopped() {
76
+ return propagationWasStopped;
77
+ },
78
+ isTrusted: domEvent.isTrusted,
79
+ nativeEvent: {
80
+ altKey: false,
81
+ ctrlKey: false,
82
+ metaKey,
83
+ shiftKey,
84
+ changedTouches,
85
+ force,
86
+ identifier,
87
+ get locationX() {
88
+ return locationX(clientX);
89
+ },
90
+ get locationY() {
91
+ return locationY(clientY);
92
+ },
93
+ pageX,
94
+ pageY,
95
+ target: domEvent.target,
96
+ timestamp,
97
+ touches,
98
+ type: domEventType
99
+ },
100
+ persist: emptyFunction,
101
+ preventDefault,
102
+ stopPropagation() {
103
+ propagationWasStopped = true;
104
+ },
105
+ target: domEvent.target,
106
+ timeStamp: timestamp,
107
+ touchHistory: responderTouchHistoryStore.touchHistory
108
+ };
109
+ function locationX(x) {
110
+ rect = rect || getBoundingClientRect(responderEvent.currentTarget);
111
+ if (rect) {
112
+ return x - rect.left;
113
+ }
114
+ }
115
+ function locationY(y) {
116
+ rect = rect || getBoundingClientRect(responderEvent.currentTarget);
117
+ if (rect) {
118
+ return y - rect.top;
119
+ }
120
+ }
121
+ return responderEvent;
122
122
  }
123
+
123
124
  export { createResponderEvent };
124
125
  //# sourceMappingURL=createResponderEvent.mjs.map