squishjs 1.3.6 → 1.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squishjs",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "squish & unsquish stuff",
5
5
  "scripts": {
6
6
  "test": "node testRunner.js"
package/src/Asset.js CHANGED
@@ -95,7 +95,7 @@ class Asset {
95
95
  existsLocally() {
96
96
  return new Promise((resolve, reject) => {
97
97
  if (this.data) {
98
- resolve(true);
98
+ return resolve(true);
99
99
  }
100
100
  const fileLocation = this.getFileLocation(this.info.id);
101
101
  this.fs.exists(fileLocation, (exists) => {
@@ -118,7 +118,7 @@ class Asset {
118
118
  } else {
119
119
  const fileLocation2 = await downloadFileSync(this.info.id, HG_ASSET_PATH);
120
120
  this.initialized = true;
121
- return fileLocation;
121
+ return fileLocation2;
122
122
  }
123
123
  }
124
124
 
@@ -170,7 +170,7 @@ class Asset {
170
170
  const filePath = `${path}/${fileHash}`;
171
171
 
172
172
  const writeStream = this.fs.createWriteStream(filePath);
173
- const getModule = this.https;
173
+ const getModule = ASSET_URL.startsWith('https') ? this.https : this.http;
174
174
 
175
175
  writeStream.on('close', () => {
176
176
  resolve(filePath);
package/src/BaseNode.js CHANGED
@@ -104,7 +104,7 @@ class BaseNode {
104
104
  this.node.fill = params.fill;
105
105
  }
106
106
  if (params.coordinates2d) {
107
- this.node.coordinates2d = coordinates2d;
107
+ this.node.coordinates2d = params.coordinates2d;
108
108
  }
109
109
  }
110
110
  this.node.onStateChange();
package/src/Game.js CHANGED
@@ -11,7 +11,7 @@ class Game {
11
11
  }
12
12
 
13
13
  removeStateListener(listener) {
14
- this.listeners.remove(listener);
14
+ this.listeners.delete(listener);
15
15
  }
16
16
 
17
17
  findNode(id) {
package/src/Squisher.js CHANGED
@@ -42,7 +42,7 @@ class Squisher {
42
42
  }
43
43
 
44
44
  removeListener(listener) {
45
- this.listeners.remove(listener);
45
+ this.listeners.delete(listener);
46
46
  }
47
47
 
48
48
  unsquish(node) {
@@ -97,9 +97,7 @@ class Squisher {
97
97
  }
98
98
 
99
99
  handleNewAsset(key, asset) {
100
- return new Promise((resolve, reject) => {
101
- this.initialize().then(resolve);
102
- });
100
+ return this.initialize();
103
101
  }
104
102
 
105
103
  squishHelper(node, squishedNodes, scale = {x: 1, y: 1}, playerMap = {}, playerIdFilter = new Set()) {
@@ -197,6 +195,12 @@ class Squisher {
197
195
  let assetBundleSize = 0;
198
196
  let finishedCount = 0;
199
197
  const totalCount = Object.keys(allAssets).length;
198
+
199
+ if (totalCount === 0) {
200
+ this.assetBundle = [];
201
+ resolve([]);
202
+ return;
203
+ }
200
204
 
201
205
  for (const key in allAssets) {
202
206
  allAssets[key].getData().then(buf => {
@@ -237,11 +241,10 @@ class Squisher {
237
241
 
238
242
  if (finishedCount == totalCount) {
239
243
  const newAssetBundle = new Array(assetBundleSize);
240
- for (let index = 0; index < assetBundleSize; index++) {
241
- for (const key in this.assets) {
242
- for (let y = 0; y < this.assets[key].length; y++) {
243
- newAssetBundle[index++] = this.assets[key][y];
244
- }
244
+ let index = 0;
245
+ for (const key in this.assets) {
246
+ for (let y = 0; y < this.assets[key].length; y++) {
247
+ newAssetBundle[index++] = this.assets[key][y];
245
248
  }
246
249
  }
247
250
  this.assetBundle = newAssetBundle;
@@ -250,6 +253,7 @@ class Squisher {
250
253
  }).catch(err => {
251
254
  console.error('Unable to get asset data for key ' + key);
252
255
  console.error(err);
256
+ reject(err);
253
257
  });
254
258
  }
255
259