From e0e81fd729bfc230bdbfa7d42b65f07708c02899 Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Sat, 11 Oct 2025 12:31:03 -0500 Subject: [PATCH] eliminate moduleNameMapper --- jest.config.mjs | 10 ---------- src/cli.ts | 12 ++++++------ src/drivers.ts | 2 +- src/ebb.ts | 4 ++-- src/massager.ts | 6 +++--- src/paper-size.ts | 2 +- src/planning.ts | 7 ++++--- src/server.ts | 10 +++++----- src/ui.tsx | 4 ++-- src/util.ts | 4 ++-- tsconfig.json | 2 +- 11 files changed, 27 insertions(+), 36 deletions(-) diff --git a/jest.config.mjs b/jest.config.mjs index dfcd2e91..3d4d6f3e 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -1,13 +1,3 @@ export default { preset: 'ts-jest', - moduleNameMapper: { - './ebb.js': './ebb.ts', - './massager.js': './massager.ts', - './paper-size.js': './paper-size.ts', - './planning.js': './planning.ts', - './serialport-serialport.js': './serialport-serialport.ts', - './server.js': './server.ts', - './util.js': './util.ts', - './vec.js': './vec.ts', - }, }; diff --git a/src/cli.ts b/src/cli.ts index 0e0e3431..ee4fcc5f 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -7,12 +7,12 @@ import { flattenSVG } from "flatten-svg"; import { Window } from "svgdom"; import yargs from "yargs"; import { hideBin } from 'yargs/helpers'; -import type { Hardware } from "./ebb.js"; -import { replan } from "./massager.js"; -import { PaperSize } from "./paper-size.js"; -import { Device, type PlanOptions, defaultPlanOptions } from "./planning.js"; -import { connectEBB, startServer } from "./server.js"; -import { formatDuration } from "./util.js"; +import type { Hardware } from "./ebb"; +import { replan } from "./massager"; +import { PaperSize } from "./paper-size"; +import { Device, defaultPlanOptions, type PlanOptions } from "./planning"; +import { connectEBB, startServer } from "./server"; +import { formatDuration } from "./util"; function parseSvg(svg: string) { const window = new Window; diff --git a/src/drivers.ts b/src/drivers.ts index d3f69e87..899998da 100644 --- a/src/drivers.ts +++ b/src/drivers.ts @@ -1,6 +1,6 @@ import { EBB, type Hardware } from "./ebb"; -import { Device, PenMotion, Plan } from "./planning.js"; +import { Device, PenMotion, Plan } from "./planning"; export interface DeviceInfo { path: string; diff --git a/src/ebb.ts b/src/ebb.ts index 905ec5da..bd11bc61 100644 --- a/src/ebb.ts +++ b/src/ebb.ts @@ -1,5 +1,5 @@ -import { type Block, type Motion, PenMotion, type Plan, XYMotion } from "./planning.js"; -import { type Vec2, vsub } from "./vec.js"; +import { type Block, type Motion, PenMotion, type Plan, XYMotion } from "./planning"; +import { type Vec2, vsub } from "./vec"; enum MicrostepMode { DISABLED=0, diff --git a/src/massager.ts b/src/massager.ts index 8829191b..9c4f7427 100644 --- a/src/massager.ts +++ b/src/massager.ts @@ -1,8 +1,8 @@ import type { Path } from "flatten-svg"; import { elideShorterThan, merge as joinNearbyPaths, reorder as sortPaths } from "optimize-paths"; -import { Device, type Plan, type PlanOptions, plan } from "./planning.js"; -import { cropToMargins, dedupPoints, scaleToPaper } from "./util.js"; -import { type Vec2, vmul, vrot } from "./vec.js"; +import { Device, type Plan, type PlanOptions, plan } from "./planning"; +import { cropToMargins, dedupPoints, scaleToPaper } from "./util"; +import { type Vec2, vmul, vrot } from "./vec"; // CSS, and thus SVG, defines 1px = 1/96th of 1in diff --git a/src/paper-size.ts b/src/paper-size.ts index c208c95e..bdcd8d9d 100644 --- a/src/paper-size.ts +++ b/src/paper-size.ts @@ -1,4 +1,4 @@ -import { type Vec2, vmul } from "./vec.js"; +import { type Vec2, vmul } from "./vec"; function vround(v: Vec2, digits = 2): Vec2 { return { x: Number(v.x.toFixed(digits)), y: Number(v.y.toFixed(digits)) }; diff --git a/src/planning.ts b/src/planning.ts index 521a86a9..75c0f162 100644 --- a/src/planning.ts +++ b/src/planning.ts @@ -1,7 +1,8 @@ // Cribbed from https://github.com/fogleman/axi/blob/master/axi/planner.py -import type { Hardware } from './ebb.js'; -import { PaperSize } from './paper-size.js'; -import { type Vec2, vadd, vdot, vlen, vmul, vnorm, vsub } from './vec.js'; +import type { Hardware } from './ebb'; +import { PaperSize } from './paper-size'; +import { type Vec2, vadd, vdot, vlen, vmul, vnorm, vsub } from './vec'; + const epsilon = 1e-9; export interface PlanOptions { diff --git a/src/server.ts b/src/server.ts index 81a69a4f..b501a1d5 100644 --- a/src/server.ts +++ b/src/server.ts @@ -15,11 +15,11 @@ import type { Request, Response } from "express"; import express from "express"; import type WebSocket from 'ws'; import { WebSocketServer } from 'ws'; -import { EBB, type Hardware } from './ebb.js'; -import { type Motion, PenMotion, Plan } from "./planning.js"; -import { SerialPortSerialPort } from "./serialport-serialport.js"; -import * as _self from './server.js'; // use self-import for test mocking -import { formatDuration } from "./util.js"; +import { EBB, type Hardware } from './ebb'; +import { type Motion, PenMotion, Plan } from "./planning"; +import { SerialPortSerialPort } from "./serialport-serialport"; +import * as _self from './server'; // use self-import for test mocking +import { formatDuration } from "./util"; type Com = string diff --git a/src/ui.tsx b/src/ui.tsx index a039e63c..0d426360 100644 --- a/src/ui.tsx +++ b/src/ui.tsx @@ -8,8 +8,8 @@ import { flattenSVG, type Path } from "flatten-svg"; import React, { type ChangeEvent, Fragment, useContext, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react"; import { createRoot } from 'react-dom/client'; import { PaperSize } from "./paper-size"; -import { Device, defaultPlanOptions, type MotionData, Plan, type PlanOptions, XYMotion } from "./planning.js"; -import { formatDuration } from "./util.js"; +import { Device, defaultPlanOptions, type MotionData, Plan, type PlanOptions, XYMotion } from "./planning"; +import { formatDuration } from "./util"; import "./style.css"; import { type BaseDriver, type DeviceInfo, SaxiDriver, WebSerialDriver } from "./drivers"; diff --git a/src/util.ts b/src/util.ts index 7711df9a..8d8e6d45 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,5 +1,5 @@ -import type { PaperSize } from "./paper-size.js"; -import { type Vec2, vadd, vlen2, vmul, vsub } from "./vec.js"; +import type { PaperSize } from "./paper-size"; +import { type Vec2, vadd, vlen2, vmul, vsub } from "./vec"; /** Format a smallish duration in 2h30m15s form */ export function formatDuration(seconds: number): string { diff --git a/tsconfig.json b/tsconfig.json index 6656763e..69b2ea24 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "moduleResolution": "node", "esModuleInterop": true, "noImplicitAny": true, - "jsx": "react", + "jsx": "react" }, } \ No newline at end of file