asciify-engine 1.0.48 → 1.0.49

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.js CHANGED
@@ -1111,6 +1111,7 @@ async function asciifyVideo(source, canvas, { fontSize = 10, artStyle = "classic
1111
1111
  onReady?.(video2);
1112
1112
  const { frames, fps } = await videoToAsciiFrames(video2, merged, canvas.width, canvas.height);
1113
1113
  let cancelled2 = false, animId2, i = 0, last = performance.now();
1114
+ let firstFrame2 = true;
1114
1115
  const interval = 1e3 / fps;
1115
1116
  const tick2 = (now) => {
1116
1117
  if (cancelled2) return;
@@ -1118,6 +1119,10 @@ async function asciifyVideo(source, canvas, { fontSize = 10, artStyle = "classic
1118
1119
  renderFrameToCanvas(ctx, frames[i], merged, canvas.width, canvas.height);
1119
1120
  i = (i + 1) % frames.length;
1120
1121
  last = now;
1122
+ if (firstFrame2) {
1123
+ firstFrame2 = false;
1124
+ onReady?.(video2);
1125
+ }
1121
1126
  onFrame?.();
1122
1127
  }
1123
1128
  animId2 = requestAnimationFrame(tick2);
@@ -1167,9 +1172,9 @@ async function asciifyVideo(source, canvas, { fontSize = 10, artStyle = "classic
1167
1172
  ro = new ResizeObserver(() => sizeCanvasToContainer(canvas, container, aspect));
1168
1173
  ro.observe(container);
1169
1174
  }
1170
- onReady?.(video);
1171
1175
  let cancelled = false;
1172
1176
  let animId;
1177
+ let firstFrame = true;
1173
1178
  const tick = () => {
1174
1179
  if (cancelled) return;
1175
1180
  animId = requestAnimationFrame(tick);
@@ -1177,6 +1182,10 @@ async function asciifyVideo(source, canvas, { fontSize = 10, artStyle = "classic
1177
1182
  const { frame } = imageToAsciiFrame(video, merged, canvas.width, canvas.height);
1178
1183
  if (frame.length > 0) {
1179
1184
  renderFrameToCanvas(ctx, frame, merged, canvas.width, canvas.height, 0, null);
1185
+ if (firstFrame) {
1186
+ firstFrame = false;
1187
+ onReady?.(video);
1188
+ }
1180
1189
  onFrame?.();
1181
1190
  }
1182
1191
  };