@playruo/embed 1.1.4 → 1.1.5
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/index.cjs +37 -3
- package/dist/index.js +37 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -60,6 +60,26 @@ var PlayruoEmbed = ({
|
|
|
60
60
|
const [state, setState] = (0, import_react.useState)(null);
|
|
61
61
|
const [errorMessage, setErrorMessage] = (0, import_react.useState)(null);
|
|
62
62
|
const src = (0, import_react.useMemo)(() => buildEmbedUrl({ baseUrl, operation, storeUrl }), [baseUrl, operation, storeUrl]);
|
|
63
|
+
const checkKeyboardLockPermission = async () => {
|
|
64
|
+
if (!navigator.permissions) {
|
|
65
|
+
console.log("[PlayruoEmbed] Permissions API not supported");
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const { state: state2 } = await navigator.permissions.query({
|
|
70
|
+
name: "keyboard-lock"
|
|
71
|
+
});
|
|
72
|
+
if (state2 === "granted" || state2 === "prompt") {
|
|
73
|
+
console.log(`[PlayruoEmbed] Keyboard lock permission: ${state2}`);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
console.log("[PlayruoEmbed] Keyboard lock permission denied");
|
|
77
|
+
return false;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.warn("[PlayruoEmbed] Error checking keyboard lock permission:", error);
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
63
83
|
const requestFullscreenWithKeyboardLock = async () => {
|
|
64
84
|
const iframe = iframeRef.current;
|
|
65
85
|
if (!iframe?.requestFullscreen) {
|
|
@@ -69,11 +89,17 @@ var PlayruoEmbed = ({
|
|
|
69
89
|
try {
|
|
70
90
|
const fullscreenPromise = iframe.requestFullscreen();
|
|
71
91
|
if (navigator.keyboard) {
|
|
72
|
-
|
|
73
|
-
|
|
92
|
+
const permissionPromise = checkKeyboardLockPermission();
|
|
93
|
+
const keyboardLockPromise = navigator.keyboard.lock(["Escape"]);
|
|
94
|
+
void Promise.all([permissionPromise, keyboardLockPromise]).then(([hasPermission]) => {
|
|
95
|
+
if (hasPermission) {
|
|
96
|
+
console.log("[PlayruoEmbed] Keyboard locked successfully");
|
|
97
|
+
}
|
|
74
98
|
}).catch((err) => {
|
|
75
99
|
console.warn("[PlayruoEmbed] Keyboard lock failed:", err);
|
|
76
100
|
});
|
|
101
|
+
} else {
|
|
102
|
+
console.log("[PlayruoEmbed] Keyboard API not supported");
|
|
77
103
|
}
|
|
78
104
|
void fullscreenPromise.then(() => {
|
|
79
105
|
console.log("[PlayruoEmbed] Fullscreen activated successfully");
|
|
@@ -96,6 +122,13 @@ var PlayruoEmbed = ({
|
|
|
96
122
|
}
|
|
97
123
|
iframeRef.current.contentWindow.postMessage({ type }, "*");
|
|
98
124
|
};
|
|
125
|
+
(0, import_react.useEffect)(() => {
|
|
126
|
+
if (!self.crossOriginIsolated) {
|
|
127
|
+
console.warn(
|
|
128
|
+
'[PlayruoEmbed] \u26A0\uFE0F Not in a cross-origin isolated context.\nSharedArrayBuffer and high-precision timers may not work.\n\nAdd these headers to your server:\n Cross-Origin-Opener-Policy: same-origin\n Cross-Origin-Embedder-Policy: credentialless\n\nAlternative (stricter, if not using credentialless iframes):\n Cross-Origin-Embedder-Policy: require-corp\n\nFor Next.js, add to next.config.js:\n async headers() {\n return [{\n source: "/:path*",\n headers: [\n { key: "Cross-Origin-Opener-Policy", value: "same-origin" },\n { key: "Cross-Origin-Embedder-Policy", value: "credentialless" }\n ]\n }];\n }'
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}, []);
|
|
99
132
|
(0, import_react.useEffect)(() => {
|
|
100
133
|
const handler = (event) => {
|
|
101
134
|
const msg = event?.data ?? {};
|
|
@@ -148,8 +181,9 @@ var PlayruoEmbed = ({
|
|
|
148
181
|
{
|
|
149
182
|
ref: iframeRef,
|
|
150
183
|
src,
|
|
151
|
-
allow: "fullscreen *; autoplay *; gamepad *",
|
|
184
|
+
allow: "fullscreen *; autoplay *; gamepad *; clipboard-write *; web-share *; encrypted-media *; accelerometer *; gyroscope *",
|
|
152
185
|
className: "w-full h-[70vh] rounded-lg border",
|
|
186
|
+
...{ credentialless: "true" },
|
|
153
187
|
title: "Playruo",
|
|
154
188
|
style: {
|
|
155
189
|
position: showIframe ? void 0 : "absolute",
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,26 @@ var PlayruoEmbed = ({
|
|
|
31
31
|
const [state, setState] = useState(null);
|
|
32
32
|
const [errorMessage, setErrorMessage] = useState(null);
|
|
33
33
|
const src = useMemo(() => buildEmbedUrl({ baseUrl, operation, storeUrl }), [baseUrl, operation, storeUrl]);
|
|
34
|
+
const checkKeyboardLockPermission = async () => {
|
|
35
|
+
if (!navigator.permissions) {
|
|
36
|
+
console.log("[PlayruoEmbed] Permissions API not supported");
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const { state: state2 } = await navigator.permissions.query({
|
|
41
|
+
name: "keyboard-lock"
|
|
42
|
+
});
|
|
43
|
+
if (state2 === "granted" || state2 === "prompt") {
|
|
44
|
+
console.log(`[PlayruoEmbed] Keyboard lock permission: ${state2}`);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
console.log("[PlayruoEmbed] Keyboard lock permission denied");
|
|
48
|
+
return false;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.warn("[PlayruoEmbed] Error checking keyboard lock permission:", error);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
34
54
|
const requestFullscreenWithKeyboardLock = async () => {
|
|
35
55
|
const iframe = iframeRef.current;
|
|
36
56
|
if (!iframe?.requestFullscreen) {
|
|
@@ -40,11 +60,17 @@ var PlayruoEmbed = ({
|
|
|
40
60
|
try {
|
|
41
61
|
const fullscreenPromise = iframe.requestFullscreen();
|
|
42
62
|
if (navigator.keyboard) {
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
const permissionPromise = checkKeyboardLockPermission();
|
|
64
|
+
const keyboardLockPromise = navigator.keyboard.lock(["Escape"]);
|
|
65
|
+
void Promise.all([permissionPromise, keyboardLockPromise]).then(([hasPermission]) => {
|
|
66
|
+
if (hasPermission) {
|
|
67
|
+
console.log("[PlayruoEmbed] Keyboard locked successfully");
|
|
68
|
+
}
|
|
45
69
|
}).catch((err) => {
|
|
46
70
|
console.warn("[PlayruoEmbed] Keyboard lock failed:", err);
|
|
47
71
|
});
|
|
72
|
+
} else {
|
|
73
|
+
console.log("[PlayruoEmbed] Keyboard API not supported");
|
|
48
74
|
}
|
|
49
75
|
void fullscreenPromise.then(() => {
|
|
50
76
|
console.log("[PlayruoEmbed] Fullscreen activated successfully");
|
|
@@ -67,6 +93,13 @@ var PlayruoEmbed = ({
|
|
|
67
93
|
}
|
|
68
94
|
iframeRef.current.contentWindow.postMessage({ type }, "*");
|
|
69
95
|
};
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!self.crossOriginIsolated) {
|
|
98
|
+
console.warn(
|
|
99
|
+
'[PlayruoEmbed] \u26A0\uFE0F Not in a cross-origin isolated context.\nSharedArrayBuffer and high-precision timers may not work.\n\nAdd these headers to your server:\n Cross-Origin-Opener-Policy: same-origin\n Cross-Origin-Embedder-Policy: credentialless\n\nAlternative (stricter, if not using credentialless iframes):\n Cross-Origin-Embedder-Policy: require-corp\n\nFor Next.js, add to next.config.js:\n async headers() {\n return [{\n source: "/:path*",\n headers: [\n { key: "Cross-Origin-Opener-Policy", value: "same-origin" },\n { key: "Cross-Origin-Embedder-Policy", value: "credentialless" }\n ]\n }];\n }'
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
70
103
|
useEffect(() => {
|
|
71
104
|
const handler = (event) => {
|
|
72
105
|
const msg = event?.data ?? {};
|
|
@@ -119,8 +152,9 @@ var PlayruoEmbed = ({
|
|
|
119
152
|
{
|
|
120
153
|
ref: iframeRef,
|
|
121
154
|
src,
|
|
122
|
-
allow: "fullscreen *; autoplay *; gamepad *",
|
|
155
|
+
allow: "fullscreen *; autoplay *; gamepad *; clipboard-write *; web-share *; encrypted-media *; accelerometer *; gyroscope *",
|
|
123
156
|
className: "w-full h-[70vh] rounded-lg border",
|
|
157
|
+
...{ credentialless: "true" },
|
|
124
158
|
title: "Playruo",
|
|
125
159
|
style: {
|
|
126
160
|
position: showIframe ? void 0 : "absolute",
|