@capawesome/capacitor-screen-orientation 1.1.7-dev.36f3183.1659623993

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/dist/docs.json ADDED
@@ -0,0 +1,217 @@
1
+ {
2
+ "api": {
3
+ "name": "ScreenOrientationPlugin",
4
+ "slug": "screenorientationplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "lock",
10
+ "signature": "(options: LockOptions) => Promise<void>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "LockOptions"
16
+ }
17
+ ],
18
+ "returns": "Promise<void>",
19
+ "tags": [],
20
+ "docs": "Locks the device orientation.",
21
+ "complexTypes": [
22
+ "LockOptions"
23
+ ],
24
+ "slug": "lock"
25
+ },
26
+ {
27
+ "name": "unlock",
28
+ "signature": "() => Promise<void>",
29
+ "parameters": [],
30
+ "returns": "Promise<void>",
31
+ "tags": [],
32
+ "docs": "Unlocks the device orientation.",
33
+ "complexTypes": [],
34
+ "slug": "unlock"
35
+ },
36
+ {
37
+ "name": "getCurrentOrientation",
38
+ "signature": "() => Promise<GetCurrentOrientationResult>",
39
+ "parameters": [],
40
+ "returns": "Promise<GetCurrentOrientationResult>",
41
+ "tags": [],
42
+ "docs": "Gets the current device orientation type.",
43
+ "complexTypes": [
44
+ "GetCurrentOrientationResult"
45
+ ],
46
+ "slug": "getcurrentorientation"
47
+ },
48
+ {
49
+ "name": "addListener",
50
+ "signature": "(eventName: 'screenOrientationChange', listenerFunc: ScreenOrientationChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle",
51
+ "parameters": [
52
+ {
53
+ "name": "eventName",
54
+ "docs": "",
55
+ "type": "'screenOrientationChange'"
56
+ },
57
+ {
58
+ "name": "listenerFunc",
59
+ "docs": "",
60
+ "type": "ScreenOrientationChangeListener"
61
+ }
62
+ ],
63
+ "returns": "Promise<PluginListenerHandle> & PluginListenerHandle",
64
+ "tags": [],
65
+ "docs": "Listen for screen orientation changes.",
66
+ "complexTypes": [
67
+ "PluginListenerHandle",
68
+ "ScreenOrientationChangeListener"
69
+ ],
70
+ "slug": "addlistenerscreenorientationchange"
71
+ },
72
+ {
73
+ "name": "removeAllListeners",
74
+ "signature": "() => Promise<void>",
75
+ "parameters": [],
76
+ "returns": "Promise<void>",
77
+ "tags": [],
78
+ "docs": "Remove all listeners for this plugin.",
79
+ "complexTypes": [],
80
+ "slug": "removealllisteners"
81
+ }
82
+ ],
83
+ "properties": []
84
+ },
85
+ "interfaces": [
86
+ {
87
+ "name": "LockOptions",
88
+ "slug": "lockoptions",
89
+ "docs": "",
90
+ "tags": [],
91
+ "methods": [],
92
+ "properties": [
93
+ {
94
+ "name": "type",
95
+ "tags": [],
96
+ "docs": "The orientation lock type.",
97
+ "complexTypes": [
98
+ "OrientationType"
99
+ ],
100
+ "type": "OrientationType"
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ "name": "GetCurrentOrientationResult",
106
+ "slug": "getcurrentorientationresult",
107
+ "docs": "",
108
+ "tags": [],
109
+ "methods": [],
110
+ "properties": [
111
+ {
112
+ "name": "type",
113
+ "tags": [],
114
+ "docs": "The current orientation type.",
115
+ "complexTypes": [
116
+ "OrientationType"
117
+ ],
118
+ "type": "OrientationType"
119
+ }
120
+ ]
121
+ },
122
+ {
123
+ "name": "PluginListenerHandle",
124
+ "slug": "pluginlistenerhandle",
125
+ "docs": "",
126
+ "tags": [],
127
+ "methods": [],
128
+ "properties": [
129
+ {
130
+ "name": "remove",
131
+ "tags": [],
132
+ "docs": "",
133
+ "complexTypes": [],
134
+ "type": "() => Promise<void>"
135
+ }
136
+ ]
137
+ },
138
+ {
139
+ "name": "ScreenOrientationChange",
140
+ "slug": "screenorientationchange",
141
+ "docs": "",
142
+ "tags": [],
143
+ "methods": [],
144
+ "properties": [
145
+ {
146
+ "name": "type",
147
+ "tags": [],
148
+ "docs": "The current orientation type.",
149
+ "complexTypes": [
150
+ "OrientationType"
151
+ ],
152
+ "type": "OrientationType"
153
+ }
154
+ ]
155
+ }
156
+ ],
157
+ "enums": [
158
+ {
159
+ "name": "OrientationType",
160
+ "slug": "orientationtype",
161
+ "members": [
162
+ {
163
+ "name": "LANDSCAPE",
164
+ "value": "'landscape'",
165
+ "tags": [],
166
+ "docs": "The orientation is either landscape-primary or landscape-secondary."
167
+ },
168
+ {
169
+ "name": "LANDSCAPE_PRIMARY",
170
+ "value": "'landscape-primary'",
171
+ "tags": [],
172
+ "docs": "The orientation is in the primary landscape mode."
173
+ },
174
+ {
175
+ "name": "LANDSCAPE_SECONDARY",
176
+ "value": "'landscape-secondary'",
177
+ "tags": [],
178
+ "docs": "The orientation is in the secondary landscape mode."
179
+ },
180
+ {
181
+ "name": "PORTRAIT",
182
+ "value": "'portrait'",
183
+ "tags": [],
184
+ "docs": "The orientation is either portrait-primary or portrait-secondary."
185
+ },
186
+ {
187
+ "name": "PORTRAIT_PRIMARY",
188
+ "value": "'portrait-primary'",
189
+ "tags": [],
190
+ "docs": "The orientation is in the primary portrait mode."
191
+ },
192
+ {
193
+ "name": "PORTRAIT_SECONDARY",
194
+ "value": "'portrait-secondary'",
195
+ "tags": [],
196
+ "docs": "The orientation is in the secondary portrait mode."
197
+ }
198
+ ]
199
+ }
200
+ ],
201
+ "typeAliases": [
202
+ {
203
+ "name": "ScreenOrientationChangeListener",
204
+ "slug": "screenorientationchangelistener",
205
+ "docs": "Callback to receive the screen orientation change notifications.",
206
+ "types": [
207
+ {
208
+ "text": "(change: ScreenOrientationChange): void",
209
+ "complexTypes": [
210
+ "ScreenOrientationChange"
211
+ ]
212
+ }
213
+ ]
214
+ }
215
+ ],
216
+ "pluginConfigs": []
217
+ }
@@ -0,0 +1,71 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ export interface ScreenOrientationPlugin {
3
+ /**
4
+ * Locks the device orientation.
5
+ */
6
+ lock(options: LockOptions): Promise<void>;
7
+ /**
8
+ * Unlocks the device orientation.
9
+ */
10
+ unlock(): Promise<void>;
11
+ /**
12
+ * Gets the current device orientation type.
13
+ */
14
+ getCurrentOrientation(): Promise<GetCurrentOrientationResult>;
15
+ /**
16
+ * Listen for screen orientation changes.
17
+ */
18
+ addListener(eventName: 'screenOrientationChange', listenerFunc: ScreenOrientationChangeListener): Promise<PluginListenerHandle> & PluginListenerHandle;
19
+ /**
20
+ * Remove all listeners for this plugin.
21
+ */
22
+ removeAllListeners(): Promise<void>;
23
+ }
24
+ export interface LockOptions {
25
+ /**
26
+ * The orientation lock type.
27
+ */
28
+ type: OrientationType;
29
+ }
30
+ export interface GetCurrentOrientationResult {
31
+ /**
32
+ * The current orientation type.
33
+ */
34
+ type: OrientationType;
35
+ }
36
+ export declare enum OrientationType {
37
+ /**
38
+ * The orientation is either landscape-primary or landscape-secondary.
39
+ */
40
+ LANDSCAPE = "landscape",
41
+ /**
42
+ * The orientation is in the primary landscape mode.
43
+ */
44
+ LANDSCAPE_PRIMARY = "landscape-primary",
45
+ /**
46
+ * The orientation is in the secondary landscape mode.
47
+ */
48
+ LANDSCAPE_SECONDARY = "landscape-secondary",
49
+ /**
50
+ * The orientation is either portrait-primary or portrait-secondary.
51
+ */
52
+ PORTRAIT = "portrait",
53
+ /**
54
+ * The orientation is in the primary portrait mode.
55
+ */
56
+ PORTRAIT_PRIMARY = "portrait-primary",
57
+ /**
58
+ * The orientation is in the secondary portrait mode.
59
+ */
60
+ PORTRAIT_SECONDARY = "portrait-secondary"
61
+ }
62
+ /**
63
+ * Callback to receive the screen orientation change notifications.
64
+ */
65
+ export declare type ScreenOrientationChangeListener = (change: ScreenOrientationChange) => void;
66
+ export interface ScreenOrientationChange {
67
+ /**
68
+ * The current orientation type.
69
+ */
70
+ type: OrientationType;
71
+ }
@@ -0,0 +1,28 @@
1
+ export var OrientationType;
2
+ (function (OrientationType) {
3
+ /**
4
+ * The orientation is either landscape-primary or landscape-secondary.
5
+ */
6
+ OrientationType["LANDSCAPE"] = "landscape";
7
+ /**
8
+ * The orientation is in the primary landscape mode.
9
+ */
10
+ OrientationType["LANDSCAPE_PRIMARY"] = "landscape-primary";
11
+ /**
12
+ * The orientation is in the secondary landscape mode.
13
+ */
14
+ OrientationType["LANDSCAPE_SECONDARY"] = "landscape-secondary";
15
+ /**
16
+ * The orientation is either portrait-primary or portrait-secondary.
17
+ */
18
+ OrientationType["PORTRAIT"] = "portrait";
19
+ /**
20
+ * The orientation is in the primary portrait mode.
21
+ */
22
+ OrientationType["PORTRAIT_PRIMARY"] = "portrait-primary";
23
+ /**
24
+ * The orientation is in the secondary portrait mode.
25
+ */
26
+ OrientationType["PORTRAIT_SECONDARY"] = "portrait-secondary";
27
+ })(OrientationType || (OrientationType = {}));
28
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA0CA,MAAM,CAAN,IAAY,eAyBX;AAzBD,WAAY,eAAe;IACzB;;OAEG;IACH,0CAAuB,CAAA;IACvB;;OAEG;IACH,0DAAuC,CAAA;IACvC;;OAEG;IACH,8DAA2C,CAAA;IAC3C;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,wDAAqC,CAAA;IACrC;;OAEG;IACH,4DAAyC,CAAA;AAC3C,CAAC,EAzBW,eAAe,KAAf,eAAe,QAyB1B","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface ScreenOrientationPlugin {\n /**\n * Locks the device orientation.\n */\n lock(options: LockOptions): Promise<void>;\n /**\n * Unlocks the device orientation.\n */\n unlock(): Promise<void>;\n /**\n * Gets the current device orientation type.\n */\n getCurrentOrientation(): Promise<GetCurrentOrientationResult>;\n /**\n * Listen for screen orientation changes.\n */\n addListener(\n eventName: 'screenOrientationChange',\n listenerFunc: ScreenOrientationChangeListener,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n /**\n * Remove all listeners for this plugin.\n */\n removeAllListeners(): Promise<void>;\n}\n\nexport interface LockOptions {\n /**\n * The orientation lock type.\n */\n type: OrientationType;\n}\n\nexport interface GetCurrentOrientationResult {\n /**\n * The current orientation type.\n */\n type: OrientationType;\n}\n\nexport enum OrientationType {\n /**\n * The orientation is either landscape-primary or landscape-secondary.\n */\n LANDSCAPE = 'landscape',\n /**\n * The orientation is in the primary landscape mode.\n */\n LANDSCAPE_PRIMARY = 'landscape-primary',\n /**\n * The orientation is in the secondary landscape mode.\n */\n LANDSCAPE_SECONDARY = 'landscape-secondary',\n /**\n * The orientation is either portrait-primary or portrait-secondary.\n */\n PORTRAIT = 'portrait',\n /**\n * The orientation is in the primary portrait mode.\n */\n PORTRAIT_PRIMARY = 'portrait-primary',\n /**\n * The orientation is in the secondary portrait mode.\n */\n PORTRAIT_SECONDARY = 'portrait-secondary',\n}\n\n/**\n * Callback to receive the screen orientation change notifications.\n */\nexport type ScreenOrientationChangeListener = (\n change: ScreenOrientationChange,\n) => void;\n\nexport interface ScreenOrientationChange {\n /**\n * The current orientation type.\n */\n type: OrientationType;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ScreenOrientationPlugin } from './definitions';
2
+ declare const ScreenOrientation: ScreenOrientationPlugin;
3
+ export * from './definitions';
4
+ export { ScreenOrientation };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const ScreenOrientation = registerPlugin('ScreenOrientation', {
3
+ web: () => import('./web').then(m => new m.ScreenOrientationWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { ScreenOrientation };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,iBAAiB,GAAG,cAAc,CACtC,mBAAmB,EACnB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;CACnE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { ScreenOrientationPlugin } from './definitions';\n\nconst ScreenOrientation = registerPlugin<ScreenOrientationPlugin>(\n 'ScreenOrientation',\n {\n web: () => import('./web').then(m => new m.ScreenOrientationWeb()),\n },\n);\n\nexport * from './definitions';\nexport { ScreenOrientation };\n"]}
@@ -0,0 +1,11 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { GetCurrentOrientationResult, LockOptions, ScreenOrientationPlugin } from './definitions';
3
+ export declare class ScreenOrientationWeb extends WebPlugin implements ScreenOrientationPlugin {
4
+ private readonly isSupported;
5
+ constructor();
6
+ lock(options: LockOptions): Promise<void>;
7
+ unlock(): Promise<void>;
8
+ getCurrentOrientation(): Promise<GetCurrentOrientationResult>;
9
+ private handleOrientationChange;
10
+ private throwUnsupportedError;
11
+ }
@@ -0,0 +1,49 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import { OrientationType } from './definitions';
3
+ export class ScreenOrientationWeb extends WebPlugin {
4
+ constructor() {
5
+ super();
6
+ this.isSupported = 'orientation' in screen;
7
+ this.handleOrientationChange = async () => {
8
+ const result = await this.getCurrentOrientation();
9
+ const changeEvent = {
10
+ type: result.type,
11
+ };
12
+ this.notifyListeners('screenOrientationChange', changeEvent);
13
+ };
14
+ if (this.isSupported) {
15
+ screen.orientation.addEventListener('change', this.handleOrientationChange);
16
+ }
17
+ }
18
+ async lock(options) {
19
+ if (!this.isSupported) {
20
+ this.throwUnsupportedError();
21
+ }
22
+ await screen.orientation.lock(options.type);
23
+ }
24
+ async unlock() {
25
+ if (!this.isSupported) {
26
+ this.throwUnsupportedError();
27
+ }
28
+ screen.orientation.unlock();
29
+ }
30
+ async getCurrentOrientation() {
31
+ if (!this.isSupported) {
32
+ this.throwUnsupportedError();
33
+ }
34
+ switch (screen.orientation.type) {
35
+ case 'landscape-primary':
36
+ return { type: OrientationType.LANDSCAPE_PRIMARY };
37
+ case 'landscape-secondary':
38
+ return { type: OrientationType.LANDSCAPE_SECONDARY };
39
+ case 'portrait-secondary':
40
+ return { type: OrientationType.PORTRAIT_SECONDARY };
41
+ default:
42
+ return { type: OrientationType.PORTRAIT_PRIMARY };
43
+ }
44
+ }
45
+ throwUnsupportedError() {
46
+ throw this.unavailable('Screen Orientation API not available in this browser.');
47
+ }
48
+ }
49
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,OAAO,oBACX,SAAQ,SAAS;IAKjB;QACE,KAAK,EAAE,CAAC;QAHO,gBAAW,GAAG,aAAa,IAAI,MAAM,CAAC;QA0C/C,4BAAuB,GAAG,KAAK,IAAI,EAAE;YAC3C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAClD,MAAM,WAAW,GAA4B;gBAC3C,IAAI,EAAE,MAAM,CAAC,IAAI;aAClB,CAAC;YACF,IAAI,CAAC,eAAe,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC;QAC/D,CAAC,CAAC;QA5CA,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,MAAM,CAAC,WAAW,CAAC,gBAAgB,CACjC,QAAQ,EACR,IAAI,CAAC,uBAAuB,CAC7B,CAAC;SACH;IACH,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAoB;QACpC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,CAAC,qBAAqB,EAAE,CAAC;SAC9B;QACD,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,CAAC,qBAAqB,EAAE,CAAC;SAC9B;QACD,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,CAAC,qBAAqB,EAAE,CAAC;SAC9B;QACD,QAAQ,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE;YAC/B,KAAK,mBAAmB;gBACtB,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,iBAAiB,EAAE,CAAC;YACrD,KAAK,qBAAqB;gBACxB,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,mBAAmB,EAAE,CAAC;YACvD,KAAK,oBAAoB;gBACvB,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,kBAAkB,EAAE,CAAC;YACtD;gBACE,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,CAAC;SACrD;IACH,CAAC;IAUO,qBAAqB;QAC3B,MAAM,IAAI,CAAC,WAAW,CACpB,uDAAuD,CACxD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\r\n\r\nimport type {\r\n GetCurrentOrientationResult,\r\n LockOptions,\r\n ScreenOrientationChange,\r\n ScreenOrientationPlugin,\r\n} from './definitions';\r\nimport { OrientationType } from './definitions';\r\n\r\nexport class ScreenOrientationWeb\r\n extends WebPlugin\r\n implements ScreenOrientationPlugin\r\n{\r\n private readonly isSupported = 'orientation' in screen;\r\n\r\n constructor() {\r\n super();\r\n if (this.isSupported) {\r\n screen.orientation.addEventListener(\r\n 'change',\r\n this.handleOrientationChange,\r\n );\r\n }\r\n }\r\n\r\n public async lock(options: LockOptions): Promise<void> {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n await screen.orientation.lock(options.type);\r\n }\r\n\r\n public async unlock(): Promise<void> {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n screen.orientation.unlock();\r\n }\r\n\r\n public async getCurrentOrientation(): Promise<GetCurrentOrientationResult> {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n switch (screen.orientation.type) {\r\n case 'landscape-primary':\r\n return { type: OrientationType.LANDSCAPE_PRIMARY };\r\n case 'landscape-secondary':\r\n return { type: OrientationType.LANDSCAPE_SECONDARY };\r\n case 'portrait-secondary':\r\n return { type: OrientationType.PORTRAIT_SECONDARY };\r\n default:\r\n return { type: OrientationType.PORTRAIT_PRIMARY };\r\n }\r\n }\r\n\r\n private handleOrientationChange = async () => {\r\n const result = await this.getCurrentOrientation();\r\n const changeEvent: ScreenOrientationChange = {\r\n type: result.type,\r\n };\r\n this.notifyListeners('screenOrientationChange', changeEvent);\r\n };\r\n\r\n private throwUnsupportedError(): never {\r\n throw this.unavailable(\r\n 'Screen Orientation API not available in this browser.',\r\n );\r\n }\r\n}\r\n"]}
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
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";
33
+ })(exports.OrientationType || (exports.OrientationType = {}));
34
+
35
+ const ScreenOrientation = core.registerPlugin('ScreenOrientation', {
36
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ScreenOrientationWeb()),
37
+ });
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
+ }
84
+ }
85
+
86
+ var web = /*#__PURE__*/Object.freeze({
87
+ __proto__: null,
88
+ ScreenOrientationWeb: ScreenOrientationWeb
89
+ });
90
+
91
+ exports.ScreenOrientation = ScreenOrientation;
92
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var OrientationType;\r\n(function (OrientationType) {\r\n /**\r\n * The orientation is either landscape-primary or landscape-secondary.\r\n */\r\n OrientationType[\"LANDSCAPE\"] = \"landscape\";\r\n /**\r\n * The orientation is in the primary landscape mode.\r\n */\r\n OrientationType[\"LANDSCAPE_PRIMARY\"] = \"landscape-primary\";\r\n /**\r\n * The orientation is in the secondary landscape mode.\r\n */\r\n OrientationType[\"LANDSCAPE_SECONDARY\"] = \"landscape-secondary\";\r\n /**\r\n * The orientation is either portrait-primary or portrait-secondary.\r\n */\r\n OrientationType[\"PORTRAIT\"] = \"portrait\";\r\n /**\r\n * The orientation is in the primary portrait mode.\r\n */\r\n OrientationType[\"PORTRAIT_PRIMARY\"] = \"portrait-primary\";\r\n /**\r\n * The orientation is in the secondary portrait mode.\r\n */\r\n OrientationType[\"PORTRAIT_SECONDARY\"] = \"portrait-secondary\";\r\n})(OrientationType || (OrientationType = {}));\r\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\r\nconst ScreenOrientation = registerPlugin('ScreenOrientation', {\r\n web: () => import('./web').then(m => new m.ScreenOrientationWeb()),\r\n});\r\nexport * from './definitions';\r\nexport { ScreenOrientation };\r\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\r\nimport { OrientationType } from './definitions';\r\nexport class ScreenOrientationWeb extends WebPlugin {\r\n constructor() {\r\n super();\r\n this.isSupported = 'orientation' in screen;\r\n this.handleOrientationChange = async () => {\r\n const result = await this.getCurrentOrientation();\r\n const changeEvent = {\r\n type: result.type,\r\n };\r\n this.notifyListeners('screenOrientationChange', changeEvent);\r\n };\r\n if (this.isSupported) {\r\n screen.orientation.addEventListener('change', this.handleOrientationChange);\r\n }\r\n }\r\n async lock(options) {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n await screen.orientation.lock(options.type);\r\n }\r\n async unlock() {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n screen.orientation.unlock();\r\n }\r\n async getCurrentOrientation() {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n switch (screen.orientation.type) {\r\n case 'landscape-primary':\r\n return { type: OrientationType.LANDSCAPE_PRIMARY };\r\n case 'landscape-secondary':\r\n return { type: OrientationType.LANDSCAPE_SECONDARY };\r\n case 'portrait-secondary':\r\n return { type: OrientationType.PORTRAIT_SECONDARY };\r\n default:\r\n return { type: OrientationType.PORTRAIT_PRIMARY };\r\n }\r\n }\r\n throwUnsupportedError() {\r\n throw this.unavailable('Screen Orientation API not available in this browser.');\r\n }\r\n}\r\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,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC;;ACzBxC,MAAC,iBAAiB,GAAGC,mBAAc,CAAC,mBAAmB,EAAE;AAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CA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BAAqB,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 ADDED
@@ -0,0 +1,95 @@
1
+ var capacitorScreenOrientation = (function (exports, core) {
2
+ 'use strict';
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";
30
+ })(exports.OrientationType || (exports.OrientationType = {}));
31
+
32
+ const ScreenOrientation = core.registerPlugin('ScreenOrientation', {
33
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ScreenOrientationWeb()),
34
+ });
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
+ }
81
+ }
82
+
83
+ var web = /*#__PURE__*/Object.freeze({
84
+ __proto__: null,
85
+ ScreenOrientationWeb: ScreenOrientationWeb
86
+ });
87
+
88
+ exports.ScreenOrientation = ScreenOrientation;
89
+
90
+ Object.defineProperty(exports, '__esModule', { value: true });
91
+
92
+ return exports;
93
+
94
+ })({}, capacitorExports);
95
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var OrientationType;\r\n(function (OrientationType) {\r\n /**\r\n * The orientation is either landscape-primary or landscape-secondary.\r\n */\r\n OrientationType[\"LANDSCAPE\"] = \"landscape\";\r\n /**\r\n * The orientation is in the primary landscape mode.\r\n */\r\n OrientationType[\"LANDSCAPE_PRIMARY\"] = \"landscape-primary\";\r\n /**\r\n * The orientation is in the secondary landscape mode.\r\n */\r\n OrientationType[\"LANDSCAPE_SECONDARY\"] = \"landscape-secondary\";\r\n /**\r\n * The orientation is either portrait-primary or portrait-secondary.\r\n */\r\n OrientationType[\"PORTRAIT\"] = \"portrait\";\r\n /**\r\n * The orientation is in the primary portrait mode.\r\n */\r\n OrientationType[\"PORTRAIT_PRIMARY\"] = \"portrait-primary\";\r\n /**\r\n * The orientation is in the secondary portrait mode.\r\n */\r\n OrientationType[\"PORTRAIT_SECONDARY\"] = \"portrait-secondary\";\r\n})(OrientationType || (OrientationType = {}));\r\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\r\nconst ScreenOrientation = registerPlugin('ScreenOrientation', {\r\n web: () => import('./web').then(m => new m.ScreenOrientationWeb()),\r\n});\r\nexport * from './definitions';\r\nexport { ScreenOrientation };\r\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\r\nimport { OrientationType } from './definitions';\r\nexport class ScreenOrientationWeb extends WebPlugin {\r\n constructor() {\r\n super();\r\n this.isSupported = 'orientation' in screen;\r\n this.handleOrientationChange = async () => {\r\n const result = await this.getCurrentOrientation();\r\n const changeEvent = {\r\n type: result.type,\r\n };\r\n this.notifyListeners('screenOrientationChange', changeEvent);\r\n };\r\n if (this.isSupported) {\r\n screen.orientation.addEventListener('change', this.handleOrientationChange);\r\n }\r\n }\r\n async lock(options) {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n await screen.orientation.lock(options.type);\r\n }\r\n async unlock() {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n screen.orientation.unlock();\r\n }\r\n async getCurrentOrientation() {\r\n if (!this.isSupported) {\r\n this.throwUnsupportedError();\r\n }\r\n switch (screen.orientation.type) {\r\n case 'landscape-primary':\r\n return { type: OrientationType.LANDSCAPE_PRIMARY };\r\n case 'landscape-secondary':\r\n return { type: OrientationType.LANDSCAPE_SECONDARY };\r\n case 'portrait-secondary':\r\n return { type: OrientationType.PORTRAIT_SECONDARY };\r\n default:\r\n return { type: OrientationType.PORTRAIT_PRIMARY };\r\n }\r\n }\r\n throwUnsupportedError() {\r\n throw this.unavailable('Screen Orientation API not available in this browser.');\r\n }\r\n}\r\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,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAA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AQ,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;;;;;;;;;;;;;;;;;"}
@@ -0,0 +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>