From c0be45f4e114143a1c6ae695aa41e3078a0cd4bb Mon Sep 17 00:00:00 2001 From: Nikhil Saraf Date: Sat, 2 Dec 2023 21:15:22 +0530 Subject: [PATCH] fix: server functions test --- packages/vinxi-devtools/dev.js | 2 + packages/vinxi-devtools/devtools-client.jsx | 64 +++++++++------------ packages/vinxi-devtools/devtools-dev.js | 4 +- packages/vinxi-devtools/dist/mount.js | 1 - packages/vinxi-devtools/mount.jsx | 40 ++++++------- packages/vinxi-devtools/tsconfig.json | 48 +++++++--------- packages/vinxi-server-functions/plugin.js | 2 +- test/templates/react-srv-fn/app/App.tsx | 14 +++++ test/templates/react-srv-fn/app/client.tsx | 12 +--- 9 files changed, 88 insertions(+), 99 deletions(-) create mode 100644 test/templates/react-srv-fn/app/App.tsx diff --git a/packages/vinxi-devtools/dev.js b/packages/vinxi-devtools/dev.js index 5a9012f4..ff41f338 100644 --- a/packages/vinxi-devtools/dev.js +++ b/packages/vinxi-devtools/dev.js @@ -1,6 +1,7 @@ import { createApp } from "vinxi"; import { config } from "vinxi/plugins/config"; import inspect from "vite-plugin-inspect"; +import solid from "vite-plugin-solid"; import { devtoolsClientDev } from "./devtools-dev.js"; import { devtoolsRpc } from "./index.js"; @@ -15,6 +16,7 @@ export default createApp({ target: "browser", plugins: () => [ inspect(), + solid(), config("test-spa", { build: { rollupOptions: { diff --git a/packages/vinxi-devtools/devtools-client.jsx b/packages/vinxi-devtools/devtools-client.jsx index 6b82d490..7ba7e4fd 100644 --- a/packages/vinxi-devtools/devtools-client.jsx +++ b/packages/vinxi-devtools/devtools-client.jsx @@ -1,18 +1,9 @@ -import { - Box, - Button, - Container, - Flex, - Theme, - ThemePanel, -} from "@radix-ui/themes"; import "@radix-ui/themes/styles.css"; +import { A, Route, Router, Routes } from "@solidjs/router"; import "@unocss/reset/tailwind.css"; import { cva } from "class-variance-authority"; import { clsx } from "clsx"; -import { use } from "react"; -import { createRoot } from "react-dom/client"; -import { BrowserRouter, Link, NavLink, Route, Routes } from "react-router-dom"; +import { render } from "solid-js/web"; import { twMerge } from "tailwind-merge"; import "virtual:uno.css"; @@ -97,7 +88,7 @@ const buttonVariants = cva( function Devtools() { return ( - +
{/*

@@ -107,33 +98,29 @@ function Devtools() {
- - buttonVariants({ - variant: "ghost", - size: "sm", - className: isActive ? "text-sky8" : null, - }) - } - to={`/index.html`} + - +
{plugins.map((plugin) => ( - - buttonVariants({ - variant: "ghost", - size: "sm", - className: isActive ? "text-sky8" : null, - }) - } - to={`/${plugin.id}`} + - + ))}
@@ -156,7 +143,7 @@ function Devtools() {

- +
); } @@ -199,8 +186,11 @@ function Input({ icon, ...props }) { ); } -createRoot(document.getElementById("devtools")).render( - - - , +render( + () => ( + + + + ), + document.getElementById("devtools"), ); diff --git a/packages/vinxi-devtools/devtools-dev.js b/packages/vinxi-devtools/devtools-dev.js index 5db14eca..f2621394 100644 --- a/packages/vinxi-devtools/devtools-dev.js +++ b/packages/vinxi-devtools/devtools-dev.js @@ -1,6 +1,6 @@ -import react from "@vitejs/plugin-react"; import unocss from "unocss/vite"; import { config } from "vinxi/plugins/config"; +import solid from "vite-plugin-solid"; import { fileURLToPath } from "node:url"; @@ -16,7 +16,7 @@ export const devtoolsClientDev = () => { base: "/__devtools/client", plugins: () => [ unocss(unocssConfig), - react(), + solid(), { name: "remove-vinxi-inject", config(config) { diff --git a/packages/vinxi-devtools/dist/mount.js b/packages/vinxi-devtools/dist/mount.js index 17687ff0..65285dc1 100644 --- a/packages/vinxi-devtools/dist/mount.js +++ b/packages/vinxi-devtools/dist/mount.js @@ -517,7 +517,6 @@ async function mount() { ] }) }), - "$", isOpen ? o3("div", { className: "nuxt-devtools-frame", style: { diff --git a/packages/vinxi-devtools/mount.jsx b/packages/vinxi-devtools/mount.jsx index c975c517..a50e837f 100644 --- a/packages/vinxi-devtools/mount.jsx +++ b/packages/vinxi-devtools/mount.jsx @@ -1,5 +1,5 @@ -import { Fragment, h, render } from "preact"; -import { useEffect, useRef, useState } from "preact/hooks"; +import { createEffect, createSignal } from "solid-js"; +import { render } from "solid-js/web"; import style from "./style.css?raw"; @@ -97,11 +97,10 @@ export default async function mount() { // }; function App(props) { - const [isOpen, setIsOpen] = useState(false); - const ref = useRef(); - - const [isHovering, setIsHovering] = useState(false); - useEffect(() => { + const [isOpen, setIsOpen] = createSignal(true); + let ref; + const [isHovering, setIsHovering] = createSignal(false); + createEffect(() => { // autoAnimate(ref.current, (el, action, oldCoords, newCoords) => { // console.log(action); // let keyframes; @@ -167,13 +166,13 @@ export default async function mount() { // }); // }); // autoAnimate(ref.current); - }, [ref.current]); + }); return ( <>
-
+
- $ - {isOpen ? ( + {isOpen() ? (