Repository navigation
v0.6.0
·
201 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
- breaking feat: parsing returns the span-only AST by default —
start/endon every
node, nolocand no Sveltename_loc— in every package and both CLIs, like acorn's
locations: false. Pass{locations: true}(ortsv parse --locations) forloc, now
computed in JS from the offsets and the source and appended last on each object (the native
CLI places it afterend, so a re-serialized tree no longer byte-matches its output);
--no-locationsis gone - breaking feat:
lochas one definition — the line and UTF-16 column of each object's own
start/end, counting ECMAScript line terminators in TypeScript (acorn's
locations: trueexactly) and\nalone in Svelte and CSS. Every object withstart/end
gets one (Svelte template nodes,Root,<style>, comments and CSS nodes included), and
Svelte'slocquirks are not reproduced: a<script>'sProgram.locfollows its
start/endrather than the tag, and a destructured block binding, a block binding's: T
and a lone CR/LS/PS no longer shift a position. A Svelte source holding a lone CR/LS/PS no
longer throws - breaking feat:
tsv_ast.d.tsdeclareslocandname_locoptional, as estree does; the
{locations: false}overloads returninganyare gone, so every parse returns its typed
root.parse_*_jsontakes onlysourceType(its string is the span-only wire) - breaking feat:
create_locator(source, {language})requires the language and no longer
takes{ast}; the bareloc_ofexport is gone (use a locator's);reconstruct_locations
reads the language off a parse's root — aRoot, aStyleSheetFile, or aProgramspanning
the source — and throws on anything else passed without{language} - breaking feat: the
Loctype is gone forSourceLocation(withPosition, the AST types'
own, at the package root);LocationOptionsisReconstructLocationsOptions, and
create_locatortakesLocatorOptions - breaking feat: a parse or format of a source that does not parse throws a
SyntaxError
(typedTsvSyntaxError) withstart— the UTF-16 offset, in the AST's coordinates — and
loc: {line, column}; the message'sline:colheader follows the same definition, its
excerpt drops a leading BOM, and a format error is located in the caller's own source, CRLF
included - breaking feat: every argument error is a
TypeError, with one message in every package —
a source that is not a string or not well-formed UTF-16 (the WASM packages read a non-string
as the empty document outside Node, and a lone surrogate became U+FFFD), a bad options bag, an
unknown key, a wrong-typed value — and the locations helpers refuse the same way - breaking feat: for Rust consumers of the language crates,
convert_ast_json_bytes/
convert_ast_json_stringwrite the span-only wire; the loc wire is
convert_ast_json_bytes_with_locations, behind a newlocationscargo feature, and the
_no_locationsfunctions are gone - feat: a locator's
position_at(offset)gives one offset's{line, column};position_atand
loc_ofthrow aRangeErrorfor an offset the source doesn't hold - feat: a
./locationssubpath export on the parse-capable packages — the line/column helpers
alone, loading no engine - fix: format refuses a Svelte document with a lone CR inside an in-tag
//comment, where
folding the CR to a line feed ended the comment early and turned the rest of its line into
markup - fix: in a Svelte template expression, comments around a JSDoc cast's parens or a grouping
paren pair attach as Svelte's parser attaches them — a comment Svelte gives the discarded
paren, the cast's own@typecomment included, is no longer attached to the inner expression;
a{#snippet}parameter's JSDoc cast keeps itsParenthesizedExpression, as Svelte's does - fix: a Svelte multi-line block comment's
valueis dedented by its own line in the document,
not by the text Svelte's reader handed acorn, so it can differ from Svelte's where a
<script>prefix, block binding or{#snippet}head shares that line