feat(editor): the canvas draws the view the Rust core composed; denylist and anatomy dependency removed
This commit is contained in:
1 parent
43a370aed1
commit
09a6cf7def
11 files changed
+165
-158
No files matched your search
@@ -10,6 +10,7 @@ import type {
|
||||
SheetView,
|
||||
VertebralRegion,
|
||||
} from '@faunosteo/core-wasm/types'
|
||||
import type { CoreOutcome } from '@faunosteo/core-wasm'
|
||||
import type { SheetOps } from '@/core/sheetOps'
|
||||
|
||||
/**
|
||||
@@ -29,8 +30,6 @@ export interface LoadedSheetView {
|
||||
schemaVersion: number
|
||||
/** The document as the core parsed it (defaults filled in). */
|
||||
document: AnatomicalSheetDocument
|
||||
/** SVG text by `svg_asset_id` (the canvas draws them until R3). */
|
||||
assets: Readonly<Record<string, string>>
|
||||
}
|
||||
|
||||
function at<T>(
|
||||
@@ -53,10 +52,11 @@ export class SheetIndex {
|
||||
readonly mainViewId: string
|
||||
private readonly spine: ReadonlySet<string>
|
||||
private readonly nodes: ReadonlySet<string>
|
||||
/** The composed canvas of each view: constant for a loaded sheet, composed once (R3). */
|
||||
private readonly canvases = new Map<string, string>()
|
||||
|
||||
constructor(
|
||||
private readonly data: SheetIndexData,
|
||||
assets: Readonly<Record<string, string>>,
|
||||
readonly ops: SheetOps,
|
||||
) {
|
||||
const { document } = data
|
||||
@@ -66,13 +66,22 @@ export class SheetIndex {
|
||||
speciesId: data.speciesId,
|
||||
schemaVersion: data.schemaVersion,
|
||||
document,
|
||||
assets,
|
||||
}
|
||||
this.mainViewId = data.mainViewId
|
||||
this.spine = new Set(data.spineIds)
|
||||
this.nodes = new Set(data.nodeKeys)
|
||||
}
|
||||
|
||||
/** The SVG text of a view's canvas (sanitised drawing + annotation layer), from the core. */
|
||||
canvasSvg(viewId: string): CoreOutcome<string> {
|
||||
const known = this.canvases.get(viewId)
|
||||
if (known !== undefined) return { ok: true, value: known }
|
||||
const outcome = this.ops.canvasView(viewId)
|
||||
if (!outcome.ok) return outcome
|
||||
this.canvases.set(viewId, outcome.value.svg)
|
||||
return { ok: true, value: outcome.value.svg }
|
||||
}
|
||||
|
||||
view(id: string): SheetView | undefined {
|
||||
return at(this.data.document.views, this.data.viewById, id)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user