@wvdsh/sdk-js 0.0.34 → 0.0.36

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5075,7 +5075,8 @@ var WavedashSDK = (() => {
5075
5075
  GET_SDK_CONFIG: "GetSDKConfig",
5076
5076
  PROGRESS_UPDATE: "ProgressUpdate",
5077
5077
  LOADING_COMPLETE: "LoadingComplete",
5078
- TOGGLE_OVERLAY: "ToggleOverlay"
5078
+ TOGGLE_OVERLAY: "ToggleOverlay",
5079
+ TAKE_FOCUS: "TakeFocus"
5079
5080
  };
5080
5081
 
5081
5082
  // node_modules/convex/dist/esm/server/pagination.js
@@ -7449,6 +7450,20 @@ var WavedashSDK = (() => {
7449
7450
  this.pendingRequests.delete(event.data.requestId);
7450
7451
  pending.resolve(event.data.data);
7451
7452
  }
7453
+ } else if (event.data?.type === IFRAME_MESSAGE_TYPE.TAKE_FOCUS) {
7454
+ if (typeof document !== "undefined") {
7455
+ const gameFocusTargets = document.getElementsByClassName("game-focus-target");
7456
+ if (gameFocusTargets.length > 0) {
7457
+ gameFocusTargets[0].focus();
7458
+ } else {
7459
+ const focusableElement = document.querySelector(
7460
+ "canvas, input, button, [tabindex]:not([tabindex='-1'])"
7461
+ );
7462
+ if (focusableElement) {
7463
+ focusableElement.focus();
7464
+ }
7465
+ }
7466
+ }
7452
7467
  }
7453
7468
  };
7454
7469
  this.pendingRequests = /* @__PURE__ */ new Map();
@@ -7460,15 +7475,15 @@ var WavedashSDK = (() => {
7460
7475
  }
7461
7476
  /**
7462
7477
  * Derive parent origin from iframe URL pattern
7463
- * iframe: [gameSlug].builds.[parentDomain]
7478
+ * iframe: [gameSlug].builds.[parentDomain] or [gameSlug].sandbox.[parentDomain]
7464
7479
  * parent: [parentDomain]
7465
7480
  */
7466
7481
  deriveParentOrigin() {
7467
7482
  if (typeof window === "undefined") return "";
7468
7483
  const iframeHost = window.location.hostname;
7469
- const match = iframeHost.match(/^[\w-]+\.builds\.(.+)$/);
7484
+ const match = iframeHost.match(/^[\w-]+\.(builds|sandbox)\.(.+)$/);
7470
7485
  if (match) {
7471
- const parentDomain = match[1];
7486
+ const parentDomain = match[2];
7472
7487
  return `${window.location.protocol}//${parentDomain}`;
7473
7488
  }
7474
7489
  console.error(`Invalid iframe hostname pattern: ${iframeHost}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wvdsh/sdk-js",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "description": "Wavedash JavaScript SDK",
5
5
  "main": "./dist/index.js",
6
6
  "files": [