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