@thestatic-tv/dcl-sdk 2.5.2 → 2.5.4

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/index.d.mts CHANGED
@@ -999,6 +999,7 @@ declare class StaticTVClient {
999
999
  private _streamVerified;
1000
1000
  private _verificationTimeoutId;
1001
1001
  private _videoEventsRegistered;
1002
+ private _verificationStartTime;
1002
1003
  /**
1003
1004
  * Play a video on the configured videoScreen entity.
1004
1005
  * Called by Guide UI and Admin Panel.
package/dist/index.d.ts CHANGED
@@ -999,6 +999,7 @@ declare class StaticTVClient {
999
999
  private _streamVerified;
1000
1000
  private _verificationTimeoutId;
1001
1001
  private _videoEventsRegistered;
1002
+ private _verificationStartTime;
1002
1003
  /**
1003
1004
  * Play a video on the configured videoScreen entity.
1004
1005
  * Called by Guide UI and Admin Panel.
package/dist/index.js CHANGED
@@ -3493,6 +3493,7 @@ function setupStaticUI(client) {
3493
3493
 
3494
3494
  // src/StaticTVClient.ts
3495
3495
  var import_ecs3 = require("@dcl/sdk/ecs");
3496
+ var utils = __toESM(require("@dcl-sdk/utils"));
3496
3497
  var DEFAULT_BASE_URL = "https://thestatic.tv/api/v1/dcl";
3497
3498
  var DEFAULT_FALLBACK_VIDEO = "https://media.thestatic.tv/fallback-loop.mp4";
3498
3499
  var KEY_TYPE_CHANNEL = "channel";
@@ -3560,7 +3561,9 @@ var StaticTVClient = class {
3560
3561
  this._pendingVideoData = null;
3561
3562
  this._streamVerified = false;
3562
3563
  this._verificationTimeoutId = null;
3564
+ // DCL timer ID
3563
3565
  this._videoEventsRegistered = false;
3566
+ this._verificationStartTime = 0;
3564
3567
  this._featuresReadyPromise = new Promise((resolve) => {
3565
3568
  this._featuresReadyResolve = resolve;
3566
3569
  });
@@ -3725,6 +3728,7 @@ var StaticTVClient = class {
3725
3728
  getConfig() {
3726
3729
  return this.config;
3727
3730
  }
3731
+ // Timestamp when verification started
3728
3732
  /**
3729
3733
  * Play a video on the configured videoScreen entity.
3730
3734
  * Called by Guide UI and Admin Panel.
@@ -3817,11 +3821,13 @@ var StaticTVClient = class {
3817
3821
  if (screen === void 0) return;
3818
3822
  this._videoEventsRegistered = true;
3819
3823
  import_ecs3.videoEventsSystem.registerVideoEventsEntity(screen, (videoEvent) => {
3820
- if (videoEvent.state === import_ecs3.VideoState.VS_READY || videoEvent.state === import_ecs3.VideoState.VS_PLAYING) {
3821
- if (this._pendingVideoData && !this._streamVerified) {
3824
+ if (videoEvent.state === import_ecs3.VideoState.VS_PLAYING) {
3825
+ const timeSinceStart = Date.now() - this._verificationStartTime;
3826
+ const MIN_VERIFICATION_DELAY = 2e3;
3827
+ if (this._pendingVideoData && !this._streamVerified && timeSinceStart >= MIN_VERIFICATION_DELAY) {
3822
3828
  this._streamVerified = true;
3823
3829
  this._clearVerificationTimeout();
3824
- this.log(`Stream verified: ${this._pendingVideoData.name}`);
3830
+ this.log(`Stream verified: ${this._pendingVideoData.name} (after ${timeSinceStart}ms)`);
3825
3831
  }
3826
3832
  }
3827
3833
  if (videoEvent.state === import_ecs3.VideoState.VS_ERROR) {
@@ -3837,10 +3843,11 @@ var StaticTVClient = class {
3837
3843
  * @internal
3838
3844
  */
3839
3845
  _startStreamVerification() {
3846
+ this._verificationStartTime = Date.now();
3840
3847
  if (this._pendingVideoData) {
3841
3848
  this.showNotification(`Connecting to ${this._pendingVideoData.name}...`, 1e4);
3842
3849
  }
3843
- this._verificationTimeoutId = setTimeout(() => {
3850
+ this._verificationTimeoutId = utils.timers.setTimeout(() => {
3844
3851
  if (!this._streamVerified && this._pendingVideoData) {
3845
3852
  this.log(`Stream verification timeout for: ${this._pendingVideoData.name}`);
3846
3853
  this._handleStreamOffline();
@@ -3866,7 +3873,7 @@ var StaticTVClient = class {
3866
3873
  */
3867
3874
  _clearVerificationTimeout() {
3868
3875
  if (this._verificationTimeoutId) {
3869
- clearTimeout(this._verificationTimeoutId);
3876
+ utils.timers.clearTimeout(this._verificationTimeoutId);
3870
3877
  this._verificationTimeoutId = null;
3871
3878
  }
3872
3879
  }
package/dist/index.mjs CHANGED
@@ -3450,6 +3450,7 @@ function setupStaticUI(client) {
3450
3450
 
3451
3451
  // src/StaticTVClient.ts
3452
3452
  import { VideoPlayer, Material, videoEventsSystem, VideoState } from "@dcl/sdk/ecs";
3453
+ import * as utils from "@dcl-sdk/utils";
3453
3454
  var DEFAULT_BASE_URL = "https://thestatic.tv/api/v1/dcl";
3454
3455
  var DEFAULT_FALLBACK_VIDEO = "https://media.thestatic.tv/fallback-loop.mp4";
3455
3456
  var KEY_TYPE_CHANNEL = "channel";
@@ -3517,7 +3518,9 @@ var StaticTVClient = class {
3517
3518
  this._pendingVideoData = null;
3518
3519
  this._streamVerified = false;
3519
3520
  this._verificationTimeoutId = null;
3521
+ // DCL timer ID
3520
3522
  this._videoEventsRegistered = false;
3523
+ this._verificationStartTime = 0;
3521
3524
  this._featuresReadyPromise = new Promise((resolve) => {
3522
3525
  this._featuresReadyResolve = resolve;
3523
3526
  });
@@ -3682,6 +3685,7 @@ var StaticTVClient = class {
3682
3685
  getConfig() {
3683
3686
  return this.config;
3684
3687
  }
3688
+ // Timestamp when verification started
3685
3689
  /**
3686
3690
  * Play a video on the configured videoScreen entity.
3687
3691
  * Called by Guide UI and Admin Panel.
@@ -3774,11 +3778,13 @@ var StaticTVClient = class {
3774
3778
  if (screen === void 0) return;
3775
3779
  this._videoEventsRegistered = true;
3776
3780
  videoEventsSystem.registerVideoEventsEntity(screen, (videoEvent) => {
3777
- if (videoEvent.state === VideoState.VS_READY || videoEvent.state === VideoState.VS_PLAYING) {
3778
- if (this._pendingVideoData && !this._streamVerified) {
3781
+ if (videoEvent.state === VideoState.VS_PLAYING) {
3782
+ const timeSinceStart = Date.now() - this._verificationStartTime;
3783
+ const MIN_VERIFICATION_DELAY = 2e3;
3784
+ if (this._pendingVideoData && !this._streamVerified && timeSinceStart >= MIN_VERIFICATION_DELAY) {
3779
3785
  this._streamVerified = true;
3780
3786
  this._clearVerificationTimeout();
3781
- this.log(`Stream verified: ${this._pendingVideoData.name}`);
3787
+ this.log(`Stream verified: ${this._pendingVideoData.name} (after ${timeSinceStart}ms)`);
3782
3788
  }
3783
3789
  }
3784
3790
  if (videoEvent.state === VideoState.VS_ERROR) {
@@ -3794,10 +3800,11 @@ var StaticTVClient = class {
3794
3800
  * @internal
3795
3801
  */
3796
3802
  _startStreamVerification() {
3803
+ this._verificationStartTime = Date.now();
3797
3804
  if (this._pendingVideoData) {
3798
3805
  this.showNotification(`Connecting to ${this._pendingVideoData.name}...`, 1e4);
3799
3806
  }
3800
- this._verificationTimeoutId = setTimeout(() => {
3807
+ this._verificationTimeoutId = utils.timers.setTimeout(() => {
3801
3808
  if (!this._streamVerified && this._pendingVideoData) {
3802
3809
  this.log(`Stream verification timeout for: ${this._pendingVideoData.name}`);
3803
3810
  this._handleStreamOffline();
@@ -3823,7 +3830,7 @@ var StaticTVClient = class {
3823
3830
  */
3824
3831
  _clearVerificationTimeout() {
3825
3832
  if (this._verificationTimeoutId) {
3826
- clearTimeout(this._verificationTimeoutId);
3833
+ utils.timers.clearTimeout(this._verificationTimeoutId);
3827
3834
  this._verificationTimeoutId = null;
3828
3835
  }
3829
3836
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thestatic-tv/dcl-sdk",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "description": "Connect your Decentraland scene to thestatic.tv - full channel lineup, metrics tracking, and interactions",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -46,9 +46,11 @@
46
46
  "url": "https://github.com/thestatic-tv/dcl-sdk/issues"
47
47
  },
48
48
  "peerDependencies": {
49
+ "@dcl-sdk/utils": ">=1.0.0",
49
50
  "@dcl/sdk": ">=7.0.0"
50
51
  },
51
52
  "devDependencies": {
53
+ "@dcl-sdk/utils": "^1.4.0",
52
54
  "@dcl/sdk": "^7.0.0",
53
55
  "@vitest/coverage-v8": "^4.0.16",
54
56
  "tsup": "^8.0.0",