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 +1 -1
- package/src/Asset.js +3 -3
- package/src/BaseNode.js +1 -1
- package/src/Game.js +1 -1
- package/src/Squisher.js +13 -9
package/package.json
CHANGED
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
|
|
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
package/src/Game.js
CHANGED
package/src/Squisher.js
CHANGED
|
@@ -42,7 +42,7 @@ class Squisher {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
removeListener(listener) {
|
|
45
|
-
this.listeners.
|
|
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
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|