Skip to content

Export 14 changes - #57

Open
tsdraft-export[bot] wants to merge 14 commits into
mainfrom
export
Open

tsdraft-export[bot] wants to merge 14 commits into
mainfrom
export

Conversation

@tsdraft-export

Copy link
Copy Markdown
Contributor

This pull request was opened by the export from tsdraft's development repository. Each commit
here is one change made there.

Merge it with squash, or with rebase to keep one commit per change. Don't push to this branch:
the next export replaces anything that did not come from it.

sc-frederick and others added 2 commits November 23, 2026 00:26
…r of a DXF or DWG

`toSVG` now draws a `DrawingRead` read with `geometry` as the leading CAD app shows the file: model space, or a layout as it plots, with its viewports and its plot style table. Every kind the readers keep is drawn by the same code that draws a `Drawing`:

- A dimension and a table draw from the block of their picture.
- A multileader draws from its own points and sizes, with the arrowheads of `leaderPicture`.
- A text starts where that app starts it. Its font is the nearest one in `FONTS` where tsdraft lacks the file's own.
- An insert draws its attributes where the file places them.
- An xref draws from its own read, with its host's layer states, its own attachments and its own images.

`readPicture(read, options)` gives the same picture, plus:
- `notes`: the fonts drawn in another, what draws nothing (counted by kind), and what draws only nearly.
- The picture in fragments, one for each entity at the top of each space, in the order the app draws them. `joinPicture` joins them back into the picture, and an edit can keep the fragments of what it leaves alone. The insert of an xref is a run of its own fragments, one for each entity of the xref's model space.

`pictureDrawing(read)` gives the `Drawing` the picture draws, with the read handle of every entity, for pictures and the checks of text. It is not for writing.

`tsdraft render` and `tsdraft dev` take a DXF, or a DWG a reader reads (from the project, or named with `--reader`), as they take a drawing file. They read the drawing's xrefs, and the xrefs' own attachments, from beside it. Their `read-picture` warnings list what the pictures could not draw as the file holds it.

The picture also escapes every character XML cannot hold. A file's text with a control character no longer makes an SVG a renderer refuses.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…of reads

- `sheetShows(read, layout, { xrefs })` gives what a layout of a read file shows: its paper, then what each viewport that is on shows of model space, through inserts and through the xrefs whose reads are given. Left out: layers that are off, frozen, frozen in that viewport, or set not to plot, with an xref's layer in the state the host gives its `XREF|LAYER` record; anything outside the viewport's rectangle or the outline that clips it; and anything outside an insert's clip. Each entity comes with its handle in the file that holds it, the inserts and xrefs it was reached through, its kind, its layer as the sheet names it, its color, its box on the paper, and its text.
- `spaceShows(read, { layout?, xrefs })` gives what model space or a layout's paper draws. `nearPoint(read, at, { sheet | layout, within, xrefs })` gives what lies near a point, nearest first; its grid is built once for each read. `xrefAreas(read, layout, xref)` gives the parts of an xref's model that a layout shows, in the xref's own coordinates.
- `editedPicture(kept, change)` gives the picture of an edited read from the fragments `readPicture` kept before the edit. It keeps the fragments of what the edit doesn't touch, leaves out what it erases, puts what it changes in its old place and what it adds at the end. The edit may be in the file's own spaces or in an xref's model.
- `readDXF` reads `ReadViewport.clipBy`, the handle of the entity that clips a viewport, and `ReadInsert.clip`, the outline of an insert's spatial filter in its block's coordinates. It counts an image whose clip the world's coordinates cannot hold as malformed.
- `tsdraft shows <file> [--sheet | --layout] [--near x,y --within d] [--xref name=file]` prints what a sheet shows, or what is near a point, as JSON.
- The command reads each drawing file once for each SHA-256 of its bytes, its reader and what is read. It keeps the read in memory, and on disk in the project's `node_modules/.cache/tsdraft`. `render` and `dev` of a DXF or DWG read through it.
- `eachDrawn` can give each placement the inserts the walk came through.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title The picture of a read file: toSVG of a DrawingRead, and tsdraft render of a DXF or DWG Export 2 changes Nov 23, 2026
… each field needs

The shape sweep, a test of the library, runs about four times faster. Each value it tries now goes into the smallest drawing that holds the field it changes. One value of each field also runs in the whole test drawing, so a fault that shows only in a big drawing is still found. Values equal to the one they replace are skipped. The sweep also checks that lint for the drawing's own version reports the same errors as plain lint. This changes no library behavior.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 2 changes Export 3 changes Nov 23, 2026
A read can keep only what named layouts show. A detail file whose model space holds far more than `GEOMETRY_ITEMS` then reads whole, one sheet at a time.

- `ReadOptions.only = { layouts?, areas? }`. With `geometry`, each named layout keeps its paper whole. Model space keeps each entity whose box meets the window of one of those layouts' viewports, or one of `areas` (two corners each, such as what a sheet of another file shows of this one through an xref).
- The boxes are never smaller than what the entity draws, so a read by layout keeps everything a layout shows, and some it doesn't:
  - Each text uses its style's slant and width, paragraph text grows with its `\H`, `\W` and `\T` codes, and leaders and dimensions include their arrowheads.
  - Each window is widened by a fiftieth of its size.
  - A viewport's clip and frozen layers are not applied, and an off viewport counts.
  - An entity the read can't box is kept, such as an insert of an xref, an insert of a block that counts kinds it draws, a spline held by fit points alone, or an old leader of an annotative style.
- A layout's own view of its paper gives no window.
- What model space leaves out is counted under `outside what was read` (`OUTSIDE_THE_READ`). A layout `only` doesn't name keeps its census, viewports and inserts, and no `entities`. `DrawingRead.only` gives back the layouts as the file spells them and each area with its lower corner first. The census and the blocks stay whole.
- Layout names are compared as CAD programs compare them: `Straße` and `Strasse` are two layouts.
- A name the file has no layout of, `Model`, an empty or malformed `only`, or more than `MOST_WINDOWS` (1,024) windows and areas is a `ReadError`. The error for an unknown name lists the file's layouts.
- `viewportWindow(viewport)` gives the corners in model space of what a viewport shows. `partFilter` lets a reader of another format read `only` the way `readDXF` does.
- A DXF lists its layouts after its entities, so `readDXF` reads twice when given `only`. A stream is read once as it arrives, with a copy of each piece kept for the second pass. Bytes or a string are read in the caller's turn.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 3 changes Export 4 changes Nov 23, 2026
- `sheetShows`, `nearPoint` and `xrefAreas` take an unclipped viewport's window in model space from `viewportWindow`, the one a read by layout keeps. No answer changes.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 4 changes Export 5 changes Nov 23, 2026
…variables and paragraph height

`readDXF` takes a file's bytes as one `Uint8Array`, such as a `Buffer` from `fs.readFileSync`, as well as a string or a stream.

The guide now explains why a point held in a variable is refused (it widens to `number[]`) and shows `satisfies` and `as const` as the fix. `ParagraphMeasure.corners` says how to get a paragraph's height and bottom.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 5 changes Export 6 changes Nov 23, 2026
Editing a firm's drawing begins with the copy and its checks.

- An edit file's default export is `editDrawing({ file, sha256, name })`. It names the file by its path and by the SHA-256 of the bytes it was planned on, and gives an `Edit`, a value that goes through JSON. `checkEdit` says what is wrong with a value meant as one.
- `editDXF` makes the edited copy of a DXF of the 2018 format: each record the edit does not change is copied as the file holds it, so an edit that changes nothing gives the file back byte for byte. It throws only an `EditError`: for other bytes than the edit's, another format, a binary DXF, or a statement or an addition, none of which this version makes.
- `dxfStructure` is the structure check of a DXF, as the leading CAD app's `AUDIT` would find a fault. `checkEditedCopy` runs the checks of every job on a copy against its source: read back, structure, before and after, lint and the changed sheets.
- `tsdraft write <edit file>...` writes each edited copy under `out/` at the source's path from the job's root, only once those checks pass. It refuses a stale hash, warns of a lock beside the file, never writes a source's or a sheet's path by any path to it, and replaces a file at a copy's path only when its record, `.tsdraft-write.json`, shows it wrote that file.
- A package edits another format as it reads one, named under `"tsdraft": { "editors" }` beside its reader.

[Editing a firm's drawing](https://github.com/Surfside-Software/tsdraft/blob/main/docs/editing.md) has the rest.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 6 changes Export 7 changes Nov 23, 2026
- The repository's pnpm version is now 12.18.0.
- The TypeScript configuration adds `noImplicitOverride` and `noFallthroughCasesInSwitch`. The code already passed both, so nothing a user sees changes.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 7 changes Export 8 changes Nov 23, 2026
Under a standard, `lint` and `tsdraft render` warn `viewport-shows-other-view` of a text, an insert, a dimension or a leader drawn for one view that a viewport of another view shows at the same scale. Two elevations at 1/8" = 1'-0" drawn too close together in model space, for example, now get a warning naming each note of one that the other's viewport takes in. Keep each view in its own part of model space, or freeze the layer in that viewport where the note is meant to show there.

The builder keeps the view an annotation was drawn for in a new optional `view` field on texts, paragraphs, inserts, dimensions and leaders. The DXF writers leave it out, and an entity without it is not checked.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 8 changes Export 9 changes Nov 23, 2026
…'s build

The read-cache test no longer fails when another test changes the core's files between two reads.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 9 changes Export 10 changes Nov 23, 2026
**Breaking changes, for the next minor release**

The names of shape files and their shapes are now SHX names. What they do is unchanged.

- `ShapeFile` is `ShxFile`, and its `shapes` is `glyphs`.
- `ShapeFiles` is `ShxFiles`.
- `ShapeDefinition` is `ShxGlyph`.
- `ShapeOutline` is `ShxOutline`.
- `parseShapes` is `parseShx`.
- `shapeFileKey` is `shxFileKey`.
- `SHAPE_FILE_LENGTH`, `SHAPE_POINTS` and `SHAPE_STEPS` are `SHX_FILE_LENGTH`, `SHX_POINTS` and `SHX_STEPS`.
- `LinetypeShape` is `LinetypeGlyph`, and its `shape` is `glyph`.
- The `shapes` option of `toSVG`, `toPDF`, `lint` and `parseLinetypes` is `shx`.
- In a read drawing, a linetype mark's `shape` is `glyph`. A text style's `shapes`, true for a style that holds a shape file and no font, is `glyphFile`.

What else changes with them:

- A drawing saved with `toJSON` before this release names `shape` in a linetype mark. `fromJSON` refuses it with the message `"shape" is now "glyph"` until the mark says `glyph`.
- The read format is 1. The `tsdraft` command still takes format 0 from a reader written for an older tsdraft, and renames its fields.
- The `tsdraft` command draws a drawing's SHX marks whichever version of tsdraft the drawing's project uses.
- Error messages name the field by its new name, for example "glyph must be a whole number".

**Other API changes**

- `Json`, the type of a value JSON can hold, is exported. So is `StandardFile`, the default type of a standard's files in `StandardOptions`.
- `leaderArrowheadInfo`, `gradientWritten` and `maskOf` take the types they read instead of `unknown`.
- An error that is not an `Error` is shown by its value where a message said "undefined".

**Development**

- The package now lints with the anti-slop oxlint rules, copied verbatim into `tools/oxlint/anti-slop` under their MIT license.
- pnpm is 12.18.0.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 10 changes Export 11 changes Nov 23, 2026
- An edit erases and moves. `e.erase(...handles)` erases each entity with what it owns: an insert's attributes, a polyline's vertices, a dimension's or a table's picture, a text's fields. It takes every reference to the entity out of groups, sort tables, reactors and a block's list of its inserts. `e.move(handles, { by, about, rotate, scale })` scales each entity about `about`, turns it about the same point, then moves it by `by`, the way the leading CAD app's own `SCALE`, `ROTATE` and `MOVE` leave it. A turn or a scale names `about`.
- Every kind the readers read moves: an insert with its attributes, a 2D polyline with its vertices, a dimension with its picture (moved only), a multileader, a hatch with its loops and its pattern, an image and a wipeout with their vectors, a table, and a viewport on its paper with the entity that clips it. An entity of a named block the file inserts once is edited in the block's definition, with the warning `edit-block-definition`.
- `lintEdit(edit, read)` gives the refusals the read can tell, each with its statement's call. Among them: a turn or a scale of a dimension, since the leading CAD app draws its picture again; a scale of a table; a turn or a scale of an old leader with its note; an attribute or a picture's entity named alone; an entity of a block inserted more than once; a viewport turned, scaled or erased; a scale of paragraph text whose codes set a height of its own; and, in a read with `only`, a move of an entity out of what the read keeps (`edit-only`). A scale multiplies a point's Z, an elevation and a thickness, as the leading CAD app's `SCALE` does. An entity on a locked layer is edited with the warning `edit-locked-layer`. The writers also refuse what only the file's records tell, such as a move that would part an associative dimension or hatch from what it names.
- `editedRead(read, edit)` gives the read of the file after the edit. The checks of every job hold the copy to it, and `FileEditor` gains `links`.
- `tsdraft render` and `tsdraft dev` take an edit file: they draw the file as it will plot after the edit, and a second picture of what it changes. `tsdraft write` refuses an edit `lintEdit` gives an error for.
- With `geometry`, each space and layout lists in `unread` each entity of a kind the reader does not read, by handle, kind and layer, such as an `OLE2FRAME` with its corners, so an edit can name one. An `OLE2FRAME` a space lists may be erased. A 2D polyline whose vertices are records of their own reads with `heavy: true`.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 11 changes Export 12 changes Nov 23, 2026
An edit changes texts and properties in place, as well as erasing and moving:

- `e.change(handle, changes)` gives a text, paragraph text or an insert's attributes (by tag) a whole value or one replacement. A replacement keeps every format it does not replace: in paragraph text it is found in the characters as the paragraph reads, takes the format in force where it starts, takes a group or a stack inside it whole, and refuses a code that would change the characters after it. A whole value takes a text's field out. It also sets a text's height, paragraph text's width (one column; two or more are refused), and any entity's own layer, color, true color, linetype, lineweight and linetype scale.
- `e.layer(name, changes)` changes a layer's on, frozen, locked, plot, color, linetype and lineweight, an xref's layer in its host among them: marked as the host's override so a reload keeps it, with `$VISRETAIN` set to 1.
- `e.viewport(handle, changes)` re-aims a viewport (center, scale, twist), turns it on or off, and freezes or thaws layers in it alone.
- A justified single-line text whose value or height changes starts where its font's widths put it; an aligned or fitted one keeps its two points.
- `lintEdit`, `editedRead` and the preview's picture of changes hold all three. New exports: `changedEntity`, `changedLayer`, `changedViewport`, `changedParagraph`, `placedText`, `paragraphReads`, `layerNamed`, `linetypeNamed`, `matchedIndex`.

`docs/editing.md` has a section on each.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 12 changes Export 13 changes Nov 23, 2026
…'s vertices set

An edit stretches and sets a polyline's vertices.

- `e.stretch(handles, { window, by })` stretches each entity it names as the leading CAD app's `STRETCH` does by a crossing window. A point on the window's edge is inside.
  - **Lines, polylines and 2D solids:** each point inside moves by `by`. A side of a polyline whose one end moves keeps its arc's height, and an arc with one end inside does the same.
  - **Moved whole, by the point they are placed by:** inserts with their attributes, texts, paragraph text, circles and points.
  - **Associative hatches:** a hatch tied to its boundary is stretched with it, loop by loop. A loop the window leaves alone keeps its boundary, so the outer edge of a hatch with a hole stretches and the hole stays.
  - **Wholly inside:** an entity moves as `e.move` moves it.
  - **Lint:** what the stretch leaves as it is gets the warning `edit-stretch-unchanged`. What it cannot stretch gets the error `edit-stretch`: a dimension with only some of its points inside, an arc whose middle is inside and one end is not, a side that would come to nothing, and kinds with no case yet.
- `e.vertices(handle, { points, bulges })` sets the points of a light or a 2D polyline.
  - Each side keeps its bulge and its widths unless `bulges` gives them.
  - A light polyline may take another number of points.
  - Its refusals are `edit-vertices`.
- Both DXF and DWG edits make both statements, and `editedRead` reads them. `stretchedEntity` and `stretchPlan` say what a stretch makes of each entity.
- The entity that clips a viewport moves only with its viewport. A move of it alone, a stretch of it, or vertices for it is refused with `edit-part`.
- A handle an earlier statement reaches takes nothing with it again. An edit that names one insert or dimension in many statements now lints in time proportional to its names, before `edit-twice` refuses it.

See `docs/editing.md`, "Stretch and vertices".

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@tsdraft-export tsdraft-export Bot changed the title Export 13 changes Export 14 changes Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant