@allternit/gizzi-code 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WORKSPACE_INTEGRATION.md +290 -0
- package/chat-sessions/sessions-index.json +98 -0
- package/package.json +43 -0
- package/package.json.original +31 -0
- package/package.json.publish +47 -0
- package/src/bootstrap/state.d.ts +169 -0
- package/src/bootstrap/state.js +261 -0
- package/src/bootstrap/state.ts +371 -0
- package/src/context/pack-builder.d.ts +24 -0
- package/src/context/pack-builder.js +281 -0
- package/src/context/pack-builder.ts +334 -0
- package/src/hooks/useExitOnCtrlCD.d.ts +86 -0
- package/src/hooks/useExitOnCtrlCD.js +130 -0
- package/src/hooks/useExitOnCtrlCD.ts +202 -0
- package/src/hooks/useKeybinding.d.ts +89 -0
- package/src/hooks/useKeybinding.js +163 -0
- package/src/hooks/useKeybinding.ts +226 -0
- package/src/hooks/useTerminalSize.d.ts +41 -0
- package/src/hooks/useTerminalSize.js +90 -0
- package/src/hooks/useTerminalSize.ts +117 -0
- package/src/index.d.ts +23 -0
- package/src/index.js +24 -0
- package/src/index.ts +132 -0
- package/src/runtime/brand/brand.d.ts +488 -0
- package/src/runtime/brand/brand.js +464 -0
- package/src/runtime/brand/brand.ts +667 -0
- package/src/runtime/services/tokenEstimation.d.ts +187 -0
- package/src/runtime/services/tokenEstimation.js +423 -0
- package/src/runtime/services/tokenEstimation.ts +547 -0
- package/src/runtime/tools/Tool.d.ts +239 -0
- package/src/runtime/tools/Tool.js +285 -0
- package/src/runtime/tools/Tool.ts +524 -0
- package/src/scheduler/TaskScheduler.d.ts +98 -0
- package/src/scheduler/TaskScheduler.js +201 -0
- package/src/scheduler/TaskScheduler.ts +259 -0
- package/src/state/AppStateStore.d.ts +347 -0
- package/src/state/AppStateStore.js +439 -0
- package/src/state/AppStateStore.ts +658 -0
- package/src/state/WorkspaceStateStore.d.ts +43 -0
- package/src/state/WorkspaceStateStore.js +224 -0
- package/src/state/WorkspaceStateStore.ts +297 -0
- package/src/types/message.d.ts +190 -0
- package/src/types/message.js +77 -0
- package/src/types/message.ts +277 -0
- package/src/utils/format.d.ts +126 -0
- package/src/utils/format.js +230 -0
- package/src/utils/format.ts +336 -0
- package/src/utils/fullscreen.d.ts +161 -0
- package/src/utils/fullscreen.js +277 -0
- package/src/utils/fullscreen.ts +382 -0
- package/src/utils/sessionStorage.d.ts +210 -0
- package/src/utils/sessionStorage.js +435 -0
- package/src/utils/sessionStorage.ts +559 -0
- package/src/watcher/WorkspaceWatcher.d.ts +70 -0
- package/src/watcher/WorkspaceWatcher.js +191 -0
- package/src/watcher/WorkspaceWatcher.ts +251 -0
- package/src/workspace/loader.d.ts +30 -0
- package/src/workspace/loader.js +117 -0
- package/src/workspace/loader.ts +171 -0
- package/src/workspace/types.d.ts +91 -0
- package/src/workspace/types.js +7 -0
- package/src/workspace/types.ts +122 -0
- package/threads/thread_1775361175022.json +9 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Fullscreen utilities for gizzi-code integration
|
|
3
|
+
* @module utils/fullscreen
|
|
4
|
+
*
|
|
5
|
+
* Provides utilities for managing fullscreen mode in browser environments.
|
|
6
|
+
* Includes support for the standard Fullscreen API with vendor prefixes
|
|
7
|
+
* for cross-browser compatibility.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Fullscreen change event handler type
|
|
11
|
+
* @typedef {Function} FullscreenChangeHandler
|
|
12
|
+
*/
|
|
13
|
+
export type FullscreenChangeHandler = (isFullscreen: boolean) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the Fullscreen API is supported in the current environment
|
|
16
|
+
*
|
|
17
|
+
* @returns {boolean} True if fullscreen is supported
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* if (isFullscreenSupported()) {
|
|
21
|
+
* enterFullscreen();
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function isFullscreenSupported(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the document is currently in fullscreen mode
|
|
28
|
+
*
|
|
29
|
+
* @returns {boolean} True if currently in fullscreen
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* if (isFullscreen()) {
|
|
33
|
+
* console.log('Currently in fullscreen mode');
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function isFullscreen(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Enters fullscreen mode for the specified element or document
|
|
40
|
+
*
|
|
41
|
+
* @param {HTMLElement} [element] - Element to make fullscreen (defaults to document.documentElement)
|
|
42
|
+
* @param {FullscreenOptions} [options] - Fullscreen options
|
|
43
|
+
* @returns {Promise<void>} Promise that resolves when fullscreen is entered
|
|
44
|
+
* @throws {Error} If fullscreen is not supported or permission is denied
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // Make entire page fullscreen
|
|
48
|
+
* await enterFullscreen();
|
|
49
|
+
*
|
|
50
|
+
* // Make specific element fullscreen
|
|
51
|
+
* const video = document.getElementById('myVideo');
|
|
52
|
+
* await enterFullscreen(video);
|
|
53
|
+
*
|
|
54
|
+
* // With navigation UI hidden
|
|
55
|
+
* await enterFullscreen(undefined, { navigationUI: 'hide' });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function enterFullscreen(element?: HTMLElement, options?: FullscreenOptions): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Exits fullscreen mode
|
|
61
|
+
*
|
|
62
|
+
* @returns {Promise<void>} Promise that resolves when fullscreen is exited
|
|
63
|
+
* @throws {Error} If not in fullscreen or API not supported
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* await exitFullscreen();
|
|
67
|
+
* console.log('Exited fullscreen');
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function exitFullscreen(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Toggles fullscreen mode for the specified element
|
|
73
|
+
*
|
|
74
|
+
* @param {HTMLElement} [element] - Element to toggle (defaults to document.documentElement)
|
|
75
|
+
* @param {FullscreenOptions} [options] - Fullscreen options
|
|
76
|
+
* @returns {Promise<boolean>} Promise that resolves to new fullscreen state
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const isFullscreen = await toggleFullscreen();
|
|
80
|
+
* console.log('Fullscreen active:', isFullscreen);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function toggleFullscreen(element?: HTMLElement, options?: FullscreenOptions): Promise<boolean>;
|
|
84
|
+
/**
|
|
85
|
+
* Subscribes to fullscreen change events
|
|
86
|
+
*
|
|
87
|
+
* @param {FullscreenChangeHandler} handler - Callback fired when fullscreen state changes
|
|
88
|
+
* @returns {() => void} Unsubscribe function
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const unsubscribe = onFullscreenChange((isFullscreen) => {
|
|
92
|
+
* console.log('Fullscreen changed:', isFullscreen);
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // Later: unsubscribe();
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function onFullscreenChange(handler: FullscreenChangeHandler): () => void;
|
|
99
|
+
/**
|
|
100
|
+
* Gets the current fullscreen element
|
|
101
|
+
*
|
|
102
|
+
* @returns {Element | null} The element currently in fullscreen, or null
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const element = getFullscreenElement();
|
|
106
|
+
* if (element) {
|
|
107
|
+
* console.log('Fullscreen element:', element.tagName);
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function getFullscreenElement(): Element | null;
|
|
112
|
+
/**
|
|
113
|
+
* Locks screen orientation when in fullscreen (mobile devices)
|
|
114
|
+
*
|
|
115
|
+
* @param {OrientationLockType} orientation - Orientation to lock to
|
|
116
|
+
* @returns {Promise<void>} Promise that resolves when orientation is locked
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* await lockOrientation('landscape');
|
|
120
|
+
* await enterFullscreen();
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* Valid orientation lock types
|
|
125
|
+
* @typedef {string} OrientationLockType
|
|
126
|
+
*/
|
|
127
|
+
type OrientationLockType = 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';
|
|
128
|
+
/**
|
|
129
|
+
* Locks screen orientation when in fullscreen (mobile devices)
|
|
130
|
+
*
|
|
131
|
+
* @param {OrientationLockType} orientation - Orientation to lock to
|
|
132
|
+
* @returns {Promise<void>} Promise that resolves when orientation is locked
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* await lockOrientation('landscape');
|
|
136
|
+
* await enterFullscreen();
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function lockOrientation(orientation: OrientationLockType): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Unlocks screen orientation
|
|
142
|
+
*
|
|
143
|
+
* @returns {Promise<void>} Promise that resolves when orientation is unlocked
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* await unlockOrientation();
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare function unlockOrientation(): Promise<void>;
|
|
150
|
+
declare const _default: {
|
|
151
|
+
isFullscreenSupported: typeof isFullscreenSupported;
|
|
152
|
+
isFullscreen: typeof isFullscreen;
|
|
153
|
+
enterFullscreen: typeof enterFullscreen;
|
|
154
|
+
exitFullscreen: typeof exitFullscreen;
|
|
155
|
+
toggleFullscreen: typeof toggleFullscreen;
|
|
156
|
+
onFullscreenChange: typeof onFullscreenChange;
|
|
157
|
+
getFullscreenElement: typeof getFullscreenElement;
|
|
158
|
+
lockOrientation: typeof lockOrientation;
|
|
159
|
+
unlockOrientation: typeof unlockOrientation;
|
|
160
|
+
};
|
|
161
|
+
export default _default;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Fullscreen utilities for gizzi-code integration
|
|
3
|
+
* @module utils/fullscreen
|
|
4
|
+
*
|
|
5
|
+
* Provides utilities for managing fullscreen mode in browser environments.
|
|
6
|
+
* Includes support for the standard Fullscreen API with vendor prefixes
|
|
7
|
+
* for cross-browser compatibility.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the Fullscreen API is supported in the current environment
|
|
11
|
+
*
|
|
12
|
+
* @returns {boolean} True if fullscreen is supported
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* if (isFullscreenSupported()) {
|
|
16
|
+
* enterFullscreen();
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function isFullscreenSupported() {
|
|
21
|
+
if (typeof document === 'undefined') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const doc = document;
|
|
25
|
+
const elem = document.documentElement;
|
|
26
|
+
return !!(doc.fullscreenEnabled ??
|
|
27
|
+
doc.webkitFullscreenEnabled ??
|
|
28
|
+
doc.mozFullScreenEnabled ??
|
|
29
|
+
doc.msFullscreenEnabled ??
|
|
30
|
+
elem.requestFullscreen ??
|
|
31
|
+
elem.webkitRequestFullscreen ??
|
|
32
|
+
elem.mozRequestFullScreen ??
|
|
33
|
+
elem.msRequestFullscreen);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the document is currently in fullscreen mode
|
|
37
|
+
*
|
|
38
|
+
* @returns {boolean} True if currently in fullscreen
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* if (isFullscreen()) {
|
|
42
|
+
* console.log('Currently in fullscreen mode');
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function isFullscreen() {
|
|
47
|
+
if (typeof document === 'undefined') {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const doc = document;
|
|
51
|
+
return !!(doc.fullscreenElement ??
|
|
52
|
+
doc.webkitFullscreenElement ??
|
|
53
|
+
doc.mozFullScreenElement ??
|
|
54
|
+
doc.msFullscreenElement ??
|
|
55
|
+
doc.webkitIsFullScreen ??
|
|
56
|
+
doc.mozFullScreen ??
|
|
57
|
+
doc.msIsFullScreen);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Enters fullscreen mode for the specified element or document
|
|
61
|
+
*
|
|
62
|
+
* @param {HTMLElement} [element] - Element to make fullscreen (defaults to document.documentElement)
|
|
63
|
+
* @param {FullscreenOptions} [options] - Fullscreen options
|
|
64
|
+
* @returns {Promise<void>} Promise that resolves when fullscreen is entered
|
|
65
|
+
* @throws {Error} If fullscreen is not supported or permission is denied
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // Make entire page fullscreen
|
|
69
|
+
* await enterFullscreen();
|
|
70
|
+
*
|
|
71
|
+
* // Make specific element fullscreen
|
|
72
|
+
* const video = document.getElementById('myVideo');
|
|
73
|
+
* await enterFullscreen(video);
|
|
74
|
+
*
|
|
75
|
+
* // With navigation UI hidden
|
|
76
|
+
* await enterFullscreen(undefined, { navigationUI: 'hide' });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export async function enterFullscreen(element, options) {
|
|
80
|
+
if (typeof document === 'undefined') {
|
|
81
|
+
return Promise.reject(new Error('Fullscreen not available in server environment'));
|
|
82
|
+
}
|
|
83
|
+
const target = (element ?? document.documentElement);
|
|
84
|
+
// Try standard method first
|
|
85
|
+
if (target.requestFullscreen) {
|
|
86
|
+
return target.requestFullscreen(options);
|
|
87
|
+
}
|
|
88
|
+
// Vendor prefixed fallbacks
|
|
89
|
+
if (target.webkitRequestFullscreen) {
|
|
90
|
+
return target.webkitRequestFullscreen(options);
|
|
91
|
+
}
|
|
92
|
+
if (target.mozRequestFullScreen) {
|
|
93
|
+
return target.mozRequestFullScreen(options);
|
|
94
|
+
}
|
|
95
|
+
if (target.msRequestFullscreen) {
|
|
96
|
+
return target.msRequestFullscreen();
|
|
97
|
+
}
|
|
98
|
+
throw new Error('Fullscreen API is not supported in this browser');
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Exits fullscreen mode
|
|
102
|
+
*
|
|
103
|
+
* @returns {Promise<void>} Promise that resolves when fullscreen is exited
|
|
104
|
+
* @throws {Error} If not in fullscreen or API not supported
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* await exitFullscreen();
|
|
108
|
+
* console.log('Exited fullscreen');
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export async function exitFullscreen() {
|
|
112
|
+
if (typeof document === 'undefined') {
|
|
113
|
+
return Promise.reject(new Error('Fullscreen not available in server environment'));
|
|
114
|
+
}
|
|
115
|
+
if (!isFullscreen()) {
|
|
116
|
+
return Promise.resolve();
|
|
117
|
+
}
|
|
118
|
+
const doc = document;
|
|
119
|
+
// Try standard method first
|
|
120
|
+
if (document.exitFullscreen) {
|
|
121
|
+
return document.exitFullscreen();
|
|
122
|
+
}
|
|
123
|
+
// Vendor prefixed fallbacks
|
|
124
|
+
if (doc.webkitExitFullscreen) {
|
|
125
|
+
return doc.webkitExitFullscreen();
|
|
126
|
+
}
|
|
127
|
+
if (doc.mozCancelFullScreen) {
|
|
128
|
+
return doc.mozCancelFullScreen();
|
|
129
|
+
}
|
|
130
|
+
if (doc.msExitFullscreen) {
|
|
131
|
+
return doc.msExitFullscreen();
|
|
132
|
+
}
|
|
133
|
+
throw new Error('Fullscreen API is not supported in this browser');
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Toggles fullscreen mode for the specified element
|
|
137
|
+
*
|
|
138
|
+
* @param {HTMLElement} [element] - Element to toggle (defaults to document.documentElement)
|
|
139
|
+
* @param {FullscreenOptions} [options] - Fullscreen options
|
|
140
|
+
* @returns {Promise<boolean>} Promise that resolves to new fullscreen state
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const isFullscreen = await toggleFullscreen();
|
|
144
|
+
* console.log('Fullscreen active:', isFullscreen);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export async function toggleFullscreen(element, options) {
|
|
148
|
+
if (isFullscreen()) {
|
|
149
|
+
await exitFullscreen();
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
await enterFullscreen(element, options);
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Subscribes to fullscreen change events
|
|
159
|
+
*
|
|
160
|
+
* @param {FullscreenChangeHandler} handler - Callback fired when fullscreen state changes
|
|
161
|
+
* @returns {() => void} Unsubscribe function
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const unsubscribe = onFullscreenChange((isFullscreen) => {
|
|
165
|
+
* console.log('Fullscreen changed:', isFullscreen);
|
|
166
|
+
* });
|
|
167
|
+
*
|
|
168
|
+
* // Later: unsubscribe();
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export function onFullscreenChange(handler) {
|
|
172
|
+
if (typeof document === 'undefined') {
|
|
173
|
+
return () => {
|
|
174
|
+
// No-op in server environment
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const handleChange = () => {
|
|
178
|
+
handler(isFullscreen());
|
|
179
|
+
};
|
|
180
|
+
// Standard event
|
|
181
|
+
document.addEventListener('fullscreenchange', handleChange);
|
|
182
|
+
// Vendor prefixed events
|
|
183
|
+
document.addEventListener('webkitfullscreenchange', handleChange);
|
|
184
|
+
document.addEventListener('mozfullscreenchange', handleChange);
|
|
185
|
+
document.addEventListener('MSFullscreenChange', handleChange);
|
|
186
|
+
// Return unsubscribe function
|
|
187
|
+
return () => {
|
|
188
|
+
document.removeEventListener('fullscreenchange', handleChange);
|
|
189
|
+
document.removeEventListener('webkitfullscreenchange', handleChange);
|
|
190
|
+
document.removeEventListener('mozfullscreenchange', handleChange);
|
|
191
|
+
document.removeEventListener('MSFullscreenChange', handleChange);
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Gets the current fullscreen element
|
|
196
|
+
*
|
|
197
|
+
* @returns {Element | null} The element currently in fullscreen, or null
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const element = getFullscreenElement();
|
|
201
|
+
* if (element) {
|
|
202
|
+
* console.log('Fullscreen element:', element.tagName);
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export function getFullscreenElement() {
|
|
207
|
+
if (typeof document === 'undefined') {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
const doc = document;
|
|
211
|
+
return (doc.fullscreenElement ??
|
|
212
|
+
doc.webkitFullscreenElement ??
|
|
213
|
+
doc.mozFullScreenElement ??
|
|
214
|
+
doc.msFullscreenElement ??
|
|
215
|
+
null);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Locks screen orientation when in fullscreen (mobile devices)
|
|
219
|
+
*
|
|
220
|
+
* @param {OrientationLockType} orientation - Orientation to lock to
|
|
221
|
+
* @returns {Promise<void>} Promise that resolves when orientation is locked
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* await lockOrientation('landscape');
|
|
225
|
+
* await enterFullscreen();
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export async function lockOrientation(orientation) {
|
|
229
|
+
if (typeof screen === 'undefined' || !screen.orientation) {
|
|
230
|
+
return Promise.reject(new Error('Screen Orientation API not supported'));
|
|
231
|
+
}
|
|
232
|
+
// Type assertion for lock method which may not be in all TypeScript lib versions
|
|
233
|
+
const orientationApi = screen.orientation;
|
|
234
|
+
if (!orientationApi.lock) {
|
|
235
|
+
return Promise.reject(new Error('Screen orientation lock not supported'));
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
await orientationApi.lock(orientation);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
return Promise.reject(error);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Unlocks screen orientation
|
|
246
|
+
*
|
|
247
|
+
* @returns {Promise<void>} Promise that resolves when orientation is unlocked
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* await unlockOrientation();
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
export async function unlockOrientation() {
|
|
254
|
+
if (typeof screen === 'undefined' || !screen.orientation) {
|
|
255
|
+
return Promise.resolve();
|
|
256
|
+
}
|
|
257
|
+
// Type assertion for unlock method which may not be in all TypeScript lib versions
|
|
258
|
+
const orientationApi = screen.orientation;
|
|
259
|
+
try {
|
|
260
|
+
orientationApi.unlock?.();
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
// Ignore unlock errors
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Default export
|
|
267
|
+
export default {
|
|
268
|
+
isFullscreenSupported,
|
|
269
|
+
isFullscreen,
|
|
270
|
+
enterFullscreen,
|
|
271
|
+
exitFullscreen,
|
|
272
|
+
toggleFullscreen,
|
|
273
|
+
onFullscreenChange,
|
|
274
|
+
getFullscreenElement,
|
|
275
|
+
lockOrientation,
|
|
276
|
+
unlockOrientation,
|
|
277
|
+
};
|