SemanticContext

What an environment's validate hook is handed: somewhere to report to, and the document facts a rule needs that the node itself does not carry.

@internote/canvas-sdkInterface
On this page
import { SemanticContext } from '@internote/canvas-sdk';

Deliberately small. It is the whole surface an environment's rules may depend on, so widening it is a decision rather than an accident. Anything not here is a fact about the node, which the node already has.

#Fields

datasetsRequired
The document's @data datasets by id, which a data: #id binding resolves against.
Record<string, unknown>
parametersRequired
The name of every parameter the enclosing scene's controls declare, wherever each control is written — the scene detail, this environment or the one beside it.
ReadonlySet<string>
reportRequired
Records a diagnostic. An error fails the compile; a warning rides along with it.
void
stepCountRequired
How many steps the enclosing scene has, for anchor-range rules.
number

#Example

validate(environment, ctx) {
    for (const mark of nodesOf(childNodes(environment.body), 'series')) {
        if (!attrString(mark, 'values')) ctx.report('error', 'plot/series-values', 'a series needs values:', mark);
    }
}

Declared in packages/canvas-sdk/src/environment/compile-spec.ts:211.

Last updated