@kitn.ai/ui 0.23.0 → 0.25.0
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/dist/{create-tween-vA7upv0h.js → create-tween-4z1XYLkR.js} +1 -1
- package/dist/{create-tween-CTT5l1bo.js → create-tween-B5Y4Im8G.js} +1 -1
- package/dist/{create-tween-BmBnlg25.js → create-tween-CUzOlaMS.js} +1 -1
- package/dist/elements/artifact.js +1 -1
- package/dist/elements/cards.js +1 -1
- package/dist/elements/chat-workspace.js +1 -1
- package/dist/elements/chat.js +1 -1
- package/dist/elements/choice.js +1 -1
- package/dist/elements/chunks/artifact-BSuPYFHY.js +1 -0
- package/dist/elements/chunks/{card-renderer-aNA0WRFH.js → card-renderer-CSoTL_e1.js} +1 -1
- package/dist/elements/chunks/card-routing-BK09BdmL.js +1 -0
- package/dist/elements/chunks/{chat-thread-DN9evldr.js → chat-thread-DxoKaStk.js} +1 -1
- package/dist/elements/chunks/{choice-card-kNsjU2m8.js → choice-card-CGMc3kek.js} +1 -1
- package/dist/elements/chunks/{confirm-card-CEvFmVhz.js → confirm-card-BWjf2-xo.js} +1 -1
- package/dist/elements/chunks/{form-lUuJjz6s.js → form-Cp8Y00Wn.js} +1 -1
- package/dist/elements/chunks/link-preview-Cf5KOP-i.js +1 -0
- package/dist/elements/chunks/link-preview-DNILK391.js +1 -0
- package/dist/elements/chunks/{markdown-BpAHnBJz.js → markdown-DbozyYqa.js} +16 -16
- package/dist/elements/chunks/{message-CoqLuLkd.js → message-CE4k-qaj.js} +1 -1
- package/dist/elements/chunks/{message-_oYx5mk1.js → message-DtXKPqiR.js} +1 -1
- package/dist/elements/chunks/{reasoning-D26Bb4p6.js → reasoning-BrxQfpfI.js} +1 -1
- package/dist/elements/chunks/source-w9V0NnBn.js +1 -0
- package/dist/elements/chunks/{tasks-card-CfqrkoVO.js → tasks-card-lPxoodlA.js} +1 -1
- package/dist/elements/compare.js +1 -1
- package/dist/elements/confirm-card.js +1 -1
- package/dist/elements/embed.js +1 -1
- package/dist/elements/form.js +1 -1
- package/dist/elements/link-preview.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/message.js +1 -1
- package/dist/elements/reasoning.js +1 -1
- package/dist/elements/remote.js +1 -1
- package/dist/elements/source.js +1 -1
- package/dist/elements/tasks.js +1 -1
- package/dist/elements/thread.js +1 -1
- package/dist/index.js +4011 -3936
- package/dist/index.server.js +3302 -3228
- package/dist/kai.es.js +1 -1
- package/dist/primitives/card-routing.d.ts +33 -0
- package/dist/{register-impl-C96AnOJn.js → register-impl-DGmGzrEM.js} +15 -15
- package/dist/{solid-C76UXJuy.js → solid-BMuDmFo_.js} +4427 -4352
- package/dist/{solid-BuqWLn6x.js → solid-CGYNdLRR.js} +3738 -3664
- package/dist/solid.js +1 -1
- package/dist/solid.server.js +1 -1
- package/dist/state/stream.d.ts +22 -4
- package/dist/{variant-aurora-CD35fdJF.js → variant-aurora-DwSOfraQ.js} +2 -2
- package/dist/{variant-aurora-Dau5Z4yR.js → variant-aurora-XEkPT0_z.js} +1 -1
- package/dist/{variant-aurora-Dc-2RVH9.js → variant-aurora-wKvAQ5wp.js} +2 -2
- package/dist/{variant-custom-CHr_jbMU.js → variant-custom-BhS9wIpU.js} +2 -2
- package/dist/{variant-custom-Df7QvXyZ.js → variant-custom-MkTNTycd.js} +1 -1
- package/dist/{variant-custom-Cyu8zx4A.js → variant-custom-eFIg2XWQ.js} +2 -2
- package/dist/{variant-wave-CXcaP_9W.js → variant-wave-BwzrHD1s.js} +1 -1
- package/dist/{variant-wave-BkVpxkVF.js → variant-wave-CUWGx9Bn.js} +2 -2
- package/dist/{variant-wave-DcGqjVnK.js → variant-wave-CbVsmgwT.js} +2 -2
- package/dist/wire.js +112 -105
- package/package.json +6 -6
- package/src/components/artifact.tsx +110 -24
- package/src/components/markdown.tsx +83 -5
- package/src/components/source.tsx +35 -3
- package/src/primitives/card-routing.ts +54 -2
- package/src/state/stream.ts +92 -3
- package/src/wire/formats/openai.ts +38 -2
- package/dist/elements/chunks/artifact-BhJIuh3D.js +0 -1
- package/dist/elements/chunks/card-routing-C986KuUA.js +0 -1
- package/dist/elements/chunks/link-preview-C9-jNJBf.js +0 -1
- package/dist/elements/chunks/source-eJurW_-L.js +0 -1
package/dist/elements/remote.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as J,g as K,h as T,o as Q,k as X}from"./chunks/define-B_tXMYRm.js";import{r as Y,e as Z}from"./chunks/card-routing-
|
|
1
|
+
import{f as J,g as K,h as T,o as Q,k as X}from"./chunks/define-B_tXMYRm.js";import{r as Y,e as Z}from"./chunks/card-routing-BK09BdmL.js";const q="kitn-card";function M(n,e){return function(o){return{protocol:q,version:n,nonce:e,message:o}}}function ee(n,e){if(typeof n!="object"||n===null)return!1;const o=n,t=o.message;return o.protocol===q&&typeof o.version=="string"&&typeof o.nonce=="string"&&typeof t=="object"&&t!==null&&t.dir===e}function ne(n,e,o){const t=new URL(n).origin;if(e===o)throw new Error("[kai-remote] providerOrigin must be cross-origin to the host");if(t===o)throw new Error("[kai-remote] src must not be same-origin as the host");if(t!==e)throw new Error("[kai-remote] src origin must equal providerOrigin")}const te=new Set(["protocol","version","dir","kind","mode","locale","edge","code","acceptedVersion","supportedVersions","cardId","type","id","height","target"]),oe=new Set(["authToken","nonce"]);function O(n){if(Array.isArray(n))return n.map(O);if(n&&typeof n=="object"){const e={};for(const[o,t]of Object.entries(n))oe.has(o)?e[o]="[redacted]":typeof t=="object"&&t!==null?e[o]=O(t):e[o]=te.has(o)?t:"[redacted]";return e}return n}function re(n){return/^[0-9]+$/.test(n)}const ie=new Set(["__proto__","constructor","prototype"]);function R(n){if(Array.isArray(n))return n.some(R);if(n&&typeof n=="object"){for(const e of Object.keys(n))if(ie.has(e)||R(n[e]))return!0}return!1}const ce=new Set(["ready","submit","action","send-prompt","open","resize","state","dismiss","error"]);function ae(n){return typeof n=="string"&&ce.has(n)}const V=["1"],le="allow-scripts allow-forms allow-same-origin",de=5e3;function se(n){try{return new URL(n).host}catch{return n}}function ue(n){const{container:e,providerOrigin:o,src:t,policy:r,maxHeight:d}=n,s=typeof window<"u"?window.location.origin:"";ne(t,o,s);const g=n.handshakeTimeoutMs??de;let m=0,w=P(),k=M("1",w),l="connecting",b=pe(n.context),v=n.envelope,p=null,u=null,c=null,I,y=null;function $(i){try{console.warn("[kai-remote]",O(i))}catch{}}function x(i){const a=c?.contentWindow;if(a)try{a.postMessage(k(i),o)}catch{}}function S(){I!==void 0&&(clearTimeout(I),I=void 0)}function U(i){l==="open"?x({dir:"down",kind:"context",context:i}):l==="connecting"&&(p=i)}function _(i){l==="open"?x({dir:"down",kind:"render",envelope:i}):l==="connecting"&&(u=i)}function z(){p&&(x({dir:"down",kind:"context",context:p}),p=null),u&&(x({dir:"down",kind:"render",envelope:u}),u=null)}function D(i){const a=document.createElement("div");a.setAttribute("role","alert"),a.dataset.kaiRemoteFallback="";const E=document.createElement("p");E.textContent=i,a.appendChild(E);const h=document.createElement("button");h.type="button",h.textContent="Retry",h.addEventListener("click",()=>W()),a.appendChild(h),c&&c.parentNode===e?e.replaceChild(a,c):e.appendChild(a),c=null}function L(i){l!=="closed"&&(S(),l="error",p=null,u=null,D(i))}function j(){const i=m,a=document.createElement("iframe");a.setAttribute("sandbox",n.sandbox??le),a.setAttribute("referrerpolicy","no-referrer"),a.setAttribute("allow","");const E=v.title??v.type;a.setAttribute("title",`${E} \u2014 provided by ${se(o)}`),a.style.border="0",a.style.width="100%",a.addEventListener("load",()=>{m!==i||l!=="connecting"||(k=M("1",w),x({dir:"down",kind:"hello",supportedVersions:V}),S(),I=setTimeout(()=>{var h;m!==i||l!=="connecting"||(L("[timeout] The card took too long to load."),(h=r?.onError)==null||h.call(r,v.id,"[timeout] handshake timed out"))},g))}),y=h=>N(h,i),window.addEventListener("message",y),c=a,e.appendChild(a),a.setAttribute("src",t)}function W(){l==="error"&&(m+=1,w=P(),k=M("1",w),l="connecting",p=null,u=null,S(),y&&(window.removeEventListener("message",y),y=null),c&&(c.remove(),c=null),p=b,u=v,e.querySelectorAll("[data-kai-remote-fallback]").forEach(i=>i.remove()),j())}function F(i){if(!c)return;const a=Math.min(i,d??1/0);c.style.height=`${a}px`}function H(){if(c)try{c.blur()}catch{}}function N(i,a){var E,h;if(a!==m||l==="closed"||l==="error")return;const A=i.data;if(i.origin===o&&i.source===c?.contentWindow&&ee(A,"up")&&A.nonce===w)try{const C=A.message;switch(C.kind){case"ready":{if(l!=="connecting")return;const f=C.acceptedVersion;if(!re(f)||!V.includes(f)){L("[version-unsupported] This card needs a different host version."),(E=r?.onError)==null||E.call(r,v.id,"[version-unsupported] no compatible protocol version");return}k=M(f,w),S(),l="open",p||(p=b),u||(u=v),z();return}case"event":{if(l!=="open")return;const f=C.event;if(f.cardId!==v.id)return;if(f.kind==="resize"){F(f.height);return}if(!ae(f.kind)||R(f)){$(A);return}Y(r??{},f);return}case"focus-edge":{H();return}case"fault":{const f=C.code,G=C.message;L(`[${f}] The card reported a problem.`),(h=r?.onError)==null||h.call(r,v.id,`[${f}] ${G}`);return}default:return}}catch{$(A)}}const B={updateContext(i){l!=="closed"&&(b=fe(b,i),U(b))},update(i){l!=="closed"&&(v=i,_(i))},destroy(){l!=="closed"&&(m+=1,l==="open"&&x({dir:"down",kind:"teardown"}),l="closed",S(),y&&(window.removeEventListener("message",y),y=null),c&&(c.remove(),c=null),e.querySelectorAll("[data-kai-remote-fallback]").forEach(i=>i.remove()))},state(){return l}};return j(),B}function P(){const n=new Uint8Array(16);crypto.getRandomValues(n);let e="";for(const o of n)e+=o.toString(16).padStart(2,"0");return e}function pe(n){return{...n}}function fe(n,e){return{...n,...e}}function me(n){if(!n||n==="*"||n.includes(","))return!1;let e;try{e=new URL(n)}catch{return!1}return e.pathname!=="/"||e.search!==""||e.hash!==""?!1:e.protocol==="https:"?!0:e.protocol==="http:"?e.hostname==="localhost"||e.hostname==="127.0.0.1":!1}function he(n,e){function o(t){Z(n,t)}return{onSubmit(t,r){var d;o({kind:"submit",cardId:t,data:r}),(d=e?.onSubmit)==null||d.call(e,t,r)},onAction(t,r,d){var s;o({kind:"action",cardId:t,action:r,payload:d}),(s=e?.onAction)==null||s.call(e,t,r,d)},onSendPrompt(t,r){var d;o({kind:"send-prompt",cardId:"",text:t,mode:r.mode,context:r.context}),(d=e?.onSendPrompt)==null||d.call(e,t,r)},onOpen(t,r){var d;o({kind:"open",cardId:"",url:t,target:r}),(d=e?.onOpen)==null||d.call(e,t,r)},onState(t,r){var d;o({kind:"state",cardId:t,patch:r}),(d=e?.onState)==null||d.call(e,t,r)},onDismiss(t){var r;o({kind:"dismiss",cardId:t}),(r=e?.onDismiss)==null||r.call(e,t)},onReopen(t){var r;o({kind:"reopen",cardId:t}),(r=e?.onReopen)==null||r.call(e,t)},onError(t,r){var d;o({kind:"error",cardId:t,message:r}),(d=e?.onError)==null||d.call(e,t,r)},maxSendPromptMode:e?.maxSendPromptMode}}J("kai-remote",{src:void 0,providerOrigin:void 0,envelope:void 0,policy:void 0},(n,{element:e})=>{let o;const[t,r]=K(!1);if(typeof window<"u"&&typeof window.matchMedia=="function"){const s=window.matchMedia("(prefers-color-scheme: dark)");r(s.matches);const g=m=>r(m.matches);s.addEventListener("change",g),T(()=>s.removeEventListener("change",g))}const d=()=>{const s=n.theme??"auto";return s==="dark"||s==="auto"&&t()};return Q(()=>{const s=e.shadowRoot;if(!s)return;function g(u){const c=document.createElement("div");c.setAttribute("role","alert"),c.textContent=u,s.appendChild(c)}const m=n.providerOrigin;if(!me(m)){g(`[kai-remote] Invalid provider-origin "${m??""}". Must be an absolute https: origin, or http://localhost / http://127.0.0.1 for local dev.`);return}const w=n.src;if(!w){g('[kai-remote] Missing required "src" attribute.');return}const k=n.envelope;if(!k){g('[kai-remote] Missing required "envelope" property.');return}const l={theme:{mode:d()?"dark":"light"},locale:typeof navigator<"u"&&navigator.language||"en"},b=n.policy,v=he(e,b),p=document.createElement("div");s.appendChild(p);try{o=ue({container:p,providerOrigin:m,src:w,envelope:k,context:l,policy:v})}catch(u){const c=u instanceof Error?u.message:String(u);g(`[kai-remote] Mount failed: ${c}`),p.remove();return}T(()=>{o?.destroy(),o=void 0})}),X(()=>{const s=d()?"dark":"light";o?.updateContext({theme:{mode:s}})}),[]});
|
package/dist/elements/source.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as o,c as t,S as v,g as p,o as w,h as m,F,j as A,t as S}from"./chunks/define-B_tXMYRm.js";import{a,b as c,c as l,S as k}from"./chunks/source-
|
|
1
|
+
import{f as o,c as t,S as v,g as p,o as w,h as m,F,j as A,t as S}from"./chunks/define-B_tXMYRm.js";import{a,b as c,c as l,S as k}from"./chunks/source-w9V0NnBn.js";var y=S("<style>:host{display:inline-flex}");o("kai-source",{href:"",label:void 0,headline:"",description:"",showFavicon:!1},(e,{flag:n})=>[y(),t(v,{get when(){return e.href},get children(){return t(a,{get href(){return e.href},get children(){return[t(c,{get label(){return e.label},get showFavicon(){return n("showFavicon")}}),t(l,{get title(){return e.headline??""},get description(){return e.description??""}})]}})}})]);function u(e){return{href:e.getAttribute("href")??"",label:e.getAttribute("label")??void 0,title:e.getAttribute("headline")??void 0,description:e.getAttribute("description")??void 0,showFavicon:e.hasAttribute("show-favicon")&&e.getAttribute("show-favicon")!=="false"}}o("kai-sources",{sources:[],showFavicon:!1,numbered:!1},(e,{element:n,flag:s})=>{const[h,d]=p([]);w(()=>{const r=()=>{const f=[...n.querySelectorAll("kai-source")];d(f.map(u))};r();const i=new MutationObserver(r);i.observe(n,{childList:!0,attributes:!0,subtree:!0}),m(()=>i.disconnect())});const g=()=>[...e.sources??[],...h()],b=()=>s("numbered");return t(k,{get children(){return t(F,{get each(){return g()},children:(r,i)=>t(a,{get href(){return r.href},get children(){return[t(c,{get label(){return A(()=>!!b())()?i()+1:r.label},get showFavicon(){return r.showFavicon??s("showFavicon")}}),t(l,{get title(){return r.title??""},get description(){return r.description??""}})]}})})}})});export{u as parseKaiSourceElement};
|
package/dist/elements/tasks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as i,c as u}from"./chunks/define-B_tXMYRm.js";import{T as s}from"./chunks/tasks-card-
|
|
1
|
+
import{f as i,c as u}from"./chunks/define-B_tXMYRm.js";import{T as s}from"./chunks/tasks-card-lPxoodlA.js";i("kai-tasks",{data:void 0,cardId:void 0,heading:void 0,resolution:void 0,value:void 0,defaultValue:void 0,disabled:!1,readonly:!1},(a,{element:t,dispatch:o,flag:d,expose:r})=>{let e;return r({select:l=>e?.select(l),toggle:(l,n)=>e?.toggle(l,n),send:()=>e?.send(),focus:l=>e?.focus(l),dismiss:()=>e?.dismiss(),reopen:()=>e?.reopen()}),u(s,{get data(){return a.data},get cardId(){return a.cardId??(t.id||"kai-tasks")},get heading(){return a.heading},get resolution(){return a.resolution},get value(){return a.value},get defaultValue(){return a.defaultValue},get disabled(){return d("disabled")},get readonly(){return d("readonly")},onValueChange:l=>o("kai-value-change",l),controllerRef:l=>e=l,hostElement:t})});
|
package/dist/elements/thread.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as B,l as M,o as w,c as r,v as R,i as h,S as o,F as H,a as T,b as k,C as z,t as c,f as $,g as A,h as j,j as C,u as F}from"./chunks/define-B_tXMYRm.js";import{r as L,T as q}from"./chunks/slots-CIw9RlAe.js";import{C as N,a as O,b as U,S as _}from"./chunks/scroll-button-CrTo7wm4.js";import{M as D,a as x,b as E}from"./chunks/message-
|
|
1
|
+
import{y as B,l as M,o as w,c as r,v as R,i as h,S as o,F as H,a as T,b as k,C as z,t as c,f as $,g as A,h as j,j as C,u as F}from"./chunks/define-B_tXMYRm.js";import{r as L,T as q}from"./chunks/slots-CIw9RlAe.js";import{C as N,a as O,b as U,S as _}from"./chunks/scroll-button-CrTo7wm4.js";import{M as D,a as x,b as E}from"./chunks/message-CE4k-qaj.js";import{b as G,c as I,a as J}from"./chunks/message-DtXKPqiR.js";import{L as K}from"./chunks/loader-B5QzK_8_.js";var P=c('<div class="flex min-h-[10rem] flex-1 flex-col items-center justify-center gap-1 py-12 text-center"><p class="text-sm font-medium text-foreground">No messages yet</p><p class="text-xs text-muted-foreground">Messages will appear here as the conversation starts.'),Q=c('<div class="rounded-lg px-1 py-2">'),V=c('<div class="absolute bottom-4 left-1/2 flex w-full max-w-3xl -translate-x-1/2 justify-center px-5">'),S=c("<div>");function W(){return P()}function X(e){const d=B(),m=()=>e.actionsReveal==="hover"?"hover":"always";let n;const i=G({emit:a=>{var t;return(t=e.onMessageAction)==null?void 0:t.call(e,a)},target:()=>n}),g=()=>e.scrollButton!==!1,p=()=>e.messages.length===0&&!e.loading,v=M(()=>e.messages.map(a=>a.id));return w(()=>{var a;(a=e.controllerRef)==null||a.call(e,{scrollToBottom:t=>{const l=n?.querySelector(".overflow-y-auto");l?.scrollTo({top:l.scrollHeight,behavior:t??"smooth"})}})}),r(z,{get proseSize(){return e.proseSize},get codeTheme(){return e.codeTheme},get codeHighlight(){return e.codeHighlight!==!1},get portalMount(){return d.portalMount()},get children(){var a=S();return R(t=>n=t,a),h(a,r(N,{class:"h-full px-4 py-3",get children(){return[r(O,{class:"mx-auto w-full max-w-3xl space-y-4",get children(){return[r(o,{get when(){return p()},get children(){return r(o,{get when(){return e.empty},get fallback(){return r(W,{})},get children(){return e.empty}})}}),r(H,{get each(){return v()},children:(t,l)=>r(o,{get when(){return e.messages[l()]},children:s=>{const y=r(D,{get parts(){return s().parts},get cardTypes(){return e.cardTypes},get cardSchemas(){return e.cardSchemas},get isUser(){return s().role==="user"},get markdown(){return s().role==="assistant"},get actions(){return s().actions},get actionsReveal(){return m()},get activeFeedback(){return i.resolveFeedback(s())},get copied(){return i.isCopied(s().id)},onAction:u=>i.handleAction(s(),u)}),b=()=>m()==="hover"?"group ":"";return r(o,{get when(){return s().avatar},get fallback(){return r(x,{get role(){return s().role},get class(){return`${b()}${s().role==="user"?"flex-col items-end":"flex-col items-start"}`},children:y})},children:u=>r(x,{get role(){return s().role},get class(){return b()},get children(){return[r(E,{get src(){return u().src??""},get alt(){return u().alt??""},get fallback(){return u().fallback}}),(()=>{var f=S();return h(f,y),T(()=>k(f,`flex min-w-0 flex-1 flex-col ${s().role==="user"?"items-end":"items-start"}`)),f})()]}})})}})}),r(o,{get when(){return e.loading},get children(){return r(x,{class:"flex-col items-start",get children(){var t=Q();return h(t,r(K,{variant:"typing"})),t}})}}),r(U,{})]}}),r(o,{get when(){return g()},get children(){var t=V();return h(t,r(_,{class:"shadow-sm"})),t}})]}})),T(()=>k(a,`relative flex h-full min-h-0 flex-col bg-background ${e.class??""}`)),a}})}var Y=c("<style>:host{display:block;height:100%}"),Z=c("<slot name=empty>");$("kai-thread",{messages:void 0,loading:!1,proseSize:"sm",codeTheme:"github-dark-dimmed",codeHighlight:!0,actionsReveal:"always",scrollButton:!0,class:void 0,cardTypes:void 0,cardSchemas:void 0},(e,{element:d,dispatch:m,flag:n,expose:i})=>{let g;const p=J("kai-thread"),[v,a]=A({});return w(()=>{const t=()=>a(L(d,q));t();const l=new MutationObserver(t);l.observe(d,{childList:!0}),j(()=>l.disconnect())}),i({scrollToBottom:t=>g?.scrollToBottom(t)}),[Y(),r(X,{get class(){return e.class},get messages(){return p(e.messages)},get loading(){return n("loading")},get proseSize(){return e.proseSize},get codeTheme(){return e.codeTheme},get codeHighlight(){return n("codeHighlight")},get actionsReveal(){return e.actionsReveal},get scrollButton(){return e.scrollButton!==!1},get cardTypes(){return I(e.cardTypes,e.theme)},get cardSchemas(){return e.cardSchemas},get empty(){return C(()=>!!v().empty)()?(()=>{var t=Z();return t._$owner=F(),t})():void 0},onMessageAction:t=>m("kai-message-action",t),controllerRef:t=>g=t})]});
|