Skip to content

Commit

Permalink
let's go
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeChampion committed Nov 21, 2024
1 parent 8f84114 commit f5db6f9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 30 deletions.
20 changes: 0 additions & 20 deletions pkg/csp_nonce_html_transformer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { awaitPromise } from "./asyncify.js";

const cachedTextDecoder = typeof TextDecoder !== "undefined"
? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true })
: {
Expand Down Expand Up @@ -1273,11 +1271,6 @@ const imports = {
return ret;
}, arguments);
},
__wbg_awaitPromise_313318e7657812c3: function () {
return logError(function (arg0, arg1) {
awaitPromise(arg0 >>> 0, arg1);
}, arguments);
},
__wbg_element_9f7a29ae173a1783: function () {
return logError(function (arg0) {
const ret = arg0.element;
Expand Down Expand Up @@ -1356,19 +1349,6 @@ const imports = {
return ret;
}, arguments);
},
__wbg_instanceof_Promise_f3fd1bcac3157f0c: function () {
return logError(function (arg0) {
let result;
try {
result = arg0 instanceof Promise;
} catch (_) {
result = false;
}
const ret = result;
_assertBoolean(ret);
return ret;
}, arguments);
},
__wbg_new_fec2611eb9180f95: function () {
return logError(function (arg0) {
const ret = new Uint8Array(arg0);
Expand Down
Binary file modified pkg/csp_nonce_html_transformer_bg.wasm
Binary file not shown.
11 changes: 1 addition & 10 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,14 @@ pub struct HandlerJsErrorWrap(pub JsValue);
unsafe impl Send for HandlerJsErrorWrap {}
unsafe impl Sync for HandlerJsErrorWrap {}

#[wasm_bindgen(raw_module = "./asyncify.js")]
extern "C" {
#[wasm_bindgen(js_name = awaitPromise)]
pub(crate) fn await_promise(stack_ptr: *mut u8, promise: &JsPromise);
}

macro_rules! make_handler {
($handler:ident, $JsArgType:ident, $this:ident, $stack_ptr:ident) => {
move |arg: &mut _| {
let (js_arg, anchor) = $JsArgType::from_native(arg, $stack_ptr);
let js_arg = JsValue::from(js_arg);

let res = match $handler.call1(&$this, &js_arg) {
Ok(res) => {
if let Some(promise) = res.dyn_ref::<JsPromise>() {
await_promise($stack_ptr, promise);
}
Ok(_) => {
Ok(())
}
Err(e) => Err(HandlerJsErrorWrap(e).into()),
Expand Down

0 comments on commit f5db6f9

Please sign in to comment.