Sprites Storage
Sprites.org takes a local first approach and stores all your data in your browser. This section describes how the data is managed and the storage formats.
Introduction
Sprites.org stores your data in an IndexedDB database named sprites. Each item, whatever its media type, is split across two object stores keyed by the same id: meta holds the metadata a listing reads, and data holds the heavy payload. A third store, refs, is the reference index between items.
| Object store | Key | Holds |
|---|---|---|
meta | id | The metadata a listing needs, including the thumbnail. See Meta. |
data | id | The heavy payload, as { id, data }. Read only when an item is opened. Each media format documents its own shape. |
refs | [from, kind, slot] | The reference index: one row per edge from one item to another. See References. |
References
Some items point at others. A map's tile set holds sprite ids, so a map uses sprites; later a text screen will hold font ids, and a 3D scene texture ids. Each item keeps its own references inside its data; that embedded copy is the source of truth and answers the forward question, what does this item use. The refs store is a separate, derived index that answers the reverse question, who uses this item, which no single document can. It is kept out of meta so a listing that bulk scans meta never pulls it, the same reason data is split from meta.
Each row is one edge. Its identity is the compound key [from, kind, slot], so a save is an idempotent set difference and one edge is addressable with no extra id field. The human description, for example Tileset sprite #3, is derived from kind and slot, not stored.
| Field | Example | Description |
|---|---|---|
from | a map id | The owner, always a real saved item. Part of the key. |
kind | tileset-sprite | The reference type, so one item may hold several kinds. Part of the key. |
slot | 3 | The occurrence within one kind of one owner; for a tile set the tile index. Part of the key. |
to | a sprite id | The target the edge points at. Indexed by by_to. |
Two indexes serve the reverse queries: by_to on the target answers the usage count and the usage list; by_from on the owner lists an owner's edges, which a delete drops with the owner. Each editor keeps its own edges, writing one when it sets a reference and deleting it when it clears one, so an edit that changes no reference writes no edge. The edge table and its reads live in Sprites.Library.Store.Refs: the usage count is Refs.Count with { to: target } and the usage list is Refs.Filter with the same filter.
Cross-Tab Updates
All the browser tabs share the same library. When one saves, the others refresh on their own. The art stays in IndexedDB, and localStorage carries a change counter which all tabs watch via a storage event.
| Key | Type | Description |
|---|---|---|
sprites:rev | Number | A change counter. Every write to the library increments it. |
Media Data Formats
In the data store, the format of the data depends on the particular media type. Each type has a page with its fields and a full example. Only the sprite editor saves today, so the rest are placeholders until their editor lands.
Sprite
A data object of width, height and mode, holding frames of layers of pixels. A pixel is a packed colour or a slot index, or empty for transparent.
Image
A data object of width, height and mode, holding layers of cells, with attribute blocks or characters where the mode needs them. The superset of every machine's picture. Documented ahead of the editor; not saved yet.
Shader
A data object of width, height, shared global code, image parameters and a stack of GLSL layers, each with its own code and parameters. The picture is stored as code and inputs, not pixels; the render driver turns it into an image.
Font
A data object of mode and cell size, holding a glyphs array of pixel grids, one per character. One bit for a machine font, freeform RGBA for a full colour one. No layers. Documented ahead of the editor; not saved yet.
Map
Not saved yet. The format lands with the map editor.
3D
Not saved yet. The format lands with the 3D editor.
Sequencer
A tune of reusable blocks, each a grid of beats by channels, each cell an optional note with the effects its channel allows.
Waveform
Not saved yet. Sampled audio, at the rates and depths each platform allows. Lands with the waveform editor.
UI
Not saved yet. The format lands with the UI editor.