mirror of https://github.com/VERT-sh/VERT.git
feat: limit concurrency
This commit is contained in:
parent
c00dac9207
commit
fb42680b40
7
bun.lock
7
bun.lock
|
@ -14,6 +14,7 @@
|
|||
"clsx": "^2.1.1",
|
||||
"lucide-svelte": "^0.475.0",
|
||||
"music-metadata": "^11.0.0",
|
||||
"p-queue": "^8.1.0",
|
||||
"vite-plugin-static-copy": "^2.2.0",
|
||||
"wasm-vips": "^0.0.11",
|
||||
},
|
||||
|
@ -400,6 +401,8 @@
|
|||
|
||||
"esutils": ["esutils@2.0.3", "", {}, "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g=="],
|
||||
|
||||
"eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="],
|
||||
|
||||
"fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
|
||||
|
||||
"fast-glob": ["fast-glob@3.3.3", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.8" } }, "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg=="],
|
||||
|
@ -568,6 +571,10 @@
|
|||
|
||||
"p-map": ["p-map@7.0.3", "", {}, "sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA=="],
|
||||
|
||||
"p-queue": ["p-queue@8.1.0", "", { "dependencies": { "eventemitter3": "^5.0.1", "p-timeout": "^6.1.2" } }, "sha512-mxLDbbGIBEXTJL0zEx8JIylaj3xQ7Z/7eEVjcF9fJX4DBiH9oqe+oahYnlKKxm0Ci9TlWTyhSHgygxMxjIB2jw=="],
|
||||
|
||||
"p-timeout": ["p-timeout@6.1.4", "", {}, "sha512-MyIV3ZA/PmyBN/ud8vV9XzwTrNtR4jFrObymZYnZqMmW0zA8Z17vnT0rBgFE/TlohB+YCHqXMgZzb3Csp49vqg=="],
|
||||
|
||||
"package-json-from-dist": ["package-json-from-dist@1.0.1", "", {}, "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw=="],
|
||||
|
||||
"parent-module": ["parent-module@1.0.1", "", { "dependencies": { "callsites": "^3.0.0" } }, "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g=="],
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
"clsx": "^2.1.1",
|
||||
"lucide-svelte": "^0.475.0",
|
||||
"music-metadata": "^11.0.0",
|
||||
"p-queue": "^8.1.0",
|
||||
"vite-plugin-static-copy": "^2.2.0",
|
||||
"wasm-vips": "^0.0.11"
|
||||
}
|
||||
|
|
|
@ -58,10 +58,9 @@
|
|||
<p class="whitespace-nowrap text-xl">Set all to</p>
|
||||
{#if files.requiredConverters.length === 1}
|
||||
<!-- cannot convert to svg or heif -->
|
||||
{@const supported =
|
||||
files.files[0]?.converter?.supportedFormats?.filter(
|
||||
(format) => format !== ".svg" && format !== ".heif",
|
||||
)}
|
||||
{@const supported = files.files[0]?.converters
|
||||
.flatMap((c) => c.supportedFormats)
|
||||
?.filter((format) => format !== ".svg" && format !== ".heif")}
|
||||
<Dropdown
|
||||
onselect={(r) =>
|
||||
files.files.forEach((f) => {
|
||||
|
|
|
@ -33,10 +33,7 @@ export class VipsConverter extends Converter {
|
|||
".tif",
|
||||
".tiff",
|
||||
".jfif",
|
||||
".heif", // HEIF files that are encoded like HEIC files (and HEIC files in general) aren't supported due to https://github.com/kleisauke/wasm-vips/issues/3
|
||||
".avif",
|
||||
".jxl",
|
||||
".svg",
|
||||
];
|
||||
|
||||
public readonly reportsProgress = false;
|
||||
|
|
|
@ -4,6 +4,7 @@ import { VertFile } from "$lib/types";
|
|||
import { parseBlob, selectCover } from "music-metadata";
|
||||
import { writable } from "svelte/store";
|
||||
import { addDialog } from "./DialogProvider";
|
||||
import PQueue from "p-queue";
|
||||
|
||||
class Files {
|
||||
public files = $state<VertFile[]>([]);
|
||||
|
@ -195,7 +196,10 @@ class Files {
|
|||
}
|
||||
|
||||
public async convertAll() {
|
||||
await Promise.all(this.files.map((f) => f.convert()));
|
||||
const promiseFns = this.files.map((f) => () => f.convert());
|
||||
const coreCount = navigator.hardwareConcurrency || 4;
|
||||
const queue = new PQueue({ concurrency: coreCount });
|
||||
await Promise.all(promiseFns.map((fn) => queue.add(fn)));
|
||||
}
|
||||
|
||||
public async downloadAll() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Vips from "wasm-vips";
|
||||
|
||||
const vipsPromise = Vips({
|
||||
dynamicLibraries: ["vips-jxl.wasm", "vips-heif.wasm", "vips-resvg.wasm"],
|
||||
dynamicLibraries: [],
|
||||
});
|
||||
|
||||
vipsPromise
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
{@const isVideo = converters
|
||||
.find((c) => c.name === "vertd")
|
||||
?.supportedFormats.includes(file.from)}
|
||||
{@const isImage = converters
|
||||
.find((c) => c.name === "libvips")
|
||||
?.supportedFormats.includes(file.from)}
|
||||
<Panel class="p-5 flex flex-col min-w-0 gap-4 relative">
|
||||
<div class="flex-shrink-0 h-8 w-full flex items-center gap-2">
|
||||
{#if !converters.length}
|
||||
|
@ -146,7 +149,7 @@
|
|||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
{:else if isVideo && !$vertdLoaded}
|
||||
{:else if isVideo && !isAudio && !isImage && !$vertdLoaded}
|
||||
<div
|
||||
class="h-full flex flex-col text-center justify-center text-failure"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue