react-iiif-vault 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.d.ts CHANGED
@@ -1,34 +1,9 @@
1
- import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-B03X9rQS.js';
2
- import { CanvasNormalized } from '@iiif/presentation-3-normalized';
3
- import { Paintables } from '@iiif/helpers/painting-annotations';
4
- import { TemporalBoxSelector, BoxSelector, SupportedTarget, Vault } from '@iiif/helpers';
5
- import { ContentResource, W3CAnnotationTarget, PointSelector } from '@iiif/presentation-3';
1
+ export { e as emptyActions, b as emptyStrategy, g as getParsedTargetSelector, c as getRenderingStrategy, p as parseSpecificResource, u as unknownResponse, a as unsupportedStrategy } from './utils-C-h4SU3S.js';
2
+ import './useRenderingStrategy-BiuSDiXu.js';
3
+ import '@iiif/helpers';
4
+ import '@iiif/presentation-3';
5
+ import '@iiif/presentation-3-normalized';
6
6
  import '@iiif/helpers/annotation-targets';
7
7
  import 'mitt';
8
-
9
- /**
10
- * Parse specific resource.
11
- *
12
- * This could be expanded to support pulling out more from the specific resource.
13
- *
14
- * @param resource
15
- */
16
- declare function parseSpecificResource(resource: ContentResource): any[];
17
- declare function getParsedTargetSelector(canvas: CanvasNormalized, target: W3CAnnotationTarget | W3CAnnotationTarget[]): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']];
18
- declare const emptyActions: {
19
- makeChoice: () => void;
20
- };
21
- declare const unknownResponse: UseRenderingStrategy[0];
22
- declare const unsupportedStrategy: (reason: string) => UnknownStrategy;
23
- declare const emptyStrategy: (width: number, height: number) => UseRenderingStrategy[0];
24
-
25
- interface GetRenderStrategyOptions {
26
- canvas: CanvasNormalized | null | undefined;
27
- paintables: Paintables;
28
- supports: string[];
29
- loadImageService: ImageServiceLoaderType;
30
- vault: Vault;
31
- }
32
- declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService, vault, }: GetRenderStrategyOptions): RenderingStrategy;
33
-
34
- export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy };
8
+ import '@iiif/helpers/painting-annotations';
9
+ import '@iiif/helpers/vault';
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-PCXRCBVF.js";export{e as emptyActions,p as emptyStrategy,r as getParsedTargetSelector,t as getRenderingStrategy,o as parseSpecificResource,f as unknownResponse,m as unsupportedStrategy};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-XNDN34SQ.js";export{e as emptyActions,p as emptyStrategy,r as getParsedTargetSelector,t as getRenderingStrategy,o as parseSpecificResource,f as unknownResponse,m as unsupportedStrategy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iiif-vault",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@atlas-viewer/atlas": "^2.2.9",
62
- "@iiif/helpers": "^1.3.0",
62
+ "@iiif/helpers": "^1.3.1",
63
63
  "@iiif/parser": "^2.1.7",
64
64
  "@iiif/presentation-2": "^1.0.4",
65
65
  "@iiif/presentation-3": "^2.2.3",
@@ -1 +0,0 @@
1
- import{expandTarget as D}from"@iiif/helpers";function _(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function x(e,o){let{selector:n,source:s}=D(o);if(s.id!==e.id)return[null,s];let t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:t.spatial}:n:null,s]}var K={makeChoice:()=>{}},T={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),w=(e,o)=>({type:"empty",width:e,height:o,annotations:{pages:[]},image:null,images:[]});var A=["model/gltf-binary"];function v(e,o){let s=o.items[0].resource;return s.format?A.indexOf(s.format)===-1?m(`3D format: ${s.format} is unsupported`):{type:"3d-model",model:s}:m("Unknown format")}import{getImageServices as O}from"@iiif/parser/image-3";import{expandTarget as P}from"@iiif/helpers/annotation-targets";function C(e,o,n){let s=[];for(let t of o.items){let a=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!a.id)return m("No resource Identifier");let c;if(a.service){let g=O(a);g[0]&&(c=n(g[0],e))}let y={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[u,i]=x(e,t.target),r=e.id?.split("?")[0]||"";if(!(i.id===e.id||decodeURIComponent(i.id||"")===(e.id||"")||i.id===r||decodeURIComponent(i.id||"")===r))continue;let l=t.resource.width&&t.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:t.resource.width,height:t.resource.height}}:void 0,p=t.resource.type==="SpecificResource"?P(t.resource):null;if(t.selector){let g=P({type:"SpecificResource",source:t.resource,selector:t.selector});g&&(p=g)}let d=p&&p.selector&&(p.selector.type==="BoxSelector"||p.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:p.selector.spatial.x,y:p.selector.spatial.y,width:p.selector.spatial.width,height:p.selector.spatial.height}}:void 0;c&&!c.id&&(c.id=c["@id"]);let f={id:a.id,type:"Image",annotationId:t.annotationId,width:Number(u||d?a.width:e.width),height:Number(u||d?a.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:a.width&&a.height?[{width:a.width,height:a.height}]:[],target:u&&u.type!=="PointSelector"?u:y,selector:d||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};s.push(f)}return{type:"images",image:s[0],images:s,choice:o.choice}}function k(e,o={},n){let s=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(o[s]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>k(t,o,s))}return o}function I(e,o){let n=[];return o.items.forEach(s=>{if(s.resource){let[t]=x(e,s.target);n.push({type:"Text",annotationId:s.annotationId,text:k(s.resource),target:t})}}),{type:"textual-content",items:n}}import{expandTarget as U,parseSelector as W}from"@iiif/helpers";var L=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function b(e,o,n){let s=o.items.filter(d=>d.type==="video"),t=!1;if(e.duration||(t=!0),s.length>1)return m("Only one video source supported");let a=s[0]?.resource,c=!!(a.service||[]).find(d=>(d.profile||"").includes("youtube.com"));if(!c&&t)return m("Video does not have duration");if(!a)return m("Unknown video");if((!a.format||a.format==="text/html")&&!c)return m("Video does not have format");let y=[],u=n.get(e.annotations);for(let d of u){let f=n.get(d.items);for(let g of f)if((g.motivation?Array.isArray(g.motivation||"")?g.motivation:[g.motivation]:[]).includes("supplementing")){let V=n.get(g.body);for(let z of V){let h=z;if(h.type==="Choice")for(let B of h.items){let S=n.get(B);S.format==="text/vtt"&&y.push({id:S.id,type:"Text",format:"text/vtt",label:S.label,language:S.language})}else h.format==="text/vtt"&&y.push({id:h.id,type:"Text",format:"text/vtt",label:h.label,language:h.language})}}}let i=o.items[0],r={annotationId:o.items[0].annotationId,duration:e.duration,url:a.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:a.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},l=U(i.target);l.selector&&l.selector.type==="TemporalBoxSelector"&&(r.target=l.selector);let{selector:p}=W(i.selector);if(p===null){let d=r.target.temporal.startTime,g=(r.target.temporal.endTime||e.duration)-d;r.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:g}}}else p.type==="TemporalSelector"&&(r.selector=p);if(c){r.type="VideoYouTube";let d=a.id.match(L);if(!d[1])return m("Video is not known youtube video");r.youTubeId=d[1]}return{type:"media",media:r,annotations:{pages:[]},captions:y}}function R(e,o,n,s){let t={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},a={type:"complex-choice",items:[]};function c(i){i.choice&&(i.choice.type==="complex-choice"?a.items.push(...i.choice.items):a.items.push(i.choice))}for(let i of o.items){if(i.type==="image"){let r=C(e,{choice:null,allChoices:null,types:["image"],items:[i]},n);if(r.type==="images"){c(r),t.items.push(r.image);let l={id:r.image.annotationId,type:"enter",resourceType:"image",time:r.image.target?.temporal?.startTime||0};t.keyframes.push(l);let p={id:r.image.annotationId,type:"exit",resourceType:"image",time:r.image.target?.temporal?.endTime||e.duration||0};t.keyframes.push(p)}}if(i.type==="textualbody"){let r=I(e,{choice:null,allChoices:null,types:["textualbody"],items:[i]});if(r.type==="textual-content"){c(r);let l=r.items[0];t.items.push(l);let p=l.target,d={id:l.annotationId,type:"enter",resourceType:"text",time:p.temporal?.startTime||0};t.keyframes.push(d);let f={id:l.annotationId,type:"exit",resourceType:"text",time:p.temporal?.endTime||e.duration||0};t.keyframes.push(f)}}if(i.type==="video"){let r=b(e,{choice:null,allChoices:null,types:["video"],items:[i]},s);if(r.type==="media"){c(r);let l=r.media;t.items.push(l);let p={id:l.annotationId,type:"enter",resourceType:"video",time:l.target?.temporal?.startTime||0};t.keyframes.push(p);let d={id:l.annotationId,type:"exit",resourceType:"video",time:l.target?.temporal?.endTime||e.duration||0};t.keyframes.push(d)}}}t.keyframes.sort((i,r)=>i.time-r.time);let y=[],u=[];for(let i of t.keyframes){if(i.resourceType==="image"||i.resourceType==="text"){u.push(i);continue}if(i.type==="enter"){y.length===0&&(i.isPrime=!0),y.push(i),u.push(i);continue}if(i.type==="exit"&&(u.push(i),y=y.filter(r=>r.id!==i.id),y.length!==0)){let r=y[0],l={id:r.id,type:"change",isPrime:!0,resourceType:r.resourceType,time:i.time};u.push(l)}}return t.keyframes=u,a.items.length&&(t.choice=a),t}function N(e,o){if(!e.duration)return m("No duration on canvas");if(o.items.length>1)return m("Only one audio source supported");let n=o.items[0]?.resource;return n?n.format?{type:"media",media:{annotationId:o.items[0].annotationId,duration:e.duration,url:n.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}function xe({canvas:e,paintables:o,supports:n,loadImageService:s,vault:t}){if(!e)return T;if(o.types.length===0)return n.indexOf("empty")!==-1?w(e.width,e.height):T;if(o.types.length!==1)if(o.types.length===2&&o.types.indexOf("text")!==-1)o.types=o.types.filter(c=>c!=="text");else return n.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):R(e,o,s,t);let a=o.types[0];return a==="image"?n.indexOf("images")===-1?m("Image not supported"):C(e,o,s):a==="Model"||a==="model"?n.indexOf("3d-model")===-1?m("3D not supported"):v(e,o):a==="textualbody"?n.indexOf("textual-content")===-1?m("Textual content not supported"):I(e,o):a==="sound"||a==="audio"?n.indexOf("media")===-1?m("Media not supported"):N(e,o):a==="video"?n.indexOf("media")===-1?m("Media not supported"):b(e,o,t):T}export{_ as a,x as b,K as c,T as d,m as e,w as f,v as g,C as h,I as i,b as j,R as k,xe as l};