@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,84 +1,35 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { atob } from '../buffer/btoa.node';
3
- export class FileReaderPolyfill {
4
- constructor() {
5
- _defineProperty(this, "onload", void 0);
6
-
7
- _defineProperty(this, "onabort", void 0);
8
-
9
- _defineProperty(this, "onerror", void 0);
10
-
11
- _defineProperty(this, "error", void 0);
12
-
13
- _defineProperty(this, "onloadstart", void 0);
14
-
15
- _defineProperty(this, "onloadend", void 0);
16
-
17
- _defineProperty(this, "onprogress", void 0);
18
-
19
- _defineProperty(this, "readyState", void 0);
20
-
21
- _defineProperty(this, "result", void 0);
22
-
23
- _defineProperty(this, "DONE", void 0);
24
-
25
- _defineProperty(this, "EMPTY", void 0);
26
-
27
- _defineProperty(this, "LOADING", void 0);
28
-
29
- _defineProperty(this, "addEventListener", void 0);
30
-
31
- _defineProperty(this, "removeEventListener", void 0);
32
-
33
- _defineProperty(this, "dispatchEvent", void 0);
34
-
35
- this.onload = null;
36
- }
37
-
38
- abort() {
39
- return;
40
- }
41
-
42
- async readAsArrayBuffer(blob) {
43
- const arrayBuffer = await blob.arrayBuffer();
44
-
45
- if (this.onload) {
46
- this.onload({
47
- target: {
48
- result: arrayBuffer
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileReaderPolyfill = void 0;
4
+ const btoa_node_1 = require("../buffer/btoa.node");
5
+ class FileReaderPolyfill {
6
+ constructor() {
7
+ this.onload = null;
8
+ }
9
+ abort() {
10
+ return;
11
+ }
12
+ async readAsArrayBuffer(blob) {
13
+ const arrayBuffer = await blob.arrayBuffer();
14
+ if (this.onload) {
15
+ this.onload({ target: { result: arrayBuffer } });
49
16
  }
50
- });
51
17
  }
52
- }
53
-
54
- async readAsBinaryString(blob) {
55
- throw Error('Not implemented');
56
- }
57
-
58
- async readAsDataURL(blob) {
59
- const text = await blob.text();
60
- const dataUrl = "data://;base64,".concat(atob(text));
61
-
62
- if (this.onload) {
63
- this.onload({
64
- target: {
65
- result: dataUrl
18
+ async readAsBinaryString(blob) {
19
+ throw Error('Not implemented');
20
+ }
21
+ async readAsDataURL(blob) {
22
+ const text = await blob.text();
23
+ const dataUrl = `data://;base64,${(0, btoa_node_1.atob)(text)}`;
24
+ if (this.onload) {
25
+ this.onload({ target: { result: dataUrl } });
66
26
  }
67
- });
68
27
  }
69
- }
70
-
71
- async readAsText(blob) {
72
- const text = await blob.text();
73
-
74
- if (this.onload) {
75
- this.onload({
76
- target: {
77
- result: text
28
+ async readAsText(blob) {
29
+ const text = await blob.text();
30
+ if (this.onload) {
31
+ this.onload({ target: { result: text } });
78
32
  }
79
- });
80
33
  }
81
- }
82
-
83
34
  }
84
- //# sourceMappingURL=file-reader.js.map
35
+ exports.FileReaderPolyfill = FileReaderPolyfill;
@@ -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"}
@@ -1,26 +1,37 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
- let _Symbol$toStringTag;
4
-
5
- import { BlobPolyfill } from './blob';
6
- _Symbol$toStringTag = Symbol.toStringTag;
7
- export class FilePolyfill extends BlobPolyfill {
8
- constructor(init, name, options = {}) {
9
- super(init, options);
10
-
11
- _defineProperty(this, "name", '');
12
-
13
- _defineProperty(this, "webkitRelativePath", '');
14
-
15
- _defineProperty(this, "lastModified", void 0);
16
-
17
- this.name = String(name).replace(/\//g, ':');
18
- this.lastModified = (options === null || options === void 0 ? void 0 : options.lastModified) || Date.now();
19
- }
20
-
21
- get [_Symbol$toStringTag]() {
22
- return 'File';
23
- }
24
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilePolyfill = void 0;
4
+ // Forked from @gozala's web-file under MIT license https://github.com/Gozala/web-file
5
+ const blob_1 = require("./blob");
6
+ /**
7
+ * Forked from @gozala's web-file under MIT license
8
+ * @see https://github.com/Gozala/web-file
9
+ */
10
+ // @ts-ignore
11
+ class FilePolyfill extends blob_1.BlobPolyfill {
12
+ /**
13
+ * @param init
14
+ * @param name - A USVString representing the file name or the path
15
+ * to the file.
16
+ * @param [options]
17
+ */
18
+ constructor(init, name, options = {}) {
19
+ super(init, options);
20
+ // implements File {
21
+ // public API
22
+ /** The name of the file referenced by the File object. */
23
+ this.name = '';
24
+ /** The path the URL of the File is relative to. */
25
+ this.webkitRelativePath = '';
26
+ // Per File API spec https://w3c.github.io/FileAPI/#file-constructor
27
+ // Every "/" character of file name must be replaced with a ":".
28
+ /** @private */
29
+ this.name = String(name).replace(/\//g, ':');
30
+ /** @private */
31
+ this.lastModified = options?.lastModified || Date.now();
32
+ }
33
+ get [Symbol.toStringTag]() {
34
+ return 'File';
35
+ }
25
36
  }
26
- //# sourceMappingURL=file.js.map
37
+ exports.FilePolyfill = FilePolyfill;
@@ -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"}
@@ -1,22 +1,27 @@
1
- import { ReadableStreamPolyfill } from './readable-stream';
2
- import { BlobPolyfill } from './blob';
3
- import { FileReaderPolyfill } from './file-reader';
4
- import { FilePolyfill } from './file';
5
- export function installFilePolyfills() {
6
- if (typeof ReadableStream === 'undefined' && global) {
7
- global.ReadableStream = ReadableStreamPolyfill;
8
- }
9
-
10
- if (typeof Blob === 'undefined' && global) {
11
- global.Blob = BlobPolyfill;
12
- }
13
-
14
- if (typeof FileReader === 'undefined' && global) {
15
- global.FileReader = FileReaderPolyfill;
16
- }
17
-
18
- if (typeof File === 'undefined' && global) {
19
- global.File = FilePolyfill;
20
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installFilePolyfills = void 0;
4
+ const readable_stream_1 = require("./readable-stream");
5
+ const blob_1 = require("./blob");
6
+ const file_reader_1 = require("./file-reader");
7
+ const file_1 = require("./file");
8
+ function installFilePolyfills() {
9
+ if (typeof ReadableStream === 'undefined' && global) {
10
+ // @ts-ignore;
11
+ global.ReadableStream = readable_stream_1.ReadableStreamPolyfill;
12
+ }
13
+ if (typeof Blob === 'undefined' && global) {
14
+ // @ts-ignore;
15
+ global.Blob = blob_1.BlobPolyfill;
16
+ }
17
+ if (typeof FileReader === 'undefined' && global) {
18
+ // @ts-ignore;
19
+ global.FileReader = file_reader_1.FileReaderPolyfill;
20
+ }
21
+ // Install minimal Node.js File polyfill
22
+ if (typeof File === 'undefined' && global) {
23
+ // @ts-ignore;
24
+ global.File = file_1.FilePolyfill;
25
+ }
21
26
  }
22
- //# sourceMappingURL=install-file-polyfills.js.map
27
+ exports.installFilePolyfills = installFilePolyfills;
@@ -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"}
@@ -1,4 +1,11 @@
1
- import { ReadableStream as WSPReadableStream } from 'web-streams-polyfill';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReadableStreamPolyfill = void 0;
4
+ const web_streams_polyfill_1 = require("web-streams-polyfill");
5
+ // Want a polyfill, but please don't install it
6
+ // @ts-ignore
2
7
  delete global.ReadableStream;
3
- export class ReadableStreamPolyfill extends WSPReadableStream {}
4
- //# sourceMappingURL=readable-stream.js.map
8
+ // @ts-ignore
9
+ class ReadableStreamPolyfill extends web_streams_polyfill_1.ReadableStream {
10
+ }
11
+ exports.ReadableStreamPolyfill = ReadableStreamPolyfill;
@@ -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"}
@@ -1,20 +1,41 @@
1
- import savePixels from 'save-pixels';
2
- import ndarray from 'ndarray';
3
- import { bufferToArrayBuffer } from '../buffer/to-array-buffer.node';
4
- export function encodeImageToStreamNode(image, options) {
5
- const type = options.type ? options.type.replace('image/', '') : 'jpeg';
6
- const pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);
7
- return savePixels(pixels, type, options);
1
+ "use strict";
2
+ // Use stackgl modules for DOM-less reading and writing of images
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.encodeImageNode = exports.encodeImageToStreamNode = void 0;
8
+ const save_pixels_1 = __importDefault(require("save-pixels"));
9
+ const ndarray_1 = __importDefault(require("ndarray"));
10
+ const to_array_buffer_node_1 = require("../buffer/to-array-buffer.node");
11
+ /**
12
+ * Returns data bytes representing a compressed image in PNG or JPG format,
13
+ * This data can be saved using file system (f) methods or
14
+ * used in a request.
15
+ * @param image to save
16
+ * @param options
17
+ * @param options.type='png' - png, jpg or image/png, image/jpg are valid
18
+ * @param options.dataURI - Whether to include a data URI header
19
+ * @return {*} bytes
20
+ */
21
+ function encodeImageToStreamNode(image, options) {
22
+ // Support MIME type strings
23
+ const type = options.type ? options.type.replace('image/', '') : 'jpeg';
24
+ const pixels = (0, ndarray_1.default)(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);
25
+ // Note: savePixels returns a stream
26
+ return (0, save_pixels_1.default)(pixels, type, options);
8
27
  }
9
- export function encodeImageNode(image, options) {
10
- const imageStream = encodeImageToStreamNode(image, options);
11
- return new Promise(resolve => {
12
- const buffers = [];
13
- imageStream.on('data', buffer => buffers.push(buffer));
14
- imageStream.on('end', () => {
15
- const buffer = Buffer.concat(buffers);
16
- resolve(bufferToArrayBuffer(buffer));
28
+ exports.encodeImageToStreamNode = encodeImageToStreamNode;
29
+ function encodeImageNode(image, options) {
30
+ const imageStream = encodeImageToStreamNode(image, options);
31
+ return new Promise((resolve) => {
32
+ const buffers = [];
33
+ imageStream.on('data', (buffer) => buffers.push(buffer));
34
+ // TODO - convert to arraybuffer?
35
+ imageStream.on('end', () => {
36
+ const buffer = Buffer.concat(buffers);
37
+ resolve((0, to_array_buffer_node_1.bufferToArrayBuffer)(buffer));
38
+ });
17
39
  });
18
- });
19
40
  }
20
- //# sourceMappingURL=encode-image.node.js.map
41
+ exports.encodeImageNode = encodeImageNode;
@@ -0,0 +1,13 @@
1
+ /** Declares which image format mime types this loader polyfill supports */
2
+ export declare const NODE_FORMAT_SUPPORT: string[];
3
+ type NDArray = {
4
+ shape: number[];
5
+ data: Uint8Array;
6
+ width: number;
7
+ height: number;
8
+ components: number;
9
+ layers: number[];
10
+ };
11
+ export declare function parseImageNode(arrayBuffer: ArrayBuffer, mimeType: string): Promise<NDArray>;
12
+ export {};
13
+ //# 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":"AAIA,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,UAA2C,CAAC;AAG5E,KAAK,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,CAQjG"}
@@ -1,20 +1,41 @@
1
- import getPixels from 'get-pixels';
2
- import { assert } from '../../utils/assert';
3
- import util from 'util';
4
- export async function parseImageNode(arrayBuffer, mimeType) {
5
- assert(mimeType, 'MIMEType is required to parse image under Node.js');
6
- const getPixelsAsync = util.promisify(getPixels);
7
- const buffer = arrayBuffer instanceof Buffer ? arrayBuffer : Buffer.from(arrayBuffer);
8
- const ndarray = await getPixelsAsync(buffer, mimeType);
9
- const shape = [...ndarray.shape];
10
- const layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;
11
- return {
12
- shape,
13
- data: ndarray.data,
14
- width: ndarray.shape[0],
15
- height: ndarray.shape[1],
16
- components: ndarray.shape[2],
17
- layers
18
- };
1
+ "use strict";
2
+ // loaders.gl, MIT license
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.parseImageNode = exports.NODE_FORMAT_SUPPORT = void 0;
8
+ const get_pixels_1 = __importDefault(require("get-pixels"));
9
+ /** Declares which image format mime types this loader polyfill supports */
10
+ exports.NODE_FORMAT_SUPPORT = ['image/png', 'image/jpeg', 'image/gif'];
11
+ async function parseImageNode(arrayBuffer, mimeType) {
12
+ if (!mimeType) {
13
+ throw new Error('MIMEType is required to parse image under Node.js');
14
+ }
15
+ const buffer = arrayBuffer instanceof Buffer ? arrayBuffer : Buffer.from(arrayBuffer);
16
+ const ndarray = await getPixelsAsync(buffer, mimeType);
17
+ return ndarray;
18
+ }
19
+ exports.parseImageNode = parseImageNode;
20
+ // TODO - check if getPixels callback is asynchronous if provided with buffer input
21
+ // if not, parseImage can be a sync function
22
+ function getPixelsAsync(buffer, mimeType) {
23
+ return new Promise((resolve) => (0, get_pixels_1.default)(buffer, mimeType, (err, ndarray) => {
24
+ if (err) {
25
+ throw err;
26
+ }
27
+ const shape = [...ndarray.shape];
28
+ const layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;
29
+ const data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;
30
+ // extract width/height etc
31
+ resolve({
32
+ shape,
33
+ data,
34
+ width: ndarray.shape[0],
35
+ height: ndarray.shape[1],
36
+ components: ndarray.shape[2],
37
+ // TODO - error
38
+ layers: layers ? [layers] : []
39
+ });
40
+ }));
19
41
  }
20
- //# sourceMappingURL=parse-image.node.js.map
@@ -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"}
@@ -1,19 +1,24 @@
1
- export const REJECTED_STATUS = 'rejected';
2
- export const FULFILLED_STATUS = 'fulfilled';
3
- export function allSettled(promises) {
4
- const mappedPromises = promises.map(promise => {
5
- return promise.then(value => {
6
- return {
7
- status: FULFILLED_STATUS,
8
- value
9
- };
10
- }).catch(reason => {
11
- return {
12
- status: REJECTED_STATUS,
13
- reason
14
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allSettled = exports.FULFILLED_STATUS = exports.REJECTED_STATUS = void 0;
4
+ exports.REJECTED_STATUS = 'rejected';
5
+ exports.FULFILLED_STATUS = 'fulfilled';
6
+ /**
7
+ * Handle list of promises and return all values regardless of results.
8
+ * Polyfill for Promise.allSettled() method.
9
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled
10
+ * @param promises
11
+ */
12
+ function allSettled(promises) {
13
+ const mappedPromises = promises.map((promise) => {
14
+ return promise
15
+ .then((value) => {
16
+ return { status: exports.FULFILLED_STATUS, value };
17
+ })
18
+ .catch((reason) => {
19
+ return { status: exports.REJECTED_STATUS, reason };
20
+ });
15
21
  });
16
- });
17
- return Promise.all(mappedPromises);
22
+ return Promise.all(mappedPromises);
18
23
  }
19
- //# sourceMappingURL=all-settled.js.map
24
+ exports.allSettled = allSettled;
@@ -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"}
@@ -1,6 +1,9 @@
1
- export function assert(condition, message) {
2
- if (!condition) {
3
- throw new Error("@loaders.gl/polyfills assertion ".concat(message));
4
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assert = void 0;
4
+ function assert(condition, message) {
5
+ if (!condition) {
6
+ throw new Error(`@loaders.gl/polyfills assertion ${message}`);
7
+ }
5
8
  }
6
- //# sourceMappingURL=assert.js.map
9
+ exports.assert = assert;
@@ -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"}
@@ -1,9 +1,36 @@
1
- const isBrowser = typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
1
+ "use strict";
2
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ // of this software and associated documentation files (the "Software"), to deal
6
+ // in the Software without restriction, including without limitation the rights
7
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ // copies of the Software, and to permit persons to whom the Software is
9
+ // furnished to do so, subject to the following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included in
12
+ // all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ // THE SOFTWARE.
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.global = exports.isBrowser = void 0;
23
+ // Purpose: include this in your module to avoids adding dependencies on
24
+ // micro modules like 'global' and 'is-browser';
25
+ /* eslint-disable no-restricted-globals */
26
+ const isBrowser =
27
+ // @ts-ignore process.browser
28
+ typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
29
+ exports.isBrowser = isBrowser;
2
30
  const globals = {
3
- self: typeof self !== 'undefined' && self,
4
- window: typeof window !== 'undefined' && window,
5
- global: typeof global !== 'undefined' && global
31
+ self: typeof self !== 'undefined' && self,
32
+ window: typeof window !== 'undefined' && window,
33
+ global: typeof global !== 'undefined' && global
6
34
  };
7
- const global_ = globals.global || globals.self || globals.window;
8
- export { isBrowser, global_ as global };
9
- //# sourceMappingURL=globals.js.map
35
+ const global_ = (globals.global || globals.self || globals.window);
36
+ exports.global = global_;
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.6",
4
4
  "description": "Polyfills for TextEncoder/TextDecoder",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -17,9 +17,9 @@
17
17
  "TextEncoder",
18
18
  "TextDecoder"
19
19
  ],
20
- "types": "src/index.ts",
21
- "main": "dist/index.js",
22
- "module": "dist/index.js",
20
+ "types": "dist/index.d.ts",
21
+ "main": "dist/es5/index.js",
22
+ "module": "dist/esm/index.js",
23
23
  "files": [
24
24
  "src",
25
25
  "dist",
@@ -93,17 +93,18 @@
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",
101
+ "buffer": "^6.0.3",
100
102
  "get-pixels": "^3.3.2",
101
103
  "ndarray": "^1.0.18",
102
104
  "save-pixels": "^2.3.2",
103
105
  "stream-to-async-iterator": "^0.2.0",
104
106
  "through": "^2.3.8",
105
- "web-streams-polyfill": "^3.0.0",
106
- "xmldom": "^0.5.0"
107
+ "web-streams-polyfill": "^3.0.0"
107
108
  },
108
- "gitHead": "53026061b3c8871f7e96d3a5826125cc6613bddc"
109
+ "gitHead": "acc1985050dfaa0f1f0c066f8da5bce7454a046c"
109
110
  }