Files
feuerwerk/src/core/store/TextureStore.ts
T
DeveloperandClaude Opus 5 99c5d2ad78 Uploads carry the name the file came with (#83)
An upload sends its file name next to the raw bytes, and the server keeps
it in a sidecar next to the content-addressed file. Both pickers caption
every tile and row with it, and an asset made there is named after the
file instead of "Texture" / "Font". Last upload of the same content wins.

The API's own set_error_handler ignores error_reporting(), so @-silenced
warnings still throw: a missing sidecar took the whole listing down with a
500. Existence is checked instead of suppressed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 20:32:45 +02:00

39 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export interface UploadedTexture {
/** Content-addressed name in `data/textures/`: `{sha256}.{png|jpg|webp|gif}` (see `isTextureFile`). */
file: string;
/**
* The name the file was uploaded under, '' when the server knows none. A picture may be
* re-encoded on the way, so this can be a `.png` name on a file stored as `.webp`.
*/
name: string;
width: number;
height: number;
bytes: number;
}
/** A file the server holds, whether any project references it or not. */
export interface StoredTexture {
file: string;
name: string;
/** 0 × 0 when the server could not read the header; such a file cannot become an asset. */
width: number;
height: number;
bytes: number;
updatedAt: string;
}
/**
* An upload is raw bytes rather than a multipart form: name, size and format are derived from the
* image itself on the server, so there is nothing else to send.
*/
export interface TextureStore {
/**
* `type` only fills the Content-Type header – the server trusts the bytes, not the label – and
* uploading the same picture twice yields the same file, the hash of its content. `name` is the
* caption kept beside it; uploading the same bytes under a new name renames what pickers show.
*/
upload(bytes: Blob | ArrayBuffer, type: string, name?: string): Promise<UploadedTexture>;
list(): Promise<StoredTexture[]>;
delete(file: string): Promise<void>;
}