revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s

revert style: clean up code with prettier and eslint
This commit is contained in:
remco committed 2026-07-12 21:02:03 +02:00
1 parent 27de078f54
commit e85e4d74ea
378 files changed
+20710 -22428

No files matched your search

+31 -31
View File
@@ -1,19 +1,19 @@
import { cropRgba, decodePng } from "@/lib/services/imager/png-decode";
import { encodePng, parseNitroBundle } from "@/lib/services/swf/nitro-builder";
import { cropRgba, decodePng } from '@/lib/services/imager/png-decode'
import { encodePng, parseNitroBundle } from '@/lib/services/swf/nitro-builder'
interface FurniAsset {
x?: number;
y?: number;
source?: string;
x?: number
y?: number
source?: string
}
interface FurniFrame {
frame: { x: number; y: number; w: number; h: number };
rotated?: boolean;
frame: { x: number; y: number; w: number; h: number }
rotated?: boolean
}
interface FurniNitroJson {
name?: string;
assets?: Record<string, FurniAsset>;
spritesheet?: { frames?: Record<string, FurniFrame> };
name?: string
assets?: Record<string, FurniAsset>
spritesheet?: { frames?: Record<string, FurniFrame> }
}
/**
@@ -23,41 +23,41 @@ interface FurniNitroJson {
* `.nitro` instead of serving a separate `{classname}_icon.png`.
*/
export function extractFurniIconPng(nitro: Buffer): Buffer | null {
let json: FurniNitroJson;
let png: Buffer;
let json: FurniNitroJson
let png: Buffer
try {
const parsed = parseNitroBundle(nitro);
json = parsed.json as FurniNitroJson;
png = parsed.png;
const parsed = parseNitroBundle(nitro)
json = parsed.json as FurniNitroJson
png = parsed.png
} catch {
return null;
return null
}
const name = json.name;
if (!name || !json.assets) return null;
const name = json.name
if (!name || !json.assets) return null
// The icon asset is conventionally `${name}_icon_a`; fall back to any
// `${name}_icon*` the bundle exposes.
const iconKey = json.assets[`${name}_icon_a`]
? `${name}_icon_a`
: Object.keys(json.assets).find((k) => k.startsWith(`${name}_icon`));
if (!iconKey) return null;
: Object.keys(json.assets).find((k) => k.startsWith(`${name}_icon`))
if (!iconKey) return null
const asset = json.assets[iconKey];
const asset = json.assets[iconKey]
// An asset may alias another's pixels via `source`; the frame key is the
// bundle name prefixed onto the asset name. Different converters pack the
// key with or without a trailing `.png`, so try both.
const pixelAsset = asset.source ?? iconKey;
const frames = json.spritesheet?.frames ?? {};
const frame = frames[`${name}_${pixelAsset}`] ?? frames[`${name}_${pixelAsset}.png`];
if (!frame || frame.rotated) return null;
const { x, y, w, h } = frame.frame;
if (w <= 0 || h <= 0) return null;
const pixelAsset = asset.source ?? iconKey
const frames = json.spritesheet?.frames ?? {}
const frame = frames[`${name}_${pixelAsset}`] ?? frames[`${name}_${pixelAsset}.png`]
if (!frame || frame.rotated) return null
const { x, y, w, h } = frame.frame
if (w <= 0 || h <= 0) return null
try {
const sheet = decodePng(png);
const px = cropRgba(sheet.rgba, sheet.width, x, y, w, h);
return encodePng(w, h, px);
const sheet = decodePng(png)
const px = cropRgba(sheet.rgba, sheet.width, x, y, w, h)
return encodePng(w, h, px)
} catch {
return null;
return null
}
}