WebAssembly and JavaScript
loadDIPL parses text and projects and exposes the inspection model.
Basic examples
After building the web module, parse text and inspect a value:
import { loadDIPL } from "./bindings/web/index.mjs";
const dipl = await loadDIPL();
const model = dipl.parse("distance float = 24 m");
console.log(model.describe("distance").valueText); // 24
model.dispose();
Evaluate a replacement input without changing the original model:
import { loadDIPL } from "./bindings/web/index.mjs";
const dipl = await loadDIPL();
const model = dipl.parse("steps int = 100");
const candidate = model.withOverride("steps = 200");
console.log(candidate.describe("steps").valueText); // 200
candidate.dispose();
model.dispose();
Common workflows
Task |
Call chain |
Result |
|---|---|---|
Initialize DIPL |
|
Runtime object |
Parse text |
|
|
Parse project input |
|
|
Discover paths |
|
|
Describe values |
|
|
Inspect schemas |
|
|
Reevaluate an override |
|
New |
Validate without evaluating |
|
|
Release a model |
|
No result |
import { loadDIPL } from "./bindings/web/index.mjs";
const dipl = await loadDIPL(); // runtime object
const source = `
distance float = 24 m
duration float = 8 s
speed float = ({?distance} / {?duration}) m/s`;
const model = dipl.parse(source); // DIPLModel
console.log(model.paths()); // string[]
console.log(model.describeMany(["distance", "speed"]));
const candidate = model.withOverride("distance = 32 m");
console.log(candidate.describe("speed").valueText); // string | null
const validation = dipl.validate(source, "missing = 1");
if (!validation.valid && validation.diagnostic) {
console.error(validation.diagnostic.message,
validation.diagnostic.details,
validation.diagnostic.suggestion);
}
candidate.dispose();
model.dispose();
withOverride creates a separate evaluated model and does not mutate the
original. Dispose every model; validation results contain plain records and
need no cleanup.
See the WebAssembly guide for project bundles, overrides, and schema inspection, and DIP inspection for the related native API.
DIPL developer tools. The web binding provides validate(),
validateProject(), and validateBundle() with structured diagnostics.
It does not expose the formatter or linter. Use the CLI or C++ tools for
formatting and linting; see the DIPL developer tools page.
Current limitations and differences
Compared with the canonical C++ implementation:
Inputs are text or supplied project bundles. The binding does not open arbitrary host files or load/save DIPH5 archives.
Results are bounded JavaScript descriptions rather than native Environment and Cursor objects.
withOverride()creates a separate model; it does not write source files. Release each model withdispose().Native adapters, exports, reports, snapshot comparison, editing/setup sessions, and experiment recording are not exposed.
validate(),validateProject(), andvalidateBundle()are available. The formatter and linter are not; use the CLI or C++ tooling API.
Binding reference
This is a lookup index, not a sequence to read from top to bottom. Use Common workflows above to choose a task, then find the exact JavaScript name below. Methods are shown with parentheses; properties and option fields are shown without them. The TypeScript declarations are the complete source for input and result shapes.
Load and evaluate
loadDIPL(options?).dipl.parse(source),dipl.parseProject(project), anddipl.parseBundle(bundle).dipl.validate(source, overrideBody?),dipl.validateProject(project, overrideBody?), anddipl.validateBundle(bundle, overrideBody?).
Model inspection and previews
model.paths().model.describe(path, maxValueElements=16)andmodel.describeMany(paths, maxValueElements=16).model.schemas()andmodel.withOverride(body).model.dispose()after the model is no longer needed.
Input and result types
ProjectInputfieldsunits,schemas,code, andoverrides; each entry is{name, text}.ProjectBundlewithformat,entry, and{path, text}files.Description,Metadata,SchemaHierarchy,Validation,Diagnostic, andSourceLocation.