react-native-orientation-director 3.0.0 → 3.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/ios/OrientationDirector.mm +21 -6
- package/ios/implementation/EventManager.swift +5 -5
- package/lib/module/EventEmitter.js +6 -6
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/RNOrientationDirector.js +11 -11
- package/lib/module/RNOrientationDirector.js.map +1 -1
- package/lib/typescript/src/EventEmitter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EventEmitter.ts +8 -7
- package/src/RNOrientationDirector.ts +11 -11
- package/lib/module/module.js +0 -18
- package/lib/module/module.js.map +0 -1
- package/lib/typescript/src/module.d.ts +0 -4
- package/lib/typescript/src/module.d.ts.map +0 -1
- package/src/module.ts +0 -28
|
@@ -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
|
-
|
|
47
|
-
|
|
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)
|
|
51
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|
|
44
|
-
func
|
|
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
|
|
4
|
+
import NativeOrientationDirector from "./NativeOrientationDirector.js";
|
|
5
5
|
class EventEmitter {
|
|
6
6
|
static androidListenerCount = 0;
|
|
7
7
|
static addDeviceOrientationDidChangeListener(callback) {
|
|
8
|
-
let listener =
|
|
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
|
-
|
|
14
|
+
NativeOrientationDirector.enableOrientationSensors();
|
|
15
15
|
}
|
|
16
16
|
return EventEmitter.createDeviceOrientationListenerProxy(listener);
|
|
17
17
|
}
|
|
18
18
|
static addInterfaceOrientationDidChangeListener(callback) {
|
|
19
|
-
return
|
|
19
|
+
return NativeOrientationDirector.onInterfaceOrientationChanged(callback);
|
|
20
20
|
}
|
|
21
21
|
static addLockDidChangeListener(callback) {
|
|
22
|
-
return
|
|
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
|
-
|
|
37
|
+
NativeOrientationDirector.disableOrientationSensors();
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
if (EventEmitter.androidListenerCount === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","
|
|
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
|
|
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
|
|
32
|
+
return NativeOrientationDirector.getInterfaceOrientation();
|
|
33
33
|
}
|
|
34
34
|
static getDeviceOrientation() {
|
|
35
|
-
return
|
|
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
|
-
|
|
58
|
+
NativeOrientationDirector.lockTo(orientation);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
if (orientation === Orientation.landscapeLeft) {
|
|
62
|
-
|
|
62
|
+
NativeOrientationDirector.lockTo(Orientation.landscapeRight);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
if (orientation === Orientation.landscapeRight) {
|
|
66
|
-
|
|
66
|
+
NativeOrientationDirector.lockTo(Orientation.landscapeLeft);
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
NativeOrientationDirector.lockTo(orientation);
|
|
70
70
|
}
|
|
71
71
|
static unlock() {
|
|
72
|
-
|
|
72
|
+
NativeOrientationDirector.unlock();
|
|
73
73
|
}
|
|
74
74
|
static isLocked() {
|
|
75
|
-
return
|
|
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
|
|
81
|
+
return NativeOrientationDirector.isAutoRotationEnabled() ? AutoRotation.enabled : AutoRotation.disabled;
|
|
82
82
|
}
|
|
83
83
|
static resetSupportedInterfaceOrientations() {
|
|
84
|
-
|
|
84
|
+
NativeOrientationDirector.resetSupportedInterfaceOrientations();
|
|
85
85
|
}
|
|
86
86
|
static listenForDeviceOrientationChanges(callback) {
|
|
87
87
|
return EventEmitter.addDeviceOrientationDidChangeListener(callback);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","
|
|
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":"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","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../../src/EventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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
package/src/EventEmitter.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
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 =
|
|
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
|
-
|
|
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
|
|
30
|
+
return NativeOrientationDirector.onInterfaceOrientationChanged(callback);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
static addLockDidChangeListener(callback: (event: LockedEvent) => void) {
|
|
33
|
-
return
|
|
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
|
-
|
|
54
|
+
NativeOrientationDirector.disableOrientationSensors();
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
-
import
|
|
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
|
|
42
|
+
return NativeOrientationDirector.getInterfaceOrientation();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
static getDeviceOrientation(): Promise<Orientation> {
|
|
46
|
-
return
|
|
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
|
-
|
|
72
|
+
NativeOrientationDirector.lockTo(orientation);
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (orientation === Orientation.landscapeLeft) {
|
|
77
|
-
|
|
77
|
+
NativeOrientationDirector.lockTo(Orientation.landscapeRight);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
if (orientation === Orientation.landscapeRight) {
|
|
82
|
-
|
|
82
|
+
NativeOrientationDirector.lockTo(Orientation.landscapeLeft);
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
NativeOrientationDirector.lockTo(orientation);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
static unlock() {
|
|
90
|
-
|
|
90
|
+
NativeOrientationDirector.unlock();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
static isLocked() {
|
|
94
|
-
return
|
|
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
|
|
101
|
+
return NativeOrientationDirector.isAutoRotationEnabled()
|
|
102
102
|
? AutoRotation.enabled
|
|
103
103
|
: AutoRotation.disabled;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
static resetSupportedInterfaceOrientations() {
|
|
107
|
-
|
|
107
|
+
NativeOrientationDirector.resetSupportedInterfaceOrientations();
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
static listenForDeviceOrientationChanges(
|
package/lib/module/module.js
DELETED
|
@@ -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
|
package/lib/module/module.js.map
DELETED
|
@@ -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 +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;
|