Browse Source

remove work that wouldn't work

Khaleel Al-Adhami 2 weeks ago
parent
commit
1ca60775ad

+ 2 - 7
pyi_hashes.json

@@ -1,13 +1,12 @@
 {
-  "reflex/__init__.pyi": "8a6d2350e96659846436792a5c7b772b",
-  "reflex/components/__init__.pyi": "76ba0a12cd3a7ba5ab6341a3ae81551f",
+  "reflex/__init__.pyi": "aea60b818ef7b189131b6403b02fc6ba",
+  "reflex/components/__init__.pyi": "21cd150be121d97c1e1a6ad0062f086d",
   "reflex/components/base/__init__.pyi": "d0139bd2c41c28d837b91fa8949e2494",
   "reflex/components/base/app_wrap.pyi": "387fc7a0c2da8760d9449e2893e44eec",
   "reflex/components/base/body.pyi": "2d16002f24c8ee0007b46ff2bf1f2c78",
   "reflex/components/base/document.pyi": "851cb54842f3df1e5f44ba1fb72e12af",
   "reflex/components/base/error_boundary.pyi": "c56b591d14a92b99a1e97e04afe167d7",
   "reflex/components/base/fragment.pyi": "603ee8e03af88d4a8ff6bc1fbce4e022",
-  "reflex/components/base/head.pyi": "893047aa32da553711db8f1345adb6b0",
   "reflex/components/base/link.pyi": "e96179dc7823f354fb73a6c03e31028c",
   "reflex/components/base/meta.pyi": "da52c3212fac6b50560863146a7afcc3",
   "reflex/components/base/script.pyi": "352ec2e82b06f2fa5b3015f7b8dd295e",
@@ -43,10 +42,6 @@
   "reflex/components/lucide/icon.pyi": "508c8844959925555a895df8dcac3751",
   "reflex/components/markdown/markdown.pyi": "1fc31d2652d3ff015c6da2c7cbab716a",
   "reflex/components/moment/moment.pyi": "6dd0c7cee5f0f29bc11d830c697d7f92",
-  "reflex/components/next/base.pyi": "14aafd5b018a4bc9748a3c9980fcfe3e",
-  "reflex/components/next/image.pyi": "3a0d1970e69144e9c6806e68ab99f181",
-  "reflex/components/next/link.pyi": "cd913e10205314afe67101d9640e05cb",
-  "reflex/components/next/video.pyi": "aa8f814dec99f8712dc2351b15f922ac",
   "reflex/components/plotly/plotly.pyi": "b1f0bbcaf4706d0a373c99395ba50118",
   "reflex/components/radix/__init__.pyi": "8d586cbff1d7130d09476ac72ee73400",
   "reflex/components/radix/primitives/__init__.pyi": "fe8715decf3e9ae471b56bba14e42cb3",

+ 3 - 11
reflex/.templates/jinja/web/utils/context.js.jinja2

@@ -123,17 +123,9 @@ export function StateProvider({ children }) {
 
   return (
     {% for state_name in initial_state %}
-    createElement(
-      StateContexts.{{state_name|var_name}},
-      { value: {{state_name|var_name}} },
-    {% endfor %}
-    createElement(
-      DispatchContext,
-      { value: dispatchers },
-      children
-    )
-    {% for state_name in initial_state|reverse %}
-    )
+    createElement(StateContexts.{{state_name|var_name}},{value: {{state_name|var_name}}},
     {% endfor %}
+    createElement(DispatchContext, {value: dispatchers}, children)
+    {% for state_name in initial_state %}){% endfor %}
   )
 }

+ 1 - 1
reflex/__init__.py

@@ -284,7 +284,7 @@ _MAPPING: dict = {
         "EditorButtonList",
         "EditorOptions",
     ],
-    "components": ["el", "radix", "lucide", "recharts", "next"],
+    "components": ["el", "radix", "lucide", "recharts"],
     "components.markdown": ["markdown"],
     **RADIX_MAPPING,
     "components.plotly": ["plotly"],

+ 1 - 1
reflex/app.py

@@ -1019,7 +1019,7 @@ class App(MiddlewareMixin, LifespanMixin):
             for i, tags in imports.items()
             if i not in constants.PackageJson.DEPENDENCIES
             and i not in constants.PackageJson.DEV_DEPENDENCIES
-            and not any(i.startswith(prefix) for prefix in ["/", "$/", ".", "next/"])
+            and not any(i.startswith(prefix) for prefix in ["/", "$/", "."])
             and i != ""
             and any(tag.install for tag in tags)
         }

+ 1 - 1
reflex/compiler/compiler.py

@@ -842,7 +842,7 @@ def compile_unevaluated_page(
     if page.description is not None:
         meta_args["description"] = page.description
 
-    # # Add meta information to the component.
+    # Add meta information to the component.
     utils.add_meta(
         component,
         **meta_args,

+ 0 - 1
reflex/components/__init__.py

@@ -26,7 +26,6 @@ _SUBMOD_ATTRS: dict[str, list[str]] = {
         "Component",
         "NoSSRComponent",
     ],
-    "next": ["NextLink", "next_link"],
 }
 __getattr__, __dir__, __all__ = lazy_loader.attach(
     __name__,

+ 0 - 20
reflex/components/base/head.py

@@ -1,20 +0,0 @@
-"""The head component."""
-
-from reflex.components.component import Component, MemoizationLeaf
-
-
-class NextHeadLib(Component):
-    """Header components."""
-
-    library = "next/head"
-
-
-class Head(NextHeadLib, MemoizationLeaf):
-    """Head Component."""
-
-    tag = "NextHead"
-
-    is_default = True
-
-
-head = Head.create

+ 1 - 4
reflex/components/component.py

@@ -78,9 +78,6 @@ class BaseComponent(Base, ABC):
     # List here the non-react dependency needed by `library`
     lib_dependencies: list[str] = pydantic.v1.Field(default_factory=list)
 
-    # List here the dependencies that need to be transpiled by Next.js
-    transpile_packages: list[str] = pydantic.v1.Field(default_factory=list)
-
     # The tag to use when rendering the component.
     tag: str | None = pydantic.v1.Field(default_factory=lambda: None)
 
@@ -1982,7 +1979,7 @@ class NoSSRComponent(Component):
         Returns:
             The imports for dynamically importing the component at module load time.
         """
-        # Next.js dynamic import mechanism.
+        # React lazy import mechanism.
         dynamic_import = {
             "react": [ImportVar(tag="lazy")],
             f"$/{constants.Dirs.UTILS}/context": [ImportVar(tag="ClientSide")],

+ 0 - 10
reflex/components/next/__init__.py

@@ -1,10 +0,0 @@
-"""Namespace for components provided by next packages."""
-
-from .base import NextComponent
-from .image import Image
-from .link import NextLink
-from .video import Video
-
-image = Image.create
-video = Video.create
-next_link = NextLink.create

+ 0 - 9
reflex/components/next/base.py

@@ -1,9 +0,0 @@
-"""Base for NextJS components."""
-
-from reflex.components.component import Component
-
-
-class NextComponent(Component):
-    """A Component used as based for any NextJS component."""
-
-    ...

+ 0 - 117
reflex/components/next/image.py

@@ -1,117 +0,0 @@
-"""Image component from next/image."""
-
-from __future__ import annotations
-
-from typing import Any, Literal
-
-from reflex.event import EventHandler, no_args_event_spec
-from reflex.utils import console, types
-from reflex.vars.base import Var
-
-from .base import NextComponent
-
-DEFAULT_W_H = "100%"
-
-
-class Image(NextComponent):
-    """Display an image."""
-
-    tag = "Image"
-    library = "next/image"
-    is_default = True
-
-    # This can be either an absolute external URL, or an internal path
-    src: Var[Any]
-
-    # Represents the rendered width in pixels, so it will affect how large the image appears.
-    width: Var[Any]
-
-    # Represents the rendered height in pixels, so it will affect how large the image appears.
-    height: Var[Any]
-
-    # Used to describe the image for screen readers and search engines.
-    alt: Var[str]
-
-    # A custom function used to resolve image URLs.
-    loader: Var[Any]
-
-    # A boolean that causes the image to fill the parent element, which is useful when the width and height are unknown. Default to True
-    fill: Var[bool]
-
-    # A string, similar to a media query, that provides information about how wide the image will be at different breakpoints.
-    sizes: Var[str]
-
-    # The quality of the optimized image, an integer between 1 and 100, where 100 is the best quality and therefore largest file size. Defaults to 75.
-    quality: Var[int]
-
-    # When true, the image will be considered high priority and preload. Lazy loading is automatically disabled for images using priority.
-    priority: Var[bool]
-
-    # A placeholder to use while the image is loading. Possible values are blur, empty, or data:image/.... Defaults to empty.
-    placeholder: Var[str]
-
-    # Allows passing CSS styles to the underlying image element.
-    # style: Var[Any] #noqa: ERA001
-
-    # The loading behavior of the image. Defaults to lazy. Can hurt performance, recommended to use `priority` instead.
-    loading: Var[Literal["lazy", "eager"]]
-
-    # A Data URL to be used as a placeholder image before the src image successfully loads. Only takes effect when combined with placeholder="blur".
-    blur_data_url: Var[str]
-
-    # Fires when the image has loaded.
-    on_load: EventHandler[no_args_event_spec]
-
-    # Fires when the image has an error.
-    on_error: EventHandler[no_args_event_spec]
-
-    @classmethod
-    def create(
-        cls,
-        *children,
-        width: int | str | None = None,
-        height: int | str | None = None,
-        **props,
-    ):
-        """Create an Image component from next/image.
-
-        Args:
-            *children: The children of the component.
-            width: The width of the image.
-            height: The height of the image.
-            **props:The props of the component.
-
-        Returns:
-            _type_: _description_
-        """
-        if "blurDataURL" in props:
-            console.deprecate(
-                feature_name="blurDataURL",
-                reason="Use blur_data_url instead",
-                deprecation_version="0.7.0",
-                removal_version="0.8.0",
-            )
-            props["blur_data_url"] = props.pop("blurDataURL")
-
-        style = props.get("style", {})
-
-        def check_prop_type(prop_name: str, prop_value: int | str | None):
-            if types.check_prop_in_allowed_types(prop_value, allowed_types=[int]):
-                props[prop_name] = prop_value
-
-            elif types.check_prop_in_allowed_types(prop_value, allowed_types=[str]):
-                props[prop_name] = 0
-                style[prop_name] = prop_value
-            else:
-                props[prop_name] = 0
-                style[prop_name] = DEFAULT_W_H
-
-        check_prop_type("width", width)
-        check_prop_type("height", height)
-
-        props["style"] = style
-
-        # mysteriously, following `sizes` prop is needed to avoid blury images.
-        props["sizes"] = "100vw"
-
-        return super().create(*children, **props)

+ 0 - 20
reflex/components/next/link.py

@@ -1,20 +0,0 @@
-"""A link component."""
-
-from reflex.components.component import Component
-from reflex.vars.base import Var
-
-
-class NextLink(Component):
-    """Links are accessible elements used primarily for navigation. This component is styled to resemble a hyperlink and semantically renders an <a>."""
-
-    library = "next/link"
-
-    tag = "NextLink"
-
-    is_default = True
-
-    # The page to link to.
-    href: Var[str]
-
-    # Whether to pass the href prop to the child.
-    pass_href: Var[bool] = Var.create(True)

+ 0 - 38
reflex/components/next/video.py

@@ -1,38 +0,0 @@
-"""Wrapping of the next-video component."""
-
-from reflex.components.component import Component
-from reflex.utils import console
-from reflex.vars.base import Var
-
-from .base import NextComponent
-
-
-class Video(NextComponent):
-    """A video component from NextJS."""
-
-    tag = "Video"
-    library = "next-video@2.2.0"
-    is_default = True
-    # the URL
-    src: Var[str]
-
-    as_: Component | None
-
-    @classmethod
-    def create(cls, *children, **props) -> NextComponent:
-        """Create a Video component.
-
-        Args:
-            *children: The children of the component.
-            **props: The props of the component.
-
-        Returns:
-            The Video component.
-        """
-        console.deprecate(
-            "next-video",
-            "The next-video component is deprecated. Use `rx.video` instead.",
-            deprecation_version="0.7.11",
-            removal_version="0.8.0",
-        )
-        return super().create(*children, **props)

+ 1 - 1
reflex/components/radix/themes/base.py

@@ -283,7 +283,7 @@ class ThemePanel(RadixThemesComponent):
 
 
 class RadixThemesColorModeProvider(Component):
-    """Next-themes integration for radix themes components."""
+    """React-themes integration for radix themes components."""
 
     library = "$/components/reflex/radix_themes_color_mode_provider"
     tag = "RadixThemesColorModeProvider"

+ 2 - 11
reflex/config.py

@@ -630,7 +630,7 @@ class EnvironmentVariables:
     # Whether to use the system installed bun. If set to false, bun will be bundled with the app.
     REFLEX_USE_SYSTEM_BUN: EnvVar[bool] = env_var(False)
 
-    # The working directory for the next.js commands.
+    # The working directory for the frontend directory.
     REFLEX_WEB_WORKDIR: EnvVar[Path] = env_var(Path(constants.Dirs.WEB))
 
     # The working directory for the states directory.
@@ -716,9 +716,6 @@ class EnvironmentVariables:
     # The maximum size of the reflex state in kilobytes.
     REFLEX_STATE_SIZE_LIMIT: EnvVar[int] = env_var(1000)
 
-    # Whether to use the turbopack bundler.
-    REFLEX_USE_TURBOPACK: EnvVar[bool] = env_var(False)
-
     # Additional paths to include in the hot reload. Separated by a colon.
     REFLEX_HOT_RELOAD_INCLUDE_PATHS: EnvVar[list[Path]] = env_var([])
 
@@ -837,13 +834,7 @@ class Config(Base):
     # DEPRECATED. Timeout when launching the gunicorn server.
     timeout: int | None = None
 
-    # Whether to enable or disable nextJS gzip compression.
-    next_compression: bool = True
-
-    # Whether to enable or disable NextJS dev indicator.
-    next_dev_indicators: bool = False
-
-    # Whether to use React strict mode in nextJS
+    # Whether to use React strict mode.
     react_strict_mode: bool = True
 
     # Additional frontend packages to install.

+ 1 - 1
reflex/testing.py

@@ -942,7 +942,7 @@ class Subdir404TCPServer(socketserver.TCPServer):
 class AppHarnessProd(AppHarness):
     """AppHarnessProd executes a reflex app in-process for testing.
 
-    In prod mode, instead of running `next dev` the app is exported as static
+    In prod mode, instead of running `react-router dev` the app is exported as static
     files and served via the builtin python http.server with custom 404 redirect
     handling. Additionally, the backend runs in multi-worker mode.
     """

+ 1 - 21
reflex/utils/build.py

@@ -3,7 +3,6 @@
 from __future__ import annotations
 
 import os
-import subprocess
 import zipfile
 from pathlib import Path
 
@@ -188,13 +187,11 @@ def build(
 
 def setup_frontend(
     root: Path,
-    disable_telemetry: bool = True,
 ):
     """Set up the frontend to run the app.
 
     Args:
         root: The root path of the project.
-        disable_telemetry: Whether to disable the Next telemetry.
     """
     # Create the assets dir if it doesn't exist.
     path_ops.mkdir(constants.Dirs.APP_ASSETS)
@@ -210,33 +207,16 @@ def setup_frontend(
     # update the last reflex run time.
     prerequisites.set_last_reflex_run_time()
 
-    # Disable the Next telemetry.
-    if disable_telemetry:
-        processes.new_process(
-            [
-                *prerequisites.get_js_package_executor(raise_on_none=True)[0],
-                "run",
-                "next",
-                "telemetry",
-                "disable",
-            ],
-            cwd=prerequisites.get_web_dir(),
-            stdout=subprocess.DEVNULL,
-            shell=constants.IS_WINDOWS,
-        )
-
 
 def setup_frontend_prod(
     root: Path,
-    disable_telemetry: bool = True,
 ):
     """Set up the frontend for prod mode.
 
     Args:
         root: The root path of the project.
-        disable_telemetry: Whether to disable the Next telemetry.
     """
-    setup_frontend(root, disable_telemetry)
+    setup_frontend(root)
     build(deploy_url=get_config().deploy_url)
 
 

+ 0 - 4
reflex/utils/imports.py

@@ -114,10 +114,6 @@ class ImportVar:
     # The path of the package to import from.
     package_path: str = "/"
 
-    # whether this import package should be added to transpilePackages in next.config.js
-    # https://nextjs.org/docs/app/api-reference/next-config-js/transpilePackages
-    transpile: bool | None = False
-
     @property
     def name(self) -> str:
         """The name of the import.

+ 1 - 7
reflex/utils/prerequisites.py

@@ -39,7 +39,6 @@ from reflex import constants, model
 from reflex.compiler import templates
 from reflex.config import Config, environment, get_config
 from reflex.utils import console, net, path_ops, processes, redir
-from reflex.utils.decorator import once
 from reflex.utils.exceptions import (
     GeneratedCodeHasNoFunctionDefsError,
     SystemPackageMissingError,
@@ -76,7 +75,7 @@ class CpuInfo:
 
 
 def get_web_dir() -> Path:
-    """Get the working directory for the next.js commands.
+    """Get the working directory for the frontend.
 
     Can be overridden with REFLEX_WEB_WORKDIR.
 
@@ -995,11 +994,6 @@ def initialize_web_directory():
     init_reflex_json(project_hash=project_hash)
 
 
-@once
-def _turbopack_flag() -> str:
-    return " --turbopack" if environment.REFLEX_USE_TURBOPACK.get() else ""
-
-
 def _compile_package_json():
     return templates.PACKAGE_JSON.render(
         scripts={

+ 8 - 2
tests/integration/test_dynamic_routes.py

@@ -427,11 +427,17 @@ async def test_render_dynamic_arg(
     assert next_page_link
     with poll_for_navigation(driver):
         next_page_link.click()
-    assert driver.current_url.removesuffix("/") == f"{frontend_url.removesuffix('/')}/arg/1"
+    assert (
+        driver.current_url.removesuffix("/")
+        == f"{frontend_url.removesuffix('/')}/arg/1"
+    )
     assert_content("1", "0")
     next_page_link = driver.find_element(By.ID, "next-page")
     assert next_page_link
     with poll_for_navigation(driver):
         next_page_link.click()
-    assert driver.current_url.removesuffix("/") == f"{frontend_url.removesuffix('/')}/arg/2"
+    assert (
+        driver.current_url.removesuffix("/")
+        == f"{frontend_url.removesuffix('/')}/arg/2"
+    )
     assert_content("2", "1")

+ 1 - 1
tests/units/components/base/test_script.py

@@ -1,4 +1,4 @@
-"""Test that Script from next/script renders correctly."""
+"""Test that element script renders correctly."""
 
 import pytest
 

+ 1 - 30
tests/units/components/media/test_image.py

@@ -4,9 +4,7 @@ import pytest
 from PIL.Image import Image as Img
 
 import reflex as rx
-from reflex.components.next.image import Image
 from reflex.utils.serializers import serialize, serialize_image
-from reflex.vars.sequence import StringVar
 
 
 @pytest.fixture
@@ -35,31 +33,4 @@ def test_serialize_image(pil_image: Img):
 def test_set_src_str():
     """Test that setting the src works."""
     image = rx.image(src="pic2.jpeg")
-    # when using next/image, we explicitly create a _var_is_str Var
-    assert str(image.src) in (  # pyright: ignore [reportAttributeAccessIssue]
-        '"pic2.jpeg"',
-        "'pic2.jpeg'",
-        "`pic2.jpeg`",
-    )
-    # For plain rx.el.img, an explicit var is not created, so the quoting happens later
-    # assert str(image.src) == "pic2.jpeg" #noqa: ERA001
-
-
-def test_set_src_img(pil_image: Img):
-    """Test that setting the src works.
-
-    Args:
-        pil_image: The image to serialize.
-    """
-    image = Image.create(src=pil_image)
-    assert str(image.src._js_expr) == '"' + serialize_image(pil_image) + '"'  # pyright: ignore [reportAttributeAccessIssue]
-
-
-def test_render(pil_image: Img):
-    """Test that rendering an image works.
-
-    Args:
-        pil_image: The image to serialize.
-    """
-    image = Image.create(src=pil_image)
-    assert isinstance(image.src, StringVar)  # pyright: ignore [reportAttributeAccessIssue]
+    assert str(image.src) == '"pic2.jpeg"'  # pyright: ignore [reportAttributeAccessIssue]

+ 1 - 1
tests/units/utils/test_utils.py

@@ -250,7 +250,7 @@ def test_setup_frontend(tmp_path, mocker):
     mocker.patch("reflex.utils.prerequisites.install_frontend_packages")
     mocker.patch("reflex.utils.build.set_env_json")
 
-    build.setup_frontend(tmp_path, disable_telemetry=False)
+    build.setup_frontend(tmp_path)
     assert web_public_folder.exists()
     assert (web_public_folder / "favicon.ico").exists()