@coxwave/tap-kit-types 0.0.63 → 1.0.3

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
@@ -1,3 +1,4 @@
1
+ import * as v from 'valibot';
1
2
  import { ReactNode, CSSProperties } from 'react';
2
3
 
3
4
  type AlarmType = "quiz" | "pingMessage" | "callToAction" | "hourSpent" | "default";
@@ -9,6 +10,108 @@ interface AlarmMessageInstanceType {
9
10
  priority: number;
10
11
  }
11
12
 
13
+ type TapMessageType = "tap:ready" | "tap:close" | "timeline:seek" | "alarm:click" | "alarm:fadeIn" | "popUp:open" | "popUp:close" | "container:expand" | "container:collapse" | "container:mode:change" | "container:mode:change:ack" | "container:layout:state:changed" | "viewport:resize" | "config:update" | "GA_EVENT";
14
+ type TapMessage = TapReadyMessage | TapCloseMessage | TimelineSeekMessage | AlarmClickMessage | AlarmFadeInMessage | PopUpOpenMessage | PopUpCloseMessage | ContainerExpandMessage | ContainerCollapseMessage | ContainerModeChangeMessage | ContainerModeChangeAckMessage | ContainerLayoutStateChangedMessage | ViewportResizeMessage | ConfigUpdateMessage | GAEventMessage;
15
+ interface TapReadyMessage {
16
+ type: "tap:ready";
17
+ gaId: string;
18
+ }
19
+ interface TapCloseMessage {
20
+ type: "tap:close";
21
+ }
22
+ interface TimelineSeekMessage {
23
+ type: "timeline:seek";
24
+ clipId: string;
25
+ clipPlayHead: number;
26
+ }
27
+ interface AlarmClickMessage {
28
+ type: "alarm:click";
29
+ messageInfo: AlarmMessageInstanceType;
30
+ }
31
+ interface AlarmFadeInMessage {
32
+ type: "alarm:fadeIn";
33
+ messageInfo: AlarmMessageInstanceType;
34
+ }
35
+ interface PopUpOpenMessage {
36
+ type: "popUp:open";
37
+ popUpInfo: {
38
+ html: string;
39
+ requestId?: string;
40
+ };
41
+ }
42
+ interface PopUpCloseMessage {
43
+ type: "popUp:close";
44
+ }
45
+ /**
46
+ * Container Expand Request (iframe → parent, call/handle pattern)
47
+ * Requests parent to enlarge iframe container for PDF full-screen view
48
+ *
49
+ * Response type (container:expand:ack) is auto-generated by iframe-messenger
50
+ */
51
+ interface ContainerExpandMessage {
52
+ type: "container:expand";
53
+ nonce?: string | number;
54
+ }
55
+ /**
56
+ * Container Collapse Request (iframe → parent, call/handle pattern)
57
+ * Requests parent to restore iframe container to normal size
58
+ *
59
+ * Response type (container:collapse:ack) is auto-generated by iframe-messenger
60
+ */
61
+ interface ContainerCollapseMessage {
62
+ type: "container:collapse";
63
+ nonce?: string | number;
64
+ }
65
+ /**
66
+ * Container Mode Change Request (iframe → parent, call/handle pattern)
67
+ *
68
+ * Request to change container layout state between floating and sidebar.
69
+ * Only "floating" and "sidebar" allowed (user-triggered).
70
+ * "floating-forced" is managed by parent automatically (viewport resize).
71
+ */
72
+ interface ContainerModeChangeMessage {
73
+ type: "container:mode:change";
74
+ mode: "floating" | "sidebar";
75
+ nonce?: string | number;
76
+ }
77
+ /**
78
+ * Container Mode Change Response (parent → iframe, call/handle pattern)
79
+ *
80
+ * Automatic response with nonce echo-back.
81
+ * Returns current layout state including "floating-forced".
82
+ */
83
+ interface ContainerModeChangeAckMessage {
84
+ type: "container:mode:change:ack";
85
+ success: boolean;
86
+ currentMode: "floating" | "sidebar" | "floating-forced";
87
+ nonce?: string | number;
88
+ }
89
+ /**
90
+ * Container Layout State Changed (parent → iframe, stream pattern)
91
+ *
92
+ * Streams layout state changes from Container (SSOT) to iframe (shadow state).
93
+ * iframe MUST NOT modify layoutState directly - it's read-only.
94
+ *
95
+ * Sent when:
96
+ * - User toggles layout via LayoutToggleButton (iframe → parent → iframe)
97
+ * - Viewport resize forces floating mode (parent only)
98
+ * - Parent calls Container.setLayoutState programmatically
99
+ *
100
+ * @see ContainerLayoutState in @coxwave/tap-kit-types
101
+ */
102
+ interface ContainerLayoutStateChangedMessage {
103
+ type: "container:layout:state:changed";
104
+ layoutState: "floating" | "sidebar" | "floating-forced";
105
+ }
106
+ /**
107
+ * Viewport Resize Event (parent window → iframe)
108
+ * Streams viewport width from parent window to iframe
109
+ * Allows iframe to make responsive UI decisions based on parent viewport
110
+ */
111
+ interface ViewportResizeMessage {
112
+ type: "viewport:resize";
113
+ viewportWidth: number;
114
+ }
12
115
  /**
13
116
  * Config Update Message (parent → iframe)
14
117
  *
@@ -58,6 +161,219 @@ interface ConfigUpdateMessage {
58
161
  };
59
162
  };
60
163
  }
164
+ /**
165
+ * Google Analytics Event Message (iframe → parent)
166
+ * Sent from edutap iframe to tap-kit-core for analytics tracking
167
+ */
168
+ interface GAEventMessage {
169
+ type: "GA_EVENT";
170
+ payload: Record<string, any>;
171
+ }
172
+
173
+ declare const AlarmTypeSchema: v.UnionSchema<[v.LiteralSchema<"quiz", undefined>, v.LiteralSchema<"pingMessage", undefined>, v.LiteralSchema<"callToAction", undefined>, v.LiteralSchema<"hourSpent", undefined>, v.LiteralSchema<"default", undefined>], undefined>;
174
+ declare const AlarmMessageInstanceSchema: v.ObjectSchema<{
175
+ readonly message: v.StringSchema<undefined>;
176
+ readonly question: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
177
+ readonly pingMessageId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
178
+ readonly type: v.UnionSchema<[v.LiteralSchema<"quiz", undefined>, v.LiteralSchema<"pingMessage", undefined>, v.LiteralSchema<"callToAction", undefined>, v.LiteralSchema<"hourSpent", undefined>, v.LiteralSchema<"default", undefined>], undefined>;
179
+ readonly priority: v.NumberSchema<undefined>;
180
+ }, undefined>;
181
+ declare const TapReadySchema: v.ObjectSchema<{
182
+ readonly type: v.LiteralSchema<"tap:ready", undefined>;
183
+ readonly gaId: v.StringSchema<undefined>;
184
+ }, undefined>;
185
+ declare const TapCloseSchema: v.ObjectSchema<{
186
+ readonly type: v.LiteralSchema<"tap:close", undefined>;
187
+ }, undefined>;
188
+ declare const TimelineSeekSchema: v.ObjectSchema<{
189
+ readonly type: v.LiteralSchema<"timeline:seek", undefined>;
190
+ readonly clipId: v.StringSchema<undefined>;
191
+ readonly clipPlayHead: v.NumberSchema<undefined>;
192
+ }, undefined>;
193
+ declare const AlarmClickSchema: v.ObjectSchema<{
194
+ readonly type: v.LiteralSchema<"alarm:click", undefined>;
195
+ readonly messageInfo: v.ObjectSchema<{
196
+ readonly message: v.StringSchema<undefined>;
197
+ readonly question: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
198
+ readonly pingMessageId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
199
+ readonly type: v.UnionSchema<[v.LiteralSchema<"quiz", undefined>, v.LiteralSchema<"pingMessage", undefined>, v.LiteralSchema<"callToAction", undefined>, v.LiteralSchema<"hourSpent", undefined>, v.LiteralSchema<"default", undefined>], undefined>;
200
+ readonly priority: v.NumberSchema<undefined>;
201
+ }, undefined>;
202
+ }, undefined>;
203
+ declare const AlarmFadeInSchema: v.ObjectSchema<{
204
+ readonly type: v.LiteralSchema<"alarm:fadeIn", undefined>;
205
+ readonly messageInfo: v.ObjectSchema<{
206
+ readonly message: v.StringSchema<undefined>;
207
+ readonly question: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
208
+ readonly pingMessageId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
209
+ readonly type: v.UnionSchema<[v.LiteralSchema<"quiz", undefined>, v.LiteralSchema<"pingMessage", undefined>, v.LiteralSchema<"callToAction", undefined>, v.LiteralSchema<"hourSpent", undefined>, v.LiteralSchema<"default", undefined>], undefined>;
210
+ readonly priority: v.NumberSchema<undefined>;
211
+ }, undefined>;
212
+ }, undefined>;
213
+ declare const PopUpOpenSchema: v.ObjectSchema<{
214
+ readonly type: v.LiteralSchema<"popUp:open", undefined>;
215
+ readonly popUpInfo: v.ObjectSchema<{
216
+ readonly html: v.StringSchema<undefined>;
217
+ readonly requestId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
218
+ }, undefined>;
219
+ }, undefined>;
220
+ declare const PopUpCloseSchema: v.ObjectSchema<{
221
+ readonly type: v.LiteralSchema<"popUp:close", undefined>;
222
+ }, undefined>;
223
+ declare const ContainerExpandSchema: v.ObjectSchema<{
224
+ readonly type: v.LiteralSchema<"container:expand", undefined>;
225
+ readonly nonce: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
226
+ }, undefined>;
227
+ declare const ContainerCollapseSchema: v.ObjectSchema<{
228
+ readonly type: v.LiteralSchema<"container:collapse", undefined>;
229
+ readonly nonce: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
230
+ }, undefined>;
231
+ declare const ContainerModeChangeSchema: v.ObjectSchema<{
232
+ readonly type: v.LiteralSchema<"container:mode:change", undefined>;
233
+ readonly mode: v.UnionSchema<[v.LiteralSchema<"floating", undefined>, v.LiteralSchema<"sidebar", undefined>], undefined>;
234
+ readonly nonce: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
235
+ }, undefined>;
236
+ declare const ContainerModeChangeAckSchema: v.ObjectSchema<{
237
+ readonly type: v.LiteralSchema<"container:mode:change:ack", undefined>;
238
+ readonly success: v.BooleanSchema<undefined>;
239
+ readonly currentMode: v.UnionSchema<[v.LiteralSchema<"floating", undefined>, v.LiteralSchema<"sidebar", undefined>, v.LiteralSchema<"floating-forced", undefined>], undefined>;
240
+ readonly nonce: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
241
+ }, undefined>;
242
+ declare const ContainerLayoutStateChangedSchema: v.ObjectSchema<{
243
+ readonly type: v.LiteralSchema<"container:layout:state:changed", undefined>;
244
+ readonly layoutState: v.UnionSchema<[v.LiteralSchema<"floating", undefined>, v.LiteralSchema<"sidebar", undefined>, v.LiteralSchema<"floating-forced", undefined>], undefined>;
245
+ }, undefined>;
246
+ declare const ViewportResizeSchema: v.ObjectSchema<{
247
+ readonly type: v.LiteralSchema<"viewport:resize", undefined>;
248
+ readonly viewportWidth: v.NumberSchema<undefined>;
249
+ }, undefined>;
250
+ declare const ConfigUpdateSchema: v.ObjectSchema<{
251
+ readonly type: v.LiteralSchema<"config:update", undefined>;
252
+ readonly apiKey: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
253
+ readonly hostOrigin: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
254
+ readonly tapUrl: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
255
+ readonly apiUrl: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
256
+ readonly environment: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"dev", undefined>, v.LiteralSchema<"prod", undefined>, v.LiteralSchema<"demo", undefined>, v.LiteralSchema<"staging", undefined>], undefined>, undefined>;
257
+ readonly language: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
258
+ readonly userId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
259
+ readonly courseId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
260
+ readonly clipId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
261
+ readonly clipPlayHead: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
262
+ readonly container: v.OptionalSchema<v.ObjectSchema<{
263
+ readonly mode: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"auto", undefined>, v.LiteralSchema<"floating", undefined>, v.LiteralSchema<"sidebar", undefined>], undefined>, undefined>;
264
+ readonly floatingConfig: v.OptionalSchema<v.ObjectSchema<{
265
+ readonly position: v.OptionalSchema<v.ObjectSchema<{
266
+ readonly top: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
267
+ readonly left: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
268
+ readonly right: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
269
+ readonly bottom: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
270
+ }, undefined>, undefined>;
271
+ readonly width: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
272
+ readonly height: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
273
+ readonly borderRadius: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
274
+ }, undefined>, undefined>;
275
+ readonly sidebarConfig: v.OptionalSchema<v.ObjectSchema<{
276
+ readonly maxWidth: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
277
+ readonly minViewportWidth: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
278
+ }, undefined>, undefined>;
279
+ }, undefined>, undefined>;
280
+ }, undefined>;
281
+ declare const GAEventSchema: v.ObjectSchema<{
282
+ readonly type: v.LiteralSchema<"GA_EVENT", undefined>;
283
+ readonly payload: v.RecordSchema<v.StringSchema<undefined>, v.AnySchema, undefined>;
284
+ }, undefined>;
285
+ declare const TapMessageSchema: v.UnionSchema<[v.ObjectSchema<{
286
+ readonly type: v.LiteralSchema<"tap:ready", undefined>;
287
+ readonly gaId: v.StringSchema<undefined>;
288
+ }, undefined>, v.ObjectSchema<{
289
+ readonly type: v.LiteralSchema<"tap:close", undefined>;
290
+ }, undefined>, v.ObjectSchema<{
291
+ readonly type: v.LiteralSchema<"timeline:seek", undefined>;
292
+ readonly clipId: v.StringSchema<undefined>;
293
+ readonly clipPlayHead: v.NumberSchema<undefined>;
294
+ }, undefined>, v.ObjectSchema<{
295
+ readonly type: v.LiteralSchema<"alarm:click", undefined>;
296
+ readonly messageInfo: v.ObjectSchema<{
297
+ readonly message: v.StringSchema<undefined>;
298
+ readonly question: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
299
+ readonly pingMessageId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
300
+ readonly type: v.UnionSchema<[v.LiteralSchema<"quiz", undefined>, v.LiteralSchema<"pingMessage", undefined>, v.LiteralSchema<"callToAction", undefined>, v.LiteralSchema<"hourSpent", undefined>, v.LiteralSchema<"default", undefined>], undefined>;
301
+ readonly priority: v.NumberSchema<undefined>;
302
+ }, undefined>;
303
+ }, undefined>, v.ObjectSchema<{
304
+ readonly type: v.LiteralSchema<"alarm:fadeIn", undefined>;
305
+ readonly messageInfo: v.ObjectSchema<{
306
+ readonly message: v.StringSchema<undefined>;
307
+ readonly question: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
308
+ readonly pingMessageId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
309
+ readonly type: v.UnionSchema<[v.LiteralSchema<"quiz", undefined>, v.LiteralSchema<"pingMessage", undefined>, v.LiteralSchema<"callToAction", undefined>, v.LiteralSchema<"hourSpent", undefined>, v.LiteralSchema<"default", undefined>], undefined>;
310
+ readonly priority: v.NumberSchema<undefined>;
311
+ }, undefined>;
312
+ }, undefined>, v.ObjectSchema<{
313
+ readonly type: v.LiteralSchema<"popUp:open", undefined>;
314
+ readonly popUpInfo: v.ObjectSchema<{
315
+ readonly html: v.StringSchema<undefined>;
316
+ readonly requestId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
317
+ }, undefined>;
318
+ }, undefined>, v.ObjectSchema<{
319
+ readonly type: v.LiteralSchema<"popUp:close", undefined>;
320
+ }, undefined>, v.ObjectSchema<{
321
+ readonly type: v.LiteralSchema<"container:expand", undefined>;
322
+ readonly nonce: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
323
+ }, undefined>, v.ObjectSchema<{
324
+ readonly type: v.LiteralSchema<"container:collapse", undefined>;
325
+ readonly nonce: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
326
+ }, undefined>, v.ObjectSchema<{
327
+ readonly type: v.LiteralSchema<"container:mode:change", undefined>;
328
+ readonly mode: v.UnionSchema<[v.LiteralSchema<"floating", undefined>, v.LiteralSchema<"sidebar", undefined>], undefined>;
329
+ readonly nonce: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
330
+ }, undefined>, v.ObjectSchema<{
331
+ readonly type: v.LiteralSchema<"container:mode:change:ack", undefined>;
332
+ readonly success: v.BooleanSchema<undefined>;
333
+ readonly currentMode: v.UnionSchema<[v.LiteralSchema<"floating", undefined>, v.LiteralSchema<"sidebar", undefined>, v.LiteralSchema<"floating-forced", undefined>], undefined>;
334
+ readonly nonce: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
335
+ }, undefined>, v.ObjectSchema<{
336
+ readonly type: v.LiteralSchema<"container:layout:state:changed", undefined>;
337
+ readonly layoutState: v.UnionSchema<[v.LiteralSchema<"floating", undefined>, v.LiteralSchema<"sidebar", undefined>, v.LiteralSchema<"floating-forced", undefined>], undefined>;
338
+ }, undefined>, v.ObjectSchema<{
339
+ readonly type: v.LiteralSchema<"viewport:resize", undefined>;
340
+ readonly viewportWidth: v.NumberSchema<undefined>;
341
+ }, undefined>, v.ObjectSchema<{
342
+ readonly type: v.LiteralSchema<"config:update", undefined>;
343
+ readonly apiKey: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
344
+ readonly hostOrigin: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
345
+ readonly tapUrl: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
346
+ readonly apiUrl: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
347
+ readonly environment: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"dev", undefined>, v.LiteralSchema<"prod", undefined>, v.LiteralSchema<"demo", undefined>, v.LiteralSchema<"staging", undefined>], undefined>, undefined>;
348
+ readonly language: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
349
+ readonly userId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
350
+ readonly courseId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
351
+ readonly clipId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
352
+ readonly clipPlayHead: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
353
+ readonly container: v.OptionalSchema<v.ObjectSchema<{
354
+ readonly mode: v.OptionalSchema<v.UnionSchema<[v.LiteralSchema<"auto", undefined>, v.LiteralSchema<"floating", undefined>, v.LiteralSchema<"sidebar", undefined>], undefined>, undefined>;
355
+ readonly floatingConfig: v.OptionalSchema<v.ObjectSchema<{
356
+ readonly position: v.OptionalSchema<v.ObjectSchema<{
357
+ readonly top: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
358
+ readonly left: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
359
+ readonly right: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
360
+ readonly bottom: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
361
+ }, undefined>, undefined>;
362
+ readonly width: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
363
+ readonly height: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
364
+ readonly borderRadius: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
365
+ }, undefined>, undefined>;
366
+ readonly sidebarConfig: v.OptionalSchema<v.ObjectSchema<{
367
+ readonly maxWidth: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
368
+ readonly minViewportWidth: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
369
+ }, undefined>, undefined>;
370
+ }, undefined>, undefined>;
371
+ }, undefined>, v.ObjectSchema<{
372
+ readonly type: v.LiteralSchema<"GA_EVENT", undefined>;
373
+ readonly payload: v.RecordSchema<v.StringSchema<undefined>, v.AnySchema, undefined>;
374
+ }, undefined>], undefined>;
375
+
376
+ type TapMessageRecord = TapMessage;
61
377
 
62
378
  /**
63
379
  * Styling Types
@@ -511,6 +827,8 @@ declare global {
511
827
  __TAP_KIT_LOADER_LOADING__?: Promise<void>;
512
828
  __TAP_KIT_LOADER_URL__?: string; // Override CDN loader URL for local testing
513
829
  __TAP_KIT_CORE_URL__?: string; // Override to load local IIFE directly (bypass loader)
830
+ __TAP_KIT_BASE_URL__?: string; // Override CDN base URL for local testing
831
+ __TAPKIT_INFERRED_BUILD_ENV__?: "dev" | "prod" | "demo" | "staging"; // Inferred build environment
514
832
  TapKitLoaded?: boolean; // Set by loader.js when real SDK is loaded
515
833
  }
516
834
 
@@ -528,4 +846,4 @@ declare global {
528
846
  function cancelIdleCallback(handle: number): void;
529
847
  }
530
848
 
531
- export { type AlarmMessageInstanceType, type AlarmType, type ContainerConfig, type ContainerLayoutState, type ContainerMode, type ContainerVisibility, type Course, type FloatingConfig, type ITapButtonElement, TapKitInitializationError as InitializationError, type PositionType, type SeekTimelineParamsType, type ShortcutKeyPropertiesType, type SidebarConfig, TAPKIT_CONFIG_SYMBOL, TAP_ERROR_MARKER, type TapButtonAttributes, type TapErrorOptions, type TapKitConfig, type TapKitConfigOptions, TapKitConfigurationError, type TapKitConstructor, TapKitError, TapKitIframeError, type TapKitInitParams, TapKitInitializationError, type TapKitInstance, TapKitLoaderError, TapKitMessageError, type TapKitRuntimeConfig, type VideoPlayerAdapter, type VideoPlayerConfig };
849
+ export { type AlarmClickMessage, AlarmClickSchema, type AlarmFadeInMessage, AlarmFadeInSchema, AlarmMessageInstanceSchema, type AlarmMessageInstanceType, type AlarmType, AlarmTypeSchema, type ConfigUpdateMessage, ConfigUpdateSchema, type ContainerCollapseMessage, ContainerCollapseSchema, type ContainerConfig, type ContainerExpandMessage, ContainerExpandSchema, type ContainerLayoutState, type ContainerLayoutStateChangedMessage, ContainerLayoutStateChangedSchema, type ContainerMode, type ContainerModeChangeAckMessage, ContainerModeChangeAckSchema, type ContainerModeChangeMessage, ContainerModeChangeSchema, type ContainerVisibility, type Course, type FloatingConfig, type GAEventMessage, GAEventSchema, type ITapButtonElement, TapKitInitializationError as InitializationError, type PopUpCloseMessage, PopUpCloseSchema, type PopUpOpenMessage, PopUpOpenSchema, type PositionType, type SeekTimelineParamsType, type ShortcutKeyPropertiesType, type SidebarConfig, TAPKIT_CONFIG_SYMBOL, TAP_ERROR_MARKER, type TapButtonAttributes, type TapCloseMessage, TapCloseSchema, type TapErrorOptions, type TapKitConfig, type TapKitConfigOptions, TapKitConfigurationError, type TapKitConstructor, TapKitError, TapKitIframeError, type TapKitInitParams, TapKitInitializationError, type TapKitInstance, TapKitLoaderError, TapKitMessageError, type TapKitRuntimeConfig, type TapMessage, type TapMessageRecord, TapMessageSchema, type TapMessageType, type TapReadyMessage, TapReadySchema, type TimelineSeekMessage, TimelineSeekSchema, type VideoPlayerAdapter, type VideoPlayerConfig, type ViewportResizeMessage, ViewportResizeSchema };
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import * as v from 'valibot';
2
+
1
3
  var __defProp = Object.defineProperty;
2
4
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
5
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -130,7 +132,160 @@ var TapKitIframeError = class _TapKitIframeError extends TapKitError {
130
132
  return null;
131
133
  }
132
134
  };
135
+ var AlarmTypeSchema = v.union([
136
+ v.literal("quiz"),
137
+ v.literal("pingMessage"),
138
+ v.literal("callToAction"),
139
+ v.literal("hourSpent"),
140
+ v.literal("default")
141
+ ]);
142
+ var AlarmMessageInstanceSchema = v.object({
143
+ message: v.string(),
144
+ question: v.optional(v.string()),
145
+ pingMessageId: v.optional(v.string()),
146
+ type: AlarmTypeSchema,
147
+ priority: v.number()
148
+ });
149
+ var TapReadySchema = v.object({
150
+ type: v.literal("tap:ready"),
151
+ gaId: v.string()
152
+ });
153
+ var TapCloseSchema = v.object({
154
+ type: v.literal("tap:close")
155
+ });
156
+ var TimelineSeekSchema = v.object({
157
+ type: v.literal("timeline:seek"),
158
+ clipId: v.string(),
159
+ clipPlayHead: v.number()
160
+ });
161
+ var AlarmClickSchema = v.object({
162
+ type: v.literal("alarm:click"),
163
+ messageInfo: AlarmMessageInstanceSchema
164
+ });
165
+ var AlarmFadeInSchema = v.object({
166
+ type: v.literal("alarm:fadeIn"),
167
+ messageInfo: AlarmMessageInstanceSchema
168
+ });
169
+ var PopUpOpenSchema = v.object({
170
+ type: v.literal("popUp:open"),
171
+ popUpInfo: v.object({
172
+ html: v.string(),
173
+ requestId: v.optional(v.string())
174
+ })
175
+ });
176
+ var PopUpCloseSchema = v.object({
177
+ type: v.literal("popUp:close")
178
+ });
179
+ var ContainerExpandSchema = v.object({
180
+ type: v.literal("container:expand"),
181
+ nonce: v.optional(v.union([v.string(), v.number()]))
182
+ });
183
+ var ContainerCollapseSchema = v.object({
184
+ type: v.literal("container:collapse"),
185
+ nonce: v.optional(v.union([v.string(), v.number()]))
186
+ });
187
+ var ContainerModeChangeSchema = v.object({
188
+ type: v.literal("container:mode:change"),
189
+ mode: v.union([v.literal("floating"), v.literal("sidebar")]),
190
+ nonce: v.optional(v.union([v.string(), v.number()]))
191
+ });
192
+ var ContainerModeChangeAckSchema = v.object({
193
+ type: v.literal("container:mode:change:ack"),
194
+ success: v.boolean(),
195
+ currentMode: v.union([
196
+ v.literal("floating"),
197
+ v.literal("sidebar"),
198
+ v.literal("floating-forced")
199
+ ]),
200
+ nonce: v.optional(v.union([v.string(), v.number()]))
201
+ });
202
+ var ContainerLayoutStateChangedSchema = v.object({
203
+ type: v.literal("container:layout:state:changed"),
204
+ layoutState: v.union([
205
+ v.literal("floating"),
206
+ v.literal("sidebar"),
207
+ v.literal("floating-forced")
208
+ ])
209
+ });
210
+ var ViewportResizeSchema = v.object({
211
+ type: v.literal("viewport:resize"),
212
+ viewportWidth: v.number()
213
+ });
214
+ var ConfigUpdateSchema = v.object({
215
+ type: v.literal("config:update"),
216
+ apiKey: v.optional(v.string()),
217
+ hostOrigin: v.optional(v.string()),
218
+ tapUrl: v.optional(v.string()),
219
+ apiUrl: v.optional(v.string()),
220
+ environment: v.optional(
221
+ v.union([
222
+ v.literal("dev"),
223
+ v.literal("prod"),
224
+ v.literal("demo"),
225
+ v.literal("staging")
226
+ ])
227
+ ),
228
+ language: v.optional(v.string()),
229
+ userId: v.optional(v.string()),
230
+ courseId: v.optional(v.string()),
231
+ clipId: v.optional(v.string()),
232
+ clipPlayHead: v.optional(v.number()),
233
+ container: v.optional(
234
+ v.object({
235
+ mode: v.optional(
236
+ v.union([
237
+ v.literal("auto"),
238
+ v.literal("floating"),
239
+ v.literal("sidebar")
240
+ ])
241
+ ),
242
+ floatingConfig: v.optional(
243
+ v.object({
244
+ position: v.optional(
245
+ v.object({
246
+ top: v.optional(v.string()),
247
+ left: v.optional(v.string()),
248
+ right: v.optional(v.string()),
249
+ bottom: v.optional(v.string())
250
+ })
251
+ ),
252
+ width: v.optional(v.string()),
253
+ height: v.optional(v.string()),
254
+ borderRadius: v.optional(v.string())
255
+ })
256
+ ),
257
+ sidebarConfig: v.optional(
258
+ v.object({
259
+ maxWidth: v.optional(v.string()),
260
+ minViewportWidth: v.optional(v.number())
261
+ })
262
+ )
263
+ })
264
+ )
265
+ });
266
+ var GAEventSchema = v.object({
267
+ type: v.literal("GA_EVENT"),
268
+ payload: v.record(v.string(), v.any())
269
+ // 유연한 payload 구조
270
+ });
271
+ var TapMessageSchema = v.union([
272
+ TapReadySchema,
273
+ TapCloseSchema,
274
+ TimelineSeekSchema,
275
+ AlarmClickSchema,
276
+ AlarmFadeInSchema,
277
+ PopUpOpenSchema,
278
+ PopUpCloseSchema,
279
+ ContainerExpandSchema,
280
+ ContainerCollapseSchema,
281
+ ContainerModeChangeSchema,
282
+ ContainerModeChangeAckSchema,
283
+ ContainerLayoutStateChangedSchema,
284
+ ViewportResizeSchema,
285
+ ConfigUpdateSchema,
286
+ GAEventSchema
287
+ ]);
133
288
 
134
- export { TapKitInitializationError as InitializationError, TAP_ERROR_MARKER, TapKitConfigurationError, TapKitError, TapKitIframeError, TapKitInitializationError, TapKitLoaderError, TapKitMessageError };
289
+ export { AlarmClickSchema, AlarmFadeInSchema, AlarmMessageInstanceSchema, AlarmTypeSchema, ConfigUpdateSchema, ContainerCollapseSchema, ContainerExpandSchema, ContainerLayoutStateChangedSchema, ContainerModeChangeAckSchema, ContainerModeChangeSchema, GAEventSchema, TapKitInitializationError as InitializationError, PopUpCloseSchema, PopUpOpenSchema, TAP_ERROR_MARKER, TapCloseSchema, TapKitConfigurationError, TapKitError, TapKitIframeError, TapKitInitializationError, TapKitLoaderError, TapKitMessageError, TapMessageSchema, TapReadySchema, TimelineSeekSchema, ViewportResizeSchema };
135
290
  //# sourceMappingURL=index.js.map
136
291
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";;;;;AAIO,IAAM,gBAAA,GAAmB;AAWzB,IAAM,WAAA,GAAN,MAAM,YAAA,SAAoB,KAAA,CAAM;AAAA,EAIrC,WAAA,CAAY,SAAiB,OAAA,EAA2B;AACtD,IAAA,KAAA,CAAM,OAAO,CAAA;AAJf,IAAA,aAAA,CAAA,IAAA,EAAS,OAAA,CAAA;AACT,IAAA,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AAIE,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,OAAO,OAAA,EAAS,IAAA;AACrB,IAAA,IAAA,CAAK,QAAQ,OAAA,EAAS,KAAA;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,2BAA2B,KAAA,EAAgC;AAChE,IAAA,IAAI,iBAAiB,YAAA,EAAa;AAChC,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,IACE,KAAA,IACA,OAAO,KAAA,KAAU,QAAA,IACjB,oBAAoB,KAAA,IACpB,KAAA,CAAM,gBAAgB,CAAA,KAAM,aAAA,EAC5B;AACA,MAAA,MAAM,GAAA,GAAM,IAAI,YAAA,CAAY,KAAA,CAAM,OAAA,EAAS;AAAA,QACzC,MAAM,KAAA,CAAM;AAAA,OACb,CAAA;AACD,MAAA,GAAA,CAAI,QAAQ,KAAA,CAAM,KAAA;AAClB,MAAA,OAAO,GAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAKO,IAAM,yBAAA,GAAN,MAAM,0BAAA,SAAkC,WAAA,CAAY;AAAA,EACzD,WAAA,C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MARKER = \"__tap_sdk_error__\";\n\nexport interface TapErrorOptions {\n code?: string;\n cause?: Error;\n}\n\n/**\n * Base error class for all TapKit errors\n * Supports serialization across iframe boundaries\n */\nexport class TapKitError extends Error {\n override cause: Error | undefined;\n code: string | undefined;\n\n constructor(message: string, options?: TapErrorOptions) {\n super(message);\n this.name = \"TapKitError\";\n this.code = options?.code;\n this.cause = options?.cause;\n }\n\n /**\n * Restore error from postMessage serialization\n */\n static fromPossibleFrameSafeError(error: any): TapKitError | null {\n if (error instanceof TapKitError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitError\"\n ) {\n const err = new TapKitError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when SDK initialization fails\n */\nexport class TapKitInitializationError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitInitializationError\";\n this.code = options?.code ?? \"ERR_INITIALIZATION\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitInitializationError | null {\n if (error instanceof TapKitInitializationError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitInitializationError\"\n ) {\n const err = new TapKitInitializationError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when message communication fails\n */\nexport class TapKitMessageError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitMessageError\";\n this.code = options?.code ?? \"ERR_MESSAGE\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitMessageError | null {\n if (error instanceof TapKitMessageError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitMessageError\"\n ) {\n const err = new TapKitMessageError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when configuration is invalid\n */\nexport class TapKitConfigurationError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitConfigurationError\";\n this.code = options?.code ?? \"ERR_CONFIGURATION\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitConfigurationError | null {\n if (error instanceof TapKitConfigurationError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitConfigurationError\"\n ) {\n const err = new TapKitConfigurationError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when loader fails to fetch or load resources\n */\nexport class TapKitLoaderError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitLoaderError\";\n this.code = options?.code ?? \"ERR_LOADER\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitLoaderError | null {\n if (error instanceof TapKitLoaderError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitLoaderError\"\n ) {\n const err = new TapKitLoaderError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when iframe operations fail\n */\nexport class TapKitIframeError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitIframeError\";\n this.code = options?.code ?? \"ERR_IFRAME\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitIframeError | null {\n if (error instanceof TapKitIframeError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitIframeError\"\n ) {\n const err = new TapKitIframeError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n// Backward compatibility alias\nexport { TapKitInitializationError as InitializationError };\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/protocol/schema.ts"],"names":[],"mappings":";;;;;;;AAIO,IAAM,gBAAA,GAAmB;AAWzB,IAAM,WAAA,GAAN,MAAM,YAAA,SAAoB,KAAA,CAAM;AAAA,EAIrC,WAAA,CAAY,SAAiB,OAAA,EAA2B;AACtD,IAAA,KAAA,CAAM,OAAO,CAAA;AAJf,IAAA,aAAA,CAAA,IAAA,EAAS,OAAA,CAAA;AACT,IAAA,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AAIE,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,OAAO,OAAA,EAAS,IAAA;AACrB,IAAA,IAAA,CAAK,QAAQ,OAAA,EAAS,KAAA;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,2BAA2B,KAAA,EAAgC;AAChE,IAAA,IAAI,iBAAiB,YAAA,EAAa;AAChC,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,IACE,KAAA,IACA,OAAO,KAAA,KAAU,QAAA,IACjB,oBAAoB,KAAA,IACpB,KAAA,CAAM,gBAAgB,CAAA,KAAM,aAAA,EAC5B;AACA,MAAA,MAAM,GAAA,GAAM,IAAI,YAAA,CAAY,KAAA,CAAM,OAAA,EAAS;AAAA,QACzC,MAAM,KAAA,CAAM;AAAA,OACb,CAAA;AACD,MAAA,GAAA,CAAI,QAAQ,KAAA,CAAM,KAAA;AAClB,MAAA,OAAO,GAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAKO,IAAM,yBAAA,GAAN,MAAM,0BAAA,SAAkC,WAAA,CAAY;AAAA,EACzD,WAAA,CAAY,SAAiB,OAAA,EAA2B;AACtD,IAAA,KAAA,CAAM,SAAS,OA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A,CAAW,CAAA,CAAA,MAAA,EAAQ,CAAA;AAAA,UAC7B,YAAA,EAAgB,CAAA,CAAA,QAAA,CAAW,CAAA,CAAA,MAAA,EAAQ;AAAA,SACpC;AAAA,OACH;AAAA,MACA,aAAA,EAAiB,CAAA,CAAA,QAAA;AAAA,QACb,CAAA,CAAA,MAAA,CAAO;AAAA,UACP,QAAA,EAAY,CAAA,CAAA,QAAA,CAAW,CAAA,CAAA,MAAA,EAAQ,CAAA;AAAA,UAC/B,gBAAA,EAAoB,CAAA,CAAA,QAAA,CAAW,CAAA,CAAA,MAAA,EAAQ;AAAA,SACxC;AAAA;AACH,KACD;AAAA;AAEL,CAAC;AAGM,IAAM,gBAAkB,CAAA,CAAA,MAAA,CAAO;AAAA,EACpC,IAAA,EAAQ,UAAQ,UAAU,CAAA;AAAA,EAC1B,OAAA,EAAW,CAAA,CAAA,MAAA,CAAS,CAAA,CAAA,MAAA,EAAO,EAAK,OAAK;AAAA;AACvC,CAAC;AAGM,IAAM,mBAAqB,CAAA,CAAA,KAAA,CAAM;AAAA,EACtC,cAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,qBAAA;AAAA,EACA,uBAAA;AAAA,EACA,yBAAA;AAAA,EACA,4BAAA;AAAA,EACA,iCAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAC","file":"index.js","sourcesContent":["/**\n * Error Classes\n */\n\nexport const TAP_ERROR_MARKER = \"__tap_sdk_error__\";\n\nexport interface TapErrorOptions {\n code?: string;\n cause?: Error;\n}\n\n/**\n * Base error class for all TapKit errors\n * Supports serialization across iframe boundaries\n */\nexport class TapKitError extends Error {\n override cause: Error | undefined;\n code: string | undefined;\n\n constructor(message: string, options?: TapErrorOptions) {\n super(message);\n this.name = \"TapKitError\";\n this.code = options?.code;\n this.cause = options?.cause;\n }\n\n /**\n * Restore error from postMessage serialization\n */\n static fromPossibleFrameSafeError(error: any): TapKitError | null {\n if (error instanceof TapKitError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitError\"\n ) {\n const err = new TapKitError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when SDK initialization fails\n */\nexport class TapKitInitializationError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitInitializationError\";\n this.code = options?.code ?? \"ERR_INITIALIZATION\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitInitializationError | null {\n if (error instanceof TapKitInitializationError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitInitializationError\"\n ) {\n const err = new TapKitInitializationError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when message communication fails\n */\nexport class TapKitMessageError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitMessageError\";\n this.code = options?.code ?? \"ERR_MESSAGE\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitMessageError | null {\n if (error instanceof TapKitMessageError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitMessageError\"\n ) {\n const err = new TapKitMessageError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when configuration is invalid\n */\nexport class TapKitConfigurationError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitConfigurationError\";\n this.code = options?.code ?? \"ERR_CONFIGURATION\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitConfigurationError | null {\n if (error instanceof TapKitConfigurationError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitConfigurationError\"\n ) {\n const err = new TapKitConfigurationError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when loader fails to fetch or load resources\n */\nexport class TapKitLoaderError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitLoaderError\";\n this.code = options?.code ?? \"ERR_LOADER\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitLoaderError | null {\n if (error instanceof TapKitLoaderError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitLoaderError\"\n ) {\n const err = new TapKitLoaderError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n/**\n * Error thrown when iframe operations fail\n */\nexport class TapKitIframeError extends TapKitError {\n constructor(message: string, options?: TapErrorOptions) {\n super(message, options);\n this.name = \"TapKitIframeError\";\n this.code = options?.code ?? \"ERR_IFRAME\";\n }\n\n static override fromPossibleFrameSafeError(\n error: any,\n ): TapKitIframeError | null {\n if (error instanceof TapKitIframeError) {\n return error;\n }\n if (\n error &&\n typeof error === \"object\" &&\n TAP_ERROR_MARKER in error &&\n error[TAP_ERROR_MARKER] === \"TapKitIframeError\"\n ) {\n const err = new TapKitIframeError(error.message, {\n code: error.code,\n });\n err.stack = error.stack;\n return err;\n }\n return null;\n }\n}\n\n// Backward compatibility alias\nexport { TapKitInitializationError as InitializationError };\n","import * as v from \"valibot\";\n\n// Alarm-related schemas\nexport const AlarmTypeSchema = v.union([\n v.literal(\"quiz\"),\n v.literal(\"pingMessage\"),\n v.literal(\"callToAction\"),\n v.literal(\"hourSpent\"),\n v.literal(\"default\"),\n]);\n\nexport const AlarmMessageInstanceSchema = v.object({\n message: v.string(),\n question: v.optional(v.string()),\n pingMessageId: v.optional(v.string()),\n type: AlarmTypeSchema,\n priority: v.number(),\n});\n\n// Validation schemas for each message type\nexport const TapReadySchema = v.object({\n type: v.literal(\"tap:ready\"),\n gaId: v.string(),\n});\n\nexport const TapCloseSchema = v.object({\n type: v.literal(\"tap:close\"),\n});\n\nexport const TimelineSeekSchema = v.object({\n type: v.literal(\"timeline:seek\"),\n clipId: v.string(),\n clipPlayHead: v.number(),\n});\n\nexport const AlarmClickSchema = v.object({\n type: v.literal(\"alarm:click\"),\n messageInfo: AlarmMessageInstanceSchema,\n});\n\nexport const AlarmFadeInSchema = v.object({\n type: v.literal(\"alarm:fadeIn\"),\n messageInfo: AlarmMessageInstanceSchema,\n});\n\nexport const PopUpOpenSchema = v.object({\n type: v.literal(\"popUp:open\"),\n popUpInfo: v.object({\n html: v.string(),\n requestId: v.optional(v.string()),\n }),\n});\n\nexport const PopUpCloseSchema = v.object({\n type: v.literal(\"popUp:close\"),\n});\n\nexport const ContainerExpandSchema = v.object({\n type: v.literal(\"container:expand\"),\n nonce: v.optional(v.union([v.string(), v.number()])),\n});\n\nexport const ContainerCollapseSchema = v.object({\n type: v.literal(\"container:collapse\"),\n nonce: v.optional(v.union([v.string(), v.number()])),\n});\n\nexport const ContainerModeChangeSchema = v.object({\n type: v.literal(\"container:mode:change\"),\n mode: v.union([v.literal(\"floating\"), v.literal(\"sidebar\")]),\n nonce: v.optional(v.union([v.string(), v.number()])),\n});\n\nexport const ContainerModeChangeAckSchema = v.object({\n type: v.literal(\"container:mode:change:ack\"),\n success: v.boolean(),\n currentMode: v.union([\n v.literal(\"floating\"),\n v.literal(\"sidebar\"),\n v.literal(\"floating-forced\"),\n ]),\n nonce: v.optional(v.union([v.string(), v.number()])),\n});\n\nexport const ContainerLayoutStateChangedSchema = v.object({\n type: v.literal(\"container:layout:state:changed\"),\n layoutState: v.union([\n v.literal(\"floating\"),\n v.literal(\"sidebar\"),\n v.literal(\"floating-forced\"),\n ]),\n});\n\nexport const ViewportResizeSchema = v.object({\n type: v.literal(\"viewport:resize\"),\n viewportWidth: v.number(),\n});\n\nexport const ConfigUpdateSchema = v.object({\n type: v.literal(\"config:update\"),\n apiKey: v.optional(v.string()),\n hostOrigin: v.optional(v.string()),\n tapUrl: v.optional(v.string()),\n apiUrl: v.optional(v.string()),\n environment: v.optional(\n v.union([\n v.literal(\"dev\"),\n v.literal(\"prod\"),\n v.literal(\"demo\"),\n v.literal(\"staging\"),\n ]),\n ),\n language: v.optional(v.string()),\n userId: v.optional(v.string()),\n courseId: v.optional(v.string()),\n clipId: v.optional(v.string()),\n clipPlayHead: v.optional(v.number()),\n container: v.optional(\n v.object({\n mode: v.optional(\n v.union([\n v.literal(\"auto\"),\n v.literal(\"floating\"),\n v.literal(\"sidebar\"),\n ]),\n ),\n floatingConfig: v.optional(\n v.object({\n position: v.optional(\n v.object({\n top: v.optional(v.string()),\n left: v.optional(v.string()),\n right: v.optional(v.string()),\n bottom: v.optional(v.string()),\n }),\n ),\n width: v.optional(v.string()),\n height: v.optional(v.string()),\n borderRadius: v.optional(v.string()),\n }),\n ),\n sidebarConfig: v.optional(\n v.object({\n maxWidth: v.optional(v.string()),\n minViewportWidth: v.optional(v.number()),\n }),\n ),\n }),\n ),\n});\n\n// Google Analytics event schema\nexport const GAEventSchema = v.object({\n type: v.literal(\"GA_EVENT\"),\n payload: v.record(v.string(), v.any()), // 유연한 payload 구조\n});\n\n// Union schema for all TAP protocol messages\nexport const TapMessageSchema = v.union([\n TapReadySchema,\n TapCloseSchema,\n TimelineSeekSchema,\n AlarmClickSchema,\n AlarmFadeInSchema,\n PopUpOpenSchema,\n PopUpCloseSchema,\n ContainerExpandSchema,\n ContainerCollapseSchema,\n ContainerModeChangeSchema,\n ContainerModeChangeAckSchema,\n ContainerLayoutStateChangedSchema,\n ViewportResizeSchema,\n ConfigUpdateSchema,\n GAEventSchema,\n]);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coxwave/tap-kit-types",
3
- "version": "0.0.63",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "description": "Shared TypeScript types for TapKit SDK packages",
6
6
  "main": "dist/index.js",
@@ -23,8 +23,8 @@
23
23
  ],
24
24
  "devDependencies": {
25
25
  "tsup": "^8.5.0",
26
- "@coxwave/config-typescript": "1.0.0",
27
- "@coxwave/tap-messages": "0.0.1"
26
+ "valibot": "1.1.0",
27
+ "@coxwave/config-typescript": "1.0.0"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup",