$ show ritz078/transform
This repository is a polyglot web converter application built with Next.js. It provides a large collection of code transformations (e.g., JSON to TypeScript, SVG to JSX, GraphQL to Resolvers, HTML to Pug, etc.) in a user-friendly two-pane editor interface. The architecture is a monolith with each transformation implemented as a separate page under `pages/`, all sharing a common `ConversionPanel` component that manages the input/output editors, web workers for heavy processing, and server-side API routes for a few transforms that require Node.js native modules. External dependencies include numerous npm libraries for the actual conversion logic (e.g., `json_typegen_wasm`, `@svgr/core`, `graphql-codegen`), the Monaco editor for code editing, and the evergreen-ui component library for the UI. The application uses web workers extensively (via a custom `workerWrapper` utility) to offload CPU-intensive conversions off the main thread, ensuring a responsive UI. Data flows from the user's input editor, through a transformer function (which may call a web worker or an API endpoint), and into the output editor, with results automatically formatted by Prettier. The codebase is well-structured with a consistent pattern for each converter, making it straightforward to add new transformations.
The LLM identified 2 files worth highlighting for reuse:
A small, self-contained utility that wraps a Web Worker to provide promise-based communication. It uses a monotonic message ID to correlate requests and responses, storing resolve/reject callbacks in a global map. This pattern can be extracted into any project that needs to communicate with web workers without managing events manually. It's a clean, reusable abstraction for worker-based task offloading.
A generic React hook for persisting state in sessionStorage with a version-prefixed key to avoid conflicts across deployments. It handles SSR gracefully and works like `useState` but persists the value across page reloads. This hook can be reused in any React application that needs session-persisted state without additional dependencies.