@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.d.mts
CHANGED
|
@@ -424,7 +424,7 @@ interface LoginFormProps {
|
|
|
424
424
|
declare const LoginForm: React$1.FC<LoginFormProps>;
|
|
425
425
|
|
|
426
426
|
type Theme$1 = "dark" | "light" | "system";
|
|
427
|
-
type
|
|
427
|
+
type HowoneContextValue = {
|
|
428
428
|
user: ReturnType<typeof parseUserFromToken> | null;
|
|
429
429
|
token: string | null;
|
|
430
430
|
isAuthenticated: boolean;
|
|
@@ -435,10 +435,8 @@ interface HowoneProviderProps {
|
|
|
435
435
|
autoRedirect?: boolean;
|
|
436
436
|
showFloatingButton?: boolean;
|
|
437
437
|
projectId?: string;
|
|
438
|
-
/** 主题相关配置 */
|
|
439
438
|
defaultTheme?: Theme$1;
|
|
440
439
|
themeStorageKey?: string;
|
|
441
|
-
/** 如果为 true,将忽略 localStorage 中的值,始终使用 defaultTheme */
|
|
442
440
|
forceDefaultTheme?: boolean;
|
|
443
441
|
}
|
|
444
442
|
/**
|
|
@@ -462,9 +460,7 @@ interface HowoneProviderProps {
|
|
|
462
460
|
* ```
|
|
463
461
|
*/
|
|
464
462
|
declare const HowoneProvider: React$1.FC<HowoneProviderProps>;
|
|
465
|
-
declare function
|
|
466
|
-
declare const AuthProvider: React$1.FC<HowoneProviderProps>;
|
|
467
|
-
type AuthProviderProps = HowoneProviderProps;
|
|
463
|
+
declare function useHowoneContext(): HowoneContextValue;
|
|
468
464
|
|
|
469
465
|
type AuthState = {
|
|
470
466
|
user: Record<string, unknown> | null;
|
|
@@ -573,4 +569,4 @@ declare function useDebounce<T>(value: T, delay: number): T;
|
|
|
573
569
|
*/
|
|
574
570
|
declare function injectEarlyErrorHandler(): void;
|
|
575
571
|
|
|
576
|
-
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery,
|
|
572
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxToast, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, GlobalToastContainer, HowoneProvider, type HowoneProviderProps, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, ThemeProvider, ThemeToggle, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, injectEarlyErrorHandler, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useHowoneContext, useIsMobile, useTheme, workflowRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -424,7 +424,7 @@ interface LoginFormProps {
|
|
|
424
424
|
declare const LoginForm: React$1.FC<LoginFormProps>;
|
|
425
425
|
|
|
426
426
|
type Theme$1 = "dark" | "light" | "system";
|
|
427
|
-
type
|
|
427
|
+
type HowoneContextValue = {
|
|
428
428
|
user: ReturnType<typeof parseUserFromToken> | null;
|
|
429
429
|
token: string | null;
|
|
430
430
|
isAuthenticated: boolean;
|
|
@@ -435,10 +435,8 @@ interface HowoneProviderProps {
|
|
|
435
435
|
autoRedirect?: boolean;
|
|
436
436
|
showFloatingButton?: boolean;
|
|
437
437
|
projectId?: string;
|
|
438
|
-
/** 主题相关配置 */
|
|
439
438
|
defaultTheme?: Theme$1;
|
|
440
439
|
themeStorageKey?: string;
|
|
441
|
-
/** 如果为 true,将忽略 localStorage 中的值,始终使用 defaultTheme */
|
|
442
440
|
forceDefaultTheme?: boolean;
|
|
443
441
|
}
|
|
444
442
|
/**
|
|
@@ -462,9 +460,7 @@ interface HowoneProviderProps {
|
|
|
462
460
|
* ```
|
|
463
461
|
*/
|
|
464
462
|
declare const HowoneProvider: React$1.FC<HowoneProviderProps>;
|
|
465
|
-
declare function
|
|
466
|
-
declare const AuthProvider: React$1.FC<HowoneProviderProps>;
|
|
467
|
-
type AuthProviderProps = HowoneProviderProps;
|
|
463
|
+
declare function useHowoneContext(): HowoneContextValue;
|
|
468
464
|
|
|
469
465
|
type AuthState = {
|
|
470
466
|
user: Record<string, unknown> | null;
|
|
@@ -573,4 +569,4 @@ declare function useDebounce<T>(value: T, delay: number): T;
|
|
|
573
569
|
*/
|
|
574
570
|
declare function injectEarlyErrorHandler(): void;
|
|
575
571
|
|
|
576
|
-
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery,
|
|
572
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxToast, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, GlobalToastContainer, HowoneProvider, type HowoneProviderProps, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, ThemeProvider, ThemeToggle, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, injectEarlyErrorHandler, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useHowoneContext, useIsMobile, useTheme, workflowRequest };
|
package/dist/index.js
CHANGED
|
@@ -235,7 +235,6 @@ var index_exports = {};
|
|
|
235
235
|
__export(index_exports, {
|
|
236
236
|
AUTH_ROOT: () => AUTH_ROOT,
|
|
237
237
|
AUTH_TOKEN_KEY: () => AUTH_TOKEN_KEY,
|
|
238
|
-
AuthProvider: () => AuthProvider,
|
|
239
238
|
ClayxToast: () => ClayxToast,
|
|
240
239
|
DefaultErrorFallback: () => DefaultErrorFallback,
|
|
241
240
|
ErrorBoundary: () => ErrorBoundary,
|
|
@@ -272,8 +271,8 @@ __export(index_exports, {
|
|
|
272
271
|
unifiedAuth: () => unifiedAuth,
|
|
273
272
|
unifiedOAuth: () => unifiedOAuth,
|
|
274
273
|
useAuth: () => useAuth,
|
|
275
|
-
useAuthContext: () => useAuthContext,
|
|
276
274
|
useDebounce: () => useDebounce,
|
|
275
|
+
useHowoneContext: () => useHowoneContext,
|
|
277
276
|
useIsMobile: () => useIsMobile,
|
|
278
277
|
useTheme: () => useTheme,
|
|
279
278
|
workflowRequest: () => workflowRequest
|
|
@@ -1558,7 +1557,7 @@ var LoginForm = ({
|
|
|
1558
1557
|
] });
|
|
1559
1558
|
};
|
|
1560
1559
|
|
|
1561
|
-
// src/components/auth/
|
|
1560
|
+
// src/components/auth/HowoneProvider.tsx
|
|
1562
1561
|
var import_react5 = require("react");
|
|
1563
1562
|
init_auth();
|
|
1564
1563
|
|
|
@@ -1628,9 +1627,9 @@ function GlobalToastContainer() {
|
|
|
1628
1627
|
);
|
|
1629
1628
|
}
|
|
1630
1629
|
|
|
1631
|
-
// src/components/auth/
|
|
1630
|
+
// src/components/auth/HowoneProvider.tsx
|
|
1632
1631
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1633
|
-
var
|
|
1632
|
+
var HowoneContext = (0, import_react5.createContext)(null);
|
|
1634
1633
|
var HowoneProvider = ({
|
|
1635
1634
|
children,
|
|
1636
1635
|
showFloatingButton = true,
|
|
@@ -1640,6 +1639,24 @@ var HowoneProvider = ({
|
|
|
1640
1639
|
}) => {
|
|
1641
1640
|
const [user, setUser] = (0, import_react5.useState)(() => parseUserFromToken(getToken()));
|
|
1642
1641
|
const [token, setTokenState] = (0, import_react5.useState)(() => getToken());
|
|
1642
|
+
(0, import_react5.useEffect)(() => {
|
|
1643
|
+
try {
|
|
1644
|
+
const params = new URLSearchParams(window.location.search);
|
|
1645
|
+
const urlToken = params.get("access_token") || params.get("token");
|
|
1646
|
+
if (urlToken) {
|
|
1647
|
+
setToken(urlToken);
|
|
1648
|
+
setTokenState(urlToken);
|
|
1649
|
+
setUser(parseUserFromToken(urlToken));
|
|
1650
|
+
params.delete("access_token");
|
|
1651
|
+
params.delete("token");
|
|
1652
|
+
const newSearch = params.toString();
|
|
1653
|
+
const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "") + window.location.hash;
|
|
1654
|
+
window.history.replaceState({}, "", newUrl);
|
|
1655
|
+
}
|
|
1656
|
+
} catch (e) {
|
|
1657
|
+
console.error("[HowoneProvider] Failed to capture token from URL:", e);
|
|
1658
|
+
}
|
|
1659
|
+
}, []);
|
|
1643
1660
|
const logout = () => {
|
|
1644
1661
|
try {
|
|
1645
1662
|
setToken(null);
|
|
@@ -1661,7 +1678,7 @@ var HowoneProvider = ({
|
|
|
1661
1678
|
storageKey: themeStorageKey,
|
|
1662
1679
|
forceDefault: forceDefaultTheme,
|
|
1663
1680
|
children: [
|
|
1664
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1681
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(HowoneContext.Provider, { value, children: [
|
|
1665
1682
|
children,
|
|
1666
1683
|
showFloatingButton && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
|
|
1667
1684
|
] }),
|
|
@@ -1670,8 +1687,8 @@ var HowoneProvider = ({
|
|
|
1670
1687
|
}
|
|
1671
1688
|
);
|
|
1672
1689
|
};
|
|
1673
|
-
function
|
|
1674
|
-
const ctx = (0, import_react5.useContext)(
|
|
1690
|
+
function useHowoneContext() {
|
|
1691
|
+
const ctx = (0, import_react5.useContext)(HowoneContext);
|
|
1675
1692
|
if (!ctx) {
|
|
1676
1693
|
const t = getToken();
|
|
1677
1694
|
return {
|
|
@@ -1688,7 +1705,6 @@ function useAuthContext() {
|
|
|
1688
1705
|
}
|
|
1689
1706
|
return ctx;
|
|
1690
1707
|
}
|
|
1691
|
-
var AuthProvider = HowoneProvider;
|
|
1692
1708
|
|
|
1693
1709
|
// src/components/index.ts
|
|
1694
1710
|
init_auth();
|
|
@@ -2031,15 +2047,31 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
|
2031
2047
|
}
|
|
2032
2048
|
) }) }),
|
|
2033
2049
|
/* @__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)(
|
|
2035
|
-
|
|
2050
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2051
|
+
"div",
|
|
2052
|
+
{
|
|
2053
|
+
className: "font-semibold leading-tight text-white/95 drop-shadow-sm",
|
|
2054
|
+
style: { fontSize: "16px" },
|
|
2055
|
+
children: title
|
|
2056
|
+
}
|
|
2057
|
+
),
|
|
2058
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2059
|
+
"div",
|
|
2060
|
+
{
|
|
2061
|
+
className: "text-white/75 drop-shadow-sm",
|
|
2062
|
+
style: {
|
|
2063
|
+
fontSize: "13px"
|
|
2064
|
+
},
|
|
2065
|
+
children: message
|
|
2066
|
+
}
|
|
2067
|
+
)
|
|
2036
2068
|
] }),
|
|
2037
2069
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "relative z-10", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { closeToast: handleClose }) })
|
|
2038
2070
|
] });
|
|
2039
2071
|
};
|
|
2040
2072
|
var defaultToastOptions = {
|
|
2041
2073
|
position: "bottom-right",
|
|
2042
|
-
autoClose:
|
|
2074
|
+
autoClose: 3e5,
|
|
2043
2075
|
hideProgressBar: true,
|
|
2044
2076
|
closeOnClick: false,
|
|
2045
2077
|
pauseOnHover: true,
|
|
@@ -2450,7 +2482,6 @@ init_config();
|
|
|
2450
2482
|
0 && (module.exports = {
|
|
2451
2483
|
AUTH_ROOT,
|
|
2452
2484
|
AUTH_TOKEN_KEY,
|
|
2453
|
-
AuthProvider,
|
|
2454
2485
|
ClayxToast,
|
|
2455
2486
|
DefaultErrorFallback,
|
|
2456
2487
|
ErrorBoundary,
|
|
@@ -2487,8 +2518,8 @@ init_config();
|
|
|
2487
2518
|
unifiedAuth,
|
|
2488
2519
|
unifiedOAuth,
|
|
2489
2520
|
useAuth,
|
|
2490
|
-
useAuthContext,
|
|
2491
2521
|
useDebounce,
|
|
2522
|
+
useHowoneContext,
|
|
2492
2523
|
useIsMobile,
|
|
2493
2524
|
useTheme,
|
|
2494
2525
|
workflowRequest
|