@coxwave/tap-kit-types 0.0.50 → 0.0.52

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 +155 -28
  2. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -7,6 +7,14 @@ interface AlarmMessageInstanceType {
7
7
  priority: number;
8
8
  }
9
9
 
10
+ /**
11
+ * Config Update Message (parent → iframe)
12
+ *
13
+ * IMPORTANT: container field mirrors ContainerConfig from @coxwave/tap-kit-types
14
+ * - SSOT: @coxwave/tap-kit-types/src/styles.ts (ContainerConfig)
15
+ * - This message protocol mirrors the structure for serialization
16
+ * - When updating ContainerConfig, update this structure accordingly
17
+ */
10
18
  interface ConfigUpdateMessage {
11
19
  type: "config:update";
12
20
  apiKey?: string;
@@ -19,8 +27,33 @@ interface ConfigUpdateMessage {
19
27
  courseId?: string;
20
28
  clipId?: string;
21
29
  clipPlayHead?: number;
30
+ /**
31
+ * Container configuration (mirrors ContainerConfig from @coxwave/tap-kit-types)
32
+ *
33
+ * Structure:
34
+ * - mode: "auto" (default) | "floating" | "sidebar"
35
+ * - floatingConfig: { position, width, height, borderRadius }
36
+ * - sidebarConfig: { maxWidth, minViewportWidth }
37
+ *
38
+ * @see ContainerConfig in @coxwave/tap-kit-types
39
+ */
22
40
  container?: {
23
- disableSidebar?: boolean;
41
+ mode?: "auto" | "floating" | "sidebar";
42
+ floatingConfig?: {
43
+ position?: {
44
+ top?: string;
45
+ left?: string;
46
+ right?: string;
47
+ bottom?: string;
48
+ };
49
+ width?: string;
50
+ height?: string;
51
+ borderRadius?: string;
52
+ };
53
+ sidebarConfig?: {
54
+ maxWidth?: string;
55
+ minViewportWidth?: number;
56
+ };
24
57
  };
25
58
  }
26
59
 
@@ -34,41 +67,104 @@ type PositionType = {
34
67
  bottom?: string;
35
68
  };
36
69
  /**
37
- * Container Mode
38
- * - floating: Floating positioned container (default)
39
- * - sidebar: Fixed sidebar positioned at the right edge
70
+ * Container Layout State (SSOT - Visual State)
71
+ *
72
+ * This is the SINGLE SOURCE OF TRUTH for container visual state.
73
+ * Managed by Container class (tap-kit-core), streamed to iframe via messages.
74
+ *
75
+ * - floating: User-chosen floating layout
76
+ * - sidebar: User-chosen sidebar layout
77
+ * - floating-forced: Forced floating due to narrow viewport (sidebar unavailable)
78
+ *
79
+ * Both tap-kit-core (Container) and edutap (UIConfigStore) use this type.
80
+ * iframe receives this as read-only shadow state via container:layout:state:changed message.
40
81
  */
41
- type ContainerMode = "floating" | "sidebar";
82
+ type ContainerLayoutState = "floating" | "sidebar" | "floating-forced";
83
+ /**
84
+ * Container Mode (Behavior Configuration)
85
+ *
86
+ * Controls toggle button visibility and layout persistence:
87
+ * - auto: User can toggle between layouts, remembers preference via localStorage (DEFAULT)
88
+ * - floating: Fixed in floating layout, no toggle button, no persistence
89
+ * - sidebar: Fixed in sidebar layout, no toggle button, no persistence
90
+ */
91
+ type ContainerMode = "auto" | "floating" | "sidebar";
92
+ /**
93
+ * Floating mode configuration
94
+ * Includes position, size, and style settings for floating container
95
+ */
96
+ type FloatingConfig = {
97
+ /** Position (default: top: "50px", right: "24px") */
98
+ position?: PositionType;
99
+ /** Width (default: "340px") */
100
+ width?: string;
101
+ /** Height (default: "calc(100% - 116px)") */
102
+ height?: string;
103
+ /** Border radius (default: "16px") */
104
+ borderRadius?: string;
105
+ };
42
106
  /**
43
107
  * Sidebar Configuration
44
108
  */
45
109
  type SidebarConfig = {
46
- /** Width of the sidebar (default: "max(15%, 400px)") */
47
- width?: string;
110
+ /** Maximum width of the sidebar (default: "min(50%, 600px)") */
111
+ maxWidth?: string;
48
112
  /** Minimum viewport width to enable sidebar mode (default: 768) */
49
113
  minViewportWidth?: number;
50
114
  };
51
115
  /**
52
- * Container Styling
116
+ * Container Configuration (SSOT - Type Level)
117
+ *
118
+ * This is the SINGLE SOURCE OF TRUTH for container configuration at the TYPE level.
119
+ * - Public API: TapKitInitParams.container
120
+ * - Internal: Container class configuration
121
+ * - Protocol: ConfigUpdateMessage.container mirrors this structure
122
+ *
123
+ * When modifying this type, also update ConfigUpdateMessage.container in @coxwave/tap-messages
124
+ *
125
+ * @example
126
+ * // Default: Auto mode with floating layout (toggle button visible)
127
+ * const config: ContainerConfig = {}
128
+ *
129
+ * @example
130
+ * // Auto mode with custom styling for both layouts
131
+ * const config: ContainerConfig = {
132
+ * floatingConfig: { width: "400px", position: { top: "80px" } },
133
+ * sidebarConfig: { maxWidth: "600px" }
134
+ * }
135
+ *
136
+ * @example
137
+ * // Fixed floating mode (no toggle button)
138
+ * const config: ContainerConfig = {
139
+ * mode: "floating",
140
+ * floatingConfig: { position: { top: "80px" }, width: "400px" }
141
+ * }
142
+ *
143
+ * @example
144
+ * // Fixed sidebar mode (no toggle button)
145
+ * const config: ContainerConfig = {
146
+ * mode: "sidebar",
147
+ * sidebarConfig: { maxWidth: "500px" }
148
+ * }
53
149
  */
54
- type ContainerStyle = {
55
- /** Container mode (default: "floating") */
150
+ type ContainerConfig = {
151
+ /**
152
+ * Container mode controls toggle button visibility and behavior
153
+ * - "auto" (default): User can toggle between layouts, starts in floating, remembers preference via localStorage
154
+ * - "floating": Fixed in floating layout, no toggle button
155
+ * - "sidebar": Fixed in sidebar layout, no toggle button
156
+ */
56
157
  mode?: ContainerMode;
57
- /** Sidebar configuration (only applicable when mode is "sidebar") */
158
+ /** Floating layout configuration (applied when in floating layout) */
159
+ floatingConfig?: FloatingConfig;
160
+ /** Sidebar layout configuration (applied when in sidebar layout) */
58
161
  sidebarConfig?: SidebarConfig;
59
- /** Position (only applicable when mode is "floating") */
60
- position?: PositionType;
61
- /** Width (only applicable when mode is "floating") */
62
- width?: string;
63
- /** Height (only applicable when mode is "floating") */
64
- height?: string;
65
- /** Border radius */
66
- borderRadius?: string;
67
162
  };
163
+
68
164
  /**
69
- * Flattened container styles (backward compatibility)
165
+ * Core Configuration Types
166
+ * Based on ConfigUpdateMessage protocol for type consistency (SSOT)
70
167
  */
71
- type CustomStyles = ContainerStyle;
72
168
 
73
169
  /**
74
170
  * SDK Configuration (Public API)
@@ -77,7 +173,7 @@ type CustomStyles = ContainerStyle;
77
173
  * Default values:
78
174
  * - tapUrl: https://edutap-ai.vercel.app
79
175
  * - apiUrl: https://tapapi.coxwave.link
80
- * - environment: local (console logging enabled)
176
+ * - environment: dev (console logging enabled)
81
177
  */
82
178
  type TapKitConfig = {
83
179
  apiKey: string;
@@ -87,7 +183,7 @@ type TapKitConfig = {
87
183
  * Derived from ConfigUpdateMessage protocol (without 'type' field)
88
184
  * This ensures type consistency between iframe messages and config
89
185
  */
90
- type TapKitRuntimeConfig = Omit<ConfigUpdateMessage, 'type'>;
186
+ type TapKitRuntimeConfig = Omit<ConfigUpdateMessage, "type">;
91
187
  /**
92
188
  * All SDK Configuration Options (Internal API)
93
189
  * Derived from ConfigUpdateMessage protocol for type consistency
@@ -111,14 +207,45 @@ type Course = {
111
207
  };
112
208
  /**
113
209
  * SDK Initialization Parameters
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const sdk = new TapSDK({ apiKey: "your-key" });
214
+ *
215
+ * // Minimal initialization (uses all defaults)
216
+ * await sdk.init({
217
+ * buttonId: "tap-button",
218
+ * course: { userId: "user1", courseId: "course1", clipId: "clip1" }
219
+ * });
220
+ *
221
+ * // Custom floating container
222
+ * await sdk.init({
223
+ * buttonId: "tap-button",
224
+ * course: { userId: "user1", courseId: "course1", clipId: "clip1" },
225
+ * container: {
226
+ * mode: "floating",
227
+ * position: { top: "80px", right: "32px" },
228
+ * width: "400px",
229
+ * disableSidebar: true // Prevent user from switching to sidebar
230
+ * }
231
+ * });
232
+ *
233
+ * // Sidebar mode with custom width
234
+ * await sdk.init({
235
+ * buttonId: "tap-button",
236
+ * course: { userId: "user1", courseId: "course1", clipId: "clip1" },
237
+ * container: {
238
+ * mode: "sidebar",
239
+ * sidebarConfig: { width: "600px", minViewportWidth: 1024 }
240
+ * }
241
+ * });
242
+ * ```
114
243
  */
115
244
  type TapKitInitParams = {
116
245
  buttonId: string;
117
246
  course: Course;
118
- container?: ContainerStyle & {
119
- /** Disable sidebar mode toggle (sidebar mode will not be available) */
120
- disableSidebar?: boolean;
121
- };
247
+ /** Container configuration (optional, uses defaults if omitted) */
248
+ container?: ContainerConfig;
122
249
  };
123
250
 
124
251
  /**
@@ -257,4 +384,4 @@ declare global {
257
384
  function cancelIdleCallback(handle: number): void;
258
385
  }
259
386
 
260
- export { type AlarmMessageInstanceType, type AlarmType, type ContainerMode, type ContainerStyle, type ContainerVisibility, type Course, type CustomStyles, TapKitInitializationError as InitializationError, type PositionType, type SeekTimelineParamsType, type ShortcutKeyPropertiesType, type SidebarConfig, TAPKIT_CONFIG_SYMBOL, TAP_ERROR_MARKER, type TapErrorOptions, type TapKitConfig, type TapKitConfigOptions, TapKitConfigurationError, type TapKitConstructor, TapKitError, TapKitIframeError, type TapKitInitParams, TapKitInitializationError, type TapKitInstance, TapKitLoaderError, TapKitMessageError, type TapKitRuntimeConfig };
387
+ export { type AlarmMessageInstanceType, type AlarmType, type ContainerConfig, type ContainerLayoutState, type ContainerMode, type ContainerVisibility, type Course, type FloatingConfig, TapKitInitializationError as InitializationError, type PositionType, type SeekTimelineParamsType, type ShortcutKeyPropertiesType, type SidebarConfig, TAPKIT_CONFIG_SYMBOL, TAP_ERROR_MARKER, type TapErrorOptions, type TapKitConfig, type TapKitConfigOptions, TapKitConfigurationError, type TapKitConstructor, TapKitError, TapKitIframeError, type TapKitInitParams, TapKitInitializationError, type TapKitInstance, TapKitLoaderError, TapKitMessageError, type TapKitRuntimeConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coxwave/tap-kit-types",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "type": "module",
5
5
  "description": "Shared TypeScript types for TapKit SDK packages",
6
6
  "main": "dist/index.js",
@@ -23,9 +23,9 @@
23
23
  ],
24
24
  "devDependencies": {
25
25
  "tsup": "^8.5.0",
26
- "@coxwave/config-typescript": "1.0.0",
26
+ "@coxwave/config-eslint": "1.0.0",
27
27
  "@coxwave/tap-messages": "0.0.1",
28
- "@coxwave/config-eslint": "1.0.0"
28
+ "@coxwave/config-typescript": "1.0.0"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "tsup",