@playruo/embed 1.2.10 → 1.3.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/dist/index.cjs +11 -4
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +11 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,11 +43,18 @@ var import_react = require("react");
|
|
|
43
43
|
|
|
44
44
|
// src/url.ts
|
|
45
45
|
var PLAYRUO_ORIGIN = "https://playruo.live";
|
|
46
|
-
var
|
|
46
|
+
var normalizeOperation = (operation) => {
|
|
47
|
+
const trimmedOperation = operation.trim();
|
|
48
|
+
if (trimmedOperation === "") {
|
|
49
|
+
throw new Error("`operation` is required to build a Playruo embed URL.");
|
|
50
|
+
}
|
|
51
|
+
return trimmedOperation.startsWith("/") ? trimmedOperation.slice(1) : trimmedOperation;
|
|
52
|
+
};
|
|
53
|
+
var buildEmbedUrl = ({ operation, storeUrl }) => {
|
|
47
54
|
return buildEmbedUrlWithOrigin(PLAYRUO_ORIGIN, { operation, storeUrl });
|
|
48
55
|
};
|
|
49
|
-
var buildEmbedUrlWithOrigin = (origin, { operation
|
|
50
|
-
const operationPath =
|
|
56
|
+
var buildEmbedUrlWithOrigin = (origin, { operation, storeUrl }) => {
|
|
57
|
+
const operationPath = normalizeOperation(operation);
|
|
51
58
|
const url = new URL(`/${operationPath}`, origin);
|
|
52
59
|
url.searchParams.set("iframe", "true");
|
|
53
60
|
if (storeUrl) {
|
|
@@ -60,7 +67,7 @@ var buildEmbedUrlWithOrigin = (origin, { operation = "iframe", storeUrl }) => {
|
|
|
60
67
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
61
68
|
var PlayruoEmbed = ({
|
|
62
69
|
baseUrl,
|
|
63
|
-
operation
|
|
70
|
+
operation,
|
|
64
71
|
storeUrl,
|
|
65
72
|
showIframe = false,
|
|
66
73
|
className,
|
package/dist/index.d.cts
CHANGED
|
@@ -36,7 +36,8 @@ interface PlayruoEmbedRenderState {
|
|
|
36
36
|
interface PlayruoEmbedProps {
|
|
37
37
|
/** Game origin (scheme + host). Omit to use production (`https://playruo.live`). */
|
|
38
38
|
baseUrl?: string;
|
|
39
|
-
operation
|
|
39
|
+
/** Game operation slug used to build the iframe URL. */
|
|
40
|
+
operation: string;
|
|
40
41
|
storeUrl?: string;
|
|
41
42
|
showIframe?: boolean;
|
|
42
43
|
className?: string;
|
|
@@ -124,7 +125,7 @@ declare const isPlayruoEmbedMessage: (data: unknown) => data is PlayruoEmbedMess
|
|
|
124
125
|
declare const isPlayruoInternalMessage: (data: unknown) => data is PlayruoInternalMessage;
|
|
125
126
|
|
|
126
127
|
interface BuildUrlParams {
|
|
127
|
-
operation
|
|
128
|
+
operation: string;
|
|
128
129
|
storeUrl?: string;
|
|
129
130
|
}
|
|
130
131
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -36,7 +36,8 @@ interface PlayruoEmbedRenderState {
|
|
|
36
36
|
interface PlayruoEmbedProps {
|
|
37
37
|
/** Game origin (scheme + host). Omit to use production (`https://playruo.live`). */
|
|
38
38
|
baseUrl?: string;
|
|
39
|
-
operation
|
|
39
|
+
/** Game operation slug used to build the iframe URL. */
|
|
40
|
+
operation: string;
|
|
40
41
|
storeUrl?: string;
|
|
41
42
|
showIframe?: boolean;
|
|
42
43
|
className?: string;
|
|
@@ -124,7 +125,7 @@ declare const isPlayruoEmbedMessage: (data: unknown) => data is PlayruoEmbedMess
|
|
|
124
125
|
declare const isPlayruoInternalMessage: (data: unknown) => data is PlayruoInternalMessage;
|
|
125
126
|
|
|
126
127
|
interface BuildUrlParams {
|
|
127
|
-
operation
|
|
128
|
+
operation: string;
|
|
128
129
|
storeUrl?: string;
|
|
129
130
|
}
|
|
130
131
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,18 @@ import { useEffect, useMemo, useRef, useState, useCallback } from "react";
|
|
|
3
3
|
|
|
4
4
|
// src/url.ts
|
|
5
5
|
var PLAYRUO_ORIGIN = "https://playruo.live";
|
|
6
|
-
var
|
|
6
|
+
var normalizeOperation = (operation) => {
|
|
7
|
+
const trimmedOperation = operation.trim();
|
|
8
|
+
if (trimmedOperation === "") {
|
|
9
|
+
throw new Error("`operation` is required to build a Playruo embed URL.");
|
|
10
|
+
}
|
|
11
|
+
return trimmedOperation.startsWith("/") ? trimmedOperation.slice(1) : trimmedOperation;
|
|
12
|
+
};
|
|
13
|
+
var buildEmbedUrl = ({ operation, storeUrl }) => {
|
|
7
14
|
return buildEmbedUrlWithOrigin(PLAYRUO_ORIGIN, { operation, storeUrl });
|
|
8
15
|
};
|
|
9
|
-
var buildEmbedUrlWithOrigin = (origin, { operation
|
|
10
|
-
const operationPath =
|
|
16
|
+
var buildEmbedUrlWithOrigin = (origin, { operation, storeUrl }) => {
|
|
17
|
+
const operationPath = normalizeOperation(operation);
|
|
11
18
|
const url = new URL(`/${operationPath}`, origin);
|
|
12
19
|
url.searchParams.set("iframe", "true");
|
|
13
20
|
if (storeUrl) {
|
|
@@ -20,7 +27,7 @@ var buildEmbedUrlWithOrigin = (origin, { operation = "iframe", storeUrl }) => {
|
|
|
20
27
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
28
|
var PlayruoEmbed = ({
|
|
22
29
|
baseUrl,
|
|
23
|
-
operation
|
|
30
|
+
operation,
|
|
24
31
|
storeUrl,
|
|
25
32
|
showIframe = false,
|
|
26
33
|
className,
|