|
1 | 1 | import type {Point} from '@flatten-js/core'; |
2 | 2 | import {isEqual} from 'es-toolkit'; |
3 | | -import type {Actor, MachineSnapshot} from 'xstate'; |
4 | 3 | import {toast} from 'react-toastify'; |
| 4 | +import type {Actor, MachineSnapshot} from 'xstate'; |
5 | 5 | import {type HoverPoint, HtmlEvent, type Layer, type SnapPoint, type StateMetaData,} from './App.types'; |
6 | 6 | import type {ScreenCanvasDrawController} from './drawControllers/screenCanvas.drawController'; |
7 | 7 | import type {Entity} from './entities/Entity'; |
@@ -203,23 +203,27 @@ export const setActiveToolActor = ( |
203 | 203 |
|
204 | 204 | activeToolActor = newToolActor; |
205 | 205 | activeToolActor.subscribe({ |
206 | | - // biome-ignore lint/suspicious/noExplicitAny: <explanation> |
207 | | - next: (state: MachineSnapshot<any, any, any, any, any, any, any, any>) => { |
208 | | - const stateInstructions = Object.values(state?.getMeta() as Record<string, StateMetaData>)[0] |
209 | | - ?.instructions; |
210 | | - |
211 | | - if (getLastStateInstructions() === stateInstructions) { |
212 | | - return; |
213 | | - } |
214 | | - |
215 | | - setLastStateInstructions(stateInstructions || null); |
216 | | - }, |
217 | | - error: (err) => { |
218 | | - toast.error(`Error in tool actor: ${err?.message}`); |
219 | | - console.error('Error in tool actor', {err, newToolActor}); |
| 206 | + // biome-ignore lint/suspicious/noExplicitAny: <explanation> |
| 207 | + next: (state: MachineSnapshot<any, any, any, any, any, any, any, any>) => { |
| 208 | + const stateInstructions = Object.values(state?.getMeta() as Record<string, StateMetaData>)[0] |
| 209 | + ?.instructions; |
| 210 | + |
| 211 | + if (getLastStateInstructions() === stateInstructions) { |
| 212 | + return; |
220 | 213 | } |
221 | | - } |
222 | | - ); |
| 214 | + |
| 215 | + setLastStateInstructions(stateInstructions || null); |
| 216 | + }, |
| 217 | + error: (err) => { |
| 218 | + toast.error( |
| 219 | + `Error in tool actor: ${ |
| 220 | + // biome-ignore lint/suspicious/noExplicitAny: <explanation> |
| 221 | + (err as any)?.message || 'unknown error' |
| 222 | + }` |
| 223 | + ); |
| 224 | + console.error('Error in tool actor', { err, newToolActor }); |
| 225 | + }, |
| 226 | + }); |
223 | 227 | activeToolActor.start(); |
224 | 228 |
|
225 | 229 | console.log('User clicked on tool: ', { |
@@ -362,7 +366,7 @@ function trackUndoState(variable: StateVariable, value: any) { |
362 | 366 | } |
363 | 367 |
|
364 | 368 | // Push the new undo state |
365 | | - undoStack.push({variable: variable, value: value}); |
| 369 | + undoStack.push({ variable: variable, value: value }); |
366 | 370 | } |
367 | 371 |
|
368 | 372 | function updateStates(undoState: UndoState) { |
|
0 commit comments