@loaders.gl/zip 4.2.0-alpha.3 → 4.2.0-alpha.5

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.
Files changed (56) hide show
  1. package/dist/dist.dev.js +924 -543
  2. package/dist/dist.min.js +25 -0
  3. package/dist/filesystems/IndexedArchive.js +24 -12
  4. package/dist/filesystems/zip-filesystem.d.ts +2 -2
  5. package/dist/filesystems/zip-filesystem.d.ts.map +1 -1
  6. package/dist/filesystems/zip-filesystem.js +121 -88
  7. package/dist/hash-file-utility.d.ts +1 -1
  8. package/dist/hash-file-utility.d.ts.map +1 -1
  9. package/dist/hash-file-utility.js +86 -40
  10. package/dist/index.cjs +53 -126
  11. package/dist/index.cjs.map +7 -0
  12. package/dist/index.d.ts +12 -12
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +4 -1
  15. package/dist/lib/tar/header.d.ts +1 -1
  16. package/dist/lib/tar/header.d.ts.map +1 -1
  17. package/dist/lib/tar/header.js +69 -33
  18. package/dist/lib/tar/tar.d.ts +1 -1
  19. package/dist/lib/tar/tar.d.ts.map +1 -1
  20. package/dist/lib/tar/tar.js +121 -106
  21. package/dist/lib/tar/types.js +3 -1
  22. package/dist/lib/tar/utils.js +45 -18
  23. package/dist/parse-zip/cd-file-header.d.ts +1 -1
  24. package/dist/parse-zip/cd-file-header.d.ts.map +1 -1
  25. package/dist/parse-zip/cd-file-header.js +239 -177
  26. package/dist/parse-zip/end-of-central-directory.js +247 -158
  27. package/dist/parse-zip/local-file-header.d.ts +1 -1
  28. package/dist/parse-zip/local-file-header.d.ts.map +1 -1
  29. package/dist/parse-zip/local-file-header.js +143 -102
  30. package/dist/parse-zip/search-from-the-end.js +27 -13
  31. package/dist/parse-zip/zip-composition.js +142 -92
  32. package/dist/parse-zip/zip64-info-generation.js +64 -41
  33. package/dist/tar-builder.d.ts +1 -1
  34. package/dist/tar-builder.d.ts.map +1 -1
  35. package/dist/tar-builder.js +30 -29
  36. package/dist/zip-loader.js +52 -41
  37. package/dist/zip-writer.js +40 -40
  38. package/package.json +11 -7
  39. package/src/hash-file-utility.ts +7 -1
  40. package/dist/filesystems/IndexedArchive.js.map +0 -1
  41. package/dist/filesystems/zip-filesystem.js.map +0 -1
  42. package/dist/hash-file-utility.js.map +0 -1
  43. package/dist/index.js.map +0 -1
  44. package/dist/lib/tar/header.js.map +0 -1
  45. package/dist/lib/tar/tar.js.map +0 -1
  46. package/dist/lib/tar/types.js.map +0 -1
  47. package/dist/lib/tar/utils.js.map +0 -1
  48. package/dist/parse-zip/cd-file-header.js.map +0 -1
  49. package/dist/parse-zip/end-of-central-directory.js.map +0 -1
  50. package/dist/parse-zip/local-file-header.js.map +0 -1
  51. package/dist/parse-zip/search-from-the-end.js.map +0 -1
  52. package/dist/parse-zip/zip-composition.js.map +0 -1
  53. package/dist/parse-zip/zip64-info-generation.js.map +0 -1
  54. package/dist/tar-builder.js.map +0 -1
  55. package/dist/zip-loader.js.map +0 -1
  56. package/dist/zip-writer.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- export { ZipLoader } from './zip-loader';
2
- export { ZipWriter } from './zip-writer';
3
- export { TarBuilder } from './tar-builder';
4
- export { parseZipCDFileHeader, makeZipCDHeaderIterator, signature as CD_HEADER_SIGNATURE, generateCDHeader } from './parse-zip/cd-file-header';
5
- export { parseZipLocalFileHeader, signature as localHeaderSignature, generateLocalHeader } from './parse-zip/local-file-header';
6
- export { parseEoCDRecord } from './parse-zip/end-of-central-directory';
7
- export { searchFromTheEnd } from './parse-zip/search-from-the-end';
8
- export { addOneFile, createZip } from './parse-zip/zip-composition';
9
- export { IndexedArchive } from './filesystems/IndexedArchive';
10
- export { parseHashTable, makeHashTableFromZipHeaders, composeHashFile } from './hash-file-utility';
11
- export { ZipFileSystem, ZIP_COMPRESSION_HANDLERS } from './filesystems/zip-filesystem';
12
- export type { CompressionHandler } from './filesystems/zip-filesystem';
1
+ export { ZipLoader } from "./zip-loader.js";
2
+ export { ZipWriter } from "./zip-writer.js";
3
+ export { TarBuilder } from "./tar-builder.js";
4
+ export { parseZipCDFileHeader, makeZipCDHeaderIterator, signature as CD_HEADER_SIGNATURE, generateCDHeader } from "./parse-zip/cd-file-header.js";
5
+ export { parseZipLocalFileHeader, signature as localHeaderSignature, generateLocalHeader } from "./parse-zip/local-file-header.js";
6
+ export { parseEoCDRecord } from "./parse-zip/end-of-central-directory.js";
7
+ export { searchFromTheEnd } from "./parse-zip/search-from-the-end.js";
8
+ export { addOneFile, createZip } from "./parse-zip/zip-composition.js";
9
+ export { IndexedArchive } from "./filesystems/IndexedArchive.js";
10
+ export { parseHashTable, makeHashTableFromZipHeaders, composeHashFile } from "./hash-file-utility.js";
11
+ export { ZipFileSystem, ZIP_COMPRESSION_HANDLERS } from "./filesystems/zip-filesystem.js";
12
+ export type { CompressionHandler } from "./filesystems/zip-filesystem.js";
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,SAAS,IAAI,mBAAmB,EAChC,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,uBAAuB,EACvB,SAAS,IAAI,oBAAoB,EACjC,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,6BAA6B,CAAC;AAGlE,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAC,cAAc,EAAE,2BAA2B,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAEjG,OAAO,EAAC,aAAa,EAAE,wBAAwB,EAAC,MAAM,8BAA8B,CAAC;AACrF,YAAY,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAC,wBAAqB;AACvC,OAAO,EAAC,SAAS,EAAC,wBAAqB;AACvC,OAAO,EAAC,UAAU,EAAC,yBAAsB;AAEzC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,SAAS,IAAI,mBAAmB,EAChC,gBAAgB,EACjB,sCAAmC;AACpC,OAAO,EACL,uBAAuB,EACvB,SAAS,IAAI,oBAAoB,EACjC,mBAAmB,EACpB,yCAAsC;AACvC,OAAO,EAAC,eAAe,EAAC,gDAA6C;AACrE,OAAO,EAAC,gBAAgB,EAAC,2CAAwC;AACjE,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,uCAAoC;AAGlE,OAAO,EAAC,cAAc,EAAC,wCAAqC;AAC5D,OAAO,EAAC,cAAc,EAAE,2BAA2B,EAAE,eAAe,EAAC,+BAA4B;AAEjG,OAAO,EAAC,aAAa,EAAE,wBAAwB,EAAC,wCAAqC;AACrF,YAAY,EAAC,kBAAkB,EAAC,wCAAqC"}
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  export { ZipLoader } from "./zip-loader.js";
2
5
  export { ZipWriter } from "./zip-writer.js";
3
6
  export { TarBuilder } from "./tar-builder.js";
@@ -6,7 +9,7 @@ export { parseZipLocalFileHeader, signature as localHeaderSignature, generateLoc
6
9
  export { parseEoCDRecord } from "./parse-zip/end-of-central-directory.js";
7
10
  export { searchFromTheEnd } from "./parse-zip/search-from-the-end.js";
8
11
  export { addOneFile, createZip } from "./parse-zip/zip-composition.js";
12
+ // export type {HashElement} from './hash-file-utility';
9
13
  export { IndexedArchive } from "./filesystems/IndexedArchive.js";
10
14
  export { parseHashTable, makeHashTableFromZipHeaders, composeHashFile } from "./hash-file-utility.js";
11
15
  export { ZipFileSystem, ZIP_COMPRESSION_HANDLERS } from "./filesystems/zip-filesystem.js";
12
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import type { TarData } from './types';
1
+ import type { TarData } from "./types.js";
2
2
  /**
3
3
  * Getting the header
4
4
  * @param data
@@ -1 +1 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/lib/tar/header.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAe,OAAO,EAAC,MAAM,SAAS,CAAC;AAyCnD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAsB/E"}
1
+ {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/lib/tar/header.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAe,OAAO,EAAC,mBAAgB;AAyCnD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAsB/E"}
@@ -1,39 +1,75 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
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
+ /* eslint-disable */
1
11
  import * as utils from "./utils.js";
12
+ /*
13
+ struct posix_header { // byte offset
14
+ char name[100]; // 0
15
+ char mode[8]; // 100
16
+ char uid[8]; // 108
17
+ char gid[8]; // 116
18
+ char size[12]; // 124
19
+ char mtime[12]; // 136
20
+ char chksum[8]; // 148
21
+ char typeflag; // 156
22
+ char linkname[100]; // 157
23
+ char magic[6]; // 257
24
+ char version[2]; // 263
25
+ char uname[32]; // 265
26
+ char gname[32]; // 297
27
+ char devmajor[8]; // 329
28
+ char devminor[8]; // 337
29
+ char prefix[155]; // 345
30
+ // 500
31
+ };
32
+ */
2
33
  const structure = {
3
- fileName: 100,
4
- fileMode: 8,
5
- uid: 8,
6
- gid: 8,
7
- fileSize: 12,
8
- mtime: 12,
9
- checksum: 8,
10
- type: 1,
11
- linkName: 100,
12
- ustar: 8,
13
- owner: 32,
14
- group: 32,
15
- majorNumber: 8,
16
- minorNumber: 8,
17
- filenamePrefix: 155,
18
- padding: 12
34
+ fileName: 100,
35
+ fileMode: 8,
36
+ uid: 8,
37
+ gid: 8,
38
+ fileSize: 12,
39
+ mtime: 12,
40
+ checksum: 8,
41
+ type: 1,
42
+ linkName: 100,
43
+ ustar: 8,
44
+ owner: 32,
45
+ group: 32,
46
+ majorNumber: 8,
47
+ minorNumber: 8,
48
+ filenamePrefix: 155,
49
+ padding: 12
19
50
  };
51
+ /**
52
+ * Getting the header
53
+ * @param data
54
+ * @param [cb]
55
+ * @returns {Uint8Array} | Array
56
+ */
20
57
  export function format(data, cb) {
21
- const buffer = utils.clean(512);
22
- let offset = 0;
23
- Object.entries(structure).forEach(_ref => {
24
- let [field, length] = _ref;
25
- const str = data[field] || '';
26
- let i;
27
- let fieldLength;
28
- for (i = 0, fieldLength = str.length; i < fieldLength; i += 1) {
29
- buffer[offset] = str.charCodeAt(i);
30
- offset += 1;
58
+ const buffer = utils.clean(512);
59
+ let offset = 0;
60
+ Object.entries(structure).forEach(([field, length]) => {
61
+ const str = data[field] || '';
62
+ let i;
63
+ let fieldLength;
64
+ for (i = 0, fieldLength = str.length; i < fieldLength; i += 1) {
65
+ buffer[offset] = str.charCodeAt(i);
66
+ offset += 1;
67
+ }
68
+ // space it out with nulls
69
+ offset += length - i;
70
+ });
71
+ if (typeof cb === 'function') {
72
+ return cb(buffer, offset);
31
73
  }
32
- offset += length - i;
33
- });
34
- if (typeof cb === 'function') {
35
- return cb(buffer, offset);
36
- }
37
- return buffer;
74
+ return buffer;
38
75
  }
39
- //# sourceMappingURL=header.js.map
@@ -1,4 +1,4 @@
1
- import type { TarBlocks, TarOptions } from './types';
1
+ import type { TarBlocks, TarOptions } from "./types.js";
2
2
  declare class Tar {
3
3
  written: number;
4
4
  out: Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../../src/lib/tar/tar.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAC,SAAS,EAAE,UAAU,EAAsB,MAAM,SAAS,CAAC;AAQxE,cAAM,GAAG;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,UAAU,CAAC;IAChB,MAAM,EAAE,SAAS,CAAM;IACvB,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;gBACS,eAAe,EAAE,MAAM,GAAG,SAAS;IAY/C;;;;;OAKG;IAEH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS;IA+DlF;;;OAGG;IACH,IAAI,IAAI,IAAI;IAkCZ;;OAEG;IACH,KAAK;CAIN;AAED,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../../src/lib/tar/tar.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAC,SAAS,EAAE,UAAU,EAAsB,mBAAgB;AAQxE,cAAM,GAAG;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,UAAU,CAAC;IAChB,MAAM,EAAE,SAAS,CAAM;IACvB,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;gBACS,eAAe,EAAE,MAAM,GAAG,SAAS;IAY/C;;;;;OAKG;IAEH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS;IA+DlF;;;OAGG;IACH,IAAI,IAAI,IAAI;IAkCZ;;OAEG;IACH,KAAK;CAIN;AAED,eAAe,GAAG,CAAC"}
@@ -1,3 +1,12 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
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
+ */
1
10
  import { clean, pad, stringToUint8 } from "./utils.js";
2
11
  import { format } from "./header.js";
3
12
  let blockSize;
@@ -5,113 +14,119 @@ let headerLength;
5
14
  let inputLength;
6
15
  const recordSize = 512;
7
16
  class Tar {
8
- constructor(recordsPerBlock) {
9
- this.written = void 0;
10
- this.out = void 0;
11
- this.blocks = [];
12
- this.length = void 0;
13
- this.written = 0;
14
- blockSize = (recordsPerBlock || 20) * recordSize;
15
- this.out = clean(blockSize);
16
- this.blocks = [];
17
- this.length = 0;
18
- this.save = this.save.bind(this);
19
- this.clear = this.clear.bind(this);
20
- this.append = this.append.bind(this);
21
- }
22
- append(filepath, input, opts) {
23
- let checksum;
24
- if (typeof input === 'string') {
25
- input = stringToUint8(input);
26
- } else if (input.constructor && input.constructor !== Uint8Array.prototype.constructor) {
27
- const errorInputMatch = /function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/.exec(input.constructor.toString());
28
- const errorInput = errorInputMatch && errorInputMatch[1];
29
- const errorMessage = `Invalid input type. You gave me: ${errorInput}`;
30
- throw errorMessage;
17
+ /**
18
+ * @param [recordsPerBlock]
19
+ */
20
+ constructor(recordsPerBlock) {
21
+ this.blocks = [];
22
+ this.written = 0;
23
+ blockSize = (recordsPerBlock || 20) * recordSize;
24
+ this.out = clean(blockSize);
25
+ this.blocks = [];
26
+ this.length = 0;
27
+ this.save = this.save.bind(this);
28
+ this.clear = this.clear.bind(this);
29
+ this.append = this.append.bind(this);
31
30
  }
32
- opts = opts || {};
33
- const mode = opts.mode || parseInt('777', 8) & 0xfff;
34
- const mtime = opts.mtime || Math.floor(Number(new Date()) / 1000);
35
- const uid = opts.uid || 0;
36
- const gid = opts.gid || 0;
37
- const data = {
38
- fileName: filepath,
39
- fileMode: pad(mode, 7),
40
- uid: pad(uid, 7),
41
- gid: pad(gid, 7),
42
- fileSize: pad(input.length, 11),
43
- mtime: pad(mtime, 11),
44
- checksum: ' ',
45
- type: '0',
46
- ustar: 'ustar ',
47
- owner: opts.owner || '',
48
- group: opts.group || ''
49
- };
50
- checksum = 0;
51
- Object.keys(data).forEach(key => {
52
- let i;
53
- const value = data[key];
54
- let length;
55
- for (i = 0, length = value.length; i < length; i += 1) {
56
- checksum += value.charCodeAt(i);
57
- }
58
- });
59
- data.checksum = `${pad(checksum, 6)}\u0000 `;
60
- const headerArr = format(data);
61
- headerLength = Math.ceil(headerArr.length / recordSize) * recordSize;
62
- inputLength = Math.ceil(input.length / recordSize) * recordSize;
63
- this.blocks.push({
64
- header: headerArr,
65
- input,
66
- headerLength,
67
- inputLength
68
- });
69
- }
70
- save() {
71
- const buffers = [];
72
- const chunks = new Array();
73
- let length = 0;
74
- const max = Math.pow(2, 20);
75
- let chunk = new Array();
76
- this.blocks.forEach(function () {
77
- let b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
78
- if (length + b.headerLength + b.inputLength > max) {
79
- chunks.push({
80
- blocks: chunk,
81
- length
31
+ /**
32
+ * Append a file to the tar archive
33
+ * @param filepath
34
+ * @param input
35
+ * @param [opts]
36
+ */
37
+ // eslint-disable-next-line complexity
38
+ append(filepath, input, opts) {
39
+ let checksum;
40
+ if (typeof input === 'string') {
41
+ input = stringToUint8(input);
42
+ }
43
+ else if (input.constructor && input.constructor !== Uint8Array.prototype.constructor) {
44
+ // @ts-ignore
45
+ const errorInputMatch = /function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/.exec(input.constructor.toString());
46
+ const errorInput = errorInputMatch && errorInputMatch[1];
47
+ const errorMessage = `Invalid input type. You gave me: ${errorInput}`;
48
+ throw errorMessage;
49
+ }
50
+ opts = opts || {};
51
+ const mode = opts.mode || parseInt('777', 8) & 0xfff;
52
+ const mtime = opts.mtime || Math.floor(Number(new Date()) / 1000);
53
+ const uid = opts.uid || 0;
54
+ const gid = opts.gid || 0;
55
+ const data = {
56
+ fileName: filepath,
57
+ fileMode: pad(mode, 7),
58
+ uid: pad(uid, 7),
59
+ gid: pad(gid, 7),
60
+ fileSize: pad(input.length, 11),
61
+ mtime: pad(mtime, 11),
62
+ checksum: ' ',
63
+ // 0 = just a file
64
+ type: '0',
65
+ ustar: 'ustar ',
66
+ owner: opts.owner || '',
67
+ group: opts.group || ''
68
+ };
69
+ // calculate the checksum
70
+ checksum = 0;
71
+ Object.keys(data).forEach((key) => {
72
+ let i;
73
+ const value = data[key];
74
+ let length;
75
+ for (i = 0, length = value.length; i < length; i += 1) {
76
+ checksum += value.charCodeAt(i);
77
+ }
82
78
  });
83
- chunk = [];
84
- length = 0;
85
- }
86
- chunk.push(b);
87
- length += b.headerLength + b.inputLength;
88
- });
89
- chunks.push({
90
- blocks: chunk,
91
- length
92
- });
93
- chunks.forEach(function () {
94
- let c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
95
- const buffer = new Uint8Array(c.length);
96
- let written = 0;
97
- c.blocks.forEach(function () {
98
- let b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
99
- buffer.set(b.header, written);
100
- written += b.headerLength;
101
- buffer.set(b.input, written);
102
- written += b.inputLength;
103
- });
104
- buffers.push(buffer);
105
- });
106
- buffers.push(new Uint8Array(2 * recordSize));
107
- return new Blob(buffers, {
108
- type: 'octet/stream'
109
- });
110
- }
111
- clear() {
112
- this.written = 0;
113
- this.out = clean(blockSize);
114
- }
79
+ data.checksum = `${pad(checksum, 6)}\u0000 `;
80
+ const headerArr = format(data);
81
+ headerLength = Math.ceil(headerArr.length / recordSize) * recordSize;
82
+ inputLength = Math.ceil(input.length / recordSize) * recordSize;
83
+ this.blocks.push({
84
+ header: headerArr,
85
+ input,
86
+ headerLength,
87
+ inputLength
88
+ });
89
+ }
90
+ /**
91
+ * Compiling data to a Blob object
92
+ * @returns {Blob}
93
+ */
94
+ save() {
95
+ const buffers = [];
96
+ const chunks = new Array();
97
+ let length = 0;
98
+ const max = Math.pow(2, 20);
99
+ let chunk = new Array();
100
+ this.blocks.forEach((b = []) => {
101
+ if (length + b.headerLength + b.inputLength > max) {
102
+ chunks.push({ blocks: chunk, length });
103
+ chunk = [];
104
+ length = 0;
105
+ }
106
+ chunk.push(b);
107
+ length += b.headerLength + b.inputLength;
108
+ });
109
+ chunks.push({ blocks: chunk, length });
110
+ chunks.forEach((c = []) => {
111
+ const buffer = new Uint8Array(c.length);
112
+ let written = 0;
113
+ c.blocks.forEach((b = []) => {
114
+ buffer.set(b.header, written);
115
+ written += b.headerLength;
116
+ buffer.set(b.input, written);
117
+ written += b.inputLength;
118
+ });
119
+ buffers.push(buffer);
120
+ });
121
+ buffers.push(new Uint8Array(2 * recordSize));
122
+ return new Blob(buffers, { type: 'octet/stream' });
123
+ }
124
+ /**
125
+ * Clear the data by its blocksize
126
+ */
127
+ clear() {
128
+ this.written = 0;
129
+ this.out = clean(blockSize);
130
+ }
115
131
  }
116
132
  export default Tar;
117
- //# sourceMappingURL=tar.js.map
@@ -1,2 +1,4 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,24 +1,51 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
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
+ */
1
15
  export function clean(length) {
2
- let i;
3
- const buffer = new Uint8Array(length);
4
- for (i = 0; i < length; i += 1) {
5
- buffer[i] = 0;
6
- }
7
- return buffer;
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;
8
22
  }
23
+ /**
24
+ * Converting data to a string
25
+ * @param num
26
+ * @param bytes
27
+ * @param base
28
+ * @returns string
29
+ */
9
30
  export function pad(num, bytes, base) {
10
- const numStr = num.toString(base || 8);
11
- return '000000000000'.substr(numStr.length + 12 - bytes) + numStr;
31
+ const numStr = num.toString(base || 8);
32
+ return '000000000000'.substr(numStr.length + 12 - bytes) + numStr;
12
33
  }
34
+ /**
35
+ * Converting input to binary data
36
+ * @param input
37
+ * @param out
38
+ * @param offset
39
+ * @returns {Uint8Array}
40
+ */
13
41
  export function stringToUint8(input, out, offset) {
14
- let i;
15
- let length;
16
- out = out || clean(input.length);
17
- offset = offset || 0;
18
- for (i = 0, length = input.length; i < length; i += 1) {
19
- out[offset] = input.charCodeAt(i);
20
- offset += 1;
21
- }
22
- return out;
42
+ let i;
43
+ let length;
44
+ out = out || clean(input.length);
45
+ offset = offset || 0;
46
+ for (i = 0, length = input.length; i < length; i += 1) {
47
+ out[offset] = input.charCodeAt(i);
48
+ offset += 1;
49
+ }
50
+ return out;
23
51
  }
24
- //# sourceMappingURL=utils.js.map
@@ -1,5 +1,5 @@
1
1
  import { FileProvider } from '@loaders.gl/loader-utils';
2
- import { ZipSignature } from './search-from-the-end';
2
+ import { ZipSignature } from "./search-from-the-end.js";
3
3
  /**
4
4
  * zip central directory file header info
5
5
  * according to https://en.wikipedia.org/wiki/ZIP_(file_format)
@@ -1 +1 @@
1
- {"version":3,"file":"cd-file-header.d.ts","sourceRoot":"","sources":["../../src/parse-zip/cd-file-header.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAA+C,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAGnD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAyBF,eAAO,MAAM,SAAS,EAAE,YAAuD,CAAC;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,iBACjB,MAAM,QACd,YAAY,KACjB,QAAQ,eAAe,GAAG,IAAI,CA2ChC,CAAC;AAEF;;;GAGG;AACH,wBAAuB,uBAAuB,CAC5C,YAAY,EAAE,YAAY,GACzB,aAAa,CAAC,eAAe,CAAC,CAUhC;AAoED,6CAA6C;AAC7C,KAAK,iBAAiB,GAAG;IACvB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,CAuCxE"}
1
+ {"version":3,"file":"cd-file-header.d.ts","sourceRoot":"","sources":["../../src/parse-zip/cd-file-header.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAA+C,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAC,YAAY,EAAC,iCAA8B;AAGnD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAyBF,eAAO,MAAM,SAAS,EAAE,YAAuD,CAAC;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,iBACjB,MAAM,QACd,YAAY,KACjB,QAAQ,eAAe,GAAG,IAAI,CA2ChC,CAAC;AAEF;;;GAGG;AACH,wBAAuB,uBAAuB,CAC5C,YAAY,EAAE,YAAY,GACzB,aAAa,CAAC,eAAe,CAAC,CAUhC;AAoED,6CAA6C;AAC7C,KAAK,iBAAiB,GAAG;IACvB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,CAuCxE"}