expo-screen-orientation 5.1.1 → 5.2.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/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 5.2.0 — 2023-05-08
14
+
15
+ ### 🎉 New features
16
+
17
+ - Migrated to new modules API on Android ([#22019](https://github.com/expo/expo/pull/22019) by [@behenate](https://github.com/behenate))
18
+
13
19
  ## 5.1.1 — 2023-02-09
14
20
 
15
21
  _This version does not introduce any user-facing changes._
package/README.md CHANGED
@@ -9,7 +9,7 @@ Allows you to manage the orientation of your app's interface.
9
9
 
10
10
  # Installation in managed Expo projects
11
11
 
12
- For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/screen-orientation/). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
12
+ For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/screen-orientation/). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
13
13
 
14
14
  # Installation in bare React Native projects
15
15
 
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '5.1.1'
6
+ version = '5.2.0'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -74,7 +74,7 @@ android {
74
74
  minSdkVersion safeExtGet("minSdkVersion", 21)
75
75
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
76
76
  versionCode 7
77
- versionName '5.1.1'
77
+ versionName '5.2.0'
78
78
  }
79
79
  lintOptions {
80
80
  abortOnError false
@@ -0,0 +1,12 @@
1
+ package expo.modules.screenorientation
2
+
3
+ import expo.modules.kotlin.exception.CodedException
4
+
5
+ internal class InvalidOrientationLockException(orientationLock: Int, cause: Exception) :
6
+ CodedException("An invalid OrientationLock was passed in: $orientationLock", cause)
7
+
8
+ internal class GetOrientationLockException(cause: Exception) :
9
+ CodedException("Could not get the current screen orientation lock: ", cause)
10
+
11
+ internal class GetPlatformOrientationLockException(cause: Exception) :
12
+ CodedException("Could not get the current screen orientation platform lock", cause)
@@ -1,146 +1,113 @@
1
1
  package expo.modules.screenorientation
2
2
 
3
3
  import android.app.Activity
4
- import android.content.Context
5
- import android.content.pm.ActivityInfo
4
+ import android.os.Build
6
5
  import android.util.DisplayMetrics
7
6
  import android.view.Surface
8
- import expo.modules.core.ExportedModule
9
- import expo.modules.core.ModuleRegistry
10
- import expo.modules.core.Promise
7
+ import android.view.WindowInsets
8
+
11
9
  import expo.modules.core.errors.InvalidArgumentException
12
- import expo.modules.core.interfaces.ActivityProvider
13
- import expo.modules.core.interfaces.ExpoMethod
14
10
  import expo.modules.core.interfaces.LifecycleEventListener
15
11
  import expo.modules.core.interfaces.services.UIManager
16
-
17
- private const val ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK = "ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK"
18
- private const val ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK = "ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK"
19
- private const val ERR_SCREEN_ORIENTATION_GET_ORIENTATION_LOCK = "ERR_SCREEN_ORIENTATION_GET_ORIENTATION_LOCK"
20
- private const val ERR_SCREEN_ORIENTATION_GET_PLATFORM_ORIENTATION_LOCK = "ERR_SCREEN_ORIENTATION_GET_PLATFORM_ORIENTATION_LOCK"
21
- private const val ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY = "ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY"
22
-
23
- class ScreenOrientationModule(context: Context) : ExportedModule(context), LifecycleEventListener {
24
- private lateinit var mActivityProvider: ActivityProvider
25
- private var mInitialOrientation: Int? = null
26
-
27
- override fun getName() = "ExpoScreenOrientation"
28
-
29
- override fun onCreate(moduleRegistry: ModuleRegistry) {
30
- mActivityProvider = moduleRegistry.getModule(ActivityProvider::class.java)
31
- ?: throw IllegalStateException("Could not find implementation for ActivityProvider.")
32
-
33
- (
34
- moduleRegistry.getModule(UIManager::class.java)
35
- ?: throw IllegalStateException("Could not find implementation for UIManager.")
36
- )
37
- .registerLifecycleEventListener(this)
38
- }
39
-
40
- override fun onHostResume() {
41
- mActivityProvider.currentActivity?.let {
42
- if (mInitialOrientation == null) {
43
- mInitialOrientation = it.requestedOrientation
12
+ import expo.modules.kotlin.exception.Exceptions
13
+ import expo.modules.kotlin.modules.Module
14
+ import expo.modules.kotlin.modules.ModuleDefinition
15
+ import expo.modules.screenorientation.enums.Orientation
16
+ import expo.modules.screenorientation.enums.OrientationAttr
17
+ import expo.modules.screenorientation.enums.OrientationLock
18
+
19
+ class ScreenOrientationModule : Module(), LifecycleEventListener {
20
+ private val currentActivity
21
+ get() = appContext.activityProvider?.currentActivity ?: throw Exceptions.MissingActivity()
22
+ private val uiManager
23
+ get() = appContext.legacyModuleRegistry.getModule(UIManager::class.java)
24
+ ?: throw IllegalStateException("Could not find implementation for UIManager.")
25
+
26
+ private var initialOrientation: Int? = null
27
+
28
+ override fun definition() = ModuleDefinition {
29
+ Name("ExpoScreenOrientation")
30
+
31
+ AsyncFunction("lockAsync") { orientationLock: OrientationLock ->
32
+ try {
33
+ currentActivity.requestedOrientation = orientationLock.toPlatformInt()
34
+ } catch (e: InvalidArgumentException) {
35
+ throw InvalidOrientationLockException(orientationLock.value, e)
44
36
  }
45
37
  }
46
- }
47
-
48
- override fun onHostPause() = Unit
49
38
 
50
- override fun onHostDestroy() = Unit
39
+ AsyncFunction("lockPlatformAsync") { orientationAttr: OrientationAttr ->
40
+ currentActivity.requestedOrientation = orientationAttr.value
41
+ }
51
42
 
52
- override fun onDestroy() {
53
- mActivityProvider.currentActivity?.let { activity ->
54
- mInitialOrientation?.let {
55
- activity.requestedOrientation = it
56
- }
43
+ AsyncFunction("getOrientationAsync") {
44
+ return@AsyncFunction getScreenOrientation(currentActivity).value
57
45
  }
58
- }
59
46
 
60
- @ExpoMethod
61
- fun lockAsync(orientationLock: Int, promise: Promise) {
62
- mActivityProvider.currentActivity?.let {
63
- return try {
64
- it.requestedOrientation = importOrientationLock(orientationLock)
65
- promise.resolve(null)
66
- } catch (e: InvalidArgumentException) {
67
- promise.reject(ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK, "An invalid OrientationLock was passed in: $orientationLock", e)
47
+ AsyncFunction("getOrientationLockAsync") {
48
+ try {
49
+ return@AsyncFunction OrientationLock.fromPlatformInt(currentActivity.requestedOrientation)
68
50
  } catch (e: Exception) {
69
- promise.reject(ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK, "Could not apply the ScreenOrientation lock: $orientationLock", e)
51
+ throw GetOrientationLockException(e)
70
52
  }
71
53
  }
72
54
 
73
- promise.reject(ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY, "Could not find activity.", null)
74
- }
75
-
76
- @ExpoMethod
77
- fun lockPlatformAsync(orientationAttr: Int, promise: Promise) {
78
- mActivityProvider.currentActivity?.let {
79
- return try {
80
- it.requestedOrientation = orientationAttr
81
- promise.resolve(null)
55
+ AsyncFunction("getPlatformOrientationLockAsync") {
56
+ try {
57
+ return@AsyncFunction currentActivity.requestedOrientation
82
58
  } catch (e: Exception) {
83
- promise.reject(ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK, "Could not apply the ScreenOrientation platform lock: $orientationAttr", e)
59
+ throw GetPlatformOrientationLockException(e)
84
60
  }
85
61
  }
86
62
 
87
- promise.reject(ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY, "Could not find activity.", null)
88
- }
89
-
90
- @ExpoMethod
91
- fun getOrientationAsync(promise: Promise) {
92
- mActivityProvider.currentActivity?.let {
93
- return promise.resolve(getScreenOrientation(it).value)
63
+ AsyncFunction("supportsOrientationLockAsync") { orientationLock: Int ->
64
+ return@AsyncFunction OrientationLock.supportsOrientationLock(orientationLock)
94
65
  }
95
66
 
96
- promise.reject(ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY, "Could not find activity.", null)
97
- }
98
-
99
- @ExpoMethod
100
- fun getOrientationLockAsync(promise: Promise) {
101
- mActivityProvider.currentActivity?.let {
102
- return try {
103
- promise.resolve(exportOrientationLock(it.requestedOrientation))
104
- } catch (e: Exception) {
105
- promise.reject(ERR_SCREEN_ORIENTATION_GET_ORIENTATION_LOCK, "Could not get the current screen orientation lock", e)
106
- }
67
+ OnCreate {
68
+ uiManager.registerLifecycleEventListener(this@ScreenOrientationModule)
107
69
  }
108
70
 
109
- promise.reject(ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY, "Could not find activity.", null)
110
- }
111
-
112
- @ExpoMethod
113
- fun getPlatformOrientationLockAsync(promise: Promise) {
114
- mActivityProvider.currentActivity?.let {
115
- return try {
116
- promise.resolve(it.requestedOrientation)
117
- } catch (e: Exception) {
118
- promise.reject(ERR_SCREEN_ORIENTATION_GET_PLATFORM_ORIENTATION_LOCK, "Could not get the current screen orientation platform lock", e)
71
+ OnDestroy {
72
+ uiManager.unregisterLifecycleEventListener(this@ScreenOrientationModule)
73
+ initialOrientation?.let {
74
+ currentActivity.requestedOrientation = it
119
75
  }
120
76
  }
121
-
122
- promise.reject(ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY, "Could not find activity.", null)
123
77
  }
124
78
 
125
- @ExpoMethod
126
- fun supportsOrientationLockAsync(orientationLock: Int, promise: Promise) {
127
- try {
128
- importOrientationLock(orientationLock)
129
- promise.resolve(true)
130
- } catch (e: Exception) {
131
- promise.resolve(false)
132
- }
79
+ override fun onHostResume() {
80
+ initialOrientation = initialOrientation ?: currentActivity.requestedOrientation
133
81
  }
134
82
 
83
+ override fun onHostPause() = Unit
84
+
85
+ override fun onHostDestroy() = Unit
86
+
135
87
  // https://stackoverflow.com/a/10383164/1123156
136
88
  // Will not work in all cases as surface rotation is not standardized across android devices, but this is best effort
137
89
  private fun getScreenOrientation(activity: Activity): Orientation {
138
90
  val windowManager = activity.windowManager ?: return Orientation.UNKNOWN
139
- val rotation = windowManager.defaultDisplay.rotation
140
- val dm = DisplayMetrics().also(windowManager.defaultDisplay::getMetrics)
141
91
 
142
- val currentOrientation: Orientation
92
+ val rotation = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
93
+ currentActivity.window.context.display?.rotation ?: return Orientation.UNKNOWN
94
+ } else {
95
+ windowManager.defaultDisplay.rotation
96
+ }
97
+
98
+ val dm = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
99
+ val windowMetrics = windowManager.currentWindowMetrics
100
+ val insets = windowMetrics.windowInsets
101
+ .getInsetsIgnoringVisibility(WindowInsets.Type.systemBars())
102
+ DisplayMetrics().apply {
103
+ widthPixels = windowMetrics.bounds.width() - insets.left - insets.right
104
+ heightPixels = windowMetrics.bounds.height() - insets.top - insets.bottom
105
+ }
106
+ } else {
107
+ DisplayMetrics().also(windowManager.defaultDisplay::getMetrics)
108
+ }
143
109
 
110
+ val currentOrientation: Orientation
144
111
  if (isPortraitNaturalOrientation(rotation, dm.widthPixels, dm.heightPixels)) {
145
112
  currentOrientation = when (rotation) {
146
113
  Surface.ROTATION_0 -> Orientation.PORTRAIT_UP
@@ -172,33 +139,4 @@ class ScreenOrientationModule(context: Context) : ExportedModule(context), Lifec
172
139
  height > width || (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) &&
173
140
  width > height
174
141
  }
175
-
176
- private fun exportOrientationLock(nativeOrientationLock: Int): Int {
177
- return when (nativeOrientationLock) {
178
- ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED -> 0
179
- ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR -> 1
180
- ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT -> 2
181
- ActivityInfo.SCREEN_ORIENTATION_PORTRAIT -> 3
182
- ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT -> 4
183
- ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE -> 5
184
- ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE -> 6
185
- ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE -> 7
186
- else -> 8 // other orientation
187
- }
188
- }
189
-
190
- @Throws(InvalidArgumentException::class)
191
- private fun importOrientationLock(orientationLock: Int): Int {
192
- return when (orientationLock) {
193
- 0 -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
194
- 1 -> ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
195
- 2 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
196
- 3 -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
197
- 4 -> ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
198
- 5 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
199
- 6 -> ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
200
- 7 -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
201
- else -> throw InvalidArgumentException("OrientationLock $orientationLock is not mappable to a native Android orientation attr")
202
- }
203
- }
204
142
  }
@@ -1,4 +1,4 @@
1
- package expo.modules.screenorientation
1
+ package expo.modules.screenorientation.enums
2
2
 
3
3
  /*
4
4
  * Enum representing a screen orientation.
@@ -0,0 +1,39 @@
1
+ package expo.modules.screenorientation.enums
2
+
3
+ import android.content.pm.ActivityInfo
4
+ import expo.modules.core.errors.InvalidArgumentException
5
+ import expo.modules.kotlin.types.Enumerable
6
+
7
+ enum class OrientationAttr(val value: Int) : Enumerable {
8
+ Behind(ActivityInfo.SCREEN_ORIENTATION_BEHIND),
9
+ Landscape(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE),
10
+ Portrait(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT),
11
+ FullSensor(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR),
12
+ Unspecified(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED),
13
+ Locked(ActivityInfo.SCREEN_ORIENTATION_LOCKED),
14
+ FullUser(ActivityInfo.SCREEN_ORIENTATION_FULL_USER),
15
+ NoSensor(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR),
16
+ ReverseLandscape(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE),
17
+ ReversePortrait(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT),
18
+ Sensor(ActivityInfo.SCREEN_ORIENTATION_SENSOR),
19
+ SensorPortrait(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT),
20
+ SensorLandscape(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE),
21
+ User(ActivityInfo.SCREEN_ORIENTATION_USER),
22
+ UserPortrait(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT),
23
+ UserLandscape(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);
24
+
25
+ internal fun toOrientationLock() = try {
26
+ OrientationLock.values().first { it.name == this@OrientationAttr.name }
27
+ } catch (e: NoSuchElementException) {
28
+ OrientationLock.Other
29
+ }
30
+
31
+ companion object {
32
+ @Throws(InvalidArgumentException::class)
33
+ fun fromInt(value: Int) = try {
34
+ OrientationAttr.values().first { it.value == value }
35
+ } catch (e: NoSuchElementException) {
36
+ throw InvalidArgumentException("Platform orientation $value is not a valid Android orientation attr")
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,39 @@
1
+ package expo.modules.screenorientation.enums
2
+
3
+ import expo.modules.core.errors.InvalidArgumentException
4
+ import expo.modules.kotlin.types.Enumerable
5
+
6
+ enum class OrientationLock(val value: Int) : Enumerable {
7
+ Unspecified(0),
8
+ FullSensor(1),
9
+ SensorPortrait(2),
10
+ Portrait(3),
11
+ ReversePortrait(4),
12
+ SensorLandscape(5),
13
+ ReverseLandscape(6),
14
+ Landscape(7),
15
+ Other(8),
16
+
17
+ // Not used for anything in the native code, but it should be possible to assign an "Unknown" value to OrientationLock
18
+ // https://docs.expo.dev/versions/latest/sdk/screen-orientation/#unknown-1
19
+ Unknown(9);
20
+
21
+ @Throws(InvalidArgumentException::class)
22
+ internal fun toOrientationAttr() = try {
23
+ OrientationAttr.values().first { it.name == this@OrientationLock.name }
24
+ } catch (e: NoSuchElementException) {
25
+ throw InvalidArgumentException("OrientationLock ${this@OrientationLock} is not mappable to a native Android orientation attr")
26
+ }
27
+
28
+ @Throws(InvalidArgumentException::class)
29
+ internal fun toPlatformInt() = toOrientationAttr().value
30
+
31
+ companion object {
32
+ @Throws(InvalidArgumentException::class)
33
+ fun fromPlatformInt(value: Int) = OrientationAttr.fromInt(value).toOrientationLock()
34
+
35
+ // Other and Unknown can be assigned but are not valid orientation locks
36
+ fun supportsOrientationLock(value: Int): Boolean =
37
+ OrientationLock.values().any { it.value == value } && value != Other.value && value != Unknown.value
38
+ }
39
+ }
@@ -1,3 +1,3 @@
1
- declare const _default: import("expo-modules-core").ProxyNativeModule;
1
+ declare const _default: any;
2
2
  export default _default;
3
3
  //# sourceMappingURL=ExpoScreenOrientation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoScreenOrientation.d.ts","sourceRoot":"","sources":["../src/ExpoScreenOrientation.ts"],"names":[],"mappings":";AAEA,wBAA8D"}
1
+ {"version":3,"file":"ExpoScreenOrientation.d.ts","sourceRoot":"","sources":["../src/ExpoScreenOrientation.ts"],"names":[],"mappings":";AAGA,wBAEmD"}
@@ -1,3 +1,6 @@
1
- import { NativeModulesProxy } from 'expo-modules-core';
2
- export default NativeModulesProxy.ExpoScreenOrientation || {};
1
+ import { NativeModulesProxy, requireNativeModule } from 'expo-modules-core';
2
+ import { Platform } from 'react-native';
3
+ export default Platform.OS === 'android'
4
+ ? requireNativeModule('ExpoScreenOrientation')
5
+ : NativeModulesProxy.ExpoScreenOrientation || {};
3
6
  //# sourceMappingURL=ExpoScreenOrientation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoScreenOrientation.js","sourceRoot":"","sources":["../src/ExpoScreenOrientation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,eAAe,kBAAkB,CAAC,qBAAqB,IAAI,EAAE,CAAC","sourcesContent":["import { NativeModulesProxy } from 'expo-modules-core';\n\nexport default NativeModulesProxy.ExpoScreenOrientation || {};\n"]}
1
+ {"version":3,"file":"ExpoScreenOrientation.js","sourceRoot":"","sources":["../src/ExpoScreenOrientation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,eAAe,QAAQ,CAAC,EAAE,KAAK,SAAS;IACtC,CAAC,CAAC,mBAAmB,CAAC,uBAAuB,CAAC;IAC9C,CAAC,CAAC,kBAAkB,CAAC,qBAAqB,IAAI,EAAE,CAAC","sourcesContent":["import { NativeModulesProxy, requireNativeModule } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nexport default Platform.OS === 'android'\n ? requireNativeModule('ExpoScreenOrientation')\n : NativeModulesProxy.ExpoScreenOrientation || {};\n"]}
@@ -7,13 +7,6 @@ export { Orientation, OrientationLock, PlatformOrientationInfo, OrientationChang
7
7
  * enum for possible values.
8
8
  * @return Returns a promise with `void` value, which fulfils when the orientation is set.
9
9
  *
10
- * # Error codes
11
- * - `ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK` - An invalid [`OrientationLock`](#orientationlock)
12
- * was passed in.
13
- * - `ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK` - The platform does not support the
14
- * orientation lock policy.
15
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
16
- *
17
10
  * @example
18
11
  * ```ts
19
12
  * async function changeScreenOrientation() {
@@ -27,52 +20,29 @@ export declare function lockAsync(orientationLock: OrientationLock): Promise<voi
27
20
  * object type for the different platform formats.
28
21
  * @return Returns a promise with `void` value, resolving when the orientation is set and rejecting
29
22
  * if an invalid option or value is passed.
30
- *
31
- * # Error codes
32
- * - `ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK` - __iOS Only.__ An invalid [`OrientationLock`](#orientationlock)
33
- * was passed in.
34
- * - `ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK` - The platform does not support the
35
- * orientation lock policy.
36
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
37
- *
38
23
  */
39
24
  export declare function lockPlatformAsync(options: PlatformOrientationInfo): Promise<void>;
40
25
  /**
41
26
  * Sets the screen orientation back to the `OrientationLock.DEFAULT` policy.
42
27
  * @return Returns a promise with `void` value, which fulfils when the orientation is set.
43
- *
44
- * # Error codes
45
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
46
28
  */
47
29
  export declare function unlockAsync(): Promise<void>;
48
30
  /**
49
31
  * Gets the current screen orientation.
50
32
  * @return Returns a promise that fulfils with an [`Orientation`](#screenorientationorientation)
51
33
  * value that reflects the current screen orientation.
52
- *
53
- * # Error codes
54
- * - `ERR_SCREEN_ORIENTATION_GET_ORIENTATION_LOCK` - __Android Only.__ An unknown error occurred
55
- * when trying to get the system lock.
56
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
57
34
  */
58
35
  export declare function getOrientationAsync(): Promise<Orientation>;
59
36
  /**
60
37
  * Gets the current screen orientation lock type.
61
38
  * @return Returns a promise which fulfils with an [`OrientationLock`](#orientationlock)
62
39
  * value.
63
- *
64
- * # Error codes
65
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
66
40
  */
67
41
  export declare function getOrientationLockAsync(): Promise<OrientationLock>;
68
42
  /**
69
43
  * Gets the platform specific screen orientation lock type.
70
44
  * @return Returns a promise which fulfils with a [`PlatformOrientationInfo`](#platformorientationinfo)
71
45
  * value.
72
- *
73
- * # Error codes
74
- * - `ERR_SCREEN_ORIENTATION_GET_PLATFORM_ORIENTATION_LOCK`
75
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
76
46
  */
77
47
  export declare function getPlatformOrientationLockAsync(): Promise<PlatformOrientationInfo>;
78
48
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenOrientation.d.ts","sourceRoot":"","sources":["../src/ScreenOrientation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AAG9F,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,YAAY,GACb,CAAC;AAQF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,SAAS,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/E;AAGD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CvF;AAGD;;;;;;GAMG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAKjD;AAGD;;;;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wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAKjD;AAGD;;;;GAIG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,WAAW,CAAC,CAKhE;AAGD;;;;GAIG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC,CAKxE;AAGD;;;;GAIG;AACH,wBAAsB,+BAA+B,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAiBxF;AAGD;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,OAAO,CAAC,CAWlB;AAaD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,yBAAyB,GAAG,YAAY,CA2B9F;AAMD;;GAEG;AACH,wBAAgB,gCAAgC,IAAI,IAAI,CAUvD;AAGD;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAQhF"}
@@ -12,13 +12,6 @@ let _lastOrientationLock = OrientationLock.UNKNOWN;
12
12
  * enum for possible values.
13
13
  * @return Returns a promise with `void` value, which fulfils when the orientation is set.
14
14
  *
15
- * # Error codes
16
- * - `ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK` - An invalid [`OrientationLock`](#orientationlock)
17
- * was passed in.
18
- * - `ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK` - The platform does not support the
19
- * orientation lock policy.
20
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
21
- *
22
15
  * @example
23
16
  * ```ts
24
17
  * async function changeScreenOrientation() {
@@ -46,14 +39,6 @@ export async function lockAsync(orientationLock) {
46
39
  * object type for the different platform formats.
47
40
  * @return Returns a promise with `void` value, resolving when the orientation is set and rejecting
48
41
  * if an invalid option or value is passed.
49
- *
50
- * # Error codes
51
- * - `ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK` - __iOS Only.__ An invalid [`OrientationLock`](#orientationlock)
52
- * was passed in.
53
- * - `ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK` - The platform does not support the
54
- * orientation lock policy.
55
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
56
- *
57
42
  */
58
43
  export async function lockPlatformAsync(options) {
59
44
  if (!ExpoScreenOrientation.lockPlatformAsync) {
@@ -96,9 +81,6 @@ export async function lockPlatformAsync(options) {
96
81
  /**
97
82
  * Sets the screen orientation back to the `OrientationLock.DEFAULT` policy.
98
83
  * @return Returns a promise with `void` value, which fulfils when the orientation is set.
99
- *
100
- * # Error codes
101
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
102
84
  */
103
85
  export async function unlockAsync() {
104
86
  if (!ExpoScreenOrientation.lockAsync) {
@@ -111,11 +93,6 @@ export async function unlockAsync() {
111
93
  * Gets the current screen orientation.
112
94
  * @return Returns a promise that fulfils with an [`Orientation`](#screenorientationorientation)
113
95
  * value that reflects the current screen orientation.
114
- *
115
- * # Error codes
116
- * - `ERR_SCREEN_ORIENTATION_GET_ORIENTATION_LOCK` - __Android Only.__ An unknown error occurred
117
- * when trying to get the system lock.
118
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
119
96
  */
120
97
  export async function getOrientationAsync() {
121
98
  if (!ExpoScreenOrientation.getOrientationAsync) {
@@ -128,9 +105,6 @@ export async function getOrientationAsync() {
128
105
  * Gets the current screen orientation lock type.
129
106
  * @return Returns a promise which fulfils with an [`OrientationLock`](#orientationlock)
130
107
  * value.
131
- *
132
- * # Error codes
133
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
134
108
  */
135
109
  export async function getOrientationLockAsync() {
136
110
  if (!ExpoScreenOrientation.getOrientationLockAsync) {
@@ -143,10 +117,6 @@ export async function getOrientationLockAsync() {
143
117
  * Gets the platform specific screen orientation lock type.
144
118
  * @return Returns a promise which fulfils with a [`PlatformOrientationInfo`](#platformorientationinfo)
145
119
  * value.
146
- *
147
- * # Error codes
148
- * - `ERR_SCREEN_ORIENTATION_GET_PLATFORM_ORIENTATION_LOCK`
149
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
150
120
  */
151
121
  export async function getPlatformOrientationLockAsync() {
152
122
  const platformOrientationLock = await ExpoScreenOrientation.getPlatformOrientationLockAsync();
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenOrientation.js","sourceRoot":"","sources":["../src/ScreenOrientation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAgB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,WAAW,EAGX,eAAe,EAEf,kBAAkB,EAClB,cAAc,EACd,YAAY,GAEb,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,WAAW,EACX,eAAe,EAIf,kBAAkB,EAClB,cAAc,EACd,YAAY,GAGb,CAAC;AAEF,MAAM,yBAAyB,GAAG,IAAI,YAAY,CAAC,qBAAqB,CAAC,CAAC;AAC1E,IAAI,6BAA6B,GAAmB,EAAE,CAAC;AAEvD,IAAI,oBAAoB,GAAoB,eAAe,CAAC,OAAO,CAAC;AAEpE,cAAc;AACd;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,eAAgC;IAC9D,IAAI,CAAC,qBAAqB,CAAC,SAAS,EAAE;QACpC,MAAM,IAAI,mBAAmB,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;KACjE;IAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACxD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,eAAe,C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;QAEpB,wCAAwC;QACxC,6BAA6B,CAAC,GAAG,EAAE,CAAC;KACrC;AACH,CAAC;AAED,cAAc;AACd;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAC,YAA0B;IACxE,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACzC,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;KAC1D;IACD,YAAY,CAAC,MAAM,EAAE,CAAC;IACtB,6BAA6B,GAAG,6BAA6B,CAAC,MAAM,CAClE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,YAAY,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import { EventEmitter, Platform, Subscription, UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoScreenOrientation from './ExpoScreenOrientation';\nimport {\n Orientation,\n OrientationChangeEvent,\n OrientationChangeListener,\n OrientationLock,\n PlatformOrientationInfo,\n WebOrientationLock,\n WebOrientation,\n SizeClassIOS,\n ScreenOrientationInfo,\n} from './ScreenOrientation.types';\n\nexport {\n Orientation,\n OrientationLock,\n PlatformOrientationInfo,\n OrientationChangeListener,\n OrientationChangeEvent,\n WebOrientationLock,\n WebOrientation,\n SizeClassIOS,\n ScreenOrientationInfo,\n Subscription,\n};\n\nconst _orientationChangeEmitter = new EventEmitter(ExpoScreenOrientation);\nlet _orientationChangeSubscribers: Subscription[] = [];\n\nlet _lastOrientationLock: OrientationLock = OrientationLock.UNKNOWN;\n\n// @needsAudit\n/**\n * Lock the screen orientation to a particular `OrientationLock`.\n * @param orientationLock The orientation lock to apply. See the [`OrientationLock`](#orientationlock)\n * enum for possible values.\n * @return Returns a promise with `void` value, which fulfils when the orientation is set.\n *\n * # Error codes\n * - `ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK` - An invalid [`OrientationLock`](#orientationlock)\n * was passed in.\n * - `ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK` - The platform does not support the\n * orientation lock policy.\n * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.\n *\n * @example\n * ```ts\n * async function changeScreenOrientation() {\n * await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_LEFT);\n * }\n * ```\n */\nexport async function lockAsync(orientationLock: OrientationLock): Promise<void> {\n if (!ExpoScreenOrientation.lockAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'lockAsync');\n }\n\n const orientationLocks = Object.values(OrientationLock);\n if (!orientationLocks.includes(orientationLock)) {\n throw new TypeError(`Invalid Orientation Lock: ${orientationLock}`);\n }\n\n if (orientationLock === OrientationLock.OTHER) {\n return;\n }\n\n await ExpoScreenOrientation.lockAsync(orientationLock);\n _lastOrientationLock = orientationLock;\n}\n\n// @needsAudit @docsMissing\n/**\n * @param options The platform specific lock to apply. See the [`PlatformOrientationInfo`](#platformorientationinfo)\n * object type for the different platform formats.\n * @return Returns a promise with `void` value, resolving when the orientation is set and rejecting\n * if an invalid option or value is passed.\n *\n * # Error codes\n * - `ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK` - __iOS Only.__ An invalid [`OrientationLock`](#orientationlock)\n * was passed in.\n * - `ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK` - The platform does not support the\n * orientation lock policy.\n * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.\n *\n */\nexport async function lockPlatformAsync(options: PlatformOrientationInfo): Promise<void> {\n if (!ExpoScreenOrientation.lockPlatformAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'lockPlatformAsync');\n }\n\n const { screenOrientationConstantAndroid, screenOrientationArrayIOS, screenOrientationLockWeb } =\n options;\n let platformOrientationParam: any;\n if (Platform.OS === 'android' && screenOrientationConstantAndroid) {\n if (isNaN(screenOrientationConstantAndroid)) {\n throw new TypeError(\n `lockPlatformAsync Android platform: screenOrientationConstantAndroid cannot be called with ${screenOrientationConstantAndroid}`\n );\n }\n platformOrientationParam = screenOrientationConstantAndroid;\n } else if (Platform.OS === 'ios' && screenOrientationArrayIOS) {\n if (!Array.isArray(screenOrientationArrayIOS)) {\n throw new TypeError(\n `lockPlatformAsync iOS platform: screenOrientationArrayIOS cannot be called with ${screenOrientationArrayIOS}`\n );\n }\n\n const orientations = Object.values(Orientation);\n for (const orientation of screenOrientationArrayIOS) {\n if (!orientations.includes(orientation)) {\n throw new TypeError(\n `lockPlatformAsync iOS platform: ${orientation} is not a valid Orientation`\n );\n }\n }\n platformOrientationParam = screenOrientationArrayIOS;\n } else if (Platform.OS === 'web' && screenOrientationLockWeb) {\n const webOrientationLocks = Object.values(WebOrientationLock);\n if (!webOrientationLocks.includes(screenOrientationLockWeb)) {\n throw new TypeError(`Invalid Web Orientation Lock: ${screenOrientationLockWeb}`);\n }\n platformOrientationParam = screenOrientationLockWeb;\n }\n\n if (!platformOrientationParam) {\n throw new TypeError('lockPlatformAsync cannot be called with undefined option properties');\n }\n await ExpoScreenOrientation.lockPlatformAsync(platformOrientationParam);\n _lastOrientationLock = OrientationLock.OTHER;\n}\n\n// @needsAudit\n/**\n * Sets the screen orientation back to the `OrientationLock.DEFAULT` policy.\n * @return Returns a promise with `void` value, which fulfils when the orientation is set.\n *\n * # Error codes\n * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.\n */\nexport async function unlockAsync(): Promise<void> {\n if (!ExpoScreenOrientation.lockAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'lockAsync');\n }\n await ExpoScreenOrientation.lockAsync(OrientationLock.DEFAULT);\n}\n\n// @needsAudit\n/**\n * Gets the current screen orientation.\n * @return Returns a promise that fulfils with an [`Orientation`](#screenorientationorientation)\n * value that reflects the current screen orientation.\n *\n * # Error codes\n * - `ERR_SCREEN_ORIENTATION_GET_ORIENTATION_LOCK` - __Android Only.__ An unknown error occurred\n * when trying to get the system lock.\n * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.\n */\nexport async function getOrientationAsync(): Promise<Orientation> {\n if (!ExpoScreenOrientation.getOrientationAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'getOrientationAsync');\n }\n return await ExpoScreenOrientation.getOrientationAsync();\n}\n\n// @needsAudit\n/**\n * Gets the current screen orientation lock type.\n * @return Returns a promise which fulfils with an [`OrientationLock`](#orientationlock)\n * value.\n *\n * # Error codes\n * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.\n */\nexport async function getOrientationLockAsync(): Promise<OrientationLock> {\n if (!ExpoScreenOrientation.getOrientationLockAsync) {\n return _lastOrientationLock;\n }\n return await ExpoScreenOrientation.getOrientationLockAsync();\n}\n\n// @needsAudit\n/**\n * Gets the platform specific screen orientation lock type.\n * @return Returns a promise which fulfils with a [`PlatformOrientationInfo`](#platformorientationinfo)\n * value.\n *\n * # Error codes\n * - `ERR_SCREEN_ORIENTATION_GET_PLATFORM_ORIENTATION_LOCK`\n * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.\n */\nexport async function getPlatformOrientationLockAsync(): Promise<PlatformOrientationInfo> {\n const platformOrientationLock = await ExpoScreenOrientation.getPlatformOrientationLockAsync();\n if (Platform.OS === 'android') {\n return {\n screenOrientationConstantAndroid: platformOrientationLock,\n };\n } else if (Platform.OS === 'ios') {\n return {\n screenOrientationArrayIOS: platformOrientationLock,\n };\n } else if (Platform.OS === 'web') {\n return {\n screenOrientationLockWeb: platformOrientationLock,\n };\n } else {\n return {};\n }\n}\n\n// @needsAudit @docsMissing\n/**\n * Returns whether the [`OrientationLock`](#orientationlock) policy is supported on\n * the device.\n * @param orientationLock\n * @return Returns a promise that resolves to a `boolean` value that reflects whether or not the\n * orientationLock is supported.\n */\nexport async function supportsOrientationLockAsync(\n orientationLock: OrientationLock\n): Promise<boolean> {\n if (!ExpoScreenOrientation.supportsOrientationLockAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'supportsOrientationLockAsync');\n }\n\n const orientationLocks = Object.values(OrientationLock);\n if (!orientationLocks.includes(orientationLock)) {\n throw new TypeError(`Invalid Orientation Lock: ${orientationLock}`);\n }\n\n return await ExpoScreenOrientation.supportsOrientationLockAsync(orientationLock);\n}\n\n// Determine the event name lazily so Jest can set up mocks in advance\nfunction getEventName(): string {\n return Platform.OS === 'ios' || Platform.OS === 'web'\n ? 'expoDidUpdateDimensions'\n : 'didUpdateDimensions';\n}\n\n// We rely on RN to emit `didUpdateDimensions`\n// If this method no longer works, it's possible that the underlying RN implementation has changed\n// see https://github.com/facebook/react-native/blob/c31f79fe478b882540d7fd31ee37b53ddbd60a17/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.java#L90\n// @needsAudit\n/**\n * Invokes the `listener` function when the screen orientation changes from `portrait` to `landscape`\n * or from `landscape` to `portrait`. For example, it won't be invoked when screen orientation\n * change from `portrait up` to `portrait down`, but it will be called when there was a change from\n * `portrait up` to `landscape left`.\n * @param listener Each orientation update will pass an object with the new [`OrientationChangeEvent`](#orientationchangeevent)\n * to the listener.\n */\nexport function addOrientationChangeListener(listener: OrientationChangeListener): Subscription {\n if (typeof listener !== 'function') {\n throw new TypeError(`addOrientationChangeListener cannot be called with ${listener}`);\n }\n const subscription = _orientationChangeEmitter.addListener(\n getEventName(),\n async (update: OrientationChangeEvent) => {\n let orientationInfo, orientationLock;\n if (Platform.OS === 'ios' || Platform.OS === 'web') {\n // For iOS, RN relies on statusBarOrientation (deprecated) to emit `didUpdateDimensions`\n // event, so we emit our own `expoDidUpdateDimensions` event instead\n orientationLock = update.orientationLock;\n orientationInfo = update.orientationInfo;\n } else {\n // We rely on the RN Dimensions to emit the `didUpdateDimensions` event on Android\n let orientation;\n [orientationLock, orientation] = await Promise.all([\n getOrientationLockAsync(),\n getOrientationAsync(),\n ]);\n orientationInfo = { orientation };\n }\n listener({ orientationInfo, orientationLock });\n }\n );\n _orientationChangeSubscribers.push(subscription);\n return subscription;\n}\n\n// We need to keep track of our own subscribers because EventEmitter uses a shared subscriber\n// from NativeEventEmitter that is registered to the same eventTypes as us. Directly calling\n// removeAllListeners(eventName) will remove other module's subscribers.\n// @needsAudit\n/**\n * Removes all listeners subscribed to orientation change updates.\n */\nexport function removeOrientationChangeListeners(): void {\n // Remove listener by subscription instead of eventType to avoid clobbering Dimension module's subscription of didUpdateDimensions\n let i = _orientationChangeSubscribers.length;\n while (i--) {\n const subscriber = _orientationChangeSubscribers[i];\n subscriber.remove();\n\n // remove after a successful unsubscribe\n _orientationChangeSubscribers.pop();\n }\n}\n\n// @needsAudit\n/**\n * Unsubscribes the listener associated with the `Subscription` object from all orientation change\n * updates.\n * @param subscription A subscription object that manages the updates passed to a listener function\n * on an orientation change.\n */\nexport function removeOrientationChangeListener(subscription: Subscription): void {\n if (!subscription || !subscription.remove) {\n throw new TypeError(`Must pass in a valid subscription`);\n }\n subscription.remove();\n _orientationChangeSubscribers = _orientationChangeSubscribers.filter(\n (sub) => sub !== subscription\n );\n}\n"]}
1
+ {"version":3,"file":"ScreenOrientation.js","sourceRoot":"","sources":["../src/ScreenOrientation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAgB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,WAAW,EAGX,eAAe,EAEf,kBAAkB,EAClB,cAAc,EACd,YAAY,GAEb,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,WAAW,EACX,eAAe,EAIf,kBAAkB,EAClB,cAAc,EACd,YAAY,GAGb,CAAC;AAEF,MAAM,yBAAyB,GAAG,IAAI,YAAY,CAAC,qBAAqB,CAAC,CAAC;AAC1E,IAAI,6BAA6B,GAAmB,EAAE,CAAC;AAEvD,IAAI,oBAAoB,GAAoB,eAAe,CAAC,OAAO,CAAC;AAEpE,cAAc;AACd;;;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FAA6F;AAC7F,4FAA4F;AAC5F,wEAAwE;AACxE,cAAc;AACd;;GAEG;AACH,MAAM,UAAU,gCAAgC;IAC9C,kIAAkI;IAClI,IAAI,CAAC,GAAG,6BAA6B,CAAC,MAAM,CAAC;IAC7C,OAAO,CAAC,EAAE,EAAE;QACV,MAAM,UAAU,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC;QACpD,UAAU,CAAC,MAAM,EAAE,CAAC;QAEpB,wCAAwC;QACxC,6BAA6B,CAAC,GAAG,EAAE,CAAC;KACrC;AACH,CAAC;AAED,cAAc;AACd;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAC,YAA0B;IACxE,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACzC,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;KAC1D;IACD,YAAY,CAAC,MAAM,EAAE,CAAC;IACtB,6BAA6B,GAAG,6BAA6B,CAAC,MAAM,CAClE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,YAAY,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import { EventEmitter, Platform, Subscription, UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoScreenOrientation from './ExpoScreenOrientation';\nimport {\n Orientation,\n OrientationChangeEvent,\n OrientationChangeListener,\n OrientationLock,\n PlatformOrientationInfo,\n WebOrientationLock,\n WebOrientation,\n SizeClassIOS,\n ScreenOrientationInfo,\n} from './ScreenOrientation.types';\n\nexport {\n Orientation,\n OrientationLock,\n PlatformOrientationInfo,\n OrientationChangeListener,\n OrientationChangeEvent,\n WebOrientationLock,\n WebOrientation,\n SizeClassIOS,\n ScreenOrientationInfo,\n Subscription,\n};\n\nconst _orientationChangeEmitter = new EventEmitter(ExpoScreenOrientation);\nlet _orientationChangeSubscribers: Subscription[] = [];\n\nlet _lastOrientationLock: OrientationLock = OrientationLock.UNKNOWN;\n\n// @needsAudit\n/**\n * Lock the screen orientation to a particular `OrientationLock`.\n * @param orientationLock The orientation lock to apply. See the [`OrientationLock`](#orientationlock)\n * enum for possible values.\n * @return Returns a promise with `void` value, which fulfils when the orientation is set.\n *\n * @example\n * ```ts\n * async function changeScreenOrientation() {\n * await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_LEFT);\n * }\n * ```\n */\nexport async function lockAsync(orientationLock: OrientationLock): Promise<void> {\n if (!ExpoScreenOrientation.lockAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'lockAsync');\n }\n\n const orientationLocks = Object.values(OrientationLock);\n if (!orientationLocks.includes(orientationLock)) {\n throw new TypeError(`Invalid Orientation Lock: ${orientationLock}`);\n }\n\n if (orientationLock === OrientationLock.OTHER) {\n return;\n }\n\n await ExpoScreenOrientation.lockAsync(orientationLock);\n _lastOrientationLock = orientationLock;\n}\n\n// @needsAudit @docsMissing\n/**\n * @param options The platform specific lock to apply. See the [`PlatformOrientationInfo`](#platformorientationinfo)\n * object type for the different platform formats.\n * @return Returns a promise with `void` value, resolving when the orientation is set and rejecting\n * if an invalid option or value is passed.\n */\nexport async function lockPlatformAsync(options: PlatformOrientationInfo): Promise<void> {\n if (!ExpoScreenOrientation.lockPlatformAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'lockPlatformAsync');\n }\n\n const { screenOrientationConstantAndroid, screenOrientationArrayIOS, screenOrientationLockWeb } =\n options;\n let platformOrientationParam: any;\n if (Platform.OS === 'android' && screenOrientationConstantAndroid) {\n if (isNaN(screenOrientationConstantAndroid)) {\n throw new TypeError(\n `lockPlatformAsync Android platform: screenOrientationConstantAndroid cannot be called with ${screenOrientationConstantAndroid}`\n );\n }\n platformOrientationParam = screenOrientationConstantAndroid;\n } else if (Platform.OS === 'ios' && screenOrientationArrayIOS) {\n if (!Array.isArray(screenOrientationArrayIOS)) {\n throw new TypeError(\n `lockPlatformAsync iOS platform: screenOrientationArrayIOS cannot be called with ${screenOrientationArrayIOS}`\n );\n }\n\n const orientations = Object.values(Orientation);\n for (const orientation of screenOrientationArrayIOS) {\n if (!orientations.includes(orientation)) {\n throw new TypeError(\n `lockPlatformAsync iOS platform: ${orientation} is not a valid Orientation`\n );\n }\n }\n platformOrientationParam = screenOrientationArrayIOS;\n } else if (Platform.OS === 'web' && screenOrientationLockWeb) {\n const webOrientationLocks = Object.values(WebOrientationLock);\n if (!webOrientationLocks.includes(screenOrientationLockWeb)) {\n throw new TypeError(`Invalid Web Orientation Lock: ${screenOrientationLockWeb}`);\n }\n platformOrientationParam = screenOrientationLockWeb;\n }\n\n if (!platformOrientationParam) {\n throw new TypeError('lockPlatformAsync cannot be called with undefined option properties');\n }\n await ExpoScreenOrientation.lockPlatformAsync(platformOrientationParam);\n _lastOrientationLock = OrientationLock.OTHER;\n}\n\n// @needsAudit\n/**\n * Sets the screen orientation back to the `OrientationLock.DEFAULT` policy.\n * @return Returns a promise with `void` value, which fulfils when the orientation is set.\n */\nexport async function unlockAsync(): Promise<void> {\n if (!ExpoScreenOrientation.lockAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'lockAsync');\n }\n await ExpoScreenOrientation.lockAsync(OrientationLock.DEFAULT);\n}\n\n// @needsAudit\n/**\n * Gets the current screen orientation.\n * @return Returns a promise that fulfils with an [`Orientation`](#screenorientationorientation)\n * value that reflects the current screen orientation.\n */\nexport async function getOrientationAsync(): Promise<Orientation> {\n if (!ExpoScreenOrientation.getOrientationAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'getOrientationAsync');\n }\n return await ExpoScreenOrientation.getOrientationAsync();\n}\n\n// @needsAudit\n/**\n * Gets the current screen orientation lock type.\n * @return Returns a promise which fulfils with an [`OrientationLock`](#orientationlock)\n * value.\n */\nexport async function getOrientationLockAsync(): Promise<OrientationLock> {\n if (!ExpoScreenOrientation.getOrientationLockAsync) {\n return _lastOrientationLock;\n }\n return await ExpoScreenOrientation.getOrientationLockAsync();\n}\n\n// @needsAudit\n/**\n * Gets the platform specific screen orientation lock type.\n * @return Returns a promise which fulfils with a [`PlatformOrientationInfo`](#platformorientationinfo)\n * value.\n */\nexport async function getPlatformOrientationLockAsync(): Promise<PlatformOrientationInfo> {\n const platformOrientationLock = await ExpoScreenOrientation.getPlatformOrientationLockAsync();\n if (Platform.OS === 'android') {\n return {\n screenOrientationConstantAndroid: platformOrientationLock,\n };\n } else if (Platform.OS === 'ios') {\n return {\n screenOrientationArrayIOS: platformOrientationLock,\n };\n } else if (Platform.OS === 'web') {\n return {\n screenOrientationLockWeb: platformOrientationLock,\n };\n } else {\n return {};\n }\n}\n\n// @needsAudit @docsMissing\n/**\n * Returns whether the [`OrientationLock`](#orientationlock) policy is supported on\n * the device.\n * @param orientationLock\n * @return Returns a promise that resolves to a `boolean` value that reflects whether or not the\n * orientationLock is supported.\n */\nexport async function supportsOrientationLockAsync(\n orientationLock: OrientationLock\n): Promise<boolean> {\n if (!ExpoScreenOrientation.supportsOrientationLockAsync) {\n throw new UnavailabilityError('ScreenOrientation', 'supportsOrientationLockAsync');\n }\n\n const orientationLocks = Object.values(OrientationLock);\n if (!orientationLocks.includes(orientationLock)) {\n throw new TypeError(`Invalid Orientation Lock: ${orientationLock}`);\n }\n\n return await ExpoScreenOrientation.supportsOrientationLockAsync(orientationLock);\n}\n\n// Determine the event name lazily so Jest can set up mocks in advance\nfunction getEventName(): string {\n return Platform.OS === 'ios' || Platform.OS === 'web'\n ? 'expoDidUpdateDimensions'\n : 'didUpdateDimensions';\n}\n\n// We rely on RN to emit `didUpdateDimensions`\n// If this method no longer works, it's possible that the underlying RN implementation has changed\n// see https://github.com/facebook/react-native/blob/c31f79fe478b882540d7fd31ee37b53ddbd60a17/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.java#L90\n// @needsAudit\n/**\n * Invokes the `listener` function when the screen orientation changes from `portrait` to `landscape`\n * or from `landscape` to `portrait`. For example, it won't be invoked when screen orientation\n * change from `portrait up` to `portrait down`, but it will be called when there was a change from\n * `portrait up` to `landscape left`.\n * @param listener Each orientation update will pass an object with the new [`OrientationChangeEvent`](#orientationchangeevent)\n * to the listener.\n */\nexport function addOrientationChangeListener(listener: OrientationChangeListener): Subscription {\n if (typeof listener !== 'function') {\n throw new TypeError(`addOrientationChangeListener cannot be called with ${listener}`);\n }\n const subscription = _orientationChangeEmitter.addListener(\n getEventName(),\n async (update: OrientationChangeEvent) => {\n let orientationInfo, orientationLock;\n if (Platform.OS === 'ios' || Platform.OS === 'web') {\n // For iOS, RN relies on statusBarOrientation (deprecated) to emit `didUpdateDimensions`\n // event, so we emit our own `expoDidUpdateDimensions` event instead\n orientationLock = update.orientationLock;\n orientationInfo = update.orientationInfo;\n } else {\n // We rely on the RN Dimensions to emit the `didUpdateDimensions` event on Android\n let orientation;\n [orientationLock, orientation] = await Promise.all([\n getOrientationLockAsync(),\n getOrientationAsync(),\n ]);\n orientationInfo = { orientation };\n }\n listener({ orientationInfo, orientationLock });\n }\n );\n _orientationChangeSubscribers.push(subscription);\n return subscription;\n}\n\n// We need to keep track of our own subscribers because EventEmitter uses a shared subscriber\n// from NativeEventEmitter that is registered to the same eventTypes as us. Directly calling\n// removeAllListeners(eventName) will remove other module's subscribers.\n// @needsAudit\n/**\n * Removes all listeners subscribed to orientation change updates.\n */\nexport function removeOrientationChangeListeners(): void {\n // Remove listener by subscription instead of eventType to avoid clobbering Dimension module's subscription of didUpdateDimensions\n let i = _orientationChangeSubscribers.length;\n while (i--) {\n const subscriber = _orientationChangeSubscribers[i];\n subscriber.remove();\n\n // remove after a successful unsubscribe\n _orientationChangeSubscribers.pop();\n }\n}\n\n// @needsAudit\n/**\n * Unsubscribes the listener associated with the `Subscription` object from all orientation change\n * updates.\n * @param subscription A subscription object that manages the updates passed to a listener function\n * on an orientation change.\n */\nexport function removeOrientationChangeListener(subscription: Subscription): void {\n if (!subscription || !subscription.remove) {\n throw new TypeError(`Must pass in a valid subscription`);\n }\n subscription.remove();\n _orientationChangeSubscribers = _orientationChangeSubscribers.filter(\n (sub) => sub !== subscription\n );\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "expo-screen-orientation",
3
3
  "platforms": ["ios", "android"],
4
+ "android": {
5
+ "modules": ["expo.modules.screenorientation.ScreenOrientationModule"]
6
+ },
4
7
  "ios": {
5
8
  "appDelegateSubscribers": ["ScreenOrientationAppDelegate"],
6
9
  "reactDelegateHandlers": ["ScreenOrientationReactDelegateHandler"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-screen-orientation",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "Expo universal module for managing device's screen orientation",
5
5
  "main": "build/ScreenOrientation.js",
6
6
  "types": "build/ScreenOrientation.d.ts",
@@ -41,5 +41,5 @@
41
41
  "peerDependencies": {
42
42
  "expo": "*"
43
43
  },
44
- "gitHead": "1f8a6a09570fd451378565ca34933018ce48454e"
44
+ "gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
45
45
  }
@@ -1,3 +1,6 @@
1
- import { NativeModulesProxy } from 'expo-modules-core';
1
+ import { NativeModulesProxy, requireNativeModule } from 'expo-modules-core';
2
+ import { Platform } from 'react-native';
2
3
 
3
- export default NativeModulesProxy.ExpoScreenOrientation || {};
4
+ export default Platform.OS === 'android'
5
+ ? requireNativeModule('ExpoScreenOrientation')
6
+ : NativeModulesProxy.ExpoScreenOrientation || {};
@@ -38,13 +38,6 @@ let _lastOrientationLock: OrientationLock = OrientationLock.UNKNOWN;
38
38
  * enum for possible values.
39
39
  * @return Returns a promise with `void` value, which fulfils when the orientation is set.
40
40
  *
41
- * # Error codes
42
- * - `ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK` - An invalid [`OrientationLock`](#orientationlock)
43
- * was passed in.
44
- * - `ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK` - The platform does not support the
45
- * orientation lock policy.
46
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
47
- *
48
41
  * @example
49
42
  * ```ts
50
43
  * async function changeScreenOrientation() {
@@ -76,14 +69,6 @@ export async function lockAsync(orientationLock: OrientationLock): Promise<void>
76
69
  * object type for the different platform formats.
77
70
  * @return Returns a promise with `void` value, resolving when the orientation is set and rejecting
78
71
  * if an invalid option or value is passed.
79
- *
80
- * # Error codes
81
- * - `ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK` - __iOS Only.__ An invalid [`OrientationLock`](#orientationlock)
82
- * was passed in.
83
- * - `ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK` - The platform does not support the
84
- * orientation lock policy.
85
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
86
- *
87
72
  */
88
73
  export async function lockPlatformAsync(options: PlatformOrientationInfo): Promise<void> {
89
74
  if (!ExpoScreenOrientation.lockPlatformAsync) {
@@ -135,9 +120,6 @@ export async function lockPlatformAsync(options: PlatformOrientationInfo): Promi
135
120
  /**
136
121
  * Sets the screen orientation back to the `OrientationLock.DEFAULT` policy.
137
122
  * @return Returns a promise with `void` value, which fulfils when the orientation is set.
138
- *
139
- * # Error codes
140
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
141
123
  */
142
124
  export async function unlockAsync(): Promise<void> {
143
125
  if (!ExpoScreenOrientation.lockAsync) {
@@ -151,11 +133,6 @@ export async function unlockAsync(): Promise<void> {
151
133
  * Gets the current screen orientation.
152
134
  * @return Returns a promise that fulfils with an [`Orientation`](#screenorientationorientation)
153
135
  * value that reflects the current screen orientation.
154
- *
155
- * # Error codes
156
- * - `ERR_SCREEN_ORIENTATION_GET_ORIENTATION_LOCK` - __Android Only.__ An unknown error occurred
157
- * when trying to get the system lock.
158
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
159
136
  */
160
137
  export async function getOrientationAsync(): Promise<Orientation> {
161
138
  if (!ExpoScreenOrientation.getOrientationAsync) {
@@ -169,9 +146,6 @@ export async function getOrientationAsync(): Promise<Orientation> {
169
146
  * Gets the current screen orientation lock type.
170
147
  * @return Returns a promise which fulfils with an [`OrientationLock`](#orientationlock)
171
148
  * value.
172
- *
173
- * # Error codes
174
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
175
149
  */
176
150
  export async function getOrientationLockAsync(): Promise<OrientationLock> {
177
151
  if (!ExpoScreenOrientation.getOrientationLockAsync) {
@@ -185,10 +159,6 @@ export async function getOrientationLockAsync(): Promise<OrientationLock> {
185
159
  * Gets the platform specific screen orientation lock type.
186
160
  * @return Returns a promise which fulfils with a [`PlatformOrientationInfo`](#platformorientationinfo)
187
161
  * value.
188
- *
189
- * # Error codes
190
- * - `ERR_SCREEN_ORIENTATION_GET_PLATFORM_ORIENTATION_LOCK`
191
- * - `ERR_SCREEN_ORIENTATION_MISSING_ACTIVITY` - __Android Only.__ Could not get the current activity.
192
162
  */
193
163
  export async function getPlatformOrientationLockAsync(): Promise<PlatformOrientationInfo> {
194
164
  const platformOrientationLock = await ExpoScreenOrientation.getPlatformOrientationLockAsync();
@@ -1,8 +0,0 @@
1
- package expo.modules.screenorientation
2
-
3
- import android.content.Context
4
- import expo.modules.core.BasePackage
5
-
6
- class ScreenOrientationPackage : BasePackage() {
7
- override fun createExportedModules(context: Context) = listOf(ScreenOrientationModule(context))
8
- }