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.
Files changed (40) hide show
  1. reactpy/__init__.py +3 -2
  2. reactpy/_html.py +11 -9
  3. reactpy/core/_life_cycle_hook.py +4 -1
  4. reactpy/core/layout.py +43 -38
  5. reactpy/core/serve.py +11 -16
  6. reactpy/core/vdom.py +3 -5
  7. reactpy/pyscript/utils.py +1 -1
  8. reactpy/reactjs/__init__.py +353 -0
  9. reactpy/reactjs/module.py +203 -0
  10. reactpy/reactjs/types.py +7 -0
  11. reactpy/reactjs/utils.py +183 -0
  12. reactpy/static/index-h31022cd.js +5 -0
  13. reactpy/static/index-h31022cd.js.map +11 -0
  14. reactpy/static/index-sbddj6ms.js +5 -0
  15. reactpy/static/index-sbddj6ms.js.map +10 -0
  16. reactpy/static/index-y71bxs88.js +5 -0
  17. reactpy/static/index-y71bxs88.js.map +10 -0
  18. reactpy/static/index.js +2 -2
  19. reactpy/static/index.js.map +6 -10
  20. reactpy/static/react-dom.js +4 -0
  21. reactpy/static/react-dom.js.map +11 -0
  22. reactpy/static/react-jsx-runtime.js +4 -0
  23. reactpy/static/react-jsx-runtime.js.map +9 -0
  24. reactpy/static/react.js +4 -0
  25. reactpy/static/react.js.map +10 -0
  26. reactpy/testing/backend.py +4 -4
  27. reactpy/testing/display.py +2 -1
  28. reactpy/testing/logs.py +1 -1
  29. reactpy/transforms.py +2 -2
  30. reactpy/types.py +17 -11
  31. reactpy/utils.py +1 -1
  32. reactpy/web/__init__.py +0 -6
  33. reactpy/web/module.py +37 -473
  34. reactpy/web/utils.py +2 -158
  35. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/METADATA +1 -1
  36. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/RECORD +39 -24
  37. reactpy/web/templates/react.js +0 -61
  38. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/WHEEL +0 -0
  39. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.dist-info}/entry_points.txt +0 -0
  40. {reactpy-2.0.0b5.dist-info → reactpy-2.0.0b6.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.0b6
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=ZO54xizsV76Vsxfo_9PdHlOkZ7dMxoXn7rAizQsPk30,1203
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
5
  reactpy/config.py,sha256=qLEOO2QQ_wq8qVaiPRujuc1nVVfwmJkHAAUTxvvQsTk,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,14 +16,14 @@ 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
19
+ reactpy/core/_life_cycle_hook.py,sha256=GyMF6g-Mjeh0wO5NBJziPOcA7gXFUO-OITmApZ2CAek,9635
20
20
  reactpy/core/_thread_local.py,sha256=nqvmSQhTrFgh34RUhzSTPEy1AaW3_j82Ji96BTz7hu0,827
21
21
  reactpy/core/component.py,sha256=zASYlRhBrT6JZ-_uTU7N_UOhVSIsnnky4S8xoz5OY98,969
22
22
  reactpy/core/events.py,sha256=HK8SHvl6uQS4H1AqfoK4Mj_YCaMaX3JvSFJ6Bqc4eMI,8594
23
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
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
28
  reactpy/executors/utils.py,sha256=ikhv0MvsOKq45Gm7auLh6PbxvUH2ZgC5HLFXI9vBcLc,2779
29
29
  reactpy/executors/asgi/__init__.py,sha256=eneHZqUxGxTUkTrrpXhq_YBqfA_mig-9YBTNNVFzXC0,405
@@ -35,10 +35,26 @@ reactpy/pyscript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
35
35
  reactpy/pyscript/component_template.py,sha256=jYzQ7YwfJ6RA3A1BcKs_1udUTt7dT3Qct7Bm73BsZdU,778
36
36
  reactpy/pyscript/components.py,sha256=1ZUM3o11cbb4QC1eSCSo1euJeV6uaKAleB3Ie7ntyoU,1915
37
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
38
+ reactpy/pyscript/utils.py,sha256=qI923vqfs91nAOYmE9G-yfIwW2DgJIUPyc9Vrm6N0t0,8863
39
+ reactpy/reactjs/__init__.py,sha256=mfhyZ0pXw9y32tb3e0pSFh6DQJGikhQ-d8Xf726-g7U,11998
40
+ reactpy/reactjs/module.py,sha256=5o-k-9LrIM2DUEgCS60HLkreEvy6cBxmyoCqAXdY57w,6122
41
+ reactpy/reactjs/types.py,sha256=Oik_-Ipj6SNwZyHa1_wEVQBAUPWIB1rtadb_rLpFDgI,208
42
+ reactpy/reactjs/utils.py,sha256=kM4OUHS3T7Ym667aDnLCsdDgId0ff4eyPXTlYpW1vvk,5893
43
+ reactpy/static/index-h31022cd.js,sha256=kDoTnADufQXfXnWz1yE4xccOc9-xenN2yVWTGsuFn_o,13168
44
+ reactpy/static/index-h31022cd.js.map,sha256=Bg8TRwgvfGprr0JUjrjX-s3SiyHhXG6D3deCpdKnsQw,30745
45
+ reactpy/static/index-sbddj6ms.js,sha256=v67dPuLSMuF_01rl37lne4610g7LGkk6mgrgK_w0dx0,1788
46
+ reactpy/static/index-sbddj6ms.js.map,sha256=0JbncMkhrRFSdL0U2EqM159wThOAKPoBPgrtluQFW00,4190
47
+ reactpy/static/index-y71bxs88.js,sha256=w91A8_qCwdjEBtVii6PS20Qq1z8MpHqhpRyzrH6KgVY,11970
48
+ reactpy/static/index-y71bxs88.js.map,sha256=bv5Abkijs0X1W0beBCtwnRJC_JS7-eYXJ-x6muSh5KU,27453
49
+ reactpy/static/index.js,sha256=pKHrDDN2A3mA4DN_Luud3mQvHQEongy8BMSxZHe1prs,13662
50
+ reactpy/static/index.js.map,sha256=3xQKLRka-SIEFOqxWnE3vn1stoSwJChUIzxqlTEe6Gc,54315
41
51
  reactpy/static/pyscript-hide-debug.css,sha256=TSVmdOQVWwN-L9C0g0JmvvHoOfN4NlXvom0SXrIEmXg,33
52
+ reactpy/static/react-dom.js,sha256=u4m8a4ULKBcBA92sLRH0olOket7n2HdnEbkB97hmu0w,1464
53
+ reactpy/static/react-dom.js.map,sha256=IGvF1acksknNvcFCRp7NnTKshv_hjIdJeoAZKdecnAQ,1182
54
+ reactpy/static/react-jsx-runtime.js,sha256=VnTzcoGvqVoi4uE1lzoBG9Hai--mqVOYpQZzt_DLkOM,292
55
+ reactpy/static/react-jsx-runtime.js.map,sha256=hTiAjMVPdotYC6qZRKa3GqLM8jodZuOeNlqPMujdWb4,144
56
+ reactpy/static/react.js,sha256=_rmkynU4uIOLGDmQdg8YSPpdY9hSN63bSc2zmO751uA,1302
57
+ reactpy/static/react.js.map,sha256=M-E4EaQVVOVEoMgXhnUWiuqTtSP1vE7QBA7f7NW_r7Y,320
42
58
  reactpy/static/morphdom/morphdom-esm.js,sha256=SOgEV5tSt-D2pjMeZDbV0cLiHCT4FVKNipG8NQmE7Do,28610
43
59
  reactpy/static/morphdom/morphdom-factory.js,sha256=iDCdYf_nbCiXC-_NKcp6nihq980NzgMZE6NX4HDgy74,26492
44
60
  reactpy/static/morphdom/morphdom-umd.js,sha256=guJOFWL0884p3kouGnEBOxxjqpyT7joM8fRXaQihL9s,31590
@@ -100,17 +116,16 @@ reactpy/static/pyscript/zip-pccs084i.js.map,sha256=HiY9HOwFsPc-R9viM6qN0QVf1PQBE
100
116
  reactpy/templatetags/__init__.py,sha256=slwD8UiXJ8WQAGxDsGy1_fpX-9mbwNAU17cTL0bktMo,80
101
117
  reactpy/templatetags/jinja.py,sha256=YHKZhf6i6tsd0IwsS4SBb7kR9MbUjSKwuEH3xdtF6-Y,1541
102
118
  reactpy/testing/__init__.py,sha256=f8JhesjRwOConigrCKd-XHRDAmpIA7xRU5oVIxLG4Fw,643
103
- reactpy/testing/backend.py,sha256=cH9LD0KeiM3eWFs-0MkAkrsNgUrZweL9Ts8PAZs8G3M,7128
119
+ reactpy/testing/backend.py,sha256=EUerzGvyPsBX7j8QCqsl03aWe2yk95lnZhSfcpYjHrA,7075
104
120
  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
121
+ reactpy/testing/display.py,sha256=zDAu7WsGDRHBt6JzBcj6U6z9htJobuG2uun1PMhEc4k,2358
122
+ reactpy/testing/logs.py,sha256=XfFZr-Qhq-x6nPgkPqeo_L51NmhJQtAsvnzjuWbx8qY,5672
107
123
  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,,
124
+ reactpy/web/__init__.py,sha256=ldSzfmqYFnKCEclfPs8Y5oL9GaG5LDYtXN9Vaz9wUhI,216
125
+ reactpy/web/module.py,sha256=A5N6habdSSOsTjvahQ7jXEPBYQKRiGslxzAc8N7GWDU,3332
126
+ reactpy/web/utils.py,sha256=TOCy15woEr2QZjiXZV_p6YMof2rYZbQu7wsJVznB5jI,136
127
+ reactpy-2.0.0b6.dist-info/METADATA,sha256=Eqm6izDH1ZU1f498yxhg_zaIxBe6lhx90qMz5FTU6Pg,4998
128
+ reactpy-2.0.0b6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
129
+ reactpy-2.0.0b6.dist-info/entry_points.txt,sha256=WRit3ZrLVh7iDEhUMAPE3A9bcaa7TsolCdAdkxGmv0U,61
130
+ reactpy-2.0.0b6.dist-info/licenses/LICENSE,sha256=-8yQb3G5cW-IBhxyIe-uoQzI9lPEu7-6Yi5wJSO1ous,1093
131
+ reactpy-2.0.0b6.dist-info/RECORD,,
@@ -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
- }