Visitar URL original
sh-syntax/CHANGELOG.md at main · un-ts/sh-syntax · GitHub
Skip to content

Latest commit

 

History

History
332 lines (192 loc) · 19.7 KB

CHANGELOG.md

File metadata and controls

332 lines (192 loc) · 19.7 KB

sh-syntax

0.8.7

Patch Changes

  • #185 7df9dae Thanks @JounQin! - Add createInteractiveParser() for REPL-style chunked parsing. Each write(chunk) returns the statements completed by that chunk, the unconsumed trailing text, and whether it is incomplete.

  • #187 ac975ad Thanks @JounQin! - Update mvdan.cc/sh/v3 to a pinned commit containing the parser nesting limit, BraceExp walk support, heredoc/Interactive fixes, and current AST fields. AST heredoc redirects now expose closePos, and split brace expansions retain their brace positions. Deeper JS/WASM transport handling, including the nesting limit's practical ceiling, remains tracked in #188.

0.8.6

Patch Changes

  • #180 8c770b7 Thanks @JounQin! - Expose stable error classes and codes. ParseError now extends ShSyntaxError/SyntaxError and reports name: "ParseError"; InputError extends TypeError; other syntax failures use ShSyntaxError with one of SH_SYNTAX_LANGUAGE, SH_SYNTAX_PRINT, or SH_SYNTAX_SPLIT_BRACES.

0.8.5

Patch Changes

  • #176 889d042 Thanks @JounQin! - Use a generated binary wire for AST transport, removing the JSON parser and encoding/json from the WASM path.

  • #173 ac1cbee Thanks @JounQin! - print(ast) now prints the current syntax tree, including edits made to its fields, instead of requiring originalText.

  • #178 910c9a3 Thanks @JounQin! - print(node) now prints printable syntax subtrees: files, statements, commands, words, word parts, and assigns. File output keeps its trailing newline; subtree output does not.

  • #179 fec2d3f Thanks @JounQin! - Add splitBraces(word) returning { word, changed } to split brace expressions into BraceExp parts for analysis. changed is true when mvdan processed brace syntax, even if no BraceExp remains. The returned word keeps its original source span. Split literals lack source positions, while composite BraceExp bounds may be derived from retained children and serialized. The printer cannot render BraceExp; such trees are rejected explicitly.

0.8.4

Patch Changes

  • #163 6235123 Thanks @JounQin! - Add init() to load the WASM runtime explicitly and cache it. The async parse and print APIs initialize automatically. init() now rejects when the Go program fails to start instead of reporting success and leaking an unhandled rejection. The browser entry now uses the same init() plus async API without top-level await.

  • #162 532ecab Thanks @JounQin! - Add createSourceIndex, which converts the AST's UTF-8 byte offsets to UTF-16 code-unit offsets for JavaScript string slicing.

  • #167 68f9c6c Thanks @JounQin! - Move the synchronous API to the sh-syntax/sync entry (Node and browser top-level await variants; workerd has no sync variant and fails at build/import time) and keep the root entry async-only. The old parseSync / printSync names are now parse / print from sh-syntax/sync.

  • #168 dcbe443 Thanks @JounQin! - Surface Go startup failures from both async init() and the synchronous sh-syntax/sync processor instead of leaking an unhandled rejection.

  • #160 a3227de Thanks @JounQin! - Add enter/exit visitors to walk: a function is the enter phase, an object may pair optional enter with required exit, and visitors receive (node, parent, prop, index). Returning false from enter skips a node's children; returning false from exit stops the walk.

  • #164 94ee1ab Thanks @JounQin! - Add a dedicated workerd entry that imports the bundled main.wasm as a compiled module and exports the same async init / parse / print API. getProcessor now also accepts a compiled WebAssembly.Module.

0.8.3

Patch Changes

  • #157 d326627 Thanks @JounQin! - Keep the vendored Go runtime in bundled builds by pointing sideEffects at vendors/wasm_exec.cjs instead of the renamed vendors/wasm_exec.js.

0.8.2

Patch Changes

  • #155 ac466ec Thanks @JounQin! - Build WASM with standard Go instead of TinyGo. The standard Go GC removes the -gc=leaking memory growth that made long-running synchronous parsing unsafe. The binary is larger; a fresh runtime has higher startup cost, although async reuse amortizes it. wasm-opt -Oz is used to trim the final artifact. The async processor now reuses one Go runtime and serializes calls, so it no longer pays WASM instantiation cost per call. That runtime retains the Go heap high-water mark for the processor lifetime; memory stays bounded but does not shrink after a large parse. The internal process ABI changed, so main.wasm must match the package version.

0.8.1

Patch Changes

  • #148 84a41e5 Thanks @renovate! - Update mvdan.cc/sh/v3 to 3.14.1 and expose the new ParamExp fields globSubst, rcExpand, and split, and refresh the Go/TinyGo toolchain.

0.8.0

Minor Changes

  • #145 8f2c8c6 Thanks @JounQin! - Return the full shell syntax tree and keep printing source text.

    Breaking changes

    • Node.js >=18 is required.

    • The AST is no longer Go-shaped. Fields are lowerCamelCase and node positions are explicit: use node.type, start/end, and { offset, line, column } objects instead of Pos/End, Stmts, Cmd, Parts, Value, and the other Go field names.

    • ParseError / IParseError fields are renamed from Go style: Filename → filename, Incomplete → incomplete, Text → text, and Pos → pos.

    • Operator-valued fields (op) now use the upstream numeric enum values instead of display strings. Typed constants such as RedirOperator, CaseOperator, ProcOperator, and BinAritOperator are exported.

    • Word.Lit is gone; use parts. File.Last is now lastComments.

    • print(ast) without originalText is no longer supported and throws a TypeError. Printing an edited AST is deferred to a follow-up; the AST is currently a parse result, not a second input format.

    Features

    • parse() now returns every node and field from mvdan.cc/sh's syntax package instead of only positions. The tree is plain JSON-compatible data: every node has type, start, and end; fields use lowerCamelCase; and position fields are { offset, line, column } objects.
    • Add a walk() helper for the typed tree; use node.type instead of a node-type helper.
    • Public AST types are a discriminated union: BaseNode plus literal type fields, with Node, Command, WordPart, Loop, ArithmExpr, and TestExpr unions so node.type narrows in TypeScript.
    • print() continues to format source text. print(ast, { originalText }) and processor(ast, { originalText }) remain accepted for tooling compatibility, but the AST is deliberately ignored and originalText is formatted.
    • getProcessor() caches the compiled WebAssembly module, uses compileStreaming() for application/wasm responses, accepts Buffer/BufferSource/Response/response-like sources, and instantiates a fresh runtime per call.
    • Add parseSync() and printSync() for bounded synchronous work, plus getProcessorSync() for preloaded WASM bytes or a synchronous loader. Long-lived processes should use the async APIs; the TinyGo leaking GC means unbounded synchronous loops accumulate memory.
    • Positions recovered by recoverErrors now expose recovered: true.

0.7.0

Minor Changes

0.6.0

Minor Changes

  • #136 ecd5eb7 Thanks @jjloneman! - Add zsh dialect support by rebuilding the WASM against a newer mvdan/sh:

    • Rebuild main.wasm against mvdan/sh v3.13.1 (was v3.11.0) and expose the zsh LangVariant.
    • Valid zsh such as ${0:A:h:h} now parses and prints instead of erroring with ternary operator missing ? before :.

    Breaking: LangVariant is now a bit-flag enum (1 << iota) to match mvdan/sh v3.13, so every numeric value changed. Code using the exported LangVariant constants is unaffected; only code passing raw variant numbers needs updating:

    • LangBash: 0 → 1
    • LangPOSIX: 1 → 2
    • LangMirBSDKorn: 2 → 4
    • LangBats: 3 → 8
    • LangZsh: (new) → 16
    • LangAuto: 4 → 32

Patch Changes

  • #138 2aa922b Thanks @JounQin! - Fix File.Stmts JSON field name to match the mvdan/sh syntax library, correcting a serialization mismatch between the WASM runtime and TypeScript types.

  • #139 eea166d Thanks @JounQin! - Remove unused tslib from dependencies.

0.5.8

Patch Changes

0.5.7

Patch Changes

0.5.6

Patch Changes

0.5.5

Patch Changes

0.5.4

Patch Changes

0.5.3

Patch Changes

0.5.2

Patch Changes

  • #107 3152cd3 Thanks @JounQin! - feat: add new LangVariant option LangAuto although it's unsupported

0.5.1

Patch Changes

0.5.0

Minor Changes

  • #97 28d68ba Thanks @JounQin! - chore: housekeeping, bump mvdan/sh and easyjson deps, upgrade go to v1.23

Patch Changes

0.4.2

Patch Changes

0.4.1

Patch Changes

  • 5760ee9 Thanks @JounQin! - fix: better LangVariant typing for compatibility with mvdan-sh

0.4.0

Minor Changes

  • e13b13a Thanks @JounQin! - fix: add a trailing 0 for bytes, this should fix several known issues

    feat: drop node 14 support

0.3.7

Patch Changes

0.3.6

Patch Changes

0.3.5

Patch Changes

0.3.4

Patch Changes

0.3.3

Patch Changes

0.3.2

Patch Changes

  • 6193518 Thanks @JounQin! - chore(deps): upgrade sh v3.5.1 and tinygo v0.23.0

0.3.1

Patch Changes

0.3.0

Minor Changes

0.2.1

Patch Changes

0.2.0

Minor Changes

0.1.4

Patch Changes

  • #15 174f66c Thanks @JounQin! - fix: use global Go to store text due to go.argv limitation

0.1.3

Patch Changes

0.1.2

Patch Changes

0.1.1

Patch Changes

0.1.0

Minor Changes

0.0.2

Patch Changes

0.0.1

Patch Changes