tekivex-ui 3.5.0 → 3.18.1
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 -21
- package/README.md +155 -37
- package/dist/agent.cjs +1 -0
- package/dist/agent.d.ts +3 -0
- package/dist/agent.js +17 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +3 -0
- package/dist/charts.js +41 -22
- package/dist/experimental.cjs +1 -0
- package/dist/experimental.d.ts +3 -0
- package/dist/experimental.js +39 -0
- package/dist/headless.cjs +1 -1
- package/dist/headless.d.ts +3 -0
- package/dist/headless.js +55 -1
- package/dist/i18n.cjs +1 -1
- package/dist/i18n.d.ts +3 -0
- package/dist/i18n.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +29 -6
- package/dist/index.js +694 -586
- package/dist/quantum.cjs +1 -1
- package/dist/quantum.d.ts +3 -0
- package/dist/quantum.js +59 -74
- package/dist/realtime.cjs +1 -1
- package/dist/realtime.d.ts +3 -0
- package/dist/realtime.js +1 -1
- package/dist/src/agent/a2a/A2AClient.d.ts +32 -0
- package/dist/src/agent/a2a/a2aTool.d.ts +11 -0
- package/dist/src/agent/a2a/createA2ARoute.d.ts +5 -0
- package/dist/src/agent/bindings/solid.d.ts +12 -0
- package/dist/src/agent/bindings/svelte.d.ts +10 -0
- package/dist/src/agent/bindings/vanilla.d.ts +17 -0
- package/dist/src/agent/bindings/vue.d.ts +15 -0
- package/dist/src/agent/components/TkxAgentMessage.d.ts +15 -0
- package/dist/src/agent/components/TkxReasoningTrace.d.ts +9 -0
- package/dist/src/agent/components/TkxToolCallCard.d.ts +12 -0
- package/dist/src/agent/content/helpers.d.ts +17 -0
- package/dist/src/agent/core/Agent.d.ts +29 -0
- package/dist/src/agent/core/Memory.d.ts +12 -0
- package/dist/src/agent/core/Middleware.d.ts +10 -0
- package/dist/src/agent/core/Provider.d.ts +44 -0
- package/dist/src/agent/core/Sanitizer.d.ts +4 -0
- package/dist/src/agent/core/Tool.d.ts +13 -0
- package/dist/src/agent/core/Transport.d.ts +18 -0
- package/dist/src/agent/core/events.d.ts +19 -0
- package/dist/src/agent/core/sse.d.ts +6 -0
- package/dist/src/agent/core/types.d.ts +39 -0
- package/dist/src/agent/devtools/DevToolsPanel.d.ts +8 -0
- package/dist/src/agent/devtools/useEventCollector.d.ts +8 -0
- package/dist/src/agent/eval/runEval.d.ts +31 -0
- package/dist/src/agent/index.d.ts +54 -0
- package/dist/src/agent/mcp/MCPClient.d.ts +33 -0
- package/dist/src/agent/mcp/mcpAdapter.d.ts +3 -0
- package/dist/src/agent/memory/SlidingWindowMemory.d.ts +10 -0
- package/dist/src/agent/memory/SummarizingMemory.d.ts +16 -0
- package/dist/src/agent/memory/VectorMemory.d.ts +17 -0
- package/dist/src/agent/middleware/guardrails.d.ts +20 -0
- package/dist/src/agent/middleware/otel.d.ts +13 -0
- package/dist/src/agent/middleware/retry.d.ts +11 -0
- package/dist/src/agent/middleware/tokenUsage.d.ts +27 -0
- package/dist/src/agent/multi/agentAsTool.d.ts +11 -0
- package/dist/src/agent/providers/anthropic.d.ts +16 -0
- package/dist/src/agent/providers/gemini.d.ts +16 -0
- package/dist/src/agent/providers/ollama.d.ts +14 -0
- package/dist/src/agent/providers/openai.d.ts +16 -0
- package/dist/src/agent/rag/Retriever.d.ts +13 -0
- package/dist/src/agent/rag/retrievalTool.d.ts +11 -0
- package/dist/src/agent/react/useAgent.d.ts +12 -0
- package/dist/src/agent/replay/ReplayProvider.d.ts +13 -0
- package/dist/src/agent/replay/recorder.d.ts +16 -0
- package/dist/src/agent/research/DeepResearch.d.ts +37 -0
- package/dist/src/agent/research/citations.d.ts +10 -0
- package/dist/src/agent/server/createAgentClient.d.ts +11 -0
- package/dist/src/agent/server/createAgentRoute.d.ts +10 -0
- package/dist/src/agent/structured/generateObject.d.ts +19 -0
- package/dist/src/agent/tools/cancellable.d.ts +6 -0
- package/dist/src/charts/TkxDataExplorer.d.ts +17 -0
- package/dist/src/charts/index.d.ts +2 -0
- package/dist/src/components/TkxAppBar.d.ts +2 -1
- package/dist/src/components/TkxButton.d.ts +1 -0
- package/dist/src/components/TkxCommandPalette.d.ts +32 -0
- package/dist/src/components/TkxDataGrid.d.ts +37 -1
- package/dist/src/components/TkxFlowChart.d.ts +52 -0
- package/dist/src/components/TkxFormBuilder.d.ts +34 -0
- package/dist/src/components/TkxFormulaBar.d.ts +19 -0
- package/dist/src/components/TkxFunnelChart.d.ts +21 -0
- package/dist/src/components/TkxGantt.d.ts +29 -0
- package/dist/src/components/TkxGauge.d.ts +21 -0
- package/dist/src/components/TkxHeatmap.d.ts +25 -0
- package/dist/src/components/TkxHolographic.d.ts +2 -0
- package/dist/src/components/TkxHolographicAdvanced.d.ts +48 -0
- package/dist/src/components/TkxMindMap.d.ts +22 -0
- package/dist/src/components/TkxPivotTable.d.ts +21 -0
- package/dist/src/components/TkxSparkline.d.ts +15 -0
- package/dist/src/components/TkxSpreadsheet.d.ts +33 -0
- package/dist/src/components/TkxTreemap.d.ts +21 -0
- package/dist/src/components/TkxTypography.d.ts +1 -1
- package/dist/src/components/index.d.ts +5 -3
- package/dist/src/engine/security.d.ts +3 -0
- package/dist/src/experimental/index.d.ts +8 -0
- package/dist/src/headless/index.d.ts +6 -0
- package/dist/src/headless/rhfBindings.d.ts +59 -0
- package/dist/src/headless/useFormState.d.ts +12 -2
- package/dist/src/headless/valibotResolver.d.ts +25 -0
- package/dist/src/headless/zodResolver.d.ts +25 -0
- package/dist/src/i18n/index.d.ts +20 -0
- package/dist/src/i18n/plurals.d.ts +4 -0
- package/dist/src/quantum/index.d.ts +0 -2
- package/dist/src/themes/index.d.ts +7 -1
- package/dist/themes.cjs +1 -0
- package/dist/themes.d.ts +3 -0
- package/dist/themes.js +1 -0
- package/package.json +32 -8
- package/dist/chunk-BHX35YDv.js +0 -1
- package/dist/chunk-BpuJ3-K8.js +0 -1
- package/dist/chunk-Bze40nDX.js +0 -1
- package/dist/chunk-C8Wy8P59.js +0 -1
- package/dist/chunk-D7-yknXg.js +0 -1
- package/dist/chunk-DTO-RrPx.js +0 -3
- package/dist/chunk-DcVMayoM.js +0 -1
- package/dist/chunk-DdHSYetV.js +0 -1
- package/dist/chunk-DmRB1Blb.js +0 -1
package/dist/realtime.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("./chunk-DmRB1Blb.js");const e=require("./chunk-BpuJ3-K8.js"),t=require("./chunk-D7-yknXg.js");let n=require("react");var o=!1;function r({item:e,isNew:o,showTimestamps:r,onItemClick:i,renderItem:s,theme:a,style:l}){const c=function(e,t){switch(e){case"info":return t.info;case"success":return t.success;case"warning":return t.warning;case"error":return t.danger;default:return t.border}}(e.type,a);return s?(0,n.createElement)("div",{style:l,className:o?"tkx-feed-item-new":void 0},s(e)):(0,n.createElement)("div",{style:{...l,display:"flex",alignItems:"center",gap:10,padding:"0 12px",borderLeft:`3px solid ${c}`,cursor:i?"pointer":"default",boxSizing:"border-box",height:64,background:a.surface,transition:"background 0.15s"},className:o?"tkx-feed-item-new":void 0,onClick:i?()=>i(e):void 0,role:i?"button":void 0,tabIndex:i?0:void 0,onKeyDown:i?t=>{"Enter"!==t.key&&" "!==t.key||i(e)}:void 0},(0,n.createElement)("div",{style:{width:36,height:36,borderRadius:"50%",background:c,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:a.bg,flexShrink:0,overflow:"hidden"}},e.avatar?(0,n.createElement)("img",{src:e.avatar,alt:e.author??"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(d=e.author)?d.split(" ").map(e=>e[0]??"").slice(0,2).join("").toUpperCase():"?"),(0,n.createElement)("div",{style:{flex:1,minWidth:0}},(0,n.createElement)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2}},e.author&&(0,n.createElement)("span",{style:{fontWeight:600,fontSize:13,color:a.text}},t.sanitizeString(e.author)),e.meta&&(0,n.createElement)("span",{style:{fontSize:11,color:a.textMuted,background:a.surfaceAlt,borderRadius:4,padding:"1px 5px"}},t.sanitizeString(e.meta))),(0,n.createElement)("div",{style:{fontSize:13,color:a.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t.sanitizeString(e.content))),r&&(0,n.createElement)("div",{style:{fontSize:11,color:a.textMuted,flexShrink:0}},function(e){const t=Date.now()-e;return t<1e4?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}(e.timestamp)));var d}var i=!1;function s(e,t){if("string"==typeof e)return e;const n=e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Number.isInteger(e)?e:e.toFixed(2));return t?`${n}${t}`:n}function a({data:e,color:t}){if(e.length<2)return null;const o=Math.min(...e),r=Math.max(...e)-o||1,i=e.map((t,n)=>{const i=n/(e.length-1)*80,s=24-(t-o)/r*22-1;return`${i.toFixed(1)},${s.toFixed(1)}`});return(0,n.createElement)("svg",{width:80,height:24,viewBox:"0 0 80 24","aria-hidden":"true"},(0,n.createElement)("polyline",{points:i.join(" "),fill:"none",stroke:t,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}))}function l({trend:e,theme:t}){return"up"===e?(0,n.createElement)("span",{style:{color:t.success,fontSize:14,fontWeight:700}},"▲"):"down"===e?(0,n.createElement)("span",{style:{color:t.danger,fontSize:14,fontWeight:700}},"▼"):(0,n.createElement)("span",{style:{color:t.textMuted,fontSize:14}},"→")}function c({metric:e,animate:o,onMetricClick:r,theme:i}){const c=e.color??function(e,t){switch(e){case"warning":return t.warning;case"critical":return t.danger;default:return t.primary}}(e.status,i),d="number"==typeof e.value?e.value:NaN,u=function(e,t,o){const[r,i]=(0,n.useState)(e),s=(0,n.useRef)(e),a=(0,n.useRef)(null),l=(0,n.useRef)(null),c=function(){const[e,t]=(0,n.useState)(()=>"undefined"!=typeof window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,n.useEffect)(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=e=>t(e.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}();return(0,n.useEffect)(()=>{if(!o||c)return i(e),void(s.current=e);const t=s.current;if(t===e)return;a.current=null;const n=o=>{null===a.current&&(a.current=o);const r=o-a.current,c=Math.min(r/600,1),d=1-Math.pow(1-c,3);i(t+(e-t)*d),c<1?l.current=requestAnimationFrame(n):s.current=e};return l.current=requestAnimationFrame(n),()=>{null!==l.current&&cancelAnimationFrame(l.current)}},[e,600,o,c]),r}(isNaN(d)?0:d,0,o&&!isNaN(d)),[f,h]=(0,n.useState)(!1),m=(0,n.useRef)(e.value);(0,n.useEffect)(()=>{if(m.current!==e.value){m.current=e.value,h(!0);const t=window.setTimeout(()=>h(!1),700);return()=>clearTimeout(t)}},[e.value]);const p=void 0!==e.previousValue&&e.previousValue!==d,g={background:i.surface,border:`1px solid ${i.border}`,borderLeft:`4px solid ${c}`,borderRadius:8,padding:"14px 16px",cursor:r?"pointer":"default",position:"relative",overflow:"hidden",boxSizing:"border-box"},y=f?{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${c}22 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"tkx-metric-shimmer 0.6s ease-in-out",pointerEvents:"none"}:{},x=isNaN(d)?t.sanitizeString(String(e.value)):s(u,e.unit);return(0,n.createElement)("div",{style:g,className:f?"tkx-metric-shimmer":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0},f&&(0,n.createElement)("div",{style:y}),(0,n.createElement)("div",{style:{fontSize:12,color:i.textMuted,marginBottom:6,fontWeight:500,letterSpacing:"0.03em"}},t.sanitizeString(e.label)),(0,n.createElement)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,marginBottom:6}},(0,n.createElement)("span",{style:{fontSize:28,fontWeight:700,color:i.text,lineHeight:1}},x),e.unit&&isNaN(d)&&(0,n.createElement)("span",{style:{fontSize:14,color:i.textMuted,marginBottom:2}},t.sanitizeString(e.unit))),(e.trend||e.trendValue)&&(0,n.createElement)("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:e.sparkline?8:0}},e.trend&&(0,n.createElement)(l,{trend:e.trend,theme:i}),e.trendValue&&(0,n.createElement)("span",{style:{fontSize:12,color:i.textMuted}},t.sanitizeString(e.trendValue))),p&&(0,n.createElement)("div",{style:{fontSize:11,color:i.textMuted,marginTop:2}},`was ${s(e.previousValue)}`),e.sparkline&&e.sparkline.length>=2&&(0,n.createElement)("div",{style:{marginTop:8}},(0,n.createElement)(a,{data:e.sparkline,color:c})))}function d(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function u(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2)}var f={debug:0,info:1,warn:2,error:3,fatal:4},h=!1;function m({entry:e,showLevel:o,showTimestamp:r,showSource:i,searchQuery:s,monospace:a,isExpanded:l,onToggle:c,onEntryClick:d,theme:u,style:f}){const h=function(e,t){switch(e){case"debug":default:return t.textMuted;case"info":return t.info;case"warn":return t.warning;case"error":case"fatal":return t.danger}}(e.level,u),m=function(e,t){return"fatal"===e?`${t.danger}22`:"transparent"}(e.level,u),p=e.metadata&&Object.keys(e.metadata).length>0,g={...f,display:"flex",alignItems:"center",gap:6,padding:"0 10px",fontSize:12,fontFamily:a?'"JetBrains Mono", "Fira Mono", Consolas, monospace':"inherit",cursor:p||d?"pointer":"default",background:m,boxSizing:"border-box",height:28,overflow:"hidden",whiteSpace:"nowrap",borderBottom:`1px solid ${u.border}22`};return(0,n.createElement)("div",{style:g,className:"tkx-log-row",onClick:()=>{p&&c(),d&&d(e)},role:p?"button":void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{"Enter"!==e.key&&" "!==e.key||c()}:void 0,"aria-expanded":p?l:void 0},r&&(0,n.createElement)("span",{style:{color:u.textMuted,flexShrink:0,minWidth:84}},function(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}(e.timestamp)),o&&(0,n.createElement)("span",{style:{color:h,flexShrink:0,fontWeight:"fatal"===e.level?700:500,minWidth:56}},`[${e.level.toUpperCase().padEnd(5)}]`),i&&e.source&&(0,n.createElement)("span",{style:{background:u.surfaceAlt,border:`1px solid ${u.border}`,borderRadius:10,padding:"0 5px",fontSize:10,color:u.textMuted,flexShrink:0,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"}},t.sanitizeString(e.source)),(0,n.createElement)("span",{style:{flex:1,color:u.text,overflow:"hidden",textOverflow:"ellipsis"}},...function(e,o){if(!o)return[e];const r=t.sanitizeString(e),i=t.sanitizeString(o);if(!i)return[r];try{const e=new RegExp(`(${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return r.split(e).map((t,o)=>e.test(t)?(0,n.createElement)("mark",{key:o,className:"tkx-log-highlight"},t):t)}catch{return[r]}}(e.message,s)),p&&(0,n.createElement)("span",{style:{color:u.textMuted,fontSize:10,flexShrink:0}},l?"▲":"▼"))}function p({metadata:e,theme:o,style:r}){return(0,n.createElement)("div",{style:{...r,background:o.surfaceAlt,borderBottom:`1px solid ${o.border}`,padding:"6px 10px 6px 56px",display:"flex",flexWrap:"wrap",gap:6,boxSizing:"border-box"}},...Object.entries(e).map(([e,r])=>(0,n.createElement)("span",{key:e,style:{fontSize:11,fontFamily:"monospace",color:o.textMuted,background:o.surface,border:`1px solid ${o.border}`,borderRadius:4,padding:"1px 6px"}},(0,n.createElement)("span",{style:{color:o.info}},`${t.sanitizeString(e)}: `),t.sanitizeString(String(r)))))}exports.TkxLiveFeed=function({items:i,maxItems:s=100,height:a=400,autoScroll:l=!0,showTimestamps:c=!0,onItemClick:d,emptyMessage:u="No activity yet.",pauseOnHover:f=!0,renderItem:h}){const m=e.useTheme();!function(){if(o||"undefined"==typeof document)return;o=!0;const e=document.createElement("style");e.id="tkx-live-feed-styles",e.textContent="\n@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}\n ".trim(),document.head.appendChild(e)}();const p=(0,n.useRef)(null),[g,y]=(0,n.useState)(0),[x,b]=(0,n.useState)(!1),[k,v]=(0,n.useState)(new Set),w=(0,n.useRef)([]),S=(0,n.useMemo)(()=>i.slice(-s),[i,s]),$="number"==typeof a?a:400,M=64*S.length;(0,n.useEffect)(()=>{const e=new Set(w.current.map(e=>e.id)),t=S.filter(t=>!e.has(t.id)).map(e=>e.id);if(t.length>0){v(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n});const e=window.setTimeout(()=>{v(e=>{const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},400);return()=>clearTimeout(e)}},[S]),(0,n.useEffect)(()=>{w.current=S},[S]);const z=l&&!(f&&x);(0,n.useEffect)(()=>{if(!z||!p.current)return;const e=p.current;(e.scrollHeight-e.scrollTop-e.clientHeight<192||S.length<=5)&&(e.scrollTop=e.scrollHeight)},[S.length,z]);const N=(0,n.useCallback)(()=>{p.current&&y(p.current.scrollTop)},[]),W=Math.max(0,Math.floor(g/64)-5),I=Math.min(S.length-1,Math.ceil((g+$)/64)+5),L={position:"relative",overflow:"auto",height:"number"==typeof a?`${a}px`:a,background:m.bg,border:`1px solid ${m.border}`,borderRadius:8,boxSizing:"border-box"},C={position:"relative",height:M,minHeight:"100%"};if(0===S.length)return(0,n.createElement)("div",{style:{...L,display:"flex",alignItems:"center",justifyContent:"center"}},(0,n.createElement)("span",{style:{color:m.textMuted,fontSize:14}},t.sanitizeString(u)));const j=[];for(let e=W;e<=I;e++){const t=S[e];t&&j.push((0,n.createElement)(r,{key:t.id,item:t,isNew:k.has(t.id),showTimestamps:c,onItemClick:d,renderItem:h,theme:m,style:{position:"absolute",top:64*e,left:0,right:0}}))}return(0,n.createElement)("div",{ref:p,style:L,onScroll:N,onMouseEnter:f?()=>b(!0):void 0,onMouseLeave:f?()=>b(!1):void 0,"aria-label":"Live feed",role:"feed"},(0,n.createElement)("div",{style:C},...j))},exports.TkxLiveLog=function({entries:t,maxEntries:o=500,height:r=400,autoScroll:i=!0,showLevel:s=!0,showTimestamp:a=!0,showSource:l=!0,filterLevel:c,searchQuery:d="",monospace:u=!0,onEntryClick:g}){const y=e.useTheme();!function(){if(h||"undefined"==typeof document)return;h=!0;const e=document.createElement("style");e.id="tkx-live-log-styles",e.textContent="\n.tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }\n ".trim(),document.head.appendChild(e)}();const x=(0,n.useRef)(null),[b,k]=(0,n.useState)(0),[v,w]=(0,n.useState)(new Set),[S,$]=(0,n.useState)(!1),M=(0,n.useRef)(t.length),z=(0,n.useMemo)(()=>{let e=t.slice(-o);if(void 0!==c){const t=f[c];e=e.filter(e=>f[e.level]>=t)}if(d){const t=d.toLowerCase();e=e.filter(e=>e.message.toLowerCase().includes(t)||(e.source??"").toLowerCase().includes(t))}return e},[t,o,c,d]),N="number"==typeof r?r:400,W=(0,n.useMemo)(()=>{const e=[];let t=0;for(const n of z)e.push(t),t+=28+(v.has(n.id)?40:0);return e.push(t),e},[z,v]),I=W[W.length-1]??0;(0,n.useEffect)(()=>{i&&!S&&z.length!==M.current&&(M.current=z.length,x.current&&(x.current.scrollTop=x.current.scrollHeight))},[z.length,i,S]);const L=(0,n.useCallback)(()=>{if(!x.current)return;const e=x.current;$(!(e.scrollHeight-e.scrollTop-e.clientHeight<56)),k(e.scrollTop)},[]),C=(0,n.useCallback)(e=>{w(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),j=z.length>0?function(e){let t=0,n=z.length-1;for(;t<n;){const o=t+n>>1;(W[o+1]??0)<=e?t=o+1:n=o}return Math.max(0,t-8)}(b):0,T=z.length>0?function(e){let t=0,n=z.length-1;for(;t<n;){const o=t+n+1>>1;(W[o]??0)>=e+N?n=o-1:t=o}return Math.min(z.length-1,t+8)}(b):-1,E={position:"relative",overflow:"auto",height:"number"==typeof r?`${r}px`:r,background:y.bg,border:`1px solid ${y.border}`,borderRadius:8,boxSizing:"border-box"},R={position:"relative",height:I,minHeight:"100%"};if(0===z.length)return(0,n.createElement)("div",{style:{...E,display:"flex",alignItems:"center",justifyContent:"center"}},(0,n.createElement)("span",{style:{color:y.textMuted,fontSize:13,fontFamily:"monospace"}},"No log entries."));const B=[];for(let e=j;e<=T;e++){const t=z[e];if(!t)continue;const o=W[e]??0,r=v.has(t.id);B.push((0,n.createElement)(m,{key:t.id,entry:t,showLevel:s,showTimestamp:a,showSource:l,searchQuery:d,monospace:u,isExpanded:r,onToggle:()=>C(t.id),onEntryClick:g,theme:y,style:{position:"absolute",top:o,left:0,right:0}})),r&&t.metadata&&Object.keys(t.metadata).length>0&&B.push((0,n.createElement)(p,{key:`${t.id}-meta`,metadata:t.metadata,theme:y,style:{position:"absolute",top:o+28,left:0,right:0,height:40}}))}return(0,n.createElement)("div",{ref:x,style:E,onScroll:L,role:"log","aria-live":"polite","aria-label":"Log viewer"},(0,n.createElement)("div",{style:R},...B))},exports.TkxLiveMetrics=function({metrics:t,columns:o=3,animate:r=!0,onMetricClick:s}){const a=e.useTheme();return function(){if(i||"undefined"==typeof document)return;i=!0;const e=document.createElement("style");e.id="tkx-live-metrics-styles",e.textContent="\n@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}\n ".trim(),document.head.appendChild(e)}(),(0,n.createElement)("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o}, minmax(0, 1fr))`,gap:16}},...t.map(e=>(0,n.createElement)(c,{key:e.id,metric:e,animate:r,onMetricClick:s,theme:a})))},exports.TkxRealTimeChart=function({data:o,maxPoints:r=60,height:i=200,width:s="100%",color:a,fill:l=!0,showGrid:c=!0,showLabels:f=!0,showTooltip:h=!0,label:m,unit:p,animate:g=!0,yMin:y,yMax:x}){const b=e.useTheme(),k=a??b.primary,v=(0,n.useRef)(null),[w,S]=(0,n.useState)(600),[$,M]=(0,n.useState)(null),[z,N]=(0,n.useState)(0),W=(0,n.useRef)(o.length);(0,n.useEffect)(()=>{if(!v.current)return;const e=new ResizeObserver(e=>{const t=e[0];t&&S(t.contentRect.width)});return e.observe(v.current),S(v.current.offsetWidth),()=>e.disconnect()},[]);const I=(0,n.useMemo)(()=>o.slice(-r),[o,r]);(0,n.useEffect)(()=>{I.length>W.current&&N(e=>e+1),W.current=I.length},[I.length]);const L=f?48:12,C=m?28:12,j=Math.max(w-L-12,1),T=Math.max(i-C-28,1),E=I.length?Math.min(...I.map(e=>e.value)):0,R=I.length?Math.max(...I.map(e=>e.value)):1,B=R-E||1,O=void 0!==y?y:E-.1*B,F=(void 0!==x?x:R+.1*B)-O||1;function D(e){return I.length<2?j/2:e/(I.length-1)*j}function q(e){return T-(e-O)/F*T}const A=I.length>=2?I.map((e,t)=>`${0===t?"M":"L"}${D(t).toFixed(2)},${q(e.value).toFixed(2)}`).join(" "):"",H=A?`${A} L${D(I.length-1).toFixed(2)},${T} L${D(0).toFixed(2)},${T} Z`:"",P=[];for(let e=0;e<=4;e++)P.push(e);const Q=P.map(e=>{const t=O+e/4*F;return{y:q(t),text:u(t)}}),K=Math.min(4,I.length),Y=K>0?Array.from({length:K},(e,t)=>Math.round(t/Math.max(K-1,1)*(I.length-1))):[],G=(0,n.useCallback)(e=>{if(!h||0===I.length)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left-L;let o=0,r=1/0;I.forEach((e,t)=>{const i=Math.abs(D(t)-n);i<r&&(r=i,o=t)});const i=I[o];i&&M({x:D(o)+L,y:q(i.value)+C,point:i})},[I,h,L,C]),J=(0,n.useCallback)(()=>M(null),[]),Z=w,U=i,V=`tkx-chart-clip-${z}`;return(0,n.createElement)("div",{ref:v,style:{position:"relative",width:"number"==typeof s?`${s}px`:s,background:b.surface,border:`1px solid ${b.border}`,borderRadius:8,overflow:"hidden",boxSizing:"border-box"}},(0,n.createElement)("svg",{width:Z,height:U,viewBox:`0 0 ${Z} ${U}`,onMouseMove:G,onMouseLeave:J,style:{display:"block",userSelect:"none"},"aria-label":m?t.sanitizeString(m):"Real-time chart"},g&&I.length>=2&&(0,n.createElement)("defs",null,(0,n.createElement)("clipPath",{id:V},(0,n.createElement)("rect",{x:0,y:0,width:j,height:U},(0,n.createElement)("animate",{attributeName:"width",from:Math.max(0,j-j/Math.max(I.length-1,1)),to:j,dur:"0.3s",fill:"freeze"})))),m&&(0,n.createElement)("text",{x:L,y:18,fill:b.textMuted,fontSize:12,fontWeight:500},t.sanitizeString(m)),c&&P.map(e=>{const t=q(O+e/4*F)+C;return(0,n.createElement)("line",{key:`grid-${e}`,x1:L,y1:t,x2:L+j,y2:t,stroke:b.border,strokeWidth:1,strokeDasharray:"4 4"})}),f&&Q.map((e,t)=>(0,n.createElement)("text",{key:`yl-${t}`,x:L-4,y:e.y+C+4,fill:b.textMuted,fontSize:10,textAnchor:"end"},e.text)),p&&(0,n.createElement)("text",{x:4,y:C+10,fill:b.textMuted,fontSize:9},t.sanitizeString(p)),l&&H&&(0,n.createElement)("path",{d:H,fill:`${k}22`,clipPath:g?`url(#${V})`:void 0,transform:`translate(${L}, ${C})`}),A&&(0,n.createElement)("path",{d:A,fill:"none",stroke:k,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",clipPath:g?`url(#${V})`:void 0,transform:`translate(${L}, ${C})`}),Y.map(e=>{const t=I[e];return t?(0,n.createElement)("text",{key:`xl-${e}`,x:L+D(e),y:U-8,fill:b.textMuted,fontSize:9,textAnchor:"middle"},d(t.timestamp)):null}),$&&(0,n.createElement)("line",{x1:$.x,y1:C,x2:$.x,y2:C+T,stroke:k,strokeWidth:1,strokeDasharray:"3 3",opacity:.6}),$&&(0,n.createElement)("circle",{cx:$.x,cy:$.y,r:4,fill:k,stroke:b.surface,strokeWidth:2}),$&&(()=>{const e=Math.min($.x+8,Z-100),t=Math.max($.y-36,4),o=`${u($.point.value)}${p||""}`,r=d($.point.timestamp);return(0,n.createElement)("g",null,(0,n.createElement)("rect",{x:e-4,y:t-2,width:90,height:34,rx:4,fill:b.surfaceAlt,stroke:b.border,strokeWidth:1}),(0,n.createElement)("text",{x:e,y:t+11,fill:b.text,fontSize:12,fontWeight:700},o),(0,n.createElement)("text",{x:e,y:t+26,fill:b.textMuted,fontSize:10},r))})()))};
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let e=require("react");var t=(0,e.createContext)({bg:"#0a0a0f",surface:"#12121a",surfaceAlt:"#1a1a2e",border:"#2a2a3e",text:"#e8e8f4",textMuted:"#8888aa",primary:"#00f5d4",secondary:"#7b2ff7",danger:"#f72585",warning:"#ffbe0b",success:"#06d6a0",info:"#3a86ff"});function n(){return(0,e.useContext)(t)}new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var r={"<":"<",">":">","&":"&","'":"'",'"':""","`":"`"};function o(e){if(null==e)return"";let t=String(e);return t=t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,""),t.replace(/[<>&'"`]/g,e=>r[e]??e)}function i(e){if("string"!=typeof e)return null;const t=e.trim();if(!t)return null;const n=t.replace(/[\u0000-\u001F\u007F]/g,"");return/^javascript:/i.test(n)||/^vbscript:/i.test(n)||/^data:/i.test(n)&&!/^data:image\//i.test(n)||/^file:/i.test(n)?null:n}var s=new Set(["a","abbr","b","blockquote","br","code","del","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","mark","ol","p","pre","q","s","samp","small","span","strong","sub","sup","table","tbody","td","tfoot","th","thead","tr","u","ul"]),a={a:new Set(["href","title","target","rel"]),img:new Set(["src","alt","title","width","height","loading","decoding"]),th:new Set(["scope","colspan","rowspan","align"]),td:new Set(["colspan","rowspan","align"]),"*":new Set(["id","class","lang","dir","title"])},l=new Set(["constructor","prototype","__proto__","submit","reset","action","method","enctype","target","elements","children","firstChild","nextSibling","parentNode","ownerDocument","cookie","domain","location","documentElement","body","head","title","contentWindow","contentDocument"]);function c(e){if("string"!=typeof e)return"";if("undefined"==typeof DOMParser)return o(e);const t=(new DOMParser).parseFromString(`<div>${e}</div>`,"text/html").body.firstElementChild;return t?(d(t),t.innerHTML):""}function d(e){const t=Array.from(e.children);for(const n of t){const e=n.tagName.toLowerCase();if(s.has(e)){for(const t of Array.from(n.attributes)){const r=t.name.toLowerCase();if(r.startsWith("on"))n.removeAttribute(t.name);else if(l.has(r))n.removeAttribute(t.name);else if("style"!==r)if((a[e]??new Set).has(r)||a["*"].has(r)){if(("href"===r||"src"===r)&&"string"==typeof t.value){const e=i(t.value);null===e?n.removeAttribute(t.name):n.setAttribute(t.name,e)}"name"!==r&&"id"!==r||!l.has(t.value.toLowerCase())||n.removeAttribute(t.name)}else n.removeAttribute(t.name);else n.setAttribute("style",u(t.value))}d(n)}else n.remove()}}function u(e){if("string"!=typeof e)return"";let t=e;return t=t.replace(/expression\s*\([^)]*\)/gi,""),t=t.replace(/url\s*\(\s*['"]?\s*(javascript|vbscript|data)\s*:[^)]*\)/gi,"url(#)"),t=t.replace(/@import[^;]*;?/gi,""),t=t.replace(/behavior\s*:[^;]*;?/gi,""),t=t.replace(/-moz-binding[^;]*;?/gi,""),t=t.replace(/[<>]/g,""),t=t.replace(/[\u0000-\u001F\u007F]/g,""),t.trim()}var f=new Set(["__proto__","constructor","prototype"]);function p(e){if(Array.isArray(e))return e.map(p);if(e&&"object"==typeof e){const t={};for(const[n,r]of Object.entries(e))f.has(n)||(t[n]=p(r));return t}return e}function m(){if("undefined"==typeof window)return!1;try{return window.top!==window.self}catch{return!0}}var h=[{name:"ssn",re:/\b\d{3}-\d{2}-\d{4}\b/g,repl:"[redacted-ssn]"},{name:"credit",re:/\b(?:\d[ -]?){13,19}\b/g,repl:e=>{const t=e.replace(/[ -]/g,"");return t.length<13||t.length>19?e:function(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let o=e.charCodeAt(r)-48;if(o<0||o>9)return!1;n&&(o*=2,o>9&&(o-=9)),t+=o,n=!n}return t>0&&t%10==0}(t)?"[redacted-card]":e}},{name:"email",re:/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,repl:"[redacted-email]"},{name:"phone",re:/\b(\+?\d{1,3}[ -])?\(?\d{3}\)?[ -]?\d{3}[ -]?\d{4}\b/g,repl:"[redacted-phone]"},{name:"apikey",re:/\b(sk|pk|rk)-[A-Za-z0-9]{20,}\b/g,repl:"[redacted-key]"}];Object.freeze({sanitizeString:o,sanitizeHref:i,sanitizeHTML:c,sanitizeCSS:u,sanitizeJSON:function(e){try{return p(JSON.parse(e,(e,t)=>{if(!f.has(e))return t}))}catch{return null}},sanitizeUnicode:function(e){return"string"!=typeof e?"":e.replace(/[\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFEFF\u00AD]/g,"")},isSafeAttrName:function(e){return!("string"!=typeof e||!e||/[\u0000-\u001F\u007F<>"]/.test(e)||l.has(e.toLowerCase()))},buildTkxCSP:function(e={}){const{allowInlineStyles:t=!0,imgHosts:n=[],connectHosts:r=[],fontHosts:o=[],scriptNonce:i,reportUri:s}=e,a=["default-src 'self'","script-src "+(i?`'self' 'nonce-${i}'`:"'self'"),"style-src "+(t?"'self' 'unsafe-inline'":"'self'"),`img-src ${["'self'","data:","https:",...n].join(" ")}`,`font-src ${["'self'","https:","data:",...o].join(" ")}`,`connect-src ${["'self'",...r].join(" ")}`,"frame-ancestors 'none'","form-action 'self'","base-uri 'self'","object-src 'none'","upgrade-insecure-requests"];return s&&a.push(`report-uri ${s}`),a.join("; ")},installTrustedTypes:function(){if("undefined"==typeof window)return;const e=window.trustedTypes;if(e)try{e.createPolicy("tkx",{createHTML:c,createScriptURL:e=>i(e)??"",createScript:()=>{throw new Error("TekiVex: inline script creation forbidden")}})}catch{}},isFramed:m,installFrameBuster:function(e){if("undefined"!=typeof window&&m())if(e)e();else try{window.top.location.href=window.self.location.href}catch{}},createRateLimiter:function(e,t){let n=e,r=Date.now();return{check(){const o=Date.now(),i=o-r,s=Math.floor(i/t);return s>0&&(n=Math.min(e,n+s),r=o),!(n<=0||(n-=1,0))},reset(){n=e,r=Date.now()}}},sniffMimeType:async function(e){const t=new Uint8Array(await e.slice(0,12).arrayBuffer()),n=(...e)=>e.every((e,n)=>t[n]===e);return n(137,80,78,71)?"image/png":n(255,216,255)?"image/jpeg":n(71,73,70,56)?"image/gif":n(66,77)?"image/bmp":n(82,73,70,70)&&87===t[8]&&69===t[9]&&66===t[10]&&80===t[11]?"image/webp":n(37,80,68,70)?"application/pdf":n(80,75,3,4)?"application/zip":123===t[0]||91===t[0]?"application/json":[...t].includes(0)?null:"text/plain"},scrubPII:function(e){if("string"!=typeof e)return"";let t=e;for(const{re:n,repl:r}of h)t=t.replace(n,r);return t},deepFreeze:function e(t){if(t&&"object"==typeof t&&!Object.isFrozen(t)){for(const n of Object.keys(t))e(t[n]);Object.freeze(t)}return t},__brand:"TekiVex SecurityCore v2.6.0 © 007krcs"});var g=!1;function y({item:t,isNew:n,showTimestamps:r,onItemClick:i,renderItem:s,theme:a,style:l}){const c=function(e,t){switch(e){case"info":return t.info;case"success":return t.success;case"warning":return t.warning;case"error":return t.danger;default:return t.border}}(t.type,a);return s?(0,e.createElement)("div",{style:l,className:n?"tkx-feed-item-new":void 0},s(t)):(0,e.createElement)("div",{style:{...l,display:"flex",alignItems:"center",gap:10,padding:"0 12px",borderLeft:`3px solid ${c}`,cursor:i?"pointer":"default",boxSizing:"border-box",height:64,background:a.surface,transition:"background 0.15s"},className:n?"tkx-feed-item-new":void 0,onClick:i?()=>i(t):void 0,role:i?"button":void 0,tabIndex:i?0:void 0,onKeyDown:i?e=>{"Enter"!==e.key&&" "!==e.key||i(t)}:void 0},(0,e.createElement)("div",{style:{width:36,height:36,borderRadius:"50%",background:c,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:a.bg,flexShrink:0,overflow:"hidden"}},t.avatar?(0,e.createElement)("img",{src:t.avatar,alt:t.author??"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(d=t.author)?d.split(" ").map(e=>e[0]??"").slice(0,2).join("").toUpperCase():"?"),(0,e.createElement)("div",{style:{flex:1,minWidth:0}},(0,e.createElement)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2}},t.author&&(0,e.createElement)("span",{style:{fontWeight:600,fontSize:13,color:a.text}},o(t.author)),t.meta&&(0,e.createElement)("span",{style:{fontSize:11,color:a.textMuted,background:a.surfaceAlt,borderRadius:4,padding:"1px 5px"}},o(t.meta))),(0,e.createElement)("div",{style:{fontSize:13,color:a.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},o(t.content))),r&&(0,e.createElement)("div",{style:{fontSize:11,color:a.textMuted,flexShrink:0}},function(e){const t=Date.now()-e;return t<1e4?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}(t.timestamp)));var d}var b=!1;function x(e,t){if("string"==typeof e)return e;const n=e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Number.isInteger(e)?e:e.toFixed(2));return t?`${n}${t}`:n}function w({data:t,color:n}){if(t.length<2)return null;const r=Math.min(...t),o=Math.max(...t)-r||1,i=t.map((e,n)=>{const i=n/(t.length-1)*80,s=24-(e-r)/o*22-1;return`${i.toFixed(1)},${s.toFixed(1)}`});return(0,e.createElement)("svg",{width:80,height:24,viewBox:"0 0 80 24","aria-hidden":"true"},(0,e.createElement)("polyline",{points:i.join(" "),fill:"none",stroke:n,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}))}function v({trend:t,theme:n}){return"up"===t?(0,e.createElement)("span",{style:{color:n.success,fontSize:14,fontWeight:700}},"▲"):"down"===t?(0,e.createElement)("span",{style:{color:n.danger,fontSize:14,fontWeight:700}},"▼"):(0,e.createElement)("span",{style:{color:n.textMuted,fontSize:14}},"→")}function k({metric:t,animate:n,onMetricClick:r,theme:i}){const s=t.color??function(e,t){switch(e){case"warning":return t.warning;case"critical":return t.danger;default:return t.primary}}(t.status,i),a="number"==typeof t.value?t.value:NaN,l=function(t,n,r){const[o,i]=(0,e.useState)(t),s=(0,e.useRef)(t),a=(0,e.useRef)(null),l=(0,e.useRef)(null),c=function(){const[t,n]=(0,e.useState)(()=>"undefined"!=typeof window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,e.useEffect)(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=e=>n(e.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),t}();return(0,e.useEffect)(()=>{if(!r||c)return i(t),void(s.current=t);const e=s.current;if(e===t)return;a.current=null;const n=r=>{null===a.current&&(a.current=r);const o=r-a.current,c=Math.min(o/600,1),d=1-Math.pow(1-c,3);i(e+(t-e)*d),c<1?l.current=requestAnimationFrame(n):s.current=t};return l.current=requestAnimationFrame(n),()=>{null!==l.current&&cancelAnimationFrame(l.current)}},[t,600,r,c]),o}(isNaN(a)?0:a,0,n&&!isNaN(a)),[c,d]=(0,e.useState)(!1),u=(0,e.useRef)(t.value);(0,e.useEffect)(()=>{if(u.current!==t.value){u.current=t.value,d(!0);const e=window.setTimeout(()=>d(!1),700);return()=>clearTimeout(e)}},[t.value]);const f=void 0!==t.previousValue&&t.previousValue!==a,p={background:i.surface,border:`1px solid ${i.border}`,borderLeft:`4px solid ${s}`,borderRadius:8,padding:"14px 16px",cursor:r?"pointer":"default",position:"relative",overflow:"hidden",boxSizing:"border-box"},m=c?{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${s}22 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"tkx-metric-shimmer 0.6s ease-in-out",pointerEvents:"none"}:{},h=isNaN(a)?o(String(t.value)):x(l,t.unit);return(0,e.createElement)("div",{style:p,className:c?"tkx-metric-shimmer":void 0,onClick:r?()=>r(t):void 0,role:r?"button":void 0,tabIndex:r?0:void 0},c&&(0,e.createElement)("div",{style:m}),(0,e.createElement)("div",{style:{fontSize:12,color:i.textMuted,marginBottom:6,fontWeight:500,letterSpacing:"0.03em"}},o(t.label)),(0,e.createElement)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,marginBottom:6}},(0,e.createElement)("span",{style:{fontSize:28,fontWeight:700,color:i.text,lineHeight:1}},h),t.unit&&isNaN(a)&&(0,e.createElement)("span",{style:{fontSize:14,color:i.textMuted,marginBottom:2}},o(t.unit))),(t.trend||t.trendValue)&&(0,e.createElement)("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:t.sparkline?8:0}},t.trend&&(0,e.createElement)(v,{trend:t.trend,theme:i}),t.trendValue&&(0,e.createElement)("span",{style:{fontSize:12,color:i.textMuted}},o(t.trendValue))),f&&(0,e.createElement)("div",{style:{fontSize:11,color:i.textMuted,marginTop:2}},`was ${x(t.previousValue)}`),t.sparkline&&t.sparkline.length>=2&&(0,e.createElement)("div",{style:{marginTop:8}},(0,e.createElement)(w,{data:t.sparkline,color:s})))}function S(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function $(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2)}var M={debug:0,info:1,warn:2,error:3,fatal:4},z=!1;function N({entry:t,showLevel:n,showTimestamp:r,showSource:i,searchQuery:s,monospace:a,isExpanded:l,onToggle:c,onEntryClick:d,theme:u,style:f}){const p=function(e,t){switch(e){case"debug":default:return t.textMuted;case"info":return t.info;case"warn":return t.warning;case"error":case"fatal":return t.danger}}(t.level,u),m=function(e,t){return"fatal"===e?`${t.danger}22`:"transparent"}(t.level,u),h=t.metadata&&Object.keys(t.metadata).length>0,g={...f,display:"flex",alignItems:"center",gap:6,padding:"0 10px",fontSize:12,fontFamily:a?'"JetBrains Mono", "Fira Mono", Consolas, monospace':"inherit",cursor:h||d?"pointer":"default",background:m,boxSizing:"border-box",height:28,overflow:"hidden",whiteSpace:"nowrap",borderBottom:`1px solid ${u.border}22`};return(0,e.createElement)("div",{style:g,className:"tkx-log-row",onClick:()=>{h&&c(),d&&d(t)},role:h?"button":void 0,tabIndex:h?0:void 0,onKeyDown:h?e=>{"Enter"!==e.key&&" "!==e.key||c()}:void 0,"aria-expanded":h?l:void 0},r&&(0,e.createElement)("span",{style:{color:u.textMuted,flexShrink:0,minWidth:84}},function(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}(t.timestamp)),n&&(0,e.createElement)("span",{style:{color:p,flexShrink:0,fontWeight:"fatal"===t.level?700:500,minWidth:56}},`[${t.level.toUpperCase().padEnd(5)}]`),i&&t.source&&(0,e.createElement)("span",{style:{background:u.surfaceAlt,border:`1px solid ${u.border}`,borderRadius:10,padding:"0 5px",fontSize:10,color:u.textMuted,flexShrink:0,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"}},o(t.source)),(0,e.createElement)("span",{style:{flex:1,color:u.text,overflow:"hidden",textOverflow:"ellipsis"}},...function(t,n){if(!n)return[t];const r=o(t),i=o(n);if(!i)return[r];try{const t=new RegExp(`(${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return r.split(t).map((n,r)=>t.test(n)?(0,e.createElement)("mark",{key:r,className:"tkx-log-highlight"},n):n)}catch{return[r]}}(t.message,s)),h&&(0,e.createElement)("span",{style:{color:u.textMuted,fontSize:10,flexShrink:0}},l?"▲":"▼"))}function F({metadata:t,theme:n,style:r}){return(0,e.createElement)("div",{style:{...r,background:n.surfaceAlt,borderBottom:`1px solid ${n.border}`,padding:"6px 10px 6px 56px",display:"flex",flexWrap:"wrap",gap:6,boxSizing:"border-box"}},...Object.entries(t).map(([t,r])=>(0,e.createElement)("span",{key:t,style:{fontSize:11,fontFamily:"monospace",color:n.textMuted,background:n.surface,border:`1px solid ${n.border}`,borderRadius:4,padding:"1px 6px"}},(0,e.createElement)("span",{style:{color:n.info}},`${o(t)}: `),o(String(r)))))}exports.TkxLiveFeed=function({items:t,maxItems:r=100,height:i=400,autoScroll:s=!0,showTimestamps:a=!0,onItemClick:l,emptyMessage:c="No activity yet.",pauseOnHover:d=!0,renderItem:u}){const f=n();!function(){if(g||"undefined"==typeof document)return;g=!0;const e=document.createElement("style");e.id="tkx-live-feed-styles",e.textContent="\n@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}\n ".trim(),document.head.appendChild(e)}();const p=(0,e.useRef)(null),[m,h]=(0,e.useState)(0),[b,x]=(0,e.useState)(!1),[w,v]=(0,e.useState)(new Set),k=(0,e.useRef)([]),S=(0,e.useMemo)(()=>t.slice(-r),[t,r]),$="number"==typeof i?i:400,M=64*S.length;(0,e.useEffect)(()=>{const e=new Set(k.current.map(e=>e.id)),t=S.filter(t=>!e.has(t.id)).map(e=>e.id);if(t.length>0){v(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n});const e=window.setTimeout(()=>{v(e=>{const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},400);return()=>clearTimeout(e)}},[S]),(0,e.useEffect)(()=>{k.current=S},[S]);const z=s&&!(d&&b);(0,e.useEffect)(()=>{if(!z||!p.current)return;const e=p.current;(e.scrollHeight-e.scrollTop-e.clientHeight<192||S.length<=5)&&(e.scrollTop=e.scrollHeight)},[S.length,z]);const N=(0,e.useCallback)(()=>{p.current&&h(p.current.scrollTop)},[]),F=Math.max(0,Math.floor(m/64)-5),j=Math.min(S.length-1,Math.ceil((m+$)/64)+5),C={position:"relative",overflow:"auto",height:"number"==typeof i?`${i}px`:i,background:f.bg,border:`1px solid ${f.border}`,borderRadius:8,boxSizing:"border-box"},L={position:"relative",height:M,minHeight:"100%"};if(0===S.length)return(0,e.createElement)("div",{style:{...C,display:"flex",alignItems:"center",justifyContent:"center"}},(0,e.createElement)("span",{style:{color:f.textMuted,fontSize:14}},o(c)));const T=[];for(let n=F;n<=j;n++){const t=S[n];t&&T.push((0,e.createElement)(y,{key:t.id,item:t,isNew:w.has(t.id),showTimestamps:a,onItemClick:l,renderItem:u,theme:f,style:{position:"absolute",top:64*n,left:0,right:0}}))}return(0,e.createElement)("div",{ref:p,style:C,onScroll:N,onMouseEnter:d?()=>x(!0):void 0,onMouseLeave:d?()=>x(!1):void 0,"aria-label":"Live feed",role:"feed"},(0,e.createElement)("div",{style:L},...T))},exports.TkxLiveLog=function({entries:t,maxEntries:r=500,height:o=400,autoScroll:i=!0,showLevel:s=!0,showTimestamp:a=!0,showSource:l=!0,filterLevel:c,searchQuery:d="",monospace:u=!0,onEntryClick:f}){const p=n();!function(){if(z||"undefined"==typeof document)return;z=!0;const e=document.createElement("style");e.id="tkx-live-log-styles",e.textContent="\n.tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }\n ".trim(),document.head.appendChild(e)}();const m=(0,e.useRef)(null),[h,g]=(0,e.useState)(0),[y,b]=(0,e.useState)(new Set),[x,w]=(0,e.useState)(!1),v=(0,e.useRef)(t.length),k=(0,e.useMemo)(()=>{let e=t.slice(-r);if(void 0!==c){const t=M[c];e=e.filter(e=>M[e.level]>=t)}if(d){const t=d.toLowerCase();e=e.filter(e=>e.message.toLowerCase().includes(t)||(e.source??"").toLowerCase().includes(t))}return e},[t,r,c,d]),S="number"==typeof o?o:400,$=(0,e.useMemo)(()=>{const e=[];let t=0;for(const n of k)e.push(t),t+=28+(y.has(n.id)?40:0);return e.push(t),e},[k,y]),j=$[$.length-1]??0;(0,e.useEffect)(()=>{i&&!x&&k.length!==v.current&&(v.current=k.length,m.current&&(m.current.scrollTop=m.current.scrollHeight))},[k.length,i,x]);const C=(0,e.useCallback)(()=>{if(!m.current)return;const e=m.current;w(!(e.scrollHeight-e.scrollTop-e.clientHeight<56)),g(e.scrollTop)},[]),L=(0,e.useCallback)(e=>{b(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),T=k.length>0?function(e){let t=0,n=k.length-1;for(;t<n;){const r=t+n>>1;($[r+1]??0)<=e?t=r+1:n=r}return Math.max(0,t-8)}(h):0,I=k.length>0?function(e){let t=0,n=k.length-1;for(;t<n;){const r=t+n+1>>1;($[r]??0)>=e+S?n=r-1:t=r}return Math.min(k.length-1,t+8)}(h):-1,W={position:"relative",overflow:"auto",height:"number"==typeof o?`${o}px`:o,background:p.bg,border:`1px solid ${p.border}`,borderRadius:8,boxSizing:"border-box"},A={position:"relative",height:j,minHeight:"100%"};if(0===k.length)return(0,e.createElement)("div",{style:{...W,display:"flex",alignItems:"center",justifyContent:"center"}},(0,e.createElement)("span",{style:{color:p.textMuted,fontSize:13,fontFamily:"monospace"}},"No log entries."));const O=[];for(let n=T;n<=I;n++){const t=k[n];if(!t)continue;const r=$[n]??0,o=y.has(t.id);O.push((0,e.createElement)(N,{key:t.id,entry:t,showLevel:s,showTimestamp:a,showSource:l,searchQuery:d,monospace:u,isExpanded:o,onToggle:()=>L(t.id),onEntryClick:f,theme:p,style:{position:"absolute",top:r,left:0,right:0}})),o&&t.metadata&&Object.keys(t.metadata).length>0&&O.push((0,e.createElement)(F,{key:`${t.id}-meta`,metadata:t.metadata,theme:p,style:{position:"absolute",top:r+28,left:0,right:0,height:40}}))}return(0,e.createElement)("div",{ref:m,style:W,onScroll:C,role:"log","aria-live":"polite","aria-label":"Log viewer"},(0,e.createElement)("div",{style:A},...O))},exports.TkxLiveMetrics=function({metrics:t,columns:r=3,animate:o=!0,onMetricClick:i}){const s=n();return function(){if(b||"undefined"==typeof document)return;b=!0;const e=document.createElement("style");e.id="tkx-live-metrics-styles",e.textContent="\n@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}\n ".trim(),document.head.appendChild(e)}(),(0,e.createElement)("div",{style:{display:"grid",gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`,gap:16}},...t.map(t=>(0,e.createElement)(k,{key:t.id,metric:t,animate:o,onMetricClick:i,theme:s})))},exports.TkxRealTimeChart=function({data:t,maxPoints:r=60,height:i=200,width:s="100%",color:a,fill:l=!0,showGrid:c=!0,showLabels:d=!0,showTooltip:u=!0,label:f,unit:p,animate:m=!0,yMin:h,yMax:g}){const y=n(),b=a??y.primary,x=(0,e.useRef)(null),[w,v]=(0,e.useState)(600),[k,M]=(0,e.useState)(null),[z,N]=(0,e.useState)(0),F=(0,e.useRef)(t.length);(0,e.useEffect)(()=>{if(!x.current)return;const e=new ResizeObserver(e=>{const t=e[0];t&&v(t.contentRect.width)});return e.observe(x.current),v(x.current.offsetWidth),()=>e.disconnect()},[]);const j=(0,e.useMemo)(()=>t.slice(-r),[t,r]);(0,e.useEffect)(()=>{j.length>F.current&&N(e=>e+1),F.current=j.length},[j.length]);const C=d?48:12,L=f?28:12,T=Math.max(w-C-12,1),I=Math.max(i-L-28,1),W=j.length?Math.min(...j.map(e=>e.value)):0,A=j.length?Math.max(...j.map(e=>e.value)):1,O=A-W||1,E=void 0!==h?h:W-.1*O,D=(void 0!==g?g:A+.1*O)-E||1;function B(e){return j.length<2?T/2:e/(j.length-1)*T}function R(e){return I-(e-E)/D*I}const _=j.length>=2?j.map((e,t)=>`${0===t?"M":"L"}${B(t).toFixed(2)},${R(e.value).toFixed(2)}`).join(" "):"",H=_?`${_} L${B(j.length-1).toFixed(2)},${I} L${B(0).toFixed(2)},${I} Z`:"",P=[];for(let e=0;e<=4;e++)P.push(e);const q=P.map(e=>{const t=E+e/4*D;return{y:R(t),text:$(t)}}),U=Math.min(4,j.length),Z=U>0?Array.from({length:U},(e,t)=>Math.round(t/Math.max(U-1,1)*(j.length-1))):[],J=(0,e.useCallback)(e=>{if(!u||0===j.length)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left-C;let r=0,o=1/0;j.forEach((e,t)=>{const i=Math.abs(B(t)-n);i<o&&(o=i,r=t)});const i=j[r];i&&M({x:B(r)+C,y:R(i.value)+L,point:i})},[j,u,C,L]),Q=(0,e.useCallback)(()=>M(null),[]),K=w,V=i,Y=`tkx-chart-clip-${z}`;return(0,e.createElement)("div",{ref:x,style:{position:"relative",width:"number"==typeof s?`${s}px`:s,background:y.surface,border:`1px solid ${y.border}`,borderRadius:8,overflow:"hidden",boxSizing:"border-box"}},(0,e.createElement)("svg",{width:K,height:V,viewBox:`0 0 ${K} ${V}`,onMouseMove:J,onMouseLeave:Q,style:{display:"block",userSelect:"none"},"aria-label":f?o(f):"Real-time chart"},m&&j.length>=2&&(0,e.createElement)("defs",null,(0,e.createElement)("clipPath",{id:Y},(0,e.createElement)("rect",{x:0,y:0,width:T,height:V},(0,e.createElement)("animate",{attributeName:"width",from:Math.max(0,T-T/Math.max(j.length-1,1)),to:T,dur:"0.3s",fill:"freeze"})))),f&&(0,e.createElement)("text",{x:C,y:18,fill:y.textMuted,fontSize:12,fontWeight:500},o(f)),c&&P.map(t=>{const n=R(E+t/4*D)+L;return(0,e.createElement)("line",{key:`grid-${t}`,x1:C,y1:n,x2:C+T,y2:n,stroke:y.border,strokeWidth:1,strokeDasharray:"4 4"})}),d&&q.map((t,n)=>(0,e.createElement)("text",{key:`yl-${n}`,x:C-4,y:t.y+L+4,fill:y.textMuted,fontSize:10,textAnchor:"end"},t.text)),p&&(0,e.createElement)("text",{x:4,y:L+10,fill:y.textMuted,fontSize:9},o(p)),l&&H&&(0,e.createElement)("path",{d:H,fill:`${b}22`,clipPath:m?`url(#${Y})`:void 0,transform:`translate(${C}, ${L})`}),_&&(0,e.createElement)("path",{d:_,fill:"none",stroke:b,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",clipPath:m?`url(#${Y})`:void 0,transform:`translate(${C}, ${L})`}),Z.map(t=>{const n=j[t];return n?(0,e.createElement)("text",{key:`xl-${t}`,x:C+B(t),y:V-8,fill:y.textMuted,fontSize:9,textAnchor:"middle"},S(n.timestamp)):null}),k&&(0,e.createElement)("line",{x1:k.x,y1:L,x2:k.x,y2:L+I,stroke:b,strokeWidth:1,strokeDasharray:"3 3",opacity:.6}),k&&(0,e.createElement)("circle",{cx:k.x,cy:k.y,r:4,fill:b,stroke:y.surface,strokeWidth:2}),k&&(()=>{const t=Math.min(k.x+8,K-100),n=Math.max(k.y-36,4),r=`${$(k.point.value)}${p||""}`,o=S(k.point.timestamp);return(0,e.createElement)("g",null,(0,e.createElement)("rect",{x:t-4,y:n-2,width:90,height:34,rx:4,fill:y.surfaceAlt,stroke:y.border,strokeWidth:1}),(0,e.createElement)("text",{x:t,y:n+11,fill:y.text,fontSize:12,fontWeight:700},r),(0,e.createElement)("text",{x:t,y:n+26,fill:y.textMuted,fontSize:10},o))})()))};
|
package/dist/realtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e}from"./chunk-DdHSYetV.js";import{E as t}from"./chunk-DcVMayoM.js";import{createElement as n,useCallback as o,useEffect as i,useMemo as r,useRef as s,useState as a}from"react";var l=!1;function c({item:e,isNew:o,showTimestamps:i,onItemClick:r,renderItem:s,theme:a,style:l}){const c=function(e,t){switch(e){case"info":return t.info;case"success":return t.success;case"warning":return t.warning;case"error":return t.danger;default:return t.border}}(e.type,a);return s?n("div",{style:l,className:o?"tkx-feed-item-new":void 0},s(e)):n("div",{style:{...l,display:"flex",alignItems:"center",gap:10,padding:"0 12px",borderLeft:`3px solid ${c}`,cursor:r?"pointer":"default",boxSizing:"border-box",height:64,background:a.surface,transition:"background 0.15s"},className:o?"tkx-feed-item-new":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:r?t=>{"Enter"!==t.key&&" "!==t.key||r(e)}:void 0},n("div",{style:{width:36,height:36,borderRadius:"50%",background:c,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:a.bg,flexShrink:0,overflow:"hidden"}},e.avatar?n("img",{src:e.avatar,alt:e.author??"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(d=e.author)?d.split(" ").map(e=>e[0]??"").slice(0,2).join("").toUpperCase():"?"),n("div",{style:{flex:1,minWidth:0}},n("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2}},e.author&&n("span",{style:{fontWeight:600,fontSize:13,color:a.text}},t(e.author)),e.meta&&n("span",{style:{fontSize:11,color:a.textMuted,background:a.surfaceAlt,borderRadius:4,padding:"1px 5px"}},t(e.meta))),n("div",{style:{fontSize:13,color:a.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t(e.content))),i&&n("div",{style:{fontSize:11,color:a.textMuted,flexShrink:0}},function(e){const t=Date.now()-e;return t<1e4?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}(e.timestamp)));var d}function d({items:d,maxItems:u=100,height:f=400,autoScroll:h=!0,showTimestamps:m=!0,onItemClick:p,emptyMessage:g="No activity yet.",pauseOnHover:y=!0,renderItem:x}){const b=e();!function(){if(l||"undefined"==typeof document)return;l=!0;const e=document.createElement("style");e.id="tkx-live-feed-styles",e.textContent="\n@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}\n ".trim(),document.head.appendChild(e)}();const k=s(null),[v,w]=a(0),[S,$]=a(!1),[M,z]=a(/* @__PURE__ */new Set),N=s([]),W=r(()=>d.slice(-u),[d,u]),I="number"==typeof f?f:400,L=64*W.length;i(()=>{const e=new Set(N.current.map(e=>e.id)),t=W.filter(t=>!e.has(t.id)).map(e=>e.id);if(t.length>0){z(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n});const e=window.setTimeout(()=>{z(e=>{const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},400);return()=>clearTimeout(e)}},[W]),i(()=>{N.current=W},[W]);const C=h&&!(y&&S);i(()=>{if(!C||!k.current)return;const e=k.current;(e.scrollHeight-e.scrollTop-e.clientHeight<192||W.length<=5)&&(e.scrollTop=e.scrollHeight)},[W.length,C]);const T=o(()=>{k.current&&w(k.current.scrollTop)},[]),j=Math.max(0,Math.floor(v/64)-5),E=Math.min(W.length-1,Math.ceil((v+I)/64)+5),R={position:"relative",overflow:"auto",height:"number"==typeof f?`${f}px`:f,background:b.bg,border:`1px solid ${b.border}`,borderRadius:8,boxSizing:"border-box"},B={position:"relative",height:L,minHeight:"100%"};if(0===W.length)return n("div",{style:{...R,display:"flex",alignItems:"center",justifyContent:"center"}},n("span",{style:{color:b.textMuted,fontSize:14}},t(g)));const F=[];for(let e=j;e<=E;e++){const t=W[e];t&&F.push(n(c,{key:t.id,item:t,isNew:M.has(t.id),showTimestamps:m,onItemClick:p,renderItem:x,theme:b,style:{position:"absolute",top:64*e,left:0,right:0}}))}return n("div",{ref:k,style:R,onScroll:T,onMouseEnter:y?()=>$(!0):void 0,onMouseLeave:y?()=>$(!1):void 0,"aria-label":"Live feed",role:"feed"},n("div",{style:B},...F))}var u=!1;function f(e,t){if("string"==typeof e)return e;const n=e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Number.isInteger(e)?e:e.toFixed(2));return t?`${n}${t}`:n}function h({data:e,color:t}){if(e.length<2)return null;const o=Math.min(...e),i=Math.max(...e)-o||1,r=e.map((t,n)=>{const r=n/(e.length-1)*80,s=24-(t-o)/i*22-1;return`${r.toFixed(1)},${s.toFixed(1)}`});return n("svg",{width:80,height:24,viewBox:"0 0 80 24","aria-hidden":"true"},n("polyline",{points:r.join(" "),fill:"none",stroke:t,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}))}function m({trend:e,theme:t}){return"up"===e?n("span",{style:{color:t.success,fontSize:14,fontWeight:700}},"▲"):"down"===e?n("span",{style:{color:t.danger,fontSize:14,fontWeight:700}},"▼"):n("span",{style:{color:t.textMuted,fontSize:14}},"→")}function p({metric:e,animate:o,onMetricClick:r,theme:l}){const c=e.color??function(e,t){switch(e){case"warning":return t.warning;case"critical":return t.danger;default:return t.primary}}(e.status,l),d="number"==typeof e.value?e.value:NaN,u=function(e,t,n){const[o,r]=a(e),l=s(e),c=s(null),d=s(null),u=function(){const[e,t]=a(()=>"undefined"!=typeof window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return i(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=e=>t(e.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}();return i(()=>{if(!n||u)return r(e),void(l.current=e);const t=l.current;if(t===e)return;c.current=null;const o=n=>{null===c.current&&(c.current=n);const i=n-c.current,s=Math.min(i/600,1),a=1-Math.pow(1-s,3);r(t+(e-t)*a),s<1?d.current=requestAnimationFrame(o):l.current=e};return d.current=requestAnimationFrame(o),()=>{null!==d.current&&cancelAnimationFrame(d.current)}},[e,600,n,u]),o}(isNaN(d)?0:d,0,o&&!isNaN(d)),[p,g]=a(!1),y=s(e.value);i(()=>{if(y.current!==e.value){y.current=e.value,g(!0);const t=window.setTimeout(()=>g(!1),700);return()=>clearTimeout(t)}},[e.value]);const x=void 0!==e.previousValue&&e.previousValue!==d,b={background:l.surface,border:`1px solid ${l.border}`,borderLeft:`4px solid ${c}`,borderRadius:8,padding:"14px 16px",cursor:r?"pointer":"default",position:"relative",overflow:"hidden",boxSizing:"border-box"},k=p?{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${c}22 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"tkx-metric-shimmer 0.6s ease-in-out",pointerEvents:"none"}:{},v=isNaN(d)?t(String(e.value)):f(u,e.unit);return n("div",{style:b,className:p?"tkx-metric-shimmer":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0},p&&n("div",{style:k}),n("div",{style:{fontSize:12,color:l.textMuted,marginBottom:6,fontWeight:500,letterSpacing:"0.03em"}},t(e.label)),n("div",{style:{display:"flex",alignItems:"flex-end",gap:6,marginBottom:6}},n("span",{style:{fontSize:28,fontWeight:700,color:l.text,lineHeight:1}},v),e.unit&&isNaN(d)&&n("span",{style:{fontSize:14,color:l.textMuted,marginBottom:2}},t(e.unit))),(e.trend||e.trendValue)&&n("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:e.sparkline?8:0}},e.trend&&n(m,{trend:e.trend,theme:l}),e.trendValue&&n("span",{style:{fontSize:12,color:l.textMuted}},t(e.trendValue))),x&&n("div",{style:{fontSize:11,color:l.textMuted,marginTop:2}},`was ${f(e.previousValue)}`),e.sparkline&&e.sparkline.length>=2&&n("div",{style:{marginTop:8}},n(h,{data:e.sparkline,color:c})))}function g({metrics:t,columns:o=3,animate:i=!0,onMetricClick:r}){const s=e();return function(){if(u||"undefined"==typeof document)return;u=!0;const e=document.createElement("style");e.id="tkx-live-metrics-styles",e.textContent="\n@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}\n ".trim(),document.head.appendChild(e)}(),n("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o}, minmax(0, 1fr))`,gap:16}},...t.map(e=>n(p,{key:e.id,metric:e,animate:i,onMetricClick:r,theme:s})))}function y(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function x(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2)}function b({data:l,maxPoints:c=60,height:d=200,width:u="100%",color:f,fill:h=!0,showGrid:m=!0,showLabels:p=!0,showTooltip:g=!0,label:b,unit:k,animate:v=!0,yMin:w,yMax:S}){const $=e(),M=f??$.primary,z=s(null),[N,W]=a(600),[I,L]=a(null),[C,T]=a(0),j=s(l.length);i(()=>{if(!z.current)return;const e=new ResizeObserver(e=>{const t=e[0];t&&W(t.contentRect.width)});return e.observe(z.current),W(z.current.offsetWidth),()=>e.disconnect()},[]);const E=r(()=>l.slice(-c),[l,c]);i(()=>{E.length>j.current&&T(e=>e+1),j.current=E.length},[E.length]);const R=p?48:12,B=b?28:12,F=Math.max(N-R-12,1),O=Math.max(d-B-28,1),D=E.length?Math.min(...E.map(e=>e.value)):0,A=E.length?Math.max(...E.map(e=>e.value)):1,H=A-D||1,P=void 0!==w?w:D-.1*H,Q=(void 0!==S?S:A+.1*H)-P||1;function q(e){return E.length<2?F/2:e/(E.length-1)*F}function K(e){return O-(e-P)/Q*O}const Y=E.length>=2?E.map((e,t)=>`${0===t?"M":"L"}${q(t).toFixed(2)},${K(e.value).toFixed(2)}`).join(" "):"",G=Y?`${Y} L${q(E.length-1).toFixed(2)},${O} L${q(0).toFixed(2)},${O} Z`:"",J=[];for(let e=0;e<=4;e++)J.push(e);const Z=J.map(e=>{const t=P+e/4*Q;return{y:K(t),text:x(t)}}),U=Math.min(4,E.length),V=U>0?Array.from({length:U},(e,t)=>Math.round(t/Math.max(U-1,1)*(E.length-1))):[],X=o(e=>{if(!g||0===E.length)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left-R;let o=0,i=1/0;E.forEach((e,t)=>{const r=Math.abs(q(t)-n);r<i&&(i=r,o=t)});const r=E[o];r&&L({x:q(o)+R,y:K(r.value)+B,point:r})},[E,g,R,B]),_=o(()=>L(null),[]),ee=N,te=d,ne=`tkx-chart-clip-${C}`;return n("div",{ref:z,style:{position:"relative",width:"number"==typeof u?`${u}px`:u,background:$.surface,border:`1px solid ${$.border}`,borderRadius:8,overflow:"hidden",boxSizing:"border-box"}},n("svg",{width:ee,height:te,viewBox:`0 0 ${ee} ${te}`,onMouseMove:X,onMouseLeave:_,style:{display:"block",userSelect:"none"},"aria-label":b?t(b):"Real-time chart"},v&&E.length>=2&&n("defs",null,n("clipPath",{id:ne},n("rect",{x:0,y:0,width:F,height:te},n("animate",{attributeName:"width",from:Math.max(0,F-F/Math.max(E.length-1,1)),to:F,dur:"0.3s",fill:"freeze"})))),b&&n("text",{x:R,y:18,fill:$.textMuted,fontSize:12,fontWeight:500},t(b)),m&&J.map(e=>{const t=K(P+e/4*Q)+B;return n("line",{key:`grid-${e}`,x1:R,y1:t,x2:R+F,y2:t,stroke:$.border,strokeWidth:1,strokeDasharray:"4 4"})}),p&&Z.map((e,t)=>n("text",{key:`yl-${t}`,x:R-4,y:e.y+B+4,fill:$.textMuted,fontSize:10,textAnchor:"end"},e.text)),k&&n("text",{x:4,y:B+10,fill:$.textMuted,fontSize:9},t(k)),h&&G&&n("path",{d:G,fill:`${M}22`,clipPath:v?`url(#${ne})`:void 0,transform:`translate(${R}, ${B})`}),Y&&n("path",{d:Y,fill:"none",stroke:M,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",clipPath:v?`url(#${ne})`:void 0,transform:`translate(${R}, ${B})`}),V.map(e=>{const t=E[e];return t?n("text",{key:`xl-${e}`,x:R+q(e),y:te-8,fill:$.textMuted,fontSize:9,textAnchor:"middle"},y(t.timestamp)):null}),I&&n("line",{x1:I.x,y1:B,x2:I.x,y2:B+O,stroke:M,strokeWidth:1,strokeDasharray:"3 3",opacity:.6}),I&&n("circle",{cx:I.x,cy:I.y,r:4,fill:M,stroke:$.surface,strokeWidth:2}),I&&(()=>{const e=Math.min(I.x+8,ee-100),t=Math.max(I.y-36,4),o=`${x(I.point.value)}${k||""}`,i=y(I.point.timestamp);return n("g",null,n("rect",{x:e-4,y:t-2,width:90,height:34,rx:4,fill:$.surfaceAlt,stroke:$.border,strokeWidth:1}),n("text",{x:e,y:t+11,fill:$.text,fontSize:12,fontWeight:700},o),n("text",{x:e,y:t+26,fill:$.textMuted,fontSize:10},i))})()))}var k={debug:0,info:1,warn:2,error:3,fatal:4},v=!1;function w({entry:e,showLevel:o,showTimestamp:i,showSource:r,searchQuery:s,monospace:a,isExpanded:l,onToggle:c,onEntryClick:d,theme:u,style:f}){const h=function(e,t){switch(e){case"debug":default:return t.textMuted;case"info":return t.info;case"warn":return t.warning;case"error":case"fatal":return t.danger}}(e.level,u),m=function(e,t){return"fatal"===e?`${t.danger}22`:"transparent"}(e.level,u),p=e.metadata&&Object.keys(e.metadata).length>0,g={...f,display:"flex",alignItems:"center",gap:6,padding:"0 10px",fontSize:12,fontFamily:a?'"JetBrains Mono", "Fira Mono", Consolas, monospace':"inherit",cursor:p||d?"pointer":"default",background:m,boxSizing:"border-box",height:28,overflow:"hidden",whiteSpace:"nowrap",borderBottom:`1px solid ${u.border}22`};return n("div",{style:g,className:"tkx-log-row",onClick:()=>{p&&c(),d&&d(e)},role:p?"button":void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{"Enter"!==e.key&&" "!==e.key||c()}:void 0,"aria-expanded":p?l:void 0},i&&n("span",{style:{color:u.textMuted,flexShrink:0,minWidth:84}},function(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}(e.timestamp)),o&&n("span",{style:{color:h,flexShrink:0,fontWeight:"fatal"===e.level?700:500,minWidth:56}},`[${e.level.toUpperCase().padEnd(5)}]`),r&&e.source&&n("span",{style:{background:u.surfaceAlt,border:`1px solid ${u.border}`,borderRadius:10,padding:"0 5px",fontSize:10,color:u.textMuted,flexShrink:0,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"}},t(e.source)),n("span",{style:{flex:1,color:u.text,overflow:"hidden",textOverflow:"ellipsis"}},...function(e,o){if(!o)return[e];const i=t(e),r=t(o);if(!r)return[i];try{const e=new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return i.split(e).map((t,o)=>e.test(t)?n("mark",{key:o,className:"tkx-log-highlight"},t):t)}catch{return[i]}}(e.message,s)),p&&n("span",{style:{color:u.textMuted,fontSize:10,flexShrink:0}},l?"▲":"▼"))}function S({metadata:e,theme:o,style:i}){return n("div",{style:{...i,background:o.surfaceAlt,borderBottom:`1px solid ${o.border}`,padding:"6px 10px 6px 56px",display:"flex",flexWrap:"wrap",gap:6,boxSizing:"border-box"}},...Object.entries(e).map(([e,i])=>n("span",{key:e,style:{fontSize:11,fontFamily:"monospace",color:o.textMuted,background:o.surface,border:`1px solid ${o.border}`,borderRadius:4,padding:"1px 6px"}},n("span",{style:{color:o.info}},`${t(e)}: `),t(String(i)))))}function $({entries:t,maxEntries:l=500,height:c=400,autoScroll:d=!0,showLevel:u=!0,showTimestamp:f=!0,showSource:h=!0,filterLevel:m,searchQuery:p="",monospace:g=!0,onEntryClick:y}){const x=e();!function(){if(v||"undefined"==typeof document)return;v=!0;const e=document.createElement("style");e.id="tkx-live-log-styles",e.textContent="\n.tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }\n ".trim(),document.head.appendChild(e)}();const b=s(null),[$,M]=a(0),[z,N]=a(/* @__PURE__ */new Set),[W,I]=a(!1),L=s(t.length),C=r(()=>{let e=t.slice(-l);if(void 0!==m){const t=k[m];e=e.filter(e=>k[e.level]>=t)}if(p){const t=p.toLowerCase();e=e.filter(e=>e.message.toLowerCase().includes(t)||(e.source??"").toLowerCase().includes(t))}return e},[t,l,m,p]),T="number"==typeof c?c:400,j=r(()=>{const e=[];let t=0;for(const n of C)e.push(t),t+=28+(z.has(n.id)?40:0);return e.push(t),e},[C,z]),E=j[j.length-1]??0;i(()=>{d&&!W&&C.length!==L.current&&(L.current=C.length,b.current&&(b.current.scrollTop=b.current.scrollHeight))},[C.length,d,W]);const R=o(()=>{if(!b.current)return;const e=b.current;I(!(e.scrollHeight-e.scrollTop-e.clientHeight<56)),M(e.scrollTop)},[]),B=o(e=>{N(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),F=C.length>0?function(e){let t=0,n=C.length-1;for(;t<n;){const o=t+n>>1;(j[o+1]??0)<=e?t=o+1:n=o}return Math.max(0,t-8)}($):0,O=C.length>0?function(e){let t=0,n=C.length-1;for(;t<n;){const o=t+n+1>>1;(j[o]??0)>=e+T?n=o-1:t=o}return Math.min(C.length-1,t+8)}($):-1,D={position:"relative",overflow:"auto",height:"number"==typeof c?`${c}px`:c,background:x.bg,border:`1px solid ${x.border}`,borderRadius:8,boxSizing:"border-box"},A={position:"relative",height:E,minHeight:"100%"};if(0===C.length)return n("div",{style:{...D,display:"flex",alignItems:"center",justifyContent:"center"}},n("span",{style:{color:x.textMuted,fontSize:13,fontFamily:"monospace"}},"No log entries."));const H=[];for(let e=F;e<=O;e++){const t=C[e];if(!t)continue;const o=j[e]??0,i=z.has(t.id);H.push(n(w,{key:t.id,entry:t,showLevel:u,showTimestamp:f,showSource:h,searchQuery:p,monospace:g,isExpanded:i,onToggle:()=>B(t.id),onEntryClick:y,theme:x,style:{position:"absolute",top:o,left:0,right:0}})),i&&t.metadata&&Object.keys(t.metadata).length>0&&H.push(n(S,{key:`${t.id}-meta`,metadata:t.metadata,theme:x,style:{position:"absolute",top:o+28,left:0,right:0,height:40}}))}return n("div",{ref:b,style:D,onScroll:R,role:"log","aria-live":"polite","aria-label":"Log viewer"},n("div",{style:A},...H))}export{d as TkxLiveFeed,$ as TkxLiveLog,g as TkxLiveMetrics,b as TkxRealTimeChart};
|
|
1
|
+
import{createContext as e,createElement as t,useCallback as n,useContext as r,useEffect as o,useMemo as i,useRef as s,useState as a}from"react";var l=e({bg:"#0a0a0f",surface:"#12121a",surfaceAlt:"#1a1a2e",border:"#2a2a3e",text:"#e8e8f4",textMuted:"#8888aa",primary:"#00f5d4",secondary:"#7b2ff7",danger:"#f72585",warning:"#ffbe0b",success:"#06d6a0",info:"#3a86ff"});function c(){return r(l)}new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var d={"<":"<",">":">","&":"&","'":"'",'"':""","`":"`"};function u(e){if(null==e)return"";let t=String(e);return t=t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,""),t.replace(/[<>&'"`]/g,e=>d[e]??e)}function f(e){if("string"!=typeof e)return null;const t=e.trim();if(!t)return null;const n=t.replace(/[\u0000-\u001F\u007F]/g,"");return/^javascript:/i.test(n)||/^vbscript:/i.test(n)||/^data:/i.test(n)&&!/^data:image\//i.test(n)||/^file:/i.test(n)?null:n}var p=new Set(["a","abbr","b","blockquote","br","code","del","div","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","mark","ol","p","pre","q","s","samp","small","span","strong","sub","sup","table","tbody","td","tfoot","th","thead","tr","u","ul"]),m={a:new Set(["href","title","target","rel"]),img:new Set(["src","alt","title","width","height","loading","decoding"]),th:new Set(["scope","colspan","rowspan","align"]),td:new Set(["colspan","rowspan","align"]),"*":new Set(["id","class","lang","dir","title"])},h=new Set(["constructor","prototype","__proto__","submit","reset","action","method","enctype","target","elements","children","firstChild","nextSibling","parentNode","ownerDocument","cookie","domain","location","documentElement","body","head","title","contentWindow","contentDocument"]);function g(e){if("string"!=typeof e)return"";if("undefined"==typeof DOMParser)return u(e);const t=(new DOMParser).parseFromString(`<div>${e}</div>`,"text/html").body.firstElementChild;return t?(y(t),t.innerHTML):""}function y(e){const t=Array.from(e.children);for(const n of t){const e=n.tagName.toLowerCase();if(p.has(e)){for(const t of Array.from(n.attributes)){const r=t.name.toLowerCase();if(r.startsWith("on"))n.removeAttribute(t.name);else if(h.has(r))n.removeAttribute(t.name);else if("style"!==r)if((m[e]??/* @__PURE__ */new Set).has(r)||m["*"].has(r)){if(("href"===r||"src"===r)&&"string"==typeof t.value){const e=f(t.value);null===e?n.removeAttribute(t.name):n.setAttribute(t.name,e)}"name"!==r&&"id"!==r||!h.has(t.value.toLowerCase())||n.removeAttribute(t.name)}else n.removeAttribute(t.name);else n.setAttribute("style",b(t.value))}y(n)}else n.remove()}}function b(e){if("string"!=typeof e)return"";let t=e;return t=t.replace(/expression\s*\([^)]*\)/gi,""),t=t.replace(/url\s*\(\s*['"]?\s*(javascript|vbscript|data)\s*:[^)]*\)/gi,"url(#)"),t=t.replace(/@import[^;]*;?/gi,""),t=t.replace(/behavior\s*:[^;]*;?/gi,""),t=t.replace(/-moz-binding[^;]*;?/gi,""),t=t.replace(/[<>]/g,""),t=t.replace(/[\u0000-\u001F\u007F]/g,""),t.trim()}var x=new Set(["__proto__","constructor","prototype"]);function w(e){if(Array.isArray(e))return e.map(w);if(e&&"object"==typeof e){const t={};for(const[n,r]of Object.entries(e))x.has(n)||(t[n]=w(r));return t}return e}function v(){if("undefined"==typeof window)return!1;try{return window.top!==window.self}catch{return!0}}var k=[{name:"ssn",re:/\b\d{3}-\d{2}-\d{4}\b/g,repl:"[redacted-ssn]"},{name:"credit",re:/\b(?:\d[ -]?){13,19}\b/g,repl:e=>{const t=e.replace(/[ -]/g,"");return t.length<13||t.length>19?e:function(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let o=e.charCodeAt(r)-48;if(o<0||o>9)return!1;n&&(o*=2,o>9&&(o-=9)),t+=o,n=!n}return t>0&&t%10==0}(t)?"[redacted-card]":e}},{name:"email",re:/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,repl:"[redacted-email]"},{name:"phone",re:/\b(\+?\d{1,3}[ -])?\(?\d{3}\)?[ -]?\d{3}[ -]?\d{4}\b/g,repl:"[redacted-phone]"},{name:"apikey",re:/\b(sk|pk|rk)-[A-Za-z0-9]{20,}\b/g,repl:"[redacted-key]"}];Object.freeze({sanitizeString:u,sanitizeHref:f,sanitizeHTML:g,sanitizeCSS:b,sanitizeJSON:function(e){try{return w(JSON.parse(e,(e,t)=>{if(!x.has(e))return t}))}catch{return null}},sanitizeUnicode:function(e){return"string"!=typeof e?"":e.replace(/[\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFEFF\u00AD]/g,"")},isSafeAttrName:function(e){return!("string"!=typeof e||!e||/[\u0000-\u001F\u007F<>"]/.test(e)||h.has(e.toLowerCase()))},buildTkxCSP:function(e={}){const{allowInlineStyles:t=!0,imgHosts:n=[],connectHosts:r=[],fontHosts:o=[],scriptNonce:i,reportUri:s}=e,a=["default-src 'self'","script-src "+(i?`'self' 'nonce-${i}'`:"'self'"),"style-src "+(t?"'self' 'unsafe-inline'":"'self'"),`img-src ${["'self'","data:","https:",...n].join(" ")}`,`font-src ${["'self'","https:","data:",...o].join(" ")}`,`connect-src ${["'self'",...r].join(" ")}`,"frame-ancestors 'none'","form-action 'self'","base-uri 'self'","object-src 'none'","upgrade-insecure-requests"];return s&&a.push(`report-uri ${s}`),a.join("; ")},installTrustedTypes:function(){if("undefined"==typeof window)return;const e=window.trustedTypes;if(e)try{e.createPolicy("tkx",{createHTML:g,createScriptURL:e=>f(e)??"",createScript:()=>{throw new Error("TekiVex: inline script creation forbidden")}})}catch{}},isFramed:v,installFrameBuster:function(e){if("undefined"!=typeof window&&v())if(e)e();else try{window.top.location.href=window.self.location.href}catch{}},createRateLimiter:function(e,t){let n=e,r=Date.now();return{check(){const o=Date.now(),i=o-r,s=Math.floor(i/t);return s>0&&(n=Math.min(e,n+s),r=o),!(n<=0||(n-=1,0))},reset(){n=e,r=Date.now()}}},sniffMimeType:async function(e){const t=new Uint8Array(await e.slice(0,12).arrayBuffer()),n=(...e)=>e.every((e,n)=>t[n]===e);return n(137,80,78,71)?"image/png":n(255,216,255)?"image/jpeg":n(71,73,70,56)?"image/gif":n(66,77)?"image/bmp":n(82,73,70,70)&&87===t[8]&&69===t[9]&&66===t[10]&&80===t[11]?"image/webp":n(37,80,68,70)?"application/pdf":n(80,75,3,4)?"application/zip":123===t[0]||91===t[0]?"application/json":[...t].includes(0)?null:"text/plain"},scrubPII:function(e){if("string"!=typeof e)return"";let t=e;for(const{re:n,repl:r}of k)t=t.replace(n,r);return t},deepFreeze:function e(t){if(t&&"object"==typeof t&&!Object.isFrozen(t)){for(const n of Object.keys(t))e(t[n]);Object.freeze(t)}return t},__brand:"TekiVex SecurityCore v2.6.0 © 007krcs"});var S=!1;function $({item:e,isNew:n,showTimestamps:r,onItemClick:o,renderItem:i,theme:s,style:a}){const l=function(e,t){switch(e){case"info":return t.info;case"success":return t.success;case"warning":return t.warning;case"error":return t.danger;default:return t.border}}(e.type,s);return i?t("div",{style:a,className:n?"tkx-feed-item-new":void 0},i(e)):t("div",{style:{...a,display:"flex",alignItems:"center",gap:10,padding:"0 12px",borderLeft:`3px solid ${l}`,cursor:o?"pointer":"default",boxSizing:"border-box",height:64,background:s.surface,transition:"background 0.15s"},className:n?"tkx-feed-item-new":void 0,onClick:o?()=>o(e):void 0,role:o?"button":void 0,tabIndex:o?0:void 0,onKeyDown:o?t=>{"Enter"!==t.key&&" "!==t.key||o(e)}:void 0},t("div",{style:{width:36,height:36,borderRadius:"50%",background:l,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:s.bg,flexShrink:0,overflow:"hidden"}},e.avatar?t("img",{src:e.avatar,alt:e.author??"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(c=e.author)?c.split(" ").map(e=>e[0]??"").slice(0,2).join("").toUpperCase():"?"),t("div",{style:{flex:1,minWidth:0}},t("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2}},e.author&&t("span",{style:{fontWeight:600,fontSize:13,color:s.text}},u(e.author)),e.meta&&t("span",{style:{fontSize:11,color:s.textMuted,background:s.surfaceAlt,borderRadius:4,padding:"1px 5px"}},u(e.meta))),t("div",{style:{fontSize:13,color:s.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},u(e.content))),r&&t("div",{style:{fontSize:11,color:s.textMuted,flexShrink:0}},function(e){const t=Date.now()-e;return t<1e4?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}(e.timestamp)));var c}function M({items:e,maxItems:r=100,height:l=400,autoScroll:d=!0,showTimestamps:f=!0,onItemClick:p,emptyMessage:m="No activity yet.",pauseOnHover:h=!0,renderItem:g}){const y=c();!function(){if(S||"undefined"==typeof document)return;S=!0;const e=document.createElement("style");e.id="tkx-live-feed-styles",e.textContent="\n@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}\n ".trim(),document.head.appendChild(e)}();const b=s(null),[x,w]=a(0),[v,k]=a(!1),[M,z]=a(/* @__PURE__ */new Set),N=s([]),F=i(()=>e.slice(-r),[e,r]),j="number"==typeof l?l:400,C=64*F.length;o(()=>{const e=new Set(N.current.map(e=>e.id)),t=F.filter(t=>!e.has(t.id)).map(e=>e.id);if(t.length>0){z(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n});const e=window.setTimeout(()=>{z(e=>{const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},400);return()=>clearTimeout(e)}},[F]),o(()=>{N.current=F},[F]);const L=d&&!(h&&v);o(()=>{if(!L||!b.current)return;const e=b.current;(e.scrollHeight-e.scrollTop-e.clientHeight<192||F.length<=5)&&(e.scrollTop=e.scrollHeight)},[F.length,L]);const T=n(()=>{b.current&&w(b.current.scrollTop)},[]),I=Math.max(0,Math.floor(x/64)-5),W=Math.min(F.length-1,Math.ceil((x+j)/64)+5),A={position:"relative",overflow:"auto",height:"number"==typeof l?`${l}px`:l,background:y.bg,border:`1px solid ${y.border}`,borderRadius:8,boxSizing:"border-box"},O={position:"relative",height:C,minHeight:"100%"};if(0===F.length)return t("div",{style:{...A,display:"flex",alignItems:"center",justifyContent:"center"}},t("span",{style:{color:y.textMuted,fontSize:14}},u(m)));const E=[];for(let n=I;n<=W;n++){const e=F[n];e&&E.push(t($,{key:e.id,item:e,isNew:M.has(e.id),showTimestamps:f,onItemClick:p,renderItem:g,theme:y,style:{position:"absolute",top:64*n,left:0,right:0}}))}return t("div",{ref:b,style:A,onScroll:T,onMouseEnter:h?()=>k(!0):void 0,onMouseLeave:h?()=>k(!1):void 0,"aria-label":"Live feed",role:"feed"},t("div",{style:O},...E))}var z=!1;function N(e,t){if("string"==typeof e)return e;const n=e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Number.isInteger(e)?e:e.toFixed(2));return t?`${n}${t}`:n}function F({data:e,color:n}){if(e.length<2)return null;const r=Math.min(...e),o=Math.max(...e)-r||1,i=e.map((t,n)=>{const i=n/(e.length-1)*80,s=24-(t-r)/o*22-1;return`${i.toFixed(1)},${s.toFixed(1)}`});return t("svg",{width:80,height:24,viewBox:"0 0 80 24","aria-hidden":"true"},t("polyline",{points:i.join(" "),fill:"none",stroke:n,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}))}function j({trend:e,theme:n}){return"up"===e?t("span",{style:{color:n.success,fontSize:14,fontWeight:700}},"▲"):"down"===e?t("span",{style:{color:n.danger,fontSize:14,fontWeight:700}},"▼"):t("span",{style:{color:n.textMuted,fontSize:14}},"→")}function C({metric:e,animate:n,onMetricClick:r,theme:i}){const l=e.color??function(e,t){switch(e){case"warning":return t.warning;case"critical":return t.danger;default:return t.primary}}(e.status,i),c="number"==typeof e.value?e.value:NaN,d=function(e,t,n){const[r,i]=a(e),l=s(e),c=s(null),d=s(null),u=function(){const[e,t]=a(()=>"undefined"!=typeof window&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return o(()=>{if("undefined"==typeof window)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=e=>t(e.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}();return o(()=>{if(!n||u)return i(e),void(l.current=e);const t=l.current;if(t===e)return;c.current=null;const r=n=>{null===c.current&&(c.current=n);const o=n-c.current,s=Math.min(o/600,1),a=1-Math.pow(1-s,3);i(t+(e-t)*a),s<1?d.current=requestAnimationFrame(r):l.current=e};return d.current=requestAnimationFrame(r),()=>{null!==d.current&&cancelAnimationFrame(d.current)}},[e,600,n,u]),r}(isNaN(c)?0:c,0,n&&!isNaN(c)),[f,p]=a(!1),m=s(e.value);o(()=>{if(m.current!==e.value){m.current=e.value,p(!0);const t=window.setTimeout(()=>p(!1),700);return()=>clearTimeout(t)}},[e.value]);const h=void 0!==e.previousValue&&e.previousValue!==c,g={background:i.surface,border:`1px solid ${i.border}`,borderLeft:`4px solid ${l}`,borderRadius:8,padding:"14px 16px",cursor:r?"pointer":"default",position:"relative",overflow:"hidden",boxSizing:"border-box"},y=f?{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${l}22 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"tkx-metric-shimmer 0.6s ease-in-out",pointerEvents:"none"}:{},b=isNaN(c)?u(String(e.value)):N(d,e.unit);return t("div",{style:g,className:f?"tkx-metric-shimmer":void 0,onClick:r?()=>r(e):void 0,role:r?"button":void 0,tabIndex:r?0:void 0},f&&t("div",{style:y}),t("div",{style:{fontSize:12,color:i.textMuted,marginBottom:6,fontWeight:500,letterSpacing:"0.03em"}},u(e.label)),t("div",{style:{display:"flex",alignItems:"flex-end",gap:6,marginBottom:6}},t("span",{style:{fontSize:28,fontWeight:700,color:i.text,lineHeight:1}},b),e.unit&&isNaN(c)&&t("span",{style:{fontSize:14,color:i.textMuted,marginBottom:2}},u(e.unit))),(e.trend||e.trendValue)&&t("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:e.sparkline?8:0}},e.trend&&t(j,{trend:e.trend,theme:i}),e.trendValue&&t("span",{style:{fontSize:12,color:i.textMuted}},u(e.trendValue))),h&&t("div",{style:{fontSize:11,color:i.textMuted,marginTop:2}},`was ${N(e.previousValue)}`),e.sparkline&&e.sparkline.length>=2&&t("div",{style:{marginTop:8}},t(F,{data:e.sparkline,color:l})))}function L({metrics:e,columns:n=3,animate:r=!0,onMetricClick:o}){const i=c();return function(){if(z||"undefined"==typeof document)return;z=!0;const e=document.createElement("style");e.id="tkx-live-metrics-styles",e.textContent="\n@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}\n ".trim(),document.head.appendChild(e)}(),t("div",{style:{display:"grid",gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`,gap:16}},...e.map(e=>t(C,{key:e.id,metric:e,animate:r,onMetricClick:o,theme:i})))}function T(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function I(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(2)}function W({data:e,maxPoints:r=60,height:l=200,width:d="100%",color:f,fill:p=!0,showGrid:m=!0,showLabels:h=!0,showTooltip:g=!0,label:y,unit:b,animate:x=!0,yMin:w,yMax:v}){const k=c(),S=f??k.primary,$=s(null),[M,z]=a(600),[N,F]=a(null),[j,C]=a(0),L=s(e.length);o(()=>{if(!$.current)return;const e=new ResizeObserver(e=>{const t=e[0];t&&z(t.contentRect.width)});return e.observe($.current),z($.current.offsetWidth),()=>e.disconnect()},[]);const W=i(()=>e.slice(-r),[e,r]);o(()=>{W.length>L.current&&C(e=>e+1),L.current=W.length},[W.length]);const A=h?48:12,O=y?28:12,E=Math.max(M-A-12,1),D=Math.max(l-O-28,1),B=W.length?Math.min(...W.map(e=>e.value)):0,R=W.length?Math.max(...W.map(e=>e.value)):1,_=R-B||1,H=void 0!==w?w:B-.1*_,P=(void 0!==v?v:R+.1*_)-H||1;function q(e){return W.length<2?E/2:e/(W.length-1)*E}function U(e){return D-(e-H)/P*D}const Z=W.length>=2?W.map((e,t)=>`${0===t?"M":"L"}${q(t).toFixed(2)},${U(e.value).toFixed(2)}`).join(" "):"",J=Z?`${Z} L${q(W.length-1).toFixed(2)},${D} L${q(0).toFixed(2)},${D} Z`:"",Q=[];for(let t=0;t<=4;t++)Q.push(t);const K=Q.map(e=>{const t=H+e/4*P;return{y:U(t),text:I(t)}}),V=Math.min(4,W.length),Y=V>0?Array.from({length:V},(e,t)=>Math.round(t/Math.max(V-1,1)*(W.length-1))):[],G=n(e=>{if(!g||0===W.length)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left-A;let r=0,o=1/0;W.forEach((e,t)=>{const i=Math.abs(q(t)-n);i<o&&(o=i,r=t)});const i=W[r];i&&F({x:q(r)+A,y:U(i.value)+O,point:i})},[W,g,A,O]),X=n(()=>F(null),[]),ee=M,te=l,ne=`tkx-chart-clip-${j}`;return t("div",{ref:$,style:{position:"relative",width:"number"==typeof d?`${d}px`:d,background:k.surface,border:`1px solid ${k.border}`,borderRadius:8,overflow:"hidden",boxSizing:"border-box"}},t("svg",{width:ee,height:te,viewBox:`0 0 ${ee} ${te}`,onMouseMove:G,onMouseLeave:X,style:{display:"block",userSelect:"none"},"aria-label":y?u(y):"Real-time chart"},x&&W.length>=2&&t("defs",null,t("clipPath",{id:ne},t("rect",{x:0,y:0,width:E,height:te},t("animate",{attributeName:"width",from:Math.max(0,E-E/Math.max(W.length-1,1)),to:E,dur:"0.3s",fill:"freeze"})))),y&&t("text",{x:A,y:18,fill:k.textMuted,fontSize:12,fontWeight:500},u(y)),m&&Q.map(e=>{const n=U(H+e/4*P)+O;return t("line",{key:`grid-${e}`,x1:A,y1:n,x2:A+E,y2:n,stroke:k.border,strokeWidth:1,strokeDasharray:"4 4"})}),h&&K.map((e,n)=>t("text",{key:`yl-${n}`,x:A-4,y:e.y+O+4,fill:k.textMuted,fontSize:10,textAnchor:"end"},e.text)),b&&t("text",{x:4,y:O+10,fill:k.textMuted,fontSize:9},u(b)),p&&J&&t("path",{d:J,fill:`${S}22`,clipPath:x?`url(#${ne})`:void 0,transform:`translate(${A}, ${O})`}),Z&&t("path",{d:Z,fill:"none",stroke:S,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",clipPath:x?`url(#${ne})`:void 0,transform:`translate(${A}, ${O})`}),Y.map(e=>{const n=W[e];return n?t("text",{key:`xl-${e}`,x:A+q(e),y:te-8,fill:k.textMuted,fontSize:9,textAnchor:"middle"},T(n.timestamp)):null}),N&&t("line",{x1:N.x,y1:O,x2:N.x,y2:O+D,stroke:S,strokeWidth:1,strokeDasharray:"3 3",opacity:.6}),N&&t("circle",{cx:N.x,cy:N.y,r:4,fill:S,stroke:k.surface,strokeWidth:2}),N&&(()=>{const e=Math.min(N.x+8,ee-100),n=Math.max(N.y-36,4),r=`${I(N.point.value)}${b||""}`,o=T(N.point.timestamp);return t("g",null,t("rect",{x:e-4,y:n-2,width:90,height:34,rx:4,fill:k.surfaceAlt,stroke:k.border,strokeWidth:1}),t("text",{x:e,y:n+11,fill:k.text,fontSize:12,fontWeight:700},r),t("text",{x:e,y:n+26,fill:k.textMuted,fontSize:10},o))})()))}var A={debug:0,info:1,warn:2,error:3,fatal:4},O=!1;function E({entry:e,showLevel:n,showTimestamp:r,showSource:o,searchQuery:i,monospace:s,isExpanded:a,onToggle:l,onEntryClick:c,theme:d,style:f}){const p=function(e,t){switch(e){case"debug":default:return t.textMuted;case"info":return t.info;case"warn":return t.warning;case"error":case"fatal":return t.danger}}(e.level,d),m=function(e,t){return"fatal"===e?`${t.danger}22`:"transparent"}(e.level,d),h=e.metadata&&Object.keys(e.metadata).length>0,g={...f,display:"flex",alignItems:"center",gap:6,padding:"0 10px",fontSize:12,fontFamily:s?'"JetBrains Mono", "Fira Mono", Consolas, monospace':"inherit",cursor:h||c?"pointer":"default",background:m,boxSizing:"border-box",height:28,overflow:"hidden",whiteSpace:"nowrap",borderBottom:`1px solid ${d.border}22`};return t("div",{style:g,className:"tkx-log-row",onClick:()=>{h&&l(),c&&c(e)},role:h?"button":void 0,tabIndex:h?0:void 0,onKeyDown:h?e=>{"Enter"!==e.key&&" "!==e.key||l()}:void 0,"aria-expanded":h?a:void 0},r&&t("span",{style:{color:d.textMuted,flexShrink:0,minWidth:84}},function(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`}(e.timestamp)),n&&t("span",{style:{color:p,flexShrink:0,fontWeight:"fatal"===e.level?700:500,minWidth:56}},`[${e.level.toUpperCase().padEnd(5)}]`),o&&e.source&&t("span",{style:{background:d.surfaceAlt,border:`1px solid ${d.border}`,borderRadius:10,padding:"0 5px",fontSize:10,color:d.textMuted,flexShrink:0,maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"}},u(e.source)),t("span",{style:{flex:1,color:d.text,overflow:"hidden",textOverflow:"ellipsis"}},...function(e,n){if(!n)return[e];const r=u(e),o=u(n);if(!o)return[r];try{const e=new RegExp(`(${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return r.split(e).map((n,r)=>e.test(n)?t("mark",{key:r,className:"tkx-log-highlight"},n):n)}catch{return[r]}}(e.message,i)),h&&t("span",{style:{color:d.textMuted,fontSize:10,flexShrink:0}},a?"▲":"▼"))}function D({metadata:e,theme:n,style:r}){return t("div",{style:{...r,background:n.surfaceAlt,borderBottom:`1px solid ${n.border}`,padding:"6px 10px 6px 56px",display:"flex",flexWrap:"wrap",gap:6,boxSizing:"border-box"}},...Object.entries(e).map(([e,r])=>t("span",{key:e,style:{fontSize:11,fontFamily:"monospace",color:n.textMuted,background:n.surface,border:`1px solid ${n.border}`,borderRadius:4,padding:"1px 6px"}},t("span",{style:{color:n.info}},`${u(e)}: `),u(String(r)))))}function B({entries:e,maxEntries:r=500,height:l=400,autoScroll:d=!0,showLevel:u=!0,showTimestamp:f=!0,showSource:p=!0,filterLevel:m,searchQuery:h="",monospace:g=!0,onEntryClick:y}){const b=c();!function(){if(O||"undefined"==typeof document)return;O=!0;const e=document.createElement("style");e.id="tkx-live-log-styles",e.textContent="\n.tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }\n ".trim(),document.head.appendChild(e)}();const x=s(null),[w,v]=a(0),[k,S]=a(/* @__PURE__ */new Set),[$,M]=a(!1),z=s(e.length),N=i(()=>{let t=e.slice(-r);if(void 0!==m){const e=A[m];t=t.filter(t=>A[t.level]>=e)}if(h){const e=h.toLowerCase();t=t.filter(t=>t.message.toLowerCase().includes(e)||(t.source??"").toLowerCase().includes(e))}return t},[e,r,m,h]),F="number"==typeof l?l:400,j=i(()=>{const e=[];let t=0;for(const n of N)e.push(t),t+=28+(k.has(n.id)?40:0);return e.push(t),e},[N,k]),C=j[j.length-1]??0;o(()=>{d&&!$&&N.length!==z.current&&(z.current=N.length,x.current&&(x.current.scrollTop=x.current.scrollHeight))},[N.length,d,$]);const L=n(()=>{if(!x.current)return;const e=x.current;M(!(e.scrollHeight-e.scrollTop-e.clientHeight<56)),v(e.scrollTop)},[]),T=n(e=>{S(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),I=N.length>0?function(e){let t=0,n=N.length-1;for(;t<n;){const r=t+n>>1;(j[r+1]??0)<=e?t=r+1:n=r}return Math.max(0,t-8)}(w):0,W=N.length>0?function(e){let t=0,n=N.length-1;for(;t<n;){const r=t+n+1>>1;(j[r]??0)>=e+F?n=r-1:t=r}return Math.min(N.length-1,t+8)}(w):-1,B={position:"relative",overflow:"auto",height:"number"==typeof l?`${l}px`:l,background:b.bg,border:`1px solid ${b.border}`,borderRadius:8,boxSizing:"border-box"},R={position:"relative",height:C,minHeight:"100%"};if(0===N.length)return t("div",{style:{...B,display:"flex",alignItems:"center",justifyContent:"center"}},t("span",{style:{color:b.textMuted,fontSize:13,fontFamily:"monospace"}},"No log entries."));const _=[];for(let n=I;n<=W;n++){const e=N[n];if(!e)continue;const r=j[n]??0,o=k.has(e.id);_.push(t(E,{key:e.id,entry:e,showLevel:u,showTimestamp:f,showSource:p,searchQuery:h,monospace:g,isExpanded:o,onToggle:()=>T(e.id),onEntryClick:y,theme:b,style:{position:"absolute",top:r,left:0,right:0}})),o&&e.metadata&&Object.keys(e.metadata).length>0&&_.push(t(D,{key:`${e.id}-meta`,metadata:e.metadata,theme:b,style:{position:"absolute",top:r+28,left:0,right:0,height:40}}))}return t("div",{ref:x,style:B,onScroll:L,role:"log","aria-live":"polite","aria-label":"Log viewer"},t("div",{style:R},..._))}export{M as TkxLiveFeed,B as TkxLiveLog,L as TkxLiveMetrics,W as TkxRealTimeChart};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Transport } from '../core/Transport';
|
|
2
|
+
export interface A2AClientOptions {
|
|
3
|
+
endpoint: string;
|
|
4
|
+
transport?: Transport;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export interface A2APart {
|
|
8
|
+
type: 'text';
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
export interface A2AMessage {
|
|
12
|
+
role: 'user' | 'agent';
|
|
13
|
+
parts: A2APart[];
|
|
14
|
+
}
|
|
15
|
+
export interface A2ATaskRequest {
|
|
16
|
+
id: string;
|
|
17
|
+
message: A2AMessage;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface A2ATaskResponse {
|
|
21
|
+
id: string;
|
|
22
|
+
status: 'completed' | 'failed' | 'in_progress';
|
|
23
|
+
messages: A2AMessage[];
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export declare class A2AClient {
|
|
27
|
+
private readonly opts;
|
|
28
|
+
private readonly transport;
|
|
29
|
+
constructor(opts: A2AClientOptions);
|
|
30
|
+
sendTask(req: A2ATaskRequest, signal?: AbortSignal): Promise<A2ATaskResponse>;
|
|
31
|
+
static newTaskId(): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Tool } from '../core/Tool';
|
|
2
|
+
import { A2AClient } from './A2AClient';
|
|
3
|
+
export interface A2AToolOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
client: A2AClient;
|
|
7
|
+
inputDescription?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function a2aTool(opts: A2AToolOptions): Tool<{
|
|
10
|
+
input: string;
|
|
11
|
+
}, string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentOptions } from '../core/Agent';
|
|
2
|
+
import { type AgentControllerState } from './vanilla';
|
|
3
|
+
export interface SolidAdapter {
|
|
4
|
+
createSignal<T>(initial: T): [() => T, (v: T) => void];
|
|
5
|
+
onCleanup(fn: () => void): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function createUseAgentSolid(adapter: SolidAdapter): (opts: AgentOptions) => {
|
|
8
|
+
state: () => AgentControllerState;
|
|
9
|
+
send: (text: string) => Promise<void>;
|
|
10
|
+
stop: () => void;
|
|
11
|
+
reset: () => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AgentOptions } from '../core/Agent';
|
|
2
|
+
import { type AgentControllerState } from './vanilla';
|
|
3
|
+
export interface SvelteAgentStore {
|
|
4
|
+
subscribe(run: (state: AgentControllerState) => void): () => void;
|
|
5
|
+
send(text: string): Promise<void>;
|
|
6
|
+
stop(): void;
|
|
7
|
+
reset(): void;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createAgentStore(opts: AgentOptions): SvelteAgentStore;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type AgentOptions } from '../core/Agent';
|
|
2
|
+
import type { Message } from '../core/types';
|
|
3
|
+
export interface AgentControllerState {
|
|
4
|
+
messages: Message[];
|
|
5
|
+
streamingText: string;
|
|
6
|
+
isStreaming: boolean;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
}
|
|
9
|
+
export interface AgentController {
|
|
10
|
+
getState(): AgentControllerState;
|
|
11
|
+
subscribe(listener: (state: AgentControllerState) => void): () => void;
|
|
12
|
+
send(text: string): Promise<void>;
|
|
13
|
+
stop(): void;
|
|
14
|
+
reset(): void;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare function createAgentController(opts: AgentOptions): AgentController;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AgentOptions } from '../core/Agent';
|
|
2
|
+
import { type AgentControllerState } from './vanilla';
|
|
3
|
+
export interface VueRef<T> {
|
|
4
|
+
value: T;
|
|
5
|
+
}
|
|
6
|
+
export interface VueAdapter {
|
|
7
|
+
shallowRef<T>(value: T): VueRef<T>;
|
|
8
|
+
onScopeDispose(fn: () => void): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createUseAgentVue(adapter: VueAdapter): (opts: AgentOptions) => {
|
|
11
|
+
state: VueRef<AgentControllerState>;
|
|
12
|
+
send: (text: string) => Promise<void>;
|
|
13
|
+
stop: () => void;
|
|
14
|
+
reset: () => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import type { ContentBlock, Message } from '../core/types';
|
|
3
|
+
export interface TkxAgentMessageProps {
|
|
4
|
+
message: Message;
|
|
5
|
+
streamingText?: string;
|
|
6
|
+
renderToolCall?(block: Extract<ContentBlock, {
|
|
7
|
+
type: 'tool_use';
|
|
8
|
+
}>): ReactNode;
|
|
9
|
+
renderToolResult?(block: Extract<ContentBlock, {
|
|
10
|
+
type: 'tool_result';
|
|
11
|
+
}>): ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
}
|
|
15
|
+
export declare function TkxAgentMessage({ message, streamingText, renderToolCall, renderToolResult, className, style, }: TkxAgentMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { AgentEvent } from '../core/events';
|
|
3
|
+
export interface TkxReasoningTraceProps {
|
|
4
|
+
events: AgentEvent[];
|
|
5
|
+
hideTextDeltas?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export declare function TkxReasoningTrace({ events, hideTextDeltas, className, style, }: TkxReasoningTraceProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
export type ToolCallStatus = 'pending' | 'running' | 'success' | 'error';
|
|
3
|
+
export interface TkxToolCallCardProps {
|
|
4
|
+
name: string;
|
|
5
|
+
input: unknown;
|
|
6
|
+
output?: unknown;
|
|
7
|
+
error?: Error;
|
|
8
|
+
status: ToolCallStatus;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
export declare function TkxToolCallCard({ name, input, output, error, status, className, style, }: TkxToolCallCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CacheControl, ContentBlock } from '../core/types';
|
|
2
|
+
export declare function textBlock(text: string, opts?: {
|
|
3
|
+
cacheControl?: CacheControl;
|
|
4
|
+
}): ContentBlock;
|
|
5
|
+
export declare function cacheable(text: string): ContentBlock;
|
|
6
|
+
export declare function imageBlock(input: {
|
|
7
|
+
url: string;
|
|
8
|
+
mediaType?: string;
|
|
9
|
+
} | {
|
|
10
|
+
base64: string;
|
|
11
|
+
mediaType?: string;
|
|
12
|
+
}): ContentBlock;
|
|
13
|
+
export declare function toolUseBlock(id: string, name: string, input: unknown): ContentBlock;
|
|
14
|
+
export declare function toolResultBlock(toolUseId: string, output: unknown, opts?: {
|
|
15
|
+
name?: string;
|
|
16
|
+
isError?: boolean;
|
|
17
|
+
}): ContentBlock;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AgentEvent } from './events';
|
|
2
|
+
import { type Memory } from './Memory';
|
|
3
|
+
import type { Middleware } from './Middleware';
|
|
4
|
+
import type { Provider } from './Provider';
|
|
5
|
+
import type { Tool } from './Tool';
|
|
6
|
+
export interface AgentOptions {
|
|
7
|
+
provider: Provider;
|
|
8
|
+
model: string;
|
|
9
|
+
system?: string;
|
|
10
|
+
tools?: Tool[];
|
|
11
|
+
memory?: Memory;
|
|
12
|
+
middleware?: Middleware[];
|
|
13
|
+
maxSteps?: number;
|
|
14
|
+
maxTokens?: number;
|
|
15
|
+
temperature?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface AgentRunInput {
|
|
18
|
+
message: string;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
export declare class Agent {
|
|
22
|
+
private readonly opts;
|
|
23
|
+
private readonly memory;
|
|
24
|
+
private readonly toolByName;
|
|
25
|
+
private readonly toolDefs;
|
|
26
|
+
constructor(opts: AgentOptions);
|
|
27
|
+
run(runInput: AgentRunInput): AsyncGenerator<AgentEvent>;
|
|
28
|
+
}
|
|
29
|
+
export declare function createAgent(opts: AgentOptions): Agent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Message } from './types';
|
|
2
|
+
export interface Memory {
|
|
3
|
+
append(message: Message): void | Promise<void>;
|
|
4
|
+
all(): Message[] | Promise<Message[]>;
|
|
5
|
+
clear(): void | Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare class InMemoryStore implements Memory {
|
|
8
|
+
private messages;
|
|
9
|
+
append(message: Message): void;
|
|
10
|
+
all(): Message[];
|
|
11
|
+
clear(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AgentEvent } from './events';
|
|
2
|
+
import type { Transport, TransportRequest, TransportResponse } from './Transport';
|
|
3
|
+
export interface Middleware {
|
|
4
|
+
name?: string;
|
|
5
|
+
beforeRequest?(req: TransportRequest): TransportRequest | Promise<TransportRequest>;
|
|
6
|
+
afterResponse?(res: TransportResponse, req: TransportRequest): TransportResponse | Promise<TransportResponse>;
|
|
7
|
+
onEvent?(event: AgentEvent): void | Promise<void>;
|
|
8
|
+
onError?(error: Error): void | Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare function applyMiddleware(transport: Transport, middleware: Middleware[]): Transport;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { JSONSchema, Message, StopReason, Usage } from './types';
|
|
2
|
+
export interface ToolDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: JSONSchema;
|
|
6
|
+
}
|
|
7
|
+
export interface ChatOptions {
|
|
8
|
+
model: string;
|
|
9
|
+
messages: Message[];
|
|
10
|
+
system?: string;
|
|
11
|
+
tools?: ToolDefinition[];
|
|
12
|
+
maxTokens?: number;
|
|
13
|
+
temperature?: number;
|
|
14
|
+
topP?: number;
|
|
15
|
+
stopSequences?: string[];
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
export type StreamEvent = {
|
|
19
|
+
type: 'text_delta';
|
|
20
|
+
text: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'tool_call_start';
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'tool_call_delta';
|
|
27
|
+
id: string;
|
|
28
|
+
argsDelta: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'tool_call_end';
|
|
31
|
+
id: string;
|
|
32
|
+
input: unknown;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'message_stop';
|
|
35
|
+
reason: StopReason;
|
|
36
|
+
usage?: Usage;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'error';
|
|
39
|
+
error: Error;
|
|
40
|
+
};
|
|
41
|
+
export interface Provider {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
stream(opts: ChatOptions): AsyncIterable<StreamEvent>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSONSchema, Message } from './types';
|
|
2
|
+
export interface ToolContext {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
messages: Message[];
|
|
5
|
+
}
|
|
6
|
+
export interface Tool<TInput = unknown, TOutput = unknown> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: JSONSchema;
|
|
10
|
+
parse?(raw: unknown): TInput;
|
|
11
|
+
execute(input: TInput, ctx: ToolContext): Promise<TOutput>;
|
|
12
|
+
}
|
|
13
|
+
export declare function defineTool<TInput, TOutput>(tool: Tool<TInput, TOutput>): Tool<TInput, TOutput>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface TransportRequest {
|
|
2
|
+
url: string;
|
|
3
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
body?: string | Uint8Array | null;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}
|
|
8
|
+
export interface TransportResponse {
|
|
9
|
+
status: number;
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
body: ReadableStream<Uint8Array> | null;
|
|
12
|
+
json(): Promise<unknown>;
|
|
13
|
+
text(): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
export interface Transport {
|
|
16
|
+
request(req: TransportRequest): Promise<TransportResponse>;
|
|
17
|
+
}
|
|
18
|
+
export declare const fetchTransport: Transport;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StreamEvent } from './Provider';
|
|
2
|
+
import type { StopReason } from './types';
|
|
3
|
+
export type AgentEvent = StreamEvent | {
|
|
4
|
+
type: 'step_start';
|
|
5
|
+
step: number;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'tool_result';
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
output: unknown;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'tool_error';
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
error: Error;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'done';
|
|
18
|
+
reason: StopReason;
|
|
19
|
+
};
|