Pake icon indicating copy to clipboard operation
Pake copied to clipboard

[Bug] window.print() fails on macOS: "webview.print not allowed" (missing core:webview:allow-print permission)

Open nhanntgit opened this issue 2 months ago • 2 comments

Search before asking

  • [x] I searched in the issues and found nothing similar.

Pake version

Search before asking

  • [x] I searched in the issues and found nothing similar.

Pake version

<3.17.2>

Rust version

rustc 1.98.1 (48a229cea 2026-09-01)

Package Manager

npm

System version

macOS <14.4.1> (Apple Silicon)

Node.js version

<v24.21.0>

Build Command

pake --config app.json --debug

app.json:

{
  "url": "./dist",
  "name": "MyApp",
  "hideTitleBar": true
}

Minimal reproduce step

  1. Create a local page test/index.html:
<!doctype html>
<html>
<body>
  <button onclick="window.print()">Print</button>
</body>
</html>
  1. Package it: pake ./test --name PakeTest --debug
  2. Open the app and click the Print button.

What did you expect to see?

The native macOS print dialog opens.

What did you see instead?

Nothing happens. The DevTools console shows:

Unhandled Promise Rejection: webview.print not allowed. Permissions associated with this command: core:webview:allow-print

Anything else?

Adding "core:webview:allow-print" to the permissions array in src-tauri/capabilities/default.json of the installed pake-cli and rebuilding fixes it: the print dialog opens and printing works.

Could this permission be included by default? Many web apps rely on window.print() (invoices, reports, tickets).

Possibly related: in the same build, window.alert(), window.confirm() and window.prompt() also do not show any dialog on macOS. I can open a separate issue for that if you prefer.

Are you willing to submit a PR?

  • [ ] I'm willing to submit a PR!

Rust version

rustc 1.98.1 (48a229cea 2026-09-01)

Package Manager

npm

System version

macOS <14.x> (Apple Silicon)

Node.js version

<v24.21.0>

Build Command

pake --config app.json --debug

app.json:

{
  "url": "./dist",
  "name": "MyApp",
  "hideTitleBar": true
}

Minimal reproduce step

  1. Create a local page test/index.html:
<!doctype html>
<html>
<body>
  <button onclick="window.print()">Print</button>
</body>
</html>
  1. Package it: pake ./test --name PakeTest --debug
  2. Open the app and click the Print button.

What did you expect to see?

The native macOS print dialog opens.

What did you see instead?

Nothing happens. The DevTools console shows:

Unhandled Promise Rejection: webview.print not allowed. Permissions associated with this command: core:webview:allow-print

Anything else?

Adding "core:webview:allow-print" to the permissions array in src-tauri/capabilities/default.json of the installed pake-cli and rebuilding fixes it: the print dialog opens and printing works.

Could this permission be included by default? Many web apps rely on window.print() (invoices, reports, tickets).

Possibly related: in the same build, window.alert(), window.confirm() and window.prompt() also do not show any dialog on macOS. I can open a separate issue for that if you prefer.

Are you willing to submit a PR?

  • [x] I'm willing to submit a PR!

nhanntgit avatar Sep 25 '26 08:09 nhanntgit

Try adding the following entry under permissions in src-tauri/capabilities/default.json:

"permissions": [
  "core:webview:allow-print"
]

Then rebuild the application and confirm whether this resolves the issue. This feature works on Windows without any additional configuration, so I’m unable to reproduce or verify the issue there.

WavesMan avatar Sep 29 '26 01:09 WavesMan

@nhanntgit Thanks for the clear report and the permission hint. pake-cli 3.17.3 grants the print permission, so window.print() now opens the macOS print dialog on local pages like your ./dist app and on the exact site you package, while other origins stay blocked.

Run npm install -g [email protected], rebuild with pake --config app.json, and click Print again. The alert/confirm/prompt behavior you mentioned is separate; if it still fails, open a new issue with a small page that shows it. I'm closing this one, and I'll reopen it if printing still doesn't work.

tw93 avatar Oct 04 '26 11:10 tw93