Refactor and fix eval channels (#2302)

* wip

* pull out eval into the interpreter

* fix web eval

* fix DioxusChannel name

* properly drop dioxus channel

* use typescript dioxus chanel in desktop

* add more comments to native eval

* add desktop headless eval tests

* expand web playwright eval tests

* fix web headless tests

* fix default hasher path

* run eval tests on windows

* restore desktop query drop code

* remove data from drop desktop query message

* catch syntax errors in desktop eval

* catch js runtime errors in desktop

* fix typo interprerter -> interpreter

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2024-04-26 11:55:48 -04:00
1 parent 1d72ef16c4
commit cbeda0af76
23 files changed
+477 -218

No files matched your search

+12 -13
View File
@@ -1,4 +1,5 @@
use std::process::Command;
use std::collections::hash_map::DefaultHasher;
use std::{hash::Hasher, process::Command};
fn main() {
// If any TS changes, re-run the build script
@@ -7,6 +8,8 @@ fn main() {
println!("cargo:rerun-if-changed=src/ts/serialize.ts");
println!("cargo:rerun-if-changed=src/ts/set_attribute.ts");
println!("cargo:rerun-if-changed=src/ts/common.ts");
println!("cargo:rerun-if-changed=src/ts/eval.ts");
println!("cargo:rerun-if-changed=src/ts/native_eval.ts");
// Compute the hash of the ts files
let hash = hash_ts_files();
@@ -22,34 +25,30 @@ fn main() {
gen_bindings("common", "common");
gen_bindings("native", "native");
gen_bindings("core", "core");
gen_bindings("eval", "eval");
gen_bindings("native_eval", "native_eval");
std::fs::write("src/js/hash.txt", hash.to_string()).unwrap();
}
/// Hashes the contents of a directory
fn hash_ts_files() -> u128 {
let mut out = 0;
fn hash_ts_files() -> u64 {
let files = [
include_str!("src/ts/common.ts"),
include_str!("src/ts/native.ts"),
include_str!("src/ts/core.ts"),
include_str!("src/ts/eval.ts"),
include_str!("src/ts/native_eval.ts"),
];
// Let's make the dumbest hasher by summing the bytes of the files
// The location is multiplied by the byte value to make sure that the order of the bytes matters
let mut idx = 0;
let mut hash = DefaultHasher::new();
for file in files {
// windows + git does a weird thing with line endings, so we need to normalize them
for line in file.lines() {
idx += 1;
for byte in line.bytes() {
idx += 1;
out += (byte as u128) * (idx as u128);
}
hash.write(line.as_bytes());
}
}
out
hash.finish()
}
// okay...... so tsc might fail if the user doesn't have it installed