saltfish 0.3.59 → 0.3.60

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.
@@ -6876,6 +6876,44 @@ function isElementValid(element, expectedElement, expectedSize, config = DEFAULT
6876
6876
  }
6877
6877
  return true;
6878
6878
  }
6879
+ const API_URL = "https://player.saltfish.ai/element-errors";
6880
+ function determineFailureReason(selector, expectedElement, expectedSize) {
6881
+ const elements = document.querySelectorAll(selector);
6882
+ if (elements.length === 0) {
6883
+ return "no_elements";
6884
+ }
6885
+ if (expectedElement) {
6886
+ const hasMatchingTag = Array.from(elements).some(
6887
+ (el) => el.tagName.toUpperCase() === expectedElement.tagName.toUpperCase()
6888
+ );
6889
+ if (!hasMatchingTag) {
6890
+ return "tag_mismatch";
6891
+ }
6892
+ return "text_mismatch";
6893
+ }
6894
+ if (expectedSize) {
6895
+ return "size_mismatch";
6896
+ }
6897
+ return "no_elements";
6898
+ }
6899
+ function reportElementError(playlistId, stepId, selector, expectedElement, expectedSize) {
6900
+ const failureReason = determineFailureReason(selector, expectedElement, expectedSize);
6901
+ const payload = {
6902
+ playlistId,
6903
+ stepId,
6904
+ failureReason,
6905
+ selector
6906
+ };
6907
+ fetch(API_URL, {
6908
+ method: "POST",
6909
+ headers: {
6910
+ "Content-Type": "application/json"
6911
+ },
6912
+ body: JSON.stringify(payload)
6913
+ }).catch((error2) => {
6914
+ console.warn("Failed to report element error:", error2);
6915
+ });
6916
+ }
6879
6917
  class CursorManager {
6880
6918
  constructor() {
6881
6919
  __publicField(this, "cursor", null);
@@ -7060,6 +7098,18 @@ class CursorManager {
7060
7098
  const MAX_RETRIES = 10;
7061
7099
  let retryCount = 0;
7062
7100
  let periodicCheckId = null;
7101
+ let errorReported = false;
7102
+ const reportFailure = () => {
7103
+ var _a;
7104
+ if (errorReported) return;
7105
+ errorReported = true;
7106
+ const state = saltfishStore.getState();
7107
+ const playlistId = (_a = state.manifest) == null ? void 0 : _a.id;
7108
+ const stepId = state.currentStepId;
7109
+ if (playlistId && stepId) {
7110
+ reportElementError(playlistId, stepId, selector, expectedElement, expectedSize);
7111
+ }
7112
+ };
7063
7113
  const cleanupWatchers = () => {
7064
7114
  if (this.targetMutationObserver) {
7065
7115
  this.targetMutationObserver.disconnect();
@@ -7074,6 +7124,7 @@ class CursorManager {
7074
7124
  retryCount++;
7075
7125
  if (retryCount > MAX_RETRIES) {
7076
7126
  console.warn(`CursorManager: Stopped waiting for element '${selector}' after ${MAX_RETRIES} attempts`);
7127
+ reportFailure();
7077
7128
  cleanupWatchers();
7078
7129
  return null;
7079
7130
  }
@@ -7099,6 +7150,7 @@ class CursorManager {
7099
7150
  retryCount++;
7100
7151
  if (retryCount > MAX_RETRIES) {
7101
7152
  console.warn(`CursorManager: Stopped waiting for element '${selector}' after ${MAX_RETRIES} attempts`);
7153
+ reportFailure();
7102
7154
  cleanupWatchers();
7103
7155
  return;
7104
7156
  }
@@ -12254,7 +12306,7 @@ const SaltfishPlayer$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
12254
12306
  __proto__: null,
12255
12307
  SaltfishPlayer
12256
12308
  }, Symbol.toStringTag, { value: "Module" }));
12257
- const version = "0.3.59";
12309
+ const version = "0.3.60";
12258
12310
  const packageJson = {
12259
12311
  version
12260
12312
  };