fullscreen-engine 0.0.0-stage → 1.1.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/README.md +232 -2
- package/bin/fullscreen-engine.js +162 -0
- package/dist/adapters/electron.cjs +249 -0
- package/dist/adapters/electron.cjs.map +1 -0
- package/dist/adapters/electron.esm.js +247 -0
- package/dist/adapters/electron.esm.js.map +1 -0
- package/dist/adapters/puppeteer.cjs +125 -0
- package/dist/adapters/puppeteer.cjs.map +1 -0
- package/dist/adapters/puppeteer.esm.js +123 -0
- package/dist/adapters/puppeteer.esm.js.map +1 -0
- package/dist/adapters/ssr.cjs +31 -0
- package/dist/adapters/ssr.cjs.map +1 -0
- package/dist/adapters/ssr.esm.js +29 -0
- package/dist/adapters/ssr.esm.js.map +1 -0
- package/dist/config.cjs +1789 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.esm.js +1783 -0
- package/dist/config.esm.js.map +1 -0
- package/dist/fullscreen.esm.js +1673 -0
- package/dist/fullscreen.esm.js.map +1 -0
- package/dist/fullscreen.esm.min.js +3 -0
- package/dist/fullscreen.esm.min.js.map +1 -0
- package/dist/fullscreen.iife.js +1689 -0
- package/dist/fullscreen.iife.js.map +1 -0
- package/dist/fullscreen.umd.cjs +1690 -0
- package/dist/fullscreen.umd.cjs.map +1 -0
- package/dist/fullscreen.umd.min.cjs +3 -0
- package/dist/fullscreen.umd.min.cjs.map +1 -0
- package/package.json +82 -4
- package/src/adapters/electron.js +180 -0
- package/src/adapters/puppeteer.js +119 -0
- package/src/adapters/ssr.js +25 -0
- package/src/config-loader.js +114 -0
- package/src/config.js +180 -0
- package/src/core.js +524 -0
- package/src/events.js +63 -0
- package/src/fallback.js +136 -0
- package/src/index.js +23 -0
- package/src/triggers.js +282 -0
- package/src/utils.js +67 -0
- package/src/vendor.js +118 -0
- package/types/config.d.ts +40 -0
- package/types/electron.d.ts +45 -0
- package/types/index.d.ts +161 -0
- package/types/puppeteer.d.ts +23 -0
- package/types/ssr.d.ts +22 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AutoRelockOptions,
|
|
3
|
+
FullscreenErrorListener,
|
|
4
|
+
FullscreenEvent,
|
|
5
|
+
FullscreenListener,
|
|
6
|
+
FullscreenState
|
|
7
|
+
} from './index.d.ts';
|
|
8
|
+
|
|
9
|
+
export interface ElectronFullscreenBridge {
|
|
10
|
+
set(on: boolean): Promise<boolean | void> | boolean | void;
|
|
11
|
+
get?(): Promise<boolean> | boolean;
|
|
12
|
+
onChange?(cb: (on: boolean) => void): (() => void) | void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ElectronFullscreenOptions {
|
|
16
|
+
autoRelock?: boolean | AutoRelockOptions;
|
|
17
|
+
preventExit?: boolean;
|
|
18
|
+
onError?: ((err: Error) => void) | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ElectronFullscreenController {
|
|
22
|
+
request(): Promise<void>;
|
|
23
|
+
exit(): Promise<void>;
|
|
24
|
+
toggle(): Promise<void>;
|
|
25
|
+
unlock(): void;
|
|
26
|
+
relock(): Promise<void>;
|
|
27
|
+
isActive(): boolean;
|
|
28
|
+
isSupported(): boolean;
|
|
29
|
+
getState(): FullscreenState;
|
|
30
|
+
on(event: 'change' | 'enter' | 'exit', cb: FullscreenListener): () => void;
|
|
31
|
+
on(event: 'error', cb: FullscreenErrorListener): () => void;
|
|
32
|
+
on(event: FullscreenEvent, cb: (...args: any[]) => void): () => void;
|
|
33
|
+
once(event: 'change' | 'enter' | 'exit', cb: FullscreenListener): () => void;
|
|
34
|
+
once(event: 'error', cb: FullscreenErrorListener): () => void;
|
|
35
|
+
once(event: FullscreenEvent, cb: (...args: any[]) => void): () => void;
|
|
36
|
+
off(event: 'change' | 'enter' | 'exit', cb: FullscreenListener): void;
|
|
37
|
+
off(event: 'error', cb: FullscreenErrorListener): void;
|
|
38
|
+
off(event: FullscreenEvent, cb: (...args: any[]) => void): void;
|
|
39
|
+
destroy(): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function createElectronFullscreen(
|
|
43
|
+
bridge: ElectronFullscreenBridge,
|
|
44
|
+
options?: ElectronFullscreenOptions
|
|
45
|
+
): ElectronFullscreenController;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
export type FullscreenSource = 'native' | 'fallback' | 'electron' | 'none';
|
|
2
|
+
|
|
3
|
+
export type FullscreenTriggerMode = 'manual' | 'hover' | 'scroll';
|
|
4
|
+
|
|
5
|
+
export type FullscreenPresetMode = 'default' | 'kiosk' | 'presentation' | 'strict';
|
|
6
|
+
|
|
7
|
+
export interface AutoRelockOptions {
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
delay?: number;
|
|
10
|
+
maxRetries?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FullscreenEnvironment {
|
|
14
|
+
request: string | null;
|
|
15
|
+
exit: string | null;
|
|
16
|
+
elementProp: string | null;
|
|
17
|
+
enabledProp: string | null;
|
|
18
|
+
changeEvent: string;
|
|
19
|
+
errorEvent: string;
|
|
20
|
+
supported: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface FullscreenState {
|
|
24
|
+
active: boolean;
|
|
25
|
+
source: FullscreenSource;
|
|
26
|
+
element: Element | null;
|
|
27
|
+
supported: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FullscreenOptions {
|
|
31
|
+
/** Element to make fullscreen. Defaults to document.documentElement. */
|
|
32
|
+
target?: Element | null;
|
|
33
|
+
/** 'css' enables a CSS-based fallback if native is unavailable/rejected. */
|
|
34
|
+
fallback?: 'css' | 'none';
|
|
35
|
+
/** Class added to the target in CSS fallback mode. */
|
|
36
|
+
fallbackClass?: string;
|
|
37
|
+
/** Prevent document scrolling during CSS fallback. Default: true (auto-disabled when scroll trigger + autoExit are both active). */
|
|
38
|
+
lockBody?: boolean;
|
|
39
|
+
/** z-index for CSS fallback. Default: 2147483647. */
|
|
40
|
+
zIndex?: number;
|
|
41
|
+
/** Error callback for any internal failure. */
|
|
42
|
+
onError?: ((err: Error) => void) | null;
|
|
43
|
+
/** Auto-detect window.fsNative bridge from Electron. Default: true. */
|
|
44
|
+
autoDetectElectron?: boolean;
|
|
45
|
+
/** Activation trigger mode(s). Default: 'manual'. */
|
|
46
|
+
trigger?: FullscreenTriggerMode | FullscreenTriggerMode[];
|
|
47
|
+
/** Element monitored for hover auto-trigger. Defaults to target or document.documentElement. */
|
|
48
|
+
hoverTarget?: Element | null;
|
|
49
|
+
/** Delay in milliseconds before hover enters fullscreen. Default: 0. */
|
|
50
|
+
hoverDelay?: number;
|
|
51
|
+
/** Scroll container monitored for scroll auto-trigger. Defaults to window. */
|
|
52
|
+
scrollTarget?: Element | Window | null;
|
|
53
|
+
/** Vertical scroll offset in pixels required to trigger fullscreen. Default: 100. */
|
|
54
|
+
scrollThreshold?: number;
|
|
55
|
+
/** Automatically exit fullscreen when cursor leaves hoverTarget or scroll returns above scrollThreshold. Default: true. */
|
|
56
|
+
autoExit?: boolean;
|
|
57
|
+
/** Suppress auto-triggers after manual exit until cursor leaves or scroll resets. Default: true. */
|
|
58
|
+
suppressOnManualExit?: boolean;
|
|
59
|
+
/** Automatically re-enter fullscreen (Electron or CSS fallback) after unexpected exit. Default: false. */
|
|
60
|
+
autoRelock?: boolean | AutoRelockOptions;
|
|
61
|
+
/** Block CSS Escape key and manual exit() calls until unlock() is called. Default: false. */
|
|
62
|
+
preventExit?: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface FullscreenAdaptersConfig {
|
|
66
|
+
electron?: {
|
|
67
|
+
autoRelock?: boolean | AutoRelockOptions;
|
|
68
|
+
preventExit?: boolean;
|
|
69
|
+
onError?: ((err: Error) => void) | null;
|
|
70
|
+
};
|
|
71
|
+
puppeteer?: {
|
|
72
|
+
restoreState?: 'normal' | 'maximized' | 'minimized';
|
|
73
|
+
preventExit?: boolean;
|
|
74
|
+
};
|
|
75
|
+
ssr?: {
|
|
76
|
+
enabled?: boolean;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface FullscreenGlobalConfig {
|
|
81
|
+
mode?: FullscreenPresetMode;
|
|
82
|
+
core?: FullscreenOptions;
|
|
83
|
+
adapters?: FullscreenAdaptersConfig;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface ResolvedFullscreenConfig {
|
|
87
|
+
mode: FullscreenPresetMode;
|
|
88
|
+
core: FullscreenOptions;
|
|
89
|
+
adapters: {
|
|
90
|
+
electron: NonNullable<FullscreenAdaptersConfig['electron']>;
|
|
91
|
+
puppeteer: NonNullable<FullscreenAdaptersConfig['puppeteer']>;
|
|
92
|
+
ssr: NonNullable<FullscreenAdaptersConfig['ssr']>;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface InitFullscreenContext {
|
|
97
|
+
adapter?: 'electron' | 'puppeteer' | 'ssr' | 'core';
|
|
98
|
+
target?: Element | null;
|
|
99
|
+
bridge?: any;
|
|
100
|
+
page?: any;
|
|
101
|
+
overrides?: FullscreenGlobalConfig;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type FullscreenEvent = 'change' | 'enter' | 'exit' | 'error';
|
|
105
|
+
|
|
106
|
+
export type FullscreenListener = (state: FullscreenState) => void;
|
|
107
|
+
export type FullscreenErrorListener = (err: Error) => void;
|
|
108
|
+
|
|
109
|
+
export interface FullscreenInstance {
|
|
110
|
+
request(): Promise<void>;
|
|
111
|
+
exit(): Promise<void>;
|
|
112
|
+
toggle(): Promise<void>;
|
|
113
|
+
unlock(): void;
|
|
114
|
+
isActive(): boolean;
|
|
115
|
+
isSupported(): boolean;
|
|
116
|
+
isFallback(): boolean;
|
|
117
|
+
getState(): FullscreenState;
|
|
118
|
+
on(event: 'change' | 'enter' | 'exit', cb: FullscreenListener): () => void;
|
|
119
|
+
on(event: 'error', cb: FullscreenErrorListener): () => void;
|
|
120
|
+
on(event: FullscreenEvent, cb: (...args: any[]) => void): () => void;
|
|
121
|
+
once(event: 'change' | 'enter' | 'exit', cb: FullscreenListener): () => void;
|
|
122
|
+
once(event: 'error', cb: FullscreenErrorListener): () => void;
|
|
123
|
+
once(event: FullscreenEvent, cb: (...args: any[]) => void): () => void;
|
|
124
|
+
off(event: 'change' | 'enter' | 'exit', cb: FullscreenListener): void;
|
|
125
|
+
off(event: 'error', cb: FullscreenErrorListener): void;
|
|
126
|
+
off(event: FullscreenEvent, cb: (...args: any[]) => void): void;
|
|
127
|
+
destroy(): void;
|
|
128
|
+
readonly _env: FullscreenEnvironment | null;
|
|
129
|
+
readonly _options: FullscreenOptions;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export declare const PRESETS: Record<FullscreenPresetMode, ResolvedFullscreenConfig>;
|
|
133
|
+
|
|
134
|
+
export function defineConfig(config?: FullscreenGlobalConfig): FullscreenGlobalConfig;
|
|
135
|
+
|
|
136
|
+
export function resolveConfig(
|
|
137
|
+
config?: FullscreenGlobalConfig,
|
|
138
|
+
overrides?: FullscreenGlobalConfig
|
|
139
|
+
): ResolvedFullscreenConfig;
|
|
140
|
+
|
|
141
|
+
export function initFullscreen(
|
|
142
|
+
config?: FullscreenGlobalConfig,
|
|
143
|
+
context?: InitFullscreenContext
|
|
144
|
+
): any;
|
|
145
|
+
|
|
146
|
+
export function createFullscreen(options?: FullscreenOptions): FullscreenInstance;
|
|
147
|
+
|
|
148
|
+
export function detectEnvironment(root?: Element | null): FullscreenEnvironment | null;
|
|
149
|
+
|
|
150
|
+
export function isBrowser(): boolean;
|
|
151
|
+
export function isNode(): boolean;
|
|
152
|
+
export function isElectron(): boolean;
|
|
153
|
+
|
|
154
|
+
export class Emitter {
|
|
155
|
+
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
156
|
+
once(event: string, cb: (...args: any[]) => void): () => void;
|
|
157
|
+
off(event: string, cb: (...args: any[]) => void): void;
|
|
158
|
+
emit(event: string, ...args: any[]): void;
|
|
159
|
+
clear(): void;
|
|
160
|
+
listenerCount(event: string): number;
|
|
161
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface PuppeteerFullscreenOptions {
|
|
2
|
+
/** Window state to restore on exit. Default: 'normal'. */
|
|
3
|
+
restoreState?: 'normal' | 'maximized' | 'minimized';
|
|
4
|
+
/** Block exit() calls until unlock() is called. Default: false. */
|
|
5
|
+
preventExit?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface PuppeteerController {
|
|
9
|
+
request(): Promise<boolean>;
|
|
10
|
+
exit(): Promise<boolean>;
|
|
11
|
+
toggle(): Promise<boolean>;
|
|
12
|
+
unlock(): void;
|
|
13
|
+
relock(): Promise<boolean>;
|
|
14
|
+
isActive(): boolean;
|
|
15
|
+
isSupported(): boolean;
|
|
16
|
+
getWindowState(): Promise<string>;
|
|
17
|
+
destroy(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function createPuppeteerFullscreen(
|
|
21
|
+
page: any,
|
|
22
|
+
options?: PuppeteerFullscreenOptions
|
|
23
|
+
): PuppeteerController;
|
package/types/ssr.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface SSRFullscreenState {
|
|
2
|
+
active: false;
|
|
3
|
+
source: 'none';
|
|
4
|
+
element: null;
|
|
5
|
+
supported: false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface SSRFullscreenInstance {
|
|
9
|
+
request(): Promise<never>;
|
|
10
|
+
exit(): Promise<void>;
|
|
11
|
+
toggle(): Promise<never>;
|
|
12
|
+
isActive(): false;
|
|
13
|
+
isSupported(): false;
|
|
14
|
+
isFallback(): false;
|
|
15
|
+
getState(): SSRFullscreenState;
|
|
16
|
+
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
17
|
+
once(event: string, cb: (...args: any[]) => void): () => void;
|
|
18
|
+
off(event: string, cb: (...args: any[]) => void): void;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createFullscreen(): SSRFullscreenInstance;
|