@loaders.gl/zip 4.0.0-alpha.22 → 4.0.0-alpha.24

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 (109) hide show
  1. package/dist/dist.min.js +156 -181
  2. package/dist/es5/filesystems/zip-filesystem.js +4 -6
  3. package/dist/es5/filesystems/zip-filesystem.js.map +1 -1
  4. package/dist/es5/hash-file-utility.js.map +1 -1
  5. package/dist/es5/index.js +2 -17
  6. package/dist/es5/index.js.map +1 -1
  7. package/dist/es5/parse-zip/cd-file-header.js.map +1 -1
  8. package/dist/es5/parse-zip/end-of-central-directory.js.map +1 -1
  9. package/dist/es5/parse-zip/local-file-header.js.map +1 -1
  10. package/dist/es5/parse-zip/search-from-the-end.js.map +1 -1
  11. package/dist/es5/tar-builder.js +8 -8
  12. package/dist/es5/tar-builder.js.map +1 -1
  13. package/dist/es5/zip-loader.js +2 -4
  14. package/dist/es5/zip-loader.js.map +1 -1
  15. package/dist/es5/zip-writer.js +19 -10
  16. package/dist/es5/zip-writer.js.map +1 -1
  17. package/dist/esm/filesystems/zip-filesystem.js +3 -3
  18. package/dist/esm/filesystems/zip-filesystem.js.map +1 -1
  19. package/dist/esm/hash-file-utility.js.map +1 -1
  20. package/dist/esm/index.js +1 -3
  21. package/dist/esm/index.js.map +1 -1
  22. package/dist/esm/parse-zip/cd-file-header.js.map +1 -1
  23. package/dist/esm/parse-zip/end-of-central-directory.js.map +1 -1
  24. package/dist/esm/parse-zip/local-file-header.js.map +1 -1
  25. package/dist/esm/parse-zip/search-from-the-end.js.map +1 -1
  26. package/dist/esm/tar-builder.js +2 -2
  27. package/dist/esm/tar-builder.js.map +1 -1
  28. package/dist/esm/zip-loader.js +1 -2
  29. package/dist/esm/zip-loader.js.map +1 -1
  30. package/dist/esm/zip-writer.js +8 -5
  31. package/dist/esm/zip-writer.js.map +1 -1
  32. package/dist/filesystems/zip-filesystem.d.ts +2 -2
  33. package/dist/filesystems/zip-filesystem.d.ts.map +1 -1
  34. package/dist/hash-file-utility.d.ts +1 -1
  35. package/dist/hash-file-utility.d.ts.map +1 -1
  36. package/dist/index.d.ts +1 -4
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/parse-zip/cd-file-header.d.ts +1 -1
  39. package/dist/parse-zip/cd-file-header.d.ts.map +1 -1
  40. package/dist/parse-zip/end-of-central-directory.d.ts +1 -1
  41. package/dist/parse-zip/end-of-central-directory.d.ts.map +1 -1
  42. package/dist/parse-zip/local-file-header.d.ts +1 -1
  43. package/dist/parse-zip/local-file-header.d.ts.map +1 -1
  44. package/dist/parse-zip/search-from-the-end.d.ts +1 -1
  45. package/dist/parse-zip/search-from-the-end.d.ts.map +1 -1
  46. package/dist/tar-builder.d.ts +2 -2
  47. package/dist/tar-builder.d.ts.map +1 -1
  48. package/dist/zip-loader.d.ts +0 -1
  49. package/dist/zip-loader.d.ts.map +1 -1
  50. package/dist/zip-writer.d.ts +12 -2
  51. package/dist/zip-writer.d.ts.map +1 -1
  52. package/package.json +4 -9
  53. package/src/filesystems/zip-filesystem.ts +3 -3
  54. package/src/hash-file-utility.ts +1 -1
  55. package/src/index.ts +3 -5
  56. package/src/parse-zip/cd-file-header.ts +1 -1
  57. package/src/parse-zip/end-of-central-directory.ts +1 -1
  58. package/src/parse-zip/local-file-header.ts +1 -1
  59. package/src/parse-zip/search-from-the-end.ts +1 -1
  60. package/src/tar-builder.ts +2 -2
  61. package/src/zip-loader.ts +2 -3
  62. package/src/zip-writer.ts +23 -10
  63. package/dist/bundle.js +0 -5
  64. package/dist/es5/file-provider/data-view-file.js +0 -146
  65. package/dist/es5/file-provider/data-view-file.js.map +0 -1
  66. package/dist/es5/file-provider/file-handle-file.js +0 -234
  67. package/dist/es5/file-provider/file-handle-file.js.map +0 -1
  68. package/dist/es5/file-provider/file-handle.js +0 -101
  69. package/dist/es5/file-provider/file-handle.js.map +0 -1
  70. package/dist/es5/file-provider/file-provider.js +0 -11
  71. package/dist/es5/file-provider/file-provider.js.map +0 -1
  72. package/dist/esm/file-provider/data-view-file.js +0 -33
  73. package/dist/esm/file-provider/data-view-file.js.map +0 -1
  74. package/dist/esm/file-provider/file-handle-file.js +0 -57
  75. package/dist/esm/file-provider/file-handle-file.js.map +0 -1
  76. package/dist/esm/file-provider/file-handle.js +0 -37
  77. package/dist/esm/file-provider/file-handle.js.map +0 -1
  78. package/dist/esm/file-provider/file-provider.js +0 -4
  79. package/dist/esm/file-provider/file-provider.js.map +0 -1
  80. package/dist/file-provider/data-view-file.d.ts +0 -37
  81. package/dist/file-provider/data-view-file.d.ts.map +0 -1
  82. package/dist/file-provider/data-view-file.js +0 -63
  83. package/dist/file-provider/file-handle-file.d.ts +0 -53
  84. package/dist/file-provider/file-handle-file.d.ts.map +0 -1
  85. package/dist/file-provider/file-handle-file.js +0 -90
  86. package/dist/file-provider/file-handle.d.ts +0 -40
  87. package/dist/file-provider/file-handle.d.ts.map +0 -1
  88. package/dist/file-provider/file-handle.js +0 -57
  89. package/dist/file-provider/file-provider.d.ts +0 -45
  90. package/dist/file-provider/file-provider.d.ts.map +0 -1
  91. package/dist/file-provider/file-provider.js +0 -13
  92. package/dist/filesystems/zip-filesystem.js +0 -128
  93. package/dist/hash-file-utility.js +0 -88
  94. package/dist/index.js +0 -34
  95. package/dist/lib/tar/header.js +0 -99
  96. package/dist/lib/tar/tar.js +0 -131
  97. package/dist/lib/tar/types.js +0 -2
  98. package/dist/lib/tar/utils.js +0 -54
  99. package/dist/parse-zip/cd-file-header.js +0 -68
  100. package/dist/parse-zip/end-of-central-directory.js +0 -40
  101. package/dist/parse-zip/local-file-header.js +0 -55
  102. package/dist/parse-zip/search-from-the-end.js +0 -31
  103. package/dist/tar-builder.js +0 -38
  104. package/dist/zip-loader.js +0 -61
  105. package/dist/zip-writer.js +0 -37
  106. package/src/file-provider/data-view-file.ts +0 -72
  107. package/src/file-provider/file-handle-file.ts +0 -114
  108. package/src/file-provider/file-handle.ts +0 -73
  109. package/src/file-provider/file-provider.ts +0 -56
@@ -1,146 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DataViewFile = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var toNumber = function toNumber(bigint) {
14
- if (bigint > Number.MAX_SAFE_INTEGER) {
15
- throw new Error('Offset is out of bounds');
16
- }
17
- return Number(bigint);
18
- };
19
- var DataViewFile = function () {
20
- function DataViewFile(file) {
21
- (0, _classCallCheck2.default)(this, DataViewFile);
22
- (0, _defineProperty2.default)(this, "file", void 0);
23
- this.file = file;
24
- }
25
- (0, _createClass2.default)(DataViewFile, [{
26
- key: "destroy",
27
- value: function () {
28
- var _destroy = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
29
- return _regenerator.default.wrap(function _callee$(_context) {
30
- while (1) switch (_context.prev = _context.next) {
31
- case 0:
32
- case "end":
33
- return _context.stop();
34
- }
35
- }, _callee);
36
- }));
37
- function destroy() {
38
- return _destroy.apply(this, arguments);
39
- }
40
- return destroy;
41
- }()
42
- }, {
43
- key: "getUint8",
44
- value: function () {
45
- var _getUint = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(offset) {
46
- return _regenerator.default.wrap(function _callee2$(_context2) {
47
- while (1) switch (_context2.prev = _context2.next) {
48
- case 0:
49
- return _context2.abrupt("return", this.file.getUint8(toNumber(offset)));
50
- case 1:
51
- case "end":
52
- return _context2.stop();
53
- }
54
- }, _callee2, this);
55
- }));
56
- function getUint8(_x) {
57
- return _getUint.apply(this, arguments);
58
- }
59
- return getUint8;
60
- }()
61
- }, {
62
- key: "getUint16",
63
- value: function () {
64
- var _getUint2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(offset) {
65
- return _regenerator.default.wrap(function _callee3$(_context3) {
66
- while (1) switch (_context3.prev = _context3.next) {
67
- case 0:
68
- return _context3.abrupt("return", this.file.getUint16(toNumber(offset), true));
69
- case 1:
70
- case "end":
71
- return _context3.stop();
72
- }
73
- }, _callee3, this);
74
- }));
75
- function getUint16(_x2) {
76
- return _getUint2.apply(this, arguments);
77
- }
78
- return getUint16;
79
- }()
80
- }, {
81
- key: "getUint32",
82
- value: function () {
83
- var _getUint3 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(offset) {
84
- return _regenerator.default.wrap(function _callee4$(_context4) {
85
- while (1) switch (_context4.prev = _context4.next) {
86
- case 0:
87
- return _context4.abrupt("return", this.file.getUint32(toNumber(offset), true));
88
- case 1:
89
- case "end":
90
- return _context4.stop();
91
- }
92
- }, _callee4, this);
93
- }));
94
- function getUint32(_x3) {
95
- return _getUint3.apply(this, arguments);
96
- }
97
- return getUint32;
98
- }()
99
- }, {
100
- key: "getBigUint64",
101
- value: function () {
102
- var _getBigUint = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(offset) {
103
- return _regenerator.default.wrap(function _callee5$(_context5) {
104
- while (1) switch (_context5.prev = _context5.next) {
105
- case 0:
106
- return _context5.abrupt("return", this.file.getBigUint64(toNumber(offset), true));
107
- case 1:
108
- case "end":
109
- return _context5.stop();
110
- }
111
- }, _callee5, this);
112
- }));
113
- function getBigUint64(_x4) {
114
- return _getBigUint.apply(this, arguments);
115
- }
116
- return getBigUint64;
117
- }()
118
- }, {
119
- key: "slice",
120
- value: function () {
121
- var _slice = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(startOffset, endOffset) {
122
- return _regenerator.default.wrap(function _callee6$(_context6) {
123
- while (1) switch (_context6.prev = _context6.next) {
124
- case 0:
125
- return _context6.abrupt("return", this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset)));
126
- case 1:
127
- case "end":
128
- return _context6.stop();
129
- }
130
- }, _callee6, this);
131
- }));
132
- function slice(_x5, _x6) {
133
- return _slice.apply(this, arguments);
134
- }
135
- return slice;
136
- }()
137
- }, {
138
- key: "length",
139
- get: function get() {
140
- return BigInt(this.file.byteLength);
141
- }
142
- }]);
143
- return DataViewFile;
144
- }();
145
- exports.DataViewFile = DataViewFile;
146
- //# sourceMappingURL=data-view-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-view-file.js","names":["toNumber","bigint","Number","MAX_SAFE_INTEGER","Error","DataViewFile","file","_classCallCheck2","default","_defineProperty2","_createClass2","key","value","_destroy","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_callee$","_context","prev","next","stop","destroy","apply","arguments","_getUint","_callee2","offset","_callee2$","_context2","abrupt","getUint8","_x","_getUint2","_callee3","_callee3$","_context3","getUint16","_x2","_getUint3","_callee4","_callee4$","_context4","getUint32","_x3","_getBigUint","_callee5","_callee5$","_context5","getBigUint64","_x4","_slice","_callee6","startOffset","endOffset","_callee6$","_context6","buffer","slice","_x5","_x6","get","BigInt","byteLength","exports"],"sources":["../../../src/file-provider/data-view-file.ts"],"sourcesContent":["import {FileProvider} from './file-provider';\n\n/**\n * Checks if bigint can be converted to number and convert it if possible\n * @param bigint bigint to be converted\n * @returns number\n */\nconst toNumber = (bigint: bigint) => {\n if (bigint > Number.MAX_SAFE_INTEGER) {\n throw new Error('Offset is out of bounds');\n }\n return Number(bigint);\n};\n\n/** Provides file data using DataView */\nexport class DataViewFile implements FileProvider {\n /** The DataView from which data is provided */\n private file: DataView;\n\n constructor(file: DataView) {\n this.file = file;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n async destroy(): Promise<void> {}\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n return this.file.getUint8(toNumber(offset));\n }\n\n /**\n * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n return this.file.getUint16(toNumber(offset), true);\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n return this.file.getUint32(toNumber(offset), true);\n }\n\n /**\n * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n return this.file.getBigUint64(toNumber(offset), true);\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));\n }\n\n /** the length (in bytes) of the data. */\n get length() {\n return BigInt(this.file.byteLength);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAOA,IAAMA,QAAQ,GAAG,SAAXA,QAAQA,CAAIC,MAAc,EAAK;EACnC,IAAIA,MAAM,GAAGC,MAAM,CAACC,gBAAgB,EAAE;IACpC,MAAM,IAAIC,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACA,OAAOF,MAAM,CAACD,MAAM,CAAC;AACvB,CAAC;AAAC,IAGWI,YAAY;EAIvB,SAAAA,aAAYC,IAAc,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAH,YAAA;IAAA,IAAAI,gBAAA,CAAAD,OAAA;IAC1B,IAAI,CAACF,IAAI,GAAGA,IAAI;EAClB;EAAC,IAAAI,aAAA,CAAAF,OAAA,EAAA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,CAAA7D,YAAA,GAAAA,YAAA"}
@@ -1,234 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.FileHandleFile = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var _fileHandle = require("./file-handle");
14
- var FileHandleFile = function () {
15
- function FileHandleFile(fileDescriptor, size) {
16
- (0, _classCallCheck2.default)(this, FileHandleFile);
17
- (0, _defineProperty2.default)(this, "fileDescriptor", void 0);
18
- (0, _defineProperty2.default)(this, "size", void 0);
19
- this.fileDescriptor = fileDescriptor;
20
- this.size = size;
21
- }
22
- (0, _createClass2.default)(FileHandleFile, [{
23
- key: "destroy",
24
- value: function () {
25
- var _destroy = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
26
- return _regenerator.default.wrap(function _callee$(_context) {
27
- while (1) switch (_context.prev = _context.next) {
28
- case 0:
29
- _context.next = 2;
30
- return this.fileDescriptor.close();
31
- case 2:
32
- case "end":
33
- return _context.stop();
34
- }
35
- }, _callee, this);
36
- }));
37
- function destroy() {
38
- return _destroy.apply(this, arguments);
39
- }
40
- return destroy;
41
- }()
42
- }, {
43
- key: "getUint8",
44
- value: function () {
45
- var _getUint = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(offset) {
46
- var val;
47
- return _regenerator.default.wrap(function _callee2$(_context2) {
48
- while (1) switch (_context2.prev = _context2.next) {
49
- case 0:
50
- _context2.t0 = Uint8Array;
51
- _context2.next = 3;
52
- return this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset);
53
- case 3:
54
- _context2.t1 = _context2.sent.buffer.buffer;
55
- val = new _context2.t0(_context2.t1).at(0);
56
- if (!(val === undefined)) {
57
- _context2.next = 7;
58
- break;
59
- }
60
- throw new Error('something went wrong');
61
- case 7:
62
- return _context2.abrupt("return", val);
63
- case 8:
64
- case "end":
65
- return _context2.stop();
66
- }
67
- }, _callee2, this);
68
- }));
69
- function getUint8(_x) {
70
- return _getUint.apply(this, arguments);
71
- }
72
- return getUint8;
73
- }()
74
- }, {
75
- key: "getUint16",
76
- value: function () {
77
- var _getUint2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(offset) {
78
- var val;
79
- return _regenerator.default.wrap(function _callee3$(_context3) {
80
- while (1) switch (_context3.prev = _context3.next) {
81
- case 0:
82
- _context3.t0 = Uint16Array;
83
- _context3.next = 3;
84
- return this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset);
85
- case 3:
86
- _context3.t1 = _context3.sent.buffer.buffer;
87
- val = new _context3.t0(_context3.t1).at(0);
88
- if (!(val === undefined)) {
89
- _context3.next = 7;
90
- break;
91
- }
92
- throw new Error('something went wrong');
93
- case 7:
94
- return _context3.abrupt("return", val);
95
- case 8:
96
- case "end":
97
- return _context3.stop();
98
- }
99
- }, _callee3, this);
100
- }));
101
- function getUint16(_x2) {
102
- return _getUint2.apply(this, arguments);
103
- }
104
- return getUint16;
105
- }()
106
- }, {
107
- key: "getUint32",
108
- value: function () {
109
- var _getUint3 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(offset) {
110
- var val;
111
- return _regenerator.default.wrap(function _callee4$(_context4) {
112
- while (1) switch (_context4.prev = _context4.next) {
113
- case 0:
114
- _context4.t0 = Uint32Array;
115
- _context4.next = 3;
116
- return this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset);
117
- case 3:
118
- _context4.t1 = _context4.sent.buffer.buffer;
119
- val = new _context4.t0(_context4.t1).at(0);
120
- if (!(val === undefined)) {
121
- _context4.next = 7;
122
- break;
123
- }
124
- throw new Error('something went wrong');
125
- case 7:
126
- return _context4.abrupt("return", val);
127
- case 8:
128
- case "end":
129
- return _context4.stop();
130
- }
131
- }, _callee4, this);
132
- }));
133
- function getUint32(_x3) {
134
- return _getUint3.apply(this, arguments);
135
- }
136
- return getUint32;
137
- }()
138
- }, {
139
- key: "getBigUint64",
140
- value: function () {
141
- var _getBigUint = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(offset) {
142
- var val;
143
- return _regenerator.default.wrap(function _callee5$(_context5) {
144
- while (1) switch (_context5.prev = _context5.next) {
145
- case 0:
146
- _context5.t0 = BigInt64Array;
147
- _context5.next = 3;
148
- return this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset);
149
- case 3:
150
- _context5.t1 = _context5.sent.buffer.buffer;
151
- val = new _context5.t0(_context5.t1).at(0);
152
- if (!(val === undefined)) {
153
- _context5.next = 7;
154
- break;
155
- }
156
- throw new Error('something went wrong');
157
- case 7:
158
- return _context5.abrupt("return", val);
159
- case 8:
160
- case "end":
161
- return _context5.stop();
162
- }
163
- }, _callee5, this);
164
- }));
165
- function getBigUint64(_x4) {
166
- return _getBigUint.apply(this, arguments);
167
- }
168
- return getBigUint64;
169
- }()
170
- }, {
171
- key: "slice",
172
- value: function () {
173
- var _slice = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(startOffsset, endOffset) {
174
- var bigLength, length;
175
- return _regenerator.default.wrap(function _callee6$(_context6) {
176
- while (1) switch (_context6.prev = _context6.next) {
177
- case 0:
178
- bigLength = endOffset - startOffsset;
179
- if (!(bigLength > Number.MAX_SAFE_INTEGER)) {
180
- _context6.next = 3;
181
- break;
182
- }
183
- throw new Error('too big slice');
184
- case 3:
185
- length = Number(bigLength);
186
- _context6.next = 6;
187
- return this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset);
188
- case 6:
189
- return _context6.abrupt("return", _context6.sent.buffer.buffer);
190
- case 7:
191
- case "end":
192
- return _context6.stop();
193
- }
194
- }, _callee6, this);
195
- }));
196
- function slice(_x5, _x6) {
197
- return _slice.apply(this, arguments);
198
- }
199
- return slice;
200
- }()
201
- }, {
202
- key: "length",
203
- get: function get() {
204
- return this.size;
205
- }
206
- }], [{
207
- key: "from",
208
- value: function () {
209
- var _from = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(path) {
210
- var fileDescriptor;
211
- return _regenerator.default.wrap(function _callee7$(_context7) {
212
- while (1) switch (_context7.prev = _context7.next) {
213
- case 0:
214
- _context7.next = 2;
215
- return _fileHandle.FileHandle.open(path);
216
- case 2:
217
- fileDescriptor = _context7.sent;
218
- return _context7.abrupt("return", new FileHandleFile(fileDescriptor, fileDescriptor.stat.size));
219
- case 4:
220
- case "end":
221
- return _context7.stop();
222
- }
223
- }, _callee7);
224
- }));
225
- function from(_x7) {
226
- return _from.apply(this, arguments);
227
- }
228
- return from;
229
- }()
230
- }]);
231
- return FileHandleFile;
232
- }();
233
- exports.FileHandleFile = FileHandleFile;
234
- //# sourceMappingURL=file-handle-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-handle-file.js","names":["_fileHandle","require","FileHandleFile","fileDescriptor","size","_classCallCheck2","default","_defineProperty2","_createClass2","key","value","_destroy","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_callee$","_context","prev","next","close","stop","destroy","apply","arguments","_getUint","_callee2","offset","val","_callee2$","_context2","t0","Uint8Array","read","Buffer","alloc","t1","sent","buffer","at","undefined","Error","abrupt","getUint8","_x","_getUint2","_callee3","_callee3$","_context3","Uint16Array","getUint16","_x2","_getUint3","_callee4","_callee4$","_context4","Uint32Array","getUint32","_x3","_getBigUint","_callee5","_callee5$","_context5","BigInt64Array","getBigUint64","_x4","_slice","_callee6","startOffsset","endOffset","bigLength","length","_callee6$","_context6","Number","MAX_SAFE_INTEGER","slice","_x5","_x6","get","_from","_callee7","path","_callee7$","_context7","FileHandle","open","stat","from","_x7","exports"],"sources":["../../../src/file-provider/file-handle-file.ts"],"sourcesContent":["import {FileProvider} from '@loaders.gl/zip';\nimport {FileHandle} from './file-handle';\n\n/**\n * Provides file data using node fs library\n */\nexport class FileHandleFile implements FileProvider {\n /**\n * Returns a new copy of FileHandleFile\n * @param path The path to the file in file system\n */\n static async from(path: string): Promise<FileHandleFile> {\n const fileDescriptor = await FileHandle.open(path);\n return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);\n }\n\n /**\n * The FileHandle from which data is provided\n */\n private fileDescriptor: FileHandle;\n\n /**\n * The file length in bytes\n */\n private size: bigint;\n\n private constructor(fileDescriptor: FileHandle, size: bigint) {\n this.fileDescriptor = fileDescriptor;\n this.size = size;\n }\n\n /** Close file */\n async destroy(): Promise<void> {\n await this.fileDescriptor.close();\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n const val = new Uint8Array(\n (await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n const val = new Uint16Array(\n (await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n const val = new Uint32Array(\n (await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n const val = new BigInt64Array(\n (await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffsset The offset, in byte, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n const bigLength = endOffset - startOffsset;\n if (bigLength > Number.MAX_SAFE_INTEGER) {\n throw new Error('too big slice');\n }\n const length = Number(bigLength);\n return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer\n .buffer;\n }\n\n /**\n * the length (in bytes) of the data.\n */\n get length(): bigint {\n return this.size;\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAAyC,IAK5BC,cAAc;EAoBzB,SAAAA,eAAoBC,cAA0B,EAAEC,IAAY,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAJ,cAAA;IAAA,IAAAK,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAC5D,IAAI,CAACH,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,IAAI,GAAGA,IAAI;EAClB;EAAC,IAAAI,aAAA,CAAAF,OAAA,EAAAJ,cAAA;IAAAO,GAAA;IAAAC,KAAA;MAAA,IAAAC,QAAA,OAAAC,kBAAA,CAAAN,OAAA,EAAAO,YAAA,CAAAP,OAAA,CAAAQ,IAAA,CAGD,SAAAC,QAAA;QAAA,OAAAF,YAAA,CAAAP,OAAA,CAAAU,IAAA,UAAAC,SAAAC,QAAA;UAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;YAAA;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AAiF,SAAA,CAAA/D,IAAA;UAAA;QAAA,GAAA4D,QAAA;MAAA,CACpE;MAAA,SAAAO,KAAAC,GAAA;QAAA,OAAAT,KAAA,CAAAzD,KAAA,OAAAC,SAAA;MAAA;MAAA,OAAAgE,IAAA;IAAA;EAAA;EAAA,OAAAvF,cAAA;AAAA;AAAAyF,OAAA,CAAAzF,cAAA,GAAAA,cAAA"}
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.FileHandle = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
- var _fs = require("fs");
15
- var FileHandle = function () {
16
- function FileHandle(fileDescriptor, stats) {
17
- var _this = this;
18
- (0, _classCallCheck2.default)(this, FileHandle);
19
- (0, _defineProperty2.default)(this, "fileDescriptor", void 0);
20
- (0, _defineProperty2.default)(this, "stats", void 0);
21
- (0, _defineProperty2.default)(this, "read", function (buffer, offset, length, position) {
22
- return new Promise(function (s) {
23
- (0, _fs.read)(_this.fileDescriptor, buffer, offset, length, position, function (_err, bytesRead, buffer) {
24
- return s({
25
- bytesRead: bytesRead,
26
- buffer: buffer
27
- });
28
- });
29
- });
30
- });
31
- this.fileDescriptor = fileDescriptor;
32
- this.stats = stats;
33
- }
34
- (0, _createClass2.default)(FileHandle, [{
35
- key: "close",
36
- value: function () {
37
- var _close2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
38
- var _this2 = this;
39
- return _regenerator.default.wrap(function _callee$(_context) {
40
- while (1) switch (_context.prev = _context.next) {
41
- case 0:
42
- return _context.abrupt("return", new Promise(function (resolve) {
43
- (0, _fs.close)(_this2.fileDescriptor, function (_err) {
44
- return resolve();
45
- });
46
- }));
47
- case 1:
48
- case "end":
49
- return _context.stop();
50
- }
51
- }, _callee);
52
- }));
53
- function close() {
54
- return _close2.apply(this, arguments);
55
- }
56
- return close;
57
- }()
58
- }, {
59
- key: "stat",
60
- get: function get() {
61
- return this.stats;
62
- }
63
- }]);
64
- return FileHandle;
65
- }();
66
- exports.FileHandle = FileHandle;
67
- (0, _defineProperty2.default)(FileHandle, "open", function () {
68
- var _ref = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(path) {
69
- var _yield$Promise$all, _yield$Promise$all2, fd, stats;
70
- return _regenerator.default.wrap(function _callee2$(_context2) {
71
- while (1) switch (_context2.prev = _context2.next) {
72
- case 0:
73
- _context2.next = 2;
74
- return Promise.all([new Promise(function (s) {
75
- (0, _fs.open)(path, undefined, undefined, function (_err, fd) {
76
- return s(fd);
77
- });
78
- }), new Promise(function (s) {
79
- (0, _fs.stat)(path, {
80
- bigint: true
81
- }, function (_err, stats) {
82
- return s(stats);
83
- });
84
- })]);
85
- case 2:
86
- _yield$Promise$all = _context2.sent;
87
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
88
- fd = _yield$Promise$all2[0];
89
- stats = _yield$Promise$all2[1];
90
- return _context2.abrupt("return", new FileHandle(fd, stats));
91
- case 7:
92
- case "end":
93
- return _context2.stop();
94
- }
95
- }, _callee2);
96
- }));
97
- return function (_x) {
98
- return _ref.apply(this, arguments);
99
- };
100
- }());
101
- //# sourceMappingURL=file-handle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-handle.js","names":["_fs","require","FileHandle","fileDescriptor","stats","_this","_classCallCheck2","default","_defineProperty2","buffer","offset","length","position","Promise","s","read","_err","bytesRead","_createClass2","key","value","_close2","_asyncToGenerator2","_regenerator","mark","_callee","_this2","wrap","_callee$","_context","prev","next","abrupt","resolve","close","stop","apply","arguments","get","exports","_ref","_callee2","path","_yield$Promise$all","_yield$Promise$all2","fd","_callee2$","_context2","all","open","undefined","stat","bigint","sent","_slicedToArray2","_x"],"sources":["../../../src/file-provider/file-handle.ts"],"sourcesContent":["import {read, open, close, stat, BigIntStats} from 'fs';\n\n/** file reading result */\nexport type FileReadResult = {\n /** amount of the bytes read */\n bytesRead: number;\n /** the buffer filled with data from file*/\n buffer: Buffer;\n};\n\n/** Object handling file info */\nexport class FileHandle {\n private fileDescriptor: number;\n private stats: BigIntStats;\n private constructor(fileDescriptor: number, stats: BigIntStats) {\n this.fileDescriptor = fileDescriptor;\n this.stats = stats;\n }\n /**\n * Opens a `FileHandle`.\n *\n * @param path path to the file\n * @return Fulfills with a {FileHandle} object.\n */\n\n static open = async (path: string): Promise<FileHandle> => {\n const [fd, stats] = await Promise.all([\n new Promise<number>((s) => {\n open(path, undefined, undefined, (_err, fd) => s(fd));\n }),\n new Promise<BigIntStats>((s) => {\n stat(path, {bigint: true}, (_err, stats) => s(stats));\n })\n ]);\n return new FileHandle(fd, stats);\n };\n\n /** Close file */\n async close(): Promise<void> {\n return new Promise<void>((resolve) => {\n close(this.fileDescriptor, (_err) => resolve());\n });\n }\n\n /**\n * Reads data from the file and stores that in the given buffer.\n *\n * If the file is not modified concurrently, the end-of-file is reached when the\n * number of bytes read is zero.\n * @param buffer A buffer that will be filled with the file data read.\n * @param offset The location in the buffer at which to start filling.\n * @param length The number of bytes to read.\n * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an\n * integer, the current file position will remain unchanged.\n * @return Fulfills upon success with a FileReadResult object\n */\n read = (\n buffer: Buffer,\n offset: number,\n length: number,\n position: number | bigint\n ): Promise<FileReadResult> => {\n return new Promise((s) => {\n read(this.fileDescriptor, buffer, offset, length, position, (_err, bytesRead, buffer) =>\n s({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;YAAI,CAAC,EAAE,UAACpC,IAAI,EAAEZ,KAAK;cAAA,OAAKU,CAAC,CAACV,KAAK,CAAC;YAAA,EAAC;UACvD,CAAC,CAAC,CACH,CAAC;QAAA;UAAAuC,kBAAA,GAAAI,SAAA,CAAAM,IAAA;UAAAT,mBAAA,OAAAU,eAAA,CAAA/C,OAAA,EAAAoC,kBAAA;UAPKE,EAAE,GAAAD,mBAAA;UAAExC,KAAK,GAAAwC,mBAAA;UAAA,OAAAG,SAAA,CAAAf,MAAA,WAQT,IAAI9B,UAAU,CAAC2C,EAAE,EAAEzC,KAAK,CAAC;QAAA;QAAA;UAAA,OAAA2C,SAAA,CAAAZ,IAAA;MAAA;IAAA,GAAAM,QAAA;EAAA,CACjC;EAAA,iBAAAc,EAAA;IAAA,OAAAf,IAAA,CAAAJ,KAAA,OAAAC,SAAA;EAAA;AAAA"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isFileProvider = void 0;
7
- var isFileProvider = function isFileProvider(fileProvider) {
8
- return (fileProvider === null || fileProvider === void 0 ? void 0 : fileProvider.getUint8) && (fileProvider === null || fileProvider === void 0 ? void 0 : fileProvider.slice) && (fileProvider === null || fileProvider === void 0 ? void 0 : fileProvider.length);
9
- };
10
- exports.isFileProvider = isFileProvider;
11
- //# sourceMappingURL=file-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-provider.js","names":["isFileProvider","fileProvider","getUint8","slice","length","exports"],"sources":["../../../src/file-provider/file-provider.ts"],"sourcesContent":["/**\n * Interface for providing file data\n */\nexport interface FileProvider {\n /**\n * Cleanup class data\n */\n destroy(): Promise<void>;\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint8(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n getUint16(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the file of the view where to read the data.\n */\n getUint32(offset: bigint): Promise<number>;\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in byte, from the file of the view where to read the data.\n */\n getBigUint64(offset: bigint): Promise<bigint>;\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;\n\n /**\n * the length (in bytes) of the data.\n */\n length: bigint;\n}\n\n/**\n * Check is the object has FileProvider members\n * @param fileProvider - tested object\n */\nexport const isFileProvider = (fileProvider: unknown) => {\n return (\n (fileProvider as FileProvider)?.getUint8 &&\n (fileProvider as FileProvider)?.slice &&\n (fileProvider as FileProvider)?.length\n );\n};\n"],"mappings":";;;;;;AAiDO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,YAAqB,EAAK;EACvD,OACE,CAACA,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAmBC,QAAQ,MACvCD,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAmBE,KAAK,MACpCF,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAmBG,MAAM;AAE1C,CAAC;AAACC,OAAA,CAAAL,cAAA,GAAAA,cAAA"}
@@ -1,33 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- const toNumber = bigint => {
3
- if (bigint > Number.MAX_SAFE_INTEGER) {
4
- throw new Error('Offset is out of bounds');
5
- }
6
- return Number(bigint);
7
- };
8
- export class DataViewFile {
9
- constructor(file) {
10
- _defineProperty(this, "file", void 0);
11
- this.file = file;
12
- }
13
- async destroy() {}
14
- async getUint8(offset) {
15
- return this.file.getUint8(toNumber(offset));
16
- }
17
- async getUint16(offset) {
18
- return this.file.getUint16(toNumber(offset), true);
19
- }
20
- async getUint32(offset) {
21
- return this.file.getUint32(toNumber(offset), true);
22
- }
23
- async getBigUint64(offset) {
24
- return this.file.getBigUint64(toNumber(offset), true);
25
- }
26
- async slice(startOffset, endOffset) {
27
- return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
28
- }
29
- get length() {
30
- return BigInt(this.file.byteLength);
31
- }
32
- }
33
- //# sourceMappingURL=data-view-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-view-file.js","names":["toNumber","bigint","Number","MAX_SAFE_INTEGER","Error","DataViewFile","constructor","file","_defineProperty","destroy","getUint8","offset","getUint16","getUint32","getBigUint64","slice","startOffset","endOffset","buffer","length","BigInt","byteLength"],"sources":["../../../src/file-provider/data-view-file.ts"],"sourcesContent":["import {FileProvider} from './file-provider';\n\n/**\n * Checks if bigint can be converted to number and convert it if possible\n * @param bigint bigint to be converted\n * @returns number\n */\nconst toNumber = (bigint: bigint) => {\n if (bigint > Number.MAX_SAFE_INTEGER) {\n throw new Error('Offset is out of bounds');\n }\n return Number(bigint);\n};\n\n/** Provides file data using DataView */\nexport class DataViewFile implements FileProvider {\n /** The DataView from which data is provided */\n private file: DataView;\n\n constructor(file: DataView) {\n this.file = file;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n async destroy(): Promise<void> {}\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n return this.file.getUint8(toNumber(offset));\n }\n\n /**\n * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n return this.file.getUint16(toNumber(offset), true);\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n return this.file.getUint32(toNumber(offset), true);\n }\n\n /**\n * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n return this.file.getBigUint64(toNumber(offset), true);\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));\n }\n\n /** the length (in bytes) of the data. */\n get length() {\n return BigInt(this.file.byteLength);\n }\n}\n"],"mappings":";AAOA,MAAMA,QAAQ,GAAIC,MAAc,IAAK;EACnC,IAAIA,MAAM,GAAGC,MAAM,CAACC,gBAAgB,EAAE;IACpC,MAAM,IAAIC,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACA,OAAOF,MAAM,CAACD,MAAM,CAAC;AACvB,CAAC;AAGD,OAAO,MAAMI,YAAY,CAAyB;EAIhDC,WAAWA,CAACC,IAAc,EAAE;IAAAC,eAAA;IAC1B,IAAI,CAACD,IAAI,GAAGA,IAAI;EAClB;EAGA,MAAME,OAAOA,CAAA,EAAkB,CAAC;EAMhC,MAAMC,QAAQA,CAACC,MAAc,EAAmB;IAC9C,OAAO,IAAI,CAACJ,IAAI,CAACG,QAAQ,CAACV,QAAQ,CAACW,MAAM,CAAC,CAAC;EAC7C;EAMA,MAAMC,SAASA,CAACD,MAAc,EAAmB;IAC/C,OAAO,IAAI,CAACJ,IAAI,CAACK,SAAS,CAACZ,QAAQ,CAACW,MAAM,CAAC,EAAE,IAAI,CAAC;EACpD;EAMA,MAAME,SAASA,CAACF,MAAc,EAAmB;IAC/C,OAAO,IAAI,CAACJ,IAAI,CAACM,SAAS,CAACb,QAAQ,CAACW,MAAM,CAAC,EAAE,IAAI,CAAC;EACpD;EAMA,MAAMG,YAAYA,CAACH,MAAc,EAAmB;IAClD,OAAO,IAAI,CAACJ,IAAI,CAACO,YAAY,CAACd,QAAQ,CAACW,MAAM,CAAC,EAAE,IAAI,CAAC;EACvD;EAOA,MAAMI,KAAKA,CAACC,WAAmB,EAAEC,SAAiB,EAAwB;IACxE,OAAO,IAAI,CAACV,IAAI,CAACW,MAAM,CAACH,KAAK,CAACf,QAAQ,CAACgB,WAAW,CAAC,EAAEhB,QAAQ,CAACiB,SAAS,CAAC,CAAC;EAC3E;EAGA,IAAIE,MAAMA,CAAA,EAAG;IACX,OAAOC,MAAM,CAAC,IAAI,CAACb,IAAI,CAACc,UAAU,CAAC;EACrC;AACF"}
@@ -1,57 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { FileHandle } from './file-handle';
3
- export class FileHandleFile {
4
- static async from(path) {
5
- const fileDescriptor = await FileHandle.open(path);
6
- return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
7
- }
8
- constructor(fileDescriptor, size) {
9
- _defineProperty(this, "fileDescriptor", void 0);
10
- _defineProperty(this, "size", void 0);
11
- this.fileDescriptor = fileDescriptor;
12
- this.size = size;
13
- }
14
- async destroy() {
15
- await this.fileDescriptor.close();
16
- }
17
- async getUint8(offset) {
18
- const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
19
- if (val === undefined) {
20
- throw new Error('something went wrong');
21
- }
22
- return val;
23
- }
24
- async getUint16(offset) {
25
- const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
26
- if (val === undefined) {
27
- throw new Error('something went wrong');
28
- }
29
- return val;
30
- }
31
- async getUint32(offset) {
32
- const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
33
- if (val === undefined) {
34
- throw new Error('something went wrong');
35
- }
36
- return val;
37
- }
38
- async getBigUint64(offset) {
39
- const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
40
- if (val === undefined) {
41
- throw new Error('something went wrong');
42
- }
43
- return val;
44
- }
45
- async slice(startOffsset, endOffset) {
46
- const bigLength = endOffset - startOffsset;
47
- if (bigLength > Number.MAX_SAFE_INTEGER) {
48
- throw new Error('too big slice');
49
- }
50
- const length = Number(bigLength);
51
- return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer.buffer;
52
- }
53
- get length() {
54
- return this.size;
55
- }
56
- }
57
- //# sourceMappingURL=file-handle-file.js.map