mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 23:50:02 -04:00
esmodules
This commit is contained in:
parent
d433f67d67
commit
862f909624
9 changed files with 141 additions and 25 deletions
|
@ -1,6 +1,9 @@
|
|||
pub mod rewrite;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use rewrite::rewrite;
|
||||
use url::Url;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
|
@ -10,15 +13,15 @@ extern "C" {
|
|||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn rewrite_js(js: &str) -> String {
|
||||
rewrite(js)
|
||||
pub fn rewrite_js(js: &str, url: &str) -> String {
|
||||
rewrite(js, Url::from_str(url).unwrap())
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn rewrite_js_from_arraybuffer(js: &[u8]) -> String {
|
||||
pub fn rewrite_js_from_arraybuffer(js: &[u8], url: &str) -> String {
|
||||
// technically slower than the c++ string conversion but it will create *less copies*
|
||||
|
||||
let js = unsafe { std::str::from_utf8_unchecked(js) };
|
||||
|
||||
rewrite(js)
|
||||
rewrite(js, Url::from_str(url).unwrap())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue