Written for the Workspace app team (and any other consumer). The
format is frozen at formatVersion: 1 (tag format-v1,
DECISIONS D26): the bytes are stable, additive-only from here. The
TypeScript API below is what the reference library ships today; it
may still evolve ahead of a 1.0 package release, but every contract
it implements is spec-frozen.
-
@workspace.sh/table-core— the format library. Pure TS, no UI. The barrel is browser/RN-safe; filesystem IO lives behind subpaths so bundlers never pullnode:fs:import { validate, applyView, searchRows, newId } from "@workspace.sh/table-core"; import { parseTable } from "@workspace.sh/table-core/parser"; // Node only import { writeTable } from "@workspace.sh/table-core/writer"; // Node only
-
@workspace.sh/table-ui(optional) — react-strict-dom view components (TableView, BoardView, GalleryView, ListView, CalendarView, SchemaFieldEditor, BodyEditor) rendering on web + RN + RN-macOS. Consume it if you want the reference views; rendering your own on top of core is equally supported. -
@workspace.sh/table-gtk(optional, Linux) — the same views for GTK4 and libadwaita, through GTKX, with the same names and props (ViewProps). An app wires one set of callbacks and hands them to either library. It needs GTKX and the app's generated bindings, so it is typechecked and tested inside a GTK app (apps/linux), and a GTK app bundles it from source. -
@workspace.sh/table-ui/shared— what every renderer shows, with no renderer in it:describeCell(what a value shows as),columnWidths,groupedRows,totalFor, the pill palette, cell checks, and theViewPropstype. Rendering your own views on another toolkit? Build on this, and a table shows the same there. -
@workspace.sh/table-app— what an app around the views does: tables held bybundle/tablekey,showView(the rows a view shows, after a viewer's own sort and search, and a Sheet view's saved grid), a viewer's arrangements, display settings, saved state over any key-value store, and single-file.tables.@workspace.sh/table-app/nodeopens.tablefolders from disk (loadLibrary).
To show a .table inside something else (a Markdown file that links to
it), an app places one drop-in and gives it the link:
embedIn(library, address, fileName)intable-appsays what a link's address names in a file just read: which table and view, or why it can't be drawn, in words for the reader. Every drop-in asks it, so a link draws the same thing and fails with the same words everywhere. What it answers carriessize: therows=orcards=the address asks to be shown at once (SPEC section 10), for the drop-in to size itself by. Withrest=morein it the drop-in draws only that many:embedCountsays which count the layout shows,embedLeftOuthow many it leaves out, andembedMoreTextwhat the line that shows them says. Withwidth=full(size.width) a table's columns share the whole width rather than stopping at their natural widths: the drop-in passesfillWidthto the view.useEmbeddedTable(shown, files)intable-app/reactholds what it names over the app reducer: the views' props and callbacks, with edits written throughfiles(how the platform writes a bundle and appends to a history) and whatever is still to write written when it goes.readEmbed({ address, baseDir, within })andembedFilesintable-app/nodeare those two over node:fs: the path resolved against the document's folder and kept insidewithin.TableEmbedin@workspace.sh/table-gtk/embedis the GTK drop-in over them (see that package's README).TableEmbedin@workspace.sh/table-app/embed-viewis the drop-in fortable-ui's views (web, iOS, Android, macOS): the same hook with those views and the platform's own files. It holds a table of 50,000 rows or more in memory, not through the index (#515).
Resolution is verified on all three loaders: Node ESM (default
condition → dist/, explicit .js specifiers), Vite (source
condition → src/*.ts; production build green), Metro
(react-native condition → src/*.ts; the mobile and macOS demo
apps are the living proof).
const table = await parseTable("path/to/projects.table");
// 1. Parse-level diagnostics — the reader is skip-and-collect
// (SPEC section 3): malformed lines and id-less rows are skipped
// and reported here, never thrown. Missing/malformed schema.json
// is the one fatal case.
if (table.diagnostics?.length) surfaceToUser(table.diagnostics);
// 2. Constraint validation — types, enums, ranges, primary keys.
const errors = validate(table.schema, table.rows);
// 3. Views — filter/sort/group/order exactly as saved in views.json.
const view = table.views[0];
const rows = applyView(table, view);
// 4. Search — string fields + long-form bodies.
const hits = searchRows(table.rows, query, { schema: table.schema, bodies: table.bodies });On a platform without node:fs (React Native, a browser with a file-system
API), the same reader and writer run over a TableFs you supply: seven
async file operations (readText, writeText, rename, mkdir, list,
remove; see @workspace.sh/table-core/io). readBundle(fs, dir),
readTable, writeBundleTo and writeTableTo are what parseBundle and
writeBundle run over node:fs. Your rename must replace an existing file
atomically, as POSIX rename(2) does, or the writer loses its per-file
guarantee. memoryFs() is one held in memory, for tests. table-app's
openLibrary(fs, paths) and writeLibraryBundle do the same for an app's
bundle/table map.
In a browser (no filesystem), skip parseTable and build the
ParsedTable yourself from fetched/bundled file contents — the demo
web app does exactly this (apps/web/src/loadFixture.ts).
writeTable(dir, { schema, rows, views, meta, bodies }) implements
the writer-atomicity contract (SPEC section 1): stage to *.tmp →
atomic per-file rename → deletions last. A crashed write leaves the
previous table intact; readers never observe a torn file. Do not
hand-roll writes that bypass this unless you replicate the contract.
To show values, formatValue(field, value, { locale, dateFormat }) renders
a field's format with Intl. locale and dateFormat are the viewer's
own preferences and are never written to the table. dateFormat applies
only to date fields with no format of their own; a field's own format
always wins. In the UI package, DisplaySettingsProvider hands them to every
cell.
To start a table from nothing, newTable(title, path) returns one with a
title text field, one table view and no rows, its manifest stamped.
Rules that matter when constructing rows:
- Ids: any non-empty string unique in the table is valid; mint
with
newId()(25-char lowercase base36 — case-safe because ids becomebodies/{title}--{id}.mdfilenames; SPEC section 3). Never reuse or rename an id — relations and addresses point at it. - Schema evolution is append-only: add fields, mark old ones
deprecated: true; never remove or rename (SPEC section 2). Bumpschema-versionon structural change — and treat it as advisory outside single-writer contexts (DECISIONS D22). - Canonical write order (SPEC section 3): keep row insertion order stable and key order consistent so identical state produces identical bytes.
fromCSV(csv, schema?) (RFC 4180, schema-coerced or inferred, ids
minted when absent) and toCSV(table) — call
csvExportWarnings(table) first and show the result: relations,
attachments, and bodies do not survive a CSV export, and the loss
must be visible, not silent.
A .table is a folder or a single file, the same document either way
(SPEC section 13, D49, D50), told apart by what's on disk. Portable:
it works on Node, in browsers, and in React Native (Hermes), so a
.table sent as one file opens on every Workspace platform:
import { readTableDocument, writeTableFileTo, readTableArchive, writeTableArchive } from "@workspace.sh/table-core";
const { form, bundle } = await readTableDocument(fs, path); // "folder" or "file", by what's on disk
await writeTableFileTo(fs, path, bundle); // a single file, written beside it and renamed over it
const read = await readTableArchive(bytes); // a single file's bytes, as a ParsedBundle
const out = await writeTableArchive("projects", read); // and back: canonical <name>.table/ layout, deterministicTo edit a single file in place, @workspace.sh/table-app's
unpackTableFile and packTableFile keep it as a working folder in
the app's own storage and pack it back after each write.
Callers supply bytes (await readFile(p) on Node, File/fetch on
web, the document picker on RN). Reading is fully in-memory (no
extraction, no zip-slip exposure); hostile entry names and
decompression bombs are rejected. Layout and security rules: SPEC
section 13.
Per-user state (open view, scroll position, column widths tweaked
locally, pinned views), ACLs, and computed view results. views.json
is shared/team state only (DECISIONS D4). Access control is a
consumer/sync concern (docs/PERMISSIONS.md — design stage); the
format itself has no private layer (docs/PRIOR-ART.md).
See "Platform realities" in docs/ARCHITECTURE.md: macOS document packages (declare the UTI to get one-item Finder behaviour), iOS file-provider caveats, Android SAF tree URIs, zip-for-transport, and case-insensitive checkout notes.
The P2P layer (Hypercore/Autobase, docs/STORAGE-AND-SYNC.md, specified in the
Workspace Protocol)
materialises the same files this guide reads and writes. Code
written against parseTable/writeTable and the contracts above
will not change when sync lands — files are the interface, by
design (DECISIONS D17). Do not couple consumer code to a transport.
diffBundle(before, after) in @workspace.sh/table-core says what changed
between two parsed bundles, as plain values that can be stored or sent.
applyChanges(bundle, changes) applies them in the order given, and the same
bundle with the same ordered changes always writes the same files. Neither
knows about git, a file sync service or a peer-to-peer log: the transport,
and the order, are the consumer's.
- Edits to different cells or rows all survive. Two edits to one cell: the later in the given order stands.
- A row deleted on one side and edited on the other is kept, with the edit.
modified_atisn't a change, and computed values aren't carried.- A table whose rows aren't in memory (read later, or held in the index) is
refused with
RowsNotLoadedError, never treated as empty.
The format gains no file and no dependency from this.
To claim .table/ support, an implementation needs only:
- Parse
schema.json(fatal if missing/malformed). - Iterate the files in
rows/in name order, line by line, skip-and-collect on bad lines (SPEC section 3, "Reader error contract"); aformatVersion1 table has onerows.ndjsoninstead. - Tolerate every optional file being absent; ignore unknown files.
Everything else — views, bodies, attachments, the SQLite cache — is progressive enhancement. A Rust reference core is tracked in issue #19.