@deepnoid/canvas 0.1.77 → 0.1.79

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.
@@ -114,11 +114,14 @@ export class AnnotationEngine {
114
114
  this.drawCanvas(this.annotationsCanvas, undefined);
115
115
  }
116
116
  drawCanvas(canvas, image) {
117
- const { moveX, moveY, zoomX, zoomY, dx, dy, zoom } = this.getImageCanvasState();
118
117
  const context = canvas.getContext('2d');
119
118
  if (!context)
120
119
  return;
120
+ context.save();
121
+ context.setTransform(1, 0, 0, 1, 0, 0);
121
122
  context.clearRect(0, 0, canvas.width, canvas.height);
123
+ context.restore();
124
+ const { moveX, moveY, zoomX, zoomY, dx, dy, zoom } = this.getImageCanvasState();
122
125
  context.save();
123
126
  context.translate(dx, dy);
124
127
  context.translate(moveX, moveY);
@@ -43,7 +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
+ pendingAnnotationsRef.current = null;
47
47
  if (!image?.trim()) {
48
48
  if (prevEngine) {
49
49
  safeRemove(container, prevEngine.getImageCanvas());
@@ -87,7 +87,7 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
87
87
  annotationsCanvas,
88
88
  image: img,
89
89
  imageCanvasState,
90
- annotations: pendingAnnotationsRef.current ?? [],
90
+ annotations: [],
91
91
  setAnnotations: (next) => {
92
92
  if (engineIdRef.current === newEngineId && setAnnotations) {
93
93
  setAnnotations(next);
@@ -117,7 +117,6 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
117
117
  engineRef.current = engine;
118
118
  imageLoadingRef.current = false;
119
119
  if (pendingAnnotationsRef.current && pendingAnnotationsRef.current.length > 0) {
120
- console.log('Applying pending annotations after image load:', pendingAnnotationsRef.current.length);
121
120
  engine.setAnnotations(pendingAnnotationsRef.current);
122
121
  engine.commitHistory();
123
122
  }
@@ -146,24 +145,12 @@ const AnnotationCanvas = ({ image, annotations = [], setAnnotations, options, dr
146
145
  }, [image, resetOnImageChange]);
147
146
  /* ---------- External annotations ---------- */
148
147
  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
- });
155
148
  if (imageLoadingRef.current || !engineRef.current) {
156
- console.log('Saving to pending annotations');
157
149
  pendingAnnotationsRef.current = annotations;
158
150
  return;
159
151
  }
160
152
  const before = engineRef.current.getAnnotations();
161
- console.log('Comparing annotations:', {
162
- before: before.length,
163
- after: annotations.length,
164
- });
165
153
  if (JSON.stringify(before) !== JSON.stringify(annotations)) {
166
- console.log('Setting new annotations to engine');
167
154
  engineRef.current.setAnnotations(annotations);
168
155
  engineRef.current.commitHistory();
169
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnoid/canvas",
3
- "version": "0.1.77",
3
+ "version": "0.1.79",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",