@capawesome/capacitor-screen-orientation 2.0.1 → 2.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/CapawesomeCapacitorScreenOrientation.podspec +17 -17
- package/LICENSE +21 -21
- package/README.md +93 -93
- package/android/build.gradle +57 -57
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenorientation/ScreenOrientation.java +87 -87
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenorientation/ScreenOrientationPlugin.java +56 -56
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenorientation/ScreenOrientationType.java +11 -11
- package/dist/esm/definitions.d.ts +71 -71
- package/dist/esm/definitions.js +27 -27
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +6 -6
- package/dist/esm/web.d.ts +11 -11
- package/dist/esm/web.js +48 -48
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +73 -73
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +73 -73
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Info.plist +24 -24
- package/ios/Plugin/ScreenOrientation.swift +171 -150
- package/ios/Plugin/ScreenOrientationPlugin.h +10 -10
- package/ios/Plugin/ScreenOrientationPlugin.m +11 -11
- package/ios/Plugin/ScreenOrientationPlugin.swift +47 -47
- package/package.json +94 -94
package/dist/plugin.cjs.js
CHANGED
|
@@ -4,83 +4,83 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@capacitor/core');
|
|
6
6
|
|
|
7
|
-
exports.OrientationType = void 0;
|
|
8
|
-
(function (OrientationType) {
|
|
9
|
-
/**
|
|
10
|
-
* The orientation is either landscape-primary or landscape-secondary.
|
|
11
|
-
*/
|
|
12
|
-
OrientationType["LANDSCAPE"] = "landscape";
|
|
13
|
-
/**
|
|
14
|
-
* The orientation is in the primary landscape mode.
|
|
15
|
-
*/
|
|
16
|
-
OrientationType["LANDSCAPE_PRIMARY"] = "landscape-primary";
|
|
17
|
-
/**
|
|
18
|
-
* The orientation is in the secondary landscape mode.
|
|
19
|
-
*/
|
|
20
|
-
OrientationType["LANDSCAPE_SECONDARY"] = "landscape-secondary";
|
|
21
|
-
/**
|
|
22
|
-
* The orientation is either portrait-primary or portrait-secondary.
|
|
23
|
-
*/
|
|
24
|
-
OrientationType["PORTRAIT"] = "portrait";
|
|
25
|
-
/**
|
|
26
|
-
* The orientation is in the primary portrait mode.
|
|
27
|
-
*/
|
|
28
|
-
OrientationType["PORTRAIT_PRIMARY"] = "portrait-primary";
|
|
29
|
-
/**
|
|
30
|
-
* The orientation is in the secondary portrait mode.
|
|
31
|
-
*/
|
|
32
|
-
OrientationType["PORTRAIT_SECONDARY"] = "portrait-secondary";
|
|
7
|
+
exports.OrientationType = void 0;
|
|
8
|
+
(function (OrientationType) {
|
|
9
|
+
/**
|
|
10
|
+
* The orientation is either landscape-primary or landscape-secondary.
|
|
11
|
+
*/
|
|
12
|
+
OrientationType["LANDSCAPE"] = "landscape";
|
|
13
|
+
/**
|
|
14
|
+
* The orientation is in the primary landscape mode.
|
|
15
|
+
*/
|
|
16
|
+
OrientationType["LANDSCAPE_PRIMARY"] = "landscape-primary";
|
|
17
|
+
/**
|
|
18
|
+
* The orientation is in the secondary landscape mode.
|
|
19
|
+
*/
|
|
20
|
+
OrientationType["LANDSCAPE_SECONDARY"] = "landscape-secondary";
|
|
21
|
+
/**
|
|
22
|
+
* The orientation is either portrait-primary or portrait-secondary.
|
|
23
|
+
*/
|
|
24
|
+
OrientationType["PORTRAIT"] = "portrait";
|
|
25
|
+
/**
|
|
26
|
+
* The orientation is in the primary portrait mode.
|
|
27
|
+
*/
|
|
28
|
+
OrientationType["PORTRAIT_PRIMARY"] = "portrait-primary";
|
|
29
|
+
/**
|
|
30
|
+
* The orientation is in the secondary portrait mode.
|
|
31
|
+
*/
|
|
32
|
+
OrientationType["PORTRAIT_SECONDARY"] = "portrait-secondary";
|
|
33
33
|
})(exports.OrientationType || (exports.OrientationType = {}));
|
|
34
34
|
|
|
35
|
-
const ScreenOrientation = core.registerPlugin('ScreenOrientation', {
|
|
36
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ScreenOrientationWeb()),
|
|
35
|
+
const ScreenOrientation = core.registerPlugin('ScreenOrientation', {
|
|
36
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ScreenOrientationWeb()),
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
class ScreenOrientationWeb extends core.WebPlugin {
|
|
40
|
-
constructor() {
|
|
41
|
-
super();
|
|
42
|
-
this.isSupported = 'orientation' in screen;
|
|
43
|
-
this.handleOrientationChange = async () => {
|
|
44
|
-
const result = await this.getCurrentOrientation();
|
|
45
|
-
const changeEvent = {
|
|
46
|
-
type: result.type,
|
|
47
|
-
};
|
|
48
|
-
this.notifyListeners('screenOrientationChange', changeEvent);
|
|
49
|
-
};
|
|
50
|
-
if (this.isSupported) {
|
|
51
|
-
screen.orientation.addEventListener('change', this.handleOrientationChange);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async lock(options) {
|
|
55
|
-
if (!this.isSupported) {
|
|
56
|
-
this.throwUnsupportedError();
|
|
57
|
-
}
|
|
58
|
-
await screen.orientation.lock(options.type);
|
|
59
|
-
}
|
|
60
|
-
async unlock() {
|
|
61
|
-
if (!this.isSupported) {
|
|
62
|
-
this.throwUnsupportedError();
|
|
63
|
-
}
|
|
64
|
-
screen.orientation.unlock();
|
|
65
|
-
}
|
|
66
|
-
async getCurrentOrientation() {
|
|
67
|
-
if (!this.isSupported) {
|
|
68
|
-
this.throwUnsupportedError();
|
|
69
|
-
}
|
|
70
|
-
switch (screen.orientation.type) {
|
|
71
|
-
case 'landscape-primary':
|
|
72
|
-
return { type: exports.OrientationType.LANDSCAPE_PRIMARY };
|
|
73
|
-
case 'landscape-secondary':
|
|
74
|
-
return { type: exports.OrientationType.LANDSCAPE_SECONDARY };
|
|
75
|
-
case 'portrait-secondary':
|
|
76
|
-
return { type: exports.OrientationType.PORTRAIT_SECONDARY };
|
|
77
|
-
default:
|
|
78
|
-
return { type: exports.OrientationType.PORTRAIT_PRIMARY };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
throwUnsupportedError() {
|
|
82
|
-
throw this.unavailable('Screen Orientation API not available in this browser.');
|
|
83
|
-
}
|
|
39
|
+
class ScreenOrientationWeb extends core.WebPlugin {
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
this.isSupported = 'orientation' in screen;
|
|
43
|
+
this.handleOrientationChange = async () => {
|
|
44
|
+
const result = await this.getCurrentOrientation();
|
|
45
|
+
const changeEvent = {
|
|
46
|
+
type: result.type,
|
|
47
|
+
};
|
|
48
|
+
this.notifyListeners('screenOrientationChange', changeEvent);
|
|
49
|
+
};
|
|
50
|
+
if (this.isSupported) {
|
|
51
|
+
screen.orientation.addEventListener('change', this.handleOrientationChange);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async lock(options) {
|
|
55
|
+
if (!this.isSupported) {
|
|
56
|
+
this.throwUnsupportedError();
|
|
57
|
+
}
|
|
58
|
+
await screen.orientation.lock(options.type);
|
|
59
|
+
}
|
|
60
|
+
async unlock() {
|
|
61
|
+
if (!this.isSupported) {
|
|
62
|
+
this.throwUnsupportedError();
|
|
63
|
+
}
|
|
64
|
+
screen.orientation.unlock();
|
|
65
|
+
}
|
|
66
|
+
async getCurrentOrientation() {
|
|
67
|
+
if (!this.isSupported) {
|
|
68
|
+
this.throwUnsupportedError();
|
|
69
|
+
}
|
|
70
|
+
switch (screen.orientation.type) {
|
|
71
|
+
case 'landscape-primary':
|
|
72
|
+
return { type: exports.OrientationType.LANDSCAPE_PRIMARY };
|
|
73
|
+
case 'landscape-secondary':
|
|
74
|
+
return { type: exports.OrientationType.LANDSCAPE_SECONDARY };
|
|
75
|
+
case 'portrait-secondary':
|
|
76
|
+
return { type: exports.OrientationType.PORTRAIT_SECONDARY };
|
|
77
|
+
default:
|
|
78
|
+
return { type: exports.OrientationType.PORTRAIT_PRIMARY };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
throwUnsupportedError() {
|
|
82
|
+
throw this.unavailable('Screen Orientation API not available in this browser.');
|
|
83
|
+
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var OrientationType;\
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var OrientationType;\n(function (OrientationType) {\n /**\n * The orientation is either landscape-primary or landscape-secondary.\n */\n OrientationType[\"LANDSCAPE\"] = \"landscape\";\n /**\n * The orientation is in the primary landscape mode.\n */\n OrientationType[\"LANDSCAPE_PRIMARY\"] = \"landscape-primary\";\n /**\n * The orientation is in the secondary landscape mode.\n */\n OrientationType[\"LANDSCAPE_SECONDARY\"] = \"landscape-secondary\";\n /**\n * The orientation is either portrait-primary or portrait-secondary.\n */\n OrientationType[\"PORTRAIT\"] = \"portrait\";\n /**\n * The orientation is in the primary portrait mode.\n */\n OrientationType[\"PORTRAIT_PRIMARY\"] = \"portrait-primary\";\n /**\n * The orientation is in the secondary portrait mode.\n */\n OrientationType[\"PORTRAIT_SECONDARY\"] = \"portrait-secondary\";\n})(OrientationType || (OrientationType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst ScreenOrientation = registerPlugin('ScreenOrientation', {\n web: () => import('./web').then(m => new m.ScreenOrientationWeb()),\n});\nexport * from './definitions';\nexport { ScreenOrientation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { OrientationType } from './definitions';\nexport class ScreenOrientationWeb extends WebPlugin {\n constructor() {\n super();\n this.isSupported = 'orientation' in screen;\n this.handleOrientationChange = async () => {\n const result = await this.getCurrentOrientation();\n const changeEvent = {\n type: result.type,\n };\n this.notifyListeners('screenOrientationChange', changeEvent);\n };\n if (this.isSupported) {\n screen.orientation.addEventListener('change', this.handleOrientationChange);\n }\n }\n async lock(options) {\n if (!this.isSupported) {\n this.throwUnsupportedError();\n }\n await screen.orientation.lock(options.type);\n }\n async unlock() {\n if (!this.isSupported) {\n this.throwUnsupportedError();\n }\n screen.orientation.unlock();\n }\n async getCurrentOrientation() {\n if (!this.isSupported) {\n this.throwUnsupportedError();\n }\n switch (screen.orientation.type) {\n case 'landscape-primary':\n return { type: OrientationType.LANDSCAPE_PRIMARY };\n case 'landscape-secondary':\n return { type: OrientationType.LANDSCAPE_SECONDARY };\n case 'portrait-secondary':\n return { type: OrientationType.PORTRAIT_SECONDARY };\n default:\n return { type: OrientationType.PORTRAIT_PRIMARY };\n }\n }\n throwUnsupportedError() {\n throw this.unavailable('Screen Orientation API not available in this browser.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["OrientationType","registerPlugin","WebPlugin"],"mappings":";;;;;;AAAWA,iCAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B;AACA;AACA;AACA,IAAI,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAC/C;AACA;AACA;AACA,IAAI,eAAe,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAC/D;AACA;AACA;AACA,IAAI,eAAe,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;AACnE;AACA;AACA;AACA,IAAI,eAAe,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC7C;AACA;AACA;AACA,IAAI,eAAe,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC7D;AACA;AACA;AACA,IAAI,eAAe,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,CAAC;AACjE,CAAC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AQ,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;AACpC,KAAK;AACL,IAAI,MAAM,qBAAqB,GAAG;AAClC,QAAQ,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;AAC/B,YAAY,IAAI,CAAC,qBAAqB,EAAE,CAAC;AACzC,SAAS;AACT,QAAQ,QAAQ,MAAM,CAAC,WAAW,CAAC,IAAI;AACvC,YAAY,KAAK,mBAAmB;AACpC,gBAAgB,OAAO,EAAE,IAAI,EAAEF,uBAAe,CAAC,iBAAiB,EAAE,CAAC;AACnE,YAAY,KAAK,qBAAqB;AACtC,gBAAgB,OAAO,EAAE,IAAI,EAAEA,uBAAe,CAAC,mBAAmB,EAAE,CAAC;AACrE,YAAY,KAAK,oBAAoB;AACrC,gBAAgB,OAAO,EAAE,IAAI,EAAEA,uBAAe,CAAC,kBAAkB,EAAE,CAAC;AACpE,YAAY;AACZ,gBAAgB,OAAO,EAAE,IAAI,EAAEA,uBAAe,CAAC,gBAAgB,EAAE,CAAC;AAClE,SAAS;AACT,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,uDAAuD,CAAC,CAAC;AACxF,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
1
|
var capacitorScreenOrientation = (function (exports, core) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
exports.OrientationType = void 0;
|
|
5
|
-
(function (OrientationType) {
|
|
6
|
-
/**
|
|
7
|
-
* The orientation is either landscape-primary or landscape-secondary.
|
|
8
|
-
*/
|
|
9
|
-
OrientationType["LANDSCAPE"] = "landscape";
|
|
10
|
-
/**
|
|
11
|
-
* The orientation is in the primary landscape mode.
|
|
12
|
-
*/
|
|
13
|
-
OrientationType["LANDSCAPE_PRIMARY"] = "landscape-primary";
|
|
14
|
-
/**
|
|
15
|
-
* The orientation is in the secondary landscape mode.
|
|
16
|
-
*/
|
|
17
|
-
OrientationType["LANDSCAPE_SECONDARY"] = "landscape-secondary";
|
|
18
|
-
/**
|
|
19
|
-
* The orientation is either portrait-primary or portrait-secondary.
|
|
20
|
-
*/
|
|
21
|
-
OrientationType["PORTRAIT"] = "portrait";
|
|
22
|
-
/**
|
|
23
|
-
* The orientation is in the primary portrait mode.
|
|
24
|
-
*/
|
|
25
|
-
OrientationType["PORTRAIT_PRIMARY"] = "portrait-primary";
|
|
26
|
-
/**
|
|
27
|
-
* The orientation is in the secondary portrait mode.
|
|
28
|
-
*/
|
|
29
|
-
OrientationType["PORTRAIT_SECONDARY"] = "portrait-secondary";
|
|
4
|
+
exports.OrientationType = void 0;
|
|
5
|
+
(function (OrientationType) {
|
|
6
|
+
/**
|
|
7
|
+
* The orientation is either landscape-primary or landscape-secondary.
|
|
8
|
+
*/
|
|
9
|
+
OrientationType["LANDSCAPE"] = "landscape";
|
|
10
|
+
/**
|
|
11
|
+
* The orientation is in the primary landscape mode.
|
|
12
|
+
*/
|
|
13
|
+
OrientationType["LANDSCAPE_PRIMARY"] = "landscape-primary";
|
|
14
|
+
/**
|
|
15
|
+
* The orientation is in the secondary landscape mode.
|
|
16
|
+
*/
|
|
17
|
+
OrientationType["LANDSCAPE_SECONDARY"] = "landscape-secondary";
|
|
18
|
+
/**
|
|
19
|
+
* The orientation is either portrait-primary or portrait-secondary.
|
|
20
|
+
*/
|
|
21
|
+
OrientationType["PORTRAIT"] = "portrait";
|
|
22
|
+
/**
|
|
23
|
+
* The orientation is in the primary portrait mode.
|
|
24
|
+
*/
|
|
25
|
+
OrientationType["PORTRAIT_PRIMARY"] = "portrait-primary";
|
|
26
|
+
/**
|
|
27
|
+
* The orientation is in the secondary portrait mode.
|
|
28
|
+
*/
|
|
29
|
+
OrientationType["PORTRAIT_SECONDARY"] = "portrait-secondary";
|
|
30
30
|
})(exports.OrientationType || (exports.OrientationType = {}));
|
|
31
31
|
|
|
32
|
-
const ScreenOrientation = core.registerPlugin('ScreenOrientation', {
|
|
33
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ScreenOrientationWeb()),
|
|
32
|
+
const ScreenOrientation = core.registerPlugin('ScreenOrientation', {
|
|
33
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ScreenOrientationWeb()),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
class ScreenOrientationWeb extends core.WebPlugin {
|
|
37
|
-
constructor() {
|
|
38
|
-
super();
|
|
39
|
-
this.isSupported = 'orientation' in screen;
|
|
40
|
-
this.handleOrientationChange = async () => {
|
|
41
|
-
const result = await this.getCurrentOrientation();
|
|
42
|
-
const changeEvent = {
|
|
43
|
-
type: result.type,
|
|
44
|
-
};
|
|
45
|
-
this.notifyListeners('screenOrientationChange', changeEvent);
|
|
46
|
-
};
|
|
47
|
-
if (this.isSupported) {
|
|
48
|
-
screen.orientation.addEventListener('change', this.handleOrientationChange);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async lock(options) {
|
|
52
|
-
if (!this.isSupported) {
|
|
53
|
-
this.throwUnsupportedError();
|
|
54
|
-
}
|
|
55
|
-
await screen.orientation.lock(options.type);
|
|
56
|
-
}
|
|
57
|
-
async unlock() {
|
|
58
|
-
if (!this.isSupported) {
|
|
59
|
-
this.throwUnsupportedError();
|
|
60
|
-
}
|
|
61
|
-
screen.orientation.unlock();
|
|
62
|
-
}
|
|
63
|
-
async getCurrentOrientation() {
|
|
64
|
-
if (!this.isSupported) {
|
|
65
|
-
this.throwUnsupportedError();
|
|
66
|
-
}
|
|
67
|
-
switch (screen.orientation.type) {
|
|
68
|
-
case 'landscape-primary':
|
|
69
|
-
return { type: exports.OrientationType.LANDSCAPE_PRIMARY };
|
|
70
|
-
case 'landscape-secondary':
|
|
71
|
-
return { type: exports.OrientationType.LANDSCAPE_SECONDARY };
|
|
72
|
-
case 'portrait-secondary':
|
|
73
|
-
return { type: exports.OrientationType.PORTRAIT_SECONDARY };
|
|
74
|
-
default:
|
|
75
|
-
return { type: exports.OrientationType.PORTRAIT_PRIMARY };
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
throwUnsupportedError() {
|
|
79
|
-
throw this.unavailable('Screen Orientation API not available in this browser.');
|
|
80
|
-
}
|
|
36
|
+
class ScreenOrientationWeb extends core.WebPlugin {
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
this.isSupported = 'orientation' in screen;
|
|
40
|
+
this.handleOrientationChange = async () => {
|
|
41
|
+
const result = await this.getCurrentOrientation();
|
|
42
|
+
const changeEvent = {
|
|
43
|
+
type: result.type,
|
|
44
|
+
};
|
|
45
|
+
this.notifyListeners('screenOrientationChange', changeEvent);
|
|
46
|
+
};
|
|
47
|
+
if (this.isSupported) {
|
|
48
|
+
screen.orientation.addEventListener('change', this.handleOrientationChange);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async lock(options) {
|
|
52
|
+
if (!this.isSupported) {
|
|
53
|
+
this.throwUnsupportedError();
|
|
54
|
+
}
|
|
55
|
+
await screen.orientation.lock(options.type);
|
|
56
|
+
}
|
|
57
|
+
async unlock() {
|
|
58
|
+
if (!this.isSupported) {
|
|
59
|
+
this.throwUnsupportedError();
|
|
60
|
+
}
|
|
61
|
+
screen.orientation.unlock();
|
|
62
|
+
}
|
|
63
|
+
async getCurrentOrientation() {
|
|
64
|
+
if (!this.isSupported) {
|
|
65
|
+
this.throwUnsupportedError();
|
|
66
|
+
}
|
|
67
|
+
switch (screen.orientation.type) {
|
|
68
|
+
case 'landscape-primary':
|
|
69
|
+
return { type: exports.OrientationType.LANDSCAPE_PRIMARY };
|
|
70
|
+
case 'landscape-secondary':
|
|
71
|
+
return { type: exports.OrientationType.LANDSCAPE_SECONDARY };
|
|
72
|
+
case 'portrait-secondary':
|
|
73
|
+
return { type: exports.OrientationType.PORTRAIT_SECONDARY };
|
|
74
|
+
default:
|
|
75
|
+
return { type: exports.OrientationType.PORTRAIT_PRIMARY };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
throwUnsupportedError() {
|
|
79
|
+
throw this.unavailable('Screen Orientation API not available in this browser.');
|
|
80
|
+
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var OrientationType;\
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var OrientationType;\n(function (OrientationType) {\n /**\n * The orientation is either landscape-primary or landscape-secondary.\n */\n OrientationType[\"LANDSCAPE\"] = \"landscape\";\n /**\n * The orientation is in the primary landscape mode.\n */\n OrientationType[\"LANDSCAPE_PRIMARY\"] = \"landscape-primary\";\n /**\n * The orientation is in the secondary landscape mode.\n */\n OrientationType[\"LANDSCAPE_SECONDARY\"] = \"landscape-secondary\";\n /**\n * The orientation is either portrait-primary or portrait-secondary.\n */\n OrientationType[\"PORTRAIT\"] = \"portrait\";\n /**\n * The orientation is in the primary portrait mode.\n */\n OrientationType[\"PORTRAIT_PRIMARY\"] = \"portrait-primary\";\n /**\n * The orientation is in the secondary portrait mode.\n */\n OrientationType[\"PORTRAIT_SECONDARY\"] = \"portrait-secondary\";\n})(OrientationType || (OrientationType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst ScreenOrientation = registerPlugin('ScreenOrientation', {\n web: () => import('./web').then(m => new m.ScreenOrientationWeb()),\n});\nexport * from './definitions';\nexport { ScreenOrientation };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { OrientationType } from './definitions';\nexport class ScreenOrientationWeb extends WebPlugin {\n constructor() {\n super();\n this.isSupported = 'orientation' in screen;\n this.handleOrientationChange = async () => {\n const result = await this.getCurrentOrientation();\n const changeEvent = {\n type: result.type,\n };\n this.notifyListeners('screenOrientationChange', changeEvent);\n };\n if (this.isSupported) {\n screen.orientation.addEventListener('change', this.handleOrientationChange);\n }\n }\n async lock(options) {\n if (!this.isSupported) {\n this.throwUnsupportedError();\n }\n await screen.orientation.lock(options.type);\n }\n async unlock() {\n if (!this.isSupported) {\n this.throwUnsupportedError();\n }\n screen.orientation.unlock();\n }\n async getCurrentOrientation() {\n if (!this.isSupported) {\n this.throwUnsupportedError();\n }\n switch (screen.orientation.type) {\n case 'landscape-primary':\n return { type: OrientationType.LANDSCAPE_PRIMARY };\n case 'landscape-secondary':\n return { type: OrientationType.LANDSCAPE_SECONDARY };\n case 'portrait-secondary':\n return { type: OrientationType.PORTRAIT_SECONDARY };\n default:\n return { type: OrientationType.PORTRAIT_PRIMARY };\n }\n }\n throwUnsupportedError() {\n throw this.unavailable('Screen Orientation API not available in this browser.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["OrientationType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,qCAAgB;IAC3B,CAAC,UAAU,eAAe,EAAE;IAC5B;IACA;IACA;IACA,IAAI,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;IAC/C;IACA;IACA;IACA,IAAI,eAAe,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;IAC/D;IACA;IACA;IACA,IAAI,eAAe,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;IACnE;IACA;IACA;IACA,IAAI,eAAe,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IAC7C;IACA;IACA;IACA,IAAI,eAAe,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;IAC7D;IACA;IACA;IACA,IAAI,eAAe,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,CAAC;IACjE,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC;;ACzBxC,UAAC,iBAAiB,GAAGC,mBAAc,CAAC,mBAAmB,EAAE;IAC9D,IAAI,GAAG,EAAE,M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IAC/B,YAAY,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACzC,SAAS;IACT,QAAQ,QAAQ,MAAM,CAAC,WAAW,CAAC,IAAI;IACvC,YAAY,KAAK,mBAAmB;IACpC,gBAAgB,OAAO,EAAE,IAAI,EAAEF,uBAAe,CAAC,iBAAiB,EAAE,CAAC;IACnE,YAAY,KAAK,qBAAqB;IACtC,gBAAgB,OAAO,EAAE,IAAI,EAAEA,uBAAe,CAAC,mBAAmB,EAAE,CAAC;IACrE,YAAY,KAAK,oBAAoB;IACrC,gBAAgB,OAAO,EAAE,IAAI,EAAEA,uBAAe,CAAC,kBAAkB,EAAE,CAAC;IACpE,YAAY;IACZ,gBAAgB,OAAO,EAAE,IAAI,EAAEA,uBAAe,CAAC,gBAAgB,EAAE,CAAC;IAClE,SAAS;IACT,KAAK;IACL,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,uDAAuD,CAAC,CAAC;IACxF,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
package/ios/Plugin/Info.plist
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
-
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
-
<key>CFBundleExecutable</key>
|
|
8
|
-
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
-
<key>CFBundleIdentifier</key>
|
|
10
|
-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
-
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
-
<string>6.0</string>
|
|
13
|
-
<key>CFBundleName</key>
|
|
14
|
-
<string>$(PRODUCT_NAME)</string>
|
|
15
|
-
<key>CFBundlePackageType</key>
|
|
16
|
-
<string>FMWK</string>
|
|
17
|
-
<key>CFBundleShortVersionString</key>
|
|
18
|
-
<string>1.0</string>
|
|
19
|
-
<key>CFBundleVersion</key>
|
|
20
|
-
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
-
<key>NSPrincipalClass</key>
|
|
22
|
-
<string></string>
|
|
23
|
-
</dict>
|
|
24
|
-
</plist>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|