From 72d43508d01706ed6262ee667a678204daf514d2 Mon Sep 17 00:00:00 2001 From: Toshit Chawda Date: Thu, 8 Aug 2024 13:01:39 -0700 Subject: [PATCH] add epoxy info function --- Cargo.lock | 2 +- client/Cargo.toml | 2 +- client/demo.js | 3 ++- client/package.json | 2 +- client/src/lib.rs | 14 ++++++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ce7d4b..900780c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -513,7 +513,7 @@ dependencies = [ [[package]] name = "epoxy-client" -version = "2.1.0" +version = "2.1.1" dependencies = [ "async-compression", "async-trait", diff --git a/client/Cargo.toml b/client/Cargo.toml index 678b3eb..a81151b 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "epoxy-client" -version = "2.1.0" +version = "2.1.1" edition = "2021" [lib] diff --git a/client/demo.js b/client/demo.js index 783e90a..6b7c2a5 100644 --- a/client/demo.js +++ b/client/demo.js @@ -1,4 +1,4 @@ -import initEpoxy, { EpoxyClient, EpoxyClientOptions, EpoxyHandlers } from "./pkg/epoxy-bundled.js"; +import initEpoxy, { EpoxyClient, EpoxyClientOptions, EpoxyHandlers, info as epoxyInfo } from "./pkg/epoxy-bundled.js"; (async () => { const params = (new URL(location.href)).searchParams; @@ -40,6 +40,7 @@ import initEpoxy, { EpoxyClient, EpoxyClientOptions, EpoxyHandlers } from "./pkg console.log(epoxy_client); // you can change the user agent and redirect limit in JS epoxy_client.redirect_limit = 15; + console.log(epoxyInfo()); const test_mux = async (url) => { const t0 = performance.now(); diff --git a/client/package.json b/client/package.json index 7861c44..a3932c3 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "@mercuryworkshop/epoxy-tls", - "version": "2.1.0-1", + "version": "2.1.1-1", "description": "A wasm library for using raw encrypted tls/ssl/tcp/udp/https/websocket streams on the browser", "scripts": { "build": "./build.sh" diff --git a/client/src/lib.rs b/client/src/lib.rs index b9e7d64..e876019 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -43,6 +43,20 @@ mod utils; mod websocket; mod ws_wrapper; +#[wasm_bindgen] +pub fn info() -> Object { + let obj = Object::new(); + object_set(&obj, "version", env!("CARGO_PKG_VERSION").into()); + cfg_if! { + if #[cfg(feature = "full")] { + object_set(&obj, "minimal", false.into()); + } else { + object_set(&obj, "minimal", true.into()); + } + }; + obj +} + type HttpBody = http_body_util::Full; #[derive(Debug, Error)]