feat: embed daemon JS in binary, eliminate npm install of camoufox-browser
The daemon JS files (daemon.js, server.js, browser.js, protocol.js, snapshot.js, ipc.js) are now EMBEDDED in the compiled Rust binary via include_dir! and extracted to ~/.gyandoot/daemon/ on first run. This eliminates the need to npm install -g camoufox-browser@0.1.0, which bundles an incompatible camoufox-js@0.9.3 that caused: - 'Cannot open database' errors - Re-downloading 298MB browser on every navigation - Circular install/remove/install loops Now the daemon imports camoufox-js from the global npm install (v0.11.0) which is installed by install.sh. Clean, no bundled deps, no conflicts. Also removed: is_npm_package_installed(), install_npm_package(), find_daemon_js() — all replaced by gyandoot_browser::daemon::extract_daemon()
This commit is contained in:
28
install.sh
28
install.sh
@@ -218,34 +218,18 @@ install_camoufox_browser() {
|
||||
|
||||
if ! command -v npx &>/dev/null && ! command -v npm &>/dev/null; then
|
||||
warn "Node.js not found. Skipping Camoufox install."
|
||||
warn "Install Node.js and re-run: npm install -g camoufox-browser@0.1.0"
|
||||
warn "Install Node.js and re-run: npm install -g camoufox-js@0.11.0 && npx --yes camoufox-js@0.11.0 fetch"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Step 1: Install npm package (daemon)
|
||||
info "Installing npm package (camoufox-browser@0.1.0)..."
|
||||
npm install -g camoufox-browser@0.1.0 2>&1 | tail -3 || {
|
||||
warn "npm install failed. Try manually: npm install -g camoufox-browser@0.1.0"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Step 2: Override bundled camoufox-js@0.9.3 with v0.11.0
|
||||
# The daemon does: import("camoufox-js") — Node resolves this from
|
||||
# the daemon's own node_modules/ FIRST, before checking global.
|
||||
# So we must REMOVE the bundled copy so Node falls through to global.
|
||||
info "Upgrading bundled camoufox-js to v0.11.0 (daemon dependency)..."
|
||||
local cb_pkg
|
||||
cb_pkg="$(npm root -g 2>/dev/null)/camoufox-browser"
|
||||
if [ -d "$cb_pkg/node_modules/camoufox-js" ]; then
|
||||
rm -rf "$cb_pkg/node_modules/camoufox-js"
|
||||
ok "Removed bundled camoufox-js@0.9.3 from daemon package"
|
||||
fi
|
||||
# Ensure global v0.11.0 exists
|
||||
# Step 1: Install camoufox-js globally (daemon imports this at runtime)
|
||||
info "Installing camoufox-js@0.11.0 (browser engine)..."
|
||||
npm install -g camoufox-js@0.11.0 2>&1 | tail -3 || {
|
||||
warn "Failed to install camoufox-js@0.11.0 globally"
|
||||
warn "npm install failed. Try manually: npm install -g camoufox-js@0.11.0"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Step 3: Download browser binary
|
||||
# Step 2: Download browser binary
|
||||
info "Downloading Camoufox browser binary (~311MB)..."
|
||||
npx --yes camoufox-js@0.11.0 fetch 2>&1 || {
|
||||
warn "Download failed. Try manually: npx --yes camoufox-js@0.11.0 fetch"
|
||||
|
||||
Reference in New Issue
Block a user