Skip to content

Commit 0fba715

Browse files
authored
refactor(plugins): use global API usage from window.__TAURI__ (#2760)
1 parent ed049d0 commit 0fba715

20 files changed

+27
-27
lines changed

src/content/docs/plugin/autostart.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The autostart plugin is available in both JavaScript and Rust.
9292
```javascript
9393
import { enable, isEnabled, disable } from '@tauri-apps/plugin-autostart';
9494
// when using `"withGlobalTauri": true`, you may use
95-
// const { enable, isEnabled, disable } = window.__TAURI_PLUGIN_AUTOSTART__;
95+
// const { enable, isEnabled, disable } = window.__TAURI__.autostart;
9696

9797
// Enable autostart
9898
await enable();

src/content/docs/plugin/barcode-scanner.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ The barcode scanner plugin is available in JavaScript.
106106
```javascript
107107
import { scan, Format } from '@tauri-apps/plugin-barcode-scanner';
108108
// when using `"withGlobalTauri": true`, you may use
109-
// const { scan, Format } = window.__TAURI_PLUGIN_BARCODE_SCANNER__;
109+
// const { scan, Format } = window.__TAURI__.barcodeScanner;
110110

111111
// `windowed: true` actually sets the webview to transparent
112112
// instead of opening a separate view for the camera

src/content/docs/plugin/cli.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ The CLI plugin is available in both JavaScript and Rust.
223223
```javascript
224224
import { getMatches } from '@tauri-apps/plugin-cli';
225225
// when using `"withGlobalTauri": true`, you may use
226-
// const { getMatches } = window.__TAURI_PLUGIN_CLI_;
226+
// const { getMatches } = window.__TAURI__.cli;
227227

228228
const matches = await getMatches();
229229
if (matches.subcommand?.name === 'run') {

src/content/docs/plugin/clipboard.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The clipboard plugin is available in both JavaScript and Rust.
8787
```javascript
8888
import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';
8989
// when using `"withGlobalTauri": true`, you may use
90-
// const { writeText, readText } = window.__TAURI_PLUGIN_CLIPBOARD_MANAGER__;
90+
// const { writeText, readText } = window.__TAURI__.clipboardManager;
9191

9292
// Write content to clipboard
9393
await writeText('Tauri is awesome!');

src/content/docs/plugin/deep-linking.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ When a deep link triggers your app to be opened, the `onOpenUrl` callback is exe
223223
```javascript
224224
import { onOpenUrl } from '@tauri-apps/plugin-deep-link';
225225
// when using `"withGlobalTauri": true`, you may use
226-
// const { onOpenUrl } = window.__TAURI_PLUGIN_DEEP_LINK__;
226+
// const { onOpenUrl } = window.__TAURI__.deepLink;
227227

228228
await onOpenUrl((urls) => {
229229
console.log('deep link:', urls);

src/content/docs/plugin/dialog.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Shows a question dialog with `Yes` and `No` buttons.
106106
```javascript
107107
import { ask } from '@tauri-apps/plugin-dialog';
108108
// when using `"withGlobalTauri": true`, you may use
109-
// const { ask } = window.__TAURI_PLUGIN_DIALOG__;
109+
// const { ask } = window.__TAURI__.dialog;
110110

111111
// Create a Yes/No dialog
112112
const answer = await ask('This action cannot be reverted. Are you sure?', {
@@ -127,7 +127,7 @@ Shows a question dialog with `Ok` and `Cancel` buttons.
127127
```javascript
128128
import { confirm } from '@tauri-apps/plugin-dialog';
129129
// when using `"withGlobalTauri": true`, you may use
130-
// const { confirm } = window.__TAURI_PLUGIN_DIALOG__;
130+
// const { confirm } = window.__TAURI__.dialog;
131131

132132
// Creates a confirmation Ok/Cancel dialog
133133
const confirmation = await confirm(
@@ -148,7 +148,7 @@ Shows a message dialog with an `Ok` button. Keep in mind that if the user closes
148148
```javascript
149149
import { message } from '@tauri-apps/plugin-dialog';
150150
// when using `"withGlobalTauri": true`, you may use
151-
// const { message } = window.__TAURI_PLUGIN_DIALOG__;
151+
// const { message } = window.__TAURI__.dialog;
152152

153153
// Shows message
154154
await message('File not found', { title: 'Tauri', kind: 'error' });
@@ -165,7 +165,7 @@ The `multiple` option controls whether the dialog allows multiple selection or n
165165
```javascript
166166
import { open } from '@tauri-apps/plugin-dialog';
167167
// when using `"withGlobalTauri": true`, you may use
168-
// const { open } = window.__TAURI_PLUGIN_DIALOG__;
168+
// const { open } = window.__TAURI__.dialog;
169169

170170
// Open a dialog
171171
const file = await open({
@@ -185,7 +185,7 @@ Open a file/directory save dialog.
185185
```javascript
186186
import { save } from '@tauri-apps/plugin-dialog';
187187
// when using `"withGlobalTauri": true`, you may use
188-
// const { save } = window.__TAURI_PLUGIN_DIALOG__;
188+
// const { save } = window.__TAURI__.dialog;
189189

190190
// Prompt to save a 'My Filter' with extension .png or .jpeg
191191
const path = await save({

src/content/docs/plugin/file-system.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ The fs plugin is available in both JavaScript and Rust.
8484
```javascript
8585
import { exists, BaseDirectory } from '@tauri-apps/plugin-fs';
8686
// when using `"withGlobalTauri": true`, you may use
87-
// const { exists, BaseDirectory } = window.__TAURI_PLUGIN_FS__;
87+
// const { exists, BaseDirectory } = window.__TAURI__.fs;
8888

8989
// Check if the `$APPDATA/avatar.png` file exists
9090
await exists('avatar.png', { baseDir: BaseDirectory.AppData });

src/content/docs/plugin/global-shortcut.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ The global-shortcut plugin is available in both JavaScript and Rust.
9393
```javascript
9494
import { register } from '@tauri-apps/plugin-global-shortcut';
9595
// when using `"withGlobalTauri": true`, you may use
96-
// const { register } = window.__TAURI_PLUGIN_GLOBAL_SHORTCUT__;
96+
// const { register } = window.__TAURI__.globalShortcut;
9797

9898
await register('CommandOrControl+Shift+C', () => {
9999
console.log('Shortcut triggered');

src/content/docs/plugin/logging.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Install the log plugin to get started.
105105
attachLogger,
106106
} from '@tauri-apps/plugin-log';
107107
// when using `"withGlobalTauri": true`, you may use
108-
// const { warn, debug, trace, info, error, attachConsole, attachLogger } = window.__TAURI_PLUGIN_LOG__;
108+
// const { warn, debug, trace, info, error, attachConsole, attachLogger } = window.__TAURI__.log;
109109
```
110110

111111
</Steps>

src/content/docs/plugin/notification.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ import {
109109
sendNotification,
110110
} from '@tauri-apps/plugin-notification';
111111
// when using `"withGlobalTauri": true`, you may use
112-
// const { isPermissionGranted, requestPermission, sendNotification, } = window.__TAURI_PLUGIN_NOTIFICATION__;
112+
// const { isPermissionGranted, requestPermission, sendNotification, } = window.__TAURI__.notification;
113113

114114
// Do you have permission to send a notification?
115115
let permissionGranted = await isPermissionGranted();

0 commit comments

Comments
 (0)