@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.
package/lib/ResourceManager.d.ts
CHANGED
package/lib/ResourceManager.js
CHANGED
|
@@ -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,
|
package/lib/gameResources.d.ts
CHANGED
|
@@ -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;
|
package/lib/gameResources.js
CHANGED
|
@@ -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
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
62
|
-
|
|
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 (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
75
|
-
|
|
76
|
-
this._state = 3 /* SENSOR_STATE.STOP */;
|
|
79
|
+
else {
|
|
80
|
+
throw new Error(`Incorrect sensor state: ${this._state}`);
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
}
|