@torrent-tv/proxy 2.101.31 → 2.101.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.101.31",
3
+ "version": "2.101.33",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -132,7 +132,9 @@ export class ViewerRequests {
132
132
  const changed = this.#recordEarlyWaitSnapshot(context, context.features);
133
133
  if (changed) context.revision += 1;
134
134
  this.#pruneEarlyWaits();
135
- const totalSeconds = this.#host.firstFrameSecondsOf?.(context.features) ?? null;
135
+ const totalSeconds = Number.isFinite(context.activeTotalSeconds)
136
+ ? context.activeTotalSeconds
137
+ : this.#host.firstFrameSecondsOf?.(context.features) ?? null;
136
138
  const seconds = earlyWaitRemainingSeconds(totalSeconds, waitElapsedSince(context, waitElapsedMs));
137
139
  if (!Number.isFinite(seconds) || seconds < 0) return null;
138
140
  return { version: 1, waitId, revision: context.revision, remainingSeconds: seconds, ageMs: 0 };
@@ -144,7 +146,9 @@ export class ViewerRequests {
144
146
  const changed = this.#recordEarlyWaitSnapshot(context, context.features);
145
147
  if (sameWait && changed) context.revision += 1;
146
148
  this.#pruneEarlyWaits();
147
- const totalSeconds = this.#host.firstFrameSecondsOf?.(context.features) ?? null;
149
+ const totalSeconds = Number.isFinite(context.activeTotalSeconds)
150
+ ? context.activeTotalSeconds
151
+ : this.#host.firstFrameSecondsOf?.(context.features) ?? null;
148
152
  const seconds = earlyWaitRemainingSeconds(totalSeconds, waitElapsedSince(context, waitElapsedMs));
149
153
  if (!Number.isFinite(seconds) || seconds < 0) return null;
150
154
  return { version: 1, waitId, revision: context.revision, remainingSeconds: seconds, ageMs: 0 };
@@ -187,14 +191,24 @@ export class ViewerRequests {
187
191
  const revision = sameWait ? current.revision : 0;
188
192
  const context = this.#setEarlyWait({ consumerId, generation, fileIndex, waitId, features, revision, current,
189
193
  sourceObserved: true, waitElapsedMs });
190
- const changed = this.#recordEarlyWaitSnapshot(context, context.features);
194
+ const featuresChanged = this.#recordEarlyWaitSnapshot(context, context.features);
195
+ const elapsedMs = waitElapsedSince(context, waitElapsedMs);
196
+ const measuredWorkSeconds = processing.firstRequiredSegmentsSeconds;
197
+ const hasActiveEstimate = Number.isFinite(measuredWorkSeconds) && measuredWorkSeconds >= 0;
198
+ const activeTotalSeconds = hasActiveEstimate
199
+ ? elapsedMs / 1000 + measuredWorkSeconds
200
+ : context.activeTotalSeconds;
201
+ const activeEstimateChanged = hasActiveEstimate && activeTotalSeconds !== context.activeTotalSeconds;
202
+ if (hasActiveEstimate) context.activeTotalSeconds = activeTotalSeconds;
203
+ const changed = featuresChanged || activeEstimateChanged;
191
204
  if (sameWait && changed) context.revision += 1;
192
205
  this.#pruneEarlyWaits();
193
- const measuredWorkSeconds = processing.firstRequiredSegmentsSeconds;
194
- const totalSeconds = Number.isFinite(measuredWorkSeconds) && measuredWorkSeconds >= 0
195
- ? waitElapsedSince(context, waitElapsedMs) / 1000 + measuredWorkSeconds
196
- : this.#host.firstFrameSecondsOf?.(context.features) ?? null;
197
- const seconds = earlyWaitRemainingSeconds(totalSeconds, waitElapsedSince(context, waitElapsedMs));
206
+ const progressHasComponentForecast = Object.hasOwn(processing, "firstRequiredSegmentsSeconds");
207
+ let totalSeconds = activeTotalSeconds;
208
+ if (!Number.isFinite(totalSeconds) && !progressHasComponentForecast) {
209
+ totalSeconds = this.#host.firstFrameSecondsOf?.(context.features) ?? null;
210
+ }
211
+ const seconds = earlyWaitRemainingSeconds(totalSeconds, elapsedMs);
198
212
  if (!Number.isFinite(seconds) || seconds < 0) return null;
199
213
  return { version: 1, waitId, revision: context.revision, remainingSeconds: seconds, ageMs: 0 };
200
214
  }