@touchcastllc/napster-companion-api-dev 1.5.0-alpha.0 → 1.6.0-alpha.0

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.
@@ -2,5 +2,5 @@ export { store } from "./store";
2
2
  export type { RootState } from "./store";
3
3
  export { setOnFeaturesUpdateCallback } from "./middleware/featuresUpdateMiddleware";
4
4
  export * from "./selectors";
5
- export { setSessionId, setAvatarReady, setDataChannel, setStopInteraction, setMuted, setAutoMicActive, setVolume, setAvatarSpeaking, setScreenSharing, setUserTalking, setConnectionToken, setCloseConnectionHandler, setSessionTerminatedByServer, resetAvatar, } from "./slices/avatarSlice";
6
- export { setFeatures, resetFeatures, setPosition, setDebugMode, } from "./slices/appSlice";
5
+ export { setSessionId, setDataChannel, setStopInteraction, setMuted, setAutoMicActive, setVolume, setAvatarSpeaking, setScreenSharing, setUserTalking, setConnectionToken, setCloseConnectionHandler, setSessionTerminatedByServer, resetAvatar, } from "./slices/avatarSlice";
6
+ export { setFeatures, resetFeatures, setDebugMode } from "./slices/appSlice";
@@ -1,10 +1,9 @@
1
1
  import { RootState } from "./index";
2
- import { FeatureConfig, Position } from "../types";
2
+ import { FeatureConfig } from "../types";
3
3
  /**
4
4
  * Avatar state selectors
5
5
  */
6
6
  export declare const selectSessionId: (state: RootState) => string | undefined;
7
- export declare const selectAvatarReady: (state: RootState) => boolean;
8
7
  export declare const selectDataChannel: (state: RootState) => RTCDataChannel | null;
9
8
  export declare const selectMuted: (state: RootState) => boolean;
10
9
  export declare const selectAutoMicActive: (state: RootState) => boolean;
@@ -18,9 +17,7 @@ export declare const selectSessionTerminatedByServer: (state: RootState) => bool
18
17
  * App state selectors
19
18
  */
20
19
  export declare const selectFeatures: (state: RootState) => FeatureConfig;
21
- export declare const selectPosition: (state: RootState) => Position | undefined;
22
20
  /**
23
21
  * Composite selectors
24
22
  */
25
23
  export declare const selectIsConnected: (state: RootState) => boolean;
26
- export declare const selectCanSendMessage: (state: RootState) => boolean;
@@ -1,11 +1,10 @@
1
- import { Position, FeatureConfig } from "../../types";
1
+ import { FeatureConfig } from "../../types";
2
2
  export interface AppState {
3
3
  features: FeatureConfig;
4
- position?: Position;
5
4
  debugMode?: boolean;
6
5
  }
7
6
  export declare const setFeatures: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
8
7
  feature: keyof FeatureConfig;
9
8
  config: FeatureConfig[keyof FeatureConfig];
10
- }, "app/setFeatures">, resetFeatures: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"app/resetFeatures">, setPosition: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<Position | undefined, "app/setPosition">, setDebugMode: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<boolean | undefined, "app/setDebugMode">;
9
+ }, "app/setFeatures">, resetFeatures: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"app/resetFeatures">, setDebugMode: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<boolean | undefined, "app/setDebugMode">;
11
10
  export declare const appReducer: import("redux").Reducer<AppState>;
@@ -1,11 +1,5 @@
1
- export interface WebRTCStatus {
2
- blocked: boolean;
3
- reason: string;
4
- message: string;
5
- }
6
1
  export interface AvatarState {
7
2
  sessionId?: string;
8
- avatarReady: boolean;
9
3
  dataChannel: RTCDataChannel | null;
10
4
  stopInteraction: boolean;
11
5
  muted: boolean;
@@ -18,5 +12,5 @@ export interface AvatarState {
18
12
  closeConnectionHandler?: () => void;
19
13
  sessionTerminatedByServer: boolean;
20
14
  }
21
- export declare const setSessionId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setSessionId">, setAvatarReady: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setAvatarReady">, setDataChannel: import("@reduxjs/toolkit").ActionCreatorWithPayload<RTCDataChannel | null, "avatar/setDataChannel">, setStopInteraction: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setStopInteraction">, setMuted: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setMuted">, setAutoMicActive: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setAutoMicActive">, setVolume: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, "avatar/setVolume">, setAvatarSpeaking: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setAvatarSpeaking">, setScreenSharing: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setScreenSharing">, setUserTalking: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setUserTalking">, setConnectionToken: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setConnectionToken">, setCloseConnectionHandler: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<(() => void) | undefined, "avatar/setCloseConnectionHandler">, setSessionTerminatedByServer: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setSessionTerminatedByServer">, resetAvatar: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"avatar/resetAvatar">;
15
+ export declare const setSessionId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setSessionId">, setDataChannel: import("@reduxjs/toolkit").ActionCreatorWithPayload<RTCDataChannel | null, "avatar/setDataChannel">, setStopInteraction: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setStopInteraction">, setMuted: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setMuted">, setAutoMicActive: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setAutoMicActive">, setVolume: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, "avatar/setVolume">, setAvatarSpeaking: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setAvatarSpeaking">, setScreenSharing: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setScreenSharing">, setUserTalking: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setUserTalking">, setConnectionToken: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, "avatar/setConnectionToken">, setCloseConnectionHandler: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<(() => void) | undefined, "avatar/setCloseConnectionHandler">, setSessionTerminatedByServer: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "avatar/setSessionTerminatedByServer">, resetAvatar: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"avatar/resetAvatar">;
22
16
  export declare const avatarReducer: import("redux").Reducer<AvatarState>;
@@ -8,4 +8,3 @@ export declare const store: import("@reduxjs/toolkit").EnhancedStore<{
8
8
  }, undefined, import("redux").UnknownAction>;
9
9
  }>, import("redux").StoreEnhancer]>>;
10
10
  export type RootState = ReturnType<typeof store.getState>;
11
- export type AppDispatch = typeof store.dispatch;
@@ -11,25 +11,3 @@ export interface BaseController<TOptions = unknown> {
11
11
  */
12
12
  destroy(silent?: boolean): void;
13
13
  }
14
- /**
15
- * Extended controller interface with lifecycle hooks
16
- */
17
- export interface LifecycleController<TOptions = unknown> extends BaseController<TOptions> {
18
- /**
19
- * Initialize controller (called after construction)
20
- */
21
- initialize?(): void;
22
- /**
23
- * Hook called before destroy
24
- */
25
- beforeDestroy?(): void;
26
- }
27
- /**
28
- * Controller with render capabilities
29
- */
30
- export interface RenderController<TOptions = unknown> extends LifecycleController<TOptions> {
31
- /**
32
- * Render or re-render the component
33
- */
34
- render(): void;
35
- }
@@ -30,12 +30,6 @@ export declare class InitializationError extends SDKError {
30
30
  export declare class TokenError extends SDKError {
31
31
  constructor(message: string, context?: Record<string, unknown>);
32
32
  }
33
- /**
34
- * React version compatibility errors
35
- */
36
- export declare class ReactVersionError extends SDKError {
37
- constructor(message: string, context?: Record<string, unknown>);
38
- }
39
33
  /**
40
34
  * Connection related errors
41
35
  */
@@ -48,30 +42,6 @@ export declare class ConnectionError extends SDKError {
48
42
  export declare class WebRTCError extends SDKError {
49
43
  constructor(message: string, context?: Record<string, unknown>);
50
44
  }
51
- /**
52
- * API related errors
53
- */
54
- export declare class APIError extends SDKError {
55
- readonly status?: number;
56
- readonly response?: unknown;
57
- constructor(message: string, status?: number, response?: unknown, context?: Record<string, unknown>);
58
- toJSON(): {
59
- status: number | undefined;
60
- response: unknown;
61
- name: string;
62
- message: string;
63
- code: string;
64
- timestamp: string;
65
- context: Record<string, unknown> | undefined;
66
- stack: string | undefined;
67
- };
68
- }
69
- /**
70
- * Configuration related errors
71
- */
72
- export declare class ConfigurationError extends SDKError {
73
- constructor(message: string, context?: Record<string, unknown>);
74
- }
75
45
  /**
76
46
  * Feature related errors
77
47
  */
@@ -123,10 +93,6 @@ export declare enum ErrorCodes {
123
93
  * Type guard to check if an error is an SDK error
124
94
  */
125
95
  export declare function isSDKError(error: unknown): error is SDKError;
126
- /**
127
- * Helper function to create appropriate error based on context
128
- */
129
- export declare function createError(type: "initialization" | "token" | "react" | "connection" | "webrtc" | "api" | "config" | "feature" | "media" | "faceTracking", message: string, context?: Record<string, unknown>): SDKError;
130
96
  /**
131
97
  * Error handler utility for consistent error processing
132
98
  */
@@ -1,7 +1,5 @@
1
- import type { AnalyticsConfig } from "./analytics";
2
1
  import { DataChannelMessageType } from "../constants/events";
3
2
  export * from "./errors";
4
- export * from "./analytics";
5
3
  export * from "./abstract-typing";
6
4
  /**
7
5
  * Placement positions used to anchor the UI on screen.
@@ -326,17 +324,42 @@ export interface PersistenceOptions {
326
324
  */
327
325
  iframeOnNavigate?: boolean;
328
326
  /**
329
- * URLs/domains excluded from persistence: instead of loading inside the iframe they
330
- * open as a normal top-level navigation (which ends the session). Use for pages that
331
- * can't be framed (auth / SSO) or shouldn't be (checkout, signout). Cross-origin
332
- * links always open top-level by default, so this only matters for same-origin.
327
+ * Pages of YOUR OWN site that must not be framed: they open as a normal top-level
328
+ * navigation, which ends the session. Use for anything that breaks inside an iframe
329
+ * or shouldn't be wrapped — auth / SSO, checkout, sign-out.
330
+ *
331
+ * Same-origin only, and that is not a limitation: anything cross-origin already opens
332
+ * top-level unless you list it under {@link include}.
333
333
  */
334
334
  exclude?: {
335
- /** Hostnames to exclude (exact host or a parent domain, e.g. `"napster.com"`). */
336
- domains?: string[];
337
- /** URLs to exclude: an absolute `"https://…"` (exact/prefix) or a same-origin path prefix. */
335
+ /** An absolute `"https://…"` (exact or prefix) or a same-origin path prefix (`"/checkout"`). */
338
336
  urls?: string[];
339
337
  };
338
+ /**
339
+ * Other people's domains that ARE allowed to load inside the site frame, so following
340
+ * a link to them keeps the session alive instead of ending it. Everything cross-origin
341
+ * breaks out by default; this is the exception list.
342
+ *
343
+ * ```ts
344
+ * include: { domains: ["docs.example.com", "partner.io"] }
345
+ * ```
346
+ *
347
+ * Matches the exact host or any subdomain of it. Only add a domain you control or have
348
+ * agreed with, and know what you give up — inside a cross-origin page the engine can
349
+ * see nothing:
350
+ *
351
+ * - the site must permit framing at all; one that sends `X-Frame-Options: DENY` or a
352
+ * restrictive `frame-ancestors` shows a blank frame, and that cannot be detected;
353
+ * - links clicked in there are not intercepted, so the user can wander anywhere and
354
+ * nothing brings them back;
355
+ * - the address bar stops following the frame, and back/forward stop syncing with it;
356
+ * - ending the session there cannot reload the page the user is on, so it unwraps to
357
+ * the last page of your own site instead.
358
+ */
359
+ include?: {
360
+ /** Hostnames allowed inside the frame (exact host or a parent domain, e.g. `"example.com"`). */
361
+ domains?: string[];
362
+ };
340
363
  /** Value for the site iframe's `allow` attribute (Permissions Policy). Default: `"autoplay; clipboard-write"`. */
341
364
  iframeAllowAttribute?: string;
342
365
  /**
@@ -452,8 +475,6 @@ export interface NapsterCompanionApiConfig {
452
475
  /** Optional companion picture shown on the button. */
453
476
  avatarUrl?: string;
454
477
  };
455
- /** Analytics configuration controls analytics delivery and tracking. */
456
- analytics?: AnalyticsConfig;
457
478
  /** Lifecycle callbacks. All are optional. */
458
479
  /** Called when the SDK has finished initialization and is ready to render. */
459
480
  onReady?: () => void;
@@ -96,9 +96,5 @@ declare class DebugLogger {
96
96
  /**
97
97
  * Global debug logger instance
98
98
  */
99
- export declare const debugLogger: DebugLogger;
100
- /**
101
- * Convenience export for common usage
102
- */
103
99
  export declare const debug: DebugLogger;
104
100
  export {};
@@ -5,10 +5,3 @@
5
5
  * level down in `context.error`.
6
6
  */
7
7
  export declare function rootCauseName(error: unknown): string | undefined;
8
- /**
9
- * Whether a media failure leaves the user with a recoverable permission
10
- * problem. Both flavors land on the same "access blocked" screen: a denied
11
- * prompt is fixable in site settings, and a missing device is equally fatal to
12
- * a voice session, so neither may negotiate a session the agent cannot hear.
13
- */
14
- export declare function isMicUnavailable(error: unknown): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@touchcastllc/napster-companion-api-dev",
3
- "version": "1.5.0-alpha.0",
3
+ "version": "1.6.0-alpha.0",
4
4
  "keywords": [
5
5
  "napster",
6
6
  "companion-api",
@@ -1,148 +0,0 @@
1
- import type { AnalyticsConfig } from "../types/analytics";
2
- /**
3
- * Analytics service class
4
- */
5
- export declare class AnalyticsService {
6
- private config;
7
- private eventQueue;
8
- private performanceQueue;
9
- private errorQueue;
10
- private flushTimer?;
11
- private sessionId;
12
- private providers;
13
- constructor(config?: Partial<AnalyticsConfig>);
14
- /**
15
- * Setup analytics providers from configuration
16
- */
17
- private setupProviders;
18
- /**
19
- * Generate a unique session ID
20
- */
21
- private generateSessionId;
22
- /**
23
- * Start the flush timer for batched sending
24
- */
25
- private startFlushTimer;
26
- /**
27
- * Setup automatic error tracking
28
- */
29
- private setupErrorTracking;
30
- /**
31
- * Setup performance tracking
32
- */
33
- private setupPerformanceTracking;
34
- /**
35
- * Track an analytics event
36
- */
37
- trackEvent(name: string, properties?: Record<string, unknown>): void;
38
- /**
39
- * Track a performance metric
40
- */
41
- trackPerformance(name: string, value: number, unit: "ms" | "bytes" | "count" | "percentage", context?: Record<string, unknown>): void;
42
- /**
43
- * Track an error
44
- */
45
- trackError(error: Error, context?: Record<string, unknown>): void;
46
- /**
47
- * Track user interaction
48
- */
49
- trackInteraction(action: string, target?: string, properties?: Record<string, unknown>): void;
50
- /**
51
- * Flush all queued data
52
- */
53
- flush(): void;
54
- /**
55
- * Flush events queue
56
- */
57
- private flushEvents;
58
- /**
59
- * Flush performance queue
60
- */
61
- private flushPerformance;
62
- /**
63
- * Flush errors queue
64
- */
65
- private flushErrors;
66
- /**
67
- * Send data to analytics endpoint
68
- */
69
- private sendData;
70
- /**
71
- * Send data to a specific analytics provider
72
- */
73
- private sendToProvider;
74
- /**
75
- * Send to custom endpoint (backward compatible)
76
- */
77
- private sendToCustomEndpoint;
78
- /**
79
- * Provider-specific send methods
80
- */
81
- private sendToGA4;
82
- private sendToMixpanel;
83
- private sendToSegment;
84
- private sendToAmplitude;
85
- private sendToPostHog;
86
- private sendToAzureInsights;
87
- /**
88
- * Update configuration
89
- */
90
- updateConfig(newConfig: Partial<AnalyticsConfig>): void;
91
- /**
92
- * Destroy the analytics service
93
- */
94
- destroy(): void;
95
- }
96
- /**
97
- * Initialize analytics service
98
- *
99
- * @example
100
- * // Single provider configuration
101
- * const analytics = initializeAnalytics({
102
- * enabled: true,
103
- * provider: {
104
- * type: 'google-analytics-4',
105
- * measurementId: 'G-XXXXXXXXXX',
106
- * apiKey: 'your-api-secret'
107
- * }
108
- * });
109
- *
110
- * @example
111
- * // Multiple providers configuration
112
- * const analytics = initializeAnalytics({
113
- * enabled: true,
114
- * providers: [
115
- * {
116
- * type: 'google-analytics-4',
117
- * measurementId: 'G-XXXXXXXXXX',
118
- * apiKey: 'your-api-secret'
119
- * },
120
- * {
121
- * type: 'mixpanel',
122
- * projectToken: 'your-mixpanel-token'
123
- * }
124
- * ]
125
- * });
126
- *
127
- * @example
128
- * // Backward compatible legacy configuration
129
- * const analytics = initializeAnalytics({
130
- * enabled: true,
131
- * endpoint: 'https://your-api.com/analytics',
132
- * apiKey: 'your-api-key'
133
- * });
134
- */
135
- export declare function initializeAnalytics(config: Partial<AnalyticsConfig>): AnalyticsService;
136
- /**
137
- * Get the global analytics instance
138
- */
139
- export declare function getAnalytics(): AnalyticsService | null;
140
- /**
141
- * Convenience functions for common tracking
142
- */
143
- export declare const analytics: {
144
- track: (name: string, properties?: Record<string, unknown>) => void;
145
- performance: (name: string, value: number, unit: "ms" | "bytes" | "count" | "percentage", context?: Record<string, unknown>) => void;
146
- error: (error: Error, context?: Record<string, unknown>) => void;
147
- interaction: (action: string, target?: string, properties?: Record<string, unknown>) => void;
148
- };
@@ -1,95 +0,0 @@
1
- /**
2
- * Analytics and monitoring service for SDK usage tracking
3
- */
4
- export interface AnalyticsEvent {
5
- /** Name of the analytics event */
6
- name: string;
7
- /** Properties associated with the event */
8
- properties?: Record<string, unknown>;
9
- /** Timestamp of the event */
10
- timestamp?: number;
11
- /** User identifier */
12
- userId?: string;
13
- /** Session identifier */
14
- sessionId?: string;
15
- }
16
- /**
17
- * Supported analytics providers
18
- */
19
- export type AnalyticsProvider = "custom" | "google-analytics-4" | "mixpanel" | "segment" | "amplitude" | "posthog" | "azure-insights";
20
- /**
21
- * Analytics provider configuration
22
- */
23
- export interface ProviderConfig {
24
- /** Type of analytics provider */
25
- type: AnalyticsProvider;
26
- /** Measurement ID for Google Analytics 4 */
27
- measurementId?: string;
28
- /** Project token for Mixpanel */
29
- projectToken?: string;
30
- /** Write key for Segment */
31
- writeKey?: string;
32
- /** Generic API key */
33
- apiKey?: string;
34
- /** Custom endpoint */
35
- endpoint?: string;
36
- /** Regional endpoint */
37
- region?: string;
38
- }
39
- /**
40
- * Performance metric data structure
41
- */
42
- export interface PerformanceMetric {
43
- /** Name of the performance metric */
44
- name: string;
45
- /** Value of the metric */
46
- value: number;
47
- /** Unit of the metric value */
48
- unit: "ms" | "bytes" | "count" | "percentage";
49
- /** Timestamp of the metric */
50
- timestamp?: number;
51
- /** Additional context for the metric */
52
- context?: Record<string, unknown>;
53
- }
54
- /**
55
- * Error event data structure
56
- */
57
- export interface ErrorEvent {
58
- /** Error object */
59
- error: Error;
60
- /** Additional context for the error */
61
- context?: Record<string, unknown>;
62
- /** Timestamp of the error event */
63
- timestamp?: number;
64
- /** User identifier */
65
- userId?: string;
66
- /** Session identifier */
67
- sessionId?: string;
68
- /** Stack trace of the error */
69
- stack?: string;
70
- }
71
- /**
72
- * Analytics configuration options
73
- */
74
- export interface AnalyticsConfig {
75
- /** Enable or disable analytics tracking */
76
- enabled: boolean;
77
- /** Analytics service provider configuration */
78
- provider?: ProviderConfig;
79
- /** Support multiple analytics service providers */
80
- providers?: ProviderConfig[];
81
- /** Unique user identifier for tracking purposes */
82
- userId?: string;
83
- /** Unique session identifier for tracking purposes */
84
- sessionId?: string;
85
- /** Batch size for sending analytics events */
86
- batchSize?: number;
87
- /** Interval in milliseconds for flushing analytics data */
88
- flushInterval?: number;
89
- /** Enable or disable performance tracking */
90
- enablePerformanceTracking?: boolean;
91
- /** Enable or disable error tracking */
92
- enableErrorTracking?: boolean;
93
- /** Enable or disable user interaction tracking */
94
- enableUserInteractionTracking?: boolean;
95
- }