@howone/sdk 0.1.18 → 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 +51 -19
- package/dist/index.d.ts +51 -19
- package/dist/index.js +613 -281
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +610 -283
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/index.mjs
CHANGED
|
@@ -232,7 +232,7 @@ var FloatingButton = ({
|
|
|
232
232
|
{
|
|
233
233
|
onClick,
|
|
234
234
|
id: "floating-howone-btn",
|
|
235
|
-
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}`,
|
|
235
|
+
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}`,
|
|
236
236
|
style: {
|
|
237
237
|
fontSize: "14px",
|
|
238
238
|
fontWeight: "bold",
|
|
@@ -245,7 +245,7 @@ var FloatingButton = ({
|
|
|
245
245
|
e.stopPropagation();
|
|
246
246
|
const btn = document.getElementById("floating-howone-btn");
|
|
247
247
|
if (btn) btn.style.display = "none";
|
|
248
|
-
}, className: "w-5 h-5 font-bold pointer-events-auto" })
|
|
248
|
+
}, 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" })
|
|
249
249
|
] })
|
|
250
250
|
}
|
|
251
251
|
);
|
|
@@ -1498,111 +1498,13 @@ var LoginForm = ({
|
|
|
1498
1498
|
};
|
|
1499
1499
|
|
|
1500
1500
|
// src/components/auth/AuthProvider.tsx
|
|
1501
|
-
import { createContext, useContext, useEffect as useEffect3, useState as useState3 } from "react";
|
|
1502
1501
|
init_auth();
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
// src/components/ui/Loading.tsx
|
|
1506
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1507
|
-
var Loading = ({
|
|
1508
|
-
size = "md",
|
|
1509
|
-
text = "Loading...",
|
|
1510
|
-
className = "",
|
|
1511
|
-
fullScreen = false
|
|
1512
|
-
}) => {
|
|
1513
|
-
const sizeClasses = {
|
|
1514
|
-
sm: "h-4 w-4",
|
|
1515
|
-
md: "h-8 w-8",
|
|
1516
|
-
lg: "h-12 w-12"
|
|
1517
|
-
};
|
|
1518
|
-
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";
|
|
1519
|
-
return /* @__PURE__ */ jsx3("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ jsxs3("div", { className: "text-center", children: [
|
|
1520
|
-
/* @__PURE__ */ jsx3(
|
|
1521
|
-
"div",
|
|
1522
|
-
{
|
|
1523
|
-
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
|
|
1524
|
-
}
|
|
1525
|
-
),
|
|
1526
|
-
text && /* @__PURE__ */ jsx3("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
1527
|
-
] }) });
|
|
1528
|
-
};
|
|
1529
|
-
var LoadingSpinner = ({
|
|
1530
|
-
size = "md",
|
|
1531
|
-
className = ""
|
|
1532
|
-
}) => {
|
|
1533
|
-
const sizeClasses = {
|
|
1534
|
-
sm: "h-4 w-4",
|
|
1535
|
-
md: "h-8 w-8",
|
|
1536
|
-
lg: "h-12 w-12"
|
|
1537
|
-
};
|
|
1538
|
-
return /* @__PURE__ */ jsx3(
|
|
1539
|
-
"div",
|
|
1540
|
-
{
|
|
1541
|
-
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
|
|
1542
|
-
}
|
|
1543
|
-
);
|
|
1544
|
-
};
|
|
1545
|
-
|
|
1546
|
-
// src/components/auth/AuthProvider.tsx
|
|
1547
|
-
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1502
|
+
import { createContext, useContext, useState as useState3 } from "react";
|
|
1503
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1548
1504
|
var AuthContext = createContext(null);
|
|
1549
|
-
var AuthProvider = ({ children,
|
|
1505
|
+
var AuthProvider = ({ children, showFloatingButton = true }) => {
|
|
1550
1506
|
const [user, setUser] = useState3(() => parseUserFromToken(getToken()));
|
|
1551
1507
|
const [token, setTokenState] = useState3(() => getToken());
|
|
1552
|
-
const [isLoading, setIsLoading] = useState3(false);
|
|
1553
|
-
useEffect3(() => {
|
|
1554
|
-
try {
|
|
1555
|
-
if (projectId) setDefaultProjectId(String(projectId));
|
|
1556
|
-
} catch {
|
|
1557
|
-
}
|
|
1558
|
-
setIsLoading(true);
|
|
1559
|
-
try {
|
|
1560
|
-
const cb = unifiedAuth.checkOAuthCallback();
|
|
1561
|
-
if (cb && cb.success) {
|
|
1562
|
-
setTokenState(cb.token ?? getToken());
|
|
1563
|
-
setUser(cb.user ?? parseUserFromToken(cb.token ?? getToken()));
|
|
1564
|
-
setIsLoading(false);
|
|
1565
|
-
return;
|
|
1566
|
-
}
|
|
1567
|
-
} catch {
|
|
1568
|
-
}
|
|
1569
|
-
const unsubscribe = onAuthStateChanged((state) => {
|
|
1570
|
-
try {
|
|
1571
|
-
setTokenState(getToken());
|
|
1572
|
-
setUser(state.user ?? parseUserFromToken(getToken()));
|
|
1573
|
-
} catch {
|
|
1574
|
-
}
|
|
1575
|
-
setIsLoading(false);
|
|
1576
|
-
if (autoRedirect && !state.user) {
|
|
1577
|
-
try {
|
|
1578
|
-
const root = getAuthRoot();
|
|
1579
|
-
const authUrl = new URL("/auth", String(root));
|
|
1580
|
-
authUrl.searchParams.set("redirect_uri", window.location.href);
|
|
1581
|
-
const pid = getDefaultProjectId();
|
|
1582
|
-
if (pid) authUrl.searchParams.set("project_id", pid);
|
|
1583
|
-
try {
|
|
1584
|
-
if (window.top && window.top !== window) {
|
|
1585
|
-
window.top.location.replace(authUrl.toString());
|
|
1586
|
-
} else {
|
|
1587
|
-
window.location.replace(authUrl.toString());
|
|
1588
|
-
}
|
|
1589
|
-
} catch (e) {
|
|
1590
|
-
try {
|
|
1591
|
-
window.location.replace(authUrl.toString());
|
|
1592
|
-
} catch {
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
} catch {
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
});
|
|
1599
|
-
return () => {
|
|
1600
|
-
try {
|
|
1601
|
-
unsubscribe();
|
|
1602
|
-
} catch {
|
|
1603
|
-
}
|
|
1604
|
-
};
|
|
1605
|
-
}, [autoRedirect]);
|
|
1606
1508
|
const logout = () => {
|
|
1607
1509
|
try {
|
|
1608
1510
|
setToken(null);
|
|
@@ -1617,12 +1519,9 @@ var AuthProvider = ({ children, autoRedirect = true, showFloatingButton = true,
|
|
|
1617
1519
|
isAuthenticated: !!token,
|
|
1618
1520
|
logout
|
|
1619
1521
|
};
|
|
1620
|
-
return /* @__PURE__ */
|
|
1621
|
-
/* @__PURE__ */ jsx4(Loading, { fullScreen: true, text: "Checking authentication..." }),
|
|
1622
|
-
showFloatingButton && /* @__PURE__ */ jsx4(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
1623
|
-
] }) : /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
1522
|
+
return /* @__PURE__ */ jsx3(AuthContext.Provider, { value, children: /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
1624
1523
|
children,
|
|
1625
|
-
showFloatingButton && /* @__PURE__ */
|
|
1524
|
+
showFloatingButton && /* @__PURE__ */ jsx3(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
1626
1525
|
] }) });
|
|
1627
1526
|
};
|
|
1628
1527
|
function useAuthContext() {
|
|
@@ -1729,6 +1628,47 @@ var howone = {
|
|
|
1729
1628
|
};
|
|
1730
1629
|
var client_default = howone;
|
|
1731
1630
|
|
|
1631
|
+
// src/components/ui/Loading.tsx
|
|
1632
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1633
|
+
var Loading = ({
|
|
1634
|
+
size = "md",
|
|
1635
|
+
text = "Loading...",
|
|
1636
|
+
className = "",
|
|
1637
|
+
fullScreen = false
|
|
1638
|
+
}) => {
|
|
1639
|
+
const sizeClasses = {
|
|
1640
|
+
sm: "h-4 w-4",
|
|
1641
|
+
md: "h-8 w-8",
|
|
1642
|
+
lg: "h-12 w-12"
|
|
1643
|
+
};
|
|
1644
|
+
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";
|
|
1645
|
+
return /* @__PURE__ */ jsx4("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ jsxs4("div", { className: "text-center", children: [
|
|
1646
|
+
/* @__PURE__ */ jsx4(
|
|
1647
|
+
"div",
|
|
1648
|
+
{
|
|
1649
|
+
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
|
|
1650
|
+
}
|
|
1651
|
+
),
|
|
1652
|
+
text && /* @__PURE__ */ jsx4("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
1653
|
+
] }) });
|
|
1654
|
+
};
|
|
1655
|
+
var LoadingSpinner = ({
|
|
1656
|
+
size = "md",
|
|
1657
|
+
className = ""
|
|
1658
|
+
}) => {
|
|
1659
|
+
const sizeClasses = {
|
|
1660
|
+
sm: "h-4 w-4",
|
|
1661
|
+
md: "h-8 w-8",
|
|
1662
|
+
lg: "h-12 w-12"
|
|
1663
|
+
};
|
|
1664
|
+
return /* @__PURE__ */ jsx4(
|
|
1665
|
+
"div",
|
|
1666
|
+
{
|
|
1667
|
+
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
|
|
1668
|
+
}
|
|
1669
|
+
);
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1732
1672
|
// src/components/ui/ErrorBoundary.tsx
|
|
1733
1673
|
import { Component } from "react";
|
|
1734
1674
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
@@ -1787,12 +1727,273 @@ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx5("div", { classNam
|
|
|
1787
1727
|
)
|
|
1788
1728
|
] }) });
|
|
1789
1729
|
|
|
1790
|
-
// src/
|
|
1730
|
+
// src/components/theme/ThemeProvider.tsx
|
|
1731
|
+
import { createContext as createContext2, useContext as useContext2, useEffect as useEffect3, useState as useState4 } from "react";
|
|
1732
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1733
|
+
var initialState = {
|
|
1734
|
+
theme: "system",
|
|
1735
|
+
setTheme: () => null
|
|
1736
|
+
};
|
|
1737
|
+
var ThemeProviderContext = createContext2(initialState);
|
|
1738
|
+
function ThemeProvider({
|
|
1739
|
+
children,
|
|
1740
|
+
defaultTheme = "system",
|
|
1741
|
+
storageKey = "vite-ui-theme",
|
|
1742
|
+
...props
|
|
1743
|
+
}) {
|
|
1744
|
+
const [theme, setTheme] = useState4(
|
|
1745
|
+
() => localStorage.getItem(storageKey) || defaultTheme
|
|
1746
|
+
);
|
|
1747
|
+
useEffect3(() => {
|
|
1748
|
+
const root = window.document.documentElement;
|
|
1749
|
+
root.classList.remove("light", "dark");
|
|
1750
|
+
if (theme === "system") {
|
|
1751
|
+
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1752
|
+
root.classList.add(systemTheme);
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
root.classList.add(theme);
|
|
1756
|
+
}, [theme]);
|
|
1757
|
+
const value = {
|
|
1758
|
+
theme,
|
|
1759
|
+
setTheme: (theme2) => {
|
|
1760
|
+
localStorage.setItem(storageKey, theme2);
|
|
1761
|
+
setTheme(theme2);
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
return /* @__PURE__ */ jsx6(ThemeProviderContext.Provider, { ...props, value, children });
|
|
1765
|
+
}
|
|
1766
|
+
var useTheme = () => {
|
|
1767
|
+
const context = useContext2(ThemeProviderContext);
|
|
1768
|
+
if (context === void 0)
|
|
1769
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
1770
|
+
return context;
|
|
1771
|
+
};
|
|
1772
|
+
|
|
1773
|
+
// src/components/theme/ThemeToggle.tsx
|
|
1791
1774
|
import * as React4 from "react";
|
|
1775
|
+
import { useTheme as useTheme2 } from "next-themes";
|
|
1776
|
+
import { Icon as Icon3 } from "@iconify/react";
|
|
1777
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1778
|
+
function ThemeToggle({ className }) {
|
|
1779
|
+
const { setTheme, theme } = useTheme2();
|
|
1780
|
+
const [mounted, setMounted] = React4.useState(false);
|
|
1781
|
+
React4.useEffect(() => {
|
|
1782
|
+
setMounted(true);
|
|
1783
|
+
}, []);
|
|
1784
|
+
if (!mounted) {
|
|
1785
|
+
return /* @__PURE__ */ jsxs6(
|
|
1786
|
+
"button",
|
|
1787
|
+
{
|
|
1788
|
+
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 || ""}`,
|
|
1789
|
+
disabled: true,
|
|
1790
|
+
children: [
|
|
1791
|
+
/* @__PURE__ */ jsx7(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }),
|
|
1792
|
+
/* @__PURE__ */ jsx7("span", { className: "sr-only", children: "Toggle theme" })
|
|
1793
|
+
]
|
|
1794
|
+
}
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
return /* @__PURE__ */ jsxs6(
|
|
1798
|
+
"button",
|
|
1799
|
+
{
|
|
1800
|
+
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 || ""}`,
|
|
1801
|
+
onClick: () => setTheme(theme === "light" ? "dark" : "light"),
|
|
1802
|
+
children: [
|
|
1803
|
+
theme === "light" ? /* @__PURE__ */ jsx7(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }) : /* @__PURE__ */ jsx7(Icon3, { icon: "solar:moon-linear", width: 20, height: 20 }),
|
|
1804
|
+
/* @__PURE__ */ jsx7("span", { className: "sr-only", children: "Toggle theme" })
|
|
1805
|
+
]
|
|
1806
|
+
}
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
// src/components/ui/Toast/GlobalToastContainer.tsx
|
|
1811
|
+
import { ToastContainer } from "react-toastify";
|
|
1812
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1813
|
+
function GlobalToastContainer() {
|
|
1814
|
+
return /* @__PURE__ */ jsx8(
|
|
1815
|
+
ToastContainer,
|
|
1816
|
+
{
|
|
1817
|
+
newestOnTop: false,
|
|
1818
|
+
closeButton: false
|
|
1819
|
+
}
|
|
1820
|
+
);
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
// src/components/ui/Toast/ClayxToast.tsx
|
|
1824
|
+
import React5, { useCallback } from "react";
|
|
1825
|
+
import { Bounce, toast } from "react-toastify";
|
|
1826
|
+
import { Icon as Icon4 } from "@iconify/react";
|
|
1827
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1828
|
+
var TOAST_ICONS = {
|
|
1829
|
+
success: {
|
|
1830
|
+
icon: "mdi:success",
|
|
1831
|
+
color: "text-green-400",
|
|
1832
|
+
className: "text-green-400",
|
|
1833
|
+
bgGradient: "bg-[#14181df2]",
|
|
1834
|
+
gradientColor: "#389726",
|
|
1835
|
+
borderGradient: "border-[#389726]",
|
|
1836
|
+
borderGradientColor: "#389726"
|
|
1837
|
+
},
|
|
1838
|
+
error: {
|
|
1839
|
+
icon: "ic:outline-close",
|
|
1840
|
+
color: "text-red-400",
|
|
1841
|
+
className: "text-red-400",
|
|
1842
|
+
bgGradient: "bg-[#14181df2]",
|
|
1843
|
+
gradientColor: "#ef4444",
|
|
1844
|
+
borderGradient: "border-[#ef4444]",
|
|
1845
|
+
borderGradientColor: "#ef4444"
|
|
1846
|
+
},
|
|
1847
|
+
warning: {
|
|
1848
|
+
icon: "mi:warning",
|
|
1849
|
+
color: "text-yellow-400",
|
|
1850
|
+
className: "text-yellow-400",
|
|
1851
|
+
bgGradient: "bg-[#14181df2]",
|
|
1852
|
+
gradientColor: "#facc15",
|
|
1853
|
+
borderGradient: "border-[#facc15]",
|
|
1854
|
+
borderGradientColor: "#facc15"
|
|
1855
|
+
},
|
|
1856
|
+
info: {
|
|
1857
|
+
icon: "ic:outline-info",
|
|
1858
|
+
color: "text-blue-400",
|
|
1859
|
+
className: "text-blue-400",
|
|
1860
|
+
bgGradient: "bg-[#14181df2]",
|
|
1861
|
+
gradientColor: "#60a5fa",
|
|
1862
|
+
borderGradient: "border-[#60a5fa]",
|
|
1863
|
+
borderGradientColor: "#f0f0f0"
|
|
1864
|
+
},
|
|
1865
|
+
default: {
|
|
1866
|
+
icon: "ic:round-notifications",
|
|
1867
|
+
color: "text-gray-400",
|
|
1868
|
+
className: "text-gray-400",
|
|
1869
|
+
bgGradient: "bg-[#14181df2]",
|
|
1870
|
+
gradientColor: "#9ca3af",
|
|
1871
|
+
borderGradient: "border-[#9ca3af]",
|
|
1872
|
+
borderGradientColor: "#9ca3af"
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
var CloseButton = React5.memo(({ closeToast }) => {
|
|
1876
|
+
const handleClick = useCallback((e) => {
|
|
1877
|
+
e.preventDefault();
|
|
1878
|
+
e.stopPropagation();
|
|
1879
|
+
closeToast?.();
|
|
1880
|
+
}, [closeToast]);
|
|
1881
|
+
return /* @__PURE__ */ jsx9(
|
|
1882
|
+
Icon4,
|
|
1883
|
+
{
|
|
1884
|
+
icon: "vaadin:close",
|
|
1885
|
+
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",
|
|
1886
|
+
onClick: handleClick,
|
|
1887
|
+
width: 14,
|
|
1888
|
+
height: 14
|
|
1889
|
+
}
|
|
1890
|
+
);
|
|
1891
|
+
});
|
|
1892
|
+
CloseButton.displayName = "CloseButton";
|
|
1893
|
+
var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
1894
|
+
const iconConfig = TOAST_ICONS[type];
|
|
1895
|
+
const handleClose = useCallback(() => {
|
|
1896
|
+
closeToast?.();
|
|
1897
|
+
}, [closeToast]);
|
|
1898
|
+
console.log(iconConfig, "????????");
|
|
1899
|
+
if (component) {
|
|
1900
|
+
return /* @__PURE__ */ jsxs7("div", { className: `flex items-start gap-3 min-h-[80px] w-full backdrop-blur-md
|
|
1901
|
+
rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
|
|
1902
|
+
/* @__PURE__ */ jsx9("div", { className: "flex-1 relative z-10", children: component }),
|
|
1903
|
+
/* @__PURE__ */ jsx9("div", { className: "relative z-10", children: /* @__PURE__ */ jsx9(CloseButton, { closeToast: handleClose }) })
|
|
1904
|
+
] });
|
|
1905
|
+
}
|
|
1906
|
+
return /* @__PURE__ */ jsxs7("div", { className: `flex items-start gap-3 min-h-[60px] w-full backdrop-blur-md
|
|
1907
|
+
rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
|
|
1908
|
+
/* @__PURE__ */ jsx9(
|
|
1909
|
+
"div",
|
|
1910
|
+
{
|
|
1911
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
1912
|
+
style: {
|
|
1913
|
+
background: `linear-gradient(135deg, ${iconConfig.gradientColor}30 0%, ${iconConfig.gradientColor}20 15%, #14181df2 30%)`
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
),
|
|
1917
|
+
/* @__PURE__ */ jsx9(
|
|
1918
|
+
"div",
|
|
1919
|
+
{
|
|
1920
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
1921
|
+
style: {
|
|
1922
|
+
border: "2px solid transparent",
|
|
1923
|
+
backgroundImage: `linear-gradient(135deg, ${iconConfig.borderGradientColor}60 0%, ${iconConfig.borderGradientColor}40 5%, transparent 22%)`,
|
|
1924
|
+
backgroundOrigin: "border-box",
|
|
1925
|
+
backgroundClip: "border-box",
|
|
1926
|
+
WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
1927
|
+
WebkitMaskComposite: "xor",
|
|
1928
|
+
mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
1929
|
+
maskComposite: "exclude"
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
),
|
|
1933
|
+
/* @__PURE__ */ jsx9("div", { className: "flex-shrink-0 mt-0.5 relative z-10 ", children: /* @__PURE__ */ jsx9("div", { className: "w-7 h-7 bg-white/10 backdrop-blur-sm rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx9(
|
|
1934
|
+
Icon4,
|
|
1935
|
+
{
|
|
1936
|
+
icon: iconConfig.icon,
|
|
1937
|
+
width: 16,
|
|
1938
|
+
height: 16,
|
|
1939
|
+
className: iconConfig.color
|
|
1940
|
+
}
|
|
1941
|
+
) }) }),
|
|
1942
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
|
|
1943
|
+
title && /* @__PURE__ */ jsx9("div", { className: "text-[16px] font-semibold leading-tight text-white/95 drop-shadow-sm", children: title }),
|
|
1944
|
+
message && /* @__PURE__ */ jsx9("div", { className: "text-[13px] font-normal leading-relaxed text-white/75 drop-shadow-sm", children: message })
|
|
1945
|
+
] }),
|
|
1946
|
+
/* @__PURE__ */ jsx9("div", { className: "relative z-10", children: /* @__PURE__ */ jsx9(CloseButton, { closeToast: handleClose }) })
|
|
1947
|
+
] });
|
|
1948
|
+
};
|
|
1949
|
+
var defaultToastOptions = {
|
|
1950
|
+
position: "bottom-right",
|
|
1951
|
+
autoClose: 3e3,
|
|
1952
|
+
hideProgressBar: true,
|
|
1953
|
+
closeOnClick: false,
|
|
1954
|
+
pauseOnHover: true,
|
|
1955
|
+
draggable: true,
|
|
1956
|
+
pauseOnFocusLoss: false,
|
|
1957
|
+
theme: "dark",
|
|
1958
|
+
transition: Bounce
|
|
1959
|
+
};
|
|
1960
|
+
var createToast = (type) => {
|
|
1961
|
+
return (params) => {
|
|
1962
|
+
const { title, message, component, options } = params;
|
|
1963
|
+
toast(
|
|
1964
|
+
({ closeToast }) => /* @__PURE__ */ jsx9(
|
|
1965
|
+
ToastContent,
|
|
1966
|
+
{
|
|
1967
|
+
type,
|
|
1968
|
+
title,
|
|
1969
|
+
message: message || "",
|
|
1970
|
+
component,
|
|
1971
|
+
closeToast
|
|
1972
|
+
}
|
|
1973
|
+
),
|
|
1974
|
+
{
|
|
1975
|
+
...defaultToastOptions,
|
|
1976
|
+
...options,
|
|
1977
|
+
className: "!bg-transparent !p-0 !shadow-none",
|
|
1978
|
+
style: { background: "transparent", padding: 0 }
|
|
1979
|
+
}
|
|
1980
|
+
);
|
|
1981
|
+
};
|
|
1982
|
+
};
|
|
1983
|
+
var ClayxToast = {
|
|
1984
|
+
success: createToast("success"),
|
|
1985
|
+
error: createToast("error"),
|
|
1986
|
+
warning: createToast("warning"),
|
|
1987
|
+
info: createToast("info"),
|
|
1988
|
+
default: createToast("default")
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1991
|
+
// src/hooks/use-mobile.ts
|
|
1992
|
+
import * as React6 from "react";
|
|
1792
1993
|
var MOBILE_BREAKPOINT = 768;
|
|
1793
1994
|
function useIsMobile() {
|
|
1794
|
-
const [isMobile, setIsMobile] =
|
|
1795
|
-
|
|
1995
|
+
const [isMobile, setIsMobile] = React6.useState(void 0);
|
|
1996
|
+
React6.useEffect(() => {
|
|
1796
1997
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
1797
1998
|
const onChange = () => {
|
|
1798
1999
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
@@ -1805,10 +2006,10 @@ function useIsMobile() {
|
|
|
1805
2006
|
}
|
|
1806
2007
|
|
|
1807
2008
|
// src/hooks/use-debounce.ts
|
|
1808
|
-
import { useState as
|
|
2009
|
+
import { useState as useState7, useEffect as useEffect6 } from "react";
|
|
1809
2010
|
function useDebounce(value, delay) {
|
|
1810
|
-
const [debouncedValue, setDebouncedValue] =
|
|
1811
|
-
|
|
2011
|
+
const [debouncedValue, setDebouncedValue] = useState7(value);
|
|
2012
|
+
useEffect6(() => {
|
|
1812
2013
|
const handler = setTimeout(() => {
|
|
1813
2014
|
setDebouncedValue(value);
|
|
1814
2015
|
}, delay);
|
|
@@ -1819,214 +2020,335 @@ function useDebounce(value, delay) {
|
|
|
1819
2020
|
return debouncedValue;
|
|
1820
2021
|
}
|
|
1821
2022
|
|
|
1822
|
-
// src/utils/
|
|
1823
|
-
function
|
|
1824
|
-
|
|
1825
|
-
const
|
|
1826
|
-
(
|
|
1827
|
-
const isIframe = window.self !== window.top;
|
|
1828
|
-
console.log("isIframe", isIframe);
|
|
2023
|
+
// src/utils/errorHandler.ts
|
|
2024
|
+
var ERROR_HANDLER_SCRIPT = `(function () {
|
|
2025
|
+
// \u68C0\u67E5\u662F\u5426\u5728 iframe \u4E2D\u8FD0\u884C
|
|
2026
|
+
const isIframe = window.self !== window.top;
|
|
2027
|
+
console.log("isIframe", isIframe);
|
|
1829
2028
|
|
|
1830
|
-
|
|
2029
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316");
|
|
1831
2030
|
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
2031
|
+
// \u76F4\u63A5\u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u7684\u51FD\u6570
|
|
2032
|
+
window.__SEND_ERROR_TO_PARENT__ = function (error, details) {
|
|
2033
|
+
try {
|
|
2034
|
+
const errorPayload = {
|
|
2035
|
+
message: error instanceof Error ? error.message : String(error),
|
|
2036
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
2037
|
+
filename: details?.file || details?.filename,
|
|
2038
|
+
lineno: details?.line,
|
|
2039
|
+
colno: details?.column,
|
|
2040
|
+
timestamp: Date.now(),
|
|
2041
|
+
type: details?.type || "compile-error",
|
|
2042
|
+
details: details,
|
|
2043
|
+
};
|
|
1844
2044
|
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
2045
|
+
window.parent.postMessage(
|
|
2046
|
+
{
|
|
2047
|
+
type: "ERROR_EVENT",
|
|
2048
|
+
payload: errorPayload,
|
|
2049
|
+
},
|
|
2050
|
+
"*"
|
|
2051
|
+
);
|
|
1851
2052
|
|
|
1852
|
-
|
|
1853
|
-
|
|
2053
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u9519\u8BEF\u5DF2\u53D1\u9001\u5230\u7236\u7A97\u53E3:", errorPayload);
|
|
2054
|
+
} catch (e) {
|
|
2055
|
+
console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u5931\u8D25:", e);
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
1854
2058
|
|
|
1855
|
-
|
|
2059
|
+
// \u8BBE\u7F6E MutationObserver \u76D1\u542C vite-error-overlay
|
|
2060
|
+
function setupViteOverlayObserver() {
|
|
2061
|
+
if (!window.MutationObserver) return;
|
|
1856
2062
|
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
2063
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u8BBE\u7F6E Vite \u9519\u8BEF overlay \u76D1\u542C\u5668");
|
|
2064
|
+
|
|
2065
|
+
function processViteErrorOverlay(overlay) {
|
|
2066
|
+
try {
|
|
2067
|
+
if (overlay.hasAttribute("data-error-sent")) return;
|
|
2068
|
+
|
|
2069
|
+
const shadowRoot = overlay.shadowRoot;
|
|
2070
|
+
if (!shadowRoot) {
|
|
2071
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] vite-error-overlay \u6CA1\u6709 Shadow DOM");
|
|
2072
|
+
return;
|
|
2073
|
+
}
|
|
1862
2074
|
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
2075
|
+
const messageElement = shadowRoot.querySelector("pre.message");
|
|
2076
|
+
const fileElement = shadowRoot.querySelector("pre.file");
|
|
2077
|
+
const frameElements = shadowRoot.querySelectorAll("pre.frame");
|
|
2078
|
+
const stackElement = shadowRoot.querySelector("pre.stack");
|
|
1867
2079
|
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
2080
|
+
const message = messageElement ? messageElement.textContent : "";
|
|
2081
|
+
const file = fileElement ? fileElement.textContent : "";
|
|
2082
|
+
const frames = Array.from(frameElements)
|
|
2083
|
+
.map((el) => el.textContent)
|
|
2084
|
+
.join("
|
|
1871
2085
|
");
|
|
1872
|
-
|
|
2086
|
+
const stack = stackElement ? stackElement.textContent : "";
|
|
1873
2087
|
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
2088
|
+
let line, column;
|
|
2089
|
+
const fileStr = file || "";
|
|
2090
|
+
const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(d+)(?::| )(d+)/i);
|
|
2091
|
+
if (lineColMatch) {
|
|
2092
|
+
line = parseInt(lineColMatch[1], 10);
|
|
2093
|
+
column = parseInt(lineColMatch[2], 10);
|
|
2094
|
+
}
|
|
1881
2095
|
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
2096
|
+
const messageStr = message || "";
|
|
2097
|
+
const isReactError =
|
|
2098
|
+
messageStr.includes("React") ||
|
|
2099
|
+
messageStr.includes("JSX") ||
|
|
2100
|
+
messageStr.includes("Unexpected token") ||
|
|
2101
|
+
messageStr.includes("vite:react-babel");
|
|
1888
2102
|
|
|
1889
|
-
|
|
2103
|
+
const viteError = new Error(messageStr);
|
|
1890
2104
|
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
2105
|
+
window.__SEND_ERROR_TO_PARENT__(viteError, {
|
|
2106
|
+
file,
|
|
2107
|
+
line,
|
|
2108
|
+
column,
|
|
2109
|
+
frames,
|
|
2110
|
+
stack,
|
|
2111
|
+
isReactError,
|
|
2112
|
+
type: isReactError ? "react-syntax" : "vite-error-overlay",
|
|
2113
|
+
});
|
|
1900
2114
|
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
}
|
|
2115
|
+
overlay.setAttribute("data-error-sent", "true");
|
|
2116
|
+
} catch (e) {
|
|
2117
|
+
console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u5904\u7406 vite-error-overlay \u5931\u8D25:", e);
|
|
1905
2118
|
}
|
|
2119
|
+
}
|
|
1906
2120
|
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
}
|
|
2121
|
+
function checkExistingOverlays() {
|
|
2122
|
+
const viteErrorOverlays = document.querySelectorAll("vite-error-overlay");
|
|
2123
|
+
if (viteErrorOverlays.length > 0) {
|
|
2124
|
+
viteErrorOverlays.forEach((overlay) => {
|
|
2125
|
+
if (!overlay.hasAttribute("data-error-sent")) {
|
|
2126
|
+
processViteErrorOverlay(overlay);
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
1916
2129
|
}
|
|
2130
|
+
}
|
|
1917
2131
|
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2132
|
+
const observer = new MutationObserver((mutations) => {
|
|
2133
|
+
for (const mutation of mutations) {
|
|
2134
|
+
if (mutation.addedNodes.length > 0) {
|
|
2135
|
+
for (const node of Array.from(mutation.addedNodes)) {
|
|
2136
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
2137
|
+
const element = node;
|
|
2138
|
+
|
|
2139
|
+
if (
|
|
2140
|
+
element.tagName === "VITE-ERROR-OVERLAY" &&
|
|
2141
|
+
!element.hasAttribute("data-error-sent")
|
|
2142
|
+
) {
|
|
2143
|
+
setTimeout(() => processViteErrorOverlay(element), 100);
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
const viteErrorOverlays = element.querySelectorAll("vite-error-overlay");
|
|
2147
|
+
for (const viteErrorOverlay of Array.from(viteErrorOverlays)) {
|
|
2148
|
+
if (!viteErrorOverlay.hasAttribute("data-error-sent")) {
|
|
2149
|
+
setTimeout(() => processViteErrorOverlay(viteErrorOverlay), 100);
|
|
1932
2150
|
}
|
|
1933
2151
|
}
|
|
1934
2152
|
}
|
|
1935
2153
|
}
|
|
1936
2154
|
}
|
|
1937
|
-
}
|
|
2155
|
+
}
|
|
2156
|
+
});
|
|
1938
2157
|
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2158
|
+
observer.observe(document.documentElement, {
|
|
2159
|
+
childList: true,
|
|
2160
|
+
subtree: true,
|
|
2161
|
+
attributes: true,
|
|
2162
|
+
characterData: true,
|
|
2163
|
+
});
|
|
1943
2164
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
2165
|
+
setTimeout(checkExistingOverlays, 500);
|
|
2166
|
+
setInterval(checkExistingOverlays, 2000);
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
window.addEventListener(
|
|
2170
|
+
"error",
|
|
2171
|
+
function (event) {
|
|
2172
|
+
const target = event && (event.target || event.srcElement);
|
|
2173
|
+
const tagName = target && target.tagName;
|
|
2174
|
+
if (tagName) {
|
|
2175
|
+
const url = (target && (target.src || target.href || target.currentSrc)) ||
|
|
2176
|
+
(target && target.getAttribute && (target.getAttribute('src') || target.getAttribute('href')));
|
|
2177
|
+
const preview = target && target.outerHTML ? String(target.outerHTML).slice(0, 300) : undefined;
|
|
2178
|
+
const resourceError = new Error('Resource load error: ' + tagName + ' ' + (url || 'unknown'));
|
|
2179
|
+
window.__SEND_ERROR_TO_PARENT__(resourceError, {
|
|
2180
|
+
filename: url,
|
|
2181
|
+
tagName: tagName,
|
|
2182
|
+
element: preview,
|
|
2183
|
+
type: "resource"
|
|
2184
|
+
});
|
|
2185
|
+
return;
|
|
2186
|
+
}
|
|
1956
2187
|
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
2188
|
+
var stack = (event && event.error && event.error.stack) || "";
|
|
2189
|
+
var message = typeof event.message === "string" ? event.message : "";
|
|
2190
|
+
if ((stack && stack.indexOf('error-handler') !== -1) || !message) return;
|
|
1960
2191
|
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
2192
|
+
window.__SEND_ERROR_TO_PARENT__(event.error || new Error(event.message), {
|
|
2193
|
+
filename: event.filename,
|
|
2194
|
+
line: event.lineno,
|
|
2195
|
+
column: event.colno,
|
|
2196
|
+
type: "runtime",
|
|
2197
|
+
});
|
|
2198
|
+
},
|
|
2199
|
+
true
|
|
2200
|
+
);
|
|
2201
|
+
|
|
2202
|
+
window.addEventListener("unhandledrejection", function (event) {
|
|
2203
|
+
const reason = event.reason;
|
|
2204
|
+
window.__SEND_ERROR_TO_PARENT__(
|
|
2205
|
+
reason instanceof Error ? reason : new Error(String(reason)),
|
|
2206
|
+
{ type: "promise" }
|
|
1964
2207
|
);
|
|
2208
|
+
});
|
|
1965
2209
|
|
|
1966
|
-
|
|
1967
|
-
const reason = event.reason;
|
|
1968
|
-
window.__SEND_ERROR_TO_PARENT__(reason instanceof Error ? reason : new Error(String(reason)), { type: "promise" });
|
|
1969
|
-
});
|
|
2210
|
+
setupViteOverlayObserver();
|
|
1970
2211
|
|
|
1971
|
-
|
|
2212
|
+
if (!window.__FETCH_INTERCEPTED__) {
|
|
2213
|
+
window.__FETCH_INTERCEPTED__ = true;
|
|
2214
|
+
const originalFetch = window.fetch;
|
|
2215
|
+
|
|
2216
|
+
function handleFetchError(error, url, response = null) {
|
|
2217
|
+
const errorDetails = {
|
|
2218
|
+
type: "network",
|
|
2219
|
+
method: "fetch",
|
|
2220
|
+
url: url
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2223
|
+
if (response && !response.ok) {
|
|
2224
|
+
errorDetails.status = response.status;
|
|
2225
|
+
errorDetails.statusText = response.statusText;
|
|
2226
|
+
errorDetails.networkError = false;
|
|
2227
|
+
} else {
|
|
2228
|
+
errorDetails.networkError = true;
|
|
2229
|
+
}
|
|
2230
|
+
window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
window.fetch = function(...args) {
|
|
2234
|
+
const url = args[0] instanceof Request ? args[0].url : args[0];
|
|
2235
|
+
|
|
2236
|
+
return originalFetch.apply(this, args)
|
|
2237
|
+
.then(response => {
|
|
2238
|
+
if (!response.ok) {
|
|
2239
|
+
const networkError = new Error(\`HTTP \${response.status}: \${response.statusText}\`);
|
|
2240
|
+
handleFetchError(networkError, url, response);
|
|
2241
|
+
}
|
|
2242
|
+
return response;
|
|
2243
|
+
})
|
|
2244
|
+
.catch(error => {
|
|
2245
|
+
handleFetchError(error, url);
|
|
2246
|
+
throw error;
|
|
2247
|
+
});
|
|
2248
|
+
};
|
|
2249
|
+
}
|
|
1972
2250
|
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2251
|
+
if (!window.__XHR_INTERCEPTED__) {
|
|
2252
|
+
window.__XHR_INTERCEPTED__ = true;
|
|
2253
|
+
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
2254
|
+
const originalXHRSend = XMLHttpRequest.prototype.send;
|
|
2255
|
+
|
|
2256
|
+
function handleXHRError(error, xhr, isNetworkError = false) {
|
|
2257
|
+
const errorDetails = {
|
|
2258
|
+
type: "network",
|
|
2259
|
+
method: "xhr",
|
|
2260
|
+
url: xhr.__intercepted_url__
|
|
2261
|
+
};
|
|
2262
|
+
|
|
2263
|
+
if (!isNetworkError && xhr.status >= 400) {
|
|
2264
|
+
errorDetails.status = xhr.status;
|
|
2265
|
+
errorDetails.statusText = xhr.statusText;
|
|
2266
|
+
errorDetails.networkError = false;
|
|
2267
|
+
} else {
|
|
2268
|
+
errorDetails.networkError = true;
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
XMLHttpRequest.prototype.open = function(method, url, ...args) {
|
|
2275
|
+
this.__intercepted_method__ = method;
|
|
2276
|
+
this.__intercepted_url__ = url;
|
|
2277
|
+
return originalXHROpen.apply(this, [method, url, ...args]);
|
|
2278
|
+
};
|
|
2279
|
+
|
|
2280
|
+
XMLHttpRequest.prototype.send = function(...args) {
|
|
2281
|
+
const xhr = this;
|
|
2282
|
+
|
|
2283
|
+
const originalOnReadyStateChange = xhr.onreadystatechange;
|
|
2284
|
+
xhr.onreadystatechange = function() {
|
|
2285
|
+
if (xhr.readyState === 4) {
|
|
2286
|
+
if (xhr.status >= 400) {
|
|
2287
|
+
const networkError = new Error(\`HTTP \${xhr.status}: \${xhr.statusText}\`);
|
|
2288
|
+
handleXHRError(networkError, xhr, false);
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
if (originalOnReadyStateChange) {
|
|
2293
|
+
return originalOnReadyStateChange.apply(this, arguments);
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
|
|
2297
|
+
const originalOnError = xhr.onerror;
|
|
2298
|
+
xhr.onerror = function() {
|
|
2299
|
+
const networkError = new Error(\`Network error for \${xhr.__intercepted_method__} \${xhr.__intercepted_url__}\`);
|
|
2300
|
+
handleXHRError(networkError, xhr, true);
|
|
2301
|
+
|
|
2302
|
+
if (originalOnError) {
|
|
2303
|
+
return originalOnError.apply(this, arguments);
|
|
2304
|
+
}
|
|
2305
|
+
};
|
|
2306
|
+
|
|
2307
|
+
return originalXHRSend.apply(this, args);
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
if (!window.__CONSOLE_ERROR_INTERCEPTED__) {
|
|
2312
|
+
window.__CONSOLE_ERROR_INTERCEPTED__ = true;
|
|
2313
|
+
const originalConsoleError = console.error;
|
|
2314
|
+
console.error = function () {
|
|
2315
|
+
try {
|
|
2316
|
+
var args = Array.prototype.slice.call(arguments);
|
|
2317
|
+
var first = args[0];
|
|
2318
|
+
var firstStr = typeof first === "string" ? first : "";
|
|
2319
|
+
var isReact = firstStr.indexOf("React") !== -1;
|
|
2320
|
+
var isVite = firstStr.indexOf("[vite]") !== -1 || firstStr.indexOf("Failed to reload") !== -1;
|
|
2321
|
+
if (isReact || isVite) {
|
|
2322
|
+
var joined = args
|
|
2323
|
+
.map(function (a) {
|
|
1985
2324
|
if (a instanceof Error) return a.message;
|
|
1986
2325
|
if (typeof a === "string") return a;
|
|
1987
2326
|
if (a && typeof a.message === "string") return a.message;
|
|
1988
|
-
try { return JSON.stringify(a); } catch (
|
|
1989
|
-
})
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
}
|
|
2327
|
+
try { return JSON.stringify(a); } catch (_) { return String(a); }
|
|
2328
|
+
})
|
|
2329
|
+
.join(" ");
|
|
2330
|
+
var errorForReport = new Error(joined);
|
|
2331
|
+
window.__SEND_ERROR_TO_PARENT__(errorForReport, { type: "runtime", viteErrorType: "console" });
|
|
2332
|
+
}
|
|
2333
|
+
} catch (_) {}
|
|
2334
|
+
return originalConsoleError.apply(console, arguments);
|
|
2335
|
+
};
|
|
2336
|
+
}
|
|
1997
2337
|
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2338
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
2339
|
+
})();`;
|
|
2340
|
+
function injectEarlyErrorHandler() {
|
|
2341
|
+
if (typeof document === "undefined") return;
|
|
2001
2342
|
try {
|
|
2002
|
-
|
|
2003
|
-
try {
|
|
2004
|
-
const external = document.createElement("script");
|
|
2005
|
-
external.type = "text/javascript";
|
|
2006
|
-
external.src = "/error-handler.js";
|
|
2007
|
-
external.async = false;
|
|
2008
|
-
parent.prepend(external);
|
|
2009
|
-
return;
|
|
2010
|
-
} catch (e) {
|
|
2011
|
-
void e;
|
|
2012
|
-
}
|
|
2343
|
+
if (window.__EARLY_ERROR_HANDLER_INJECTED__) return;
|
|
2013
2344
|
const script = document.createElement("script");
|
|
2014
2345
|
script.type = "text/javascript";
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
}
|
|
2021
|
-
} catch (e) {
|
|
2022
|
-
try {
|
|
2023
|
-
script.appendChild(document.createTextNode(code));
|
|
2024
|
-
} catch {
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
parent.prepend(script);
|
|
2346
|
+
script.text = ERROR_HANDLER_SCRIPT;
|
|
2347
|
+
const head = document.head || document.getElementsByTagName("head")[0];
|
|
2348
|
+
if (head && head.firstChild) head.insertBefore(script, head.firstChild);
|
|
2349
|
+
else if (head) head.appendChild(script);
|
|
2350
|
+
window.__EARLY_ERROR_HANDLER_INJECTED__ = true;
|
|
2028
2351
|
} catch (e) {
|
|
2029
|
-
void e;
|
|
2030
2352
|
}
|
|
2031
2353
|
}
|
|
2032
2354
|
|
|
@@ -2037,12 +2359,16 @@ export {
|
|
|
2037
2359
|
AUTH_ROOT,
|
|
2038
2360
|
AUTH_TOKEN_KEY,
|
|
2039
2361
|
AuthProvider,
|
|
2362
|
+
ClayxToast,
|
|
2040
2363
|
DefaultErrorFallback,
|
|
2041
2364
|
ErrorBoundary,
|
|
2042
2365
|
FloatingButton,
|
|
2366
|
+
GlobalToastContainer,
|
|
2043
2367
|
Loading,
|
|
2044
2368
|
LoadingSpinner,
|
|
2045
2369
|
LoginForm,
|
|
2370
|
+
ThemeProvider,
|
|
2371
|
+
ThemeToggle,
|
|
2046
2372
|
aiRequest,
|
|
2047
2373
|
aiWorkflow,
|
|
2048
2374
|
canAccessArtifact,
|
|
@@ -2071,6 +2397,7 @@ export {
|
|
|
2071
2397
|
useAuthContext,
|
|
2072
2398
|
useDebounce,
|
|
2073
2399
|
useIsMobile,
|
|
2400
|
+
useTheme,
|
|
2074
2401
|
workflowRequest
|
|
2075
2402
|
};
|
|
2076
2403
|
//# sourceMappingURL=index.mjs.map
|