22
33import dataclasses
44import inspect
5+ import sys
56import types
67import urllib .parse
78from base64 import b64encode
@@ -403,7 +404,7 @@ def __init__(self, fn: Callable[..., EventSpec] | None = None, **kwargs):
403404
404405 Args:
405406 fn: The function to decorate.
406- **kwargs: The kwargs to pass to pydantic initializer
407+ **kwargs: The kwargs to pass to the EventSpec constructor.
407408 """
408409 if fn is not None :
409410 default_event_spec = fn ()
@@ -1243,19 +1244,6 @@ def download(
12431244 )
12441245
12451246
1246- # This function seems unused. Check if we still need it. If not, remove in 0.7.0
1247- def _callback_arg_spec (eval_result : Any ):
1248- """ArgSpec for call_script callback function.
1249-
1250- Args:
1251- eval_result: The result of the javascript execution.
1252-
1253- Returns:
1254- Args for the callback function
1255- """
1256- return [eval_result ]
1257-
1258-
12591247def call_script (
12601248 javascript_code : str | Var [str ],
12611249 callback : "EventType[Any] | None" = None ,
@@ -2197,7 +2185,9 @@ def __call__(self, *args: Var) -> Any:
21972185class EventNamespace :
21982186 """A namespace for event related classes."""
21992187
2188+ # Core Event Classes
22002189 Event = Event
2190+ EventActionsMixin = EventActionsMixin
22012191 EventHandler = EventHandler
22022192 EventSpec = EventSpec
22032193 CallableEventSpec = CallableEventSpec
@@ -2206,8 +2196,43 @@ class EventNamespace:
22062196 LiteralEventVar = LiteralEventVar
22072197 EventChainVar = EventChainVar
22082198 LiteralEventChainVar = LiteralEventChainVar
2209- EventType = EventType
22102199 EventCallback = EventCallback
2200+ LambdaEventCallback = LambdaEventCallback
2201+
2202+ # Javascript Event Classes
2203+ JavascriptHTMLInputElement = JavascriptHTMLInputElement
2204+ JavascriptInputEvent = JavascriptInputEvent
2205+ JavascriptKeyboardEvent = JavascriptKeyboardEvent
2206+ JavascriptMouseEvent = JavascriptMouseEvent
2207+ JavascriptPointerEvent = JavascriptPointerEvent
2208+
2209+ # Type Info Classes
2210+ KeyInputInfo = KeyInputInfo
2211+ MouseEventInfo = MouseEventInfo
2212+ PointerEventInfo = PointerEventInfo
2213+ IdentityEventReturn = IdentityEventReturn
2214+
2215+ # File Upload
2216+ FileUpload = FileUpload
2217+
2218+ # Type Aliases
2219+ EventType = EventType
2220+ LAMBDA_OR_STATE = LAMBDA_OR_STATE
2221+ BASIC_EVENT_TYPES = BASIC_EVENT_TYPES
2222+ IndividualEventType = IndividualEventType
2223+
2224+ # Constants
2225+ BACKGROUND_TASK_MARKER = BACKGROUND_TASK_MARKER
2226+ _EVENT_FIELDS = _EVENT_FIELDS
2227+ upload_files = upload_files
2228+ stop_propagation = stop_propagation
2229+ prevent_default = prevent_default
2230+
2231+ # Private/Internal Functions
2232+ _values_returned_from_event = staticmethod (_values_returned_from_event )
2233+ _check_event_args_subclass_of_callback = staticmethod (
2234+ _check_event_args_subclass_of_callback
2235+ )
22112236
22122237 @overload
22132238 def __new__ (
@@ -2359,10 +2384,20 @@ def wrapper(
23592384 check_fn_match_arg_spec = staticmethod (check_fn_match_arg_spec )
23602385 resolve_annotation = staticmethod (resolve_annotation )
23612386 parse_args_spec = staticmethod (parse_args_spec )
2387+ unwrap_var_annotation = staticmethod (unwrap_var_annotation )
2388+ get_fn_signature = staticmethod (get_fn_signature )
2389+
2390+ # Event Spec Functions
23622391 passthrough_event_spec = staticmethod (passthrough_event_spec )
23632392 input_event = staticmethod (input_event )
2393+ int_input_event = staticmethod (int_input_event )
2394+ float_input_event = staticmethod (float_input_event )
2395+ checked_input_event = staticmethod (checked_input_event )
23642396 key_event = staticmethod (key_event )
2397+ pointer_event_spec = staticmethod (pointer_event_spec )
23652398 no_args_event_spec = staticmethod (no_args_event_spec )
2399+
2400+ # Server Side Events
23662401 server_side = staticmethod (server_side )
23672402 redirect = staticmethod (redirect )
23682403 console_log = staticmethod (console_log )
@@ -2383,6 +2418,9 @@ def wrapper(
23832418 call_script = staticmethod (call_script )
23842419 call_function = staticmethod (call_function )
23852420 run_script = staticmethod (run_script )
2421+ __file__ = __file__
23862422
23872423
23882424event = EventNamespace
2425+ event .event = event # pyright: ignore[reportAttributeAccessIssue]
2426+ sys .modules [__name__ ] = event # pyright: ignore[reportArgumentType]
0 commit comments