ai-app-client 0.1.2 → 0.1.3
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/dist/index.cjs +48 -0
- package/dist/index.js +48 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// src/error/index.tsx
|
|
4
|
+
function createErrorTools() {
|
|
5
|
+
const handleError = (event) => {
|
|
6
|
+
const errorInfo = {
|
|
7
|
+
type: "error",
|
|
8
|
+
message: event.message,
|
|
9
|
+
filename: event.filename,
|
|
10
|
+
lineno: event.lineno,
|
|
11
|
+
colno: event.colno,
|
|
12
|
+
stack: event.error?.stack,
|
|
13
|
+
timestamp: Date.now()
|
|
14
|
+
};
|
|
15
|
+
sendErrorToTop(errorInfo);
|
|
16
|
+
};
|
|
17
|
+
const handleUnhandledRejection = (event) => {
|
|
18
|
+
const errorInfo = {
|
|
19
|
+
type: "unhandledrejection",
|
|
20
|
+
message: event.reason?.message || String(event.reason),
|
|
21
|
+
stack: event.reason?.stack,
|
|
22
|
+
timestamp: Date.now()
|
|
23
|
+
};
|
|
24
|
+
sendErrorToTop(errorInfo);
|
|
25
|
+
};
|
|
26
|
+
const sendErrorToTop = (errorInfo) => {
|
|
27
|
+
try {
|
|
28
|
+
if (window.top && window.top !== window) {
|
|
29
|
+
window.top.postMessage(
|
|
30
|
+
{
|
|
31
|
+
type: "aiapp-runtime-error",
|
|
32
|
+
data: errorInfo
|
|
33
|
+
},
|
|
34
|
+
"*"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error("Failed to send error to top window:", error);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
window.addEventListener("error", handleError);
|
|
42
|
+
window.addEventListener("unhandledrejection", handleUnhandledRejection);
|
|
43
|
+
return () => {
|
|
44
|
+
window.removeEventListener("error", handleError);
|
|
45
|
+
window.removeEventListener("unhandledrejection", handleUnhandledRejection);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
createErrorTools();
|
|
49
|
+
|
|
3
50
|
// src/auth/index.ts
|
|
4
51
|
var import_supabase_js = require("@supabase/supabase-js");
|
|
5
52
|
|
|
@@ -144,5 +191,6 @@ function createAuthTools() {
|
|
|
144
191
|
|
|
145
192
|
// src/index.ts
|
|
146
193
|
if (typeof window !== "undefined") {
|
|
194
|
+
window.AIApp || (window.AIApp = {});
|
|
147
195
|
createAuthTools();
|
|
148
196
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
// src/error/index.tsx
|
|
2
|
+
function createErrorTools() {
|
|
3
|
+
const handleError = (event) => {
|
|
4
|
+
const errorInfo = {
|
|
5
|
+
type: "error",
|
|
6
|
+
message: event.message,
|
|
7
|
+
filename: event.filename,
|
|
8
|
+
lineno: event.lineno,
|
|
9
|
+
colno: event.colno,
|
|
10
|
+
stack: event.error?.stack,
|
|
11
|
+
timestamp: Date.now()
|
|
12
|
+
};
|
|
13
|
+
sendErrorToTop(errorInfo);
|
|
14
|
+
};
|
|
15
|
+
const handleUnhandledRejection = (event) => {
|
|
16
|
+
const errorInfo = {
|
|
17
|
+
type: "unhandledrejection",
|
|
18
|
+
message: event.reason?.message || String(event.reason),
|
|
19
|
+
stack: event.reason?.stack,
|
|
20
|
+
timestamp: Date.now()
|
|
21
|
+
};
|
|
22
|
+
sendErrorToTop(errorInfo);
|
|
23
|
+
};
|
|
24
|
+
const sendErrorToTop = (errorInfo) => {
|
|
25
|
+
try {
|
|
26
|
+
if (window.top && window.top !== window) {
|
|
27
|
+
window.top.postMessage(
|
|
28
|
+
{
|
|
29
|
+
type: "aiapp-runtime-error",
|
|
30
|
+
data: errorInfo
|
|
31
|
+
},
|
|
32
|
+
"*"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error("Failed to send error to top window:", error);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener("error", handleError);
|
|
40
|
+
window.addEventListener("unhandledrejection", handleUnhandledRejection);
|
|
41
|
+
return () => {
|
|
42
|
+
window.removeEventListener("error", handleError);
|
|
43
|
+
window.removeEventListener("unhandledrejection", handleUnhandledRejection);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
createErrorTools();
|
|
47
|
+
|
|
1
48
|
// src/auth/index.ts
|
|
2
49
|
import { createClient } from "@supabase/supabase-js";
|
|
3
50
|
|
|
@@ -142,5 +189,6 @@ function createAuthTools() {
|
|
|
142
189
|
|
|
143
190
|
// src/index.ts
|
|
144
191
|
if (typeof window !== "undefined") {
|
|
192
|
+
window.AIApp || (window.AIApp = {});
|
|
145
193
|
createAuthTools();
|
|
146
194
|
}
|