react-native-orientation-director 2.3.1 → 2.4.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 +10 -6
- package/android/src/main/java/com/orientationdirector/implementation/ConfigurationChangedBroadcastReceiver.kt +14 -1
- package/lib/module/EventEmitter.js +2 -2
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/NativeOrientationDirector.ts +28 -0
- package/lib/module/RNOrientationDirector.js +5 -5
- package/lib/module/RNOrientationDirector.js.map +1 -1
- package/lib/module/hooks/useDeviceOrientation.hook.js +2 -2
- package/lib/module/hooks/useDeviceOrientation.hook.js.map +1 -1
- package/lib/module/hooks/useInterfaceOrientation.hook.js +2 -2
- package/lib/module/hooks/useInterfaceOrientation.hook.js.map +1 -1
- package/lib/module/hooks/useIsInterfaceOrientationLocked.hook.js +1 -1
- package/lib/module/hooks/useIsInterfaceOrientationLocked.hook.js.map +1 -1
- package/lib/module/index.js +7 -7
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/example/src/App.d.ts +2 -0
- package/lib/typescript/example/src/App.d.ts.map +1 -0
- package/lib/typescript/example/src/AppNavigationContainer.d.ts +3 -0
- package/lib/typescript/example/src/AppNavigationContainer.d.ts.map +1 -0
- package/lib/typescript/example/src/screens/Explore.d.ts +3 -0
- package/lib/typescript/example/src/screens/Explore.d.ts.map +1 -0
- package/lib/typescript/example/src/screens/Home.d.ts +3 -0
- package/lib/typescript/example/src/screens/Home.d.ts.map +1 -0
- package/lib/typescript/example/src/screens/InnerExplore.d.ts +3 -0
- package/lib/typescript/example/src/screens/InnerExplore.d.ts.map +1 -0
- package/lib/typescript/example/src/screens/styles.d.ts +51 -0
- package/lib/typescript/example/src/screens/styles.d.ts.map +1 -0
- package/lib/typescript/lib/module/NativeOrientationDirector.d.ts +17 -0
- package/lib/typescript/lib/module/NativeOrientationDirector.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/package.json +20 -15
- package/plugin/build/withRNOrientationMainActivity.js +40 -2
- package/lib/commonjs/EventEmitter.js +0 -50
- package/lib/commonjs/EventEmitter.js.map +0 -1
- package/lib/commonjs/NativeOrientationDirector.js +0 -9
- package/lib/commonjs/NativeOrientationDirector.js.map +0 -1
- package/lib/commonjs/RNOrientationDirector.js +0 -127
- package/lib/commonjs/RNOrientationDirector.js.map +0 -1
- package/lib/commonjs/hooks/useDeviceOrientation.hook.js +0 -39
- package/lib/commonjs/hooks/useDeviceOrientation.hook.js.map +0 -1
- package/lib/commonjs/hooks/useInterfaceOrientation.hook.js +0 -39
- package/lib/commonjs/hooks/useInterfaceOrientation.hook.js.map +0 -1
- package/lib/commonjs/hooks/useIsInterfaceOrientationLocked.hook.js +0 -28
- package/lib/commonjs/hooks/useIsInterfaceOrientationLocked.hook.js.map +0 -1
- package/lib/commonjs/index.js +0 -52
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/module.js +0 -23
- package/lib/commonjs/module.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/commonjs/types/AutoRotation.enum.js +0 -13
- package/lib/commonjs/types/AutoRotation.enum.js.map +0 -1
- package/lib/commonjs/types/Event.enum.js +0 -14
- package/lib/commonjs/types/Event.enum.js.map +0 -1
- package/lib/commonjs/types/HumanReadableAutoRotationsResource.type.js +0 -6
- package/lib/commonjs/types/HumanReadableAutoRotationsResource.type.js.map +0 -1
- package/lib/commonjs/types/HumanReadableOrientationsResource.type.js +0 -6
- package/lib/commonjs/types/HumanReadableOrientationsResource.type.js.map +0 -1
- package/lib/commonjs/types/LockableOrientation.type.js +0 -6
- package/lib/commonjs/types/LockableOrientation.type.js.map +0 -1
- package/lib/commonjs/types/LockedEvent.interface.js +0 -2
- package/lib/commonjs/types/LockedEvent.interface.js.map +0 -1
- package/lib/commonjs/types/Orientation.enum.js +0 -18
- package/lib/commonjs/types/Orientation.enum.js.map +0 -1
- package/lib/commonjs/types/OrientationEvent.interface.js +0 -6
- package/lib/commonjs/types/OrientationEvent.interface.js.map +0 -1
- package/lib/commonjs/types/OrientationType.enum.js +0 -12
- package/lib/commonjs/types/OrientationType.enum.js.map +0 -1
- package/lib/module/NativeOrientationDirector.js +0 -5
- package/lib/module/NativeOrientationDirector.js.map +0 -1
- package/lib/typescript/plugin/src/custom-mod/withBridgingHeader.d.ts +0 -13
- package/lib/typescript/plugin/src/custom-mod/withBridgingHeader.d.ts.map +0 -1
- package/lib/typescript/plugin/src/index.d.ts +0 -4
- package/lib/typescript/plugin/src/index.d.ts.map +0 -1
- package/lib/typescript/plugin/src/withRNOrientationAppDelegate.d.ts +0 -5
- package/lib/typescript/plugin/src/withRNOrientationAppDelegate.d.ts.map +0 -1
- package/lib/typescript/plugin/src/withRNOrientationBridgingHeader.d.ts +0 -4
- package/lib/typescript/plugin/src/withRNOrientationBridgingHeader.d.ts.map +0 -1
- package/lib/typescript/plugin/src/withRNOrientationMainActivity.d.ts +0 -4
- package/lib/typescript/plugin/src/withRNOrientationMainActivity.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -50,7 +50,11 @@ You can install the package like any other Expo package, using the following com
|
|
|
50
50
|
npx expo install react-native-orientation-director
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
## Setup
|
|
54
|
+
|
|
55
|
+
### Expo
|
|
56
|
+
|
|
57
|
+
Simply add the library plugin to your `app.json` file:
|
|
54
58
|
|
|
55
59
|
```json
|
|
56
60
|
{
|
|
@@ -66,9 +70,9 @@ This way, Expo will handle the native setup for you during `prebuild`.
|
|
|
66
70
|
|
|
67
71
|
> Note: only SDK 50 and above are supported, the plugin is configured to handle only the kotlin template.
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
### Bare
|
|
70
74
|
|
|
71
|
-
|
|
75
|
+
#### Android
|
|
72
76
|
|
|
73
77
|
This library uses a custom broadcast receiver to handle the manual orientation changes: when the user disables the
|
|
74
78
|
autorotation feature and the system prompts the user to rotate the device, the library will listen to the broadcast
|
|
@@ -96,12 +100,12 @@ override fun onConfigurationChanged(newConfig: Configuration) {
|
|
|
96
100
|
|
|
97
101
|
Nothing else is required for Android.
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
#### iOS
|
|
100
104
|
|
|
101
105
|
To properly handle interface orientation changes in iOS, you need to update your AppDelegate file. Since React Native
|
|
102
106
|
0.77, the AppDelegate has been migrated to Swift, so see the instructions below for both Swift and Objective-C.
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
##### Objective-C
|
|
105
109
|
|
|
106
110
|
In your AppDelegate.h file, import "OrientationDirector.h" and implement supportedInterfaceOrientationsForWindow method as follows:
|
|
107
111
|
|
|
@@ -114,7 +118,7 @@ In your AppDelegate.h file, import "OrientationDirector.h" and implement support
|
|
|
114
118
|
}
|
|
115
119
|
```
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
##### Swift
|
|
118
122
|
|
|
119
123
|
You need to create a [bridging header](https://developer.apple.com/documentation/swift/importing-objective-c-into-swift#Import-Code-Within-an-App-Target)
|
|
120
124
|
to import the library, as shown below:
|
|
@@ -17,6 +17,8 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
17
17
|
class ConfigurationChangedBroadcastReceiver internal constructor(private val context: ReactApplicationContext) :
|
|
18
18
|
BroadcastReceiver() {
|
|
19
19
|
|
|
20
|
+
private var isRegistered = false
|
|
21
|
+
|
|
20
22
|
private var onReceiveCallback: ((intent: Intent?) -> Unit)? = null
|
|
21
23
|
|
|
22
24
|
override fun onReceive(context: Context?, intent: Intent?) {
|
|
@@ -40,10 +42,21 @@ class ConfigurationChangedBroadcastReceiver internal constructor(private val con
|
|
|
40
42
|
} else {
|
|
41
43
|
context.registerReceiver(this, filter)
|
|
42
44
|
}
|
|
45
|
+
|
|
46
|
+
isRegistered = true
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
fun unregister() {
|
|
46
|
-
|
|
50
|
+
if (!isRegistered) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
context.unregisterReceiver(this)
|
|
56
|
+
} catch(_: IllegalArgumentException) {
|
|
57
|
+
} finally {
|
|
58
|
+
isRegistered = false
|
|
59
|
+
}
|
|
47
60
|
}
|
|
48
61
|
|
|
49
62
|
companion object {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
|
-
import Module, { ModuleEventEmitter } from
|
|
5
|
-
import Event from
|
|
4
|
+
import Module, { ModuleEventEmitter } from "./module.js";
|
|
5
|
+
import Event from "./types/Event.enum.js";
|
|
6
6
|
class EventEmitter {
|
|
7
7
|
static addDeviceOrientationDidChangeListener(callback) {
|
|
8
8
|
let listener = ModuleEventEmitter.addListener(Event.DeviceOrientationDidChange, callback);
|
|
@@ -1 +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,
|
|
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,SA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AAGT,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":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
getInterfaceOrientation(): Promise<number>;
|
|
6
|
+
getDeviceOrientation(): Promise<number>;
|
|
7
|
+
lockTo(orientation: number): void;
|
|
8
|
+
unlock(): void;
|
|
9
|
+
isLocked(): boolean;
|
|
10
|
+
resetSupportedInterfaceOrientations(): void;
|
|
11
|
+
|
|
12
|
+
////////////////////////////////////
|
|
13
|
+
//
|
|
14
|
+
// ANDROID ONLY
|
|
15
|
+
//
|
|
16
|
+
|
|
17
|
+
isAutoRotationEnabled(): boolean;
|
|
18
|
+
enableOrientationSensors(): void;
|
|
19
|
+
disableOrientationSensors(): void;
|
|
20
|
+
|
|
21
|
+
//
|
|
22
|
+
////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
addListener: (eventType: string) => void;
|
|
25
|
+
removeListeners: (count: number) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('OrientationDirector');
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
|
-
import Module from
|
|
5
|
-
import { Orientation } from
|
|
6
|
-
import { AutoRotation } from
|
|
7
|
-
import { OrientationType } from
|
|
8
|
-
import EventEmitter from
|
|
4
|
+
import Module from "./module.js";
|
|
5
|
+
import { Orientation } from "./types/Orientation.enum.js";
|
|
6
|
+
import { AutoRotation } from "./types/AutoRotation.enum.js";
|
|
7
|
+
import { OrientationType } from "./types/OrientationType.enum.js";
|
|
8
|
+
import EventEmitter from "./EventEmitter.js";
|
|
9
9
|
class RNOrientationDirector {
|
|
10
10
|
static _humanReadableOrientationsResource = {
|
|
11
11
|
[Orientation.unknown]: 'Unknown',
|
|
@@ -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,
|
|
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":"../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BA,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,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useRef } from 'react';
|
|
4
|
-
import RNOrientationDirector from
|
|
5
|
-
import { Orientation } from
|
|
4
|
+
import RNOrientationDirector from "../RNOrientationDirector.js";
|
|
5
|
+
import { Orientation } from "../types/Orientation.enum.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Hook that returns the current device orientation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","RNOrientationDirector","Orientation","useDeviceOrientation","initialRender","orientation","setOrientation","useState","unknown","useEffect","current","getDeviceOrientation","then","onChange","event","subscription","listenForDeviceOrientationChanges","remove"],"sourceRoot":"../../../src","sources":["hooks/useDeviceOrientation.hook.ts"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC,OAAOC,qBAAqB,MAAM,
|
|
1
|
+
{"version":3,"names":["React","useRef","RNOrientationDirector","Orientation","useDeviceOrientation","initialRender","orientation","setOrientation","useState","unknown","useEffect","current","getDeviceOrientation","then","onChange","event","subscription","listenForDeviceOrientationChanges","remove"],"sourceRoot":"../../../src","sources":["hooks/useDeviceOrientation.hook.ts"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC,OAAOC,qBAAqB,MAAM,6BAA0B;AAE5D,SAASC,WAAW,QAAQ,8BAA2B;;AAEvD;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACjC,MAAMC,aAAa,GAAGJ,MAAM,CAAC,KAAK,CAAC;EACnC,MAAM,CAACK,WAAW,EAAEC,cAAc,CAAC,GAAGP,KAAK,CAACQ,QAAQ,CAClDL,WAAW,CAACM,OACd,CAAC;EAEDT,KAAK,CAACU,SAAS,CAAC,MAAM;IACpB,IAAIL,aAAa,CAACM,OAAO,EAAE;MACzB;IACF;IAEAN,aAAa,CAACM,OAAO,GAAG,IAAI;IAC5BT,qBAAqB,CAACU,oBAAoB,CAAC,CAAC,CAACC,IAAI,CAACN,cAAc,CAAC;EACnE,CAAC,EAAE,EAAE,CAAC;EAENP,KAAK,CAACU,SAAS,CAAC,MAAM;IACpB,MAAMI,QAAQ,GAAIC,KAAuB,IAAK;MAC5CR,cAAc,CAACQ,KAAK,CAACT,WAAW,CAAC;IACnC,CAAC;IAED,MAAMU,YAAY,GAChBd,qBAAqB,CAACe,iCAAiC,CAACH,QAAQ,CAAC;IACnE,OAAO,MAAM;MACXE,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOZ,WAAW;AACpB,CAAC;AAED,eAAeF,oBAAoB","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useRef } from 'react';
|
|
4
|
-
import RNOrientationDirector from
|
|
5
|
-
import { Orientation } from
|
|
4
|
+
import RNOrientationDirector from "../RNOrientationDirector.js";
|
|
5
|
+
import { Orientation } from "../types/Orientation.enum.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Hook that returns the current interface orientation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","RNOrientationDirector","Orientation","useInterfaceOrientation","initialRender","orientation","setOrientation","useState","unknown","useEffect","current","getInterfaceOrientation","then","onChange","event","subscription","listenForInterfaceOrientationChanges","remove"],"sourceRoot":"../../../src","sources":["hooks/useInterfaceOrientation.hook.ts"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC,OAAOC,qBAAqB,MAAM,
|
|
1
|
+
{"version":3,"names":["React","useRef","RNOrientationDirector","Orientation","useInterfaceOrientation","initialRender","orientation","setOrientation","useState","unknown","useEffect","current","getInterfaceOrientation","then","onChange","event","subscription","listenForInterfaceOrientationChanges","remove"],"sourceRoot":"../../../src","sources":["hooks/useInterfaceOrientation.hook.ts"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC,OAAOC,qBAAqB,MAAM,6BAA0B;AAE5D,SAASC,WAAW,QAAQ,8BAA2B;;AAEvD;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,GAAGA,CAAA,KAAM;EACpC,MAAMC,aAAa,GAAGJ,MAAM,CAAC,KAAK,CAAC;EACnC,MAAM,CAACK,WAAW,EAAEC,cAAc,CAAC,GAAGP,KAAK,CAACQ,QAAQ,CAClDL,WAAW,CAACM,OACd,CAAC;EAEDT,KAAK,CAACU,SAAS,CAAC,MAAM;IACpB,IAAIL,aAAa,CAACM,OAAO,EAAE;MACzB;IACF;IAEAN,aAAa,CAACM,OAAO,GAAG,IAAI;IAC5BT,qBAAqB,CAACU,uBAAuB,CAAC,CAAC,CAACC,IAAI,CAACN,cAAc,CAAC;EACtE,CAAC,EAAE,EAAE,CAAC;EAENP,KAAK,CAACU,SAAS,CAAC,MAAM;IACpB,MAAMI,QAAQ,GAAIC,KAAuB,IAAK;MAC5CR,cAAc,CAACQ,KAAK,CAACT,WAAW,CAAC;IACnC,CAAC;IAED,MAAMU,YAAY,GAChBd,qBAAqB,CAACe,oCAAoC,CAACH,QAAQ,CAAC;IACtE,OAAO,MAAM;MACXE,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOZ,WAAW;AACpB,CAAC;AAED,eAAeF,uBAAuB","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import RNOrientationDirector from
|
|
4
|
+
import RNOrientationDirector from "../RNOrientationDirector.js";
|
|
5
5
|
/**
|
|
6
6
|
* Hook that returns whether the interface is locked.
|
|
7
7
|
* It listens for changes and updates the state accordingly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","RNOrientationDirector","useIsInterfaceOrientationLocked","orientation","setOrientation","useState","isLocked","useEffect","onChange","event","locked","subscription","listenForLockChanges","remove"],"sourceRoot":"../../../src","sources":["hooks/useIsInterfaceOrientationLocked.hook.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,qBAAqB,MAAM,
|
|
1
|
+
{"version":3,"names":["React","RNOrientationDirector","useIsInterfaceOrientationLocked","orientation","setOrientation","useState","isLocked","useEffect","onChange","event","locked","subscription","listenForLockChanges","remove"],"sourceRoot":"../../../src","sources":["hooks/useIsInterfaceOrientationLocked.hook.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,qBAAqB,MAAM,6BAA0B;AAG5D;AACA;AACA;AACA;AACA,MAAMC,+BAA+B,GAAGA,CAAA,KAAM;EAC5C,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGJ,KAAK,CAACK,QAAQ,CAAU,MAC5DJ,qBAAqB,CAACK,QAAQ,CAAC,CACjC,CAAC;EAEDN,KAAK,CAACO,SAAS,CAAC,MAAM;IACpB,MAAMC,QAAQ,GAAIC,KAAkB,IAAK;MACvCL,cAAc,CAACK,KAAK,CAACC,MAAM,CAAC;IAC9B,CAAC;IAED,MAAMC,YAAY,GAAGV,qBAAqB,CAACW,oBAAoB,CAACJ,QAAQ,CAAC;IACzE,OAAO,MAAM;MACXG,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOV,WAAW;AACpB,CAAC;AAED,eAAeD,+BAA+B","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export { Orientation } from
|
|
4
|
-
export { AutoRotation } from
|
|
5
|
-
export { OrientationType } from
|
|
6
|
-
import useDeviceOrientation from
|
|
3
|
+
export { Orientation } from "./types/Orientation.enum.js";
|
|
4
|
+
export { AutoRotation } from "./types/AutoRotation.enum.js";
|
|
5
|
+
export { OrientationType } from "./types/OrientationType.enum.js";
|
|
6
|
+
import useDeviceOrientation from "./hooks/useDeviceOrientation.hook.js";
|
|
7
7
|
export { useDeviceOrientation };
|
|
8
|
-
import useInterfaceOrientation from
|
|
8
|
+
import useInterfaceOrientation from "./hooks/useInterfaceOrientation.hook.js";
|
|
9
9
|
export { useInterfaceOrientation };
|
|
10
|
-
import useIsInterfaceOrientationLocked from
|
|
10
|
+
import useIsInterfaceOrientationLocked from "./hooks/useIsInterfaceOrientationLocked.hook.js";
|
|
11
11
|
export { useIsInterfaceOrientationLocked };
|
|
12
|
-
import RNOrientationDirector from
|
|
12
|
+
import RNOrientationDirector from "./RNOrientationDirector.js";
|
|
13
13
|
export default RNOrientationDirector;
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Orientation","AutoRotation","OrientationType","useDeviceOrientation","useInterfaceOrientation","useIsInterfaceOrientationLocked","RNOrientationDirector"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,
|
|
1
|
+
{"version":3,"names":["Orientation","AutoRotation","OrientationType","useDeviceOrientation","useInterfaceOrientation","useIsInterfaceOrientationLocked","RNOrientationDirector"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,6BAA0B;AACtD,SAASC,YAAY,QAAQ,8BAA2B;AACxD,SAASC,eAAe,QAAQ,iCAA8B;AAE9D,OAAOC,oBAAoB,MAAM,sCAAmC;AACpE,SAASA,oBAAoB;AAE7B,OAAOC,uBAAuB,MAAM,yCAAsC;AAC1E,SAASA,uBAAuB;AAEhC,OAAOC,+BAA+B,MAAM,iDAA8C;AAC1F,SAASA,+BAA+B;AAExC,OAAOC,qBAAqB,MAAM,4BAAyB;AAC3D,eAAeA,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../example/src/App.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,GAAG,4CAE1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppNavigationContainer.d.ts","sourceRoot":"","sources":["../../../../example/src/AppNavigationContainer.tsx"],"names":[],"mappings":"AAOA,iBAAS,sBAAsB,4CA8B9B;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Explore.d.ts","sourceRoot":"","sources":["../../../../../example/src/screens/Explore.tsx"],"names":[],"mappings":"AASA,iBAAS,OAAO,4CAwCf;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../../../../example/src/screens/Home.tsx"],"names":[],"mappings":"AAOA,iBAAS,IAAI,4CAmHZ;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InnerExplore.d.ts","sourceRoot":"","sources":["../../../../../example/src/screens/InnerExplore.tsx"],"names":[],"mappings":"AAMA,iBAAS,YAAY,4CAkBpB;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare const homepageStyle: {
|
|
2
|
+
container: {
|
|
3
|
+
flexGrow: number;
|
|
4
|
+
padding: number;
|
|
5
|
+
};
|
|
6
|
+
marginBottom: {
|
|
7
|
+
marginBottom: number;
|
|
8
|
+
};
|
|
9
|
+
buttonsContainer: {
|
|
10
|
+
flex: number;
|
|
11
|
+
justifyContent: "center";
|
|
12
|
+
};
|
|
13
|
+
text: {
|
|
14
|
+
color: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const exploreStyle: {
|
|
18
|
+
container: {
|
|
19
|
+
flexGrow: number;
|
|
20
|
+
padding: number;
|
|
21
|
+
};
|
|
22
|
+
marginBottom: {
|
|
23
|
+
marginBottom: number;
|
|
24
|
+
};
|
|
25
|
+
text: {
|
|
26
|
+
color: string;
|
|
27
|
+
};
|
|
28
|
+
body: {
|
|
29
|
+
flex: number;
|
|
30
|
+
justifyContent: "center";
|
|
31
|
+
alignItems: "center";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const innerExploreStyle: {
|
|
35
|
+
container: {
|
|
36
|
+
flexGrow: number;
|
|
37
|
+
padding: number;
|
|
38
|
+
};
|
|
39
|
+
marginBottom: {
|
|
40
|
+
marginBottom: number;
|
|
41
|
+
};
|
|
42
|
+
text: {
|
|
43
|
+
color: string;
|
|
44
|
+
};
|
|
45
|
+
body: {
|
|
46
|
+
flex: number;
|
|
47
|
+
justifyContent: "center";
|
|
48
|
+
alignItems: "center";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../example/src/screens/styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;CAexB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;CASvB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;CAE5B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
getInterfaceOrientation(): Promise<number>;
|
|
4
|
+
getDeviceOrientation(): Promise<number>;
|
|
5
|
+
lockTo(orientation: number): void;
|
|
6
|
+
unlock(): void;
|
|
7
|
+
isLocked(): boolean;
|
|
8
|
+
resetSupportedInterfaceOrientations(): void;
|
|
9
|
+
isAutoRotationEnabled(): boolean;
|
|
10
|
+
enableOrientationSensors(): void;
|
|
11
|
+
disableOrientationSensors(): void;
|
|
12
|
+
addListener: (eventType: string) => void;
|
|
13
|
+
removeListeners: (count: number) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const _default: Spec;
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=NativeOrientationDirector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeOrientationDirector.d.ts","sourceRoot":"","sources":["../../../module/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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-orientation-director",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "A Modern React Native library that allows you to access orientation",
|
|
5
|
-
"main": "lib/
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
7
|
"types": "lib/typescript/src/index.d.ts",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"source": "./src/index.tsx",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
12
|
+
"default": "./lib/module/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
10
16
|
"files": [
|
|
11
17
|
"src",
|
|
12
18
|
"lib",
|
|
@@ -59,10 +65,10 @@
|
|
|
59
65
|
"devDependencies": {
|
|
60
66
|
"@commitlint/config-conventional": "^17.0.2",
|
|
61
67
|
"@evilmartians/lefthook": "^1.5.0",
|
|
62
|
-
"@react-native/eslint-config": "0.
|
|
68
|
+
"@react-native/eslint-config": "0.78.2",
|
|
63
69
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
64
70
|
"@types/jest": "^29.5.5",
|
|
65
|
-
"@types/react": "^
|
|
71
|
+
"@types/react": "^19.0.0",
|
|
66
72
|
"commitlint": "^17.0.2",
|
|
67
73
|
"del-cli": "^5.1.0",
|
|
68
74
|
"eslint": "^8.51.0",
|
|
@@ -71,15 +77,15 @@
|
|
|
71
77
|
"expo": "^52.0.35",
|
|
72
78
|
"jest": "^29.7.0",
|
|
73
79
|
"prettier": "^3.0.3",
|
|
74
|
-
"react": "
|
|
75
|
-
"react-native": "0.
|
|
76
|
-
"react-native-builder-bob": "^0.
|
|
80
|
+
"react": "19.0.0",
|
|
81
|
+
"react-native": "0.78.2",
|
|
82
|
+
"react-native-builder-bob": "^0.40.0",
|
|
77
83
|
"release-it": "^15.0.0",
|
|
78
84
|
"turbo": "^1.10.7",
|
|
79
85
|
"typescript": "^5.2.2"
|
|
80
86
|
},
|
|
81
87
|
"resolutions": {
|
|
82
|
-
"@types/react": "^
|
|
88
|
+
"@types/react": "^19.0.0",
|
|
83
89
|
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
|
84
90
|
"@typescript-eslint/parser": "^7.1.1"
|
|
85
91
|
},
|
|
@@ -178,14 +184,13 @@
|
|
|
178
184
|
"source": "src",
|
|
179
185
|
"output": "lib",
|
|
180
186
|
"targets": [
|
|
181
|
-
"commonjs",
|
|
182
|
-
"module",
|
|
183
187
|
[
|
|
184
|
-
"
|
|
188
|
+
"module",
|
|
185
189
|
{
|
|
186
|
-
"
|
|
190
|
+
"esm": true
|
|
187
191
|
}
|
|
188
|
-
]
|
|
192
|
+
],
|
|
193
|
+
"typescript"
|
|
189
194
|
]
|
|
190
195
|
},
|
|
191
196
|
"codegenConfig": {
|
|
@@ -23,11 +23,12 @@ function getCompatibleFileUpdater(language) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
function ktFileUpdater(originalContents) {
|
|
26
|
-
const
|
|
26
|
+
const systemImportsContents = updateContentsWithSystemImports(originalContents);
|
|
27
|
+
const libraryImportCodeBlock = 'import com.orientationdirector.implementation.ConfigurationChangedBroadcastReceiver';
|
|
27
28
|
const rightBeforeClassDeclaration = /class MainActivity/g;
|
|
28
29
|
const importMergeResults = (0, generateCode_1.mergeContents)({
|
|
29
30
|
tag: '@react-native-orientation-director/library-import',
|
|
30
|
-
src:
|
|
31
|
+
src: systemImportsContents,
|
|
31
32
|
newSrc: libraryImportCodeBlock,
|
|
32
33
|
anchor: rightBeforeClassDeclaration,
|
|
33
34
|
offset: 0,
|
|
@@ -60,3 +61,40 @@ function ktFileUpdater(originalContents) {
|
|
|
60
61
|
});
|
|
61
62
|
return implementationMergeResults.contents;
|
|
62
63
|
}
|
|
64
|
+
function updateContentsWithSystemImports(originalContents) {
|
|
65
|
+
const rightBeforeClassDeclaration = /class MainActivity/g;
|
|
66
|
+
let possibleUpdatedContents = originalContents;
|
|
67
|
+
possibleUpdatedContents = addIntentImportIfNecessary(possibleUpdatedContents);
|
|
68
|
+
possibleUpdatedContents = addConfigurationImportIfNecessary(possibleUpdatedContents);
|
|
69
|
+
return possibleUpdatedContents;
|
|
70
|
+
function addIntentImportIfNecessary(_contents) {
|
|
71
|
+
const systemIntentImportCodeBlock = 'import android.content.Intent';
|
|
72
|
+
if (_contents.includes(systemIntentImportCodeBlock)) {
|
|
73
|
+
return _contents;
|
|
74
|
+
}
|
|
75
|
+
const mergeResults = (0, generateCode_1.mergeContents)({
|
|
76
|
+
tag: '@react-native-orientation-director/system-intent-import',
|
|
77
|
+
src: _contents,
|
|
78
|
+
newSrc: systemIntentImportCodeBlock,
|
|
79
|
+
anchor: rightBeforeClassDeclaration,
|
|
80
|
+
offset: 0,
|
|
81
|
+
comment: '// React Native Orientation Director',
|
|
82
|
+
});
|
|
83
|
+
return mergeResults.contents;
|
|
84
|
+
}
|
|
85
|
+
function addConfigurationImportIfNecessary(_contents) {
|
|
86
|
+
const systemConfigurationImportCodeBlock = 'import android.content.res.Configuration';
|
|
87
|
+
if (possibleUpdatedContents.includes(systemConfigurationImportCodeBlock)) {
|
|
88
|
+
return _contents;
|
|
89
|
+
}
|
|
90
|
+
const mergeResults = (0, generateCode_1.mergeContents)({
|
|
91
|
+
tag: '@react-native-orientation-director/system-configuration-import',
|
|
92
|
+
src: possibleUpdatedContents,
|
|
93
|
+
newSrc: systemConfigurationImportCodeBlock,
|
|
94
|
+
anchor: rightBeforeClassDeclaration,
|
|
95
|
+
offset: 0,
|
|
96
|
+
comment: '// React Native Orientation Director',
|
|
97
|
+
});
|
|
98
|
+
return mergeResults.contents;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
var _module = _interopRequireWildcard(require("./module"));
|
|
9
|
-
var _Event = _interopRequireDefault(require("./types/Event.enum"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
-
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
|
-
class EventEmitter {
|
|
14
|
-
static addDeviceOrientationDidChangeListener(callback) {
|
|
15
|
-
let listener = _module.ModuleEventEmitter.addListener(_Event.default.DeviceOrientationDidChange, callback);
|
|
16
|
-
if (_reactNative.Platform.OS !== 'android') {
|
|
17
|
-
return listener;
|
|
18
|
-
}
|
|
19
|
-
const listenerCount = _module.ModuleEventEmitter.listenerCount(_Event.default.DeviceOrientationDidChange);
|
|
20
|
-
if (listenerCount === 1) {
|
|
21
|
-
_module.default.enableOrientationSensors();
|
|
22
|
-
}
|
|
23
|
-
return EventEmitter.createDeviceOrientationListenerProxy(listener);
|
|
24
|
-
}
|
|
25
|
-
static addInterfaceOrientationDidChangeListener(callback) {
|
|
26
|
-
return _module.ModuleEventEmitter.addListener(_Event.default.InterfaceOrientationDidChange, callback);
|
|
27
|
-
}
|
|
28
|
-
static addLockDidChangeListener(callback) {
|
|
29
|
-
return _module.ModuleEventEmitter.addListener(_Event.default.LockDidChange, callback);
|
|
30
|
-
}
|
|
31
|
-
static createDeviceOrientationListenerProxy(listener) {
|
|
32
|
-
const handler = {
|
|
33
|
-
get(target, propertyKey, receiver) {
|
|
34
|
-
if (propertyKey === 'remove') {
|
|
35
|
-
disableOrientationSensorsIfLastListener();
|
|
36
|
-
}
|
|
37
|
-
return Reflect.get(target, propertyKey, receiver);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
return new Proxy(listener, handler);
|
|
41
|
-
function disableOrientationSensorsIfLastListener() {
|
|
42
|
-
const listenerCount = _module.ModuleEventEmitter.listenerCount(_Event.default.DeviceOrientationDidChange);
|
|
43
|
-
if (listenerCount === 1) {
|
|
44
|
-
_module.default.disableOrientationSensors();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
var _default = exports.default = EventEmitter;
|
|
50
|
-
//# sourceMappingURL=EventEmitter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_module","_interopRequireWildcard","_Event","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","EventEmitter","addDeviceOrientationDidChangeListener","callback","listener","ModuleEventEmitter","addListener","Event","DeviceOrientationDidChange","Platform","OS","listenerCount","Module","enableOrientationSensors","createDeviceOrientationListenerProxy","addInterfaceOrientationDidChangeListener","InterfaceOrientationDidChange","addLockDidChangeListener","LockDidChange","handler","target","propertyKey","receiver","disableOrientationSensorsIfLastListener","Reflect","Proxy","disableOrientationSensors","_default","exports"],"sourceRoot":"../../src","sources":["EventEmitter.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAuC,SAAAI,uBAAAC,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,SAAAH,wBAAAG,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,CAAAE,wBAAA,CAAAd,CAAA,EAAAe,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA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,MAAM,EAAEC,WAAW,EAAEC,QAAQ,CAAC;MACnD;IACF,CAAC;IAED,OAAO,IAAIG,KAAK,CAACrB,QAAQ,EAAEe,OAAO,CAAC;IAEnC,SAASI,uCAAuCA,CAAA,EAAG;MACjD,MAAMZ,aAAa,GAAGN,0BAAkB,CAACM,aAAa,CACpDJ,cAAK,CAACC,0BACR,CAAC;MAED,IAAIG,aAAa,KAAK,CAAC,EAAE;QACvBC,eAAM,CAACc,yBAAyB,CAAC,CAAC;MACpC;IACF;EACF;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7C,OAAA,GAEckB,YAAY","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('OrientationDirector');
|
|
9
|
-
//# sourceMappingURL=NativeOrientationDirector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOrientationDirector.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GA0BpCC,gCAAmB,CAACC,YAAY,CAAO,qBAAqB,CAAC","ignoreList":[]}
|