yamlover 0.3.13 → 0.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +11 -2
  2. package/dist/agent-docs/AGENTS.md +4 -2
  3. package/dist/builtin-taxonomy/$defs/board +7 -7
  4. package/dist/builtin-taxonomy/$defs/chapter +17 -11
  5. package/dist/builtin-taxonomy/$defs/chunk +5 -3
  6. package/dist/builtin-taxonomy/$defs/task +15 -16
  7. package/dist/builtin-taxonomy/$defs/workflow +1 -1
  8. package/dist/client/assets/decoded-CY5-anyl.js +1 -0
  9. package/dist/client/assets/djvu-CbL4_9ak.js +1 -0
  10. package/dist/client/assets/{docx-B_9I-KwO.js → docx-CCEuxO9n.js} +1 -1
  11. package/dist/client/assets/{heic-Ce7tu8UK.js → heic-BvS6Unla.js} +2 -2
  12. package/dist/client/assets/imagemap-DBji1qL1.js +1 -0
  13. package/dist/client/assets/index-1sCxQdj3.css +1 -0
  14. package/dist/client/assets/index-DqdQvRi4.js +632 -0
  15. package/dist/client/assets/map-BfHrzAqt.js +1 -0
  16. package/dist/client/assets/openable-DIyqYrzm.js +4 -0
  17. package/dist/client/assets/{paged-CBui7Gsu.js → paged-COP9CRTO.js} +1 -1
  18. package/dist/client/assets/{pdf-DEAMWCiJ.js → pdf-C-kvASQl.js} +9 -9
  19. package/dist/client/assets/psd-KxbPOIwA.js +11 -0
  20. package/dist/client/assets/{spreadsheet-DM8lRCkI.js → spreadsheet-DkG5umsc.js} +1 -1
  21. package/dist/client/assets/tiff-sq_Q9sNj.js +1 -0
  22. package/dist/client/index.html +2 -2
  23. package/dist/server.js +1014 -274
  24. package/package.json +1 -1
  25. package/dist/client/assets/decoded-7CsibQKd.js +0 -1
  26. package/dist/client/assets/djvu-BXFlPnkK.js +0 -1
  27. package/dist/client/assets/imagemap-DlsYOgu-.js +0 -1
  28. package/dist/client/assets/index-D7TqaRqy.js +0 -620
  29. package/dist/client/assets/index-DEBdytA6.css +0 -1
  30. package/dist/client/assets/map-CKyCg437.js +0 -1
  31. package/dist/client/assets/panzoom-BDtxTlLr.js +0 -4
  32. package/dist/client/assets/psd-BUfV7J7j.js +0 -11
  33. package/dist/client/assets/tiff-DvGVB25t.js +0 -1
  34. /package/dist/client/assets/{panzoom-CIGW-MKW.css → openable-CIGW-MKW.css} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yamlover",
3
- "version": "0.3.13",
3
+ "version": "0.3.21",
4
4
  "description": "Browse a yamlover tree in the web: npx yamlover <root> serves a React SPA over a directory.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- import{r as f,b as d,j as i}from"./index-D7TqaRqy.js";import{PanZoomImage as p}from"./imagemap-DlsYOgu-.js";function j({node:r,label:t,decode:a}){const[e,n]=f.useState([]),[c,u]=f.useState(null);return f.useEffect(()=>{let s=!1;const o=[];return n([]),u(null),(async()=>{const l=await fetch(d(r.path)).then(m=>m.arrayBuffer()),g=await a(l);if(!s){for(const m of g)o.push(URL.createObjectURL(m));s||n(o)}})().catch(l=>!s&&u(String(l.message||l))),()=>{s=!0,o.forEach(URL.revokeObjectURL)}},[r.path]),c?i.jsxs("div",{className:"error",children:[t,": ",c]}):e.length?i.jsx(i.Fragment,{children:e.map((s,o)=>i.jsx(p,{src:s,className:"filemap fileimagemap"},o))}):i.jsxs("div",{className:"loading",children:["decoding ",t,"…"]})}async function E(r,t,a){const e=document.createElement("canvas");e.width=t,e.height=a;const n=e.getContext("2d");if(!n)throw new Error("no 2d context");const c=n.createImageData(t,a);return c.data.set(r),n.putImageData(c,0,0),h(e)}function h(r){return new Promise((t,a)=>r.toBlob(e=>e?t(e):a(new Error("canvas export failed")),"image/png"))}export{j as D,h as c,E as r};
@@ -1 +0,0 @@
1
- import{r as u,f as te,d as ne,e as oe,c as re,D as W,b as se,j as d}from"./index-D7TqaRqy.js";import{u as ae}from"./paged-CBui7Gsu.js";const ce="/assets/djvu-Ci0lFKxE.js";let X=null;function ie(){return window.DjVu?Promise.resolve(window.DjVu):(X??=new Promise((s,c)=>{const i=document.createElement("script");i.src=ce,i.onload=()=>window.DjVu?s(window.DjVu):c(new Error("DjVu failed to load")),i.onerror=()=>c(new Error("could not load djvu.js")),document.head.appendChild(i)}),X)}let m=null,Y=null,_=null;const p=new Map,S=new Map,le=6,F=1500;async function ue(s,c){const i=await ie();return m??=new i.Worker,c!==Y&&(Y=c,p.clear(),S.clear(),_=(async()=>(await m.createDocument(s),Number(await m.doc.getPagesQuantity().run())||0))()),_}async function de(s,c){const i=Math.max(1,Math.round(s.height*c/s.width)),w=await createImageBitmap(s,{resizeWidth:c,resizeHeight:i,resizeQuality:"medium"}),g=document.createElement("canvas");g.width=c,g.height=i;const v=g.getContext("2d");return v.drawImage(w,0,0),w.close(),v.getImageData(0,0,c,i)}function he(s){const c=p.get(s);if(c)return p.delete(s),p.set(s,c),Promise.resolve(c);const i=S.get(s);if(i)return i;const w=(async()=>{const[g,v,x,P]=await m.run(m.doc.getPage(s).getImageData(),m.doc.getPage(s).getNormalizedTextZones(),m.doc.getPage(s).getWidth(),m.doc.getPage(s).getHeight()),M=Number(x)||g.width,N=Number(P)||g.height,y={image:M>F?await de(g,F):g,zones:Array.isArray(v)?v:[],w:M,h:N};for(S.delete(s),p.set(s,y);p.size>le;)p.delete(p.keys().next().value);return y})();return S.set(s,w),w}const C=s=>Number(s)||0;function ge({image:s}){const c=u.useRef(null);return u.useLayoutEffect(()=>{const i=c.current;i&&(i.width=s.width,i.height=s.height,i.getContext("2d")?.putImageData(s,0,0))},[s]),d.jsx("canvas",{className:"djvu-page",ref:c})}function ve({node:s}){const c=u.useRef(null),[i,w]=u.useState(0),[g,v]=u.useState(1),[x,P]=u.useState(0),[M,N]=u.useState(null),[f,y]=u.useState(null),[b,V]=u.useState(()=>new Set),[D,T]=u.useState(()=>new Map),A=u.useRef(new Map),z=te(s.path),{openCreate:H,openEdit:Q,palette:Z,preview:R}=ne(z),q=(R?[...z.annotations,{path:"(preview)",selector:R.selector,tag:R.tag}]:z.annotations).filter(t=>t.selector?.type==="djvu").map(t=>({page:C(t.selector.page)||1,x:C(t.selector.x),y:C(t.selector.y),w:C(t.selector.w),h:C(t.selector.h),title:t.description,color:re(t),ann:oe(t)?t:void 0})),O=R?.color??W,E=u.useRef(new Map),k=ae(c,()=>{const t=[];for(let n=1;n<=i;n++){const e=E.current.get(n);e&&t.push(e)}return t},i>0&&x>0),K=u.useRef(k);K.current=k,u.useLayoutEffect(()=>{k.restoreAnchor()},[g]),u.useEffect(()=>{const t=c.current;t&&!t.closest(".chunk-body")&&t.focus({preventScroll:!0})},[]),u.useLayoutEffect(()=>{const t=c.current;if(!t)return;const n=new ResizeObserver(([e])=>P(e.contentRect.width));return n.observe(t),()=>n.disconnect()},[]);const B=Math.min(x,1e3)*g;u.useEffect(()=>{const t=c.current;if(!t)return;let n=!1,e=0;const o=a=>{(a.ctrlKey||a.altKey||a.metaKey)&&(a.preventDefault(),n||(K.current.captureAnchor(),n=!0),clearTimeout(e),e=window.setTimeout(()=>n=!1,250),v(h=>Math.min(5,Math.max(.4,h*(a.deltaY<0?1.1:1/1.1)))))};return t.addEventListener("wheel",o,{passive:!1}),()=>{t.removeEventListener("wheel",o),clearTimeout(e)}},[]),u.useEffect(()=>{let t=!1;return w(0),N(null),V(new Set),T(new Map),E.current.clear(),A.current.clear(),(async()=>{const n=await fetch(se(s.path)).then(o=>o.arrayBuffer()),e=await ue(n,s.path);t||w(e)})().catch(n=>!t&&N(String(n.message||n))),()=>{t=!0}},[s.path]),u.useEffect(()=>{if(!i)return;const t=new IntersectionObserver(n=>{V(e=>{const o=new Set(e);for(const a of n){const h=Number(a.target.dataset.page);a.isIntersecting?o.add(h):o.delete(h)}return o.size===e.size&&[...o].every(a=>e.has(a))?e:o})},{root:c.current,rootMargin:"2000px 0px"});for(const n of E.current.values())t.observe(n);return()=>t.disconnect()},[i,x>0]),u.useEffect(()=>{let t=!0;return b.forEach(n=>{D.has(n)||he(n).then(e=>{A.current.set(n,{w:e.w,h:e.h}),t&&T(o=>new Map(o).set(n,e))}).catch(()=>{})}),T(n=>{let e=!1;const o=new Map(n);for(const a of o.keys())b.has(a)||(o.delete(a),e=!0);return e?o:n}),()=>{t=!1}},[b]);const G=()=>{const t=window.getSelection();if(!t||t.isCollapsed||!t.anchorNode)return;const e=(t.anchorNode.nodeType===1?t.anchorNode:t.anchorNode.parentElement)?.closest(".djvu-page-wrap");if(!e||!c.current?.contains(e))return;const o=Number(e.dataset.page),a=e.getBoundingClientRect(),h=a.width/(D.get(o)?.w||1);if(!h)return;const l=t.getRangeAt(0).getBoundingClientRect();l.width<2||l.height<2||H({type:"djvu",page:o,x:Math.round((l.left-a.left)/h),y:Math.round((l.top-a.top)/h),w:Math.round(l.width/h),h:Math.round(l.height/h)},{x:l.left,y:l.bottom+6})},I=(t,n)=>n.getBoundingClientRect().width/(D.get(t)?.w||1),J=(t,n)=>{const e=n.currentTarget.getBoundingClientRect(),o=I(t,n.currentTarget);y({page:t,x0:(n.clientX-e.left)/o,y0:(n.clientY-e.top)/o,x1:(n.clientX-e.left)/o,y1:(n.clientY-e.top)/o})},$=(t,n)=>{const e=n.currentTarget.getBoundingClientRect(),o=I(t,n.currentTarget);y(a=>a&&{...a,x1:(n.clientX-e.left)/o,y1:(n.clientY-e.top)/o})},ee=(t,n)=>{const e=f;if(y(null),!e||e.page!==t)return;const o=I(t,n.currentTarget),a=Math.min(e.x0,e.x1),h=Math.min(e.y0,e.y1),l=Math.abs(e.x1-e.x0),r=Math.abs(e.y1-e.y0);if(l*o<3||r*o<3)return;const j=n.currentTarget.getBoundingClientRect();H({type:"djvu",page:t,x:Math.round(a),y:Math.round(h),w:Math.round(l),h:Math.round(r)},{x:j.left+a*o,y:j.top+(h+r)*o+6})};return M?d.jsxs("div",{className:"error",children:["djvu: ",M]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"filedjvu yo-zoomable",ref:c,tabIndex:0,onMouseUp:G,children:[i===0&&d.jsx("div",{className:"loading",children:"opening djvu…"}),x>0&&Array.from({length:i},(t,n)=>{const e=n+1,o=b.has(e)?D.get(e):void 0,a=A.current.get(e),h=B*(a?a.h/a.w:Math.SQRT2),l=o?B/o.w:0;return d.jsx("div",{className:"djvu-page-wrap","data-page":e,ref:r=>{r?E.current.set(e,r):E.current.delete(e)},style:{width:B,height:o?void 0:h},children:o?d.jsxs(d.Fragment,{children:[d.jsx(ge,{image:o.image}),o.zones.length>0?d.jsx("div",{className:"djvu-textlayer",children:o.zones.map((r,j)=>d.jsx("span",{style:{left:r.x*l,top:r.y*l,width:r.width*l,height:r.height*l,fontSize:r.height*l},children:r.text},j))}):d.jsx("div",{className:"djvu-marquee",onMouseDown:r=>J(e,r),onMouseMove:r=>$(e,r),onMouseUp:r=>ee(e,r),children:f?.page===e&&d.jsx("div",{className:"djvu-region",style:{left:Math.min(f.x0,f.x1)*l,top:Math.min(f.y0,f.y1)*l,width:Math.abs(f.x1-f.x0)*l,height:Math.abs(f.y1-f.y0)*l,borderColor:O,background:O+"2e"}})}),q.filter(r=>r.page===e).map((r,j)=>{const U=r.color||W;return d.jsx("div",{className:"djvu-region"+(r.ann?" editable":""),title:r.ann?r.title||"click to recolor or delete":r.title,onClick:r.ann?L=>{L.stopPropagation(),Q(r.ann,{x:L.clientX,y:L.clientY})}:void 0,style:{left:r.x*l,top:r.y*l,width:r.w*l,height:r.h*l,borderColor:U,background:U+"2e"}},j)})]}):d.jsx("div",{className:"djvu-placeholder",children:b.has(e)?"decoding…":""})},n)})]}),Z]})}export{ve as DjvuView};
@@ -1 +0,0 @@
1
- import{j as a,b as U,f as J,d as K,r,D as A,e as V,c as X}from"./index-D7TqaRqy.js";import{L as h,w as Y}from"./panzoom-BDtxTlLr.js";const E=e=>Number(e)||0;function _(e,t,f,s,c){if(!e||s<=0||c<=0)return;const o=document.createElement("canvas");o.width=s,o.height=c;const l=o.getContext("2d");if(l){l.drawImage(e,t,f,s,c,0,0,s,c);try{return o.toDataURL("image/png")}catch{return}}}function q(e){return e.filter(t=>t.selector?.type==="rect").map(t=>({x:E(t.selector.x),y:E(t.selector.y),w:E(t.selector.w),h:E(t.selector.h),title:t.description,color:X(t),ann:V(t)?t:void 0}))}function z({src:e,className:t,regions:f,onSelectRegion:s,onRegionClick:c,selectColor:o}){const l=r.useRef(null),g=r.useRef(null),x=r.useRef(null),w=r.useRef(null),R=r.useRef({w:1,h:1}),N=r.useRef(s),j=r.useRef(c),b=r.useRef(o),[C,S]=r.useState(null),[F,G]=r.useState(0),P=JSON.stringify(f??[]),M=!!s;return r.useEffect(()=>{N.current=s,j.current=c,b.current=o}),r.useEffect(()=>{let i=!1,y=null;S(null);const n=new Image;return n.onload=()=>{if(i||!l.current)return;const v=n.naturalWidth||1,m=n.naturalHeight||1;R.current={w:v,h:m},w.current=n;const u=h.map(l.current,{crs:h.CRS.Simple,minZoom:-8,attributionControl:!1,zoomSnap:0}),d=[[0,0],[m,v]];h.imageOverlay(e,d).addTo(u),u.fitBounds(d),x.current=h.layerGroup().addTo(u),g.current=u,y=Y(u,{color:()=>b.current?.()??A,onSelect:M?(p,W)=>{const{h:Z}=R.current,O=p.getWest(),B=p.getEast(),H=p.getSouth(),I=p.getNorth(),L=Math.round(O),T=Math.round(Z-I),k=Math.round(B-O),D=Math.round(I-H);N.current?.({type:"rect",x:L,y:T,w:k,h:D},W,_(w.current,L,T,k,D))}:void 0}),G(p=>p+1)},n.onerror=()=>{i||S("could not load image")},n.src=e,()=>{i=!0,y?.(),g.current?.remove(),g.current=null,x.current=null}},[e]),r.useEffect(()=>{const i=x.current;if(!i)return;i.clearLayers();const{h:y}=R.current;for(const n of f??[]){const v=n.color||A,m=h.rectangle([[y-n.y,n.x],[y-(n.y+n.h),n.x+n.w]],{className:"yo-region",color:v,weight:3,fillColor:v,fillOpacity:.25});if(n.title&&m.bindTooltip(n.title),n.ann){const u=n.ann;m.on("click",d=>{h.DomEvent.stop(d),j.current?.(u,{x:d.originalEvent.clientX,y:d.originalEvent.clientY})})}m.addTo(i)}},[P,F]),a.jsxs(a.Fragment,{children:[C&&a.jsxs("div",{className:"error",children:["image: ",C]}),a.jsx("div",{ref:l,className:t+(M?" yo-selectable":"")})]})}function ee({node:e}){const t=J(e.path),{openCreate:f,openEdit:s,palette:c,preview:o,color:l}=K(t),g=o?[...t.annotations,{path:"(preview)",selector:o.selector,tag:o.tag}]:t.annotations;return a.jsxs("div",{className:"text",children:[e.title&&a.jsx("h1",{className:"chapter-title",children:e.title}),e.description&&a.jsx("p",{className:"chapter-subtitle",children:e.description}),a.jsx(z,{src:U(e.path),regions:q(g),onSelectRegion:(x,w,R)=>f(x,w,void 0,R),onRegionClick:s,selectColor:()=>l,className:"filemap fileimagemap"}),c]})}function te({chunk:e}){return a.jsx(z,{src:U(e.path),className:"filemap chunk-map fileimagemap"})}export{te as ImageChunk,ee as ImageView,z as PanZoomImage};