1 line
7.9 KiB
JavaScript
1 line
7.9 KiB
JavaScript
import{C as e,Ct as t,E as n,Mt as r,Qt as i,W as a,Y as o,_ as s,c,dt as l,ft as u,g as d,h as f,m as p,tn as m,v as h,w as g}from"./vendor/json-editor-vue-ddj4xtqm.js";import"./vendor/shiki-kunkft64.js";import{C as _,D as v,G as y,Ht as b,In as x,Jt as S,Kn as C,N as w,Nn as T,T as E,c as D,et as O,f as k,k as A,kt as j,l as M,o as N,q as P,qt as F,t as I,y as L}from"#entry";import"./client-cbmkjf3j.js";import{t as R}from"./ncode-block-j2hcqwrp.js";import{t as z}from"./composables-g8w9dpc0.js";import{t as B}from"./ncheckbox-f4a8016e.js";import{t as V}from"./filepath-item-osqp88cx.js";import{t as H}from"./help-fab-bhtk9hzf.js";var U={"h-full":``,grid:`~ rows-[max-content_1fr]`},W={flex:`~ wrap`,"w-full":``},G=[`onClick`],K={key:0,flex:`~ col gap-4 items-center justify-center`,p4:``},q={grid:`~ cols-[30px_1fr] gap-x-2 gap-y-3 items-center justify-center`,"w-100":``},J=`/__nuxt_devtools__/client`,Y=n({__name:`BuildAnalyzeDetails`,props:{current:{},prev:{}},setup(n){let d=n,_=`${x().app.baseURL.replace(J,`/`)}/__nuxt_devtools__/analyze/`.replace(/\/+/g,`/`),v=p(()=>{let e=[{name:`Overview`,id:`overview`}];return d.current.features.bundleClient&&e.push({name:`Client Bundle`,id:`bundle-client`}),d.current.features.bundleNitro&&e.push({name:`Nitro Bundle`,id:`bundle-nitro`}),d.current.features.viteInspect&&e.push({name:`Vite Inspect`,id:`vite-inspect`}),e}),y=t(v.value[0]);function w(e){return`${((e.endTime-e.startTime)/1e3).toFixed(1)}s`}function T(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(1)}GB`}async function E(e){return b.clearAnalyzeBuilds(await P(),[e])}return(t,d)=>{let p=V,b=A;return a(),h(`div`,U,[f(`div`,W,[(a(!0),h(c,null,o(v.value,(e,t)=>(a(),h(`button`,{key:t,px4:``,py2:``,border:`r base`,hover:`bg-active`,class:i(e.id===y.value?.id?``:`border-b`),onClick:t=>y.value=e},[f(`div`,{class:i(e.id===y.value?.id?``:`op30`)},m(e.name),3)],10,G))),128)),d[1]||=f(`div`,{border:`b base`,"flex-auto":``},null,-1)]),y.value?.id===`overview`?(a(),h(`div`,K,[d[15]||=f(`div`,{"flex-auto":``},null,-1),f(`div`,q,[d[10]||=f(`div`,{"i-carbon-commit":``,"text-xl":``},null,-1),f(`div`,null,[d[2]||=f(`div`,{"text-sm":``,op50:``},` Name `,-1),f(`div`,null,m(n.current.name),1)]),d[11]||=f(`div`,{"i-carbon-time":``,"text-xl":``},null,-1),f(`div`,null,[d[3]||=f(`div`,{"text-sm":``,op50:``},` Build duration `,-1),f(`div`,null,m(w(n.current)),1)]),n.current.size?.clientBundle?(a(),h(c,{key:0},[d[5]||=f(`div`,{"i-carbon-cics-program":``,"text-xl":``},null,-1),f(`div`,null,[d[4]||=f(`div`,{"text-sm":``,op50:``},` Client bundle size `,-1),f(`div`,null,m(T(n.current.size.clientBundle)),1)])],64)):s(``,!0),n.current.size?.nitroBundle?(a(),h(c,{key:1},[d[7]||=f(`div`,{"i-carbon-bare-metal-server":``,"text-xl":``},null,-1),f(`div`,null,[d[6]||=f(`div`,{"text-sm":``,op50:``},` Nitro bundle size `,-1),f(`div`,null,m(T(n.current.size.nitroBundle)),1)])],64)):s(``,!0),d[12]||=f(`div`,{"i-carbon-edge-node":``,"text-xl":``},null,-1),f(`div`,null,[d[8]||=f(`div`,{"text-sm":``,op50:``},` Built `,-1),f(`div`,null,m(r(S)(new Date(n.current.endTime))),1)]),d[13]||=f(`div`,{"i-carbon:folder-parent":``,"text-xl":``},null,-1),f(`div`,null,[d[9]||=f(`div`,{"text-sm":``,op50:``},` Report Path `,-1),g(p,{filepath:n.current.analyzeDir},null,8,[`filepath`])])]),d[16]||=f(`div`,{"flex-auto":``},null,-1),g(b,{n:`rose`,icon:`carbon-delete`,onClick:d[0]||=e=>E(n.current.name)},{default:l(()=>[...d[14]||=[e(` Delete this report `,-1)]]),_:1})])):s(``,!0),d._lazyshow1||y.value?.id===`bundle-client`?(d._lazyshow1=!0,a(),h(c,null,[u(f(`iframe`,{src:`${r(_)}${n.current.slug}/client.html`,"h-full":``,"w-full":``},null,8,[`src`]),[[C,y.value?.id===`bundle-client`]])],64)):s(`v-show-if`,!0),d._lazyshow2||y.value?.id===`bundle-nitro`?(d._lazyshow2=!0,a(),h(c,null,[u(f(`iframe`,{src:`${r(_)}${n.current.slug}/nitro.html`,"h-full":``,"w-full":``},null,8,[`src`]),[[C,y.value?.id===`bundle-nitro`]])],64)):s(`v-show-if`,!0),d._lazyshow3||y.value?.id===`vite-inspect`?(d._lazyshow3=!0,a(),h(c,null,[u(f(`iframe`,{src:`${r(_)}${n.current.slug}/.vite-inspect/`,"h-full":``,"w-full":``},null,8,[`src`]),[[C,y.value?.id===`vite-inspect`]])],64)):s(`v-show-if`,!0)])}}}),X=Object.assign(Y,{__name:`BuildAnalyzeDetails`}),Z={},Q={class:`markdown-body`};function $(t,n){return a(),h(`div`,Q,[...n[0]||=[f(`template`,null,[f(`div`,{class:`markdown-body`},[f(`h1`,null,`Build Analyze`),f(`p`,null,[e(`DevTools provides a build analyze tool to help you understand the size of your app in production. Whenever you start a new build, it runs the command `),f(`code`,{"v-pre":``},`nuxt build --analyze`),e(` and present the output data directly in DevTools for easy browsing and comparing.`)])])],-1)]])}var ee=w(Z,[[`render`,$]]),te={flex:`~ col`},ne=[`onClick`],re={flex:`~ gap-1 items-center wrap`,"w-full":``,"text-sm":``,op60:``},ie={flex:`~ items-center justify-center wrap`,p4:``},ae={flex:`~ col gap-1`,"w-250":``,p4:``},oe={flex:`~ gap-3`,mt2:``,"justify-end":``},se=n({__name:`analyze-build`,setup(n){let u=F(),y=O(),x=T(),C=j(`analyze-build:slug`,``),w=p(()=>y.value?.builds.find(e=>e.slug===C.value)??y.value?.builds[0]),z=t(!1),V=t(``),U=p(()=>y.value?.builds.some(e=>e.name===V.value.trim()));async function W(){V.value=await b.generateAnalyzeBuildName(),await u.start()&&(L(`analyze-build:start`),I.value={name:V.value,processId:await b.startAnalyzeBuild(await P(),V.value)},z.value&&q())}let G=_();function K(e){return`${((e.endTime-e.startTime)/1e3).toFixed(1)}s`}function q(){I.value?.processId&&(G.value=I.value.processId,x.push(`/modules/terminals`))}return N(()=>[{id:`action:analyze-build: start`,title:`Start a new analyze build`,icon:`i-carbon-edge-node`,action:W}]),(t,n)=>{let p=A,_=X,b=k,x=M,T=D,O=v,j=R,N=B,P=E,F=ee,L=H;return a(),h(c,null,[g(x,{"left-size":30},{left:l(()=>[f(`div`,te,[(a(!0),h(c,null,o(r(y)?.builds,e=>(a(),h(c,{key:e.slug},[f(`button`,{flex:`~ col gap1`,p3:``,"hover:bg-active":``,class:i(e.slug===w.value?.slug?`text-primary bg-active`:``),onClick:t=>C.value=e.slug},[f(`code`,null,m(e.name),1),f(`div`,re,[n[4]||=f(`div`,{"i-carbon-time":``},null,-1),f(`span`,null,m(K(e)),1),n[5]||=f(`div`,{"flex-auto":``},null,-1),f(`span`,null,m(r(S)(new Date(e.endTime))),1)])],10,ne),n[6]||=f(`div`,{"x-divider":``},null,-1)],64))),128)),f(`div`,ie,[r(I)?(a(),d(p,{key:1,n:`primary`,icon:`carbon-circle-dash animate-spin`,onClick:n[1]||=e=>q()},{default:l(()=>[...n[8]||=[e(` Building... `,-1)]]),_:1})):(a(),d(p,{key:0,n:`primary`,icon:`carbon-edge-node`,onClick:n[0]||=e=>W()},{default:l(()=>[...n[7]||=[e(` Start a new build `,-1)]]),_:1}))])])]),right:l(()=>[w.value?(a(),d(_,{key:0,current:w.value},null,8,[`current`])):(a(),d(b,{key:1}))]),_:1}),g(r(u),null,{default:l(({resolve:t})=>[g(P,{"model-value":!0,onClose:e=>t(!1)},{default:l(()=>[f(`div`,ae,[n[13]||=f(`h3`,{class:`text-lg font-medium leading-6`,mb2:``},` Start analyze build? `,-1),n[14]||=f(`p`,{op50:``},` Enter the name of the build: `,-1),g(T,{modelValue:V.value,"onUpdate:modelValue":n[2]||=e=>V.value=e,placeholder:`Build name`},null,8,[`modelValue`]),U.value?(a(),d(O,{key:0,"n-orange":``},{default:l(()=>[...n[9]||=[e(` A build with the same name already exists, continue would overrides the previous build result. `,-1)]]),_:1})):s(``,!0),n[15]||=f(`div`,{my3:``,"x-divider":``},null,-1),n[16]||=f(`p`,{op50:``},` The following command will be executed in your terminal: `,-1),g(j,{code:`npx nuxi analyze --no-serve --name=${V.value}`,lang:`bash`,px4:``,py2:``,border:`~ base rounded`,lines:!1},null,8,[`code`]),g(N,{modelValue:z.value,"onUpdate:modelValue":n[3]||=e=>z.value=e,mt2:``,n:`primary`},{default:l(()=>[...n[10]||=[e(` Navigate to terminal `,-1)]]),_:1},8,[`modelValue`]),f(`div`,oe,[g(p,{onClick:e=>t(!1)},{default:l(()=>[...n[11]||=[e(` Cancel `,-1)]]),_:1},8,[`onClick`]),g(p,{n:`solid primary`,onClick:e=>t(!0)},{default:l(()=>[...n[12]||=[e(` Start `,-1)]]),_:1},8,[`onClick`])])])]),_:2},1032,[`onClose`])]),_:1}),g(L,null,{default:l(()=>[g(F)]),_:1})],64)}}});export{se as default}; |