* Add more utility traits and funtions to boa_interop
* cargo clippy
* Readd the safe version for Fn which also implements Copy
* Use a new trait for converting a Rust type to a JsResult<JsValue>
* cargo clippy
* Add a test for returning result and Fn()
* Seal both IntoJsFunction and IntoJsFunctionUnsafe
* Try Borrowing and return a nice error instead of panicking
* Address comments
* Rename into_js_function to into_js_function_copied
* Move TryIntoJsResult to boa_engine
* Move JsRest to be at the end only of arguments and add JsAll
* use from_copy_closure and remove unsafe
* Add a HostDefined struct to grab host defined in the argument list
* cargo fmt and clippy
* Explain why we need Clone
* Remove the vector from JsRest<> and use a reference
* Add HostDefined to context as Data, and rename the injector in boa_interop
* Use TypeError instead if the type was not found in context
* Update core/interop/src/lib.rs
Co-authored-by: José Julián Espina <jedel0124@gmail.com>
* cargo fmt
* cargo fmt
---------
Co-authored-by: José Julián Espina <jedel0124@gmail.com>
* Add an embed_module!() macro to boa_interop
The macro creates a ModuleLoader that includes all JS files from a directory.
* Add description of function
* Run prettier
* Remove reference to a unaccessible crate
* Remove one more reference to a unaccessible crate
* Disable test that plays with paths on Windows
* Block the whole test module instead of just the fn
* This is a bit insane
* Replace path separators into JavaScript specifier separators
* cargo fmt
* cargo fmt part deux
* fix some issues with relative path and pathing on windows
* fix module resolver when there are no base path
* use the platform's path separator
* cargo fmt
* prettier
* Remove caching of the error
* Pedantic clippy gonna pedant
* Add functions to create modules from a JSON value
* Move json_module to Module::from_value_as_default
* Flag the whole json module behind the json feature
* Rename and add doc
* Add TryFromJs for more types
* Add a new type Coerce<> to coerce values
This can be used to transform values in to coerced versions by
using the type system and TryFromJs.
* Fix build error
* Rename Coerce<> to Convert<>
* replace missed coerce to Convert
* cargo fmt and clippy
* Add more utility traits and funtions to boa_interop
* cargo clippy
* Readd the safe version for Fn which also implements Copy
* Use a new trait for converting a Rust type to a JsResult<JsValue>
* cargo clippy
* Add a test for returning result and Fn()
* Seal both IntoJsFunction and IntoJsFunctionUnsafe
* Try Borrowing and return a nice error instead of panicking
* Address comments
* Rename into_js_function to into_js_function_copied
* Move TryIntoJsResult to boa_engine
* Move JsRest to be at the end only of arguments and add JsAll
* use from_copy_closure and remove unsafe
* Properly resolve paths in SimpleModuleLoader and add path to Referrer::Script
* Add missing example
* Carry active runnable on frame push
* Duplicate the tests with proper paths for Windows/Unix
* Use the right root for absolute referrers
* ugh cargo fmt
* Limit doctest to unix
* Limit doctest to unix, for real
* cargo fmt
---------
Co-authored-by: jedel1043 <jedel0124@gmail.com>
* Add an integration test for relative imports on SimpleModuleLoader
* Add a path to Module (and expose it in Referrer)
This allows SimpleModuleLoader to resolve relative to the current
file (which this commit also does).
Fixes#3782
* cargo clippy and fmt
* prettier
* Fix merge error
* Add a boa_interop crate
This crate will contain types and functions to help integrating
boa in Rust projects, making it easier to interop between the
host and the JavaScript code.
See https://github.com/boa-dev/boa/discussions/3770
* Remove unnecessary into_iter()
* cargo fmt
* cargo clippy
* Make IntoJsFunction unsafe
* Remove unused code
* Allow deserialization of missing objects properties into Option<>
Currently the TryFromJs derive macro requires that all properties
be defined in the object, whether they are declared as Option<> or
not. This commit makes it so if the field is not found in the
JsObject, we try to deserialize undefined.
This is more in line with JavaScript behaviour.
* Fix cargo fmt
* Fix clippies
* Empty commit to trigger rerun of workflow
* Remove circular dependency between boa_engine and boa_macros
* Missing "::" in macro
---------
Co-authored-by: jedel1043 <jedel0124@gmail.com>
In previous implementation when converting a number to PropertyKey, we
always converted it to string and only when the conversion to
PropertyKey::Index was not possible we returned that string.
* Swap to Duration::round from temporal_rs
* Clean up round method and impl From for RoundingMode enum
* Fix build failure
* Fix clippy error
* Respond to comments
* Remove commented line
* Add a try_from_js implementation for Vec<T> (accept any Array-like)
* Use safe conversion to usize
* Fix typing compile error
* Fix clippies and fmt
* Remove println from test
* Add a negative test