Skip to content

Releases: adalinesimonian/jshiki

v3.4.0

10 Sep 20:16
8ea130c
Compare
Choose a tag to compare

Additions

  • Asynchronous expressions are now supported!
    • parseAsync returns an async function
      const expr = jshiki.parseAsync('1 + 2')
      await expr() // => 3
    • evaluateAsync returns a promise
      await jshiki.evaluateAsync('1 + 2') // => 3
    • await is supported within async expressions
      const expr = jshiki.parseAsync('await a()')
      await expr({ a: async () => 1 }) // => 1

Fixes

  • Fixed bug where calling a method on a property using optional chaining syntax would instead operate as though regular member access was used. Example:

    // Prior behavior:
    jshiki.evaluate('a?.b?.()') // throws TypeError
    jshiki.evaluate('a?.b()') // throws TypeError
    
    // Patched behaviour:
    jshiki.evaluate('a?.b?.()') // returns undefined
    jshiki.evaluate('a?.b()') // returns undefined

Development changes

  • Unit tests are now run before functional tests.
  • Updated yarn to 3.0.2

Full Changelog

v3.3.0

08 Sep 21:00
ed9fdf1
Compare
Choose a tag to compare

Additions

  • typeof, in, and instanceof operators are now supported. They are disabled by default to maintain behaviour with prior versions of jshiki.

Fixes

  • Fixed bug where rules with ** wildcards would be incorrectly evaluated in certain cases.

Documentation

  • Documented that rules do not affect properties of values that are not objects or functions due to limitations of proxies.

Development changes

  • Coverage split between unit and functional tests.
  • Unit tests have 100% coverage.
  • Tests that used snapshots to check errors thrown by Node for property access on null and undefined have been edited to test without using snapshots. This is due to a change in V8 that changes the format of the error message, included in the version of V8 used by Node 16.9.0 and above.
  • Type in SVG assets has been converted to outlines.
  • VS Code configured to use the workspace version of Typescript.

Full Changelog

v3.2.0

29 Aug 17:03
a039cf8
Compare
Choose a tag to compare

Additions

  • Specific operators can now be blocked or allow-listed:
    // throws Error: Binary operator / is not allowed.
    jshiki.parse('a / b', {
      operators: {
        binary: { allow: ['+', '-'] },
      },
    })
  • Specific syntax can now be blocked:
    // throws Error: Function calls are not allowed.
    jshiki.parse('a()', {
      syntax: {
        calls: false,
      },
    })

Documentation

  • Fixed edit links by pointing them to the correct branch.
  • Fixed codecov link in the readme.

Full Changelog

v3.1.0 — Types and documentation

27 Aug 23:00
b0001d5
Compare
Choose a tag to compare

Additions

  • The following types are now exported in the package entry point:
    • JshikiParseOptions
    • JshikiEvaluateOptions
    • JshikiExpression
    • AccessPath
    • AccessRule
    • AllowAccessRule
    • BlockAccessRule

Development Changes

Full Changelog

v3.0.0 — ES2020, parsing with acorn

20 Aug 22:39
e7a07bf
Compare
Choose a tag to compare

BREAKING CHANGES

  • parse() now returns an expression that expects the scope to be passed as an argument. This allows reusing the same expression in different contexts without having to parse the expression or rules again. For example:
    const expression = jshiki.parse('`Hello ${name}!`')
    const result = expression({ name: 'Azumi' })
    // result => 'Hello Azumi!'
  • ES2020 syntax is now supported, and support for Node 12.x has been dropped.
  • NaN and Infinity identifiers are now supported.
  • Unicode escape sequences \x and \u are now supported.
  • The bundled, custom version of esprima has been entirely removed and replaced with an external dependency on acorn, a fast, lightweight Javascript parser. The corresponding licences for Polymer Expressions and esprima have been removed from the project as the code to which they pertain is no longer part of the project.

Fixes

  • Fixed a bug where holes in sparse arrays were being evaluated as null.
  • Fixed a bug where undefined could evaluate to a value other than undefined if a property named undefined was defined on the scope object.
  • Fixed a bug where calling a function returned by a function would not evaluate and instead return the function.
  • Fixed a bug where computed property accessors were not being evaluated (obj[prop] was being evaluated as obj['prop'] instead of obj[prop]).
  • Fixed a bug where a function member of a scope object that returned this would result in a TypeError being thrown.
  • Fixed a bug where a function member of a scope object could not access properties on this.
  • Fixed a bug where logical operators (&&, ||) would evaluate both operands before evaluating the result.

Development changes

  • Test coverage is now 100%.
  • Node 12.x has been dropped from the test matrix.

Full Changelog

v2.1.0 — Rule-based access control

17 Aug 20:07
191c4d0
Compare
Choose a tag to compare

Additions

  • New options rules and explicitAllow, which facilitate rules-based access control for scope members. Documentation available in the README.
  • Documentation added to API.

Development changes

  • More robust, less hacky evaluation of expressions internally.
  • AST information retained on expressions.

Full Changelog

v2.0.0 — Typescript Rewrite

13 Aug 00:50
9d4b77c
Compare
Choose a tag to compare

BREAKING CHANGES

  • parse() now returns the expression function instead of an object
  • Polymer Expressions holdovers (filters, as/in expressions) removed
  • Errors thrown when parsing invalid expressions are now thrown when parsing instead of during evaluation

Additions

  • evaluate(), which executes an expression immediately, added to API

Fixes

  • Tests for the << bitwise left shift and >> bitwise right shift operators fixed; prior, the tests mistakenly used < and > instead of << and >>

Development changes

Full Changelog

v1.1.1

19 May 23:41
Compare
Choose a tag to compare
  • Repository path updated

Exponential and Bitwise Operators

04 Jul 00:32
Compare
Choose a tag to compare

Full Changelog

Implemented enhancements:

  • Added exponential and bitwise operators. #1 (emorris00)

Fully ES6 implementation

29 Jun 18:37
Compare
Choose a tag to compare
  • Now requires Node.js 8.x at minimum
  • ES6 classes used internally
  • Upgraded development dependencies to latest versions