@embedpdf/plugin-fullscreen 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/LICENSE +21 -0
- package/dist/index.cjs +110 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/preact/index.cjs +76 -0
- package/dist/preact/index.cjs.map +1 -0
- package/dist/preact/index.d.cts +22 -0
- package/dist/preact/index.d.ts +22 -0
- package/dist/preact/index.js +47 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/react/index.cjs +76 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +22 -0
- package/dist/react/index.d.ts +22 -0
- package/dist/react/index.js +47 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CloudPDF
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
FULLSCREEN_PLUGIN_ID: () => FULLSCREEN_PLUGIN_ID,
|
|
24
|
+
FullscreenPlugin: () => FullscreenPlugin,
|
|
25
|
+
FullscreenPluginPackage: () => FullscreenPluginPackage,
|
|
26
|
+
SET_FULLSCREEN: () => SET_FULLSCREEN,
|
|
27
|
+
manifest: () => manifest,
|
|
28
|
+
setFullscreen: () => setFullscreen
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(index_exports);
|
|
31
|
+
|
|
32
|
+
// src/lib/manifest.ts
|
|
33
|
+
var FULLSCREEN_PLUGIN_ID = "fullscreen";
|
|
34
|
+
var manifest = {
|
|
35
|
+
id: FULLSCREEN_PLUGIN_ID,
|
|
36
|
+
name: "Fullscreen Plugin",
|
|
37
|
+
version: "1.0.0",
|
|
38
|
+
provides: ["fullscreen"],
|
|
39
|
+
requires: [],
|
|
40
|
+
optional: [],
|
|
41
|
+
defaultConfig: {
|
|
42
|
+
enabled: true
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/lib/fullscreen-plugin.ts
|
|
47
|
+
var import_core = require("@embedpdf/core");
|
|
48
|
+
|
|
49
|
+
// src/lib/actions.ts
|
|
50
|
+
var SET_FULLSCREEN = "SET_FULLSCREEN";
|
|
51
|
+
function setFullscreen(payload) {
|
|
52
|
+
return { type: SET_FULLSCREEN, payload };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/lib/fullscreen-plugin.ts
|
|
56
|
+
var FullscreenPlugin = class extends import_core.BasePlugin {
|
|
57
|
+
constructor(id, registry) {
|
|
58
|
+
super(id, registry);
|
|
59
|
+
this.fullscreenRequest$ = (0, import_core.createEmitter)();
|
|
60
|
+
}
|
|
61
|
+
async initialize(_) {
|
|
62
|
+
}
|
|
63
|
+
buildCapability() {
|
|
64
|
+
return {
|
|
65
|
+
isFullscreen: () => this.state.isFullscreen,
|
|
66
|
+
enableFullscreen: () => this.fullscreenRequest$.emit("enter"),
|
|
67
|
+
exitFullscreen: () => this.fullscreenRequest$.emit("exit"),
|
|
68
|
+
onRequest: this.fullscreenRequest$.on
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
setFullscreenState(isFullscreen) {
|
|
72
|
+
this.dispatch(setFullscreen(isFullscreen));
|
|
73
|
+
}
|
|
74
|
+
async destroy() {
|
|
75
|
+
this.fullscreenRequest$.clear();
|
|
76
|
+
super.destroy();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
FullscreenPlugin.id = "fullscreen";
|
|
80
|
+
|
|
81
|
+
// src/lib/reducer.ts
|
|
82
|
+
var initialState = {
|
|
83
|
+
isFullscreen: false
|
|
84
|
+
};
|
|
85
|
+
var reducer = (state, action) => {
|
|
86
|
+
switch (action.type) {
|
|
87
|
+
case SET_FULLSCREEN:
|
|
88
|
+
return { ...state, isFullscreen: action.payload };
|
|
89
|
+
default:
|
|
90
|
+
return state;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/lib/index.ts
|
|
95
|
+
var FullscreenPluginPackage = {
|
|
96
|
+
manifest,
|
|
97
|
+
create: (registry) => new FullscreenPlugin(FULLSCREEN_PLUGIN_ID, registry),
|
|
98
|
+
reducer,
|
|
99
|
+
initialState
|
|
100
|
+
};
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
FULLSCREEN_PLUGIN_ID,
|
|
104
|
+
FullscreenPlugin,
|
|
105
|
+
FullscreenPluginPackage,
|
|
106
|
+
SET_FULLSCREEN,
|
|
107
|
+
manifest,
|
|
108
|
+
setFullscreen
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lib/manifest.ts","../src/lib/fullscreen-plugin.ts","../src/lib/actions.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["export * from './lib';\n","import { PluginManifest } from '@embedpdf/core';\nimport { FullscreenPluginConfig } from './types';\n\nexport const FULLSCREEN_PLUGIN_ID = 'fullscreen';\n\nexport const manifest: PluginManifest<FullscreenPluginConfig> = {\n id: FULLSCREEN_PLUGIN_ID,\n name: 'Fullscreen Plugin',\n version: '1.0.0',\n provides: ['fullscreen'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport { FullscreenCapability, FullscreenPluginConfig, FullscreenState } from './types';\nimport { FullscreenAction, setFullscreen } from './actions';\n\nexport class FullscreenPlugin extends BasePlugin<\n FullscreenPluginConfig,\n FullscreenCapability,\n FullscreenState,\n FullscreenAction\n> {\n static readonly id = 'fullscreen' as const;\n\n private readonly fullscreenRequest$ = createEmitter<'enter' | 'exit'>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n }\n\n async initialize(_: FullscreenPluginConfig): Promise<void> {}\n\n protected buildCapability(): FullscreenCapability {\n return {\n isFullscreen: () => this.state.isFullscreen,\n enableFullscreen: () => this.fullscreenRequest$.emit('enter'),\n exitFullscreen: () => this.fullscreenRequest$.emit('exit'),\n onRequest: this.fullscreenRequest$.on,\n };\n }\n\n public setFullscreenState(isFullscreen: boolean): void {\n this.dispatch(setFullscreen(isFullscreen));\n }\n\n async destroy(): Promise<void> {\n this.fullscreenRequest$.clear();\n super.destroy();\n }\n}\n","import { Action } from '@embedpdf/core';\n\nexport const SET_FULLSCREEN = 'SET_FULLSCREEN';\n\nexport interface SetFullscreenAction extends Action {\n type: typeof SET_FULLSCREEN;\n payload: boolean;\n}\n\nexport type FullscreenAction = SetFullscreenAction;\n\nexport function setFullscreen(payload: boolean): SetFullscreenAction {\n return { type: SET_FULLSCREEN, payload };\n}\n","import { Reducer } from '@embedpdf/core';\nimport { FullscreenState } from './types';\nimport { FullscreenAction, SET_FULLSCREEN } from './actions';\n\nexport const initialState: FullscreenState = {\n isFullscreen: false,\n};\n\nexport const reducer: Reducer<FullscreenState, FullscreenAction> = (state, action) => {\n switch (action.type) {\n case SET_FULLSCREEN:\n return { ...state, isFullscreen: action.payload };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, FULLSCREEN_PLUGIN_ID } from './manifest';\nimport { FullscreenPluginConfig, FullscreenState } from './types';\nimport { FullscreenPlugin } from './fullscreen-plugin';\nimport { initialState } from './reducer';\nimport { reducer } from './reducer';\nimport { FullscreenAction } from './actions';\n\nexport const FullscreenPluginPackage: PluginPackage<\n FullscreenPlugin,\n FullscreenPluginConfig,\n FullscreenState,\n FullscreenAction\n> = {\n manifest,\n create: (registry) => new FullscreenPlugin(FULLSCREEN_PLUGIN_ID, registry),\n reducer,\n initialState,\n};\n\nexport * from './fullscreen-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './actions';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,uBAAuB;AAE7B,IAAM,WAAmD;AAAA,EAC9D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,YAAY;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,EACX;AACF;;;ACfA,kBAA0D;;;ACEnD,IAAM,iBAAiB;AASvB,SAAS,cAAc,SAAuC;AACnE,SAAO,EAAE,MAAM,gBAAgB,QAAQ;AACzC;;;ADTO,IAAM,mBAAN,cAA+B,uBAKpC;AAAA,EAKA,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AAHpB,SAAiB,yBAAqB,2BAAgC;AAAA,EAItE;AAAA,EAEA,MAAM,WAAW,GAA0C;AAAA,EAAC;AAAA,EAElD,kBAAwC;AAChD,WAAO;AAAA,MACL,cAAc,MAAM,KAAK,MAAM;AAAA,MAC/B,kBAAkB,MAAM,KAAK,mBAAmB,KAAK,OAAO;AAAA,MAC5D,gBAAgB,MAAM,KAAK,mBAAmB,KAAK,MAAM;AAAA,MACzD,WAAW,KAAK,mBAAmB;AAAA,IACrC;AAAA,EACF;AAAA,EAEO,mBAAmB,cAA6B;AACrD,SAAK,SAAS,cAAc,YAAY,CAAC;AAAA,EAC3C;AAAA,EAEA,MAAM,UAAyB;AAC7B,SAAK,mBAAmB,MAAM;AAC9B,UAAM,QAAQ;AAAA,EAChB;AACF;AAjCa,iBAMK,KAAK;;;AENhB,IAAM,eAAgC;AAAA,EAC3C,cAAc;AAChB;AAEO,IAAM,UAAsD,CAAC,OAAO,WAAW;AACpF,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,cAAc,OAAO,QAAQ;AAAA,IAClD;AACE,aAAO;AAAA,EACX;AACF;;;ACPO,IAAM,0BAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,aAAa,IAAI,iBAAiB,sBAAsB,QAAQ;AAAA,EACzE;AAAA,EACA;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BasePluginConfig, EventHook, Action, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
|
|
2
|
+
|
|
3
|
+
interface FullscreenState {
|
|
4
|
+
isFullscreen: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface FullscreenPluginConfig extends BasePluginConfig {
|
|
7
|
+
}
|
|
8
|
+
interface FullscreenCapability {
|
|
9
|
+
isFullscreen: () => boolean;
|
|
10
|
+
enableFullscreen: () => void;
|
|
11
|
+
exitFullscreen: () => void;
|
|
12
|
+
onRequest: EventHook<'enter' | 'exit'>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const SET_FULLSCREEN = "SET_FULLSCREEN";
|
|
16
|
+
interface SetFullscreenAction extends Action {
|
|
17
|
+
type: typeof SET_FULLSCREEN;
|
|
18
|
+
payload: boolean;
|
|
19
|
+
}
|
|
20
|
+
type FullscreenAction = SetFullscreenAction;
|
|
21
|
+
declare function setFullscreen(payload: boolean): SetFullscreenAction;
|
|
22
|
+
|
|
23
|
+
declare class FullscreenPlugin extends BasePlugin<FullscreenPluginConfig, FullscreenCapability, FullscreenState, FullscreenAction> {
|
|
24
|
+
static readonly id: "fullscreen";
|
|
25
|
+
private readonly fullscreenRequest$;
|
|
26
|
+
constructor(id: string, registry: PluginRegistry);
|
|
27
|
+
initialize(_: FullscreenPluginConfig): Promise<void>;
|
|
28
|
+
protected buildCapability(): FullscreenCapability;
|
|
29
|
+
setFullscreenState(isFullscreen: boolean): void;
|
|
30
|
+
destroy(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare const FULLSCREEN_PLUGIN_ID = "fullscreen";
|
|
34
|
+
declare const manifest: PluginManifest<FullscreenPluginConfig>;
|
|
35
|
+
|
|
36
|
+
declare const FullscreenPluginPackage: PluginPackage<FullscreenPlugin, FullscreenPluginConfig, FullscreenState, FullscreenAction>;
|
|
37
|
+
|
|
38
|
+
export { FULLSCREEN_PLUGIN_ID, type FullscreenAction, type FullscreenCapability, FullscreenPlugin, type FullscreenPluginConfig, FullscreenPluginPackage, type FullscreenState, SET_FULLSCREEN, type SetFullscreenAction, manifest, setFullscreen };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BasePluginConfig, EventHook, Action, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
|
|
2
|
+
|
|
3
|
+
interface FullscreenState {
|
|
4
|
+
isFullscreen: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface FullscreenPluginConfig extends BasePluginConfig {
|
|
7
|
+
}
|
|
8
|
+
interface FullscreenCapability {
|
|
9
|
+
isFullscreen: () => boolean;
|
|
10
|
+
enableFullscreen: () => void;
|
|
11
|
+
exitFullscreen: () => void;
|
|
12
|
+
onRequest: EventHook<'enter' | 'exit'>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const SET_FULLSCREEN = "SET_FULLSCREEN";
|
|
16
|
+
interface SetFullscreenAction extends Action {
|
|
17
|
+
type: typeof SET_FULLSCREEN;
|
|
18
|
+
payload: boolean;
|
|
19
|
+
}
|
|
20
|
+
type FullscreenAction = SetFullscreenAction;
|
|
21
|
+
declare function setFullscreen(payload: boolean): SetFullscreenAction;
|
|
22
|
+
|
|
23
|
+
declare class FullscreenPlugin extends BasePlugin<FullscreenPluginConfig, FullscreenCapability, FullscreenState, FullscreenAction> {
|
|
24
|
+
static readonly id: "fullscreen";
|
|
25
|
+
private readonly fullscreenRequest$;
|
|
26
|
+
constructor(id: string, registry: PluginRegistry);
|
|
27
|
+
initialize(_: FullscreenPluginConfig): Promise<void>;
|
|
28
|
+
protected buildCapability(): FullscreenCapability;
|
|
29
|
+
setFullscreenState(isFullscreen: boolean): void;
|
|
30
|
+
destroy(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare const FULLSCREEN_PLUGIN_ID = "fullscreen";
|
|
34
|
+
declare const manifest: PluginManifest<FullscreenPluginConfig>;
|
|
35
|
+
|
|
36
|
+
declare const FullscreenPluginPackage: PluginPackage<FullscreenPlugin, FullscreenPluginConfig, FullscreenState, FullscreenAction>;
|
|
37
|
+
|
|
38
|
+
export { FULLSCREEN_PLUGIN_ID, type FullscreenAction, type FullscreenCapability, FullscreenPlugin, type FullscreenPluginConfig, FullscreenPluginPackage, type FullscreenState, SET_FULLSCREEN, type SetFullscreenAction, manifest, setFullscreen };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/lib/manifest.ts
|
|
2
|
+
var FULLSCREEN_PLUGIN_ID = "fullscreen";
|
|
3
|
+
var manifest = {
|
|
4
|
+
id: FULLSCREEN_PLUGIN_ID,
|
|
5
|
+
name: "Fullscreen Plugin",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
provides: ["fullscreen"],
|
|
8
|
+
requires: [],
|
|
9
|
+
optional: [],
|
|
10
|
+
defaultConfig: {
|
|
11
|
+
enabled: true
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/lib/fullscreen-plugin.ts
|
|
16
|
+
import { BasePlugin, createEmitter } from "@embedpdf/core";
|
|
17
|
+
|
|
18
|
+
// src/lib/actions.ts
|
|
19
|
+
var SET_FULLSCREEN = "SET_FULLSCREEN";
|
|
20
|
+
function setFullscreen(payload) {
|
|
21
|
+
return { type: SET_FULLSCREEN, payload };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/lib/fullscreen-plugin.ts
|
|
25
|
+
var FullscreenPlugin = class extends BasePlugin {
|
|
26
|
+
constructor(id, registry) {
|
|
27
|
+
super(id, registry);
|
|
28
|
+
this.fullscreenRequest$ = createEmitter();
|
|
29
|
+
}
|
|
30
|
+
async initialize(_) {
|
|
31
|
+
}
|
|
32
|
+
buildCapability() {
|
|
33
|
+
return {
|
|
34
|
+
isFullscreen: () => this.state.isFullscreen,
|
|
35
|
+
enableFullscreen: () => this.fullscreenRequest$.emit("enter"),
|
|
36
|
+
exitFullscreen: () => this.fullscreenRequest$.emit("exit"),
|
|
37
|
+
onRequest: this.fullscreenRequest$.on
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
setFullscreenState(isFullscreen) {
|
|
41
|
+
this.dispatch(setFullscreen(isFullscreen));
|
|
42
|
+
}
|
|
43
|
+
async destroy() {
|
|
44
|
+
this.fullscreenRequest$.clear();
|
|
45
|
+
super.destroy();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
FullscreenPlugin.id = "fullscreen";
|
|
49
|
+
|
|
50
|
+
// src/lib/reducer.ts
|
|
51
|
+
var initialState = {
|
|
52
|
+
isFullscreen: false
|
|
53
|
+
};
|
|
54
|
+
var reducer = (state, action) => {
|
|
55
|
+
switch (action.type) {
|
|
56
|
+
case SET_FULLSCREEN:
|
|
57
|
+
return { ...state, isFullscreen: action.payload };
|
|
58
|
+
default:
|
|
59
|
+
return state;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/lib/index.ts
|
|
64
|
+
var FullscreenPluginPackage = {
|
|
65
|
+
manifest,
|
|
66
|
+
create: (registry) => new FullscreenPlugin(FULLSCREEN_PLUGIN_ID, registry),
|
|
67
|
+
reducer,
|
|
68
|
+
initialState
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
FULLSCREEN_PLUGIN_ID,
|
|
72
|
+
FullscreenPlugin,
|
|
73
|
+
FullscreenPluginPackage,
|
|
74
|
+
SET_FULLSCREEN,
|
|
75
|
+
manifest,
|
|
76
|
+
setFullscreen
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/manifest.ts","../src/lib/fullscreen-plugin.ts","../src/lib/actions.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { FullscreenPluginConfig } from './types';\n\nexport const FULLSCREEN_PLUGIN_ID = 'fullscreen';\n\nexport const manifest: PluginManifest<FullscreenPluginConfig> = {\n id: FULLSCREEN_PLUGIN_ID,\n name: 'Fullscreen Plugin',\n version: '1.0.0',\n provides: ['fullscreen'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport { FullscreenCapability, FullscreenPluginConfig, FullscreenState } from './types';\nimport { FullscreenAction, setFullscreen } from './actions';\n\nexport class FullscreenPlugin extends BasePlugin<\n FullscreenPluginConfig,\n FullscreenCapability,\n FullscreenState,\n FullscreenAction\n> {\n static readonly id = 'fullscreen' as const;\n\n private readonly fullscreenRequest$ = createEmitter<'enter' | 'exit'>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n }\n\n async initialize(_: FullscreenPluginConfig): Promise<void> {}\n\n protected buildCapability(): FullscreenCapability {\n return {\n isFullscreen: () => this.state.isFullscreen,\n enableFullscreen: () => this.fullscreenRequest$.emit('enter'),\n exitFullscreen: () => this.fullscreenRequest$.emit('exit'),\n onRequest: this.fullscreenRequest$.on,\n };\n }\n\n public setFullscreenState(isFullscreen: boolean): void {\n this.dispatch(setFullscreen(isFullscreen));\n }\n\n async destroy(): Promise<void> {\n this.fullscreenRequest$.clear();\n super.destroy();\n }\n}\n","import { Action } from '@embedpdf/core';\n\nexport const SET_FULLSCREEN = 'SET_FULLSCREEN';\n\nexport interface SetFullscreenAction extends Action {\n type: typeof SET_FULLSCREEN;\n payload: boolean;\n}\n\nexport type FullscreenAction = SetFullscreenAction;\n\nexport function setFullscreen(payload: boolean): SetFullscreenAction {\n return { type: SET_FULLSCREEN, payload };\n}\n","import { Reducer } from '@embedpdf/core';\nimport { FullscreenState } from './types';\nimport { FullscreenAction, SET_FULLSCREEN } from './actions';\n\nexport const initialState: FullscreenState = {\n isFullscreen: false,\n};\n\nexport const reducer: Reducer<FullscreenState, FullscreenAction> = (state, action) => {\n switch (action.type) {\n case SET_FULLSCREEN:\n return { ...state, isFullscreen: action.payload };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, FULLSCREEN_PLUGIN_ID } from './manifest';\nimport { FullscreenPluginConfig, FullscreenState } from './types';\nimport { FullscreenPlugin } from './fullscreen-plugin';\nimport { initialState } from './reducer';\nimport { reducer } from './reducer';\nimport { FullscreenAction } from './actions';\n\nexport const FullscreenPluginPackage: PluginPackage<\n FullscreenPlugin,\n FullscreenPluginConfig,\n FullscreenState,\n FullscreenAction\n> = {\n manifest,\n create: (registry) => new FullscreenPlugin(FULLSCREEN_PLUGIN_ID, registry),\n reducer,\n initialState,\n};\n\nexport * from './fullscreen-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './actions';\n"],"mappings":";AAGO,IAAM,uBAAuB;AAE7B,IAAM,WAAmD;AAAA,EAC9D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,YAAY;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,EACX;AACF;;;ACfA,SAAS,YAAY,qBAAqC;;;ACEnD,IAAM,iBAAiB;AASvB,SAAS,cAAc,SAAuC;AACnE,SAAO,EAAE,MAAM,gBAAgB,QAAQ;AACzC;;;ADTO,IAAM,mBAAN,cAA+B,WAKpC;AAAA,EAKA,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AAHpB,SAAiB,qBAAqB,cAAgC;AAAA,EAItE;AAAA,EAEA,MAAM,WAAW,GAA0C;AAAA,EAAC;AAAA,EAElD,kBAAwC;AAChD,WAAO;AAAA,MACL,cAAc,MAAM,KAAK,MAAM;AAAA,MAC/B,kBAAkB,MAAM,KAAK,mBAAmB,KAAK,OAAO;AAAA,MAC5D,gBAAgB,MAAM,KAAK,mBAAmB,KAAK,MAAM;AAAA,MACzD,WAAW,KAAK,mBAAmB;AAAA,IACrC;AAAA,EACF;AAAA,EAEO,mBAAmB,cAA6B;AACrD,SAAK,SAAS,cAAc,YAAY,CAAC;AAAA,EAC3C;AAAA,EAEA,MAAM,UAAyB;AAC7B,SAAK,mBAAmB,MAAM;AAC9B,UAAM,QAAQ;AAAA,EAChB;AACF;AAjCa,iBAMK,KAAK;;;AENhB,IAAM,eAAgC;AAAA,EAC3C,cAAc;AAChB;AAEO,IAAM,UAAsD,CAAC,OAAO,WAAW;AACpF,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,cAAc,OAAO,QAAQ;AAAA,IAClD;AACE,aAAO;AAAA,EACX;AACF;;;ACPO,IAAM,0BAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,aAAa,IAAI,iBAAiB,sBAAsB,QAAQ;AAAA,EACzE;AAAA,EACA;AACF;","names":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/preact/index.ts
|
|
21
|
+
var preact_exports = {};
|
|
22
|
+
__export(preact_exports, {
|
|
23
|
+
FullscreenProvider: () => FullscreenProvider,
|
|
24
|
+
useFullscreen: () => useFullscreen,
|
|
25
|
+
useFullscreenCapability: () => useFullscreenCapability
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(preact_exports);
|
|
28
|
+
|
|
29
|
+
// src/preact/hooks/use-fullscreen.ts
|
|
30
|
+
var import_preact = require("@embedpdf/core/preact");
|
|
31
|
+
var import_plugin_fullscreen = require("@embedpdf/plugin-fullscreen");
|
|
32
|
+
var useFullscreen = () => (0, import_preact.usePlugin)(import_plugin_fullscreen.FullscreenPlugin.id);
|
|
33
|
+
var useFullscreenCapability = () => (0, import_preact.useCapability)(import_plugin_fullscreen.FullscreenPlugin.id);
|
|
34
|
+
|
|
35
|
+
// src/preact/components/fullscreen.tsx
|
|
36
|
+
var import_hooks = require("preact/hooks");
|
|
37
|
+
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
38
|
+
function FullscreenProvider({ children, ...props }) {
|
|
39
|
+
const { provides: fullscreenCapability } = useFullscreenCapability();
|
|
40
|
+
const { plugin } = useFullscreen();
|
|
41
|
+
const ref = (0, import_hooks.useRef)(null);
|
|
42
|
+
(0, import_hooks.useEffect)(() => {
|
|
43
|
+
if (!fullscreenCapability) return;
|
|
44
|
+
const unsub = fullscreenCapability.onRequest(async (action) => {
|
|
45
|
+
if (action === "enter") {
|
|
46
|
+
const el = ref.current;
|
|
47
|
+
if (el && !document.fullscreenElement) await el.requestFullscreen();
|
|
48
|
+
} else {
|
|
49
|
+
if (document.fullscreenElement) await document.exitFullscreen();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return unsub;
|
|
53
|
+
}, [fullscreenCapability]);
|
|
54
|
+
(0, import_hooks.useEffect)(() => {
|
|
55
|
+
if (!plugin) return;
|
|
56
|
+
const handler = () => plugin.setFullscreenState(!!document.fullscreenElement);
|
|
57
|
+
document.addEventListener("fullscreenchange", handler);
|
|
58
|
+
return () => document.removeEventListener("fullscreenchange", handler);
|
|
59
|
+
}, [plugin]);
|
|
60
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
...props,
|
|
64
|
+
style: { position: "relative", width: "100%", height: "100%", ...props.style },
|
|
65
|
+
ref,
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
FullscreenProvider,
|
|
73
|
+
useFullscreen,
|
|
74
|
+
useFullscreenCapability
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-fullscreen.ts","../../src/preact/components/fullscreen.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { FullscreenPlugin } from '@embedpdf/plugin-fullscreen';\n\nexport const useFullscreen = () => usePlugin<FullscreenPlugin>(FullscreenPlugin.id);\nexport const useFullscreenCapability = () => useCapability<FullscreenPlugin>(FullscreenPlugin.id);\n","/** @jsxImportSource preact */\nimport { setFullscreen } from '@embedpdf/plugin-fullscreen';\nimport { ComponentChildren, JSX } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\n\nimport { useFullscreen, useFullscreenCapability } from '../hooks';\n\ntype FullscreenProviderProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ComponentChildren;\n style?: JSX.CSSProperties;\n};\n\nexport function FullscreenProvider({ children, ...props }: FullscreenProviderProps) {\n const { provides: fullscreenCapability } = useFullscreenCapability();\n const { plugin } = useFullscreen();\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!fullscreenCapability) return;\n\n const unsub = fullscreenCapability.onRequest(async (action) => {\n if (action === 'enter') {\n const el = ref.current;\n if (el && !document.fullscreenElement) await el.requestFullscreen();\n } else {\n if (document.fullscreenElement) await document.exitFullscreen();\n }\n });\n\n return unsub;\n }, [fullscreenCapability]);\n\n useEffect(() => {\n if (!plugin) return;\n const handler = () => plugin.setFullscreenState(!!document.fullscreenElement);\n document.addEventListener('fullscreenchange', handler);\n return () => document.removeEventListener('fullscreenchange', handler);\n }, [plugin]);\n\n return (\n <div\n {...props}\n style={{ position: 'relative', width: '100%', height: '100%', ...props.style }}\n ref={ref}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyC;AACzC,+BAAiC;AAE1B,IAAM,gBAAgB,UAAM,yBAA4B,0CAAiB,EAAE;AAC3E,IAAM,0BAA0B,UAAM,6BAAgC,0CAAiB,EAAE;;;ACDhG,mBAAkC;AAqC9B;AA5BG,SAAS,mBAAmB,EAAE,UAAU,GAAG,MAAM,GAA4B;AAClF,QAAM,EAAE,UAAU,qBAAqB,IAAI,wBAAwB;AACnE,QAAM,EAAE,OAAO,IAAI,cAAc;AACjC,QAAM,UAAM,qBAAuB,IAAI;AAEvC,8BAAU,MAAM;AACd,QAAI,CAAC,qBAAsB;AAE3B,UAAM,QAAQ,qBAAqB,UAAU,OAAO,WAAW;AAC7D,UAAI,WAAW,SAAS;AACtB,cAAM,KAAK,IAAI;AACf,YAAI,MAAM,CAAC,SAAS,kBAAmB,OAAM,GAAG,kBAAkB;AAAA,MACpE,OAAO;AACL,YAAI,SAAS,kBAAmB,OAAM,SAAS,eAAe;AAAA,MAChE;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT,GAAG,CAAC,oBAAoB,CAAC;AAEzB,8BAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,UAAM,UAAU,MAAM,OAAO,mBAAmB,CAAC,CAAC,SAAS,iBAAiB;AAC5E,aAAS,iBAAiB,oBAAoB,OAAO;AACrD,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,OAAO;AAAA,EACvE,GAAG,CAAC,MAAM,CAAC;AAEX,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,EAAE,UAAU,YAAY,OAAO,QAAQ,QAAQ,QAAQ,GAAG,MAAM,MAAM;AAAA,MAC7E;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _embedpdf_plugin_fullscreen from '@embedpdf/plugin-fullscreen';
|
|
2
|
+
import { FullscreenPlugin } from '@embedpdf/plugin-fullscreen';
|
|
3
|
+
import { JSX, ComponentChildren } from 'preact';
|
|
4
|
+
|
|
5
|
+
declare const useFullscreen: () => {
|
|
6
|
+
plugin: FullscreenPlugin | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
ready: Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
declare const useFullscreenCapability: () => {
|
|
11
|
+
provides: Readonly<_embedpdf_plugin_fullscreen.FullscreenCapability> | null;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
ready: Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type FullscreenProviderProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
17
|
+
children: ComponentChildren;
|
|
18
|
+
style?: JSX.CSSProperties;
|
|
19
|
+
};
|
|
20
|
+
declare function FullscreenProvider({ children, ...props }: FullscreenProviderProps): JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { FullscreenProvider, useFullscreen, useFullscreenCapability };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _embedpdf_plugin_fullscreen from '@embedpdf/plugin-fullscreen';
|
|
2
|
+
import { FullscreenPlugin } from '@embedpdf/plugin-fullscreen';
|
|
3
|
+
import { JSX, ComponentChildren } from 'preact';
|
|
4
|
+
|
|
5
|
+
declare const useFullscreen: () => {
|
|
6
|
+
plugin: FullscreenPlugin | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
ready: Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
declare const useFullscreenCapability: () => {
|
|
11
|
+
provides: Readonly<_embedpdf_plugin_fullscreen.FullscreenCapability> | null;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
ready: Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type FullscreenProviderProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
17
|
+
children: ComponentChildren;
|
|
18
|
+
style?: JSX.CSSProperties;
|
|
19
|
+
};
|
|
20
|
+
declare function FullscreenProvider({ children, ...props }: FullscreenProviderProps): JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { FullscreenProvider, useFullscreen, useFullscreenCapability };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/preact/hooks/use-fullscreen.ts
|
|
2
|
+
import { useCapability, usePlugin } from "@embedpdf/core/preact";
|
|
3
|
+
import { FullscreenPlugin } from "@embedpdf/plugin-fullscreen";
|
|
4
|
+
var useFullscreen = () => usePlugin(FullscreenPlugin.id);
|
|
5
|
+
var useFullscreenCapability = () => useCapability(FullscreenPlugin.id);
|
|
6
|
+
|
|
7
|
+
// src/preact/components/fullscreen.tsx
|
|
8
|
+
import { useEffect, useRef } from "preact/hooks";
|
|
9
|
+
import { jsx } from "preact/jsx-runtime";
|
|
10
|
+
function FullscreenProvider({ children, ...props }) {
|
|
11
|
+
const { provides: fullscreenCapability } = useFullscreenCapability();
|
|
12
|
+
const { plugin } = useFullscreen();
|
|
13
|
+
const ref = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!fullscreenCapability) return;
|
|
16
|
+
const unsub = fullscreenCapability.onRequest(async (action) => {
|
|
17
|
+
if (action === "enter") {
|
|
18
|
+
const el = ref.current;
|
|
19
|
+
if (el && !document.fullscreenElement) await el.requestFullscreen();
|
|
20
|
+
} else {
|
|
21
|
+
if (document.fullscreenElement) await document.exitFullscreen();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return unsub;
|
|
25
|
+
}, [fullscreenCapability]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!plugin) return;
|
|
28
|
+
const handler = () => plugin.setFullscreenState(!!document.fullscreenElement);
|
|
29
|
+
document.addEventListener("fullscreenchange", handler);
|
|
30
|
+
return () => document.removeEventListener("fullscreenchange", handler);
|
|
31
|
+
}, [plugin]);
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
...props,
|
|
36
|
+
style: { position: "relative", width: "100%", height: "100%", ...props.style },
|
|
37
|
+
ref,
|
|
38
|
+
children
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
FullscreenProvider,
|
|
44
|
+
useFullscreen,
|
|
45
|
+
useFullscreenCapability
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/preact/hooks/use-fullscreen.ts","../../src/preact/components/fullscreen.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { FullscreenPlugin } from '@embedpdf/plugin-fullscreen';\n\nexport const useFullscreen = () => usePlugin<FullscreenPlugin>(FullscreenPlugin.id);\nexport const useFullscreenCapability = () => useCapability<FullscreenPlugin>(FullscreenPlugin.id);\n","/** @jsxImportSource preact */\nimport { setFullscreen } from '@embedpdf/plugin-fullscreen';\nimport { ComponentChildren, JSX } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\n\nimport { useFullscreen, useFullscreenCapability } from '../hooks';\n\ntype FullscreenProviderProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ComponentChildren;\n style?: JSX.CSSProperties;\n};\n\nexport function FullscreenProvider({ children, ...props }: FullscreenProviderProps) {\n const { provides: fullscreenCapability } = useFullscreenCapability();\n const { plugin } = useFullscreen();\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!fullscreenCapability) return;\n\n const unsub = fullscreenCapability.onRequest(async (action) => {\n if (action === 'enter') {\n const el = ref.current;\n if (el && !document.fullscreenElement) await el.requestFullscreen();\n } else {\n if (document.fullscreenElement) await document.exitFullscreen();\n }\n });\n\n return unsub;\n }, [fullscreenCapability]);\n\n useEffect(() => {\n if (!plugin) return;\n const handler = () => plugin.setFullscreenState(!!document.fullscreenElement);\n document.addEventListener('fullscreenchange', handler);\n return () => document.removeEventListener('fullscreenchange', handler);\n }, [plugin]);\n\n return (\n <div\n {...props}\n style={{ position: 'relative', width: '100%', height: '100%', ...props.style }}\n ref={ref}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,wBAAwB;AAE1B,IAAM,gBAAgB,MAAM,UAA4B,iBAAiB,EAAE;AAC3E,IAAM,0BAA0B,MAAM,cAAgC,iBAAiB,EAAE;;;ACDhG,SAAS,WAAW,cAAc;AAqC9B;AA5BG,SAAS,mBAAmB,EAAE,UAAU,GAAG,MAAM,GAA4B;AAClF,QAAM,EAAE,UAAU,qBAAqB,IAAI,wBAAwB;AACnE,QAAM,EAAE,OAAO,IAAI,cAAc;AACjC,QAAM,MAAM,OAAuB,IAAI;AAEvC,YAAU,MAAM;AACd,QAAI,CAAC,qBAAsB;AAE3B,UAAM,QAAQ,qBAAqB,UAAU,OAAO,WAAW;AAC7D,UAAI,WAAW,SAAS;AACtB,cAAM,KAAK,IAAI;AACf,YAAI,MAAM,CAAC,SAAS,kBAAmB,OAAM,GAAG,kBAAkB;AAAA,MACpE,OAAO;AACL,YAAI,SAAS,kBAAmB,OAAM,SAAS,eAAe;AAAA,MAChE;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT,GAAG,CAAC,oBAAoB,CAAC;AAEzB,YAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,UAAM,UAAU,MAAM,OAAO,mBAAmB,CAAC,CAAC,SAAS,iBAAiB;AAC5E,aAAS,iBAAiB,oBAAoB,OAAO;AACrD,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,OAAO;AAAA,EACvE,GAAG,CAAC,MAAM,CAAC;AAEX,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,EAAE,UAAU,YAAY,OAAO,QAAQ,QAAQ,QAAQ,GAAG,MAAM,MAAM;AAAA,MAC7E;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/react/index.ts
|
|
21
|
+
var react_exports = {};
|
|
22
|
+
__export(react_exports, {
|
|
23
|
+
FullscreenProvider: () => FullscreenProvider,
|
|
24
|
+
useFullscreen: () => useFullscreen,
|
|
25
|
+
useFullscreenCapability: () => useFullscreenCapability
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(react_exports);
|
|
28
|
+
|
|
29
|
+
// src/react/hooks/use-fullscreen.ts
|
|
30
|
+
var import_react = require("@embedpdf/core/react");
|
|
31
|
+
var import_plugin_fullscreen = require("@embedpdf/plugin-fullscreen");
|
|
32
|
+
var useFullscreen = () => (0, import_react.usePlugin)(import_plugin_fullscreen.FullscreenPlugin.id);
|
|
33
|
+
var useFullscreenCapability = () => (0, import_react.useCapability)(import_plugin_fullscreen.FullscreenPlugin.id);
|
|
34
|
+
|
|
35
|
+
// src/react/components/fullscreen.tsx
|
|
36
|
+
var import_react2 = require("react");
|
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
function FullscreenProvider({ children, ...props }) {
|
|
39
|
+
const { provides: fullscreenCapability } = useFullscreenCapability();
|
|
40
|
+
const { plugin } = useFullscreen();
|
|
41
|
+
const ref = (0, import_react2.useRef)(null);
|
|
42
|
+
(0, import_react2.useEffect)(() => {
|
|
43
|
+
if (!fullscreenCapability) return;
|
|
44
|
+
const unsub = fullscreenCapability.onRequest(async (action) => {
|
|
45
|
+
if (action === "enter") {
|
|
46
|
+
const el = ref.current;
|
|
47
|
+
if (el && !document.fullscreenElement) await el.requestFullscreen();
|
|
48
|
+
} else {
|
|
49
|
+
if (document.fullscreenElement) await document.exitFullscreen();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return unsub;
|
|
53
|
+
}, [fullscreenCapability]);
|
|
54
|
+
(0, import_react2.useEffect)(() => {
|
|
55
|
+
if (!plugin) return;
|
|
56
|
+
const handler = () => plugin.setFullscreenState(!!document.fullscreenElement);
|
|
57
|
+
document.addEventListener("fullscreenchange", handler);
|
|
58
|
+
return () => document.removeEventListener("fullscreenchange", handler);
|
|
59
|
+
}, [plugin]);
|
|
60
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
...props,
|
|
64
|
+
style: { position: "relative", width: "100%", height: "100%", ...props.style },
|
|
65
|
+
ref,
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
FullscreenProvider,
|
|
73
|
+
useFullscreen,
|
|
74
|
+
useFullscreenCapability
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/react/index.ts","../../src/react/hooks/use-fullscreen.ts","../../src/react/components/fullscreen.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { FullscreenPlugin } from '@embedpdf/plugin-fullscreen';\n\nexport const useFullscreen = () => usePlugin<FullscreenPlugin>(FullscreenPlugin.id);\nexport const useFullscreenCapability = () => useCapability<FullscreenPlugin>(FullscreenPlugin.id);\n","import { useEffect, useRef } from 'react';\n\nimport { useFullscreen, useFullscreenCapability } from '../hooks';\n\ntype FullscreenProviderProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: React.ReactNode;\n style?: React.CSSProperties;\n};\n\nexport function FullscreenProvider({ children, ...props }: FullscreenProviderProps) {\n const { provides: fullscreenCapability } = useFullscreenCapability();\n const { plugin } = useFullscreen();\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!fullscreenCapability) return;\n\n const unsub = fullscreenCapability.onRequest(async (action) => {\n if (action === 'enter') {\n const el = ref.current;\n if (el && !document.fullscreenElement) await el.requestFullscreen();\n } else {\n if (document.fullscreenElement) await document.exitFullscreen();\n }\n });\n\n return unsub;\n }, [fullscreenCapability]);\n\n useEffect(() => {\n if (!plugin) return;\n const handler = () => plugin.setFullscreenState(!!document.fullscreenElement);\n document.addEventListener('fullscreenchange', handler);\n return () => document.removeEventListener('fullscreenchange', handler);\n }, [plugin]);\n\n return (\n <div\n {...props}\n style={{ position: 'relative', width: '100%', height: '100%', ...props.style }}\n ref={ref}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AACzC,+BAAiC;AAE1B,IAAM,gBAAgB,UAAM,wBAA4B,0CAAiB,EAAE;AAC3E,IAAM,0BAA0B,UAAM,4BAAgC,0CAAiB,EAAE;;;ACJhG,IAAAA,gBAAkC;AAqC9B;AA5BG,SAAS,mBAAmB,EAAE,UAAU,GAAG,MAAM,GAA4B;AAClF,QAAM,EAAE,UAAU,qBAAqB,IAAI,wBAAwB;AACnE,QAAM,EAAE,OAAO,IAAI,cAAc;AACjC,QAAM,UAAM,sBAAuB,IAAI;AAEvC,+BAAU,MAAM;AACd,QAAI,CAAC,qBAAsB;AAE3B,UAAM,QAAQ,qBAAqB,UAAU,OAAO,WAAW;AAC7D,UAAI,WAAW,SAAS;AACtB,cAAM,KAAK,IAAI;AACf,YAAI,MAAM,CAAC,SAAS,kBAAmB,OAAM,GAAG,kBAAkB;AAAA,MACpE,OAAO;AACL,YAAI,SAAS,kBAAmB,OAAM,SAAS,eAAe;AAAA,MAChE;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT,GAAG,CAAC,oBAAoB,CAAC;AAEzB,+BAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,UAAM,UAAU,MAAM,OAAO,mBAAmB,CAAC,CAAC,SAAS,iBAAiB;AAC5E,aAAS,iBAAiB,oBAAoB,OAAO;AACrD,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,OAAO;AAAA,EACvE,GAAG,CAAC,MAAM,CAAC;AAEX,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,EAAE,UAAU,YAAY,OAAO,QAAQ,QAAQ,QAAQ,GAAG,MAAM,MAAM;AAAA,MAC7E;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":["import_react"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _embedpdf_plugin_fullscreen from '@embedpdf/plugin-fullscreen';
|
|
2
|
+
import { FullscreenPlugin } from '@embedpdf/plugin-fullscreen';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
declare const useFullscreen: () => {
|
|
6
|
+
plugin: FullscreenPlugin | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
ready: Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
declare const useFullscreenCapability: () => {
|
|
11
|
+
provides: Readonly<_embedpdf_plugin_fullscreen.FullscreenCapability> | null;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
ready: Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type FullscreenProviderProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
};
|
|
20
|
+
declare function FullscreenProvider({ children, ...props }: FullscreenProviderProps): react_jsx_runtime.JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { FullscreenProvider, useFullscreen, useFullscreenCapability };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _embedpdf_plugin_fullscreen from '@embedpdf/plugin-fullscreen';
|
|
2
|
+
import { FullscreenPlugin } from '@embedpdf/plugin-fullscreen';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
declare const useFullscreen: () => {
|
|
6
|
+
plugin: FullscreenPlugin | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
ready: Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
declare const useFullscreenCapability: () => {
|
|
11
|
+
provides: Readonly<_embedpdf_plugin_fullscreen.FullscreenCapability> | null;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
ready: Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type FullscreenProviderProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
};
|
|
20
|
+
declare function FullscreenProvider({ children, ...props }: FullscreenProviderProps): react_jsx_runtime.JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { FullscreenProvider, useFullscreen, useFullscreenCapability };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/react/hooks/use-fullscreen.ts
|
|
2
|
+
import { useCapability, usePlugin } from "@embedpdf/core/react";
|
|
3
|
+
import { FullscreenPlugin } from "@embedpdf/plugin-fullscreen";
|
|
4
|
+
var useFullscreen = () => usePlugin(FullscreenPlugin.id);
|
|
5
|
+
var useFullscreenCapability = () => useCapability(FullscreenPlugin.id);
|
|
6
|
+
|
|
7
|
+
// src/react/components/fullscreen.tsx
|
|
8
|
+
import { useEffect, useRef } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
function FullscreenProvider({ children, ...props }) {
|
|
11
|
+
const { provides: fullscreenCapability } = useFullscreenCapability();
|
|
12
|
+
const { plugin } = useFullscreen();
|
|
13
|
+
const ref = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!fullscreenCapability) return;
|
|
16
|
+
const unsub = fullscreenCapability.onRequest(async (action) => {
|
|
17
|
+
if (action === "enter") {
|
|
18
|
+
const el = ref.current;
|
|
19
|
+
if (el && !document.fullscreenElement) await el.requestFullscreen();
|
|
20
|
+
} else {
|
|
21
|
+
if (document.fullscreenElement) await document.exitFullscreen();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return unsub;
|
|
25
|
+
}, [fullscreenCapability]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!plugin) return;
|
|
28
|
+
const handler = () => plugin.setFullscreenState(!!document.fullscreenElement);
|
|
29
|
+
document.addEventListener("fullscreenchange", handler);
|
|
30
|
+
return () => document.removeEventListener("fullscreenchange", handler);
|
|
31
|
+
}, [plugin]);
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
...props,
|
|
36
|
+
style: { position: "relative", width: "100%", height: "100%", ...props.style },
|
|
37
|
+
ref,
|
|
38
|
+
children
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
FullscreenProvider,
|
|
44
|
+
useFullscreen,
|
|
45
|
+
useFullscreenCapability
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/react/hooks/use-fullscreen.ts","../../src/react/components/fullscreen.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { FullscreenPlugin } from '@embedpdf/plugin-fullscreen';\n\nexport const useFullscreen = () => usePlugin<FullscreenPlugin>(FullscreenPlugin.id);\nexport const useFullscreenCapability = () => useCapability<FullscreenPlugin>(FullscreenPlugin.id);\n","import { useEffect, useRef } from 'react';\n\nimport { useFullscreen, useFullscreenCapability } from '../hooks';\n\ntype FullscreenProviderProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: React.ReactNode;\n style?: React.CSSProperties;\n};\n\nexport function FullscreenProvider({ children, ...props }: FullscreenProviderProps) {\n const { provides: fullscreenCapability } = useFullscreenCapability();\n const { plugin } = useFullscreen();\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!fullscreenCapability) return;\n\n const unsub = fullscreenCapability.onRequest(async (action) => {\n if (action === 'enter') {\n const el = ref.current;\n if (el && !document.fullscreenElement) await el.requestFullscreen();\n } else {\n if (document.fullscreenElement) await document.exitFullscreen();\n }\n });\n\n return unsub;\n }, [fullscreenCapability]);\n\n useEffect(() => {\n if (!plugin) return;\n const handler = () => plugin.setFullscreenState(!!document.fullscreenElement);\n document.addEventListener('fullscreenchange', handler);\n return () => document.removeEventListener('fullscreenchange', handler);\n }, [plugin]);\n\n return (\n <div\n {...props}\n style={{ position: 'relative', width: '100%', height: '100%', ...props.style }}\n ref={ref}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,wBAAwB;AAE1B,IAAM,gBAAgB,MAAM,UAA4B,iBAAiB,EAAE;AAC3E,IAAM,0BAA0B,MAAM,cAAgC,iBAAiB,EAAE;;;ACJhG,SAAS,WAAW,cAAc;AAqC9B;AA5BG,SAAS,mBAAmB,EAAE,UAAU,GAAG,MAAM,GAA4B;AAClF,QAAM,EAAE,UAAU,qBAAqB,IAAI,wBAAwB;AACnE,QAAM,EAAE,OAAO,IAAI,cAAc;AACjC,QAAM,MAAM,OAAuB,IAAI;AAEvC,YAAU,MAAM;AACd,QAAI,CAAC,qBAAsB;AAE3B,UAAM,QAAQ,qBAAqB,UAAU,OAAO,WAAW;AAC7D,UAAI,WAAW,SAAS;AACtB,cAAM,KAAK,IAAI;AACf,YAAI,MAAM,CAAC,SAAS,kBAAmB,OAAM,GAAG,kBAAkB;AAAA,MACpE,OAAO;AACL,YAAI,SAAS,kBAAmB,OAAM,SAAS,eAAe;AAAA,MAChE;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT,GAAG,CAAC,oBAAoB,CAAC;AAEzB,YAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,UAAM,UAAU,MAAM,OAAO,mBAAmB,CAAC,CAAC,SAAS,iBAAiB;AAC5E,aAAS,iBAAiB,oBAAoB,OAAO;AACrD,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,OAAO;AAAA,EACvE,GAAG,CAAC,MAAM,CAAC;AAEX,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,EAAE,UAAU,YAAY,OAAO,QAAQ,QAAQ,QAAQ,GAAG,MAAM,MAAM;AAAA,MAC7E;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@embedpdf/plugin-fullscreen",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./preact": {
|
|
15
|
+
"types": "./dist/preact/index.d.ts",
|
|
16
|
+
"import": "./dist/preact/index.js",
|
|
17
|
+
"require": "./dist/preact/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./react": {
|
|
20
|
+
"types": "./dist/react/index.d.ts",
|
|
21
|
+
"import": "./dist/react/index.js",
|
|
22
|
+
"require": "./dist/react/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/react": "^18.2.0",
|
|
28
|
+
"tsup": "^8.0.0",
|
|
29
|
+
"typescript": "^5.0.0",
|
|
30
|
+
"@embedpdf/plugin-loader": "1.0.0",
|
|
31
|
+
"@embedpdf/models": "1.0.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": ">=16.8.0",
|
|
35
|
+
"react-dom": ">=16.8.0",
|
|
36
|
+
"preact": "^10.26.4",
|
|
37
|
+
"@embedpdf/core": "1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md"
|
|
42
|
+
],
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/embedpdf/embed-pdf-viewer",
|
|
46
|
+
"directory": "packages/plugin-fullscreen"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://www.embedpdf.com/docs",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/embedpdf/embed-pdf-viewer/issues"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "PROJECT_CWD=$(pwd) pnpm -w p:build",
|
|
57
|
+
"build:watch": "PROJECT_CWD=$(pwd) pnpm -w p:build:watch",
|
|
58
|
+
"clean": "PROJECT_CWD=$(pwd) pnpm -w p:clean",
|
|
59
|
+
"lint": "PROJECT_CWD=$(pwd) pnpm -w p:lint",
|
|
60
|
+
"lint:fix": "PROJECT_CWD=$(pwd) pnpm -w p:lint:fix",
|
|
61
|
+
"typecheck": "PROJECT_CWD=$(pwd) pnpm -w p:typecheck"
|
|
62
|
+
}
|
|
63
|
+
}
|