refactor(core): extract shared studio API module (#113)

## Summary
Extracts all studio API routes into a shared Hono-based module at `@hyperframes/core/studio-api`.

### Architecture
- **`StudioApiAdapter` interface** — consumers inject host-specific behavior (project resolution, bundling, rendering, thumbnails)
- **Shared route modules**: projects, files, preview, lint, render, thumbnail
- **Shared helpers**: `isSafePath`, `walkDir`, `getMimeType`, `buildSubCompositionHtml`

### What this PR does
- Creates the shared module with all API routes extracted from both `vite.config.ts` and `studioServer.ts`
- Both consumers will be refactored in follow-up commits to mount this module with their own adapter

### What stays in each consumer
- **Vite**: SSR module loading, Puppeteer thumbnails, file watcher + HMR, producer HTTP proxy, multi-project scanning
- **CLI**: in-process `executeRenderJob`, local runtime serving, browser management, SPA static file serving

### Follow-up needed
- [ ] Refactor `packages/studio/vite.config.ts` to use `createStudioApi(adapter)` via `@hono/node-server`'s `getRequestListener`
- [ ] Refactor `packages/cli/src/server/studioServer.ts` to use `createStudioApi(adapter)`
- [ ] Add `./studio-api` export path to `packages/core/package.json`
- [ ] Add `hono` as peer dependency of `@hyperframes/core`

## Test plan
- [ ] Verify shared module compiles without type errors
- [ ] After consumer refactoring: all studio features work identically via both vite dev and CLI embedded servers

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
Miguel Ángel
2026-03-28 22:28:12 +01:00
committed by GitHub
parent fecd4c8485
commit bd175b64a6
15 changed files with 848 additions and 471 deletions
+18 -2
View File
@@ -28,7 +28,11 @@
"import": "./src/compiler/index.ts",
"types": "./src/compiler/index.ts"
},
"./runtime": "./dist/hyperframe.runtime.iife.js"
"./runtime": "./dist/hyperframe.runtime.iife.js",
"./studio-api": {
"import": "./src/studio-api/index.ts",
"types": "./src/studio-api/index.ts"
}
},
"publishConfig": {
"access": "public",
@@ -45,7 +49,11 @@
"import": "./dist/compiler/index.js",
"types": "./dist/compiler/index.d.ts"
},
"./runtime": "./dist/hyperframe.runtime.iife.js"
"./runtime": "./dist/hyperframe.runtime.iife.js",
"./studio-api": {
"import": "./dist/studio-api/index.js",
"types": "./dist/studio-api/index.d.ts"
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
@@ -81,6 +89,14 @@
"typescript": "^5.0.0",
"vitest": "^3.2.4"
},
"peerDependencies": {
"hono": "^4.0.0"
},
"peerDependenciesMeta": {
"hono": {
"optional": true
}
},
"optionalDependencies": {
"cheerio": "^1.2.0",
"esbuild": "^0.25.12"