@hyperframes/parsers 0.9.53 → 0.9.54
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.js +44 -15
- package/package.json +2 -2
package/dist/ffBinaries.js
CHANGED
|
@@ -9,31 +9,59 @@ import {
|
|
|
9
9
|
statSync as statSync2
|
|
10
10
|
} from "fs";
|
|
11
11
|
import { createRequire } from "module";
|
|
12
|
-
import { basename, dirname as dirname2, join as join2, resolve as resolve2 } from "path";
|
|
12
|
+
import { basename as basename2, dirname as dirname2, join as join2, resolve as resolve2 } from "path";
|
|
13
13
|
|
|
14
14
|
// src/trustedExecutable.ts
|
|
15
15
|
import { accessSync, constants, existsSync, realpathSync, statSync } from "fs";
|
|
16
16
|
import { homedir } from "os";
|
|
17
|
-
import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
17
|
+
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
18
18
|
function comparable(path) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const full = resolve(path);
|
|
20
|
+
const missing = [];
|
|
21
|
+
for (let dir = full; ; dir = dirname(dir)) {
|
|
22
|
+
try {
|
|
23
|
+
const real = join(realpathSync.native(dir), ...missing.reverse());
|
|
24
|
+
return process.platform === "win32" ? real.toLowerCase() : real;
|
|
25
|
+
} catch {
|
|
26
|
+
if (dirname(dir) === dir) return process.platform === "win32" ? full.toLowerCase() : full;
|
|
27
|
+
missing.push(basename(dir));
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
|
-
return process.platform === "win32" ? full.toLowerCase() : full;
|
|
26
30
|
}
|
|
27
31
|
function contains(parent, child) {
|
|
28
32
|
const rel = relative(parent, child);
|
|
29
33
|
return rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
var PROJECT_MARKERS = [".git", "package.json", "node_modules", "hyperframes.json"];
|
|
36
|
+
function projectRoot(cwd, home) {
|
|
37
|
+
let root = cwd;
|
|
38
|
+
for (let dir = cwd; dirname(dir) !== dir && !contains(dir, home); dir = dirname(dir)) {
|
|
39
|
+
if (PROJECT_MARKERS.some((marker) => existsSync(join(dir, marker)))) root = dir;
|
|
40
|
+
}
|
|
41
|
+
return root;
|
|
42
|
+
}
|
|
43
|
+
function ancestorNodeModules(cwd) {
|
|
44
|
+
const folders = [];
|
|
45
|
+
for (let dir = dirname(cwd); ; dir = dirname(dir)) {
|
|
46
|
+
folders.push(comparable(join(dir, "node_modules")));
|
|
47
|
+
if (dirname(dir) === dir) return folders;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function trustRule() {
|
|
34
51
|
const cwd = comparable(process.cwd());
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
const home = comparable(homedir());
|
|
53
|
+
const fromHome = contains(cwd, home);
|
|
54
|
+
const project = fromHome ? cwd : projectRoot(cwd, home);
|
|
55
|
+
const nodeModules = ancestorNodeModules(cwd);
|
|
56
|
+
return (dir) => {
|
|
57
|
+
if (!dir || !isAbsolute(dir)) return false;
|
|
58
|
+
const target = comparable(dir);
|
|
59
|
+
if (target === cwd || nodeModules.some((folder) => contains(folder, target))) return false;
|
|
60
|
+
return fromHome || !contains(project, target);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function isTrustedDirectory(dir) {
|
|
64
|
+
return trustRule()(dir);
|
|
37
65
|
}
|
|
38
66
|
function isTrustedExecutablePath(file) {
|
|
39
67
|
return isAbsolute(file) && isTrustedDirectory(dirname(file));
|
|
@@ -44,7 +72,8 @@ function expandHome(dir) {
|
|
|
44
72
|
}
|
|
45
73
|
function trustedPathDirs(pathValue = process.env.PATH ?? "") {
|
|
46
74
|
const entries = pathValue.split(delimiter).map(expandHome);
|
|
47
|
-
|
|
75
|
+
const trusted = trustRule();
|
|
76
|
+
return [...new Set(entries.filter((dir) => trusted(dir)))];
|
|
48
77
|
}
|
|
49
78
|
function windowsExtensions() {
|
|
50
79
|
const listed = (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((ext) => ext.trim().toLowerCase()).filter(Boolean);
|
|
@@ -108,7 +137,7 @@ function runsOnThisMac(candidate) {
|
|
|
108
137
|
return true;
|
|
109
138
|
}
|
|
110
139
|
if (!isX86OnlyMachO(candidate)) return true;
|
|
111
|
-
const name =
|
|
140
|
+
const name = basename2(candidate);
|
|
112
141
|
if (!skippedX86Binaries.has(name)) skippedX86Binaries.set(name, candidate);
|
|
113
142
|
return false;
|
|
114
143
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/parsers",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.54",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"tsx": "^4.21.0",
|
|
144
144
|
"typescript": "^5.0.0",
|
|
145
145
|
"vitest": "^4.1.12",
|
|
146
|
-
"@hyperframes/core": "0.9.
|
|
146
|
+
"@hyperframes/core": "0.9.54"
|
|
147
147
|
},
|
|
148
148
|
"scripts": {
|
|
149
149
|
"build": "tsup",
|