@canopy-iiif/app 1.9.19 → 1.9.21
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.
- package/package.json +1 -1
- package/ui/dist/index.mjs +69 -9
- package/ui/dist/index.mjs.map +3 -3
- package/ui/dist/server.mjs +69 -9
- package/ui/dist/server.mjs.map +3 -3
package/ui/dist/server.mjs
CHANGED
|
@@ -209,6 +209,10 @@ var Viewer = (props) => {
|
|
|
209
209
|
DEFAULT_VIEWER_OPTIONS,
|
|
210
210
|
props && props.options
|
|
211
211
|
);
|
|
212
|
+
const crossOriginExplicitlyUndefined = props && props.options && Object.prototype.hasOwnProperty.call(props.options, "crossOrigin") && props.options.crossOrigin === void 0;
|
|
213
|
+
if (crossOriginExplicitlyUndefined) {
|
|
214
|
+
mergedOptions.crossOrigin = null;
|
|
215
|
+
}
|
|
212
216
|
useEffect(() => {
|
|
213
217
|
let mounted = true;
|
|
214
218
|
const canUseDom = typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -699,21 +703,16 @@ var ImageStory = (props = {}) => {
|
|
|
699
703
|
if (!node) return void 0;
|
|
700
704
|
let cleanup = null;
|
|
701
705
|
let cancelled = false;
|
|
706
|
+
let mounted = false;
|
|
707
|
+
let resizeObserver = null;
|
|
708
|
+
let pollId = null;
|
|
702
709
|
const payload = sanitizeImageStoryProps({
|
|
703
710
|
iiifContent,
|
|
704
711
|
disablePanAndZoom,
|
|
705
712
|
pointOfInterestSvgUrl,
|
|
706
713
|
viewerOptions
|
|
707
714
|
});
|
|
708
|
-
|
|
709
|
-
if (cancelled) {
|
|
710
|
-
destroy && destroy();
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
cleanup = typeof destroy === "function" ? destroy : null;
|
|
714
|
-
});
|
|
715
|
-
return () => {
|
|
716
|
-
cancelled = true;
|
|
715
|
+
const destroyCleanup = () => {
|
|
717
716
|
if (cleanup) {
|
|
718
717
|
try {
|
|
719
718
|
cleanup();
|
|
@@ -722,6 +721,67 @@ var ImageStory = (props = {}) => {
|
|
|
722
721
|
cleanup = null;
|
|
723
722
|
}
|
|
724
723
|
};
|
|
724
|
+
const disconnectWatchers = () => {
|
|
725
|
+
if (resizeObserver) {
|
|
726
|
+
try {
|
|
727
|
+
resizeObserver.disconnect();
|
|
728
|
+
} catch (_) {
|
|
729
|
+
}
|
|
730
|
+
resizeObserver = null;
|
|
731
|
+
}
|
|
732
|
+
if (pollId) {
|
|
733
|
+
window.clearTimeout(pollId);
|
|
734
|
+
pollId = null;
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
const hasUsableSize = () => {
|
|
738
|
+
if (!node) return false;
|
|
739
|
+
const rect = node.getBoundingClientRect();
|
|
740
|
+
const width = (rect == null ? void 0 : rect.width) || node.offsetWidth || node.clientWidth;
|
|
741
|
+
const height2 = (rect == null ? void 0 : rect.height) || node.offsetHeight || node.clientHeight;
|
|
742
|
+
return width > 2 && height2 > 2;
|
|
743
|
+
};
|
|
744
|
+
const mountViewer = () => {
|
|
745
|
+
if (!node || mounted || cancelled) return false;
|
|
746
|
+
if (!hasUsableSize()) return false;
|
|
747
|
+
mounted = true;
|
|
748
|
+
disconnectWatchers();
|
|
749
|
+
mountImageStory(node, payload).then((destroy) => {
|
|
750
|
+
if (cancelled) {
|
|
751
|
+
destroy && destroy();
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
cleanup = typeof destroy === "function" ? destroy : null;
|
|
755
|
+
});
|
|
756
|
+
return true;
|
|
757
|
+
};
|
|
758
|
+
if (!mountViewer()) {
|
|
759
|
+
if (typeof window !== "undefined" && typeof window.ResizeObserver === "function") {
|
|
760
|
+
resizeObserver = new window.ResizeObserver(() => {
|
|
761
|
+
if (mounted || cancelled) return;
|
|
762
|
+
mountViewer();
|
|
763
|
+
});
|
|
764
|
+
try {
|
|
765
|
+
resizeObserver.observe(node);
|
|
766
|
+
} catch (_) {
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
const schedulePoll = () => {
|
|
770
|
+
if (mounted || cancelled) return;
|
|
771
|
+
pollId = window.setTimeout(() => {
|
|
772
|
+
pollId = null;
|
|
773
|
+
if (!mountViewer()) {
|
|
774
|
+
schedulePoll();
|
|
775
|
+
}
|
|
776
|
+
}, 200);
|
|
777
|
+
};
|
|
778
|
+
schedulePoll();
|
|
779
|
+
}
|
|
780
|
+
return () => {
|
|
781
|
+
cancelled = true;
|
|
782
|
+
disconnectWatchers();
|
|
783
|
+
destroyCleanup();
|
|
784
|
+
};
|
|
725
785
|
}, [iiifContent, disablePanAndZoom, pointOfInterestSvgUrl, viewerOptions]);
|
|
726
786
|
return /* @__PURE__ */ React6.createElement(
|
|
727
787
|
"div",
|