[K4] S2: typisiertes Rust-Modell (generiert aus TS-Typen), Document::project(), Kennzahlen rechnen auf dem Dokument; TS-Sammler entfernt
This commit is contained in:
1 parent
8a120329ee
commit
8d4952e5d0
16 files changed
+3700
-119
No files matched your search
@@ -7,7 +7,6 @@
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { createStore } from "./store";
|
||||
import { ProjectDocument } from "../core/document";
|
||||
import type { StoreApi } from "./store";
|
||||
import { createProjectSlice } from "./projectSlice";
|
||||
import type { ProjectSlice } from "./projectSlice";
|
||||
@@ -65,24 +64,3 @@ export const useStore = store.useStore;
|
||||
export const getState = store.getState;
|
||||
export const setState = store.setState;
|
||||
|
||||
// Kern-Dokument ([K4] S1): spiegelt jede Änderung von `project` (Setzen, Laden, Undo/Redo) als Ops
|
||||
// in den Rust-Kern. Ohne geladenen Kern (Start, manche Tests) bleibt es aus und holt sich beim
|
||||
// nächsten Zugriff den vollen Stand.
|
||||
let coreDoc: ProjectDocument | null = null;
|
||||
|
||||
/** Das Rust-Dokument zum aktuellen Projekt (synchron nachgezogen); `null`, solange der Kern fehlt. */
|
||||
export function projectDocument(): ProjectDocument | null {
|
||||
try {
|
||||
const p = store.getState().project;
|
||||
if (!coreDoc) coreDoc = new ProjectDocument(p);
|
||||
else coreDoc.sync(p);
|
||||
return coreDoc;
|
||||
} catch {
|
||||
coreDoc = null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
store.subscribe(() => {
|
||||
void projectDocument();
|
||||
});
|
||||
Reference in new issue
Block a user