feat(nitro): normalise hotel and uploaded bundles to WebP Lossless
Gitea Actions Runner Test / test-job (push) Successful in 0s
CI / check (push) Successful in 31s
CI / tests-integration (push) Successful in 2m17s
CI / tests-unit (push) Failing after 2m29s
CI / tests-ui (push) Successful in 3m17s
CI / preflight (push) Skipped
CI / deploy (push) Skipped
Gitea Actions Runner Test / test-job (push) Successful in 0s
CI / check (push) Successful in 31s
CI / tests-integration (push) Successful in 2m17s
CI / tests-unit (push) Failing after 2m29s
CI / tests-ui (push) Successful in 3m17s
CI / preflight (push) Skipped
CI / deploy (push) Skipped
Importing from a hotel wrote the downloaded .nitro to disk untouched, so official PNG textures stayed PNG and only SWF imports ended up as WebP. Every Studio import should produce the same format regardless of where the bytes came from, so both clone and upload paths now run the bundle through toWebpLosslessBundle. The helper decodes the texture and re-encodes it with the same VP8L options the SWF importer uses, so the artwork round-trips bit-for-bit, and lets createNitroBundle relabel the member and repair the meta.image pointer. A bundle that is already lossless WebP is returned untouched, making the operation idempotent and safe to run on re-import. A colour variant that shares a library keeps the member base name it arrived with. A texture that cannot be decoded keeps its original format with a warning instead of failing the import: the bundle is valid, and losing a furniture item over a codec edge case is worse than a slightly larger texture.
This commit is contained in:
1 parent
306e209e29
commit
b26e2e0de4
5 files changed
+174
-36
No files matched your search
@@ -24,7 +24,10 @@ import {
|
||||
} from "@/lib/services/import/core/curl-fetch";
|
||||
import { downloadFile } from "@/lib/services/import/core/download";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
import { parseNitroBundle } from "@/lib/services/swf/nitro-builder";
|
||||
import {
|
||||
parseNitroBundle,
|
||||
toWebpLosslessBundle,
|
||||
} from "@/lib/services/swf/nitro-builder";
|
||||
import { getRuntimePath } from "@/lib/utils/runtime-path";
|
||||
|
||||
export interface SourceFurni {
|
||||
@@ -331,6 +334,22 @@ export async function cloneSingleFurni(params: {
|
||||
logger.warn("[clone-import] invalid .nitro bundle for", { classname });
|
||||
return { ok: false, classname, warnings, error: "invalid .nitro bundle" };
|
||||
}
|
||||
// Hotels ship PNG textures, so normalise every clone to WebP Lossless and
|
||||
// make it match the SWF importer. A texture that will not re-encode is
|
||||
// kept as it arrived rather than failing the whole import — the bundle is
|
||||
// valid, and losing the furniture over a codec edge case is worse.
|
||||
try {
|
||||
const converted = await toWebpLosslessBundle(
|
||||
await fs.readFile(/*turbopackIgnore: true*/ nitroPath),
|
||||
);
|
||||
await fs.writeFile(/*turbopackIgnore: true*/ nitroPath, converted);
|
||||
} catch (err) {
|
||||
warnings.push("texture kept in its original format");
|
||||
logger.warn("[clone-import] WebP normalisation failed for", {
|
||||
classname,
|
||||
err,
|
||||
});
|
||||
}
|
||||
let iconDl: { ok: boolean; size: number };
|
||||
if (source.iconBaseUrl) {
|
||||
iconDl = await downloadFile(
|
||||
|
||||
Reference in new issue
Block a user