Bladeren bron

Revert "Fix importing `@tauri-apps/api` in Node.js" (#3767)

Amr Bashir 3 jaren geleden
bovenliggende
commit
6054e981c4

+ 0 - 5
.changes/fix-nodejs-api-import.md

@@ -1,5 +0,0 @@
----
-"api": patch
----
-
-Fix importing `@tauri-apps/api` in Node.js

File diff suppressed because it is too large
+ 0 - 0
core/tauri/scripts/bundle.js


+ 0 - 35
tooling/api/src/helpers/env-check.ts

@@ -1,35 +0,0 @@
-// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT
-
-/** @ignore */
-
-function isBrowser(): boolean {
-  return typeof window !== 'undefined'
-}
-
-function isLinux(): boolean {
-  if (isBrowser()) {
-    return navigator.appVersion.includes('Linux')
-  } else {
-    return process.platform === 'linux'
-  }
-}
-
-function isWindows(): boolean {
-  if (isBrowser()) {
-    return navigator.appVersion.includes('Win')
-  } else {
-    return process.platform === 'win32'
-  }
-}
-
-function isMacOS(): boolean {
-  if (isBrowser()) {
-    return navigator.appVersion.includes('Mac')
-  } else {
-    return process.platform === 'darwin'
-  }
-}
-
-export { isLinux, isWindows, isMacOS, isBrowser }

+ 19 - 0
tooling/api/src/helpers/os-check.ts

@@ -0,0 +1,19 @@
+// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-License-Identifier: MIT
+
+/** @ignore */
+
+function isLinux(): boolean {
+  return navigator.appVersion.includes('Linux')
+}
+
+function isWindows(): boolean {
+  return navigator.appVersion.includes('Win')
+}
+
+function isMacOS(): boolean {
+  return navigator.appVersion.includes('Mac')
+}
+
+export { isLinux, isWindows, isMacOS }

+ 1 - 1
tooling/api/src/os.ts

@@ -24,7 +24,7 @@
  */
 
 import { LiteralUnion } from 'type-fest'
-import { isWindows } from './helpers/env-check'
+import { isWindows } from './helpers/os-check'
 import { invokeTauriCommand } from './helpers/tauri'
 
 /**

+ 1 - 1
tooling/api/src/path.ts

@@ -25,7 +25,7 @@
 
 import { invokeTauriCommand } from './helpers/tauri'
 import { BaseDirectory } from './fs'
-import { isWindows } from './helpers/env-check'
+import { isWindows } from './helpers/os-check'
 
 /**
  * Returns the path to the suggested directory for your app config files.

+ 1 - 2
tooling/api/src/window.ts

@@ -108,7 +108,6 @@
 import { invokeTauriCommand } from './helpers/tauri'
 import type { EventName, EventCallback, UnlistenFn } from './event'
 import { emit, listen, once } from './helpers/event'
-import { isBrowser } from './helpers/env-check'
 
 /** Allows you to retrieve information about a given monitor. */
 interface Monitor {
@@ -1170,7 +1169,7 @@ class WebviewWindow extends WindowManager {
 
 /** The WebviewWindow for the current window. */
 let appWindow
-if (isBrowser() && '__TAURI_METADATA__' in window) {
+if ('__TAURI_METADATA__' in window) {
   appWindow = new WebviewWindow(
     window.__TAURI_METADATA__.__currentWindow.label,
     {

Some files were not shown because too many files changed in this diff