DotchalkCompilationService

Compiles chalk source into an internote document, with the canvas environments' refinement and validation applied.

@internote/canvas-sdk/compileClass
On this page
import { DotchalkCompilationService } from '@internote/canvas-sdk/compile';

compile(source, constants?, files?, packs?) runs the four steps in order: the wasm compiler against the library built from every registered environment, the refiner pass that re-reads custom-typed attribute values from the strings the compiler carried them as, the semantic pass, and the result envelope. An error at any step is returned, never thrown, as a CompileResult whose ok is false. validate(source) is the same compile reduced to whether it succeeded.

The service holds no state, so the shared dotchalkService serves every caller. It throws on the first compile if no environment has been registered, naming what to call, rather than reporting every environment node as unknown.

#Signature

typeof DotchalkCompilationService

#Example

registerEnvironment(greetingSpec);
const result = dotchalkService.compile(source);
if (!result.ok) throw new Error(result.error);
mount(result.data);

Declared in packages/canvas-sdk/src/compile/index.ts:131.

Last updated