expo-screen-orientation 6.4.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,7 +10,14 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 6.4.12023-12-19
13
+ ## 7.0.02024-04-18
14
+
15
+ ### 💡 Others
16
+
17
+ - drop unused web `name` property. ([#27437](https://github.com/expo/expo/pull/27437) by [@EvanBacon](https://github.com/EvanBacon))
18
+ - Removed deprecated backward compatible Gradle settings. ([#28083](https://github.com/expo/expo/pull/28083) by [@kudo](https://github.com/kudo))
19
+
20
+ ## 6.4.1 - 2023-12-19
14
21
 
15
22
  _This version does not introduce any user-facing changes._
16
23
 
@@ -1,107 +1,19 @@
1
1
  apply plugin: 'com.android.library'
2
- apply plugin: 'kotlin-android'
3
- apply plugin: 'maven-publish'
4
2
 
5
3
  group = 'host.exp.exponent'
6
- version = '6.4.1'
4
+ version = '7.0.0'
7
5
 
8
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
- if (expoModulesCorePlugin.exists()) {
10
- apply from: expoModulesCorePlugin
11
- applyKotlinExpoModulesCorePlugin()
12
- // Remove this check, but keep the contents after SDK49 support is dropped
13
- if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
- useExpoPublishing()
15
- useCoreDependencies()
16
- }
17
- }
18
-
19
- buildscript {
20
- // Simple helper that allows the root project to override versions declared by this library.
21
- ext.safeExtGet = { prop, fallback ->
22
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
23
- }
24
-
25
- // Ensures backward compatibility
26
- ext.getKotlinVersion = {
27
- if (ext.has("kotlinVersion")) {
28
- ext.kotlinVersion()
29
- } else {
30
- ext.safeExtGet("kotlinVersion", "1.8.10")
31
- }
32
- }
33
-
34
- repositories {
35
- mavenCentral()
36
- }
37
-
38
- dependencies {
39
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
40
- }
41
- }
42
-
43
- // Remove this if and it's contents, when support for SDK49 is dropped
44
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
- afterEvaluate {
46
- publishing {
47
- publications {
48
- release(MavenPublication) {
49
- from components.release
50
- }
51
- }
52
- repositories {
53
- maven {
54
- url = mavenLocal().url
55
- }
56
- }
57
- }
58
- }
59
- }
7
+ apply from: expoModulesCorePlugin
8
+ applyKotlinExpoModulesCorePlugin()
9
+ useCoreDependencies()
10
+ useDefaultAndroidSdkVersions()
11
+ useExpoPublishing()
60
12
 
61
13
  android {
62
- // Remove this if and it's contents, when support for SDK49 is dropped
63
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
- compileSdkVersion safeExtGet("compileSdkVersion", 34)
65
-
66
- defaultConfig {
67
- minSdkVersion safeExtGet("minSdkVersion", 23)
68
- targetSdkVersion safeExtGet("targetSdkVersion", 34)
69
- }
70
-
71
- publishing {
72
- singleVariant("release") {
73
- withSourcesJar()
74
- }
75
- }
76
-
77
- lintOptions {
78
- abortOnError false
79
- }
80
- }
81
-
82
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
83
- if (agpVersion.tokenize('.')[0].toInteger() < 8) {
84
- compileOptions {
85
- sourceCompatibility JavaVersion.VERSION_11
86
- targetCompatibility JavaVersion.VERSION_11
87
- }
88
-
89
- kotlinOptions {
90
- jvmTarget = JavaVersion.VERSION_11.majorVersion
91
- }
92
- }
93
-
94
14
  namespace "expo.modules.screenorientation"
95
15
  defaultConfig {
96
16
  versionCode 7
97
- versionName '6.4.1'
98
- }
99
- }
100
-
101
- dependencies {
102
- // Remove this if and it's contents, when support for SDK49 is dropped
103
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
104
- implementation project(':expo-modules-core')
105
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
17
+ versionName '7.0.0'
106
18
  }
107
19
  }
@@ -47,11 +47,11 @@ class ScreenOrientationModule : Module(), LifecycleEventListener {
47
47
  currentActivity.requestedOrientation = orientationAttr.value
48
48
  }
49
49
 
50
- AsyncFunction("getOrientationAsync") {
50
+ AsyncFunction<Int>("getOrientationAsync") {
51
51
  return@AsyncFunction getScreenOrientation(currentActivity).value
52
52
  }
53
53
 
54
- AsyncFunction("getOrientationLockAsync") {
54
+ AsyncFunction<OrientationLock>("getOrientationLockAsync") {
55
55
  try {
56
56
  return@AsyncFunction OrientationLock.fromPlatformInt(currentActivity.requestedOrientation)
57
57
  } catch (e: Exception) {
@@ -59,7 +59,7 @@ class ScreenOrientationModule : Module(), LifecycleEventListener {
59
59
  }
60
60
  }
61
61
 
62
- AsyncFunction("getPlatformOrientationLockAsync") {
62
+ AsyncFunction<Int>("getPlatformOrientationLockAsync") {
63
63
  try {
64
64
  return@AsyncFunction currentActivity.requestedOrientation
65
65
  } catch (e: Exception) {
@@ -1,6 +1,5 @@
1
1
  import { Orientation, OrientationLock, WebOrientationLock } from './ScreenOrientation.types';
2
2
  declare const _default: {
3
- readonly name: string;
4
3
  supportsOrientationLockAsync(orientationLock: OrientationLock): Promise<boolean>;
5
4
  getPlatformOrientationLockAsync(): Promise<WebOrientationLock>;
6
5
  getOrientationAsync(): Promise<Orientation>;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoScreenOrientation.web.d.ts","sourceRoot":"","sources":["../src/ExpoScreenOrientation.web.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,eAAe,EACf,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;;;kDAqGmB,eAAe,GAAG,QAAQ,OAAO,CAAC;uCAG7C,QAAQ,kBAAkB,CAAC;2BAGvC,QAAQ,WAAW,CAAC;+BAQhB,eAAe,GAAG,QAAQ,IAAI,CAAC;0CAOpB,kBAAkB,GAAG,QAAQ,IAAI,CAAC;mBAIzD,QAAQ,IAAI,CAAC;;AA7BpC,wBAoDE"}
1
+ {"version":3,"file":"ExpoScreenOrientation.web.d.ts","sourceRoot":"","sources":["../src/ExpoScreenOrientation.web.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,eAAe,EACf,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;;kDAoGmB,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;uCAG7C,OAAO,CAAC,kBAAkB,CAAC;2BAGvC,OAAO,CAAC,WAAW,CAAC;+BAQhB,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;0CAOpB,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;mBAIzD,OAAO,CAAC,IAAI,CAAC;;AA1BpC,wBAiDE"}
@@ -1,4 +1,4 @@
1
- import { SyntheticPlatformEmitter, Platform } from 'expo-modules-core';
1
+ import { DeviceEventEmitter, Platform } from 'expo-modules-core';
2
2
  import { getOrientationLockAsync, getOrientationAsync } from './ScreenOrientation';
3
3
  import { Orientation, OrientationLock, WebOrientationLock, WebOrientation, } from './ScreenOrientation.types';
4
4
  const OrientationLockAPIToWeb = {
@@ -26,7 +26,7 @@ async function emitOrientationEvent() {
26
26
  getOrientationLockAsync(),
27
27
  getOrientationAsync(),
28
28
  ]);
29
- SyntheticPlatformEmitter.emit('expoDidUpdateDimensions', {
29
+ DeviceEventEmitter.emit('expoDidUpdateDimensions', {
30
30
  orientationLock,
31
31
  orientationInfo: { orientation },
32
32
  });
@@ -55,7 +55,9 @@ async function _lockAsync(webOrientationLock) {
55
55
  if (webOrientationLock === WebOrientationLock.UNKNOWN) {
56
56
  throw new Error(`expo-screen-orientation: WebOrientationLock.UNKNOWN is not a valid lock that can be applied to the device.`);
57
57
  }
58
+ // @ts-expect-error: This is missing in the TypeScript definitions
58
59
  if (screen.orientation && screen.orientation.lock) {
60
+ // @ts-expect-error
59
61
  await screen.orientation.lock(webOrientationLock);
60
62
  }
61
63
  else if (screen['lockOrientation'] ||
@@ -75,9 +77,6 @@ async function _lockAsync(webOrientationLock) {
75
77
  }
76
78
  let _lastWebOrientationLock = WebOrientationLock.UNKNOWN;
77
79
  export default {
78
- get name() {
79
- return 'ExpoScreenOrientation';
80
- },
81
80
  async supportsOrientationLockAsync(orientationLock) {
82
81
  return orientationLock in OrientationLockAPIToWeb;
83
82
  },
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoScreenOrientation.web.js","sourceRoot":"","sources":["../src/ExpoScreenOrientation.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EACL,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,MAAM,uBAAuB,GAEzB;IACF,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,OAAO;IACrD,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,GAAG;IAC7C,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,QAAQ;IACvD,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC,gBAAgB;IAClE,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC,kBAAkB;IACtE,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,kBAAkB,CAAC,SAAS;IACzD,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,kBAAkB,CAAC,iBAAiB;IACtE,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,kBAAkB,CAAC,mBAAmB;CAC1E,CAAC;AAEF,MAAM,mBAAmB,GAErB;IACF,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,WAAW;IAC1D,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,aAAa;IAC9D,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,WAAW,CAAC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":["import { SyntheticPlatformEmitter, Platform } from 'expo-modules-core';\n\nimport { getOrientationLockAsync, getOrientationAsync } from './ScreenOrientation';\nimport {\n Orientation,\n OrientationLock,\n WebOrientationLock,\n WebOrientation,\n} from './ScreenOrientation.types';\n\nconst OrientationLockAPIToWeb: {\n [lock: string]: WebOrientationLock;\n} = {\n [OrientationLock.DEFAULT]: WebOrientationLock.NATURAL,\n [OrientationLock.ALL]: WebOrientationLock.ANY,\n [OrientationLock.PORTRAIT]: WebOrientationLock.PORTRAIT,\n [OrientationLock.PORTRAIT_UP]: WebOrientationLock.PORTRAIT_PRIMARY,\n [OrientationLock.PORTRAIT_DOWN]: WebOrientationLock.PORTRAIT_SECONDARY,\n [OrientationLock.LANDSCAPE]: WebOrientationLock.LANDSCAPE,\n [OrientationLock.LANDSCAPE_LEFT]: WebOrientationLock.LANDSCAPE_PRIMARY,\n [OrientationLock.LANDSCAPE_RIGHT]: WebOrientationLock.LANDSCAPE_SECONDARY,\n};\n\nconst OrientationWebToAPI: {\n [orientationWeb: string]: Orientation;\n} = {\n [WebOrientation.PORTRAIT_PRIMARY]: Orientation.PORTRAIT_UP,\n [WebOrientation.PORTRAIT_SECONDARY]: Orientation.PORTRAIT_DOWN,\n [WebOrientation.LANDSCAPE_PRIMARY]: Orientation.LANDSCAPE_LEFT,\n [WebOrientation.LANDSCAPE_SECONDARY]: Orientation.LANDSCAPE_RIGHT,\n};\n\ndeclare const window: Window;\n\nconst screen: Screen = Platform.canUseViewport ? window.screen : ({} as Screen);\nconst orientation: ScreenOrientation | null = Platform.canUseViewport\n ? screen.orientation || (screen as any).msOrientation || null\n : null;\n\nasync function emitOrientationEvent() {\n const [orientationLock, orientation] = await Promise.all([\n getOrientationLockAsync(),\n getOrientationAsync(),\n ]);\n SyntheticPlatformEmitter.emit('expoDidUpdateDimensions', {\n orientationLock,\n orientationInfo: { orientation },\n });\n}\n\nif (Platform.canUseEventListeners) {\n if (orientation && orientation.addEventListener) {\n orientation.addEventListener('change', emitOrientationEvent);\n } else {\n window.addEventListener('orientationchange', emitOrientationEvent);\n }\n}\n\nfunction _convertToLegacyOrientationLock(orientationLock: WebOrientationLock): string | string[] {\n switch (orientationLock) {\n case WebOrientationLock.UNKNOWN:\n throw new Error(\n `expo-screen-orientation: WebOrientationLock.UNKNOWN is not a valid lock to be converted.`\n );\n case WebOrientationLock.ANY:\n return ['portrait', 'landscape'];\n case WebOrientationLock.NATURAL:\n return 'default';\n default:\n return orientationLock;\n }\n}\n\nasync function _lockAsync(webOrientationLock: WebOrientationLock): Promise<void> {\n if (webOrientationLock === WebOrientationLock.UNKNOWN) {\n throw new Error(\n `expo-screen-orientation: WebOrientationLock.UNKNOWN is not a valid lock that can be applied to the device.`\n );\n }\n if (screen.orientation && screen.orientation.lock) {\n await screen.orientation.lock(webOrientationLock);\n } else if (\n screen['lockOrientation'] ||\n screen['mozLockOrientation'] ||\n screen['msLockOrientation']\n ) {\n const legacyLock = _convertToLegacyOrientationLock(webOrientationLock);\n const lockOrientation =\n screen['lockOrientation'] || screen['mozLockOrientation'] || screen['msLockOrientation'];\n // correct `this` context must be passed in otherwise method call is disallowed by browser\n const isSuccess = lockOrientation.call(screen, legacyLock);\n if (!isSuccess) {\n throw new Error(\n `Applying orientation lock: ${JSON.stringify(webOrientationLock)} to device was denied`\n );\n }\n } else {\n throw new Error(\n `expo-screen-orientation: The browser doesn't support locking screen orientation.`\n );\n }\n}\n\nlet _lastWebOrientationLock: WebOrientationLock = WebOrientationLock.UNKNOWN;\n\nexport default {\n get name(): string {\n return 'ExpoScreenOrientation';\n },\n async supportsOrientationLockAsync(orientationLock: OrientationLock): Promise<boolean> {\n return orientationLock in OrientationLockAPIToWeb;\n },\n async getPlatformOrientationLockAsync(): Promise<WebOrientationLock> {\n return _lastWebOrientationLock;\n },\n async getOrientationAsync(): Promise<Orientation> {\n const webOrientation =\n screen['msOrientation'] || (screen.orientation || screen['mozOrientation'] || {}).type;\n if (!webOrientation) {\n return Orientation.UNKNOWN;\n }\n return OrientationWebToAPI[webOrientation];\n },\n async lockAsync(orientationLock: OrientationLock): Promise<void> {\n const webOrientationLock = OrientationLockAPIToWeb[orientationLock];\n if (!webOrientationLock) {\n throw new TypeError(`Invalid Orientation Lock: ${orientationLock}`);\n }\n await _lockAsync(webOrientationLock);\n },\n async lockPlatformAsync(webOrientationLock: WebOrientationLock): Promise<void> {\n await _lockAsync(webOrientationLock);\n _lastWebOrientationLock = webOrientationLock;\n },\n async unlockAsync(): Promise<void> {\n if (screen.orientation && screen.orientation.unlock) {\n screen.orientation.unlock();\n } else if (\n screen['unlockOrientation'] ||\n screen['mozUnlockOrientation'] ||\n screen['msUnlockOrientation']\n ) {\n const unlockOrientation =\n screen['unlockOrientation'] ||\n screen['mozUnlockOrientation'] ||\n screen['msUnlockOrientation'];\n // correct `this` context must be passed in otherwise method call is disallowed by browser\n const isSuccess = unlockOrientation.call(screen);\n if (!isSuccess) {\n throw new Error(`Unlocking screen orientation on device was denied`);\n }\n } else {\n throw new Error(\n `expo-screen-orientation: The browser doesn't support unlocking screen orientation.`\n );\n }\n },\n};\n"]}
1
+ {"version":3,"file":"ExpoScreenOrientation.web.js","sourceRoot":"","sources":["../src/ExpoScreenOrientation.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EACL,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,MAAM,uBAAuB,GAEzB;IACF,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,OAAO;IACrD,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,GAAG;IAC7C,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,QAAQ;IACvD,CAAC,eAAe,CAAC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;QACf,IAAI,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YACpD,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;QAC9B,CAAC;aAAM,IACL,MAAM,CAAC,mBAAmB,CAAC;YAC3B,MAAM,CAAC,sBAAsB,CAAC;YAC9B,MAAM,CAAC,qBAAqB,CAAC,EAC7B,CAAC;YACD,MAAM,iBAAiB,GACrB,MAAM,CAAC,mBAAmB,CAAC;gBAC3B,MAAM,CAAC,sBAAsB,CAAC;gBAC9B,MAAM,CAAC,qBAAqB,CAAC,CAAC;YAChC,0FAA0F;YAC1F,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { DeviceEventEmitter, Platform } from 'expo-modules-core';\n\nimport { getOrientationLockAsync, getOrientationAsync } from './ScreenOrientation';\nimport {\n Orientation,\n OrientationLock,\n WebOrientationLock,\n WebOrientation,\n} from './ScreenOrientation.types';\n\nconst OrientationLockAPIToWeb: {\n [lock: string]: WebOrientationLock;\n} = {\n [OrientationLock.DEFAULT]: WebOrientationLock.NATURAL,\n [OrientationLock.ALL]: WebOrientationLock.ANY,\n [OrientationLock.PORTRAIT]: WebOrientationLock.PORTRAIT,\n [OrientationLock.PORTRAIT_UP]: WebOrientationLock.PORTRAIT_PRIMARY,\n [OrientationLock.PORTRAIT_DOWN]: WebOrientationLock.PORTRAIT_SECONDARY,\n [OrientationLock.LANDSCAPE]: WebOrientationLock.LANDSCAPE,\n [OrientationLock.LANDSCAPE_LEFT]: WebOrientationLock.LANDSCAPE_PRIMARY,\n [OrientationLock.LANDSCAPE_RIGHT]: WebOrientationLock.LANDSCAPE_SECONDARY,\n};\n\nconst OrientationWebToAPI: {\n [orientationWeb: string]: Orientation;\n} = {\n [WebOrientation.PORTRAIT_PRIMARY]: Orientation.PORTRAIT_UP,\n [WebOrientation.PORTRAIT_SECONDARY]: Orientation.PORTRAIT_DOWN,\n [WebOrientation.LANDSCAPE_PRIMARY]: Orientation.LANDSCAPE_LEFT,\n [WebOrientation.LANDSCAPE_SECONDARY]: Orientation.LANDSCAPE_RIGHT,\n};\n\ndeclare const window: Window;\n\nconst screen: Screen = Platform.canUseViewport ? window.screen : ({} as Screen);\nconst orientation: ScreenOrientation | null = Platform.canUseViewport\n ? screen.orientation || (screen as any).msOrientation || null\n : null;\n\nasync function emitOrientationEvent() {\n const [orientationLock, orientation] = await Promise.all([\n getOrientationLockAsync(),\n getOrientationAsync(),\n ]);\n DeviceEventEmitter.emit('expoDidUpdateDimensions', {\n orientationLock,\n orientationInfo: { orientation },\n });\n}\n\nif (Platform.canUseEventListeners) {\n if (orientation && orientation.addEventListener) {\n orientation.addEventListener('change', emitOrientationEvent);\n } else {\n window.addEventListener('orientationchange', emitOrientationEvent);\n }\n}\n\nfunction _convertToLegacyOrientationLock(orientationLock: WebOrientationLock): string | string[] {\n switch (orientationLock) {\n case WebOrientationLock.UNKNOWN:\n throw new Error(\n `expo-screen-orientation: WebOrientationLock.UNKNOWN is not a valid lock to be converted.`\n );\n case WebOrientationLock.ANY:\n return ['portrait', 'landscape'];\n case WebOrientationLock.NATURAL:\n return 'default';\n default:\n return orientationLock;\n }\n}\n\nasync function _lockAsync(webOrientationLock: WebOrientationLock): Promise<void> {\n if (webOrientationLock === WebOrientationLock.UNKNOWN) {\n throw new Error(\n `expo-screen-orientation: WebOrientationLock.UNKNOWN is not a valid lock that can be applied to the device.`\n );\n }\n // @ts-expect-error: This is missing in the TypeScript definitions\n if (screen.orientation && screen.orientation.lock) {\n // @ts-expect-error\n await screen.orientation.lock(webOrientationLock);\n } else if (\n screen['lockOrientation'] ||\n screen['mozLockOrientation'] ||\n screen['msLockOrientation']\n ) {\n const legacyLock = _convertToLegacyOrientationLock(webOrientationLock);\n const lockOrientation =\n screen['lockOrientation'] || screen['mozLockOrientation'] || screen['msLockOrientation'];\n // correct `this` context must be passed in otherwise method call is disallowed by browser\n const isSuccess = lockOrientation.call(screen, legacyLock);\n if (!isSuccess) {\n throw new Error(\n `Applying orientation lock: ${JSON.stringify(webOrientationLock)} to device was denied`\n );\n }\n } else {\n throw new Error(\n `expo-screen-orientation: The browser doesn't support locking screen orientation.`\n );\n }\n}\n\nlet _lastWebOrientationLock: WebOrientationLock = WebOrientationLock.UNKNOWN;\n\nexport default {\n async supportsOrientationLockAsync(orientationLock: OrientationLock): Promise<boolean> {\n return orientationLock in OrientationLockAPIToWeb;\n },\n async getPlatformOrientationLockAsync(): Promise<WebOrientationLock> {\n return _lastWebOrientationLock;\n },\n async getOrientationAsync(): Promise<Orientation> {\n const webOrientation =\n screen['msOrientation'] || (screen.orientation || screen['mozOrientation'] || {}).type;\n if (!webOrientation) {\n return Orientation.UNKNOWN;\n }\n return OrientationWebToAPI[webOrientation];\n },\n async lockAsync(orientationLock: OrientationLock): Promise<void> {\n const webOrientationLock = OrientationLockAPIToWeb[orientationLock];\n if (!webOrientationLock) {\n throw new TypeError(`Invalid Orientation Lock: ${orientationLock}`);\n }\n await _lockAsync(webOrientationLock);\n },\n async lockPlatformAsync(webOrientationLock: WebOrientationLock): Promise<void> {\n await _lockAsync(webOrientationLock);\n _lastWebOrientationLock = webOrientationLock;\n },\n async unlockAsync(): Promise<void> {\n if (screen.orientation && screen.orientation.unlock) {\n screen.orientation.unlock();\n } else if (\n screen['unlockOrientation'] ||\n screen['mozUnlockOrientation'] ||\n screen['msUnlockOrientation']\n ) {\n const unlockOrientation =\n screen['unlockOrientation'] ||\n screen['mozUnlockOrientation'] ||\n screen['msUnlockOrientation'];\n // correct `this` context must be passed in otherwise method call is disallowed by browser\n const isSuccess = unlockOrientation.call(screen);\n if (!isSuccess) {\n throw new Error(`Unlocking screen orientation on device was denied`);\n }\n } else {\n throw new Error(\n `expo-screen-orientation: The browser doesn't support unlocking screen orientation.`\n );\n }\n },\n};\n"]}
@@ -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;;;;;;;;;;;;GAYG;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,CAAC,EAAE;QAC/C,MAAM,IAAI,SAAS,CAAC,6BAA6B,eAAe,EAAE,CAAC,CAAC;KACrE;IAED,IAAI,eAAe,KAAK,eAAe,CAAC,KAAK,EAAE;QAC7C,OAAO;KACR;IAED,MAAM,qBAAqB,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACvD,oBAAoB,GAAG,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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
+ {"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,CAA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EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACjD,uBAAuB,EAAE;gBACzB,mBAAmB,EAAE;aACtB,CAAC,CAAC;YACH,eAAe,GAAG,EAAE,WAAW,EAAE,CAAC;QACpC,CAAC;QACD,QAAQ,CAAC,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;IACF,6BAA6B,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,6FAA6F;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,CAAC;QACX,MAAM,UAAU,GAAG,6BAA6B,CAAC,CAAC,CAAC,CAAC;QACpD,UAAU,CAAC,MAAM,EAAE,CAAC;QAEpB,wCAAwC;QACxC,6BAA6B,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;AACH,CAAC;AAED,cAAc;AACd;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAC,YAA0B;IACxE,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QAC1C,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;IAC3D,CAAC;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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-screen-orientation",
3
- "version": "6.4.1",
3
+ "version": "7.0.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": "43f1b4f8a5a9bca649e4e7ca6e4155482a162431"
44
+ "gitHead": "4165b8d72e1b9a1889c2767534cc619e21468110"
45
45
  }
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setInitialOrientation = exports.INITIAL_ORIENTATION_KEY = void 0;
6
+ exports.INITIAL_ORIENTATION_KEY = void 0;
7
+ exports.setInitialOrientation = setInitialOrientation;
7
8
  const assert_1 = __importDefault(require("assert"));
8
9
  const config_plugins_1 = require("expo/config-plugins");
9
10
  const pkg = require('expo-screen-orientation/package.json');
@@ -40,5 +41,4 @@ function setInitialOrientation(config, infoPlist) {
40
41
  infoPlist[exports.INITIAL_ORIENTATION_KEY] = OrientationLock[initialOrientation];
41
42
  return infoPlist;
42
43
  }
43
- exports.setInitialOrientation = setInitialOrientation;
44
44
  exports.default = (0, config_plugins_1.createRunOncePlugin)(withScreenOrientationViewController, pkg.name, pkg.version);
@@ -1,4 +1,4 @@
1
- import { SyntheticPlatformEmitter, Platform } from 'expo-modules-core';
1
+ import { DeviceEventEmitter, Platform } from 'expo-modules-core';
2
2
 
3
3
  import { getOrientationLockAsync, getOrientationAsync } from './ScreenOrientation';
4
4
  import {
@@ -42,7 +42,7 @@ async function emitOrientationEvent() {
42
42
  getOrientationLockAsync(),
43
43
  getOrientationAsync(),
44
44
  ]);
45
- SyntheticPlatformEmitter.emit('expoDidUpdateDimensions', {
45
+ DeviceEventEmitter.emit('expoDidUpdateDimensions', {
46
46
  orientationLock,
47
47
  orientationInfo: { orientation },
48
48
  });
@@ -77,7 +77,9 @@ async function _lockAsync(webOrientationLock: WebOrientationLock): Promise<void>
77
77
  `expo-screen-orientation: WebOrientationLock.UNKNOWN is not a valid lock that can be applied to the device.`
78
78
  );
79
79
  }
80
+ // @ts-expect-error: This is missing in the TypeScript definitions
80
81
  if (screen.orientation && screen.orientation.lock) {
82
+ // @ts-expect-error
81
83
  await screen.orientation.lock(webOrientationLock);
82
84
  } else if (
83
85
  screen['lockOrientation'] ||
@@ -104,9 +106,6 @@ async function _lockAsync(webOrientationLock: WebOrientationLock): Promise<void>
104
106
  let _lastWebOrientationLock: WebOrientationLock = WebOrientationLock.UNKNOWN;
105
107
 
106
108
  export default {
107
- get name(): string {
108
- return 'ExpoScreenOrientation';
109
- },
110
109
  async supportsOrientationLockAsync(orientationLock: OrientationLock): Promise<boolean> {
111
110
  return orientationLock in OrientationLockAPIToWeb;
112
111
  },