saltfish 0.2.26 → 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.
@@ -2923,11 +2923,20 @@ class StateMachineActionHandler {
2923
2923
  }
2924
2924
  this.managers.videoManager.setCompletionPolicy(completionPolicy, () => {
2925
2925
  if (context.currentStep) {
2926
+ const store = useSaltfishStore.getState();
2926
2927
  if (!hasSpecialTransitions) {
2927
2928
  log("StateMachineActionHandler: Setting up transitions after video ended");
2928
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
+ }
2929
2939
  } else {
2930
- const store = useSaltfishStore.getState();
2931
2940
  store.sendStateMachineEvent({
2932
2941
  type: "VIDEO_FINISHED_WAIT",
2933
2942
  step: context.currentStep
@@ -4918,74 +4927,14 @@ class VideoManager {
4918
4927
  * Handles video ended event for automatic completion policy
4919
4928
  */
4920
4929
  __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
4930
  if (this.videoEndedCallback) {
4932
4931
  this.videoEndedCallback();
4933
4932
  }
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
4933
  });
4963
4934
  /**
4964
4935
  * Handles video ended event for manual completion policy
4965
4936
  */
4966
4937
  __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
4938
  if (this.videoEndedCallback) {
4990
4939
  this.videoEndedCallback();
4991
4940
  }