diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml
index 759456e4..db425fc9 100644
--- a/.github/workflows/prerelease.yml
+++ b/.github/workflows/prerelease.yml
@@ -195,6 +195,12 @@ jobs:
bun install
bun run build
+ - name: Verify managed Windows launcher
+ run: bun test src/main/runtime/managed-launcher.test.ts
+
+ - name: Verify Windows launcher bootstrap
+ run: bun test src/main/runtime/windows-launcher-bootstrap.test.ts
+
- name: Build unsigned Windows artifacts
run: bun run build:win:unsigned
@@ -256,11 +262,11 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile
- - name: Build Bun subminer wrapper
+ - name: Build launcher runtime artifacts
run: make build-launcher
- - name: Verify Bun subminer wrapper
- run: dist/launcher/subminer --help >/dev/null
+ - name: Smoke launcher bundle
+ run: bun dist/launcher/subminer.js --help >/dev/null
- name: Enforce generated launcher workflow
run: bash scripts/verify-generated-launcher.sh
@@ -275,12 +281,16 @@ jobs:
plugin/subminer \
plugin/subminer.conf \
assets/themes/subminer.rasi \
- assets/thumbnailers/subminer-ffmpegthumbnailer.thumbnailer
+ assets/thumbnailers/subminer-ffmpegthumbnailer.thumbnailer \
+ resources/bun/licenses
+
+ - name: Package Bun corresponding source
+ run: bun scripts/package-bun-source.mjs
- name: Generate checksums
run: |
shopt -s nullglob
- files=(release/*.AppImage release/*.dmg release/*.exe release/*.zip release/*.tar.gz release/latest*.yml release/*.blockmap dist/launcher/subminer)
+ files=(release/*.AppImage release/*.dmg release/*.exe release/*.zip release/*.tar.gz release/latest*.yml release/*.blockmap dist/launcher/subminer dist/launcher/subminer.cmd)
if [ "${#files[@]}" -eq 0 ]; then
echo "No release artifacts found for checksum generation."
exit 1
@@ -323,10 +333,12 @@ jobs:
release/*.exe
release/*.zip
release/*.tar.gz
+ release/*.tar.gz.sha256
release/latest*.yml
release/*.blockmap
release/SHA256SUMS.txt
dist/launcher/subminer
+ dist/launcher/subminer.cmd
)
if [ "${#artifacts[@]}" -eq 0 ]; then
diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml
index ecf50aa8..50c69c3e 100644
--- a/.github/workflows/quality-gate.yml
+++ b/.github/workflows/quality-gate.yml
@@ -7,6 +7,31 @@ permissions:
contents: read
jobs:
+ launcher-runtime:
+ strategy:
+ matrix:
+ os: [windows-latest, macos-latest]
+ runs-on: ${{ matrix.os }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+
+ - name: Setup Bun
+ uses: oven-sh/setup-bun@v2
+ with:
+ bun-version: 1.3.5
+
+ - name: Verify native runtime staging
+ run: bun test src/main/runtime/managed-launcher.test.ts
+
+ - name: Verify Windows launcher bootstrap
+ run: bun test src/main/runtime/windows-launcher-bootstrap.test.ts
+
+ - name: Verify POSIX launcher bootstrap
+ run: bun test src/main/runtime/posix-launcher-bootstrap.test.ts
+
quality-gate:
runs-on: ubuntu-latest
steps:
@@ -110,11 +135,11 @@ jobs:
- name: Security audit
run: bun audit --audit-level high
- - name: Build Bun subminer wrapper
+ - name: Build launcher runtime artifacts
run: make build-launcher
- - name: Verify Bun subminer wrapper
- run: dist/launcher/subminer --help >/dev/null
+ - name: Smoke launcher bundle
+ run: bun dist/launcher/subminer.js --help >/dev/null
- name: Enforce generated launcher workflow
run: bash scripts/verify-generated-launcher.sh
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 86ba2ce7..53ae1a64 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -194,6 +194,12 @@ jobs:
bun install
bun run build
+ - name: Verify managed Windows launcher
+ run: bun test src/main/runtime/managed-launcher.test.ts
+
+ - name: Verify Windows launcher bootstrap
+ run: bun test src/main/runtime/windows-launcher-bootstrap.test.ts
+
- name: Build unsigned Windows artifacts
run: bun run build:win:unsigned
@@ -255,11 +261,11 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile
- - name: Build Bun subminer wrapper
+ - name: Build launcher runtime artifacts
run: make build-launcher
- - name: Verify Bun subminer wrapper
- run: dist/launcher/subminer --help >/dev/null
+ - name: Smoke launcher bundle
+ run: bun dist/launcher/subminer.js --help >/dev/null
- name: Enforce generated launcher workflow
run: bash scripts/verify-generated-launcher.sh
@@ -274,12 +280,16 @@ jobs:
plugin/subminer \
plugin/subminer.conf \
assets/themes/subminer.rasi \
- assets/thumbnailers/subminer-ffmpegthumbnailer.thumbnailer
+ assets/thumbnailers/subminer-ffmpegthumbnailer.thumbnailer \
+ resources/bun/licenses
+
+ - name: Package Bun corresponding source
+ run: bun scripts/package-bun-source.mjs
- name: Generate checksums
run: |
shopt -s nullglob
- files=(release/*.AppImage release/*.dmg release/*.exe release/*.zip release/*.tar.gz release/latest*.yml release/*.blockmap dist/launcher/subminer)
+ files=(release/*.AppImage release/*.dmg release/*.exe release/*.zip release/*.tar.gz release/latest*.yml release/*.blockmap dist/launcher/subminer dist/launcher/subminer.cmd)
if [ "${#files[@]}" -eq 0 ]; then
echo "No release artifacts found for checksum generation."
exit 1
@@ -340,10 +350,12 @@ jobs:
release/*.exe
release/*.zip
release/*.tar.gz
+ release/*.tar.gz.sha256
release/latest*.yml
release/*.blockmap
release/SHA256SUMS.txt
dist/launcher/subminer
+ dist/launcher/subminer.cmd
)
if [ "${#artifacts[@]}" -eq 0 ]; then
diff --git a/Makefile b/Makefile
index 09533805..59adc5e3 100644
--- a/Makefile
+++ b/Makefile
@@ -160,14 +160,8 @@ build-macos-unsigned: deps
@bun run build:mac:unsigned
build-launcher:
- @printf '%s\n' "[INFO] Bundling launcher script"
- @install -d "$(dir $(LAUNCHER_OUT))"
- @bun build ./launcher/main.ts --target=bun --packages=bundle --outfile="$(LAUNCHER_OUT)"
- @if ! head -1 "$(LAUNCHER_OUT)" | grep -q '^#!/usr/bin/env bun'; then \
- { printf '#!/usr/bin/env bun\n'; cat "$(LAUNCHER_OUT)"; } > "$(LAUNCHER_OUT).tmp" && mv "$(LAUNCHER_OUT).tmp" "$(LAUNCHER_OUT)"; \
- fi
- @chmod +x "$(LAUNCHER_OUT)"
- @printf '%s\n' "[INFO] Launcher artifact: $(LAUNCHER_OUT)"
+ @printf '%s\n' "[INFO] Building launcher runtime artifacts"
+ @bun run build:launcher
clean:
@printf '%s\n' "[INFO] Removing build artifacts"
diff --git a/README.md b/README.md
index 4fd7b218..301e9d3b 100644
--- a/README.md
+++ b/README.md
@@ -191,7 +191,9 @@ wget https://github.com/ksyasuda/SubMiner/releases/latest/download/SubMiner.AppI
&& chmod +x ~/.local/bin/SubMiner.AppImage
```
-The AppImage is all you need. The optional `subminer` command-line launcher runs on [Bun](https://bun.sh), and first-run setup can install both for you. To grab it manually instead, install Bun first, then:
+The AppImage is all you need. First-run setup can install the optional `subminer` command-line launcher. Every current launcher uses Bun included with the app, so you do not need Bun installed or on `PATH`.
+
+You can also download the launcher wrapper directly:
```bash
wget https://github.com/ksyasuda/SubMiner/releases/latest/download/subminer -O ~/.local/bin/subminer \
@@ -212,6 +214,8 @@ Download the latest DMG from [GitHub Releases](https://github.com/ksyasuda/SubMi
Download and run the latest installer (`.exe`) from [GitHub Releases](https://github.com/ksyasuda/SubMiner/releases/latest).
+For terminal use, download `subminer.cmd`. It locates the installed app and uses its private Bun runtime.
+
@@ -223,14 +227,14 @@ See the [build-from-source guide](https://docs.subminer.moe/installation#from-so
### 2. Launch & Set Up
-Run SubMiner and the first-run setup wizard will guide you through importing Yomitan dictionaries and optionally installing the `subminer` command-line launcher.
+Run the installed app and the first-run setup wizard will guide you through importing Yomitan dictionaries and optionally installing the `subminer` command-line launcher. Setup records a custom app location when needed, and the wrapper runs with the app's private Bun runtime.
```bash
# Linux
-subminer app --setup
+~/.local/bin/SubMiner.AppImage --setup
-# macOS — open SubMiner.app, or:
-subminer app --setup
+# macOS
+open -a SubMiner --args --setup
```
On **Windows**, just run `SubMiner.exe` and the setup will open automatically on first launch.
@@ -262,6 +266,7 @@ SubMiner builds on the work of these open-source projects:
| [Anacreon-Script](https://github.com/friedrich-de/Anacreon-Script) | Inspiration for the mining workflow |
| [asbplayer](https://github.com/killergerbah/asbplayer) | Inspiration for subtitle sidebar and logic for YouTube subtitle parsing |
| [Bee's Character Dictionary](https://github.com/bee-san/Japanese_Character_Name_Dictionary) | Character name recognition in subtitles |
+| [Bun](https://github.com/oven-sh/bun) | Bundled runtime for the `subminer` command-line launcher |
| [GameSentenceMiner](https://github.com/bpwhelan/GameSentenceMiner) | Inspiration for Electron overlay with Yomitan integration |
| [jellyfin-mpv-shim](https://github.com/jellyfin/jellyfin-mpv-shim) | Jellyfin integration |
| [Jimaku.cc](https://jimaku.cc) | Japanese subtitle search and downloads |
@@ -271,4 +276,6 @@ SubMiner builds on the work of these open-source projects:
## License
-[GNU General Public License v3.0](LICENSE)
+SubMiner is released under the [GNU General Public License v3.0](LICENSE).
+
+Release packages also bundle an unmodified copy of [Bun](https://github.com/oven-sh/bun), which is MIT licensed and statically links JavaScriptCore (LGPL 2.0) and TinyCC (LGPL 2.1). Its license texts and third-party notices ship inside the app under `resources/bun/licenses`, and each release publishes `bun-v1.3.5-source.tar.gz` with the corresponding source. See [Bundled Bun runtime](https://docs.subminer.moe/installation#bundled-bun-runtime).
diff --git a/build/bun-runtime-manifest.json b/build/bun-runtime-manifest.json
new file mode 100644
index 00000000..e0dcd726
--- /dev/null
+++ b/build/bun-runtime-manifest.json
@@ -0,0 +1,31 @@
+{
+ "schemaVersion": 1,
+ "version": "1.3.5",
+ "bunRevision": "1e86cebd74a5723e818b5c0555276b646bcf0e4c",
+ "releaseTagCommit": "fa5a5bbe556a4bda5bde77b4013aa6c3bb4ec9ab",
+ "artifacts": {
+ "darwin-arm64": {
+ "file": "bun-darwin-aarch64.zip",
+ "sha256": "db17588a4aea8804856825d4bead3f05e1f37276ca606f37e369b4f72f35d3fb"
+ },
+ "darwin-x64": {
+ "file": "bun-darwin-x64-baseline.zip",
+ "sha256": "34b9a56b851058dafa1bc9d61233f2c383aa996889bba30b3180f5ccc2cff1b2"
+ },
+ "linux-arm64": {
+ "file": "bun-linux-aarch64.zip",
+ "sha256": "ed01000f85bd97785228ad2845dc92a1860b8054856826d7317690ac8f8ee74b"
+ },
+ "linux-x64": {
+ "file": "bun-linux-x64-baseline.zip",
+ "sha256": "6bddacd6a65855698b9816f2d74871eda4dd0b7fa921140c6445248f94a742fd"
+ },
+ "win32-x64": {
+ "file": "bun-windows-x64-baseline.zip",
+ "sha256": "bf447dcc3b06aba9b9706a9db46fcd65e06a4d47d31439922313825d06eb47ca"
+ }
+ },
+ "licenseInventoryStatus": "source-and-notices-pinned-to-binary-revision",
+ "sourceManifest": "build/bun-source-manifest.json",
+ "correspondingSourceAsset": "bun-v1.3.5-source.tar.gz"
+}
diff --git a/build/bun-source-manifest.json b/build/bun-source-manifest.json
new file mode 100644
index 00000000..23b4864b
--- /dev/null
+++ b/build/bun-source-manifest.json
@@ -0,0 +1,148 @@
+{
+ "schemaVersion": 1,
+ "version": "1.3.5",
+ "releaseTag": "bun-v1.3.5",
+ "releaseTagCommit": "fa5a5bbe556a4bda5bde77b4013aa6c3bb4ec9ab",
+ "bunRevision": "1e86cebd74a5723e818b5c0555276b646bcf0e4c",
+ "archiveName": "bun-v1.3.5-source.tar.gz",
+ "sources": [
+ {
+ "name": "bun",
+ "repository": "oven-sh/bun",
+ "revision": "1e86cebd74a5723e818b5c0555276b646bcf0e4c",
+ "destination": "bun",
+ "sha256": "3a766087902a62a4920e5ac5452dbc7143ff97ea19721f945146629fc9f2d82c",
+ "licensePaths": ["LICENSE.md"]
+ },
+ {
+ "name": "WebKit",
+ "repository": "oven-sh/WebKit",
+ "revision": "6d0f3aac0b817cc01a846b3754b21271adedac12",
+ "destination": "bun/vendor/WebKit",
+ "transport": "git-sparse",
+ "exclude": ["JSTests", "LayoutTests", "ManualTests", "PerformanceTests", "WebDriverTests"],
+ "licensePaths": ["Source/JavaScriptCore/COPYING.LIB"]
+ },
+ {
+ "name": "boringssl",
+ "repository": "oven-sh/boringssl",
+ "revision": "f1ffd9e83d4f5c28a9c70d73f9a4e6fcf310062f",
+ "destination": "bun/vendor/boringssl",
+ "sha256": "af8fd325793bb261c70114d09a24f36092fbe252be8ec040f0054ec9455f0ea3",
+ "licensePaths": ["LICENSE"]
+ },
+ {
+ "name": "brotli",
+ "repository": "google/brotli",
+ "revision": "ed738e842d2fbdf2d6459e39267a633c4a9b2f5d",
+ "upstreamReference": "v1.1.0",
+ "destination": "bun/vendor/brotli",
+ "sha256": "aaa739962a45b508b2e783b915e6b2b57ed3b12bd4b0feac73acfb144dffa54f",
+ "licensePaths": ["LICENSE"]
+ },
+ {
+ "name": "cares",
+ "repository": "c-ares/c-ares",
+ "revision": "3ac47ee46edd8ea40370222f91613fc16c434853",
+ "destination": "bun/vendor/cares",
+ "sha256": "8c94116cb366ae4a44e487da4d9f7e736287d329efa6f88fdf077cd2d0a2e4b8",
+ "licensePaths": ["LICENSE.md"]
+ },
+ {
+ "name": "hdrhistogram",
+ "repository": "HdrHistogram/HdrHistogram_c",
+ "revision": "be60a9987ee48d0abf0d7b6a175bad8d6c1585d1",
+ "destination": "bun/vendor/hdrhistogram",
+ "sha256": "811c5e5ae5303a75ade50688880af6aad5d2f951ec5785f68186bd18635cdfc9",
+ "licensePaths": ["COPYING.txt", "LICENSE.txt"]
+ },
+ {
+ "name": "highway",
+ "repository": "google/highway",
+ "revision": "ac0d5d297b13ab1b89f48484fc7911082d76a93f",
+ "destination": "bun/vendor/highway",
+ "sha256": "a7a816f4b62a0414ff0d39c0a8875847468dd6f7c9ad71781a24469a756cdea7",
+ "licensePaths": ["LICENSE"]
+ },
+ {
+ "name": "libarchive",
+ "repository": "libarchive/libarchive",
+ "revision": "9525f90ca4bd14c7b335e2f8c84a4607b0af6bdf",
+ "destination": "bun/vendor/libarchive",
+ "sha256": "944db9ab58a3cbdb5d947db4f04a3cc15f83b3147fcf7830ada592ba8d4a102c",
+ "licensePaths": ["COPYING"]
+ },
+ {
+ "name": "libdeflate",
+ "repository": "ebiggers/libdeflate",
+ "revision": "c8c56a20f8f621e6a966b716b31f1dedab6a41e3",
+ "destination": "bun/vendor/libdeflate",
+ "sha256": "1e5cc06bdbf3e1245d8b89c9e3588f507e3c8bc53fe8b8229770a9e8661dea81",
+ "licensePaths": ["COPYING"]
+ },
+ {
+ "name": "libuv",
+ "repository": "libuv/libuv",
+ "revision": "f3ce527ea940d926c40878ba5de219640c362811",
+ "destination": "bun/vendor/libuv",
+ "sha256": "46040d51e8aa86a7c84e377e224d427c35022ec6e3ed8ed399493b0d8574d0cf",
+ "licensePaths": ["LICENSE"]
+ },
+ {
+ "name": "lolhtml",
+ "repository": "cloudflare/lol-html",
+ "revision": "d64457d9ff0143deef025d5df7e8586092b9afb7",
+ "destination": "bun/vendor/lolhtml",
+ "sha256": "893b77b460f4c4f4634c973f72cf35e38ebe30646d14a92db3f50ee7e586c0ad",
+ "licensePaths": ["LICENSE"]
+ },
+ {
+ "name": "lshpack",
+ "repository": "litespeedtech/ls-hpack",
+ "revision": "8905c024b6d052f083a3d11d0a169b3c2735c8a1",
+ "destination": "bun/vendor/lshpack",
+ "sha256": "07d8bf901bb1b15543f38eabd23938519e1210eebadb52f3d651d6ef130ef973",
+ "licensePaths": ["LICENSE"]
+ },
+ {
+ "name": "mimalloc",
+ "repository": "oven-sh/mimalloc",
+ "revision": "1beadf9651a7bfdec6b5367c380ecc3fe1c40d1a",
+ "destination": "bun/vendor/mimalloc",
+ "sha256": "317ec2a83462ece78c344c4955c6fee103b412a8e6a0d6ddf9ec8963ed9c0881",
+ "licensePaths": ["LICENSE"]
+ },
+ {
+ "name": "picohttpparser",
+ "repository": "h2o/picohttpparser",
+ "revision": "066d2b1e9ab820703db0837a7255d92d30f0c9f5",
+ "destination": "bun/vendor/picohttpparser",
+ "sha256": "637ff2ab6f5c7f7e05a5b5dc393d5cf2fea8d4754fcaceaaf935ffff5c1323ee",
+ "licensePaths": ["picohttpparser.c", "picohttpparser.h"]
+ },
+ {
+ "name": "tinycc",
+ "repository": "oven-sh/tinycc",
+ "revision": "29985a3b59898861442fa3b43f663fc1af2591d7",
+ "destination": "bun/vendor/tinycc",
+ "sha256": "813cc09aafd6cea9c1ae6b745781e6b27576a0c103f49b63b5c8a732bbe3d290",
+ "licensePaths": ["COPYING"]
+ },
+ {
+ "name": "zlib",
+ "repository": "cloudflare/zlib",
+ "revision": "886098f3f339617b4243b286f5ed364b9989e245",
+ "destination": "bun/vendor/zlib",
+ "sha256": "14bf449df8308696af52f87de88f54c9eb9c91ec5e280587f9d37f7a3f6ed9bb",
+ "licensePaths": ["LICENSE"]
+ },
+ {
+ "name": "zstd",
+ "repository": "facebook/zstd",
+ "revision": "f8745da6ff1ad1e7bab384bd1f9d742439278e99",
+ "destination": "bun/vendor/zstd",
+ "sha256": "4b0bd1f0cfb25e61b9103c35f27395530ff5b4c0d2513a00fd745849e85ea52c",
+ "licensePaths": ["COPYING", "LICENSE"]
+ }
+ ]
+}
diff --git a/changes/bundled-bun-runtime-docs.md b/changes/bundled-bun-runtime-docs.md
new file mode 100644
index 00000000..5ac31726
--- /dev/null
+++ b/changes/bundled-bun-runtime-docs.md
@@ -0,0 +1,5 @@
+type: docs
+area: launcher
+
+- Documented private-runtime launcher installation, simplified first-run setup, custom app locations, legacy launcher migration, and package-managed updates. Updated release-note download guidance for the bundled runtime and Windows launcher.
+- Documented the bundled Bun runtime's MIT and LGPL licensing, where the notices live in the app, and the corresponding-source release asset. The AUR package now lists the bundled runtime licenses and installs their notices under `/usr/share/licenses/subminer-bin`, and `subminer-assets.tar.gz` includes the same notices.
diff --git a/changes/bundled-bun-runtime.md b/changes/bundled-bun-runtime.md
new file mode 100644
index 00000000..b0cfc2d9
--- /dev/null
+++ b/changes/bundled-bun-runtime.md
@@ -0,0 +1,5 @@
+type: changed
+area: launcher
+
+- Made every installed and downloadable launcher use the Bun runtime included with SubMiner. Added a Windows `subminer.cmd` download, persistent private runtime caches for Linux and Windows, and migration for recognized legacy launchers. Deferred migrations survive overlapping update checks and remain pending when startup cannot safely refresh the launcher.
+- Simplified first-run setup to a single optional launcher control, with runtime repair guidance shown only when needed.
diff --git a/docs-site/development.md b/docs-site/development.md
index f03f8f92..71a7a793 100644
--- a/docs-site/development.md
+++ b/docs-site/development.md
@@ -207,7 +207,7 @@ Run `make help` for a full list of targets. Key ones:
| Target | Description |
| --------------------------- | ----------------------------------------------------------------- |
| `make build` | Build platform package for detected OS |
-| `make build-launcher` | Generate Bun launcher wrapper at `dist/launcher/subminer` |
+| `make build-launcher` | Generate launcher wrappers and CLI payload in `dist/launcher/` |
| `make install` | Install platform artifacts (wrapper, theme, AppImage/app bundle) |
| `make deps` | Init submodules and install root/stats/texthooker-ui deps |
| `make pretty` | Run scoped Prettier formatting for maintained source/config files |
diff --git a/docs-site/installation.md b/docs-site/installation.md
index 6495fb47..527a8c9e 100644
--- a/docs-site/installation.md
+++ b/docs-site/installation.md
@@ -14,7 +14,7 @@ Three steps to get started:
Only **mpv** is strictly required. Everything else is optional, though you will want ffmpeg unless you are fine with cards that have no audio or screenshot.
-Some rows below matter only for the `subminer` command-line launcher, which is Linux and macOS only. On Windows you launch playback with the **SubMiner mpv** shortcut, so skip those.
+Some rows below matter only for the `subminer` command-line launcher's picker features. On Windows, the **SubMiner mpv** shortcut remains the recommended playback entry point.
| Dependency | Status | Platforms | What it does |
| -------------------- | ----------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -205,13 +205,13 @@ There is no equivalent setting for ffmpeg: SubMiner invokes it by bare name when
**Optional extras:** [MeCab for Windows](https://taku910.github.io/mecab/#download) with the UTF-8 dictionary improves annotation accuracy; it is not in any package manager, so install it from that page. `xz` is needed only for [TsukiHime](/tsukihime-integration) subtitle downloads and is not packaged by winget or Chocolatey, so use `scoop install main/xz` or download [XZ Utils](https://tukaani.org/xz/) and add its folder to `PATH`.
-The `subminer` command-line launcher and its picker tools (`fzf`, `rofi`, `chafa`, `ffmpegthumbnailer`) are Linux/macOS only; on Windows you use the **SubMiner mpv** shortcut instead.
+The launcher's picker tools (`fzf`, `rofi`, `chafa`, `ffmpegthumbnailer`) are for Linux and macOS. On Windows, use the **SubMiner mpv** shortcut for playback or install the optional `subminer` terminal wrapper during setup.
## 2. Install SubMiner
### Arch Linux (AUR) {#arch-aur}
-Install [`subminer-bin`](https://aur.archlinux.org/packages/subminer-bin) from the AUR. The package includes the SubMiner AppImage and the `subminer` launcher.
+Install [`subminer-bin`](https://aur.archlinux.org/packages/subminer-bin) from the AUR. The package includes the SubMiner AppImage and its launcher wrapper. Bun is included with the app, so the package has no Bun dependency. Install updates through your AUR helper or package manager.
```bash
paru -S subminer-bin
@@ -236,9 +236,7 @@ chmod +x ~/.local/bin/SubMiner.AppImage
```
::: tip Launcher install is optional
-First-run setup can install [Bun](https://bun.sh) and the `subminer` command-line launcher for you automatically. You don't need to download the launcher separately.
-
-If you prefer to install it manually, see [manual launcher install](#manual-launcher-install-linux).
+First-run setup can install the `subminer` command-line launcher for you. It uses Bun bundled with the AppImage, so it does not need a separate Bun installation or a Bun entry on `PATH`. The downloaded wrapper works the same way. See [manual launcher install](#manual-launcher-install-linux).
:::
### macOS (DMG) {#macos-dmg}
@@ -257,9 +255,7 @@ xattr -d com.apple.quarantine /Applications/SubMiner.app
2. Enable SubMiner in the list (add it if it does not appear)
::: tip Launcher install is optional
-First-run setup can install [Bun](https://bun.sh) and the `subminer` command-line launcher for you automatically. You don't need to download the launcher separately.
-
-If you prefer to install it manually, see [manual launcher install](#manual-launcher-install-macos).
+First-run setup can install the `subminer` command-line launcher for you. It uses Bun bundled inside `SubMiner.app`, so it does not need a separate Bun installation or a Bun entry on `PATH`. The downloaded wrapper works the same way. See [manual launcher install](#manual-launcher-install-macos).
:::
### Windows (installer) {#windows-installer}
@@ -268,6 +264,7 @@ Download the latest installer from [GitHub Releases](https://github.com/ksyasuda
- `SubMiner-.exe` - installer (recommended)
- `SubMiner--win.zip` - portable fallback
+- `subminer.cmd` - optional terminal launcher wrapper
Make sure `mpv.exe` is on your `PATH`, or set `mpv.executablePath` in the config during first-run setup.
@@ -288,6 +285,8 @@ bun run build:appimage
Bundled Yomitan is built during `bun run build`.
+Source and development commands use Bun installed on your system.
+
@@ -323,6 +322,10 @@ bun run build:win
+### Bundled Bun runtime {#bundled-bun-runtime}
+
+Every package includes an unmodified copy of Bun 1.3.5 that runs the command-line launcher. Bun is MIT licensed and statically links JavaScriptCore under LGPL 2.0 and TinyCC under LGPL 2.1. The license texts, third-party notices, and a `SOURCE.md` describing the corresponding source ship inside the app under `resources/bun/licenses` (`SubMiner.app/Contents/Resources/bun/licenses` on macOS). Each GitHub release also publishes `bun-v1.3.5-source.tar.gz` with the matching Bun, WebKit, and dependency sources and instructions for rebuilding Bun against a modified JavaScriptCore.
+
## 3. Launch and first-run setup
Launch SubMiner and the setup wizard opens on its own:
@@ -344,10 +347,12 @@ The setup wizard walks you through:
- **Config file** - auto-created at `~/.config/SubMiner/config.jsonc` (Linux/macOS) or `%APPDATA%\SubMiner\config.jsonc` (Windows)
- **Yomitan dictionaries** - import at least one dictionary so word lookups work
-- **Bun + `subminer` launcher** _(optional)_ - installs the command-line launcher into a writable PATH directory
+- **`subminer` launcher** _(optional)_ - installs a wrapper into a writable terminal PATH directory. The wrapper uses Bun packaged with the app, with no separate runtime setup. If the included runtime is unavailable, the launcher controls show an error asking you to reinstall SubMiner.
- **Windows shortcut** _(Windows only)_ - create a `SubMiner mpv` Start Menu/Desktop shortcut
-The `Finish setup` button requires a config file and at least one Yomitan dictionary. Bun and the launcher are optional and never block setup completion.
+The `Finish setup` button requires a config file and at least one Yomitan dictionary. The launcher is optional and never blocks setup completion.
+
+On Linux and macOS, setup selects a writable directory already on your terminal `PATH`. If it cannot find one, it creates `~/.local/bin` and shows the `export PATH=...` command to run. Add that command to your shell configuration yourself if you want it in future terminals. Setup never edits shell configuration files. On Windows, setup adds only the wrapper directory to the user `PATH`. Setup stores a custom app location so the wrapper can find an AppImage or app bundle outside the usual install directories.
> [!TIP]
> You can re-open the setup wizard at any time with `subminer app --setup` or `SubMiner.AppImage --setup`.
@@ -396,9 +401,9 @@ subminer --update
SubMiner verifies AppImage, launcher, and Linux support-asset downloads against `SHA256SUMS.txt`. On Linux those support assets include the launcher-managed runtime plugin copy under `SubMiner/plugin/subminer`, the rofi theme at `SubMiner/themes/subminer.rasi`, and the scoped Matroska thumbnailer registration under `SubMiner/thumbnailers`. If the binary is in a protected path, SubMiner shows the exact command to run rather than elevating itself.
-The tray "Check for Updates" entry installs the new app automatically on Linux, macOS, and Windows. On Linux it replaces the running `.AppImage` in place via `electron-updater` and refreshes the managed support assets from `subminer-assets.tar.gz`; AppImages managed by a system package (for example the AUR `/opt/SubMiner/SubMiner.AppImage`) are skipped so the package manager stays in charge.
+The tray "Check for Updates" entry installs the new app automatically on Linux, macOS, and Windows. Current `subminer` wrappers remain small bootstraps that locate the installed app and its private runtime. On Linux the updater replaces the running `.AppImage` in place via `electron-updater` and refreshes managed support assets from `subminer-assets.tar.gz`. The next launcher invocation detects the changed AppImage fingerprint and prepares the matching Bun and CLI cache before running the command. App startup also refreshes this payload and migrates recognized writable legacy launchers, including the launcher path an update deferred. AppImages managed by a system package, for example the AUR `/opt/SubMiner/SubMiner.AppImage`, are skipped so the package manager stays in charge.
-`subminer -u` also performs the AppImage, launcher, and managed support-asset updates directly from the launcher process, which is useful when SubMiner is not currently running.
+On Linux, `subminer -u` updates the AppImage and managed support assets directly, even when the app is not running. The launcher cache refreshes when the app fingerprint changes. AUR installs remain under package-manager control and should be updated through the package manager.
## How it all fits together
@@ -430,14 +435,11 @@ SubMiner injects the bundled mpv plugin at runtime, so there is nothing to insta
## Manual launcher install
-The `subminer` launcher uses a [Bun](https://bun.sh) shebang, so Bun must be installed. First-run setup can handle this automatically, but if you prefer to do it yourself:
+Current launcher downloads use Bun included in the SubMiner app. The wrapper searches normal install locations and honors `SUBMINER_BINARY_PATH`; Linux also honors `SUBMINER_APPIMAGE_PATH`.
### Linux {#manual-launcher-install-linux}
```bash
-# Install Bun
-curl -fsSL https://bun.sh/install | bash
-
# Download the launcher
wget https://github.com/ksyasuda/SubMiner/releases/latest/download/subminer -O ~/.local/bin/subminer
chmod +x ~/.local/bin/subminer
@@ -446,19 +448,22 @@ chmod +x ~/.local/bin/subminer
### macOS {#manual-launcher-install-macos}
```bash
-# Install Bun
-curl -fsSL https://bun.sh/install | bash
-
# Download the launcher
sudo curl -fSL https://github.com/ksyasuda/SubMiner/releases/latest/download/subminer -o /usr/local/bin/subminer
sudo chmod +x /usr/local/bin/subminer
```
+### Windows {#manual-launcher-install-windows}
+
+Download `subminer.cmd` from GitHub Releases and place it in a directory on your user `PATH`. It finds the installed app in the normal per-user or Program Files location. Set `SUBMINER_BINARY_PATH` if you use a portable or custom install.
+
+Launchers installed before the private-runtime change may still be bundled JavaScript with a Bun shebang. Those old files need system Bun until a current app startup migrates a recognized writable launcher, or until you replace one with the current release wrapper.
+
## Optional extras
### Linux support assets
-SubMiner ships the Linux rofi theme, scoped Matroska thumbnailer registration, and launcher-managed runtime plugin copy in `subminer-assets.tar.gz`:
+SubMiner ships the Linux rofi theme, scoped Matroska thumbnailer registration, launcher-managed runtime plugin copy, and the bundled Bun license notices in `subminer-assets.tar.gz`:
```bash
wget https://github.com/ksyasuda/SubMiner/releases/latest/download/subminer-assets.tar.gz -O /tmp/subminer-assets.tar.gz
diff --git a/docs-site/launcher-script.md b/docs-site/launcher-script.md
index e6790053..1b0c25a6 100644
--- a/docs-site/launcher-script.md
+++ b/docs-site/launcher-script.md
@@ -1,6 +1,14 @@
# Launcher script
-The `subminer` launcher handles video selection, mpv startup, and overlay management in one script. Use it on Linux and macOS: it is the only path that guarantees mpv comes up with the right IPC socket and SubMiner's defaults. It is a Bun script, shipped as a release asset next to the AppImage and DMG.
+The `subminer` launcher handles video selection, mpv startup, and overlay management in one script. It guarantees mpv starts with the right IPC socket and SubMiner defaults. On Windows, the **SubMiner mpv** shortcut remains the recommended playback entry point.
+
+The launcher is a small wrapper around the CLI bundled in the desktop app. It locates a normal SubMiner installation, or uses `SUBMINER_BINARY_PATH` when you set a custom executable. Linux also accepts `SUBMINER_APPIMAGE_PATH`. First-run setup records the selected app location for the wrapper. You do not need Bun installed or on `PATH`; only the directory containing `subminer` needs to be on `PATH`.
+
+On macOS, the wrapper runs Bun and the CLI directly from `SubMiner.app/Contents/Resources`. On Windows, `subminer.cmd` stages a versioned private Bun copy under `%LOCALAPPDATA%\SubMiner\launcher-runtime/` and runs the CLI from the current app. Keeping the executable outside the app avoids locking an updater-owned file while a launcher is running. Old runtime versions are removed when no running launcher is using them.
+
+On Linux, the first launch caches Bun and its matching CLI and license files under `${XDG_DATA_HOME:-~/.local/share}/SubMiner/launcher`. Later launches make one `stat` call against the AppImage and run the cache without starting Electron. A missing cache or changed app fingerprint rebuilds it. App startup also refreshes the managed payload after an update.
+
+The downloaded `subminer` and `subminer.cmd` release assets use the same private runtime flow. Older launcher scripts that were installed before this change cannot update their own code retroactively and still need system Bun until the app migrates them at startup or you download a current wrapper.
::: tip Windows users
On Windows, the recommended way to launch playback is the **SubMiner mpv** shortcut created during first-run setup - double-click it, drag a file onto it, or run `SubMiner.exe --launch-mpv` from a terminal. See [Windows mpv Shortcut](/usage#windows-mpv-shortcut) for details.
diff --git a/docs-site/usage.md b/docs-site/usage.md
index 18cddde1..9784f5a1 100644
--- a/docs-site/usage.md
+++ b/docs-site/usage.md
@@ -12,6 +12,8 @@ On **Windows**, use the **SubMiner mpv** shortcut created during first-run setup
That is the whole setup. The `subminer` launcher starts mpv, opens the IPC socket, and brings up the overlay.
+Every current launcher wrapper uses the Bun runtime included with the SubMiner app. This includes setup installs, release downloads, `make install`, and the AUR package. You only need the wrapper directory on your terminal `PATH`. Building SubMiner from source still requires Bun on the development machine.
+
> [!IMPORTANT]
> SubMiner requires the bundled Yomitan instance to have at least one dictionary imported for lookups to work.
> See [Yomitan setup](#yomitan-setup) for details.
@@ -74,7 +76,7 @@ subminer app --setup # Re-open first-run setup
subminer -u # Check for updates
```
-On **Windows** there is no `subminer` launcher. Use the **SubMiner mpv** shortcut for playback (see [Windows mpv Shortcut](#windows-mpv-shortcut)), and run `SubMiner.exe` directly for everything else.
+On **Windows**, first-run setup can install the optional `subminer` terminal wrapper. Use the **SubMiner mpv** shortcut for playback (see [Windows mpv Shortcut](#windows-mpv-shortcut)), or use `subminer` and `SubMiner.exe` from a terminal.
Two flags are worth knowing early:
@@ -212,6 +214,7 @@ Setup flow:
- legacy plugin cleanup: remove detected older global SubMiner mpv plugin files if present (the bundled plugin is injected at runtime automatically)
- Yomitan shortcut: open bundled Yomitan settings directly from the setup window
- dictionary check: confirm at least one bundled Yomitan dictionary is present, unless an external Yomitan profile is configured
+- command line launcher: optionally install or reinstall the managed `subminer` wrapper. Reinstall it to migrate an older launcher or after moving a macOS or Windows app install.
- Windows: optionally create or remove `SubMiner mpv` Start Menu/Desktop shortcuts (`SubMiner.exe --launch-mpv`)
- Windows: optionally set `mpv.executablePath` if `mpv.exe` is not on `PATH`
- refresh: re-check dictionary state without restarting
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index cdc4e8e6..e4320e44 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -31,6 +31,14 @@
`bun run test:fast`
`bun run test:env`
`bun run build`
+ Confirm `dist/launcher` contains only `subminer`, `subminer.cmd`,
+ `subminer.js`, `prepare.cjs`, and `version`. Release CI smoke-tests
+ `subminer.js` with Bun, then publishes both wrapper files and their checksums.
+ Tagged CI runs `bun scripts/package-bun-source.mjs` and must publish
+ `bun-v-source.tar.gz` plus its `.sha256` file. The script
+ fails if Bun's CMake dependency pins, WebKit pin, source checksums, patch
+ inputs, or collected license files differ from
+ `build/bun-source-manifest.json`.
When validating auto-update metadata, also run the relevant platform package
build and confirm `release/` contains the generated updater metadata
(`latest*.yml`) and blockmaps (`*.blockmap`).
@@ -54,6 +62,11 @@
`bun run test:fast`
`bun run test:env`
`bun run build`
+ Confirm both launcher wrappers and their checksums are included in the
+ prerelease assets.
+ Prerelease CI also assembles and publishes the pinned Bun corresponding
+ source archive. A missing source repository or license file fails the
+ release instead of publishing only the executable.
When validating packaged updater output, confirm the platform build writes
`latest*.yml` and `*.blockmap` files under `release/`.
5. Commit the prerelease prep (package.json version bump + the generated
@@ -97,6 +110,7 @@ Notes:
- AUR publish is best-effort: the workflow retries transient SSH clone/push failures, then warns and leaves the GitHub Release green if AUR still fails. Follow up with a manual `git push aur master` from the AUR checkout when needed.
- Required GitHub Actions secret: `AUR_SSH_PRIVATE_KEY`. Add the matching public key to your AUR account before relying on the automation.
- Release and prerelease workflows upload updater metadata (`latest*.yml`) and blockmaps (`*.blockmap`) alongside platform artifacts. Do not remove those files while `electron-updater` is enabled.
+- Release and prerelease workflows publish `subminer` for POSIX systems and `subminer.cmd` for Windows. Both locate a packaged app and use its private Bun runtime. Keep the corresponding-source archive named `bun-v1.3.5-source.tar.gz`.
- macOS tray app updates use the standard `electron-updater`/Squirrel path. Keep `latest-mac.yml`, the macOS `SubMiner--mac.zip`, and ZIP blockmap published; Squirrel uses the ZIP payload even when the DMG remains the user-facing installer.
- macOS update metadata and full ZIP downloads are routed through `/usr/bin/curl` before Squirrel installation to avoid Electron main-process network crashes on update checks.
- Windows tray app updates use the standard `electron-updater`/NSIS path. Keep `latest.yml`, the Windows NSIS installer, and installer blockmap published; updater HTTP is routed through main-process fetch to avoid Electron main-process network crashes during update checks.
diff --git a/docs/architecture/README.md b/docs/architecture/README.md
index 02bd40a2..79565cf9 100644
--- a/docs/architecture/README.md
+++ b/docs/architecture/README.md
@@ -10,11 +10,15 @@ Read when: runtime ownership, composition boundaries, or layering questions
SubMiner runs as three cooperating runtimes:
- Electron desktop app in `src/`
-- Launcher CLI in `launcher/`
+- Launcher CLI in `launcher/`, with managed app-installed wrappers in `src/main/runtime/managed-launcher.ts`
- mpv Lua plugin in `plugin/subminer/`
The desktop app keeps `src/main.ts` as composition root and pushes behavior into small runtime/domain modules.
+Packaged apps include a private Bun runtime. Setup and release assets provide bootstrap wrappers generated from `src/main/runtime/*-launcher-bootstrap.ts`. macOS runs Bun and the CLI from app resources. Windows stages a versioned private Bun copy under `%LOCALAPPDATA%\SubMiner\launcher-runtime/` so a running launcher does not lock the updater-owned app executable. Linux stages Bun, the matching CLI, and licenses under `${XDG_DATA_HOME:-~/.local/share}/SubMiner/launcher`. Its steady-state path performs one app `stat` and starts the cache without Electron. A missing cache or changed app fingerprint runs `launcher/prepare.cjs` through Electron's Node mode to refresh it. Desktop startup migrates recognized writable legacy JavaScript launchers and refreshes managed payloads after app changes. Development commands still use system Bun.
+
+Update checks and startup launcher migration share a serialized update-state store. Deferred launcher paths are acknowledged only after migration succeeds or the candidate is no longer eligible. Running Windows launchers and unreadable or unwritable candidates remain pending for a later startup.
+
## Read Next
- [Domains](./domains.md) - who owns what
diff --git a/docs/architecture/layering.md b/docs/architecture/layering.md
index ef7e1440..794f3c3e 100644
--- a/docs/architecture/layering.md
+++ b/docs/architecture/layering.md
@@ -23,7 +23,7 @@ Renderer, launcher, plugin, and stats each keep their own local layering and sho
- Keep side effects explicit and close to composition boundaries.
- Put reusable business logic in focused services, not in top-level lifecycle files.
- Keep renderer concerns in `src/renderer/`; avoid leaking DOM behavior into main-process code.
-- Treat `launcher/*.ts` as source of truth for the launcher. Never hand-edit `dist/launcher/subminer`.
+- Treat `launcher/*.ts` and the runtime bootstrap generators as source of truth for launcher behavior. `scripts/build-launcher.ts` creates `dist/launcher`; never hand-edit those artifacts.
## Smells
diff --git a/launcher/commands/update-command.test.ts b/launcher/commands/update-command.test.ts
index da7ce1d6..8f358e69 100644
--- a/launcher/commands/update-command.test.ts
+++ b/launcher/commands/update-command.test.ts
@@ -1,5 +1,9 @@
import test from 'node:test';
import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
import { runUpdateCommand } from './update-command';
import type { LauncherCommandContext } from './context';
@@ -62,6 +66,24 @@ test('runUpdateCommand updates directly on Linux without launching Electron', as
]);
});
+test('runUpdateCommand sends symlinked AUR installs to the package helper without network access', async () => {
+ const calls: string[] = [];
+ const handled = await runUpdateCommand(makeContext({ appPath: '/usr/bin/SubMiner.AppImage' }), {
+ resolveRealPath: () => '/opt/SubMiner/SubMiner.AppImage',
+ runDirectReleaseUpdate: async () => {
+ throw new Error('must not check GitHub releases for an AUR install');
+ },
+ log: (level, _configured, message) => {
+ calls.push(`${level}:${message}`);
+ },
+ });
+
+ assert.equal(handled, true);
+ assert.deepEqual(calls, [
+ 'warn:SubMiner is installed through subminer-bin. Update it with your AUR helper, for example: yay -S subminer-bin.',
+ ]);
+});
+
test('runUpdateCommand skips Linux asset replacement when release is not newer', async () => {
const calls: string[] = [];
const originalFetch = globalThis.fetch;
@@ -118,6 +140,65 @@ test('runUpdateCommand skips Linux asset replacement when release is not newer',
}
});
+test('Linux update does not replace the launcher after an AppImage hash failure', async () => {
+ const workspace = fs.mkdtempSync(path.join(os.tmpdir(), 'subminer-update-order-'));
+ const appImagePath = path.join(workspace, 'SubMiner.AppImage');
+ const launcherPath = path.join(workspace, 'subminer');
+ fs.writeFileSync(appImagePath, 'old app');
+ fs.writeFileSync(launcherPath, '#!/bin/sh\n# SubMiner launcher\n');
+
+ const fetched: string[] = [];
+ const originalFetch = globalThis.fetch;
+ globalThis.fetch = (async (input: string | URL | Request) => {
+ const url = input instanceof Request ? input.url : String(input);
+ fetched.push(url);
+ if (url.endsWith('/releases')) {
+ return Response.json([
+ {
+ tag_name: 'v999.0.0',
+ prerelease: false,
+ draft: false,
+ assets: [
+ {
+ name: 'SHA256SUMS.txt',
+ browser_download_url: 'https://example.test/SHA256SUMS.txt',
+ },
+ {
+ name: 'SubMiner.AppImage',
+ browser_download_url: 'https://example.test/SubMiner.AppImage',
+ },
+ { name: 'subminer', browser_download_url: 'https://example.test/subminer' },
+ ],
+ },
+ ]);
+ }
+ if (url.endsWith('/SHA256SUMS.txt')) {
+ return new Response(
+ `${createHash('sha256').update('expected app').digest('hex')} SubMiner.AppImage\n${createHash('sha256').update('new launcher').digest('hex')} subminer\n`,
+ );
+ }
+ if (url.endsWith('/SubMiner.AppImage')) {
+ return new Response('corrupt app');
+ }
+ throw new Error(`launcher asset should not be fetched: ${url}`);
+ }) as typeof globalThis.fetch;
+
+ try {
+ const handled = await runUpdateCommand(
+ makeContext({ appPath: appImagePath, scriptPath: launcherPath }),
+ { readMainConfig: () => null, log: () => {} },
+ );
+
+ assert.equal(handled, true);
+ assert.equal(fs.readFileSync(appImagePath, 'utf8'), 'old app');
+ assert.equal(fs.readFileSync(launcherPath, 'utf8'), '#!/bin/sh\n# SubMiner launcher\n');
+ assert.equal(fetched.includes('https://example.test/subminer'), false);
+ } finally {
+ globalThis.fetch = originalFetch;
+ fs.rmSync(workspace, { recursive: true, force: true });
+ }
+});
+
test('runUpdateCommand keeps app-mediated update path on non-Linux', async () => {
const calls: string[] = [];
@@ -148,3 +229,32 @@ test('runUpdateCommand keeps app-mediated update path on non-Linux', async () =>
'remove:/tmp/subminer-update-test',
]);
});
+
+test('managed launcher passes its wrapper to app updates, protecting signed resources', async () => {
+ const previous = process.env.SUBMINER_LAUNCHER_PATH;
+ process.env.SUBMINER_LAUNCHER_PATH = '/Users/tester/.local/bin/subminer';
+ try {
+ let forwarded: string[] = [];
+ await runUpdateCommand(
+ makeContext({
+ processAdapter: { ...makeContext().processAdapter, platform: () => 'darwin' },
+ scriptPath: '/Applications/SubMiner.app/Contents/Resources/launcher/subminer',
+ appPath: '/Applications/SubMiner.app/Contents/MacOS/SubMiner',
+ }),
+ {
+ createTempDir: () => '/tmp/subminer-update-test',
+ joinPath: (...parts) => parts.join('/'),
+ runAppCommandCaptureOutput: (_app, args) => {
+ forwarded = args;
+ return { status: 0, stdout: '', stderr: '' };
+ },
+ waitForUpdateResponse: async () => ({ ok: true }),
+ removeDir: () => {},
+ },
+ );
+ assert.equal(forwarded[2], '/Users/tester/.local/bin/subminer');
+ } finally {
+ if (previous === undefined) delete process.env.SUBMINER_LAUNCHER_PATH;
+ else process.env.SUBMINER_LAUNCHER_PATH = previous;
+ }
+});
diff --git a/launcher/commands/update-command.ts b/launcher/commands/update-command.ts
index 0b0a88be..5fbf6c46 100644
--- a/launcher/commands/update-command.ts
+++ b/launcher/commands/update-command.ts
@@ -58,6 +58,7 @@ type UpdateCommandDeps = {
) => { status: number; stdout: string; stderr: string; error?: Error };
waitForUpdateResponse: (responsePath: string) => Promise;
removeDir: (targetPath: string) => void;
+ resolveRealPath: (targetPath: string) => string;
runDirectReleaseUpdate: (
request: DirectReleaseUpdateRequest,
) => Promise;
@@ -98,25 +99,36 @@ async function runDirectReleaseUpdate(
: new Map();
const downloadAsset = (url: string) => fetchReleaseAssetBuffer(fetchForUpdater, url);
- const [appImage, launcher, supportAssets] = await Promise.all([
- updateAppImageFromRelease({
- release,
- sha256Sums,
- appImagePath: request.appPath,
- downloadAsset,
- }),
- updateLauncherFromRelease({
+ const appImage = await updateAppImageFromRelease({
+ release,
+ sha256Sums,
+ appImagePath: request.appPath,
+ downloadAsset,
+ });
+ let launcher: DirectReleaseUpdateResult['launcher'];
+ if (appImage.status !== 'updated') {
+ launcher = {
+ status: 'skipped',
+ message: 'Launcher update requires a successful AppImage update first.',
+ };
+ } else if (process.env.SUBMINER_MANAGED_LAUNCHER === '1') {
+ launcher = {
+ status: 'skipped',
+ message: 'This launcher is updated with the SubMiner app.',
+ };
+ } else {
+ launcher = await updateLauncherFromRelease({
release,
sha256Sums,
launcherPath: request.launcherPath,
downloadAsset,
- }),
- updateSupportAssetsFromRelease({
- release,
- sha256Sums,
- downloadAsset,
- }),
- ]);
+ });
+ }
+ const supportAssets = await updateSupportAssetsFromRelease({
+ release,
+ sha256Sums,
+ downloadAsset,
+ });
return { appImage, launcher, supportAssets };
}
@@ -173,6 +185,13 @@ const defaultDeps: UpdateCommandDeps = {
removeDir: (targetPath) => {
fs.rmSync(targetPath, { recursive: true, force: true });
},
+ resolveRealPath: (targetPath) => {
+ try {
+ return fs.realpathSync(targetPath);
+ } catch {
+ return targetPath;
+ }
+ },
runDirectReleaseUpdate,
readMainConfig: readLauncherMainConfigObject,
log: launcherLog,
@@ -189,12 +208,20 @@ export async function runUpdateCommand(
}
if (context.processAdapter.platform() === 'linux') {
+ const logLevel = args.logLevel ?? 'warn';
+ if (resolvedDeps.resolveRealPath(appPath) === '/opt/SubMiner/SubMiner.AppImage') {
+ resolvedDeps.log(
+ 'warn',
+ logLevel,
+ 'SubMiner is installed through subminer-bin. Update it with your AUR helper, for example: yay -S subminer-bin.',
+ );
+ return true;
+ }
const result = await resolvedDeps.runDirectReleaseUpdate({
appPath,
launcherPath: scriptPath,
channel: readUpdateChannel(resolvedDeps.readMainConfig()),
});
- const logLevel = args.logLevel ?? 'warn';
logUpdateResult('AppImage', result.appImage, logLevel, resolvedDeps);
logUpdateResult('Launcher', result.launcher, logLevel, resolvedDeps);
for (const supportResult of result.supportAssets) {
@@ -203,6 +230,7 @@ export async function runUpdateCommand(
return true;
}
+ const launcherPath = path.resolve(process.env.SUBMINER_LAUNCHER_PATH ?? scriptPath);
const tempDir = resolvedDeps.createTempDir('subminer-update-');
const responsePath = resolvedDeps.joinPath(tempDir, 'response.json');
@@ -210,7 +238,7 @@ export async function runUpdateCommand(
const result = resolvedDeps.runAppCommandCaptureOutput(appPath, [
'--update',
'--update-launcher-path',
- scriptPath,
+ launcherPath,
'--update-response-path',
responsePath,
]);
diff --git a/package.json b/package.json
index 1b67f725..e8e8e159 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"compare-yomitan-api:electron": "bun run build:yomitan && bun build scripts/compare-yomitan-api.ts --format=cjs --target=node --outfile dist/scripts/compare-yomitan-api.js --external electron && env -u ELECTRON_RUN_AS_NODE electron dist/scripts/compare-yomitan-api.js",
"build:yomitan": "bun scripts/build-yomitan.mjs",
"build:assets": "bun scripts/prepare-build-assets.mjs",
- "build:launcher": "bun build ./launcher/main.ts --target=bun --packages=bundle --banner='#!/usr/bin/env bun' --outfile=dist/launcher/subminer",
+ "build:launcher": "bun run scripts/build-launcher.ts",
"build:stats": "cd stats && bun run build",
"dev:stats": "cd stats && bun run dev",
"build": "bun run build:yomitan && bun run build:stats && tsc -p tsconfig.json && bun run build:renderer && bun run build:settings && bun run build:syncui && bun run build:launcher && bun run build:assets",
@@ -259,8 +259,15 @@
"to": "plugin/subminer.conf"
},
{
- "from": "dist/launcher/subminer",
- "to": "launcher/subminer"
+ "from": "dist/launcher",
+ "to": "launcher",
+ "filter": [
+ "subminer",
+ "subminer.cmd",
+ "subminer.js",
+ "prepare.cjs",
+ "version"
+ ]
},
{
"from": "CHANGELOG.md",
diff --git a/packaging/aur/subminer-bin/.SRCINFO b/packaging/aur/subminer-bin/.SRCINFO
index 5f734785..cb84fc25 100644
--- a/packaging/aur/subminer-bin/.SRCINFO
+++ b/packaging/aur/subminer-bin/.SRCINFO
@@ -5,7 +5,11 @@ pkgbase = subminer-bin
url = https://github.com/ksyasuda/SubMiner
arch = x86_64
license = GPL-3.0-or-later
- depends = bun
+ license = MIT
+ license = LGPL-2.0-only
+ license = LGPL-2.1-only
+ license = Apache-2.0
+ license = BSD-3-Clause
depends = fuse2
depends = glibc
depends = mpv
diff --git a/packaging/aur/subminer-bin/PKGBUILD b/packaging/aur/subminer-bin/PKGBUILD
index cbe87dd1..99ef6aec 100644
--- a/packaging/aur/subminer-bin/PKGBUILD
+++ b/packaging/aur/subminer-bin/PKGBUILD
@@ -6,10 +6,9 @@ pkgrel=1
pkgdesc='All-in-one sentence mining overlay with AnkiConnect and dictionary integration'
arch=('x86_64')
url='https://github.com/ksyasuda/SubMiner'
-license=('GPL-3.0-or-later')
+license=('GPL-3.0-or-later' 'MIT' 'LGPL-2.0-only' 'LGPL-2.1-only' 'Apache-2.0' 'BSD-3-Clause')
options=('!strip' '!debug')
depends=(
- 'bun'
'fuse2'
'glibc'
'mpv'
@@ -63,4 +62,9 @@ package() {
install -dm755 "${pkgdir}/usr/share/SubMiner/plugin/subminer"
cp -a "${srcdir}/plugin/subminer/." "${pkgdir}/usr/share/SubMiner/plugin/subminer/"
+
+ # Bundled Bun runtime notices: MIT and BSD texts are not in the licenses package.
+ install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 "${srcdir}"/resources/bun/licenses/* \
+ "${pkgdir}/usr/share/licenses/${pkgname}/"
}
diff --git a/release/prerelease-notes.md b/release/prerelease-notes.md
index ae7c87f0..6549b5cc 100644
--- a/release/prerelease-notes.md
+++ b/release/prerelease-notes.md
@@ -73,6 +73,9 @@ See the README and docs/installation guide for full setup steps.
- Linux: `SubMiner.AppImage`
- macOS: `SubMiner-*.dmg` and `SubMiner-*.zip`
- Windows: `SubMiner-*.exe` and `SubMiner-*-win.zip`
-- Optional extras: `subminer-assets.tar.gz` and the `subminer` launcher
+- Optional extras: `subminer-assets.tar.gz`, the `subminer` launcher, and the Windows `subminer.cmd` launcher
+- Bun corresponding source: `bun-v1.3.5-source.tar.gz` and its `.sha256` file
-Note: the `subminer` wrapper script uses Bun (`#!/usr/bin/env bun`), so `bun` must be installed and on `PATH`.
+Both launcher downloads use Bun included with the SubMiner app. Download `subminer` on Linux or macOS and `subminer.cmd` on Windows.
+
+The app bundles an unmodified Bun 1.3.5 runtime. Bun is MIT licensed and statically links JavaScriptCore (LGPL 2.0) and TinyCC (LGPL 2.1). License texts and third-party notices ship inside the app under `resources/bun/licenses`, and the source archive above contains the matching Bun, WebKit, and dependency sources for relinking.
diff --git a/release/release-notes.md b/release/release-notes.md
index 7c30bba3..f2b75bc3 100644
--- a/release/release-notes.md
+++ b/release/release-notes.md
@@ -46,6 +46,9 @@ See the README and docs/installation guide for full setup steps.
- Linux: `SubMiner.AppImage`
- macOS: `SubMiner-*.dmg` and `SubMiner-*.zip`
- Windows: `SubMiner-*.exe` and `SubMiner-*-win.zip`
-- Optional extras: `subminer-assets.tar.gz` and the `subminer` launcher
+- Optional extras: `subminer-assets.tar.gz`, the `subminer` launcher, and the Windows `subminer.cmd` launcher
+- Bun corresponding source: `bun-v1.3.5-source.tar.gz` and its `.sha256` file
-Note: the `subminer` wrapper script uses Bun (`#!/usr/bin/env bun`), so `bun` must be installed and on `PATH`.
+Both launcher downloads use Bun included with the SubMiner app. Download `subminer` on Linux or macOS and `subminer.cmd` on Windows.
+
+The app bundles an unmodified Bun 1.3.5 runtime. Bun is MIT licensed and statically links JavaScriptCore (LGPL 2.0) and TinyCC (LGPL 2.1). License texts and third-party notices ship inside the app under `resources/bun/licenses`, and the source archive above contains the matching Bun, WebKit, and dependency sources for relinking.
diff --git a/resources/bun/licenses/Bun-LICENSE.md b/resources/bun/licenses/Bun-LICENSE.md
new file mode 100644
index 00000000..df8d965c
--- /dev/null
+++ b/resources/bun/licenses/Bun-LICENSE.md
@@ -0,0 +1,73 @@
+Bun itself is MIT-licensed.
+
+## JavaScriptCore
+
+Bun statically links JavaScriptCore (and WebKit) which is LGPL-2 licensed. WebCore files from WebKit are also licensed under LGPL2. Per LGPL2:
+
+> (1) If you statically link against an LGPL’d library, you must also provide your application in an object (not necessarily source) format, so that a user has the opportunity to modify the library and relink the application.
+
+You can find the patched version of WebKit used by Bun here: . If you would like to relink Bun with changes:
+
+- `git submodule update --init --recursive`
+- `make jsc`
+- `zig build`
+
+This compiles JavaScriptCore, compiles Bun’s `.cpp` bindings for JavaScriptCore (which are the object files using JavaScriptCore) and outputs a new `bun` binary with your changes.
+
+## Linked libraries
+
+Bun statically links these libraries:
+
+| Library | License |
+|---------|---------|
+| [`boringssl`](https://boringssl.googlesource.com/boringssl/) | [several licenses](https://boringssl.googlesource.com/boringssl/+/refs/heads/master/LICENSE) |
+| [`brotli`](https://github.com/google/brotli) | MIT |
+| [`libarchive`](https://github.com/libarchive/libarchive) | [several licenses](https://github.com/libarchive/libarchive/blob/master/COPYING) |
+| [`lol-html`](https://github.com/cloudflare/lol-html/tree/master/c-api) | BSD 3-Clause |
+| [`mimalloc`](https://github.com/microsoft/mimalloc) | MIT |
+| [`picohttp`](https://github.com/h2o/picohttpparser) | dual-licensed under the Perl License or the MIT License |
+| [`zstd`](https://github.com/facebook/zstd) | dual-licensed under the BSD License or GPLv2 license |
+| [`simdutf`](https://github.com/simdutf/simdutf) | Apache 2.0 |
+| [`tinycc`](https://github.com/tinycc/tinycc) | LGPL v2.1 |
+| [`uSockets`](https://github.com/uNetworking/uSockets) | Apache 2.0 |
+| [`zlib-cloudflare`](https://github.com/cloudflare/zlib) | zlib |
+| [`c-ares`](https://github.com/c-ares/c-ares) | MIT licensed |
+| [`libicu`](https://github.com/unicode-org/icu) 72 | [license here](https://github.com/unicode-org/icu/blob/main/icu4c/LICENSE) |
+| [`libbase64`](https://github.com/aklomp/base64/blob/master/LICENSE) | BSD 2-Clause |
+| [`libuv`](https://github.com/libuv/libuv) (on Windows) | MIT |
+| [`libdeflate`](https://github.com/ebiggers/libdeflate) | MIT |
+| A fork of [`uWebsockets`](https://github.com/jarred-sumner/uwebsockets) | Apache 2.0 licensed |
+| Parts of [Tigerbeetle's IO code](https://github.com/tigerbeetle/tigerbeetle/blob/532c8b70b9142c17e07737ab6d3da68d7500cbca/src/io/windows.zig#L1) | Apache 2.0 licensed |
+
+## Polyfills
+
+For compatibility reasons, the following packages are embedded into Bun's binary and injected if imported.
+
+| Package | License |
+|---------|---------|
+| [`assert`](https://npmjs.com/package/assert) | MIT |
+| [`browserify-zlib`](https://npmjs.com/package/browserify-zlib) | MIT |
+| [`buffer`](https://npmjs.com/package/buffer) | MIT |
+| [`constants-browserify`](https://npmjs.com/package/constants-browserify) | MIT |
+| [`crypto-browserify`](https://npmjs.com/package/crypto-browserify) | MIT |
+| [`domain-browser`](https://npmjs.com/package/domain-browser) | MIT |
+| [`events`](https://npmjs.com/package/events) | MIT |
+| [`https-browserify`](https://npmjs.com/package/https-browserify) | MIT |
+| [`os-browserify`](https://npmjs.com/package/os-browserify) | MIT |
+| [`path-browserify`](https://npmjs.com/package/path-browserify) | MIT |
+| [`process`](https://npmjs.com/package/process) | MIT |
+| [`punycode`](https://npmjs.com/package/punycode) | MIT |
+| [`querystring-es3`](https://npmjs.com/package/querystring-es3) | MIT |
+| [`stream-browserify`](https://npmjs.com/package/stream-browserify) | MIT |
+| [`stream-http`](https://npmjs.com/package/stream-http) | MIT |
+| [`string_decoder`](https://npmjs.com/package/string_decoder) | MIT |
+| [`timers-browserify`](https://npmjs.com/package/timers-browserify) | MIT |
+| [`tty-browserify`](https://npmjs.com/package/tty-browserify) | MIT |
+| [`url`](https://npmjs.com/package/url) | MIT |
+| [`util`](https://npmjs.com/package/util) | MIT |
+| [`vm-browserify`](https://npmjs.com/package/vm-browserify) | MIT |
+
+## Additional credits
+
+- Bun's JS transpiler, CSS lexer, and Node.js module resolver source code is a Zig port of [@evanw](https://github.com/evanw)’s [esbuild](https://github.com/evanw/esbuild) project.
+- Credit to [@kipply](https://github.com/kipply) for the name "Bun"!
diff --git a/resources/bun/licenses/LGPL-2.0.txt b/resources/bun/licenses/LGPL-2.0.txt
new file mode 100644
index 00000000..87c4a33d
--- /dev/null
+++ b/resources/bun/licenses/LGPL-2.0.txt
@@ -0,0 +1,488 @@
+
+
+NOTE! The LGPL below is copyrighted by the Free Software Foundation, but
+the instance of code that it refers to (the kde libraries) are copyrighted
+by the authors who actually wrote it.
+
+---------------------------------------------------------------------------
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor
+ Boston, MA 02110-1301, USA.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/resources/bun/licenses/LGPL-2.1.txt b/resources/bun/licenses/LGPL-2.1.txt
new file mode 100644
index 00000000..223ede7d
--- /dev/null
+++ b/resources/bun/licenses/LGPL-2.1.txt
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/resources/bun/licenses/SOURCE.md b/resources/bun/licenses/SOURCE.md
new file mode 100644
index 00000000..8fa0a336
--- /dev/null
+++ b/resources/bun/licenses/SOURCE.md
@@ -0,0 +1,19 @@
+# Bun 1.3.5 source and relinking materials
+
+SubMiner redistributes unmodified Bun 1.3.5 executables from the official Bun release. The executables report revision `1e86cebd74a5723e818b5c0555276b646bcf0e4c` through `bun --revision`. Bun's `bun-v1.3.5` Git tag points to the next commit, `fa5a5bbe556a4bda5bde77b4013aa6c3bb4ec9ab`, so the tag archive does not exactly match the distributed executables.
+
+The SubMiner GitHub release containing this application also contains `bun-v1.3.5-source.tar.gz` and its `.sha256` file. The archive contains:
+
+- Bun source at the binary's reported revision
+- WebKit and JavaScriptCore source at `6d0f3aac0b817cc01a846b3754b21271adedac12`
+- TinyCC source at `29985a3b59898861442fa3b43f663fc1af2591d7`
+- every external source repository registered by that Bun revision's CMake build, at its exact commit
+- Bun's dependency patches, build scripts, lockfiles, collected third-party license files, and instructions for rebuilding Bun against a modified JavaScriptCore
+
+The machine-readable inventory lives at `SOURCE-INVENTORY.json` inside the source archive and at `build/bun-source-manifest.json` in SubMiner's source repository.
+
+The archive vendors the source repositories linked through Bun's CMake build. It preserves Bun's package-manager lockfiles and lol-html's `Cargo.lock`, but it does not vendor npm packages, crates.io packages, compilers, SDKs, or other build tools. Rebuilding needs network access for those package-manager and toolchain inputs. The archive's rebuild README records the known tool versions and the remaining unpinned Rust nightly input.
+
+Bun's own license overview is included as `Bun-LICENSE.md`. WebKit's JavaScriptCore copy of GNU Library General Public License version 2 is included as `LGPL-2.0.txt`. TinyCC's GNU Lesser General Public License version 2.1 is included as `LGPL-2.1.txt`. `THIRD-PARTY-NOTICES.md` collects license texts from Bun's other externally fetched linked dependencies and identifies the scope of the remaining per-file notices in the source archive.
+
+This notice describes the materials supplied with the release. It is not a legal-compliance or reproducible-build claim.
diff --git a/resources/bun/licenses/THIRD-PARTY-NOTICES.md b/resources/bun/licenses/THIRD-PARTY-NOTICES.md
new file mode 100644
index 00000000..d4a64575
--- /dev/null
+++ b/resources/bun/licenses/THIRD-PARTY-NOTICES.md
@@ -0,0 +1,2011 @@
+# Bun 1.3.5 third-party notices
+
+This file collects the license texts shipped by the external source repositories used by Bun 1.3.5 at the revisions in build/bun-source-manifest.json. The corresponding-source release asset also preserves license notices embedded in individual Bun and WebKit source files. Bun’s own LICENSE.md lists additional embedded libraries and JavaScript polyfills whose source and per-file notices are included in that asset.
+
+## BoringSSL
+
+Source revision: f1ffd9e83d4f5c28a9c70d73f9a4e6fcf310062f
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+Licenses for support code
+-------------------------
+
+Parts of the TLS test suite are under the Go license. This code is not included
+in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so
+distributing code linked against BoringSSL does not trigger this license:
+
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+The Apache License, Version 2.0 (Apache-2.0)
+
+Copyright 2015-2020 the fiat-crypto authors (see the AUTHORS file)
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+Copyright 2008, Google Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+## Brotli
+
+Source revision: ed738e842d2fbdf2d6459e39267a633c4a9b2f5d
+
+Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+## c-ares
+
+Source revision: 3ac47ee46edd8ea40370222f91613fc16c434853
+
+MIT License
+
+Copyright (c) 1998 Massachusetts Institute of Technology
+Copyright (c) 2007 - 2023 Daniel Stenberg with many contributors, see AUTHORS
+file.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+## HdrHistogram-CC0
+
+Source revision: be60a9987ee48d0abf0d7b6a175bad8d6c1585d1
+
+Creative Commons Legal Code
+
+CC0 1.0 Universal
+
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
+ HEREUNDER.
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator
+and subsequent owner(s) (each and all, an "owner") of an original work of
+authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for
+the purpose of contributing to a commons of creative, cultural and
+scientific works ("Commons") that the public can reliably and without fear
+of later claims of infringement build upon, modify, incorporate in other
+works, reuse and redistribute as freely as possible in any form whatsoever
+and for any purposes, including without limitation commercial purposes.
+These owners may contribute to the Commons to promote the ideal of a free
+culture and the further production of creative, cultural and scientific
+works, or to gain reputation or greater distribution for their Work in
+part through the use and efforts of others.
+
+For these and/or other purposes and motivations, and without any
+expectation of additional consideration or compensation, the person
+associating CC0 with a Work (the "Affirmer"), to the extent that he or she
+is an owner of Copyright and Related Rights in the Work, voluntarily
+elects to apply CC0 to the Work and publicly distribute the Work under its
+terms, with knowledge of his or her Copyright and Related Rights in the
+Work and the meaning and intended legal effect of CC0 on those rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be
+protected by copyright and related or neighboring rights ("Copyright and
+Related Rights"). Copyright and Related Rights include, but are not
+limited to, the following:
+
+ i. the right to reproduce, adapt, distribute, perform, display,
+ communicate, and translate a Work;
+ ii. moral rights retained by the original author(s) and/or performer(s);
+iii. publicity and privacy rights pertaining to a person's image or
+ likeness depicted in a Work;
+ iv. rights protecting against unfair competition in regards to a Work,
+ subject to the limitations in paragraph 4(a), below;
+ v. rights protecting the extraction, dissemination, use and reuse of data
+ in a Work;
+ vi. database rights (such as those arising under Directive 96/9/EC of the
+ European Parliament and of the Council of 11 March 1996 on the legal
+ protection of databases, and under any national implementation
+ thereof, including any amended or successor version of such
+ directive); and
+vii. other similar, equivalent or corresponding rights throughout the
+ world based on applicable law or treaty, and any national
+ implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention
+of, applicable law, Affirmer hereby overtly, fully, permanently,
+irrevocably and unconditionally waives, abandons, and surrenders all of
+Affirmer's Copyright and Related Rights and associated claims and causes
+of action, whether now known or unknown (including existing as well as
+future claims and causes of action), in the Work (i) in all territories
+worldwide, (ii) for the maximum duration provided by applicable law or
+treaty (including future time extensions), (iii) in any current or future
+medium and for any number of copies, and (iv) for any purpose whatsoever,
+including without limitation commercial, advertising or promotional
+purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
+member of the public at large and to the detriment of Affirmer's heirs and
+successors, fully intending that such Waiver shall not be subject to
+revocation, rescission, cancellation, termination, or any other legal or
+equitable action to disrupt the quiet enjoyment of the Work by the public
+as contemplated by Affirmer's express Statement of Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason
+be judged legally invalid or ineffective under applicable law, then the
+Waiver shall be preserved to the maximum extent permitted taking into
+account Affirmer's express Statement of Purpose. In addition, to the
+extent the Waiver is so judged Affirmer hereby grants to each affected
+person a royalty-free, non transferable, non sublicensable, non exclusive,
+irrevocable and unconditional license to exercise Affirmer's Copyright and
+Related Rights in the Work (i) in all territories worldwide, (ii) for the
+maximum duration provided by applicable law or treaty (including future
+time extensions), (iii) in any current or future medium and for any number
+of copies, and (iv) for any purpose whatsoever, including without
+limitation commercial, advertising or promotional purposes (the
+"License"). The License shall be deemed effective as of the date CC0 was
+applied by Affirmer to the Work. Should any part of the License for any
+reason be judged legally invalid or ineffective under applicable law, such
+partial invalidity or ineffectiveness shall not invalidate the remainder
+of the License, and in such case Affirmer hereby affirms that he or she
+will not (i) exercise any of his or her remaining Copyright and Related
+Rights in the Work or (ii) assert any associated claims and causes of
+action with respect to the Work, in either case contrary to Affirmer's
+express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
+ surrendered, licensed or otherwise affected by this document.
+ b. Affirmer offers the Work as-is and makes no representations or
+ warranties of any kind concerning the Work, express, implied,
+ statutory or otherwise, including without limitation warranties of
+ title, merchantability, fitness for a particular purpose, non
+ infringement, or the absence of latent or other defects, accuracy, or
+ the present or absence of errors, whether or not discoverable, all to
+ the greatest extent permissible under applicable law.
+ c. Affirmer disclaims responsibility for clearing rights of other persons
+ that may apply to the Work or any use thereof, including without
+ limitation any person's Copyright and Related Rights in the Work.
+ Further, Affirmer disclaims responsibility for obtaining any necessary
+ consents, permissions or other rights required for any use of the
+ Work.
+ d. Affirmer understands and acknowledges that Creative Commons is not a
+ party to this document and has no duty or obligation with respect to
+ this CC0 or use of the Work.
+
+## HdrHistogram-BSD-2-Clause
+
+Source revision: be60a9987ee48d0abf0d7b6a175bad8d6c1585d1
+
+The code in this repository code was Written by Gil Tene, Michael Barker,
+Matt Warren, and Philip Orwig, and released to the public domain, as explained at
+http://creativecommons.org/publicdomain/zero/1.0/
+
+For users of this code who wish to consume it under the "BSD" license
+rather than under the public domain or CC0 contribution text mentioned
+above, the code found under this directory is *also* provided under the
+following license (commonly referred to as the BSD 2-Clause License). This
+license does not detract from the above stated release of the code into
+the public domain, and simply represents an additional license granted by
+the Author.
+
+-----------------------------------------------------------------------------
+** Beginning of "BSD 2-Clause License" text. **
+
+ Copyright (c) 2012, 2013, 2014 Gil Tene
+ Copyright (c) 2014 Michael Barker
+ Copyright (c) 2014 Matt Warren
+ Copyright (c) 2015 Philip Orwig
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
+
+## Highway
+
+Source revision: ac0d5d297b13ab1b89f48484fc7911082d76a93f
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+## libarchive
+
+Source revision: 9525f90ca4bd14c7b335e2f8c84a4607b0af6bdf
+
+The libarchive distribution as a whole is Copyright by Tim Kientzle
+and is subject to the copyright notice reproduced at the bottom of
+this file.
+
+Each individual file in this distribution should have a clear
+copyright/licensing statement at the beginning of the file. If any do
+not, please let me know and I will rectify it. The following is
+intended to summarize the copyright status of the individual files;
+the actual statements in the files are controlling.
+
+* Except as listed below, all C sources (including .c and .h files)
+ and documentation files are subject to the copyright notice reproduced
+ at the bottom of this file.
+
+* The following source files are also subject in whole or in part to
+ a 3-clause UC Regents copyright; please read the individual source
+ files for details:
+ libarchive/archive_read_support_filter_compress.c
+ libarchive/archive_write_add_filter_compress.c
+ libarchive/mtree.5
+
+* The following source files are in the public domain:
+ libarchive/archive_parse_date.c
+
+* The following source files are triple-licensed with the ability to choose
+ from CC0 1.0 Universal, OpenSSL or Apache 2.0 licenses:
+ libarchive/archive_blake2.h
+ libarchive/archive_blake2_impl.h
+ libarchive/archive_blake2s_ref.c
+ libarchive/archive_blake2sp_ref.c
+
+* The build files---including Makefiles, configure scripts,
+ and auxiliary scripts used as part of the compile process---have
+ widely varying licensing terms. Please check individual files before
+ distributing them to see if those restrictions apply to you.
+
+I intend for all new source code to use the license below and hope over
+time to replace code with other licenses with new implementations that
+do use the license below. The varying licensing of the build scripts
+seems to be an unavoidable mess.
+
+
+Copyright (c) 2003-2018
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer
+ in this position and unchanged.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+## libdeflate
+
+Source revision: c8c56a20f8f621e6a966b716b31f1dedab6a41e3
+
+Copyright 2016 Eric Biggers
+Copyright 2024 Google LLC
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation files
+(the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+## libuv
+
+Source revision: f3ce527ea940d926c40878ba5de219640c362811
+
+Copyright (c) 2015-present libuv project contributors.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
+
+## lol-html
+
+Source revision: d64457d9ff0143deef025d5df7e8586092b9afb7
+
+Copyright (C) 2019, Cloudflare, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+may be used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+## ls-hpack
+
+Source revision: 8905c024b6d052f083a3d11d0a169b3c2735c8a1
+
+MIT License
+
+Copyright (c) 2018 - 2023 LiteSpeed Technologies Inc
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+## mimalloc
+
+Source revision: 1beadf9651a7bfdec6b5367c380ecc3fe1c40d1a
+
+MIT License
+
+Copyright (c) 2018-2021 Microsoft Corporation, Daan Leijen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+## zlib
+
+Source revision: 886098f3f339617b4243b286f5ed364b9989e245
+
+Copyright notice:
+
+ (C) 1995-2022 Jean-loup Gailly and Mark Adler
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly Mark Adler
+ jloup@gzip.org madler@alumni.caltech.edu
+
+## zstd-BSD
+
+Source revision: f8745da6ff1ad1e7bab384bd1f9d742439278e99
+
+BSD License
+
+For Zstandard software
+
+Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name Facebook, nor Meta, nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+## zstd-GPLv2
+
+Source revision: f8745da6ff1ad1e7bab384bd1f9d742439278e99
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
+## picohttpparser
+
+Source revision: 066d2b1e9ab820703db0837a7255d92d30f0c9f5
+
+/*
+ * Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase,
+ * Shigeo Mitsunari
+ *
+ * The software is licensed under either the MIT License (below) or the Perl
+ * license.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+## Bun uSockets fork
+
+
+
+Source: Bun source tree at packages/bun-usockets
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+## Bun uWebSockets fork
+
+
+
+Source: Bun source tree at packages/bun-uws
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+## zig-clap
+
+
+
+Source: Bun source tree at src/deps/zig-clap
+
+
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
diff --git a/scripts/build-changelog.test.ts b/scripts/build-changelog.test.ts
index 764bbffd..cfb2ef06 100644
--- a/scripts/build-changelog.test.ts
+++ b/scripts/build-changelog.test.ts
@@ -620,6 +620,10 @@ test('writePrereleaseNotesForVersion writes cumulative beta notes without mutati
assert.match(prereleaseNotes, /## Highlights\n### Added\n- Polished: added entry\./);
assert.match(prereleaseNotes, /### Fixed\n- Polished: fixed entry\./);
assert.match(prereleaseNotes, /## Installation\n\nSee the README and docs\/installation guide/);
+ assert.match(prereleaseNotes, /Windows `subminer\.cmd` launcher/);
+ assert.match(prereleaseNotes, /Both launcher downloads use Bun included with the SubMiner app/);
+ assert.match(prereleaseNotes, /Bun corresponding source: `bun-v1\.3\.5-source\.tar\.gz`/);
+ assert.match(prereleaseNotes, /statically links JavaScriptCore \(LGPL 2\.0\)/);
} finally {
fs.rmSync(workspace, { recursive: true, force: true });
}
diff --git a/scripts/build-changelog.ts b/scripts/build-changelog.ts
index 2330e26d..01cf7227 100644
--- a/scripts/build-changelog.ts
+++ b/scripts/build-changelog.ts
@@ -977,9 +977,12 @@ function renderReleaseNotes(
'- Linux: `SubMiner.AppImage`',
'- macOS: `SubMiner-*.dmg` and `SubMiner-*.zip`',
'- Windows: `SubMiner-*.exe` and `SubMiner-*-win.zip`',
- '- Optional extras: `subminer-assets.tar.gz` and the `subminer` launcher',
+ '- Optional extras: `subminer-assets.tar.gz`, the `subminer` launcher, and the Windows `subminer.cmd` launcher',
+ '- Bun corresponding source: `bun-v1.3.5-source.tar.gz` and its `.sha256` file',
'',
- 'Note: the `subminer` wrapper script uses Bun (`#!/usr/bin/env bun`), so `bun` must be installed and on `PATH`.',
+ 'Both launcher downloads use Bun included with the SubMiner app. Download `subminer` on Linux or macOS and `subminer.cmd` on Windows.',
+ '',
+ 'The app bundles an unmodified Bun 1.3.5 runtime. Bun is MIT licensed and statically links JavaScriptCore (LGPL 2.0) and TinyCC (LGPL 2.1). License texts and third-party notices ship inside the app under `resources/bun/licenses`, and the source archive above contains the matching Bun, WebKit, and dependency sources for relinking.',
'',
].join('\n');
}
diff --git a/scripts/build-launcher.ts b/scripts/build-launcher.ts
new file mode 100644
index 00000000..ff868a85
--- /dev/null
+++ b/scripts/build-launcher.ts
@@ -0,0 +1,54 @@
+import fs from 'node:fs';
+import path from 'node:path';
+import { execFileSync } from 'node:child_process';
+import packageJson from '../package.json';
+import { posixLauncherBootstrapContent } from '../src/main/runtime/posix-launcher-bootstrap';
+import { windowsLauncherBootstrapContent } from '../src/main/runtime/windows-launcher-bootstrap';
+
+const outputDirectory = path.join(process.cwd(), 'dist', 'launcher');
+
+function bundle(options: {
+ entrypoint: string;
+ outfile: string;
+ target: 'bun' | 'node';
+ format?: 'cjs';
+ banner?: string;
+}): void {
+ const args = [
+ 'build',
+ options.entrypoint,
+ `--outfile=${options.outfile}`,
+ `--target=${options.target}`,
+ '--packages=bundle',
+ ];
+ if (options.format) args.push(`--format=${options.format}`);
+ if (options.banner) args.push(`--banner=${options.banner}`);
+ execFileSync(process.execPath, args, { stdio: 'inherit' });
+}
+
+fs.mkdirSync(outputDirectory, { recursive: true });
+
+bundle({
+ entrypoint: path.join(process.cwd(), 'launcher', 'main.ts'),
+ outfile: path.join(outputDirectory, 'subminer.js'),
+ target: 'bun',
+ banner: '#!/usr/bin/env bun',
+});
+bundle({
+ entrypoint: path.join(process.cwd(), 'src', 'main', 'runtime', 'prepare-launcher-runtime.ts'),
+ outfile: path.join(outputDirectory, 'prepare.cjs'),
+ target: 'node',
+ format: 'cjs',
+});
+
+const posixLauncherPath = path.join(outputDirectory, 'subminer');
+fs.writeFileSync(posixLauncherPath, posixLauncherBootstrapContent(), { mode: 0o755 });
+fs.chmodSync(posixLauncherPath, 0o755);
+fs.writeFileSync(
+ path.join(outputDirectory, 'subminer.cmd'),
+ windowsLauncherBootstrapContent(),
+ 'utf8',
+);
+fs.writeFileSync(path.join(outputDirectory, 'version'), `${packageJson.version}\n`, 'utf8');
+
+console.log(`Built launcher runtime artifacts in ${outputDirectory}`);
diff --git a/scripts/electron-builder-after-pack.cjs b/scripts/electron-builder-after-pack.cjs
index 4153f760..c73fe9e7 100644
--- a/scripts/electron-builder-after-pack.cjs
+++ b/scripts/electron-builder-after-pack.cjs
@@ -86,15 +86,32 @@ async function verifyMacOSWindowHelper(
return true;
}
-async function afterPack(context) {
+async function stageBundledBunRuntime(context, deps = {}) {
+ const stageBunRuntime =
+ deps.stageBunRuntime ?? (await import('./stage-bun-runtime.mjs')).stageBunRuntime;
+ const productFilename = context.packager?.appInfo?.productFilename;
+ await stageBunRuntime({
+ appOutDir: context.appOutDir,
+ platform: context.electronPlatformName,
+ arch: context.arch,
+ productFilename:
+ typeof productFilename === 'string' && productFilename.trim()
+ ? productFilename.trim()
+ : 'SubMiner',
+ });
+}
+
+async function afterPack(context, deps = {}) {
await stageLinuxAppImageSharedLibrary(context);
await verifyMacOSWindowHelper(context);
+ await stageBundledBunRuntime(context, deps);
}
module.exports = {
LINUX_FFMPEG_LIBRARY,
MACOS_WINDOW_HELPER,
resolveMacOSAppBundlePath,
+ stageBundledBunRuntime,
stageLinuxAppImageSharedLibrary,
verifyMacOSWindowHelper,
default: afterPack,
diff --git a/scripts/electron-builder-after-pack.test.ts b/scripts/electron-builder-after-pack.test.ts
index 5470b62c..0e9f36a5 100644
--- a/scripts/electron-builder-after-pack.test.ts
+++ b/scripts/electron-builder-after-pack.test.ts
@@ -13,7 +13,22 @@ const {
} = require('./electron-builder-after-pack.cjs') as {
LINUX_FFMPEG_LIBRARY: string;
MACOS_WINDOW_HELPER: string;
- default: (context: { appOutDir: string; electronPlatformName: string }) => Promise;
+ default: (
+ context: {
+ appOutDir: string;
+ arch?: number;
+ electronPlatformName: string;
+ packager?: { appInfo?: { productFilename?: string } };
+ },
+ deps?: {
+ stageBunRuntime?: (options: {
+ appOutDir: string;
+ platform: string;
+ arch: number | undefined;
+ productFilename: string;
+ }) => Promise;
+ },
+ ) => Promise;
stageLinuxAppImageSharedLibrary: (context: {
appOutDir: string;
electronPlatformName: string;
@@ -156,3 +171,47 @@ test('afterPack propagates Linux staging failures', async () => {
fs.rmSync(workspace, { recursive: true, force: true });
}
});
+
+test('afterPack preserves Linux staging and forwards the electron-builder target to Bun staging', async () => {
+ const workspace = createWorkspace('subminer-after-pack-target');
+ const appOutDir = path.join(workspace, 'SubMiner-linux-arm64');
+ const sourceLibraryPath = path.join(appOutDir, LINUX_FFMPEG_LIBRARY);
+ const targetLibraryPath = path.join(appOutDir, 'usr', 'lib', LINUX_FFMPEG_LIBRARY);
+ let stagedOptions:
+ | {
+ appOutDir: string;
+ platform: string;
+ arch: number | undefined;
+ productFilename: string;
+ }
+ | undefined;
+
+ fs.mkdirSync(appOutDir, { recursive: true });
+ fs.writeFileSync(sourceLibraryPath, 'bundled ffmpeg', 'utf8');
+
+ try {
+ await afterPack(
+ {
+ appOutDir,
+ arch: 3,
+ electronPlatformName: 'linux',
+ packager: { appInfo: { productFilename: 'SubMiner Preview' } },
+ },
+ {
+ stageBunRuntime: async (options) => {
+ stagedOptions = options;
+ },
+ },
+ );
+
+ assert.deepEqual(stagedOptions, {
+ appOutDir,
+ platform: 'linux',
+ arch: 3,
+ productFilename: 'SubMiner Preview',
+ });
+ assert.equal(fs.readFileSync(targetLibraryPath, 'utf8'), 'bundled ffmpeg');
+ } finally {
+ fs.rmSync(workspace, { recursive: true, force: true });
+ }
+});
diff --git a/scripts/package-bun-source.mjs b/scripts/package-bun-source.mjs
new file mode 100644
index 00000000..1d88d3c6
--- /dev/null
+++ b/scripts/package-bun-source.mjs
@@ -0,0 +1,456 @@
+import { createHash, randomUUID } from 'node:crypto';
+import { createReadStream, createWriteStream } from 'node:fs';
+import fs from 'node:fs/promises';
+import path from 'node:path';
+import { spawn } from 'node:child_process';
+import { fileURLToPath } from 'node:url';
+import { pipeline } from 'node:stream/promises';
+import { Readable } from 'node:stream';
+
+const scriptDir = path.dirname(fileURLToPath(import.meta.url));
+const repoRoot = path.resolve(scriptDir, '..');
+
+export const DEFAULT_MANIFEST_PATH = path.join(repoRoot, 'build', 'bun-source-manifest.json');
+export const DEFAULT_RUNTIME_MANIFEST_PATH = path.join(
+ repoRoot,
+ 'build',
+ 'bun-runtime-manifest.json',
+);
+export const DEFAULT_PACKAGE_JSON_PATH = path.join(repoRoot, 'package.json');
+export const DEFAULT_OUTPUT_DIR = path.join(repoRoot, 'release');
+export const DEFAULT_CACHE_DIR = path.join(repoRoot, '.tmp', 'bun-corresponding-source');
+
+function isRecord(value) {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
+}
+
+function requiredString(record, key, source) {
+ const value = record[key];
+ if (typeof value !== 'string' || value.length === 0) {
+ throw new Error(`${source} must contain a non-empty ${key} string.`);
+ }
+ return value;
+}
+
+function assertSafeRelativePath(value, source) {
+ if (path.isAbsolute(value) || value.split(/[\\/]/).includes('..')) {
+ throw new Error(`${source} contains an unsafe path: ${value}`);
+ }
+}
+
+export function parseSourceManifest(value) {
+ if (!isRecord(value) || value.schemaVersion !== 1) {
+ throw new Error('Bun source manifest must use schemaVersion 1.');
+ }
+ const version = requiredString(value, 'version', 'Bun source manifest');
+ const bunRevision = requiredString(value, 'bunRevision', 'Bun source manifest');
+ const archiveName = requiredString(value, 'archiveName', 'Bun source manifest');
+ if (!/^\d+\.\d+\.\d+$/.test(version) || !/^[a-f0-9]{40}$/.test(bunRevision)) {
+ throw new Error('Bun source manifest has an invalid version or bunRevision.');
+ }
+ if (path.basename(archiveName) !== archiveName || !archiveName.endsWith('.tar.gz')) {
+ throw new Error('Bun source manifest archiveName must be a safe .tar.gz filename.');
+ }
+ if (!Array.isArray(value.sources) || value.sources.length === 0) {
+ throw new Error('Bun source manifest must contain sources.');
+ }
+
+ const names = new Set();
+ const destinations = new Set();
+ const sources = value.sources.map((entry, index) => {
+ if (!isRecord(entry)) throw new Error(`Bun source ${index} must be an object.`);
+ const name = requiredString(entry, 'name', `Bun source ${index}`);
+ const repository = requiredString(entry, 'repository', `Bun source ${name}`);
+ const revision = requiredString(entry, 'revision', `Bun source ${name}`);
+ const destination = requiredString(entry, 'destination', `Bun source ${name}`);
+ if (!/^[\w.-]+\/[\w.-]+$/.test(repository) || !/^[a-f0-9]{40}$/.test(revision)) {
+ throw new Error(`Bun source ${name} has an invalid repository or revision.`);
+ }
+ assertSafeRelativePath(destination, `Bun source ${name}`);
+ if (names.has(name) || destinations.has(destination)) {
+ throw new Error(`Bun source manifest repeats ${name} or ${destination}.`);
+ }
+ names.add(name);
+ destinations.add(destination);
+
+ const transport = entry.transport ?? 'archive';
+ if (transport !== 'archive' && transport !== 'git-sparse') {
+ throw new Error(`Bun source ${name} has unsupported transport ${transport}.`);
+ }
+ const sha256 =
+ transport === 'archive' ? requiredString(entry, 'sha256', `Bun source ${name}`) : null;
+ if (sha256 !== null && !/^[a-f0-9]{64}$/.test(sha256)) {
+ throw new Error(`Bun source ${name} has an invalid SHA-256 digest.`);
+ }
+ if (!Array.isArray(entry.licensePaths) || entry.licensePaths.length === 0) {
+ throw new Error(`Bun source ${name} must declare licensePaths.`);
+ }
+ const licensePaths = entry.licensePaths.map((licensePath) => {
+ if (typeof licensePath !== 'string' || licensePath.length === 0) {
+ throw new Error(`Bun source ${name} has an invalid license path.`);
+ }
+ assertSafeRelativePath(licensePath, `Bun source ${name}`);
+ return licensePath;
+ });
+ const exclude = Array.isArray(entry.exclude) ? entry.exclude : [];
+ for (const excludedPath of exclude) assertSafeRelativePath(excludedPath, `Bun source ${name}`);
+ return {
+ ...entry,
+ name,
+ repository,
+ revision,
+ destination,
+ transport,
+ sha256,
+ licensePaths,
+ exclude,
+ };
+ });
+
+ const bun = sources.find((source) => source.name === 'bun');
+ if (!bun || bun.revision !== bunRevision || bun.destination !== 'bun') {
+ throw new Error('Bun source manifest must map bunRevision to the bun source at bun/.');
+ }
+ return { ...value, version, bunRevision, archiveName, sources };
+}
+
+export function parseRegisteredRepositories(cmakeText) {
+ const registrations = new Map();
+ const uncommented = cmakeText.replace(/#[^\n]*/g, '');
+ for (const match of uncommented.matchAll(/register_repository\(([\s\S]*?)\)/g)) {
+ const body = match[1];
+ const name = /\bNAME\s+([^\s#)]+)/.exec(body)?.[1];
+ const repository = /\bREPOSITORY\s+([^\s#)]+)/.exec(body)?.[1];
+ const reference = /\b(COMMIT|TAG)\s+(?:#[^\n]*\n\s*)?([^\s#)]+)/.exec(body);
+ if (name && repository && reference) {
+ registrations.set(name, {
+ repository,
+ kind: reference[1].toLowerCase(),
+ reference: reference[2],
+ });
+ }
+ }
+ return registrations;
+}
+
+export function validateRuntimeAlignment(manifest, packageJson, runtimeManifest) {
+ if (!isRecord(packageJson) || packageJson.packageManager !== `bun@${manifest.version}`) {
+ throw new Error(
+ `package.json must pin bun@${manifest.version} to match the Bun source manifest.`,
+ );
+ }
+ if (!isRecord(runtimeManifest)) throw new Error('Bun runtime manifest must be an object.');
+ for (const key of ['version', 'bunRevision']) {
+ if (runtimeManifest[key] !== manifest[key]) {
+ throw new Error(`Bun runtime manifest ${key} does not match the Bun source manifest.`);
+ }
+ }
+ if (runtimeManifest.correspondingSourceAsset !== manifest.archiveName) {
+ throw new Error(
+ 'Bun runtime manifest correspondingSourceAsset does not match the Bun source manifest.',
+ );
+ }
+}
+
+export function validateBunPins(manifest, cmakeTexts, setupWebKitText) {
+ const actual = new Map();
+ for (const cmakeText of cmakeTexts) {
+ for (const [name, registration] of parseRegisteredRepositories(cmakeText)) {
+ if (actual.has(name)) throw new Error(`Bun registers ${name} more than once.`);
+ actual.set(name, registration);
+ }
+ }
+ const expected = new Map(
+ manifest.sources
+ .filter((source) => source.destination.startsWith('bun/vendor/') && source.name !== 'WebKit')
+ .map((source) => [source.name, source]),
+ );
+ for (const [name, registration] of actual) {
+ const source = expected.get(name);
+ if (!source) throw new Error(`Source manifest omits Bun dependency ${name}.`);
+ if (source.repository !== registration.repository) {
+ throw new Error(`Source manifest repository mismatch for ${name}.`);
+ }
+ const expectedReference = source.upstreamReference ?? source.revision;
+ if (expectedReference !== registration.reference) {
+ throw new Error(`Source manifest revision mismatch for ${name}.`);
+ }
+ expected.delete(name);
+ }
+ if (expected.size > 0) {
+ throw new Error(
+ `Source manifest has unregistered Bun dependencies: ${[...expected.keys()].join(', ')}.`,
+ );
+ }
+
+ const webKitPin = /set\(WEBKIT_VERSION\s+([a-f0-9]{40})\)/.exec(setupWebKitText)?.[1];
+ const webKit = manifest.sources.find((source) => source.name === 'WebKit');
+ if (!webKitPin || !webKit || webKit.revision !== webKitPin) {
+ throw new Error('Source manifest WebKit revision does not match SetupWebKit.cmake.');
+ }
+}
+
+async function sha256File(filePath) {
+ const hash = createHash('sha256');
+ for await (const chunk of createReadStream(filePath)) hash.update(chunk);
+ return hash.digest('hex');
+}
+
+async function run(command, args, options = {}) {
+ await new Promise((resolve, reject) => {
+ const child = spawn(command, args, { stdio: 'inherit', ...options });
+ child.once('error', reject);
+ child.once('close', (code) => {
+ if (code === 0) resolve();
+ else reject(new Error(`${command} exited with status ${code}.`));
+ });
+ });
+}
+
+export async function downloadArchive(source, cacheDir, fetchImpl) {
+ const archivePath = path.join(cacheDir, `${source.name}-${source.revision}.tar.gz`);
+ try {
+ if ((await sha256File(archivePath)) === source.sha256) return archivePath;
+ await fs.rm(archivePath, { force: true });
+ } catch (error) {
+ if (!isRecord(error) || error.code !== 'ENOENT') throw error;
+ }
+
+ const url = `https://codeload.github.com/${source.repository}/tar.gz/${source.revision}`;
+ const temporaryPath = `${archivePath}.download-${randomUUID()}`;
+ try {
+ const response = await fetchImpl(url);
+ if (!response.ok || !response.body)
+ throw new Error(`Unable to download ${url}: HTTP ${response.status}`);
+ await pipeline(
+ Readable.fromWeb(response.body),
+ createWriteStream(temporaryPath, { flags: 'wx' }),
+ );
+ const actualSha256 = await sha256File(temporaryPath);
+ if (actualSha256 !== source.sha256) {
+ throw new Error(
+ `Source checksum mismatch for ${source.name}: expected ${source.sha256}, received ${actualSha256}.`,
+ );
+ }
+ await fs.rename(temporaryPath, archivePath);
+ return archivePath;
+ } finally {
+ // Cleanup must not replace the original download, validation, or rename error.
+ await fs.rm(temporaryPath, { force: true }).catch(() => {});
+ }
+}
+
+async function materializeArchive(source, root, cacheDir, fetchImpl) {
+ const archivePath = await downloadArchive(source, cacheDir, fetchImpl);
+ const destination = path.join(root, source.destination);
+ await fs.mkdir(destination, { recursive: true });
+ await run('tar', ['-xzf', archivePath, '-C', destination, '--strip-components=1']);
+}
+
+async function materializeGitSparse(source, root, cacheDir) {
+ const checkout = path.join(cacheDir, `${source.name}-${source.revision}-git`);
+ await fs.rm(checkout, { recursive: true, force: true });
+ await run('git', [
+ 'clone',
+ '--filter=blob:none',
+ '--no-checkout',
+ '--depth=1',
+ `https://github.com/${source.repository}.git`,
+ checkout,
+ ]);
+ await run('git', ['-C', checkout, 'fetch', '--depth=1', 'origin', source.revision]);
+ await run('git', ['-C', checkout, 'sparse-checkout', 'init', '--no-cone']);
+ const sparseRules = ['/*', ...source.exclude.map((entry) => `!/${entry}/`), ''];
+ await fs.writeFile(
+ path.join(checkout, '.git', 'info', 'sparse-checkout'),
+ sparseRules.join('\n'),
+ );
+ await run('git', ['-C', checkout, 'checkout', '--detach', source.revision]);
+ const actualRevision = (await fs.readFile(path.join(checkout, '.git', 'HEAD'), 'utf8')).trim();
+ if (actualRevision !== source.revision)
+ throw new Error(`Git checkout mismatch for ${source.name}.`);
+ await fs.rm(path.join(checkout, '.git'), { recursive: true, force: true });
+ await fs.mkdir(path.dirname(path.join(root, source.destination)), { recursive: true });
+ await fs.rename(checkout, path.join(root, source.destination));
+}
+
+async function applyBunDependencyPatches(root, manifest) {
+ const bunRoot = path.join(root, 'bun');
+ for (const source of manifest.sources) {
+ if (!source.destination.startsWith('bun/vendor/') || source.name === 'WebKit') continue;
+ const destination = path.join(root, source.destination);
+ const patchDirectory = path.join(bunRoot, 'patches', source.name);
+ let entries = [];
+ try {
+ entries = await fs.readdir(patchDirectory, { withFileTypes: true });
+ } catch (error) {
+ if (!isRecord(error) || error.code !== 'ENOENT') throw error;
+ }
+ for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
+ const patchPath = path.join(patchDirectory, entry.name);
+ if (entry.isFile() && entry.name.endsWith('.patch')) {
+ await run(
+ 'git',
+ ['apply', '--ignore-whitespace', '--ignore-space-change', '--no-index', patchPath],
+ { cwd: destination },
+ );
+ } else if (entry.isFile()) {
+ await fs.copyFile(patchPath, path.join(destination, entry.name));
+ }
+ }
+ const cmakeReference = source.upstreamReference
+ ? `refs/tags/${source.upstreamReference}`
+ : source.revision;
+ await fs.writeFile(path.join(destination, '.ref'), `${cmakeReference}\n`);
+ }
+}
+
+async function validateAndCollectLicenses(root, manifest) {
+ const licensesRoot = path.join(root, 'THIRD-PARTY-LICENSES');
+ await fs.mkdir(licensesRoot, { recursive: true });
+ for (const source of manifest.sources) {
+ const target = path.join(licensesRoot, source.name);
+ await fs.mkdir(target, { recursive: true });
+ for (const licensePath of source.licensePaths) {
+ const sourcePath = path.join(root, source.destination, licensePath);
+ const stat = await fs.stat(sourcePath).catch(() => null);
+ if (!stat?.isFile() || stat.size === 0) {
+ throw new Error(`Missing required license material for ${source.name}: ${licensePath}`);
+ }
+ const safeName = licensePath.replaceAll('/', '__');
+ await fs.copyFile(sourcePath, path.join(target, safeName));
+ }
+ }
+}
+
+function rebuildReadme(manifest) {
+ const webKit = manifest.sources.find((source) => source.name === 'WebKit');
+ const tinycc = manifest.sources.find((source) => source.name === 'tinycc');
+ return `# Bun ${manifest.version} corresponding source and rebuild materials
+
+This archive matches the official Bun ${manifest.version} binaries whose \`bun --revision\` output names commit \`${manifest.bunRevision}\`. The GitHub release tag points to \`${manifest.releaseTagCommit}\`, one later commit, so this package intentionally uses the binary revision.
+
+The archive includes Bun's complete source tree, Bun's build scripts and dependency patches, every external repository registered by Bun's CMake build at its exact pin, and Oven's WebKit fork at \`${webKit.revision}\`. Large WebKit test-only trees are excluded. The JavaScriptCore, WTF, WebCore, build-tool, configuration, and resource trees used to build the library are included. TinyCC is \`${tinycc.revision}\`.
+
+## Rebuild with modified JavaScriptCore
+
+Install the prerequisites recorded in \`bun/.buildkite/Dockerfile\`, \`bun/scripts/bootstrap.sh\`, and the WebKit platform build scripts. Bun ${manifest.version} used LLVM 19.1.7, CMake 3.30.5 in its Linux build image, and Bun 1.1.38 as the bootstrap runtime. Its Rust input was nightly and was not pinned to a dated toolchain in the release source.
+
+From this archive root on Linux or macOS:
+
+\`\`\`sh
+cd bun
+bun install --frozen-lockfile
+bun run jsc:build
+bun run build:release:local -- -DVERSION=${manifest.version} -DREVISION=${manifest.bunRevision}
+\`\`\`
+
+The first command uses the bootstrap Bun. \`jsc:build\` builds the included \`vendor/WebKit\` checkout into \`vendor/WebKit/WebKitBuild/Release\`. \`build:release:local\` links Bun against that local JavaScriptCore build. The explicit version and revision replace metadata that Bun normally reads from its Git checkout. The included \`vendor/*/.ref\` files prevent Bun's CMake rules from replacing the packaged dependency sources, and this package has already applied the files under \`bun/patches//\` in the same order as \`bun/cmake/scripts/GitClone.cmake\`.
+
+The archive vendors the source repositories that Bun's CMake build links into the executable. It preserves Bun's \`bun.lock\` files and lol-html's \`Cargo.lock\`, but it does not vendor npm packages, crates.io packages used to build lol-html, compilers, SDKs, or other build tools. The rebuild therefore needs network access for those pinned package-manager inputs. License notices embedded in those downloaded packages are outside the collected \`THIRD-PARTY-LICENSES\` directory's scope.
+
+Windows uses the prerequisites in \`bun/docs/project/building-windows.mdx\` and WebKit's \`windows-release.ps1\`. The local-JavaScriptCore path above has not been verified on Windows.
+
+These instructions describe the source and build entry points. Toolchain and generated-output differences mean a rebuild is not expected to be byte-for-byte identical to Oven's release binary. No claim about legal compliance or reproducible builds is made here.
+`;
+}
+
+async function createDeterministicArchive(stagingParent, rootName, outputPath) {
+ const temporaryTar = `${outputPath}.tar-${randomUUID()}`;
+ const temporaryGzip = `${outputPath}.gzip-${randomUUID()}`;
+ try {
+ await run('tar', [
+ '--sort=name',
+ '--mtime=@0',
+ '--owner=0',
+ '--group=0',
+ '--numeric-owner',
+ '-cf',
+ temporaryTar,
+ '-C',
+ stagingParent,
+ rootName,
+ ]);
+ const gzip = spawn('gzip', ['-n', '-9', '-c', temporaryTar], {
+ stdio: ['ignore', 'pipe', 'inherit'],
+ });
+ const completion = new Promise((resolve, reject) => {
+ gzip.once('error', reject);
+ gzip.once('close', resolve);
+ });
+ const [, code] = await Promise.all([
+ pipeline(gzip.stdout, createWriteStream(temporaryGzip, { flags: 'wx' })),
+ completion,
+ ]);
+ if (code !== 0) throw new Error(`gzip exited with status ${code}.`);
+ await fs.rm(outputPath, { force: true });
+ await fs.rename(temporaryGzip, outputPath);
+ } finally {
+ await Promise.all([
+ fs.rm(temporaryTar, { force: true }),
+ fs.rm(temporaryGzip, { force: true }),
+ ]);
+ }
+}
+
+export async function packageBunSource({
+ manifestPath = DEFAULT_MANIFEST_PATH,
+ runtimeManifestPath = DEFAULT_RUNTIME_MANIFEST_PATH,
+ packageJsonPath = DEFAULT_PACKAGE_JSON_PATH,
+ outputDir = DEFAULT_OUTPUT_DIR,
+ cacheDir = DEFAULT_CACHE_DIR,
+ fetchImpl = globalThis.fetch,
+} = {}) {
+ const [manifestText, runtimeManifestText, packageJsonText] = await Promise.all([
+ fs.readFile(manifestPath, 'utf8'),
+ fs.readFile(runtimeManifestPath, 'utf8'),
+ fs.readFile(packageJsonPath, 'utf8'),
+ ]);
+ const manifest = parseSourceManifest(JSON.parse(manifestText));
+ validateRuntimeAlignment(manifest, JSON.parse(packageJsonText), JSON.parse(runtimeManifestText));
+ if (typeof fetchImpl !== 'function') throw new Error('No fetch implementation is available.');
+ await fs.mkdir(cacheDir, { recursive: true });
+ const stagingParent = await fs.mkdtemp(path.join(cacheDir, 'assemble-'));
+ const rootName = path.basename(manifest.archiveName, '.tar.gz');
+ const root = path.join(stagingParent, rootName);
+ await fs.mkdir(root);
+
+ try {
+ const bun = manifest.sources.find((source) => source.name === 'bun');
+ await materializeArchive(bun, root, cacheDir, fetchImpl);
+ const cmakeFiles = (await fs.readdir(path.join(root, 'bun', 'cmake', 'targets')))
+ .filter((name) => name.endsWith('.cmake'))
+ .map((name) => fs.readFile(path.join(root, 'bun', 'cmake', 'targets', name), 'utf8'));
+ validateBunPins(
+ manifest,
+ await Promise.all(cmakeFiles),
+ await fs.readFile(path.join(root, 'bun', 'cmake', 'tools', 'SetupWebKit.cmake'), 'utf8'),
+ );
+
+ for (const source of manifest.sources.filter((entry) => entry.name !== 'bun')) {
+ if (source.transport === 'git-sparse') await materializeGitSparse(source, root, cacheDir);
+ else await materializeArchive(source, root, cacheDir, fetchImpl);
+ }
+ await applyBunDependencyPatches(root, manifest);
+ await validateAndCollectLicenses(root, manifest);
+ await fs.writeFile(
+ path.join(root, 'SOURCE-INVENTORY.json'),
+ `${JSON.stringify(manifest, null, 2)}\n`,
+ );
+ await fs.writeFile(path.join(root, 'README-REBUILD.md'), rebuildReadme(manifest));
+
+ await fs.mkdir(outputDir, { recursive: true });
+ const outputPath = path.join(outputDir, manifest.archiveName);
+ await createDeterministicArchive(stagingParent, rootName, outputPath);
+ const digest = await sha256File(outputPath);
+ await fs.writeFile(`${outputPath}.sha256`, `${digest} ${manifest.archiveName}\n`);
+ return { outputPath, sha256: digest };
+ } finally {
+ await fs.rm(stagingParent, { recursive: true, force: true });
+ }
+}
+
+if (import.meta.main) {
+ const result = await packageBunSource();
+ console.log(`${result.sha256} ${path.basename(result.outputPath)}`);
+}
diff --git a/scripts/package-bun-source.test.ts b/scripts/package-bun-source.test.ts
new file mode 100644
index 00000000..d361523a
--- /dev/null
+++ b/scripts/package-bun-source.test.ts
@@ -0,0 +1,153 @@
+import { describe, expect, test } from 'bun:test';
+import { createHash } from 'node:crypto';
+import fs from 'node:fs/promises';
+import os from 'node:os';
+import path from 'node:path';
+import {
+ downloadArchive,
+ parseRegisteredRepositories,
+ parseSourceManifest,
+ validateBunPins,
+ validateRuntimeAlignment,
+} from './package-bun-source.mjs';
+
+const projectRoot = path.resolve(import.meta.dir, '..');
+
+describe('Bun corresponding-source manifest', () => {
+ test('removes partial downloads when placing a valid archive fails', async () => {
+ const cacheDir = await fs.mkdtemp(path.join(os.tmpdir(), 'subminer-bun-source-test-'));
+ try {
+ const payload = new Uint8Array([1, 2, 3]);
+ const source = {
+ name: 'fixture',
+ repository: 'example/fixture',
+ revision: 'a'.repeat(40),
+ sha256: createHash('sha256').update(payload).digest('hex'),
+ };
+ const archivePath = path.join(cacheDir, `${source.name}-${source.revision}.tar.gz`);
+ await expect(
+ downloadArchive(source, cacheDir, async () => {
+ await fs.mkdir(archivePath);
+ return { ok: true, status: 200, body: new Response(payload).body };
+ }),
+ ).rejects.toMatchObject({ syscall: 'rename' });
+
+ const entries = await fs.readdir(cacheDir);
+ expect(entries.filter((entry) => entry.includes('.download-'))).toEqual([]);
+ } finally {
+ await fs.rm(cacheDir, { recursive: true, force: true });
+ }
+ });
+
+ test('pins the source to the revision reported by the distributed binary', async () => {
+ const manifest = parseSourceManifest(
+ JSON.parse(
+ await fs.readFile(path.join(projectRoot, 'build/bun-source-manifest.json'), 'utf8'),
+ ),
+ );
+
+ expect(manifest.version).toBe('1.3.5');
+ expect(manifest.bunRevision).toBe('1e86cebd74a5723e818b5c0555276b646bcf0e4c');
+ expect(manifest.releaseTagCommit).toBe('fa5a5bbe556a4bda5bde77b4013aa6c3bb4ec9ab');
+ expect(manifest.sources.find((source) => source.name === 'WebKit')?.revision).toBe(
+ '6d0f3aac0b817cc01a846b3754b21271adedac12',
+ );
+ expect(manifest.sources.find((source) => source.name === 'tinycc')?.revision).toBe(
+ '29985a3b59898861442fa3b43f663fc1af2591d7',
+ );
+ });
+
+ test('parses commit and tag registrations from Bun CMake', () => {
+ const registrations = parseRegisteredRepositories(`
+ register_repository(
+ NAME tinycc
+ REPOSITORY oven-sh/tinycc
+ COMMIT
+ # A comment between the field and its value is valid CMake.
+ 29985a3b59898861442fa3b43f663fc1af2591d7
+ )
+ register_repository(
+ NAME brotli
+ REPOSITORY google/brotli
+ TAG v1.1.0
+ )
+ `);
+
+ expect(registrations.get('tinycc')).toEqual({
+ repository: 'oven-sh/tinycc',
+ kind: 'commit',
+ reference: '29985a3b59898861442fa3b43f663fc1af2591d7',
+ });
+ expect(registrations.get('brotli')).toEqual({
+ repository: 'google/brotli',
+ kind: 'tag',
+ reference: 'v1.1.0',
+ });
+ });
+
+ test('rejects stale runtime or package-manager pins', async () => {
+ const manifest = parseSourceManifest(
+ JSON.parse(
+ await fs.readFile(path.join(projectRoot, 'build/bun-source-manifest.json'), 'utf8'),
+ ),
+ );
+ const runtimeManifest = {
+ version: manifest.version,
+ bunRevision: manifest.bunRevision,
+ correspondingSourceAsset: manifest.archiveName,
+ };
+
+ expect(() =>
+ validateRuntimeAlignment(manifest, { packageManager: 'bun@1.3.5' }, runtimeManifest),
+ ).not.toThrow();
+ expect(() =>
+ validateRuntimeAlignment(manifest, { packageManager: 'bun@1.3.6' }, runtimeManifest),
+ ).toThrow('package.json must pin bun@1.3.5');
+ expect(() =>
+ validateRuntimeAlignment(
+ manifest,
+ { packageManager: 'bun@1.3.5' },
+ {
+ ...runtimeManifest,
+ correspondingSourceAsset: 'stale.tar.gz',
+ },
+ ),
+ ).toThrow('correspondingSourceAsset does not match');
+ });
+
+ test('rejects drift in CMake dependency and WebKit pins', async () => {
+ const manifest = parseSourceManifest(
+ JSON.parse(
+ await fs.readFile(path.join(projectRoot, 'build/bun-source-manifest.json'), 'utf8'),
+ ),
+ );
+ const registrations = manifest.sources
+ .filter((source) => source.destination.startsWith('bun/vendor/') && source.name !== 'WebKit')
+ .map(
+ (source) => `register_repository(
+ NAME ${source.name}
+ REPOSITORY ${source.repository}
+ ${source.upstreamReference ? 'TAG' : 'COMMIT'} ${source.upstreamReference ?? source.revision}
+ )`,
+ )
+ .join('\n');
+
+ expect(() =>
+ validateBunPins(
+ manifest,
+ [registrations],
+ 'set(WEBKIT_VERSION 6d0f3aac0b817cc01a846b3754b21271adedac12)',
+ ),
+ ).not.toThrow();
+ expect(() =>
+ validateBunPins(
+ manifest,
+ [registrations.replace('29985a3b59898861442fa3b43f663fc1af2591d7', '0'.repeat(40))],
+ 'set(WEBKIT_VERSION 6d0f3aac0b817cc01a846b3754b21271adedac12)',
+ ),
+ ).toThrow('revision mismatch for tinycc');
+ expect(() =>
+ validateBunPins(manifest, [registrations], `set(WEBKIT_VERSION ${'0'.repeat(40)})`),
+ ).toThrow('WebKit revision does not match');
+ });
+});
diff --git a/scripts/stage-bun-runtime.mjs b/scripts/stage-bun-runtime.mjs
new file mode 100644
index 00000000..e18ce7ec
--- /dev/null
+++ b/scripts/stage-bun-runtime.mjs
@@ -0,0 +1,389 @@
+import { createHash, randomUUID } from 'node:crypto';
+import { createReadStream, createWriteStream } from 'node:fs';
+import fs from 'node:fs/promises';
+import path from 'node:path';
+import { spawn } from 'node:child_process';
+import { fileURLToPath } from 'node:url';
+import { pipeline } from 'node:stream/promises';
+import { Readable } from 'node:stream';
+import { promisify } from 'node:util';
+import { execFile } from 'node:child_process';
+
+const execFileAsync = promisify(execFile);
+const scriptDir = path.dirname(fileURLToPath(import.meta.url));
+const repoRoot = path.resolve(scriptDir, '..');
+
+export const DEFAULT_PACKAGE_JSON_PATH = path.join(repoRoot, 'package.json');
+export const DEFAULT_MANIFEST_PATH = path.join(repoRoot, 'build', 'bun-runtime-manifest.json');
+export const DEFAULT_CACHE_DIR = path.join(repoRoot, '.tmp', 'bun-runtime');
+export const DEFAULT_LICENSES_SOURCE_DIR = path.join(repoRoot, 'resources', 'bun', 'licenses');
+export const STAGED_METADATA_FILE = 'metadata.json';
+export const REQUIRED_LICENSE_FILES = [
+ 'Bun-LICENSE.md',
+ 'LGPL-2.0.txt',
+ 'LGPL-2.1.txt',
+ 'SOURCE.md',
+ 'THIRD-PARTY-NOTICES.md',
+];
+
+const RELEASE_BASE_URL = 'https://github.com/oven-sh/bun/releases/download';
+const SUPPORTED_PLATFORMS = new Set(['darwin', 'linux', 'win32']);
+const ARCH_BY_BUILDER_VALUE = new Map([
+ [1, 'x64'],
+ [3, 'arm64'],
+ ['x64', 'x64'],
+ ['arm64', 'arm64'],
+]);
+
+function isRecord(value) {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
+}
+
+function readRequiredString(record, key, source) {
+ const value = record[key];
+ if (typeof value !== 'string' || value.length === 0) {
+ throw new Error(`${source} must contain a non-empty ${key} string.`);
+ }
+ return value;
+}
+
+function readCommit(record, key, source) {
+ const value = readRequiredString(record, key, source);
+ if (!/^[a-f0-9]{40}$/.test(value)) {
+ throw new Error(`${source} must contain a 40-character ${key} commit.`);
+ }
+ return value;
+}
+
+export function normalizeTarget(platform, arch) {
+ if (!SUPPORTED_PLATFORMS.has(platform)) {
+ throw new Error(`Unsupported Bun runtime target platform: ${platform}`);
+ }
+
+ const normalizedArch = ARCH_BY_BUILDER_VALUE.get(arch);
+ if (!normalizedArch) {
+ throw new Error(`Unsupported Bun runtime target architecture for ${platform}: ${String(arch)}`);
+ }
+ if (platform === 'win32' && normalizedArch !== 'x64') {
+ throw new Error(`Unsupported Bun runtime target: ${platform}-${normalizedArch}`);
+ }
+
+ return {
+ platform,
+ arch: normalizedArch,
+ key: `${platform}-${normalizedArch}`,
+ executableName: platform === 'win32' ? 'bun.exe' : 'bun',
+ };
+}
+
+export function parsePackageManagerVersion(packageJson) {
+ if (!isRecord(packageJson)) {
+ throw new Error('package.json must contain a JSON object.');
+ }
+ const packageManager = readRequiredString(packageJson, 'packageManager', 'package.json');
+ const match = /^bun@(\d+\.\d+\.\d+)$/.exec(packageManager);
+ if (!match) {
+ throw new Error(
+ `package.json packageManager must pin Bun exactly, received ${packageManager}.`,
+ );
+ }
+ return match[1];
+}
+
+function parseArtifact(value, key) {
+ if (!isRecord(value)) {
+ throw new Error(`Bun runtime manifest artifact ${key} must be an object.`);
+ }
+ const file = readRequiredString(value, 'file', `Bun runtime manifest artifact ${key}`);
+ const sha256 = readRequiredString(value, 'sha256', `Bun runtime manifest artifact ${key}`);
+ if (!/^[a-f0-9]{64}$/.test(sha256)) {
+ throw new Error(`Bun runtime manifest artifact ${key} has an invalid SHA-256 digest.`);
+ }
+ if (path.basename(file) !== file || !file.endsWith('.zip')) {
+ throw new Error(`Bun runtime manifest artifact ${key} has an unsafe file name.`);
+ }
+ return { file, sha256 };
+}
+
+export function parseRuntimeManifest(manifest, version) {
+ if (!isRecord(manifest) || manifest.schemaVersion !== 1) {
+ throw new Error('Bun runtime manifest must use schemaVersion 1.');
+ }
+ const manifestVersion = readRequiredString(manifest, 'version', 'Bun runtime manifest');
+ if (manifestVersion !== version) {
+ throw new Error(
+ `Bun runtime manifest version ${manifestVersion} does not match packageManager bun@${version}.`,
+ );
+ }
+ if (!isRecord(manifest.artifacts)) {
+ throw new Error('Bun runtime manifest must contain an artifacts object.');
+ }
+ return {
+ version,
+ bunRevision: readCommit(manifest, 'bunRevision', 'Bun runtime manifest'),
+ releaseTagCommit: readCommit(manifest, 'releaseTagCommit', 'Bun runtime manifest'),
+ artifacts: manifest.artifacts,
+ licenseInventoryStatus: readRequiredString(
+ manifest,
+ 'licenseInventoryStatus',
+ 'Bun runtime manifest',
+ ),
+ sourceManifest: readRequiredString(manifest, 'sourceManifest', 'Bun runtime manifest'),
+ correspondingSourceAsset: readRequiredString(
+ manifest,
+ 'correspondingSourceAsset',
+ 'Bun runtime manifest',
+ ),
+ };
+}
+
+export async function loadRuntimeConfig({
+ packageJsonPath = DEFAULT_PACKAGE_JSON_PATH,
+ manifestPath = DEFAULT_MANIFEST_PATH,
+} = {}) {
+ const [packageJsonText, manifestText] = await Promise.all([
+ fs.readFile(packageJsonPath, 'utf8'),
+ fs.readFile(manifestPath, 'utf8'),
+ ]);
+ const version = parsePackageManagerVersion(JSON.parse(packageJsonText));
+ return parseRuntimeManifest(JSON.parse(manifestText), version);
+}
+
+export function resolveArtifact(config, platform, arch) {
+ const target = normalizeTarget(platform, arch);
+ const artifactValue = config.artifacts[target.key];
+ if (artifactValue === undefined) {
+ throw new Error(`Bun runtime manifest has no artifact for ${target.key}.`);
+ }
+ const artifact = parseArtifact(artifactValue, target.key);
+ return {
+ ...target,
+ ...artifact,
+ version: config.version,
+ url: `${RELEASE_BASE_URL}/bun-v${config.version}/${artifact.file}`,
+ };
+}
+
+export async function sha256File(filePath) {
+ const hash = createHash('sha256');
+ for await (const chunk of createReadStream(filePath)) {
+ hash.update(chunk);
+ }
+ return hash.digest('hex');
+}
+
+export async function ensureCachedArchive(
+ artifact,
+ { cacheDir = DEFAULT_CACHE_DIR, fetchImpl = globalThis.fetch } = {},
+) {
+ if (typeof fetchImpl !== 'function') {
+ throw new Error('No fetch implementation is available to download Bun.');
+ }
+ const versionCacheDir = path.join(cacheDir, artifact.version);
+ const archivePath = path.join(versionCacheDir, artifact.file);
+ await fs.mkdir(versionCacheDir, { recursive: true });
+
+ try {
+ if ((await sha256File(archivePath)) === artifact.sha256) return archivePath;
+ await fs.unlink(archivePath);
+ } catch (error) {
+ if (!isRecord(error) || error.code !== 'ENOENT') throw error;
+ }
+
+ const temporaryPath = `${archivePath}.download-${randomUUID()}`;
+ try {
+ const response = await fetchImpl(artifact.url);
+ if (!response.ok || !response.body) {
+ throw new Error(`Unable to download ${artifact.url}: HTTP ${response.status}`);
+ }
+ await pipeline(
+ Readable.fromWeb(response.body),
+ createWriteStream(temporaryPath, { flags: 'wx' }),
+ );
+ const actualSha256 = await sha256File(temporaryPath);
+ if (actualSha256 !== artifact.sha256) {
+ throw new Error(
+ `Bun archive checksum mismatch for ${artifact.file}: expected ${artifact.sha256}, received ${actualSha256}.`,
+ );
+ }
+ await fs.rename(temporaryPath, archivePath);
+ return archivePath;
+ } catch (error) {
+ await fs.rm(temporaryPath, { force: true });
+ throw error;
+ }
+}
+
+function isSafeZipEntry(entry) {
+ if (entry.startsWith('/') || /^[A-Za-z]:/.test(entry)) return false;
+ return !entry.replaceAll('\\', '/').split('/').includes('..');
+}
+
+function waitForProcess(child, description) {
+ let stderr = '';
+ child.stderr.setEncoding('utf8');
+ child.stderr.on('data', (chunk) => {
+ stderr += chunk;
+ });
+ return new Promise((resolve, reject) => {
+ child.once('error', reject);
+ child.once('close', (code) => {
+ if (code === 0) resolve();
+ else reject(new Error(`${description}: ${stderr.trim() || `process exited ${code}`}`));
+ });
+ });
+}
+
+export function buildWindowsExtractionCommand(archivePath, member, outputPath) {
+ const script = [
+ 'Add-Type -AssemblyName System.IO.Compression.FileSystem',
+ '$archive = [IO.Compression.ZipFile]::OpenRead($env:SUBMINER_BUN_ARCHIVE_PATH)',
+ 'try {',
+ ' $entry = $archive.Entries | Where-Object { $_.FullName -ceq $env:SUBMINER_BUN_ARCHIVE_MEMBER }',
+ ' if ($null -eq $entry) { throw "Archive member not found: $env:SUBMINER_BUN_ARCHIVE_MEMBER" }',
+ ' $inputStream = $entry.Open()',
+ ' $outputStream = [IO.File]::Create($env:SUBMINER_BUN_OUTPUT_PATH)',
+ ' try { $inputStream.CopyTo($outputStream) } finally { $outputStream.Dispose(); $inputStream.Dispose() }',
+ '} finally { $archive.Dispose() }',
+ ].join('; ');
+ return {
+ command: 'powershell.exe',
+ args: [
+ '-NoLogo',
+ '-NoProfile',
+ '-NonInteractive',
+ '-EncodedCommand',
+ Buffer.from(script, 'utf16le').toString('base64'),
+ ],
+ environment: {
+ SUBMINER_BUN_ARCHIVE_PATH: archivePath,
+ SUBMINER_BUN_ARCHIVE_MEMBER: member,
+ SUBMINER_BUN_OUTPUT_PATH: outputPath,
+ },
+ };
+}
+
+async function extractZipMemberOnWindows(archivePath, member, outputPath) {
+ const command = buildWindowsExtractionCommand(archivePath, member, outputPath);
+ const powershell = spawn(command.command, command.args, {
+ env: { ...process.env, ...command.environment },
+ stdio: ['ignore', 'ignore', 'pipe'],
+ });
+ await waitForProcess(powershell, `Unable to extract ${member}`);
+}
+
+export async function extractZipMember(archivePath, member, outputPath) {
+ if (!isSafeZipEntry(member)) {
+ throw new Error(`Refusing to extract unsafe Bun archive member ${member}.`);
+ }
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
+ const temporaryPath = `${outputPath}.extract-${randomUUID()}`;
+
+ if (process.platform === 'win32') {
+ try {
+ await extractZipMemberOnWindows(archivePath, member, temporaryPath);
+ await fs.chmod(temporaryPath, 0o755);
+ await fs.rename(temporaryPath, outputPath);
+ } catch (error) {
+ await fs.rm(temporaryPath, { force: true });
+ throw error;
+ }
+ return;
+ }
+
+ const { stdout } = await execFileAsync('unzip', ['-Z1', archivePath], {
+ encoding: 'utf8',
+ maxBuffer: 1024 * 1024,
+ });
+ const entries = stdout.split(/\r?\n/).filter(Boolean);
+ if (entries.some((entry) => !isSafeZipEntry(entry))) {
+ throw new Error(`Bun archive ${archivePath} contains an unsafe path.`);
+ }
+ if (!entries.includes(member)) {
+ throw new Error(`Bun archive ${archivePath} does not contain ${member}.`);
+ }
+
+ const output = createWriteStream(temporaryPath, { flags: 'wx', mode: 0o755 });
+ const unzip = spawn('unzip', ['-p', archivePath, member], { stdio: ['ignore', 'pipe', 'pipe'] });
+
+ try {
+ await Promise.all([
+ pipeline(unzip.stdout, output),
+ waitForProcess(unzip, `Unable to extract ${member}`),
+ ]);
+ await fs.chmod(temporaryPath, 0o755);
+ await fs.rename(temporaryPath, outputPath);
+ } catch (error) {
+ await fs.rm(temporaryPath, { force: true });
+ throw error;
+ }
+}
+
+export function resolveResourcesDirectory(appOutDir, platform, productFilename = 'SubMiner') {
+ if (platform !== 'darwin') return path.join(appOutDir, 'resources');
+ const appBundlePath = appOutDir.endsWith('.app')
+ ? appOutDir
+ : path.join(appOutDir, `${productFilename}.app`);
+ return path.join(appBundlePath, 'Contents', 'Resources');
+}
+
+export async function stageBunLicenses(
+ runtimeDirectory,
+ licensesSourceDir = DEFAULT_LICENSES_SOURCE_DIR,
+) {
+ const licensesDirectory = path.join(runtimeDirectory, 'licenses');
+ await Promise.all(
+ REQUIRED_LICENSE_FILES.map((fileName) => fs.access(path.join(licensesSourceDir, fileName))),
+ );
+ await fs.cp(licensesSourceDir, licensesDirectory, { recursive: true, force: true });
+ return licensesDirectory;
+}
+
+export async function stageBunRuntime(
+ { appOutDir, platform, arch, productFilename = 'SubMiner' },
+ {
+ configLoader = loadRuntimeConfig,
+ archiveLoader = ensureCachedArchive,
+ extractor = extractZipMember,
+ licenseStager = stageBunLicenses,
+ } = {},
+) {
+ const config = await configLoader();
+ const artifact = resolveArtifact(config, platform, arch);
+ const archivePath = await archiveLoader(artifact);
+ const archiveDirectory = path.basename(artifact.file, '.zip');
+ const archiveExecutableName = platform === 'win32' ? 'bun.exe' : 'bun';
+ const member = `${archiveDirectory}/${archiveExecutableName}`;
+ const runtimeDirectory = path.join(
+ resolveResourcesDirectory(appOutDir, platform, productFilename),
+ 'bun',
+ );
+ const executablePath = path.join(runtimeDirectory, artifact.executableName);
+ await extractor(archivePath, member, executablePath);
+ await licenseStager(runtimeDirectory);
+
+ const metadata = {
+ name: 'Bun',
+ version: config.version,
+ bunRevision: config.bunRevision,
+ releaseTagCommit: config.releaseTagCommit,
+ target: artifact.key,
+ artifact: artifact.file,
+ artifactSha256: artifact.sha256,
+ sourceUrl: artifact.url,
+ licenseInventoryStatus: config.licenseInventoryStatus,
+ correspondingSourceAsset: config.correspondingSourceAsset,
+ sourceInstructions: 'licenses/SOURCE.md',
+ thirdPartyNotices: 'licenses/THIRD-PARTY-NOTICES.md',
+ };
+ await fs.writeFile(
+ path.join(runtimeDirectory, STAGED_METADATA_FILE),
+ `${JSON.stringify(metadata, null, 2)}\n`,
+ { mode: 0o644 },
+ );
+ return {
+ executablePath,
+ metadataPath: path.join(runtimeDirectory, STAGED_METADATA_FILE),
+ artifact,
+ };
+}
diff --git a/scripts/stage-bun-runtime.test.ts b/scripts/stage-bun-runtime.test.ts
new file mode 100644
index 00000000..56f1c255
--- /dev/null
+++ b/scripts/stage-bun-runtime.test.ts
@@ -0,0 +1,307 @@
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import fs from 'node:fs/promises';
+import os from 'node:os';
+import path from 'node:path';
+import test from 'node:test';
+
+import {
+ buildWindowsExtractionCommand,
+ ensureCachedArchive,
+ extractZipMember,
+ loadRuntimeConfig,
+ normalizeTarget,
+ parsePackageManagerVersion,
+ parseRuntimeManifest,
+ resolveArtifact,
+ stageBunLicenses,
+ stageBunRuntime,
+} from './stage-bun-runtime.mjs';
+
+function sha256(content: Uint8Array): string {
+ return createHash('sha256').update(content).digest('hex');
+}
+
+function runtimeConfig() {
+ return {
+ version: '1.3.5',
+ bunRevision: '1e86cebd74a5723e818b5c0555276b646bcf0e4c',
+ releaseTagCommit: 'fa5a5bbe556a4bda5bde77b4013aa6c3bb4ec9ab',
+ artifacts: {
+ 'darwin-arm64': { file: 'bun-darwin-aarch64.zip', sha256: '1'.repeat(64) },
+ 'darwin-x64': { file: 'bun-darwin-x64-baseline.zip', sha256: '2'.repeat(64) },
+ 'linux-arm64': { file: 'bun-linux-aarch64.zip', sha256: '3'.repeat(64) },
+ 'linux-x64': { file: 'bun-linux-x64-baseline.zip', sha256: '4'.repeat(64) },
+ 'win32-x64': { file: 'bun-windows-x64-baseline.zip', sha256: '5'.repeat(64) },
+ },
+ licenseInventoryStatus: 'complete-for-bun-1.3.5-declared-linked-libraries',
+ sourceManifest: 'build/bun-source-manifest.json',
+ correspondingSourceAsset: 'bun-v1.3.5-source.tar.gz',
+ };
+}
+
+test('normalizeTarget maps each supported electron-builder target without using the host', () => {
+ assert.deepEqual(normalizeTarget('linux', 1), {
+ platform: 'linux',
+ arch: 'x64',
+ key: 'linux-x64',
+ executableName: 'bun',
+ });
+ assert.equal(normalizeTarget('linux', 3).key, 'linux-arm64');
+ assert.equal(normalizeTarget('darwin', 'x64').key, 'darwin-x64');
+ assert.equal(normalizeTarget('darwin', 'arm64').key, 'darwin-arm64');
+ assert.deepEqual(normalizeTarget('win32', 1), {
+ platform: 'win32',
+ arch: 'x64',
+ key: 'win32-x64',
+ executableName: 'bun.exe',
+ });
+ assert.throws(() => normalizeTarget('freebsd', 'x64'), /Unsupported Bun runtime target platform/);
+ assert.throws(() => normalizeTarget('win32', 'arm64'), /Unsupported Bun runtime target/);
+ assert.throws(() => normalizeTarget('linux', 0), /Unsupported Bun runtime target architecture/);
+});
+
+test('resolveArtifact chooses baseline x64 builds and standard arm64 builds', () => {
+ const config = runtimeConfig();
+ assert.equal(resolveArtifact(config, 'linux', 'x64').file, 'bun-linux-x64-baseline.zip');
+ assert.equal(resolveArtifact(config, 'darwin', 'x64').file, 'bun-darwin-x64-baseline.zip');
+ assert.equal(resolveArtifact(config, 'win32', 'x64').file, 'bun-windows-x64-baseline.zip');
+ assert.equal(resolveArtifact(config, 'linux', 'arm64').file, 'bun-linux-aarch64.zip');
+ assert.equal(resolveArtifact(config, 'darwin', 'arm64').file, 'bun-darwin-aarch64.zip');
+});
+
+test('tracked runtime manifest covers every supported target at the packageManager version', async () => {
+ const config = await loadRuntimeConfig();
+ assert.equal(config.version, '1.3.5');
+ for (const [platform, arch] of [
+ ['linux', 'x64'],
+ ['linux', 'arm64'],
+ ['darwin', 'x64'],
+ ['darwin', 'arm64'],
+ ['win32', 'x64'],
+ ]) {
+ const artifact = resolveArtifact(config, platform, arch);
+ assert.match(artifact.sha256, /^[a-f0-9]{64}$/);
+ assert.equal(
+ artifact.url,
+ `https://github.com/oven-sh/bun/releases/download/bun-v1.3.5/${artifact.file}`,
+ );
+ }
+});
+
+test('manifest version must match the exact packageManager Bun pin', () => {
+ assert.equal(parsePackageManagerVersion({ packageManager: 'bun@1.3.5' }), '1.3.5');
+ assert.throws(
+ () => parsePackageManagerVersion({ packageManager: 'bun@^1.3.5' }),
+ /must pin Bun exactly/,
+ );
+ assert.throws(
+ () =>
+ parseRuntimeManifest(
+ {
+ schemaVersion: 1,
+ version: '1.3.6',
+ bunRevision: '1e86cebd74a5723e818b5c0555276b646bcf0e4c',
+ releaseTagCommit: 'fa5a5bbe556a4bda5bde77b4013aa6c3bb4ec9ab',
+ artifacts: {},
+ licenseInventoryStatus: 'partial',
+ sourceManifest: 'build/bun-source-manifest.json',
+ correspondingSourceAsset: 'bun-v1.3.5-source.tar.gz',
+ },
+ '1.3.5',
+ ),
+ /does not match packageManager bun@1\.3\.5/,
+ );
+});
+
+test('ensureCachedArchive verifies downloads and reuses a verified cache entry offline', async () => {
+ const workspace = await fs.mkdtemp(path.join(os.tmpdir(), 'subminer-bun-cache-'));
+ const bytes = new TextEncoder().encode('verified Bun archive fixture');
+ const artifact = {
+ version: '1.3.5',
+ file: 'bun-linux-x64-baseline.zip',
+ sha256: sha256(bytes),
+ url: 'https://example.invalid/bun.zip',
+ };
+ let downloads = 0;
+ const fetchImpl = async () => {
+ downloads += 1;
+ return new Response(bytes);
+ };
+
+ try {
+ const firstPath = await ensureCachedArchive(artifact, { cacheDir: workspace, fetchImpl });
+ const secondPath = await ensureCachedArchive(artifact, {
+ cacheDir: workspace,
+ fetchImpl: async () => {
+ throw new Error('verified cache should not fetch');
+ },
+ });
+ assert.equal(firstPath, secondPath);
+ assert.equal(downloads, 1);
+ assert.deepEqual(await fs.readFile(firstPath), Buffer.from(bytes));
+ } finally {
+ await fs.rm(workspace, { recursive: true, force: true });
+ }
+});
+
+test('ensureCachedArchive rejects a checksum mismatch without caching the download', async () => {
+ const workspace = await fs.mkdtemp(path.join(os.tmpdir(), 'subminer-bun-cache-mismatch-'));
+ const artifact = {
+ version: '1.3.5',
+ file: 'bun-linux-x64-baseline.zip',
+ sha256: '0'.repeat(64),
+ url: 'https://example.invalid/bun.zip',
+ };
+
+ try {
+ await assert.rejects(
+ ensureCachedArchive(artifact, {
+ cacheDir: workspace,
+ fetchImpl: async () => new Response('tampered'),
+ }),
+ /checksum mismatch/,
+ );
+ const cacheEntries = await fs.readdir(path.join(workspace, '1.3.5'));
+ assert.deepEqual(cacheEntries, []);
+ } finally {
+ await fs.rm(workspace, { recursive: true, force: true });
+ }
+});
+
+test('extractZipMember extracts only the requested path and makes the runtime executable', async () => {
+ const workspace = await fs.mkdtemp(path.join(os.tmpdir(), 'subminer-bun-extract-'));
+ const archivePath = path.join(workspace, 'fixture.zip');
+ const outputPath = path.join(workspace, 'output', 'bun');
+ const archiveBase64 =
+ 'UEsDBAoAAAAAAMxcKl3rs337EgAAABIAAAAaABwAYnVuLWxpbnV4LXg2NC1iYXNlbGluZS9idW5VVAkAAyD5omog+aJqdXgLAAEE6AMAAAToAwAAYnVuIGZpeHR1cmUgYmluYXJ5UEsBAh4DCgAAAAAAzFwqXeuzffsSAAAAEgAAABoAGAAAAAAAAQAAAKSBAAAAAGJ1bi1saW51eC14NjQtYmFzZWxpbmUvYnVuVVQFAAMg+aJqdXgLAAEE6AMAAAToAwAAUEsFBgAAAAABAAEAYAAAAGYAAAAAAA==';
+
+ try {
+ await fs.writeFile(archivePath, Buffer.from(archiveBase64, 'base64'));
+ await extractZipMember(archivePath, 'bun-linux-x64-baseline/bun', outputPath);
+ assert.equal(await fs.readFile(outputPath, 'utf8'), 'bun fixture binary');
+ assert.equal((await fs.stat(outputPath)).mode & 0o777, 0o755);
+ await assert.rejects(
+ extractZipMember(archivePath, '../bun', path.join(workspace, 'unsafe')),
+ /unsafe Bun archive member/,
+ );
+ } finally {
+ await fs.rm(workspace, { recursive: true, force: true });
+ }
+});
+
+test('Windows extraction keeps paths and archive members out of PowerShell command text', () => {
+ const archivePath = String.raw`C:\Release Builds\bun $(archive) '1.3.5'.zip`;
+ const member = 'bun-windows-x64-baseline/bun.exe';
+ const outputPath = String.raw`C:\Staged App & Tools\resources\bun\bun.exe`;
+ const command = buildWindowsExtractionCommand(archivePath, member, outputPath);
+ const encodedCommand = command.args.at(-1);
+
+ assert.equal(command.command, 'powershell.exe');
+ assert.equal(command.args.at(-2), '-EncodedCommand');
+ assert.ok(encodedCommand);
+ const script = Buffer.from(encodedCommand, 'base64').toString('utf16le');
+ assert.match(script, /\$env:SUBMINER_BUN_ARCHIVE_PATH/);
+ assert.match(script, /\$env:SUBMINER_BUN_ARCHIVE_MEMBER/);
+ assert.match(script, /\$env:SUBMINER_BUN_OUTPUT_PATH/);
+ assert.doesNotMatch(script, /Release Builds|Staged App|bun-windows-x64-baseline/);
+ assert.deepEqual(command.environment, {
+ SUBMINER_BUN_ARCHIVE_PATH: archivePath,
+ SUBMINER_BUN_ARCHIVE_MEMBER: member,
+ SUBMINER_BUN_OUTPUT_PATH: outputPath,
+ });
+});
+
+test('stageBunLicenses copies the tracked inventory into resources/bun/licenses', async () => {
+ const workspace = await fs.mkdtemp(path.join(os.tmpdir(), 'subminer-bun-licenses-'));
+ const sourceDirectory = path.join(workspace, 'tracked-licenses');
+ const runtimeDirectory = path.join(workspace, 'resources', 'bun');
+
+ try {
+ await fs.mkdir(sourceDirectory, { recursive: true });
+ for (const fileName of [
+ 'Bun-LICENSE.md',
+ 'LGPL-2.0.txt',
+ 'LGPL-2.1.txt',
+ 'SOURCE.md',
+ 'THIRD-PARTY-NOTICES.md',
+ ]) {
+ await fs.writeFile(path.join(sourceDirectory, fileName), `${fileName}\n`);
+ }
+ const licensesDirectory = await stageBunLicenses(runtimeDirectory, sourceDirectory);
+ assert.equal(licensesDirectory, path.join(runtimeDirectory, 'licenses'));
+ assert.equal(
+ await fs.readFile(path.join(licensesDirectory, 'THIRD-PARTY-NOTICES.md'), 'utf8'),
+ 'THIRD-PARTY-NOTICES.md\n',
+ );
+ } finally {
+ await fs.rm(workspace, { recursive: true, force: true });
+ }
+});
+
+test('stageBunRuntime places target executables and metadata in app resources with safe modes', async () => {
+ const workspace = await fs.mkdtemp(path.join(os.tmpdir(), 'subminer-bun-stage-'));
+ const cases = [
+ {
+ platform: 'linux',
+ arch: 'x64',
+ appOutDir: path.join(workspace, 'linux'),
+ relativeExecutable: path.join('resources', 'bun', 'bun'),
+ member: 'bun-linux-x64-baseline/bun',
+ },
+ {
+ platform: 'darwin',
+ arch: 'arm64',
+ appOutDir: path.join(workspace, 'darwin'),
+ relativeExecutable: path.join('SubMiner.app', 'Contents', 'Resources', 'bun', 'bun'),
+ member: 'bun-darwin-aarch64/bun',
+ },
+ {
+ platform: 'win32',
+ arch: 'x64',
+ appOutDir: path.join(workspace, 'windows'),
+ relativeExecutable: path.join('resources', 'bun', 'bun.exe'),
+ member: 'bun-windows-x64-baseline/bun.exe',
+ },
+ ] as const;
+
+ try {
+ for (const targetCase of cases) {
+ let extractedMember = '';
+ const result = await stageBunRuntime(targetCase, {
+ configLoader: async () => runtimeConfig(),
+ archiveLoader: async () => path.join(workspace, 'fixture.zip'),
+ extractor: async (_archivePath: string, member: string, outputPath: string) => {
+ extractedMember = member;
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
+ await fs.writeFile(outputPath, 'bun fixture', { mode: 0o755 });
+ },
+ licenseStager: async (runtimeDirectory: string) => {
+ const licensesDirectory = path.join(runtimeDirectory, 'licenses');
+ await fs.mkdir(licensesDirectory, { recursive: true });
+ await fs.writeFile(path.join(licensesDirectory, 'Bun-LICENSE.md'), 'MIT fixture');
+ return licensesDirectory;
+ },
+ });
+ const expectedExecutable = path.join(targetCase.appOutDir, targetCase.relativeExecutable);
+ assert.equal(result.executablePath, expectedExecutable);
+ assert.equal(extractedMember, targetCase.member);
+ assert.equal((await fs.stat(expectedExecutable)).mode & 0o777, 0o755);
+ assert.equal((await fs.stat(result.metadataPath)).mode & 0o777, 0o644);
+ const metadata = JSON.parse(await fs.readFile(result.metadataPath, 'utf8'));
+ assert.equal(metadata.version, '1.3.5');
+ assert.equal(metadata.bunRevision, '1e86cebd74a5723e818b5c0555276b646bcf0e4c');
+ assert.equal(metadata.artifactSha256, result.artifact.sha256);
+ assert.equal(metadata.target, result.artifact.key);
+ assert.equal(
+ await fs.readFile(
+ path.join(path.dirname(expectedExecutable), 'licenses', 'Bun-LICENSE.md'),
+ 'utf8',
+ ),
+ 'MIT fixture',
+ );
+ }
+ } finally {
+ await fs.rm(workspace, { recursive: true, force: true });
+ }
+});
diff --git a/scripts/update-aur-package.test.ts b/scripts/update-aur-package.test.ts
index 70a46799..c1b8187a 100644
--- a/scripts/update-aur-package.test.ts
+++ b/scripts/update-aur-package.test.ts
@@ -70,6 +70,7 @@ test('update-aur-package updates PKGBUILD and .SRCINFO without makepkg', () => {
);
assert.match(pkgbuild, /^pkgver=0\.6\.3$/m);
+ assert.doesNotMatch(pkgbuild, /^\s*'bun'$/m);
assert.match(
pkgbuild,
/^\s*"subminer-\$\{pkgver\}::https:\/\/github\.com\/ksyasuda\/SubMiner\/releases\/download\/v\$\{pkgver\}\/subminer"$/m,
@@ -84,6 +85,7 @@ test('update-aur-package updates PKGBUILD and .SRCINFO without makepkg', () => {
);
assert.match(pkgbuild, /assets\/thumbnailers\/subminer-ffmpegthumbnailer\.thumbnailer/);
assert.match(srcinfo, /^\tpkgver = 0\.6\.3$/m);
+ assert.doesNotMatch(srcinfo, /^\tdepends = bun$/m);
assert.match(srcinfo, /^\tprovides = subminer=0\.6\.3$/m);
assert.match(
srcinfo,
diff --git a/scripts/verify-generated-launcher.sh b/scripts/verify-generated-launcher.sh
index aab1494d..4ce7c1be 100755
--- a/scripts/verify-generated-launcher.sh
+++ b/scripts/verify-generated-launcher.sh
@@ -2,23 +2,38 @@
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-LAUNCHER_OUT="$REPO_ROOT/dist/launcher/subminer"
+LAUNCHER_DIR="$REPO_ROOT/dist/launcher"
+LAUNCHER_OUT="$LAUNCHER_DIR/subminer"
+EXPECTED_ARTIFACTS=(prepare.cjs subminer subminer.cmd subminer.js version)
if [[ ! -f "$REPO_ROOT/launcher/main.ts" ]]; then
echo "[FAIL] launcher source missing: launcher/main.ts"
exit 1
fi
-if ! grep -Fn -- "--outfile=\"\$(LAUNCHER_OUT)\"" "$REPO_ROOT/Makefile" >/dev/null; then
- echo "[FAIL] Makefile build-launcher target is not writing to dist/launcher/subminer"
+if ! grep -F -- "bun run build:launcher" "$REPO_ROOT/Makefile" >/dev/null; then
+ echo "[FAIL] Makefile build-launcher target does not call the canonical package script"
exit 1
fi
-if [[ ! -f "$LAUNCHER_OUT" ]]; then
- echo "[FAIL] generated launcher not found at dist/launcher/subminer"
- echo " run: make build-launcher"
- exit 1
-fi
+for artifact in "${EXPECTED_ARTIFACTS[@]}"; do
+ if [[ ! -f "$LAUNCHER_DIR/$artifact" ]]; then
+ echo "[FAIL] generated launcher artifact missing: dist/launcher/$artifact"
+ echo " run: make build-launcher"
+ exit 1
+ fi
+done
+
+for artifact_path in "$LAUNCHER_DIR"/*; do
+ artifact="${artifact_path##*/}"
+ case "$artifact" in
+ prepare.cjs | subminer | subminer.cmd | subminer.js | version) ;;
+ *)
+ echo "[FAIL] dist/launcher contains an unexpected runtime artifact: $artifact"
+ exit 1
+ ;;
+ esac
+done
if [[ ! -x "$LAUNCHER_OUT" ]]; then
echo "[FAIL] generated launcher is not executable: dist/launcher/subminer"
@@ -32,11 +47,11 @@ if [[ -f "$REPO_ROOT/subminer" ]]; then
exit 1
fi
-if git -C "$REPO_ROOT" ls-files --error-unmatch dist/launcher/subminer >/dev/null 2>&1; then
- echo "[FAIL] dist/launcher/subminer is tracked by git; generated artifacts must remain untracked"
+if git -C "$REPO_ROOT" ls-files --error-unmatch dist/launcher >/dev/null 2>&1; then
+ echo "[FAIL] dist/launcher contains tracked files; generated artifacts must remain untracked"
exit 1
fi
echo "[OK] launcher workflow verified"
echo " source: launcher/*.ts"
-echo " generated artifact: dist/launcher/subminer"
+echo " generated artifacts: ${EXPECTED_ARTIFACTS[*]}"
diff --git a/src/main.ts b/src/main.ts
index f142fd01..7a98dbdd 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -388,6 +388,7 @@ import {
detectCommandLineLauncher,
installBun as installCommandLineBun,
installLauncher as installCommandLineLauncher,
+ refreshManagedCommandLineLauncher,
} from './main/runtime/command-line-launcher';
import {
createWindowsMpvLaunchDeps,
@@ -1433,6 +1434,10 @@ const createCommandLineLauncherRuntimeOptions = () => ({
cwd: process.cwd(),
resourcesPath: process.resourcesPath,
appExePath: process.execPath,
+ appVersion: app.getVersion(),
+ bundledBunPath: app.isPackaged
+ ? path.join(process.resourcesPath, 'bun', process.platform === 'win32' ? 'bun.exe' : 'bun')
+ : undefined,
});
const firstRunSetupService = createFirstRunSetupService({
platform: process.platform,
@@ -1518,7 +1523,7 @@ const firstRunSetupService = createFirstRunSetupService({
},
installCommandLineLauncher: async () => {
const snapshot = await installCommandLineLauncher(createCommandLineLauncherRuntimeOptions());
- const ok = snapshot.status === 'ready' || snapshot.status === 'installed_bun_missing';
+ const ok = snapshot.status === 'ready' || snapshot.status === 'not_on_path';
return {
ok,
installPath: snapshot.installPath,
@@ -5291,7 +5296,7 @@ const { getChangelogSnapshot } = createChangelogRuntime({
logWarn: (message) => logger.warn(message),
});
-const { getUpdateService } = createUpdateServiceRuntime({
+const { getUpdateService, takePendingLauncherMigrationPath } = createUpdateServiceRuntime({
userDataPath: USER_DATA_PATH,
getUpdatesConfig: () => configService.getConfig().updates,
logInfo: (message) => logger.info(message),
@@ -6249,6 +6254,15 @@ const { runAndApplyStartupState } = composeHeadlessStartupHandlers<
runAndApplyStartupState();
void app.whenReady().then(() => {
+ void takePendingLauncherMigrationPath(async (pendingLauncherPath) => {
+ const acknowledgedPaths = await refreshManagedCommandLineLauncher({
+ ...createCommandLineLauncherRuntimeOptions(),
+ additionalLauncherPaths: pendingLauncherPath ? [pendingLauncherPath] : [],
+ });
+ return pendingLauncherPath !== undefined && acknowledgedPaths.includes(pendingLauncherPath);
+ }).catch((error) => {
+ logger.warn('Failed to refresh the installed command-line launcher', error);
+ });
if (!shouldStartAutomaticUpdateChecks(appState.initialArgs)) {
return;
}
diff --git a/src/main/runtime/command-line-launcher-deps.ts b/src/main/runtime/command-line-launcher-deps.ts
index 69b654af..58f01693 100644
--- a/src/main/runtime/command-line-launcher-deps.ts
+++ b/src/main/runtime/command-line-launcher-deps.ts
@@ -32,6 +32,8 @@ export type CommonOptions = FsDeps & {
resourcesPath?: string;
appExePath?: string;
launcherResourcePath?: string;
+ bundledBunPath?: string;
+ appVersion?: string;
runCommand?: RunCommand;
};
@@ -143,8 +145,40 @@ function needsWindowsShell(command: string): boolean {
return process.platform === 'win32' && /\.(cmd|bat)$/i.test(command);
}
-function quoteForWindowsShell(value: string): string {
- return `"${value.replace(/([&|<>^%!])/g, '^$1').replace(/"/g, '""')}"`;
+/*!
+ * Windows command escaping adapted from cross-spawn 7.0.6.
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Made With MOXY Lda
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+const WINDOWS_SHELL_META_CHARACTERS = /([()\][%!^"`<>&|;, *?])/g;
+
+// Quote for both cmd.exe and the Windows argv parser. The outer caret escapes
+// are consumed by cmd, leaving the quoted argument unchanged for the command.
+function escapeWindowsShellArgument(value: string): string {
+ const quotesEscaped = value
+ .replace(/(?=(\\+?)?)\1"/g, '$1$1\\"')
+ .replace(/(?=(\\+?)?)\1$/, '$1$1');
+ return `"${quotesEscaped}"`.replace(WINDOWS_SHELL_META_CHARACTERS, '^$1');
}
function createDefaultRunCommand(): RunCommand {
@@ -153,16 +187,24 @@ function createDefaultRunCommand(): RunCommand {
const useShell = needsWindowsShell(command);
let child: ReturnType;
try {
- child = useShell
- ? spawn(quoteForWindowsShell(command), args.map(quoteForWindowsShell), {
- env: options.env ?? process.env,
- windowsHide: false,
- shell: true,
- })
- : spawn(command, args, {
- env: options.env ?? process.env,
- windowsHide: false,
- });
+ const env = options.env ?? process.env;
+ if (useShell) {
+ const shellCommand = [
+ escapeWindowsShellArgument(command),
+ ...args.map(escapeWindowsShellArgument),
+ ].join(' ');
+ const commandProcessor = env.ComSpec ?? env.COMSPEC ?? process.env.ComSpec ?? 'cmd.exe';
+ child = spawn(commandProcessor, ['/d', '/s', '/v:off', '/c', `"${shellCommand}"`], {
+ env,
+ windowsHide: false,
+ windowsVerbatimArguments: true,
+ });
+ } else {
+ child = spawn(command, args, {
+ env,
+ windowsHide: false,
+ });
+ }
} catch (error) {
resolve({
exitCode: 1,
diff --git a/src/main/runtime/command-line-launcher.test.ts b/src/main/runtime/command-line-launcher.test.ts
index 68e516b4..97e29600 100644
--- a/src/main/runtime/command-line-launcher.test.ts
+++ b/src/main/runtime/command-line-launcher.test.ts
@@ -91,43 +91,54 @@ test('resolveBunInstallCommand prefers winget on Windows', () => {
test('default runCommand preserves Windows cmd metacharacter args', async (t) => {
if (process.platform !== 'win32') return;
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'subminer-cmd-args-'));
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'subminer cmd & 100% ! '));
const scriptPath = path.join(tempDir, 'argv.cmd');
- const outputPath = path.join(tempDir, 'argv.txt');
+ const argvScriptPath = path.join(tempDir, 'argv.js');
t.after(() => {
fs.rmSync(tempDir, { recursive: true, force: true });
});
+ fs.writeFileSync(
+ argvScriptPath,
+ 'process.stdout.write(JSON.stringify(process.argv.slice(2)));',
+ 'utf8',
+ );
fs.writeFileSync(
scriptPath,
[
'@echo off',
'setlocal DisableDelayedExpansion',
- '> "%SUBMINER_ARGV_OUT%" (',
- ' echo 1=%~1',
- ' echo 2=%~2',
- ' echo 3=%~3',
- ' echo 4=%~4',
- ' echo 5=%~5',
- ' echo 6=%~6',
- ')',
+ '"%SUBMINER_TEST_RUNTIME%" "%SUBMINER_ARGV_SCRIPT%" %*',
+ 'exit /b %errorlevel%',
'',
].join('\r\n'),
'utf8',
);
- const result = await getRunCommand({})(
- scriptPath,
- ['plain', 'has space', 'a&b', 'x|y', 'p%PATH%q', 'bang!z'],
- {
- env: { ...process.env, SUBMINER_ARGV_OUT: outputPath },
+ const args = [
+ 'plain',
+ 'has space',
+ 'a&b',
+ 'x|y',
+ 'p%TEMP%q',
+ 'bang!z',
+ 'caret^z',
+ '',
+ 'say "hi"',
+ 'slash\\"quote',
+ 'trailing\\',
+ '',
+ '日本語',
+ ];
+ const result = await getRunCommand({})(scriptPath, args, {
+ env: {
+ ...process.env,
+ SUBMINER_ARGV_SCRIPT: argvScriptPath,
+ SUBMINER_TEST_RUNTIME: process.execPath,
},
- );
+ });
assert.equal(result.exitCode, 0, result.stderr);
- assert.equal(
- fs.readFileSync(outputPath, 'utf8'),
- ['1=plain', '2=has space', '3=a&b', '4=x|y', '5=p%PATH%q', '6=bang!z', ''].join('\r\n'),
- );
+ assert.deepEqual(JSON.parse(result.stdout), args);
});
test('resolveBunInstallCommand falls back to scoop on Windows before official installer', () => {
@@ -189,7 +200,7 @@ test('resolveLauncherInstallTarget prefers writable user bin on Linux', async ()
assert.equal(target.installPath, '/home/tester/.local/bin/subminer');
});
-test('resolveLauncherInstallTarget returns not_installable without writable PATH dirs', async () => {
+test('resolveLauncherInstallTarget offers a user bin without writable PATH dirs', async () => {
const target = await resolveLauncherInstallTarget({
platform: 'linux',
homeDir: '/home/tester',
@@ -200,8 +211,9 @@ test('resolveLauncherInstallTarget returns not_installable without writable PATH
},
});
- assert.equal(target.status, 'not_installable');
- assert.equal(target.installPath, null);
+ assert.equal(target.status, 'not_installed');
+ assert.equal(target.installPath, '/home/tester/.local/bin/subminer');
+ assert.match(target.message ?? '', /export PATH=/);
});
test('resolveLauncherInstallTarget skips Homebrew bin for empty macOS manual installs', async () => {
diff --git a/src/main/runtime/command-line-launcher.ts b/src/main/runtime/command-line-launcher.ts
index 0194b4b5..eab7c053 100644
--- a/src/main/runtime/command-line-launcher.ts
+++ b/src/main/runtime/command-line-launcher.ts
@@ -1,6 +1,13 @@
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
+import {
+ cleanupOldWindowsManagedRuntimes,
+ isManagedLauncher,
+ managedLauncherContent,
+ shellQuote,
+ stageManagedLauncher,
+} from './managed-launcher';
import {
accessSyncOf,
envOf,
@@ -115,8 +122,13 @@ export function resolveBunInstallCommand(
}
export async function detectBun(options: CommonOptions = {}): Promise {
- const bunPath = findCommand('bun', options);
- const installCommand = resolveBunInstallCommand(options);
+ const bundled = options.bundledBunPath;
+ const bunPath = bundled
+ ? existsSyncOf(options)(bundled)
+ ? bundled
+ : null
+ : findCommand('bun', options);
+ const installCommand = bundled ? null : resolveBunInstallCommand(options);
if (!bunPath) {
return {
status: 'missing',
@@ -124,7 +136,9 @@ export async function detectBun(options: CommonOptions = {}): Promise {
@@ -201,19 +232,7 @@ export async function resolveLauncherInstallTarget(
const homeDir = options.homeDir ?? os.homedir();
const pathDirs = collectPathDirs(options);
- const preferred =
- platform === 'darwin'
- ? [
- '/opt/homebrew/bin',
- '/usr/local/bin',
- path.posix.join(homeDir, '.local', 'bin'),
- path.posix.join(homeDir, 'bin'),
- ]
- : [
- path.posix.join(homeDir, '.local', 'bin'),
- path.posix.join(homeDir, 'bin'),
- '/usr/local/bin',
- ];
+ const preferred = preferredLauncherDirs(platform, homeDir);
const manualPreferred =
platform === 'darwin'
? [
@@ -251,13 +270,15 @@ export async function resolveLauncherInstallTarget(
isWritableDir(dir, options),
);
if (!selected) {
+ const pathDir = path.posix.join(homeDir, '.local', 'bin');
+ const installPath = path.posix.join(pathDir, 'subminer');
return {
- status: 'not_installable',
- commandPath: null,
- installPath: null,
- pathDir: null,
+ status: existsSyncOf(options)(installPath) ? 'not_on_path' : 'not_installed',
+ commandPath: existsSyncOf(options)(installPath) ? installPath : null,
+ installPath,
+ pathDir,
shadowedBy: null,
- message: 'No writable directory was found on your command-line PATH.',
+ message: `Add ${pathDir} to your terminal PATH: export PATH=${shellQuote(pathDir)}:"$PATH". Save this in your shell configuration for future terminals.`,
};
}
const installPath = path.posix.join(selected, 'subminer');
@@ -283,7 +304,29 @@ export async function detectLauncher(
const launcherResourcePath = resolveLauncherResourcePath(options);
const appExePath = options.appExePath ?? process.execPath;
- if (platform === 'win32' && existsSyncOf(options)(expectedPath)) {
+ if (options.bundledBunPath && existsSyncOf(options)(expectedPath)) {
+ const content = String((options.readFileSync ?? fs.readFileSync)(expectedPath, 'utf8'));
+ if (!isManagedLauncher(content)) {
+ return {
+ ...target,
+ status: 'not_installed',
+ message: 'Reinstall the launcher to use the runtime included with SubMiner.',
+ };
+ }
+ if (
+ content !==
+ managedLauncherContent({
+ platform,
+ appPath: envOf(options).APPIMAGE ?? appExePath,
+ })
+ ) {
+ return {
+ ...target,
+ status: 'not_installed',
+ message: 'Reinstall the launcher to refresh its SubMiner location.',
+ };
+ }
+ } else if (platform === 'win32' && existsSyncOf(options)(expectedPath)) {
const content = String((options.readFileSync ?? fs.readFileSync)(expectedPath, 'utf8'));
if (!shimMatchesCurrentInstall(content, appExePath, launcherResourcePath)) {
return {
@@ -305,26 +348,19 @@ export async function detectLauncher(
}
if (!existsSyncOf(options)(expectedPath))
return { ...target, status: 'not_installed', commandPath: null };
- if (!commandPath) {
- return {
- ...target,
- status: 'not_on_path',
- commandPath: expectedPath,
- message: 'Launcher exists but its directory is not on PATH.',
- };
- }
-
const bunSnapshot = options.bunSnapshot ?? (await detectBun(options));
if (bunSnapshot.status !== 'ready') {
return {
...target,
status: 'installed_bun_missing',
commandPath,
- message: 'Launcher is installed, but Bun is missing. Install Bun, then open a new terminal.',
+ message: options.bundledBunPath
+ ? bunSnapshot.message
+ : 'Launcher is installed, but Bun is missing. Install Bun, then open a new terminal.',
};
}
- const result = await getRunCommand(options)(commandPath, ['--help'], {
+ const result = await getRunCommand(options)(expectedPath, ['--help'], {
timeoutMs: COMMAND_TIMEOUT_MS,
env: envOf(options) as NodeJS.ProcessEnv,
});
@@ -336,6 +372,16 @@ export async function detectLauncher(
message: failureMessage(result, 'subminer --help failed'),
};
}
+ if (!commandPath) {
+ return {
+ ...target,
+ status: 'not_on_path',
+ commandPath: expectedPath,
+ message:
+ target.message ??
+ `Launcher installed. Add ${target.pathDir} to your terminal PATH: export PATH=${shellQuote(target.pathDir ?? '')}:"$PATH". Save this in your shell configuration for future terminals.`,
+ };
+ }
return { ...target, status: 'ready', commandPath, message: null };
}
@@ -354,6 +400,48 @@ export async function installLauncher(
};
}
+ if (options.bundledBunPath) {
+ const bun = await detectBun(options);
+ if (bun.status !== 'ready')
+ return {
+ ...target,
+ status: 'failed',
+ message: bun.message ?? 'The included launcher runtime failed to start.',
+ };
+ try {
+ stageManagedLauncher({
+ ...options,
+ bundledBunPath: options.bundledBunPath,
+ launcherResourcePath,
+ force: true,
+ });
+ (options.mkdirSync ?? fs.mkdirSync)(target.pathDir, { recursive: true });
+ (options.writeFileSync ?? fs.writeFileSync)(
+ target.installPath,
+ managedLauncherContent({
+ platform,
+ appPath: envOf(options).APPIMAGE ?? options.appExePath ?? process.execPath,
+ }),
+ );
+ (options.chmodSync ?? fs.chmodSync)(target.installPath, 0o755);
+ if (platform === 'win32') {
+ cleanupOldWindowsManagedRuntimes(options);
+ const nextPath = await appendWindowsUserPathDir(target.pathDir, options);
+ if (nextPath && options.env) {
+ options.env.PATH = nextPath;
+ options.env.Path = nextPath;
+ }
+ }
+ return await detectLauncher({ ...options, bunSnapshot: bun });
+ } catch (error) {
+ return {
+ ...target,
+ status: 'failed',
+ message: error instanceof Error ? error.message : String(error),
+ };
+ }
+ }
+
if (platform === 'win32') {
(options.mkdirSync ?? fs.mkdirSync)(target.pathDir, { recursive: true });
(options.writeFileSync ?? fs.writeFileSync)(
@@ -375,6 +463,8 @@ export async function installLauncher(
};
}
} else {
+ if (!existsSyncOf(options)(target.pathDir))
+ (options.mkdirSync ?? fs.mkdirSync)(target.pathDir, { recursive: true });
(options.copyFileSync ?? fs.copyFileSync)(launcherResourcePath, target.installPath);
(options.chmodSync ?? fs.chmodSync)(target.installPath, 0o755);
}
@@ -384,6 +474,7 @@ export async function installLauncher(
export async function installBun(
options: CommonOptions & WindowsPathOptions = {},
): Promise {
+ if (options.bundledBunPath) return detectBun(options);
const platform = platformOf(options);
if (platform === 'win32') {
const bunDir = defaultBunRepairPath(options);
@@ -455,6 +546,84 @@ export async function installBun(
};
}
+// Runs at app startup. Migrates recognized launchers in the standard bin dirs,
+// the setup install target, and any paths a deferred update handed over.
+// Returns paths that were refreshed or are no longer eligible for migration.
+export async function refreshManagedCommandLineLauncher(
+ options: CommonOptions & WindowsPathOptions & { additionalLauncherPaths?: string[] },
+): Promise {
+ if (!options.bundledBunPath) return [];
+ const target = await resolveLauncherInstallTarget(options);
+ const platform = platformOf(options);
+ const platformPath = pathModuleFor(platform);
+ // cmd.exe reads a batch file incrementally while it runs, so the launcher that
+ // started this app is left alone until a later app start rewrites it.
+ const runningLauncherPath =
+ platform === 'win32' ? envOf(options).SUBMINER_LAUNCHER_PATH : undefined;
+ const isRunningLauncher = (candidate: string) =>
+ runningLauncherPath !== undefined &&
+ platformPath.normalize(candidate).toLowerCase() ===
+ platformPath.normalize(runningLauncherPath).toLowerCase();
+ const candidates = new Set([
+ ...(target.installPath ? [target.installPath] : []),
+ ...(options.additionalLauncherPaths ?? []),
+ ...(platform === 'win32'
+ ? []
+ : preferredLauncherDirs(platform, options.homeDir ?? os.homedir()).map((directory) =>
+ path.posix.join(directory, 'subminer'),
+ )),
+ ]);
+ const readFile = options.readFileSync ?? fs.readFileSync;
+ const acknowledgedPaths: string[] = [];
+ let payload: ReturnType | undefined;
+ for (const candidate of candidates) {
+ if (isRunningLauncher(candidate)) continue;
+ if (!existsSyncOf(options)(candidate)) {
+ acknowledgedPaths.push(candidate);
+ continue;
+ }
+ let existing: string;
+ try {
+ existing = String(readFile(candidate, 'utf8'));
+ } catch {
+ continue;
+ }
+ const legacy =
+ (existing.startsWith('#!/usr/bin/env bun\n') &&
+ (existing.includes('SubMiner launcher') ||
+ existing.includes('Launch MPV with SubMiner'))) ||
+ (platform === 'win32' &&
+ existing ===
+ windowsShimContent(
+ options.appExePath ?? process.execPath,
+ resolveLauncherResourcePath(options).replace(/subminer\.js$/, 'subminer'),
+ ));
+ if (!isManagedLauncher(existing) && !legacy) {
+ acknowledgedPaths.push(candidate);
+ continue;
+ }
+ if (!isWritableDir(pathModuleFor(platform).dirname(candidate), options)) continue;
+ try {
+ accessSyncOf(options)(candidate, fs.constants.W_OK);
+ } catch {
+ continue;
+ }
+ payload ??= stageManagedLauncher({
+ ...options,
+ bundledBunPath: options.bundledBunPath,
+ launcherResourcePath: resolveLauncherResourcePath(options),
+ });
+ const content = managedLauncherContent({
+ platform,
+ appPath: envOf(options).APPIMAGE ?? options.appExePath ?? process.execPath,
+ });
+ if (existing !== content) (options.writeFileSync ?? fs.writeFileSync)(candidate, content);
+ acknowledgedPaths.push(candidate);
+ }
+ if (platform === 'win32' && payload) cleanupOldWindowsManagedRuntimes(options);
+ return acknowledgedPaths;
+}
+
export async function detectCommandLineLauncher(
options: CommonOptions & WindowsPathOptions = {},
): Promise {
diff --git a/src/main/runtime/first-run-setup-window.test.ts b/src/main/runtime/first-run-setup-window.test.ts
index e62dc335..024ff27e 100644
--- a/src/main/runtime/first-run-setup-window.test.ts
+++ b/src/main/runtime/first-run-setup-window.test.ts
@@ -271,7 +271,7 @@ test('parseFirstRunSetupSubmissionUrl parses supported custom actions', () => {
assert.equal(parseFirstRunSetupSubmissionUrl('https://example.com'), null);
});
-test('buildFirstRunSetupHtml renders command-line launcher section and actions', () => {
+test('buildFirstRunSetupHtml reports a broken included runtime in the optional launcher controls', () => {
const html = buildFirstRunSetupHtml({
configReady: true,
dictionaryCount: 1,
@@ -294,9 +294,9 @@ test('buildFirstRunSetupHtml renders command-line launcher section and actions',
status: 'failed',
commandPath: null,
version: null,
- installMethod: 'official-script',
- installCommand: ['bash', '-lc', 'curl -fsSL https://bun.com/install | bash'],
- message: 'network failed',
+ installMethod: null,
+ installCommand: null,
+ message: 'Included Bun runtime is missing.',
},
launcher: {
status: 'installed_bun_missing',
@@ -311,14 +311,11 @@ test('buildFirstRunSetupHtml renders command-line launcher section and actions',
});
assert.match(html, /Command line launcher/);
- assert.match(html, /Optional\. Setup can finish without Bun or the launcher\./);
- assert.match(html, /Bun runtime/);
+ assert.match(html, /Optional\. Install the launcher to use SubMiner from your terminal\./);
assert.match(html, /Failed/);
- assert.match(html, /bash -lc curl -fsSL https:\/\/bun\.com\/install \| bash/);
- assert.match(html, /Install Bun/);
- assert.match(html, /action=install-bun/);
assert.match(html, /SubMiner launcher/);
- assert.match(html, /Installed, Bun missing/);
+ assert.match(html, /Reinstall SubMiner to repair it/);
+ assert.match(html, /