ephaptic 0.2.0__tar.gz → 0.2.1__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.
Files changed (24) hide show
  1. {ephaptic-0.2.0 → ephaptic-0.2.1}/PKG-INFO +4 -1
  2. {ephaptic-0.2.0 → ephaptic-0.2.1}/README.md +3 -0
  3. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/__init__.py +3 -1
  4. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/ephaptic.py +14 -0
  5. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic.egg-info/PKG-INFO +4 -1
  6. {ephaptic-0.2.0 → ephaptic-0.2.1}/pyproject.toml +1 -1
  7. {ephaptic-0.2.0 → ephaptic-0.2.1}/LICENSE +0 -0
  8. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/adapters/__init__.py +0 -0
  9. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/adapters/fastapi_.py +0 -0
  10. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/adapters/quart_.py +0 -0
  11. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/cli/__init__.py +0 -0
  12. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/cli/__main__.py +0 -0
  13. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/client/__init__.py +0 -0
  14. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/client/client.py +0 -0
  15. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/localproxy.py +0 -0
  16. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/transports/__init__.py +0 -0
  17. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/transports/fastapi_ws.py +0 -0
  18. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic/transports/websocket.py +0 -0
  19. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic.egg-info/SOURCES.txt +0 -0
  20. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic.egg-info/dependency_links.txt +0 -0
  21. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic.egg-info/entry_points.txt +0 -0
  22. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic.egg-info/requires.txt +0 -0
  23. {ephaptic-0.2.0 → ephaptic-0.2.1}/ephaptic.egg-info/top_level.txt +0 -0
  24. {ephaptic-0.2.0 → ephaptic-0.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ephaptic
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: The Python client/server package for ephaptic.
5
5
  Author-email: uukelele <robustrobot11@gmail.com>
6
6
  License: MIT License
@@ -132,6 +132,9 @@ async def add(num1: int, num2: int) -> int:
132
132
  return num1 + num2
133
133
  ```
134
134
 
135
+ > [!TIP]
136
+ > If you're experiencing circular imports, feel free to instead import and use the `expose` function from the library instead of the instance. Please note that if you do this, you must define all exposed functions *before* creating the ephaptic instance - this is mainly for people importing RPC functions from another file. The same thing can be done with the global `identity_loader` decorator.
137
+
135
138
  Yep, it's really that simple.
136
139
 
137
140
  But what if your code throws an error? No sweat, it just throws up on the frontend, with the error name.
@@ -90,6 +90,9 @@ async def add(num1: int, num2: int) -> int:
90
90
  return num1 + num2
91
91
  ```
92
92
 
93
+ > [!TIP]
94
+ > If you're experiencing circular imports, feel free to instead import and use the `expose` function from the library instead of the instance. Please note that if you do this, you must define all exposed functions *before* creating the ephaptic instance - this is mainly for people importing RPC functions from another file. The same thing can be done with the global `identity_loader` decorator.
95
+
93
96
  Yep, it's really that simple.
94
97
 
95
98
  But what if your code throws an error? No sweat, it just throws up on the frontend, with the error name.
@@ -1,6 +1,8 @@
1
1
  from .ephaptic import (
2
2
  Ephaptic,
3
- active_user
3
+ active_user,
4
+ expose,
5
+ identity_loader,
4
6
  )
5
7
 
6
8
  from .client import (
@@ -67,6 +67,9 @@ class ConnectionManager:
67
67
 
68
68
  manager = ConnectionManager()
69
69
 
70
+ _EXPOSED_FUNCTIONS = {}
71
+ _IDENTITY_LOADER: Optional[Callable] = None
72
+
70
73
  class EphapticTarget:
71
74
  def __init__(self, user_ids: list[str]):
72
75
  self.user_ids = user_ids
@@ -76,6 +79,14 @@ class EphapticTarget:
76
79
  await manager.broadcast(self.user_ids, name, list(args), dict(kwargs))
77
80
  return emitter
78
81
 
82
+ def expose(func: Callable):
83
+ _EXPOSED_FUNCTIONS[func.__name__] = func
84
+ return func
85
+
86
+ def identity_loader(func: Callable):
87
+ _IDENTITY_LOADER = func
88
+ return func
89
+
79
90
  class Ephaptic:
80
91
  _exposed_functions: Dict[str, Callable] = {}
81
92
  _identity_loader: Optional[Callable] = None
@@ -111,6 +122,9 @@ class Ephaptic:
111
122
  case _:
112
123
  raise TypeError(f"Unsupported app type: {module}")
113
124
 
125
+ cls._exposed_functions = _EXPOSED_FUNCTIONS.copy()
126
+ cls._identity_loader = _IDENTITY_LOADER
127
+
114
128
  return instance
115
129
 
116
130
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ephaptic
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: The Python client/server package for ephaptic.
5
5
  Author-email: uukelele <robustrobot11@gmail.com>
6
6
  License: MIT License
@@ -132,6 +132,9 @@ async def add(num1: int, num2: int) -> int:
132
132
  return num1 + num2
133
133
  ```
134
134
 
135
+ > [!TIP]
136
+ > If you're experiencing circular imports, feel free to instead import and use the `expose` function from the library instead of the instance. Please note that if you do this, you must define all exposed functions *before* creating the ephaptic instance - this is mainly for people importing RPC functions from another file. The same thing can be done with the global `identity_loader` decorator.
137
+
135
138
  Yep, it's really that simple.
136
139
 
137
140
  But what if your code throws an error? No sweat, it just throws up on the frontend, with the error name.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ephaptic"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  authors = [
9
9
  { name="uukelele", email="robustrobot11@gmail.com" },
10
10
  ]
File without changes
File without changes