react-native-orientation-director 1.3.0 → 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/README.md +30 -18
- package/android/build.gradle +13 -1
- package/android/gradle.properties +12 -0
- package/android/src/main/java/com/orientationdirector/OrientationDirectorPackage.kt +5 -4
- package/android/src/main/java/com/orientationdirector/implementation/EventManager.kt +0 -1
- package/android/src/main/java/com/orientationdirector/implementation/LifecycleListener.kt +1 -1
- package/android/src/main/java/com/orientationdirector/implementation/Orientation.kt +2 -0
- package/android/src/main/java/com/orientationdirector/implementation/{OrientationDirectorImpl.kt → OrientationDirectorModuleImpl.kt} +47 -33
- package/android/src/main/java/com/orientationdirector/implementation/OrientationSensorsEventListener.kt +79 -0
- package/android/src/main/java/com/orientationdirector/implementation/Utils.kt +28 -15
- package/android/src/newarch/OrientationDirectorModule.kt +59 -0
- package/android/src/oldarch/OrientationDirectorModule.kt +66 -0
- package/android/src/test/java/com/orientationdirector/implementation/OrientationDirectorModuleImplTest.kt +188 -0
- package/android/src/test/java/com/orientationdirector/implementation/UtilsTest.kt +314 -0
- package/ios/OrientationDirector.mm +12 -37
- package/lib/commonjs/EventEmitter.js +50 -0
- package/lib/commonjs/EventEmitter.js.map +1 -0
- package/lib/commonjs/NativeOrientationDirector.js.map +1 -1
- package/lib/commonjs/RNOrientationDirector.js +6 -8
- package/lib/commonjs/RNOrientationDirector.js.map +1 -1
- package/lib/commonjs/hooks/useDeviceOrientation.hook.js +1 -1
- package/lib/commonjs/hooks/useDeviceOrientation.hook.js.map +1 -1
- package/lib/commonjs/hooks/useInterfaceOrientation.hook.js +1 -1
- package/lib/commonjs/hooks/useInterfaceOrientation.hook.js.map +1 -1
- package/lib/commonjs/hooks/useIsInterfaceOrientationLocked.hook.js +1 -1
- package/lib/commonjs/hooks/useIsInterfaceOrientationLocked.hook.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/module.js +2 -2
- package/lib/commonjs/module.js.map +1 -1
- package/lib/module/EventEmitter.js +41 -0
- package/lib/module/EventEmitter.js.map +1 -0
- package/lib/module/NativeOrientationDirector.js.map +1 -1
- package/lib/module/RNOrientationDirector.js +5 -5
- package/lib/module/RNOrientationDirector.js.map +1 -1
- package/lib/module/module.js +1 -1
- package/lib/module/module.js.map +1 -1
- package/lib/typescript/src/EventEmitter.d.ts +11 -0
- package/lib/typescript/src/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/src/NativeOrientationDirector.d.ts +3 -1
- package/lib/typescript/src/NativeOrientationDirector.d.ts.map +1 -1
- package/lib/typescript/src/RNOrientationDirector.d.ts +1 -1
- package/lib/typescript/src/RNOrientationDirector.d.ts.map +1 -1
- package/lib/typescript/src/module.d.ts +1 -1
- package/lib/typescript/src/module.d.ts.map +1 -1
- package/lib/typescript/src/types/Orientation.enum.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EventEmitter.ts +70 -0
- package/src/NativeOrientationDirector.ts +12 -1
- package/src/RNOrientationDirector.ts +6 -9
- package/src/module.ts +1 -1
- package/src/types/Orientation.enum.ts +0 -2
- package/android/src/main/java/com/orientationdirector/OrientationDirectorModule.kt +0 -65
- package/android/src/main/java/com/orientationdirector/implementation/SensorListener.kt +0 -26
- package/android/src/newarch/OrientationDirectorSpec.kt +0 -7
- package/android/src/oldarch/OrientationDirectorSpec.kt +0 -18
|
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
-
var _module =
|
|
9
|
-
var _Event = _interopRequireDefault(require("./types/Event.enum"));
|
|
8
|
+
var _module = _interopRequireDefault(require("./module"));
|
|
10
9
|
var _Orientation = require("./types/Orientation.enum");
|
|
11
10
|
var _AutoRotation = require("./types/AutoRotation.enum");
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
var _EventEmitter = _interopRequireDefault(require("./EventEmitter"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
13
|
class RNOrientationDirector {
|
|
16
14
|
static _humanReadableOrientationsResource = {
|
|
17
15
|
[_Orientation.Orientation.unknown]: 'Unknown',
|
|
@@ -58,13 +56,13 @@ class RNOrientationDirector {
|
|
|
58
56
|
_module.default.resetSupportedInterfaceOrientations();
|
|
59
57
|
}
|
|
60
58
|
static listenForDeviceOrientationChanges(callback) {
|
|
61
|
-
return
|
|
59
|
+
return _EventEmitter.default.addDeviceOrientationDidChangeListener(callback);
|
|
62
60
|
}
|
|
63
61
|
static listenForInterfaceOrientationChanges(callback) {
|
|
64
|
-
return
|
|
62
|
+
return _EventEmitter.default.addInterfaceOrientationDidChangeListener(callback);
|
|
65
63
|
}
|
|
66
64
|
static listenForLockChanges(callback) {
|
|
67
|
-
return
|
|
65
|
+
return _EventEmitter.default.addLockDidChangeListener(callback);
|
|
68
66
|
}
|
|
69
67
|
static convertOrientationToHumanReadableString(orientation) {
|
|
70
68
|
return RNOrientationDirector._humanReadableOrientationsResource[orientation];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_module","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_module","_interopRequireDefault","_Orientation","_AutoRotation","_EventEmitter","e","__esModule","default","RNOrientationDirector","_humanReadableOrientationsResource","Orientation","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","faceUp","faceDown","_humanReadableAutoRotationsResource","AutoRotation","enabled","disabled","setHumanReadableOrientations","resource","setHumanReadableAutoRotations","getInterfaceOrientation","Module","getDeviceOrientation","lockTo","orientation","unlock","isLocked","isAutoRotationEnabled","Platform","OS","resetSupportedInterfaceOrientations","listenForDeviceOrientationChanges","callback","EventEmitter","addDeviceOrientationDidChangeListener","listenForInterfaceOrientationChanges","addInterfaceOrientationDidChangeListener","listenForLockChanges","addLockDidChangeListener","convertOrientationToHumanReadableString","convertAutoRotationToHumanReadableString","autoRotation","_default","exports"],"sourceRoot":"../../src","sources":["RNOrientationDirector.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAKA,IAAAK,aAAA,GAAAH,sBAAA,CAAAF,OAAA;AAA0C,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1C,MAAMG,qBAAqB,CAAC;EAC1B,OAAeC,kCAAkC,GAC/C;IACE,CAACC,wBAAW,CAACC,OAAO,GAAG,SAAS;IAChC,CAACD,wBAAW,CAACE,QAAQ,GAAG,UAAU;IAClC,CAACF,wBAAW,CAACG,kBAAkB,GAAG,sBAAsB;IACxD,CAACH,wBAAW,CAACI,aAAa,GAAG,gBAAgB;IAC7C,CAACJ,wBAAW,CAACK,cAAc,GAAG,iBAAiB;IAC/C,CAACL,wBAAW,CAACM,MAAM,GAAG,SAAS;IAC/B,CAACN,wBAAW,CAACO,QAAQ,GAAG;EAC1B,CAAC;EAEH,OAAeC,mCAAmC,GAChD;IACE,CAACC,0BAAY,CAACR,OAAO,GAAG,SAAS;IACjC,CAACQ,0BAAY,CAACC,OAAO,GAAG,SAAS;IACjC,CAACD,0BAAY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AwB,CAACN,QAAQ,CAAC;EACxD;EAEA,OAAOO,uCAAuCA,CAACf,WAAwB,EAAE;IACvE,OAAOrB,qBAAqB,CAACC,kCAAkC,CAC7DoB,WAAW,CACZ;EACH;EAEA,OAAOgB,wCAAwCA,CAACC,YAA0B,EAAE;IAC1E,OAAOtC,qBAAqB,CAACU,mCAAmC,CAC9D4B,YAAY,CACb;EACH;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzC,OAAA,GAEcC,qBAAqB","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _RNOrientationDirector = _interopRequireDefault(require("../RNOrientationDirector"));
|
|
9
9
|
var _Orientation = require("../types/Orientation.enum");
|
|
10
|
-
function _interopRequireDefault(
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
12
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_RNOrientationDirector","_interopRequireDefault","_Orientation","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_RNOrientationDirector","_interopRequireDefault","_Orientation","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useDeviceOrientation","initialRender","useRef","orientation","setOrientation","React","useState","Orientation","unknown","useEffect","current","RNOrientationDirector","getDeviceOrientation","then","onChange","event","subscription","listenForDeviceOrientationChanges","remove","_default","exports"],"sourceRoot":"../../../src","sources":["hooks/useDeviceOrientation.hook.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAAwD,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAA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
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _RNOrientationDirector = _interopRequireDefault(require("../RNOrientationDirector"));
|
|
9
9
|
var _Orientation = require("../types/Orientation.enum");
|
|
10
|
-
function _interopRequireDefault(
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
12
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_RNOrientationDirector","_interopRequireDefault","_Orientation","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_RNOrientationDirector","_interopRequireDefault","_Orientation","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useInterfaceOrientation","initialRender","useRef","orientation","setOrientation","React","useState","Orientation","unknown","useEffect","current","RNOrientationDirector","getInterfaceOrientation","then","onChange","event","subscription","listenForInterfaceOrientationChanges","remove","_default","exports"],"sourceRoot":"../../../src","sources":["hooks/useInterfaceOrientation.hook.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAC,sBAAA,CAAA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A;AACA;AACA,MAAMW,uBAAuB,GAAGA,CAAA,KAAM;EACpC,MAAMC,aAAa,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EACnC,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAClDC,wBAAW,CAACC,OACd,CAAC;EAEDH,cAAK,CAACI,SAAS,CAAC,MAAM;IACpB,IAAIR,aAAa,CAACS,OAAO,EAAE;MACzB;IACF;IAEAT,aAAa,CAACS,OAAO,GAAG,IAAI;IAC5BC,8BAAqB,CAACC,uBAAuB,CAAC,CAAC,CAACC,IAAI,CAACT,cAAc,CAAC;EACtE,CAAC,EAAE,EAAE,CAAC;EAENC,cAAK,CAACI,SAAS,CAAC,MAAM;IACpB,MAAMK,QAAQ,GAAIC,KAAuB,IAAK;MAC5CX,cAAc,CAACW,KAAK,CAACZ,WAAW,CAAC;IACnC,CAAC;IAED,MAAMa,YAAY,GAChBL,8BAAqB,CAACM,oCAAoC,CAACH,QAAQ,CAAC;IACtE,OAAO,MAAM;MACXE,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOf,WAAW;AACpB,CAAC;AAAC,IAAAgB,QAAA,GAAAC,OAAA,CAAAtC,OAAA,GAEakB,uBAAuB","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _RNOrientationDirector = _interopRequireDefault(require("../RNOrientationDirector"));
|
|
9
|
-
function _interopRequireDefault(
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/**
|
|
11
11
|
* Hook that returns whether the interface is locked.
|
|
12
12
|
* It listens for changes and updates the state accordingly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_RNOrientationDirector","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_RNOrientationDirector","e","__esModule","default","useIsInterfaceOrientationLocked","orientation","setOrientation","React","useState","RNOrientationDirector","isLocked","useEffect","onChange","event","locked","subscription","listenForLockChanges","remove","_default","exports"],"sourceRoot":"../../../src","sources":["hooks/useIsInterfaceOrientationLocked.hook.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA6D,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG7D;AACA;AACA;AACA;AACA,MAAMG,+BAA+B,GAAGA,CAAA,KAAM;EAC5C,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAU,MAC5DC,8BAAqB,CAACC,QAAQ,CAAC,CACjC,CAAC;EAEDH,cAAK,CAACI,SAAS,CAAC,MAAM;IACpB,MAAMC,QAAQ,GAAIC,KAAkB,IAAK;MACvCP,cAAc,CAACO,KAAK,CAACC,MAAM,CAAC;IAC9B,CAAC;IAED,MAAMC,YAAY,GAAGN,8BAAqB,CAACO,oBAAoB,CAACJ,QAAQ,CAAC;IACzE,OAAO,MAAM;MACXG,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOZ,WAAW;AACpB,CAAC;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAAhB,OAAA,GAEaC,+BAA+B","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -40,6 +40,6 @@ var _useDeviceOrientation = _interopRequireDefault(require("./hooks/useDeviceOri
|
|
|
40
40
|
var _useInterfaceOrientation = _interopRequireDefault(require("./hooks/useInterfaceOrientation.hook"));
|
|
41
41
|
var _useIsInterfaceOrientationLocked = _interopRequireDefault(require("./hooks/useIsInterfaceOrientationLocked.hook"));
|
|
42
42
|
var _RNOrientationDirector = _interopRequireDefault(require("./RNOrientationDirector"));
|
|
43
|
-
function _interopRequireDefault(
|
|
43
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
44
44
|
var _default = exports.default = _RNOrientationDirector.default;
|
|
45
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Orientation","require","_AutoRotation","_useDeviceOrientation","_interopRequireDefault","_useInterfaceOrientation","_useIsInterfaceOrientationLocked","_RNOrientationDirector","
|
|
1
|
+
{"version":3,"names":["_Orientation","require","_AutoRotation","_useDeviceOrientation","_interopRequireDefault","_useInterfaceOrientation","_useIsInterfaceOrientationLocked","_RNOrientationDirector","e","__esModule","default","_default","exports","RNOrientationDirector"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGA,IAAAI,wBAAA,GAAAD,sBAAA,CAAAH,OAAA;AAGA,IAAAK,gCAAA,GAAAF,sBAAA,CAAAH,OAAA;AAGA,IAAAM,sBAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA4D,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAC7CG,8BAAqB","ignoreList":[]}
|
package/lib/commonjs/module.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.
|
|
6
|
+
exports.default = exports.ModuleEventEmitter = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
const LINKING_ERROR = `The package 'react-native-orientation-director' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
9
|
ios: "- You have run 'pod install'\n",
|
|
@@ -18,6 +18,6 @@ const OrientationDirectorModule = Module ? Module : new Proxy({}, {
|
|
|
18
18
|
throw new Error(LINKING_ERROR);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
const
|
|
21
|
+
const ModuleEventEmitter = exports.ModuleEventEmitter = new _reactNative.NativeEventEmitter(Module);
|
|
22
22
|
var _default = exports.default = OrientationDirectorModule;
|
|
23
23
|
//# sourceMappingURL=module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","isTurboModuleEnabled","global","__turboModuleProxy","Module","NativeModules","OrientationDirector","OrientationDirectorModule","Proxy","get","Error","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","isTurboModuleEnabled","global","__turboModuleProxy","Module","NativeModules","OrientationDirector","OrientationDirectorModule","Proxy","get","Error","ModuleEventEmitter","exports","NativeEventEmitter","_default"],"sourceRoot":"../../src","sources":["module.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,aAAa,GACjB,4FAA4F,GAC5FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,kBAAkB,IAAI,IAAI;AAE9D,MAAMC,MAAM,GAAGH,oBAAoB,GAC/BN,OAAO,CAAC,6BAA6B,CAAC,CAACK,OAAO,GAC9CK,0BAAa,CAACC,mBAAmB;AAErC,MAAMC,yBAAyB,GAAGH,MAAM,GACpCA,MAAM,GACN,IAAII,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACd,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEE,MAAMe,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,IAAIE,+BAAkB,CAACT,MAAM,CAAC;AAAC,IAAAU,QAAA,GAAAF,OAAA,CAAAZ,OAAA,GAElDO,yBAAyB","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import Module, { ModuleEventEmitter } from './module';
|
|
3
|
+
import Event from './types/Event.enum';
|
|
4
|
+
class EventEmitter {
|
|
5
|
+
static addDeviceOrientationDidChangeListener(callback) {
|
|
6
|
+
let listener = ModuleEventEmitter.addListener(Event.DeviceOrientationDidChange, callback);
|
|
7
|
+
if (Platform.OS !== 'android') {
|
|
8
|
+
return listener;
|
|
9
|
+
}
|
|
10
|
+
const listenerCount = ModuleEventEmitter.listenerCount(Event.DeviceOrientationDidChange);
|
|
11
|
+
if (listenerCount === 1) {
|
|
12
|
+
Module.enableOrientationSensors();
|
|
13
|
+
}
|
|
14
|
+
return EventEmitter.createDeviceOrientationListenerProxy(listener);
|
|
15
|
+
}
|
|
16
|
+
static addInterfaceOrientationDidChangeListener(callback) {
|
|
17
|
+
return ModuleEventEmitter.addListener(Event.InterfaceOrientationDidChange, callback);
|
|
18
|
+
}
|
|
19
|
+
static addLockDidChangeListener(callback) {
|
|
20
|
+
return ModuleEventEmitter.addListener(Event.LockDidChange, callback);
|
|
21
|
+
}
|
|
22
|
+
static createDeviceOrientationListenerProxy(listener) {
|
|
23
|
+
const handler = {
|
|
24
|
+
get(target, propertyKey, receiver) {
|
|
25
|
+
if (propertyKey === 'remove') {
|
|
26
|
+
disableOrientationSensorsIfLastListener();
|
|
27
|
+
}
|
|
28
|
+
return Reflect.get(target, propertyKey, receiver);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return new Proxy(listener, handler);
|
|
32
|
+
function disableOrientationSensorsIfLastListener() {
|
|
33
|
+
const listenerCount = ModuleEventEmitter.listenerCount(Event.DeviceOrientationDidChange);
|
|
34
|
+
if (listenerCount === 1) {
|
|
35
|
+
Module.disableOrientationSensors();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export default EventEmitter;
|
|
41
|
+
//# sourceMappingURL=EventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","Module","ModuleEventEmitter","Event","EventEmitter","addDeviceOrientationDidChangeListener","callback","listener","addListener","DeviceOrientationDidChange","OS","listenerCount","enableOrientationSensors","createDeviceOrientationListenerProxy","addInterfaceOrientationDidChangeListener","InterfaceOrientationDidChange","addLockDidChangeListener","LockDidChange","handler","get","target","propertyKey","receiver","disableOrientationSensorsIfLastListener","Reflect","Proxy","disableOrientationSensors"],"sourceRoot":"../../src","sources":["EventEmitter.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAkC,cAAc;AACjE,OAAOC,MAAM,IAAIC,kBAAkB,QAAQ,UAAU;AACrD,OAAOC,KAAK,MAAM,oBAAoB;AAItC,MAAMC,YAAY,CAAC;EACjB,OAAOC,qCAAqCA,CAC1CC,QAAiD,EACjD;IACA,IAAIC,QAAQ,GAAGL,kBAAkB,CAACM,WAAW,CAC3CL,KAAK,CAACM,0BAA0B,EAChCH,QACF,CAAC;IAED,IAAIN,QAAQ,CAACU,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOH,QAAQ;IACjB;IAEA,MAAMI,aAAa,GAAGT,kBAAkB,CAACS,aAAa,CACpDR,KAAK,CAACM,0BACR,CAAC;IAED,IAAIE,aAAa,KAAK,CAAC,EAAE;MACvBV,MAAM,CAACW,wBAAwB,CAAC,CAAC;IACnC;IAEA,OAAOR,YAAY,CAACS,oCAAoC,CAACN,QAAQ,CAAC;EACpE;EAEA,OAAOO,wCAAwCA,CAC7CR,QAAiD,EACjD;IACA,OAAOJ,kBAAkB,CAACM,WAAW,CACnCL,KAAK,CAACY,6BAA6B,EACnCT,QACF,CAAC;EACH;EAEA,OAAOU,wBAAwBA,CAACV,QAAsC,EAAE;IACtE,OAAOJ,kBAAkB,CAACM,WAAW,CAACL,KAAK,CAACc,aAAa,EAAEX,QAAQ,CAAC;EACtE;EAEA,OAAeO,oCAAoCA,CACjDN,QAA6B,EAC7B;IACA,MAAMW,OAA0C,GAAG;MACjDC,GAAGA,CAACC,MAAM,EAAEC,WAAW,EAAEC,QAAQ,EAAE;QACjC,IAAID,WAAW,KAAK,QAAQ,EAAE;UAC5BE,uCAAuC,CAAC,CAAC;QAC3C;QACA,OAAOC,OAAO,CAACL,GAAG,CAACC,MAAM,EAAEC,WAAW,EAAEC,QAAQ,CAAC;MACnD;IACF,CAAC;IAED,OAAO,IAAIG,KAAK,CAAClB,QAAQ,EAAEW,OAAO,CAAC;IAEnC,SAASK,uCAAuCA,CAAA,EAAG;MACjD,MAAMZ,aAAa,GAAGT,kBAAkB,CAACS,aAAa,CACpDR,KAAK,CAACM,0BACR,CAAC;MAED,IAAIE,aAAa,KAAK,CAAC,EAAE;QACvBV,MAAM,CAACyB,yBAAyB,CAAC,CAAC;MACpC;IACF;EACF;AACF;AAEA,eAAetB,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOrientationDirector.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOrientationDirector.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AA0BlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,qBAAqB,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
-
import Module
|
|
3
|
-
import Event from './types/Event.enum';
|
|
2
|
+
import Module from './module';
|
|
4
3
|
import { Orientation } from './types/Orientation.enum';
|
|
5
4
|
import { AutoRotation } from './types/AutoRotation.enum';
|
|
5
|
+
import EventEmitter from './EventEmitter';
|
|
6
6
|
class RNOrientationDirector {
|
|
7
7
|
static _humanReadableOrientationsResource = {
|
|
8
8
|
[Orientation.unknown]: 'Unknown',
|
|
@@ -49,13 +49,13 @@ class RNOrientationDirector {
|
|
|
49
49
|
Module.resetSupportedInterfaceOrientations();
|
|
50
50
|
}
|
|
51
51
|
static listenForDeviceOrientationChanges(callback) {
|
|
52
|
-
return EventEmitter.
|
|
52
|
+
return EventEmitter.addDeviceOrientationDidChangeListener(callback);
|
|
53
53
|
}
|
|
54
54
|
static listenForInterfaceOrientationChanges(callback) {
|
|
55
|
-
return EventEmitter.
|
|
55
|
+
return EventEmitter.addInterfaceOrientationDidChangeListener(callback);
|
|
56
56
|
}
|
|
57
57
|
static listenForLockChanges(callback) {
|
|
58
|
-
return EventEmitter.
|
|
58
|
+
return EventEmitter.addLockDidChangeListener(callback);
|
|
59
59
|
}
|
|
60
60
|
static convertOrientationToHumanReadableString(orientation) {
|
|
61
61
|
return RNOrientationDirector._humanReadableOrientationsResource[orientation];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","Module","
|
|
1
|
+
{"version":3,"names":["Platform","Module","Orientation","AutoRotation","EventEmitter","RNOrientationDirector","_humanReadableOrientationsResource","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","faceUp","faceDown","_humanReadableAutoRotationsResource","enabled","disabled","setHumanReadableOrientations","resource","setHumanReadableAutoRotations","getInterfaceOrientation","getDeviceOrientation","lockTo","orientation","unlock","isLocked","isAutoRotationEnabled","OS","resetSupportedInterfaceOrientations","listenForDeviceOrientationChanges","callback","addDeviceOrientationDidChangeListener","listenForInterfaceOrientationChanges","addInterfaceOrientationDidChangeListener","listenForLockChanges","addLockDidChangeListener","convertOrientationToHumanReadableString","convertAutoRotationToHumanReadableString","autoRotation"],"sourceRoot":"../../src","sources":["RNOrientationDirector.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,MAAM,MAAM,UAAU;AAE7B,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,YAAY,QAAQ,2BAA2B;AAKxD,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,MAAMC,qBAAqB,CAAC;EAC1B,OAAeC,kCAAkC,GAC/C;IACE,CAACJ,WAAW,CAACK,OAAO,GAAG,SAAS;IAChC,CAACL,WAAW,CAACM,QAAQ,GAAG,UAAU;IAClC,CAACN,WAAW,CAACO,kBAAkB,GAAG,sBAAsB;IACxD,CAACP,WAAW,CAACQ,aAAa,GAAG,gBAAgB;IAC7C,CAACR,WAAW,CAACS,cAAc,GAAG,iBAAiB;IAC/C,CAACT,WAAW,CAACU,MAAM,GAAG,SAAS;IAC/B,CAACV,WAAW,CAACW,QAAQ,GAAG;EAC1B,CAAC;EAEH,OAAeC,mCAAmC,GAChD;IACE,CAACX,YAAY,CAACI,OAAO,GAAG,SAAS;IACjC,CAACJ,YAAY,CAACY,OAAO,GAAG,SAAS;IACjC,CAACZ,YAAY,CAACa,QAAQ,GAAG;EAC3B,CAAC;EAEHC,4BAA4BA,CAACC,QAA2C,EAAE;IACxEb,qBAAqB,CAACC,kCAAkC,GAAGY,QAAQ;EACrE;EAEAC,6BAA6BA,CAACD,QAA4C,EAAE;IAC1Eb,qBAAqB,CAACS,mCAAmC,GAAGI,QAAQ;EACtE;EAEA,OAAOE,uBAAuBA,CAAA,EAAyB;IACrD,OAAOnB,MAAM,CAACmB,uBAAuB,CAAC,CAAC;EACzC;EAEA,OAAOC,oBAAoBA,CAAA,EAAyB;IAClD,OAAOpB,MAAM,CAACoB,oBAAoB,CAAC,CAAC;EACtC;EAEA,OAAOC,MAAMA,CAACC,WAAgC,EAAE;IAC9CtB,MAAM,CAACqB,MAAM,CAACC,WAAW,CAAC;EAC5B;EAEA,OAAOC,MAAMA,CAAA,EAAG;IACdvB,MAAM,CAACuB,MAAM,CAAC,CAAC;EACjB;EAEA,OAAOC,QAAQA,CAAA,EAAG;IAChB,OAAOxB,MAAM,CAACwB,QAAQ,CAAC,CAAC;EAC1B;EAEA,OAAOC,qBAAqBA,CAAA,EAAG;IAC7B,IAAI1B,QAAQ,CAAC2B,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOxB,YAAY,CAACI,OAAO;IAC7B;IACA,OAAON,MAAM,CAACyB,qBAAqB,CAAC,CAAC,GACjCvB,YAAY,CAACY,OAAO,GACpBZ,YAAY,CAACa,QAAQ;EAC3B;EAEA,OAAOY,mCAAmCA,CAAA,EAAG;IAC3C3B,MAAM,CAAC2B,mCAAmC,CAAC,CAAC;EAC9C;EAEA,OAAOC,iCAAiCA,CACtCC,QAAiD,EACjD;IACA,OAAO1B,YAAY,CAAC2B,qCAAqC,CAACD,QAAQ,CAAC;EACrE;EAEA,OAAOE,oCAAoCA,CACzCF,QAAiD,EACjD;IACA,OAAO1B,YAAY,CAAC6B,wCAAwC,CAACH,QAAQ,CAAC;EACxE;EAEA,OAAOI,oBAAoBA,CAACJ,QAAsC,EAAE;IAClE,OAAO1B,YAAY,CAAC+B,wBAAwB,CAACL,QAAQ,CAAC;EACxD;EAEA,OAAOM,uCAAuCA,CAACb,WAAwB,EAAE;IACvE,OAAOlB,qBAAqB,CAACC,kCAAkC,CAC7DiB,WAAW,CACZ;EACH;EAEA,OAAOc,wCAAwCA,CAACC,YAA0B,EAAE;IAC1E,OAAOjC,qBAAqB,CAACS,mCAAmC,CAC9DwB,YAAY,CACb;EACH;AACF;AAEA,eAAejC,qBAAqB","ignoreList":[]}
|
package/lib/module/module.js
CHANGED
|
@@ -12,6 +12,6 @@ const OrientationDirectorModule = Module ? Module : new Proxy({}, {
|
|
|
12
12
|
throw new Error(LINKING_ERROR);
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
export const
|
|
15
|
+
export const ModuleEventEmitter = new NativeEventEmitter(Module);
|
|
16
16
|
export default OrientationDirectorModule;
|
|
17
17
|
//# sourceMappingURL=module.js.map
|
package/lib/module/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","LINKING_ERROR","select","ios","default","isTurboModuleEnabled","global","__turboModuleProxy","Module","require","OrientationDirector","OrientationDirectorModule","Proxy","get","Error","
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","LINKING_ERROR","select","ios","default","isTurboModuleEnabled","global","__turboModuleProxy","Module","require","OrientationDirector","OrientationDirectorModule","Proxy","get","Error","ModuleEventEmitter"],"sourceRoot":"../../src","sources":["module.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAG1E,MAAMC,aAAa,GACjB,4FAA4F,GAC5FD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,kBAAkB,IAAI,IAAI;AAE9D,MAAMC,MAAM,GAAGH,oBAAoB,GAC/BI,OAAO,CAAC,6BAA6B,CAAC,CAACL,OAAO,GAC9CL,aAAa,CAACW,mBAAmB;AAErC,MAAMC,yBAAyB,GAAGH,MAAM,GACpCA,MAAM,GACN,IAAII,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACb,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMc,kBAAkB,GAAG,IAAIjB,kBAAkB,CAACU,MAAM,CAAC;AAEhE,eAAeG,yBAAyB","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type EmitterSubscription } from 'react-native';
|
|
2
|
+
import type { OrientationEvent } from './types/OrientationEvent.interface';
|
|
3
|
+
import type { LockedEvent } from './types/LockedEvent.interface';
|
|
4
|
+
declare class EventEmitter {
|
|
5
|
+
static addDeviceOrientationDidChangeListener(callback: (orientation: OrientationEvent) => void): EmitterSubscription;
|
|
6
|
+
static addInterfaceOrientationDidChangeListener(callback: (orientation: OrientationEvent) => void): EmitterSubscription;
|
|
7
|
+
static addLockDidChangeListener(callback: (event: LockedEvent) => void): EmitterSubscription;
|
|
8
|
+
private static createDeviceOrientationListenerProxy;
|
|
9
|
+
}
|
|
10
|
+
export default EventEmitter;
|
|
11
|
+
//# sourceMappingURL=EventEmitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../../src/EventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,cAAM,YAAY;IAChB,MAAM,CAAC,qCAAqC,CAC1C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAsBnD,MAAM,CAAC,wCAAwC,CAC7C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAQnD,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI;IAItE,OAAO,CAAC,MAAM,CAAC,oCAAoC;CAwBpD;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -5,8 +5,10 @@ export interface Spec extends TurboModule {
|
|
|
5
5
|
lockTo(orientation: number): void;
|
|
6
6
|
unlock(): void;
|
|
7
7
|
isLocked(): boolean;
|
|
8
|
-
isAutoRotationEnabled(): boolean;
|
|
9
8
|
resetSupportedInterfaceOrientations(): void;
|
|
9
|
+
isAutoRotationEnabled(): boolean;
|
|
10
|
+
enableOrientationSensors(): void;
|
|
11
|
+
disableOrientationSensors(): void;
|
|
10
12
|
addListener: (eventType: string) => void;
|
|
11
13
|
removeListeners: (count: number) => void;
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/NativeOrientationDirector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,IAAI,IAAI,CAAC;IACf,QAAQ,IAAI,OAAO,CAAC;IACpB,qBAAqB,IAAI,OAAO,CAAC;IACjC,
|
|
1
|
+
{"version":3,"file":"NativeOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/NativeOrientationDirector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,IAAI,IAAI,CAAC;IACf,QAAQ,IAAI,OAAO,CAAC;IACpB,mCAAmC,IAAI,IAAI,CAAC;IAO5C,qBAAqB,IAAI,OAAO,CAAC;IACjC,wBAAwB,IAAI,IAAI,CAAC;IACjC,yBAAyB,IAAI,IAAI,CAAC;IAKlC,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;;AAED,wBAA6E"}
|
|
@@ -19,7 +19,7 @@ declare class RNOrientationDirector {
|
|
|
19
19
|
static resetSupportedInterfaceOrientations(): void;
|
|
20
20
|
static listenForDeviceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EmitterSubscription;
|
|
21
21
|
static listenForInterfaceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EmitterSubscription;
|
|
22
|
-
static listenForLockChanges(callback: (
|
|
22
|
+
static listenForLockChanges(callback: (event: LockedEvent) => void): import("react-native").EmitterSubscription;
|
|
23
23
|
static convertOrientationToHumanReadableString(orientation: Orientation): string;
|
|
24
24
|
static convertAutoRotationToHumanReadableString(autoRotation: AutoRotation): string;
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/RNOrientationDirector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RNOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/RNOrientationDirector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gDAAgD,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AAG1G,cAAM,qBAAqB;IACzB,OAAO,CAAC,MAAM,CAAC,kCAAkC,CAS7C;IAEJ,OAAO,CAAC,MAAM,CAAC,mCAAmC,CAK9C;IAEJ,4BAA4B,CAAC,QAAQ,EAAE,iCAAiC;IAIxE,6BAA6B,CAAC,QAAQ,EAAE,kCAAkC;IAI1E,MAAM,CAAC,uBAAuB,IAAI,OAAO,CAAC,WAAW,CAAC;IAItD,MAAM,CAAC,oBAAoB,IAAI,OAAO,CAAC,WAAW,CAAC;IAInD,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,mBAAmB;IAI9C,MAAM,CAAC,MAAM;IAIb,MAAM,CAAC,QAAQ;IAIf,MAAM,CAAC,qBAAqB;IAS5B,MAAM,CAAC,mCAAmC;IAI1C,MAAM,CAAC,iCAAiC,CACtC,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAKnD,MAAM,CAAC,oCAAoC,CACzC,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAKnD,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI;IAIlE,MAAM,CAAC,uCAAuC,CAAC,WAAW,EAAE,WAAW;IAMvE,MAAM,CAAC,wCAAwC,CAAC,YAAY,EAAE,YAAY;CAK3E;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NativeEventEmitter } from 'react-native';
|
|
2
2
|
import type { Spec } from './NativeOrientationDirector';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ModuleEventEmitter: NativeEventEmitter;
|
|
4
4
|
declare const _default: Spec;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AA0BxD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AA0BxD,eAAO,MAAM,kBAAkB,oBAAiC,CAAC;wBAErB,IAAI;AAAhD,wBAAiD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Orientation.enum.d.ts","sourceRoot":"","sources":["../../../../src/types/Orientation.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,cAAc,IAAI;IAClB,kBAAkB,IAAI;IACtB,aAAa,IAAI;
|
|
1
|
+
{"version":3,"file":"Orientation.enum.d.ts","sourceRoot":"","sources":["../../../../src/types/Orientation.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,cAAc,IAAI;IAClB,kBAAkB,IAAI;IACtB,aAAa,IAAI;IACjB,MAAM,IAAI;IACV,QAAQ,IAAI;CACb"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Platform, type EmitterSubscription } from 'react-native';
|
|
2
|
+
import Module, { ModuleEventEmitter } from './module';
|
|
3
|
+
import Event from './types/Event.enum';
|
|
4
|
+
import type { OrientationEvent } from './types/OrientationEvent.interface';
|
|
5
|
+
import type { LockedEvent } from './types/LockedEvent.interface';
|
|
6
|
+
|
|
7
|
+
class EventEmitter {
|
|
8
|
+
static addDeviceOrientationDidChangeListener(
|
|
9
|
+
callback: (orientation: OrientationEvent) => void
|
|
10
|
+
) {
|
|
11
|
+
let listener = ModuleEventEmitter.addListener(
|
|
12
|
+
Event.DeviceOrientationDidChange,
|
|
13
|
+
callback
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (Platform.OS !== 'android') {
|
|
17
|
+
return listener;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const listenerCount = ModuleEventEmitter.listenerCount(
|
|
21
|
+
Event.DeviceOrientationDidChange
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (listenerCount === 1) {
|
|
25
|
+
Module.enableOrientationSensors();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return EventEmitter.createDeviceOrientationListenerProxy(listener);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static addInterfaceOrientationDidChangeListener(
|
|
32
|
+
callback: (orientation: OrientationEvent) => void
|
|
33
|
+
) {
|
|
34
|
+
return ModuleEventEmitter.addListener(
|
|
35
|
+
Event.InterfaceOrientationDidChange,
|
|
36
|
+
callback
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static addLockDidChangeListener(callback: (event: LockedEvent) => void) {
|
|
41
|
+
return ModuleEventEmitter.addListener(Event.LockDidChange, callback);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private static createDeviceOrientationListenerProxy(
|
|
45
|
+
listener: EmitterSubscription
|
|
46
|
+
) {
|
|
47
|
+
const handler: ProxyHandler<EmitterSubscription> = {
|
|
48
|
+
get(target, propertyKey, receiver) {
|
|
49
|
+
if (propertyKey === 'remove') {
|
|
50
|
+
disableOrientationSensorsIfLastListener();
|
|
51
|
+
}
|
|
52
|
+
return Reflect.get(target, propertyKey, receiver);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return new Proxy(listener, handler);
|
|
57
|
+
|
|
58
|
+
function disableOrientationSensorsIfLastListener() {
|
|
59
|
+
const listenerCount = ModuleEventEmitter.listenerCount(
|
|
60
|
+
Event.DeviceOrientationDidChange
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (listenerCount === 1) {
|
|
64
|
+
Module.disableOrientationSensors();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default EventEmitter;
|
|
@@ -7,9 +7,20 @@ export interface Spec extends TurboModule {
|
|
|
7
7
|
lockTo(orientation: number): void;
|
|
8
8
|
unlock(): void;
|
|
9
9
|
isLocked(): boolean;
|
|
10
|
-
isAutoRotationEnabled(): boolean;
|
|
11
10
|
resetSupportedInterfaceOrientations(): void;
|
|
12
11
|
|
|
12
|
+
////////////////////////////////////
|
|
13
|
+
//
|
|
14
|
+
// ANDROID ONLY
|
|
15
|
+
//
|
|
16
|
+
|
|
17
|
+
isAutoRotationEnabled(): boolean;
|
|
18
|
+
enableOrientationSensors(): void;
|
|
19
|
+
disableOrientationSensors(): void;
|
|
20
|
+
|
|
21
|
+
//
|
|
22
|
+
////////////////////////////////////
|
|
23
|
+
|
|
13
24
|
addListener: (eventType: string) => void;
|
|
14
25
|
removeListeners: (count: number) => void;
|
|
15
26
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
-
import Module
|
|
3
|
-
import Event from './types/Event.enum';
|
|
2
|
+
import Module from './module';
|
|
4
3
|
import type { HumanReadableOrientationsResource } from './types/HumanReadableOrientationsResource.type';
|
|
5
4
|
import { Orientation } from './types/Orientation.enum';
|
|
6
5
|
import { AutoRotation } from './types/AutoRotation.enum';
|
|
@@ -8,6 +7,7 @@ import type { OrientationEvent } from './types/OrientationEvent.interface';
|
|
|
8
7
|
import type { LockableOrientation } from './types/LockableOrientation.type';
|
|
9
8
|
import type { LockedEvent } from './types/LockedEvent.interface';
|
|
10
9
|
import type { HumanReadableAutoRotationsResource } from './types/HumanReadableAutoRotationsResource.type';
|
|
10
|
+
import EventEmitter from './EventEmitter';
|
|
11
11
|
|
|
12
12
|
class RNOrientationDirector {
|
|
13
13
|
private static _humanReadableOrientationsResource: HumanReadableOrientationsResource =
|
|
@@ -72,20 +72,17 @@ class RNOrientationDirector {
|
|
|
72
72
|
static listenForDeviceOrientationChanges(
|
|
73
73
|
callback: (orientation: OrientationEvent) => void
|
|
74
74
|
) {
|
|
75
|
-
return EventEmitter.
|
|
75
|
+
return EventEmitter.addDeviceOrientationDidChangeListener(callback);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
static listenForInterfaceOrientationChanges(
|
|
79
79
|
callback: (orientation: OrientationEvent) => void
|
|
80
80
|
) {
|
|
81
|
-
return EventEmitter.
|
|
82
|
-
Event.InterfaceOrientationDidChange,
|
|
83
|
-
callback
|
|
84
|
-
);
|
|
81
|
+
return EventEmitter.addInterfaceOrientationDidChangeListener(callback);
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
static listenForLockChanges(callback: (
|
|
88
|
-
return EventEmitter.
|
|
84
|
+
static listenForLockChanges(callback: (event: LockedEvent) => void) {
|
|
85
|
+
return EventEmitter.addLockDidChangeListener(callback);
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
static convertOrientationToHumanReadableString(orientation: Orientation) {
|
package/src/module.ts
CHANGED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
package com.orientationdirector
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
-
import com.facebook.react.bridge.ReactMethod
|
|
5
|
-
import com.facebook.react.bridge.Promise
|
|
6
|
-
import com.orientationdirector.implementation.OrientationDirectorImpl
|
|
7
|
-
|
|
8
|
-
class OrientationDirectorModule internal constructor(context: ReactApplicationContext) :
|
|
9
|
-
OrientationDirectorSpec(context) {
|
|
10
|
-
|
|
11
|
-
private var orientationDirectorImpl: OrientationDirectorImpl
|
|
12
|
-
|
|
13
|
-
override fun getName(): String {
|
|
14
|
-
return NAME
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
init {
|
|
18
|
-
orientationDirectorImpl = OrientationDirectorImpl(context)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@ReactMethod()
|
|
22
|
-
override fun getInterfaceOrientation(promise: Promise) {
|
|
23
|
-
promise.resolve(orientationDirectorImpl.getInterfaceOrientation().ordinal)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@ReactMethod()
|
|
27
|
-
override fun getDeviceOrientation(promise: Promise) {
|
|
28
|
-
promise.resolve(orientationDirectorImpl.getDeviceOrientation().ordinal)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@ReactMethod()
|
|
32
|
-
override fun lockTo(orientation: Double) {
|
|
33
|
-
orientationDirectorImpl.lockTo(orientation.toInt())
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@ReactMethod()
|
|
37
|
-
override fun unlock() {
|
|
38
|
-
orientationDirectorImpl.unlock()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@ReactMethod()
|
|
42
|
-
override fun resetSupportedInterfaceOrientations() {
|
|
43
|
-
orientationDirectorImpl.resetSupportedInterfaceOrientations()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
47
|
-
override fun isLocked(): Boolean {
|
|
48
|
-
return orientationDirectorImpl.getIsLocked()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
52
|
-
override fun isAutoRotationEnabled(): Boolean {
|
|
53
|
-
return orientationDirectorImpl.getIsAutoRotationEnabled()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@ReactMethod()
|
|
57
|
-
override fun addListener(eventName: String) {}
|
|
58
|
-
|
|
59
|
-
@ReactMethod()
|
|
60
|
-
override fun removeListeners(count: Double) {}
|
|
61
|
-
|
|
62
|
-
companion object {
|
|
63
|
-
const val NAME = "OrientationDirector"
|
|
64
|
-
}
|
|
65
|
-
}
|