@loaders.gl/polyfills 3.1.3 → 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.
- package/dist/bundle.js +2 -2
- package/dist/bundle.js.map +1 -0
- package/dist/index.js +49 -84
- package/dist/index.js.map +1 -0
- package/dist/lib/encoding-indexes.js +29 -34
- package/dist/lib/encoding-indexes.js.map +1 -0
- package/dist/lib/encoding.js +1281 -2610
- package/dist/lib/encoding.js.map +1 -0
- package/dist/libs/encoding-indexes-asian.js +8 -9
- package/dist/node/buffer/btoa.node.js +5 -12
- package/dist/node/buffer/btoa.node.js.map +1 -0
- package/dist/node/buffer/to-array-buffer.node.js +8 -11
- package/dist/node/buffer/to-array-buffer.node.js.map +1 -0
- package/dist/node/fetch/fetch.node.js +112 -103
- package/dist/node/fetch/fetch.node.js.map +1 -0
- package/dist/node/fetch/headers.node.js +114 -94
- package/dist/node/fetch/headers.node.js.map +1 -0
- package/dist/node/fetch/response.node.js +84 -73
- package/dist/node/fetch/response.node.js.map +1 -0
- package/dist/node/fetch/utils/decode-data-uri.node.js +53 -63
- package/dist/node/fetch/utils/decode-data-uri.node.js.map +1 -0
- package/dist/node/fetch/utils/stream-utils.node.js +87 -105
- package/dist/node/fetch/utils/stream-utils.node.js.map +1 -0
- package/dist/node/file/blob-stream-controller.js +52 -59
- package/dist/node/file/blob-stream-controller.js.map +1 -0
- package/dist/node/file/blob-stream.js +25 -36
- package/dist/node/file/blob-stream.js.map +1 -0
- package/dist/node/file/blob.js +131 -151
- package/dist/node/file/blob.js.map +1 -0
- package/dist/node/file/file-reader.js +77 -28
- package/dist/node/file/file-reader.js.map +1 -0
- package/dist/node/file/file.js +25 -36
- package/dist/node/file/file.js.map +1 -0
- package/dist/node/file/install-file-polyfills.js +21 -26
- package/dist/node/file/install-file-polyfills.js.map +1 -0
- package/dist/node/file/readable-stream.js +3 -10
- package/dist/node/file/readable-stream.js.map +1 -0
- package/dist/node/images/encode-image.node.js +17 -38
- package/dist/node/images/encode-image.node.js.map +1 -0
- package/dist/node/images/parse-image.node.js +19 -28
- package/dist/node/images/parse-image.node.js.map +1 -0
- package/dist/promise/all-settled.js +17 -22
- package/dist/promise/all-settled.js.map +1 -0
- package/dist/utils/assert.js +5 -8
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/globals.js +7 -34
- package/dist/utils/globals.js.map +1 -0
- package/package.json +4 -4
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/index.js +0 -122
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/encoding-indexes.js +0 -37
- package/dist/es5/lib/encoding-indexes.js.map +0 -1
- package/dist/es5/lib/encoding.js +0 -1465
- package/dist/es5/lib/encoding.js.map +0 -1
- package/dist/es5/libs/encoding-indexes-asian.js +0 -13
- package/dist/es5/node/buffer/btoa.node.js +0 -16
- package/dist/es5/node/buffer/btoa.node.js.map +0 -1
- package/dist/es5/node/buffer/to-array-buffer.node.js +0 -16
- package/dist/es5/node/buffer/to-array-buffer.node.js.map +0 -1
- package/dist/es5/node/fetch/fetch.node.js +0 -183
- package/dist/es5/node/fetch/fetch.node.js.map +0 -1
- package/dist/es5/node/fetch/headers.node.js +0 -175
- package/dist/es5/node/fetch/headers.node.js.map +0 -1
- package/dist/es5/node/fetch/response.node.js +0 -231
- package/dist/es5/node/fetch/response.node.js.map +0 -1
- package/dist/es5/node/fetch/utils/decode-data-uri.node.js +0 -72
- package/dist/es5/node/fetch/utils/decode-data-uri.node.js.map +0 -1
- package/dist/es5/node/fetch/utils/stream-utils.node.js +0 -213
- package/dist/es5/node/fetch/utils/stream-utils.node.js.map +0 -1
- package/dist/es5/node/file/blob-stream-controller.js +0 -110
- package/dist/es5/node/file/blob-stream-controller.js.map +0 -1
- package/dist/es5/node/file/blob-stream.js +0 -93
- package/dist/es5/node/file/blob-stream.js.map +0 -1
- package/dist/es5/node/file/blob.js +0 -259
- package/dist/es5/node/file/blob.js.map +0 -1
- package/dist/es5/node/file/file-reader.js +0 -189
- package/dist/es5/node/file/file-reader.js.map +0 -1
- package/dist/es5/node/file/file.js +0 -63
- package/dist/es5/node/file/file.js.map +0 -1
- package/dist/es5/node/file/install-file-polyfills.js +0 -33
- package/dist/es5/node/file/install-file-polyfills.js.map +0 -1
- package/dist/es5/node/file/readable-stream.js +0 -40
- package/dist/es5/node/file/readable-stream.js.map +0 -1
- package/dist/es5/node/images/encode-image.node.js +0 -36
- package/dist/es5/node/images/encode-image.node.js.map +0 -1
- package/dist/es5/node/images/parse-image.node.js +0 -61
- package/dist/es5/node/images/parse-image.node.js.map +0 -1
- package/dist/es5/promise/all-settled.js +0 -29
- package/dist/es5/promise/all-settled.js.map +0 -1
- package/dist/es5/utils/assert.js +0 -13
- package/dist/es5/utils/assert.js.map +0 -1
- package/dist/es5/utils/globals.js +0 -21
- package/dist/es5/utils/globals.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/index.js +0 -63
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/encoding-indexes.js +0 -30
- package/dist/esm/lib/encoding-indexes.js.map +0 -1
- package/dist/esm/lib/encoding.js +0 -1450
- package/dist/esm/lib/encoding.js.map +0 -1
- package/dist/esm/libs/encoding-indexes-asian.js +0 -13
- package/dist/esm/node/buffer/btoa.node.js +0 -7
- package/dist/esm/node/buffer/btoa.node.js.map +0 -1
- package/dist/esm/node/buffer/to-array-buffer.node.js +0 -9
- package/dist/esm/node/buffer/to-array-buffer.node.js.map +0 -1
- package/dist/esm/node/fetch/fetch.node.js +0 -126
- package/dist/esm/node/fetch/fetch.node.js.map +0 -1
- package/dist/esm/node/fetch/headers.node.js +0 -125
- package/dist/esm/node/fetch/headers.node.js.map +0 -1
- package/dist/esm/node/fetch/response.node.js +0 -88
- package/dist/esm/node/fetch/response.node.js.map +0 -1
- package/dist/esm/node/fetch/utils/decode-data-uri.node.js +0 -55
- package/dist/esm/node/fetch/utils/decode-data-uri.node.js.map +0 -1
- package/dist/esm/node/fetch/utils/stream-utils.node.js +0 -98
- package/dist/esm/node/fetch/utils/stream-utils.node.js.map +0 -1
- package/dist/esm/node/file/blob-stream-controller.js +0 -56
- package/dist/esm/node/file/blob-stream-controller.js.map +0 -1
- package/dist/esm/node/file/blob-stream.js +0 -26
- package/dist/esm/node/file/blob-stream.js.map +0 -1
- package/dist/esm/node/file/blob.js +0 -140
- package/dist/esm/node/file/blob.js.map +0 -1
- package/dist/esm/node/file/file-reader.js +0 -84
- package/dist/esm/node/file/file-reader.js.map +0 -1
- package/dist/esm/node/file/file.js +0 -26
- package/dist/esm/node/file/file.js.map +0 -1
- package/dist/esm/node/file/install-file-polyfills.js +0 -22
- package/dist/esm/node/file/install-file-polyfills.js.map +0 -1
- package/dist/esm/node/file/readable-stream.js +0 -4
- package/dist/esm/node/file/readable-stream.js.map +0 -1
- package/dist/esm/node/images/encode-image.node.js +0 -20
- package/dist/esm/node/images/encode-image.node.js.map +0 -1
- package/dist/esm/node/images/parse-image.node.js +0 -20
- package/dist/esm/node/images/parse-image.node.js.map +0 -1
- package/dist/esm/promise/all-settled.js +0 -19
- package/dist/esm/promise/all-settled.js.map +0 -1
- package/dist/esm/utils/assert.js +0 -6
- package/dist/esm/utils/assert.js.map +0 -1
- package/dist/esm/utils/globals.js +0 -9
- package/dist/esm/utils/globals.js.map +0 -1
package/dist/node/file/file.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
}
|
|
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
|
+
|
|
36
25
|
}
|
|
37
|
-
|
|
26
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/node/file/file.ts"],"names":["BlobPolyfill","Symbol","toStringTag","FilePolyfill","constructor","init","name","options","String","replace","lastModified","Date","now"],"mappings":";;;;AACA,SAAQA,YAAR,QAA2B,QAA3B;sBAqCOC,MAAM,CAACC,W;AA9Bd,OAAO,MAAMC,YAAN,SAA2BH,YAA3B,CAAwC;AAoB7CI,EAAAA,WAAW,CAACC,IAAD,EAAmBC,IAAnB,EAAiCC,OAAwB,GAAG,EAA5D,EAAgE;AACzE,UAAMF,IAAN,EAAYE,OAAZ;;AADyE,kCAhB5D,EAgB4D;;AAAA,gDAd9C,EAc8C;;AAAA;;AAKzE,SAAKD,IAAL,GAAYE,MAAM,CAACF,IAAD,CAAN,CAAaG,OAAb,CAAqB,KAArB,EAA4B,GAA5B,CAAZ;AAEA,SAAKC,YAAL,GAAoB,CAAAH,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEG,YAAT,KAAyBC,IAAI,CAACC,GAAL,EAA7C;AACD;;AAED,8BAA2B;AACzB,WAAO,MAAP;AACD;;AAhC4C","sourcesContent":["// Forked from @gozala's web-file under MIT license https://github.com/Gozala/web-file\nimport {BlobPolyfill} from './blob';\n\n/**\n * Forked from @gozala's web-file under MIT license\n * @see https://github.com/Gozala/web-file\n */\n// @ts-ignore\nexport class FilePolyfill extends BlobPolyfill {\n // implements File {\n // public API\n /** The name of the file referenced by the File object. */\n name: string = '';\n /** The path the URL of the File is relative to. */\n webkitRelativePath: string = '';\n\n /**\n * Returns the last modified time of the file, in millisecond since the UNIX\n * epoch (January 1st, 1970 at Midnight).\n */\n lastModified: number;\n\n /**\n * @param init\n * @param name - A USVString representing the file name or the path\n * to the file.\n * @param [options]\n */\n constructor(init: BlobPart[], name: string, options: FilePropertyBag = {}) {\n super(init, options);\n // Per File API spec https://w3c.github.io/FileAPI/#file-constructor\n // Every \"/\" character of file name must be replaced with a \":\".\n /** @private */\n this.name = String(name).replace(/\\//g, ':');\n /** @private */\n this.lastModified = options?.lastModified || Date.now();\n }\n\n get [Symbol.toStringTag]() {\n return 'File';\n }\n}\n"],"file":"file.js"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Install minimal Node.js File polyfill
|
|
22
|
-
if (typeof File === 'undefined' && global) {
|
|
23
|
-
// @ts-ignore;
|
|
24
|
-
global.File = file_1.FilePolyfill;
|
|
25
|
-
}
|
|
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
|
+
}
|
|
26
21
|
}
|
|
27
|
-
|
|
22
|
+
//# sourceMappingURL=install-file-polyfills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/node/file/install-file-polyfills.ts"],"names":["ReadableStreamPolyfill","BlobPolyfill","FileReaderPolyfill","FilePolyfill","installFilePolyfills","ReadableStream","global","Blob","FileReader","File"],"mappings":"AAAA,SAAQA,sBAAR,QAAqC,mBAArC;AACA,SAAQC,YAAR,QAA2B,QAA3B;AACA,SAAQC,kBAAR,QAAiC,eAAjC;AACA,SAAQC,YAAR,QAA2B,QAA3B;AAEA,OAAO,SAASC,oBAAT,GAAgC;AACrC,MAAI,OAAOC,cAAP,KAA0B,WAA1B,IAAyCC,MAA7C,EAAqD;AAEnDA,IAAAA,MAAM,CAACD,cAAP,GAAwBL,sBAAxB;AACD;;AAED,MAAI,OAAOO,IAAP,KAAgB,WAAhB,IAA+BD,MAAnC,EAA2C;AAEzCA,IAAAA,MAAM,CAACC,IAAP,GAAcN,YAAd;AACD;;AAED,MAAI,OAAOO,UAAP,KAAsB,WAAtB,IAAqCF,MAAzC,EAAiD;AAE/CA,IAAAA,MAAM,CAACE,UAAP,GAAoBN,kBAApB;AACD;;AAGD,MAAI,OAAOO,IAAP,KAAgB,WAAhB,IAA+BH,MAAnC,EAA2C;AAEzCA,IAAAA,MAAM,CAACG,IAAP,GAAcN,YAAd;AACD;AACF","sourcesContent":["import {ReadableStreamPolyfill} from './readable-stream';\nimport {BlobPolyfill} from './blob';\nimport {FileReaderPolyfill} from './file-reader';\nimport {FilePolyfill} from './file';\n\nexport function installFilePolyfills() {\n if (typeof ReadableStream === 'undefined' && global) {\n // @ts-ignore;\n global.ReadableStream = ReadableStreamPolyfill;\n }\n\n if (typeof Blob === 'undefined' && global) {\n // @ts-ignore;\n global.Blob = BlobPolyfill;\n }\n\n if (typeof FileReader === 'undefined' && global) {\n // @ts-ignore;\n global.FileReader = FileReaderPolyfill;\n }\n\n // Install minimal Node.js File polyfill\n if (typeof File === 'undefined' && global) {\n // @ts-ignore;\n global.File = FilePolyfill;\n }\n}\n"],"file":"install-file-polyfills.js"}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
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
|
|
1
|
+
import { ReadableStream as WSPReadableStream } from 'web-streams-polyfill';
|
|
7
2
|
delete global.ReadableStream;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
exports.ReadableStreamPolyfill = ReadableStreamPolyfill;
|
|
3
|
+
export class ReadableStreamPolyfill extends WSPReadableStream {}
|
|
4
|
+
//# sourceMappingURL=readable-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/node/file/readable-stream.ts"],"names":["ReadableStream","WSPReadableStream","global","ReadableStreamPolyfill"],"mappings":"AAAA,SAAQA,cAAc,IAAIC,iBAA1B,QAAkD,sBAAlD;AAIA,OAAOC,MAAM,CAACF,cAAd;AAGA,OAAO,MAAMG,sBAAN,SAAwCF,iBAAxC,CAAuF","sourcesContent":["import {ReadableStream as WSPReadableStream} from 'web-streams-polyfill';\n\n// Want a polyfill, but please don't install it\n// @ts-ignore\ndelete global.ReadableStream;\n\n// @ts-ignore\nexport class ReadableStreamPolyfill<T> extends WSPReadableStream<T> implements ReadableStream {}\n"],"file":"readable-stream.js"}
|
|
@@ -1,41 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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);
|
|
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);
|
|
27
8
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const buffer = Buffer.concat(buffers);
|
|
37
|
-
resolve((0, to_array_buffer_node_1.bufferToArrayBuffer)(buffer));
|
|
38
|
-
});
|
|
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));
|
|
39
17
|
});
|
|
18
|
+
});
|
|
40
19
|
}
|
|
41
|
-
|
|
20
|
+
//# sourceMappingURL=encode-image.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/node/images/encode-image.node.ts"],"names":["savePixels","ndarray","bufferToArrayBuffer","encodeImageToStreamNode","image","options","type","replace","pixels","data","width","height","encodeImageNode","imageStream","Promise","resolve","buffers","on","buffer","push","Buffer","concat"],"mappings":"AAEA,OAAOA,UAAP,MAAuB,aAAvB;AACA,OAAOC,OAAP,MAAoB,SAApB;AACA,SAAQC,mBAAR,QAAkC,gCAAlC;AAYA,OAAO,SAASC,uBAAT,CACLC,KADK,EAELC,OAFK,EAGL;AAEA,QAAMC,IAAI,GAAGD,OAAO,CAACC,IAAR,GAAeD,OAAO,CAACC,IAAR,CAAaC,OAAb,CAAqB,QAArB,EAA+B,EAA/B,CAAf,GAAoD,MAAjE;AACA,QAAMC,MAAM,GAAGP,OAAO,CAACG,KAAK,CAACK,IAAP,EAAa,CAACL,KAAK,CAACM,KAAP,EAAcN,KAAK,CAACO,MAApB,EAA4B,CAA5B,CAAb,EAA6C,CAAC,CAAD,EAAIP,KAAK,CAACM,KAAN,GAAc,CAAlB,EAAqB,CAArB,CAA7C,EAAsE,CAAtE,CAAtB;AAGA,SAAOV,UAAU,CAACQ,MAAD,EAASF,IAAT,EAAeD,OAAf,CAAjB;AACD;AAED,OAAO,SAASO,eAAT,CAAyBR,KAAzB,EAAgCC,OAAhC,EAAyC;AAC9C,QAAMQ,WAAW,GAAGV,uBAAuB,CAACC,KAAD,EAAQC,OAAR,CAA3C;AAEA,SAAO,IAAIS,OAAJ,CAAaC,OAAD,IAAa;AAC9B,UAAMC,OAAc,GAAG,EAAvB;AACAH,IAAAA,WAAW,CAACI,EAAZ,CAAe,MAAf,EAAwBC,MAAD,IAAYF,OAAO,CAACG,IAAR,CAAaD,MAAb,CAAnC;AAEAL,IAAAA,WAAW,CAACI,EAAZ,CAAe,KAAf,EAAsB,MAAM;AAC1B,YAAMC,MAAM,GAAGE,MAAM,CAACC,MAAP,CAAcL,OAAd,CAAf;AACAD,MAAAA,OAAO,CAACb,mBAAmB,CAACgB,MAAD,CAApB,CAAP;AACD,KAHD;AAID,GARM,CAAP;AASD","sourcesContent":["// Use stackgl modules for DOM-less reading and writing of images\n\nimport savePixels from 'save-pixels';\nimport ndarray from 'ndarray';\nimport {bufferToArrayBuffer} from '../buffer/to-array-buffer.node';\n\n/**\n * Returns data bytes representing a compressed image in PNG or JPG format,\n * This data can be saved using file system (f) methods or\n * used in a request.\n * @param image to save\n * @param options\n * @param options.type='png' - png, jpg or image/png, image/jpg are valid\n * @param options.dataURI - Whether to include a data URI header\n * @return {*} bytes\n */\nexport function encodeImageToStreamNode(\n image: {data: any; width: number; height: number},\n options: {type?: string; dataURI?: string}\n) {\n // Support MIME type strings\n const type = options.type ? options.type.replace('image/', '') : 'jpeg';\n const pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);\n\n // Note: savePixels returns a stream\n return savePixels(pixels, type, options);\n}\n\nexport function encodeImageNode(image, options) {\n const imageStream = encodeImageToStreamNode(image, options);\n\n return new Promise((resolve) => {\n const buffers: any[] = [];\n imageStream.on('data', (buffer) => buffers.push(buffer));\n // TODO - convert to arraybuffer?\n imageStream.on('end', () => {\n const buffer = Buffer.concat(buffers);\n resolve(bufferToArrayBuffer(buffer));\n });\n });\n}\n"],"file":"encode-image.node.js"}
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// extract width/height etc
|
|
20
|
-
return {
|
|
21
|
-
shape,
|
|
22
|
-
data: ndarray.data,
|
|
23
|
-
width: ndarray.shape[0],
|
|
24
|
-
height: ndarray.shape[1],
|
|
25
|
-
components: ndarray.shape[2],
|
|
26
|
-
layers
|
|
27
|
-
};
|
|
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
|
+
};
|
|
28
19
|
}
|
|
29
|
-
|
|
20
|
+
//# sourceMappingURL=parse-image.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/node/images/parse-image.node.ts"],"names":["getPixels","assert","util","parseImageNode","arrayBuffer","mimeType","getPixelsAsync","promisify","buffer","Buffer","from","ndarray","shape","layers","length","shift","data","width","height","components"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,YAAtB;AACA,SAAQC,MAAR,QAAqB,oBAArB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AAYA,OAAO,eAAeC,cAAf,CAA8BC,WAA9B,EAAwDC,QAAxD,EAA4F;AACjGJ,EAAAA,MAAM,CAACI,QAAD,EAAW,mDAAX,CAAN;AAIA,QAAMC,cAAc,GAAGJ,IAAI,CAACK,SAAL,CAAeP,SAAf,CAAvB;AAEA,QAAMQ,MAAM,GAAGJ,WAAW,YAAYK,MAAvB,GAAgCL,WAAhC,GAA8CK,MAAM,CAACC,IAAP,CAAYN,WAAZ,CAA7D;AAEA,QAAMO,OAAO,GAAG,MAAML,cAAc,CAACE,MAAD,EAASH,QAAT,CAApC;AAEA,QAAMO,KAAK,GAAG,CAAC,GAAGD,OAAO,CAACC,KAAZ,CAAd;AACA,QAAMC,MAAM,GAAGF,OAAO,CAACC,KAAR,CAAcE,MAAd,KAAyB,CAAzB,GAA6BH,OAAO,CAACC,KAAR,CAAcG,KAAd,EAA7B,GAAqD,CAApE;AAGA,SAAO;AACLH,IAAAA,KADK;AAELI,IAAAA,IAAI,EAAEL,OAAO,CAACK,IAFT;AAGLC,IAAAA,KAAK,EAAEN,OAAO,CAACC,KAAR,CAAc,CAAd,CAHF;AAILM,IAAAA,MAAM,EAAEP,OAAO,CAACC,KAAR,CAAc,CAAd,CAJH;AAKLO,IAAAA,UAAU,EAAER,OAAO,CAACC,KAAR,CAAc,CAAd,CALP;AAMLC,IAAAA;AANK,GAAP;AAQD","sourcesContent":["import getPixels from 'get-pixels';\nimport {assert} from '../../utils/assert';\nimport util from 'util';\n\n// Note: These types are also defined in @loaders.gl/images and need to be kept in sync\ntype NDArray = {\n shape: number[];\n data: Uint8Array;\n width: number;\n height: number;\n components: number;\n layers: number[];\n};\n\nexport async function parseImageNode(arrayBuffer: ArrayBuffer, mimeType: string): Promise<NDArray> {\n assert(mimeType, 'MIMEType is required to parse image under Node.js');\n\n // TODO - check if getPixels callback is asynchronous if provided with buffer input\n // if not, parseImage can be a sync function\n const getPixelsAsync = util.promisify(getPixels);\n\n const buffer = arrayBuffer instanceof Buffer ? arrayBuffer : Buffer.from(arrayBuffer);\n\n const ndarray = await getPixelsAsync(buffer, mimeType);\n\n const shape = [...ndarray.shape];\n const layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;\n\n // extract width/height etc\n return {\n shape,\n data: ndarray.data,\n width: ndarray.shape[0],\n height: ndarray.shape[1],\n components: ndarray.shape[2],\n layers\n };\n}\n"],"file":"parse-image.node.js"}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.then((value) => {
|
|
16
|
-
return { status: exports.FULFILLED_STATUS, value };
|
|
17
|
-
})
|
|
18
|
-
.catch((reason) => {
|
|
19
|
-
return { status: exports.REJECTED_STATUS, reason };
|
|
20
|
-
});
|
|
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
|
+
};
|
|
21
15
|
});
|
|
22
|
-
|
|
16
|
+
});
|
|
17
|
+
return Promise.all(mappedPromises);
|
|
23
18
|
}
|
|
24
|
-
|
|
19
|
+
//# sourceMappingURL=all-settled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/promise/all-settled.ts"],"names":["REJECTED_STATUS","FULFILLED_STATUS","allSettled","promises","mappedPromises","map","promise","then","value","status","catch","reason","Promise","all"],"mappings":"AAAA,OAAO,MAAMA,eAAe,GAAG,UAAxB;AACP,OAAO,MAAMC,gBAAgB,GAAG,WAAzB;AAQP,OAAO,SAASC,UAAT,CAAoBC,QAApB,EAA4D;AACjE,QAAMC,cAAc,GAAGD,QAAQ,CAACE,GAAT,CAAcC,OAAD,IAAa;AAC/C,WAAOA,OAAO,CACXC,IADI,CACEC,KAAD,IAAW;AACf,aAAO;AAACC,QAAAA,MAAM,EAAER,gBAAT;AAA2BO,QAAAA;AAA3B,OAAP;AACD,KAHI,EAIJE,KAJI,CAIGC,MAAD,IAAY;AACjB,aAAO;AAACF,QAAAA,MAAM,EAAET,eAAT;AAA0BW,QAAAA;AAA1B,OAAP;AACD,KANI,CAAP;AAOD,GARsB,CAAvB;AASA,SAAOC,OAAO,CAACC,GAAR,CAAYT,cAAZ,CAAP;AACD","sourcesContent":["export const REJECTED_STATUS = 'rejected';\nexport const FULFILLED_STATUS = 'fulfilled';\n\n/**\n * Handle list of promises and return all values regardless of results.\n * Polyfill for Promise.allSettled() method.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled\n * @param promises\n */\nexport function allSettled(promises: Promise<any>[]): Promise<any> {\n const mappedPromises = promises.map((promise) => {\n return promise\n .then((value) => {\n return {status: FULFILLED_STATUS, value};\n })\n .catch((reason) => {\n return {status: REJECTED_STATUS, reason};\n });\n });\n return Promise.all(mappedPromises);\n}\n"],"file":"all-settled.js"}
|
package/dist/utils/assert.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!condition) {
|
|
6
|
-
throw new Error(`@loaders.gl/polyfills assertion ${message}`);
|
|
7
|
-
}
|
|
1
|
+
export function assert(condition, message) {
|
|
2
|
+
if (!condition) {
|
|
3
|
+
throw new Error("@loaders.gl/polyfills assertion ".concat(message));
|
|
4
|
+
}
|
|
8
5
|
}
|
|
9
|
-
|
|
6
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/assert.ts"],"names":["assert","condition","message","Error"],"mappings":"AAAA,OAAO,SAASA,MAAT,CAAgBC,SAAhB,EAAgCC,OAAhC,EAAwD;AAC7D,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,2CAA6CD,OAA7C,EAAN;AACD;AACF","sourcesContent":["export function assert(condition: any, message?: string): void {\n if (!condition) {\n throw new Error(`@loaders.gl/polyfills assertion ${message}`);\n }\n}\n"],"file":"assert.js"}
|
package/dist/utils/globals.js
CHANGED
|
@@ -1,36 +1,9 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
const isBrowser = typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
|
|
30
2
|
const globals = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
3
|
+
self: typeof self !== 'undefined' && self,
|
|
4
|
+
window: typeof window !== 'undefined' && window,
|
|
5
|
+
global: typeof global !== 'undefined' && global
|
|
34
6
|
};
|
|
35
|
-
const global_ =
|
|
36
|
-
|
|
7
|
+
const global_ = globals.global || globals.self || globals.window;
|
|
8
|
+
export { isBrowser, global_ as global };
|
|
9
|
+
//# sourceMappingURL=globals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/globals.ts"],"names":["isBrowser","process","String","browser","globals","self","window","global","global_"],"mappings":"AAwBA,MAAMA,SAAkB,GAEtB,OAAOC,OAAP,KAAmB,QAAnB,IAA+BC,MAAM,CAACD,OAAD,CAAN,KAAoB,kBAAnD,IAAyEA,OAAO,CAACE,OAFnF;AAIA,MAAMC,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAE,OAAOA,IAAP,KAAgB,WAAhB,IAA+BA,IADvB;AAEdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA,MAF3B;AAGdC,EAAAA,MAAM,EAAE,OAAOA,MAAP,KAAkB,WAAlB,IAAiCA;AAH3B,CAAhB;AAMA,MAAMC,OAAe,GAAIJ,OAAO,CAACG,MAAR,IAAkBH,OAAO,CAACC,IAA1B,IAAkCD,OAAO,CAACE,MAAnE;AAEA,SAAQN,SAAR,EAAmBQ,OAAO,IAAID,MAA9B","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n// Purpose: include this in your module to avoids adding dependencies on\n// micro modules like 'global' and 'is-browser';\n\n/* eslint-disable no-restricted-globals */\nconst isBrowser: boolean =\n // @ts-ignore process.browser\n typeof process !== 'object' || String(process) !== '[object process]' || process.browser;\n\nconst globals = {\n self: typeof self !== 'undefined' && self,\n window: typeof window !== 'undefined' && window,\n global: typeof global !== 'undefined' && global\n};\n\nconst global_: object = (globals.global || globals.self || globals.window) as object;\n\nexport {isBrowser, global_ as global};\n"],"file":"globals.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/polyfills",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"description": "Polyfills for TextEncoder/TextDecoder",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"TextDecoder"
|
|
19
19
|
],
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
|
-
"main": "dist/
|
|
22
|
-
"module": "dist/
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"module": "dist/index.js",
|
|
23
23
|
"files": [
|
|
24
24
|
"src",
|
|
25
25
|
"dist",
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"through": "^2.3.8",
|
|
106
106
|
"web-streams-polyfill": "^3.0.0"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
|
|
109
109
|
}
|
package/dist/es5/bundle.js
DELETED
package/dist/es5/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
|
package/dist/es5/index.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
Object.defineProperty(exports, "ReadableStreamPolyfill", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _readableStream.ReadableStreamPolyfill;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, "BlobPolyfill", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
return _blob.BlobPolyfill;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(exports, "FileReaderPolyfill", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function get() {
|
|
25
|
-
return _fileReader.FileReaderPolyfill;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports, "FilePolyfill", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function get() {
|
|
31
|
-
return _file.FilePolyfill;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(exports, "installFilePolyfills", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function get() {
|
|
37
|
-
return _installFilePolyfills.installFilePolyfills;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
var _xmldom = require("@xmldom/xmldom");
|
|
42
|
-
|
|
43
|
-
var _globals = require("./utils/globals");
|
|
44
|
-
|
|
45
|
-
var _encoding = require("./lib/encoding");
|
|
46
|
-
|
|
47
|
-
var _allSettled = require("./promise/all-settled");
|
|
48
|
-
|
|
49
|
-
var base64 = _interopRequireWildcard(require("./node/buffer/btoa.node"));
|
|
50
|
-
|
|
51
|
-
var _headers = _interopRequireDefault(require("./node/fetch/headers.node"));
|
|
52
|
-
|
|
53
|
-
var _response = _interopRequireDefault(require("./node/fetch/response.node"));
|
|
54
|
-
|
|
55
|
-
var _fetch = _interopRequireDefault(require("./node/fetch/fetch.node"));
|
|
56
|
-
|
|
57
|
-
var _encodeImage = require("./node/images/encode-image.node");
|
|
58
|
-
|
|
59
|
-
var _parseImage = require("./node/images/parse-image.node");
|
|
60
|
-
|
|
61
|
-
var _readableStream = require("./node/file/readable-stream");
|
|
62
|
-
|
|
63
|
-
var _blob = require("./node/file/blob");
|
|
64
|
-
|
|
65
|
-
var _fileReader = require("./node/file/file-reader");
|
|
66
|
-
|
|
67
|
-
var _file = require("./node/file/file");
|
|
68
|
-
|
|
69
|
-
var _installFilePolyfills = require("./node/file/install-file-polyfills");
|
|
70
|
-
|
|
71
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
72
|
-
|
|
73
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
74
|
-
|
|
75
|
-
var installTextEncoder = !_globals.isBrowser || !('TextEncoder' in _globals.global);
|
|
76
|
-
|
|
77
|
-
if (installTextEncoder) {
|
|
78
|
-
_globals.global['TextEncoder'] = _encoding.TextEncoder;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var installTextDecoder = !_globals.isBrowser || !('TextDecoder' in _globals.global);
|
|
82
|
-
|
|
83
|
-
if (installTextDecoder) {
|
|
84
|
-
_globals.global['TextDecoder'] = _encoding.TextDecoder;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!_globals.isBrowser && !('atob' in _globals.global) && base64.atob) {
|
|
88
|
-
_globals.global['atob'] = base64.atob;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (!_globals.isBrowser && !('btoa' in _globals.global) && base64.btoa) {
|
|
92
|
-
_globals.global['btoa'] = base64.btoa;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!_globals.isBrowser && !('Headers' in _globals.global) && _headers.default) {
|
|
96
|
-
_globals.global['Headers'] = _headers.default;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!_globals.isBrowser && !('Response' in _globals.global) && _response.default) {
|
|
100
|
-
_globals.global['Response'] = _response.default;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (!_globals.isBrowser && !('fetch' in _globals.global) && _fetch.default) {
|
|
104
|
-
_globals.global['fetch'] = _fetch.default;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (!_globals.isBrowser && !('DOMParser' in _globals.global) && _xmldom.DOMParser) {
|
|
108
|
-
_globals.global['DOMParser'] = _xmldom.DOMParser;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!_globals.isBrowser && !('_encodeImageNode' in _globals.global) && _encodeImage.encodeImageNode) {
|
|
112
|
-
_globals.global['_encodeImageNode'] = _encodeImage.encodeImageNode;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (!_globals.isBrowser && !('_parseImageNode' in _globals.global) && _parseImage.parseImageNode) {
|
|
116
|
-
_globals.global['_parseImageNode'] = _parseImage.parseImageNode;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!('allSettled' in Promise)) {
|
|
120
|
-
Promise.allSettled = _allSettled.allSettled;
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=index.js.map
|
package/dist/es5/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":["installTextEncoder","isBrowser","global","TextEncoder","installTextDecoder","TextDecoder","base64","atob","btoa","HeadersNode","ResponseNode","fetchNode","DOMParser","encodeImageNode","parseImageNode","Promise","allSettled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAGA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMA,IAAMA,kBAAkB,GAAG,CAACC,kBAAD,IAAc,EAAE,iBAAiBC,eAAnB,CAAzC;;AACA,IAAIF,kBAAJ,EAAwB;AACtBE,kBAAO,aAAP,IAAwBC,qBAAxB;AACD;;AAED,IAAMC,kBAAkB,GAAG,CAACH,kBAAD,IAAc,EAAE,iBAAiBC,eAAnB,CAAzC;;AACA,IAAIE,kBAAJ,EAAwB;AACtBF,kBAAO,aAAP,IAAwBG,qBAAxB;AACD;;AAMD,IAAI,CAACJ,kBAAD,IAAc,EAAE,UAAUC,eAAZ,CAAd,IAAqCI,MAAM,CAACC,IAAhD,EAAsD;AACpDL,kBAAO,MAAP,IAAiBI,MAAM,CAACC,IAAxB;AACD;;AACD,IAAI,CAACN,kBAAD,IAAc,EAAE,UAAUC,eAAZ,CAAd,IAAqCI,MAAM,CAACE,IAAhD,EAAsD;AACpDN,kBAAO,MAAP,IAAiBI,MAAM,CAACE,IAAxB;AACD;;AAMD,IAAI,CAACP,kBAAD,IAAc,EAAE,aAAaC,eAAf,CAAd,IAAwCO,gBAA5C,EAAyD;AACvDP,kBAAO,SAAP,IAAoBO,gBAApB;AACD;;AAED,IAAI,CAACR,kBAAD,IAAc,EAAE,cAAcC,eAAhB,CAAd,IAAyCQ,iBAA7C,EAA2D;AACzDR,kBAAO,UAAP,IAAqBQ,iBAArB;AACD;;AAED,IAAI,CAACT,kBAAD,IAAc,EAAE,WAAWC,eAAb,CAAd,IAAsCS,cAA1C,EAAqD;AACnDT,kBAAO,OAAP,IAAkBS,cAAlB;AACD;;AAMD,IAAI,CAACV,kBAAD,IAAc,EAAE,eAAeC,eAAjB,CAAd,IAA0CU,iBAA9C,EAAyD;AACvDV,kBAAO,WAAP,IAAsBU,iBAAtB;AACD;;AAMD,IAAI,CAACX,kBAAD,IAAc,EAAE,sBAAsBC,eAAxB,CAAd,IAAiDW,4BAArD,EAAsE;AACpEX,kBAAO,kBAAP,IAA6BW,4BAA7B;AACD;;AAED,IAAI,CAACZ,kBAAD,IAAc,EAAE,qBAAqBC,eAAvB,CAAd,IAAgDY,0BAApD,EAAoE;AAClEZ,kBAAO,iBAAP,IAA4BY,0BAA5B;AACD;;AAED,IAAI,EAAE,gBAAgBC,OAAlB,CAAJ,EAAgC;AAE9BA,EAAAA,OAAO,CAACC,UAAR,GAAqBA,sBAArB;AACD","sourcesContent":["/* eslint-disable dot-notation */\nimport {DOMParser} from '@xmldom/xmldom';\nimport {isBrowser, global} from './utils/globals';\n\nimport {TextDecoder, TextEncoder} from './lib/encoding';\nimport {allSettled} from './promise/all-settled';\n\n// Node specific\nimport * as base64 from './node/buffer/btoa.node';\n\nimport HeadersNode from './node/fetch/headers.node';\nimport ResponseNode from './node/fetch/response.node';\nimport fetchNode from './node/fetch/fetch.node';\n\nimport {encodeImageNode} from './node/images/encode-image.node';\nimport {parseImageNode} from './node/images/parse-image.node';\n\nexport {ReadableStreamPolyfill} from './node/file/readable-stream';\nexport {BlobPolyfill} from './node/file/blob';\nexport {FileReaderPolyfill} from './node/file/file-reader';\nexport {FilePolyfill} from './node/file/file';\nexport {installFilePolyfills} from './node/file/install-file-polyfills';\n\n// POLYFILLS: TextEncoder, TextDecoder\n// - Recent Node versions have these classes but virtually no encodings unless special build.\n// - Browser: Edge, IE11 do not have these\n\nconst installTextEncoder = !isBrowser || !('TextEncoder' in global);\nif (installTextEncoder) {\n global['TextEncoder'] = TextEncoder;\n}\n\nconst installTextDecoder = !isBrowser || !('TextDecoder' in global);\nif (installTextDecoder) {\n global['TextDecoder'] = TextDecoder;\n}\n\n// POLYFILLS: btoa, atob\n// - Node: Yes\n// - Browser: No\n\nif (!isBrowser && !('atob' in global) && base64.atob) {\n global['atob'] = base64.atob;\n}\nif (!isBrowser && !('btoa' in global) && base64.btoa) {\n global['btoa'] = base64.btoa;\n}\n\n// POLYFILL: fetch\n// - Node: Yes\n// - Browser: No. For This polyfill is node only, IE11 etc, install external polyfill\n\nif (!isBrowser && !('Headers' in global) && HeadersNode) {\n global['Headers'] = HeadersNode;\n}\n\nif (!isBrowser && !('Response' in global) && ResponseNode) {\n global['Response'] = ResponseNode;\n}\n\nif (!isBrowser && !('fetch' in global) && fetchNode) {\n global['fetch'] = fetchNode;\n}\n\n// POLYFILL: DOMParser\n// - Node: Yes\n// - Browser: No\n\nif (!isBrowser && !('DOMParser' in global) && DOMParser) {\n global['DOMParser'] = DOMParser;\n}\n\n// NODE IMAGE FUNCTIONS:\n// These are not official polyfills but used by the @loaders.gl/images module if installed\n// TODO - is there an appropriate Image API we could polyfill using an adapter?\n\nif (!isBrowser && !('_encodeImageNode' in global) && encodeImageNode) {\n global['_encodeImageNode'] = encodeImageNode;\n}\n\nif (!isBrowser && !('_parseImageNode' in global) && parseImageNode) {\n global['_parseImageNode'] = parseImageNode;\n}\n\nif (!('allSettled' in Promise)) {\n // @ts-ignore\n Promise.allSettled = allSettled;\n}\n"],"file":"index.js"}
|