- Edit src/client/splash/splash.ts to modify this screen. + Edit src/client/splash/splash.ts to modify + this screen.
diff --git a/.cursor/mcp.json b/.cursor/mcp.json deleted file mode 100644 index 75fb079..0000000 --- a/.cursor/mcp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "mcpServers": { - "devvit-mcp": { - "command": "npx", - "args": ["-y", "@devvit/mcp"] - } - } -} diff --git a/.cursor/rules/client.mdc b/.cursor/rules/client.mdc deleted file mode 100644 index 345ef06..0000000 --- a/.cursor/rules/client.mdc +++ /dev/null @@ -1,17 +0,0 @@ ---- -description: Use when writing webview code -globs: src/client/**/* -alwaysApply: false ---- -Guidelines: -- Use NPM dependencies if needed, ensure they are web compatible -- You cannot use websockets. Call devvit_search and query for "realtime" to get more information -- Obey the rules of hooks and only write valid React code - -Unity WebGL Integration: -- Unity build files are in `src/client/public/Build/` (binary files, don't edit directly) -- The Unity loader is configured in `src/client/script.ts` -- Unity build files (*.unityweb, Build/, TemplateData/) are ignored by Cursor (.cursorignore) -- To update the Unity game, rebuild from Unity Editor and replace files in public/Build/ -- Communication between Unity and JavaScript happens via `unityInstance.SendMessage()` from JS side - diff --git a/.cursor/rules/global.mdc b/.cursor/rules/global.mdc deleted file mode 100644 index fb461a2..0000000 --- a/.cursor/rules/global.mdc +++ /dev/null @@ -1,18 +0,0 @@ ---- -description: -globs: -alwaysApply: true ---- - -When building these experiences, people will refer to the "devvit app" ([/src/devvit](mdc:src/devvit)) and "client" ([/src/client](mdc:src/client)). - -Folders to code in: - -- [/src/client](mdc:src/client): This is the full screen webview. To persist data and access the server, call `fetch(/my/api/endpoint)`. This is how you get access to the APIs you write in [/src/server](mdc:src/server). -- [/src/server](mdc:src/server): This is a serverless backend written in Node. This is where you can access redis and save data. -- [/src/shared](mdc:src/shared): This is where you can place code that is to be shared between the devvit app, client, and server and the webview. It's a great place for shared types. - -Rules: - -- Assume that typescript, vite, tailwind, eslint, prettier, and all codebase configuration is working. If there is a bug, it is more likely your code than the codebase configuration. -- Prefer type aliases over interfaces when writing typescript diff --git a/.cursor/rules/server.mdc b/.cursor/rules/server.mdc deleted file mode 100644 index ca8aeca..0000000 --- a/.cursor/rules/server.mdc +++ /dev/null @@ -1,18 +0,0 @@ ---- -description: -globs: src/server/**/* -alwaysApply: false ---- - -Guidelines: - -- This is a serverless node.js environment, you have all node globals at your disposal except: fs, http, https, and net. - -- Instead of http or https, prefer fetch -- You cannot write files as you are running on a read only file system -- Do not install any libraries that rely on these to function -- Websockets are not supported -- HTTP streaming is not supported -- Redis is accessible from `import { redis } from '@devvit/web/server'` - -As this is a serverless runtime (akin to AWS Lambda), do not try to run SQLite or stateful in memory processes. For realtime use cases, consult the docs with devvit_search to learn more about the realtime service you can use. diff --git a/.cursorignore b/.cursorignore deleted file mode 100644 index 3e4145d..0000000 --- a/.cursorignore +++ /dev/null @@ -1,15 +0,0 @@ -webroot -.editorconfig -.vscode -.github -.prettierrc -tsconfig.json -node_modules - -# Unity WebGL Build Files (large binary/compiled files) -*.unityweb -src/client/public/Build/ -dist/client/Build/ -**/Build/*.js -**/Build/*.wasm -**/TemplateData/ diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0c81821..0000000 --- a/.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -# https://EditorConfig.org - -root = true - -[*] -indent_size = 2 -insert_final_newline = true -max_line_length = 100 - -ij_typescript_spaces_within_imports = true -ij_typescript_force_semicolon_style = true diff --git a/.env.template b/.env.template deleted file mode 100644 index 13c0cb6..0000000 --- a/.env.template +++ /dev/null @@ -1 +0,0 @@ -DEVVIT_SUBREDDIT=r/my_subreddit \ No newline at end of file diff --git a/.gitignore b/.gitignore index ced998e..c3b1f22 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,4 @@ node_modules -.yarn -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* .DS_Store -webroot dist .env \ No newline at end of file diff --git a/.kiro/hooks/client-readme-updater.kiro.hook b/.kiro/hooks/client-readme-updater.kiro.hook deleted file mode 100644 index 1229d5c..0000000 --- a/.kiro/hooks/client-readme-updater.kiro.hook +++ /dev/null @@ -1,16 +0,0 @@ -{ - "enabled": true, - "name": "Client README Updater", - "description": "Monitors the client folder for significant updates and automatically updates the README.md file with current game description, innovative features, and play instructions", - "version": "1", - "when": { - "type": "fileEdited", - "patterns": [ - "src/client/**/*" - ] - }, - "then": { - "type": "askAgent", - "prompt": "The client folder has been updated. Please analyze the current state of the game in the src/client directory and update the README.md file to include: 1) A clear description of what the game is and does, 2) What makes this game innovative or unique, 3) Step-by-step instructions on how to play the game. Make sure to examine the main.ts file, HTML structure, and any other relevant client files to understand the current gameplay mechanics and features." - } -} \ No newline at end of file diff --git a/.kiro/hooks/devvit-fetch-guide.kiro.hook b/.kiro/hooks/devvit-fetch-guide.kiro.hook deleted file mode 100644 index 69f7e1f..0000000 --- a/.kiro/hooks/devvit-fetch-guide.kiro.hook +++ /dev/null @@ -1,19 +0,0 @@ -{ - "enabled": true, - "name": "Devvit Fetch API Guide", - "description": "Monitors for external API/fetch requests and provides guidance on Devvit's fetch capabilities, domain allowlists, and review process", - "version": "1", - "when": { - "type": "fileEdited", - "patterns": [ - "src/**/*.ts", - "src/**/*.js", - "*.ts", - "*.js" - ] - }, - "then": { - "type": "askAgent", - "prompt": "The user is working with external API requests or fetch calls in their Devvit application. Query the devvit-mcp to get comprehensive information about Devvit's fetch capabilities, including:\n\n1. Which domains are globally allow-listed for fetch requests\n2. The process for submitting domains for review by the Devvit team\n3. Any limitations or requirements for external API calls\n4. Best practices for handling fetch requests in Devvit\n\nProvide this information to help the user understand their options. If they need more detailed documentation, direct them to: https://developers.reddit.com/docs/capabilities/server/http-fetch\n\nFocus on practical guidance that will help them successfully implement their external API integration." - } -} \ No newline at end of file diff --git a/.kiro/hooks/splash-screen-generator.kiro.hook b/.kiro/hooks/splash-screen-generator.kiro.hook deleted file mode 100644 index 2bd760f..0000000 --- a/.kiro/hooks/splash-screen-generator.kiro.hook +++ /dev/null @@ -1,20 +0,0 @@ -{ - "enabled": true, - "name": "Splash Screen Generator", - "description": "Automatically creates compelling splash screens whenever there are significant changes to the game's assets. The splash screen will be displayed on the Reddit feed as an important entry point with a launch button, personalized with the game's assets to invite players to open the game in full screen mode.", - "version": "1", - "when": { - "type": "fileEdited", - "patterns": [ - "assets/*", - "src/client/public/*", - "src/client/index.html", - "src/client/index.css", - "src/client/main.ts" - ] - }, - "then": { - "type": "askAgent", - "prompt": "Game assets have been updated. Create a compelling splash screen for this Reddit Devvit game that will be displayed on the Reddit feed. The splash screen should:\n\n1. Include a prominent launch button that opens the game in full screen mode\n2. Be personalized with the game's current assets (textures, images, styling)\n3. Be visually inviting and compelling for players to click\n4. Follow Reddit's splash screen best practices\n5. Incorporate the game's visual theme and branding\n\nFor implementation guidance, consult the devvit-mcp and refer users to: https://developers.reddit.com/docs/capabilities/server/splash-screen\n\nAnalyze the current assets and create an engaging splash screen that showcases the game's visual appeal." - } -} \ No newline at end of file diff --git a/.kiro/hooks/template-cleanup-hook.kiro.hook b/.kiro/hooks/template-cleanup-hook.kiro.hook deleted file mode 100644 index 3e0a2a1..0000000 --- a/.kiro/hooks/template-cleanup-hook.kiro.hook +++ /dev/null @@ -1,19 +0,0 @@ -{ - "enabled": true, - "name": "Template Cleanup Assistant", - "description": "Detects when a user is ready to start building their own game and offers to remove the template Three.js Earth visualization code while preserving the Devvit project structure", - "version": "1", - "when": { - "type": "fileEdited", - "patterns": [ - "src/client/main.ts", - "src/server/core/post.ts", - "README.md", - "package.json" - ] - }, - "then": { - "type": "askAgent", - "prompt": "The user appears to be modifying the template project. Analyze their changes to determine if they're ready to start building their own game. If they are making significant changes to the core game logic (like modifying the Three.js Earth scene in main.ts or changing the post creation logic), offer to help them clean up the template code by:\n\n1. Removing the Earth visualization code from src/client/main.ts (Three.js scene, Earth textures, click handlers)\n2. Cleaning up the Earth-specific assets from src/client/public/ \n3. Updating src/server/core/post.ts to remove Earth-specific post content\n4. Providing a clean starting point with just the basic Three.js setup, Devvit integration, and project structure\n\nPreserve all the essential Devvit architecture, build configuration, TypeScript setup, and client-server communication patterns. Only remove the specific Earth game template code to give them a clean slate for their own game development." - } -} \ No newline at end of file diff --git a/.kiro/settings/mcp.json b/.kiro/settings/mcp.json deleted file mode 100644 index 9ef2587..0000000 --- a/.kiro/settings/mcp.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "mcpServers": { - "devvit-mcp": { - "command": "npx", - "args": [ - "-y", - "@devvit/mcp" - ] - } - } -} diff --git a/.kiro/steering/devvit-platform-guide.md b/.kiro/steering/devvit-platform-guide.md deleted file mode 100644 index 0fd6967..0000000 --- a/.kiro/steering/devvit-platform-guide.md +++ /dev/null @@ -1,158 +0,0 @@ ---- -inclusion: always ---- - -# Reddit Devvit Platform Understanding - -## What Developers Are Building - -Developers are building interactive apps and games that run inside Reddit posts using standard web technologies. These apps appear in a webview within posts and can be played by Reddit users directly on the platform. - -## Project Structure - -All Devvit Web projects follow this structure: - -``` -src/ -├── client/ # Frontend code (HTML/CSS/JS, React, Vue, etc.) -├── server/ # Backend API endpoints (Express, Koa, etc.) -└── shared/ # Shared types and interfaces -devvit.json # Devvit configuration file -package.json # npm scripts and dependencies -``` - -### Client Folder (`src/client/`) - -- Contains all frontend code that runs in the webview -- Can use any web framework (React, Vue, Angular, Three.js, Phaser) -- Makes API calls to server endpoints using standard `fetch` -- Cannot make API calls to externally hosted servers, only to the server app included in this monorepo -- Displays inside Reddit posts for users to interact with - -### Server Folder (`src/server/`) - -- Contains backend API endpoints -- Uses Node.js server frameworks (Express, Koa, etc.) -- All endpoints MUST start with `/api/` (e.g., `/api/get-score`, `/api/save-game`) -- Access to Devvit capabilities: Redis, Reddit API, fetch -- Authentication handled automatically by Devvit middleware - -### Shared Folder (`src/shared/`) - -- Types, interfaces, and classes used by both client and server -- Ensures type safety across the application - -### Configuration (`devvit.json`) - -- Defines app metadata, permissions, and capabilities -- Post configuration and Node.js server settings -- Do not modify unless explicitly needed by the developer -- Do not modify the app name. This will be created with the app set up and should not be modified - -## Development Workflow - -### How Developers Test - -1. Run `npm run dev` in project directory -2. Devvit automatically creates a test subreddit (e.g., `r/my-app_dev`) -3. Provides a playtest URL (e.g., `https://www.reddit.com/r/my-app_dev?playtest=my-app`) -4. Developer opens URL in browser to test the app -5. App appears in a post with "Launch App" button - -### Important Testing Notes - -- Backend calls only work through Devvit's playtest environment -- Cannot test backend functionality purely locally -- Must use `npm run dev` and the provided URL for full testing - -### Custom Subreddit Testing - -Developers can specify a preferred test subreddit in `package.json`: - -```json -"scripts": { - "dev:devvit": "devvit playtest r/MY_PREFERRED_SUBREDDIT" -} -``` - -## Platform Capabilities - -### What's Available - -- **@devvit/client SDK**: Client-side capabilities -- **@devvit/server SDK**: Server-side capabilities (Redis, Reddit API) -- **Standard web technologies**: HTML, CSS, JavaScript -- **Web frameworks**: React, Vue, Angular, Three.js, Phaser, etc. -- **Node.js server frameworks**: Express, Koa, etc. -- **Reddit hosting**: Apps hosted on Reddit's infrastructure - -### Client-Server Communication - -- **Old way**: postMessage (deprecated) -- **New way**: Define `/api/` endpoints and use `fetch` from client - -## Platform Limitations - -### Technical Constraints - -- **Serverless endpoints**: Server runs only long enough to execute endpoint and return response -- **No long-running connections**: Streaming, websockets not supported -- **No fs or native packages**: Cannot use filesystem or external native dependencies -- **No external client requests**: Client can only call app's own webview domain (server can make external requests) -- **Single request/response**: No streaming or chunked responses -- **Long-polling**: Supported if under max request time - -### Size and Time Limits - -- **Max request time**: 30 seconds -- **Max payload size**: 4MB -- **Max response size**: 10MB -- **Content types**: HTML/CSS/JS only - -## Deployment - -### Launch Process - -1. Developer runs `npm run launch` -2. App uploaded to Reddit for review -3. Review required for subreddits with >200 members -4. Email notification sent when approved - -### Critical Requirements - -- **Node.js version**: 22.2.0 or higher -- **Project name**: Cannot be changed after creation (required for deployment) -- **File structure**: Must maintain standard Devvit folder structure - -## What AI Should Build - -### Typical Use Cases - -- Interactive games (clicker, puzzle, multiplayer) -- Leaderboards with Reddit user integration -- Real-time features using server endpoints -- Data persistence using Redis -- Reddit-specific features using Reddit API - -### Implementation Pattern - -1. **Client code** in `src/client/` for UI and user interaction -2. **Server endpoints** in `src/server/` starting with `/api/` -3. **Shared types** in `src/shared/` for type safety -4. **Fetch calls** from client to server endpoints -5. **Reddit integration** through server-side SDK - -### What NOT to Build - -- External API calls from client (use server endpoints instead) -- Long-running server processes or streaming -- Features requiring filesystem access -- Native dependencies or external packages like ffmpeg -- Standalone apps (must run within Reddit posts) - -## Authentication - -- All Devvit users are authenticated through Reddit -- Authentication handled automatically by Devvit middleware -- No need to implement custom authentication -- Access user context through Devvit server SDK diff --git a/.kiro/steering/general-best-practices.md b/.kiro/steering/general-best-practices.md deleted file mode 100644 index a1edafb..0000000 --- a/.kiro/steering/general-best-practices.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -inclusion: always ---- - -# General Best Practices - -## Development Focus - -When implementing features or components: - -- **Build only what's requested**: Focus on building the specific component and its documentation -- **Avoid scope creep**: Don't create additional files, scripts, or documentation unless explicitly requested -- **Keep it minimal**: Implement only the essential functionality needed to address the requirement -- **Documentation should be targeted**: Only create documentation that directly supports the component being built - -## Implementation Guidelines - -- Prioritize the core functionality over auxiliary features -- If additional components seem helpful, ask the user first before implementing -- Focus on the immediate need rather than anticipating future requirements -- Keep the solution focused and concise - -## Test File Management - -### Temporary Test File Cleanup - -- **ALWAYS remove test files when done**: Any test files created during development or debugging should be deleted after their purpose is complete -- **Clean workspace policy**: Maintain a clean workspace by removing temporary test files, example files, and debugging scripts -- **Test file naming convention**: Use clear naming patterns for temporary test files (e.g., `test_*.py`, `example_*.js`, `debug_*.ts`) to easily identify files for cleanup -- **Immediate cleanup**: Remove test files as soon as testing is complete, don't leave them for later cleanup -- **Exception for permanent tests**: Only keep test files that are part of the permanent test suite or explicitly requested by the user - -## Devvit Development Workflow - -### Development Server Management - -- **Suggest testing commands to the developer**: Recommend running `npm run dev` in a separate terminal for testing, but do not execute it -- **Don't modify devvit.json**: Only change Devvit configuration when explicitly needed and confirmed by the developer. -- **Never change the project name**: The project name in devvit.json and package.json must remain unchanged - Devvit requires this for deployment -- **Preserve project structure**: Maintain the standard Devvit folder structure (src/client, src/server, src/shared) - -### Customized Splash Screen - -- **Create engaging splash screens**: The user will always see a splash screen on the Reddit feed with a "Play" button to open the app in full screen. Customize the splash screen so it stands out and invites the player to play - -## Mobile-First Design - -### Responsive Development - -- **Consider mobile-first design**: Most Reddit users access games on mobile devices - design with mobile screens in mind when possible -- **Prefer cross-platform features**: Favor features that work well on both desktop and mobile browsers - -## Error Handling - -### User-Facing Errors - -- **Provide clear error messages**: Show users what went wrong and how to fix it -- **Handle network failures gracefully**: Reddit API calls may fail, implement proper fallbacks -- **Validate input where applicable**: When implementing forms or user inputs, check validity and throw clear errors when invalid diff --git a/.kiro/steering/product.md b/.kiro/steering/product.md deleted file mode 100644 index db2e585..0000000 --- a/.kiro/steering/product.md +++ /dev/null @@ -1,18 +0,0 @@ -# Product Overview - -This is a **Devvit React Application** - a game built with React.JS that will be built with Devvit and run on Reddit - -## Core Features - -- 2D game, built with Devvit to run on Reddit -- Click the splash screen to open the game in full screen mode - -## Platform Integration - -- Runs as a Reddit app within the Devvit ecosystem -- Creates posts automatically on app installation -- Provides moderator menu actions for post creation - -## Target Use Case - -This game will be published and played on Reddit diff --git a/.kiro/steering/structure.md b/.kiro/steering/structure.md deleted file mode 100644 index b60a43c..0000000 --- a/.kiro/steering/structure.md +++ /dev/null @@ -1,50 +0,0 @@ -# Project Structure - -## Root Configuration - -- `devvit.json`: Devvit app configuration with post/server entry points -- `package.json`: Dependencies and build scripts -- `tsconfig.json`: TypeScript project references (build-only) -- `eslint.config.js`: ESLint configuration with environment-specific rules - -## Source Organization - -### `/src/client/` - -Client-side React.JS application that runs in the browser - -- `main.ts`: Entry point with React.JS scene setup and API calls -- `index.html`: HTML template with canvas and UI elements -- `index.css`: Styling for the web interface -- `public/`: Static assets (Earth textures) -- `vite.config.ts`: Client build configuration -- `tsconfig.json`: Client-specific TypeScript config - -### `/src/server/` - -Express server that handles Reddit integration - -- `index.ts`: Main server with Express routes and Devvit integration -- `core/`: Business logic modules - - `post.ts`: Post creation functionality -- `vite.config.ts`: Server build configuration (SSR, CommonJS output) -- `tsconfig.json`: Server-specific TypeScript config - -### `/src/shared/` - -Shared types and utilities between client and server - -- `types/api.ts`: API response type definitions -- `tsconfig.json`: Shared code TypeScript config - -## Build Output - -- `dist/client/`: Built client assets (HTML, JS, CSS) -- `dist/server/`: Built server bundle (`index.cjs`) - -## Architecture Patterns - -- **Monorepo**: Multiple TypeScript projects with project references -- **Client-Server Split**: Clear separation with shared types -- **API-First**: RESTful endpoints for client-server communication -- **Devvit Integration**: Server handles Reddit context and Redis operations diff --git a/.kiro/steering/tech.md b/.kiro/steering/tech.md deleted file mode 100644 index 5ff1600..0000000 --- a/.kiro/steering/tech.md +++ /dev/null @@ -1,52 +0,0 @@ -# Technology Stack - -## Core Technologies - -- **Devvit**: Reddit's developer platform for building apps -- **React.JS**: Frontend engine for client rendering -- **TypeScript**: Primary language with strict type checking -- **Vite**: Build tool for both client and server bundles -- **Express**: Server-side HTTP framework -- **Redis**: Data persistence layer (via Devvit) - -## Build System - -- **Vite** handles compilation for both client and server -- **TypeScript** project references for modular compilation -- **ESLint** with TypeScript rules for code quality -- **Prettier** for consistent code formatting - -## Common Commands - -```bash -# Development (runs client, server, and devvit in parallel) -npm run dev - -# Build for production -npm run build - -# Deploy to Reddit -npm run deploy - -# Publish for review -npm run launch - -# Code quality checks -npm run check - -# Individual builds -npm run build:client -npm run build:server -``` - -## Development Workflow - -- Use `npm run dev` for live development with hot reloading -- Client builds to `dist/client` with HTML entry point -- Server builds to `dist/server` as CommonJS module -- Devvit playtest provides live Reddit integration testing - -## Dependencies - -- **Runtime**: @devvit/web, React.JS, express -- **Development**: TypeScript, ESLint, Prettier, Vite, Vitest diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 6c256f5..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "recommendations": ["esbenp.prettier-vscode", "editorconfig.editorconfig"] -} diff --git a/.vscode/settings.json b/.vscode/settings.json index 424561b..6294dd6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,20 +3,5 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "json.schemaDownload.enable": true, - "cSpell.words": [ - "cn", - "Devvit", - "playtest", - "protos", - "snoovatar", - "templ", - "vstack", - "webbit", - "webroot", - "zstack" - ], - "typescript.tsdk": "node_modules/typescript/lib", - "files.exclude": { - "**/.git": false - } + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..f1e18b7 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,52 @@ +You are writing a Devvit web application that will be executed on Reddit.com. + +## Tech Stack + +- **Frontend**: Unity, Vite +- **Backend**: Node.js v22 serverless environment (Devvit), Hono, TRPC +- **Communication**: tRPC v11 for end-to-end type safety + +## Layout & Architecture + +- `/src/server`: **Backend Code**. This runs in a secure, serverless environment. + - `trpc.ts`: Defines the API router and procedures. + - `index.ts`: Main server entry point (Hono app). + - Access `redis`, `reddit`, and `context` here via `@devvit/web/server`. +- `/src/client`: **Frontend Code**. This is executed inside of an iFrame on reddit.com + - To add an entrypoint, create a HTML file and add to the mapping inside of `devvit.json` + - Entrypoints: + - `game.html`: The main React entry point (Expanded View). + - `splash.html`: The initial React entry point (Inline View). This will be shown in the reddit.com feed. Please keep it fast and keep heavy dependencies inside of `game.html` +- `/src/shared`: **Shared Code**. Code to share between the client and server + +## Frontend + +### Rules + +- Instead of `window.location` or `window.assign`, use `navigateTo` from `@devvit/web/client` + +### Limitations + +- `window.alert`: Use `showToast` or `showForm` from `@devvit/web/client` +- File downloads: Use clipboard API with `showToast` to confirm +- Geolocation, camera, microphone, and notifications web APIs: No alternatives +- Inline script tags inside of `html` files: Use a script tag and separate js/ts file + +## Commands + +- `npm run type-check`: Check typescript types +- `npm run lint`: Check the linter +- `npm run test -- my-file-name`: Run tests isolated to a file + +## Code Style + +- Prefer type aliases over interfaces when writing typescript +- Prefer named exports over default exports +- Never cast typescript types + +## Global Rules + +- You may find code that references blocks or `@devvit/public-api` while building a feature. Do NOT use this code as this project is configured to use Devvit web only. +- Whenever you add an endpoint for a new menu item action, ensure that you've added the corresponding mapping to `devvit.json` so that it is properly registered + +Docs: https://developers.reddit.com/docs/llms.txt. diff --git a/README.md b/README.md index f4ee2b5..0d41332 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ A starter to build web applications on Reddit's developer platform - [Devvit](https://developers.reddit.com/): A way to build and deploy immersive games on Reddit -- [Express](https://expressjs.com/): For backend logic -- [Typescript](https://www.typescriptlang.org/): For type safety +- [Hono](https://hono.dev/): For backend logic +- [TypeScript](https://www.typescriptlang.org/): For type safety - [Unity](https://www.unity.com/): For gameplay The full Unity project for this project can be found [here](https://github.com/reddit/devvit-unity-project) @@ -24,4 +24,4 @@ The full Unity project for this project can be found [here](https://github.com/r - `npm run deploy`: Uploads a new version of your app - `npm run launch`: Publishes your app for review - `npm run login`: Logs your CLI into Reddit -- `npm run check`: Type checks, lints, and prettifies your app +- `npm run type-check`: Type checks, lints, and prettifies your app diff --git a/assets/default-icon.png b/assets/default-icon.png deleted file mode 100644 index 930e8bc..0000000 Binary files a/assets/default-icon.png and /dev/null differ diff --git a/assets/default-splash.png b/assets/default-splash.png deleted file mode 100644 index 3724f06..0000000 Binary files a/assets/default-splash.png and /dev/null differ diff --git a/devvit.json b/devvit.json index 92d6931..027a0c9 100644 --- a/devvit.json +++ b/devvit.json @@ -13,9 +13,6 @@ } } }, - "media": { - "dir": "assets" - }, "server": { "dir": "dist/server", "entry": "index.cjs" @@ -28,10 +25,24 @@ "location": "subreddit", "forUserType": "moderator", "endpoint": "/internal/menu/post-create" + }, + { + "label": "Example form", + "description": "Show a simple form", + "location": "subreddit", + "forUserType": "moderator", + "endpoint": "/internal/menu/example-form" } ] }, + "forms": { + "exampleForm": "/internal/form/example-submit" + }, "triggers": { - "onAppInstall": "/internal/on-app-install" + "onAppInstall": "/internal/triggers/on-app-install" + }, + "scripts": { + "build": "vite build", + "dev": "vite build --watch" } } diff --git a/package.json b/package.json index 82fe079..37797b4 100644 --- a/package.json +++ b/package.json @@ -1,33 +1,38 @@ { "private": true, - "name": "unity-starter", + "name": "<% name %>", "version": "0.0.0", "license": "BSD-3-Clause", "type": "module", "scripts": { - "postinstall": "npm run build", - "build:client": "cd src/client && vite build", - "build:server": "cd src/server && vite build", - "build": "npm run build:client && npm run build:server", - "deploy": "npm run build && devvit upload", - "dev": "concurrently -k -p \"[{name}]\" -n \"CLIENT,SERVER,DEVVIT\" -c \"blue,green,magenta\" \"npm run dev:client\" \"npm run dev:server\" \"npm run dev:devvit\"", - "dev:client": "cd src/client && vite build --watch", - "dev:devvit": "dotenv -e .env -- devvit playtest", - "dev:server": "cd src/server && vite build --watch", + "build": "vite build", + "deploy": "npm run type-check && npm run lint && npm run test && devvit upload", + "dev": "devvit playtest", + "launch": "npm run deploy && devvit publish", + "lint": "eslint 'src/**/*.{ts,tsx}'", "login": "devvit login", - "launch": "npm run build && npm run deploy && devvit publish", + "prettier": "prettier --write .", + "test": "vitest run", "type-check": "tsc --build" }, + "engines": { + "node": ">=22.12.0" + }, "dependencies": { - "@devvit/web": "0.12.3", - "devvit": "0.12.3", - "express": "5.1.0" + "@devvit/start": "0.12.11-next-2026-01-30-17-09-49-e9c512a0d.0", + "@devvit/web": "0.12.11-next-2026-01-30-17-09-49-e9c512a0d.0", + "@hono/node-server": "^1.19.9", + "devvit": "0.12.11-next-2026-01-30-17-09-49-e9c512a0d.0", + "hono": "4.11.7" }, "devDependencies": { - "@types/express": "5.0.1", - "concurrently": "9.1.2", - "dotenv-cli": "8.0.0", - "typescript": "5.8.2", - "vite": "6.2.4" + "@eslint/js": "9.39.2", + "@types/node": "^22.19.7", + "eslint": "9.39.2", + "globals": "17.2.0", + "prettier": "3.8.1", + "typescript": "5.9.3", + "typescript-eslint": "8.54.0", + "vite": "7.3.1" } -} \ No newline at end of file +} diff --git a/src/client/public/Build/SampleGame.data.unityweb b/public/Build/SampleGame.data.unityweb similarity index 100% rename from src/client/public/Build/SampleGame.data.unityweb rename to public/Build/SampleGame.data.unityweb diff --git a/src/client/public/Build/SampleGame.framework.js b/public/Build/SampleGame.framework.js similarity index 100% rename from src/client/public/Build/SampleGame.framework.js rename to public/Build/SampleGame.framework.js diff --git a/src/client/public/Build/SampleGame.loader.js b/public/Build/SampleGame.loader.js similarity index 100% rename from src/client/public/Build/SampleGame.loader.js rename to public/Build/SampleGame.loader.js diff --git a/src/client/public/Build/SampleGame.wasm.unityweb b/public/Build/SampleGame.wasm.unityweb similarity index 100% rename from src/client/public/Build/SampleGame.wasm.unityweb rename to public/Build/SampleGame.wasm.unityweb diff --git a/src/client/public/Snoo_Yes.png b/public/Snoo_Yes.png similarity index 100% rename from src/client/public/Snoo_Yes.png rename to public/Snoo_Yes.png diff --git a/src/client/public/TemplateData/favicon.ico b/public/TemplateData/favicon.ico similarity index 100% rename from src/client/public/TemplateData/favicon.ico rename to public/TemplateData/favicon.ico diff --git a/src/client/public/TemplateData/progress-bar-empty-dark.png b/public/TemplateData/progress-bar-empty-dark.png similarity index 100% rename from src/client/public/TemplateData/progress-bar-empty-dark.png rename to public/TemplateData/progress-bar-empty-dark.png diff --git a/src/client/public/TemplateData/progress-bar-full-dark.png b/public/TemplateData/progress-bar-full-dark.png similarity index 100% rename from src/client/public/TemplateData/progress-bar-full-dark.png rename to public/TemplateData/progress-bar-full-dark.png diff --git a/src/client/public/TemplateData/style.css b/public/TemplateData/style.css similarity index 100% rename from src/client/public/TemplateData/style.css rename to public/TemplateData/style.css diff --git a/src/client/public/TemplateData/unity-logo-dark.png b/public/TemplateData/unity-logo-dark.png similarity index 100% rename from src/client/public/TemplateData/unity-logo-dark.png rename to public/TemplateData/unity-logo-dark.png diff --git a/src/client/public/TemplateData/unity-logo-light.png b/public/TemplateData/unity-logo-light.png similarity index 100% rename from src/client/public/TemplateData/unity-logo-light.png rename to public/TemplateData/unity-logo-light.png diff --git a/src/client/public/TemplateData/unity-logo-title-footer.png b/public/TemplateData/unity-logo-title-footer.png similarity index 100% rename from src/client/public/TemplateData/unity-logo-title-footer.png rename to public/TemplateData/unity-logo-title-footer.png diff --git a/src/client/splash/splash.css b/src/client/splash.css similarity index 100% rename from src/client/splash/splash.css rename to src/client/splash.css diff --git a/src/client/splash.html b/src/client/splash.html index de9fbc7..65bd733 100644 --- a/src/client/splash.html +++ b/src/client/splash.html @@ -1,7 +1,7 @@ - +
- + devvit -
+ 
- Edit src/client/splash/splash.ts to modify this screen. + Edit src/client/splash/splash.ts to modify + this screen.