yamlover 0.3.24 → 0.3.48
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/README.md +29 -10
- package/bin/yamlover.js +14 -6
- package/dist/agent-docs/AGENTS.md +28 -2
- package/dist/builtin-taxonomy/$defs/.yamlover/meta.yamlover +9 -0
- package/dist/builtin-taxonomy/$defs/bullets +12 -0
- package/dist/builtin-taxonomy/$defs/chapter +19 -13
- package/dist/builtin-taxonomy/$defs/numbered +12 -0
- package/dist/builtin-taxonomy/$defs/table +36 -0
- package/dist/builtin-taxonomy/$defs/task +4 -3
- package/dist/client/assets/decoded-Dfxf1BRR.js +1 -0
- package/dist/client/assets/djvu-BAFaxONw.js +1 -0
- package/dist/client/assets/{docx-D39uvoU4.js → docx-aCX_2O0_.js} +1 -1
- package/dist/client/assets/{heic-V9_YmnBI.js → heic-8pzTwsCx.js} +2 -2
- package/dist/client/assets/imagemap-Bp26n33x.js +1 -0
- package/dist/client/assets/index-BohJjyVY.css +1 -0
- package/dist/client/assets/index-DXrtwPKE.js +754 -0
- package/dist/client/assets/map-Dtw0_sOf.js +1 -0
- package/dist/client/assets/{openable-BA6YbLif.js → openable-Banncb36.js} +2 -2
- package/dist/client/assets/paged-BGVPKMC7.js +1 -0
- package/dist/client/assets/{pdf-n0dUtCdE.js → pdf-eI1AsxuB.js} +5 -5
- package/dist/client/assets/psd-BD_hUWIy.js +11 -0
- package/dist/client/assets/{spreadsheet-Cx1xwMVZ.js → spreadsheet-D_yjjR8a.js} +1 -1
- package/dist/client/assets/tiff-BewNDYwu.js +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server.js +2658 -647
- package/package.json +2 -1
- package/dist/client/assets/decoded-CoBf28Qo.js +0 -1
- package/dist/client/assets/djvu-CZ2rFOhT.js +0 -1
- package/dist/client/assets/imagemap-b1Kpzcjf.js +0 -1
- package/dist/client/assets/index-DGta_4EZ.js +0 -665
- package/dist/client/assets/index-DyHnoDfk.css +0 -1
- package/dist/client/assets/map-CTJuSrDN.js +0 -1
- package/dist/client/assets/paged-BYF4Obqh.js +0 -1
- package/dist/client/assets/psd-Z9Xy8WJM.js +0 -11
- package/dist/client/assets/tiff-BU7hwL9b.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yamlover",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.48",
|
|
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",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"start": "node bin/yamlover.js",
|
|
32
32
|
"build": "node scripts/build.mjs",
|
|
33
33
|
"prepack": "node scripts/build.mjs",
|
|
34
|
+
"gen:edit-fixtures": "node scripts/gen-edit-fixtures.ts",
|
|
34
35
|
"test": "vitest run",
|
|
35
36
|
"test:watch": "vitest"
|
|
36
37
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,b as d,j as o}from"./index-DGta_4EZ.js";import{StaticImageChunk as h,PanZoomImage as x}from"./imagemap-b1Kpzcjf.js";function E({node:t,label:a,decode:n,chunk:e}){const[s,i]=l.useState([]),[u,g]=l.useState(null);return l.useEffect(()=>{let r=!1;const c=[];return i([]),g(null),(async()=>{const m=await fetch(d(t.path)).then(f=>f.arrayBuffer()),p=await n(m);if(!r){for(const f of p)c.push(URL.createObjectURL(f));r||i(c)}})().catch(m=>!r&&g(String(m.message||m))),()=>{r=!0,c.forEach(URL.revokeObjectURL)}},[t.path]),u?o.jsxs("div",{className:"error",children:[a,": ",u]}):s.length?o.jsx(o.Fragment,{children:s.map((r,c)=>e?o.jsx(h,{src:r,path:t.path,onNavigate:e.onNavigate},c):o.jsx(x,{src:r,className:"filemap fileimagemap"},c))}):o.jsxs("div",{className:"loading",children:["decoding ",a,"…"]})}async function w(t,a,n){const e=document.createElement("canvas");e.width=a,e.height=n;const s=e.getContext("2d");if(!s)throw new Error("no 2d context");const i=s.createImageData(a,n);return i.data.set(t),s.putImageData(i,0,0),b(e)}function b(t){return new Promise((a,n)=>t.toBlob(e=>e?a(e):n(new Error("canvas export failed")),"image/png"))}export{E as D,b as c,w as r};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,u as te,a as ne,e as oe,c as re,D as X,b as se,j as d,f as ae}from"./index-DGta_4EZ.js";import{u as ce}from"./paged-BYF4Obqh.js";const ie="/assets/djvu-Ci0lFKxE.js";let Y=null;function ue(){return window.DjVu?Promise.resolve(window.DjVu):(Y??=new Promise((s,c)=>{const i=document.createElement("script");i.src=ie,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)}),Y)}let v=null,_=null,F=null;const m=new Map,R=new Map,le=6,Q=1500;async function de(s,c){const i=await ue();return v??=new i.Worker,c!==_&&(_=c,m.clear(),R.clear(),F=(async()=>(await v.createDocument(s),Number(await v.doc.getPagesQuantity().run())||0))()),F}async function he(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 x=g.getContext("2d");return x.drawImage(w,0,0),w.close(),x.getImageData(0,0,c,i)}function ge(s){const c=m.get(s);if(c)return m.delete(s),m.set(s,c),Promise.resolve(c);const i=R.get(s);if(i)return i;const w=(async()=>{const[g,x,y,A]=await v.run(v.doc.getPage(s).getImageData(),v.doc.getPage(s).getNormalizedTextZones(),v.doc.getPage(s).getWidth(),v.doc.getPage(s).getHeight()),b=Number(y)||g.width,N=Number(A)||g.height,j={image:b>Q?await he(g,Q):g,zones:Array.isArray(x)?x:[],w:b,h:N};for(R.delete(s),m.set(s,j);m.size>le;)m.delete(m.keys().next().value);return j})();return R.set(s,w),w}const p=s=>Number(s)||0;function fe({image:s}){const c=l.useRef(null);return l.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=l.useRef(null),[i,w]=l.useState(0),[g,x]=l.useState(1),[y,A]=l.useState(0),[b,N]=l.useState(null),[f,j]=l.useState(null),[E,L]=l.useState(()=>new Set),[D,P]=l.useState(()=>new Map),T=l.useRef(new Map),V=te(s.path),{openCreate:H,openEdit:Z,palette:q,preview:S}=ne(V,s.path),O=V.annotations.filter(e=>e.selector?.type==="djvu").map(e=>({page:p(e.selector.page)||1,x:p(e.selector.x),y:p(e.selector.y),w:p(e.selector.w),h:p(e.selector.h),title:e.description,color:re(e),ann:oe(e)?e:void 0})),K=S?.color??X;if(S?.selector.type==="djvu"){const e=S.selector;O.push({page:p(e.page)||1,x:p(e.x),y:p(e.y),w:p(e.w),h:p(e.h),color:S.color})}const C=l.useRef(new Map),z=ce(c,()=>{const e=[];for(let n=1;n<=i;n++){const t=C.current.get(n);t&&e.push(t)}return e},i>0&&y>0),U=l.useRef(z);U.current=z,l.useLayoutEffect(()=>{z.restoreAnchor()},[g]),l.useEffect(()=>{const e=c.current;e&&!e.closest(".chunk-body")&&e.focus({preventScroll:!0})},[]),l.useLayoutEffect(()=>{const e=c.current;if(!e)return;const n=new ResizeObserver(([t])=>A(t.contentRect.width));return n.observe(e),()=>n.disconnect()},[]);const k=Math.min(y,1e3)*g;l.useEffect(()=>{const e=c.current;if(!e)return;let n=!1,t=0;const o=a=>{(a.ctrlKey||a.altKey||a.metaKey)&&(a.preventDefault(),n||(U.current.captureAnchor(),n=!0),clearTimeout(t),t=window.setTimeout(()=>n=!1,250),x(h=>Math.min(5,Math.max(.4,h*(a.deltaY<0?1.1:1/1.1)))))};return e.addEventListener("wheel",o,{passive:!1}),()=>{e.removeEventListener("wheel",o),clearTimeout(t)}},[]),l.useEffect(()=>{let e=!1;return w(0),N(null),L(new Set),P(new Map),C.current.clear(),T.current.clear(),(async()=>{const n=await fetch(se(s.path)).then(o=>o.arrayBuffer()),t=await de(n,s.path);e||w(t)})().catch(n=>!e&&N(String(n.message||n))),()=>{e=!0}},[s.path]),l.useEffect(()=>{if(!i)return;const e=new IntersectionObserver(n=>{L(t=>{const o=new Set(t);for(const a of n){const h=Number(a.target.dataset.page);a.isIntersecting?o.add(h):o.delete(h)}return o.size===t.size&&[...o].every(a=>t.has(a))?t:o})},{root:c.current,rootMargin:"2000px 0px"});for(const n of C.current.values())e.observe(n);return()=>e.disconnect()},[i,y>0]),l.useEffect(()=>{let e=!0;return E.forEach(n=>{D.has(n)||ge(n).then(t=>{T.current.set(n,{w:t.w,h:t.h}),e&&P(o=>new Map(o).set(n,t))}).catch(()=>{})}),P(n=>{let t=!1;const o=new Map(n);for(const a of o.keys())E.has(a)||(o.delete(a),t=!0);return t?o:n}),()=>{e=!1}},[E]);const G=()=>{const e=window.getSelection();if(!e||e.isCollapsed||!e.anchorNode)return;const t=(e.anchorNode.nodeType===1?e.anchorNode:e.anchorNode.parentElement)?.closest(".djvu-page-wrap");if(!t||!c.current?.contains(t))return;const o=Number(t.dataset.page),a=t.getBoundingClientRect(),h=a.width/(D.get(o)?.w||1);if(!h)return;const u=e.getRangeAt(0).getBoundingClientRect();u.width<2||u.height<2||H({type:"djvu",page:o,x:Math.round((u.left-a.left)/h),y:Math.round((u.top-a.top)/h),w:Math.round(u.width/h),h:Math.round(u.height/h)},{x:u.left,y:u.bottom+6})},I=(e,n)=>n.getBoundingClientRect().width/(D.get(e)?.w||1),J=(e,n)=>{const t=n.currentTarget.getBoundingClientRect(),o=I(e,n.currentTarget);j({page:e,x0:(n.clientX-t.left)/o,y0:(n.clientY-t.top)/o,x1:(n.clientX-t.left)/o,y1:(n.clientY-t.top)/o})},$=(e,n)=>{const t=n.currentTarget.getBoundingClientRect(),o=I(e,n.currentTarget);j(a=>a&&{...a,x1:(n.clientX-t.left)/o,y1:(n.clientY-t.top)/o})},ee=(e,n)=>{const t=f;if(j(null),!t||t.page!==e)return;const o=I(e,n.currentTarget),a=Math.min(t.x0,t.x1),h=Math.min(t.y0,t.y1),u=Math.abs(t.x1-t.x0),r=Math.abs(t.y1-t.y0);if(u*o<3||r*o<3)return;const M=n.currentTarget.getBoundingClientRect();H({type:"djvu",page:e,x:Math.round(a),y:Math.round(h),w:Math.round(u),h:Math.round(r)},{x:M.left+a*o,y:M.top+(h+r)*o+6})};return b?d.jsxs("div",{className:"error",children:["djvu: ",b]}):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…"}),y>0&&Array.from({length:i},(e,n)=>{const t=n+1,o=E.has(t)?D.get(t):void 0,a=T.current.get(t),h=k*(a?a.h/a.w:Math.SQRT2),u=o?k/o.w:0;return d.jsx("div",{className:"djvu-page-wrap","data-page":t,ref:r=>{r?C.current.set(t,r):C.current.delete(t)},style:{width:k,height:o?void 0:h},children:o?d.jsxs(d.Fragment,{children:[d.jsx(fe,{image:o.image}),o.zones.length>0?d.jsx("div",{className:"djvu-textlayer",children:o.zones.map((r,M)=>d.jsx("span",{style:{left:r.x*u,top:r.y*u,width:r.width*u,height:r.height*u,fontSize:r.height*u},children:r.text},M))}):d.jsx("div",{className:"djvu-marquee",onMouseDown:r=>J(t,r),onMouseMove:r=>$(t,r),onMouseUp:r=>ee(t,r),children:f?.page===t&&d.jsx("div",{className:"djvu-region",style:{left:Math.min(f.x0,f.x1)*u,top:Math.min(f.y0,f.y1)*u,width:Math.abs(f.x1-f.x0)*u,height:Math.abs(f.y1-f.y0)*u,borderColor:K,background:K+"2e"}})}),O.filter(r=>r.page===t).map((r,M)=>{const W=r.color||X;return d.jsx("div",{id:r.ann?.fragmentSlug?ae(s.path,r.ann.fragmentSlug):void 0,className:"djvu-region"+(r.ann?" editable":""),title:r.ann?r.title||"click to recolor or delete":r.title,onClick:r.ann?B=>{B.stopPropagation(),Z(r.ann,{x:B.clientX,y:B.clientY})}:void 0,style:{left:r.x*u,top:r.y*u,width:r.w*u,height:r.h*u,borderColor:W,background:W+"2e"}},M)})]}):d.jsx("div",{className:"djvu-placeholder",children:E.has(t)?"decoding…":""})},n)})]}),q]})}export{ve as DjvuView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as g,b as H,u as W,a as q,r as a,D as z,f as K,e as V,c as X,i as Y,k as _}from"./index-DGta_4EZ.js";import{L as d,w as Q,O as ee}from"./openable-BA6YbLif.js";const y=t=>Number(t)||0,B=t=>t.replace(/[&<>"]/g,o=>({"&":"&","<":"<",">":">",'"':"""})[o]);function te(t){return t.map(o=>{const s=Y({name:o.label,color:o.color});return _(o.path)?`<span class="tagswatch" style="--tag:${s}" title="${B(o.label)}"></span>`:`<span class="tagtag" style="--tag:${s}">${B(o.label)}</span>`}).join("")}function ne(t,o,s,n,c){if(!t||n<=0||c<=0)return;const r=document.createElement("canvas");r.width=n,r.height=c;const p=r.getContext("2d");if(p){p.drawImage(t,o,s,n,c,0,0,n,c);try{return r.toDataURL("image/png")}catch{return}}}function oe(t,o){const s=new Map;for(const n of t){if(n.selector?.type!=="rect")continue;const c=JSON.stringify(n.selector);let r=s.get(c);r||(r={x:y(n.selector.x),y:y(n.selector.y),w:y(n.selector.w),h:y(n.selector.h),title:n.description,color:X(n),ann:V(n)?n:void 0,id:n.fragmentSlug?K(o,n.fragmentSlug):void 0,tags:[]},s.set(c,r)),n.tag&&r.tags.push({path:n.tag.path,label:n.tag.name,color:n.tag.color})}return[...s.values()]}function re({src:t,className:o,regions:s,onSelectRegion:n,onRegionClick:c,selectColor:r}){const p=a.useRef(null),w=a.useRef(null),f=a.useRef(null),b=a.useRef(null),v=a.useRef({w:1,h:1}),j=a.useRef(n),C=a.useRef(c),N=a.useRef(r),[O,k]=a.useState(null),[I,P]=a.useState(0),T=JSON.stringify(s??[]),L=!!n;a.useEffect(()=>{j.current=n,C.current=c,N.current=r}),a.useEffect(()=>{let l=!1,h=null;k(null);const e=new Image;return e.onload=()=>{if(l||!p.current)return;const m=e.naturalWidth||1,R=e.naturalHeight||1;v.current={w:m,h:R},b.current=e;const i=d.map(p.current,{crs:d.CRS.Simple,minZoom:-8,attributionControl:!1,zoomSnap:0}),x=[[0,0],[R,m]];d.imageOverlay(t,x).addTo(i),i.fitBounds(x),f.current=d.layerGroup().addTo(i),w.current=i,h=Q(i,{color:()=>N.current?.()??z,onSelect:L?(u,E)=>{const{h:F}=v.current,M=u.getWest(),G=u.getEast(),J=u.getSouth(),A=u.getNorth(),D=Math.round(M),U=Math.round(F-A),Z=Math.round(G-M),$=Math.round(A-J);j.current?.({type:"rect",x:D,y:U,w:Z,h:$},E,ne(b.current,D,U,Z,$))}:void 0}),P(u=>u+1)},e.onerror=()=>{l||k("could not load image")},e.src=t,()=>{l=!0,h?.(),w.current?.remove(),w.current=null,f.current=null}},[t]);const S=a.useRef(new Map);return a.useEffect(()=>{const l=f.current;if(!l)return;l.clearLayers(),S.current.clear();const{h}=v.current;for(const e of s??[]){const m=e.color||z,R=[[h-e.y,e.x],[h-(e.y+e.h),e.x+e.w]],i=d.rectangle(R,{className:"yo-region",color:m,weight:3,fillColor:m,fillOpacity:.25});if(e.title&&i.bindTooltip(e.title),e.ann){const x=e.ann,u=E=>{d.DomEvent.stop(E),C.current?.(x,{x:E.originalEvent.clientX,y:E.originalEvent.clientY})};i.on("click",u),i.on("contextmenu",u)}if(i.addTo(l),e.tags&&e.tags.length){const x=d.latLng(h-(e.y+e.h),e.x),u=d.divIcon({className:"yo-region-tags",html:te(e.tags),iconAnchor:[0,0]});d.marker(x,{icon:u,interactive:!1,keyboard:!1}).addTo(l)}e.id&&S.current.set(e.id,{rect:i,bounds:R})}},[T,I]),a.useEffect(()=>{const l=()=>{const h=w.current,e=decodeURIComponent(window.location.hash.slice(1)),m=e?S.current.get(e):void 0;!h||!m||(h.fitBounds(m.bounds,{maxZoom:h.getZoom(),padding:[40,40]}),m.rect.setStyle({weight:6,fillOpacity:.45}),window.setTimeout(()=>m.rect.setStyle({weight:3,fillOpacity:.25}),1e3))};return l(),window.addEventListener("hashchange",l),()=>window.removeEventListener("hashchange",l)},[T,I]),g.jsxs(g.Fragment,{children:[O&&g.jsxs("div",{className:"error",children:["image: ",O]}),g.jsx("div",{ref:p,className:o+(L?" yo-selectable":"")})]})}function le({node:t}){const o=W(t.path),{openCreate:s,openEdit:n,palette:c,preview:r,color:p}=q(o,t.path),w=oe(o.annotations,t.path);if(r?.selector.type==="rect"){const f=r.selector;w.push({x:y(f.x),y:y(f.y),w:y(f.w),h:y(f.h),color:r.color})}return g.jsxs("div",{className:"text",children:[t.title&&g.jsx("h1",{className:"chapter-title",children:t.title}),t.description&&g.jsx("p",{className:"chapter-subtitle",children:t.description}),g.jsx(re,{src:H(t.path),regions:w,onSelectRegion:(f,b,v)=>s(f,b,void 0,v),onRegionClick:n,selectColor:()=>p,className:"filemap fileimagemap"}),c]})}function se({src:t,path:o,onNavigate:s}){return g.jsx(ee,{path:o,onNavigate:s,title:"Open image on its own page",children:g.jsx("img",{className:"chunk-image",src:t,alt:"",loading:"lazy"})})}function ie({chunk:t,onNavigate:o}){return g.jsx(se,{src:H(t.path),path:t.path,onNavigate:o})}export{ie as ImageChunk,le as ImageView,re as PanZoomImage,se as StaticImageChunk};
|