@samvera/nectar-iiif
Advanced tools
Comparing version 0.0.19 to 0.0.20
@@ -1,1 +0,1 @@ | ||
"use strict";var pt=Object.create;var k=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var Rt=(t,e)=>{for(var r in e)k(t,r,{get:e[r],enumerable:!0})},J=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of yt(e))!St.call(t,a)&&a!==r&&k(t,a,{get:()=>e[a],enumerable:!(n=gt(e,a))||n.enumerable});return t};var q=(t,e,r)=>(r=t!=null?pt(bt(t)):{},J(e||!t||!t.__esModule?k(r,"default",{value:t,enumerable:!0}):r,t)),vt=t=>J(k({},"__esModule",{value:!0}),t);var Bt={};Rt(Bt,{Homepage:()=>Y,Label:()=>I,Metadata:()=>nt,PartOf:()=>it,RequiredStatement:()=>st,SeeAlso:()=>mt,Summary:()=>lt,Thumbnail:()=>dt,Value:()=>O});module.exports=vt(Bt);var Q=require("@stitches/react"),{styled:s,css:Ut,keyframes:Xt}=(0,Q.createStitches)({prefix:"nectar"});var _=(t,e="none")=>{if(!t)return null;if(typeof t=="string")return[t];if(!t[e]){let r=Object.getOwnPropertyNames(t);if(r.length>0)return t[r[0]]}return!t[e]||!Array.isArray(t[e])?null:t[e]},c=(t,e="none",r=", ")=>{let n=_(t,e);return Array.isArray(n)?n.join(`${r}`):n};var U=q(require("sanitize-html"));function X(t){return{__html:Nt(t)}}function m(t,e){let r=Object.keys(t).filter(a=>e.includes(a)?null:a),n=new Object;return r.forEach(a=>{n[a]=t[a]}),n}function Nt(t){return(0,U.default)(t,{allowedAttributes:{a:["href"],img:["alt","src"]},allowedSchemes:["http","https","mailto"],allowedTags:["a","b","br","i","img","p","small","span","sub","sup"]})}var h=require("react/jsx-runtime"),Ct=s("a",{}),At=t=>{let{children:e,homepage:r}=t,a=m(t,["children","homepage"]);return(0,h.jsx)(h.Fragment,{children:r&&r.map(o=>{let i=c(o.label,a.lang);return(0,h.jsx)(Ct,{"aria-label":e?i:void 0,href:o.id,...a,children:e||i},o.id)})})},Y=At;var Z=require("react/jsx-runtime"),ht=s("span",{}),Mt=t=>{let{as:e,label:r}=t,a=m(t,["as","label"]);return(0,Z.jsx)(ht,{as:e,...a,children:c(r,a.lang)})},I=Mt;var et=q(require("react"));var L=require("react"),j=require("react/jsx-runtime"),Pt={delimiter:", "},x=(0,L.createContext)(void 0),E=()=>{let t=(0,L.useContext)(x);if(t===void 0)throw new Error("useNectarContext must be used with a NectarProvider");return t},p=({children:t,initialState:e=Pt})=>{let r=y(e,"delimiter");return(0,j.jsx)(x.Provider,{value:{delimiter:r},children:t})},y=(t,e)=>Object.hasOwn(t,e)?t[e].toString():void 0;var g=require("react/jsx-runtime"),Vt=s("span",{}),tt=t=>{let{as:e,markup:r}=t,{delimiter:n}=E();if(!r)return(0,g.jsx)(g.Fragment,{});let o=m(t,["as","markup"]),i=X(c(r,o.lang,n));return(0,g.jsx)(Vt,{as:e,...o,dangerouslySetInnerHTML:i})},kt=t=>et.default.useContext(x)?(0,g.jsx)(tt,{...t}):(0,g.jsx)(p,{children:(0,g.jsx)(tt,{...t})}),F=kt;var rt=require("react/jsx-runtime"),It=({as:t="dd",lang:e,value:r})=>(0,rt.jsx)(F,{markup:r,as:t,lang:e}),O=It;var T=require("react");var G=require("react/jsx-runtime"),Lt=s("span",{}),xt=({as:t="dd",customValueContent:e,lang:r,value:n})=>{var i;let{delimiter:a}=E(),o=(i=_(n,r))==null?void 0:i.map(f=>(0,T.cloneElement)(e,{value:f}));return(0,G.jsx)(Lt,{as:t,lang:r,children:o==null?void 0:o.map((f,d)=>[d>0&&`${a}`,(0,G.jsx)(T.Fragment,{children:f},d)])})},ot=xt;var R=require("react/jsx-runtime"),Et=t=>{let{item:e,lang:r,customValueContent:n}=t,{label:a,value:o}=e;return(0,R.jsxs)("div",{role:"group",children:[(0,R.jsx)(I,{as:"dt",label:a,lang:r}),n?(0,R.jsx)(ot,{as:"dd",customValueContent:n,value:o,lang:r}):(0,R.jsx)(O,{as:"dd",value:o,lang:r})]})},w=Et;function at(t,e){let r=e.filter(n=>{let{matchingLabel:a}=n,o=Object.keys(n.matchingLabel)[0],i=c(a,o);if(c(t,o)===i)return!0}).map(n=>n.Content);if(!!Array.isArray(r))return r[0]}var b=require("react/jsx-runtime"),Ft=s("dl",{}),Ot=t=>{let{as:e,customValueContent:r,metadata:n}=t;if(!Array.isArray(n))return(0,b.jsx)(b.Fragment,{});let a=y(t,"customValueDelimiter"),i=m(t,["as","customValueContent","customValueDelimiter","metadata"]);return(0,b.jsx)(p,{...typeof a=="string"?{initialState:{delimiter:a}}:void 0,children:n.length>0&&(0,b.jsx)(Ft,{as:e,...i,children:n.map((f,d)=>{let u=r?at(f.label,r):void 0;return(0,b.jsx)(w,{customValueContent:u,item:f,lang:i==null?void 0:i.lang},d)})})})},nt=Ot;var H=require("react/jsx-runtime"),Tt=s("li",{}),wt=s("ul",{}),Ht=t=>{let{as:e,partOf:r}=t,a=m(t,["as","partOf"]);return(0,H.jsx)(wt,{as:e,children:r&&r.map(o=>{let i=o.label?c(o.label,a.lang):void 0;return(0,H.jsx)(Tt,{children:(0,H.jsx)("a",{href:o.id,...a,children:i||o.id})},o.id)})})},it=Ht;var S=require("react/jsx-runtime"),$t=s("dl",{}),zt=t=>{let{as:e,requiredStatement:r}=t;if(!r)return(0,S.jsx)(S.Fragment,{});let n=y(t,"customValueDelimiter"),o=m(t,["as","customValueDelimiter","requiredStatement"]);return(0,S.jsx)(p,{...typeof n=="string"?{initialState:{delimiter:n}}:void 0,children:(0,S.jsx)($t,{as:e,...o,children:(0,S.jsx)(w,{item:r,lang:o.lang})})})},st=zt;var $=require("react/jsx-runtime"),Wt=s("li",{}),Dt=s("ul",{}),qt=t=>{let{as:e,seeAlso:r}=t,a=m(t,["as","seeAlso"]);return(0,$.jsx)(Dt,{as:e,children:r&&r.map(o=>{let i=c(o.label,a.lang);return(0,$.jsx)(Wt,{children:(0,$.jsx)("a",{href:o.id,...a,children:i||o.id})},o.id)})})},mt=qt;var K=require("react/jsx-runtime"),_t=t=>{let{as:e,summary:r}=t,n=y(t,"customValueDelimiter"),o=m(t,["as","customValueDelimiter","summary"]);return(0,K.jsx)(p,{...typeof n=="string"?{initialState:{delimiter:n}}:void 0,children:(0,K.jsx)(F,{as:e,markup:r,...o})})},lt=_t;var M=require("react");var v=q(require("hls.js"));var ct=(t,e="200,",r="full")=>{Array.isArray(t)&&(t=t[0]);let{id:n,service:a}=t,o;if(!a)return n;if(Array.isArray(t.service)&&t.service.length>0&&(o=a[0]),o){if(o["@id"])return`${o["@id"]}/${r}/${e}/0/default.jpg`;if(o.id)return`${o.id}/${r}/${e}/0/default.jpg`}};var N=require("react/jsx-runtime"),ut=s("img",{objectFit:"cover"}),Gt=t=>{let e=(0,M.useRef)(null),{contentResource:r,altAsLabel:n,region:a="full"}=t,o;n&&(o=c(n));let f=m(t,["contentResource","altAsLabel"]),{type:d,id:u,width:z=200,height:W=200,format:Jt,duration:V}=r;(0,M.useEffect)(()=>{if(!u&&!e.current||["Image"].includes(d)||!u.includes("m3u8"))return;let l=new v.default;return e.current&&(l.attachMedia(e.current),l.on(v.default.Events.MEDIA_ATTACHED,function(){l.loadSource(u)})),l.on(v.default.Events.ERROR,function(C,A){if(A.fatal)switch(A.type){case v.default.ErrorTypes.NETWORK_ERROR:console.error(`fatal ${C} network error encountered, try to recover`),l.startLoad();break;case v.default.ErrorTypes.MEDIA_ERROR:console.error(`fatal ${C} media error encountered, try to recover`),l.recoverMediaError();break;default:l.destroy();break}}),()=>{l&&(l.detachMedia(),l.destroy())}},[]),(0,M.useEffect)(()=>D(),[]);let D=()=>{if(!e.current)return;let l=0,C=30;if(V&&(C=V),!u.split("#t=")&&V&&(l=V*.1),u.split("#t=").pop()){let B=u.split("#t=").pop();B&&(l=parseInt(B.split(",")[0]))}let A=e.current;A.autoplay=!0,A.currentTime=l,setTimeout(()=>D(),C*1e3)};switch(d){case"Image":let l=ct(r,`${z},${W}`,a);return(0,N.jsx)(ut,{as:"img",alt:o,css:{width:z,height:W},src:l,...f},u);case"Video":return(0,N.jsx)(ut,{as:"video",css:{width:z,height:W},disablePictureInPicture:!0,loop:!0,muted:!0,onPause:D,ref:e,src:u},u);default:return console.warn(`Resource type: ${d} is not valid or not yet supported in Nectar.`),(0,N.jsx)(N.Fragment,{})}},ft=Gt;var P=require("react/jsx-runtime"),Kt=t=>{let{thumbnail:e,region:r}=t,a=m(t,["thumbnail"]);return(0,P.jsx)(P.Fragment,{children:e&&e.map(o=>(0,P.jsx)(ft,{contentResource:o,region:r,...a},o.id))})},dt=Kt; | ||
"use strict";var pt=Object.create;var L=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var Rt=(t,e)=>{for(var r in e)L(t,r,{get:e[r],enumerable:!0})},J=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of yt(e))!St.call(t,a)&&a!==r&&L(t,a,{get:()=>e[a],enumerable:!(n=gt(e,a))||n.enumerable});return t};var q=(t,e,r)=>(r=t!=null?pt(bt(t)):{},J(e||!t||!t.__esModule?L(r,"default",{value:t,enumerable:!0}):r,t)),vt=t=>J(L({},"__esModule",{value:!0}),t);var Bt={};Rt(Bt,{Homepage:()=>Y,Label:()=>k,Metadata:()=>nt,PartOf:()=>it,RequiredStatement:()=>st,SeeAlso:()=>mt,Summary:()=>lt,Thumbnail:()=>dt,Value:()=>O});module.exports=vt(Bt);var Q=require("@stitches/react"),{styled:s,css:Ut,keyframes:Xt}=(0,Q.createStitches)({prefix:"nectar"});var _=(t,e="none")=>{if(!t)return null;if(typeof t=="string")return[t];if(!t[e]){let r=Object.getOwnPropertyNames(t);if(r.length>0)return t[r[0]]}return!t[e]||!Array.isArray(t[e])?null:t[e]},l=(t,e="none",r=", ")=>{let n=_(t,e);return Array.isArray(n)?n.join(`${r}`):n};var U=q(require("sanitize-html"));function X(t){return{__html:Ct(t)}}function m(t,e){let r=Object.keys(t).filter(a=>e.includes(a)?null:a),n=new Object;return r.forEach(a=>{n[a]=t[a]}),n}function Ct(t){return(0,U.default)(t,{allowedAttributes:{a:["href"],img:["alt","src"]},allowedSchemes:["http","https","mailto"],allowedTags:["a","b","br","i","img","p","small","span","sub","sup"]})}var h=require("react/jsx-runtime"),Nt=s("a",{}),At=t=>{let{children:e,homepage:r}=t,a=m(t,["children","homepage"]);return(0,h.jsx)(h.Fragment,{children:r&&r.map(o=>{let i=l(o.label,a.lang);return(0,h.jsx)(Nt,{"aria-label":e?i:void 0,href:o.id,...a,children:e||i},o.id)})})},Y=At;var Z=require("react/jsx-runtime"),ht=s("span",{}),Mt=t=>{let{as:e,label:r}=t,a=m(t,["as","label"]);return(0,Z.jsx)(ht,{as:e,...a,children:l(r,a.lang)})},k=Mt;var et=q(require("react"));var I=require("react"),j=require("react/jsx-runtime"),Pt={delimiter:", "},x=(0,I.createContext)(void 0),E=()=>{let t=(0,I.useContext)(x);if(t===void 0)throw new Error("useNectarContext must be used with a NectarProvider");return t},p=({children:t,initialState:e=Pt})=>{let r=y(e,"delimiter");return(0,j.jsx)(x.Provider,{value:{delimiter:r},children:t})},y=(t,e)=>Object.hasOwn(t,e)?t[e].toString():void 0;var g=require("react/jsx-runtime"),Vt=s("span",{}),tt=t=>{let{as:e,markup:r}=t,{delimiter:n}=E();if(!r)return(0,g.jsx)(g.Fragment,{});let o=m(t,["as","markup"]),i=X(l(r,o.lang,n));return(0,g.jsx)(Vt,{as:e,...o,dangerouslySetInnerHTML:i})},Lt=t=>et.default.useContext(x)?(0,g.jsx)(tt,{...t}):(0,g.jsx)(p,{children:(0,g.jsx)(tt,{...t})}),F=Lt;var rt=require("react/jsx-runtime"),kt=({as:t="dd",lang:e,value:r})=>(0,rt.jsx)(F,{markup:r,as:t,lang:e}),O=kt;var T=require("react");var G=require("react/jsx-runtime"),It=s("span",{}),xt=({as:t="dd",customValueContent:e,lang:r,value:n})=>{var i;let{delimiter:a}=E(),o=(i=_(n,r))==null?void 0:i.map(u=>(0,T.cloneElement)(e,{value:u}));return(0,G.jsx)(It,{as:t,lang:r,children:o==null?void 0:o.map((u,d)=>[d>0&&`${a}`,(0,G.jsx)(T.Fragment,{children:u},d)])})},ot=xt;var R=require("react/jsx-runtime"),Et=t=>{var u;let{item:e,lang:r,customValueContent:n}=t,{label:a,value:o}=e,i=(u=l(a))==null?void 0:u.replace(" ","-").toLowerCase();return(0,R.jsxs)("div",{role:"group","data-label":i,children:[(0,R.jsx)(k,{as:"dt",label:a,lang:r}),n?(0,R.jsx)(ot,{as:"dd",customValueContent:n,value:o,lang:r}):(0,R.jsx)(O,{as:"dd",value:o,lang:r})]})},w=Et;function at(t,e){let r=e.filter(n=>{let{matchingLabel:a}=n,o=Object.keys(n.matchingLabel)[0],i=l(a,o);if(l(t,o)===i)return!0}).map(n=>n.Content);if(!!Array.isArray(r))return r[0]}var b=require("react/jsx-runtime"),Ft=s("dl",{}),Ot=t=>{let{as:e,customValueContent:r,metadata:n}=t;if(!Array.isArray(n))return(0,b.jsx)(b.Fragment,{});let a=y(t,"customValueDelimiter"),i=m(t,["as","customValueContent","customValueDelimiter","metadata"]);return(0,b.jsx)(p,{...typeof a=="string"?{initialState:{delimiter:a}}:void 0,children:n.length>0&&(0,b.jsx)(Ft,{as:e,...i,children:n.map((u,d)=>{let f=r?at(u.label,r):void 0;return(0,b.jsx)(w,{customValueContent:f,item:u,lang:i==null?void 0:i.lang},d)})})})},nt=Ot;var H=require("react/jsx-runtime"),Tt=s("li",{}),wt=s("ul",{}),Ht=t=>{let{as:e,partOf:r}=t,a=m(t,["as","partOf"]);return(0,H.jsx)(wt,{as:e,children:r&&r.map(o=>{let i=o.label?l(o.label,a.lang):void 0;return(0,H.jsx)(Tt,{children:(0,H.jsx)("a",{href:o.id,...a,children:i||o.id})},o.id)})})},it=Ht;var S=require("react/jsx-runtime"),$t=s("dl",{}),zt=t=>{let{as:e,requiredStatement:r}=t;if(!r)return(0,S.jsx)(S.Fragment,{});let n=y(t,"customValueDelimiter"),o=m(t,["as","customValueDelimiter","requiredStatement"]);return(0,S.jsx)(p,{...typeof n=="string"?{initialState:{delimiter:n}}:void 0,children:(0,S.jsx)($t,{as:e,...o,children:(0,S.jsx)(w,{item:r,lang:o.lang})})})},st=zt;var $=require("react/jsx-runtime"),Wt=s("li",{}),Dt=s("ul",{}),qt=t=>{let{as:e,seeAlso:r}=t,a=m(t,["as","seeAlso"]);return(0,$.jsx)(Dt,{as:e,children:r&&r.map(o=>{let i=l(o.label,a.lang);return(0,$.jsx)(Wt,{children:(0,$.jsx)("a",{href:o.id,...a,children:i||o.id})},o.id)})})},mt=qt;var K=require("react/jsx-runtime"),_t=t=>{let{as:e,summary:r}=t,n=y(t,"customValueDelimiter"),o=m(t,["as","customValueDelimiter","summary"]);return(0,K.jsx)(p,{...typeof n=="string"?{initialState:{delimiter:n}}:void 0,children:(0,K.jsx)(F,{as:e,markup:r,...o})})},lt=_t;var M=require("react");var v=q(require("hls.js"));var ct=(t,e="200,",r="full")=>{Array.isArray(t)&&(t=t[0]);let{id:n,service:a}=t,o;if(!a)return n;if(Array.isArray(t.service)&&t.service.length>0&&(o=a[0]),o){if(o["@id"])return`${o["@id"]}/${r}/${e}/0/default.jpg`;if(o.id)return`${o.id}/${r}/${e}/0/default.jpg`}};var C=require("react/jsx-runtime"),ut=s("img",{objectFit:"cover"}),Gt=t=>{let e=(0,M.useRef)(null),{contentResource:r,altAsLabel:n,region:a="full"}=t,o;n&&(o=l(n));let u=m(t,["contentResource","altAsLabel"]),{type:d,id:f,width:z=200,height:W=200,format:Jt,duration:V}=r;(0,M.useEffect)(()=>{if(!f&&!e.current||["Image"].includes(d)||!f.includes("m3u8"))return;let c=new v.default;return e.current&&(c.attachMedia(e.current),c.on(v.default.Events.MEDIA_ATTACHED,function(){c.loadSource(f)})),c.on(v.default.Events.ERROR,function(N,A){if(A.fatal)switch(A.type){case v.default.ErrorTypes.NETWORK_ERROR:console.error(`fatal ${N} network error encountered, try to recover`),c.startLoad();break;case v.default.ErrorTypes.MEDIA_ERROR:console.error(`fatal ${N} media error encountered, try to recover`),c.recoverMediaError();break;default:c.destroy();break}}),()=>{c&&(c.detachMedia(),c.destroy())}},[]),(0,M.useEffect)(()=>D(),[]);let D=()=>{if(!e.current)return;let c=0,N=30;if(V&&(N=V),!f.split("#t=")&&V&&(c=V*.1),f.split("#t=").pop()){let B=f.split("#t=").pop();B&&(c=parseInt(B.split(",")[0]))}let A=e.current;A.autoplay=!0,A.currentTime=c,setTimeout(()=>D(),N*1e3)};switch(d){case"Image":let c=ct(r,`${z},${W}`,a);return(0,C.jsx)(ut,{as:"img",alt:o,css:{width:z,height:W},src:c,...u},f);case"Video":return(0,C.jsx)(ut,{as:"video",css:{width:z,height:W},disablePictureInPicture:!0,loop:!0,muted:!0,onPause:D,ref:e,src:f},f);default:return console.warn(`Resource type: ${d} is not valid or not yet supported in Nectar.`),(0,C.jsx)(C.Fragment,{})}},ft=Gt;var P=require("react/jsx-runtime"),Kt=t=>{let{thumbnail:e,region:r}=t,a=m(t,["thumbnail"]);return(0,P.jsx)(P.Fragment,{children:e&&e.map(o=>(0,P.jsx)(ft,{contentResource:o,region:r,...a},o.id))})},dt=Kt; |
@@ -1,1 +0,1 @@ | ||
import{createStitches as X}from"@stitches/react";var{styled:s,css:Qt,keyframes:Ut}=X({prefix:"nectar"});var L=(t,e="none")=>{if(!t)return null;if(typeof t=="string")return[t];if(!t[e]){let r=Object.getOwnPropertyNames(t);if(r.length>0)return t[r[0]]}return!t[e]||!Array.isArray(t[e])?null:t[e]},c=(t,e="none",r=", ")=>{let a=L(t,e);return Array.isArray(a)?a.join(`${r}`):a};import Y from"sanitize-html";function $(t){return{__html:Z(t)}}function m(t,e){let r=Object.keys(t).filter(n=>e.includes(n)?null:n),a=new Object;return r.forEach(n=>{a[n]=t[n]}),a}function Z(t){return Y(t,{allowedAttributes:{a:["href"],img:["alt","src"]},allowedSchemes:["http","https","mailto"],allowedTags:["a","b","br","i","img","p","small","span","sub","sup"]})}import{Fragment as rt,jsx as z}from"react/jsx-runtime";var j=s("a",{}),tt=t=>{let{children:e,homepage:r}=t,n=m(t,["children","homepage"]);return z(rt,{children:r&&r.map(o=>{let i=c(o.label,n.lang);return z(j,{"aria-label":e?i:void 0,href:o.id,...n,children:e||i},o.id)})})},et=tt;import{jsx as nt}from"react/jsx-runtime";var ot=s("span",{}),at=t=>{let{as:e,label:r}=t,n=m(t,["as","label"]);return nt(ot,{as:e,...n,children:c(r,n.lang)})},x=at;import ct from"react";import{createContext as it,useContext as st}from"react";import{jsx as lt}from"react/jsx-runtime";var mt={delimiter:", "},N=it(void 0),C=()=>{let t=st(N);if(t===void 0)throw new Error("useNectarContext must be used with a NectarProvider");return t},p=({children:t,initialState:e=mt})=>{let r=g(e,"delimiter");return lt(N.Provider,{value:{delimiter:r},children:t})},g=(t,e)=>Object.hasOwn(t,e)?t[e].toString():void 0;import{Fragment as dt,jsx as S}from"react/jsx-runtime";var ut=s("span",{}),W=t=>{let{as:e,markup:r}=t,{delimiter:a}=C();if(!r)return S(dt,{});let o=m(t,["as","markup"]),i=$(c(r,o.lang,a));return S(ut,{as:e,...o,dangerouslySetInnerHTML:i})},ft=t=>ct.useContext(N)?S(W,{...t}):S(p,{children:S(W,{...t})}),A=ft;import{jsx as gt}from"react/jsx-runtime";var pt=({as:t="dd",lang:e,value:r})=>gt(A,{markup:r,as:t,lang:e}),E=pt;import{cloneElement as yt,Fragment as bt}from"react";import{jsx as D}from"react/jsx-runtime";var St=s("span",{}),Rt=({as:t="dd",customValueContent:e,lang:r,value:a})=>{var i;let{delimiter:n}=C(),o=(i=L(a,r))==null?void 0:i.map(f=>yt(e,{value:f}));return D(St,{as:t,lang:r,children:o==null?void 0:o.map((f,d)=>[d>0&&`${n}`,D(bt,{children:f},d)])})},q=Rt;import{jsx as F,jsxs as Nt}from"react/jsx-runtime";var vt=t=>{let{item:e,lang:r,customValueContent:a}=t,{label:n,value:o}=e;return Nt("div",{role:"group",children:[F(x,{as:"dt",label:n,lang:r}),a?F(q,{as:"dd",customValueContent:a,value:o,lang:r}):F(E,{as:"dd",value:o,lang:r})]})},h=vt;function _(t,e){let r=e.filter(a=>{let{matchingLabel:n}=a,o=Object.keys(a.matchingLabel)[0],i=c(n,o);if(c(t,o)===i)return!0}).map(a=>a.Content);if(!!Array.isArray(r))return r[0]}import{Fragment as Mt,jsx as M}from"react/jsx-runtime";var Ct=s("dl",{}),At=t=>{let{as:e,customValueContent:r,metadata:a}=t;if(!Array.isArray(a))return M(Mt,{});let n=g(t,"customValueDelimiter"),i=m(t,["as","customValueContent","customValueDelimiter","metadata"]);return M(p,{...typeof n=="string"?{initialState:{delimiter:n}}:void 0,children:a.length>0&&M(Ct,{as:e,...i,children:a.map((f,d)=>{let u=r?_(f.label,r):void 0;return M(h,{customValueContent:u,item:f,lang:i==null?void 0:i.lang},d)})})})},ht=At;import{jsx as O}from"react/jsx-runtime";var Pt=s("li",{}),Vt=s("ul",{}),kt=t=>{let{as:e,partOf:r}=t,n=m(t,["as","partOf"]);return O(Vt,{as:e,children:r&&r.map(o=>{let i=o.label?c(o.label,n.lang):void 0;return O(Pt,{children:O("a",{href:o.id,...n,children:i||o.id})},o.id)})})},It=kt;import{Fragment as Ft,jsx as P}from"react/jsx-runtime";var Lt=s("dl",{}),xt=t=>{let{as:e,requiredStatement:r}=t;if(!r)return P(Ft,{});let a=g(t,"customValueDelimiter"),o=m(t,["as","customValueDelimiter","requiredStatement"]);return P(p,{...typeof a=="string"?{initialState:{delimiter:a}}:void 0,children:P(Lt,{as:e,...o,children:P(h,{item:r,lang:o.lang})})})},Et=xt;import{jsx as T}from"react/jsx-runtime";var Ot=s("li",{}),Tt=s("ul",{}),wt=t=>{let{as:e,seeAlso:r}=t,n=m(t,["as","seeAlso"]);return T(Tt,{as:e,children:r&&r.map(o=>{let i=c(o.label,n.lang);return T(Ot,{children:T("a",{href:o.id,...n,children:i||o.id})},o.id)})})},Ht=wt;import{jsx as G}from"react/jsx-runtime";var $t=t=>{let{as:e,summary:r}=t,a=g(t,"customValueDelimiter"),o=m(t,["as","customValueDelimiter","summary"]);return G(p,{...typeof a=="string"?{initialState:{delimiter:a}}:void 0,children:G(A,{as:e,markup:r,...o})})},zt=$t;import{useEffect as B,useRef as Wt}from"react";import R from"hls.js";var K=(t,e="200,",r="full")=>{Array.isArray(t)&&(t=t[0]);let{id:a,service:n}=t,o;if(!n)return a;if(Array.isArray(t.service)&&t.service.length>0&&(o=n[0]),o){if(o["@id"])return`${o["@id"]}/${r}/${e}/0/default.jpg`;if(o.id)return`${o.id}/${r}/${e}/0/default.jpg`}};import{Fragment as qt,jsx as w}from"react/jsx-runtime";var J=s("img",{objectFit:"cover"}),Dt=t=>{let e=Wt(null),{contentResource:r,altAsLabel:a,region:n="full"}=t,o;a&&(o=c(a));let f=m(t,["contentResource","altAsLabel"]),{type:d,id:u,width:V=200,height:k=200,format:Bt,duration:v}=r;B(()=>{if(!u&&!e.current||["Image"].includes(d)||!u.includes("m3u8"))return;let l=new R;return e.current&&(l.attachMedia(e.current),l.on(R.Events.MEDIA_ATTACHED,function(){l.loadSource(u)})),l.on(R.Events.ERROR,function(y,b){if(b.fatal)switch(b.type){case R.ErrorTypes.NETWORK_ERROR:console.error(`fatal ${y} network error encountered, try to recover`),l.startLoad();break;case R.ErrorTypes.MEDIA_ERROR:console.error(`fatal ${y} media error encountered, try to recover`),l.recoverMediaError();break;default:l.destroy();break}}),()=>{l&&(l.detachMedia(),l.destroy())}},[]),B(()=>I(),[]);let I=()=>{if(!e.current)return;let l=0,y=30;if(v&&(y=v),!u.split("#t=")&&v&&(l=v*.1),u.split("#t=").pop()){let H=u.split("#t=").pop();H&&(l=parseInt(H.split(",")[0]))}let b=e.current;b.autoplay=!0,b.currentTime=l,setTimeout(()=>I(),y*1e3)};switch(d){case"Image":let l=K(r,`${V},${k}`,n);return w(J,{as:"img",alt:o,css:{width:V,height:k},src:l,...f},u);case"Video":return w(J,{as:"video",css:{width:V,height:k},disablePictureInPicture:!0,loop:!0,muted:!0,onPause:I,ref:e,src:u},u);default:return console.warn(`Resource type: ${d} is not valid or not yet supported in Nectar.`),w(qt,{})}},Q=Dt;import{Fragment as Kt,jsx as U}from"react/jsx-runtime";var _t=t=>{let{thumbnail:e,region:r}=t,n=m(t,["thumbnail"]);return U(Kt,{children:e&&e.map(o=>U(Q,{contentResource:o,region:r,...n},o.id))})},Gt=_t;export{et as Homepage,x as Label,ht as Metadata,It as PartOf,Et as RequiredStatement,Ht as SeeAlso,zt as Summary,Gt as Thumbnail,E as Value}; | ||
import{createStitches as X}from"@stitches/react";var{styled:s,css:Qt,keyframes:Ut}=X({prefix:"nectar"});var I=(t,e="none")=>{if(!t)return null;if(typeof t=="string")return[t];if(!t[e]){let r=Object.getOwnPropertyNames(t);if(r.length>0)return t[r[0]]}return!t[e]||!Array.isArray(t[e])?null:t[e]},l=(t,e="none",r=", ")=>{let a=I(t,e);return Array.isArray(a)?a.join(`${r}`):a};import Y from"sanitize-html";function $(t){return{__html:Z(t)}}function m(t,e){let r=Object.keys(t).filter(n=>e.includes(n)?null:n),a=new Object;return r.forEach(n=>{a[n]=t[n]}),a}function Z(t){return Y(t,{allowedAttributes:{a:["href"],img:["alt","src"]},allowedSchemes:["http","https","mailto"],allowedTags:["a","b","br","i","img","p","small","span","sub","sup"]})}import{Fragment as rt,jsx as z}from"react/jsx-runtime";var j=s("a",{}),tt=t=>{let{children:e,homepage:r}=t,n=m(t,["children","homepage"]);return z(rt,{children:r&&r.map(o=>{let i=l(o.label,n.lang);return z(j,{"aria-label":e?i:void 0,href:o.id,...n,children:e||i},o.id)})})},et=tt;import{jsx as nt}from"react/jsx-runtime";var ot=s("span",{}),at=t=>{let{as:e,label:r}=t,n=m(t,["as","label"]);return nt(ot,{as:e,...n,children:l(r,n.lang)})},x=at;import ct from"react";import{createContext as it,useContext as st}from"react";import{jsx as lt}from"react/jsx-runtime";var mt={delimiter:", "},C=it(void 0),N=()=>{let t=st(C);if(t===void 0)throw new Error("useNectarContext must be used with a NectarProvider");return t},p=({children:t,initialState:e=mt})=>{let r=g(e,"delimiter");return lt(C.Provider,{value:{delimiter:r},children:t})},g=(t,e)=>Object.hasOwn(t,e)?t[e].toString():void 0;import{Fragment as dt,jsx as S}from"react/jsx-runtime";var ut=s("span",{}),W=t=>{let{as:e,markup:r}=t,{delimiter:a}=N();if(!r)return S(dt,{});let o=m(t,["as","markup"]),i=$(l(r,o.lang,a));return S(ut,{as:e,...o,dangerouslySetInnerHTML:i})},ft=t=>ct.useContext(C)?S(W,{...t}):S(p,{children:S(W,{...t})}),A=ft;import{jsx as gt}from"react/jsx-runtime";var pt=({as:t="dd",lang:e,value:r})=>gt(A,{markup:r,as:t,lang:e}),E=pt;import{cloneElement as yt,Fragment as bt}from"react";import{jsx as D}from"react/jsx-runtime";var St=s("span",{}),Rt=({as:t="dd",customValueContent:e,lang:r,value:a})=>{var i;let{delimiter:n}=N(),o=(i=I(a,r))==null?void 0:i.map(u=>yt(e,{value:u}));return D(St,{as:t,lang:r,children:o==null?void 0:o.map((u,d)=>[d>0&&`${n}`,D(bt,{children:u},d)])})},q=Rt;import{jsx as F,jsxs as Ct}from"react/jsx-runtime";var vt=t=>{var u;let{item:e,lang:r,customValueContent:a}=t,{label:n,value:o}=e,i=(u=l(n))==null?void 0:u.replace(" ","-").toLowerCase();return Ct("div",{role:"group","data-label":i,children:[F(x,{as:"dt",label:n,lang:r}),a?F(q,{as:"dd",customValueContent:a,value:o,lang:r}):F(E,{as:"dd",value:o,lang:r})]})},h=vt;function _(t,e){let r=e.filter(a=>{let{matchingLabel:n}=a,o=Object.keys(a.matchingLabel)[0],i=l(n,o);if(l(t,o)===i)return!0}).map(a=>a.Content);if(!!Array.isArray(r))return r[0]}import{Fragment as Mt,jsx as M}from"react/jsx-runtime";var Nt=s("dl",{}),At=t=>{let{as:e,customValueContent:r,metadata:a}=t;if(!Array.isArray(a))return M(Mt,{});let n=g(t,"customValueDelimiter"),i=m(t,["as","customValueContent","customValueDelimiter","metadata"]);return M(p,{...typeof n=="string"?{initialState:{delimiter:n}}:void 0,children:a.length>0&&M(Nt,{as:e,...i,children:a.map((u,d)=>{let f=r?_(u.label,r):void 0;return M(h,{customValueContent:f,item:u,lang:i==null?void 0:i.lang},d)})})})},ht=At;import{jsx as O}from"react/jsx-runtime";var Pt=s("li",{}),Vt=s("ul",{}),Lt=t=>{let{as:e,partOf:r}=t,n=m(t,["as","partOf"]);return O(Vt,{as:e,children:r&&r.map(o=>{let i=o.label?l(o.label,n.lang):void 0;return O(Pt,{children:O("a",{href:o.id,...n,children:i||o.id})},o.id)})})},kt=Lt;import{Fragment as Ft,jsx as P}from"react/jsx-runtime";var It=s("dl",{}),xt=t=>{let{as:e,requiredStatement:r}=t;if(!r)return P(Ft,{});let a=g(t,"customValueDelimiter"),o=m(t,["as","customValueDelimiter","requiredStatement"]);return P(p,{...typeof a=="string"?{initialState:{delimiter:a}}:void 0,children:P(It,{as:e,...o,children:P(h,{item:r,lang:o.lang})})})},Et=xt;import{jsx as T}from"react/jsx-runtime";var Ot=s("li",{}),Tt=s("ul",{}),wt=t=>{let{as:e,seeAlso:r}=t,n=m(t,["as","seeAlso"]);return T(Tt,{as:e,children:r&&r.map(o=>{let i=l(o.label,n.lang);return T(Ot,{children:T("a",{href:o.id,...n,children:i||o.id})},o.id)})})},Ht=wt;import{jsx as G}from"react/jsx-runtime";var $t=t=>{let{as:e,summary:r}=t,a=g(t,"customValueDelimiter"),o=m(t,["as","customValueDelimiter","summary"]);return G(p,{...typeof a=="string"?{initialState:{delimiter:a}}:void 0,children:G(A,{as:e,markup:r,...o})})},zt=$t;import{useEffect as B,useRef as Wt}from"react";import R from"hls.js";var K=(t,e="200,",r="full")=>{Array.isArray(t)&&(t=t[0]);let{id:a,service:n}=t,o;if(!n)return a;if(Array.isArray(t.service)&&t.service.length>0&&(o=n[0]),o){if(o["@id"])return`${o["@id"]}/${r}/${e}/0/default.jpg`;if(o.id)return`${o.id}/${r}/${e}/0/default.jpg`}};import{Fragment as qt,jsx as w}from"react/jsx-runtime";var J=s("img",{objectFit:"cover"}),Dt=t=>{let e=Wt(null),{contentResource:r,altAsLabel:a,region:n="full"}=t,o;a&&(o=l(a));let u=m(t,["contentResource","altAsLabel"]),{type:d,id:f,width:V=200,height:L=200,format:Bt,duration:v}=r;B(()=>{if(!f&&!e.current||["Image"].includes(d)||!f.includes("m3u8"))return;let c=new R;return e.current&&(c.attachMedia(e.current),c.on(R.Events.MEDIA_ATTACHED,function(){c.loadSource(f)})),c.on(R.Events.ERROR,function(y,b){if(b.fatal)switch(b.type){case R.ErrorTypes.NETWORK_ERROR:console.error(`fatal ${y} network error encountered, try to recover`),c.startLoad();break;case R.ErrorTypes.MEDIA_ERROR:console.error(`fatal ${y} media error encountered, try to recover`),c.recoverMediaError();break;default:c.destroy();break}}),()=>{c&&(c.detachMedia(),c.destroy())}},[]),B(()=>k(),[]);let k=()=>{if(!e.current)return;let c=0,y=30;if(v&&(y=v),!f.split("#t=")&&v&&(c=v*.1),f.split("#t=").pop()){let H=f.split("#t=").pop();H&&(c=parseInt(H.split(",")[0]))}let b=e.current;b.autoplay=!0,b.currentTime=c,setTimeout(()=>k(),y*1e3)};switch(d){case"Image":let c=K(r,`${V},${L}`,n);return w(J,{as:"img",alt:o,css:{width:V,height:L},src:c,...u},f);case"Video":return w(J,{as:"video",css:{width:V,height:L},disablePictureInPicture:!0,loop:!0,muted:!0,onPause:k,ref:e,src:f},f);default:return console.warn(`Resource type: ${d} is not valid or not yet supported in Nectar.`),w(qt,{})}},Q=Dt;import{Fragment as Kt,jsx as U}from"react/jsx-runtime";var _t=t=>{let{thumbnail:e,region:r}=t,n=m(t,["thumbnail"]);return U(Kt,{children:e&&e.map(o=>U(Q,{contentResource:o,region:r,...n},o.id))})},Gt=_t;export{et as Homepage,x as Label,ht as Metadata,kt as PartOf,Et as RequiredStatement,Ht as SeeAlso,zt as Summary,Gt as Thumbnail,E as Value}; |
{ | ||
"name": "@samvera/nectar-iiif", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
76701
300
0