@inappstory/game-center-api 1.3.39 → 1.3.41

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.
@@ -56,6 +56,6 @@ export type GameLaunchConfig = {
56
56
  userAgent: string;
57
57
  userId: string;
58
58
  nonce?: string;
59
- variables?: Record<string, any>;
59
+ variables: Record<string, any>;
60
60
  };
61
61
  };
@@ -20,6 +20,7 @@ function setGameLaunchConfig(config) {
20
20
  checkUserId(exports.gameLaunchConfig.clientConfig.userId);
21
21
  processImagePlaceholders();
22
22
  processLocalization();
23
+ exports.gameLaunchConfig.clientConfig.variables = exports.gameLaunchConfig.clientConfig.variables ?? {};
23
24
  Object.freeze(exports.gameLaunchConfig);
24
25
  }
25
26
  exports.setGameLaunchConfig = setGameLaunchConfig;
@@ -23,12 +23,15 @@ class URLResolver {
23
23
  }
24
24
  }
25
25
  function fetchLocalAndroid(url, init) {
26
+ // if sdk 1.16.2+
27
+ return fetch(convertToAndroidFileAssetsProtocol(url), init);
28
+ }
29
+ const convertToAndroidFileAssetsProtocol = (url) => {
26
30
  if (url.substring(0, 1) === "/" || url.substring(0, 2) === "./") {
27
31
  url = URLResolver.getInstance().resolve(url);
28
32
  }
29
- // if sdk 1.16.2+
30
- return fetch(url.replace("file:///", "http://file-assets/"), init);
31
- }
33
+ return url.replace("file:///", "http://file-assets/");
34
+ };
32
35
  function fetchLocalFile(url, options) {
33
36
  if (env_1.isAndroid) {
34
37
  const semverVersion = (0, env_1.getSemverSdkVersion)();
@@ -45,7 +48,7 @@ function fetchLocalFile(url, options) {
45
48
  sdkSupportFileAssetsProtocol = false;
46
49
  }
47
50
  }
48
- const fetchViaXhr = () => new Promise(function (resolve, reject) {
51
+ const fetchViaXhr = (xhrUrl) => new Promise(function (resolve, reject) {
49
52
  const xhr = new XMLHttpRequest();
50
53
  xhr.onload = function () {
51
54
  // status 0 in android 9+
@@ -63,13 +66,13 @@ function fetchLocalFile(url, options) {
63
66
  xhr.onerror = function () {
64
67
  reject(new TypeError("Local request failed"));
65
68
  };
66
- xhr.open("GET", url);
69
+ xhr.open("GET", xhrUrl);
67
70
  xhr.responseType = "arraybuffer";
68
71
  xhr.send(null);
69
72
  });
70
73
  if (sdkSupportFileAssetsProtocol) {
71
74
  if (options?.AndroidUseXhr) {
72
- return fetchViaXhr();
75
+ return fetchViaXhr(convertToAndroidFileAssetsProtocol(url));
73
76
  }
74
77
  return fetchLocalAndroid(url, options?.fetchOptions);
75
78
  }
@@ -81,7 +84,7 @@ function fetchLocalFile(url, options) {
81
84
  return fetch(options.remoteUrl + "&stamp=" + new Date().getTime(), options?.fetchOptions);
82
85
  }
83
86
  else {
84
- return fetchViaXhr();
87
+ return fetchViaXhr(url);
85
88
  }
86
89
  }
87
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/game-center-api",
3
- "version": "1.3.39",
3
+ "version": "1.3.41",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@sentry/browser": "^9.5.0",