@howone/sdk 0.1.20 → 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.d.mts +3 -7
- package/dist/index.d.ts +3 -7
- package/dist/index.js +45 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1497,9 +1497,9 @@ var LoginForm = ({
|
|
|
1497
1497
|
] });
|
|
1498
1498
|
};
|
|
1499
1499
|
|
|
1500
|
-
// src/components/auth/
|
|
1500
|
+
// src/components/auth/HowoneProvider.tsx
|
|
1501
1501
|
init_auth();
|
|
1502
|
-
import { createContext as createContext2, useContext as useContext2, useState as useState4 } from "react";
|
|
1502
|
+
import { createContext as createContext2, useContext as useContext2, useState as useState4, useEffect as useEffect4 } from "react";
|
|
1503
1503
|
|
|
1504
1504
|
// src/components/theme/ThemeProvider.tsx
|
|
1505
1505
|
import { createContext, useContext, useEffect as useEffect3, useState as useState3 } from "react";
|
|
@@ -1567,9 +1567,9 @@ function GlobalToastContainer() {
|
|
|
1567
1567
|
);
|
|
1568
1568
|
}
|
|
1569
1569
|
|
|
1570
|
-
// src/components/auth/
|
|
1570
|
+
// src/components/auth/HowoneProvider.tsx
|
|
1571
1571
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1572
|
-
var
|
|
1572
|
+
var HowoneContext = createContext2(null);
|
|
1573
1573
|
var HowoneProvider = ({
|
|
1574
1574
|
children,
|
|
1575
1575
|
showFloatingButton = true,
|
|
@@ -1579,6 +1579,24 @@ var HowoneProvider = ({
|
|
|
1579
1579
|
}) => {
|
|
1580
1580
|
const [user, setUser] = useState4(() => parseUserFromToken(getToken()));
|
|
1581
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
|
+
}, []);
|
|
1582
1600
|
const logout = () => {
|
|
1583
1601
|
try {
|
|
1584
1602
|
setToken(null);
|
|
@@ -1600,7 +1618,7 @@ var HowoneProvider = ({
|
|
|
1600
1618
|
storageKey: themeStorageKey,
|
|
1601
1619
|
forceDefault: forceDefaultTheme,
|
|
1602
1620
|
children: [
|
|
1603
|
-
/* @__PURE__ */ jsxs3(
|
|
1621
|
+
/* @__PURE__ */ jsxs3(HowoneContext.Provider, { value, children: [
|
|
1604
1622
|
children,
|
|
1605
1623
|
showFloatingButton && /* @__PURE__ */ jsx5(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
1606
1624
|
] }),
|
|
@@ -1609,8 +1627,8 @@ var HowoneProvider = ({
|
|
|
1609
1627
|
}
|
|
1610
1628
|
);
|
|
1611
1629
|
};
|
|
1612
|
-
function
|
|
1613
|
-
const ctx = useContext2(
|
|
1630
|
+
function useHowoneContext() {
|
|
1631
|
+
const ctx = useContext2(HowoneContext);
|
|
1614
1632
|
if (!ctx) {
|
|
1615
1633
|
const t = getToken();
|
|
1616
1634
|
return {
|
|
@@ -1627,7 +1645,6 @@ function useAuthContext() {
|
|
|
1627
1645
|
}
|
|
1628
1646
|
return ctx;
|
|
1629
1647
|
}
|
|
1630
|
-
var AuthProvider = HowoneProvider;
|
|
1631
1648
|
|
|
1632
1649
|
// src/components/index.ts
|
|
1633
1650
|
init_auth();
|
|
@@ -1970,15 +1987,31 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
|
1970
1987
|
}
|
|
1971
1988
|
) }) }),
|
|
1972
1989
|
/* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
|
|
1973
|
-
title && /* @__PURE__ */ jsx9(
|
|
1974
|
-
|
|
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
|
+
)
|
|
1975
2008
|
] }),
|
|
1976
2009
|
/* @__PURE__ */ jsx9("div", { className: "relative z-10", children: /* @__PURE__ */ jsx9(CloseButton, { closeToast: handleClose }) })
|
|
1977
2010
|
] });
|
|
1978
2011
|
};
|
|
1979
2012
|
var defaultToastOptions = {
|
|
1980
2013
|
position: "bottom-right",
|
|
1981
|
-
autoClose:
|
|
2014
|
+
autoClose: 3e5,
|
|
1982
2015
|
hideProgressBar: true,
|
|
1983
2016
|
closeOnClick: false,
|
|
1984
2017
|
pauseOnHover: true,
|
|
@@ -2036,10 +2069,10 @@ function useIsMobile() {
|
|
|
2036
2069
|
}
|
|
2037
2070
|
|
|
2038
2071
|
// src/hooks/use-debounce.ts
|
|
2039
|
-
import { useState as useState7, useEffect as
|
|
2072
|
+
import { useState as useState7, useEffect as useEffect7 } from "react";
|
|
2040
2073
|
function useDebounce(value, delay) {
|
|
2041
2074
|
const [debouncedValue, setDebouncedValue] = useState7(value);
|
|
2042
|
-
|
|
2075
|
+
useEffect7(() => {
|
|
2043
2076
|
const handler = setTimeout(() => {
|
|
2044
2077
|
setDebouncedValue(value);
|
|
2045
2078
|
}, delay);
|
|
@@ -2388,7 +2421,6 @@ init_config();
|
|
|
2388
2421
|
export {
|
|
2389
2422
|
AUTH_ROOT,
|
|
2390
2423
|
AUTH_TOKEN_KEY,
|
|
2391
|
-
AuthProvider,
|
|
2392
2424
|
ClayxToast,
|
|
2393
2425
|
DefaultErrorFallback,
|
|
2394
2426
|
ErrorBoundary,
|
|
@@ -2425,8 +2457,8 @@ export {
|
|
|
2425
2457
|
unifiedAuth,
|
|
2426
2458
|
unifiedOAuth,
|
|
2427
2459
|
useAuth,
|
|
2428
|
-
useAuthContext,
|
|
2429
2460
|
useDebounce,
|
|
2461
|
+
useHowoneContext,
|
|
2430
2462
|
useIsMobile,
|
|
2431
2463
|
useTheme,
|
|
2432
2464
|
workflowRequest
|