@doclessai/sdk 0.3.3 → 0.3.5
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/README.md +18 -14
- package/dist/chunk-IRSYXS5O.js +39 -0
- package/dist/index.cjs +14 -2
- package/dist/index.js +1 -1
- package/dist/loader.cjs +14 -2
- package/dist/loader.js +1 -1
- package/dist/loader.standalone.js +293 -0
- package/package.json +4 -2
- package/dist/chunk-QBXANVZR.js +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doclessai/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Plug-and-play AI assistants infrastructure as a service.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
|
-
"build": "tsup src/index.ts src/loader.ts --format cjs,esm --dts --clean --minify",
|
|
29
|
+
"build": "tsup src/index.ts src/loader.ts --format cjs,esm --dts --clean --minify && node build-standalone.mjs",
|
|
30
30
|
"dev": "tsup src/index.ts src/loader.ts --format cjs,esm --watch --dts",
|
|
31
31
|
"lint": "tsc --noEmit"
|
|
32
32
|
},
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/react": "^19.2.13",
|
|
48
48
|
"@types/react-dom": "^19.2.3",
|
|
49
|
+
"react": "^19.2.4",
|
|
50
|
+
"react-dom": "^19.2.4",
|
|
49
51
|
"tsup": "^8.0.0",
|
|
50
52
|
"typescript": "^5.0.0"
|
|
51
53
|
},
|
package/dist/chunk-QBXANVZR.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var g=class{appKey;baseUrl;constructor(s){this.appKey=s.appKey,this.baseUrl=s.baseUrl||"https://doclessai.vercel.app/api/v1"}async ask(s,p){let f=new AbortController;try{let i=new FormData;i.append("appKey",this.appKey),i.append("query",s),p&&i.append("image",p);let n=await fetch(`${this.baseUrl}/chat`,{method:"POST",signal:f.signal,headers:{"X-SDK-Name":"@doclessai/sdk","X-SDK-Version":"0.3.3"},body:i});if(!n.ok){let x=await n.json().catch(()=>({}));throw new Error(x.message||`DoclessAI Request failed with status ${n.status}`)}return await n.json()}catch(i){throw i instanceof Error&&i.name==="AbortError"?new Error("DoclessAI Error: Request timed out."):new Error(`DoclessAI Error: ${i instanceof Error?i.message:"Unknown error"}`)}}};import{useState as d,useRef as z,useEffect as L,useMemo as D}from"react";import{toast as T,Toaster as W}from"react-hot-toast";import A from"react-markdown";import{jsx as e,jsxs as r}from"react/jsx-runtime";function F({name:u="Assistant",appKey:s}){let[p,f]=d(!1),[i,n]=d(""),[x,b]=d([{role:"assistant",content:"Hello! How can I help you today?"}]),[a,m]=d(!1),[y,w]=d(null),[k,v]=d(null),C=z(null),c=z(null),E=D(()=>new g({appKey:s}),[s]);L(()=>{c.current&&c.current.scrollTo({top:c.current.scrollHeight,behavior:"smooth"})},[x,a]);let S=async()=>{if(!i.trim()||a)return;let o=i.trim(),l=y;n(""),b(t=>[...t,{role:"user",content:o}]),m(!0);try{let t=await E.ask(o,l||void 0);w(null),b(h=>[...h,{role:"assistant",content:t.res,image:t.image,route:t.route,elementId:t.elementId}])}catch(t){T.error(t?.message||"Something went wrong"),n(o)}finally{m(!1)}};return r("div",{style:{fontFamily:"Inter, system-ui, sans-serif"},children:[e(W,{position:"top-center",reverseOrder:!1}),e("style",{children:`
|
|
2
|
-
@keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-5px); } }
|
|
3
|
-
@keyframes blink { 0%, 90%, 100% { opacity: 1; } 95% { opacity: 0.3; } }
|
|
4
|
-
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
|
5
|
-
|
|
6
|
-
.chat-bubble { animation: float 2s ease-in-out infinite; }
|
|
7
|
-
.robot-eye { animation: blink 3s ease-in-out infinite; }
|
|
8
|
-
|
|
9
|
-
.markdown-container {
|
|
10
|
-
word-break: break-word;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.markdown-container strong {
|
|
14
|
-
font-weight: 700;
|
|
15
|
-
color: #111827;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.markdown-container a {
|
|
19
|
-
color: #4f46e5;
|
|
20
|
-
text-decoration: underline;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.markdown-container pre {
|
|
24
|
-
white-space: pre-wrap;
|
|
25
|
-
word-wrap: break-word;
|
|
26
|
-
}
|
|
27
|
-
`}),k&&r("div",{onClick:()=>v(null),style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.8)",backdropFilter:"blur(5px)",zIndex:2e4,display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out",padding:"20px"},children:[e("button",{style:{position:"absolute",top:"20px",right:"20px",background:"#fff",border:"none",borderRadius:"50%",width:"40px",height:"40px",cursor:"pointer",fontSize:"20px"},children:"\u2715"}),e("img",{src:k,style:{maxWidth:"100%",maxHeight:"90vh",borderRadius:"8px",boxShadow:"0 0 30px rgba(0,0,0,0.5)"},alt:"Zoomed reference"})]}),!p&&e("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",style:{cursor:"pointer",position:"fixed",bottom:"20px",right:"20px",zIndex:9999,filter:"drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.15))"},onClick:()=>f(!0),children:r("g",{className:"chat-bubble",children:[e("ellipse",{cx:"30",cy:"52",rx:"15",ry:"3",fill:"#000",opacity:"0.1"}),e("path",{d:"M45 15C45 8.37258 39.6274 3 33 3H15C8.37258 3 3 8.37258 3 15V33C3 39.6274 8.37258 45 15 45H18V52L26 45H33C39.6274 45 45 39.6274 45 33V15Z",fill:"#4F46E5"}),r("g",{transform:"translate(12, 14)",children:[e("line",{x1:"12",y1:"0",x2:"12",y2:"3",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),e("circle",{cx:"12",cy:"0",r:"1.5",fill:"white"}),e("rect",{x:"6",y:"3",width:"12",height:"10",rx:"2",fill:"white"}),e("circle",{className:"robot-eye",cx:"9.5",cy:"8",r:"1.5",fill:"#4F46E5"}),e("circle",{className:"robot-eye",cx:"14.5",cy:"8",r:"1.5",fill:"#4F46E5"}),e("line",{x1:"9",y1:"11",x2:"15",y2:"11",stroke:"#4F46E5",strokeWidth:"1",strokeLinecap:"round"}),e("rect",{x:"7",y:"14",width:"10",height:"6",rx:"1",fill:"white"}),e("rect",{x:"4",y:"15",width:"2",height:"4",rx:"1",fill:"white"}),e("rect",{x:"18",y:"15",width:"2",height:"4",rx:"1",fill:"white"})]})]})}),p&&r("div",{style:{position:"fixed",bottom:"20px",right:"20px",width:"min(400px, 90vw)",height:"min(600px, 85vh)",backgroundColor:"#fff",boxShadow:"0 12px 40px rgba(79, 70, 229, 0.25)",borderRadius:"16px",display:"flex",flexDirection:"column",zIndex:1e4,overflow:"hidden",border:"1px solid #e5e7eb",animation:"fadeIn 0.2s ease-out"},children:[r("div",{style:{backgroundColor:"#4f46e5",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",color:"#fff"},children:[r("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e("div",{style:{width:"8px",height:"8px",backgroundColor:"#22c55e",borderRadius:"50%",boxShadow:"0 0 8px #22c55e"}}),e("span",{style:{fontWeight:600,fontSize:"15px"},children:u})]}),e("span",{style:{cursor:"pointer",fontSize:"18px",opacity:.8},onClick:()=>f(!1),children:"\u2715"})]}),r("div",{ref:c,style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#f9fafb"},children:[x.map((o,l)=>e("div",{style:{alignSelf:o.role==="user"?"flex-end":"flex-start",maxWidth:"85%",display:"flex",flexDirection:"column",gap:"4px"},children:r("div",{style:{backgroundColor:o.role==="user"?"#4f46e5":"#fff",color:o.role==="user"?"#fff":"#374151",padding:"12px 16px",borderRadius:"12px",fontSize:"14px",border:o.role==="user"?"none":"1px solid #e5e7eb",boxShadow:o.role==="user"?"0 2px 4px rgba(79,70,229,0.2)":"0 1px 2px rgba(0,0,0,0.05)"},children:[o.image&&e("div",{style:{marginBottom:"10px"},children:e("img",{src:o.image,onClick:()=>v(o.image),style:{width:"100%",borderRadius:"8px",cursor:"zoom-in"},alt:"Reference"})}),o.role==="assistant"?r("div",{className:"markdown-container",children:[e(A,{components:{p:({children:t})=>e("p",{style:{marginBottom:"12px",lineHeight:"1.6"},children:t}),ul:({children:t})=>e("ul",{style:{listStyleType:"disc",marginLeft:"20px",marginBottom:"12px"},children:t}),ol:({children:t})=>e("ol",{style:{listStyleType:"decimal",marginLeft:"20px",marginBottom:"12px"},children:t}),li:({children:t})=>e("li",{style:{marginBottom:"4px"},children:t}),h1:({children:t})=>e("h1",{style:{fontSize:"1.25rem",fontWeight:"bold",margin:"16px 0 8px"},children:t}),h2:({children:t})=>e("h2",{style:{fontSize:"1.1rem",fontWeight:"bold",margin:"14px 0 7px"},children:t}),h3:({children:t})=>e("h3",{style:{fontSize:"1rem",fontWeight:"bold",margin:"12px 0 6px"},children:t}),code:({node:t,inline:h,className:M,children:I,...R})=>h?e("code",{style:{backgroundColor:"#f3f4f6",padding:"2px 5px",borderRadius:"4px",fontSize:"13px",color:"#e03e2d",fontFamily:"monospace"},...R,children:I}):e("div",{style:{backgroundColor:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:"8px",padding:"12px",margin:"12px 0",overflowX:"auto"},children:e("code",{style:{fontSize:"13px",color:"#1e293b",fontFamily:"monospace",whiteSpace:"pre"},...R,children:I})}),blockquote:({children:t})=>e("blockquote",{style:{borderLeft:"4px solid #4f46e5",paddingLeft:"12px",color:"#4b5563",fontStyle:"italic",margin:"12px 0"},children:t}),table:({children:t})=>e("div",{style:{overflowX:"auto",margin:"12px 0"},children:e("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px"},children:t})}),th:({children:t})=>e("th",{style:{border:"1px solid #e5e7eb",padding:"8px",backgroundColor:"#f9fafb",textAlign:"left"},children:t}),td:({children:t})=>e("td",{style:{border:"1px solid #e5e7eb",padding:"8px"},children:t})},children:o.content}),o.route&&e("div",{style:{marginTop:"12px",borderTop:"1px solid #f3f4f6",paddingTop:"10px"},children:r("button",{onClick:()=>{window.location.href=o.route},style:{display:"inline-flex",alignItems:"center",gap:"6px",backgroundColor:"#4f46e5",color:"white",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"none",cursor:"pointer",transition:"background 0.2s"},onMouseOver:t=>t.currentTarget.style.backgroundColor="#4338ca",onMouseOut:t=>t.currentTarget.style.backgroundColor="#4f46e5",children:["Explore Page",r("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e("line",{x1:"7",y1:"17",x2:"17",y2:"7"}),e("polyline",{points:"7 7 17 7 17 17"})]})]})})]}):e("div",{style:{whiteSpace:"pre-wrap"},children:o.content})]})},l)),e("div",{ref:c}),a&&r("div",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"4px"},children:[u," is thinking..."]})]}),r("div",{style:{padding:"16px",borderTop:"1px solid #e5e7eb",backgroundColor:"#fff"},children:[r("div",{style:{display:"flex",alignItems:"center",gap:"10px",backgroundColor:"#f3f4f6",padding:"6px 14px",borderRadius:"28px"},children:[r("button",{style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex"},onClick:()=>C.current?.click(),children:[r("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e("polyline",{points:"21 15 16 10 5 21"})]}),e("input",{type:"file",accept:"image/*",ref:C,style:{display:"none"},onChange:o=>{let l=o.target.files?.[0];l&&(w(l),T.success(`Attached: ${l.name}`))}})]}),y&&r("div",{style:{fontSize:"11px",color:"#4f46e5",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["\u{1F4CE} ",y.name]}),e("input",{type:"text",value:i,onChange:o=>n(o.target.value),onKeyDown:o=>o.key==="Enter"&&S(),placeholder:"Type a message...",style:{flex:1,border:"none",background:"none",padding:"10px 0",outline:"none",fontSize:"14px",color:"#1f2937"}}),e("button",{onClick:S,disabled:!i.trim()||a,style:{background:i.trim()&&!a?"#4f46e5":"transparent",border:"none",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:i.trim()&&!a?"pointer":"default",transition:"all 0.2s"},children:r("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:i.trim()&&!a?"#fff":"#9ca3af",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),e("polyline",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),r("div",{style:{textAlign:"center",fontSize:"11px",color:"#9ca3af",marginTop:"10px"},children:["Powered by ",e("strong",{children:"DoclessAI"})]})]})]})]})}export{g as a,F as b};
|