@coxwave/tap-kit 1.0.6 โ 2.0.0
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 +5 -6
- package/dist/index.d.cts +36 -8
- package/dist/index.d.ts +36 -8
- 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 +84 -62
- package/dist/react.d.ts +84 -62
- package/dist/react.js +2 -382
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +2 -380
- package/dist/react.mjs.map +1 -1
- package/package.json +7 -6
package/dist/react.d.cts
CHANGED
|
@@ -1,87 +1,109 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TapKitConfig, TapKitElement } from '@coxwave/tap-kit-types';
|
|
2
2
|
|
|
3
|
-
interface UseTapKitReturn {
|
|
4
|
-
/** TapKit instance */
|
|
5
|
-
kit: TapKitInstance | null;
|
|
6
|
-
/** Whether TapKit is ready to use */
|
|
7
|
-
isReady: boolean;
|
|
8
|
-
/** Error that occurred during loading */
|
|
9
|
-
error: Error | null;
|
|
10
|
-
/** Setup TapKit with given parameters (button, course info, etc.) */
|
|
11
|
-
setup: (params: TapKitInitParams) => Promise<() => void>;
|
|
12
|
-
}
|
|
13
3
|
/**
|
|
14
|
-
*
|
|
4
|
+
* useTapKit Hook - Advanced imperative control of TapKit Web Component
|
|
15
5
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
6
|
+
* This hook provides direct access to the TapKitElement instance and full
|
|
7
|
+
* control over its lifecycle. Use this when you need:
|
|
8
|
+
* - Direct element manipulation
|
|
9
|
+
* - Custom rendering logic
|
|
10
|
+
* - Imperative control over Web Component behavior
|
|
18
11
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
12
|
+
* For most use cases, prefer the `<TapKit />` component which provides a
|
|
13
|
+
* simpler declarative API.
|
|
21
14
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @returns
|
|
15
|
+
* @param options - TapKit configuration
|
|
16
|
+
* @returns Object with element reference, state, and control methods
|
|
24
17
|
*
|
|
25
|
-
* @example
|
|
18
|
+
* @example Advanced control with custom rendering
|
|
26
19
|
* ```tsx
|
|
27
|
-
* 'use client';
|
|
20
|
+
* 'use client';
|
|
28
21
|
*
|
|
29
|
-
* import { useEffect } from 'react';
|
|
30
22
|
* import { useTapKit } from '@coxwave/tap-kit/react';
|
|
31
23
|
*
|
|
32
24
|
* function MyComponent() {
|
|
33
|
-
* const {
|
|
34
|
-
* apiKey: 'your-
|
|
25
|
+
* const { element, elementRef, show, hide, isReady, error } = useTapKit({
|
|
26
|
+
* apiKey: 'your-key',
|
|
27
|
+
* userId: 'user-123',
|
|
28
|
+
* courseId: 'course-456',
|
|
29
|
+
* clipId: 'clip-789',
|
|
35
30
|
* });
|
|
36
31
|
*
|
|
32
|
+
* // Direct element access for advanced operations
|
|
37
33
|
* useEffect(() => {
|
|
38
|
-
* if (
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* course: {
|
|
42
|
-
* userId: 'user-123',
|
|
43
|
-
* courseId: 'course-456',
|
|
44
|
-
* clipId: 'clip-789',
|
|
45
|
-
* },
|
|
46
|
-
* });
|
|
34
|
+
* if (element) {
|
|
35
|
+
* // Direct manipulation of TapKitElement
|
|
36
|
+
* console.log('Element mounted:', element);
|
|
47
37
|
* }
|
|
48
|
-
* }, [
|
|
38
|
+
* }, [element]);
|
|
49
39
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* return <div id="tap-button">AI ํํฐ</div>;
|
|
40
|
+
* return (
|
|
41
|
+
* <div>
|
|
42
|
+
* <button onClick={show} disabled={!isReady}>Show Chat</button>
|
|
43
|
+
* <button onClick={hide}>Hide Chat</button>
|
|
44
|
+
* {error && <p>Error: {error.message}</p>}
|
|
45
|
+
* <div ref={elementRef} /> // Container for Web Component
|
|
46
|
+
* </div>
|
|
47
|
+
* );
|
|
59
48
|
* }
|
|
60
49
|
* ```
|
|
50
|
+
*
|
|
51
|
+
* @see TapKit - Use this component for simpler declarative API
|
|
61
52
|
*/
|
|
62
|
-
declare function useTapKit(config: TapKitConfig): UseTapKitReturn;
|
|
63
53
|
|
|
54
|
+
interface UseTapKitOptions extends TapKitConfig {
|
|
55
|
+
/** User ID */
|
|
56
|
+
userId?: string;
|
|
57
|
+
/** Course ID */
|
|
58
|
+
courseId?: string;
|
|
59
|
+
/** Clip ID */
|
|
60
|
+
clipId?: string;
|
|
61
|
+
/** Clip playhead position */
|
|
62
|
+
clipPlayHead?: number;
|
|
63
|
+
/** Language */
|
|
64
|
+
language?: "ko" | "en";
|
|
65
|
+
/** Custom button element ID */
|
|
66
|
+
buttonId?: string;
|
|
67
|
+
/** Display mode */
|
|
68
|
+
mode?: "inline" | "floating" | "sidebar";
|
|
69
|
+
/** Debug mode */
|
|
70
|
+
debug?: boolean;
|
|
71
|
+
/** TAP Frontend URL */
|
|
72
|
+
tapUrl?: string;
|
|
73
|
+
/** API Backend URL */
|
|
74
|
+
apiUrl?: string;
|
|
75
|
+
/** Environment */
|
|
76
|
+
environment?: "dev" | "prod" | "staging" | "demo";
|
|
77
|
+
}
|
|
78
|
+
interface UseTapKitReturn {
|
|
79
|
+
/** Web Component element reference */
|
|
80
|
+
element: TapKitElement | null;
|
|
81
|
+
/** Container ref to attach element */
|
|
82
|
+
elementRef: React.RefCallback<HTMLDivElement>;
|
|
83
|
+
/** Whether TapKit is ready */
|
|
84
|
+
isReady: boolean;
|
|
85
|
+
/** Error during initialization */
|
|
86
|
+
error: Error | null;
|
|
87
|
+
/** Show chat interface */
|
|
88
|
+
show: () => void;
|
|
89
|
+
/** Hide chat interface */
|
|
90
|
+
hide: () => void;
|
|
91
|
+
/** Set course information */
|
|
92
|
+
setCourse: (course: {
|
|
93
|
+
courseId: string;
|
|
94
|
+
clipId: string;
|
|
95
|
+
userId?: string;
|
|
96
|
+
clipPlayHead?: number;
|
|
97
|
+
}) => void;
|
|
98
|
+
}
|
|
64
99
|
/**
|
|
65
|
-
* TapKit
|
|
100
|
+
* Hook for managing TapKit Web Component
|
|
66
101
|
*
|
|
67
|
-
*
|
|
102
|
+
* Automatically loads CDN, creates Web Component, and provides control methods.
|
|
68
103
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* **Note for Next.js App Router users:**
|
|
73
|
-
* If you're using this in a Next.js App Router project with Server Components,
|
|
74
|
-
* make sure to add 'use client' at the top of your component file that imports this hook.
|
|
75
|
-
*
|
|
76
|
-
* @see https://edutap-ai-docs.vercel.app/docs/guides/react
|
|
104
|
+
* @param options - TapKit configuration
|
|
105
|
+
* @returns Methods to control TapKit instance
|
|
77
106
|
*/
|
|
107
|
+
declare function useTapKit(options: UseTapKitOptions): UseTapKitReturn;
|
|
78
108
|
|
|
79
|
-
|
|
80
|
-
namespace JSX {
|
|
81
|
-
interface IntrinsicElements {
|
|
82
|
-
"tap-button": TapButtonAttributes;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { type UseTapKitReturn, useTapKit };
|
|
109
|
+
export { type UseTapKitOptions, type UseTapKitReturn, useTapKit };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,87 +1,109 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TapKitConfig, TapKitElement } from '@coxwave/tap-kit-types';
|
|
2
2
|
|
|
3
|
-
interface UseTapKitReturn {
|
|
4
|
-
/** TapKit instance */
|
|
5
|
-
kit: TapKitInstance | null;
|
|
6
|
-
/** Whether TapKit is ready to use */
|
|
7
|
-
isReady: boolean;
|
|
8
|
-
/** Error that occurred during loading */
|
|
9
|
-
error: Error | null;
|
|
10
|
-
/** Setup TapKit with given parameters (button, course info, etc.) */
|
|
11
|
-
setup: (params: TapKitInitParams) => Promise<() => void>;
|
|
12
|
-
}
|
|
13
3
|
/**
|
|
14
|
-
*
|
|
4
|
+
* useTapKit Hook - Advanced imperative control of TapKit Web Component
|
|
15
5
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
6
|
+
* This hook provides direct access to the TapKitElement instance and full
|
|
7
|
+
* control over its lifecycle. Use this when you need:
|
|
8
|
+
* - Direct element manipulation
|
|
9
|
+
* - Custom rendering logic
|
|
10
|
+
* - Imperative control over Web Component behavior
|
|
18
11
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
12
|
+
* For most use cases, prefer the `<TapKit />` component which provides a
|
|
13
|
+
* simpler declarative API.
|
|
21
14
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @returns
|
|
15
|
+
* @param options - TapKit configuration
|
|
16
|
+
* @returns Object with element reference, state, and control methods
|
|
24
17
|
*
|
|
25
|
-
* @example
|
|
18
|
+
* @example Advanced control with custom rendering
|
|
26
19
|
* ```tsx
|
|
27
|
-
* 'use client';
|
|
20
|
+
* 'use client';
|
|
28
21
|
*
|
|
29
|
-
* import { useEffect } from 'react';
|
|
30
22
|
* import { useTapKit } from '@coxwave/tap-kit/react';
|
|
31
23
|
*
|
|
32
24
|
* function MyComponent() {
|
|
33
|
-
* const {
|
|
34
|
-
* apiKey: 'your-
|
|
25
|
+
* const { element, elementRef, show, hide, isReady, error } = useTapKit({
|
|
26
|
+
* apiKey: 'your-key',
|
|
27
|
+
* userId: 'user-123',
|
|
28
|
+
* courseId: 'course-456',
|
|
29
|
+
* clipId: 'clip-789',
|
|
35
30
|
* });
|
|
36
31
|
*
|
|
32
|
+
* // Direct element access for advanced operations
|
|
37
33
|
* useEffect(() => {
|
|
38
|
-
* if (
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* course: {
|
|
42
|
-
* userId: 'user-123',
|
|
43
|
-
* courseId: 'course-456',
|
|
44
|
-
* clipId: 'clip-789',
|
|
45
|
-
* },
|
|
46
|
-
* });
|
|
34
|
+
* if (element) {
|
|
35
|
+
* // Direct manipulation of TapKitElement
|
|
36
|
+
* console.log('Element mounted:', element);
|
|
47
37
|
* }
|
|
48
|
-
* }, [
|
|
38
|
+
* }, [element]);
|
|
49
39
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* return <div id="tap-button">AI ํํฐ</div>;
|
|
40
|
+
* return (
|
|
41
|
+
* <div>
|
|
42
|
+
* <button onClick={show} disabled={!isReady}>Show Chat</button>
|
|
43
|
+
* <button onClick={hide}>Hide Chat</button>
|
|
44
|
+
* {error && <p>Error: {error.message}</p>}
|
|
45
|
+
* <div ref={elementRef} /> // Container for Web Component
|
|
46
|
+
* </div>
|
|
47
|
+
* );
|
|
59
48
|
* }
|
|
60
49
|
* ```
|
|
50
|
+
*
|
|
51
|
+
* @see TapKit - Use this component for simpler declarative API
|
|
61
52
|
*/
|
|
62
|
-
declare function useTapKit(config: TapKitConfig): UseTapKitReturn;
|
|
63
53
|
|
|
54
|
+
interface UseTapKitOptions extends TapKitConfig {
|
|
55
|
+
/** User ID */
|
|
56
|
+
userId?: string;
|
|
57
|
+
/** Course ID */
|
|
58
|
+
courseId?: string;
|
|
59
|
+
/** Clip ID */
|
|
60
|
+
clipId?: string;
|
|
61
|
+
/** Clip playhead position */
|
|
62
|
+
clipPlayHead?: number;
|
|
63
|
+
/** Language */
|
|
64
|
+
language?: "ko" | "en";
|
|
65
|
+
/** Custom button element ID */
|
|
66
|
+
buttonId?: string;
|
|
67
|
+
/** Display mode */
|
|
68
|
+
mode?: "inline" | "floating" | "sidebar";
|
|
69
|
+
/** Debug mode */
|
|
70
|
+
debug?: boolean;
|
|
71
|
+
/** TAP Frontend URL */
|
|
72
|
+
tapUrl?: string;
|
|
73
|
+
/** API Backend URL */
|
|
74
|
+
apiUrl?: string;
|
|
75
|
+
/** Environment */
|
|
76
|
+
environment?: "dev" | "prod" | "staging" | "demo";
|
|
77
|
+
}
|
|
78
|
+
interface UseTapKitReturn {
|
|
79
|
+
/** Web Component element reference */
|
|
80
|
+
element: TapKitElement | null;
|
|
81
|
+
/** Container ref to attach element */
|
|
82
|
+
elementRef: React.RefCallback<HTMLDivElement>;
|
|
83
|
+
/** Whether TapKit is ready */
|
|
84
|
+
isReady: boolean;
|
|
85
|
+
/** Error during initialization */
|
|
86
|
+
error: Error | null;
|
|
87
|
+
/** Show chat interface */
|
|
88
|
+
show: () => void;
|
|
89
|
+
/** Hide chat interface */
|
|
90
|
+
hide: () => void;
|
|
91
|
+
/** Set course information */
|
|
92
|
+
setCourse: (course: {
|
|
93
|
+
courseId: string;
|
|
94
|
+
clipId: string;
|
|
95
|
+
userId?: string;
|
|
96
|
+
clipPlayHead?: number;
|
|
97
|
+
}) => void;
|
|
98
|
+
}
|
|
64
99
|
/**
|
|
65
|
-
* TapKit
|
|
100
|
+
* Hook for managing TapKit Web Component
|
|
66
101
|
*
|
|
67
|
-
*
|
|
102
|
+
* Automatically loads CDN, creates Web Component, and provides control methods.
|
|
68
103
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* **Note for Next.js App Router users:**
|
|
73
|
-
* If you're using this in a Next.js App Router project with Server Components,
|
|
74
|
-
* make sure to add 'use client' at the top of your component file that imports this hook.
|
|
75
|
-
*
|
|
76
|
-
* @see https://edutap-ai-docs.vercel.app/docs/guides/react
|
|
104
|
+
* @param options - TapKit configuration
|
|
105
|
+
* @returns Methods to control TapKit instance
|
|
77
106
|
*/
|
|
107
|
+
declare function useTapKit(options: UseTapKitOptions): UseTapKitReturn;
|
|
78
108
|
|
|
79
|
-
|
|
80
|
-
namespace JSX {
|
|
81
|
-
interface IntrinsicElements {
|
|
82
|
-
"tap-button": TapButtonAttributes;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { type UseTapKitReturn, useTapKit };
|
|
109
|
+
export { type UseTapKitOptions, type UseTapKitReturn, useTapKit };
|