@coxwave/tap-kit-types 2.0.4 → 2.0.7

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.ts CHANGED
@@ -2,10 +2,10 @@ import * as CSS from 'csstype';
2
2
  import { ReactNode, CSSProperties } from 'react';
3
3
 
4
4
  /**
5
- * Alarm display duration (18 seconds total)
6
- * 말풍선 발생 후, 12뒤에 서서히 사라짐 (전체 시간 18초)
5
+ * Alarm display duration (16 seconds total)
6
+ * 12초 유지 + 4fade out = 16초 total
7
7
  */
8
- declare const ALARM_DURATION = 18000;
8
+ declare const ALARM_DURATION = 16000;
9
9
  /**
10
10
  * Base style type for all elements
11
11
  * Uses csstype for accurate CSS property types
@@ -85,15 +85,101 @@ type AlarmType = "basic:welcome" | "basic:default" | "feat:quiz" | "feat:guide"
85
85
  * Complete alarm message definition
86
86
  * UI is fully defined via JSON Component Descriptor
87
87
  * Click behavior is simple: open chat + send message (if provided in content.payload)
88
- * Duration is always 18 seconds (handled in useAlarmEffects)
88
+ * Duration is always 16 seconds (12s visible + 4s fade, handled in useAlarmEffects)
89
89
  */
90
90
  interface AlarmMessageInstanceType {
91
91
  type: AlarmType;
92
92
  content: AlarmElement;
93
93
  }
94
94
 
95
- type TapMessageType = "tap:ready" | "tap:close" | "timeline:seek" | "alarm:click" | "alarm:fadeIn" | "popUp:open" | "popUp:close" | "material:view:open" | "material:view:close" | "material:view:error" | "container:mode:change" | "container:mode:change:ack" | "container:layout:state:changed" | "viewport:resize" | "config:update" | "GA_EVENT";
96
- type TapMessage = TapReadyMessage | TapCloseMessage | TimelineSeekMessage | AlarmClickMessage | AlarmFadeInMessage | PopUpOpenMessage | PopUpCloseMessage | MaterialViewOpenMessage | MaterialViewCloseMessage | MaterialViewErrorMessage | ContainerModeChangeMessage | ContainerModeChangeAckMessage | ContainerLayoutStateChangedMessage | ViewportResizeMessage | ConfigUpdateMessage | GAEventMessage;
95
+ /**
96
+ * Styling Types
97
+ */
98
+ /**
99
+ * Display mode for TapKit container (user-facing configuration)
100
+ *
101
+ * - "inline": Embedded at element position
102
+ * - "floating": Compact widget floating in document.body
103
+ * - "sidebar": Full-height sidebar in document.body
104
+ */
105
+ type DisplayMode = "inline" | "floating" | "sidebar";
106
+ /**
107
+ * Layout mode for runtime layout switching
108
+ *
109
+ * Excludes "inline" because inline mode doesn't participate in layout toggling.
110
+ * Used by ContainerStateStore, localStorage persistence, and layout manager.
111
+ */
112
+ type LayoutMode = "floating" | "sidebar";
113
+ type PositionType = {
114
+ top?: string;
115
+ left?: string;
116
+ right?: string;
117
+ bottom?: string;
118
+ };
119
+ /**
120
+ * Floating mode configuration
121
+ * Includes position, size, and style settings for floating container
122
+ */
123
+ type FloatingConfig = {
124
+ /** Position (default: top: "50px", right: "24px") */
125
+ position?: PositionType;
126
+ /** Width (default: "340px") */
127
+ width?: string;
128
+ /** Height (default: "calc(100% - 116px)") */
129
+ height?: string;
130
+ /** Border radius (default: "16px") */
131
+ borderRadius?: string;
132
+ /** Expanded width for PDF viewer (default: "min(90vw, 1200px)") */
133
+ expandedWidth?: string;
134
+ /** Expanded height for PDF viewer (default: "90vh") */
135
+ expandedHeight?: string;
136
+ /** Expanded top position for PDF viewer (default: "5vh") */
137
+ expandedTop?: string;
138
+ /** Expanded right position for PDF viewer (default: "5vw") */
139
+ expandedRight?: string;
140
+ };
141
+ /**
142
+ * Sidebar Configuration
143
+ */
144
+ type SidebarConfig = {
145
+ /** Maximum width of the sidebar (default: "min(50%, 1000px)") */
146
+ maxWidth?: string;
147
+ /** Expanded maximum width for PDF viewer (default: "min(70%, 1400px)") */
148
+ expandedMaxWidth?: string;
149
+ /** Minimum viewport width to enable sidebar mode (default: 768) */
150
+ minViewportWidth?: number;
151
+ };
152
+ /**
153
+ * Container Configuration (SSOT - Type Level)
154
+ *
155
+ * This is the SINGLE SOURCE OF TRUTH for container configuration at the TYPE level.
156
+ * - Public API: TapKitInitParams.container
157
+ * - Internal: Container class configuration
158
+ * - Protocol: ConfigUpdateMessage.container mirrors this structure
159
+ *
160
+ * When modifying this type, also update ConfigUpdateMessage.container in @coxwave/tap-messages
161
+ *
162
+ * @example
163
+ * // Custom styling for floating/sidebar modes
164
+ * const config: ContainerConfig = {
165
+ * floatingConfig: { width: "400px", position: { top: "80px" } },
166
+ * sidebarConfig: { maxWidth: "800px" }
167
+ * }
168
+ */
169
+ type ContainerConfig = {
170
+ /**
171
+ * Display mode
172
+ * @see DisplayMode
173
+ */
174
+ mode?: DisplayMode;
175
+ /** Floating layout configuration (applied when SDK auto-creates container in floating layout) */
176
+ floatingConfig?: FloatingConfig;
177
+ /** Sidebar layout configuration (applied when SDK auto-creates container in sidebar layout) */
178
+ sidebarConfig?: SidebarConfig;
179
+ };
180
+
181
+ type TapMessageType = "tap:ready" | "tap:close" | "timeline:seek" | "alarm:click" | "alarm:fadeIn" | "popUp:open" | "popUp:close" | "material:view:open" | "material:view:close" | "material:view:error" | "html:view:open" | "html:view:close" | "container:mode:change" | "container:mode:change:ack" | "container:layout:state:changed" | "viewport:resize" | "config:update" | "GA_EVENT";
182
+ type TapMessage = TapReadyMessage | TapCloseMessage | TimelineSeekMessage | AlarmClickMessage | AlarmFadeInMessage | PopUpOpenMessage | PopUpCloseMessage | MaterialViewOpenMessage | MaterialViewCloseMessage | MaterialViewErrorMessage | HtmlViewOpenMessage | HtmlViewCloseMessage | ContainerModeChangeMessage | ContainerModeChangeAckMessage | ContainerLayoutStateChangedMessage | ViewportResizeMessage | ConfigUpdateMessage | GAEventMessage;
97
183
  interface TapReadyMessage {
98
184
  type: "tap:ready";
99
185
  gaId: string;
@@ -155,6 +241,30 @@ interface MaterialViewErrorMessage {
155
241
  error: "fetch_failed" | "expired_url" | "extraction_failed" | "unknown";
156
242
  message?: string;
157
243
  }
244
+ /**
245
+ * HTML View Open Request (iframe → parent, simple post pattern)
246
+ * Requests parent to open HTML viewer overlay
247
+ *
248
+ * Supports two content sources:
249
+ * - htmlUrl: Load HTML from URL (iframe src)
250
+ * - htmlContent: Render HTML string directly (iframe srcdoc)
251
+ */
252
+ interface HtmlViewOpenMessage {
253
+ type: "html:view:open";
254
+ /** URL to load HTML content from */
255
+ htmlUrl?: string;
256
+ /** HTML string to render directly */
257
+ htmlContent?: string;
258
+ /** Optional title for the viewer header */
259
+ title?: string;
260
+ }
261
+ /**
262
+ * HTML View Close Request (iframe → parent, simple post pattern)
263
+ * Requests parent to close HTML viewer overlay
264
+ */
265
+ interface HtmlViewCloseMessage {
266
+ type: "html:view:close";
267
+ }
158
268
  /**
159
269
  * Container Mode Change Request (iframe → parent, call/handle pattern)
160
270
  *
@@ -226,14 +336,7 @@ interface ConfigUpdateMessage {
226
336
  courseId?: string;
227
337
  clipId?: string;
228
338
  clipPlayHead?: number;
229
- /**
230
- * Display mode
231
- * - "inline": Container rendered at <tap-kit> position (embedded in page)
232
- * - "floating": Container floats in document.body as compact widget
233
- * - "sidebar": Container floats in document.body as full-height sidebar
234
- * Default: "inline"
235
- */
236
- mode?: "inline" | "floating" | "sidebar";
339
+ mode?: DisplayMode;
237
340
  /**
238
341
  * Allow user to toggle between floating and sidebar layouts
239
342
  * @default true
@@ -2038,6 +2141,15 @@ declare const MaterialViewErrorSchema: ObjectSchema<{
2038
2141
  readonly error: UnionSchema<[LiteralSchema<"fetch_failed", undefined>, LiteralSchema<"expired_url", undefined>, LiteralSchema<"extraction_failed", undefined>, LiteralSchema<"unknown", undefined>], undefined>;
2039
2142
  readonly message: OptionalSchema<StringSchema<undefined>, undefined>;
2040
2143
  }, undefined>;
2144
+ declare const HtmlViewOpenSchema: ObjectSchema<{
2145
+ readonly type: LiteralSchema<"html:view:open", undefined>;
2146
+ readonly htmlUrl: OptionalSchema<StringSchema<undefined>, undefined>;
2147
+ readonly htmlContent: OptionalSchema<StringSchema<undefined>, undefined>;
2148
+ readonly title: OptionalSchema<StringSchema<undefined>, undefined>;
2149
+ }, undefined>;
2150
+ declare const HtmlViewCloseSchema: ObjectSchema<{
2151
+ readonly type: LiteralSchema<"html:view:close", undefined>;
2152
+ }, undefined>;
2041
2153
  declare const ContainerModeChangeSchema: ObjectSchema<{
2042
2154
  readonly type: LiteralSchema<"container:mode:change", undefined>;
2043
2155
  readonly mode: UnionSchema<[LiteralSchema<"floating", undefined>, LiteralSchema<"sidebar", undefined>], undefined>;
@@ -2137,6 +2249,13 @@ declare const TapMessageSchema: UnionSchema<[ObjectSchema<{
2137
2249
  readonly materialId: StringSchema<undefined>;
2138
2250
  readonly error: UnionSchema<[LiteralSchema<"fetch_failed", undefined>, LiteralSchema<"expired_url", undefined>, LiteralSchema<"extraction_failed", undefined>, LiteralSchema<"unknown", undefined>], undefined>;
2139
2251
  readonly message: OptionalSchema<StringSchema<undefined>, undefined>;
2252
+ }, undefined>, ObjectSchema<{
2253
+ readonly type: LiteralSchema<"html:view:open", undefined>;
2254
+ readonly htmlUrl: OptionalSchema<StringSchema<undefined>, undefined>;
2255
+ readonly htmlContent: OptionalSchema<StringSchema<undefined>, undefined>;
2256
+ readonly title: OptionalSchema<StringSchema<undefined>, undefined>;
2257
+ }, undefined>, ObjectSchema<{
2258
+ readonly type: LiteralSchema<"html:view:close", undefined>;
2140
2259
  }, undefined>, ObjectSchema<{
2141
2260
  readonly type: LiteralSchema<"container:mode:change", undefined>;
2142
2261
  readonly mode: UnionSchema<[LiteralSchema<"floating", undefined>, LiteralSchema<"sidebar", undefined>], undefined>;
@@ -2209,23 +2328,49 @@ type TapKitConfig = {
2209
2328
  apiKey: string;
2210
2329
  };
2211
2330
  /**
2212
- * Runtime configuration sent to iframe via config:update message
2213
- * Derived from ConfigUpdateMessage protocol (without 'type' field)
2214
- * This ensures type consistency between iframe messages and config
2331
+ * =============================================================================
2332
+ * SSOT (Single Source of Truth) Type Hierarchy
2333
+ * =============================================================================
2334
+ *
2335
+ * All configuration types derive from ConfigUpdateMessage:
2336
+ *
2337
+ * ConfigUpdateMessage (SSOT - protocol/messages.ts)
2338
+ * ↓ Omit<..., "type">
2339
+ * ConfigUpdatePayload (모든 config 필드)
2340
+ * ↓ Partial<...>
2341
+ * ConfigUpdateOptions (런타임 업데이트용, 모든 필드 optional)
2342
+ * ↓ Exclude<keyof ..., ...>
2343
+ * SyncableConfigKey (iframe 동기화 대상 키들)
2344
+ *
2345
+ * Benefits:
2346
+ * - 새 필드 추가 시 ConfigUpdateMessage만 수정
2347
+ * - 다른 위치에서 컴파일 에러 발생으로 누락 방지
2348
+ * =============================================================================
2215
2349
  */
2216
- type TapKitRuntimeConfig = Omit<ConfigUpdateMessage, "type">;
2217
2350
  /**
2218
- * All SDK Configuration Options (Internal API)
2219
- * Derived from ConfigUpdateMessage protocol for type consistency
2220
- * Used by Symbol-based config() method for advanced configuration
2221
- *
2222
- * Note: All fields (tapUrl, environment, etc.) are now part of TapKitRuntimeConfig
2223
- * which is based on ConfigUpdateMessage. This ensures consistency between
2224
- * SDK configuration and iframe message protocol.
2351
+ * config:update 메시지의 payload (type 필드 제외)
2352
+ * 모든 config 관련 타입의 기반
2353
+ */
2354
+ type ConfigUpdatePayload = Omit<ConfigUpdateMessage, "type">;
2355
+ /**
2356
+ * 런타임 업데이트 가능한 config
2357
+ */
2358
+ type ConfigUpdateKey = keyof ConfigUpdatePayload;
2359
+ /**
2360
+ * 런타임 config 업데이트용 (모든 필드 optional)
2361
+ * updateConfig() 메서드에서 사용
2362
+ */
2363
+ type ConfigUpdateOptions = Partial<ConfigUpdatePayload>;
2364
+ /**
2365
+ * iframe 동기화 대상 키 (초기화 전용 키 제외)
2366
+ * CONFIG_KEYS 배열의 타입 제약으로 사용
2225
2367
  *
2226
- * @internal This is not part of the public API
2368
+ * 제외 항목:
2369
+ * - apiKey: 초기화 시에만 설정
2370
+ * - hostOrigin: 자동 감지
2371
+ * - tapUrl: 초기화 시에만 설정
2227
2372
  */
2228
- type TapKitConfigOptions = TapKitRuntimeConfig;
2373
+ type SyncableConfigKey = Exclude<ConfigUpdateKey, "apiKey" | "hostOrigin" | "tapUrl">;
2229
2374
  /**
2230
2375
  * Course Information
2231
2376
  */
@@ -2481,16 +2626,19 @@ interface VideoPlayerAdapter {
2481
2626
  *
2482
2627
  * @example
2483
2628
  * ```typescript
2484
- * // HTML5 Video
2629
+ * // HTML5 Video (recommended - clipId auto-tracked)
2485
2630
  * const videoElement = document.querySelector('video');
2486
- * sdk.video.bind(videoElement, 'clip-123');
2631
+ * sdk.video.bind(videoElement); // clipId from SDK config, auto-updates with setCourse()
2487
2632
  *
2488
2633
  * // Custom Adapter
2489
2634
  * const adapter = {
2490
2635
  * getCurrentTime: () => player.currentTime,
2491
2636
  * setCurrentTime: (time) => { player.currentTime = time; }
2492
2637
  * };
2493
- * sdk.video.bind(adapter, 'clip-123');
2638
+ * sdk.video.bind(adapter);
2639
+ *
2640
+ * // Manual clipId (for special cases)
2641
+ * sdk.video.bind(videoElement, 'specific-clip-id');
2494
2642
  * ```
2495
2643
  */
2496
2644
  type VideoPlayerConfig = HTMLVideoElement | VideoPlayerAdapter;
@@ -2508,8 +2656,13 @@ interface TapKitInstance {
2508
2656
  onAlarmFadeIn: (handler: (messageInfo: AlarmMessageInstanceType) => void) => () => void;
2509
2657
  };
2510
2658
  video: {
2511
- /** Bind video player for timeline synchronization */
2512
- bind: (config: VideoPlayerConfig, clipId: string) => void;
2659
+ /**
2660
+ * Bind video player for timeline synchronization
2661
+ *
2662
+ * @param config - HTMLVideoElement or VideoPlayerAdapter
2663
+ * @param clipId - Optional clipId. If not provided, uses SDK config (auto-tracks changes from setCourse)
2664
+ */
2665
+ bind: (config: VideoPlayerConfig, clipId?: string) => void;
2513
2666
  /** Unbind current video player */
2514
2667
  unbind: () => void;
2515
2668
  };
@@ -2523,87 +2676,17 @@ interface TapKitInstance {
2523
2676
  /** Hide chat container */
2524
2677
  hide(): void;
2525
2678
  /**
2526
- * Internal config update method (soft-private, discouraged)
2527
- *
2528
- * Accepts any config key-value pairs for advanced configuration.
2529
- * Type is intentionally generic to hide implementation details.
2530
- *
2531
- * @deprecated Use public APIs instead. This is kept for backward compatibility.
2532
- * Prefer using Symbol API via Symbol.for("tapkit.config") for advanced config.
2533
- *
2534
- * @internal Soft-private method (starts with _)
2679
+ * Update course information
2680
+ * @param course - Course info (courseId and clipId required, userId and clipPlayHead optional)
2535
2681
  */
2536
- _updateConfig?(options: Record<string, unknown>): void;
2682
+ setCourse(course: Partial<Course> & {
2683
+ courseId: string;
2684
+ clipId: string;
2685
+ }): void;
2537
2686
  }
2538
2687
  /** TapKit constructor type */
2539
2688
  type TapKitConstructor = new (config: TapKitConfig) => TapKitInstance;
2540
2689
 
2541
- /**
2542
- * Styling Types
2543
- */
2544
- type PositionType = {
2545
- top?: string;
2546
- left?: string;
2547
- right?: string;
2548
- bottom?: string;
2549
- };
2550
- /**
2551
- * Floating mode configuration
2552
- * Includes position, size, and style settings for floating container
2553
- */
2554
- type FloatingConfig = {
2555
- /** Position (default: top: "50px", right: "24px") */
2556
- position?: PositionType;
2557
- /** Width (default: "340px") */
2558
- width?: string;
2559
- /** Height (default: "calc(100% - 116px)") */
2560
- height?: string;
2561
- /** Border radius (default: "16px") */
2562
- borderRadius?: string;
2563
- /** Expanded width for PDF viewer (default: "min(90vw, 1200px)") */
2564
- expandedWidth?: string;
2565
- /** Expanded height for PDF viewer (default: "90vh") */
2566
- expandedHeight?: string;
2567
- /** Expanded top position for PDF viewer (default: "5vh") */
2568
- expandedTop?: string;
2569
- /** Expanded right position for PDF viewer (default: "5vw") */
2570
- expandedRight?: string;
2571
- };
2572
- /**
2573
- * Sidebar Configuration
2574
- */
2575
- type SidebarConfig = {
2576
- /** Maximum width of the sidebar (default: "min(50%, 1000px)") */
2577
- maxWidth?: string;
2578
- /** Expanded maximum width for PDF viewer (default: "min(70%, 1400px)") */
2579
- expandedMaxWidth?: string;
2580
- /** Minimum viewport width to enable sidebar mode (default: 768) */
2581
- minViewportWidth?: number;
2582
- };
2583
- /**
2584
- * Container Configuration (SSOT - Type Level)
2585
- *
2586
- * This is the SINGLE SOURCE OF TRUTH for container configuration at the TYPE level.
2587
- * - Public API: TapKitInitParams.container
2588
- * - Internal: Container class configuration
2589
- * - Protocol: ConfigUpdateMessage.container mirrors this structure
2590
- *
2591
- * When modifying this type, also update ConfigUpdateMessage.container in @coxwave/tap-messages
2592
- *
2593
- * @example
2594
- * // Custom styling for floating/sidebar modes
2595
- * const config: ContainerConfig = {
2596
- * floatingConfig: { width: "400px", position: { top: "80px" } },
2597
- * sidebarConfig: { maxWidth: "800px" }
2598
- * }
2599
- */
2600
- type ContainerConfig = {
2601
- /** Floating layout configuration (applied when SDK auto-creates container in floating layout) */
2602
- floatingConfig?: FloatingConfig;
2603
- /** Sidebar layout configuration (applied when SDK auto-creates container in sidebar layout) */
2604
- sidebarConfig?: SidebarConfig;
2605
- };
2606
-
2607
2690
  /**
2608
2691
  * Type declarations for <tap-button> Web Component
2609
2692
  *
@@ -2904,6 +2987,167 @@ interface TapContainerAttributes {
2904
2987
  onDestroy?: () => void;
2905
2988
  }
2906
2989
 
2990
+ /**
2991
+ * Type declarations for <tap-html-viewer> Web Component
2992
+ *
2993
+ * Provides TypeScript support for using <tap-html-viewer> in JSX/TSX.
2994
+ * The actual Web Component is registered by tap-kit-core when loaded.
2995
+ */
2996
+
2997
+
2998
+
2999
+ // React 19 requires module augmentation based on tsconfig jsx setting
3000
+ // - "jsx": "react-jsx" → augment "react/jsx-runtime"
3001
+ // - "jsx": "preserve" → augment "react" (Next.js default)
3002
+
3003
+ // For Next.js (jsx: preserve)
3004
+ declare module "react" {
3005
+ namespace JSX {
3006
+ interface IntrinsicElements {
3007
+ "tap-html-viewer": TapHtmlViewerAttributes;
3008
+ }
3009
+ }
3010
+ }
3011
+
3012
+ // For CRA, Vite (jsx: react-jsx)
3013
+ declare module "react/jsx-runtime" {
3014
+ namespace JSX {
3015
+ interface IntrinsicElements {
3016
+ "tap-html-viewer": TapHtmlViewerAttributes;
3017
+ }
3018
+ }
3019
+ }
3020
+
3021
+ /**
3022
+ * Configuration for opening HTML viewer
3023
+ */
3024
+ interface HtmlViewConfig {
3025
+ /**
3026
+ * URL to load HTML content from (uses iframe src)
3027
+ */
3028
+ htmlUrl?: string;
3029
+
3030
+ /**
3031
+ * HTML string to render directly (uses iframe srcdoc)
3032
+ */
3033
+ htmlContent?: string;
3034
+
3035
+ /**
3036
+ * Optional title for the viewer header
3037
+ */
3038
+ title?: string;
3039
+ }
3040
+
3041
+ /**
3042
+ * Public API interface for TapHtmlViewerElement Web Component
3043
+ *
3044
+ * This interface defines the contract that tap-kit-core's TapHtmlViewerElement must implement.
3045
+ * It provides type-safe access to the Web Component's public API.
3046
+ *
3047
+ * The HTML viewer displays HTML content in a sandboxed iframe overlay
3048
+ * positioned relative to a container element.
3049
+ */
3050
+ interface ITapHtmlViewerElement extends HTMLElement {
3051
+ /**
3052
+ * Container element reference for positioning
3053
+ * Must be set before calling open()
3054
+ */
3055
+ containerElement: HTMLElement | null;
3056
+
3057
+ /**
3058
+ * Open HTML viewer with configuration
3059
+ *
3060
+ * Displays HTML content in a sandboxed iframe overlay.
3061
+ * Content source: htmlUrl (external) or htmlContent (inline).
3062
+ *
3063
+ * @param config - HTML view configuration
3064
+ * @fires open - When viewer is successfully displayed
3065
+ */
3066
+ open(config: HtmlViewConfig): void;
3067
+
3068
+ /**
3069
+ * Close HTML viewer and cleanup
3070
+ *
3071
+ * Hides overlay and resets state.
3072
+ *
3073
+ * @fires close - When viewer is closed
3074
+ */
3075
+ close(): void;
3076
+
3077
+ /**
3078
+ * Update overlay position relative to container
3079
+ *
3080
+ * Automatically called on container resize/move.
3081
+ * Can be manually triggered if needed.
3082
+ */
3083
+ updatePosition(): void;
3084
+
3085
+ /**
3086
+ * Hide overlay without closing viewer
3087
+ *
3088
+ * Called when container is hidden. Preserves viewer state
3089
+ * so it can be shown again when container becomes visible.
3090
+ */
3091
+ hideOverlay(): void;
3092
+
3093
+ /**
3094
+ * Show overlay (if viewer has content)
3095
+ *
3096
+ * Called when container is shown. Only displays overlay
3097
+ * if viewer has content loaded.
3098
+ */
3099
+ showOverlay(): void;
3100
+
3101
+ /**
3102
+ * Check if viewer is currently visible
3103
+ *
3104
+ * @returns true if visible, false otherwise
3105
+ */
3106
+ readonly isVisible: boolean;
3107
+ }
3108
+
3109
+ /**
3110
+ * Props/Attributes for <tap-html-viewer> Web Component
3111
+ */
3112
+ interface TapHtmlViewerAttributes {
3113
+ /**
3114
+ * Element ID attribute
3115
+ */
3116
+ id?: string;
3117
+
3118
+ /**
3119
+ * CSS class name(s)
3120
+ */
3121
+ className?: string;
3122
+
3123
+ /**
3124
+ * Container element reference for positioning
3125
+ * Required before calling open()
3126
+ */
3127
+ containerElement?: HTMLElement | null;
3128
+
3129
+ /**
3130
+ * Child content (not typically used for tap-html-viewer)
3131
+ * The component automatically creates overlay content
3132
+ */
3133
+ children?: ReactNode;
3134
+
3135
+ /**
3136
+ * Custom inline styles
3137
+ */
3138
+ style?: CSSProperties;
3139
+
3140
+ /**
3141
+ * Event handler for when viewer is successfully displayed
3142
+ */
3143
+ onOpen?: () => void;
3144
+
3145
+ /**
3146
+ * Event handler for when viewer is closed
3147
+ */
3148
+ onClose?: () => void;
3149
+ }
3150
+
2907
3151
  /**
2908
3152
  * TapKit Web Component Type Definitions
2909
3153
  *
@@ -2929,7 +3173,22 @@ interface EventManager {
2929
3173
  * VideoController type (matches TapKitInstance.video)
2930
3174
  */
2931
3175
  interface VideoController {
2932
- bind: (config: VideoPlayerConfig, clipId: string) => void;
3176
+ /**
3177
+ * Bind video player for timeline synchronization
3178
+ *
3179
+ * @param config - HTMLVideoElement or VideoPlayerAdapter
3180
+ * @param clipId - Optional clipId. If not provided, uses SDK config (auto-tracks changes from setCourse)
3181
+ *
3182
+ * @example
3183
+ * ```typescript
3184
+ * // Auto-tracking (recommended) - clipId syncs with setCourse()
3185
+ * kit.video.bind(videoElement);
3186
+ *
3187
+ * // Manual clipId (for special cases)
3188
+ * kit.video.bind(videoElement, 'specific-clip-id');
3189
+ * ```
3190
+ */
3191
+ bind: (config: VideoPlayerConfig, clipId?: string) => void;
2933
3192
  unbind: () => void;
2934
3193
  }
2935
3194
 
@@ -3001,11 +3260,55 @@ interface TapKitElement extends HTMLElement {
3001
3260
  mode?: "inline" | "floating" | "sidebar";
3002
3261
 
3003
3262
  /**
3004
- * Auto-created flag (internal use only)
3005
- * Indicates SDK-controlled element (used by legacy TapKit class)
3006
- * @internal
3263
+ * Allow user to toggle between floating and sidebar layouts
3264
+ * Only applies when mode is "floating" or "sidebar"
3265
+ * @default true
3007
3266
  */
3008
- autoCreated?: boolean;
3267
+ allowLayoutToggle: boolean;
3268
+
3269
+ /**
3270
+ * Video player target for timeline synchronization (recommended)
3271
+ *
3272
+ * Supports HTMLVideoElement or VideoPlayerAdapter.
3273
+ * Survives lifecycle changes (mode change, reconnect).
3274
+ *
3275
+ * @example
3276
+ * ```typescript
3277
+ * // HTMLVideoElement
3278
+ * kit.videoTarget = document.querySelector('video');
3279
+ *
3280
+ * // VideoPlayerAdapter (YouTube, Vimeo, etc.)
3281
+ * kit.videoTarget = {
3282
+ * getCurrentTime: () => player.getCurrentTime(),
3283
+ * setCurrentTime: (t) => player.seekTo(t)
3284
+ * };
3285
+ * ```
3286
+ */
3287
+ videoTarget?: VideoPlayerConfig;
3288
+
3289
+ /**
3290
+ * Root element - tracks the parent element where TapKit is rendered
3291
+ *
3292
+ * **Declarative mode** (`<TapKit />`, `<tap-kit>`):
3293
+ * - Automatically set to `parentElement` on mount
3294
+ * - Read-only after initialization
3295
+ *
3296
+ * **Imperative mode** (`createTapKit()`):
3297
+ * - Set before mount (default: `document.body`)
3298
+ * - Can be changed at runtime
3299
+ *
3300
+ * **Note:** Ignored in inline mode (element stays in declarative position).
3301
+ *
3302
+ * @example
3303
+ * ```typescript
3304
+ * // Imperative: set root before mount
3305
+ * const kit = createTapKit({ apiKey: '...', root: myContainer });
3306
+ *
3307
+ * // Imperative: change root at runtime
3308
+ * kit.root = document.getElementById('another-container');
3309
+ * ```
3310
+ */
3311
+ root?: HTMLElement;
3009
3312
 
3010
3313
  // ===== Public Methods (Imperative API) =====
3011
3314
 
@@ -3159,9 +3462,6 @@ interface TapKitAttributes {
3159
3462
  /** Custom button element ID */
3160
3463
  "button-id"?: string;
3161
3464
 
3162
- /** Custom container element ID */
3163
- "container-id"?: string;
3164
-
3165
3465
  /** Enable debug mode */
3166
3466
  debug?: boolean;
3167
3467
 
@@ -3173,6 +3473,12 @@ interface TapKitAttributes {
3173
3473
  */
3174
3474
  mode?: "inline" | "floating" | "sidebar";
3175
3475
 
3476
+ /**
3477
+ * Allow user to toggle between floating and sidebar layouts
3478
+ * Only applies when mode is "floating" or "sidebar"
3479
+ */
3480
+ "allow-layout-toggle"?: boolean;
3481
+
3176
3482
  /** Custom inline styles */
3177
3483
  style?: CSSProperties;
3178
3484
 
@@ -3301,6 +3607,8 @@ interface ITapMaterialViewerElement extends HTMLElement {
3301
3607
  * Downloads PDF from presigned URL, extracts specified pages,
3302
3608
  * and displays in an overlay positioned relative to containerElement.
3303
3609
  *
3610
+ * Note: For HTML content, use TapHtmlViewerElement instead (Separation of Concerns).
3611
+ *
3304
3612
  * @param config - Material view configuration
3305
3613
  * @throws {MaterialViewerError} If PDF fetch or processing fails
3306
3614
  * @fires error - When material loading fails
@@ -3473,4 +3781,4 @@ declare global {
3473
3781
  function cancelIdleCallback(handle: number): void;
3474
3782
  }
3475
3783
 
3476
- export { ALARM_DURATION, type AlarmClickMessage, AlarmClickSchema, type AlarmElement, type AlarmElementProps, AlarmElementPropsSchema, AlarmElementSchema, type AlarmFadeInMessage, AlarmFadeInSchema, AlarmMessageInstanceSchema, type AlarmMessageInstanceType, type AlarmPayload, type AlarmType, type CSSStyle, CSSStyleSchema, type ConfigUpdateMessage, ConfigUpdateSchema, type ContainerConfig, type ContainerLayoutStateChangedMessage, ContainerLayoutStateChangedSchema, type ContainerModeChangeAckMessage, ContainerModeChangeAckSchema, type ContainerModeChangeMessage, ContainerModeChangeSchema, type ContainerVisibility, type Course, type EventManager, type FloatingConfig, type GAEventMessage, GAEventSchema, type ITapButtonElement, type ITapContainerElement, type ITapKitElement, type ITapMaterialViewerElement, TapKitInitializationError as InitializationError, type MaterialViewCloseMessage, MaterialViewCloseSchema, type MaterialViewConfig, type MaterialViewErrorMessage, MaterialViewErrorSchema, type MaterialViewOpenMessage, MaterialViewOpenSchema, MaterialViewerError, type PopUpCloseMessage, PopUpCloseSchema, type PopUpOpenMessage, PopUpOpenSchema, type PositionType, type SeekTimelineParamsType, type ShortcutKeyPropertiesType, type SidebarConfig, TAP_BUTTON_CLICK_EVENT, TAP_ERROR_MARKER, type TapButtonAttributes, type TapButtonClickEventDetail, type TapCloseMessage, TapCloseSchema, type TapContainerAttributes, type TapErrorOptions, type TapKitConfig, type TapKitConfigOptions, TapKitConfigurationError, type TapKitConstructor, type TapKitElement, type TapKitElementEventMap, TapKitError, TapKitIframeError, type TapKitInitParams, TapKitInitializationError, type TapKitInstance, TapKitLoaderError, TapKitMessageError, type TapKitRuntimeConfig, type TapMaterialViewerAttributes, type TapMessage, type TapMessageRecord, TapMessageSchema, type TapMessageType, type TapReadyMessage, TapReadySchema, type TimelineSeekMessage, TimelineSeekSchema, type VideoController, type VideoPlayerAdapter, type VideoPlayerConfig, type ViewportResizeMessage, ViewportResizeSchema };
3784
+ export { ALARM_DURATION, type AlarmClickMessage, AlarmClickSchema, type AlarmElement, type AlarmElementProps, AlarmElementPropsSchema, AlarmElementSchema, type AlarmFadeInMessage, AlarmFadeInSchema, AlarmMessageInstanceSchema, type AlarmMessageInstanceType, type AlarmPayload, type AlarmType, type CSSStyle, CSSStyleSchema, type ConfigUpdateKey, type ConfigUpdateMessage, type ConfigUpdateOptions, type ConfigUpdatePayload, ConfigUpdateSchema, type ContainerConfig, type ContainerLayoutStateChangedMessage, ContainerLayoutStateChangedSchema, type ContainerModeChangeAckMessage, ContainerModeChangeAckSchema, type ContainerModeChangeMessage, ContainerModeChangeSchema, type ContainerVisibility, type Course, type DisplayMode, type EventManager, type FloatingConfig, type GAEventMessage, GAEventSchema, type HtmlViewCloseMessage, HtmlViewCloseSchema, type HtmlViewConfig, type HtmlViewOpenMessage, HtmlViewOpenSchema, type ITapButtonElement, type ITapContainerElement, type ITapHtmlViewerElement, type ITapKitElement, type ITapMaterialViewerElement, TapKitInitializationError as InitializationError, type LayoutMode, type MaterialViewCloseMessage, MaterialViewCloseSchema, type MaterialViewConfig, type MaterialViewErrorMessage, MaterialViewErrorSchema, type MaterialViewOpenMessage, MaterialViewOpenSchema, MaterialViewerError, type PopUpCloseMessage, PopUpCloseSchema, type PopUpOpenMessage, PopUpOpenSchema, type PositionType, type SeekTimelineParamsType, type ShortcutKeyPropertiesType, type SidebarConfig, type SyncableConfigKey, TAP_BUTTON_CLICK_EVENT, TAP_ERROR_MARKER, type TapButtonAttributes, type TapButtonClickEventDetail, type TapCloseMessage, TapCloseSchema, type TapContainerAttributes, type TapErrorOptions, type TapHtmlViewerAttributes, type TapKitConfig, TapKitConfigurationError, type TapKitConstructor, type TapKitElement, type TapKitElementEventMap, TapKitError, TapKitIframeError, type TapKitInitParams, TapKitInitializationError, type TapKitInstance, TapKitLoaderError, TapKitMessageError, type TapMaterialViewerAttributes, type TapMessage, type TapMessageRecord, TapMessageSchema, type TapMessageType, type TapReadyMessage, TapReadySchema, type TimelineSeekMessage, TimelineSeekSchema, type VideoController, type VideoPlayerAdapter, type VideoPlayerConfig, type ViewportResizeMessage, ViewportResizeSchema };