reactpy_django 3.8.1__tar.gz → 5.0.0__tar.gz

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 (115) hide show
  1. {reactpy_django-3.8.1/src/reactpy_django.egg-info → reactpy_django-5.0.0}/PKG-INFO +5 -5
  2. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/README.md +3 -2
  3. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/pyproject.toml +1 -1
  4. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/setup.cfg +0 -3
  5. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/setup.py +44 -5
  6. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/__init__.py +11 -7
  7. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/checks.py +42 -26
  8. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/clean.py +1 -1
  9. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/components.py +75 -77
  10. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/config.py +4 -11
  11. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/database.py +1 -1
  12. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/decorators.py +2 -38
  13. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/hooks.py +66 -93
  14. reactpy_django-5.0.0/src/reactpy_django/html.py +3 -0
  15. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/http/views.py +3 -3
  16. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/management/commands/clean_reactpy.py +2 -2
  17. reactpy_django-5.0.0/src/reactpy_django/pyscript/component_template.py +26 -0
  18. reactpy_django-5.0.0/src/reactpy_django/pyscript/layout_handler.py +139 -0
  19. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/router/__init__.py +1 -1
  20. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/router/converters.py +2 -1
  21. reactpy_django-5.0.0/src/reactpy_django/router/resolvers.py +22 -0
  22. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/client.js +1 -0
  23. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/morphdom/morphdom-esm.js +769 -0
  24. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/morphdom/morphdom-factory.js +705 -0
  25. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/morphdom/morphdom-umd.js +777 -0
  26. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/morphdom/morphdom-umd.min.js +1 -0
  27. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/morphdom/morphdom.js +771 -0
  28. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror-BEtcgaoQ.js +2 -0
  29. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror-BEtcgaoQ.js.map +1 -0
  30. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_commands-DDxffOmd.js +2 -0
  31. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_commands-DDxffOmd.js.map +1 -0
  32. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_lang-python-CnWnFqxD.js +2 -0
  33. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_lang-python-CnWnFqxD.js.map +1 -0
  34. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_language-CjmvX4ix.js +2 -0
  35. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_language-CjmvX4ix.js.map +1 -0
  36. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_state-D1qTXrff.js +2 -0
  37. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_state-D1qTXrff.js.map +1 -0
  38. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_view-DVb8uYMr.js +2 -0
  39. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/codemirror_view-DVb8uYMr.js.map +1 -0
  40. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/core-CjO3FOKB.js +2 -0
  41. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/core-CjO3FOKB.js.map +1 -0
  42. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/core.css +1 -0
  43. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/core.js +2 -0
  44. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/core.js.map +1 -0
  45. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/deprecations-manager-pFtn19mE.js +2 -0
  46. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/deprecations-manager-pFtn19mE.js.map +1 -0
  47. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/error-tq-z48YI.js +2 -0
  48. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/error-tq-z48YI.js.map +1 -0
  49. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/index-S1Do43bx.js +2 -0
  50. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/index-S1Do43bx.js.map +1 -0
  51. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/mpy-DovD7Qjy.js +2 -0
  52. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/mpy-DovD7Qjy.js.map +1 -0
  53. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/py-BUsUWVJg.js +2 -0
  54. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/py-BUsUWVJg.js.map +1 -0
  55. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/py-editor-CeySmmer.js +2 -0
  56. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/py-editor-CeySmmer.js.map +1 -0
  57. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/py-terminal-CH_wV7wQ.js +2 -0
  58. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/py-terminal-CH_wV7wQ.js.map +1 -0
  59. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/storage.js +2 -0
  60. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/storage.js.map +1 -0
  61. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/toml-CvAfdf9_.js +3 -0
  62. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/toml-CvAfdf9_.js.map +1 -0
  63. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/toml-DiUM0_qs.js +3 -0
  64. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/toml-DiUM0_qs.js.map +1 -0
  65. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm-BY7uk_OU.js +2 -0
  66. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm-BY7uk_OU.js.map +1 -0
  67. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm-readline-CZfBw7ic.js +2 -0
  68. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm-readline-CZfBw7ic.js.map +1 -0
  69. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm.css +7 -0
  70. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm_addon-fit--gyF3PcZ.js +2 -0
  71. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm_addon-fit--gyF3PcZ.js.map +1 -0
  72. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm_addon-web-links-Cnej-nJ6.js +2 -0
  73. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/xterm_addon-web-links-Cnej-nJ6.js.map +1 -0
  74. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/zip-DrwYHuF9.js +2 -0
  75. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript/zip-DrwYHuF9.js.map +1 -0
  76. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript-custom.css +3 -0
  77. reactpy_django-5.0.0/src/reactpy_django/static/reactpy_django/pyscript-hide-debug.css +3 -0
  78. reactpy_django-5.0.0/src/reactpy_django/templates/reactpy/pyscript_component.html +2 -0
  79. reactpy_django-5.0.0/src/reactpy_django/templates/reactpy/pyscript_setup.html +8 -0
  80. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/templatetags/reactpy.py +91 -62
  81. reactpy_django-5.0.0/src/reactpy_django/types.py +81 -0
  82. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/utils.py +192 -16
  83. reactpy_django-5.0.0/src/reactpy_django/websocket/__init__.py +0 -0
  84. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/websocket/consumer.py +17 -8
  85. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/websocket/paths.py +2 -4
  86. {reactpy_django-3.8.1 → reactpy_django-5.0.0/src/reactpy_django.egg-info}/PKG-INFO +5 -5
  87. reactpy_django-5.0.0/src/reactpy_django.egg-info/SOURCES.txt +109 -0
  88. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django.egg-info/requires.txt +1 -2
  89. reactpy_django-3.8.1/src/reactpy_django/router/resolvers.py +0 -58
  90. reactpy_django-3.8.1/src/reactpy_django/static/reactpy_django/client.js +0 -1630
  91. reactpy_django-3.8.1/src/reactpy_django/types.py +0 -121
  92. reactpy_django-3.8.1/src/reactpy_django.egg-info/SOURCES.txt +0 -49
  93. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/LICENSE.md +0 -0
  94. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/MANIFEST.in +0 -0
  95. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/apps.py +0 -0
  96. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/exceptions.py +0 -0
  97. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/http/__init__.py +0 -0
  98. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/http/urls.py +0 -0
  99. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/management/__init__.py +0 -0
  100. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/management/commands/__init__.py +0 -0
  101. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/migrations/0001_initial.py +0 -0
  102. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/migrations/0002_rename_created_at_componentparams_last_accessed.py +0 -0
  103. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/migrations/0003_componentsession_delete_componentparams.py +0 -0
  104. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/migrations/0004_config.py +0 -0
  105. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/migrations/0005_alter_componentsession_last_accessed.py +0 -0
  106. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/migrations/0006_userdatamodel.py +0 -0
  107. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/migrations/__init__.py +0 -0
  108. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/models.py +0 -0
  109. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/py.typed +0 -0
  110. {reactpy_django-3.8.1/src/reactpy_django/templatetags → reactpy_django-5.0.0/src/reactpy_django/pyscript}/__init__.py +0 -0
  111. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django/templates/reactpy/component.html +0 -0
  112. {reactpy_django-3.8.1/src/reactpy_django/websocket → reactpy_django-5.0.0/src/reactpy_django/templatetags}/__init__.py +0 -0
  113. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django.egg-info/dependency_links.txt +0 -0
  114. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django.egg-info/not-zip-safe +0 -0
  115. {reactpy_django-3.8.1 → reactpy_django-5.0.0}/src/reactpy_django.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reactpy_django
3
- Version: 3.8.1
3
+ Version: 5.0.0
4
4
  Summary: It's React, but in Python. Now with Django integration.
5
5
  Home-page: https://github.com/reactive-python/reactpy-django
6
6
  Author: Mark Bakhit
@@ -27,14 +27,13 @@ License-File: LICENSE.md
27
27
  Requires-Dist: channels>=4.0.0
28
28
  Requires-Dist: django>=4.2.0
29
29
  Requires-Dist: reactpy<1.1.0,>=1.0.2
30
- Requires-Dist: reactpy-router<1.0.0,>=0.1.1
31
- Requires-Dist: aiofile>=3.0
30
+ Requires-Dist: reactpy-router<2.0.0,>=1.0.0
32
31
  Requires-Dist: dill>=0.3.5
33
32
  Requires-Dist: orjson>=3.6.0
34
33
  Requires-Dist: nest_asyncio>=1.5.0
35
34
  Requires-Dist: typing_extensions
36
35
 
37
- # <img src="https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg" align="left" height="45"/> ReactPy Django
36
+ # <img src="https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg" align="left" height="45"/> ReactPy-Django
38
37
 
39
38
  <p>
40
39
  <a href="https://github.com/reactive-python/reactpy-django/actions?query=workflow%3ATest">
@@ -57,6 +56,7 @@ Requires-Dist: typing_extensions
57
56
  [ReactPy-Django](https://github.com/reactive-python/reactpy-django) is used to add [ReactPy](https://reactpy.dev/) support to an existing **Django project**. This package also turbocharges ReactPy with features such as...
58
57
 
59
58
  - [SEO compatible rendering](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_prerender)
59
+ - [Client-Side Python components](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag/#pyscript-component)
60
60
  - [Single page application (SPA) capabilities](https://reactive-python.github.io/reactpy-django/latest/reference/router/#django-router)
61
61
  - [Distributed computing](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_default_hosts)
62
62
  - [Performance enhancements](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#performance-settings)
@@ -118,7 +118,7 @@ def hello_world(recipient: str):
118
118
 
119
119
  <!--py-code-end-->
120
120
 
121
- ## [`my_app/templates/my-template.html`](https://docs.djangoproject.com/en/dev/topics/templates/)
121
+ ## [`my_app/templates/my_template.html`](https://docs.djangoproject.com/en/stable/topics/templates/)
122
122
 
123
123
  <!--html-header-start-->
124
124
 
@@ -1,4 +1,4 @@
1
- # <img src="https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg" align="left" height="45"/> ReactPy Django
1
+ # <img src="https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/svg/reactpy-logo-square.svg" align="left" height="45"/> ReactPy-Django
2
2
 
3
3
  <p>
4
4
  <a href="https://github.com/reactive-python/reactpy-django/actions?query=workflow%3ATest">
@@ -21,6 +21,7 @@
21
21
  [ReactPy-Django](https://github.com/reactive-python/reactpy-django) is used to add [ReactPy](https://reactpy.dev/) support to an existing **Django project**. This package also turbocharges ReactPy with features such as...
22
22
 
23
23
  - [SEO compatible rendering](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_prerender)
24
+ - [Client-Side Python components](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag/#pyscript-component)
24
25
  - [Single page application (SPA) capabilities](https://reactive-python.github.io/reactpy-django/latest/reference/router/#django-router)
25
26
  - [Distributed computing](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#reactpy_default_hosts)
26
27
  - [Performance enhancements](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#performance-settings)
@@ -82,7 +83,7 @@ def hello_world(recipient: str):
82
83
 
83
84
  <!--py-code-end-->
84
85
 
85
- ## [`my_app/templates/my-template.html`](https://docs.djangoproject.com/en/dev/topics/templates/)
86
+ ## [`my_app/templates/my_template.html`](https://docs.djangoproject.com/en/stable/topics/templates/)
86
87
 
87
88
  <!--html-header-start-->
88
89
 
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["setuptools>=42", "wheel", "nodejs-bin==18.4.0a4"]
2
+ requires = ["setuptools>=42", "wheel"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [tool.mypy]
@@ -1,6 +1,3 @@
1
- [bdist_wheel]
2
- universal = 1
3
-
4
1
  [egg_info]
5
2
  tag_build =
6
3
  tag_date = 0
@@ -1,22 +1,27 @@
1
1
  from __future__ import annotations, print_function
2
2
 
3
+ import shutil
4
+ import subprocess
3
5
  import sys
4
6
  import traceback
5
- from distutils import log
7
+ from logging import getLogger
6
8
  from pathlib import Path
7
9
 
8
- from nodejs import npm
9
10
  from setuptools import find_namespace_packages, setup
10
11
  from setuptools.command.develop import develop
11
12
  from setuptools.command.sdist import sdist
12
13
 
14
+ log = getLogger(__name__)
15
+
13
16
  # -----------------------------------------------------------------------------
14
17
  # Basic Constants
15
18
  # -----------------------------------------------------------------------------
16
19
  name = "reactpy_django"
17
20
  root_dir = Path(__file__).parent
18
21
  src_dir = root_dir / "src"
22
+ js_dir = src_dir / "js"
19
23
  package_dir = src_dir / name
24
+ static_dir = package_dir / "static" / name
20
25
 
21
26
 
22
27
  # -----------------------------------------------------------------------------
@@ -94,25 +99,59 @@ package["long_description_content_type"] = "text/markdown"
94
99
  # ----------------------------------------------------------------------------
95
100
  # Build Javascript
96
101
  # ----------------------------------------------------------------------------
102
+ def copy_js_files(source_dir: Path, destination: Path) -> None:
103
+ if destination.exists():
104
+ shutil.rmtree(destination)
105
+ destination.mkdir()
106
+
107
+ for file in source_dir.iterdir():
108
+ if file.is_file():
109
+ shutil.copy(file, destination / file.name)
110
+ else:
111
+ copy_js_files(file, destination / file.name)
112
+
113
+
97
114
  def build_javascript_first(build_cls: type):
98
115
  class Command(build_cls):
99
116
  def run(self):
100
- js_dir = str(src_dir / "js")
101
117
 
102
118
  log.info("Installing Javascript...")
103
- result = npm.call(["install"], cwd=js_dir)
119
+ result = subprocess.run(
120
+ ["bun", "install"], cwd=str(js_dir), check=True
121
+ ).returncode
104
122
  if result != 0:
105
123
  log.error(traceback.format_exc())
106
124
  log.error("Failed to install Javascript")
107
125
  raise RuntimeError("Failed to install Javascript")
108
126
 
109
127
  log.info("Building Javascript...")
110
- result = npm.call(["run", "build"], cwd=js_dir)
128
+ result = subprocess.run(
129
+ [
130
+ "bun",
131
+ "build",
132
+ "./src/index.tsx",
133
+ "--outfile",
134
+ str(static_dir / "client.js"),
135
+ "--minify",
136
+ ],
137
+ cwd=str(js_dir),
138
+ check=True,
139
+ ).returncode
111
140
  if result != 0:
112
141
  log.error(traceback.format_exc())
113
142
  log.error("Failed to build Javascript")
114
143
  raise RuntimeError("Failed to build Javascript")
115
144
 
145
+ log.info("Copying @pyscript/core distribution")
146
+ pyscript_dist = js_dir / "node_modules" / "@pyscript" / "core" / "dist"
147
+ pyscript_static_dir = static_dir / "pyscript"
148
+ copy_js_files(pyscript_dist, pyscript_static_dir)
149
+
150
+ log.info("Copying Morphdom distribution")
151
+ morphdom_dist = js_dir / "node_modules" / "morphdom" / "dist"
152
+ morphdom_static_dir = static_dir / "morphdom"
153
+ copy_js_files(morphdom_dist, morphdom_static_dir)
154
+
116
155
  log.info("Successfully built Javascript")
117
156
  super().run()
118
157
 
@@ -2,22 +2,26 @@ import contextlib
2
2
 
3
3
  import nest_asyncio
4
4
 
5
- from reactpy_django import checks, components, decorators, hooks, router, types, utils
6
- from reactpy_django.websocket.paths import (
7
- REACTPY_WEBSOCKET_PATH,
8
- REACTPY_WEBSOCKET_ROUTE,
5
+ from reactpy_django import (
6
+ components,
7
+ decorators,
8
+ hooks,
9
+ html,
10
+ router,
11
+ types,
12
+ utils,
9
13
  )
14
+ from reactpy_django.websocket.paths import REACTPY_WEBSOCKET_ROUTE
10
15
 
11
- __version__ = "3.8.1"
16
+ __version__ = "5.0.0"
12
17
  __all__ = [
13
- "REACTPY_WEBSOCKET_PATH",
14
18
  "REACTPY_WEBSOCKET_ROUTE",
19
+ "html",
15
20
  "hooks",
16
21
  "components",
17
22
  "decorators",
18
23
  "types",
19
24
  "utils",
20
- "checks",
21
25
  "router",
22
26
  ]
23
27
 
@@ -19,7 +19,7 @@ def reactpy_warnings(app_configs, **kwargs):
19
19
  warnings = []
20
20
  INSTALLED_APPS: list[str] = getattr(settings, "INSTALLED_APPS", [])
21
21
 
22
- # REACTPY_DATABASE is not an in-memory database.
22
+ # Check if REACTPY_DATABASE is not an in-memory database.
23
23
  if (
24
24
  getattr(settings, "DATABASES", {})
25
25
  .get(getattr(settings, "REACTPY_DATABASE", "default"), {})
@@ -36,7 +36,7 @@ def reactpy_warnings(app_configs, **kwargs):
36
36
  )
37
37
  )
38
38
 
39
- # ReactPy URLs exist
39
+ # Check if ReactPy URLs are reachable
40
40
  try:
41
41
  reverse("reactpy:web_modules", kwargs={"file": "example"})
42
42
  reverse("reactpy:view_to_iframe", kwargs={"dotted_path": "example"})
@@ -102,16 +102,7 @@ def reactpy_warnings(app_configs, **kwargs):
102
102
 
103
103
  # DELETED W007: Check if REACTPY_WEBSOCKET_URL doesn't end with a slash
104
104
  # DELETED W008: Check if REACTPY_WEBSOCKET_URL doesn't start with an alphanumeric character
105
-
106
- # Removed REACTPY_WEBSOCKET_URL setting
107
- if getattr(settings, "REACTPY_WEBSOCKET_URL", None):
108
- warnings.append(
109
- Warning(
110
- "REACTPY_WEBSOCKET_URL has been removed.",
111
- hint="Use REACTPY_URL_PREFIX instead.",
112
- id="reactpy_django.W009",
113
- )
114
- )
105
+ # DELETED W009: Check if deprecated value REACTPY_WEBSOCKET_URL exists
115
106
 
116
107
  # Check if REACTPY_URL_PREFIX is being used properly in our HTTP URLs
117
108
  with contextlib.suppress(NoReverseMatch):
@@ -152,22 +143,16 @@ def reactpy_warnings(app_configs, **kwargs):
152
143
  ):
153
144
  warnings.append(
154
145
  Warning(
155
- "You have not configured runserver to use ASGI.",
146
+ "You have not configured the `runserver` command to use ASGI. "
147
+ "ReactPy will work properly in this configuration.",
156
148
  hint="Add daphne to settings.py:INSTALLED_APPS.",
157
149
  id="reactpy_django.W012",
158
150
  )
159
151
  )
160
152
 
161
- # Removed REACTPY_RECONNECT_MAX setting
162
- if getattr(settings, "REACTPY_RECONNECT_MAX", None):
163
- warnings.append(
164
- Warning(
165
- "REACTPY_RECONNECT_MAX has been removed.",
166
- hint="See the docs for the new REACTPY_RECONNECT_* settings.",
167
- id="reactpy_django.W013",
168
- )
169
- )
153
+ # DELETED W013: Check if deprecated value REACTPY_RECONNECT_MAX exists
170
154
 
155
+ # Check if REACTPY_RECONNECT_INTERVAL is set to a large value
171
156
  if (
172
157
  isinstance(config.REACTPY_RECONNECT_INTERVAL, int)
173
158
  and config.REACTPY_RECONNECT_INTERVAL > 30000
@@ -181,20 +166,22 @@ def reactpy_warnings(app_configs, **kwargs):
181
166
  )
182
167
  )
183
168
 
169
+ # Check if REACTPY_RECONNECT_MAX_RETRIES is set to a large value
184
170
  if (
185
171
  isinstance(config.REACTPY_RECONNECT_MAX_RETRIES, int)
186
172
  and config.REACTPY_RECONNECT_MAX_RETRIES > 5000
187
173
  ):
188
174
  warnings.append(
189
175
  Warning(
190
- "REACTPY_RECONNECT_MAX_RETRIES is set to a very large value. Are you sure this is intentional? "
176
+ "REACTPY_RECONNECT_MAX_RETRIES is set to a very large value "
177
+ f"{config.REACTPY_RECONNECT_MAX_RETRIES}. Are you sure this is intentional? "
191
178
  "This may leave your clients attempting reconnections for a long time.",
192
179
  hint="Check your value for REACTPY_RECONNECT_MAX_RETRIES or suppress this warning.",
193
180
  id="reactpy_django.W015",
194
181
  )
195
182
  )
196
183
 
197
- # Check if the value is too large (greater than 50)
184
+ # Check if the REACTPY_RECONNECT_BACKOFF_MULTIPLIER is set to a large value
198
185
  if (
199
186
  isinstance(config.REACTPY_RECONNECT_BACKOFF_MULTIPLIER, (int, float))
200
187
  and config.REACTPY_RECONNECT_BACKOFF_MULTIPLIER > 100
@@ -207,6 +194,7 @@ def reactpy_warnings(app_configs, **kwargs):
207
194
  )
208
195
  )
209
196
 
197
+ # Check if REACTPY_RECONNECT_MAX_INTERVAL is reachable
210
198
  if (
211
199
  isinstance(config.REACTPY_RECONNECT_MAX_INTERVAL, int)
212
200
  and isinstance(config.REACTPY_RECONNECT_INTERVAL, int)
@@ -239,6 +227,7 @@ def reactpy_warnings(app_configs, **kwargs):
239
227
  )
240
228
  )
241
229
 
230
+ # Check if 'reactpy_django' is in the correct position in INSTALLED_APPS
242
231
  position_to_beat = 0
243
232
  for app in INSTALLED_APPS:
244
233
  if app.startswith("django.contrib."):
@@ -255,6 +244,7 @@ def reactpy_warnings(app_configs, **kwargs):
255
244
  )
256
245
  )
257
246
 
247
+ # Check if REACTPY_CLEAN_SESSION is not a valid property
258
248
  if getattr(settings, "REACTPY_CLEAN_SESSION", None):
259
249
  warnings.append(
260
250
  Warning(
@@ -301,7 +291,7 @@ def reactpy_errors(app_configs, **kwargs):
301
291
  )
302
292
  )
303
293
 
304
- # All settings in reactpy_django.conf are the correct data type
294
+ # Check if REACTPY_URL_PREFIX is a valid data type
305
295
  if not isinstance(getattr(settings, "REACTPY_URL_PREFIX", ""), str):
306
296
  errors.append(
307
297
  Error(
@@ -311,6 +301,8 @@ def reactpy_errors(app_configs, **kwargs):
311
301
  id="reactpy_django.E003",
312
302
  )
313
303
  )
304
+
305
+ # Check if REACTPY_SESSION_MAX_AGE is a valid data type
314
306
  if not isinstance(getattr(settings, "REACTPY_SESSION_MAX_AGE", 0), int):
315
307
  errors.append(
316
308
  Error(
@@ -320,6 +312,8 @@ def reactpy_errors(app_configs, **kwargs):
320
312
  id="reactpy_django.E004",
321
313
  )
322
314
  )
315
+
316
+ # Check if REACTPY_CACHE is a valid data type
323
317
  if not isinstance(getattr(settings, "REACTPY_CACHE", ""), str):
324
318
  errors.append(
325
319
  Error(
@@ -329,6 +323,8 @@ def reactpy_errors(app_configs, **kwargs):
329
323
  id="reactpy_django.E005",
330
324
  )
331
325
  )
326
+
327
+ # Check if REACTPY_DATABASE is a valid data type
332
328
  if not isinstance(getattr(settings, "REACTPY_DATABASE", ""), str):
333
329
  errors.append(
334
330
  Error(
@@ -338,6 +334,8 @@ def reactpy_errors(app_configs, **kwargs):
338
334
  id="reactpy_django.E006",
339
335
  )
340
336
  )
337
+
338
+ # Check if REACTPY_DEFAULT_QUERY_POSTPROCESSOR is a valid data type
341
339
  if not isinstance(
342
340
  getattr(settings, "REACTPY_DEFAULT_QUERY_POSTPROCESSOR", ""), (str, type(None))
343
341
  ):
@@ -349,6 +347,8 @@ def reactpy_errors(app_configs, **kwargs):
349
347
  id="reactpy_django.E007",
350
348
  )
351
349
  )
350
+
351
+ # Check if REACTPY_AUTH_BACKEND is a valid data type
352
352
  if not isinstance(getattr(settings, "REACTPY_AUTH_BACKEND", ""), str):
353
353
  errors.append(
354
354
  Error(
@@ -361,6 +361,7 @@ def reactpy_errors(app_configs, **kwargs):
361
361
 
362
362
  # DELETED E009: Check if `channels` is in INSTALLED_APPS
363
363
 
364
+ # Check if REACTPY_DEFAULT_HOSTS is a valid data type
364
365
  if not isinstance(getattr(settings, "REACTPY_DEFAULT_HOSTS", []), list):
365
366
  errors.append(
366
367
  Error(
@@ -371,7 +372,7 @@ def reactpy_errors(app_configs, **kwargs):
371
372
  )
372
373
  )
373
374
 
374
- # Check of all values in the list are strings
375
+ # Check of all values in the REACTPY_DEFAULT_HOSTS are strings
375
376
  if isinstance(getattr(settings, "REACTPY_DEFAULT_HOSTS", None), list):
376
377
  for host in settings.REACTPY_DEFAULT_HOSTS:
377
378
  if not isinstance(host, str):
@@ -385,6 +386,7 @@ def reactpy_errors(app_configs, **kwargs):
385
386
  )
386
387
  break
387
388
 
389
+ # Check if REACTPY_RECONNECT_INTERVAL is a valid data type
388
390
  if not isinstance(config.REACTPY_RECONNECT_INTERVAL, int):
389
391
  errors.append(
390
392
  Error(
@@ -394,6 +396,7 @@ def reactpy_errors(app_configs, **kwargs):
394
396
  )
395
397
  )
396
398
 
399
+ # Check if REACTPY_RECONNECT_INTERVAL is a positive integer
397
400
  if (
398
401
  isinstance(config.REACTPY_RECONNECT_INTERVAL, int)
399
402
  and config.REACTPY_RECONNECT_INTERVAL < 0
@@ -406,6 +409,7 @@ def reactpy_errors(app_configs, **kwargs):
406
409
  )
407
410
  )
408
411
 
412
+ # Check if REACTPY_RECONNECT_MAX_INTERVAL is a valid data type
409
413
  if not isinstance(config.REACTPY_RECONNECT_MAX_INTERVAL, int):
410
414
  errors.append(
411
415
  Error(
@@ -415,6 +419,7 @@ def reactpy_errors(app_configs, **kwargs):
415
419
  )
416
420
  )
417
421
 
422
+ # Check if REACTPY_RECONNECT_MAX_INTERVAL is a positive integer
418
423
  if (
419
424
  isinstance(config.REACTPY_RECONNECT_MAX_INTERVAL, int)
420
425
  and config.REACTPY_RECONNECT_MAX_INTERVAL < 0
@@ -427,6 +432,7 @@ def reactpy_errors(app_configs, **kwargs):
427
432
  )
428
433
  )
429
434
 
435
+ # Check if REACTPY_RECONNECT_MAX_INTERVAL is greater than REACTPY_RECONNECT_INTERVAL
430
436
  if (
431
437
  isinstance(config.REACTPY_RECONNECT_MAX_INTERVAL, int)
432
438
  and isinstance(config.REACTPY_RECONNECT_INTERVAL, int)
@@ -440,6 +446,7 @@ def reactpy_errors(app_configs, **kwargs):
440
446
  )
441
447
  )
442
448
 
449
+ # Check if REACTPY_RECONNECT_MAX_RETRIES is a valid data type
443
450
  if not isinstance(config.REACTPY_RECONNECT_MAX_RETRIES, int):
444
451
  errors.append(
445
452
  Error(
@@ -449,6 +456,7 @@ def reactpy_errors(app_configs, **kwargs):
449
456
  )
450
457
  )
451
458
 
459
+ # Check if REACTPY_RECONNECT_MAX_RETRIES is a positive integer
452
460
  if (
453
461
  isinstance(config.REACTPY_RECONNECT_MAX_RETRIES, int)
454
462
  and config.REACTPY_RECONNECT_MAX_RETRIES < 0
@@ -461,6 +469,7 @@ def reactpy_errors(app_configs, **kwargs):
461
469
  )
462
470
  )
463
471
 
472
+ # Check if REACTPY_RECONNECT_BACKOFF_MULTIPLIER is a valid data type
464
473
  if not isinstance(config.REACTPY_RECONNECT_BACKOFF_MULTIPLIER, (int, float)):
465
474
  errors.append(
466
475
  Error(
@@ -470,6 +479,7 @@ def reactpy_errors(app_configs, **kwargs):
470
479
  )
471
480
  )
472
481
 
482
+ # Check if REACTPY_RECONNECT_BACKOFF_MULTIPLIER is greater than or equal to 1
473
483
  if (
474
484
  isinstance(config.REACTPY_RECONNECT_BACKOFF_MULTIPLIER, (int, float))
475
485
  and config.REACTPY_RECONNECT_BACKOFF_MULTIPLIER < 1
@@ -482,6 +492,7 @@ def reactpy_errors(app_configs, **kwargs):
482
492
  )
483
493
  )
484
494
 
495
+ # Check if REACTPY_PRERENDER is a valid data type
485
496
  if not isinstance(config.REACTPY_PRERENDER, bool):
486
497
  errors.append(
487
498
  Error(
@@ -491,6 +502,7 @@ def reactpy_errors(app_configs, **kwargs):
491
502
  )
492
503
  )
493
504
 
505
+ # Check if REACTPY_AUTO_RELOGIN is a valid data type
494
506
  if not isinstance(config.REACTPY_AUTO_RELOGIN, bool):
495
507
  errors.append(
496
508
  Error(
@@ -500,6 +512,7 @@ def reactpy_errors(app_configs, **kwargs):
500
512
  )
501
513
  )
502
514
 
515
+ # Check if REACTPY_CLEAN_INTERVAL is a valid data type
503
516
  if not isinstance(config.REACTPY_CLEAN_INTERVAL, (int, type(None))):
504
517
  errors.append(
505
518
  Error(
@@ -509,6 +522,7 @@ def reactpy_errors(app_configs, **kwargs):
509
522
  )
510
523
  )
511
524
 
525
+ # Check if REACTPY_CLEAN_INTERVAL is a positive integer
512
526
  if (
513
527
  isinstance(config.REACTPY_CLEAN_INTERVAL, int)
514
528
  and config.REACTPY_CLEAN_INTERVAL < 0
@@ -521,6 +535,7 @@ def reactpy_errors(app_configs, **kwargs):
521
535
  )
522
536
  )
523
537
 
538
+ # Check if REACTPY_CLEAN_SESSIONS is a valid data type
524
539
  if not isinstance(config.REACTPY_CLEAN_SESSIONS, bool):
525
540
  errors.append(
526
541
  Error(
@@ -530,6 +545,7 @@ def reactpy_errors(app_configs, **kwargs):
530
545
  )
531
546
  )
532
547
 
548
+ # Check if REACTPY_CLEAN_USER_DATA is a valid data type
533
549
  if not isinstance(config.REACTPY_CLEAN_USER_DATA, bool):
534
550
  errors.append(
535
551
  Error(
@@ -87,7 +87,7 @@ def clean_user_data(verbosity: int = 1):
87
87
  start_time = timezone.now()
88
88
  user_model = get_user_model()
89
89
  all_users = user_model.objects.all()
90
- all_user_pks = all_users.values_list(user_model._meta.pk.name, flat=True) # type: ignore
90
+ all_user_pks = all_users.values_list(user_model._meta.pk.name, flat=True)
91
91
 
92
92
  # Django doesn't support using QuerySets as an argument with cross-database relations.
93
93
  if user_model.objects.db != UserDataModel.objects.db: