@loaders.gl/core 5.0.0-beta.1 → 5.0.0-beta.2
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/README.md +3 -1
- package/dist/cluster-source.cjs +7228 -0
- package/dist/cluster-source.cjs.map +6 -0
- package/dist/cluster-source.d.ts +2 -0
- package/dist/cluster-source.d.ts.map +1 -0
- package/dist/cluster-source.js +2 -0
- package/dist/cluster-source.js.map +1 -0
- package/dist/dist.dev.js +894 -273
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +2677 -0
- package/dist/federated-table-scan-source.cjs.map +6 -0
- package/dist/federated-table-scan-source.d.ts +2 -0
- package/dist/federated-table-scan-source.d.ts.map +1 -0
- package/dist/federated-table-scan-source.js +2 -0
- package/dist/federated-table-scan-source.js.map +1 -0
- package/dist/index.cjs +12 -1045
- package/dist/index.cjs.map +3 -3
- package/dist/lib/init.js +1 -1
- package/dist/loader-utils/index.cjs +43 -1331
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +169 -79
- package/dist/null-worker.js +166 -55
- package/dist/polyfills/images/encode-image-node.d.ts +18 -15
- package/dist/polyfills/images/encode-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/encode-image-node.js +19 -33
- package/dist/polyfills/images/encode-image-node.js.map +1 -1
- package/dist/polyfills/images/image-codecs-node.d.ts +2 -6
- package/dist/polyfills/images/image-codecs-node.d.ts.map +1 -1
- package/dist/polyfills/images/image-codecs-node.js +2 -24
- package/dist/polyfills/images/image-codecs-node.js.map +1 -1
- package/dist/polyfills/images/load-sharp.d.ts +3 -0
- package/dist/polyfills/images/load-sharp.d.ts.map +1 -0
- package/dist/polyfills/images/load-sharp.js +11 -0
- package/dist/polyfills/images/load-sharp.js.map +1 -0
- package/dist/polyfills/images/node-image-bitmap.d.ts +1 -1
- package/dist/polyfills/images/node-image-bitmap.js +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts.map +1 -1
- package/dist/polyfills/images/node-image-formats.js +10 -4
- package/dist/polyfills/images/node-image-formats.js.map +1 -1
- package/dist/polyfills/images/parse-image-node.d.ts +10 -2
- package/dist/polyfills/images/parse-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/parse-image-node.js +20 -32
- package/dist/polyfills/images/parse-image-node.js.map +1 -1
- package/dist/polyfills/index.cjs +73 -149
- package/dist/vector-table-scan-source.cjs +1703 -0
- package/dist/vector-table-scan-source.cjs.map +6 -0
- package/dist/vector-table-scan-source.d.ts +2 -0
- package/dist/vector-table-scan-source.d.ts.map +1 -0
- package/dist/vector-table-scan-source.js +2 -0
- package/dist/vector-table-scan-source.js.map +1 -0
- package/dist/worker-utils/index.cjs +72 -1225
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts +1 -31
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts.map +1 -1
- package/dist/worker-utils/lib/async-queue/async-queue.js +1 -87
- package/dist/worker-utils/lib/async-queue/async-queue.js.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts +1 -8
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.js +1 -157
- package/dist/worker-utils/lib/worker-api/create-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +2 -49
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +1 -345
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts +1 -19
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.js +1 -127
- package/dist/worker-utils/lib/worker-farm/worker-body.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts +1 -57
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.js +1 -112
- package/dist/worker-utils/lib/worker-farm/worker-farm.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts +1 -33
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.js +1 -70
- package/dist/worker-utils/lib/worker-farm/worker-job.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts +1 -93
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.js +1 -242
- package/dist/worker-utils/lib/worker-farm/worker-pool.js.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts +1 -66
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.js +1 -171
- package/dist/worker-utils/lib/worker-farm/worker-thread.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js +234 -144
- package/dist/worker-utils/null-worker-node.js.map +4 -4
- package/dist/worker-utils/null-worker.js +232 -121
- package/dist/worker-utils/null-worker.js.map +4 -4
- package/dist/worker-utils/types.d.ts +1 -99
- package/dist/worker-utils/types.d.ts.map +1 -1
- package/package.json +27 -29
- package/src/cluster-source.ts +1 -0
- package/src/federated-table-scan-source.ts +1 -0
- package/src/polyfills/README.md +2 -2
- package/src/polyfills/images/encode-image-node.ts +44 -37
- package/src/polyfills/images/image-codecs-node.ts +2 -37
- package/src/polyfills/images/load-sharp.ts +13 -0
- package/src/polyfills/images/node-image-bitmap.ts +1 -1
- package/src/polyfills/images/node-image-formats.ts +10 -4
- package/src/polyfills/images/parse-image-node.ts +31 -40
- package/src/vector-table-scan-source.ts +1 -0
- package/src/worker-utils/lib/async-queue/async-queue.ts +1 -96
- package/src/worker-utils/lib/worker-api/create-worker.ts +1 -201
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +8 -464
- package/src/worker-utils/lib/worker-farm/worker-body.ts +1 -141
- package/src/worker-utils/lib/worker-farm/worker-farm.ts +1 -140
- package/src/worker-utils/lib/worker-farm/worker-job.ts +1 -81
- package/src/worker-utils/lib/worker-farm/worker-pool.ts +1 -312
- package/src/worker-utils/lib/worker-farm/worker-thread.ts +1 -202
- package/src/worker-utils/types.ts +14 -144
- package/src/polyfills/images/encode-image.node.ts.disabled +0 -41
- package/src/polyfills/images/parse-image.node.ts.disabled +0 -55
|
@@ -1,36 +1,24 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
1
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import getPixels from 'get-pixels';
|
|
2
|
+
import { loadSharp } from "./load-sharp.js";
|
|
5
3
|
export { NODE_FORMAT_SUPPORT } from "./node-image-formats.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
resolve({
|
|
26
|
-
shape,
|
|
27
|
-
data,
|
|
28
|
-
width: ndarray.shape[0],
|
|
29
|
-
height: ndarray.shape[1],
|
|
30
|
-
components: ndarray.shape[2],
|
|
31
|
-
// TODO - error
|
|
32
|
-
layers: layers ? [layers] : []
|
|
33
|
-
});
|
|
34
|
-
}));
|
|
4
|
+
/** Decodes encoded image bytes into RGBA pixels, detecting the format from the bytes. */
|
|
5
|
+
export async function parseImageNode(arrayBuffer, _mimeType) {
|
|
6
|
+
const sharp = await loadSharp();
|
|
7
|
+
const { data, info: imageInformation } = await sharp(Buffer.from(arrayBuffer), { animated: true })
|
|
8
|
+
.toColourspace('srgb')
|
|
9
|
+
.ensureAlpha()
|
|
10
|
+
.raw()
|
|
11
|
+
.toBuffer({ resolveWithObject: true });
|
|
12
|
+
const width = imageInformation.width;
|
|
13
|
+
const height = imageInformation.pageHeight || imageInformation.height;
|
|
14
|
+
const frameCount = imageInformation.pages || 1;
|
|
15
|
+
return {
|
|
16
|
+
shape: frameCount > 1 ? [frameCount, width, height, 4] : [width, height, 4],
|
|
17
|
+
data: new Uint8Array(data),
|
|
18
|
+
width,
|
|
19
|
+
height,
|
|
20
|
+
components: 4,
|
|
21
|
+
layers: [frameCount]
|
|
22
|
+
};
|
|
35
23
|
}
|
|
36
24
|
//# sourceMappingURL=parse-image-node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-image-node.js","sourceRoot":"","sources":["../../../src/polyfills/images/parse-image-node.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"parse-image-node.js","sourceRoot":"","sources":["../../../src/polyfills/images/parse-image-node.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,OAAO,EAAC,SAAS,EAAC,wBAAqB;AAEvC,OAAO,EAAC,mBAAmB,EAAC,gCAA6B;AAkBzD,yFAAyF;AACzF,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,WAAwB,EACxB,SAAkB;IAElB,MAAM,KAAK,GAAG,MAAM,SAAS,EAAE,CAAC;IAChC,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAC,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;SAC3F,aAAa,CAAC,MAAM,CAAC;SACrB,WAAW,EAAE;SACb,GAAG,EAAE;SACL,QAAQ,CAAC,EAAC,iBAAiB,EAAE,IAAI,EAAC,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC;IACrC,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,IAAI,gBAAgB,CAAC,MAAM,CAAC;IACtE,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,IAAI,CAAC,CAAC;IAC/C,OAAO;QACL,KAAK,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3E,IAAI,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC;QAC1B,KAAK;QACL,MAAM;QACN,UAAU,EAAE,CAAC;QACb,MAAM,EAAE,CAAC,UAAU,CAAC;KACrB,CAAC;AACJ,CAAC"}
|
package/dist/polyfills/index.cjs
CHANGED
|
@@ -5,14 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res, err) => function __init() {
|
|
9
|
-
if (err) throw err[0];
|
|
10
|
-
try {
|
|
11
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
-
} catch (e) {
|
|
13
|
-
throw err = [e], e;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
8
|
var __export = (target, all) => {
|
|
17
9
|
for (var name in all)
|
|
18
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -35,105 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
27
|
));
|
|
36
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
29
|
|
|
38
|
-
// src/polyfills/images/node-image-formats.ts
|
|
39
|
-
var NODE_FORMAT_SUPPORT;
|
|
40
|
-
var init_node_image_formats = __esm({
|
|
41
|
-
"src/polyfills/images/node-image-formats.ts"() {
|
|
42
|
-
"use strict";
|
|
43
|
-
NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// src/polyfills/images/parse-image-node.ts
|
|
48
|
-
var parse_image_node_exports = {};
|
|
49
|
-
__export(parse_image_node_exports, {
|
|
50
|
-
NODE_FORMAT_SUPPORT: () => NODE_FORMAT_SUPPORT,
|
|
51
|
-
parseImageNode: () => parseImageNode
|
|
52
|
-
});
|
|
53
|
-
async function parseImageNode(arrayBuffer, mimeType) {
|
|
54
|
-
if (!mimeType) {
|
|
55
|
-
throw new Error("MIMEType is required to parse image under Node.js");
|
|
56
|
-
}
|
|
57
|
-
const buffer = arrayBuffer instanceof Buffer ? arrayBuffer : Buffer.from(arrayBuffer);
|
|
58
|
-
const ndarray2 = await getPixelsAsync(buffer, mimeType);
|
|
59
|
-
return ndarray2;
|
|
60
|
-
}
|
|
61
|
-
function getPixelsAsync(buffer, mimeType) {
|
|
62
|
-
return new Promise(
|
|
63
|
-
(resolve) => (0, import_get_pixels.default)(buffer, mimeType, (err, ndarray2) => {
|
|
64
|
-
if (err) {
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
const shape = [...ndarray2.shape];
|
|
68
|
-
const layers = ndarray2.shape.length === 4 ? ndarray2.shape.shift() : 1;
|
|
69
|
-
const data = ndarray2.data instanceof Buffer ? new Uint8Array(ndarray2.data) : ndarray2.data;
|
|
70
|
-
resolve({
|
|
71
|
-
shape,
|
|
72
|
-
data,
|
|
73
|
-
width: ndarray2.shape[0],
|
|
74
|
-
height: ndarray2.shape[1],
|
|
75
|
-
components: ndarray2.shape[2],
|
|
76
|
-
// TODO - error
|
|
77
|
-
layers: layers ? [layers] : []
|
|
78
|
-
});
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
var import_get_pixels;
|
|
83
|
-
var init_parse_image_node = __esm({
|
|
84
|
-
"src/polyfills/images/parse-image-node.ts"() {
|
|
85
|
-
"use strict";
|
|
86
|
-
import_get_pixels = __toESM(require("get-pixels"), 1);
|
|
87
|
-
init_node_image_formats();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// src/polyfills/buffer/to-array-buffer.node.ts
|
|
92
|
-
function bufferToArrayBuffer(buffer) {
|
|
93
|
-
if (Buffer.isBuffer(buffer)) {
|
|
94
|
-
const typedArray = new Uint8Array(buffer);
|
|
95
|
-
return typedArray.buffer;
|
|
96
|
-
}
|
|
97
|
-
return buffer;
|
|
98
|
-
}
|
|
99
|
-
var init_to_array_buffer_node = __esm({
|
|
100
|
-
"src/polyfills/buffer/to-array-buffer.node.ts"() {
|
|
101
|
-
"use strict";
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// src/polyfills/images/encode-image-node.ts
|
|
106
|
-
var encode_image_node_exports = {};
|
|
107
|
-
__export(encode_image_node_exports, {
|
|
108
|
-
encodeImageNode: () => encodeImageNode,
|
|
109
|
-
encodeImageToStreamNode: () => encodeImageToStreamNode
|
|
110
|
-
});
|
|
111
|
-
function encodeImageToStreamNode(image, options) {
|
|
112
|
-
const type = options.type ? options.type.replace("image/", "") : "jpeg";
|
|
113
|
-
const pixels = (0, import_ndarray.default)(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);
|
|
114
|
-
return (0, import_save_pixels.default)(pixels, type, options);
|
|
115
|
-
}
|
|
116
|
-
function encodeImageNode(image, options) {
|
|
117
|
-
const imageStream = encodeImageToStreamNode(image, options);
|
|
118
|
-
return new Promise((resolve) => {
|
|
119
|
-
const buffers = [];
|
|
120
|
-
imageStream.on("data", (buffer) => buffers.push(buffer));
|
|
121
|
-
imageStream.on("end", () => {
|
|
122
|
-
const buffer = Buffer.concat(buffers);
|
|
123
|
-
resolve(bufferToArrayBuffer(buffer));
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
var import_save_pixels, import_ndarray;
|
|
128
|
-
var init_encode_image_node = __esm({
|
|
129
|
-
"src/polyfills/images/encode-image-node.ts"() {
|
|
130
|
-
"use strict";
|
|
131
|
-
import_save_pixels = __toESM(require("save-pixels"), 1);
|
|
132
|
-
import_ndarray = __toESM(require("ndarray"), 1);
|
|
133
|
-
init_to_array_buffer_node();
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
30
|
// src/polyfills/index.ts
|
|
138
31
|
var index_exports = {};
|
|
139
32
|
__export(index_exports, {
|
|
@@ -1675,31 +1568,84 @@ function btoa(base64) {
|
|
|
1675
1568
|
return Buffer.from(base64, "base64").toString("ascii");
|
|
1676
1569
|
}
|
|
1677
1570
|
|
|
1678
|
-
// src/polyfills/images/
|
|
1679
|
-
|
|
1680
|
-
async function parseImageNode2(...parameters) {
|
|
1681
|
-
let decoder;
|
|
1571
|
+
// src/polyfills/images/load-sharp.ts
|
|
1572
|
+
async function loadSharp() {
|
|
1682
1573
|
try {
|
|
1683
|
-
|
|
1574
|
+
return (await import("sharp")).default;
|
|
1684
1575
|
} catch (error) {
|
|
1685
1576
|
throw new Error(
|
|
1686
|
-
"Node image decoding
|
|
1577
|
+
"Node image decoding and encoding require the optional 'sharp' package. Install it with 'npm install sharp'.",
|
|
1687
1578
|
{ cause: error }
|
|
1688
1579
|
);
|
|
1689
1580
|
}
|
|
1690
|
-
return decoder.parseImageNode(...parameters);
|
|
1691
1581
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1582
|
+
|
|
1583
|
+
// src/polyfills/images/node-image-formats.ts
|
|
1584
|
+
var NODE_FORMAT_SUPPORT = [
|
|
1585
|
+
"image/png",
|
|
1586
|
+
"image/jpeg",
|
|
1587
|
+
"image/gif",
|
|
1588
|
+
"image/webp",
|
|
1589
|
+
"image/avif",
|
|
1590
|
+
"image/tiff",
|
|
1591
|
+
"image/svg+xml"
|
|
1592
|
+
];
|
|
1593
|
+
|
|
1594
|
+
// src/polyfills/images/parse-image-node.ts
|
|
1595
|
+
async function parseImageNode(arrayBuffer, _mimeType) {
|
|
1596
|
+
const sharp = await loadSharp();
|
|
1597
|
+
const { data, info: imageInformation } = await sharp(Buffer.from(arrayBuffer), { animated: true }).toColourspace("srgb").ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
1598
|
+
const width = imageInformation.width;
|
|
1599
|
+
const height = imageInformation.pageHeight || imageInformation.height;
|
|
1600
|
+
const frameCount = imageInformation.pages || 1;
|
|
1601
|
+
return {
|
|
1602
|
+
shape: frameCount > 1 ? [frameCount, width, height, 4] : [width, height, 4],
|
|
1603
|
+
data: new Uint8Array(data),
|
|
1604
|
+
width,
|
|
1605
|
+
height,
|
|
1606
|
+
components: 4,
|
|
1607
|
+
layers: [frameCount]
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
// src/polyfills/utils/buffer-utils.ts
|
|
1612
|
+
function toArrayBuffer(data) {
|
|
1613
|
+
if (data instanceof ArrayBuffer) {
|
|
1614
|
+
return data;
|
|
1701
1615
|
}
|
|
1702
|
-
|
|
1616
|
+
if (ArrayBuffer.isView(data)) {
|
|
1617
|
+
return ensureArrayBuffer(data);
|
|
1618
|
+
}
|
|
1619
|
+
return ensureArrayBuffer(data);
|
|
1620
|
+
}
|
|
1621
|
+
function ensureArrayBuffer(data) {
|
|
1622
|
+
if (data instanceof ArrayBuffer) {
|
|
1623
|
+
return data;
|
|
1624
|
+
}
|
|
1625
|
+
if (ArrayBuffer.isView(data)) {
|
|
1626
|
+
const { buffer, byteOffset, byteLength } = data;
|
|
1627
|
+
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
1628
|
+
return buffer;
|
|
1629
|
+
}
|
|
1630
|
+
return copyArrayBufferRange(buffer, byteOffset, byteLength);
|
|
1631
|
+
}
|
|
1632
|
+
return copyArrayBufferRange(data);
|
|
1633
|
+
}
|
|
1634
|
+
function copyArrayBufferRange(buffer, offset = 0, length = buffer.byteLength - offset) {
|
|
1635
|
+
const copy = new Uint8Array(length);
|
|
1636
|
+
copy.set(new Uint8Array(buffer, offset, length));
|
|
1637
|
+
return copy.buffer;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// src/polyfills/images/encode-image-node.ts
|
|
1641
|
+
async function encodeImageNode(image, options = {}) {
|
|
1642
|
+
const sharp = await loadSharp();
|
|
1643
|
+
const requestedFormat = (options.type || "jpeg").toLowerCase().replace(/^image\//, "");
|
|
1644
|
+
const format = requestedFormat === "jpg" ? "jpeg" : requestedFormat;
|
|
1645
|
+
const encodedImage = await sharp(Buffer.from(image.data), {
|
|
1646
|
+
raw: { width: image.width, height: image.height, channels: 4 }
|
|
1647
|
+
}).toFormat(format).toBuffer();
|
|
1648
|
+
return toArrayBuffer(encodedImage);
|
|
1703
1649
|
}
|
|
1704
1650
|
|
|
1705
1651
|
// src/polyfills/images/node-image-bitmap.ts
|
|
@@ -1892,28 +1838,6 @@ var import_stream = require("stream");
|
|
|
1892
1838
|
|
|
1893
1839
|
// src/polyfills/filesystems/stream-utils.node.ts
|
|
1894
1840
|
var import_zlib = __toESM(require("zlib"), 1);
|
|
1895
|
-
|
|
1896
|
-
// src/polyfills/utils/buffer-utils.ts
|
|
1897
|
-
function ensureArrayBuffer(data) {
|
|
1898
|
-
if (data instanceof ArrayBuffer) {
|
|
1899
|
-
return data;
|
|
1900
|
-
}
|
|
1901
|
-
if (ArrayBuffer.isView(data)) {
|
|
1902
|
-
const { buffer, byteOffset, byteLength } = data;
|
|
1903
|
-
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
1904
|
-
return buffer;
|
|
1905
|
-
}
|
|
1906
|
-
return copyArrayBufferRange(buffer, byteOffset, byteLength);
|
|
1907
|
-
}
|
|
1908
|
-
return copyArrayBufferRange(data);
|
|
1909
|
-
}
|
|
1910
|
-
function copyArrayBufferRange(buffer, offset = 0, length = buffer.byteLength - offset) {
|
|
1911
|
-
const copy = new Uint8Array(length);
|
|
1912
|
-
copy.set(new Uint8Array(buffer, offset, length));
|
|
1913
|
-
return copy.buffer;
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
// src/polyfills/filesystems/stream-utils.node.ts
|
|
1917
1841
|
function decompressReadStream(readStream, headers) {
|
|
1918
1842
|
switch (headers?.get("content-encoding")) {
|
|
1919
1843
|
case "br":
|
|
@@ -2265,8 +2189,8 @@ if (!("atob" in globalThis) && atob) {
|
|
|
2265
2189
|
if (!("btoa" in globalThis) && btoa) {
|
|
2266
2190
|
globalThis["btoa"] = btoa;
|
|
2267
2191
|
}
|
|
2268
|
-
globalThis.loaders.encodeImageNode =
|
|
2269
|
-
globalThis.loaders.parseImageNode =
|
|
2192
|
+
globalThis.loaders.encodeImageNode = encodeImageNode;
|
|
2193
|
+
globalThis.loaders.parseImageNode = parseImageNode;
|
|
2270
2194
|
globalThis.loaders.imageFormatsNode = NODE_FORMAT_SUPPORT;
|
|
2271
2195
|
globalThis.loaders.createImageBitmapNode = createImageBitmapNode;
|
|
2272
2196
|
globalThis.loaders.getImageBitmapDataNode = getImageBitmapDataNode;
|
|
@@ -2277,7 +2201,7 @@ if (!globalThis.ImageBitmap) {
|
|
|
2277
2201
|
if (!("getImageBitmapData" in globalThis)) {
|
|
2278
2202
|
globalThis.getImageBitmapData = getImageBitmapDataNode;
|
|
2279
2203
|
}
|
|
2280
|
-
globalThis._parseImageNode =
|
|
2204
|
+
globalThis._parseImageNode = parseImageNode;
|
|
2281
2205
|
globalThis._imageFormatsNode = NODE_FORMAT_SUPPORT;
|
|
2282
2206
|
globalThis.loaders.readFileAsArrayBuffer = readFileAsArrayBuffer;
|
|
2283
2207
|
globalThis.loaders.readFileAsText = readFileAsText;
|