@howone/sdk 0.1.20 → 0.1.22

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
@@ -328,7 +328,6 @@ var UnifiedAuthService = class {
328
328
  };
329
329
  popupCheckInterval = window.setInterval(checkPopupStatus, 1e3);
330
330
  const messageHandler = (event) => {
331
- console.log("messageHandler", event);
332
331
  const validOrigins = [window.location.origin, "https://create-x-backend-dev.fly.dev"];
333
332
  const isValidOrigin = validOrigins.some(
334
333
  (origin) => event.origin === origin || event.origin.includes("localhost") || event.origin.includes("127.0.0.1") || event.origin.includes("fly.dev")
@@ -1497,9 +1496,9 @@ var LoginForm = ({
1497
1496
  ] });
1498
1497
  };
1499
1498
 
1500
- // src/components/auth/AuthProvider.tsx
1499
+ // src/components/auth/HowoneProvider.tsx
1501
1500
  init_auth();
1502
- import { createContext as createContext2, useContext as useContext2, useState as useState4 } from "react";
1501
+ import { createContext as createContext2, useContext as useContext2, useState as useState4, useEffect as useEffect4 } from "react";
1503
1502
 
1504
1503
  // src/components/theme/ThemeProvider.tsx
1505
1504
  import { createContext, useContext, useEffect as useEffect3, useState as useState3 } from "react";
@@ -1567,9 +1566,9 @@ function GlobalToastContainer() {
1567
1566
  );
1568
1567
  }
1569
1568
 
1570
- // src/components/auth/AuthProvider.tsx
1569
+ // src/components/auth/HowoneProvider.tsx
1571
1570
  import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1572
- var AuthContext = createContext2(null);
1571
+ var HowoneContext = createContext2(null);
1573
1572
  var HowoneProvider = ({
1574
1573
  children,
1575
1574
  showFloatingButton = true,
@@ -1579,6 +1578,24 @@ var HowoneProvider = ({
1579
1578
  }) => {
1580
1579
  const [user, setUser] = useState4(() => parseUserFromToken(getToken()));
1581
1580
  const [token, setTokenState] = useState4(() => getToken());
1581
+ useEffect4(() => {
1582
+ try {
1583
+ const params = new URLSearchParams(window.location.search);
1584
+ const urlToken = params.get("access_token") || params.get("token");
1585
+ if (urlToken) {
1586
+ setToken(urlToken);
1587
+ setTokenState(urlToken);
1588
+ setUser(parseUserFromToken(urlToken));
1589
+ params.delete("access_token");
1590
+ params.delete("token");
1591
+ const newSearch = params.toString();
1592
+ const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "") + window.location.hash;
1593
+ window.history.replaceState({}, "", newUrl);
1594
+ }
1595
+ } catch (e) {
1596
+ console.error("[HowoneProvider] Failed to capture token from URL:", e);
1597
+ }
1598
+ }, []);
1582
1599
  const logout = () => {
1583
1600
  try {
1584
1601
  setToken(null);
@@ -1600,7 +1617,7 @@ var HowoneProvider = ({
1600
1617
  storageKey: themeStorageKey,
1601
1618
  forceDefault: forceDefaultTheme,
1602
1619
  children: [
1603
- /* @__PURE__ */ jsxs3(AuthContext.Provider, { value, children: [
1620
+ /* @__PURE__ */ jsxs3(HowoneContext.Provider, { value, children: [
1604
1621
  children,
1605
1622
  showFloatingButton && /* @__PURE__ */ jsx5(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1606
1623
  ] }),
@@ -1609,8 +1626,8 @@ var HowoneProvider = ({
1609
1626
  }
1610
1627
  );
1611
1628
  };
1612
- function useAuthContext() {
1613
- const ctx = useContext2(AuthContext);
1629
+ function useHowoneContext() {
1630
+ const ctx = useContext2(HowoneContext);
1614
1631
  if (!ctx) {
1615
1632
  const t = getToken();
1616
1633
  return {
@@ -1627,7 +1644,6 @@ function useAuthContext() {
1627
1644
  }
1628
1645
  return ctx;
1629
1646
  }
1630
- var AuthProvider = HowoneProvider;
1631
1647
 
1632
1648
  // src/components/index.ts
1633
1649
  init_auth();
@@ -1925,7 +1941,6 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
1925
1941
  const handleClose = useCallback(() => {
1926
1942
  closeToast?.();
1927
1943
  }, [closeToast]);
1928
- console.log(iconConfig, "????????");
1929
1944
  if (component) {
1930
1945
  return /* @__PURE__ */ jsxs7("div", { className: `flex items-start gap-3 min-h-[80px] w-full backdrop-blur-md
1931
1946
  rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
@@ -1970,15 +1985,31 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
1970
1985
  }
1971
1986
  ) }) }),
1972
1987
  /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
1973
- title && /* @__PURE__ */ jsx9("div", { className: "text-[16px] font-semibold leading-tight text-white/95 drop-shadow-sm", children: title }),
1974
- message && /* @__PURE__ */ jsx9("div", { className: "text-[13px] font-normal leading-relaxed text-white/75 drop-shadow-sm", children: message })
1988
+ title && /* @__PURE__ */ jsx9(
1989
+ "div",
1990
+ {
1991
+ className: "font-semibold leading-tight text-white/95 drop-shadow-sm",
1992
+ style: { fontSize: "16px" },
1993
+ children: title
1994
+ }
1995
+ ),
1996
+ message && /* @__PURE__ */ jsx9(
1997
+ "div",
1998
+ {
1999
+ className: "text-white/75 drop-shadow-sm",
2000
+ style: {
2001
+ fontSize: "13px"
2002
+ },
2003
+ children: message
2004
+ }
2005
+ )
1975
2006
  ] }),
1976
2007
  /* @__PURE__ */ jsx9("div", { className: "relative z-10", children: /* @__PURE__ */ jsx9(CloseButton, { closeToast: handleClose }) })
1977
2008
  ] });
1978
2009
  };
1979
2010
  var defaultToastOptions = {
1980
2011
  position: "bottom-right",
1981
- autoClose: 3e3,
2012
+ autoClose: 3e5,
1982
2013
  hideProgressBar: true,
1983
2014
  closeOnClick: false,
1984
2015
  pauseOnHover: true,
@@ -2036,10 +2067,10 @@ function useIsMobile() {
2036
2067
  }
2037
2068
 
2038
2069
  // src/hooks/use-debounce.ts
2039
- import { useState as useState7, useEffect as useEffect6 } from "react";
2070
+ import { useState as useState7, useEffect as useEffect7 } from "react";
2040
2071
  function useDebounce(value, delay) {
2041
2072
  const [debouncedValue, setDebouncedValue] = useState7(value);
2042
- useEffect6(() => {
2073
+ useEffect7(() => {
2043
2074
  const handler = setTimeout(() => {
2044
2075
  setDebouncedValue(value);
2045
2076
  }, delay);
@@ -2111,13 +2142,12 @@ var ERROR_HANDLER_SCRIPT = `(function () {
2111
2142
  const file = fileElement ? fileElement.textContent : "";
2112
2143
  const frames = Array.from(frameElements)
2113
2144
  .map((el) => el.textContent)
2114
- .join("
2115
- ");
2145
+ .join("\\n");
2116
2146
  const stack = stackElement ? stackElement.textContent : "";
2117
2147
 
2118
2148
  let line, column;
2119
2149
  const fileStr = file || "";
2120
- const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(d+)(?::| )(d+)/i);
2150
+ const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(\\d+)(?::| )(\\d+)/i);
2121
2151
  if (lineColMatch) {
2122
2152
  line = parseInt(lineColMatch[1], 10);
2123
2153
  column = parseInt(lineColMatch[2], 10);
@@ -2266,7 +2296,7 @@ var ERROR_HANDLER_SCRIPT = `(function () {
2266
2296
  return originalFetch.apply(this, args)
2267
2297
  .then(response => {
2268
2298
  if (!response.ok) {
2269
- const networkError = new Error(\`HTTP \${response.status}: \${response.statusText}\`);
2299
+ const networkError = new Error('HTTP ' + response.status + ': ' + response.statusText);
2270
2300
  handleFetchError(networkError, url, response);
2271
2301
  }
2272
2302
  return response;
@@ -2314,7 +2344,7 @@ var ERROR_HANDLER_SCRIPT = `(function () {
2314
2344
  xhr.onreadystatechange = function() {
2315
2345
  if (xhr.readyState === 4) {
2316
2346
  if (xhr.status >= 400) {
2317
- const networkError = new Error(\`HTTP \${xhr.status}: \${xhr.statusText}\`);
2347
+ const networkError = new Error('HTTP ' + xhr.status + ': ' + xhr.statusText);
2318
2348
  handleXHRError(networkError, xhr, false);
2319
2349
  }
2320
2350
  }
@@ -2326,7 +2356,7 @@ var ERROR_HANDLER_SCRIPT = `(function () {
2326
2356
 
2327
2357
  const originalOnError = xhr.onerror;
2328
2358
  xhr.onerror = function() {
2329
- const networkError = new Error(\`Network error for \${xhr.__intercepted_method__} \${xhr.__intercepted_url__}\`);
2359
+ const networkError = new Error('Network error for ' + xhr.__intercepted_method__ + ' ' + xhr.__intercepted_url__);
2330
2360
  handleXHRError(networkError, xhr, true);
2331
2361
 
2332
2362
  if (originalOnError) {
@@ -2388,7 +2418,6 @@ init_config();
2388
2418
  export {
2389
2419
  AUTH_ROOT,
2390
2420
  AUTH_TOKEN_KEY,
2391
- AuthProvider,
2392
2421
  ClayxToast,
2393
2422
  DefaultErrorFallback,
2394
2423
  ErrorBoundary,
@@ -2425,8 +2454,8 @@ export {
2425
2454
  unifiedAuth,
2426
2455
  unifiedOAuth,
2427
2456
  useAuth,
2428
- useAuthContext,
2429
2457
  useDebounce,
2458
+ useHowoneContext,
2430
2459
  useIsMobile,
2431
2460
  useTheme,
2432
2461
  workflowRequest