m4k 0.2.0 → 0.2.2

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.
@@ -20,7 +20,12 @@ export function processFfmpeg(input, buildArgs, { signal, queue, tmpDir, }) {
20
20
  const { input: inArgs, out: outArgs, format } = buildArgs();
21
21
  const outputPath = `${tmpDir}/out-${id}.${getExtension(format)}`;
22
22
  try {
23
- const child = spawn(ffmpeg, ["-y", ...inArgs, "-i", await inputPath, ...outArgs, outputPath], { stdio: ["pipe", "pipe", "pipe"], signal });
23
+ signal?.throwIfAborted();
24
+ const p = await inputPath;
25
+ signal?.throwIfAborted();
26
+ const child = spawn(ffmpeg, ["-y", ...inArgs, "-i", p, ...outArgs, outputPath], { stdio: ["pipe", "pipe", "pipe"] });
27
+ // Use manual abort handling to avoid some uncatchable error, at least in bun.
28
+ signal?.addEventListener("abort", () => child.kill());
24
29
  const decoder = new TextDecoder();
25
30
  let metadataStr = "";
26
31
  let duration = null;
@@ -60,13 +65,17 @@ export function processFfmpeg(input, buildArgs, { signal, queue, tmpDir, }) {
60
65
  }
61
66
  yield new ProcessedFile(outputPath, mimeTypes[format]);
62
67
  }
68
+ catch (e) {
69
+ signal?.throwIfAborted();
70
+ throw e;
71
+ }
63
72
  finally {
64
73
  await rm(outputPath, { force: true });
65
74
  if (typeof inputPath !== "string") {
66
75
  await rm(await inputPath, { force: true });
67
76
  }
68
77
  }
69
- }, signal);
78
+ });
70
79
  if (!iterable)
71
80
  return null;
72
81
  return (async function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m4k",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "typescript": "^5.0.0"
19
19
  },
20
20
  "dependencies": {
21
- "@m4k/common": "^0.1.0"
21
+ "@m4k/common": "^0.2.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "sharp": "^0.33.5"