Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignorePatterns": ["tools/oxlint/**"]
}
39 changes: 39 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"extends": ["./.oxlintrc.shared.json"],
"ignorePatterns": ["tools/oxlint/**", "node_modules/**", "dist/**", "cli/dist/**"],
"overrides": [
{
"files": ["src/guards.ts", "src/json.ts", "src/shape.ts"],
"rules": {
"anti-slop/no-unsafe-dictionary-type": "off"
}
},
{
"files": [
"cli/src/worker.ts",
"src/colors.ts",
"src/drawing.ts",
"src/edit/change-shape.ts",
"src/edit/model.ts",
"src/json.ts",
"src/leaders.ts",
"src/lint.ts",
"src/points.ts",
"src/read/check.ts",
"src/rules.ts",
"src/shape.ts",
"src/shapes.ts",
"src/standard/define.ts",
"src/standard/made.ts",
"src/standard/lint.ts",
"src/standard/shape.ts",
"src/tables.ts",
"src/transparency.ts"
],
"rules": {
"anti-slop/no-unknown-parameters": "off"
}
}
]
}
45 changes: 45 additions & 0 deletions .oxlintrc.shared.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"jsPlugins": [
{
"name": "anti-slop",
"specifier": "./tools/oxlint/anti-slop/index.ts"
},
{
"name": "anti-slop-effect",
"specifier": "./tools/oxlint/anti-slop/effect/index.ts"
}
],
"ignorePatterns": ["tools/oxlint/**", "node_modules/**", "dist/**", "cli/dist/**"],
"rules": {
"oxc/no-accumulating-spread": "error",
"anti-slop/no-array-filter-map": "error",
"anti-slop/no-reduce-accumulator-copy": "error",
"anti-slop/no-chained-type-assertions": "error",
"anti-slop/no-conditional-empty-object-spread": "error",
"anti-slop/no-known-value-widening": "error",
"anti-slop/no-module-mocking": "error",
"anti-slop/no-object-parameters": "error",
"anti-slop/no-reflect-apply": "error",
"anti-slop/no-reflect-get": "error",
"anti-slop/no-runtime-typeof": [
"error",
{
"allowInTypeGuards": true
}
],
"anti-slop/no-unsafe-dictionary-type": "error",
"anti-slop/no-shape-in-symbol-names": "error",
"anti-slop/no-unknown-parameters": "error",
"anti-slop/no-unknown-returns": "error",
"anti-slop/no-unknown-type-aliases": "error",
"anti-slop/no-widen-then-assert": "error",
"anti-slop/require-readable-spacing": "error",
"anti-slop/require-safety-comment-for-type-assertion": "error",
"anti-slop-effect/no-manual-effect-error-tag": "error",
"anti-slop-effect/no-manual-tag-comparison": "error",
"anti-slop-effect/no-manual-tagged-construction": "error",
"anti-slop-effect/no-service-constructor-imports": "error",
"anti-slop-effect/prefer-effect-match": "error"
}
}
11 changes: 11 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ own, and each is as binding as these: before you change a part, read its page. A
- Run `pnpm verify` before finishing a change. It checks formatting, lints,
type checks, runs the tests and runs the package smoke test, which builds.
Run `pnpm fmt` to fix formatting.
- Lint runs the anti-slop rules in `tools/oxlint/anti-slop`, vendored verbatim from the revision
`provenance.json` names; `.oxlintrc.shared.json` configures them for every package, and
`.oxlintrc.json` adds this package's overrides. Add no disable comments.
- Check a value from outside the types with a guard from `src/guards.ts`, or a named guard of
your own: `typeof` may appear only in a type guard.
- `unknown` parameters, and records of `unknown`, are allowed only in the files
`.oxlintrc.json`'s `overrides` lists: the ones that decode outside input. Everywhere else,
take the type the value has once decoded, or an interface whose fields are `unknown`. Never
stand a type parameter in for `unknown`.
- Add a field only when it is present with `...(cond && { field })`, not `cond ? {...} : {}`.
- A type assertion that stays has a one-line `// SAFETY:` comment saying why it holds.
- Source files import each other with `.ts` extensions. Node runs them directly,
and `tsc` rewrites the extensions to `.js` when it builds `dist/`.
- Keep syntax erasable: no enums, namespaces or parameter properties.
Expand Down
145 changes: 145 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,151 @@

## Unreleased

- An edit adds. `e.model(draw)` and `e.layout(name, draw)` give the drawing builder over the file's
own layers, styles and blocks, in the file's or the layout's units: a name the file holds is the
file's, used as the file defines it, and another definition of it is refused with the new rule
`file-definition`. `editDXF`, and an editor of another format, writes each addition with a handle
counted from the file's `$HANDSEED` and a mark, extended data under `TSDRAFT` that holds the
edit's name, the addition's id, its handle and `markHash` of what it held, and keeps a record of
the edit's additions in the dictionary `TSDRAFT`. A later edit of the same name writes an
unchanged addition over itself, in place and with its handle, erases one it drops, all of them
when it adds none, and is refused
where a person changed or erased one, `edit-mark-changed` and `edit-mark-erased`.
`markUnchanged`, `replacement` and `withReplacement` say what a later edit sees. `lintEdit`
refuses what the writers cannot add, an image or an underlay among them for now, and warns, `edit-addition-layer`, of an addition on a layer
that hides it or does not plot it. The preview draws what an edit adds.
- An entity's own `linetypeScale`, group 48, a dimension's own `scale`, `DIMSCALE`, written as its
override of its style's, and a dimension style's `lineExtension`, `DIMDLE`, which defaults to
the arrow size as before.
- Under a standard, a text role and a leader style take `styleName`, the name of the firm's style
it stands for, which an edit of a file that holds it draws in.
- The read holds more of what an edit needs: each entity's `mark`, the file's `edits`, the
header's `handseed`, the multileader styles, `leaderStyles`, a layout's `plotScale`, and of a
dimension style its `extensionOffset`, `extensionBeyond`, `textGap`, `lineExtension`, `zeros`,
`textLevelInside`, `textLevelOutside` and `lineInside`.
- An edit changes texts and properties in place: `e.change(handle, changes)` gives a text, a
paragraph or an insert's attributes by tag a whole value or one replacement, keeping every
format it does not replace, a text a height and paragraph text a width, and any entity its own
layer, color, true color, linetype, lineweight and linetype scale. A whole value takes a text's
field out. `e.layer(name, changes)` changes a layer's state, an xref's layer in its host among
them, and `e.viewport(handle, changes)` re-aims a viewport, turns it on or off and freezes and
thaws layers in it. Both writers make each in place, `lintEdit` refuses what the read tells is
wrong, `editedRead` and the preview hold the changes, and `changedEntity`, `changedLayer`,
`changedViewport`, `changedParagraph`, `placedText`, `paragraphReads`, `layerNamed`,
`linetypeNamed` and `matchedIndex` are exported.
- A read's `header` gives `clayer`, the current layer, which an edit never freezes.
- Breaking: the names of shape files and their shapes are SHX names. Rename these in your code;
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`: a mark is
`{ after, glyph, file, scale }`. A drawing saved with `toJSON` before this release names
`shape` in such a mark, and `fromJSON` refuses it until the mark says `glyph`, with the
message `linetypes[0].marks[0]: "shape" is now "glyph"`.
- The `shapes` option of `toSVG`, `toPDF`, `lint` and `parseLinetypes` is `shx`.
- In a read drawing, a linetype mark's `shape` is `glyph`, and a text style's `shapes` is
`glyphFile`.
- An error about a mark's shape names the field `glyph`, as in "its mark 0: glyph must be a whole
number from 1 to 65535", where it said `shape`.
- Breaking for readers of other formats: `READ_FORMAT` is 1, the read format with the names above.
A reader built for this release gives `format: 1`, a mark's `glyph` and a style's `glyphFile`,
and `checkDrawingRead` passes only format 1. The `tsdraft` command still takes an answer in
format 0 from a reader built for an older tsdraft, and renames its `shape` and `shapes` before
it checks the answer. It skips an answer in any other format, and says which format it gave.
- `Json`, the type of a value JSON can hold, is exported.
- `StandardOptions.files` is typed by default as a record of `StandardFile`, a `Standard`, a
`Drawing` or a `Json` value, where it took any value; `StandardFile` is exported. What
`defineStandard` accepts at run time is unchanged.
- `leaderArrowheadInfo` takes a `string`, `gradientWritten` a `HatchGradient` or `undefined`, and
`maskOf` a `TextMask` or `undefined`, where each took `unknown`. What each does with a value of
another type at run time is unchanged.
- When code that the builder or the checks of an edited copy run throws a value that is not an
`Error`, the message names the value, where it said `undefined`.
- Under a standard, `lint` warns `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, such as two
elevations at one scale drawn too close in model space. The builder keeps the view an annotation
was drawn for in its new `view` field, which the writers leave out.
- `readDXF` takes the file's bytes as one `Uint8Array`, such as a `Buffer` from `fs.readFileSync`,
as `readDWG` does.
- The picture of a read file. `toSVG` draws a `DrawingRead` read with `geometry` as the leading
CAD app shows the file: model space, or a layout as it plots, with every kind the readers keep.
A dimension and a table draw from the block of their picture, a multileader from its own
points, a text from where that app starts it, in the nearest font of `FONTS` where tsdraft lacks
its own. `readPicture` gives the picture with notes of what it could not draw as the file holds
it, and in fragments, one for each entity at the top of a space, which `joinPicture` joins.
`pictureDrawing` gives the `Drawing` it draws.
- `tsdraft render` and `tsdraft dev` draw a DXF, and a DWG through a reader the project installs
or `--reader` names, as they draw a drawing file.
- `sheetShows`, `spaceShows` and `nearPoint` answer what a sheet of a read file shows, what a space
draws and what is near a point: through inserts and the xrefs whose reads are given, with each
layer's state as the sheet holds it, `XREF|LAYER` among them, each viewport's frozen layers,
its outline or the entity that clips it, and an insert's clip. `xrefAreas` gives the parts of
an xref's model a host's layout shows.
- Both `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, are
read from a DXF.
- `tsdraft shows` prints what a sheet of a drawing file shows, or what is near a point, as JSON.
- The command keeps each read of a drawing file, one for each hash of the file's bytes, its
reader and what is read, in memory and in the project's `node_modules/.cache/tsdraft`.
- `eachDrawn` can give each placement the inserts the walk came through.
- `ReadOptions.only` reads a file as named layouts show it: each layout's paper whole, and of
model space what its viewports' windows meet, or areas of model space given as two corners. A
detail file whose model space holds far more than `GEOMETRY_ITEMS` reads whole one sheet at a
time. What model space leaves out is counted under `outside what was read`, a layout not named
keeps no `entities`, and `DrawingRead.only` gives back what the read kept. `viewportWindow` gives
the corners in model space of what a viewport shows, and `partFilter` is how a reader of another
format reads `only` as `readDXF` does.

- Editing a firm's drawing begins with the copy and its checks. An edit file's default export is
`editDrawing({ file, sha256, name })`, which names the file by its path and the SHA-256 of the
bytes it was planned on, and gives an `Edit`, a value that goes through JSON and that `checkEdit`
checks. `editDXF` makes the edited copy of a DXF of the 2018 format, each record the edit does
not change copied as the file holds it, and throws only an `EditError`: for other bytes than the
edit's, another format, or a statement or an addition, none of which this release makes.
`dxfStructure` is the structure check of a DXF, as the leading CAD app's `AUDIT` would find a
fault, and `checkEditedCopy` runs the checks of every job on a copy against its source.
`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, refuses a stale hash, warns of a lock, and never
writes the source's path. A package edits another format as it reads one, named under
`"tsdraft": { "editors" }`. [Editing a firm's drawing](docs/editing.md) has the rest.
- An edit erases and moves. `e.erase(...handles)` erases each entity with what it owns, and takes
every reference to it out of groups, sort tables, reactors and a block's list of its inserts;
`e.move(handles, { by, about, rotate, scale })` moves, turns and scales each entity of every
kind the readers read, an insert with its attributes and a dimension, moved only, with its
picture among them, the way the leading CAD app's own `SCALE`, `ROTATE` and `MOVE` leave it. `editDXF` makes
both, writing again only the values that change. `lintEdit(edit, read)` gives the refusals the
read can tell, each with the call of its statement, and `editedRead(read, edit)` the read of the
file after the edit. The checks of every job hold a copy to it, and `FileEditor` gains `links`.
- An edit stretches and sets a polyline's vertices. `e.stretch(handles, { window, by })` moves
each point of a named entity inside the window, its edge among it, by `by`, as the leading CAD
app's `STRETCH` does by a crossing window: a side of a polyline or an arc whose one end moves
keeps its arc's height, an insert, a text, paragraph text, a circle and a point move whole by the
point they are placed by, an associative hatch is stretched with its boundary, and an entity
wholly inside moves as `e.move` moves it, a dimension with its picture. What it would leave as it
is gets the warning `edit-stretch-unchanged`, and what it cannot stretch, such as a dimension
with only some of its points inside, the error `edit-stretch`.
`e.vertices(handle, { points, bulges })` sets a light or a 2D polyline's points, each side
keeping its bulge and its widths unless `bulges` gives them; a light polyline may take another
number of points. Its refusals are `edit-vertices`. Both writers make both, 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 or
vertices of it is refused with `edit-part`. A handle an earlier statement reaches takes nothing
with it again, so an edit that names one insert or dimension in many statements lints in time
of its names, before `edit-twice` refuses it.
- `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, and `tsdraft write` refuses an edit
`lintEdit` gives an error for.
- With `geometry`, each space and layout of a read lists in `unread` each entity of a kind the
reader does not read, by its handle, kind and layer, such as an `OLE2FRAME` with its corners, so
an edit can name it. A 2D polyline, whose vertices are records of their own, reads with
`heavy: true`.

## 0.5.4

This release has breaking changes, though its number is a patch's. A project that depends on
Expand Down
Loading