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
@@ -84,19 +84,16 @@ vi.mock("@/lib/services/furni-import", () => ({
|
||||
IMPORTED_PAGE_CAPTION_SAVE: "imported_furni",
|
||||
}));
|
||||
|
||||
const nitroBuilderMock = vi.hoisted(() => ({
|
||||
createNitroBundle: vi.fn((json: object) =>
|
||||
Buffer.from(`rebuilt:${JSON.stringify(json)}`, "utf-8"),
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/services/swf/nitro-builder", () => ({
|
||||
parseNitroBundle: vi.fn(() => ({
|
||||
json: { xdim: 1, ydim: 1 },
|
||||
texture: Buffer.from("texture-bytes"),
|
||||
textureFileName: "chair.png",
|
||||
})),
|
||||
createNitroBundle: nitroBuilderMock.createNitroBundle,
|
||||
isLosslessWebp: vi.fn(() => false),
|
||||
toWebpLosslessBundle: vi.fn(() =>
|
||||
Promise.resolve(Buffer.from("webp-normalised", "utf-8")),
|
||||
),
|
||||
}));
|
||||
|
||||
import {
|
||||
@@ -146,19 +143,13 @@ describe("uploadSingleFurni live asset mirrors", () => {
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
// The bundle is re-written through the builder so `meta.image` can never
|
||||
// disagree with the texture member, while the member keeps the name it
|
||||
// arrived with (colour variants share a library name).
|
||||
expect(nitroBuilderMock.createNitroBundle).toHaveBeenCalledWith(
|
||||
{ xdim: 1, ydim: 1 },
|
||||
Buffer.from("texture-bytes"),
|
||||
"chair",
|
||||
);
|
||||
// Every upload is normalised to WebP Lossless, whatever the source
|
||||
// bundle carried, so what lands on disk is not the raw upload.
|
||||
await expect(
|
||||
fs.readFile(
|
||||
getRuntimePath(assetTargets.mirrorDirs[0].nitroDir, "chair.nitro"),
|
||||
),
|
||||
).resolves.toEqual(Buffer.from('rebuilt:{"xdim":1,"ydim":1}', "utf-8"));
|
||||
).resolves.toEqual(Buffer.from("webp-normalised", "utf-8"));
|
||||
await expect(
|
||||
fs.readFile(
|
||||
getRuntimePath(assetTargets.mirrorDirs[0].iconDir, "chair_icon.png"),
|
||||
|
||||
Reference in new issue
Block a user