@loaders.gl/polyfills 4.0.0-alpha.4 → 4.0.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.
Files changed (208) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2 -2
  4. package/dist/dist.min.js +4207 -0
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/index.js +103 -0
  8. package/dist/es5/index.js.map +1 -0
  9. package/dist/es5/lib/encoding-indexes.js +37 -0
  10. package/dist/es5/lib/encoding-indexes.js.map +1 -0
  11. package/dist/es5/lib/encoding.js +1214 -0
  12. package/dist/es5/lib/encoding.js.map +1 -0
  13. package/{src/libs/encoding-indexes.js → dist/es5/libs/encoding-indexes-asian.js} +2 -40
  14. package/dist/es5/node/buffer/btoa.node.js +14 -0
  15. package/dist/es5/node/buffer/btoa.node.js.map +1 -0
  16. package/dist/es5/node/buffer/to-array-buffer.node.js +14 -0
  17. package/dist/es5/node/buffer/to-array-buffer.node.js.map +1 -0
  18. package/dist/es5/node/fetch/fetch-file.node.js +83 -0
  19. package/dist/es5/node/fetch/fetch-file.node.js.map +1 -0
  20. package/dist/es5/node/fetch/fetch.node.js +194 -0
  21. package/dist/es5/node/fetch/fetch.node.js.map +1 -0
  22. package/dist/es5/node/fetch/headers.node.js +151 -0
  23. package/dist/es5/node/fetch/headers.node.js.map +1 -0
  24. package/dist/es5/node/fetch/response.node.js +182 -0
  25. package/dist/es5/node/fetch/response.node.js.map +1 -0
  26. package/dist/es5/node/fetch/utils/decode-data-uri.node.js +58 -0
  27. package/dist/es5/node/fetch/utils/decode-data-uri.node.js.map +1 -0
  28. package/dist/es5/node/fetch/utils/stream-utils.node.js +92 -0
  29. package/dist/es5/node/fetch/utils/stream-utils.node.js.map +1 -0
  30. package/dist/es5/node/file/blob-stream-controller.js +90 -0
  31. package/dist/es5/node/file/blob-stream-controller.js.map +1 -0
  32. package/dist/es5/node/file/blob-stream.js +64 -0
  33. package/dist/es5/node/file/blob-stream.js.map +1 -0
  34. package/dist/es5/node/file/blob.js +212 -0
  35. package/dist/es5/node/file/blob.js.map +1 -0
  36. package/dist/es5/node/file/file-reader.js +153 -0
  37. package/dist/es5/node/file/file-reader.js.map +1 -0
  38. package/dist/es5/node/file/file.js +44 -0
  39. package/dist/es5/node/file/file.js.map +1 -0
  40. package/dist/es5/node/file/install-file-polyfills.js +25 -0
  41. package/dist/es5/node/file/install-file-polyfills.js.map +1 -0
  42. package/dist/es5/node/file/readable-stream.js +27 -0
  43. package/dist/es5/node/file/readable-stream.js.map +1 -0
  44. package/dist/es5/node/images/encode-image.node.js +30 -0
  45. package/dist/es5/node/images/encode-image.node.js.map +1 -0
  46. package/dist/es5/node/images/parse-image.node.js +64 -0
  47. package/dist/es5/node/images/parse-image.node.js.map +1 -0
  48. package/dist/es5/promise/all-settled.js +28 -0
  49. package/dist/es5/promise/all-settled.js.map +1 -0
  50. package/dist/es5/utils/assert.js +12 -0
  51. package/dist/es5/utils/assert.js.map +1 -0
  52. package/dist/es5/utils/globals.js +18 -0
  53. package/dist/es5/utils/globals.js.map +1 -0
  54. package/dist/esm/bundle.js +4 -0
  55. package/dist/esm/bundle.js.map +1 -0
  56. package/dist/esm/index.js +54 -0
  57. package/dist/esm/index.js.map +1 -0
  58. package/dist/esm/lib/encoding-indexes.js +30 -0
  59. package/dist/esm/lib/encoding-indexes.js.map +1 -0
  60. package/dist/esm/lib/encoding.js +1206 -0
  61. package/dist/esm/lib/encoding.js.map +1 -0
  62. package/dist/{libs/encoding-indexes.js → esm/libs/encoding-indexes-asian.js} +2 -40
  63. package/dist/esm/node/buffer/btoa.node.js +7 -0
  64. package/dist/esm/node/buffer/btoa.node.js.map +1 -0
  65. package/dist/esm/node/buffer/to-array-buffer.node.js +8 -0
  66. package/dist/esm/node/buffer/to-array-buffer.node.js.map +1 -0
  67. package/dist/esm/node/fetch/fetch-file.node.js +50 -0
  68. package/dist/esm/node/fetch/fetch-file.node.js.map +1 -0
  69. package/dist/esm/node/fetch/fetch.node.js +126 -0
  70. package/dist/esm/node/fetch/fetch.node.js.map +1 -0
  71. package/dist/esm/node/fetch/headers.node.js +102 -0
  72. package/dist/esm/node/fetch/headers.node.js.map +1 -0
  73. package/dist/esm/node/fetch/response.node.js +67 -0
  74. package/dist/esm/node/fetch/response.node.js.map +1 -0
  75. package/dist/esm/node/fetch/utils/decode-data-uri.node.js +45 -0
  76. package/dist/esm/node/fetch/utils/decode-data-uri.node.js.map +1 -0
  77. package/dist/esm/node/fetch/utils/stream-utils.node.js +43 -0
  78. package/dist/esm/node/fetch/utils/stream-utils.node.js.map +1 -0
  79. package/dist/esm/node/file/blob-stream-controller.js +44 -0
  80. package/dist/esm/node/file/blob-stream-controller.js.map +1 -0
  81. package/dist/esm/node/file/blob-stream.js +20 -0
  82. package/dist/esm/node/file/blob-stream.js.map +1 -0
  83. package/dist/esm/node/file/blob.js +120 -0
  84. package/dist/esm/node/file/blob.js.map +1 -0
  85. package/dist/esm/node/file/file-reader.js +60 -0
  86. package/dist/esm/node/file/file-reader.js.map +1 -0
  87. package/dist/esm/node/file/file.js +19 -0
  88. package/dist/esm/node/file/file.js.map +1 -0
  89. package/dist/esm/node/file/install-file-polyfills.js +19 -0
  90. package/dist/esm/node/file/install-file-polyfills.js.map +1 -0
  91. package/dist/esm/node/file/readable-stream.js +4 -0
  92. package/dist/esm/node/file/readable-stream.js.map +1 -0
  93. package/dist/esm/node/images/encode-image.node.js +20 -0
  94. package/dist/esm/node/images/encode-image.node.js.map +1 -0
  95. package/dist/esm/node/images/parse-image.node.js +29 -0
  96. package/dist/esm/node/images/parse-image.node.js.map +1 -0
  97. package/dist/esm/promise/all-settled.js +19 -0
  98. package/dist/esm/promise/all-settled.js.map +1 -0
  99. package/dist/esm/utils/assert.js +6 -0
  100. package/dist/esm/utils/assert.js.map +1 -0
  101. package/dist/esm/utils/globals.js +9 -0
  102. package/dist/esm/utils/globals.js.map +1 -0
  103. package/dist/index.d.ts +8 -0
  104. package/dist/index.d.ts.map +1 -0
  105. package/dist/index.js +90 -49
  106. package/dist/lib/encoding-indexes.d.ts +31 -0
  107. package/dist/lib/encoding-indexes.d.ts.map +1 -0
  108. package/dist/lib/encoding-indexes.js +35 -0
  109. package/dist/lib/encoding.d.ts +15 -0
  110. package/dist/lib/encoding.d.ts.map +1 -0
  111. package/dist/lib/encoding.js +2779 -0
  112. package/dist/libs/encoding-indexes-asian.d.ts +10 -0
  113. package/dist/libs/encoding-indexes-asian.d.ts.map +1 -0
  114. package/dist/libs/encoding-indexes-asian.js +14 -0
  115. package/dist/node/buffer/btoa.node.d.ts +3 -0
  116. package/dist/node/buffer/btoa.node.d.ts.map +1 -0
  117. package/dist/node/buffer/btoa.node.js +12 -5
  118. package/dist/node/buffer/to-array-buffer.node.d.ts +2 -0
  119. package/dist/node/buffer/to-array-buffer.node.d.ts.map +1 -0
  120. package/dist/node/buffer/to-array-buffer.node.js +11 -8
  121. package/dist/node/fetch/fetch-file.node.d.ts +4 -0
  122. package/dist/node/fetch/fetch-file.node.d.ts.map +1 -0
  123. package/dist/node/fetch/fetch-file.node.js +51 -0
  124. package/dist/node/fetch/fetch.node.d.ts +12 -0
  125. package/dist/node/fetch/fetch.node.d.ts.map +1 -0
  126. package/dist/node/fetch/fetch.node.js +128 -111
  127. package/dist/node/fetch/headers.node.d.ts +34 -0
  128. package/dist/node/fetch/headers.node.d.ts.map +1 -0
  129. package/dist/node/fetch/headers.node.js +95 -114
  130. package/dist/node/fetch/response.node.d.ts +22 -0
  131. package/dist/node/fetch/response.node.d.ts.map +1 -0
  132. package/dist/node/fetch/response.node.js +72 -84
  133. package/dist/node/fetch/utils/decode-data-uri.node.d.ts +16 -0
  134. package/dist/node/fetch/utils/decode-data-uri.node.d.ts.map +1 -0
  135. package/dist/node/fetch/utils/decode-data-uri.node.js +63 -55
  136. package/dist/node/fetch/utils/stream-utils.node.d.ts +17 -0
  137. package/dist/node/fetch/utils/stream-utils.node.d.ts.map +1 -0
  138. package/dist/node/fetch/utils/stream-utils.node.js +69 -85
  139. package/dist/node/file/blob-stream-controller.d.ts +29 -0
  140. package/dist/node/file/blob-stream-controller.d.ts.map +1 -0
  141. package/dist/node/file/blob-stream-controller.js +59 -52
  142. package/dist/node/file/blob-stream.d.ts +25 -0
  143. package/dist/node/file/blob-stream.d.ts.map +1 -0
  144. package/dist/node/file/blob-stream.js +36 -25
  145. package/dist/node/file/blob.d.ts +58 -0
  146. package/dist/node/file/blob.d.ts.map +1 -0
  147. package/dist/node/file/blob.js +151 -131
  148. package/dist/node/file/file-reader.d.ts +24 -0
  149. package/dist/node/file/file-reader.d.ts.map +1 -0
  150. package/dist/node/file/file-reader.js +28 -77
  151. package/dist/node/file/file.d.ts +25 -0
  152. package/dist/node/file/file.d.ts.map +1 -0
  153. package/dist/node/file/file.js +36 -25
  154. package/dist/node/file/install-file-polyfills.d.ts +2 -0
  155. package/dist/node/file/install-file-polyfills.d.ts.map +1 -0
  156. package/dist/node/file/install-file-polyfills.js +26 -21
  157. package/dist/node/file/readable-stream.d.ts +4 -0
  158. package/dist/node/file/readable-stream.d.ts.map +1 -0
  159. package/dist/node/file/readable-stream.js +10 -3
  160. package/dist/node/images/encode-image.node.d.ts +20 -0
  161. package/dist/node/images/encode-image.node.d.ts.map +1 -0
  162. package/dist/node/images/encode-image.node.js +38 -17
  163. package/dist/node/images/parse-image.node.d.ts +13 -0
  164. package/dist/node/images/parse-image.node.d.ts.map +1 -0
  165. package/dist/node/images/parse-image.node.js +40 -19
  166. package/dist/promise/all-settled.d.ts +10 -0
  167. package/dist/promise/all-settled.d.ts.map +1 -0
  168. package/dist/promise/all-settled.js +22 -17
  169. package/dist/utils/assert.d.ts +2 -0
  170. package/dist/utils/assert.d.ts.map +1 -0
  171. package/dist/utils/assert.js +8 -5
  172. package/dist/utils/globals.d.ts +4 -0
  173. package/dist/utils/globals.d.ts.map +1 -0
  174. package/dist/utils/globals.js +34 -7
  175. package/package.json +9 -8
  176. package/src/index.ts +9 -6
  177. package/src/lib/encoding-indexes.ts +34 -0
  178. package/src/{libs/encoding.js → lib/encoding.ts} +78 -78
  179. package/src/libs/encoding-indexes-asian.js +13 -0
  180. package/src/node/fetch/fetch-file.node.ts +51 -0
  181. package/src/node/fetch/fetch.node.ts +64 -30
  182. package/src/node/fetch/headers.node.ts +1 -1
  183. package/src/node/fetch/response.node.ts +4 -2
  184. package/src/node/fetch/utils/decode-data-uri.node.ts +7 -6
  185. package/src/node/fetch/utils/stream-utils.node.ts +39 -64
  186. package/src/node/images/parse-image.node.ts +35 -20
  187. package/dist/bundle.js.map +0 -1
  188. package/dist/index.js.map +0 -1
  189. package/dist/libs/encoding.js +0 -3084
  190. package/dist/node/buffer/btoa.node.js.map +0 -1
  191. package/dist/node/buffer/to-array-buffer.node.js.map +0 -1
  192. package/dist/node/fetch/fetch.node.js.map +0 -1
  193. package/dist/node/fetch/headers.node.js.map +0 -1
  194. package/dist/node/fetch/response.node.js.map +0 -1
  195. package/dist/node/fetch/utils/decode-data-uri.node.js.map +0 -1
  196. package/dist/node/fetch/utils/stream-utils.node.js.map +0 -1
  197. package/dist/node/file/blob-stream-controller.js.map +0 -1
  198. package/dist/node/file/blob-stream.js.map +0 -1
  199. package/dist/node/file/blob.js.map +0 -1
  200. package/dist/node/file/file-reader.js.map +0 -1
  201. package/dist/node/file/file.js.map +0 -1
  202. package/dist/node/file/install-file-polyfills.js.map +0 -1
  203. package/dist/node/file/readable-stream.js.map +0 -1
  204. package/dist/node/images/encode-image.node.js.map +0 -1
  205. package/dist/node/images/parse-image.node.js.map +0 -1
  206. package/dist/promise/all-settled.js.map +0 -1
  207. package/dist/utils/assert.js.map +0 -1
  208. package/dist/utils/globals.js.map +0 -1
@@ -1,56 +1,63 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- export class BlobStreamController {
3
- constructor(chunks) {
4
- _defineProperty(this, "chunks", void 0);
5
-
6
- _defineProperty(this, "isWorking", false);
7
-
8
- _defineProperty(this, "isCancelled", false);
9
-
10
- this.chunks = chunks;
11
- }
12
-
13
- start(controller) {
14
- this.work(controller);
15
- }
16
-
17
- async work(controller) {
18
- const {
19
- chunks
20
- } = this;
21
- this.isWorking = true;
22
-
23
- while (!this.isCancelled && (controller.desiredSize || 0) > 0) {
24
- let next;
25
-
26
- try {
27
- next = chunks.next();
28
- } catch (error) {
29
- controller.error(error);
30
- break;
31
- }
32
-
33
- if (next) {
34
- if (!next.done && !this.isCancelled) {
35
- controller.enqueue(next.value);
36
- } else {
37
- controller.close();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BlobStreamController = void 0;
4
+ /**
5
+ * Forked from @gozala's web-blob under MIT license
6
+ * @see https://github.com/Gozala/web-blob
7
+ */
8
+ class BlobStreamController {
9
+ /**
10
+ * @param chunks
11
+ */
12
+ constructor(chunks) {
13
+ this.isWorking = false;
14
+ this.isCancelled = false;
15
+ this.chunks = chunks;
16
+ }
17
+ /**
18
+ * @param controller
19
+ */
20
+ start(controller) {
21
+ this.work(controller); // eslint-disable-line @typescript-eslint/no-floating-promises
22
+ }
23
+ /**
24
+ *
25
+ * @param controller
26
+ */
27
+ async work(controller) {
28
+ const { chunks } = this;
29
+ this.isWorking = true;
30
+ while (!this.isCancelled && (controller.desiredSize || 0) > 0) {
31
+ let next;
32
+ try {
33
+ next = chunks.next();
34
+ }
35
+ catch (error) {
36
+ controller.error(error);
37
+ break;
38
+ }
39
+ if (next) {
40
+ if (!next.done && !this.isCancelled) {
41
+ controller.enqueue(next.value);
42
+ }
43
+ else {
44
+ controller.close();
45
+ }
46
+ }
47
+ }
48
+ this.isWorking = false;
49
+ }
50
+ /**
51
+ *
52
+ * @param {ReadableStreamDefaultController} controller
53
+ */
54
+ pull(controller) {
55
+ if (!this.isWorking) {
56
+ this.work(controller); // eslint-disable-line @typescript-eslint/no-floating-promises
38
57
  }
39
- }
40
58
  }
41
-
42
- this.isWorking = false;
43
- }
44
-
45
- pull(controller) {
46
- if (!this.isWorking) {
47
- this.work(controller);
59
+ cancel() {
60
+ this.isCancelled = true;
48
61
  }
49
- }
50
-
51
- cancel() {
52
- this.isCancelled = true;
53
- }
54
-
55
62
  }
56
- //# sourceMappingURL=blob-stream-controller.js.map
63
+ exports.BlobStreamController = BlobStreamController;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Forked from @gozala's web-blob under MIT license
3
+ * @see https://github.com/Gozala/web-blob
4
+ */
5
+ import { ReadableStreamPolyfill } from './readable-stream';
6
+ /**
7
+ * Blob stream is a `ReadableStream` extension optimized to have minimal
8
+ * overhead when consumed as `AsyncIterable<Uint8Array>`.
9
+ * extends {ReadableStream<Uint8Array>}
10
+ * implements {AsyncIterable<Uint8Array>}
11
+ */
12
+ export declare class BlobStream<T> extends ReadableStreamPolyfill<T> {
13
+ private readonly _chunks;
14
+ /**
15
+ * @param chunks
16
+ */
17
+ constructor(chunks: any);
18
+ /**
19
+ * @property [_options.preventCancel]
20
+ */
21
+ [Symbol.asyncIterator](_options?: {
22
+ preventCancel?: boolean;
23
+ }): AsyncIterable<Uint8Array>;
24
+ }
25
+ //# sourceMappingURL=blob-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-stream.d.ts","sourceRoot":"","sources":["../../../src/node/file/blob-stream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AAGzD;;;;;GAKG;AAEH,qBAAa,UAAU,CAAC,CAAC,CAAE,SAAQ,sBAAsB,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC;;OAEG;gBACS,MAAM,KAAA;IAOlB;;OAEG;IAEI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAC,GAAG,aAAa,CAAC,UAAU,CAAC;CAK/F"}
@@ -1,26 +1,37 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
- let _Symbol$asyncIterator;
4
-
5
- import { ReadableStreamPolyfill } from './readable-stream';
6
- import { BlobStreamController } from './blob-stream-controller';
7
- _Symbol$asyncIterator = Symbol.asyncIterator;
8
- export class BlobStream extends ReadableStreamPolyfill {
9
- constructor(chunks) {
10
- super(new BlobStreamController(chunks.values()), {
11
- type: 'bytes'
12
- });
13
-
14
- _defineProperty(this, "_chunks", void 0);
15
-
16
- this._chunks = chunks;
17
- }
18
-
19
- async *[_Symbol$asyncIterator](_options) {
20
- const reader = this.getReader();
21
- yield* this._chunks;
22
- reader.releaseLock();
23
- }
24
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BlobStream = void 0;
4
+ /**
5
+ * Forked from @gozala's web-blob under MIT license
6
+ * @see https://github.com/Gozala/web-blob
7
+ */
8
+ const readable_stream_1 = require("./readable-stream");
9
+ const blob_stream_controller_1 = require("./blob-stream-controller");
10
+ /**
11
+ * Blob stream is a `ReadableStream` extension optimized to have minimal
12
+ * overhead when consumed as `AsyncIterable<Uint8Array>`.
13
+ * extends {ReadableStream<Uint8Array>}
14
+ * implements {AsyncIterable<Uint8Array>}
15
+ */
16
+ // @ts-ignore
17
+ class BlobStream extends readable_stream_1.ReadableStreamPolyfill {
18
+ /**
19
+ * @param chunks
20
+ */
21
+ constructor(chunks) {
22
+ // @ts-ignore
23
+ super(new blob_stream_controller_1.BlobStreamController(chunks.values()), { type: 'bytes' });
24
+ /** @private */
25
+ this._chunks = chunks;
26
+ }
27
+ /**
28
+ * @property [_options.preventCancel]
29
+ */
30
+ // @ts-ignore
31
+ async *[Symbol.asyncIterator](_options) {
32
+ const reader = this.getReader();
33
+ yield* this._chunks;
34
+ reader.releaseLock();
35
+ }
25
36
  }
26
- //# sourceMappingURL=blob-stream.js.map
37
+ exports.BlobStream = BlobStream;
@@ -0,0 +1,58 @@
1
+ import { BlobStream } from './blob-stream';
2
+ /**
3
+ * Forked from @gozala's web-blob under MIT license
4
+ * @see https://github.com/Gozala/web-blob
5
+ */
6
+ export declare class BlobPolyfill {
7
+ /** The MIME type of the data contained in the Blob. If type is unknown, string is empty. */
8
+ readonly type: string;
9
+ /** The size, in bytes, of the data contained in the Blob object. */
10
+ size: number;
11
+ private parts;
12
+ /**
13
+ * @param [init]
14
+ * @param [options]
15
+ */
16
+ constructor(init?: BlobPart[], options?: BlobPropertyBag);
17
+ /**
18
+ * Returns a new Blob object containing the data in the specified range of
19
+ * bytes of the blob on which it's called.
20
+ * @param start=0 - An index into the Blob indicating the first
21
+ * byte to include in the new Blob. If you specify a negative value, it's
22
+ * treated as an offset from the end of the Blob toward the beginning. For
23
+ * example, `-10` would be the 10th from last byte in the Blob. The default
24
+ * value is `0`. If you specify a value for start that is larger than the
25
+ * size of the source Blob, the returned Blob has size 0 and contains no
26
+ * data.
27
+ * @param end - An index into the `Blob` indicating the first byte
28
+ * that will *not* be included in the new `Blob` (i.e. the byte exactly at
29
+ * this index is not included). If you specify a negative value, it's treated
30
+ * as an offset from the end of the Blob toward the beginning. For example,
31
+ * `-10` would be the 10th from last byte in the `Blob`. The default value is
32
+ * size.
33
+ * @param type - The content type to assign to the new Blob;
34
+ * this will be the value of its type property. The default value is an empty
35
+ * string.
36
+ */
37
+ slice(start?: number, end?: number, type?: string): Blob;
38
+ /**
39
+ * Returns a promise that resolves with an ArrayBuffer containing the entire
40
+ * contents of the Blob as binary data.
41
+ */
42
+ arrayBuffer(): Promise<ArrayBuffer>;
43
+ /**
44
+ * Returns a promise that resolves with a USVString containing the entire
45
+ * contents of the Blob interpreted as UTF-8 text.
46
+ */
47
+ text(): Promise<string>;
48
+ /**
49
+ */
50
+ stream(): BlobStream<any>;
51
+ /**
52
+ * @returns {string}
53
+ */
54
+ toString(): string;
55
+ get [Symbol.toStringTag](): string;
56
+ _toArrayBuffer(): ArrayBuffer;
57
+ }
58
+ //# sourceMappingURL=blob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../../src/node/file/blob.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;;GAGG;AACH,qBAAa,YAAY;IAEvB,4FAA4F;IAC5F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,KAAK,CAAe;IAC5B;;;OAGG;gBACS,IAAI,GAAE,QAAQ,EAAO,EAAE,OAAO,GAAE,eAAoB;IAmChE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,KAAK,GAAE,MAAU,EAAE,GAAG,GAAE,MAAkB,EAAE,IAAI,GAAE,MAAW,GAAG,IAAI;IAyC1E;;;OAGG;IAEG,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAIzC;;;OAGG;IAEG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAS7B;OACG;IAEH,MAAM,IAAI,UAAU,CAAC,GAAG,CAAC;IAIzB;;OAEG;IACH,QAAQ;IAIR,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAED,cAAc,IAAI,WAAW;CAU9B"}
@@ -1,140 +1,160 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
- let _Symbol$toStringTag;
4
-
5
- import { BlobStream } from './blob-stream';
6
- _Symbol$toStringTag = Symbol.toStringTag;
7
- export class BlobPolyfill {
8
- constructor(init = [], options = {}) {
9
- _defineProperty(this, "type", void 0);
10
-
11
- _defineProperty(this, "size", void 0);
12
-
13
- _defineProperty(this, "parts", void 0);
14
-
15
- this.parts = [];
16
- this.size = 0;
17
-
18
- for (const part of init) {
19
- if (typeof part === 'string') {
20
- const bytes = new TextEncoder().encode(part);
21
- this.parts.push(bytes);
22
- this.size += bytes.byteLength;
23
- } else if (part instanceof BlobPolyfill) {
24
- this.size += part.size;
25
- this.parts.push(...part.parts);
26
- } else if (part instanceof ArrayBuffer) {
27
- this.parts.push(new Uint8Array(part));
28
- this.size += part.byteLength;
29
- } else if (part instanceof Uint8Array) {
30
- this.parts.push(part);
31
- this.size += part.byteLength;
32
- } else if (ArrayBuffer.isView(part)) {
33
- const {
34
- buffer,
35
- byteOffset,
36
- byteLength
37
- } = part;
38
- this.parts.push(new Uint8Array(buffer, byteOffset, byteLength));
39
- this.size += byteLength;
40
- } else {
41
- const bytes = new TextEncoder().encode(String(part));
42
- this.parts.push(bytes);
43
- this.size += bytes.byteLength;
44
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BlobPolyfill = void 0;
4
+ // Forked from @gozala's web-blob under MIT license https://github.com/Gozala/web-blob
5
+ const blob_stream_1 = require("./blob-stream");
6
+ /**
7
+ * Forked from @gozala's web-blob under MIT license
8
+ * @see https://github.com/Gozala/web-blob
9
+ */
10
+ class BlobPolyfill {
11
+ /**
12
+ * @param [init]
13
+ * @param [options]
14
+ */
15
+ constructor(init = [], options = {}) {
16
+ this.parts = [];
17
+ this.size = 0;
18
+ for (const part of init) {
19
+ if (typeof part === 'string') {
20
+ const bytes = new TextEncoder().encode(part);
21
+ this.parts.push(bytes);
22
+ this.size += bytes.byteLength;
23
+ }
24
+ else if (part instanceof BlobPolyfill) {
25
+ this.size += part.size;
26
+ // @ts-ignore - `parts` is marked private so TS will complain about
27
+ // accessing it.
28
+ this.parts.push(...part.parts);
29
+ }
30
+ else if (part instanceof ArrayBuffer) {
31
+ this.parts.push(new Uint8Array(part));
32
+ this.size += part.byteLength;
33
+ }
34
+ else if (part instanceof Uint8Array) {
35
+ this.parts.push(part);
36
+ this.size += part.byteLength;
37
+ }
38
+ else if (ArrayBuffer.isView(part)) {
39
+ const { buffer, byteOffset, byteLength } = part;
40
+ this.parts.push(new Uint8Array(buffer, byteOffset, byteLength));
41
+ this.size += byteLength;
42
+ }
43
+ else {
44
+ const bytes = new TextEncoder().encode(String(part));
45
+ this.parts.push(bytes);
46
+ this.size += bytes.byteLength;
47
+ }
48
+ }
49
+ /** @private */
50
+ this.type = readType(options.type);
51
+ }
52
+ /**
53
+ * Returns a new Blob object containing the data in the specified range of
54
+ * bytes of the blob on which it's called.
55
+ * @param start=0 - An index into the Blob indicating the first
56
+ * byte to include in the new Blob. If you specify a negative value, it's
57
+ * treated as an offset from the end of the Blob toward the beginning. For
58
+ * example, `-10` would be the 10th from last byte in the Blob. The default
59
+ * value is `0`. If you specify a value for start that is larger than the
60
+ * size of the source Blob, the returned Blob has size 0 and contains no
61
+ * data.
62
+ * @param end - An index into the `Blob` indicating the first byte
63
+ * that will *not* be included in the new `Blob` (i.e. the byte exactly at
64
+ * this index is not included). If you specify a negative value, it's treated
65
+ * as an offset from the end of the Blob toward the beginning. For example,
66
+ * `-10` would be the 10th from last byte in the `Blob`. The default value is
67
+ * size.
68
+ * @param type - The content type to assign to the new Blob;
69
+ * this will be the value of its type property. The default value is an empty
70
+ * string.
71
+ */
72
+ slice(start = 0, end = this.size, type = '') {
73
+ const { size, parts: parts } = this;
74
+ let offset = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
75
+ let limit = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
76
+ const span = Math.max(limit - offset, 0);
77
+ const blob = new BlobPolyfill([], { type });
78
+ if (span === 0) {
79
+ // @ts-ignore
80
+ return blob;
81
+ }
82
+ let blobSize = 0;
83
+ const blobParts = [];
84
+ for (const part of parts) {
85
+ const { byteLength } = part;
86
+ if (offset > 0 && byteLength <= offset) {
87
+ offset -= byteLength;
88
+ limit -= byteLength;
89
+ }
90
+ else {
91
+ const chunk = part.subarray(offset, Math.min(byteLength, limit));
92
+ blobParts.push(chunk);
93
+ blobSize += chunk.byteLength;
94
+ // no longer need to take that into account
95
+ offset = 0;
96
+ // don't add the overflow to new blobParts
97
+ if (blobSize >= span) {
98
+ break;
99
+ }
100
+ }
101
+ }
102
+ blob.parts = blobParts;
103
+ blob.size = blobSize;
104
+ // @ts-ignore
105
+ return blob;
45
106
  }
46
-
47
- this.type = readType(options.type);
48
- }
49
-
50
- slice(start = 0, end = this.size, type = '') {
51
- const {
52
- size,
53
- parts: parts
54
- } = this;
55
- let offset = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
56
- let limit = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
57
- const span = Math.max(limit - offset, 0);
58
- const blob = new BlobPolyfill([], {
59
- type
60
- });
61
-
62
- if (span === 0) {
63
- return blob;
107
+ /**
108
+ * Returns a promise that resolves with an ArrayBuffer containing the entire
109
+ * contents of the Blob as binary data.
110
+ */
111
+ // eslint-disable-next-line require-await
112
+ async arrayBuffer() {
113
+ return this._toArrayBuffer();
64
114
  }
65
-
66
- let blobSize = 0;
67
- const blobParts = [];
68
-
69
- for (const part of parts) {
70
- const {
71
- byteLength
72
- } = part;
73
-
74
- if (offset > 0 && byteLength <= offset) {
75
- offset -= byteLength;
76
- limit -= byteLength;
77
- } else {
78
- const chunk = part.subarray(offset, Math.min(byteLength, limit));
79
- blobParts.push(chunk);
80
- blobSize += chunk.byteLength;
81
- offset = 0;
82
-
83
- if (blobSize >= span) {
84
- break;
115
+ /**
116
+ * Returns a promise that resolves with a USVString containing the entire
117
+ * contents of the Blob interpreted as UTF-8 text.
118
+ */
119
+ // eslint-disable-next-line require-await
120
+ async text() {
121
+ const decoder = new TextDecoder();
122
+ let text = '';
123
+ for (const part of this.parts) {
124
+ text += decoder.decode(part);
85
125
  }
86
- }
126
+ return text;
87
127
  }
88
-
89
- blob.parts = blobParts;
90
- blob.size = blobSize;
91
- return blob;
92
- }
93
-
94
- async arrayBuffer() {
95
- return this._toArrayBuffer();
96
- }
97
-
98
- async text() {
99
- const decoder = new TextDecoder();
100
- let text = '';
101
-
102
- for (const part of this.parts) {
103
- text += decoder.decode(part);
128
+ /**
129
+ */
130
+ // @ts-ignore
131
+ stream() {
132
+ return new blob_stream_1.BlobStream(this.parts);
104
133
  }
105
-
106
- return text;
107
- }
108
-
109
- stream() {
110
- return new BlobStream(this.parts);
111
- }
112
-
113
- toString() {
114
- return '[object Blob]';
115
- }
116
-
117
- get [_Symbol$toStringTag]() {
118
- return 'Blob';
119
- }
120
-
121
- _toArrayBuffer() {
122
- const buffer = new ArrayBuffer(this.size);
123
- const bytes = new Uint8Array(buffer);
124
- let offset = 0;
125
-
126
- for (const part of this.parts) {
127
- bytes.set(part, offset);
128
- offset += part.byteLength;
134
+ /**
135
+ * @returns {string}
136
+ */
137
+ toString() {
138
+ return '[object Blob]';
139
+ }
140
+ get [Symbol.toStringTag]() {
141
+ return 'Blob';
142
+ }
143
+ _toArrayBuffer() {
144
+ const buffer = new ArrayBuffer(this.size);
145
+ const bytes = new Uint8Array(buffer);
146
+ let offset = 0;
147
+ for (const part of this.parts) {
148
+ bytes.set(part, offset);
149
+ offset += part.byteLength;
150
+ }
151
+ return buffer;
129
152
  }
130
-
131
- return buffer;
132
- }
133
-
134
153
  }
135
-
154
+ exports.BlobPolyfill = BlobPolyfill;
155
+ /**
156
+ */
136
157
  function readType(input = '') {
137
- const type = String(input).toLowerCase();
138
- return /[^\u0020-\u007E]/.test(type) ? '' : type;
158
+ const type = String(input).toLowerCase();
159
+ return /[^\u0020-\u007E]/.test(type) ? '' : type;
139
160
  }
140
- //# sourceMappingURL=blob.js.map
@@ -0,0 +1,24 @@
1
+ export declare class FileReaderPolyfill implements FileReader {
2
+ onload: any;
3
+ onabort: any;
4
+ onerror: any;
5
+ error: any;
6
+ onloadstart: any;
7
+ onloadend: any;
8
+ onprogress: any;
9
+ readyState: any;
10
+ result: any;
11
+ DONE: any;
12
+ EMPTY: any;
13
+ LOADING: any;
14
+ addEventListener: any;
15
+ removeEventListener: any;
16
+ dispatchEvent: any;
17
+ constructor();
18
+ abort(): void;
19
+ readAsArrayBuffer(blob: Blob): Promise<void>;
20
+ readAsBinaryString(blob: any): Promise<void>;
21
+ readAsDataURL(blob: any): Promise<void>;
22
+ readAsText(blob: any): Promise<void>;
23
+ }
24
+ //# sourceMappingURL=file-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-reader.d.ts","sourceRoot":"","sources":["../../../src/node/file/file-reader.ts"],"names":[],"mappings":"AAEA,qBAAa,kBAAmB,YAAW,UAAU;IAEnD,MAAM,MAAC;IACP,OAAO,MAAC;IACR,OAAO,MAAC;IACR,KAAK,MAAC;IACN,WAAW,MAAC;IACZ,SAAS,MAAC;IACV,UAAU,MAAC;IAEX,UAAU,MAAC;IACX,MAAM,MAAC;IACP,IAAI,MAAC;IACL,KAAK,MAAC;IACN,OAAO,MAAC;IACR,gBAAgB,MAAC;IACjB,mBAAmB,MAAC;IACpB,aAAa,MAAC;;IAMd,KAAK,IAAI,IAAI;IAIP,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5C,kBAAkB,CAAC,IAAI,KAAA;IAIvB,aAAa,CAAC,IAAI,KAAA;IAQlB,UAAU,CAAC,IAAI,KAAA;CAMtB"}