saltfish 0.2.27 → 0.2.29
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.
|
@@ -1427,16 +1427,7 @@ const saltfishStore = createStore()(
|
|
|
1427
1427
|
},
|
|
1428
1428
|
completePlaylist: () => {
|
|
1429
1429
|
set2((state) => {
|
|
1430
|
-
var _a, _b;
|
|
1431
|
-
const { manifest } = state;
|
|
1432
1430
|
state.currentState = transitionState({ type: "COMPLETE_PLAYLIST" });
|
|
1433
|
-
const playlistPersistence = ((_a = state.playlistOptions) == null ? void 0 : _a.persistence) ?? true;
|
|
1434
|
-
if (manifest && playlistPersistence) {
|
|
1435
|
-
delete state.progress[manifest.id];
|
|
1436
|
-
const userId = (_b = state.user) == null ? void 0 : _b.id;
|
|
1437
|
-
storageManager.setProgress(state.progress, userId);
|
|
1438
|
-
log(`Store: Removed completed playlist ${manifest.id} from localStorage`);
|
|
1439
|
-
}
|
|
1440
1431
|
});
|
|
1441
1432
|
},
|
|
1442
1433
|
// Add new method to reset playlist state while preserving config and user data
|
|
@@ -2885,94 +2876,89 @@ class StateMachineActionHandler {
|
|
|
2885
2876
|
if (!context.currentStep) {
|
|
2886
2877
|
return;
|
|
2887
2878
|
}
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2879
|
+
const currentStep = context.currentStep;
|
|
2880
|
+
if (currentStep.urlRequirement) {
|
|
2881
|
+
log(`StateMachineActionHandler: Validating URL requirement for step ${currentStep.id}`);
|
|
2882
|
+
const isValid = this.validateStepUrlRequirement(currentStep);
|
|
2891
2883
|
if (!isValid) {
|
|
2892
2884
|
return;
|
|
2893
2885
|
}
|
|
2894
2886
|
}
|
|
2895
|
-
const videoUrl = this.getVideoUrl(
|
|
2887
|
+
const videoUrl = this.getVideoUrl(currentStep);
|
|
2896
2888
|
try {
|
|
2897
2889
|
this.managers.interactionManager.clearButtons();
|
|
2898
2890
|
this.managers.interactionManager.clearDOMInteractions();
|
|
2899
|
-
if (
|
|
2900
|
-
this.managers.interactionManager.setupDOMInteractions(
|
|
2891
|
+
if (currentStep.domInteractions) {
|
|
2892
|
+
this.managers.interactionManager.setupDOMInteractions(currentStep.domInteractions);
|
|
2901
2893
|
}
|
|
2902
|
-
if (
|
|
2903
|
-
this.managers.interactionManager.createButtons(
|
|
2894
|
+
if (currentStep.buttons) {
|
|
2895
|
+
this.managers.interactionManager.createButtons(currentStep.buttons);
|
|
2904
2896
|
}
|
|
2905
|
-
log(`StateMachineActionHandler: Processing cursor animations for step ${
|
|
2906
|
-
log(`StateMachineActionHandler: Step has cursor animations: ${!!(
|
|
2907
|
-
if (
|
|
2908
|
-
log(`StateMachineActionHandler: Setting cursor visibility to true for step ${
|
|
2897
|
+
log(`StateMachineActionHandler: Processing cursor animations for step ${currentStep.id}`);
|
|
2898
|
+
log(`StateMachineActionHandler: Step has cursor animations: ${!!(currentStep.cursorAnimations && currentStep.cursorAnimations.length > 0)}`);
|
|
2899
|
+
if (currentStep.cursorAnimations && currentStep.cursorAnimations.length > 0) {
|
|
2900
|
+
log(`StateMachineActionHandler: Setting cursor visibility to true for step ${currentStep.id}`);
|
|
2909
2901
|
this.managers.cursorManager.setShouldShowCursor(true);
|
|
2910
|
-
log(`StateMachineActionHandler: Starting cursor animation for step ${
|
|
2911
|
-
this.managers.cursorManager.animate(
|
|
2902
|
+
log(`StateMachineActionHandler: Starting cursor animation for step ${currentStep.id} with target: ${currentStep.cursorAnimations[0].targetSelector || "no target"}`);
|
|
2903
|
+
this.managers.cursorManager.animate(currentStep.cursorAnimations[0]);
|
|
2912
2904
|
} else {
|
|
2913
|
-
log(`StateMachineActionHandler: Setting cursor visibility to false for step ${
|
|
2905
|
+
log(`StateMachineActionHandler: Setting cursor visibility to false for step ${currentStep.id} - step has no cursor animations`);
|
|
2914
2906
|
this.managers.cursorManager.setShouldShowCursor(false);
|
|
2915
2907
|
}
|
|
2916
|
-
const hasSpecialTransitions =
|
|
2908
|
+
const hasSpecialTransitions = currentStep.buttons && currentStep.buttons.length > 0 || currentStep.transitions.some(
|
|
2917
2909
|
(t) => t.type === "dom-click" || t.type === "url-path" || t.type === "dom-element-visible"
|
|
2918
2910
|
);
|
|
2919
2911
|
const completionPolicy = hasSpecialTransitions ? "manual" : "auto";
|
|
2920
2912
|
if (hasSpecialTransitions) {
|
|
2921
2913
|
log("StateMachineActionHandler: Setting up transitions immediately for step with special transitions");
|
|
2922
|
-
this.managers.transitionManager.setupTransitions(
|
|
2914
|
+
this.managers.transitionManager.setupTransitions(currentStep, false);
|
|
2923
2915
|
}
|
|
2924
2916
|
this.managers.videoManager.setCompletionPolicy(completionPolicy, () => {
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
log("StateMachineActionHandler: No valid next steps found, completing playlist");
|
|
2935
|
-
store.sendStateMachineEvent({
|
|
2936
|
-
type: "COMPLETE_PLAYLIST"
|
|
2937
|
-
});
|
|
2938
|
-
}
|
|
2939
|
-
} else {
|
|
2917
|
+
const store = useSaltfishStore.getState();
|
|
2918
|
+
if (!hasSpecialTransitions) {
|
|
2919
|
+
log("StateMachineActionHandler: Setting up transitions after video ended");
|
|
2920
|
+
this.managers.transitionManager.setupTransitions(currentStep, true);
|
|
2921
|
+
const hasValidNextSteps = currentStep.transitions.some((transition) => {
|
|
2922
|
+
return store.manifest.steps.some((s) => s.id === transition.nextStep);
|
|
2923
|
+
});
|
|
2924
|
+
if (!hasValidNextSteps) {
|
|
2925
|
+
log("StateMachineActionHandler: No valid next steps found, completing playlist");
|
|
2940
2926
|
store.sendStateMachineEvent({
|
|
2941
|
-
type: "
|
|
2942
|
-
step: context.currentStep
|
|
2927
|
+
type: "COMPLETE_PLAYLIST"
|
|
2943
2928
|
});
|
|
2944
2929
|
}
|
|
2930
|
+
} else {
|
|
2931
|
+
store.sendStateMachineEvent({
|
|
2932
|
+
type: "VIDEO_FINISHED_WAIT",
|
|
2933
|
+
step: currentStep
|
|
2934
|
+
});
|
|
2945
2935
|
}
|
|
2946
2936
|
});
|
|
2947
2937
|
log("StateMachineActionHandler: Starting async video load");
|
|
2948
2938
|
const loadTranscriptForStep = () => {
|
|
2949
2939
|
var _a, _b, _c;
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
log(`StateMachineActionHandler: Loading translated transcript for step ${context.currentStep.id} in language ${language}`);
|
|
2962
|
-
} else {
|
|
2963
|
-
log(`StateMachineActionHandler: No translated transcript found for language ${language}, using default`);
|
|
2964
|
-
}
|
|
2965
|
-
} else if (language) {
|
|
2966
|
-
log(`StateMachineActionHandler: No translation available for language ${language}, using default transcript`);
|
|
2967
|
-
}
|
|
2968
|
-
if (transcript) {
|
|
2969
|
-
log(`StateMachineActionHandler: Loading transcript for step ${context.currentStep.id}, initially visible: ${captionsEnabled}`);
|
|
2970
|
-
this.managers.videoManager.loadTranscript(transcript, captionsEnabled);
|
|
2940
|
+
const store = useSaltfishStore.getState();
|
|
2941
|
+
const currentPlaylistId = (_a = store.manifest) == null ? void 0 : _a.id;
|
|
2942
|
+
const currentPlaylist = (_b = store.backendPlaylists) == null ? void 0 : _b.find((p) => p.id === currentPlaylistId);
|
|
2943
|
+
const captionsEnabled = (currentPlaylist == null ? void 0 : currentPlaylist.captions) === true;
|
|
2944
|
+
const language = (_c = store.config) == null ? void 0 : _c.language;
|
|
2945
|
+
let transcript = currentStep.transcript;
|
|
2946
|
+
if (language && currentStep.translations && currentStep.translations[language]) {
|
|
2947
|
+
const translatedTranscript = currentStep.translations[language].transcript;
|
|
2948
|
+
if (translatedTranscript) {
|
|
2949
|
+
transcript = translatedTranscript;
|
|
2950
|
+
log(`StateMachineActionHandler: Loading translated transcript for step ${currentStep.id} in language ${language}`);
|
|
2971
2951
|
} else {
|
|
2972
|
-
log(`StateMachineActionHandler: No transcript
|
|
2973
|
-
this.managers.videoManager.loadTranscript(null, true);
|
|
2952
|
+
log(`StateMachineActionHandler: No translated transcript found for language ${language}, using default`);
|
|
2974
2953
|
}
|
|
2954
|
+
} else if (language) {
|
|
2955
|
+
log(`StateMachineActionHandler: No translation available for language ${language}, using default transcript`);
|
|
2956
|
+
}
|
|
2957
|
+
if (transcript) {
|
|
2958
|
+
log(`StateMachineActionHandler: Loading transcript for step ${currentStep.id}, initially visible: ${captionsEnabled}`);
|
|
2959
|
+
this.managers.videoManager.loadTranscript(transcript, captionsEnabled);
|
|
2975
2960
|
} else {
|
|
2961
|
+
log(`StateMachineActionHandler: No transcript available for step ${currentStep.id}`);
|
|
2976
2962
|
this.managers.videoManager.loadTranscript(null, true);
|
|
2977
2963
|
}
|
|
2978
2964
|
};
|
|
@@ -2980,15 +2966,13 @@ class StateMachineActionHandler {
|
|
|
2980
2966
|
log("StateMachineActionHandler: Video loaded successfully, playing");
|
|
2981
2967
|
loadTranscriptForStep();
|
|
2982
2968
|
this.managers.videoManager.play();
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
this.managers.videoManager.preloadNextVideo(nextVideoUrl);
|
|
2988
|
-
}
|
|
2969
|
+
const nextVideoUrl = this.findNextVideoUrl(currentStep);
|
|
2970
|
+
if (nextVideoUrl) {
|
|
2971
|
+
log(`StateMachineActionHandler: Preloading next video: ${nextVideoUrl}`);
|
|
2972
|
+
this.managers.videoManager.preloadNextVideo(nextVideoUrl);
|
|
2989
2973
|
}
|
|
2990
2974
|
}).catch((error2) => {
|
|
2991
|
-
var _a
|
|
2975
|
+
var _a;
|
|
2992
2976
|
log(`StateMachineActionHandler: Error loading video: ${error2}`);
|
|
2993
2977
|
this.managers.uiManager.showError(
|
|
2994
2978
|
error2 instanceof Error ? error2 : new Error(`Failed to load video: ${error2}`),
|
|
@@ -3000,7 +2984,7 @@ class StateMachineActionHandler {
|
|
|
3000
2984
|
this.managers.eventManager.trigger("error", {
|
|
3001
2985
|
timestamp: Date.now(),
|
|
3002
2986
|
playlistId: ((_a = store.manifest) == null ? void 0 : _a.id) || void 0,
|
|
3003
|
-
stepId:
|
|
2987
|
+
stepId: currentStep.id,
|
|
3004
2988
|
error: errorObj,
|
|
3005
2989
|
errorType: "video",
|
|
3006
2990
|
videoUrl: enrichedError == null ? void 0 : enrichedError.videoUrl,
|
|
@@ -3028,34 +3012,35 @@ class StateMachineActionHandler {
|
|
|
3028
3012
|
if (!context.currentStep) {
|
|
3029
3013
|
return;
|
|
3030
3014
|
}
|
|
3031
|
-
const
|
|
3015
|
+
const currentStep = context.currentStep;
|
|
3016
|
+
const videoUrl = this.getVideoUrl(currentStep);
|
|
3032
3017
|
try {
|
|
3033
3018
|
this.managers.interactionManager.clearButtons();
|
|
3034
3019
|
this.managers.interactionManager.clearDOMInteractions();
|
|
3035
|
-
if (
|
|
3036
|
-
this.managers.interactionManager.setupDOMInteractions(
|
|
3020
|
+
if (currentStep.domInteractions) {
|
|
3021
|
+
this.managers.interactionManager.setupDOMInteractions(currentStep.domInteractions);
|
|
3037
3022
|
}
|
|
3038
|
-
if (
|
|
3039
|
-
this.managers.interactionManager.createButtons(
|
|
3023
|
+
if (currentStep.buttons) {
|
|
3024
|
+
this.managers.interactionManager.createButtons(currentStep.buttons);
|
|
3040
3025
|
}
|
|
3041
|
-
if (
|
|
3042
|
-
log(`StateMachineActionHandler: Setting up cursor animations for idle mode step ${
|
|
3026
|
+
if (currentStep.cursorAnimations && currentStep.cursorAnimations.length > 0) {
|
|
3027
|
+
log(`StateMachineActionHandler: Setting up cursor animations for idle mode step ${currentStep.id}`);
|
|
3043
3028
|
this.managers.cursorManager.setShouldShowCursor(true);
|
|
3044
|
-
this.managers.cursorManager.animate(
|
|
3029
|
+
this.managers.cursorManager.animate(currentStep.cursorAnimations[0]);
|
|
3045
3030
|
} else {
|
|
3046
3031
|
this.managers.cursorManager.setShouldShowCursor(false);
|
|
3047
3032
|
}
|
|
3048
|
-
const hasSpecialTransitions =
|
|
3033
|
+
const hasSpecialTransitions = currentStep.buttons && currentStep.buttons.length > 0 || currentStep.transitions.some(
|
|
3049
3034
|
(t) => t.type === "dom-click" || t.type === "url-path"
|
|
3050
3035
|
);
|
|
3051
3036
|
const completionPolicy = hasSpecialTransitions ? "manual" : "auto";
|
|
3052
3037
|
if (hasSpecialTransitions) {
|
|
3053
3038
|
log("StateMachineActionHandler: Setting up transitions for idle mode step with special transitions");
|
|
3054
|
-
this.managers.transitionManager.setupTransitions(
|
|
3039
|
+
this.managers.transitionManager.setupTransitions(currentStep, false);
|
|
3055
3040
|
}
|
|
3056
3041
|
this.managers.videoManager.setCompletionPolicy(completionPolicy, () => {
|
|
3057
|
-
if (
|
|
3058
|
-
this.managers.transitionManager.setupTransitions(
|
|
3042
|
+
if (!hasSpecialTransitions) {
|
|
3043
|
+
this.managers.transitionManager.setupTransitions(currentStep, true);
|
|
3059
3044
|
}
|
|
3060
3045
|
});
|
|
3061
3046
|
log("StateMachineActionHandler: Starting async idle mode video load");
|
|
@@ -3070,27 +3055,25 @@ class StateMachineActionHandler {
|
|
|
3070
3055
|
log("StateMachineActionHandler: Idle mode video play failed");
|
|
3071
3056
|
});
|
|
3072
3057
|
}
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
log(`StateMachineActionHandler: Using translated transcript for idle mode, language: ${language}`);
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
if (transcript) {
|
|
3088
|
-
log(`StateMachineActionHandler: Loading transcript for idle mode step ${context.currentStep.id}, initially visible: ${captionsEnabled}`);
|
|
3089
|
-
this.managers.videoManager.loadTranscript(transcript, captionsEnabled);
|
|
3090
|
-
} else {
|
|
3091
|
-
this.managers.videoManager.loadTranscript(null, true);
|
|
3058
|
+
const store = useSaltfishStore.getState();
|
|
3059
|
+
const currentPlaylistId = (_a = store.manifest) == null ? void 0 : _a.id;
|
|
3060
|
+
const currentPlaylist = (_b = store.backendPlaylists) == null ? void 0 : _b.find((p) => p.id === currentPlaylistId);
|
|
3061
|
+
const captionsEnabled = (currentPlaylist == null ? void 0 : currentPlaylist.captions) === true;
|
|
3062
|
+
const language = (_c = store.config) == null ? void 0 : _c.language;
|
|
3063
|
+
let transcript = currentStep.transcript;
|
|
3064
|
+
if (language && currentStep.translations && currentStep.translations[language]) {
|
|
3065
|
+
const translation = currentStep.translations[language];
|
|
3066
|
+
if (translation.transcript) {
|
|
3067
|
+
transcript = translation.transcript;
|
|
3068
|
+
log(`StateMachineActionHandler: Using translated transcript for idle mode, language: ${language}`);
|
|
3092
3069
|
}
|
|
3093
3070
|
}
|
|
3071
|
+
if (transcript) {
|
|
3072
|
+
log(`StateMachineActionHandler: Loading transcript for idle mode step ${currentStep.id}, initially visible: ${captionsEnabled}`);
|
|
3073
|
+
this.managers.videoManager.loadTranscript(transcript, captionsEnabled);
|
|
3074
|
+
} else {
|
|
3075
|
+
this.managers.videoManager.loadTranscript(null, true);
|
|
3076
|
+
}
|
|
3094
3077
|
}).catch((error2) => {
|
|
3095
3078
|
log(`StateMachineActionHandler: Error loading idle mode video: ${error2}`);
|
|
3096
3079
|
});
|
|
@@ -3098,16 +3081,24 @@ class StateMachineActionHandler {
|
|
|
3098
3081
|
}
|
|
3099
3082
|
}
|
|
3100
3083
|
handleTrackPlaylistComplete() {
|
|
3084
|
+
var _a, _b;
|
|
3101
3085
|
const store = useSaltfishStore.getState();
|
|
3102
3086
|
if (store.manifest && this.managers.eventManager) {
|
|
3103
|
-
|
|
3087
|
+
const playlistId = store.manifest.id;
|
|
3104
3088
|
this.managers.eventManager.trigger("playlistEnded", {
|
|
3105
3089
|
timestamp: Date.now(),
|
|
3106
3090
|
playlist: {
|
|
3107
|
-
id:
|
|
3091
|
+
id: playlistId,
|
|
3108
3092
|
title: store.manifest.name
|
|
3109
3093
|
}
|
|
3110
3094
|
});
|
|
3095
|
+
const playlistPersistence = ((_a = store.playlistOptions) == null ? void 0 : _a.persistence) ?? true;
|
|
3096
|
+
if (playlistPersistence && store.progress[playlistId]) {
|
|
3097
|
+
const updatedProgress = { ...store.progress };
|
|
3098
|
+
delete updatedProgress[playlistId];
|
|
3099
|
+
const userId = (_b = store.user) == null ? void 0 : _b.id;
|
|
3100
|
+
this.managers.storageManager.setProgress(updatedProgress, userId);
|
|
3101
|
+
}
|
|
3111
3102
|
}
|
|
3112
3103
|
}
|
|
3113
3104
|
handleError(context) {
|