Skip to content

Modernize to Vite + React 19, deploy with pm2, adopt tooltheme, add rounded corners - #1

Merged
joshmarinacci merged 2 commits into
mainfrom
modernize-pm2-tooltheme
Nov 20, 2026
Merged

joshmarinacci merged 2 commits into
mainfrom
modernize-pm2-tooltheme

Conversation

@joshmarinacci

Copy link
Copy Markdown
Owner

Summary

  • pm2 deploy: adds ecosystem.config.cjs. It's a static site, so pm2 checks out the repo on josh.earth and runs npm ci && npm run build; nginx serves /projects/boxbuilder/current/dist at /boxbuilder/.
  • Toolchain: Create React App → Vite 8, React 17 → 19, TypeScript 4.7 → 6.0, zod 3 → 4, Jest → Vitest. Adds ESLint and Prettier. npm audit goes from 80 vulnerabilities to 0.
  • 3D viewer: jscad-react (pinned to React 17, unmaintained) is replaced by src/viewer/, built on @jscad/regl-renderer. It supports mouse, touch (pinch) and keyboard (arrows, shift+arrows, +/-).
  • UI: restyled with tooltheme as an app shell, with light/dark mode. The 3D view follows the theme.
  • Corner radius now works. It was always shown as a slider but never used. Vertical corners of the box and lid are rounded and the rim stays flat.
  • Docs: README covers settings, controls, development, tooltheme updates and deploy.

Bugs fixed along the way

  • zod 4's .int() reports MAX_SAFE_INTEGER as its max, which made the width slider unusable (regression test added).
  • Clearing a number box and typing "42" produced "1042". Number boxes now keep a draft while you type.
  • Small boxes with thick walls (e.g. 10 mm wide, 5 mm walls) showed a 1 mm cube instead of the box. This was also broken before.
  • React warnings about <tr> without <tbody>.

Before merging / deploying

  • tooltheme is vendored as vendor/joshmarinacci-tooltheme-0.1.0.tgz because its GitHub repo is private. Merging puts its CSS, JS helpers and examples in this public repo. Switch to the npm package once it's published.
  • Server: needs Node 20.19+ or 22.12+, and nginx must point at /projects/boxbuilder/current/dist. The old GitHub Pages deploy is removed; CI now only checks.
  • src/App.css copies tooltheme's shell layout onto #root. It can shrink if tooltheme learns to attach its shell to a container.

Known issues, not changed here

  • Wall thickness: the floor gets the full value but each side wall only half (cavity is width − wall thickness). The README describes it as it is. Worth deciding whether walls should be the full value.
  • Back button: pressing it pushes a new history entry, so Back/Forward behave oddly.

Testing

  • npm run typecheck, npm run lint, npm test (35 tests across box geometry, camera math, URL state, the viewer and the form), npm run build: all pass.
  • Checked the production build and dev server in a browser: rotate, pan, wheel and keyboard zoom, slider keyboard input, typing into number boxes, URL state, STL download (valid binary STL), dark mode, phone width, and a single WebGL canvas under StrictMode.
  • Not tested: pinch zoom on a real touch device, printing a rounded-corner lid, and pm2 deploy against josh.earth.

🤖 Generated with Claude Code

joshmarinacci and others added 2 commits November 20, 2026 13:04
boxbuilder is a static site, so the config defines no pm2 process. pm2 deploy
checks out the repo on josh.earth, runs `npm ci && npm run build`, and nginx
serves <path>/current/dist at /boxbuilder/. User, host, key, ref and path can be
overridden with BOXBUILDER_DEPLOY_* environment variables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unded corners

Toolchain
- Create React App -> Vite 8; React 17 -> 19; TypeScript 4.7 -> 6.0 (7 isn't
  supported by typescript-eslint yet); zod 3 -> 4.
- Jest -> Vitest + Testing Library + user-event. Add ESLint (typescript-eslint,
  react-hooks) and Prettier. npm audit: 80 vulnerabilities -> 0.
- CI workflow now typechecks, lints, tests and builds on Node 22. The gh-pages
  deploy is removed; deployment is pm2 (ecosystem.config.cjs).

3D viewer
- jscad-react pinned React 17 and is unmaintained. Replace it with src/viewer/:
  orbitView.ts (pure camera transitions), viewerEngine.ts (canvas, WebGL context,
  frame loop, outside React) and JscadViewer.tsx (pointer events with capture,
  pinch zoom, keyboard rotate/pan/zoom). The GL context is released on unmount.

UI
- Use tooltheme (vendored tarball; its repo is private) as an app shell: header,
  viewer, inspector of property rows, status bar. App.css mirrors the shell rules
  onto #root because tooltheme's shell only matches direct children of <body>.
- Viewer colors come from tooltheme tokens and follow light/dark mode.
- autoform.tsx is typed against zod 4. Fixes: int() fields reported
  MAX_SAFE_INTEGER as max, making the width slider unusable; clearing a number
  box and retyping produced e.g. "1042".

Geometry
- Corner radius now works: vertical edges are rounded by extruding rounded
  rectangles, with inner outlines inset so walls stay even. Previously the
  setting was ignored.
- Small boxes with thick walls no longer fall back to a 1mm cube: the lid insert
  becomes solid, or is dropped, when there's no room for it.
- Box logic moved from App.tsx to box.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joshmarinacci
joshmarinacci merged commit 3a18116 into main Nov 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant