Commit graph

8 commits

Author SHA1 Message Date
Simon Hausmann
5d102bc838 napi: Fix access to diagnostics
Invoking the diagnostics getter would throw an exception because the JsDiagnostic type has no constructor.

There's however no constructor that would allow for the previous
laziness, so instead this PR bites the bullet:

- When diagnostics are requested, we convert them all in one go into proper JavaScript objects.
- The vector returned by line_column is replaced with more idiomatic column and lineNumber properties
2023-08-08 13:46:53 +02:00
Simon Hausmann
4679bb6c38 napi: In the test for data structure conversion, remove the unrelated boolean property test 2023-08-08 13:45:02 +02:00
Simon Hausmann
23e4f4e6fe napi: In the tests, don't rely on the current process working directory
Instead, resolve the path to resources/rgb.png relative
to the test file.
2023-08-08 13:44:46 +02:00
Simon Hausmann
63df4b78c3 napi: Add tests that verify that lookup of non-existent global callbacks and properties fails 2023-08-08 13:44:12 +02:00
Simon Hausmann
7c8b49743c napi: Remove unnecessary dependencies
Let's add them later when we need to
2023-08-08 13:43:52 +02:00
Simon Hausmann
0007a0c0d9 napi: Remove unnecessary cargo build
Since this file is part of the repository workspace, we
should use the common profile in the top-level Cargo.toml.
2023-08-07 17:20:47 +02:00
Simon Hausmann
56feda7ad9 napi: Fix typo in file name 2023-08-07 13:30:06 +02:00
Florian Blasius
b375b67467
Initial setup for napi-rs port (#3171)
* Startup with napi.

* Added interpreter api for napi.

* Initial implementation of set_property/get_property on ComponentInstance

Co-authored-by: Florian Blasius <FloVanGH@users.noreply.github.com>

* fixup! minimal napi setup

* Type conversion for napi.

* Work on napi callbacks.

* Fix life-time of JsFunction kept in closures for callbacks

The life-time of napi values is limited to the method invocation from napi itself.
In order to keep a value beyond that, it's necessary to use persistent references:

https://nodejs.org/api/n-api.html#references-to-values-with-a-lifespan-longer-than-that-of-the-native-method

* Added callback tests for napi.

* Fix licenses for napi stuff.

* Update api/napi/src/interpreter/component_instance.rs

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>

* Update api/napi/src/interpreter/component_instance.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Code review stuff

* Update api/napi/src/interpreter/component_definition.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update api/napi/src/interpreter/component_instance.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update api/napi/src/interpreter/component_instance.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* code review fixes

* ci fix

* code review fixes.

* up

* Revert "up"

This reverts commit 06412f1acf.

* ci fix

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
Co-authored-by: Florian Blasius <FloVanGH@users.noreply.github.com>
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-07 10:44:05 +02:00