@playruo/embed 1.1.3 → 1.1.4

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 CHANGED
@@ -51,18 +51,49 @@ var PlayruoEmbed = ({
51
51
  onDemoCompleted,
52
52
  onPurchaseRequest,
53
53
  onError,
54
- renderState
54
+ renderState,
55
+ iframeRef: externalIframeRef
55
56
  }) => {
56
- const iframeRef = (0, import_react.useRef)(null);
57
+ const internalIframeRef = (0, import_react.useRef)(null);
58
+ const iframeRef = externalIframeRef || internalIframeRef;
57
59
  const [isReady, setIsReady] = (0, import_react.useState)(false);
58
60
  const [state, setState] = (0, import_react.useState)(null);
59
61
  const [errorMessage, setErrorMessage] = (0, import_react.useState)(null);
60
62
  const src = (0, import_react.useMemo)(() => buildEmbedUrl({ baseUrl, operation, storeUrl }), [baseUrl, operation, storeUrl]);
63
+ const requestFullscreenWithKeyboardLock = async () => {
64
+ const iframe = iframeRef.current;
65
+ if (!iframe?.requestFullscreen) {
66
+ console.log("[PlayruoEmbed] Fullscreen not supported on this browser");
67
+ return false;
68
+ }
69
+ try {
70
+ const fullscreenPromise = iframe.requestFullscreen();
71
+ if (navigator.keyboard) {
72
+ navigator.keyboard.lock(["Escape"]).then(() => {
73
+ console.log("[PlayruoEmbed] Keyboard locked successfully");
74
+ }).catch((err) => {
75
+ console.warn("[PlayruoEmbed] Keyboard lock failed:", err);
76
+ });
77
+ }
78
+ void fullscreenPromise.then(() => {
79
+ console.log("[PlayruoEmbed] Fullscreen activated successfully");
80
+ }).catch((err) => {
81
+ console.warn("[PlayruoEmbed] Fullscreen failed:", err);
82
+ });
83
+ return true;
84
+ } catch (error) {
85
+ console.error("[PlayruoEmbed] Error requesting fullscreen:", error);
86
+ return false;
87
+ }
88
+ };
61
89
  const sendCommand = (type) => {
62
90
  if (!iframeRef.current?.contentWindow) {
63
91
  console.warn(`PlayruoEmbed: Cannot send ${type} command, iframe not ready`);
64
92
  return;
65
93
  }
94
+ if (type === "try_now") {
95
+ requestFullscreenWithKeyboardLock();
96
+ }
66
97
  iframeRef.current.contentWindow.postMessage({ type }, "*");
67
98
  };
68
99
  (0, import_react.useEffect)(() => {
package/dist/index.d.cts CHANGED
@@ -16,6 +16,15 @@ interface DemoCompletedPayload {
16
16
  storeUrl?: string;
17
17
  }
18
18
 
19
+ interface Keyboard {
20
+ lock: (keys: string[]) => Promise<void>;
21
+ unlock: () => void;
22
+ }
23
+ declare global {
24
+ interface Navigator {
25
+ keyboard?: Keyboard;
26
+ }
27
+ }
19
28
  interface PlayruoEmbedActions {
20
29
  /** Start the demo session */
21
30
  tryNow: () => void;
@@ -49,6 +58,10 @@ interface PlayruoEmbedProps {
49
58
  * Provides status, message, and available actions based on current state.
50
59
  */
51
60
  renderState?: (render: PlayruoEmbedRenderState) => ReactNode;
61
+ /**
62
+ * Ref to access the iframe element for fullscreen requests
63
+ */
64
+ iframeRef?: React.RefObject<HTMLIFrameElement>;
52
65
  }
53
66
  declare const PlayruoEmbed: FC<PlayruoEmbedProps>;
54
67
 
package/dist/index.d.ts CHANGED
@@ -16,6 +16,15 @@ interface DemoCompletedPayload {
16
16
  storeUrl?: string;
17
17
  }
18
18
 
19
+ interface Keyboard {
20
+ lock: (keys: string[]) => Promise<void>;
21
+ unlock: () => void;
22
+ }
23
+ declare global {
24
+ interface Navigator {
25
+ keyboard?: Keyboard;
26
+ }
27
+ }
19
28
  interface PlayruoEmbedActions {
20
29
  /** Start the demo session */
21
30
  tryNow: () => void;
@@ -49,6 +58,10 @@ interface PlayruoEmbedProps {
49
58
  * Provides status, message, and available actions based on current state.
50
59
  */
51
60
  renderState?: (render: PlayruoEmbedRenderState) => ReactNode;
61
+ /**
62
+ * Ref to access the iframe element for fullscreen requests
63
+ */
64
+ iframeRef?: React.RefObject<HTMLIFrameElement>;
52
65
  }
53
66
  declare const PlayruoEmbed: FC<PlayruoEmbedProps>;
54
67
 
package/dist/index.js CHANGED
@@ -22,18 +22,49 @@ var PlayruoEmbed = ({
22
22
  onDemoCompleted,
23
23
  onPurchaseRequest,
24
24
  onError,
25
- renderState
25
+ renderState,
26
+ iframeRef: externalIframeRef
26
27
  }) => {
27
- const iframeRef = useRef(null);
28
+ const internalIframeRef = useRef(null);
29
+ const iframeRef = externalIframeRef || internalIframeRef;
28
30
  const [isReady, setIsReady] = useState(false);
29
31
  const [state, setState] = useState(null);
30
32
  const [errorMessage, setErrorMessage] = useState(null);
31
33
  const src = useMemo(() => buildEmbedUrl({ baseUrl, operation, storeUrl }), [baseUrl, operation, storeUrl]);
34
+ const requestFullscreenWithKeyboardLock = async () => {
35
+ const iframe = iframeRef.current;
36
+ if (!iframe?.requestFullscreen) {
37
+ console.log("[PlayruoEmbed] Fullscreen not supported on this browser");
38
+ return false;
39
+ }
40
+ try {
41
+ const fullscreenPromise = iframe.requestFullscreen();
42
+ if (navigator.keyboard) {
43
+ navigator.keyboard.lock(["Escape"]).then(() => {
44
+ console.log("[PlayruoEmbed] Keyboard locked successfully");
45
+ }).catch((err) => {
46
+ console.warn("[PlayruoEmbed] Keyboard lock failed:", err);
47
+ });
48
+ }
49
+ void fullscreenPromise.then(() => {
50
+ console.log("[PlayruoEmbed] Fullscreen activated successfully");
51
+ }).catch((err) => {
52
+ console.warn("[PlayruoEmbed] Fullscreen failed:", err);
53
+ });
54
+ return true;
55
+ } catch (error) {
56
+ console.error("[PlayruoEmbed] Error requesting fullscreen:", error);
57
+ return false;
58
+ }
59
+ };
32
60
  const sendCommand = (type) => {
33
61
  if (!iframeRef.current?.contentWindow) {
34
62
  console.warn(`PlayruoEmbed: Cannot send ${type} command, iframe not ready`);
35
63
  return;
36
64
  }
65
+ if (type === "try_now") {
66
+ requestFullscreenWithKeyboardLock();
67
+ }
37
68
  iframeRef.current.contentWindow.postMessage({ type }, "*");
38
69
  };
39
70
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playruo/embed",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "React SDK to embed Playruo with postMessage API.",
5
5
  "license": "MIT",
6
6
  "type": "module",