@loaders.gl/polyfills 4.0.0-alpha.4 → 4.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/dist.min.js +3994 -0
  4. package/dist/index.d.ts +6 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +2 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/encoding-indexes.d.ts +31 -0
  9. package/dist/lib/encoding-indexes.d.ts.map +1 -0
  10. package/dist/lib/encoding-indexes.js +30 -0
  11. package/dist/lib/encoding-indexes.js.map +1 -0
  12. package/dist/lib/encoding.d.ts +15 -0
  13. package/dist/lib/encoding.d.ts.map +1 -0
  14. package/dist/lib/encoding.js +1450 -0
  15. package/dist/lib/encoding.js.map +1 -0
  16. package/dist/libs/encoding-indexes-asian.d.ts +10 -0
  17. package/dist/libs/encoding-indexes-asian.d.ts.map +1 -0
  18. package/dist/libs/{encoding-indexes.js → encoding-indexes-asian.js} +2 -40
  19. package/dist/node/buffer/btoa.node.d.ts +3 -0
  20. package/dist/node/buffer/btoa.node.d.ts.map +1 -0
  21. package/dist/node/buffer/to-array-buffer.node.d.ts +2 -0
  22. package/dist/node/buffer/to-array-buffer.node.d.ts.map +1 -0
  23. package/dist/node/fetch/fetch.node.d.ts +7 -0
  24. package/dist/node/fetch/fetch.node.d.ts.map +1 -0
  25. package/dist/node/fetch/headers.node.d.ts +34 -0
  26. package/dist/node/fetch/headers.node.d.ts.map +1 -0
  27. package/dist/node/fetch/response.node.d.ts +22 -0
  28. package/dist/node/fetch/response.node.d.ts.map +1 -0
  29. package/dist/node/fetch/utils/decode-data-uri.node.d.ts +16 -0
  30. package/dist/node/fetch/utils/decode-data-uri.node.d.ts.map +1 -0
  31. package/dist/node/fetch/utils/decode-data-uri.node.js +1 -3
  32. package/dist/node/fetch/utils/decode-data-uri.node.js.map +1 -1
  33. package/dist/node/fetch/utils/stream-utils.node.d.ts +10 -0
  34. package/dist/node/fetch/utils/stream-utils.node.d.ts.map +1 -0
  35. package/dist/node/fetch/utils/stream-utils.node.js +21 -12
  36. package/dist/node/fetch/utils/stream-utils.node.js.map +1 -1
  37. package/dist/node/file/blob-stream-controller.d.ts +29 -0
  38. package/dist/node/file/blob-stream-controller.d.ts.map +1 -0
  39. package/dist/node/file/blob-stream.d.ts +25 -0
  40. package/dist/node/file/blob-stream.d.ts.map +1 -0
  41. package/dist/node/file/blob.d.ts +58 -0
  42. package/dist/node/file/blob.d.ts.map +1 -0
  43. package/dist/node/file/file-reader.d.ts +24 -0
  44. package/dist/node/file/file-reader.d.ts.map +1 -0
  45. package/dist/node/file/file.d.ts +25 -0
  46. package/dist/node/file/file.d.ts.map +1 -0
  47. package/dist/node/file/install-file-polyfills.d.ts +2 -0
  48. package/dist/node/file/install-file-polyfills.d.ts.map +1 -0
  49. package/dist/node/file/readable-stream.d.ts +4 -0
  50. package/dist/node/file/readable-stream.d.ts.map +1 -0
  51. package/dist/node/images/encode-image.node.d.ts +20 -0
  52. package/dist/node/images/encode-image.node.d.ts.map +1 -0
  53. package/dist/node/images/parse-image.node.d.ts +11 -0
  54. package/dist/node/images/parse-image.node.d.ts.map +1 -0
  55. package/dist/promise/all-settled.d.ts +10 -0
  56. package/dist/promise/all-settled.d.ts.map +1 -0
  57. package/dist/utils/assert.d.ts +2 -0
  58. package/dist/utils/assert.d.ts.map +1 -0
  59. package/dist/utils/globals.d.ts +4 -0
  60. package/dist/utils/globals.d.ts.map +1 -0
  61. package/package.json +6 -6
  62. package/src/index.ts +2 -2
  63. package/src/lib/encoding-indexes.ts +34 -0
  64. package/{dist/libs/encoding.js → src/lib/encoding.ts} +78 -78
  65. package/src/libs/{encoding-indexes.js → encoding-indexes-asian.js} +2 -40
  66. package/src/node/fetch/utils/decode-data-uri.node.ts +7 -6
  67. package/src/node/fetch/utils/stream-utils.node.ts +38 -15
  68. package/src/libs/encoding.js +0 -3084
@@ -0,0 +1,3 @@
1
+ export declare function atob(string: any): string;
2
+ export declare function btoa(base64: any): string;
3
+ //# sourceMappingURL=btoa.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btoa.node.d.ts","sourceRoot":"","sources":["../../../src/node/buffer/btoa.node.ts"],"names":[],"mappings":"AAIA,wBAAgB,IAAI,CAAC,MAAM,KAAA,UAE1B;AAED,wBAAgB,IAAI,CAAC,MAAM,KAAA,UAE1B"}
@@ -0,0 +1,2 @@
1
+ export declare function bufferToArrayBuffer(buffer: any): any;
2
+ //# sourceMappingURL=to-array-buffer.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-array-buffer.node.d.ts","sourceRoot":"","sources":["../../../src/node/buffer/to-array-buffer.node.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,MAAM,KAAA,OAOzC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Emulation of Browser fetch for Node.js
3
+ * @param url
4
+ * @param options
5
+ */
6
+ export default function fetchNode(url: any, options: any): any;
7
+ //# sourceMappingURL=fetch.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.node.d.ts","sourceRoot":"","sources":["../../../src/node/fetch/fetch.node.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAA8B,SAAS,CAAC,GAAG,KAAA,EAAE,OAAO,KAAA,OAwCnD"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Polyfill for Browser Headers
3
+ * Based on https://github.com/github/fetch under MIT license
4
+ */
5
+ export default class Headers {
6
+ map: {};
7
+ constructor(headers: any);
8
+ append(name: any, value: any): void;
9
+ delete(name: any): void;
10
+ get(name: any): any;
11
+ has(name: any): boolean;
12
+ set(name: any, value: any): void;
13
+ forEach(visitor: any, thisArg?: null): void;
14
+ keys(): {
15
+ next(): {
16
+ done: boolean;
17
+ value: any;
18
+ };
19
+ };
20
+ values(): {
21
+ next(): {
22
+ done: boolean;
23
+ value: any;
24
+ };
25
+ };
26
+ entries(): {
27
+ next(): {
28
+ done: boolean;
29
+ value: any;
30
+ };
31
+ };
32
+ [Symbol.iterator](): Generator<any, void, unknown>;
33
+ }
34
+ //# sourceMappingURL=headers.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.node.d.ts","sourceRoot":"","sources":["../../../src/node/fetch/headers.node.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,GAAG,EAAE,EAAE,CAAC;gBAEI,OAAO,KAAA;IAYnB,MAAM,CAAC,IAAI,KAAA,EAAE,KAAK,KAAA;IAOlB,MAAM,CAAC,IAAI,KAAA;IAIX,GAAG,CAAC,IAAI,KAAA;IAKR,GAAG,CAAC,IAAI,KAAA;IAIR,GAAG,CAAC,IAAI,KAAA,EAAE,KAAK,KAAA;IAIf,OAAO,CAAC,OAAO,KAAA,EAAE,OAAO,OAAO;IAY/B,IAAI;;;;;;IAQJ,MAAM;;;;;;IAQN,OAAO;;;;;;IAQN,CAAC,MAAM,CAAC,QAAQ,CAAC;CAInB"}
@@ -0,0 +1,22 @@
1
+ import Headers from './headers.node';
2
+ export default class Response {
3
+ readonly ok: boolean;
4
+ readonly status: number;
5
+ readonly statusText: string;
6
+ readonly headers: Headers;
7
+ readonly url: string;
8
+ bodyUsed: boolean;
9
+ private readonly _body;
10
+ constructor(body: any, options: {
11
+ headers?: any;
12
+ status?: number;
13
+ statusText?: string;
14
+ url: string;
15
+ });
16
+ get body(): any;
17
+ arrayBuffer(): Promise<any>;
18
+ text(): Promise<string>;
19
+ json(): Promise<any>;
20
+ blob(): Promise<Blob>;
21
+ }
22
+ //# sourceMappingURL=response.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.node.d.ts","sourceRoot":"","sources":["../../../src/node/fetch/response.node.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAoBrC,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAIrB,IAAI,KAAA,EACJ,OAAO,EAAE;QACP,OAAO,CAAC,MAAC;QACT,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;KACb;IAuBH,IAAI,IAAI,QAKP;IAIK,WAAW;IAQX,IAAI;IAMJ,IAAI;IAKJ,IAAI;CAMX"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Parses a data URI into a buffer, as well as retrieving its declared MIME type.
3
+ *
4
+ * @param {string} uri - a data URI (assumed to be valid)
5
+ * @returns {Object} { buffer, mimeType }
6
+ */
7
+ export declare function decodeDataUri(uri: string): {
8
+ arrayBuffer: ArrayBuffer;
9
+ mimeType: string;
10
+ };
11
+ /**
12
+ * @param data
13
+ * @todo Duplicate of core
14
+ */
15
+ export declare function toArrayBuffer(data: unknown): ArrayBuffer;
16
+ //# sourceMappingURL=decode-data-uri.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode-data-uri.node.d.ts","sourceRoot":"","sources":["../../../../src/node/fetch/utils/decode-data-uri.node.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG;IAAC,WAAW,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAoBvF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CA+BxD"}
@@ -1,5 +1,3 @@
1
- import { assert } from '../../../utils/assert';
2
-
3
1
  const isArrayBuffer = x => x && x instanceof ArrayBuffer;
4
2
 
5
3
  const isBuffer = x => x && x instanceof Buffer;
@@ -52,6 +50,6 @@ export function toArrayBuffer(data) {
52
50
  return data._toArrayBuffer();
53
51
  }
54
52
 
55
- return assert(false, "toArrayBuffer(".concat(JSON.stringify(data, null, 2).slice(10), ")"));
53
+ throw new Error("toArrayBuffer(".concat(JSON.stringify(data, null, 2).slice(10), ")"));
56
54
  }
57
55
  //# sourceMappingURL=decode-data-uri.node.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/node/fetch/utils/decode-data-uri.node.ts"],"names":["assert","isArrayBuffer","x","ArrayBuffer","isBuffer","Buffer","decodeDataUri","uri","dataIndex","indexOf","buffer","mimeType","slice","from","trim","decodeURIComponent","startsWith","arrayBuffer","toArrayBuffer","data","typedArray","Uint8Array","isView","text","uint8Array","TextEncoder","encode","_toArrayBuffer","JSON","stringify"],"mappings":"AAEA,SAAQA,MAAR,QAAqB,uBAArB;;AAEA,MAAMC,aAAa,GAAIC,CAAD,IAAOA,CAAC,IAAIA,CAAC,YAAYC,WAA/C;;AACA,MAAMC,QAAQ,GAAIF,CAAD,IAAOA,CAAC,IAAIA,CAAC,YAAYG,MAA1C;;AAQA,OAAO,SAASC,aAAT,CAAuBC,GAAvB,EAA4B;AACjC,QAAMC,SAAS,GAAGD,GAAG,CAACE,OAAJ,CAAY,GAAZ,CAAlB;AAEA,MAAIC,MAAJ;AACA,MAAIC,QAAJ;;AACA,MAAIJ,GAAG,CAACK,KAAJ,CAAUJ,SAAS,GAAG,CAAtB,EAAyBA,SAAzB,MAAwC,SAA5C,EAAuD;AACrDE,IAAAA,MAAM,GAAGL,MAAM,CAACQ,IAAP,CAAYN,GAAG,CAACK,KAAJ,CAAUJ,SAAS,GAAG,CAAtB,CAAZ,EAAsC,QAAtC,CA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,OAAOA,IAAP,KAAgB,QAAxB,IAAoCA,IAAI,CAACQ,cAA7C,EAA6D;AAC3D,WAAOR,IAAI,CAACQ,cAAL,EAAP;AACD;;AAED,SAAO3B,MAAM,CAAC,KAAD,0BAAyB4B,IAAI,CAACC,SAAL,CAAeV,IAAf,EAAqB,IAArB,EAA2B,CAA3B,EAA8BP,KAA9B,CAAoC,EAApC,CAAzB,OAAb;AACD","sourcesContent":["// Based on binary-gltf-utils under MIT license: Copyright (c) 2016-17 Karl Cheng\n\nimport {assert} from '../../../utils/assert';\n\nconst isArrayBuffer = (x) => x && x instanceof ArrayBuffer;\nconst isBuffer = (x) => x && x instanceof Buffer;\n\n/**\n * Parses a data URI into a buffer, as well as retrieving its declared MIME type.\n *\n * @param {string} uri - a data URI (assumed to be valid)\n * @returns {Object} { buffer, mimeType }\n */\nexport function decodeDataUri(uri) {\n const dataIndex = uri.indexOf(',');\n\n let buffer;\n let mimeType;\n if (uri.slice(dataIndex - 7, dataIndex) === ';base64') {\n buffer = Buffer.from(uri.slice(dataIndex + 1), 'base64');\n mimeType = uri.slice(5, dataIndex - 7).trim();\n } else {\n buffer = Buffer.from(decodeURIComponent(uri.slice(dataIndex + 1)));\n mimeType = uri.slice(5, dataIndex).trim();\n }\n\n if (!mimeType) {\n mimeType = 'text/plain;charset=US-ASCII';\n } else if (mimeType.startsWith(';')) {\n mimeType = `text/plain${mimeType}`;\n }\n\n return {arrayBuffer: toArrayBuffer(buffer), mimeType};\n}\n\n/**\n * @param data\n * @todo Duplicate of core\n */\nexport function toArrayBuffer(data) {\n if (isArrayBuffer(data)) {\n return data;\n }\n\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n if (isBuffer(data)) {\n const typedArray = new Uint8Array(data);\n return typedArray.buffer;\n }\n\n // Careful - Node Buffers will look like ArrayBuffers (keep after isBuffer)\n if (ArrayBuffer.isView(data)) {\n return data.buffer;\n }\n\n if (typeof data === 'string') {\n const text = data;\n const uint8Array = new TextEncoder().encode(text);\n return uint8Array.buffer;\n }\n\n // HACK to support Blob polyfill\n if (data && typeof data === 'object' && data._toArrayBuffer) {\n return data._toArrayBuffer();\n }\n\n return assert(false, `toArrayBuffer(${JSON.stringify(data, null, 2).slice(10)})`);\n}\n"],"file":"decode-data-uri.node.js"}
1
+ {"version":3,"sources":["../../../../src/node/fetch/utils/decode-data-uri.node.ts"],"names":["isArrayBuffer","x","ArrayBuffer","isBuffer","Buffer","decodeDataUri","uri","dataIndex","indexOf","buffer","mimeType","slice","from","trim","decodeURIComponent","startsWith","arrayBuffer","toArrayBuffer","data","typedArray","Uint8Array","isView","text","uint8Array","TextEncoder","encode","_toArrayBuffer","Error","JSON","stringify"],"mappings":"AAEA,MAAMA,aAAa,GAAIC,CAAD,IAAOA,CAAC,IAAIA,CAAC,YAAYC,WAA/C;;AACA,MAAMC,QAAQ,GAAIF,CAAD,IAAOA,CAAC,IAAIA,CAAC,YAAYG,MAA1C;;AAQA,OAAO,SAASC,aAAT,CAAuBC,GAAvB,EAAkF;AACvF,QAAMC,SAAS,GAAGD,GAAG,CAACE,OAAJ,CAAY,GAAZ,CAAlB;AAEA,MAAIC,MAAJ;AACA,MAAIC,QAAJ;;AACA,MAAIJ,GAAG,CAACK,KAAJ,CAAUJ,SAAS,GAAG,CAAtB,EAAyBA,SAAzB,MAAwC,SAA5C,EAAuD;AACrDE,IAAAA,MAAM,GAAGL,MAAM,CAACQ,IAAP,CAAYN,GAAG,CAACK,KAAJ,CAAUJ,SAAS,GAAG,CAAtB,CAAZ,EAAsC,QAAtC,CAAT;AACAG,IAAAA,QAAQ,GAAGJ,GAAG,CAACK,KAAJ,CAAU,CAAV,EAAaJ,SAAS,GAAG,CAAzB,EAA4BM,IAA5B,EAAX;AACD,GAHD,MAGO;AACLJ,IAAAA,MAAM,GAAGL,MAAM,CAACQ,IAAP,CAAYE,kBAAkB,CAACR,GAAG,CAACK,KAAJ,CAAUJ,SAAS,GAAG,CAAtB,CAAD,CAA9B,CAAT;AACAG,IAAA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under MIT license: Copyright (c) 2016-17 Karl Cheng\n\nconst isArrayBuffer = (x) => x && x instanceof ArrayBuffer;\nconst isBuffer = (x) => x && x instanceof Buffer;\n\n/**\n * Parses a data URI into a buffer, as well as retrieving its declared MIME type.\n *\n * @param {string} uri - a data URI (assumed to be valid)\n * @returns {Object} { buffer, mimeType }\n */\nexport function decodeDataUri(uri: string): {arrayBuffer: ArrayBuffer; mimeType: string} {\n const dataIndex = uri.indexOf(',');\n\n let buffer;\n let mimeType;\n if (uri.slice(dataIndex - 7, dataIndex) === ';base64') {\n buffer = Buffer.from(uri.slice(dataIndex + 1), 'base64');\n mimeType = uri.slice(5, dataIndex - 7).trim();\n } else {\n buffer = Buffer.from(decodeURIComponent(uri.slice(dataIndex + 1)));\n mimeType = uri.slice(5, dataIndex).trim();\n }\n\n if (!mimeType) {\n mimeType = 'text/plain;charset=US-ASCII';\n } else if (mimeType.startsWith(';')) {\n mimeType = `text/plain${mimeType}`;\n }\n\n return {arrayBuffer: toArrayBuffer(buffer), mimeType};\n}\n\n/**\n * @param data\n * @todo Duplicate of core\n */\nexport function toArrayBuffer(data: unknown): ArrayBuffer {\n if (isArrayBuffer(data)) {\n return data as ArrayBuffer;\n }\n\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n if (isBuffer(data)) {\n // @ts-expect-error\n const typedArray = new Uint8Array(data);\n return typedArray.buffer;\n }\n\n // Careful - Node Buffers will look like ArrayBuffers (keep after isBuffer)\n if (ArrayBuffer.isView(data)) {\n return data.buffer;\n }\n\n if (typeof data === 'string') {\n const text = data;\n const uint8Array = new TextEncoder().encode(text);\n return uint8Array.buffer;\n }\n\n // HACK to support Blob polyfill\n // @ts-expect-error\n if (data && typeof data === 'object' && data._toArrayBuffer) {\n // @ts-expect-error\n return data._toArrayBuffer();\n }\n\n throw new Error(`toArrayBuffer(${JSON.stringify(data, null, 2).slice(10)})`);\n}\n"],"file":"decode-data-uri.node.js"}
@@ -0,0 +1,10 @@
1
+ export declare function createReadStream(url: any, options: any): Promise<any>;
2
+ export declare function decompressReadStream(readStream: any, headers: any): any;
3
+ export declare function concatenateReadStream(readStream: any): Promise<ArrayBuffer>;
4
+ /**
5
+ * Concatenate a sequence of ArrayBuffers
6
+ * @return A concatenated ArrayBuffer
7
+ * @note duplicates loader-utils since polyfills should be independent
8
+ */
9
+ export declare function concatenateArrayBuffers(sources: (ArrayBuffer | Uint8Array)[]): ArrayBuffer;
10
+ //# sourceMappingURL=stream-utils.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-utils.node.d.ts","sourceRoot":"","sources":["../../../../src/node/fetch/utils/stream-utils.node.ts"],"names":[],"mappings":"AAYA,wBAAsB,gBAAgB,CAAC,GAAG,KAAA,EAAE,OAAO,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC,CAsBjE;AAED,wBAAgB,oBAAoB,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA,OAYvD;AAED,wBAAsB,qBAAqB,CAAC,UAAU,KAAA,GAAG,OAAO,CAAC,WAAW,CAAC,CAsB5E;AA4BD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,GAAG,WAAW,CAqB1F"}
@@ -4,7 +4,9 @@ import https from 'https';
4
4
  import zlib from 'zlib';
5
5
  import { toArrayBuffer } from './decode-data-uri.node';
6
6
 
7
- const isRequestURL = url => url.startsWith('http:') || url.startsWith('https:');
7
+ function isRequestURL(url) {
8
+ return url.startsWith('http:') || url.startsWith('https:');
9
+ }
8
10
 
9
11
  export async function createReadStream(url, options) {
10
12
  if (!isRequestURL(url)) {
@@ -42,7 +44,7 @@ export function decompressReadStream(readStream, headers) {
42
44
  }
43
45
  }
44
46
  export async function concatenateReadStream(readStream) {
45
- let arrayBuffer = new ArrayBuffer(0);
47
+ const arrayBufferChunks = [];
46
48
  return await new Promise((resolve, reject) => {
47
49
  readStream.on('error', error => reject(error));
48
50
  readStream.on('readable', () => readStream.read());
@@ -51,10 +53,12 @@ export async function concatenateReadStream(readStream) {
51
53
  reject(new Error('Read stream not binary'));
52
54
  }
53
55
 
54
- const chunkAsArrayBuffer = toArrayBuffer(chunk);
55
- arrayBuffer = concatenateArrayBuffers(arrayBuffer, chunkAsArrayBuffer);
56
+ arrayBufferChunks.push(toArrayBuffer(chunk));
57
+ });
58
+ readStream.on('end', () => {
59
+ const arrayBuffer = concatenateArrayBuffers(arrayBufferChunks);
60
+ resolve(arrayBuffer);
56
61
  });
57
- readStream.on('end', () => resolve(arrayBuffer));
58
62
  });
59
63
  }
60
64
 
@@ -78,12 +82,17 @@ function getRequestOptions(url, options) {
78
82
  };
79
83
  }
80
84
 
81
- function concatenateArrayBuffers(source1, source2) {
82
- const sourceArray1 = source1 instanceof ArrayBuffer ? new Uint8Array(source1) : source1;
83
- const sourceArray2 = source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2;
84
- const temp = new Uint8Array(sourceArray1.byteLength + sourceArray2.byteLength);
85
- temp.set(sourceArray1, 0);
86
- temp.set(sourceArray2, sourceArray1.byteLength);
87
- return temp.buffer;
85
+ export function concatenateArrayBuffers(sources) {
86
+ const sourceArrays = sources.map(source2 => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2);
87
+ const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);
88
+ const result = new Uint8Array(byteLength);
89
+ let offset = 0;
90
+
91
+ for (const sourceArray of sourceArrays) {
92
+ result.set(sourceArray, offset);
93
+ offset += sourceArray.byteLength;
94
+ }
95
+
96
+ return result.buffer;
88
97
  }
89
98
  //# sourceMappingURL=stream-utils.node.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/node/fetch/utils/stream-utils.node.ts"],"names":["fs","http","https","zlib","toArrayBuffer","isRequestURL","url","startsWith","createReadStream","options","noqueryUrl","split","Promise","resolve","reject","stream","encoding","once","on","error","requestFunction","request","requestOptions","getRequestOptions","req","res","end","decompressReadStream","readStream","headers","get","pipe","createBrotliDecompress","createGunzip","createDeflate","concatenateReadStream","arrayBuffer","ArrayBuffer","read","chunk","Error","chunkAsArrayBuffer","concatenateArrayBuffers","originalHeaders","key","Object","keys","toLowerCase","urlObject","URL","hostname","path","pathname","method","fetch","source1","source2","sourceArray1","Uint8Array","sourceArray2","temp","byteLength","set","buffer"],"mappings":"AAAA,OAAOA,EAAP,MAAe,IAAf;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AAEA,SAAQC,aAAR,QAA4B,wBAA5B;;AAEA,MAAMC,YAAY,GAAIC,GAAD,IAASA,GAAG,CAACC,UAAJ,CAAe,OAAf,KAA2BD,GAAG,CAACC,UAAJ,CAAe,QAAf,CAAzD;;AAGA,OAAO,eAAeC,gBAAf,CAAgCF,GAAhC,EAAqCG,OAArC,EAA8C;AAEnD,MAAI,CAACJ,YAAY,CAACC,GAAD,CAAjB,EAAwB;AACtB,UAAMI,UAAU,GAAGJ,GAAG,CAACK,KAAJ,CAAU,GAAV,EAAe,CAAf,CAAnB;AAEA,WAAO,MAAM,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAE5C,YAAMC,MAAM,GAAGf,EAAE,CAACQ,gBAAH,CAAoBE,UAApB,EAAgC;AAACM,QAAAA,QAAQ,EAAE;AAAX,OAAhC,CAAf;AACAD,MAAAA,MAAM,CAACE,IAAP,CAAY,UAAZ,EAAwB,MAAMJ,OAAO,CAACE,MAAD,CAArC;AACAA,MAAAA,MAAM,CAACG,EAAP,CAAU,OAAV,EAAoBC,KAAD,IAAWL,MAAM,CAACK,KAAD,CAApC;AACD,KALY,CAAb;AAMD;;AAID,SAAO,MAAM,IAAIP,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAC5C,UAAMM,eAAe,GAAGd,GAAG,CAACC,UAAJ,CAAe,QAAf,IAA2BL,KAAK,CAACmB,OAAjC,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,UAAJ,CAAeH,OAAf,CAAjC,GAA2DA,OAAhF;AACA,QAAMI,YAAY,GAAGH,OAAO,YAAYnB,WAAnB,GAAiC,IAAIqB,UAAJ,CAAeF,OAAf,CAAjC,GAA2DA,OAAhF;AACA,QAAMI,IAAI,GAAG,IAAIF,UAAJ,CAAeD,YAAY,CAACI,UAAb,GAA0BF,YAAY,CAACE,UAAtD,CAAb;AACAD,EAAAA,IAAI,CAACE,GAAL,CAASL,YAAT,EAAuB,CAAvB;AACAG,EAAAA,IAAI,CAACE,GAAL,CAASH,YAAT,EAAuBF,YAAY,CAACI,UAApC;AACA,SAAOD,IAAI,CAACG,MAAZ;AACD","sourcesContent":["import fs from 'fs'; // `fs` will be empty object in browsers (see package.json \"browser\" field).\nimport http from 'http';\nimport https from 'https';\nimport zlib from 'zlib';\n\nimport {toArrayBuffer} from './decode-data-uri.node';\n\nconst isRequestURL = (url) => url.startsWith('http:') || url.startsWith('https:');\n\n// Returns a promise that resolves to a readable stream\nexport async function createReadStream(url, options) {\n // Handle file streams in node\n if (!isRequestURL(url)) {\n const noqueryUrl = url.split('?')[0];\n // Now open the stream\n return await new Promise((resolve, reject) => {\n // @ts-ignore\n const stream = fs.createReadStream(noqueryUrl, {encoding: null});\n stream.once('readable', () => resolve(stream));\n stream.on('error', (error) => reject(error));\n });\n }\n\n // HANDLE HTTP/HTTPS REQUESTS IN NODE\n // TODO: THIS IS BAD SINCE WE RETURN A PROMISE INSTEAD OF A STREAM\n return await new Promise((resolve, reject) => {\n const requestFunction = url.startsWith('https:') ? https.request : http.request;\n const requestOptions = getRequestOptions(url, options);\n const req = requestFunction(requestOptions, (res) => resolve(res));\n req.on('error', (error) => reject(error));\n req.end();\n });\n}\n\nexport function decompressReadStream(readStream, headers) {\n switch (headers.get('content-encoding')) {\n case 'br':\n return readStream.pipe(zlib.createBrotliDecompress());\n case 'gzip':\n return readStream.pipe(zlib.createGunzip());\n case 'deflate':\n return readStream.pipe(zlib.createDeflate());\n default:\n // No compression or an unknown one, just return it as is\n return readStream;\n }\n}\n\nexport async function concatenateReadStream(readStream) {\n let arrayBuffer = new ArrayBuffer(0);\n\n return await new Promise((resolve, reject) => {\n readStream.on('error', (error) => reject(error));\n\n // Once the readable callback has been added, stream switches to \"flowing mode\"\n // In Node 10 (but not 12 and 14) this causes `data` and `end` to never be called unless we read data here\n readStream.on('readable', () => readStream.read());\n\n readStream.on('data', (chunk) => {\n if (typeof chunk === 'string') {\n reject(new Error('Read stream not binary'));\n }\n const chunkAsArrayBuffer = toArrayBuffer(chunk);\n arrayBuffer = concatenateArrayBuffers(arrayBuffer, chunkAsArrayBuffer);\n });\n\n readStream.on('end', () => resolve(arrayBuffer));\n });\n}\n\n// HELPERS\n\nfunction getRequestOptions(url, options?: {fetch?: typeof fetch; headers?}) {\n // Ensure header keys are lower case so that we can merge without duplicates\n const originalHeaders = options?.headers || {};\n const headers = {};\n for (const key of Object.keys(originalHeaders)) {\n headers[key.toLowerCase()] = originalHeaders[key];\n }\n\n // Add default accept-encoding to headers\n headers['accept-encoding'] = headers['accept-encoding'] || 'gzip,br,deflate';\n\n const urlObject = new URL(url);\n return {\n hostname: urlObject.hostname,\n path: urlObject.pathname,\n method: 'GET',\n // Add options and user provided 'options.fetch' overrides if available\n ...options,\n ...options?.fetch,\n // Override with updated headers with accepted encodings:\n headers\n };\n}\n\nfunction concatenateArrayBuffers(source1, source2) {\n const sourceArray1 = source1 instanceof ArrayBuffer ? new Uint8Array(source1) : source1;\n const sourceArray2 = source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2;\n const temp = new Uint8Array(sourceArray1.byteLength + sourceArray2.byteLength);\n temp.set(sourceArray1, 0);\n temp.set(sourceArray2, sourceArray1.byteLength);\n return temp.buffer;\n}\n"],"file":"stream-utils.node.js"}
1
+ {"version":3,"sources":["../../../../src/node/fetch/utils/stream-utils.node.ts"],"names":["fs","http","https","zlib","toArrayBuffer","isRequestURL","url","startsWith","createReadStream","options","noqueryUrl","split","Promise","resolve","reject","stream","encoding","once","on","error","requestFunction","request","requestOptions","getRequestOptions","req","res","end","decompressReadStream","readStream","headers","get","pipe","createBrotliDecompress","createGunzip","createDeflate","concatenateReadStream","arrayBufferChunks","read","chunk","Error","push","arrayBuffer","concatenateArrayBuffers","originalHeaders","key","Object","keys","toLowerCase","urlObject","URL","hostname","path","pathname","method","fetch","sources","sourceArrays","map","source2","ArrayBuffer","Uint8Array","byteLength","reduce","length","typedArray","result","offset","sourceArray","set","buffer"],"mappings":"AAAA,OAAOA,EAAP,MAAe,IAAf;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AAEA,SAAQC,aAAR,QAA4B,wBAA5B;;AAEA,SAASC,YAAT,CAAsBC,GAAtB,EAA4C;AAC1C,SAAOA,GAAG,CAACC,UAAJ,CAAe,OAAf,KAA2BD,GAAG,CAACC,UAAJ,CAAe,QAAf,CAAlC;AACD;;AAGD,OAAO,eAAeC,gBAAf,CAAgCF,GAAhC,EAAqCG,OAArC,EAA4D;AAEjE,MAAI,CAACJ,YAAY,CAACC,GAAD,CAAjB,EAAwB;AACtB,UAAMI,UAAU,GAAGJ,GAAG,CAACK,KAAJ,CAAU,GAAV,EAAe,CAAf,CAAnB;AAEA,WAAO,MAAM,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAE5C,YAAMC,MAAM,GAAGf,EAAE,CAACQ,gBAAH,CAAoBE,UAApB,EAAgC;AAACM,QAAAA,QAAQ,EAAE;AAAX,OAAhC,CAAf;AACAD,MAAAA,MAAM,CAACE,IAAP,CAAY,UAAZ,EAAwB,MAAMJ,OAAO,CAACE,MAAD,CAArC;AACAA,MAAAA,MAAM,CAACG,EAAP,CAAU,OAAV,EAAoBC,KAAD,IAAWL,MAAM,CAACK,KAAD,CAApC;AACD,KALY,CAAb;AAMD;;AAID,SAAO,MAAM,IAAIP,OAAJ,CAAY,CAACC,OAA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,OAAO,SAASa,uBAAT,CAAiCa,OAAjC,EAAqF;AAE1F,QAAMC,YAAY,GAAGD,OAAO,CAACE,GAAR,CAAaC,OAAD,IAC/BA,OAAO,YAAYC,WAAnB,GAAiC,IAAIC,UAAJ,CAAeF,OAAf,CAAjC,GAA2DA,OADxC,CAArB;AAKA,QAAMG,UAAU,GAAGL,YAAY,CAACM,MAAb,CAAoB,CAACC,MAAD,EAASC,UAAT,KAAwBD,MAAM,GAAGC,UAAU,CAACH,UAAhE,EAA4E,CAA5E,CAAnB;AAGA,QAAMI,MAAM,GAAG,IAAIL,UAAJ,CAAeC,UAAf,CAAf;AAGA,MAAIK,MAAM,GAAG,CAAb;;AACA,OAAK,MAAMC,WAAX,IAA0BX,YAA1B,EAAwC;AACtCS,IAAAA,MAAM,CAACG,GAAP,CAAWD,WAAX,EAAwBD,MAAxB;AACAA,IAAAA,MAAM,IAAIC,WAAW,CAACN,UAAtB;AACD;;AAGD,SAAOI,MAAM,CAACI,MAAd;AACD","sourcesContent":["import fs from 'fs'; // `fs` will be empty object in browsers (see package.json \"browser\" field).\nimport http from 'http';\nimport https from 'https';\nimport zlib from 'zlib';\n\nimport {toArrayBuffer} from './decode-data-uri.node';\n\nfunction isRequestURL(url: string): boolean {\n return url.startsWith('http:') || url.startsWith('https:');\n}\n\n// Returns a promise that resolves to a readable stream\nexport async function createReadStream(url, options): Promise<any> {\n // Handle file streams in node\n if (!isRequestURL(url)) {\n const noqueryUrl = url.split('?')[0];\n // Now open the stream\n return await new Promise((resolve, reject) => {\n // @ts-ignore\n const stream = fs.createReadStream(noqueryUrl, {encoding: null});\n stream.once('readable', () => resolve(stream));\n stream.on('error', (error) => reject(error));\n });\n }\n\n // HANDLE HTTP/HTTPS REQUESTS IN NODE\n // TODO: THIS IS BAD SINCE WE RETURN A PROMISE INSTEAD OF A STREAM\n return await new Promise((resolve, reject) => {\n const requestFunction = url.startsWith('https:') ? https.request : http.request;\n const requestOptions = getRequestOptions(url, options);\n const req = requestFunction(requestOptions, (res) => resolve(res));\n req.on('error', (error) => reject(error));\n req.end();\n });\n}\n\nexport function decompressReadStream(readStream, headers) {\n switch (headers.get('content-encoding')) {\n case 'br':\n return readStream.pipe(zlib.createBrotliDecompress());\n case 'gzip':\n return readStream.pipe(zlib.createGunzip());\n case 'deflate':\n return readStream.pipe(zlib.createDeflate());\n default:\n // No compression or an unknown one, just return it as is\n return readStream;\n }\n}\n\nexport async function concatenateReadStream(readStream): Promise<ArrayBuffer> {\n const arrayBufferChunks: ArrayBuffer[] = [];\n\n return await new Promise((resolve, reject) => {\n readStream.on('error', (error) => reject(error));\n\n // Once the readable callback has been added, stream switches to \"flowing mode\"\n // In Node 10 (but not 12 and 14) this causes `data` and `end` to never be called unless we read data here\n readStream.on('readable', () => readStream.read());\n\n readStream.on('data', (chunk) => {\n if (typeof chunk === 'string') {\n reject(new Error('Read stream not binary'));\n }\n arrayBufferChunks.push(toArrayBuffer(chunk));\n });\n\n readStream.on('end', () => {\n const arrayBuffer = concatenateArrayBuffers(arrayBufferChunks);\n resolve(arrayBuffer);\n });\n });\n}\n\n// HELPERS\n\nfunction getRequestOptions(url: string, options?: {fetch?: typeof fetch; headers?}) {\n // Ensure header keys are lower case so that we can merge without duplicates\n const originalHeaders = options?.headers || {};\n const headers = {};\n for (const key of Object.keys(originalHeaders)) {\n headers[key.toLowerCase()] = originalHeaders[key];\n }\n\n // Add default accept-encoding to headers\n headers['accept-encoding'] = headers['accept-encoding'] || 'gzip,br,deflate';\n\n const urlObject = new URL(url);\n return {\n hostname: urlObject.hostname,\n path: urlObject.pathname,\n method: 'GET',\n // Add options and user provided 'options.fetch' overrides if available\n ...options,\n ...options?.fetch,\n // Override with updated headers with accepted encodings:\n headers\n };\n}\n\n/**\n * Concatenate a sequence of ArrayBuffers\n * @return A concatenated ArrayBuffer\n * @note duplicates loader-utils since polyfills should be independent\n */\nexport function concatenateArrayBuffers(sources: (ArrayBuffer | Uint8Array)[]): ArrayBuffer {\n // Make sure all inputs are wrapped in typed arrays\n const sourceArrays = sources.map((source2) =>\n source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2\n );\n\n // Get length of all inputs\n const byteLength = sourceArrays.reduce((length, typedArray) => length + typedArray.byteLength, 0);\n\n // Allocate array with space for all inputs\n const result = new Uint8Array(byteLength);\n\n // Copy the subarrays\n let offset = 0;\n for (const sourceArray of sourceArrays) {\n result.set(sourceArray, offset);\n offset += sourceArray.byteLength;\n }\n\n // We work with ArrayBuffers, discard the typed array wrapper\n return result.buffer;\n}\n"],"file":"stream-utils.node.js"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Forked from @gozala's web-blob under MIT license
3
+ * @see https://github.com/Gozala/web-blob
4
+ */
5
+ export declare class BlobStreamController {
6
+ private chunks;
7
+ private isWorking;
8
+ private isCancelled;
9
+ /**
10
+ * @param chunks
11
+ */
12
+ constructor(chunks: Iterator<Uint8Array>);
13
+ /**
14
+ * @param controller
15
+ */
16
+ start(controller: ReadableStreamDefaultController): void;
17
+ /**
18
+ *
19
+ * @param controller
20
+ */
21
+ work(controller: ReadableStreamDefaultController): Promise<void>;
22
+ /**
23
+ *
24
+ * @param {ReadableStreamDefaultController} controller
25
+ */
26
+ pull(controller: any): void;
27
+ cancel(): void;
28
+ }
29
+ //# sourceMappingURL=blob-stream-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-stream-controller.d.ts","sourceRoot":"","sources":["../../../src/node/file/blob-stream-controller.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,WAAW,CAAkB;IAErC;;OAEG;gBACS,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;IAIxC;;OAEG;IACH,KAAK,CAAC,UAAU,EAAE,+BAA+B;IAIjD;;;OAGG;IACG,IAAI,CAAC,UAAU,EAAE,+BAA+B;IAyBtD;;;OAGG;IACH,IAAI,CAAC,UAAU,KAAA;IAKf,MAAM;CAGP"}
@@ -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"}
@@ -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"}
@@ -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"}
@@ -0,0 +1,25 @@
1
+ import { BlobPolyfill } from './blob';
2
+ /**
3
+ * Forked from @gozala's web-file under MIT license
4
+ * @see https://github.com/Gozala/web-file
5
+ */
6
+ export declare class FilePolyfill extends BlobPolyfill {
7
+ /** The name of the file referenced by the File object. */
8
+ name: string;
9
+ /** The path the URL of the File is relative to. */
10
+ webkitRelativePath: string;
11
+ /**
12
+ * Returns the last modified time of the file, in millisecond since the UNIX
13
+ * epoch (January 1st, 1970 at Midnight).
14
+ */
15
+ lastModified: number;
16
+ /**
17
+ * @param init
18
+ * @param name - A USVString representing the file name or the path
19
+ * to the file.
20
+ * @param [options]
21
+ */
22
+ constructor(init: BlobPart[], name: string, options?: FilePropertyBag);
23
+ get [Symbol.toStringTag](): string;
24
+ }
25
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/node/file/file.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAEpC;;;GAGG;AAEH,qBAAa,YAAa,SAAQ,YAAY;IAG5C,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAM;IAClB,mDAAmD;IACnD,kBAAkB,EAAE,MAAM,CAAM;IAEhC;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;gBACS,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;IAUzE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare function installFilePolyfills(): void;
2
+ //# sourceMappingURL=install-file-polyfills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-file-polyfills.d.ts","sourceRoot":"","sources":["../../../src/node/file/install-file-polyfills.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,SAqBnC"}
@@ -0,0 +1,4 @@
1
+ import { ReadableStream as WSPReadableStream } from 'web-streams-polyfill';
2
+ export declare class ReadableStreamPolyfill<T> extends WSPReadableStream<T> implements ReadableStream {
3
+ }
4
+ //# sourceMappingURL=readable-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readable-stream.d.ts","sourceRoot":"","sources":["../../../src/node/file/readable-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,IAAI,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAOzE,qBAAa,sBAAsB,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAE,YAAW,cAAc;CAAG"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Returns data bytes representing a compressed image in PNG or JPG format,
3
+ * This data can be saved using file system (f) methods or
4
+ * used in a request.
5
+ * @param image to save
6
+ * @param options
7
+ * @param options.type='png' - png, jpg or image/png, image/jpg are valid
8
+ * @param options.dataURI - Whether to include a data URI header
9
+ * @return {*} bytes
10
+ */
11
+ export declare function encodeImageToStreamNode(image: {
12
+ data: any;
13
+ width: number;
14
+ height: number;
15
+ }, options: {
16
+ type?: string;
17
+ dataURI?: string;
18
+ }): any;
19
+ export declare function encodeImageNode(image: any, options: any): Promise<unknown>;
20
+ //# sourceMappingURL=encode-image.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode-image.node.d.ts","sourceRoot":"","sources":["../../../src/node/images/encode-image.node.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,EACjD,OAAO,EAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,OAQ3C;AAED,wBAAgB,eAAe,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA,oBAY7C"}
@@ -0,0 +1,11 @@
1
+ declare type NDArray = {
2
+ shape: number[];
3
+ data: Uint8Array;
4
+ width: number;
5
+ height: number;
6
+ components: number;
7
+ layers: number[];
8
+ };
9
+ export declare function parseImageNode(arrayBuffer: ArrayBuffer, mimeType: string): Promise<NDArray>;
10
+ export {};
11
+ //# sourceMappingURL=parse-image.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-image.node.d.ts","sourceRoot":"","sources":["../../../src/node/images/parse-image.node.ts"],"names":[],"mappings":"AAKA,aAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,wBAAsB,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuBjG"}
@@ -0,0 +1,10 @@
1
+ export declare const REJECTED_STATUS = "rejected";
2
+ export declare const FULFILLED_STATUS = "fulfilled";
3
+ /**
4
+ * Handle list of promises and return all values regardless of results.
5
+ * Polyfill for Promise.allSettled() method.
6
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled
7
+ * @param promises
8
+ */
9
+ export declare function allSettled(promises: Promise<any>[]): Promise<any>;
10
+ //# sourceMappingURL=all-settled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"all-settled.d.ts","sourceRoot":"","sources":["../../src/promise/all-settled.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAWjE"}
@@ -0,0 +1,2 @@
1
+ export declare function assert(condition: any, message?: string): void;
2
+ //# sourceMappingURL=assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/utils/assert.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAI7D"}
@@ -0,0 +1,4 @@
1
+ declare const isBrowser: boolean;
2
+ declare const global_: object;
3
+ export { isBrowser, global_ as global };
4
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../src/utils/globals.ts"],"names":[],"mappings":"AAwBA,QAAA,MAAM,SAAS,EAAE,OAEyE,CAAC;AAQ3F,QAAA,MAAM,OAAO,EAAE,MAAqE,CAAC;AAErF,OAAO,EAAC,SAAS,EAAE,OAAO,IAAI,MAAM,EAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/polyfills",
3
- "version": "4.0.0-alpha.4",
3
+ "version": "4.0.0-alpha.5",
4
4
  "description": "Polyfills for TextEncoder/TextDecoder",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -17,7 +17,7 @@
17
17
  "TextEncoder",
18
18
  "TextDecoder"
19
19
  ],
20
- "types": "src/index.ts",
20
+ "types": "dist/index.d.ts",
21
21
  "main": "dist/index.js",
22
22
  "module": "dist/index.js",
23
23
  "files": [
@@ -93,17 +93,17 @@
93
93
  },
94
94
  "scripts": {
95
95
  "pre-build": "npm run build-bundle",
96
- "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js"
96
+ "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
97
97
  },
98
98
  "dependencies": {
99
99
  "@babel/runtime": "^7.3.1",
100
+ "@xmldom/xmldom": "^0.7.5",
100
101
  "get-pixels": "^3.3.2",
101
102
  "ndarray": "^1.0.18",
102
103
  "save-pixels": "^2.3.2",
103
104
  "stream-to-async-iterator": "^0.2.0",
104
105
  "through": "^2.3.8",
105
- "web-streams-polyfill": "^3.0.0",
106
- "xmldom": "^0.5.0"
106
+ "web-streams-polyfill": "^3.0.0"
107
107
  },
108
- "gitHead": "53026061b3c8871f7e96d3a5826125cc6613bddc"
108
+ "gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
109
109
  }
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable dot-notation */
2
- import {DOMParser} from 'xmldom';
2
+ import {DOMParser} from '@xmldom/xmldom';
3
3
  import {isBrowser, global} from './utils/globals';
4
4
 
5
- import {TextDecoder, TextEncoder} from './libs/encoding';
5
+ import {TextDecoder, TextEncoder} from './lib/encoding';
6
6
  import {allSettled} from './promise/all-settled';
7
7
 
8
8
  // Node specific