Add map import and export with durable refresh progress

This commit is contained in:
2026-10-07 19:44:49 +05:00
parent dac8650ac1
commit 1307436e65
37 changed files with 2207 additions and 85 deletions

View File

@@ -49,6 +49,8 @@ export const datasetSchema = z
),
dimension: z.literal("minecraft:overworld"),
source: z.enum(["plugin", "fabric"]),
// Portable map imports contain rendered images rather than capture inputs.
mediaFormat: z.literal("webp").optional(),
name: z.string().min(3).max(80),
description: z.string().max(2000).default(""),
serverName: z.string().min(2).max(80),
@@ -88,16 +90,23 @@ export const datasetSchema = z
});
const paths = new Set(d.assets.map((asset) => asset.path));
const requiredPaths =
d.source === "plugin"
? ["terrain.json.gz"]
: [
"map.png",
...(d.availableViewpoints ?? d.viewpoints)
.filter((point) => !point.assetRoot)
.flatMap((point) =>
faces.map((face) => `${point.id}/${face}.png`),
),
];
d.mediaFormat === "webp"
? [
"map.webp",
...d.viewpoints.flatMap((point) =>
faces.map((face) => `${point.id}/${face}.webp`),
),
]
: d.source === "plugin"
? ["terrain.json.gz"]
: [
"map.png",
...(d.availableViewpoints ?? d.viewpoints)
.filter((point) => !point.assetRoot)
.flatMap((point) =>
faces.map((face) => `${point.id}/${face}.png`),
),
];
for (const path of requiredPaths) {
if (!paths.has(path))
ctx.addIssue({
@@ -135,6 +144,8 @@ export const datasetSchema = z
// Media provenance is assigned by the server after the owner accepts a contribution.
export function parseUploadManifest(value: unknown) {
const manifest = datasetSchema.parse(value);
if (manifest.mediaFormat)
throw new Error("Use map import for rendered archives");
manifest.serverAddress =
normalizeServerAddress(manifest.serverAddress) ?? undefined;
for (const p of [