Skip to content

Commit

Permalink
2 again
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeChampion committed Nov 21, 2024
1 parent 1187b65 commit 023e2c3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 45 deletions.
3 changes: 1 addition & 2 deletions pkg/csp_nonce_html_transformer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export class HTMLRewriter {
free(): void;
/**
* @param {Function} output_sink
* @param {any | undefined} [options]
*/
constructor(output_sink: Function, options?: any);
constructor(output_sink: Function);
/**
* @param {string} selector
* @param {any} handlers
Expand Down
23 changes: 2 additions & 21 deletions pkg/csp_nonce_html_transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@ function logError(f, args) {
}
}

function _assertBoolean(n) {
if (typeof n !== "boolean") {
throw new Error(`expected a boolean argument, found ${typeof n}`);
}
}

function _assertNum(n) {
if (typeof n !== "number") {
throw new Error(`expected a number argument, found ${typeof n}`);
Expand Down Expand Up @@ -306,13 +300,9 @@ export class HTMLRewriter {
}
/**
* @param {Function} output_sink
* @param {any | undefined} [options]
*/
constructor(output_sink, options) {
const ret = wasm.htmlrewriter_new(
output_sink,
isLikeNone(options) ? 0 : addToExternrefTable0(options),
);
constructor(output_sink) {
const ret = wasm.htmlrewriter_new(output_sink);
this.__wbg_ptr = ret >>> 0;
HTMLRewriterFinalization.register(this, this.__wbg_ptr, this);
return this;
Expand Down Expand Up @@ -376,15 +366,6 @@ const imports = {
return ret;
}, arguments);
},
__wbg_enableEsiTags_f773d89434472a3e: function () {
return logError(function (arg0) {
const ret = arg0.enableEsiTags;
if (!isLikeNone(ret)) {
_assertBoolean(ret);
}
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
}, arguments);
},
__wbg_call_3bfa248576352471: function () {
return handleError(function (arg0, arg1, arg2) {
const ret = arg0.call(arg1, arg2);
Expand Down
Binary file modified pkg/csp_nonce_html_transformer_bg.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion pkg/csp_nonce_html_transformer_bg.wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function __wbg_htmlrewriter_free(a: number, b: number): void;
export function htmlrewriter_new(a: number, b: number): number;
export function htmlrewriter_new(a: number): number;
export function htmlrewriter_on(
a: number,
b: number,
Expand Down
13 changes: 1 addition & 12 deletions src/html_rewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,14 @@ pub struct HTMLRewriter {
output_sink: Option<JsOutputSink>,
inner: Option<NativeHTMLRewriter<'static, JsOutputSink>>,
inner_constructed: bool,
enable_esi_tags: bool,
}

#[wasm_bindgen]
extern "C" {
pub type HTMLRewriterOptions;

#[wasm_bindgen(structural, method, getter, js_name = enableEsiTags)]
pub fn enable_esi_tags(this: &HTMLRewriterOptions) -> Option<bool>;
}

#[wasm_bindgen]
impl HTMLRewriter {
#[wasm_bindgen(constructor)]
pub fn new(output_sink: &JsFunction, options: Option<HTMLRewriterOptions>) -> Self {
pub fn new(output_sink: &JsFunction) -> Self {
HTMLRewriter {
output_sink: Some(JsOutputSink::new(output_sink)),
enable_esi_tags: options.and_then(|o| o.enable_esi_tags()).unwrap_or(false),
..Self::default()
}
}
Expand Down Expand Up @@ -90,7 +80,6 @@ impl HTMLRewriter {
.collect(),

document_content_handlers: self.document_content_handlers.drain(..).collect(),
enable_esi_tags: self.enable_esi_tags,
..Settings::default()
};

Expand Down
9 changes: 0 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,9 @@ impl<T, E: ToString> IntoJsResult<T> for Result<T, E> {
}
}

#[wasm_bindgen]
extern "C" {
pub type ContentTypeOptions;

#[wasm_bindgen(method, getter)]
fn html(this: &ContentTypeOptions) -> Option<bool>;
}

macro_rules! impl_from_native {
($Ty:ident --> $JsTy:ident) => {
impl $JsTy {
#[allow(dead_code)]
pub(crate) fn from_native<'r>(
inner: &'r mut $Ty,
) -> (Self, Anchor<'r>) {
Expand Down

0 comments on commit 023e2c3

Please sign in to comment.