@deepnoid/canvas 0.1.75 → 0.1.77

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.
@@ -115,8 +115,13 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
115
115
  prevEngine.destroy();
116
116
  }
117
117
  engineRef.current = engine;
118
- pendingAnnotationsRef.current = null;
119
118
  imageLoadingRef.current = false;
119
+ if (pendingAnnotationsRef.current && pendingAnnotationsRef.current.length > 0) {
120
+ console.log('Applying pending annotations after image load:', pendingAnnotationsRef.current.length);
121
+ engine.setAnnotations(pendingAnnotationsRef.current);
122
+ engine.commitHistory();
123
+ }
124
+ pendingAnnotationsRef.current = null;
120
125
  onImageLoadSuccess?.();
121
126
  });
122
127
  };
@@ -141,12 +146,24 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
141
146
  }, [image, resetOnImageChange]);
142
147
  /* ---------- External annotations ---------- */
143
148
  useEffect(() => {
149
+ console.log('External annotations effect:', {
150
+ imageLoading: imageLoadingRef.current,
151
+ hasEngine: !!engineRef.current,
152
+ annotationsLength: annotations.length,
153
+ pendingLength: pendingAnnotationsRef.current?.length,
154
+ });
144
155
  if (imageLoadingRef.current || !engineRef.current) {
156
+ console.log('Saving to pending annotations');
145
157
  pendingAnnotationsRef.current = annotations;
146
158
  return;
147
159
  }
148
160
  const before = engineRef.current.getAnnotations();
161
+ console.log('Comparing annotations:', {
162
+ before: before.length,
163
+ after: annotations.length,
164
+ });
149
165
  if (JSON.stringify(before) !== JSON.stringify(annotations)) {
166
+ console.log('Setting new annotations to engine');
150
167
  engineRef.current.setAnnotations(annotations);
151
168
  engineRef.current.commitHistory();
152
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnoid/canvas",
3
- "version": "0.1.75",
3
+ "version": "0.1.77",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",