saltfish 0.2.26 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/services/StateMachineActionHandler.d.ts.map +1 -1
- package/dist/core/store.d.ts.map +1 -1
- package/dist/managers/VideoManager.d.ts.map +1 -1
- package/dist/player.js +2 -2
- package/dist/player.min.js +2 -2
- package/dist/saltfish-playlist-player.es.js +20 -72
- package/dist/saltfish-playlist-player.umd.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
@@ -2923,11 +2914,20 @@ class StateMachineActionHandler {
|
|
|
2923
2914
|
}
|
|
2924
2915
|
this.managers.videoManager.setCompletionPolicy(completionPolicy, () => {
|
|
2925
2916
|
if (context.currentStep) {
|
|
2917
|
+
const store = useSaltfishStore.getState();
|
|
2926
2918
|
if (!hasSpecialTransitions) {
|
|
2927
2919
|
log("StateMachineActionHandler: Setting up transitions after video ended");
|
|
2928
2920
|
this.managers.transitionManager.setupTransitions(context.currentStep, true);
|
|
2921
|
+
const hasValidNextSteps = context.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");
|
|
2926
|
+
store.sendStateMachineEvent({
|
|
2927
|
+
type: "COMPLETE_PLAYLIST"
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2929
2930
|
} else {
|
|
2930
|
-
const store = useSaltfishStore.getState();
|
|
2931
2931
|
store.sendStateMachineEvent({
|
|
2932
2932
|
type: "VIDEO_FINISHED_WAIT",
|
|
2933
2933
|
step: context.currentStep
|
|
@@ -3089,16 +3089,24 @@ class StateMachineActionHandler {
|
|
|
3089
3089
|
}
|
|
3090
3090
|
}
|
|
3091
3091
|
handleTrackPlaylistComplete() {
|
|
3092
|
+
var _a, _b;
|
|
3092
3093
|
const store = useSaltfishStore.getState();
|
|
3093
3094
|
if (store.manifest && this.managers.eventManager) {
|
|
3094
|
-
|
|
3095
|
+
const playlistId = store.manifest.id;
|
|
3095
3096
|
this.managers.eventManager.trigger("playlistEnded", {
|
|
3096
3097
|
timestamp: Date.now(),
|
|
3097
3098
|
playlist: {
|
|
3098
|
-
id:
|
|
3099
|
+
id: playlistId,
|
|
3099
3100
|
title: store.manifest.name
|
|
3100
3101
|
}
|
|
3101
3102
|
});
|
|
3103
|
+
const playlistPersistence = ((_a = store.playlistOptions) == null ? void 0 : _a.persistence) ?? true;
|
|
3104
|
+
if (playlistPersistence && store.progress[playlistId]) {
|
|
3105
|
+
const updatedProgress = { ...store.progress };
|
|
3106
|
+
delete updatedProgress[playlistId];
|
|
3107
|
+
const userId = (_b = store.user) == null ? void 0 : _b.id;
|
|
3108
|
+
this.managers.storageManager.setProgress(updatedProgress, userId);
|
|
3109
|
+
}
|
|
3102
3110
|
}
|
|
3103
3111
|
}
|
|
3104
3112
|
handleError(context) {
|
|
@@ -4918,74 +4926,14 @@ class VideoManager {
|
|
|
4918
4926
|
* Handles video ended event for automatic completion policy
|
|
4919
4927
|
*/
|
|
4920
4928
|
__publicField(this, "handleAutoVideoEnded", () => {
|
|
4921
|
-
var _a;
|
|
4922
|
-
const store = useSaltfishStore.getState();
|
|
4923
|
-
const currentStepId = store.currentStepId;
|
|
4924
|
-
if (!currentStepId || !store.manifest) {
|
|
4925
|
-
return;
|
|
4926
|
-
}
|
|
4927
|
-
const currentStep = store.manifest.steps.find((step) => step.id === currentStepId);
|
|
4928
|
-
if (!currentStep) {
|
|
4929
|
-
return;
|
|
4930
|
-
}
|
|
4931
4929
|
if (this.videoEndedCallback) {
|
|
4932
4930
|
this.videoEndedCallback();
|
|
4933
4931
|
}
|
|
4934
|
-
const hasExternalUrlButtons = ((_a = currentStep.buttons) == null ? void 0 : _a.some((button) => button.action.type === "url")) ?? false;
|
|
4935
|
-
const stepIndex = store.manifest.steps.findIndex((s) => s.id === currentStep.id);
|
|
4936
|
-
const isLastInSequence = stepIndex === store.manifest.steps.length - 1;
|
|
4937
|
-
const hasValidNextSteps = currentStep.transitions.some((transition) => {
|
|
4938
|
-
return store.manifest.steps.some((s) => s.id === transition.nextStep);
|
|
4939
|
-
});
|
|
4940
|
-
const isEffectivelyFinal = hasExternalUrlButtons || isLastInSequence || !hasValidNextSteps;
|
|
4941
|
-
const hasUrlPathTransitions = currentStep.transitions.some((t) => t.type === "url-path");
|
|
4942
|
-
const hasDomClickTransitions = currentStep.transitions.some((t) => t.type === "dom-click");
|
|
4943
|
-
const hasDomElementVisibleTransitions = currentStep.transitions.some((t) => t.type === "dom-element-visible");
|
|
4944
|
-
const hasButtons = currentStep.buttons && currentStep.buttons.length > 0;
|
|
4945
|
-
if (hasUrlPathTransitions || hasDomClickTransitions || hasDomElementVisibleTransitions || hasButtons) {
|
|
4946
|
-
if (isEffectivelyFinal && hasExternalUrlButtons) {
|
|
4947
|
-
store.updateProgressWithCompletion(store.manifest.id, currentStepId);
|
|
4948
|
-
}
|
|
4949
|
-
return;
|
|
4950
|
-
}
|
|
4951
|
-
if (currentStep.transitions.length > 0) {
|
|
4952
|
-
const defaultTransition = currentStep.transitions[0];
|
|
4953
|
-
const nextStepId = defaultTransition.nextStep;
|
|
4954
|
-
store.goToStep(nextStepId);
|
|
4955
|
-
} else {
|
|
4956
|
-
if (store.completePlaylist) {
|
|
4957
|
-
store.completePlaylist();
|
|
4958
|
-
} else {
|
|
4959
|
-
store.goToStep("completed");
|
|
4960
|
-
}
|
|
4961
|
-
}
|
|
4962
4932
|
});
|
|
4963
4933
|
/**
|
|
4964
4934
|
* Handles video ended event for manual completion policy
|
|
4965
4935
|
*/
|
|
4966
4936
|
__publicField(this, "handleManualVideoEnded", () => {
|
|
4967
|
-
var _a;
|
|
4968
|
-
const store = useSaltfishStore.getState();
|
|
4969
|
-
const currentStepId = store.currentStepId;
|
|
4970
|
-
if (currentStepId && store.manifest && store.manifest.steps) {
|
|
4971
|
-
const currentStep = store.manifest.steps.find((step) => step.id === currentStepId);
|
|
4972
|
-
if (currentStep) {
|
|
4973
|
-
const hasExternalUrlButtons = ((_a = currentStep.buttons) == null ? void 0 : _a.some((button) => button.action.type === "url")) ?? false;
|
|
4974
|
-
const stepIndex = store.manifest.steps.findIndex((s) => s.id === currentStep.id);
|
|
4975
|
-
const isLastInSequence = stepIndex === store.manifest.steps.length - 1;
|
|
4976
|
-
const hasValidNextSteps = currentStep.transitions.some((transition) => {
|
|
4977
|
-
return store.manifest.steps.some((s) => s.id === transition.nextStep);
|
|
4978
|
-
});
|
|
4979
|
-
const isEffectivelyFinal = hasExternalUrlButtons || isLastInSequence || !hasValidNextSteps;
|
|
4980
|
-
if (isEffectivelyFinal && hasExternalUrlButtons) {
|
|
4981
|
-
store.updateProgressWithCompletion(store.manifest.id, currentStepId);
|
|
4982
|
-
if (this.videoEndedCallback) {
|
|
4983
|
-
this.videoEndedCallback();
|
|
4984
|
-
}
|
|
4985
|
-
return;
|
|
4986
|
-
}
|
|
4987
|
-
}
|
|
4988
|
-
}
|
|
4989
4937
|
if (this.videoEndedCallback) {
|
|
4990
4938
|
this.videoEndedCallback();
|
|
4991
4939
|
}
|