@@ -24,8 +24,8 @@ def __init__(
24
24
self ,
25
25
* component_paths : str | Path ,
26
26
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 ,
29
29
root_name : str = "root" ,
30
30
initial : str | VdomDict = "" ,
31
31
http_headers : dict [str , str ] | None = None ,
@@ -35,8 +35,31 @@ def __init__(
35
35
) -> None :
36
36
"""Variant of ReactPy's standalone that only performs Client-Side Rendering (CSR).
37
37
38
+ This ASGI webserver is only used to serve the initial HTML document and static files.
39
+
38
40
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.
40
63
"""
41
64
ReactPyMiddleware .__init__ (
42
65
self , app = ReactPyAppCSR (self ), root_components = [], ** settings
@@ -45,8 +68,8 @@ def __init__(
45
68
raise ValueError ("At least one component file path must be provided." )
46
69
self .component_paths = tuple (str (path ) for path in component_paths )
47
70
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 {}
50
73
self .root_name = root_name
51
74
self .initial = initial
52
75
self .extra_headers = http_headers or {}
@@ -55,6 +78,7 @@ def __init__(
55
78
self .html_lang = html_lang
56
79
57
80
def match_dispatch_path (self , scope : WebSocketScope ) -> bool :
81
+ """We do not use a WebSocket dispatcher for Client-Side Rendering (CSR)."""
58
82
return False
59
83
60
84
0 commit comments