websocket-proxy 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: websocket-proxy
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Foxglove WebSocket proxy with message transformations
5
5
  Keywords: websocket,foxglove,robotics,ros,ros2,proxy,compression
6
6
  Author: Marko Bausch
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "websocket-proxy"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "Foxglove WebSocket proxy with message transformations"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -22,6 +22,7 @@ from .transformers import Transformer, TransformerRegistry, TransformError
22
22
 
23
23
  if TYPE_CHECKING:
24
24
  from collections.abc import Callable
25
+ from types import SimpleNamespace
25
26
 
26
27
  from robo_ws_bridge.ws_types import ChannelInfo
27
28
 
@@ -712,7 +713,7 @@ class ProxyBridge:
712
713
  logger.exception("Message transformation failed")
713
714
  return None
714
715
 
715
- def _decode_message(self, channel: ChannelInfo, payload: bytes) -> Any:
716
+ def _decode_message(self, channel: ChannelInfo, payload: bytes) -> SimpleNamespace:
716
717
  """Decode a CDR-encoded message.
717
718
 
718
719
  Args:
@@ -1,7 +1,12 @@
1
1
  """Message transformers for converting between ROS2 message types."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  from abc import ABC, abstractmethod
4
- from typing import Any
6
+ from typing import TYPE_CHECKING, Any
7
+
8
+ if TYPE_CHECKING:
9
+ from types import SimpleNamespace
5
10
 
6
11
 
7
12
  class Transformer(ABC):
@@ -23,11 +28,11 @@ class Transformer(ABC):
23
28
  ...
24
29
 
25
30
  @abstractmethod
26
- def transform(self, message: dict[str, Any]) -> dict[str, Any]:
27
- """Transform a decoded message dict to another message dict.
31
+ def transform(self, message: SimpleNamespace) -> dict[str, Any]:
32
+ """Transform a decoded message object to a message dict.
28
33
 
29
34
  Args:
30
- message: Decoded input message as a dictionary
35
+ message: Decoded input message (SimpleNamespace from CDR decoder)
31
36
 
32
37
  Returns:
33
38
  Transformed output message as a dictionary
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import logging
6
- from typing import Any
6
+ from typing import TYPE_CHECKING, Any
7
7
 
8
8
  from pymcap_cli.image_utils import (
9
9
  FOXGLOVE_COMPRESSED_VIDEO,
@@ -18,6 +18,9 @@ from pymcap_cli.image_utils import (
18
18
 
19
19
  from . import Transformer, TransformError
20
20
 
21
+ if TYPE_CHECKING:
22
+ from types import SimpleNamespace
23
+
21
24
  logger = logging.getLogger(__name__)
22
25
 
23
26
 
@@ -60,7 +63,7 @@ class ImageToVideoTransformer(Transformer):
60
63
  def get_output_schema_definition(self) -> str:
61
64
  return FOXGLOVE_COMPRESSED_VIDEO
62
65
 
63
- def transform(self, message: Any) -> dict[str, Any]:
66
+ def transform(self, message: SimpleNamespace) -> dict[str, Any]:
64
67
  if not message.data:
65
68
  raise TransformError(f"Empty image data, {message}")
66
69
 
@@ -3,12 +3,15 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import logging
6
- from typing import Any
6
+ from typing import TYPE_CHECKING, Any
7
7
 
8
8
  from pymcap_cli.image_utils import COMPRESSED_POINTCLOUD2, PointCloudCompressor
9
9
 
10
10
  from . import Transformer, TransformError
11
11
 
12
+ if TYPE_CHECKING:
13
+ from types import SimpleNamespace
14
+
12
15
  logger = logging.getLogger(__name__)
13
16
 
14
17
 
@@ -34,7 +37,7 @@ class PointCloudPureiniTransformer(Transformer):
34
37
  def get_output_schema_definition(self) -> str:
35
38
  return COMPRESSED_POINTCLOUD2
36
39
 
37
- def transform(self, message: Any) -> dict[str, Any]:
40
+ def transform(self, message: SimpleNamespace) -> dict[str, Any]:
38
41
  try:
39
42
  compressed = self._compressor.compress(message)
40
43