@hyperframes/parsers 0.8.217 → 0.8.219
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/ffBinaries.d.ts +4 -1
- package/dist/ffBinaries.js +35 -4
- package/package.json +2 -2
package/dist/ffBinaries.d.ts
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
declare const FFMPEG_PATH_ENV = "HYPERFRAMES_FFMPEG_PATH";
|
|
7
7
|
declare const FFPROBE_PATH_ENV = "HYPERFRAMES_FFPROBE_PATH";
|
|
8
8
|
type FfBinaryName = "ffmpeg" | "ffprobe";
|
|
9
|
+
declare function isX86OnlyMachO(file: string): boolean;
|
|
10
|
+
/** The first x86_64-only binary skipped on this Mac, for naming in the "not found" hint. */
|
|
11
|
+
declare function getSkippedX86Binary(): string | undefined;
|
|
9
12
|
interface FindFfBinaryOptions {
|
|
10
13
|
/**
|
|
11
14
|
* How to treat an env override that points at a missing file: `true`
|
|
@@ -29,4 +32,4 @@ declare function findFfBinary(name: FfBinaryName, options?: FindFfBinaryOptions)
|
|
|
29
32
|
/** Test hook: drop cached system lookups so resolution can be re-exercised. */
|
|
30
33
|
declare function clearFfBinaryLookupCache(): void;
|
|
31
34
|
|
|
32
|
-
export { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, type FfBinaryName, type FindFfBinaryOptions, clearFfBinaryLookupCache, findFfBinary };
|
|
35
|
+
export { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, type FfBinaryName, type FindFfBinaryOptions, clearFfBinaryLookupCache, findFfBinary, getSkippedX86Binary, isX86OnlyMachO };
|
package/dist/ffBinaries.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/ffBinaries.ts
|
|
2
2
|
import { execFileSync } from "child_process";
|
|
3
|
-
import { accessSync, constants, existsSync } from "fs";
|
|
3
|
+
import { accessSync, closeSync, constants, existsSync, openSync, readSync } from "fs";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
5
|
import { delimiter, dirname, join, resolve } from "path";
|
|
6
6
|
var FFMPEG_PATH_ENV = "HYPERFRAMES_FFMPEG_PATH";
|
|
@@ -19,11 +19,39 @@ function chooseBestPathCandidate(name, candidates) {
|
|
|
19
19
|
const normalized = candidates.map((candidate) => candidate.trim()).filter(Boolean);
|
|
20
20
|
return normalized.find((candidate) => candidateFileName(candidate) === `${name}.exe`) ?? normalized.find((candidate) => candidateFileName(candidate) === name) ?? normalized.find((candidate) => !candidateFileName(candidate).match(/\.(cmd|bat)$/i)) ?? normalized[0];
|
|
21
21
|
}
|
|
22
|
+
var MACHO_CPU_X86_64 = 16777223;
|
|
23
|
+
var ROSETTA_RUNTIME = "/Library/Apple/usr/libexec/oah/libRosettaRuntime";
|
|
24
|
+
function isX86OnlyMachO(file) {
|
|
25
|
+
const header = Buffer.alloc(8);
|
|
26
|
+
try {
|
|
27
|
+
const fd = openSync(file, "r");
|
|
28
|
+
try {
|
|
29
|
+
readSync(fd, header, 0, 8, 0);
|
|
30
|
+
} finally {
|
|
31
|
+
closeSync(fd);
|
|
32
|
+
}
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return header.readUInt32LE(0) === 4277009103 && header.readUInt32LE(4) === MACHO_CPU_X86_64;
|
|
37
|
+
}
|
|
38
|
+
function runsOnThisMac(candidate) {
|
|
39
|
+
if (process.platform !== "darwin" || process.arch !== "arm64" || existsSync(ROSETTA_RUNTIME)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (!isX86OnlyMachO(candidate)) return true;
|
|
43
|
+
skippedX86Binary ??= candidate;
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
var skippedX86Binary;
|
|
47
|
+
function getSkippedX86Binary() {
|
|
48
|
+
return skippedX86Binary;
|
|
49
|
+
}
|
|
22
50
|
function isExecutablePathCandidate(candidate) {
|
|
23
51
|
if (process.platform === "win32") return existsSync(candidate);
|
|
24
52
|
try {
|
|
25
53
|
accessSync(candidate, constants.X_OK);
|
|
26
|
-
return
|
|
54
|
+
return runsOnThisMac(candidate);
|
|
27
55
|
} catch {
|
|
28
56
|
return false;
|
|
29
57
|
}
|
|
@@ -55,7 +83,7 @@ var COMMON_BIN_DIRS = process.platform === "win32" ? [] : ["/opt/homebrew/bin",
|
|
|
55
83
|
function findInCommonDirsOrInstallerPackage(name) {
|
|
56
84
|
for (const dir of COMMON_BIN_DIRS) {
|
|
57
85
|
const candidate = `${dir}/${name}`;
|
|
58
|
-
if (existsSync(candidate)) return candidate;
|
|
86
|
+
if (existsSync(candidate) && runsOnThisMac(candidate)) return candidate;
|
|
59
87
|
}
|
|
60
88
|
return findInInstallerPackage(name);
|
|
61
89
|
}
|
|
@@ -126,10 +154,13 @@ function findFfBinary(name, options = {}) {
|
|
|
126
154
|
function clearFfBinaryLookupCache() {
|
|
127
155
|
pathLookupCache.clear();
|
|
128
156
|
lastMissAt.clear();
|
|
157
|
+
skippedX86Binary = void 0;
|
|
129
158
|
}
|
|
130
159
|
export {
|
|
131
160
|
FFMPEG_PATH_ENV,
|
|
132
161
|
FFPROBE_PATH_ENV,
|
|
133
162
|
clearFfBinaryLookupCache,
|
|
134
|
-
findFfBinary
|
|
163
|
+
findFfBinary,
|
|
164
|
+
getSkippedX86Binary,
|
|
165
|
+
isX86OnlyMachO
|
|
135
166
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/parsers",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.219",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"tsx": "^4.21.0",
|
|
140
140
|
"typescript": "^5.0.0",
|
|
141
141
|
"vitest": "^4.1.11",
|
|
142
|
-
"@hyperframes/core": "0.8.
|
|
142
|
+
"@hyperframes/core": "0.8.219"
|
|
143
143
|
},
|
|
144
144
|
"scripts": {
|
|
145
145
|
"build": "tsup",
|