The 54 editor engine tests move to packages/core/tests/editor with their helpers, importing Core's public subpaths or source modules relatively. The package gains test and typecheck scripts; the first type check fixed nullable lookups, stale imports, and renderer doubles, and graph events now declare the GraphEventRenderer surface they invalidate. The engine baseline drops to 534 files.
13 lines
405 B
TypeScript
13 lines
405 B
TypeScript
import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
|
|
|
|
export function expectDefined<T>(value: T | null | undefined, label = 'value'): NonNullable<T> {
|
|
if (value == null) {
|
|
throw new Error(`${label} was expected to be defined`)
|
|
}
|
|
return value
|
|
}
|
|
|
|
export function getNodeOrThrow(graph: SceneGraph, id: string): SceneNode {
|
|
return expectDefined(graph.getNode(id), `node ${id}`)
|
|
}
|