Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: apply fuses in dev
  • Loading branch information
iamEvanYT committed Mar 27, 2026
commit 6b2c5aa8afa5302ba0c27c968453dbb40391858d
13 changes: 10 additions & 3 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/contributing/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ These dependencies are either used in the build process, or they are only used i
- cmdk - Used for building command menus.
- string-similarity-js - Use for fuzzy matching.
- hono - Used for handling and routing custom protocols. (Used and bundled into the main process)
- @electron/fuses - Used for flipping development fuses.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"script:upgrade-electron-to-next": "bun run scripts/electron-upgrader/next.ts",
"script:generate-frontend-routes": "bun run scripts/frontend-routes-generator/generator.ts --run-as-script",
"script:prune-frontend-routes": "bun run scripts/frontend-routes-generator/pruner.ts",
"postinstall": "electron-builder install-app-deps",
"script:apply-dev-fuses": "bun run scripts/apply-dev-fuses.ts",
"postinstall": "electron-builder install-app-deps && bun run script:apply-dev-fuses",
"reset": "rm -rf dist && rm -rf out && rm -rf yalc.lock && rm -rf .yalc && rm -rf node_modules && bun pm cache rm && echo 'Reset complete!'"
},
"dependencies": {
Expand Down Expand Up @@ -61,6 +62,7 @@
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
"@electron-toolkit/eslint-config-ts": "^3.1.0",
"@electron-toolkit/tsconfig": "^2.0.0",
"@electron/fuses": "^2.1.1",
"@headlessui/react": "^2.2.3",
"@iamevan/react-resizable-panels": "^3.0.7",
"@pdfslick/react": "^3.0.0",
Expand Down
36 changes: 36 additions & 0 deletions scripts/apply-dev-fuses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { spawnSync } from "node:child_process";
import { flipFuses, FuseVersion, FuseV1Options } from "@electron/fuses";

// Get the path to the electron binary
function getElectronPath(): string {
// eslint-disable-next-line @typescript-eslint/no-require-imports
return require("electron");
}

const appPath = getElectronPath();

// Apply dev fuses
const result = await flipFuses(appPath, {
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
// Differs from production: used for debugging
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: true,
// Differs from production: used for debugging
[FuseV1Options.EnableNodeCliInspectArguments]: true,
// Differs from production: development runs the app from source, not asar archive
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
// Differs from production: development runs the app from source, not asar archive
[FuseV1Options.OnlyLoadAppFromAsar]: false,
[FuseV1Options.LoadBrowserProcessSpecificV8Snapshot]: false,
[FuseV1Options.GrantFileProtocolExtraPrivileges]: true
});
console.log("Dev fuses applied successfully:", result ? "true" : "false");

// Shows the current fuses (same as `bunx @electron/fuses read --app <appPath>`)
const read = spawnSync("bunx", ["@electron/fuses", "read", "--app", appPath], {
stdio: "inherit"
});
if (read.status !== 0) {
process.exit(read.status ?? 1);
}
Loading