mirror of
https://github.com/jhbruhn/respira.git
synced 2026-01-27 10:23:41 +00:00
feature: Reorganize code into formats folder structure
Moved embroidery format-related code from utils to new formats folder: Structure: - src/formats/pen/ - PEN format encoding and parsing - encoder.ts (was utils/penEncoder.ts) - encoder.test.ts (was utils/penEncoder.test.ts) - parser.ts (was utils/penParser.ts) - PEN constants moved inline to encoder.ts - src/formats/import/ - Pattern import/conversion (currently PES) - worker.ts (was workers/patternConverter.worker.ts) - client.ts (was utils/patternConverterClient.ts) - pesImporter.ts (was utils/pystitchConverter.ts) - pyodideLoader.ts (was utils/pyodideLoader.ts) - constants.ts (PyStitch/pyembroidery constants) Benefits: - Better separation of concerns - PEN encoder is co-located with PEN parser - Import logic is in one place and extensible for other formats - Removed utils/embroideryConstants.ts - split into appropriate locations - Updated all 18 import references across the codebase All tests passing, build successful. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b09f97afef
commit
11b710eb17
20 changed files with 33 additions and 41 deletions
|
|
@ -3,7 +3,7 @@ import { useShallow } from 'zustand/react/shallow';
|
|||
import { useMachineStore } from '../stores/useMachineStore';
|
||||
import { usePatternStore } from '../stores/usePatternStore';
|
||||
import { useUIStore } from '../stores/useUIStore';
|
||||
import { convertPesToPen, type PesPatternData } from '../utils/pystitchConverter';
|
||||
import { convertPesToPen, type PesPatternData } from '../formats/import/pesImporter';
|
||||
import { canUploadPattern, getMachineStateCategory } from '../utils/machineStateHelpers';
|
||||
import { PatternInfoSkeleton } from './SkeletonLoader';
|
||||
import { ArrowUpTrayIcon, CheckCircleIcon, DocumentTextIcon, FolderOpenIcon } from '@heroicons/react/24/solid';
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { memo, useMemo } from 'react';
|
||||
import { Group, Line, Rect, Text, Circle } from 'react-konva';
|
||||
import type { PesPatternData } from '../utils/pystitchConverter';
|
||||
import { getThreadColor } from '../utils/pystitchConverter';
|
||||
import type { PesPatternData } from '../formats/import/pesImporter';
|
||||
import { getThreadColor } from '../formats/import/pesImporter';
|
||||
import type { MachineInfo } from '../types/machine';
|
||||
import { MOVE } from '../utils/embroideryConstants';
|
||||
import { MOVE } from '../formats/import/constants';
|
||||
|
||||
interface GridProps {
|
||||
gridSize: number;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { usePatternStore } from '../stores/usePatternStore';
|
|||
import { Stage, Layer, Group } from 'react-konva';
|
||||
import Konva from 'konva';
|
||||
import { PlusIcon, MinusIcon, ArrowPathIcon, LockClosedIcon, PhotoIcon, ArrowsPointingInIcon } from '@heroicons/react/24/solid';
|
||||
import type { PesPatternData } from '../utils/pystitchConverter';
|
||||
import type { PesPatternData } from '../formats/import/pesImporter';
|
||||
import { calculateInitialScale } from '../utils/konvaRenderers';
|
||||
import { Grid, Origin, Hoop, Stitches, PatternBounds, CurrentPosition } from './KonvaComponents';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { WorkerMessage, WorkerResponse } from '../workers/patternConverter.worker';
|
||||
import PatternConverterWorker from '../workers/patternConverter.worker?worker';
|
||||
import { parsePenData } from './penParser';
|
||||
import type { PenData } from '../types/machine';
|
||||
import type { WorkerMessage, WorkerResponse } from './worker';
|
||||
import PatternConverterWorker from './worker?worker';
|
||||
import { parsePenData } from '../pen/parser';
|
||||
import type { PenData } from '../../types/machine';
|
||||
|
||||
export type PyodideState = 'not_loaded' | 'loading' | 'ready' | 'error';
|
||||
|
||||
|
|
@ -15,9 +15,3 @@ export const TRIM = 0x20; // Trim thread command
|
|||
export const COLOR_CHANGE = 0x40; // Color change command
|
||||
export const STOP = 0x80; // Stop command
|
||||
export const END = 0x100; // End of pattern
|
||||
|
||||
// PEN format flags for Brother machines
|
||||
export const PEN_FEED_DATA = 0x01; // Bit 0: Jump stitch (move without stitching)
|
||||
export const PEN_CUT_DATA = 0x02; // Bit 1: Trim/cut thread command
|
||||
export const PEN_COLOR_END = 0x03; // Last stitch before color change
|
||||
export const PEN_DATA_END = 0x05; // Last stitch of entire pattern
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { patternConverterClient, type PesPatternData } from "./patternConverterClient";
|
||||
import { patternConverterClient, type PesPatternData } from "./client";
|
||||
|
||||
// Re-export the type for backwards compatibility
|
||||
export type { PesPatternData };
|
||||
|
|
@ -4,8 +4,8 @@ import {
|
|||
MOVE,
|
||||
TRIM,
|
||||
END,
|
||||
} from '../utils/embroideryConstants';
|
||||
import { encodeStitchesToPen } from '../utils/penEncoder';
|
||||
} from './constants';
|
||||
import { encodeStitchesToPen } from '../pen/encoder';
|
||||
|
||||
// Message types from main thread
|
||||
export type WorkerMessage =
|
||||
|
|
@ -4,8 +4,8 @@ import {
|
|||
calculateLockDirection,
|
||||
generateLockStitches,
|
||||
encodeStitchesToPen,
|
||||
} from './penEncoder';
|
||||
import { STITCH, MOVE, TRIM, END } from './embroideryConstants';
|
||||
} from './encoder';
|
||||
import { STITCH, MOVE, TRIM, END } from '../import/constants';
|
||||
|
||||
// PEN format flag constants for testing
|
||||
const PEN_FEED_DATA = 0x01;
|
||||
|
|
@ -5,15 +5,13 @@
|
|||
* The PEN format uses absolute coordinates shifted left by 3 bits, with flags in the low 3 bits.
|
||||
*/
|
||||
|
||||
import {
|
||||
MOVE,
|
||||
TRIM,
|
||||
END,
|
||||
PEN_FEED_DATA,
|
||||
PEN_CUT_DATA,
|
||||
PEN_COLOR_END,
|
||||
PEN_DATA_END,
|
||||
} from './embroideryConstants';
|
||||
import { MOVE, TRIM, END } from '../import/constants';
|
||||
|
||||
// PEN format flags for Brother machines
|
||||
const PEN_FEED_DATA = 0x01; // Bit 0: Jump stitch (move without stitching)
|
||||
const PEN_CUT_DATA = 0x02; // Bit 1: Trim/cut thread command
|
||||
const PEN_COLOR_END = 0x03; // Last stitch before color change
|
||||
const PEN_DATA_END = 0x05; // Last stitch of entire pattern
|
||||
|
||||
// Constants from PesxToPen.cs
|
||||
const FEED_LENGTH = 50; // Long jump threshold requiring lock stitches and cut
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PenData, PenStitch, PenColorBlock } from '../types/machine';
|
||||
import type { PenData, PenStitch, PenColorBlock } from '../../types/machine';
|
||||
|
||||
// PEN format flags
|
||||
const PEN_FEED_DATA = 0x01; // Y-coordinate low byte, bit 0
|
||||
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from "../services/PatternCacheService";
|
||||
import type { IStorageService } from "../platform/interfaces/IStorageService";
|
||||
import { createStorageService } from "../platform";
|
||||
import type { PesPatternData } from "../utils/pystitchConverter";
|
||||
import type { PesPatternData } from "../formats/import/pesImporter";
|
||||
import { SewingMachineError } from "../utils/errorCodeHelpers";
|
||||
|
||||
export function useBrotherMachine() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { PatternCacheService } from '../../services/PatternCacheService';
|
||||
import type { IStorageService, ICachedPattern } from '../interfaces/IStorageService';
|
||||
import type { PesPatternData } from '../../utils/pystitchConverter';
|
||||
import type { PesPatternData } from '../../formats/import/pesImporter';
|
||||
|
||||
/**
|
||||
* Browser implementation of storage service using localStorage
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { IStorageService, ICachedPattern } from '../interfaces/IStorageService';
|
||||
import type { PesPatternData } from '../../utils/pystitchConverter';
|
||||
import type { PesPatternData } from '../../formats/import/pesImporter';
|
||||
|
||||
/**
|
||||
* Electron implementation of storage service using electron-store via IPC
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PesPatternData } from '../../utils/pystitchConverter';
|
||||
import type { PesPatternData } from '../../formats/import/pesImporter';
|
||||
|
||||
export interface ICachedPattern {
|
||||
uuid: string;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { PesPatternData } from '../utils/pystitchConverter';
|
||||
import type { PesPatternData } from '../formats/import/pesImporter';
|
||||
|
||||
interface CachedPattern {
|
||||
uuid: string;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { SewingMachineError } from '../utils/errorCodeHelpers';
|
|||
import { uuidToString } from '../services/PatternCacheService';
|
||||
import { createStorageService } from '../platform';
|
||||
import type { IStorageService } from '../platform/interfaces/IStorageService';
|
||||
import type { PesPatternData } from '../utils/pystitchConverter';
|
||||
import type { PesPatternData } from '../formats/import/pesImporter';
|
||||
|
||||
interface MachineState {
|
||||
// Service instances
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { create } from 'zustand';
|
||||
import type { PesPatternData } from '../utils/pystitchConverter';
|
||||
import type { PesPatternData } from '../formats/import/pesImporter';
|
||||
|
||||
interface PatternState {
|
||||
// Pattern data
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { create } from 'zustand';
|
||||
import { patternConverterClient } from '../utils/patternConverterClient';
|
||||
import { patternConverterClient } from '../formats/import/client';
|
||||
|
||||
interface UIState {
|
||||
// Pyodide state
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import Konva from 'konva';
|
||||
import type { PesPatternData } from './pystitchConverter';
|
||||
import { getThreadColor } from './pystitchConverter';
|
||||
import type { PesPatternData } from '../formats/import/pesImporter';
|
||||
import { getThreadColor } from '../formats/import/pesImporter';
|
||||
import type { MachineInfo } from '../types/machine';
|
||||
import { MOVE } from './embroideryConstants';
|
||||
import { MOVE } from '../formats/import/constants';
|
||||
|
||||
/**
|
||||
* Renders a grid with specified spacing
|
||||
|
|
|
|||
Loading…
Reference in a new issue