mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-23 11:36:13 +02:00
fix(os): use an internal object instead of ` window.__TAURI__`, closes #719
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"os": "patch"
|
||||
"os-js": "patch"
|
||||
---
|
||||
|
||||
Fix `Uncaught TypeError: Cannot read properties of undefined (reading 'os')`
|
||||
|
||||
@@ -8,6 +8,7 @@ rust-version = { workspace = true }
|
||||
license = "Apache-2.0 OR MIT"
|
||||
|
||||
[lib]
|
||||
name = "api_lib"
|
||||
crate-type = [ "staticlib", "cdylib", "rlib" ]
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#![cfg_attr(
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
mod cmd;
|
||||
#[cfg(desktop)]
|
||||
mod tray;
|
||||
|
||||
@@ -6,6 +6,5 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
#[cfg(desktop)]
|
||||
api::run();
|
||||
api_lib::run();
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import { invoke } from "@tauri-apps/api/primitives";
|
||||
/** @ignore */
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI__: {
|
||||
os: { __eol: string };
|
||||
__TAURI_OS_PLUGIN_INTERNALS__: {
|
||||
eol: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ type Arch =
|
||||
* @since 2.0.0
|
||||
* */
|
||||
function eol() {
|
||||
return window.__TAURI__.os.__eol;
|
||||
return window.__TAURI_OS_PLUGIN_INTERNALS__.eol;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1 +1 @@
|
||||
if("__TAURI__"in window){var __TAURI_OS__=function(n){"use strict";async function o(n,o={},e){return window.__TAURI_INTERNALS__.invoke(n,o,e)}return"function"==typeof SuppressedError&&SuppressedError,n.arch=async function(){return o("plugin:os|arch")},n.eol=function(){return window.__TAURI__.os.__eol},n.exeExtension=async function(){return o("plugin:os|exe_extension")},n.family=async function(){return o("plugin:os|family")},n.hostname=async function(){return o("plugin:os|hostname")},n.locale=async function(){return o("plugin:os|locale")},n.platform=async function(){return o("plugin:os|platform")},n.type=async function(){return o("plugin:os|os_type")},n.version=async function(){return o("plugin:os|version")},n}({});Object.defineProperty(window.__TAURI__,"os",{value:__TAURI_OS__})}
|
||||
if("__TAURI__"in window){var __TAURI_OS__=function(n){"use strict";async function o(n,o={},e){return window.__TAURI_INTERNALS__.invoke(n,o,e)}return"function"==typeof SuppressedError&&SuppressedError,n.arch=async function(){return o("plugin:os|arch")},n.eol=function(){return window.__TAURI_OS_PLUGIN_INTERNALS__.eol},n.exeExtension=async function(){return o("plugin:os|exe_extension")},n.family=async function(){return o("plugin:os|family")},n.hostname=async function(){return o("plugin:os|hostname")},n.locale=async function(){return o("plugin:os|locale")},n.platform=async function(){return o("plugin:os|platform")},n.type=async function(){return o("plugin:os|os_type")},n.version=async function(){return o("plugin:os|version")},n}({});Object.defineProperty(window.__TAURI__,"os",{value:__TAURI_OS__})}
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
__RAW_global_os_api__;
|
||||
|
||||
// eslint-disable-next-line
|
||||
window.__TAURI__.os.__eol = __TEMPLATE_eol__;
|
||||
Object.defineProperty(window, "__TAURI_OS_PLUGIN_INTERNALS__", {
|
||||
value: {
|
||||
eol: __TEMPLATE_eol__,
|
||||
},
|
||||
});
|
||||
|
||||
__RAW_global_os_api__;
|
||||
|
||||
Reference in New Issue
Block a user