expo-screen-orientation 7.0.1 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/android/build.gradle +2 -2
- package/build/ScreenOrientation.d.ts +1 -1
- package/build/ScreenOrientation.js +1 -1
- package/build/ScreenOrientation.js.map +1 -1
- package/build/ScreenOrientation.types.d.ts +6 -6
- package/build/ScreenOrientation.types.js +3 -3
- package/build/ScreenOrientation.types.js.map +1 -1
- package/package.json +2 -2
- package/src/ScreenOrientation.ts +1 -1
- package/src/ScreenOrientation.types.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 7.0.2 — 2024-04-25
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix reversed `SizeClassIOS` enum values. ([#28448](https://github.com/expo/expo/pull/28448) by [@Simek](https://github.com/Simek))
|
|
18
|
+
|
|
13
19
|
## 7.0.1 — 2024-04-23
|
|
14
20
|
|
|
15
21
|
_This version does not introduce any user-facing changes._
|
|
@@ -18,7 +24,7 @@ _This version does not introduce any user-facing changes._
|
|
|
18
24
|
|
|
19
25
|
### 💡 Others
|
|
20
26
|
|
|
21
|
-
-
|
|
27
|
+
- Drop unused web `name` property. ([#27437](https://github.com/expo/expo/pull/27437) by [@EvanBacon](https://github.com/EvanBacon))
|
|
22
28
|
- Removed deprecated backward compatible Gradle settings. ([#28083](https://github.com/expo/expo/pull/28083) by [@kudo](https://github.com/kudo))
|
|
23
29
|
|
|
24
30
|
## 6.4.1 - 2023-12-19
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'host.exp.exponent'
|
|
4
|
-
version = '7.0.
|
|
4
|
+
version = '7.0.2'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -14,6 +14,6 @@ android {
|
|
|
14
14
|
namespace "expo.modules.screenorientation"
|
|
15
15
|
defaultConfig {
|
|
16
16
|
versionCode 7
|
|
17
|
-
versionName '7.0.
|
|
17
|
+
versionName '7.0.2'
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -29,7 +29,7 @@ export declare function lockPlatformAsync(options: PlatformOrientationInfo): Pro
|
|
|
29
29
|
export declare function unlockAsync(): Promise<void>;
|
|
30
30
|
/**
|
|
31
31
|
* Gets the current screen orientation.
|
|
32
|
-
* @return Returns a promise that fulfils with an [`Orientation`](#
|
|
32
|
+
* @return Returns a promise that fulfils with an [`Orientation`](#orientation)
|
|
33
33
|
* value that reflects the current screen orientation.
|
|
34
34
|
*/
|
|
35
35
|
export declare function getOrientationAsync(): Promise<Orientation>;
|
|
@@ -91,7 +91,7 @@ export async function unlockAsync() {
|
|
|
91
91
|
// @needsAudit
|
|
92
92
|
/**
|
|
93
93
|
* Gets the current screen orientation.
|
|
94
|
-
* @return Returns a promise that fulfils with an [`Orientation`](#
|
|
94
|
+
* @return Returns a promise that fulfils with an [`Orientation`](#orientation)
|
|
95
95
|
* value that reflects the current screen orientation.
|
|
96
96
|
*/
|
|
97
97
|
export async function getOrientationAsync() {
|
|
@@ -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;AA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gBACzB,mBAAmB,EAAE;aACtB,CAAC,CAAC;YACH,eAAe,GAAG,EAAE,WAAW,EAAE,CAAC;SACnC;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;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
|
+
{"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,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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`](#orientation)\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"]}
|
|
@@ -70,13 +70,13 @@ export declare enum OrientationLock {
|
|
|
70
70
|
UNKNOWN = 9
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* Each iOS device has a default set of [size classes](https://developer.apple.com/
|
|
73
|
+
* Each iOS device has a default set of [size classes](https://developer.apple.com/documentation/uikit/uiuserinterfacesizeclass)
|
|
74
74
|
* that you can use as a guide when designing your interface.
|
|
75
75
|
*/
|
|
76
76
|
export declare enum SizeClassIOS {
|
|
77
|
-
|
|
77
|
+
UNKNOWN = 0,
|
|
78
78
|
COMPACT = 1,
|
|
79
|
-
|
|
79
|
+
REGULAR = 2
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* An enum representing the lock policies that can be applied on the web platform, modelled after
|
|
@@ -103,7 +103,7 @@ export declare enum WebOrientation {
|
|
|
103
103
|
}
|
|
104
104
|
export type PlatformOrientationInfo = {
|
|
105
105
|
/**
|
|
106
|
-
* A constant to set using the Android native [API](https://developer.android.com/reference/android/R.attr
|
|
106
|
+
* A constant to set using the Android native [API](https://developer.android.com/reference/android/R.attr#screenOrientation).
|
|
107
107
|
* For example, in order to set the lock policy to [unspecified](https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_UNSPECIFIED),
|
|
108
108
|
* `-1` should be passed in.
|
|
109
109
|
* @platform android
|
|
@@ -126,13 +126,13 @@ export type ScreenOrientationInfo = {
|
|
|
126
126
|
*/
|
|
127
127
|
orientation: Orientation;
|
|
128
128
|
/**
|
|
129
|
-
* The [vertical size class](https://developer.apple.com/
|
|
129
|
+
* The [vertical size class](https://developer.apple.com/documentation/uikit/uitraitcollection/1623513-verticalsizeclass)
|
|
130
130
|
* of the device.
|
|
131
131
|
* @platform ios
|
|
132
132
|
*/
|
|
133
133
|
verticalSizeClass?: SizeClassIOS;
|
|
134
134
|
/**
|
|
135
|
-
* The [horizontal size class](https://developer.apple.com/
|
|
135
|
+
* The [horizontal size class](https://developer.apple.com/documentation/uikit/uitraitcollection/1623508-horizontalsizeclass)
|
|
136
136
|
* of the device.
|
|
137
137
|
* @platform ios
|
|
138
138
|
*/
|
|
@@ -75,14 +75,14 @@ export var OrientationLock;
|
|
|
75
75
|
})(OrientationLock || (OrientationLock = {}));
|
|
76
76
|
// @needsAudit
|
|
77
77
|
/**
|
|
78
|
-
* Each iOS device has a default set of [size classes](https://developer.apple.com/
|
|
78
|
+
* Each iOS device has a default set of [size classes](https://developer.apple.com/documentation/uikit/uiuserinterfacesizeclass)
|
|
79
79
|
* that you can use as a guide when designing your interface.
|
|
80
80
|
*/
|
|
81
81
|
export var SizeClassIOS;
|
|
82
82
|
(function (SizeClassIOS) {
|
|
83
|
-
SizeClassIOS[SizeClassIOS["
|
|
83
|
+
SizeClassIOS[SizeClassIOS["UNKNOWN"] = 0] = "UNKNOWN";
|
|
84
84
|
SizeClassIOS[SizeClassIOS["COMPACT"] = 1] = "COMPACT";
|
|
85
|
-
SizeClassIOS[SizeClassIOS["
|
|
85
|
+
SizeClassIOS[SizeClassIOS["REGULAR"] = 2] = "REGULAR";
|
|
86
86
|
})(SizeClassIOS || (SizeClassIOS = {}));
|
|
87
87
|
// @needsAudit
|
|
88
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScreenOrientation.types.js","sourceRoot":"","sources":["../src/ScreenOrientation.types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;OAEG;IACH,mDAAW,CAAA;IACX;;OAEG;IACH,2DAAe,CAAA;IACf;;OAEG;IACH,+DAAiB,CAAA;IACjB;;OAEG;IACH,iEAAkB,CAAA;IAClB;;OAEG;IACH,mEAAmB,CAAA;AACrB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB;AAED,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAN,IAAY,eA0CX;AA1CD,WAAY,eAAe;IACzB;;;OAGG;IACH,2DAAW,CAAA;IACX;;OAEG;IACH,mDAAO,CAAA;IACP;;OAEG;IACH,6DAAY,CAAA;IACZ;;OAEG;IACH,mEAAe,CAAA;IACf;;OAEG;IACH,uEAAiB,CAAA;IACjB;;OAEG;IACH,+DAAa,CAAA;IACb;;OAEG;IACH,yEAAkB,CAAA;IAClB;;OAEG;IACH,2EAAmB,CAAA;IACnB;;OAEG;IACH,uDAAS,CAAA;IACT;;OAEG;IACH,2DAAW,CAAA;AACb,CAAC,EA1CW,eAAe,KAAf,eAAe,QA0C1B;AAED,cAAc;AACd;;;GAGG;AACH,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,qDAAW,CAAA;IACX,qDAAW,CAAA;AACb,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC5B,2DAAqC,CAAA;IACrC,+DAAyC,CAAA;IACzC,2CAAqB,CAAA;IACrB,6DAAuC,CAAA;IACvC,iEAA2C,CAAA;IAC3C,6CAAuB,CAAA;IACvB,iCAAW,CAAA;IACX,yCAAmB,CAAA;IACnB,yCAAmB,CAAA;AACrB,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B;AAED,eAAe;AACf,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,2DAAyC,CAAA;IACzC,yDAAuC,CAAA;IACvC,6DAA2C,CAAA;AAC7C,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB","sourcesContent":["// @needsAudit\nexport enum Orientation {\n /**\n * An unknown screen orientation. For example, the device is flat, perhaps on a table.\n */\n UNKNOWN = 0,\n /**\n * Right-side up portrait interface orientation.\n */\n PORTRAIT_UP = 1,\n /**\n * Upside down portrait interface orientation.\n */\n PORTRAIT_DOWN = 2,\n /**\n * Left landscape interface orientation.\n */\n LANDSCAPE_LEFT = 3,\n /**\n * Right landscape interface orientation.\n */\n LANDSCAPE_RIGHT = 4,\n}\n\n// @needsAudit\n/**\n * An enum whose values can be passed to the [`lockAsync`](#screenorientationlockasyncorientationlock)\n * method.\n * > __Note:__ `OrientationLock.ALL` and `OrientationLock.PORTRAIT` are invalid on devices which\n * > don't support `OrientationLock.PORTRAIT_DOWN`.\n */\nexport enum OrientationLock {\n /**\n * The default orientation. On iOS, this will allow all orientations except `Orientation.PORTRAIT_DOWN`.\n * On Android, this lets the system decide the best orientation.\n */\n DEFAULT = 0,\n /**\n * All four possible orientations\n */\n ALL = 1,\n /**\n * Any portrait orientation.\n */\n PORTRAIT = 2,\n /**\n * Right-side up portrait only.\n */\n PORTRAIT_UP = 3,\n /**\n * Upside down portrait only.\n */\n PORTRAIT_DOWN = 4,\n /**\n * Any landscape orientation.\n */\n LANDSCAPE = 5,\n /**\n * Left landscape only.\n */\n LANDSCAPE_LEFT = 6,\n /**\n * Right landscape only.\n */\n LANDSCAPE_RIGHT = 7,\n /**\n * A platform specific orientation. This is not a valid policy that can be applied in [`lockAsync`](#screenorientationlockasyncorientationlock).\n */\n OTHER = 8,\n /**\n * An unknown screen orientation lock. This is not a valid policy that can be applied in [`lockAsync`](#screenorientationlockasyncorientationlock).\n */\n UNKNOWN = 9,\n}\n\n// @needsAudit\n/**\n * Each iOS device has a default set of [size classes](https://developer.apple.com/
|
|
1
|
+
{"version":3,"file":"ScreenOrientation.types.js","sourceRoot":"","sources":["../src/ScreenOrientation.types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;OAEG;IACH,mDAAW,CAAA;IACX;;OAEG;IACH,2DAAe,CAAA;IACf;;OAEG;IACH,+DAAiB,CAAA;IACjB;;OAEG;IACH,iEAAkB,CAAA;IAClB;;OAEG;IACH,mEAAmB,CAAA;AACrB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB;AAED,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAN,IAAY,eA0CX;AA1CD,WAAY,eAAe;IACzB;;;OAGG;IACH,2DAAW,CAAA;IACX;;OAEG;IACH,mDAAO,CAAA;IACP;;OAEG;IACH,6DAAY,CAAA;IACZ;;OAEG;IACH,mEAAe,CAAA;IACf;;OAEG;IACH,uEAAiB,CAAA;IACjB;;OAEG;IACH,+DAAa,CAAA;IACb;;OAEG;IACH,yEAAkB,CAAA;IAClB;;OAEG;IACH,2EAAmB,CAAA;IACnB;;OAEG;IACH,uDAAS,CAAA;IACT;;OAEG;IACH,2DAAW,CAAA;AACb,CAAC,EA1CW,eAAe,KAAf,eAAe,QA0C1B;AAED,cAAc;AACd;;;GAGG;AACH,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,qDAAW,CAAA;IACX,qDAAW,CAAA;AACb,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,cAAc;AACd;;;;;GAKG;AACH,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC5B,2DAAqC,CAAA;IACrC,+DAAyC,CAAA;IACzC,2CAAqB,CAAA;IACrB,6DAAuC,CAAA;IACvC,iEAA2C,CAAA;IAC3C,6CAAuB,CAAA;IACvB,iCAAW,CAAA;IACX,yCAAmB,CAAA;IACnB,yCAAmB,CAAA;AACrB,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B;AAED,eAAe;AACf,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,2DAAyC,CAAA;IACzC,yDAAuC,CAAA;IACvC,6DAA2C,CAAA;AAC7C,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB","sourcesContent":["// @needsAudit\nexport enum Orientation {\n /**\n * An unknown screen orientation. For example, the device is flat, perhaps on a table.\n */\n UNKNOWN = 0,\n /**\n * Right-side up portrait interface orientation.\n */\n PORTRAIT_UP = 1,\n /**\n * Upside down portrait interface orientation.\n */\n PORTRAIT_DOWN = 2,\n /**\n * Left landscape interface orientation.\n */\n LANDSCAPE_LEFT = 3,\n /**\n * Right landscape interface orientation.\n */\n LANDSCAPE_RIGHT = 4,\n}\n\n// @needsAudit\n/**\n * An enum whose values can be passed to the [`lockAsync`](#screenorientationlockasyncorientationlock)\n * method.\n * > __Note:__ `OrientationLock.ALL` and `OrientationLock.PORTRAIT` are invalid on devices which\n * > don't support `OrientationLock.PORTRAIT_DOWN`.\n */\nexport enum OrientationLock {\n /**\n * The default orientation. On iOS, this will allow all orientations except `Orientation.PORTRAIT_DOWN`.\n * On Android, this lets the system decide the best orientation.\n */\n DEFAULT = 0,\n /**\n * All four possible orientations\n */\n ALL = 1,\n /**\n * Any portrait orientation.\n */\n PORTRAIT = 2,\n /**\n * Right-side up portrait only.\n */\n PORTRAIT_UP = 3,\n /**\n * Upside down portrait only.\n */\n PORTRAIT_DOWN = 4,\n /**\n * Any landscape orientation.\n */\n LANDSCAPE = 5,\n /**\n * Left landscape only.\n */\n LANDSCAPE_LEFT = 6,\n /**\n * Right landscape only.\n */\n LANDSCAPE_RIGHT = 7,\n /**\n * A platform specific orientation. This is not a valid policy that can be applied in [`lockAsync`](#screenorientationlockasyncorientationlock).\n */\n OTHER = 8,\n /**\n * An unknown screen orientation lock. This is not a valid policy that can be applied in [`lockAsync`](#screenorientationlockasyncorientationlock).\n */\n UNKNOWN = 9,\n}\n\n// @needsAudit\n/**\n * Each iOS device has a default set of [size classes](https://developer.apple.com/documentation/uikit/uiuserinterfacesizeclass)\n * that you can use as a guide when designing your interface.\n */\nexport enum SizeClassIOS {\n UNKNOWN = 0,\n COMPACT = 1,\n REGULAR = 2,\n}\n\n// @needsAudit\n/**\n * An enum representing the lock policies that can be applied on the web platform, modelled after\n * the [W3C specification](https://w3c.github.io/screen-orientation/#dom-orientationlocktype).\n * These values can be applied through the [`lockPlatformAsync`](#screenorientationlockplatformasyncoptions)\n * method.\n */\nexport enum WebOrientationLock {\n PORTRAIT_PRIMARY = 'portrait-primary',\n PORTRAIT_SECONDARY = 'portrait-secondary',\n PORTRAIT = 'portrait',\n LANDSCAPE_PRIMARY = 'landscape-primary',\n LANDSCAPE_SECONDARY = 'landscape-secondary',\n LANDSCAPE = 'landscape',\n ANY = 'any',\n NATURAL = 'natural',\n UNKNOWN = 'unknown',\n}\n\n// @docsMissing\nexport enum WebOrientation {\n PORTRAIT_PRIMARY = 'portrait-primary',\n PORTRAIT_SECONDARY = 'portrait-secondary',\n LANDSCAPE_PRIMARY = 'landscape-primary',\n LANDSCAPE_SECONDARY = 'landscape-secondary',\n}\n\n// @needsAudit\nexport type PlatformOrientationInfo = {\n /**\n * A constant to set using the Android native [API](https://developer.android.com/reference/android/R.attr#screenOrientation).\n * For example, in order to set the lock policy to [unspecified](https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_UNSPECIFIED),\n * `-1` should be passed in.\n * @platform android\n */\n screenOrientationConstantAndroid?: number;\n /**\n * An array of orientations to allow on the iOS platform.\n * @platform ios\n */\n screenOrientationArrayIOS?: Orientation[];\n /**\n * A web orientation lock to apply in the browser.\n * @platform web\n */\n screenOrientationLockWeb?: WebOrientationLock;\n};\n\n// @needsAudit\nexport type ScreenOrientationInfo = {\n /**\n * The current orientation of the device.\n */\n orientation: Orientation;\n /**\n * The [vertical size class](https://developer.apple.com/documentation/uikit/uitraitcollection/1623513-verticalsizeclass)\n * of the device.\n * @platform ios\n */\n verticalSizeClass?: SizeClassIOS;\n /**\n * The [horizontal size class](https://developer.apple.com/documentation/uikit/uitraitcollection/1623508-horizontalsizeclass)\n * of the device.\n * @platform ios\n */\n horizontalSizeClass?: SizeClassIOS;\n};\n\nexport type OrientationChangeListener = (event: OrientationChangeEvent) => void;\n\n// @needsAudit\nexport type OrientationChangeEvent = {\n /**\n * The current `OrientationLock` of the device.\n */\n orientationLock: OrientationLock;\n /**\n * The current `ScreenOrientationInfo` of the device.\n */\n orientationInfo: ScreenOrientationInfo;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-screen-orientation",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
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": "
|
|
44
|
+
"gitHead": "f47e3af17a790a34b95fe10dda8383389e7d74e2"
|
|
45
45
|
}
|
package/src/ScreenOrientation.ts
CHANGED
|
@@ -131,7 +131,7 @@ export async function unlockAsync(): Promise<void> {
|
|
|
131
131
|
// @needsAudit
|
|
132
132
|
/**
|
|
133
133
|
* Gets the current screen orientation.
|
|
134
|
-
* @return Returns a promise that fulfils with an [`Orientation`](#
|
|
134
|
+
* @return Returns a promise that fulfils with an [`Orientation`](#orientation)
|
|
135
135
|
* value that reflects the current screen orientation.
|
|
136
136
|
*/
|
|
137
137
|
export async function getOrientationAsync(): Promise<Orientation> {
|
|
@@ -75,13 +75,13 @@ export enum OrientationLock {
|
|
|
75
75
|
|
|
76
76
|
// @needsAudit
|
|
77
77
|
/**
|
|
78
|
-
* Each iOS device has a default set of [size classes](https://developer.apple.com/
|
|
78
|
+
* Each iOS device has a default set of [size classes](https://developer.apple.com/documentation/uikit/uiuserinterfacesizeclass)
|
|
79
79
|
* that you can use as a guide when designing your interface.
|
|
80
80
|
*/
|
|
81
81
|
export enum SizeClassIOS {
|
|
82
|
-
|
|
82
|
+
UNKNOWN = 0,
|
|
83
83
|
COMPACT = 1,
|
|
84
|
-
|
|
84
|
+
REGULAR = 2,
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// @needsAudit
|
|
@@ -114,7 +114,7 @@ export enum WebOrientation {
|
|
|
114
114
|
// @needsAudit
|
|
115
115
|
export type PlatformOrientationInfo = {
|
|
116
116
|
/**
|
|
117
|
-
* A constant to set using the Android native [API](https://developer.android.com/reference/android/R.attr
|
|
117
|
+
* A constant to set using the Android native [API](https://developer.android.com/reference/android/R.attr#screenOrientation).
|
|
118
118
|
* For example, in order to set the lock policy to [unspecified](https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_UNSPECIFIED),
|
|
119
119
|
* `-1` should be passed in.
|
|
120
120
|
* @platform android
|
|
@@ -139,13 +139,13 @@ export type ScreenOrientationInfo = {
|
|
|
139
139
|
*/
|
|
140
140
|
orientation: Orientation;
|
|
141
141
|
/**
|
|
142
|
-
* The [vertical size class](https://developer.apple.com/
|
|
142
|
+
* The [vertical size class](https://developer.apple.com/documentation/uikit/uitraitcollection/1623513-verticalsizeclass)
|
|
143
143
|
* of the device.
|
|
144
144
|
* @platform ios
|
|
145
145
|
*/
|
|
146
146
|
verticalSizeClass?: SizeClassIOS;
|
|
147
147
|
/**
|
|
148
|
-
* The [horizontal size class](https://developer.apple.com/
|
|
148
|
+
* The [horizontal size class](https://developer.apple.com/documentation/uikit/uitraitcollection/1623508-horizontalsizeclass)
|
|
149
149
|
* of the device.
|
|
150
150
|
* @platform ios
|
|
151
151
|
*/
|