Mini-racer

Latest version: v0.12.0

Safety actively analyzes 624643 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 6

0.12.0

- Added support for installing callbacks from JS back into Python, using
MiniRacer.wrap_py_function.

- Refactored the Python implementation into many internal files. This should mostly not
present a breaking change, except for code which reaches into internal
(`_`-prefixed) variables.

0.11.1

- Fixed Python crash on long-running microtasks, introduced in v0.8.1 (before which
long-running microtasks would probably not run at all).

- Fixed memory leak on the exception object reported when an `eval` times out.

- Hardened the memory management of JS value interchange, context tracking, and
asynchronous task tracking between C++ and Python.

- Added exhaustive typing (now with a MyPy pre-commit to verify!)

- Added a test asserting that [the v8 sandbox](https://v8.dev/blog/sandbox) is enabled
on all platforms we build wheels for.

0.11.0

- Added a `MutableMapping` (`dict`-like) interface for all derivatives of JS Objects,
and a `MutableSequence` (`list`-like) interface for JS Arrays. You can now use
Pythonic idioms to read and write Object properties and Array elements in Python,
including recursively (i.e., you can read Objects embedded in other objects, and
embed your own).

- Added ability to directly call `JSFunction` objects from Python. E.g.,
`mr.eval("a => a*a")(4)` parses the given number-squaring code into a function,
returns a handle to that function to Python, calls it with the number `4`, and
recieves the result of `16`.

- Added a `JSUndefined` Python object to model JavaScript `undefined`. This is needed to
properly implement the above interface for reading Object and Array elements.
*Unfortunately, this may present a breaking change for users who assume JavaScript
`undefined` is modeled as Python `None`.*

- Removed an old optimization for `eval` on simple no-argument function calls (i.e.,
`myfunc()`). The optimization only delivered about a 17% speedup on no-op calls (and
helped relatively *less* on calls which actually did work), and for the purpose of
optimizing repeated calls to the same function, it's now redundant with extracting
and calling the function from Python, e.g., `mr.eval("myfunc")()`.

- Hardening (meaning "fixing potential but not-yet-seen bugs") related to freeing
`BinaryValue` instances (which convey data from C++ to Python).

- More hardening related to race conditions on teardown of the `MiniRacer` object in the
unlikely condition that `eval` operations are still executing on the C++ side, and
abandoned on the Python side, when Python attempts to garbage collect the
`MiniRacer` object.

0.10.0

- Updated to V8 12.3 from V8 12.2 now that Chromium stable is on 12.3.

- Added Python-side support for JS Promises. You can now return a JS Promise from code
executed by `MiniRacer.eval`, and PyMiniRacer will convert it to a Python object
which has a blocking `promise.get()` method, and also supports `await promise` in
`async` Python functions.

- Added a `setTimeout` and `clearTimeout`. These common functions live in the Web API
standard, not the ECMAScript standard, and thus don't come with V8, but they're so
ubiquitious we now ship an implemention with `PyMiniRacer`.

0.9.0

- Revamped JS execution model to be out-of-thread. Python/C++ interaction now happens
via callbacks.

- Consequently, Control+C (`KeyboardInterrupt`) now interrupts JS execution.

- Hardened C++-side thread safety model, resolving potential race conditions introduced
in v0.8.1 (but not actually reported as happening anywhere).

- Further improved JS exception reporting; exception reports now show the offending code
where possible.

- Introduced `timeout_sec` parameter to `eval`, `call`, and `execute` to replace the
`timeout`, which unfortunately uses milliseconds (unlike the Python standard
library). In the future we may emit deprecation warnings for use of `timeout`.

0.8.1

- A series of C++ changes which should not impact the behavior of PyMiniRacer:
- Refactoring how we use V8 by inverting the control flow. Before we had function
evaluations which ran and drained the message loop. Now we have an always-running
message loop into which we inject function evaluations. This seems to be the
preferred way to use V8. This is not expected to cause any behavior changes (but, in
tests, makes
[microtask competion](https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide)
more consistent).
- Refactoring the C++ implementation into multiple components to make startup and
teardown logic more robust.
- Added tests for the existing fast-function-call path.
- Also, simplified Python conversion of C++ evaluation results.

Page 1 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.