@@ -24,8 +24,8 @@ def __init__(
2424 self ,
2525 * component_paths : str | Path ,
2626 extra_py : tuple [str , ...] = (),
27- extra_js : dict [str , Any ] | str = "" ,
28- pyscript_config : dict [str , Any ] | str = "" ,
27+ extra_js : dict [str , str ] | None = None ,
28+ pyscript_config : dict [str , Any ] | None = None ,
2929 root_name : str = "root" ,
3030 initial : str | VdomDict = "" ,
3131 http_headers : dict [str , str ] | None = None ,
@@ -35,8 +35,31 @@ def __init__(
3535 ) -> None :
3636 """Variant of ReactPy's standalone that only performs Client-Side Rendering (CSR).
3737
38+ This ASGI webserver is only used to serve the initial HTML document and static files.
39+
3840 Parameters:
39- ...
41+ component_paths:
42+ File paths to the Python files containing the root component. If multuple paths are
43+ provided, the components will be concatenated in the order they were provided.
44+ extra_py:
45+ Additional Python packages to be made available to the root component. These packages
46+ will be automatically installed from PyPi. Any packages names ending with `.whl` will
47+ be assumed to be a URL to a wheel file.
48+ extra_js: Dictionary where the `key` is the URL to the JavaScript file and the `value` is
49+ the name you'd like to export it as. Any JavaScript files declared here will be available
50+ to your root component via the `pyscript.js_modules.*` object.
51+ pyscript_config:
52+ Additional configuration options for the PyScript runtime. This will be merged with the
53+ default configuration.
54+ root_name: The name of the root component in your Python file.
55+ initial: The initial HTML that is rendered prior to your component loading in. This is most
56+ commonly used to render a loading animation.
57+ http_headers: Additional headers to include in the HTTP response for the base HTML document.
58+ html_head: Additional head elements to include in the HTML response.
59+ html_lang: The language of the HTML document.
60+ settings:
61+ Global ReactPy configuration settings that affect behavior and performance. Most settings
62+ are not applicable to CSR and will have no effect.
4063 """
4164 ReactPyMiddleware .__init__ (
4265 self , app = ReactPyAppCSR (self ), root_components = [], ** settings
@@ -45,8 +68,8 @@ def __init__(
4568 raise ValueError ("At least one component file path must be provided." )
4669 self .component_paths = tuple (str (path ) for path in component_paths )
4770 self .extra_py = extra_py
48- self .extra_js = extra_js
49- self .pyscript_config = pyscript_config
71+ self .extra_js = extra_js or {}
72+ self .pyscript_config = pyscript_config or {}
5073 self .root_name = root_name
5174 self .initial = initial
5275 self .extra_headers = http_headers or {}
@@ -55,6 +78,7 @@ def __init__(
5578 self .html_lang = html_lang
5679
5780 def match_dispatch_path (self , scope : WebSocketScope ) -> bool :
81+ """We do not use a WebSocket dispatcher for Client-Side Rendering (CSR)."""
5882 return False
5983
6084
0 commit comments