react-iiif-vault 1.0.8 → 1.0.10

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.
Files changed (67) hide show
  1. package/.build/types/canvas-panel/Viewer.d.ts +1 -1
  2. package/.build/types/canvas-panel/index.d.ts +2 -1
  3. package/.build/types/canvas-panel/render/Audio.d.ts +1 -1
  4. package/.build/types/canvas-panel/render/Canvas.d.ts +2 -2
  5. package/.build/types/canvas-panel/render/CanvasBackground.d.ts +1 -1
  6. package/.build/types/canvas-panel/render/DefaultCanvasFallback.d.ts +1 -1
  7. package/.build/types/canvas-panel/render/Image.d.ts +1 -1
  8. package/.build/types/canvas-panel/render/Model.d.ts +1 -1
  9. package/.build/types/canvas-panel/render/Video.d.ts +1 -1
  10. package/.build/types/canvas-panel/render/VideoYouTube.d.ts +1 -1
  11. package/.build/types/components/CanvasAnnotations.d.ts +10 -0
  12. package/.build/types/components/CombinedMetadata.d.ts +4 -0
  13. package/.build/types/components/Image.d.ts +15 -0
  14. package/.build/types/components/ManifestMetadata.d.ts +4 -0
  15. package/.build/types/components/Metadata.d.ts +39 -0
  16. package/.build/types/components/SequenceThumbnails.d.ts +29 -0
  17. package/.build/types/components/SingleCanvasThumbnail.d.ts +20 -0
  18. package/.build/types/context/AnnotationContext.d.ts +1 -1
  19. package/.build/types/context/AnnotationPageContext.d.ts +1 -1
  20. package/.build/types/context/CanvasContext.d.ts +1 -1
  21. package/.build/types/context/CollectionContext.d.ts +1 -1
  22. package/.build/types/context/ContextBridge.d.ts +1 -1
  23. package/.build/types/context/ManifestContext.d.ts +1 -1
  24. package/.build/types/context/MediaContext.d.ts +1 -1
  25. package/.build/types/context/RangeContext.d.ts +1 -1
  26. package/.build/types/context/ResourceContext.d.ts +2 -2
  27. package/.build/types/context/VaultContext.d.ts +1 -1
  28. package/.build/types/demo/media-controls.d.ts +1 -1
  29. package/.build/types/demo/viewer-controls.d.ts +1 -1
  30. package/.build/types/features/rendering-strategy/3d-strategy.d.ts +1 -1
  31. package/.build/types/features/rendering-strategy/image-strategy.d.ts +1 -1
  32. package/.build/types/features/rendering-strategy/resource-types.d.ts +7 -7
  33. package/.build/types/features/rendering-strategy/strategies.d.ts +5 -5
  34. package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +1 -1
  35. package/.build/types/hooks/useEventListener.d.ts +1 -1
  36. package/.build/types/hooks/useExistingVault.d.ts +2 -1
  37. package/.build/types/hooks/useExternalResource.d.ts +1 -1
  38. package/.build/types/hooks/useImage.d.ts +10 -0
  39. package/.build/types/hooks/useLoadImageService.d.ts +1 -1
  40. package/.build/types/hooks/useRenderingStrategy.d.ts +3 -3
  41. package/.build/types/hooks/useSimpleMediaPlayer.d.ts +2 -2
  42. package/.build/types/hooks/useVirtualAnnotationPageContext.d.ts +81 -81
  43. package/.build/types/index.d.ts +8 -0
  44. package/.build/types/utility/i18n-utils.d.ts +8 -6
  45. package/.build/types/viewers/SimpleViewerContext.d.ts +2 -2
  46. package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +2 -0
  47. package/.build/types/viewers/SimpleViewerContext.types.d.ts +8 -4
  48. package/README.md +495 -177
  49. package/dist/bundle/cjs/index.js +7 -6
  50. package/dist/bundle/cjs/index.js.map +1 -1
  51. package/dist/bundle/esm/index.mjs +2391 -1186
  52. package/dist/bundle/esm/index.mjs.map +1 -1
  53. package/dist/canvas-panel/cjs/canvas-panel.js +5 -5
  54. package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
  55. package/dist/canvas-panel/esm/canvas-panel.mjs +596 -547
  56. package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
  57. package/dist/index.umd.js +78 -76
  58. package/dist/index.umd.js.map +1 -1
  59. package/dist/react17/cjs/index.js +7 -6
  60. package/dist/react17/cjs/index.js.map +1 -1
  61. package/dist/react17/esm/index.mjs +2391 -1186
  62. package/dist/react17/esm/index.mjs.map +1 -1
  63. package/dist/utils/cjs/utils.js +1 -1
  64. package/dist/utils/cjs/utils.js.map +1 -1
  65. package/dist/utils/esm/utils.mjs +21 -21
  66. package/dist/utils/esm/utils.mjs.map +1 -1
  67. package/package.json +24 -22
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@iiif/helpers"),w=require("@atlas-viewer/iiif-image-api"),g=require("@iiif/helpers/annotation-targets");function I(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function m(e,o){const{selector:r,source:i}=T.expandTarget(o);if(i.id!==e.id)return[null,i];const t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[r?r.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:r.temporal,spatial:t.spatial}:r:null,i]}const R={makeChoice:()=>{}},f={type:"unknown"},n=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),y=(e,o)=>({type:"empty",width:e,height:o,annotations:{pages:[]},image:null,images:[]}),O=["model/gltf-binary"];function k(e,o){const i=o.items[0].resource;return i.format?O.indexOf(i.format)===-1?n(`3D format: ${i.format} is unsupported`):{type:"3d-model",model:i}:n("Unknown format")}function N(e,o){var i;if(!e.duration)return n("No duration on canvas");if(o.items.length>1)return n("Only one audio source supported");const r=(i=o.items[0])==null?void 0:i.resource;return r?r.format?{type:"media",media:{annotationId:o.items[0].annotationId,duration:e.duration,url:r.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:n("Audio does not have format"):n("Unknown audio")}function v(e,o,r){const i=[];for(const t of o.items){const u=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!u.id)return n("No resource Identifier");let s;if(u.service){const a=w.getImageServices(u);a[0]&&(s=r(a[0],e))}const l={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[d,S]=m(e,t.target);if(S.id!==e.id)continue;t.resource.width&&t.resource.height&&(t.resource.width,t.resource.height);let c=t.resource.type==="SpecificResource"?g.expandTarget(t.resource):null;if(t.selector){const a=g.expandTarget({type:"SpecificResource",source:t.resource,selector:t.selector});a&&(c=a)}const p=c&&c.selector&&(c.selector.type==="BoxSelector"||c.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:c.selector.spatial.x,y:c.selector.spatial.y,width:c.selector.spatial.width,height:c.selector.spatial.height}}:void 0;s&&!s.id&&(s.id=s["@id"]);const x={id:u.id,type:"Image",annotationId:t.annotationId,width:Number(d||p?u.width:e.width),height:Number(d||p?u.height:e.height),service:s,sizes:s&&s.sizes?s.sizes:u.width&&u.height?[{width:u.width,height:u.height}]:[],target:d&&d.type!=="PointSelector"?d:l,selector:p};i.push(x)}return{type:"images",image:i[0],images:i,choice:o.choice}}function h(e,o={},r){const i=e.language||r||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(o[i]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>h(t,o,i))}return o}function B(e,o){const r=[];return o.items.forEach(i=>{if(i.resource){const[t]=m(e,i.target);r.push({annotationId:i.annotationId,text:h(i.resource),target:t})}}),{type:"textual-content",items:r}}const C=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function V(e,o){var l;const r=o.items.filter(d=>d.type==="video");let i=!1;if(e.duration||(i=!0),r.length>1)return n("Only one video source supported");const t=(l=r[0])==null?void 0:l.resource,u=!!(t.service||[]).find(d=>(d.profile||"").includes("youtube.com"));if(!u&&i)return n("Video does not have duration");if(!t)return n("Unknown video");if((!t.format||t.format==="text/html")&&!u)return n("Video does not have format");const s={annotationId:o.items[0].annotationId,duration:e.duration,url:t.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:t.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(u){s.type="VideoYouTube";const d=t.id.match(C);if(!d[1])return n("Video is not known youtube video");s.youTubeId=d[1]}return{type:"media",media:s,annotations:{pages:[]}}}function b({canvas:e,paintables:o,supports:r,loadImageService:i}){if(!e)return console.log("No canvas"),f;if(o.types.length===0)return r.indexOf("empty")!==-1?y(e.width,e.height):(console.log("No paintables"),f);if(o.types.length!==1)if(o.types.length===2&&o.types.indexOf("text")!==-1)o.types=o.types.filter(u=>u!=="text");else return r.indexOf("complex-timeline")===-1?n("Complex timeline not supported"):n("ComplexTimelineStrategy not yet supported");const t=o.types[0];return t==="image"?r.indexOf("images")===-1?n("Image not supported"):v(e,o,i):t==="Model"||t==="model"?r.indexOf("3d-model")===-1?n("3D not supported"):k(e,o):t==="textualbody"?r.indexOf("textual-content")===-1?n("Textual content not supported"):B(e,o):t==="sound"||t==="audio"?r.indexOf("media")===-1?n("Media not supported"):N(e,o):t==="video"?r.indexOf("media")===-1?n("Media not supported"):V(e,o):f}exports.emptyActions=R;exports.emptyStrategy=y;exports.getParsedTargetSelector=m;exports.getRenderingStrategy=b;exports.parseSpecificResource=I;exports.unknownResponse=f;exports.unsupportedStrategy=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@iiif/helpers"),w=require("@atlas-viewer/iiif-image-api"),y=require("@iiif/helpers/annotation-targets");function I(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function m(e,o){const{selector:r,source:i}=T.expandTarget(o);if(i.id!==e.id)return[null,i];const t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[r?r.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:r.temporal,spatial:t.spatial}:r:null,i]}const R={makeChoice:()=>{}},f={type:"unknown"},n=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),h=(e,o)=>({type:"empty",width:e,height:o,annotations:{pages:[]},image:null,images:[]}),O=["model/gltf-binary"];function k(e,o){const i=o.items[0].resource;return i.format?O.indexOf(i.format)===-1?n(`3D format: ${i.format} is unsupported`):{type:"3d-model",model:i}:n("Unknown format")}function N(e,o){var i;if(!e.duration)return n("No duration on canvas");if(o.items.length>1)return n("Only one audio source supported");const r=(i=o.items[0])==null?void 0:i.resource;return r?r.format?{type:"media",media:{annotationId:o.items[0].annotationId,duration:e.duration,url:r.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:n("Audio does not have format"):n("Unknown audio")}function B(e,o,r){const i=[];for(const t of o.items){const u=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!u.id)return n("No resource Identifier");let s;if(u.service){const a=w.getImageServices(u);a[0]&&(s=r(a[0],e))}const l={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[d,g]=m(e,t.target);if(!(g.id===e.id||decodeURIComponent(g.id||"")===(e.id||"")))continue;t.resource.width&&t.resource.height&&(t.resource.width,t.resource.height);let c=t.resource.type==="SpecificResource"?y.expandTarget(t.resource):null;if(t.selector){const a=y.expandTarget({type:"SpecificResource",source:t.resource,selector:t.selector});a&&(c=a)}const p=c&&c.selector&&(c.selector.type==="BoxSelector"||c.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:c.selector.spatial.x,y:c.selector.spatial.y,width:c.selector.spatial.width,height:c.selector.spatial.height}}:void 0;s&&!s.id&&(s.id=s["@id"]);const x={id:u.id,type:"Image",annotationId:t.annotationId,width:Number(d||p?u.width:e.width),height:Number(d||p?u.height:e.height),service:s,sizes:s&&s.sizes?s.sizes:u.width&&u.height?[{width:u.width,height:u.height}]:[],target:d&&d.type!=="PointSelector"?d:l,selector:p};i.push(x)}return{type:"images",image:i[0],images:i,choice:o.choice}}function S(e,o={},r){const i=e.language||r||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(o[i]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>S(t,o,i))}return o}function v(e,o){const r=[];return o.items.forEach(i=>{if(i.resource){const[t]=m(e,i.target);r.push({annotationId:i.annotationId,text:S(i.resource),target:t})}}),{type:"textual-content",items:r}}const C=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function V(e,o){var l;const r=o.items.filter(d=>d.type==="video");let i=!1;if(e.duration||(i=!0),r.length>1)return n("Only one video source supported");const t=(l=r[0])==null?void 0:l.resource,u=!!(t.service||[]).find(d=>(d.profile||"").includes("youtube.com"));if(!u&&i)return n("Video does not have duration");if(!t)return n("Unknown video");if((!t.format||t.format==="text/html")&&!u)return n("Video does not have format");const s={annotationId:o.items[0].annotationId,duration:e.duration,url:t.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:t.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(u){s.type="VideoYouTube";const d=t.id.match(C);if(!d[1])return n("Video is not known youtube video");s.youTubeId=d[1]}return{type:"media",media:s,annotations:{pages:[]}}}function b({canvas:e,paintables:o,supports:r,loadImageService:i}){if(!e)return console.log("No canvas"),f;if(o.types.length===0)return r.indexOf("empty")!==-1?h(e.width,e.height):(console.log("No paintables"),f);if(o.types.length!==1)if(o.types.length===2&&o.types.indexOf("text")!==-1)o.types=o.types.filter(u=>u!=="text");else return r.indexOf("complex-timeline")===-1?n("Complex timeline not supported"):n("ComplexTimelineStrategy not yet supported");const t=o.types[0];return t==="image"?r.indexOf("images")===-1?n("Image not supported"):B(e,o,i):t==="Model"||t==="model"?r.indexOf("3d-model")===-1?n("3D not supported"):k(e,o):t==="textualbody"?r.indexOf("textual-content")===-1?n("Textual content not supported"):v(e,o):t==="sound"||t==="audio"?r.indexOf("media")===-1?n("Media not supported"):N(e,o):t==="video"?r.indexOf("media")===-1?n("Media not supported"):V(e,o):f}exports.emptyActions=R;exports.emptyStrategy=h;exports.getParsedTargetSelector=m;exports.getRenderingStrategy=b;exports.parseSpecificResource=I;exports.unknownResponse=f;exports.unsupportedStrategy=n;
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/features/rendering-strategy/rendering-utils.ts","../../../src/features/rendering-strategy/3d-strategy.ts","../../../src/features/rendering-strategy/audio-strategy.ts","../../../src/features/rendering-strategy/image-strategy.ts","../../../src/features/rendering-strategy/textual-content-strategy.ts","../../../src/features/rendering-strategy/video-strategy.ts","../../../src/features/rendering-strategy/get-rendering-strategy.ts"],"sourcesContent":["import { ContentResource, PointSelector, W3CAnnotationTarget } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { UseRenderingStrategy } from '../../hooks/useRenderingStrategy';\nimport { BoxSelector, expandTarget, SupportedTarget, TemporalBoxSelector } from '@iiif/helpers';\n\n/**\n * Parse specific resource.\n *\n * This could be expanded to support pulling out more from the specific resource.\n *\n * @param resource\n */\nexport function parseSpecificResource(resource: ContentResource) {\n if (resource.type === 'SpecificResource') {\n return [resource.source, { selector: resource.selector }];\n }\n\n return [resource, { selector: null }];\n}\n\nexport function getParsedTargetSelector(\n canvas: CanvasNormalized,\n target: W3CAnnotationTarget | W3CAnnotationTarget[]\n): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']] {\n const { selector: imageTarget, source } = expandTarget(target);\n\n if (source.id !== canvas.id) {\n // Skip invalid targets.\n return [null, source];\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n return [\n imageTarget\n ? imageTarget.type === 'TemporalSelector'\n ? ({\n type: 'TemporalBoxSelector',\n temporal: imageTarget.temporal,\n spatial: defaultTarget.spatial,\n } as any)\n : imageTarget\n : null,\n source,\n ];\n}\n\nexport const emptyActions = {\n makeChoice: () => {\n // no-op\n },\n};\n\nexport const unknownResponse: UseRenderingStrategy[0] = { type: 'unknown' };\n\nexport const unsupportedStrategy = (reason: string): UseRenderingStrategy[0] => {\n return { type: 'unknown', reason, annotations: { pages: [] } };\n};\n\nexport const emptyStrategy = (width: number, height: number): UseRenderingStrategy[0] => {\n return { type: 'empty', width, height, annotations: { pages: [] }, image: null, images: [] };\n};\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { AnnotationPageDescription } from './resource-types';\nimport { ExternalWebResource } from '@iiif/presentation-3';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type Single3DModelStrategy = {\n type: '3d-model';\n model: ExternalWebResource;\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nconst supportedFormats = ['model/gltf-binary'];\n\nexport function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const first = paintables.items[0];\n const resource = first.resource as ExternalWebResource;\n\n if (!resource.format) {\n return unsupportedStrategy('Unknown format');\n }\n\n if (supportedFormats.indexOf(resource.format) === -1) {\n return unsupportedStrategy(`3D format: ${resource.format} is unsupported`);\n }\n\n return {\n type: '3d-model',\n model: resource as any,\n } as Single3DModelStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\nexport function getAudioStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n if (!canvas.duration) {\n return unsupportedStrategy('No duration on canvas');\n }\n\n if (paintables.items.length > 1) {\n return unsupportedStrategy('Only one audio source supported');\n }\n\n const audioResource = paintables.items[0]?.resource as any; // @todo stronger type for what this might be.\n\n if (!audioResource) {\n return unsupportedStrategy('Unknown audio');\n }\n\n if (!audioResource.format) {\n return unsupportedStrategy('Audio does not have format');\n }\n\n return {\n type: 'media',\n media: {\n annotationId: paintables.items[0].annotationId,\n duration: canvas.duration,\n url: audioResource.id,\n type: 'Sound',\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: audioResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n },\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { IIIFExternalWebResource } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\nimport { AnnotationPageDescription, ImageWithOptionalService } from './resource-types';\nimport { getImageServices } from '@atlas-viewer/iiif-image-api';\nimport { getParsedTargetSelector, unsupportedStrategy } from './rendering-utils';\nimport { expandTarget } from '@iiif/helpers/annotation-targets';\nimport { BoxSelector, ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type SingleImageStrategy = {\n type: 'images';\n image: ImageWithOptionalService;\n images: Array<ImageWithOptionalService>;\n choice?: ChoiceDescription;\n annotations?: AnnotationPageDescription;\n};\n\nexport function getImageStrategy(\n canvas: CanvasNormalized,\n paintables: Paintables,\n loadImageService: ImageServiceLoaderType\n) {\n const imageTypes: ImageWithOptionalService[] = [];\n for (const singleImage of paintables.items) {\n // SingleImageStrategy\n const resource: IIIFExternalWebResource =\n singleImage.resource && singleImage.resource.type === 'SpecificResource'\n ? singleImage.resource.source\n : singleImage.resource;\n\n // Validation.\n if (!resource.id) {\n // @todo we could skip this?\n return unsupportedStrategy('No resource Identifier');\n }\n\n let imageService = undefined;\n if (resource.service) {\n const imageServices = getImageServices(resource as any) as any[];\n if (imageServices[0]) {\n imageService = loadImageService(imageServices[0], canvas);\n }\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n const [target, source] = getParsedTargetSelector(canvas, singleImage.target);\n if (source.id !== canvas.id) {\n // Skip invalid targets.\n continue;\n }\n\n // Support for cropping before painting an annotation.\n // @todo this isn't working.\n const defaultImageSelector =\n (singleImage.resource as any).width && (singleImage.resource as any).height\n ? ({\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: (singleImage.resource as any).width,\n height: (singleImage.resource as any).height,\n },\n } as BoxSelector)\n : undefined;\n\n let imageSelector = singleImage.resource.type === 'SpecificResource' ? expandTarget(singleImage.resource) : null;\n\n if (singleImage.selector) {\n const found = expandTarget({\n type: 'SpecificResource',\n source: singleImage.resource,\n selector: singleImage.selector,\n });\n\n if (found) {\n imageSelector = found;\n }\n }\n\n const selector: undefined | BoxSelector =\n imageSelector &&\n imageSelector.selector &&\n (imageSelector.selector.type === 'BoxSelector' || imageSelector.selector.type === 'TemporalBoxSelector')\n ? {\n type: 'BoxSelector',\n spatial: {\n x: imageSelector.selector.spatial.x,\n y: imageSelector.selector.spatial.y,\n width: imageSelector.selector.spatial.width,\n height: imageSelector.selector.spatial.height,\n },\n }\n : undefined;\n\n if (imageService && !imageService.id) {\n (imageService as any).id = imageService['@id'];\n }\n\n const imageType: ImageWithOptionalService = {\n id: resource.id,\n type: 'Image',\n annotationId: (singleImage as any).annotationId,\n width: Number(target || selector ? resource.width : canvas.width),\n height: Number(target || selector ? resource.height : canvas.height),\n service: imageService,\n sizes:\n imageService && imageService.sizes\n ? imageService.sizes\n : resource.width && resource.height\n ? [{ width: resource.width, height: resource.height }]\n : [],\n target: target && target.type !== 'PointSelector' ? target : defaultTarget,\n selector: selector,\n };\n\n imageTypes.push(imageType);\n }\n\n return {\n type: 'images',\n image: imageTypes[0],\n images: imageTypes,\n choice: paintables.choice,\n } as SingleImageStrategy;\n}\n","import { InternationalString } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { AnnotationPageDescription } from './resource-types';\nimport { getParsedTargetSelector } from './rendering-utils';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables, SupportedTarget } from '@iiif/helpers';\n\nexport type TextualContentStrategy = {\n type: 'textual-content';\n items: { annotationId: string; text: InternationalString; target: SupportedTarget | null }[];\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nfunction parseType(item: any, languageMap: InternationalString = {}, lang?: string) {\n const language = item.language || lang || 'none';\n switch (item.type) {\n case 'TextualBody': {\n if (typeof item.value !== 'undefined') {\n languageMap[language] = item.value;\n }\n break;\n }\n case 'List':\n case 'Composite':\n case 'Choice': {\n if (item.items) {\n item.items.forEach((inner: any) => parseType(inner, languageMap, language));\n }\n }\n }\n return languageMap;\n}\n\nexport function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const items: TextualContentStrategy['items'] = [];\n\n paintables.items.forEach((item) => {\n if (item.resource) {\n const [target] = getParsedTargetSelector(canvas, item.target);\n items.push({ annotationId: item.annotationId, text: parseType(item.resource), target: target as any });\n }\n });\n\n return {\n type: 'textual-content',\n items,\n } as TextualContentStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\n// https://stackoverflow.com/a/27728417\nconst ytRegex = /^.*(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/|shorts\\/)|(?:(?:watch)?\\?vi?=|&vi?=))([^#&?]*).*/;\n\nexport function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n const videoPaintables = paintables.items.filter((t) => t.type === 'video');\n\n let noDuration = false;\n\n if (!canvas.duration) {\n noDuration = true;\n }\n\n if (videoPaintables.length > 1) {\n return unsupportedStrategy('Only one video source supported');\n }\n\n const videoResource = videoPaintables[0]?.resource as any; // @todo stronger type for what this might be.\n const isYouTube = !!(videoResource.service || []).find((service: any) =>\n (service.profile || '').includes('youtube.com')\n );\n\n if (!isYouTube && noDuration) {\n return unsupportedStrategy('Video does not have duration');\n }\n\n if (!videoResource) {\n return unsupportedStrategy('Unknown video');\n }\n\n if (!videoResource.format || videoResource.format === 'text/html') {\n if (!isYouTube) {\n return unsupportedStrategy('Video does not have format');\n }\n }\n\n const media = {\n annotationId: (paintables.items[0] as any).annotationId,\n duration: canvas.duration,\n url: videoResource.id,\n type: 'Video',\n items: [],\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: videoResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n };\n\n if (isYouTube) {\n media.type = 'VideoYouTube';\n const id = videoResource.id.match(ytRegex);\n if (!id[1]) {\n return unsupportedStrategy('Video is not known youtube video');\n }\n (media as any).youTubeId = id[1];\n }\n\n // @todo support VTT\n\n return {\n type: 'media',\n media,\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { get3dStrategy } from './3d-strategy';\nimport { getAudioStrategy } from './audio-strategy';\nimport { getImageStrategy } from './image-strategy';\nimport { emptyStrategy, unknownResponse, unsupportedStrategy } from './rendering-utils';\nimport { getTextualContentStrategy } from './textual-content-strategy';\nimport { getVideoStrategy } from './video-strategy';\nimport type { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport type { Paintables } from '@iiif/helpers/painting-annotations';\nimport type { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\n\ninterface GetRenderStrategyOptions {\n canvas: CanvasNormalized | null | undefined;\n paintables: Paintables;\n supports: string[];\n loadImageService: ImageServiceLoaderType;\n}\n\nexport function getRenderingStrategy({ canvas, paintables, supports, loadImageService }: GetRenderStrategyOptions) {\n if (!canvas) {\n console.log('No canvas');\n return unknownResponse;\n }\n\n if (paintables.types.length === 0) {\n if (supports.indexOf('empty') !== -1) {\n return emptyStrategy(canvas.width, canvas.height);\n }\n console.log('No paintables');\n return unknownResponse;\n }\n\n if (paintables.types.length !== 1) {\n if (paintables.types.length === 2 && paintables.types.indexOf('text') !== -1) {\n paintables.types = paintables.types.filter((t) => t !== 'text');\n } else {\n if (supports.indexOf('complex-timeline') === -1) {\n return unsupportedStrategy('Complex timeline not supported');\n }\n return unsupportedStrategy('ComplexTimelineStrategy not yet supported');\n }\n }\n\n const mainType = paintables.types[0];\n\n // Image\n if (mainType === 'image') {\n if (supports.indexOf('images') === -1) {\n return unsupportedStrategy('Image not supported');\n }\n\n return getImageStrategy(canvas, paintables, loadImageService);\n }\n\n // 3D\n if (mainType === 'Model' || mainType === 'model') {\n if (supports.indexOf('3d-model') === -1) {\n return unsupportedStrategy('3D not supported');\n }\n\n return get3dStrategy(canvas, paintables);\n }\n\n if (mainType === 'textualbody') {\n if (supports.indexOf('textual-content') === -1) {\n return unsupportedStrategy('Textual content not supported');\n }\n\n return getTextualContentStrategy(canvas, paintables);\n }\n\n if (mainType === 'sound' || mainType === 'audio') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with audio or audio sequence.\n return getAudioStrategy(canvas, paintables);\n }\n\n if (mainType === 'video') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with video or video sequence.\n return getVideoStrategy(canvas, paintables);\n }\n\n // Unknown fallback.\n return unknownResponse;\n}\n"],"names":["parseSpecificResource","resource","getParsedTargetSelector","canvas","target","imageTarget","source","expandTarget","defaultTarget","emptyActions","unknownResponse","unsupportedStrategy","reason","emptyStrategy","width","height","supportedFormats","get3dStrategy","paintables","getAudioStrategy","audioResource","_a","getImageStrategy","loadImageService","imageTypes","singleImage","imageService","imageServices","getImageServices","imageSelector","found","selector","imageType","parseType","item","languageMap","lang","language","inner","getTextualContentStrategy","items","ytRegex","getVideoStrategy","videoPaintables","t","noDuration","videoResource","isYouTube","service","media","id","getRenderingStrategy","supports","mainType"],"mappings":"yMAYO,SAASA,EAAsBC,EAA2B,CAC3D,OAAAA,EAAS,OA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nB,EAAQe,EAAYK,CAAgB,EAI1D8B,IAAa,SAAWA,IAAa,QACnCD,EAAS,QAAQ,UAAU,IAAM,GAC5BzC,EAAoB,kBAAkB,EAGxCM,EAAcd,EAAQe,CAAU,EAGrCmC,IAAa,cACXD,EAAS,QAAQ,iBAAiB,IAAM,GACnCzC,EAAoB,+BAA+B,EAGrD4B,EAA0BpC,EAAQe,CAAU,EAGjDmC,IAAa,SAAWA,IAAa,QACnCD,EAAS,QAAQ,OAAO,IAAM,GACzBzC,EAAoB,qBAAqB,EAI3CQ,EAAiBhB,EAAQe,CAAU,EAGxCmC,IAAa,QACXD,EAAS,QAAQ,OAAO,IAAM,GACzBzC,EAAoB,qBAAqB,EAI3C+B,EAAiBvC,EAAQe,CAAU,EAIrCR,CACT"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/features/rendering-strategy/rendering-utils.ts","../../../src/features/rendering-strategy/3d-strategy.ts","../../../src/features/rendering-strategy/audio-strategy.ts","../../../src/features/rendering-strategy/image-strategy.ts","../../../src/features/rendering-strategy/textual-content-strategy.ts","../../../src/features/rendering-strategy/video-strategy.ts","../../../src/features/rendering-strategy/get-rendering-strategy.ts"],"sourcesContent":["import { ContentResource, PointSelector, W3CAnnotationTarget } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { UseRenderingStrategy } from '../../hooks/useRenderingStrategy';\nimport { BoxSelector, expandTarget, SupportedTarget, TemporalBoxSelector } from '@iiif/helpers';\n\n/**\n * Parse specific resource.\n *\n * This could be expanded to support pulling out more from the specific resource.\n *\n * @param resource\n */\nexport function parseSpecificResource(resource: ContentResource) {\n if (resource.type === 'SpecificResource') {\n return [resource.source, { selector: resource.selector }];\n }\n\n return [resource, { selector: null }];\n}\n\nexport function getParsedTargetSelector(\n canvas: CanvasNormalized,\n target: W3CAnnotationTarget | W3CAnnotationTarget[]\n): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']] {\n const { selector: imageTarget, source } = expandTarget(target);\n\n if (source.id !== canvas.id) {\n // Skip invalid targets.\n return [null, source];\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n return [\n imageTarget\n ? imageTarget.type === 'TemporalSelector'\n ? ({\n type: 'TemporalBoxSelector',\n temporal: imageTarget.temporal,\n spatial: defaultTarget.spatial,\n } as any)\n : imageTarget\n : null,\n source,\n ];\n}\n\nexport const emptyActions = {\n makeChoice: () => {\n // no-op\n },\n};\n\nexport const unknownResponse: UseRenderingStrategy[0] = { type: 'unknown' };\n\nexport const unsupportedStrategy = (reason: string): UseRenderingStrategy[0] => {\n return { type: 'unknown', reason, annotations: { pages: [] } };\n};\n\nexport const emptyStrategy = (width: number, height: number): UseRenderingStrategy[0] => {\n return { type: 'empty', width, height, annotations: { pages: [] }, image: null, images: [] };\n};\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { AnnotationPageDescription } from './resource-types';\nimport { ExternalWebResource } from '@iiif/presentation-3';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type Single3DModelStrategy = {\n type: '3d-model';\n model: ExternalWebResource;\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nconst supportedFormats = ['model/gltf-binary'];\n\nexport function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const first = paintables.items[0];\n const resource = first.resource as ExternalWebResource;\n\n if (!resource.format) {\n return unsupportedStrategy('Unknown format');\n }\n\n if (supportedFormats.indexOf(resource.format) === -1) {\n return unsupportedStrategy(`3D format: ${resource.format} is unsupported`);\n }\n\n return {\n type: '3d-model',\n model: resource as any,\n } as Single3DModelStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\nexport function getAudioStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n if (!canvas.duration) {\n return unsupportedStrategy('No duration on canvas');\n }\n\n if (paintables.items.length > 1) {\n return unsupportedStrategy('Only one audio source supported');\n }\n\n const audioResource = paintables.items[0]?.resource as any; // @todo stronger type for what this might be.\n\n if (!audioResource) {\n return unsupportedStrategy('Unknown audio');\n }\n\n if (!audioResource.format) {\n return unsupportedStrategy('Audio does not have format');\n }\n\n return {\n type: 'media',\n media: {\n annotationId: paintables.items[0].annotationId,\n duration: canvas.duration,\n url: audioResource.id,\n type: 'Sound',\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: audioResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n },\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { IIIFExternalWebResource } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\nimport { AnnotationPageDescription, ImageWithOptionalService } from './resource-types';\nimport { getImageServices } from '@atlas-viewer/iiif-image-api';\nimport { getParsedTargetSelector, unsupportedStrategy } from './rendering-utils';\nimport { expandTarget } from '@iiif/helpers/annotation-targets';\nimport { BoxSelector, ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type SingleImageStrategy = {\n type: 'images';\n image: ImageWithOptionalService;\n images: Array<ImageWithOptionalService>;\n choice?: ChoiceDescription;\n annotations?: AnnotationPageDescription;\n};\n\nexport function getImageStrategy(\n canvas: CanvasNormalized,\n paintables: Paintables,\n loadImageService: ImageServiceLoaderType\n) {\n const imageTypes: ImageWithOptionalService[] = [];\n for (const singleImage of paintables.items) {\n // SingleImageStrategy\n const resource: IIIFExternalWebResource =\n singleImage.resource && singleImage.resource.type === 'SpecificResource'\n ? singleImage.resource.source\n : singleImage.resource;\n\n // Validation.\n if (!resource.id) {\n // @todo we could skip this?\n return unsupportedStrategy('No resource Identifier');\n }\n\n let imageService = undefined;\n if (resource.service) {\n const imageServices = getImageServices(resource as any) as any[];\n if (imageServices[0]) {\n imageService = loadImageService(imageServices[0], canvas);\n }\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n const [target, source] = getParsedTargetSelector(canvas, singleImage.target);\n if (!(source.id === canvas.id || decodeURIComponent(source.id || '') === (canvas.id || ''))) {\n // Skip invalid targets.\n continue;\n }\n\n // Support for cropping before painting an annotation.\n // @todo this isn't working.\n const defaultImageSelector =\n (singleImage.resource as any).width && (singleImage.resource as any).height\n ? ({\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: (singleImage.resource as any).width,\n height: (singleImage.resource as any).height,\n },\n } as BoxSelector)\n : undefined;\n\n let imageSelector = singleImage.resource.type === 'SpecificResource' ? expandTarget(singleImage.resource) : null;\n\n if (singleImage.selector) {\n const found = expandTarget({\n type: 'SpecificResource',\n source: singleImage.resource,\n selector: singleImage.selector,\n });\n\n if (found) {\n imageSelector = found;\n }\n }\n\n const selector: undefined | BoxSelector =\n imageSelector &&\n imageSelector.selector &&\n (imageSelector.selector.type === 'BoxSelector' || imageSelector.selector.type === 'TemporalBoxSelector')\n ? {\n type: 'BoxSelector',\n spatial: {\n x: imageSelector.selector.spatial.x,\n y: imageSelector.selector.spatial.y,\n width: imageSelector.selector.spatial.width,\n height: imageSelector.selector.spatial.height,\n },\n }\n : undefined;\n\n if (imageService && !imageService.id) {\n (imageService as any).id = imageService['@id'];\n }\n\n const imageType: ImageWithOptionalService = {\n id: resource.id,\n type: 'Image',\n annotationId: (singleImage as any).annotationId,\n width: Number(target || selector ? resource.width : canvas.width),\n height: Number(target || selector ? resource.height : canvas.height),\n service: imageService,\n sizes:\n imageService && imageService.sizes\n ? imageService.sizes\n : resource.width && resource.height\n ? [{ width: resource.width, height: resource.height }]\n : [],\n target: target && target.type !== 'PointSelector' ? target : defaultTarget,\n selector: selector,\n };\n\n imageTypes.push(imageType);\n }\n\n return {\n type: 'images',\n image: imageTypes[0],\n images: imageTypes,\n choice: paintables.choice,\n } as SingleImageStrategy;\n}\n","import { InternationalString } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { AnnotationPageDescription } from './resource-types';\nimport { getParsedTargetSelector } from './rendering-utils';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables, SupportedTarget } from '@iiif/helpers';\n\nexport type TextualContentStrategy = {\n type: 'textual-content';\n items: { annotationId: string; text: InternationalString; target: SupportedTarget | null }[];\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nfunction parseType(item: any, languageMap: InternationalString = {}, lang?: string) {\n const language = item.language || lang || 'none';\n switch (item.type) {\n case 'TextualBody': {\n if (typeof item.value !== 'undefined') {\n languageMap[language] = item.value;\n }\n break;\n }\n case 'List':\n case 'Composite':\n case 'Choice': {\n if (item.items) {\n item.items.forEach((inner: any) => parseType(inner, languageMap, language));\n }\n }\n }\n return languageMap;\n}\n\nexport function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const items: TextualContentStrategy['items'] = [];\n\n paintables.items.forEach((item) => {\n if (item.resource) {\n const [target] = getParsedTargetSelector(canvas, item.target);\n items.push({ annotationId: item.annotationId, text: parseType(item.resource), target: target as any });\n }\n });\n\n return {\n type: 'textual-content',\n items,\n } as TextualContentStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\n// https://stackoverflow.com/a/27728417\nconst ytRegex = /^.*(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/|shorts\\/)|(?:(?:watch)?\\?vi?=|&vi?=))([^#&?]*).*/;\n\nexport function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n const videoPaintables = paintables.items.filter((t) => t.type === 'video');\n\n let noDuration = false;\n\n if (!canvas.duration) {\n noDuration = true;\n }\n\n if (videoPaintables.length > 1) {\n return unsupportedStrategy('Only one video source supported');\n }\n\n const videoResource = videoPaintables[0]?.resource as any; // @todo stronger type for what this might be.\n const isYouTube = !!(videoResource.service || []).find((service: any) =>\n (service.profile || '').includes('youtube.com')\n );\n\n if (!isYouTube && noDuration) {\n return unsupportedStrategy('Video does not have duration');\n }\n\n if (!videoResource) {\n return unsupportedStrategy('Unknown video');\n }\n\n if (!videoResource.format || videoResource.format === 'text/html') {\n if (!isYouTube) {\n return unsupportedStrategy('Video does not have format');\n }\n }\n\n const media = {\n annotationId: (paintables.items[0] as any).annotationId,\n duration: canvas.duration,\n url: videoResource.id,\n type: 'Video',\n items: [],\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: videoResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n };\n\n if (isYouTube) {\n media.type = 'VideoYouTube';\n const id = videoResource.id.match(ytRegex);\n if (!id[1]) {\n return unsupportedStrategy('Video is not known youtube video');\n }\n (media as any).youTubeId = id[1];\n }\n\n // @todo support VTT\n\n return {\n type: 'media',\n media,\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { get3dStrategy } from './3d-strategy';\nimport { getAudioStrategy } from './audio-strategy';\nimport { getImageStrategy } from './image-strategy';\nimport { emptyStrategy, unknownResponse, unsupportedStrategy } from './rendering-utils';\nimport { getTextualContentStrategy } from './textual-content-strategy';\nimport { getVideoStrategy } from './video-strategy';\nimport type { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport type { Paintables } from '@iiif/helpers/painting-annotations';\nimport type { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\n\ninterface GetRenderStrategyOptions {\n canvas: CanvasNormalized | null | undefined;\n paintables: Paintables;\n supports: string[];\n loadImageService: ImageServiceLoaderType;\n}\n\nexport function getRenderingStrategy({ canvas, paintables, supports, loadImageService }: GetRenderStrategyOptions) {\n if (!canvas) {\n console.log('No canvas');\n return unknownResponse;\n }\n\n if (paintables.types.length === 0) {\n if (supports.indexOf('empty') !== -1) {\n return emptyStrategy(canvas.width, canvas.height);\n }\n console.log('No paintables');\n return unknownResponse;\n }\n\n if (paintables.types.length !== 1) {\n if (paintables.types.length === 2 && paintables.types.indexOf('text') !== -1) {\n paintables.types = paintables.types.filter((t) => t !== 'text');\n } else {\n if (supports.indexOf('complex-timeline') === -1) {\n return unsupportedStrategy('Complex timeline not supported');\n }\n return unsupportedStrategy('ComplexTimelineStrategy not yet supported');\n }\n }\n\n const mainType = paintables.types[0];\n\n // Image\n if (mainType === 'image') {\n if (supports.indexOf('images') === -1) {\n return unsupportedStrategy('Image not supported');\n }\n\n return getImageStrategy(canvas, paintables, loadImageService);\n }\n\n // 3D\n if (mainType === 'Model' || mainType === 'model') {\n if (supports.indexOf('3d-model') === -1) {\n return unsupportedStrategy('3D not supported');\n }\n\n return get3dStrategy(canvas, paintables);\n }\n\n if (mainType === 'textualbody') {\n if (supports.indexOf('textual-content') === -1) {\n return unsupportedStrategy('Textual content not supported');\n }\n\n return getTextualContentStrategy(canvas, paintables);\n }\n\n if (mainType === 'sound' || mainType === 'audio') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with audio or audio sequence.\n return getAudioStrategy(canvas, paintables);\n }\n\n if (mainType === 'video') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with video or video sequence.\n return getVideoStrategy(canvas, paintables);\n }\n\n // Unknown fallback.\n return unknownResponse;\n}\n"],"names":["parseSpecificResource","resource","getParsedTargetSelector","canvas","target","imageTarget","source","expandTarget","defaultTarget","emptyActions","unknownResponse","unsupportedStrategy","reason","emptyStrategy","width","height","supportedFormats","get3dStrategy","paintables","getAudioStrategy","audioResource","_a","getImageStrategy","loadImageService","imageTypes","singleImage","imageService","imageServices","getImageServices","imageSelector","found","selector","imageType","parseType","item","languageMap","lang","language","inner","getTextualContentStrategy","items","ytRegex","getVideoStrategy","videoPaintables","t","noDuration","videoResource","isYouTube","service","media","id","getRenderingStrategy","supports","mainType"],"mappings":"yMAYO,SAASA,EAAsBC,EAA2B,CAC3D,OAAAA,EAAS,OAAS,mBACb,CAACA,EAAS,OAAQ,CAAE,SAAUA,EAAS,SAAU,EAGnD,CAACA,EAAU,CAAE,SAAU,IAAM,CAAA,CACtC,CAEgB,SAAAC,EACdC,EACAC,EACuF,CACvF,KAAM,CAAE,SAAUC,EAAa,OAAAC,CAAO,EAAIC,EAAAA,aAAaH,CAAM,EAEzD,GAAAE,EAAO,KAAOH,EAAO,GAEhB,MAAA,CAAC,KAAMG,CAAM,EAItB,MAAME,EAA6B,CACjC,KAAM,cACN,QAAS,CACP,EAAG,EACH,EAAG,EACH,MAAO,OAAOL,EAAO,KAAK,EAC1B,OAAQ,OAAOA,EAAO,MAAM,CAC9B,CAAA,EAGK,MAAA,CACLE,EACIA,EAAY,OAAS,mBAClB,CACC,KAAM,sBACN,SAAUA,EAAY,SACtB,QAASG,EAAc,SAEzBH,EACF,KACJC,CAAA,CAEJ,CAEO,MAAMG,EAAe,CAC1B,WAAY,IAAM,CAElB,CACF,EAEaC,EAA2C,CAAE,KAAM,SAAU,EAE7DC,EAAuBC,IAC3B,CAAE,KAAM,UAAW,OAAAA,EAAQ,YAAa,CAAE,MAAO,CAAC,CAAA,IAG9CC,EAAgB,CAACC,EAAeC,KACpC,CAAE,KAAM,QAAS,MAAAD,EAAO,OAAAC,EAAQ,YAAa,CAAE,MAAO,CAAA,CAAM,EAAA,MAAO,KAAM,OAAQ,CAAG,CAAA,GCvDvFC,EA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GAElD,QAAQ,IAAI,eAAe,EACpBO,GAGL,GAAAQ,EAAW,MAAM,SAAW,EAC1B,GAAAA,EAAW,MAAM,SAAW,GAAKA,EAAW,MAAM,QAAQ,MAAM,IAAM,GACxEA,EAAW,MAAQA,EAAW,MAAM,OAAQ0B,GAAMA,IAAM,MAAM,MAE9D,QAAIQ,EAAS,QAAQ,kBAAkB,IAAM,GACpCzC,EAAoB,gCAAgC,EAEtDA,EAAoB,2CAA2C,EAIpE,MAAA0C,EAAWnC,EAAW,MAAM,CAAC,EAGnC,OAAImC,IAAa,QACXD,EAAS,QAAQ,QAAQ,IAAM,GAC1BzC,EAAoB,qBAAqB,EAG3CW,EAAiBnB,EAAQe,EAAYK,CAAgB,EAI1D8B,IAAa,SAAWA,IAAa,QACnCD,EAAS,QAAQ,UAAU,IAAM,GAC5BzC,EAAoB,kBAAkB,EAGxCM,EAAcd,EAAQe,CAAU,EAGrCmC,IAAa,cACXD,EAAS,QAAQ,iBAAiB,IAAM,GACnCzC,EAAoB,+BAA+B,EAGrD4B,EAA0BpC,EAAQe,CAAU,EAGjDmC,IAAa,SAAWA,IAAa,QACnCD,EAAS,QAAQ,OAAO,IAAM,GACzBzC,EAAoB,qBAAqB,EAI3CQ,EAAiBhB,EAAQe,CAAU,EAGxCmC,IAAa,QACXD,EAAS,QAAQ,OAAO,IAAM,GACzBzC,EAAoB,qBAAqB,EAI3C+B,EAAiBvC,EAAQe,CAAU,EAIrCR,CACT"}
@@ -1,10 +1,10 @@
1
1
  import { expandTarget as S } from "@iiif/helpers";
2
2
  import { getImageServices as T } from "@atlas-viewer/iiif-image-api";
3
- import { expandTarget as p } from "@iiif/helpers/annotation-targets";
4
- function z(e) {
3
+ import { expandTarget as g } from "@iiif/helpers/annotation-targets";
4
+ function b(e) {
5
5
  return e.type === "SpecificResource" ? [e.source, { selector: e.selector }] : [e, { selector: null }];
6
6
  }
7
- function g(e, o) {
7
+ function y(e, o) {
8
8
  const { selector: r, source: i } = S(o);
9
9
  if (i.id !== e.id)
10
10
  return [null, i];
@@ -26,7 +26,7 @@ function g(e, o) {
26
26
  i
27
27
  ];
28
28
  }
29
- const A = {
29
+ const z = {
30
30
  makeChoice: () => {
31
31
  }
32
32
  }, m = { type: "unknown" }, n = (e) => ({ type: "unknown", reason: e, annotations: { pages: [] } }), w = (e, o) => ({ type: "empty", width: e, height: o, annotations: { pages: [] }, image: null, images: [] }), I = ["model/gltf-binary"];
@@ -37,7 +37,7 @@ function O(e, o) {
37
37
  model: i
38
38
  } : n("Unknown format");
39
39
  }
40
- function N(e, o) {
40
+ function R(e, o) {
41
41
  var i;
42
42
  if (!e.duration)
43
43
  return n("No duration on canvas");
@@ -72,7 +72,7 @@ function N(e, o) {
72
72
  }
73
73
  } : n("Audio does not have format") : n("Unknown audio");
74
74
  }
75
- function R(e, o, r) {
75
+ function N(e, o, r) {
76
76
  const i = [];
77
77
  for (const t of o.items) {
78
78
  const u = t.resource && t.resource.type === "SpecificResource" ? t.resource.source : t.resource;
@@ -91,13 +91,13 @@ function R(e, o, r) {
91
91
  width: Number(e.width),
92
92
  height: Number(e.height)
93
93
  }
94
- }, [s, h] = g(e, t.target);
95
- if (h.id !== e.id)
94
+ }, [s, p] = y(e, t.target);
95
+ if (!(p.id === e.id || decodeURIComponent(p.id || "") === (e.id || "")))
96
96
  continue;
97
97
  t.resource.width && t.resource.height && (t.resource.width, t.resource.height);
98
- let c = t.resource.type === "SpecificResource" ? p(t.resource) : null;
98
+ let c = t.resource.type === "SpecificResource" ? g(t.resource) : null;
99
99
  if (t.selector) {
100
- const a = p({
100
+ const a = g({
101
101
  type: "SpecificResource",
102
102
  source: t.resource,
103
103
  selector: t.selector
@@ -134,7 +134,7 @@ function R(e, o, r) {
134
134
  choice: o.choice
135
135
  };
136
136
  }
137
- function y(e, o = {}, r) {
137
+ function h(e, o = {}, r) {
138
138
  const i = e.language || r || "none";
139
139
  switch (e.type) {
140
140
  case "TextualBody": {
@@ -144,7 +144,7 @@ function y(e, o = {}, r) {
144
144
  case "List":
145
145
  case "Composite":
146
146
  case "Choice":
147
- e.items && e.items.forEach((t) => y(t, o, i));
147
+ e.items && e.items.forEach((t) => h(t, o, i));
148
148
  }
149
149
  return o;
150
150
  }
@@ -152,8 +152,8 @@ function k(e, o) {
152
152
  const r = [];
153
153
  return o.items.forEach((i) => {
154
154
  if (i.resource) {
155
- const [t] = g(e, i.target);
156
- r.push({ annotationId: i.annotationId, text: y(i.resource), target: t });
155
+ const [t] = y(e, i.target);
156
+ r.push({ annotationId: i.annotationId, text: h(i.resource), target: t });
157
157
  }
158
158
  }), {
159
159
  type: "textual-content",
@@ -161,7 +161,7 @@ function k(e, o) {
161
161
  };
162
162
  }
163
163
  const B = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;
164
- function v(e, o) {
164
+ function C(e, o) {
165
165
  var f;
166
166
  const r = o.items.filter((s) => s.type === "video");
167
167
  let i = !1;
@@ -213,7 +213,7 @@ function v(e, o) {
213
213
  }
214
214
  };
215
215
  }
216
- function D({ canvas: e, paintables: o, supports: r, loadImageService: i }) {
216
+ function A({ canvas: e, paintables: o, supports: r, loadImageService: i }) {
217
217
  if (!e)
218
218
  return console.log("No canvas"), m;
219
219
  if (o.types.length === 0)
@@ -224,14 +224,14 @@ function D({ canvas: e, paintables: o, supports: r, loadImageService: i }) {
224
224
  else
225
225
  return r.indexOf("complex-timeline") === -1 ? n("Complex timeline not supported") : n("ComplexTimelineStrategy not yet supported");
226
226
  const t = o.types[0];
227
- return t === "image" ? r.indexOf("images") === -1 ? n("Image not supported") : R(e, o, i) : t === "Model" || t === "model" ? r.indexOf("3d-model") === -1 ? n("3D not supported") : O(e, o) : t === "textualbody" ? r.indexOf("textual-content") === -1 ? n("Textual content not supported") : k(e, o) : t === "sound" || t === "audio" ? r.indexOf("media") === -1 ? n("Media not supported") : N(e, o) : t === "video" ? r.indexOf("media") === -1 ? n("Media not supported") : v(e, o) : m;
227
+ return t === "image" ? r.indexOf("images") === -1 ? n("Image not supported") : N(e, o, i) : t === "Model" || t === "model" ? r.indexOf("3d-model") === -1 ? n("3D not supported") : O(e, o) : t === "textualbody" ? r.indexOf("textual-content") === -1 ? n("Textual content not supported") : k(e, o) : t === "sound" || t === "audio" ? r.indexOf("media") === -1 ? n("Media not supported") : R(e, o) : t === "video" ? r.indexOf("media") === -1 ? n("Media not supported") : C(e, o) : m;
228
228
  }
229
229
  export {
230
- A as emptyActions,
230
+ z as emptyActions,
231
231
  w as emptyStrategy,
232
- g as getParsedTargetSelector,
233
- D as getRenderingStrategy,
234
- z as parseSpecificResource,
232
+ y as getParsedTargetSelector,
233
+ A as getRenderingStrategy,
234
+ b as parseSpecificResource,
235
235
  m as unknownResponse,
236
236
  n as unsupportedStrategy
237
237
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../../../src/features/rendering-strategy/rendering-utils.ts","../../../src/features/rendering-strategy/3d-strategy.ts","../../../src/features/rendering-strategy/audio-strategy.ts","../../../src/features/rendering-strategy/image-strategy.ts","../../../src/features/rendering-strategy/textual-content-strategy.ts","../../../src/features/rendering-strategy/video-strategy.ts","../../../src/features/rendering-strategy/get-rendering-strategy.ts"],"sourcesContent":["import { ContentResource, PointSelector, W3CAnnotationTarget } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { UseRenderingStrategy } from '../../hooks/useRenderingStrategy';\nimport { BoxSelector, expandTarget, SupportedTarget, TemporalBoxSelector } from '@iiif/helpers';\n\n/**\n * Parse specific resource.\n *\n * This could be expanded to support pulling out more from the specific resource.\n *\n * @param resource\n */\nexport function parseSpecificResource(resource: ContentResource) {\n if (resource.type === 'SpecificResource') {\n return [resource.source, { selector: resource.selector }];\n }\n\n return [resource, { selector: null }];\n}\n\nexport function getParsedTargetSelector(\n canvas: CanvasNormalized,\n target: W3CAnnotationTarget | W3CAnnotationTarget[]\n): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']] {\n const { selector: imageTarget, source } = expandTarget(target);\n\n if (source.id !== canvas.id) {\n // Skip invalid targets.\n return [null, source];\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n return [\n imageTarget\n ? imageTarget.type === 'TemporalSelector'\n ? ({\n type: 'TemporalBoxSelector',\n temporal: imageTarget.temporal,\n spatial: defaultTarget.spatial,\n } as any)\n : imageTarget\n : null,\n source,\n ];\n}\n\nexport const emptyActions = {\n makeChoice: () => {\n // no-op\n },\n};\n\nexport const unknownResponse: UseRenderingStrategy[0] = { type: 'unknown' };\n\nexport const unsupportedStrategy = (reason: string): UseRenderingStrategy[0] => {\n return { type: 'unknown', reason, annotations: { pages: [] } };\n};\n\nexport const emptyStrategy = (width: number, height: number): UseRenderingStrategy[0] => {\n return { type: 'empty', width, height, annotations: { pages: [] }, image: null, images: [] };\n};\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { AnnotationPageDescription } from './resource-types';\nimport { ExternalWebResource } from '@iiif/presentation-3';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type Single3DModelStrategy = {\n type: '3d-model';\n model: ExternalWebResource;\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nconst supportedFormats = ['model/gltf-binary'];\n\nexport function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const first = paintables.items[0];\n const resource = first.resource as ExternalWebResource;\n\n if (!resource.format) {\n return unsupportedStrategy('Unknown format');\n }\n\n if (supportedFormats.indexOf(resource.format) === -1) {\n return unsupportedStrategy(`3D format: ${resource.format} is unsupported`);\n }\n\n return {\n type: '3d-model',\n model: resource as any,\n } as Single3DModelStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\nexport function getAudioStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n if (!canvas.duration) {\n return unsupportedStrategy('No duration on canvas');\n }\n\n if (paintables.items.length > 1) {\n return unsupportedStrategy('Only one audio source supported');\n }\n\n const audioResource = paintables.items[0]?.resource as any; // @todo stronger type for what this might be.\n\n if (!audioResource) {\n return unsupportedStrategy('Unknown audio');\n }\n\n if (!audioResource.format) {\n return unsupportedStrategy('Audio does not have format');\n }\n\n return {\n type: 'media',\n media: {\n annotationId: paintables.items[0].annotationId,\n duration: canvas.duration,\n url: audioResource.id,\n type: 'Sound',\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: audioResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n },\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { IIIFExternalWebResource } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\nimport { AnnotationPageDescription, ImageWithOptionalService } from './resource-types';\nimport { getImageServices } from '@atlas-viewer/iiif-image-api';\nimport { getParsedTargetSelector, unsupportedStrategy } from './rendering-utils';\nimport { expandTarget } from '@iiif/helpers/annotation-targets';\nimport { BoxSelector, ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type SingleImageStrategy = {\n type: 'images';\n image: ImageWithOptionalService;\n images: Array<ImageWithOptionalService>;\n choice?: ChoiceDescription;\n annotations?: AnnotationPageDescription;\n};\n\nexport function getImageStrategy(\n canvas: CanvasNormalized,\n paintables: Paintables,\n loadImageService: ImageServiceLoaderType\n) {\n const imageTypes: ImageWithOptionalService[] = [];\n for (const singleImage of paintables.items) {\n // SingleImageStrategy\n const resource: IIIFExternalWebResource =\n singleImage.resource && singleImage.resource.type === 'SpecificResource'\n ? singleImage.resource.source\n : singleImage.resource;\n\n // Validation.\n if (!resource.id) {\n // @todo we could skip this?\n return unsupportedStrategy('No resource Identifier');\n }\n\n let imageService = undefined;\n if (resource.service) {\n const imageServices = getImageServices(resource as any) as any[];\n if (imageServices[0]) {\n imageService = loadImageService(imageServices[0], canvas);\n }\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n const [target, source] = getParsedTargetSelector(canvas, singleImage.target);\n if (source.id !== canvas.id) {\n // Skip invalid targets.\n continue;\n }\n\n // Support for cropping before painting an annotation.\n // @todo this isn't working.\n const defaultImageSelector =\n (singleImage.resource as any).width && (singleImage.resource as any).height\n ? ({\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: (singleImage.resource as any).width,\n height: (singleImage.resource as any).height,\n },\n } as BoxSelector)\n : undefined;\n\n let imageSelector = singleImage.resource.type === 'SpecificResource' ? expandTarget(singleImage.resource) : null;\n\n if (singleImage.selector) {\n const found = expandTarget({\n type: 'SpecificResource',\n source: singleImage.resource,\n selector: singleImage.selector,\n });\n\n if (found) {\n imageSelector = found;\n }\n }\n\n const selector: undefined | BoxSelector =\n imageSelector &&\n imageSelector.selector &&\n (imageSelector.selector.type === 'BoxSelector' || imageSelector.selector.type === 'TemporalBoxSelector')\n ? {\n type: 'BoxSelector',\n spatial: {\n x: imageSelector.selector.spatial.x,\n y: imageSelector.selector.spatial.y,\n width: imageSelector.selector.spatial.width,\n height: imageSelector.selector.spatial.height,\n },\n }\n : undefined;\n\n if (imageService && !imageService.id) {\n (imageService as any).id = imageService['@id'];\n }\n\n const imageType: ImageWithOptionalService = {\n id: resource.id,\n type: 'Image',\n annotationId: (singleImage as any).annotationId,\n width: Number(target || selector ? resource.width : canvas.width),\n height: Number(target || selector ? resource.height : canvas.height),\n service: imageService,\n sizes:\n imageService && imageService.sizes\n ? imageService.sizes\n : resource.width && resource.height\n ? [{ width: resource.width, height: resource.height }]\n : [],\n target: target && target.type !== 'PointSelector' ? target : defaultTarget,\n selector: selector,\n };\n\n imageTypes.push(imageType);\n }\n\n return {\n type: 'images',\n image: imageTypes[0],\n images: imageTypes,\n choice: paintables.choice,\n } as SingleImageStrategy;\n}\n","import { InternationalString } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { AnnotationPageDescription } from './resource-types';\nimport { getParsedTargetSelector } from './rendering-utils';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables, SupportedTarget } from '@iiif/helpers';\n\nexport type TextualContentStrategy = {\n type: 'textual-content';\n items: { annotationId: string; text: InternationalString; target: SupportedTarget | null }[];\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nfunction parseType(item: any, languageMap: InternationalString = {}, lang?: string) {\n const language = item.language || lang || 'none';\n switch (item.type) {\n case 'TextualBody': {\n if (typeof item.value !== 'undefined') {\n languageMap[language] = item.value;\n }\n break;\n }\n case 'List':\n case 'Composite':\n case 'Choice': {\n if (item.items) {\n item.items.forEach((inner: any) => parseType(inner, languageMap, language));\n }\n }\n }\n return languageMap;\n}\n\nexport function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const items: TextualContentStrategy['items'] = [];\n\n paintables.items.forEach((item) => {\n if (item.resource) {\n const [target] = getParsedTargetSelector(canvas, item.target);\n items.push({ annotationId: item.annotationId, text: parseType(item.resource), target: target as any });\n }\n });\n\n return {\n type: 'textual-content',\n items,\n } as TextualContentStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\n// https://stackoverflow.com/a/27728417\nconst ytRegex = /^.*(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/|shorts\\/)|(?:(?:watch)?\\?vi?=|&vi?=))([^#&?]*).*/;\n\nexport function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n const videoPaintables = paintables.items.filter((t) => t.type === 'video');\n\n let noDuration = false;\n\n if (!canvas.duration) {\n noDuration = true;\n }\n\n if (videoPaintables.length > 1) {\n return unsupportedStrategy('Only one video source supported');\n }\n\n const videoResource = videoPaintables[0]?.resource as any; // @todo stronger type for what this might be.\n const isYouTube = !!(videoResource.service || []).find((service: any) =>\n (service.profile || '').includes('youtube.com')\n );\n\n if (!isYouTube && noDuration) {\n return unsupportedStrategy('Video does not have duration');\n }\n\n if (!videoResource) {\n return unsupportedStrategy('Unknown video');\n }\n\n if (!videoResource.format || videoResource.format === 'text/html') {\n if (!isYouTube) {\n return unsupportedStrategy('Video does not have format');\n }\n }\n\n const media = {\n annotationId: (paintables.items[0] as any).annotationId,\n duration: canvas.duration,\n url: videoResource.id,\n type: 'Video',\n items: [],\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: videoResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n };\n\n if (isYouTube) {\n media.type = 'VideoYouTube';\n const id = videoResource.id.match(ytRegex);\n if (!id[1]) {\n return unsupportedStrategy('Video is not known youtube video');\n }\n (media as any).youTubeId = id[1];\n }\n\n // @todo support VTT\n\n return {\n type: 'media',\n media,\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { get3dStrategy } from './3d-strategy';\nimport { getAudioStrategy } from './audio-strategy';\nimport { getImageStrategy } from './image-strategy';\nimport { emptyStrategy, unknownResponse, unsupportedStrategy } from './rendering-utils';\nimport { getTextualContentStrategy } from './textual-content-strategy';\nimport { getVideoStrategy } from './video-strategy';\nimport type { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport type { Paintables } from '@iiif/helpers/painting-annotations';\nimport type { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\n\ninterface GetRenderStrategyOptions {\n canvas: CanvasNormalized | null | undefined;\n paintables: Paintables;\n supports: string[];\n loadImageService: ImageServiceLoaderType;\n}\n\nexport function getRenderingStrategy({ canvas, paintables, supports, loadImageService }: GetRenderStrategyOptions) {\n if (!canvas) {\n console.log('No canvas');\n return unknownResponse;\n }\n\n if (paintables.types.length === 0) {\n if (supports.indexOf('empty') !== -1) {\n return emptyStrategy(canvas.width, canvas.height);\n }\n console.log('No paintables');\n return unknownResponse;\n }\n\n if (paintables.types.length !== 1) {\n if (paintables.types.length === 2 && paintables.types.indexOf('text') !== -1) {\n paintables.types = paintables.types.filter((t) => t !== 'text');\n } else {\n if (supports.indexOf('complex-timeline') === -1) {\n return unsupportedStrategy('Complex timeline not supported');\n }\n return unsupportedStrategy('ComplexTimelineStrategy not yet supported');\n }\n }\n\n const mainType = paintables.types[0];\n\n // Image\n if (mainType === 'image') {\n if (supports.indexOf('images') === -1) {\n return unsupportedStrategy('Image not supported');\n }\n\n return getImageStrategy(canvas, paintables, loadImageService);\n }\n\n // 3D\n if (mainType === 'Model' || mainType === 'model') {\n if (supports.indexOf('3d-model') === -1) {\n return unsupportedStrategy('3D not supported');\n }\n\n return get3dStrategy(canvas, paintables);\n }\n\n if (mainType === 'textualbody') {\n if (supports.indexOf('textual-content') === -1) {\n return unsupportedStrategy('Textual content not supported');\n }\n\n return getTextualContentStrategy(canvas, paintables);\n }\n\n if (mainType === 'sound' || mainType === 'audio') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with audio or audio sequence.\n return getAudioStrategy(canvas, paintables);\n }\n\n if (mainType === 'video') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with video or video sequence.\n return getVideoStrategy(canvas, paintables);\n }\n\n // Unknown fallback.\n return unknownResponse;\n}\n"],"names":["parseSpecificResource","resource","getParsedTargetSelector","canvas","target","imageTarget","source","expandTarget","defaultTarget","emptyActions","unknownResponse","unsupportedStrategy","reason","emptyStrategy","width","height","supportedFormats","get3dStrategy","paintables","getAudioStrategy","audioResource","_a","getImageStrategy","loadImageService","imageTypes","singleImage","imageService","imageServices","getImageServices","imageSelector","found","selector","imageType","parseType","item","languageMap","lang","language","inner","getTextualContentStrategy","items","ytRegex","getVideoStrategy","videoPaintables","t","noDuration","videoResource","isYouTube","service","media","id","getRenderingStrategy","supports","mainType"],"mappings":";;;AAYO,SAASA,EAAsBC,GAA2B;AAC3D,SAAAA,EAAS,SAAS,qBACb,CAACA,EAAS,QAAQ,EAAE,UAAUA,EAAS,UAAU,IAGnD,CAACA,GAAU,EAAE,UAAU,KAAM,CAAA;AACtC;AAEgB,SAAAC,EACdC,GACAC,GACuF;AACvF,QAAM,EAAE,UAAUC,GAAa,QAAAC,EAAO,IAAIC,EAAaH,CAAM;AAEzD,MAAAE,EAAO,OAAOH,EAAO;AAEhB,WAAA,CAAC,MAAMG,CAAM;AAItB,QAAME,IAA6B;AAAA,IACjC,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,OAAO,OAAOL,EAAO,KAAK;AAAA,MAC1B,QAAQ,OAAOA,EAAO,MAAM;AAAA,IAC9B;AAAA,EAAA;AAGK,SAAA;AAAA,IACLE,IACIA,EAAY,SAAS,qBAClB;AAAA,MACC,MAAM;AAAA,MACN,UAAUA,EAAY;AAAA,MACtB,SAASG,EAAc;AAAA,QAEzBH,IACF;AAAA,IACJC;AAAA,EAAA;AAEJ;AAEO,MAAMG,IAAe;AAAA,EAC1B,YAAY,MAAM;AAAA,EAElB;AACF,GAEaC,IAA2C,EAAE,MAAM,UAAU,GAE7DC,IAAsB,CAACC,OAC3B,EAAE,MAAM,WAAW,QAAAA,GAAQ,aAAa,EAAE,OAAO,CAAC,EAAA,MAG9CC,IAAgB,CAACC,GAAeC,OACpC,EA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,GAAYK,CAAgB,IAI1D8B,MAAa,WAAWA,MAAa,UACnCD,EAAS,QAAQ,UAAU,MAAM,KAC5BzC,EAAoB,kBAAkB,IAGxCM,EAAcd,GAAQe,CAAU,IAGrCmC,MAAa,gBACXD,EAAS,QAAQ,iBAAiB,MAAM,KACnCzC,EAAoB,+BAA+B,IAGrD4B,EAA0BpC,GAAQe,CAAU,IAGjDmC,MAAa,WAAWA,MAAa,UACnCD,EAAS,QAAQ,OAAO,MAAM,KACzBzC,EAAoB,qBAAqB,IAI3CQ,EAAiBhB,GAAQe,CAAU,IAGxCmC,MAAa,UACXD,EAAS,QAAQ,OAAO,MAAM,KACzBzC,EAAoB,qBAAqB,IAI3C+B,EAAiBvC,GAAQe,CAAU,IAIrCR;AACT;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../../src/features/rendering-strategy/rendering-utils.ts","../../../src/features/rendering-strategy/3d-strategy.ts","../../../src/features/rendering-strategy/audio-strategy.ts","../../../src/features/rendering-strategy/image-strategy.ts","../../../src/features/rendering-strategy/textual-content-strategy.ts","../../../src/features/rendering-strategy/video-strategy.ts","../../../src/features/rendering-strategy/get-rendering-strategy.ts"],"sourcesContent":["import { ContentResource, PointSelector, W3CAnnotationTarget } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { UseRenderingStrategy } from '../../hooks/useRenderingStrategy';\nimport { BoxSelector, expandTarget, SupportedTarget, TemporalBoxSelector } from '@iiif/helpers';\n\n/**\n * Parse specific resource.\n *\n * This could be expanded to support pulling out more from the specific resource.\n *\n * @param resource\n */\nexport function parseSpecificResource(resource: ContentResource) {\n if (resource.type === 'SpecificResource') {\n return [resource.source, { selector: resource.selector }];\n }\n\n return [resource, { selector: null }];\n}\n\nexport function getParsedTargetSelector(\n canvas: CanvasNormalized,\n target: W3CAnnotationTarget | W3CAnnotationTarget[]\n): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']] {\n const { selector: imageTarget, source } = expandTarget(target);\n\n if (source.id !== canvas.id) {\n // Skip invalid targets.\n return [null, source];\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n return [\n imageTarget\n ? imageTarget.type === 'TemporalSelector'\n ? ({\n type: 'TemporalBoxSelector',\n temporal: imageTarget.temporal,\n spatial: defaultTarget.spatial,\n } as any)\n : imageTarget\n : null,\n source,\n ];\n}\n\nexport const emptyActions = {\n makeChoice: () => {\n // no-op\n },\n};\n\nexport const unknownResponse: UseRenderingStrategy[0] = { type: 'unknown' };\n\nexport const unsupportedStrategy = (reason: string): UseRenderingStrategy[0] => {\n return { type: 'unknown', reason, annotations: { pages: [] } };\n};\n\nexport const emptyStrategy = (width: number, height: number): UseRenderingStrategy[0] => {\n return { type: 'empty', width, height, annotations: { pages: [] }, image: null, images: [] };\n};\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { AnnotationPageDescription } from './resource-types';\nimport { ExternalWebResource } from '@iiif/presentation-3';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type Single3DModelStrategy = {\n type: '3d-model';\n model: ExternalWebResource;\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nconst supportedFormats = ['model/gltf-binary'];\n\nexport function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const first = paintables.items[0];\n const resource = first.resource as ExternalWebResource;\n\n if (!resource.format) {\n return unsupportedStrategy('Unknown format');\n }\n\n if (supportedFormats.indexOf(resource.format) === -1) {\n return unsupportedStrategy(`3D format: ${resource.format} is unsupported`);\n }\n\n return {\n type: '3d-model',\n model: resource as any,\n } as Single3DModelStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\nexport function getAudioStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n if (!canvas.duration) {\n return unsupportedStrategy('No duration on canvas');\n }\n\n if (paintables.items.length > 1) {\n return unsupportedStrategy('Only one audio source supported');\n }\n\n const audioResource = paintables.items[0]?.resource as any; // @todo stronger type for what this might be.\n\n if (!audioResource) {\n return unsupportedStrategy('Unknown audio');\n }\n\n if (!audioResource.format) {\n return unsupportedStrategy('Audio does not have format');\n }\n\n return {\n type: 'media',\n media: {\n annotationId: paintables.items[0].annotationId,\n duration: canvas.duration,\n url: audioResource.id,\n type: 'Sound',\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: audioResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n },\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { IIIFExternalWebResource } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\nimport { AnnotationPageDescription, ImageWithOptionalService } from './resource-types';\nimport { getImageServices } from '@atlas-viewer/iiif-image-api';\nimport { getParsedTargetSelector, unsupportedStrategy } from './rendering-utils';\nimport { expandTarget } from '@iiif/helpers/annotation-targets';\nimport { BoxSelector, ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type SingleImageStrategy = {\n type: 'images';\n image: ImageWithOptionalService;\n images: Array<ImageWithOptionalService>;\n choice?: ChoiceDescription;\n annotations?: AnnotationPageDescription;\n};\n\nexport function getImageStrategy(\n canvas: CanvasNormalized,\n paintables: Paintables,\n loadImageService: ImageServiceLoaderType\n) {\n const imageTypes: ImageWithOptionalService[] = [];\n for (const singleImage of paintables.items) {\n // SingleImageStrategy\n const resource: IIIFExternalWebResource =\n singleImage.resource && singleImage.resource.type === 'SpecificResource'\n ? singleImage.resource.source\n : singleImage.resource;\n\n // Validation.\n if (!resource.id) {\n // @todo we could skip this?\n return unsupportedStrategy('No resource Identifier');\n }\n\n let imageService = undefined;\n if (resource.service) {\n const imageServices = getImageServices(resource as any) as any[];\n if (imageServices[0]) {\n imageService = loadImageService(imageServices[0], canvas);\n }\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n const [target, source] = getParsedTargetSelector(canvas, singleImage.target);\n if (!(source.id === canvas.id || decodeURIComponent(source.id || '') === (canvas.id || ''))) {\n // Skip invalid targets.\n continue;\n }\n\n // Support for cropping before painting an annotation.\n // @todo this isn't working.\n const defaultImageSelector =\n (singleImage.resource as any).width && (singleImage.resource as any).height\n ? ({\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: (singleImage.resource as any).width,\n height: (singleImage.resource as any).height,\n },\n } as BoxSelector)\n : undefined;\n\n let imageSelector = singleImage.resource.type === 'SpecificResource' ? expandTarget(singleImage.resource) : null;\n\n if (singleImage.selector) {\n const found = expandTarget({\n type: 'SpecificResource',\n source: singleImage.resource,\n selector: singleImage.selector,\n });\n\n if (found) {\n imageSelector = found;\n }\n }\n\n const selector: undefined | BoxSelector =\n imageSelector &&\n imageSelector.selector &&\n (imageSelector.selector.type === 'BoxSelector' || imageSelector.selector.type === 'TemporalBoxSelector')\n ? {\n type: 'BoxSelector',\n spatial: {\n x: imageSelector.selector.spatial.x,\n y: imageSelector.selector.spatial.y,\n width: imageSelector.selector.spatial.width,\n height: imageSelector.selector.spatial.height,\n },\n }\n : undefined;\n\n if (imageService && !imageService.id) {\n (imageService as any).id = imageService['@id'];\n }\n\n const imageType: ImageWithOptionalService = {\n id: resource.id,\n type: 'Image',\n annotationId: (singleImage as any).annotationId,\n width: Number(target || selector ? resource.width : canvas.width),\n height: Number(target || selector ? resource.height : canvas.height),\n service: imageService,\n sizes:\n imageService && imageService.sizes\n ? imageService.sizes\n : resource.width && resource.height\n ? [{ width: resource.width, height: resource.height }]\n : [],\n target: target && target.type !== 'PointSelector' ? target : defaultTarget,\n selector: selector,\n };\n\n imageTypes.push(imageType);\n }\n\n return {\n type: 'images',\n image: imageTypes[0],\n images: imageTypes,\n choice: paintables.choice,\n } as SingleImageStrategy;\n}\n","import { InternationalString } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { AnnotationPageDescription } from './resource-types';\nimport { getParsedTargetSelector } from './rendering-utils';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables, SupportedTarget } from '@iiif/helpers';\n\nexport type TextualContentStrategy = {\n type: 'textual-content';\n items: { annotationId: string; text: InternationalString; target: SupportedTarget | null }[];\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nfunction parseType(item: any, languageMap: InternationalString = {}, lang?: string) {\n const language = item.language || lang || 'none';\n switch (item.type) {\n case 'TextualBody': {\n if (typeof item.value !== 'undefined') {\n languageMap[language] = item.value;\n }\n break;\n }\n case 'List':\n case 'Composite':\n case 'Choice': {\n if (item.items) {\n item.items.forEach((inner: any) => parseType(inner, languageMap, language));\n }\n }\n }\n return languageMap;\n}\n\nexport function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const items: TextualContentStrategy['items'] = [];\n\n paintables.items.forEach((item) => {\n if (item.resource) {\n const [target] = getParsedTargetSelector(canvas, item.target);\n items.push({ annotationId: item.annotationId, text: parseType(item.resource), target: target as any });\n }\n });\n\n return {\n type: 'textual-content',\n items,\n } as TextualContentStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\n// https://stackoverflow.com/a/27728417\nconst ytRegex = /^.*(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/|shorts\\/)|(?:(?:watch)?\\?vi?=|&vi?=))([^#&?]*).*/;\n\nexport function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n const videoPaintables = paintables.items.filter((t) => t.type === 'video');\n\n let noDuration = false;\n\n if (!canvas.duration) {\n noDuration = true;\n }\n\n if (videoPaintables.length > 1) {\n return unsupportedStrategy('Only one video source supported');\n }\n\n const videoResource = videoPaintables[0]?.resource as any; // @todo stronger type for what this might be.\n const isYouTube = !!(videoResource.service || []).find((service: any) =>\n (service.profile || '').includes('youtube.com')\n );\n\n if (!isYouTube && noDuration) {\n return unsupportedStrategy('Video does not have duration');\n }\n\n if (!videoResource) {\n return unsupportedStrategy('Unknown video');\n }\n\n if (!videoResource.format || videoResource.format === 'text/html') {\n if (!isYouTube) {\n return unsupportedStrategy('Video does not have format');\n }\n }\n\n const media = {\n annotationId: (paintables.items[0] as any).annotationId,\n duration: canvas.duration,\n url: videoResource.id,\n type: 'Video',\n items: [],\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: videoResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n };\n\n if (isYouTube) {\n media.type = 'VideoYouTube';\n const id = videoResource.id.match(ytRegex);\n if (!id[1]) {\n return unsupportedStrategy('Video is not known youtube video');\n }\n (media as any).youTubeId = id[1];\n }\n\n // @todo support VTT\n\n return {\n type: 'media',\n media,\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { get3dStrategy } from './3d-strategy';\nimport { getAudioStrategy } from './audio-strategy';\nimport { getImageStrategy } from './image-strategy';\nimport { emptyStrategy, unknownResponse, unsupportedStrategy } from './rendering-utils';\nimport { getTextualContentStrategy } from './textual-content-strategy';\nimport { getVideoStrategy } from './video-strategy';\nimport type { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport type { Paintables } from '@iiif/helpers/painting-annotations';\nimport type { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\n\ninterface GetRenderStrategyOptions {\n canvas: CanvasNormalized | null | undefined;\n paintables: Paintables;\n supports: string[];\n loadImageService: ImageServiceLoaderType;\n}\n\nexport function getRenderingStrategy({ canvas, paintables, supports, loadImageService }: GetRenderStrategyOptions) {\n if (!canvas) {\n console.log('No canvas');\n return unknownResponse;\n }\n\n if (paintables.types.length === 0) {\n if (supports.indexOf('empty') !== -1) {\n return emptyStrategy(canvas.width, canvas.height);\n }\n console.log('No paintables');\n return unknownResponse;\n }\n\n if (paintables.types.length !== 1) {\n if (paintables.types.length === 2 && paintables.types.indexOf('text') !== -1) {\n paintables.types = paintables.types.filter((t) => t !== 'text');\n } else {\n if (supports.indexOf('complex-timeline') === -1) {\n return unsupportedStrategy('Complex timeline not supported');\n }\n return unsupportedStrategy('ComplexTimelineStrategy not yet supported');\n }\n }\n\n const mainType = paintables.types[0];\n\n // Image\n if (mainType === 'image') {\n if (supports.indexOf('images') === -1) {\n return unsupportedStrategy('Image not supported');\n }\n\n return getImageStrategy(canvas, paintables, loadImageService);\n }\n\n // 3D\n if (mainType === 'Model' || mainType === 'model') {\n if (supports.indexOf('3d-model') === -1) {\n return unsupportedStrategy('3D not supported');\n }\n\n return get3dStrategy(canvas, paintables);\n }\n\n if (mainType === 'textualbody') {\n if (supports.indexOf('textual-content') === -1) {\n return unsupportedStrategy('Textual content not supported');\n }\n\n return getTextualContentStrategy(canvas, paintables);\n }\n\n if (mainType === 'sound' || mainType === 'audio') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with audio or audio sequence.\n return getAudioStrategy(canvas, paintables);\n }\n\n if (mainType === 'video') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with video or video sequence.\n return getVideoStrategy(canvas, paintables);\n }\n\n // Unknown fallback.\n return unknownResponse;\n}\n"],"names":["parseSpecificResource","resource","getParsedTargetSelector","canvas","target","imageTarget","source","expandTarget","defaultTarget","emptyActions","unknownResponse","unsupportedStrategy","reason","emptyStrategy","width","height","supportedFormats","get3dStrategy","paintables","getAudioStrategy","audioResource","_a","getImageStrategy","loadImageService","imageTypes","singleImage","imageService","imageServices","getImageServices","imageSelector","found","selector","imageType","parseType","item","languageMap","lang","language","inner","getTextualContentStrategy","items","ytRegex","getVideoStrategy","videoPaintables","t","noDuration","videoResource","isYouTube","service","media","id","getRenderingStrategy","supports","mainType"],"mappings":";;;AAYO,SAASA,EAAsBC,GAA2B;AAC3D,SAAAA,EAAS,SAAS,qBACb,CAACA,EAAS,QAAQ,EAAE,UAAUA,EAAS,UAAU,IAGnD,CAACA,GAAU,EAAE,UAAU,KAAM,CAAA;AACtC;AAEgB,SAAAC,EACdC,GACAC,GACuF;AACvF,QAAM,EAAE,UAAUC,GAAa,QAAAC,EAAO,IAAIC,EAAaH,CAAM;AAEzD,MAAAE,EAAO,OAAOH,EAAO;AAEhB,WAAA,CAAC,MAAMG,CAAM;AAItB,QAAME,IAA6B;AAAA,IACjC,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,OAAO,OAAOL,EAAO,KAAK;AAAA,MAC1B,QAAQ,OAAOA,EAAO,MAAM;AAAA,IAC9B;AAAA,EAAA;AAGK,SAAA;AAAA,IACLE,IACIA,EAAY,SAAS,qBAClB;AAAA,MACC,MAAM;AAAA,MACN,UAAUA,EAAY;AAAA,MACtB,SAASG,EAAc;AAAA,QAEzBH,IACF;AAAA,IACJC;AAAA,EAAA;AAEJ;AAEO,MAAMG,IAAe;AAAA,EAC1B,YAAY,MAAM;AAAA,EAElB;AACF,GAEaC,IAA2C,EAAE,MAAM,UAAU,GAE7DC,IAAsB,CAACC,OAC3B,EAAE,MAAM,WAAW,QAAAA,GAAQ,aAAa,EAAE,OAAO,CAAC,EAAA,MAG9CC,IAAgB,CAACC,GAAeC,OACpC,EAAE,MAAM,SAAS,OAAAD,GAAO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BAAqB,IAG3CW,EAAiBnB,GAAQe,GAAYK,CAAgB,IAI1D8B,MAAa,WAAWA,MAAa,UACnCD,EAAS,QAAQ,UAAU,MAAM,KAC5BzC,EAAoB,kBAAkB,IAGxCM,EAAcd,GAAQe,CAAU,IAGrCmC,MAAa,gBACXD,EAAS,QAAQ,iBAAiB,MAAM,KACnCzC,EAAoB,+BAA+B,IAGrD4B,EAA0BpC,GAAQe,CAAU,IAGjDmC,MAAa,WAAWA,MAAa,UACnCD,EAAS,QAAQ,OAAO,MAAM,KACzBzC,EAAoB,qBAAqB,IAI3CQ,EAAiBhB,GAAQe,CAAU,IAGxCmC,MAAa,UACXD,EAAS,QAAQ,OAAO,MAAM,KACzBzC,EAAoB,qBAAqB,IAI3C+B,EAAiBvC,GAAQe,CAAU,IAIrCR;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iiif-vault",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "main": "dist/bundle/cjs/index.js",
5
5
  "module": "dist/bundle/esm/index.mjs",
6
6
  "types": ".build/types/index.d.ts",
@@ -55,42 +55,44 @@
55
55
  },
56
56
  "license": "MIT",
57
57
  "dependencies": {
58
- "@atlas-viewer/atlas": ">=2.0.4",
58
+ "@atlas-viewer/atlas": ">=2.0.6",
59
59
  "@atlas-viewer/iiif-image-api": ">=2.1.1",
60
- "@iiif/parser": ">=2.0.1",
60
+ "@iiif/helpers": ">=1.0.6",
61
+ "@iiif/parser": ">=2.0.2",
61
62
  "@iiif/presentation-2": ">=1.*",
62
63
  "@iiif/presentation-3": ">=2.1.3",
63
64
  "@iiif/presentation-3-normalized": ">=0.9.7",
64
- "@iiif/helpers": ">=1.0.4",
65
65
  "react": "^16.10.2 || ^17.0.2 || ^18.2.0",
66
66
  "react-dom": "^16.10.2 || ^17.0.2 || ^18.2.0",
67
- "react-error-boundary": "^3.1.4"
67
+ "react-error-boundary": "^4.0.12",
68
+ "react-lazy-load-image-component": "^1.6.0"
68
69
  },
69
70
  "devDependencies": {
70
- "@testing-library/react": "^12.1.4",
71
- "@testing-library/react-hooks": "^7.0.2",
72
- "@types/react": "^18.0.14",
73
- "@types/react-dom": "^18.0.5",
74
- "@typescript-eslint/eslint-plugin": "^5.22.0",
75
- "@typescript-eslint/parser": "^5.22.0",
76
- "@vitejs/plugin-react": "4.2.1",
77
- "chalk": "^5.0.1",
78
- "eslint": "^8.11.0",
71
+ "@testing-library/react": "^14.2.1",
72
+ "@testing-library/react-hooks": "^8.0.1",
73
+ "@types/react": "^18.2.55",
74
+ "@types/react-dom": "^18.2.19",
75
+ "@types/react-lazy-load-image-component": "^1.6.3",
76
+ "@typescript-eslint/eslint-plugin": "^7.0.1",
77
+ "@typescript-eslint/parser": "7.0.1",
78
+ "@vitejs/plugin-react": "^4.2.1",
79
+ "chalk": "^5.3.0",
80
+ "eslint": "^8.56.0",
79
81
  "eslint-plugin-json": "^3.1.0",
80
- "eslint-plugin-prettier": "^4.0.0",
81
- "happy-dom": "^13.1.4",
82
- "prettier": "^2.6.2",
83
- "query-string": "^7.1.1",
82
+ "eslint-plugin-prettier": "^5.1.3",
83
+ "happy-dom": "^13.3.8",
84
+ "prettier": "^3.2.5",
85
+ "query-string": "^8.2.0",
84
86
  "react-16": "npm:react@16",
85
87
  "react-17": "npm:react@17",
86
88
  "react-18": "npm:react@18",
87
89
  "react-dom-16": "npm:react-dom@16",
88
90
  "react-dom-17": "npm:react-dom@17",
89
91
  "react-dom-18": "npm:react-dom@18",
90
- "tslib": "^2.4.0",
91
- "typescript": "^4.7.4",
92
- "vite": "^5.0.11",
93
- "vitest": "1.2.0",
92
+ "tslib": "^2.6.2",
93
+ "typescript": "^5.3.3",
94
+ "vite": "^5.1.2",
95
+ "vitest": "^1.2.2",
94
96
  "zustand": "^4.5.0"
95
97
  },
96
98
  "publishConfig": {