lumely-react 0.1.2 → 0.1.4
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 +52 -22
- package/dist/index.d.mts +46 -5
- package/dist/index.d.ts +46 -5
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,22 +10,45 @@ npm install lumely-react
|
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
+
Just wrap your app with `LumelyProvider` and add your API key:
|
|
14
|
+
|
|
13
15
|
```tsx
|
|
14
16
|
import { LumelyProvider } from 'lumely-react';
|
|
15
17
|
|
|
16
18
|
function App() {
|
|
17
19
|
return (
|
|
18
|
-
<LumelyProvider
|
|
19
|
-
apiKey="your-lumely-api-key"
|
|
20
|
-
apiEndpoint="https://api.lumely.com/api/lumely"
|
|
21
|
-
>
|
|
20
|
+
<LumelyProvider apiKey={import.meta.env.VITE_LUMELY_API_KEY ?? ''}>
|
|
22
21
|
<YourApp />
|
|
23
22
|
</LumelyProvider>
|
|
24
23
|
);
|
|
25
24
|
}
|
|
26
25
|
```
|
|
27
26
|
|
|
28
|
-
That's it
|
|
27
|
+
That's it! Lumely will automatically:
|
|
28
|
+
- Catch errors and display a user-friendly overlay
|
|
29
|
+
- Send error data to Lumely's hosted backend
|
|
30
|
+
- Generate AI-powered explanations and fix suggestions
|
|
31
|
+
- Store errors in your Lumely dashboard
|
|
32
|
+
|
|
33
|
+
## Get Your API Key
|
|
34
|
+
|
|
35
|
+
1. Sign up at [lumely.vercel.app](https://lumely.vercel.app)
|
|
36
|
+
2. Create a project
|
|
37
|
+
3. Copy your API key from the project settings
|
|
38
|
+
|
|
39
|
+
## Environment Variables
|
|
40
|
+
|
|
41
|
+
Add your API key to your environment file:
|
|
42
|
+
|
|
43
|
+
**Vite:**
|
|
44
|
+
```
|
|
45
|
+
VITE_LUMELY_API_KEY=lum_your_api_key_here
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Create React App:**
|
|
49
|
+
```
|
|
50
|
+
REACT_APP_LUMELY_API_KEY=lum_your_api_key_here
|
|
51
|
+
```
|
|
29
52
|
|
|
30
53
|
## Features
|
|
31
54
|
|
|
@@ -33,30 +56,37 @@ That's it. Lumely will automatically catch errors and display a user-friendly ov
|
|
|
33
56
|
- **User Feedback** - Collect context about what users were doing
|
|
34
57
|
- **Modern Glassmorphism UI** - Beautiful, customizable overlay
|
|
35
58
|
- **Fast Response** - User message appears in ~2s, detailed analysis runs in background
|
|
36
|
-
- **
|
|
59
|
+
- **Zero Config** - Works out of the box with Lumely's hosted backend
|
|
37
60
|
|
|
38
61
|
## Props
|
|
39
62
|
|
|
40
|
-
| Prop | Type | Required | Description |
|
|
41
|
-
|
|
42
|
-
| `apiKey` |
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
| `onError` | `(report) => void` | No | Callback when error is caught |
|
|
63
|
+
| Prop | Type | Required | Default | Description |
|
|
64
|
+
|------|------|----------|---------|-------------|
|
|
65
|
+
| `apiKey` | string | Yes | - | Your Lumely API key |
|
|
66
|
+
| `environment` | 'development' \| 'production' | No | 'production' | Current environment |
|
|
67
|
+
| `userId` | string | No | - | Optional user identifier |
|
|
68
|
+
|
|
69
|
+
## Manual Error Reporting
|
|
48
70
|
|
|
49
|
-
|
|
71
|
+
Report caught errors that don't crash the app:
|
|
50
72
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
73
|
+
```tsx
|
|
74
|
+
import { useLumelyReport } from 'lumely-react';
|
|
75
|
+
|
|
76
|
+
function MyComponent() {
|
|
77
|
+
const { reportError } = useLumelyReport();
|
|
56
78
|
|
|
57
|
-
|
|
79
|
+
const handleClick = async () => {
|
|
80
|
+
try {
|
|
81
|
+
await fetch('/api/action');
|
|
82
|
+
} catch (error) {
|
|
83
|
+
reportError(error, { action: 'button_click' });
|
|
84
|
+
}
|
|
85
|
+
};
|
|
58
86
|
|
|
59
|
-
|
|
87
|
+
return <button onClick={handleClick}>Action</button>;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
60
90
|
|
|
61
91
|
## License
|
|
62
92
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React, { Component, ErrorInfo } from 'react';
|
|
2
|
+
import React, { Component, ErrorInfo, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface LumelyConfig {
|
|
5
5
|
apiKey: string;
|
|
6
|
-
apiEndpoint
|
|
6
|
+
apiEndpoint?: string;
|
|
7
7
|
environment?: 'development' | 'production';
|
|
8
8
|
userId?: string;
|
|
9
9
|
sessionId?: string;
|
|
@@ -16,6 +16,7 @@ interface LumelyErrorContext {
|
|
|
16
16
|
sessionId?: string;
|
|
17
17
|
userFeedback?: string;
|
|
18
18
|
timestamp: string;
|
|
19
|
+
additionalContext?: string;
|
|
19
20
|
}
|
|
20
21
|
interface LumelyErrorReport {
|
|
21
22
|
errorMessage: string;
|
|
@@ -37,7 +38,8 @@ interface LumelyAPIResponse {
|
|
|
37
38
|
interface LumelyProviderProps {
|
|
38
39
|
children: React.ReactNode;
|
|
39
40
|
apiKey: string;
|
|
40
|
-
|
|
41
|
+
/** API endpoint for error reporting. Defaults to Lumely's hosted backend. */
|
|
42
|
+
apiEndpoint?: string;
|
|
41
43
|
environment?: 'development' | 'production';
|
|
42
44
|
userId?: string;
|
|
43
45
|
sessionId?: string;
|
|
@@ -67,7 +69,7 @@ declare const LumelyProvider: ({ children, apiKey, apiEndpoint, environment, use
|
|
|
67
69
|
declare class LumelyClient {
|
|
68
70
|
private apiKey;
|
|
69
71
|
private apiEndpoint;
|
|
70
|
-
constructor(apiKey: string, apiEndpoint
|
|
72
|
+
constructor(apiKey: string, apiEndpoint?: string);
|
|
71
73
|
reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse>;
|
|
72
74
|
updateFeedback(errorId: string, feedback: string): Promise<boolean>;
|
|
73
75
|
}
|
|
@@ -113,7 +115,46 @@ declare const LumelyErrorOverlay: ({ aiResponse, isLoading, feedbackSubmitted, o
|
|
|
113
115
|
interface LumelyContextValue extends LumelyConfig {
|
|
114
116
|
client: LumelyClient;
|
|
115
117
|
sessionId: string;
|
|
118
|
+
reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;
|
|
116
119
|
}
|
|
117
120
|
declare const useLumely: () => LumelyContextValue;
|
|
121
|
+
/**
|
|
122
|
+
* Hook for manually reporting errors that aren't caught by the Error Boundary.
|
|
123
|
+
* The error overlay will be shown to the user.
|
|
124
|
+
*
|
|
125
|
+
* Usage:
|
|
126
|
+
* ```tsx
|
|
127
|
+
* const { reportError } = useLumelyReport();
|
|
128
|
+
*
|
|
129
|
+
* try {
|
|
130
|
+
* await fetchData();
|
|
131
|
+
* } catch (error) {
|
|
132
|
+
* reportError(error, { action: 'fetching user data' });
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare const useLumelyReport: () => {
|
|
137
|
+
reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
interface LumelyOverlayState {
|
|
141
|
+
isVisible: boolean;
|
|
142
|
+
error: Error | null;
|
|
143
|
+
isLoading: boolean;
|
|
144
|
+
aiResponse: LumelyAIResponse | null;
|
|
145
|
+
errorId: string | null;
|
|
146
|
+
}
|
|
147
|
+
interface LumelyOverlayContextValue {
|
|
148
|
+
state: LumelyOverlayState;
|
|
149
|
+
showOverlay: (error: Error, aiResponse?: LumelyAIResponse | null, errorId?: string | null) => void;
|
|
150
|
+
hideOverlay: () => void;
|
|
151
|
+
setLoading: (loading: boolean) => void;
|
|
152
|
+
setAiResponse: (response: LumelyAIResponse | null, errorId?: string | null) => void;
|
|
153
|
+
}
|
|
154
|
+
declare const useLumelyOverlay: () => LumelyOverlayContextValue | null;
|
|
155
|
+
interface LumelyOverlayProviderProps {
|
|
156
|
+
children: ReactNode;
|
|
157
|
+
}
|
|
158
|
+
declare const LumelyOverlayProvider: ({ children }: LumelyOverlayProviderProps) => react_jsx_runtime.JSX.Element;
|
|
118
159
|
|
|
119
|
-
export { type LumelyAIResponse, type LumelyAPIResponse, LumelyClient, type LumelyConfig, LumelyErrorBoundary, type LumelyErrorContext, LumelyErrorOverlay, type LumelyErrorReport, LumelyProvider, useLumely };
|
|
160
|
+
export { type LumelyAIResponse, type LumelyAPIResponse, LumelyClient, type LumelyConfig, LumelyErrorBoundary, type LumelyErrorContext, LumelyErrorOverlay, type LumelyErrorReport, LumelyOverlayProvider, LumelyProvider, useLumely, useLumelyOverlay, useLumelyReport };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React, { Component, ErrorInfo } from 'react';
|
|
2
|
+
import React, { Component, ErrorInfo, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface LumelyConfig {
|
|
5
5
|
apiKey: string;
|
|
6
|
-
apiEndpoint
|
|
6
|
+
apiEndpoint?: string;
|
|
7
7
|
environment?: 'development' | 'production';
|
|
8
8
|
userId?: string;
|
|
9
9
|
sessionId?: string;
|
|
@@ -16,6 +16,7 @@ interface LumelyErrorContext {
|
|
|
16
16
|
sessionId?: string;
|
|
17
17
|
userFeedback?: string;
|
|
18
18
|
timestamp: string;
|
|
19
|
+
additionalContext?: string;
|
|
19
20
|
}
|
|
20
21
|
interface LumelyErrorReport {
|
|
21
22
|
errorMessage: string;
|
|
@@ -37,7 +38,8 @@ interface LumelyAPIResponse {
|
|
|
37
38
|
interface LumelyProviderProps {
|
|
38
39
|
children: React.ReactNode;
|
|
39
40
|
apiKey: string;
|
|
40
|
-
|
|
41
|
+
/** API endpoint for error reporting. Defaults to Lumely's hosted backend. */
|
|
42
|
+
apiEndpoint?: string;
|
|
41
43
|
environment?: 'development' | 'production';
|
|
42
44
|
userId?: string;
|
|
43
45
|
sessionId?: string;
|
|
@@ -67,7 +69,7 @@ declare const LumelyProvider: ({ children, apiKey, apiEndpoint, environment, use
|
|
|
67
69
|
declare class LumelyClient {
|
|
68
70
|
private apiKey;
|
|
69
71
|
private apiEndpoint;
|
|
70
|
-
constructor(apiKey: string, apiEndpoint
|
|
72
|
+
constructor(apiKey: string, apiEndpoint?: string);
|
|
71
73
|
reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse>;
|
|
72
74
|
updateFeedback(errorId: string, feedback: string): Promise<boolean>;
|
|
73
75
|
}
|
|
@@ -113,7 +115,46 @@ declare const LumelyErrorOverlay: ({ aiResponse, isLoading, feedbackSubmitted, o
|
|
|
113
115
|
interface LumelyContextValue extends LumelyConfig {
|
|
114
116
|
client: LumelyClient;
|
|
115
117
|
sessionId: string;
|
|
118
|
+
reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;
|
|
116
119
|
}
|
|
117
120
|
declare const useLumely: () => LumelyContextValue;
|
|
121
|
+
/**
|
|
122
|
+
* Hook for manually reporting errors that aren't caught by the Error Boundary.
|
|
123
|
+
* The error overlay will be shown to the user.
|
|
124
|
+
*
|
|
125
|
+
* Usage:
|
|
126
|
+
* ```tsx
|
|
127
|
+
* const { reportError } = useLumelyReport();
|
|
128
|
+
*
|
|
129
|
+
* try {
|
|
130
|
+
* await fetchData();
|
|
131
|
+
* } catch (error) {
|
|
132
|
+
* reportError(error, { action: 'fetching user data' });
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare const useLumelyReport: () => {
|
|
137
|
+
reportError: (error: Error, additionalContext?: Record<string, unknown>) => Promise<void>;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
interface LumelyOverlayState {
|
|
141
|
+
isVisible: boolean;
|
|
142
|
+
error: Error | null;
|
|
143
|
+
isLoading: boolean;
|
|
144
|
+
aiResponse: LumelyAIResponse | null;
|
|
145
|
+
errorId: string | null;
|
|
146
|
+
}
|
|
147
|
+
interface LumelyOverlayContextValue {
|
|
148
|
+
state: LumelyOverlayState;
|
|
149
|
+
showOverlay: (error: Error, aiResponse?: LumelyAIResponse | null, errorId?: string | null) => void;
|
|
150
|
+
hideOverlay: () => void;
|
|
151
|
+
setLoading: (loading: boolean) => void;
|
|
152
|
+
setAiResponse: (response: LumelyAIResponse | null, errorId?: string | null) => void;
|
|
153
|
+
}
|
|
154
|
+
declare const useLumelyOverlay: () => LumelyOverlayContextValue | null;
|
|
155
|
+
interface LumelyOverlayProviderProps {
|
|
156
|
+
children: ReactNode;
|
|
157
|
+
}
|
|
158
|
+
declare const LumelyOverlayProvider: ({ children }: LumelyOverlayProviderProps) => react_jsx_runtime.JSX.Element;
|
|
118
159
|
|
|
119
|
-
export { type LumelyAIResponse, type LumelyAPIResponse, LumelyClient, type LumelyConfig, LumelyErrorBoundary, type LumelyErrorContext, LumelyErrorOverlay, type LumelyErrorReport, LumelyProvider, useLumely };
|
|
160
|
+
export { type LumelyAIResponse, type LumelyAPIResponse, LumelyClient, type LumelyConfig, LumelyErrorBoundary, type LumelyErrorContext, LumelyErrorOverlay, type LumelyErrorReport, LumelyOverlayProvider, LumelyProvider, useLumely, useLumelyOverlay, useLumelyReport };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var M=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var M__default=/*#__PURE__*/_interopDefault(M);var f="https://lumely.vercel.app/api/lumely";var g=class{constructor(e,r){this.apiKey=e,this.apiEndpoint=r||f;}async reportError(e){try{let r=await fetch(`${this.apiEndpoint}/report-error`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify(e)});if(r.ok)return await r.json();throw new Error("Failed to report error")}catch(r){return console.error("Lumely: Failed to report error",r),{success:false,ai:{userMessage:"Something went wrong. We're looking into it.",summary:"",suggestedFix:""},errorId:"client-error"}}}async updateFeedback(e,r){try{return (await fetch(`${this.apiEndpoint}/update-feedback`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify({errorId:e,feedback:r})})).ok}catch(s){return console.error("Lumely: Failed to update feedback",s),false}}};var R=M.createContext(null),b=()=>M.useContext(R),E=({children:a})=>{let[e,r]=M.useState({isVisible:false,error:null,isLoading:false,aiResponse:null,errorId:null}),s=M.useCallback((n,u,l)=>{r({isVisible:true,error:n,isLoading:!u,aiResponse:u||null,errorId:l||null});},[]),t=M.useCallback(()=>{r({isVisible:false,error:null,isLoading:false,aiResponse:null,errorId:null});},[]),d=M.useCallback(n=>{r(u=>({...u,isLoading:n}));},[]),c=M.useCallback((n,u)=>{r(l=>({...l,aiResponse:n,errorId:u||l.errorId,isLoading:false}));},[]);return jsxRuntime.jsx(R.Provider,{value:{state:e,showOverlay:s,hideOverlay:t,setLoading:d,setAiResponse:c},children:a})};var k=M.createContext(null),T=()=>typeof window=="undefined"?null:sessionStorage.getItem("lumely_session_id"),W=()=>`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,j=()=>{let a=M.useContext(k);if(!a)throw new Error("useLumely must be used within a LumelyProvider");return a},z=()=>{let a=M.useContext(k);if(!a)throw new Error("useLumelyReport must be used within a LumelyProvider");return {reportError:a.reportError}},P=({children:a,config:e})=>{let[r]=M__default.default.useState(()=>e.sessionId?e.sessionId:T()||W());M.useEffect(()=>{typeof window!="undefined"&&!e.sessionId&&r!=="server"&&(sessionStorage.getItem("lumely_session_id")||sessionStorage.setItem("lumely_session_id",r));},[r,e.sessionId]);let s=M.useMemo(()=>{var n;return new g(e.apiKey,(n=e.apiEndpoint)!=null?n:f)},[e.apiKey,e.apiEndpoint]),t=b(),d=M.useCallback(async(n,u)=>{var m;let l={errorMessage:n.message,errorStack:n.stack,context:{url:typeof window!="undefined"?window.location.href:"server",userAgent:typeof navigator!="undefined"?navigator.userAgent:"server",userId:e.userId,sessionId:r,timestamp:new Date().toISOString(),...u&&{additionalContext:JSON.stringify(u)}}};t==null||t.showOverlay(n);try{let y=await s.reportError(l);y&&y.ai?t==null||t.setAiResponse(y.ai,y.errorId):t==null||t.setLoading(!1),(m=e.onError)==null||m.call(e,l);}catch(y){console.error("[Lumely] Error reporting failed:",y),t==null||t.setLoading(false);}},[s,e,r,t]);M.useEffect(()=>{if(typeof window=="undefined")return;let n=l=>{let m=l.reason instanceof Error?l.reason:new Error(String(l.reason));d(m);},u=l=>{let m=l.error instanceof Error?l.error:new Error(l.message);d(m);};return window.addEventListener("unhandledrejection",n),window.addEventListener("error",u),()=>{window.removeEventListener("unhandledrejection",n),window.removeEventListener("error",u);}},[d]);let c=M.useMemo(()=>({...e,sessionId:r,environment:e.environment||"production",client:s,reportError:d}),[e,r,s,d]);return jsxRuntime.jsx(k.Provider,{value:c,children:a})};var G=()=>{if(typeof document=="undefined"||document.getElementById("lumely-react-styles"))return;let a=document.createElement("style");a.id="lumely-react-styles",a.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(
|
|
7
|
+
`,document.head.appendChild(a);},U=()=>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"})]}),Y=()=>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"})]}),$=()=>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"})]}),J=()=>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"})]}),i={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"}},h=({aiResponse:a,isLoading:e,feedbackSubmitted:r=false,onSubmitFeedback:s,onRetry:t,onDismiss:d,onGoBack:c})=>{let[n,u]=M.useState(""),[l,m]=M.useState(false);M.useEffect(()=>{G();},[]);let y=I=>{I.preventDefault(),n.trim()&&!l&&(m(true),s(n));};return jsxRuntime.jsx("div",{style:i.overlay,children:jsxRuntime.jsxs("div",{style:i.card,children:[jsxRuntime.jsx("button",{style:i.closeButton,onClick:d,children:jsxRuntime.jsx(U,{})}),jsxRuntime.jsxs("div",{style:i.content,children:[jsxRuntime.jsxs("div",{style:i.header,children:[jsxRuntime.jsx("div",{style:i.logo,children:"L"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{style:i.title,children:"Something went wrong"}),jsxRuntime.jsx("p",{style:i.subtitle,children:"We're looking into it"})]})]}),e?jsxRuntime.jsxs("div",{style:i.loading,children:[jsxRuntime.jsx("div",{style:i.spinner}),jsxRuntime.jsx("span",{children:"Analyzing the issue..."})]}):a?jsxRuntime.jsx("div",{style:i.messageBox,children:jsxRuntime.jsx("p",{style:i.message,children:a.userMessage})}):jsxRuntime.jsx("div",{style:i.messageBox,children:jsxRuntime.jsx("p",{style:i.message,children:"We encountered an unexpected issue. Our team has been notified."})}),!r&&!l?jsxRuntime.jsxs("form",{style:i.form,onSubmit:y,children:[jsxRuntime.jsx("label",{style:i.label,children:"What were you trying to do?"}),jsxRuntime.jsxs("div",{style:i.inputWrapper,children:[jsxRuntime.jsx("input",{type:"text",value:n,onChange:I=>u(I.target.value),placeholder:"e.g., I was trying to save my changes...",style:i.input}),jsxRuntime.jsx("button",{type:"submit",disabled:!n.trim(),style:{...i.submitButton,opacity:n.trim()?1:.3},children:jsxRuntime.jsx(Y,{})})]})]}):jsxRuntime.jsx("div",{style:i.successBox,children:jsxRuntime.jsx("p",{style:i.successText,children:"Thank you! Your feedback helps us improve."})}),jsxRuntime.jsxs("div",{style:i.buttons,children:[jsxRuntime.jsxs("button",{style:{...i.button,...i.secondaryButton},onClick:c,children:[jsxRuntime.jsx($,{}),"Go Back"]}),jsxRuntime.jsxs("button",{style:{...i.button,...i.primaryButton},onClick:t,children:[jsxRuntime.jsx(J,{}),"Try Again"]})]})]})]})})};var L=class extends M.Component{constructor(r){super(r);this.isReporting=false;this.handleSubmitFeedback=async r=>{let{errorId:s}=this.state,{client:t}=this.props;if(!s||s==="client-error"){this.setState({feedbackSubmitted:true});return}await t.updateFeedback(s,r),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(r){return {hasError:true,error:r}}componentDidCatch(r,s){this.isReporting||(this.isReporting=true,this.setState({errorInfo:s,isLoading:true}),this.reportError(r,s));}async reportError(r,s){let{config:t,client:d}=this.props,c={errorMessage:r.message,errorStack:r.stack,componentStack:s.componentStack||void 0,context:{url:typeof window!="undefined"?window.location.href:"",userAgent:typeof navigator!="undefined"?navigator.userAgent:"",userId:t.userId,sessionId:t.sessionId,timestamp:new Date().toISOString()}},n=await d.reportError(c);this.setState({aiResponse:n.ai,errorId:n.errorId,isLoading:false}),t.onError&&t.onError(c);}render(){let{hasError:r,aiResponse:s,isLoading:t,feedbackSubmitted:d}=this.state,{children:c}=this.props;return r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[c,jsxRuntime.jsx(h,{aiResponse:s||void 0,isLoading:t,feedbackSubmitted:d,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):c}};var Z=({apiEndpoint:a})=>{let e=b();if(!(e!=null&&e.state.isVisible)||!e.state.error)return null;let r=async t=>{if(e.state.errorId)try{await fetch(`${a}/update-feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({errorId:e.state.errorId,userFeedback:t})});}catch(d){console.error("[Lumely] Failed to submit feedback:",d);}},s=()=>{e.hideOverlay(),typeof window!="undefined"&&window.history.back();};return jsxRuntime.jsx(h,{aiResponse:e.state.aiResponse||void 0,isLoading:e.state.isLoading,feedbackSubmitted:false,onSubmitFeedback:r,onRetry:e.hideOverlay,onDismiss:e.hideOverlay,onGoBack:s})},ee=({children:a,apiKey:e,apiEndpoint:r=f,environment:s="production",userId:t,sessionId:d,onError:c})=>{let n={apiKey:e,apiEndpoint:r,environment:s,userId:t,sessionId:d,onError:c},u=new g(e,r);return jsxRuntime.jsx(E,{children:jsxRuntime.jsxs(P,{config:n,children:[jsxRuntime.jsx(L,{config:n,client:u,children:a}),jsxRuntime.jsx(Z,{apiEndpoint:r})]})})};exports.LumelyClient=g;exports.LumelyErrorBoundary=L;exports.LumelyErrorOverlay=h;exports.LumelyOverlayProvider=E;exports.LumelyProvider=ee;exports.useLumely=j;exports.useLumelyOverlay=b;exports.useLumelyReport=z;//# sourceMappingURL=index.js.map
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../LumelyClient.ts","../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyClient","apiKey","apiEndpoint","report","response","err","errorId","feedback","LumelyContext","createContext","generateSessionId","stored","newId","useLumely","context","useContext","LumelyContextProvider","children","config","value","useMemo","sessionId","client","jsx","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","setFeedback","useState","isSubmitting","setIsSubmitting","useEffect","handleSubmit","e","LumelyErrorBoundary","Component","props","error","errorInfo","hasError","Fragment","LumelyProvider","environment","userId","onError"],"mappings":"gFAEO,IAAMA,CAAAA,CAAN,KAAmB,CAItB,WAAA,CAAYC,CAAAA,CAAgBC,CAAAA,CAAqB,CAC7C,IAAA,CAAK,MAAA,CAASD,CAAAA,CACd,IAAA,CAAK,YAAcC,EACvB,CAEA,MAAM,WAAA,CAAYC,EAAuD,CACrE,GAAI,CACA,IAAMC,EAAW,MAAM,KAAA,CAAM,CAAA,EAAG,IAAA,CAAK,WAAW,CAAA,aAAA,CAAA,CAAiB,CAC7D,MAAA,CAAQ,MAAA,CACR,OAAA,CAAS,CACL,cAAA,CAAgB,kBAAA,CAChB,eAAgB,IAAA,CAAK,MACzB,CAAA,CACA,IAAA,CAAM,KAAK,SAAA,CAAUD,CAAM,CAC/B,CAAC,EAED,GAAIC,CAAAA,CAAS,EAAA,CACT,OAAO,MAAMA,CAAAA,CAAS,IAAA,EAAK,CAG/B,MAAM,IAAI,KAAA,CAAM,wBAAwB,CAC5C,CAAA,MAASC,EAAK,CACV,OAAA,OAAA,CAAQ,KAAA,CAAM,gCAAA,CAAkCA,CAAG,CAAA,CAC5C,CACH,OAAA,CAAS,KAAA,CACT,EAAA,CAAI,CACA,WAAA,CAAa,8CAAA,CACb,QAAS,EAAA,CACT,YAAA,CAAc,EAClB,CAAA,CACA,QAAS,cACb,CACJ,CACJ,CAEA,MAAM,cAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAAoC,CACtE,GAAI,CAUA,OAAA,CATiB,MAAM,KAAA,CAAM,GAAG,IAAA,CAAK,WAAW,CAAA,gBAAA,CAAA,CAAoB,CAChE,OAAQ,MAAA,CACR,OAAA,CAAS,CACL,cAAA,CAAgB,mBAChB,cAAA,CAAgB,IAAA,CAAK,MACzB,CAAA,CACA,IAAA,CAAM,IAAA,CAAK,SAAA,CAAU,C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,CAAAA,CACL,EACJ,CAER","file":"index.js","sourcesContent":["import type { LumelyErrorReport, LumelyAPIResponse } from './types';\r\n\r\nexport class LumelyClient {\r\n private apiKey: string;\r\n private apiEndpoint: string;\r\n\r\n constructor(apiKey: string, apiEndpoint: string) {\r\n this.apiKey = apiKey;\r\n this.apiEndpoint = apiEndpoint;\r\n }\r\n\r\n async reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/report-error`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n return await response.json();\r\n }\r\n\r\n throw new Error('Failed to report error');\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n return {\r\n success: false,\r\n ai: {\r\n userMessage: \"Something went wrong. We're looking into it.\",\r\n summary: '',\r\n suggestedFix: '',\r\n },\r\n errorId: 'client-error',\r\n };\r\n }\r\n }\r\n\r\n async updateFeedback(errorId: string, feedback: string): Promise<boolean> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n return response.ok;\r\n } catch (err) {\r\n console.error('Lumely: Failed to update feedback', err);\r\n return false;\r\n }\r\n }\r\n}\r\n","import React, { createContext, useContext, useMemo } from 'react';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n client: LumelyClient;\r\n sessionId: string;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\nconst generateSessionId = () => {\r\n if (typeof window === 'undefined') return 'server';\r\n const stored = sessionStorage.getItem('lumely_session_id');\r\n if (stored) return stored;\r\n const newId = `sess_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\r\n sessionStorage.setItem('lumely_session_id', newId);\r\n return newId;\r\n};\r\n\r\nexport const useLumely = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumely must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\ninterface LumelyContextProviderProps {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n}\r\n\r\nexport const LumelyContextProvider = ({ children, config }: LumelyContextProviderProps) => {\r\n const value = useMemo(() => {\r\n const sessionId = config.sessionId || generateSessionId();\r\n const client = new LumelyClient(config.apiKey, config.apiEndpoint);\r\n\r\n return {\r\n ...config,\r\n sessionId,\r\n environment: config.environment || 'production',\r\n client,\r\n };\r\n }, [config]);\r\n\r\n return (\r\n <LumelyContext.Provider value={value}>\r\n {children}\r\n </LumelyContext.Provider>\r\n );\r\n};\r\n","import React, { useState, useEffect } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Inject Poppins font and keyframes\r\nconst injectStyles = () => {\r\n if (typeof document === 'undefined') return;\r\n if (document.getElementById('lumely-react-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-react-styles';\r\n style.textContent = `\r\n @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');\r\n @keyframes lumely-spin {\r\n from { transform: rotate(0deg); }\r\n to { transform: rotate(360deg); }\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n};\r\n\r\n// SVG Icons as components (replacing lucide-react)\r\nconst XIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n </svg>\r\n);\r\n\r\nconst SendIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\r\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\r\n </svg>\r\n);\r\n\r\nconst ArrowLeftIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line>\r\n <polyline points=\"12 19 5 12 12 5\"></polyline>\r\n </svg>\r\n);\r\n\r\nconst RefreshCwIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <polyline points=\"23 4 23 10 17 10\"></polyline>\r\n <polyline points=\"1 20 1 14 7 14\"></polyline>\r\n <path d=\"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15\"></path>\r\n </svg>\r\n);\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n overlay: {\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 9999,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: '16px',\r\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\r\n backdropFilter: 'blur(8px)',\r\n fontFamily: \"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\r\n },\r\n card: {\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: '448px',\r\n background: 'rgba(255, 255, 255, 0.1)',\r\n backdropFilter: 'blur(24px)',\r\n border: '1px solid rgba(255, 255, 255, 0.2)',\r\n borderRadius: '16px',\r\n overflow: 'hidden',\r\n },\r\n closeButton: {\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n padding: '6px',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n background: 'transparent',\r\n border: 'none',\r\n borderRadius: '8px',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'all 0.2s',\r\n },\r\n content: {\r\n padding: '24px',\r\n },\r\n header: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '12px',\r\n marginBottom: '16px',\r\n },\r\n logo: {\r\n width: '40px',\r\n height: '40px',\r\n borderRadius: '12px',\r\n background: 'linear-gradient(135deg, #7c3aed, #8b5cf6)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n color: 'white',\r\n fontWeight: 700,\r\n fontSize: '18px',\r\n },\r\n title: {\r\n color: 'white',\r\n fontWeight: 600,\r\n fontSize: '14px',\r\n margin: 0,\r\n },\r\n subtitle: {\r\n color: 'rgba(255, 255, 255, 0.5)',\r\n fontSize: '12px',\r\n margin: 0,\r\n },\r\n messageBox: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '16px',\r\n marginBottom: '16px',\r\n },\r\n message: {\r\n color: 'rgba(255, 255, 255, 0.9)',\r\n fontSize: '14px',\r\n lineHeight: 1.6,\r\n margin: 0,\r\n },\r\n loading: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'rgba(255, 255, 255, 0.7)',\r\n fontSize: '14px',\r\n padding: '16px 0',\r\n },\r\n spinner: {\r\n width: '16px',\r\n height: '16px',\r\n border: '2px solid rgba(255, 255, 255, 0.3)',\r\n borderTopColor: 'white',\r\n borderRadius: '50%',\r\n animation: 'lumely-spin 1s linear infinite',\r\n },\r\n form: {\r\n marginBottom: '16px',\r\n },\r\n label: {\r\n display: 'block',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n fontSize: '12px',\r\n marginBottom: '8px',\r\n },\r\n inputWrapper: {\r\n position: 'relative',\r\n },\r\n input: {\r\n width: '100%',\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '12px 48px 12px 16px',\r\n color: 'white',\r\n fontSize: '14px',\r\n outline: 'none',\r\n boxSizing: 'border-box',\r\n transition: 'border-color 0.2s',\r\n },\r\n submitButton: {\r\n position: 'absolute',\r\n right: '8px',\r\n top: '50%',\r\n transform: 'translateY(-50%)',\r\n padding: '8px',\r\n color: 'rgba(255, 255, 255, 0.4)',\r\n background: 'transparent',\r\n border: 'none',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'color 0.2s',\r\n },\r\n successBox: {\r\n background: 'rgba(34, 197, 94, 0.1)',\r\n border: '1px solid rgba(34, 197, 94, 0.2)',\r\n borderRadius: '12px',\r\n padding: '12px',\r\n marginBottom: '16px',\r\n },\r\n successText: {\r\n color: '#4ade80',\r\n fontSize: '12px',\r\n textAlign: 'center',\r\n margin: 0,\r\n },\r\n buttons: {\r\n display: 'flex',\r\n gap: '8px',\r\n },\r\n button: {\r\n flex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n gap: '8px',\r\n padding: '10px 16px',\r\n borderRadius: '12px',\r\n fontSize: '14px',\r\n fontWeight: 500,\r\n cursor: 'pointer',\r\n border: 'none',\r\n transition: 'all 0.2s',\r\n },\r\n secondaryButton: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n color: 'rgba(255, 255, 255, 0.8)',\r\n },\r\n primaryButton: {\r\n background: '#7c3aed',\r\n color: 'white',\r\n },\r\n};\r\n\r\ninterface LumelyErrorOverlayProps {\r\n aiResponse?: LumelyAIResponse;\r\n isLoading: boolean;\r\n feedbackSubmitted?: boolean;\r\n onSubmitFeedback: (feedback: string) => void;\r\n onRetry: () => void;\r\n onDismiss: () => void;\r\n onGoBack: () => void;\r\n}\r\n\r\nexport const LumelyErrorOverlay = ({\r\n aiResponse,\r\n isLoading,\r\n feedbackSubmitted = false,\r\n onSubmitFeedback,\r\n onRetry,\r\n onDismiss,\r\n onGoBack,\r\n}: LumelyErrorOverlayProps) => {\r\n const [feedback, setFeedback] = useState('');\r\n const [isSubmitting, setIsSubmitting] = useState(false);\r\n\r\n useEffect(() => {\r\n injectStyles();\r\n }, []);\r\n\r\n const handleSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n if (feedback.trim() && !isSubmitting) {\r\n setIsSubmitting(true);\r\n onSubmitFeedback(feedback);\r\n }\r\n };\r\n\r\n return (\r\n <div style={styles.overlay}>\r\n <div style={styles.card}>\r\n {/* Close Button */}\r\n <button style={styles.closeButton} onClick={onDismiss}>\r\n <XIcon />\r\n </button>\r\n\r\n <div style={styles.content}>\r\n {/* Header */}\r\n <div style={styles.header}>\r\n <div style={styles.logo}>L</div>\r\n <div>\r\n <h3 style={styles.title}>Something went wrong</h3>\r\n <p style={styles.subtitle}>We're looking into it</p>\r\n </div>\r\n </div>\r\n\r\n {/* AI Message */}\r\n {isLoading ? (\r\n <div style={styles.loading}>\r\n <div style={styles.spinner} />\r\n <span>Analyzing the issue...</span>\r\n </div>\r\n ) : aiResponse ? (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>{aiResponse.userMessage}</p>\r\n </div>\r\n ) : (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>\r\n We encountered an unexpected issue. Our team has been notified.\r\n </p>\r\n </div>\r\n )}\r\n\r\n {/* Feedback Input */}\r\n {!feedbackSubmitted && !isSubmitting ? (\r\n <form style={styles.form} onSubmit={handleSubmit}>\r\n <label style={styles.label}>What were you trying to do?</label>\r\n <div style={styles.inputWrapper}>\r\n <input\r\n type=\"text\"\r\n value={feedback}\r\n onChange={(e) => setFeedback(e.target.value)}\r\n placeholder=\"e.g., I was trying to save my changes...\"\r\n style={styles.input}\r\n />\r\n <button\r\n type=\"submit\"\r\n disabled={!feedback.trim()}\r\n style={{\r\n ...styles.submitButton,\r\n opacity: feedback.trim() ? 1 : 0.3,\r\n }}\r\n >\r\n <SendIcon />\r\n </button>\r\n </div>\r\n </form>\r\n ) : (\r\n <div style={styles.successBox}>\r\n <p style={styles.successText}>Thank you! Your feedback helps us improve.</p>\r\n </div>\r\n )}\r\n\r\n {/* Action Buttons */}\r\n <div style={styles.buttons}>\r\n <button\r\n style={{ ...styles.button, ...styles.secondaryButton }}\r\n onClick={onGoBack}\r\n >\r\n <ArrowLeftIcon />\r\n Go Back\r\n </button>\r\n <button\r\n style={{ ...styles.button, ...styles.primaryButton }}\r\n onClick={onRetry}\r\n >\r\n <RefreshCwIcon />\r\n Try Again\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n client: LumelyClient;\r\n}\r\n\r\ninterface State {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n aiResponse: LumelyAIResponse | null;\r\n isLoading: boolean;\r\n errorId: string | null;\r\n feedbackSubmitted: boolean;\r\n}\r\n\r\nexport class LumelyErrorBoundary extends Component<Props, State> {\r\n private isReporting = false;\r\n\r\n constructor(props: Props) {\r\n super(props);\r\n this.state = {\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): Partial<State> {\r\n return { hasError: true, error };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\r\n if (this.isReporting) return;\r\n\r\n this.isReporting = true;\r\n this.setState({ errorInfo, isLoading: true });\r\n this.reportError(error, errorInfo);\r\n }\r\n\r\n private async reportError(error: Error, errorInfo: ErrorInfo) {\r\n const { config, client } = this.props;\r\n\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n componentStack: errorInfo.componentStack || undefined,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : '',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',\r\n userId: config.userId,\r\n sessionId: config.sessionId,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const response = await client.reportError(report);\r\n\r\n this.setState({\r\n aiResponse: response.ai,\r\n errorId: response.errorId,\r\n isLoading: false,\r\n });\r\n\r\n if (config.onError) {\r\n config.onError(report);\r\n }\r\n }\r\n\r\n private handleSubmitFeedback = async (feedback: string) => {\r\n const { errorId } = this.state;\r\n const { client } = this.props;\r\n\r\n if (!errorId || errorId === 'client-error') {\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n await client.updateFeedback(errorId, feedback);\r\n this.setState({ feedbackSubmitted: true });\r\n };\r\n\r\n private handleRetry = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleDismiss = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleGoBack = () => {\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n render() {\r\n const { hasError, aiResponse, isLoading, feedbackSubmitted } = this.state;\r\n const { children } = this.props;\r\n\r\n if (hasError) {\r\n return (\r\n <>\r\n {children}\r\n <LumelyErrorOverlay\r\n aiResponse={aiResponse || undefined}\r\n isLoading={isLoading}\r\n feedbackSubmitted={feedbackSubmitted}\r\n onSubmitFeedback={this.handleSubmitFeedback}\r\n onRetry={this.handleRetry}\r\n onDismiss={this.handleDismiss}\r\n onGoBack={this.handleGoBack}\r\n />\r\n </>\r\n );\r\n }\r\n\r\n return children;\r\n }\r\n}\r\n","import React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n apiEndpoint: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\n/**\r\n * LumelyProvider for Plain React (Vite, CRA, etc.)\r\n * \r\n * Usage:\r\n * ```tsx\r\n * import { LumelyProvider } from './components/lumely-react';\r\n * \r\n * function App() {\r\n * return (\r\n * <LumelyProvider \r\n * apiKey=\"your-api-key\"\r\n * apiEndpoint=\"https://your-api.com/api/lumely\"\r\n * >\r\n * <YourApp />\r\n * </LumelyProvider>\r\n * );\r\n * }\r\n * ```\r\n */\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\r\n apiEndpoint,\r\n environment = 'production',\r\n userId,\r\n sessionId,\r\n onError,\r\n}: LumelyProviderProps) => {\r\n const config: LumelyConfig = {\r\n apiKey,\r\n apiEndpoint,\r\n environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n const client = new LumelyClient(apiKey, apiEndpoint);\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config} client={client}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n </LumelyContextProvider>\r\n );\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../types.ts","../LumelyClient.ts","../LumelyOverlayContext.tsx","../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LUMELY_API_ENDPOINT","LumelyClient","apiKey","apiEndpoint","report","response","err","errorId","feedback","LumelyOverlayContext","createContext","useLumelyOverlay","useContext","LumelyOverlayProvider","children","state","setState","useState","showOverlay","useCallback","error","aiResponse","hideOverlay","setLoading","loading","prev","setAiResponse","jsx","LumelyContext","getStoredSessionId","createSessionId","useLumely","context","useLumelyReport","LumelyContextProvider","config","sessionId","React","useEffect","client","useMemo","_a","overlay","reportError","additionalContext","e","handleUnhandledRejection","event","handleGlobalError","value","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","setFeedback","isSubmitting","setIsSubmitting","handleSubmit","LumelyErrorBoundary","Component","props","errorInfo","hasError","Fragment","ManualErrorOverlay","handleSubmitFeedback","handleGoBack","LumelyProvider","environment","userId","onError"],"mappings":"4LACO,IAAMA,CAAAA,CAAsB,sCAAA,KCEtBC,CAAAA,CAAN,KAAmB,CAItB,WAAA,CAAYC,CAAAA,CAAgBC,CAAAA,CAAsB,CAC9C,KAAK,MAAA,CAASD,CAAAA,CACd,KAAK,WAAA,CAAcC,CAAAA,EAAeH,EACtC,CAEA,MAAM,YAAYI,CAAAA,CAAuD,CACrE,GAAI,CACA,IAAMC,EAAW,MAAM,KAAA,CAAM,GAAG,IAAA,CAAK,WAAW,CAAA,aAAA,CAAA,CAAiB,CAC7D,OAAQ,MAAA,CACR,OAAA,CAAS,CACL,cAAA,CAAgB,kBAAA,CAChB,eAAgB,IAAA,CAAK,MACzB,EACA,IAAA,CAAM,IAAA,CAAK,UAAUD,CAAM,CAC/B,CAAC,CAAA,CAED,GAAIC,EAAS,EAAA,CACT,OAAO,MAAMA,CAAAA,CAAS,IAAA,GAG1B,MAAM,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AAQI,CAAAA,CACxC,QAAA,CAAAzB,CAAAA,CACL,CAAA,CACAa,eAACgD,CAAAA,CAAA,CAAmB,YAAaxE,CAAAA,CAAa,CAAA,CAAA,CAClD,EACJ,CAER","file":"index.js","sourcesContent":["// Default API endpoint - points to Lumely's hosted backend\r\nexport const LUMELY_API_ENDPOINT = 'https://lumely.vercel.app/api/lumely';\r\n\r\nexport interface LumelyConfig {\r\n apiKey: string;\r\n apiEndpoint?: string; // Defaults to LUMELY_API_ENDPOINT\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: (error: LumelyErrorReport) => void;\r\n}\r\n\r\nexport interface LumelyErrorContext {\r\n url: string;\r\n userAgent: string;\r\n userId?: string;\r\n sessionId?: string;\r\n userFeedback?: string;\r\n timestamp: string;\r\n additionalContext?: string;\r\n}\r\n\r\nexport interface LumelyErrorReport {\r\n errorMessage: string;\r\n errorStack?: string;\r\n componentStack?: string;\r\n context: LumelyErrorContext;\r\n}\r\n\r\nexport interface LumelyAIResponse {\r\n userMessage: string;\r\n summary: string;\r\n suggestedFix: string;\r\n}\r\n\r\nexport interface LumelyAPIResponse {\r\n success: boolean;\r\n ai: LumelyAIResponse;\r\n errorId: string;\r\n}\r\n","import type { LumelyErrorReport, LumelyAPIResponse } from './types';\r\nimport { LUMELY_API_ENDPOINT } from './types';\r\n\r\nexport class LumelyClient {\r\n private apiKey: string;\r\n private apiEndpoint: string;\r\n\r\n constructor(apiKey: string, apiEndpoint?: string) {\r\n this.apiKey = apiKey;\r\n this.apiEndpoint = apiEndpoint || LUMELY_API_ENDPOINT;\r\n }\r\n\r\n async reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/report-error`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n return await response.json();\r\n }\r\n\r\n throw new Error('Failed to report error');\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n return {\r\n success: false,\r\n ai: {\r\n userMessage: \"Something went wrong. We're looking into it.\",\r\n summary: '',\r\n suggestedFix: '',\r\n },\r\n errorId: 'client-error',\r\n };\r\n }\r\n }\r\n\r\n async updateFeedback(errorId: string, feedback: string): Promise<boolean> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n return response.ok;\r\n } catch (err) {\r\n console.error('Lumely: Failed to update feedback', err);\r\n return false;\r\n }\r\n }\r\n}\r\n","'use client';\r\n\r\nimport React, { createContext, useContext, useState, useCallback, ReactNode } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Shared error state for overlay\r\ninterface LumelyOverlayState {\r\n isVisible: boolean;\r\n error: Error | null;\r\n isLoading: boolean;\r\n aiResponse: LumelyAIResponse | null;\r\n errorId: string | null;\r\n}\r\n\r\ninterface LumelyOverlayContextValue {\r\n state: LumelyOverlayState;\r\n showOverlay: (error: Error, aiResponse?: LumelyAIResponse | null, errorId?: string | null) => void;\r\n hideOverlay: () => void;\r\n setLoading: (loading: boolean) => void;\r\n setAiResponse: (response: LumelyAIResponse | null, errorId?: string | null) => void;\r\n}\r\n\r\nconst LumelyOverlayContext = createContext<LumelyOverlayContextValue | null>(null);\r\n\r\nexport const useLumelyOverlay = () => {\r\n return useContext(LumelyOverlayContext);\r\n};\r\n\r\ninterface LumelyOverlayProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\nexport const LumelyOverlayProvider = ({ children }: LumelyOverlayProviderProps) => {\r\n const [state, setState] = useState<LumelyOverlayState>({\r\n isVisible: false,\r\n error: null,\r\n isLoading: false,\r\n aiResponse: null,\r\n errorId: null,\r\n });\r\n\r\n const showOverlay = useCallback((error: Error, aiResponse?: LumelyAIResponse | null, errorId?: string | null) => {\r\n setState({\r\n isVisible: true,\r\n error,\r\n isLoading: !aiResponse,\r\n aiResponse: aiResponse || null,\r\n errorId: errorId || null,\r\n });\r\n }, []);\r\n\r\n const hideOverlay = useCallback(() => {\r\n setState({\r\n isVisible: false,\r\n error: null,\r\n isLoading: false,\r\n aiResponse: null,\r\n errorId: null,\r\n });\r\n }, []);\r\n\r\n const setLoading = useCallback((loading: boolean) => {\r\n setState(prev => ({ ...prev, isLoading: loading }));\r\n }, []);\r\n\r\n const setAiResponse = useCallback((response: LumelyAIResponse | null, errorId?: string | null) => {\r\n setState(prev => ({\r\n ...prev,\r\n aiResponse: response,\r\n errorId: errorId || prev.errorId,\r\n isLoading: false\r\n }));\r\n }, []);\r\n\r\n return (\r\n <LumelyOverlayContext.Provider value={{ state, showOverlay, hideOverlay, setLoading, setAiResponse }}>\r\n {children}\r\n </LumelyOverlayContext.Provider>\r\n );\r\n};\r\n","import React, { createContext, useContext, useMemo, useCallback, useEffect } from 'react';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport } from './types';\r\nimport { LUMELY_API_ENDPOINT } from './types';\r\nimport { useLumelyOverlay } from './LumelyOverlayContext';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n client: LumelyClient;\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\nconst getStoredSessionId = () => {\r\n if (typeof window === 'undefined') return null;\r\n return sessionStorage.getItem('lumely_session_id');\r\n};\r\n\r\nconst createSessionId = () => {\r\n return `sess_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\r\n};\r\n\r\nexport const useLumely = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumely must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\n/**\r\n * Hook for manually reporting errors that aren't caught by the Error Boundary.\r\n * The error overlay will be shown to the user.\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] = React.useState(() => {\r\n if (config.sessionId) return config.sessionId;\r\n return getStoredSessionId() || createSessionId();\r\n });\r\n\r\n useEffect(() => {\r\n if (typeof window !== 'undefined' && !config.sessionId && sessionId !== 'server') {\r\n const stored = sessionStorage.getItem('lumely_session_id');\r\n if (!stored) {\r\n sessionStorage.setItem('lumely_session_id', sessionId);\r\n }\r\n }\r\n }, [sessionId, config.sessionId]);\r\n const client = useMemo(() => new LumelyClient(config.apiKey, config.apiEndpoint ?? LUMELY_API_ENDPOINT), [config.apiKey, config.apiEndpoint]);\r\n const overlay = useLumelyOverlay();\r\n\r\n // Manual error reporting function - now shows overlay\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 // Show overlay immediately with loading state\r\n overlay?.showOverlay(error);\r\n\r\n try {\r\n const response = await client.reportError(report);\r\n if (response && response.ai) {\r\n overlay?.setAiResponse(response.ai, response.errorId);\r\n } else {\r\n overlay?.setLoading(false);\r\n }\r\n config.onError?.(report);\r\n } catch (e) {\r\n console.error('[Lumely] Error reporting failed:', e);\r\n overlay?.setLoading(false);\r\n }\r\n }, [client, config, sessionId, overlay]);\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);\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 };\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 client,\r\n reportError,\r\n }), [config, sessionId, client, 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\r\n","import React, { useState, useEffect } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Inject Poppins font and keyframes\r\nconst injectStyles = () => {\r\n if (typeof document === 'undefined') return;\r\n if (document.getElementById('lumely-react-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-react-styles';\r\n style.textContent = `\r\n @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');\r\n @keyframes lumely-spin {\r\n from { transform: rotate(0deg); }\r\n to { transform: rotate(360deg); }\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n};\r\n\r\n// SVG Icons as components (replacing lucide-react)\r\nconst XIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n </svg>\r\n);\r\n\r\nconst SendIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\r\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\r\n </svg>\r\n);\r\n\r\nconst ArrowLeftIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line>\r\n <polyline points=\"12 19 5 12 12 5\"></polyline>\r\n </svg>\r\n);\r\n\r\nconst RefreshCwIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <polyline points=\"23 4 23 10 17 10\"></polyline>\r\n <polyline points=\"1 20 1 14 7 14\"></polyline>\r\n <path d=\"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15\"></path>\r\n </svg>\r\n);\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n overlay: {\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 9999,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: '16px',\r\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\r\n backdropFilter: 'blur(8px)',\r\n fontFamily: \"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\r\n },\r\n card: {\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: '448px',\r\n background: 'rgba(255, 255, 255, 0.1)',\r\n backdropFilter: 'blur(24px)',\r\n border: '1px solid rgba(255, 255, 255, 0.2)',\r\n borderRadius: '16px',\r\n overflow: 'hidden',\r\n },\r\n closeButton: {\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n padding: '6px',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n background: 'transparent',\r\n border: 'none',\r\n borderRadius: '8px',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'all 0.2s',\r\n },\r\n content: {\r\n padding: '24px',\r\n },\r\n header: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '12px',\r\n marginBottom: '16px',\r\n },\r\n logo: {\r\n width: '40px',\r\n height: '40px',\r\n borderRadius: '12px',\r\n background: 'linear-gradient(135deg, #7c3aed, #8b5cf6)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n color: 'white',\r\n fontWeight: 700,\r\n fontSize: '18px',\r\n },\r\n title: {\r\n color: 'white',\r\n fontWeight: 600,\r\n fontSize: '14px',\r\n margin: 0,\r\n },\r\n subtitle: {\r\n color: 'rgba(255, 255, 255, 0.5)',\r\n fontSize: '12px',\r\n margin: 0,\r\n },\r\n messageBox: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '16px',\r\n marginBottom: '16px',\r\n },\r\n message: {\r\n color: 'rgba(255, 255, 255, 0.9)',\r\n fontSize: '14px',\r\n lineHeight: 1.6,\r\n margin: 0,\r\n },\r\n loading: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'rgba(255, 255, 255, 0.7)',\r\n fontSize: '14px',\r\n padding: '16px 0',\r\n },\r\n spinner: {\r\n width: '16px',\r\n height: '16px',\r\n border: '2px solid rgba(255, 255, 255, 0.3)',\r\n borderTopColor: 'white',\r\n borderRadius: '50%',\r\n animation: 'lumely-spin 1s linear infinite',\r\n },\r\n form: {\r\n marginBottom: '16px',\r\n },\r\n label: {\r\n display: 'block',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n fontSize: '12px',\r\n marginBottom: '8px',\r\n },\r\n inputWrapper: {\r\n position: 'relative',\r\n },\r\n input: {\r\n width: '100%',\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '12px 48px 12px 16px',\r\n color: 'white',\r\n fontSize: '14px',\r\n outline: 'none',\r\n boxSizing: 'border-box',\r\n transition: 'border-color 0.2s',\r\n },\r\n submitButton: {\r\n position: 'absolute',\r\n right: '8px',\r\n top: '50%',\r\n transform: 'translateY(-50%)',\r\n padding: '8px',\r\n color: 'rgba(255, 255, 255, 0.4)',\r\n background: 'transparent',\r\n border: 'none',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'color 0.2s',\r\n },\r\n successBox: {\r\n background: 'rgba(34, 197, 94, 0.1)',\r\n border: '1px solid rgba(34, 197, 94, 0.2)',\r\n borderRadius: '12px',\r\n padding: '12px',\r\n marginBottom: '16px',\r\n },\r\n successText: {\r\n color: '#4ade80',\r\n fontSize: '12px',\r\n textAlign: 'center',\r\n margin: 0,\r\n },\r\n buttons: {\r\n display: 'flex',\r\n gap: '8px',\r\n },\r\n button: {\r\n flex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n gap: '8px',\r\n padding: '10px 16px',\r\n borderRadius: '12px',\r\n fontSize: '14px',\r\n fontWeight: 500,\r\n cursor: 'pointer',\r\n border: 'none',\r\n transition: 'all 0.2s',\r\n },\r\n secondaryButton: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n color: 'rgba(255, 255, 255, 0.8)',\r\n },\r\n primaryButton: {\r\n background: '#7c3aed',\r\n color: 'white',\r\n },\r\n};\r\n\r\ninterface LumelyErrorOverlayProps {\r\n aiResponse?: LumelyAIResponse;\r\n isLoading: boolean;\r\n feedbackSubmitted?: boolean;\r\n onSubmitFeedback: (feedback: string) => void;\r\n onRetry: () => void;\r\n onDismiss: () => void;\r\n onGoBack: () => void;\r\n}\r\n\r\nexport const LumelyErrorOverlay = ({\r\n aiResponse,\r\n isLoading,\r\n feedbackSubmitted = false,\r\n onSubmitFeedback,\r\n onRetry,\r\n onDismiss,\r\n onGoBack,\r\n}: LumelyErrorOverlayProps) => {\r\n const [feedback, setFeedback] = useState('');\r\n const [isSubmitting, setIsSubmitting] = useState(false);\r\n\r\n useEffect(() => {\r\n injectStyles();\r\n }, []);\r\n\r\n const handleSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n if (feedback.trim() && !isSubmitting) {\r\n setIsSubmitting(true);\r\n onSubmitFeedback(feedback);\r\n }\r\n };\r\n\r\n return (\r\n <div style={styles.overlay}>\r\n <div style={styles.card}>\r\n {/* Close Button */}\r\n <button style={styles.closeButton} onClick={onDismiss}>\r\n <XIcon />\r\n </button>\r\n\r\n <div style={styles.content}>\r\n {/* Header */}\r\n <div style={styles.header}>\r\n <div style={styles.logo}>L</div>\r\n <div>\r\n <h3 style={styles.title}>Something went wrong</h3>\r\n <p style={styles.subtitle}>We're looking into it</p>\r\n </div>\r\n </div>\r\n\r\n {/* AI Message */}\r\n {isLoading ? (\r\n <div style={styles.loading}>\r\n <div style={styles.spinner} />\r\n <span>Analyzing the issue...</span>\r\n </div>\r\n ) : aiResponse ? (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>{aiResponse.userMessage}</p>\r\n </div>\r\n ) : (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>\r\n We encountered an unexpected issue. Our team has been notified.\r\n </p>\r\n </div>\r\n )}\r\n\r\n {/* Feedback Input */}\r\n {!feedbackSubmitted && !isSubmitting ? (\r\n <form style={styles.form} onSubmit={handleSubmit}>\r\n <label style={styles.label}>What were you trying to do?</label>\r\n <div style={styles.inputWrapper}>\r\n <input\r\n type=\"text\"\r\n value={feedback}\r\n onChange={(e) => setFeedback(e.target.value)}\r\n placeholder=\"e.g., I was trying to save my changes...\"\r\n style={styles.input}\r\n />\r\n <button\r\n type=\"submit\"\r\n disabled={!feedback.trim()}\r\n style={{\r\n ...styles.submitButton,\r\n opacity: feedback.trim() ? 1 : 0.3,\r\n }}\r\n >\r\n <SendIcon />\r\n </button>\r\n </div>\r\n </form>\r\n ) : (\r\n <div style={styles.successBox}>\r\n <p style={styles.successText}>Thank you! Your feedback helps us improve.</p>\r\n </div>\r\n )}\r\n\r\n {/* Action Buttons */}\r\n <div style={styles.buttons}>\r\n <button\r\n style={{ ...styles.button, ...styles.secondaryButton }}\r\n onClick={onGoBack}\r\n >\r\n <ArrowLeftIcon />\r\n Go Back\r\n </button>\r\n <button\r\n style={{ ...styles.button, ...styles.primaryButton }}\r\n onClick={onRetry}\r\n >\r\n <RefreshCwIcon />\r\n Try Again\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n client: LumelyClient;\r\n}\r\n\r\ninterface State {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n aiResponse: LumelyAIResponse | null;\r\n isLoading: boolean;\r\n errorId: string | null;\r\n feedbackSubmitted: boolean;\r\n}\r\n\r\nexport class LumelyErrorBoundary extends Component<Props, State> {\r\n private isReporting = false;\r\n\r\n constructor(props: Props) {\r\n super(props);\r\n this.state = {\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): Partial<State> {\r\n return { hasError: true, error };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\r\n if (this.isReporting) return;\r\n\r\n this.isReporting = true;\r\n this.setState({ errorInfo, isLoading: true });\r\n this.reportError(error, errorInfo);\r\n }\r\n\r\n private async reportError(error: Error, errorInfo: ErrorInfo) {\r\n const { config, client } = this.props;\r\n\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n componentStack: errorInfo.componentStack || undefined,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : '',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',\r\n userId: config.userId,\r\n sessionId: config.sessionId,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const response = await client.reportError(report);\r\n\r\n this.setState({\r\n aiResponse: response.ai,\r\n errorId: response.errorId,\r\n isLoading: false,\r\n });\r\n\r\n if (config.onError) {\r\n config.onError(report);\r\n }\r\n }\r\n\r\n private handleSubmitFeedback = async (feedback: string) => {\r\n const { errorId } = this.state;\r\n const { client } = this.props;\r\n\r\n if (!errorId || errorId === 'client-error') {\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n await client.updateFeedback(errorId, feedback);\r\n this.setState({ feedbackSubmitted: true });\r\n };\r\n\r\n private handleRetry = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleDismiss = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleGoBack = () => {\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n render() {\r\n const { hasError, aiResponse, isLoading, feedbackSubmitted } = this.state;\r\n const { children } = this.props;\r\n\r\n if (hasError) {\r\n return (\r\n <>\r\n {children}\r\n <LumelyErrorOverlay\r\n aiResponse={aiResponse || undefined}\r\n isLoading={isLoading}\r\n feedbackSubmitted={feedbackSubmitted}\r\n onSubmitFeedback={this.handleSubmitFeedback}\r\n onRetry={this.handleRetry}\r\n onDismiss={this.handleDismiss}\r\n onGoBack={this.handleGoBack}\r\n />\r\n </>\r\n );\r\n }\r\n\r\n return children;\r\n }\r\n}\r\n","import React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport { LumelyOverlayProvider, useLumelyOverlay } from './LumelyOverlayContext';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\nimport { LUMELY_API_ENDPOINT } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n /** API endpoint for error reporting. Defaults to Lumely's hosted backend. */\r\n apiEndpoint?: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\n// Component that renders the overlay for manually reported errors\r\nconst ManualErrorOverlay = ({ apiEndpoint }: { apiEndpoint: string }) => {\r\n const overlay = useLumelyOverlay();\r\n\r\n if (!overlay?.state.isVisible || !overlay.state.error) {\r\n return null;\r\n }\r\n\r\n const handleSubmitFeedback = async (feedback: string) => {\r\n if (!overlay.state.errorId) return;\r\n\r\n try {\r\n await fetch(`${apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify({\r\n errorId: overlay.state.errorId,\r\n userFeedback: feedback,\r\n }),\r\n });\r\n } catch (e) {\r\n console.error('[Lumely] Failed to submit feedback:', e);\r\n }\r\n };\r\n\r\n const handleGoBack = () => {\r\n overlay.hideOverlay();\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n return (\r\n <LumelyErrorOverlay\r\n aiResponse={overlay.state.aiResponse || undefined}\r\n isLoading={overlay.state.isLoading}\r\n feedbackSubmitted={false}\r\n onSubmitFeedback={handleSubmitFeedback}\r\n onRetry={overlay.hideOverlay}\r\n onDismiss={overlay.hideOverlay}\r\n onGoBack={handleGoBack}\r\n />\r\n );\r\n};\r\n\r\n/**\r\n * LumelyProvider for Plain React (Vite, CRA, etc.)\r\n * \r\n * Usage:\r\n * ```tsx\r\n * import { LumelyProvider } from './components/lumely-react';\r\n * \r\n * function App() {\r\n * return (\r\n * <LumelyProvider \r\n * apiKey=\"your-api-key\"\r\n * apiEndpoint=\"https://your-api.com/api/lumely\"\r\n * >\r\n * <YourApp />\r\n * </LumelyProvider>\r\n * );\r\n * }\r\n * ```\r\n */\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\r\n apiEndpoint = LUMELY_API_ENDPOINT,\r\n environment = 'production',\r\n userId,\r\n sessionId,\r\n onError,\r\n}: LumelyProviderProps) => {\r\n const config: LumelyConfig = {\r\n apiKey,\r\n apiEndpoint,\r\n environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n const client = new LumelyClient(apiKey, apiEndpoint);\r\n\r\n return (\r\n <LumelyOverlayProvider>\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config} client={client}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n <ManualErrorOverlay apiEndpoint={apiEndpoint} />\r\n </LumelyContextProvider>\r\n </LumelyOverlayProvider>\r\n );\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
|
|
1
|
+
import M,{createContext,useContext,useState,useCallback,useEffect,Component,useMemo}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var f="https://lumely.vercel.app/api/lumely";var g=class{constructor(e,r){this.apiKey=e,this.apiEndpoint=r||f;}async reportError(e){try{let r=await fetch(`${this.apiEndpoint}/report-error`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify(e)});if(r.ok)return await r.json();throw new Error("Failed to report error")}catch(r){return console.error("Lumely: Failed to report error",r),{success:false,ai:{userMessage:"Something went wrong. We're looking into it.",summary:"",suggestedFix:""},errorId:"client-error"}}}async updateFeedback(e,r){try{return (await fetch(`${this.apiEndpoint}/update-feedback`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumely-Key":this.apiKey},body:JSON.stringify({errorId:e,feedback:r})})).ok}catch(s){return console.error("Lumely: Failed to update feedback",s),false}}};var R=createContext(null),b=()=>useContext(R),E=({children:a})=>{let[e,r]=useState({isVisible:false,error:null,isLoading:false,aiResponse:null,errorId:null}),s=useCallback((n,u,l)=>{r({isVisible:true,error:n,isLoading:!u,aiResponse:u||null,errorId:l||null});},[]),t=useCallback(()=>{r({isVisible:false,error:null,isLoading:false,aiResponse:null,errorId:null});},[]),d=useCallback(n=>{r(u=>({...u,isLoading:n}));},[]),c=useCallback((n,u)=>{r(l=>({...l,aiResponse:n,errorId:u||l.errorId,isLoading:false}));},[]);return jsx(R.Provider,{value:{state:e,showOverlay:s,hideOverlay:t,setLoading:d,setAiResponse:c},children:a})};var k=createContext(null),T=()=>typeof window=="undefined"?null:sessionStorage.getItem("lumely_session_id"),W=()=>`sess_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,j=()=>{let a=useContext(k);if(!a)throw new Error("useLumely must be used within a LumelyProvider");return a},z=()=>{let a=useContext(k);if(!a)throw new Error("useLumelyReport must be used within a LumelyProvider");return {reportError:a.reportError}},P=({children:a,config:e})=>{let[r]=M.useState(()=>e.sessionId?e.sessionId:T()||W());useEffect(()=>{typeof window!="undefined"&&!e.sessionId&&r!=="server"&&(sessionStorage.getItem("lumely_session_id")||sessionStorage.setItem("lumely_session_id",r));},[r,e.sessionId]);let s=useMemo(()=>{var n;return new g(e.apiKey,(n=e.apiEndpoint)!=null?n:f)},[e.apiKey,e.apiEndpoint]),t=b(),d=useCallback(async(n,u)=>{var m;let l={errorMessage:n.message,errorStack:n.stack,context:{url:typeof window!="undefined"?window.location.href:"server",userAgent:typeof navigator!="undefined"?navigator.userAgent:"server",userId:e.userId,sessionId:r,timestamp:new Date().toISOString(),...u&&{additionalContext:JSON.stringify(u)}}};t==null||t.showOverlay(n);try{let y=await s.reportError(l);y&&y.ai?t==null||t.setAiResponse(y.ai,y.errorId):t==null||t.setLoading(!1),(m=e.onError)==null||m.call(e,l);}catch(y){console.error("[Lumely] Error reporting failed:",y),t==null||t.setLoading(false);}},[s,e,r,t]);useEffect(()=>{if(typeof window=="undefined")return;let n=l=>{let m=l.reason instanceof Error?l.reason:new Error(String(l.reason));d(m);},u=l=>{let m=l.error instanceof Error?l.error:new Error(l.message);d(m);};return window.addEventListener("unhandledrejection",n),window.addEventListener("error",u),()=>{window.removeEventListener("unhandledrejection",n),window.removeEventListener("error",u);}},[d]);let c=useMemo(()=>({...e,sessionId:r,environment:e.environment||"production",client:s,reportError:d}),[e,r,s,d]);return jsx(k.Provider,{value:c,children:a})};var G=()=>{if(typeof document=="undefined"||document.getElementById("lumely-react-styles"))return;let a=document.createElement("style");a.id="lumely-react-styles",a.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(
|
|
7
|
+
`,document.head.appendChild(a);},U=()=>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"})]}),Y=()=>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"})]}),$=()=>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"})]}),J=()=>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"})]}),i={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"}},h=({aiResponse:a,isLoading:e,feedbackSubmitted:r=false,onSubmitFeedback:s,onRetry:t,onDismiss:d,onGoBack:c})=>{let[n,u]=useState(""),[l,m]=useState(false);useEffect(()=>{G();},[]);let y=I=>{I.preventDefault(),n.trim()&&!l&&(m(true),s(n));};return jsx("div",{style:i.overlay,children:jsxs("div",{style:i.card,children:[jsx("button",{style:i.closeButton,onClick:d,children:jsx(U,{})}),jsxs("div",{style:i.content,children:[jsxs("div",{style:i.header,children:[jsx("div",{style:i.logo,children:"L"}),jsxs("div",{children:[jsx("h3",{style:i.title,children:"Something went wrong"}),jsx("p",{style:i.subtitle,children:"We're looking into it"})]})]}),e?jsxs("div",{style:i.loading,children:[jsx("div",{style:i.spinner}),jsx("span",{children:"Analyzing the issue..."})]}):a?jsx("div",{style:i.messageBox,children:jsx("p",{style:i.message,children:a.userMessage})}):jsx("div",{style:i.messageBox,children:jsx("p",{style:i.message,children:"We encountered an unexpected issue. Our team has been notified."})}),!r&&!l?jsxs("form",{style:i.form,onSubmit:y,children:[jsx("label",{style:i.label,children:"What were you trying to do?"}),jsxs("div",{style:i.inputWrapper,children:[jsx("input",{type:"text",value:n,onChange:I=>u(I.target.value),placeholder:"e.g., I was trying to save my changes...",style:i.input}),jsx("button",{type:"submit",disabled:!n.trim(),style:{...i.submitButton,opacity:n.trim()?1:.3},children:jsx(Y,{})})]})]}):jsx("div",{style:i.successBox,children:jsx("p",{style:i.successText,children:"Thank you! Your feedback helps us improve."})}),jsxs("div",{style:i.buttons,children:[jsxs("button",{style:{...i.button,...i.secondaryButton},onClick:c,children:[jsx($,{}),"Go Back"]}),jsxs("button",{style:{...i.button,...i.primaryButton},onClick:t,children:[jsx(J,{}),"Try Again"]})]})]})]})})};var L=class extends Component{constructor(r){super(r);this.isReporting=false;this.handleSubmitFeedback=async r=>{let{errorId:s}=this.state,{client:t}=this.props;if(!s||s==="client-error"){this.setState({feedbackSubmitted:true});return}await t.updateFeedback(s,r),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(r){return {hasError:true,error:r}}componentDidCatch(r,s){this.isReporting||(this.isReporting=true,this.setState({errorInfo:s,isLoading:true}),this.reportError(r,s));}async reportError(r,s){let{config:t,client:d}=this.props,c={errorMessage:r.message,errorStack:r.stack,componentStack:s.componentStack||void 0,context:{url:typeof window!="undefined"?window.location.href:"",userAgent:typeof navigator!="undefined"?navigator.userAgent:"",userId:t.userId,sessionId:t.sessionId,timestamp:new Date().toISOString()}},n=await d.reportError(c);this.setState({aiResponse:n.ai,errorId:n.errorId,isLoading:false}),t.onError&&t.onError(c);}render(){let{hasError:r,aiResponse:s,isLoading:t,feedbackSubmitted:d}=this.state,{children:c}=this.props;return r?jsxs(Fragment,{children:[c,jsx(h,{aiResponse:s||void 0,isLoading:t,feedbackSubmitted:d,onSubmitFeedback:this.handleSubmitFeedback,onRetry:this.handleRetry,onDismiss:this.handleDismiss,onGoBack:this.handleGoBack})]}):c}};var Z=({apiEndpoint:a})=>{let e=b();if(!(e!=null&&e.state.isVisible)||!e.state.error)return null;let r=async t=>{if(e.state.errorId)try{await fetch(`${a}/update-feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({errorId:e.state.errorId,userFeedback:t})});}catch(d){console.error("[Lumely] Failed to submit feedback:",d);}},s=()=>{e.hideOverlay(),typeof window!="undefined"&&window.history.back();};return jsx(h,{aiResponse:e.state.aiResponse||void 0,isLoading:e.state.isLoading,feedbackSubmitted:false,onSubmitFeedback:r,onRetry:e.hideOverlay,onDismiss:e.hideOverlay,onGoBack:s})},ee=({children:a,apiKey:e,apiEndpoint:r=f,environment:s="production",userId:t,sessionId:d,onError:c})=>{let n={apiKey:e,apiEndpoint:r,environment:s,userId:t,sessionId:d,onError:c},u=new g(e,r);return jsx(E,{children:jsxs(P,{config:n,children:[jsx(L,{config:n,client:u,children:a}),jsx(Z,{apiEndpoint:r})]})})};export{g as LumelyClient,L as LumelyErrorBoundary,h as LumelyErrorOverlay,E as LumelyOverlayProvider,ee as LumelyProvider,j as useLumely,b as useLumelyOverlay,z as useLumelyReport};//# sourceMappingURL=index.mjs.map
|
|
8
8
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../LumelyClient.ts","../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LumelyClient","apiKey","apiEndpoint","report","response","err","errorId","feedback","LumelyContext","createContext","generateSessionId","stored","newId","useLumely","context","useContext","LumelyContextProvider","children","config","value","useMemo","sessionId","client","jsx","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","aiResponse","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","setFeedback","useState","isSubmitting","setIsSubmitting","useEffect","handleSubmit","e","LumelyErrorBoundary","Component","props","error","errorInfo","hasError","Fragment","LumelyProvider","environment","userId","onError"],"mappings":"oI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AE,QAAA,CAAAlB,CAAS,CAAA,CAAI,IAAA,CAAK,KAAA,CAE1B,OAAImC,EAEIzB,IAAAA,CAAA0B,QAAAA,CAAA,CACK,QAAA,CAAA,CAAApC,CAAAA,CACDM,GAAAA,CAACS,CAAAA,CAAA,CACG,WAAYC,CAAAA,EAAc,MAAA,CAC1B,SAAA,CAAWC,CAAAA,CACX,kBAAmBC,CAAAA,CACnB,gBAAA,CAAkB,IAAA,CAAK,oBAAA,CACvB,QAAS,IAAA,CAAK,WAAA,CACd,SAAA,CAAW,IAAA,CAAK,aAAA,CAChB,QAAA,CAAU,IAAA,CAAK,YAAA,CACnB,GACJ,CAAA,CAIDlB,CACX,CACJ,EC/GO,IAAMqC,CAAAA,CAAiB,CAAC,CAC3B,QAAA,CAAArC,CAAAA,CACA,MAAA,CAAAhB,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,WAAA,CAAAqD,EAAc,YAAA,CACd,MAAA,CAAAC,CAAAA,CACA,SAAA,CAAAnC,EACA,OAAA,CAAAoC,CACJ,CAAA,GAA2B,CACvB,IAAMvC,CAAAA,CAAuB,CACzB,MAAA,CAAAjB,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,WAAA,CAAAqD,CAAAA,CACA,OAAAC,CAAAA,CACA,SAAA,CAAAnC,CAAAA,CACA,OAAA,CAAAoC,CACJ,CAAA,CAEMnC,CAAAA,CAAS,IAAItB,CAAAA,CAAaC,EAAQC,CAAW,CAAA,CAEnD,OACIqB,GAAAA,CAACP,CAAAA,CAAA,CAAsB,MAAA,CAAQE,CAAAA,CAC3B,SAAAK,GAAAA,CAACwB,CAAAA,CAAA,CAAoB,MAAA,CAAQ7B,EAAQ,MAAA,CAAQI,CAAAA,CACxC,QAAA,CAAAL,CAAAA,CACL,EACJ,CAER","file":"index.mjs","sourcesContent":["import type { LumelyErrorReport, LumelyAPIResponse } from './types';\r\n\r\nexport class LumelyClient {\r\n private apiKey: string;\r\n private apiEndpoint: string;\r\n\r\n constructor(apiKey: string, apiEndpoint: string) {\r\n this.apiKey = apiKey;\r\n this.apiEndpoint = apiEndpoint;\r\n }\r\n\r\n async reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/report-error`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n return await response.json();\r\n }\r\n\r\n throw new Error('Failed to report error');\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n return {\r\n success: false,\r\n ai: {\r\n userMessage: \"Something went wrong. We're looking into it.\",\r\n summary: '',\r\n suggestedFix: '',\r\n },\r\n errorId: 'client-error',\r\n };\r\n }\r\n }\r\n\r\n async updateFeedback(errorId: string, feedback: string): Promise<boolean> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n return response.ok;\r\n } catch (err) {\r\n console.error('Lumely: Failed to update feedback', err);\r\n return false;\r\n }\r\n }\r\n}\r\n","import React, { createContext, useContext, useMemo } from 'react';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n client: LumelyClient;\r\n sessionId: string;\r\n}\r\n\r\nconst LumelyContext = createContext<LumelyContextValue | null>(null);\r\n\r\nconst generateSessionId = () => {\r\n if (typeof window === 'undefined') return 'server';\r\n const stored = sessionStorage.getItem('lumely_session_id');\r\n if (stored) return stored;\r\n const newId = `sess_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\r\n sessionStorage.setItem('lumely_session_id', newId);\r\n return newId;\r\n};\r\n\r\nexport const useLumely = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumely must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\ninterface LumelyContextProviderProps {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n}\r\n\r\nexport const LumelyContextProvider = ({ children, config }: LumelyContextProviderProps) => {\r\n const value = useMemo(() => {\r\n const sessionId = config.sessionId || generateSessionId();\r\n const client = new LumelyClient(config.apiKey, config.apiEndpoint);\r\n\r\n return {\r\n ...config,\r\n sessionId,\r\n environment: config.environment || 'production',\r\n client,\r\n };\r\n }, [config]);\r\n\r\n return (\r\n <LumelyContext.Provider value={value}>\r\n {children}\r\n </LumelyContext.Provider>\r\n );\r\n};\r\n","import React, { useState, useEffect } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Inject Poppins font and keyframes\r\nconst injectStyles = () => {\r\n if (typeof document === 'undefined') return;\r\n if (document.getElementById('lumely-react-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-react-styles';\r\n style.textContent = `\r\n @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');\r\n @keyframes lumely-spin {\r\n from { transform: rotate(0deg); }\r\n to { transform: rotate(360deg); }\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n};\r\n\r\n// SVG Icons as components (replacing lucide-react)\r\nconst XIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n </svg>\r\n);\r\n\r\nconst SendIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\r\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\r\n </svg>\r\n);\r\n\r\nconst ArrowLeftIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line>\r\n <polyline points=\"12 19 5 12 12 5\"></polyline>\r\n </svg>\r\n);\r\n\r\nconst RefreshCwIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <polyline points=\"23 4 23 10 17 10\"></polyline>\r\n <polyline points=\"1 20 1 14 7 14\"></polyline>\r\n <path d=\"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15\"></path>\r\n </svg>\r\n);\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n overlay: {\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 9999,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: '16px',\r\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\r\n backdropFilter: 'blur(8px)',\r\n fontFamily: \"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\r\n },\r\n card: {\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: '448px',\r\n background: 'rgba(255, 255, 255, 0.1)',\r\n backdropFilter: 'blur(24px)',\r\n border: '1px solid rgba(255, 255, 255, 0.2)',\r\n borderRadius: '16px',\r\n overflow: 'hidden',\r\n },\r\n closeButton: {\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n padding: '6px',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n background: 'transparent',\r\n border: 'none',\r\n borderRadius: '8px',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'all 0.2s',\r\n },\r\n content: {\r\n padding: '24px',\r\n },\r\n header: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '12px',\r\n marginBottom: '16px',\r\n },\r\n logo: {\r\n width: '40px',\r\n height: '40px',\r\n borderRadius: '12px',\r\n background: 'linear-gradient(135deg, #7c3aed, #8b5cf6)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n color: 'white',\r\n fontWeight: 700,\r\n fontSize: '18px',\r\n },\r\n title: {\r\n color: 'white',\r\n fontWeight: 600,\r\n fontSize: '14px',\r\n margin: 0,\r\n },\r\n subtitle: {\r\n color: 'rgba(255, 255, 255, 0.5)',\r\n fontSize: '12px',\r\n margin: 0,\r\n },\r\n messageBox: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '16px',\r\n marginBottom: '16px',\r\n },\r\n message: {\r\n color: 'rgba(255, 255, 255, 0.9)',\r\n fontSize: '14px',\r\n lineHeight: 1.6,\r\n margin: 0,\r\n },\r\n loading: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'rgba(255, 255, 255, 0.7)',\r\n fontSize: '14px',\r\n padding: '16px 0',\r\n },\r\n spinner: {\r\n width: '16px',\r\n height: '16px',\r\n border: '2px solid rgba(255, 255, 255, 0.3)',\r\n borderTopColor: 'white',\r\n borderRadius: '50%',\r\n animation: 'lumely-spin 1s linear infinite',\r\n },\r\n form: {\r\n marginBottom: '16px',\r\n },\r\n label: {\r\n display: 'block',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n fontSize: '12px',\r\n marginBottom: '8px',\r\n },\r\n inputWrapper: {\r\n position: 'relative',\r\n },\r\n input: {\r\n width: '100%',\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '12px 48px 12px 16px',\r\n color: 'white',\r\n fontSize: '14px',\r\n outline: 'none',\r\n boxSizing: 'border-box',\r\n transition: 'border-color 0.2s',\r\n },\r\n submitButton: {\r\n position: 'absolute',\r\n right: '8px',\r\n top: '50%',\r\n transform: 'translateY(-50%)',\r\n padding: '8px',\r\n color: 'rgba(255, 255, 255, 0.4)',\r\n background: 'transparent',\r\n border: 'none',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'color 0.2s',\r\n },\r\n successBox: {\r\n background: 'rgba(34, 197, 94, 0.1)',\r\n border: '1px solid rgba(34, 197, 94, 0.2)',\r\n borderRadius: '12px',\r\n padding: '12px',\r\n marginBottom: '16px',\r\n },\r\n successText: {\r\n color: '#4ade80',\r\n fontSize: '12px',\r\n textAlign: 'center',\r\n margin: 0,\r\n },\r\n buttons: {\r\n display: 'flex',\r\n gap: '8px',\r\n },\r\n button: {\r\n flex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n gap: '8px',\r\n padding: '10px 16px',\r\n borderRadius: '12px',\r\n fontSize: '14px',\r\n fontWeight: 500,\r\n cursor: 'pointer',\r\n border: 'none',\r\n transition: 'all 0.2s',\r\n },\r\n secondaryButton: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n color: 'rgba(255, 255, 255, 0.8)',\r\n },\r\n primaryButton: {\r\n background: '#7c3aed',\r\n color: 'white',\r\n },\r\n};\r\n\r\ninterface LumelyErrorOverlayProps {\r\n aiResponse?: LumelyAIResponse;\r\n isLoading: boolean;\r\n feedbackSubmitted?: boolean;\r\n onSubmitFeedback: (feedback: string) => void;\r\n onRetry: () => void;\r\n onDismiss: () => void;\r\n onGoBack: () => void;\r\n}\r\n\r\nexport const LumelyErrorOverlay = ({\r\n aiResponse,\r\n isLoading,\r\n feedbackSubmitted = false,\r\n onSubmitFeedback,\r\n onRetry,\r\n onDismiss,\r\n onGoBack,\r\n}: LumelyErrorOverlayProps) => {\r\n const [feedback, setFeedback] = useState('');\r\n const [isSubmitting, setIsSubmitting] = useState(false);\r\n\r\n useEffect(() => {\r\n injectStyles();\r\n }, []);\r\n\r\n const handleSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n if (feedback.trim() && !isSubmitting) {\r\n setIsSubmitting(true);\r\n onSubmitFeedback(feedback);\r\n }\r\n };\r\n\r\n return (\r\n <div style={styles.overlay}>\r\n <div style={styles.card}>\r\n {/* Close Button */}\r\n <button style={styles.closeButton} onClick={onDismiss}>\r\n <XIcon />\r\n </button>\r\n\r\n <div style={styles.content}>\r\n {/* Header */}\r\n <div style={styles.header}>\r\n <div style={styles.logo}>L</div>\r\n <div>\r\n <h3 style={styles.title}>Something went wrong</h3>\r\n <p style={styles.subtitle}>We're looking into it</p>\r\n </div>\r\n </div>\r\n\r\n {/* AI Message */}\r\n {isLoading ? (\r\n <div style={styles.loading}>\r\n <div style={styles.spinner} />\r\n <span>Analyzing the issue...</span>\r\n </div>\r\n ) : aiResponse ? (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>{aiResponse.userMessage}</p>\r\n </div>\r\n ) : (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>\r\n We encountered an unexpected issue. Our team has been notified.\r\n </p>\r\n </div>\r\n )}\r\n\r\n {/* Feedback Input */}\r\n {!feedbackSubmitted && !isSubmitting ? (\r\n <form style={styles.form} onSubmit={handleSubmit}>\r\n <label style={styles.label}>What were you trying to do?</label>\r\n <div style={styles.inputWrapper}>\r\n <input\r\n type=\"text\"\r\n value={feedback}\r\n onChange={(e) => setFeedback(e.target.value)}\r\n placeholder=\"e.g., I was trying to save my changes...\"\r\n style={styles.input}\r\n />\r\n <button\r\n type=\"submit\"\r\n disabled={!feedback.trim()}\r\n style={{\r\n ...styles.submitButton,\r\n opacity: feedback.trim() ? 1 : 0.3,\r\n }}\r\n >\r\n <SendIcon />\r\n </button>\r\n </div>\r\n </form>\r\n ) : (\r\n <div style={styles.successBox}>\r\n <p style={styles.successText}>Thank you! Your feedback helps us improve.</p>\r\n </div>\r\n )}\r\n\r\n {/* Action Buttons */}\r\n <div style={styles.buttons}>\r\n <button\r\n style={{ ...styles.button, ...styles.secondaryButton }}\r\n onClick={onGoBack}\r\n >\r\n <ArrowLeftIcon />\r\n Go Back\r\n </button>\r\n <button\r\n style={{ ...styles.button, ...styles.primaryButton }}\r\n onClick={onRetry}\r\n >\r\n <RefreshCwIcon />\r\n Try Again\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n client: LumelyClient;\r\n}\r\n\r\ninterface State {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n aiResponse: LumelyAIResponse | null;\r\n isLoading: boolean;\r\n errorId: string | null;\r\n feedbackSubmitted: boolean;\r\n}\r\n\r\nexport class LumelyErrorBoundary extends Component<Props, State> {\r\n private isReporting = false;\r\n\r\n constructor(props: Props) {\r\n super(props);\r\n this.state = {\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): Partial<State> {\r\n return { hasError: true, error };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\r\n if (this.isReporting) return;\r\n\r\n this.isReporting = true;\r\n this.setState({ errorInfo, isLoading: true });\r\n this.reportError(error, errorInfo);\r\n }\r\n\r\n private async reportError(error: Error, errorInfo: ErrorInfo) {\r\n const { config, client } = this.props;\r\n\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n componentStack: errorInfo.componentStack || undefined,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : '',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',\r\n userId: config.userId,\r\n sessionId: config.sessionId,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const response = await client.reportError(report);\r\n\r\n this.setState({\r\n aiResponse: response.ai,\r\n errorId: response.errorId,\r\n isLoading: false,\r\n });\r\n\r\n if (config.onError) {\r\n config.onError(report);\r\n }\r\n }\r\n\r\n private handleSubmitFeedback = async (feedback: string) => {\r\n const { errorId } = this.state;\r\n const { client } = this.props;\r\n\r\n if (!errorId || errorId === 'client-error') {\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n await client.updateFeedback(errorId, feedback);\r\n this.setState({ feedbackSubmitted: true });\r\n };\r\n\r\n private handleRetry = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleDismiss = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleGoBack = () => {\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n render() {\r\n const { hasError, aiResponse, isLoading, feedbackSubmitted } = this.state;\r\n const { children } = this.props;\r\n\r\n if (hasError) {\r\n return (\r\n <>\r\n {children}\r\n <LumelyErrorOverlay\r\n aiResponse={aiResponse || undefined}\r\n isLoading={isLoading}\r\n feedbackSubmitted={feedbackSubmitted}\r\n onSubmitFeedback={this.handleSubmitFeedback}\r\n onRetry={this.handleRetry}\r\n onDismiss={this.handleDismiss}\r\n onGoBack={this.handleGoBack}\r\n />\r\n </>\r\n );\r\n }\r\n\r\n return children;\r\n }\r\n}\r\n","import React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n apiEndpoint: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\n/**\r\n * LumelyProvider for Plain React (Vite, CRA, etc.)\r\n * \r\n * Usage:\r\n * ```tsx\r\n * import { LumelyProvider } from './components/lumely-react';\r\n * \r\n * function App() {\r\n * return (\r\n * <LumelyProvider \r\n * apiKey=\"your-api-key\"\r\n * apiEndpoint=\"https://your-api.com/api/lumely\"\r\n * >\r\n * <YourApp />\r\n * </LumelyProvider>\r\n * );\r\n * }\r\n * ```\r\n */\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\r\n apiEndpoint,\r\n environment = 'production',\r\n userId,\r\n sessionId,\r\n onError,\r\n}: LumelyProviderProps) => {\r\n const config: LumelyConfig = {\r\n apiKey,\r\n apiEndpoint,\r\n environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n const client = new LumelyClient(apiKey, apiEndpoint);\r\n\r\n return (\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config} client={client}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n </LumelyContextProvider>\r\n );\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../types.ts","../LumelyClient.ts","../LumelyOverlayContext.tsx","../LumelyContext.tsx","../LumelyErrorOverlay.tsx","../LumelyErrorBoundary.tsx","../LumelyProvider.tsx"],"names":["LUMELY_API_ENDPOINT","LumelyClient","apiKey","apiEndpoint","report","response","err","errorId","feedback","LumelyOverlayContext","createContext","useLumelyOverlay","useContext","LumelyOverlayProvider","children","state","setState","useState","showOverlay","useCallback","error","aiResponse","hideOverlay","setLoading","loading","prev","setAiResponse","jsx","LumelyContext","getStoredSessionId","createSessionId","useLumely","context","useLumelyReport","LumelyContextProvider","config","sessionId","React","useEffect","client","useMemo","_a","overlay","reportError","additionalContext","e","handleUnhandledRejection","event","handleGlobalError","value","injectStyles","style","XIcon","jsxs","SendIcon","ArrowLeftIcon","RefreshCwIcon","styles","LumelyErrorOverlay","isLoading","feedbackSubmitted","onSubmitFeedback","onRetry","onDismiss","onGoBack","setFeedback","isSubmitting","setIsSubmitting","handleSubmit","LumelyErrorBoundary","Component","props","errorInfo","hasError","Fragment","ManualErrorOverlay","handleSubmitFeedback","handleGoBack","LumelyProvider","environment","userId","onError"],"mappings":"kJACO,IAAMA,CAAAA,CAAsB,sCAAA,KCEtBC,CAAAA,CAAN,KAAmB,CAItB,WAAA,CAAYC,CAAAA,CAAgBC,CAAAA,CAAsB,CAC9C,KAAK,MAAA,CAASD,CAAAA,CACd,KAAK,WAAA,CAAcC,CAAAA,EAAeH,EACtC,CAEA,MAAM,YAAYI,CAAAA,CAAuD,CACrE,GAAI,CACA,IAAMC,EAAW,MAAM,KAAA,CAAM,GAAG,IAAA,CAAK,WAAW,CAAA,aAAA,CAAA,CAAiB,CAC7D,OAAQ,MAAA,CACR,OAAA,CAAS,CACL,cAAA,CAAgB,kBAAA,CAChB,eAAgB,IAAA,CAAK,MACzB,EACA,IAAA,CAAM,IAAA,CAAK,UAAUD,CAAM,CAC/B,CAAC,CAAA,CAED,GAAIC,EAAS,EAAA,CACT,OAAO,MAAMA,CAAAA,CAAS,IAAA,GAG1B,MAAM,IAAI,MAAM,wBAAwB,CAC5C,OAASC,CAAAA,CAAK,CACV,eAAQ,KAAA,CAAM,gCAAA,CAAkCA,CAAG,CAAA,CAC5C,CACH,QAAS,KAAA,CACT,EAAA,CAAI,CACA,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cesContent":["// Default API endpoint - points to Lumely's hosted backend\r\nexport const LUMELY_API_ENDPOINT = 'https://lumely.vercel.app/api/lumely';\r\n\r\nexport interface LumelyConfig {\r\n apiKey: string;\r\n apiEndpoint?: string; // Defaults to LUMELY_API_ENDPOINT\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: (error: LumelyErrorReport) => void;\r\n}\r\n\r\nexport interface LumelyErrorContext {\r\n url: string;\r\n userAgent: string;\r\n userId?: string;\r\n sessionId?: string;\r\n userFeedback?: string;\r\n timestamp: string;\r\n additionalContext?: string;\r\n}\r\n\r\nexport interface LumelyErrorReport {\r\n errorMessage: string;\r\n errorStack?: string;\r\n componentStack?: string;\r\n context: LumelyErrorContext;\r\n}\r\n\r\nexport interface LumelyAIResponse {\r\n userMessage: string;\r\n summary: string;\r\n suggestedFix: string;\r\n}\r\n\r\nexport interface LumelyAPIResponse {\r\n success: boolean;\r\n ai: LumelyAIResponse;\r\n errorId: string;\r\n}\r\n","import type { LumelyErrorReport, LumelyAPIResponse } from './types';\r\nimport { LUMELY_API_ENDPOINT } from './types';\r\n\r\nexport class LumelyClient {\r\n private apiKey: string;\r\n private apiEndpoint: string;\r\n\r\n constructor(apiKey: string, apiEndpoint?: string) {\r\n this.apiKey = apiKey;\r\n this.apiEndpoint = apiEndpoint || LUMELY_API_ENDPOINT;\r\n }\r\n\r\n async reportError(report: LumelyErrorReport): Promise<LumelyAPIResponse> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/report-error`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify(report),\r\n });\r\n\r\n if (response.ok) {\r\n return await response.json();\r\n }\r\n\r\n throw new Error('Failed to report error');\r\n } catch (err) {\r\n console.error('Lumely: Failed to report error', err);\r\n return {\r\n success: false,\r\n ai: {\r\n userMessage: \"Something went wrong. We're looking into it.\",\r\n summary: '',\r\n suggestedFix: '',\r\n },\r\n errorId: 'client-error',\r\n };\r\n }\r\n }\r\n\r\n async updateFeedback(errorId: string, feedback: string): Promise<boolean> {\r\n try {\r\n const response = await fetch(`${this.apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'X-Lumely-Key': this.apiKey,\r\n },\r\n body: JSON.stringify({ errorId, feedback }),\r\n });\r\n\r\n return response.ok;\r\n } catch (err) {\r\n console.error('Lumely: Failed to update feedback', err);\r\n return false;\r\n }\r\n }\r\n}\r\n","'use client';\r\n\r\nimport React, { createContext, useContext, useState, useCallback, ReactNode } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Shared error state for overlay\r\ninterface LumelyOverlayState {\r\n isVisible: boolean;\r\n error: Error | null;\r\n isLoading: boolean;\r\n aiResponse: LumelyAIResponse | null;\r\n errorId: string | null;\r\n}\r\n\r\ninterface LumelyOverlayContextValue {\r\n state: LumelyOverlayState;\r\n showOverlay: (error: Error, aiResponse?: LumelyAIResponse | null, errorId?: string | null) => void;\r\n hideOverlay: () => void;\r\n setLoading: (loading: boolean) => void;\r\n setAiResponse: (response: LumelyAIResponse | null, errorId?: string | null) => void;\r\n}\r\n\r\nconst LumelyOverlayContext = createContext<LumelyOverlayContextValue | null>(null);\r\n\r\nexport const useLumelyOverlay = () => {\r\n return useContext(LumelyOverlayContext);\r\n};\r\n\r\ninterface LumelyOverlayProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\nexport const LumelyOverlayProvider = ({ children }: LumelyOverlayProviderProps) => {\r\n const [state, setState] = useState<LumelyOverlayState>({\r\n isVisible: false,\r\n error: null,\r\n isLoading: false,\r\n aiResponse: null,\r\n errorId: null,\r\n });\r\n\r\n const showOverlay = useCallback((error: Error, aiResponse?: LumelyAIResponse | null, errorId?: string | null) => {\r\n setState({\r\n isVisible: true,\r\n error,\r\n isLoading: !aiResponse,\r\n aiResponse: aiResponse || null,\r\n errorId: errorId || null,\r\n });\r\n }, []);\r\n\r\n const hideOverlay = useCallback(() => {\r\n setState({\r\n isVisible: false,\r\n error: null,\r\n isLoading: false,\r\n aiResponse: null,\r\n errorId: null,\r\n });\r\n }, []);\r\n\r\n const setLoading = useCallback((loading: boolean) => {\r\n setState(prev => ({ ...prev, isLoading: loading }));\r\n }, []);\r\n\r\n const setAiResponse = useCallback((response: LumelyAIResponse | null, errorId?: string | null) => {\r\n setState(prev => ({\r\n ...prev,\r\n aiResponse: response,\r\n errorId: errorId || prev.errorId,\r\n isLoading: false\r\n }));\r\n }, []);\r\n\r\n return (\r\n <LumelyOverlayContext.Provider value={{ state, showOverlay, hideOverlay, setLoading, setAiResponse }}>\r\n {children}\r\n </LumelyOverlayContext.Provider>\r\n );\r\n};\r\n","import React, { createContext, useContext, useMemo, useCallback, useEffect } from 'react';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport } from './types';\r\nimport { LUMELY_API_ENDPOINT } from './types';\r\nimport { useLumelyOverlay } from './LumelyOverlayContext';\r\n\r\ninterface LumelyContextValue extends LumelyConfig {\r\n client: LumelyClient;\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\nconst getStoredSessionId = () => {\r\n if (typeof window === 'undefined') return null;\r\n return sessionStorage.getItem('lumely_session_id');\r\n};\r\n\r\nconst createSessionId = () => {\r\n return `sess_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\r\n};\r\n\r\nexport const useLumely = () => {\r\n const context = useContext(LumelyContext);\r\n if (!context) {\r\n throw new Error('useLumely must be used within a LumelyProvider');\r\n }\r\n return context;\r\n};\r\n\r\n/**\r\n * Hook for manually reporting errors that aren't caught by the Error Boundary.\r\n * The error overlay will be shown to the user.\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] = React.useState(() => {\r\n if (config.sessionId) return config.sessionId;\r\n return getStoredSessionId() || createSessionId();\r\n });\r\n\r\n useEffect(() => {\r\n if (typeof window !== 'undefined' && !config.sessionId && sessionId !== 'server') {\r\n const stored = sessionStorage.getItem('lumely_session_id');\r\n if (!stored) {\r\n sessionStorage.setItem('lumely_session_id', sessionId);\r\n }\r\n }\r\n }, [sessionId, config.sessionId]);\r\n const client = useMemo(() => new LumelyClient(config.apiKey, config.apiEndpoint ?? LUMELY_API_ENDPOINT), [config.apiKey, config.apiEndpoint]);\r\n const overlay = useLumelyOverlay();\r\n\r\n // Manual error reporting function - now shows overlay\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 // Show overlay immediately with loading state\r\n overlay?.showOverlay(error);\r\n\r\n try {\r\n const response = await client.reportError(report);\r\n if (response && response.ai) {\r\n overlay?.setAiResponse(response.ai, response.errorId);\r\n } else {\r\n overlay?.setLoading(false);\r\n }\r\n config.onError?.(report);\r\n } catch (e) {\r\n console.error('[Lumely] Error reporting failed:', e);\r\n overlay?.setLoading(false);\r\n }\r\n }, [client, config, sessionId, overlay]);\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);\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 };\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 client,\r\n reportError,\r\n }), [config, sessionId, client, 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\r\n","import React, { useState, useEffect } from 'react';\r\nimport type { LumelyAIResponse } from './types';\r\n\r\n// Inject Poppins font and keyframes\r\nconst injectStyles = () => {\r\n if (typeof document === 'undefined') return;\r\n if (document.getElementById('lumely-react-styles')) return;\r\n\r\n const style = document.createElement('style');\r\n style.id = 'lumely-react-styles';\r\n style.textContent = `\r\n @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');\r\n @keyframes lumely-spin {\r\n from { transform: rotate(0deg); }\r\n to { transform: rotate(360deg); }\r\n }\r\n `;\r\n document.head.appendChild(style);\r\n};\r\n\r\n// SVG Icons as components (replacing lucide-react)\r\nconst XIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n </svg>\r\n);\r\n\r\nconst SendIcon = () => (\r\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\r\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\r\n </svg>\r\n);\r\n\r\nconst ArrowLeftIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"></line>\r\n <polyline points=\"12 19 5 12 12 5\"></polyline>\r\n </svg>\r\n);\r\n\r\nconst RefreshCwIcon = () => (\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\r\n <polyline points=\"23 4 23 10 17 10\"></polyline>\r\n <polyline points=\"1 20 1 14 7 14\"></polyline>\r\n <path d=\"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15\"></path>\r\n </svg>\r\n);\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n overlay: {\r\n position: 'fixed',\r\n inset: 0,\r\n zIndex: 9999,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n padding: '16px',\r\n backgroundColor: 'rgba(0, 0, 0, 0.4)',\r\n backdropFilter: 'blur(8px)',\r\n fontFamily: \"'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\r\n },\r\n card: {\r\n position: 'relative',\r\n width: '100%',\r\n maxWidth: '448px',\r\n background: 'rgba(255, 255, 255, 0.1)',\r\n backdropFilter: 'blur(24px)',\r\n border: '1px solid rgba(255, 255, 255, 0.2)',\r\n borderRadius: '16px',\r\n overflow: 'hidden',\r\n },\r\n closeButton: {\r\n position: 'absolute',\r\n top: '12px',\r\n right: '12px',\r\n padding: '6px',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n background: 'transparent',\r\n border: 'none',\r\n borderRadius: '8px',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'all 0.2s',\r\n },\r\n content: {\r\n padding: '24px',\r\n },\r\n header: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '12px',\r\n marginBottom: '16px',\r\n },\r\n logo: {\r\n width: '40px',\r\n height: '40px',\r\n borderRadius: '12px',\r\n background: 'linear-gradient(135deg, #7c3aed, #8b5cf6)',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n color: 'white',\r\n fontWeight: 700,\r\n fontSize: '18px',\r\n },\r\n title: {\r\n color: 'white',\r\n fontWeight: 600,\r\n fontSize: '14px',\r\n margin: 0,\r\n },\r\n subtitle: {\r\n color: 'rgba(255, 255, 255, 0.5)',\r\n fontSize: '12px',\r\n margin: 0,\r\n },\r\n messageBox: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '16px',\r\n marginBottom: '16px',\r\n },\r\n message: {\r\n color: 'rgba(255, 255, 255, 0.9)',\r\n fontSize: '14px',\r\n lineHeight: 1.6,\r\n margin: 0,\r\n },\r\n loading: {\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '8px',\r\n color: 'rgba(255, 255, 255, 0.7)',\r\n fontSize: '14px',\r\n padding: '16px 0',\r\n },\r\n spinner: {\r\n width: '16px',\r\n height: '16px',\r\n border: '2px solid rgba(255, 255, 255, 0.3)',\r\n borderTopColor: 'white',\r\n borderRadius: '50%',\r\n animation: 'lumely-spin 1s linear infinite',\r\n },\r\n form: {\r\n marginBottom: '16px',\r\n },\r\n label: {\r\n display: 'block',\r\n color: 'rgba(255, 255, 255, 0.6)',\r\n fontSize: '12px',\r\n marginBottom: '8px',\r\n },\r\n inputWrapper: {\r\n position: 'relative',\r\n },\r\n input: {\r\n width: '100%',\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n borderRadius: '12px',\r\n padding: '12px 48px 12px 16px',\r\n color: 'white',\r\n fontSize: '14px',\r\n outline: 'none',\r\n boxSizing: 'border-box',\r\n transition: 'border-color 0.2s',\r\n },\r\n submitButton: {\r\n position: 'absolute',\r\n right: '8px',\r\n top: '50%',\r\n transform: 'translateY(-50%)',\r\n padding: '8px',\r\n color: 'rgba(255, 255, 255, 0.4)',\r\n background: 'transparent',\r\n border: 'none',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n transition: 'color 0.2s',\r\n },\r\n successBox: {\r\n background: 'rgba(34, 197, 94, 0.1)',\r\n border: '1px solid rgba(34, 197, 94, 0.2)',\r\n borderRadius: '12px',\r\n padding: '12px',\r\n marginBottom: '16px',\r\n },\r\n successText: {\r\n color: '#4ade80',\r\n fontSize: '12px',\r\n textAlign: 'center',\r\n margin: 0,\r\n },\r\n buttons: {\r\n display: 'flex',\r\n gap: '8px',\r\n },\r\n button: {\r\n flex: 1,\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n gap: '8px',\r\n padding: '10px 16px',\r\n borderRadius: '12px',\r\n fontSize: '14px',\r\n fontWeight: 500,\r\n cursor: 'pointer',\r\n border: 'none',\r\n transition: 'all 0.2s',\r\n },\r\n secondaryButton: {\r\n background: 'rgba(255, 255, 255, 0.05)',\r\n border: '1px solid rgba(255, 255, 255, 0.1)',\r\n color: 'rgba(255, 255, 255, 0.8)',\r\n },\r\n primaryButton: {\r\n background: '#7c3aed',\r\n color: 'white',\r\n },\r\n};\r\n\r\ninterface LumelyErrorOverlayProps {\r\n aiResponse?: LumelyAIResponse;\r\n isLoading: boolean;\r\n feedbackSubmitted?: boolean;\r\n onSubmitFeedback: (feedback: string) => void;\r\n onRetry: () => void;\r\n onDismiss: () => void;\r\n onGoBack: () => void;\r\n}\r\n\r\nexport const LumelyErrorOverlay = ({\r\n aiResponse,\r\n isLoading,\r\n feedbackSubmitted = false,\r\n onSubmitFeedback,\r\n onRetry,\r\n onDismiss,\r\n onGoBack,\r\n}: LumelyErrorOverlayProps) => {\r\n const [feedback, setFeedback] = useState('');\r\n const [isSubmitting, setIsSubmitting] = useState(false);\r\n\r\n useEffect(() => {\r\n injectStyles();\r\n }, []);\r\n\r\n const handleSubmit = (e: React.FormEvent) => {\r\n e.preventDefault();\r\n if (feedback.trim() && !isSubmitting) {\r\n setIsSubmitting(true);\r\n onSubmitFeedback(feedback);\r\n }\r\n };\r\n\r\n return (\r\n <div style={styles.overlay}>\r\n <div style={styles.card}>\r\n {/* Close Button */}\r\n <button style={styles.closeButton} onClick={onDismiss}>\r\n <XIcon />\r\n </button>\r\n\r\n <div style={styles.content}>\r\n {/* Header */}\r\n <div style={styles.header}>\r\n <div style={styles.logo}>L</div>\r\n <div>\r\n <h3 style={styles.title}>Something went wrong</h3>\r\n <p style={styles.subtitle}>We're looking into it</p>\r\n </div>\r\n </div>\r\n\r\n {/* AI Message */}\r\n {isLoading ? (\r\n <div style={styles.loading}>\r\n <div style={styles.spinner} />\r\n <span>Analyzing the issue...</span>\r\n </div>\r\n ) : aiResponse ? (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>{aiResponse.userMessage}</p>\r\n </div>\r\n ) : (\r\n <div style={styles.messageBox}>\r\n <p style={styles.message}>\r\n We encountered an unexpected issue. Our team has been notified.\r\n </p>\r\n </div>\r\n )}\r\n\r\n {/* Feedback Input */}\r\n {!feedbackSubmitted && !isSubmitting ? (\r\n <form style={styles.form} onSubmit={handleSubmit}>\r\n <label style={styles.label}>What were you trying to do?</label>\r\n <div style={styles.inputWrapper}>\r\n <input\r\n type=\"text\"\r\n value={feedback}\r\n onChange={(e) => setFeedback(e.target.value)}\r\n placeholder=\"e.g., I was trying to save my changes...\"\r\n style={styles.input}\r\n />\r\n <button\r\n type=\"submit\"\r\n disabled={!feedback.trim()}\r\n style={{\r\n ...styles.submitButton,\r\n opacity: feedback.trim() ? 1 : 0.3,\r\n }}\r\n >\r\n <SendIcon />\r\n </button>\r\n </div>\r\n </form>\r\n ) : (\r\n <div style={styles.successBox}>\r\n <p style={styles.successText}>Thank you! Your feedback helps us improve.</p>\r\n </div>\r\n )}\r\n\r\n {/* Action Buttons */}\r\n <div style={styles.buttons}>\r\n <button\r\n style={{ ...styles.button, ...styles.secondaryButton }}\r\n onClick={onGoBack}\r\n >\r\n <ArrowLeftIcon />\r\n Go Back\r\n </button>\r\n <button\r\n style={{ ...styles.button, ...styles.primaryButton }}\r\n onClick={onRetry}\r\n >\r\n <RefreshCwIcon />\r\n Try Again\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n};\r\n","import React, { Component, ErrorInfo } from 'react';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig, LumelyErrorReport, LumelyAIResponse } from './types';\r\n\r\ninterface Props {\r\n children: React.ReactNode;\r\n config: LumelyConfig;\r\n client: LumelyClient;\r\n}\r\n\r\ninterface State {\r\n hasError: boolean;\r\n error: Error | null;\r\n errorInfo: ErrorInfo | null;\r\n aiResponse: LumelyAIResponse | null;\r\n isLoading: boolean;\r\n errorId: string | null;\r\n feedbackSubmitted: boolean;\r\n}\r\n\r\nexport class LumelyErrorBoundary extends Component<Props, State> {\r\n private isReporting = false;\r\n\r\n constructor(props: Props) {\r\n super(props);\r\n this.state = {\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n };\r\n }\r\n\r\n static getDerivedStateFromError(error: Error): Partial<State> {\r\n return { hasError: true, error };\r\n }\r\n\r\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\r\n if (this.isReporting) return;\r\n\r\n this.isReporting = true;\r\n this.setState({ errorInfo, isLoading: true });\r\n this.reportError(error, errorInfo);\r\n }\r\n\r\n private async reportError(error: Error, errorInfo: ErrorInfo) {\r\n const { config, client } = this.props;\r\n\r\n const report: LumelyErrorReport = {\r\n errorMessage: error.message,\r\n errorStack: error.stack,\r\n componentStack: errorInfo.componentStack || undefined,\r\n context: {\r\n url: typeof window !== 'undefined' ? window.location.href : '',\r\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : '',\r\n userId: config.userId,\r\n sessionId: config.sessionId,\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const response = await client.reportError(report);\r\n\r\n this.setState({\r\n aiResponse: response.ai,\r\n errorId: response.errorId,\r\n isLoading: false,\r\n });\r\n\r\n if (config.onError) {\r\n config.onError(report);\r\n }\r\n }\r\n\r\n private handleSubmitFeedback = async (feedback: string) => {\r\n const { errorId } = this.state;\r\n const { client } = this.props;\r\n\r\n if (!errorId || errorId === 'client-error') {\r\n this.setState({ feedbackSubmitted: true });\r\n return;\r\n }\r\n\r\n await client.updateFeedback(errorId, feedback);\r\n this.setState({ feedbackSubmitted: true });\r\n };\r\n\r\n private handleRetry = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleDismiss = () => {\r\n this.isReporting = false;\r\n this.setState({\r\n hasError: false,\r\n error: null,\r\n errorInfo: null,\r\n aiResponse: null,\r\n isLoading: false,\r\n errorId: null,\r\n feedbackSubmitted: false,\r\n });\r\n };\r\n\r\n private handleGoBack = () => {\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n render() {\r\n const { hasError, aiResponse, isLoading, feedbackSubmitted } = this.state;\r\n const { children } = this.props;\r\n\r\n if (hasError) {\r\n return (\r\n <>\r\n {children}\r\n <LumelyErrorOverlay\r\n aiResponse={aiResponse || undefined}\r\n isLoading={isLoading}\r\n feedbackSubmitted={feedbackSubmitted}\r\n onSubmitFeedback={this.handleSubmitFeedback}\r\n onRetry={this.handleRetry}\r\n onDismiss={this.handleDismiss}\r\n onGoBack={this.handleGoBack}\r\n />\r\n </>\r\n );\r\n }\r\n\r\n return children;\r\n }\r\n}\r\n","import React from 'react';\r\nimport { LumelyContextProvider } from './LumelyContext';\r\nimport { LumelyErrorBoundary } from './LumelyErrorBoundary';\r\nimport { LumelyOverlayProvider, useLumelyOverlay } from './LumelyOverlayContext';\r\nimport { LumelyErrorOverlay } from './LumelyErrorOverlay';\r\nimport { LumelyClient } from './LumelyClient';\r\nimport type { LumelyConfig } from './types';\r\nimport { LUMELY_API_ENDPOINT } from './types';\r\n\r\ninterface LumelyProviderProps {\r\n children: React.ReactNode;\r\n apiKey: string;\r\n /** API endpoint for error reporting. Defaults to Lumely's hosted backend. */\r\n apiEndpoint?: string;\r\n environment?: 'development' | 'production';\r\n userId?: string;\r\n sessionId?: string;\r\n onError?: LumelyConfig['onError'];\r\n}\r\n\r\n// Component that renders the overlay for manually reported errors\r\nconst ManualErrorOverlay = ({ apiEndpoint }: { apiEndpoint: string }) => {\r\n const overlay = useLumelyOverlay();\r\n\r\n if (!overlay?.state.isVisible || !overlay.state.error) {\r\n return null;\r\n }\r\n\r\n const handleSubmitFeedback = async (feedback: string) => {\r\n if (!overlay.state.errorId) return;\r\n\r\n try {\r\n await fetch(`${apiEndpoint}/update-feedback`, {\r\n method: 'POST',\r\n headers: { 'Content-Type': 'application/json' },\r\n body: JSON.stringify({\r\n errorId: overlay.state.errorId,\r\n userFeedback: feedback,\r\n }),\r\n });\r\n } catch (e) {\r\n console.error('[Lumely] Failed to submit feedback:', e);\r\n }\r\n };\r\n\r\n const handleGoBack = () => {\r\n overlay.hideOverlay();\r\n if (typeof window !== 'undefined') {\r\n window.history.back();\r\n }\r\n };\r\n\r\n return (\r\n <LumelyErrorOverlay\r\n aiResponse={overlay.state.aiResponse || undefined}\r\n isLoading={overlay.state.isLoading}\r\n feedbackSubmitted={false}\r\n onSubmitFeedback={handleSubmitFeedback}\r\n onRetry={overlay.hideOverlay}\r\n onDismiss={overlay.hideOverlay}\r\n onGoBack={handleGoBack}\r\n />\r\n );\r\n};\r\n\r\n/**\r\n * LumelyProvider for Plain React (Vite, CRA, etc.)\r\n * \r\n * Usage:\r\n * ```tsx\r\n * import { LumelyProvider } from './components/lumely-react';\r\n * \r\n * function App() {\r\n * return (\r\n * <LumelyProvider \r\n * apiKey=\"your-api-key\"\r\n * apiEndpoint=\"https://your-api.com/api/lumely\"\r\n * >\r\n * <YourApp />\r\n * </LumelyProvider>\r\n * );\r\n * }\r\n * ```\r\n */\r\nexport const LumelyProvider = ({\r\n children,\r\n apiKey,\r\n apiEndpoint = LUMELY_API_ENDPOINT,\r\n environment = 'production',\r\n userId,\r\n sessionId,\r\n onError,\r\n}: LumelyProviderProps) => {\r\n const config: LumelyConfig = {\r\n apiKey,\r\n apiEndpoint,\r\n environment,\r\n userId,\r\n sessionId,\r\n onError,\r\n };\r\n\r\n const client = new LumelyClient(apiKey, apiEndpoint);\r\n\r\n return (\r\n <LumelyOverlayProvider>\r\n <LumelyContextProvider config={config}>\r\n <LumelyErrorBoundary config={config} client={client}>\r\n {children}\r\n </LumelyErrorBoundary>\r\n <ManualErrorOverlay apiEndpoint={apiEndpoint} />\r\n </LumelyContextProvider>\r\n </LumelyOverlayProvider>\r\n );\r\n};\r\n\r\n"]}
|