diff --git a/examples/actor-actions/src/frontend/App.tsx b/examples/actor-actions/frontend/App.tsx similarity index 99% rename from examples/actor-actions/src/frontend/App.tsx rename to examples/actor-actions/frontend/App.tsx index 98ca216895..e189b5a064 100644 --- a/examples/actor-actions/src/frontend/App.tsx +++ b/examples/actor-actions/frontend/App.tsx @@ -4,7 +4,7 @@ import type { CompanyProfile, EmployeeProfile, registry, -} from "../backend/registry"; +} from "../src/registry"; const client = createClient("http://localhost:6420"); diff --git a/examples/actor-actions/src/frontend/index.html b/examples/actor-actions/frontend/index.css similarity index 91% rename from examples/actor-actions/src/frontend/index.html rename to examples/actor-actions/frontend/index.css index a22c6b469c..ebebd02b85 100644 --- a/examples/actor-actions/src/frontend/index.html +++ b/examples/actor-actions/frontend/index.css @@ -1,10 +1,3 @@ - - - - - - Quickstart: Actions - - - -
- - - + } \ No newline at end of file diff --git a/examples/actor-actions/src/frontend/main.tsx b/examples/actor-actions/frontend/main.tsx similarity index 92% rename from examples/actor-actions/src/frontend/main.tsx rename to examples/actor-actions/frontend/main.tsx index bd39f29eec..c5d6260976 100644 --- a/examples/actor-actions/src/frontend/main.tsx +++ b/examples/actor-actions/frontend/main.tsx @@ -1,6 +1,7 @@ import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; import { App } from "./App"; +import "./index.css"; const root = document.getElementById("root"); if (!root) throw new Error("Root element not found"); diff --git a/examples/actor-actions/package.json b/examples/actor-actions/package.json index 00ddbe6026..c734e4787b 100644 --- a/examples/actor-actions/package.json +++ b/examples/actor-actions/package.json @@ -4,27 +4,31 @@ "private": true, "type": "module", "scripts": { - "dev": "concurrently \"npm run dev:backend\" \"npm run dev:frontend\"", - "dev:backend": "tsx --watch src/backend/server.ts", - "dev:frontend": "vite", + "dev": "vite", + "build": "vite build --mode client && vite build", + "serve": "vite preview", "check-types": "tsc --noEmit", "test": "vitest run" }, "devDependencies": { + "@hono/vite-build": "^1.8.0", + "@hono/vite-dev-server": "^0.23.0", + "@rivetkit/react": "workspace:*", "@types/node": "^22.13.9", "@types/react": "^18.2.0", "@types/react-dom": "^18.2.0", "@vitejs/plugin-react": "^4.2.0", "concurrently": "^8.2.2", + "hono": "^4.11.3", + "react": "^18.2.0", + "react-dom": "^18.2.0", "tsx": "^3.12.7", "typescript": "^5.5.2", "vite": "^5.0.0", - "vitest": "^3.1.1", - "@rivetkit/react": "workspace:*", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "vitest": "^3.1.1" }, "dependencies": { + "@hono/node-server": "^1.19.7", "rivetkit": "workspace:*" }, "template": { diff --git a/examples/actor-actions/src/backend/server.ts b/examples/actor-actions/src/backend/server.ts deleted file mode 100644 index aa0ee6ed61..0000000000 --- a/examples/actor-actions/src/backend/server.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { registry } from "./registry"; - -registry.start(); diff --git a/examples/actor-actions/src/backend/registry.ts b/examples/actor-actions/src/registry.ts similarity index 100% rename from examples/actor-actions/src/backend/registry.ts rename to examples/actor-actions/src/registry.ts diff --git a/examples/actor-actions/src/server.tsx b/examples/actor-actions/src/server.tsx new file mode 100644 index 0000000000..94096f7552 --- /dev/null +++ b/examples/actor-actions/src/server.tsx @@ -0,0 +1,29 @@ +/** @jsx jsx */ +/** @jsxImportSource hono/jsx */ + +import { registry } from "./registry"; +import { Hono } from "hono"; + +const app = new Hono(); + +app.get("/", async (c) => { + return c.html( + + + {import.meta.env.PROD ? ( + + ) : ( + + )} + + +
+ + + ) +}); + +// FIXME: use registry.serve() +app.mount("/api/rivet", registry.start().fetch); + +export default app; diff --git a/examples/actor-actions/tests/actions.test.ts b/examples/actor-actions/tests/actions.test.ts index 9f80399a83..74f1b122b9 100644 --- a/examples/actor-actions/tests/actions.test.ts +++ b/examples/actor-actions/tests/actions.test.ts @@ -1,6 +1,6 @@ import { setupTest } from "rivetkit/test"; import { describe, expect, test } from "vitest"; -import { registry } from "../src/backend/registry"; +import { registry } from "../src/registry"; describe("company and employee actors", () => { test("create company actor with input and get profile", async (ctx) => { diff --git a/examples/actor-actions/vite.config.ts b/examples/actor-actions/vite.config.ts index 19155bde35..d4e185cef7 100644 --- a/examples/actor-actions/vite.config.ts +++ b/examples/actor-actions/vite.config.ts @@ -1,11 +1,40 @@ import react from "@vitejs/plugin-react"; +import build from '@hono/vite-build/node' +import devServer from '@hono/vite-dev-server' import { defineConfig } from "vite"; -export default defineConfig({ - plugins: [react()], - root: "src/frontend", - server: { - host: "0.0.0.0", - port: 5173, - }, -}); +export default defineConfig(({ mode, command }) => { + if (mode === 'client') { + return { + build: { + rollupOptions: { + input: ['./frontend/main.tsx'], + output: { + entryFileNames: 'static/main.js', + chunkFileNames: 'static/assets/[name]-[hash].js', + assetFileNames: 'static/assets/[name].[ext]', + }, + }, + emptyOutDir: false, + copyPublicDir: false, + }, + plugins: [react()], + } + } else { + return { + build: { + minify: true, + rollupOptions: { + output: { + entryFileNames: '_worker.js', + }, + }, + }, + plugins: command === "build" ? [build({entry: './src/server.tsx'})] : [ + devServer({ + entry: './src/server.tsx', + }), + ], + } + } +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a5ab7d0fe8..29398b9095 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -244,10 +244,19 @@ importers: examples/actor-actions: dependencies: + '@hono/node-server': + specifier: ^1.19.7 + version: 1.19.7(hono@4.11.3) rivetkit: specifier: workspace:* version: link:../../rivetkit-typescript/packages/rivetkit devDependencies: + '@hono/vite-build': + specifier: ^1.8.0 + version: 1.8.0(hono@4.11.3) + '@hono/vite-dev-server': + specifier: ^0.23.0 + version: 0.23.0(hono@4.11.3)(miniflare@4.20251011.0)(wrangler@4.44.0(@cloudflare/workers-types@4.20251014.0)) '@rivetkit/react': specifier: workspace:* version: link:../../rivetkit-typescript/packages/react @@ -266,6 +275,9 @@ importers: concurrently: specifier: ^8.2.2 version: 8.2.2 + hono: + specifier: ^4.11.3 + version: 4.11.3 react: specifier: ^18.2.0 version: 18.3.1 @@ -350,7 +362,7 @@ importers: version: https://pkg.pr.new/rivet-dev/cloud/@rivet-gg/cloud@715f221 '@rivetkit/engine-api-full': specifier: latest - version: 2.0.30 + version: 2.0.32 dotenv: specifier: ^17.2.2 version: 17.2.3 @@ -1979,7 +1991,7 @@ importers: version: 3.13.12(react-dom@19.1.1(react@19.1.1))(react@19.1.1) '@uiw/codemirror-extensions-basic-setup': specifier: ^4.25.1 - version: 4.25.1(@codemirror/autocomplete@6.19.0)(@codemirror/commands@6.9.0)(@codemirror/language@6.11.3)(@codemirror/lint@6.9.0)(@codemirror/search@6.5.11)(@codemirror/state@6.5.2)(@codemirror/view@6.38.2) + version: 4.25.1(@codemirror/autocomplete@6.19.0)(@codemirror/commands@6.8.1)(@codemirror/language@6.11.3)(@codemirror/lint@6.9.0)(@codemirror/search@6.5.11)(@codemirror/state@6.5.2)(@codemirror/view@6.38.2) '@uiw/codemirror-theme-github': specifier: ^4.25.1 version: 4.25.1(@codemirror/language@6.11.3)(@codemirror/state@6.5.2)(@codemirror/view@6.38.2) @@ -4871,6 +4883,12 @@ packages: peerDependencies: hono: ^4 + '@hono/node-server@1.19.7': + resolution: {integrity: sha512-vUcD0uauS7EU2caukW8z5lJKtoGMokxNbJtBiwHgpqxEXokaHCBkQUmCHhjFB1VUTWdqj25QoMkMKzgjq+uhrw==} + engines: {node: '>=18.14.1'} + peerDependencies: + hono: ^4 + '@hono/node-ws@1.2.0': resolution: {integrity: sha512-OBPQ8OSHBw29mj00wT/xGYtB6HY54j0fNSdVZ7gZM3TUeq0So11GXaWtFf1xWxQNfumKIsj0wRuLKWfVsO5GgQ==} engines: {node: '>=18.14.1'} @@ -4884,6 +4902,25 @@ packages: '@standard-schema/spec': 1.0.0 hono: '>=3.9.0' + '@hono/vite-build@1.8.0': + resolution: {integrity: sha512-T/w0Tuv8VV6FgjNnw2aW6LXtRfc5tOhaO54tKCRv4Zqc1tP3w6JyqTFtzJFFDvmY0xTxHS+Pj+ZPLhzFsdiFzQ==} + engines: {node: '>=18.14.1'} + peerDependencies: + hono: '*' + + '@hono/vite-dev-server@0.23.0': + resolution: {integrity: sha512-tHV86xToed9Up0j/dubQW2PDP4aYNFDSfQrjcV6Ra7bqCGrxhtg/zZBmbgSco3aTxKOEPzDXKK+6seAAfsbIXw==} + engines: {node: '>=18.14.1'} + peerDependencies: + hono: '*' + miniflare: '*' + wrangler: '*' + peerDependenciesMeta: + miniflare: + optional: true + wrangler: + optional: true + '@hono/zod-openapi@1.1.5': resolution: {integrity: sha512-EAnY6ad4yt/MUKHx716BEGGOXSl5d0/FOLozOYB/pmSEFq07qrzefKFtBEMAgd3hlpJXjH+4lwgTtlAo+BGBgQ==} engines: {node: '>=16.0.0'} @@ -6566,8 +6603,8 @@ packages: resolution: {integrity: sha512-LYDaHEaZdH7YPgEG20OxOgTugqJPSUbH79wwcNKGyyDmrL5lu5D86jdb4T3Na5ZvenYe3xIjIc6JudAHAqbwaA==} engines: {node: ^14.18.0 || >=16.0.0} - '@rivetkit/engine-api-full@2.0.30': - resolution: {integrity: sha512-YVoGnXv2WAsc30GnJGEDV7LZVANfHEluuPWuo7TjBjs4799q+WwkhlzA84mlqjbbCYMNy12Ep5bsuae4/sJVgA==} + '@rivetkit/engine-api-full@2.0.32': + resolution: {integrity: sha512-NjI36eqg4tF1O5LoxrHDvR/Zg5w55ML3/2DUkhP87SyRX6vbZuZ+Pbb/CysfWHt1Myft4uM5jJzeKBk8UffOOg==} '@rivetkit/fast-json-patch@3.1.2': resolution: {integrity: sha512-CtA50xgsSSzICQduF/NDShPRzvucnNvsW/lQO0WgMTT1XAj9Lfae4pm7r3llFwilgG+9iq76Hv1LUqNy72v6yw==} @@ -10284,6 +10321,10 @@ packages: hoist-non-react-statics@3.3.2: resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} + hono@4.11.3: + resolution: {integrity: sha512-PmQi306+M/ct/m5s66Hrg+adPnkD5jiO6IjA7WhWw0gSBSo1EcRegwuI1deZ+wd5pzCGynCcn2DprnE4/yEV4w==} + engines: {node: '>=16.9.0'} + hono@4.9.8: resolution: {integrity: sha512-JW8Bb4RFWD9iOKxg5PbUarBYGM99IcxFl2FPBo2gSJO11jjUDqlP1Bmfyqt8Z/dGhIQ63PMA9LdcLefXyIasyg==} engines: {node: '>=16.9.0'} @@ -16955,6 +16996,10 @@ snapshots: dependencies: hono: 4.9.8 + '@hono/node-server@1.19.7(hono@4.11.3)': + dependencies: + hono: 4.11.3 + '@hono/node-ws@1.2.0(@hono/node-server@1.19.1(hono@4.9.8))(hono@4.9.8)': dependencies: '@hono/node-server': 1.19.1(hono@4.9.8) @@ -16969,6 +17014,19 @@ snapshots: '@standard-schema/spec': 1.0.0 hono: 4.9.8 + '@hono/vite-build@1.8.0(hono@4.11.3)': + dependencies: + hono: 4.11.3 + + '@hono/vite-dev-server@0.23.0(hono@4.11.3)(miniflare@4.20251011.0)(wrangler@4.44.0(@cloudflare/workers-types@4.20251014.0))': + dependencies: + '@hono/node-server': 1.19.7(hono@4.11.3) + hono: 4.11.3 + minimatch: 9.0.5 + optionalDependencies: + miniflare: 4.20251011.0 + wrangler: 4.44.0(@cloudflare/workers-types@4.20251014.0) + '@hono/zod-openapi@1.1.5(hono@4.9.8)(zod@4.1.13)': dependencies: '@asteasolutions/zod-to-openapi': 8.2.0(zod@4.1.13) @@ -18885,7 +18943,7 @@ snapshots: dependencies: '@biomejs/cli-darwin-arm64': 2.3.10 - '@rivetkit/engine-api-full@2.0.30': + '@rivetkit/engine-api-full@2.0.32': dependencies: form-data: 4.0.5 js-base64: 3.7.8 @@ -20091,16 +20149,6 @@ snapshots: '@codemirror/state': 6.5.2 '@codemirror/view': 6.38.2 - '@uiw/codemirror-extensions-basic-setup@4.25.1(@codemirror/autocomplete@6.19.0)(@codemirror/commands@6.9.0)(@codemirror/language@6.11.3)(@codemirror/lint@6.9.0)(@codemirror/search@6.5.11)(@codemirror/state@6.5.2)(@codemirror/view@6.38.2)': - dependencies: - '@codemirror/autocomplete': 6.19.0 - '@codemirror/commands': 6.9.0 - '@codemirror/language': 6.11.3 - '@codemirror/lint': 6.9.0 - '@codemirror/search': 6.5.11 - '@codemirror/state': 6.5.2 - '@codemirror/view': 6.38.2 - '@uiw/codemirror-theme-github@4.25.1(@codemirror/language@6.11.3)(@codemirror/state@6.5.2)(@codemirror/view@6.38.2)': dependencies: '@uiw/codemirror-themes': 4.25.1(@codemirror/language@6.11.3)(@codemirror/state@6.5.2)(@codemirror/view@6.38.2) @@ -22282,7 +22330,7 @@ snapshots: eslint: 9.39.1(jiti@1.21.7) eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7)))(eslint@9.39.1(jiti@1.21.7)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7)))(eslint@9.39.1(jiti@1.21.7)))(eslint@9.39.1(jiti@1.21.7)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@1.21.7)) eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.1(jiti@1.21.7)) eslint-plugin-react: 7.37.5(eslint@9.39.1(jiti@1.21.7)) eslint-plugin-react-hooks: 7.0.1(eslint@9.39.1(jiti@1.21.7)) @@ -22315,7 +22363,7 @@ snapshots: tinyglobby: 0.2.15 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7)))(eslint@9.39.1(jiti@1.21.7)))(eslint@9.39.1(jiti@1.21.7)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@1.21.7)) transitivePeerDependencies: - supports-color @@ -22330,7 +22378,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7)))(eslint@9.39.1(jiti@1.21.7)))(eslint@9.39.1(jiti@1.21.7)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@1.21.7)): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 @@ -23499,6 +23547,8 @@ snapshots: dependencies: react-is: 16.13.1 + hono@4.11.3: {} + hono@4.9.8: {} hosted-git-info@7.0.2: