asciify-engine 1.0.68 → 1.0.69

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
@@ -1188,7 +1188,7 @@ function sizeCanvasToContainer(canvas, container, aspect, srcW, srcH) {
1188
1188
  canvas.style.width = cssW + "px";
1189
1189
  canvas.style.height = cssH + "px";
1190
1190
  }
1191
- async function asciify(source, canvas, { fontSize = 10, artStyle = "classic", options = {} } = {}) {
1191
+ async function asciify(source, canvas, { fontSize, artStyle = "classic", options = {} } = {}) {
1192
1192
  let el;
1193
1193
  if (typeof source === "string") {
1194
1194
  const img = new Image();
@@ -1209,15 +1209,17 @@ async function asciify(source, canvas, { fontSize = 10, artStyle = "classic", op
1209
1209
  el = source;
1210
1210
  }
1211
1211
  const preset = ART_STYLE_PRESETS[artStyle];
1212
- const merged = { ...DEFAULT_OPTIONS, ...preset, ...options, fontSize };
1212
+ const resolvedFontSize = fontSize ?? options.fontSize ?? 10;
1213
+ const merged = { ...DEFAULT_OPTIONS, ...preset, ...options, fontSize: resolvedFontSize };
1213
1214
  const ctx = canvas.getContext("2d");
1214
1215
  if (!ctx) throw new Error("Could not get 2d context from canvas");
1215
1216
  const { frame } = imageToAsciiFrame(el, merged, canvas.width, canvas.height);
1216
1217
  renderFrameToCanvas(ctx, frame, merged, canvas.width, canvas.height);
1217
1218
  }
1218
- async function asciifyGif(source, canvas, { fontSize = 10, artStyle = "classic", options = {} } = {}) {
1219
+ async function asciifyGif(source, canvas, { fontSize, artStyle = "classic", options = {} } = {}) {
1219
1220
  const buffer = typeof source === "string" ? await fetch(source).then((r) => r.arrayBuffer()) : source;
1220
- const merged = { ...DEFAULT_OPTIONS, ...ART_STYLE_PRESETS[artStyle], ...options, fontSize };
1221
+ const resolvedFontSize = fontSize ?? options.fontSize ?? 10;
1222
+ const merged = { ...DEFAULT_OPTIONS, ...ART_STYLE_PRESETS[artStyle], ...options, fontSize: resolvedFontSize };
1221
1223
  const ctx = canvas.getContext("2d");
1222
1224
  if (!ctx) throw new Error("Could not get 2d context from canvas");
1223
1225
  const { frames, fps } = await gifToAsciiFrames(buffer, merged, canvas.width, canvas.height);
@@ -1241,10 +1243,11 @@ async function asciifyGif(source, canvas, { fontSize = 10, artStyle = "classic",
1241
1243
  cancelAnimationFrame(animId);
1242
1244
  };
1243
1245
  }
1244
- async function asciifyVideo(source, canvas, { fontSize = 10, artStyle = "classic", options = {}, fitTo, preExtract = false, trim, onReady, onFrame } = {}) {
1246
+ async function asciifyVideo(source, canvas, { fontSize, artStyle = "classic", options = {}, fitTo, preExtract = false, trim, onReady, onFrame } = {}) {
1245
1247
  const trimStart = trim?.start ?? 0;
1246
1248
  const trimEnd = trim?.end;
1247
- const merged = { ...DEFAULT_OPTIONS, ...ART_STYLE_PRESETS[artStyle], ...options, fontSize };
1249
+ const resolvedFontSize = fontSize ?? options.fontSize ?? 10;
1250
+ const merged = { ...DEFAULT_OPTIONS, ...ART_STYLE_PRESETS[artStyle], ...options, fontSize: resolvedFontSize };
1248
1251
  const ctx = canvas.getContext("2d");
1249
1252
  if (!ctx) throw new Error("asciifyVideo: could not get 2d context from canvas.");
1250
1253
  const container = typeof fitTo === "string" ? document.querySelector(fitTo) : fitTo instanceof HTMLElement ? fitTo : null;