Try every layout we know about for `worker_host.js`, dev or bundled: 1. `CARGO_MANIFEST_DIR/resources/worker_host.js` — `cargo run` / `tauri dev`. 2. ` /resources/worker_host.js` — generic side-by-side bundle. 3. ` /../Resources/resources/worker_host.js` — macOS `.app` (Tauri copies bundle.resources into `Contents/Resources/`). 4. ` /../Resources/worker_host.js` — flat macO
()
| 519 | /// 5. `<exe_dir>/../lib/<bin>/resources/worker_host.js` — typical Linux deb/AppImage. |
| 520 | /// 6. `<exe_dir>/../share/<bin>/resources/worker_host.js` — alt Linux layout. |
| 521 | fn resolve_worker_host_path() -> Option<std::path::PathBuf> { |
| 522 | let mut candidates: Vec<std::path::PathBuf> = Vec::new(); |
| 523 | |
| 524 | candidates.push( |
| 525 | std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) |
| 526 | .join("resources") |
| 527 | .join("worker_host.js"), |
| 528 | ); |
| 529 | |
| 530 | if let Ok(exe) = std::env::current_exe() { |
| 531 | if let Some(exe_dir) = exe.parent() { |
| 532 | candidates.push(exe_dir.join("resources").join("worker_host.js")); |
| 533 | if let Some(parent) = exe_dir.parent() { |
| 534 | candidates.push( |
| 535 | parent |
| 536 | .join("Resources") |
| 537 | .join("resources") |
| 538 | .join("worker_host.js"), |
| 539 | ); |
| 540 | candidates.push(parent.join("Resources").join("worker_host.js")); |
| 541 | if let Some(bin_name) = exe.file_name().and_then(|s| s.to_str()) { |
| 542 | candidates.push( |
| 543 | parent |
| 544 | .join("lib") |
| 545 | .join(bin_name) |
| 546 | .join("resources") |
| 547 | .join("worker_host.js"), |
| 548 | ); |
| 549 | candidates.push( |
| 550 | parent |
| 551 | .join("share") |
| 552 | .join(bin_name) |
| 553 | .join("resources") |
| 554 | .join("worker_host.js"), |
| 555 | ); |
| 556 | } |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | candidates.into_iter().find(|p| p.exists()) |
| 562 | } |