-
Notifications
You must be signed in to change notification settings - Fork 7
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
WebCore #6
Comments
Hey, If you want the APIs included, you're better off using something like Deno (the https://github.com/denoland/deno/blob/main/runtime/README.md Here's an example: test.js const request = await fetch('https://example.com')
const html = await request.text()
console.log(html) main.rs use std::path::Path;
use std::rc::Rc;
use deno_core::anyhow::Ok;
use deno_core::error::AnyError;
use deno_runtime::deno_core::FsModuleLoader;
use deno_runtime::deno_core::ModuleSpecifier;
use deno_runtime::permissions::PermissionsContainer;
use deno_runtime::worker::MainWorker;
use deno_runtime::worker::WorkerOptions;
#[tokio::main]
async fn main() -> Result<(), AnyError> {
let js_path = Path::new("src/test.js").canonicalize().unwrap();
let main_module = ModuleSpecifier::from_file_path(js_path).unwrap();
let mut worker = MainWorker::bootstrap_from_options(
main_module.clone(),
PermissionsContainer::allow_all(),
WorkerOptions {
module_loader: Rc::new(FsModuleLoader),
..Default::default()
},
);
worker.execute_main_module(&main_module).await?;
worker.run_event_loop(false).await?;
Ok(())
} |
Hey, this looks great!
Applogies if this is a silly question, I’ve essentially just started exploring the space :)
Is it possible to load & call into WebCore APIs; eg fetch?
Also, perhaps relatedly, how I can discover what the context provides by default? I see the punjs (lol, A+) example runs a
console.log
script but 1) where is console coming from? 2) I don’t see it log, so is that effectively a noop since evaluateScript only prints the return value? Or do I have to define my own console global callback which passes thru to println?Thanks !
The text was updated successfully, but these errors were encountered: