Skip to content

Commit

Permalink
chore(transformations): add filter_svg
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Oct 24, 2024
1 parent 0083627 commit 5233744
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 134 deletions.
42 changes: 29 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions spider/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spider"
version = "2.10.15"
version = "2.10.16"
authors = [
"j-mendez <jeff@spider.cloud>"
]
Expand All @@ -19,7 +19,7 @@ maintenance = { status = "as-is" }
[dependencies]
url = "2"
tokio-stream = "0.1"
hashbrown = { version = "0.14", default-features = true }
hashbrown = { version = "0.15", default-features = true }
log = "0.4"
percent-encoding = "2"
regex = { version = "1", optional = true }
Expand Down Expand Up @@ -48,7 +48,7 @@ async_job = { version = "0.1", optional = true }
reqwest-middleware = { version = "0.3", optional = true }
http-cache-reqwest = { version = "0.14.0", optional = true }
const_format = { version = "0.2", optional = true }
async-openai = { version = "0.23", optional = true }
async-openai = { version = "0.25", optional = true }
tiktoken-rs = { version = "0.5", optional = true }
lol_html = { version = "1", optional = true }
serde_json = { version = "1", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion spider_chrome/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spider_chrome"
version = "2.10.15"
version = "2.10.16"
rust-version = "1.70"
authors = [
"j-mendez <jeff@spider.cloud>"
Expand Down
88 changes: 46 additions & 42 deletions spider_chrome/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,52 +110,56 @@ impl<T: EventMessage + Unpin> Stream for Connection<T> {
let pin = self.get_mut();

loop {
// queue in the next message if not currently flushing
if let Err(err) = pin.start_send_next(cx) {
return Poll::Ready(Some(Err(err)));
}

// send the message
if let Some(call) = pin.pending_flush.take() {
if pin.ws.poll_ready_unpin(cx).is_ready() {
pin.needs_flush = true;
// try another flush
continue;
} else {
pin.pending_flush = Some(call);
loop {
// queue in the next message if not currently flushing
if let Err(err) = pin.start_send_next(cx) {
return Poll::Ready(Some(Err(err)));
}
}

break;
}

// read from the ws
match ready!(pin.ws.poll_next_unpin(cx)) {
Some(Ok(WsMessage::Text(text))) => {
let ready = match serde_json::from_str::<Message<T>>(&text) {
Ok(msg) => {
tracing::trace!("Received {:?}", msg);
Ok(msg)
}
Err(err) => {
tracing::debug!(target: "chromiumoxide::conn::raw_ws::parse_errors", msg = text, "Failed to parse raw WS message");
tracing::error!("Failed to deserialize WS response {}", err);
Err(err.into())
// send the message
if let Some(call) = pin.pending_flush.take() {
if pin.ws.poll_ready_unpin(cx).is_ready() {
pin.needs_flush = true;
// try another flush
continue;
} else {
pin.pending_flush = Some(call);
}
};
Poll::Ready(Some(ready))
}
Some(Ok(WsMessage::Close(_))) => Poll::Ready(None),
// ignore ping and pong
Some(Ok(WsMessage::Ping(_))) | Some(Ok(WsMessage::Pong(_))) => {
cx.waker().wake_by_ref();
Poll::Pending
}

break;
}
Some(Ok(msg)) => Poll::Ready(Some(Err(CdpError::UnexpectedWsMessage(msg)))),
Some(Err(err)) => Poll::Ready(Some(Err(CdpError::Ws(err)))),
None => {
// ws connection closed
Poll::Ready(None)

// read from the ws
match ready!(pin.ws.poll_next_unpin(cx)) {
Some(Ok(WsMessage::Text(text))) => {
let ready = match serde_json::from_str::<Message<T>>(&text) {
Ok(msg) => {
tracing::trace!("Received {:?}", msg);
Ok(msg)
}
Err(err) => {
tracing::debug!(target: "chromiumoxide::conn::raw_ws::parse_errors", msg = text, "Failed to parse raw WS message");
tracing::error!("Failed to deserialize WS response {}", err);
// Go to the next iteration and try reading the next message
// in the hopes we can reconver and continue working.
continue;
}
};
return Poll::Ready(Some(ready));
}
Some(Ok(WsMessage::Close(_))) => return Poll::Ready(None),
// ignore ping and pong
Some(Ok(WsMessage::Ping(_))) | Some(Ok(WsMessage::Pong(_))) => {
cx.waker().wake_by_ref();
return Poll::Pending;
}
Some(Ok(msg)) => return Poll::Ready(Some(Err(CdpError::UnexpectedWsMessage(msg)))),
Some(Err(err)) => return Poll::Ready(Some(Err(CdpError::Ws(err)))),
None => {
// ws connection closed
return Poll::Ready(None);
}
}
}
}
Expand Down
Loading

0 comments on commit 5233744

Please sign in to comment.