@deepnoid/canvas 0.1.74 → 0.1.76

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.
@@ -43,6 +43,7 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
43
43
  imageLoadingRef.current = true;
44
44
  const newEngineId = ++engineIdRef.current;
45
45
  const prevEngine = engineRef.current;
46
+ pendingAnnotationsRef.current = annotations;
46
47
  if (!image?.trim()) {
47
48
  if (prevEngine) {
48
49
  safeRemove(container, prevEngine.getImageCanvas());
@@ -86,10 +87,10 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
86
87
  annotationsCanvas,
87
88
  image: img,
88
89
  imageCanvasState,
89
- annotations: pendingAnnotationsRef.current ?? annotations,
90
+ annotations: pendingAnnotationsRef.current ?? [],
90
91
  setAnnotations: (next) => {
91
- if (engineIdRef.current === newEngineId) {
92
- setAnnotations?.(next);
92
+ if (engineIdRef.current === newEngineId && setAnnotations) {
93
+ setAnnotations(next);
93
94
  }
94
95
  },
95
96
  drawing,
@@ -140,12 +141,24 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
140
141
  }, [image, resetOnImageChange]);
141
142
  /* ---------- External annotations ---------- */
142
143
  useEffect(() => {
144
+ console.log('External annotations effect:', {
145
+ imageLoading: imageLoadingRef.current,
146
+ hasEngine: !!engineRef.current,
147
+ annotationsLength: annotations.length,
148
+ pendingLength: pendingAnnotationsRef.current?.length,
149
+ });
143
150
  if (imageLoadingRef.current || !engineRef.current) {
151
+ console.log('Saving to pending annotations');
144
152
  pendingAnnotationsRef.current = annotations;
145
153
  return;
146
154
  }
147
155
  const before = engineRef.current.getAnnotations();
156
+ console.log('Comparing annotations:', {
157
+ before: before.length,
158
+ after: annotations.length,
159
+ });
148
160
  if (JSON.stringify(before) !== JSON.stringify(annotations)) {
161
+ console.log('Setting new annotations to engine');
149
162
  engineRef.current.setAnnotations(annotations);
150
163
  engineRef.current.commitHistory();
151
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnoid/canvas",
3
- "version": "0.1.74",
3
+ "version": "0.1.76",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",