@sveda-ai/svelte 0.3.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 +557 -0
- package/README.md +18 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.js +1138 -0
- package/dist/styles.css +3 -0
- package/package.json +73 -0
- package/src/app.d.ts +7 -0
- package/src/appearance.ts +66 -0
- package/src/components/ChatHistoryList.svelte +134 -0
- package/src/components/SvedaChat.svelte +689 -0
- package/src/components/SvedaProvider.svelte +29 -0
- package/src/context.ts +50 -0
- package/src/hooks/useSvedaChat.svelte.ts +120 -0
- package/src/hooks/useSvedaChatLayout.svelte.ts +308 -0
- package/src/hooks/useSvedaStreaming.svelte.ts +117 -0
- package/src/i18n.ts +51 -0
- package/src/index.ts +106 -0
- package/src/lib/utils.ts +6 -0
- package/src/markdown.css +96 -0
- package/src/provider.ts +173 -0
- package/src/styles.css +6 -0
- package/src/theme.css +137 -0
package/dist/styles.css
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
:where(.sveda-chat,sveda-chat){--sveda-background:0 0% 100%;--sveda-foreground:0 0% 4%;--sveda-card:0 0% 100%;--sveda-card-foreground:0 0% 4%;--sveda-popover:0 0% 100%;--sveda-popover-foreground:0 0% 4%;--sveda-primary:0 0% 4%;--sveda-primary-foreground:0 0% 100%;--sveda-secondary:40 20% 90%;--sveda-secondary-foreground:0 0% 4%;--sveda-muted:40 22% 90%;--sveda-muted-foreground:40 6% 41%;--sveda-accent:40 22% 90%;--sveda-accent-foreground:0 0% 4%;--sveda-destructive:0 84.2% 60.2%;--sveda-destructive-foreground:0 0% 98%;--sveda-border:42 18% 82%;--sveda-input:40 22% 92%;--sveda-ring:0 0% 4%;--sveda-radius:0;--sveda-brand:0 0% 4%;--sveda-brand-foreground:0 0% 100%;--sveda-surface:hsl(var(--sveda-background));--font-sans:Geist,ui-sans-serif,system-ui,sans-serif;--font-serif:Newsreader,ui-serif,Georgia,serif;--font-mono:"Geist Mono",ui-monospace,monospace}.sveda-chat,sveda-chat{--color-background:hsl(var(--sveda-background));--color-foreground:hsl(var(--sveda-foreground));--color-card:hsl(var(--sveda-card));--color-card-foreground:hsl(var(--sveda-card-foreground));--color-popover:hsl(var(--sveda-popover));--color-popover-foreground:hsl(var(--sveda-popover-foreground));--color-primary:hsl(var(--sveda-primary));--color-primary-foreground:hsl(var(--sveda-primary-foreground));--color-secondary:hsl(var(--sveda-secondary));--color-secondary-foreground:hsl(var(--sveda-secondary-foreground));--color-muted:hsl(var(--sveda-muted));--color-muted-foreground:hsl(var(--sveda-muted-foreground));--color-accent:hsl(var(--sveda-accent));--color-accent-foreground:hsl(var(--sveda-accent-foreground));--color-destructive:hsl(var(--sveda-destructive));--color-destructive-foreground:hsl(var(--sveda-destructive-foreground));--color-border:hsl(var(--sveda-border));--color-input:hsl(var(--sveda-input));--color-ring:hsl(var(--sveda-ring));--color-brand-primary-purple:hsl(var(--sveda-brand));--color-brand-primary-purple-foreground:hsl(var(--sveda-brand-foreground));--radius:var(--sveda-radius);--radius-xs:var(--sveda-radius);--radius-sm:var(--sveda-radius);--radius-md:var(--sveda-radius);--radius-lg:var(--sveda-radius);--radius-xl:var(--sveda-radius);--radius-2xl:var(--sveda-radius);--radius-3xl:var(--sveda-radius);--radius-4xl:var(--sveda-radius);font-family:var(--font-sans,Geist,ui-sans-serif,system-ui,sans-serif)}:where(.sveda-chat.dark,sveda-chat.dark,.dark .sveda-chat,.dark sveda-chat){--sveda-background:30 12% 9%;--sveda-foreground:40 24% 94%;--sveda-card:30 10% 12%;--sveda-card-foreground:40 24% 94%;--sveda-popover:30 10% 12%;--sveda-popover-foreground:40 24% 94%;--sveda-primary:40 24% 94%;--sveda-primary-foreground:30 12% 9%;--sveda-secondary:30 8% 16%;--sveda-secondary-foreground:40 24% 94%;--sveda-muted:30 8% 16%;--sveda-muted-foreground:36 10% 62%;--sveda-accent:30 8% 16%;--sveda-accent-foreground:40 24% 94%;--sveda-destructive:0 62.8% 30.6%;--sveda-destructive-foreground:40 24% 94%;--sveda-border:30 8% 22%;--sveda-input:30 8% 16%;--sveda-ring:40 24% 94%;--sveda-brand:40 24% 94%;--sveda-brand-foreground:30 12% 9%}.sveda-chat-surface{background-color:var(--sveda-surface,hsl(var(--sveda-background)))}.sveda-chat input:not([type]),.sveda-chat input[type=search],.sveda-chat input[type=text],.sveda-chat textarea{box-sizing:border-box;width:auto;max-width:100%;margin:0;border:0;border-radius:var(--sveda-radius,0);background:transparent;padding:0;min-height:0;box-shadow:none;font:inherit;color:inherit;letter-spacing:inherit;resize:none;-webkit-appearance:none;-moz-appearance:none;appearance:none}.sveda-chat .sveda-chat-input-textarea{width:100%;min-height:60px;max-height:250px;padding:.75rem}.sveda-chat .sveda-chat-frame,.sveda-chat-frame,sveda-chat .sveda-chat-frame{border:1px dashed hsl(var(--sveda-foreground))}.sveda-chat ::-moz-selection,sveda-chat ::-moz-selection{background:hsl(var(--sveda-foreground));color:hsl(var(--sveda-background))}.sveda-chat ::selection,sveda-chat ::selection{background:hsl(var(--sveda-foreground));color:hsl(var(--sveda-background))}body.sveda-chat-immersive-mode{overflow:hidden;overscroll-behavior:none}.sveda-chat .prose{line-height:1.55}.sveda-chat .prose h1,.sveda-chat .prose h2,.sveda-chat .prose h3,.sveda-chat .prose h4{color:inherit;line-height:1.3;letter-spacing:-.01em}.sveda-chat .prose h1{font-size:1.2rem;font-weight:700;margin:.9em 0 .35em}.sveda-chat .prose h2{font-size:1.08rem;font-weight:650;margin:.85em 0 .3em}.sveda-chat .prose h3,.sveda-chat .prose h4{font-size:1rem;font-weight:600;margin:.75em 0 .25em}.sveda-chat .prose h1:first-child,.sveda-chat .prose h2:first-child,.sveda-chat .prose h3:first-child,.sveda-chat .prose h4:first-child{margin-top:0}.sveda-chat .prose p{margin:.45em 0}.sveda-chat .prose p:first-child{margin-top:0}.sveda-chat .prose p:last-child{margin-bottom:0}.sveda-chat .prose ol,.sveda-chat .prose ul{margin:.4em 0;padding-left:1.25rem}.sveda-chat .prose ul{list-style-type:disc}.sveda-chat .prose ol{list-style-type:decimal}.sveda-chat .prose li{display:list-item;margin:.2em 0}.sveda-chat .prose li>p{margin:.15em 0}.sveda-chat .prose hr{border:0;border-top:1px solid hsl(var(--sveda-border));margin:.9em 0}.sveda-chat .prose a{color:hsl(var(--sveda-brand));text-decoration:underline;text-underline-offset:2px}.sveda-chat .prose blockquote{margin:.5em 0;padding-left:.75rem;border-left:2px solid hsl(var(--sveda-border));color:hsl(var(--sveda-muted-foreground))}.sveda-chat .prose strong{font-weight:650}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }
|
|
2
|
+
|
|
3
|
+
/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.-bottom-px{bottom:-1px}.-left-px{left:-1px}.-right-px{right:-1px}.-top-px{top:-1px}.bottom-0{bottom:0}.bottom-3{bottom:.75rem}.bottom-4{bottom:1rem}.left-0{left:0}.left-3{left:.75rem}.right-0{right:0}.right-3{right:.75rem}.right-4{right:1rem}.right-full{right:100%}.top-0{top:0}.top-3{top:.75rem}.z-10{z-index:10}.z-50{z-index:50}.z-\[60\]{z-index:60}.z-\[70\]{z-index:70}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.ml-0\.5{margin-left:.125rem}.ml-8{margin-left:2rem}.mr-4{margin-right:1rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-auto{margin-top:auto}.flex{display:flex}.inline-flex{display:inline-flex}.size-5{width:1.25rem;height:1.25rem}.size-7{width:1.75rem;height:1.75rem}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-2\.5{height:.625rem}.h-3{height:.75rem}.h-4{height:1rem}.h-6{height:1.5rem}.h-9{height:2.25rem}.h-\[100dvh\]{height:100dvh}.h-auto{height:auto}.h-full{height:100%}.h-screen{height:100vh}.max-h-\[250px\]{max-height:250px}.min-h-0{min-height:0}.min-h-\[60px\]{min-height:60px}.w-1{width:.25rem}.w-1\.5{width:.375rem}.w-2\.5{width:.625rem}.w-3{width:.75rem}.w-4{width:1rem}.w-6{width:1.5rem}.w-80{width:20rem}.w-9{width:2.25rem}.w-\[min\(20rem\2c 33vw\)\]{width:min(20rem,33vw)}.w-full{width:100%}.min-w-0{min-width:0}.min-w-max{min-width:-moz-max-content;min-width:max-content}.max-w-56{max-width:14rem}.max-w-7xl{max-width:80rem}.max-w-\[88vw\]{max-width:88vw}.max-w-\[90\%\]{max-width:90%}.max-w-full{max-width:100%}.max-w-none{max-width:none}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.cursor-ew-resize{cursor:ew-resize}.cursor-n-resize{cursor:n-resize}.cursor-nw-resize{cursor:nw-resize}.cursor-pointer{cursor:pointer}.cursor-w-resize{cursor:w-resize}.touch-none{touch-action:none}.resize-none{resize:none}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-stretch{align-items:stretch}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-px{gap:1px}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-\[var\(--sveda-radius\)\]{border-radius:var(--sveda-radius)}.rounded-full{border-radius:9999px}.rounded-none{border-radius:0}.rounded-t-\[var\(--sveda-radius\)\]{border-top-left-radius:var(--sveda-radius);border-top-right-radius:var(--sveda-radius)}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-r{border-right-width:1px}.border-r-0{border-right-width:0}.border-t{border-top-width:1px}.border-t-0{border-top-width:0}.border-dashed{border-style:dashed}.border-border{border-color:hsl(var(--sveda-border))}.border-border\/40{border-color:hsl(var(--sveda-border)/.4)}.border-border\/50{border-color:hsl(var(--sveda-border)/.5)}.border-destructive{border-color:hsl(var(--sveda-destructive))}.border-foreground{border-color:hsl(var(--sveda-foreground))}.border-input{border-color:hsl(var(--sveda-input))}.border-primary{border-color:hsl(var(--sveda-primary))}.border-transparent{border-color:transparent}.bg-background{background-color:hsl(var(--sveda-background))}.bg-black\/40{background-color:rgba(0,0,0,.4)}.bg-card{background-color:hsl(var(--sveda-card))}.bg-foreground{background-color:hsl(var(--sveda-foreground))}.bg-input{background-color:hsl(var(--sveda-input))}.bg-muted{background-color:hsl(var(--sveda-muted))}.bg-muted\/60{background-color:hsl(var(--sveda-muted)/.6)}.bg-primary{background-color:hsl(var(--sveda-primary))}.bg-primary\/10{background-color:hsl(var(--sveda-primary)/.1)}.bg-secondary{background-color:hsl(var(--sveda-secondary))}.bg-transparent{background-color:transparent}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-\[env\(safe-area-inset-bottom\)\]{padding-bottom:env(safe-area-inset-bottom)}.pt-\[env\(safe-area-inset-top\)\]{padding-top:env(safe-area-inset-top)}.text-left{text-align:left}.text-center{text-align:center}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.text-\[11px\]{font-size:11px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.leading-none{line-height:1}.tracking-\[0\.08em\]{letter-spacing:.08em}.tracking-\[0\.12em\]{letter-spacing:.12em}.tracking-\[0\.14em\]{letter-spacing:.14em}.tracking-wide{letter-spacing:.025em}.text-card-foreground{color:hsl(var(--sveda-card-foreground))}.text-destructive{color:hsl(var(--sveda-destructive))}.text-foreground{color:hsl(var(--sveda-foreground))}.text-muted-foreground{color:hsl(var(--sveda-muted-foreground))}.text-primary{color:hsl(var(--sveda-primary))}.text-primary-foreground{color:hsl(var(--sveda-primary-foreground))}.text-secondary-foreground{color:hsl(var(--sveda-secondary-foreground))}.opacity-0{opacity:0}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-none{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-0{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.placeholder\:font-mono::-moz-placeholder{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.placeholder\:font-mono::placeholder{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.placeholder\:text-\[11px\]::-moz-placeholder{font-size:11px}.placeholder\:text-\[11px\]::placeholder{font-size:11px}.placeholder\:tracking-\[0\.08em\]::-moz-placeholder{letter-spacing:.08em}.placeholder\:tracking-\[0\.08em\]::placeholder{letter-spacing:.08em}.placeholder\:text-muted-foreground::-moz-placeholder{color:hsl(var(--sveda-muted-foreground))}.placeholder\:text-muted-foreground::placeholder{color:hsl(var(--sveda-muted-foreground))}.last\:mb-1:last-child{margin-bottom:.25rem}.hover\:bg-muted:hover{background-color:hsl(var(--sveda-muted))}.hover\:bg-primary\/20:hover{background-color:hsl(var(--sveda-primary)/.2)}.hover\:bg-primary\/30:hover{background-color:hsl(var(--sveda-primary)/.3)}.hover\:text-foreground:hover{color:hsl(var(--sveda-foreground))}.hover\:opacity-90:hover{opacity:.9}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:opacity-100{opacity:1}@media (min-width:1872px){.min-\[1872px\]\:bottom-4{bottom:1rem}.min-\[1872px\]\:right-4{right:1rem}.min-\[1872px\]\:h-10{height:2.5rem}.min-\[1872px\]\:w-10{width:2.5rem}}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sveda-ai/svelte",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "SSPL-1.0",
|
|
6
|
+
"description": "Svelte 5 chat UI to embed a Sveda AI agent. https://sveda.dev/docs/chat-ui",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"sveda",
|
|
9
|
+
"ai",
|
|
10
|
+
"agent",
|
|
11
|
+
"copilot",
|
|
12
|
+
"svelte",
|
|
13
|
+
"chat"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/neresson/sveda.git",
|
|
18
|
+
"directory": "packages/svelte"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://sveda.dev/docs/chat-ui",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"svelte": "./dist/index.js",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./styles.css": "./dist/styles.css",
|
|
30
|
+
"./theme.css": "./src/theme.css"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"src"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"clsx": "^2.1.1",
|
|
41
|
+
"dompurify": "^3.3.1",
|
|
42
|
+
"highlight.js": "^11.11.1",
|
|
43
|
+
"lucide-svelte": "^0.468.0",
|
|
44
|
+
"marked": "^17.0.2",
|
|
45
|
+
"tailwind-merge": "^2.6.0",
|
|
46
|
+
"@sveda-ai/chat": "0.3.1",
|
|
47
|
+
"@sveda-ai/core": "0.3.1",
|
|
48
|
+
"@sveda-ai/protocol": "0.3.1"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"svelte": "^5.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
55
|
+
"@testing-library/svelte": "^5.2.7",
|
|
56
|
+
"happy-dom": "^20.14.5",
|
|
57
|
+
"svelte": "^5.20.0",
|
|
58
|
+
"svelte-check": "^4.1.4",
|
|
59
|
+
"tailwindcss": "^3.4.17",
|
|
60
|
+
"tailwindcss-animate": "^1.0.7",
|
|
61
|
+
"typescript": "^5.8.2",
|
|
62
|
+
"vite": "^6.2.0",
|
|
63
|
+
"vitest": "^4.1.4"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "vite build && npm run build:css && npm run build:types",
|
|
67
|
+
"build:css": "tailwindcss -c tailwind.config.ts -i src/styles.css -o dist/styles.css --minify",
|
|
68
|
+
"build:types": "cp types-entry.d.ts dist/index.d.ts",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"typecheck": "svelte-check --tsconfig ./tsconfig.json",
|
|
71
|
+
"lint": "echo 'no lint configured'"
|
|
72
|
+
}
|
|
73
|
+
}
|
package/src/app.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applySvedaAppearance as applySvedaAppearanceDom,
|
|
3
|
+
resolveSvedaAppearance,
|
|
4
|
+
sanitizeSvedaChrome,
|
|
5
|
+
sanitizeSvedaLauncher,
|
|
6
|
+
type SvedaAppearance,
|
|
7
|
+
type SvedaAppearanceChrome,
|
|
8
|
+
type SvedaAppearanceLauncher,
|
|
9
|
+
} from '@sveda-ai/chat';
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
SVEDA_APPEARANCE_STYLE_ID,
|
|
13
|
+
SVEDA_TOKEN_KEYS,
|
|
14
|
+
SVEDA_LAUNCHER_ICON_IDS,
|
|
15
|
+
SVEDA_DEFAULT_LAUNCHER_ICON,
|
|
16
|
+
SVEDA_LAUNCHER_IMAGE_MAX_BYTES,
|
|
17
|
+
SVEDA_LAUNCHER_IMAGE_MAX_CHARS,
|
|
18
|
+
SVEDA_APPEARANCE_PRESET_IDS,
|
|
19
|
+
SVEDA_APPEARANCE_PRESETS,
|
|
20
|
+
isSvedaHsl,
|
|
21
|
+
sanitizeSvedaTheme,
|
|
22
|
+
sanitizeSvedaLauncherImage,
|
|
23
|
+
sanitizeSvedaLauncher,
|
|
24
|
+
sanitizeSvedaChrome,
|
|
25
|
+
sanitizeSvedaRadius,
|
|
26
|
+
parseRadiusPx,
|
|
27
|
+
formatRadiusPx,
|
|
28
|
+
hslToHex,
|
|
29
|
+
hexToHsl,
|
|
30
|
+
resolveSvedaAppearance,
|
|
31
|
+
buildAppearanceCss,
|
|
32
|
+
isSvedaAppearanceProvided,
|
|
33
|
+
mergeSvedaAppearance,
|
|
34
|
+
} from '@sveda-ai/chat';
|
|
35
|
+
export type {
|
|
36
|
+
SvedaTokenKey,
|
|
37
|
+
SvedaAppearanceTokens,
|
|
38
|
+
SvedaAppearanceTheme,
|
|
39
|
+
SvedaLauncherIconId,
|
|
40
|
+
SvedaAppearanceLauncher,
|
|
41
|
+
SvedaAppearanceChrome,
|
|
42
|
+
SvedaAppearance,
|
|
43
|
+
SvedaAppearancePresetId,
|
|
44
|
+
} from '@sveda-ai/chat';
|
|
45
|
+
|
|
46
|
+
export const svedaLauncher: SvedaAppearanceLauncher = sanitizeSvedaLauncher(null);
|
|
47
|
+
|
|
48
|
+
export const useSvedaLauncher = (): SvedaAppearanceLauncher => svedaLauncher;
|
|
49
|
+
|
|
50
|
+
export const svedaChrome: SvedaAppearanceChrome = sanitizeSvedaChrome(null);
|
|
51
|
+
|
|
52
|
+
export const useSvedaChrome = (): SvedaAppearanceChrome => svedaChrome;
|
|
53
|
+
|
|
54
|
+
export const applySvedaAppearance = (appearance: SvedaAppearance | null | undefined): void => {
|
|
55
|
+
const resolved = resolveSvedaAppearance(appearance);
|
|
56
|
+
const launcher = sanitizeSvedaLauncher(resolved?.launcher);
|
|
57
|
+
svedaLauncher.label = launcher.label;
|
|
58
|
+
svedaLauncher.icon = launcher.icon;
|
|
59
|
+
svedaLauncher.image = launcher.image;
|
|
60
|
+
|
|
61
|
+
const chrome = sanitizeSvedaChrome(resolved?.chrome);
|
|
62
|
+
svedaChrome.modelSelect = chrome.modelSelect;
|
|
63
|
+
svedaChrome.thinking = chrome.thinking;
|
|
64
|
+
|
|
65
|
+
applySvedaAppearanceDom(appearance);
|
|
66
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SvedaChatHistory } from '@sveda-ai/chat';
|
|
3
|
+
import { getUserMessageText } from '@sveda-ai/chat';
|
|
4
|
+
import { Search, SquarePen, Trash2 } from 'lucide-svelte';
|
|
5
|
+
import { useSvedaT } from '../context.js';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
histories: SvedaChatHistory[];
|
|
9
|
+
currentChatId?: string | null;
|
|
10
|
+
onSelectChat: (chatId: string) => void;
|
|
11
|
+
onDeleteChat: (chatId: string) => void;
|
|
12
|
+
onRenameChat: (chatId: string) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let { histories, currentChatId = null, onSelectChat, onDeleteChat, onRenameChat }: Props = $props();
|
|
16
|
+
|
|
17
|
+
const t = useSvedaT();
|
|
18
|
+
let searchQuery = $state('');
|
|
19
|
+
|
|
20
|
+
const previewFor = (chat: SvedaChatHistory) => {
|
|
21
|
+
if (typeof chat.preview === 'string' && chat.preview.trim()) {
|
|
22
|
+
return chat.preview.trim();
|
|
23
|
+
}
|
|
24
|
+
const message = chat.messages?.find((item) => item.role === 'user');
|
|
25
|
+
return message ? getUserMessageText(message) : '';
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const dayDiff = (timestamp: number) => {
|
|
29
|
+
const targetDate = new Date(Number(timestamp) || Date.now());
|
|
30
|
+
const now = new Date();
|
|
31
|
+
const targetStart = new Date(targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate()).getTime();
|
|
32
|
+
const nowStart = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
|
|
33
|
+
return Math.max(0, Math.floor((nowStart - targetStart) / 86400000));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const groups = $derived.by(() => {
|
|
37
|
+
const query = searchQuery.trim().toLowerCase();
|
|
38
|
+
const filtered = query
|
|
39
|
+
? histories.filter((chat) => {
|
|
40
|
+
const preview = previewFor(chat);
|
|
41
|
+
return chat.title.toLowerCase().includes(query) || preview.toLowerCase().includes(query);
|
|
42
|
+
})
|
|
43
|
+
: histories;
|
|
44
|
+
const grouped: { label: string; chats: SvedaChatHistory[] }[] = [];
|
|
45
|
+
const indexByLabel = new Map<string, number>();
|
|
46
|
+
for (const chat of filtered) {
|
|
47
|
+
const diff = dayDiff(chat.updatedAt);
|
|
48
|
+
const label =
|
|
49
|
+
diff === 0 ? t('today') : diff === 1 ? t('yesterday') : diff === 2 ? t('dayBeforeYesterday') : t('daysAgo', { count: diff });
|
|
50
|
+
const index = indexByLabel.get(label);
|
|
51
|
+
if (index === undefined) {
|
|
52
|
+
indexByLabel.set(label, grouped.length);
|
|
53
|
+
grouped.push({ label, chats: [chat] });
|
|
54
|
+
} else {
|
|
55
|
+
grouped[index].chats.push(chat);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return grouped;
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div class="flex h-full min-h-0 w-full flex-col bg-background">
|
|
63
|
+
<div class="shrink-0 border-b border-border p-3">
|
|
64
|
+
<div class="mb-3 flex items-center justify-between">
|
|
65
|
+
<p class="text-sm font-semibold">{t('chatHistory')}</p>
|
|
66
|
+
</div>
|
|
67
|
+
<div class="flex h-10 items-center gap-2 rounded-[var(--sveda-radius)] border border-border bg-input px-3">
|
|
68
|
+
<Search class="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden="true" />
|
|
69
|
+
<input
|
|
70
|
+
bind:value={searchQuery}
|
|
71
|
+
type="text"
|
|
72
|
+
autocomplete="off"
|
|
73
|
+
placeholder={t('searchChats')}
|
|
74
|
+
class="h-full min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-card-foreground outline-none placeholder:text-muted-foreground"
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="min-h-0 flex-1 overflow-y-auto p-2">
|
|
79
|
+
{#if groups.length === 0}
|
|
80
|
+
<div class="px-2 py-6 text-center text-sm text-muted-foreground">{t('noChatsFound')}</div>
|
|
81
|
+
{:else}
|
|
82
|
+
{#each groups as group (group.label)}
|
|
83
|
+
<div class="mb-3 last:mb-1">
|
|
84
|
+
<p class="px-2 pb-1 text-xs font-medium uppercase tracking-wide text-muted-foreground">{group.label}</p>
|
|
85
|
+
{#each group.chats as item (item.id)}
|
|
86
|
+
<div
|
|
87
|
+
role="button"
|
|
88
|
+
tabindex="0"
|
|
89
|
+
class="group relative cursor-pointer px-2 py-2 transition-colors hover:bg-muted {currentChatId === item.id ? 'bg-primary/10' : ''}"
|
|
90
|
+
onclick={() => onSelectChat(item.id)}
|
|
91
|
+
onkeydown={(event) => {
|
|
92
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
onSelectChat(item.id);
|
|
95
|
+
}
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
<div class="flex items-start justify-between gap-2">
|
|
99
|
+
<div class="min-w-0 flex-1">
|
|
100
|
+
<p class="truncate text-sm font-medium">{item.title}</p>
|
|
101
|
+
<p class="truncate text-xs text-muted-foreground">{previewFor(item)}</p>
|
|
102
|
+
</div>
|
|
103
|
+
<div class="flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100">
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
class="inline-flex h-6 w-6 items-center justify-center"
|
|
107
|
+
aria-label={t('renameChat')}
|
|
108
|
+
onclick={(event) => {
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
onRenameChat(item.id);
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
<SquarePen class="h-3 w-3" />
|
|
114
|
+
</button>
|
|
115
|
+
<button
|
|
116
|
+
type="button"
|
|
117
|
+
class="inline-flex h-6 w-6 items-center justify-center"
|
|
118
|
+
aria-label={t('delete')}
|
|
119
|
+
onclick={(event) => {
|
|
120
|
+
event.stopPropagation();
|
|
121
|
+
onDeleteChat(item.id);
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
<Trash2 class="h-3 w-3" />
|
|
125
|
+
</button>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
{/each}
|
|
130
|
+
</div>
|
|
131
|
+
{/each}
|
|
132
|
+
{/if}
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|