saltfish 0.2.76 → 0.2.77

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.
@@ -2920,11 +2920,11 @@ class StateMachineActionHandler {
2920
2920
  destroy() {
2921
2921
  }
2922
2922
  /**
2923
- * Validates URL requirement for a specific step
2923
+ * Validates URL requirement for a specific step with retry logic
2924
2924
  * @param step - The step to validate
2925
- * @returns true if validation passes or no requirement exists, false if validation fails
2925
+ * @returns Promise<boolean> - true if validation passes, false otherwise
2926
2926
  */
2927
- validateStepUrlRequirement(step) {
2927
+ async validateStepUrlRequirement(step) {
2928
2928
  if (!step.urlRequirement) {
2929
2929
  return true;
2930
2930
  }
@@ -2932,40 +2932,53 @@ class StateMachineActionHandler {
2932
2932
  if (!pattern) {
2933
2933
  return true;
2934
2934
  }
2935
- const currentUrl = window.location.href.split("#")[0];
2936
- const currentPath = window.location.pathname;
2937
- let matches = false;
2938
- if (matchType === "regex") {
2939
- try {
2940
- const regex = new RegExp(pattern);
2941
- matches = regex.test(currentUrl) || regex.test(currentPath);
2942
- log(`StateMachineActionHandler: URL requirement validation (regex) - matches: ${matches}`);
2943
- } catch (error2) {
2944
- matches = false;
2935
+ const checkUrl = () => {
2936
+ const currentUrl = window.location.href.split("#")[0];
2937
+ const currentPath = window.location.pathname;
2938
+ let matches = false;
2939
+ if (matchType === "regex") {
2940
+ try {
2941
+ const regex = new RegExp(pattern);
2942
+ matches = regex.test(currentUrl) || regex.test(currentPath);
2943
+ } catch (error2) {
2944
+ }
2945
+ } else if (matchType === "contains") {
2946
+ matches = currentUrl.includes(pattern) || currentPath.includes(pattern);
2947
+ } else {
2948
+ matches = currentUrl === pattern || currentPath === pattern;
2945
2949
  }
2946
- } else if (matchType === "contains") {
2947
- matches = currentUrl.includes(pattern) || currentPath.includes(pattern);
2948
- } else {
2949
- matches = currentUrl === pattern || currentPath === pattern;
2950
- }
2951
- if (!matches) {
2952
- log(`StateMachineActionHandler: URL requirement validation failed for step '${step.id}'`);
2953
- const saltfishPlayer = window._saltfishPlayer;
2954
- if (saltfishPlayer && typeof saltfishPlayer.destroy === "function") {
2955
- saltfishPlayer.destroy();
2950
+ return matches;
2951
+ };
2952
+ const maxRetries = 3;
2953
+ const retryDelay = 100;
2954
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
2955
+ if (checkUrl()) {
2956
+ return true;
2957
+ }
2958
+ if (attempt < maxRetries - 1) {
2959
+ await new Promise((resolve) => setTimeout(resolve, retryDelay));
2960
+ const saltfishPlayer2 = window._saltfishPlayer;
2961
+ if (!saltfishPlayer2) {
2962
+ return false;
2963
+ }
2956
2964
  }
2957
2965
  }
2958
- return matches;
2966
+ log(`StateMachineActionHandler: URL requirement validation failed after ${maxRetries} retries for step '${step.id}'`);
2967
+ const saltfishPlayer = window._saltfishPlayer;
2968
+ if (saltfishPlayer && typeof saltfishPlayer.destroy === "function") {
2969
+ saltfishPlayer.destroy();
2970
+ }
2971
+ return false;
2959
2972
  }
2960
2973
  // Private action handler methods
2961
- handleStartVideoPlayback(context) {
2974
+ async handleStartVideoPlayback(context) {
2962
2975
  if (!context.currentStep) {
2963
2976
  return;
2964
2977
  }
2965
2978
  const currentStep = context.currentStep;
2966
2979
  if (currentStep.urlRequirement) {
2967
2980
  log(`StateMachineActionHandler: Validating URL requirement for step ${currentStep.id}`);
2968
- const isValid = this.validateStepUrlRequirement(currentStep);
2981
+ const isValid = await this.validateStepUrlRequirement(currentStep);
2969
2982
  if (!isValid) {
2970
2983
  return;
2971
2984
  }
@@ -10815,7 +10828,7 @@ const SaltfishPlayer$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
10815
10828
  __proto__: null,
10816
10829
  SaltfishPlayer
10817
10830
  }, Symbol.toStringTag, { value: "Module" }));
10818
- const version = "0.2.76";
10831
+ const version = "0.2.77";
10819
10832
  const packageJson = {
10820
10833
  version
10821
10834
  };