tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
81.61k stars 2.44k forks source link

[bug] data-tauri-drag-region not working when in isolation mode #5868

Open linonetwo opened 1 year ago

linonetwo commented 1 year ago

Describe the bug

If we have

  "tauri": {
    "pattern": {
      "use": "isolation",
      "options": {
        "dir": "../dist/preload"
      }
    },

Then <div data-tauri-drag-region="true"> won't work. And delete "use": "isolation", makes it work again.

Reproduction

  1. an existed example app with data-tauri-drag-region
  2. can drag
  3. add isolation config
  4. can't drag

Expected behavior

Always can drag

Platform and versions

Environment › OS: Mac OS 13.0.1 X64 › Node.js: 18.12.1 › npm: 8.19.2 › pnpm: 7.18.2 › yarn: 1.22.4 › rustup: 1.25.1 › rustc: 1.65.0 › cargo: 1.65.0 › Rust toolchain: stable-x86_64-apple-darwin

Packages › @tauri-apps/cli [NPM]: 1.2.1 (outdated, latest: 1.2.2) › @tauri-apps/api [NPM]: 1.2.0 › tauri [RUST]: 1.2.1, › tauri-build [RUST]: 1.2.1, › tao [RUST]: 0.15.6, › wry [RUST]: 0.22.5,

App › build-type: bundle › CSP: default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self' › distDir: ../dist › devPath: http://localhost:1420/ › framework: React

App directory structure ├─ dist ├─ node_modules ├─ src-affine ├─ public ├─ scripts ├─ src-tauri ├─ .git ├─ .vscode └─ src

Stack trace

No response

Additional context

And this don't have a proper ts type, and can't log anything

window.__TAURI_ISOLATION_HOOK__ = payload => {
  // eslint-disable-next-line no-console
  console.log('Tauri isolation hook', payload);

  return payload;
};

export {};

// TODO: find official typings if available
type IsolationPayload = unknown;

declare global {
  interface Window {
    __TAURI_ISOLATION_HOOK__: (payload: IsolationPayload) => IsolationPayload;
  }
}
linonetwo commented 1 year ago

This isolation mode is very difficult to use, normally we will load "devPath": "http://localhost:1420",provided by Vite, so we won't load HTML in the  "dir": "../dist/preload" , this is confusing.

linonetwo commented 1 year ago

And I'd like to load arbitrary HTML in the public folder after build, which will replace the HTML in the  "dir": "../dist/preload", will preload still work?

lucasfernog commented 1 year ago

Can you share an example we can use to reproduce it? I couldn't do it using our isolation example.