@juejin-opensource/jusage 0.1.6-beta.0 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/args.d.ts +20 -0
- package/dist/args.js +121 -0
- package/dist/daemon.d.ts +2 -2
- package/dist/daemon.js +8 -7
- package/dist/dashboard/assets/Check-C6Vp6SAU.js +1 -0
- package/dist/dashboard/assets/click-idle-CXAVCmiH.png +0 -0
- package/dist/dashboard/assets/dashboard-CW-mCwMR.js +55 -0
- package/dist/dashboard/assets/download-_xhCt7jY.js +1 -0
- package/dist/dashboard/assets/downloads-63AG5C_E.js +1 -0
- package/dist/dashboard/assets/hawking-idle-QoXt5bST.png +0 -0
- package/dist/dashboard/assets/index-3miiAdwH.js +143 -0
- package/dist/dashboard/assets/{index-I_ub2jqy.css → index-C1vokUY2.css} +1 -1
- package/dist/dashboard/assets/{index-C28OANM4.js → index-DikHz9Xg.js} +1 -1
- package/dist/dashboard/assets/{pricing-C1AgdgdM.js → pricing-Btfm94JM.js} +1 -1
- package/dist/dashboard/assets/rank-LoqZH6uK.js +16 -0
- package/dist/dashboard/assets/{settings-BA_UlPf3.js → settings-BzyD7YMM.js} +1 -1
- package/dist/dashboard/assets/useLocalStorage-C_Z-N_8Q.js +1 -0
- package/dist/dashboard/assets/yoyo-idle-DDvV3ieO.png +0 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/index.d.ts +1 -10
- package/dist/index.js +21 -93
- package/dist/service-linux.js +6 -1
- package/dist/service.d.ts +4 -1
- package/dist/service.js +19 -8
- package/package.json +13 -13
- package/dist/dashboard/assets/ChevronDown-raqOGGZY.js +0 -1
- package/dist/dashboard/assets/click-idle-6pQvdt8N.png +0 -0
- package/dist/dashboard/assets/dashboard-2aS4UXAq.js +0 -55
- package/dist/dashboard/assets/download-w1_SlsVA.js +0 -1
- package/dist/dashboard/assets/downloads-DRt36RTZ.js +0 -1
- package/dist/dashboard/assets/env-Bahc-RuR.js +0 -1
- package/dist/dashboard/assets/hawking-idle-C6M3ZvDm.png +0 -0
- package/dist/dashboard/assets/index-DpG68XJd.js +0 -143
- package/dist/dashboard/assets/rank-DNpmekT1.js +0 -16
- package/dist/dashboard/assets/yoyo-idle-DmXh5tLT.png +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as e,k as l,B as R,bb as T,bc as q,bd as K}from"./index-3miiAdwH.js";import{r as M,d as O,a as V,g as Y,f as Q,D as k,m as X,b as ee,G as se,c as ae}from"./downloads-63AG5C_E.js";import{P as i,C as v}from"./Check-C6Vp6SAU.js";const te=a=>r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},a),r.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 2.5H8A1.5 1.5 0 0 0 6.5 4v1H8a3 3 0 0 1 3 3v1.5h1A1.5 1.5 0 0 0 13.5 8V4A1.5 1.5 0 0 0 12 2.5M11 11h1a3 3 0 0 0 3-3V4a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v1H4a3 3 0 0 0-3 3v4a3 3 0 0 0 3 3h4a3 3 0 0 0 3-3zM4 6.5h4A1.5 1.5 0 0 1 9.5 8v4A1.5 1.5 0 0 1 8 13.5H4A1.5 1.5 0 0 1 2.5 12V8A1.5 1.5 0 0 1 4 6.5",clipRule:"evenodd"})),ne={new_user:{badge:"Juejin Usage",headline:["Cursor、Claude、Codex","多工具 Token 与费用","本地面板一张表看完。"],description:"汇总你实际在用的 AI 编码工具用量与趋势,安装后即可查看。"},uninstalled:{badge:"客户端暂未连接",headline:["客户端暂未连接","启动后继续","同步本机用量。"],description:"下载并打开 Juejin Usage,即可把本机 AI 用量同步回这块面板。"}},re="/e1.png",j=[{id:"install-start",label:"npm",command:"npm i -g @juejin-opensource/jusage && jusage service start"},{id:"npx",label:"npx",command:"npx @juejin-opensource/jusage start"}],L="tud.downloadTarget";function H(){try{const a=sessionStorage.getItem(L);if(a&&k.some(o=>o.id===a))return a}catch{}return null}function oe(a){try{sessionStorage.setItem(L,a)}catch{}}function ie({reason:a}){const o=ne[a],[d,y]=r.useState(()=>{const s=H();return s||(typeof navigator>"u"?"macos-arm":M(V(navigator.userAgent,navigator.platform),O(navigator.userAgent)))}),[_,G]=r.useState({}),[P,B]=r.useState(),[h,C]=r.useState(!1),[p,A]=r.useState(!1),[S,U]=r.useState("npx"),[u,g]=r.useState(!1),[z,F]=r.useState(null),I=r.useRef(H()!==null),f=Y(d),Z=ae(P),b=j.find(s=>s.id===S)??j[0];r.useEffect(()=>{var c,x;let s=!1;const t=navigator,n=(m,W)=>{var E;s||I.current||y(M(V(t.userAgent,t.platform,W??((E=t.userAgentData)==null?void 0:E.platform)??""),O(t.userAgent,m)))};return n(),(x=(c=t.userAgentData)==null?void 0:c.getHighEntropyValues)==null||x.call(c,["architecture","platform"]).then(m=>{n(m.architecture,m.platform)}).catch(()=>{}),()=>{s=!0}},[]),r.useEffect(()=>{let s=!1;return Q().then(t=>{if(s)return;const n={};for(const c of k){const x=X(t.assets,c.id);x&&(n[c.id]=x)}G(n),B(t.source)}).catch(()=>{}),()=>{s=!0}},[]),r.useEffect(()=>{if(!u)return;const s=window.setTimeout(()=>g(!1),1600);return()=>window.clearTimeout(s)},[u]),r.useEffect(()=>{let s=!1;return fetch("https://api.github.com/repos/juejin-cn/juejin-usage",{headers:{Accept:"application/vnd.github+json"}}).then(t=>t.ok?t.json():null).then(t=>{const n=t==null?void 0:t.stargazers_count;s||typeof n!="number"||!Number.isFinite(n)||F(le(n))}).catch(()=>{}),()=>{s=!0}},[]);const $=s=>{const t=_[s]??Z,n=document.createElement("a");n.href=t,n.rel="noopener noreferrer",n.target="_blank",_[s]&&(n.download=""),document.body.append(n),n.click(),n.remove()},J=async()=>{try{await navigator.clipboard.writeText(b.command),g(!0)}catch{g(!1)}};return e.jsx("section",{className:"flex min-h-[calc(100svh-9rem)] items-start pt-4 pb-10 sm:pt-6 sm:pb-14 lg:pt-8",children:e.jsxs("div",{className:"flex w-full flex-col gap-14 sm:gap-16 lg:gap-20",children:[e.jsxs("div",{className:"grid w-full items-start gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)] lg:gap-16 xl:gap-20",children:[e.jsxs("div",{className:"max-w-2xl motion-safe:animate-[fade-up_420ms_ease-out] lg:max-w-none",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-base text-muted",children:[e.jsx("span",{children:o.badge}),e.jsx("span",{"aria-hidden":"true",className:"text-foreground/25",children:"·"}),f.os==="windows"?e.jsx(N,{className:"size-4 text-foreground/70"}):e.jsx(w,{className:"size-4 text-foreground/70"}),e.jsxs("span",{children:["适用于 ",f.badgePlatform]})]}),e.jsxs("h1",{className:"mt-6 text-[2.15rem] leading-[1.15] font-semibold tracking-tight text-foreground sm:text-5xl sm:leading-[1.12] lg:text-[3.15rem] lg:leading-[1.1]",children:[o.headline[0],e.jsx("br",{}),o.headline[1],e.jsx("br",{}),o.headline[2]]}),e.jsx("p",{className:"mt-5 max-w-xl text-lg leading-8 text-muted",children:o.description}),e.jsxs("div",{className:"mt-9 flex flex-col gap-4",children:[e.jsxs("div",{"aria-label":"下载客户端",className:"inline-flex max-w-full shrink-0 overflow-hidden rounded-full shadow-[0_1px_2px_rgb(0_0_0/0.06)]",role:"group",children:[e.jsxs("button",{className:l(D,"rounded-l-full ps-6 pe-5"),type:"button",onClick:()=>$(d),children:[f.os==="windows"?e.jsx(N,{className:"size-4.5"}):e.jsx(w,{className:"size-4.5"}),f.label]}),e.jsxs(i,{isOpen:h,onOpenChange:C,children:[e.jsx(R,{"aria-expanded":h,"aria-haspopup":"menu","aria-label":"选择其它系统",className:l(D,"h-14! min-h-14! min-w-14 rounded-l-none rounded-r-full border-0 p-0 shadow-none","bg-[#1e80ff]! text-white! hover:bg-[#1171ee]!","relative before:absolute before:inset-y-2.5 before:left-0 before:w-px before:bg-white/30","dark:bg-[#4b9cff]! dark:hover:bg-[#3a8ff0]!"),isIconOnly:!0,variant:"primary",children:e.jsx(T,{"aria-hidden":"true",className:l("size-4.5 transition-transform duration-200 motion-reduce:transition-none",h&&"rotate-180")})}),e.jsx(i.Content,{className:"min-w-56 overflow-hidden rounded-[10px] border-0 bg-overlay p-0 text-overlay-foreground shadow-surface",placement:"bottom start",children:e.jsxs(i.Dialog,{className:"p-0 outline-none",children:[e.jsx(i.Heading,{className:"sr-only",children:"选择下载平台"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:k.map(s=>{const t=s.id===d;return e.jsxs("button",{"aria-current":t?"true":void 0,className:l("flex min-h-11 w-full cursor-pointer items-center gap-2 px-3 text-left text-sm","transition-colors duration-150","hover:bg-surface-secondary","focus-visible:bg-surface-secondary focus-visible:outline-none",t?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{I.current=!0,oe(s.id),y(s.id),C(!1)},children:[s.os==="windows"?e.jsx(N,{className:"size-4 text-foreground/70"}):e.jsx(w,{className:"size-4 text-foreground/70"}),e.jsx("span",{className:"min-w-0 flex-1",children:s.menuLabel}),t?e.jsx(v,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):null]},s.id)})})]})})]})]}),e.jsxs("div",{className:"flex min-h-14 min-w-0 max-w-2xl items-center gap-2 rounded-2xl border border-border bg-surface-secondary/80 p-2 ps-3 dark:bg-overlay/60",children:[e.jsxs(i,{isOpen:p,onOpenChange:A,children:[e.jsxs(R,{"aria-expanded":p,"aria-haspopup":"menu","aria-label":"选择 CLI 启动方式",className:"h-10 min-h-10 shrink-0 gap-1 rounded-full bg-background/80 px-3 text-xs font-medium text-foreground shadow-none hover:bg-background dark:bg-black/10 dark:hover:bg-black/20",variant:"secondary",children:[e.jsx("span",{children:b.label}),e.jsx(T,{"aria-hidden":"true",className:l("size-3.5 transition-transform duration-200 motion-reduce:transition-none",p&&"rotate-180")})]}),e.jsx(i.Content,{className:"min-w-60 overflow-hidden rounded-[10px] border-0 bg-overlay p-0 text-overlay-foreground shadow-surface",placement:"bottom start",children:e.jsxs(i.Dialog,{className:"p-0 outline-none",children:[e.jsx(i.Heading,{className:"sr-only",children:"选择 CLI 启动方式"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:j.map(s=>{const t=s.id===S;return e.jsxs("button",{"aria-current":t?"true":void 0,className:l("flex min-h-11 w-full cursor-pointer items-center gap-2 px-3 text-left text-sm","transition-colors duration-150 hover:bg-surface-secondary","focus-visible:bg-surface-secondary focus-visible:outline-none",t?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{U(s.id),A(!1)},children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.label}),t?e.jsx(v,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):null]},s.id)})})]})})]}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden rounded-xl bg-background/75 px-3 py-2 dark:bg-black/10",children:e.jsxs("code",{className:"block overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground/85 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:["$ ",b.command]})}),e.jsx("button",{"aria-label":u?"安装命令已复制":"复制 CLI 安装命令",className:l("inline-flex size-11 shrink-0 items-center justify-center rounded-full","text-muted transition-colors duration-150","hover:bg-background hover:text-foreground","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent","touch-manipulation"),type:"button",onClick:()=>{J()},children:u?e.jsx(v,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):e.jsx(te,{"aria-hidden":"true",className:"size-4"})})]})]}),e.jsx("p",{"aria-live":"polite",className:"sr-only",children:u?"安装命令已复制":""}),e.jsxs("p",{className:"mt-5 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted",children:[e.jsx("span",{children:f.requirement}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:"CLI 需 Node.js 20+"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("a",{className:"inline-flex items-center gap-1 text-foreground/70 transition-colors hover:text-foreground",href:ee,rel:"noopener noreferrer",target:"_blank",children:[e.jsx(de,{className:"size-3.5"}),"Gitee"]})]}),e.jsxs("a",{"aria-label":"在 GitHub 上 Star 本项目",className:"mt-4 flex w-full max-w-xl items-center gap-4 rounded-2xl border border-border bg-surface-secondary/80 px-5 py-4 shadow-[0_1px_2px_rgb(0_0_0/0.06)] outline-offset-2 transition-colors hover:bg-surface-secondary focus-visible:outline-2 focus-visible:outline-accent dark:bg-overlay/60 dark:hover:bg-overlay/80",href:se,rel:"noopener noreferrer",target:"_blank",children:[e.jsx(ce,{className:"size-8 shrink-0"}),e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-foreground",children:"⭐️ Star"}),z?e.jsx("span",{className:"text-sm font-medium tabular-nums text-foreground/55",children:z}):null]}),e.jsx("span",{className:"mt-0.5 block text-sm leading-6 text-muted",children:"开源共享,欢迎提 Issue 与贡献代码"})]})]})]}),e.jsx("div",{className:"min-w-0 motion-safe:animate-[fade-up_520ms_ease-out]",children:e.jsx("figure",{className:"overflow-hidden rounded-2xl border border-border/80 bg-surface shadow-[0_24px_48px_-28px_rgb(15_23_42/0.45)] dark:shadow-[0_24px_48px_-24px_rgb(0_0_0/0.65)]",children:e.jsx("img",{alt:"Juejin Usage 用量看板界面预览:费用、Token、热力图与趋势图",className:"h-auto w-full",decoding:"async",fetchPriority:"high",height:1560,src:re,width:2102})})})]}),e.jsxs("section",{"aria-labelledby":"supported-tools-heading",className:"w-full",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight text-foreground sm:text-xl",id:"supported-tools-heading",children:"支持的工具"}),e.jsx("div",{className:"mt-4",children:e.jsx(q,{className:"lg:grid-cols-3",collapsible:!0})})]})]})})}const D=l("inline-flex h-14 min-h-14 cursor-pointer items-center justify-center gap-2.5","bg-[#1e80ff] text-base font-medium whitespace-nowrap text-white","transition-colors duration-200 motion-reduce:transition-none","hover:bg-[#1171ee] active:brightness-[0.96]","focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#1e80ff]","dark:bg-[#4b9cff] dark:hover:bg-[#3a8ff0] dark:focus-visible:outline-[#4b9cff]","touch-manipulation");function le(a){if(a<1e3)return String(Math.floor(a));const o=a/1e3,d=a>=1e4?0:1;return`${o.toFixed(d).replace(/\.0$/,"")}k`}function ce({className:a}){return e.jsx("svg",{"aria-hidden":"true",className:a,fill:"currentColor",focusable:"false",overflow:"visible",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M10.226 17.284c-2.965-.36-5.054-2.493-5.054-5.256 0-1.123.404-2.336 1.078-3.144-.292-.741-.247-2.314.09-2.965.898-.112 2.111.36 2.83 1.01.853-.269 1.752-.404 2.853-.404 1.1 0 1.999.135 2.807.382.696-.629 1.932-1.1 2.83-.988.315.606.36 2.179.067 2.942.72.854 1.101 2 1.101 3.167 0 2.763-2.089 4.852-5.098 5.234.763.494 1.28 1.572 1.28 2.807v2.336c0 .674.561 1.056 1.235.786 4.066-1.55 7.255-5.615 7.255-10.646C23.5 6.188 18.334 1 11.978 1 5.62 1 .5 6.188.5 12.545c0 4.986 3.167 9.12 7.435 10.669.606.225 1.19-.18 1.19-.786V20.63a2.9 2.9 0 0 1-1.078.224c-1.483 0-2.359-.808-2.987-2.313-.247-.607-.517-.966-1.034-1.033-.27-.023-.359-.135-.359-.27 0-.27.45-.471.898-.471.652 0 1.213.404 1.797 1.235.45.651.921.943 1.483.943.561 0 .92-.202 1.437-.719.382-.381.674-.718.944-.943"})})}function w({className:a}){return e.jsx("svg",{"aria-hidden":"true",className:a,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})})}function de({className:a}){return e.jsx("svg",{"aria-hidden":"true",className:a,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296z"})})}function N({className:a}){return e.jsx("svg",{"aria-hidden":"true",className:a,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 5.2 11.2 4v7.4H3V5.2Zm8.9-1.4L21 2.6v8.8h-9.1V3.8ZM3 13.4h8.2V21L3 19.7v-6.3Zm8.9 0H21V21.4l-9.1-1.3v-6.7Z"})})}function me(){const a=K(),o=(a==null?void 0:a.reason)==="uninstalled"?"uninstalled":"new_user";return e.jsx(ie,{reason:o})}export{me as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const w="https://gitee.com/juejin-cn/juejin-usage",b=`${w}/releases`,g="https://gitee.com/api/v5/repos/juejin-cn/juejin-usage/releases?per_page=20&direction=desc",h="https://github.com/juejin-cn/juejin-usage",_=`${h}/releases`,E="https://api.github.com/repos/juejin-cn/juejin-usage/releases?per_page=20",R=8e3,p=[{id:"macos-arm",os:"macos",label:"下载 macOS",menuLabel:"macOS(Apple Silicon)",badgePlatform:"macOS",requirement:"macOS 14+"},{id:"macos-intel",os:"macos",label:"下载 macOS(Intel)",menuLabel:"macOS(Intel)",badgePlatform:"macOS",requirement:"macOS 14+"},{id:"windows",os:"windows",label:"下载 Windows",menuLabel:"Windows",badgePlatform:"Windows",requirement:"Windows 10+"}],S=new Map(p.map(e=>[e.id,e]));function I(e){return S.get(e)??p[0]}function O(e,n="",t=""){const s=`${t} ${n} ${e}`.toLowerCase();return/\bwin(?:dows|32|64|ce)?\b/.test(s)||s.includes("windows")?"windows":s.includes("mac")||s.includes("darwin")||s.includes("iphone")||s.includes("ipad")||s.includes("ipod")?"macos":"other"}function $(e,n=""){const t=n.toLowerCase();return t.includes("arm")?"arm":t.includes("x86")||t.includes("x64")||t.includes("amd64")||/\bintel\b/i.test(e)?"x64":"unknown"}function x(e,n="unknown"){return e==="windows"?"windows":e==="macos"&&n==="x64"?"macos-intel":"macos-arm"}function u(e){const n=e.trim().replace(/^v/i,""),t=n.indexOf("-"),s=t===-1?n:n.slice(0,t),a=t===-1?null:n.slice(t+1);return{parts:s.split(".").map(o=>{const r=Number.parseInt(o,10);return Number.isFinite(r)?r:0}),prerelease:a}}function j(e,n){const t=u(e),s=u(n),a=Math.max(t.parts.length,s.parts.length);for(let i=0;i<a;i+=1){const o=(t.parts[i]??0)-(s.parts[i]??0);if(o!==0)return o}return t.prerelease==null&&s.prerelease!=null?1:t.prerelease!=null&&s.prerelease==null?-1:t.prerelease!=null&&s.prerelease!=null?t.prerelease.localeCompare(s.prerelease,"en",{numeric:!0}):0}function m(e){if(!e)return 0;const n=Date.parse(e);return Number.isFinite(n)?n:0}function A(e){const n=e.filter(t=>!t.draft);return n.length===0?null:n.reduce((t,s)=>{const a=j(s.tag_name??"",t.tag_name??"");return a>0?s:a<0?t:m(s.created_at)>m(t.created_at)?s:t})}function f(e){return!/\.(blockmap|yml|yaml|zip|tar\.gz)$/i.test(e)}function c(e){return e.some(n=>f(n.name)&&/\.(dmg|exe)$/i.test(n.name))}function k(e,n){var s,a,i,o;const t=e.filter(r=>f(r.name));if(n==="windows"){const r=t.find(l=>/\.exe$/i.test(l.name)&&/setup/i.test(l.name)&&!/portable/i.test(l.name));return r?r.browser_download_url:((s=t.find(l=>/\.exe$/i.test(l.name)&&!/portable/i.test(l.name)))==null?void 0:s.browser_download_url)??null}return n==="macos-arm"?((a=t.find(r=>/arm64\.dmg$/i.test(r.name)))==null?void 0:a.browser_download_url)??null:((i=t.find(r=>/x64\.dmg$/i.test(r.name)))==null?void 0:i.browser_download_url)??((o=t.find(r=>/\.dmg$/i.test(r.name)&&!/arm64/i.test(r.name)))==null?void 0:o.browser_download_url)??null}function P(e){return e==="github"?_:b}function T(e,n){return{source:e,tagName:n.tag_name,assets:n.assets??[]}}function L(e,n){if(e&&c(e.assets))return e;if(n&&c(n.assets))return n;throw new Error("No published desktop release")}async function d(e,n){const t=new AbortController,s=setTimeout(()=>t.abort(),R);try{const a=await fetch(e,{headers:{Accept:n==="github"?"application/vnd.github+json":"application/json"},signal:t.signal});if(!a.ok)throw new Error(`${n} releases ${a.status}`);const i=await a.json(),o=A(i);if(!o)throw new Error(`No published ${n} release`);return T(n,o)}finally{clearTimeout(s)}}async function y(){let e=null;try{e=await d(g,"gitee")}catch{e=null}if(e&&c(e.assets))return e;const n=await d(E,"github");return L(e,n)}export{p as D,h as G,O as a,w as b,P as c,$ as d,y as f,I as g,k as m,x as r};
|
|
Binary file
|