reactpy 2.0.0b5__py3-none-any.whl → 2.0.0b7__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.
Files changed (52) hide show
  1. reactpy/__init__.py +4 -3
  2. reactpy/_html.py +11 -9
  3. reactpy/config.py +1 -1
  4. reactpy/core/_life_cycle_hook.py +4 -1
  5. reactpy/core/_thread_local.py +1 -1
  6. reactpy/core/hooks.py +11 -19
  7. reactpy/core/layout.py +43 -38
  8. reactpy/core/serve.py +11 -16
  9. reactpy/core/vdom.py +3 -5
  10. reactpy/executors/asgi/pyscript.py +4 -1
  11. reactpy/executors/asgi/standalone.py +1 -1
  12. reactpy/{pyscript → executors/pyscript}/component_template.py +1 -1
  13. reactpy/{pyscript → executors/pyscript}/components.py +1 -1
  14. reactpy/{pyscript → executors/pyscript}/utils.py +1 -1
  15. reactpy/executors/utils.py +32 -7
  16. reactpy/reactjs/__init__.py +351 -0
  17. reactpy/reactjs/module.py +267 -0
  18. reactpy/reactjs/types.py +7 -0
  19. reactpy/reactjs/utils.py +212 -0
  20. reactpy/static/index-64wy0fss.js +5 -0
  21. reactpy/static/index-64wy0fss.js.map +10 -0
  22. reactpy/static/index-beq660xy.js +5 -0
  23. reactpy/static/index-beq660xy.js.map +12 -0
  24. reactpy/static/index.js +2 -2
  25. reactpy/static/index.js.map +7 -10
  26. reactpy/static/preact-dom.js +4 -0
  27. reactpy/static/preact-dom.js.map +11 -0
  28. reactpy/static/preact-jsx-runtime.js +4 -0
  29. reactpy/static/preact-jsx-runtime.js.map +9 -0
  30. reactpy/static/preact.js +4 -0
  31. reactpy/static/preact.js.map +10 -0
  32. reactpy/templatetags/jinja.py +4 -1
  33. reactpy/testing/__init__.py +2 -7
  34. reactpy/testing/backend.py +24 -12
  35. reactpy/testing/common.py +1 -9
  36. reactpy/testing/display.py +65 -28
  37. reactpy/testing/logs.py +1 -1
  38. reactpy/transforms.py +2 -2
  39. reactpy/types.py +17 -11
  40. reactpy/utils.py +1 -1
  41. reactpy/web/__init__.py +0 -6
  42. reactpy/web/module.py +37 -473
  43. reactpy/web/utils.py +2 -158
  44. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b7.dist-info}/METADATA +1 -1
  45. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b7.dist-info}/RECORD +50 -38
  46. reactpy/testing/utils.py +0 -27
  47. reactpy/web/templates/react.js +0 -61
  48. /reactpy/{pyscript → executors/pyscript}/__init__.py +0 -0
  49. /reactpy/{pyscript → executors/pyscript}/layout_handler.py +0 -0
  50. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b7.dist-info}/WHEEL +0 -0
  51. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b7.dist-info}/entry_points.txt +0 -0
  52. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b7.dist-info}/licenses/LICENSE +0 -0
reactpy/web/utils.py CHANGED
@@ -1,159 +1,3 @@
1
- import logging
2
- import re
3
- from pathlib import Path, PurePosixPath
4
- from urllib.parse import urlparse, urlunparse
5
-
6
- import requests
7
-
8
- logger = logging.getLogger(__name__)
9
-
10
-
11
- def module_name_suffix(name: str) -> str:
12
- if name.startswith("@"):
13
- name = name[1:]
14
- head, _, tail = name.partition("@") # handle version identifier
15
- _, _, tail = tail.partition("/") # get section after version
16
- return PurePosixPath(tail or head).suffix or ".js"
17
-
18
-
19
- def resolve_module_exports_from_file(
20
- file: Path,
21
- max_depth: int,
22
- is_re_export: bool = False,
23
- ) -> set[str]:
24
- if max_depth == 0:
25
- logger.warning(f"Did not resolve all exports for {file} - max depth reached")
26
- return set()
27
- elif not file.exists():
28
- logger.warning(f"Did not resolve exports for unknown file {file}")
29
- return set()
30
-
31
- export_names, references = resolve_module_exports_from_source(
32
- file.read_text(encoding="utf-8"), exclude_default=is_re_export
33
- )
34
-
35
- for ref in references:
36
- if urlparse(ref).scheme: # is an absolute URL
37
- export_names.update(
38
- resolve_module_exports_from_url(ref, max_depth - 1, is_re_export=True)
39
- )
40
- else:
41
- path = file.parent.joinpath(*ref.split("/"))
42
- export_names.update(
43
- resolve_module_exports_from_file(path, max_depth - 1, is_re_export=True)
44
- )
45
-
46
- return export_names
47
-
48
-
49
- def resolve_module_exports_from_url(
50
- url: str,
51
- max_depth: int,
52
- is_re_export: bool = False,
53
- ) -> set[str]:
54
- if max_depth == 0:
55
- logger.warning(f"Did not resolve all exports for {url} - max depth reached")
56
- return set()
57
-
58
- try:
59
- text = requests.get(url, timeout=5).text
60
- except requests.exceptions.ConnectionError as error:
61
- reason = "" if error is None else " - {error.errno}"
62
- logger.warning("Did not resolve exports for url " + url + reason)
63
- return set()
64
-
65
- export_names, references = resolve_module_exports_from_source(
66
- text, exclude_default=is_re_export
67
- )
68
-
69
- for ref in references:
70
- url = _resolve_relative_url(url, ref)
71
- export_names.update(
72
- resolve_module_exports_from_url(url, max_depth - 1, is_re_export=True)
73
- )
74
-
75
- return export_names
76
-
77
-
78
- def resolve_module_exports_from_source(
79
- content: str, exclude_default: bool
80
- ) -> tuple[set[str], set[str]]:
81
- names: set[str] = set()
82
- references: set[str] = set()
83
-
84
- if _JS_DEFAULT_EXPORT_PATTERN.search(content):
85
- names.add("default")
86
-
87
- # Exporting functions and classes
88
- names.update(_JS_FUNC_OR_CLS_EXPORT_PATTERN.findall(content))
89
-
90
- for export in _JS_GENERAL_EXPORT_PATTERN.findall(content):
91
- export = export.rstrip(";").strip()
92
- # Exporting individual features
93
- if export.startswith("let "):
94
- names.update(let.split("=", 1)[0] for let in export[4:].split(","))
95
- # Renaming exports and export list
96
- elif export.startswith("{") and export.endswith("}"):
97
- names.update(
98
- item.split(" as ", 1)[-1] for item in export.strip("{}").split(",")
99
- )
100
- # Exporting destructured assignments with renaming
101
- elif export.startswith("const "):
102
- names.update(
103
- item.split(":", 1)[0]
104
- for item in export[6:].split("=", 1)[0].strip("{}").split(",")
105
- )
106
- # Default exports
107
- elif export.startswith("default "):
108
- names.add("default")
109
- # Aggregating modules
110
- elif export.startswith("* as "):
111
- names.add(export[5:].split(" from ", 1)[0])
112
- elif export.startswith("* "):
113
- references.add(export[2:].split("from ", 1)[-1].strip("'\""))
114
- elif export.startswith("{") and " from " in export:
115
- names.update(
116
- item.split(" as ", 1)[-1]
117
- for item in export.split(" from ")[0].strip("{}").split(",")
118
- )
119
- elif not (export.startswith("function ") or export.startswith("class ")):
120
- logger.warning(f"Unknown export type {export!r}")
121
-
122
- names = {n.strip() for n in names}
123
- references = {r.strip() for r in references}
124
-
125
- if exclude_default and "default" in names:
126
- names.remove("default")
127
-
128
- return names, references
129
-
130
-
131
- def _resolve_relative_url(base_url: str, rel_url: str) -> str:
132
- if not rel_url.startswith("."):
133
- if rel_url.startswith("/"):
134
- # copy scheme and hostname from base_url
135
- return urlunparse(urlparse(base_url)[:2] + urlparse(rel_url)[2:])
136
- else:
137
- return rel_url
138
-
139
- base_url = base_url.rsplit("/", 1)[0]
140
-
141
- if rel_url.startswith("./"):
142
- return base_url + rel_url[1:]
143
-
144
- while rel_url.startswith("../"):
145
- base_url = base_url.rsplit("/", 1)[0]
146
- rel_url = rel_url[3:]
147
-
148
- return f"{base_url}/{rel_url}"
149
-
150
-
151
- _JS_DEFAULT_EXPORT_PATTERN = re.compile(
152
- r";?\s*export\s+default\s",
153
- )
154
- _JS_FUNC_OR_CLS_EXPORT_PATTERN = re.compile(
155
- r";?\s*export\s+(?:function|class)\s+([a-zA-Z_$][0-9a-zA-Z_$]*)"
156
- )
157
- _JS_GENERAL_EXPORT_PATTERN = re.compile(
158
- r"(?:^|;|})\s*export(?=\s+|{)(.*?)(?=;|$)", re.MULTILINE
1
+ raise ImportError( # nocov
2
+ "WARNING: reactpy.web.utils was not within the public API, and thus has been removed without notice."
159
3
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reactpy
3
- Version: 2.0.0b5
3
+ Version: 2.0.0b7
4
4
  Summary: It's React, but in Python.
5
5
  Project-URL: Changelog, https://reactpy.dev/docs/about/changelog.html
6
6
  Project-URL: Documentation, https://reactpy.dev/
@@ -1,13 +1,13 @@
1
- reactpy/__init__.py,sha256=-JzXcLiay8bWxSlRerOIjXe9XLdFM5SZudRUerLTaAM,1179
2
- reactpy/_html.py,sha256=SNDqr_ovXYFruC7ZWYFGCCCN9S4UTYGTsLnM-8VCz0o,11368
1
+ reactpy/__init__.py,sha256=pZzzdfRxte7CxgoM2pWcguSrtDTpoouoGXQcf2YpIBQ,1213
2
+ reactpy/_html.py,sha256=1r47Irgeh_emnJfSNo9ajDntmW4CeiqSqPFLMczQG_Y,11529
3
3
  reactpy/_option.py,sha256=T4rQa_YIGLEVlYmqLDD-a2hQBfM5OHVGjFycTQUP4sI,5115
4
4
  reactpy/_warnings.py,sha256=DR1YGzTS8ijaH0Wqh2V3TWDeDlkBwEb9dSsEYYuW-RI,933
5
- reactpy/config.py,sha256=qLEOO2QQ_wq8qVaiPRujuc1nVVfwmJkHAAUTxvvQsTk,3791
5
+ reactpy/config.py,sha256=-RRW7GTUpZ7CXewb27DLfl8T410TTXvQ479B_DAkbws,3791
6
6
  reactpy/logging.py,sha256=VEQWQIjgAfAKj1qdvcT9PoMiRZ5iCfd0GPkhI5vmjxA,857
7
7
  reactpy/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
8
- reactpy/transforms.py,sha256=hgIiMriflwPsMZhtZkqUm5Qj_eR5hrLrp0yTJ7NnC_c,11837
9
- reactpy/types.py,sha256=xF8QvkNgzJZXgKOnRAL_NA82UIDQk594qzkdUXjY1Go,33739
10
- reactpy/utils.py,sha256=pCPLpqnS8PhTsWnUROVOOLuQC_dzGo6fTiDd-ATVOEc,10871
8
+ reactpy/transforms.py,sha256=mDtA_8_GFluukNBckIGaeCtOQ8EOi-Fn-MTlq-xEn6Y,11871
9
+ reactpy/types.py,sha256=Uh6_PsiZoPa9AdNT9zstMnqgrgrAl_X5NhZxJgk8onk,33727
10
+ reactpy/utils.py,sha256=8IIAe_3lpSlwL8BQtFfqel77vYr95d4o0xDpcayFMWE,10862
11
11
  reactpy/widgets.py,sha256=xLfjTqvDg96jQa-mApex7QGcikt216DeTcDFc_9pwAU,2623
12
12
  reactpy/_console/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  reactpy/_console/ast_utils.py,sha256=bBQ0hNP5-p5CbQFRK0-f-z1c1cVReNBFR0BAcN30vTg,6340
@@ -16,28 +16,42 @@ reactpy/_console/rewrite_keys.py,sha256=Ydnbfxp8Sv6OnCwLCLQp6aTurAOLW9w1fOFVPWSu
16
16
  reactpy/_console/rewrite_props.py,sha256=bnGjLBOLQJNgIWBbilQ6Df_nJBuPDODk93bAQUwgC4s,4791
17
17
  reactpy/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  reactpy/core/_f_back.py,sha256=hVVbAjfaGO7oTh3VGdDziThuspYftfQICtWSv_0i1yc,605
19
- reactpy/core/_life_cycle_hook.py,sha256=T8R3BMi7QaEsi1la1nywwfG_h4ts1JEe4MdsBTskGdU,9568
20
- reactpy/core/_thread_local.py,sha256=nqvmSQhTrFgh34RUhzSTPEy1AaW3_j82Ji96BTz7hu0,827
19
+ reactpy/core/_life_cycle_hook.py,sha256=GyMF6g-Mjeh0wO5NBJziPOcA7gXFUO-OITmApZ2CAek,9635
20
+ reactpy/core/_thread_local.py,sha256=qMnnF9Wz-OqbqUk81glgPpppvxdq6hXyDkx-AYXtfAI,828
21
21
  reactpy/core/component.py,sha256=zASYlRhBrT6JZ-_uTU7N_UOhVSIsnnky4S8xoz5OY98,969
22
22
  reactpy/core/events.py,sha256=HK8SHvl6uQS4H1AqfoK4Mj_YCaMaX3JvSFJ6Bqc4eMI,8594
23
- reactpy/core/hooks.py,sha256=GtEG1bFubMUR1BLW_k5cBz1-mCy6XxKUkoR1x_tv2mk,19034
24
- reactpy/core/layout.py,sha256=nNO4y6vxhEpmcw3JHDGxPENDr_y_KegBYO_UyUmdswY,25842
25
- reactpy/core/serve.py,sha256=KU71UlAITA_b3ahz93rZTlqX0uHOXCYpR09GDsAWrmk,2544
26
- reactpy/core/vdom.py,sha256=porm5xYGiKJSYM5rFd4jkzC-csAx5S4n1ZgWMo60pxI,9910
23
+ reactpy/core/hooks.py,sha256=iL36fDcubkB65PjKt0JVyvD0rtdmzcN-4-brHO67bB0,18919
24
+ reactpy/core/layout.py,sha256=CYQBWnzS0PdzRi8pifC8PYg3BS0kzOgB0MQc1O4e404,26122
25
+ reactpy/core/serve.py,sha256=DFdJ6AWZzAuuq_8PtPmD-QprvMJFsYp77_O3Q46prx8,2337
26
+ reactpy/core/vdom.py,sha256=Boe9dsHKrsVWM2hZai7Y41VYzTHeIQn-bl537vkj0ds,9771
27
27
  reactpy/executors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- reactpy/executors/utils.py,sha256=ikhv0MvsOKq45Gm7auLh6PbxvUH2ZgC5HLFXI9vBcLc,2779
28
+ reactpy/executors/utils.py,sha256=ycRRrAazuQk6q7E3vV88J0PrbYB8PCwxwnaoqVPRino,3848
29
29
  reactpy/executors/asgi/__init__.py,sha256=eneHZqUxGxTUkTrrpXhq_YBqfA_mig-9YBTNNVFzXC0,405
30
30
  reactpy/executors/asgi/middleware.py,sha256=AgXs7VxBjS01v1Fq4WkU6ORmNr7-pd7eEzaybRYig3o,11428
31
- reactpy/executors/asgi/pyscript.py,sha256=W-5E5RNVsE5zNKF9iU0zs0M37DKbuGWTKUZiOwoVbWs,5263
32
- reactpy/executors/asgi/standalone.py,sha256=dh1BqFwDOcsXeAjgWH2cw2Wn3vp4KK7x8uwhX_cb3BM,8698
31
+ reactpy/executors/asgi/pyscript.py,sha256=8maR9XQwR-hZHNDZi5e4QXYvpbJp1qzjBZyk6pg-rUo,5286
32
+ reactpy/executors/asgi/standalone.py,sha256=2-IhMwFgwFttEmz4bf2I8cMdEgEKBxGjHKaTtJDkVxE,8708
33
33
  reactpy/executors/asgi/types.py,sha256=jCIU8mJx1CMvYtmV3Lq7iIET8uiSwAeMJOwTsosHBKs,3362
34
- reactpy/pyscript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- reactpy/pyscript/component_template.py,sha256=jYzQ7YwfJ6RA3A1BcKs_1udUTt7dT3Qct7Bm73BsZdU,778
36
- reactpy/pyscript/components.py,sha256=1ZUM3o11cbb4QC1eSCSo1euJeV6uaKAleB3Ie7ntyoU,1915
37
- reactpy/pyscript/layout_handler.py,sha256=aBrnBeiEMudUvRqbhW7KoJW-RkwS_wQ2KZl6m47vcNA,6289
38
- reactpy/pyscript/utils.py,sha256=VX13umrX-d9qvSdxBfS6_RiXPjD5DGYJQA25PpEpn5Q,8854
39
- reactpy/static/index.js,sha256=wgV9C8lXoR0DjQRLplUlSqC7Xz0piLJWCcVjdQQOvq4,32495
40
- reactpy/static/index.js.map,sha256=oYBPFgYcxsgDIAaKEADBkrRVSm9v4lzrpp8PvdhS5bo,105332
34
+ reactpy/executors/pyscript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
+ reactpy/executors/pyscript/component_template.py,sha256=0EC2NUzrDxjCg0zcOtHV1yfRmFEA6n9e9rt9gP03G_A,788
36
+ reactpy/executors/pyscript/components.py,sha256=cz1555jzwqc8JZfPP3g-aV3UEJ1-Qh4zXNKfAxksotk,1925
37
+ reactpy/executors/pyscript/layout_handler.py,sha256=aBrnBeiEMudUvRqbhW7KoJW-RkwS_wQ2KZl6m47vcNA,6289
38
+ reactpy/executors/pyscript/utils.py,sha256=qI923vqfs91nAOYmE9G-yfIwW2DgJIUPyc9Vrm6N0t0,8863
39
+ reactpy/reactjs/__init__.py,sha256=0hu1wuFi3nhcsfHT4EMM2O5E4XMD9ijaE3IBJTLQeHw,11990
40
+ reactpy/reactjs/module.py,sha256=AqfdO9foXHqiPKk02fs-AAX5Cwa_CxoXMYt1qYNOBSI,9141
41
+ reactpy/reactjs/types.py,sha256=Oik_-Ipj6SNwZyHa1_wEVQBAUPWIB1rtadb_rLpFDgI,208
42
+ reactpy/reactjs/utils.py,sha256=cJ2VbImlhfv0qwIZaCTXJ5YgbuqKPaO2_IHCQqLZLlE,6840
43
+ reactpy/static/index-64wy0fss.js,sha256=8syb59S954n37cK1l2G5UqbfQ6pvolOXMcTIo3XAgAY,1793
44
+ reactpy/static/index-64wy0fss.js.map,sha256=rx76p2DWfjroCpS4CrT0rou36_T0gzSPWgd5aJ8uKIY,4190
45
+ reactpy/static/index-beq660xy.js,sha256=oeNLtnKprSg7WT2Wr_Pn6oNgOJYwDguUWkBB0fmy4FE,25294
46
+ reactpy/static/index-beq660xy.js.map,sha256=su0fHsjdcrYoql7TC8xxnrzXN9TasaoNC_6MKmG6N5M,58059
47
+ reactpy/static/index.js,sha256=4gDPhAEoAqCepQBVsiXNTc5uJg8_sM2wkvqhGIXyXOQ,14268
48
+ reactpy/static/index.js.map,sha256=j4unEoY--U9dHL-cCK-PwNKcmR_wbq5QohRMgv5U7fg,57173
49
+ reactpy/static/preact-dom.js,sha256=37D1sjc5O-4VhLm4cJj4dGSL2tgFjIb4lRTHfIRE-Aw,1427
50
+ reactpy/static/preact-dom.js.map,sha256=oL0GgSCIpg81j_LP5uWonxvEhWmNYsQXiEnyLT-dMRY,1183
51
+ reactpy/static/preact-jsx-runtime.js,sha256=fOTjeln4sPSheSj7VRmpI0zJuUhep1wmbTJGjEDvW8E,293
52
+ reactpy/static/preact-jsx-runtime.js.map,sha256=Du-8IyulpefkvfQqn5SP-udpOmXpiZrzV5vGVwJGDFs,144
53
+ reactpy/static/preact.js,sha256=qKqljSpOym3cUU9eZgohVRIaiPgpdBXmNXlSX6zs-Lk,1280
54
+ reactpy/static/preact.js.map,sha256=0AP-2ugcNhPyDRl-YJEIag7NSIgrP74ocuCcjGr_VFI,321
41
55
  reactpy/static/pyscript-hide-debug.css,sha256=TSVmdOQVWwN-L9C0g0JmvvHoOfN4NlXvom0SXrIEmXg,33
42
56
  reactpy/static/morphdom/morphdom-esm.js,sha256=SOgEV5tSt-D2pjMeZDbV0cLiHCT4FVKNipG8NQmE7Do,28610
43
57
  reactpy/static/morphdom/morphdom-factory.js,sha256=iDCdYf_nbCiXC-_NKcp6nihq980NzgMZE6NX4HDgy74,26492
@@ -98,19 +112,17 @@ reactpy/static/pyscript/xterm_addon-web-links-D95xh2la.js.map,sha256=da7uXeo4q_I
98
112
  reactpy/static/pyscript/zip-pccs084i.js,sha256=Xi7AoScnuKZgx803pBsSyfVLX6fi5-_XBU_2W-4UOrs,158922
99
113
  reactpy/static/pyscript/zip-pccs084i.js.map,sha256=HiY9HOwFsPc-R9viM6qN0QVf1PQBEhA5Lg2-bDy2tu8,293552
100
114
  reactpy/templatetags/__init__.py,sha256=slwD8UiXJ8WQAGxDsGy1_fpX-9mbwNAU17cTL0bktMo,80
101
- reactpy/templatetags/jinja.py,sha256=YHKZhf6i6tsd0IwsS4SBb7kR9MbUjSKwuEH3xdtF6-Y,1541
102
- reactpy/testing/__init__.py,sha256=f8JhesjRwOConigrCKd-XHRDAmpIA7xRU5oVIxLG4Fw,643
103
- reactpy/testing/backend.py,sha256=cH9LD0KeiM3eWFs-0MkAkrsNgUrZweL9Ts8PAZs8G3M,7128
104
- reactpy/testing/common.py,sha256=gkcEJDAel-6nsOtuL628WoB1eSmzhLKp6RFwtN84TR8,7042
105
- reactpy/testing/display.py,sha256=9XbQ6qVrsbDXWIJ-LXemspGFqxmtzzIy5Ojed6J71-c,2170
106
- reactpy/testing/logs.py,sha256=40MGuZIlwT6c_ziziwLCsH1Y032ROAFcLvd8g9lRvAc,5672
107
- reactpy/testing/utils.py,sha256=b4s1hpLqdl_Z8G_hHAx3ELlr4x1oI9iuazOdS43wkZI,1071
108
- reactpy/web/__init__.py,sha256=gJuI9-GMoMSV6KrA3idYRIWmFu6wtnwnIWU2IA8PJS0,422
109
- reactpy/web/module.py,sha256=hpm60GbUMimIPY7_7-AJ7CCZesVxEE1Ur9Vrra6bzQg,18097
110
- reactpy/web/utils.py,sha256=gAlR_rIIB0ezPZCb8bYKd8hSPb95RTAjcQmozkUqMhY,5172
111
- reactpy/web/templates/react.js,sha256=VIwJfl8S3b53PazgFdaWpgHLhTYpcmNdSQfpl9LPQdM,1950
112
- reactpy-2.0.0b5.dist-info/METADATA,sha256=XFAsLQjc7T6iaZ7G9u7e-o3uIBLz8F9OCh0o43U39bI,4998
113
- reactpy-2.0.0b5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
114
- reactpy-2.0.0b5.dist-info/entry_points.txt,sha256=WRit3ZrLVh7iDEhUMAPE3A9bcaa7TsolCdAdkxGmv0U,61
115
- reactpy-2.0.0b5.dist-info/licenses/LICENSE,sha256=-8yQb3G5cW-IBhxyIe-uoQzI9lPEu7-6Yi5wJSO1ous,1093
116
- reactpy-2.0.0b5.dist-info/RECORD,,
115
+ reactpy/templatetags/jinja.py,sha256=lWmFQFVe9ofv08nH9TelRHZenHNXf1vgCbQeJsCoFoQ,1564
116
+ reactpy/testing/__init__.py,sha256=WF825hAnnfYGLmKQPbyHHG4q-OsXHMjpOGRrmX3fel8,592
117
+ reactpy/testing/backend.py,sha256=XwLbGs0OKp-d1rjpy6U4gDCdOTGJNmqPIO9uoxzecNk,7470
118
+ reactpy/testing/common.py,sha256=8eFPocyS62iGalr63ucbYI_oaJHFks0ZCZB6BQV4W0A,6758
119
+ reactpy/testing/display.py,sha256=FJJ_9bbD408NfqmnW6LrJmQNn_vg61otBkEyp30Z6_M,3580
120
+ reactpy/testing/logs.py,sha256=XfFZr-Qhq-x6nPgkPqeo_L51NmhJQtAsvnzjuWbx8qY,5672
121
+ reactpy/web/__init__.py,sha256=ldSzfmqYFnKCEclfPs8Y5oL9GaG5LDYtXN9Vaz9wUhI,216
122
+ reactpy/web/module.py,sha256=A5N6habdSSOsTjvahQ7jXEPBYQKRiGslxzAc8N7GWDU,3332
123
+ reactpy/web/utils.py,sha256=TOCy15woEr2QZjiXZV_p6YMof2rYZbQu7wsJVznB5jI,136
124
+ reactpy-2.0.0b7.dist-info/METADATA,sha256=1nBGMDi9F9qXJmvdMH3diPUS8b33XpMLo2I9u20XaYE,4998
125
+ reactpy-2.0.0b7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
126
+ reactpy-2.0.0b7.dist-info/entry_points.txt,sha256=WRit3ZrLVh7iDEhUMAPE3A9bcaa7TsolCdAdkxGmv0U,61
127
+ reactpy-2.0.0b7.dist-info/licenses/LICENSE,sha256=-8yQb3G5cW-IBhxyIe-uoQzI9lPEu7-6Yi5wJSO1ous,1093
128
+ reactpy-2.0.0b7.dist-info/RECORD,,
reactpy/testing/utils.py DELETED
@@ -1,27 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import socket
4
- import sys
5
- from contextlib import closing
6
-
7
-
8
- def find_available_port(
9
- host: str, port_min: int = 8000, port_max: int = 9000
10
- ) -> int: # nocov
11
- """Get a port that's available for the given host and port range"""
12
- for port in range(port_min, port_max):
13
- with closing(socket.socket()) as sock:
14
- try:
15
- if sys.platform in ("linux", "darwin"):
16
- # Fixes bug on Unix-like systems where every time you restart the
17
- # server you'll get a different port on Linux. This cannot be set
18
- # on Windows otherwise address will always be reused.
19
- # Ref: https://stackoverflow.com/a/19247688/3159288
20
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
21
- sock.bind((host, port))
22
- except OSError:
23
- pass
24
- else:
25
- return port
26
- msg = f"Host {host!r} has no available port in range {port_max}-{port_max}"
27
- raise RuntimeError(msg)
@@ -1,61 +0,0 @@
1
- export * from "$CDN/$PACKAGE";
2
-
3
- import * as React from "$CDN/react$VERSION";
4
- import * as ReactDOM from "$CDN/react-dom$VERSION";
5
-
6
- export default ({ children, ...props }) => {
7
- const [{ component }, setComponent] = React.useState({});
8
- React.useEffect(() => {
9
- import("$CDN/$PACKAGE").then((module) => {
10
- // dynamically load the default export since we don't know if it's exported.
11
- setComponent({ component: module.default });
12
- });
13
- });
14
- return component
15
- ? React.createElement(component, props, ...(children || []))
16
- : null;
17
- };
18
-
19
- export function bind(node, config) {
20
- const root = ReactDOM.createRoot(node);
21
- return {
22
- create: (component, props, children) =>
23
- React.createElement(component, wrapEventHandlers(props), ...children),
24
- render: (element) => root.render(element),
25
- unmount: () => root.unmount()
26
- };
27
- }
28
-
29
- function wrapEventHandlers(props) {
30
- const newProps = Object.assign({}, props);
31
- for (const [key, value] of Object.entries(props)) {
32
- if (typeof value === "function" && value.isHandler) {
33
- newProps[key] = makeJsonSafeEventHandler(value);
34
- }
35
- }
36
- return newProps;
37
- }
38
-
39
- function makeJsonSafeEventHandler(oldHandler) {
40
- // Since we can't really know what the event handlers get passed we have to check if
41
- // they are JSON serializable or not. We can allow normal synthetic events to pass
42
- // through since the original handler already knows how to serialize those for us.
43
- return function safeEventHandler() {
44
- oldHandler(
45
- ...Array.from(arguments).filter((value) => {
46
- if (typeof value === "object" && value.nativeEvent) {
47
- // this is probably a standard React synthetic event
48
- return true;
49
- } else {
50
- try {
51
- JSON.stringify(value);
52
- } catch (err) {
53
- console.error("Failed to serialize some event data");
54
- return false;
55
- }
56
- return true;
57
- }
58
- }),
59
- );
60
- };
61
- }
File without changes