@coxwave/tap-kit-types 0.0.52 → 0.0.63

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @coxwave/tap-kit-types
2
2
 
3
- Shared TypeScript types for TapKit SDK packages.
3
+ TypeScript types for the TapKit SDK and `<tap-button>` Web Component.
4
4
 
5
5
  ## Purpose
6
6
 
@@ -17,6 +17,46 @@ npm install @coxwave/tap-kit-types
17
17
  pnpm add @coxwave/tap-kit-types
18
18
  ```
19
19
 
20
+ ## Setup
21
+
22
+ Once you install the package, the global type definitions are automatically available. No additional configuration is needed!
23
+
24
+ The package exports global type declarations that TypeScript automatically picks up from `node_modules`. This includes:
25
+
26
+ - **Web Component**: `<tap-button>` element with type-safe attributes
27
+ - **Window extensions**: `Window.TapKit`, loader flags, and debug properties
28
+ - **Browser APIs**: `requestIdleCallback` / `cancelIdleCallback` types
29
+
30
+ ### Manual Setup (Optional)
31
+
32
+ If the global types are not automatically picked up, you can explicitly include them in your `tsconfig.json`:
33
+
34
+ ```json
35
+ {
36
+ "include": [
37
+ "src/**/*",
38
+ "node_modules/@coxwave/tap-kit-types/dist/index.d.ts"
39
+ ]
40
+ }
41
+ ```
42
+
43
+ **Note**: Do NOT add this package to `compilerOptions.types` - that option is only for `@types/*` packages. Adding non-`@types` packages there will cause TypeScript errors.
44
+
45
+ ### What Gets Registered
46
+
47
+ When you install this package, the following global types are automatically available:
48
+
49
+ - **Web Component**: `<tap-button>` element with type-safe attributes
50
+ - **Window extensions**: `Window.TapKit`, loader flags, and debug properties
51
+ - **Browser APIs**: `requestIdleCallback` / `cancelIdleCallback` types
52
+
53
+ This allows you to use the Web Component in JSX/TSX without type errors:
54
+
55
+ ```tsx
56
+ // ✅ TypeScript knows about <tap-button>
57
+ <tap-button floating={true} position="bottom-right" size="medium" />
58
+ ```
59
+
20
60
  ## Usage
21
61
 
22
62
  ```typescript
@@ -51,9 +91,12 @@ const params: TapKitInitParams = {
51
91
 
52
92
  ### Styling
53
93
 
54
- - `ContainerStyle` - Container styling options
94
+ - `ContainerConfig` - Container configuration
95
+ - `ContainerMode` - Container display mode
96
+ - `FloatingConfig` - Floating container settings
97
+ - `SidebarConfig` - Sidebar container settings
55
98
  - `PositionType` - Position configuration
56
- - `CustomStyles` - Backward compatibility alias
99
+ - `ContainerLayoutState` - Container layout state
57
100
 
58
101
  ### Events
59
102
 
@@ -61,6 +104,22 @@ const params: TapKitInitParams = {
61
104
  - `ShortcutKeyPropertiesType` - Keyboard shortcut configuration
62
105
  - `ContainerVisibility` - Visibility state
63
106
 
107
+ ### Web Component
108
+
109
+ - `ITapButtonElement` - Public API interface for `<tap-button>` Web Component
110
+ - `TapButtonAttributes` - Props/Attributes for `<tap-button>` element
111
+
112
+ ```tsx
113
+ // Example usage in React
114
+ <tap-button
115
+ floating={true}
116
+ position="bottom-right"
117
+ size="medium"
118
+ >
119
+ Custom content
120
+ </tap-button>
121
+ ```
122
+
64
123
  ### Errors
65
124
 
66
125
  - `TapKitError` - Base error class
@@ -70,15 +129,21 @@ const params: TapKitInitParams = {
70
129
  - `TapKitLoaderError` - Loader errors
71
130
  - `TapKitIframeError` - iframe operation errors
72
131
 
132
+ ### Instance
133
+
134
+ - `TapKitInstance` - TapKit SDK instance interface
135
+ - `TapKitConstructor` - TapKit class constructor type
136
+
137
+ ### Video
138
+
139
+ - `VideoPlayerAdapter` - Video player adapter interface
140
+ - `VideoPlayerConfig` - Video player configuration
141
+
73
142
  ### Re-exports from @coxwave/tap-messages
74
143
 
75
144
  - `AlarmMessageInstanceType`
76
145
  - `AlarmType`
77
146
 
78
- ## Version
79
-
80
- Current version: 0.1.0
81
-
82
147
  ## License
83
148
 
84
149
  MIT
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { ReactNode, CSSProperties } from 'react';
2
+
1
3
  type AlarmType = "quiz" | "pingMessage" | "callToAction" | "hourSpent" | "default";
2
4
  interface AlarmMessageInstanceType {
3
5
  message: string;
@@ -21,7 +23,7 @@ interface ConfigUpdateMessage {
21
23
  hostOrigin?: string;
22
24
  tapUrl?: string;
23
25
  apiUrl?: string;
24
- environment?: "dev" | "prod" | "demo";
26
+ environment?: "dev" | "prod" | "demo" | "staging";
25
27
  language?: "ko" | "en" | (string & {});
26
28
  userId?: string;
27
29
  courseId?: string;
@@ -107,7 +109,7 @@ type FloatingConfig = {
107
109
  * Sidebar Configuration
108
110
  */
109
111
  type SidebarConfig = {
110
- /** Maximum width of the sidebar (default: "min(50%, 600px)") */
112
+ /** Maximum width of the sidebar (default: "min(50%, 1000px)") */
111
113
  maxWidth?: string;
112
114
  /** Minimum viewport width to enable sidebar mode (default: 768) */
113
115
  minViewportWidth?: number;
@@ -130,7 +132,7 @@ type SidebarConfig = {
130
132
  * // Auto mode with custom styling for both layouts
131
133
  * const config: ContainerConfig = {
132
134
  * floatingConfig: { width: "400px", position: { top: "80px" } },
133
- * sidebarConfig: { maxWidth: "600px" }
135
+ * sidebarConfig: { maxWidth: "800px" }
134
136
  * }
135
137
  *
136
138
  * @example
@@ -208,13 +210,29 @@ type Course = {
208
210
  /**
209
211
  * SDK Initialization Parameters
210
212
  *
213
+ * Button Options (choose one):
214
+ * 1. buttonId: Attach to your own button element (provide element ID)
215
+ * 2. <tap-button>: Use the built-in Web Component (omit buttonId)
216
+ *
211
217
  * @example
212
218
  * ```typescript
213
219
  * const sdk = new TapSDK({ apiKey: "your-key" });
214
220
  *
215
- * // Minimal initialization (uses all defaults)
221
+ * // Option 1: Use your own button element
222
+ * await sdk.init({
223
+ * buttonId: "my-chat-button",
224
+ * course: { userId: "user1", courseId: "course1", clipId: "clip1" }
225
+ * });
226
+ *
227
+ * // Option 2: Use <tap-button> Web Component (recommended)
228
+ * // HTML: <tap-button></tap-button>
229
+ * await sdk.init({
230
+ * course: { userId: "user1", courseId: "course1", clipId: "clip1" }
231
+ * });
232
+ *
233
+ * // Custom styled <tap-button>
234
+ * // HTML: <tap-button position="bottom-left" size="large"></tap-button>
216
235
  * await sdk.init({
217
- * buttonId: "tap-button",
218
236
  * course: { userId: "user1", courseId: "course1", clipId: "clip1" }
219
237
  * });
220
238
  *
@@ -236,67 +254,23 @@ type Course = {
236
254
  * course: { userId: "user1", courseId: "course1", clipId: "clip1" },
237
255
  * container: {
238
256
  * mode: "sidebar",
239
- * sidebarConfig: { width: "600px", minViewportWidth: 1024 }
257
+ * sidebarConfig: { maxWidth: "800px", minViewportWidth: 1024 }
240
258
  * }
241
259
  * });
242
260
  * ```
243
261
  */
244
262
  type TapKitInitParams = {
245
- buttonId: string;
263
+ /**
264
+ * Element ID of your custom button (optional)
265
+ * If omitted, SDK will use <tap-button> Web Component
266
+ * @see https://edutap-ai-docs.vercel.app/docs/sdk/button
267
+ */
268
+ buttonId?: string;
246
269
  course: Course;
247
270
  /** Container configuration (optional, uses defaults if omitted) */
248
271
  container?: ContainerConfig;
249
272
  };
250
273
 
251
- /**
252
- * Event Types
253
- */
254
- /**
255
- * Timeline seek parameters
256
- */
257
- type SeekTimelineParamsType = {
258
- clipId: string;
259
- clipPlayHead: number;
260
- };
261
- /**
262
- * Shortcut Key Configuration
263
- */
264
- type ShortcutKeyPropertiesType = {
265
- key: string;
266
- modifier: "ctrlKey" | "altKey" | "shiftKey" | "metaKey" | "";
267
- };
268
- /**
269
- * Container Visibility State
270
- */
271
- type ContainerVisibility = "open" | "closed";
272
-
273
- /**
274
- * @internal
275
- * Type-only symbol reference for internal configuration method
276
- * Actual symbol value: Symbol.for("tapkit.config")
277
- * Use this type in interface definitions, create actual symbol in implementation packages
278
- */
279
- declare const TAPKIT_CONFIG_SYMBOL: unique symbol;
280
- /** TapKit instance interface - shared by tap-kit-core and tap-sdk */
281
- interface TapKitInstance {
282
- events: {
283
- seekTimeline: (params: SeekTimelineParamsType) => void;
284
- onTimelineSeek: (callback: (clipPlayHead: number, clipId: string) => void) => () => void;
285
- onChatOpened: (handler: () => void) => () => void;
286
- onChatClosed: (handler: () => void) => () => void;
287
- onAlarmFadeIn: (handler: (messageInfo: AlarmMessageInstanceType) => void) => () => void;
288
- };
289
- isOpen: boolean;
290
- isInitialized: boolean;
291
- ready: Promise<void>;
292
- init(params: TapKitInitParams): Promise<void>;
293
- destroy(): void;
294
- /** @internal Advanced configuration API using Symbol.for("tapkit.config") */
295
- [TAPKIT_CONFIG_SYMBOL]?(options: TapKitConfigOptions): void;
296
- }
297
- /** TapKit constructor type */
298
- type TapKitConstructor = new (config: TapKitConfig) => TapKitInstance;
299
-
300
274
  /**
301
275
  * Error Classes
302
276
  */
@@ -354,6 +328,176 @@ declare class TapKitIframeError extends TapKitError {
354
328
  static fromPossibleFrameSafeError(error: any): TapKitIframeError | null;
355
329
  }
356
330
 
331
+ /**
332
+ * Event Types
333
+ */
334
+ /**
335
+ * Timeline seek parameters
336
+ */
337
+ type SeekTimelineParamsType = {
338
+ clipId: string;
339
+ clipPlayHead: number;
340
+ };
341
+ /**
342
+ * Shortcut Key Configuration
343
+ */
344
+ type ShortcutKeyPropertiesType = {
345
+ key: string;
346
+ modifier: "ctrlKey" | "altKey" | "shiftKey" | "metaKey" | "";
347
+ };
348
+ /**
349
+ * Container Visibility State
350
+ */
351
+ type ContainerVisibility = "open" | "closed";
352
+
353
+ /**
354
+ * Video Player Integration Types
355
+ * Supports both HTMLVideoElement and custom player adapters
356
+ */
357
+ /**
358
+ * Video Player Adapter Interface
359
+ * For custom video players (YouTube, Vimeo, Video.js, etc.)
360
+ *
361
+ * @example
362
+ * ```typescript
363
+ * const adapter = {
364
+ * getCurrentTime: () => player.currentTime,
365
+ * setCurrentTime: (time) => { player.currentTime = time; }
366
+ * };
367
+ * ```
368
+ */
369
+ interface VideoPlayerAdapter {
370
+ /** Get current playback time in seconds */
371
+ getCurrentTime: () => number;
372
+ /** Set playback time in seconds */
373
+ setCurrentTime: (time: number) => void;
374
+ }
375
+ /**
376
+ * Video Player Configuration
377
+ * Accepts either HTMLVideoElement or custom adapter
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * // HTML5 Video
382
+ * const videoElement = document.querySelector('video');
383
+ * sdk.video.bind(videoElement, 'clip-123');
384
+ *
385
+ * // Custom Adapter
386
+ * const adapter = {
387
+ * getCurrentTime: () => player.currentTime,
388
+ * setCurrentTime: (time) => { player.currentTime = time; }
389
+ * };
390
+ * sdk.video.bind(adapter, 'clip-123');
391
+ * ```
392
+ */
393
+ type VideoPlayerConfig = HTMLVideoElement | VideoPlayerAdapter;
394
+
395
+ /**
396
+ * @internal
397
+ * Type-only symbol reference for internal configuration method
398
+ * Actual symbol value: Symbol.for("tapkit.config")
399
+ * Use this type in interface definitions, create actual symbol in implementation packages
400
+ */
401
+ declare const TAPKIT_CONFIG_SYMBOL: unique symbol;
402
+ /** TapKit instance interface - shared by tap-kit-core and tap-sdk */
403
+ interface TapKitInstance {
404
+ events: {
405
+ seekTimeline: (params: SeekTimelineParamsType) => void;
406
+ onTimelineSeek: (callback: (clipPlayHead: number, clipId: string) => void) => () => void;
407
+ onAlarmFadeIn: (handler: (messageInfo: AlarmMessageInstanceType) => void) => () => void;
408
+ };
409
+ video: {
410
+ /** Bind video player for timeline synchronization */
411
+ bind: (config: VideoPlayerConfig, clipId: string) => void;
412
+ /** Unbind current video player */
413
+ unbind: () => void;
414
+ };
415
+ isOpen: boolean;
416
+ isInitialized: boolean;
417
+ ready: Promise<void>;
418
+ init(params: TapKitInitParams): Promise<() => void>;
419
+ destroy(): void;
420
+ /** @internal Advanced configuration API using Symbol.for("tapkit.config") */
421
+ [TAPKIT_CONFIG_SYMBOL]?(options: TapKitConfigOptions): void;
422
+ }
423
+ /** TapKit constructor type */
424
+ type TapKitConstructor = new (config: TapKitConfig) => TapKitInstance;
425
+
426
+ /**
427
+ * Type declarations for <tap-button> Web Component
428
+ *
429
+ * Provides TypeScript support for using <tap-button> in JSX/TSX.
430
+ * The actual Web Component is registered by tap-kit-core when loaded.
431
+ */
432
+
433
+
434
+
435
+ declare global {
436
+ namespace JSX {
437
+ interface IntrinsicElements {
438
+ "tap-button": TapButtonAttributes;
439
+ }
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Public API interface for TapButtonElement Web Component
445
+ *
446
+ * This interface defines the contract that tap-kit-core's TapButtonElement must implement.
447
+ * It provides type-safe access to the Web Component's internal structure.
448
+ */
449
+ interface ITapButtonElement extends HTMLElement {
450
+ /**
451
+ * Get the button element from Shadow DOM
452
+ * Used by tap-kit-core to attach click listeners and manage the button
453
+ * @returns The button element inside Shadow DOM, or null if not found
454
+ */
455
+ getButtonElement(): HTMLButtonElement | null;
456
+ }
457
+
458
+ /**
459
+ * Props/Attributes for <tap-button> Web Component
460
+ */
461
+ interface TapButtonAttributes {
462
+ /**
463
+ * Enable floating mode (position: fixed)
464
+ * When true or omitted: button floats with fixed positioning
465
+ * When false: button uses static positioning (normal flow)
466
+ * @default true
467
+ */
468
+ floating?: boolean;
469
+
470
+ /**
471
+ * Button position on screen (only applies when floating is true)
472
+ * @default "bottom-right"
473
+ */
474
+ position?:
475
+ | "bottom-right"
476
+ | "bottom-left"
477
+ | "top-right"
478
+ | "top-left"
479
+ | "custom";
480
+
481
+ /**
482
+ * Button size preset
483
+ * @default "medium"
484
+ */
485
+ size?: "small" | "medium" | "large";
486
+
487
+ /**
488
+ * Child content (replaces default icon via slot)
489
+ * Use this to provide custom button content (e.g., custom logo, icon, or text)
490
+ * If not provided, displays default edutap logo
491
+ */
492
+ children?: ReactNode;
493
+
494
+ /**
495
+ * Custom inline styles for positioning
496
+ * Use position="custom" attribute to enable custom positioning
497
+ */
498
+ style?: CSSProperties;
499
+ }
500
+
357
501
  /**
358
502
  * Global type definitions for browser environment
359
503
  */
@@ -384,4 +528,4 @@ declare global {
384
528
  function cancelIdleCallback(handle: number): void;
385
529
  }
386
530
 
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 };
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 };
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,YA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IAAI,iBAAiB,kBAAA,EAAmB;AACtC,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,IACE,KAAA,IACA,OAAO,KAAA,KAAU,QAAA,IACjB,oBAAoB,KAAA,IACpB,KAAA,CAAM,gBAAgB,CAAA,KAAM,mBAAA,EAC5B;AACA,MAAA,MAAM,GAAA,GAAM,IAAI,kBAAA,CAAkB,KAAA,CAAM,OAAA,EAAS;AAAA,QAC/C,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","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"]}
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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AA,IACA,OAAO,KAAA,KAAU,QAAA,IACjB,oBAAoB,KAAA,IACpB,KAAA,CAAM,gBAAgB,CAAA,KAAM,mBAAA,EAC5B;AACA,MAAA,MAAM,GAAA,GAAM,IAAI,kBAAA,CAAkB,KAAA,CAAM,OAAA,EAAS;AAAA,QAC/C,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","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coxwave/tap-kit-types",
3
- "version": "0.0.52",
3
+ "version": "0.0.63",
4
4
  "type": "module",
5
5
  "description": "Shared TypeScript types for TapKit SDK packages",
6
6
  "main": "dist/index.js",
@@ -23,14 +23,16 @@
23
23
  ],
24
24
  "devDependencies": {
25
25
  "tsup": "^8.5.0",
26
- "@coxwave/config-eslint": "1.0.0",
27
- "@coxwave/tap-messages": "0.0.1",
28
- "@coxwave/config-typescript": "1.0.0"
26
+ "@coxwave/config-typescript": "1.0.0",
27
+ "@coxwave/tap-messages": "0.0.1"
29
28
  },
30
29
  "scripts": {
31
30
  "build": "tsup",
32
31
  "dev": "tsup --watch",
33
- "lint": "eslint .",
32
+ "lint": "biome check .",
33
+ "lint:fix": "biome check --write .",
34
+ "format": "biome format --write .",
35
+ "typecheck": "tsc --noEmit",
34
36
  "publish:npm": "./scripts/publish.sh"
35
37
  }
36
38
  }