@howone/sdk 0.3.6 → 0.3.8
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 +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +35 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -162,7 +162,7 @@ function parseUserFromToken(token) {
|
|
|
162
162
|
const payload = decodeJwtPayload(token);
|
|
163
163
|
if (!payload) return null;
|
|
164
164
|
return {
|
|
165
|
-
id: payload.userId || payload.sub || "",
|
|
165
|
+
id: payload.puid || payload.userId || payload.sub || "",
|
|
166
166
|
email: payload.email || "",
|
|
167
167
|
name: payload.name || "",
|
|
168
168
|
avatar: payload.avatar || payload.picture || ""
|
|
@@ -932,7 +932,7 @@ var LoginForm = ({
|
|
|
932
932
|
|
|
933
933
|
// src/components/auth/HowoneProvider.tsx
|
|
934
934
|
init_auth();
|
|
935
|
-
import { createContext as createContext2, useContext as useContext2, useState as useState7, useEffect as useEffect6, useMemo } from "react";
|
|
935
|
+
import { createContext as createContext2, useContext as useContext2, useState as useState7, useEffect as useEffect6, useMemo, useCallback as useCallback4 } from "react";
|
|
936
936
|
|
|
937
937
|
// src/components/theme/ThemeProvider.tsx
|
|
938
938
|
import { createContext, useContext, useEffect as useEffect3, useState as useState3 } from "react";
|
|
@@ -1325,34 +1325,42 @@ var HowOneProvider = ({
|
|
|
1325
1325
|
injectRedirectOverlayStyles();
|
|
1326
1326
|
}
|
|
1327
1327
|
}, [pendingRedirect]);
|
|
1328
|
-
|
|
1329
|
-
if (!
|
|
1330
|
-
|
|
1331
|
-
}
|
|
1332
|
-
if (redirectOnUnauthenticated && !token && !user) {
|
|
1328
|
+
const redirectToAuth = useCallback4(() => {
|
|
1329
|
+
if (!redirectOnUnauthenticated || typeof window === "undefined") return;
|
|
1330
|
+
try {
|
|
1333
1331
|
const currentUrl = new URL(window.location.href);
|
|
1334
|
-
if (
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
authUrlObj.searchParams.set("project_id", projectId);
|
|
1341
|
-
}
|
|
1342
|
-
setPendingRedirect(true);
|
|
1343
|
-
requestAnimationFrame(() => {
|
|
1344
|
-
window.location.href = authUrlObj.toString();
|
|
1345
|
-
});
|
|
1346
|
-
} catch (error) {
|
|
1347
|
-
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
1348
|
-
setPendingRedirect(true);
|
|
1349
|
-
requestAnimationFrame(() => {
|
|
1350
|
-
window.location.href = resolvedAuthUrl;
|
|
1351
|
-
});
|
|
1332
|
+
if (currentUrl.pathname.includes("/auth")) return;
|
|
1333
|
+
try {
|
|
1334
|
+
const authUrlObj = new URL(resolvedAuthUrl);
|
|
1335
|
+
authUrlObj.searchParams.set("redirect_uri", window.location.href);
|
|
1336
|
+
if (projectId) {
|
|
1337
|
+
authUrlObj.searchParams.set("project_id", projectId);
|
|
1352
1338
|
}
|
|
1339
|
+
setPendingRedirect(true);
|
|
1340
|
+
requestAnimationFrame(() => {
|
|
1341
|
+
window.location.href = authUrlObj.toString();
|
|
1342
|
+
});
|
|
1343
|
+
return;
|
|
1344
|
+
} catch (error) {
|
|
1345
|
+
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
1353
1346
|
}
|
|
1347
|
+
setPendingRedirect(true);
|
|
1348
|
+
requestAnimationFrame(() => {
|
|
1349
|
+
window.location.href = resolvedAuthUrl;
|
|
1350
|
+
});
|
|
1351
|
+
} catch {
|
|
1352
|
+
setPendingRedirect(true);
|
|
1353
|
+
requestAnimationFrame(() => {
|
|
1354
|
+
window.location.href = resolvedAuthUrl;
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
}, [redirectOnUnauthenticated, resolvedAuthUrl, projectId]);
|
|
1358
|
+
useEffect6(() => {
|
|
1359
|
+
if (!hasCheckedUrlToken) return;
|
|
1360
|
+
if (!token && !user) {
|
|
1361
|
+
redirectToAuth();
|
|
1354
1362
|
}
|
|
1355
|
-
}, [token, user,
|
|
1363
|
+
}, [token, user, hasCheckedUrlToken, redirectToAuth]);
|
|
1356
1364
|
const logout = () => {
|
|
1357
1365
|
try {
|
|
1358
1366
|
setToken(null);
|
|
@@ -1360,6 +1368,7 @@ var HowOneProvider = ({
|
|
|
1360
1368
|
}
|
|
1361
1369
|
setTokenState(null);
|
|
1362
1370
|
setUser(null);
|
|
1371
|
+
redirectToAuth();
|
|
1363
1372
|
};
|
|
1364
1373
|
const value = {
|
|
1365
1374
|
user,
|
|
@@ -1678,7 +1687,7 @@ import React8 from "react";
|
|
|
1678
1687
|
import { Icon as Icon5 } from "@iconify/react";
|
|
1679
1688
|
|
|
1680
1689
|
// src/components/ui/Toast/ClayxToast.tsx
|
|
1681
|
-
import React7, { useCallback as
|
|
1690
|
+
import React7, { useCallback as useCallback5 } from "react";
|
|
1682
1691
|
import { Bounce, toast } from "react-toastify";
|
|
1683
1692
|
import { Icon as Icon4 } from "@iconify/react";
|
|
1684
1693
|
|
|
@@ -1828,7 +1837,7 @@ var TOAST_ICONS = {
|
|
|
1828
1837
|
};
|
|
1829
1838
|
var CloseButton = React7.memo(({ closeToast }) => {
|
|
1830
1839
|
const { theme } = useTheme();
|
|
1831
|
-
const handleClick =
|
|
1840
|
+
const handleClick = useCallback5((e) => {
|
|
1832
1841
|
e.preventDefault();
|
|
1833
1842
|
e.stopPropagation();
|
|
1834
1843
|
closeToast?.();
|
|
@@ -1865,7 +1874,7 @@ CloseButton.displayName = "CloseButton";
|
|
|
1865
1874
|
var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
1866
1875
|
const iconConfig = TOAST_ICONS[type];
|
|
1867
1876
|
const { theme } = useTheme();
|
|
1868
|
-
const handleClose =
|
|
1877
|
+
const handleClose = useCallback5(() => {
|
|
1869
1878
|
closeToast?.();
|
|
1870
1879
|
}, [closeToast]);
|
|
1871
1880
|
const getTextColor = () => {
|
|
@@ -2012,7 +2021,7 @@ var createToast = (type) => {
|
|
|
2012
2021
|
theme: getToastifyTheme(),
|
|
2013
2022
|
// 确保圆角样式不被覆盖,添加 rounded-xl 类
|
|
2014
2023
|
className: "!p-0 !shadow-none !rounded-xl",
|
|
2015
|
-
style: { padding: 0, borderRadius: "0.75rem" }
|
|
2024
|
+
style: { padding: 0, borderRadius: "0.75rem", backgroundColor: "transparent" }
|
|
2016
2025
|
}
|
|
2017
2026
|
);
|
|
2018
2027
|
};
|
|
@@ -3535,7 +3544,7 @@ function useDebounce(value, delay) {
|
|
|
3535
3544
|
}
|
|
3536
3545
|
|
|
3537
3546
|
// src/hooks/use-workflow-stream.ts
|
|
3538
|
-
import { useState as useState11, useCallback as
|
|
3547
|
+
import { useState as useState11, useCallback as useCallback6, useRef as useRef2 } from "react";
|
|
3539
3548
|
function useWorkflowStream() {
|
|
3540
3549
|
const [state, setState] = useState11({
|
|
3541
3550
|
loading: false,
|
|
@@ -3546,7 +3555,7 @@ function useWorkflowStream() {
|
|
|
3546
3555
|
error: null
|
|
3547
3556
|
});
|
|
3548
3557
|
const abortControllerRef = useRef2(null);
|
|
3549
|
-
const execute =
|
|
3558
|
+
const execute = useCallback6(async (executeWorkflowStream, workflowId, inputs) => {
|
|
3550
3559
|
setState({
|
|
3551
3560
|
loading: true,
|
|
3552
3561
|
progress: 0,
|
|
@@ -3599,7 +3608,7 @@ function useWorkflowStream() {
|
|
|
3599
3608
|
throw error;
|
|
3600
3609
|
}
|
|
3601
3610
|
}, []);
|
|
3602
|
-
const cancel =
|
|
3611
|
+
const cancel = useCallback6(() => {
|
|
3603
3612
|
if (abortControllerRef.current) {
|
|
3604
3613
|
abortControllerRef.current.abort();
|
|
3605
3614
|
setState((prev) => ({
|
|
@@ -3609,7 +3618,7 @@ function useWorkflowStream() {
|
|
|
3609
3618
|
}));
|
|
3610
3619
|
}
|
|
3611
3620
|
}, []);
|
|
3612
|
-
const reset =
|
|
3621
|
+
const reset = useCallback6(() => {
|
|
3613
3622
|
setState({
|
|
3614
3623
|
loading: false,
|
|
3615
3624
|
progress: 0,
|