@howone/sdk 0.1.17 → 0.1.19
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.d.mts +67 -24
- package/dist/index.d.ts +67 -24
- package/dist/index.js +657 -290
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +654 -292
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -236,12 +236,16 @@ __export(index_exports, {
|
|
|
236
236
|
AUTH_ROOT: () => AUTH_ROOT,
|
|
237
237
|
AUTH_TOKEN_KEY: () => AUTH_TOKEN_KEY,
|
|
238
238
|
AuthProvider: () => AuthProvider,
|
|
239
|
+
ClayxToast: () => ClayxToast,
|
|
239
240
|
DefaultErrorFallback: () => DefaultErrorFallback,
|
|
240
241
|
ErrorBoundary: () => ErrorBoundary,
|
|
241
242
|
FloatingButton: () => FloatingButton,
|
|
243
|
+
GlobalToastContainer: () => GlobalToastContainer,
|
|
242
244
|
Loading: () => Loading,
|
|
243
245
|
LoadingSpinner: () => LoadingSpinner,
|
|
244
246
|
LoginForm: () => LoginForm,
|
|
247
|
+
ThemeProvider: () => ThemeProvider,
|
|
248
|
+
ThemeToggle: () => ThemeToggle,
|
|
245
249
|
aiRequest: () => aiRequest,
|
|
246
250
|
aiWorkflow: () => aiWorkflow,
|
|
247
251
|
canAccessArtifact: () => canAccessArtifact,
|
|
@@ -270,6 +274,7 @@ __export(index_exports, {
|
|
|
270
274
|
useAuthContext: () => useAuthContext,
|
|
271
275
|
useDebounce: () => useDebounce,
|
|
272
276
|
useIsMobile: () => useIsMobile,
|
|
277
|
+
useTheme: () => useTheme,
|
|
273
278
|
workflowRequest: () => workflowRequest
|
|
274
279
|
});
|
|
275
280
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -287,7 +292,7 @@ var FloatingButton = ({
|
|
|
287
292
|
{
|
|
288
293
|
onClick,
|
|
289
294
|
id: "floating-howone-btn",
|
|
290
|
-
className: `fixed flex bg-white gap-2 items-center right-4 z-50 text-black px-3 py-2 rounded-lg shadow-lg transition-colors duration-200 ${className}`,
|
|
295
|
+
className: `fixed flex bg-white dark:bg-gray-800 gap-2 items-center right-4 z-50 text-black dark:text-white px-3 py-2 rounded-lg shadow-lg transition-colors duration-200 border border-gray-200 dark:border-gray-700 ${className}`,
|
|
291
296
|
style: {
|
|
292
297
|
fontSize: "14px",
|
|
293
298
|
fontWeight: "bold",
|
|
@@ -300,7 +305,7 @@ var FloatingButton = ({
|
|
|
300
305
|
e.stopPropagation();
|
|
301
306
|
const btn = document.getElementById("floating-howone-btn");
|
|
302
307
|
if (btn) btn.style.display = "none";
|
|
303
|
-
}, className: "w-5 h-5 font-bold pointer-events-auto" })
|
|
308
|
+
}, className: "w-5 h-5 font-bold pointer-events-auto text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200" })
|
|
304
309
|
] })
|
|
305
310
|
}
|
|
306
311
|
);
|
|
@@ -383,10 +388,8 @@ var UnifiedAuthService = class {
|
|
|
383
388
|
};
|
|
384
389
|
popupCheckInterval = window.setInterval(checkPopupStatus, 1e3);
|
|
385
390
|
const messageHandler = (event) => {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
"https://create-x-backend-dev.fly.dev"
|
|
389
|
-
];
|
|
391
|
+
console.log("messageHandler", event);
|
|
392
|
+
const validOrigins = [window.location.origin, "https://create-x-backend-dev.fly.dev"];
|
|
390
393
|
const isValidOrigin = validOrigins.some(
|
|
391
394
|
(origin) => event.origin === origin || event.origin.includes("localhost") || event.origin.includes("127.0.0.1") || event.origin.includes("fly.dev")
|
|
392
395
|
);
|
|
@@ -646,7 +649,7 @@ var UnifiedAuthService = class {
|
|
|
646
649
|
const response = await fetch(`${this.API_BASE_URL}/api/auth/verify`, {
|
|
647
650
|
method: "GET",
|
|
648
651
|
headers: {
|
|
649
|
-
|
|
652
|
+
Authorization: `Bearer ${token}`
|
|
650
653
|
}
|
|
651
654
|
});
|
|
652
655
|
if (response.ok) {
|
|
@@ -677,8 +680,8 @@ var UnifiedAuthService = class {
|
|
|
677
680
|
}
|
|
678
681
|
}
|
|
679
682
|
/**
|
|
680
|
-
|
|
681
|
-
|
|
683
|
+
* 保存认证数据到本地存储
|
|
684
|
+
*/
|
|
682
685
|
saveAuthData(token) {
|
|
683
686
|
try {
|
|
684
687
|
try {
|
|
@@ -699,7 +702,7 @@ var UnifiedAuthService = class {
|
|
|
699
702
|
await fetch(`${this.API_BASE_URL}/api/auth/logout`, {
|
|
700
703
|
method: "POST",
|
|
701
704
|
headers: {
|
|
702
|
-
|
|
705
|
+
Authorization: `Bearer ${token}`
|
|
703
706
|
}
|
|
704
707
|
});
|
|
705
708
|
} catch (error) {
|
|
@@ -1047,12 +1050,25 @@ function setupClearUrlTokenListener(opts) {
|
|
|
1047
1050
|
}
|
|
1048
1051
|
|
|
1049
1052
|
// src/services/index.ts
|
|
1053
|
+
function getGlobalAvailableToken() {
|
|
1054
|
+
try {
|
|
1055
|
+
return getToken() || null;
|
|
1056
|
+
} catch {
|
|
1057
|
+
return null;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1050
1060
|
var request = new request_default({
|
|
1051
1061
|
baseURL: "https://create-x-backend-dev.fly.dev/api",
|
|
1052
1062
|
timeout: 6e4,
|
|
1053
1063
|
interceptors: {
|
|
1054
1064
|
requestInterceptor: (config) => {
|
|
1055
1065
|
config.headers = config.headers || {};
|
|
1066
|
+
if (!config.headers["Authorization"]) {
|
|
1067
|
+
const availableToken = getGlobalAvailableToken();
|
|
1068
|
+
if (availableToken) {
|
|
1069
|
+
config.headers["Authorization"] = `Bearer ${availableToken}`;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1056
1072
|
return config;
|
|
1057
1073
|
},
|
|
1058
1074
|
requestInterceptorCatch: (err) => {
|
|
@@ -1072,6 +1088,12 @@ var aiRequest = new request_default({
|
|
|
1072
1088
|
interceptors: {
|
|
1073
1089
|
requestInterceptor: (config) => {
|
|
1074
1090
|
config.headers = config.headers || {};
|
|
1091
|
+
if (!config.headers["Authorization"]) {
|
|
1092
|
+
const availableToken = getGlobalAvailableToken();
|
|
1093
|
+
if (availableToken) {
|
|
1094
|
+
config.headers["Authorization"] = `Bearer ${availableToken}`;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1075
1097
|
return config;
|
|
1076
1098
|
},
|
|
1077
1099
|
requestInterceptorCatch: (err) => {
|
|
@@ -1127,6 +1149,12 @@ function createClient(opts) {
|
|
|
1127
1149
|
interceptors: {
|
|
1128
1150
|
requestInterceptor: (config) => {
|
|
1129
1151
|
config.headers = config.headers || {};
|
|
1152
|
+
if (!config.headers["Authorization"]) {
|
|
1153
|
+
const availableToken = getAvailableToken();
|
|
1154
|
+
if (availableToken) {
|
|
1155
|
+
config.headers["Authorization"] = `Bearer ${availableToken}`;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1130
1158
|
return config;
|
|
1131
1159
|
},
|
|
1132
1160
|
requestInterceptorCatch: (err) => Promise.reject(err),
|
|
@@ -1139,12 +1167,23 @@ function createClient(opts) {
|
|
|
1139
1167
|
const ai = opts?.aiRequestInstance || makeRequestFromBase(opts?.aiBaseUrl) || aiRequest;
|
|
1140
1168
|
const bizWrapped = wrapRequestWithProjectPrefix(biz, opts?.projectId);
|
|
1141
1169
|
let token = null;
|
|
1170
|
+
function getAvailableToken() {
|
|
1171
|
+
return token || getGlobalAvailableToken();
|
|
1172
|
+
}
|
|
1142
1173
|
try {
|
|
1143
1174
|
if (opts?.projectId) {
|
|
1144
1175
|
setDefaultProjectId(String(opts.projectId));
|
|
1145
1176
|
}
|
|
1146
1177
|
} catch {
|
|
1147
1178
|
}
|
|
1179
|
+
try {
|
|
1180
|
+
const existingToken = getToken();
|
|
1181
|
+
if (existingToken) {
|
|
1182
|
+
token = existingToken;
|
|
1183
|
+
applyToken(token);
|
|
1184
|
+
}
|
|
1185
|
+
} catch {
|
|
1186
|
+
}
|
|
1148
1187
|
function applyToken(t) {
|
|
1149
1188
|
try {
|
|
1150
1189
|
try {
|
|
@@ -1164,7 +1203,8 @@ function createClient(opts) {
|
|
|
1164
1203
|
const runtimeMode = (() => {
|
|
1165
1204
|
if (opts?.mode) return opts.mode;
|
|
1166
1205
|
try {
|
|
1167
|
-
if (typeof window !== "undefined")
|
|
1206
|
+
if (typeof window !== "undefined")
|
|
1207
|
+
return window.self !== window.top ? "embedded" : "standalone";
|
|
1168
1208
|
} catch (_e) {
|
|
1169
1209
|
return "standalone";
|
|
1170
1210
|
}
|
|
@@ -1520,109 +1560,11 @@ var LoginForm = ({
|
|
|
1520
1560
|
// src/components/auth/AuthProvider.tsx
|
|
1521
1561
|
var import_react4 = require("react");
|
|
1522
1562
|
init_auth();
|
|
1523
|
-
init_config();
|
|
1524
|
-
|
|
1525
|
-
// src/components/ui/Loading.tsx
|
|
1526
1563
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1527
|
-
var Loading = ({
|
|
1528
|
-
size = "md",
|
|
1529
|
-
text = "Loading...",
|
|
1530
|
-
className = "",
|
|
1531
|
-
fullScreen = false
|
|
1532
|
-
}) => {
|
|
1533
|
-
const sizeClasses = {
|
|
1534
|
-
sm: "h-4 w-4",
|
|
1535
|
-
md: "h-8 w-8",
|
|
1536
|
-
lg: "h-12 w-12"
|
|
1537
|
-
};
|
|
1538
|
-
const containerClasses = fullScreen ? "fixed inset-0 flex items-center justify-center bg-white/80 backdrop-blur-sm z-50" : "flex items-center justify-center p-4";
|
|
1539
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "text-center", children: [
|
|
1540
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1541
|
-
"div",
|
|
1542
|
-
{
|
|
1543
|
-
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
|
|
1544
|
-
}
|
|
1545
|
-
),
|
|
1546
|
-
text && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
1547
|
-
] }) });
|
|
1548
|
-
};
|
|
1549
|
-
var LoadingSpinner = ({
|
|
1550
|
-
size = "md",
|
|
1551
|
-
className = ""
|
|
1552
|
-
}) => {
|
|
1553
|
-
const sizeClasses = {
|
|
1554
|
-
sm: "h-4 w-4",
|
|
1555
|
-
md: "h-8 w-8",
|
|
1556
|
-
lg: "h-12 w-12"
|
|
1557
|
-
};
|
|
1558
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1559
|
-
"div",
|
|
1560
|
-
{
|
|
1561
|
-
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
|
|
1562
|
-
}
|
|
1563
|
-
);
|
|
1564
|
-
};
|
|
1565
|
-
|
|
1566
|
-
// src/components/auth/AuthProvider.tsx
|
|
1567
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1568
1564
|
var AuthContext = (0, import_react4.createContext)(null);
|
|
1569
|
-
var AuthProvider = ({ children,
|
|
1565
|
+
var AuthProvider = ({ children, showFloatingButton = true }) => {
|
|
1570
1566
|
const [user, setUser] = (0, import_react4.useState)(() => parseUserFromToken(getToken()));
|
|
1571
1567
|
const [token, setTokenState] = (0, import_react4.useState)(() => getToken());
|
|
1572
|
-
const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
|
|
1573
|
-
(0, import_react4.useEffect)(() => {
|
|
1574
|
-
try {
|
|
1575
|
-
if (projectId) setDefaultProjectId(String(projectId));
|
|
1576
|
-
} catch {
|
|
1577
|
-
}
|
|
1578
|
-
setIsLoading(true);
|
|
1579
|
-
try {
|
|
1580
|
-
const cb = unifiedAuth.checkOAuthCallback();
|
|
1581
|
-
if (cb && cb.success) {
|
|
1582
|
-
setTokenState(cb.token ?? getToken());
|
|
1583
|
-
setUser(cb.user ?? parseUserFromToken(cb.token ?? getToken()));
|
|
1584
|
-
setIsLoading(false);
|
|
1585
|
-
return;
|
|
1586
|
-
}
|
|
1587
|
-
} catch {
|
|
1588
|
-
}
|
|
1589
|
-
const unsubscribe = onAuthStateChanged((state) => {
|
|
1590
|
-
try {
|
|
1591
|
-
setTokenState(getToken());
|
|
1592
|
-
setUser(state.user ?? parseUserFromToken(getToken()));
|
|
1593
|
-
} catch {
|
|
1594
|
-
}
|
|
1595
|
-
setIsLoading(false);
|
|
1596
|
-
if (autoRedirect && !state.user) {
|
|
1597
|
-
try {
|
|
1598
|
-
const root = getAuthRoot();
|
|
1599
|
-
const authUrl = new URL("/auth", String(root));
|
|
1600
|
-
authUrl.searchParams.set("redirect_uri", window.location.href);
|
|
1601
|
-
const pid = getDefaultProjectId();
|
|
1602
|
-
if (pid) authUrl.searchParams.set("project_id", pid);
|
|
1603
|
-
try {
|
|
1604
|
-
if (window.top && window.top !== window) {
|
|
1605
|
-
window.top.location.replace(authUrl.toString());
|
|
1606
|
-
} else {
|
|
1607
|
-
window.location.replace(authUrl.toString());
|
|
1608
|
-
}
|
|
1609
|
-
} catch (e) {
|
|
1610
|
-
try {
|
|
1611
|
-
window.location.replace(authUrl.toString());
|
|
1612
|
-
} catch {
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
} catch {
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
});
|
|
1619
|
-
return () => {
|
|
1620
|
-
try {
|
|
1621
|
-
unsubscribe();
|
|
1622
|
-
} catch {
|
|
1623
|
-
}
|
|
1624
|
-
};
|
|
1625
|
-
}, [autoRedirect]);
|
|
1626
1568
|
const logout = () => {
|
|
1627
1569
|
try {
|
|
1628
1570
|
setToken(null);
|
|
@@ -1637,12 +1579,9 @@ var AuthProvider = ({ children, autoRedirect = true, showFloatingButton = true,
|
|
|
1637
1579
|
isAuthenticated: !!token,
|
|
1638
1580
|
logout
|
|
1639
1581
|
};
|
|
1640
|
-
return /* @__PURE__ */ (0,
|
|
1641
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Loading, { fullScreen: true, text: "Checking authentication..." }),
|
|
1642
|
-
showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
1643
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AuthContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1644
1583
|
children,
|
|
1645
|
-
showFloatingButton && /* @__PURE__ */ (0,
|
|
1584
|
+
showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
1646
1585
|
] }) });
|
|
1647
1586
|
};
|
|
1648
1587
|
function useAuthContext() {
|
|
@@ -1749,6 +1688,47 @@ var howone = {
|
|
|
1749
1688
|
};
|
|
1750
1689
|
var client_default = howone;
|
|
1751
1690
|
|
|
1691
|
+
// src/components/ui/Loading.tsx
|
|
1692
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1693
|
+
var Loading = ({
|
|
1694
|
+
size = "md",
|
|
1695
|
+
text = "Loading...",
|
|
1696
|
+
className = "",
|
|
1697
|
+
fullScreen = false
|
|
1698
|
+
}) => {
|
|
1699
|
+
const sizeClasses = {
|
|
1700
|
+
sm: "h-4 w-4",
|
|
1701
|
+
md: "h-8 w-8",
|
|
1702
|
+
lg: "h-12 w-12"
|
|
1703
|
+
};
|
|
1704
|
+
const containerClasses = fullScreen ? "fixed inset-0 flex items-center justify-center bg-white/80 backdrop-blur-sm z-50" : "flex items-center justify-center p-4";
|
|
1705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "text-center", children: [
|
|
1706
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1707
|
+
"div",
|
|
1708
|
+
{
|
|
1709
|
+
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
|
|
1710
|
+
}
|
|
1711
|
+
),
|
|
1712
|
+
text && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
1713
|
+
] }) });
|
|
1714
|
+
};
|
|
1715
|
+
var LoadingSpinner = ({
|
|
1716
|
+
size = "md",
|
|
1717
|
+
className = ""
|
|
1718
|
+
}) => {
|
|
1719
|
+
const sizeClasses = {
|
|
1720
|
+
sm: "h-4 w-4",
|
|
1721
|
+
md: "h-8 w-8",
|
|
1722
|
+
lg: "h-12 w-12"
|
|
1723
|
+
};
|
|
1724
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1725
|
+
"div",
|
|
1726
|
+
{
|
|
1727
|
+
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
|
|
1728
|
+
}
|
|
1729
|
+
);
|
|
1730
|
+
};
|
|
1731
|
+
|
|
1752
1732
|
// src/components/ui/ErrorBoundary.tsx
|
|
1753
1733
|
var import_react5 = require("react");
|
|
1754
1734
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -1807,12 +1787,273 @@ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ (0, import_jsx_runtime
|
|
|
1807
1787
|
)
|
|
1808
1788
|
] }) });
|
|
1809
1789
|
|
|
1810
|
-
// src/
|
|
1790
|
+
// src/components/theme/ThemeProvider.tsx
|
|
1791
|
+
var import_react6 = require("react");
|
|
1792
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1793
|
+
var initialState = {
|
|
1794
|
+
theme: "system",
|
|
1795
|
+
setTheme: () => null
|
|
1796
|
+
};
|
|
1797
|
+
var ThemeProviderContext = (0, import_react6.createContext)(initialState);
|
|
1798
|
+
function ThemeProvider({
|
|
1799
|
+
children,
|
|
1800
|
+
defaultTheme = "system",
|
|
1801
|
+
storageKey = "vite-ui-theme",
|
|
1802
|
+
...props
|
|
1803
|
+
}) {
|
|
1804
|
+
const [theme, setTheme] = (0, import_react6.useState)(
|
|
1805
|
+
() => localStorage.getItem(storageKey) || defaultTheme
|
|
1806
|
+
);
|
|
1807
|
+
(0, import_react6.useEffect)(() => {
|
|
1808
|
+
const root = window.document.documentElement;
|
|
1809
|
+
root.classList.remove("light", "dark");
|
|
1810
|
+
if (theme === "system") {
|
|
1811
|
+
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1812
|
+
root.classList.add(systemTheme);
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
root.classList.add(theme);
|
|
1816
|
+
}, [theme]);
|
|
1817
|
+
const value = {
|
|
1818
|
+
theme,
|
|
1819
|
+
setTheme: (theme2) => {
|
|
1820
|
+
localStorage.setItem(storageKey, theme2);
|
|
1821
|
+
setTheme(theme2);
|
|
1822
|
+
}
|
|
1823
|
+
};
|
|
1824
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ThemeProviderContext.Provider, { ...props, value, children });
|
|
1825
|
+
}
|
|
1826
|
+
var useTheme = () => {
|
|
1827
|
+
const context = (0, import_react6.useContext)(ThemeProviderContext);
|
|
1828
|
+
if (context === void 0)
|
|
1829
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
1830
|
+
return context;
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
|
+
// src/components/theme/ThemeToggle.tsx
|
|
1811
1834
|
var React4 = __toESM(require("react"));
|
|
1835
|
+
var import_next_themes = require("next-themes");
|
|
1836
|
+
var import_react7 = require("@iconify/react");
|
|
1837
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1838
|
+
function ThemeToggle({ className }) {
|
|
1839
|
+
const { setTheme, theme } = (0, import_next_themes.useTheme)();
|
|
1840
|
+
const [mounted, setMounted] = React4.useState(false);
|
|
1841
|
+
React4.useEffect(() => {
|
|
1842
|
+
setMounted(true);
|
|
1843
|
+
}, []);
|
|
1844
|
+
if (!mounted) {
|
|
1845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1846
|
+
"button",
|
|
1847
|
+
{
|
|
1848
|
+
className: `relative inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground ${className || ""}`,
|
|
1849
|
+
disabled: true,
|
|
1850
|
+
children: [
|
|
1851
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.Icon, { icon: "solar:sun-2-linear", width: 20, height: 20 }),
|
|
1852
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sr-only", children: "Toggle theme" })
|
|
1853
|
+
]
|
|
1854
|
+
}
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1858
|
+
"button",
|
|
1859
|
+
{
|
|
1860
|
+
className: `inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors ${className || ""}`,
|
|
1861
|
+
onClick: () => setTheme(theme === "light" ? "dark" : "light"),
|
|
1862
|
+
children: [
|
|
1863
|
+
theme === "light" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.Icon, { icon: "solar:sun-2-linear", width: 20, height: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.Icon, { icon: "solar:moon-linear", width: 20, height: 20 }),
|
|
1864
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sr-only", children: "Toggle theme" })
|
|
1865
|
+
]
|
|
1866
|
+
}
|
|
1867
|
+
);
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
// src/components/ui/Toast/GlobalToastContainer.tsx
|
|
1871
|
+
var import_react_toastify = require("react-toastify");
|
|
1872
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1873
|
+
function GlobalToastContainer() {
|
|
1874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1875
|
+
import_react_toastify.ToastContainer,
|
|
1876
|
+
{
|
|
1877
|
+
newestOnTop: false,
|
|
1878
|
+
closeButton: false
|
|
1879
|
+
}
|
|
1880
|
+
);
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
// src/components/ui/Toast/ClayxToast.tsx
|
|
1884
|
+
var import_react8 = __toESM(require("react"));
|
|
1885
|
+
var import_react_toastify2 = require("react-toastify");
|
|
1886
|
+
var import_react9 = require("@iconify/react");
|
|
1887
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1888
|
+
var TOAST_ICONS = {
|
|
1889
|
+
success: {
|
|
1890
|
+
icon: "mdi:success",
|
|
1891
|
+
color: "text-green-400",
|
|
1892
|
+
className: "text-green-400",
|
|
1893
|
+
bgGradient: "bg-[#14181df2]",
|
|
1894
|
+
gradientColor: "#389726",
|
|
1895
|
+
borderGradient: "border-[#389726]",
|
|
1896
|
+
borderGradientColor: "#389726"
|
|
1897
|
+
},
|
|
1898
|
+
error: {
|
|
1899
|
+
icon: "ic:outline-close",
|
|
1900
|
+
color: "text-red-400",
|
|
1901
|
+
className: "text-red-400",
|
|
1902
|
+
bgGradient: "bg-[#14181df2]",
|
|
1903
|
+
gradientColor: "#ef4444",
|
|
1904
|
+
borderGradient: "border-[#ef4444]",
|
|
1905
|
+
borderGradientColor: "#ef4444"
|
|
1906
|
+
},
|
|
1907
|
+
warning: {
|
|
1908
|
+
icon: "mi:warning",
|
|
1909
|
+
color: "text-yellow-400",
|
|
1910
|
+
className: "text-yellow-400",
|
|
1911
|
+
bgGradient: "bg-[#14181df2]",
|
|
1912
|
+
gradientColor: "#facc15",
|
|
1913
|
+
borderGradient: "border-[#facc15]",
|
|
1914
|
+
borderGradientColor: "#facc15"
|
|
1915
|
+
},
|
|
1916
|
+
info: {
|
|
1917
|
+
icon: "ic:outline-info",
|
|
1918
|
+
color: "text-blue-400",
|
|
1919
|
+
className: "text-blue-400",
|
|
1920
|
+
bgGradient: "bg-[#14181df2]",
|
|
1921
|
+
gradientColor: "#60a5fa",
|
|
1922
|
+
borderGradient: "border-[#60a5fa]",
|
|
1923
|
+
borderGradientColor: "#f0f0f0"
|
|
1924
|
+
},
|
|
1925
|
+
default: {
|
|
1926
|
+
icon: "ic:round-notifications",
|
|
1927
|
+
color: "text-gray-400",
|
|
1928
|
+
className: "text-gray-400",
|
|
1929
|
+
bgGradient: "bg-[#14181df2]",
|
|
1930
|
+
gradientColor: "#9ca3af",
|
|
1931
|
+
borderGradient: "border-[#9ca3af]",
|
|
1932
|
+
borderGradientColor: "#9ca3af"
|
|
1933
|
+
}
|
|
1934
|
+
};
|
|
1935
|
+
var CloseButton = import_react8.default.memo(({ closeToast }) => {
|
|
1936
|
+
const handleClick = (0, import_react8.useCallback)((e) => {
|
|
1937
|
+
e.preventDefault();
|
|
1938
|
+
e.stopPropagation();
|
|
1939
|
+
closeToast?.();
|
|
1940
|
+
}, [closeToast]);
|
|
1941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1942
|
+
import_react9.Icon,
|
|
1943
|
+
{
|
|
1944
|
+
icon: "vaadin:close",
|
|
1945
|
+
className: "flex items-center justify-center rounded-full relative z-10 flex-shrink-0 cursor-pointer \n !text-[#b4b4b4] hover:text-white transition-colors duration-200 drop-shadow-sm",
|
|
1946
|
+
onClick: handleClick,
|
|
1947
|
+
width: 14,
|
|
1948
|
+
height: 14
|
|
1949
|
+
}
|
|
1950
|
+
);
|
|
1951
|
+
});
|
|
1952
|
+
CloseButton.displayName = "CloseButton";
|
|
1953
|
+
var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
1954
|
+
const iconConfig = TOAST_ICONS[type];
|
|
1955
|
+
const handleClose = (0, import_react8.useCallback)(() => {
|
|
1956
|
+
closeToast?.();
|
|
1957
|
+
}, [closeToast]);
|
|
1958
|
+
console.log(iconConfig, "????????");
|
|
1959
|
+
if (component) {
|
|
1960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `flex items-start gap-3 min-h-[80px] w-full backdrop-blur-md
|
|
1961
|
+
rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
|
|
1962
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 relative z-10", children: component }),
|
|
1963
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { closeToast: handleClose }) })
|
|
1964
|
+
] });
|
|
1965
|
+
}
|
|
1966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `flex items-start gap-3 min-h-[60px] w-full backdrop-blur-md
|
|
1967
|
+
rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
|
|
1968
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1969
|
+
"div",
|
|
1970
|
+
{
|
|
1971
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
1972
|
+
style: {
|
|
1973
|
+
background: `linear-gradient(135deg, ${iconConfig.gradientColor}30 0%, ${iconConfig.gradientColor}20 15%, #14181df2 30%)`
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
),
|
|
1977
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1978
|
+
"div",
|
|
1979
|
+
{
|
|
1980
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
1981
|
+
style: {
|
|
1982
|
+
border: "2px solid transparent",
|
|
1983
|
+
backgroundImage: `linear-gradient(135deg, ${iconConfig.borderGradientColor}60 0%, ${iconConfig.borderGradientColor}40 5%, transparent 22%)`,
|
|
1984
|
+
backgroundOrigin: "border-box",
|
|
1985
|
+
backgroundClip: "border-box",
|
|
1986
|
+
WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
1987
|
+
WebkitMaskComposite: "xor",
|
|
1988
|
+
mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
1989
|
+
maskComposite: "exclude"
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
),
|
|
1993
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-shrink-0 mt-0.5 relative z-10 ", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "w-7 h-7 bg-white/10 backdrop-blur-sm rounded-full flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1994
|
+
import_react9.Icon,
|
|
1995
|
+
{
|
|
1996
|
+
icon: iconConfig.icon,
|
|
1997
|
+
width: 16,
|
|
1998
|
+
height: 16,
|
|
1999
|
+
className: iconConfig.color
|
|
2000
|
+
}
|
|
2001
|
+
) }) }),
|
|
2002
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
|
|
2003
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[16px] font-semibold leading-tight text-white/95 drop-shadow-sm", children: title }),
|
|
2004
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[13px] font-normal leading-relaxed text-white/75 drop-shadow-sm", children: message })
|
|
2005
|
+
] }),
|
|
2006
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { closeToast: handleClose }) })
|
|
2007
|
+
] });
|
|
2008
|
+
};
|
|
2009
|
+
var defaultToastOptions = {
|
|
2010
|
+
position: "bottom-right",
|
|
2011
|
+
autoClose: 3e3,
|
|
2012
|
+
hideProgressBar: true,
|
|
2013
|
+
closeOnClick: false,
|
|
2014
|
+
pauseOnHover: true,
|
|
2015
|
+
draggable: true,
|
|
2016
|
+
pauseOnFocusLoss: false,
|
|
2017
|
+
theme: "dark",
|
|
2018
|
+
transition: import_react_toastify2.Bounce
|
|
2019
|
+
};
|
|
2020
|
+
var createToast = (type) => {
|
|
2021
|
+
return (params) => {
|
|
2022
|
+
const { title, message, component, options } = params;
|
|
2023
|
+
(0, import_react_toastify2.toast)(
|
|
2024
|
+
({ closeToast }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2025
|
+
ToastContent,
|
|
2026
|
+
{
|
|
2027
|
+
type,
|
|
2028
|
+
title,
|
|
2029
|
+
message: message || "",
|
|
2030
|
+
component,
|
|
2031
|
+
closeToast
|
|
2032
|
+
}
|
|
2033
|
+
),
|
|
2034
|
+
{
|
|
2035
|
+
...defaultToastOptions,
|
|
2036
|
+
...options,
|
|
2037
|
+
className: "!bg-transparent !p-0 !shadow-none",
|
|
2038
|
+
style: { background: "transparent", padding: 0 }
|
|
2039
|
+
}
|
|
2040
|
+
);
|
|
2041
|
+
};
|
|
2042
|
+
};
|
|
2043
|
+
var ClayxToast = {
|
|
2044
|
+
success: createToast("success"),
|
|
2045
|
+
error: createToast("error"),
|
|
2046
|
+
warning: createToast("warning"),
|
|
2047
|
+
info: createToast("info"),
|
|
2048
|
+
default: createToast("default")
|
|
2049
|
+
};
|
|
2050
|
+
|
|
2051
|
+
// src/hooks/use-mobile.ts
|
|
2052
|
+
var React6 = __toESM(require("react"));
|
|
1812
2053
|
var MOBILE_BREAKPOINT = 768;
|
|
1813
2054
|
function useIsMobile() {
|
|
1814
|
-
const [isMobile, setIsMobile] =
|
|
1815
|
-
|
|
2055
|
+
const [isMobile, setIsMobile] = React6.useState(void 0);
|
|
2056
|
+
React6.useEffect(() => {
|
|
1816
2057
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
1817
2058
|
const onChange = () => {
|
|
1818
2059
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
@@ -1825,10 +2066,10 @@ function useIsMobile() {
|
|
|
1825
2066
|
}
|
|
1826
2067
|
|
|
1827
2068
|
// src/hooks/use-debounce.ts
|
|
1828
|
-
var
|
|
2069
|
+
var import_react10 = require("react");
|
|
1829
2070
|
function useDebounce(value, delay) {
|
|
1830
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
1831
|
-
(0,
|
|
2071
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react10.useState)(value);
|
|
2072
|
+
(0, import_react10.useEffect)(() => {
|
|
1832
2073
|
const handler = setTimeout(() => {
|
|
1833
2074
|
setDebouncedValue(value);
|
|
1834
2075
|
}, delay);
|
|
@@ -1839,214 +2080,335 @@ function useDebounce(value, delay) {
|
|
|
1839
2080
|
return debouncedValue;
|
|
1840
2081
|
}
|
|
1841
2082
|
|
|
1842
|
-
// src/utils/
|
|
1843
|
-
function
|
|
1844
|
-
|
|
1845
|
-
const
|
|
1846
|
-
(
|
|
1847
|
-
const isIframe = window.self !== window.top;
|
|
1848
|
-
console.log("isIframe", isIframe);
|
|
2083
|
+
// src/utils/errorHandler.ts
|
|
2084
|
+
var ERROR_HANDLER_SCRIPT = `(function () {
|
|
2085
|
+
// \u68C0\u67E5\u662F\u5426\u5728 iframe \u4E2D\u8FD0\u884C
|
|
2086
|
+
const isIframe = window.self !== window.top;
|
|
2087
|
+
console.log("isIframe", isIframe);
|
|
1849
2088
|
|
|
1850
|
-
|
|
2089
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316");
|
|
1851
2090
|
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
2091
|
+
// \u76F4\u63A5\u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u7684\u51FD\u6570
|
|
2092
|
+
window.__SEND_ERROR_TO_PARENT__ = function (error, details) {
|
|
2093
|
+
try {
|
|
2094
|
+
const errorPayload = {
|
|
2095
|
+
message: error instanceof Error ? error.message : String(error),
|
|
2096
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
2097
|
+
filename: details?.file || details?.filename,
|
|
2098
|
+
lineno: details?.line,
|
|
2099
|
+
colno: details?.column,
|
|
2100
|
+
timestamp: Date.now(),
|
|
2101
|
+
type: details?.type || "compile-error",
|
|
2102
|
+
details: details,
|
|
2103
|
+
};
|
|
1864
2104
|
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
2105
|
+
window.parent.postMessage(
|
|
2106
|
+
{
|
|
2107
|
+
type: "ERROR_EVENT",
|
|
2108
|
+
payload: errorPayload,
|
|
2109
|
+
},
|
|
2110
|
+
"*"
|
|
2111
|
+
);
|
|
2112
|
+
|
|
2113
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u9519\u8BEF\u5DF2\u53D1\u9001\u5230\u7236\u7A97\u53E3:", errorPayload);
|
|
2114
|
+
} catch (e) {
|
|
2115
|
+
console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u5931\u8D25:", e);
|
|
2116
|
+
}
|
|
2117
|
+
};
|
|
1871
2118
|
|
|
1872
|
-
|
|
1873
|
-
|
|
2119
|
+
// \u8BBE\u7F6E MutationObserver \u76D1\u542C vite-error-overlay
|
|
2120
|
+
function setupViteOverlayObserver() {
|
|
2121
|
+
if (!window.MutationObserver) return;
|
|
1874
2122
|
|
|
1875
|
-
|
|
2123
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u8BBE\u7F6E Vite \u9519\u8BEF overlay \u76D1\u542C\u5668");
|
|
1876
2124
|
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
const shadowRoot = overlay.shadowRoot;
|
|
1881
|
-
if (!shadowRoot) return;
|
|
2125
|
+
function processViteErrorOverlay(overlay) {
|
|
2126
|
+
try {
|
|
2127
|
+
if (overlay.hasAttribute("data-error-sent")) return;
|
|
1882
2128
|
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
2129
|
+
const shadowRoot = overlay.shadowRoot;
|
|
2130
|
+
if (!shadowRoot) {
|
|
2131
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] vite-error-overlay \u6CA1\u6709 Shadow DOM");
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
const messageElement = shadowRoot.querySelector("pre.message");
|
|
2136
|
+
const fileElement = shadowRoot.querySelector("pre.file");
|
|
2137
|
+
const frameElements = shadowRoot.querySelectorAll("pre.frame");
|
|
2138
|
+
const stackElement = shadowRoot.querySelector("pre.stack");
|
|
1887
2139
|
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
2140
|
+
const message = messageElement ? messageElement.textContent : "";
|
|
2141
|
+
const file = fileElement ? fileElement.textContent : "";
|
|
2142
|
+
const frames = Array.from(frameElements)
|
|
2143
|
+
.map((el) => el.textContent)
|
|
2144
|
+
.join("
|
|
1891
2145
|
");
|
|
1892
|
-
|
|
2146
|
+
const stack = stackElement ? stackElement.textContent : "";
|
|
1893
2147
|
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
2148
|
+
let line, column;
|
|
2149
|
+
const fileStr = file || "";
|
|
2150
|
+
const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(d+)(?::| )(d+)/i);
|
|
2151
|
+
if (lineColMatch) {
|
|
2152
|
+
line = parseInt(lineColMatch[1], 10);
|
|
2153
|
+
column = parseInt(lineColMatch[2], 10);
|
|
2154
|
+
}
|
|
1901
2155
|
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2156
|
+
const messageStr = message || "";
|
|
2157
|
+
const isReactError =
|
|
2158
|
+
messageStr.includes("React") ||
|
|
2159
|
+
messageStr.includes("JSX") ||
|
|
2160
|
+
messageStr.includes("Unexpected token") ||
|
|
2161
|
+
messageStr.includes("vite:react-babel");
|
|
1908
2162
|
|
|
1909
|
-
|
|
2163
|
+
const viteError = new Error(messageStr);
|
|
1910
2164
|
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
2165
|
+
window.__SEND_ERROR_TO_PARENT__(viteError, {
|
|
2166
|
+
file,
|
|
2167
|
+
line,
|
|
2168
|
+
column,
|
|
2169
|
+
frames,
|
|
2170
|
+
stack,
|
|
2171
|
+
isReactError,
|
|
2172
|
+
type: isReactError ? "react-syntax" : "vite-error-overlay",
|
|
2173
|
+
});
|
|
1920
2174
|
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
}
|
|
2175
|
+
overlay.setAttribute("data-error-sent", "true");
|
|
2176
|
+
} catch (e) {
|
|
2177
|
+
console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u5904\u7406 vite-error-overlay \u5931\u8D25:", e);
|
|
1925
2178
|
}
|
|
2179
|
+
}
|
|
1926
2180
|
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
}
|
|
2181
|
+
function checkExistingOverlays() {
|
|
2182
|
+
const viteErrorOverlays = document.querySelectorAll("vite-error-overlay");
|
|
2183
|
+
if (viteErrorOverlays.length > 0) {
|
|
2184
|
+
viteErrorOverlays.forEach((overlay) => {
|
|
2185
|
+
if (!overlay.hasAttribute("data-error-sent")) {
|
|
2186
|
+
processViteErrorOverlay(overlay);
|
|
2187
|
+
}
|
|
2188
|
+
});
|
|
1936
2189
|
}
|
|
2190
|
+
}
|
|
1937
2191
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
2192
|
+
const observer = new MutationObserver((mutations) => {
|
|
2193
|
+
for (const mutation of mutations) {
|
|
2194
|
+
if (mutation.addedNodes.length > 0) {
|
|
2195
|
+
for (const node of Array.from(mutation.addedNodes)) {
|
|
2196
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
2197
|
+
const element = node;
|
|
2198
|
+
|
|
2199
|
+
if (
|
|
2200
|
+
element.tagName === "VITE-ERROR-OVERLAY" &&
|
|
2201
|
+
!element.hasAttribute("data-error-sent")
|
|
2202
|
+
) {
|
|
2203
|
+
setTimeout(() => processViteErrorOverlay(element), 100);
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
const viteErrorOverlays = element.querySelectorAll("vite-error-overlay");
|
|
2207
|
+
for (const viteErrorOverlay of Array.from(viteErrorOverlays)) {
|
|
2208
|
+
if (!viteErrorOverlay.hasAttribute("data-error-sent")) {
|
|
2209
|
+
setTimeout(() => processViteErrorOverlay(viteErrorOverlay), 100);
|
|
1952
2210
|
}
|
|
1953
2211
|
}
|
|
1954
2212
|
}
|
|
1955
2213
|
}
|
|
1956
2214
|
}
|
|
1957
|
-
}
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
1958
2217
|
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
2218
|
+
observer.observe(document.documentElement, {
|
|
2219
|
+
childList: true,
|
|
2220
|
+
subtree: true,
|
|
2221
|
+
attributes: true,
|
|
2222
|
+
characterData: true,
|
|
2223
|
+
});
|
|
1963
2224
|
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
const target = event && (event.target || event.srcElement);
|
|
1968
|
-
const tagName = target && target.tagName;
|
|
1969
|
-
if (tagName) {
|
|
1970
|
-
const url = (target && (target.src || target.href || target.currentSrc)) || (target && target.getAttribute && (target.getAttribute('src') || target.getAttribute('href')));
|
|
1971
|
-
const preview = target && target.outerHTML ? String(target.outerHTML).slice(0, 300) : undefined;
|
|
1972
|
-
const resourceError = new Error('Resource load error: ' + tagName + ' ' + (url || 'unknown'));
|
|
1973
|
-
window.__SEND_ERROR_TO_PARENT__(resourceError, { filename: url, tagName: tagName, element: preview, type: "resource" });
|
|
1974
|
-
return;
|
|
1975
|
-
}
|
|
2225
|
+
setTimeout(checkExistingOverlays, 500);
|
|
2226
|
+
setInterval(checkExistingOverlays, 2000);
|
|
2227
|
+
}
|
|
1976
2228
|
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
2229
|
+
window.addEventListener(
|
|
2230
|
+
"error",
|
|
2231
|
+
function (event) {
|
|
2232
|
+
const target = event && (event.target || event.srcElement);
|
|
2233
|
+
const tagName = target && target.tagName;
|
|
2234
|
+
if (tagName) {
|
|
2235
|
+
const url = (target && (target.src || target.href || target.currentSrc)) ||
|
|
2236
|
+
(target && target.getAttribute && (target.getAttribute('src') || target.getAttribute('href')));
|
|
2237
|
+
const preview = target && target.outerHTML ? String(target.outerHTML).slice(0, 300) : undefined;
|
|
2238
|
+
const resourceError = new Error('Resource load error: ' + tagName + ' ' + (url || 'unknown'));
|
|
2239
|
+
window.__SEND_ERROR_TO_PARENT__(resourceError, {
|
|
2240
|
+
filename: url,
|
|
2241
|
+
tagName: tagName,
|
|
2242
|
+
element: preview,
|
|
2243
|
+
type: "resource"
|
|
2244
|
+
});
|
|
2245
|
+
return;
|
|
2246
|
+
}
|
|
1980
2247
|
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
2248
|
+
var stack = (event && event.error && event.error.stack) || "";
|
|
2249
|
+
var message = typeof event.message === "string" ? event.message : "";
|
|
2250
|
+
if ((stack && stack.indexOf('error-handler') !== -1) || !message) return;
|
|
2251
|
+
|
|
2252
|
+
window.__SEND_ERROR_TO_PARENT__(event.error || new Error(event.message), {
|
|
2253
|
+
filename: event.filename,
|
|
2254
|
+
line: event.lineno,
|
|
2255
|
+
column: event.colno,
|
|
2256
|
+
type: "runtime",
|
|
2257
|
+
});
|
|
2258
|
+
},
|
|
2259
|
+
true
|
|
2260
|
+
);
|
|
2261
|
+
|
|
2262
|
+
window.addEventListener("unhandledrejection", function (event) {
|
|
2263
|
+
const reason = event.reason;
|
|
2264
|
+
window.__SEND_ERROR_TO_PARENT__(
|
|
2265
|
+
reason instanceof Error ? reason : new Error(String(reason)),
|
|
2266
|
+
{ type: "promise" }
|
|
1984
2267
|
);
|
|
2268
|
+
});
|
|
1985
2269
|
|
|
1986
|
-
|
|
1987
|
-
const reason = event.reason;
|
|
1988
|
-
window.__SEND_ERROR_TO_PARENT__(reason instanceof Error ? reason : new Error(String(reason)), { type: "promise" });
|
|
1989
|
-
});
|
|
2270
|
+
setupViteOverlayObserver();
|
|
1990
2271
|
|
|
1991
|
-
|
|
2272
|
+
if (!window.__FETCH_INTERCEPTED__) {
|
|
2273
|
+
window.__FETCH_INTERCEPTED__ = true;
|
|
2274
|
+
const originalFetch = window.fetch;
|
|
2275
|
+
|
|
2276
|
+
function handleFetchError(error, url, response = null) {
|
|
2277
|
+
const errorDetails = {
|
|
2278
|
+
type: "network",
|
|
2279
|
+
method: "fetch",
|
|
2280
|
+
url: url
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2283
|
+
if (response && !response.ok) {
|
|
2284
|
+
errorDetails.status = response.status;
|
|
2285
|
+
errorDetails.statusText = response.statusText;
|
|
2286
|
+
errorDetails.networkError = false;
|
|
2287
|
+
} else {
|
|
2288
|
+
errorDetails.networkError = true;
|
|
2289
|
+
}
|
|
2290
|
+
window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
window.fetch = function(...args) {
|
|
2294
|
+
const url = args[0] instanceof Request ? args[0].url : args[0];
|
|
2295
|
+
|
|
2296
|
+
return originalFetch.apply(this, args)
|
|
2297
|
+
.then(response => {
|
|
2298
|
+
if (!response.ok) {
|
|
2299
|
+
const networkError = new Error(\`HTTP \${response.status}: \${response.statusText}\`);
|
|
2300
|
+
handleFetchError(networkError, url, response);
|
|
2301
|
+
}
|
|
2302
|
+
return response;
|
|
2303
|
+
})
|
|
2304
|
+
.catch(error => {
|
|
2305
|
+
handleFetchError(error, url);
|
|
2306
|
+
throw error;
|
|
2307
|
+
});
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
1992
2310
|
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2311
|
+
if (!window.__XHR_INTERCEPTED__) {
|
|
2312
|
+
window.__XHR_INTERCEPTED__ = true;
|
|
2313
|
+
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
2314
|
+
const originalXHRSend = XMLHttpRequest.prototype.send;
|
|
2315
|
+
|
|
2316
|
+
function handleXHRError(error, xhr, isNetworkError = false) {
|
|
2317
|
+
const errorDetails = {
|
|
2318
|
+
type: "network",
|
|
2319
|
+
method: "xhr",
|
|
2320
|
+
url: xhr.__intercepted_url__
|
|
2321
|
+
};
|
|
2322
|
+
|
|
2323
|
+
if (!isNetworkError && xhr.status >= 400) {
|
|
2324
|
+
errorDetails.status = xhr.status;
|
|
2325
|
+
errorDetails.statusText = xhr.statusText;
|
|
2326
|
+
errorDetails.networkError = false;
|
|
2327
|
+
} else {
|
|
2328
|
+
errorDetails.networkError = true;
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
XMLHttpRequest.prototype.open = function(method, url, ...args) {
|
|
2335
|
+
this.__intercepted_method__ = method;
|
|
2336
|
+
this.__intercepted_url__ = url;
|
|
2337
|
+
return originalXHROpen.apply(this, [method, url, ...args]);
|
|
2338
|
+
};
|
|
2339
|
+
|
|
2340
|
+
XMLHttpRequest.prototype.send = function(...args) {
|
|
2341
|
+
const xhr = this;
|
|
2342
|
+
|
|
2343
|
+
const originalOnReadyStateChange = xhr.onreadystatechange;
|
|
2344
|
+
xhr.onreadystatechange = function() {
|
|
2345
|
+
if (xhr.readyState === 4) {
|
|
2346
|
+
if (xhr.status >= 400) {
|
|
2347
|
+
const networkError = new Error(\`HTTP \${xhr.status}: \${xhr.statusText}\`);
|
|
2348
|
+
handleXHRError(networkError, xhr, false);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
if (originalOnReadyStateChange) {
|
|
2353
|
+
return originalOnReadyStateChange.apply(this, arguments);
|
|
2354
|
+
}
|
|
2355
|
+
};
|
|
2356
|
+
|
|
2357
|
+
const originalOnError = xhr.onerror;
|
|
2358
|
+
xhr.onerror = function() {
|
|
2359
|
+
const networkError = new Error(\`Network error for \${xhr.__intercepted_method__} \${xhr.__intercepted_url__}\`);
|
|
2360
|
+
handleXHRError(networkError, xhr, true);
|
|
2361
|
+
|
|
2362
|
+
if (originalOnError) {
|
|
2363
|
+
return originalOnError.apply(this, arguments);
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
|
|
2367
|
+
return originalXHRSend.apply(this, args);
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
if (!window.__CONSOLE_ERROR_INTERCEPTED__) {
|
|
2372
|
+
window.__CONSOLE_ERROR_INTERCEPTED__ = true;
|
|
2373
|
+
const originalConsoleError = console.error;
|
|
2374
|
+
console.error = function () {
|
|
2375
|
+
try {
|
|
2376
|
+
var args = Array.prototype.slice.call(arguments);
|
|
2377
|
+
var first = args[0];
|
|
2378
|
+
var firstStr = typeof first === "string" ? first : "";
|
|
2379
|
+
var isReact = firstStr.indexOf("React") !== -1;
|
|
2380
|
+
var isVite = firstStr.indexOf("[vite]") !== -1 || firstStr.indexOf("Failed to reload") !== -1;
|
|
2381
|
+
if (isReact || isVite) {
|
|
2382
|
+
var joined = args
|
|
2383
|
+
.map(function (a) {
|
|
2005
2384
|
if (a instanceof Error) return a.message;
|
|
2006
2385
|
if (typeof a === "string") return a;
|
|
2007
2386
|
if (a && typeof a.message === "string") return a.message;
|
|
2008
|
-
try { return JSON.stringify(a); } catch (
|
|
2009
|
-
})
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
}
|
|
2387
|
+
try { return JSON.stringify(a); } catch (_) { return String(a); }
|
|
2388
|
+
})
|
|
2389
|
+
.join(" ");
|
|
2390
|
+
var errorForReport = new Error(joined);
|
|
2391
|
+
window.__SEND_ERROR_TO_PARENT__(errorForReport, { type: "runtime", viteErrorType: "console" });
|
|
2392
|
+
}
|
|
2393
|
+
} catch (_) {}
|
|
2394
|
+
return originalConsoleError.apply(console, arguments);
|
|
2395
|
+
};
|
|
2396
|
+
}
|
|
2017
2397
|
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2398
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
2399
|
+
})();`;
|
|
2400
|
+
function injectEarlyErrorHandler() {
|
|
2401
|
+
if (typeof document === "undefined") return;
|
|
2021
2402
|
try {
|
|
2022
|
-
|
|
2023
|
-
try {
|
|
2024
|
-
const external = document.createElement("script");
|
|
2025
|
-
external.type = "text/javascript";
|
|
2026
|
-
external.src = "/error-handler.js";
|
|
2027
|
-
external.async = false;
|
|
2028
|
-
parent.prepend(external);
|
|
2029
|
-
return;
|
|
2030
|
-
} catch (e) {
|
|
2031
|
-
void e;
|
|
2032
|
-
}
|
|
2403
|
+
if (window.__EARLY_ERROR_HANDLER_INJECTED__) return;
|
|
2033
2404
|
const script = document.createElement("script");
|
|
2034
2405
|
script.type = "text/javascript";
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
}
|
|
2041
|
-
} catch (e) {
|
|
2042
|
-
try {
|
|
2043
|
-
script.appendChild(document.createTextNode(code));
|
|
2044
|
-
} catch {
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
parent.prepend(script);
|
|
2406
|
+
script.text = ERROR_HANDLER_SCRIPT;
|
|
2407
|
+
const head = document.head || document.getElementsByTagName("head")[0];
|
|
2408
|
+
if (head && head.firstChild) head.insertBefore(script, head.firstChild);
|
|
2409
|
+
else if (head) head.appendChild(script);
|
|
2410
|
+
window.__EARLY_ERROR_HANDLER_INJECTED__ = true;
|
|
2048
2411
|
} catch (e) {
|
|
2049
|
-
void e;
|
|
2050
2412
|
}
|
|
2051
2413
|
}
|
|
2052
2414
|
|
|
@@ -2058,12 +2420,16 @@ init_config();
|
|
|
2058
2420
|
AUTH_ROOT,
|
|
2059
2421
|
AUTH_TOKEN_KEY,
|
|
2060
2422
|
AuthProvider,
|
|
2423
|
+
ClayxToast,
|
|
2061
2424
|
DefaultErrorFallback,
|
|
2062
2425
|
ErrorBoundary,
|
|
2063
2426
|
FloatingButton,
|
|
2427
|
+
GlobalToastContainer,
|
|
2064
2428
|
Loading,
|
|
2065
2429
|
LoadingSpinner,
|
|
2066
2430
|
LoginForm,
|
|
2431
|
+
ThemeProvider,
|
|
2432
|
+
ThemeToggle,
|
|
2067
2433
|
aiRequest,
|
|
2068
2434
|
aiWorkflow,
|
|
2069
2435
|
canAccessArtifact,
|
|
@@ -2092,6 +2458,7 @@ init_config();
|
|
|
2092
2458
|
useAuthContext,
|
|
2093
2459
|
useDebounce,
|
|
2094
2460
|
useIsMobile,
|
|
2461
|
+
useTheme,
|
|
2095
2462
|
workflowRequest
|
|
2096
2463
|
});
|
|
2097
2464
|
//# sourceMappingURL=index.js.map
|