@inappstory/game-center-api 1.3.6 → 1.3.8

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.
@@ -16,14 +16,11 @@ export declare class Resource implements ResourceInterface {
16
16
  }
17
17
  export declare abstract class ResourceList implements Iterable<ResourceInterface> {
18
18
  protected orderOfFetch: number;
19
+ protected _hashMap: Record<string, Resource> | null;
20
+ protected get hashMap(): Readonly<Record<string, Resource>>;
19
21
  constructor();
20
- get assets(): {
21
- [k: string]: string;
22
- };
23
- getAssetByKey(key: string, defaultValue: any): any;
24
- protected _assets: Array<Resource> | undefined;
22
+ getAssetByKey<T>(key: string, defaultValue: T): string | T;
25
23
  protected rawMapGetter(): Record<string, string>;
26
- protected get __assets(): Resource[];
27
24
  protected prepareSrc(src: string, key: string): string;
28
25
  protected onCacheDone(): void;
29
26
  [Symbol.iterator](): {
@@ -43,47 +43,40 @@ class Resource {
43
43
  exports.Resource = Resource;
44
44
  class ResourceList {
45
45
  orderOfFetch = 0;
46
- constructor() { }
47
- get assets() {
48
- // get keys from Asset
49
- return Object.fromEntries(this.__assets.map(item => [item.key, item.getCacheUri()]));
50
- }
51
- getAssetByKey(key, defaultValue) {
52
- for (let i = 0; i < this.__assets.length; ++i) {
53
- if (this.__assets[i].key === key) {
54
- return this.__assets[i].getCacheUri();
46
+ _hashMap = null;
47
+ get hashMap() {
48
+ if (this._hashMap === null) {
49
+ const map = this.rawMapGetter();
50
+ this._hashMap = {};
51
+ let src;
52
+ for (let key in map) {
53
+ src = map[key];
54
+ this._hashMap[key] = new Resource(key, this.prepareSrc(src, key), src, this.orderOfFetch);
55
55
  }
56
56
  }
57
- return defaultValue;
57
+ return this._hashMap;
58
+ }
59
+ constructor() { }
60
+ getAssetByKey(key, defaultValue) {
61
+ const resource = this.hashMap[key] ?? null;
62
+ return resource === null ? defaultValue : resource.getCacheUri();
58
63
  }
59
- _assets = undefined;
60
64
  rawMapGetter() {
61
65
  return {};
62
66
  }
63
- get __assets() {
64
- if (this._assets == null) {
65
- const map = this.rawMapGetter();
66
- this._assets = new Array();
67
- for (let key in map) {
68
- let src = map[key];
69
- this._assets.push(new Resource(key, this.prepareSrc(src, key), src, this.orderOfFetch));
70
- }
71
- }
72
- return this._assets;
73
- }
74
67
  prepareSrc(src, key) {
75
68
  return src;
76
69
  }
77
70
  onCacheDone() { }
78
71
  [Symbol.iterator]() {
79
72
  let pointer = 0;
80
- const components = this.__assets;
73
+ const resources = Object.values(this.hashMap);
81
74
  return {
82
75
  next() {
83
- if (pointer < components.length) {
76
+ if (pointer < resources.length) {
84
77
  return {
85
78
  done: false,
86
- value: components[pointer++],
79
+ value: resources[pointer++],
87
80
  };
88
81
  }
89
82
  else {
package/lib/logger.html CHANGED
@@ -75,7 +75,7 @@
75
75
 
76
76
  window.gameLoadingInfo.error = msg;
77
77
  if (msg === "Script error.") {
78
- window.gameLoadFailed(msg, true);
78
+ // window.gameLoadFailed(msg, true);
79
79
  }
80
80
 
81
81
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/game-center-api",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "semver": "^7.3.8",