@lemoncat7/dsh-knowledge 2.0.0 → 2.1.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.
@@ -0,0 +1,16 @@
1
+ "use strict";(()=>{var M="http://www.w3.org/2000/svg",k=[".sidebar",".topbar",".note-tree-panel",".notes-browser",".notes-content-header",".notes-document-toolbar",".note-editor-toolbar",".dialog"].join(","),x=[".login-card",".panel",".mount-table",".note-workspace",".notes-workspace",".dialog"].join(","),A=[".button",".nav-button",".tab",".pane-toggle-button",".note-tree-base",".note-tree-document",".note-tree-new",".notes-tree-row",".notes-search-row",".notes-file-main"].join(","),G=[".note-tree",".notes-tree",".base-grid",".mount-table"].join(","),R="[data-knowledge-motion-key]",T=700,C=38,m=new Map,v=new Map,u=new Map,p=new Map,F=0,d,$=window.matchMedia("(prefers-reduced-motion: reduce)"),O=window.matchMedia("(prefers-reduced-transparency: reduce)");function h(e,t){let n=Array.from(e.querySelectorAll(t));return e instanceof HTMLElement&&e.matches(t)&&n.unshift(e),n}function H(){return d?.isConnected||(d=document.createElementNS(M,"svg"),d.classList.add("knowledge-glass-filter-bank"),d.setAttribute("aria-hidden","true"),d.setAttribute("focusable","false"),document.body.append(d)),d}function b(e,t){let n=document.createElementNS(M,e);for(let[o,r]of Object.entries(t))n.setAttribute(o,r);return n}function P(e){let t=b("filter",{id:e,x:"0%",y:"0%",width:"100%",height:"100%","color-interpolation-filters":"sRGB"}),n=b("feImage",{x:"0",y:"0",width:"100%",height:"100%",preserveAspectRatio:"none",result:"map"});return t.append(n,b("feGaussianBlur",{in:"SourceGraphic",stdDeviation:"6",result:"frosted"})),t.append(b("feDisplacementMap",{in:"frosted",in2:"map",scale:"-16",xChannelSelector:"R",yChannelSelector:"G",result:"refracted"}),b("feGaussianBlur",{in:"refracted",stdDeviation:".12"})),{filter:t,image:n}}function N(){if(O.matches)return!1;let e=navigator.userAgent;return/Firefox/i.test(e)||/Safari/i.test(e)&&!/(Chrome|Chromium|CriOS)/i.test(e)?!1:CSS.supports?.("backdrop-filter","url(#knowledge-glass-support)")||CSS.supports?.("-webkit-backdrop-filter","url(#knowledge-glass-support)")||!1}function _(e,t,n){let o=Number.parseFloat(getComputedStyle(e).borderTopLeftRadius);return Number.isFinite(o)?Math.max(0,Math.min(o,Math.min(t,n)/2)):Math.min(t,n)*.16}function I(e,t,n){let o=Math.min(12,Math.max(4,Math.min(e,t)*.08)),r=`<svg viewBox="0 0 ${e} ${t}" xmlns="${M}">
2
+ <defs>
3
+ <clipPath id="shape"><rect width="${e}" height="${t}" rx="${n}"/></clipPath>
4
+ <linearGradient id="left" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="rgb(92 128 128)"/><stop offset="100%" stop-color="rgb(128 128 128)"/></linearGradient>
5
+ <linearGradient id="right" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="rgb(128 128 128)"/><stop offset="100%" stop-color="rgb(164 128 128)"/></linearGradient>
6
+ <linearGradient id="top" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" stop-color="rgb(128 92 128)"/><stop offset="100%" stop-color="rgb(128 128 128)"/></linearGradient>
7
+ <linearGradient id="bottom" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" stop-color="rgb(128 128 128)"/><stop offset="100%" stop-color="rgb(128 164 128)"/></linearGradient>
8
+ </defs>
9
+ <g clip-path="url(#shape)">
10
+ <rect width="${e}" height="${t}" fill="rgb(128 128 128)"/>
11
+ <rect width="${o}" height="${t}" fill="url(#left)"/>
12
+ <rect x="${e-o}" width="${o}" height="${t}" fill="url(#right)"/>
13
+ <rect width="${e}" height="${o}" fill="url(#top)"/>
14
+ <rect y="${t-o}" width="${e}" height="${o}" fill="url(#bottom)"/>
15
+ </g>
16
+ </svg>`;return`data:image/svg+xml,${encodeURIComponent(r)}`}function B(e){if(m.has(e))return;if(e.classList.add("knowledge-glass-surface"),!N()){e.dataset.knowledgeGlass="fallback",m.set(e,{filter:void 0,observer:void 0,frame:0});return}let t=`knowledge-glass-filter-${++F}`,{filter:n,image:o}=P(t);H().append(n),e.dataset.knowledgeGlass="svg",e.style.setProperty("--knowledge-glass-filter",`url(#${t})`);let r={filter:n,observer:void 0,frame:0},c=()=>{if(r.frame=0,!e.isConnected)return;let a=e.getBoundingClientRect(),l=Math.max(1,Math.round(a.width)),i=Math.max(1,Math.round(a.height));o.setAttribute("href",I(l,i,_(e,l,i)))},s=()=>{r.frame===0&&(r.frame=requestAnimationFrame(c))};r.observer=typeof ResizeObserver>"u"?void 0:new ResizeObserver(s),r.observer?.observe(e),r.frame=requestAnimationFrame(c),m.set(e,r)}function D(e){if(v.has(e))return;e.classList.add("knowledge-border-surface");let t=0,n,o=()=>{if(t=0,n===void 0||!e.isConnected)return;let s=e.getBoundingClientRect(),a=Math.min(s.width,Math.max(0,n.x-s.left)),l=Math.min(s.height,Math.max(0,n.y-s.top)),i=Math.min(a,s.width-a,l,s.height-l),w=Math.min(1,Math.max(0,1-i/C)),E=Math.atan2(l-s.height/2,a-s.width/2)*(180/Math.PI)+90;e.style.setProperty("--knowledge-border-proximity",w.toFixed(3)),e.style.setProperty("--knowledge-border-angle",`${E.toFixed(2)}deg`)},r=s=>{n={x:s.clientX,y:s.clientY},t===0&&(t=requestAnimationFrame(o))},c=()=>{n=void 0,e.style.setProperty("--knowledge-border-proximity","0")};e.addEventListener("pointermove",r,{passive:!0}),e.addEventListener("pointerleave",c,{passive:!0}),v.set(e,()=>{t!==0&&cancelAnimationFrame(t),e.removeEventListener("pointermove",r),e.removeEventListener("pointerleave",c)})}function V(e,t){let n=e.dataset.knowledgeMotionKey;if(n===void 0)return!1;let o=p.get(n);return o!==void 0&&t-o<T}function q(e,t){let n=e.dataset.knowledgeMotionKey;if(n===void 0||(p.set(n,t),p.size<=4e3))return;let o=p.keys().next().value;o!==void 0&&p.delete(o)}function S(e){let t=e.scrollHeight-e.clientHeight-e.scrollTop;e.dataset.scrollTop=String(e.scrollTop<=2),e.dataset.scrollBottom=String(t<=2)}function K(e){if(u.has(e))return;let t=e.matches(".base-grid");e.classList.add("knowledge-animated-list"),e.dataset.knowledgeListLayout=t?"grid":"scroll",S(e);let n=()=>S(e);e.addEventListener("scroll",n,{passive:!0});let o=Array.from(e.querySelectorAll(R));if($.matches||typeof IntersectionObserver>"u"){for(let i of o)i.classList.add("knowledge-list-reveal","is-visible");u.set(e,()=>e.removeEventListener("scroll",n));return}let r=e.scrollHeight-e.clientHeight>2?e:null,c=new IntersectionObserver(i=>{let w=i.filter(f=>f.isIntersecting).sort((f,g)=>f.boundingClientRect.top-g.boundingClientRect.top),E=performance.now();w.forEach((f,g)=>{let y=f.target,L=t?52:38;y.style.setProperty("--knowledge-list-delay",`${Math.min(g,7)*L}ms`),y.classList.add("is-visible"),q(y,E)});for(let f of i){if(f.isIntersecting)continue;let g=f.target;g.classList.remove("is-visible"),g.style.setProperty("--knowledge-list-delay","0ms")}},{root:r,threshold:.12,rootMargin:"-4px 0px"}),s=performance.now();for(let i of o)i.classList.add("knowledge-list-reveal"),!t&&V(i,s)&&i.classList.add("is-visible");let a=0,l=0;a=requestAnimationFrame(()=>{a=0,l=requestAnimationFrame(()=>{l=0;for(let i of o)c.observe(i)})}),u.set(e,()=>{a!==0&&cancelAnimationFrame(a),l!==0&&cancelAnimationFrame(l),c.disconnect(),e.removeEventListener("scroll",n)})}function j(){for(let[e,t]of m)e.isConnected||(t.frame!==0&&cancelAnimationFrame(t.frame),t.observer?.disconnect(),t.filter?.remove(),m.delete(e));for(let[e,t]of v)e.isConnected||(t(),v.delete(e));for(let[e,t]of u)e.isConnected||(t(),u.delete(e))}function U(e=document){j();for(let t of h(e,k))B(t);for(let t of h(e,x))D(t);for(let t of h(e,A))t.classList.add("knowledge-glare-surface");for(let t of h(e,G))K(t)}function W(){for(let[e,t]of m)t.frame!==0&&cancelAnimationFrame(t.frame),t.observer?.disconnect(),t.filter?.remove(),e.classList.remove("knowledge-glass-surface"),e.removeAttribute("data-knowledge-glass"),e.style.removeProperty("--knowledge-glass-filter");for(let[e,t]of v)t(),e.classList.remove("knowledge-border-surface");for(let[e,t]of u)t(),e.classList.remove("knowledge-animated-list");m.clear(),v.clear(),u.clear(),p.clear(),d?.remove(),d=void 0}window.DshKnowledgeEffects?.destroy();window.DshKnowledgeEffects={refresh:U,destroy:W};})();