@blazediff/bin 2.1.0 → 3.0.0
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.js +87 -5
- package/dist/index.mjs +82 -13
- package/package.json +11 -13
- package/bin/blazediff.exe +0 -0
- package/binaries/blazediff-linux-arm64 +0 -0
- package/binaries/blazediff-linux-x64 +0 -0
- package/binaries/blazediff-macos-arm64 +0 -0
- package/binaries/blazediff-macos-x64 +0 -0
- package/binaries/blazediff-windows-arm64.exe +0 -0
- package/binaries/blazediff-windows-x64.exe +0 -0
- package/post_install.js +0 -40
package/dist/index.js
CHANGED
|
@@ -34,21 +34,102 @@ __export(index_exports, {
|
|
|
34
34
|
getBinaryPath: () => getBinaryPath
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_jiti@2.6.0_postcss@8.5.6_tsx@4.20.6_typescript@5.9.2_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
|
|
39
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
40
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
41
|
+
|
|
42
|
+
// src/index.ts
|
|
37
43
|
var import_node_child_process = require("child_process");
|
|
44
|
+
var import_node_fs = require("fs");
|
|
45
|
+
var import_node_module = require("module");
|
|
46
|
+
var import_node_os = __toESM(require("os"));
|
|
38
47
|
var import_node_path = __toESM(require("path"));
|
|
48
|
+
var import_node_url = require("url");
|
|
39
49
|
var import_node_util = require("util");
|
|
40
50
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
41
|
-
var
|
|
51
|
+
var PLATFORM_PACKAGES = {
|
|
52
|
+
"darwin-arm64": {
|
|
53
|
+
packageName: "@blazediff/bin-darwin-arm64",
|
|
54
|
+
packageDir: "bin-darwin-arm64"
|
|
55
|
+
},
|
|
56
|
+
"darwin-x64": {
|
|
57
|
+
packageName: "@blazediff/bin-darwin-x64",
|
|
58
|
+
packageDir: "bin-darwin-x64"
|
|
59
|
+
},
|
|
60
|
+
"linux-arm64": {
|
|
61
|
+
packageName: "@blazediff/bin-linux-arm64",
|
|
62
|
+
packageDir: "bin-linux-arm64"
|
|
63
|
+
},
|
|
64
|
+
"linux-x64": {
|
|
65
|
+
packageName: "@blazediff/bin-linux-x64",
|
|
66
|
+
packageDir: "bin-linux-x64"
|
|
67
|
+
},
|
|
68
|
+
"win32-arm64": {
|
|
69
|
+
packageName: "@blazediff/bin-win32-arm64",
|
|
70
|
+
packageDir: "bin-win32-arm64"
|
|
71
|
+
},
|
|
72
|
+
"win32-x64": {
|
|
73
|
+
packageName: "@blazediff/bin-win32-x64",
|
|
74
|
+
packageDir: "bin-win32-x64"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function resolveBinaryPath() {
|
|
78
|
+
const platform = import_node_os.default.platform();
|
|
79
|
+
const arch = import_node_os.default.arch();
|
|
80
|
+
const key = `${platform}-${arch}`;
|
|
81
|
+
const platformInfo = PLATFORM_PACKAGES[key];
|
|
82
|
+
if (!platformInfo) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Unsupported platform: ${key}. Supported: ${Object.keys(PLATFORM_PACKAGES).join(", ")}`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
const binaryName = platform === "win32" ? "blazediff.exe" : "blazediff";
|
|
88
|
+
try {
|
|
89
|
+
const require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
90
|
+
const packagePath = require2.resolve(
|
|
91
|
+
`${platformInfo.packageName}/package.json`
|
|
92
|
+
);
|
|
93
|
+
const packageDir = import_node_path.default.dirname(packagePath);
|
|
94
|
+
const binaryPath = import_node_path.default.join(packageDir, binaryName);
|
|
95
|
+
if ((0, import_node_fs.existsSync)(binaryPath)) {
|
|
96
|
+
return binaryPath;
|
|
97
|
+
}
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
const currentDir = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
101
|
+
const packagesDir = import_node_path.default.resolve(currentDir, "..", "..");
|
|
102
|
+
const siblingPath = import_node_path.default.join(
|
|
103
|
+
packagesDir,
|
|
104
|
+
platformInfo.packageDir,
|
|
105
|
+
binaryName
|
|
106
|
+
);
|
|
107
|
+
if ((0, import_node_fs.existsSync)(siblingPath)) {
|
|
108
|
+
return siblingPath;
|
|
109
|
+
}
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Platform package ${platformInfo.packageName} is not installed. This usually means the optional dependency wasn't installed for your platform. Try reinstalling with: npm install @blazediff/bin`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
var cachedBinaryPath = null;
|
|
115
|
+
function getBinaryPathInternal() {
|
|
116
|
+
if (!cachedBinaryPath) {
|
|
117
|
+
cachedBinaryPath = resolveBinaryPath();
|
|
118
|
+
}
|
|
119
|
+
return cachedBinaryPath;
|
|
120
|
+
}
|
|
42
121
|
function buildArgs(diffOutput, options) {
|
|
43
122
|
const args = [];
|
|
44
123
|
if (diffOutput) args.push(diffOutput);
|
|
45
124
|
args.push("--output-format=json");
|
|
46
125
|
if (!options) return args;
|
|
47
|
-
if (options.threshold !== void 0)
|
|
126
|
+
if (options.threshold !== void 0)
|
|
127
|
+
args.push(`--threshold=${options.threshold}`);
|
|
48
128
|
if (options.antialiasing) args.push("--antialiasing");
|
|
49
129
|
if (options.diffMask) args.push("--diff-mask");
|
|
50
130
|
if (options.failOnLayoutDiff) args.push("--fail-on-layout");
|
|
51
|
-
if (options.compression !== void 0)
|
|
131
|
+
if (options.compression !== void 0)
|
|
132
|
+
args.push(`--compression=${options.compression}`);
|
|
52
133
|
return args;
|
|
53
134
|
}
|
|
54
135
|
function parseJsonOutput(text) {
|
|
@@ -67,9 +148,10 @@ function detectMissingFile(error, basePath, comparePath) {
|
|
|
67
148
|
return basePath;
|
|
68
149
|
}
|
|
69
150
|
async function compare(basePath, comparePath, diffOutput, options) {
|
|
151
|
+
const binaryPath = getBinaryPathInternal();
|
|
70
152
|
const args = [basePath, comparePath, ...buildArgs(diffOutput, options)];
|
|
71
153
|
try {
|
|
72
|
-
await execFileAsync(
|
|
154
|
+
await execFileAsync(binaryPath, args);
|
|
73
155
|
return { match: true };
|
|
74
156
|
} catch (err) {
|
|
75
157
|
const { code, stdout, stderr } = err;
|
|
@@ -101,7 +183,7 @@ async function compare(basePath, comparePath, diffOutput, options) {
|
|
|
101
183
|
}
|
|
102
184
|
}
|
|
103
185
|
function getBinaryPath() {
|
|
104
|
-
return
|
|
186
|
+
return getBinaryPathInternal();
|
|
105
187
|
}
|
|
106
188
|
// Annotate the CommonJS export names for ESM import in node:
|
|
107
189
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,94 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/tsup@8.5.0_jiti@2.6.0_postcss@8.5.6_tsx@4.20.6_typescript@5.9.2_yaml@2.8.1/node_modules/tsup/assets/esm_shims.js
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
5
|
-
var getDirname = () => path.dirname(getFilename());
|
|
6
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
7
|
-
|
|
8
1
|
// src/index.ts
|
|
9
2
|
import { execFile } from "child_process";
|
|
10
|
-
import
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
11
8
|
import { promisify } from "util";
|
|
12
9
|
var execFileAsync = promisify(execFile);
|
|
13
|
-
var
|
|
10
|
+
var PLATFORM_PACKAGES = {
|
|
11
|
+
"darwin-arm64": {
|
|
12
|
+
packageName: "@blazediff/bin-darwin-arm64",
|
|
13
|
+
packageDir: "bin-darwin-arm64"
|
|
14
|
+
},
|
|
15
|
+
"darwin-x64": {
|
|
16
|
+
packageName: "@blazediff/bin-darwin-x64",
|
|
17
|
+
packageDir: "bin-darwin-x64"
|
|
18
|
+
},
|
|
19
|
+
"linux-arm64": {
|
|
20
|
+
packageName: "@blazediff/bin-linux-arm64",
|
|
21
|
+
packageDir: "bin-linux-arm64"
|
|
22
|
+
},
|
|
23
|
+
"linux-x64": {
|
|
24
|
+
packageName: "@blazediff/bin-linux-x64",
|
|
25
|
+
packageDir: "bin-linux-x64"
|
|
26
|
+
},
|
|
27
|
+
"win32-arm64": {
|
|
28
|
+
packageName: "@blazediff/bin-win32-arm64",
|
|
29
|
+
packageDir: "bin-win32-arm64"
|
|
30
|
+
},
|
|
31
|
+
"win32-x64": {
|
|
32
|
+
packageName: "@blazediff/bin-win32-x64",
|
|
33
|
+
packageDir: "bin-win32-x64"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function resolveBinaryPath() {
|
|
37
|
+
const platform = os.platform();
|
|
38
|
+
const arch = os.arch();
|
|
39
|
+
const key = `${platform}-${arch}`;
|
|
40
|
+
const platformInfo = PLATFORM_PACKAGES[key];
|
|
41
|
+
if (!platformInfo) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Unsupported platform: ${key}. Supported: ${Object.keys(PLATFORM_PACKAGES).join(", ")}`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
const binaryName = platform === "win32" ? "blazediff.exe" : "blazediff";
|
|
47
|
+
try {
|
|
48
|
+
const require2 = createRequire(import.meta.url);
|
|
49
|
+
const packagePath = require2.resolve(
|
|
50
|
+
`${platformInfo.packageName}/package.json`
|
|
51
|
+
);
|
|
52
|
+
const packageDir = path.dirname(packagePath);
|
|
53
|
+
const binaryPath = path.join(packageDir, binaryName);
|
|
54
|
+
if (existsSync(binaryPath)) {
|
|
55
|
+
return binaryPath;
|
|
56
|
+
}
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
60
|
+
const packagesDir = path.resolve(currentDir, "..", "..");
|
|
61
|
+
const siblingPath = path.join(
|
|
62
|
+
packagesDir,
|
|
63
|
+
platformInfo.packageDir,
|
|
64
|
+
binaryName
|
|
65
|
+
);
|
|
66
|
+
if (existsSync(siblingPath)) {
|
|
67
|
+
return siblingPath;
|
|
68
|
+
}
|
|
69
|
+
throw new Error(
|
|
70
|
+
`Platform package ${platformInfo.packageName} is not installed. This usually means the optional dependency wasn't installed for your platform. Try reinstalling with: npm install @blazediff/bin`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
var cachedBinaryPath = null;
|
|
74
|
+
function getBinaryPathInternal() {
|
|
75
|
+
if (!cachedBinaryPath) {
|
|
76
|
+
cachedBinaryPath = resolveBinaryPath();
|
|
77
|
+
}
|
|
78
|
+
return cachedBinaryPath;
|
|
79
|
+
}
|
|
14
80
|
function buildArgs(diffOutput, options) {
|
|
15
81
|
const args = [];
|
|
16
82
|
if (diffOutput) args.push(diffOutput);
|
|
17
83
|
args.push("--output-format=json");
|
|
18
84
|
if (!options) return args;
|
|
19
|
-
if (options.threshold !== void 0)
|
|
85
|
+
if (options.threshold !== void 0)
|
|
86
|
+
args.push(`--threshold=${options.threshold}`);
|
|
20
87
|
if (options.antialiasing) args.push("--antialiasing");
|
|
21
88
|
if (options.diffMask) args.push("--diff-mask");
|
|
22
89
|
if (options.failOnLayoutDiff) args.push("--fail-on-layout");
|
|
23
|
-
if (options.compression !== void 0)
|
|
90
|
+
if (options.compression !== void 0)
|
|
91
|
+
args.push(`--compression=${options.compression}`);
|
|
24
92
|
return args;
|
|
25
93
|
}
|
|
26
94
|
function parseJsonOutput(text) {
|
|
@@ -39,9 +107,10 @@ function detectMissingFile(error, basePath, comparePath) {
|
|
|
39
107
|
return basePath;
|
|
40
108
|
}
|
|
41
109
|
async function compare(basePath, comparePath, diffOutput, options) {
|
|
110
|
+
const binaryPath = getBinaryPathInternal();
|
|
42
111
|
const args = [basePath, comparePath, ...buildArgs(diffOutput, options)];
|
|
43
112
|
try {
|
|
44
|
-
await execFileAsync(
|
|
113
|
+
await execFileAsync(binaryPath, args);
|
|
45
114
|
return { match: true };
|
|
46
115
|
} catch (err) {
|
|
47
116
|
const { code, stdout, stderr } = err;
|
|
@@ -73,7 +142,7 @@ async function compare(basePath, comparePath, diffOutput, options) {
|
|
|
73
142
|
}
|
|
74
143
|
}
|
|
75
144
|
function getBinaryPath() {
|
|
76
|
-
return
|
|
145
|
+
return getBinaryPathInternal();
|
|
77
146
|
}
|
|
78
147
|
export {
|
|
79
148
|
compare,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazediff/bin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Native Rust binaries for blazediff - the fastest image diff in the world",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -16,15 +16,17 @@
|
|
|
16
16
|
"require": "./dist/index.js"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"bin": {
|
|
20
|
-
"blazediff": "bin/blazediff.exe"
|
|
21
|
-
},
|
|
22
19
|
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
"bin",
|
|
25
|
-
"binaries",
|
|
26
|
-
"post_install.js"
|
|
20
|
+
"dist"
|
|
27
21
|
],
|
|
22
|
+
"optionalDependencies": {
|
|
23
|
+
"@blazediff/bin-darwin-arm64": "3.0.0",
|
|
24
|
+
"@blazediff/bin-darwin-x64": "3.0.0",
|
|
25
|
+
"@blazediff/bin-linux-arm64": "3.0.0",
|
|
26
|
+
"@blazediff/bin-linux-x64": "3.0.0",
|
|
27
|
+
"@blazediff/bin-win32-arm64": "3.0.0",
|
|
28
|
+
"@blazediff/bin-win32-x64": "3.0.0"
|
|
29
|
+
},
|
|
28
30
|
"keywords": [
|
|
29
31
|
"image",
|
|
30
32
|
"comparison",
|
|
@@ -48,11 +50,7 @@
|
|
|
48
50
|
"typescript": "5.9.2"
|
|
49
51
|
},
|
|
50
52
|
"scripts": {
|
|
51
|
-
"postinstall": "node ./post_install.js",
|
|
52
53
|
"build": "tsup",
|
|
53
|
-
"
|
|
54
|
-
"build:rust:local": "cd rust && cargo build --release && cp target/release/blazediff ../binaries/blazediff-$(node -e \"console.log(process.platform === 'darwin' ? 'macos' : process.platform)-$(process.arch === 'arm64' ? 'arm64' : 'x64')\")",
|
|
55
|
-
"prepare-binaries": "node ./scripts/prepare-binaries.js",
|
|
56
|
-
"clean": "rm -rf dist bin"
|
|
54
|
+
"clean": "rm -rf dist"
|
|
57
55
|
}
|
|
58
56
|
}
|
package/bin/blazediff.exe
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/post_install.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const os = require("os");
|
|
4
|
-
|
|
5
|
-
const binaries = {
|
|
6
|
-
"linux-x64": "blazediff-linux-x64",
|
|
7
|
-
"linux-arm64": "blazediff-linux-arm64",
|
|
8
|
-
"darwin-arm64": "blazediff-macos-arm64",
|
|
9
|
-
"darwin-x64": "blazediff-macos-x64",
|
|
10
|
-
"win32-x64": "blazediff-windows-x64.exe",
|
|
11
|
-
"win32-arm64": "blazediff-windows-arm64.exe",
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const platform = os.platform();
|
|
15
|
-
const arch = os.arch();
|
|
16
|
-
|
|
17
|
-
const binaryKey = `${platform}-${arch}`;
|
|
18
|
-
const binaryFile = binaries[binaryKey];
|
|
19
|
-
|
|
20
|
-
if (!binaryFile) {
|
|
21
|
-
console.error(
|
|
22
|
-
`blazediff: Sorry your platform or architecture is not supported. Supported: ${Object.keys(binaries).join(", ")}`,
|
|
23
|
-
);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const sourcePath = path.join(__dirname, "binaries", binaryFile);
|
|
28
|
-
const binDir = path.join(__dirname, "bin");
|
|
29
|
-
const destPath = path.join(binDir, "blazediff.exe");
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
if (!fs.existsSync(binDir)) {
|
|
33
|
-
fs.mkdirSync(binDir, { recursive: true });
|
|
34
|
-
}
|
|
35
|
-
fs.copyFileSync(sourcePath, destPath);
|
|
36
|
-
fs.chmodSync(destPath, 0o755);
|
|
37
|
-
} catch (err) {
|
|
38
|
-
console.error(`blazediff: failed to copy and link the binary file: ${err}`);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|