@loaders.gl/polyfills 3.3.0-alpha.5 → 3.3.0-alpha.6
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 +22 -10
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/index.js +10 -37
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/encoding-indexes.js.map +1 -1
- package/dist/es5/lib/encoding.js +255 -135
- package/dist/es5/lib/encoding.js.map +1 -1
- package/dist/es5/node/buffer/btoa.node.js +0 -1
- package/dist/es5/node/buffer/btoa.node.js.map +1 -1
- package/dist/es5/node/buffer/to-array-buffer.node.js +0 -2
- package/dist/es5/node/buffer/to-array-buffer.node.js.map +1 -1
- package/dist/es5/node/fetch/fetch.node.js +2 -36
- package/dist/es5/node/fetch/fetch.node.js.map +1 -1
- package/dist/es5/node/fetch/headers.node.js +0 -21
- package/dist/es5/node/fetch/headers.node.js.map +1 -1
- package/dist/es5/node/fetch/response.node.js +10 -45
- package/dist/es5/node/fetch/response.node.js.map +1 -1
- package/dist/es5/node/fetch/utils/decode-data-uri.node.js +0 -8
- package/dist/es5/node/fetch/utils/decode-data-uri.node.js.map +1 -1
- package/dist/es5/node/fetch/utils/stream-utils.node.js +10 -40
- package/dist/es5/node/fetch/utils/stream-utils.node.js.map +1 -1
- package/dist/es5/node/file/blob-stream-controller.js +5 -19
- package/dist/es5/node/file/blob-stream-controller.js.map +1 -1
- package/dist/es5/node/file/blob-stream.js +5 -30
- package/dist/es5/node/file/blob-stream.js.map +1 -1
- package/dist/es5/node/file/blob.js +17 -50
- package/dist/es5/node/file/blob.js.map +1 -1
- package/dist/es5/node/file/file-reader.js +1 -28
- package/dist/es5/node/file/file-reader.js.map +1 -1
- package/dist/es5/node/file/file.js +0 -18
- package/dist/es5/node/file/file.js.map +1 -1
- package/dist/es5/node/file/install-file-polyfills.js +0 -7
- package/dist/es5/node/file/install-file-polyfills.js.map +1 -1
- package/dist/es5/node/file/readable-stream.js +2 -14
- package/dist/es5/node/file/readable-stream.js.map +1 -1
- package/dist/es5/node/images/encode-image.node.js +2 -6
- package/dist/es5/node/images/encode-image.node.js.map +1 -1
- package/dist/es5/node/images/parse-image.node.js +1 -11
- package/dist/es5/node/images/parse-image.node.js.map +1 -1
- package/dist/es5/promise/all-settled.js +2 -2
- package/dist/es5/promise/all-settled.js.map +1 -1
- package/dist/es5/utils/assert.js +0 -1
- package/dist/es5/utils/assert.js.map +1 -1
- package/dist/es5/utils/globals.js +3 -4
- package/dist/es5/utils/globals.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js +3 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/encoding-indexes.js +2 -0
- package/dist/esm/lib/encoding-indexes.js.map +1 -1
- package/dist/esm/lib/encoding.js +256 -131
- package/dist/esm/lib/encoding.js.map +1 -1
- package/dist/esm/node/buffer/btoa.node.js +2 -0
- package/dist/esm/node/buffer/btoa.node.js.map +1 -1
- package/dist/esm/node/buffer/to-array-buffer.node.js +0 -1
- package/dist/esm/node/buffer/to-array-buffer.node.js.map +1 -1
- package/dist/esm/node/fetch/fetch.node.js +5 -17
- package/dist/esm/node/fetch/fetch.node.js.map +1 -1
- package/dist/esm/node/fetch/headers.node.js +2 -24
- package/dist/esm/node/fetch/headers.node.js.map +1 -1
- package/dist/esm/node/fetch/response.node.js +0 -17
- package/dist/esm/node/fetch/response.node.js.map +1 -1
- package/dist/esm/node/fetch/utils/decode-data-uri.node.js +3 -6
- package/dist/esm/node/fetch/utils/decode-data-uri.node.js.map +1 -1
- package/dist/esm/node/fetch/utils/stream-utils.node.js +4 -7
- package/dist/esm/node/fetch/utils/stream-utils.node.js.map +1 -1
- package/dist/esm/node/file/blob-stream-controller.js +0 -8
- package/dist/esm/node/file/blob-stream-controller.js.map +1 -1
- package/dist/esm/node/file/blob-stream.js +1 -5
- package/dist/esm/node/file/blob-stream.js.map +1 -1
- package/dist/esm/node/file/blob.js +12 -21
- package/dist/esm/node/file/blob.js.map +1 -1
- package/dist/esm/node/file/file-reader.js +1 -24
- package/dist/esm/node/file/file-reader.js.map +1 -1
- package/dist/esm/node/file/file.js +4 -9
- package/dist/esm/node/file/file.js.map +1 -1
- package/dist/esm/node/file/install-file-polyfills.js +0 -2
- package/dist/esm/node/file/install-file-polyfills.js.map +1 -1
- package/dist/esm/node/file/readable-stream.js +2 -0
- package/dist/esm/node/file/readable-stream.js.map +1 -1
- package/dist/esm/node/images/encode-image.node.js +4 -0
- package/dist/esm/node/images/encode-image.node.js.map +1 -1
- package/dist/esm/node/images/parse-image.node.js +3 -0
- package/dist/esm/node/images/parse-image.node.js.map +1 -1
- package/dist/esm/promise/all-settled.js +1 -0
- package/dist/esm/promise/all-settled.js.map +1 -1
- package/dist/esm/utils/assert.js.map +1 -1
- package/dist/esm/utils/globals.js +4 -1
- package/dist/esm/utils/globals.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/libs/encoding-indexes-asian.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,37 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.BlobPolyfill = void 0;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
|
|
16
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
-
|
|
18
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
-
|
|
20
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
|
|
22
14
|
var _blobStream = require("./blob-stream");
|
|
23
|
-
|
|
24
15
|
var _Symbol$toStringTag;
|
|
25
|
-
|
|
26
16
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
27
|
-
|
|
28
17
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
|
-
|
|
30
18
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
31
|
-
|
|
32
19
|
_Symbol$toStringTag = Symbol.toStringTag;
|
|
33
|
-
|
|
34
20
|
var BlobPolyfill = function () {
|
|
21
|
+
|
|
35
22
|
function BlobPolyfill() {
|
|
36
23
|
var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
37
24
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -41,23 +28,18 @@ var BlobPolyfill = function () {
|
|
|
41
28
|
(0, _defineProperty2.default)(this, "parts", void 0);
|
|
42
29
|
this.parts = [];
|
|
43
30
|
this.size = 0;
|
|
44
|
-
|
|
45
31
|
var _iterator = _createForOfIteratorHelper(init),
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
_step;
|
|
48
33
|
try {
|
|
49
34
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
50
35
|
var part = _step.value;
|
|
51
|
-
|
|
52
36
|
if (typeof part === 'string') {
|
|
53
37
|
var bytes = new TextEncoder().encode(part);
|
|
54
38
|
this.parts.push(bytes);
|
|
55
39
|
this.size += bytes.byteLength;
|
|
56
40
|
} else if (part instanceof BlobPolyfill) {
|
|
57
41
|
var _this$parts;
|
|
58
|
-
|
|
59
42
|
this.size += part.size;
|
|
60
|
-
|
|
61
43
|
(_this$parts = this.parts).push.apply(_this$parts, (0, _toConsumableArray2.default)(part.parts));
|
|
62
44
|
} else if (part instanceof ArrayBuffer) {
|
|
63
45
|
this.parts.push(new Uint8Array(part));
|
|
@@ -67,56 +49,51 @@ var BlobPolyfill = function () {
|
|
|
67
49
|
this.size += part.byteLength;
|
|
68
50
|
} else if (ArrayBuffer.isView(part)) {
|
|
69
51
|
var buffer = part.buffer,
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
byteOffset = part.byteOffset,
|
|
53
|
+
byteLength = part.byteLength;
|
|
72
54
|
this.parts.push(new Uint8Array(buffer, byteOffset, byteLength));
|
|
73
55
|
this.size += byteLength;
|
|
74
56
|
} else {
|
|
75
57
|
var _bytes = new TextEncoder().encode(String(part));
|
|
76
|
-
|
|
77
58
|
this.parts.push(_bytes);
|
|
78
59
|
this.size += _bytes.byteLength;
|
|
79
60
|
}
|
|
80
61
|
}
|
|
62
|
+
|
|
81
63
|
} catch (err) {
|
|
82
64
|
_iterator.e(err);
|
|
83
65
|
} finally {
|
|
84
66
|
_iterator.f();
|
|
85
67
|
}
|
|
86
|
-
|
|
87
68
|
this.type = readType(options.type);
|
|
88
69
|
}
|
|
89
70
|
|
|
90
71
|
(0, _createClass2.default)(BlobPolyfill, [{
|
|
91
72
|
key: "slice",
|
|
92
|
-
value:
|
|
73
|
+
value:
|
|
74
|
+
function slice() {
|
|
93
75
|
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
94
76
|
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
|
|
95
77
|
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
96
78
|
var size = this.size,
|
|
97
|
-
|
|
79
|
+
parts = this.parts;
|
|
98
80
|
var offset = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
|
|
99
81
|
var limit = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
|
|
100
82
|
var span = Math.max(limit - offset, 0);
|
|
101
83
|
var blob = new BlobPolyfill([], {
|
|
102
84
|
type: type
|
|
103
85
|
});
|
|
104
|
-
|
|
105
86
|
if (span === 0) {
|
|
106
87
|
return blob;
|
|
107
88
|
}
|
|
108
|
-
|
|
109
89
|
var blobSize = 0;
|
|
110
90
|
var blobParts = [];
|
|
111
|
-
|
|
112
91
|
var _iterator2 = _createForOfIteratorHelper(parts),
|
|
113
|
-
|
|
114
|
-
|
|
92
|
+
_step2;
|
|
115
93
|
try {
|
|
116
94
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
117
95
|
var part = _step2.value;
|
|
118
96
|
var byteLength = part.byteLength;
|
|
119
|
-
|
|
120
97
|
if (offset > 0 && byteLength <= offset) {
|
|
121
98
|
offset -= byteLength;
|
|
122
99
|
limit -= byteLength;
|
|
@@ -136,11 +113,12 @@ var BlobPolyfill = function () {
|
|
|
136
113
|
} finally {
|
|
137
114
|
_iterator2.f();
|
|
138
115
|
}
|
|
139
|
-
|
|
140
116
|
blob.parts = blobParts;
|
|
141
117
|
blob.size = blobSize;
|
|
118
|
+
|
|
142
119
|
return blob;
|
|
143
120
|
}
|
|
121
|
+
|
|
144
122
|
}, {
|
|
145
123
|
key: "arrayBuffer",
|
|
146
124
|
value: function () {
|
|
@@ -150,7 +128,6 @@ var BlobPolyfill = function () {
|
|
|
150
128
|
switch (_context.prev = _context.next) {
|
|
151
129
|
case 0:
|
|
152
130
|
return _context.abrupt("return", this._toArrayBuffer());
|
|
153
|
-
|
|
154
131
|
case 1:
|
|
155
132
|
case "end":
|
|
156
133
|
return _context.stop();
|
|
@@ -158,11 +135,9 @@ var BlobPolyfill = function () {
|
|
|
158
135
|
}
|
|
159
136
|
}, _callee, this);
|
|
160
137
|
}));
|
|
161
|
-
|
|
162
138
|
function arrayBuffer() {
|
|
163
139
|
return _arrayBuffer.apply(this, arguments);
|
|
164
140
|
}
|
|
165
|
-
|
|
166
141
|
return arrayBuffer;
|
|
167
142
|
}()
|
|
168
143
|
}, {
|
|
@@ -170,7 +145,6 @@ var BlobPolyfill = function () {
|
|
|
170
145
|
value: function () {
|
|
171
146
|
var _text = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2() {
|
|
172
147
|
var decoder, text, _iterator3, _step3, part;
|
|
173
|
-
|
|
174
148
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
175
149
|
while (1) {
|
|
176
150
|
switch (_context2.prev = _context2.next) {
|
|
@@ -178,7 +152,6 @@ var BlobPolyfill = function () {
|
|
|
178
152
|
decoder = new TextDecoder();
|
|
179
153
|
text = '';
|
|
180
154
|
_iterator3 = _createForOfIteratorHelper(this.parts);
|
|
181
|
-
|
|
182
155
|
try {
|
|
183
156
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
184
157
|
part = _step3.value;
|
|
@@ -189,9 +162,7 @@ var BlobPolyfill = function () {
|
|
|
189
162
|
} finally {
|
|
190
163
|
_iterator3.f();
|
|
191
164
|
}
|
|
192
|
-
|
|
193
165
|
return _context2.abrupt("return", text);
|
|
194
|
-
|
|
195
166
|
case 5:
|
|
196
167
|
case "end":
|
|
197
168
|
return _context2.stop();
|
|
@@ -199,21 +170,22 @@ var BlobPolyfill = function () {
|
|
|
199
170
|
}
|
|
200
171
|
}, _callee2, this);
|
|
201
172
|
}));
|
|
202
|
-
|
|
203
173
|
function text() {
|
|
204
174
|
return _text.apply(this, arguments);
|
|
205
175
|
}
|
|
206
|
-
|
|
207
176
|
return text;
|
|
208
177
|
}()
|
|
209
178
|
}, {
|
|
210
179
|
key: "stream",
|
|
211
|
-
value:
|
|
180
|
+
value:
|
|
181
|
+
function stream() {
|
|
212
182
|
return new _blobStream.BlobStream(this.parts);
|
|
213
183
|
}
|
|
184
|
+
|
|
214
185
|
}, {
|
|
215
186
|
key: "toString",
|
|
216
|
-
value:
|
|
187
|
+
value:
|
|
188
|
+
function toString() {
|
|
217
189
|
return '[object Blob]';
|
|
218
190
|
}
|
|
219
191
|
}, {
|
|
@@ -227,10 +199,8 @@ var BlobPolyfill = function () {
|
|
|
227
199
|
var buffer = new ArrayBuffer(this.size);
|
|
228
200
|
var bytes = new Uint8Array(buffer);
|
|
229
201
|
var offset = 0;
|
|
230
|
-
|
|
231
202
|
var _iterator4 = _createForOfIteratorHelper(this.parts),
|
|
232
|
-
|
|
233
|
-
|
|
203
|
+
_step4;
|
|
234
204
|
try {
|
|
235
205
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
236
206
|
var part = _step4.value;
|
|
@@ -242,15 +212,12 @@ var BlobPolyfill = function () {
|
|
|
242
212
|
} finally {
|
|
243
213
|
_iterator4.f();
|
|
244
214
|
}
|
|
245
|
-
|
|
246
215
|
return buffer;
|
|
247
216
|
}
|
|
248
217
|
}]);
|
|
249
218
|
return BlobPolyfill;
|
|
250
219
|
}();
|
|
251
|
-
|
|
252
220
|
exports.BlobPolyfill = BlobPolyfill;
|
|
253
|
-
|
|
254
221
|
function readType() {
|
|
255
222
|
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
256
223
|
var type = String(input).toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/node/file/blob.ts"],"names":["Symbol","toStringTag","BlobPolyfill","init","options","parts","size","part","bytes","TextEncoder","encode","push","byteLength","ArrayBuffer","Uint8Array","isView","buffer","byteOffset","String","type","readType","start","end","offset","Math","max","min","limit","span","blob","blobSize","blobParts","chunk","subarray","_toArrayBuffer","decoder","TextDecoder","text","decode","BlobStream","set","input","toLowerCase","test"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;;;;;;;;;sBAsJOA,MAAM,CAACC,W;;IAhJDC,Y;AAWX,0BAAkE;AAAA,QAAtDC,IAAsD,uEAAnC,EAAmC;AAAA,QAA/BC,OAA+B,uEAAJ,EAAI;AAAA;AAAA;AAAA;AAAA;AAChE,SAAKC,KAAL,GAAa,EAAb;AAEA,SAAKC,IAAL,GAAY,CAAZ;;AAHgE,+CAI7CH,IAJ6C;AAAA;;AAAA;AAIhE,0DAAyB;AAAA,YAAdI,IAAc;;AACvB,YAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC5B,cAAMC,KAAK,GAAG,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBH,IAAzB,CAAd;AACA,eAAKF,KAAL,CAAWM,IAAX,CAAgBH,KAAhB;AACA,eAAKF,IAAL,IAAaE,KAAK,CAACI,UAAnB;AACD,SAJD,MAIO,IAAIL,IAAI,YAAYL,YAApB,EAAkC;AAAA;;AACvC,eAAKI,IAAL,IAAaC,IAAI,CAACD,IAAlB;;AAGA,8BAAKD,KAAL,EAAWM,IAAX,qDAAmBJ,IAAI,CAACF,KAAxB;AACD,SALM,MAKA,IAAIE,IAAI,YAAYM,WAApB,EAAiC;AACtC,eAAKR,KAAL,CAAWM,IAAX,CAAgB,IAAIG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AY;AAC5C,MAAMtB,IAAI,GAAGD,MAAM,CAACuB,KAAD,CAAN,CAAcC,WAAd,EAAb;AACA,SAAO,mBAAmBC,IAAnB,CAAwBxB,IAAxB,IAAgC,EAAhC,GAAqCA,IAA5C;AACD","sourcesContent":["// Forked from @gozala's web-blob under MIT license https://github.com/Gozala/web-blob\nimport {BlobStream} from './blob-stream';\n\n/**\n * Forked from @gozala's web-blob under MIT license\n * @see https://github.com/Gozala/web-blob\n */\nexport class BlobPolyfill {\n // implements Blob {\n /** The MIME type of the data contained in the Blob. If type is unknown, string is empty. */\n readonly type: string;\n /** The size, in bytes, of the data contained in the Blob object. */\n size: number;\n private parts: Uint8Array[];\n /**\n * @param [init]\n * @param [options]\n */\n constructor(init: BlobPart[] = [], options: BlobPropertyBag = {}) {\n this.parts = [];\n\n this.size = 0;\n for (const part of init) {\n if (typeof part === 'string') {\n const bytes = new TextEncoder().encode(part);\n this.parts.push(bytes);\n this.size += bytes.byteLength;\n } else if (part instanceof BlobPolyfill) {\n this.size += part.size;\n // @ts-ignore - `parts` is marked private so TS will complain about\n // accessing it.\n this.parts.push(...part.parts);\n } else if (part instanceof ArrayBuffer) {\n this.parts.push(new Uint8Array(part));\n this.size += part.byteLength;\n } else if (part instanceof Uint8Array) {\n this.parts.push(part);\n this.size += part.byteLength;\n } else if (ArrayBuffer.isView(part)) {\n const {buffer, byteOffset, byteLength} = part;\n this.parts.push(new Uint8Array(buffer, byteOffset, byteLength));\n this.size += byteLength;\n } else {\n const bytes = new TextEncoder().encode(String(part));\n this.parts.push(bytes);\n this.size += bytes.byteLength;\n }\n }\n\n /** @private */\n this.type = readType(options.type);\n }\n\n /**\n * Returns a new Blob object containing the data in the specified range of\n * bytes of the blob on which it's called.\n * @param start=0 - An index into the Blob indicating the first\n * byte to include in the new Blob. If you specify a negative value, it's\n * treated as an offset from the end of the Blob toward the beginning. For\n * example, `-10` would be the 10th from last byte in the Blob. The default\n * value is `0`. If you specify a value for start that is larger than the\n * size of the source Blob, the returned Blob has size 0 and contains no\n * data.\n * @param end - An index into the `Blob` indicating the first byte\n * that will *not* be included in the new `Blob` (i.e. the byte exactly at\n * this index is not included). If you specify a negative value, it's treated\n * as an offset from the end of the Blob toward the beginning. For example,\n * `-10` would be the 10th from last byte in the `Blob`. The default value is\n * size.\n * @param type - The content type to assign to the new Blob;\n * this will be the value of its type property. The default value is an empty\n * string.\n */\n slice(start: number = 0, end: number = this.size, type: string = ''): Blob {\n const {size, parts: parts} = this;\n let offset = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);\n\n let limit = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);\n const span = Math.max(limit - offset, 0);\n const blob = new BlobPolyfill([], {type});\n\n if (span === 0) {\n // @ts-ignore\n return blob;\n }\n\n let blobSize = 0;\n const blobParts: Uint8Array[] = [];\n for (const part of parts) {\n const {byteLength} = part;\n if (offset > 0 && byteLength <= offset) {\n offset -= byteLength;\n limit -= byteLength;\n } else {\n const chunk = part.subarray(offset, Math.min(byteLength, limit));\n blobParts.push(chunk);\n blobSize += chunk.byteLength;\n // no longer need to take that into account\n offset = 0;\n\n // don't add the overflow to new blobParts\n if (blobSize >= span) {\n break;\n }\n }\n }\n\n blob.parts = blobParts;\n blob.size = blobSize;\n\n // @ts-ignore\n return blob;\n }\n\n /**\n * Returns a promise that resolves with an ArrayBuffer containing the entire\n * contents of the Blob as binary data.\n */\n // eslint-disable-next-line require-await\n async arrayBuffer(): Promise<ArrayBuffer> {\n return this._toArrayBuffer();\n }\n\n /**\n * Returns a promise that resolves with a USVString containing the entire\n * contents of the Blob interpreted as UTF-8 text.\n */\n // eslint-disable-next-line require-await\n async text(): Promise<string> {\n const decoder = new TextDecoder();\n let text = '';\n for (const part of this.parts) {\n text += decoder.decode(part);\n }\n return text;\n }\n\n /**\n */\n // @ts-ignore\n stream(): BlobStream<any> {\n return new BlobStream<any>(this.parts);\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return '[object Blob]';\n }\n\n get [Symbol.toStringTag]() {\n return 'Blob';\n }\n\n _toArrayBuffer(): ArrayBuffer {\n const buffer = new ArrayBuffer(this.size);\n const bytes = new Uint8Array(buffer);\n let offset = 0;\n for (const part of this.parts) {\n bytes.set(part, offset);\n offset += part.byteLength;\n }\n return buffer;\n }\n}\n\n/**\n */\nfunction readType(input: string = ''): string {\n const type = String(input).toLowerCase();\n return /[^\\u0020-\\u007E]/.test(type) ? '' : type;\n}\n"],"file":"blob.js"}
|
|
1
|
+
{"version":3,"file":"blob.js","names":["Symbol","toStringTag","BlobPolyfill","init","options","parts","size","part","bytes","TextEncoder","encode","push","byteLength","ArrayBuffer","Uint8Array","isView","buffer","byteOffset","String","type","readType","start","end","offset","Math","max","min","limit","span","blob","blobSize","blobParts","chunk","subarray","_toArrayBuffer","decoder","TextDecoder","text","decode","BlobStream","set","input","toLowerCase","test"],"sources":["../../../../src/node/file/blob.ts"],"sourcesContent":["// Forked from @gozala's web-blob under MIT license https://github.com/Gozala/web-blob\nimport {BlobStream} from './blob-stream';\n\n/**\n * Forked from @gozala's web-blob under MIT license\n * @see https://github.com/Gozala/web-blob\n */\nexport class BlobPolyfill {\n // implements Blob {\n /** The MIME type of the data contained in the Blob. If type is unknown, string is empty. */\n readonly type: string;\n /** The size, in bytes, of the data contained in the Blob object. */\n size: number;\n private parts: Uint8Array[];\n /**\n * @param [init]\n * @param [options]\n */\n constructor(init: BlobPart[] = [], options: BlobPropertyBag = {}) {\n this.parts = [];\n\n this.size = 0;\n for (const part of init) {\n if (typeof part === 'string') {\n const bytes = new TextEncoder().encode(part);\n this.parts.push(bytes);\n this.size += bytes.byteLength;\n } else if (part instanceof BlobPolyfill) {\n this.size += part.size;\n // @ts-ignore - `parts` is marked private so TS will complain about\n // accessing it.\n this.parts.push(...part.parts);\n } else if (part instanceof ArrayBuffer) {\n this.parts.push(new Uint8Array(part));\n this.size += part.byteLength;\n } else if (part instanceof Uint8Array) {\n this.parts.push(part);\n this.size += part.byteLength;\n } else if (ArrayBuffer.isView(part)) {\n const {buffer, byteOffset, byteLength} = part;\n this.parts.push(new Uint8Array(buffer, byteOffset, byteLength));\n this.size += byteLength;\n } else {\n const bytes = new TextEncoder().encode(String(part));\n this.parts.push(bytes);\n this.size += bytes.byteLength;\n }\n }\n\n /** @private */\n this.type = readType(options.type);\n }\n\n /**\n * Returns a new Blob object containing the data in the specified range of\n * bytes of the blob on which it's called.\n * @param start=0 - An index into the Blob indicating the first\n * byte to include in the new Blob. If you specify a negative value, it's\n * treated as an offset from the end of the Blob toward the beginning. For\n * example, `-10` would be the 10th from last byte in the Blob. The default\n * value is `0`. If you specify a value for start that is larger than the\n * size of the source Blob, the returned Blob has size 0 and contains no\n * data.\n * @param end - An index into the `Blob` indicating the first byte\n * that will *not* be included in the new `Blob` (i.e. the byte exactly at\n * this index is not included). If you specify a negative value, it's treated\n * as an offset from the end of the Blob toward the beginning. For example,\n * `-10` would be the 10th from last byte in the `Blob`. The default value is\n * size.\n * @param type - The content type to assign to the new Blob;\n * this will be the value of its type property. The default value is an empty\n * string.\n */\n slice(start: number = 0, end: number = this.size, type: string = ''): Blob {\n const {size, parts: parts} = this;\n let offset = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);\n\n let limit = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);\n const span = Math.max(limit - offset, 0);\n const blob = new BlobPolyfill([], {type});\n\n if (span === 0) {\n // @ts-ignore\n return blob;\n }\n\n let blobSize = 0;\n const blobParts: Uint8Array[] = [];\n for (const part of parts) {\n const {byteLength} = part;\n if (offset > 0 && byteLength <= offset) {\n offset -= byteLength;\n limit -= byteLength;\n } else {\n const chunk = part.subarray(offset, Math.min(byteLength, limit));\n blobParts.push(chunk);\n blobSize += chunk.byteLength;\n // no longer need to take that into account\n offset = 0;\n\n // don't add the overflow to new blobParts\n if (blobSize >= span) {\n break;\n }\n }\n }\n\n blob.parts = blobParts;\n blob.size = blobSize;\n\n // @ts-ignore\n return blob;\n }\n\n /**\n * Returns a promise that resolves with an ArrayBuffer containing the entire\n * contents of the Blob as binary data.\n */\n // eslint-disable-next-line require-await\n async arrayBuffer(): Promise<ArrayBuffer> {\n return this._toArrayBuffer();\n }\n\n /**\n * Returns a promise that resolves with a USVString containing the entire\n * contents of the Blob interpreted as UTF-8 text.\n */\n // eslint-disable-next-line require-await\n async text(): Promise<string> {\n const decoder = new TextDecoder();\n let text = '';\n for (const part of this.parts) {\n text += decoder.decode(part);\n }\n return text;\n }\n\n /**\n */\n // @ts-ignore\n stream(): BlobStream<any> {\n return new BlobStream<any>(this.parts);\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return '[object Blob]';\n }\n\n get [Symbol.toStringTag]() {\n return 'Blob';\n }\n\n _toArrayBuffer(): ArrayBuffer {\n const buffer = new ArrayBuffer(this.size);\n const bytes = new Uint8Array(buffer);\n let offset = 0;\n for (const part of this.parts) {\n bytes.set(part, offset);\n offset += part.byteLength;\n }\n return buffer;\n }\n}\n\n/**\n */\nfunction readType(input: string = ''): string {\n const type = String(input).toLowerCase();\n return /[^\\u0020-\\u007E]/.test(type) ? '' : type;\n}\n"],"mappings":";;;;;;;;;;;;;AACA;AAAyC;AAAA;AAAA;AAAA;AAAA,sBAsJlCA,MAAM,CAACC,WAAW;AAAA,IAhJZC,YAAY;;EAWvB,wBAAkE;IAAA,IAAtDC,IAAgB,uEAAG,EAAE;IAAA,IAAEC,OAAwB,uEAAG,CAAC,CAAC;IAAA;IAAA;IAAA;IAAA;IAC9D,IAAI,CAACC,KAAK,GAAG,EAAE;IAEf,IAAI,CAACC,IAAI,GAAG,CAAC;IAAC,2CACKH,IAAI;MAAA;IAAA;MAAvB,oDAAyB;QAAA,IAAdI,IAAI;QACb,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;UAC5B,IAAMC,KAAK,GAAG,IAAIC,WAAW,EAAE,CAACC,MAAM,CAACH,IAAI,CAAC;UAC5C,IAAI,CAACF,KAAK,CAACM,IAAI,CAACH,KAAK,CAAC;UACtB,IAAI,CAACF,IAAI,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KAAK,GAAG,IAAIM,UAAU,CAACE,MAAM,CAAC;MACpC,IAAIO,MAAM,GAAG,CAAC;MAAC,4CACI,IAAI,CAAClB,KAAK;QAAA;MAAA;QAA7B,uDAA+B;UAAA,IAApBE,IAAI;UACbC,KAAK,CAACgC,GAAG,CAACjC,IAAI,EAAEgB,MAAM,CAAC;UACvBA,MAAM,IAAIhB,IAAI,CAACK,UAAU;QAC3B;MAAC;QAAA;MAAA;QAAA;MAAA;MACD,OAAOI,MAAM;IACf;EAAC;EAAA;AAAA;AAAA;AAKH,SAASI,QAAQ,GAA6B;EAAA,IAA5BqB,KAAa,uEAAG,EAAE;EAClC,IAAMtB,IAAI,GAAGD,MAAM,CAACuB,KAAK,CAAC,CAACC,WAAW,EAAE;EACxC,OAAO,kBAAkB,CAACC,IAAI,CAACxB,IAAI,CAAC,GAAG,EAAE,GAAGA,IAAI;AAClD"}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.FileReaderPolyfill = void 0;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
13
|
var _btoa = require("../buffer/btoa.node");
|
|
21
|
-
|
|
22
14
|
var FileReaderPolyfill = function () {
|
|
15
|
+
|
|
23
16
|
function FileReaderPolyfill() {
|
|
24
17
|
(0, _classCallCheck2.default)(this, FileReaderPolyfill);
|
|
25
18
|
(0, _defineProperty2.default)(this, "onload", void 0);
|
|
@@ -39,7 +32,6 @@ var FileReaderPolyfill = function () {
|
|
|
39
32
|
(0, _defineProperty2.default)(this, "dispatchEvent", void 0);
|
|
40
33
|
this.onload = null;
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
(0, _createClass2.default)(FileReaderPolyfill, [{
|
|
44
36
|
key: "abort",
|
|
45
37
|
value: function abort() {
|
|
@@ -56,10 +48,8 @@ var FileReaderPolyfill = function () {
|
|
|
56
48
|
case 0:
|
|
57
49
|
_context.next = 2;
|
|
58
50
|
return blob.arrayBuffer();
|
|
59
|
-
|
|
60
51
|
case 2:
|
|
61
52
|
arrayBuffer = _context.sent;
|
|
62
|
-
|
|
63
53
|
if (this.onload) {
|
|
64
54
|
this.onload({
|
|
65
55
|
target: {
|
|
@@ -67,7 +57,6 @@ var FileReaderPolyfill = function () {
|
|
|
67
57
|
}
|
|
68
58
|
});
|
|
69
59
|
}
|
|
70
|
-
|
|
71
60
|
case 4:
|
|
72
61
|
case "end":
|
|
73
62
|
return _context.stop();
|
|
@@ -75,11 +64,9 @@ var FileReaderPolyfill = function () {
|
|
|
75
64
|
}
|
|
76
65
|
}, _callee, this);
|
|
77
66
|
}));
|
|
78
|
-
|
|
79
67
|
function readAsArrayBuffer(_x) {
|
|
80
68
|
return _readAsArrayBuffer.apply(this, arguments);
|
|
81
69
|
}
|
|
82
|
-
|
|
83
70
|
return readAsArrayBuffer;
|
|
84
71
|
}()
|
|
85
72
|
}, {
|
|
@@ -91,7 +78,6 @@ var FileReaderPolyfill = function () {
|
|
|
91
78
|
switch (_context2.prev = _context2.next) {
|
|
92
79
|
case 0:
|
|
93
80
|
throw Error('Not implemented');
|
|
94
|
-
|
|
95
81
|
case 1:
|
|
96
82
|
case "end":
|
|
97
83
|
return _context2.stop();
|
|
@@ -99,11 +85,9 @@ var FileReaderPolyfill = function () {
|
|
|
99
85
|
}
|
|
100
86
|
}, _callee2);
|
|
101
87
|
}));
|
|
102
|
-
|
|
103
88
|
function readAsBinaryString(_x2) {
|
|
104
89
|
return _readAsBinaryString.apply(this, arguments);
|
|
105
90
|
}
|
|
106
|
-
|
|
107
91
|
return readAsBinaryString;
|
|
108
92
|
}()
|
|
109
93
|
}, {
|
|
@@ -117,11 +101,9 @@ var FileReaderPolyfill = function () {
|
|
|
117
101
|
case 0:
|
|
118
102
|
_context3.next = 2;
|
|
119
103
|
return blob.text();
|
|
120
|
-
|
|
121
104
|
case 2:
|
|
122
105
|
text = _context3.sent;
|
|
123
106
|
dataUrl = "data://;base64,".concat((0, _btoa.atob)(text));
|
|
124
|
-
|
|
125
107
|
if (this.onload) {
|
|
126
108
|
this.onload({
|
|
127
109
|
target: {
|
|
@@ -129,7 +111,6 @@ var FileReaderPolyfill = function () {
|
|
|
129
111
|
}
|
|
130
112
|
});
|
|
131
113
|
}
|
|
132
|
-
|
|
133
114
|
case 5:
|
|
134
115
|
case "end":
|
|
135
116
|
return _context3.stop();
|
|
@@ -137,11 +118,9 @@ var FileReaderPolyfill = function () {
|
|
|
137
118
|
}
|
|
138
119
|
}, _callee3, this);
|
|
139
120
|
}));
|
|
140
|
-
|
|
141
121
|
function readAsDataURL(_x3) {
|
|
142
122
|
return _readAsDataURL.apply(this, arguments);
|
|
143
123
|
}
|
|
144
|
-
|
|
145
124
|
return readAsDataURL;
|
|
146
125
|
}()
|
|
147
126
|
}, {
|
|
@@ -155,10 +134,8 @@ var FileReaderPolyfill = function () {
|
|
|
155
134
|
case 0:
|
|
156
135
|
_context4.next = 2;
|
|
157
136
|
return blob.text();
|
|
158
|
-
|
|
159
137
|
case 2:
|
|
160
138
|
text = _context4.sent;
|
|
161
|
-
|
|
162
139
|
if (this.onload) {
|
|
163
140
|
this.onload({
|
|
164
141
|
target: {
|
|
@@ -166,7 +143,6 @@ var FileReaderPolyfill = function () {
|
|
|
166
143
|
}
|
|
167
144
|
});
|
|
168
145
|
}
|
|
169
|
-
|
|
170
146
|
case 4:
|
|
171
147
|
case "end":
|
|
172
148
|
return _context4.stop();
|
|
@@ -174,16 +150,13 @@ var FileReaderPolyfill = function () {
|
|
|
174
150
|
}
|
|
175
151
|
}, _callee4, this);
|
|
176
152
|
}));
|
|
177
|
-
|
|
178
153
|
function readAsText(_x4) {
|
|
179
154
|
return _readAsText.apply(this, arguments);
|
|
180
155
|
}
|
|
181
|
-
|
|
182
156
|
return readAsText;
|
|
183
157
|
}()
|
|
184
158
|
}]);
|
|
185
159
|
return FileReaderPolyfill;
|
|
186
160
|
}();
|
|
187
|
-
|
|
188
161
|
exports.FileReaderPolyfill = FileReaderPolyfill;
|
|
189
162
|
//# sourceMappingURL=file-reader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"file-reader.js","names":["FileReaderPolyfill","onload","blob","arrayBuffer","target","result","Error","text","dataUrl","atob"],"sources":["../../../../src/node/file/file-reader.ts"],"sourcesContent":["import {atob} from '../buffer/btoa.node';\n\nexport class FileReaderPolyfill implements FileReader {\n // onload: ({result: any}) => void;\n onload;\n onabort;\n onerror;\n error;\n onloadstart;\n onloadend;\n onprogress;\n\n readyState;\n result;\n DONE;\n EMPTY;\n LOADING;\n addEventListener;\n removeEventListener;\n dispatchEvent;\n\n constructor() {\n this.onload = null;\n }\n\n abort(): void {\n return;\n }\n\n async readAsArrayBuffer(blob: Blob): Promise<void> {\n const arrayBuffer = await blob.arrayBuffer();\n if (this.onload) {\n this.onload({target: {result: arrayBuffer}});\n }\n }\n\n async readAsBinaryString(blob) {\n throw Error('Not implemented');\n }\n\n async readAsDataURL(blob) {\n const text = await blob.text();\n const dataUrl = `data://;base64,${atob(text)}`;\n if (this.onload) {\n this.onload({target: {result: dataUrl}});\n }\n }\n\n async readAsText(blob) {\n const text = await blob.text();\n if (this.onload) {\n this.onload({target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AA;IAAA;EAAA;IAAA;IAAA;MAAA,4EAED,kBAAiBN,IAAI;QAAA;QAAA;UAAA;YAAA;cAAA;gBAAA;gBAAA,OACAA,IAAI,CAACK,IAAI,EAAE;cAAA;gBAAxBA,IAAI;gBACV,IAAI,IAAI,CAACN,MAAM,EAAE;kBACf,IAAI,CAACA,MAAM,CAAC;oBAACG,MAAM,EAAE;sBAACC,MAAM,EAAEE;oBAAI;kBAAC,CAAC,CAAC;gBACvC;cAAC;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CACF;MAAA;QAAA;MAAA;MAAA;IAAA;EAAA;EAAA;AAAA;AAAA"}
|
|
@@ -1,44 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.FilePolyfill = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
15
|
var _blob = require("./blob");
|
|
25
|
-
|
|
26
16
|
var _Symbol$toStringTag;
|
|
27
|
-
|
|
28
17
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
29
|
-
|
|
30
18
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
|
-
|
|
32
19
|
_Symbol$toStringTag = Symbol.toStringTag;
|
|
33
|
-
|
|
34
20
|
var FilePolyfill = function (_BlobPolyfill) {
|
|
35
21
|
(0, _inherits2.default)(FilePolyfill, _BlobPolyfill);
|
|
36
|
-
|
|
37
22
|
var _super = _createSuper(FilePolyfill);
|
|
38
23
|
|
|
39
24
|
function FilePolyfill(init, name) {
|
|
40
25
|
var _this;
|
|
41
|
-
|
|
42
26
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
43
27
|
(0, _classCallCheck2.default)(this, FilePolyfill);
|
|
44
28
|
_this = _super.call(this, init, options);
|
|
@@ -49,7 +33,6 @@ var FilePolyfill = function (_BlobPolyfill) {
|
|
|
49
33
|
_this.lastModified = (options === null || options === void 0 ? void 0 : options.lastModified) || Date.now();
|
|
50
34
|
return _this;
|
|
51
35
|
}
|
|
52
|
-
|
|
53
36
|
(0, _createClass2.default)(FilePolyfill, [{
|
|
54
37
|
key: _Symbol$toStringTag,
|
|
55
38
|
get: function get() {
|
|
@@ -58,6 +41,5 @@ var FilePolyfill = function (_BlobPolyfill) {
|
|
|
58
41
|
}]);
|
|
59
42
|
return FilePolyfill;
|
|
60
43
|
}(_blob.BlobPolyfill);
|
|
61
|
-
|
|
62
44
|
exports.FilePolyfill = FilePolyfill;
|
|
63
45
|
//# sourceMappingURL=file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"file.js","names":["Symbol","toStringTag","FilePolyfill","init","name","options","String","replace","lastModified","Date","now","BlobPolyfill"],"sources":["../../../../src/node/file/file.ts"],"sourcesContent":["// Forked from @gozala's web-file under MIT license https://github.com/Gozala/web-file\nimport {BlobPolyfill} from './blob';\n\n/**\n * Forked from @gozala's web-file under MIT license\n * @see https://github.com/Gozala/web-file\n */\n// @ts-ignore\nexport class FilePolyfill extends BlobPolyfill {\n // implements File {\n // public API\n /** The name of the file referenced by the File object. */\n name: string = '';\n /** The path the URL of the File is relative to. */\n webkitRelativePath: string = '';\n\n /**\n * Returns the last modified time of the file, in millisecond since the UNIX\n * epoch (January 1st, 1970 at Midnight).\n */\n lastModified: number;\n\n /**\n * @param init\n * @param name - A USVString representing the file name or the path\n * to the file.\n * @param [options]\n */\n constructor(init: BlobPart[], name: string, options: FilePropertyBag = {}) {\n super(init, options);\n // Per File API spec https://w3c.github.io/FileAPI/#file-constructor\n // Every \"/\" character of file name must be replaced with a \":\".\n /** @private */\n this.name = String(name).replace(/\\//g, ':');\n /** @private */\n this.lastModified = options?.lastModified || Date.now();\n }\n\n get [Symbol.toStringTag]() {\n return 'File';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA;AAAoC;AAAA;AAAA;AAAA,sBAqC7BA,MAAM,CAACC,WAAW;AAAA,IA9BZC,YAAY;EAAA;EAAA;;EAoBvB,sBAAYC,IAAgB,EAAEC,IAAY,EAAiC;IAAA;IAAA,IAA/BC,OAAwB,uEAAG,CAAC,CAAC;IAAA;IACvE,0BAAMF,IAAI,EAAEE,OAAO;IAAE,mFAjBR,EAAE;IAAA,iGAEY,EAAE;IAAA;IAmB7B,MAAKD,IAAI,GAAGE,MAAM,CAACF,IAAI,CAAC,CAACG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;IAE5C,MAAKC,YAAY,GAAG,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,YAAY,KAAIC,IAAI,CAACC,GAAG,EAAE;IAAC;EAC1D;EAAC;IAAA;IAAA,KAED,eAA2B;MACzB,OAAO,MAAM;IACf;EAAC;EAAA;AAAA,EAhC+BC,kBAAY;AAAA"}
|
|
@@ -4,24 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.installFilePolyfills = installFilePolyfills;
|
|
7
|
-
|
|
8
7
|
var _readableStream = require("./readable-stream");
|
|
9
|
-
|
|
10
8
|
var _blob = require("./blob");
|
|
11
|
-
|
|
12
9
|
var _fileReader = require("./file-reader");
|
|
13
|
-
|
|
14
10
|
var _file = require("./file");
|
|
15
|
-
|
|
16
11
|
function installFilePolyfills() {
|
|
17
12
|
if (typeof ReadableStream === 'undefined' && global) {
|
|
18
13
|
global.ReadableStream = _readableStream.ReadableStreamPolyfill;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
if (typeof Blob === 'undefined' && global) {
|
|
22
16
|
global.Blob = _blob.BlobPolyfill;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
if (typeof FileReader === 'undefined' && global) {
|
|
26
19
|
global.FileReader = _fileReader.FileReaderPolyfill;
|
|
27
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"install-file-polyfills.js","names":["installFilePolyfills","ReadableStream","global","ReadableStreamPolyfill","Blob","BlobPolyfill","FileReader","FileReaderPolyfill","File","FilePolyfill"],"sources":["../../../../src/node/file/install-file-polyfills.ts"],"sourcesContent":["import {ReadableStreamPolyfill} from './readable-stream';\nimport {BlobPolyfill} from './blob';\nimport {FileReaderPolyfill} from './file-reader';\nimport {FilePolyfill} from './file';\n\nexport function installFilePolyfills() {\n if (typeof ReadableStream === 'undefined' && global) {\n // @ts-ignore;\n global.ReadableStream = ReadableStreamPolyfill;\n }\n\n if (typeof Blob === 'undefined' && global) {\n // @ts-ignore;\n global.Blob = BlobPolyfill;\n }\n\n if (typeof FileReader === 'undefined' && global) {\n // @ts-ignore;\n global.FileReader = FileReaderPolyfill;\n }\n\n // Install minimal Node.js File polyfill\n if (typeof File === 'undefined' && global) {\n // @ts-ignore;\n global.File = FilePolyfill;\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAEO,SAASA,oBAAoB,GAAG;EACrC,IAAI,OAAOC,cAAc,KAAK,WAAW,IAAIC,MAAM,EAAE;IAEnDA,MAAM,CAACD,cAAc,GAAGE,sCAAsB;EAChD;EAEA,IAAI,OAAOC,IAAI,KAAK,WAAW,IAAIF,MAAM,EAAE;IAEzCA,MAAM,CAACE,IAAI,GAAGC,kBAAY;EAC5B;EAEA,IAAI,OAAOC,UAAU,KAAK,WAAW,IAAIJ,MAAM,EAAE;IAE/CA,MAAM,CAACI,UAAU,GAAGC,8BAAkB;EACxC;;EAGA,IAAI,OAAOC,IAAI,KAAK,WAAW,IAAIN,MAAM,EAAE;IAEzCA,MAAM,CAACM,IAAI,GAAGC,kBAAY;EAC5B;AACF"}
|
|
@@ -1,40 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ReadableStreamPolyfill = void 0;
|
|
9
|
-
|
|
8
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
10
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
|
|
14
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
|
|
16
12
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
|
|
18
13
|
var _webStreamsPolyfill = require("web-streams-polyfill");
|
|
19
|
-
|
|
20
14
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
21
|
-
|
|
22
15
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
23
|
-
|
|
24
16
|
delete global.ReadableStream;
|
|
25
17
|
|
|
26
18
|
var ReadableStreamPolyfill = function (_WSPReadableStream) {
|
|
27
19
|
(0, _inherits2.default)(ReadableStreamPolyfill, _WSPReadableStream);
|
|
28
|
-
|
|
29
20
|
var _super = _createSuper(ReadableStreamPolyfill);
|
|
30
|
-
|
|
31
21
|
function ReadableStreamPolyfill() {
|
|
32
22
|
(0, _classCallCheck2.default)(this, ReadableStreamPolyfill);
|
|
33
23
|
return _super.apply(this, arguments);
|
|
34
24
|
}
|
|
35
|
-
|
|
36
|
-
return ReadableStreamPolyfill;
|
|
25
|
+
return (0, _createClass2.default)(ReadableStreamPolyfill);
|
|
37
26
|
}(_webStreamsPolyfill.ReadableStream);
|
|
38
|
-
|
|
39
27
|
exports.ReadableStreamPolyfill = ReadableStreamPolyfill;
|
|
40
28
|
//# sourceMappingURL=readable-stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"readable-stream.js","names":["global","ReadableStream","ReadableStreamPolyfill","WSPReadableStream"],"sources":["../../../../src/node/file/readable-stream.ts"],"sourcesContent":["import {ReadableStream as WSPReadableStream} from 'web-streams-polyfill';\n\n// Want a polyfill, but please don't install it\n// @ts-ignore\ndelete global.ReadableStream;\n\n// @ts-ignore\nexport class ReadableStreamPolyfill<T> extends WSPReadableStream<T> implements ReadableStream {}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAyE;AAAA;AAIzE,OAAOA,MAAM,CAACC,cAAc;;AAAC,IAGhBC,sBAAsB;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;AAAA,EAAYC,kCAAiB;AAAA"}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.encodeImageToStreamNode = encodeImageToStreamNode;
|
|
9
7
|
exports.encodeImageNode = encodeImageNode;
|
|
10
|
-
|
|
8
|
+
exports.encodeImageToStreamNode = encodeImageToStreamNode;
|
|
11
9
|
var _savePixels = _interopRequireDefault(require("save-pixels"));
|
|
12
|
-
|
|
13
10
|
var _ndarray = _interopRequireDefault(require("ndarray"));
|
|
14
|
-
|
|
15
11
|
var _toArrayBuffer = require("../buffer/to-array-buffer.node");
|
|
16
12
|
|
|
17
13
|
function encodeImageToStreamNode(image, options) {
|
|
18
14
|
var type = options.type ? options.type.replace('image/', '') : 'jpeg';
|
|
19
15
|
var pixels = (0, _ndarray.default)(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);
|
|
16
|
+
|
|
20
17
|
return (0, _savePixels.default)(pixels, type, options);
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
function encodeImageNode(image, options) {
|
|
24
20
|
var imageStream = encodeImageToStreamNode(image, options);
|
|
25
21
|
return new Promise(function (resolve) {
|