mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
Fix desktop app not being able to load pdfium (#6575)
# Description of Changes The changes in [#6279](https://github.com/Stirling-Tools/Stirling-PDF/pull/6279) broke the desktop app because the wasm URL handling didn't deal with `tauri://` paths. Also I noticed that `task desktop:build:dev:mac` failed locally because it was attempting to sign the app with credentials that developers won't have (and shouldn't need), so I fixed that too.
This commit is contained in:
@@ -62,21 +62,21 @@ tasks:
|
|||||||
deps: [prepare]
|
deps: [prepare]
|
||||||
dir: editor
|
dir: editor
|
||||||
cmds:
|
cmds:
|
||||||
- npx tauri build --bundles app
|
- npx tauri build --bundles app --config '{"bundle":{"createUpdaterArtifacts":false}}'
|
||||||
|
|
||||||
build:dev:windows:
|
build:dev:windows:
|
||||||
desc: "Build Tauri desktop NSIS installer (Windows)"
|
desc: "Build Tauri desktop NSIS installer (Windows)"
|
||||||
deps: [prepare]
|
deps: [prepare]
|
||||||
dir: editor
|
dir: editor
|
||||||
cmds:
|
cmds:
|
||||||
- npx tauri build --bundles nsis
|
- npx tauri build --bundles nsis --config '{"bundle":{"createUpdaterArtifacts":false}}'
|
||||||
|
|
||||||
build:dev:linux:
|
build:dev:linux:
|
||||||
desc: "Build Tauri desktop AppImage (Linux)"
|
desc: "Build Tauri desktop AppImage (Linux)"
|
||||||
deps: [prepare]
|
deps: [prepare]
|
||||||
dir: editor
|
dir: editor
|
||||||
cmds:
|
cmds:
|
||||||
- npx tauri build --bundles appimage
|
- npx tauri build --bundles appimage --config '{"bundle":{"createUpdaterArtifacts":false}}'
|
||||||
|
|
||||||
test:
|
test:
|
||||||
desc: "Run Tauri/Cargo tests"
|
desc: "Run Tauri/Cargo tests"
|
||||||
|
|||||||
@@ -2,22 +2,19 @@ import { BASE_PATH } from "@app/constants/app";
|
|||||||
import pdfiumWasmAssetUrl from "@embedpdf/pdfium/pdfium.wasm?url";
|
import pdfiumWasmAssetUrl from "@embedpdf/pdfium/pdfium.wasm?url";
|
||||||
|
|
||||||
const getWasmUrl = (): string => {
|
const getWasmUrl = (): string => {
|
||||||
if (
|
// In dev, Vite serves the statically-copied asset from the dev server root.
|
||||||
pdfiumWasmAssetUrl.startsWith("http://") ||
|
|
||||||
pdfiumWasmAssetUrl.startsWith("https://") ||
|
|
||||||
pdfiumWasmAssetUrl.startsWith("//")
|
|
||||||
) {
|
|
||||||
return pdfiumWasmAssetUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
||||||
if (import.meta.env.DEV) {
|
if (import.meta.env.DEV) {
|
||||||
|
const origin = typeof window !== "undefined" ? window.location.origin : "";
|
||||||
return `${origin}${BASE_PATH}/pdfium/pdfium.wasm`;
|
return `${origin}${BASE_PATH}/pdfium/pdfium.wasm`;
|
||||||
}
|
}
|
||||||
const cleanAssetUrl = pdfiumWasmAssetUrl
|
|
||||||
.replace(/^\.\//, "")
|
// Vite has already produced a base-aware asset URL (absolute under a relative
|
||||||
.replace(/^\//, "");
|
// base, root-relative under an absolute base). Resolve it against the document
|
||||||
return `${origin}${BASE_PATH}/${cleanAssetUrl}`;
|
// to get a fetchable absolute URL that is also safe to pass to Web Workers.
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
return new URL(pdfiumWasmAssetUrl, window.location.href).href;
|
||||||
|
}
|
||||||
|
return pdfiumWasmAssetUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const pdfiumWasmUrl = getWasmUrl();
|
export const pdfiumWasmUrl = getWasmUrl();
|
||||||
|
|||||||
Reference in New Issue
Block a user