* Local studio mode: spawn Vite using a locally installed @hyperframes/studio. * Provides full Vite HMR and the complete studio experience.
(dir: string, options?: StudioLaunchOptions)
| 799 | * Provides full Vite HMR and the complete studio experience. |
| 800 | */ |
| 801 | async function runLocalStudioMode(dir: string, options?: StudioLaunchOptions): Promise<void> { |
| 802 | const req = createRequire(join(dir, "package.json")); |
| 803 | const studioPkgPath = dirname(req.resolve("@hyperframes/studio/package.json")); |
| 804 | const pName = options?.projectName ?? basename(dir); |
| 805 | |
| 806 | // Symlink project into studio's data directory |
| 807 | const projectsDir = join(studioPkgPath, "data", "projects"); |
| 808 | const { symlinkPath, createdSymlink } = linkProjectIntoStudioData(dir, projectsDir, pName); |
| 809 | |
| 810 | clack.intro(c.bold("hyperframes preview") + c.dim(" (local studio)")); |
| 811 | const s = clack.spinner(); |
| 812 | s.start("Starting studio..."); |
| 813 | |
| 814 | const viteCommand = buildNpxCommand(["vite"]); |
| 815 | const child = spawn(viteCommand.command, viteCommand.args, { |
| 816 | cwd: studioPkgPath, |
| 817 | stdio: ["ignore", "pipe", "pipe"], |
| 818 | }); |
| 819 | |
| 820 | attachStudioReadyHandler(child, s, pName, options); |
| 821 | removeSymlinkOnExit(createdSymlink, symlinkPath); |
| 822 | |
| 823 | // Same tree-kill handler as dev mode. No-op on Windows (see comment above). |
| 824 | registerChildTreeShutdown(child); |
| 825 | return waitForChildClose(child); |
| 826 | } |
| 827 | |
| 828 | /** |
| 829 | * Embedded mode: serve the pre-built studio SPA with a standalone Hono server. |
no test coverage detected