fix: global API script should reuse window.__TAURI__ types (#3602)

currently each script inlines what it needs from @tauri-apps/api, so type checks like `image instanceof Image` all fail
This commit is contained in:
Lucas Fernandes Nogueira
2026-09-22 06:04:28 -03:00
committed by GitHub
parent 5baf71a472
commit ae3c808eb6
29 changed files with 98 additions and 28 deletions
+1 -1
View File
@@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARD_MANAGER__=function(e){"use strict";var n;async function t(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}"function"==typeof SuppressedError&&SuppressedError;class r{get rid(){return function(e,n,t,r){if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(e):r?r.value:n.get(e)}(this,n,"f")}constructor(e){n.set(this,void 0),function(e,n,t){if("function"==typeof n||!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");n.set(e,t)}(this,n,e)}async close(){return t("plugin:resources|close",{rid:this.rid})}}n=new WeakMap;class a extends r{constructor(e){super(e)}static async new(e,n,r){return t("plugin:image|new",{rgba:i(e),width:n,height:r}).then(e=>new a(e))}static async fromBytes(e){return t("plugin:image|from_bytes",{bytes:i(e)}).then(e=>new a(e))}static async fromPath(e){return t("plugin:image|from_path",{path:e}).then(e=>new a(e))}async rgba(){return t("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return t("plugin:image|size",{rid:this.rid})}}function i(e){return null==e?null:"string"==typeof e?e:e instanceof a?e.rid:e}return e.clear=async function(){await t("plugin:clipboard-manager|clear")},e.readImage=async function(){return await t("plugin:clipboard-manager|read_image").then(e=>new a(e))},e.readText=async function(){return await t("plugin:clipboard-manager|read_text")},e.writeHtml=async function(e,n){await t("plugin:clipboard-manager|write_html",{html:e,altText:n})},e.writeImage=async function(e){await t("plugin:clipboard-manager|write_image",{image:i(e)})},e.writeText=async function(e,n){await t("plugin:clipboard-manager|write_text",{label:n?.label,text:e})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARD_MANAGER__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARD_MANAGER__=function(a,e,n){"use strict";return a.clear=async function(){await e.invoke("plugin:clipboard-manager|clear")},a.readImage=async function(){return await e.invoke("plugin:clipboard-manager|read_image").then(a=>new n.Image(a))},a.readText=async function(){return await e.invoke("plugin:clipboard-manager|read_text")},a.writeHtml=async function(a,n){await e.invoke("plugin:clipboard-manager|write_html",{html:a,altText:n})},a.writeImage=async function(a){await e.invoke("plugin:clipboard-manager|write_image",{image:n.transformImage(a)})},a.writeText=async function(a,n){await e.invoke("plugin:clipboard-manager|write_text",{label:n?.label,text:a})},a}({},window.__TAURI__.core,window.__TAURI__.image);Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARD_MANAGER__})}