From a9a1632260ce111103aa868d1edade31b6608dc0 Mon Sep 17 00:00:00 2001 From: karim Date: Tue, 27 Oct 2026 19:30:47 +0100 Subject: [PATCH] Kern/Huelle Phase A.3-5: Fassade src/core, Hueller-Importe aus plan/ und geometry/ darauf umgestellt, Waechter-Test (Kern importiert keine Huelle, Huelle nur ueber core), Plattform-Adapter (projectFile, saveFile, colorIcc) nach native/, Kern laeuft headless --- scripts/core-facade.py | 102 ++++++++ src/App.tsx | 12 +- src/commands/cmds/arc.ts | 6 +- src/commands/cmds/bezier.ts | 2 +- src/commands/cmds/break.ts | 4 +- src/commands/cmds/ceiling.ts | 2 +- src/commands/cmds/ceilingOpening.ts | 2 +- src/commands/cmds/chamfer.ts | 4 +- src/commands/cmds/circle.ts | 9 +- src/commands/cmds/column.ts | 2 +- src/commands/cmds/defblock.ts | 2 +- src/commands/cmds/ellipse.ts | 2 +- src/commands/cmds/extend.ts | 9 +- src/commands/cmds/extrude.ts | 2 +- src/commands/cmds/fillet.ts | 4 +- src/commands/cmds/multiline.ts | 2 +- src/commands/cmds/offset.ts | 10 +- src/commands/cmds/polyline.ts | 2 +- src/commands/cmds/rect.ts | 4 +- src/commands/cmds/revcloud.ts | 4 +- src/commands/cmds/room.ts | 4 +- src/commands/cmds/solidbool.ts | 2 +- src/commands/cmds/spline.ts | 2 +- src/commands/cmds/stair.ts | 2 +- src/commands/cmds/trim.ts | 9 +- src/core/boundary.test.ts | 105 ++++++++ src/core/headless.test.ts | 19 ++ src/core/index.ts | 309 ++++++++++++++++++++++++ src/editors/align.ts | 2 +- src/editors/explode.ts | 2 +- src/editors/splitJoin.ts | 12 +- src/export/layoutPdf.ts | 19 +- src/menus/contextMenu.tsx | 4 +- src/native/appMenu.ts | 2 +- src/{model => native}/colorIcc.test.ts | 0 src/{model => native}/colorIcc.ts | 2 +- src/native/contextImportWindow.ts | 2 +- src/native/drawingLevelsWindow.ts | 2 +- src/native/layerSettingsWindow.ts | 2 +- src/{io => native}/projectFile.ts | 0 src/native/resourceWindow.ts | 2 +- src/{io => native}/saveFile.test.ts | 0 src/{io => native}/saveFile.ts | 0 src/native/settingsWindow.ts | 2 +- src/panels/AttributesPanel.tsx | 2 +- src/panels/ObjectInfoPanel.tsx | 2 +- src/panels/RoomBalancePanel.tsx | 7 +- src/panels/SitePanel.tsx | 2 +- src/state/groupActions.ts | 4 +- src/state/projectSlice.ts | 6 +- src/state/selectionInfo.ts | 21 +- src/state/useExportHandlers.ts | 4 +- src/state/useGripEditing.ts | 2 +- src/state/useMouseSelectionHandlers.ts | 2 +- src/state/usePanelHostBase.ts | 9 +- src/state/useProjectFileActions.ts | 6 +- src/tools/drawingPreview.ts | 4 +- src/tools/sheetSnapGeometry.ts | 2 +- src/tools/snapping.ts | 10 +- src/tools/tools.ts | 2 +- src/tools/transform.ts | 8 +- src/ui/ColorMixer.tsx | 2 +- src/ui/LayoutSheet.tsx | 2 +- src/ui/LockConflictDialog.tsx | 2 +- src/ui/StartScreen.tsx | 2 +- src/ui/hatchPreview.tsx | 2 +- src/ui/resourceManager/LinesTab.tsx | 10 +- src/update/checkForUpdate.ts | 2 +- src/update/version.ts | 2 +- src/update/versionHistory.ts | 2 +- src/viewport/Wasm3DViewport.tsx | 6 +- src/viewport/materialTextures.ts | 2 +- src/viewport/raycast3d.ts | 5 +- src/viewport/useWasm3dRenderer.ts | 2 +- src/views/plan/PlanView.tsx | 43 +--- src/views/plan/nativeGl.ts | 2 +- src/views/plan/nativeSync.ts | 8 +- src/views/plan/planView/PlanGrid.tsx | 2 +- src/views/plan/planView/PlanRulers.tsx | 2 +- src/views/plan/planView/primitives.tsx | 10 +- src/views/plan/useNativePlanRenderer.ts | 12 +- src/views/plan/useWasmPlanRenderer.ts | 4 +- src/views/viewportContent.tsx | 22 +- 83 files changed, 690 insertions(+), 240 deletions(-) create mode 100755 scripts/core-facade.py create mode 100644 src/core/boundary.test.ts create mode 100644 src/core/headless.test.ts create mode 100644 src/core/index.ts rename src/{model => native}/colorIcc.test.ts (100%) rename src/{model => native}/colorIcc.ts (98%) rename src/{io => native}/projectFile.ts (100%) rename src/{io => native}/saveFile.test.ts (100%) rename src/{io => native}/saveFile.ts (100%) diff --git a/scripts/core-facade.py b/scripts/core-facade.py new file mode 100755 index 00000000..612f22d0 --- /dev/null +++ b/scripts/core-facade.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +"""Erzeugt src/core/index.ts aus den Importen der Hülle in plan/ und geometry/ und schreibt die +Importe der Hülle auf "core" um (Phase A der Kern/UI-Trennung, docs/core-ui-split.md). +Aufruf: scripts/core-facade.py [--dry]""" +import re, glob, os, sys, collections +SHELL = ['ui','panels','views','menus','editors','viewport','native','tools','state','commands'] +FACADE_DIRS = ('plan', 'geometry') +imp_re = re.compile(r'''import\s+(type\s+)?\{([^}]*)\}\s+from\s+["'](\.[^"']*)["'];?[ \t]*\n''', re.S) + +# Namen, die ein Modul nur weiterreicht — kanonisch aus dem Ursprungsmodul exportieren. +CANON = { + 'buildDrawingIndex': 'src/geometry/drawingIndex', 'DrawingIndex': 'src/geometry/drawingIndex', + 'drawingsWithinDistance': 'src/geometry/drawingIndex', 'nearestInDrawings': 'src/geometry/drawingIndex', + 'Primitive': 'src/plan/generatePlan/shared', +} + +def shell_file(f): + parts = f.split('/') + top = parts[1] if len(parts) > 2 else parts[1].split('.')[0] + return top in SHELL or top in ('App', 'main') + +uses = collections.defaultdict(dict) # name -> {module: is_type_only} +edits = {} +for f in glob.glob('src/**/*.ts*', recursive=True): + if '.test.' in f or not shell_file(f): continue + s = open(f).read() + out = s + for m in imp_re.finditer(s): + tgt = os.path.normpath(os.path.join(os.path.dirname(f), m.group(3))) + tp = tgt.split('/') + if len(tp) < 3 or tp[0] != 'src' or tp[1] not in FACADE_DIRS: continue + all_type = bool(m.group(1)) + for raw in m.group(2).split(','): + raw = raw.strip() + if not raw: continue + is_t = all_type or raw.startswith('type ') + nm = raw[5:].strip() if raw.startswith('type ') else raw + orig = nm.split(' as ')[0].strip() + tgt2 = CANON.get(orig, tgt) + prev = uses[orig].get(tgt2) + uses[orig][tgt2] = (prev if prev is not None else True) and is_t + edits[f] = s + +# Kollisionen: gleicher Name aus mehreren Modulen +coll = {n: m for n, m in uses.items() if len(m) > 1} +if coll: + print('Namenskollisionen (werden mit Modul-Präfix aliasiert):') + for n, m in coll.items(): print(' ', n, list(m)) + +def alias(n, mod): + if n not in coll: return n + return n + '__' + re.sub(r'\W+', '_', mod[len('src/'):]) + +lines = ['// Fassade des Kerns für die Hülle (Phase A der Kern/UI-Trennung, docs/core-ui-split.md).', + '// Dünne Durchreichung, Namen 1:1; die Hülle importiert Plan-/Geometrie-Funktionen nur noch von hier.', + '// Erzeugt mit scripts/core-facade.py — neue Einträge von Hand ergänzen.', ''] +bymod = collections.defaultdict(list) +for n, mods in uses.items(): + for mod, is_t in mods.items(): bymod[mod].append((n, is_t)) +for mod in sorted(bymod): + rel = '../' + mod[len('src/'):] + items = [] + for n, is_t in sorted(bymod[mod]): + a = alias(n, mod) + core = f'{n} as {a}' if a != n else n + items.append(('type ' if is_t else '') + core) + lines.append('export {\n ' + ',\n '.join(items) + f',\n}} from "{rel}";') + lines.append('') +os.makedirs('src/core', exist_ok=True) +if '--dry' not in sys.argv: + open('src/core/index.ts', 'w').write('\n'.join(lines)) + +def rel_core(f): + r = os.path.relpath('src/core', os.path.dirname(f)) + return r if r.startswith('.') else './' + r + +changed = 0 +if '--dry' not in sys.argv: + for f, s in edits.items(): + keep_stmts = [] + core_items = [] + def fix(m): + tgt = os.path.normpath(os.path.join(os.path.dirname(f), m.group(3))) + tp = tgt.split('/') + if len(tp) < 3 or tp[0] != 'src' or tp[1] not in FACADE_DIRS: return m.group(0) + all_type = bool(m.group(1)) + items = [] + for raw in m.group(2).split(','): + raw = raw.strip() + if not raw: continue + is_t = all_type or raw.startswith('type ') + nm = raw[5:].strip() if raw.startswith('type ') else raw + orig, _, loc = nm.partition(' as ') + a = alias(orig.strip(), CANON.get(orig.strip(), tgt)) + spec = (a if a == orig.strip() else f'{a} as {orig.strip()}') if not loc else f'{a} as {loc.strip()}' + items.append(('type ' if is_t and not all_type else '') + spec) + kw = 'import type' if all_type else 'import' + return f'{kw} {{ {", ".join(items)} }} from "{rel_core(f)}";\n' + n = imp_re.sub(fix, s) + if n != s: + open(f, 'w').write(n); changed += 1 + print('umgeschrieben:', changed, 'Dateien;', len(uses), 'Namen') diff --git a/src/App.tsx b/src/App.tsx index d2325563..27f07033 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -34,10 +34,10 @@ import type { } from "./model/types"; import { activePenSet, resolvePenColor, resolvePenWeight } from "./model/penSets"; import { PenColorField } from "./ui/PenColorField"; -import { generatePlan } from "./plan/generatePlan"; -import type { CategoryDisplayResolver } from "./plan/generatePlan"; -import { sectionPlaneFromLevel, sectionUAxisModel } from "./plan/toSection"; -import { roofBaseElevation, roofGeometry } from "./geometry/roof"; +import { generatePlan } from "./core"; +import type { CategoryDisplayResolver } from "./core"; +import { sectionPlaneFromLevel, sectionUAxisModel } from "./core"; +import { roofBaseElevation, roofGeometry } from "./core"; import { setDxfImportTrigger } from "./io/dxfImportHook"; import { ImportDialog } from "./ui/ImportDialog"; import { BusyOverlay } from "./ui/BusyOverlay"; @@ -51,7 +51,7 @@ import { LockConflictDialog } from "./ui/LockConflictDialog"; import { UnsavedChangesDialog } from "./ui/UnsavedChangesDialog"; import { RecoverAutosaveDialog } from "./ui/RecoverAutosaveDialog"; import { Toast } from "./ui/Toast"; -import { isTauriRuntime, PROJECT_TEMPLATE_EXT } from "./io/projectFile"; +import { isTauriRuntime, PROJECT_TEMPLATE_EXT } from "./native/projectFile"; import { stepTextToImportedMeshes } from "./io/stepImport"; import { applyClashMarkers, runClashCheck } from "./analysis/clash"; import { checkForUpdate } from "./update/checkForUpdate"; @@ -204,7 +204,7 @@ import { PanelHostContext } from "./panels/types"; import { hostWithMode } from "./panels/host"; import { deriveSelection } from "./state/selectionInfo"; import type { Selection } from "./state/selectionInfo"; -import { centroid as roomCentroid } from "./geometry/roomArea"; +import { centroid as roomCentroid } from "./core"; import { docFromText, plainText, DEFAULT_PRESETS } from "./text/richText"; import type { RichTextDoc } from "./text/richText"; import { revealPanel, saveLayout } from "./panels/layout"; diff --git a/src/commands/cmds/arc.ts b/src/commands/cmds/arc.ts index 1ab8331c..e0df69d3 100644 --- a/src/commands/cmds/arc.ts +++ b/src/commands/cmds/arc.ts @@ -33,11 +33,7 @@ import type { Drawing2D } from "../../model/types"; import { uniqueId } from "../../tools/types"; -import { - arcFromStartEndDirection, - arcFromStartEndRadius, - arcThroughPoints, -} from "../../geometry/bulge"; +import { arcFromStartEndDirection, arcFromStartEndRadius, arcThroughPoints } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/bezier.ts b/src/commands/cmds/bezier.ts index 47ce8096..8d7c7db3 100644 --- a/src/commands/cmds/bezier.ts +++ b/src/commands/cmds/bezier.ts @@ -9,7 +9,7 @@ import type { Drawing2D } from "../../model/types"; import { uniqueId } from "../../tools/types"; -import { sampleBezierChain } from "../../geometry/curves"; +import { sampleBezierChain } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/break.ts b/src/commands/cmds/break.ts index 82f94896..75bcc84f 100644 --- a/src/commands/cmds/break.ts +++ b/src/commands/cmds/break.ts @@ -20,8 +20,8 @@ import type { Drawing2D } from "../../model/types"; import { uniqueId } from "../../tools/types"; -import { breakCurve, nearestOnPolyline } from "../../geometry/kernel2d"; -import { hasRealBulge } from "../../geometry/bulge"; +import { breakCurve, nearestOnPolyline } from "../../core"; +import { hasRealBulge } from "../../core"; import { chainToGeom, geomToCurve, isTrimmable, pickCurveAt } from "./trim"; import type { Command, diff --git a/src/commands/cmds/ceiling.ts b/src/commands/cmds/ceiling.ts index 01661a9d..2ace28b9 100644 --- a/src/commands/cmds/ceiling.ts +++ b/src/commands/cmds/ceiling.ts @@ -16,7 +16,7 @@ // • categoryCode← "30" (Ebene „Decken"; Fallback ctx.defaultCategoryCode) import type { Ceiling } from "../../model/types"; -import { normalizeOutline, ceilingArea } from "../../geometry/ceiling"; +import { normalizeOutline, ceilingArea } from "../../core"; import { uniqueId } from "../../tools/types"; import type { Command, diff --git a/src/commands/cmds/ceilingOpening.ts b/src/commands/cmds/ceilingOpening.ts index baf520d0..e274e2b3 100644 --- a/src/commands/cmds/ceilingOpening.ts +++ b/src/commands/cmds/ceilingOpening.ts @@ -8,7 +8,7 @@ // 1) „Erste Ecke der Aussparung:" → Punkt // 2) „Gegenecke:" → Live-Rechteck-Vorschau; Klick committet. -import { pointInOutline } from "../../geometry/ceiling"; +import { pointInOutline } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/chamfer.ts b/src/commands/cmds/chamfer.ts index 3bc8544e..99fa2ee2 100644 --- a/src/commands/cmds/chamfer.ts +++ b/src/commands/cmds/chamfer.ts @@ -9,8 +9,8 @@ // ist von Natur aus gerade, also ein exaktes (nicht approximiertes) Ergebnis. import type { Drawing2D, Drawing2DGeom } from "../../model/types"; -import { hasRealBulge } from "../../geometry/bulge"; -import { chamferCorner, type Chamfer } from "../../geometry/kernel2d"; +import { hasRealBulge } from "../../core"; +import { chamferCorner, type Chamfer } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/circle.ts b/src/commands/cmds/circle.ts index c8932707..94bc2869 100644 --- a/src/commands/cmds/circle.ts +++ b/src/commands/cmds/circle.ts @@ -37,13 +37,8 @@ import type { Drawing2D, Drawing2DGeom } from "../../model/types"; import { uniqueId } from "../../tools/types"; -import { arcThroughPoints } from "../../geometry/bulge"; -import { - pointSegmentDistance, - polylineEdges, - tangentCircleCenters, - type TangentTarget, -} from "../../geometry/kernel2d"; +import { arcThroughPoints } from "../../core"; +import { pointSegmentDistance, polylineEdges, tangentCircleCenters, type TangentTarget } from "../../core"; import type { CmdOption, Command, diff --git a/src/commands/cmds/column.ts b/src/commands/cmds/column.ts index 787421f0..7d6cf22f 100644 --- a/src/commands/cmds/column.ts +++ b/src/commands/cmds/column.ts @@ -15,7 +15,7 @@ import type { Column, ColumnProfile } from "../../model/types"; import { uniqueId } from "../../tools/types"; -import { columnFootprint } from "../../geometry/column"; +import { columnFootprint } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/defblock.ts b/src/commands/cmds/defblock.ts index 63e9a4af..373ef5a3 100644 --- a/src/commands/cmds/defblock.ts +++ b/src/commands/cmds/defblock.ts @@ -11,7 +11,7 @@ // Leere/rein-block-Auswahl → No-Op (kein Commit). import type { BlockDef, Drawing2D } from "../../model/types"; -import { mvGeom } from "../../geometry/geomTransform"; +import { mvGeom } from "../../core"; import { uniqueId } from "../../tools/types"; import type { Command, diff --git a/src/commands/cmds/ellipse.ts b/src/commands/cmds/ellipse.ts index e41cd35c..6e79a1cf 100644 --- a/src/commands/cmds/ellipse.ts +++ b/src/commands/cmds/ellipse.ts @@ -21,7 +21,7 @@ import type { Drawing2D } from "../../model/types"; import { segmentHud, uniqueId } from "../../tools/types"; -import { ellipsePts } from "../../geometry/curves"; +import { ellipsePts } from "../../core"; import type { CmdOption, Command, diff --git a/src/commands/cmds/extend.ts b/src/commands/cmds/extend.ts index ca1a58b6..d4f379df 100644 --- a/src/commands/cmds/extend.ts +++ b/src/commands/cmds/extend.ts @@ -23,13 +23,8 @@ // Bezeichner englisch, Kommentare/UI deutsch (CONVENTIONS.md). import type { Drawing2D, Drawing2DGeom } from "../../model/types"; -import { bulgeArcPoints, hasRealBulge } from "../../geometry/bulge"; -import { - extendBulgeSegment, - extendSegment, - pointSegmentDistance, - polylineEdges, -} from "../../geometry/kernel2d"; +import { bulgeArcPoints, hasRealBulge } from "../../core"; +import { extendBulgeSegment, extendSegment, pointSegmentDistance, polylineEdges } from "../../core"; import type { Command, CommandResult, diff --git a/src/commands/cmds/extrude.ts b/src/commands/cmds/extrude.ts index 96e19abf..58a5ec0b 100644 --- a/src/commands/cmds/extrude.ts +++ b/src/commands/cmds/extrude.ts @@ -15,7 +15,7 @@ import type { Drawing2D, ExtrudedSolid } from "../../model/types"; import { uniqueId } from "../../tools/types"; -import { polylineEdges, pointSegmentDistance } from "../../geometry/kernel2d"; +import { polylineEdges, pointSegmentDistance } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/fillet.ts b/src/commands/cmds/fillet.ts index 79025551..eae0d120 100644 --- a/src/commands/cmds/fillet.ts +++ b/src/commands/cmds/fillet.ts @@ -15,8 +15,8 @@ // einer polyline (kein reines Rechteck mehr). import type { Drawing2D, Drawing2DGeom } from "../../model/types"; -import { bulgeFromSagittaPoint, hasRealBulge } from "../../geometry/bulge"; -import { filletCorner, type Fillet } from "../../geometry/kernel2d"; +import { bulgeFromSagittaPoint, hasRealBulge } from "../../core"; +import { filletCorner, type Fillet } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/multiline.ts b/src/commands/cmds/multiline.ts index c2d84533..ed97ae3e 100644 --- a/src/commands/cmds/multiline.ts +++ b/src/commands/cmds/multiline.ts @@ -18,7 +18,7 @@ import type { Drawing2D } from "../../model/types"; import { segmentHud, uniqueId } from "../../tools/types"; import { leftNormal, normalize, sub } from "../../model/geometry"; -import { offsetSegment } from "../../geometry/kernel2d"; +import { offsetSegment } from "../../core"; import type { CmdOption, Command, diff --git a/src/commands/cmds/offset.ts b/src/commands/cmds/offset.ts index 94afc245..32b89d93 100644 --- a/src/commands/cmds/offset.ts +++ b/src/commands/cmds/offset.ts @@ -14,16 +14,10 @@ // Vorzeichen, wenn negativ getippt. import type { Drawing2D, Drawing2DGeom } from "../../model/types"; -import { bulgeArcPoints, hasRealBulge } from "../../geometry/bulge"; +import { bulgeArcPoints, hasRealBulge } from "../../core"; import { uniqueId } from "../../tools/types"; import { leftNormal, normalize, sub } from "../../model/geometry"; -import { - offsetPolyline, - offsetPolylineWithBulge, - offsetSegment, - pointSegmentDistance, - polylineEdges, -} from "../../geometry/kernel2d"; +import { offsetPolyline, offsetPolylineWithBulge, offsetSegment, pointSegmentDistance, polylineEdges } from "../../core"; import type { CmdInput, Command, diff --git a/src/commands/cmds/polyline.ts b/src/commands/cmds/polyline.ts index 88dbfb3e..5f330781 100644 --- a/src/commands/cmds/polyline.ts +++ b/src/commands/cmds/polyline.ts @@ -19,7 +19,7 @@ // Tangenten-Referenz und bleibt gerade. import type { Drawing2D } from "../../model/types"; -import { bulgeArcPoints, bulgeThroughPoint } from "../../geometry/bulge"; +import { bulgeArcPoints, bulgeThroughPoint } from "../../core"; import { segmentHud, uniqueId } from "../../tools/types"; import type { Command, diff --git a/src/commands/cmds/rect.ts b/src/commands/cmds/rect.ts index aa3e0bb8..c0ce3809 100644 --- a/src/commands/cmds/rect.ts +++ b/src/commands/cmds/rect.ts @@ -31,8 +31,8 @@ import type { Drawing2D } from "../../model/types"; import { deltaHud, segmentHud, uniqueId } from "../../tools/types"; -import { filletCorner } from "../../geometry/kernel2d"; -import { bulgeArcPoints, bulgeThroughPoint } from "../../geometry/bulge"; +import { filletCorner } from "../../core"; +import { bulgeArcPoints, bulgeThroughPoint } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/revcloud.ts b/src/commands/cmds/revcloud.ts index 00dc2786..17e2d0be 100644 --- a/src/commands/cmds/revcloud.ts +++ b/src/commands/cmds/revcloud.ts @@ -9,8 +9,8 @@ // Aufrufe hinweg (wie `lastSides` bei `polygon.ts`). import type { Drawing2D } from "../../model/types"; -import { bulgeArcPoints } from "../../geometry/bulge"; -import { revisionCloudPts } from "../../geometry/revisionCloud"; +import { bulgeArcPoints } from "../../core"; +import { revisionCloudPts } from "../../core"; import { segmentHud, uniqueId } from "../../tools/types"; import type { CmdOption, diff --git a/src/commands/cmds/room.ts b/src/commands/cmds/room.ts index 6a4c8ed2..222cbf5f 100644 --- a/src/commands/cmds/room.ts +++ b/src/commands/cmds/room.ts @@ -19,8 +19,8 @@ import type { Room } from "../../model/types"; import { wallTypeThickness } from "../../model/types"; -import { roomFromPointInside, type WallSegment } from "../../geometry/roomBoundary"; -import { polygonArea, centroid } from "../../geometry/roomArea"; +import { roomFromPointInside, type WallSegment } from "../../core"; +import { polygonArea, centroid } from "../../core"; import { docFromText } from "../../text/richText"; import { uniqueId } from "../../tools/types"; import type { diff --git a/src/commands/cmds/solidbool.ts b/src/commands/cmds/solidbool.ts index 556008d3..fc67ac1c 100644 --- a/src/commands/cmds/solidbool.ts +++ b/src/commands/cmds/solidbool.ts @@ -10,7 +10,7 @@ import type { ExtrudedSolid, Vec2 } from "../../model/types"; import { getFloor } from "../../model/types"; import { uniqueId } from "../../tools/types"; -import { extrudedSolidSpec } from "../../plan/extrudedSolidSpec"; +import { extrudedSolidSpec } from "../../core"; import type { Command, CommandResult, CommandState, CmdOption, Project, ToolDraft } from "../types"; export type SolidBoolOp = "union" | "difference" | "intersection"; diff --git a/src/commands/cmds/spline.ts b/src/commands/cmds/spline.ts index 80a04b90..0e9d1cfc 100644 --- a/src/commands/cmds/spline.ts +++ b/src/commands/cmds/spline.ts @@ -17,7 +17,7 @@ import type { Drawing2D } from "../../model/types"; import { segmentHud, uniqueId } from "../../tools/types"; -import { sampleCatmullRom, sampleUniformBSpline } from "../../geometry/curves"; +import { sampleCatmullRom, sampleUniformBSpline } from "../../core"; import type { Command, CommandContext, diff --git a/src/commands/cmds/stair.ts b/src/commands/cmds/stair.ts index bbd6a9e1..32a0a1a6 100644 --- a/src/commands/cmds/stair.ts +++ b/src/commands/cmds/stair.ts @@ -20,7 +20,7 @@ // Bezeichner englisch, sichtbarer Text via t() (CONVENTIONS.md). import type { Stair, StairShape, Vec2 as MVec2 } from "../../model/types"; -import { stairGeometry, defaultStepCount, IDEAL_TREAD, MIN_STEPS } from "../../geometry/stair"; +import { stairGeometry, defaultStepCount, IDEAL_TREAD, MIN_STEPS } from "../../core"; import { uniqueId } from "../../tools/types"; import type { Command, diff --git a/src/commands/cmds/trim.ts b/src/commands/cmds/trim.ts index 622beb57..2fce85c9 100644 --- a/src/commands/cmds/trim.ts +++ b/src/commands/cmds/trim.ts @@ -19,14 +19,9 @@ // Bezeichner englisch, Kommentare/UI deutsch (CONVENTIONS.md). import type { Drawing2D, Drawing2DGeom } from "../../model/types"; -import { bulgeArcPoints, hasRealBulge } from "../../geometry/bulge"; +import { bulgeArcPoints, hasRealBulge } from "../../core"; import { uniqueId } from "../../tools/types"; -import { - pointSegmentDistance, - polylineEdges, - trimPolylineWithBulge, - vecEqual, -} from "../../geometry/kernel2d"; +import { pointSegmentDistance, polylineEdges, trimPolylineWithBulge, vecEqual } from "../../core"; import type { Command, CommandResult, diff --git a/src/core/boundary.test.ts b/src/core/boundary.test.ts new file mode 100644 index 00000000..cdc6febe --- /dev/null +++ b/src/core/boundary.test.ts @@ -0,0 +1,105 @@ +// Wächter für die Kern/Hülle-Grenze (docs/core-ui-split.md, Phase A). Es gibt kein ESLint im +// Projekt — die Regeln laufen deshalb als Test über die Importzeilen aller Quelldateien. +// +// 1. Der KERN (model, geometry, plan, io, export, analysis, materials, text, engine) importiert +// nie die HÜLLE (ui, panels, views, menus, editors, viewport, native, tools, state, commands, +// App) und nie React/Zustand/Tauri statisch. +// 2. Die HÜLLE holt Funktionen aus `plan/` und `geometry/` nur über die Fassade `src/core`. +// (`model/` — Typen und kleine Modell-Helfer — darf sie direkt importieren.) +// +// Ausnahmen stehen in den Listen unten; Ziel: leer. + +import { describe, expect, it } from "vitest"; +import { readdirSync, readFileSync, statSync } from "node:fs"; +import { dirname, join, normalize, relative, sep } from "node:path"; + +const SRC = join(process.cwd(), "src"); +const CORE_DIRS = new Set(["model", "geometry", "plan", "io", "export", "analysis", "materials", "text", "engine"]); +const SHELL_DIRS = new Set(["ui", "panels", "views", "menus", "editors", "viewport", "native", "tools", "state", "commands"]); +const FACADE_DIRS = new Set(["plan", "geometry"]); +const FORBIDDEN_PACKAGES = /^(react|react-dom|zustand|@tauri-apps\/.*)$/; + +/** Kern-Dateien, die (noch) Hüllen-Verzeichnisse oder UI-Pakete importieren — Ziel: leer. */ +const CORE_EXCEPTIONS: string[] = []; +/** Hüllen-Dateien, die `plan/`/`geometry/` direkt importieren — Ziel: leer. */ +const SHELL_EXCEPTIONS: string[] = []; + +function walk(dir: string, out: string[] = []): string[] { + for (const name of readdirSync(dir)) { + const p = join(dir, name); + if (statSync(p).isDirectory()) walk(p, out); + else if (/\.tsx?$/.test(name) && !/\.test\.tsx?$/.test(name)) out.push(p); + } + return out; +} + +/** Oberstes Verzeichnis unter src/ ("App"/"main" für Dateien direkt darin). */ +function top(file: string): string { + const parts = relative(SRC, file).split(sep); + return parts.length > 1 ? parts[0] : parts[0].replace(/\.tsx?$/, ""); +} + +interface Imp { + spec: string; + /** aufgelöst relativ zu src/, mit "/" (nur bei relativen Importen) */ + target: string | null; +} + +const IMPORT_RE = /(?:import|export)\s+(?:type\s+)?(?:[^"';]*?\s+from\s+)?["']([^"']+)["']|import\(\s*["']([^"']+)["']\s*\)/g; + +function importsOf(file: string): Imp[] { + const src = readFileSync(file, "utf8"); + const out: Imp[] = []; + for (const m of src.matchAll(IMPORT_RE)) { + const spec = m[1] ?? m[2]; + if (!spec) continue; + out.push({ + spec, + target: spec.startsWith(".") ? normalize(join(dirname(file), spec)).slice(SRC.length + 1).split(sep).join("/") : null, + }); + } + return out; +} + +const files = walk(SRC); + +describe("Kern/Hülle-Grenze", () => { + it("der Kern importiert keine Hülle und keine UI-Pakete", () => { + const violations: string[] = []; + for (const f of files) { + const t = top(f); + if (!CORE_DIRS.has(t)) continue; + const rel = relative(SRC, f).split(sep).join("/"); + if (CORE_EXCEPTIONS.includes(rel)) continue; + for (const i of importsOf(f)) { + const tt = i.target?.split("/")[0]; + if (tt && (SHELL_DIRS.has(tt) || tt === "App" || tt === "main")) violations.push(`${rel} → ${i.target}`); + if (!i.target && FORBIDDEN_PACKAGES.test(i.spec)) violations.push(`${rel} → ${i.spec}`); + } + } + expect(violations).toEqual([]); + }); + + it("die Hülle holt plan/ und geometry/ nur über die Fassade src/core", () => { + const violations: string[] = []; + for (const f of files) { + const t = top(f); + if (!SHELL_DIRS.has(t) && t !== "App" && t !== "main") continue; + const rel = relative(SRC, f).split(sep).join("/"); + if (SHELL_EXCEPTIONS.includes(rel)) continue; + for (const i of importsOf(f)) { + const tt = i.target?.split("/")[0]; + if (tt && FACADE_DIRS.has(tt)) violations.push(`${rel} → ${i.target}`); + } + } + expect(violations).toEqual([]); + }); + + it("die Fassade zeigt nur auf plan/ und geometry/ und importiert keine Hülle", () => { + const f = join(SRC, "core", "index.ts"); + for (const i of importsOf(f)) { + const tt = i.target?.split("/")[0]; + expect(tt === undefined || FACADE_DIRS.has(tt)).toBe(true); + } + }); +}); diff --git a/src/core/headless.test.ts b/src/core/headless.test.ts new file mode 100644 index 00000000..5fd809ae --- /dev/null +++ b/src/core/headless.test.ts @@ -0,0 +1,19 @@ +// Beweis, dass die Grenze trägt: der Kern läuft ohne DOM/React, nur über die Fassade `src/core` +// (Vitest-Umgebung = node). Ein späteres `dossier-cli` ([4]) nutzt genau diese Einstiege. +import { describe, expect, it } from "vitest"; +import { generatePlan, planToRenderScene, projectToModel3d } from "./index"; +import { sampleProject } from "../model/sampleProject"; + +describe("Kern headless (nur über src/core)", () => { + it("Grundriss, Render-Szene und 3D-Modell des Beispielprojekts ohne DOM", () => { + expect(typeof document).toBe("undefined"); + const floor = sampleProject.drawingLevels.find((l) => l.kind === "floor")!; + const codes = new Set(sampleProject.layers.map((l) => l.code)); + const plan = generatePlan(sampleProject, floor.id, codes); + expect(plan.primitives.length).toBeGreaterThan(50); + const scene = planToRenderScene(plan); + expect(scene).toBeTruthy(); + const model = projectToModel3d(sampleProject); + expect(model.walls.length).toBeGreaterThan(5); + }); +}); diff --git a/src/core/index.ts b/src/core/index.ts new file mode 100644 index 00000000..f9fda0ce --- /dev/null +++ b/src/core/index.ts @@ -0,0 +1,309 @@ +// Fassade des Kerns für die Hülle (Phase A der Kern/UI-Trennung, docs/core-ui-split.md). +// Dünne Durchreichung, Namen 1:1; die Hülle importiert Plan-/Geometrie-Funktionen nur noch von hier. +// Erzeugt mit scripts/core-facade.py — neue Einträge von Hand ergänzen. + +export { + arcFromStartEndDirection, + arcFromStartEndRadius, + arcThroughPoints, + bulgeArc, + bulgeArcPoints, + bulgeBetweenAngles, + bulgeFromSagittaPoint, + bulgePointAt, + bulgeThroughPoint, + hasRealBulge, + pointOnCircle, +} from "../geometry/bulge"; + +export { + ceilingArea, + normalizeOutline, + outlineBBox, + pointInOutline, +} from "../geometry/ceiling"; + +export { + columnFootprint, +} from "../geometry/column"; + +export { + ellipsePts, + sampleBezierChain, + sampleCatmullRom, + sampleUniformBSpline, +} from "../geometry/curves"; + +export { + type DrawingIndex, + buildDrawingIndex, + drawingsNear, + drawingsWithinDistance, + isIndexable, + nearestInDrawings, + pointSegDist as pointSegDist__geometry_drawingIndex, +} from "../geometry/drawingIndex"; + +export { + mvGeom, + reversesOrientation, + scaleFactor, + scaleGeom, +} from "../geometry/geomTransform"; + +export { + type Chamfer, + type Fillet, + type TangentTarget, + breakCurve, + chamferCorner, + extendBulgeSegment, + extendSegment, + filletCorner, + joinChainsWithBulge, + nearestOnPolyline, + offsetPolyline, + offsetPolylineWithBulge, + offsetSegment, + pointSegmentDistance, + polylineEdges, + removeSegment, + removeSegmentWithBulge, + splitAtIntersections, + splitClosedByChord, + splitPolylineAtParam, + tangentCircleCenters, + trimPolylineWithBulge, + vecEqual, +} from "../geometry/kernel2d"; + +export { + LINE_PRESETS, + type LinePresetKey, + type LineSegment, + type LineSegmentType, + dashHasDot, + dashToSegments, + presetOfDash, + segmentsToDash, +} from "../geometry/lineSegments"; + +export { + openingGapQuad, + openingVerticalExtent, +} from "../geometry/opening"; + +export { + nearestPolylineTarget, + toleranceFor, +} from "../geometry/polylinePoint"; + +export { + type PolylineVertexType, + canSetVertexType, + vertexTypeOf, + withVertexType, +} from "../geometry/polylineVertexType"; + +export { + revisionCloudPts, +} from "../geometry/revisionCloud"; + +export { + roofBBox, + roofBaseElevation, + roofGeometry, +} from "../geometry/roof"; + +export { + SIA_CATEGORIES, + balance, + centroid, + evaluateRoom, + polygonArea, + roomsToCsv, + siaLabelFull, +} from "../geometry/roomArea"; + +export { + type WallSegment, + roomFromPointInside, +} from "../geometry/roomBoundary"; + +export { + IDEAL_TREAD, + MIN_STEPS, + defaultStepCount, + stairBBox, + stairGeometry, + stairOutline, +} from "../geometry/stair"; + +export { + extrudedSolidSpec, + transformSolid, +} from "../plan/extrudedSolidSpec"; + +export { + type CategoryDisplayResolver, + type HatchRender, + type Plan, + type PlanImage, + type UnderlayGroup, + generatePlan, + generateSectionPlan, + generateVisibleLevelsPlan, + materializeGreyed, + materializeUnderlay, +} from "../plan/generatePlan"; + +export { + addDrawing2D, +} from "../plan/generatePlan/drawing2d"; + +export { + END_MARK_DEFAULT_SIZE_MM, +} from "../plan/generatePlan/endMarks"; + +export { + NO_HATCH, + type Primitive, + resolveBackground, + resolveForeground, + resolveHatchId, + resolveStrokeWeight, +} from "../plan/generatePlan/shared"; + +export { + GpuChunkCache, +} from "../plan/glPlan/glPlanChunks"; + +export { + compilePrimitivesToGpu, +} from "../plan/glPlan/glPlanCompile"; + +export { + DASH_MM_TO_M, + buildRandomHatchRuns, + motifPoints, + zigzagPoints, +} from "../plan/glPlan/glPlanHatch"; + +export { + type BufferGl, + type GpuGeometry, + type ViewBox as ViewBox__plan_glPlan_glPlanTypes, +} from "../plan/glPlan/glPlanTypes"; + +export { + levelMarkerPrimitives, + levelMarksEnabled, +} from "../plan/levelMarkers"; + +export { + NativeTextSync, + isGpuText, +} from "../plan/nativeText"; + +export { + type PickKind, + categoryNameForPick, +} from "../plan/pickLabels"; + +export { + DRAWING_PICK_TOLERANCE, + type PickContextMesh, + type PickDrawingSeg, + type PickOpening, + type PickRoof, + type PickSlab, + type PickStair, + type PickWall, + type Vec3, +} from "../plan/pickTypes"; + +export { + crossKindOverlayAllowed, + planUnderlayPrimitives, +} from "../plan/planUnderlay"; + +export { + type Bounds, + expandRegion, + indexedInRegion, + regionContains, +} from "../plan/planView/cullPrimitives"; + +export { + HAIRLINE_PX, + type ModelRect, + PAD, + PX_PER_M, + type ViewBox as ViewBox__plan_planView_geometry, + clamp, + fitBoxFor, + marqueeHit, + marqueeHitCeilings, + marqueeHitDrawings, + marqueeHitRooms, + marqueeHitStairs, + meetScale, + mmToPx, + pointInPolygon, + pointSegDistPx, + printStrokeVb, + scaleFromView, + toScreen, + viewForCamera, + viewForScale, + visibleEdgeRuns, +} from "../plan/planView/geometry"; + +export { + type OwnerField, + type OwnerIndex, + buildOwnerIndex, + ownedBy, +} from "../plan/planView/ownerIndex"; + +export { + buildSegmentIndex, + nearestSegment, + pointSegDist as pointSegDist__plan_planView_segmentIndex, + segmentsNear, +} from "../plan/planView/segmentIndex"; + +export { + marqueeHitUnderlay, +} from "../plan/planView/underlayAccess"; + +export { + sectionOpeningPrimitives, +} from "../plan/sectionOpenings"; + +export { + generateElevationPlan, +} from "../plan/toElevation"; + +export { + planToRenderScene, +} from "../plan/toRenderScene"; + +export { + type SectionOutput, + computeSection, + sameSectionInputs, + sameSectionLine, + sectionPlaneFromLevel, + sectionUAxisModel, +} from "../plan/toSection"; + +export { + TRUCK_MESH_READY_EVENT, + draftWorldLines, + emitDrawingLineVerts, + pickGeometry, + projectToModel3d, + selectionHighlightLines, + wallMaterialColorMaps, +} from "../plan/toWalls3d"; diff --git a/src/editors/align.ts b/src/editors/align.ts index 84cd57d2..31aa04c6 100644 --- a/src/editors/align.ts +++ b/src/editors/align.ts @@ -8,7 +8,7 @@ import type { Drawing2D, Project, Vec2 } from "../model/types"; import { geomBBox } from "../state/selectionInfo"; -import { mvGeom } from "../geometry/geomTransform"; +import { mvGeom } from "../core"; /** Ausrichtungskante bzw. -achse. */ export type AlignMode = "left" | "right" | "centerX" | "top" | "bottom" | "centerY"; diff --git a/src/editors/explode.ts b/src/editors/explode.ts index 4744e8d6..5ab05aca 100644 --- a/src/editors/explode.ts +++ b/src/editors/explode.ts @@ -16,7 +16,7 @@ // unverändert stehen. Ebenso alles, was kein 2D-Element ist. import type { Drawing2D, Drawing2DGeom, Project, Vec2 } from "../model/types"; -import { bulgeArc } from "../geometry/bulge"; +import { bulgeArc } from "../core"; import { uniqueId } from "../tools/types"; /** Teilgeometrien EINES Elements, oder `null`, wenn es nicht zerlegbar ist. */ diff --git a/src/editors/splitJoin.ts b/src/editors/splitJoin.ts index 5e4d2788..e1239988 100644 --- a/src/editors/splitJoin.ts +++ b/src/editors/splitJoin.ts @@ -6,16 +6,8 @@ // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). import type { Drawing2D, Drawing2DGeom, Vec2 } from "../model/types"; -import { - joinChainsWithBulge, - removeSegment, - removeSegmentWithBulge, - splitAtIntersections, - splitClosedByChord, - splitPolylineAtParam, - vecEqual, -} from "../geometry/kernel2d"; -import { bulgeArcPoints, hasRealBulge } from "../geometry/bulge"; +import { joinChainsWithBulge, removeSegment, removeSegmentWithBulge, splitAtIntersections, splitClosedByChord, splitPolylineAtParam, vecEqual } from "../core"; +import { bulgeArcPoints, hasRealBulge } from "../core"; /** Eine Polylinien-Darstellung eines Drawing2D (für die Kernel-Funktionen). */ export interface PolyForm { diff --git a/src/export/layoutPdf.ts b/src/export/layoutPdf.ts index 3704e653..67546757 100644 --- a/src/export/layoutPdf.ts +++ b/src/export/layoutPdf.ts @@ -15,7 +15,6 @@ import "svg2pdf.js"; import type { Layout, LayoutAnnotation, MasterLayout, Project } from "../model/types"; import { generatePlan } from "../plan/generatePlan"; import { planToPrintSvg } from "./planToPrintSvg"; -import { saveBinaryFile } from "../io/saveFile"; import { wrapDocToLines, type SvgLine } from "../text/renderHtml"; import { docFromText } from "../text/richText"; import { @@ -304,19 +303,9 @@ export async function buildFolderPdf( return doc; } -/** - * Baut das Ordner-PDF und speichert es (nativer Tauri-Dialog bzw. - * Browser-Download). Liefert `false`, wenn nichts zu exportieren war oder der - * Speichern-Dialog abgebrochen wurde. - */ -export async function saveFolderPdf( - project: Project, - folderId: string, - fileName: string, -): Promise { +/** Baut das Ordner-PDF als Bytes (`null`, wenn nichts zu exportieren war). Speichern macht die Hülle. */ +export async function folderPdfBytes(project: Project, folderId: string): Promise { const doc = await buildFolderPdf(project, folderId); - if (!doc) return false; - const bytes = doc.output("arraybuffer"); - const name = fileName.replace(/\.pdf$/i, ""); - return saveBinaryFile(new Uint8Array(bytes), `${name}.pdf`, "application/pdf"); + if (!doc) return null; + return new Uint8Array(doc.output("arraybuffer")); } diff --git a/src/menus/contextMenu.tsx b/src/menus/contextMenu.tsx index 3ad3d190..e8c44165 100644 --- a/src/menus/contextMenu.tsx +++ b/src/menus/contextMenu.tsx @@ -8,8 +8,8 @@ // Kommentare deutsch (CONVENTIONS.md). import { t } from "../i18n"; -import { canSetVertexType, vertexTypeOf, type PolylineVertexType } from "../geometry/polylineVertexType"; -import { nearestPolylineTarget, toleranceFor } from "../geometry/polylinePoint"; +import { canSetVertexType, vertexTypeOf, type PolylineVertexType } from "../core"; +import { nearestPolylineTarget, toleranceFor } from "../core"; import type { LayerCategory, Project, Vec2 } from "../model/types"; import { flattenCategories } from "../model/types"; import { findCategory } from "../state/projectSlice"; diff --git a/src/native/appMenu.ts b/src/native/appMenu.ts index 4e2da665..78f03c52 100644 --- a/src/native/appMenu.ts +++ b/src/native/appMenu.ts @@ -13,7 +13,7 @@ // Bezeichner englisch, UI-Text über i18n (CONVENTIONS.md). import { useEffect, useRef } from "react"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "./projectFile"; import { t } from "../i18n"; import { APP_VERSION } from "../ui/TopBar"; import type { View3d, ViewType } from "../model/viewTypes"; diff --git a/src/model/colorIcc.test.ts b/src/native/colorIcc.test.ts similarity index 100% rename from src/model/colorIcc.test.ts rename to src/native/colorIcc.test.ts diff --git a/src/model/colorIcc.ts b/src/native/colorIcc.ts similarity index 98% rename from src/model/colorIcc.ts rename to src/native/colorIcc.ts index 31d0e12d..4af05d79 100644 --- a/src/model/colorIcc.ts +++ b/src/native/colorIcc.ts @@ -21,7 +21,7 @@ import { readFile } from "@tauri-apps/plugin-fs"; import type { LcmsInstance } from "lcms-wasm"; -import type { Cmyk, Rgb } from "./color"; +import type { Cmyk, Rgb } from "../model/color"; const MACOS_GENERIC_CMYK_PROFILE = "/System/Library/ColorSync/Profiles/Generic CMYK Profile.icc"; diff --git a/src/native/contextImportWindow.ts b/src/native/contextImportWindow.ts index c051100b..37260f09 100644 --- a/src/native/contextImportWindow.ts +++ b/src/native/contextImportWindow.ts @@ -16,7 +16,7 @@ // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). import { useEffect, useRef } from "react"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "./projectFile"; import type { GeoAnchor } from "../ui/ContextImportDialog"; import { BORDERLESS_WINDOW_CHROME } from "./windowChrome"; diff --git a/src/native/drawingLevelsWindow.ts b/src/native/drawingLevelsWindow.ts index 6438a32b..02307845 100644 --- a/src/native/drawingLevelsWindow.ts +++ b/src/native/drawingLevelsWindow.ts @@ -18,7 +18,7 @@ // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). import { useEffect, useRef } from "react"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "./projectFile"; import type { DrawingLevel } from "../model/types"; import type { DisplayMode } from "../panels/types"; import { BORDERLESS_WINDOW_CHROME } from "./windowChrome"; diff --git a/src/native/layerSettingsWindow.ts b/src/native/layerSettingsWindow.ts index 4f3ca3b3..c089c9cb 100644 --- a/src/native/layerSettingsWindow.ts +++ b/src/native/layerSettingsWindow.ts @@ -22,7 +22,7 @@ // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). import { useEffect, useRef } from "react"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "./projectFile"; import { findCategory } from "../state/projectSlice"; import type { HatchStyle, LayerCategory, Project } from "../model/types"; import { BORDERLESS_WINDOW_CHROME } from "./windowChrome"; diff --git a/src/io/projectFile.ts b/src/native/projectFile.ts similarity index 100% rename from src/io/projectFile.ts rename to src/native/projectFile.ts diff --git a/src/native/resourceWindow.ts b/src/native/resourceWindow.ts index 773adb42..b7743f5a 100644 --- a/src/native/resourceWindow.ts +++ b/src/native/resourceWindow.ts @@ -19,7 +19,7 @@ // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). import { useEffect, useRef } from "react"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "./projectFile"; import type { Project } from "../model/types"; import type { ResourceManagerHandlers, TabId } from "../ui/ResourceManager"; import { BORDERLESS_WINDOW_CHROME } from "./windowChrome"; diff --git a/src/io/saveFile.test.ts b/src/native/saveFile.test.ts similarity index 100% rename from src/io/saveFile.test.ts rename to src/native/saveFile.test.ts diff --git a/src/io/saveFile.ts b/src/native/saveFile.ts similarity index 100% rename from src/io/saveFile.ts rename to src/native/saveFile.ts diff --git a/src/native/settingsWindow.ts b/src/native/settingsWindow.ts index bb6d7608..4698a61e 100644 --- a/src/native/settingsWindow.ts +++ b/src/native/settingsWindow.ts @@ -13,7 +13,7 @@ // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). import { useEffect, useRef } from "react"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "./projectFile"; import type { LayoutState } from "../panels/types"; import type { RendererMode } from "../ui/StatusBar"; import type { ThemeMode } from "../theme/themeMode"; diff --git a/src/panels/AttributesPanel.tsx b/src/panels/AttributesPanel.tsx index 292ae626..e1884d59 100644 --- a/src/panels/AttributesPanel.tsx +++ b/src/panels/AttributesPanel.tsx @@ -33,7 +33,7 @@ import { Dropdown } from "../ui/Dropdown"; import { PenColorField } from "../ui/PenColorField"; import { activePenSet, resolvePenWeight } from "../model/penSets"; import { DIM_DEFAULTS_MM } from "../model/dimension"; -import { END_MARK_DEFAULT_SIZE_MM } from "../plan/generatePlan/endMarks"; +import { END_MARK_DEFAULT_SIZE_MM } from "../core"; import type { EndMark } from "../model/types"; /** Auswahl der Linienenden (Reihenfolge = Anzeige im Dropdown). */ diff --git a/src/panels/ObjectInfoPanel.tsx b/src/panels/ObjectInfoPanel.tsx index 2a943a2a..927bdc8d 100644 --- a/src/panels/ObjectInfoPanel.tsx +++ b/src/panels/ObjectInfoPanel.tsx @@ -35,7 +35,7 @@ import type { VerticalAnchor, WallReferenceLine, } from "../model/types"; -import { SIA_CATEGORIES, siaLabelFull } from "../geometry/roomArea"; +import { SIA_CATEGORIES, siaLabelFull } from "../core"; import { Dropdown } from "../ui/Dropdown"; import type { DetailLevel } from "../model/viewTypes"; import { ColorHexField } from "../ui/ColorHexField"; diff --git a/src/panels/RoomBalancePanel.tsx b/src/panels/RoomBalancePanel.tsx index e8e2d84b..dfeafb26 100644 --- a/src/panels/RoomBalancePanel.tsx +++ b/src/panels/RoomBalancePanel.tsx @@ -8,12 +8,7 @@ import { t } from "../i18n"; import { usePanelHost } from "./host"; -import { - balance, - evaluateRoom, - roomsToCsv, - siaLabelFull, -} from "../geometry/roomArea"; +import { balance, evaluateRoom, roomsToCsv, siaLabelFull } from "../core"; import type { Room } from "../model/types"; import { roomDisplayName } from "../model/roomStamp"; diff --git a/src/panels/SitePanel.tsx b/src/panels/SitePanel.tsx index 19523b29..0436bddf 100644 --- a/src/panels/SitePanel.tsx +++ b/src/panels/SitePanel.tsx @@ -19,7 +19,7 @@ import type { ContextObject } from "../model/types"; import { ContextImportDialog } from "../ui/ContextImportDialog"; import { Dropdown } from "../ui/Dropdown"; import { useStore } from "../state/appStore"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "../native/projectFile"; import { openContextImportWindowNative } from "../native/contextImportWindow"; /** Typ-spezifisches Badge-Label (i18n-Key) je Kontext-Objekt-Art. */ diff --git a/src/state/groupActions.ts b/src/state/groupActions.ts index a2dafb7d..978c9502 100644 --- a/src/state/groupActions.ts +++ b/src/state/groupActions.ts @@ -6,9 +6,9 @@ // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). import type { Drawing2D, Group, Project } from "../model/types"; -import type { Plan, UnderlayGroup } from "../plan/generatePlan"; +import type { Plan, UnderlayGroup } from "../core"; import { uniqueId } from "../tools/types"; -import type { Primitive } from "../plan/generatePlan/shared"; +import type { Primitive } from "../core"; /** Mitglieds-IDs je Elementart — dieselbe Form wie `Group`, ohne `id`/`name`/`groupIds`. */ export interface GroupMembership { diff --git a/src/state/projectSlice.ts b/src/state/projectSlice.ts index cb695896..34b9ff7d 100644 --- a/src/state/projectSlice.ts +++ b/src/state/projectSlice.ts @@ -8,7 +8,7 @@ // laufen. Die Slice tippt daher nur ihre eigenen Felder; `get()` liefert // RootState (siehe appStore.ts), wir greifen punktuell auf View-Felder zu. -import { withVertexType, type PolylineVertexType } from "../geometry/polylineVertexType"; +import { withVertexType, type PolylineVertexType } from "../core"; import { sampleProject } from "../model/sampleProject"; import { flattenCategories, @@ -38,8 +38,8 @@ import { lineIntersect } from "../model/geometry"; import { commitTransform } from "../tools/transform"; import type { CopyMode, TransformOp, TransformSelection } from "../tools/transform"; import { uniqueId } from "../tools/types"; -import { centroid as roomCentroid } from "../geometry/roomArea"; -import { bulgeArc, bulgeBetweenAngles, bulgeFromSagittaPoint, bulgePointAt, pointOnCircle } from "../geometry/bulge"; +import { centroid as roomCentroid } from "../core"; +import { bulgeArc, bulgeBetweenAngles, bulgeFromSagittaPoint, bulgePointAt, pointOnCircle } from "../core"; import { DEFAULT_SCALE_DENOMINATOR, DIM_DEFAULTS_MM, diff --git a/src/state/selectionInfo.ts b/src/state/selectionInfo.ts index bbecc11e..0423562b 100644 --- a/src/state/selectionInfo.ts +++ b/src/state/selectionInfo.ts @@ -10,7 +10,7 @@ // // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). -import { extrudedSolidSpec } from "../plan/extrudedSolidSpec"; +import { extrudedSolidSpec } from "../core"; import type { SolidSpec } from "../engine/truckSolid"; import { ceilingThickness, @@ -47,25 +47,20 @@ import type { } from "../model/types"; import type { DetailLevel } from "../model/viewTypes"; import { localToLv95 } from "../io/lv95"; -import { - resolveForeground, - resolveBackground, - resolveHatchId, - resolveStrokeWeight, -} from "../plan/generatePlan/shared"; +import { resolveForeground, resolveBackground, resolveHatchId, resolveStrokeWeight } from "../core"; import { columnVerticalExtent } from "../model/wall"; -import { columnFootprint } from "../geometry/column"; -import { evaluateRoom, polygonArea } from "../geometry/roomArea"; +import { columnFootprint } from "../core"; +import { evaluateRoom, polygonArea } from "../core"; import { ceilingVerticalExtent, nextFloorAbove, stairVerticalExtent, wallVerticalExtent, } from "../model/wall"; -import { ceilingArea, outlineBBox } from "../geometry/ceiling"; -import { roofBBox, roofBaseElevation, roofGeometry } from "../geometry/roof"; -import { openingGapQuad, openingVerticalExtent } from "../geometry/opening"; -import { stairGeometry, stairBBox } from "../geometry/stair"; +import { ceilingArea, outlineBBox } from "../core"; +import { roofBBox, roofBaseElevation, roofGeometry } from "../core"; +import { openingGapQuad, openingVerticalExtent } from "../core"; +import { stairGeometry, stairBBox } from "../core"; /** Eintrag für die WallType-Auswahl (Preset-Dropdown) im Object-Info-Panel. */ export interface WallTypeChoice { diff --git a/src/state/useExportHandlers.ts b/src/state/useExportHandlers.ts index 548b7a0f..091a3b20 100644 --- a/src/state/useExportHandlers.ts +++ b/src/state/useExportHandlers.ts @@ -5,8 +5,8 @@ // // Extrahiert aus App.tsx. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). -import { generatePlan } from "../plan/generatePlan"; -import type { CategoryDisplayResolver } from "../plan/generatePlan"; +import { generatePlan } from "../core"; +import type { CategoryDisplayResolver } from "../core"; import type { DetailLevel } from "../model/viewTypes"; import type { DisplayResolver } from "../viewport/Viewport3D"; import { savePlanPdf } from "../export/exportPdf"; diff --git a/src/state/useGripEditing.ts b/src/state/useGripEditing.ts index 1f4bbc0c..5be6940b 100644 --- a/src/state/useGripEditing.ts +++ b/src/state/useGripEditing.ts @@ -11,7 +11,7 @@ import type { Ceiling, Drawing2D, EdgeGrip, Project, Room, Stair, Vec2 } from ". import { wallTypeThickness } from "../model/types"; import { drawingVertices } from "./projectSlice"; import { areaMovePreview } from "../tools/transform"; -import { mvGeom } from "../geometry/geomTransform"; +import { mvGeom } from "../core"; import { drawingPreviewShapes } from "../tools/drawingPreview"; import type { DraftShape, SnapResult, SnapSettings, ToolDraft, ToolMods } from "../tools/types"; import { applyAngleConstraint, computeSnap } from "../tools/snapping"; diff --git a/src/state/useMouseSelectionHandlers.ts b/src/state/useMouseSelectionHandlers.ts index 1021b5fe..3536d068 100644 --- a/src/state/useMouseSelectionHandlers.ts +++ b/src/state/useMouseSelectionHandlers.ts @@ -6,7 +6,7 @@ // Extrahiert aus App.tsx. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). import type { Project, Vec2 } from "../model/types"; -import type { CategoryDisplayResolver } from "../plan/generatePlan"; +import type { CategoryDisplayResolver } from "../core"; import type { DisplayResolver } from "../viewport/Viewport3D"; import type { PlanSelection, MarqueeSelection } from "../views/plan/PlanView"; import type { Pick3dHit } from "../viewport/Wasm3DViewport"; diff --git a/src/state/usePanelHostBase.ts b/src/state/usePanelHostBase.ts index fa2f48e6..0e15b58a 100644 --- a/src/state/usePanelHostBase.ts +++ b/src/state/usePanelHostBase.ts @@ -20,7 +20,7 @@ import type { Selection } from "./selectionInfo"; import type { EngineView } from "../commands/engine"; import type { ScheduleKind } from "../export/exportSchedule"; import type { TabId as ResourceTabId } from "../ui/ResourceManager"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "../native/projectFile"; import { openDrawingLevelsWindowNative } from "../native/drawingLevelsWindow"; import { t } from "../i18n"; import { @@ -52,7 +52,8 @@ import { moveFolderToFolder, patchAnnotation as patchAnnotationInLayout, } from "../model/layoutModel"; -import { saveFolderPdf } from "../export/layoutPdf"; +import { folderPdfBytes } from "../export/layoutPdf"; +import { saveBinaryFile } from "../native/saveFile"; import type { useProjectActions } from "./useProjectActions"; import type { useSelectionState } from "./useSelectionState"; import type { useDrawingToolState } from "./useDrawingToolState"; @@ -1567,7 +1568,9 @@ export function usePanelHostBase(opts: { onExportFolderPdf: (folderId) => { const folder = (project.layoutFolders ?? []).find((f) => f.id === folderId); const name = folder?.name?.trim() || "layouts"; - void saveFolderPdf(project, folderId, name); + void folderPdfBytes(project, folderId).then((bytes) => { + if (bytes) return saveBinaryFile(bytes, `${name}.pdf`, "application/pdf"); + }); }, onMoveLayoutToFolder: (layoutId, folderId) => { setProject((p) => ({ diff --git a/src/state/useProjectFileActions.ts b/src/state/useProjectFileActions.ts index ed628942..d789f245 100644 --- a/src/state/useProjectFileActions.ts +++ b/src/state/useProjectFileActions.ts @@ -25,7 +25,7 @@ import { exportIfcSpf } from "../export/exportIfc"; import { exportProjectStep } from "../export/exportStep"; import { exportObj, exportStl } from "../export/exportMesh"; import type { ExportSaveFormat } from "../ui/ExportSaveDialog"; -import { saveTextFile } from "../io/saveFile"; +import { saveTextFile } from "../native/saveFile"; import { saveProjectFile, openProjectFileNative, @@ -35,8 +35,8 @@ import { releaseProjectLock, registerLockAutoRelease, isTauriRuntime, -} from "../io/projectFile"; -import type { LockInfo } from "../io/projectFile"; +} from "../native/projectFile"; +import type { LockInfo } from "../native/projectFile"; import { addRecentProject, removeRecentProject } from "./recentProjects"; import { emptyProject, sampleProject } from "../model/sampleProject"; import { flattenCategories } from "../model/types"; diff --git a/src/tools/drawingPreview.ts b/src/tools/drawingPreview.ts index 1fc3424a..d4c72e34 100644 --- a/src/tools/drawingPreview.ts +++ b/src/tools/drawingPreview.ts @@ -6,8 +6,8 @@ // Polylinie/Rechteck/Bild, alles andere war beim Verschieben unsichtbar). import type { Drawing2D, Project, Vec2 } from "../model/types"; -import type { Primitive } from "../plan/generatePlan"; -import { addDrawing2D } from "../plan/generatePlan/drawing2d"; +import type { Primitive } from "../core"; +import { addDrawing2D } from "../core"; import { textFrameCorners } from "../text/textFrame"; import type { DraftShape } from "./types"; diff --git a/src/tools/sheetSnapGeometry.ts b/src/tools/sheetSnapGeometry.ts index 9a2cf28b..4844d18d 100644 --- a/src/tools/sheetSnapGeometry.ts +++ b/src/tools/sheetSnapGeometry.ts @@ -6,7 +6,7 @@ // `computeSnap` liest sie für die aktive Ebene mit. import type { Vec2 } from "../model/types"; -import type { Primitive } from "../plan/generatePlan"; +import type { Primitive } from "../core"; export type SnapSeg = [Vec2, Vec2]; diff --git a/src/tools/snapping.ts b/src/tools/snapping.ts index 3a27fa55..cecf35ed 100644 --- a/src/tools/snapping.ts +++ b/src/tools/snapping.ts @@ -10,12 +10,12 @@ import type { Drawing2D, Project, Vec2, Wall } from "../model/types"; import { getWallType, wallTypeThickness } from "../model/types"; import { add, leftNormal, lineIntersect, normalize, scale, sub } from "../model/geometry"; import { wallReferenceOffset } from "../model/wall"; -import { centroid as roomCentroid } from "../geometry/roomArea"; -import { columnFootprint } from "../geometry/column"; -import { stairOutline } from "../geometry/stair"; +import { centroid as roomCentroid } from "../core"; +import { columnFootprint } from "../core"; +import { stairOutline } from "../core"; import type { SnapKind, SnapResult, SnapSettings } from "./types"; -import { sampleBezierChain, sampleCatmullRom, sampleUniformBSpline } from "../geometry/curves"; -import { buildDrawingIndex, drawingsNear, isIndexable, pointSegDist, type DrawingIndex } from "../geometry/drawingIndex"; +import { sampleBezierChain, sampleCatmullRom, sampleUniformBSpline } from "../core"; +import { buildDrawingIndex, drawingsNear, isIndexable, pointSegDist__geometry_drawingIndex as pointSegDist, type DrawingIndex } from "../core"; import { sheetSnapSegments } from "./sheetSnapGeometry"; const dist = (a: Vec2, b: Vec2): number => Math.hypot(a.x - b.x, a.y - b.y); diff --git a/src/tools/tools.ts b/src/tools/tools.ts index a6991622..d0748b44 100644 --- a/src/tools/tools.ts +++ b/src/tools/tools.ts @@ -4,7 +4,7 @@ import type { Ceiling, Drawing2D, Project, Vec2, Wall } from "../model/types"; import { wallTypeThickness } from "../model/types"; import { wallCorners } from "../model/geometry"; -import { normalizeOutline, ceilingArea } from "../geometry/ceiling"; +import { normalizeOutline, ceilingArea } from "../core"; import type { DraftShape, Tool, ToolContext, ToolDraft, ToolId } from "./types"; import { uniqueId } from "./types"; diff --git a/src/tools/transform.ts b/src/tools/transform.ts index 2e955267..78de0f52 100644 --- a/src/tools/transform.ts +++ b/src/tools/transform.ts @@ -9,7 +9,7 @@ // Bezeichner englisch, UI-Text via t() (CONVENTIONS.md). Reine Funktionen + Geometrie; // die App hält den State und wendet `commitTransform` immutabel an. -import { transformSolid } from "../plan/extrudedSolidSpec"; +import { transformSolid } from "../core"; import type { Ceiling, Column, @@ -25,11 +25,11 @@ import type { } from "../model/types"; import { wallTypeThickness } from "../model/types"; import { wallCorners } from "../model/geometry"; -import { columnFootprint } from "../geometry/column"; -import { stairOutline } from "../geometry/stair"; +import { columnFootprint } from "../core"; +import { stairOutline } from "../core"; import type { DraftShape } from "./types"; import { drawingPreviewShapes } from "./drawingPreview"; -import { mvGeom, reversesOrientation, scaleFactor, scaleGeom } from "../geometry/geomTransform"; +import { mvGeom, reversesOrientation, scaleFactor, scaleGeom } from "../core"; import { uniqueId } from "./types"; import type { CommandSelection } from "../commands/types"; diff --git a/src/ui/ColorMixer.tsx b/src/ui/ColorMixer.tsx index ed06a42e..a3535dd5 100644 --- a/src/ui/ColorMixer.tsx +++ b/src/ui/ColorMixer.tsx @@ -29,7 +29,7 @@ import { rgbToHsv, } from "../model/color"; import type { Cmyk, Hsl, Hsv, Rgb } from "../model/color"; -import { initIccColorManagement, iccColorManagementAvailable, rgbToCmykIcc, cmykToRgbIcc } from "../model/colorIcc"; +import { initIccColorManagement, iccColorManagementAvailable, rgbToCmykIcc, cmykToRgbIcc } from "../native/colorIcc"; import { SpectrumPicker } from "./SpectrumPicker"; import { Segmented } from "./resourceManager/fields"; import { t } from "../i18n"; diff --git a/src/ui/LayoutSheet.tsx b/src/ui/LayoutSheet.tsx index e5c52a5f..8af711f7 100644 --- a/src/ui/LayoutSheet.tsx +++ b/src/ui/LayoutSheet.tsx @@ -23,7 +23,7 @@ import type { LayoutViewport, Project, } from "../model/types"; -import { generatePlan } from "../plan/generatePlan"; +import { generatePlan } from "../core"; import { planToPrintSvg } from "../export/planToPrintSvg"; import { effectiveSheetSizeMm, diff --git a/src/ui/LockConflictDialog.tsx b/src/ui/LockConflictDialog.tsx index d60e20c2..9e92f4dc 100644 --- a/src/ui/LockConflictDialog.tsx +++ b/src/ui/LockConflictDialog.tsx @@ -5,7 +5,7 @@ import { useEffect } from "react"; import { t } from "../i18n"; -import type { LockInfo } from "../io/projectFile"; +import type { LockInfo } from "../native/projectFile"; export interface LockConflictDialogProps { /** Info aus der Lock-Sidecar-Datei (pid/hostname/timestamp) — kann fehlen. */ diff --git a/src/ui/StartScreen.tsx b/src/ui/StartScreen.tsx index 16c0a817..9edb6c6e 100644 --- a/src/ui/StartScreen.tsx +++ b/src/ui/StartScreen.tsx @@ -5,7 +5,7 @@ // tatsächlich laufende Version in der Fussleiste (s. update/version.ts). import { useEffect, useState } from "react"; import { getLanguage, t } from "../i18n"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "../native/projectFile"; import { APP_VERSION } from "./TopBar"; import { getRunningVersion } from "../update/version"; import { diff --git a/src/ui/hatchPreview.tsx b/src/ui/hatchPreview.tsx index fce27087..60d70488 100644 --- a/src/ui/hatchPreview.tsx +++ b/src/ui/hatchPreview.tsx @@ -10,7 +10,7 @@ import { useId } from "react"; import type { HatchStyle, LineStyle } from "../model/types"; -import { dashHasDot } from "../geometry/lineSegments"; +import { dashHasDot } from "../core"; // ── Kleiner deterministischer PRNG (mulberry32) ──────────────────────────── // Für „random"-Striche: stabil pro Seed, damit die Vorschau bei gleichem diff --git a/src/ui/resourceManager/LinesTab.tsx b/src/ui/resourceManager/LinesTab.tsx index 3731760f..0bd9679b 100644 --- a/src/ui/resourceManager/LinesTab.tsx +++ b/src/ui/resourceManager/LinesTab.tsx @@ -7,15 +7,7 @@ import type { LineStyle, Project } from "../../model/types"; import { PEN_WEIGHTS } from "../../model/types"; import { parseLin } from "../../io/linParser"; import { LineSwatch } from "../hatchPreview"; -import { - segmentsToDash, - dashToSegments, - presetOfDash, - LINE_PRESETS, - type LineSegment, - type LineSegmentType, - type LinePresetKey, -} from "../../geometry/lineSegments"; +import { segmentsToDash, dashToSegments, presetOfDash, LINE_PRESETS, type LineSegment, type LineSegmentType, type LinePresetKey } from "../../core"; import { MotifEditor } from "../MotifEditor"; import { t } from "../../i18n"; import { diff --git a/src/update/checkForUpdate.ts b/src/update/checkForUpdate.ts index 77160543..120c5b58 100644 --- a/src/update/checkForUpdate.ts +++ b/src/update/checkForUpdate.ts @@ -5,7 +5,7 @@ // weder die Plugins noch etwas zu aktualisieren. import { ask, message } from "@tauri-apps/plugin-dialog"; import { t } from "../i18n"; -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "../native/projectFile"; /** localStorage-Key fuer die Update-Pause (s. `getUpdateSnoozeUntil`). */ const SNOOZE_KEY = "dossier.updateSnoozeUntil"; diff --git a/src/update/version.ts b/src/update/version.ts index 599d6cfa..ff5ee443 100644 --- a/src/update/version.ts +++ b/src/update/version.ts @@ -2,7 +2,7 @@ // manuell gepflegte `APP_VERSION`-String in ui/TopBar.tsx) — vermeidet, dass // die Anzeige von der echten Installation abweicht, falls jemand beim // Versionsbump eine der beiden Stellen vergisst. -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "../native/projectFile"; /** `null` ausserhalb von Tauri (Vite-Dev-Server im Browser, keine Installation). */ export async function getRunningVersion(): Promise { diff --git a/src/update/versionHistory.ts b/src/update/versionHistory.ts index f55afa4a..3d63b7b7 100644 --- a/src/update/versionHistory.ts +++ b/src/update/versionHistory.ts @@ -5,7 +5,7 @@ // Release „latest" wie `latest.json`, s. checkForUpdate.ts) und bieten pro // Eintrag nur den DMG-Download im System-Browser an — Installation bleibt // der gewohnte manuelle Schritt (DMG oeffnen, App in Applications ersetzen). -import { isTauriRuntime } from "../io/projectFile"; +import { isTauriRuntime } from "../native/projectFile"; export interface VersionEntry { version: string; diff --git a/src/viewport/Wasm3DViewport.tsx b/src/viewport/Wasm3DViewport.tsx index 2aeafc72..90bd4195 100644 --- a/src/viewport/Wasm3DViewport.tsx +++ b/src/viewport/Wasm3DViewport.tsx @@ -45,8 +45,8 @@ import { useEffect, useRef, useState } from "react"; import type { Project, Wall, Drawing2D, Ceiling, Roof, Vec2 } from "../model/types"; import { ceilingVerticalExtent, wallVerticalExtent } from "../model/wall"; -import { roofBaseElevation, roofGeometry } from "../geometry/roof"; -import { projectToModel3d, pickGeometry, draftWorldLines, TRUCK_MESH_READY_EVENT } from "../plan/toWalls3d"; +import { roofBaseElevation, roofGeometry } from "../core"; +import { projectToModel3d, pickGeometry, draftWorldLines, TRUCK_MESH_READY_EVENT } from "../core"; import type { DetailLevel, RenderMode, View3d } from "../model/viewTypes"; import type { ToolDraft } from "../tools/types"; import { hudSegments, type HudFieldsState } from "../tools/hudFormat"; @@ -63,7 +63,7 @@ import { t } from "../i18n"; import { useWasm3dRenderer } from "./useWasm3dRenderer"; import type { Camera3d } from "./useWasm3dRenderer"; import { cameraRay, pickNearest, rayPlaneY, rayPlane, worldToScreen } from "./raycast3d"; -import type { Vec3 } from "./raycast3d"; +import type { Vec3 } from "../core"; import { drawingGripVertices, drawingMoveAnchor } from "./drawingGrips"; /** Ein per 3D-Klick getroffenes Bauteil, oder null (Leerraum). */ diff --git a/src/viewport/materialTextures.ts b/src/viewport/materialTextures.ts index 841626f9..ed153257 100644 --- a/src/viewport/materialTextures.ts +++ b/src/viewport/materialTextures.ts @@ -15,7 +15,7 @@ */ import type { Project } from "../model/types"; -import { wallMaterialColorMaps } from "../plan/toWalls3d"; +import { wallMaterialColorMaps } from "../core"; /** Kantenlänge einer Textur-Ebene in Texeln (muss zu render3d `TEXTURE_SIZE`). */ const TEX_SIZE = 256; diff --git a/src/viewport/raycast3d.ts b/src/viewport/raycast3d.ts index 8828441b..465b86e4 100644 --- a/src/viewport/raycast3d.ts +++ b/src/viewport/raycast3d.ts @@ -17,9 +17,8 @@ // Ortho-Zweig, keine perspektivische Näherung mehr. -import { DRAWING_PICK_TOLERANCE } from "../plan/pickTypes"; -import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh } from "../plan/pickTypes"; -export type { Vec3 } from "../plan/pickTypes"; +import { DRAWING_PICK_TOLERANCE } from "../core"; +import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh } from "../core"; /** Kamera-Parameter für den Pick-Strahl (Teilmenge von Camera3d). */ export interface RayCamera { diff --git a/src/viewport/useWasm3dRenderer.ts b/src/viewport/useWasm3dRenderer.ts index 0c533fd2..32bf9ece 100644 --- a/src/viewport/useWasm3dRenderer.ts +++ b/src/viewport/useWasm3dRenderer.ts @@ -18,7 +18,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import type { ContextImage, Project } from "../model/types"; -import { emitDrawingLineVerts, projectToModel3d } from "../plan/toWalls3d"; +import { emitDrawingLineVerts, projectToModel3d } from "../core"; import type { DetailLevel } from "../model/viewTypes"; import { loadEngine3d } from "../engine/engine3d"; import { decodeMaterialTextures } from "./materialTextures"; diff --git a/src/views/plan/PlanView.tsx b/src/views/plan/PlanView.tsx index b27ec91b..6aa3066d 100644 --- a/src/views/plan/PlanView.tsx +++ b/src/views/plan/PlanView.tsx @@ -5,7 +5,7 @@ // Polygon wird ein eigenes in definiert, damit Maßstab/Winkel/ // Farbe variieren können. -import type { PickKind } from "../../plan/pickLabels"; +import type { PickKind } from "../../core"; import { forwardRef, useEffect, @@ -15,8 +15,8 @@ import { useState, } from "react"; import type { ComponentProps, CSSProperties } from "react"; -import type { HatchRender, Plan, PlanImage, Primitive } from "../../plan/generatePlan"; -import { materializeGreyed, materializeUnderlay, type UnderlayGroup } from "../../plan/generatePlan"; +import type { HatchRender, Plan, PlanImage, Primitive } from "../../core"; +import { materializeGreyed, materializeUnderlay, type UnderlayGroup } from "../../core"; import type { Drawing2D, EdgeGrip, Vec2 } from "../../model/types"; import { t } from "../../i18n"; import type { ToolHandlers, ToolId, ToolMods } from "../../tools/types"; @@ -27,30 +27,11 @@ import { contentFontBaselineFromTop, TEXT_LINE_HEIGHT_MULT } from "../../text/fo import { textFrameCorners } from "../../text/textFrame"; import { RichTextEditor } from "../../editors/RichTextEditor"; import { useNativeAvailable, useNativePlanRenderer } from "./useNativePlanRenderer"; -import { isGpuText } from "../../plan/nativeText"; +import { isGpuText } from "../../core"; import { LiveMeet, LiveValue, createMeetStore, createValueStore } from "./planView/liveMeet"; import { useWasmPlanRenderer } from "./useWasmPlanRenderer"; import { DEFAULT_MARQUEE_COLOR, DEFAULT_SNAP_COLOR } from "../../theme/accents"; -import { - type ViewBox, - PX_PER_M, - PAD, - toScreen, - clamp, - meetScale, - scaleFromView, - viewForScale, - viewForCamera, - fitBoxFor, - pointInPolygon, - pointSegDistPx, - marqueeHit, - marqueeHitDrawings, - type ModelRect, - marqueeHitCeilings, - marqueeHitRooms, - marqueeHitStairs, -} from "../../plan/planView/geometry"; +import { type ViewBox__plan_planView_geometry as ViewBox, PX_PER_M, PAD, toScreen, clamp, meetScale, scaleFromView, viewForScale, viewForCamera, fitBoxFor, pointInPolygon, pointSegDistPx, marqueeHit, marqueeHitDrawings, type ModelRect, marqueeHitCeilings, marqueeHitRooms, marqueeHitStairs } from "../../core"; import { polyUsesPattern, HatchPattern, @@ -62,16 +43,10 @@ import { import { DraftOverlay } from "./planView/overlays"; import { PlanRulers } from "./planView/PlanRulers"; import { PlanGrid } from "./planView/PlanGrid"; -import { expandRegion, indexedInRegion, regionContains, type Bounds } from "../../plan/planView/cullPrimitives"; -import { buildSegmentIndex, nearestSegment, pointSegDist, segmentsNear } from "../../plan/planView/segmentIndex"; -import { buildOwnerIndex, ownedBy, type OwnerField, type OwnerIndex } from "../../plan/planView/ownerIndex"; -import { - buildDrawingIndex, - drawingsWithinDistance, - marqueeHitUnderlay, - nearestInDrawings, - type DrawingIndex, -} from "../../plan/planView/underlayAccess"; +import { expandRegion, indexedInRegion, regionContains, type Bounds } from "../../core"; +import { buildSegmentIndex, nearestSegment, pointSegDist__plan_planView_segmentIndex as pointSegDist, segmentsNear } from "../../core"; +import { buildOwnerIndex, ownedBy, type OwnerField, type OwnerIndex } from "../../core"; +import { buildDrawingIndex, drawingsWithinDistance, marqueeHitUnderlay, nearestInDrawings, type DrawingIndex } from "../../core"; import { endBusyAfterPaint } from "../../state/busyStore"; import { createCursorStore, useCursorValue, type CursorStore } from "../../state/cursorStore"; diff --git a/src/views/plan/nativeGl.ts b/src/views/plan/nativeGl.ts index 43a2e73e..61e83b74 100644 --- a/src/views/plan/nativeGl.ts +++ b/src/views/plan/nativeGl.ts @@ -8,7 +8,7 @@ * Frame wandert danach nur noch der Ausschnitt. */ -import type { BufferGl, GpuGeometry } from '../../plan/glPlan/glPlanTypes'; +import type { BufferGl, GpuGeometry } from "../../core"; export type NativeInvoke = (cmd: string, args?: unknown, options?: unknown) => Promise; diff --git a/src/views/plan/nativeSync.ts b/src/views/plan/nativeSync.ts index 0e69d14e..a3a40888 100644 --- a/src/views/plan/nativeSync.ts +++ b/src/views/plan/nativeSync.ts @@ -9,11 +9,11 @@ // Tauri an `window.__TAURI_INTERNALS__`; Fehler beim Invoke werden still // geschluckt (console.debug), damit die App nie daran scheitert. -import type { Plan } from "../../plan/generatePlan"; -import { materializeGreyed, materializeUnderlay } from "../../plan/generatePlan"; +import type { Plan } from "../../core"; +import { materializeGreyed, materializeUnderlay } from "../../core"; import type { Project } from "../../model/types"; -import { planToRenderScene } from "../../plan/toRenderScene"; -import { projectToModel3d, TRUCK_MESH_READY_EVENT } from "../../plan/toWalls3d"; +import { planToRenderScene } from "../../core"; +import { projectToModel3d, TRUCK_MESH_READY_EVENT } from "../../core"; /** Sammel-Fenster: Modelländerungen werden gebündelt gepusht (nicht je Frame). */ const DEBOUNCE_MS = 200; diff --git a/src/views/plan/planView/PlanGrid.tsx b/src/views/plan/planView/PlanGrid.tsx index bdce721d..f358ff99 100644 --- a/src/views/plan/planView/PlanGrid.tsx +++ b/src/views/plan/planView/PlanGrid.tsx @@ -6,7 +6,7 @@ // (`ZOOM_MIN`/`ZOOM_MAX` in PlanView.tsx) auf ≤ ~Bildschirmbreite/64px // begrenzt, unabhängig davon, wie weit heraus- oder hereingezoomt ist. -import { PX_PER_M } from "../../../plan/planView/geometry"; +import { PX_PER_M } from "../../../core"; import { rulerStep } from "./PlanRulers"; export function PlanGrid({ diff --git a/src/views/plan/planView/PlanRulers.tsx b/src/views/plan/planView/PlanRulers.tsx index 5e39190f..20c7e3d1 100644 --- a/src/views/plan/planView/PlanRulers.tsx +++ b/src/views/plan/planView/PlanRulers.tsx @@ -1,7 +1,7 @@ // Lineale oben + links (Vectorworks-Stil) am Rand der Plan-Ansicht. import type { Vec2 } from "../../../model/types"; -import { PX_PER_M } from "../../../plan/planView/geometry"; +import { PX_PER_M } from "../../../core"; /** * Schrittweite (Meter) fürs Lineal: 1/2/5·10^n, sodass Major-Ticks ≥ ~64 px diff --git a/src/views/plan/planView/primitives.tsx b/src/views/plan/planView/primitives.tsx index 3b9a98e3..28b9006d 100644 --- a/src/views/plan/planView/primitives.tsx +++ b/src/views/plan/planView/primitives.tsx @@ -3,14 +3,14 @@ // Renderer. Bekommt `toScreen`/Massstab-Parameter gereicht, kein eigener // Zugriff auf PlanView-internen State. -import type { HatchRender, Primitive } from "../../../plan/generatePlan"; -import { NO_HATCH } from "../../../plan/generatePlan/shared"; +import type { HatchRender, Primitive } from "../../../core"; +import { NO_HATCH } from "../../../core"; import { docToLines, wrapDocToLines, type SvgLine } from "../../../text/renderHtml"; import type { Vec2 } from "../../../model/types"; import { quantizePen } from "../../../export/sceneToPrintSvg"; -import { buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../plan/glPlan/glPlanHatch"; -import { dashHasDot } from "../../../geometry/lineSegments"; -import { HAIRLINE_PX, PX_PER_M, mmToPx, printStrokeVb, visibleEdgeRuns } from "../../../plan/planView/geometry"; +import { buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../core"; +import { dashHasDot } from "../../../core"; +import { HAIRLINE_PX, PX_PER_M, mmToPx, printStrokeVb, visibleEdgeRuns } from "../../../core"; /** Basis-Kachelmaß (viewBox-Einheiten) einer Bild-Schraffur bei scaleX/scaleY = 1. */ const IMG_TILE_VB = 40; diff --git a/src/views/plan/useNativePlanRenderer.ts b/src/views/plan/useNativePlanRenderer.ts index a5bde82a..aee806d3 100644 --- a/src/views/plan/useNativePlanRenderer.ts +++ b/src/views/plan/useNativePlanRenderer.ts @@ -9,14 +9,14 @@ */ import { useCallback, useEffect, useRef, useState } from 'react'; -import type { Plan } from '../../plan/generatePlan'; -import { GpuChunkCache } from '../../plan/glPlan/glPlanChunks'; -import { compilePrimitivesToGpu } from '../../plan/glPlan/glPlanCompile'; -import type { GpuGeometry, ViewBox } from '../../plan/glPlan/glPlanTypes'; -import type { Primitive } from '../../plan/generatePlan'; +import type { Plan } from "../../core"; +import { GpuChunkCache } from "../../core"; +import { compilePrimitivesToGpu } from "../../core"; +import type { GpuGeometry, ViewBox__plan_glPlan_glPlanTypes as ViewBox } from "../../core"; +import type { Primitive } from "../../core"; import { NativeGl, type NativeInvoke } from './nativeGl'; import { readCssColor } from './cssColor'; -import { NativeTextSync } from '../../plan/nativeText'; +import { NativeTextSync } from "../../core"; /** Läuft die App in einer Tauri-Webview? */ const isTauri = (): boolean => typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window; diff --git a/src/views/plan/useWasmPlanRenderer.ts b/src/views/plan/useWasmPlanRenderer.ts index 6cc17d70..e967c5c3 100644 --- a/src/views/plan/useWasmPlanRenderer.ts +++ b/src/views/plan/useWasmPlanRenderer.ts @@ -13,8 +13,8 @@ */ import { useCallback, useEffect, useRef, useState } from "react"; -import type { Plan } from "../../plan/generatePlan"; -import { planToRenderScene } from "../../plan/toRenderScene"; +import type { Plan } from "../../core"; +import { planToRenderScene } from "../../core"; interface ViewBox { x: number; diff --git a/src/views/viewportContent.tsx b/src/views/viewportContent.tsx index 980b3014..6bb2f1ee 100644 --- a/src/views/viewportContent.tsx +++ b/src/views/viewportContent.tsx @@ -19,20 +19,20 @@ import type { Vec2, Wall, } from "../model/types"; -import { categoryNameForPick } from "../plan/pickLabels"; -import type { PickKind } from "../plan/pickLabels"; -import { generatePlan, generateSectionPlan, generateVisibleLevelsPlan } from "../plan/generatePlan"; -import type { CategoryDisplayResolver, Plan, Primitive } from "../plan/generatePlan"; +import { categoryNameForPick } from "../core"; +import type { PickKind } from "../core"; +import { generatePlan, generateSectionPlan, generateVisibleLevelsPlan } from "../core"; +import type { CategoryDisplayResolver, Plan, Primitive } from "../core"; import type { RichTextDoc } from "../text/richText"; -import { computeSection, sameSectionInputs, sameSectionLine } from "../plan/toSection"; -import type { SectionOutput } from "../plan/toSection"; -import { generateElevationPlan } from "../plan/toElevation"; -import { crossKindOverlayAllowed, planUnderlayPrimitives } from "../plan/planUnderlay"; -import { sectionOpeningPrimitives } from "../plan/sectionOpenings"; -import { levelMarkerPrimitives, levelMarksEnabled } from "../plan/levelMarkers"; +import { computeSection, sameSectionInputs, sameSectionLine } from "../core"; +import type { SectionOutput } from "../core"; +import { generateElevationPlan } from "../core"; +import { crossKindOverlayAllowed, planUnderlayPrimitives } from "../core"; +import { sectionOpeningPrimitives } from "../core"; +import { levelMarkerPrimitives, levelMarksEnabled } from "../core"; import { setSheetOwnerOutlines, setSheetSnapSegments, snapSegmentsFromPrimitives } from "../tools/sheetSnapGeometry"; import { pushNativeScene, pushNativeWalls } from "./plan/nativeSync"; -import { selectionHighlightLines } from "../plan/toWalls3d"; +import { selectionHighlightLines } from "../core"; import { applyGroupDimmingToPlan } from "../state/groupActions"; import { PlanView } from "./plan/PlanView"; import type {