react-iiif-vault 1.0.3 → 1.0.5

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.
@@ -0,0 +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,t){const{selector:i,source:o}=T.expandTarget(t);if(o.id!==e.id)return[null,o];const r={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[i?i.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:i.temporal,spatial:r.spatial}:i:null,o]}const R={makeChoice:()=>{}},f={type:"unknown"},n=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),y=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]}),O=["model/gltf-binary"];function N(e,t){const o=t.items[0].resource;return o.format?O.indexOf(o.format)===-1?n(`3D format: ${o.format} is unsupported`):{type:"3d-model",model:o}:n("Unknown format")}function k(e,t){var o;if(!e.duration)return n("No duration on canvas");if(t.items.length>1)return n("Only one audio source supported");const i=(o=t.items[0])==null?void 0:o.resource;return i?i.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:i.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:i.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:n("Audio does not have format"):n("Unknown audio")}function B(e,t,i){const o=[];for(const r of t.items){const u=r.resource&&r.resource.type==="SpecificResource"?r.resource.source:r.resource;if(!u.id)return n("No resource Identifier");let s;if(u.service){const l=w.getImageServices(u);l[0]&&(s=i(l[0],e))}const c={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[a,S]=m(e,r.target);if(S.id!==e.id)continue;r.resource.width&&r.resource.height&&(r.resource.width,r.resource.height);let d=r.resource.type==="SpecificResource"?g.expandTarget(r.resource):null;if(r.selector){const l=g.expandTarget({type:"SpecificResource",source:r.resource,selector:r.selector});l&&(d=l)}const p=d&&d.selector&&(d.selector.type==="BoxSelector"||d.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:d.selector.spatial.x,y:d.selector.spatial.y,width:d.selector.spatial.width,height:d.selector.spatial.height}}:void 0;s&&!s.id&&(s.id=s["@id"]);const x={id:u.id,type:"Image",annotationId:r.annotationId,width:Number(a||p?u.width:e.width),height:Number(a||p?u.height:e.height),service:s,sizes:s&&s.sizes?s.sizes:u.width&&u.height?[{width:u.width,height:u.height}]:[],target:a&&a.type!=="PointSelector"?a:c,selector:p};o.push(x)}return{type:"images",image:o[0],images:o,choice:t.choice}}function h(e,t={},i){const o=e.language||i||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[o]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(r=>h(r,t,o))}return t}function v(e,t){const i=[];return t.items.forEach(o=>{if(o.resource){const[r]=m(e,o.target);i.push({annotationId:o.annotationId,text:h(o.resource),target:r})}}),{type:"textual-content",items:i}}const C=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function b(e,t){var s;const i=t.items.filter(c=>c.type==="video");if(!e.duration)return n("No duration on canvas");if(i.length>1)return n("Only one video source supported");const o=(s=i[0])==null?void 0:s.resource,r=!!(o.service||[]).find(c=>(c.profile||"").includes("youtube.com"));if(!o)return n("Unknown video");if((!o.format||o.format==="text/html")&&!r)return n("Video does not have format");const u={annotationId:t.items[0].annotationId,duration:e.duration,url:o.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(r){u.type="VideoYouTube";const c=o.id.match(C);if(!c[1])return n("Video is not known youtube video");u.youTubeId=c[1]}return{type:"media",media:u,annotations:{pages:[]}}}function A({canvas:e,paintables:t,supports:i,loadImageService:o}){if(!e)return console.log("No canvas"),f;if(t.types.length===0)return i.indexOf("empty")!==-1?y(e.width,e.height):(console.log("No paintables"),f);if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(u=>u!=="text");else return i.indexOf("complex-timeline")===-1?n("Complex timeline not supported"):n("ComplexTimelineStrategy not yet supported");const r=t.types[0];return r==="image"?i.indexOf("images")===-1?n("Image not supported"):B(e,t,o):r==="Model"||r==="model"?i.indexOf("3d-model")===-1?n("3D not supported"):N(e,t):r==="textualbody"?i.indexOf("textual-content")===-1?n("Textual content not supported"):v(e,t):r==="sound"||r==="audio"?i.indexOf("media")===-1?n("Media not supported"):k(e,t):r==="video"?i.indexOf("media")===-1?n("Media not supported"):b(e,t):f}exports.emptyActions=R;exports.emptyStrategy=y;exports.getParsedTargetSelector=m;exports.getRenderingStrategy=A;exports.parseSpecificResource=I;exports.unknownResponse=f;exports.unsupportedStrategy=n;
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +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 if (!canvas.duration) {\n return unsupportedStrategy('No duration on canvas');\n }\n\n if (videoPaintables.length > 1) {\n return unsupportedStrategy('Only one video source supported');\n }\n\n const audioResource = videoPaintables[0]?.resource as any; // @todo stronger type for what this might be.\n const isYouTube = !!(audioResource.service || []).find((service: any) =>\n (service.profile || '').includes('youtube.com')\n );\n\n if (!audioResource) {\n return unsupportedStrategy('Unknown video');\n }\n\n if (!audioResource.format || audioResource.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: audioResource.id,\n type: 'Video',\n items: [],\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\n if (isYouTube) {\n media.type = 'VideoYouTube';\n const id = audioResource.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","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,CAA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AS,QAAQ,OAAO,IAAM,GACzBrC,EAAcV,EAAO,MAAOA,EAAO,MAAM,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,QAAIM,EAAS,QAAQ,kBAAkB,IAAM,GACpCvC,EAAoB,gCAAgC,EAEtDA,EAAoB,2CAA2C,EAIpE,MAAAwC,EAAWjC,EAAW,MAAM,CAAC,EAGnC,OAAIiC,IAAa,QACXD,EAAS,QAAQ,QAAQ,IAAM,GAC1BvC,EAAoB,qBAAqB,EAG3CW,EAAiBnB,EAAQe,EAAYK,CAAgB,EAI1D4B,IAAa,SAAWA,IAAa,QACnCD,EAAS,QAAQ,UAAU,IAAM,GAC5BvC,EAAoB,kBAAkB,EAGxCM,EAAcd,EAAQe,CAAU,EAGrCiC,IAAa,cACXD,EAAS,QAAQ,iBAAiB,IAAM,GACnCvC,EAAoB,+BAA+B,EAGrD4B,EAA0BpC,EAAQe,CAAU,EAGjDiC,IAAa,SAAWA,IAAa,QACnCD,EAAS,QAAQ,OAAO,IAAM,GACzBvC,EAAoB,qBAAqB,EAI3CQ,EAAiBhB,EAAQe,CAAU,EAGxCiC,IAAa,QACXD,EAAS,QAAQ,OAAO,IAAM,GACzBvC,EAAoB,qBAAqB,EAI3C+B,EAAiBvC,EAAQe,CAAU,EAIrCR,CACT"}
@@ -0,0 +1,237 @@
1
+ import { expandTarget as S } from "@iiif/helpers";
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) {
5
+ return e.type === "SpecificResource" ? [e.source, { selector: e.selector }] : [e, { selector: null }];
6
+ }
7
+ function g(e, t) {
8
+ const { selector: i, source: o } = S(t);
9
+ if (o.id !== e.id)
10
+ return [null, o];
11
+ const r = {
12
+ type: "BoxSelector",
13
+ spatial: {
14
+ x: 0,
15
+ y: 0,
16
+ width: Number(e.width),
17
+ height: Number(e.height)
18
+ }
19
+ };
20
+ return [
21
+ i ? i.type === "TemporalSelector" ? {
22
+ type: "TemporalBoxSelector",
23
+ temporal: i.temporal,
24
+ spatial: r.spatial
25
+ } : i : null,
26
+ o
27
+ ];
28
+ }
29
+ const A = {
30
+ makeChoice: () => {
31
+ }
32
+ }, l = { type: "unknown" }, n = (e) => ({ type: "unknown", reason: e, annotations: { pages: [] } }), w = (e, t) => ({ type: "empty", width: e, height: t, annotations: { pages: [] }, image: null, images: [] }), I = ["model/gltf-binary"];
33
+ function N(e, t) {
34
+ const o = t.items[0].resource;
35
+ return o.format ? I.indexOf(o.format) === -1 ? n(`3D format: ${o.format} is unsupported`) : {
36
+ type: "3d-model",
37
+ model: o
38
+ } : n("Unknown format");
39
+ }
40
+ function O(e, t) {
41
+ var o;
42
+ if (!e.duration)
43
+ return n("No duration on canvas");
44
+ if (t.items.length > 1)
45
+ return n("Only one audio source supported");
46
+ const i = (o = t.items[0]) == null ? void 0 : o.resource;
47
+ return i ? i.format ? {
48
+ type: "media",
49
+ media: {
50
+ annotationId: t.items[0].annotationId,
51
+ duration: e.duration,
52
+ url: i.id,
53
+ type: "Sound",
54
+ target: {
55
+ type: "TemporalSelector",
56
+ temporal: {
57
+ startTime: 0,
58
+ endTime: e.duration
59
+ }
60
+ },
61
+ format: i.format,
62
+ selector: {
63
+ type: "TemporalSelector",
64
+ temporal: {
65
+ startTime: 0,
66
+ endTime: e.duration
67
+ }
68
+ }
69
+ },
70
+ annotations: {
71
+ pages: []
72
+ }
73
+ } : n("Audio does not have format") : n("Unknown audio");
74
+ }
75
+ function R(e, t, i) {
76
+ const o = [];
77
+ for (const r of t.items) {
78
+ const u = r.resource && r.resource.type === "SpecificResource" ? r.resource.source : r.resource;
79
+ if (!u.id)
80
+ return n("No resource Identifier");
81
+ let s;
82
+ if (u.service) {
83
+ const f = T(u);
84
+ f[0] && (s = i(f[0], e));
85
+ }
86
+ const c = {
87
+ type: "BoxSelector",
88
+ spatial: {
89
+ x: 0,
90
+ y: 0,
91
+ width: Number(e.width),
92
+ height: Number(e.height)
93
+ }
94
+ }, [a, h] = g(e, r.target);
95
+ if (h.id !== e.id)
96
+ continue;
97
+ r.resource.width && r.resource.height && (r.resource.width, r.resource.height);
98
+ let d = r.resource.type === "SpecificResource" ? p(r.resource) : null;
99
+ if (r.selector) {
100
+ const f = p({
101
+ type: "SpecificResource",
102
+ source: r.resource,
103
+ selector: r.selector
104
+ });
105
+ f && (d = f);
106
+ }
107
+ const m = d && d.selector && (d.selector.type === "BoxSelector" || d.selector.type === "TemporalBoxSelector") ? {
108
+ type: "BoxSelector",
109
+ spatial: {
110
+ x: d.selector.spatial.x,
111
+ y: d.selector.spatial.y,
112
+ width: d.selector.spatial.width,
113
+ height: d.selector.spatial.height
114
+ }
115
+ } : void 0;
116
+ s && !s.id && (s.id = s["@id"]);
117
+ const x = {
118
+ id: u.id,
119
+ type: "Image",
120
+ annotationId: r.annotationId,
121
+ width: Number(a || m ? u.width : e.width),
122
+ height: Number(a || m ? u.height : e.height),
123
+ service: s,
124
+ sizes: s && s.sizes ? s.sizes : u.width && u.height ? [{ width: u.width, height: u.height }] : [],
125
+ target: a && a.type !== "PointSelector" ? a : c,
126
+ selector: m
127
+ };
128
+ o.push(x);
129
+ }
130
+ return {
131
+ type: "images",
132
+ image: o[0],
133
+ images: o,
134
+ choice: t.choice
135
+ };
136
+ }
137
+ function y(e, t = {}, i) {
138
+ const o = e.language || i || "none";
139
+ switch (e.type) {
140
+ case "TextualBody": {
141
+ typeof e.value < "u" && (t[o] = e.value);
142
+ break;
143
+ }
144
+ case "List":
145
+ case "Composite":
146
+ case "Choice":
147
+ e.items && e.items.forEach((r) => y(r, t, o));
148
+ }
149
+ return t;
150
+ }
151
+ function k(e, t) {
152
+ const i = [];
153
+ return t.items.forEach((o) => {
154
+ if (o.resource) {
155
+ const [r] = g(e, o.target);
156
+ i.push({ annotationId: o.annotationId, text: y(o.resource), target: r });
157
+ }
158
+ }), {
159
+ type: "textual-content",
160
+ items: i
161
+ };
162
+ }
163
+ const B = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;
164
+ function v(e, t) {
165
+ var s;
166
+ const i = t.items.filter((c) => c.type === "video");
167
+ if (!e.duration)
168
+ return n("No duration on canvas");
169
+ if (i.length > 1)
170
+ return n("Only one video source supported");
171
+ const o = (s = i[0]) == null ? void 0 : s.resource, r = !!(o.service || []).find(
172
+ (c) => (c.profile || "").includes("youtube.com")
173
+ );
174
+ if (!o)
175
+ return n("Unknown video");
176
+ if ((!o.format || o.format === "text/html") && !r)
177
+ return n("Video does not have format");
178
+ const u = {
179
+ annotationId: t.items[0].annotationId,
180
+ duration: e.duration,
181
+ url: o.id,
182
+ type: "Video",
183
+ items: [],
184
+ target: {
185
+ type: "TemporalSelector",
186
+ temporal: {
187
+ startTime: 0,
188
+ endTime: e.duration
189
+ }
190
+ },
191
+ format: o.format,
192
+ selector: {
193
+ type: "TemporalSelector",
194
+ temporal: {
195
+ startTime: 0,
196
+ endTime: e.duration
197
+ }
198
+ }
199
+ };
200
+ if (r) {
201
+ u.type = "VideoYouTube";
202
+ const c = o.id.match(B);
203
+ if (!c[1])
204
+ return n("Video is not known youtube video");
205
+ u.youTubeId = c[1];
206
+ }
207
+ return {
208
+ type: "media",
209
+ media: u,
210
+ annotations: {
211
+ pages: []
212
+ }
213
+ };
214
+ }
215
+ function P({ canvas: e, paintables: t, supports: i, loadImageService: o }) {
216
+ if (!e)
217
+ return console.log("No canvas"), l;
218
+ if (t.types.length === 0)
219
+ return i.indexOf("empty") !== -1 ? w(e.width, e.height) : (console.log("No paintables"), l);
220
+ if (t.types.length !== 1)
221
+ if (t.types.length === 2 && t.types.indexOf("text") !== -1)
222
+ t.types = t.types.filter((u) => u !== "text");
223
+ else
224
+ return i.indexOf("complex-timeline") === -1 ? n("Complex timeline not supported") : n("ComplexTimelineStrategy not yet supported");
225
+ const r = t.types[0];
226
+ return r === "image" ? i.indexOf("images") === -1 ? n("Image not supported") : R(e, t, o) : r === "Model" || r === "model" ? i.indexOf("3d-model") === -1 ? n("3D not supported") : N(e, t) : r === "textualbody" ? i.indexOf("textual-content") === -1 ? n("Textual content not supported") : k(e, t) : r === "sound" || r === "audio" ? i.indexOf("media") === -1 ? n("Media not supported") : O(e, t) : r === "video" ? i.indexOf("media") === -1 ? n("Media not supported") : v(e, t) : l;
227
+ }
228
+ export {
229
+ A as emptyActions,
230
+ w as emptyStrategy,
231
+ g as getParsedTargetSelector,
232
+ P as getRenderingStrategy,
233
+ z as parseSpecificResource,
234
+ l as unknownResponse,
235
+ n as unsupportedStrategy
236
+ };
237
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +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 if (!canvas.duration) {\n return unsupportedStrategy('No duration on canvas');\n }\n\n if (videoPaintables.length > 1) {\n return unsupportedStrategy('Only one video source supported');\n }\n\n const audioResource = videoPaintables[0]?.resource as any; // @todo stronger type for what this might be.\n const isYouTube = !!(audioResource.service || []).find((service: any) =>\n (service.profile || '').includes('youtube.com')\n );\n\n if (!audioResource) {\n return unsupportedStrategy('Unknown video');\n }\n\n if (!audioResource.format || audioResource.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: audioResource.id,\n type: 'Video',\n items: [],\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\n if (isYouTube) {\n media.type = 'VideoYouTube';\n const id = audioResource.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","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,MAA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AAS,QAAQ,UAAU,MAAM,KAC5BvC,EAAoB,kBAAkB,IAGxCM,EAAcd,GAAQe,CAAU,IAGrCiC,MAAa,gBACXD,EAAS,QAAQ,iBAAiB,MAAM,KACnCvC,EAAoB,+BAA+B,IAGrD4B,EAA0BpC,GAAQe,CAAU,IAGjDiC,MAAa,WAAWA,MAAa,UACnCD,EAAS,QAAQ,OAAO,MAAM,KACzBvC,EAAoB,qBAAqB,IAI3CQ,EAAiBhB,GAAQe,CAAU,IAGxCiC,MAAa,UACXD,EAAS,QAAQ,OAAO,MAAM,KACzBvC,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.3",
3
+ "version": "1.0.5",
4
4
  "main": "dist/bundle/cjs/index.js",
5
5
  "module": "dist/bundle/esm/index.mjs",
6
6
  "types": ".build/types/index.d.ts",
@@ -16,17 +16,22 @@
16
16
  "require": "./dist/bundle/cjs/index.js",
17
17
  "import": "./dist/bundle/esm/index.mjs",
18
18
  "default": "./dist/index.umd.js",
19
- "types": "./dist/types/index.d.ts"
19
+ "types": "./.build/types/index.d.ts"
20
20
  },
21
21
  "./canvas-panel": {
22
22
  "require": "./dist/canvas-panel/cjs/canvas-panel.js",
23
23
  "import": "./dist/canvas-panel/esm/canvas-panel.mjs",
24
- "types": "./dist/types/canvas-panel/index.d.ts"
24
+ "types": "./.build/types/canvas-panel/index.d.ts"
25
+ },
26
+ "./utils": {
27
+ "require": "./dist/utils/cjs/utils.js",
28
+ "import": "./dist/utils/esm/utils.mjs",
29
+ "types": "./.build/types/utils.d.ts"
25
30
  },
26
31
  "./react17": {
27
32
  "require": "./dist/react17/cjs/index.js",
28
33
  "import": "./dist/react17/esm/index.mjs",
29
- "types": "./dist/types/index.d.ts"
34
+ "types": "./.build/types/index.d.ts"
30
35
  }
31
36
  },
32
37
  "typesVersions": {
@@ -34,6 +39,9 @@
34
39
  "*": [
35
40
  ".build/types/index.d.ts"
36
41
  ],
42
+ "utils": [
43
+ ".build/types/utils.d.ts"
44
+ ],
37
45
  "canvas-panel": [
38
46
  ".build/types/canvas-panel/index.d.ts"
39
47
  ]
@@ -47,17 +55,16 @@
47
55
  },
48
56
  "license": "MIT",
49
57
  "dependencies": {
50
- "@atlas-viewer/atlas": "^2.0.1",
51
- "@atlas-viewer/iiif-image-api": "^2.1.1",
52
- "@iiif/parser": "^2.0.1",
53
- "@iiif/presentation-2": "1.*",
54
- "@iiif/presentation-3": "^2.1.3",
55
- "@iiif/presentation-3-normalized": "^0.9.7",
56
- "@iiif/helpers": "^1.0.4",
58
+ "@atlas-viewer/atlas": ">=2.0.1",
59
+ "@atlas-viewer/iiif-image-api": ">=2.1.1",
60
+ "@iiif/parser": ">=2.0.1",
61
+ "@iiif/presentation-2": ">=1.*",
62
+ "@iiif/presentation-3": ">=2.1.3",
63
+ "@iiif/presentation-3-normalized": ">=0.9.7",
64
+ "@iiif/helpers": ">=1.0.4",
57
65
  "react": "^16.10.2 || ^17.0.2 || ^18.2.0",
58
66
  "react-dom": "^16.10.2 || ^17.0.2 || ^18.2.0",
59
- "react-error-boundary": "^3.1.4",
60
- "zustand": "4.4.7"
67
+ "react-error-boundary": "^3.1.4"
61
68
  },
62
69
  "devDependencies": {
63
70
  "@testing-library/react": "^12.1.4",
@@ -80,11 +87,11 @@
80
87
  "react-dom-16": "npm:react-dom@16",
81
88
  "react-dom-17": "npm:react-dom@17",
82
89
  "react-dom-18": "npm:react-dom@18",
83
- "react-use": "^17.3.2",
84
90
  "tslib": "^2.4.0",
85
91
  "typescript": "^4.7.4",
86
92
  "vite": "^5.0.11",
87
- "vitest": "1.2.0"
93
+ "vitest": "1.2.0",
94
+ "zustand": "^4.5.0"
88
95
  },
89
96
  "publishConfig": {
90
97
  "access": "public"