saltfish 0.2.25 → 0.2.27
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/stateMachine.d.ts +0 -3
- package/dist/core/stateMachine.d.ts.map +1 -1
- package/dist/core/stateMachineConfig.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 +16 -76
- package/dist/saltfish-playlist-player.umd.js +1 -1
- package/package.json +1 -1
|
@@ -722,11 +722,6 @@ class PlayerStateMachine {
|
|
|
722
722
|
}
|
|
723
723
|
},
|
|
724
724
|
logErrorRecovery: () => {
|
|
725
|
-
},
|
|
726
|
-
autoProgressToNextStep: (_context, event) => {
|
|
727
|
-
if ((event == null ? void 0 : event.type) === "VIDEO_FINISHED_CONTINUE") {
|
|
728
|
-
log(`State Machine: Auto-progressing from step: ${event.step.id}`);
|
|
729
|
-
}
|
|
730
725
|
}
|
|
731
726
|
};
|
|
732
727
|
}
|
|
@@ -782,7 +777,7 @@ class PlayerStateMachine {
|
|
|
782
777
|
* @param event - The event to process
|
|
783
778
|
*/
|
|
784
779
|
updateContextFromEvent(event) {
|
|
785
|
-
if (event.type === "TRANSITION_TO_STEP" || event.type === "MANIFEST_LOADED" || event.type === "
|
|
780
|
+
if (event.type === "TRANSITION_TO_STEP" || event.type === "MANIFEST_LOADED" || event.type === "VIDEO_FINISHED_WAIT") {
|
|
786
781
|
this.context.currentStep = event.step;
|
|
787
782
|
} else if (event.type === "ERROR") {
|
|
788
783
|
this.context.error = event.error;
|
|
@@ -856,10 +851,6 @@ const playerStateMachineConfig = {
|
|
|
856
851
|
on: {
|
|
857
852
|
"PAUSE": { target: "paused" },
|
|
858
853
|
"MINIMIZE": { target: "minimized" },
|
|
859
|
-
"VIDEO_FINISHED_CONTINUE": {
|
|
860
|
-
target: "playing",
|
|
861
|
-
actions: ["autoProgressToNextStep"]
|
|
862
|
-
},
|
|
863
854
|
"VIDEO_FINISHED_WAIT": { target: "waitingForInteraction" },
|
|
864
855
|
"AUTOPLAY_FALLBACK": { target: "autoplayBlocked" },
|
|
865
856
|
"TRANSITION_TO_STEP": {
|
|
@@ -2932,16 +2923,25 @@ class StateMachineActionHandler {
|
|
|
2932
2923
|
}
|
|
2933
2924
|
this.managers.videoManager.setCompletionPolicy(completionPolicy, () => {
|
|
2934
2925
|
if (context.currentStep) {
|
|
2926
|
+
const store = useSaltfishStore.getState();
|
|
2935
2927
|
if (!hasSpecialTransitions) {
|
|
2936
2928
|
log("StateMachineActionHandler: Setting up transitions after video ended");
|
|
2937
2929
|
this.managers.transitionManager.setupTransitions(context.currentStep, true);
|
|
2930
|
+
const hasValidNextSteps = context.currentStep.transitions.some((transition) => {
|
|
2931
|
+
return store.manifest.steps.some((s) => s.id === transition.nextStep);
|
|
2932
|
+
});
|
|
2933
|
+
if (!hasValidNextSteps) {
|
|
2934
|
+
log("StateMachineActionHandler: No valid next steps found, completing playlist");
|
|
2935
|
+
store.sendStateMachineEvent({
|
|
2936
|
+
type: "COMPLETE_PLAYLIST"
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2939
|
+
} else {
|
|
2940
|
+
store.sendStateMachineEvent({
|
|
2941
|
+
type: "VIDEO_FINISHED_WAIT",
|
|
2942
|
+
step: context.currentStep
|
|
2943
|
+
});
|
|
2938
2944
|
}
|
|
2939
|
-
const eventType = hasSpecialTransitions ? "VIDEO_FINISHED_WAIT" : "VIDEO_FINISHED_CONTINUE";
|
|
2940
|
-
const store = useSaltfishStore.getState();
|
|
2941
|
-
store.sendStateMachineEvent({
|
|
2942
|
-
type: eventType,
|
|
2943
|
-
step: context.currentStep
|
|
2944
|
-
});
|
|
2945
2945
|
}
|
|
2946
2946
|
});
|
|
2947
2947
|
log("StateMachineActionHandler: Starting async video load");
|
|
@@ -4927,74 +4927,14 @@ class VideoManager {
|
|
|
4927
4927
|
* Handles video ended event for automatic completion policy
|
|
4928
4928
|
*/
|
|
4929
4929
|
__publicField(this, "handleAutoVideoEnded", () => {
|
|
4930
|
-
var _a;
|
|
4931
|
-
const store = useSaltfishStore.getState();
|
|
4932
|
-
const currentStepId = store.currentStepId;
|
|
4933
|
-
if (!currentStepId || !store.manifest) {
|
|
4934
|
-
return;
|
|
4935
|
-
}
|
|
4936
|
-
const currentStep = store.manifest.steps.find((step) => step.id === currentStepId);
|
|
4937
|
-
if (!currentStep) {
|
|
4938
|
-
return;
|
|
4939
|
-
}
|
|
4940
4930
|
if (this.videoEndedCallback) {
|
|
4941
4931
|
this.videoEndedCallback();
|
|
4942
4932
|
}
|
|
4943
|
-
const hasExternalUrlButtons = ((_a = currentStep.buttons) == null ? void 0 : _a.some((button) => button.action.type === "url")) ?? false;
|
|
4944
|
-
const stepIndex = store.manifest.steps.findIndex((s) => s.id === currentStep.id);
|
|
4945
|
-
const isLastInSequence = stepIndex === store.manifest.steps.length - 1;
|
|
4946
|
-
const hasValidNextSteps = currentStep.transitions.some((transition) => {
|
|
4947
|
-
return store.manifest.steps.some((s) => s.id === transition.nextStep);
|
|
4948
|
-
});
|
|
4949
|
-
const isEffectivelyFinal = hasExternalUrlButtons || isLastInSequence || !hasValidNextSteps;
|
|
4950
|
-
const hasUrlPathTransitions = currentStep.transitions.some((t) => t.type === "url-path");
|
|
4951
|
-
const hasDomClickTransitions = currentStep.transitions.some((t) => t.type === "dom-click");
|
|
4952
|
-
const hasDomElementVisibleTransitions = currentStep.transitions.some((t) => t.type === "dom-element-visible");
|
|
4953
|
-
const hasButtons = currentStep.buttons && currentStep.buttons.length > 0;
|
|
4954
|
-
if (hasUrlPathTransitions || hasDomClickTransitions || hasDomElementVisibleTransitions || hasButtons) {
|
|
4955
|
-
if (isEffectivelyFinal && hasExternalUrlButtons) {
|
|
4956
|
-
store.updateProgressWithCompletion(store.manifest.id, currentStepId);
|
|
4957
|
-
}
|
|
4958
|
-
return;
|
|
4959
|
-
}
|
|
4960
|
-
if (currentStep.transitions.length > 0) {
|
|
4961
|
-
const defaultTransition = currentStep.transitions[0];
|
|
4962
|
-
const nextStepId = defaultTransition.nextStep;
|
|
4963
|
-
store.goToStep(nextStepId);
|
|
4964
|
-
} else {
|
|
4965
|
-
if (store.completePlaylist) {
|
|
4966
|
-
store.completePlaylist();
|
|
4967
|
-
} else {
|
|
4968
|
-
store.goToStep("completed");
|
|
4969
|
-
}
|
|
4970
|
-
}
|
|
4971
4933
|
});
|
|
4972
4934
|
/**
|
|
4973
4935
|
* Handles video ended event for manual completion policy
|
|
4974
4936
|
*/
|
|
4975
4937
|
__publicField(this, "handleManualVideoEnded", () => {
|
|
4976
|
-
var _a;
|
|
4977
|
-
const store = useSaltfishStore.getState();
|
|
4978
|
-
const currentStepId = store.currentStepId;
|
|
4979
|
-
if (currentStepId && store.manifest && store.manifest.steps) {
|
|
4980
|
-
const currentStep = store.manifest.steps.find((step) => step.id === currentStepId);
|
|
4981
|
-
if (currentStep) {
|
|
4982
|
-
const hasExternalUrlButtons = ((_a = currentStep.buttons) == null ? void 0 : _a.some((button) => button.action.type === "url")) ?? false;
|
|
4983
|
-
const stepIndex = store.manifest.steps.findIndex((s) => s.id === currentStep.id);
|
|
4984
|
-
const isLastInSequence = stepIndex === store.manifest.steps.length - 1;
|
|
4985
|
-
const hasValidNextSteps = currentStep.transitions.some((transition) => {
|
|
4986
|
-
return store.manifest.steps.some((s) => s.id === transition.nextStep);
|
|
4987
|
-
});
|
|
4988
|
-
const isEffectivelyFinal = hasExternalUrlButtons || isLastInSequence || !hasValidNextSteps;
|
|
4989
|
-
if (isEffectivelyFinal && hasExternalUrlButtons) {
|
|
4990
|
-
store.updateProgressWithCompletion(store.manifest.id, currentStepId);
|
|
4991
|
-
if (this.videoEndedCallback) {
|
|
4992
|
-
this.videoEndedCallback();
|
|
4993
|
-
}
|
|
4994
|
-
return;
|
|
4995
|
-
}
|
|
4996
|
-
}
|
|
4997
|
-
}
|
|
4998
4938
|
if (this.videoEndedCallback) {
|
|
4999
4939
|
this.videoEndedCallback();
|
|
5000
4940
|
}
|