feat(doc): F4.1 the shared document — a project in a Y.Doc and back, the janitor
packages/doc holds the editor's model (ImportedProject) losslessly in a Yjs document (schema 1): ports with their settings, each node's settings as maps per field, programs, files as a flat path map in creation order (text as Y.Text), own Java applications, links, documentation items, archive entries. The core's snapshot and the .fls export go through the project. The janitor repairs dangling links, two links at one port and files without their folder, deterministically and idempotently. All 23 corpus files come back through a Yjs update with the same snapshot and export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// Where the document meets the core and the file format: both through the
|
||||
// project it holds, so that the core never sees Yjs and the document never
|
||||
// the core's snapshot (plan §5.2).
|
||||
|
||||
import type * as Y from 'yjs';
|
||||
import type { TopologySnapshot } from '@mdg-filius/core';
|
||||
import { projectSnapshot, saveProjectArchive } from '@mdg-filius/fls';
|
||||
import { readProject } from './projectDoc.js';
|
||||
|
||||
/** The core's snapshot of the document, to start a simulation with. */
|
||||
export function docSnapshot(doc: Y.Doc): TopologySnapshot {
|
||||
return projectSnapshot(readProject(doc));
|
||||
}
|
||||
|
||||
/** The document as a .fls file, and what the export had to leave out. */
|
||||
export function docArchive(doc: Y.Doc): { readonly archive: Uint8Array; readonly warnings: string[] } {
|
||||
return saveProjectArchive(readProject(doc));
|
||||
}
|
||||
Reference in New Issue
Block a user