refactor(import): add v4section/v4url aliases, inline clamp wrappers, replace classes with fns

Finding 5: Introduce V4Url + V4Section<T> type aliases in reactive-resume-v4-json.tsx; collapse
310-line V4ResumeData type (13x 5-field section header, 11x {label,href}) into typed aliases.
Inferred shape is structurally identical.

Finding 6: Remove 9 single-caller clamp/pxToPt wrappers; replace compile-time constants
(rotation=0, sidebarWidth=35, shadowWidth=0, gapX=4, gapY=6) with literals; inline dynamic
calls (clamp(x, 32, 512) etc.) at the two body/heading typography call sites.

Finding 7: Convert three stateless single-method importer classes to plain functions.
Extract shared rethrowAsImportError() to error.ts, replacing triplicated ZodError catch blocks.
Update web import dialog + all in-package test files to use function API.

Claude-Session: https://claude.ai/code/session_012Bnvt1MghwHj4qQRxuQUGa
This commit is contained in:
Amruth Pillai
2026-07-04 21:02:17 +02:00
parent 493ef12a9a
commit afd734dd61
9 changed files with 834 additions and 1026 deletions
+6 -12
View File
@@ -9,9 +9,9 @@ import { Link, useNavigate } from "@tanstack/react-router";
import { useRef, useState } from "react";
import { toast } from "sonner";
import z from "zod";
import { JSONResumeImporter } from "@reactive-resume/import/json-resume";
import { ReactiveResumeJSONImporter } from "@reactive-resume/import/reactive-resume-json";
import { ReactiveResumeV4JSONImporter } from "@reactive-resume/import/reactive-resume-v4-json";
import { parseJSONResume } from "@reactive-resume/import/json-resume";
import { parseReactiveResumeJSON } from "@reactive-resume/import/reactive-resume-json";
import { parseReactiveResumeV4JSON } from "@reactive-resume/import/reactive-resume-v4-json";
import { Badge } from "@reactive-resume/ui/components/badge";
import { Button } from "@reactive-resume/ui/components/button";
import {
@@ -167,21 +167,15 @@ export function ImportResumeDialog(_: DialogProps<"resume.import">) {
let data: ResumeData | undefined;
if (value.type === "json-resume-json") {
const json = await value.file.text();
const importer = new JSONResumeImporter();
data = importer.parse(json);
data = parseJSONResume(await value.file.text());
}
if (value.type === "reactive-resume-json") {
const json = await value.file.text();
const importer = new ReactiveResumeJSONImporter();
data = importer.parse(json);
data = parseReactiveResumeJSON(await value.file.text());
}
if (value.type === "reactive-resume-v4-json") {
const json = await value.file.text();
const importer = new ReactiveResumeV4JSONImporter();
data = importer.parse(json);
data = parseReactiveResumeV4JSON(await value.file.text());
}
if (value.type === "pdf") {