saltfish 0.1.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.
- package/LICENSE +34 -0
- package/README.md +633 -0
- package/dist/components/buttons/ExitButton.d.ts +9 -0
- package/dist/components/buttons/ExitButton.d.ts.map +1 -0
- package/dist/components/buttons/MinimizeButton.d.ts +11 -0
- package/dist/components/buttons/MinimizeButton.d.ts.map +1 -0
- package/dist/components/buttons/PlayPauseButton.d.ts +13 -0
- package/dist/components/buttons/PlayPauseButton.d.ts.map +1 -0
- package/dist/core/SaltfishPlayer.d.ts +154 -0
- package/dist/core/SaltfishPlayer.d.ts.map +1 -0
- package/dist/core/stateMachine.d.ts +119 -0
- package/dist/core/stateMachine.d.ts.map +1 -0
- package/dist/core/stateMachineConfig.d.ts +7 -0
- package/dist/core/stateMachineConfig.d.ts.map +1 -0
- package/dist/core/store.d.ts +27 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/managers/AnalyticsManager.d.ts +107 -0
- package/dist/managers/AnalyticsManager.d.ts.map +1 -0
- package/dist/managers/ButtonManager.d.ts +40 -0
- package/dist/managers/ButtonManager.d.ts.map +1 -0
- package/dist/managers/CursorManager.d.ts +143 -0
- package/dist/managers/CursorManager.d.ts.map +1 -0
- package/dist/managers/EventManager.d.ts +127 -0
- package/dist/managers/EventManager.d.ts.map +1 -0
- package/dist/managers/InteractionManager.d.ts +58 -0
- package/dist/managers/InteractionManager.d.ts.map +1 -0
- package/dist/managers/PlaylistManager.d.ts +42 -0
- package/dist/managers/PlaylistManager.d.ts.map +1 -0
- package/dist/managers/SessionManager.d.ts +56 -0
- package/dist/managers/SessionManager.d.ts.map +1 -0
- package/dist/managers/SessionRecordingManager.d.ts +52 -0
- package/dist/managers/SessionRecordingManager.d.ts.map +1 -0
- package/dist/managers/ShadowDOMManager.d.ts +35 -0
- package/dist/managers/ShadowDOMManager.d.ts.map +1 -0
- package/dist/managers/StepTimeoutManager.d.ts +38 -0
- package/dist/managers/StepTimeoutManager.d.ts.map +1 -0
- package/dist/managers/TransitionManager.d.ts +73 -0
- package/dist/managers/TransitionManager.d.ts.map +1 -0
- package/dist/managers/VideoManager.d.ts +231 -0
- package/dist/managers/VideoManager.d.ts.map +1 -0
- package/dist/observers/EventObserver.d.ts +52 -0
- package/dist/observers/EventObserver.d.ts.map +1 -0
- package/dist/observers/UIObserver.d.ts +43 -0
- package/dist/observers/UIObserver.d.ts.map +1 -0
- package/dist/patterns/Observer.d.ts +63 -0
- package/dist/patterns/Observer.d.ts.map +1 -0
- package/dist/patterns/PlayerStateSubject.d.ts +34 -0
- package/dist/patterns/PlayerStateSubject.d.ts.map +1 -0
- package/dist/player.js +8 -0
- package/dist/player.min.js +6 -0
- package/dist/saltfish-playlist-player.es.js +7202 -0
- package/dist/saltfish-playlist-player.umd.js +1 -0
- package/dist/styles/index.d.ts +14 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +337 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/ErrorHandler.d.ts +106 -0
- package/dist/utils/ErrorHandler.d.ts.map +1 -0
- package/dist/utils/PositionCalculator.d.ts +90 -0
- package/dist/utils/PositionCalculator.d.ts.map +1 -0
- package/dist/utils/deviceDetection.d.ts +90 -0
- package/dist/utils/deviceDetection.d.ts.map +1 -0
- package/dist/utils/dimensions.d.ts +26 -0
- package/dist/utils/dimensions.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +35 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/mockManifest.d.ts +27 -0
- package/dist/utils/mockManifest.d.ts.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PlayerState } from '../../types/index';
|
|
2
|
+
import type { VideoManager } from '../../managers/VideoManager';
|
|
3
|
+
export declare class PlayPauseButton {
|
|
4
|
+
private playButton;
|
|
5
|
+
private container;
|
|
6
|
+
private videoManager;
|
|
7
|
+
constructor(container: HTMLElement, videoManager?: VideoManager);
|
|
8
|
+
private createButton;
|
|
9
|
+
private handlePlayClick;
|
|
10
|
+
updateState(state: PlayerState): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=PlayPauseButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayPauseButton.d.ts","sourceRoot":"","sources":["../../../src/components/buttons/PlayPauseButton.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,YAAY,CAA6B;gBAErC,SAAS,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,YAAY;IAM/D,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,eAAe;IAuDhB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAmBrC,OAAO,IAAI,IAAI;CAIvB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { VideoManager } from '../managers/VideoManager';
|
|
2
|
+
import { SaltfishEventName, EventHandler } from '../managers/EventManager';
|
|
3
|
+
import type { SaltfishConfig, PlaylistOptions } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Main class for the Saltfish playlist Player
|
|
6
|
+
*/
|
|
7
|
+
export declare class SaltfishPlayer {
|
|
8
|
+
private static instance;
|
|
9
|
+
private shadowDOMManager;
|
|
10
|
+
videoManager: VideoManager;
|
|
11
|
+
private cursorManager;
|
|
12
|
+
private interactionManager;
|
|
13
|
+
private analyticsManager;
|
|
14
|
+
private sessionRecordingManager;
|
|
15
|
+
private sessionManager;
|
|
16
|
+
private buttonManager;
|
|
17
|
+
private transitionManager;
|
|
18
|
+
private eventManager;
|
|
19
|
+
private playlistManager;
|
|
20
|
+
private stepTimeoutManager;
|
|
21
|
+
private stateSubject;
|
|
22
|
+
private uiObserver;
|
|
23
|
+
private eventObserver;
|
|
24
|
+
private playerRoot;
|
|
25
|
+
private playerElement;
|
|
26
|
+
private minimizeButton;
|
|
27
|
+
private exitButton;
|
|
28
|
+
private playPauseButton;
|
|
29
|
+
private isInitialized;
|
|
30
|
+
private isDragging;
|
|
31
|
+
private dragOffset;
|
|
32
|
+
private justFinishedDragging;
|
|
33
|
+
private dragStartPosition;
|
|
34
|
+
private hasMoved;
|
|
35
|
+
private resizeListener;
|
|
36
|
+
private static prevState;
|
|
37
|
+
private static destroyTimeoutId;
|
|
38
|
+
private lastConfig;
|
|
39
|
+
private lastUserIdentification;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new Saltfish playlist Player instance
|
|
42
|
+
* @private Constructor is private to enforce singleton pattern
|
|
43
|
+
*/
|
|
44
|
+
private constructor();
|
|
45
|
+
/**
|
|
46
|
+
* Gets the singleton instance of the Saltfish playlist Player
|
|
47
|
+
*/
|
|
48
|
+
static getInstance(): SaltfishPlayer;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the current sessionId (persistent across 30 minutes)
|
|
51
|
+
* @returns The current sessionId
|
|
52
|
+
*/
|
|
53
|
+
getSessionId(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the current runId (unique per playlist execution)
|
|
56
|
+
* @returns The current runId or null if no playlist is running
|
|
57
|
+
*/
|
|
58
|
+
getRunId(): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Initializes the Saltfish playlist Player
|
|
61
|
+
* @param config - Configuration options
|
|
62
|
+
*/
|
|
63
|
+
initialize(config: SaltfishConfig): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates the player element
|
|
66
|
+
* This is now private and will be called by startPlaylist
|
|
67
|
+
*/
|
|
68
|
+
private createPlayerUI;
|
|
69
|
+
/**
|
|
70
|
+
* Identifies the current user
|
|
71
|
+
* @param userId - User ID
|
|
72
|
+
* @param userData - Additional user data
|
|
73
|
+
*/
|
|
74
|
+
identifyUser(userId: string, userData?: any): void;
|
|
75
|
+
/**
|
|
76
|
+
* Fetches user data from the backend
|
|
77
|
+
* @param userId - User ID
|
|
78
|
+
* @param userData - Additional user data
|
|
79
|
+
*/
|
|
80
|
+
private fetchUserData;
|
|
81
|
+
/**
|
|
82
|
+
* Starts a new playlist
|
|
83
|
+
* @param playlistId - ID of the playlist to start
|
|
84
|
+
* @param options - Optional playback options including position, drag behavior, and starting step
|
|
85
|
+
* @param options.position - Position of the player on screen
|
|
86
|
+
* @param options.allowDrag - Whether the player can be dragged
|
|
87
|
+
* @param options.startNodeId - Optional step ID to start from instead of the manifest's default startStep
|
|
88
|
+
*
|
|
89
|
+
* If the player has been destroyed, it will automatically reinitialize using the last configuration
|
|
90
|
+
* before starting the playlist.
|
|
91
|
+
*/
|
|
92
|
+
startPlaylist(playlistId: string, options?: PlaylistOptions): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Registers action handlers with the state machine
|
|
95
|
+
*/
|
|
96
|
+
private registerStateMachineActions;
|
|
97
|
+
/**
|
|
98
|
+
* Finds the URL of the next video in the playlist
|
|
99
|
+
* @param currentStep - The current step being played
|
|
100
|
+
* @returns The URL of the next video or null if no next video exists
|
|
101
|
+
*/
|
|
102
|
+
private findNextVideoUrl;
|
|
103
|
+
/**
|
|
104
|
+
* Handles store state changes
|
|
105
|
+
*/
|
|
106
|
+
private handleStoreChanges;
|
|
107
|
+
/**
|
|
108
|
+
* Updates the position of the player element based on store state
|
|
109
|
+
*/
|
|
110
|
+
private updatePosition;
|
|
111
|
+
/**
|
|
112
|
+
* Handles minimize button click
|
|
113
|
+
*/
|
|
114
|
+
private handleMinimizeClick;
|
|
115
|
+
/**
|
|
116
|
+
* Sets up drag handlers for the player
|
|
117
|
+
*/
|
|
118
|
+
private setupDragHandlers;
|
|
119
|
+
/**
|
|
120
|
+
* Destroys the Saltfish playlist Player instance
|
|
121
|
+
*/
|
|
122
|
+
destroy(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Updates the visibility of player controls based on the current state
|
|
125
|
+
* @param state - The current player state
|
|
126
|
+
*/
|
|
127
|
+
private updateControlsVisibility;
|
|
128
|
+
/**
|
|
129
|
+
* Handles completed state
|
|
130
|
+
*/
|
|
131
|
+
private handleCompletedState;
|
|
132
|
+
/**
|
|
133
|
+
* Registers an event listener to be called when the given eventName is triggered
|
|
134
|
+
* @param eventName - Name of event to listen for
|
|
135
|
+
* @param listener - Function to call when the event is triggered
|
|
136
|
+
*/
|
|
137
|
+
on<T extends SaltfishEventName>(eventName: T, listener: EventHandler<T>): void;
|
|
138
|
+
/**
|
|
139
|
+
* Removes an event listener for the given eventName
|
|
140
|
+
* @param eventName - Name of event to stop listening for
|
|
141
|
+
* @param listener - Function to remove
|
|
142
|
+
* @returns true if the listener was removed, false if it wasn't found
|
|
143
|
+
*/
|
|
144
|
+
off<T extends SaltfishEventName>(eventName: T, listener: EventHandler<T>): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Resets the current playlist to its initial state
|
|
147
|
+
*/
|
|
148
|
+
resetPlaylist(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Cleans up the current playlist state
|
|
151
|
+
*/
|
|
152
|
+
private cleanupCurrentPlaylist;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=SaltfishPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SaltfishPlayer.d.ts","sourceRoot":"","sources":["../../src/core/SaltfishPlayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAQxD,OAAO,EAAgB,iBAAiB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGzF,OAAO,KAAK,EAAE,cAAc,EAAe,eAAe,EAAQ,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|
3
|
+
type: 'INITIALIZE';
|
|
4
|
+
} | {
|
|
5
|
+
type: 'LOAD_MANIFEST';
|
|
6
|
+
} | {
|
|
7
|
+
type: 'MANIFEST_LOADED';
|
|
8
|
+
step: Step;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'PLAY';
|
|
11
|
+
} | {
|
|
12
|
+
type: 'PAUSE';
|
|
13
|
+
} | {
|
|
14
|
+
type: 'MINIMIZE';
|
|
15
|
+
} | {
|
|
16
|
+
type: 'MAXIMIZE';
|
|
17
|
+
} | {
|
|
18
|
+
type: 'VIDEO_ENDED';
|
|
19
|
+
step: Step;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'TRANSITION_TO_STEP';
|
|
22
|
+
step: Step;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'WAIT_FOR_INTERACTION';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'INTERACTION_COMPLETED';
|
|
27
|
+
} | {
|
|
28
|
+
type: 'ERROR';
|
|
29
|
+
error: Error;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'AUTOPLAY_FALLBACK';
|
|
32
|
+
} | {
|
|
33
|
+
type: 'COMPLETE_PLAYLIST';
|
|
34
|
+
};
|
|
35
|
+
export interface PlayerContext {
|
|
36
|
+
currentStep: Step | null;
|
|
37
|
+
error: Error | null;
|
|
38
|
+
}
|
|
39
|
+
export type ActionFunction = (context: PlayerContext, event?: PlayerEvent) => void;
|
|
40
|
+
export type Action = string | ActionFunction;
|
|
41
|
+
export type StateTransition = {
|
|
42
|
+
target: PlayerState;
|
|
43
|
+
actions?: Action[];
|
|
44
|
+
};
|
|
45
|
+
export type StateConfig = {
|
|
46
|
+
on: {
|
|
47
|
+
[key in PlayerEvent['type']]?: StateTransition;
|
|
48
|
+
};
|
|
49
|
+
entry?: Action[];
|
|
50
|
+
exit?: Action[];
|
|
51
|
+
};
|
|
52
|
+
export type StateMachineConfig = {
|
|
53
|
+
states: {
|
|
54
|
+
[key in PlayerState]: StateConfig;
|
|
55
|
+
};
|
|
56
|
+
initial: PlayerState;
|
|
57
|
+
};
|
|
58
|
+
export interface ActionHandlers {
|
|
59
|
+
[actionName: string]: ActionFunction;
|
|
60
|
+
}
|
|
61
|
+
export declare class PlayerStateMachine {
|
|
62
|
+
private currentState;
|
|
63
|
+
private config;
|
|
64
|
+
private context;
|
|
65
|
+
private actionHandlers;
|
|
66
|
+
constructor(config: StateMachineConfig, initialContext: PlayerContext);
|
|
67
|
+
/**
|
|
68
|
+
* Set up default action handlers for common operations
|
|
69
|
+
*/
|
|
70
|
+
private setupDefaultActions;
|
|
71
|
+
/**
|
|
72
|
+
* Register custom action handlers
|
|
73
|
+
* @param actions - Object mapping action names to handler functions
|
|
74
|
+
*/
|
|
75
|
+
registerActions(actions: ActionHandlers): void;
|
|
76
|
+
/**
|
|
77
|
+
* Execute an action (either named or inline function)
|
|
78
|
+
* @param action - The action to execute
|
|
79
|
+
* @param event - Optional event that triggered the action
|
|
80
|
+
*/
|
|
81
|
+
private executeAction;
|
|
82
|
+
/**
|
|
83
|
+
* Send an event to the state machine to trigger a transition
|
|
84
|
+
* @param event - The event to send
|
|
85
|
+
* @returns The new state after the transition
|
|
86
|
+
*/
|
|
87
|
+
send(event: PlayerEvent): PlayerState;
|
|
88
|
+
/**
|
|
89
|
+
* Update context based on the event
|
|
90
|
+
* @param event - The event to process
|
|
91
|
+
*/
|
|
92
|
+
private updateContextFromEvent;
|
|
93
|
+
/**
|
|
94
|
+
* Get the current state of the state machine
|
|
95
|
+
* @returns The current state
|
|
96
|
+
*/
|
|
97
|
+
getState(): PlayerState;
|
|
98
|
+
/**
|
|
99
|
+
* Get the current context of the state machine
|
|
100
|
+
* @returns The current context
|
|
101
|
+
*/
|
|
102
|
+
getContext(): PlayerContext;
|
|
103
|
+
/**
|
|
104
|
+
* Update the context directly (use with caution)
|
|
105
|
+
* @param updater Function that takes the current context and returns an updated one
|
|
106
|
+
*/
|
|
107
|
+
updateContext(updater: (context: PlayerContext) => Partial<PlayerContext>): void;
|
|
108
|
+
/**
|
|
109
|
+
* Run entry actions for a state
|
|
110
|
+
* @param state - The state to run entry actions for
|
|
111
|
+
*/
|
|
112
|
+
private runEntryActions;
|
|
113
|
+
/**
|
|
114
|
+
* Run exit actions for a state
|
|
115
|
+
* @param state - The state to run exit actions for
|
|
116
|
+
*/
|
|
117
|
+
private runExitActions;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=stateMachine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateMachine.d.ts","sourceRoot":"","sources":["../../src/core/stateMachine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIlD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,uBAAuB,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAGlC,MAAM,WAA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G;IACH,OAAO,CAAC,sBAAsB;IAQ9B;;;OAGG;IACI,QAAQ,IAAI,WAAW;IAI9B;;;OAGG;IACI,UAAU,IAAI,aAAa;IAIlC;;;OAGG;IACI,aAAa,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;IAKvF;;;OAGG;IACH,OAAO,CAAC,eAAe;IAOvB;;;OAGG;IACH,OAAO,CAAC,cAAc;CAMvB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StateMachineConfig } from './stateMachine';
|
|
2
|
+
/**
|
|
3
|
+
* Pure configuration for the player state machine
|
|
4
|
+
* All side effects are handled through named actions
|
|
5
|
+
*/
|
|
6
|
+
export declare const playerStateMachineConfig: StateMachineConfig;
|
|
7
|
+
//# sourceMappingURL=stateMachineConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateMachineConfig.d.ts","sourceRoot":"","sources":["../../src/core/stateMachineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,kBAoGtC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SaltfishStore, Step } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates the Saltfish playlist Player store with Zustand and Immer
|
|
4
|
+
* Using vanilla store to avoid React hooks
|
|
5
|
+
*/
|
|
6
|
+
export declare const saltfishStore: Omit<import("zustand/vanilla").StoreApi<SaltfishStore>, "setState"> & {
|
|
7
|
+
setState(nextStateOrUpdater: SaltfishStore | Partial<SaltfishStore> | ((state: import("immer").WritableDraft<SaltfishStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
8
|
+
};
|
|
9
|
+
type StoreAdapter = {
|
|
10
|
+
getState: () => SaltfishStore;
|
|
11
|
+
setState: typeof saltfishStore.setState;
|
|
12
|
+
subscribe: typeof saltfishStore.subscribe;
|
|
13
|
+
destroy: typeof saltfishStore.destroy;
|
|
14
|
+
};
|
|
15
|
+
export declare const useSaltfishStore: StoreAdapter;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the current step from the store
|
|
18
|
+
* This is a React hook and should only be used in React components
|
|
19
|
+
*/
|
|
20
|
+
export declare const useCurrentStep: () => Step | null;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the current step directly from the store state
|
|
23
|
+
* This is a regular function that can be used in non-React environments
|
|
24
|
+
*/
|
|
25
|
+
export declare const getCurrentStep: () => Step | null;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAIb,IAAI,EAKL,MAAM,UAAU,CAAC;AAgBlB;;;GAGG;AACH,eAAO,MAAM,aAAa;;CA2azB,CAAC;AAIF,KAAK,YAAY,GAAG;IAClB,QAAQ,EAAE,MAAM,aAAa,CAAC;IAC9B,QAAQ,EAAE,OAAO,aAAa,CAAC,QAAQ,CAAC;IACxC,SAAS,EAAE,OAAO,aAAa,CAAC,SAAS,CAAC;IAC1C,OAAO,EAAE,OAAO,aAAa,CAAC,OAAO,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,YAK9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAO,IAAI,GAAG,IAKxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAO,IAAI,GAAG,IAKxC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { SaltfishConfig, PlaylistOptions, playlistManifest } from './types';
|
|
2
|
+
import { SaltfishEventName, EventHandler } from './managers/EventManager';
|
|
3
|
+
import type { DeviceInfo } from './utils/deviceDetection';
|
|
4
|
+
/**
|
|
5
|
+
* Global Saltfish playlist Player API
|
|
6
|
+
*/
|
|
7
|
+
export interface SaltfishAPI {
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the Saltfish playlist Player
|
|
10
|
+
* @param token - Saltfish API token or configuration object
|
|
11
|
+
* @returns Promise that resolves when initialization is complete
|
|
12
|
+
* @note You don't need to use await with this method - it can be called synchronously.
|
|
13
|
+
* You can also listen for the 'initialized' event instead of awaiting the promise.
|
|
14
|
+
* @example
|
|
15
|
+
* // Using with just a token:
|
|
16
|
+
* saltfish.init('YOUR_API_TOKEN');
|
|
17
|
+
* saltfish.startPlaylist('your_playlist_id');
|
|
18
|
+
*
|
|
19
|
+
* // Using with configuration object:
|
|
20
|
+
* saltfish.init({
|
|
21
|
+
* token: 'YOUR_API_TOKEN',
|
|
22
|
+
* enableAnalytics: false // Disable analytics for development
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Using with events:
|
|
26
|
+
* saltfish.on('initialized', () => {
|
|
27
|
+
* saltfish.startPlaylist('your_playlist_id');
|
|
28
|
+
* });
|
|
29
|
+
* saltfish.init('YOUR_API_TOKEN');
|
|
30
|
+
*/
|
|
31
|
+
init: (token: string | SaltfishConfig) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Identifies the current user
|
|
34
|
+
* @param userId - User ID
|
|
35
|
+
* @param userData - Additional user data
|
|
36
|
+
*/
|
|
37
|
+
identify: (userId: string, userData?: Record<string, any>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Starts a playlist
|
|
40
|
+
* @param playlistId - playlist ID to start
|
|
41
|
+
* @param options - Optional configuration for position, drag behavior, and starting step
|
|
42
|
+
* @param options.position - Position of the player on screen
|
|
43
|
+
* @param options.allowDrag - Whether the player can be dragged
|
|
44
|
+
* @param options.startNodeId - Optional step ID to start from instead of the manifest's default startStep
|
|
45
|
+
* @returns Promise that resolves when playlist is started
|
|
46
|
+
* @note You don't need to use await with this method - it can be called synchronously.
|
|
47
|
+
* You can also listen for the 'playlistStarted' event instead of awaiting the promise.
|
|
48
|
+
* @note If a list of playlists was provided by the backend during initialization, the `playlistId` parameter
|
|
49
|
+
* may be ignored, and the player will attempt to load the first playlist from that list.
|
|
50
|
+
* @note If a playlist is already running, this will automatically reset the store state and start the new playlist with a clean state.
|
|
51
|
+
* @example
|
|
52
|
+
* // Using without await:
|
|
53
|
+
* saltfish.startPlaylist('your_playlist_id');
|
|
54
|
+
*
|
|
55
|
+
* // Starting from a specific step:
|
|
56
|
+
* saltfish.startPlaylist('your_playlist_id', { startNodeId: 'step2' });
|
|
57
|
+
*
|
|
58
|
+
* // Starting a new playlist while another is running:
|
|
59
|
+
* saltfish.startPlaylist('new_playlist_id'); // Automatically resets state
|
|
60
|
+
*
|
|
61
|
+
* // Using with events:
|
|
62
|
+
* saltfish.on('playlistStarted', (event) => {
|
|
63
|
+
* console.log('Playlist started:', event.playlist.id);
|
|
64
|
+
* });
|
|
65
|
+
* saltfish.startPlaylist('your_playlist_id');
|
|
66
|
+
*/
|
|
67
|
+
startPlaylist: (playlistId: string, options?: PlaylistOptions) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the current session ID
|
|
70
|
+
* @returns The unique session ID generated during initialization
|
|
71
|
+
*/
|
|
72
|
+
getSessionId: () => string;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the current run ID
|
|
75
|
+
* @returns The unique run ID for the current playlist execution, or null if no playlist is running
|
|
76
|
+
*/
|
|
77
|
+
getRunId: () => string | null;
|
|
78
|
+
/**
|
|
79
|
+
* Registers an event listener to be called when the given eventName is triggered
|
|
80
|
+
* @param eventName - Name of event to listen for. See list of supported events.
|
|
81
|
+
* @param listener - Function to call when the event is triggered
|
|
82
|
+
*/
|
|
83
|
+
on: <T extends SaltfishEventName>(eventName: T, listener: EventHandler<T>) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Removes an event listener for the given eventName
|
|
86
|
+
* @param eventName - Name of event to stop listening for
|
|
87
|
+
* @param listener - Function to remove
|
|
88
|
+
* @returns true if the listener was removed, false if it wasn't found
|
|
89
|
+
*/
|
|
90
|
+
off: <T extends SaltfishEventName>(eventName: T, listener: EventHandler<T>) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Resets the current playlist
|
|
93
|
+
*/
|
|
94
|
+
resetPlaylist: () => void;
|
|
95
|
+
/**
|
|
96
|
+
* Destroys the Saltfish playlist Player
|
|
97
|
+
*/
|
|
98
|
+
destroy: () => void;
|
|
99
|
+
/**
|
|
100
|
+
* Testing utilities for development mode only
|
|
101
|
+
* These will be removed in production builds
|
|
102
|
+
*/
|
|
103
|
+
__dev__?: {
|
|
104
|
+
/**
|
|
105
|
+
* Sets a custom mock manifest for testing
|
|
106
|
+
* @param manifest - The manifest to use for testing
|
|
107
|
+
*/
|
|
108
|
+
setMockManifest: (manifest: playlistManifest) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Creates a custom mock manifest based on provided overrides
|
|
111
|
+
* @param overrides - Partial playlistManifest to override default values
|
|
112
|
+
*/
|
|
113
|
+
createMockManifest: (overrides: Partial<playlistManifest>) => playlistManifest;
|
|
114
|
+
/**
|
|
115
|
+
* The default mock manifest
|
|
116
|
+
*/
|
|
117
|
+
defaultMockManifest: playlistManifest;
|
|
118
|
+
/**
|
|
119
|
+
* Gets current device detection information
|
|
120
|
+
* @returns DeviceInfo object with all device details
|
|
121
|
+
*/
|
|
122
|
+
getDeviceInfo: () => DeviceInfo;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
declare const saltfish: SaltfishAPI;
|
|
126
|
+
export default saltfish;
|
|
127
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE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AE,OAAO,CAAC,gBAAgB,CAAC,KAAK,gBAAgB,CAAC;QAE/E;;WAEG;QACH,mBAAmB,EAAE,gBAAgB,CAAC;QAEtC;;;WAGG;QACH,aAAa,EAAE,MAAM,UAAU,CAAC;KACjC,CAAA;CACF;AAyMD,QAAA,MAAM,QAAQ,aAAc,CAAC;AAO7B,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { SaltfishConfig, UserData } from '../types';
|
|
2
|
+
import { EventManager } from './EventManager';
|
|
3
|
+
/**
|
|
4
|
+
* Manager class for tracking and reporting analytics events
|
|
5
|
+
*
|
|
6
|
+
* This class handles tracking of various events in the player, including:
|
|
7
|
+
* - Standard events: playlistStart, playlistComplete, stepStarted, stepComplete
|
|
8
|
+
* - Player state events: playerPaused, playerResumed, playerMinimized, playerMaximized
|
|
9
|
+
* - Error events
|
|
10
|
+
*
|
|
11
|
+
* Events are queued and sent in batches to the backend analytics API.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AnalyticsManager {
|
|
14
|
+
private config;
|
|
15
|
+
private user;
|
|
16
|
+
private eventQueue;
|
|
17
|
+
private isSending;
|
|
18
|
+
private flushInterval;
|
|
19
|
+
private eventManager;
|
|
20
|
+
private sessionId;
|
|
21
|
+
private analyticsEnabled;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new AnalyticsManager
|
|
24
|
+
* @param eventManager - Optional event manager to subscribe to events
|
|
25
|
+
*/
|
|
26
|
+
constructor(eventManager?: EventManager);
|
|
27
|
+
/**
|
|
28
|
+
* Sets the event manager and subscribes to relevant events
|
|
29
|
+
* @param eventManager - Event manager instance
|
|
30
|
+
*/
|
|
31
|
+
setEventManager(eventManager: EventManager): void;
|
|
32
|
+
/**
|
|
33
|
+
* Subscribe to relevant player events for analytics tracking
|
|
34
|
+
*/
|
|
35
|
+
private subscribeToEvents;
|
|
36
|
+
/**
|
|
37
|
+
* Helper to get the store state when needed
|
|
38
|
+
*/
|
|
39
|
+
private getStore;
|
|
40
|
+
/**
|
|
41
|
+
* Initializes the analytics manager
|
|
42
|
+
* @param config - Saltfish configuration
|
|
43
|
+
* @param sessionId - Unique session identifier
|
|
44
|
+
*/
|
|
45
|
+
initialize(config: SaltfishConfig, sessionId?: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Sets the current user
|
|
48
|
+
* @param user - User data
|
|
49
|
+
*/
|
|
50
|
+
setUser(user: UserData): void;
|
|
51
|
+
/**
|
|
52
|
+
* Tracks a playlist start event
|
|
53
|
+
* @param playlistId - playlist ID
|
|
54
|
+
*/
|
|
55
|
+
trackPlaylistStart(playlistId: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Tracks a playlist completion event
|
|
58
|
+
* @param playlistId - playlist ID
|
|
59
|
+
*/
|
|
60
|
+
trackPlaylistComplete(playlistId: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* Tracks a step started event
|
|
63
|
+
* @param playlistId - playlist ID
|
|
64
|
+
* @param stepId - Step ID
|
|
65
|
+
*/
|
|
66
|
+
trackStepStarted(playlistId: string, stepId: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Tracks a step completion event
|
|
69
|
+
* @param playlistId - playlist ID
|
|
70
|
+
* @param stepId - Step ID
|
|
71
|
+
*/
|
|
72
|
+
trackStepComplete(playlistId: string, stepId: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Tracks an interaction event
|
|
75
|
+
* @param playlistId - playlist ID
|
|
76
|
+
* @param stepId - Step ID
|
|
77
|
+
* @param interactionData - Interaction data
|
|
78
|
+
*/
|
|
79
|
+
trackInteraction(playlistId: string, stepId: string, interactionData: Record<string, any>): void;
|
|
80
|
+
/**
|
|
81
|
+
* Tracks an error event
|
|
82
|
+
* @param playlistId - playlist ID
|
|
83
|
+
* @param error - Error object
|
|
84
|
+
* @param stepId - Optional step ID
|
|
85
|
+
* @param errorType - Optional error type/category (e.g., 'playlist', 'video', 'network', 'initialization')
|
|
86
|
+
*/
|
|
87
|
+
trackError(playlistId: string, error: Error, stepId?: string, errorType?: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Tracks a generic event
|
|
90
|
+
* @param event - Event data
|
|
91
|
+
*/
|
|
92
|
+
private trackEvent;
|
|
93
|
+
/**
|
|
94
|
+
* Sends queued events to the backend
|
|
95
|
+
*/
|
|
96
|
+
private flushEvents;
|
|
97
|
+
/**
|
|
98
|
+
* Cleans up resources used by the analytics manager
|
|
99
|
+
*/
|
|
100
|
+
destroy(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Gets the current runId from the player
|
|
103
|
+
* @returns The current runId or null if not available
|
|
104
|
+
*/
|
|
105
|
+
private getRunId;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=AnalyticsManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnalyticsManager.d.ts","sourceRoot":"","sources":["../../src/managers/AnalyticsManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,gBAAgB,CAAiB;IAEzC;;;OAGG;gBACS,YAAY,CAAC,EAAE,YAAY;IAMvC;;;OAGG;IACI,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAKxD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAgGzB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAUhB;;;;OAIG;IACI,UAAU,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAqBnE;;;OAGG;IACI,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAIpC;;;OAGG;IACI,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAkBnD;;;OAGG;IACI,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAkBtD;;;;OAIG;IACI,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAmBjE;;;;OAIG;IACI,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAmBlE;;;;;OAKG;IACI,gBAAgB,CACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnC,IAAI;IAmBP;;;;;;OAMG;IACI,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAuB9F;;;OAGG;IACH,OAAO,CAAC,UAAU;IAgBlB;;OAEG;YACW,WAAW;IAoDzB;;OAEG;IACI,OAAO,IAAI,IAAI;IA2BtB;;;OAGG;IACH,OAAO,CAAC,QAAQ;CASjB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PlayerState } from '../types';
|
|
2
|
+
import type { VideoManager } from './VideoManager';
|
|
3
|
+
/**
|
|
4
|
+
* ButtonManager is responsible for managing the display of
|
|
5
|
+
* playback buttons, DOM click buttons, and other UI controls in the player.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ButtonManager {
|
|
8
|
+
private playbackButtonsVisible;
|
|
9
|
+
private rootElement;
|
|
10
|
+
private playButton;
|
|
11
|
+
private centerPlayButton;
|
|
12
|
+
private videoManager;
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Initializes the ButtonManager with the root element and video manager
|
|
16
|
+
* Should be called after the player UI is created
|
|
17
|
+
* @param element - The root element containing the player controls
|
|
18
|
+
* @param videoManager - The video manager for handling interactions
|
|
19
|
+
*/
|
|
20
|
+
initialize(element: HTMLElement, videoManager: VideoManager): void;
|
|
21
|
+
/**
|
|
22
|
+
* Displays or hides the DOM click button based on the given visibility state
|
|
23
|
+
* @param visible - Whether the button should be visible
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Displays or hides the playback buttons based on the given visibility state
|
|
27
|
+
* @param visible - Whether the buttons should be visible
|
|
28
|
+
*/
|
|
29
|
+
displayPlaybackButtons(visible: boolean): void;
|
|
30
|
+
/**
|
|
31
|
+
* Updates the play/pause button state based on the video state
|
|
32
|
+
* @param state - The current video state ('playing' or 'paused')
|
|
33
|
+
*/
|
|
34
|
+
updatePlayPauseButton(state: PlayerState): void;
|
|
35
|
+
/**
|
|
36
|
+
* Cleans up any resources used by the button manager
|
|
37
|
+
*/
|
|
38
|
+
destroy(): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=ButtonManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonManager.d.ts","sourceRoot":"","sources":["../../src/managers/ButtonManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,YAAY,CAA6B;;IAMjD;;;;;OAKG;IACI,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI;IAmFzE;;;OAGG;IAEH;;;OAGG;IACI,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAYrD;;;OAGG;IACI,qBAAqB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IA4FtD;;OAEG;IACI,OAAO,IAAI,IAAI;CAQvB"}
|