// Metro module 1620 (f1621). import _classCallCheck from "./_classCallCheck"; import _createClass from "./_createClass"; import _classPrivateFieldKey from "./_classPrivateFieldKey"; import * as _Module1609 from "./Module1609"; import { isJest, isChromeDebugger, isWindowAvailable } from "./Module1609"; import { mockedRequestAnimationFrame } from "./Module1621"; import { WorkletsModule } from "./Module1622"; import { SensorType } from "./Module1631"; import { ReanimatedError } from "./Module1617"; import { logger } from "./Module1610"; let c1282_6, c1282_7; let env1282 = {}; const c1282_4 = !isJest() && globalThis.globalThis.requestAnimationFrame ? globalThis.globalThis.requestAnimationFrame : mockedRequestAnimationFrame; const c1282_5 = _classPrivateFieldKey("workletsModule"); const JSReanimated = function JSReanimated() { _classCallCheck(this, JSReanimated); Object.defineProperty(this, c1282_5, { writable: true, value: WorkletsModule }); this.nextSensorId = 0; this.sensors = new Map(); this.platform = void 0; this.getSensorCallback = (c28918_0, a1, c28918_1) => { if (SensorType.ACCELEROMETER !== a1 && SensorType.GRAVITY !== a1) { if (SensorType.GYROSCOPE !== a1 && SensorType.MAGNETIC_FIELD !== a1) { if (SensorType.ROTATION === a1) { return () => { const [qw, qx, r16, r17] = c28918_0.quaternion; const platform2 = this.platform; const WEB_ANDROID = c1282_7.WEB_ANDROID; let qz = r17; let qy = r16; if (platform2 === WEB_ANDROID) { const r23 = [r17, -r16]; qy = r23[0]; qz = r23[1]; } c28918_1({ qw, qx, qy, qz, yaw: -Math.atan2(2 * (qy * qz + qw * qx), qw * qw - qx * qx - qy * qy + qz * qz), pitch: Math.sin(-2 * (qx * qz - qw * qy)), roll: -Math.atan2(2 * (qx * qy + qw * qz), qw * qw + qx * qx - qy * qy - qz * qz), interfaceOrientation: 0 }); }; } return void 0; } return () => { c28918_1({ x: c28918_0.x, y: c28918_0.y, z: c28918_0.z, interfaceOrientation: 0 }); }; } return () => { const { x: r7, y: r6, z: r10 } = c28918_0; const platform2 = this.platform; const WEB_ANDROID = c1282_7.WEB_ANDROID; let r14 = r10; let r4 = r6; let r5 = r7; if (platform2 === WEB_ANDROID) { const r18 = [-r7, -r6, -r10]; r5 = r18[0]; r4 = r18[1]; r14 = r18[2]; } c28918_1({ x: r5, y: r4, z: r14, interfaceOrientation: 0 }); }; }; }; c1282_6 = _createClass(JSReanimated, [{ key: "scheduleOnUI", value: function scheduleOnUI(a0) { c1282_4(a0); } }, { key: "createWorkletRuntime", value: function createWorkletRuntime(a0, a1) { throw new ReanimatedError("createWorkletRuntime is not available in JSReanimated."); } }, { key: "scheduleOnRuntime", value: function scheduleOnRuntime() { throw new ReanimatedError("scheduleOnRuntime is not available in JSReanimated."); } }, { key: "registerEventHandler", value: function registerEventHandler(a0, a1, a2) { throw new ReanimatedError("registerEventHandler is not available in JSReanimated."); } }, { key: "unregisterEventHandler", value: function unregisterEventHandler(a0) { throw new ReanimatedError("unregisterEventHandler is not available in JSReanimated."); } }, { key: "enableLayoutAnimations", value: function enableLayoutAnimations() { if (_Module1609.isWeb()) { logger.warn("Layout Animations are not supported on web yet."); } else if (isJest()) { logger.warn("Layout Animations are no-ops when using Jest."); } else if (isChromeDebugger()) { logger.warn("Layout Animations are no-ops when using Chrome Debugger."); } else { logger.warn("Layout Animations are not supported on this configuration."); } } }, { key: "configureLayoutAnimationBatch", value: function configureLayoutAnimationBatch() {} }, { key: "setShouldAnimateExitingForTag", value: function setShouldAnimateExitingForTag() {} }, { key: "registerSensor", value: function registerSensor(a0, a1, a2, a3) { if (isWindowAvailable()) { if (this.platform === void 0) { this.detectPlatform(); } if (this.getSensorName(a0) in window) { if (this.platform === void 0) { this.detectPlatform(); } const r47 = this.initializeSensor(a0, a1); r47.addEventListener("reading", this.getSensorCallback(r47, a0, a3)); r47.start(); this.sensors.set(this.nextSensorId, r47); const r60 = +this.nextSensorId; this.nextSensorId = r60 + 1; return r60; } const isWeb = _Module1609.isWeb(); let r28 = ""; const r29 = isWeb ? location.protocol !== "https:" ? " Make sure you use secure origin with `npx expo start --web --https`." : "" : ""; if (this.platform === c1282_7.WEB_IOS) { r28 = " For iOS web, you will also have to also grant permission in the browser: https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2."; } logger.warn(`Sensor is not available.${r29}${r28}`); return -1; } return -1; } }, { key: "unregisterSensor", value: function unregisterSensor(a0) { const r5 = this.sensors.get(a0); if (r5 !== void 0) { r5.stop(); this.sensors.delete(a0); } } }, { key: "subscribeForKeyboardEvents", value: function subscribeForKeyboardEvents(a0) { if (_Module1609.isWeb()) { logger.warn("useAnimatedKeyboard is not available on web yet."); } else if (isJest()) { logger.warn("useAnimatedKeyboard is not available when using Jest."); } else if (isChromeDebugger()) { logger.warn("useAnimatedKeyboard is not available when using Chrome Debugger."); } else { logger.warn("useAnimatedKeyboard is not available on this configuration."); } return -1; } }, { key: "unsubscribeFromKeyboardEvents", value: function unsubscribeFromKeyboardEvents(a0) {} }, { key: "initializeSensor", value: function initializeSensor(a0, a1) { const r4 = a1 <= 0 ? { referenceFrame: "device" } : { frequency: 1000 / a1 }; if (SensorType.ACCELEROMETER === a0) { return new window.Accelerometer(r4); } if (SensorType.GYROSCOPE === a0) { return new window.Gyroscope(r4); } if (SensorType.GRAVITY === a0) { return new window.GravitySensor(r4); } if (SensorType.MAGNETIC_FIELD === a0) { return new window.Magnetometer(r4); } if (SensorType.ROTATION === a0) { return new window.AbsoluteOrientationSensor(r4); } } }, { key: "getSensorName", value: function getSensorName(a0) { if (SensorType.ACCELEROMETER === a0) { return "Accelerometer"; } if (SensorType.GRAVITY === a0) { return "GravitySensor"; } if (SensorType.GYROSCOPE === a0) { return "Gyroscope"; } if (SensorType.MAGNETIC_FIELD === a0) { return "Magnetometer"; } if (SensorType.ROTATION === a0) { return "AbsoluteOrientationSensor"; } } }, { key: "getSettledUpdates", value: function getSettledUpdates() { throw new ReanimatedError("`getSettledUpdates` is not available in JSReanimated."); } }, { key: "detectPlatform", value: function detectPlatform() { const r5 = navigator.userAgent || navigator.vendor || window.opera; if (r5 === void 0) { this.platform = c1282_7.UNKNOWN; } else if (/iPad|iPhone|iPod/.test(r5)) { this.platform = c1282_7.WEB_IOS; } else { const r13 = /android/i.test(r5); if (r13) { this.platform = c1282_7.WEB_ANDROID; } else { this.platform = c1282_7.WEB; } } } }, { key: "getViewProp", value: function getViewProp(a0, a1, a2, a3) { throw new ReanimatedError("getViewProp is not available in JSReanimated."); } }, { key: "configureProps", value: function configureProps() { throw new ReanimatedError("configureProps is not available in JSReanimated."); } }, { key: "executeOnUIRuntimeSync", value: function executeOnUIRuntimeSync(a0) { throw new ReanimatedError("`executeOnUIRuntimeSync` is not available in JSReanimated."); } }, { key: "markNodeAsRemovable", value: function markNodeAsRemovable(a0) { throw new ReanimatedError("markNodeAsRemovable is not available in JSReanimated."); } }, { key: "unmarkNodeAsRemovable", value: function unmarkNodeAsRemovable(a0) { throw new ReanimatedError("unmarkNodeAsRemovable is not available in JSReanimated."); } }]); c1282_7 = { WEB_IOS: "web iOS", WEB_ANDROID: "web Android", WEB: "web", UNKNOWN: "unknown" }; export function createJSReanimatedModule() { return new c1282_6(); } export { c1282_7 as Platform };