expo-screen-orientation 6.0.3 → 6.0.4
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 -0
- package/android/build.gradle +2 -2
- package/ios/ScreenOrientationModule.swift +10 -2
- package/ios/ScreenOrientationRegistry.swift +2 -1
- package/package.json +2 -2
- package/plugin/build/withScreenOrientation.d.ts +0 -1
- package/plugin/build/withScreenOrientation.js +7 -12
- package/plugin/src/withScreenOrientation.ts +9 -13
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 6.0.4 — 2023-07-23
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- [iOS] Fix event emitter sending events with no registered listeners. ([#23462](https://github.com/expo/expo/pull/23462) by [@behenate](https://github.com/behenate))
|
|
18
|
+
- [iOS] Fix config plugin deleting the orientations key from `Info.plist` when the initial orientation value is set to `DEFAULT`. ([#23637](https://github.com/expo/expo/pull/23637) by [@behenate](https://github.com/behenate))
|
|
19
|
+
|
|
13
20
|
## 6.0.3 — 2023-07-12
|
|
14
21
|
|
|
15
22
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '6.0.
|
|
6
|
+
version = '6.0.4'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -67,7 +67,7 @@ android {
|
|
|
67
67
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
68
68
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
69
69
|
versionCode 7
|
|
70
|
-
versionName '6.0.
|
|
70
|
+
versionName '6.0.4'
|
|
71
71
|
}
|
|
72
72
|
lintOptions {
|
|
73
73
|
abortOnError false
|
|
@@ -4,7 +4,7 @@ public class ScreenOrientationModule: Module, ScreenOrientationController {
|
|
|
4
4
|
static let didUpdateDimensionsEvent = "expoDidUpdateDimensions"
|
|
5
5
|
|
|
6
6
|
let screenOrientationRegistry = ScreenOrientationRegistry.shared
|
|
7
|
-
var
|
|
7
|
+
var shouldEmitEvents = false
|
|
8
8
|
|
|
9
9
|
public func definition() -> ModuleDefinition {
|
|
10
10
|
Name("ExpoScreenOrientation")
|
|
@@ -82,12 +82,20 @@ public class ScreenOrientationModule: Module, ScreenOrientationController {
|
|
|
82
82
|
OnDestroy {
|
|
83
83
|
screenOrientationRegistry.unregisterController(self)
|
|
84
84
|
}
|
|
85
|
+
|
|
86
|
+
OnStartObserving {
|
|
87
|
+
shouldEmitEvents = true
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
OnStopObserving {
|
|
91
|
+
shouldEmitEvents = false
|
|
92
|
+
}
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
// MARK: - ScreenOrientationController
|
|
88
96
|
|
|
89
97
|
public func screenOrientationDidChange(_ orientation: UIInterfaceOrientation) {
|
|
90
|
-
guard let currentTraitCollection = screenOrientationRegistry.currentTraitCollection else {
|
|
98
|
+
guard let currentTraitCollection = screenOrientationRegistry.currentTraitCollection, shouldEmitEvents else {
|
|
91
99
|
return
|
|
92
100
|
}
|
|
93
101
|
|
|
@@ -79,7 +79,8 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
79
79
|
/**
|
|
80
80
|
Rotates the view to currentScreenOrientation or default orientation from the orientationMask.
|
|
81
81
|
*/
|
|
82
|
-
|
|
82
|
+
@objc
|
|
83
|
+
public func enforceDesiredDeviceOrientation(withOrientationMask orientationMask: UIInterfaceOrientationMask) {
|
|
83
84
|
var newOrientation = orientationMask.defaultOrientation()
|
|
84
85
|
|
|
85
86
|
if orientationMask.contains(currentScreenOrientation) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-screen-orientation",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
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": "c0d646e9295094bca877513e500d3c9f2e990c42"
|
|
45
45
|
}
|
|
@@ -15,7 +15,6 @@ type OrientationMasks = keyof typeof OrientationLock;
|
|
|
15
15
|
interface ExpoConfigWithInitialOrientation extends ExpoConfig {
|
|
16
16
|
initialOrientation?: OrientationMasks;
|
|
17
17
|
}
|
|
18
|
-
export declare function getInitialOrientation(config: Pick<ExpoConfigWithInitialOrientation, 'initialOrientation'>): OrientationMasks;
|
|
19
18
|
export declare function setInitialOrientation(config: Pick<ExpoConfigWithInitialOrientation, 'initialOrientation'>, infoPlist: InfoPlist): InfoPlist;
|
|
20
19
|
declare const _default: ConfigPlugin<void | {
|
|
21
20
|
initialOrientation?: "DEFAULT" | "ALL" | "PORTRAIT" | "PORTRAIT_UP" | "PORTRAIT_DOWN" | "LANDSCAPE" | "LANDSCAPE_LEFT" | "LANDSCAPE_RIGHT" | undefined;
|
|
@@ -3,7 +3,7 @@ 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.
|
|
6
|
+
exports.setInitialOrientation = exports.INITIAL_ORIENTATION_KEY = void 0;
|
|
7
7
|
const assert_1 = __importDefault(require("assert"));
|
|
8
8
|
const config_plugins_1 = require("expo/config-plugins");
|
|
9
9
|
const pkg = require('expo-screen-orientation/package.json');
|
|
@@ -19,7 +19,7 @@ const OrientationLock = {
|
|
|
19
19
|
LANDSCAPE_LEFT: 'UIInterfaceOrientationMaskLandscapeLeft',
|
|
20
20
|
LANDSCAPE_RIGHT: 'UIInterfaceOrientationMaskLandscapeRight',
|
|
21
21
|
};
|
|
22
|
-
const withScreenOrientationViewController = (config, { initialOrientation
|
|
22
|
+
const withScreenOrientationViewController = (config, { initialOrientation } = {}) => {
|
|
23
23
|
config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
|
|
24
24
|
const extendedConfig = {
|
|
25
25
|
...config,
|
|
@@ -30,19 +30,14 @@ const withScreenOrientationViewController = (config, { initialOrientation = 'DEF
|
|
|
30
30
|
});
|
|
31
31
|
return config;
|
|
32
32
|
};
|
|
33
|
-
function getInitialOrientation(config) {
|
|
34
|
-
return config.initialOrientation ?? 'DEFAULT';
|
|
35
|
-
}
|
|
36
|
-
exports.getInitialOrientation = getInitialOrientation;
|
|
37
33
|
function setInitialOrientation(config, infoPlist) {
|
|
38
|
-
const initialOrientation =
|
|
39
|
-
|
|
40
|
-
if (initialOrientation === 'DEFAULT') {
|
|
34
|
+
const initialOrientation = config.initialOrientation;
|
|
35
|
+
if (!initialOrientation) {
|
|
41
36
|
delete infoPlist[exports.INITIAL_ORIENTATION_KEY];
|
|
37
|
+
return infoPlist;
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
39
|
+
(0, assert_1.default)(initialOrientation in OrientationLock, `Invalid initial orientation "${initialOrientation}" expected one of: ${Object.keys(OrientationLock).join(', ')}`);
|
|
40
|
+
infoPlist[exports.INITIAL_ORIENTATION_KEY] = OrientationLock[initialOrientation];
|
|
46
41
|
return infoPlist;
|
|
47
42
|
}
|
|
48
43
|
exports.setInitialOrientation = setInitialOrientation;
|
|
@@ -29,7 +29,7 @@ const withScreenOrientationViewController: ConfigPlugin<
|
|
|
29
29
|
{
|
|
30
30
|
initialOrientation?: keyof typeof OrientationLock;
|
|
31
31
|
} | void
|
|
32
|
-
> = (config, { initialOrientation
|
|
32
|
+
> = (config, { initialOrientation } = {}) => {
|
|
33
33
|
config = withInfoPlist(config, (config) => {
|
|
34
34
|
const extendedConfig = {
|
|
35
35
|
...config,
|
|
@@ -41,17 +41,16 @@ const withScreenOrientationViewController: ConfigPlugin<
|
|
|
41
41
|
return config;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
export function getInitialOrientation(
|
|
45
|
-
config: Pick<ExpoConfigWithInitialOrientation, 'initialOrientation'>
|
|
46
|
-
): OrientationMasks {
|
|
47
|
-
return config.initialOrientation ?? 'DEFAULT';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
44
|
export function setInitialOrientation(
|
|
51
45
|
config: Pick<ExpoConfigWithInitialOrientation, 'initialOrientation'>,
|
|
52
46
|
infoPlist: InfoPlist
|
|
53
47
|
): InfoPlist {
|
|
54
|
-
const initialOrientation =
|
|
48
|
+
const initialOrientation = config.initialOrientation;
|
|
49
|
+
|
|
50
|
+
if (!initialOrientation) {
|
|
51
|
+
delete infoPlist[INITIAL_ORIENTATION_KEY];
|
|
52
|
+
return infoPlist;
|
|
53
|
+
}
|
|
55
54
|
|
|
56
55
|
assert(
|
|
57
56
|
initialOrientation in OrientationLock,
|
|
@@ -60,11 +59,8 @@ export function setInitialOrientation(
|
|
|
60
59
|
).join(', ')}`
|
|
61
60
|
);
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} else {
|
|
66
|
-
infoPlist[INITIAL_ORIENTATION_KEY] = OrientationLock[initialOrientation];
|
|
67
|
-
}
|
|
62
|
+
infoPlist[INITIAL_ORIENTATION_KEY] = OrientationLock[initialOrientation];
|
|
63
|
+
|
|
68
64
|
return infoPlist;
|
|
69
65
|
}
|
|
70
66
|
|