T24: Use shared types from cad.types.ts in importService
This commit is contained in:
@@ -1,55 +1,10 @@
|
||||
import type { YjsDocument } from '../crdt/YjsDocument';
|
||||
|
||||
// ── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
interface CADLayer {
|
||||
id: string;
|
||||
name: string;
|
||||
visible: boolean;
|
||||
locked: boolean;
|
||||
color?: string;
|
||||
lineType?: string;
|
||||
transparency?: number;
|
||||
sortOrder?: number;
|
||||
}
|
||||
|
||||
interface CADProperties {
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
rotation?: number;
|
||||
lineType?: 'solid' | 'dashed' | 'dotted';
|
||||
radius?: number;
|
||||
x1?: number;
|
||||
y1?: number;
|
||||
x2?: number;
|
||||
y2?: number;
|
||||
points?: Array<{ x: number; y: number }>;
|
||||
text?: string;
|
||||
fontSize?: number;
|
||||
startAngle?: number;
|
||||
endAngle?: number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
interface CADElement {
|
||||
id: string;
|
||||
type: string;
|
||||
layerId: string;
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
properties: CADProperties;
|
||||
}
|
||||
|
||||
interface ImportData {
|
||||
version: string;
|
||||
exportedAt: number;
|
||||
projectMeta: Record<string, unknown>;
|
||||
layers: CADLayer[];
|
||||
elements: CADElement[];
|
||||
}
|
||||
import type {
|
||||
CADLayer,
|
||||
CADProperties,
|
||||
CADElement,
|
||||
ImportData,
|
||||
} from '../types/cad.types';
|
||||
|
||||
export interface ImportResult {
|
||||
success: boolean;
|
||||
@@ -59,7 +14,7 @@ export interface ImportResult {
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
// ── JSON Import ──────────────────────────────────────────────────────────────
|
||||
// ── JSON Import ───────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Import a JSON string (from exportJSON) into a YjsDocument.
|
||||
@@ -173,7 +128,7 @@ export async function importJSONFile(file: File, yjsDoc: YjsDocument): Promise<I
|
||||
return importJSON(text, yjsDoc);
|
||||
}
|
||||
|
||||
// ── DXF Import (basic) ───────────────────────────────────────────────────────
|
||||
// ── DXF Import (basic) ────────────────────────────────────────────────────────
|
||||
|
||||
interface DxfEntity {
|
||||
type: string;
|
||||
@@ -491,7 +446,7 @@ export async function importDXFFile(file: File, yjsDoc: YjsDocument): Promise<Im
|
||||
return importDXF(text, yjsDoc);
|
||||
}
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────────────
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
function aciToHex(aci: number): string {
|
||||
const aciMap: Record<number, string> = {
|
||||
@@ -506,7 +461,7 @@ function aciToHex(aci: number): string {
|
||||
return aciMap[aci] || '#000000';
|
||||
}
|
||||
|
||||
// ── Unified Import ───────────────────────────────────────────────────────────
|
||||
// ── Unified Import ────────────────────────────────────────────────────────────
|
||||
|
||||
export type ImportFormat = 'json' | 'dxf';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user