Rust bcf.rs in fileio (zip + quick-xml, MIT): Themen, Kommentare, Viewpoints mit Kamera, Auswahl, Sichtbarkeit, Schnittebenen, Snapshot. TS-Fassade io/bcf.ts, Zuordnung io/bcfMatch.ts (gleiche GlobalId-Ableitung wie der IFC-Export), Dock-Panel und Menüpunkt, dossier-cli bcf-info. Kamera setzen steht offen (Viewport ohne Setter). Nur im Linux-Container geprüft. Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
34 lines
991 B
TypeScript
34 lines
991 B
TypeScript
// Sitzungszustand des BCF-Panels: die geladene BCF-Datei lebt AUSSERHALB des Projekts (eigene .bcfzip),
|
|
// aber über das Umschalten der Panel-Tabs hinweg — daher ein kleiner Modul-Speicher statt React-State.
|
|
|
|
import { useSyncExternalStore } from "react";
|
|
import type { BcfFile, BcfVersion } from "../io/bcf";
|
|
|
|
export interface BcfSession {
|
|
file: BcfFile | null;
|
|
fileName: string;
|
|
dirty: boolean;
|
|
selectedGuid: string | null;
|
|
version: BcfVersion;
|
|
}
|
|
|
|
let state: BcfSession = { file: null, fileName: "", dirty: false, selectedGuid: null, version: "2.1" };
|
|
const listeners = new Set<() => void>();
|
|
|
|
export const getBcfSession = (): BcfSession => state;
|
|
|
|
export function setBcfSession(patch: Partial<BcfSession>): void {
|
|
state = { ...state, ...patch };
|
|
for (const l of listeners) l();
|
|
}
|
|
|
|
export function useBcfSession(): BcfSession {
|
|
return useSyncExternalStore(
|
|
(cb) => {
|
|
listeners.add(cb);
|
|
return () => listeners.delete(cb);
|
|
},
|
|
getBcfSession,
|
|
);
|
|
}
|