completely move off sharp, use monaco for the editor now and use tabulator for tables (much easier and better performance).
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { ServerWebSocket } from "bun";
|
||||
import { decodeMessage, encodeMessage, type WireMessage, type PluginManifest } from "./protocol";
|
||||
import { logger } from "./logger";
|
||||
import { fileURLToPath } from "url";
|
||||
import { fileURLToPath, pathToFileURL } from "url";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
import { existsSync } from "node:fs";
|
||||
@@ -202,6 +202,14 @@ const DEPLOY_ROOT = path.join(DATA_DIR, "deploy");
|
||||
const WINRE_ROOT = path.join(DATA_DIR, "winre");
|
||||
const FILE_SHARE_ROOT = path.join(DATA_DIR, "file-share");
|
||||
|
||||
function resolvePluginWorkerHostUrl(): string {
|
||||
const builtWorker = path.join(RUNTIME_ROOT, "dist", "server", "plugin-runtime", "worker-host.js");
|
||||
if (existsSync(builtWorker)) {
|
||||
return pathToFileURL(builtWorker).href;
|
||||
}
|
||||
return new URL("./server/plugin-runtime/worker-host.ts", import.meta.url).href;
|
||||
}
|
||||
|
||||
const TLS_CERT_PATH = config.tls.certPath;
|
||||
const TLS_KEY_PATH = config.tls.keyPath;
|
||||
const TLS_CA_PATH = config.tls.caPath;
|
||||
@@ -240,7 +248,7 @@ const loadPluginState = async () => {
|
||||
|
||||
const pluginRuntime = createPluginRuntime({
|
||||
pluginRoot: PLUGIN_ROOT,
|
||||
workerHostUrl: new URL("./server/plugin-runtime/worker-host.ts", import.meta.url).href,
|
||||
workerHostUrl: resolvePluginWorkerHostUrl(),
|
||||
setLastError: (pluginId, error) => {
|
||||
pluginState.lastError[pluginId] = error;
|
||||
void savePluginState();
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
let _sharp: any = null;
|
||||
let _sharpLoadAttempted = false;
|
||||
|
||||
async function getSharp(): Promise<any> {
|
||||
if (_sharp) return _sharp;
|
||||
if (_sharpLoadAttempted) throw new Error("sharp module unavailable");
|
||||
_sharpLoadAttempted = true;
|
||||
try {
|
||||
_sharp = (await import("sharp")).default as any;
|
||||
return _sharp!;
|
||||
} catch (err) {
|
||||
console.error("[thumbnails] Failed to load sharp module. Thumbnails will be unavailable.", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
const THUMBNAIL_WIDTH = Math.max(64, Number(process.env.OVERLORD_THUMBNAIL_WIDTH || 1920));
|
||||
const THUMBNAIL_HEIGHT = Math.max(48, Number(process.env.OVERLORD_THUMBNAIL_HEIGHT || 1080));
|
||||
const THUMBNAIL_QUALITY = Math.min(95, Math.max(40, Number(process.env.OVERLORD_THUMBNAIL_QUALITY || 88)));
|
||||
@@ -133,18 +117,16 @@ async function buildThumbnailBytes(bytes: Uint8Array, format: string): Promise<U
|
||||
return null;
|
||||
}
|
||||
|
||||
const sharp = await getSharp();
|
||||
const output = await sharp(Buffer.from(bytes), { failOn: "none" })
|
||||
.rotate()
|
||||
.resize({
|
||||
width: THUMBNAIL_WIDTH,
|
||||
height: THUMBNAIL_HEIGHT,
|
||||
const output = await new Bun.Image(bytes, {
|
||||
autoOrient: true,
|
||||
maxPixels: THUMBNAIL_WIDTH * THUMBNAIL_HEIGHT * 16,
|
||||
})
|
||||
.resize(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, {
|
||||
fit: "inside",
|
||||
withoutEnlargement: true,
|
||||
fastShrinkOnLoad: true,
|
||||
})
|
||||
.webp({ quality: THUMBNAIL_QUALITY })
|
||||
.toBuffer();
|
||||
.bytes();
|
||||
|
||||
return new Uint8Array(output);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user