@loaders.gl/polyfills 4.4.0-alpha.1 → 4.4.0-alpha.10
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/buffer/btoa.node.js +1 -0
- package/dist/buffer/btoa.node.js.map +1 -0
- package/dist/buffer/to-array-buffer.node.js +1 -0
- package/dist/buffer/to-array-buffer.node.js.map +1 -0
- package/dist/crypto/node-hash.js +1 -0
- package/dist/crypto/node-hash.js.map +1 -0
- package/dist/fetch/decode-data-uri.d.ts +0 -5
- package/dist/fetch/decode-data-uri.d.ts.map +1 -1
- package/dist/fetch/decode-data-uri.js +33 -33
- package/dist/fetch/decode-data-uri.js.map +1 -0
- package/dist/fetch/fetch-polyfill.js +1 -0
- package/dist/fetch/fetch-polyfill.js.map +1 -0
- package/dist/fetch/headers-polyfill.js +1 -0
- package/dist/fetch/headers-polyfill.js.map +1 -0
- package/dist/fetch/response-polyfill.js +2 -1
- package/dist/fetch/response-polyfill.js.map +1 -0
- package/dist/fetch/utils/decode-data-uri.node.d.ts +0 -5
- package/dist/fetch/utils/decode-data-uri.node.d.ts.map +1 -1
- package/dist/fetch/utils/decode-data-uri.node.js +2 -33
- package/dist/fetch/utils/decode-data-uri.node.js.map +1 -0
- package/dist/file/blob-stream-controller.js +1 -0
- package/dist/file/blob-stream-controller.js.map +1 -0
- package/dist/file/blob-stream.js +1 -0
- package/dist/file/blob-stream.js.map +1 -0
- package/dist/file/blob.js +1 -0
- package/dist/file/blob.js.map +1 -0
- package/dist/file/file-reader.js +2 -1
- package/dist/file/file-reader.js.map +1 -0
- package/dist/file/file.js +1 -0
- package/dist/file/file.js.map +1 -0
- package/dist/file/install-blob-polyfills.js +1 -0
- package/dist/file/install-blob-polyfills.js.map +1 -0
- package/dist/file/install-file-polyfills.js +1 -0
- package/dist/file/install-file-polyfills.js.map +1 -0
- package/dist/file/readable-stream.js +1 -0
- package/dist/file/readable-stream.js.map +1 -0
- package/dist/filesystems/fetch-node.js +4 -3
- package/dist/filesystems/fetch-node.js.map +1 -0
- package/dist/filesystems/node-file.js +1 -0
- package/dist/filesystems/node-file.js.map +1 -0
- package/dist/filesystems/node-filesystem.js +1 -0
- package/dist/filesystems/node-filesystem.js.map +1 -0
- package/dist/filesystems/stream-utils.node.d.ts +0 -5
- package/dist/filesystems/stream-utils.node.d.ts.map +1 -1
- package/dist/filesystems/stream-utils.node.js +2 -33
- package/dist/filesystems/stream-utils.node.js.map +1 -0
- package/dist/images/encode-image-node.js +2 -1
- package/dist/images/encode-image-node.js.map +1 -0
- package/dist/images/parse-image-node.js +1 -0
- package/dist/images/parse-image-node.js.map +1 -0
- package/dist/index.browser.js +1 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -0
- package/dist/libs/encoding-indexes-asian.js +1 -0
- package/dist/libs/encoding-indexes-asian.js.map +1 -0
- package/dist/load-library/require-utils.node.d.ts.map +1 -1
- package/dist/load-library/require-utils.node.js +3 -1
- package/dist/load-library/require-utils.node.js.map +1 -0
- package/dist/streams/make-node-stream.js +1 -0
- package/dist/streams/make-node-stream.js.map +1 -0
- package/dist/text-encoder/encoding-indexes.js +1 -0
- package/dist/text-encoder/encoding-indexes.js.map +1 -0
- package/dist/text-encoder/text-encoder.js +1 -0
- package/dist/text-encoder/text-encoder.js.map +1 -0
- package/dist/utils/assert.js +1 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/is-browser.js +1 -0
- package/dist/utils/is-browser.js.map +1 -0
- package/package.json +5 -5
- package/src/fetch/decode-data-uri.ts +32 -34
- package/src/fetch/utils/decode-data-uri.node.ts +1 -40
- package/src/filesystems/fetch-node.ts +2 -2
- package/src/filesystems/stream-utils.node.ts +1 -40
- package/src/images/parse-image-node.ts +1 -1
- package/src/images/{parse-image.node.ts → parse-image.node.ts.disabled} +1 -1
- package/src/load-library/require-utils.node.ts +2 -1
- package/dist/images/encode-image.node.d.ts +0 -20
- package/dist/images/encode-image.node.d.ts.map +0 -1
- package/dist/images/encode-image.node.js +0 -33
- package/dist/images/parse-image.node.d.ts +0 -13
- package/dist/images/parse-image.node.d.ts.map +0 -1
- package/dist/images/parse-image.node.js +0 -36
- /package/src/images/{encode-image.node.ts → encode-image.node.ts.disabled} +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Use stackgl modules for DOM-less reading and writing of images
|
|
2
|
-
import savePixels from 'save-pixels';
|
|
3
|
-
import ndarray from 'ndarray';
|
|
4
|
-
import { bufferToArrayBuffer } from "../buffer/to-array-buffer.node.js";
|
|
5
|
-
/**
|
|
6
|
-
* Returns data bytes representing a compressed image in PNG or JPG format,
|
|
7
|
-
* This data can be saved using file system (f) methods or
|
|
8
|
-
* used in a request.
|
|
9
|
-
* @param image to save
|
|
10
|
-
* @param options
|
|
11
|
-
* @param options.type='png' - png, jpg or image/png, image/jpg are valid
|
|
12
|
-
* @param options.dataURI - Whether to include a data URI header
|
|
13
|
-
* @return {*} bytes
|
|
14
|
-
*/
|
|
15
|
-
export function encodeImageToStreamNode(image, options) {
|
|
16
|
-
// Support MIME type strings
|
|
17
|
-
const type = options.type ? options.type.replace('image/', '') : 'jpeg';
|
|
18
|
-
const pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);
|
|
19
|
-
// Note: savePixels returns a stream
|
|
20
|
-
return savePixels(pixels, type, options);
|
|
21
|
-
}
|
|
22
|
-
export function encodeImageNode(image, options) {
|
|
23
|
-
const imageStream = encodeImageToStreamNode(image, options);
|
|
24
|
-
return new Promise((resolve) => {
|
|
25
|
-
const buffers = [];
|
|
26
|
-
imageStream.on('data', (buffer) => buffers.push(buffer));
|
|
27
|
-
// TODO - convert to arraybuffer?
|
|
28
|
-
imageStream.on('end', () => {
|
|
29
|
-
const buffer = Buffer.concat(buffers);
|
|
30
|
-
resolve(bufferToArrayBuffer(buffer));
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-image.node.d.ts","sourceRoot":"","sources":["../../src/images/parse-image.node.ts"],"names":[],"mappings":"AAMA,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,36 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import getPixels from 'get-pixels';
|
|
5
|
-
/** Declares which image format mime types this loader polyfill supports */
|
|
6
|
-
export const NODE_FORMAT_SUPPORT = ['image/png', 'image/jpeg', 'image/gif'];
|
|
7
|
-
export async function parseImageNode(arrayBuffer, mimeType) {
|
|
8
|
-
if (!mimeType) {
|
|
9
|
-
throw new Error('MIMEType is required to parse image under Node.js');
|
|
10
|
-
}
|
|
11
|
-
const buffer = arrayBuffer instanceof Buffer ? arrayBuffer : Buffer.from(arrayBuffer);
|
|
12
|
-
const ndarray = await getPixelsAsync(buffer, mimeType);
|
|
13
|
-
return ndarray;
|
|
14
|
-
}
|
|
15
|
-
// TODO - check if getPixels callback is asynchronous if provided with buffer input
|
|
16
|
-
// if not, parseImage can be a sync function
|
|
17
|
-
function getPixelsAsync(buffer, mimeType) {
|
|
18
|
-
return new Promise((resolve) => getPixels(buffer, mimeType, (err, ndarray) => {
|
|
19
|
-
if (err) {
|
|
20
|
-
throw err;
|
|
21
|
-
}
|
|
22
|
-
const shape = [...ndarray.shape];
|
|
23
|
-
const layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;
|
|
24
|
-
const data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;
|
|
25
|
-
// extract width/height etc
|
|
26
|
-
resolve({
|
|
27
|
-
shape,
|
|
28
|
-
data,
|
|
29
|
-
width: ndarray.shape[0],
|
|
30
|
-
height: ndarray.shape[1],
|
|
31
|
-
components: ndarray.shape[2],
|
|
32
|
-
// TODO - error
|
|
33
|
-
layers: layers ? [layers] : []
|
|
34
|
-
});
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
File without changes
|