@zeey4d/react-native-gesture-engine 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.js +38 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -10
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var expoSensors = require('expo-sensors');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
var Haptics = require('expo-haptics');
|
|
3
6
|
var react = require('react');
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var Haptics__namespace = /*#__PURE__*/_interopNamespace(Haptics);
|
|
11
27
|
|
|
12
28
|
// src/core/EventBus.ts
|
|
13
29
|
var EventBus = class {
|
|
@@ -224,21 +240,6 @@ var TouchInputProvider = class {
|
|
|
224
240
|
this.eventBus.emit("input:raw" /* InputRaw */, event);
|
|
225
241
|
}
|
|
226
242
|
};
|
|
227
|
-
|
|
228
|
-
// src/input/SensorInputProvider.ts
|
|
229
|
-
var Accelerometer;
|
|
230
|
-
var Gyroscope;
|
|
231
|
-
function loadSensorModules() {
|
|
232
|
-
try {
|
|
233
|
-
const sensors = __require("expo-sensors");
|
|
234
|
-
Accelerometer = sensors.Accelerometer;
|
|
235
|
-
Gyroscope = sensors.Gyroscope;
|
|
236
|
-
} catch {
|
|
237
|
-
console.warn(
|
|
238
|
-
"[GestureEngine] expo-sensors not found. SensorInputProvider will not function."
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
243
|
var SensorInputProvider = class {
|
|
243
244
|
constructor(eventBus, updateIntervalMs = 100) {
|
|
244
245
|
this.eventBus = eventBus;
|
|
@@ -246,7 +247,6 @@ var SensorInputProvider = class {
|
|
|
246
247
|
this.accelSubscription = null;
|
|
247
248
|
this.gyroSubscription = null;
|
|
248
249
|
this.updateIntervalMs = Math.max(16, updateIntervalMs);
|
|
249
|
-
loadSensorModules();
|
|
250
250
|
}
|
|
251
251
|
get isActive() {
|
|
252
252
|
return this._isActive;
|
|
@@ -254,13 +254,13 @@ var SensorInputProvider = class {
|
|
|
254
254
|
start() {
|
|
255
255
|
if (this._isActive) return;
|
|
256
256
|
this._isActive = true;
|
|
257
|
-
if (!Accelerometer || !Gyroscope) {
|
|
257
|
+
if (!expoSensors.Accelerometer || !expoSensors.Gyroscope) {
|
|
258
258
|
console.warn("[GestureEngine] Sensors unavailable. Skipping sensor subscriptions.");
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
|
-
Accelerometer.setUpdateInterval(this.updateIntervalMs);
|
|
262
|
-
Gyroscope.setUpdateInterval(this.updateIntervalMs);
|
|
263
|
-
this.accelSubscription = Accelerometer.addListener(
|
|
261
|
+
expoSensors.Accelerometer.setUpdateInterval(this.updateIntervalMs);
|
|
262
|
+
expoSensors.Gyroscope.setUpdateInterval(this.updateIntervalMs);
|
|
263
|
+
this.accelSubscription = expoSensors.Accelerometer.addListener(
|
|
264
264
|
(data) => {
|
|
265
265
|
if (!this._isActive) return;
|
|
266
266
|
const sensorData = {
|
|
@@ -278,7 +278,7 @@ var SensorInputProvider = class {
|
|
|
278
278
|
this.eventBus.emit("input:raw" /* InputRaw */, event);
|
|
279
279
|
}
|
|
280
280
|
);
|
|
281
|
-
this.gyroSubscription = Gyroscope.addListener(
|
|
281
|
+
this.gyroSubscription = expoSensors.Gyroscope.addListener(
|
|
282
282
|
(data) => {
|
|
283
283
|
if (!this._isActive) return;
|
|
284
284
|
const sensorData = {
|
|
@@ -309,23 +309,12 @@ var SensorInputProvider = class {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
|
-
|
|
313
|
-
// src/input/HardwareInputProvider.ts
|
|
314
|
-
var DeviceEventEmitter;
|
|
315
|
-
function loadEmitter() {
|
|
316
|
-
try {
|
|
317
|
-
const rn = __require("react-native");
|
|
318
|
-
DeviceEventEmitter = rn.DeviceEventEmitter;
|
|
319
|
-
} catch {
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
312
|
var HardwareInputProvider = class {
|
|
323
313
|
constructor(eventBus, eventName = "onHardwareKey") {
|
|
324
314
|
this.eventBus = eventBus;
|
|
325
315
|
this._isActive = false;
|
|
326
316
|
this.subscription = null;
|
|
327
317
|
this.eventName = eventName;
|
|
328
|
-
loadEmitter();
|
|
329
318
|
}
|
|
330
319
|
get isActive() {
|
|
331
320
|
return this._isActive;
|
|
@@ -333,10 +322,10 @@ var HardwareInputProvider = class {
|
|
|
333
322
|
start() {
|
|
334
323
|
if (this._isActive) return;
|
|
335
324
|
this._isActive = true;
|
|
336
|
-
if (!DeviceEventEmitter) {
|
|
325
|
+
if (!reactNative.DeviceEventEmitter) {
|
|
337
326
|
return;
|
|
338
327
|
}
|
|
339
|
-
this.subscription = DeviceEventEmitter.addListener(
|
|
328
|
+
this.subscription = reactNative.DeviceEventEmitter.addListener(
|
|
340
329
|
this.eventName,
|
|
341
330
|
(data) => {
|
|
342
331
|
if (!this._isActive) return;
|
|
@@ -1946,30 +1935,14 @@ var CustomAction = class {
|
|
|
1946
1935
|
this.callback(event);
|
|
1947
1936
|
}
|
|
1948
1937
|
};
|
|
1949
|
-
|
|
1950
|
-
// src/feedback/HapticFeedback.ts
|
|
1951
|
-
var Haptics;
|
|
1952
|
-
var Vibration;
|
|
1953
|
-
function loadModules() {
|
|
1954
|
-
try {
|
|
1955
|
-
Haptics = __require("expo-haptics");
|
|
1956
|
-
} catch {
|
|
1957
|
-
}
|
|
1958
|
-
try {
|
|
1959
|
-
const rn = __require("react-native");
|
|
1960
|
-
Vibration = rn.Vibration;
|
|
1961
|
-
} catch {
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
1938
|
var HapticFeedback = class {
|
|
1965
1939
|
constructor(enabled = true) {
|
|
1966
1940
|
this._isSupported = false;
|
|
1967
1941
|
this.useVibrationFallback = false;
|
|
1968
1942
|
this.enabled = enabled;
|
|
1969
|
-
|
|
1970
|
-
if (Haptics) {
|
|
1943
|
+
if (Haptics__namespace) {
|
|
1971
1944
|
this._isSupported = true;
|
|
1972
|
-
} else if (Vibration) {
|
|
1945
|
+
} else if (reactNative.Vibration) {
|
|
1973
1946
|
this._isSupported = true;
|
|
1974
1947
|
this.useVibrationFallback = true;
|
|
1975
1948
|
}
|
|
@@ -1983,18 +1956,18 @@ var HapticFeedback = class {
|
|
|
1983
1956
|
return;
|
|
1984
1957
|
}
|
|
1985
1958
|
if (this.useVibrationFallback) {
|
|
1986
|
-
Vibration?.vibrate(50);
|
|
1959
|
+
reactNative.Vibration?.vibrate(50);
|
|
1987
1960
|
return;
|
|
1988
1961
|
}
|
|
1989
1962
|
const gestureName = event.name;
|
|
1990
1963
|
if (gestureName.startsWith("sequence:") || gestureName === "shake") {
|
|
1991
|
-
|
|
1964
|
+
Haptics__namespace?.notificationAsync?.(Haptics__namespace.NotificationFeedbackType?.Success);
|
|
1992
1965
|
} else if (gestureName === "tap" || gestureName === "double-tap") {
|
|
1993
|
-
|
|
1966
|
+
Haptics__namespace?.impactAsync?.(Haptics__namespace.ImpactFeedbackStyle?.Light);
|
|
1994
1967
|
} else if (gestureName.startsWith("edge-swipe") || gestureName.startsWith("corner")) {
|
|
1995
|
-
|
|
1968
|
+
Haptics__namespace?.impactAsync?.(Haptics__namespace.ImpactFeedbackStyle?.Medium);
|
|
1996
1969
|
} else {
|
|
1997
|
-
|
|
1970
|
+
Haptics__namespace?.selectionAsync?.();
|
|
1998
1971
|
}
|
|
1999
1972
|
}
|
|
2000
1973
|
setEnabled(enabled) {
|
|
@@ -2022,22 +1995,11 @@ var VisualFeedback = class {
|
|
|
2022
1995
|
this.callback = callback;
|
|
2023
1996
|
}
|
|
2024
1997
|
};
|
|
2025
|
-
|
|
2026
|
-
// src/feedback/AccessibilityFeedback.ts
|
|
2027
|
-
var AccessibilityInfo;
|
|
2028
|
-
function loadAccessibility() {
|
|
2029
|
-
try {
|
|
2030
|
-
const rn = __require("react-native");
|
|
2031
|
-
AccessibilityInfo = rn.AccessibilityInfo;
|
|
2032
|
-
} catch {
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
1998
|
var AccessibilityFeedback = class {
|
|
2036
1999
|
constructor() {
|
|
2037
2000
|
this._isSupported = false;
|
|
2038
2001
|
this.announcementBuilder = null;
|
|
2039
|
-
|
|
2040
|
-
this._isSupported = !!AccessibilityInfo?.announceForAccessibility;
|
|
2002
|
+
this._isSupported = !!reactNative.AccessibilityInfo?.announceForAccessibility;
|
|
2041
2003
|
}
|
|
2042
2004
|
get isSupported() {
|
|
2043
2005
|
return this._isSupported;
|
|
@@ -2046,7 +2008,7 @@ var AccessibilityFeedback = class {
|
|
|
2046
2008
|
if (!this._isSupported) return;
|
|
2047
2009
|
if (event.state !== "ended" /* Ended */) return;
|
|
2048
2010
|
const announcement = this.announcementBuilder ? this.announcementBuilder(event) : this.defaultAnnouncement(event);
|
|
2049
|
-
AccessibilityInfo.announceForAccessibility(announcement);
|
|
2011
|
+
reactNative.AccessibilityInfo.announceForAccessibility(announcement);
|
|
2050
2012
|
}
|
|
2051
2013
|
/**
|
|
2052
2014
|
* Set a custom function to build announcement strings.
|