diff --git a/examples/CLAUDE.md b/examples/CLAUDE.md new file mode 100644 index 0000000000..39fa50ffc4 --- /dev/null +++ b/examples/CLAUDE.md @@ -0,0 +1,458 @@ +# examples/CLAUDE.md + +Guidelines for creating and maintaining examples in this repository. + +## README Format + +All example READMEs must follow the template defined in `.claude/resources/EXAMPLE_TEMPLATE.md`. Key requirements: +- Use exact section headings: `## Getting Started`, `## Features`, `## Implementation`, `## Resources`, `## License` +- Include `## Prerequisites` only for non-obvious dependencies (API keys, external services) +- Focus features on RivetKit concepts demonstrated, not just app functionality +- Include GitHub source code links in Implementation section + +## Project Structure + +### Directory Layout + +Examples with frontend (using vite-plugin-srvx): +``` +example-name/ +├── src/ +│ ├── actors.ts # Actor definitions and registry setup +│ └── server.ts # Server entry point +├── frontend/ +│ ├── App.tsx # Main React component +│ └── main.tsx # React entry point +├── tests/ +│ └── *.test.ts # Vitest tests +├── index.html # HTML entry point (for Vite) +├── package.json +├── tsconfig.json +├── vite.config.ts +├── vitest.config.ts # Only if tests exist +├── turbo.json +└── README.md +``` + +Examples with separate frontend/backend dev servers: +``` +example-name/ +├── src/ +│ ├── actors.ts # Actor definitions and registry setup +│ └── server.ts # Server entry point +├── frontend/ +│ ├── App.tsx +│ └── main.tsx +├── package.json +├── tsconfig.json +├── tsup.config.ts # For backend bundling +├── vite.config.ts +├── vitest.config.ts # Only if tests exist +├── turbo.json +└── README.md +``` + +Backend-only examples: +``` +example-name/ +├── src/ +│ ├── actors.ts # Actor definitions and registry setup +│ └── server.ts # Server entry point +├── package.json +├── tsconfig.json +├── turbo.json +└── README.md +``` + +### Naming Conventions + +- Actor definitions go in `src/actors.ts` +- Server entry point is always `src/server.ts` +- Frontend entry is `frontend/main.tsx` with main component in `frontend/App.tsx` +- Test files use `.test.ts` extension in `tests/` directory + +## package.json + +### Required Scripts + +For examples with frontend (using vite-plugin-srvx): +```json +{ + "scripts": { + "dev": "vite", + "check-types": "tsc --noEmit", + "test": "vitest run", + "build": "vite build && vite build --mode server", + "start": "srvx --static=public/ dist/server.js" + } +} +``` + +For examples with separate frontend/backend dev servers: +```json +{ + "scripts": { + "dev:backend": "srvx --import tsx src/server.ts", + "dev:frontend": "vite", + "dev": "concurrently \"npm run dev:backend\" \"npm run dev:frontend\"", + "check-types": "tsc --noEmit", + "test": "vitest run", + "build:frontend": "vite build", + "build:backend": "tsup", + "build": "npm run build:backend && npm run build:frontend", + "start": "srvx --static=../frontend/dist dist/server.js" + } +} +``` + +For backend-only examples: +```json +{ + "scripts": { + "dev": "npx srvx --import tsx src/server.ts", + "start": "npx srvx --import tsx src/server.ts", + "check-types": "tsc --noEmit", + "build": "tsup" + } +} +``` + +### Required Fields + +```json +{ + "name": "example-name", + "version": "2.0.21", + "private": true, + "type": "module", + "stableVersion": "0.8.0", + "template": { + "technologies": ["react", "typescript"], + "tags": ["real-time"], + "frontendPort": 5173, + "noFrontend": true // Only for backend-only examples + }, + "license": "MIT" +} +``` + +### Dependencies + +- Use `"rivetkit": "*"` for the main RivetKit package +- Use `"@rivetkit/react": "*"` for React integration +- Common dev dependencies: + - `tsx` for running TypeScript in development + - `typescript` for type checking + - `vite` and `@vitejs/plugin-react` for frontend + - `vite-plugin-srvx` for unified dev server (when using vite-plugin-srvx pattern) + - `vitest` for testing + - `tsup` for bundling (only for separate frontend/backend examples) + - `concurrently` for parallel dev servers (only for separate frontend/backend examples) +- Common production dependencies: + - `hono` for the server framework (required for Vercel detection) + - `srvx` for serving in production (used by `start` script) + - `@hono/node-server` for Node.js HTTP server adapter + - `@hono/node-ws` for Node.js WebSocket support + +## Configuration Files + +### tsconfig.json + +```json +{ + "compilerOptions": { + "target": "esnext", + "lib": ["esnext", "dom"], + "jsx": "react-jsx", + "module": "esnext", + "moduleResolution": "bundler", + "types": ["node", "vite/client"], + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "allowImportingTsExtensions": true, + "rewriteRelativeImportExtensions": true + }, + "include": ["src/**/*", "frontend/**/*", "tests/**/*"] +} +``` + +Notes: +- Include `"dom"` in lib for frontend examples +- Include `"vite/client"` in types when using Vite +- Omit `"frontend/**/*"` and `"tests/**/*"` from include if they don't exist +- `allowImportingTsExtensions` and `rewriteRelativeImportExtensions` enable ESM-compliant `.ts` imports + +### tsup.config.ts + +Only needed for examples with separate frontend/backend dev servers (not using vite-plugin-srvx): + +```typescript +import { defineConfig } from "tsup"; + +export default defineConfig({ + entry: { + server: "src/server.ts", + }, + format: ["esm"], + outDir: "dist", + bundle: true, + splitting: false, + shims: true, +}); +``` + +### vite.config.ts + +For examples using vite-plugin-srvx (unified dev): +```typescript +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import srvx from "vite-plugin-srvx"; + +export default defineConfig({ + plugins: [react(), ...srvx({ entry: "src/server.ts" })], +}); +``` + +For examples with separate dev servers: +```typescript +import react from "@vitejs/plugin-react"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [react()], + root: "frontend", + build: { + outDir: "dist", + emptyOutDir: true, + }, + server: { + host: "0.0.0.0", + port: 5173, + proxy: { + "/api/rivet/": "http://localhost:3000", + }, + }, +}); +``` + +### vitest.config.ts + +```typescript +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + server: { + port: 5173, + }, + test: { + include: ["tests/**/*.test.ts"], + }, +}); +``` + +### vercel.json + +Vercel auto-detects Vite when it sees a `vite.config.ts` and ignores Hono. We must explicitly set the framework to Hono: + +```json +{ + "framework": "hono" +} +``` + +### turbo.json + +All examples should extend the root turbo config: +```json +{ + "$schema": "https://turbo.build/schema.json", + "extends": ["//"] +} +``` + +### .gitignore + +``` +.actorcore +node_modules +``` + +## Source Code Patterns + +### Actor Definitions (src/actors.ts) + +```typescript +import { actor, setup } from "rivetkit"; + +// Export types for client usage +export type Message = { sender: string; text: string; timestamp: number }; + +export const chatRoom = actor({ + // Persistent state + state: { + messages: [] as Message[], + }, + + actions: { + sendMessage: (c, sender: string, text: string) => { + const message = { sender, text, timestamp: Date.now() }; + c.state.messages.push(message); + c.broadcast("newMessage", message); + return message; + }, + getHistory: (c) => c.state.messages, + }, +}); + +// Registry setup - always export as `registry` +export const registry = setup({ + use: { chatRoom }, +}); +``` + +### Server Entry Point (src/server.ts) + +You must explicitly import from `"hono"` for Vercel to detect the framework. + +Minimum required: + +```typescript +import { Hono } from "hono"; +import { registry } from "./actors.ts"; + +const app = new Hono(); +app.all("/api/rivet/*", (c) => registry.handler(c.req.raw)); +export default app; +``` + +With additional routes: + +```typescript +import { Hono } from "hono"; +import { registry } from "./actors.ts"; + +const app = new Hono(); + +app.get("/api/foo", (c) => c.text("bar")); + +app.all("/api/rivet/*", (c) => registry.handler(c.req.raw)); + +export default app; +``` + +### React Frontend (frontend/App.tsx) + +```typescript +import { createRivetKit } from "@rivetkit/react"; +import type { registry } from "../src/actors.ts"; + +const { useActor } = createRivetKit(`${location.origin}/api/rivet`); + +export function App() { + const actor = useActor({ + name: "actorName", + key: ["key"], + }); + + // Use actor.connection for actions + // Use actor.useEvent for event subscriptions +} +``` + +### React Entry Point (frontend/main.tsx) + +```typescript +import { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; +import { App } from "./App.tsx"; + +const root = document.getElementById("root"); +if (!root) throw new Error("Root element not found"); + +createRoot(root).render( + + + +); +``` + +### Tests (tests/*.test.ts) + +```typescript +import { setupTest } from "rivetkit/test"; +import { expect, test } from "vitest"; +import { registry } from "../src/actors.ts"; + +test("Description of test", async (ctx) => { + const { client } = await setupTest(ctx, registry); + const actor = client.actorName.getOrCreate(["key"]); + + // Test actor actions + const result = await actor.someAction(); + expect(result).toEqual(expected); +}); +``` + +## HTML Entry Point + +For Vite-based examples: +```html + + + + + + Example Title + + + +
+ + + +``` + +## ESM Import Requirements + +All imports must be ESM-compliant with explicit `.ts` extensions for relative imports: + +```typescript +// Correct +import { registry } from "./actors.ts"; +import { someUtil } from "../utils/helper.ts"; + +// Incorrect +import { registry } from "./actors"; +import { someUtil } from "../utils/helper"; +``` + +This is enforced by the tsconfig options `allowImportingTsExtensions` and `rewriteRelativeImportExtensions`. + +## Best Practices + +1. **Keep examples minimal** - Focus on demonstrating specific RivetKit concepts +2. **Type safety** - Export types from actors for client usage, use `typeof registry` for type-safe clients +3. **Consistent naming** - Use `registry` for the setup export, match actor names to their purpose +4. **Real-time patterns** - Demonstrate `broadcast()` for events and `useEvent()` for subscriptions +5. **State management** - Show persistent state with clear before/after behavior +6. **Testing** - Use `setupTest()` from `rivetkit/test` for isolated actor testing +7. **Comments** - Include helpful comments linking to documentation (e.g., `// https://rivet.dev/docs/actors/state`) + +## TODO: Examples Cleanup + +The following issues need to be fixed across examples: + +- [ ] Rename `src/registry.ts` to `src/actors.ts` in all examples +- [ ] Update all relative imports to use `.ts` extensions (ESM compliance) +- [ ] Add `allowImportingTsExtensions` and `rewriteRelativeImportExtensions` to tsconfig.json +- [ ] Remove unused `tsup.config.ts` from examples using vite-plugin-srvx +- [ ] Remove unused `tsup` devDependency from examples using vite-plugin-srvx +- [ ] Move `srvx` from devDependencies to dependencies (used by `start` script) +- [ ] Move `@hono/node-server` and `@hono/node-ws` from devDependencies to dependencies +- [ ] Remove unused `concurrently` devDependency from examples using vite-plugin-srvx +- [ ] Remove `scripts/` directories with CLI client scripts +- [ ] Remove `prompts` and `@types/prompts` devDependencies diff --git a/examples/chat-room/frontend/App.tsx b/examples/chat-room/frontend/App.tsx index 2e2f2d3c6e..e8971e199e 100644 --- a/examples/chat-room/frontend/App.tsx +++ b/examples/chat-room/frontend/App.tsx @@ -1,8 +1,8 @@ import { createRivetKit } from "@rivetkit/react"; import { useEffect, useState } from "react"; -import type { Message, registry } from "../src/actors"; +import type { Message, registry } from "../src/actors.ts"; -const { useActor } = createRivetKit("http://localhost:5173/api/rivet"); +const { useActor } = createRivetKit(`${location.origin}/api/rivet`); export function App() { const [roomId, setRoomId] = useState("general"); diff --git a/examples/chat-room/frontend/main.tsx b/examples/chat-room/frontend/main.tsx index bd39f29eec..372f49c622 100644 --- a/examples/chat-room/frontend/main.tsx +++ b/examples/chat-room/frontend/main.tsx @@ -1,6 +1,6 @@ import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; -import { App } from "./App"; +import { App } from "./App.tsx"; const root = document.getElementById("root"); if (!root) throw new Error("Root element not found"); diff --git a/examples/chat-room/frontend/index.html b/examples/chat-room/index.html similarity index 97% rename from examples/chat-room/frontend/index.html rename to examples/chat-room/index.html index 91526270f9..5a22647a06 100644 --- a/examples/chat-room/frontend/index.html +++ b/examples/chat-room/index.html @@ -108,6 +108,6 @@
- + - \ No newline at end of file + diff --git a/examples/chat-room/package.json b/examples/chat-room/package.json index aa42aae2f1..693bc33f8a 100644 --- a/examples/chat-room/package.json +++ b/examples/chat-room/package.json @@ -4,40 +4,33 @@ "private": true, "type": "module", "scripts": { - "dev:backend": "srvx --import tsx src/server.ts", - "dev:frontend": "vite", - "dev": "concurrently \"npm run dev:backend\" \"npm run dev:frontend\"", - "dev:cli": "tsx src/scripts/cli.ts", + "dev": "vite", "check-types": "tsc --noEmit", "test": "vitest run", - "build:frontend": "vite build", - "build:backend": "tsup", - "build": "npm run build:backend && npm run build:frontend", - "start": "srvx --static=frontend/dist dist/server.js" + "build": "vite build && vite build --mode server", + "start": "srvx --static=public/ dist/server.js" }, "devDependencies": { - "@hono/node-server": "^1.19.7", - "@hono/node-ws": "^1.3.0", "@types/node": "^22.13.9", - "@types/prompts": "^2", "@types/react": "^18.2.0", "@types/react-dom": "^18.2.0", "@vitejs/plugin-react": "^4.2.0", "concurrently": "^8.2.2", - "prompts": "^2.4.2", - "srvx": "^0.10.0", - "tsup": "^8.5.1", "tsx": "^3.12.7", "typescript": "^5.5.2", "vite": "^5.0.0", + "vite-plugin-srvx": "^0.1.0", "vitest": "^3.1.1" }, "dependencies": { + "@hono/node-server": "^1.19.7", + "@hono/node-ws": "^1.3.0", "@rivetkit/react": "*", "hono": "^4.11.3", "react": "^18.2.0", "react-dom": "^18.2.0", - "rivetkit": "*" + "rivetkit": "*", + "srvx": "^0.10.0" }, "stableVersion": "0.8.0", "template": { diff --git a/examples/chat-room/scripts/cli.ts b/examples/chat-room/scripts/cli.ts deleted file mode 100644 index 834a241993..0000000000 --- a/examples/chat-room/scripts/cli.ts +++ /dev/null @@ -1,69 +0,0 @@ -import prompts from "prompts"; -import { createClient } from "rivetkit/client"; -import type { registry } from "../src/actors"; - -async function main() { - const { username, room } = await initPrompt(); - - // Create type-aware client - const client = createClient("http://localhost:3000/api/rivet"); - - // connect to chat room - const chatRoom = client.chatRoom.getOrCreate([room]).connect(); - - // fetch history - const history = await chatRoom.getHistory(); - console.log( - `History:\n${history.map((m) => `[${m.sender}] ${m.text}`).join("\n")}`, - ); - - // listen for new messages - let needsNewLine = false; - chatRoom.on("newMessage", (message: any) => { - if (needsNewLine) { - needsNewLine = false; - console.log(); - } - console.log(`[${message.sender}] ${message.text}`); - }); - - // loop to send messages - while (true) { - needsNewLine = true; - const message = await textPrompt("Message"); - if (!message) break; - needsNewLine = false; - await chatRoom.sendMessage(username, message); - } - - await chatRoom.dispose(); -} - -async function initPrompt(): Promise<{ - room: string; - username: string; -}> { - return await prompts([ - { - type: "text", - name: "username", - message: "Username", - }, - { - type: "text", - name: "room", - message: "Room", - }, - ]); -} - -async function textPrompt(message: string): Promise { - const { x } = await prompts({ - type: "text", - name: "x", - message, - }); - return x; -} - -main(); diff --git a/examples/chat-room/src/server.ts b/examples/chat-room/src/server.ts index 6690c51a3f..95c8895f94 100644 --- a/examples/chat-room/src/server.ts +++ b/examples/chat-room/src/server.ts @@ -1,4 +1,6 @@ -import { registry } from "./actors"; - -export default registry.serve(); +import { Hono } from "hono"; +import { registry } from "./actors.ts"; +const app = new Hono(); +app.all("/api/rivet/*", (c) => registry.handler(c.req.raw)); +export default app; diff --git a/examples/chat-room/tests/chat-room.test.ts b/examples/chat-room/tests/chat-room.test.ts index 6ee9362e86..7a004d2d40 100644 --- a/examples/chat-room/tests/chat-room.test.ts +++ b/examples/chat-room/tests/chat-room.test.ts @@ -1,6 +1,6 @@ import { setupTest } from "rivetkit/test"; import { expect, test } from "vitest"; -import { registry } from "../src/actors"; +import { registry } from "../src/actors.ts"; test("Chat room can handle message sending and history", async (ctx) => { const { client } = await setupTest(ctx, registry); diff --git a/examples/chat-room/tsconfig.json b/examples/chat-room/tsconfig.json index ebf8f3a6e1..0551447a84 100644 --- a/examples/chat-room/tsconfig.json +++ b/examples/chat-room/tsconfig.json @@ -1,43 +1,16 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ "target": "esnext", - /* Specify a set of bundled library declaration files that describe the target runtime environment. */ "lib": ["esnext", "dom"], - /* Specify what JSX code is generated. */ "jsx": "react-jsx", - - /* Specify what module code is generated. */ "module": "esnext", - /* Specify how TypeScript looks up a file from a given module specifier. */ "moduleResolution": "bundler", - /* Specify type package names to be included without being referenced in a source file. */ "types": ["node", "vite/client"], - /* Enable importing .json files */ - "resolveJsonModule": true, - - /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ - "allowJs": true, - /* Enable error reporting in type-checked JavaScript files. */ - "checkJs": false, - - /* Disable emitting files from a compilation. */ "noEmit": true, - - /* Ensure that each file can be safely transpiled without relying on other imports. */ - "isolatedModules": true, - /* Allow 'import x from y' when a module doesn't have a default export. */ - "allowSyntheticDefaultImports": true, - /* Ensure that casing is correct in imports. */ - "forceConsistentCasingInFileNames": true, - - /* Enable all strict type-checking options. */ "strict": true, - - /* Skip type checking all .d.ts files. */ - "skipLibCheck": true + "skipLibCheck": true, + "allowImportingTsExtensions": true, + "rewriteRelativeImportExtensions": true }, - "include": ["src/**/*", "tests/**/*"] + "include": ["src/**/*", "frontend/**/*", "tests/**/*"] } diff --git a/examples/chat-room/tsup.config.ts b/examples/chat-room/tsup.config.ts deleted file mode 100644 index 18240b4aa0..0000000000 --- a/examples/chat-room/tsup.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from "tsup"; - -export default defineConfig({ - entry: { - server: "src/server.ts", - }, - format: ["esm"], - outDir: "dist", - bundle: true, - splitting: false, - shims: true, -}); diff --git a/examples/chat-room/vercel.json b/examples/chat-room/vercel.json new file mode 100644 index 0000000000..e4d47292a2 --- /dev/null +++ b/examples/chat-room/vercel.json @@ -0,0 +1,3 @@ +{ + "framework": "hono" +} diff --git a/examples/chat-room/vite.config.ts b/examples/chat-room/vite.config.ts index dd96ac2cdf..06dae893f5 100644 --- a/examples/chat-room/vite.config.ts +++ b/examples/chat-room/vite.config.ts @@ -1,14 +1,7 @@ -import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import srvx from "vite-plugin-srvx"; export default defineConfig({ - plugins: [react()], - root: "frontend", - server: { - host: "0.0.0.0", - port: 5173, - proxy: { - "/api/rivet/": "http://localhost:3000", - }, - }, + plugins: [react(), ...srvx({ entry: "src/server.ts" })], }); diff --git a/rivetkit-typescript/contrib-docs/EXAMPLE_PROJECT_STRUCTURE.md b/rivetkit-typescript/contrib-docs/EXAMPLE_PROJECT_STRUCTURE.md new file mode 100644 index 0000000000..f8c5f1b608 --- /dev/null +++ b/rivetkit-typescript/contrib-docs/EXAMPLE_PROJECT_STRUCTURE.md @@ -0,0 +1,122 @@ +# Example Project Structure + +This document explains why RivetKit examples are structured the way they are. The goal is a single project structure that works without extra configuration across: + +- Vercel +- Node (for the majority of "normal" deployments like Kubernetes, Railway, etc.) +- Bun & Deno (for hipster devs) + +See `examples/CLAUDE.md` for the specific structure and patterns to follow. + +## Platform Constraints + +### Vercel + +- Expects entry point at `src/server.ts` (not configurable) +- Static files must be in `public/` directory - served automatically via CDN +- Requires strict ESM imports using `.ts` suffix +- Requires the framework to be set to Hono to enable Vercel's "magic" WinterTC support +- Auto-detects Vite when it sees `vite.config.ts` and ignores Hono, so `vercel.json` must explicitly set `"framework": "hono"` + +Reference: https://vercel.com/docs/frameworks/backend/hono + +### Node + +- No native TypeScript support +- No native WinterCG/WinterTC APIs +- No built-in static file serving +- WebSocket support requires `@hono/node-server` and `@hono/node-ws` adapters + +### Bun & Deno + +- No built-in static file serving + +Everything else tends to _just work_ since these are modern ESM-compliant and WinterTC-compliant platforms. + +## Structure + +### src/server.ts with WinterTC + +The server entry point must be `src/server.ts` with a default export. **You must explicitly import from `"hono"` for Vercel to detect the framework.** + +Minimum required: + +```typescript +import { Hono } from "hono"; +import { registry } from "./actors.ts"; + +const app = new Hono(); +app.all("/api/rivet/*", (c) => registry.handler(c.req.raw)); +export default app; +``` + +With additional routes: + +```typescript +import { Hono } from "hono"; +import { registry } from "./actors.ts"; + +const app = new Hono(); + +app.get("/api/foo", (c) => c.text("bar")); + +app.all("/api/rivet/*", (c) => registry.handler(c.req.raw)); + +export default app; +``` + +- **Vercel** uses the default export to create serverless functions (requires `import { Hono } from "hono"` to detect framework) +- **WinterTC**-compatible runtimes expect this pattern +- **srvx** wraps the export for Node.js +- **Bun/Deno** can run it directly, srvx delegates to Bun/Deno if detected + +### vercel.json + +Vercel auto-detects Vite when it sees a `vite.config.ts` and ignores Hono. We must explicitly set the framework: + +```json +{ + "framework": "hono" +} +``` + +Without this, Vercel won't enable WinterTC support and the server won't work correctly. + +### public/ for Static Files + +Static files are served from the `public/` directory: + +- **Vercel** serves `public/` automatically via CDN with caching headers +- **srvx** serves files with `--static=public/`, matching Vercel's behavior +- **Bun/Deno** rely on srvx for the static file serving + +This avoids platform-specific static file handling code. + +### srvx + Vite + vite-plugin-srvx + +For Node.js, we use `srvx` to bridge the gaps: + +- Provides automatic TypeScript compilation +- Provides WinterTC compatibility shims +- `--static=public/` for static file serving + +**Development** (with Vite): + +```typescript +// vite.config.ts +import srvx from "vite-plugin-srvx"; + +export default defineConfig({ + plugins: [react(), ...srvx({ entry: "src/server.ts" })], +}); +``` + +`vite-plugin-srvx` provides a unified dev server with frontend HMR and backend API handling. + +**Production**: + +```bash +srvx --static=public/ dist/server.js +``` + +Serves both the API and static files, matching Vercel's behavior. diff --git a/rivetkit-typescript/packages/rivetkit/package.json b/rivetkit-typescript/packages/rivetkit/package.json index da6100b80f..5253ec0360 100644 --- a/rivetkit-typescript/packages/rivetkit/package.json +++ b/rivetkit-typescript/packages/rivetkit/package.json @@ -165,23 +165,23 @@ "dump-asyncapi": "tsx scripts/dump-asyncapi.ts" }, "dependencies": { - "@rivetkit/virtual-websocket": "workspace:*", - "@rivetkit/bare-ts": "^0.6.2", "@hono/standard-validator": "^0.1.3", "@hono/zod-openapi": "^1.1.5", + "@rivetkit/bare-ts": "^0.6.2", "@rivetkit/engine-runner": "workspace:*", "@rivetkit/fast-json-patch": "^3.1.2", + "@rivetkit/on-change": "^6.0.2-rc.1", + "@rivetkit/virtual-websocket": "workspace:*", "cbor-x": "^1.6.0", "get-port": "^7.1.0", "hono": "^4.7.0", "invariant": "^2.2.4", "nanoevents": "^9.1.0", - "@rivetkit/on-change": "^6.0.2-rc.1", "p-retry": "^6.2.1", "pino": "^9.5.0", "uuid": "^12.0.0", - "zod": "^4.1.0", - "vbare": "^0.0.4" + "vbare": "^0.0.4", + "zod": "^4.1.0" }, "devDependencies": { "@bare-ts/tools": "^0.13.0", @@ -194,6 +194,7 @@ "@vitest/ui": "3.1.1", "commander": "^12.1.0", "eventsource": "^4.0.0", + "local-pkg": "^0.5.1", "tsup": "^8.4.0", "tsx": "^4.19.4", "typescript": "^5.7.3", diff --git a/rivetkit-typescript/packages/rivetkit/src/registry/serve.ts b/rivetkit-typescript/packages/rivetkit/src/registry/serve.ts index 07869f239c..c2aece9a43 100644 --- a/rivetkit-typescript/packages/rivetkit/src/registry/serve.ts +++ b/rivetkit-typescript/packages/rivetkit/src/registry/serve.ts @@ -3,6 +3,9 @@ import { detectRuntime, stringifyError } from "../utils"; import { logger } from "./log"; import { RegistryConfig } from "./config"; +// TODO: Go back to dynamic import for this +import getPort from "get-port"; + const DEFAULT_PORT = 6420; /** @@ -10,9 +13,12 @@ const DEFAULT_PORT = 6420; * * Tries ports incrementally until a free one is found. */ -export async function findFreePort(startPort: number = DEFAULT_PORT): Promise { - const getPortModule = "get-port"; - const { default: getPort } = await import(/* webpackIgnore: true */ getPortModule); +export async function findFreePort( + startPort: number = DEFAULT_PORT, +): Promise { + // TODO: Fix this + // const getPortModule = "get-port"; + // const { default: getPort } = await import(/* webpackIgnore: true */ getPortModule); // Create an iterable of ports starting from startPort function* portRange(start: number, count: number = 100): Iterable { diff --git a/scripts/vercel/generate-deploy-url.ts b/scripts/vercel/generate-deploy-url.ts index 1adab3adc2..723027fcfb 100755 --- a/scripts/vercel/generate-deploy-url.ts +++ b/scripts/vercel/generate-deploy-url.ts @@ -12,7 +12,7 @@ const REPO_OWNER = "rivet-dev"; const REPO_NAME = "rivet"; -const BRANCH = "update-examples"; +const BRANCH = "01-07-chore_example_update_examples_to_use_srvx"; interface DeployUrlOptions { example: string;