@playruo/embed 1.2.4 → 1.2.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 +30 -7
- package/dist/index.js +30 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -110,6 +110,18 @@ var PlayruoEmbed = ({
|
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
}, [hasPlayedOnce, isCompatible, iframeState]);
|
|
113
|
+
const hasIframeConfirmed = Boolean(iframeState?.tryNow?.available === true);
|
|
114
|
+
const exposedState = (0, import_react.useMemo)(
|
|
115
|
+
() => ({
|
|
116
|
+
...currentState,
|
|
117
|
+
tryNow: {
|
|
118
|
+
...currentState.tryNow,
|
|
119
|
+
available: hasIframeConfirmed,
|
|
120
|
+
status: currentState.tryNow.status ?? (hasIframeConfirmed ? "Ready" : isCompatible ? "Checking availability\u2026" : "Browser not compatible")
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
[currentState, hasIframeConfirmed, isCompatible]
|
|
124
|
+
);
|
|
113
125
|
const handleTryNow = (0, import_react.useCallback)(() => {
|
|
114
126
|
if (!isCompatible) {
|
|
115
127
|
console.warn("[PlayruoEmbed] Browser not compatible");
|
|
@@ -156,9 +168,9 @@ var PlayruoEmbed = ({
|
|
|
156
168
|
}, [storeUrl, onPurchaseRequest]);
|
|
157
169
|
(0, import_react.useEffect)(() => {
|
|
158
170
|
if (isReady) {
|
|
159
|
-
onStateChange?.(
|
|
171
|
+
onStateChange?.(exposedState);
|
|
160
172
|
}
|
|
161
|
-
}, [isReady,
|
|
173
|
+
}, [isReady, exposedState, onStateChange]);
|
|
162
174
|
(0, import_react.useEffect)(() => {
|
|
163
175
|
if (isReady) {
|
|
164
176
|
onReady?.();
|
|
@@ -394,22 +406,28 @@ var PlayruoEmbed = ({
|
|
|
394
406
|
logCrossOriginStatus();
|
|
395
407
|
}
|
|
396
408
|
}, [isReady]);
|
|
397
|
-
const isAvailable = Boolean(isReady && isCompatible);
|
|
409
|
+
const isAvailable = Boolean(isReady && isCompatible && hasIframeConfirmed);
|
|
398
410
|
const renderContent = () => {
|
|
399
411
|
if (!renderState) return null;
|
|
412
|
+
const canTryNow = Boolean(
|
|
413
|
+
!errorMessage && isReady && isCompatible && hasIframeConfirmed
|
|
414
|
+
);
|
|
400
415
|
const actions = {
|
|
401
416
|
tryNow: handleTryNow,
|
|
402
417
|
buyNow: handleBuyNow,
|
|
403
|
-
canTryNow
|
|
418
|
+
canTryNow,
|
|
404
419
|
canBuyNow: Boolean(isReady)
|
|
405
420
|
};
|
|
406
421
|
if (errorMessage) {
|
|
407
422
|
return renderState({ status: "error", message: errorMessage, actions });
|
|
408
423
|
}
|
|
409
424
|
if (!isReady) {
|
|
410
|
-
return renderState({ status: "loading", actions });
|
|
425
|
+
return renderState({ status: "loading", message: "Loading\u2026", actions });
|
|
411
426
|
}
|
|
412
|
-
|
|
427
|
+
if (isCompatible && !iframeState) {
|
|
428
|
+
return renderState({ status: "loading", message: "Checking availability\u2026", actions });
|
|
429
|
+
}
|
|
430
|
+
const message = !isAvailable ? currentState.tryNow.status ?? exposedState.tryNow.status : void 0;
|
|
413
431
|
return renderState({
|
|
414
432
|
status: isAvailable ? "available" : "unavailable",
|
|
415
433
|
message,
|
|
@@ -642,6 +660,10 @@ var EmbedTester = (props = {}) => {
|
|
|
642
660
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: embedState.hasPlayedOnce ? successStatus : errorStatus, children: embedState.hasPlayedOnce ? "\u2705 Played" : "\u274C Not Played" }),
|
|
643
661
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: embedState.tryNow?.available ? successStatus : errorStatus, children: embedState.tryNow?.available ? "\u2705 Try Now" : "\u274C Try Now" }),
|
|
644
662
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: embedState.buyNow?.available ? successStatus : errorStatus, children: embedState.buyNow?.available ? "\u2705 Buy Now" : "\u274C Buy Now" })
|
|
663
|
+
] }),
|
|
664
|
+
!embedState.tryNow?.available && embedState.tryNow?.status && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { style: { margin: "8px 0 0 0", fontSize: "12px", color: "#a3a3a3" }, children: [
|
|
665
|
+
"Try Now reason: ",
|
|
666
|
+
embedState.tryNow.status
|
|
645
667
|
] })
|
|
646
668
|
] }),
|
|
647
669
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: cardStyle, children: [
|
|
@@ -671,7 +693,8 @@ var EmbedTester = (props = {}) => {
|
|
|
671
693
|
backgroundColor: "#0a0a0a",
|
|
672
694
|
padding: "12px",
|
|
673
695
|
borderRadius: "4px",
|
|
674
|
-
|
|
696
|
+
minHeight: "200px",
|
|
697
|
+
height: "min(50vh, 480px)",
|
|
675
698
|
overflowY: "auto",
|
|
676
699
|
fontFamily: "monospace",
|
|
677
700
|
fontSize: "12px",
|
package/dist/index.js
CHANGED
|
@@ -70,6 +70,18 @@ var PlayruoEmbed = ({
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}, [hasPlayedOnce, isCompatible, iframeState]);
|
|
73
|
+
const hasIframeConfirmed = Boolean(iframeState?.tryNow?.available === true);
|
|
74
|
+
const exposedState = useMemo(
|
|
75
|
+
() => ({
|
|
76
|
+
...currentState,
|
|
77
|
+
tryNow: {
|
|
78
|
+
...currentState.tryNow,
|
|
79
|
+
available: hasIframeConfirmed,
|
|
80
|
+
status: currentState.tryNow.status ?? (hasIframeConfirmed ? "Ready" : isCompatible ? "Checking availability\u2026" : "Browser not compatible")
|
|
81
|
+
}
|
|
82
|
+
}),
|
|
83
|
+
[currentState, hasIframeConfirmed, isCompatible]
|
|
84
|
+
);
|
|
73
85
|
const handleTryNow = useCallback(() => {
|
|
74
86
|
if (!isCompatible) {
|
|
75
87
|
console.warn("[PlayruoEmbed] Browser not compatible");
|
|
@@ -116,9 +128,9 @@ var PlayruoEmbed = ({
|
|
|
116
128
|
}, [storeUrl, onPurchaseRequest]);
|
|
117
129
|
useEffect(() => {
|
|
118
130
|
if (isReady) {
|
|
119
|
-
onStateChange?.(
|
|
131
|
+
onStateChange?.(exposedState);
|
|
120
132
|
}
|
|
121
|
-
}, [isReady,
|
|
133
|
+
}, [isReady, exposedState, onStateChange]);
|
|
122
134
|
useEffect(() => {
|
|
123
135
|
if (isReady) {
|
|
124
136
|
onReady?.();
|
|
@@ -354,22 +366,28 @@ var PlayruoEmbed = ({
|
|
|
354
366
|
logCrossOriginStatus();
|
|
355
367
|
}
|
|
356
368
|
}, [isReady]);
|
|
357
|
-
const isAvailable = Boolean(isReady && isCompatible);
|
|
369
|
+
const isAvailable = Boolean(isReady && isCompatible && hasIframeConfirmed);
|
|
358
370
|
const renderContent = () => {
|
|
359
371
|
if (!renderState) return null;
|
|
372
|
+
const canTryNow = Boolean(
|
|
373
|
+
!errorMessage && isReady && isCompatible && hasIframeConfirmed
|
|
374
|
+
);
|
|
360
375
|
const actions = {
|
|
361
376
|
tryNow: handleTryNow,
|
|
362
377
|
buyNow: handleBuyNow,
|
|
363
|
-
canTryNow
|
|
378
|
+
canTryNow,
|
|
364
379
|
canBuyNow: Boolean(isReady)
|
|
365
380
|
};
|
|
366
381
|
if (errorMessage) {
|
|
367
382
|
return renderState({ status: "error", message: errorMessage, actions });
|
|
368
383
|
}
|
|
369
384
|
if (!isReady) {
|
|
370
|
-
return renderState({ status: "loading", actions });
|
|
385
|
+
return renderState({ status: "loading", message: "Loading\u2026", actions });
|
|
371
386
|
}
|
|
372
|
-
|
|
387
|
+
if (isCompatible && !iframeState) {
|
|
388
|
+
return renderState({ status: "loading", message: "Checking availability\u2026", actions });
|
|
389
|
+
}
|
|
390
|
+
const message = !isAvailable ? currentState.tryNow.status ?? exposedState.tryNow.status : void 0;
|
|
373
391
|
return renderState({
|
|
374
392
|
status: isAvailable ? "available" : "unavailable",
|
|
375
393
|
message,
|
|
@@ -602,6 +620,10 @@ var EmbedTester = (props = {}) => {
|
|
|
602
620
|
/* @__PURE__ */ jsx2("span", { style: embedState.hasPlayedOnce ? successStatus : errorStatus, children: embedState.hasPlayedOnce ? "\u2705 Played" : "\u274C Not Played" }),
|
|
603
621
|
/* @__PURE__ */ jsx2("span", { style: embedState.tryNow?.available ? successStatus : errorStatus, children: embedState.tryNow?.available ? "\u2705 Try Now" : "\u274C Try Now" }),
|
|
604
622
|
/* @__PURE__ */ jsx2("span", { style: embedState.buyNow?.available ? successStatus : errorStatus, children: embedState.buyNow?.available ? "\u2705 Buy Now" : "\u274C Buy Now" })
|
|
623
|
+
] }),
|
|
624
|
+
!embedState.tryNow?.available && embedState.tryNow?.status && /* @__PURE__ */ jsxs2("p", { style: { margin: "8px 0 0 0", fontSize: "12px", color: "#a3a3a3" }, children: [
|
|
625
|
+
"Try Now reason: ",
|
|
626
|
+
embedState.tryNow.status
|
|
605
627
|
] })
|
|
606
628
|
] }),
|
|
607
629
|
/* @__PURE__ */ jsxs2("div", { style: cardStyle, children: [
|
|
@@ -631,7 +653,8 @@ var EmbedTester = (props = {}) => {
|
|
|
631
653
|
backgroundColor: "#0a0a0a",
|
|
632
654
|
padding: "12px",
|
|
633
655
|
borderRadius: "4px",
|
|
634
|
-
|
|
656
|
+
minHeight: "200px",
|
|
657
|
+
height: "min(50vh, 480px)",
|
|
635
658
|
overflowY: "auto",
|
|
636
659
|
fontFamily: "monospace",
|
|
637
660
|
fontSize: "12px",
|