@inappstory/game-center-api 1.3.19 → 1.3.21

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.
@@ -41,6 +41,7 @@ class ResourceManager {
41
41
  async cacheAllResources() {
42
42
  this.createCacheTree();
43
43
  const promises = [];
44
+ let hasInvalidResource = false;
44
45
  for (let resUri in this.cacheTree) {
45
46
  const { resourceForFetch, relatedResources } = this.cacheTree[resUri];
46
47
  const promise = ((resourceForFetch, relatedResources) => {
@@ -49,7 +50,11 @@ class ResourceManager {
49
50
  const uri = resourceForFetch.getUri();
50
51
  const originUri = resourceForFetch.getOriginUri();
51
52
  try {
52
- const objectUrl = await this.cacheResource({ uri, originUri, resourceKeys: resourceKeys });
53
+ const objectUrl = await this.cacheResource({
54
+ uri,
55
+ originUri,
56
+ resourceKeys,
57
+ });
53
58
  if (objectUrl === originUri) {
54
59
  resolve();
55
60
  return;
@@ -60,7 +65,11 @@ class ResourceManager {
60
65
  resolve();
61
66
  }
62
67
  catch (e) {
63
- (0, eventLogger_1.logError)(e, { resourceKeys });
68
+ if (hasInvalidResource) {
69
+ return;
70
+ }
71
+ hasInvalidResource = true;
72
+ (0, eventLogger_1.logError)(e);
64
73
  reject(`Can't load resource for [${resourceKeys.join(", ")}]`);
65
74
  }
66
75
  });
@@ -71,42 +80,41 @@ class ResourceManager {
71
80
  await Promise.all(promises);
72
81
  }
73
82
  catch (e) {
74
- (0, eventLogger_1.logError)(e);
83
+ const error = new Error("Failed to execute cacheAllResources", { cause: e });
84
+ (0, eventLogger_1.logError)(error);
85
+ throw error;
75
86
  }
76
- for (const resList of this.resLists)
87
+ for (const resList of this.resLists) {
77
88
  resList["onCacheDone"]();
89
+ }
78
90
  }
79
91
  async cacheResource({ uri, originUri = uri, resourceKeys = ["outerResource"], }) {
80
- let objectUrl = null;
81
- try {
82
- objectUrl = await this.createObjectUrlByUri(uri, resourceKeys);
83
- }
84
- catch (e) {
85
- (0, eventLogger_1.logError)(e, { uri, resourceKeys });
86
- }
87
- if (objectUrl === null && uri !== originUri) {
88
- try {
89
- objectUrl = await this.createObjectUrlByUri(originUri, resourceKeys);
90
- }
91
- catch (e) {
92
- (0, eventLogger_1.logError)(e, { originUri, resourceKeys });
93
- }
92
+ let objectUrl = { failMessage: "" };
93
+ objectUrl = await this.createObjectUrlByUri(uri, resourceKeys);
94
+ if (typeof objectUrl !== "string" && uri !== originUri) {
95
+ (0, eventLogger_1.logError)(`Warning: ${objectUrl.failMessage}`, { uri });
96
+ objectUrl = await this.createObjectUrlByUri(originUri, resourceKeys);
94
97
  }
95
- if (objectUrl !== null) {
98
+ if (typeof objectUrl === "string") {
96
99
  return objectUrl;
97
100
  }
101
+ (0, eventLogger_1.logError)(`Warning: ${objectUrl.failMessage}`, { originUri });
98
102
  return new Promise((resolve, reject) => {
99
103
  const image = new Image();
100
- image.onload = () => resolve(originUri);
101
- image.onerror = () => reject();
104
+ image.onload = () => {
105
+ resolve(originUri);
106
+ };
107
+ image.onerror = (event, source, lineno, colno, error) => {
108
+ reject(new Error(`Unable to load ${originUri} via Image object`, { cause: new Error(`Fetch info: ${objectUrl.failMessage}`, { cause: error }) }));
109
+ };
102
110
  image.src = originUri;
103
111
  });
104
112
  }
105
113
  async createObjectUrlByUri(uri, resourceKeys) {
106
- if (!uri) {
107
- throw `Resource uri for [${resourceKeys.join(", ")}] can't be empty string`;
108
- }
109
114
  try {
115
+ if (!uri) {
116
+ throw `Resource uri must be a valid string`;
117
+ }
110
118
  const response = await (0, fetchLocalFile_1.fetchLocalFile)(uri);
111
119
  if (response != null && response.ok) {
112
120
  let blob = null;
@@ -114,18 +122,33 @@ class ResourceManager {
114
122
  blob = await response.blob();
115
123
  }
116
124
  catch (e) {
117
- (0, eventLogger_1.logError)(e);
118
125
  throw e;
119
126
  }
120
127
  return URL.createObjectURL(blob);
121
128
  }
122
129
  else {
123
- throw "";
130
+ if (response != null) {
131
+ let responseText = "unknown";
132
+ try {
133
+ responseText = await response.text();
134
+ }
135
+ catch (e) { }
136
+ throw `Response status: ${response.status}, response text: ${responseText}`;
137
+ }
138
+ else {
139
+ throw "Response is undefined";
140
+ }
124
141
  }
125
142
  }
126
- catch (err) {
127
- console.warn(`Error to fetch ${uri} for related images [${resourceKeys.join(", ")}]`, err);
128
- return null;
143
+ catch (e) {
144
+ let errorInfo = "unknown";
145
+ if (typeof e === "string") {
146
+ errorInfo = e;
147
+ }
148
+ else if (e && typeof e === "object" && "message" in e && typeof e.message === "string") {
149
+ errorInfo = e.message;
150
+ }
151
+ return { failMessage: `Unable to fetch ${uri ? uri : "empty uri"} for related images [${resourceKeys.join(", ")}], info: ${errorInfo}` };
129
152
  }
130
153
  }
131
154
  revokeCache() {
@@ -21,10 +21,10 @@ interface Event {
21
21
  interface Exception extends SentryException {
22
22
  cause?: string;
23
23
  }
24
- export declare const eventFromConsoleErrorMessage: (exception: unknown) => Event;
24
+ export declare const eventFromConsoleErrorMessage: (exceptions: unknown) => Event;
25
25
  declare const EventLogger: {
26
26
  eventFromException: (exception: unknown) => Event;
27
- eventFromConsoleErrorMessage: (exception: unknown) => Event;
27
+ eventFromConsoleErrorMessage: (exceptions: unknown) => Event;
28
28
  eventFromUnhandledRejection: (rawEvent: PromiseRejectionEvent) => Event;
29
29
  };
30
30
  export default EventLogger;
@@ -1 +1 @@
1
- var EventLogger;!function(){"use strict";var e={938:function(e,n,r){function t(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}n.nN=void 0;var a=r(651),o=Object.prototype.toString;function i(e){switch(o.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return function(e,n){try{return e instanceof n}catch(e){return!1}}(e,Error)}}function c(e){if(i(e))return e;var n="";if(function(e){return o.call(e)==="[object ".concat("Object","]")}(e))try{n=JSON.stringify(e)}catch(e){}else if("string"==typeof e)n=e;else try{n=JSON.stringify(e)}catch(e){}var r=new Error(n);return r.message="".concat(n),r}function u(e){var n=[e],r=function(e){return i(e.cause)?(n.push(e.cause),r(e.cause)):null};return r(e),n}function f(e,n){var r={type:n.name||n.constructor.name,value:n.message};null!=n.cause&&"string"==typeof n.cause&&(r.cause=n.cause);var t=e(n.stack||"",0);return t.length&&(r.stacktrace={frames:t}),r}n.nN=function(e){var n,r={level:"error",source:"consoleErrorMessage",exception:{values:u(c(e)).map((function(e){return f(a.defaultStackParser,e)}))},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return r.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(r.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,r.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,r.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,r.sdkVersion=null===(n=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===n?void 0:n.sdkVersion,r.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig),r};var s={eventFromException:function(e){var n,r={level:"error",source:"onerror",exception:{values:u(c(e)).map((function(e){return f(a.defaultStackParser,e)}))},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return r.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(r.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,r.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,r.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,r.sdkVersion=null===(n=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===n?void 0:n.sdkVersion,r.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig),r},eventFromConsoleErrorMessage:n.nN,eventFromUnhandledRejection:function(e){var n=[];i(e.reason)&&(n=u(e.reason).map((function(e){return f(a.defaultStackParser,e)})));var r="";if("string"==typeof e.reason)r=e.reason;else try{r=JSON.stringify(e.reason)}catch(e){}var o={type:"PromiseRejection",value:r},c=e.promise.creationPoint;if(null!=c&&"string"==typeof c){var s=(0,a.defaultStackParser)(c||"",0);s.length&&(o.stacktrace={frames:s})}var l,g,d={level:"error",source:"onunhandledrejection",exception:{values:[].concat((g=n,function(e){if(Array.isArray(e))return t(e)}(g)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(g)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(g)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),[o]).filter(Boolean)},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return null!=window.gameLoadingInfo&&(d.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(d.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,d.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,d.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,d.sdkVersion=null===(l=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===l?void 0:l.sdkVersion,d.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig)),d}};n.default=s},651:function(e,n,r){function t(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,a,o,i,c=[],u=!0,f=!1;try{if(o=(r=r.call(e)).next,0===n){if(Object(r)!==r)return;u=!1}else for(;!(u=(t=o.call(r)).done)&&(c.push(t.value),c.length!==n);u=!0);}catch(e){f=!0,a=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(f)throw a}}return c}}(e,n)||a(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,n){if(e){if("string"==typeof e)return o(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,n):void 0}}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}Object.defineProperty(n,"__esModule",{value:!0}),n.defaultStackParser=n.defaultStackLineParsers=n.opera11StackLineParser=n.opera10StackLineParser=n.winjsStackLineParser=n.geckoStackLineParser=n.chromeStackLineParser=void 0;var i=r(425);function c(e,n,r,t){var a={filename:e,function:"<anonymous>"===n?i.UNKNOWN_FUNCTION:n,in_app:!0};return void 0!==r&&(a.lineno=r),void 0!==t&&(a.colno=t),a}var u=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,f=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,s=/\((\S*)(?::(\d+))(?::(\d+))\)/;n.chromeStackLineParser=[30,function(e){var n=u.exec(e);if(n){var r=t(n,4),a=r[1],o=r[2],l=r[3];return c(a,i.UNKNOWN_FUNCTION,+o,+l)}var g=f.exec(e);if(g){if(g[2]&&0===g[2].indexOf("eval")){var d=s.exec(g[2]);d&&(g[2]=d[1],g[3]=d[2],g[4]=d[3])}var m=t(p(g[1]||i.UNKNOWN_FUNCTION,g[2]),2),v=m[0];return c(m[1],v,g[3]?+g[3]:void 0,g[4]?+g[4]:void 0)}}];var l=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,g=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;n.geckoStackLineParser=[50,function(e){var n=l.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=g.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var a=n[3],o=n[1]||i.UNKNOWN_FUNCTION,u=t(p(o,a),2);return o=u[0],c(a=u[1],o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}}];var d=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;n.winjsStackLineParser=[40,function(e){var n=d.exec(e);return n?c(n[2],n[1]||i.UNKNOWN_FUNCTION,+n[3],n[4]?+n[4]:void 0):void 0}];var m=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;n.opera10StackLineParser=[10,function(e){var n=m.exec(e);return n?c(n[2],n[3]||i.UNKNOWN_FUNCTION,+n[1]):void 0}];var v,y=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;n.opera11StackLineParser=[20,function(e){var n=y.exec(e);return n?c(n[5],n[3]||n[4]||i.UNKNOWN_FUNCTION,+n[1],+n[2]):void 0}],n.defaultStackLineParsers=[n.chromeStackLineParser,n.geckoStackLineParser],n.defaultStackParser=i.createStackParser.apply(void 0,function(e){if(Array.isArray(e))return o(e)}(v=n.defaultStackLineParsers)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(v)||a(v)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());var p=function(e,n){var r=-1!==e.indexOf("safari-extension"),t=-1!==e.indexOf("safari-web-extension");return r||t?[-1!==e.indexOf("@")?e.split("@")[0]:i.UNKNOWN_FUNCTION,r?"safari-extension:".concat(n):"safari-web-extension:".concat(n)]:[e,n]}},425:function(e,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function t(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function a(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function o(e,n,t){return(n=function(e){var n=function(e){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var t=n.call(e,"string");if("object"!=r(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(n)?n:n+""}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=u(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0,a=function(){};return{s:a,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw o}}}}function u(e,n){if(e){if("string"==typeof e)return f(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,n):void 0}}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}Object.defineProperty(n,"__esModule",{value:!0}),n.getFramesFromEvent=n.getFunctionName=n.stripSentryFramesAndReverse=n.stackParserFromStackParserOptions=n.createStackParser=n.UNKNOWN_FUNCTION=void 0,n.UNKNOWN_FUNCTION="?";var s=/\(error: (.*)\)/,l=/captureMessage|captureException/;function g(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var t=n.sort((function(e,n){return e[0]-n[0]})).map((function(e){return e[1]}));return function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=[],o=e.split("\n"),i=n;i<o.length;i++){var u=o[i];if(!(u.length>1024)){var f=s.test(u)?u.replace(s,"$1"):u;if(!f.match(/\S*Error: /)){var l,g=c(t);try{for(g.s();!(l=g.n()).done;){var m=(0,l.value)(f);if(m){a.push(m);break}}}catch(e){g.e(e)}finally{g.f()}if(a.length>=50+r)break}}}return d(a.slice(r))}}function d(e){if(!e.length)return[];var r=Array.from(e);return/sentryWrapped/.test(m(r).function||"")&&r.pop(),r.reverse(),l.test(m(r).function||"")&&(r.pop(),l.test(m(r).function||"")&&r.pop()),r.slice(0,50).map((function(e){return a(a({},e),{},{filename:e.filename||m(r).filename,function:e.function||n.UNKNOWN_FUNCTION})}))}function m(e){return e[e.length-1]||{}}n.createStackParser=g,n.stackParserFromStackParserOptions=function(e){return Array.isArray(e)?g.apply(void 0,i(e)):e},n.stripSentryFramesAndReverse=d;var v="<anonymous>";n.getFunctionName=function(e){try{return e&&"function"==typeof e&&e.name||v}catch(e){return v}},n.getFramesFromEvent=function(e){var n=e.exception;if(n){var r=[];try{return n.values.forEach((function(e){e.stacktrace.frames&&r.push.apply(r,i(e.stacktrace.frames))})),r}catch(e){return}}}}},n={},r=function r(t){var a=n[t];if(void 0!==a)return a.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}(938);EventLogger=r.default}();
1
+ var EventLogger;!function(){"use strict";var e={938:function(e,n,r){function t(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return a(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}n.nN=void 0;var o=r(651),i=Object.prototype.toString;function c(e){switch(i.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return function(e,n){try{return e instanceof n}catch(e){return!1}}(e,Error)}}function u(e){if(c(e))return e;var n="";if(function(e){return i.call(e)==="[object ".concat("Object","]")}(e))try{n=JSON.stringify(e)}catch(e){}else if("string"==typeof e)n=e;else try{n=JSON.stringify(e)}catch(e){}var r=new Error(n);return r.message="".concat(n),r}function f(e){var n=[e],r=function(e){return c(e.cause)?(n.push(e.cause),r(e.cause)):null};return r(e),n}function s(e,n){var r={type:n.name||n.constructor.name,value:n.message};if(null!=n.cause)if("string"==typeof n.cause)r.cause=n.cause;else if(!1===c(n.cause))try{r.cause=JSON.stringify(n.cause)}catch(e){}var t=e(n.stack||"",0);return t.length&&(r.stacktrace={frames:t}),r}n.nN=function(e){var n=[];(Array.isArray(e)?e:[e]).forEach((function(e){n.push.apply(n,t(f(u(e)).map((function(e){return s(o.defaultStackParser,e)}))))}));var r,a={level:"error",source:"consoleErrorMessage",exception:{values:n},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return a.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(a.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,a.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,a.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,a.sdkVersion=null===(r=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===r?void 0:r.sdkVersion,a.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig),a};var l={eventFromException:function(e){var n,r={level:"error",source:"onerror",exception:{values:f(u(e)).map((function(e){return s(o.defaultStackParser,e)}))},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return r.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(r.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,r.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,r.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,r.sdkVersion=null===(n=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===n?void 0:n.sdkVersion,r.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig),r},eventFromConsoleErrorMessage:n.nN,eventFromUnhandledRejection:function(e){var n=[];c(e.reason)&&(n=f(e.reason).map((function(e){return s(o.defaultStackParser,e)})));var r="";if("string"==typeof e.reason)r=e.reason;else try{r=JSON.stringify(e.reason)}catch(e){}var a={type:"PromiseRejection",value:r},i=e.promise.creationPoint;if(null!=i&&"string"==typeof i){var u=(0,o.defaultStackParser)(i||"",0);u.length&&(a.stacktrace={frames:u})}var l,g={level:"error",source:"onunhandledrejection",exception:{values:[].concat(t(n),[a]).filter(Boolean)},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return null!=window.gameLoadingInfo&&(g.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(g.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,g.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,g.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,g.sdkVersion=null===(l=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===l?void 0:l.sdkVersion,g.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig)),g}};n.default=l},651:function(e,n,r){function t(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,a,o,i,c=[],u=!0,f=!1;try{if(o=(r=r.call(e)).next,0===n){if(Object(r)!==r)return;u=!1}else for(;!(u=(t=o.call(r)).done)&&(c.push(t.value),c.length!==n);u=!0);}catch(e){f=!0,a=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(f)throw a}}return c}}(e,n)||a(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,n){if(e){if("string"==typeof e)return o(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,n):void 0}}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}Object.defineProperty(n,"__esModule",{value:!0}),n.defaultStackParser=n.defaultStackLineParsers=n.opera11StackLineParser=n.opera10StackLineParser=n.winjsStackLineParser=n.geckoStackLineParser=n.chromeStackLineParser=void 0;var i=r(425);function c(e,n,r,t){var a={filename:e,function:"<anonymous>"===n?i.UNKNOWN_FUNCTION:n,in_app:!0};return void 0!==r&&(a.lineno=r),void 0!==t&&(a.colno=t),a}var u=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,f=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,s=/\((\S*)(?::(\d+))(?::(\d+))\)/;n.chromeStackLineParser=[30,function(e){var n=u.exec(e);if(n){var r=t(n,4),a=r[1],o=r[2],l=r[3];return c(a,i.UNKNOWN_FUNCTION,+o,+l)}var g=f.exec(e);if(g){if(g[2]&&0===g[2].indexOf("eval")){var d=s.exec(g[2]);d&&(g[2]=d[1],g[3]=d[2],g[4]=d[3])}var m=t(p(g[1]||i.UNKNOWN_FUNCTION,g[2]),2),v=m[0];return c(m[1],v,g[3]?+g[3]:void 0,g[4]?+g[4]:void 0)}}];var l=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,g=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;n.geckoStackLineParser=[50,function(e){var n=l.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=g.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var a=n[3],o=n[1]||i.UNKNOWN_FUNCTION,u=t(p(o,a),2);return o=u[0],c(a=u[1],o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}}];var d=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;n.winjsStackLineParser=[40,function(e){var n=d.exec(e);return n?c(n[2],n[1]||i.UNKNOWN_FUNCTION,+n[3],n[4]?+n[4]:void 0):void 0}];var m=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;n.opera10StackLineParser=[10,function(e){var n=m.exec(e);return n?c(n[2],n[3]||i.UNKNOWN_FUNCTION,+n[1]):void 0}];var v,y=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;n.opera11StackLineParser=[20,function(e){var n=y.exec(e);return n?c(n[5],n[3]||n[4]||i.UNKNOWN_FUNCTION,+n[1],+n[2]):void 0}],n.defaultStackLineParsers=[n.chromeStackLineParser,n.geckoStackLineParser],n.defaultStackParser=i.createStackParser.apply(void 0,function(e){if(Array.isArray(e))return o(e)}(v=n.defaultStackLineParsers)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(v)||a(v)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());var p=function(e,n){var r=-1!==e.indexOf("safari-extension"),t=-1!==e.indexOf("safari-web-extension");return r||t?[-1!==e.indexOf("@")?e.split("@")[0]:i.UNKNOWN_FUNCTION,r?"safari-extension:".concat(n):"safari-web-extension:".concat(n)]:[e,n]}},425:function(e,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function t(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function a(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function o(e,n,t){return(n=function(e){var n=function(e){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var t=n.call(e,"string");if("object"!=r(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(n)?n:n+""}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=u(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0,a=function(){};return{s:a,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw o}}}}function u(e,n){if(e){if("string"==typeof e)return f(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,n):void 0}}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}Object.defineProperty(n,"__esModule",{value:!0}),n.getFramesFromEvent=n.getFunctionName=n.stripSentryFramesAndReverse=n.stackParserFromStackParserOptions=n.createStackParser=n.UNKNOWN_FUNCTION=void 0,n.UNKNOWN_FUNCTION="?";var s=/\(error: (.*)\)/,l=/captureMessage|captureException/;function g(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var t=n.sort((function(e,n){return e[0]-n[0]})).map((function(e){return e[1]}));return function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=[],o=e.split("\n"),i=n;i<o.length;i++){var u=o[i];if(!(u.length>1024)){var f=s.test(u)?u.replace(s,"$1"):u;if(!f.match(/\S*Error: /)){var l,g=c(t);try{for(g.s();!(l=g.n()).done;){var m=(0,l.value)(f);if(m){a.push(m);break}}}catch(e){g.e(e)}finally{g.f()}if(a.length>=50+r)break}}}return d(a.slice(r))}}function d(e){if(!e.length)return[];var r=Array.from(e);return/sentryWrapped/.test(m(r).function||"")&&r.pop(),r.reverse(),l.test(m(r).function||"")&&(r.pop(),l.test(m(r).function||"")&&r.pop()),r.slice(0,50).map((function(e){return a(a({},e),{},{filename:e.filename||m(r).filename,function:e.function||n.UNKNOWN_FUNCTION})}))}function m(e){return e[e.length-1]||{}}n.createStackParser=g,n.stackParserFromStackParserOptions=function(e){return Array.isArray(e)?g.apply(void 0,i(e)):e},n.stripSentryFramesAndReverse=d;var v="<anonymous>";n.getFunctionName=function(e){try{return e&&"function"==typeof e&&e.name||v}catch(e){return v}},n.getFramesFromEvent=function(e){var n=e.exception;if(n){var r=[];try{return n.values.forEach((function(e){e.stacktrace.frames&&r.push.apply(r,i(e.stacktrace.frames))})),r}catch(e){return}}}}},n={},r=function r(t){var a=n[t];if(void 0!==a)return a.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}(938);EventLogger=r.default}();
@@ -10,16 +10,24 @@ const logError = (e, cause) => {
10
10
  let error = null;
11
11
  if (e instanceof Error) {
12
12
  error = e;
13
- if (cause != null) {
14
- error.cause = cause;
13
+ if (cause !== null) {
14
+ const originErrorCause = error.cause ?? null;
15
+ if (originErrorCause === null) {
16
+ error.cause = cause;
17
+ }
18
+ else {
19
+ error.cause = cause;
20
+ error = [error, originErrorCause];
21
+ }
15
22
  }
16
23
  }
17
24
  if (typeof e === "string") {
18
25
  error = new Error(e);
26
+ cause !== null && (error.cause = cause);
19
27
  }
20
28
  if (error !== null) {
21
29
  // will be handled via sdk console.error override
22
- console.error((0, exports.eventFromConsoleErrorMessage)(e));
30
+ console.error((0, exports.eventFromConsoleErrorMessage)(error));
23
31
  }
24
32
  else {
25
33
  console.error(e);
@@ -129,8 +137,16 @@ function exceptionFromError(stackParser, error) {
129
137
  type: error.name || error.constructor.name,
130
138
  value: error.message,
131
139
  };
132
- if (error.cause != null && typeof error.cause === "string") {
133
- exception.cause = error.cause;
140
+ if (error.cause != null) {
141
+ if (typeof error.cause === "string") {
142
+ exception.cause = error.cause;
143
+ }
144
+ else if (isError(error.cause) === false) {
145
+ try {
146
+ exception.cause = JSON.stringify(error.cause);
147
+ }
148
+ catch (_) { }
149
+ }
134
150
  }
135
151
  const frames = stackParser(error.stack || "", 0);
136
152
  if (frames.length) {
@@ -162,13 +178,16 @@ const eventFromException = (exception) => {
162
178
  }
163
179
  return event;
164
180
  };
165
- const eventFromConsoleErrorMessage = (exception) => {
181
+ const eventFromConsoleErrorMessage = (exceptions) => {
182
+ const values = [];
183
+ const exceptionArray = Array.isArray(exceptions) ? exceptions : [exceptions];
184
+ exceptionArray.forEach(exception => {
185
+ values.push(...flatErrorCause(getException(exception)).map(error => exceptionFromError(stack_parsers_1.defaultStackParser, error)));
186
+ });
166
187
  const event = {
167
188
  level: "error",
168
189
  source: "consoleErrorMessage",
169
- exception: {
170
- values: flatErrorCause(getException(exception)).map(error => exceptionFromError(stack_parsers_1.defaultStackParser, error)),
171
- },
190
+ exception: { values },
172
191
  gameLoaded: false,
173
192
  gameLaunchRawConfig: {},
174
193
  gameSlug: "",
package/lib/index.d.ts CHANGED
@@ -17,6 +17,7 @@ import { ResourceManager } from "./ResourceManager";
17
17
  import { hasFilePickerApi, openFilePicker } from "./sdkApi/filePicker";
18
18
  import { FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile } from "./sdkApi/filePicker.h";
19
19
  import { logError } from "./eventLogger";
20
+ import { UserAccelerationSensor } from "./sdkApi/UserAccelerationSensor";
20
21
  export type { OpenFilePickerProps, SDKFileResponse, LocalFile, LocalFileList, FilePickerResultPayload, FilePickerResult } from "./sdkApi/filePicker.h";
21
22
  export type { PrimaryFontVariants as SDKPrimaryFontVariants, SecondaryFontVariants as SDKSecondaryFontVariants } from "./gameResources";
22
23
  export type { OpenUrlOptions as SDKOpenUrlOptions } from "./sdkApi/openUrl.h";
@@ -26,7 +27,7 @@ export type { ProjectFontFamily } from "./gameResources";
26
27
  export type { ResourceInterface } from "./ResourceManager";
27
28
  export type { OpenStoryOptions } from "./sdkApi/openStory.h";
28
29
  export type { OpenGameInstanceOptions } from "./sdkApi/openGameInstance.h";
29
- export { createSdkApi, closeGameReader, gameLoadedSdkCallback, gameLoadFailedSdkCallback, gameLaunchConfig, isIos, isWeb, isAndroid, isDev, getSdkVersion, getSemverSdkVersion, gameLocalData, sendIasApiRequest, openUrl, shareText, shareUrl, shareFiles, vibrate, getDynamicResourceAsset, getDynamicResourceFont, getProjectFontFamilyStylesheet, getIsDemoMode, getSessionId, getApiBaseUrl, ScreenOrientation, PlaceholderType, fetchLocalFile, openStory, ResourceManager, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList, eventGame, reloadGameReader, openFilePicker, FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile, hasFilePickerApi, gameShouldForegroundCallback, gameOnForeground, getApplicationVersion, getApplicationBuildVersion, openGameInstance, logError, };
30
+ export { createSdkApi, closeGameReader, gameLoadedSdkCallback, gameLoadFailedSdkCallback, gameLaunchConfig, isIos, isWeb, isAndroid, isDev, getSdkVersion, getSemverSdkVersion, gameLocalData, sendIasApiRequest, openUrl, shareText, shareUrl, shareFiles, vibrate, getDynamicResourceAsset, getDynamicResourceFont, getProjectFontFamilyStylesheet, getIsDemoMode, getSessionId, getApiBaseUrl, ScreenOrientation, PlaceholderType, fetchLocalFile, openStory, ResourceManager, dynamicResourceAssets, dynamicResourceFonts, staticResourcesImagePlaceholders, StaticResourceList, eventGame, reloadGameReader, openFilePicker, FilePickerResultType, isFilePickerResultFileList, isFilePickerResultLocalFileList, isLocalFile, hasFilePickerApi, gameShouldForegroundCallback, gameOnForeground, getApplicationVersion, getApplicationBuildVersion, openGameInstance, logError, UserAccelerationSensor, };
30
31
  declare const GameCenterApi: {
31
32
  createSdkApi: ({ mounted, beforeUnmount: beforeUnmountCb, onSdkCloseGameReaderIntent, onPause, onResume, onBackGesture, onAudioFocusChange, filterPlaceholders, gameShouldForeground, }: Partial<{
32
33
  mounted: () => void;
@@ -92,6 +93,7 @@ declare const GameCenterApi: {
92
93
  getApplicationBuildVersion: () => number | null;
93
94
  openGameInstance: (openGameInstance: import("./sdkApi/openGameInstance.h").OpenGameInstanceOptions) => void;
94
95
  logError: (e: unknown, cause?: any) => void;
96
+ UserAccelerationSensor: typeof UserAccelerationSensor;
95
97
  };
96
98
  export { GameCenterApi as default };
97
99
  export { TraceablePromise } from "./TraceablePromise";
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TraceablePromise = exports.default = exports.logError = exports.openGameInstance = exports.getApplicationBuildVersion = exports.getApplicationVersion = exports.gameOnForeground = exports.gameShouldForegroundCallback = exports.hasFilePickerApi = exports.isLocalFile = exports.isFilePickerResultLocalFileList = exports.isFilePickerResultFileList = exports.FilePickerResultType = exports.openFilePicker = exports.reloadGameReader = exports.eventGame = exports.StaticResourceList = exports.staticResourcesImagePlaceholders = exports.dynamicResourceFonts = exports.dynamicResourceAssets = exports.ResourceManager = exports.openStory = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getProjectFontFamilyStylesheet = exports.getDynamicResourceFont = exports.getDynamicResourceAsset = exports.vibrate = exports.shareFiles = exports.shareUrl = exports.shareText = exports.openUrl = exports.sendIasApiRequest = exports.gameLocalData = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.isAndroid = exports.isWeb = exports.isIos = exports.gameLaunchConfig = exports.gameLoadFailedSdkCallback = exports.gameLoadedSdkCallback = exports.closeGameReader = exports.createSdkApi = void 0;
3
+ exports.TraceablePromise = exports.default = exports.UserAccelerationSensor = exports.logError = exports.openGameInstance = exports.getApplicationBuildVersion = exports.getApplicationVersion = exports.gameOnForeground = exports.gameShouldForegroundCallback = exports.hasFilePickerApi = exports.isLocalFile = exports.isFilePickerResultLocalFileList = exports.isFilePickerResultFileList = exports.FilePickerResultType = exports.openFilePicker = exports.reloadGameReader = exports.eventGame = exports.StaticResourceList = exports.staticResourcesImagePlaceholders = exports.dynamicResourceFonts = exports.dynamicResourceAssets = exports.ResourceManager = exports.openStory = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getProjectFontFamilyStylesheet = exports.getDynamicResourceFont = exports.getDynamicResourceAsset = exports.vibrate = exports.shareFiles = exports.shareUrl = exports.shareText = exports.openUrl = exports.sendIasApiRequest = exports.gameLocalData = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.isAndroid = exports.isWeb = exports.isIos = exports.gameLaunchConfig = exports.gameLoadFailedSdkCallback = exports.gameLoadedSdkCallback = exports.closeGameReader = exports.createSdkApi = void 0;
4
4
  const env_1 = require("./env");
5
5
  Object.defineProperty(exports, "getApplicationBuildVersion", { enumerable: true, get: function () { return env_1.getApplicationBuildVersion; } });
6
6
  Object.defineProperty(exports, "getApplicationVersion", { enumerable: true, get: function () { return env_1.getApplicationVersion; } });
@@ -67,6 +67,8 @@ Object.defineProperty(exports, "isFilePickerResultLocalFileList", { enumerable:
67
67
  Object.defineProperty(exports, "isLocalFile", { enumerable: true, get: function () { return filePicker_h_1.isLocalFile; } });
68
68
  const eventLogger_1 = require("./eventLogger");
69
69
  Object.defineProperty(exports, "logError", { enumerable: true, get: function () { return eventLogger_1.logError; } });
70
+ const UserAccelerationSensor_1 = require("./sdkApi/UserAccelerationSensor");
71
+ Object.defineProperty(exports, "UserAccelerationSensor", { enumerable: true, get: function () { return UserAccelerationSensor_1.UserAccelerationSensor; } });
70
72
  const GameCenterApi = {
71
73
  createSdkApi: sdkApi_1.createSdkApi,
72
74
  closeGameReader: sdkApi_1.closeGameReader,
@@ -115,6 +117,7 @@ const GameCenterApi = {
115
117
  getApplicationBuildVersion: env_1.getApplicationBuildVersion,
116
118
  openGameInstance: openGameInstance_1.openGameInstance,
117
119
  logError: eventLogger_1.logError,
120
+ UserAccelerationSensor: UserAccelerationSensor_1.UserAccelerationSensor,
118
121
  };
119
122
  exports.default = GameCenterApi;
120
123
  var TraceablePromise_1 = require("./TraceablePromise");
package/lib/logger.html CHANGED
@@ -239,5 +239,5 @@
239
239
  };
240
240
 
241
241
  // use EventLogger in handlers
242
- var EventLogger;!function(){"use strict";var e={938:function(e,n,r){function t(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}n.nN=void 0;var a=r(651),o=Object.prototype.toString;function i(e){switch(o.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return function(e,n){try{return e instanceof n}catch(e){return!1}}(e,Error)}}function c(e){if(i(e))return e;var n="";if(function(e){return o.call(e)==="[object ".concat("Object","]")}(e))try{n=JSON.stringify(e)}catch(e){}else if("string"==typeof e)n=e;else try{n=JSON.stringify(e)}catch(e){}var r=new Error(n);return r.message="".concat(n),r}function u(e){var n=[e],r=function(e){return i(e.cause)?(n.push(e.cause),r(e.cause)):null};return r(e),n}function f(e,n){var r={type:n.name||n.constructor.name,value:n.message};null!=n.cause&&"string"==typeof n.cause&&(r.cause=n.cause);var t=e(n.stack||"",0);return t.length&&(r.stacktrace={frames:t}),r}n.nN=function(e){var n,r={level:"error",source:"consoleErrorMessage",exception:{values:u(c(e)).map((function(e){return f(a.defaultStackParser,e)}))},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return r.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(r.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,r.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,r.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,r.sdkVersion=null===(n=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===n?void 0:n.sdkVersion,r.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig),r};var s={eventFromException:function(e){var n,r={level:"error",source:"onerror",exception:{values:u(c(e)).map((function(e){return f(a.defaultStackParser,e)}))},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return r.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(r.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,r.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,r.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,r.sdkVersion=null===(n=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===n?void 0:n.sdkVersion,r.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig),r},eventFromConsoleErrorMessage:n.nN,eventFromUnhandledRejection:function(e){var n=[];i(e.reason)&&(n=u(e.reason).map((function(e){return f(a.defaultStackParser,e)})));var r="";if("string"==typeof e.reason)r=e.reason;else try{r=JSON.stringify(e.reason)}catch(e){}var o={type:"PromiseRejection",value:r},c=e.promise.creationPoint;if(null!=c&&"string"==typeof c){var s=(0,a.defaultStackParser)(c||"",0);s.length&&(o.stacktrace={frames:s})}var l,g,d={level:"error",source:"onunhandledrejection",exception:{values:[].concat((g=n,function(e){if(Array.isArray(e))return t(e)}(g)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(g)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(g)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),[o]).filter(Boolean)},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return null!=window.gameLoadingInfo&&(d.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(d.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,d.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,d.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,d.sdkVersion=null===(l=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===l?void 0:l.sdkVersion,d.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig)),d}};n.default=s},651:function(e,n,r){function t(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,a,o,i,c=[],u=!0,f=!1;try{if(o=(r=r.call(e)).next,0===n){if(Object(r)!==r)return;u=!1}else for(;!(u=(t=o.call(r)).done)&&(c.push(t.value),c.length!==n);u=!0);}catch(e){f=!0,a=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(f)throw a}}return c}}(e,n)||a(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,n){if(e){if("string"==typeof e)return o(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,n):void 0}}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}Object.defineProperty(n,"__esModule",{value:!0}),n.defaultStackParser=n.defaultStackLineParsers=n.opera11StackLineParser=n.opera10StackLineParser=n.winjsStackLineParser=n.geckoStackLineParser=n.chromeStackLineParser=void 0;var i=r(425);function c(e,n,r,t){var a={filename:e,function:"<anonymous>"===n?i.UNKNOWN_FUNCTION:n,in_app:!0};return void 0!==r&&(a.lineno=r),void 0!==t&&(a.colno=t),a}var u=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,f=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,s=/\((\S*)(?::(\d+))(?::(\d+))\)/;n.chromeStackLineParser=[30,function(e){var n=u.exec(e);if(n){var r=t(n,4),a=r[1],o=r[2],l=r[3];return c(a,i.UNKNOWN_FUNCTION,+o,+l)}var g=f.exec(e);if(g){if(g[2]&&0===g[2].indexOf("eval")){var d=s.exec(g[2]);d&&(g[2]=d[1],g[3]=d[2],g[4]=d[3])}var m=t(p(g[1]||i.UNKNOWN_FUNCTION,g[2]),2),v=m[0];return c(m[1],v,g[3]?+g[3]:void 0,g[4]?+g[4]:void 0)}}];var l=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,g=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;n.geckoStackLineParser=[50,function(e){var n=l.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=g.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var a=n[3],o=n[1]||i.UNKNOWN_FUNCTION,u=t(p(o,a),2);return o=u[0],c(a=u[1],o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}}];var d=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;n.winjsStackLineParser=[40,function(e){var n=d.exec(e);return n?c(n[2],n[1]||i.UNKNOWN_FUNCTION,+n[3],n[4]?+n[4]:void 0):void 0}];var m=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;n.opera10StackLineParser=[10,function(e){var n=m.exec(e);return n?c(n[2],n[3]||i.UNKNOWN_FUNCTION,+n[1]):void 0}];var v,y=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;n.opera11StackLineParser=[20,function(e){var n=y.exec(e);return n?c(n[5],n[3]||n[4]||i.UNKNOWN_FUNCTION,+n[1],+n[2]):void 0}],n.defaultStackLineParsers=[n.chromeStackLineParser,n.geckoStackLineParser],n.defaultStackParser=i.createStackParser.apply(void 0,function(e){if(Array.isArray(e))return o(e)}(v=n.defaultStackLineParsers)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(v)||a(v)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());var p=function(e,n){var r=-1!==e.indexOf("safari-extension"),t=-1!==e.indexOf("safari-web-extension");return r||t?[-1!==e.indexOf("@")?e.split("@")[0]:i.UNKNOWN_FUNCTION,r?"safari-extension:".concat(n):"safari-web-extension:".concat(n)]:[e,n]}},425:function(e,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function t(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function a(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function o(e,n,t){return(n=function(e){var n=function(e){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var t=n.call(e,"string");if("object"!=r(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(n)?n:n+""}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=u(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0,a=function(){};return{s:a,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw o}}}}function u(e,n){if(e){if("string"==typeof e)return f(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,n):void 0}}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}Object.defineProperty(n,"__esModule",{value:!0}),n.getFramesFromEvent=n.getFunctionName=n.stripSentryFramesAndReverse=n.stackParserFromStackParserOptions=n.createStackParser=n.UNKNOWN_FUNCTION=void 0,n.UNKNOWN_FUNCTION="?";var s=/\(error: (.*)\)/,l=/captureMessage|captureException/;function g(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var t=n.sort((function(e,n){return e[0]-n[0]})).map((function(e){return e[1]}));return function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=[],o=e.split("\n"),i=n;i<o.length;i++){var u=o[i];if(!(u.length>1024)){var f=s.test(u)?u.replace(s,"$1"):u;if(!f.match(/\S*Error: /)){var l,g=c(t);try{for(g.s();!(l=g.n()).done;){var m=(0,l.value)(f);if(m){a.push(m);break}}}catch(e){g.e(e)}finally{g.f()}if(a.length>=50+r)break}}}return d(a.slice(r))}}function d(e){if(!e.length)return[];var r=Array.from(e);return/sentryWrapped/.test(m(r).function||"")&&r.pop(),r.reverse(),l.test(m(r).function||"")&&(r.pop(),l.test(m(r).function||"")&&r.pop()),r.slice(0,50).map((function(e){return a(a({},e),{},{filename:e.filename||m(r).filename,function:e.function||n.UNKNOWN_FUNCTION})}))}function m(e){return e[e.length-1]||{}}n.createStackParser=g,n.stackParserFromStackParserOptions=function(e){return Array.isArray(e)?g.apply(void 0,i(e)):e},n.stripSentryFramesAndReverse=d;var v="<anonymous>";n.getFunctionName=function(e){try{return e&&"function"==typeof e&&e.name||v}catch(e){return v}},n.getFramesFromEvent=function(e){var n=e.exception;if(n){var r=[];try{return n.values.forEach((function(e){e.stacktrace.frames&&r.push.apply(r,i(e.stacktrace.frames))})),r}catch(e){return}}}}},n={},r=function r(t){var a=n[t];if(void 0!==a)return a.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}(938);EventLogger=r.default}();;
242
+ var EventLogger;!function(){"use strict";var e={938:function(e,n,r){function t(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return a(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}n.nN=void 0;var o=r(651),i=Object.prototype.toString;function c(e){switch(i.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return function(e,n){try{return e instanceof n}catch(e){return!1}}(e,Error)}}function u(e){if(c(e))return e;var n="";if(function(e){return i.call(e)==="[object ".concat("Object","]")}(e))try{n=JSON.stringify(e)}catch(e){}else if("string"==typeof e)n=e;else try{n=JSON.stringify(e)}catch(e){}var r=new Error(n);return r.message="".concat(n),r}function f(e){var n=[e],r=function(e){return c(e.cause)?(n.push(e.cause),r(e.cause)):null};return r(e),n}function s(e,n){var r={type:n.name||n.constructor.name,value:n.message};if(null!=n.cause)if("string"==typeof n.cause)r.cause=n.cause;else if(!1===c(n.cause))try{r.cause=JSON.stringify(n.cause)}catch(e){}var t=e(n.stack||"",0);return t.length&&(r.stacktrace={frames:t}),r}n.nN=function(e){var n=[];(Array.isArray(e)?e:[e]).forEach((function(e){n.push.apply(n,t(f(u(e)).map((function(e){return s(o.defaultStackParser,e)}))))}));var r,a={level:"error",source:"consoleErrorMessage",exception:{values:n},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return a.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(a.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,a.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,a.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,a.sdkVersion=null===(r=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===r?void 0:r.sdkVersion,a.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig),a};var l={eventFromException:function(e){var n,r={level:"error",source:"onerror",exception:{values:f(u(e)).map((function(e){return s(o.defaultStackParser,e)}))},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return r.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(r.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,r.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,r.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,r.sdkVersion=null===(n=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===n?void 0:n.sdkVersion,r.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig),r},eventFromConsoleErrorMessage:n.nN,eventFromUnhandledRejection:function(e){var n=[];c(e.reason)&&(n=f(e.reason).map((function(e){return s(o.defaultStackParser,e)})));var r="";if("string"==typeof e.reason)r=e.reason;else try{r=JSON.stringify(e.reason)}catch(e){}var a={type:"PromiseRejection",value:r},i=e.promise.creationPoint;if(null!=i&&"string"==typeof i){var u=(0,o.defaultStackParser)(i||"",0);u.length&&(a.stacktrace={frames:u})}var l,g={level:"error",source:"onunhandledrejection",exception:{values:[].concat(t(n),[a]).filter(Boolean)},gameLoaded:!1,gameLaunchRawConfig:{},gameSlug:"",gameVersion:"",sdkVersion:"",env:""};return null!=window.gameLoadingInfo&&(g.gameLoaded=window.gameLoadingInfo.loaded,null!=window.gameLoadingInfo.gameLaunchRawConfig&&(g.gameSlug=window.gameLoadingInfo.gameLaunchRawConfig.gameSlug,g.gameVersion=window.gameLoadingInfo.gameLaunchRawConfig.gameVersion,g.env=window.gameLoadingInfo.gameLaunchRawConfig.projectEnv,g.sdkVersion=null===(l=window.gameLoadingInfo.gameLaunchRawConfig.clientConfig)||void 0===l?void 0:l.sdkVersion,g.gameLaunchRawConfig=window.gameLoadingInfo.gameLaunchRawConfig)),g}};n.default=l},651:function(e,n,r){function t(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,a,o,i,c=[],u=!0,f=!1;try{if(o=(r=r.call(e)).next,0===n){if(Object(r)!==r)return;u=!1}else for(;!(u=(t=o.call(r)).done)&&(c.push(t.value),c.length!==n);u=!0);}catch(e){f=!0,a=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(f)throw a}}return c}}(e,n)||a(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,n){if(e){if("string"==typeof e)return o(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,n):void 0}}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}Object.defineProperty(n,"__esModule",{value:!0}),n.defaultStackParser=n.defaultStackLineParsers=n.opera11StackLineParser=n.opera10StackLineParser=n.winjsStackLineParser=n.geckoStackLineParser=n.chromeStackLineParser=void 0;var i=r(425);function c(e,n,r,t){var a={filename:e,function:"<anonymous>"===n?i.UNKNOWN_FUNCTION:n,in_app:!0};return void 0!==r&&(a.lineno=r),void 0!==t&&(a.colno=t),a}var u=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,f=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,s=/\((\S*)(?::(\d+))(?::(\d+))\)/;n.chromeStackLineParser=[30,function(e){var n=u.exec(e);if(n){var r=t(n,4),a=r[1],o=r[2],l=r[3];return c(a,i.UNKNOWN_FUNCTION,+o,+l)}var g=f.exec(e);if(g){if(g[2]&&0===g[2].indexOf("eval")){var d=s.exec(g[2]);d&&(g[2]=d[1],g[3]=d[2],g[4]=d[3])}var m=t(p(g[1]||i.UNKNOWN_FUNCTION,g[2]),2),v=m[0];return c(m[1],v,g[3]?+g[3]:void 0,g[4]?+g[4]:void 0)}}];var l=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,g=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;n.geckoStackLineParser=[50,function(e){var n=l.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=g.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var a=n[3],o=n[1]||i.UNKNOWN_FUNCTION,u=t(p(o,a),2);return o=u[0],c(a=u[1],o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}}];var d=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;n.winjsStackLineParser=[40,function(e){var n=d.exec(e);return n?c(n[2],n[1]||i.UNKNOWN_FUNCTION,+n[3],n[4]?+n[4]:void 0):void 0}];var m=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;n.opera10StackLineParser=[10,function(e){var n=m.exec(e);return n?c(n[2],n[3]||i.UNKNOWN_FUNCTION,+n[1]):void 0}];var v,y=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;n.opera11StackLineParser=[20,function(e){var n=y.exec(e);return n?c(n[5],n[3]||n[4]||i.UNKNOWN_FUNCTION,+n[1],+n[2]):void 0}],n.defaultStackLineParsers=[n.chromeStackLineParser,n.geckoStackLineParser],n.defaultStackParser=i.createStackParser.apply(void 0,function(e){if(Array.isArray(e))return o(e)}(v=n.defaultStackLineParsers)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(v)||a(v)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());var p=function(e,n){var r=-1!==e.indexOf("safari-extension"),t=-1!==e.indexOf("safari-web-extension");return r||t?[-1!==e.indexOf("@")?e.split("@")[0]:i.UNKNOWN_FUNCTION,r?"safari-extension:".concat(n):"safari-web-extension:".concat(n)]:[e,n]}},425:function(e,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function t(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function a(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function o(e,n,t){return(n=function(e){var n=function(e){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var t=n.call(e,"string");if("object"!=r(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(n)?n:n+""}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=u(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0,a=function(){};return{s:a,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw o}}}}function u(e,n){if(e){if("string"==typeof e)return f(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,n):void 0}}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}Object.defineProperty(n,"__esModule",{value:!0}),n.getFramesFromEvent=n.getFunctionName=n.stripSentryFramesAndReverse=n.stackParserFromStackParserOptions=n.createStackParser=n.UNKNOWN_FUNCTION=void 0,n.UNKNOWN_FUNCTION="?";var s=/\(error: (.*)\)/,l=/captureMessage|captureException/;function g(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var t=n.sort((function(e,n){return e[0]-n[0]})).map((function(e){return e[1]}));return function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=[],o=e.split("\n"),i=n;i<o.length;i++){var u=o[i];if(!(u.length>1024)){var f=s.test(u)?u.replace(s,"$1"):u;if(!f.match(/\S*Error: /)){var l,g=c(t);try{for(g.s();!(l=g.n()).done;){var m=(0,l.value)(f);if(m){a.push(m);break}}}catch(e){g.e(e)}finally{g.f()}if(a.length>=50+r)break}}}return d(a.slice(r))}}function d(e){if(!e.length)return[];var r=Array.from(e);return/sentryWrapped/.test(m(r).function||"")&&r.pop(),r.reverse(),l.test(m(r).function||"")&&(r.pop(),l.test(m(r).function||"")&&r.pop()),r.slice(0,50).map((function(e){return a(a({},e),{},{filename:e.filename||m(r).filename,function:e.function||n.UNKNOWN_FUNCTION})}))}function m(e){return e[e.length-1]||{}}n.createStackParser=g,n.stackParserFromStackParserOptions=function(e){return Array.isArray(e)?g.apply(void 0,i(e)):e},n.stripSentryFramesAndReverse=d;var v="<anonymous>";n.getFunctionName=function(e){try{return e&&"function"==typeof e&&e.name||v}catch(e){return v}},n.getFramesFromEvent=function(e){var n=e.exception;if(n){var r=[];try{return n.values.forEach((function(e){e.stacktrace.frames&&r.push.apply(r,i(e.stacktrace.frames))})),r}catch(e){return}}}}},n={},r=function r(t){var a=n[t];if(void 0!==a)return a.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}(938);EventLogger=r.default}();;
243
243
  </script>
@@ -0,0 +1,19 @@
1
+ import EventEmitter from "eventemitter3";
2
+ export declare class UserAccelerationSensor extends EventEmitter<"activate" | "reading" | "error"> {
3
+ private readonly _options;
4
+ constructor(_options: {
5
+ frequency: number;
6
+ });
7
+ private _state;
8
+ static get isAvailableOnPlatform(): boolean;
9
+ private _init;
10
+ start(): void;
11
+ stop(): void;
12
+ }
13
+ declare global {
14
+ interface Window {
15
+ userAccelerationSensorCbActivate: () => void;
16
+ userAccelerationSensorCbRead: (x: number, y: number, z: number) => void;
17
+ userAccelerationSensorCbError: (type: string, message: string) => void;
18
+ }
19
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UserAccelerationSensor = void 0;
7
+ const eventemitter3_1 = __importDefault(require("eventemitter3"));
8
+ const env_1 = require("../env");
9
+ class UserAccelerationSensor extends eventemitter3_1.default {
10
+ _options;
11
+ constructor(_options) {
12
+ super();
13
+ this._options = _options;
14
+ if (!UserAccelerationSensor.isAvailableOnPlatform) {
15
+ throw new Error("UserAccelerationSensor isn't supported on this platform");
16
+ }
17
+ this._init();
18
+ // add callbacks
19
+ window.userAccelerationSensorCbActivate = () => {
20
+ this.emit("activate");
21
+ };
22
+ window.userAccelerationSensorCbRead = (x, y, z) => {
23
+ this.emit("reading", { x, y, z });
24
+ };
25
+ window.userAccelerationSensorCbError = (type, message) => {
26
+ this._state = 4 /* SENSOR_STATE.ERROR */;
27
+ const error = new Error();
28
+ error.name = type;
29
+ error.message = message;
30
+ this.emit("error", { error });
31
+ };
32
+ }
33
+ _state = 0 /* SENSOR_STATE.UNDEFINED */;
34
+ static get isAvailableOnPlatform() {
35
+ if (env_1.isAndroid && window.Android.initUserAccelerationSensor != null) {
36
+ return true;
37
+ }
38
+ else if (env_1.isIos && env_1.iosMh.initUserAccelerationSensor != null) {
39
+ return true;
40
+ }
41
+ return false;
42
+ }
43
+ _init() {
44
+ if (env_1.isAndroid) {
45
+ window.Android.initUserAccelerationSensor(JSON.stringify(this._options));
46
+ this._state = 1 /* SENSOR_STATE.INIT */;
47
+ }
48
+ else if (env_1.isIos) {
49
+ env_1.iosMh.initUserAccelerationSensor.postMessage(JSON.stringify(this._options));
50
+ this._state = 1 /* SENSOR_STATE.INIT */;
51
+ }
52
+ }
53
+ start() {
54
+ if (this._state !== 1 /* SENSOR_STATE.INIT */) {
55
+ throw new Error(`Incorrect sensor state: ${this._state}`);
56
+ }
57
+ if (env_1.isAndroid) {
58
+ window.Android.startUserAccelerationSensor();
59
+ this._state = 2 /* SENSOR_STATE.START */;
60
+ }
61
+ else if (env_1.isIos) {
62
+ env_1.iosMh.startUserAccelerationSensor.postMessage(JSON.stringify({}));
63
+ this._state = 2 /* SENSOR_STATE.START */;
64
+ }
65
+ }
66
+ stop() {
67
+ if (!(this._state === 2 /* SENSOR_STATE.START */ || this._state === 4 /* SENSOR_STATE.ERROR */)) {
68
+ throw new Error(`Incorrect sensor state: ${this._state}`);
69
+ }
70
+ if (env_1.isAndroid) {
71
+ window.Android.stopUserAccelerationSensor();
72
+ this._state = 3 /* SENSOR_STATE.STOP */;
73
+ }
74
+ else if (env_1.isIos) {
75
+ env_1.iosMh.stopUserAccelerationSensor.postMessage(JSON.stringify({}));
76
+ this._state = 3 /* SENSOR_STATE.STOP */;
77
+ }
78
+ }
79
+ }
80
+ exports.UserAccelerationSensor = UserAccelerationSensor;
81
+ window.userAccelerationSensorCbActivate = () => { };
82
+ window.userAccelerationSensorCbRead = (x, y, z) => { };
83
+ window.userAccelerationSensorCbError = (type, message) => { };
@@ -78,6 +78,26 @@ function fetchLocalFile(url, remoteUrl) {
78
78
  }
79
79
  }
80
80
  }
81
+ else if (env_1.isIos) {
82
+ // https://stackoverflow.com/questions/40182785/why-fetch-return-a-response-with-status-0
83
+ // Effectively, the response you get from making such a request (with no-cors specified as a mode) will contain no information about whether the request succeeded or failed, making the status code 0.
84
+ // Welcome to the insane and wonderful world of CORS. A necessary(?) evil; CORS is a huge pain the ass for web developers.
85
+ // fetch local file on iOS return status 0, response.ok = false
86
+ // fallback via wrap fetch result into new Response with status 200
87
+ // assume that failed load - trigger catch by origin fetch
88
+ return new Promise(function (resolve, reject) {
89
+ fetch(url)
90
+ .then(response => {
91
+ if (response.status === 0) {
92
+ resolve(new Response(response.body, { status: 200 }));
93
+ }
94
+ else {
95
+ resolve(response);
96
+ }
97
+ })
98
+ .catch(reject);
99
+ });
100
+ }
81
101
  else {
82
102
  return fetch(url);
83
103
  }
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@inappstory/game-center-api",
3
- "version": "1.3.19",
3
+ "version": "1.3.21",
4
4
  "description": "",
5
5
  "dependencies": {
6
- "@sentry/browser": "^9.1.0",
6
+ "@sentry/browser": "^9.5.0",
7
+ "eventemitter3": "^5.0.1",
7
8
  "semver": "^7.3.8",
8
9
  "uuid": "^8.3.2"
9
10
  },