Skip to content

Commit

Permalink
Fix attachment rendering
Browse files Browse the repository at this point in the history
In `tauri build` anyway, still doesn't work in `tauri dev`.
  • Loading branch information
OJFord committed May 14, 2024
1 parent c0bbb4f commit 84c0970
Show file tree
Hide file tree
Showing 6 changed files with 479 additions and 546 deletions.
11 changes: 9 additions & 2 deletions eml-client/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"dependencies": {
"pdfjs-dist": "^3.11.174"
},
"devDependencies": {
"@fortawesome/fontawesome-svg-core": "^6.5.2",
"@fortawesome/free-solid-svg-icons": "^6.5.2",
Expand All @@ -17,17 +20,21 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-svelte": "^2.37.0",
"ical.js": "^1.5.0",
"pdfjs-dist": "4.1.392",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"sass": "^1.75.0",
"svelte": "^4.2.15",
"svelte-pdfjs": "^0.6.3",
"svelte-pdfjs": "^0.8.0",
"vite": "^5.2.10"
},
"engines": {
"node": ">=16.0.0"
},
"private": true,
"scripts": {
"vite:build:debug-false": "vite build --debug --mode=production",
"vite:build:debug-true": "vite build --debug --mode=development",
"vite:dev": "vite --clearScreen=false --debug"
},
"type": "module"
}
29 changes: 0 additions & 29 deletions eml-client/src-tauri/src/build.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
use std::env;
use std::process::Command;
use std::process::Stdio;

fn main() {
Command::new("yarn")
.args(["--cwd=.."])
.stderr(Stdio::inherit())
.stdout(Stdio::inherit())
.output()
.expect("failed to execute yarn");

Command::new("rm")
.args(["-r", "../dist/assets", "../dist/index.html"])
.stderr(Stdio::inherit())
.stdout(Stdio::inherit())
.output()
.expect("failed to clean previous build");

Command::new("yarn")
.env(
"DEBUG",
format!("{}", env::var("PROFILE") != Ok("release".into())),
)
.args(["--cwd=..", "vite", "build"])
.stderr(Stdio::inherit())
.stdout(Stdio::inherit())
.output()
.expect("failed to execute vite");

tauri_build::build()
}
13 changes: 9 additions & 4 deletions eml-client/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,22 @@
}
},
"build": {
"beforeDevCommand": "DEBUG=true yarn --cwd=.. vite --clearScreen=false --port=42411",
"frontendDist": "../dist",
"devUrl": "http://localhost:42411"
"beforeBuildCommand": "rm -r ../dist; yarn --cwd=..; yarn --cwd=.. vite:build:debug-${TAURI_ENV_DEBUG:-false}",
"beforeDevCommand": "yarn --cwd=..; yarn --cwd=.. vite:dev --port=42411",
"devUrl": "http://localhost:42411",
"frontendDist": "../dist"
},
"productName": "amail",
"version": "0.0.0",
"identifier": "com.ojford.amail.eml-client",
"plugins": {},
"app": {
"security": {
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'; connect-src ipc: http://ipc.localhost"
"csp": {
"default-src": "blob: data: filesystem: tauri: 'self'",
"connect-src": "ipc://localhost data:",
"style-src": "'unsafe-inline' tauri:"
}
},
"windows": [
{
Expand Down
12 changes: 10 additions & 2 deletions eml-client/src/components/PdfAttachmentViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
} from "svelte-pdfjs"
import {
set_pdfjs_context,
} from "svelte-pdfjs/utils/vite"
} from "svelte-pdfjs/vite"
export let b64Data
Expand All @@ -36,11 +36,19 @@
break
}
}
const loadOptions = {
isEvalSupported: false,
}
</script>
<svelte:window on:keydown={handleKey} />
<Document file={docUrl} on:loadsuccess={(ev) => (doc = ev.detail)}>
<Document
file={docUrl}
{loadOptions}
on:loadsuccess={(ev) => (doc = ev.detail)}
>
<div>
<Page {scale} num={pageNumber} />
Expand Down
3 changes: 3 additions & 0 deletions eml-client/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default defineConfig({
esbuildOptions: {
target: "esnext",
},
exclude: [
"pdfjs-dist",
],
},

plugins: [
Expand Down
Loading

0 comments on commit 84c0970

Please sign in to comment.