@inappstory/game-center-api 1.3.41 → 1.3.43

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.
@@ -6,6 +6,7 @@ export interface ResourceInterface {
6
6
  getOriginUri(): string;
7
7
  unsetCacheUri(): void;
8
8
  getOrderOfFetch(): number;
9
+ getIsCached(): boolean;
9
10
  key: string;
10
11
  }
11
12
  export declare class ResourceManager {
@@ -49,6 +49,11 @@ class ResourceManager {
49
49
  const resourceKeys = relatedResources.map(resource => resource.key);
50
50
  const uri = resourceForFetch.getUri();
51
51
  const originUri = resourceForFetch.getOriginUri();
52
+ if (resourceForFetch.getIsCached()) {
53
+ // skip for already cached Resource
54
+ resolve();
55
+ return;
56
+ }
52
57
  try {
53
58
  const objectUrl = await this.cacheResource({
54
59
  uri,
@@ -5,6 +5,7 @@ export declare class Resource implements ResourceInterface {
5
5
  private readonly _originUri;
6
6
  private readonly _orderOfFetch;
7
7
  private _cacheUri;
8
+ protected _isCached: boolean;
8
9
  constructor(_key: string, _uri: string, _originUri: string, _orderOfFetch: number);
9
10
  get key(): string;
10
11
  setCacheUri(uri: string): void;
@@ -13,6 +14,7 @@ export declare class Resource implements ResourceInterface {
13
14
  getUri(): string;
14
15
  getOriginUri(): string;
15
16
  getOrderOfFetch(): number;
17
+ getIsCached(): boolean;
16
18
  }
17
19
  export declare abstract class ResourceList implements Iterable<ResourceInterface> {
18
20
  protected orderOfFetch: number;
@@ -11,6 +11,7 @@ class Resource {
11
11
  _originUri;
12
12
  _orderOfFetch;
13
13
  _cacheUri = "";
14
+ _isCached = false;
14
15
  constructor(_key, _uri, _originUri, _orderOfFetch) {
15
16
  this._key = _key;
16
17
  this._uri = _uri;
@@ -23,12 +24,14 @@ class Resource {
23
24
  }
24
25
  setCacheUri(uri) {
25
26
  this._cacheUri = uri;
27
+ this._isCached = true;
26
28
  }
27
29
  getCacheUri() {
28
30
  return this._cacheUri;
29
31
  }
30
32
  unsetCacheUri() {
31
33
  this._cacheUri = this._uri;
34
+ this._isCached = false;
32
35
  }
33
36
  getUri() {
34
37
  return this._uri;
@@ -39,6 +42,9 @@ class Resource {
39
42
  getOrderOfFetch() {
40
43
  return 0;
41
44
  }
45
+ getIsCached() {
46
+ return this._isCached;
47
+ }
42
48
  }
43
49
  exports.Resource = Resource;
44
50
  class ResourceList {
@@ -51,29 +51,33 @@ class UserAccelerationSensor extends eventemitter3_1.default {
51
51
  }
52
52
  }
53
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 */;
54
+ if (this._state === 1 /* SENSOR_STATE.INIT */ || this._state === 3 /* SENSOR_STATE.STOP */) {
55
+ if (env_1.isAndroid) {
56
+ window.Android.startUserAccelerationSensor();
57
+ this._state = 2 /* SENSOR_STATE.START */;
58
+ }
59
+ else if (env_1.isIos) {
60
+ env_1.iosMh.startUserAccelerationSensor.postMessage(JSON.stringify({}));
61
+ this._state = 2 /* SENSOR_STATE.START */;
62
+ }
60
63
  }
61
- else if (env_1.isIos) {
62
- env_1.iosMh.startUserAccelerationSensor.postMessage(JSON.stringify({}));
63
- this._state = 2 /* SENSOR_STATE.START */;
64
+ else {
65
+ throw new Error(`Incorrect sensor state: ${this._state}`);
64
66
  }
65
67
  }
66
68
  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 */;
69
+ if (this._state === 2 /* SENSOR_STATE.START */ || this._state === 4 /* SENSOR_STATE.ERROR */) {
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
+ }
73
78
  }
74
- else if (env_1.isIos) {
75
- env_1.iosMh.stopUserAccelerationSensor.postMessage(JSON.stringify({}));
76
- this._state = 3 /* SENSOR_STATE.STOP */;
79
+ else {
80
+ throw new Error(`Incorrect sensor state: ${this._state}`);
77
81
  }
78
82
  }
79
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/game-center-api",
3
- "version": "1.3.41",
3
+ "version": "1.3.43",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@sentry/browser": "^9.5.0",