@juejin-opensource/jusage 0.1.10 → 0.1.11

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.
@@ -1,4 +1,4 @@
1
- import{r as _,c as J,j as e,B as M,C as we,a as C,M as T,A as be,b as ge,Q as ke,e as ve,f as ye,g as je,h as ie,i as q,k as A,l as Ne,T as E,P as Y,L as Se,u as le,m as Re,n as ne,D as Z,o as Ce,S as G,d as Le,p as Ie}from"./index-BishKKQ3.js";import{g as Me,S as P,M as Ae}from"./model-provider-DFqk09Xz.js";import{P as U,C as K,G as ee}from"./downloads-DtzcmlGG.js";import{L as Q,S as k,a as S,b as R}from"./index-tHASxOXL.js";import{C as H,T as F,L as ze,a as Te,S as V,i as Ee,u as Pe}from"./useLocalStorage-CmdvKOoP.js";const Oe=t=>_.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},t),_.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M5.47 13.03a.75.75 0 0 1 0-1.06L9.44 8 5.47 4.03a.75.75 0 0 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0",clipRule:"evenodd"}));/**
1
+ import{r as _,c as J,j as e,B as M,C as we,a as C,M as T,A as be,b as ge,Q as ke,e as ve,f as ye,g as je,h as ie,i as q,k as A,l as Ne,T as E,P as Y,L as Se,u as le,m as Re,n as ne,D as Z,o as Ce,S as G,d as Le,p as Ie}from"./index-mevy0vLr.js";import{g as Me,S as P,M as Ae}from"./model-provider-CXm-Ru1s.js";import{P as U,C as K,G as ee}from"./downloads-BWVeZf1b.js";import{L as Q,S as k,a as S,b as R}from"./index-Cl161mdg.js";import{C as H,T as F,L as ze,a as Te,S as V,i as Ee,u as Pe}from"./useLocalStorage-CKd3SYzL.js";const Oe=t=>_.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},t),_.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M5.47 13.03a.75.75 0 0 1 0-1.06L9.44 8 5.47 4.03a.75.75 0 0 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0",clipRule:"evenodd"}));/**
2
2
  * @license lucide-react v1.24.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as t,d as n}from"./index-BishKKQ3.js";function e(){return t.useEffect(()=>{n()},[]),null}const s=e;export{s as component};
1
+ import{r as t,d as n}from"./index-mevy0vLr.js";function e(){return t.useEffect(()=>{n()},[]),null}const s=e;export{s as component};
@@ -1,4 +1,4 @@
1
- import{t as _,an as f,j as u,aS as T,aU as O,r,bI as ce,aD as Q,b0 as de,b1 as ue,ai as fe,aJ as pe,bJ as be,b3 as $e,am as A,X as D,ay as H,_ as P,ao as X,b4 as he,b6 as me,ak as xe,al as B,bK as ve,aV as L,bL as ge,bM as ye,aF as we,bN as Pe,G as Ce,aa as Y,bO as Se,a6 as Re,bP as Ee,bQ as Te,bR as Oe,bS as Me,bT as Ne,bU as De,c as F,bt as Ie,B as je}from"./index-BishKKQ3.js";import{u as U}from"./index-tHASxOXL.js";const ke=_({defaultVariants:{color:"default",variant:"secondary"},slots:{base:"chip",label:"chip__label"},variants:{color:{accent:{base:"chip--accent"},danger:{base:"chip--danger"},default:{base:"chip--default"},success:{base:"chip--success"},warning:{base:"chip--warning"}},size:{lg:{base:"chip--lg"},md:{base:"chip--md"},sm:{base:"chip--sm"}},variant:{primary:{base:"chip--primary"},secondary:{base:"chip--secondary"},soft:{base:"chip--soft"},tertiary:{base:"chip--tertiary"}}}}),_e=_({defaultVariants:{size:"md"},slots:{base:"switch",content:"switch__content",control:"switch__control",icon:"switch__icon",thumb:"switch__thumb"},variants:{size:{lg:{base:"switch--lg"},md:{base:"switch--md"},sm:{base:"switch--sm"}}}}),Ae=_({slots:{base:"tooltip",trigger:"tooltip__trigger"}}),Z=r.createContext({}),z=({children:e,className:t,color:a,size:n,variant:o,...s})=>{const i=f.useMemo(()=>ke({color:a,size:n,variant:o}),[a,n,o]),d=f.useMemo(()=>typeof e=="string"||typeof e=="number"?u.jsx(ee,{children:e}):e,[e]);return u.jsx(Z,{value:{slots:i},children:u.jsx(T.span,{...s,className:O(i.base,t),"data-slot":"chip",children:d})})},ee=({children:e,className:t,...a})=>{const{slots:n}=r.use(Z);return u.jsx(T.span,{className:O(n==null?void 0:n.label,t),"data-slot":"chip-label",...a,children:e})},$t=Object.assign(z,{Root:z,Label:ee});function He(e,t,a){let{labelProps:n,inputProps:o,isSelected:s,...i}=ce(e,t,a);return{labelProps:n,inputProps:{...o,role:"switch",checked:s},isSelected:s,...i}}const Be=r.createContext(null),te=r.createContext(null),ae=r.createContext(null),Le=r.forwardRef(function(t,a){let{inputRef:n=null,...o}=t;[t,a]=Q(o,a,Be);let{validationBehavior:s}=de(ue)||{},i=t.validationBehavior??s??"native",d=fe(pe(n,t.inputRef!==void 0?t.inputRef:null)),l=be(t),c=He({...$e(t),children:typeof t.children=="function"?!0:t.children,validationBehavior:i},l,d),{descriptionProps:b,errorMessageProps:h,isSelected:m,isDisabled:$,isReadOnly:x,isInvalid:y,validationDetails:p,validationErrors:C}=c,v=A({...t,defaultClassName:"react-aria-SwitchField",values:{isSelected:m,isDisabled:$,isReadOnly:x,isInvalid:y,isRequired:t.isRequired||!1,state:l}}),w=D(t,{global:!0});return delete w.id,delete w.onClick,f.createElement(H.div,{...P(w,v),ref:a,slot:t.slot||void 0,"data-selected":m||void 0,"data-disabled":$||void 0,"data-readonly":x||void 0,"data-invalid":y||void 0,"data-required":t.isRequired||void 0},f.createElement(X,{values:[[te,l],[ae,{...c,inputRef:d,defaultClassName:"react-aria-SwitchButton",isRequired:t.isRequired}],[he,{slots:{description:b,errorMessage:h}}],[me,{isInvalid:y,validationDetails:p,validationErrors:C}]]},v.children))}),Fe=r.forwardRef(function(t,a){let{labelProps:n,inputProps:o,isSelected:s,isDisabled:i,isReadOnly:d,isPressed:l,isInvalid:c,inputRef:b,defaultClassName:h,isRequired:m}=r.useContext(ae),{isFocused:$,isFocusVisible:x,focusProps:y}=xe(),p=i||d,C=r.useContext(te),{hoverProps:v,isHovered:w}=B({...t,isDisabled:p}),q=A({...t,defaultClassName:h,values:{isSelected:s,isPressed:l,isHovered:w,isFocused:$,isFocusVisible:x,isDisabled:i,isReadOnly:d,isInvalid:c,isRequired:m||!1,state:C}}),I=D(t,{global:!0});return delete I.id,delete I.onClick,f.createElement(H.label,{...P(I,n,v,q),ref:a,slot:t.slot||void 0,"data-selected":s||void 0,"data-pressed":l||void 0,"data-hovered":w||void 0,"data-focused":$||void 0,"data-focus-visible":x||void 0,"data-disabled":i||void 0,"data-readonly":d||void 0,"data-invalid":c||void 0,"data-required":m||void 0},f.createElement(ve,{elementType:"span"},f.createElement("input",{...P(o,y),ref:b})),q.children)}),N=r.createContext({}),j=({children:e,className:t,size:a,...n})=>{const o=f.useMemo(()=>_e({size:a}),[a]);return u.jsx(Le,{"data-slot":"switch",...n,className:L(t,o.base()),children:s=>u.jsx(N,{value:{slots:o,state:s},children:typeof e=="function"?e(s):e})})};j.displayName="HeroUI.Switch";const ne=({children:e,className:t,...a})=>{const{slots:n}=r.use(N);return u.jsx(Fe,{"data-slot":"switch-content",...a,className:L(t,n==null?void 0:n.content()),children:e})};ne.displayName="HeroUI.Switch.Content";const oe=({children:e,className:t,...a})=>{const{slots:n}=r.use(N);return u.jsx(T.span,{className:O(n==null?void 0:n.control,t),"data-slot":"switch-control",...a,children:e})};oe.displayName="HeroUI.Switch.Control";const re=({children:e,className:t,...a})=>{const{slots:n}=r.use(N);return u.jsx(T.span,{className:O(n==null?void 0:n.thumb,t),"data-slot":"switch-thumb",...a,children:e})};re.displayName="HeroUI.Switch.Thumb";const se=({children:e,className:t,...a})=>{const{slots:n}=r.use(N);return u.jsx(T.span,{className:O(n==null?void 0:n.icon,t),"data-slot":"switch-icon",...a,children:e})};se.displayName="HeroUI.Switch.Icon";const ht=Object.assign(j,{Root:j,Content:ne,Control:oe,Thumb:re,Icon:se}),k=f.createContext(null);function Ve(e){let{children:t}=e,a=r.useContext(k),[n,o]=r.useState(0),s=r.useMemo(()=>({parent:a,modalCount:n,addModal(){o(i=>i+1),a&&a.addModal()},removeModal(){o(i=>i-1),a&&a.removeModal()}}),[a,n]);return f.createElement(k.Provider,{value:s},t)}function qe(){let e=r.useContext(k);return{modalProviderProps:{"aria-hidden":e&&e.modalCount>0?!0:void 0}}}function Ue(e){let{modalProviderProps:t}=qe();return f.createElement("div",{"data-overlay-container":!0,...e,...t})}function ze(e){return f.createElement(Ve,null,f.createElement(Ue,e))}function We(e){let t=ge(),{portalContainer:a=t?null:document.body,...n}=e,{getContainer:o}=ye();if(!e.portalContainer&&o&&(a=o()),f.useEffect(()=>{if(a!=null&&a.closest("[data-overlay-container]"))throw new Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.")},[a]),!a)return null;let s=f.createElement(ze,n);return we.createPortal(s,a)}const Je=1500,W=500;let S={},Ke=0,E=!1,g=null,R=null;function ie(e={}){let{delay:t=Je,closeDelay:a=W}=e,{isOpen:n,open:o,close:s}=Pe(e),[i,d]=r.useState(!1),l=r.useMemo(()=>`${++Ke}`,[]),c=r.useRef(null),b=r.useRef(s),h=()=>{S[l]=x},m=()=>{for(let p in S)p!==l&&(S[p](!0,!0),delete S[p])},$=p=>{c.current&&clearTimeout(c.current),c.current=null,m(),h(),d(!!p),E=!0,o(),g&&(clearTimeout(g),g=null),R&&(clearTimeout(R),R=null)},x=(p,C)=>{d(!!C),p||a<=0?(c.current&&clearTimeout(c.current),c.current=null,b.current()):c.current||(c.current=setTimeout(()=>{c.current=null,b.current()},a)),g&&(clearTimeout(g),g=null),E&&(R&&clearTimeout(R),R=setTimeout(()=>{delete S[l],R=null,E=!1},Math.max(W,a)))},y=()=>{m(),h(),!n&&!E?(g&&clearTimeout(g),g=setTimeout(()=>{g=null,E=!0,$(!1)},t)):n||$(!0)};return r.useEffect(()=>{b.current=s},[s]),r.useEffect(()=>()=>{c.current&&clearTimeout(c.current),S[l]&&delete S[l]},[l]),{isOpen:n,shouldSkipAnimation:i,open:p=>{!p&&t>0&&!c.current?y():$(E)},close:x}}function Ge(e,t){let a=D(e,{labelable:!0}),{hoverProps:n}=B({onHoverStart:()=>t==null?void 0:t.open(!0),onHoverEnd:()=>t==null?void 0:t.close()});return{tooltipProps:P(a,n,{role:"tooltip"})}}function Qe(e,t,a){let{isDisabled:n,trigger:o,shouldCloseOnPress:s=!0}=e,i=Ce(),d=r.useRef(!1),l=r.useRef(!1),c=()=>{(d.current||l.current)&&t.open(l.current)},b=v=>{!d.current&&!l.current&&t.close(v)};r.useEffect(()=>{let v=w=>{a&&a.current&&w.key==="Escape"&&(w.stopPropagation(),t.close(!0))};if(t.isOpen)return document.addEventListener("keydown",v,!0),()=>{document.removeEventListener("keydown",v,!0)}},[a,t]);let h=()=>{o!=="focus"&&(Se()==="pointer"?d.current=!0:d.current=!1,c())},m=()=>{o!=="focus"&&(l.current=!1,d.current=!1,b())},$=()=>{s&&(l.current=!1,d.current=!1,b(!0))},x=()=>{Re()&&(l.current=!0,c())},y=()=>{l.current=!1,d.current=!1,b(!0)},{hoverProps:p}=B({isDisabled:n,onHoverStart:h,onHoverEnd:m}),{focusableProps:C}=Y({isDisabled:n,onFocus:x,onBlur:y},a);return{triggerProps:{"aria-describedby":t.isOpen?i:void 0,...P(C,p,{onPointerDown:$,onKeyDown:$}),tabIndex:void 0},tooltipProps:{id:i}}}const M=r.createContext(null),le=r.createContext(null);function Xe(e){let t=ie(e),a=r.useRef(null),{triggerProps:n,tooltipProps:o}=Qe(e,t,a);return f.createElement(X,{values:[[M,t],[le,{...o,triggerRef:a}]]},f.createElement(Ee,{...n,ref:a},e.children))}const Ye=r.forwardRef(function({UNSTABLE_portalContainer:t,...a},n){[a,n]=Q(a,n,le);let o=r.useContext(M),s=ie(a),i=a.isOpen!=null||a.defaultOpen!=null||!o?s:o,d=Te(n,i.isOpen),l=a.isExiting||!i.shouldSkipAnimation&&d||!1;return!i.isOpen&&!l?null:f.createElement(We,{portalContainer:t},f.createElement(Ze,{...a,tooltipRef:n,isExiting:l}))});function Ze(e){let t=r.useContext(M),a=r.useRef(null),{overlayProps:n,arrowProps:o,placement:s,triggerAnchorPoint:i}=Oe({placement:e.placement||"top",targetRef:e.triggerRef,overlayRef:e.tooltipRef,arrowRef:a,offset:e.offset,crossOffset:e.crossOffset,isOpen:t.isOpen,arrowBoundaryOffset:e.arrowBoundaryOffset,shouldFlip:e.shouldFlip,containerPadding:e.containerPadding,onClose:()=>t.close(!0)}),d=Me(e.tooltipRef,!!s),l=e.isEntering||!t.shouldSkipAnimation&&d||!1,c=A({...e,defaultClassName:"react-aria-Tooltip",values:{placement:s,isEntering:l,isExiting:e.isExiting,state:t}});e=P(e,n);let{tooltipProps:b}=Ge(e,t),h=D(e,{global:!0});return f.createElement(H.div,{...P(h,c,b),ref:e.tooltipRef,style:{...n.style,"--trigger-anchor-point":i?`${i.x}px ${i.y}px`:void 0,...c.style},"data-placement":s??void 0,"data-entering":l||void 0,"data-exiting":e.isExiting||void 0},f.createElement(Ne.Provider,{value:{...o,placement:s,ref:a}},c.children))}const J=e=>{if(!e)return;const t=e.trim(),a=parseFloat(t);if(!Number.isNaN(a))return t.endsWith("ms")?a:t.endsWith("s")?a*1e3:a},V=r.createContext({}),et=({children:e,shouldSkipAnimation:t})=>{const a=r.use(M);return!a||t?e:u.jsx(M,{value:{...a,shouldSkipAnimation:!1},children:e})},K=({children:e,closeDelay:t,delay:a,shouldSkipAnimation:n=!1,...o})=>{const s=f.useMemo(()=>Ae(),[]),i=U("--tooltip-delay"),d=U("--tooltip-close-delay"),l=a??J(i),c=t??J(d);return u.jsx(V,{value:{slots:s},children:u.jsx(Xe,{closeDelay:c,"data-slot":"tooltip-root",delay:l,...o,children:u.jsx(et,{shouldSkipAnimation:n,children:e})})})},tt=({children:e,className:t,offset:a,showArrow:n=!1,...o})=>{const{slots:s}=r.use(V),i=a||(n?7:3);return u.jsx(Ye,{...o,className:L(t,s==null?void 0:s.base()),offset:i,children:e})},at=({children:e,className:t,...a})=>{const n=u.jsx("svg",{"data-slot":"overlay-arrow",fill:"none",height:"12",viewBox:"0 0 12 12",width:"12",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M0 0C5.48483 8 6.5 8 12 0Z"})}),o=f.isValidElement(e)?f.cloneElement(e,{"data-slot":"overlay-arrow"}):n;return u.jsx(De,{"data-slot":"tooltip-arrow",...a,className:t,children:o})},nt=({children:e,className:t,...a})=>{const{slots:n}=r.use(V),o=r.useRef(null),{focusableProps:s}=Y({},o);return u.jsx(T.div,{ref:o,className:O(n==null?void 0:n.trigger,t),"data-slot":"tooltip-trigger",role:"button",...P(s,a),children:e})},G=Object.assign(K,{Root:K,Trigger:nt,Content:tt,Arrow:at}),mt=e=>r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),r.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M10.418 2.489c.9-1.196 2.382-1.724 3.154-1.391.852.367 1.539 2.08 1.054 3.702a4 4 0 0 1-2.616 5.559c.309.471.49 1.035.49 1.641v2.25a.75.75 0 0 1-1.5 0V12a1.5 1.5 0 0 0-3 0v2.25a.75.75 0 0 1-1.5 0v-.75h-.876a2.626 2.626 0 0 1-2.625-2.625c0-.621-.504-1.125-1.125-1.125h-.125a.75.75 0 0 1 0-1.5h.125a2.625 2.625 0 0 1 2.625 2.625c0 .621.504 1.125 1.125 1.125H6.5c0-.606.18-1.17.488-1.641A4 4 0 0 1 4.373 4.8c-.484-1.623.202-3.335 1.054-3.702.772-.333 2.254.195 3.155 1.39zm2.549.02a1.4 1.4 0 0 0-.35.098 2.5 2.5 0 0 0-1 .784l-.451.598H7.834l-.45-.598a2.5 2.5 0 0 0-1.001-.784 1.4 1.4 0 0 0-.352-.099c-.063.088-.14.231-.204.429a2.5 2.5 0 0 0-.016 1.434l.163.546-.242.517c-.13.279-.21.586-.228.913l-.004.142a2.5 2.5 0 0 0 2.5 2.5h3a2.5 2.5 0 0 0 2.267-3.555l-.242-.517.163-.547a2.5 2.5 0 0 0-.016-1.433 1.6 1.6 0 0 0-.205-.429",clipRule:"evenodd"}));/**
1
+ import{t as _,an as f,j as u,aS as T,aU as O,r,bI as ce,aD as Q,b0 as de,b1 as ue,ai as fe,aJ as pe,bJ as be,b3 as $e,am as A,X as D,ay as H,_ as P,ao as X,b4 as he,b6 as me,ak as xe,al as B,bK as ve,aV as L,bL as ge,bM as ye,aF as we,bN as Pe,G as Ce,aa as Y,bO as Se,a6 as Re,bP as Ee,bQ as Te,bR as Oe,bS as Me,bT as Ne,bU as De,c as F,bt as Ie,B as je}from"./index-mevy0vLr.js";import{u as U}from"./index-Cl161mdg.js";const ke=_({defaultVariants:{color:"default",variant:"secondary"},slots:{base:"chip",label:"chip__label"},variants:{color:{accent:{base:"chip--accent"},danger:{base:"chip--danger"},default:{base:"chip--default"},success:{base:"chip--success"},warning:{base:"chip--warning"}},size:{lg:{base:"chip--lg"},md:{base:"chip--md"},sm:{base:"chip--sm"}},variant:{primary:{base:"chip--primary"},secondary:{base:"chip--secondary"},soft:{base:"chip--soft"},tertiary:{base:"chip--tertiary"}}}}),_e=_({defaultVariants:{size:"md"},slots:{base:"switch",content:"switch__content",control:"switch__control",icon:"switch__icon",thumb:"switch__thumb"},variants:{size:{lg:{base:"switch--lg"},md:{base:"switch--md"},sm:{base:"switch--sm"}}}}),Ae=_({slots:{base:"tooltip",trigger:"tooltip__trigger"}}),Z=r.createContext({}),z=({children:e,className:t,color:a,size:n,variant:o,...s})=>{const i=f.useMemo(()=>ke({color:a,size:n,variant:o}),[a,n,o]),d=f.useMemo(()=>typeof e=="string"||typeof e=="number"?u.jsx(ee,{children:e}):e,[e]);return u.jsx(Z,{value:{slots:i},children:u.jsx(T.span,{...s,className:O(i.base,t),"data-slot":"chip",children:d})})},ee=({children:e,className:t,...a})=>{const{slots:n}=r.use(Z);return u.jsx(T.span,{className:O(n==null?void 0:n.label,t),"data-slot":"chip-label",...a,children:e})},$t=Object.assign(z,{Root:z,Label:ee});function He(e,t,a){let{labelProps:n,inputProps:o,isSelected:s,...i}=ce(e,t,a);return{labelProps:n,inputProps:{...o,role:"switch",checked:s},isSelected:s,...i}}const Be=r.createContext(null),te=r.createContext(null),ae=r.createContext(null),Le=r.forwardRef(function(t,a){let{inputRef:n=null,...o}=t;[t,a]=Q(o,a,Be);let{validationBehavior:s}=de(ue)||{},i=t.validationBehavior??s??"native",d=fe(pe(n,t.inputRef!==void 0?t.inputRef:null)),l=be(t),c=He({...$e(t),children:typeof t.children=="function"?!0:t.children,validationBehavior:i},l,d),{descriptionProps:b,errorMessageProps:h,isSelected:m,isDisabled:$,isReadOnly:x,isInvalid:y,validationDetails:p,validationErrors:C}=c,v=A({...t,defaultClassName:"react-aria-SwitchField",values:{isSelected:m,isDisabled:$,isReadOnly:x,isInvalid:y,isRequired:t.isRequired||!1,state:l}}),w=D(t,{global:!0});return delete w.id,delete w.onClick,f.createElement(H.div,{...P(w,v),ref:a,slot:t.slot||void 0,"data-selected":m||void 0,"data-disabled":$||void 0,"data-readonly":x||void 0,"data-invalid":y||void 0,"data-required":t.isRequired||void 0},f.createElement(X,{values:[[te,l],[ae,{...c,inputRef:d,defaultClassName:"react-aria-SwitchButton",isRequired:t.isRequired}],[he,{slots:{description:b,errorMessage:h}}],[me,{isInvalid:y,validationDetails:p,validationErrors:C}]]},v.children))}),Fe=r.forwardRef(function(t,a){let{labelProps:n,inputProps:o,isSelected:s,isDisabled:i,isReadOnly:d,isPressed:l,isInvalid:c,inputRef:b,defaultClassName:h,isRequired:m}=r.useContext(ae),{isFocused:$,isFocusVisible:x,focusProps:y}=xe(),p=i||d,C=r.useContext(te),{hoverProps:v,isHovered:w}=B({...t,isDisabled:p}),q=A({...t,defaultClassName:h,values:{isSelected:s,isPressed:l,isHovered:w,isFocused:$,isFocusVisible:x,isDisabled:i,isReadOnly:d,isInvalid:c,isRequired:m||!1,state:C}}),I=D(t,{global:!0});return delete I.id,delete I.onClick,f.createElement(H.label,{...P(I,n,v,q),ref:a,slot:t.slot||void 0,"data-selected":s||void 0,"data-pressed":l||void 0,"data-hovered":w||void 0,"data-focused":$||void 0,"data-focus-visible":x||void 0,"data-disabled":i||void 0,"data-readonly":d||void 0,"data-invalid":c||void 0,"data-required":m||void 0},f.createElement(ve,{elementType:"span"},f.createElement("input",{...P(o,y),ref:b})),q.children)}),N=r.createContext({}),j=({children:e,className:t,size:a,...n})=>{const o=f.useMemo(()=>_e({size:a}),[a]);return u.jsx(Le,{"data-slot":"switch",...n,className:L(t,o.base()),children:s=>u.jsx(N,{value:{slots:o,state:s},children:typeof e=="function"?e(s):e})})};j.displayName="HeroUI.Switch";const ne=({children:e,className:t,...a})=>{const{slots:n}=r.use(N);return u.jsx(Fe,{"data-slot":"switch-content",...a,className:L(t,n==null?void 0:n.content()),children:e})};ne.displayName="HeroUI.Switch.Content";const oe=({children:e,className:t,...a})=>{const{slots:n}=r.use(N);return u.jsx(T.span,{className:O(n==null?void 0:n.control,t),"data-slot":"switch-control",...a,children:e})};oe.displayName="HeroUI.Switch.Control";const re=({children:e,className:t,...a})=>{const{slots:n}=r.use(N);return u.jsx(T.span,{className:O(n==null?void 0:n.thumb,t),"data-slot":"switch-thumb",...a,children:e})};re.displayName="HeroUI.Switch.Thumb";const se=({children:e,className:t,...a})=>{const{slots:n}=r.use(N);return u.jsx(T.span,{className:O(n==null?void 0:n.icon,t),"data-slot":"switch-icon",...a,children:e})};se.displayName="HeroUI.Switch.Icon";const ht=Object.assign(j,{Root:j,Content:ne,Control:oe,Thumb:re,Icon:se}),k=f.createContext(null);function Ve(e){let{children:t}=e,a=r.useContext(k),[n,o]=r.useState(0),s=r.useMemo(()=>({parent:a,modalCount:n,addModal(){o(i=>i+1),a&&a.addModal()},removeModal(){o(i=>i-1),a&&a.removeModal()}}),[a,n]);return f.createElement(k.Provider,{value:s},t)}function qe(){let e=r.useContext(k);return{modalProviderProps:{"aria-hidden":e&&e.modalCount>0?!0:void 0}}}function Ue(e){let{modalProviderProps:t}=qe();return f.createElement("div",{"data-overlay-container":!0,...e,...t})}function ze(e){return f.createElement(Ve,null,f.createElement(Ue,e))}function We(e){let t=ge(),{portalContainer:a=t?null:document.body,...n}=e,{getContainer:o}=ye();if(!e.portalContainer&&o&&(a=o()),f.useEffect(()=>{if(a!=null&&a.closest("[data-overlay-container]"))throw new Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.")},[a]),!a)return null;let s=f.createElement(ze,n);return we.createPortal(s,a)}const Je=1500,W=500;let S={},Ke=0,E=!1,g=null,R=null;function ie(e={}){let{delay:t=Je,closeDelay:a=W}=e,{isOpen:n,open:o,close:s}=Pe(e),[i,d]=r.useState(!1),l=r.useMemo(()=>`${++Ke}`,[]),c=r.useRef(null),b=r.useRef(s),h=()=>{S[l]=x},m=()=>{for(let p in S)p!==l&&(S[p](!0,!0),delete S[p])},$=p=>{c.current&&clearTimeout(c.current),c.current=null,m(),h(),d(!!p),E=!0,o(),g&&(clearTimeout(g),g=null),R&&(clearTimeout(R),R=null)},x=(p,C)=>{d(!!C),p||a<=0?(c.current&&clearTimeout(c.current),c.current=null,b.current()):c.current||(c.current=setTimeout(()=>{c.current=null,b.current()},a)),g&&(clearTimeout(g),g=null),E&&(R&&clearTimeout(R),R=setTimeout(()=>{delete S[l],R=null,E=!1},Math.max(W,a)))},y=()=>{m(),h(),!n&&!E?(g&&clearTimeout(g),g=setTimeout(()=>{g=null,E=!0,$(!1)},t)):n||$(!0)};return r.useEffect(()=>{b.current=s},[s]),r.useEffect(()=>()=>{c.current&&clearTimeout(c.current),S[l]&&delete S[l]},[l]),{isOpen:n,shouldSkipAnimation:i,open:p=>{!p&&t>0&&!c.current?y():$(E)},close:x}}function Ge(e,t){let a=D(e,{labelable:!0}),{hoverProps:n}=B({onHoverStart:()=>t==null?void 0:t.open(!0),onHoverEnd:()=>t==null?void 0:t.close()});return{tooltipProps:P(a,n,{role:"tooltip"})}}function Qe(e,t,a){let{isDisabled:n,trigger:o,shouldCloseOnPress:s=!0}=e,i=Ce(),d=r.useRef(!1),l=r.useRef(!1),c=()=>{(d.current||l.current)&&t.open(l.current)},b=v=>{!d.current&&!l.current&&t.close(v)};r.useEffect(()=>{let v=w=>{a&&a.current&&w.key==="Escape"&&(w.stopPropagation(),t.close(!0))};if(t.isOpen)return document.addEventListener("keydown",v,!0),()=>{document.removeEventListener("keydown",v,!0)}},[a,t]);let h=()=>{o!=="focus"&&(Se()==="pointer"?d.current=!0:d.current=!1,c())},m=()=>{o!=="focus"&&(l.current=!1,d.current=!1,b())},$=()=>{s&&(l.current=!1,d.current=!1,b(!0))},x=()=>{Re()&&(l.current=!0,c())},y=()=>{l.current=!1,d.current=!1,b(!0)},{hoverProps:p}=B({isDisabled:n,onHoverStart:h,onHoverEnd:m}),{focusableProps:C}=Y({isDisabled:n,onFocus:x,onBlur:y},a);return{triggerProps:{"aria-describedby":t.isOpen?i:void 0,...P(C,p,{onPointerDown:$,onKeyDown:$}),tabIndex:void 0},tooltipProps:{id:i}}}const M=r.createContext(null),le=r.createContext(null);function Xe(e){let t=ie(e),a=r.useRef(null),{triggerProps:n,tooltipProps:o}=Qe(e,t,a);return f.createElement(X,{values:[[M,t],[le,{...o,triggerRef:a}]]},f.createElement(Ee,{...n,ref:a},e.children))}const Ye=r.forwardRef(function({UNSTABLE_portalContainer:t,...a},n){[a,n]=Q(a,n,le);let o=r.useContext(M),s=ie(a),i=a.isOpen!=null||a.defaultOpen!=null||!o?s:o,d=Te(n,i.isOpen),l=a.isExiting||!i.shouldSkipAnimation&&d||!1;return!i.isOpen&&!l?null:f.createElement(We,{portalContainer:t},f.createElement(Ze,{...a,tooltipRef:n,isExiting:l}))});function Ze(e){let t=r.useContext(M),a=r.useRef(null),{overlayProps:n,arrowProps:o,placement:s,triggerAnchorPoint:i}=Oe({placement:e.placement||"top",targetRef:e.triggerRef,overlayRef:e.tooltipRef,arrowRef:a,offset:e.offset,crossOffset:e.crossOffset,isOpen:t.isOpen,arrowBoundaryOffset:e.arrowBoundaryOffset,shouldFlip:e.shouldFlip,containerPadding:e.containerPadding,onClose:()=>t.close(!0)}),d=Me(e.tooltipRef,!!s),l=e.isEntering||!t.shouldSkipAnimation&&d||!1,c=A({...e,defaultClassName:"react-aria-Tooltip",values:{placement:s,isEntering:l,isExiting:e.isExiting,state:t}});e=P(e,n);let{tooltipProps:b}=Ge(e,t),h=D(e,{global:!0});return f.createElement(H.div,{...P(h,c,b),ref:e.tooltipRef,style:{...n.style,"--trigger-anchor-point":i?`${i.x}px ${i.y}px`:void 0,...c.style},"data-placement":s??void 0,"data-entering":l||void 0,"data-exiting":e.isExiting||void 0},f.createElement(Ne.Provider,{value:{...o,placement:s,ref:a}},c.children))}const J=e=>{if(!e)return;const t=e.trim(),a=parseFloat(t);if(!Number.isNaN(a))return t.endsWith("ms")?a:t.endsWith("s")?a*1e3:a},V=r.createContext({}),et=({children:e,shouldSkipAnimation:t})=>{const a=r.use(M);return!a||t?e:u.jsx(M,{value:{...a,shouldSkipAnimation:!1},children:e})},K=({children:e,closeDelay:t,delay:a,shouldSkipAnimation:n=!1,...o})=>{const s=f.useMemo(()=>Ae(),[]),i=U("--tooltip-delay"),d=U("--tooltip-close-delay"),l=a??J(i),c=t??J(d);return u.jsx(V,{value:{slots:s},children:u.jsx(Xe,{closeDelay:c,"data-slot":"tooltip-root",delay:l,...o,children:u.jsx(et,{shouldSkipAnimation:n,children:e})})})},tt=({children:e,className:t,offset:a,showArrow:n=!1,...o})=>{const{slots:s}=r.use(V),i=a||(n?7:3);return u.jsx(Ye,{...o,className:L(t,s==null?void 0:s.base()),offset:i,children:e})},at=({children:e,className:t,...a})=>{const n=u.jsx("svg",{"data-slot":"overlay-arrow",fill:"none",height:"12",viewBox:"0 0 12 12",width:"12",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M0 0C5.48483 8 6.5 8 12 0Z"})}),o=f.isValidElement(e)?f.cloneElement(e,{"data-slot":"overlay-arrow"}):n;return u.jsx(De,{"data-slot":"tooltip-arrow",...a,className:t,children:o})},nt=({children:e,className:t,...a})=>{const{slots:n}=r.use(V),o=r.useRef(null),{focusableProps:s}=Y({},o);return u.jsx(T.div,{ref:o,className:O(n==null?void 0:n.trigger,t),"data-slot":"tooltip-trigger",role:"button",...P(s,a),children:e})},G=Object.assign(K,{Root:K,Trigger:nt,Content:tt,Arrow:at}),mt=e=>r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},e),r.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M10.418 2.489c.9-1.196 2.382-1.724 3.154-1.391.852.367 1.539 2.08 1.054 3.702a4 4 0 0 1-2.616 5.559c.309.471.49 1.035.49 1.641v2.25a.75.75 0 0 1-1.5 0V12a1.5 1.5 0 0 0-3 0v2.25a.75.75 0 0 1-1.5 0v-.75h-.876a2.626 2.626 0 0 1-2.625-2.625c0-.621-.504-1.125-1.125-1.125h-.125a.75.75 0 0 1 0-1.5h.125a2.625 2.625 0 0 1 2.625 2.625c0 .621.504 1.125 1.125 1.125H6.5c0-.606.18-1.17.488-1.641A4 4 0 0 1 4.373 4.8c-.484-1.623.202-3.335 1.054-3.702.772-.333 2.254.195 3.155 1.39zm2.549.02a1.4 1.4 0 0 0-.35.098 2.5 2.5 0 0 0-1 .784l-.451.598H7.834l-.45-.598a2.5 2.5 0 0 0-1.001-.784 1.4 1.4 0 0 0-.352-.099c-.063.088-.14.231-.204.429a2.5 2.5 0 0 0-.016 1.434l.163.546-.242.517c-.13.279-.21.586-.228.913l-.004.142a2.5 2.5 0 0 0 2.5 2.5h3a2.5 2.5 0 0 0 2.267-3.555l-.242-.517.163-.547a2.5 2.5 0 0 0-.016-1.433 1.6 1.6 0 0 0-.205-.429",clipRule:"evenodd"}));/**
2
2
  * @license lucide-react v1.24.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>AI Usage Dashboard</title>
7
- <script type="module" crossorigin src="/assets/index-BishKKQ3.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-B_TGKfQG.css">
7
+ <script type="module" crossorigin src="/assets/index-mevy0vLr.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-Dt-v3FGI.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
@@ -0,0 +1,2 @@
1
+ import type { DoctorReport } from '@juejin-opensource/jusage-core';
2
+ export declare function printDoctorReport(report: DoctorReport): void;
package/dist/doctor.js ADDED
@@ -0,0 +1,91 @@
1
+ function shouldUseColors() {
2
+ if (process.env.NO_COLOR)
3
+ return false;
4
+ if (process.env.FORCE_COLOR)
5
+ return true;
6
+ return Boolean(process.stdout.isTTY);
7
+ }
8
+ const colors = {
9
+ reset: '\x1b[0m',
10
+ bold: '\x1b[1m',
11
+ dim: '\x1b[2m',
12
+ green: '\x1b[32m',
13
+ yellow: '\x1b[33m',
14
+ red: '\x1b[31m',
15
+ cyan: '\x1b[36m',
16
+ gray: '\x1b[90m',
17
+ };
18
+ function c(color, text, enabled) {
19
+ if (!enabled)
20
+ return text;
21
+ return `${colors[color]}${text}${colors.reset}`;
22
+ }
23
+ export function printDoctorReport(report) {
24
+ const useColor = shouldUseColors();
25
+ console.log();
26
+ console.log(c('bold', `🩺 ${c('cyan', 'JUsage Doctor', useColor)} - 系统环境与数据源全面诊断`, useColor));
27
+ console.log(c('dim', `诊断时间: ${new Date(report.timestamp).toLocaleString()}`, useColor));
28
+ console.log();
29
+ for (const cat of report.categories) {
30
+ let catIcon = c('green', '[✓]', useColor);
31
+ if (cat.status === 'error') {
32
+ catIcon = c('red', '[✗]', useColor);
33
+ }
34
+ else if (cat.status === 'warn') {
35
+ catIcon = c('yellow', '[!]', useColor);
36
+ }
37
+ console.log(`${catIcon} ${c('bold', cat.title, useColor)}`);
38
+ for (const item of cat.items) {
39
+ let itemIcon = c('green', '✓', useColor);
40
+ if (item.status === 'error')
41
+ itemIcon = c('red', '✗', useColor);
42
+ else if (item.status === 'warn')
43
+ itemIcon = c('yellow', '!', useColor);
44
+ else if (item.status === 'info')
45
+ itemIcon = c('gray', '-', useColor);
46
+ console.log(` ${itemIcon} ${item.name}: ${item.message}`);
47
+ if (item.detail) {
48
+ console.log(` ${c('dim', item.detail, useColor)}`);
49
+ }
50
+ }
51
+ console.log();
52
+ }
53
+ // Display collectors breakdown if any
54
+ const detected = report.collectors.items.filter((i) => i.present);
55
+ const undetected = report.collectors.items.filter((i) => !i.present);
56
+ console.log(`${c('cyan', '📊 AI 编程工具探测详情', useColor)} ` +
57
+ `(${c('bold', String(detected.length), useColor)} / ${report.collectors.total} 款已就绪)`);
58
+ if (detected.length > 0) {
59
+ for (const d of detected) {
60
+ const hookText = d.hookStatus ? ` ${c('cyan', `[Hook: ${d.hookStatus}]`, useColor)}` : '';
61
+ console.log(` ${c('green', '✓', useColor)} ${d.displayName}${hookText}`);
62
+ }
63
+ }
64
+ else {
65
+ console.log(` ${c('yellow', '!', useColor)} 尚未检测到任何支持的 AI 工具`);
66
+ }
67
+ if (undetected.length > 0) {
68
+ const unNames = undetected.map((u) => u.displayName).join(', ');
69
+ console.log(` ${c('dim', `- 未探测到日志的工具 (${undetected.length}): ${unNames}`, useColor)}`);
70
+ }
71
+ console.log();
72
+ // Suggestions block if any warnings/errors
73
+ if (report.summary.suggestions.length > 0) {
74
+ console.log(c('bold', c('yellow', '💡 诊断发现以下建议项:', useColor), useColor));
75
+ for (const suggestion of report.summary.suggestions) {
76
+ console.log(` • ${suggestion}`);
77
+ }
78
+ console.log();
79
+ }
80
+ // Summary conclusion line
81
+ if (report.summary.status === 'ok') {
82
+ console.log(c('green', `🎉 诊断完成: ${report.summary.okCount} 项正常, 0 个错误, 0 个警告。所有核心组件运行良好!`, useColor));
83
+ }
84
+ else if (report.summary.status === 'warn') {
85
+ console.log(c('yellow', `⚠️ 诊断完成: ${report.summary.warnCount} 个提醒事项,请根据上方建议进行调整。`, useColor));
86
+ }
87
+ else {
88
+ console.log(c('red', `❌ 诊断完成: 发现 ${report.summary.errorCount} 个异常项,请优先处理上方错误。`, useColor));
89
+ }
90
+ console.log();
91
+ }
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { dirname, join } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
- import { appendJsonLog, BucketStore, createAggregateCache, createApplyAfterSync, createHttpServer, createLocalApiApp, createPollBackoff, DEFAULT_PORT, getHookStatus, getRunningOwner, listenServer, loadConfig, POLL_INTERVAL_MS, pollIntervalLabel, releaseRuntimeOwner, resolveLocalCollectSince, runtimeKindLabel, saveConfig, setupClaudeHook, setupCodexHook, syncAll, collectWrittenBuckets, syncLogPath, touchStatsSince, watchRuntimeSignals, watchSyncSignals, writeSyncDone, maybeUploadAfterSync, uploadToServer, kickBackfillDrain, stopBackfillDrain, drainBackfillUntilIdle, resolvePricingRefreshConfig, DEFAULT_PRICING_FIRST_FETCH_TIMEOUT_MS, startPricingRefresh, } from '@juejin-opensource/jusage-core';
3
+ import { appendJsonLog, BucketStore, createAggregateCache, createApplyAfterSync, createHttpServer, createLocalApiApp, createPollBackoff, DEFAULT_PORT, getHookStatus, getRunningOwner, listenServer, loadConfig, POLL_INTERVAL_MS, pollIntervalLabel, releaseRuntimeOwner, resolveLocalCollectSince, runtimeKindLabel, saveConfig, setupClaudeHook, setupCodexHook, syncAll, collectWrittenBuckets, syncLogPath, touchStatsSince, watchRuntimeSignals, watchSyncSignals, writeSyncDone, maybeUploadAfterSync, uploadToServer, kickBackfillDrain, stopBackfillDrain, drainBackfillUntilIdle, resolvePricingRefreshConfig, DEFAULT_PRICING_FIRST_FETCH_TIMEOUT_MS, startPricingRefresh, runDoctorDiagnostics, } from '@juejin-opensource/jusage-core';
4
4
  import { DEFAULT_HOST, formatListenUrl, isWildcardListenHost, parseArgs, printHelp, resolveDaysAgo, resolveSyncSource, } from './args.js';
5
5
  import { writePid } from './daemon.js';
6
+ import { printDoctorReport } from './doctor.js';
6
7
  import { cmdServiceStart, cmdServiceStatus, cmdServiceStop } from './service.js';
7
8
  export { parseArgs } from './args.js';
8
9
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -344,6 +345,10 @@ async function cmdStatus() {
344
345
  console.log(`上次上报: ${config.lastUploadAt ?? '从未'}`);
345
346
  console.log(`调试日志: ${join(dir, 'logs')}`);
346
347
  }
348
+ async function cmdDoctor(port) {
349
+ const report = await runDoctorDiagnostics({ port });
350
+ printDoctorReport(report);
351
+ }
347
352
  async function cmdUpload(force = false, reconcile = false) {
348
353
  const { dir, config } = await loadConfig();
349
354
  await touchStatsSince(dir, config);
@@ -430,6 +435,9 @@ async function main() {
430
435
  case 'status':
431
436
  await cmdStatus();
432
437
  break;
438
+ case 'doctor':
439
+ await cmdDoctor(port);
440
+ break;
433
441
  case 'upload':
434
442
  await cmdUpload(force, reconcile);
435
443
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juejin-opensource/jusage",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Juejin AI Usage 统计 CLI:Token 用量明细追踪,本地记录、云端同步,内置用量看板。",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,12 +34,12 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@juejin-opensource/jusage-core": "0.1.10"
37
+ "@juejin-opensource/jusage-core": "0.1.11"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^22.13.10",
41
41
  "typescript": "^5.8.2",
42
- "@juejin-opensource/jusage-dashboard": "0.1.10"
42
+ "@juejin-opensource/jusage-dashboard": "0.1.11"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=20"