localhop 0.0.0-stage → 0.2.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/README.md +17 -2
- package/bin/localhop.js +34 -0
- package/install.js +76 -0
- package/package.json +37 -4
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# localhop
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Seamless, ultra-low-latency Rust localhost tunnel with a built-in live HTTP & webhook inspector and 1-click replay UI.
|
|
4
|
+
|
|
5
|
+
This npm package downloads the native prebuilt Rust binary (~3.5 MB, zero garbage collector) from [GitHub Releases](https://github.com/Leon24k/localhop/releases) — no Rust toolchain required.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Run without installing
|
|
11
|
+
npx localhop 3000 --server https://<your-relay>.onrender.com
|
|
12
|
+
|
|
13
|
+
# Or install globally
|
|
14
|
+
npm install -g localhop
|
|
15
|
+
localhop 3000 --server https://<your-relay>.onrender.com
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Full documentation, benchmarks, and $0 self-hosting guides: **https://github.com/Leon24k/localhop**
|
package/bin/localhop.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const { spawn } = require("node:child_process");
|
|
7
|
+
|
|
8
|
+
const binName = process.platform === "win32" ? "localhop.exe" : "localhop";
|
|
9
|
+
const binPath = path.join(__dirname, "..", "vendor", binName);
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(binPath)) {
|
|
12
|
+
console.error(
|
|
13
|
+
"[localhop] Native binary not found. Re-run `npm rebuild localhop` or install via `cargo install localhop`."
|
|
14
|
+
);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
23
|
+
process.on(sig, () => {
|
|
24
|
+
if (!child.killed) child.kill(sig);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
child.on("exit", (code, signal) => {
|
|
29
|
+
if (signal) {
|
|
30
|
+
process.kill(process.pid, signal);
|
|
31
|
+
} else {
|
|
32
|
+
process.exit(code ?? 0);
|
|
33
|
+
}
|
|
34
|
+
});
|
package/install.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const os = require("node:os");
|
|
7
|
+
const { execFileSync } = require("node:child_process");
|
|
8
|
+
const pkg = require("./package.json");
|
|
9
|
+
|
|
10
|
+
const REPO = "Leon24k/localhop";
|
|
11
|
+
|
|
12
|
+
function resolveTarget() {
|
|
13
|
+
const { platform, arch } = process;
|
|
14
|
+
if (platform === "darwin" && arch === "arm64") return { target: "aarch64-apple-darwin", ext: "tar.gz", bin: "localhop" };
|
|
15
|
+
if (platform === "darwin" && arch === "x64") return { target: "x86_64-apple-darwin", ext: "tar.gz", bin: "localhop" };
|
|
16
|
+
if (platform === "linux" && arch === "x64") return { target: "x86_64-unknown-linux-gnu", ext: "tar.gz", bin: "localhop" };
|
|
17
|
+
if (platform === "linux" && arch === "arm64") return { target: "aarch64-unknown-linux-gnu", ext: "tar.gz", bin: "localhop" };
|
|
18
|
+
if (platform === "win32" && arch === "x64") return { target: "x86_64-pc-windows-msvc", ext: "zip", bin: "localhop.exe" };
|
|
19
|
+
throw new Error(`Unsupported platform: ${platform}-${arch}. Install via 'cargo install localhop' instead.`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function main() {
|
|
23
|
+
if (process.env.LOCALHOP_SKIP_DOWNLOAD === "1") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { target, ext, bin } = resolveTarget();
|
|
28
|
+
const vendorDir = path.join(__dirname, "vendor");
|
|
29
|
+
const binPath = path.join(vendorDir, bin);
|
|
30
|
+
|
|
31
|
+
if (fs.existsSync(binPath)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const tag = `v${pkg.version}`;
|
|
36
|
+
const asset = `localhop-${tag}-${target}.${ext}`;
|
|
37
|
+
const url = `https://github.com/${REPO}/releases/download/${tag}/${asset}`;
|
|
38
|
+
|
|
39
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
40
|
+
if (!res.ok) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Failed to download ${url} (HTTP ${res.status}). ` +
|
|
43
|
+
`Make sure GitHub Release ${tag} exists, or install via 'cargo install localhop'.`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "localhop-"));
|
|
48
|
+
const archivePath = path.join(tmpDir, asset);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
52
|
+
fs.writeFileSync(archivePath, buf);
|
|
53
|
+
fs.mkdirSync(vendorDir, { recursive: true });
|
|
54
|
+
|
|
55
|
+
if (ext === "tar.gz") {
|
|
56
|
+
execFileSync("tar", ["-xzf", archivePath, "-C", vendorDir], { stdio: "inherit" });
|
|
57
|
+
} else {
|
|
58
|
+
execFileSync(
|
|
59
|
+
"powershell",
|
|
60
|
+
["-NoProfile", "-Command", `Expand-Archive -Path '${archivePath}' -DestinationPath '${vendorDir}' -Force`],
|
|
61
|
+
{ stdio: "inherit" }
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (process.platform !== "win32") {
|
|
66
|
+
fs.chmodSync(binPath, 0o755);
|
|
67
|
+
}
|
|
68
|
+
} finally {
|
|
69
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main().catch((err) => {
|
|
74
|
+
console.error(`[localhop] ${err.message}`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "localhop",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Seamless, ultra-low-latency Rust localhost tunnel with built-in live HTTP/webhook inspector & replay",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"tunnel",
|
|
8
|
+
"ngrok",
|
|
9
|
+
"localhost",
|
|
10
|
+
"webhook",
|
|
11
|
+
"inspector",
|
|
12
|
+
"rust",
|
|
13
|
+
"proxy",
|
|
14
|
+
"devtool"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Leon24k/localhop.git",
|
|
19
|
+
"directory": "npm/localhop"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://leon24k.github.io/localhop/",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/Leon24k/localhop/issues"
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"localhop": "bin/localhop.js"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"postinstall": "node install.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"bin/localhop.js",
|
|
33
|
+
"install.js",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
}
|
|
39
|
+
}
|