feat: standalone save/load routing + VITE_DOC_SOURCE ydoc mode

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Gergő Törcsvári 2026-06-12 10:16:02 +02:00
commit 8131bf9bac
No known key found for this signature in database
GPG key ID: 8E75F2CDE64E5322
19 changed files with 735 additions and 62 deletions

View file

@ -25,3 +25,21 @@ export function yjsProviderConfig(): ProviderConfig {
params: token ? { token } : undefined,
};
}
/**
* Where a backend project's DOCUMENT content lives (per deployment, not per
* route — /p/<project> URLs behave the same either way):
*
* "api" — file bytes are fetched from the REST backend and a user save is
* uploaded back to it (the Y.Doc, when collab is on, mirrors the file).
* "ydoc" — the collab room is the source of truth: when it holds the document
* it is materialized client-side (docToFile) instead of fetching the
* file, and saves stay in MEMFS (the provider persists the doc). The
* REST backend still serves project metadata + sibling files, and the
* file fetch remains the first-open fallback that seeds the room.
*/
export type DocSource = "api" | "ydoc";
export function docSourceConfig(): DocSource {
return import.meta.env.VITE_DOC_SOURCE === "ydoc" ? "ydoc" : "api";
}