@wvdsh/sdk-js 0.0.36 → 0.0.38

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 +20 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7433,6 +7433,23 @@ var WavedashSDK = (() => {
7433
7433
  }
7434
7434
  };
7435
7435
 
7436
+ // src/utils/focusManager.ts
7437
+ function takeFocus() {
7438
+ if (typeof document !== "undefined") {
7439
+ const gameFocusTargets = document.getElementsByClassName("game-focus-target");
7440
+ if (gameFocusTargets.length > 0) {
7441
+ gameFocusTargets[0].focus();
7442
+ } else {
7443
+ const focusableElement = document.querySelector(
7444
+ "canvas, input, button, [tabindex]:not([tabindex='-1'])"
7445
+ );
7446
+ if (focusableElement) {
7447
+ focusableElement.focus();
7448
+ }
7449
+ }
7450
+ }
7451
+ }
7452
+
7436
7453
  // src/utils/iframeMessenger.ts
7437
7454
  var RESPONSE_TIMEOUT_MS = 5e3;
7438
7455
  var IFrameMessenger = class {
@@ -7451,19 +7468,7 @@ var WavedashSDK = (() => {
7451
7468
  pending.resolve(event.data.data);
7452
7469
  }
7453
7470
  } 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
- }
7471
+ takeFocus();
7467
7472
  }
7468
7473
  };
7469
7474
  this.pendingRequests = /* @__PURE__ */ new Map();
@@ -8017,6 +8022,7 @@ var WavedashSDK = (() => {
8017
8022
  const script = document.createElement("script");
8018
8023
  script.type = "text/javascript";
8019
8024
  script.src = src;
8025
+ script.crossOrigin = "use-credentials";
8020
8026
  script.onload = resolve;
8021
8027
  script.onerror = reject;
8022
8028
  document.head.appendChild(script);
@@ -8033,6 +8039,7 @@ var WavedashSDK = (() => {
8033
8039
  IFRAME_MESSAGE_TYPE.LOADING_COMPLETE,
8034
8040
  {}
8035
8041
  );
8042
+ takeFocus();
8036
8043
  }
8037
8044
  };
8038
8045
  var getAuthToken = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wvdsh/sdk-js",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "description": "Wavedash JavaScript SDK",
5
5
  "main": "./dist/index.js",
6
6
  "files": [