bdsa-react-components 0.1.7 → 0.1.8

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.
@@ -1,6 +1,6 @@
1
1
  # bdsa-react-components - CURSOR Integration Guide
2
2
 
3
- **Version:** 0.1.7 | **Generated:** 2025-11-02T21:57:14.327Z
3
+ **Version:** 0.1.8 | **Generated:** 2025-11-03T14:33:04.861Z
4
4
 
5
5
  > This document provides everything Cursor needs to integrate and use the bdsa-react-components library.
6
6
  > Copy this entire document into your project's .cursorrules or docs folder.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bdsa-react-components",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Reusable React components for the Digital Slide Archive project",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -16,6 +16,7 @@
16
16
  },
17
17
  "files": [
18
18
  "dist",
19
+ "patches",
19
20
  "README.md",
20
21
  "CHANGELOG.md",
21
22
  "INTEGRATION.md",
@@ -0,0 +1,158 @@
1
+ diff --git a/node_modules/osd-paperjs-annotation/src/js/paper-overlay.mjs b/node_modules/osd-paperjs-annotation/src/js/paper-overlay.mjs
2
+ index 5f5aa6e..fb7937f 100644
3
+ --- a/node_modules/osd-paperjs-annotation/src/js/paper-overlay.mjs
4
+ +++ b/node_modules/osd-paperjs-annotation/src/js/paper-overlay.mjs
5
+ @@ -200,7 +200,14 @@ class PaperOverlay extends OpenSeadragon.EventSource{
6
+
7
+ this.onViewerResize=(self=>function(){
8
+ self._resize();
9
+ - self.paperScope.view.emit('resize',{size:new paper.Size(self._containerWidth, self._containerHeight)})
10
+ + // Safely emit resize event - check if view is still valid
11
+ + try {
12
+ + if (self.paperScope && self.paperScope.view && self.paperScope.view._transformBounds) {
13
+ + self.paperScope.view.emit('resize',{size:new paper.Size(self._containerWidth, self._containerHeight)})
14
+ + }
15
+ + } catch (e) {
16
+ + // View destroyed, ignore
17
+ + }
18
+ self._updatePaperView();
19
+ })(this);
20
+
21
+ @@ -571,24 +578,111 @@ class PaperOverlay extends OpenSeadragon.EventSource{
22
+ return;
23
+ }
24
+
25
+ + // Defensive check: ensure Paper.js view is still initialized
26
+ + // This prevents _transformBounds errors when Paper.js is destroyed but event handlers still fire
27
+ + if(!this.paperScope || !this.paperScope.view) {
28
+ + return;
29
+ + }
30
+ +
31
+ + // Check if _transformBounds exists (internal Paper.js property indicating initialization)
32
+ + const view = this.paperScope.view;
33
+ + if(view._transformBounds === null || view._transformBounds === undefined) {
34
+ + return;
35
+ + }
36
+ +
37
+ + // Additional check: ensure viewer hasn't been destroyed
38
+ + if(this.destroyed) {
39
+ + return;
40
+ + }
41
+ +
42
+ let viewportZoom = this.viewer.viewport.getZoom(true);
43
+ - let oldZoom = this.paperScope.view.getZoom();
44
+ - this.paperScope.view.setZoom(this.viewer.viewport._containerInnerSize.x * viewportZoom / this.scaleFactor);
45
+ +
46
+ + // Safely get zoom - these methods internally call getBounds/getCenter which access _transformBounds
47
+ + let oldZoom = 0;
48
+ + try {
49
+ + if (view._transformBounds) {
50
+ + oldZoom = this.paperScope.view.getZoom();
51
+ + }
52
+ + } catch (e) {
53
+ + // _transformBounds became null, exit early
54
+ + return;
55
+ + }
56
+ +
57
+ + // Safely set zoom
58
+ + try {
59
+ + if (view._transformBounds) {
60
+ + this.paperScope.view.setZoom(this.viewer.viewport._containerInnerSize.x * viewportZoom / this.scaleFactor);
61
+ + } else {
62
+ + return;
63
+ + }
64
+ + } catch (e) {
65
+ + // _transformBounds became null, exit early
66
+ + return;
67
+ + }
68
+
69
+ let center = this._getCenter();
70
+ + if(!center) {
71
+ + return; // _getCenter() may return null if viewer is destroyed
72
+ + }
73
+ +
74
+ this.viewer.drawer.canvas.pixelRatio = window.devicePixelRatio;
75
+ - this.paperScope.view.center = new paper.Point(center.x, center.y).multiply(this.scaleFactor);
76
+ +
77
+ + // Safely set center - this internally calls setCenter which accesses _transformBounds
78
+ + try {
79
+ + if (view._transformBounds) {
80
+ + this.paperScope.view.center = new paper.Point(center.x, center.y).multiply(this.scaleFactor);
81
+ + } else {
82
+ + return;
83
+ + }
84
+ + } catch (e) {
85
+ + // _transformBounds became null, exit early
86
+ + return;
87
+ + }
88
+
89
+ let degrees = this.viewer.viewport.getRotation(true);
90
+ let pivot = this._getPivot();
91
+ - this.paperScope.view.setRotation(degrees, pivot);
92
+
93
+ - const newZoom = this.paperScope.view.getZoom();
94
+ - if(Math.abs(newZoom - oldZoom)>0.0000001){
95
+ - this.paperScope.view.emit('zoom-changed',{zoom:newZoom});
96
+ + // Safely set rotation
97
+ + try {
98
+ + if (view._transformBounds) {
99
+ + this.paperScope.view.setRotation(degrees, pivot);
100
+ + } else {
101
+ + return;
102
+ + }
103
+ + } catch (e) {
104
+ + // _transformBounds became null, exit early
105
+ + return;
106
+ + }
107
+ +
108
+ + // Safely get new zoom for comparison
109
+ + const newZoom = (() => {
110
+ + try {
111
+ + if (view._transformBounds) {
112
+ + return this.paperScope.view.getZoom();
113
+ + }
114
+ + } catch (e) {
115
+ + // Ignore
116
+ + }
117
+ + return oldZoom;
118
+ + })();
119
+ +
120
+ + // Safely emit zoom-changed event
121
+ + try {
122
+ + if (view._transformBounds && Math.abs(newZoom - oldZoom)>0.0000001){
123
+ + this.paperScope.view.emit('zoom-changed',{zoom:newZoom});
124
+ + }
125
+ + } catch (e) {
126
+ + // _transformBounds became null, ignore
127
+ }
128
+
129
+ - this.paperScope.view.update();
130
+ + // Safely update view - this method also accesses _transformBounds internally
131
+ + try {
132
+ + if (view._transformBounds) {
133
+ + this.paperScope.view.update();
134
+ + }
135
+ + } catch (e) {
136
+ + // _transformBounds became null, ignore
137
+ + }
138
+ }
139
+ _getPivot(){
140
+ if(!this._pivot) return;
141
+ @@ -596,7 +690,16 @@ class PaperOverlay extends OpenSeadragon.EventSource{
142
+ return this._pivot.multiply(this.scaleFactor);
143
+ }
144
+ _getCenter(){
145
+ - return this.viewer.viewport.getCenter(true);
146
+ + // Defensive check: ensure viewer and viewport still exist
147
+ + if(!this.viewer || !this.viewer.viewport || this.destroyed) {
148
+ + return null;
149
+ + }
150
+ + try {
151
+ + return this.viewer.viewport.getCenter(true);
152
+ + } catch(e) {
153
+ + // Viewer might be destroyed, return null to indicate failure
154
+ + return null;
155
+ + }
156
+ }
157
+
158
+