Model - Sheets
API reference for src/lanes/sheets/sheets, src/document/sheets, src/schema/sheets on @huukhanhnguyen/model, reachable from ..
See the Guide for the ModelJSON / evaluate pipeline.
API reference
Signatures are generated from the live package .d.ts - not hand-written.
contentFill
function
Fraction of area the entities cover — the minContentFill measurement.
contentFill(entities: Entity[], area: Rect): numberdrawingIndexEntities
function
drawingIndexEntities(sheets: { key: string; title: string; }[], size: { width: number; height: number; }, info: { author?: string; date?: string; owner?: string; checker?: string; units?: string; }): ResolvedSheetisLayoutSheetJSON
function
Drawing-sheet RUNTIME — the guards that narrow an unknown value to one of the evaluated sheet records.
The records (LayoutSheet / ResolvedSheet / ResolvedSheetValue / SheetSetEntry) are declared in @huukhanhnguyen/types and re-exported from this package's barrel.
isLayoutSheetJSON(value: unknown): value is LayoutSheetisResolvedSheet
function
isResolvedSheet(value: unknown): value is ResolvedSheetisResolvedSheetValue
function
isResolvedSheetValue(value: unknown): value is ResolvedSheetValueisSheetSetEntry
function
isSheetSetEntry(value: unknown): value is SheetSetEntrypaperSizeName
function
paperSizeName(size: { width: number; height: number; }): stringresolveSheet
function
Compose one sheet into flat sheet-space entities. See the module doc for the coordinate convention and the SheetResolveOptions contract.
resolveSheet(scene: Entity[], sheet: Sheet, options?: SheetResolveOptions): ResolvedSheetresolveSheetParams
function
Read sheet paper/scale from parameters[] (literal primary-arg values), falling back to the builtins. Same activation-by-declaration law every lane builtin follows (resolveLaneBuiltins), plus the two sheet-local rules: paper must be positive, and scale widens to a number.
resolveSheetParams(sheet: Sheet): { paperWidth: number; paperHeight: number; scale: number | "auto"; }scaleCandidates
function
Standard drawing scale sequence: {1,2,5}×10^n and reciprocals, largest first.
scaleCandidates(): number[]scaleLabel
function
scaleLabel(scale: number): stringSHEET_BUILTIN_PARAMS
const
Default paper size (A3 landscape mm) + scale — the values slice of the ONE lane-builtin table (schema/vocabulary/builtinParams.ts), re-exported here where every sheet consumer already looks. Declaring a matching key in sheet.parameters overrides; scale default expression when seeding is "'auto'".
const SHEET_BUILTIN_PARAMS: BuiltinValues<{ readonly paperWidth: { readonly default: 420SheetEvaluation
type
What Model.evaluateSheet answers with.
A UNION, not a warnings field beside the sheet, because the failure mode being fixed is a consumer that reads .value.entities and renders a page that LOOKS finished. A field is ignorable by doing nothing; this shape is not reachable at all without naming which case you are in, so "I forgot to check" becomes a compile error rather than a drawing with a view missing.
Measured (parashape sheetSurface fixture): a literal window drew 80 entities with sourceKey stamps [["group1",6],["undefined",74]]; the same window with an undefined variable drew 74, stamps [["undefined",74]]. The 6 stamped entities vanish, placementsOf then skips a placement with no stamped entities, and the placed view is gone from the sheet with a console line as its only trace.
partial still carries the sheet: the drawing that DID compose is worth showing beside "this view could not be placed because: …". What it must not do is arrive looking whole.
type SheetEvaluation
// = {
status: "complete";
sheet: ResolvedSheet;
}sheetFrame
function
The ISO 5457 frame: the BORDER line (binding edge wider) and the rectangle INSIDE the zone band — everything a sheet draws lives in the latter.
sheetFrame(size: { width: number; height: number; }): { border: Rect; inner: Rect; }SheetResolveOptions
type
type SheetResolveOptions
// = {
/** The model's named `views[]` lane — a top-level `viewEntity` node with
* no `at` arg (the auto-tile bucket, see autoTileViewSpecs) resolves
* its `source` key against this. */
views?: View[];
materials?: Material[];
/** Forwarded verbatim to each auto-tiled view's own resolveView call —
* a `viewDetail` head reads its flat component through it (see
* ResolveViewOptions.resolveDetail in views.ts). A POSITIONED
* `viewEntity` (one with `at`) goes the other way round, through
* resolveFlatOperations → Model's own view node. */
resolveDetail?: (source: string) => Entity[];
/** Resolves the sheet's own `operations` (everything past the extracted
* auto-tile view nodes — flat lane, authored in sheet mm, y UP from the
* paper's bottom-left, CAD paper-space convention: `viewEntity`/
* `tableEntity`/`imageEntity` place shared content by
* key with their own `at`/`scale`) — `Model`'s flat evaluator bound.
* `parameters` is the SHEET'S OWN signature, forwarded so the isolated
* scope those operations evaluate in can bind it (2026-07-26 — a free
* sheet parameter used to be inert). Passed from here rather than closed
* over by the caller because `drawingSetToSvg` runs one callback across
* every sheet in the set. */
resolveFlatOperations?: (operations: (Operation | Container)[], parameters?: (Operation | Container)[]) => Entity[];
/** Evaluates `sheet.title` — an expression like every other authored
* string (titleValue law: eval, else the literal). Absent (a bare-engine
* caller with no registry) leaves the title literal. */
evaluateExpression?: (expr: string) => unknown;
titleAuthor?: string;
date?: string;
/** "Owner / Project" — the issuing company or project name. */
owner?: string;
/** "Checked" — the reviewer's name/initials. */
checker?: string;
/** "Rev" — issue revision code. Defaults to "-" (first issue, unrevised). */
revision?: string;
/** "Sheet" — this sheet's position in the set, e.g. "2 of 7". */
sheetOf?: string;
/** "Units" — the document's display unit. Defaults to "mm". */
units?: string;
}SheetWarning
type
One placement that did NOT make it onto the sheet, and why. step is the operation key (placedView, a table placement, …) whose fold failed; reason is that step's own error message.
type SheetWarning
// = {
step: string;
method: string;
reason: string;
}tableEntities
function
One TableValue as sheet-space entities: frame + separators as curves, title/header/cells as text marks. Cells formatted at draw time from ColumnMeta.
tableEntities(table: TableValue & { title?: string; columnWidths?: number[]; }, at: [number, number]): Entity[]tableHeight
function
Total sheet-mm height a table occupies (title + header + data rows).
tableHeight(table: TableValue & { title?: string; }): numberTitleBlockInfo
type
Values for the standard's title-block fields, keyed by TitleBlockField.source.
type TitleBlockInfo
// = Partial<Record<TitleBlockField["source"], string>>