@loaders.gl/zip 4.0.0-alpha.9 → 4.0.0-beta.1
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/dist/dist.min.js +5143 -36
- package/dist/es5/filesystems/zip-filesystem.js +372 -0
- package/dist/es5/filesystems/zip-filesystem.js.map +1 -0
- package/dist/es5/hash-file-utility.js +130 -0
- package/dist/es5/hash-file-utility.js.map +1 -0
- package/dist/es5/index.js +80 -3
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/parse-zip/cd-file-header.js +163 -0
- package/dist/es5/parse-zip/cd-file-header.js.map +1 -0
- package/dist/es5/parse-zip/end-of-central-directory.js +98 -0
- package/dist/es5/parse-zip/end-of-central-directory.js.map +1 -0
- package/dist/es5/parse-zip/local-file-header.js +117 -0
- package/dist/es5/parse-zip/local-file-header.js.map +1 -0
- package/dist/es5/parse-zip/search-from-the-end.js +69 -0
- package/dist/es5/parse-zip/search-from-the-end.js.map +1 -0
- package/dist/es5/tar-builder.js +8 -8
- package/dist/es5/tar-builder.js.map +1 -1
- package/dist/es5/zip-loader.js +2 -4
- package/dist/es5/zip-loader.js.map +1 -1
- package/dist/es5/zip-writer.js +19 -10
- package/dist/es5/zip-writer.js.map +1 -1
- package/dist/esm/filesystems/zip-filesystem.js +99 -0
- package/dist/esm/filesystems/zip-filesystem.js.map +1 -0
- package/dist/esm/hash-file-utility.js +55 -0
- package/dist/esm/hash-file-utility.js.map +1 -0
- package/dist/esm/index.js +7 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/parse-zip/cd-file-header.js +54 -0
- package/dist/esm/parse-zip/cd-file-header.js.map +1 -0
- package/dist/esm/parse-zip/end-of-central-directory.js +31 -0
- package/dist/esm/parse-zip/end-of-central-directory.js.map +1 -0
- package/dist/esm/parse-zip/local-file-header.js +41 -0
- package/dist/esm/parse-zip/local-file-header.js.map +1 -0
- package/dist/esm/parse-zip/search-from-the-end.js +16 -0
- package/dist/esm/parse-zip/search-from-the-end.js.map +1 -0
- package/dist/esm/tar-builder.js +2 -2
- package/dist/esm/tar-builder.js.map +1 -1
- package/dist/esm/zip-loader.js +1 -2
- package/dist/esm/zip-loader.js.map +1 -1
- package/dist/esm/zip-writer.js +8 -5
- package/dist/esm/zip-writer.js.map +1 -1
- package/dist/filesystems/zip-filesystem.d.ts +45 -0
- package/dist/filesystems/zip-filesystem.d.ts.map +1 -0
- package/dist/hash-file-utility.d.ts +35 -0
- package/dist/hash-file-utility.d.ts.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/parse-zip/cd-file-header.d.ts +36 -0
- package/dist/parse-zip/cd-file-header.d.ts.map +1 -0
- package/dist/parse-zip/end-of-central-directory.d.ts +18 -0
- package/dist/parse-zip/end-of-central-directory.d.ts.map +1 -0
- package/dist/parse-zip/local-file-header.d.ts +28 -0
- package/dist/parse-zip/local-file-header.d.ts.map +1 -0
- package/dist/parse-zip/search-from-the-end.d.ts +11 -0
- package/dist/parse-zip/search-from-the-end.d.ts.map +1 -0
- package/dist/tar-builder.d.ts +2 -2
- package/dist/tar-builder.d.ts.map +1 -1
- package/dist/zip-loader.d.ts +0 -1
- package/dist/zip-loader.d.ts.map +1 -1
- package/dist/zip-writer.d.ts +12 -2
- package/dist/zip-writer.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/filesystems/zip-filesystem.ts +142 -0
- package/src/hash-file-utility.ts +101 -0
- package/src/index.ts +20 -1
- package/src/parse-zip/cd-file-header.ts +114 -0
- package/src/parse-zip/end-of-central-directory.ts +71 -0
- package/src/parse-zip/local-file-header.ts +95 -0
- package/src/parse-zip/search-from-the-end.ts +38 -0
- package/src/tar-builder.ts +2 -2
- package/src/zip-loader.ts +2 -3
- package/src/zip-writer.ts +23 -10
- package/dist/bundle.js +0 -5
- package/dist/index.js +0 -12
- package/dist/lib/tar/header.js +0 -99
- package/dist/lib/tar/tar.js +0 -131
- package/dist/lib/tar/types.js +0 -2
- package/dist/lib/tar/utils.js +0 -54
- package/dist/tar-builder.js +0 -38
- package/dist/zip-loader.js +0 -61
- package/dist/zip-writer.js +0 -37
package/dist/lib/tar/utils.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringToUint8 = exports.pad = exports.clean = void 0;
|
|
4
|
-
// This file is derived from the tar-js code base under MIT license
|
|
5
|
-
// See https://github.com/beatgammit/tar-js/blob/master/LICENSE
|
|
6
|
-
/*
|
|
7
|
-
* tar-js
|
|
8
|
-
* MIT (c) 2011 T. Jameson Little
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Returns the memory area specified by length
|
|
12
|
-
* @param length
|
|
13
|
-
* @returns {Uint8Array}
|
|
14
|
-
*/
|
|
15
|
-
function clean(length) {
|
|
16
|
-
let i;
|
|
17
|
-
const buffer = new Uint8Array(length);
|
|
18
|
-
for (i = 0; i < length; i += 1) {
|
|
19
|
-
buffer[i] = 0;
|
|
20
|
-
}
|
|
21
|
-
return buffer;
|
|
22
|
-
}
|
|
23
|
-
exports.clean = clean;
|
|
24
|
-
/**
|
|
25
|
-
* Converting data to a string
|
|
26
|
-
* @param num
|
|
27
|
-
* @param bytes
|
|
28
|
-
* @param base
|
|
29
|
-
* @returns string
|
|
30
|
-
*/
|
|
31
|
-
function pad(num, bytes, base) {
|
|
32
|
-
const numStr = num.toString(base || 8);
|
|
33
|
-
return '000000000000'.substr(numStr.length + 12 - bytes) + numStr;
|
|
34
|
-
}
|
|
35
|
-
exports.pad = pad;
|
|
36
|
-
/**
|
|
37
|
-
* Converting input to binary data
|
|
38
|
-
* @param input
|
|
39
|
-
* @param out
|
|
40
|
-
* @param offset
|
|
41
|
-
* @returns {Uint8Array}
|
|
42
|
-
*/
|
|
43
|
-
function stringToUint8(input, out, offset) {
|
|
44
|
-
let i;
|
|
45
|
-
let length;
|
|
46
|
-
out = out || clean(input.length);
|
|
47
|
-
offset = offset || 0;
|
|
48
|
-
for (i = 0, length = input.length; i < length; i += 1) {
|
|
49
|
-
out[offset] = input.charCodeAt(i);
|
|
50
|
-
offset += 1;
|
|
51
|
-
}
|
|
52
|
-
return out;
|
|
53
|
-
}
|
|
54
|
-
exports.stringToUint8 = stringToUint8;
|
package/dist/tar-builder.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const tar_1 = __importDefault(require("./lib/tar/tar"));
|
|
7
|
-
const TAR_BUILDER_OPTIONS = {
|
|
8
|
-
recordsPerBlock: 20
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Build a tar file by adding files
|
|
12
|
-
*/
|
|
13
|
-
class TARBuilder {
|
|
14
|
-
static get properties() {
|
|
15
|
-
return {
|
|
16
|
-
id: 'tar',
|
|
17
|
-
name: 'TAR',
|
|
18
|
-
extensions: ['tar'],
|
|
19
|
-
mimeTypes: ['application/x-tar'],
|
|
20
|
-
builder: TARBuilder,
|
|
21
|
-
options: TAR_BUILDER_OPTIONS
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
constructor(options) {
|
|
25
|
-
this.count = 0;
|
|
26
|
-
this.options = { ...TAR_BUILDER_OPTIONS, ...options };
|
|
27
|
-
this.tape = new tar_1.default(this.options.recordsPerBlock);
|
|
28
|
-
}
|
|
29
|
-
/** Adds a file to the archive. */
|
|
30
|
-
addFile(filename, buffer) {
|
|
31
|
-
this.tape.append(filename, new Uint8Array(buffer));
|
|
32
|
-
this.count++;
|
|
33
|
-
}
|
|
34
|
-
async build() {
|
|
35
|
-
return new Response(this.tape.save()).arrayBuffer();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.default = TARBuilder;
|
package/dist/zip-loader.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports._typecheckZipLoader = exports.ZipLoader = void 0;
|
|
7
|
-
const jszip_1 = __importDefault(require("jszip"));
|
|
8
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
9
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
10
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
11
|
-
exports.ZipLoader = {
|
|
12
|
-
id: 'zip',
|
|
13
|
-
module: 'zip',
|
|
14
|
-
name: 'Zip Archive',
|
|
15
|
-
version: VERSION,
|
|
16
|
-
extensions: ['zip'],
|
|
17
|
-
mimeTypes: ['application/zip'],
|
|
18
|
-
category: 'archive',
|
|
19
|
-
tests: ['PK'],
|
|
20
|
-
options: {},
|
|
21
|
-
parse: parseZipAsync
|
|
22
|
-
};
|
|
23
|
-
// TODO - Could return a map of promises, perhaps as an option...
|
|
24
|
-
async function parseZipAsync(data, options = {}) {
|
|
25
|
-
const promises = [];
|
|
26
|
-
const fileMap = {};
|
|
27
|
-
try {
|
|
28
|
-
const jsZip = new jszip_1.default();
|
|
29
|
-
const zip = await jsZip.loadAsync(data, options);
|
|
30
|
-
// start to load each file in this zip
|
|
31
|
-
zip.forEach((relativePath, zipEntry) => {
|
|
32
|
-
const subFilename = zipEntry.name;
|
|
33
|
-
const promise = loadZipEntry(jsZip, subFilename, options).then((arrayBufferOrError) => {
|
|
34
|
-
fileMap[relativePath] = arrayBufferOrError;
|
|
35
|
-
});
|
|
36
|
-
// Ensure Promise.all doesn't ignore rejected promises.
|
|
37
|
-
promises.push(promise);
|
|
38
|
-
});
|
|
39
|
-
await Promise.all(promises);
|
|
40
|
-
return fileMap;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
options.log.error(`Unable to read zip archive: ${error}`);
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async function loadZipEntry(jsZip, subFilename, options = {}) {
|
|
49
|
-
// jszip supports both arraybuffer and text, the main loaders.gl types
|
|
50
|
-
// https://stuk.github.io/jszip/documentation/api_zipobject/async.html
|
|
51
|
-
try {
|
|
52
|
-
const arrayBuffer = await jsZip.file(subFilename).async(options.dataType || 'arraybuffer');
|
|
53
|
-
return arrayBuffer;
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
options.log.error(`Unable to read ${subFilename} from zip archive: ${error}`);
|
|
57
|
-
// Store error in place of data in map
|
|
58
|
-
return error;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports._typecheckZipLoader = exports.ZipLoader;
|
package/dist/zip-writer.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ZipWriter = void 0;
|
|
7
|
-
const jszip_1 = __importDefault(require("jszip"));
|
|
8
|
-
/**
|
|
9
|
-
* Zip exporter
|
|
10
|
-
*/
|
|
11
|
-
exports.ZipWriter = {
|
|
12
|
-
name: 'Zip Archive',
|
|
13
|
-
extensions: ['zip'],
|
|
14
|
-
category: 'archive',
|
|
15
|
-
mimeTypes: ['application/zip'],
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
encode: encodeZipAsync
|
|
18
|
-
};
|
|
19
|
-
async function encodeZipAsync(fileMap, options = {}) {
|
|
20
|
-
const jsZip = new jszip_1.default();
|
|
21
|
-
// add files to the zip
|
|
22
|
-
for (const subFileName in fileMap) {
|
|
23
|
-
const subFileData = fileMap[subFileName];
|
|
24
|
-
// jszip supports both arraybuffer and string data (the main loaders.gl types)
|
|
25
|
-
// https://stuk.github.io/jszip/documentation/api_zipobject/async.html
|
|
26
|
-
jsZip.file(subFileName, subFileData, options);
|
|
27
|
-
}
|
|
28
|
-
// always generate the full zip as an arraybuffer
|
|
29
|
-
options = Object.assign({}, options, {
|
|
30
|
-
type: 'arraybuffer'
|
|
31
|
-
});
|
|
32
|
-
const { onUpdate = () => { } } = options;
|
|
33
|
-
return jsZip.generateAsync(options, onUpdate).catch((error) => {
|
|
34
|
-
options.log.error(`Unable to write zip archive: ${error}`);
|
|
35
|
-
throw error;
|
|
36
|
-
});
|
|
37
|
-
}
|