saltfish 0.3.45 → 0.3.46
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/managers/PlaylistManager.d.ts.map +1 -1
- package/dist/managers/TriggerManager.d.ts +3 -3
- package/dist/managers/TriggerManager.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 +29 -17
- package/dist/saltfish-playlist-player.umd.js +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/validators/PlaylistValidator.d.ts +1 -1
- package/dist/validators/PlaylistValidator.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2460,8 +2460,7 @@ class PlaylistValidator {
|
|
|
2460
2460
|
return { isValid: false, error: "Playlist not found in backend list" };
|
|
2461
2461
|
}
|
|
2462
2462
|
const hasTriggers = (foundPlaylist == null ? void 0 : foundPlaylist.hasTriggers) ?? (foundPlaylist == null ? void 0 : foundPlaylist.autoStart) ?? false;
|
|
2463
|
-
|
|
2464
|
-
if (hasTriggers && wasTriggered) {
|
|
2463
|
+
if (hasTriggers) {
|
|
2465
2464
|
const triggerValidation = await this.validateTriggerConditions(
|
|
2466
2465
|
playlistId,
|
|
2467
2466
|
foundPlaylist,
|
|
@@ -2535,12 +2534,14 @@ class PlaylistValidator {
|
|
|
2535
2534
|
const watchedPlaylists = ((_a = currentStore.userData) == null ? void 0 : _a.watchedPlaylists) || {};
|
|
2536
2535
|
const hasTriggers = foundPlaylist.hasTriggers ?? foundPlaylist.autoStart ?? false;
|
|
2537
2536
|
const playlistData = watchedPlaylists[playlistId];
|
|
2538
|
-
|
|
2539
|
-
|
|
2537
|
+
const maxVisits = (_b = foundPlaylist.triggers) == null ? void 0 : _b.maxVisits;
|
|
2538
|
+
const visitCount = (playlistData == null ? void 0 : playlistData.visitCount) ?? 0;
|
|
2539
|
+
if (hasTriggers && maxVisits !== null && maxVisits !== void 0 && visitCount >= maxVisits) {
|
|
2540
|
+
info(`Playlist ${playlistId} has hasTriggers enabled with maxVisits:${maxVisits} and user has ${visitCount} visits. Skipping playlist start.`, {
|
|
2540
2541
|
watchedPlaylists,
|
|
2541
2542
|
triggers: foundPlaylist.triggers
|
|
2542
2543
|
});
|
|
2543
|
-
return { isValid: false, error: `Playlist
|
|
2544
|
+
return { isValid: false, error: `Playlist visit limit reached (${visitCount}/${maxVisits})` };
|
|
2544
2545
|
}
|
|
2545
2546
|
return { isValid: true };
|
|
2546
2547
|
}
|
|
@@ -9664,7 +9665,7 @@ class TriggerManager {
|
|
|
9664
9665
|
log(`TriggerManager: Registered ${this.triggeredPlaylists.length} playlists with triggers`);
|
|
9665
9666
|
this.triggeredPlaylists.forEach((playlist) => {
|
|
9666
9667
|
var _a, _b, _c, _d;
|
|
9667
|
-
log(`TriggerManager: Registered trigger for playlist ${playlist.id} - URL: ${(_a = playlist.triggers) == null ? void 0 : _a.url}, ElementClick: ${(_b = playlist.triggers) == null ? void 0 : _b.elementClicked}, ElementVisible: ${(_c = playlist.triggers) == null ? void 0 : _c.elementVisible},
|
|
9668
|
+
log(`TriggerManager: Registered trigger for playlist ${playlist.id} - URL: ${(_a = playlist.triggers) == null ? void 0 : _a.url}, ElementClick: ${(_b = playlist.triggers) == null ? void 0 : _b.elementClicked}, ElementVisible: ${(_c = playlist.triggers) == null ? void 0 : _c.elementVisible}, MaxVisits: ${(_d = playlist.triggers) == null ? void 0 : _d.maxVisits}`);
|
|
9668
9669
|
});
|
|
9669
9670
|
this.setupElementClickListeners();
|
|
9670
9671
|
this.setupElementVisibleObservers();
|
|
@@ -9716,8 +9717,8 @@ class TriggerManager {
|
|
|
9716
9717
|
return;
|
|
9717
9718
|
}
|
|
9718
9719
|
const conditions = [];
|
|
9719
|
-
const
|
|
9720
|
-
conditions.push(
|
|
9720
|
+
const maxVisitsCondition = this.evaluateMaxVisitsCondition(triggers.maxVisits, playlistId, ((_a = store.userData) == null ? void 0 : _a.watchedPlaylists) || {});
|
|
9721
|
+
conditions.push(maxVisitsCondition);
|
|
9721
9722
|
const urlCondition = this.evaluateURLCondition(triggers);
|
|
9722
9723
|
conditions.push(urlCondition);
|
|
9723
9724
|
log(`TriggerManager: URL condition for playlist ${playlistId}: ${urlCondition} (pattern: ${triggers.url})`);
|
|
@@ -9743,17 +9744,18 @@ class TriggerManager {
|
|
|
9743
9744
|
}
|
|
9744
9745
|
}
|
|
9745
9746
|
/**
|
|
9746
|
-
* Evaluates the '
|
|
9747
|
-
* @param
|
|
9747
|
+
* Evaluates the 'maxVisits' condition for a playlist
|
|
9748
|
+
* @param maxVisits - Maximum number of times user can see this playlist (null = unlimited)
|
|
9748
9749
|
* @param playlistId - The playlist ID to check
|
|
9749
9750
|
* @param watchedPlaylists - User's watched playlists data
|
|
9750
9751
|
*/
|
|
9751
|
-
|
|
9752
|
-
if (
|
|
9752
|
+
evaluateMaxVisitsCondition(maxVisits, playlistId, watchedPlaylists) {
|
|
9753
|
+
if (maxVisits === null) {
|
|
9753
9754
|
return true;
|
|
9754
9755
|
}
|
|
9755
|
-
const
|
|
9756
|
-
|
|
9756
|
+
const playlistData = watchedPlaylists && watchedPlaylists[playlistId];
|
|
9757
|
+
const visitCount = (playlistData == null ? void 0 : playlistData.visitCount) ?? 0;
|
|
9758
|
+
return visitCount < maxVisits;
|
|
9757
9759
|
}
|
|
9758
9760
|
/**
|
|
9759
9761
|
* Normalizes a URL by removing trailing slash (unless it's the root path)
|
|
@@ -10660,14 +10662,19 @@ class PlaylistManager extends EventSubscriberManager {
|
|
|
10660
10662
|
const store = getSaltfishStore();
|
|
10661
10663
|
const currentUserData = store.userData || {};
|
|
10662
10664
|
const currentWatchedPlaylists = currentUserData.watchedPlaylists || {};
|
|
10665
|
+
const existingPlaylistData = currentWatchedPlaylists[playlistId];
|
|
10666
|
+
const previousStatus = existingPlaylistData == null ? void 0 : existingPlaylistData.status;
|
|
10667
|
+
const currentVisitCount = (existingPlaylistData == null ? void 0 : existingPlaylistData.visitCount) ?? 0;
|
|
10668
|
+
const shouldIncrementVisitCount = (status === "completed" || status === "dismissed") && previousStatus !== status;
|
|
10663
10669
|
const updatedPlaylistData = {
|
|
10664
10670
|
status,
|
|
10665
10671
|
// Don't save currentStepId for completed playlists - they should restart from beginning
|
|
10666
10672
|
currentStepId: status === "completed" ? null : currentStepId || store.currentStepId || null,
|
|
10667
10673
|
timestamp: Date.now(),
|
|
10668
10674
|
// Use timestamp for consistency with checkAndResumeInProgressPlaylist
|
|
10669
|
-
lastProgressAt: Date.now()
|
|
10675
|
+
lastProgressAt: Date.now(),
|
|
10670
10676
|
// Keep for backward compatibility
|
|
10677
|
+
visitCount: shouldIncrementVisitCount ? currentVisitCount + 1 : currentVisitCount
|
|
10671
10678
|
};
|
|
10672
10679
|
const updatedWatchedPlaylists = {
|
|
10673
10680
|
...currentWatchedPlaylists,
|
|
@@ -10726,13 +10733,18 @@ class PlaylistManager extends EventSubscriberManager {
|
|
|
10726
10733
|
if (!anonymousUserData.watchedPlaylists) {
|
|
10727
10734
|
anonymousUserData.watchedPlaylists = {};
|
|
10728
10735
|
}
|
|
10736
|
+
const existingPlaylistData = anonymousUserData.watchedPlaylists[playlistId];
|
|
10737
|
+
const previousStatus = existingPlaylistData == null ? void 0 : existingPlaylistData.status;
|
|
10738
|
+
const currentVisitCount = (existingPlaylistData == null ? void 0 : existingPlaylistData.visitCount) ?? 0;
|
|
10739
|
+
const shouldIncrementVisitCount = (status === "completed" || status === "dismissed") && previousStatus !== status;
|
|
10729
10740
|
anonymousUserData.watchedPlaylists[playlistId] = {
|
|
10730
10741
|
status,
|
|
10731
10742
|
currentStepId: currentStepId || null,
|
|
10732
10743
|
timestamp: Date.now(),
|
|
10733
10744
|
// Use timestamp for consistency with checkAndResumeInProgressPlaylist
|
|
10734
|
-
lastProgressAt: Date.now()
|
|
10745
|
+
lastProgressAt: Date.now(),
|
|
10735
10746
|
// Keep for backward compatibility
|
|
10747
|
+
visitCount: shouldIncrementVisitCount ? currentVisitCount + 1 : currentVisitCount
|
|
10736
10748
|
};
|
|
10737
10749
|
anonymousUserData.timestamp = Date.now();
|
|
10738
10750
|
this.storageManager.setAnonymousUserData(anonymousUserData);
|
|
@@ -12001,7 +12013,7 @@ const SaltfishPlayer$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
|
|
|
12001
12013
|
__proto__: null,
|
|
12002
12014
|
SaltfishPlayer
|
|
12003
12015
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
12004
|
-
const version = "0.3.
|
|
12016
|
+
const version = "0.3.46";
|
|
12005
12017
|
const packageJson = {
|
|
12006
12018
|
version
|
|
12007
12019
|
};
|