@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/dist/react.d.cts CHANGED
@@ -1,87 +1,109 @@
1
- import { TapKitInstance, TapKitInitParams, TapKitConfig, TapButtonAttributes } from '@coxwave/tap-kit-types';
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
- * ๐ŸŒŸ TapKit์„ React์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ํ•ต์‹ฌ Hook
4
+ * useTapKit Hook - Advanced imperative control of TapKit Web Component
15
5
  *
16
- * useSyncExternalStore๋ฅผ ํ™œ์šฉํ•˜์—ฌ TapKit ์ธ์Šคํ„ด์Šค๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
17
- * ๊ฐ™์€ apiKey๋กœ ์—ฌ๋Ÿฌ ์ปดํฌ๋„ŒํŠธ์—์„œ ํ˜ธ์ถœํ•ด๋„ ๋™์ผํ•œ ์ธ์Šคํ„ด์Šค๋ฅผ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.
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
- * **Note for Next.js App Router users:**
20
- * Make sure to add 'use client' at the top of your component file when using this hook.
12
+ * For most use cases, prefer the `<TapKit />` component which provides a
13
+ * simpler declarative API.
21
14
  *
22
- * @param config - TapKit ์„ค์ • (apiKey ๋“ฑ)
23
- * @returns TapKit ์ธ์Šคํ„ด์Šค, ๋กœ๋”ฉ ์ƒํƒœ, ์—๋Ÿฌ ์ •๋ณด, ์„ค์ • ํ•จ์ˆ˜
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'; // Add this for Next.js App Router
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 { kit, isReady, error, setup } = useTapKit({
34
- * apiKey: 'your-api-key',
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 (isReady) {
39
- * setup({
40
- * buttonId: 'tap-button',
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
- * }, [isReady, setup]);
38
+ * }, [element]);
49
39
  *
50
- * if (error) {
51
- * return <div>์—๋Ÿฌ ๋ฐœ์ƒ: {error.message}</div>;
52
- * }
53
- *
54
- * if (!isReady) {
55
- * return <div>TapKit ๋กœ๋”ฉ ์ค‘...</div>;
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 React Integration
100
+ * Hook for managing TapKit Web Component
66
101
  *
67
- * React ์•ฑ์—์„œ TapKit์„ ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Hook์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
102
+ * Automatically loads CDN, creates Web Component, and provides control methods.
68
103
  *
69
- * useTapKit์€ useSyncExternalStore๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์ „์—ญ store๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
70
- * ๊ฐ™์€ apiKey๋กœ ์—ฌ๋Ÿฌ ์ปดํฌ๋„ŒํŠธ์—์„œ ํ˜ธ์ถœํ•˜๋ฉด ์ž๋™์œผ๋กœ ๊ฐ™์€ ์ธ์Šคํ„ด์Šค๋ฅผ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.
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
- declare global {
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 { TapKitInstance, TapKitInitParams, TapKitConfig, TapButtonAttributes } from '@coxwave/tap-kit-types';
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
- * ๐ŸŒŸ TapKit์„ React์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ํ•ต์‹ฌ Hook
4
+ * useTapKit Hook - Advanced imperative control of TapKit Web Component
15
5
  *
16
- * useSyncExternalStore๋ฅผ ํ™œ์šฉํ•˜์—ฌ TapKit ์ธ์Šคํ„ด์Šค๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
17
- * ๊ฐ™์€ apiKey๋กœ ์—ฌ๋Ÿฌ ์ปดํฌ๋„ŒํŠธ์—์„œ ํ˜ธ์ถœํ•ด๋„ ๋™์ผํ•œ ์ธ์Šคํ„ด์Šค๋ฅผ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.
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
- * **Note for Next.js App Router users:**
20
- * Make sure to add 'use client' at the top of your component file when using this hook.
12
+ * For most use cases, prefer the `<TapKit />` component which provides a
13
+ * simpler declarative API.
21
14
  *
22
- * @param config - TapKit ์„ค์ • (apiKey ๋“ฑ)
23
- * @returns TapKit ์ธ์Šคํ„ด์Šค, ๋กœ๋”ฉ ์ƒํƒœ, ์—๋Ÿฌ ์ •๋ณด, ์„ค์ • ํ•จ์ˆ˜
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'; // Add this for Next.js App Router
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 { kit, isReady, error, setup } = useTapKit({
34
- * apiKey: 'your-api-key',
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 (isReady) {
39
- * setup({
40
- * buttonId: 'tap-button',
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
- * }, [isReady, setup]);
38
+ * }, [element]);
49
39
  *
50
- * if (error) {
51
- * return <div>์—๋Ÿฌ ๋ฐœ์ƒ: {error.message}</div>;
52
- * }
53
- *
54
- * if (!isReady) {
55
- * return <div>TapKit ๋กœ๋”ฉ ์ค‘...</div>;
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 React Integration
100
+ * Hook for managing TapKit Web Component
66
101
  *
67
- * React ์•ฑ์—์„œ TapKit์„ ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Hook์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
102
+ * Automatically loads CDN, creates Web Component, and provides control methods.
68
103
  *
69
- * useTapKit์€ useSyncExternalStore๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์ „์—ญ store๋ฅผ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
70
- * ๊ฐ™์€ apiKey๋กœ ์—ฌ๋Ÿฌ ์ปดํฌ๋„ŒํŠธ์—์„œ ํ˜ธ์ถœํ•˜๋ฉด ์ž๋™์œผ๋กœ ๊ฐ™์€ ์ธ์Šคํ„ด์Šค๋ฅผ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.
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
- declare global {
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 };