@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 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 buildEmbedUrl = ({ operation = "iframe", storeUrl }) => {
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 = "iframe", storeUrl }) => {
50
- const operationPath = operation.startsWith("/") ? operation.slice(1) : operation;
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 = "iframe",
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?: string;
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?: string;
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?: string;
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?: string;
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 buildEmbedUrl = ({ operation = "iframe", storeUrl }) => {
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 = "iframe", storeUrl }) => {
10
- const operationPath = operation.startsWith("/") ? operation.slice(1) : operation;
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 = "iframe",
30
+ operation,
24
31
  storeUrl,
25
32
  showIframe = false,
26
33
  className,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playruo/embed",
3
- "version": "1.2.10",
3
+ "version": "1.3.0",
4
4
  "description": "React SDK to embed Playruo with postMessage API.",
5
5
  "license": "MIT",
6
6
  "type": "module",