@preventive/triage 1.0.0-alpha.42 → 1.0.0-alpha.44
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/common/bundle-compare-diff.js +2 -167
- package/common/bundle-compare-versions.js +172 -0
- package/common/bundle-comparison.d.ts +8 -0
- package/common/bundle-comparison.js +62 -0
- package/common/managed/report-filter.ts +2 -1
- package/common/managed/routes.js +3 -3
- package/common/security-links.d.ts +5 -0
- package/common/security-links.js +33 -0
- package/common/server-info.ts +8 -0
- package/common/workspace-app.js +14 -1
- package/out/chunk-2ABLKCOY.js +46 -0
- package/out/chunk-5LSXOLUS.js +1 -0
- package/out/chunk-5RCM2J63.js +1 -0
- package/out/chunk-7B6HB4D7.js +1 -0
- package/out/{chunk-4F6JSF57.js → chunk-AJ4GTATZ.js} +1 -1
- package/out/chunk-CH4UN6WK.js +225 -0
- package/out/chunk-EDKLBQQN.js +17 -0
- package/out/{chunk-UXNUAIIC.js → chunk-F47DXCEV.js} +1 -1
- package/out/chunk-FK3DZEKL.js +1 -0
- package/out/chunk-G6AJWENO.js +1 -0
- package/out/chunk-GZWM7UQM.js +2 -0
- package/out/chunk-JCIIBLKR.js +1 -0
- package/out/chunk-LPCTJYNA.js +7 -0
- package/out/{chunk-DGVQPIYB.js → chunk-O4RJY5TP.js} +1 -1
- package/out/chunk-OD4LPN3H.js +1 -0
- package/out/{chunk-D7AF2JXL.js → chunk-QWDWTBM7.js} +1 -1
- package/out/chunk-QYWKC557.js +1 -0
- package/out/chunk-R75XOKUP.js +1 -0
- package/out/{chunk-RSHMVYNS.js → chunk-SWTLADW5.js} +1 -1
- package/out/chunk-T7OKH4VW.js +1 -0
- package/out/{chunk-ZMQQCGF6.js → chunk-UTR2LVME.js} +1 -1
- package/out/chunk-ZESLQCTF.js +6 -0
- package/out/client-managed-import.js +1 -1
- package/out/client-managed.js +21 -21
- package/out/client-sync.js +1 -1
- package/out/graph.js +1 -1
- package/out/index.html +14 -10
- package/out/terminal.js +1 -1
- package/out/view.css +1 -1
- package/out/view.js +58 -58
- package/package.json +13 -3
- package/risk/index.d.ts +26 -0
- package/risk/index.js +1 -1
- package/risk/npm/assess.js +66 -15
- package/risk/npm/dependencies.js +22 -3
- package/risk/npm/new-dependency.js +42 -12
- package/risk/npm/registry.js +122 -21
- package/server-managed/comparison.ts +41 -0
- package/server-managed/http.ts +161 -56
- package/server-managed/locked-packages.ts +29 -6
- package/server-managed/npm-kept.ts +38 -14
- package/server-managed/npm-packages.ts +27 -13
- package/server-managed/npm-risk.ts +69 -11
- package/server-managed/pretty-print.ts +14 -9
- package/server-managed/public-workspace.ts +26 -8
- package/server-managed/queue.ts +23 -0
- package/server-managed/report-sources.ts +1 -1
- package/server-managed/repository-risk-assess.ts +105 -0
- package/server-managed/repository-risk-audit.ts +66 -0
- package/server-managed/repository-risk.ts +265 -209
- package/server-managed/scan-downloads.ts +87 -0
- package/server-managed/sql.ts +1 -1
- package/server-managed/team-app.ts +38 -14
- package/server-managed/team-reports.ts +6 -11
- package/server-managed/upstream-cache.ts +16 -0
- package/out/chunk-CLPKNNC7.js +0 -51
- package/out/chunk-Q7ZSIEHP.js +0 -1
- package/out/chunk-RFZQQXSG.js +0 -17
- package/out/chunk-VQJCXGIY.js +0 -7
- package/out/chunk-WOTMRDM3.js +0 -226
- package/out/chunk-WZDTZE64.js +0 -1
- package/out/chunk-YP2537WX.js +0 -1
- package/out/chunk-YQRVLRDH.js +0 -1
- package/out/chunk-YVZH5SHP.js +0 -1
- package/out/chunk-ZBBOBQ43.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ke}from"./chunk-FK3DZEKL.js";import{c as G,d as Q,e as xe,h as ee,i as Se,j as te,m as ne,n as Oe,o as se}from"./chunk-GZWM7UQM.js";import{a as q,c as Y}from"./chunk-JCIIBLKR.js";import{n as be}from"./chunk-EDKLBQQN.js";import{k as we,o as X,p as J,t as V}from"./chunk-ZESLQCTF.js";import{a as Z}from"./chunk-OD4LPN3H.js";import"./chunk-3BZ7JERB.js";import"./chunk-GNXOKIGP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function oe(e){if(typeof e!="string")throw new TypeError(`a text must be a string, not ${typeof e}`);if(!e.isWellFormed())throw new TypeError("a text must be a well-formed string");return{proven:!1,reason:"unsupported",at:null}}var We=e=>e.subarray(0,8e3).includes(0),Me=(e,t)=>(e+Math.imul(t,97)>>>0)%107927,Be=e=>Uint8Array.from({length:256},(t,s)=>Number(s===10||e.includes(String.fromCodePoint(s)))),Xe=Be(""),Ae=Be(",;={}");function re(e,t=Xe){let s=!We(e),n=new Map,o=(f,l)=>n.set(f,(n.get(f)??0)+l),i=0,a=0,r=0;for(let f=0;f<e.length;f++){let l=e[f];if(s&&l===13&&e[f+1]===10)continue;let u=i;i=(i<<7^a>>>25)+l>>>0,a=(a<<7^u>>>25)>>>0,!(++r<64&&t[l]===0)&&(o(Me(i,a),r),r=0,i=0,a=0)}r>0&&o(Me(i,a),r);let c=Uint32Array.from(n.keys()).sort();return{hashes:c,bytes:Float64Array.from(c,f=>n.get(f)),total:n.values().reduce((f,l)=>f+l,0)}}function Je(e,t){let s=0;for(let n=0,o=0;n<e.hashes.length&&o<t.hashes.length;)e.hashes[n]<t.hashes[o]?n++:e.hashes[n]>t.hashes[o]?o++:s+=Math.min(e.bytes[n++],t.bytes[o++]);return s}function Ve(e,t,s){let n=0,o=e.total,i=t.total;for(let a=0,r=0;a<e.hashes.length&&r<t.hashes.length;)if(e.hashes[a]<t.hashes[r]?o-=e.bytes[a++]:(e.hashes[a]>t.hashes[r]||(n+=Math.min(e.bytes[a],t.bytes[r]),o-=e.bytes[a++]),i-=t.bytes[r++]),(n+Math.min(o,i))*6e4<s)return 0;return n}function ie(e,t,s,n,o=!1){if(e===null||t===null||t.length===0)return 0;let i=Math.abs(e.length-t.length),a=Math.max(e.length,t.length);if(a*(6e4-s)<i*6e4)return 0;let r=n(e),c=n(t),f=o?Ve(r,c,s*a):Je(r,c);return Math.trunc(f*6e4/a)}var $e=/^[\w-]{6,}$/u,ae=/[\dA-Z]/u;var Ze=/^(?:\.[\w-]+)+$/u,qe=/^[\w-]{8,32}$/u;function Ee(e){let t=[];for(let s=e.length-1;s>0;s--){if(e[s]!=="-"&&e[s]!==".")continue;let n=e.indexOf(".",s+1),o=e.slice(n),i=e.slice(s+1,n);n!==-1&&qe.test(i)&&Ze.test(o)&&/[A-Za-z]/u.test(i)&&ae.test(i)&&t.push([e.slice(0,s),i,o])}return t}var Te=e=>e.replaceAll(/\d/gu,"0").replaceAll(/[a-z]/gu,"a").replaceAll(/[A-Z]/gu,"A");function Ye(e,t){let s=Ee(t);for(let[n,o,i]of Ee(e)){let a=s.find(r=>r[2]===i);if(a&&a[1]!==o)return a[0]===n&&Te(a[1])!==Te(o)}return!1}function Ge(e){let t=e.lastIndexOf("/"),s=e.slice(t+1),n=s.lastIndexOf("."),o=n>0?s.slice(n):"";return{name:s,key:`${e.slice(0,t+1)}\0${o}\0${s.length}`}}function Qe(e,t){let s=e.length,n=0;for(;n<e.length&&e[n]===t[n];)n++;for(;s>n&&e[s-1]===t[s-1];)s--;for(;n>0&&!"-._".includes(e[n-1]);)n--;for(;s<e.length&&e[s]!==".";)s++;let o=e.slice(n,s),i=t.slice(n,s);return n>0&&$e.test(o)&&$e.test(i)&&(ae.test(o)||ae.test(i))}function Ce({sources:e,dests:t,pairs:s,used:n,record:o,punctuatedScoreOf:i},{remaining:a,open:r},c,f){let l=(w,$)=>new Map($.filter(A=>w[A].type==="file").map(A=>[A,Ge(w[A].path)])),u=l(t,r),p=l(e,a),h=Map.groupBy(p.keys(),w=>p.get(w).key),b=Map.groupBy(u.keys(),w=>u.get(w).key),m=[];for(let[w,$]of b){let A=h.get(w)??[];for(let C of $)for(let D of A)Qe(p.get(D).name,u.get(C).name)&&m.push({s:D,d:C})}let y=Map.groupBy(m,({d:w})=>w),d=Map.groupBy(m,({s:w})=>w),x=[];for(let{s:w,d:$}of m){let A=d.get(w).length===1&&y.get($).length===1&&Ye(p.get(w).name,u.get($).name),C=i(w,$,A?0:c);(A||C>=c)&&x.push({s:w,d:$,score:C})}let S=[],O=new Set,N=new Set;for(let w of x.sort(($,A)=>A.score-$.score))s.has(w.d)||n.has(w.s)||(N.has(w.s)||O.has(w.d)||f(w)?(S.push(w),N.add(w.s),O.add(w.d)):o(w.d,w.s,w.score));return S}function Fe(e,t){let s=e.length;if(s!==t.length)return!1;let n=0;if(s>=32&&(e.byteOffset&3)===(t.byteOffset&3)){for(let r=4-(e.byteOffset&3)&3;n<r;n++)if(e[n]!==t[n])return!1;let o=s-n>>>2,i=new Int32Array(e.buffer,e.byteOffset+n,o),a=new Int32Array(t.buffer,t.byteOffset+n,o);for(let r=0;r<o;r++)if(i[r]!==a[r])return!1;n+=o*4}for(;n<s;n++)if(e[n]!==t[n])return!1;return!0}var T=class extends Error{constructor(t,s,n){let o=n===void 0?"":` in the ${n} tree`;super(s===void 0?t:`${t}: ${JSON.stringify(s)}${o}`),this.name="CompareError",this.path=s,this.tree=n}};var et=new Set(["file","contiguous-file"]),tt=new Set(["fifo","character-device","block-device"]),nt=/(?:^|\/)\.{0,2}(?:\/|$)/u;function st(e){if(!Number.isInteger(e)||e<0||e>4095)throw new RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`)}function ot(e,t,s,n){if(typeof e!="string")throw new TypeError(`an entry's name must be a string, not ${typeof e}`);if(!(e==="."&&t==="directory")){if(n?e==="":nt.test(e))throw new T(n?"a name must not be empty":"a name must be a relative path with no empty, `.` or `..` segment",e,s);if(!e.isWellFormed())throw new T("a name must be well-formed Unicode",e,s)}}function rt(e,t,s){if(typeof e!="string"||e==="")throw new T("a link must name its target",t,s);if(!e.isWellFormed())throw new T("a link target must be well-formed Unicode",t,s);return e}function it(e){if(e===void 0)return new Uint8Array(0);if(e instanceof Uint8Array)return e;if(typeof e!="string")throw new TypeError(`a file's data must be a string or a Uint8Array, not ${typeof e}`);if(!e.isWellFormed())throw new TypeError("a file's text must be well-formed Unicode");return e}var K=e=>typeof e=="string"?be(e):e;function at(e,t,s){if(typeof e!="object"||e===null)throw new TypeError(`an entry must be an object, not ${e===null?"null":typeof e}`);let{name:n,type:o="file",mode:i,linkname:a,data:r}=e;if(ot(n,o,t,s),i!==void 0&&st(i),et.has(o))return{path:n,type:"file",mode:i??420,data:it(r)};if(o==="symlink"||o==="hardlink")return{path:n,type:o,target:rt(a,n,t)};if(o==="directory")return{path:n,type:o};throw tt.has(o)?new T(`a ${o} is neither a file nor a link`,n,t):new TypeError(`${JSON.stringify(o)} is not an entry type`)}function U(e,t){return e.type!==t.type?!1:e.type==="symlink"?e.target===t.target:e.data===t.data?!0:typeof e.data=="string"&&typeof t.data=="string"?!1:Fe(K(e.data),K(t.data))}function ct(e,t,s){let n=new Set([e.path]),o=t.get(e.target);for(;o?.type==="hardlink";){if(n.has(o.path))throw new T("a hard link leads back to itself",e.path,s);n.add(o.path),o=t.get(o.target)}if(o===void 0||o.type==="directory")throw new T("a hard link must name a file or a link in the tree",e.path,s);return{...o,path:e.path}}function ce(e,t,s){let n=new Map;for(let i of e){let a=at(i,t,s);if(!(a.type==="directory"&&a.path===".")){if(n.has(a.path))throw new T("a name is given twice",a.path,t);n.set(a.path,a)}}let o=new Map;for(let[i,a]of n){for(let r=s?-1:i.lastIndexOf("/");r>0;r=i.lastIndexOf("/",r-1)){let c=n.get(i.slice(0,r));if(c!==void 0&&c.type!=="directory")throw new T(`a path lies under a ${c.type==="symlink"?"link":"file"}`,i,t)}a.type==="hardlink"?o.set(i,ct(a,n,t)):a.type!=="directory"&&o.set(i,a)}return o}var lt=100,ft=4,Re=e=>e.slice(e.lastIndexOf("/")+1);function Ne(e,t){if(e.type==="symlink")return`l${e.target}`;let s=t(e);return`f${s.length}:${ke(s)}`}function ut({sources:e,dests:t,sourceNames:s,destNames:n,used:o,record:i,bytes:a}){let r=Map.groupBy(e.keys(),c=>Ne(e[c],a));for(let c=0;c<t.length;c++){let f=-1,l=lt;for(let u of r.get(Ne(t[c],a))??[])if(!(o.has(u)||!U(e[u],t[c]))&&((f===-1||s[u]===n[c])&&(f=u),s[u]===n[c]||--l===0))break;f!==-1&&i(c,f,6e4)}}var pt=new Map([[".ts",".js"],[".mts",".mjs"],[".cts",".cjs"],[".tsx",".jsx"]]),ht=new Map([...[".js",".mjs",".cjs",".jsx",".ts",".mts",".cts",".tsx"].map(e=>[e,"script"]),...[".css",".scss",".sass",".less"].map(e=>[e,"style"])]);function De(e){let t=e.split("/"),s=t.pop(),n=s.lastIndexOf(".");return n>0?{dirs:t,stem:s.slice(0,n),extension:s.slice(n)}:{dirs:t,stem:s,extension:""}}function Ie(e){let{dirs:t,stem:s,extension:n}=De(e);return JSON.stringify([t.map(o=>o==="lib"||o==="src"?null:o),s,pt.get(n)??n])}function dt(e){let{dirs:t,stem:s,extension:n}=De(e),o=[s,ht.get(n)??n],i=t.lastIndexOf("node_modules"),a=i===-1?0:i+(t[i+1]?.startsWith("@")?3:2),r=[JSON.stringify([...o,t])];for(let c=a;c<t.length;c++)r.push(JSON.stringify([...o,t.toSpliced(c,1,null)]));return r}var Le=(e,t)=>Math.max(t,e+Math.trunc((6e4-e)/2));function fe({pairs:e,used:t,scoreOf:s},{remaining:n,open:o},{s:i,d:a,score:r},c){let f=Le(r,c);return o.some(l=>l!==a&&!e.has(l)&&s(i,l,f)>=f)||n.some(l=>l!==i&&!t.has(l)&&s(l,a,f)>=f)}function yt(e,t,s,n){let{sources:o,dests:i,pairs:a,used:r,record:c,scoreOf:f}=e,l=Map.groupBy(t.remaining.filter(p=>o[p].type==="file"),p=>Ie(o[p].path)),u=t.open.filter(p=>i[p].type==="file").flatMap(p=>(l.get(Ie(i[p].path))??[]).map(h=>({s:h,d:p,score:f(h,p,0)})));for(let p of u.sort((h,b)=>b.score-h.score))!a.has(p.d)&&!r.has(p.s)&&!(s&&fe(e,t,p,n))&&c(p.d,p.s,p.score)}function mt(e,t,s,n){let{sources:o,dests:i,pairs:a,used:r,record:c,scoreOf:f}=e,l=new Map,u=(m,y,d)=>new Map(y.filter(x=>m[x].type==="file").map(x=>{let S=dt(m[x].path);for(let O of S)(l.get(O)??l.set(O,{sources:[],dests:[]}).get(O))[d].push(x);return[x,S]})),p=u(i,t.open.filter(m=>!a.has(m)),"dests"),h=u(o,t.remaining.filter(m=>!r.has(m)),"sources"),b=(m,y)=>{let d=new Set(m.flatMap(x=>l.get(x)[y]));return d.size===1?[...d][0]:-1};for(let[m,y]of h){let d=b(y,"dests");if(d===-1||b(p.get(d),"sources")!==m)continue;let x={s:m,d,score:f(m,d,0)};s&&fe(e,t,x,n)||c(d,m,x.score)}}function gt(e,t,s){let n=H(e),o=t<6e4&&n.remaining.length*n.open.length<=s*s;yt(e,n,o,t),mt(e,n,o,t)}function ve(e,t){let s=new Map;for(let n of t)s.set(e[n],s.has(e[n])?-1:n);return s}function wt({sourceNames:e,destNames:t,record:s,scoreOf:n},{remaining:o,open:i},a){let r=ve(t,i),c=ve(e,o);for(let f of o){let l=r.get(e[f]);if(l===void 0||l===-1||c.get(e[f])===-1)continue;let u=n(f,l,a);u>=a&&s(l,f,u)}}var le=(e,t)=>t.score-e.score||t.nameScore-e.nameScore;function bt(e,t){if(e.length<ft){e.push(t);return}let s=0;for(let n=1;n<e.length;n++)le(e[n],e[s])>0&&(s=n);le(e[s],t)>0&&(e[s]=t)}function kt({sourceNames:e,destNames:t,pairs:s,used:n,record:o,scoreOf:i},{remaining:a,open:r},c,f){let l=[];for(let h of r){let b=[];for(let m of a)bt(b,{score:i(m,h,c),nameScore:e[m]===t[h]?1:0,dst:h,src:m});l.push(...b)}let u=0,p=h=>{for(;u<f.length&&Le(f[u].score,c)>h;u++){let{s:b,d:m,score:y}=f[u];!s.has(m)&&!n.has(b)&&o(m,b,y)}};for(let{dst:h,src:b,score:m}of l.sort(le)){if(m<c)break;p(m),!s.has(h)&&!n.has(b)&&o(h,b,m)}p(-1/0)}var H=({sources:e,dests:t,pairs:s,used:n})=>({remaining:e.keys().filter(o=>!n.has(o)).toArray(),open:t.keys().filter(o=>!s.has(o)).toArray()}),Pe=e=>e+Math.trunc(.5*(6e4-e));function ue(e,t,{minimum:s,limit:n,byPath:o}){let i=new Map,a=new Set;if(e.length===0||t.length===0)return i;let r=new Map,c=new Map,f=new Map,l=y=>y.type==="file"?c.get(y)??c.set(y,K(y.data)).get(y):null,u=y=>r.get(y)??r.set(y,re(y)).get(y),p=y=>f.get(y)??f.set(y,re(y,Ae)).get(y),h={sources:e,dests:t,pairs:i,used:a,sourceNames:e.map(y=>Re(y.path)),destNames:t.map(y=>Re(y.path)),record(y,d,x){i.set(y,{source:d,score:x}),a.add(d)},bytes:l,scoreOf:(y,d,x)=>ie(l(e[y]),l(t[d]),x,u),punctuatedScoreOf:(y,d,x)=>ie(l(e[y]),l(t[d]),x,p,!0)};if(ut(h),o&>(h,s,n),s>=6e4)return i;wt(h,H(h),Pe(s));let b=H(h);if(b.remaining.length*b.open.length>n*n)return i;let m=o?Ce(h,b,Pe(s),y=>fe(h,b,y,s)):[];return kt(h,H(h),s,m),i}var xt=50,St=1e3;function pe(e,t){let s=Math.min(e.length,t.length);for(let n=0;n<s;n++)if(e[n]!==t[n])return e.codePointAt(n)-t.codePointAt(n);return e.length-t.length}function Ot(e){if(e===!1)return null;let t=e===!0?xt:e;if(typeof t!="number")throw new TypeError(`renames must be a boolean or a percentage, not ${typeof e}`);if(!(t>0&&t<=100))throw new RangeError(`renames must be a percentage above 0 and at most 100, not ${e}`);return Math.max(1,Math.trunc(6e4*t/100))}function Mt({renamesByPath:e,renameLimit:t,renameGroup:s,paths:n,lines:o}){if(typeof e!="boolean")throw new TypeError(`renamesByPath must be a boolean, not ${typeof e}`);if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw new RangeError(`renameLimit must be a whole number or Infinity, not ${t}`);if(s!==null&&typeof s!="function")throw new TypeError(`renameGroup must be a function, not ${typeof s}`);if(n!=="tree"&&n!=="keys")throw new RangeError(`paths must be 'tree' or 'keys', not ${n}`);if(typeof o!="boolean")throw new TypeError(`lines must be a boolean, not ${typeof o}`)}var Bt=(e,t)=>U(e,t)&&(e.type!=="file"||e.mode===t.mode),_=(e,t,s,n=null)=>({status:e,old:t,new:s,similarity:n}),At=/\.d\.(?:[^./]+\.)?[cm]?ts$/u,Ue=e=>e.endsWith(".mts")?"module":e.endsWith(".cts")?"commonjs":null,$t=/^export\s*\{\s*\}\s*;?$/u;function _e(e){if(e===null)return{proven:!0,runtime:"",loads:!1};let t=G(e);try{return t===void 0?{proven:!1}:oe(t)}catch{return{proven:!1}}}function Et(e){if(![e.old,e.new].filter(o=>o!==null).every(o=>o.type==="file"&&At.test(o.path))||e.old&&e.new&&e.old.mode!==e.new.mode)return e;let s=_e(e.new),n=_e(e.old);return!n.proven||!s.proven||n.runtime!==s.runtime&&!(e.old===null&&$t.test(s.runtime))||n.loads&&e.old&&e.new&&e.old.path!==e.new.path&&Ue(e.old.path)!==Ue(e.new.path)?e:{...e,typeOnly:!0}}function Tt(e,t){let s=[],n=[],o=[];for(let[i,a]of e){let r=t.get(i);r===void 0?o.push(a):r.type!==a.type?n.push(_("type-changed",a,r)):Bt(a,r)||n.push(_("modified",a,r))}for(let[i,a]of t)e.has(i)||s.push(a);return o.sort((i,a)=>pe(i.path,a.path)),s.sort((i,a)=>pe(i.path,a.path)),{changes:n,deleted:o,added:s}}function Ct(e,t,{group:s,...n}){if(s===null)return ue(e,t,n);let o=new Map,i=r=>Map.groupBy(r.keys(),c=>s(r[c].path)),a=i(e);for(let[r,c]of i(t)){let f=a.get(r);if(f!==void 0)for(let[l,{source:u,score:p}]of ue(f.map(h=>e[h]),c.map(h=>t[h]),n))o.set(c[l],{source:f[u],score:p})}return o}function he(e,t,{renames:s=!0,renamesByPath:n=!0,renameLimit:o=St,renameGroup:i=null,paths:a="tree",lines:r=!0,horizon:c,whitespace:f,ignoreCase:l}={}){let u=Ot(s);Mt({renamesByPath:n,renameLimit:o,renameGroup:i,paths:a,lines:r});let p=Q({horizon:c,whitespace:f,ignoreCase:l}),h=a==="keys",{changes:b,deleted:m,added:y}=Tt(ce(e,"old",h),ce(t,"new",h)),d=u===null?new Map:Ct(m,y,{minimum:u,limit:o,byPath:n,group:i});for(let[S,O]of y.entries()){let N=d.get(S);b.push(N===void 0?_("added",null,O):_("renamed",m[N.source],O,Math.trunc(N.score*100/6e4)))}let x=new Set(d.values().map(({source:S})=>S));for(let[S,O]of m.entries())x.has(S)||b.push(_("deleted",O,null));return b.sort((S,O)=>pe((S.new??S.old).path,(O.new??O.old).path)),(r?b.map(S=>({...S,...xe(S.old,S.new,p)})):b).map(Et)}function de(e,t,s){let n=new Map,o=new Set,i=0;for(let r of e){let c=ee(s,r);c===null||!t.has(c)||(n.set(r,c),o.add(c),c!==r&&i++)}for(let r of e)n.has(r)||!t.has(r)||o.has(r)||(n.set(r,r),o.add(r));let a=n.size;for(let r of e){if(n.has(r))continue;let c=ee(s,r)??Se(s,r);for(;t.has(c)||o.has(c);)c=`../${c}`;n.set(r,c),o.add(c)}return{paths:n,paired:a,moved:i}}function Ft(e,t){let s=new Set(e),n=new Set(t),o=(r,c)=>{let f=new Map;for(let p of r)for(let h=p.indexOf("/");h!==-1;h=p.indexOf("/",h+1))c.has(p.slice(h+1))&&f.set(p.slice(0,h+1),(f.get(p.slice(0,h+1))??0)+1);let l=null,u=!1;for(let[p,h]of f)h>(f.get(l)??0)?[l,u]=[p,!1]:h===f.get(l)&&(u=!0);return u?null:l},i=de(s,n,null).paired,a=[[{base:"",other:o(n,s)},s],[{base:o(s,n),other:""},n]].filter(([r])=>r.base!==null&&r.other!==null).map(([r,c])=>({root:r,side:c,...de(s,n,r)})).filter(({side:r,paired:c,moved:f})=>c>i&&f*2>=r.size);return a.length===2&&a[0].paired===a[1].paired?null:a.toSorted((r,c)=>c.paired-r.paired)[0]?.root??null}function j(e,t){let s=[...e],n=new Set(t),o=Ft(s,n);return{root:o,paths:de(s,n,o).paths}}function ye(e,t,s){if(!e&&!t)return null;let n=Map.groupBy([...e??[]],([,i])=>i),o=new Map([...n].map(([i,a])=>[i,te(s,i,a.map(([r])=>r.slice(i.length+1)))]));return new Map([...[...e??[]].map(([i,a])=>[s.paths.get(i)??i,o.get(a)]),...t??[]])}function Ke(e,t,s=new Map,n=new Map,o=null){let i=r=>{let c=s.get(r)??n.get(r);return c===void 0?[...new Set([r,Pt(o,r)??r])]:[c]},a=[];for(let r of e.values()){let c=i(r.parent).map(f=>t.get(Oe(f,r.specifier,r.conditions,r.platform))).find(Boolean);if(c&&!i(r.target).includes(c.target)){let{target:f,...l}=c;a.push({...l,baseTarget:n.get(r.target)??r.target,otherTarget:f})}}return a.sort((r,c)=>r.key.localeCompare(c.key)),{changed:a,totalChanges:a.length}}function P(e){return we(e)??0}function je(e,t){return e===t||e?.format==="base64"&&t?.format==="base64"&&e.data===t.data||e?.format==="digest"&&t?.format==="digest"&&e.digest===t.digest}function me(e){if(e?.kind!=="stasis"||!e.bundle)return null;let{formats:t,executable:s,entries:n}=e.bundle;return o=>({format:t?.get(o),executable:s?.has(o)??!1,entry:n?.has(o)??!1})}function Rt(e,t){return!e||!t?[]:["format","executable","entry"].filter(s=>e[s]!==t[s]).map(s=>({field:s,from:e[s],to:t[s]}))}function ze(e){return(t,s)=>Math.abs(s.delta)-Math.abs(t.delta)||t[e].localeCompare(s[e])}function W(e){return(t,s)=>s.bytes-t.bytes||t[e].localeCompare(s[e])}function Nt(e,t){return typeof e=="string"?`\0text\0${e.toWellFormed()}`:e?.format==="base64"?`\0base64\0${e.data}`:e?.format==="digest"?`\0digest\0${e.digest}`:`\0none\0${t}`}var It=250;function vt(e,t,s,n,o){let i=(c,f,l)=>c.filter(({path:u})=>u!==""&&u.isWellFormed()).map(({path:u},p)=>({name:u,data:Nt(f.get(u),`${l}${p}`)})),a={paths:"keys",renameGroup:o,renameLimit:It,lines:!1},r=he(i(e,s,"a"),i(t,n,"b"),a);return new Map(r.filter(({status:c})=>c==="renamed").map(c=>[c.old.path,c.new.path]))}function Pt(e,t){return e?e.base===""?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}function Dt(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function He(e,t,s,n=j(e.keys(),t.keys()),o=[]){let{root:i,paths:a}=n,r=new Map([...a].map(([k,g])=>[g,k]));e=new Map([...e].map(([k,g])=>[a.get(k),g]));let c=k=>r.get(k)===k?{}:{basePath:r.get(k)},f=(k,g)=>{let B=Rt(o[0]?.(k),o[1]?.(g));return B.length>0?{meta:B}:{}},l=[],u=[],p=[],h=0,b=0,m=0,y=0,d=0,x=0,S=new Map,O=k=>{let g=s(k),B=S.get(g);return B||(B=Dt(),S.set(g,B)),B},N=new Set([...e.keys(),...t.keys()]);for(let k of N){let g=e.has(k),B=t.has(k),E=O(k);if(g&&B){let M=e.get(k),L=t.get(k),F=je(M,L),v=f(r.get(k),k),R=P(M),z=F?R:P(L);if(h+=R,b+=z,E.baseBytes+=R,E.otherBytes+=z,F&&!v.meta)x++;else{let ge=z-R;p.push({path:k,...c(k),baseBytes:R,otherBytes:z,delta:ge,...v,...F?{modified:!1}:{}}),d+=ge,E.changedFiles++}}else if(g){let M=P(e.get(k));h+=M,m+=M,E.baseBytes+=M,E.onlyBaseFiles++,l.push({path:k,...c(k),bytes:M})}else{let M=P(t.get(k));b+=M,y+=M,E.otherBytes+=M,E.onlyOtherFiles++,u.push({path:k,bytes:M})}}let w=vt(l,u,e,t,s);if(w.size>0){let k=new Set(w.values());for(let[g,B]of w){let E=e.get(g),M=t.get(B),L=je(E,M),F=P(E),v=L?F:P(M);m-=F,y-=v,p.push({path:B,renamedFrom:g,basePath:r.get(g),baseBytes:F,otherBytes:v,delta:v-F,modified:!L,...f(r.get(g),B)}),d+=v-F;let R=O(g);R.onlyBaseFiles--,R.onlyOtherFiles--,R.changedFiles++}l.splice(0,l.length,...l.filter(g=>!w.has(g.path))),u.splice(0,u.length,...u.filter(g=>!k.has(g.path)))}let $=[],A=[],C=[],D=[];for(let[k,g]of S){let B=g.baseBytes>0||g.onlyBaseFiles>0||g.changedFiles>0,E=g.otherBytes>0||g.onlyOtherFiles>0||g.changedFiles>0,M=g.onlyBaseFiles+g.onlyOtherFiles+g.changedFiles;B&&!E?$.push({pkg:k,bytes:g.baseBytes}):E&&!B?A.push({pkg:k,bytes:g.otherBytes}):M>0||g.baseBytes!==g.otherBytes?C.push({pkg:k,baseBytes:g.baseBytes,otherBytes:g.otherBytes,delta:g.otherBytes-g.baseBytes}):D.push({pkg:k,bytes:g.baseBytes})}return l.sort(W("path")),u.sort(W("path")),p.sort(ze("path")),$.sort(W("pkg")),A.sort(W("pkg")),C.sort(ze("pkg")),{totals:{baseFiles:e.size,baseBytes:h,otherFiles:t.size,otherBytes:b,onlyBaseFiles:l.length,onlyBaseBytes:m,onlyOtherFiles:u.length,onlyOtherBytes:y,changedFiles:p.length,renamedFiles:w.size,changedDelta:d,unchangedFiles:x,fileDelta:t.size-e.size,byteDelta:b-h,identical:l.length===0&&u.length===0&&p.length===0},files:{onlyBase:l,onlyOther:u,changed:p,root:i,basePaths:a},packages:{onlyBase:$,onlyOther:A,changed:C,unchanged:D}}}function Lt(e,t,s=null){let[n,o]=[e,t],i=ne(n,s),a=ne(o,s),r=j(i.keys(),a.keys()),c=ye(X(n),X(o),r),l=He(i,a,d=>Z(d,{packageDir:c?.get(d)}),r,[me(n),me(o)]),u=V(n),p=V(o),h=(d,x)=>{let S=0;for(let O of x)S+=d.get(O)??0;return S};Object.assign(l.totals,{baseLines:h(u,i.keys()),otherLines:h(p,a.keys())});for(let d of l.files.onlyBase)d.lines=u.get(d.basePath??d.path)??0;for(let d of l.files.onlyOther)d.lines=p.get(d.path)??0;for(let d of l.files.changed)Object.assign(d,{baseLines:u.get(d.basePath??d.path)??0,otherLines:p.get(d.path)??0});l.resolutions=Ke(se(n,s),se(o,s),new Map(l.files.changed.filter(d=>d.renamedFrom!=null).map(d=>[d.basePath,d.path])),l.files.basePaths,l.files.root);let b=d=>Z("",{packageDir:d}),m=J(n,s?i.keys():null,b),y=J(o,s?a.keys():null,b);return l.versionUpdates=Y(m,y),l.packageRows=q(l.packages,m,y),l.scope=s??"",l}export{Lt as prepareComparison};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as w,c as f,j as m,l as k}from"./chunk-
|
|
1
|
+
import{b as w,c as f,j as m,l as k}from"./chunk-QYWKC557.js";import{a as h}from"./chunk-TUII34K2.js";var x=3,y=4,H=/^[\w-]{4}$/u,_=/^[\w-]{8}$/u,u="AAAA",R={report:`deepview/finding-link/report/v1
|
|
2
2
|
`,workspace:`deepview/finding-link/workspace/v1
|
|
3
3
|
`},p=new Map;function $(t,e){return`${t}\0${e}`}function I(t){return typeof t=="string"&&H.test(t)}async function T(t,e){let n=R[t];if(!n||typeof e!="string"||!e)return null;let i=$(t,e),o=p.get(i);if(o!==void 0)return o;let r;try{let s=await crypto.subtle.digest("SHA-256",h(n+e));r=new Uint8Array(s).slice(0,x).toBase64({alphabet:"base64url",omitPadding:!0})}catch{return null}return p.set(i,r),r}function E(t,e){return typeof e!="string"||!e?null:p.get($(t,e))??null}function N(t,e){let n=[];for(let[i,o]of[["report",t],["workspace",e]]){if(o==null||o===""){n.push(u);continue}if(!I(o))throw new TypeError(`encodeFindingRef: ${i} must be a link hint token, not a name`);n.push(o)}return n.every(i=>i===u)?null:n[0]===u?`w${n[1]}`:n.join("")}function b(t){let e=[t.slice(0,y),t.slice(y)].map(n=>n===u?null:n);return{report:e[0],workspace:e[1]}}function a({id:t,report:e,workspace:n}={}){if(!f(t))throw new TypeError("encodeFindingRef: a persistent finding id is required");let i=[`finding=${encodeURIComponent(t)}`],o=N(e,n);return o&&i.push(`v=${o}`),i.join("&")}function O(t,e){let n=a(t);return typeof location>"u"?`${e??""}#${n}`:`${location.origin}${e??location.pathname}#${n}`}function A(t){let e=typeof t=="string"?t:typeof location>"u"?"":location.hash;if(!e)return null;let n=e.replace(/^#/u,"");if(!n)return null;let i={id:null,report:null,workspace:null};for(let o of n.split("&")){let r=o.indexOf("=");if(r<0)continue;let s=o.slice(0,r),c=o.slice(r+1);if(!c)continue;if(s==="v"){if(c.length===5&&c[0]==="w"&&I(c.slice(1))){let g=c.slice(1);Object.assign(i,{report:null,workspace:g===u?null:g});continue}if(!_.test(c))continue;Object.assign(i,b(c));continue}if(s!=="finding"||c.length>w*3)continue;let d;try{d=decodeURIComponent(c)}catch{continue}f(d)&&(i.id=d)}return i.id?i:null}function U(t,{managed:e=!1}={}){if(typeof location>"u")return null;let n;try{n=new URL(t)}catch{return null}if(n.href!==t||n.protocol!==location.protocol||n.host!==location.host||n.username||n.password)return null;let i=k(n);if(i?.finding)return{id:i.finding.id,fragment:a(i.finding),path:m(i)};if(e&&i?.view!=="home"&&!/\/(?:index|view)\.html$/u.test(n.pathname))return null;let o=A(n.hash);if(!o)return null;let r=a(o);return{id:o.id,fragment:r,path:`/#${r}`}}function l(t,e){if(typeof t!="string")return!1;let n=t.replaceAll("\\","/");return n.startsWith(`${e}/`)||n.includes(`/${e}/`)}function C(t){let e=!1;for(let n of t){for(let i of n.groups??[])for(let o of i){if(l(o.file,"node_modules"))return"node_modules";l(o.file,"vendor")&&(e=!0)}for(let i of Object.keys(n.tree??{})){if(l(i,"node_modules"))return"node_modules";l(i,"vendor")&&(e=!0)}}return e?"vendor":"dependencies"}export{l as a,C as b,T as c,E as d,a as e,O as f,A as g,U as h};
|