feat(app): editor views tab, drawing upload and cleaning, guarded crops

This commit is contained in:
bchanot committed 2026-11-04 13:02:30 +01:00
1 parent d163b2ce9a
commit 8343528be9
22 files changed
+2164 -4

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import type { DetailView, SheetView } from '@faunosteo/core-wasm/types'
import { geometryAccept, type GeometryRefusal } from './issues'
import { useEditorStore } from './state/editorStore'
import type { CommitOutcome } from './state/editorTypes'
export type ViewPatch = Partial<
Pick<DetailView, 'name' | 'svg_asset_id' | 'view_box' | 'parent_view_id'>
>
/**
* One `update` of a view through the store. A frame change (drawing, crop, parent) is
* `guarded`: the core's geometry verdict decides through `geometryAccept`, so no annotation
* gets a geometry error it did not have and no measured view becomes unmeasured.
*/
export function updateView(
viewId: string,
patch: ViewPatch,
guarded: boolean,
): CommitOutcome<GeometryRefusal> {
const store = useEditorStore.getState()
const before = store.previewState
const view = before?.document.views.find(
(candidate) => candidate.id === viewId,
)
if (!before || !view)
return { ok: false, reason: 'blocked', kind: 'not_ready' }
const value = { ...view, ...patch } as SheetView
return store.commit(
{
op: 'update',
key: { kind: 'view', id: viewId },
element: { kind: 'view', value },
},
guarded
? { accept: geometryAccept({ before, changedIds: [] }) }
: undefined,
)
}