Releases: adalinesimonian/jshiki
Releases · adalinesimonian/jshiki
v3.4.0
Additions
- Asynchronous expressions are now supported!
parseAsync
returns an async functionconst expr = jshiki.parseAsync('1 + 2') await expr() // => 3
evaluateAsync
returns a promiseawait jshiki.evaluateAsync('1 + 2') // => 3
await
is supported within async expressionsconst 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
v3.3.0
Additions
typeof
,in
, andinstanceof
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
andundefined
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.
v3.2.0
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.
v3.1.0 — Types and documentation
Additions
- The following types are now exported in the package entry point:
JshikiParseOptions
JshikiEvaluateOptions
JshikiExpression
AccessPath
AccessRule
AllowAccessRule
BlockAccessRule
Development Changes
- Documentation site added using mkdocs and mkdocs-material.
v3.0.0 — ES2020, parsing with acorn
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
andInfinity
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 thanundefined
if a property namedundefined
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 asobj['prop']
instead ofobj[prop]
). - Fixed a bug where a function member of a scope object that returned
this
would result in aTypeError
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.
v2.1.0 — Rule-based access control
Additions
- New options
rules
andexplicitAllow
, 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.
v2.0.0 — Typescript Rewrite
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
- Rewritten in TypeScript
- Switched to jest for testing
- Switched CI to Github Actions
v1.1.1
- Repository path updated
Exponential and Bitwise Operators
Fully ES6 implementation
- Now requires Node.js 8.x at minimum
- ES6 classes used internally
- Upgraded development dependencies to latest versions