// Moket Plugin SDK 1 (Moket 2026.10.20-a29c23b): what a plugin's module imports // from '@moket/plugin-sdk'. Write a plugin: https://app.moket.io/help/plugins/write-a-plugin /** Types the default export of a plugin's module. */ export declare const definePlugin: (plugin: T) => T; /** * Fails the feature with a message for the person, on a param when `path` * names one: `throw fail('The pitch is longer than the line', 'pitch')`. */ export declare function fail(message: string, path?: string): Error; /** What a plugin feature changed; like a built-in feature's result. */ export interface PluginBuildResult { bodies?: Readonly>; removes?: readonly Uuid[]; tools?: ToolSet; /** Lines drawn on bodies: stitches, fold lines. */ marks?: readonly FeatureMark[]; /** Bodies whose earlier marks `marks` replace (a fold moves them). */ replacesMarks?: readonly Uuid[]; /** JSON for later features and exports, at most 1 MB. */ data?: unknown; /** Looks of bodies it made or changed: a finish id and a colour. */ appearances?: Readonly>; } export interface PluginContext { readonly feature: { readonly id: Uuid; readonly name: string }; readonly kernel: PluginKernel; /** A number param's evaluated value, in mm, rad or plain. */ value(name: string): number; body(id: Uuid): Promise; /** Every body of the model before this feature. */ bodies(): Promise>; sketch(id: Uuid): Promise; plane(id: Uuid): Promise; /** Tool solids an earlier feature applied. */ tools(id: Uuid): Promise; /** A face or edge by its topological name (ADR-003). */ resolve(ref: TopoRef, body?: Uuid): Promise; context(ref: Uuid): Promise; /** Marks earlier features drew on a body (stitches). */ marks(body: Uuid): Promise; /** What an earlier feature gave in its result's `data`. */ data(feature: Uuid): Promise; /** A document parameter's value as text, without its unit. */ parameterText(name: string): Promise; /** Kept for code written for built-in features: shapes free on their own. */ temp(shape: ShapeId): ShapeId; report(report: PluginReport): void; } export interface PluginFeature

{ build(ctx: PluginContext, params: P): Promise; } /** Kernel operations a plugin may call; `release` frees nothing early. */ export type PluginKernel = Omit< GeometryKernel, | 'releaseAll' | 'heapStats' | 'version' | 'importStepParts' | 'exportStepAssembly' >; /** The default export of a plugin's module. */ export interface PluginModule { /** By feature type, one for each feature of the manifest. */ features: Readonly>; /** By export id, one for each export of the manifest. */ exports?: Readonly>; } /** A warning or a note on the feature, shown with its other diagnostics. */ export interface PluginReport { severity: 'warning' | 'info'; message: string; /** The param it is about: `pitch`. */ path?: string; details?: Record; } /** Params of a curves pick: sketch entity ids. */ export interface CurvesValue { sketch: Uuid; curves: string[]; } /** A plugin feature's params, as stored in the document. */ export type PluginParams = Record; /** Params of a regions pick. */ export interface RegionsValue { sketch: Uuid; /** Region keys (`SketchRegion.key`); every primary region when omitted. */ regions?: string[]; } export type ExportFormat = 'pdf-tiled' | 'pdf' | 'svg' | 'dxf'; export type FeatureDecl = { type: string; version: number; label: string; params: Record; description?: string; icon?: string; }; export type PluginManifest = { id: string; name: string; version: string; sdk: number; main: string; features: FeatureDecl[]; exports: { id: string; label: string; formats: ('pdf-tiled' | 'pdf' | 'svg' | 'dxf')[]; }[]; author?: string; description?: string; homepage?: string; workbench?: { label: string; tools: string[] }; }; /** Expressions with the document's parameters, evaluated before `build`. */ export type NumberKind = 'length' | 'angle' | 'count' | 'number'; export type ParamDecl = | { kind: NumberKind; default?: string; check?: 'positive' | 'nonzero' | 'nonnegative'; optional?: boolean; label?: string; hint?: string; } | { kind: 'boolean'; default?: boolean; label?: string; hint?: string } | { options: string[]; kind: 'choice'; labels?: string[]; default?: string; label?: string; hint?: string; } | { kind: 'text'; default?: string; maxLength?: number; label?: string; hint?: string; } | { kind: 'regions'; optional?: boolean; label?: string; hint?: string } | { kind: 'curves'; min?: number; max?: number; optional?: boolean; label?: string; hint?: string; } | { kind: 'faces'; min?: number; max?: number; optional?: boolean; label?: string; hint?: string; } | { kind: 'edges'; min?: number; max?: number; optional?: boolean; label?: string; hint?: string; } | { kind: 'bodies'; modifies?: boolean; min?: number; max?: number; optional?: boolean; label?: string; hint?: string; } | { kind: 'newBody'; label?: string; hint?: string } | { kind: 'feature'; types?: string[]; optional?: boolean; label?: string; hint?: string; }; export type ParamKind = NumberKind | PickKind | 'boolean' | 'choice' | 'text' | 'newBody'; /** Picks of things in the model, stored as ids or topological names. */ export type PickKind = 'regions' | 'curves' | 'faces' | 'edges' | 'bodies' | 'feature'; export interface ExportContext { /** The plugin's features of the document in timeline order, built ones only. */ readonly features: readonly ExportFeature[]; } /** A feature of the plugin, for its exports: its result's `data`. */ export interface ExportFeature { id: Uuid; type: string; name: string; data: unknown; } export interface ExportLayout { items: LayoutItem[]; } /** One thing to lay out: a piece of a pattern, in its own coordinates. */ export interface LayoutItem { /** Stable across exports: the feature it comes from. */ id: string; /** "Outer". */ label: string; /** "cut 1 ยท veg-tan 1.4 mm". */ detail?: string; shapes: LayoutShape[]; } export type LayoutShape = | { kind: 'path'; layer: string; points: Vec2[]; closed?: boolean; dashed?: boolean; } | { kind: 'circle'; layer: string; center: Vec2; radius: number; dashed?: boolean; } | { kind: 'text'; layer: string; at: Vec2; text: string; /** Cap height, mm. */ height: number; /** rad, counter-clockwise. */ angle?: number; anchor?: 'start' | 'middle' | 'end'; }; export type PluginExport = (ctx: ExportContext) => Promise; export declare const faceName: ( feature: string, role: string, source?: string, ) => string; /** Names edges by their adjacent faces' names. */ export declare function nameEdges( faces: string[], topology: Topology, fragile: Set, raw?: boolean, ): NamedTopology; export declare function nameResult(input: NameResultInput): NamedTopology; /** * Seeds for an extrusion or revolution: the caps by role, every side face by * the stable id of the sketch segment it was swept from. * * @param segmentEdges `makeProfileFace` output: profile edge index per * [loop][segment]. * @param segmentIds stable sketch entity ids in the same [loop][segment] shape. */ export declare function sweepSeeds( sweep: SweepInfo, segmentEdges: readonly (readonly number[])[], segmentIds: readonly (readonly string[])[], ): Map; /** Feature semantics for a result face, e.g. the end cap of an extrusion. */ export interface FaceSeed { role: string; source?: string; } export interface NamedTopology { /** Name per face index of the shape. */ faces: readonly string[]; /** Name per edge index of the shape. */ edges: readonly string[]; /** Names that needed a geometric ordinal and may not survive edits. */ fragile: ReadonlySet; } export interface NameResultInput { /** Stable UUID of the feature that produced the shape. */ feature: string; /** Names of the operation inputs, by argument index (empty for primitives). */ inputs: readonly NamedTopology[]; history?: ShapeHistory; /** Topology of the result shape. */ topology: Topology; /** Roles the feature assigns to result faces by index; win over history. */ seeds?: ReadonlyMap; /** Role for faces generated from input edges, e.g. 'blend' for fillets. */ generatedRole?: string; /** * Leaves duplicate names as they are, for intermediate shapes such as * tools joined before they meet the body: the result they end up in * numbers its duplicates once. */ raw?: boolean; } /** A body in the model state between features. */ export interface BodyState { shape: ShapeId; topology: Topology; named: NamedTopology; } /** A body's look a feature gives, under the body's and over the part's. */ export interface FeatureAppearance { finish: string; color?: string; } /** * A line a feature draws on a body without changing its shape (ADR-006): a * plugin's stitches and fold lines. Hidden with its body; a later feature * that moves the body (a fold) gives the body's marks again, moved. */ export interface FeatureMark { /** The body it is drawn on. */ body: Uuid; /** `stitch`: a dash between each pair of points; `fold`: dashed; `line`: solid. */ style: 'stitch' | 'fold' | 'line'; points: readonly Vec3[]; closed?: boolean; } export type ResolvedRef = | { ok: true; body: Uuid; index: number; fragile: boolean } | { ok: false; diagnostic: Diagnostic; /** What an ambiguous name matches, for callers that need less than one sub-shape (a plane). */ candidates?: readonly { body: Uuid; index: number }[]; }; /** A closed region of a sketch: outer loop first, holes after it. */ export interface SketchRegion { /** * Stable key: the sorted ids of the outer loop's curves. Survives dimension * changes, so features can store which regions they use. */ key: string; loops: readonly ProfileLoop[]; /** Sketch entity id per [loop][segment], for naming side faces. */ segmentIds: readonly (readonly string[])[]; /** Outer boundary and holes as polygons in sketch coordinates, for display and picking. */ polygon: readonly (readonly [number, number])[]; holes: readonly (readonly (readonly [number, number])[])[]; area: number; /** * Regions a feature uses when it names none: outer loops with their holes * (even nesting depth). The insides of holes are regions too, but only * when picked. */ primary: boolean; } /** A solved sketch in the model state. */ export interface SketchState { plane: Plane; regions: readonly SketchRegion[]; /** Solved entities in sketch coordinates. */ entities: readonly SketchEntity[]; /** Outlines of its texts, as polylines by text, for drawing (ADR-021). */ outlines?: readonly { id: string; points: readonly Vec2[] }[]; /** Remaining degrees of freedom; 0 = fully defined. */ dof: number; } /** * Tool solids a feature applied to bodies (Extrude, Revolve, Hole). A feature * pattern transforms and re-applies them. */ export interface ToolSet { shapes: readonly BodyState[]; operation: 'join' | 'cut' | 'intersect'; targets: readonly Uuid[]; } export interface KernelError { code: string; message: string; /** The input that failed when the kernel can tell (a draft's face, a loft's section). */ index?: number; } export type KernelResult = ({ ok: true } & T) | { ok: false; error: KernelError }; export interface OpResult { shape: ShapeId; history: ShapeHistory; } export interface Plane { origin: Vec3; normal: Vec3; xDir: Vec3; } /** Closed loops in plane coordinates: the first is outer, the rest are holes. */ export type ProfileLoop = readonly ProfileSegment[]; export type ProfileSegment = | { kind: 'line'; a: Vec2; b: Vec2 } | { kind: 'arc'; center: Vec2; radius: number; start: Vec2; end: Vec2; ccw: boolean; } | { kind: 'circle'; center: Vec2; radius: number } /** * A clamped B-spline (ADR-021): it starts at its first pole and ends at * its last. Sketch splines; text outlines as quadratic and cubic Beziers * (one knot span). */ | { kind: 'bspline'; poles: readonly Vec2[]; /** Distinct knots, increasing. */ knots: readonly number[]; /** One per knot; they add up to poles + degree + 1. */ multiplicities: readonly number[]; degree: number; /** Rational splines: one per pole, positive. */ weights?: readonly number[]; }; /** * Keyed by the kind of the input sub-shapes. Sub-shape indices are 0-based * positions in the kernel's canonical enumeration of a shape (stable for the * same shape, not across rebuilds), the same indices `topology()` reports. * `input` is the argument index (boolean: 0 = a, 1 = b; others: 0). */ export interface ShapeHistory { faces: SubShapeHistory; edges: SubShapeHistory; vertices: SubShapeHistory; } /** * Handle of a shape inside one kernel instance. Not persistent: it is only * valid until released or until the kernel restarts. Document entities use * stable UUIDs and map to handles at rebuild time. */ export type ShapeId = number; export interface SweepResult extends OpResult { sweep: SweepInfo; } export interface Topology { faces: readonly FaceInfo[]; edges: readonly EdgeInfo[]; vertices: readonly VertexInfo[]; } export type Vec2 = readonly [number, number]; export type Vec3 = readonly [number, number, number]; export type Uuid = string; export type TopoRef = { readonly kind: 'face' | 'edge' | 'vertex'; readonly name: string; readonly hint?: { readonly type?: string; readonly point?: readonly number[]; readonly normal?: readonly number[]; readonly measure?: number; }; }; export type ContextCopy = | { readonly kind: 'plane'; readonly origin: readonly number[]; readonly normal: readonly number[]; readonly xDir: readonly number[]; } | { readonly kind: 'edge'; readonly curve: 'line' | 'circle'; readonly start: readonly number[]; readonly end: readonly number[]; readonly length: number; readonly axis?: { readonly origin: readonly number[]; readonly dir: readonly number[]; }; readonly radius?: number; }; export interface GeometryKernel { version(): Promise; heapStats(): Promise; makeBox( dx: number, dy: number, dz: number, ): Promise>; makeCylinder( axisOrigin: Vec3, axisDir: Vec3, radius: number, height: number, ): Promise>; /** * Builds a planar face. `segmentEdges[loop][segment]` is the face's edge * index created from that input segment, so features can name side faces * by the sketch entities they come from. */ makeProfileFace( plane: Plane, loops: readonly ProfileLoop[], ): Promise< KernelResult<{ shape: ShapeId; segmentEdges: readonly (readonly number[])[]; }> >; /** A point, e.g. the tip of a loft. */ makeVertex(point: Vec3): Promise>; /** * A helix wire on a cylinder (a cone with `taper`, the half angle in * radians), from the axis origin plus `radius` along `xDir`, rising * `pitch` per turn up to `height`; right-handed unless `leftHanded`. */ helix( axisOrigin: Vec3, axisDir: Vec3, radius: number, pitch: number, height: number, options?: { xDir?: Vec3; leftHanded?: boolean; taper?: number }, ): Promise>; /** A sub-shape as a shape of its own, by its `topology()` index. */ subShape( shape: ShapeId, kind: 'solid' | 'shell' | 'face' | 'wire' | 'edge' | 'vertex', index: number, ): Promise>; /** * An open or closed wire (a path) from sketch segments in any order and * direction; `segmentEdges[i]` is segment i's edge in the wire. A broken * path fails with PATH_NOT_CONNECTED naming the gap. */ makeWire( plane: Plane, segments: readonly ProfileSegment[], ): Promise>; /** One wire from edges of shapes (all edges when `edges` is omitted). */ joinEdges( parts: readonly { shape: ShapeId; edges?: readonly number[] }[], ): Promise< KernelResult >; extrude( shape: ShapeId, dir: Vec3, distance: number, ): Promise>; revolve( shape: ShapeId, axisOrigin: Vec3, axisDir: Vec3, angleRad: number, ): Promise>; boolean( op: 'fuse' | 'cut' | 'common', a: ShapeId, b: ShapeId, ): Promise>; fillet( shape: ShapeId, edges: readonly number[], radius: number, ): Promise>; chamfer( shape: ShapeId, edges: readonly number[], distance: number, ): Promise>; /** * Transformed copy (a rigid motion or a mirror); history maps every * sub-shape to its copy. */ transform(shape: ShapeId, matrix: Matrix34): Promise>; /** * Shell: removes `faces` and gives the walls `offset` (negative inside). * Kept faces stay and generate their inner walls; a removed face becomes * the rim. No faces: a solid with a cavity. */ thickSolid( shape: ShapeId, faces: readonly number[], offset: number, options?: { tolerance?: number }, ): Promise>; /** Every face moved by `offset` (positive outside), each generated from its face. */ offsetShape( shape: ShapeId, offset: number, options?: { tolerance?: number }, ): Promise>; /** * Tapers faces by `angleRad` for a pull along `direction`, turning about * the neutral plane; a positive angle narrows the part along the pull. * Tapered faces are generated from the originals. DRAFT_FAILED carries * the face index in `error.index`. */ draft( shape: ShapeId, faces: readonly number[], direction: Vec3, angleRad: number, neutral: { origin: Vec3; normal: Vec3 }, ): Promise>; /** A face (solid) or wire (shell) swept along a wire or edge. */ sweep( profile: ShapeId, spine: ShapeId, options?: { /** * `binormal`: the profile keeps its angle to `binormal`, e.g. a helix * axis, so a thread or coil profile does not twist (no holes). */ orientation?: 'perpendicular' | 'parallel' | 'binormal'; binormal?: Vec3; }, ): Promise>; /** * A loft through sections in order: faces without holes, wires, edges, * and a point first or last. */ loft( sections: readonly ShapeId[], options?: { solid?: boolean; ruled?: boolean }, ): Promise>; topology(shape: ShapeId): Promise>; mesh( shape: ShapeId, linearDeflection: number, angularDeflection: number, ): Promise>; properties(shape: ShapeId): Promise>; /** Validity only, much cheaper than `properties`. */ check(shape: ShapeId): Promise>; /** Minimum distance between shapes or sub-shapes (`null`: the whole shape). */ distance( a: ShapeId, subA: SubShape | null, b: ShapeId, subB: SubShape | null, ): Promise>; /** Exact hidden line removal of the shapes together onto a view plane. */ project( shapes: readonly ShapeId[], view: ProjectView, ): Promise>; /** With options, one named product with colours (XCAF). */ exportStep( shapes: readonly ShapeId[], options?: { name?: string } & StepColors, ): Promise>; importStep(bytes: Uint8Array): Promise>; /** * STEP part by part with names, colors and assembly paths, in * millimeters; open shells are sewn into solids unless `heal` is false. */ importStepParts( bytes: Uint8Array, /** `local`: shapes in their product's coordinates, placed by `matrix`. */ options?: { heal?: boolean; tolerance?: number; local?: boolean }, ): Promise>; /** STEP with the assembly structure and names (XCAF products and instances). */ exportStepAssembly( assembly: StepAssembly, ): Promise>; /** Native B-rep bytes, for caching rebuild results. */ exportBrep(shape: ShapeId): Promise>; importBrep(bytes: Uint8Array): Promise>; release(shape: ShapeId): Promise; releaseAll(): Promise; } export type SubShapeKind = 'face' | 'edge' | 'vertex'; /** Structure of an extrusion or revolution, as result face indices. */ export interface SweepInfo { /** Faces of the start cap. Empty for full revolutions. */ bottom: readonly number[]; /** Faces of the end cap. */ top: readonly number[]; /** For every edge of the input profile, the side faces it generated. */ sides: readonly { edge: number; faces: readonly number[] }[]; } export interface Diagnostic { code: DiagnosticCode; severity: Severity; /** English, for people. Machines use `code`, `path` and `details`. */ message: string; /** Feature, parameter or body the diagnostic is about. */ entity?: string; /** Index of the command in its transaction. */ command?: number; /** JSON path inside the document, command or params, e.g. `params.distance`. */ path?: string; details?: Readonly>; } export type SketchEntity = | { id: SketchId; kind: 'point'; x: number; y: number; fixed?: boolean; /** A reference point, e.g. the sharp corner kept by a sketch fillet. */ construction?: boolean; } | { id: SketchId; kind: 'line'; start: SketchId; end: SketchId; construction?: boolean; } | { id: SketchId; kind: 'circle'; center: SketchId; radius: number; construction?: boolean; /** The radius is fixed (projected geometry). */ fixed?: boolean; } | { id: SketchId; kind: 'arc'; center: SketchId; start: SketchId; end: SketchId; /** Counter-clockwise from start to end. */ radius: number; construction?: boolean; /** The radius is fixed (projected geometry). */ fixed?: boolean; } | { id: SketchId; /** * A smooth curve through its points (`fit`) or shaped by them as a * control polygon (`control`), ADR-021. Its points are ordinary sketch * points; the curve is computed from them after the solve. */ kind: 'spline'; points: readonly SketchId[]; by: 'fit' | 'control'; construction?: boolean; } | { id: SketchId; /** * Text whose outlines are profiles (ADR-021): placed at `position` (the * start of its baseline, its middle or end by `align`), `height` the * height of a capital letter in mm, turned by `angle` radians. */ kind: 'text'; text: string; font: 'noto-sans' | 'noto-sans-mono' | 'inter'; bold?: boolean; position: SketchId; /** Expressions in the document ("5 mm"), numbers once evaluated. */ height: number | string; angle: number | string; align: 'left' | 'center' | 'right'; construction?: boolean; }; /** How sub-shapes of an operation's inputs map onto the result. */ export interface SubShapeHistory { /** Input sub-shape replaced by one or more result sub-shapes. */ modified: readonly { input: number; from: number; to: readonly number[] }[]; /** * Result sub-shapes created from an input sub-shape (e.g. a fillet face * from an edge). `kind` is the kind of the result sub-shapes in `to`. */ generated: readonly { input: number; from: number; to: readonly number[]; kind: SubShapeKind; }[]; /** Input sub-shapes that no longer exist in the result. */ deleted: readonly { input: number; from: number }[]; /** Input sub-shapes present unchanged in the result. */ unchanged: readonly { input: number; from: number; to: number }[]; } export interface FaceInfo { index: number; surface: SurfaceType; area: number; centroid: Vec3; /** Outward normal at the middle of the face parameter range. */ normal: Vec3; bbox: BBox; /** Face orientation is reversed relative to its surface. */ reversed: boolean; /** Axis of cylinders, cones, spheres (center, pole) and tori. */ axis?: Axis; /** Cylinder and sphere radius, cone reference radius, torus major radius. */ radius?: number; } export interface EdgeInfo { index: number; curve: CurveType; length: number; midpoint: Vec3; /** Adjacent face indices (unique). */ faces: readonly number[]; degenerated: boolean; /** Points at the first and last curve parameter; absent when degenerated. */ start?: Vec3; end?: Vec3; /** Circle center and normal. */ axis?: Axis; /** Circle radius. */ radius?: number; } export interface VertexInfo { index: number; point: Vec3; } export interface KernelVersion { occt: string; facade: string; emscripten: string; } export interface HeapStats { /** Size of the kernel's linear memory. */ heapBytes: number; /** Bytes currently allocated. */ usedBytes: number; liveShapes: number; } /** A wire joined end to end from edges given in any order and direction. */ export interface WireInfo { shape: ShapeId; /** The wire ends where it starts. */ closed: boolean; } /** * Row-major 3x4 rigid motion or reflection: * [r11 r12 r13 tx r21 r22 r23 ty r31 r32 r33 tz]. */ export type Matrix34 = readonly number[]; export interface LoftResult extends OpResult { loft: LoftInfo; } /** Render mesh. Ranges are [start, count] pairs indexed by face or edge index. */ export interface MeshPayload { positions: Float32Array; normals: Float32Array; indices: Uint32Array; /** Pairs (start, count) into `indices`, one pair per face. */ faceRanges: Uint32Array; /** Edge polylines, xyz per point. */ edgePositions: Float32Array; /** Pairs (start, count) in points into `edgePositions`, one pair per edge. */ edgeRanges: Uint32Array; } export interface ShapeProperties { shapeType: ShapeType; volume: number; area: number; centroid: Vec3; bbox: BBox; valid: boolean; faces: number; edges: number; vertices: number; solids: number; shells: number; } export interface ShapeCheck { valid: boolean; shapeType: ShapeType; solids: number; } /** A face, edge or vertex of a shape by its topology index. */ export interface SubShape { kind: SubShapeKind; index: number; } export interface DistanceInfo { value: number; pointA: Vec3; pointB: Vec3; /** Parallel faces and similar cases have several. */ solutions: number; } /** An orthographic view for hidden line removal (drawings, ADR-013). */ export interface ProjectView { /** Where the viewer looks, e.g. [0, 1, 0] for a front view. */ direction: Vec3; /** Up on the drawing; not parallel to direction. */ up: Vec3; /** Also the hidden parts. */ hidden?: boolean; /** Also smooth (tangent) edges between faces. */ smooth?: boolean; /** Chordal deviation of polylines for other curves, mm. */ deflection?: number; } export interface Projection { curves: readonly ProjectedCurve[]; /** The view's x axis in model space. */ xDir: Vec3; /** Kernel time, ms. */ ms: number; } /** Colours of one STEP product, sRGB in [0, 1]. */ export interface StepColors { color?: Vec3; /** One per shape; null for none. */ shapeColors?: readonly (Vec3 | null)[]; /** Faces of `shapes[shape]` by `topology()` index. */ faceColors?: readonly { shape: number; faces: readonly number[]; color: Vec3; }[]; /** Named faces of `shapes[shape]` (cosmetic threads, ADR-021). */ faceNames?: readonly { shape: number; faces: readonly number[]; name: string; }[]; } export interface StepParts { parts: readonly StepPart[]; /** Length units named in the file, lower case: 'millimetre', 'inch'. */ units: readonly string[]; solids: number; /** Parts that are not solids. */ open: number; healed: number; } /** An assembly for STEP: parts written once, placed by named instances. */ export interface StepAssembly { /** Name of the root product. */ name?: string; /** Colours: sRGB in [0, 1], surface colours. */ parts: readonly ({ name?: string; shapes: readonly ShapeId[]; } & StepColors)[]; /** Sub-assemblies, one product each, placing parts and each other. */ assemblies?: readonly { name?: string; instances: readonly StepAssemblyInstance[]; }[]; /** The root's instances. */ instances: readonly StepAssemblyInstance[]; } export type DiagnosticCode = | 'REVISION_CONFLICT' | 'COMMAND_INVALID' | 'ENTITY_NOT_FOUND' | 'ID_CONFLICT' | 'NAME_CONFLICT' | 'EXPRESSION_SYNTAX' | 'UNKNOWN_NAME' | 'UNIT_MISMATCH' | 'VALUE_OUT_OF_RANGE' | 'PARAMETER_CYCLE' | 'PARAMETER_IN_USE' | 'UNKNOWN_FEATURE_TYPE' | 'FEATURE_ORDER' | 'DOCUMENT_INVALID' | 'DOCUMENT_TOO_NEW' | 'UNKNOWN_PLUGIN_FEATURE' | 'CONSTRAINT_CONFLICT' | 'SKETCH_UNDERDEFINED' | 'PROFILE_INVALID' | 'INPUT_MISSING' | 'REFERENCE_LOST' | 'REFERENCE_AMBIGUOUS' | 'REFERENCE_FRAGILE' | 'FEATURE_INVALID_GEOMETRY' | 'KERNEL_TIMEOUT' | 'KERNEL_CRASHED' | 'UNITS_LOCKED' | 'SKETCH_ENTITY_IN_USE' | 'PATTERN_EMPTY' | 'HOLE_NO_POINTS' | 'PREVIEW_REQUIRED' | 'HOLE_MISSES_BODY' | 'DIMENSION_DANGLING' | 'ANNOTATION_INVALID' | 'VIEW_SOURCE_MISSING' | 'VIEW_EMPTY' | 'PROJECTION_FAILED' | 'COMPONENT_SOURCE_MISSING' | 'COMPONENT_SOURCE_UNAVAILABLE' | 'COMPONENT_EMPTY' | 'JOINT_DANGLING' | 'JOINT_INVALID' | 'JOINT_CONFLICT' | 'JOINT_LIMIT' | 'INTERFERENCE' | 'JOINT_DUPLICATE' | 'SHELL_THICKER_THAN_FILLET' | 'MIRROR_EMPTY' | 'PATH_NOT_CONNECTED' | 'SKETCH_PROJECTION_DANGLING' | 'IMPORT_FILE_MISSING' | 'IMPORT_UNREADABLE' | 'IMPORT_NOT_SOLID' | 'IMPORT_PARTIAL' | 'APPEARANCE_FACE_LOST' | 'CONFIGURATION_MISSING' | 'COMPONENT_PARAMETER_MISSING' | 'ASSEMBLY_CYCLE' | 'SUBASSEMBLY_PROBLEMS' | 'RELATION_DANGLING' | 'RELATION_CONFLICT' | 'TEXT_FONT_MISSING' | 'TEXT_PARAMETER_MISSING' | 'THREAD_FACE_LOST' | 'THREAD_NOT_CYLINDER' | 'THREAD_SIZE_UNKNOWN' | 'THREAD_DIAMETER_MISMATCH' | 'KNURL_HEAVY' | 'VIEW_REFERENCE_LOST' | 'GDT_INVALID' | 'DATUM_DUPLICATE' | 'TEMPLATE_MISSING' | 'CONTEXT_IN_USE' | 'CONTEXT_STALE' | 'CONTEXT_LOST' | 'PLUGIN_FAILED' | 'PLUGIN_TIMEOUT' | 'PLUGIN_LIMIT' | 'PLUGIN_REPORT' | 'PLUGIN_RESULT_STALE'; export type Severity = 'error' | 'warning' | 'info'; export type SketchId = string; export type SurfaceType = 'plane' | 'cylinder' | 'cone' | 'sphere' | 'torus' | 'bspline' | 'other'; /** Axis-aligned bounding box: [minX, minY, minZ, maxX, maxY, maxZ]. */ export type BBox = readonly [number, number, number, number, number, number]; export interface Axis { origin: Vec3; dir: Vec3; } export type CurveType = 'line' | 'circle' | 'ellipse' | 'bspline' | 'other'; /** Structure of a loft, as result face indices. */ export interface LoftInfo { /** Faces closing the first section (empty for a shell or a point). */ first: readonly number[]; /** Faces closing the last section. */ last: readonly number[]; /** Per section, the side faces each of its edges generated. */ sections: readonly (readonly { edge: number; faces: readonly number[] }[])[]; } export type ShapeType = | 'compound' | 'compsolid' | 'solid' | 'shell' | 'face' | 'wire' | 'edge' | 'vertex' | 'shape'; export type ProjectedCurve = ProjectedGeometry & { visible: boolean; /** Sharp edge, smooth (tangent) edge, or silhouette of a curved face. */ kind: 'sharp' | 'smooth' | 'outline'; /** Position of the source shape in the shapes passed to `project`. */ shape: number; /** Edge index of the source shape (`topology()`), -1 for outlines. */ edge: number; /** Face index of an outline, -1 otherwise. */ face: number; }; /** One solid (or open shell) of an imported STEP file, placed, in millimeters. */ export interface StepPart { shape: ShapeId; /** `solid`, or `shell` / `face` / `compound` when it does not close. */ type: ShapeType; valid: boolean; /** Sewn into a solid or fixed by healing. */ healed: boolean; /** Instance name, or the product name outside an assembly. */ name: string; /** Product (part) name. */ product: string; /** Assemblies above it from the root down. */ path: readonly string[]; /** sRGB in [0, 1] from the file. */ color?: Vec3; /** Faces whose colour differs from `color`, by `topology()` index. */ faceColors?: readonly { face: number; color: Vec3 }[]; /** Named faces in the file (cosmetic threads), by index. */ faceNames?: readonly { face: number; name: string }[]; /** Placement from the file's root: its instances' matrices composed. */ matrix: Matrix34; /** The product, the same for all its instances in one read of a file. */ productId: string; /** The instances from the root down to this part, its own last. */ instances: readonly StepInstanceRef[]; /** The free shape (root) it was found under. */ root: { id: string; name: string }; } /** * A part or a sub-assembly placed in its parent: exactly one of `part` * (indexes `parts`) and `assembly` (indexes `assemblies`); `color` wins over * what it places. */ export interface StepAssemblyInstance { part?: number; assembly?: number; name?: string; matrix: Matrix34; color?: Vec3; } /** 2D curves in view coordinates: x to the right, y up, model units. */ export type ProjectedGeometry = | { type: 'line'; a: Vec2; b: Vec2 } | { type: 'circle'; center: Vec2; radius: number } | { type: 'arc'; center: Vec2; radius: number; /** Start, a point between and end. */ a: Vec2; m: Vec2; b: Vec2; } | { type: 'polyline'; points: readonly number[] }; /** One instance on the way from a STEP file's root to a part. */ export interface StepInstanceRef { id: string; /** The product (part or assembly) it places. */ product: string; /** Its own name, or its product's. */ name: string; productName: string; /** Its placement in its parent. */ matrix: Matrix34; }