Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ⬆️ Upgrade to rquickjs 0.6.2 #377

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions llrt_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ crc32c = "0.6.5"
crc32fast = "1.4.0"
phf = "0.11.2"
md-5 = { version = "0.10.6", features = ["asm"] }
rquickjs = { version = "0.5.1", features = [
rquickjs = { version = "0.6.2", features = [
"full-async",
"parallel",
"rust-alloc",
Expand Down Expand Up @@ -80,7 +80,7 @@ brotlic = "0.8.2"
idna = "0.5.0"

[build-dependencies]
rquickjs = { version = "0.5.1", features = [
rquickjs = { version = "0.6.2", features = [
"full-async",
"rust-alloc",
], default-features = false }
Expand Down
6 changes: 2 additions & 4 deletions llrt_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ async fn main() -> StdResult<(), Box<dyn Error>> {
lrt_filenames.push(lrt_filename.clone());
let bytes = {
{
let module = unsafe {
Module::unsafe_declare(ctx.clone(), module_name.clone(), source)
}?;
module.write_object(false)
let module = Module::declare(ctx.clone(), module_name.clone(), source)?;
module.write(false)
}
}
.catch(&ctx)
Expand Down
4 changes: 2 additions & 2 deletions llrt_core/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ pub async fn compile_file(input_filename: &Path, output_filename: &Path) -> Resu

trace!("Compiling module: {}", module_name);

let module = unsafe { Module::unsafe_declare(ctx.clone(), module_name, source).unwrap() };
let bytes = module.write_object(false).unwrap();
let module = Module::declare(ctx.clone(), module_name, source).unwrap();
let bytes = module.write(false).unwrap();
let filename = output_filename.to_string_lossy().to_string();
let compressed = compress_module(&bytes).unwrap();
fs::write(filename, &compressed).unwrap();
Expand Down
8 changes: 4 additions & 4 deletions llrt_core/src/compiler_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
pub struct DummyLoader;

impl rquickjs::loader::Loader for DummyLoader {
fn load(
fn load<'js>(
&mut self,
_ctx: &rquickjs::Ctx<'_>,
ctx: &rquickjs::Ctx<'js>,
name: &str,
) -> rquickjs::Result<rquickjs::module::ModuleData> {
Ok(rquickjs::module::ModuleData::source(name, ""))
) -> rquickjs::Result<rquickjs::module::Module<'js>> {
rquickjs::module::Module::declare(ctx.clone(), name, "")
}
}

Expand Down
6 changes: 3 additions & 3 deletions llrt_core/src/modules/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ pub fn init<'js>(ctx: &Ctx<'js>) -> Result<()> {
pub struct BufferModule;

impl ModuleDef for BufferModule {
fn declare(declare: &mut Declarations) -> Result<()> {
fn declare(declare: &Declarations) -> Result<()> {
declare.declare(stringify!(Buffer))?;
declare.declare_static(cstr!("default"))?;
declare.declare_c_str(cstr!("default"))?;

Ok(())
}

fn evaluate<'js>(ctx: &Ctx<'js>, exports: &mut Exports<'js>) -> Result<()> {
fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
let globals = ctx.globals();
let buf: Constructor = globals.get(stringify!(Buffer))?;

Expand Down
4 changes: 2 additions & 2 deletions llrt_core/src/modules/child_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ where
pub struct ChildProcessModule;

impl ModuleDef for ChildProcessModule {
fn declare(declare: &mut Declarations) -> Result<()> {
fn declare(declare: &Declarations) -> Result<()> {
declare.declare("spawn")?;
declare.declare("spawnSync")?;
declare.declare("exec")?;
Expand All @@ -514,7 +514,7 @@ impl ModuleDef for ChildProcessModule {
Ok(())
}

fn evaluate<'js>(ctx: &Ctx<'js>, exports: &mut Exports<'js>) -> Result<()> {
fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
Class::<ChildProcess>::register(ctx)?;
Class::<DefaultWritableStream>::register(ctx)?;
Class::<DefaultReadableStream>::register(ctx)?;
Expand Down
6 changes: 3 additions & 3 deletions llrt_core/src/modules/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ impl LogLevel {
pub struct ConsoleModule;

impl ModuleDef for ConsoleModule {
fn declare(declare: &mut Declarations) -> Result<()> {
fn declare(declare: &Declarations) -> Result<()> {
declare.declare(stringify!(Console))?;
declare.declare("default")?;

Ok(())
}

fn evaluate<'js>(ctx: &Ctx<'js>, exports: &mut Exports<'js>) -> Result<()> {
fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
Class::<Console>::register(ctx)?;

export_default(ctx, exports, |default| {
Expand Down Expand Up @@ -199,7 +199,7 @@ fn stringify_primitive<'js>(
Type::String => result.push_str(&value.as_string().unwrap().to_string()?),
Type::Symbol => {
let description = value.as_symbol().unwrap().description()?;
let description = description.to_string()?;
let description = description.into_string().unwrap().to_string()?;
result.push_str("Symbol(");
if description != "undefined" {
result.push_str(&description);
Expand Down
4 changes: 2 additions & 2 deletions llrt_core/src/modules/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub fn init(ctx: &Ctx<'_>) -> Result<()> {
pub struct CryptoModule;

impl ModuleDef for CryptoModule {
fn declare(declare: &mut Declarations) -> Result<()> {
fn declare(declare: &Declarations) -> Result<()> {
declare.declare("createHash")?;
declare.declare("createHmac")?;
declare.declare("Crc32")?;
Expand All @@ -175,7 +175,7 @@ impl ModuleDef for CryptoModule {
Ok(())
}

fn evaluate<'js>(ctx: &Ctx<'js>, exports: &mut Exports<'js>) -> Result<()> {
fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
Class::<Hash>::register(ctx)?;
Class::<Hmac>::register(ctx)?;
Class::<ShaHash>::register(ctx)?;
Expand Down
4 changes: 2 additions & 2 deletions llrt_core/src/modules/encoding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ impl HexModule {
}

impl ModuleDef for HexModule {
fn declare(declare: &mut Declarations) -> Result<()> {
fn declare(declare: &Declarations) -> Result<()> {
declare.declare(stringify!(encode))?;
declare.declare(stringify!(decode))?;
declare.declare("default")?;
Ok(())
}

fn evaluate<'js>(ctx: &Ctx<'js>, exports: &mut Exports<'js>) -> Result<()> {
fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
export_default(ctx, exports, |default| {
default.set(stringify!(encode), Func::from(Self::encode))?;
default.set(stringify!(decode), Func::from(Self::decode))?;
Expand Down
6 changes: 3 additions & 3 deletions llrt_core/src/modules/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ impl<'js> AbortSignal<'js> {

for signal in signals.iter() {
let signal: Value = signal?;
let signal: Class<AbortSignal> = Class::from_value(signal)
let signal: Class<AbortSignal> = Class::from_value(&signal)
.map_err(|_| Exception::throw_type(&ctx, "Value is not an AbortSignal instance"))?;
let signal_borrow = signal.borrow();
if signal_borrow.aborted {
Expand Down Expand Up @@ -633,14 +633,14 @@ impl<'js> AbortSignal<'js> {
pub struct EventsModule;

impl ModuleDef for EventsModule {
fn declare(declare: &mut Declarations) -> Result<()> {
fn declare(declare: &Declarations) -> Result<()> {
declare.declare(stringify!(EventEmitter))?;
declare.declare("default")?;

Ok(())
}

fn evaluate<'js>(ctx: &Ctx<'js>, exports: &mut Exports<'js>) -> Result<()> {
fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
let ctor = Class::<EventEmitter>::create_constructor(ctx)?
.expect("Can't create EventEmitter constructor");
ctor.set(stringify!(EventEmitter), ctor.clone())?;
Expand Down
8 changes: 4 additions & 4 deletions llrt_core/src/modules/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub const CONSTANT_X_OK: u32 = 1;
pub struct FsPromisesModule;

impl ModuleDef for FsPromisesModule {
fn declare(declare: &mut Declarations) -> Result<()> {
fn declare(declare: &Declarations) -> Result<()> {
declare.declare("access")?;
declare.declare("open")?;
declare.declare("readFile")?;
Expand All @@ -60,7 +60,7 @@ impl ModuleDef for FsPromisesModule {
Ok(())
}

fn evaluate<'js>(ctx: &Ctx<'js>, exports: &mut Exports<'js>) -> Result<()> {
fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
Class::<Dirent>::register(ctx)?;
Class::<Stat>::register(ctx)?;

Expand All @@ -84,7 +84,7 @@ impl From<FsPromisesModule> for ModuleInfo<FsPromisesModule> {
pub struct FsModule;

impl ModuleDef for FsModule {
fn declare(declare: &mut Declarations) -> Result<()> {
fn declare(declare: &Declarations) -> Result<()> {
declare.declare("promises")?;
declare.declare("accessSync")?;
declare.declare("mkdirSync")?;
Expand All @@ -101,7 +101,7 @@ impl ModuleDef for FsModule {
Ok(())
}

fn evaluate<'js>(ctx: &Ctx<'js>, exports: &mut Exports<'js>) -> Result<()> {
fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
Class::<Dirent>::register(ctx)?;
Class::<Stat>::register(ctx)?;

Expand Down
2 changes: 1 addition & 1 deletion llrt_core/src/modules/http/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn bytes_from_parts<'js>(
for elem in array.iter::<Value>() {
let elem = elem?;
if let Some(object) = elem.as_object() {
if let Some(x) = Class::<Blob>::from_object(object.clone()) {
if let Some(x) = Class::<Blob>::from_object(object) {
data.extend_from_slice(&x.borrow().data);
continue;
}
Expand Down
Loading