react-iiif-vault 1.4.0 → 1.5.0
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/bundle.d.ts +129 -13
- package/dist/bundle.global.js +30 -28
- package/dist/canvas-panel.cjs +7 -7
- package/dist/canvas-panel.d.cts +2 -3
- package/dist/canvas-panel.d.ts +2 -3
- package/dist/canvas-panel.js +1 -1
- package/dist/chunk-LXMMN7PH.js +48 -0
- package/dist/chunk-PCXRCBVF.js +1 -0
- package/dist/{index-BAYQ0qVx.d.cts → index-Cs7EchlV.d.cts} +5 -5
- package/dist/{index-CnXzAuQK.d.ts → index-DZK6q9iO.d.ts} +5 -5
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +124 -15
- package/dist/index.d.ts +124 -15
- package/dist/index.js +1 -1
- package/dist/{useRenderingStrategy-DkjxMKJV.d.cts → useRenderingStrategy-B03X9rQS.d.cts} +7 -1
- package/dist/{useRenderingStrategy-DkjxMKJV.d.ts → useRenderingStrategy-B03X9rQS.d.ts} +7 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +4 -5
- package/dist/chunk-7KUFVAUD.js +0 -48
- package/dist/chunk-CCTBCLBV.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -3,9 +3,8 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
import { AtlasProps, Preset, BoxStyle, ViewerMode } from '@atlas-viewer/atlas';
|
|
4
4
|
import { AnnotationPage, Reference } from '@iiif/presentation-3';
|
|
5
5
|
import { AnnotationPageNormalized, CanvasNormalized } from '@iiif/presentation-3-normalized';
|
|
6
|
-
import { S as SingleAudio, a as SingleVideo, M as MediaStrategy, b as StrategyActions, c as SingleImageStrategy, E as EmptyStrategy, C as ComplexTimelineStrategy, R as RenderingStrategy, I as ImageWithOptionalService } from './useRenderingStrategy-
|
|
7
|
-
import { ChoiceDescription, BoxSelector } from '@iiif/helpers';
|
|
8
|
-
import { ImageCandidate } from '@atlas-viewer/iiif-image-api';
|
|
6
|
+
import { S as SingleAudio, a as SingleVideo, M as MediaStrategy, b as StrategyActions, c as SingleImageStrategy, E as EmptyStrategy, C as ComplexTimelineStrategy, R as RenderingStrategy, I as ImageWithOptionalService } from './useRenderingStrategy-B03X9rQS.cjs';
|
|
7
|
+
import { ChoiceDescription, ImageCandidate, BoxSelector } from '@iiif/helpers';
|
|
9
8
|
import { Vault } from '@iiif/helpers/vault';
|
|
10
9
|
|
|
11
10
|
declare function Viewer({ children, errorFallback, outerContainerProps, worldScale: _worldScale, ...props }: AtlasProps & {
|
|
@@ -83,6 +82,7 @@ type CanvasProps = {
|
|
|
83
82
|
viewControlsDeps?: any[];
|
|
84
83
|
renderMediaControls?: (strategy: MediaStrategy) => ReactNode;
|
|
85
84
|
renderComplexTimelineControls?: (strategy: ComplexTimelineStrategy) => ReactNode;
|
|
85
|
+
complexTimelineControlsDeps?: any[];
|
|
86
86
|
mediaControlsDeps?: any[];
|
|
87
87
|
strategies?: Array<RenderingStrategy['type']>;
|
|
88
88
|
backgroundStyle?: BoxStyle;
|
|
@@ -97,7 +97,7 @@ type CanvasProps = {
|
|
|
97
97
|
Audio?: React__default.ComponentType<AudioComponentProps>;
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
-
declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, renderComplexTimelineControls, viewControlsDeps, mediaControlsDeps, strategies, throwOnUnknown, backgroundStyle, alwaysShowBackground, keepCanvasScale, enableSizes, enableYouTube, onClickPaintingAnnotation, components, children, }: CanvasProps): react_jsx_runtime.JSX.Element
|
|
100
|
+
declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, renderComplexTimelineControls, complexTimelineControlsDeps, viewControlsDeps, mediaControlsDeps, strategies, throwOnUnknown, backgroundStyle, alwaysShowBackground, keepCanvasScale, enableSizes, enableYouTube, onClickPaintingAnnotation, components, children, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
101
101
|
|
|
102
102
|
declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, selector, onClick, enableSizes, }: {
|
|
103
103
|
id: string;
|
|
@@ -211,4 +211,4 @@ type CanvasPanelType = ForwardRefExoticComponent<CanvasPanelProps & RefAttribute
|
|
|
211
211
|
};
|
|
212
212
|
declare const CanvasPanel: CanvasPanelType;
|
|
213
213
|
|
|
214
|
-
export { CanvasPanel as C, type SimpleViewerContext as S, type SimpleViewerProps as a, type SimpleViewerReducerState as b, type SimpleViewerActions as c, type SimpleViewerActionsType as d };
|
|
214
|
+
export { type AudioComponentProps as A, CanvasPanel as C, type SimpleViewerContext as S, type VideoComponentProps as V, type SimpleViewerProps as a, type SimpleViewerReducerState as b, type SimpleViewerActions as c, type SimpleViewerActionsType as d };
|
|
@@ -3,9 +3,8 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
import { AtlasProps, Preset, BoxStyle, ViewerMode } from '@atlas-viewer/atlas';
|
|
4
4
|
import { AnnotationPage, Reference } from '@iiif/presentation-3';
|
|
5
5
|
import { AnnotationPageNormalized, CanvasNormalized } from '@iiif/presentation-3-normalized';
|
|
6
|
-
import { S as SingleAudio, a as SingleVideo, M as MediaStrategy, b as StrategyActions, c as SingleImageStrategy, E as EmptyStrategy, C as ComplexTimelineStrategy, R as RenderingStrategy, I as ImageWithOptionalService } from './useRenderingStrategy-
|
|
7
|
-
import { ChoiceDescription, BoxSelector } from '@iiif/helpers';
|
|
8
|
-
import { ImageCandidate } from '@atlas-viewer/iiif-image-api';
|
|
6
|
+
import { S as SingleAudio, a as SingleVideo, M as MediaStrategy, b as StrategyActions, c as SingleImageStrategy, E as EmptyStrategy, C as ComplexTimelineStrategy, R as RenderingStrategy, I as ImageWithOptionalService } from './useRenderingStrategy-B03X9rQS.js';
|
|
7
|
+
import { ChoiceDescription, ImageCandidate, BoxSelector } from '@iiif/helpers';
|
|
9
8
|
import { Vault } from '@iiif/helpers/vault';
|
|
10
9
|
|
|
11
10
|
declare function Viewer({ children, errorFallback, outerContainerProps, worldScale: _worldScale, ...props }: AtlasProps & {
|
|
@@ -83,6 +82,7 @@ type CanvasProps = {
|
|
|
83
82
|
viewControlsDeps?: any[];
|
|
84
83
|
renderMediaControls?: (strategy: MediaStrategy) => ReactNode;
|
|
85
84
|
renderComplexTimelineControls?: (strategy: ComplexTimelineStrategy) => ReactNode;
|
|
85
|
+
complexTimelineControlsDeps?: any[];
|
|
86
86
|
mediaControlsDeps?: any[];
|
|
87
87
|
strategies?: Array<RenderingStrategy['type']>;
|
|
88
88
|
backgroundStyle?: BoxStyle;
|
|
@@ -97,7 +97,7 @@ type CanvasProps = {
|
|
|
97
97
|
Audio?: React__default.ComponentType<AudioComponentProps>;
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
-
declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, renderComplexTimelineControls, viewControlsDeps, mediaControlsDeps, strategies, throwOnUnknown, backgroundStyle, alwaysShowBackground, keepCanvasScale, enableSizes, enableYouTube, onClickPaintingAnnotation, components, children, }: CanvasProps): react_jsx_runtime.JSX.Element
|
|
100
|
+
declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, renderComplexTimelineControls, complexTimelineControlsDeps, viewControlsDeps, mediaControlsDeps, strategies, throwOnUnknown, backgroundStyle, alwaysShowBackground, keepCanvasScale, enableSizes, enableYouTube, onClickPaintingAnnotation, components, children, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
101
101
|
|
|
102
102
|
declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, selector, onClick, enableSizes, }: {
|
|
103
103
|
id: string;
|
|
@@ -211,4 +211,4 @@ type CanvasPanelType = ForwardRefExoticComponent<CanvasPanelProps & RefAttribute
|
|
|
211
211
|
};
|
|
212
212
|
declare const CanvasPanel: CanvasPanelType;
|
|
213
213
|
|
|
214
|
-
export { CanvasPanel as C, type SimpleViewerContext as S, type SimpleViewerProps as a, type SimpleViewerReducerState as b, type SimpleViewerActions as c, type SimpleViewerActionsType as d };
|
|
214
|
+
export { type AudioComponentProps as A, CanvasPanel as C, type SimpleViewerContext as S, type VideoComponentProps as V, type SimpleViewerProps as a, type SimpleViewerReducerState as b, type SimpleViewerActions as c, type SimpleViewerActionsType as d };
|