lumely-next 0.1.1 → 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
@@ -49,7 +49,10 @@ That's it. Lumely will automatically catch errors and display a user-friendly ov
49
49
 
50
50
  ## API Routes
51
51
 
52
- This package expects API routes at `/api/lumely/`. Set up the API by copying the route handlers from the Lumely documentation.
52
+ This package expects API routes at `/api/lumely/`.
53
+ 1. Create a `pages/api/lumely/report-error.ts` file.
54
+ 2. Create a `pages/api/lumely/update-feedback.ts` file.
55
+ 3. Use the `apiEndpoint="/api/lumely"` prop in your Provider.
53
56
 
54
57
  ## Documentation
55
58
 
package/dist/index.d.mts CHANGED
@@ -82,7 +82,25 @@ declare const LumelyErrorOverlay: ({ aiResponse, isLoading, feedbackSubmitted, o
82
82
 
83
83
  interface LumelyContextValue extends LumelyConfig {
84
84
  sessionId: string;
85
+ reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;
85
86
  }
86
87
  declare const useLumelyContext: () => LumelyContextValue;
88
+ /**
89
+ * Hook for manually reporting errors that aren't caught by the Error Boundary.
90
+ *
91
+ * Usage:
92
+ * ```tsx
93
+ * const { reportError } = useLumelyReport();
94
+ *
95
+ * try {
96
+ * await fetchData();
97
+ * } catch (error) {
98
+ * reportError(error, { action: 'fetching user data' });
99
+ * }
100
+ * ```
101
+ */
102
+ declare const useLumelyReport: () => {
103
+ reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;
104
+ };
87
105
 
88
- export { type LumelyAIResponse, type LumelyAPIResponse, type LumelyConfig, LumelyErrorBoundary, type LumelyErrorContext, LumelyErrorOverlay, type LumelyErrorReport, LumelyProvider, useLumelyContext };
106
+ export { type LumelyAIResponse, type LumelyAPIResponse, type LumelyConfig, LumelyErrorBoundary, type LumelyErrorContext, LumelyErrorOverlay, type LumelyErrorReport, LumelyProvider, useLumelyContext, useLumelyReport };
package/dist/index.d.ts CHANGED
@@ -82,7 +82,25 @@ declare const LumelyErrorOverlay: ({ aiResponse, isLoading, feedbackSubmitted, o
82
82
 
83
83
  interface LumelyContextValue extends LumelyConfig {
84
84
  sessionId: string;
85
+ reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;
85
86
  }
86
87
  declare const useLumelyContext: () => LumelyContextValue;
88
+ /**
89
+ * Hook for manually reporting errors that aren't caught by the Error Boundary.
90
+ *
91
+ * Usage:
92
+ * ```tsx
93
+ * const { reportError } = useLumelyReport();
94
+ *
95
+ * try {
96
+ * await fetchData();
97
+ * } catch (error) {
98
+ * reportError(error, { action: 'fetching user data' });
99
+ * }
100
+ * ```
101
+ */
102
+ declare const useLumelyReport: () => {
103
+ reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;
104
+ };
87
105
 
88
- export { type LumelyAIResponse, type LumelyAPIResponse, type LumelyConfig, LumelyErrorBoundary, type LumelyErrorContext, LumelyErrorOverlay, type LumelyErrorReport, LumelyProvider, useLumelyContext };
106
+ export { type LumelyAIResponse, type LumelyAPIResponse, type LumelyConfig, LumelyErrorBoundary, type LumelyErrorContext, LumelyErrorOverlay, type LumelyErrorReport, LumelyProvider, useLumelyContext, useLumelyReport };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var g=react.createContext(null),R=()=>{if(typeof window=="undefined")return "server";let r=sessionStorage.getItem("lumely_session_id");if(r)return r;let a=`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;return sessionStorage.setItem("lumely_session_id",a),a},C=()=>{let r=react.useContext(g);if(!r)throw new Error("useLumelyContext must be used within a LumelyProvider");return r},f=({children:r,config:a})=>{let o=react.useMemo(()=>({...a,sessionId:a.sessionId||R(),environment:a.environment||"production"}),[a]);return jsxRuntime.jsx(g.Provider,{value:o,children:r})};var B=()=>{if(typeof document=="undefined"||document.getElementById("lumely-next-styles"))return;let r=document.createElement("style");r.id="lumely-next-styles",r.textContent=`
1
+ 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var g=react.createContext(null),I=()=>{if(typeof window=="undefined")return "server";let i=sessionStorage.getItem("lumely_session_id");if(i)return i;let s=`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;return sessionStorage.setItem("lumely_session_id",s),s},C=()=>{let i=react.useContext(g);if(!i)throw new Error("useLumelyContext must be used within a LumelyProvider");return i},P=()=>{let i=react.useContext(g);if(!i)throw new Error("useLumelyReport must be used within a LumelyProvider");return {reportError:i.reportError}},x=({children:i,config:s})=>{let o=react.useMemo(()=>s.sessionId||I(),[s.sessionId]),n=react.useCallback(async(l,a)=>{var u;let t={errorMessage:l.message,errorStack:l.stack,context:{url:typeof window!="undefined"?window.location.href:"server",userAgent:typeof navigator!="undefined"?navigator.userAgent:"server",userId:s.userId,sessionId:o,timestamp:new Date().toISOString(),...a&&{additionalContext:JSON.stringify(a)}}};try{let c=await fetch("/api/lumely/report-error",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":s.apiKey},body:JSON.stringify(t)});c.ok||console.error("[Lumely] Failed to report error:",c.statusText),(u=s.onError)==null||u.call(s,t);}catch(c){console.error("[Lumely] Error reporting failed:",c);}},[s,o]);react.useEffect(()=>{if(typeof window=="undefined")return;let l=t=>{let u=t.reason instanceof Error?t.reason:new Error(String(t.reason));n(u,{type:"unhandledRejection"});},a=t=>{let u=t.error instanceof Error?t.error:new Error(t.message);n(u,{type:"globalError",filename:t.filename,lineno:t.lineno,colno:t.colno});};return window.addEventListener("unhandledrejection",l),window.addEventListener("error",a),()=>{window.removeEventListener("unhandledrejection",l),window.removeEventListener("error",a);}},[n]);let d=react.useMemo(()=>({...s,sessionId:o,environment:s.environment||"production",reportError:n}),[s,o,n]);return jsxRuntime.jsx(g.Provider,{value:d,children:i})};var j=()=>{if(typeof document=="undefined"||document.getElementById("lumely-next-styles"))return;let i=document.createElement("style");i.id="lumely-next-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(r);},P=()=>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"})]}),F=()=>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"})]}),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("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"})]}),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:"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"}},m=({aiResponse:r,isLoading:a,feedbackSubmitted:o=false,onSubmitFeedback:n,onRetry:s,onDismiss:d,onGoBack:l})=>{let[p,h]=react.useState(""),[y,v]=react.useState(false);react.useEffect(()=>{B();},[]);let L=c=>{c.preventDefault(),p.trim()&&!y&&(v(true),n(p));};return jsxRuntime.jsx("div",{style:t.overlay,children:jsxRuntime.jsxs("div",{style:t.card,children:[jsxRuntime.jsx("button",{style:t.closeButton,onClick:d,children:jsxRuntime.jsx(P,{})}),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"})]})]}),a?jsxRuntime.jsxs("div",{style:t.loading,children:[jsxRuntime.jsx("div",{style:t.spinner}),jsxRuntime.jsx("span",{children:"Analyzing the issue..."})]}):r?jsxRuntime.jsx("div",{style:t.messageBox,children:jsxRuntime.jsx("p",{style:t.message,children:r.userMessage})}):jsxRuntime.jsx("div",{style:t.messageBox,children:jsxRuntime.jsx("p",{style:t.message,children:"We encountered an unexpected issue. Our team has been notified."})}),!o&&!y?jsxRuntime.jsxs("form",{style:t.form,onSubmit:L,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:p,onChange:c=>h(c.target.value),placeholder:"e.g., I was trying to save my changes...",style:t.input}),jsxRuntime.jsx("button",{type:"submit",disabled:!p.trim(),style:{...t.submitButton,opacity:p.trim()?1:.3},children:jsxRuntime.jsx(A,{})})]})]}):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.jsxs("button",{style:{...t.button,...t.secondaryButton},onClick:l,children:[jsxRuntime.jsx(F,{}),"Go Back"]}),jsxRuntime.jsxs("button",{style:{...t.button,...t.primaryButton},onClick:s,children:[jsxRuntime.jsx(W,{}),"Try Again"]})]})]})]})})};var u=class extends react.Component{constructor(o){super(o);this.isReporting=false;this.handleSubmitFeedback=async o=>{let{errorId:n}=this.state,{config:s}=this.props;if(!n||n==="no-db"||n==="db-error"){this.setState({feedbackSubmitted:true});return}try{await fetch("/api/lumely/update-feedback",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":s.apiKey},body:JSON.stringify({errorId:n,feedback:o})}),this.setState({feedbackSubmitted:!0});}catch(d){console.error("Lumely: Failed to submit feedback",d),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(o){return {hasError:true,error:o}}componentDidCatch(o,n){this.isReporting||(this.isReporting=true,this.setState({errorInfo:n,isLoading:true}),this.reportError(o,n));}async reportError(o,n){let{config:s}=this.props,d={errorMessage:o.message,errorStack:o.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()}};try{let l=await fetch("/api/lumely/report-error",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":s.apiKey},body:JSON.stringify(d)});if(l.ok){let p=await l.json();this.setState({aiResponse:p.ai,errorId:p.errorId,isLoading:!1});}else this.setState({isLoading:!1});}catch(l){console.error("Lumely: Failed to report error",l),this.setState({isLoading:false});}s.onError&&s.onError(d);}render(){let{hasError:o,aiResponse:n,isLoading:s,feedbackSubmitted:d}=this.state,{children:l}=this.props;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l,jsxRuntime.jsx(m,{aiResponse:n||void 0,isLoading:s,feedbackSubmitted:d,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):l}};var T=({children:r,apiKey:a,environment:o="production",userId:n,sessionId:s,onError:d})=>{let l={apiKey:a,environment:o,userId:n,sessionId:s,onError:d};return jsxRuntime.jsx(f,{config:l,children:jsxRuntime.jsx(u,{config:l,children:r})})};exports.LumelyErrorBoundary=u;exports.LumelyErrorOverlay=m;exports.LumelyProvider=T;exports.useLumelyContext=C;//# sourceMappingURL=index.js.map
7
+ `,document.head.appendChild(i);},O=()=>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"})]}),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:"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"}},f=({aiResponse:i,isLoading:s,feedbackSubmitted:o=false,onSubmitFeedback:n,onRetry:d,onDismiss:l,onGoBack:a})=>{let[t,u]=react.useState(""),[c,k]=react.useState(false);react.useEffect(()=>{j();},[]);let S=y=>{y.preventDefault(),t.trim()&&!c&&(k(true),n(t));};return jsxRuntime.jsx("div",{style:r.overlay,children:jsxRuntime.jsxs("div",{style:r.card,children:[jsxRuntime.jsx("button",{style:r.closeButton,onClick:l,children:jsxRuntime.jsx(O,{})}),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"})]})]}),s?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."})}),!o&&!c?jsxRuntime.jsxs("form",{style:r.form,onSubmit:S,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:t,onChange:y=>u(y.target.value),placeholder:"e.g., I was trying to save my changes...",style:r.input}),jsxRuntime.jsx("button",{type:"submit",disabled:!t.trim(),style:{...r.submitButton,opacity:t.trim()?1:.3},children:jsxRuntime.jsx(F,{})})]})]}):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:a,children:[jsxRuntime.jsx(W,{}),"Go Back"]}),jsxRuntime.jsxs("button",{style:{...r.button,...r.primaryButton},onClick:d,children:[jsxRuntime.jsx(z,{}),"Try Again"]})]})]})]})})};var m=class extends react.Component{constructor(o){super(o);this.isReporting=false;this.handleSubmitFeedback=async o=>{let{errorId:n}=this.state,{config:d}=this.props;if(!n||n==="no-db"||n==="db-error"){this.setState({feedbackSubmitted:true});return}try{await fetch("/api/lumely/update-feedback",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":d.apiKey},body:JSON.stringify({errorId:n,feedback:o})}),this.setState({feedbackSubmitted:!0});}catch(l){console.error("Lumely: Failed to submit feedback",l),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(o){return {hasError:true,error:o}}componentDidCatch(o,n){this.isReporting||(this.isReporting=true,this.setState({errorInfo:n,isLoading:true}),this.reportError(o,n));}async reportError(o,n){let{config:d}=this.props,l={errorMessage:o.message,errorStack:o.stack,componentStack:n.componentStack||void 0,context:{url:typeof window!="undefined"?window.location.href:"",userAgent:typeof navigator!="undefined"?navigator.userAgent:"",userId:d.userId,sessionId:d.sessionId,timestamp:new Date().toISOString()}};try{let a=await fetch("/api/lumely/report-error",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":d.apiKey},body:JSON.stringify(l)});if(a.ok){let t=await a.json();this.setState({aiResponse:t.ai,errorId:t.errorId,isLoading:!1});}else this.setState({isLoading:!1});}catch(a){console.error("Lumely: Failed to report error",a),this.setState({isLoading:false});}d.onError&&d.onError(l);}render(){let{hasError:o,aiResponse:n,isLoading:d,feedbackSubmitted:l}=this.state,{children:a}=this.props;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a,jsxRuntime.jsx(f,{aiResponse:n||void 0,isLoading:d,feedbackSubmitted:l,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):a}};var N=({children:i,apiKey:s,environment:o="production",userId:n,sessionId:d,onError:l})=>{let a={apiKey:s,environment:o,userId:n,sessionId:d,onError:l};return jsxRuntime.jsx(x,{config:a,children:jsxRuntime.jsx(m,{config:a,children:i})})};exports.LumelyErrorBoundary=m;exports.LumelyErrorOverlay=f;exports.LumelyProvider=N;exports.useLumelyContext=C;exports.useLumelyReport=P;//# sourceMappingURL=index.js.map
8
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyContext","createContext","generateSessionId","stored","newId","useLumelyContext","context","useContext","LumelyContextProvider","children","config","value","useMemo","jsx","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","feedback","setFeedback","useState","isSubmitting","setIsSubmitting","useEffect","handleSubmit","e","LumelyErrorBoundary","Component","props","errorId","err","error","errorInfo","report","response","data","hasError","Fragment","LumelyProvider","apiKey","environment","userId","sessionId","onError"],"mappings":"oFASMA,CAAAA,CAAgBC,mBAAAA,CAAyC,IAAI,CAAA,CAG7DC,EAAoB,IAAM,CAC5B,GAAI,OAAO,QAAW,WAAA,CAAa,OAAO,QAAA,CAC1C,IAAMC,EA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AAzB,CAAAA,CAAY,SAAA,CAAAC,EAAW,iBAAA,CAAAC,CAAkB,CAAA,CAAI,IAAA,CAAK,MAC9D,CAAE,QAAA,CAAAhB,CAAS,CAAA,CAAI,KAAK,KAAA,CAE1B,OAAIuC,CAAAA,CAEI/B,eAAAA,CAAAgC,oBAAA,CACK,QAAA,CAAA,CAAAxC,CAAAA,CACDI,cAAAA,CAACS,EAAA,CACG,UAAA,CAAYC,CAAAA,EAAc,MAAA,CAC1B,UAAWC,CAAAA,CACX,iBAAA,CAAmBC,CAAAA,CACnB,gBAAA,CAAkB,KAAK,oBAAA,CACvB,OAAA,CAAS,IAAA,CAAK,WAAA,CACd,UAAW,IAAA,CAAK,aAAA,CAChB,QAAA,CAAU,IAAA,CAAK,aACnB,CAAA,CAAA,CACJ,CAAA,CAIDhB,CACX,CACJ,ECpKO,IAAMyC,EAAiB,CAAC,CAC3B,QAAA,CAAAzC,CAAAA,CACA,OAAA0C,CAAAA,CACA,WAAA,CAAAC,CAAAA,CAAc,YAAA,CACd,OAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CACJ,CAAA,GAA2B,CACvB,IAAM7C,CAAAA,CAAuB,CACzB,MAAA,CAAAyC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,OAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CACJ,CAAA,CAEA,OACI1C,cAAAA,CAACL,CAAAA,CAAA,CAAsB,MAAA,CAAQE,CAAAA,CAC3B,QAAA,CAAAG,cAAAA,CAACyB,EAAA,CAAoB,MAAA,CAAQ5B,EACxB,QAAA,CAAAD,CAAAA,CACL,EACJ,CAER","file":"index.js","sourcesContent":["'use client';\r\n\r\nimport React, { createContext, useContext, useMemo } from 'react';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n sessionId: string;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\n// Generate a unique session ID\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 useLumelyContext = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumelyContext 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 ...config,\r\n sessionId: config.sessionId || generateSessionId(),\r\n environment: config.environment || 'production',\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","'use client';\r\n\r\nimport 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-next-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-next-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","'use client';\r\n\r\nimport React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse, LumelyAPIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\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; // Prevent duplicate reports\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 // Prevent duplicate reports\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 } = 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 try {\r\n const response = await fetch('/api/lumely/report-error', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n const data: LumelyAPIResponse = await response.json();\r\n this.setState({\r\n aiResponse: data.ai,\r\n errorId: data.errorId,\r\n isLoading: false,\r\n });\r\n } else {\r\n this.setState({ isLoading: false });\r\n }\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n this.setState({ isLoading: false });\r\n }\r\n\r\n // Call optional callback\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 { config } = this.props;\r\n\r\n if (!errorId || errorId === 'no-db' || errorId === 'db-error') {\r\n // Can't update if no valid error ID\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n try {\r\n // Update existing error record with feedback\r\n await fetch('/api/lumely/update-feedback', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n this.setState({ feedbackSubmitted: true });\r\n } catch (err) {\r\n console.error('Lumely: Failed to submit feedback', err);\r\n this.setState({ feedbackSubmitted: true });\r\n }\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","'use client';\r\n\r\nimport React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\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 environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n </LumelyContextProvider>\r\n );\r\n};\r\n"]}
1
+ {"version":3,"sources":["../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyContext","createContext","generateSessionId","stored","newId","useLumelyContext","context","useContext","useLumelyReport","LumelyContextProvider","children","config","sessionId","useMemo","reportError","useCallback","error","additionalContext","_a","report","response","e","useEffect","handleUnhandledRejection","event","handleGlobalError","value","jsx","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","feedback","setFeedback","useState","isSubmitting","setIsSubmitting","handleSubmit","LumelyErrorBoundary","Component","props","errorId","err","errorInfo","data","hasError","Fragment","LumelyProvider","apiKey","environment","userId","onError"],"mappings":"gFAUA,IAAMA,CAAAA,CAAgBC,oBAAyC,IAAI,CAAA,CAG7DC,CAAAA,CAAoB,IAAM,CAC5B,GAAI,OAAO,MAAA,EAAW,WAAA,CAAa,OAAO,QAAA,CAC1C,IAAMC,EAAS,cAAA,CAAe,OAAA,CAAQ,mBAAmB,CAAA,CACzD,GAAIA,CAAAA,CAAQ,OAAOA,CAAAA,CACnB,IAAMC,EAAQ,CAAA,KAAA,EAAQ,IAAA,CAAK,KAAK,CAAA,CAAA,EAAI,IAAA,CAAK,MAAA,EAAO,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,SAAA,CAAU,EAAG,CAAC,CAAC,GAC9E,OAAA,cAAA,CAAe,OAAA,CAAQ,oBAAqBA,CAAK,CAAA,CAC1CA,CACX,CAAA,CAEaC,CAAAA,CAAmB,IAAM,CAClC,IAAMC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CACJ,ECpKO,IAAMiD,EAAiB,CAAC,CAC3B,QAAA,CAAAjD,CAAAA,CACA,OAAAkD,CAAAA,CACA,WAAA,CAAAC,CAAAA,CAAc,YAAA,CACd,OAAAC,CAAAA,CACA,SAAA,CAAAlD,CAAAA,CACA,OAAA,CAAAmD,CACJ,CAAA,GAA2B,CACvB,IAAMpD,CAAAA,CAAuB,CACzB,MAAA,CAAAiD,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,OAAAC,CAAAA,CACA,SAAA,CAAAlD,CAAAA,CACA,OAAA,CAAAmD,CACJ,CAAA,CAEA,OACIpC,cAAAA,CAAClB,CAAAA,CAAA,CAAsB,MAAA,CAAQE,CAAAA,CAC3B,QAAA,CAAAgB,cAAAA,CAACuB,EAAA,CAAoB,MAAA,CAAQvC,EACxB,QAAA,CAAAD,CAAAA,CACL,EACJ,CAER","file":"index.js","sourcesContent":["'use client';\r\n\r\nimport React, { createContext, useContext, useMemo, useCallback, useEffect } from 'react';\r\nimport type { LumelyConfig, LumelyErrorReport } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n sessionId: string;\r\n reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\n// Generate a unique session ID\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 useLumelyContext = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumelyContext must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\n/**\r\n * Hook for manually reporting errors that aren't caught by the Error Boundary.\r\n * \r\n * Usage:\r\n * ```tsx\r\n * const { reportError } = useLumelyReport();\r\n * \r\n * try {\r\n * await fetchData();\r\n * } catch (error) {\r\n * reportError(error, { action: 'fetching user data' });\r\n * }\r\n * ```\r\n */\r\nexport const useLumelyReport = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumelyReport must be used within a LumelyProvider');\r\n }\r\n return { reportError: context.reportError };\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 sessionId = useMemo(() => config.sessionId || generateSessionId(), [config.sessionId]);\r\n\r\n // Manual error reporting function\r\n const reportError = useCallback(async (error: Error, additionalContext?: Record<string, unknown>) => {\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : 'server',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : 'server',\r\n userId: config.userId,\r\n sessionId: sessionId,\r\n timestamp: new Date().toISOString(),\r\n ...(additionalContext && { additionalContext: JSON.stringify(additionalContext) }),\r\n }\r\n };\r\n\r\n try {\r\n const response = await fetch('/api/lumely/report-error', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (!response.ok) {\r\n console.error('[Lumely] Failed to report error:', response.statusText);\r\n }\r\n\r\n // Call user's onError callback if provided\r\n config.onError?.(report);\r\n } catch (e) {\r\n console.error('[Lumely] Error reporting failed:', e);\r\n }\r\n }, [config, sessionId]);\r\n\r\n // Setup global error handlers for uncaught errors\r\n useEffect(() => {\r\n if (typeof window === 'undefined') return;\r\n\r\n // Catch unhandled promise rejections\r\n const handleUnhandledRejection = (event: PromiseRejectionEvent) => {\r\n const error = event.reason instanceof Error\r\n ? event.reason\r\n : new Error(String(event.reason));\r\n reportError(error, { type: 'unhandledRejection' });\r\n };\r\n\r\n // Catch global errors (non-React)\r\n const handleGlobalError = (event: ErrorEvent) => {\r\n const error = event.error instanceof Error\r\n ? event.error\r\n : new Error(event.message);\r\n reportError(error, {\r\n type: 'globalError',\r\n filename: event.filename,\r\n lineno: event.lineno,\r\n colno: event.colno\r\n });\r\n };\r\n\r\n window.addEventListener('unhandledrejection', handleUnhandledRejection);\r\n window.addEventListener('error', handleGlobalError);\r\n\r\n return () => {\r\n window.removeEventListener('unhandledrejection', handleUnhandledRejection);\r\n window.removeEventListener('error', handleGlobalError);\r\n };\r\n }, [reportError]);\r\n\r\n const value = useMemo(() => ({\r\n ...config,\r\n sessionId,\r\n environment: config.environment || 'production',\r\n reportError,\r\n }), [config, sessionId, reportError]);\r\n\r\n return (\r\n <LumelyContext.Provider value={value}>\r\n {children}\r\n </LumelyContext.Provider>\r\n );\r\n};\r\n","'use client';\r\n\r\nimport 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-next-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-next-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","'use client';\r\n\r\nimport React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse, LumelyAPIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\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; // Prevent duplicate reports\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 // Prevent duplicate reports\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 } = 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 try {\r\n const response = await fetch('/api/lumely/report-error', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n const data: LumelyAPIResponse = await response.json();\r\n this.setState({\r\n aiResponse: data.ai,\r\n errorId: data.errorId,\r\n isLoading: false,\r\n });\r\n } else {\r\n this.setState({ isLoading: false });\r\n }\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n this.setState({ isLoading: false });\r\n }\r\n\r\n // Call optional callback\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 { config } = this.props;\r\n\r\n if (!errorId || errorId === 'no-db' || errorId === 'db-error') {\r\n // Can't update if no valid error ID\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n try {\r\n // Update existing error record with feedback\r\n await fetch('/api/lumely/update-feedback', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n this.setState({ feedbackSubmitted: true });\r\n } catch (err) {\r\n console.error('Lumely: Failed to submit feedback', err);\r\n this.setState({ feedbackSubmitted: true });\r\n }\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","'use client';\r\n\r\nimport React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\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 environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config}>\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 g=createContext(null),R=()=>{if(typeof window=="undefined")return "server";let r=sessionStorage.getItem("lumely_session_id");if(r)return r;let a=`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;return sessionStorage.setItem("lumely_session_id",a),a},C=()=>{let r=useContext(g);if(!r)throw new Error("useLumelyContext must be used within a LumelyProvider");return r},f=({children:r,config:a})=>{let o=useMemo(()=>({...a,sessionId:a.sessionId||R(),environment:a.environment||"production"}),[a]);return jsx(g.Provider,{value:o,children:r})};var B=()=>{if(typeof document=="undefined"||document.getElementById("lumely-next-styles"))return;let r=document.createElement("style");r.id="lumely-next-styles",r.textContent=`
1
+ import {createContext,useContext,useState,useEffect,Component,useMemo,useCallback}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var g=createContext(null),I=()=>{if(typeof window=="undefined")return "server";let i=sessionStorage.getItem("lumely_session_id");if(i)return i;let s=`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;return sessionStorage.setItem("lumely_session_id",s),s},C=()=>{let i=useContext(g);if(!i)throw new Error("useLumelyContext must be used within a LumelyProvider");return i},P=()=>{let i=useContext(g);if(!i)throw new Error("useLumelyReport must be used within a LumelyProvider");return {reportError:i.reportError}},x=({children:i,config:s})=>{let o=useMemo(()=>s.sessionId||I(),[s.sessionId]),n=useCallback(async(l,a)=>{var u;let t={errorMessage:l.message,errorStack:l.stack,context:{url:typeof window!="undefined"?window.location.href:"server",userAgent:typeof navigator!="undefined"?navigator.userAgent:"server",userId:s.userId,sessionId:o,timestamp:new Date().toISOString(),...a&&{additionalContext:JSON.stringify(a)}}};try{let c=await fetch("/api/lumely/report-error",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":s.apiKey},body:JSON.stringify(t)});c.ok||console.error("[Lumely] Failed to report error:",c.statusText),(u=s.onError)==null||u.call(s,t);}catch(c){console.error("[Lumely] Error reporting failed:",c);}},[s,o]);useEffect(()=>{if(typeof window=="undefined")return;let l=t=>{let u=t.reason instanceof Error?t.reason:new Error(String(t.reason));n(u,{type:"unhandledRejection"});},a=t=>{let u=t.error instanceof Error?t.error:new Error(t.message);n(u,{type:"globalError",filename:t.filename,lineno:t.lineno,colno:t.colno});};return window.addEventListener("unhandledrejection",l),window.addEventListener("error",a),()=>{window.removeEventListener("unhandledrejection",l),window.removeEventListener("error",a);}},[n]);let d=useMemo(()=>({...s,sessionId:o,environment:s.environment||"production",reportError:n}),[s,o,n]);return jsx(g.Provider,{value:d,children:i})};var j=()=>{if(typeof document=="undefined"||document.getElementById("lumely-next-styles"))return;let i=document.createElement("style");i.id="lumely-next-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(r);},P=()=>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"})]}),F=()=>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"})]}),W=()=>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"})]}),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:"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"}},m=({aiResponse:r,isLoading:a,feedbackSubmitted:o=false,onSubmitFeedback:n,onRetry:s,onDismiss:d,onGoBack:l})=>{let[p,h]=useState(""),[y,v]=useState(false);useEffect(()=>{B();},[]);let L=c=>{c.preventDefault(),p.trim()&&!y&&(v(true),n(p));};return jsx("div",{style:t.overlay,children:jsxs("div",{style:t.card,children:[jsx("button",{style:t.closeButton,onClick:d,children:jsx(P,{})}),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"})]})]}),a?jsxs("div",{style:t.loading,children:[jsx("div",{style:t.spinner}),jsx("span",{children:"Analyzing the issue..."})]}):r?jsx("div",{style:t.messageBox,children:jsx("p",{style:t.message,children:r.userMessage})}):jsx("div",{style:t.messageBox,children:jsx("p",{style:t.message,children:"We encountered an unexpected issue. Our team has been notified."})}),!o&&!y?jsxs("form",{style:t.form,onSubmit:L,children:[jsx("label",{style:t.label,children:"What were you trying to do?"}),jsxs("div",{style:t.inputWrapper,children:[jsx("input",{type:"text",value:p,onChange:c=>h(c.target.value),placeholder:"e.g., I was trying to save my changes...",style:t.input}),jsx("button",{type:"submit",disabled:!p.trim(),style:{...t.submitButton,opacity:p.trim()?1:.3},children:jsx(A,{})})]})]}):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:[jsxs("button",{style:{...t.button,...t.secondaryButton},onClick:l,children:[jsx(F,{}),"Go Back"]}),jsxs("button",{style:{...t.button,...t.primaryButton},onClick:s,children:[jsx(W,{}),"Try Again"]})]})]})]})})};var u=class extends Component{constructor(o){super(o);this.isReporting=false;this.handleSubmitFeedback=async o=>{let{errorId:n}=this.state,{config:s}=this.props;if(!n||n==="no-db"||n==="db-error"){this.setState({feedbackSubmitted:true});return}try{await fetch("/api/lumely/update-feedback",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":s.apiKey},body:JSON.stringify({errorId:n,feedback:o})}),this.setState({feedbackSubmitted:!0});}catch(d){console.error("Lumely: Failed to submit feedback",d),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(o){return {hasError:true,error:o}}componentDidCatch(o,n){this.isReporting||(this.isReporting=true,this.setState({errorInfo:n,isLoading:true}),this.reportError(o,n));}async reportError(o,n){let{config:s}=this.props,d={errorMessage:o.message,errorStack:o.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()}};try{let l=await fetch("/api/lumely/report-error",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":s.apiKey},body:JSON.stringify(d)});if(l.ok){let p=await l.json();this.setState({aiResponse:p.ai,errorId:p.errorId,isLoading:!1});}else this.setState({isLoading:!1});}catch(l){console.error("Lumely: Failed to report error",l),this.setState({isLoading:false});}s.onError&&s.onError(d);}render(){let{hasError:o,aiResponse:n,isLoading:s,feedbackSubmitted:d}=this.state,{children:l}=this.props;return o?jsxs(Fragment,{children:[l,jsx(m,{aiResponse:n||void 0,isLoading:s,feedbackSubmitted:d,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):l}};var T=({children:r,apiKey:a,environment:o="production",userId:n,sessionId:s,onError:d})=>{let l={apiKey:a,environment:o,userId:n,sessionId:s,onError:d};return jsx(f,{config:l,children:jsx(u,{config:l,children:r})})};export{u as LumelyErrorBoundary,m as LumelyErrorOverlay,T as LumelyProvider,C as useLumelyContext};//# sourceMappingURL=index.mjs.map
7
+ `,document.head.appendChild(i);},O=()=>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"})]}),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:"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"}},f=({aiResponse:i,isLoading:s,feedbackSubmitted:o=false,onSubmitFeedback:n,onRetry:d,onDismiss:l,onGoBack:a})=>{let[t,u]=useState(""),[c,k]=useState(false);useEffect(()=>{j();},[]);let S=y=>{y.preventDefault(),t.trim()&&!c&&(k(true),n(t));};return jsx("div",{style:r.overlay,children:jsxs("div",{style:r.card,children:[jsx("button",{style:r.closeButton,onClick:l,children:jsx(O,{})}),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"})]})]}),s?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."})}),!o&&!c?jsxs("form",{style:r.form,onSubmit:S,children:[jsx("label",{style:r.label,children:"What were you trying to do?"}),jsxs("div",{style:r.inputWrapper,children:[jsx("input",{type:"text",value:t,onChange:y=>u(y.target.value),placeholder:"e.g., I was trying to save my changes...",style:r.input}),jsx("button",{type:"submit",disabled:!t.trim(),style:{...r.submitButton,opacity:t.trim()?1:.3},children:jsx(F,{})})]})]}):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:a,children:[jsx(W,{}),"Go Back"]}),jsxs("button",{style:{...r.button,...r.primaryButton},onClick:d,children:[jsx(z,{}),"Try Again"]})]})]})]})})};var m=class extends Component{constructor(o){super(o);this.isReporting=false;this.handleSubmitFeedback=async o=>{let{errorId:n}=this.state,{config:d}=this.props;if(!n||n==="no-db"||n==="db-error"){this.setState({feedbackSubmitted:true});return}try{await fetch("/api/lumely/update-feedback",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":d.apiKey},body:JSON.stringify({errorId:n,feedback:o})}),this.setState({feedbackSubmitted:!0});}catch(l){console.error("Lumely: Failed to submit feedback",l),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(o){return {hasError:true,error:o}}componentDidCatch(o,n){this.isReporting||(this.isReporting=true,this.setState({errorInfo:n,isLoading:true}),this.reportError(o,n));}async reportError(o,n){let{config:d}=this.props,l={errorMessage:o.message,errorStack:o.stack,componentStack:n.componentStack||void 0,context:{url:typeof window!="undefined"?window.location.href:"",userAgent:typeof navigator!="undefined"?navigator.userAgent:"",userId:d.userId,sessionId:d.sessionId,timestamp:new Date().toISOString()}};try{let a=await fetch("/api/lumely/report-error",{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":d.apiKey},body:JSON.stringify(l)});if(a.ok){let t=await a.json();this.setState({aiResponse:t.ai,errorId:t.errorId,isLoading:!1});}else this.setState({isLoading:!1});}catch(a){console.error("Lumely: Failed to report error",a),this.setState({isLoading:false});}d.onError&&d.onError(l);}render(){let{hasError:o,aiResponse:n,isLoading:d,feedbackSubmitted:l}=this.state,{children:a}=this.props;return o?jsxs(Fragment,{children:[a,jsx(f,{aiResponse:n||void 0,isLoading:d,feedbackSubmitted:l,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):a}};var N=({children:i,apiKey:s,environment:o="production",userId:n,sessionId:d,onError:l})=>{let a={apiKey:s,environment:o,userId:n,sessionId:d,onError:l};return jsx(x,{config:a,children:jsx(m,{config:a,children:i})})};export{m as LumelyErrorBoundary,f as LumelyErrorOverlay,N as LumelyProvider,C as useLumelyContext,P as useLumelyReport};//# sourceMappingURL=index.mjs.map
8
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyContext","createContext","generateSessionId","stored","newId","useLumelyContext","context","useContext","LumelyContextProvider","children","config","value","useMemo","jsx","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","feedback","setFeedback","useState","isSubmitting","setIsSubmitting","useEffect","handleSubmit","e","LumelyErrorBoundary","Component","props","errorId","err","error","errorInfo","report","response","data","hasError","Fragment","LumelyProvider","apiKey","environment","userId","sessionId","onError"],"mappings":"wIASMA,CAAAA,CAAgBC,aAAAA,CAAyC,IAAI,CAAA,CAG7DC,EAAoB,IAAM,CAC5B,GAAI,OAAO,QAAW,WAAA,CAAa,OAAO,QAAA,CAC1C,IAAMC,EAAS,cAAA,CAAe,OAAA,CAAQ,mBAAmB,CAAA,CACzD,GAAIA,CAAAA,CAAQ,OAAOA,CAAAA,CACnB,IAAMC,EAAQ,CAAA,KAAA,EAAQ,IAAA,CAAK,GAAA,EAAK,IAAI,IAAA,CAAK,MAAA,EAAO,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,SAAA,CAAU,CAAA,CAAG,CAAC,CAAC,CAAA,CAAA,CAC9E,OAAA,cAAA,CAAe,OAAA,CAAQ,mBAAA,CAAqBA,CAAK,CAAA,CAC1CA,CACX,CAAA,CAEaC,CAAA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BAAA,CACvB,OAAA,CAAS,IAAA,CAAK,WAAA,CACd,UAAW,IAAA,CAAK,aAAA,CAChB,QAAA,CAAU,IAAA,CAAK,aACnB,CAAA,CAAA,CACJ,CAAA,CAIDhB,CACX,CACJ,ECpKO,IAAMyC,EAAiB,CAAC,CAC3B,QAAA,CAAAzC,CAAAA,CACA,OAAA0C,CAAAA,CACA,WAAA,CAAAC,CAAAA,CAAc,YAAA,CACd,OAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CACJ,CAAA,GAA2B,CACvB,IAAM7C,CAAAA,CAAuB,CACzB,MAAA,CAAAyC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,OAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CACJ,CAAA,CAEA,OACI1C,GAAAA,CAACL,CAAAA,CAAA,CAAsB,MAAA,CAAQE,CAAAA,CAC3B,QAAA,CAAAG,GAAAA,CAACyB,EAAA,CAAoB,MAAA,CAAQ5B,EACxB,QAAA,CAAAD,CAAAA,CACL,EACJ,CAER","file":"index.mjs","sourcesContent":["'use client';\r\n\r\nimport React, { createContext, useContext, useMemo } from 'react';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n sessionId: string;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\n// Generate a unique session ID\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 useLumelyContext = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumelyContext 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 ...config,\r\n sessionId: config.sessionId || generateSessionId(),\r\n environment: config.environment || 'production',\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","'use client';\r\n\r\nimport 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-next-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-next-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","'use client';\r\n\r\nimport React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse, LumelyAPIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\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; // Prevent duplicate reports\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 // Prevent duplicate reports\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 } = 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 try {\r\n const response = await fetch('/api/lumely/report-error', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n const data: LumelyAPIResponse = await response.json();\r\n this.setState({\r\n aiResponse: data.ai,\r\n errorId: data.errorId,\r\n isLoading: false,\r\n });\r\n } else {\r\n this.setState({ isLoading: false });\r\n }\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n this.setState({ isLoading: false });\r\n }\r\n\r\n // Call optional callback\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 { config } = this.props;\r\n\r\n if (!errorId || errorId === 'no-db' || errorId === 'db-error') {\r\n // Can't update if no valid error ID\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n try {\r\n // Update existing error record with feedback\r\n await fetch('/api/lumely/update-feedback', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n this.setState({ feedbackSubmitted: true });\r\n } catch (err) {\r\n console.error('Lumely: Failed to submit feedback', err);\r\n this.setState({ feedbackSubmitted: true });\r\n }\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","'use client';\r\n\r\nimport React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\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 environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n </LumelyContextProvider>\r\n );\r\n};\r\n"]}
1
+ {"version":3,"sources":["../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyContext","createContext","generateSessionId","stored","newId","useLumelyContext","context","useContext","useLumelyReport","LumelyContextProvider","children","config","sessionId","useMemo","reportError","useCallback","error","additionalContext","_a","report","response","e","useEffect","handleUnhandledRejection","event","handleGlobalError","value","jsx","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","feedback","setFeedback","useState","isSubmitting","setIsSubmitting","handleSubmit","LumelyErrorBoundary","Component","props","errorId","err","errorInfo","data","hasError","Fragment","LumelyProvider","apiKey","environment","userId","onError"],"mappings":"gJAUA,IAAMA,CAAAA,CAAgBC,cAAyC,IAAI,CAAA,CAG7DC,CAAAA,CAAoB,IAAM,CAC5B,GAAI,OAAO,MAAA,EAAW,WAAA,CAAa,OAAO,QAAA,CAC1C,IAAMC,EAAS,cAAA,CAAe,OAAA,CAAQ,mBAAmB,CAAA,CACzD,GAAIA,CAAAA,CAAQ,OAAOA,CAAAA,CACnB,IAAMC,EAAQ,CAAA,KAAA,EAAQ,IAAA,CAAK,KAAK,CAAA,CAAA,EAAI,IAAA,CAAK,MAAA,EAAO,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,SAAA,CAAU,EAAG,CAAC,CAAC,GAC9E,OAAA,cAAA,CAAe,OAAA,CAAQ,oBAAqBA,CAAK,CAAA,CAC1CA,CACX,CAAA,CAEaC,CAAAA,CAAmB,IAAM,CAClC,IAAMC,EAAUC,UAAAA,CAAWP,CAAa,CAAA,CACxC,GAAI,CAACM,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,uDAAuD,CAAA,CAE3E,OAAOA,CACX,CAAA,CAgBaE,CAAAA,CAAkB,IAAM,CACjC,IAAMF,CAAAA,CAAUC,WAAWP,CAAa,CAAA,CACxC,GAAI,CAACM,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,sDAAsD,CAAA,CAE1E,OAAO,CAAE,YAAaA,CAAAA,CAAQ,WAAY,CAC9C,CAAA,CAOaG,CAAAA,CAAwB,CAAC,CAAE,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,GAAAA,CAAClB,CAAAA,CAAA,CAAsB,MAAA,CAAQE,CAAAA,CAC3B,QAAA,CAAAgB,GAAAA,CAACuB,EAAA,CAAoB,MAAA,CAAQvC,EACxB,QAAA,CAAAD,CAAAA,CACL,EACJ,CAER","file":"index.mjs","sourcesContent":["'use client';\r\n\r\nimport React, { createContext, useContext, useMemo, useCallback, useEffect } from 'react';\r\nimport type { LumelyConfig, LumelyErrorReport } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n sessionId: string;\r\n reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\n// Generate a unique session ID\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 useLumelyContext = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumelyContext must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\n/**\r\n * Hook for manually reporting errors that aren't caught by the Error Boundary.\r\n * \r\n * Usage:\r\n * ```tsx\r\n * const { reportError } = useLumelyReport();\r\n * \r\n * try {\r\n * await fetchData();\r\n * } catch (error) {\r\n * reportError(error, { action: 'fetching user data' });\r\n * }\r\n * ```\r\n */\r\nexport const useLumelyReport = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumelyReport must be used within a LumelyProvider');\r\n }\r\n return { reportError: context.reportError };\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 sessionId = useMemo(() => config.sessionId || generateSessionId(), [config.sessionId]);\r\n\r\n // Manual error reporting function\r\n const reportError = useCallback(async (error: Error, additionalContext?: Record<string, unknown>) => {\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : 'server',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : 'server',\r\n userId: config.userId,\r\n sessionId: sessionId,\r\n timestamp: new Date().toISOString(),\r\n ...(additionalContext && { additionalContext: JSON.stringify(additionalContext) }),\r\n }\r\n };\r\n\r\n try {\r\n const response = await fetch('/api/lumely/report-error', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (!response.ok) {\r\n console.error('[Lumely] Failed to report error:', response.statusText);\r\n }\r\n\r\n // Call user's onError callback if provided\r\n config.onError?.(report);\r\n } catch (e) {\r\n console.error('[Lumely] Error reporting failed:', e);\r\n }\r\n }, [config, sessionId]);\r\n\r\n // Setup global error handlers for uncaught errors\r\n useEffect(() => {\r\n if (typeof window === 'undefined') return;\r\n\r\n // Catch unhandled promise rejections\r\n const handleUnhandledRejection = (event: PromiseRejectionEvent) => {\r\n const error = event.reason instanceof Error\r\n ? event.reason\r\n : new Error(String(event.reason));\r\n reportError(error, { type: 'unhandledRejection' });\r\n };\r\n\r\n // Catch global errors (non-React)\r\n const handleGlobalError = (event: ErrorEvent) => {\r\n const error = event.error instanceof Error\r\n ? event.error\r\n : new Error(event.message);\r\n reportError(error, {\r\n type: 'globalError',\r\n filename: event.filename,\r\n lineno: event.lineno,\r\n colno: event.colno\r\n });\r\n };\r\n\r\n window.addEventListener('unhandledrejection', handleUnhandledRejection);\r\n window.addEventListener('error', handleGlobalError);\r\n\r\n return () => {\r\n window.removeEventListener('unhandledrejection', handleUnhandledRejection);\r\n window.removeEventListener('error', handleGlobalError);\r\n };\r\n }, [reportError]);\r\n\r\n const value = useMemo(() => ({\r\n ...config,\r\n sessionId,\r\n environment: config.environment || 'production',\r\n reportError,\r\n }), [config, sessionId, reportError]);\r\n\r\n return (\r\n <LumelyContext.Provider value={value}>\r\n {children}\r\n </LumelyContext.Provider>\r\n );\r\n};\r\n","'use client';\r\n\r\nimport 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-next-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-next-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","'use client';\r\n\r\nimport React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse, LumelyAPIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\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; // Prevent duplicate reports\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 // Prevent duplicate reports\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 } = 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 try {\r\n const response = await fetch('/api/lumely/report-error', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n const data: LumelyAPIResponse = await response.json();\r\n this.setState({\r\n aiResponse: data.ai,\r\n errorId: data.errorId,\r\n isLoading: false,\r\n });\r\n } else {\r\n this.setState({ isLoading: false });\r\n }\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n this.setState({ isLoading: false });\r\n }\r\n\r\n // Call optional callback\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 { config } = this.props;\r\n\r\n if (!errorId || errorId === 'no-db' || errorId === 'db-error') {\r\n // Can't update if no valid error ID\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n try {\r\n // Update existing error record with feedback\r\n await fetch('/api/lumely/update-feedback', {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': config.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n this.setState({ feedbackSubmitted: true });\r\n } catch (err) {\r\n console.error('Lumely: Failed to submit feedback', err);\r\n this.setState({ feedbackSubmitted: true });\r\n }\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","'use client';\r\n\r\nimport React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\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 environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config}>\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-next",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "AI-powered error handling for Next.js applications",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",