@howone/sdk 0.1.18 → 0.1.20
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 +82 -20
- package/dist/index.d.ts +82 -20
- package/dist/index.js +657 -293
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +650 -292
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -236,12 +236,17 @@ __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,
|
|
244
|
+
HowoneProvider: () => HowoneProvider,
|
|
242
245
|
Loading: () => Loading,
|
|
243
246
|
LoadingSpinner: () => LoadingSpinner,
|
|
244
247
|
LoginForm: () => LoginForm,
|
|
248
|
+
ThemeProvider: () => ThemeProvider,
|
|
249
|
+
ThemeToggle: () => ThemeToggle,
|
|
245
250
|
aiRequest: () => aiRequest,
|
|
246
251
|
aiWorkflow: () => aiWorkflow,
|
|
247
252
|
canAccessArtifact: () => canAccessArtifact,
|
|
@@ -270,6 +275,7 @@ __export(index_exports, {
|
|
|
270
275
|
useAuthContext: () => useAuthContext,
|
|
271
276
|
useDebounce: () => useDebounce,
|
|
272
277
|
useIsMobile: () => useIsMobile,
|
|
278
|
+
useTheme: () => useTheme,
|
|
273
279
|
workflowRequest: () => workflowRequest
|
|
274
280
|
});
|
|
275
281
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -287,7 +293,7 @@ var FloatingButton = ({
|
|
|
287
293
|
{
|
|
288
294
|
onClick,
|
|
289
295
|
id: "floating-howone-btn",
|
|
290
|
-
className: `fixed flex bg-
|
|
296
|
+
className: `fixed flex bg-background 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
297
|
style: {
|
|
292
298
|
fontSize: "14px",
|
|
293
299
|
fontWeight: "bold",
|
|
@@ -300,7 +306,7 @@ var FloatingButton = ({
|
|
|
300
306
|
e.stopPropagation();
|
|
301
307
|
const btn = document.getElementById("floating-howone-btn");
|
|
302
308
|
if (btn) btn.style.display = "none";
|
|
303
|
-
}, className: "w-5 h-5 font-bold pointer-events-auto" })
|
|
309
|
+
}, 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
310
|
] })
|
|
305
311
|
}
|
|
306
312
|
);
|
|
@@ -1553,111 +1559,87 @@ var LoginForm = ({
|
|
|
1553
1559
|
};
|
|
1554
1560
|
|
|
1555
1561
|
// src/components/auth/AuthProvider.tsx
|
|
1556
|
-
var
|
|
1562
|
+
var import_react5 = require("react");
|
|
1557
1563
|
init_auth();
|
|
1558
|
-
init_config();
|
|
1559
1564
|
|
|
1560
|
-
// src/components/
|
|
1565
|
+
// src/components/theme/ThemeProvider.tsx
|
|
1566
|
+
var import_react4 = require("react");
|
|
1561
1567
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1562
|
-
var
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
className = "",
|
|
1566
|
-
fullScreen = false
|
|
1567
|
-
}) => {
|
|
1568
|
-
const sizeClasses = {
|
|
1569
|
-
sm: "h-4 w-4",
|
|
1570
|
-
md: "h-8 w-8",
|
|
1571
|
-
lg: "h-12 w-12"
|
|
1572
|
-
};
|
|
1573
|
-
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";
|
|
1574
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "text-center", children: [
|
|
1575
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1576
|
-
"div",
|
|
1577
|
-
{
|
|
1578
|
-
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
|
|
1579
|
-
}
|
|
1580
|
-
),
|
|
1581
|
-
text && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
1582
|
-
] }) });
|
|
1568
|
+
var initialState = {
|
|
1569
|
+
theme: "system",
|
|
1570
|
+
setTheme: () => null
|
|
1583
1571
|
};
|
|
1584
|
-
var
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1572
|
+
var ThemeProviderContext = (0, import_react4.createContext)(initialState);
|
|
1573
|
+
function ThemeProvider({
|
|
1574
|
+
children,
|
|
1575
|
+
defaultTheme = "system",
|
|
1576
|
+
storageKey = "vite-ui-theme",
|
|
1577
|
+
forceDefault = false,
|
|
1578
|
+
...props
|
|
1579
|
+
}) {
|
|
1580
|
+
const [theme, setTheme] = (0, import_react4.useState)(() => {
|
|
1581
|
+
if (forceDefault) {
|
|
1582
|
+
localStorage.setItem(storageKey, defaultTheme);
|
|
1583
|
+
return defaultTheme;
|
|
1584
|
+
}
|
|
1585
|
+
const stored = localStorage.getItem(storageKey);
|
|
1586
|
+
const initialTheme = stored || defaultTheme;
|
|
1587
|
+
if (!stored) {
|
|
1588
|
+
localStorage.setItem(storageKey, defaultTheme);
|
|
1589
|
+
}
|
|
1590
|
+
return initialTheme;
|
|
1591
|
+
});
|
|
1592
|
+
(0, import_react4.useEffect)(() => {
|
|
1593
|
+
const root = window.document.documentElement;
|
|
1594
|
+
root.classList.remove("light", "dark");
|
|
1595
|
+
if (theme === "system") {
|
|
1596
|
+
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1597
|
+
root.classList.add(systemTheme);
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
root.classList.add(theme);
|
|
1601
|
+
}, [theme]);
|
|
1602
|
+
const value = {
|
|
1603
|
+
theme,
|
|
1604
|
+
setTheme: (theme2) => {
|
|
1605
|
+
localStorage.setItem(storageKey, theme2);
|
|
1606
|
+
setTheme(theme2);
|
|
1607
|
+
}
|
|
1592
1608
|
};
|
|
1593
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1594
|
-
|
|
1609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ThemeProviderContext.Provider, { ...props, value, children });
|
|
1610
|
+
}
|
|
1611
|
+
var useTheme = () => {
|
|
1612
|
+
const context = (0, import_react4.useContext)(ThemeProviderContext);
|
|
1613
|
+
if (context === void 0)
|
|
1614
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
1615
|
+
return context;
|
|
1616
|
+
};
|
|
1617
|
+
|
|
1618
|
+
// src/components/ui/Toast/GlobalToastContainer.tsx
|
|
1619
|
+
var import_react_toastify = require("react-toastify");
|
|
1620
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1621
|
+
function GlobalToastContainer() {
|
|
1622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1623
|
+
import_react_toastify.ToastContainer,
|
|
1595
1624
|
{
|
|
1596
|
-
|
|
1625
|
+
newestOnTop: false,
|
|
1626
|
+
closeButton: false
|
|
1597
1627
|
}
|
|
1598
1628
|
);
|
|
1599
|
-
}
|
|
1629
|
+
}
|
|
1600
1630
|
|
|
1601
1631
|
// src/components/auth/AuthProvider.tsx
|
|
1602
|
-
var
|
|
1603
|
-
var AuthContext = (0,
|
|
1604
|
-
var
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
setIsLoading(true);
|
|
1614
|
-
try {
|
|
1615
|
-
const cb = unifiedAuth.checkOAuthCallback();
|
|
1616
|
-
if (cb && cb.success) {
|
|
1617
|
-
setTokenState(cb.token ?? getToken());
|
|
1618
|
-
setUser(cb.user ?? parseUserFromToken(cb.token ?? getToken()));
|
|
1619
|
-
setIsLoading(false);
|
|
1620
|
-
return;
|
|
1621
|
-
}
|
|
1622
|
-
} catch {
|
|
1623
|
-
}
|
|
1624
|
-
const unsubscribe = onAuthStateChanged((state) => {
|
|
1625
|
-
try {
|
|
1626
|
-
setTokenState(getToken());
|
|
1627
|
-
setUser(state.user ?? parseUserFromToken(getToken()));
|
|
1628
|
-
} catch {
|
|
1629
|
-
}
|
|
1630
|
-
setIsLoading(false);
|
|
1631
|
-
if (autoRedirect && !state.user) {
|
|
1632
|
-
try {
|
|
1633
|
-
const root = getAuthRoot();
|
|
1634
|
-
const authUrl = new URL("/auth", String(root));
|
|
1635
|
-
authUrl.searchParams.set("redirect_uri", window.location.href);
|
|
1636
|
-
const pid = getDefaultProjectId();
|
|
1637
|
-
if (pid) authUrl.searchParams.set("project_id", pid);
|
|
1638
|
-
try {
|
|
1639
|
-
if (window.top && window.top !== window) {
|
|
1640
|
-
window.top.location.replace(authUrl.toString());
|
|
1641
|
-
} else {
|
|
1642
|
-
window.location.replace(authUrl.toString());
|
|
1643
|
-
}
|
|
1644
|
-
} catch (e) {
|
|
1645
|
-
try {
|
|
1646
|
-
window.location.replace(authUrl.toString());
|
|
1647
|
-
} catch {
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
} catch {
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
});
|
|
1654
|
-
return () => {
|
|
1655
|
-
try {
|
|
1656
|
-
unsubscribe();
|
|
1657
|
-
} catch {
|
|
1658
|
-
}
|
|
1659
|
-
};
|
|
1660
|
-
}, [autoRedirect]);
|
|
1632
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1633
|
+
var AuthContext = (0, import_react5.createContext)(null);
|
|
1634
|
+
var HowoneProvider = ({
|
|
1635
|
+
children,
|
|
1636
|
+
showFloatingButton = true,
|
|
1637
|
+
defaultTheme = "system",
|
|
1638
|
+
themeStorageKey = "howone-theme",
|
|
1639
|
+
forceDefaultTheme = false
|
|
1640
|
+
}) => {
|
|
1641
|
+
const [user, setUser] = (0, import_react5.useState)(() => parseUserFromToken(getToken()));
|
|
1642
|
+
const [token, setTokenState] = (0, import_react5.useState)(() => getToken());
|
|
1661
1643
|
const logout = () => {
|
|
1662
1644
|
try {
|
|
1663
1645
|
setToken(null);
|
|
@@ -1672,16 +1654,24 @@ var AuthProvider = ({ children, autoRedirect = true, showFloatingButton = true,
|
|
|
1672
1654
|
isAuthenticated: !!token,
|
|
1673
1655
|
logout
|
|
1674
1656
|
};
|
|
1675
|
-
return /* @__PURE__ */ (0,
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1658
|
+
ThemeProvider,
|
|
1659
|
+
{
|
|
1660
|
+
defaultTheme,
|
|
1661
|
+
storageKey: themeStorageKey,
|
|
1662
|
+
forceDefault: forceDefaultTheme,
|
|
1663
|
+
children: [
|
|
1664
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(AuthContext.Provider, { value, children: [
|
|
1665
|
+
children,
|
|
1666
|
+
showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
1667
|
+
] }),
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GlobalToastContainer, {})
|
|
1669
|
+
]
|
|
1670
|
+
}
|
|
1671
|
+
);
|
|
1682
1672
|
};
|
|
1683
1673
|
function useAuthContext() {
|
|
1684
|
-
const ctx = (0,
|
|
1674
|
+
const ctx = (0, import_react5.useContext)(AuthContext);
|
|
1685
1675
|
if (!ctx) {
|
|
1686
1676
|
const t = getToken();
|
|
1687
1677
|
return {
|
|
@@ -1698,6 +1688,7 @@ function useAuthContext() {
|
|
|
1698
1688
|
}
|
|
1699
1689
|
return ctx;
|
|
1700
1690
|
}
|
|
1691
|
+
var AuthProvider = HowoneProvider;
|
|
1701
1692
|
|
|
1702
1693
|
// src/components/index.ts
|
|
1703
1694
|
init_auth();
|
|
@@ -1784,10 +1775,51 @@ var howone = {
|
|
|
1784
1775
|
};
|
|
1785
1776
|
var client_default = howone;
|
|
1786
1777
|
|
|
1778
|
+
// src/components/ui/Loading.tsx
|
|
1779
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1780
|
+
var Loading = ({
|
|
1781
|
+
size = "md",
|
|
1782
|
+
text = "Loading...",
|
|
1783
|
+
className = "",
|
|
1784
|
+
fullScreen = false
|
|
1785
|
+
}) => {
|
|
1786
|
+
const sizeClasses = {
|
|
1787
|
+
sm: "h-4 w-4",
|
|
1788
|
+
md: "h-8 w-8",
|
|
1789
|
+
lg: "h-12 w-12"
|
|
1790
|
+
};
|
|
1791
|
+
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";
|
|
1792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "text-center", children: [
|
|
1793
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1794
|
+
"div",
|
|
1795
|
+
{
|
|
1796
|
+
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
|
|
1797
|
+
}
|
|
1798
|
+
),
|
|
1799
|
+
text && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mt-2 text-sm text-gray-600", children: text })
|
|
1800
|
+
] }) });
|
|
1801
|
+
};
|
|
1802
|
+
var LoadingSpinner = ({
|
|
1803
|
+
size = "md",
|
|
1804
|
+
className = ""
|
|
1805
|
+
}) => {
|
|
1806
|
+
const sizeClasses = {
|
|
1807
|
+
sm: "h-4 w-4",
|
|
1808
|
+
md: "h-8 w-8",
|
|
1809
|
+
lg: "h-12 w-12"
|
|
1810
|
+
};
|
|
1811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1812
|
+
"div",
|
|
1813
|
+
{
|
|
1814
|
+
className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
|
|
1815
|
+
}
|
|
1816
|
+
);
|
|
1817
|
+
};
|
|
1818
|
+
|
|
1787
1819
|
// src/components/ui/ErrorBoundary.tsx
|
|
1788
|
-
var
|
|
1789
|
-
var
|
|
1790
|
-
var ErrorBoundary = class extends
|
|
1820
|
+
var import_react6 = require("react");
|
|
1821
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1822
|
+
var ErrorBoundary = class extends import_react6.Component {
|
|
1791
1823
|
constructor(props) {
|
|
1792
1824
|
super(props);
|
|
1793
1825
|
this.handleRetry = () => {
|
|
@@ -1809,13 +1841,13 @@ var ErrorBoundary = class extends import_react5.Component {
|
|
|
1809
1841
|
if (this.state.hasError) {
|
|
1810
1842
|
if (this.props.fallback) {
|
|
1811
1843
|
const FallbackComponent = this.props.fallback;
|
|
1812
|
-
return /* @__PURE__ */ (0,
|
|
1844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FallbackComponent, { error: this.state.error, retry: this.handleRetry });
|
|
1813
1845
|
}
|
|
1814
|
-
return /* @__PURE__ */ (0,
|
|
1815
|
-
/* @__PURE__ */ (0,
|
|
1816
|
-
/* @__PURE__ */ (0,
|
|
1817
|
-
/* @__PURE__ */ (0,
|
|
1818
|
-
/* @__PURE__ */ (0,
|
|
1846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "min-h-[400px] flex items-center justify-center p-4", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "text-center max-w-md", children: [
|
|
1847
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-red-500 text-6xl mb-4", children: "\u26A0\uFE0F" }),
|
|
1848
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Something went wrong" }),
|
|
1849
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-gray-600 mb-4", children: "An unexpected error occurred. Please try refreshing the page." }),
|
|
1850
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1819
1851
|
"button",
|
|
1820
1852
|
{
|
|
1821
1853
|
onClick: this.handleRetry,
|
|
@@ -1829,10 +1861,10 @@ var ErrorBoundary = class extends import_react5.Component {
|
|
|
1829
1861
|
return this.props.children;
|
|
1830
1862
|
}
|
|
1831
1863
|
};
|
|
1832
|
-
var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ (0,
|
|
1833
|
-
/* @__PURE__ */ (0,
|
|
1834
|
-
/* @__PURE__ */ (0,
|
|
1835
|
-
retry && /* @__PURE__ */ (0,
|
|
1864
|
+
var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "min-h-[200px] flex items-center justify-center p-4", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "text-center", children: [
|
|
1865
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-red-500 text-4xl mb-2", children: "\u26A0\uFE0F" }),
|
|
1866
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-gray-600 mb-2", children: "Something went wrong" }),
|
|
1867
|
+
retry && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1836
1868
|
"button",
|
|
1837
1869
|
{
|
|
1838
1870
|
onClick: retry,
|
|
@@ -1842,12 +1874,217 @@ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ (0, import_jsx_runtime
|
|
|
1842
1874
|
)
|
|
1843
1875
|
] }) });
|
|
1844
1876
|
|
|
1845
|
-
// src/
|
|
1877
|
+
// src/components/theme/ThemeToggle.tsx
|
|
1846
1878
|
var React4 = __toESM(require("react"));
|
|
1879
|
+
var import_next_themes = require("next-themes");
|
|
1880
|
+
var import_react7 = require("@iconify/react");
|
|
1881
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1882
|
+
function ThemeToggle({ className }) {
|
|
1883
|
+
const { setTheme, theme } = (0, import_next_themes.useTheme)();
|
|
1884
|
+
const [mounted, setMounted] = React4.useState(false);
|
|
1885
|
+
React4.useEffect(() => {
|
|
1886
|
+
setMounted(true);
|
|
1887
|
+
}, []);
|
|
1888
|
+
if (!mounted) {
|
|
1889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1890
|
+
"button",
|
|
1891
|
+
{
|
|
1892
|
+
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 || ""}`,
|
|
1893
|
+
disabled: true,
|
|
1894
|
+
children: [
|
|
1895
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react7.Icon, { icon: "solar:sun-2-linear", width: 20, height: 20 }),
|
|
1896
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sr-only", children: "Toggle theme" })
|
|
1897
|
+
]
|
|
1898
|
+
}
|
|
1899
|
+
);
|
|
1900
|
+
}
|
|
1901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1902
|
+
"button",
|
|
1903
|
+
{
|
|
1904
|
+
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 || ""}`,
|
|
1905
|
+
onClick: () => setTheme(theme === "light" ? "dark" : "light"),
|
|
1906
|
+
children: [
|
|
1907
|
+
theme === "light" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react7.Icon, { icon: "solar:sun-2-linear", width: 20, height: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react7.Icon, { icon: "solar:moon-linear", width: 20, height: 20 }),
|
|
1908
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sr-only", children: "Toggle theme" })
|
|
1909
|
+
]
|
|
1910
|
+
}
|
|
1911
|
+
);
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
// src/components/ui/Toast/ClayxToast.tsx
|
|
1915
|
+
var import_react8 = __toESM(require("react"));
|
|
1916
|
+
var import_react_toastify2 = require("react-toastify");
|
|
1917
|
+
var import_react9 = require("@iconify/react");
|
|
1918
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1919
|
+
var TOAST_ICONS = {
|
|
1920
|
+
success: {
|
|
1921
|
+
icon: "mdi:success",
|
|
1922
|
+
color: "text-green-400",
|
|
1923
|
+
className: "text-green-400",
|
|
1924
|
+
bgGradient: "bg-[#14181df2]",
|
|
1925
|
+
gradientColor: "#389726",
|
|
1926
|
+
borderGradient: "border-[#389726]",
|
|
1927
|
+
borderGradientColor: "#389726"
|
|
1928
|
+
},
|
|
1929
|
+
error: {
|
|
1930
|
+
icon: "ic:outline-close",
|
|
1931
|
+
color: "text-red-400",
|
|
1932
|
+
className: "text-red-400",
|
|
1933
|
+
bgGradient: "bg-[#14181df2]",
|
|
1934
|
+
gradientColor: "#ef4444",
|
|
1935
|
+
borderGradient: "border-[#ef4444]",
|
|
1936
|
+
borderGradientColor: "#ef4444"
|
|
1937
|
+
},
|
|
1938
|
+
warning: {
|
|
1939
|
+
icon: "mi:warning",
|
|
1940
|
+
color: "text-yellow-400",
|
|
1941
|
+
className: "text-yellow-400",
|
|
1942
|
+
bgGradient: "bg-[#14181df2]",
|
|
1943
|
+
gradientColor: "#facc15",
|
|
1944
|
+
borderGradient: "border-[#facc15]",
|
|
1945
|
+
borderGradientColor: "#facc15"
|
|
1946
|
+
},
|
|
1947
|
+
info: {
|
|
1948
|
+
icon: "ic:outline-info",
|
|
1949
|
+
color: "text-blue-400",
|
|
1950
|
+
className: "text-blue-400",
|
|
1951
|
+
bgGradient: "bg-[#14181df2]",
|
|
1952
|
+
gradientColor: "#60a5fa",
|
|
1953
|
+
borderGradient: "border-[#60a5fa]",
|
|
1954
|
+
borderGradientColor: "#f0f0f0"
|
|
1955
|
+
},
|
|
1956
|
+
default: {
|
|
1957
|
+
icon: "ic:round-notifications",
|
|
1958
|
+
color: "text-gray-400",
|
|
1959
|
+
className: "text-gray-400",
|
|
1960
|
+
bgGradient: "bg-[#14181df2]",
|
|
1961
|
+
gradientColor: "#9ca3af",
|
|
1962
|
+
borderGradient: "border-[#9ca3af]",
|
|
1963
|
+
borderGradientColor: "#9ca3af"
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
var CloseButton = import_react8.default.memo(({ closeToast }) => {
|
|
1967
|
+
const handleClick = (0, import_react8.useCallback)((e) => {
|
|
1968
|
+
e.preventDefault();
|
|
1969
|
+
e.stopPropagation();
|
|
1970
|
+
closeToast?.();
|
|
1971
|
+
}, [closeToast]);
|
|
1972
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1973
|
+
import_react9.Icon,
|
|
1974
|
+
{
|
|
1975
|
+
icon: "vaadin:close",
|
|
1976
|
+
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",
|
|
1977
|
+
onClick: handleClick,
|
|
1978
|
+
width: 14,
|
|
1979
|
+
height: 14
|
|
1980
|
+
}
|
|
1981
|
+
);
|
|
1982
|
+
});
|
|
1983
|
+
CloseButton.displayName = "CloseButton";
|
|
1984
|
+
var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
1985
|
+
const iconConfig = TOAST_ICONS[type];
|
|
1986
|
+
const handleClose = (0, import_react8.useCallback)(() => {
|
|
1987
|
+
closeToast?.();
|
|
1988
|
+
}, [closeToast]);
|
|
1989
|
+
console.log(iconConfig, "????????");
|
|
1990
|
+
if (component) {
|
|
1991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `flex items-start gap-3 min-h-[80px] w-full backdrop-blur-md
|
|
1992
|
+
rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
|
|
1993
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 relative z-10", children: component }),
|
|
1994
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { closeToast: handleClose }) })
|
|
1995
|
+
] });
|
|
1996
|
+
}
|
|
1997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `flex items-start gap-3 min-h-[60px] w-full backdrop-blur-md
|
|
1998
|
+
rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
|
|
1999
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2000
|
+
"div",
|
|
2001
|
+
{
|
|
2002
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
2003
|
+
style: {
|
|
2004
|
+
background: `linear-gradient(135deg, ${iconConfig.gradientColor}30 0%, ${iconConfig.gradientColor}20 15%, #14181df2 30%)`
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
),
|
|
2008
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2009
|
+
"div",
|
|
2010
|
+
{
|
|
2011
|
+
className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
|
|
2012
|
+
style: {
|
|
2013
|
+
border: "2px solid transparent",
|
|
2014
|
+
backgroundImage: `linear-gradient(135deg, ${iconConfig.borderGradientColor}60 0%, ${iconConfig.borderGradientColor}40 5%, transparent 22%)`,
|
|
2015
|
+
backgroundOrigin: "border-box",
|
|
2016
|
+
backgroundClip: "border-box",
|
|
2017
|
+
WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
2018
|
+
WebkitMaskComposite: "xor",
|
|
2019
|
+
mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
|
|
2020
|
+
maskComposite: "exclude"
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
),
|
|
2024
|
+
/* @__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)(
|
|
2025
|
+
import_react9.Icon,
|
|
2026
|
+
{
|
|
2027
|
+
icon: iconConfig.icon,
|
|
2028
|
+
width: 16,
|
|
2029
|
+
height: 16,
|
|
2030
|
+
className: iconConfig.color
|
|
2031
|
+
}
|
|
2032
|
+
) }) }),
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
|
|
2034
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[16px] font-semibold leading-tight text-white/95 drop-shadow-sm", children: title }),
|
|
2035
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[13px] font-normal leading-relaxed text-white/75 drop-shadow-sm", children: message })
|
|
2036
|
+
] }),
|
|
2037
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { closeToast: handleClose }) })
|
|
2038
|
+
] });
|
|
2039
|
+
};
|
|
2040
|
+
var defaultToastOptions = {
|
|
2041
|
+
position: "bottom-right",
|
|
2042
|
+
autoClose: 3e3,
|
|
2043
|
+
hideProgressBar: true,
|
|
2044
|
+
closeOnClick: false,
|
|
2045
|
+
pauseOnHover: true,
|
|
2046
|
+
draggable: true,
|
|
2047
|
+
pauseOnFocusLoss: false,
|
|
2048
|
+
theme: "dark",
|
|
2049
|
+
transition: import_react_toastify2.Bounce
|
|
2050
|
+
};
|
|
2051
|
+
var createToast = (type) => {
|
|
2052
|
+
return (params) => {
|
|
2053
|
+
const { title, message, component, options } = params;
|
|
2054
|
+
(0, import_react_toastify2.toast)(
|
|
2055
|
+
({ closeToast }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2056
|
+
ToastContent,
|
|
2057
|
+
{
|
|
2058
|
+
type,
|
|
2059
|
+
title,
|
|
2060
|
+
message: message || "",
|
|
2061
|
+
component,
|
|
2062
|
+
closeToast
|
|
2063
|
+
}
|
|
2064
|
+
),
|
|
2065
|
+
{
|
|
2066
|
+
...defaultToastOptions,
|
|
2067
|
+
...options,
|
|
2068
|
+
className: "!bg-transparent !p-0 !shadow-none",
|
|
2069
|
+
style: { background: "transparent", padding: 0 }
|
|
2070
|
+
}
|
|
2071
|
+
);
|
|
2072
|
+
};
|
|
2073
|
+
};
|
|
2074
|
+
var ClayxToast = {
|
|
2075
|
+
success: createToast("success"),
|
|
2076
|
+
error: createToast("error"),
|
|
2077
|
+
warning: createToast("warning"),
|
|
2078
|
+
info: createToast("info"),
|
|
2079
|
+
default: createToast("default")
|
|
2080
|
+
};
|
|
2081
|
+
|
|
2082
|
+
// src/hooks/use-mobile.ts
|
|
2083
|
+
var React6 = __toESM(require("react"));
|
|
1847
2084
|
var MOBILE_BREAKPOINT = 768;
|
|
1848
2085
|
function useIsMobile() {
|
|
1849
|
-
const [isMobile, setIsMobile] =
|
|
1850
|
-
|
|
2086
|
+
const [isMobile, setIsMobile] = React6.useState(void 0);
|
|
2087
|
+
React6.useEffect(() => {
|
|
1851
2088
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
1852
2089
|
const onChange = () => {
|
|
1853
2090
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
@@ -1860,10 +2097,10 @@ function useIsMobile() {
|
|
|
1860
2097
|
}
|
|
1861
2098
|
|
|
1862
2099
|
// src/hooks/use-debounce.ts
|
|
1863
|
-
var
|
|
2100
|
+
var import_react10 = require("react");
|
|
1864
2101
|
function useDebounce(value, delay) {
|
|
1865
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
1866
|
-
(0,
|
|
2102
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react10.useState)(value);
|
|
2103
|
+
(0, import_react10.useEffect)(() => {
|
|
1867
2104
|
const handler = setTimeout(() => {
|
|
1868
2105
|
setDebouncedValue(value);
|
|
1869
2106
|
}, delay);
|
|
@@ -1874,214 +2111,335 @@ function useDebounce(value, delay) {
|
|
|
1874
2111
|
return debouncedValue;
|
|
1875
2112
|
}
|
|
1876
2113
|
|
|
1877
|
-
// src/utils/
|
|
1878
|
-
function
|
|
1879
|
-
|
|
1880
|
-
const
|
|
1881
|
-
(
|
|
1882
|
-
const isIframe = window.self !== window.top;
|
|
1883
|
-
console.log("isIframe", isIframe);
|
|
2114
|
+
// src/utils/errorHandler.ts
|
|
2115
|
+
var ERROR_HANDLER_SCRIPT = `(function () {
|
|
2116
|
+
// \u68C0\u67E5\u662F\u5426\u5728 iframe \u4E2D\u8FD0\u884C
|
|
2117
|
+
const isIframe = window.self !== window.top;
|
|
2118
|
+
console.log("isIframe", isIframe);
|
|
1884
2119
|
|
|
1885
|
-
|
|
2120
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316");
|
|
1886
2121
|
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
2122
|
+
// \u76F4\u63A5\u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u7684\u51FD\u6570
|
|
2123
|
+
window.__SEND_ERROR_TO_PARENT__ = function (error, details) {
|
|
2124
|
+
try {
|
|
2125
|
+
const errorPayload = {
|
|
2126
|
+
message: error instanceof Error ? error.message : String(error),
|
|
2127
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
2128
|
+
filename: details?.file || details?.filename,
|
|
2129
|
+
lineno: details?.line,
|
|
2130
|
+
colno: details?.column,
|
|
2131
|
+
timestamp: Date.now(),
|
|
2132
|
+
type: details?.type || "compile-error",
|
|
2133
|
+
details: details,
|
|
2134
|
+
};
|
|
1899
2135
|
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
2136
|
+
window.parent.postMessage(
|
|
2137
|
+
{
|
|
2138
|
+
type: "ERROR_EVENT",
|
|
2139
|
+
payload: errorPayload,
|
|
2140
|
+
},
|
|
2141
|
+
"*"
|
|
2142
|
+
);
|
|
1906
2143
|
|
|
1907
|
-
|
|
1908
|
-
|
|
2144
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u9519\u8BEF\u5DF2\u53D1\u9001\u5230\u7236\u7A97\u53E3:", errorPayload);
|
|
2145
|
+
} catch (e) {
|
|
2146
|
+
console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u5931\u8D25:", e);
|
|
2147
|
+
}
|
|
2148
|
+
};
|
|
1909
2149
|
|
|
1910
|
-
|
|
2150
|
+
// \u8BBE\u7F6E MutationObserver \u76D1\u542C vite-error-overlay
|
|
2151
|
+
function setupViteOverlayObserver() {
|
|
2152
|
+
if (!window.MutationObserver) return;
|
|
1911
2153
|
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
2154
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u8BBE\u7F6E Vite \u9519\u8BEF overlay \u76D1\u542C\u5668");
|
|
2155
|
+
|
|
2156
|
+
function processViteErrorOverlay(overlay) {
|
|
2157
|
+
try {
|
|
2158
|
+
if (overlay.hasAttribute("data-error-sent")) return;
|
|
2159
|
+
|
|
2160
|
+
const shadowRoot = overlay.shadowRoot;
|
|
2161
|
+
if (!shadowRoot) {
|
|
2162
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] vite-error-overlay \u6CA1\u6709 Shadow DOM");
|
|
2163
|
+
return;
|
|
2164
|
+
}
|
|
1917
2165
|
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2166
|
+
const messageElement = shadowRoot.querySelector("pre.message");
|
|
2167
|
+
const fileElement = shadowRoot.querySelector("pre.file");
|
|
2168
|
+
const frameElements = shadowRoot.querySelectorAll("pre.frame");
|
|
2169
|
+
const stackElement = shadowRoot.querySelector("pre.stack");
|
|
1922
2170
|
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2171
|
+
const message = messageElement ? messageElement.textContent : "";
|
|
2172
|
+
const file = fileElement ? fileElement.textContent : "";
|
|
2173
|
+
const frames = Array.from(frameElements)
|
|
2174
|
+
.map((el) => el.textContent)
|
|
2175
|
+
.join("
|
|
1926
2176
|
");
|
|
1927
|
-
|
|
2177
|
+
const stack = stackElement ? stackElement.textContent : "";
|
|
1928
2178
|
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
2179
|
+
let line, column;
|
|
2180
|
+
const fileStr = file || "";
|
|
2181
|
+
const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(d+)(?::| )(d+)/i);
|
|
2182
|
+
if (lineColMatch) {
|
|
2183
|
+
line = parseInt(lineColMatch[1], 10);
|
|
2184
|
+
column = parseInt(lineColMatch[2], 10);
|
|
2185
|
+
}
|
|
1936
2186
|
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2187
|
+
const messageStr = message || "";
|
|
2188
|
+
const isReactError =
|
|
2189
|
+
messageStr.includes("React") ||
|
|
2190
|
+
messageStr.includes("JSX") ||
|
|
2191
|
+
messageStr.includes("Unexpected token") ||
|
|
2192
|
+
messageStr.includes("vite:react-babel");
|
|
1943
2193
|
|
|
1944
|
-
|
|
2194
|
+
const viteError = new Error(messageStr);
|
|
1945
2195
|
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2196
|
+
window.__SEND_ERROR_TO_PARENT__(viteError, {
|
|
2197
|
+
file,
|
|
2198
|
+
line,
|
|
2199
|
+
column,
|
|
2200
|
+
frames,
|
|
2201
|
+
stack,
|
|
2202
|
+
isReactError,
|
|
2203
|
+
type: isReactError ? "react-syntax" : "vite-error-overlay",
|
|
2204
|
+
});
|
|
1955
2205
|
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
}
|
|
2206
|
+
overlay.setAttribute("data-error-sent", "true");
|
|
2207
|
+
} catch (e) {
|
|
2208
|
+
console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u5904\u7406 vite-error-overlay \u5931\u8D25:", e);
|
|
1960
2209
|
}
|
|
2210
|
+
}
|
|
1961
2211
|
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
}
|
|
2212
|
+
function checkExistingOverlays() {
|
|
2213
|
+
const viteErrorOverlays = document.querySelectorAll("vite-error-overlay");
|
|
2214
|
+
if (viteErrorOverlays.length > 0) {
|
|
2215
|
+
viteErrorOverlays.forEach((overlay) => {
|
|
2216
|
+
if (!overlay.hasAttribute("data-error-sent")) {
|
|
2217
|
+
processViteErrorOverlay(overlay);
|
|
2218
|
+
}
|
|
2219
|
+
});
|
|
1971
2220
|
}
|
|
2221
|
+
}
|
|
1972
2222
|
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2223
|
+
const observer = new MutationObserver((mutations) => {
|
|
2224
|
+
for (const mutation of mutations) {
|
|
2225
|
+
if (mutation.addedNodes.length > 0) {
|
|
2226
|
+
for (const node of Array.from(mutation.addedNodes)) {
|
|
2227
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
2228
|
+
const element = node;
|
|
2229
|
+
|
|
2230
|
+
if (
|
|
2231
|
+
element.tagName === "VITE-ERROR-OVERLAY" &&
|
|
2232
|
+
!element.hasAttribute("data-error-sent")
|
|
2233
|
+
) {
|
|
2234
|
+
setTimeout(() => processViteErrorOverlay(element), 100);
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
const viteErrorOverlays = element.querySelectorAll("vite-error-overlay");
|
|
2238
|
+
for (const viteErrorOverlay of Array.from(viteErrorOverlays)) {
|
|
2239
|
+
if (!viteErrorOverlay.hasAttribute("data-error-sent")) {
|
|
2240
|
+
setTimeout(() => processViteErrorOverlay(viteErrorOverlay), 100);
|
|
1987
2241
|
}
|
|
1988
2242
|
}
|
|
1989
2243
|
}
|
|
1990
2244
|
}
|
|
1991
2245
|
}
|
|
1992
|
-
}
|
|
2246
|
+
}
|
|
2247
|
+
});
|
|
1993
2248
|
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2249
|
+
observer.observe(document.documentElement, {
|
|
2250
|
+
childList: true,
|
|
2251
|
+
subtree: true,
|
|
2252
|
+
attributes: true,
|
|
2253
|
+
characterData: true,
|
|
2254
|
+
});
|
|
1998
2255
|
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2256
|
+
setTimeout(checkExistingOverlays, 500);
|
|
2257
|
+
setInterval(checkExistingOverlays, 2000);
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
window.addEventListener(
|
|
2261
|
+
"error",
|
|
2262
|
+
function (event) {
|
|
2263
|
+
const target = event && (event.target || event.srcElement);
|
|
2264
|
+
const tagName = target && target.tagName;
|
|
2265
|
+
if (tagName) {
|
|
2266
|
+
const url = (target && (target.src || target.href || target.currentSrc)) ||
|
|
2267
|
+
(target && target.getAttribute && (target.getAttribute('src') || target.getAttribute('href')));
|
|
2268
|
+
const preview = target && target.outerHTML ? String(target.outerHTML).slice(0, 300) : undefined;
|
|
2269
|
+
const resourceError = new Error('Resource load error: ' + tagName + ' ' + (url || 'unknown'));
|
|
2270
|
+
window.__SEND_ERROR_TO_PARENT__(resourceError, {
|
|
2271
|
+
filename: url,
|
|
2272
|
+
tagName: tagName,
|
|
2273
|
+
element: preview,
|
|
2274
|
+
type: "resource"
|
|
2275
|
+
});
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2011
2278
|
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2279
|
+
var stack = (event && event.error && event.error.stack) || "";
|
|
2280
|
+
var message = typeof event.message === "string" ? event.message : "";
|
|
2281
|
+
if ((stack && stack.indexOf('error-handler') !== -1) || !message) return;
|
|
2015
2282
|
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2283
|
+
window.__SEND_ERROR_TO_PARENT__(event.error || new Error(event.message), {
|
|
2284
|
+
filename: event.filename,
|
|
2285
|
+
line: event.lineno,
|
|
2286
|
+
column: event.colno,
|
|
2287
|
+
type: "runtime",
|
|
2288
|
+
});
|
|
2289
|
+
},
|
|
2290
|
+
true
|
|
2291
|
+
);
|
|
2292
|
+
|
|
2293
|
+
window.addEventListener("unhandledrejection", function (event) {
|
|
2294
|
+
const reason = event.reason;
|
|
2295
|
+
window.__SEND_ERROR_TO_PARENT__(
|
|
2296
|
+
reason instanceof Error ? reason : new Error(String(reason)),
|
|
2297
|
+
{ type: "promise" }
|
|
2019
2298
|
);
|
|
2299
|
+
});
|
|
2020
2300
|
|
|
2021
|
-
|
|
2022
|
-
const reason = event.reason;
|
|
2023
|
-
window.__SEND_ERROR_TO_PARENT__(reason instanceof Error ? reason : new Error(String(reason)), { type: "promise" });
|
|
2024
|
-
});
|
|
2301
|
+
setupViteOverlayObserver();
|
|
2025
2302
|
|
|
2026
|
-
|
|
2303
|
+
if (!window.__FETCH_INTERCEPTED__) {
|
|
2304
|
+
window.__FETCH_INTERCEPTED__ = true;
|
|
2305
|
+
const originalFetch = window.fetch;
|
|
2306
|
+
|
|
2307
|
+
function handleFetchError(error, url, response = null) {
|
|
2308
|
+
const errorDetails = {
|
|
2309
|
+
type: "network",
|
|
2310
|
+
method: "fetch",
|
|
2311
|
+
url: url
|
|
2312
|
+
};
|
|
2313
|
+
|
|
2314
|
+
if (response && !response.ok) {
|
|
2315
|
+
errorDetails.status = response.status;
|
|
2316
|
+
errorDetails.statusText = response.statusText;
|
|
2317
|
+
errorDetails.networkError = false;
|
|
2318
|
+
} else {
|
|
2319
|
+
errorDetails.networkError = true;
|
|
2320
|
+
}
|
|
2321
|
+
window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
window.fetch = function(...args) {
|
|
2325
|
+
const url = args[0] instanceof Request ? args[0].url : args[0];
|
|
2326
|
+
|
|
2327
|
+
return originalFetch.apply(this, args)
|
|
2328
|
+
.then(response => {
|
|
2329
|
+
if (!response.ok) {
|
|
2330
|
+
const networkError = new Error(\`HTTP \${response.status}: \${response.statusText}\`);
|
|
2331
|
+
handleFetchError(networkError, url, response);
|
|
2332
|
+
}
|
|
2333
|
+
return response;
|
|
2334
|
+
})
|
|
2335
|
+
.catch(error => {
|
|
2336
|
+
handleFetchError(error, url);
|
|
2337
|
+
throw error;
|
|
2338
|
+
});
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2027
2341
|
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2342
|
+
if (!window.__XHR_INTERCEPTED__) {
|
|
2343
|
+
window.__XHR_INTERCEPTED__ = true;
|
|
2344
|
+
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
2345
|
+
const originalXHRSend = XMLHttpRequest.prototype.send;
|
|
2346
|
+
|
|
2347
|
+
function handleXHRError(error, xhr, isNetworkError = false) {
|
|
2348
|
+
const errorDetails = {
|
|
2349
|
+
type: "network",
|
|
2350
|
+
method: "xhr",
|
|
2351
|
+
url: xhr.__intercepted_url__
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
if (!isNetworkError && xhr.status >= 400) {
|
|
2355
|
+
errorDetails.status = xhr.status;
|
|
2356
|
+
errorDetails.statusText = xhr.statusText;
|
|
2357
|
+
errorDetails.networkError = false;
|
|
2358
|
+
} else {
|
|
2359
|
+
errorDetails.networkError = true;
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
XMLHttpRequest.prototype.open = function(method, url, ...args) {
|
|
2366
|
+
this.__intercepted_method__ = method;
|
|
2367
|
+
this.__intercepted_url__ = url;
|
|
2368
|
+
return originalXHROpen.apply(this, [method, url, ...args]);
|
|
2369
|
+
};
|
|
2370
|
+
|
|
2371
|
+
XMLHttpRequest.prototype.send = function(...args) {
|
|
2372
|
+
const xhr = this;
|
|
2373
|
+
|
|
2374
|
+
const originalOnReadyStateChange = xhr.onreadystatechange;
|
|
2375
|
+
xhr.onreadystatechange = function() {
|
|
2376
|
+
if (xhr.readyState === 4) {
|
|
2377
|
+
if (xhr.status >= 400) {
|
|
2378
|
+
const networkError = new Error(\`HTTP \${xhr.status}: \${xhr.statusText}\`);
|
|
2379
|
+
handleXHRError(networkError, xhr, false);
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
if (originalOnReadyStateChange) {
|
|
2384
|
+
return originalOnReadyStateChange.apply(this, arguments);
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
|
|
2388
|
+
const originalOnError = xhr.onerror;
|
|
2389
|
+
xhr.onerror = function() {
|
|
2390
|
+
const networkError = new Error(\`Network error for \${xhr.__intercepted_method__} \${xhr.__intercepted_url__}\`);
|
|
2391
|
+
handleXHRError(networkError, xhr, true);
|
|
2392
|
+
|
|
2393
|
+
if (originalOnError) {
|
|
2394
|
+
return originalOnError.apply(this, arguments);
|
|
2395
|
+
}
|
|
2396
|
+
};
|
|
2397
|
+
|
|
2398
|
+
return originalXHRSend.apply(this, args);
|
|
2399
|
+
};
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
if (!window.__CONSOLE_ERROR_INTERCEPTED__) {
|
|
2403
|
+
window.__CONSOLE_ERROR_INTERCEPTED__ = true;
|
|
2404
|
+
const originalConsoleError = console.error;
|
|
2405
|
+
console.error = function () {
|
|
2406
|
+
try {
|
|
2407
|
+
var args = Array.prototype.slice.call(arguments);
|
|
2408
|
+
var first = args[0];
|
|
2409
|
+
var firstStr = typeof first === "string" ? first : "";
|
|
2410
|
+
var isReact = firstStr.indexOf("React") !== -1;
|
|
2411
|
+
var isVite = firstStr.indexOf("[vite]") !== -1 || firstStr.indexOf("Failed to reload") !== -1;
|
|
2412
|
+
if (isReact || isVite) {
|
|
2413
|
+
var joined = args
|
|
2414
|
+
.map(function (a) {
|
|
2040
2415
|
if (a instanceof Error) return a.message;
|
|
2041
2416
|
if (typeof a === "string") return a;
|
|
2042
2417
|
if (a && typeof a.message === "string") return a.message;
|
|
2043
|
-
try { return JSON.stringify(a); } catch (
|
|
2044
|
-
})
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
}
|
|
2418
|
+
try { return JSON.stringify(a); } catch (_) { return String(a); }
|
|
2419
|
+
})
|
|
2420
|
+
.join(" ");
|
|
2421
|
+
var errorForReport = new Error(joined);
|
|
2422
|
+
window.__SEND_ERROR_TO_PARENT__(errorForReport, { type: "runtime", viteErrorType: "console" });
|
|
2423
|
+
}
|
|
2424
|
+
} catch (_) {}
|
|
2425
|
+
return originalConsoleError.apply(console, arguments);
|
|
2426
|
+
};
|
|
2427
|
+
}
|
|
2052
2428
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2429
|
+
console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
2430
|
+
})();`;
|
|
2431
|
+
function injectEarlyErrorHandler() {
|
|
2432
|
+
if (typeof document === "undefined") return;
|
|
2056
2433
|
try {
|
|
2057
|
-
|
|
2058
|
-
try {
|
|
2059
|
-
const external = document.createElement("script");
|
|
2060
|
-
external.type = "text/javascript";
|
|
2061
|
-
external.src = "/error-handler.js";
|
|
2062
|
-
external.async = false;
|
|
2063
|
-
parent.prepend(external);
|
|
2064
|
-
return;
|
|
2065
|
-
} catch (e) {
|
|
2066
|
-
void e;
|
|
2067
|
-
}
|
|
2434
|
+
if (window.__EARLY_ERROR_HANDLER_INJECTED__) return;
|
|
2068
2435
|
const script = document.createElement("script");
|
|
2069
2436
|
script.type = "text/javascript";
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
}
|
|
2076
|
-
} catch (e) {
|
|
2077
|
-
try {
|
|
2078
|
-
script.appendChild(document.createTextNode(code));
|
|
2079
|
-
} catch {
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
parent.prepend(script);
|
|
2437
|
+
script.text = ERROR_HANDLER_SCRIPT;
|
|
2438
|
+
const head = document.head || document.getElementsByTagName("head")[0];
|
|
2439
|
+
if (head && head.firstChild) head.insertBefore(script, head.firstChild);
|
|
2440
|
+
else if (head) head.appendChild(script);
|
|
2441
|
+
window.__EARLY_ERROR_HANDLER_INJECTED__ = true;
|
|
2083
2442
|
} catch (e) {
|
|
2084
|
-
void e;
|
|
2085
2443
|
}
|
|
2086
2444
|
}
|
|
2087
2445
|
|
|
@@ -2093,12 +2451,17 @@ init_config();
|
|
|
2093
2451
|
AUTH_ROOT,
|
|
2094
2452
|
AUTH_TOKEN_KEY,
|
|
2095
2453
|
AuthProvider,
|
|
2454
|
+
ClayxToast,
|
|
2096
2455
|
DefaultErrorFallback,
|
|
2097
2456
|
ErrorBoundary,
|
|
2098
2457
|
FloatingButton,
|
|
2458
|
+
GlobalToastContainer,
|
|
2459
|
+
HowoneProvider,
|
|
2099
2460
|
Loading,
|
|
2100
2461
|
LoadingSpinner,
|
|
2101
2462
|
LoginForm,
|
|
2463
|
+
ThemeProvider,
|
|
2464
|
+
ThemeToggle,
|
|
2102
2465
|
aiRequest,
|
|
2103
2466
|
aiWorkflow,
|
|
2104
2467
|
canAccessArtifact,
|
|
@@ -2127,6 +2490,7 @@ init_config();
|
|
|
2127
2490
|
useAuthContext,
|
|
2128
2491
|
useDebounce,
|
|
2129
2492
|
useIsMobile,
|
|
2493
|
+
useTheme,
|
|
2130
2494
|
workflowRequest
|
|
2131
2495
|
});
|
|
2132
2496
|
//# sourceMappingURL=index.js.map
|