react-native-orientation-director 3.0.0 → 3.0.2

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.
@@ -50,15 +50,27 @@ class OrientationDirectorModule(reactContext: ReactApplicationContext) :
50
50
  }
51
51
 
52
52
  override fun sendOnDeviceOrientationChanged(params: WritableMap) {
53
- emitOnDeviceOrientationChanged(params)
53
+ try {
54
+ emitOnDeviceOrientationChanged(params)
55
+ } catch(_: Exception) {
56
+ // No listener instance yet
57
+ }
54
58
  }
55
59
 
56
60
  override fun sendOnInterfaceOrientationChanged(params: WritableMap) {
57
- emitOnInterfaceOrientationChanged(params)
61
+ try {
62
+ emitOnInterfaceOrientationChanged(params)
63
+ } catch(_: Exception) {
64
+ // No listener instance yet
65
+ }
58
66
  }
59
67
 
60
68
  override fun sendOnLockChanged(params: WritableMap) {
61
- emitOnLockChanged(params)
69
+ try {
70
+ emitOnLockChanged(params)
71
+ } catch(_: Exception) {
72
+ // No listener instance yet
73
+ }
62
74
  }
63
75
 
64
76
  companion object {
@@ -10,11 +10,12 @@
10
10
  #import "OrientationDirector/OrientationDirector-Swift.h"
11
11
  #endif
12
12
 
13
+ #include <exception>
14
+
13
15
  static OrientationDirectorImpl *_director = SharedOrientationDirectorImpl.shared;
14
16
 
15
17
  ///////////////////////////////////////////////////////////////////////////////////////
16
18
  /// EVENT EMITTER SETUP
17
- ///https://github.com/react-native-community/RNNewArchitectureLibraries/tree/feat/swift-event-emitter
18
19
  @interface OrientationDirector() <OrientationEventEmitterDelegate>
19
20
  @end
20
21
  ///
@@ -43,17 +44,31 @@ static OrientationDirectorImpl *_director = SharedOrientationDirectorImpl.shared
43
44
  ///////////////////////////////////////////////////////////////////////////////////////
44
45
  /// EVENT EMITTER SETUP
45
46
  ///
46
- -(void)emitOnDeviceOrientationDidChangeWithParams:(NSDictionary*)params {
47
- [self emitOnDeviceOrientationChanged:params];
47
+
48
+ -(void)emitDeviceOrientationChangedWithParams:(NSDictionary*)params {
49
+ try {
50
+ [self emitOnDeviceOrientationChanged:params];
51
+ } catch (std::exception &e) {
52
+ // Ignore if no listeners
53
+ }
48
54
  }
49
55
 
50
- -(void)emitOnInterfaceOrientationDidChangeWithParams:(NSDictionary*)params {
51
- [self emitOnInterfaceOrientationChanged:params];
56
+ -(void)emitInterfaceOrientationChangedWithParams:(NSDictionary*)params {
57
+ try {
58
+ [self emitOnInterfaceOrientationChanged:params];
59
+ } catch (std::exception &e) {
60
+ // Ignore if no listeners
61
+ }
52
62
  }
53
63
 
54
64
  -(void)emitOnLockChangedWithParams:(NSDictionary*)params {
55
- [self emitOnLockChanged:params];
65
+ try {
66
+ [self emitOnLockChanged:params];
67
+ } catch (std::exception &e) {
68
+ // Ignore if no listeners
69
+ }
56
70
  }
71
+
57
72
  ///
58
73
  ///////////////////////////////////////////////////////////////////////////////////////
59
74
 
@@ -14,9 +14,9 @@ public class EventManager: NSObject {
14
14
  guard let delegate = delegate else {
15
15
  return
16
16
  }
17
-
17
+
18
18
  let params = Dictionary(dictionaryLiteral: ("orientation", value))
19
- delegate.emitOnDeviceOrientationDidChange(params: params as NSDictionary)
19
+ delegate.emitDeviceOrientationChanged(params: params as NSDictionary)
20
20
  }
21
21
 
22
22
  func sendInterfaceOrientationDidChange(value: Int) {
@@ -25,7 +25,7 @@ public class EventManager: NSObject {
25
25
  }
26
26
 
27
27
  let params = Dictionary(dictionaryLiteral: ("orientation", value))
28
- delegate.emitOnInterfaceOrientationDidChange(params: params as NSDictionary)
28
+ delegate.emitInterfaceOrientationChanged(params: params as NSDictionary)
29
29
  }
30
30
 
31
31
  func sendLockDidChange(value: Bool) {
@@ -40,6 +40,6 @@ public class EventManager: NSObject {
40
40
 
41
41
  @objc public protocol OrientationEventEmitterDelegate {
42
42
  func emitOnLockChanged(params: NSDictionary)
43
- func emitOnDeviceOrientationDidChange(params: NSDictionary)
44
- func emitOnInterfaceOrientationDidChange(params: NSDictionary)
43
+ func emitDeviceOrientationChanged(params: NSDictionary)
44
+ func emitInterfaceOrientationChanged(params: NSDictionary)
45
45
  }
@@ -1,25 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  import { Platform } from 'react-native';
4
- import Module from "./module.js";
4
+ import NativeOrientationDirector from "./NativeOrientationDirector.js";
5
5
  class EventEmitter {
6
6
  static androidListenerCount = 0;
7
7
  static addDeviceOrientationDidChangeListener(callback) {
8
- let listener = Module.onDeviceOrientationChanged(callback);
8
+ let listener = NativeOrientationDirector.onDeviceOrientationChanged(callback);
9
9
  if (Platform.OS !== 'android') {
10
10
  return listener;
11
11
  }
12
12
  EventEmitter.androidListenerCount++;
13
13
  if (EventEmitter.androidListenerCount === 1) {
14
- Module.enableOrientationSensors();
14
+ NativeOrientationDirector.enableOrientationSensors();
15
15
  }
16
16
  return EventEmitter.createDeviceOrientationListenerProxy(listener);
17
17
  }
18
18
  static addInterfaceOrientationDidChangeListener(callback) {
19
- return Module.onInterfaceOrientationChanged(callback);
19
+ return NativeOrientationDirector.onInterfaceOrientationChanged(callback);
20
20
  }
21
21
  static addLockDidChangeListener(callback) {
22
- return Module.onLockChanged(callback);
22
+ return NativeOrientationDirector.onLockChanged(callback);
23
23
  }
24
24
  static createDeviceOrientationListenerProxy(listener) {
25
25
  const handler = {
@@ -34,7 +34,7 @@ class EventEmitter {
34
34
  function disableOrientationSensorsIfLastListener() {
35
35
  if (EventEmitter.androidListenerCount === 1) {
36
36
  EventEmitter.androidListenerCount = 0;
37
- Module.disableOrientationSensors();
37
+ NativeOrientationDirector.disableOrientationSensors();
38
38
  return;
39
39
  }
40
40
  if (EventEmitter.androidListenerCount === 0) {
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","Module","EventEmitter","androidListenerCount","addDeviceOrientationDidChangeListener","callback","listener","onDeviceOrientationChanged","OS","enableOrientationSensors","createDeviceOrientationListenerProxy","addInterfaceOrientationDidChangeListener","onInterfaceOrientationChanged","addLockDidChangeListener","onLockChanged","handler","get","target","propertyKey","receiver","disableOrientationSensorsIf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;QAC3CD,YAAY,CAACC,oBAAoB,GAAG,CAAC;QACrCF,MAAM,CAACsB,yBAAyB,CAAC,CAAC;QAClC;MACF;MAEA,IAAIrB,YAAY,CAACC,oBAAoB,KAAK,CAAC,EAAE;QAC3C;MACF;MAEAD,YAAY,CAACC,oBAAoB,EAAE;MACnC;IACF;EACF;AACF;AAEA,eAAeD,YAAY","ignoreList":[]}
1
+ {"version":3,"names":["Platform","NativeOrientationDirector","EventEmitter","androidListenerCount","addDeviceOrientationDidChangeListener","callback","listener","onDeviceOrientationChanged","OS","enableOrientationSensors","createDeviceOrientationListenerProxy","addInterfaceOrientationDidChangeListener","onInterfaceOrientationChanged","addLockDidChangeListener","onLockChanged","handler","get","target","propertyKey","receiver","disableOrientationSensorsIfLastListener","Reflect","Proxy","disableOrientationSensors"],"sourceRoot":"../../src","sources":["EventEmitter.ts"],"mappings":";;AAAA,SAAiCA,QAAQ,QAAQ,cAAc;AAC/D,OAAOC,yBAAyB,MAAM,gCAA6B;AAInE,MAAMC,YAAY,CAAC;EACjB,OAAeC,oBAAoB,GAAG,CAAC;EAEvC,OAAOC,qCAAqCA,CAC1CC,QAAiD,EACjD;IACA,IAAIC,QAAQ,GACVL,yBAAyB,CAACM,0BAA0B,CAACF,QAAQ,CAAC;IAEhE,IAAIL,QAAQ,CAACQ,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOF,QAAQ;IACjB;IAEAJ,YAAY,CAACC,oBAAoB,EAAE;IACnC,IAAID,YAAY,CAACC,oBAAoB,KAAK,CAAC,EAAE;MAC3CF,yBAAyB,CAACQ,wBAAwB,CAAC,CAAC;IACtD;IAEA,OAAOP,YAAY,CAACQ,oCAAoC,CAACJ,QAAQ,CAAC;EACpE;EAEA,OAAOK,wCAAwCA,CAC7CN,QAAiD,EACjD;IACA,OAAOJ,yBAAyB,CAACW,6BAA6B,CAACP,QAAQ,CAAC;EAC1E;EAEA,OAAOQ,wBAAwBA,CAACR,QAAsC,EAAE;IACtE,OAAOJ,yBAAyB,CAACa,aAAa,CAACT,QAAQ,CAAC;EAC1D;EAEA,OAAeK,oCAAoCA,CACjDJ,QAA2B,EAC3B;IACA,MAAMS,OAAwC,GAAG;MAC/CC,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,CAAChB,QAAQ,EAAES,OAAO,CAAC;IAEnC,SAASK,uCAAuCA,CAAA,EAAG;MACjD,IAAIlB,YAAY,CAACC,oBAAoB,KAAK,CAAC,EAAE;QAC3CD,YAAY,CAACC,oBAAoB,GAAG,CAAC;QACrCF,yBAAyB,CAACsB,yBAAyB,CAAC,CAAC;QACrD;MACF;MAEA,IAAIrB,YAAY,CAACC,oBAAoB,KAAK,CAAC,EAAE;QAC3C;MACF;MAEAD,YAAY,CAACC,oBAAoB,EAAE;MACnC;IACF;EACF;AACF;AAEA,eAAeD,YAAY","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { Platform } from 'react-native';
4
- import Module from "./module.js";
4
+ import NativeOrientationDirector from "./NativeOrientationDirector.js";
5
5
  import { Orientation } from "./types/Orientation.enum.js";
6
6
  import { AutoRotation } from "./types/AutoRotation.enum.js";
7
7
  import { OrientationType } from "./types/OrientationType.enum.js";
@@ -29,10 +29,10 @@ class RNOrientationDirector {
29
29
  RNOrientationDirector._humanReadableAutoRotationsResource = resource;
30
30
  }
31
31
  static getInterfaceOrientation() {
32
- return Module.getInterfaceOrientation();
32
+ return NativeOrientationDirector.getInterfaceOrientation();
33
33
  }
34
34
  static getDeviceOrientation() {
35
- return Module.getDeviceOrientation();
35
+ return NativeOrientationDirector.getDeviceOrientation();
36
36
  }
37
37
 
38
38
  /**
@@ -55,33 +55,33 @@ class RNOrientationDirector {
55
55
  */
56
56
  static lockTo(orientation, orientationType = OrientationType.interface) {
57
57
  if (orientationType === OrientationType.interface) {
58
- Module.lockTo(orientation);
58
+ NativeOrientationDirector.lockTo(orientation);
59
59
  return;
60
60
  }
61
61
  if (orientation === Orientation.landscapeLeft) {
62
- Module.lockTo(Orientation.landscapeRight);
62
+ NativeOrientationDirector.lockTo(Orientation.landscapeRight);
63
63
  return;
64
64
  }
65
65
  if (orientation === Orientation.landscapeRight) {
66
- Module.lockTo(Orientation.landscapeLeft);
66
+ NativeOrientationDirector.lockTo(Orientation.landscapeLeft);
67
67
  return;
68
68
  }
69
- Module.lockTo(orientation);
69
+ NativeOrientationDirector.lockTo(orientation);
70
70
  }
71
71
  static unlock() {
72
- Module.unlock();
72
+ NativeOrientationDirector.unlock();
73
73
  }
74
74
  static isLocked() {
75
- return Module.isLocked();
75
+ return NativeOrientationDirector.isLocked();
76
76
  }
77
77
  static isAutoRotationEnabled() {
78
78
  if (Platform.OS !== 'android') {
79
79
  return AutoRotation.unknown;
80
80
  }
81
- return Module.isAutoRotationEnabled() ? AutoRotation.enabled : AutoRotation.disabled;
81
+ return NativeOrientationDirector.isAutoRotationEnabled() ? AutoRotation.enabled : AutoRotation.disabled;
82
82
  }
83
83
  static resetSupportedInterfaceOrientations() {
84
- Module.resetSupportedInterfaceOrientations();
84
+ NativeOrientationDirector.resetSupportedInterfaceOrientations();
85
85
  }
86
86
  static listenForDeviceOrientationChanges(callback) {
87
87
  return EventEmitter.addDeviceOrientationDidChangeListener(callback);
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","Module","Orientation","AutoRotation","OrientationType","EventEmitter","RNOrientationDirector","_humanReadableOrientationsResource","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","landscape","faceUp","faceDown","_humanReadableAutoRotationsResource","enabled","disabled","setHumanReadableOrientations","resource","setHumanReadableAutoRotations","getInterfaceOrientation","getDeviceOrientation","lockTo","orientation","orientationType","interface","unlock","isLocked","isAutoRotationEnabled","OS","resetSupportedInterfaceOrientations","listenForDeviceOrientationChanges","callback","addDeviceOrientationDidChangeListener","listenForInterfaceOrientationChanges","addInterfaceOrientationDidChangeListener","listenForLockChanges","addLockDidChangeListener","convertOrientationToHumanReadableString","convertAutoRotationToHumanReadableString","autoRotation","isLockableOrientation"],"sourceRoot":"../../src","sources":["RNOrientationDirector.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,MAAM,MAAM,aAAU;AAE7B,SAASC,WAAW,QAAQ,6BAA0B;AACtD,SAASC,YAAY,QAAQ,8BAA2B;AACxD,SAASC,eAAe,QAAQ,iCAA8B;AAK9D,OAAOC,YAAY,MAAM,mBAAgB;AAEzC,MAAMC,qBAAqB,CAAC;EAC1B,OAAeC,kCAAkC,GAC/C;IACE,CAACL,WAAW,CAACM,OAAO,GAAG,SAAS;IAChC,CAACN,WAAW,CAACO,QAAQ,GAAG,UAAU;IAClC,CAACP,WAAW,CAACQ,kBAAkB,GAAG,sBAAsB;IACxD,CAACR,WAAW,CAACS,aAAa,GAAG,gBAAgB;IAC7C,CAACT,WAAW,CAACU,cAAc,GAAG,iBAAiB;IAC/C,CAACV,WAAW,CAACW,SAAS,GAAG,WAAW;IACpC,CAACX,WAAW,CAACY,MAAM,GAAG,SAAS;IAC/B,CAACZ,WAAW,CAACa,QAAQ,GAAG;EAC1B,CAAC;EAEH,OAAeC,mCAAmC,GAChD;IACE,CAACb,YAAY,CAACK,OAAO,GAAG,SAAS;IACjC,CAACL,YAAY,CAACc,OAAO,GAAG,SAAS;IACjC,CAACd,YAAY,CAACe,QAAQ,GAAG;EAC3B,CAAC;EAEHC,4BAA4BA,CAACC,QAA2C,EAAE;IACxEd,qBAAqB,CAACC,kCAAkC,GAAGa,QAAQ;EACrE;EAEAC,6BAA6BA,CAACD,QAA4C,EAAE;IAC1Ed,qBAAqB,CAACU,mCAAmC,GAAGI,QAAQ;EACtE;EAEA,OA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C9C;EAEA,OAAOC,iCAAiCA,CACtCC,QAAiD,EACjD;IACA,OAAO7B,YAAY,CAAC8B,qCAAqC,CAACD,QAAQ,CAAC;EACrE;EAEA,OAAOE,oCAAoCA,CACzCF,QAAiD,EACjD;IACA,OAAO7B,YAAY,CAACgC,wCAAwC,CAACH,QAAQ,CAAC;EACxE;EAEA,OAAOI,oBAAoBA,CAACJ,QAAsC,EAAE;IAClE,OAAO7B,YAAY,CAACkC,wBAAwB,CAACL,QAAQ,CAAC;EACxD;EAEA,OAAOM,uCAAuCA,CAACf,WAAwB,EAAE;IACvE,OAAOnB,qBAAqB,CAACC,kCAAkC,CAC7DkB,WAAW,CACZ;EACH;EAEA,OAAOgB,wCAAwCA,CAACC,YAA0B,EAAE;IAC1E,OAAOpC,qBAAqB,CAACU,mCAAmC,CAC9D0B,YAAY,CACb;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,qBAAqBA,CAC1BlB,WAAwB,EACY;IACpC,OAAO,EACLA,WAAW,KAAKvB,WAAW,CAACM,OAAO,IACnCiB,WAAW,KAAKvB,WAAW,CAACY,MAAM,IAClCW,WAAW,KAAKvB,WAAW,CAACa,QAAQ,CACrC;EACH;AACF;AAEA,eAAeT,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["Platform","NativeOrientationDirector","Orientation","AutoRotation","OrientationType","EventEmitter","RNOrientationDirector","_humanReadableOrientationsResource","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","landscape","faceUp","faceDown","_humanReadableAutoRotationsResource","enabled","disabled","setHumanReadableOrientations","resource","setHumanReadableAutoRotations","getInterfaceOrientation","getDeviceOrientation","lockTo","orientation","orientationType","interface","unlock","isLocked","isAutoRotationEnabled","OS","resetSupportedInterfaceOrientations","listenForDeviceOrientationChanges","callback","addDeviceOrientationDidChangeListener","listenForInterfaceOrientationChanges","addInterfaceOrientationDidChangeListener","listenForLockChanges","addLockDidChangeListener","convertOrientationToHumanReadableString","convertAutoRotationToHumanReadableString","autoRotation","isLockableOrientation"],"sourceRoot":"../../src","sources":["RNOrientationDirector.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,yBAAyB,MAAM,gCAA6B;AAEnE,SAASC,WAAW,QAAQ,6BAA0B;AACtD,SAASC,YAAY,QAAQ,8BAA2B;AACxD,SAASC,eAAe,QAAQ,iCAA8B;AAK9D,OAAOC,YAAY,MAAM,mBAAgB;AAEzC,MAAMC,qBAAqB,CAAC;EAC1B,OAAeC,kCAAkC,GAC/C;IACE,CAACL,WAAW,CAACM,OAAO,GAAG,SAAS;IAChC,CAACN,WAAW,CAACO,QAAQ,GAAG,UAAU;IAClC,CAACP,WAAW,CAACQ,kBAAkB,GAAG,sBAAsB;IACxD,CAACR,WAAW,CAACS,aAAa,GAAG,gBAAgB;IAC7C,CAACT,WAAW,CAACU,cAAc,GAAG,iBAAiB;IAC/C,CAACV,WAAW,CAACW,SAAS,GAAG,WAAW;IACpC,CAACX,WAAW,CAACY,MAAM,GAAG,SAAS;IAC/B,CAACZ,WAAW,CAACa,QAAQ,GAAG;EAC1B,CAAC;EAEH,OAAeC,mCAAmC,GAChD;IACE,CAACb,YAAY,CAACK,OAAO,GAAG,SAAS;IACjC,CAACL,YAAY,CAACc,OAAO,GAAG,SAAS;IACjC,CAACd,YAAY,CAACe,QAAQ,GAAG;EAC3B,CAAC;EAEHC,4BAA4BA,CAACC,QAA2C,EAAE;IACxEd,qBAAqB,CAACC,kCAAkC,GAAGa,QAAQ;EACrE;EAEAC,6BAA6BA,CAACD,QAA4C,EAAE;IAC1Ed,qBAAqB,CAACU,mCAAmC,GAAGI,QAAQ;EACtE;EAEA,OAAOE,uBAAuBA,CAAA,EAAyB;IACrD,OAAOrB,yBAAyB,CAACqB,uBAAuB,CAAC,CAAC;EAC5D;EAEA,OAAOC,oBAAoBA,CAAA,EAAyB;IAClD,OAAOtB,yBAAyB,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AOE,oCAAoCA,CACzCF,QAAiD,EACjD;IACA,OAAO7B,YAAY,CAACgC,wCAAwC,CAACH,QAAQ,CAAC;EACxE;EAEA,OAAOI,oBAAoBA,CAACJ,QAAsC,EAAE;IAClE,OAAO7B,YAAY,CAACkC,wBAAwB,CAACL,QAAQ,CAAC;EACxD;EAEA,OAAOM,uCAAuCA,CAACf,WAAwB,EAAE;IACvE,OAAOnB,qBAAqB,CAACC,kCAAkC,CAC7DkB,WAAW,CACZ;EACH;EAEA,OAAOgB,wCAAwCA,CAACC,YAA0B,EAAE;IAC1E,OAAOpC,qBAAqB,CAACU,mCAAmC,CAC9D0B,YAAY,CACb;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,qBAAqBA,CAC1BlB,WAAwB,EACY;IACpC,OAAO,EACLA,WAAW,KAAKvB,WAAW,CAACM,OAAO,IACnCiB,WAAW,KAAKvB,WAAW,CAACY,MAAM,IAClCW,WAAW,KAAKvB,WAAW,CAACa,QAAQ,CACrC;EACH;AACF;AAEA,eAAeT,qBAAqB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../../src/EventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,cAAM,YAAY;IAChB,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAK;IAExC,MAAM,CAAC,qCAAqC,CAC1C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAgBnD,MAAM,CAAC,wCAAwC,CAC7C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAKnD,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI;IAItE,OAAO,CAAC,MAAM,CAAC,oCAAoC;CA6BpD;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../../src/EventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,cAAM,YAAY;IAChB,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAK;IAExC,MAAM,CAAC,qCAAqC,CAC1C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAiBnD,MAAM,CAAC,wCAAwC,CAC7C,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAKnD,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI;IAItE,OAAO,CAAC,MAAM,CAAC,oCAAoC;CA6BpD;AAED,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-orientation-director",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "A Modern React Native library that allows you to access orientation",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -1,5 +1,5 @@
1
- import { Platform, type EventSubscription } from 'react-native';
2
- import Module from './module';
1
+ import { type EventSubscription, Platform } from 'react-native';
2
+ import NativeOrientationDirector from './NativeOrientationDirector';
3
3
  import type { OrientationEvent } from './types/OrientationEvent.interface';
4
4
  import type { LockedEvent } from './types/LockedEvent.interface';
5
5
 
@@ -9,7 +9,8 @@ class EventEmitter {
9
9
  static addDeviceOrientationDidChangeListener(
10
10
  callback: (orientation: OrientationEvent) => void
11
11
  ) {
12
- let listener = Module.onDeviceOrientationChanged(callback);
12
+ let listener =
13
+ NativeOrientationDirector.onDeviceOrientationChanged(callback);
13
14
 
14
15
  if (Platform.OS !== 'android') {
15
16
  return listener;
@@ -17,7 +18,7 @@ class EventEmitter {
17
18
 
18
19
  EventEmitter.androidListenerCount++;
19
20
  if (EventEmitter.androidListenerCount === 1) {
20
- Module.enableOrientationSensors();
21
+ NativeOrientationDirector.enableOrientationSensors();
21
22
  }
22
23
 
23
24
  return EventEmitter.createDeviceOrientationListenerProxy(listener);
@@ -26,11 +27,11 @@ class EventEmitter {
26
27
  static addInterfaceOrientationDidChangeListener(
27
28
  callback: (orientation: OrientationEvent) => void
28
29
  ) {
29
- return Module.onInterfaceOrientationChanged(callback);
30
+ return NativeOrientationDirector.onInterfaceOrientationChanged(callback);
30
31
  }
31
32
 
32
33
  static addLockDidChangeListener(callback: (event: LockedEvent) => void) {
33
- return Module.onLockChanged(callback);
34
+ return NativeOrientationDirector.onLockChanged(callback);
34
35
  }
35
36
 
36
37
  private static createDeviceOrientationListenerProxy(
@@ -50,7 +51,7 @@ class EventEmitter {
50
51
  function disableOrientationSensorsIfLastListener() {
51
52
  if (EventEmitter.androidListenerCount === 1) {
52
53
  EventEmitter.androidListenerCount = 0;
53
- Module.disableOrientationSensors();
54
+ NativeOrientationDirector.disableOrientationSensors();
54
55
  return;
55
56
  }
56
57
 
@@ -1,5 +1,5 @@
1
1
  import { Platform } from 'react-native';
2
- import Module from './module';
2
+ import NativeOrientationDirector from './NativeOrientationDirector';
3
3
  import type { HumanReadableOrientationsResource } from './types/HumanReadableOrientationsResource.type';
4
4
  import { Orientation } from './types/Orientation.enum';
5
5
  import { AutoRotation } from './types/AutoRotation.enum';
@@ -39,11 +39,11 @@ class RNOrientationDirector {
39
39
  }
40
40
 
41
41
  static getInterfaceOrientation(): Promise<Orientation> {
42
- return Module.getInterfaceOrientation();
42
+ return NativeOrientationDirector.getInterfaceOrientation();
43
43
  }
44
44
 
45
45
  static getDeviceOrientation(): Promise<Orientation> {
46
- return Module.getDeviceOrientation();
46
+ return NativeOrientationDirector.getDeviceOrientation();
47
47
  }
48
48
 
49
49
  /**
@@ -69,42 +69,42 @@ class RNOrientationDirector {
69
69
  orientationType: OrientationType = OrientationType.interface
70
70
  ) {
71
71
  if (orientationType === OrientationType.interface) {
72
- Module.lockTo(orientation);
72
+ NativeOrientationDirector.lockTo(orientation);
73
73
  return;
74
74
  }
75
75
 
76
76
  if (orientation === Orientation.landscapeLeft) {
77
- Module.lockTo(Orientation.landscapeRight);
77
+ NativeOrientationDirector.lockTo(Orientation.landscapeRight);
78
78
  return;
79
79
  }
80
80
 
81
81
  if (orientation === Orientation.landscapeRight) {
82
- Module.lockTo(Orientation.landscapeLeft);
82
+ NativeOrientationDirector.lockTo(Orientation.landscapeLeft);
83
83
  return;
84
84
  }
85
85
 
86
- Module.lockTo(orientation);
86
+ NativeOrientationDirector.lockTo(orientation);
87
87
  }
88
88
 
89
89
  static unlock() {
90
- Module.unlock();
90
+ NativeOrientationDirector.unlock();
91
91
  }
92
92
 
93
93
  static isLocked() {
94
- return Module.isLocked();
94
+ return NativeOrientationDirector.isLocked();
95
95
  }
96
96
 
97
97
  static isAutoRotationEnabled() {
98
98
  if (Platform.OS !== 'android') {
99
99
  return AutoRotation.unknown;
100
100
  }
101
- return Module.isAutoRotationEnabled()
101
+ return NativeOrientationDirector.isAutoRotationEnabled()
102
102
  ? AutoRotation.enabled
103
103
  : AutoRotation.disabled;
104
104
  }
105
105
 
106
106
  static resetSupportedInterfaceOrientations() {
107
- Module.resetSupportedInterfaceOrientations();
107
+ NativeOrientationDirector.resetSupportedInterfaceOrientations();
108
108
  }
109
109
 
110
110
  static listenForDeviceOrientationChanges(
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- import { NativeModules, Platform } from 'react-native';
4
- const LINKING_ERROR = `The package 'react-native-orientation-director' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
5
- ios: "- You have run 'pod install'\n",
6
- default: ''
7
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
8
-
9
- // @ts-expect-error
10
- const isTurboModuleEnabled = global.__turboModuleProxy != null;
11
- const Module = isTurboModuleEnabled ? require('./NativeOrientationDirector').default : NativeModules.OrientationDirector;
12
- const OrientationDirectorModule = Module ? Module : new Proxy({}, {
13
- get() {
14
- throw new Error(LINKING_ERROR);
15
- }
16
- });
17
- export default OrientationDirectorModule;
18
- //# sourceMappingURL=module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","isTurboModuleEnabled","global","__turboModuleProxy","Module","require","OrientationDirector","OrientationDirectorModule","Proxy","get","Error"],"sourceRoot":"../../src","sources":["module.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAGtD,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,eAAeU,yBAAyB","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import type { Spec } from './NativeOrientationDirector';
2
- declare const _default: Spec;
3
- export default _default;
4
- //# sourceMappingURL=module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;wBA0BZ,IAAI;AAAhD,wBAAiD"}
package/src/module.ts DELETED
@@ -1,28 +0,0 @@
1
- import { NativeModules, Platform } from 'react-native';
2
- import type { Spec } from './NativeOrientationDirector';
3
-
4
- const LINKING_ERROR =
5
- `The package 'react-native-orientation-director' doesn't seem to be linked. Make sure: \n\n` +
6
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
7
- '- You rebuilt the app after installing the package\n' +
8
- '- You are not using Expo Go\n';
9
-
10
- // @ts-expect-error
11
- const isTurboModuleEnabled = global.__turboModuleProxy != null;
12
-
13
- const Module = isTurboModuleEnabled
14
- ? require('./NativeOrientationDirector').default
15
- : NativeModules.OrientationDirector;
16
-
17
- const OrientationDirectorModule = Module
18
- ? Module
19
- : new Proxy(
20
- {},
21
- {
22
- get() {
23
- throw new Error(LINKING_ERROR);
24
- },
25
- }
26
- );
27
-
28
- export default OrientationDirectorModule as Spec;