@coxwave/tap-kit-types 2.0.3 → 2.0.6
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 +415 -95
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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 (
|
|
6
|
-
*
|
|
5
|
+
* Alarm display duration (16 seconds total)
|
|
6
|
+
* 12초 유지 + 4초 fade out = 16초 total
|
|
7
7
|
*/
|
|
8
|
-
declare const ALARM_DURATION =
|
|
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
|
|
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
|
-
|
|
96
|
-
|
|
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>;
|
|
@@ -2371,6 +2490,76 @@ type SeekTimelineParamsType = {
|
|
|
2371
2490
|
clipId: string;
|
|
2372
2491
|
clipPlayHead: number;
|
|
2373
2492
|
};
|
|
2493
|
+
/**
|
|
2494
|
+
* TapKit Ready Event - Fired when iframe is initialized and ready
|
|
2495
|
+
*
|
|
2496
|
+
* @example
|
|
2497
|
+
* ```typescript
|
|
2498
|
+
* document.addEventListener('tapkit:ready', (e) => {
|
|
2499
|
+
* console.log('TapKit ready! GA ID:', e.detail.gaId);
|
|
2500
|
+
* });
|
|
2501
|
+
* ```
|
|
2502
|
+
*/
|
|
2503
|
+
interface TapKitReadyEvent extends CustomEvent<{
|
|
2504
|
+
gaId: string;
|
|
2505
|
+
}> {
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* TapKit Close Event - Fired when chat is closed from within iframe
|
|
2509
|
+
*
|
|
2510
|
+
* @example
|
|
2511
|
+
* ```typescript
|
|
2512
|
+
* document.addEventListener('tapkit:close', () => {
|
|
2513
|
+
* console.log('Chat closed');
|
|
2514
|
+
* });
|
|
2515
|
+
* ```
|
|
2516
|
+
*/
|
|
2517
|
+
interface TapKitCloseEvent extends CustomEvent<undefined> {
|
|
2518
|
+
}
|
|
2519
|
+
/**
|
|
2520
|
+
* TapKit Timeline Seek Event - Fired when user clicks timeline in chat
|
|
2521
|
+
*
|
|
2522
|
+
* @example
|
|
2523
|
+
* ```typescript
|
|
2524
|
+
* document.addEventListener('tapkit:timeline:seek', (e) => {
|
|
2525
|
+
* videoElement.currentTime = e.detail.clipPlayHead;
|
|
2526
|
+
* });
|
|
2527
|
+
* ```
|
|
2528
|
+
*/
|
|
2529
|
+
interface TapKitTimelineSeekEvent extends CustomEvent<{
|
|
2530
|
+
clipId: string;
|
|
2531
|
+
clipPlayHead: number;
|
|
2532
|
+
}> {
|
|
2533
|
+
}
|
|
2534
|
+
/**
|
|
2535
|
+
* TapKit Material View Open Event - Fired when PDF/document viewer opens
|
|
2536
|
+
*
|
|
2537
|
+
* @example
|
|
2538
|
+
* ```typescript
|
|
2539
|
+
* document.addEventListener('tapkit:material:view:open', (e) => {
|
|
2540
|
+
* console.log('Material opened:', e.detail.materialId);
|
|
2541
|
+
* });
|
|
2542
|
+
* ```
|
|
2543
|
+
*/
|
|
2544
|
+
interface TapKitMaterialViewOpenEvent extends CustomEvent<{
|
|
2545
|
+
materialId: string;
|
|
2546
|
+
presignedUrl: string;
|
|
2547
|
+
pageStart?: number;
|
|
2548
|
+
pageEnd?: number;
|
|
2549
|
+
}> {
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* TapKit Material View Close Event - Fired when PDF/document viewer closes
|
|
2553
|
+
*
|
|
2554
|
+
* @example
|
|
2555
|
+
* ```typescript
|
|
2556
|
+
* document.addEventListener('tapkit:material:view:close', () => {
|
|
2557
|
+
* console.log('Material viewer closed');
|
|
2558
|
+
* });
|
|
2559
|
+
* ```
|
|
2560
|
+
*/
|
|
2561
|
+
interface TapKitMaterialViewCloseEvent extends CustomEvent<undefined> {
|
|
2562
|
+
}
|
|
2374
2563
|
/**
|
|
2375
2564
|
* Shortcut Key Configuration
|
|
2376
2565
|
*/
|
|
@@ -2411,16 +2600,19 @@ interface VideoPlayerAdapter {
|
|
|
2411
2600
|
*
|
|
2412
2601
|
* @example
|
|
2413
2602
|
* ```typescript
|
|
2414
|
-
* // HTML5 Video
|
|
2603
|
+
* // HTML5 Video (recommended - clipId auto-tracked)
|
|
2415
2604
|
* const videoElement = document.querySelector('video');
|
|
2416
|
-
* sdk.video.bind(videoElement,
|
|
2605
|
+
* sdk.video.bind(videoElement); // clipId from SDK config, auto-updates with setCourse()
|
|
2417
2606
|
*
|
|
2418
2607
|
* // Custom Adapter
|
|
2419
2608
|
* const adapter = {
|
|
2420
2609
|
* getCurrentTime: () => player.currentTime,
|
|
2421
2610
|
* setCurrentTime: (time) => { player.currentTime = time; }
|
|
2422
2611
|
* };
|
|
2423
|
-
* sdk.video.bind(adapter
|
|
2612
|
+
* sdk.video.bind(adapter);
|
|
2613
|
+
*
|
|
2614
|
+
* // Manual clipId (for special cases)
|
|
2615
|
+
* sdk.video.bind(videoElement, 'specific-clip-id');
|
|
2424
2616
|
* ```
|
|
2425
2617
|
*/
|
|
2426
2618
|
type VideoPlayerConfig = HTMLVideoElement | VideoPlayerAdapter;
|
|
@@ -2453,87 +2645,17 @@ interface TapKitInstance {
|
|
|
2453
2645
|
/** Hide chat container */
|
|
2454
2646
|
hide(): void;
|
|
2455
2647
|
/**
|
|
2456
|
-
*
|
|
2457
|
-
*
|
|
2458
|
-
* Accepts any config key-value pairs for advanced configuration.
|
|
2459
|
-
* Type is intentionally generic to hide implementation details.
|
|
2460
|
-
*
|
|
2461
|
-
* @deprecated Use public APIs instead. This is kept for backward compatibility.
|
|
2462
|
-
* Prefer using Symbol API via Symbol.for("tapkit.config") for advanced config.
|
|
2463
|
-
*
|
|
2464
|
-
* @internal Soft-private method (starts with _)
|
|
2648
|
+
* Update course information
|
|
2649
|
+
* @param course - Course info (courseId and clipId required, userId and clipPlayHead optional)
|
|
2465
2650
|
*/
|
|
2466
|
-
|
|
2651
|
+
setCourse(course: Partial<Course> & {
|
|
2652
|
+
courseId: string;
|
|
2653
|
+
clipId: string;
|
|
2654
|
+
}): void;
|
|
2467
2655
|
}
|
|
2468
2656
|
/** TapKit constructor type */
|
|
2469
2657
|
type TapKitConstructor = new (config: TapKitConfig) => TapKitInstance;
|
|
2470
2658
|
|
|
2471
|
-
/**
|
|
2472
|
-
* Styling Types
|
|
2473
|
-
*/
|
|
2474
|
-
type PositionType = {
|
|
2475
|
-
top?: string;
|
|
2476
|
-
left?: string;
|
|
2477
|
-
right?: string;
|
|
2478
|
-
bottom?: string;
|
|
2479
|
-
};
|
|
2480
|
-
/**
|
|
2481
|
-
* Floating mode configuration
|
|
2482
|
-
* Includes position, size, and style settings for floating container
|
|
2483
|
-
*/
|
|
2484
|
-
type FloatingConfig = {
|
|
2485
|
-
/** Position (default: top: "50px", right: "24px") */
|
|
2486
|
-
position?: PositionType;
|
|
2487
|
-
/** Width (default: "340px") */
|
|
2488
|
-
width?: string;
|
|
2489
|
-
/** Height (default: "calc(100% - 116px)") */
|
|
2490
|
-
height?: string;
|
|
2491
|
-
/** Border radius (default: "16px") */
|
|
2492
|
-
borderRadius?: string;
|
|
2493
|
-
/** Expanded width for PDF viewer (default: "min(90vw, 1200px)") */
|
|
2494
|
-
expandedWidth?: string;
|
|
2495
|
-
/** Expanded height for PDF viewer (default: "90vh") */
|
|
2496
|
-
expandedHeight?: string;
|
|
2497
|
-
/** Expanded top position for PDF viewer (default: "5vh") */
|
|
2498
|
-
expandedTop?: string;
|
|
2499
|
-
/** Expanded right position for PDF viewer (default: "5vw") */
|
|
2500
|
-
expandedRight?: string;
|
|
2501
|
-
};
|
|
2502
|
-
/**
|
|
2503
|
-
* Sidebar Configuration
|
|
2504
|
-
*/
|
|
2505
|
-
type SidebarConfig = {
|
|
2506
|
-
/** Maximum width of the sidebar (default: "min(50%, 1000px)") */
|
|
2507
|
-
maxWidth?: string;
|
|
2508
|
-
/** Expanded maximum width for PDF viewer (default: "min(70%, 1400px)") */
|
|
2509
|
-
expandedMaxWidth?: string;
|
|
2510
|
-
/** Minimum viewport width to enable sidebar mode (default: 768) */
|
|
2511
|
-
minViewportWidth?: number;
|
|
2512
|
-
};
|
|
2513
|
-
/**
|
|
2514
|
-
* Container Configuration (SSOT - Type Level)
|
|
2515
|
-
*
|
|
2516
|
-
* This is the SINGLE SOURCE OF TRUTH for container configuration at the TYPE level.
|
|
2517
|
-
* - Public API: TapKitInitParams.container
|
|
2518
|
-
* - Internal: Container class configuration
|
|
2519
|
-
* - Protocol: ConfigUpdateMessage.container mirrors this structure
|
|
2520
|
-
*
|
|
2521
|
-
* When modifying this type, also update ConfigUpdateMessage.container in @coxwave/tap-messages
|
|
2522
|
-
*
|
|
2523
|
-
* @example
|
|
2524
|
-
* // Custom styling for floating/sidebar modes
|
|
2525
|
-
* const config: ContainerConfig = {
|
|
2526
|
-
* floatingConfig: { width: "400px", position: { top: "80px" } },
|
|
2527
|
-
* sidebarConfig: { maxWidth: "800px" }
|
|
2528
|
-
* }
|
|
2529
|
-
*/
|
|
2530
|
-
type ContainerConfig = {
|
|
2531
|
-
/** Floating layout configuration (applied when SDK auto-creates container in floating layout) */
|
|
2532
|
-
floatingConfig?: FloatingConfig;
|
|
2533
|
-
/** Sidebar layout configuration (applied when SDK auto-creates container in sidebar layout) */
|
|
2534
|
-
sidebarConfig?: SidebarConfig;
|
|
2535
|
-
};
|
|
2536
|
-
|
|
2537
2659
|
/**
|
|
2538
2660
|
* Type declarations for <tap-button> Web Component
|
|
2539
2661
|
*
|
|
@@ -2834,6 +2956,167 @@ interface TapContainerAttributes {
|
|
|
2834
2956
|
onDestroy?: () => void;
|
|
2835
2957
|
}
|
|
2836
2958
|
|
|
2959
|
+
/**
|
|
2960
|
+
* Type declarations for <tap-html-viewer> Web Component
|
|
2961
|
+
*
|
|
2962
|
+
* Provides TypeScript support for using <tap-html-viewer> in JSX/TSX.
|
|
2963
|
+
* The actual Web Component is registered by tap-kit-core when loaded.
|
|
2964
|
+
*/
|
|
2965
|
+
|
|
2966
|
+
|
|
2967
|
+
|
|
2968
|
+
// React 19 requires module augmentation based on tsconfig jsx setting
|
|
2969
|
+
// - "jsx": "react-jsx" → augment "react/jsx-runtime"
|
|
2970
|
+
// - "jsx": "preserve" → augment "react" (Next.js default)
|
|
2971
|
+
|
|
2972
|
+
// For Next.js (jsx: preserve)
|
|
2973
|
+
declare module "react" {
|
|
2974
|
+
namespace JSX {
|
|
2975
|
+
interface IntrinsicElements {
|
|
2976
|
+
"tap-html-viewer": TapHtmlViewerAttributes;
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
// For CRA, Vite (jsx: react-jsx)
|
|
2982
|
+
declare module "react/jsx-runtime" {
|
|
2983
|
+
namespace JSX {
|
|
2984
|
+
interface IntrinsicElements {
|
|
2985
|
+
"tap-html-viewer": TapHtmlViewerAttributes;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
/**
|
|
2991
|
+
* Configuration for opening HTML viewer
|
|
2992
|
+
*/
|
|
2993
|
+
interface HtmlViewConfig {
|
|
2994
|
+
/**
|
|
2995
|
+
* URL to load HTML content from (uses iframe src)
|
|
2996
|
+
*/
|
|
2997
|
+
htmlUrl?: string;
|
|
2998
|
+
|
|
2999
|
+
/**
|
|
3000
|
+
* HTML string to render directly (uses iframe srcdoc)
|
|
3001
|
+
*/
|
|
3002
|
+
htmlContent?: string;
|
|
3003
|
+
|
|
3004
|
+
/**
|
|
3005
|
+
* Optional title for the viewer header
|
|
3006
|
+
*/
|
|
3007
|
+
title?: string;
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
/**
|
|
3011
|
+
* Public API interface for TapHtmlViewerElement Web Component
|
|
3012
|
+
*
|
|
3013
|
+
* This interface defines the contract that tap-kit-core's TapHtmlViewerElement must implement.
|
|
3014
|
+
* It provides type-safe access to the Web Component's public API.
|
|
3015
|
+
*
|
|
3016
|
+
* The HTML viewer displays HTML content in a sandboxed iframe overlay
|
|
3017
|
+
* positioned relative to a container element.
|
|
3018
|
+
*/
|
|
3019
|
+
interface ITapHtmlViewerElement extends HTMLElement {
|
|
3020
|
+
/**
|
|
3021
|
+
* Container element reference for positioning
|
|
3022
|
+
* Must be set before calling open()
|
|
3023
|
+
*/
|
|
3024
|
+
containerElement: HTMLElement | null;
|
|
3025
|
+
|
|
3026
|
+
/**
|
|
3027
|
+
* Open HTML viewer with configuration
|
|
3028
|
+
*
|
|
3029
|
+
* Displays HTML content in a sandboxed iframe overlay.
|
|
3030
|
+
* Content source: htmlUrl (external) or htmlContent (inline).
|
|
3031
|
+
*
|
|
3032
|
+
* @param config - HTML view configuration
|
|
3033
|
+
* @fires open - When viewer is successfully displayed
|
|
3034
|
+
*/
|
|
3035
|
+
open(config: HtmlViewConfig): void;
|
|
3036
|
+
|
|
3037
|
+
/**
|
|
3038
|
+
* Close HTML viewer and cleanup
|
|
3039
|
+
*
|
|
3040
|
+
* Hides overlay and resets state.
|
|
3041
|
+
*
|
|
3042
|
+
* @fires close - When viewer is closed
|
|
3043
|
+
*/
|
|
3044
|
+
close(): void;
|
|
3045
|
+
|
|
3046
|
+
/**
|
|
3047
|
+
* Update overlay position relative to container
|
|
3048
|
+
*
|
|
3049
|
+
* Automatically called on container resize/move.
|
|
3050
|
+
* Can be manually triggered if needed.
|
|
3051
|
+
*/
|
|
3052
|
+
updatePosition(): void;
|
|
3053
|
+
|
|
3054
|
+
/**
|
|
3055
|
+
* Hide overlay without closing viewer
|
|
3056
|
+
*
|
|
3057
|
+
* Called when container is hidden. Preserves viewer state
|
|
3058
|
+
* so it can be shown again when container becomes visible.
|
|
3059
|
+
*/
|
|
3060
|
+
hideOverlay(): void;
|
|
3061
|
+
|
|
3062
|
+
/**
|
|
3063
|
+
* Show overlay (if viewer has content)
|
|
3064
|
+
*
|
|
3065
|
+
* Called when container is shown. Only displays overlay
|
|
3066
|
+
* if viewer has content loaded.
|
|
3067
|
+
*/
|
|
3068
|
+
showOverlay(): void;
|
|
3069
|
+
|
|
3070
|
+
/**
|
|
3071
|
+
* Check if viewer is currently visible
|
|
3072
|
+
*
|
|
3073
|
+
* @returns true if visible, false otherwise
|
|
3074
|
+
*/
|
|
3075
|
+
readonly isVisible: boolean;
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
/**
|
|
3079
|
+
* Props/Attributes for <tap-html-viewer> Web Component
|
|
3080
|
+
*/
|
|
3081
|
+
interface TapHtmlViewerAttributes {
|
|
3082
|
+
/**
|
|
3083
|
+
* Element ID attribute
|
|
3084
|
+
*/
|
|
3085
|
+
id?: string;
|
|
3086
|
+
|
|
3087
|
+
/**
|
|
3088
|
+
* CSS class name(s)
|
|
3089
|
+
*/
|
|
3090
|
+
className?: string;
|
|
3091
|
+
|
|
3092
|
+
/**
|
|
3093
|
+
* Container element reference for positioning
|
|
3094
|
+
* Required before calling open()
|
|
3095
|
+
*/
|
|
3096
|
+
containerElement?: HTMLElement | null;
|
|
3097
|
+
|
|
3098
|
+
/**
|
|
3099
|
+
* Child content (not typically used for tap-html-viewer)
|
|
3100
|
+
* The component automatically creates overlay content
|
|
3101
|
+
*/
|
|
3102
|
+
children?: ReactNode;
|
|
3103
|
+
|
|
3104
|
+
/**
|
|
3105
|
+
* Custom inline styles
|
|
3106
|
+
*/
|
|
3107
|
+
style?: CSSProperties;
|
|
3108
|
+
|
|
3109
|
+
/**
|
|
3110
|
+
* Event handler for when viewer is successfully displayed
|
|
3111
|
+
*/
|
|
3112
|
+
onOpen?: () => void;
|
|
3113
|
+
|
|
3114
|
+
/**
|
|
3115
|
+
* Event handler for when viewer is closed
|
|
3116
|
+
*/
|
|
3117
|
+
onClose?: () => void;
|
|
3118
|
+
}
|
|
3119
|
+
|
|
2837
3120
|
/**
|
|
2838
3121
|
* TapKit Web Component Type Definitions
|
|
2839
3122
|
*
|
|
@@ -2859,7 +3142,22 @@ interface EventManager {
|
|
|
2859
3142
|
* VideoController type (matches TapKitInstance.video)
|
|
2860
3143
|
*/
|
|
2861
3144
|
interface VideoController {
|
|
2862
|
-
|
|
3145
|
+
/**
|
|
3146
|
+
* Bind video player for timeline synchronization
|
|
3147
|
+
*
|
|
3148
|
+
* @param config - HTMLVideoElement or VideoPlayerAdapter
|
|
3149
|
+
* @param clipId - Optional clipId. If not provided, uses SDK config (auto-tracks changes from setCourse)
|
|
3150
|
+
*
|
|
3151
|
+
* @example
|
|
3152
|
+
* ```typescript
|
|
3153
|
+
* // Auto-tracking (recommended) - clipId syncs with setCourse()
|
|
3154
|
+
* kit.video.bind(videoElement);
|
|
3155
|
+
*
|
|
3156
|
+
* // Manual clipId (for special cases)
|
|
3157
|
+
* kit.video.bind(videoElement, 'specific-clip-id');
|
|
3158
|
+
* ```
|
|
3159
|
+
*/
|
|
3160
|
+
bind: (config: VideoPlayerConfig, clipId?: string) => void;
|
|
2863
3161
|
unbind: () => void;
|
|
2864
3162
|
}
|
|
2865
3163
|
|
|
@@ -3342,6 +3640,28 @@ interface TapMaterialViewerAttributes {
|
|
|
3342
3640
|
|
|
3343
3641
|
|
|
3344
3642
|
declare global {
|
|
3643
|
+
/**
|
|
3644
|
+
* TapKit CustomEvent types for document.addEventListener
|
|
3645
|
+
*
|
|
3646
|
+
* @example
|
|
3647
|
+
* ```typescript
|
|
3648
|
+
* document.addEventListener('tapkit:ready', (e) => {
|
|
3649
|
+
* console.log(e.detail.gaId); // Type-safe!
|
|
3650
|
+
* });
|
|
3651
|
+
*
|
|
3652
|
+
* document.addEventListener('tapkit:timeline:seek', (e) => {
|
|
3653
|
+
* videoElement.currentTime = e.detail.clipPlayHead; // Type-safe!
|
|
3654
|
+
* });
|
|
3655
|
+
* ```
|
|
3656
|
+
*/
|
|
3657
|
+
interface DocumentEventMap {
|
|
3658
|
+
"tapkit:ready": TapKitReadyEvent;
|
|
3659
|
+
"tapkit:close": TapKitCloseEvent;
|
|
3660
|
+
"tapkit:timeline:seek": TapKitTimelineSeekEvent;
|
|
3661
|
+
"tapkit:material:view:open": TapKitMaterialViewOpenEvent;
|
|
3662
|
+
"tapkit:material:view:close": TapKitMaterialViewCloseEvent;
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3345
3665
|
interface Window {
|
|
3346
3666
|
TapKit?: TapKitConstructor;
|
|
3347
3667
|
createTapKit?: (config: {
|
|
@@ -3381,4 +3701,4 @@ declare global {
|
|
|
3381
3701
|
function cancelIdleCallback(handle: number): void;
|
|
3382
3702
|
}
|
|
3383
3703
|
|
|
3384
|
-
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 };
|
|
3704
|
+
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 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, TAP_BUTTON_CLICK_EVENT, TAP_ERROR_MARKER, type TapButtonAttributes, type TapButtonClickEventDetail, type TapCloseMessage, TapCloseSchema, type TapContainerAttributes, type TapErrorOptions, type TapHtmlViewerAttributes, 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 };
|
package/dist/index.js
CHANGED
|
@@ -158,7 +158,7 @@ var MaterialViewerError = class _MaterialViewerError extends TapKitError {
|
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
// src/protocol/alarm.ts
|
|
161
|
-
var ALARM_DURATION =
|
|
161
|
+
var ALARM_DURATION = 16e3;
|
|
162
162
|
|
|
163
163
|
// ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.9.2/node_modules/valibot/dist/index.js
|
|
164
164
|
var store;
|
|
@@ -819,6 +819,15 @@ var MaterialViewErrorSchema = object({
|
|
|
819
819
|
]),
|
|
820
820
|
message: optional(string())
|
|
821
821
|
});
|
|
822
|
+
var HtmlViewOpenSchema = object({
|
|
823
|
+
type: literal("html:view:open"),
|
|
824
|
+
htmlUrl: optional(string()),
|
|
825
|
+
htmlContent: optional(string()),
|
|
826
|
+
title: optional(string())
|
|
827
|
+
});
|
|
828
|
+
var HtmlViewCloseSchema = object({
|
|
829
|
+
type: literal("html:view:close")
|
|
830
|
+
});
|
|
822
831
|
var ContainerModeChangeSchema = object({
|
|
823
832
|
type: literal("container:mode:change"),
|
|
824
833
|
mode: union([literal("floating"), literal("sidebar")]),
|
|
@@ -908,6 +917,8 @@ var TapMessageSchema = union([
|
|
|
908
917
|
MaterialViewOpenSchema,
|
|
909
918
|
MaterialViewCloseSchema,
|
|
910
919
|
MaterialViewErrorSchema,
|
|
920
|
+
HtmlViewOpenSchema,
|
|
921
|
+
HtmlViewCloseSchema,
|
|
911
922
|
ContainerModeChangeSchema,
|
|
912
923
|
ContainerModeChangeAckSchema,
|
|
913
924
|
ContainerLayoutStateChangedSchema,
|
|
@@ -919,6 +930,6 @@ var TapMessageSchema = union([
|
|
|
919
930
|
// src/tap-button.d.ts
|
|
920
931
|
var TAP_BUTTON_CLICK_EVENT = "tap-button:click";
|
|
921
932
|
|
|
922
|
-
export { ALARM_DURATION, AlarmClickSchema, AlarmElementPropsSchema, AlarmElementSchema, AlarmFadeInSchema, AlarmMessageInstanceSchema, CSSStyleSchema, ConfigUpdateSchema, ContainerLayoutStateChangedSchema, ContainerModeChangeAckSchema, ContainerModeChangeSchema, GAEventSchema, TapKitInitializationError as InitializationError, MaterialViewCloseSchema, MaterialViewErrorSchema, MaterialViewOpenSchema, MaterialViewerError, PopUpCloseSchema, PopUpOpenSchema, TAP_BUTTON_CLICK_EVENT, TAP_ERROR_MARKER, TapCloseSchema, TapKitConfigurationError, TapKitError, TapKitIframeError, TapKitInitializationError, TapKitLoaderError, TapKitMessageError, TapMessageSchema, TapReadySchema, TimelineSeekSchema, ViewportResizeSchema };
|
|
933
|
+
export { ALARM_DURATION, AlarmClickSchema, AlarmElementPropsSchema, AlarmElementSchema, AlarmFadeInSchema, AlarmMessageInstanceSchema, CSSStyleSchema, ConfigUpdateSchema, ContainerLayoutStateChangedSchema, ContainerModeChangeAckSchema, ContainerModeChangeSchema, GAEventSchema, HtmlViewCloseSchema, HtmlViewOpenSchema, TapKitInitializationError as InitializationError, MaterialViewCloseSchema, MaterialViewErrorSchema, MaterialViewOpenSchema, MaterialViewerError, PopUpCloseSchema, PopUpOpenSchema, TAP_BUTTON_CLICK_EVENT, TAP_ERROR_MARKER, TapCloseSchema, TapKitConfigurationError, TapKitError, TapKitIframeError, TapKitInitializationError, TapKitLoaderError, TapKitMessageError, TapMessageSchema, TapReadySchema, TimelineSeekSchema, ViewportResizeSchema };
|
|
923
934
|
//# sourceMappingURL=index.js.map
|
|
924
935
|
//# sourceMappingURL=index.js.map
|