@yogiswara/honcho-editor-ui 3.8.2 → 3.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,7 +47,7 @@ export interface UseHonchoEditorSingleActions {
47
47
  setBatchMode: (enabled: boolean) => void;
48
48
  startBatchMode: () => void;
49
49
  endBatchMode: () => void;
50
- updateFromSocket: (imageId: string, adjustmentTaskId: string, adjustment: ColorAdjustment) => void;
50
+ updateFromSocket: (imageId: string, adjustmentTaskId: string, adjustment: ColorAdjustment, preset_id?: string) => void;
51
51
  pushState: (state: AdjustmentState) => void;
52
52
  undo: () => void;
53
53
  redo: () => void;
@@ -166,8 +166,8 @@ export function useHonchoEditorSingle({ controller, initImageId, firebaseUid })
166
166
  sharpness: adjustments.sharpnessScore,
167
167
  };
168
168
  }, [adjustmentHistory.currentState]);
169
- const updateFromSocket = useCallback((imageId, adjustmentTaskId, adjustment) => {
170
- adjustmentHistory.actions.updateFromBackend(imageId, adjustmentTaskId, adjustment);
169
+ const updateFromSocket = useCallback((imageId, adjustmentTaskId, adjustment, preset_id) => {
170
+ adjustmentHistory.actions.updateFromBackend(imageId, adjustmentTaskId, adjustment, preset_id);
171
171
  }, [adjustmentHistory.actions.updateFromBackend]);
172
172
  const actions = {
173
173
  // Navigation
@@ -53,7 +53,7 @@ export interface HistoryActions {
53
53
  /** Sync history from backend using getEditorHistory */
54
54
  syncFromBackend: () => Promise<void>;
55
55
  /** Update specific history entry from backend without changing current index */
56
- updateFromBackend: (imageId: string, adjustmentTaskId: string, adjustment: ColorAdjustment) => void;
56
+ updateFromBackend: (imageId: string, adjustmentTaskId: string, adjustment: ColorAdjustment, preset_id?: string) => void;
57
57
  }
58
58
  /**
59
59
  * Configuration actions for runtime adjustment
@@ -22,7 +22,7 @@ const convertAdjustmentStateToColorAdjustment = (adjustmentState) => {
22
22
  /**
23
23
  * Convert ColorAdjustment from backend to AdjustmentState format
24
24
  */
25
- const convertColorAdjustmentToAdjustmentState = (colorAdjustment) => {
25
+ const convertColorAdjustmentToAdjustmentState = (colorAdjustment, preset_id) => {
26
26
  return {
27
27
  tempScore: colorAdjustment.temperature,
28
28
  tintScore: colorAdjustment.tint,
@@ -36,6 +36,7 @@ const convertColorAdjustmentToAdjustmentState = (colorAdjustment) => {
36
36
  blacksScore: colorAdjustment.blacks,
37
37
  clarityScore: colorAdjustment.clarity,
38
38
  sharpnessScore: Math.max(0, Math.min(100, colorAdjustment.sharpness)),
39
+ preset_id: preset_id,
39
40
  };
40
41
  };
41
42
  /**
@@ -579,32 +580,32 @@ export function useAdjustmentHistory(initialState, controller, firebaseUid, curr
579
580
  }
580
581
  }, [internalOptions]);
581
582
  // Update specific history entry from backend without changing current index
582
- const updateFromBackend = useCallback((imageId, adjustmentTaskId, adjustment) => {
583
+ const updateFromBackend = useCallback((imageId, adjustmentTaskId, adjustment, preset_id) => {
583
584
  // Ignore updates if imageID doesn't match current image
584
585
  if (imageId !== internalOptions.currentImageId) {
585
- console.log(`🚫 updateFromBackend: Ignoring update for different image (${imageId} vs ${internalOptions.currentImageId})`);
586
+ log.debug({ receivedImageId: imageId, currentImageId: internalOptions.currentImageId }, '🚫 updateFromBackend: Ignoring update for different image');
586
587
  return;
587
588
  }
588
589
  // Ignore updates during batch mode
589
590
  if (batchModeRef.current) {
590
- console.log(`🚫 updateFromBackend: Ignoring update during batch mode for taskId: ${adjustmentTaskId}`);
591
+ log.debug({ adjustmentTaskId }, '🚫 updateFromBackend: Ignoring update during batch mode for taskId');
591
592
  return;
592
593
  }
593
- console.log(`🔄 updateFromBackend: Received update for taskId: ${adjustmentTaskId}, imageId: ${imageId}`);
594
+ log.info({ adjustmentTaskId, imageId, preset_id }, '🔄 updateFromBackend: Received update');
594
595
  // Convert ColorAdjustment to AdjustmentState
595
- const updatedState = convertColorAdjustmentToAdjustmentState(adjustment);
596
+ const updatedState = convertColorAdjustmentToAdjustmentState(adjustment, preset_id);
596
597
  setHistory(prevHistory => {
597
598
  // Find the index of the task to update
598
599
  const taskIndex = prevHistory.findIndex(entry => entry.taskId === adjustmentTaskId);
599
600
  if (taskIndex === -1) {
600
601
  // Task doesn't exist in current history, we need to sync from backend
601
602
  // to get the complete history with proper chronological order
602
- console.log(`📝 updateFromBackend: TaskId ${adjustmentTaskId} not found in current history, triggering sync from backend`);
603
+ log.info({ adjustmentTaskId }, '📝 updateFromBackend: TaskId not found in current history, triggering sync from backend');
603
604
  // Don't modify history here, instead trigger a sync
604
605
  // Use setTimeout to avoid calling async function inside setState
605
606
  setTimeout(() => {
606
607
  syncFromBackend().catch(error => {
607
- console.error('❌ Failed to sync history after unknown taskId:', error);
608
+ log.error({ error, adjustmentTaskId }, '❌ Failed to sync history after unknown taskId');
608
609
  });
609
610
  }, 0);
610
611
  // Return unchanged history for now
@@ -613,10 +614,10 @@ export function useAdjustmentHistory(initialState, controller, firebaseUid, curr
613
614
  // Task exists, check if it's the current index
614
615
  const isCurrentIndex = taskIndex === currentIndexRef.current;
615
616
  if (isCurrentIndex) {
616
- console.log(`🔄 updateFromBackend: Updating current index (${taskIndex}) but not changing current state`);
617
+ log.debug({ taskIndex }, '🔄 updateFromBackend: Updating current index but not changing current state');
617
618
  }
618
619
  else {
619
- console.log(`🔄 updateFromBackend: Updating history entry at index ${taskIndex} (far behind current ${currentIndexRef.current})`);
620
+ log.debug({ taskIndex, currentIndex: currentIndexRef.current }, '🔄 updateFromBackend: Updating history entry far behind current');
620
621
  }
621
622
  // Update the specific history entry
622
623
  const updatedHistory = [...prevHistory];
@@ -626,7 +627,7 @@ export function useAdjustmentHistory(initialState, controller, firebaseUid, curr
626
627
  };
627
628
  return updatedHistory;
628
629
  });
629
- console.log(`✅ updateFromBackend: Successfully updated taskId ${adjustmentTaskId}`);
630
+ log.info({ adjustmentTaskId }, '✅ updateFromBackend: Successfully updated taskId');
630
631
  }, [internalOptions]);
631
632
  // History info object
632
633
  const historyInfo = useMemo(() => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "3.8.2",
3
+ "version": "3.8.3",
4
4
  "description": "A complete UI component library for the Honcho photo editor.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",