@visulima/vis 1.0.0-alpha.2 → 1.0.0-alpha.20

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 (147) hide show
  1. package/CHANGELOG.md +830 -14
  2. package/LICENSE.md +7667 -0
  3. package/README.md +322 -19
  4. package/dist/bin.js +1 -146
  5. package/dist/config/index.d.ts +2795 -0
  6. package/dist/config/index.js +1 -0
  7. package/dist/generate/index.d.ts +157 -0
  8. package/dist/generate/index.js +1 -0
  9. package/dist/packem_chunks/bin.js +1295 -0
  10. package/dist/packem_chunks/config.js +19 -0
  11. package/dist/packem_chunks/doctor-probe.js +2 -0
  12. package/dist/packem_chunks/fix.js +11 -0
  13. package/dist/packem_chunks/handler.js +1 -0
  14. package/dist/packem_chunks/handler10.js +1 -0
  15. package/dist/packem_chunks/handler11.js +5 -0
  16. package/dist/packem_chunks/handler12.js +1 -0
  17. package/dist/packem_chunks/handler13.js +27 -0
  18. package/dist/packem_chunks/handler14.js +5 -0
  19. package/dist/packem_chunks/handler15.js +1 -0
  20. package/dist/packem_chunks/handler16.js +1 -0
  21. package/dist/packem_chunks/handler17.js +1 -0
  22. package/dist/packem_chunks/handler18.js +1 -0
  23. package/dist/packem_chunks/handler19.js +1 -0
  24. package/dist/packem_chunks/handler2.js +2 -0
  25. package/dist/packem_chunks/handler20.js +5 -0
  26. package/dist/packem_chunks/handler21.js +2 -0
  27. package/dist/packem_chunks/handler22.js +2 -0
  28. package/dist/packem_chunks/handler23.js +18 -0
  29. package/dist/packem_chunks/handler24.js +1 -0
  30. package/dist/packem_chunks/handler25.js +1 -0
  31. package/dist/packem_chunks/handler26.js +5 -0
  32. package/dist/packem_chunks/handler27.js +1 -0
  33. package/dist/packem_chunks/handler28.js +3 -0
  34. package/dist/packem_chunks/handler29.js +1 -0
  35. package/dist/packem_chunks/handler3.js +4 -0
  36. package/dist/packem_chunks/handler30.js +7 -0
  37. package/dist/packem_chunks/handler31.js +33 -0
  38. package/dist/packem_chunks/handler32.js +3 -0
  39. package/dist/packem_chunks/handler33.js +1 -0
  40. package/dist/packem_chunks/handler34.js +26 -0
  41. package/dist/packem_chunks/handler35.js +3 -0
  42. package/dist/packem_chunks/handler36.js +7 -0
  43. package/dist/packem_chunks/handler37.js +22 -0
  44. package/dist/packem_chunks/handler38.js +428 -0
  45. package/dist/packem_chunks/handler39.js +6 -0
  46. package/dist/packem_chunks/handler4.js +8 -0
  47. package/dist/packem_chunks/handler40.js +24 -0
  48. package/dist/packem_chunks/handler41.js +10 -0
  49. package/dist/packem_chunks/handler42.js +153 -0
  50. package/dist/packem_chunks/handler43.js +25 -0
  51. package/dist/packem_chunks/handler44.js +24 -0
  52. package/dist/packem_chunks/handler45.js +213 -0
  53. package/dist/packem_chunks/handler46.js +3 -0
  54. package/dist/packem_chunks/handler47.js +27 -0
  55. package/dist/packem_chunks/handler48.js +167 -0
  56. package/dist/packem_chunks/handler49.js +34 -0
  57. package/dist/packem_chunks/handler5.js +1 -0
  58. package/dist/packem_chunks/handler6.js +1 -0
  59. package/dist/packem_chunks/handler7.js +1 -0
  60. package/dist/packem_chunks/handler8.js +1 -0
  61. package/dist/packem_chunks/handler9.js +2 -0
  62. package/dist/packem_chunks/heal-accept.js +10 -0
  63. package/dist/packem_chunks/heal.js +14 -0
  64. package/dist/packem_chunks/help-command.js +18 -0
  65. package/dist/packem_chunks/index.js +7 -0
  66. package/dist/packem_chunks/keys-refresh.js +4 -0
  67. package/dist/packem_chunks/list.js +3 -0
  68. package/dist/packem_chunks/loader.js +1 -0
  69. package/dist/packem_chunks/prune.js +3 -0
  70. package/dist/packem_chunks/run.js +1 -0
  71. package/dist/packem_chunks/status.js +2 -0
  72. package/dist/packem_chunks/sync.js +2 -0
  73. package/dist/packem_chunks/sync2.js +2 -0
  74. package/dist/packem_chunks/tar.js +3 -0
  75. package/dist/packem_chunks/tripwire.js +2 -0
  76. package/dist/packem_shared/advisories-DsynpacV.js +1 -0
  77. package/dist/packem_shared/ai-analysis-uYuTIIXi.js +68 -0
  78. package/dist/packem_shared/ai-cache-DuwHYx2O.js +1 -0
  79. package/dist/packem_shared/ai-fix-DzrA-dVz.js +43 -0
  80. package/dist/packem_shared/applyDefaults-BOVDw1jD.js +1 -0
  81. package/dist/packem_shared/build-scripts-DsWMSWDs.js +1 -0
  82. package/dist/packem_shared/cache-directory-DQak1Vjc.js +1 -0
  83. package/dist/packem_shared/cyclonedx-CiHXuG8M.js +4 -0
  84. package/dist/packem_shared/definePlugin-CWm4Dv_t.js +1 -0
  85. package/dist/packem_shared/dependency-scan-DC3nAFHS.js +1 -0
  86. package/dist/packem_shared/docker-B-CIN_nj.js +60 -0
  87. package/dist/packem_shared/failure-log-C3LEMmkq.js +2 -0
  88. package/dist/packem_shared/flakiness-Dq6K4ymq.js +1 -0
  89. package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
  90. package/dist/packem_shared/glob-MHJQjR39-CQ2GC0b_.js +1 -0
  91. package/dist/packem_shared/index-DH-5hsrC.js +1 -0
  92. package/dist/packem_shared/lifecycle-Dv3nAtoD.js +2 -0
  93. package/dist/packem_shared/lockfile-C5DYMHVq.js +1 -0
  94. package/dist/packem_shared/manifests-B0fMp872.js +1 -0
  95. package/dist/packem_shared/min-release-age-BFozFonQ.js +34 -0
  96. package/dist/packem_shared/native-config-sync-Dvi1g2nQ.js +21 -0
  97. package/dist/packem_shared/otelPlugin-CJR2T_lk.js +1 -0
  98. package/dist/packem_shared/registry-keys-CewRFW0e.js +1 -0
  99. package/dist/packem_shared/resolve-explicit-CC4Kifk5.js +5 -0
  100. package/dist/packem_shared/run-summary-utils-BaBGP3bo.js +1 -0
  101. package/dist/packem_shared/runtime-check-BusAwPb2.js +1 -0
  102. package/dist/packem_shared/scan-progress-CMynp3eA.js +2 -0
  103. package/dist/packem_shared/selectors-B2ISH581.js +3 -0
  104. package/dist/packem_shared/signatures-5ZdjJ2Pu.js +2 -0
  105. package/dist/packem_shared/symbols-CQmER5MT.js +1 -0
  106. package/dist/packem_shared/toolchain-Cc3cwyLP.js +5 -0
  107. package/dist/packem_shared/typosquats-BCeR-sLf.js +1 -0
  108. package/dist/packem_shared/use-measured-height-DjYgUOKk.js +1 -0
  109. package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
  110. package/dist/packem_shared/verify-07kUNTuP.js +1 -0
  111. package/dist/packem_shared/vis-update-app-CFrlJ3mW.js +1 -0
  112. package/dist/packem_shared/xxh3-DrAUNq4n.js +1 -0
  113. package/index.d.ts +358 -0
  114. package/index.js +609 -0
  115. package/package.json +57 -22
  116. package/schemas/project.schema.json +872 -0
  117. package/schemas/vis-config.schema.json +4306 -0
  118. package/skills/vis/SKILL.md +96 -0
  119. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  120. package/templates/buildkite-ci/template.yml +20 -0
  121. package/dist/ai-analysis.d.ts +0 -40
  122. package/dist/ai-cache.d.ts +0 -21
  123. package/dist/bin.d.ts +0 -1
  124. package/dist/catalog.d.ts +0 -110
  125. package/dist/commands/affected.d.ts +0 -3
  126. package/dist/commands/ai.d.ts +0 -3
  127. package/dist/commands/analyze.d.ts +0 -3
  128. package/dist/commands/check.d.ts +0 -3
  129. package/dist/commands/graph.d.ts +0 -3
  130. package/dist/commands/hook/constants.d.ts +0 -8
  131. package/dist/commands/hook/index.d.ts +0 -3
  132. package/dist/commands/hook/install.d.ts +0 -7
  133. package/dist/commands/hook/migrate.d.ts +0 -27
  134. package/dist/commands/hook/uninstall.d.ts +0 -3
  135. package/dist/commands/migrate/constants.d.ts +0 -12
  136. package/dist/commands/migrate/deps.d.ts +0 -32
  137. package/dist/commands/migrate/index.d.ts +0 -3
  138. package/dist/commands/migrate/json.d.ts +0 -20
  139. package/dist/commands/migrate/lint-staged.d.ts +0 -62
  140. package/dist/commands/migrate/types.d.ts +0 -20
  141. package/dist/commands/run.d.ts +0 -3
  142. package/dist/commands/staged.d.ts +0 -3
  143. package/dist/commands/update.d.ts +0 -3
  144. package/dist/config.d.ts +0 -40
  145. package/dist/config.js +0 -1
  146. package/dist/package-manager.d.ts +0 -23
  147. package/dist/workspace.d.ts +0 -58
@@ -0,0 +1,428 @@
1
+ var ie=Object.defineProperty;var k=(o,e)=>ie(o,"name",{value:e,configurable:!0});import{createRequire as le}from"node:module";import{aT as G,E,j as S,q as z,y as ae,m as pe,s as he}from"./bin.js";import{projectGraphToDot as ue}from"@visulima/task-runner";import{render as fe}from"@visulima/tui";import ge,{useSyncExternalStore as me,useState as $,useRef as W,useMemo as P,useCallback as q,useEffect as xe}from"react";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{Box as i}from"@visulima/tui/components/box";import{Dialog as be}from"@visulima/tui/components/dialog";import{Text as t}from"@visulima/tui/components/text";import{useApp as ye}from"@visulima/tui/hooks/use-app";import{useInput as we}from"@visulima/tui/hooks/use-input";import{useWindowSize as ve}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Ce}from"@visulima/tui/components/scroll-view";import{ScrollBar as Ae}from"@visulima/tui/components/scroll-bar";const de=le(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=k(o=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[e,l]=N.versions.node.split(".").map(Number);if(e>22||e===22&&l>=3||e===20&&l>=16)return N.getBuiltinModule(o)}return de(o)},"__cjs_getBuiltinModule"),{writeFileSync:ce}=se("node:fs");var Ee=Object.defineProperty,T=k((o,e)=>Ee(o,"name",{value:e,configurable:!0}),"l");const ke={application:0,library:3,service:1,tool:2},_=T(o=>ke[o]??Number.MAX_SAFE_INTEGER,"typeRank"),Me=T(o=>{const e=new Map;for(const[l,d]of Object.entries(o.dependencies))for(const c of d){const s=e.get(c.target)??[];s.push(l),e.set(c.target,s)}return Object.values(o.nodes).map(l=>({deps:o.dependencies[l.name]??[],name:l.name,reverseDeps:e.get(l.name)??[],type:l.type})).sort((l,d)=>l.type!==d.type?_(l.type)-_(d.type):l.name.localeCompare(d.name))},"buildNodes"),Se=T((o,e,l)=>{let d=o;if(e==="app"?d=d.filter(c=>c.type==="application"):e==="lib"&&(d=d.filter(c=>c.type!=="application")),l){const c=l.toLowerCase();d=d.filter(s=>s.name.toLowerCase().includes(c))}return d},"filterNodes");class Te{static{k(this,"GraphStore")}static{T(this,"GraphStore")}#e;#n=new Set;#r;constructor(e){this.#r=e;const l=Me(e);this.#e={allNodes:l,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=T(()=>this.#e,"getSnapshot");subscribe=T(e=>(this.#n.add(e),()=>{this.#n.delete(e)}),"subscribe");getFilteredNodes(){return Se(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(c=>c.type==="application").length,l=this.#e.allNodes.length,d=Object.values(this.#r.dependencies).reduce((c,s)=>c+s.length,0);return{apps:e,deps:d,libs:l-e,total:l}}setSelectedIndex(e){const l=this.getFilteredNodes(),d=l.length===0?-1:Math.max(0,Math.min(e,l.length-1));d!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:d})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#t({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#t(e){this.#e=e;for(const l of this.#n)try{l()}catch{}}}var je=Object.defineProperty,De=k((o,e)=>je(o,"name",{value:e,configurable:!0}),"p");const Ne=De(({focused:o,node:e,scrollRef:l})=>{const d=o?"white":"gray";if(!e)return n(i,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:n(t,{dimColor:!0,children:"No project selected"})});const c=e.type==="application",s=c?"yellow":"cyan",f=c?"Application":"Library";return n(i,{borderColor:d,borderStyle:"single",borderTopRightTitle:` ${f} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:r(Ce,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"DEPENDS ON"}),r(t,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.deps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"cyan",children:"→"}),n(t,{children:a.target}),a.type!=="static"&&r(t,{dimColor:!0,children:["(",a.type,")"]})]},a.target))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"REQUIRED BY"}),r(t,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No reverse dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"magenta",children:"←"}),n(t,{children:a})]},a))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"INFO"})]}),r(i,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Type:"})}),n(t,{color:s,children:f})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Dependencies:"})}),n(t,{children:String(e.deps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Required by:"})}),n(t,{children:String(e.reverseDeps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Connectivity:"})}),n(t,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var Ie=Object.defineProperty,L=k((o,e)=>Ie(o,"name",{value:e,configurable:!0}),"m");const $e=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],U=L(({isSelected:o,node:e})=>{const l=e.type==="application",d=l?"yellow":"cyan",c=l?"app":"lib";return r(i,{flexShrink:0,height:1,children:[r(t,{children:[o?"▶":" "," "]}),n(i,{flexGrow:1,children:n(t,{bold:o,inverse:o,wrap:"truncate",children:e.name})}),r(t,{color:d,children:[" ",c]}),r(t,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),Y=L(({count:o,label:e})=>r(i,{flexShrink:0,height:1,marginTop:1,children:[r(t,{dimColor:!0,children:["▼"," "]}),n(t,{bold:!0,color:"white",children:e.toUpperCase()}),r(t,{dimColor:!0,children:[" ","(",o,")"]})]}),"TypeHeader"),Pe=L(({filterActive:o,filterText:e,filterType:l,focused:d,nodes:c,scrollOffset:s,selectedIndex:f,stats:a,viewportHeight:y})=>{const m=d?"white":"gray",v=c.filter(w=>w.type==="application"),h=c.filter(w=>w.type!=="application"),g=[];let x=0;if(v.length>0){g.push(n(Y,{count:v.length,label:"Applications"},"hdr-apps"));for(const w of v){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}if(h.length>0){g.push(n(Y,{count:h.length,label:"Libraries"},"hdr-libs"));for(const w of h){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}let C=0;v.length>0&&(C+=2+v.length),h.length>0&&(C+=2+h.length);const M=C>y&&y>0;return r(i,{borderColor:m,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[r(i,{flexShrink:0,gap:1,paddingX:1,children:[n(t,{bold:!0,inverse:!0,children:" VIS "}),r(t,{wrap:"truncate",children:[a.total," ","packages"]}),r(t,{dimColor:!0,children:["(",a.apps," ","apps,"," ",a.libs," ","libs,"," ",a.deps," ","deps)"]})]}),n(i,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:$e.map(w=>{const A=l===w.key;return r(i,{children:[n(t,{dimColor:!A,children:"["}),n(t,{bold:A,color:A?"cyan":"gray",children:w.shortcut}),n(t,{dimColor:!A,children:"]"}),r(t,{color:A?"white":"gray",children:[" ",w.label]})]},w.key)})}),o&&r(i,{flexShrink:0,paddingX:1,children:[n(t,{bold:!0,color:"white",children:"/ "}),n(t,{children:e}),n(t,{inverse:!0,children:" "})]}),r(i,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[n(i,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:n(i,{flexDirection:"column",marginTop:-s,children:g})}),M&&n(i,{flexShrink:0,marginLeft:1,marginRight:1,children:n(Ae,{contentHeight:C,placement:"inset",scrollOffset:s,style:"block",viewportHeight:y})})]})]})},"ProjectListPanel");var Le=Object.defineProperty,Oe=k((o,e)=>Le(o,"name",{value:e,configurable:!0}),"E");const Re=100,Be=40,Fe=10,X={1:"all",2:"app",3:"lib"},He=Oe(({autoExitSeconds:o=0,store:e})=>{const{exit:l}=ye(),{columns:d,rows:c}=ve(),s=me(e.subscribe,e.getSnapshot),[f,a]=$(!1),y=W(null),m=W(null),[v,h]=$(0),[g,x]=$(!1),C=P(()=>e.getFilteredNodes(),[s.allNodes,s.filterType,s.filterText]),M=P(()=>e.getStats(),[s.allNodes]),w=C[s.selectedIndex]??null,A=P(()=>{let u=0,p=0;for(const b of C)b.type==="application"?u+=1:p+=1;return{appsCount:u,libsCount:p}},[C]),O=q(u=>{const{appsCount:p,libsCount:b}=A;if(u<p)return(p>0?2:0)+u;const re=p>0?2+p:0,oe=b>0?2:0;return re+oe+(u-p)},[A]),I=Math.max(1,c-8-(s.filterActive?1:0)),D=q(u=>{const p=O(u);h(b=>p>b+I-2?Math.max(0,p-I+2):p<b+1?Math.max(0,p-1):b)},[O,I]);if(xe(()=>{m.current?.scrollToTop()},[w?.name]),we((u,p)=>{if(u==="c"&&p.ctrl){l();return}if(!g){if(f){p.escape||u==="?"?a(!1):u==="q"?(a(!1),x(!0)):p.downArrow||u==="j"?y.current?.scrollBy(1):(p.upArrow||u==="k")&&y.current?.scrollBy(-1);return}if(u==="?"){a(!0);return}if(u==="q"){x(!0);return}if(p.tab){e.setFocusedPanel(s.focusedPanel==="list"?"detail":"list");return}if(X[u]){e.setFilterType(X[u]);return}if(s.filterActive){if(p.escape){e.setFilterActive(!1);return}if(p.return){e.setFilterActive(!1);return}if(p.backspace){e.setFilter(s.filterText.slice(0,-1));return}if(u&&!p.ctrl&&!p.meta){e.setFilter(s.filterText+u);return}return}if(s.focusedPanel==="list"){if(C.length===0){u==="/"&&e.setFilterActive(!0);return}if(p.downArrow||u==="j"){const b=Math.min(s.selectedIndex+1,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.upArrow||u==="k"){const b=Math.max(s.selectedIndex-1,0);e.setSelectedIndex(b),D(b);return}if(p.pageDown){const b=Math.min(s.selectedIndex+10,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.pageUp){const b=Math.max(s.selectedIndex-10,0);e.setSelectedIndex(b),D(b);return}if(p.home){e.setSelectedIndex(0),h(0);return}if(p.end){const b=C.length-1;e.setSelectedIndex(b),D(b);return}if(u==="/"){e.setFilterActive(!0);return}if(p.rightArrow){e.setFocusedPanel("detail");return}return}if(s.focusedPanel==="detail"){if(p.escape||p.leftArrow){e.setFocusedPanel("list");return}if(p.downArrow||u==="j"){m.current?.scrollBy(1);return}if(p.upArrow||u==="k"){m.current?.scrollBy(-1);return}if(p.pageDown){m.current?.scrollBy(10);return}if(p.pageUp){m.current?.scrollBy(-10);return}if(p.home){m.current?.scrollToTop();return}p.end&&m.current?.scrollToBottom()}}},{isActive:!0}),d<Be||c<Fe)return n(i,{alignItems:"center",height:c,justifyContent:"center",width:d,children:r(t,{color:"yellow",children:["Terminal too small (",d,"x",c,")"]})});const te=d>=Re,R=n(i,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(i,{flexWrap:"wrap",gap:2,paddingX:1,children:[r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"q"}),n(t,{dimColor:!0,children:"QUIT"})]},"q"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"?"}),n(t,{dimColor:!0,children:"HELP"})]},"?"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"↑↓"}),n(t,{dimColor:!0,children:"NAV"})]},"nav"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"1-3 /"}),n(t,{dimColor:!0,children:"FILTER"})]},"f"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"Tab"}),n(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),B=r(be,{footer:r(t,{dimColor:!0,children:[n(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n(t,{bold:!0,color:"white",children:"?"}),"/",n(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:f,width:52,children:[r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),n(t,{dimColor:!0,children:" Move up"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),n(t,{dimColor:!0,children:" Move down"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Tab"]}),n(t,{dimColor:!0,children:" Switch panel"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),n(t,{dimColor:!0,children:" Focus detail/list"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),n(t,{dimColor:!0,children:" Jump 10 items"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Home/End"]}),n(t,{dimColor:!0,children:" Jump to start/end"})]})]}),r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"FILTERS"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","1"]}),n(t,{dimColor:!0,children:" All"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","2"]}),n(t,{dimColor:!0,children:" Apps only"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","3"]}),n(t,{dimColor:!0,children:" Libraries only"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","/"]}),n(t,{dimColor:!0,children:" Text filter"})]})]}),r(i,{flexDirection:"column",children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"ACTIONS"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","q"]}),n(t,{dimColor:!0,children:" Quit"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","?"]}),n(t,{dimColor:!0,children:" Toggle help"})]})]})]}),F=n(Pe,{filterActive:s.filterActive,filterText:s.filterText,filterType:s.filterType,focused:s.focusedPanel==="list",nodes:C,scrollOffset:v,selectedIndex:s.selectedIndex,stats:M,viewportHeight:I}),H=n(Ne,{focused:s.focusedPanel==="detail",node:w,scrollRef:m});if(te){const u=Math.floor(d*.35);return r(i,{flexDirection:"column",height:c,width:d,children:[r(i,{flexDirection:"row",flexGrow:1,children:[n(i,{flexGrow:1,children:F}),n(i,{width:u,children:H})]}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})}const ne=Math.floor(c*.55);return r(i,{flexDirection:"column",height:c,width:d,children:[n(i,{height:ne,children:F}),n(i,{flexGrow:1,children:H}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})},"VisGraphApp");var J=Object.freeze,Z=Object.defineProperty,j=k((o,e)=>Z(o,"name",{value:e,configurable:!0}),"x"),Ge=k((o,e)=>J(Z(o,"raw",{value:J(e||o.slice())})),"C");const ee=j((o,e,l,d,c,s,f,a)=>{const y=l?E("└── "):E("├── "),m=c.has(o),v=m?E(" (*)"):"",h=d.get(o),g=h?.type==="application"?S(o):o;if(s.push(`${e}${y}${g}${v}`),m)return;c.add(o);const x=h?.deps??[],C=l?`${e} `:`${e}${E("│")} `;if(a>=f&&x.length>0){s.push(`${C}${E(`... ${x.length} more`)}`);return}for(let M=0;M<x.length;M++){const w=x[M];w&&ee(w.target,C,M===x.length-1,d,c,s,f,a+1)}},"printDepsTree"),V=j((o,e,l,d,c,s)=>{const f=e.get(o),a=f?.type==="application"?S(o):o;d.push(`${s}${a}`),l.add(o);const y=f?.deps??[];if(y.length===0){d.push(`${s} ${E("(no dependencies)")}`);return}if(c<=0){d.push(`${s} ${E(`... ${y.length} dependencies`)}`);return}for(let m=0;m<y.length;m++){const v=y[m];v&&ee(v.target,s,m===y.length-1,e,l,d,c,1)}},"printRootProject"),Q=j((o,e)=>{const l=new Map;for(const[h,g]of Object.entries(o.nodes))l.set(h,{deps:(o.dependencies[h]??[]).map(x=>({target:x.target,type:x.type})),name:h,type:g.type});const d=[],c=[];for(const[h,g]of l)g.type==="application"?d.push(h):c.push(h);d.sort(),c.sort();const s=d.length+c.length,f=Object.values(o.dependencies).reduce((h,g)=>h+g.length,0),a=[S("Project Dependency Graph"),""];if(d.length>0){a.push(` ${S(z(`Applications (${d.length})`))}`,"");for(const h of d)V(h,l,new Set,a,e," "),a.push("")}if(c.length>0){a.push(` ${S(z(`Libraries (${c.length})`))}`,"");for(const h of c)V(h,l,new Set,a,e," "),a.push("")}const y=process.stdout.columns||80;a.push(E("─".repeat(Math.min(y,60)))),a.push(`${S(String(s))} packages ${E("·")} ${S(String(f))} dependencies ${E("·")} ${S(String(d.length))} apps${E(",")} ${S(String(c.length))} libraries`);const m=new Set;let v=!1;for(const h of[...d,...c]){const g=l.get(h)?.deps??[];for(const x of g)m.has(x.target)&&(v=!0),m.add(x.target);m.add(h)}return v&&a.push(E("(*) = already shown above")),a.join(`
2
+ `)},"projectGraphToAscii"),ze=j(o=>{const e=Object.values(o.nodes).map(l=>({name:l.name,type:l.type}));return{edges:Object.values(o.dependencies).flat(),nodes:e}},"projectGraphToJson");var K;const We=j(o=>{const e=Object.values(o.nodes).map(f=>({name:f.name,type:f.type})),l=[];for(const f of Object.values(o.dependencies))for(const a of f)l.push({source:a.source,target:a.target,type:a.type});const d=e.filter(f=>f.type==="application"),c=e.filter(f=>f.type!=="application"),s={apps:d.length,edges:l,libs:c.length,nodes:e};return String.raw(K||(K=Ge([`<!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <title>Project Dependency Graph</title>
7
+ <style>
8
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9
+ body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #e2e8f0; overflow: hidden; }
10
+ svg { width: 100vw; height: 100vh; }
11
+ .edge { fill: none; marker-end: url(#arrow); }
12
+ .node rect { rx: 8; ry: 8; cursor: pointer; transition: stroke-width 0.15s; }
13
+ .node text { font-size: 12px; font-weight: 600; pointer-events: none; }
14
+ .node:hover rect { stroke-width: 2.5; stroke: #fff; }
15
+ #info { position: fixed; top: 16px; right: 16px; background: #1e293b; padding: 14px 20px; border-radius: 10px; font-size: 13px; border: 1px solid #334155; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
16
+ #info b { font-variant-numeric: tabular-nums; }
17
+ .app-count { color: #fbbf24; }
18
+ .lib-count { color: #38bdf8; }
19
+ .dep-count { color: #a78bfa; }
20
+ #legend { position: fixed; bottom: 16px; left: 16px; background: #1e293b; padding: 12px 16px; border-radius: 10px; font-size: 12px; border: 1px solid #334155; display: flex; gap: 16px; align-items: center; }
21
+ .legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; }
22
+ #tooltip { position: fixed; display: none; background: #1e293b; border: 1px solid #475569; border-radius: 8px; padding: 12px 16px; font-size: 12px; max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 10; pointer-events: none; }
23
+ #tooltip h3 { font-size: 14px; margin-bottom: 6px; }
24
+ #tooltip .type-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 8px; }
25
+ #tooltip .dep-section { margin-top: 8px; color: #94a3b8; }
26
+ #tooltip ul { list-style: none; padding-left: 0; margin-top: 4px; }
27
+ #tooltip li { padding: 1px 0; color: #cbd5e1; }
28
+ #tooltip li::before { content: "92 "; color: #64748b; }
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <div id="info">
33
+ <b class="app-count">`,`</b> apps &middot;
34
+ <b class="lib-count">`,`</b> libraries &middot;
35
+ <b class="dep-count">`,`</b> dependencies
36
+ </div>
37
+ <div id="legend">
38
+ <span><span class="legend-dot" style="background:#fbbf24"></span>Application</span>
39
+ <span><span class="legend-dot" style="background:#38bdf8"></span>Library</span>
40
+ <span style="color:#64748b">&mdash; solid = static &nbsp; - - - = implicit</span>
41
+ </div>
42
+ <div id="tooltip"></div>
43
+ <svg id="graph">
44
+ <defs>
45
+ <marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
46
+ <path d="M 0 0 L 10 5 L 0 10 z" fill="#64748b"/>
47
+ </marker>
48
+ </defs>
49
+ </svg>
50
+ <script>
51
+ const data = `,`;
52
+ const svg = document.getElementById('graph');
53
+ const tooltip = document.getElementById('tooltip');
54
+ const W = window.innerWidth, H = window.innerHeight;
55
+
56
+ // Build adjacency
57
+ const depMap = {}, rdepMap = {};
58
+ data.nodes.forEach(n => { depMap[n.name] = []; rdepMap[n.name] = []; });
59
+ data.edges.forEach(e => { depMap[e.source]?.push(e.target); rdepMap[e.target]?.push(e.source); });
60
+
61
+ // Escape text for safe DOM insertion
62
+ function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.textContent; }
63
+
64
+ // Force-directed layout
65
+ const repulsion = 5000 + data.nodes.length * 150;
66
+ const nodes = data.nodes.map(n => ({
67
+ ...n, x: W/2 + (Math.random()-0.5)*Math.min(W*0.6, 600),
68
+ y: H/2 + (Math.random()-0.5)*Math.min(H*0.6, 400), vx: 0, vy: 0
69
+ }));
70
+ const nodeMap = new Map(nodes.map(n => [n.name, n]));
71
+ const edges = data.edges.map(e => ({
72
+ source: nodeMap.get(e.source), target: nodeMap.get(e.target), type: e.type
73
+ }));
74
+
75
+ for (let iter = 0; iter < 400; iter++) {
76
+ for (let i = 0; i < nodes.length; i++) {
77
+ for (let j = i+1; j < nodes.length; j++) {
78
+ let dx = nodes[j].x - nodes[i].x, dy = nodes[j].y - nodes[i].y;
79
+ let d = Math.sqrt(dx*dx + dy*dy) || 1;
80
+ let f = repulsion / (d * d);
81
+ nodes[i].vx -= dx/d * f; nodes[i].vy -= dy/d * f;
82
+ nodes[j].vx += dx/d * f; nodes[j].vy += dy/d * f;
83
+ }
84
+ }
85
+ edges.forEach(e => {
86
+ if (!e.source || !e.target) {
87
+ return;
88
+ }
89
+ let dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
90
+ let d = Math.sqrt(dx*dx + dy*dy) || 1;
91
+ let f = (d - 180) * 0.008;
92
+ e.source.vx += dx/d * f; e.source.vy += dy/d * f;
93
+ e.target.vx -= dx/d * f; e.target.vy -= dy/d * f;
94
+ });
95
+ nodes.forEach(n => {
96
+ n.vx += (W/2 - n.x) * 0.001; n.vy += (H/2 - n.y) * 0.001;
97
+ n.x += n.vx * 0.3; n.y += n.vy * 0.3;
98
+ n.vx *= 0.75; n.vy *= 0.75;
99
+ n.x = Math.max(80, Math.min(W-80, n.x));
100
+ n.y = Math.max(40, Math.min(H-40, n.y));
101
+ });
102
+ }
103
+
104
+ // Measure text widths
105
+ const measure = document.createElementNS('http://www.w3.org/2000/svg','text');
106
+ measure.setAttribute('font-size','12'); measure.setAttribute('font-weight','600');
107
+ measure.setAttribute('font-family','system-ui');
108
+ svg.appendChild(measure);
109
+ const widths = {};
110
+ nodes.forEach(n => { measure.textContent = n.name; widths[n.name] = measure.getComputedTextLength(); });
111
+ svg.removeChild(measure);
112
+
113
+ // Render edges
114
+ edges.forEach(e => {
115
+ if (!e.source || !e.target) {
116
+ return;
117
+ }
118
+ const sw = (widths[e.source.name]||80)/2 + 12;
119
+ const tw = (widths[e.target.name]||80)/2 + 12;
120
+ const dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
121
+ const d = Math.sqrt(dx*dx+dy*dy)||1;
122
+ const x1 = e.source.x + dx/d*sw, y1 = e.source.y + dy/d*14;
123
+ const x2 = e.target.x - dx/d*tw, y2 = e.target.y - dy/d*14;
124
+ const line = document.createElementNS('http://www.w3.org/2000/svg','line');
125
+ line.setAttribute('x1',x1); line.setAttribute('y1',y1);
126
+ line.setAttribute('x2',x2); line.setAttribute('y2',y2);
127
+ line.setAttribute('class','edge');
128
+ const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
129
+ line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
130
+ line.setAttribute('stroke-width', '1.5');
131
+ if (e.type === 'implicit' || e.type === 'peerDependency') {
132
+ line.setAttribute('stroke-dasharray', '6,4');
133
+ }
134
+ if (e.type === 'devDependency') {
135
+ line.setAttribute('stroke-dasharray', '3,3');
136
+ }
137
+ svg.appendChild(line);
138
+ });
139
+
140
+ // Render nodes
141
+ nodes.forEach(n => {
142
+ const w = (widths[n.name]||80) + 24;
143
+ const h = 32;
144
+ const isApp = n.type === 'application';
145
+ const fill = isApp ? '#fbbf24' : '#38bdf8';
146
+ const textFill = '#0f172a';
147
+ const stroke = isApp ? '#f59e0b' : '#0284c7';
148
+
149
+ const g = document.createElementNS('http://www.w3.org/2000/svg','g');
150
+ g.setAttribute('class','node');
151
+ g.setAttribute('transform','translate('+(n.x - w/2)+','+(n.y - h/2)+')');
152
+ const rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
153
+ rect.setAttribute('width', w); rect.setAttribute('height', h);
154
+ rect.setAttribute('fill', fill); rect.setAttribute('stroke', stroke); rect.setAttribute('stroke-width','1.5');
155
+ g.appendChild(rect);
156
+ const text = document.createElementNS('http://www.w3.org/2000/svg','text');
157
+ text.setAttribute('x', w/2); text.setAttribute('y', h/2 + 4.5);
158
+ text.setAttribute('text-anchor','middle'); text.setAttribute('fill', textFill);
159
+ text.textContent = n.name;
160
+ g.appendChild(text);
161
+
162
+ g.addEventListener('mouseenter', (ev) => {
163
+ const deps = depMap[n.name] || [];
164
+ const rdeps = rdepMap[n.name] || [];
165
+
166
+ // Build tooltip using safe DOM methods
167
+ tooltip.textContent = '';
168
+
169
+ const heading = document.createElement('h3');
170
+ heading.textContent = n.name;
171
+ const badge = document.createElement('span');
172
+ badge.className = 'type-badge';
173
+ badge.style.background = fill;
174
+ badge.style.color = '#0f172a';
175
+ badge.textContent = n.type;
176
+ heading.appendChild(badge);
177
+ tooltip.appendChild(heading);
178
+
179
+ if (deps.length) {
180
+ const label = document.createElement('div');
181
+ label.className = 'dep-section';
182
+ label.textContent = 'Depends on:';
183
+ tooltip.appendChild(label);
184
+ const ul = document.createElement('ul');
185
+ deps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
186
+ tooltip.appendChild(ul);
187
+ }
188
+ if (rdeps.length) {
189
+ const label = document.createElement('div');
190
+ label.className = 'dep-section';
191
+ label.textContent = 'Required by:';
192
+ tooltip.appendChild(label);
193
+ const ul = document.createElement('ul');
194
+ rdeps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
195
+ tooltip.appendChild(ul);
196
+ }
197
+ if (!deps.length && !rdeps.length) {
198
+ const empty = document.createElement('div');
199
+ empty.style.marginTop = '6px';
200
+ empty.style.color = '#64748b';
201
+ empty.textContent = 'No dependencies';
202
+ tooltip.appendChild(empty);
203
+ }
204
+
205
+ tooltip.style.display = 'block';
206
+ const rect = tooltip.getBoundingClientRect();
207
+ tooltip.style.left = Math.min(ev.clientX + 12, W - rect.width - 12) + 'px';
208
+ tooltip.style.top = Math.min(ev.clientY + 12, H - rect.height - 12) + 'px';
209
+ });
210
+ g.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; });
211
+ svg.appendChild(g);
212
+ });
213
+ <\/script>
214
+ </body>
215
+ </html>`],[`<!DOCTYPE html>
216
+ <html lang="en">
217
+ <head>
218
+ <meta charset="UTF-8">
219
+ <title>Project Dependency Graph</title>
220
+ <style>
221
+ * { margin: 0; padding: 0; box-sizing: border-box; }
222
+ body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #e2e8f0; overflow: hidden; }
223
+ svg { width: 100vw; height: 100vh; }
224
+ .edge { fill: none; marker-end: url(#arrow); }
225
+ .node rect { rx: 8; ry: 8; cursor: pointer; transition: stroke-width 0.15s; }
226
+ .node text { font-size: 12px; font-weight: 600; pointer-events: none; }
227
+ .node:hover rect { stroke-width: 2.5; stroke: #fff; }
228
+ #info { position: fixed; top: 16px; right: 16px; background: #1e293b; padding: 14px 20px; border-radius: 10px; font-size: 13px; border: 1px solid #334155; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
229
+ #info b { font-variant-numeric: tabular-nums; }
230
+ .app-count { color: #fbbf24; }
231
+ .lib-count { color: #38bdf8; }
232
+ .dep-count { color: #a78bfa; }
233
+ #legend { position: fixed; bottom: 16px; left: 16px; background: #1e293b; padding: 12px 16px; border-radius: 10px; font-size: 12px; border: 1px solid #334155; display: flex; gap: 16px; align-items: center; }
234
+ .legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; }
235
+ #tooltip { position: fixed; display: none; background: #1e293b; border: 1px solid #475569; border-radius: 8px; padding: 12px 16px; font-size: 12px; max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 10; pointer-events: none; }
236
+ #tooltip h3 { font-size: 14px; margin-bottom: 6px; }
237
+ #tooltip .type-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-left: 8px; }
238
+ #tooltip .dep-section { margin-top: 8px; color: #94a3b8; }
239
+ #tooltip ul { list-style: none; padding-left: 0; margin-top: 4px; }
240
+ #tooltip li { padding: 1px 0; color: #cbd5e1; }
241
+ #tooltip li::before { content: "\\2192 "; color: #64748b; }
242
+ </style>
243
+ </head>
244
+ <body>
245
+ <div id="info">
246
+ <b class="app-count">`,`</b> apps &middot;
247
+ <b class="lib-count">`,`</b> libraries &middot;
248
+ <b class="dep-count">`,`</b> dependencies
249
+ </div>
250
+ <div id="legend">
251
+ <span><span class="legend-dot" style="background:#fbbf24"></span>Application</span>
252
+ <span><span class="legend-dot" style="background:#38bdf8"></span>Library</span>
253
+ <span style="color:#64748b">&mdash; solid = static &nbsp; - - - = implicit</span>
254
+ </div>
255
+ <div id="tooltip"></div>
256
+ <svg id="graph">
257
+ <defs>
258
+ <marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
259
+ <path d="M 0 0 L 10 5 L 0 10 z" fill="#64748b"/>
260
+ </marker>
261
+ </defs>
262
+ </svg>
263
+ <script>
264
+ const data = `,`;
265
+ const svg = document.getElementById('graph');
266
+ const tooltip = document.getElementById('tooltip');
267
+ const W = window.innerWidth, H = window.innerHeight;
268
+
269
+ // Build adjacency
270
+ const depMap = {}, rdepMap = {};
271
+ data.nodes.forEach(n => { depMap[n.name] = []; rdepMap[n.name] = []; });
272
+ data.edges.forEach(e => { depMap[e.source]?.push(e.target); rdepMap[e.target]?.push(e.source); });
273
+
274
+ // Escape text for safe DOM insertion
275
+ function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.textContent; }
276
+
277
+ // Force-directed layout
278
+ const repulsion = 5000 + data.nodes.length * 150;
279
+ const nodes = data.nodes.map(n => ({
280
+ ...n, x: W/2 + (Math.random()-0.5)*Math.min(W*0.6, 600),
281
+ y: H/2 + (Math.random()-0.5)*Math.min(H*0.6, 400), vx: 0, vy: 0
282
+ }));
283
+ const nodeMap = new Map(nodes.map(n => [n.name, n]));
284
+ const edges = data.edges.map(e => ({
285
+ source: nodeMap.get(e.source), target: nodeMap.get(e.target), type: e.type
286
+ }));
287
+
288
+ for (let iter = 0; iter < 400; iter++) {
289
+ for (let i = 0; i < nodes.length; i++) {
290
+ for (let j = i+1; j < nodes.length; j++) {
291
+ let dx = nodes[j].x - nodes[i].x, dy = nodes[j].y - nodes[i].y;
292
+ let d = Math.sqrt(dx*dx + dy*dy) || 1;
293
+ let f = repulsion / (d * d);
294
+ nodes[i].vx -= dx/d * f; nodes[i].vy -= dy/d * f;
295
+ nodes[j].vx += dx/d * f; nodes[j].vy += dy/d * f;
296
+ }
297
+ }
298
+ edges.forEach(e => {
299
+ if (!e.source || !e.target) {
300
+ return;
301
+ }
302
+ let dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
303
+ let d = Math.sqrt(dx*dx + dy*dy) || 1;
304
+ let f = (d - 180) * 0.008;
305
+ e.source.vx += dx/d * f; e.source.vy += dy/d * f;
306
+ e.target.vx -= dx/d * f; e.target.vy -= dy/d * f;
307
+ });
308
+ nodes.forEach(n => {
309
+ n.vx += (W/2 - n.x) * 0.001; n.vy += (H/2 - n.y) * 0.001;
310
+ n.x += n.vx * 0.3; n.y += n.vy * 0.3;
311
+ n.vx *= 0.75; n.vy *= 0.75;
312
+ n.x = Math.max(80, Math.min(W-80, n.x));
313
+ n.y = Math.max(40, Math.min(H-40, n.y));
314
+ });
315
+ }
316
+
317
+ // Measure text widths
318
+ const measure = document.createElementNS('http://www.w3.org/2000/svg','text');
319
+ measure.setAttribute('font-size','12'); measure.setAttribute('font-weight','600');
320
+ measure.setAttribute('font-family','system-ui');
321
+ svg.appendChild(measure);
322
+ const widths = {};
323
+ nodes.forEach(n => { measure.textContent = n.name; widths[n.name] = measure.getComputedTextLength(); });
324
+ svg.removeChild(measure);
325
+
326
+ // Render edges
327
+ edges.forEach(e => {
328
+ if (!e.source || !e.target) {
329
+ return;
330
+ }
331
+ const sw = (widths[e.source.name]||80)/2 + 12;
332
+ const tw = (widths[e.target.name]||80)/2 + 12;
333
+ const dx = e.target.x - e.source.x, dy = e.target.y - e.source.y;
334
+ const d = Math.sqrt(dx*dx+dy*dy)||1;
335
+ const x1 = e.source.x + dx/d*sw, y1 = e.source.y + dy/d*14;
336
+ const x2 = e.target.x - dx/d*tw, y2 = e.target.y - dy/d*14;
337
+ const line = document.createElementNS('http://www.w3.org/2000/svg','line');
338
+ line.setAttribute('x1',x1); line.setAttribute('y1',y1);
339
+ line.setAttribute('x2',x2); line.setAttribute('y2',y2);
340
+ line.setAttribute('class','edge');
341
+ const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
342
+ line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
343
+ line.setAttribute('stroke-width', '1.5');
344
+ if (e.type === 'implicit' || e.type === 'peerDependency') {
345
+ line.setAttribute('stroke-dasharray', '6,4');
346
+ }
347
+ if (e.type === 'devDependency') {
348
+ line.setAttribute('stroke-dasharray', '3,3');
349
+ }
350
+ svg.appendChild(line);
351
+ });
352
+
353
+ // Render nodes
354
+ nodes.forEach(n => {
355
+ const w = (widths[n.name]||80) + 24;
356
+ const h = 32;
357
+ const isApp = n.type === 'application';
358
+ const fill = isApp ? '#fbbf24' : '#38bdf8';
359
+ const textFill = '#0f172a';
360
+ const stroke = isApp ? '#f59e0b' : '#0284c7';
361
+
362
+ const g = document.createElementNS('http://www.w3.org/2000/svg','g');
363
+ g.setAttribute('class','node');
364
+ g.setAttribute('transform','translate('+(n.x - w/2)+','+(n.y - h/2)+')');
365
+ const rect = document.createElementNS('http://www.w3.org/2000/svg','rect');
366
+ rect.setAttribute('width', w); rect.setAttribute('height', h);
367
+ rect.setAttribute('fill', fill); rect.setAttribute('stroke', stroke); rect.setAttribute('stroke-width','1.5');
368
+ g.appendChild(rect);
369
+ const text = document.createElementNS('http://www.w3.org/2000/svg','text');
370
+ text.setAttribute('x', w/2); text.setAttribute('y', h/2 + 4.5);
371
+ text.setAttribute('text-anchor','middle'); text.setAttribute('fill', textFill);
372
+ text.textContent = n.name;
373
+ g.appendChild(text);
374
+
375
+ g.addEventListener('mouseenter', (ev) => {
376
+ const deps = depMap[n.name] || [];
377
+ const rdeps = rdepMap[n.name] || [];
378
+
379
+ // Build tooltip using safe DOM methods
380
+ tooltip.textContent = '';
381
+
382
+ const heading = document.createElement('h3');
383
+ heading.textContent = n.name;
384
+ const badge = document.createElement('span');
385
+ badge.className = 'type-badge';
386
+ badge.style.background = fill;
387
+ badge.style.color = '#0f172a';
388
+ badge.textContent = n.type;
389
+ heading.appendChild(badge);
390
+ tooltip.appendChild(heading);
391
+
392
+ if (deps.length) {
393
+ const label = document.createElement('div');
394
+ label.className = 'dep-section';
395
+ label.textContent = 'Depends on:';
396
+ tooltip.appendChild(label);
397
+ const ul = document.createElement('ul');
398
+ deps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
399
+ tooltip.appendChild(ul);
400
+ }
401
+ if (rdeps.length) {
402
+ const label = document.createElement('div');
403
+ label.className = 'dep-section';
404
+ label.textContent = 'Required by:';
405
+ tooltip.appendChild(label);
406
+ const ul = document.createElement('ul');
407
+ rdeps.forEach(d => { const li = document.createElement('li'); li.textContent = d; ul.appendChild(li); });
408
+ tooltip.appendChild(ul);
409
+ }
410
+ if (!deps.length && !rdeps.length) {
411
+ const empty = document.createElement('div');
412
+ empty.style.marginTop = '6px';
413
+ empty.style.color = '#64748b';
414
+ empty.textContent = 'No dependencies';
415
+ tooltip.appendChild(empty);
416
+ }
417
+
418
+ tooltip.style.display = 'block';
419
+ const rect = tooltip.getBoundingClientRect();
420
+ tooltip.style.left = Math.min(ev.clientX + 12, W - rect.width - 12) + 'px';
421
+ tooltip.style.top = Math.min(ev.clientY + 12, H - rect.height - 12) + 'px';
422
+ });
423
+ g.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; });
424
+ svg.appendChild(g);
425
+ });
426
+ <\/script>
427
+ </body>
428
+ </html>`])),s.apps,s.libs,s.edges.length,JSON.stringify(s).replaceAll("</",String.raw`<\/`))},"projectGraphToHtml"),it=j(async({logger:o,options:e,visConfig:l,workspaceRoot:d})=>{if(!d)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const c=d,{packageJsons:s,workspace:f}=ae(c,l),a=pe(c,f,s),y=!!process.stdout.isTTY&&!he,m=e.format??(y?"tui":"ascii"),v=e.output,h=e.depth??1/0;let g;switch(m){case"dot":{g=ue(a);break}case"html":{g=We(a);break}case"json":{g=JSON.stringify(ze(a),void 0,2);break}case"tui":{if(!y){g=Q(a,h);break}const x=l?.tui?.autoExit===!0?3:typeof l?.tui?.autoExit=="number"?l.tui.autoExit:0;process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const C=setInterval(()=>{},1e3),M=new Te(a);await fe(ge.createElement(He,{autoExitSeconds:x,store:M}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(C);return}default:g=Q(a,h)}v?(ce(v,g,"utf8"),o.info(`Graph written to ${v}`)):o.info(g)},"execute");export{it as default};
@@ -0,0 +1,6 @@
1
+ var re=Object.defineProperty;var E=(e,r)=>re(e,"name",{value:r,configurable:!0});import{createRequire as te}from"node:module";import{C as se,i as G,M,$ as K,z as Q,Q as le}from"./config.js";import{render as ce}from"@visulima/tui";import{h as ae,k as J,aU as de,aV as ue,aW as fe,aX as he,p as k,s as ge}from"./bin.js";import pe,{useSyncExternalStore as me,useRef as F,useCallback as _}from"react";import{o as we}from"../packem_shared/index-DH-5hsrC.js";import{sortPackageJsonStringWithOptions as U}from"#native";import{jsxs as f,jsx as s,Fragment as ye}from"react/jsx-runtime";import{Box as a}from"@visulima/tui/components/box";import{Text as c}from"@visulima/tui/components/text";import{useApp as xe}from"@visulima/tui/hooks/use-app";import{useInput as be}from"@visulima/tui/hooks/use-input";import{useWindowSize as Se}from"@visulima/tui/hooks/use-window-size";import{ScrollView as ke}from"@visulima/tui/components/scroll-view";import{ScrollBar as ve}from"@visulima/tui/components/scroll-bar";import{f as N}from"../packem_shared/utils-DrNg0XTR.js";const oe=te(import.meta.url),T=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=E(e=>{if(typeof T<"u"&&T.versions&&T.versions.node){const[r,t]=T.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return T.getBuiltinModule(e)}return oe(e)},"__cjs_getBuiltinModule"),{writeFileSync:ie}=ne("node:fs");var $e=Object.defineProperty,I=E((e,r)=>$e(e,"name",{value:r,configurable:!0}),"i$1");const q={error:0,rewritten:1,"would-rewrite":1,unchanged:2},Pe=I(e=>[...e].sort((r,t)=>q[r.status]-q[t.status]),"sortByStatusRank"),Ee=I((e,r)=>r==="all"?e:r==="errors"?e.filter(t=>t.status==="error"):r==="rewritten"?e.filter(t=>t.status==="rewritten"||t.status==="would-rewrite"):e.filter(t=>t.status==="unchanged"),"filterEntries");class Oe{static{E(this,"a")}static{I(this,"SortPackageJsonStore")}#e;#r=new Set;constructor(r){this.#e={entries:Pe(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=I(()=>this.#e,"getSnapshot");subscribe=I(r=>(this.#r.add(r),()=>{this.#r.delete(r)}),"subscribe");getFilteredEntries=I(()=>Ee(this.#e.entries,this.#e.filterType),"getFilteredEntries");#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(r,t.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}var je=Object.defineProperty,Ce=E((e,r)=>je(e,"name",{value:r,configurable:!0}),"c$2");const Re=Ce(({checkMode:e,entry:r,focused:t,scrollRef:l})=>r?f(a,{borderColor:t?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s(a,{flexShrink:0,paddingTop:1,paddingX:2,children:s(c,{bold:!0,color:"white",children:r.relativePath})}),f(ke,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[s(c,{}),f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?s(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?s(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?s(c,{bold:!0,color:"yellow",children:"rewritten"}):s(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Path:"})}),s(c,{children:r.filePath})]}),r.error?f(ye,{children:[f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"red",children:"ERROR"}),f(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Step:"})}),s(c,{color:"yellow",children:r.error.step})]}),r.error.context&&f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Position:"})}),s(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),s(a,{marginTop:1,children:s(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"white",children:"SNIPPET"}),f(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const i=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return f(a,{children:[s(c,{color:n.isErrorLine?"red":"gray",children:i}),s(c,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&s(a,{children:s(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"white",children:"KEY DIFF"}),s(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?s(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(n=>{const i=n.toIndex-n.fromIndex,d=i<0?`↑ ${String(Math.abs(i))}`:`↓ ${String(i)}`,g=i<0?"green":"yellow";return f(a,{children:[s(a,{width:28,children:s(c,{wrap:"truncate",children:n.key})}),s(a,{width:10,children:f(c,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),s(c,{color:g,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&s(a,{marginTop:1,paddingLeft:2,children:s(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):s(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:s(c,{dimColor:!0,children:"No entry selected"})}),"SortDetailPanel");var Ie=Object.defineProperty,O=E((e,r)=>Ie(e,"name",{value:r,configurable:!0}),"i");const Te={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},Me={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},Y={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},Fe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},Ne=[{count:O(e=>e.errors+e.rewrites+e.sorted,"count"),key:"all",label:"All",shortcut:"1"},{count:O(e=>e.rewrites,"count"),key:"rewritten",label:"Rewrites",shortcut:"2"},{count:O(e=>e.errors,"count"),key:"errors",label:"Errors",shortcut:"3"},{count:O(e=>e.sorted,"count"),key:"unchanged",label:"Sorted",shortcut:"4"}],Z=O(e=>{const r={errors:0,rewrites:0,sorted:0};for(const t of e)r[Y[t.status]]++;return r},"computeGroupCounts"),Ae=O(({entry:e,isSelected:r})=>{const t=Te[e.status],l=Me[e.status];return f(a,{flexShrink:0,height:1,children:[s(c,{children:r?">":" "}),s(c,{children:" "}),s(c,{bold:!0,color:t,children:`[${l}]`.padEnd(10)}),s(c,{children:" "}),s(a,{flexGrow:1,children:s(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&s(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},"EntryRow"),De=O(({color:e,count:r,label:t})=>s(a,{flexShrink:0,height:1,children:s(c,{bold:!0,color:e,children:`${t} (${String(r)})`})}),"SectionHeader"),Le=O(({counts:e,entries:r,filterType:t,focused:l,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=l?"white":"gray",g=Z(r),b=(g.errors>0?1:0)+(g.rewrites>0?1:0)+(g.sorted>0?1:0),w=t==="all"&&b>1,p=[];let m;for(const[u,y]of r.entries()){const S=Y[y.status];w&&S!==m&&(m!==void 0&&p.push({kind:"spacer"}),p.push({color:S==="errors"?"red":S==="rewrites"?"yellow":"green",count:g[S],kind:"header",label:Fe[S]}),m=S),p.push({entry:y,entryIndex:u,kind:"entry"})}const v=p.findIndex(u=>u.kind==="entry"&&u.entryIndex===o),$=v!==-1,P=p.length,h=Math.max(0,P-i);let C=0;$&&i>0&&(C=Math.min(h,Math.max(0,v-i+1)));const R=P>i&&i>0;return f(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(a,{flexShrink:0,gap:1,paddingX:1,children:[s(c,{bold:!0,inverse:!0,children:" VIS SORT "}),f(c,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),s(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Ne.map(u=>{const y=t===u.key,S=u.count(e);return f(a,{children:[s(c,{dimColor:!y,children:"["}),s(c,{bold:y,color:y?"cyan":"gray",children:u.shortcut}),s(c,{dimColor:!y,children:"]"}),f(c,{color:y?"white":"gray",children:[" ",u.label]}),f(c,{dimColor:!0,children:[" ","(",S,")"]})]},u.key)})}),f(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[s(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:s(a,{flexDirection:"column",marginTop:-C,children:p.map((u,y)=>u.kind==="spacer"?s(a,{flexShrink:0,height:1},`s-${String(y)}`):u.kind==="header"?s(De,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):s(Ae,{entry:u.entry,isSelected:u.entryIndex===o},u.entry.filePath))})}),R&&s(a,{flexShrink:0,marginLeft:1,marginRight:1,children:s(ve,{contentHeight:P,placement:"inset",scrollOffset:C,style:"block",viewportHeight:i})})]})]})},"SortListPanel");var Be=Object.defineProperty,Ge=E((e,r)=>Be(e,"name",{value:r,configurable:!0}),"T");const Je=100,H=10,_e=6,qe=1,z={1:"all",2:"rewritten",3:"errors",4:"unchanged"},He=Ge(({checkMode:e,store:r})=>{const{exit:t}=xe(),{columns:l,rows:o}=Se(),n=me(r.subscribe,r.getSnapshot),i=F(null),d=r.getFilteredEntries(),g=d[n.selectedIndex]??null,b=Z(n.entries),w=l>=Je,p=Math.max(0,o-qe),m=w?p:Math.floor(p/2),v=Math.max(0,m-_e),$=_(()=>{t()},[t]),P=F(0),h=F(void 0),C=F(!1),R=_((u,y)=>{P.current+=y,h.current=u,!C.current&&(C.current=!0,queueMicrotask(()=>{C.current=!1;const S=P.current,B=h.current;P.current=0,h.current=void 0,!(S===0||B===void 0)&&(B==="list"?r.selectStep(Math.sign(S)):i.current?.scrollBy(Math.sign(S)))}))},[r]);return be((u,y)=>{if(u==="q"||y.escape){$();return}if(z[u]){r.setFilter(z[u]);return}if(y.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?y.upArrow||u==="k"?R("list",-1):(y.downArrow||u==="j")&&R("list",1):n.focusedPanel==="detail"&&(y.upArrow||u==="k"?R("detail",-1):(y.downArrow||u==="j")&&R("detail",1))}),o<H?s(a,{alignItems:"center",justifyContent:"center",children:f(c,{color:"yellow",children:["Terminal too small. Resize to at least",H," ","rows."]})}):f(a,{flexDirection:"column",height:o,width:l,children:[f(a,{flexDirection:w?"row":"column",flexGrow:1,children:[s(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:s(Le,{counts:b,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:v})}),s(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:s(Re,{checkMode:e,entry:g,focused:n.focusedPanel==="detail",scrollRef:i})})]}),s(a,{flexShrink:0,paddingX:1,children:s(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},"VisSortPackageJsonApp");var ze=Object.defineProperty,j=E((e,r)=>ze(e,"name",{value:r,configurable:!0}),"c$1");const W=["types","node-addons","node","import","require","default"],We=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Xe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,A=j(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),L=j(e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(t=>L(t));const r={};for(const[t,l]of Object.entries(e))r[t]=L(l);return r},"cloneDeep"),Ve=j(e=>{if(!A(e))return{changed:!1,value:e};const r=Object.keys(e);return r.length===1&&r[0]==="url"&&typeof e.url=="string"?{changed:!0,value:e.url}:{changed:!1,value:e}},"tryFormatBugs"),Ke=j(e=>e.endsWith(".git")?e.slice(0,-4):e,"stripGitSuffix"),Qe=j(e=>{if(!A(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:t}=e;if(typeof t!="string")return{changed:!1,value:e};const l=We.exec(t)??Xe.exec(t);if(!l)return{changed:!1,value:e};const o=l[1],n=Ke(l[2]??"");if(!o||!n)return{changed:!1,value:e};const i=new Set(["type","url"]);for(const d of Object.keys(e))if(!i.has(d))return{changed:!1,value:e};return{changed:!0,value:`${o}/${n}`}},"tryFormatRepository"),Ue=j(e=>{const r=Object.keys(e),t=[],l=[];for(const i of W)Object.hasOwn(e,i)&&t.push(i);for(const i of r)W.includes(i)||l.push(i);const o=[...t,...l];if(o.length===r.length&&o.every((i,d)=>i===r[d]))return{changed:!1,value:e};const n={};for(const i of o)n[i]=e[i];return{changed:!0,value:n}},"orderConditions"),ee=j(e=>{if(!A(e))return{changed:!1,value:e};let r=!1;const t={};for(const[o,n]of Object.entries(e)){const i=ee(n);t[o]=i.value,i.changed&&(r=!0)}const l=Ue(t);return{changed:r||l.changed,value:l.value}},"sortExportsRecursive"),Ye=j((e,r)=>{const t=L(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(t,"bugs")){const o=Ve(t.bugs);o.changed&&(t.bugs=o.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(t,"repository")){const o=Qe(t.repository);o.changed&&(t.repository=o.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(t,"exports")&&A(t.exports)){const o=ee(t.exports);o.changed&&(t.exports=o.value,l=!0)}return{changed:l,pkg:t}},"formatPackageJsonFields");var Ze=Object.defineProperty,x=E((e,r)=>Ze(e,"name",{value:r,configurable:!0}),"c");const er=/at position (\d+)/,rr=/\(?line (\d+) column (\d+)\)?/,tr=x(e=>{const r=new Set,t=[],l=x(n=>{const i=se(n);!r.has(i)&&G(i)&&(r.add(i),t.push(i))},"addFile");l(M(e,"package.json"));const o=ae(e);if(o){const n=J(e,o);for(const i of n)l(M(e,i,"package.json"))}else{const n=M(e,"package.json");if(G(n)){const i=JSON.parse(K(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const g=J(e,d);for(const b of g)l(M(e,b,"package.json"))}}}return t},"findPackageJsonFiles"),or=x(e=>/\n([ \t]+)/.exec(e)?.[1]??" ","detectIndent"),nr=x(e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},"resolveIndentOverride"),D=x(e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),"splitList"),ir=x(e=>e.includes(`\r
2
+ `)?"crlf":"lf","detectLineEnding"),sr=new Set(["auto","crlf","lf"]),lr=x(e=>{if(e===void 0||e==="")return"auto";if(sr.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},"validateLineEnding"),cr=x((e,r,t)=>r.length===0?e:e.filter(l=>{const o=Q(t,l),n=le(l);return!r.some(i=>{const d=i.includes("/")?o:n;return we(i,d)})}),"filterByIgnore"),ar=x((e,r)=>{if(r.length===0)return e;const t={},l=new Set;for(const o of r)Object.hasOwn(e,o)&&(t[o]=e[o],l.add(o));for(const o of Object.keys(e))l.has(o)||(t[o]=e[o]);return t},"applySortOrder"),dr=x((e,r,t)=>{if(t.length===0)return e;const l={...e};for(const o of t)Object.hasOwn(r,o)&&(l[o]=r[o]);return l},"restoreUnsortedSections"),ur=x((e,r)=>{let t=1,l=1;const o=Math.min(r,e.length);for(let n=0;n<o;n++)e.codePointAt(n)===10?(t++,l=1):l++;return{column:l,line:t}},"computeLineColumn"),X=x((e,r,t=2)=>{const l=e.split(`
3
+ `);if(r<1||r>l.length)return[];const o=Math.max(0,r-1-t),n=Math.min(l.length,r+t),i=[];for(let d=o;d<n;d++)i.push({content:l[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return i},"buildSnippet"),V=x((e,r)=>{if(!(e instanceof Error))return;const t=er.exec(e.message);if(t){const{column:o,line:n}=ur(r,Number.parseInt(t[1]??"0",10));return{column:o,line:n,snippet:X(r,n)}}const l=rr.exec(e.message);if(l){const o=Number.parseInt(l[1]??"1",10);return{column:Number.parseInt(l[2]??"1",10),line:o,snippet:X(r,o)}}},"extractParseErrorContext"),fr=x((e,r)=>{const t=Object.keys(JSON.parse(e)),l=Object.keys(JSON.parse(r)),o=new Map(t.map((i,d)=>[i,d])),n=[];for(const[i,d]of l.entries()){const g=o.get(d);g!==void 0&&g!==i&&n.push({fromIndex:g,key:d,toIndex:i})}return n},"computeKeyDiff"),hr=x((e,r,t)=>{const l=r.indent??t.indent??or(e),o=r.lineEnding==="auto"?t.lineEnding??ir(e):r.lineEnding,n=U(e,{pretty:!1,sortScripts:r.sortScripts});let i=JSON.parse(n);if(r.unsorted.length>0){const w=JSON.parse(e);i=dr(i,w,r.unsorted)}i=ar(i,r.sortOrder);const d={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},g=Ye(i,d);let b=JSON.stringify(g.pkg,null,l);return r.finalNewline&&(b+=`
4
+ `),o==="crlf"&&(b=b.replaceAll(`
5
+ `,`\r
6
+ `)),b},"sortContents"),gr=x((e,r)=>{const t=tr(e),l=de(e),o=ue({cwd:e,extraPatterns:fe(l)}),n=t.filter(d=>!o.ignores(d)),i=cr(n,r,e);return{afterGitignore:n,allFiles:t,files:i}},"discoverPackageJsonFiles"),pr=x((e,{checkMode:r,cwd:t,normalized:l})=>{const o=Q(t,e)||e;let n;try{n=K(e)}catch(w){return{diff:[],error:{message:N(w),step:"read"},filePath:e,relativePath:o,status:"error"}}let i;try{i=U(n,{pretty:!1,sortScripts:l.sortScripts})}catch(w){const p={message:N(w),step:"native-sort"},m=V(w,n);return m&&(p.context=m),{diff:[],error:p,filePath:e,relativePath:o,status:"error"}}const d=l.editorconfig?he(e):{};let g;try{g=hr(n,l,d)}catch(w){const p={message:N(w),step:"json-parse"},m=V(w,n);return m&&(p.context=m),{diff:[],error:p,filePath:e,relativePath:o,status:"error"}}if(n===g)return{diff:[],filePath:e,relativePath:o,status:"unchanged"};let b;try{b=fr(n,i)}catch{b=[]}if(r)return{diff:b,filePath:e,relativePath:o,status:"would-rewrite"};try{ie(e,g,"utf8")}catch(w){return{diff:b,error:{message:N(w),step:"write"},filePath:e,relativePath:o,status:"error"}}return{diff:b,filePath:e,relativePath:o,status:"rewritten"}},"processFile"),mr=x(e=>{if(e.error&&(k.error(`${e.filePath}: ${e.error.message}`),k.info(` step: ${e.error.step}`),e.error.context)){k.info(` at line ${String(e.error.context.line)}, column ${String(e.error.context.column)}`);for(const r of e.error.context.snippet){const t=r.isErrorLine?">":" ";k.info(` ${t} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},"printStaticError"),Fr=x(async({options:e,visConfig:r,workspaceRoot:t})=>{const l=t??process.cwd(),o=r?.sortPackageJson,n=e.check||!1,i={editorconfig:e.editorconfig===!1?!1:o?.editorconfig??!0,finalNewline:e.finalNewline??o?.finalNewline??!0,formatBugs:e.formatBugs===!1?!1:o?.formatBugs??!0,formatRepository:e.formatRepository===!1?!1:o?.formatRepository??!0,ignore:[...D(e.ignore),...o?.ignore??[]],indent:nr(e.indent??o?.indent),lineEnding:lr(e.lineEnding??o?.lineEnding),sortExports:e.sortExports===!1?!1:o?.sortExports??!0,sortOrder:[...D(e.sortOrder),...o?.sortOrder??[]],sortScripts:e.sortScripts||o?.sortScripts||!1,unsorted:[...D(e.unsorted),...o?.unsorted??[]]},d=gr(l,i.ignore),{afterGitignore:g,allFiles:b,files:w}=d;if(w.length===0){b.length===0?k.info("No package.json files found."):g.length===0?k.info("All package.json files were excluded by .gitignore or workspace exclusions."):k.info("All package.json files were excluded by --ignore.");return}const p=[];for(const h of w)p.push(pr(h,{checkMode:n,cwd:l,normalized:i}));let m=0,v=0,$=0;for(const h of p)h.status==="error"?$++:h.status==="rewritten"||h.status==="would-rewrite"?m++:v++;const P=m>0||$>0;if(process.stdout.isTTY&&!ge&&P){const h=new Oe(p);await ce(pe.createElement(He,{checkMode:n,store:h}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const h of p)switch(h.status){case"error":{mr(h);break}case"rewritten":{k.success(`Sorted ${h.filePath}`);break}case"would-rewrite":{k.warn(`${h.filePath} is not sorted`);break}}if(n)m>0?(k.info(`${String(m)} file${m===1?"":"s"} not sorted, ${String(v)} already sorted`),process.exitCode=1):$===0&&k.info(`All ${String(v)} package.json file${v===1?" is":"s are"} sorted`);else{const h=[];m>0&&h.push(`sorted ${String(m)} file${m===1?"":"s"}`),v>0&&h.push(`${String(v)} already sorted`),$>0&&h.push(`${String($)} error${$===1?"":"s"}`),h.length>0&&k.info(h.join(", "))}$>0&&(process.exitCode=1)},"execute");export{X as buildSnippet,fr as computeKeyDiff,ur as computeLineColumn,Fr as default,gr as discoverPackageJsonFiles,V as extractParseErrorContext,pr as processFile};
@@ -0,0 +1,8 @@
1
+ var G=Object.defineProperty;var j=(c,o)=>G(c,"name",{value:o,configurable:!0});import{A as J,b as P,c as V,p as m,U as W,O as B,R as Z,F as f,i as q,J as K,V as Q,W as X,H as T,d as _,G as ee,s as te}from"./bin.js";import{render as O,renderToString as oe}from"@visulima/tui";import{Text as y}from"@visulima/tui/components/text";import i from"react";import{H as re,e as ne,Z as se}from"../packem_shared/ai-analysis-uYuTIIXi.js";import{U as ae,C as ie,a as U}from"../packem_shared/vis-update-app-CFrlJ3mW.js";var ce=Object.defineProperty,le=j((c,o)=>ce(c,"name",{value:o,configurable:!0}),"O");const he=le(async({argument:c,logger:o,options:e,visConfig:a,workspaceRoot:E})=>{if(!E)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=E;if(e.securityConfig){const t=J(d);if(P(a??{},t.name),e.sync&&t.name==="pnpm"){const r=V(a??{});if(r.length>0){m.info(`
2
+ Settings that would sync to pnpm-workspace.yaml:`);for(const x of r)m.success(` ${x}`)}else m.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(m.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),m.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!c?.length)return}const{packageManager:N}=W(d),F=B(d),l=a?.update??{},h=Z(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){o.info("No catalogs found.");return}const w=e.target??l.target??"latest";if(!["latest","minor","patch"].includes(w))throw new Error(`Invalid target "${w}". Use: latest, minor, or patch.`);const M={exclude:[...f(e.exclude),...f(l.exclude)],ignore:f(l.ignore),include:[...f(e.include),...f(l.include),...c],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||l.prerelease||!1,security:e.security!==!1,target:w};let R=0;for(const t of h.values())R+=t.size;const v=!!process.stdout.isTTY&&!te;let u;const z=v?(t,r)=>{u?u.rerender(i.createElement(U,{current:t,total:r})):u=O(i.createElement(U,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{o.info(`Checking ${String(t)}/${String(r)} dependencies...`)};v||o.info(`Checking ${String(R)} catalog dependencies against npm registry...
3
+ `);const k=q("socket")?void 0:K(a?.security?.socket,a?.security?.policies?.score?.minimum),{failed:C,outdated:s}=await Q(h,M,F,z,d,k,a?.security?.acceptedRisks);if(u&&(u.clear(),u.unmount()),C.length>0&&o.warn(`Failed to fetch: ${C.join(", ")}`),s.length===0){o.info("All catalog dependencies are up to date.");return}const S=e.format??l.format??"table",A=re(e.aiType??"impact"),p=e.ai?await ne(s,o,a?.ai,A):void 0;if(v&&S==="table"){const t=new ae(s,p??null),r=a?.tui?.autoExit??!1,x=r===!0?3:typeof r=="number"?r:0;await O(i.createElement(ie,{autoExitSeconds:x,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const D=process.stdout.columns||80;process.stdout.write(`
4
+ `);for(const n of s){const H=n.vulnerabilities?.length||n.socketReport&&n.socketReport.alerts.length>0,$=!!n.acceptedRisk,I=H?$?"✓":"⚠":"✓",L=$?"gray":n.updateType==="major"?"red":n.updateType==="minor"?"yellow":"green",g=n.socketReport?.score.overall,Y=g===void 0?"":` [${String(Math.round(g*100))}%]`,b=g===void 0?void 0:X(g);process.stdout.write(`${oe(i.createElement(y,null," ",i.createElement(y,{color:L},I),` ${n.packageName} ${n.currentRange} → ${n.newRange}`,i.createElement(y,{dimColor:!0},` ${n.updateType}`),b?i.createElement(y,{color:b},Y):null),{columns:D})}
5
+ `)}process.stdout.write(`
6
+ `),o.info(T(s,k?.minimumScore))}else if(S==="json"){const t={failed:C,outdated:s};p&&(t.aiAnalysis=p),process.stdout.write(`${JSON.stringify(t,void 0,2)}
7
+ `)}else S==="minimal"?process.stdout.write(`${_(s)}
8
+ `):(ee(s,o),o.info(T(s,k?.minimumScore)),p&&(o.info(""),o.info(se(p))));e.exitCode&&s.length>0&&(process.exitCode=1)},"execute");export{he as default};
@@ -0,0 +1,24 @@
1
+ var me=Object.defineProperty;var S=(r,e)=>me(r,"name",{value:e,configurable:!0});import{createRequire as he}from"node:module";import{ax as ne,u as ke,a$ as we,aT as be,h as xe,k as K,A as $e,p as b,M as Ce,s as Oe}from"./bin.js";import{i as Se}from"../packem_shared/glob-MHJQjR39-CQ2GC0b_.js";import{M as j,i as X,$ as G,B as M,n as ie,C as Pe}from"./config.js";import{render as Ne}from"@visulima/tui";import Ee from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import _e from"module-replacements/manifests/native.json"with{type:"json"};import je from"module-replacements/manifests/preferred.json"with{type:"json"};import Te,{useSyncExternalStore as Ae,useRef as De,useState as Y,useCallback as Re}from"react";import{jsx as n,jsxs as m,Fragment as U}from"react/jsx-runtime";import{Box as h}from"@visulima/tui/components/box";import{Text as s}from"@visulima/tui/components/text";import{useApp as Ie}from"@visulima/tui/hooks/use-app";import{useInput as Me}from"@visulima/tui/hooks/use-input";import{useWindowSize as Fe}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Ge}from"@visulima/tui/components/scroll-view";import{ScrollBar as Le}from"@visulima/tui/components/scroll-bar";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ const require = __cjs_mod__.createRequire(import.meta.url);
3
+ const ge=he(import.meta.url),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ye=S(r=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[e,t]=I.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return I.getBuiltinModule(r)}return ge(r)},"__cjs_getBuiltinModule"),{writeFileSync:ve}=ye("node:fs");var qe=Object.defineProperty,_=S((r,e)=>qe(r,"name",{value:e,configurable:!0}),"d$1");const ze=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ue=["overrides","pnpm","resolutions"],Be=["engines","files"],Je=_(r=>{const e=ne.coerce(r)?.major;return e!==void 0&&e>=10},"isPnpmV10Plus"),He=_(r=>{const e=j(r,"pnpm-workspace.yaml");if(!X(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:ke(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},"readPnpmWorkspaceOverrides"),Ve=_((r,e)=>{let t={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?t=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?t=r.resolutions??{}:t=r.overrides??{},{overrides:t,source:"package.json"})},"readPkgJsonOverrides"),We=_((r,e,t)=>t.name==="pnpm"&&Je(t.version)?He(r):Ve(e,t.name),"readOverrides"),Q=_((r,e)=>{const t=e;for(const a of Ue){const i=r.indexOf(a);if(i!==-1&&a!==t)return t==="overrides"?i:i+1}let o=-1;for(const a of ze){const i=r.indexOf(a);i>o&&(o=i)}if(o!==-1)return o+1;for(const a of Be){const i=r.indexOf(a);if(i!==-1)return i}return r.length},"findInsertIndex"),Xe=_((r,e)=>{const t=j(r,"pnpm-workspace.yaml");if(!X(t))throw new Error(`pnpm-workspace.yaml not found at ${t}. Cannot write overrides for pnpm v10+.`);let o=G(t);const a=`overrides:
4
+ ${Object.entries(e).map(([i,l])=>` '${i}': '${l}'`).join(`
5
+ `)}
6
+ `;o=/^overrides:\s*$/m.test(o)||/^overrides:\s*\n/m.test(o)?o.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,a):`${o.trimEnd()}
7
+
8
+ ${a}`,M(t,o)},"writePnpmWorkspaceOverrides"),Ke=_((r,e,t,o,a)=>{const i=G(r),l=we(r,i,{useEditorconfig:a});if(o==="pnpm"){const v=e.pnpm??{};if(v.overrides=t,e.pnpm)e.pnpm=v,M(r,`${JSON.stringify(e,null,l)}
9
+ `);else{const x=Object.keys(e),w=Q(x,"pnpm"),k=Object.entries(e);k.splice(w,0,["pnpm",v]),M(r,`${JSON.stringify(Object.fromEntries(k),null,l)}
10
+ `)}}else{const v=o==="yarn"||o==="bun"?"resolutions":"overrides";if(e[v])e[v]=t,M(r,`${JSON.stringify(e,null,l)}
11
+ `);else{const x=Object.keys(e),w=Q(x,v),k=Object.entries(e);k.splice(w,0,[v,t]),M(r,`${JSON.stringify(Object.fromEntries(k),null,l)}
12
+ `)}}},"writePkgJsonOverrides"),Ye=_((r,e,t,o,a)=>{if(o.name==="deno")return{added:[],updated:[]};const i=G(e),l=JSON.parse(i),{overrides:v,source:x}=We(r,l,o),w=[],k=[],c=new Set;if(o.name==="npm")for(const p of["dependencies","devDependencies"]){const g=l[p];if(g)for(const y of Object.keys(g))c.add(y)}for(const p of t){const g=v[p.original];if(typeof g=="object")continue;let y=p.spec;o.name==="npm"&&c.has(p.original)&&(y=`$${p.original}`),g!==y&&(g?k.push(p.original):w.push(p.original),v[p.original]=y)}if(w.length===0&&k.length===0)return{added:w,updated:k};const f=Object.fromEntries(Object.entries(v).sort(([p],[g])=>p.localeCompare(g)));return x==="pnpm-workspace.yaml"?Xe(r,f):Ke(e,l,f,o.name,a),{added:w,updated:k}},"applyOverrides"),Qe=_((r,e)=>{const t={bun:["bun.lock"],deno:["deno.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const o of t[e]??[]){const a=j(r,o);try{return G(a)}catch{continue}}return""},"readLockfileText"),Ze=_((r,e,t)=>{if(!r)return!1;const o=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(t){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${o}@`,"m").test(r);case"deno":return r.includes(`"${e}"`)||r.includes(`"npm:${e}@`)||r.includes(`"jsr:${e}@`);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${o}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${o}@`,"m").test(r);default:return!1}},"lockfileContainsPackage");var H={exports:{}},V,Z;function ee(){if(Z)return V;Z=1;var r=Object.defineProperty,e=S((c,f)=>r(c,"name",{value:f,configurable:!0}),"t"),t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,l=e((c,f)=>{for(var p in f)t(c,p,{get:f[p],enumerable:!0})},"__export"),v=e((c,f,p,g)=>{if(f&&typeof f=="object"||typeof f=="function")for(let y of a(f))!i.call(c,y)&&y!==p&&t(c,y,{get:e(()=>f[y],"get"),enumerable:!(g=o(f,y))||g.enumerable});return c},"__copyProps"),x=e(c=>v(t({},"__esModule",{value:!0}),c),"__toCommonJS"),w={};l(w,{PURL_Type:e(()=>k,"PURL_Type")}),V=x(w);var k=(c=>(c.APK="apk",c.BITBUCKET="bitbucket",c.COCOAPODS="cocoapods",c.CARGO="cargo",c.CHROME="chrome",c.COMPOSER="composer",c.CONAN="conan",c.CONDA="conda",c.CRAN="cran",c.DEB="deb",c.DOCKER="docker",c.GEM="gem",c.GENERIC="generic",c.GITHUB="github",c.GOLANG="golang",c.HACKAGE="hackage",c.HEX="hex",c.HUGGINGFACE="huggingface",c.MAVEN="maven",c.MLFLOW="mlflow",c.NPM="npm",c.NUGET="nuget",c.OCI="oci",c.PUB="pub",c.PYPI="pypi",c.QPKG="qpkg",c.RPM="rpm",c.SWID="swid",c.SWIFT="swift",c.VCS="vcs",c))(k||{});return V}S(ee,"requireTypes");var re;function er(){return re||(re=1,(function(r){var e=Object.defineProperty,t=S((f,p)=>e(f,"name",{value:p,configurable:!0}),"a"),o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,v=t((f,p)=>{for(var g in p)o(f,g,{get:p[g],enumerable:!0})},"__export"),x=t((f,p,g,y)=>{if(p&&typeof p=="object"||typeof p=="function")for(let u of i(p))!l.call(f,u)&&u!==g&&o(f,u,{get:t(()=>p[u],"get"),enumerable:!(y=a(p,u))||y.enumerable});return f},"__copyProps"),w=t((f,p,g)=>(x(f,p,"default"),g&&x(g,p,"default")),"__reExport"),k={};v(k,{getManifestData:t(()=>c,"getManifestData")}),w(k,ee(),r.exports);function c(f,p){try{const g=require("../manifest.json");if(!f)return g;const y=g[f];if(!y)return;if(!p)return y;const u=y.find(([C,O])=>O.package===p);return u?u[1]:void 0}catch{return}}S(c,"getManifestData"),t(c,"getManifestData"),r.exports={getManifestData:c,...ee()}})(H)),H.exports}S(er,"requireDist");var rr=er(),tr=Object.defineProperty,F=S((r,e)=>tr(r,"name",{value:e,configurable:!0}),"s");const or=F((r,e,t)=>{let o=r;if(e!=="all"&&(o=o.filter(a=>a.category===e)),t){const a=t.toLowerCase();o=o.filter(i=>i.packageName.toLowerCase().includes(a))}return o},"filterEntries");class nr{static{S(this,"h")}static{F(this,"OptimizeStore")}#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=F(()=>this.#e,"getSnapshot");subscribe=F(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=F(()=>or(this.#e.entries,this.#e.filterType,this.#e.filterText),"getFilteredEntries");#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(e,t.length-1)),this.#r()}toggleCheck(e){const t=new Set(this.#e.checkedEntries);t.has(e)?t.delete(e):t.add(e),this.#e.checkedEntries=t,this.#r()}toggleAll(){const e=this.getFilteredEntries(),t=new Set(this.#e.checkedEntries);if(e.every(o=>t.has(o.packageName)))for(const o of e)t.delete(o.packageName);else for(const o of e)t.add(o.packageName);this.#e.checkedEntries=t,this.#r()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#r()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#r()}setFilterActive(e){this.#e.filterActive=e,this.#r()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#r()}setPhase(e){this.#e.phase=e,this.#r()}setProgress(e,t){this.#e.applyProgress={current:e,total:t},this.#r()}setError(e){this.#e.error=e,this.#e.phase="error",this.#r()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}}const ce={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},ir={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},cr={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."};var ar=Object.defineProperty,sr=S((r,e)=>ar(r,"name",{value:e,configurable:!0}),"d");const lr=sr(({entry:r,focused:e,scrollRef:t})=>{const o=e?"white":"gray";if(!r)return n(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:n(s,{dimColor:!0,children:"No entry selected"})});const a=ce[r.category]??"gray";return m(h,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[n(h,{flexShrink:0,paddingTop:1,paddingX:2,children:n(s,{bold:!0,color:"white",children:r.packageName})}),m(Ge,{flexGrow:1,flexShrink:1,paddingX:2,ref:t,scrollbar:!0,scrollbarColor:"gray",children:[n(s,{}),m(h,{children:[n(h,{width:14,children:n(s,{dimColor:!0,children:"Category:"})}),n(s,{bold:!0,color:a,children:r.category})]}),m(h,{children:[n(h,{width:14,children:n(s,{dimColor:!0,children:"Replace with:"})}),n(s,{children:r.replacement})]}),r.overrideSpec&&m(h,{children:[n(h,{width:14,children:n(s,{dimColor:!0,children:"Override:"})}),n(s,{color:"cyan",children:r.overrideSpec})]}),m(h,{children:[n(h,{width:14,children:n(s,{dimColor:!0,children:"Codemod:"})}),n(s,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"white",children:"DESCRIPTION"}),n(h,{marginTop:1,paddingLeft:2,children:n(s,{children:cr[r.category]??""})})]}),r.category==="native"&&m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"green",children:"ACTION"}),n(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?m(U,{children:[m(s,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),n(s,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):m(U,{children:[m(s,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),n(s,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"cyan",children:"ACTION"}),m(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[m(s,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),n(s,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"yellow",children:"ACTION"}),n(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?m(U,{children:[m(s,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),n(s,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):m(U,{children:[m(s,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?n(s,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):n(s,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),m(h,{flexDirection:"column",marginTop:1,children:[n(s,{dimColor:!0,children:"── "}),n(s,{bold:!0,color:"white",children:"LINKS"}),m(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[m(s,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&n(s,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},"OptimizeDetailPanel");var dr=Object.defineProperty,ae=S((r,e)=>dr(r,"name",{value:e,configurable:!0}),"b$1");const pr=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],fr=ae(({checked:r,entry:e,isSelected:t})=>{const o=ce[e.category]??"white",a=ir[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return m(h,{flexShrink:0,height:1,children:[n(s,{children:t?">":" "}),m(s,{color:r?"white":"gray",children:[" ",i," "]}),n(s,{bold:!0,color:o,children:`[${a}]`.padEnd(9)}),m(s,{children:[" ",l," "]}),n(h,{flexGrow:1,children:n(s,{bold:t,inverse:t,wrap:"truncate",children:e.packageName})}),n(s,{dimColor:!0,children:" → "}),n(s,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),ur=ae(({checkedEntries:r,entries:e,filterActive:t,filterText:o,filterType:a,focused:i,isDryRun:l,scrollOffset:v,selectedIndex:x,totalEntries:w,viewportHeight:k})=>{const c=i?"white":"gray";let f=0,p=0,g=0,y=0;for(const d of e)switch(d.category){case"micro-utility":{g++;break}case"native":{f++;break}case"preferred":{p++;break}case"socket":{y++;break}}const u=[];f>0&&u.push(`${f} native`),p>0&&u.push(`${p} preferred`),g>0&&u.push(`${g} micro`),y>0&&u.push(`${y} socket`);const C=u.length>0?` (${u.join(", ")})`:"",O=r.size,T=[];for(const[d,P]of e.entries())T.push(n(fr,{checked:r.has(P.packageName),entry:P,isSelected:d===x},P.packageName));const A=e.length,R=A>k&&k>0;return m(h,{borderColor:c,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[m(h,{flexShrink:0,gap:1,paddingX:1,children:[n(s,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),m(s,{wrap:"truncate",children:[w," ","optimizations",C]}),!l&&O>0&&m(s,{dimColor:!0,children:[" ","—",O," ","selected"]})]}),n(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pr.map(d=>{const P=a===d.key;return m(h,{children:[n(s,{dimColor:!P,children:"["}),n(s,{bold:P,color:P?"cyan":"gray",children:d.shortcut}),n(s,{dimColor:!P,children:"]"}),m(s,{color:P?"white":"gray",children:[" ",d.label]})]},d.key)})}),t&&m(h,{flexShrink:0,paddingX:1,children:[n(s,{bold:!0,color:"white",children:"/ "}),n(s,{children:o}),n(s,{inverse:!0,children:" "})]}),m(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[n(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:n(h,{flexDirection:"column",marginTop:-v,children:T})}),R&&n(h,{flexShrink:0,marginLeft:1,marginRight:1,children:n(Le,{contentHeight:A,placement:"inset",scrollOffset:v,style:"block",viewportHeight:k})})]})]})},"OptimizeListPanel");var mr=Object.defineProperty,hr=S((r,e)=>mr(r,"name",{value:e,configurable:!0}),"I$1");const gr=100,te=10,oe={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},yr=hr(({isDryRun:r,store:e})=>{const{exit:t}=Ie(),{columns:o,rows:a}=Fe(),i=Ae(e.subscribe,e.getSnapshot),l=De(null),[v,x]=Y(0),[w,k]=Y(!1),c=e.getFilteredEntries(),f=c[i.selectedIndex]??null,p=o>=gr,g=Math.max(0,a-5),y=Re(u=>{t(u)},[t]);return Me((u,C)=>{if(w){u==="y"||u==="Y"?y():k(!1);return}if(i.filterActive){C.escape?(e.setFilterActive(!1),e.setFilterText("")):C.return?e.setFilterActive(!1):C.backspace||C.delete?e.setFilterText(i.filterText.slice(0,-1)):u&&!C.ctrl&&!C.meta&&e.setFilterText(i.filterText+u);return}if(u==="q"){!r&&i.checkedEntries.size>0?k(!0):y();return}if(u==="/"){e.setFilterActive(!0);return}if(oe[u]){e.setFilter(oe[u]);return}if(C.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(C.upArrow||u==="k"){const O=Math.max(0,i.selectedIndex-1);e.select(O),O<v&&x(O)}else if(C.downArrow||u==="j"){const O=Math.min(c.length-1,i.selectedIndex+1);e.select(O),O>=v+g&&x(O-g+1)}else u===" "?f&&e.toggleCheck(f.packageName):u==="a"?e.toggleAll():C.return&&!r&&i.checkedEntries.size>0&&y(e.getCheckedEntries());else i.focusedPanel==="detail"&&(C.upArrow||u==="k"?l.current?.scrollBy(-1):(C.downArrow||u==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),a<te?n(h,{alignItems:"center",justifyContent:"center",children:m(s,{color:"yellow",children:["Terminal too small. Resize to at least",te," ","rows."]})}):m(h,{flexDirection:"column",height:a,width:o,children:[m(h,{flexDirection:p?"row":"column",flexGrow:1,children:[n(h,{flexBasis:p?"50%":void 0,flexGrow:1,children:n(ur,{checkedEntries:i.checkedEntries,entries:c,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:r,scrollOffset:v,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:g})}),n(h,{flexBasis:p?"50%":void 0,flexGrow:1,children:n(lr,{entry:f,focused:i.focusedPanel==="detail",scrollRef:l})})]}),n(h,{flexShrink:0,paddingX:1,children:m(s,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),n(be,{autoExitSeconds:3,onCancel:S(()=>{k(!1)},"onCancel"),visible:w})]})},"VisOptimizeApp");var vr=Object.defineProperty,N=S((r,e)=>vr(r,"name",{value:e,configurable:!0}),"p");const W=N((r,e)=>{const t=new Set;try{const o=ie(r),a=e?[o.dependencies,o.optionalDependencies]:[o.dependencies,o.devDependencies,o.peerDependencies,o.optionalDependencies];for(const i of a)if(i)for(const l of Object.keys(i))t.add(l)}catch{}return t},"collectDepsFromPkgJson"),se=N(r=>{const e=xe(r);if(e)return K(r,e);const t=j(r,"package.json");if(!X(t))return[];try{const o=ie(t),a=Array.isArray(o.workspaces)?o.workspaces:o.workspaces?.packages;return a?K(r,a):[]}catch{return[]}},"discoverWorkspacePackages"),kr="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",wr=N(r=>`${kr}/${r}.md`,"buildE18eDocUrl"),br=N(r=>{if(r.type==="simple"&&r.replacement)return r.replacement;if(r.type==="native"){const e=r.nodeVersion?` (Node ${r.nodeVersion}+)`:"";return r.replacement?`${r.replacement}${e}`:`Native API${e}`}return r.type==="documented"&&r.docPath?"see migration guide":""},"e18eReplacementHint"),le=N(r=>{const e=[],t=N((o,a)=>{const i=o.moduleReplacements;if(Array.isArray(i))for(const l of i)r.has(l.moduleName)&&e.push({category:a,docUrl:l.type==="documented"&&l.docPath?wr(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:br(l)})},"scanManifest");return t(_e,"native"),t(je,"preferred"),t(Ee,"micro-utility"),e},"buildE18eEntries"),de=N((r,e,t,o)=>{const a=rr.getManifestData("npm")??[],i=[];for(const[,l]of a){if(l.deprecated)continue;const v=r.has(l.package),x=e?Ze(e,l.package,t.name):!1;if(!v&&!x)continue;const w=ne.coerce(l.version)?.major;if(w===void 0)continue;const k=o?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(w)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:k,packageName:l.package,replacement:l.name})}return i},"buildSocketEntries");let B;const pe=N(async()=>{if(B)return B;try{return B=(await import("module-replacements-codemods")).codemods,B}catch{return{}}},"loadCodemods"),fe=N(async r=>{try{const e=await pe();for(const t of r)t.category!=="socket"&&e[t.packageName]&&(t.hasCodemod=!0)}catch{}},"markCodemodAvailability"),ue=N(async(r,e)=>{let t=0;try{const o=(await pe())[e];if(!o)return{filesChanged:0,packageName:e};const a=o({}),i=await xr(r);for(const l of i){const v=G(l);if(v.includes(e))try{const x=await a.transform({file:{filename:l,source:v}});x!==v&&(ve(l,x,"utf8"),t++)}catch(x){process.stderr.write(`warn: codemod transform failed for ${l}: ${x instanceof Error?x.message:String(x)}
13
+ `)}}}catch{}return{filesChanged:t,packageName:e}},"runCodemod"),xr=N(async r=>Se("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),"collectSourceFiles"),$r=N(async({logger:r,options:e,visConfig:t,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const a=$e(o),i=!!e.dryRun,l=!!e.prod,v=!!e.pin;b.info(`Detected ${a.name} v${a.version}.`);const x=W(j(o,"package.json"),l),w=se(o),k=new Set(x);for(const d of w){const P=W(j(Pe(o,d),"package.json"),l);for(const D of P)k.add(D)}w.length>0&&b.info(`Scanned ${String(w.length)} workspace package${w.length===1?"":"s"}.`),b.info(`Scanning dependencies...
14
+ `);const c=Qe(o,a.name),f=le(k),p=de(k,c,a,v),g=new Set(f.map(d=>d.packageName)),y=p.filter(d=>!g.has(d.packageName)),u=[...f,...y];if(await fe(u),u.length===0){b.info("No optimizations found for your dependencies.");return}const C=!!process.stdout.isTTY&&!Oe,O=e.format==="json"||!!e.json;if(C&&!i&&!O){const d=new nr(u),P=await Ne(Te.createElement(yr,{isDryRun:!1,store:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),D=Array.isArray(P)?P:[];if(D.length===0){b.info("No optimizations selected.");return}const L=D.filter($=>$.category!=="socket"&&$.hasCodemod),q=D.filter($=>$.category!=="socket"&&!$.hasCodemod),J=D.filter($=>$.category==="socket");if(L.length>0){b.info(`
15
+ Running ${String(L.length)} codemod${L.length===1?"":"s"}...
16
+ `);for(const $ of L){const E=await ue(o,$.packageName);E.filesChanged>0?b.success(` ${$.packageName}: ${String(E.filesChanged)} file${E.filesChanged===1?"":"s"} updated`):b.info(` ${$.packageName}: no files changed`)}}if(q.length>0){b.warn(`
17
+ ${String(q.length)} selected replacement${q.length===1?"":"s"} require manual migration (no codemod available):`);for(const $ of q)b.info(` ${$.packageName} → ${$.replacement}`);b.notice(" Replace usage in your source code, then remove from dependencies.")}if(J.length>0){const $=J.filter(z=>z.overrideSpec).map(z=>({original:z.packageName,spec:z.overrideSpec})),E=Ye(o,j(o,"package.json"),$,a,t?.editorconfig??!0);E.added.length>0&&b.success(`
18
+ Added ${String(E.added.length)} override${E.added.length===1?"":"s"}.`),E.updated.length>0&&b.success(`Updated ${String(E.updated.length)} override${E.updated.length===1?"":"s"}.`)}if(J.length>0&&e.install!==!1){b.info(`
19
+ Running ${a.name} install to update lockfile...`);const $=Ce(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},o,r);$!==0&&b.warn(`${a.name} install exited with code ${String($)}. Run it manually.`)}b.info(""),b.success("Optimization complete.");return}if(O){process.stdout.write(`${JSON.stringify({e18e:f.map(d=>({category:d.category,hasCodemod:d.hasCodemod,packageName:d.packageName,replacement:d.replacement})),packageManager:a.name,socket:y.map(d=>({overrideSpec:d.overrideSpec,packageName:d.packageName,replacement:d.replacement})),total:u.length,workspaces:w.length},void 0,2)}
20
+ `);return}const T=f.filter(d=>d.category==="native"),A=f.filter(d=>d.category==="preferred"),R=f.filter(d=>d.category==="micro-utility");if(T.length>0){b.info(`Native replacements (${String(T.length)}):`);for(const d of T)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(A.length>0){b.info(`
21
+ Preferred alternatives (${String(A.length)}):`);for(const d of A)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(R.length>0){b.info(`
22
+ Micro-utilities (${String(R.length)}):`);for(const d of R)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(y.length>0){b.info(`
23
+ Socket.dev overrides (${String(y.length)}):`);for(const d of y)b.info(` ${d.packageName} → ${d.overrideSpec}`)}b.info(`
24
+ Total: ${String(u.length)} optimizations available (⚙ = codemod available).`),i&&b.notice("Run without --dry-run for interactive selection.")},"execute"),zr=Object.defineProperty({__proto__:null,buildE18eEntries:le,buildSocketEntries:de,collectDepsFromPkgJson:W,default:$r,discoverWorkspacePackages:se,markCodemodAvailability:fe,runCodemod:ue},Symbol.toStringTag,{value:"Module"});export{se as A,le as F,ue as I,Qe as L,de as T,fe as U,Ye as a,zr as h,W as x};