fix: SQLite boolean binding, CSS brace, race condition, 0 npm vulns, code-splitting
This commit is contained in:
@@ -55,6 +55,10 @@ export class InteractionEngine {
|
||||
private onTextEdit?: (el: CADElement) => void;
|
||||
private onSelectionChange?: (selectedIds: string[]) => void;
|
||||
private animationFrame: number | null = null;
|
||||
private boundKeyDown: EventListener;
|
||||
private boundMouseMove: EventListener;
|
||||
private boundMouseUp: EventListener;
|
||||
private boundPointerCancel: EventListener;
|
||||
|
||||
constructor(
|
||||
canvas: HTMLCanvasElement,
|
||||
@@ -89,6 +93,10 @@ export class InteractionEngine {
|
||||
undoKey: 'z',
|
||||
redoKey: 'y',
|
||||
};
|
||||
this.boundKeyDown = this.onKeyDown.bind(this) as EventListener;
|
||||
this.boundMouseMove = this.onMouseMove.bind(this) as EventListener;
|
||||
this.boundMouseUp = this.onMouseUp.bind(this) as EventListener;
|
||||
this.boundPointerCancel = this.onMouseUp.bind(this) as EventListener;
|
||||
}
|
||||
|
||||
setElements(elements: CADElement[]): void {
|
||||
@@ -156,13 +164,14 @@ export class InteractionEngine {
|
||||
}
|
||||
|
||||
attach(): void {
|
||||
this.addListener('mousedown', this.onMouseDown.bind(this) as EventListener);
|
||||
this.addListener('mousemove', this.onMouseMove.bind(this) as EventListener);
|
||||
this.addListener('mouseup', this.onMouseUp.bind(this) as EventListener);
|
||||
this.addListener('pointerdown', this.onMouseDown.bind(this) as EventListener);
|
||||
document.addEventListener('pointermove', this.boundMouseMove);
|
||||
document.addEventListener('pointerup', this.boundMouseUp);
|
||||
document.addEventListener('pointercancel', this.boundPointerCancel);
|
||||
this.addListener('dblclick', this.onDoubleClick.bind(this) as EventListener);
|
||||
this.addListener('wheel', this.onWheel.bind(this) as EventListener, { passive: false } as AddEventListenerOptions);
|
||||
this.addListener('contextmenu', this.onContextMenu.bind(this) as EventListener);
|
||||
document.addEventListener('keydown', this.onKeyDown.bind(this) as EventListener);
|
||||
document.addEventListener('keydown', this.boundKeyDown);
|
||||
}
|
||||
|
||||
detach(): void {
|
||||
@@ -170,7 +179,10 @@ export class InteractionEngine {
|
||||
this.canvas.removeEventListener(type, fn);
|
||||
}
|
||||
this.eventListeners = [];
|
||||
document.removeEventListener('keydown', this.onKeyDown.bind(this) as EventListener);
|
||||
document.removeEventListener('pointermove', this.boundMouseMove);
|
||||
document.removeEventListener('pointerup', this.boundMouseUp);
|
||||
document.removeEventListener('pointercancel', this.boundPointerCancel);
|
||||
document.removeEventListener('keydown', this.boundKeyDown);
|
||||
if (this.animationFrame !== null) {
|
||||
cancelAnimationFrame(this.animationFrame);
|
||||
this.animationFrame = null;
|
||||
@@ -214,7 +226,7 @@ export class InteractionEngine {
|
||||
}
|
||||
|
||||
private onMouseDown(e: MouseEvent): void {
|
||||
e.preventDefault();
|
||||
try { this.canvas.setPointerCapture((e as any).pointerId); } catch {}
|
||||
this.isMouseDown = true;
|
||||
this.lastMouseScreen = { x: e.clientX, y: e.clientY };
|
||||
|
||||
@@ -289,6 +301,10 @@ export class InteractionEngine {
|
||||
}
|
||||
|
||||
private onMouseMove(e: MouseEvent): void {
|
||||
if (this.state.phase === 'idle' && !this.isMouseDown) {
|
||||
const rect = this.canvas.getBoundingClientRect();
|
||||
if (e.clientX < rect.left || e.clientX > rect.right || e.clientY < rect.top || e.clientY > rect.bottom) return;
|
||||
}
|
||||
this.lastMouseScreen = { x: e.clientX, y: e.clientY };
|
||||
const raw = this.getWorldCoords(e);
|
||||
this.onCursorMoved?.(raw.x, raw.y);
|
||||
@@ -329,7 +345,7 @@ export class InteractionEngine {
|
||||
}
|
||||
|
||||
private onMouseUp(e: MouseEvent): void {
|
||||
e.preventDefault();
|
||||
try { this.canvas.releasePointerCapture((e as any).pointerId); } catch {}
|
||||
this.isMouseDown = false;
|
||||
|
||||
if (e.button === 2 || (e.button === 1 && this.state.phase === 'panning')) {
|
||||
@@ -359,7 +375,7 @@ export class InteractionEngine {
|
||||
const final = this.applyOrtho(snapped.x, snapped.y);
|
||||
const tool = this.state.activeTool;
|
||||
// For 2-point tools: use mouseup position as second point
|
||||
if (tool === 'line' || tool === 'rect' || tool === 'circle' || tool === 'dimension' || tool === 'leader') {
|
||||
if (tool === 'line' || tool === 'rect' || tool === 'circle' || tool === 'dimension' || tool === 'leader' || tool === 'arc' || tool === 'polygon' || tool === 'revcloud') {
|
||||
this.state.points.push(final);
|
||||
this.confirmDraw();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user