@loaders.gl/polyfills 3.3.0-alpha.3 → 3.3.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/es5/node/images/parse-image.node.js +4 -3
- package/dist/es5/node/images/parse-image.node.js.map +1 -1
- package/dist/esm/node/images/parse-image.node.js +2 -1
- package/dist/esm/node/images/parse-image.node.js.map +1 -1
- package/dist/node/images/parse-image.node.d.ts.map +1 -1
- package/dist/node/images/parse-image.node.js +2 -1
- package/package.json +2 -2
- package/src/node/images/parse-image.node.ts +2 -1
|
@@ -25,7 +25,7 @@ function parseImageNode(_x, _x2) {
|
|
|
25
25
|
|
|
26
26
|
function _parseImageNode() {
|
|
27
27
|
_parseImageNode = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, mimeType) {
|
|
28
|
-
var getPixelsAsync, buffer, ndarray, shape, layers;
|
|
28
|
+
var getPixelsAsync, buffer, ndarray, shape, layers, data;
|
|
29
29
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
30
30
|
while (1) {
|
|
31
31
|
switch (_context.prev = _context.next) {
|
|
@@ -40,16 +40,17 @@ function _parseImageNode() {
|
|
|
40
40
|
ndarray = _context.sent;
|
|
41
41
|
shape = (0, _toConsumableArray2.default)(ndarray.shape);
|
|
42
42
|
layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;
|
|
43
|
+
data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;
|
|
43
44
|
return _context.abrupt("return", {
|
|
44
45
|
shape: shape,
|
|
45
|
-
data:
|
|
46
|
+
data: data,
|
|
46
47
|
width: ndarray.shape[0],
|
|
47
48
|
height: ndarray.shape[1],
|
|
48
49
|
components: ndarray.shape[2],
|
|
49
50
|
layers: layers
|
|
50
51
|
});
|
|
51
52
|
|
|
52
|
-
case
|
|
53
|
+
case 10:
|
|
53
54
|
case "end":
|
|
54
55
|
return _context.stop();
|
|
55
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/node/images/parse-image.node.ts"],"names":["parseImageNode","arrayBuffer","mimeType","getPixelsAsync","util","promisify","getPixels","buffer","Buffer","from","ndarray","shape","layers","length","shift","data","width","height","components"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;SAYsBA,c;;;;;8EAAf,iBAA8BC,WAA9B,EAAwDC,QAAxD;AAAA;AAAA;AAAA;AAAA;AAAA;AACL,gCAAOA,QAAP,EAAiB,mDAAjB;AAIMC,YAAAA,cALD,GAKkBC,cAAKC,SAAL,CAAeC,kBAAf,CALlB;AAOCC,YAAAA,MAPD,GAOUN,WAAW,YAAYO,MAAvB,GAAgCP,WAAhC,GAA8CO,MAAM,CAACC,IAAP,CAAYR,WAAZ,CAPxD;AAAA;AAAA,mBASiBE,cAAc,CAACI,MAAD,EAASL,QAAT,CAT/B;;AAAA;AASCQ,YAAAA,OATD;AAWCC,YAAAA,KAXD,oCAWaD,OAAO,CAACC,KAXrB;AAYCC,YAAAA,MAZD,GAYUF,OAAO,CAACC,KAAR,CAAcE,MAAd,KAAyB,CAAzB,GAA6BH,OAAO,CAACC,KAAR,CAAcG,KAAd,EAA7B,GAAqD,CAZ/D;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/node/images/parse-image.node.ts"],"names":["parseImageNode","arrayBuffer","mimeType","getPixelsAsync","util","promisify","getPixels","buffer","Buffer","from","ndarray","shape","layers","length","shift","data","Uint8Array","width","height","components"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;SAYsBA,c;;;;;8EAAf,iBAA8BC,WAA9B,EAAwDC,QAAxD;AAAA;AAAA;AAAA;AAAA;AAAA;AACL,gCAAOA,QAAP,EAAiB,mDAAjB;AAIMC,YAAAA,cALD,GAKkBC,cAAKC,SAAL,CAAeC,kBAAf,CALlB;AAOCC,YAAAA,MAPD,GAOUN,WAAW,YAAYO,MAAvB,GAAgCP,WAAhC,GAA8CO,MAAM,CAACC,IAAP,CAAYR,WAAZ,CAPxD;AAAA;AAAA,mBASiBE,cAAc,CAACI,MAAD,EAASL,QAAT,CAT/B;;AAAA;AASCQ,YAAAA,OATD;AAWCC,YAAAA,KAXD,oCAWaD,OAAO,CAACC,KAXrB;AAYCC,YAAAA,MAZD,GAYUF,OAAO,CAACC,KAAR,CAAcE,MAAd,KAAyB,CAAzB,GAA6BH,OAAO,CAACC,KAAR,CAAcG,KAAd,EAA7B,GAAqD,CAZ/D;AAaCC,YAAAA,IAbD,GAaQL,OAAO,CAACK,IAAR,YAAwBP,MAAxB,GAAiC,IAAIQ,UAAJ,CAAeN,OAAO,CAACK,IAAvB,CAAjC,GAAgEL,OAAO,CAACK,IAbhF;AAAA,6CAgBE;AACLJ,cAAAA,KAAK,EAALA,KADK;AAELI,cAAAA,IAAI,EAAJA,IAFK;AAGLE,cAAAA,KAAK,EAAEP,OAAO,CAACC,KAAR,CAAc,CAAd,CAHF;AAILO,cAAAA,MAAM,EAAER,OAAO,CAACC,KAAR,CAAc,CAAd,CAJH;AAKLQ,cAAAA,UAAU,EAAET,OAAO,CAACC,KAAR,CAAc,CAAd,CALP;AAMLC,cAAAA,MAAM,EAANA;AANK,aAhBF;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","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 const data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;\n\n // extract width/height etc\n return {\n shape,\n 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"}
|
|
@@ -8,9 +8,10 @@ export async function parseImageNode(arrayBuffer, mimeType) {
|
|
|
8
8
|
const ndarray = await getPixelsAsync(buffer, mimeType);
|
|
9
9
|
const shape = [...ndarray.shape];
|
|
10
10
|
const layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;
|
|
11
|
+
const data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;
|
|
11
12
|
return {
|
|
12
13
|
shape,
|
|
13
|
-
data
|
|
14
|
+
data,
|
|
14
15
|
width: ndarray.shape[0],
|
|
15
16
|
height: ndarray.shape[1],
|
|
16
17
|
components: ndarray.shape[2],
|
|
@@ -1 +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;
|
|
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","Uint8Array","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;AACA,QAAMC,IAAI,GAAGL,OAAO,CAACK,IAAR,YAAwBP,MAAxB,GAAiC,IAAIQ,UAAJ,CAAeN,OAAO,CAACK,IAAvB,CAAjC,GAAgEL,OAAO,CAACK,IAArF;AAGA,SAAO;AACLJ,IAAAA,KADK;AAELI,IAAAA,IAFK;AAGLE,IAAAA,KAAK,EAAEP,OAAO,CAACC,KAAR,CAAc,CAAd,CAHF;AAILO,IAAAA,MAAM,EAAER,OAAO,CAACC,KAAR,CAAc,CAAd,CAJH;AAKLQ,IAAAA,UAAU,EAAET,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 const data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;\n\n // extract width/height etc\n return {\n shape,\n 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 +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,
|
|
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,CAwBjG"}
|
|
@@ -16,10 +16,11 @@ async function parseImageNode(arrayBuffer, mimeType) {
|
|
|
16
16
|
const ndarray = await getPixelsAsync(buffer, mimeType);
|
|
17
17
|
const shape = [...ndarray.shape];
|
|
18
18
|
const layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;
|
|
19
|
+
const data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;
|
|
19
20
|
// extract width/height etc
|
|
20
21
|
return {
|
|
21
22
|
shape,
|
|
22
|
-
data
|
|
23
|
+
data,
|
|
23
24
|
width: ndarray.shape[0],
|
|
24
25
|
height: ndarray.shape[1],
|
|
25
26
|
components: ndarray.shape[2],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/polyfills",
|
|
3
|
-
"version": "3.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-alpha.5",
|
|
4
4
|
"description": "Polyfills for TextEncoder/TextDecoder",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"through": "^2.3.8",
|
|
106
106
|
"web-streams-polyfill": "^3.0.0"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "d2df3bead97710c45fd2974cd51ecd7d5f7f5ea4"
|
|
109
109
|
}
|
|
@@ -25,11 +25,12 @@ export async function parseImageNode(arrayBuffer: ArrayBuffer, mimeType: string)
|
|
|
25
25
|
|
|
26
26
|
const shape = [...ndarray.shape];
|
|
27
27
|
const layers = ndarray.shape.length === 4 ? ndarray.shape.shift() : 1;
|
|
28
|
+
const data = ndarray.data instanceof Buffer ? new Uint8Array(ndarray.data) : ndarray.data;
|
|
28
29
|
|
|
29
30
|
// extract width/height etc
|
|
30
31
|
return {
|
|
31
32
|
shape,
|
|
32
|
-
data
|
|
33
|
+
data,
|
|
33
34
|
width: ndarray.shape[0],
|
|
34
35
|
height: ndarray.shape[1],
|
|
35
36
|
components: ndarray.shape[2],
|