@tradalab/mediakit 2.9.0 → 2.9.1

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.ts CHANGED
@@ -424,6 +424,7 @@ declare class VideoPipeline {
424
424
  private watchdog;
425
425
  private movedOff;
426
426
  private raised;
427
+ private effectOff;
427
428
  private slowTicks;
428
429
  private gpuRecoveries;
429
430
  private gpu;
package/dist/index.js CHANGED
@@ -112,6 +112,7 @@ async function preloadDetectors(parts = { person: true, classes: true, face: tru
112
112
  tell(true);
113
113
  await Promise.all(
114
114
  urls.map(async (u, i) => {
115
+ let got = 0;
115
116
  try {
116
117
  const r = await fetch(u, { priority: "low" });
117
118
  if (!r.ok) {
@@ -126,13 +127,15 @@ async function preloadDetectors(parts = { person: true, classes: true, face: tru
126
127
  for (; ; ) {
127
128
  const { done, value } = await reader.read();
128
129
  if (done) break;
130
+ got += value.byteLength;
129
131
  p.loaded += value.byteLength;
130
132
  tell(false);
131
133
  }
132
134
  }
133
135
  }
134
136
  } catch {
135
- sizes[i] ??= 0;
137
+ p.loaded -= got;
138
+ sizes[i] = 0;
136
139
  }
137
140
  p.done++;
138
141
  tell(true);
@@ -774,7 +777,7 @@ var Engine = class _Engine {
774
777
  // steers on past numbers because there is no way to know in advance what a frame will cost.
775
778
  prevTotalMs = 0;
776
779
  prevSegMs = 0;
777
- last = { ...ZERO_STATS };
780
+ last = { ...ZERO_STATS, parts: { ...NO_PARTS }, partErrors: { ...NO_PART_ERRORS } };
778
781
  constructor(canvas, gl, core) {
779
782
  this.canvas = canvas;
780
783
  this.gl = gl;
@@ -992,7 +995,7 @@ var Engine = class _Engine {
992
995
  });
993
996
  }).catch((e) => {
994
997
  this.failed.add("face");
995
- this.partFailed("face", "face detection", "face effects", e);
998
+ this.partFailed("face", "face detection", "face effects stay off", e);
996
999
  this.gaveUp("face effects", e);
997
1000
  if (!(e instanceof LoadTimeout)) console.error("mediakit: face detector failed to load", e);
998
1001
  }).finally(() => {
@@ -1011,7 +1014,7 @@ var Engine = class _Engine {
1011
1014
  }).catch((e) => {
1012
1015
  if (!(e instanceof LoadTimeout)) return;
1013
1016
  this.failed.add("person");
1014
- this.partFailed("person", "person segmentation", "background effects", e);
1017
+ this.partFailed("person", "person segmentation", "background effects stay off", e);
1015
1018
  this.gaveUp("background effects", e);
1016
1019
  }).finally(() => {
1017
1020
  this.personLoading = null;
@@ -1072,7 +1075,7 @@ var Engine = class _Engine {
1072
1075
  cover: (ok, message) => {
1073
1076
  if (key !== "face" || this.coverState === "failed") return;
1074
1077
  this.coverState = ok ? "ready" : "failed";
1075
- if (!ok) this.partErr.set("cover", `mediakit: ${message}; occluders stays off`);
1078
+ if (!ok) this.partErr.set("cover", `${message}; occluders stays off`);
1076
1079
  },
1077
1080
  failed: (k, reason) => {
1078
1081
  if (key === "faceExtra") {
@@ -1376,7 +1379,7 @@ var Engine = class _Engine {
1376
1379
  this.segmenter = s;
1377
1380
  }).catch((e) => {
1378
1381
  this.failed.add("segmenter");
1379
- this.partFailed("person", "person segmentation", "background and skin effects", e);
1382
+ this.partFailed("person", "person segmentation", "background and skin effects stay off", e);
1380
1383
  this.gaveUp("background and skin effects", e);
1381
1384
  if (!(e instanceof LoadTimeout)) console.error("mediakit: segmenter failed to load", e);
1382
1385
  }).finally(() => {
@@ -1740,10 +1743,10 @@ var Engine = class _Engine {
1740
1743
  };
1741
1744
  return glCalls > 0;
1742
1745
  }
1743
- partFailed(part, what, off, e) {
1746
+ partFailed(part, what, then, e) {
1744
1747
  if (this.partErr.has(part)) return;
1745
1748
  const why = e instanceof LoadTimeout ? e.message : `mediakit: ${what} did not load: ${String(e?.message ?? e)}`;
1746
- this.partErr.set(part, `${why}; ${off} stay off`);
1749
+ this.partErr.set(part, `${why}; ${then}`);
1747
1750
  }
1748
1751
  parts() {
1749
1752
  const f = this.filter;
@@ -1928,6 +1931,7 @@ var VideoPipeline = class {
1928
1931
  watchdog = null;
1929
1932
  movedOff = false;
1930
1933
  raised = /* @__PURE__ */ new Set();
1934
+ effectOff = "";
1931
1935
  slowTicks = 0;
1932
1936
  gpuRecoveries = 0;
1933
1937
  gpu = "";
@@ -1995,7 +1999,7 @@ var VideoPipeline = class {
1995
1999
  });
1996
2000
  }
1997
2001
  issue(code, message, key = code) {
1998
- if (this.raised.has(key)) return;
2002
+ if (this.raised.has(key)) return false;
1999
2003
  this.raised.add(key);
2000
2004
  console.warn(`mediakit: ${code}: ${message}`);
2001
2005
  try {
@@ -2003,15 +2007,16 @@ var VideoPipeline = class {
2003
2007
  } catch (e) {
2004
2008
  console.error("mediakit: onIssue threw", e);
2005
2009
  }
2010
+ return true;
2006
2011
  }
2007
2012
  watchQuality() {
2008
2013
  const s = this.stats;
2009
2014
  if (!s) return;
2010
- if (s.effectError) this.issue("effect-off", s.effectError);
2015
+ if (s.effectError && this.issue("effect-off", s.effectError)) this.effectOff = s.effectError;
2011
2016
  for (const part of Object.keys(s.parts ?? {})) {
2012
2017
  if (s.parts[part] !== "failed") continue;
2013
2018
  const why = s.partErrors?.[part] || `mediakit: ${part} failed to load; its effects stay off`;
2014
- if (s.effectError && s.effectError.includes(why)) continue;
2019
+ if (this.effectOff.includes(why)) continue;
2015
2020
  this.issue("part-off", why, `part-off:${why}`);
2016
2021
  }
2017
2022
  const slow = s.totalMs > SLOW_FRAME_MS || s.faceMs > SLOW_FRAME_MS;