@howone/sdk 0.1.18 → 0.1.20
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 +82 -20
- package/dist/index.d.ts +82 -20
- package/dist/index.js +657 -293
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +650 -292
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import React, { Component, ReactNode } from 'react';
|
|
1
|
+
import React$1, { Component, ReactNode } from 'react';
|
|
2
2
|
import * as axios from 'axios';
|
|
3
3
|
import { AxiosResponse, InternalAxiosRequestConfig, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { ToastOptions } from 'react-toastify';
|
|
5
6
|
|
|
6
7
|
interface FloatingButtonProps {
|
|
7
8
|
text?: string;
|
|
8
9
|
onClick?: () => void;
|
|
9
10
|
className?: string;
|
|
10
11
|
}
|
|
11
|
-
declare const FloatingButton: React.FC<FloatingButtonProps>;
|
|
12
|
+
declare const FloatingButton: React$1.FC<FloatingButtonProps>;
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* 统一认证服务
|
|
@@ -420,21 +421,50 @@ interface LoginFormProps {
|
|
|
420
421
|
appName?: string;
|
|
421
422
|
className?: string;
|
|
422
423
|
}
|
|
423
|
-
declare const LoginForm: React.FC<LoginFormProps>;
|
|
424
|
+
declare const LoginForm: React$1.FC<LoginFormProps>;
|
|
424
425
|
|
|
426
|
+
type Theme$1 = "dark" | "light" | "system";
|
|
425
427
|
type AuthContextValue = {
|
|
426
428
|
user: ReturnType<typeof parseUserFromToken> | null;
|
|
427
429
|
token: string | null;
|
|
428
430
|
isAuthenticated: boolean;
|
|
429
431
|
logout: () => void;
|
|
430
432
|
};
|
|
431
|
-
|
|
432
|
-
children: React.ReactNode;
|
|
433
|
+
interface HowoneProviderProps {
|
|
434
|
+
children: React$1.ReactNode;
|
|
433
435
|
autoRedirect?: boolean;
|
|
434
436
|
showFloatingButton?: boolean;
|
|
435
437
|
projectId?: string;
|
|
436
|
-
|
|
438
|
+
/** 主题相关配置 */
|
|
439
|
+
defaultTheme?: Theme$1;
|
|
440
|
+
themeStorageKey?: string;
|
|
441
|
+
/** 如果为 true,将忽略 localStorage 中的值,始终使用 defaultTheme */
|
|
442
|
+
forceDefaultTheme?: boolean;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* HowoneProvider - All-in-one application provider
|
|
446
|
+
*
|
|
447
|
+
* Includes:
|
|
448
|
+
* - Authentication management
|
|
449
|
+
* - Theme management (dark/light/system)
|
|
450
|
+
* - Toast notifications
|
|
451
|
+
* - Floating button
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```tsx
|
|
455
|
+
* <HowoneProvider
|
|
456
|
+
* defaultTheme="dark"
|
|
457
|
+
* themeStorageKey="my-app-theme"
|
|
458
|
+
* showFloatingButton={true}
|
|
459
|
+
* >
|
|
460
|
+
* <App />
|
|
461
|
+
* </HowoneProvider>
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
declare const HowoneProvider: React$1.FC<HowoneProviderProps>;
|
|
437
465
|
declare function useAuthContext(): AuthContextValue;
|
|
466
|
+
declare const AuthProvider: React$1.FC<HowoneProviderProps>;
|
|
467
|
+
type AuthProviderProps = HowoneProviderProps;
|
|
438
468
|
|
|
439
469
|
type AuthState = {
|
|
440
470
|
user: Record<string, unknown> | null;
|
|
@@ -465,50 +495,82 @@ interface LoadingProps {
|
|
|
465
495
|
className?: string;
|
|
466
496
|
fullScreen?: boolean;
|
|
467
497
|
}
|
|
468
|
-
declare const Loading: React.FC<LoadingProps>;
|
|
498
|
+
declare const Loading: React$1.FC<LoadingProps>;
|
|
469
499
|
interface LoadingSpinnerProps {
|
|
470
500
|
size?: 'sm' | 'md' | 'lg';
|
|
471
501
|
className?: string;
|
|
472
502
|
}
|
|
473
|
-
declare const LoadingSpinner: React.FC<LoadingSpinnerProps>;
|
|
503
|
+
declare const LoadingSpinner: React$1.FC<LoadingSpinnerProps>;
|
|
474
504
|
|
|
475
505
|
interface ErrorBoundaryState {
|
|
476
506
|
hasError: boolean;
|
|
477
507
|
error?: Error;
|
|
478
|
-
errorInfo?: React.ErrorInfo;
|
|
508
|
+
errorInfo?: React$1.ErrorInfo;
|
|
479
509
|
}
|
|
480
510
|
interface ErrorBoundaryProps {
|
|
481
511
|
children: ReactNode;
|
|
482
|
-
fallback?: React.ComponentType<{
|
|
512
|
+
fallback?: React$1.ComponentType<{
|
|
483
513
|
error?: Error;
|
|
484
514
|
retry?: () => void;
|
|
485
515
|
}>;
|
|
486
|
-
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
516
|
+
onError?: (error: Error, errorInfo: React$1.ErrorInfo) => void;
|
|
487
517
|
}
|
|
488
518
|
declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
489
519
|
constructor(props: ErrorBoundaryProps);
|
|
490
520
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
491
|
-
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
521
|
+
componentDidCatch(error: Error, errorInfo: React$1.ErrorInfo): void;
|
|
492
522
|
handleRetry: () => void;
|
|
493
|
-
render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
523
|
+
render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React$1.ReactNode> | null | undefined;
|
|
494
524
|
}
|
|
495
525
|
interface ErrorFallbackProps {
|
|
496
526
|
error?: Error;
|
|
497
527
|
retry?: () => void;
|
|
498
528
|
}
|
|
499
|
-
declare const DefaultErrorFallback: React.FC<ErrorFallbackProps>;
|
|
529
|
+
declare const DefaultErrorFallback: React$1.FC<ErrorFallbackProps>;
|
|
530
|
+
|
|
531
|
+
type Theme = "dark" | "light" | "system";
|
|
532
|
+
type ThemeProviderProps = {
|
|
533
|
+
children: React.ReactNode;
|
|
534
|
+
defaultTheme?: Theme;
|
|
535
|
+
storageKey?: string;
|
|
536
|
+
forceDefault?: boolean;
|
|
537
|
+
};
|
|
538
|
+
type ThemeProviderState = {
|
|
539
|
+
theme: Theme;
|
|
540
|
+
setTheme: (theme: Theme) => void;
|
|
541
|
+
};
|
|
542
|
+
declare function ThemeProvider({ children, defaultTheme, storageKey, forceDefault, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
543
|
+
declare const useTheme: () => ThemeProviderState;
|
|
544
|
+
|
|
545
|
+
interface ThemeToggleProps {
|
|
546
|
+
className?: string;
|
|
547
|
+
}
|
|
548
|
+
declare function ThemeToggle({ className }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
|
|
549
|
+
|
|
550
|
+
declare function GlobalToastContainer(): react_jsx_runtime.JSX.Element;
|
|
551
|
+
|
|
552
|
+
interface ToastParams {
|
|
553
|
+
title?: string;
|
|
554
|
+
message?: string;
|
|
555
|
+
component?: React$1.ReactNode;
|
|
556
|
+
options?: Partial<ToastOptions>;
|
|
557
|
+
}
|
|
558
|
+
declare const ClayxToast: {
|
|
559
|
+
success: (params: ToastParams) => void;
|
|
560
|
+
error: (params: ToastParams) => void;
|
|
561
|
+
warning: (params: ToastParams) => void;
|
|
562
|
+
info: (params: ToastParams) => void;
|
|
563
|
+
default: (params: ToastParams) => void;
|
|
564
|
+
};
|
|
500
565
|
|
|
501
566
|
declare function useIsMobile(): boolean;
|
|
502
567
|
|
|
503
568
|
declare function useDebounce<T>(value: T, delay: number): T;
|
|
504
569
|
|
|
505
570
|
/**
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* `error-handler.js` script into the page. The script is executed
|
|
509
|
-
* as soon as it's injected, providing early capture of runtime and
|
|
510
|
-
* Vite overlay errors for the host app.
|
|
571
|
+
* 在页面尽早注入错误处理脚本。
|
|
572
|
+
* 调用时机:应在应用入口尽早执行(例如在 root render 之前)。
|
|
511
573
|
*/
|
|
512
574
|
declare function injectEarlyErrorHandler(): void;
|
|
513
575
|
|
|
514
|
-
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthProvider, type AxiosAIWorkflowOptions, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, 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, useAuthContext, useDebounce, useIsMobile, workflowRequest };
|
|
576
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthProvider, type AuthProviderProps, 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, useAuthContext, useDebounce, useIsMobile, useTheme, workflowRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import React, { Component, ReactNode } from 'react';
|
|
1
|
+
import React$1, { Component, ReactNode } from 'react';
|
|
2
2
|
import * as axios from 'axios';
|
|
3
3
|
import { AxiosResponse, InternalAxiosRequestConfig, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { ToastOptions } from 'react-toastify';
|
|
5
6
|
|
|
6
7
|
interface FloatingButtonProps {
|
|
7
8
|
text?: string;
|
|
8
9
|
onClick?: () => void;
|
|
9
10
|
className?: string;
|
|
10
11
|
}
|
|
11
|
-
declare const FloatingButton: React.FC<FloatingButtonProps>;
|
|
12
|
+
declare const FloatingButton: React$1.FC<FloatingButtonProps>;
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* 统一认证服务
|
|
@@ -420,21 +421,50 @@ interface LoginFormProps {
|
|
|
420
421
|
appName?: string;
|
|
421
422
|
className?: string;
|
|
422
423
|
}
|
|
423
|
-
declare const LoginForm: React.FC<LoginFormProps>;
|
|
424
|
+
declare const LoginForm: React$1.FC<LoginFormProps>;
|
|
424
425
|
|
|
426
|
+
type Theme$1 = "dark" | "light" | "system";
|
|
425
427
|
type AuthContextValue = {
|
|
426
428
|
user: ReturnType<typeof parseUserFromToken> | null;
|
|
427
429
|
token: string | null;
|
|
428
430
|
isAuthenticated: boolean;
|
|
429
431
|
logout: () => void;
|
|
430
432
|
};
|
|
431
|
-
|
|
432
|
-
children: React.ReactNode;
|
|
433
|
+
interface HowoneProviderProps {
|
|
434
|
+
children: React$1.ReactNode;
|
|
433
435
|
autoRedirect?: boolean;
|
|
434
436
|
showFloatingButton?: boolean;
|
|
435
437
|
projectId?: string;
|
|
436
|
-
|
|
438
|
+
/** 主题相关配置 */
|
|
439
|
+
defaultTheme?: Theme$1;
|
|
440
|
+
themeStorageKey?: string;
|
|
441
|
+
/** 如果为 true,将忽略 localStorage 中的值,始终使用 defaultTheme */
|
|
442
|
+
forceDefaultTheme?: boolean;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* HowoneProvider - All-in-one application provider
|
|
446
|
+
*
|
|
447
|
+
* Includes:
|
|
448
|
+
* - Authentication management
|
|
449
|
+
* - Theme management (dark/light/system)
|
|
450
|
+
* - Toast notifications
|
|
451
|
+
* - Floating button
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```tsx
|
|
455
|
+
* <HowoneProvider
|
|
456
|
+
* defaultTheme="dark"
|
|
457
|
+
* themeStorageKey="my-app-theme"
|
|
458
|
+
* showFloatingButton={true}
|
|
459
|
+
* >
|
|
460
|
+
* <App />
|
|
461
|
+
* </HowoneProvider>
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
declare const HowoneProvider: React$1.FC<HowoneProviderProps>;
|
|
437
465
|
declare function useAuthContext(): AuthContextValue;
|
|
466
|
+
declare const AuthProvider: React$1.FC<HowoneProviderProps>;
|
|
467
|
+
type AuthProviderProps = HowoneProviderProps;
|
|
438
468
|
|
|
439
469
|
type AuthState = {
|
|
440
470
|
user: Record<string, unknown> | null;
|
|
@@ -465,50 +495,82 @@ interface LoadingProps {
|
|
|
465
495
|
className?: string;
|
|
466
496
|
fullScreen?: boolean;
|
|
467
497
|
}
|
|
468
|
-
declare const Loading: React.FC<LoadingProps>;
|
|
498
|
+
declare const Loading: React$1.FC<LoadingProps>;
|
|
469
499
|
interface LoadingSpinnerProps {
|
|
470
500
|
size?: 'sm' | 'md' | 'lg';
|
|
471
501
|
className?: string;
|
|
472
502
|
}
|
|
473
|
-
declare const LoadingSpinner: React.FC<LoadingSpinnerProps>;
|
|
503
|
+
declare const LoadingSpinner: React$1.FC<LoadingSpinnerProps>;
|
|
474
504
|
|
|
475
505
|
interface ErrorBoundaryState {
|
|
476
506
|
hasError: boolean;
|
|
477
507
|
error?: Error;
|
|
478
|
-
errorInfo?: React.ErrorInfo;
|
|
508
|
+
errorInfo?: React$1.ErrorInfo;
|
|
479
509
|
}
|
|
480
510
|
interface ErrorBoundaryProps {
|
|
481
511
|
children: ReactNode;
|
|
482
|
-
fallback?: React.ComponentType<{
|
|
512
|
+
fallback?: React$1.ComponentType<{
|
|
483
513
|
error?: Error;
|
|
484
514
|
retry?: () => void;
|
|
485
515
|
}>;
|
|
486
|
-
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
516
|
+
onError?: (error: Error, errorInfo: React$1.ErrorInfo) => void;
|
|
487
517
|
}
|
|
488
518
|
declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
489
519
|
constructor(props: ErrorBoundaryProps);
|
|
490
520
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
491
|
-
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
521
|
+
componentDidCatch(error: Error, errorInfo: React$1.ErrorInfo): void;
|
|
492
522
|
handleRetry: () => void;
|
|
493
|
-
render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
523
|
+
render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React$1.ReactNode> | null | undefined;
|
|
494
524
|
}
|
|
495
525
|
interface ErrorFallbackProps {
|
|
496
526
|
error?: Error;
|
|
497
527
|
retry?: () => void;
|
|
498
528
|
}
|
|
499
|
-
declare const DefaultErrorFallback: React.FC<ErrorFallbackProps>;
|
|
529
|
+
declare const DefaultErrorFallback: React$1.FC<ErrorFallbackProps>;
|
|
530
|
+
|
|
531
|
+
type Theme = "dark" | "light" | "system";
|
|
532
|
+
type ThemeProviderProps = {
|
|
533
|
+
children: React.ReactNode;
|
|
534
|
+
defaultTheme?: Theme;
|
|
535
|
+
storageKey?: string;
|
|
536
|
+
forceDefault?: boolean;
|
|
537
|
+
};
|
|
538
|
+
type ThemeProviderState = {
|
|
539
|
+
theme: Theme;
|
|
540
|
+
setTheme: (theme: Theme) => void;
|
|
541
|
+
};
|
|
542
|
+
declare function ThemeProvider({ children, defaultTheme, storageKey, forceDefault, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
543
|
+
declare const useTheme: () => ThemeProviderState;
|
|
544
|
+
|
|
545
|
+
interface ThemeToggleProps {
|
|
546
|
+
className?: string;
|
|
547
|
+
}
|
|
548
|
+
declare function ThemeToggle({ className }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
|
|
549
|
+
|
|
550
|
+
declare function GlobalToastContainer(): react_jsx_runtime.JSX.Element;
|
|
551
|
+
|
|
552
|
+
interface ToastParams {
|
|
553
|
+
title?: string;
|
|
554
|
+
message?: string;
|
|
555
|
+
component?: React$1.ReactNode;
|
|
556
|
+
options?: Partial<ToastOptions>;
|
|
557
|
+
}
|
|
558
|
+
declare const ClayxToast: {
|
|
559
|
+
success: (params: ToastParams) => void;
|
|
560
|
+
error: (params: ToastParams) => void;
|
|
561
|
+
warning: (params: ToastParams) => void;
|
|
562
|
+
info: (params: ToastParams) => void;
|
|
563
|
+
default: (params: ToastParams) => void;
|
|
564
|
+
};
|
|
500
565
|
|
|
501
566
|
declare function useIsMobile(): boolean;
|
|
502
567
|
|
|
503
568
|
declare function useDebounce<T>(value: T, delay: number): T;
|
|
504
569
|
|
|
505
570
|
/**
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* `error-handler.js` script into the page. The script is executed
|
|
509
|
-
* as soon as it's injected, providing early capture of runtime and
|
|
510
|
-
* Vite overlay errors for the host app.
|
|
571
|
+
* 在页面尽早注入错误处理脚本。
|
|
572
|
+
* 调用时机:应在应用入口尽早执行(例如在 root render 之前)。
|
|
511
573
|
*/
|
|
512
574
|
declare function injectEarlyErrorHandler(): void;
|
|
513
575
|
|
|
514
|
-
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthProvider, type AxiosAIWorkflowOptions, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, 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, useAuthContext, useDebounce, useIsMobile, workflowRequest };
|
|
576
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthProvider, type AuthProviderProps, 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, useAuthContext, useDebounce, useIsMobile, useTheme, workflowRequest };
|