@coxwave/tap-kit 2.0.0 → 2.0.2
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/README.md +174 -72
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.cts +193 -39
- package/dist/react.d.ts +193 -39
- package/dist/react.js +373 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +366 -2
- package/dist/react.mjs.map +1 -1
- package/package.json +2 -2
package/dist/react.d.cts
CHANGED
|
@@ -1,57 +1,201 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TapKitElement } from '@coxwave/tap-kit-types';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* React-specific type definitions for TapKit
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
7
|
+
* Defines event handler types and control patterns for React integration.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Event handler type definitions for TapKit Web Component
|
|
12
|
+
*
|
|
13
|
+
* Maps CustomEvent types to React callback signatures.
|
|
14
|
+
*/
|
|
15
|
+
interface TapKitEventHandlers {
|
|
16
|
+
/**
|
|
17
|
+
* Called when TapKit SDK is ready
|
|
18
|
+
* @example onReady={() => console.log('TapKit ready!')}
|
|
19
|
+
*/
|
|
20
|
+
onReady?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Called when initialization or runtime error occurs
|
|
23
|
+
* @example onError={(error) => console.error('TapKit error:', error)}
|
|
24
|
+
*/
|
|
25
|
+
onError?: (error: Error) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Called when timeline seek event occurs
|
|
28
|
+
* @example onTimelineSeek={(clipPlayHead, clipId) => console.log('Seek:', clipPlayHead)}
|
|
29
|
+
*/
|
|
30
|
+
onTimelineSeek?: (clipPlayHead: number, clipId: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Called when alarm fade-in occurs
|
|
33
|
+
* @example onAlarmFadeIn={(messageInfo) => console.log('Alarm:', messageInfo)}
|
|
34
|
+
*/
|
|
35
|
+
onAlarmFadeIn?: (messageInfo: unknown) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Control object pattern for managing TapKit instance
|
|
11
39
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
40
|
+
* Separates instance management (setInstance) from configuration (options)
|
|
41
|
+
* and event handling (handlers). Inspired by ChatKit's control pattern.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const tapkit = useTapKit({ apiKey: 'key', onReady: () => {} });
|
|
46
|
+
* <TapKit control={tapkit.control} />
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
interface TapKitControl<T> {
|
|
50
|
+
/**
|
|
51
|
+
* Set the TapKit element instance reference
|
|
52
|
+
*
|
|
53
|
+
* Called by TapKit component to register the element instance.
|
|
54
|
+
* Enables imperative control via useTapKit methods.
|
|
55
|
+
*/
|
|
56
|
+
setInstance: (instance: TapKitElement | null) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Configuration options (non-function values)
|
|
59
|
+
*
|
|
60
|
+
* All options except event handlers.
|
|
61
|
+
*/
|
|
62
|
+
options: T;
|
|
63
|
+
/**
|
|
64
|
+
* Event handler callbacks (function values)
|
|
65
|
+
*
|
|
66
|
+
* Separated from options for easier event listener management.
|
|
67
|
+
*/
|
|
68
|
+
handlers: TapKitEventHandlers;
|
|
69
|
+
/**
|
|
70
|
+
* Whether CDN is loaded and Web Component is available
|
|
71
|
+
*
|
|
72
|
+
* @internal Used by TapKit component to delay rendering
|
|
73
|
+
*/
|
|
74
|
+
isCdnLoaded: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* TapKit React Component
|
|
14
79
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
80
|
+
* Declarative React wrapper for <tap-kit> Web Component.
|
|
81
|
+
* Use this with useTapKit hook for a clean separation of control and rendering.
|
|
17
82
|
*
|
|
18
|
-
* @example
|
|
83
|
+
* @example
|
|
19
84
|
* ```tsx
|
|
20
85
|
* 'use client';
|
|
21
86
|
*
|
|
22
|
-
* import { useTapKit } from '@coxwave/tap-kit/react';
|
|
87
|
+
* import { TapKit, useTapKit } from '@coxwave/tap-kit/react';
|
|
23
88
|
*
|
|
24
|
-
* function
|
|
25
|
-
* const
|
|
89
|
+
* function MyApp() {
|
|
90
|
+
* const tapkit = useTapKit({
|
|
26
91
|
* apiKey: 'your-key',
|
|
27
92
|
* userId: 'user-123',
|
|
28
93
|
* courseId: 'course-456',
|
|
29
94
|
* clipId: 'clip-789',
|
|
95
|
+
* onReady: () => console.log('TapKit ready!'),
|
|
96
|
+
* onError: (error) => console.error('Error:', error),
|
|
30
97
|
* });
|
|
31
98
|
*
|
|
32
|
-
* // Direct element access for advanced operations
|
|
33
|
-
* useEffect(() => {
|
|
34
|
-
* if (element) {
|
|
35
|
-
* // Direct manipulation of TapKitElement
|
|
36
|
-
* console.log('Element mounted:', element);
|
|
37
|
-
* }
|
|
38
|
-
* }, [element]);
|
|
39
|
-
*
|
|
40
99
|
* return (
|
|
41
100
|
* <div>
|
|
42
|
-
* <button onClick={show} disabled={!isReady}>
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* <
|
|
101
|
+
* <button onClick={tapkit.show} disabled={!tapkit.isReady}>
|
|
102
|
+
* Show Chat
|
|
103
|
+
* </button>
|
|
104
|
+
* <TapKit control={tapkit.control} style={{ height: '600px' }} />
|
|
46
105
|
* </div>
|
|
47
106
|
* );
|
|
48
107
|
* }
|
|
49
108
|
* ```
|
|
50
109
|
*
|
|
51
|
-
*
|
|
110
|
+
* **Note for Next.js App Router users:**
|
|
111
|
+
* Make sure to add 'use client' at the top of your component file.
|
|
112
|
+
*
|
|
113
|
+
* @see https://edutap-ai-docs.vercel.app/docs/guides/react
|
|
52
114
|
*/
|
|
53
115
|
|
|
54
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Props for TapKit React component
|
|
118
|
+
*/
|
|
119
|
+
interface TapKitProps extends Omit<React.HTMLAttributes<TapKitElement>, "children" | "dangerouslySetInnerHTML"> {
|
|
120
|
+
/**
|
|
121
|
+
* Control object from useTapKit hook
|
|
122
|
+
*
|
|
123
|
+
* Provides instance management, configuration, and event handlers.
|
|
124
|
+
*/
|
|
125
|
+
control: TapKitControl<any>;
|
|
126
|
+
}
|
|
127
|
+
declare global {
|
|
128
|
+
namespace JSX {
|
|
129
|
+
interface IntrinsicElements {
|
|
130
|
+
"tap-kit": React.DetailedHTMLProps<React.HTMLAttributes<TapKitElement>, TapKitElement> & {
|
|
131
|
+
"api-key"?: string;
|
|
132
|
+
"user-id"?: string;
|
|
133
|
+
"course-id"?: string;
|
|
134
|
+
"clip-id"?: string;
|
|
135
|
+
"clip-play-head"?: number;
|
|
136
|
+
language?: "ko" | "en";
|
|
137
|
+
"button-id"?: string;
|
|
138
|
+
mode?: "inline" | "floating" | "sidebar";
|
|
139
|
+
debug?: boolean;
|
|
140
|
+
"tap-url"?: string;
|
|
141
|
+
"api-url"?: string;
|
|
142
|
+
environment?: "dev" | "prod" | "staging" | "demo";
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* TapKit React Component
|
|
149
|
+
*
|
|
150
|
+
* Renders <tap-kit> Web Component with React integration.
|
|
151
|
+
* Automatically manages instance lifecycle and event listeners.
|
|
152
|
+
*
|
|
153
|
+
* **Ref Access**: The forwarded ref provides direct access to the TapKitElement:
|
|
154
|
+
* ```tsx
|
|
155
|
+
* const tapkitRef = useRef<TapKitElement>(null);
|
|
156
|
+
* <TapKit ref={tapkitRef} control={...} />
|
|
157
|
+
* // tapkitRef.current?.show()
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
declare const TapKit: React.ForwardRefExoticComponent<TapKitProps & React.RefAttributes<TapKitElement>>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* useTapKit Hook - ChatKit-style control for TapKit Web Component
|
|
164
|
+
*
|
|
165
|
+
* This hook provides a control object to manage TapKit through the
|
|
166
|
+
* <TapKit /> component. Inspired by OpenAI's ChatKit pattern.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* 'use client';
|
|
171
|
+
*
|
|
172
|
+
* import { TapKit, useTapKit } from '@coxwave/tap-kit/react';
|
|
173
|
+
*
|
|
174
|
+
* function MyApp() {
|
|
175
|
+
* const tapkit = useTapKit({
|
|
176
|
+
* apiKey: 'your-key',
|
|
177
|
+
* userId: 'user-123',
|
|
178
|
+
* courseId: 'course-456',
|
|
179
|
+
* clipId: 'clip-789',
|
|
180
|
+
* onReady: () => console.log('Ready!'),
|
|
181
|
+
* onError: (error) => console.error(error),
|
|
182
|
+
* });
|
|
183
|
+
*
|
|
184
|
+
* return (
|
|
185
|
+
* <div>
|
|
186
|
+
* <button onClick={tapkit.show} disabled={!tapkit.isReady}>
|
|
187
|
+
* Ask AI Tutor
|
|
188
|
+
* </button>
|
|
189
|
+
* <TapKit control={tapkit.control} />
|
|
190
|
+
* </div>
|
|
191
|
+
* );
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
interface UseTapKitOptions extends TapKitEventHandlers {
|
|
197
|
+
/** API Key (required) */
|
|
198
|
+
apiKey: string;
|
|
55
199
|
/** User ID */
|
|
56
200
|
userId?: string;
|
|
57
201
|
/** Course ID */
|
|
@@ -75,11 +219,13 @@ interface UseTapKitOptions extends TapKitConfig {
|
|
|
75
219
|
/** Environment */
|
|
76
220
|
environment?: "dev" | "prod" | "staging" | "demo";
|
|
77
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Configuration options type (non-function values)
|
|
224
|
+
*/
|
|
225
|
+
type TapKitOptions = Omit<UseTapKitOptions, keyof TapKitEventHandlers>;
|
|
78
226
|
interface UseTapKitReturn {
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
/** Container ref to attach element */
|
|
82
|
-
elementRef: React.RefCallback<HTMLDivElement>;
|
|
227
|
+
/** Control object for <TapKit /> component */
|
|
228
|
+
control: TapKitControl<TapKitOptions>;
|
|
83
229
|
/** Whether TapKit is ready */
|
|
84
230
|
isReady: boolean;
|
|
85
231
|
/** Error during initialization */
|
|
@@ -95,15 +241,23 @@ interface UseTapKitReturn {
|
|
|
95
241
|
userId?: string;
|
|
96
242
|
clipPlayHead?: number;
|
|
97
243
|
}) => void;
|
|
244
|
+
/** Video adapter control */
|
|
245
|
+
video: {
|
|
246
|
+
/** Bind video player for timeline synchronization */
|
|
247
|
+
bind: (adapter: {
|
|
248
|
+
getCurrentTime: () => number;
|
|
249
|
+
setCurrentTime: (time: number) => void;
|
|
250
|
+
}, clipId: string) => void;
|
|
251
|
+
/** Unbind current video player */
|
|
252
|
+
unbind: () => void;
|
|
253
|
+
};
|
|
98
254
|
}
|
|
99
255
|
/**
|
|
100
|
-
* Hook for managing TapKit Web Component
|
|
101
|
-
*
|
|
102
|
-
* Automatically loads CDN, creates Web Component, and provides control methods.
|
|
256
|
+
* Hook for managing TapKit Web Component (ChatKit Pattern)
|
|
103
257
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
258
|
+
* Returns a control object to pass to <TapKit /> component.
|
|
259
|
+
* The component handles rendering, this hook handles state and methods.
|
|
106
260
|
*/
|
|
107
261
|
declare function useTapKit(options: UseTapKitOptions): UseTapKitReturn;
|
|
108
262
|
|
|
109
|
-
export { type UseTapKitOptions, type UseTapKitReturn, useTapKit };
|
|
263
|
+
export { TapKit, type TapKitControl, type TapKitEventHandlers, type TapKitProps, type UseTapKitOptions, type UseTapKitReturn, useTapKit };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,57 +1,201 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TapKitElement } from '@coxwave/tap-kit-types';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* React-specific type definitions for TapKit
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
7
|
+
* Defines event handler types and control patterns for React integration.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Event handler type definitions for TapKit Web Component
|
|
12
|
+
*
|
|
13
|
+
* Maps CustomEvent types to React callback signatures.
|
|
14
|
+
*/
|
|
15
|
+
interface TapKitEventHandlers {
|
|
16
|
+
/**
|
|
17
|
+
* Called when TapKit SDK is ready
|
|
18
|
+
* @example onReady={() => console.log('TapKit ready!')}
|
|
19
|
+
*/
|
|
20
|
+
onReady?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Called when initialization or runtime error occurs
|
|
23
|
+
* @example onError={(error) => console.error('TapKit error:', error)}
|
|
24
|
+
*/
|
|
25
|
+
onError?: (error: Error) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Called when timeline seek event occurs
|
|
28
|
+
* @example onTimelineSeek={(clipPlayHead, clipId) => console.log('Seek:', clipPlayHead)}
|
|
29
|
+
*/
|
|
30
|
+
onTimelineSeek?: (clipPlayHead: number, clipId: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Called when alarm fade-in occurs
|
|
33
|
+
* @example onAlarmFadeIn={(messageInfo) => console.log('Alarm:', messageInfo)}
|
|
34
|
+
*/
|
|
35
|
+
onAlarmFadeIn?: (messageInfo: unknown) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Control object pattern for managing TapKit instance
|
|
11
39
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
40
|
+
* Separates instance management (setInstance) from configuration (options)
|
|
41
|
+
* and event handling (handlers). Inspired by ChatKit's control pattern.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const tapkit = useTapKit({ apiKey: 'key', onReady: () => {} });
|
|
46
|
+
* <TapKit control={tapkit.control} />
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
interface TapKitControl<T> {
|
|
50
|
+
/**
|
|
51
|
+
* Set the TapKit element instance reference
|
|
52
|
+
*
|
|
53
|
+
* Called by TapKit component to register the element instance.
|
|
54
|
+
* Enables imperative control via useTapKit methods.
|
|
55
|
+
*/
|
|
56
|
+
setInstance: (instance: TapKitElement | null) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Configuration options (non-function values)
|
|
59
|
+
*
|
|
60
|
+
* All options except event handlers.
|
|
61
|
+
*/
|
|
62
|
+
options: T;
|
|
63
|
+
/**
|
|
64
|
+
* Event handler callbacks (function values)
|
|
65
|
+
*
|
|
66
|
+
* Separated from options for easier event listener management.
|
|
67
|
+
*/
|
|
68
|
+
handlers: TapKitEventHandlers;
|
|
69
|
+
/**
|
|
70
|
+
* Whether CDN is loaded and Web Component is available
|
|
71
|
+
*
|
|
72
|
+
* @internal Used by TapKit component to delay rendering
|
|
73
|
+
*/
|
|
74
|
+
isCdnLoaded: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* TapKit React Component
|
|
14
79
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
80
|
+
* Declarative React wrapper for <tap-kit> Web Component.
|
|
81
|
+
* Use this with useTapKit hook for a clean separation of control and rendering.
|
|
17
82
|
*
|
|
18
|
-
* @example
|
|
83
|
+
* @example
|
|
19
84
|
* ```tsx
|
|
20
85
|
* 'use client';
|
|
21
86
|
*
|
|
22
|
-
* import { useTapKit } from '@coxwave/tap-kit/react';
|
|
87
|
+
* import { TapKit, useTapKit } from '@coxwave/tap-kit/react';
|
|
23
88
|
*
|
|
24
|
-
* function
|
|
25
|
-
* const
|
|
89
|
+
* function MyApp() {
|
|
90
|
+
* const tapkit = useTapKit({
|
|
26
91
|
* apiKey: 'your-key',
|
|
27
92
|
* userId: 'user-123',
|
|
28
93
|
* courseId: 'course-456',
|
|
29
94
|
* clipId: 'clip-789',
|
|
95
|
+
* onReady: () => console.log('TapKit ready!'),
|
|
96
|
+
* onError: (error) => console.error('Error:', error),
|
|
30
97
|
* });
|
|
31
98
|
*
|
|
32
|
-
* // Direct element access for advanced operations
|
|
33
|
-
* useEffect(() => {
|
|
34
|
-
* if (element) {
|
|
35
|
-
* // Direct manipulation of TapKitElement
|
|
36
|
-
* console.log('Element mounted:', element);
|
|
37
|
-
* }
|
|
38
|
-
* }, [element]);
|
|
39
|
-
*
|
|
40
99
|
* return (
|
|
41
100
|
* <div>
|
|
42
|
-
* <button onClick={show} disabled={!isReady}>
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* <
|
|
101
|
+
* <button onClick={tapkit.show} disabled={!tapkit.isReady}>
|
|
102
|
+
* Show Chat
|
|
103
|
+
* </button>
|
|
104
|
+
* <TapKit control={tapkit.control} style={{ height: '600px' }} />
|
|
46
105
|
* </div>
|
|
47
106
|
* );
|
|
48
107
|
* }
|
|
49
108
|
* ```
|
|
50
109
|
*
|
|
51
|
-
*
|
|
110
|
+
* **Note for Next.js App Router users:**
|
|
111
|
+
* Make sure to add 'use client' at the top of your component file.
|
|
112
|
+
*
|
|
113
|
+
* @see https://edutap-ai-docs.vercel.app/docs/guides/react
|
|
52
114
|
*/
|
|
53
115
|
|
|
54
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Props for TapKit React component
|
|
118
|
+
*/
|
|
119
|
+
interface TapKitProps extends Omit<React.HTMLAttributes<TapKitElement>, "children" | "dangerouslySetInnerHTML"> {
|
|
120
|
+
/**
|
|
121
|
+
* Control object from useTapKit hook
|
|
122
|
+
*
|
|
123
|
+
* Provides instance management, configuration, and event handlers.
|
|
124
|
+
*/
|
|
125
|
+
control: TapKitControl<any>;
|
|
126
|
+
}
|
|
127
|
+
declare global {
|
|
128
|
+
namespace JSX {
|
|
129
|
+
interface IntrinsicElements {
|
|
130
|
+
"tap-kit": React.DetailedHTMLProps<React.HTMLAttributes<TapKitElement>, TapKitElement> & {
|
|
131
|
+
"api-key"?: string;
|
|
132
|
+
"user-id"?: string;
|
|
133
|
+
"course-id"?: string;
|
|
134
|
+
"clip-id"?: string;
|
|
135
|
+
"clip-play-head"?: number;
|
|
136
|
+
language?: "ko" | "en";
|
|
137
|
+
"button-id"?: string;
|
|
138
|
+
mode?: "inline" | "floating" | "sidebar";
|
|
139
|
+
debug?: boolean;
|
|
140
|
+
"tap-url"?: string;
|
|
141
|
+
"api-url"?: string;
|
|
142
|
+
environment?: "dev" | "prod" | "staging" | "demo";
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* TapKit React Component
|
|
149
|
+
*
|
|
150
|
+
* Renders <tap-kit> Web Component with React integration.
|
|
151
|
+
* Automatically manages instance lifecycle and event listeners.
|
|
152
|
+
*
|
|
153
|
+
* **Ref Access**: The forwarded ref provides direct access to the TapKitElement:
|
|
154
|
+
* ```tsx
|
|
155
|
+
* const tapkitRef = useRef<TapKitElement>(null);
|
|
156
|
+
* <TapKit ref={tapkitRef} control={...} />
|
|
157
|
+
* // tapkitRef.current?.show()
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
declare const TapKit: React.ForwardRefExoticComponent<TapKitProps & React.RefAttributes<TapKitElement>>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* useTapKit Hook - ChatKit-style control for TapKit Web Component
|
|
164
|
+
*
|
|
165
|
+
* This hook provides a control object to manage TapKit through the
|
|
166
|
+
* <TapKit /> component. Inspired by OpenAI's ChatKit pattern.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* 'use client';
|
|
171
|
+
*
|
|
172
|
+
* import { TapKit, useTapKit } from '@coxwave/tap-kit/react';
|
|
173
|
+
*
|
|
174
|
+
* function MyApp() {
|
|
175
|
+
* const tapkit = useTapKit({
|
|
176
|
+
* apiKey: 'your-key',
|
|
177
|
+
* userId: 'user-123',
|
|
178
|
+
* courseId: 'course-456',
|
|
179
|
+
* clipId: 'clip-789',
|
|
180
|
+
* onReady: () => console.log('Ready!'),
|
|
181
|
+
* onError: (error) => console.error(error),
|
|
182
|
+
* });
|
|
183
|
+
*
|
|
184
|
+
* return (
|
|
185
|
+
* <div>
|
|
186
|
+
* <button onClick={tapkit.show} disabled={!tapkit.isReady}>
|
|
187
|
+
* Ask AI Tutor
|
|
188
|
+
* </button>
|
|
189
|
+
* <TapKit control={tapkit.control} />
|
|
190
|
+
* </div>
|
|
191
|
+
* );
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
interface UseTapKitOptions extends TapKitEventHandlers {
|
|
197
|
+
/** API Key (required) */
|
|
198
|
+
apiKey: string;
|
|
55
199
|
/** User ID */
|
|
56
200
|
userId?: string;
|
|
57
201
|
/** Course ID */
|
|
@@ -75,11 +219,13 @@ interface UseTapKitOptions extends TapKitConfig {
|
|
|
75
219
|
/** Environment */
|
|
76
220
|
environment?: "dev" | "prod" | "staging" | "demo";
|
|
77
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Configuration options type (non-function values)
|
|
224
|
+
*/
|
|
225
|
+
type TapKitOptions = Omit<UseTapKitOptions, keyof TapKitEventHandlers>;
|
|
78
226
|
interface UseTapKitReturn {
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
/** Container ref to attach element */
|
|
82
|
-
elementRef: React.RefCallback<HTMLDivElement>;
|
|
227
|
+
/** Control object for <TapKit /> component */
|
|
228
|
+
control: TapKitControl<TapKitOptions>;
|
|
83
229
|
/** Whether TapKit is ready */
|
|
84
230
|
isReady: boolean;
|
|
85
231
|
/** Error during initialization */
|
|
@@ -95,15 +241,23 @@ interface UseTapKitReturn {
|
|
|
95
241
|
userId?: string;
|
|
96
242
|
clipPlayHead?: number;
|
|
97
243
|
}) => void;
|
|
244
|
+
/** Video adapter control */
|
|
245
|
+
video: {
|
|
246
|
+
/** Bind video player for timeline synchronization */
|
|
247
|
+
bind: (adapter: {
|
|
248
|
+
getCurrentTime: () => number;
|
|
249
|
+
setCurrentTime: (time: number) => void;
|
|
250
|
+
}, clipId: string) => void;
|
|
251
|
+
/** Unbind current video player */
|
|
252
|
+
unbind: () => void;
|
|
253
|
+
};
|
|
98
254
|
}
|
|
99
255
|
/**
|
|
100
|
-
* Hook for managing TapKit Web Component
|
|
101
|
-
*
|
|
102
|
-
* Automatically loads CDN, creates Web Component, and provides control methods.
|
|
256
|
+
* Hook for managing TapKit Web Component (ChatKit Pattern)
|
|
103
257
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
258
|
+
* Returns a control object to pass to <TapKit /> component.
|
|
259
|
+
* The component handles rendering, this hook handles state and methods.
|
|
106
260
|
*/
|
|
107
261
|
declare function useTapKit(options: UseTapKitOptions): UseTapKitReturn;
|
|
108
262
|
|
|
109
|
-
export { type UseTapKitOptions, type UseTapKitReturn, useTapKit };
|
|
263
|
+
export { TapKit, type TapKitControl, type TapKitEventHandlers, type TapKitProps, type UseTapKitOptions, type UseTapKitReturn, useTapKit };
|