@rpg-engine/shared 0.2.93 → 0.2.97
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,7 +1,6 @@
|
|
|
1
|
-
declare class MapZipHelper {
|
|
2
|
-
createZipMap(mapName: string, mapObject: object, pathToSave: string): Promise<void>;
|
|
1
|
+
export declare class MapZipHelper {
|
|
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
|
-
export {};
|
|
7
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":"AAMA,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"}
|
|
@@ -9,14 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.mapZipHelper = void 0;
|
|
13
|
-
const
|
|
12
|
+
exports.mapZipHelper = exports.MapZipHelper = void 0;
|
|
13
|
+
const { compress, decompress } = require("compress-json");
|
|
14
|
+
const fetch = require("node-fetch");
|
|
15
|
+
const File = require("file-class");
|
|
14
16
|
const fs = require("fs");
|
|
15
17
|
const JSZip = require("jszip");
|
|
16
18
|
class MapZipHelper {
|
|
17
|
-
createZipMap(mapName, mapObject, pathToSave) {
|
|
19
|
+
static createZipMap(mapName, mapObject, pathToSave) {
|
|
18
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const data =
|
|
21
|
+
const data = compress(mapObject);
|
|
20
22
|
const zip = new JSZip();
|
|
21
23
|
zip.file(`${mapName}.txt`, JSON.stringify(data));
|
|
22
24
|
const buffer = yield zip.generateAsync({ type: "uint8array" });
|
|
@@ -25,15 +27,20 @@ class MapZipHelper {
|
|
|
25
27
|
}
|
|
26
28
|
readZip(fileName, filePath) {
|
|
27
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const data = yield
|
|
30
|
+
const data = yield (yield fetch(filePath)).blob();
|
|
31
|
+
const file = new File([data], fileName, { type: "application/zip" });
|
|
29
32
|
const zipRead = new JSZip();
|
|
30
|
-
const content = yield zipRead.loadAsync(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const content = yield zipRead.loadAsync(file);
|
|
34
|
+
if (content.files && content.files[`${fileName}.txt`]) {
|
|
35
|
+
const txtFile = content.files[`${fileName}.txt`]._data.compressedContent;
|
|
36
|
+
const bufferedString = Buffer.from(txtFile).toString();
|
|
37
|
+
const fileContent = decompress(JSON.parse(bufferedString));
|
|
38
|
+
return fileContent;
|
|
39
|
+
}
|
|
40
|
+
return {};
|
|
35
41
|
});
|
|
36
42
|
}
|
|
37
43
|
}
|
|
44
|
+
exports.MapZipHelper = MapZipHelper;
|
|
38
45
|
exports.mapZipHelper = new MapZipHelper();
|
|
39
46
|
//# sourceMappingURL=MapZipHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapZipHelper.js","sourceRoot":"","sources":["../../src/libs/MapZipHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
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M,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.97",
|
|
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
|
}
|