saltfish 0.3.81 → 0.3.82

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.
@@ -9676,6 +9676,9 @@ class TransitionManager {
9676
9676
  if (this.isStateMachineValidating) {
9677
9677
  return;
9678
9678
  }
9679
+ if (this.triggerManager) {
9680
+ this.triggerManager.clearTriggeredForNonMatchingUrls();
9681
+ }
9679
9682
  const urlPathTransitions = Array.from(this.activeTransitions.entries()).filter(([_, transition]) => {
9680
9683
  var _a;
9681
9684
  return ((_a = transition.data) == null ? void 0 : _a.type) === "url-path";
@@ -9692,6 +9695,9 @@ class TransitionManager {
9692
9695
  if (!hasValidTransition) {
9693
9696
  const isValidUrl = this.validateCurrentStepUrl();
9694
9697
  if (!isValidUrl) {
9698
+ if (this.triggerManager) {
9699
+ this.triggerManager.evaluateAllTriggers();
9700
+ }
9695
9701
  return;
9696
9702
  }
9697
9703
  }
@@ -10007,8 +10013,12 @@ class TransitionManager {
10007
10013
  log(`TransitionManager: Expected pattern: '${urlRequirement.pattern}' (matchType: ${urlRequirement.matchType})`);
10008
10014
  this.cleanupTransitions();
10009
10015
  const saltfishPlayer = window._saltfishPlayer;
10010
- if (saltfishPlayer && typeof saltfishPlayer.destroy === "function") {
10011
- saltfishPlayer.destroy();
10016
+ if (saltfishPlayer && typeof saltfishPlayer.closePlaylist === "function") {
10017
+ saltfishPlayer.closePlaylist();
10018
+ } else {
10019
+ if (saltfishPlayer && typeof saltfishPlayer.destroy === "function") {
10020
+ saltfishPlayer.destroy();
10021
+ }
10012
10022
  }
10013
10023
  }
10014
10024
  /**
@@ -10938,6 +10948,32 @@ class TriggerManager {
10938
10948
  this.triggeredPlaylistsSet.delete(playlistId);
10939
10949
  }
10940
10950
  }
10951
+ /**
10952
+ * Clears triggered state for playlists whose URL condition no longer matches the current URL.
10953
+ * This allows re-triggering when the user navigates back to a matching URL via SPA navigation.
10954
+ * Only clears playlists that have a URL trigger condition — non-URL triggers keep their state.
10955
+ */
10956
+ clearTriggeredForNonMatchingUrls() {
10957
+ var _a;
10958
+ if (this.triggeredPlaylistsSet.size === 0) {
10959
+ return;
10960
+ }
10961
+ const triggeredIds = Array.from(this.triggeredPlaylistsSet);
10962
+ log(`TriggerManager: clearTriggeredForNonMatchingUrls - checking ${triggeredIds.length} triggered playlists: [${triggeredIds.map((id) => id.substring(0, 8)).join(", ")}]`);
10963
+ for (const playlistId of triggeredIds) {
10964
+ const playlist = this.triggeredPlaylists.find((p) => p.id === playlistId);
10965
+ if (!((_a = playlist == null ? void 0 : playlist.triggers) == null ? void 0 : _a.url)) {
10966
+ log(`TriggerManager: Playlist ${playlistId.substring(0, 8)} has no URL trigger, keeping triggered state`);
10967
+ continue;
10968
+ }
10969
+ const urlStillMatches = this.evaluateURLCondition(playlist.triggers);
10970
+ if (!urlStillMatches) {
10971
+ this.triggeredPlaylistsSet.delete(playlistId);
10972
+ } else {
10973
+ log(`TriggerManager: Playlist ${playlistId.substring(0, 8)} URL still matches, keeping triggered state`);
10974
+ }
10975
+ }
10976
+ }
10941
10977
  /**
10942
10978
  * Resets the triggered playlists tracking
10943
10979
  * Useful for testing or when user context changes
@@ -12791,6 +12827,16 @@ const _SaltfishPlayer = class _SaltfishPlayer {
12791
12827
  resetPlaylist() {
12792
12828
  this.playlistOrchestrator.resetPlaylist();
12793
12829
  }
12830
+ /**
12831
+ * Close the current playlist while preserving the trigger system.
12832
+ * Used when a playlist needs to be stopped (e.g. URL validation failure)
12833
+ * but triggers should keep monitoring for future URL changes.
12834
+ */
12835
+ closePlaylist() {
12836
+ this.managerOrchestrator.cleanupPlaylist();
12837
+ const store = useSaltfishStore.getState();
12838
+ store.resetForNewPlaylist();
12839
+ }
12794
12840
  /**
12795
12841
  * Destroy the player and clean up all resources
12796
12842
  */
@@ -12857,7 +12903,7 @@ const SaltfishPlayer$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
12857
12903
  __proto__: null,
12858
12904
  SaltfishPlayer
12859
12905
  }, Symbol.toStringTag, { value: "Module" }));
12860
- const version = "0.3.81";
12906
+ const version = "0.3.82";
12861
12907
  const packageJson = {
12862
12908
  version
12863
12909
  };