reactpy 2.0.0b5__py3-none-any.whl → 2.0.0b6__py3-none-any.whl
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.
- reactpy/__init__.py +3 -2
- reactpy/_html.py +11 -9
- reactpy/core/_life_cycle_hook.py +4 -1
- reactpy/core/layout.py +43 -38
- reactpy/core/serve.py +11 -16
- reactpy/core/vdom.py +3 -5
- reactpy/pyscript/utils.py +1 -1
- reactpy/reactjs/__init__.py +353 -0
- reactpy/reactjs/module.py +203 -0
- reactpy/reactjs/types.py +7 -0
- reactpy/reactjs/utils.py +183 -0
- reactpy/static/index-h31022cd.js +5 -0
- reactpy/static/index-h31022cd.js.map +11 -0
- reactpy/static/index-sbddj6ms.js +5 -0
- reactpy/static/index-sbddj6ms.js.map +10 -0
- reactpy/static/index-y71bxs88.js +5 -0
- reactpy/static/index-y71bxs88.js.map +10 -0
- reactpy/static/index.js +2 -2
- reactpy/static/index.js.map +6 -10
- reactpy/static/react-dom.js +4 -0
- reactpy/static/react-dom.js.map +11 -0
- reactpy/static/react-jsx-runtime.js +4 -0
- reactpy/static/react-jsx-runtime.js.map +9 -0
- reactpy/static/react.js +4 -0
- reactpy/static/react.js.map +10 -0
- reactpy/testing/backend.py +4 -4
- reactpy/testing/display.py +2 -1
- reactpy/testing/logs.py +1 -1
- reactpy/transforms.py +2 -2
- reactpy/types.py +17 -11
- reactpy/utils.py +1 -1
- reactpy/web/__init__.py +0 -6
- reactpy/web/module.py +37 -473
- reactpy/web/utils.py +2 -158
- {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/METADATA +1 -1
- {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/RECORD +39 -24
- reactpy/web/templates/react.js +0 -61
- {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/WHEEL +0 -0
- {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/entry_points.txt +0 -0
- {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../js/node_modules/preact/compat/client.mjs", "../../js/packages/@reactpy/app/src/react-dom.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { render, hydrate, unmountComponentAtNode } from 'preact/compat';\n\nexport function createRoot(container) {\n\treturn {\n\t\t// eslint-disable-next-line\n\t\trender: function (children) {\n\t\t\trender(children, container);\n\t\t},\n\t\t// eslint-disable-next-line\n\t\tunmount: function () {\n\t\t\tunmountComponentAtNode(container);\n\t\t}\n\t};\n}\n\nexport function hydrateRoot(container, children) {\n\thydrate(children, container);\n\treturn createRoot(container);\n}\n\nexport default {\n\tcreateRoot,\n\thydrateRoot\n};\n",
|
|
6
|
+
"import ReactDOM from \"preact/compat\";\n\n// @ts-ignore\nexport * from \"preact/compat\";\n\n// @ts-ignore\nexport * from \"preact/compat/client\";\n\nexport default ReactDOM;\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "8YAEO,GAAS,CAAU,CAAC,EAAW,CACrC,MAAO,CAEN,OAAQ,QAAS,CAAC,EAAU,CAC3B,EAAO,EAAU,CAAS,GAG3B,QAAS,QAAS,EAAG,CACpB,EAAuB,CAAS,EAElC,EAGM,SAAS,CAAW,CAAC,EAAW,EAAU,CAEhD,OADA,EAAQ,EAAU,CAAS,EACpB,EAAW,CAAS,ECT5B,IAAe",
|
|
9
|
+
"debugId": "268FD8A3AAB1D8C564756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{P as f,Q as m,R as p,S as t}from"./index-sbddj6ms.js";import{Y as e}from"./index-y71bxs88.js";export{f as jsxs,m as jsxTemplate,t as jsxEscape,f as jsxDEV,p as jsxAttr,f as jsx,e as Fragment};
|
|
2
|
+
|
|
3
|
+
//# debugId=95B2A863FE6290C864756E2164756E21
|
|
4
|
+
//# sourceMappingURL=react-jsx-runtime.js.map
|
reactpy/static/react.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{A as J,B as K,C as L,D as M,E as N,F as O,G as P,H as Q,I as S,J as T,K as U,L as V,M as W,N as X,O as o,a as d,b as i,c as l,d as u,e as R,f as b,g,h,i as j,j as k,k as n,l as q,m as s,n as v,o as w,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as I}from"./index-h31022cd.js";import{W as m,X as p,Y as a,Z as x,ca as c}from"./index-y71bxs88.js";var f=o;export{L as version,y as useTransition,s as useSyncExternalStore,d as useState,R as useRef,i as useReducer,g as useMemo,u as useLayoutEffect,z as useInsertionEffect,b as useImperativeHandle,q as useId,n as useErrorBoundary,l as useEffect,w as useDeferredValue,k as useDebugValue,j as useContext,h as useCallback,U as unstable_batchedUpdates,S as unmountComponentAtNode,v as startTransition,I as render,B as memo,F as lazy,N as isValidElement,P as isMemo,O as isFragment,X as isElement,J as hydrate,C as forwardRef,V as flushSync,T as findDOMNode,f as default,p as createRef,H as createPortal,M as createFactory,m as createElement,c as createContext,Q as cloneElement,K as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,G as SuspenseList,E as Suspense,W as StrictMode,A as PureComponent,a as Fragment,x as Component,D as Children};
|
|
2
|
+
|
|
3
|
+
//# debugId=8D5FBD04CB59E99664756E2164756E21
|
|
4
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../js/packages/@reactpy/app/src/react.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import React from \"preact/compat\";\n\n// @ts-ignore\nexport * from \"preact/compat\";\n\nexport default React;\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "iYAKA,FAAe",
|
|
8
|
+
"debugId": "8D5FBD04CB59E99664756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
reactpy/testing/backend.py
CHANGED
|
@@ -22,7 +22,7 @@ from reactpy.testing.logs import (
|
|
|
22
22
|
list_logged_exceptions,
|
|
23
23
|
)
|
|
24
24
|
from reactpy.testing.utils import find_available_port
|
|
25
|
-
from reactpy.types import ComponentConstructor
|
|
25
|
+
from reactpy.types import ComponentConstructor
|
|
26
26
|
from reactpy.utils import Ref
|
|
27
27
|
|
|
28
28
|
|
|
@@ -48,7 +48,7 @@ class BackendFixture:
|
|
|
48
48
|
host: str = "127.0.0.1",
|
|
49
49
|
port: int | None = None,
|
|
50
50
|
timeout: float | None = None,
|
|
51
|
-
reactpy_config:
|
|
51
|
+
**reactpy_config: Any,
|
|
52
52
|
) -> None:
|
|
53
53
|
self.host = host
|
|
54
54
|
self.port = port or find_available_port(host)
|
|
@@ -62,12 +62,12 @@ class BackendFixture:
|
|
|
62
62
|
self._app = ReactPyMiddleware(
|
|
63
63
|
app,
|
|
64
64
|
root_components=["reactpy.testing.backend.root_hotswap_component"],
|
|
65
|
-
**
|
|
65
|
+
**reactpy_config,
|
|
66
66
|
)
|
|
67
67
|
else:
|
|
68
68
|
self._app = ReactPy(
|
|
69
69
|
root_hotswap_component,
|
|
70
|
-
**
|
|
70
|
+
**reactpy_config,
|
|
71
71
|
)
|
|
72
72
|
self.webserver = uvicorn.Server(
|
|
73
73
|
uvicorn.Config(
|
reactpy/testing/display.py
CHANGED
|
@@ -57,7 +57,8 @@ class DisplayFixture:
|
|
|
57
57
|
self.page = await browser.new_page()
|
|
58
58
|
|
|
59
59
|
self.page.set_default_timeout(REACTPY_TESTS_DEFAULT_TIMEOUT.current * 1000)
|
|
60
|
-
|
|
60
|
+
self.page.on("console", lambda msg: print(f"BROWSER CONSOLE: {msg.text}")) # noqa: T201
|
|
61
|
+
self.page.on("pageerror", lambda exc: print(f"BROWSER ERROR: {exc}")) # noqa: T201
|
|
61
62
|
if not hasattr(self, "backend"): # nocov
|
|
62
63
|
self.backend = BackendFixture()
|
|
63
64
|
await es.enter_async_context(self.backend)
|
reactpy/testing/logs.py
CHANGED
|
@@ -175,4 +175,4 @@ def _raise_log_message_error(
|
|
|
175
175
|
conditions.append(f"exception type {error_type}")
|
|
176
176
|
if match_error:
|
|
177
177
|
conditions.append(f"error message pattern {match_error!r}")
|
|
178
|
-
raise LogAssertionError(prefix
|
|
178
|
+
raise LogAssertionError(f"{prefix} " + " and ".join(conditions))
|
reactpy/transforms.py
CHANGED
|
@@ -113,8 +113,8 @@ class RequiredTransforms:
|
|
|
113
113
|
if key is None and vdom["tagName"] in {"input", "select", "textarea"}:
|
|
114
114
|
key = attributes.get("name")
|
|
115
115
|
|
|
116
|
-
if key:
|
|
117
|
-
|
|
116
|
+
if key and "key" not in attributes:
|
|
117
|
+
attributes["key"] = key
|
|
118
118
|
|
|
119
119
|
def intercept_link_clicks(self, vdom: VdomDict) -> None:
|
|
120
120
|
"""Intercepts anchor link clicks and prevents the default behavior.
|
reactpy/types.py
CHANGED
|
@@ -10,6 +10,7 @@ from typing import (
|
|
|
10
10
|
Generic,
|
|
11
11
|
Literal,
|
|
12
12
|
NamedTuple,
|
|
13
|
+
NewType,
|
|
13
14
|
NotRequired,
|
|
14
15
|
Protocol,
|
|
15
16
|
TypeAlias,
|
|
@@ -533,7 +534,7 @@ class CssStyleTypeDict(TypedDict, total=False):
|
|
|
533
534
|
zIndex: str | int
|
|
534
535
|
|
|
535
536
|
|
|
536
|
-
# TODO: Enable `extra_items` on `CssStyleDict` when PEP 728 is merged, likely in Python 3.
|
|
537
|
+
# TODO: Enable `extra_items` on `CssStyleDict` when PEP 728 is merged, likely in Python 3.15. Ref: https://peps.python.org/pep-0728/
|
|
537
538
|
CssStyleDict = CssStyleTypeDict | dict[str, Any]
|
|
538
539
|
|
|
539
540
|
EventFunc = Callable[[dict[str, Any]], Awaitable[None] | None]
|
|
@@ -543,8 +544,8 @@ class DangerouslySetInnerHTML(TypedDict):
|
|
|
543
544
|
__html: str
|
|
544
545
|
|
|
545
546
|
|
|
546
|
-
# TODO: It's probably better to break this
|
|
547
|
-
#
|
|
547
|
+
# TODO: It's probably better to break this down into what each HTML node's attributes can be,
|
|
548
|
+
# and make sure those types are resolved correctly within `HtmlConstructor`
|
|
548
549
|
# TODO: This could be generated by parsing from `@types/react` in the future
|
|
549
550
|
# https://www.npmjs.com/package/@types/react?activeTab=code
|
|
550
551
|
VdomAttributesTypeDict = TypedDict(
|
|
@@ -797,7 +798,6 @@ VdomAttributes = VdomAttributesTypeDict | dict[str, Any]
|
|
|
797
798
|
|
|
798
799
|
VdomDictKeys = Literal[
|
|
799
800
|
"tagName",
|
|
800
|
-
"key",
|
|
801
801
|
"children",
|
|
802
802
|
"attributes",
|
|
803
803
|
"eventHandlers",
|
|
@@ -806,7 +806,6 @@ VdomDictKeys = Literal[
|
|
|
806
806
|
]
|
|
807
807
|
ALLOWED_VDOM_KEYS = {
|
|
808
808
|
"tagName",
|
|
809
|
-
"key",
|
|
810
809
|
"children",
|
|
811
810
|
"attributes",
|
|
812
811
|
"eventHandlers",
|
|
@@ -819,7 +818,6 @@ class VdomTypeDict(TypedDict):
|
|
|
819
818
|
"""TypedDict representation of what the `VdomDict` should look like."""
|
|
820
819
|
|
|
821
820
|
tagName: str
|
|
822
|
-
key: NotRequired[Key | None]
|
|
823
821
|
children: NotRequired[Sequence[Component | VdomChild]]
|
|
824
822
|
attributes: NotRequired[VdomAttributes]
|
|
825
823
|
eventHandlers: NotRequired[EventHandlerDict]
|
|
@@ -844,8 +842,6 @@ class VdomDict(dict):
|
|
|
844
842
|
@overload
|
|
845
843
|
def __getitem__(self, key: Literal["tagName"]) -> str: ...
|
|
846
844
|
@overload
|
|
847
|
-
def __getitem__(self, key: Literal["key"]) -> Key | None: ...
|
|
848
|
-
@overload
|
|
849
845
|
def __getitem__(
|
|
850
846
|
self, key: Literal["children"]
|
|
851
847
|
) -> Sequence[Component | VdomChild]: ...
|
|
@@ -863,8 +859,6 @@ class VdomDict(dict):
|
|
|
863
859
|
@overload
|
|
864
860
|
def __setitem__(self, key: Literal["tagName"], value: str) -> None: ...
|
|
865
861
|
@overload
|
|
866
|
-
def __setitem__(self, key: Literal["key"], value: Key | None) -> None: ...
|
|
867
|
-
@overload
|
|
868
862
|
def __setitem__(
|
|
869
863
|
self, key: Literal["children"], value: Sequence[Component | VdomChild]
|
|
870
864
|
) -> None: ...
|
|
@@ -1116,7 +1110,6 @@ class CustomVdomConstructor(Protocol):
|
|
|
1116
1110
|
self,
|
|
1117
1111
|
attributes: VdomAttributes,
|
|
1118
1112
|
children: Sequence[VdomChildren],
|
|
1119
|
-
key: Key | None,
|
|
1120
1113
|
event_handlers: EventHandlerDict,
|
|
1121
1114
|
) -> VdomDict: ...
|
|
1122
1115
|
|
|
@@ -1140,3 +1133,16 @@ class Event(dict):
|
|
|
1140
1133
|
|
|
1141
1134
|
def stopPropagation(self) -> None:
|
|
1142
1135
|
"""Stop the event from propagating."""
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
SourceType = NewType("SourceType", str)
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
@dataclass(frozen=True)
|
|
1142
|
+
class JavaScriptModule:
|
|
1143
|
+
source: str
|
|
1144
|
+
source_type: SourceType
|
|
1145
|
+
default_fallback: Any | None
|
|
1146
|
+
import_names: set[str] | None
|
|
1147
|
+
file: Path | None
|
|
1148
|
+
unmount_before_update: bool
|
reactpy/utils.py
CHANGED
|
@@ -242,7 +242,7 @@ def component_to_vdom(component: Component) -> VdomDict:
|
|
|
242
242
|
return component_to_vdom(cast(Component, result))
|
|
243
243
|
elif isinstance(result, str):
|
|
244
244
|
return html.div(result)
|
|
245
|
-
return html
|
|
245
|
+
return html()
|
|
246
246
|
|
|
247
247
|
|
|
248
248
|
def _react_attribute_to_html(key: str, value: Any) -> tuple[str, str]:
|
reactpy/web/__init__.py
CHANGED
|
@@ -3,9 +3,6 @@ from reactpy.web.module import (
|
|
|
3
3
|
module_from_file,
|
|
4
4
|
module_from_string,
|
|
5
5
|
module_from_url,
|
|
6
|
-
reactjs_component_from_file,
|
|
7
|
-
reactjs_component_from_string,
|
|
8
|
-
reactjs_component_from_url,
|
|
9
6
|
)
|
|
10
7
|
|
|
11
8
|
__all__ = [
|
|
@@ -13,7 +10,4 @@ __all__ = [
|
|
|
13
10
|
"module_from_file",
|
|
14
11
|
"module_from_string",
|
|
15
12
|
"module_from_url",
|
|
16
|
-
"reactjs_component_from_file",
|
|
17
|
-
"reactjs_component_from_string",
|
|
18
|
-
"reactjs_component_from_url",
|
|
19
13
|
]
|