@howone/sdk 0.1.19 → 0.1.21

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.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 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}`,
235
+ 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}`,
236
236
  style: {
237
237
  fontSize: "14px",
238
238
  fontWeight: "bold",
@@ -1497,14 +1497,106 @@ var LoginForm = ({
1497
1497
  ] });
1498
1498
  };
1499
1499
 
1500
- // src/components/auth/AuthProvider.tsx
1500
+ // src/components/auth/HowoneProvider.tsx
1501
1501
  init_auth();
1502
- import { createContext, useContext, useState as useState3 } from "react";
1503
- import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1504
- var AuthContext = createContext(null);
1505
- var AuthProvider = ({ children, showFloatingButton = true }) => {
1506
- const [user, setUser] = useState3(() => parseUserFromToken(getToken()));
1507
- const [token, setTokenState] = useState3(() => getToken());
1502
+ import { createContext as createContext2, useContext as useContext2, useState as useState4, useEffect as useEffect4 } from "react";
1503
+
1504
+ // src/components/theme/ThemeProvider.tsx
1505
+ import { createContext, useContext, useEffect as useEffect3, useState as useState3 } from "react";
1506
+ import { jsx as jsx3 } from "react/jsx-runtime";
1507
+ var initialState = {
1508
+ theme: "system",
1509
+ setTheme: () => null
1510
+ };
1511
+ var ThemeProviderContext = createContext(initialState);
1512
+ function ThemeProvider({
1513
+ children,
1514
+ defaultTheme = "system",
1515
+ storageKey = "vite-ui-theme",
1516
+ forceDefault = false,
1517
+ ...props
1518
+ }) {
1519
+ const [theme, setTheme] = useState3(() => {
1520
+ if (forceDefault) {
1521
+ localStorage.setItem(storageKey, defaultTheme);
1522
+ return defaultTheme;
1523
+ }
1524
+ const stored = localStorage.getItem(storageKey);
1525
+ const initialTheme = stored || defaultTheme;
1526
+ if (!stored) {
1527
+ localStorage.setItem(storageKey, defaultTheme);
1528
+ }
1529
+ return initialTheme;
1530
+ });
1531
+ useEffect3(() => {
1532
+ const root = window.document.documentElement;
1533
+ root.classList.remove("light", "dark");
1534
+ if (theme === "system") {
1535
+ const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
1536
+ root.classList.add(systemTheme);
1537
+ return;
1538
+ }
1539
+ root.classList.add(theme);
1540
+ }, [theme]);
1541
+ const value = {
1542
+ theme,
1543
+ setTheme: (theme2) => {
1544
+ localStorage.setItem(storageKey, theme2);
1545
+ setTheme(theme2);
1546
+ }
1547
+ };
1548
+ return /* @__PURE__ */ jsx3(ThemeProviderContext.Provider, { ...props, value, children });
1549
+ }
1550
+ var useTheme = () => {
1551
+ const context = useContext(ThemeProviderContext);
1552
+ if (context === void 0)
1553
+ throw new Error("useTheme must be used within a ThemeProvider");
1554
+ return context;
1555
+ };
1556
+
1557
+ // src/components/ui/Toast/GlobalToastContainer.tsx
1558
+ import { ToastContainer } from "react-toastify";
1559
+ import { jsx as jsx4 } from "react/jsx-runtime";
1560
+ function GlobalToastContainer() {
1561
+ return /* @__PURE__ */ jsx4(
1562
+ ToastContainer,
1563
+ {
1564
+ newestOnTop: false,
1565
+ closeButton: false
1566
+ }
1567
+ );
1568
+ }
1569
+
1570
+ // src/components/auth/HowoneProvider.tsx
1571
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1572
+ var HowoneContext = createContext2(null);
1573
+ var HowoneProvider = ({
1574
+ children,
1575
+ showFloatingButton = true,
1576
+ defaultTheme = "system",
1577
+ themeStorageKey = "howone-theme",
1578
+ forceDefaultTheme = false
1579
+ }) => {
1580
+ const [user, setUser] = useState4(() => parseUserFromToken(getToken()));
1581
+ const [token, setTokenState] = useState4(() => getToken());
1582
+ useEffect4(() => {
1583
+ try {
1584
+ const params = new URLSearchParams(window.location.search);
1585
+ const urlToken = params.get("access_token") || params.get("token");
1586
+ if (urlToken) {
1587
+ setToken(urlToken);
1588
+ setTokenState(urlToken);
1589
+ setUser(parseUserFromToken(urlToken));
1590
+ params.delete("access_token");
1591
+ params.delete("token");
1592
+ const newSearch = params.toString();
1593
+ const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "") + window.location.hash;
1594
+ window.history.replaceState({}, "", newUrl);
1595
+ }
1596
+ } catch (e) {
1597
+ console.error("[HowoneProvider] Failed to capture token from URL:", e);
1598
+ }
1599
+ }, []);
1508
1600
  const logout = () => {
1509
1601
  try {
1510
1602
  setToken(null);
@@ -1519,13 +1611,24 @@ var AuthProvider = ({ children, showFloatingButton = true }) => {
1519
1611
  isAuthenticated: !!token,
1520
1612
  logout
1521
1613
  };
1522
- return /* @__PURE__ */ jsx3(AuthContext.Provider, { value, children: /* @__PURE__ */ jsxs3(Fragment, { children: [
1523
- children,
1524
- showFloatingButton && /* @__PURE__ */ jsx3(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1525
- ] }) });
1614
+ return /* @__PURE__ */ jsxs3(
1615
+ ThemeProvider,
1616
+ {
1617
+ defaultTheme,
1618
+ storageKey: themeStorageKey,
1619
+ forceDefault: forceDefaultTheme,
1620
+ children: [
1621
+ /* @__PURE__ */ jsxs3(HowoneContext.Provider, { value, children: [
1622
+ children,
1623
+ showFloatingButton && /* @__PURE__ */ jsx5(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1624
+ ] }),
1625
+ /* @__PURE__ */ jsx5(GlobalToastContainer, {})
1626
+ ]
1627
+ }
1628
+ );
1526
1629
  };
1527
- function useAuthContext() {
1528
- const ctx = useContext(AuthContext);
1630
+ function useHowoneContext() {
1631
+ const ctx = useContext2(HowoneContext);
1529
1632
  if (!ctx) {
1530
1633
  const t = getToken();
1531
1634
  return {
@@ -1629,7 +1732,7 @@ var howone = {
1629
1732
  var client_default = howone;
1630
1733
 
1631
1734
  // src/components/ui/Loading.tsx
1632
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1735
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1633
1736
  var Loading = ({
1634
1737
  size = "md",
1635
1738
  text = "Loading...",
@@ -1642,14 +1745,14 @@ var Loading = ({
1642
1745
  lg: "h-12 w-12"
1643
1746
  };
1644
1747
  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(
1748
+ return /* @__PURE__ */ jsx6("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ jsxs4("div", { className: "text-center", children: [
1749
+ /* @__PURE__ */ jsx6(
1647
1750
  "div",
1648
1751
  {
1649
1752
  className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
1650
1753
  }
1651
1754
  ),
1652
- text && /* @__PURE__ */ jsx4("p", { className: "mt-2 text-sm text-gray-600", children: text })
1755
+ text && /* @__PURE__ */ jsx6("p", { className: "mt-2 text-sm text-gray-600", children: text })
1653
1756
  ] }) });
1654
1757
  };
1655
1758
  var LoadingSpinner = ({
@@ -1661,7 +1764,7 @@ var LoadingSpinner = ({
1661
1764
  md: "h-8 w-8",
1662
1765
  lg: "h-12 w-12"
1663
1766
  };
1664
- return /* @__PURE__ */ jsx4(
1767
+ return /* @__PURE__ */ jsx6(
1665
1768
  "div",
1666
1769
  {
1667
1770
  className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
@@ -1671,7 +1774,7 @@ var LoadingSpinner = ({
1671
1774
 
1672
1775
  // src/components/ui/ErrorBoundary.tsx
1673
1776
  import { Component } from "react";
1674
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1777
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1675
1778
  var ErrorBoundary = class extends Component {
1676
1779
  constructor(props) {
1677
1780
  super(props);
@@ -1694,13 +1797,13 @@ var ErrorBoundary = class extends Component {
1694
1797
  if (this.state.hasError) {
1695
1798
  if (this.props.fallback) {
1696
1799
  const FallbackComponent = this.props.fallback;
1697
- return /* @__PURE__ */ jsx5(FallbackComponent, { error: this.state.error, retry: this.handleRetry });
1800
+ return /* @__PURE__ */ jsx7(FallbackComponent, { error: this.state.error, retry: this.handleRetry });
1698
1801
  }
1699
- return /* @__PURE__ */ jsx5("div", { className: "min-h-[400px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center max-w-md", children: [
1700
- /* @__PURE__ */ jsx5("div", { className: "text-red-500 text-6xl mb-4", children: "\u26A0\uFE0F" }),
1701
- /* @__PURE__ */ jsx5("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Something went wrong" }),
1702
- /* @__PURE__ */ jsx5("p", { className: "text-gray-600 mb-4", children: "An unexpected error occurred. Please try refreshing the page." }),
1703
- /* @__PURE__ */ jsx5(
1802
+ return /* @__PURE__ */ jsx7("div", { className: "min-h-[400px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center max-w-md", children: [
1803
+ /* @__PURE__ */ jsx7("div", { className: "text-red-500 text-6xl mb-4", children: "\u26A0\uFE0F" }),
1804
+ /* @__PURE__ */ jsx7("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Something went wrong" }),
1805
+ /* @__PURE__ */ jsx7("p", { className: "text-gray-600 mb-4", children: "An unexpected error occurred. Please try refreshing the page." }),
1806
+ /* @__PURE__ */ jsx7(
1704
1807
  "button",
1705
1808
  {
1706
1809
  onClick: this.handleRetry,
@@ -1714,10 +1817,10 @@ var ErrorBoundary = class extends Component {
1714
1817
  return this.props.children;
1715
1818
  }
1716
1819
  };
1717
- var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx5("div", { className: "min-h-[200px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center", children: [
1718
- /* @__PURE__ */ jsx5("div", { className: "text-red-500 text-4xl mb-2", children: "\u26A0\uFE0F" }),
1719
- /* @__PURE__ */ jsx5("p", { className: "text-gray-600 mb-2", children: "Something went wrong" }),
1720
- retry && /* @__PURE__ */ jsx5(
1820
+ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx7("div", { className: "min-h-[200px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center", children: [
1821
+ /* @__PURE__ */ jsx7("div", { className: "text-red-500 text-4xl mb-2", children: "\u26A0\uFE0F" }),
1822
+ /* @__PURE__ */ jsx7("p", { className: "text-gray-600 mb-2", children: "Something went wrong" }),
1823
+ retry && /* @__PURE__ */ jsx7(
1721
1824
  "button",
1722
1825
  {
1723
1826
  onClick: retry,
@@ -1727,54 +1830,11 @@ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx5("div", { classNam
1727
1830
  )
1728
1831
  ] }) });
1729
1832
 
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
1833
  // src/components/theme/ThemeToggle.tsx
1774
1834
  import * as React4 from "react";
1775
1835
  import { useTheme as useTheme2 } from "next-themes";
1776
1836
  import { Icon as Icon3 } from "@iconify/react";
1777
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1837
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1778
1838
  function ThemeToggle({ className }) {
1779
1839
  const { setTheme, theme } = useTheme2();
1780
1840
  const [mounted, setMounted] = React4.useState(false);
@@ -1788,8 +1848,8 @@ function ThemeToggle({ className }) {
1788
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 || ""}`,
1789
1849
  disabled: true,
1790
1850
  children: [
1791
- /* @__PURE__ */ jsx7(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }),
1792
- /* @__PURE__ */ jsx7("span", { className: "sr-only", children: "Toggle theme" })
1851
+ /* @__PURE__ */ jsx8(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }),
1852
+ /* @__PURE__ */ jsx8("span", { className: "sr-only", children: "Toggle theme" })
1793
1853
  ]
1794
1854
  }
1795
1855
  );
@@ -1800,26 +1860,13 @@ function ThemeToggle({ className }) {
1800
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 || ""}`,
1801
1861
  onClick: () => setTheme(theme === "light" ? "dark" : "light"),
1802
1862
  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" })
1863
+ theme === "light" ? /* @__PURE__ */ jsx8(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }) : /* @__PURE__ */ jsx8(Icon3, { icon: "solar:moon-linear", width: 20, height: 20 }),
1864
+ /* @__PURE__ */ jsx8("span", { className: "sr-only", children: "Toggle theme" })
1805
1865
  ]
1806
1866
  }
1807
1867
  );
1808
1868
  }
1809
1869
 
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
1870
  // src/components/ui/Toast/ClayxToast.tsx
1824
1871
  import React5, { useCallback } from "react";
1825
1872
  import { Bounce, toast } from "react-toastify";
@@ -1940,15 +1987,31 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
1940
1987
  }
1941
1988
  ) }) }),
1942
1989
  /* @__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 })
1990
+ title && /* @__PURE__ */ jsx9(
1991
+ "div",
1992
+ {
1993
+ className: "font-semibold leading-tight text-white/95 drop-shadow-sm",
1994
+ style: { fontSize: "16px" },
1995
+ children: title
1996
+ }
1997
+ ),
1998
+ message && /* @__PURE__ */ jsx9(
1999
+ "div",
2000
+ {
2001
+ className: "text-white/75 drop-shadow-sm",
2002
+ style: {
2003
+ fontSize: "13px"
2004
+ },
2005
+ children: message
2006
+ }
2007
+ )
1945
2008
  ] }),
1946
2009
  /* @__PURE__ */ jsx9("div", { className: "relative z-10", children: /* @__PURE__ */ jsx9(CloseButton, { closeToast: handleClose }) })
1947
2010
  ] });
1948
2011
  };
1949
2012
  var defaultToastOptions = {
1950
2013
  position: "bottom-right",
1951
- autoClose: 3e3,
2014
+ autoClose: 3e5,
1952
2015
  hideProgressBar: true,
1953
2016
  closeOnClick: false,
1954
2017
  pauseOnHover: true,
@@ -2006,10 +2069,10 @@ function useIsMobile() {
2006
2069
  }
2007
2070
 
2008
2071
  // src/hooks/use-debounce.ts
2009
- import { useState as useState7, useEffect as useEffect6 } from "react";
2072
+ import { useState as useState7, useEffect as useEffect7 } from "react";
2010
2073
  function useDebounce(value, delay) {
2011
2074
  const [debouncedValue, setDebouncedValue] = useState7(value);
2012
- useEffect6(() => {
2075
+ useEffect7(() => {
2013
2076
  const handler = setTimeout(() => {
2014
2077
  setDebouncedValue(value);
2015
2078
  }, delay);
@@ -2358,12 +2421,12 @@ init_config();
2358
2421
  export {
2359
2422
  AUTH_ROOT,
2360
2423
  AUTH_TOKEN_KEY,
2361
- AuthProvider,
2362
2424
  ClayxToast,
2363
2425
  DefaultErrorFallback,
2364
2426
  ErrorBoundary,
2365
2427
  FloatingButton,
2366
2428
  GlobalToastContainer,
2429
+ HowoneProvider,
2367
2430
  Loading,
2368
2431
  LoadingSpinner,
2369
2432
  LoginForm,
@@ -2394,8 +2457,8 @@ export {
2394
2457
  unifiedAuth,
2395
2458
  unifiedOAuth,
2396
2459
  useAuth,
2397
- useAuthContext,
2398
2460
  useDebounce,
2461
+ useHowoneContext,
2399
2462
  useIsMobile,
2400
2463
  useTheme,
2401
2464
  workflowRequest