lumely-react 0.1.0 → 0.1.2

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 CHANGED
@@ -1,17 +1,17 @@
1
- # @lumely/react
1
+ # lumely-react
2
2
 
3
3
  AI-powered error handling for React applications. Automatically catches errors, explains them to users in plain language, and provides developers with AI-generated fix suggestions.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @lumely/react
8
+ npm install lumely-react
9
9
  ```
10
10
 
11
11
  ## Quick Start
12
12
 
13
13
  ```tsx
14
- import { LumelyProvider } from '@lumely/react';
14
+ import { LumelyProvider } from 'lumely-react';
15
15
 
16
16
  function App() {
17
17
  return (
@@ -25,34 +25,38 @@ function App() {
25
25
  }
26
26
  ```
27
27
 
28
- That's it! Lumely will automatically catch errors and display a user-friendly overlay.
28
+ That's it. Lumely will automatically catch errors and display a user-friendly overlay.
29
29
 
30
30
  ## Features
31
31
 
32
- - **🤖 AI-Powered Explanations** - Errors are explained in plain language
33
- - **📝 User Feedback** - Collect context about what users were doing
34
- - **🎨 Beautiful Glassmorphism UI** - Modern, customizable overlay
35
- - **⚡ Fast** - User message appears in ~2s, detailed analysis runs in background
36
- - **🔒 Secure** - API keys stay on your server
32
+ - **AI-Powered Explanations** - Errors are explained in plain language
33
+ - **User Feedback** - Collect context about what users were doing
34
+ - **Modern Glassmorphism UI** - Beautiful, customizable overlay
35
+ - **Fast Response** - User message appears in ~2s, detailed analysis runs in background
36
+ - **Secure** - API keys stay on your server
37
37
 
38
38
  ## Props
39
39
 
40
40
  | Prop | Type | Required | Description |
41
41
  |------|------|----------|-------------|
42
- | `apiKey` | `string` | | Your Lumely API key |
43
- | `apiEndpoint` | `string` | | URL to your Lumely API |
44
- | `environment` | `'development' \| 'production'` | | Environment name |
45
- | `userId` | `string` | | Current user's ID |
46
- | `sessionId` | `string` | | Session ID (auto-generated if not provided) |
47
- | `onError` | `(report) => void` | | Callback when error is caught |
42
+ | `apiKey` | `string` | Yes | Your Lumely API key |
43
+ | `apiEndpoint` | `string` | Yes | URL to your Lumely API |
44
+ | `environment` | `'development' \| 'production'` | No | Environment name |
45
+ | `userId` | `string` | No | Current user's ID |
46
+ | `sessionId` | `string` | No | Session ID (auto-generated if not provided) |
47
+ | `onError` | `(report) => void` | No | Callback when error is caught |
48
48
 
49
49
  ## How It Works
50
50
 
51
- 1. **Error Caught** React Error Boundary catches the crash
52
- 2. **Reported** Error details sent to your Lumely API
53
- 3. **AI Analysis** Gemini analyzes and generates user-friendly message
54
- 4. **Overlay Shown** User sees explanation + can provide feedback
55
- 5. **Saved** Everything stored in your database
51
+ 1. **Error Caught** - React Error Boundary catches the crash
52
+ 2. **Reported** - Error details sent to your Lumely API
53
+ 3. **AI Analysis** - Gemini analyzes and generates user-friendly message
54
+ 4. **Overlay Shown** - User sees explanation and can provide feedback
55
+ 5. **Saved** - Everything stored in your database
56
+
57
+ ## Documentation
58
+
59
+ Visit [lumely.vercel.app](https://lumely.vercel.app) for full documentation.
56
60
 
57
61
  ## License
58
62
 
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var u=class{constructor(r,e){this.apiKey=r,this.apiEndpoint=e;}async reportError(r){try{let e=await fetch(`${this.apiEndpoint}/report-error`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify(r)});if(e.ok)return await e.json();throw new Error("Failed to report error")}catch(e){return console.error("Lumely: Failed to report error",e),{success:false,ai:{userMessage:"Something went wrong. We're looking into it.",summary:"",suggestedFix:""},errorId:"client-error"}}}async updateFeedback(r,e){try{return (await fetch(`${this.apiEndpoint}/update-feedback`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify({errorId:r,feedback:e})})).ok}catch(n){return console.error("Lumely: Failed to update feedback",n),false}}};var b=react.createContext(null),I=()=>{if(typeof window=="undefined")return "server";let o=sessionStorage.getItem("lumely_session_id");if(o)return o;let r=`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;return sessionStorage.setItem("lumely_session_id",r),r},w=()=>{let o=react.useContext(b);if(!o)throw new Error("useLumely must be used within a LumelyProvider");return o},x=({children:o,config:r})=>{let e=react.useMemo(()=>{let n=r.sessionId||I(),s=new u(r.apiKey,r.apiEndpoint);return {...r,sessionId:n,environment:r.environment||"production",client:s}},[r]);return jsxRuntime.jsx(b.Provider,{value:e,children:o})};var B=()=>{if(typeof document=="undefined"||document.getElementById("lumely-react-styles"))return;let o=document.createElement("style");o.id="lumely-react-styles",o.textContent=`
1
+ 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var u=class{constructor(o,t){this.apiKey=o,this.apiEndpoint=t;}async reportError(o){try{let t=await fetch(`${this.apiEndpoint}/report-error`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify(o)});if(t.ok)return await t.json();throw new Error("Failed to report error")}catch(t){return console.error("Lumely: Failed to report error",t),{success:false,ai:{userMessage:"Something went wrong. We're looking into it.",summary:"",suggestedFix:""},errorId:"client-error"}}}async updateFeedback(o,t){try{return (await fetch(`${this.apiEndpoint}/update-feedback`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify({errorId:o,feedback:t})})).ok}catch(n){return console.error("Lumely: Failed to update feedback",n),false}}};var b=react.createContext(null),R=()=>{if(typeof window=="undefined")return "server";let i=sessionStorage.getItem("lumely_session_id");if(i)return i;let o=`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;return sessionStorage.setItem("lumely_session_id",o),o},C=()=>{let i=react.useContext(b);if(!i)throw new Error("useLumely must be used within a LumelyProvider");return i},h=({children:i,config:o})=>{let t=react.useMemo(()=>{let n=o.sessionId||R(),s=new u(o.apiKey,o.apiEndpoint);return {...o,sessionId:n,environment:o.environment||"production",client:s}},[o]);return jsxRuntime.jsx(b.Provider,{value:t,children:i})};var B=()=>{if(typeof document=="undefined"||document.getElementById("lumely-react-styles"))return;let i=document.createElement("style");i.id="lumely-react-styles",i.textContent=`
2
2
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
3
3
  @keyframes lumely-spin {
4
4
  from { transform: rotate(0deg); }
5
5
  to { transform: rotate(360deg); }
6
6
  }
7
- `,document.head.appendChild(o);},t={overlay:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(8px)",fontFamily:"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},card:{position:"relative",width:"100%",maxWidth:"400px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(20px)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"16px",overflow:"hidden"},closeButton:{position:"absolute",top:"12px",right:"12px",padding:"6px",color:"rgba(255, 255, 255, 0.6)",background:"transparent",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"18px"},content:{padding:"24px"},header:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},logo:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #7c3aed, #8b5cf6)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:700,fontSize:"18px"},title:{color:"white",fontWeight:600,fontSize:"14px",margin:0},subtitle:{color:"rgba(255, 255, 255, 0.5)",fontSize:"12px",margin:0},messageBox:{background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"16px",marginBottom:"16px"},message:{color:"rgba(255, 255, 255, 0.9)",fontSize:"14px",lineHeight:1.6,margin:0},loading:{display:"flex",alignItems:"center",gap:"8px",color:"rgba(255, 255, 255, 0.7)",fontSize:"14px",padding:"16px 0"},spinner:{width:"16px",height:"16px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"lumely-spin 1s linear infinite"},form:{marginBottom:"16px"},label:{display:"block",color:"rgba(255, 255, 255, 0.6)",fontSize:"12px",marginBottom:"8px"},inputWrapper:{position:"relative"},input:{width:"100%",background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"12px 48px 12px 16px",color:"white",fontSize:"14px",outline:"none",boxSizing:"border-box"},submitButton:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",padding:"8px",color:"rgba(255, 255, 255, 0.4)",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px"},successBox:{background:"rgba(34, 197, 94, 0.1)",border:"1px solid rgba(34, 197, 94, 0.2)",borderRadius:"12px",padding:"12px",marginBottom:"16px"},successText:{color:"#4ade80",fontSize:"12px",textAlign:"center",margin:0},buttons:{display:"flex",gap:"8px"},button:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"10px 16px",borderRadius:"12px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none",transition:"all 0.2s"},secondaryButton:{background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",color:"rgba(255, 255, 255, 0.8)"},primaryButton:{background:"#7c3aed",color:"white"}},g=({aiResponse:o,isLoading:r,feedbackSubmitted:e=false,onSubmitFeedback:n,onRetry:s,onDismiss:p,onGoBack:l})=>{let[a,m]=react.useState(""),[f,L]=react.useState(false);react.useEffect(()=>{B();},[]);let S=y=>{y.preventDefault(),a.trim()&&!f&&(L(true),n(a));};return jsxRuntime.jsx("div",{style:t.overlay,children:jsxRuntime.jsxs("div",{style:t.card,children:[jsxRuntime.jsx("button",{style:t.closeButton,onClick:p,children:"\u2715"}),jsxRuntime.jsxs("div",{style:t.content,children:[jsxRuntime.jsxs("div",{style:t.header,children:[jsxRuntime.jsx("div",{style:t.logo,children:"L"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{style:t.title,children:"Something went wrong"}),jsxRuntime.jsx("p",{style:t.subtitle,children:"We're looking into it"})]})]}),r?jsxRuntime.jsxs("div",{style:t.loading,children:[jsxRuntime.jsx("div",{style:t.spinner}),jsxRuntime.jsx("span",{children:"Analyzing the issue..."})]}):jsxRuntime.jsx("div",{style:t.messageBox,children:jsxRuntime.jsx("p",{style:t.message,children:(o==null?void 0:o.userMessage)||"We encountered an unexpected issue. Our team has been notified."})}),!e&&!f?jsxRuntime.jsxs("form",{style:t.form,onSubmit:S,children:[jsxRuntime.jsx("label",{style:t.label,children:"What were you trying to do?"}),jsxRuntime.jsxs("div",{style:t.inputWrapper,children:[jsxRuntime.jsx("input",{type:"text",value:a,onChange:y=>m(y.target.value),placeholder:"e.g., I was trying to save my changes...",style:t.input}),jsxRuntime.jsx("button",{type:"submit",disabled:!a.trim(),style:{...t.submitButton,opacity:a.trim()?1:.3},children:"\u27A4"})]})]}):jsxRuntime.jsx("div",{style:t.successBox,children:jsxRuntime.jsx("p",{style:t.successText,children:"Thank you! Your feedback helps us improve."})}),jsxRuntime.jsxs("div",{style:t.buttons,children:[jsxRuntime.jsx("button",{style:{...t.button,...t.secondaryButton},onClick:l,children:"\u2190 Go Back"}),jsxRuntime.jsx("button",{style:{...t.button,...t.primaryButton},onClick:s,children:"\u21BB Try Again"})]})]})]})})};var c=class extends react.Component{constructor(e){super(e);this.isReporting=false;this.handleSubmitFeedback=async e=>{let{errorId:n}=this.state,{client:s}=this.props;if(!n||n==="client-error"){this.setState({feedbackSubmitted:true});return}await s.updateFeedback(n,e),this.setState({feedbackSubmitted:true});};this.handleRetry=()=>{this.isReporting=false,this.setState({hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false});};this.handleDismiss=()=>{this.isReporting=false,this.setState({hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false});};this.handleGoBack=()=>{typeof window!="undefined"&&window.history.back();};this.state={hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false};}static getDerivedStateFromError(e){return {hasError:true,error:e}}componentDidCatch(e,n){this.isReporting||(this.isReporting=true,this.setState({errorInfo:n,isLoading:true}),this.reportError(e,n));}async reportError(e,n){let{config:s,client:p}=this.props,l={errorMessage:e.message,errorStack:e.stack,componentStack:n.componentStack||void 0,context:{url:typeof window!="undefined"?window.location.href:"",userAgent:typeof navigator!="undefined"?navigator.userAgent:"",userId:s.userId,sessionId:s.sessionId,timestamp:new Date().toISOString()}},a=await p.reportError(l);this.setState({aiResponse:a.ai,errorId:a.errorId,isLoading:false}),s.onError&&s.onError(l);}render(){let{hasError:e,aiResponse:n,isLoading:s,feedbackSubmitted:p}=this.state,{children:l}=this.props;return e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l,jsxRuntime.jsx(g,{aiResponse:n||void 0,isLoading:s,feedbackSubmitted:p,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):l}};var W=({children:o,apiKey:r,apiEndpoint:e,environment:n="production",userId:s,sessionId:p,onError:l})=>{let a={apiKey:r,apiEndpoint:e,environment:n,userId:s,sessionId:p,onError:l},m=new u(r,e);return jsxRuntime.jsx(x,{config:a,children:jsxRuntime.jsx(c,{config:a,client:m,children:o})})};exports.LumelyClient=u;exports.LumelyErrorBoundary=c;exports.LumelyErrorOverlay=g;exports.LumelyProvider=W;exports.useLumely=w;//# sourceMappingURL=index.js.map
7
+ `,document.head.appendChild(i);},F=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),A=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),jsxRuntime.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),W=()=>jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"19",y1:"12",x2:"5",y2:"12"}),jsxRuntime.jsx("polyline",{points:"12 19 5 12 12 5"})]}),z=()=>jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("polyline",{points:"23 4 23 10 17 10"}),jsxRuntime.jsx("polyline",{points:"1 20 1 14 7 14"}),jsxRuntime.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),r={overlay:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(8px)",fontFamily:"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},card:{position:"relative",width:"100%",maxWidth:"448px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"16px",overflow:"hidden"},closeButton:{position:"absolute",top:"12px",right:"12px",padding:"6px",color:"rgba(255, 255, 255, 0.6)",background:"transparent",border:"none",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"},content:{padding:"24px"},header:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},logo:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #7c3aed, #8b5cf6)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:700,fontSize:"18px"},title:{color:"white",fontWeight:600,fontSize:"14px",margin:0},subtitle:{color:"rgba(255, 255, 255, 0.5)",fontSize:"12px",margin:0},messageBox:{background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"16px",marginBottom:"16px"},message:{color:"rgba(255, 255, 255, 0.9)",fontSize:"14px",lineHeight:1.6,margin:0},loading:{display:"flex",alignItems:"center",gap:"8px",color:"rgba(255, 255, 255, 0.7)",fontSize:"14px",padding:"16px 0"},spinner:{width:"16px",height:"16px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"lumely-spin 1s linear infinite"},form:{marginBottom:"16px"},label:{display:"block",color:"rgba(255, 255, 255, 0.6)",fontSize:"12px",marginBottom:"8px"},inputWrapper:{position:"relative"},input:{width:"100%",background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"12px 48px 12px 16px",color:"white",fontSize:"14px",outline:"none",boxSizing:"border-box",transition:"border-color 0.2s"},submitButton:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",padding:"8px",color:"rgba(255, 255, 255, 0.4)",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s"},successBox:{background:"rgba(34, 197, 94, 0.1)",border:"1px solid rgba(34, 197, 94, 0.2)",borderRadius:"12px",padding:"12px",marginBottom:"16px"},successText:{color:"#4ade80",fontSize:"12px",textAlign:"center",margin:0},buttons:{display:"flex",gap:"8px"},button:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"10px 16px",borderRadius:"12px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none",transition:"all 0.2s"},secondaryButton:{background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",color:"rgba(255, 255, 255, 0.8)"},primaryButton:{background:"#7c3aed",color:"white"}},g=({aiResponse:i,isLoading:o,feedbackSubmitted:t=false,onSubmitFeedback:n,onRetry:s,onDismiss:p,onGoBack:d})=>{let[l,m]=react.useState(""),[f,L]=react.useState(false);react.useEffect(()=>{B();},[]);let k=y=>{y.preventDefault(),l.trim()&&!f&&(L(true),n(l));};return jsxRuntime.jsx("div",{style:r.overlay,children:jsxRuntime.jsxs("div",{style:r.card,children:[jsxRuntime.jsx("button",{style:r.closeButton,onClick:p,children:jsxRuntime.jsx(F,{})}),jsxRuntime.jsxs("div",{style:r.content,children:[jsxRuntime.jsxs("div",{style:r.header,children:[jsxRuntime.jsx("div",{style:r.logo,children:"L"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{style:r.title,children:"Something went wrong"}),jsxRuntime.jsx("p",{style:r.subtitle,children:"We're looking into it"})]})]}),o?jsxRuntime.jsxs("div",{style:r.loading,children:[jsxRuntime.jsx("div",{style:r.spinner}),jsxRuntime.jsx("span",{children:"Analyzing the issue..."})]}):i?jsxRuntime.jsx("div",{style:r.messageBox,children:jsxRuntime.jsx("p",{style:r.message,children:i.userMessage})}):jsxRuntime.jsx("div",{style:r.messageBox,children:jsxRuntime.jsx("p",{style:r.message,children:"We encountered an unexpected issue. Our team has been notified."})}),!t&&!f?jsxRuntime.jsxs("form",{style:r.form,onSubmit:k,children:[jsxRuntime.jsx("label",{style:r.label,children:"What were you trying to do?"}),jsxRuntime.jsxs("div",{style:r.inputWrapper,children:[jsxRuntime.jsx("input",{type:"text",value:l,onChange:y=>m(y.target.value),placeholder:"e.g., I was trying to save my changes...",style:r.input}),jsxRuntime.jsx("button",{type:"submit",disabled:!l.trim(),style:{...r.submitButton,opacity:l.trim()?1:.3},children:jsxRuntime.jsx(A,{})})]})]}):jsxRuntime.jsx("div",{style:r.successBox,children:jsxRuntime.jsx("p",{style:r.successText,children:"Thank you! Your feedback helps us improve."})}),jsxRuntime.jsxs("div",{style:r.buttons,children:[jsxRuntime.jsxs("button",{style:{...r.button,...r.secondaryButton},onClick:d,children:[jsxRuntime.jsx(W,{}),"Go Back"]}),jsxRuntime.jsxs("button",{style:{...r.button,...r.primaryButton},onClick:s,children:[jsxRuntime.jsx(z,{}),"Try Again"]})]})]})]})})};var c=class extends react.Component{constructor(t){super(t);this.isReporting=false;this.handleSubmitFeedback=async t=>{let{errorId:n}=this.state,{client:s}=this.props;if(!n||n==="client-error"){this.setState({feedbackSubmitted:true});return}await s.updateFeedback(n,t),this.setState({feedbackSubmitted:true});};this.handleRetry=()=>{this.isReporting=false,this.setState({hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false});};this.handleDismiss=()=>{this.isReporting=false,this.setState({hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false});};this.handleGoBack=()=>{typeof window!="undefined"&&window.history.back();};this.state={hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,n){this.isReporting||(this.isReporting=true,this.setState({errorInfo:n,isLoading:true}),this.reportError(t,n));}async reportError(t,n){let{config:s,client:p}=this.props,d={errorMessage:t.message,errorStack:t.stack,componentStack:n.componentStack||void 0,context:{url:typeof window!="undefined"?window.location.href:"",userAgent:typeof navigator!="undefined"?navigator.userAgent:"",userId:s.userId,sessionId:s.sessionId,timestamp:new Date().toISOString()}},l=await p.reportError(d);this.setState({aiResponse:l.ai,errorId:l.errorId,isLoading:false}),s.onError&&s.onError(d);}render(){let{hasError:t,aiResponse:n,isLoading:s,feedbackSubmitted:p}=this.state,{children:d}=this.props;return t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[d,jsxRuntime.jsx(g,{aiResponse:n||void 0,isLoading:s,feedbackSubmitted:p,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):d}};var M=({children:i,apiKey:o,apiEndpoint:t,environment:n="production",userId:s,sessionId:p,onError:d})=>{let l={apiKey:o,apiEndpoint:t,environment:n,userId:s,sessionId:p,onError:d},m=new u(o,t);return jsxRuntime.jsx(h,{config:l,children:jsxRuntime.jsx(c,{config:l,client:m,children:i})})};exports.LumelyClient=u;exports.LumelyErrorBoundary=c;exports.LumelyErrorOverlay=g;exports.LumelyProvider=M;exports.useLumely=C;//# sourceMappingURL=index.js.map
8
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../LumelyClient.ts","../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyClient","apiKey","apiEndpoint","report","response","err","errorId","feedback","LumelyContext","createContext","generateSessionId","stored","newId","useLumely","context","useContext","LumelyContextProvider","children","config","value","useMemo","sessionId","client","jsx","injectStyles","style","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","setFeedback","useState","isSubmitting","setIsSubmitting","useEffect","handleSubmit","e","jsxs","LumelyErrorBoundary","Component","props","error","errorInfo","hasError","Fragment","LumelyProvider","environment","userId","onError"],"mappings":"gFAEO,IAAMA,CAAAA,CAAN,KAAmB,CAItB,WAAA,CAAYC,CAAAA,CAAgBC,CAAAA,CAAqB,CAC7C,IAAA,CAAK,MAAA,CAASD,CAAAA,CACd,IAAA,CAAK,YAAcC,EACvB,CAEA,MAAM,WAAA,CAAYC,EAAuD,CACrE,GAAI,CACA,IAAMC,EAAW,MAAM,KAAA,CAAM,CAAA,EAAG,IAAA,CAAK,WAAW,CAAA,aAAA,CAAA,CAAiB,CAC7D,MAAA,CAAQ,MAAA,CACR,OAAA,CAAS,CACL,cAAA,CAAgB,kBAAA,CAChB,eAAgB,IAAA,CAAK,MACzB,CAAA,CACA,IAAA,CAAM,KAAK,SAAA,CAAUD,CAAM,CAC/B,CA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,CAAQE,CAAAA,CAC3B,QAAA,CAAAK,cAAAA,CAACoB,CAAAA,CAAA,CAAoB,MAAA,CAAQzB,CAAAA,CAAQ,MAAA,CAAQI,CAAAA,CACxC,QAAA,CAAAL,CAAAA,CACL,CAAA,CACJ,CAER","file":"index.js","sourcesContent":["import type { LumelyErrorReport, LumelyAPIResponse } from './types';\r\n\r\nexport class LumelyClient {\r\n private apiKey: string;\r\n private apiEndpoint: string;\r\n\r\n constructor(apiKey: string, apiEndpoint: string) {\r\n this.apiKey = apiKey;\r\n this.apiEndpoint = apiEndpoint;\r\n }\r\n\r\n async reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/report-error`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n return await response.json();\r\n }\r\n\r\n throw new Error('Failed to report error');\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n return {\r\n success: false,\r\n ai: {\r\n userMessage: \"Something went wrong. We're looking into it.\",\r\n summary: '',\r\n suggestedFix: '',\r\n },\r\n errorId: 'client-error',\r\n };\r\n }\r\n }\r\n\r\n async updateFeedback(errorId: string, feedback: string): Promise<boolean> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n return response.ok;\r\n } catch (err) {\r\n console.error('Lumely: Failed to update feedback', err);\r\n return false;\r\n }\r\n }\r\n}\r\n","import React, { createContext, useContext, useMemo } from 'react';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n client: LumelyClient;\r\n sessionId: string;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\nconst generateSessionId = () => {\r\n if (typeof window === 'undefined') return 'server';\r\n const stored = sessionStorage.getItem('lumely_session_id');\r\n if (stored) return stored;\r\n const newId = `sess_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\r\n sessionStorage.setItem('lumely_session_id', newId);\r\n return newId;\r\n};\r\n\r\nexport const useLumely = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumely must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\ninterface LumelyContextProviderProps {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n}\r\n\r\nexport const LumelyContextProvider = ({ children, config }: LumelyContextProviderProps) => {\r\n const value = useMemo(() => {\r\n const sessionId = config.sessionId || generateSessionId();\r\n const client = new LumelyClient(config.apiKey, config.apiEndpoint);\r\n\r\n return {\r\n ...config,\r\n sessionId,\r\n environment: config.environment || 'production',\r\n client,\r\n };\r\n }, [config]);\r\n\r\n return (\r\n <LumelyContext.Provider value={value}>\r\n {children}\r\n </LumelyContext.Provider>\r\n );\r\n};\r\n","import React, { useState, useEffect } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Inject Poppins font and keyframes\r\nconst injectStyles = () => {\r\n if (typeof document === 'undefined') return;\r\n if (document.getElementById('lumely-react-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-react-styles';\r\n style.textContent = `\r\n @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');\r\n @keyframes lumely-spin {\r\n from { transform: rotate(0deg); }\r\n to { transform: rotate(360deg); }\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n};\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n overlay: {\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 9999,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: '16px',\r\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\r\n backdropFilter: 'blur(8px)',\r\n fontFamily: \"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\r\n },\r\n card: {\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: '400px',\r\n background: 'rgba(255, 255, 255, 0.1)',\r\n backdropFilter: 'blur(20px)',\r\n border: '1px solid rgba(255, 255, 255, 0.2)',\r\n borderRadius: '16px',\r\n overflow: 'hidden',\r\n },\r\n closeButton: {\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n padding: '6px',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n background: 'transparent',\r\n border: 'none',\r\n borderRadius: '8px',\r\n cursor: 'pointer',\r\n fontSize: '18px',\r\n },\r\n content: {\r\n padding: '24px',\r\n },\r\n header: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '12px',\r\n marginBottom: '16px',\r\n },\r\n logo: {\r\n width: '40px',\r\n height: '40px',\r\n borderRadius: '12px',\r\n background: 'linear-gradient(135deg, #7c3aed, #8b5cf6)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n color: 'white',\r\n fontWeight: 700,\r\n fontSize: '18px',\r\n },\r\n title: {\r\n color: 'white',\r\n fontWeight: 600,\r\n fontSize: '14px',\r\n margin: 0,\r\n },\r\n subtitle: {\r\n color: 'rgba(255, 255, 255, 0.5)',\r\n fontSize: '12px',\r\n margin: 0,\r\n },\r\n messageBox: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '16px',\r\n marginBottom: '16px',\r\n },\r\n message: {\r\n color: 'rgba(255, 255, 255, 0.9)',\r\n fontSize: '14px',\r\n lineHeight: 1.6,\r\n margin: 0,\r\n },\r\n loading: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'rgba(255, 255, 255, 0.7)',\r\n fontSize: '14px',\r\n padding: '16px 0',\r\n },\r\n spinner: {\r\n width: '16px',\r\n height: '16px',\r\n border: '2px solid rgba(255, 255, 255, 0.3)',\r\n borderTopColor: 'white',\r\n borderRadius: '50%',\r\n animation: 'lumely-spin 1s linear infinite',\r\n },\r\n form: {\r\n marginBottom: '16px',\r\n },\r\n label: {\r\n display: 'block',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n fontSize: '12px',\r\n marginBottom: '8px',\r\n },\r\n inputWrapper: {\r\n position: 'relative',\r\n },\r\n input: {\r\n width: '100%',\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '12px 48px 12px 16px',\r\n color: 'white',\r\n fontSize: '14px',\r\n outline: 'none',\r\n boxSizing: 'border-box',\r\n },\r\n submitButton: {\r\n position: 'absolute',\r\n right: '8px',\r\n top: '50%',\r\n transform: 'translateY(-50%)',\r\n padding: '8px',\r\n color: 'rgba(255, 255, 255, 0.4)',\r\n background: 'transparent',\r\n border: 'none',\r\n cursor: 'pointer',\r\n fontSize: '16px',\r\n },\r\n successBox: {\r\n background: 'rgba(34, 197, 94, 0.1)',\r\n border: '1px solid rgba(34, 197, 94, 0.2)',\r\n borderRadius: '12px',\r\n padding: '12px',\r\n marginBottom: '16px',\r\n },\r\n successText: {\r\n color: '#4ade80',\r\n fontSize: '12px',\r\n textAlign: 'center',\r\n margin: 0,\r\n },\r\n buttons: {\r\n display: 'flex',\r\n gap: '8px',\r\n },\r\n button: {\r\n flex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n gap: '8px',\r\n padding: '10px 16px',\r\n borderRadius: '12px',\r\n fontSize: '14px',\r\n fontWeight: 500,\r\n cursor: 'pointer',\r\n border: 'none',\r\n transition: 'all 0.2s',\r\n },\r\n secondaryButton: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n color: 'rgba(255, 255, 255, 0.8)',\r\n },\r\n primaryButton: {\r\n background: '#7c3aed',\r\n color: 'white',\r\n },\r\n};\r\n\r\ninterface LumelyErrorOverlayProps {\r\n aiResponse?: LumelyAIResponse;\r\n isLoading: boolean;\r\n feedbackSubmitted?: boolean;\r\n onSubmitFeedback: (feedback: string) => void;\r\n onRetry: () => void;\r\n onDismiss: () => void;\r\n onGoBack: () => void;\r\n}\r\n\r\nexport const LumelyErrorOverlay = ({\r\n aiResponse,\r\n isLoading,\r\n feedbackSubmitted = false,\r\n onSubmitFeedback,\r\n onRetry,\r\n onDismiss,\r\n onGoBack,\r\n}: LumelyErrorOverlayProps) => {\r\n const [feedback, setFeedback] = useState('');\r\n const [isSubmitting, setIsSubmitting] = useState(false);\r\n\r\n useEffect(() => {\r\n injectStyles();\r\n }, []);\r\n\r\n const handleSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n if (feedback.trim() && !isSubmitting) {\r\n setIsSubmitting(true);\r\n onSubmitFeedback(feedback);\r\n }\r\n };\r\n\r\n return (\r\n <div style={styles.overlay}>\r\n <div style={styles.card}>\r\n <button style={styles.closeButton} onClick={onDismiss}>✕</button>\r\n\r\n <div style={styles.content}>\r\n <div style={styles.header}>\r\n <div style={styles.logo}>L</div>\r\n <div>\r\n <h3 style={styles.title}>Something went wrong</h3>\r\n <p style={styles.subtitle}>We're looking into it</p>\r\n </div>\r\n </div>\r\n\r\n {isLoading ? (\r\n <div style={styles.loading}>\r\n <div style={styles.spinner} />\r\n <span>Analyzing the issue...</span>\r\n </div>\r\n ) : (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>\r\n {aiResponse?.userMessage || \"We encountered an unexpected issue. Our team has been notified.\"}\r\n </p>\r\n </div>\r\n )}\r\n\r\n {!feedbackSubmitted && !isSubmitting ? (\r\n <form style={styles.form} onSubmit={handleSubmit}>\r\n <label style={styles.label}>What were you trying to do?</label>\r\n <div style={styles.inputWrapper}>\r\n <input\r\n type=\"text\"\r\n value={feedback}\r\n onChange={(e) => setFeedback(e.target.value)}\r\n placeholder=\"e.g., I was trying to save my changes...\"\r\n style={styles.input}\r\n />\r\n <button\r\n type=\"submit\"\r\n disabled={!feedback.trim()}\r\n style={{ ...styles.submitButton, opacity: feedback.trim() ? 1 : 0.3 }}\r\n >\r\n ➤\r\n </button>\r\n </div>\r\n </form>\r\n ) : (\r\n <div style={styles.successBox}>\r\n <p style={styles.successText}>Thank you! Your feedback helps us improve.</p>\r\n </div>\r\n )}\r\n\r\n <div style={styles.buttons}>\r\n <button style={{ ...styles.button, ...styles.secondaryButton }} onClick={onGoBack}>\r\n ← Go Back\r\n </button>\r\n <button style={{ ...styles.button, ...styles.primaryButton }} onClick={onRetry}>\r\n ↻ Try Again\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n client: LumelyClient;\r\n}\r\n\r\ninterface State {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n aiResponse: LumelyAIResponse | null;\r\n isLoading: boolean;\r\n errorId: string | null;\r\n feedbackSubmitted: boolean;\r\n}\r\n\r\nexport class LumelyErrorBoundary extends Component<Props, State> {\r\n private isReporting = false;\r\n\r\n constructor(props: Props) {\r\n super(props);\r\n this.state = {\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): Partial<State> {\r\n return { hasError: true, error };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\r\n if (this.isReporting) return;\r\n\r\n this.isReporting = true;\r\n this.setState({ errorInfo, isLoading: true });\r\n this.reportError(error, errorInfo);\r\n }\r\n\r\n private async reportError(error: Error, errorInfo: ErrorInfo) {\r\n const { config, client } = this.props;\r\n\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n componentStack: errorInfo.componentStack || undefined,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : '',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',\r\n userId: config.userId,\r\n sessionId: config.sessionId,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const response = await client.reportError(report);\r\n\r\n this.setState({\r\n aiResponse: response.ai,\r\n errorId: response.errorId,\r\n isLoading: false,\r\n });\r\n\r\n if (config.onError) {\r\n config.onError(report);\r\n }\r\n }\r\n\r\n private handleSubmitFeedback = async (feedback: string) => {\r\n const { errorId } = this.state;\r\n const { client } = this.props;\r\n\r\n if (!errorId || errorId === 'client-error') {\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n await client.updateFeedback(errorId, feedback);\r\n this.setState({ feedbackSubmitted: true });\r\n };\r\n\r\n private handleRetry = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleDismiss = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleGoBack = () => {\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n render() {\r\n const { hasError, aiResponse, isLoading, feedbackSubmitted } = this.state;\r\n const { children } = this.props;\r\n\r\n if (hasError) {\r\n return (\r\n <>\r\n {children}\r\n <LumelyErrorOverlay\r\n aiResponse={aiResponse || undefined}\r\n isLoading={isLoading}\r\n feedbackSubmitted={feedbackSubmitted}\r\n onSubmitFeedback={this.handleSubmitFeedback}\r\n onRetry={this.handleRetry}\r\n onDismiss={this.handleDismiss}\r\n onGoBack={this.handleGoBack}\r\n />\r\n </>\r\n );\r\n }\r\n\r\n return children;\r\n }\r\n}\r\n","import React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n apiEndpoint: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\n/**\r\n * LumelyProvider for Plain React (Vite, CRA, etc.)\r\n * \r\n * Usage:\r\n * ```tsx\r\n * import { LumelyProvider } from './components/lumely-react';\r\n * \r\n * function App() {\r\n * return (\r\n * <LumelyProvider \r\n * apiKey=\"your-api-key\"\r\n * apiEndpoint=\"https://your-api.com/api/lumely\"\r\n * >\r\n * <YourApp />\r\n * </LumelyProvider>\r\n * );\r\n * }\r\n * ```\r\n */\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\r\n apiEndpoint,\r\n environment = 'production',\r\n userId,\r\n sessionId,\r\n onError,\r\n}: LumelyProviderProps) => {\r\n const config: LumelyConfig = {\r\n apiKey,\r\n apiEndpoint,\r\n environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n const client = new LumelyClient(apiKey, apiEndpoint);\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config} client={client}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n </LumelyContextProvider>\r\n );\r\n};\r\n"]}
1
+ {"version":3,"sources":["../LumelyClient.ts","../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyClient","apiKey","apiEndpoint","report","response","err","errorId","feedback","LumelyContext","createContext","generateSessionId","stored","newId","useLumely","context","useContext","LumelyContextProvider","children","config","value","useMemo","sessionId","client","jsx","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","setFeedback","useState","isSubmitting","setIsSubmitting","useEffect","handleSubmit","e","LumelyErrorBoundary","Component","props","error","errorInfo","hasError","Fragment","LumelyProvider","environment","userId","onError"],"mappings":"gFAEO,IAAMA,CAAAA,CAAN,KAAmB,CAItB,WAAA,CAAYC,CAAAA,CAAgBC,CAAAA,CAAqB,CAC7C,IAAA,CAAK,MAAA,CAASD,CAAAA,CACd,IAAA,CAAK,YAAcC,EACvB,CAEA,MAAM,WAAA,CAAYC,EAAuD,CACrE,GAAI,CACA,IAAMC,EAAW,MAAM,KAAA,CAAM,CAAA,EAAG,IAAA,CAAK,WAAW,CAAA,aAAA,CAAA,CAAiB,CAC7D,MAAA,CAAQ,MAAA,CACR,OAAA,CAAS,CACL,cAAA,CAAgB,kBAAA,CAChB,eAAgB,IAAA,CAAK,MACzB,CAAA,CACA,IAAA,CAAM,KAAK,SAAA,CAAUD,CAAM,CAC/B,CAAC,EAED,GAAIC,CAAAA,CAAS,EAAA,CACT,OAAO,MAAMA,CAAAA,CAAS,IAAA,EAAK,CAG/B,MAAM,IAAI,KAAA,CAAM,wBAAwB,CAC5C,CAAA,MAASC,EAAK,CACV,OAAA,OAAA,CAAQ,KAAA,CAAM,gCAAA,CAAkCA,CAAG,CAAA,CAC5C,CACH,OAAA,CAAS,KAAA,CACT,EAAA,CAAI,CACA,WAAA,CAAa,8CAAA,CACb,QAAS,EAAA,CACT,YAAA,CAAc,EAClB,CAAA,CACA,QAAS,cACb,CACJ,CACJ,CAEA,MAAM,cAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAAoC,C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MnC,CAAAA,CAAS,IAAItB,CAAAA,CAAaC,EAAQC,CAAW,CAAA,CAEnD,OACIqB,cAAAA,CAACP,CAAAA,CAAA,CAAsB,MAAA,CAAQE,CAAAA,CAC3B,SAAAK,cAAAA,CAACwB,CAAAA,CAAA,CAAoB,MAAA,CAAQ7B,EAAQ,MAAA,CAAQI,CAAAA,CACxC,QAAA,CAAAL,CAAAA,CACL,EACJ,CAER","file":"index.js","sourcesContent":["import type { LumelyErrorReport, LumelyAPIResponse } from './types';\r\n\r\nexport class LumelyClient {\r\n private apiKey: string;\r\n private apiEndpoint: string;\r\n\r\n constructor(apiKey: string, apiEndpoint: string) {\r\n this.apiKey = apiKey;\r\n this.apiEndpoint = apiEndpoint;\r\n }\r\n\r\n async reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/report-error`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n return await response.json();\r\n }\r\n\r\n throw new Error('Failed to report error');\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n return {\r\n success: false,\r\n ai: {\r\n userMessage: \"Something went wrong. We're looking into it.\",\r\n summary: '',\r\n suggestedFix: '',\r\n },\r\n errorId: 'client-error',\r\n };\r\n }\r\n }\r\n\r\n async updateFeedback(errorId: string, feedback: string): Promise<boolean> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n return response.ok;\r\n } catch (err) {\r\n console.error('Lumely: Failed to update feedback', err);\r\n return false;\r\n }\r\n }\r\n}\r\n","import React, { createContext, useContext, useMemo } from 'react';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n client: LumelyClient;\r\n sessionId: string;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\nconst generateSessionId = () => {\r\n if (typeof window === 'undefined') return 'server';\r\n const stored = sessionStorage.getItem('lumely_session_id');\r\n if (stored) return stored;\r\n const newId = `sess_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\r\n sessionStorage.setItem('lumely_session_id', newId);\r\n return newId;\r\n};\r\n\r\nexport const useLumely = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumely must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\ninterface LumelyContextProviderProps {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n}\r\n\r\nexport const LumelyContextProvider = ({ children, config }: LumelyContextProviderProps) => {\r\n const value = useMemo(() => {\r\n const sessionId = config.sessionId || generateSessionId();\r\n const client = new LumelyClient(config.apiKey, config.apiEndpoint);\r\n\r\n return {\r\n ...config,\r\n sessionId,\r\n environment: config.environment || 'production',\r\n client,\r\n };\r\n }, [config]);\r\n\r\n return (\r\n <LumelyContext.Provider value={value}>\r\n {children}\r\n </LumelyContext.Provider>\r\n );\r\n};\r\n","import React, { useState, useEffect } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Inject Poppins font and keyframes\r\nconst injectStyles = () => {\r\n if (typeof document === 'undefined') return;\r\n if (document.getElementById('lumely-react-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-react-styles';\r\n style.textContent = `\r\n @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');\r\n @keyframes lumely-spin {\r\n from { transform: rotate(0deg); }\r\n to { transform: rotate(360deg); }\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n};\r\n\r\n// SVG Icons as components (replacing lucide-react)\r\nconst XIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n </svg>\r\n);\r\n\r\nconst SendIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\r\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\r\n </svg>\r\n);\r\n\r\nconst ArrowLeftIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line>\r\n <polyline points=\"12 19 5 12 12 5\"></polyline>\r\n </svg>\r\n);\r\n\r\nconst RefreshCwIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <polyline points=\"23 4 23 10 17 10\"></polyline>\r\n <polyline points=\"1 20 1 14 7 14\"></polyline>\r\n <path d=\"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15\"></path>\r\n </svg>\r\n);\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n overlay: {\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 9999,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: '16px',\r\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\r\n backdropFilter: 'blur(8px)',\r\n fontFamily: \"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\r\n },\r\n card: {\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: '448px',\r\n background: 'rgba(255, 255, 255, 0.1)',\r\n backdropFilter: 'blur(24px)',\r\n border: '1px solid rgba(255, 255, 255, 0.2)',\r\n borderRadius: '16px',\r\n overflow: 'hidden',\r\n },\r\n closeButton: {\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n padding: '6px',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n background: 'transparent',\r\n border: 'none',\r\n borderRadius: '8px',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'all 0.2s',\r\n },\r\n content: {\r\n padding: '24px',\r\n },\r\n header: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '12px',\r\n marginBottom: '16px',\r\n },\r\n logo: {\r\n width: '40px',\r\n height: '40px',\r\n borderRadius: '12px',\r\n background: 'linear-gradient(135deg, #7c3aed, #8b5cf6)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n color: 'white',\r\n fontWeight: 700,\r\n fontSize: '18px',\r\n },\r\n title: {\r\n color: 'white',\r\n fontWeight: 600,\r\n fontSize: '14px',\r\n margin: 0,\r\n },\r\n subtitle: {\r\n color: 'rgba(255, 255, 255, 0.5)',\r\n fontSize: '12px',\r\n margin: 0,\r\n },\r\n messageBox: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '16px',\r\n marginBottom: '16px',\r\n },\r\n message: {\r\n color: 'rgba(255, 255, 255, 0.9)',\r\n fontSize: '14px',\r\n lineHeight: 1.6,\r\n margin: 0,\r\n },\r\n loading: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'rgba(255, 255, 255, 0.7)',\r\n fontSize: '14px',\r\n padding: '16px 0',\r\n },\r\n spinner: {\r\n width: '16px',\r\n height: '16px',\r\n border: '2px solid rgba(255, 255, 255, 0.3)',\r\n borderTopColor: 'white',\r\n borderRadius: '50%',\r\n animation: 'lumely-spin 1s linear infinite',\r\n },\r\n form: {\r\n marginBottom: '16px',\r\n },\r\n label: {\r\n display: 'block',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n fontSize: '12px',\r\n marginBottom: '8px',\r\n },\r\n inputWrapper: {\r\n position: 'relative',\r\n },\r\n input: {\r\n width: '100%',\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '12px 48px 12px 16px',\r\n color: 'white',\r\n fontSize: '14px',\r\n outline: 'none',\r\n boxSizing: 'border-box',\r\n transition: 'border-color 0.2s',\r\n },\r\n submitButton: {\r\n position: 'absolute',\r\n right: '8px',\r\n top: '50%',\r\n transform: 'translateY(-50%)',\r\n padding: '8px',\r\n color: 'rgba(255, 255, 255, 0.4)',\r\n background: 'transparent',\r\n border: 'none',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'color 0.2s',\r\n },\r\n successBox: {\r\n background: 'rgba(34, 197, 94, 0.1)',\r\n border: '1px solid rgba(34, 197, 94, 0.2)',\r\n borderRadius: '12px',\r\n padding: '12px',\r\n marginBottom: '16px',\r\n },\r\n successText: {\r\n color: '#4ade80',\r\n fontSize: '12px',\r\n textAlign: 'center',\r\n margin: 0,\r\n },\r\n buttons: {\r\n display: 'flex',\r\n gap: '8px',\r\n },\r\n button: {\r\n flex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n gap: '8px',\r\n padding: '10px 16px',\r\n borderRadius: '12px',\r\n fontSize: '14px',\r\n fontWeight: 500,\r\n cursor: 'pointer',\r\n border: 'none',\r\n transition: 'all 0.2s',\r\n },\r\n secondaryButton: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n color: 'rgba(255, 255, 255, 0.8)',\r\n },\r\n primaryButton: {\r\n background: '#7c3aed',\r\n color: 'white',\r\n },\r\n};\r\n\r\ninterface LumelyErrorOverlayProps {\r\n aiResponse?: LumelyAIResponse;\r\n isLoading: boolean;\r\n feedbackSubmitted?: boolean;\r\n onSubmitFeedback: (feedback: string) => void;\r\n onRetry: () => void;\r\n onDismiss: () => void;\r\n onGoBack: () => void;\r\n}\r\n\r\nexport const LumelyErrorOverlay = ({\r\n aiResponse,\r\n isLoading,\r\n feedbackSubmitted = false,\r\n onSubmitFeedback,\r\n onRetry,\r\n onDismiss,\r\n onGoBack,\r\n}: LumelyErrorOverlayProps) => {\r\n const [feedback, setFeedback] = useState('');\r\n const [isSubmitting, setIsSubmitting] = useState(false);\r\n\r\n useEffect(() => {\r\n injectStyles();\r\n }, []);\r\n\r\n const handleSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n if (feedback.trim() && !isSubmitting) {\r\n setIsSubmitting(true);\r\n onSubmitFeedback(feedback);\r\n }\r\n };\r\n\r\n return (\r\n <div style={styles.overlay}>\r\n <div style={styles.card}>\r\n {/* Close Button */}\r\n <button style={styles.closeButton} onClick={onDismiss}>\r\n <XIcon />\r\n </button>\r\n\r\n <div style={styles.content}>\r\n {/* Header */}\r\n <div style={styles.header}>\r\n <div style={styles.logo}>L</div>\r\n <div>\r\n <h3 style={styles.title}>Something went wrong</h3>\r\n <p style={styles.subtitle}>We're looking into it</p>\r\n </div>\r\n </div>\r\n\r\n {/* AI Message */}\r\n {isLoading ? (\r\n <div style={styles.loading}>\r\n <div style={styles.spinner} />\r\n <span>Analyzing the issue...</span>\r\n </div>\r\n ) : aiResponse ? (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>{aiResponse.userMessage}</p>\r\n </div>\r\n ) : (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>\r\n We encountered an unexpected issue. Our team has been notified.\r\n </p>\r\n </div>\r\n )}\r\n\r\n {/* Feedback Input */}\r\n {!feedbackSubmitted && !isSubmitting ? (\r\n <form style={styles.form} onSubmit={handleSubmit}>\r\n <label style={styles.label}>What were you trying to do?</label>\r\n <div style={styles.inputWrapper}>\r\n <input\r\n type=\"text\"\r\n value={feedback}\r\n onChange={(e) => setFeedback(e.target.value)}\r\n placeholder=\"e.g., I was trying to save my changes...\"\r\n style={styles.input}\r\n />\r\n <button\r\n type=\"submit\"\r\n disabled={!feedback.trim()}\r\n style={{\r\n ...styles.submitButton,\r\n opacity: feedback.trim() ? 1 : 0.3,\r\n }}\r\n >\r\n <SendIcon />\r\n </button>\r\n </div>\r\n </form>\r\n ) : (\r\n <div style={styles.successBox}>\r\n <p style={styles.successText}>Thank you! Your feedback helps us improve.</p>\r\n </div>\r\n )}\r\n\r\n {/* Action Buttons */}\r\n <div style={styles.buttons}>\r\n <button\r\n style={{ ...styles.button, ...styles.secondaryButton }}\r\n onClick={onGoBack}\r\n >\r\n <ArrowLeftIcon />\r\n Go Back\r\n </button>\r\n <button\r\n style={{ ...styles.button, ...styles.primaryButton }}\r\n onClick={onRetry}\r\n >\r\n <RefreshCwIcon />\r\n Try Again\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n client: LumelyClient;\r\n}\r\n\r\ninterface State {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n aiResponse: LumelyAIResponse | null;\r\n isLoading: boolean;\r\n errorId: string | null;\r\n feedbackSubmitted: boolean;\r\n}\r\n\r\nexport class LumelyErrorBoundary extends Component<Props, State> {\r\n private isReporting = false;\r\n\r\n constructor(props: Props) {\r\n super(props);\r\n this.state = {\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): Partial<State> {\r\n return { hasError: true, error };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\r\n if (this.isReporting) return;\r\n\r\n this.isReporting = true;\r\n this.setState({ errorInfo, isLoading: true });\r\n this.reportError(error, errorInfo);\r\n }\r\n\r\n private async reportError(error: Error, errorInfo: ErrorInfo) {\r\n const { config, client } = this.props;\r\n\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n componentStack: errorInfo.componentStack || undefined,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : '',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',\r\n userId: config.userId,\r\n sessionId: config.sessionId,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const response = await client.reportError(report);\r\n\r\n this.setState({\r\n aiResponse: response.ai,\r\n errorId: response.errorId,\r\n isLoading: false,\r\n });\r\n\r\n if (config.onError) {\r\n config.onError(report);\r\n }\r\n }\r\n\r\n private handleSubmitFeedback = async (feedback: string) => {\r\n const { errorId } = this.state;\r\n const { client } = this.props;\r\n\r\n if (!errorId || errorId === 'client-error') {\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n await client.updateFeedback(errorId, feedback);\r\n this.setState({ feedbackSubmitted: true });\r\n };\r\n\r\n private handleRetry = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleDismiss = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleGoBack = () => {\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n render() {\r\n const { hasError, aiResponse, isLoading, feedbackSubmitted } = this.state;\r\n const { children } = this.props;\r\n\r\n if (hasError) {\r\n return (\r\n <>\r\n {children}\r\n <LumelyErrorOverlay\r\n aiResponse={aiResponse || undefined}\r\n isLoading={isLoading}\r\n feedbackSubmitted={feedbackSubmitted}\r\n onSubmitFeedback={this.handleSubmitFeedback}\r\n onRetry={this.handleRetry}\r\n onDismiss={this.handleDismiss}\r\n onGoBack={this.handleGoBack}\r\n />\r\n </>\r\n );\r\n }\r\n\r\n return children;\r\n }\r\n}\r\n","import React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n apiEndpoint: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\n/**\r\n * LumelyProvider for Plain React (Vite, CRA, etc.)\r\n * \r\n * Usage:\r\n * ```tsx\r\n * import { LumelyProvider } from './components/lumely-react';\r\n * \r\n * function App() {\r\n * return (\r\n * <LumelyProvider \r\n * apiKey=\"your-api-key\"\r\n * apiEndpoint=\"https://your-api.com/api/lumely\"\r\n * >\r\n * <YourApp />\r\n * </LumelyProvider>\r\n * );\r\n * }\r\n * ```\r\n */\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\r\n apiEndpoint,\r\n environment = 'production',\r\n userId,\r\n sessionId,\r\n onError,\r\n}: LumelyProviderProps) => {\r\n const config: LumelyConfig = {\r\n apiKey,\r\n apiEndpoint,\r\n environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n const client = new LumelyClient(apiKey, apiEndpoint);\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config} client={client}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n </LumelyContextProvider>\r\n );\r\n};\r\n"]}
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import {createContext,useContext,useState,useEffect,Component,useMemo}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var u=class{constructor(r,e){this.apiKey=r,this.apiEndpoint=e;}async reportError(r){try{let e=await fetch(`${this.apiEndpoint}/report-error`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify(r)});if(e.ok)return await e.json();throw new Error("Failed to report error")}catch(e){return console.error("Lumely: Failed to report error",e),{success:false,ai:{userMessage:"Something went wrong. We're looking into it.",summary:"",suggestedFix:""},errorId:"client-error"}}}async updateFeedback(r,e){try{return (await fetch(`${this.apiEndpoint}/update-feedback`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify({errorId:r,feedback:e})})).ok}catch(n){return console.error("Lumely: Failed to update feedback",n),false}}};var b=createContext(null),I=()=>{if(typeof window=="undefined")return "server";let o=sessionStorage.getItem("lumely_session_id");if(o)return o;let r=`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;return sessionStorage.setItem("lumely_session_id",r),r},w=()=>{let o=useContext(b);if(!o)throw new Error("useLumely must be used within a LumelyProvider");return o},x=({children:o,config:r})=>{let e=useMemo(()=>{let n=r.sessionId||I(),s=new u(r.apiKey,r.apiEndpoint);return {...r,sessionId:n,environment:r.environment||"production",client:s}},[r]);return jsx(b.Provider,{value:e,children:o})};var B=()=>{if(typeof document=="undefined"||document.getElementById("lumely-react-styles"))return;let o=document.createElement("style");o.id="lumely-react-styles",o.textContent=`
1
+ import {createContext,useContext,useState,useEffect,Component,useMemo}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var u=class{constructor(o,t){this.apiKey=o,this.apiEndpoint=t;}async reportError(o){try{let t=await fetch(`${this.apiEndpoint}/report-error`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify(o)});if(t.ok)return await t.json();throw new Error("Failed to report error")}catch(t){return console.error("Lumely: Failed to report error",t),{success:false,ai:{userMessage:"Something went wrong. We're looking into it.",summary:"",suggestedFix:""},errorId:"client-error"}}}async updateFeedback(o,t){try{return (await fetch(`${this.apiEndpoint}/update-feedback`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify({errorId:o,feedback:t})})).ok}catch(n){return console.error("Lumely: Failed to update feedback",n),false}}};var b=createContext(null),R=()=>{if(typeof window=="undefined")return "server";let i=sessionStorage.getItem("lumely_session_id");if(i)return i;let o=`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;return sessionStorage.setItem("lumely_session_id",o),o},C=()=>{let i=useContext(b);if(!i)throw new Error("useLumely must be used within a LumelyProvider");return i},h=({children:i,config:o})=>{let t=useMemo(()=>{let n=o.sessionId||R(),s=new u(o.apiKey,o.apiEndpoint);return {...o,sessionId:n,environment:o.environment||"production",client:s}},[o]);return jsx(b.Provider,{value:t,children:i})};var B=()=>{if(typeof document=="undefined"||document.getElementById("lumely-react-styles"))return;let i=document.createElement("style");i.id="lumely-react-styles",i.textContent=`
2
2
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
3
3
  @keyframes lumely-spin {
4
4
  from { transform: rotate(0deg); }
5
5
  to { transform: rotate(360deg); }
6
6
  }
7
- `,document.head.appendChild(o);},t={overlay:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(8px)",fontFamily:"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},card:{position:"relative",width:"100%",maxWidth:"400px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(20px)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"16px",overflow:"hidden"},closeButton:{position:"absolute",top:"12px",right:"12px",padding:"6px",color:"rgba(255, 255, 255, 0.6)",background:"transparent",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"18px"},content:{padding:"24px"},header:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},logo:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #7c3aed, #8b5cf6)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:700,fontSize:"18px"},title:{color:"white",fontWeight:600,fontSize:"14px",margin:0},subtitle:{color:"rgba(255, 255, 255, 0.5)",fontSize:"12px",margin:0},messageBox:{background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"16px",marginBottom:"16px"},message:{color:"rgba(255, 255, 255, 0.9)",fontSize:"14px",lineHeight:1.6,margin:0},loading:{display:"flex",alignItems:"center",gap:"8px",color:"rgba(255, 255, 255, 0.7)",fontSize:"14px",padding:"16px 0"},spinner:{width:"16px",height:"16px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"lumely-spin 1s linear infinite"},form:{marginBottom:"16px"},label:{display:"block",color:"rgba(255, 255, 255, 0.6)",fontSize:"12px",marginBottom:"8px"},inputWrapper:{position:"relative"},input:{width:"100%",background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"12px 48px 12px 16px",color:"white",fontSize:"14px",outline:"none",boxSizing:"border-box"},submitButton:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",padding:"8px",color:"rgba(255, 255, 255, 0.4)",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px"},successBox:{background:"rgba(34, 197, 94, 0.1)",border:"1px solid rgba(34, 197, 94, 0.2)",borderRadius:"12px",padding:"12px",marginBottom:"16px"},successText:{color:"#4ade80",fontSize:"12px",textAlign:"center",margin:0},buttons:{display:"flex",gap:"8px"},button:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"10px 16px",borderRadius:"12px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none",transition:"all 0.2s"},secondaryButton:{background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",color:"rgba(255, 255, 255, 0.8)"},primaryButton:{background:"#7c3aed",color:"white"}},g=({aiResponse:o,isLoading:r,feedbackSubmitted:e=false,onSubmitFeedback:n,onRetry:s,onDismiss:p,onGoBack:l})=>{let[a,m]=useState(""),[f,L]=useState(false);useEffect(()=>{B();},[]);let S=y=>{y.preventDefault(),a.trim()&&!f&&(L(true),n(a));};return jsx("div",{style:t.overlay,children:jsxs("div",{style:t.card,children:[jsx("button",{style:t.closeButton,onClick:p,children:"\u2715"}),jsxs("div",{style:t.content,children:[jsxs("div",{style:t.header,children:[jsx("div",{style:t.logo,children:"L"}),jsxs("div",{children:[jsx("h3",{style:t.title,children:"Something went wrong"}),jsx("p",{style:t.subtitle,children:"We're looking into it"})]})]}),r?jsxs("div",{style:t.loading,children:[jsx("div",{style:t.spinner}),jsx("span",{children:"Analyzing the issue..."})]}):jsx("div",{style:t.messageBox,children:jsx("p",{style:t.message,children:(o==null?void 0:o.userMessage)||"We encountered an unexpected issue. Our team has been notified."})}),!e&&!f?jsxs("form",{style:t.form,onSubmit:S,children:[jsx("label",{style:t.label,children:"What were you trying to do?"}),jsxs("div",{style:t.inputWrapper,children:[jsx("input",{type:"text",value:a,onChange:y=>m(y.target.value),placeholder:"e.g., I was trying to save my changes...",style:t.input}),jsx("button",{type:"submit",disabled:!a.trim(),style:{...t.submitButton,opacity:a.trim()?1:.3},children:"\u27A4"})]})]}):jsx("div",{style:t.successBox,children:jsx("p",{style:t.successText,children:"Thank you! Your feedback helps us improve."})}),jsxs("div",{style:t.buttons,children:[jsx("button",{style:{...t.button,...t.secondaryButton},onClick:l,children:"\u2190 Go Back"}),jsx("button",{style:{...t.button,...t.primaryButton},onClick:s,children:"\u21BB Try Again"})]})]})]})})};var c=class extends Component{constructor(e){super(e);this.isReporting=false;this.handleSubmitFeedback=async e=>{let{errorId:n}=this.state,{client:s}=this.props;if(!n||n==="client-error"){this.setState({feedbackSubmitted:true});return}await s.updateFeedback(n,e),this.setState({feedbackSubmitted:true});};this.handleRetry=()=>{this.isReporting=false,this.setState({hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false});};this.handleDismiss=()=>{this.isReporting=false,this.setState({hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false});};this.handleGoBack=()=>{typeof window!="undefined"&&window.history.back();};this.state={hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false};}static getDerivedStateFromError(e){return {hasError:true,error:e}}componentDidCatch(e,n){this.isReporting||(this.isReporting=true,this.setState({errorInfo:n,isLoading:true}),this.reportError(e,n));}async reportError(e,n){let{config:s,client:p}=this.props,l={errorMessage:e.message,errorStack:e.stack,componentStack:n.componentStack||void 0,context:{url:typeof window!="undefined"?window.location.href:"",userAgent:typeof navigator!="undefined"?navigator.userAgent:"",userId:s.userId,sessionId:s.sessionId,timestamp:new Date().toISOString()}},a=await p.reportError(l);this.setState({aiResponse:a.ai,errorId:a.errorId,isLoading:false}),s.onError&&s.onError(l);}render(){let{hasError:e,aiResponse:n,isLoading:s,feedbackSubmitted:p}=this.state,{children:l}=this.props;return e?jsxs(Fragment,{children:[l,jsx(g,{aiResponse:n||void 0,isLoading:s,feedbackSubmitted:p,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):l}};var W=({children:o,apiKey:r,apiEndpoint:e,environment:n="production",userId:s,sessionId:p,onError:l})=>{let a={apiKey:r,apiEndpoint:e,environment:n,userId:s,sessionId:p,onError:l},m=new u(r,e);return jsx(x,{config:a,children:jsx(c,{config:a,client:m,children:o})})};export{u as LumelyClient,c as LumelyErrorBoundary,g as LumelyErrorOverlay,W as LumelyProvider,w as useLumely};//# sourceMappingURL=index.mjs.map
7
+ `,document.head.appendChild(i);},F=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),A=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),W=()=>jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"19",y1:"12",x2:"5",y2:"12"}),jsx("polyline",{points:"12 19 5 12 12 5"})]}),z=()=>jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("polyline",{points:"23 4 23 10 17 10"}),jsx("polyline",{points:"1 20 1 14 7 14"}),jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),r={overlay:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(8px)",fontFamily:"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},card:{position:"relative",width:"100%",maxWidth:"448px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"16px",overflow:"hidden"},closeButton:{position:"absolute",top:"12px",right:"12px",padding:"6px",color:"rgba(255, 255, 255, 0.6)",background:"transparent",border:"none",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"},content:{padding:"24px"},header:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},logo:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #7c3aed, #8b5cf6)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:700,fontSize:"18px"},title:{color:"white",fontWeight:600,fontSize:"14px",margin:0},subtitle:{color:"rgba(255, 255, 255, 0.5)",fontSize:"12px",margin:0},messageBox:{background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"16px",marginBottom:"16px"},message:{color:"rgba(255, 255, 255, 0.9)",fontSize:"14px",lineHeight:1.6,margin:0},loading:{display:"flex",alignItems:"center",gap:"8px",color:"rgba(255, 255, 255, 0.7)",fontSize:"14px",padding:"16px 0"},spinner:{width:"16px",height:"16px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"lumely-spin 1s linear infinite"},form:{marginBottom:"16px"},label:{display:"block",color:"rgba(255, 255, 255, 0.6)",fontSize:"12px",marginBottom:"8px"},inputWrapper:{position:"relative"},input:{width:"100%",background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"12px 48px 12px 16px",color:"white",fontSize:"14px",outline:"none",boxSizing:"border-box",transition:"border-color 0.2s"},submitButton:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",padding:"8px",color:"rgba(255, 255, 255, 0.4)",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.2s"},successBox:{background:"rgba(34, 197, 94, 0.1)",border:"1px solid rgba(34, 197, 94, 0.2)",borderRadius:"12px",padding:"12px",marginBottom:"16px"},successText:{color:"#4ade80",fontSize:"12px",textAlign:"center",margin:0},buttons:{display:"flex",gap:"8px"},button:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"10px 16px",borderRadius:"12px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none",transition:"all 0.2s"},secondaryButton:{background:"rgba(255, 255, 255, 0.05)",border:"1px solid rgba(255, 255, 255, 0.1)",color:"rgba(255, 255, 255, 0.8)"},primaryButton:{background:"#7c3aed",color:"white"}},g=({aiResponse:i,isLoading:o,feedbackSubmitted:t=false,onSubmitFeedback:n,onRetry:s,onDismiss:p,onGoBack:d})=>{let[l,m]=useState(""),[f,L]=useState(false);useEffect(()=>{B();},[]);let k=y=>{y.preventDefault(),l.trim()&&!f&&(L(true),n(l));};return jsx("div",{style:r.overlay,children:jsxs("div",{style:r.card,children:[jsx("button",{style:r.closeButton,onClick:p,children:jsx(F,{})}),jsxs("div",{style:r.content,children:[jsxs("div",{style:r.header,children:[jsx("div",{style:r.logo,children:"L"}),jsxs("div",{children:[jsx("h3",{style:r.title,children:"Something went wrong"}),jsx("p",{style:r.subtitle,children:"We're looking into it"})]})]}),o?jsxs("div",{style:r.loading,children:[jsx("div",{style:r.spinner}),jsx("span",{children:"Analyzing the issue..."})]}):i?jsx("div",{style:r.messageBox,children:jsx("p",{style:r.message,children:i.userMessage})}):jsx("div",{style:r.messageBox,children:jsx("p",{style:r.message,children:"We encountered an unexpected issue. Our team has been notified."})}),!t&&!f?jsxs("form",{style:r.form,onSubmit:k,children:[jsx("label",{style:r.label,children:"What were you trying to do?"}),jsxs("div",{style:r.inputWrapper,children:[jsx("input",{type:"text",value:l,onChange:y=>m(y.target.value),placeholder:"e.g., I was trying to save my changes...",style:r.input}),jsx("button",{type:"submit",disabled:!l.trim(),style:{...r.submitButton,opacity:l.trim()?1:.3},children:jsx(A,{})})]})]}):jsx("div",{style:r.successBox,children:jsx("p",{style:r.successText,children:"Thank you! Your feedback helps us improve."})}),jsxs("div",{style:r.buttons,children:[jsxs("button",{style:{...r.button,...r.secondaryButton},onClick:d,children:[jsx(W,{}),"Go Back"]}),jsxs("button",{style:{...r.button,...r.primaryButton},onClick:s,children:[jsx(z,{}),"Try Again"]})]})]})]})})};var c=class extends Component{constructor(t){super(t);this.isReporting=false;this.handleSubmitFeedback=async t=>{let{errorId:n}=this.state,{client:s}=this.props;if(!n||n==="client-error"){this.setState({feedbackSubmitted:true});return}await s.updateFeedback(n,t),this.setState({feedbackSubmitted:true});};this.handleRetry=()=>{this.isReporting=false,this.setState({hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false});};this.handleDismiss=()=>{this.isReporting=false,this.setState({hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false});};this.handleGoBack=()=>{typeof window!="undefined"&&window.history.back();};this.state={hasError:false,error:null,errorInfo:null,aiResponse:null,isLoading:false,errorId:null,feedbackSubmitted:false};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,n){this.isReporting||(this.isReporting=true,this.setState({errorInfo:n,isLoading:true}),this.reportError(t,n));}async reportError(t,n){let{config:s,client:p}=this.props,d={errorMessage:t.message,errorStack:t.stack,componentStack:n.componentStack||void 0,context:{url:typeof window!="undefined"?window.location.href:"",userAgent:typeof navigator!="undefined"?navigator.userAgent:"",userId:s.userId,sessionId:s.sessionId,timestamp:new Date().toISOString()}},l=await p.reportError(d);this.setState({aiResponse:l.ai,errorId:l.errorId,isLoading:false}),s.onError&&s.onError(d);}render(){let{hasError:t,aiResponse:n,isLoading:s,feedbackSubmitted:p}=this.state,{children:d}=this.props;return t?jsxs(Fragment,{children:[d,jsx(g,{aiResponse:n||void 0,isLoading:s,feedbackSubmitted:p,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):d}};var M=({children:i,apiKey:o,apiEndpoint:t,environment:n="production",userId:s,sessionId:p,onError:d})=>{let l={apiKey:o,apiEndpoint:t,environment:n,userId:s,sessionId:p,onError:d},m=new u(o,t);return jsx(h,{config:l,children:jsx(c,{config:l,client:m,children:i})})};export{u as LumelyClient,c as LumelyErrorBoundary,g as LumelyErrorOverlay,M as LumelyProvider,C as useLumely};//# sourceMappingURL=index.mjs.map
8
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../LumelyClient.ts","../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyClient","apiKey","apiEndpoint","report","response","err","errorId","feedback","LumelyContext","createContext","generateSessionId","stored","newId","useLumely","context","useContext","LumelyContextProvider","children","config","value","useMemo","sessionId","client","jsx","injectStyles","style","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","setFeedback","useState","isSubmitting","setIsSubmitting","useEffect","handleSubmit","e","jsxs","LumelyErrorBoundary","Component","props","error","errorInfo","hasError","Fragment","LumelyProvider","environment","userId","onError"],"mappings":"oIAEO,IAAMA,CAAAA,CAAN,KAAmB,CAItB,WAAA,CAAYC,CAAAA,CAAgBC,CAAAA,CAAqB,CAC7C,IAAA,CAAK,MAAA,CAASD,CAAAA,CACd,IAAA,CAAK,YAAcC,EACvB,CAEA,MAAM,WAAA,CAAYC,EAAuD,CACrE,GAAI,CACA,IAAMC,EAAW,MAAM,KAAA,CAAM,CAAA,EAAG,IAAA,CAAK,WAAW,CAAA,aAAA,CAAA,CAAiB,CAC7D,MAAA,CAAQ,MAAA,CACR,OAAA,CAAS,CACL,cAAA,CAAgB,kBAAA,CAChB,eAAgB,IAAA,CAAK,MACzB,CAAA,CACA,IAAA,CAAM,KAAK,SAAA,CAAUD,CAAM,CAC/B,CAAC,EA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AAAA,CAC3B,QAAA,CAAAK,GAAAA,CAACoB,CAAAA,CAAA,CAAoB,MAAA,CAAQzB,CAAAA,CAAQ,MAAA,CAAQI,CAAAA,CACxC,QAAA,CAAAL,CAAAA,CACL,CAAA,CACJ,CAER","file":"index.mjs","sourcesContent":["import type { LumelyErrorReport, LumelyAPIResponse } from './types';\r\n\r\nexport class LumelyClient {\r\n private apiKey: string;\r\n private apiEndpoint: string;\r\n\r\n constructor(apiKey: string, apiEndpoint: string) {\r\n this.apiKey = apiKey;\r\n this.apiEndpoint = apiEndpoint;\r\n }\r\n\r\n async reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/report-error`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n return await response.json();\r\n }\r\n\r\n throw new Error('Failed to report error');\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n return {\r\n success: false,\r\n ai: {\r\n userMessage: \"Something went wrong. We're looking into it.\",\r\n summary: '',\r\n suggestedFix: '',\r\n },\r\n errorId: 'client-error',\r\n };\r\n }\r\n }\r\n\r\n async updateFeedback(errorId: string, feedback: string): Promise<boolean> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n return response.ok;\r\n } catch (err) {\r\n console.error('Lumely: Failed to update feedback', err);\r\n return false;\r\n }\r\n }\r\n}\r\n","import React, { createContext, useContext, useMemo } from 'react';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n client: LumelyClient;\r\n sessionId: string;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\nconst generateSessionId = () => {\r\n if (typeof window === 'undefined') return 'server';\r\n const stored = sessionStorage.getItem('lumely_session_id');\r\n if (stored) return stored;\r\n const newId = `sess_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\r\n sessionStorage.setItem('lumely_session_id', newId);\r\n return newId;\r\n};\r\n\r\nexport const useLumely = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumely must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\ninterface LumelyContextProviderProps {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n}\r\n\r\nexport const LumelyContextProvider = ({ children, config }: LumelyContextProviderProps) => {\r\n const value = useMemo(() => {\r\n const sessionId = config.sessionId || generateSessionId();\r\n const client = new LumelyClient(config.apiKey, config.apiEndpoint);\r\n\r\n return {\r\n ...config,\r\n sessionId,\r\n environment: config.environment || 'production',\r\n client,\r\n };\r\n }, [config]);\r\n\r\n return (\r\n <LumelyContext.Provider value={value}>\r\n {children}\r\n </LumelyContext.Provider>\r\n );\r\n};\r\n","import React, { useState, useEffect } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Inject Poppins font and keyframes\r\nconst injectStyles = () => {\r\n if (typeof document === 'undefined') return;\r\n if (document.getElementById('lumely-react-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-react-styles';\r\n style.textContent = `\r\n @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');\r\n @keyframes lumely-spin {\r\n from { transform: rotate(0deg); }\r\n to { transform: rotate(360deg); }\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n};\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n overlay: {\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 9999,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: '16px',\r\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\r\n backdropFilter: 'blur(8px)',\r\n fontFamily: \"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\r\n },\r\n card: {\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: '400px',\r\n background: 'rgba(255, 255, 255, 0.1)',\r\n backdropFilter: 'blur(20px)',\r\n border: '1px solid rgba(255, 255, 255, 0.2)',\r\n borderRadius: '16px',\r\n overflow: 'hidden',\r\n },\r\n closeButton: {\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n padding: '6px',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n background: 'transparent',\r\n border: 'none',\r\n borderRadius: '8px',\r\n cursor: 'pointer',\r\n fontSize: '18px',\r\n },\r\n content: {\r\n padding: '24px',\r\n },\r\n header: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '12px',\r\n marginBottom: '16px',\r\n },\r\n logo: {\r\n width: '40px',\r\n height: '40px',\r\n borderRadius: '12px',\r\n background: 'linear-gradient(135deg, #7c3aed, #8b5cf6)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n color: 'white',\r\n fontWeight: 700,\r\n fontSize: '18px',\r\n },\r\n title: {\r\n color: 'white',\r\n fontWeight: 600,\r\n fontSize: '14px',\r\n margin: 0,\r\n },\r\n subtitle: {\r\n color: 'rgba(255, 255, 255, 0.5)',\r\n fontSize: '12px',\r\n margin: 0,\r\n },\r\n messageBox: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '16px',\r\n marginBottom: '16px',\r\n },\r\n message: {\r\n color: 'rgba(255, 255, 255, 0.9)',\r\n fontSize: '14px',\r\n lineHeight: 1.6,\r\n margin: 0,\r\n },\r\n loading: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'rgba(255, 255, 255, 0.7)',\r\n fontSize: '14px',\r\n padding: '16px 0',\r\n },\r\n spinner: {\r\n width: '16px',\r\n height: '16px',\r\n border: '2px solid rgba(255, 255, 255, 0.3)',\r\n borderTopColor: 'white',\r\n borderRadius: '50%',\r\n animation: 'lumely-spin 1s linear infinite',\r\n },\r\n form: {\r\n marginBottom: '16px',\r\n },\r\n label: {\r\n display: 'block',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n fontSize: '12px',\r\n marginBottom: '8px',\r\n },\r\n inputWrapper: {\r\n position: 'relative',\r\n },\r\n input: {\r\n width: '100%',\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '12px 48px 12px 16px',\r\n color: 'white',\r\n fontSize: '14px',\r\n outline: 'none',\r\n boxSizing: 'border-box',\r\n },\r\n submitButton: {\r\n position: 'absolute',\r\n right: '8px',\r\n top: '50%',\r\n transform: 'translateY(-50%)',\r\n padding: '8px',\r\n color: 'rgba(255, 255, 255, 0.4)',\r\n background: 'transparent',\r\n border: 'none',\r\n cursor: 'pointer',\r\n fontSize: '16px',\r\n },\r\n successBox: {\r\n background: 'rgba(34, 197, 94, 0.1)',\r\n border: '1px solid rgba(34, 197, 94, 0.2)',\r\n borderRadius: '12px',\r\n padding: '12px',\r\n marginBottom: '16px',\r\n },\r\n successText: {\r\n color: '#4ade80',\r\n fontSize: '12px',\r\n textAlign: 'center',\r\n margin: 0,\r\n },\r\n buttons: {\r\n display: 'flex',\r\n gap: '8px',\r\n },\r\n button: {\r\n flex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n gap: '8px',\r\n padding: '10px 16px',\r\n borderRadius: '12px',\r\n fontSize: '14px',\r\n fontWeight: 500,\r\n cursor: 'pointer',\r\n border: 'none',\r\n transition: 'all 0.2s',\r\n },\r\n secondaryButton: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n color: 'rgba(255, 255, 255, 0.8)',\r\n },\r\n primaryButton: {\r\n background: '#7c3aed',\r\n color: 'white',\r\n },\r\n};\r\n\r\ninterface LumelyErrorOverlayProps {\r\n aiResponse?: LumelyAIResponse;\r\n isLoading: boolean;\r\n feedbackSubmitted?: boolean;\r\n onSubmitFeedback: (feedback: string) => void;\r\n onRetry: () => void;\r\n onDismiss: () => void;\r\n onGoBack: () => void;\r\n}\r\n\r\nexport const LumelyErrorOverlay = ({\r\n aiResponse,\r\n isLoading,\r\n feedbackSubmitted = false,\r\n onSubmitFeedback,\r\n onRetry,\r\n onDismiss,\r\n onGoBack,\r\n}: LumelyErrorOverlayProps) => {\r\n const [feedback, setFeedback] = useState('');\r\n const [isSubmitting, setIsSubmitting] = useState(false);\r\n\r\n useEffect(() => {\r\n injectStyles();\r\n }, []);\r\n\r\n const handleSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n if (feedback.trim() && !isSubmitting) {\r\n setIsSubmitting(true);\r\n onSubmitFeedback(feedback);\r\n }\r\n };\r\n\r\n return (\r\n <div style={styles.overlay}>\r\n <div style={styles.card}>\r\n <button style={styles.closeButton} onClick={onDismiss}>✕</button>\r\n\r\n <div style={styles.content}>\r\n <div style={styles.header}>\r\n <div style={styles.logo}>L</div>\r\n <div>\r\n <h3 style={styles.title}>Something went wrong</h3>\r\n <p style={styles.subtitle}>We're looking into it</p>\r\n </div>\r\n </div>\r\n\r\n {isLoading ? (\r\n <div style={styles.loading}>\r\n <div style={styles.spinner} />\r\n <span>Analyzing the issue...</span>\r\n </div>\r\n ) : (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>\r\n {aiResponse?.userMessage || \"We encountered an unexpected issue. Our team has been notified.\"}\r\n </p>\r\n </div>\r\n )}\r\n\r\n {!feedbackSubmitted && !isSubmitting ? (\r\n <form style={styles.form} onSubmit={handleSubmit}>\r\n <label style={styles.label}>What were you trying to do?</label>\r\n <div style={styles.inputWrapper}>\r\n <input\r\n type=\"text\"\r\n value={feedback}\r\n onChange={(e) => setFeedback(e.target.value)}\r\n placeholder=\"e.g., I was trying to save my changes...\"\r\n style={styles.input}\r\n />\r\n <button\r\n type=\"submit\"\r\n disabled={!feedback.trim()}\r\n style={{ ...styles.submitButton, opacity: feedback.trim() ? 1 : 0.3 }}\r\n >\r\n ➤\r\n </button>\r\n </div>\r\n </form>\r\n ) : (\r\n <div style={styles.successBox}>\r\n <p style={styles.successText}>Thank you! Your feedback helps us improve.</p>\r\n </div>\r\n )}\r\n\r\n <div style={styles.buttons}>\r\n <button style={{ ...styles.button, ...styles.secondaryButton }} onClick={onGoBack}>\r\n ← Go Back\r\n </button>\r\n <button style={{ ...styles.button, ...styles.primaryButton }} onClick={onRetry}>\r\n ↻ Try Again\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n client: LumelyClient;\r\n}\r\n\r\ninterface State {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n aiResponse: LumelyAIResponse | null;\r\n isLoading: boolean;\r\n errorId: string | null;\r\n feedbackSubmitted: boolean;\r\n}\r\n\r\nexport class LumelyErrorBoundary extends Component<Props, State> {\r\n private isReporting = false;\r\n\r\n constructor(props: Props) {\r\n super(props);\r\n this.state = {\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): Partial<State> {\r\n return { hasError: true, error };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\r\n if (this.isReporting) return;\r\n\r\n this.isReporting = true;\r\n this.setState({ errorInfo, isLoading: true });\r\n this.reportError(error, errorInfo);\r\n }\r\n\r\n private async reportError(error: Error, errorInfo: ErrorInfo) {\r\n const { config, client } = this.props;\r\n\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n componentStack: errorInfo.componentStack || undefined,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : '',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',\r\n userId: config.userId,\r\n sessionId: config.sessionId,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const response = await client.reportError(report);\r\n\r\n this.setState({\r\n aiResponse: response.ai,\r\n errorId: response.errorId,\r\n isLoading: false,\r\n });\r\n\r\n if (config.onError) {\r\n config.onError(report);\r\n }\r\n }\r\n\r\n private handleSubmitFeedback = async (feedback: string) => {\r\n const { errorId } = this.state;\r\n const { client } = this.props;\r\n\r\n if (!errorId || errorId === 'client-error') {\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n await client.updateFeedback(errorId, feedback);\r\n this.setState({ feedbackSubmitted: true });\r\n };\r\n\r\n private handleRetry = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleDismiss = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleGoBack = () => {\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n render() {\r\n const { hasError, aiResponse, isLoading, feedbackSubmitted } = this.state;\r\n const { children } = this.props;\r\n\r\n if (hasError) {\r\n return (\r\n <>\r\n {children}\r\n <LumelyErrorOverlay\r\n aiResponse={aiResponse || undefined}\r\n isLoading={isLoading}\r\n feedbackSubmitted={feedbackSubmitted}\r\n onSubmitFeedback={this.handleSubmitFeedback}\r\n onRetry={this.handleRetry}\r\n onDismiss={this.handleDismiss}\r\n onGoBack={this.handleGoBack}\r\n />\r\n </>\r\n );\r\n }\r\n\r\n return children;\r\n }\r\n}\r\n","import React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n apiEndpoint: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\n/**\r\n * LumelyProvider for Plain React (Vite, CRA, etc.)\r\n * \r\n * Usage:\r\n * ```tsx\r\n * import { LumelyProvider } from './components/lumely-react';\r\n * \r\n * function App() {\r\n * return (\r\n * <LumelyProvider \r\n * apiKey=\"your-api-key\"\r\n * apiEndpoint=\"https://your-api.com/api/lumely\"\r\n * >\r\n * <YourApp />\r\n * </LumelyProvider>\r\n * );\r\n * }\r\n * ```\r\n */\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\r\n apiEndpoint,\r\n environment = 'production',\r\n userId,\r\n sessionId,\r\n onError,\r\n}: LumelyProviderProps) => {\r\n const config: LumelyConfig = {\r\n apiKey,\r\n apiEndpoint,\r\n environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n const client = new LumelyClient(apiKey, apiEndpoint);\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config} client={client}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n </LumelyContextProvider>\r\n );\r\n};\r\n"]}
1
+ {"version":3,"sources":["../LumelyClient.ts","../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyClient","apiKey","apiEndpoint","report","response","err","errorId","feedback","LumelyContext","createContext","generateSessionId","stored","newId","useLumely","context","useContext","LumelyContextProvider","children","config","value","useMemo","sessionId","client","jsx","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","setFeedback","useState","isSubmitting","setIsSubmitting","useEffect","handleSubmit","e","LumelyErrorBoundary","Component","props","error","errorInfo","hasError","Fragment","LumelyProvider","environment","userId","onError"],"mappings":"oIAEO,IAAMA,CAAAA,CAAN,KAAmB,CAItB,WAAA,CAAYC,CAAAA,CAAgBC,CAAAA,CAAqB,CAC7C,IAAA,CAAK,MAAA,CAASD,CAAAA,CACd,IAAA,CAAK,YAAcC,EACvB,CAEA,MAAM,WAAA,CAAYC,EAAuD,CACrE,GAAI,CACA,IAAMC,EAAW,MAAM,KAAA,CAAM,CAAA,EAAG,IAAA,CAAK,WAAW,CAAA,aAAA,CAAA,CAAiB,CAC7D,MAAA,CAAQ,MAAA,CACR,OAAA,CAAS,CACL,cAAA,CAAgB,kBAAA,CAChB,eAAgB,IAAA,CAAK,MACzB,CAAA,CACA,IAAA,CAAM,KAAK,SAAA,CAAUD,CAAM,CAC/B,CAAC,EAED,GAAIC,CAAAA,CAAS,EAAA,CACT,OAAO,MAAMA,CAAAA,CAAS,IAAA,EAAK,CAG/B,MAAM,IAAI,KAAA,CAAM,wBAAwB,CAC5C,CAAA,MAASC,EAAK,CACV,OAAA,OAAA,CAAQ,KAAA,CAAM,gCAAA,CAAkCA,CAAG,CAAA,CAC5C,CACH,OAAA,CAAS,KAAA,CACT,EAAA,CAAI,CACA,WAAA,CAAa,8CAAA,CACb,QAAS,EAAA,CACT,YAAA,CAAc,EAClB,CAAA,CACA,QAAS,cACb,CACJ,CACJ,CAEA,MAAM,cAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAAoC,CACtE,GA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CAAS,IAAItB,CAAAA,CAAaC,EAAQC,CAAW,CAAA,CAEnD,OACIqB,GAAAA,CAACP,CAAAA,CAAA,CAAsB,MAAA,CAAQE,CAAAA,CAC3B,SAAAK,GAAAA,CAACwB,CAAAA,CAAA,CAAoB,MAAA,CAAQ7B,EAAQ,MAAA,CAAQI,CAAAA,CACxC,QAAA,CAAAL,CAAAA,CACL,EACJ,CAER","file":"index.mjs","sourcesContent":["import type { LumelyErrorReport, LumelyAPIResponse } from './types';\r\n\r\nexport class LumelyClient {\r\n private apiKey: string;\r\n private apiEndpoint: string;\r\n\r\n constructor(apiKey: string, apiEndpoint: string) {\r\n this.apiKey = apiKey;\r\n this.apiEndpoint = apiEndpoint;\r\n }\r\n\r\n async reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/report-error`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n return await response.json();\r\n }\r\n\r\n throw new Error('Failed to report error');\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n return {\r\n success: false,\r\n ai: {\r\n userMessage: \"Something went wrong. We're looking into it.\",\r\n summary: '',\r\n suggestedFix: '',\r\n },\r\n errorId: 'client-error',\r\n };\r\n }\r\n }\r\n\r\n async updateFeedback(errorId: string, feedback: string): Promise<boolean> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n return response.ok;\r\n } catch (err) {\r\n console.error('Lumely: Failed to update feedback', err);\r\n return false;\r\n }\r\n }\r\n}\r\n","import React, { createContext, useContext, useMemo } from 'react';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n client: LumelyClient;\r\n sessionId: string;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\nconst generateSessionId = () => {\r\n if (typeof window === 'undefined') return 'server';\r\n const stored = sessionStorage.getItem('lumely_session_id');\r\n if (stored) return stored;\r\n const newId = `sess_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\r\n sessionStorage.setItem('lumely_session_id', newId);\r\n return newId;\r\n};\r\n\r\nexport const useLumely = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumely must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\ninterface LumelyContextProviderProps {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n}\r\n\r\nexport const LumelyContextProvider = ({ children, config }: LumelyContextProviderProps) => {\r\n const value = useMemo(() => {\r\n const sessionId = config.sessionId || generateSessionId();\r\n const client = new LumelyClient(config.apiKey, config.apiEndpoint);\r\n\r\n return {\r\n ...config,\r\n sessionId,\r\n environment: config.environment || 'production',\r\n client,\r\n };\r\n }, [config]);\r\n\r\n return (\r\n <LumelyContext.Provider value={value}>\r\n {children}\r\n </LumelyContext.Provider>\r\n );\r\n};\r\n","import React, { useState, useEffect } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Inject Poppins font and keyframes\r\nconst injectStyles = () => {\r\n if (typeof document === 'undefined') return;\r\n if (document.getElementById('lumely-react-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-react-styles';\r\n style.textContent = `\r\n @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');\r\n @keyframes lumely-spin {\r\n from { transform: rotate(0deg); }\r\n to { transform: rotate(360deg); }\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n};\r\n\r\n// SVG Icons as components (replacing lucide-react)\r\nconst XIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n </svg>\r\n);\r\n\r\nconst SendIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\r\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\r\n </svg>\r\n);\r\n\r\nconst ArrowLeftIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line>\r\n <polyline points=\"12 19 5 12 12 5\"></polyline>\r\n </svg>\r\n);\r\n\r\nconst RefreshCwIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <polyline points=\"23 4 23 10 17 10\"></polyline>\r\n <polyline points=\"1 20 1 14 7 14\"></polyline>\r\n <path d=\"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15\"></path>\r\n </svg>\r\n);\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n overlay: {\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 9999,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: '16px',\r\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\r\n backdropFilter: 'blur(8px)',\r\n fontFamily: \"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\r\n },\r\n card: {\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: '448px',\r\n background: 'rgba(255, 255, 255, 0.1)',\r\n backdropFilter: 'blur(24px)',\r\n border: '1px solid rgba(255, 255, 255, 0.2)',\r\n borderRadius: '16px',\r\n overflow: 'hidden',\r\n },\r\n closeButton: {\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n padding: '6px',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n background: 'transparent',\r\n border: 'none',\r\n borderRadius: '8px',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'all 0.2s',\r\n },\r\n content: {\r\n padding: '24px',\r\n },\r\n header: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '12px',\r\n marginBottom: '16px',\r\n },\r\n logo: {\r\n width: '40px',\r\n height: '40px',\r\n borderRadius: '12px',\r\n background: 'linear-gradient(135deg, #7c3aed, #8b5cf6)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n color: 'white',\r\n fontWeight: 700,\r\n fontSize: '18px',\r\n },\r\n title: {\r\n color: 'white',\r\n fontWeight: 600,\r\n fontSize: '14px',\r\n margin: 0,\r\n },\r\n subtitle: {\r\n color: 'rgba(255, 255, 255, 0.5)',\r\n fontSize: '12px',\r\n margin: 0,\r\n },\r\n messageBox: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '16px',\r\n marginBottom: '16px',\r\n },\r\n message: {\r\n color: 'rgba(255, 255, 255, 0.9)',\r\n fontSize: '14px',\r\n lineHeight: 1.6,\r\n margin: 0,\r\n },\r\n loading: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'rgba(255, 255, 255, 0.7)',\r\n fontSize: '14px',\r\n padding: '16px 0',\r\n },\r\n spinner: {\r\n width: '16px',\r\n height: '16px',\r\n border: '2px solid rgba(255, 255, 255, 0.3)',\r\n borderTopColor: 'white',\r\n borderRadius: '50%',\r\n animation: 'lumely-spin 1s linear infinite',\r\n },\r\n form: {\r\n marginBottom: '16px',\r\n },\r\n label: {\r\n display: 'block',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n fontSize: '12px',\r\n marginBottom: '8px',\r\n },\r\n inputWrapper: {\r\n position: 'relative',\r\n },\r\n input: {\r\n width: '100%',\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '12px 48px 12px 16px',\r\n color: 'white',\r\n fontSize: '14px',\r\n outline: 'none',\r\n boxSizing: 'border-box',\r\n transition: 'border-color 0.2s',\r\n },\r\n submitButton: {\r\n position: 'absolute',\r\n right: '8px',\r\n top: '50%',\r\n transform: 'translateY(-50%)',\r\n padding: '8px',\r\n color: 'rgba(255, 255, 255, 0.4)',\r\n background: 'transparent',\r\n border: 'none',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'color 0.2s',\r\n },\r\n successBox: {\r\n background: 'rgba(34, 197, 94, 0.1)',\r\n border: '1px solid rgba(34, 197, 94, 0.2)',\r\n borderRadius: '12px',\r\n padding: '12px',\r\n marginBottom: '16px',\r\n },\r\n successText: {\r\n color: '#4ade80',\r\n fontSize: '12px',\r\n textAlign: 'center',\r\n margin: 0,\r\n },\r\n buttons: {\r\n display: 'flex',\r\n gap: '8px',\r\n },\r\n button: {\r\n flex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n gap: '8px',\r\n padding: '10px 16px',\r\n borderRadius: '12px',\r\n fontSize: '14px',\r\n fontWeight: 500,\r\n cursor: 'pointer',\r\n border: 'none',\r\n transition: 'all 0.2s',\r\n },\r\n secondaryButton: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n color: 'rgba(255, 255, 255, 0.8)',\r\n },\r\n primaryButton: {\r\n background: '#7c3aed',\r\n color: 'white',\r\n },\r\n};\r\n\r\ninterface LumelyErrorOverlayProps {\r\n aiResponse?: LumelyAIResponse;\r\n isLoading: boolean;\r\n feedbackSubmitted?: boolean;\r\n onSubmitFeedback: (feedback: string) => void;\r\n onRetry: () => void;\r\n onDismiss: () => void;\r\n onGoBack: () => void;\r\n}\r\n\r\nexport const LumelyErrorOverlay = ({\r\n aiResponse,\r\n isLoading,\r\n feedbackSubmitted = false,\r\n onSubmitFeedback,\r\n onRetry,\r\n onDismiss,\r\n onGoBack,\r\n}: LumelyErrorOverlayProps) => {\r\n const [feedback, setFeedback] = useState('');\r\n const [isSubmitting, setIsSubmitting] = useState(false);\r\n\r\n useEffect(() => {\r\n injectStyles();\r\n }, []);\r\n\r\n const handleSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n if (feedback.trim() && !isSubmitting) {\r\n setIsSubmitting(true);\r\n onSubmitFeedback(feedback);\r\n }\r\n };\r\n\r\n return (\r\n <div style={styles.overlay}>\r\n <div style={styles.card}>\r\n {/* Close Button */}\r\n <button style={styles.closeButton} onClick={onDismiss}>\r\n <XIcon />\r\n </button>\r\n\r\n <div style={styles.content}>\r\n {/* Header */}\r\n <div style={styles.header}>\r\n <div style={styles.logo}>L</div>\r\n <div>\r\n <h3 style={styles.title}>Something went wrong</h3>\r\n <p style={styles.subtitle}>We're looking into it</p>\r\n </div>\r\n </div>\r\n\r\n {/* AI Message */}\r\n {isLoading ? (\r\n <div style={styles.loading}>\r\n <div style={styles.spinner} />\r\n <span>Analyzing the issue...</span>\r\n </div>\r\n ) : aiResponse ? (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>{aiResponse.userMessage}</p>\r\n </div>\r\n ) : (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>\r\n We encountered an unexpected issue. Our team has been notified.\r\n </p>\r\n </div>\r\n )}\r\n\r\n {/* Feedback Input */}\r\n {!feedbackSubmitted && !isSubmitting ? (\r\n <form style={styles.form} onSubmit={handleSubmit}>\r\n <label style={styles.label}>What were you trying to do?</label>\r\n <div style={styles.inputWrapper}>\r\n <input\r\n type=\"text\"\r\n value={feedback}\r\n onChange={(e) => setFeedback(e.target.value)}\r\n placeholder=\"e.g., I was trying to save my changes...\"\r\n style={styles.input}\r\n />\r\n <button\r\n type=\"submit\"\r\n disabled={!feedback.trim()}\r\n style={{\r\n ...styles.submitButton,\r\n opacity: feedback.trim() ? 1 : 0.3,\r\n }}\r\n >\r\n <SendIcon />\r\n </button>\r\n </div>\r\n </form>\r\n ) : (\r\n <div style={styles.successBox}>\r\n <p style={styles.successText}>Thank you! Your feedback helps us improve.</p>\r\n </div>\r\n )}\r\n\r\n {/* Action Buttons */}\r\n <div style={styles.buttons}>\r\n <button\r\n style={{ ...styles.button, ...styles.secondaryButton }}\r\n onClick={onGoBack}\r\n >\r\n <ArrowLeftIcon />\r\n Go Back\r\n </button>\r\n <button\r\n style={{ ...styles.button, ...styles.primaryButton }}\r\n onClick={onRetry}\r\n >\r\n <RefreshCwIcon />\r\n Try Again\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n client: LumelyClient;\r\n}\r\n\r\ninterface State {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n aiResponse: LumelyAIResponse | null;\r\n isLoading: boolean;\r\n errorId: string | null;\r\n feedbackSubmitted: boolean;\r\n}\r\n\r\nexport class LumelyErrorBoundary extends Component<Props, State> {\r\n private isReporting = false;\r\n\r\n constructor(props: Props) {\r\n super(props);\r\n this.state = {\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): Partial<State> {\r\n return { hasError: true, error };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\r\n if (this.isReporting) return;\r\n\r\n this.isReporting = true;\r\n this.setState({ errorInfo, isLoading: true });\r\n this.reportError(error, errorInfo);\r\n }\r\n\r\n private async reportError(error: Error, errorInfo: ErrorInfo) {\r\n const { config, client } = this.props;\r\n\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n componentStack: errorInfo.componentStack || undefined,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : '',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',\r\n userId: config.userId,\r\n sessionId: config.sessionId,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const response = await client.reportError(report);\r\n\r\n this.setState({\r\n aiResponse: response.ai,\r\n errorId: response.errorId,\r\n isLoading: false,\r\n });\r\n\r\n if (config.onError) {\r\n config.onError(report);\r\n }\r\n }\r\n\r\n private handleSubmitFeedback = async (feedback: string) => {\r\n const { errorId } = this.state;\r\n const { client } = this.props;\r\n\r\n if (!errorId || errorId === 'client-error') {\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n await client.updateFeedback(errorId, feedback);\r\n this.setState({ feedbackSubmitted: true });\r\n };\r\n\r\n private handleRetry = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleDismiss = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleGoBack = () => {\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n render() {\r\n const { hasError, aiResponse, isLoading, feedbackSubmitted } = this.state;\r\n const { children } = this.props;\r\n\r\n if (hasError) {\r\n return (\r\n <>\r\n {children}\r\n <LumelyErrorOverlay\r\n aiResponse={aiResponse || undefined}\r\n isLoading={isLoading}\r\n feedbackSubmitted={feedbackSubmitted}\r\n onSubmitFeedback={this.handleSubmitFeedback}\r\n onRetry={this.handleRetry}\r\n onDismiss={this.handleDismiss}\r\n onGoBack={this.handleGoBack}\r\n />\r\n </>\r\n );\r\n }\r\n\r\n return children;\r\n }\r\n}\r\n","import React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n apiEndpoint: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\n/**\r\n * LumelyProvider for Plain React (Vite, CRA, etc.)\r\n * \r\n * Usage:\r\n * ```tsx\r\n * import { LumelyProvider } from './components/lumely-react';\r\n * \r\n * function App() {\r\n * return (\r\n * <LumelyProvider \r\n * apiKey=\"your-api-key\"\r\n * apiEndpoint=\"https://your-api.com/api/lumely\"\r\n * >\r\n * <YourApp />\r\n * </LumelyProvider>\r\n * );\r\n * }\r\n * ```\r\n */\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\r\n apiEndpoint,\r\n environment = 'production',\r\n userId,\r\n sessionId,\r\n onError,\r\n}: LumelyProviderProps) => {\r\n const config: LumelyConfig = {\r\n apiKey,\r\n apiEndpoint,\r\n environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n const client = new LumelyClient(apiKey, apiEndpoint);\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config} client={client}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n </LumelyContextProvider>\r\n );\r\n};\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumely-react",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "AI-powered error handling for React applications",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -47,8 +47,8 @@
47
47
  "type": "git",
48
48
  "url": "https://github.com/lumely/lumely-react"
49
49
  },
50
- "homepage": "https://lumely.com",
50
+ "homepage": "https://lumely.vercel.app",
51
51
  "bugs": {
52
52
  "url": "https://github.com/lumely/lumely-react/issues"
53
53
  }
54
- }
54
+ }