Update heic-convert to 2.1.0

This commit is contained in:
Fedor Indutny 2024-08-05 13:26:40 -07:00 committed by GitHub
parent c4f0db0307
commit 610e441de9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 27 additions and 27 deletions

38
package-lock.json generated
View file

@ -53,7 +53,7 @@
"glob": "7.1.6",
"google-libphonenumber": "3.2.36",
"got": "11.8.5",
"heic-convert": "1.2.4",
"heic-convert": "2.1.0",
"humanize-duration": "3.27.1",
"intl-tel-input": "17.0.13",
"js-yaml": "3.13.1",
@ -22400,32 +22400,32 @@
}
},
"node_modules/heic-convert": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/heic-convert/-/heic-convert-1.2.4.tgz",
"integrity": "sha512-klJHyv+BqbgKiCQvCqI9IKIvweCcohDuDl0Jphearj8+16+v8eff2piVevHqq4dW9TK0r1onTR6PKHP1I4hdbA==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/heic-convert/-/heic-convert-2.1.0.tgz",
"integrity": "sha512-1qDuRvEHifTVAj3pFIgkqGgJIr0M3X7cxEPjEp0oG4mo8GFjq99DpCo8Eg3kg17Cy0MTjxpFdoBHOatj7ZVKtg==",
"dependencies": {
"heic-decode": "^1.1.2",
"jpeg-js": "^0.4.1",
"pngjs": "^3.4.0"
"heic-decode": "^2.0.0",
"jpeg-js": "^0.4.4",
"pngjs": "^6.0.0"
},
"engines": {
"node": ">=8.0.0"
"node": ">=12.0.0"
}
},
"node_modules/heic-convert/node_modules/pngjs": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz",
"integrity": "sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==",
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-6.0.0.tgz",
"integrity": "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg==",
"engines": {
"node": ">=4.0.0"
"node": ">=12.13.0"
}
},
"node_modules/heic-decode": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/heic-decode/-/heic-decode-1.1.2.tgz",
"integrity": "sha512-UF8teegxvzQPdSTcx5frIUhitNDliz/9Pui0JFdIqVRE00spVE33DcCYtZqaLNyd4y5RP/QQWZFIc1YWVKKm2A==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/heic-decode/-/heic-decode-2.0.0.tgz",
"integrity": "sha512-NU+zsiDvdL+EebyTjrEqjkO2XYI7FgLhQzsbmO8dnnYce3S0PBSDm/ZyI4KpcGPXYEdb5W72vp/AQFuc4F8ASg==",
"dependencies": {
"libheif-js": "^1.10.0"
"libheif-js": "^1.17.1"
},
"engines": {
"node": ">=8.0.0"
@ -25880,9 +25880,9 @@
"license": "MIT"
},
"node_modules/libheif-js": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/libheif-js/-/libheif-js-1.15.1.tgz",
"integrity": "sha512-1nIVY1IFYLglxHPuLMqMBpjx4wigEEUVnSj2d3pRzeOjzKetwXlVejHJJgomZwEARu0PZ3HeGOW7ID/hZr13cg==",
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/libheif-js/-/libheif-js-1.18.0.tgz",
"integrity": "sha512-C/MaC0mYd3b2u21Hp76FoR8JDexwRjCZyJhdPMmzjdFnNyBkk6NQXyu9XaTl31GcT/xBR/y7mSPeg62CzyLxkg==",
"engines": {
"node": ">=8.0.0"
}

View file

@ -135,7 +135,7 @@
"glob": "7.1.6",
"google-libphonenumber": "3.2.36",
"got": "11.8.5",
"heic-convert": "1.2.4",
"heic-convert": "2.1.0",
"humanize-duration": "3.27.1",
"intl-tel-input": "17.0.13",
"js-yaml": "3.13.1",

View file

@ -6,5 +6,5 @@ declare module 'heic-convert' {
buffer: Uint8Array;
format: string;
quality: number;
}): Promise<File>;
}): Promise<Buffer>;
}

View file

@ -22,7 +22,7 @@ export async function handleImageAttachment(
const uuid = genUuid();
const bytes = new Uint8Array(await file.arrayBuffer());
const convertedFile = await new Promise<File>((resolve, reject) => {
const convertedData = await new Promise<Uint8Array>((resolve, reject) => {
ipcRenderer.once(`convert-image:${uuid}`, (_, { error, response }) => {
if (response) {
resolve(response);
@ -33,7 +33,7 @@ export async function handleImageAttachment(
ipcRenderer.send('convert-image', uuid, bytes);
});
processedFile = new Blob([convertedFile]);
processedFile = new Blob([convertedData]);
}
const {

View file

@ -13,7 +13,7 @@ export type WrappedWorkerRequest = {
export type WrappedWorkerResponse = {
readonly uuid: string;
readonly error: string | undefined;
readonly response?: File;
readonly response?: Buffer;
};
export function getHeicConverter(): (

View file

@ -15,7 +15,7 @@ if (!parentPort) {
const port = parentPort;
function respond(uuid: string, error: Error | undefined, response?: File) {
function respond(uuid: string, error: Error | undefined, response?: Buffer) {
const wrappedResponse: WrappedWorkerResponse = {
uuid,
error: error?.stack,
@ -26,13 +26,13 @@ function respond(uuid: string, error: Error | undefined, response?: File) {
port.on('message', async ({ uuid, data }: WrappedWorkerRequest) => {
try {
const file = await heicConvert({
const buf = await heicConvert({
buffer: new Uint8Array(data),
format: 'JPEG',
quality: 0.75,
});
respond(uuid, undefined, file);
respond(uuid, undefined, buf);
} catch (error) {
respond(uuid, error, undefined);
}