@coxwave/tap-kit-types 2.0.6 → 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.
Files changed (2) hide show
  1. package/dist/index.d.ts +103 -23
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -2328,23 +2328,49 @@ type TapKitConfig = {
2328
2328
  apiKey: string;
2329
2329
  };
2330
2330
  /**
2331
- * Runtime configuration sent to iframe via config:update message
2332
- * Derived from ConfigUpdateMessage protocol (without 'type' field)
2333
- * 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
+ * =============================================================================
2334
2349
  */
2335
- type TapKitRuntimeConfig = Omit<ConfigUpdateMessage, "type">;
2336
2350
  /**
2337
- * All SDK Configuration Options (Internal API)
2338
- * Derived from ConfigUpdateMessage protocol for type consistency
2339
- * Used by Symbol-based config() method for advanced configuration
2340
- *
2341
- * Note: All fields (tapUrl, environment, etc.) are now part of TapKitRuntimeConfig
2342
- * which is based on ConfigUpdateMessage. This ensures consistency between
2343
- * 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 배열의 타입 제약으로 사용
2344
2367
  *
2345
- * @internal This is not part of the public API
2368
+ * 제외 항목:
2369
+ * - apiKey: 초기화 시에만 설정
2370
+ * - hostOrigin: 자동 감지
2371
+ * - tapUrl: 초기화 시에만 설정
2346
2372
  */
2347
- type TapKitConfigOptions = TapKitRuntimeConfig;
2373
+ type SyncableConfigKey = Exclude<ConfigUpdateKey, "apiKey" | "hostOrigin" | "tapUrl">;
2348
2374
  /**
2349
2375
  * Course Information
2350
2376
  */
@@ -2630,8 +2656,13 @@ interface TapKitInstance {
2630
2656
  onAlarmFadeIn: (handler: (messageInfo: AlarmMessageInstanceType) => void) => () => void;
2631
2657
  };
2632
2658
  video: {
2633
- /** Bind video player for timeline synchronization */
2634
- 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;
2635
2666
  /** Unbind current video player */
2636
2667
  unbind: () => void;
2637
2668
  };
@@ -3229,11 +3260,55 @@ interface TapKitElement extends HTMLElement {
3229
3260
  mode?: "inline" | "floating" | "sidebar";
3230
3261
 
3231
3262
  /**
3232
- * Auto-created flag (internal use only)
3233
- * Indicates SDK-controlled element (used by legacy TapKit class)
3234
- * @internal
3263
+ * Allow user to toggle between floating and sidebar layouts
3264
+ * Only applies when mode is "floating" or "sidebar"
3265
+ * @default true
3266
+ */
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
+ * ```
3235
3310
  */
3236
- autoCreated?: boolean;
3311
+ root?: HTMLElement;
3237
3312
 
3238
3313
  // ===== Public Methods (Imperative API) =====
3239
3314
 
@@ -3387,9 +3462,6 @@ interface TapKitAttributes {
3387
3462
  /** Custom button element ID */
3388
3463
  "button-id"?: string;
3389
3464
 
3390
- /** Custom container element ID */
3391
- "container-id"?: string;
3392
-
3393
3465
  /** Enable debug mode */
3394
3466
  debug?: boolean;
3395
3467
 
@@ -3401,6 +3473,12 @@ interface TapKitAttributes {
3401
3473
  */
3402
3474
  mode?: "inline" | "floating" | "sidebar";
3403
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
+
3404
3482
  /** Custom inline styles */
3405
3483
  style?: CSSProperties;
3406
3484
 
@@ -3529,6 +3607,8 @@ interface ITapMaterialViewerElement extends HTMLElement {
3529
3607
  * Downloads PDF from presigned URL, extracts specified pages,
3530
3608
  * and displays in an overlay positioned relative to containerElement.
3531
3609
  *
3610
+ * Note: For HTML content, use TapHtmlViewerElement instead (Separation of Concerns).
3611
+ *
3532
3612
  * @param config - Material view configuration
3533
3613
  * @throws {MaterialViewerError} If PDF fetch or processing fails
3534
3614
  * @fires error - When material loading fails
@@ -3701,4 +3781,4 @@ declare global {
3701
3781
  function cancelIdleCallback(handle: number): void;
3702
3782
  }
3703
3783
 
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 };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coxwave/tap-kit-types",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "type": "module",
5
5
  "description": "Shared TypeScript types for TapKit SDK packages",
6
6
  "main": "dist/index.js",