Skip to content

Releases: slevithan/oniguruma-to-es

v3.1.0

03 Feb 20:22
Compare
Choose a tag to compare

🚀 Features

  • Added support for lazy compilation of regexes (hat-tip @jeff-hykin for the idea).
    • New option lazyCompile in EmulatedRegExp.
    • New option lazyCompileLength in toRegExp/toRegExpDetails allows triggering the use of lazy compilation based on the length of the transpiled pattern.
  • toOnigurumaAst: Allow compile-time option rules.singleline (already supported by toRegExp/toRegExpDetails).

v3.0.0

01 Feb 04:03
Compare
Choose a tag to compare

🚨 Breaking

  • Renamed toDetails as toRegExpDetails.
  • Renamed type OnigurumaToEsOptions as ToRegExpOptions.
  • Renamed the browser bundle's global object as OnigurumaToEs.
  • EmulatedRegExp: Metadata for hidden/transfer captures no longer embedded in the pattern; provided via options.
  • Removed the rawArgs property of EmulatedRegExp instances; replaced with rawOptions. The pattern and flags properties of rawArgs are no longer needed for serialization.

🚀 Features

  • Improved regex construction performance when using the EmulatedRegExp subclass.
  • Added support for the subroutine behavior of only transferring subpattern matches to earlier capture slots when a subroutine participates in the match; also covered for complex cases when subroutines are used for/within recursion.
  • Improved some recursion-related error messages.

🐞 Fixes

  • Fixed cases where valid nested character classes starting and ending with : were treated as invalid POSIX classes. (#23)
  • Fixed subroutine capture transfer for edge cases with recursion. Now transfers from the last expanded instance for recursively repeated captures that precede the recursion token in the recursed subpattern's contents.

v2.3.0

21 Jan 15:06
Compare
Choose a tag to compare

🚀 Features

  • Added support for absent repeaters (?~…). (#13)

v2.2.0

20 Jan 04:28
Compare
Choose a tag to compare

🚀 Features

  • Added option rules.singleline (Oniguruma compile-time option ONIG_OPTION_SINGLELINE).
    • Handles ^ as \A and $ as \Z.
    • Improves performance of generated regexes without changing their meaning if used for line-by-line search.
  • Added support for invalid JS identifiers as group names, so long as they are valid in Oniguruma.

v2.1.0

16 Jan 23:07
Compare
Choose a tag to compare

🚀 Features

  • Restored support for subclass-based \G emulation in strict accuracy mode, for patterns without lookbehind.
  • Added support for use of a leading flag modifier when using keep directives (\K).
  • Improved error specificity for some invalid group names.

v2.0.0

14 Jan 20:08
Compare
Choose a tag to compare

This release brings full support for Oniguruma's \G anchor (which has no direct equivalent in JavaScript). This is a very flexible anchor, and previous versions supported some but not all ways that it could be used.

🚨 Breaking

  • Subclass strategy names that were used to support some cases of \G have been combined into a new strategy.
    • This is an internal-only change, but it can be breaking if you call the updated EmulatedRegExp constructor with details serialized from a previous version of this library.
  • The non-default strict accuracy mode no longer allows subclass-based emulation of \G.

🚀 Features

  • Added comprehensive support for the \G anchor via subclass-based emulation.
  • Added a CommonJS bundle. (#26, @vcschapp)
  • Added support for using \G in some positions where it can never match and forces backtracking (without the need for subclass-based emulation).
  • Removed option rules.ignoreUnsupportedGAnchors since it's no longer useful.

🐞 Fixes

  • Fixed some extremely unlikely uses of \G that could lead to mismatches with some target strings.

v1.0.0

08 Jan 13:41
Compare
Choose a tag to compare

Most of the changes and fixes in this release resulted from feedback by @RedCMD. ✨

Note that every fix and newly-supported syntax in this release addresses an extreme edge case that did not affect even one regex in the tens of thousands of Oniguruma regexes found in the TextMate grammars provided by Shiki.

🚨 Breaking

  • Redesigned the recursion depth limit around the fact that Oniguruma uses a limit of 20 (rather than an infinite or high-value depth like other regex flavors). (#19)
    • Moved option maxRecursionDepth to rules.recursionLimit.
    • Changed the default recursionLimit from 5 to 20.
    • Reduced the max recursionLimit from 100 to 20.
    • Removed the ability to disable support for recursion.
    • Setting accuracy to 'strict' no longer disables recursion.

🚀 Features

  • Support \x{…} values above 10FFFF at the end of character class ranges. (#22)
  • Validate lookbehind contents and throw if not supported by Oniguruma. (#24)
  • Support possessive interval quantifiers specified using a reversed range. (#25)
  • Error at compile time rather than runtime for Unicode property names that start with a digit.
  • Improved test coverage.

🐞 Fixes

  • Don't remove negation for negated character classes used in intersection that contain a single token (bug applied when using target ES2024 or later and option verbose not enabled).
  • Ignore insignificant hyphens in Unicode property names. (#16)
  • Don't throw for intersection with an empty set. (#17)
  • Don't throw for character class ranges ending with literal hyphens followed by character or character-set tokens. (#18)

v0.10.0

01 Jan 22:26
Compare
Choose a tag to compare

🚨 Breaking

  • toDetails: The subclass property on result objects was renamed as options, for consistency with EmulatedRegExp.

🚀 Features

  • Added a rawArgs property to EmulatedRegExp instances that can be used to serialize the object.
  • Added support for use of lone \G in any top-level alternative.
  • Environment support for duplicate group names is no longer required as a condition for target auto to use ES2025.
  • Improved EmulatedRegExp types.

🐞 Fixes

  • With target ES2025: Subpattern details on match results did not match Oniguruma in some cases when duplicate group names were used across mutually exclusive alternation paths. Results are now the same across all targets. (#14)
  • With pre-ES2025 targets: Duplicate characters were added in edge cases during mixed case-insensitivity expansion of character class ranges that included the same character in multiple cases. This had no effect on resulting matches, but generated regex source is now cleaner in these cases.

v0.9.0

27 Dec 02:39
Compare
Choose a tag to compare

🚨 Breaking

  • Option allowUnhandledGAnchors renamed as ignoreUnsupportedGAnchors.

🚀 Features

  • Externalized dependencies for the ESM bundle. (#12, @bluwy)
  • No longer restricting Unicode properties based on target. (#10)

🐞 Fixes

  • Switched to preserving duplicate group names on the first instance (rather than the last per mutually exclusive alternation path), to match Oniguruma's match results in cases affected by subroutines and duplicate group names.
  • When option avoidSubclass is not enabled:
    • Hide subpattern details from match results for captures created by emulated subroutines.
    • Transfer subroutine (and descendent) capture details on match results to the indexes of groups they reference (if preceding) to match Oniguruma's subpattern match results/ordering.

v0.8.1

21 Dec 01:12
Compare
Choose a tag to compare

🐞 Fixes

  • When the following conditions were all met, the indices values of result arrays could be incorrect.
    1. Options hasIndices and global both enabled.
    2. The pattern included (^|\G) or similar.
    3. The generated regex was used with a lastIndex greater than 0.