@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopy-iiif/app",
3
- "version": "1.9.19",
3
+ "version": "1.9.21",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Mat Jordan <mat@northwestern.edu>",
package/ui/dist/index.mjs CHANGED
@@ -45036,6 +45036,10 @@ var Viewer = (props) => {
45036
45036
  DEFAULT_VIEWER_OPTIONS,
45037
45037
  props && props.options
45038
45038
  );
45039
+ const crossOriginExplicitlyUndefined = props && props.options && Object.prototype.hasOwnProperty.call(props.options, "crossOrigin") && props.options.crossOrigin === void 0;
45040
+ if (crossOriginExplicitlyUndefined) {
45041
+ mergedOptions.crossOrigin = null;
45042
+ }
45039
45043
  useEffect2(() => {
45040
45044
  let mounted = true;
45041
45045
  const canUseDom = typeof window !== "undefined" && typeof document !== "undefined";
@@ -45526,21 +45530,16 @@ var ImageStory = (props = {}) => {
45526
45530
  if (!node) return void 0;
45527
45531
  let cleanup = null;
45528
45532
  let cancelled = false;
45533
+ let mounted = false;
45534
+ let resizeObserver = null;
45535
+ let pollId = null;
45529
45536
  const payload = sanitizeImageStoryProps({
45530
45537
  iiifContent,
45531
45538
  disablePanAndZoom,
45532
45539
  pointOfInterestSvgUrl,
45533
45540
  viewerOptions
45534
45541
  });
45535
- mountImageStory(node, payload).then((destroy) => {
45536
- if (cancelled) {
45537
- destroy && destroy();
45538
- return;
45539
- }
45540
- cleanup = typeof destroy === "function" ? destroy : null;
45541
- });
45542
- return () => {
45543
- cancelled = true;
45542
+ const destroyCleanup = () => {
45544
45543
  if (cleanup) {
45545
45544
  try {
45546
45545
  cleanup();
@@ -45549,6 +45548,67 @@ var ImageStory = (props = {}) => {
45549
45548
  cleanup = null;
45550
45549
  }
45551
45550
  };
45551
+ const disconnectWatchers = () => {
45552
+ if (resizeObserver) {
45553
+ try {
45554
+ resizeObserver.disconnect();
45555
+ } catch (_) {
45556
+ }
45557
+ resizeObserver = null;
45558
+ }
45559
+ if (pollId) {
45560
+ window.clearTimeout(pollId);
45561
+ pollId = null;
45562
+ }
45563
+ };
45564
+ const hasUsableSize = () => {
45565
+ if (!node) return false;
45566
+ const rect = node.getBoundingClientRect();
45567
+ const width = (rect == null ? void 0 : rect.width) || node.offsetWidth || node.clientWidth;
45568
+ const height2 = (rect == null ? void 0 : rect.height) || node.offsetHeight || node.clientHeight;
45569
+ return width > 2 && height2 > 2;
45570
+ };
45571
+ const mountViewer = () => {
45572
+ if (!node || mounted || cancelled) return false;
45573
+ if (!hasUsableSize()) return false;
45574
+ mounted = true;
45575
+ disconnectWatchers();
45576
+ mountImageStory(node, payload).then((destroy) => {
45577
+ if (cancelled) {
45578
+ destroy && destroy();
45579
+ return;
45580
+ }
45581
+ cleanup = typeof destroy === "function" ? destroy : null;
45582
+ });
45583
+ return true;
45584
+ };
45585
+ if (!mountViewer()) {
45586
+ if (typeof window !== "undefined" && typeof window.ResizeObserver === "function") {
45587
+ resizeObserver = new window.ResizeObserver(() => {
45588
+ if (mounted || cancelled) return;
45589
+ mountViewer();
45590
+ });
45591
+ try {
45592
+ resizeObserver.observe(node);
45593
+ } catch (_) {
45594
+ }
45595
+ }
45596
+ const schedulePoll = () => {
45597
+ if (mounted || cancelled) return;
45598
+ pollId = window.setTimeout(() => {
45599
+ pollId = null;
45600
+ if (!mountViewer()) {
45601
+ schedulePoll();
45602
+ }
45603
+ }, 200);
45604
+ };
45605
+ schedulePoll();
45606
+ }
45607
+ return () => {
45608
+ cancelled = true;
45609
+ disconnectWatchers();
45610
+ destroyCleanup();
45611
+ };
45552
45612
  }, [iiifContent, disablePanAndZoom, pointOfInterestSvgUrl, viewerOptions]);
45553
45613
  return /* @__PURE__ */ React27.createElement(
45554
45614
  "div",