Skip to content
Shapemetry

Guide

What it is: the shared type contract — every type the live packages share (geometry, model, hosts) is declared here. There is no second place.

Declarations only. No runtime code, no const, no functions, no dependencies - the package compiles to an empty module.

Design laws

  1. Imports nothing. Types sits BELOW all packages in the dependency graph; importing one would invert the arrows.
  2. Cross-boundary only. A type moves in when a SECOND package needs it - never speculatively.
  3. One declaration, both sides. The exchange format is declared once. The goal is to retire unchecked JSON.parse(...) as X casts: the producer's return type IS the consumer's expectation.
pnpm add @huukhanhnguyen/types
import type {
  Point, BoundingBox, BoundingBox2d, Curve2d,
  ObjectNode, BlockNode, ObjectNodeBase, SceneNode,
  SceneObject, ObjectData, CameraObject, Page, BrepData,
} from '@huukhanhnguyen/types'

Object tier: identity is the object's key. Mid-chain stream is ObjectData (*Data). Page.objects is SceneObject[]. CameraData is projection only (fov | height); placement is CameraObject.instances[i]. Two kinds carry an Entity tier over their *Data for what only a viewport needs: LightEntity = LightData & { target?, gizmoSize? } and CameraEntity = CameraData & { gizmoSize? } — one Entity each, wrapping the whole union, never one per shape or projection arm.

Modules

Last updated: 📖 1 min readEdit on GitHub