@canopy-iiif/app 1.5.12 → 1.5.14

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.
@@ -3453,6 +3453,10 @@ TimelinePoint.displayName = "TimelinePoint";
3453
3453
  // ui/src/utils/manifestReferences.js
3454
3454
  import React31 from "react";
3455
3455
  import navigationHelpers6 from "@canopy-iiif/app/lib/components/navigation.js";
3456
+ import referencedHelpers from "@canopy-iiif/app/lib/components/referenced.js";
3457
+ var referencedModule = referencedHelpers && typeof referencedHelpers === "object" ? referencedHelpers : null;
3458
+ var buildReferencedItems = referencedModule && typeof referencedModule.buildReferencedItems === "function" ? referencedModule.buildReferencedItems : null;
3459
+ var normalizeReferencedManifestList = referencedModule && typeof referencedModule.normalizeReferencedManifestList === "function" ? referencedModule.normalizeReferencedManifestList : null;
3456
3460
  function normalizeManifestId(raw) {
3457
3461
  if (!raw) return "";
3458
3462
  try {
@@ -3512,6 +3516,57 @@ function resolveManifestReferences(ids, manifestMap) {
3512
3516
  });
3513
3517
  return out;
3514
3518
  }
3519
+ function resolveReferencedManifests(ids, manifestMap) {
3520
+ if (!Array.isArray(ids) || !ids.length) return [];
3521
+ const order = [];
3522
+ const seen = /* @__PURE__ */ new Set();
3523
+ ids.forEach((value) => {
3524
+ const normalized = normalizeManifestId(value);
3525
+ if (!normalized || seen.has(normalized)) return;
3526
+ seen.add(normalized);
3527
+ order.push(normalized);
3528
+ });
3529
+ if (!order.length) return [];
3530
+ const manifestRecords = /* @__PURE__ */ new Map();
3531
+ if (manifestMap) {
3532
+ const resolved = resolveManifestReferences(ids, manifestMap);
3533
+ resolved.forEach((entry) => {
3534
+ const key = normalizeManifestId(entry && (entry.id || entry.href));
3535
+ if (key && !manifestRecords.has(key)) {
3536
+ manifestRecords.set(key, entry);
3537
+ }
3538
+ });
3539
+ }
3540
+ const missing = order.filter((key) => key && !manifestRecords.has(key));
3541
+ if (missing.length && buildReferencedItems) {
3542
+ let fallbackItems = [];
3543
+ try {
3544
+ const normalizedMissing = normalizeReferencedManifestList ? normalizeReferencedManifestList(missing) : missing;
3545
+ if (normalizedMissing && normalizedMissing.length) {
3546
+ fallbackItems = buildReferencedItems(normalizedMissing) || [];
3547
+ }
3548
+ } catch (_) {
3549
+ fallbackItems = [];
3550
+ }
3551
+ fallbackItems.forEach((item) => {
3552
+ if (!item) return;
3553
+ const fallbackKey = normalizeManifestId(item.id || item.href);
3554
+ if (!fallbackKey || manifestRecords.has(fallbackKey)) return;
3555
+ manifestRecords.set(fallbackKey, {
3556
+ id: item.id || item.href || fallbackKey,
3557
+ href: item.href || null,
3558
+ title: item.title || item.href || "",
3559
+ summary: item.summary || "",
3560
+ thumbnail: item.thumbnail || null,
3561
+ thumbnailWidth: item.thumbnailWidth,
3562
+ thumbnailHeight: item.thumbnailHeight,
3563
+ type: item.type || "work",
3564
+ metadata: Array.isArray(item.metadata) && item.metadata.length ? item.metadata : item.summary ? [item.summary] : []
3565
+ });
3566
+ });
3567
+ }
3568
+ return order.map((key) => manifestRecords.get(key)).filter(Boolean);
3569
+ }
3515
3570
 
3516
3571
  // ui/src/content/timeline/MdxTimeline.jsx
3517
3572
  function normalizeResource(resource, index) {
@@ -3553,7 +3608,7 @@ function normalizePoint(child, index, options) {
3553
3608
  }
3554
3609
  const resources = Array.isArray(props.iiifResources) ? props.iiifResources.map(normalizeResource).filter(Boolean) : [];
3555
3610
  const manifestValues = Array.isArray(props.referencedManifests) ? props.referencedManifests : props.manifest ? [props.manifest] : Array.isArray(props.manifests) ? props.manifests : [];
3556
- const manifests = resolveManifestReferences(manifestValues, options.manifestMap);
3611
+ const manifests = resolveReferencedManifests(manifestValues, options.manifestMap);
3557
3612
  return {
3558
3613
  id,
3559
3614
  title: props.title || props.label || `Point ${index + 1}`,
@@ -3669,7 +3724,7 @@ function normalizeCustomPoint(child, index, manifestMap) {
3669
3724
  let thumbnailHeight = normalizeNumber(props.thumbnailHeight);
3670
3725
  const detailsHtml = renderDetailsHtml(props.children);
3671
3726
  const manifestValues = Array.isArray(props.referencedManifests) ? props.referencedManifests : props.manifest ? [props.manifest] : Array.isArray(props.manifests) ? props.manifests : [];
3672
- const manifests = resolveManifestReferences(manifestValues, manifestMap);
3727
+ const manifests = resolveReferencedManifests(manifestValues, manifestMap);
3673
3728
  if (!thumbnail && manifests.length) {
3674
3729
  const manifestWithThumb = manifests.find(
3675
3730
  (manifest) => manifest && manifest.thumbnail