@rpg-engine/shared 0.2.95 → 0.2.99
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class MapZipHelper {
|
|
2
2
|
static createZipMap(mapName: string, mapObject: object, pathToSave: string): Promise<void>;
|
|
3
|
-
|
|
3
|
+
readZip(fileName: any, filePath: any): Promise<object>;
|
|
4
4
|
}
|
|
5
5
|
export declare const mapZipHelper: MapZipHelper;
|
|
6
6
|
//# sourceMappingURL=MapZipHelper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapZipHelper.d.ts","sourceRoot":"","sources":["../../src/libs/MapZipHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapZipHelper.d.ts","sourceRoot":"","sources":["../../src/libs/MapZipHelper.ts"],"names":[],"mappings":"AAYA,qBAAa,YAAY;WACV,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1F,OAAO,CAAC,QAAQ,KAAA,EAAE,QAAQ,KAAA,GAAG,OAAO,CAAC,MAAM,CAAC;CAkBnD;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
|
@@ -10,10 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.mapZipHelper = exports.MapZipHelper = void 0;
|
|
13
|
-
const compress = require("compress-json");
|
|
14
|
-
const decompress = require("compress-json");
|
|
13
|
+
const { compress, decompress } = require("compress-json");
|
|
15
14
|
const fs = require("fs");
|
|
16
15
|
const JSZip = require("jszip");
|
|
16
|
+
let fetch = null;
|
|
17
|
+
let file = null;
|
|
18
|
+
Promise.resolve().then(() => require("node-fetch")).then(f => {
|
|
19
|
+
fetch = f;
|
|
20
|
+
});
|
|
21
|
+
Promise.resolve().then(() => require("file-class")).then(f => {
|
|
22
|
+
file = f;
|
|
23
|
+
});
|
|
17
24
|
class MapZipHelper {
|
|
18
25
|
static createZipMap(mapName, mapObject, pathToSave) {
|
|
19
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -24,15 +31,19 @@ class MapZipHelper {
|
|
|
24
31
|
yield fs.createWriteStream(`${pathToSave}/${mapName}.zip`).write(buffer);
|
|
25
32
|
});
|
|
26
33
|
}
|
|
27
|
-
|
|
34
|
+
readZip(fileName, filePath) {
|
|
28
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const data = yield
|
|
36
|
+
const data = yield (yield fetch(filePath)).blob();
|
|
37
|
+
const file = new File([data], fileName, { type: "application/zip" });
|
|
30
38
|
const zipRead = new JSZip();
|
|
31
|
-
const content = yield zipRead.loadAsync(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
const content = yield zipRead.loadAsync(file);
|
|
40
|
+
if (content.files && content.files[`${fileName}.txt`]) {
|
|
41
|
+
const txtFile = content.files[`${fileName}.txt`]._data.compressedContent;
|
|
42
|
+
const bufferedString = Buffer.from(txtFile).toString();
|
|
43
|
+
const fileContent = decompress(JSON.parse(bufferedString));
|
|
44
|
+
return fileContent;
|
|
45
|
+
}
|
|
46
|
+
return {};
|
|
36
47
|
});
|
|
37
48
|
}
|
|
38
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapZipHelper.js","sourceRoot":"","sources":["../../src/libs/MapZipHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"MapZipHelper.js","sourceRoot":"","sources":["../../src/libs/MapZipHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,EAAE,QAAQ,EAAE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E,MAAM,OAAO,GAAG,IAAI,KAAK,EAAE,CAAC;YAC5B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAE9C,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,QAAQ,MAAM,CAAC,EAAE;gBAErD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;gBACzE,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACvD,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;gBAC3D,OAAO,WAAW,CAAC;aACpB;YAED,OAAO,EAAE,CAAC;QACZ,CAAC;KAAA;CACF;AA3BD,oCA2BC;AAEY,QAAA,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpg-engine/shared",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.99",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Joao Paulo Furtado <joaopaulofurtado@live.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"@rpg-engine/shared": "^0.2.51",
|
|
39
39
|
"@types/mongoose": "^5.11.97",
|
|
40
40
|
"compress-json": "^2.0.1",
|
|
41
|
-
"
|
|
41
|
+
"file-class": "^0.1.3",
|
|
42
|
+
"jszip": "^3.10.0",
|
|
43
|
+
"node-fetch": "^3.2.5"
|
|
42
44
|
}
|
|
43
45
|
}
|