Skip to content

Commit

Permalink
[i18nIgnore] Import Examples When "withGlobalTauri": true (tauri-ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbolda authored Jul 9, 2024
1 parent 37041ac commit 17260f7
Show file tree
Hide file tree
Showing 58 changed files with 189 additions and 130 deletions.
2 changes: 1 addition & 1 deletion src/content/docs/blog/tauri-2-0-0-alpha-4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {

**Frontend code to call the plugin command:**

```js
```javascript
import { invoke } from '@tauri-apps/api/tauri';
invoke('plugin:example|ping', { value: 'Tauri' }).then(({ value }) =>
console.log('Response', value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ For the purposes of this example, let's imagine we are in the same directory as

`../dist-isolation/index.js`:

```js
```javascript
window.__TAURI_ISOLATION_HOOK__ = (payload) => {
// let's not verify or modify anything, just print the content from the hook
console.log('hook', payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ testing file at `test/test.js` by default, so let's create that file now.

`test/test.js`:

```js
```javascript
const os = require('os');
const path = require('path');
const { expect } = require('chai');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ config file which controls most aspects of our testing suite.

`wdio.conf.js`:

```js
```javascript
const os = require('os');
const path = require('path');
const { spawn, spawnSync } = require('child_process');
Expand Down Expand Up @@ -135,7 +135,7 @@ run them as it sees fit. Let's create our spec now in the directory we specified

`test/specs/example.e2e.js`:

```js
```javascript
// calculates the luma from a hex color `#abcdef`
function luma(hex) {
if (hex.startsWith('#')) {
Expand Down
8 changes: 4 additions & 4 deletions src/content/docs/develop/Tests/mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following examples use [Vitest], but you can use any other frontend testing

:::

```js
```javascript
import { beforeAll, expect, test } from "vitest";
import { randomFillSync } from "crypto";

Expand Down Expand Up @@ -61,7 +61,7 @@ test("invoke simple", async () => {
Sometimes you want to track more information about an IPC call; how many times was the command invoked? Was it invoked at all?
You can use [`mockIPC()`] with other spying and mocking tools to test this:

```js
```javascript
import { beforeAll, expect, test, vi } from "vitest";
import { randomFillSync } from "crypto";

Expand Down Expand Up @@ -99,7 +99,7 @@ test("invoke", async () => {

To mock IPC requests to a sidecar or shell command you need to grab the ID of the event handler when `spawn()` or `execute()` is called and use this ID to emit events the backend would send back:

```js
```javascript
mockIPC(async (cmd, args) => {
if (args.message.cmd === 'execute') {
const eventCallbackId = `_${args.message.onEventFn}`;
Expand Down Expand Up @@ -134,7 +134,7 @@ You can use the [`mockWindows()`] method to create fake window labels. The first

:::

```js
```javascript
import { beforeAll, expect, test } from 'vitest';
import { randomFillSync } from 'crypto';

Expand Down
14 changes: 7 additions & 7 deletions src/content/docs/develop/calling-rust.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn run() {

Now, you can invoke the command from your JavaScript code:

```js
```javascript
// When using the Tauri API npm package:
import { invoke } from '@tauri-apps/api/core';

Expand All @@ -60,7 +60,7 @@ fn my_custom_command(invoke_message: String) {

Arguments should be passed as a JSON object with camelCase keys:

```js
```javascript
invoke('my_custom_command', { invokeMessage: 'Hello!' });
```

Expand All @@ -78,7 +78,7 @@ fn my_custom_command(invoke_message: String) {

The corresponding JavaScript:

```js
```javascript
invoke('my_custom_command', { invoke_message: 'Hello!' });
```

Expand All @@ -95,7 +95,7 @@ fn my_custom_command() -> String {

The `invoke` function returns a promise that resolves with the returned value:

```js
```javascript
invoke('my_custom_command').then((message) => console.log(message));
```

Expand All @@ -117,7 +117,7 @@ fn my_custom_command() -> Result<String, String> {

If the command returns an error, the promise will reject, otherwise, it resolves:

```js
```javascript
invoke('my_custom_command')
.then((message) => console.log(message))
.catch((error) => console.error(error));
Expand Down Expand Up @@ -229,7 +229,7 @@ async fn my_custom_command(value: &str) -> Result<String, ()> {

Since invoking the command from JavaScript already returns a promise, it works just like any other command:

```js
```javascript
invoke('my_custom_command', { value: 'Hello, Async!' }).then(() =>
console.log('Completed!')
);
Expand Down Expand Up @@ -374,7 +374,7 @@ pub fn run() {
}
```

```js
```javascript
import { invoke } from '@tauri-apps/api/core';

// Invocation from JavaScript
Expand Down
10 changes: 5 additions & 5 deletions src/content/docs/es/plugin/dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Consulta todas las [Opciones de diálogo](/reference/javascript/dialog/) en la r

Muestra un diálogo de pregunta con botones `Yes` y `No`.

```js
```javascript
import { ask } from '@tauri-apps/plugin-dialog';

// Crea un diálogo de Sí/No
Expand All @@ -107,7 +107,7 @@ console.log(answer);

Muestra un diálogo de pregunta con botones `Ok` y `Cancel`.

```js
```javascript
import { confirm } from '@tauri-apps/plugin-dialog';

// Crea un diálogo de confirmación Ok/Cancelar
Expand All @@ -126,7 +126,7 @@ console.log(confirmation);

Muestra un diálogo de mensaje con un botón `Ok`. Ten en cuenta que si el usuario cierra el diálogo, devolverá `false`.

```js
```javascript
import { message } from '@tauri-apps/plugin-dialog';

// Muestra un mensaje
Expand All @@ -141,7 +141,7 @@ Abre un diálogo de selección de archivos/directorios.

La opción `multiple` controla si el diálogo permite la selección múltiple o no, mientras que `directory`, si es una selección de directorio o no.

```js
```javascript
import { open } from '@tauri-apps/plugin-dialog';

// Abre un diálogo
Expand All @@ -159,7 +159,7 @@ console.log(file);

Abre un diálogo de guardar archivo/directorio.

```js
```javascript
import { save } from '@tauri-apps/plugin-dialog';
// Indica para guardar un 'My Filter' con extensión .png o .jpeg
const path = await save({
Expand Down
22 changes: 11 additions & 11 deletions src/content/docs/es/start/migrate/from-tauri-1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn main() {
}
```

```js
```javascript
import { getMatches } from '@tauri-apps/plugin-cli';
const matches = await getMatches();
```
Expand Down Expand Up @@ -291,7 +291,7 @@ fn main() {
}
```

```js
```javascript
import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';
await writeText('Tauri is awesome!');
assert(await readText(), 'Tauri is awesome!');
Expand Down Expand Up @@ -349,7 +349,7 @@ fn main() {
}
```

```js
```javascript
import { save } from '@tauri-apps/plugin-dialog';
const filePath = await save({
filters: [
Expand Down Expand Up @@ -415,7 +415,7 @@ fn main() {
}
```

```js
```javascript
import { mkdir, BaseDirectory } from '@tauri-apps/plugin-fs';
await mkdir('db', { baseDir: BaseDirectory.AppLocalData });
```
Expand Down Expand Up @@ -473,7 +473,7 @@ fn main() {
}
```

```js
```javascript
import { register } from '@tauri-apps/plugin-global-shortcut';
await register('CommandOrControl+Shift+C', () => {
console.log('Shortcut triggered');
Expand Down Expand Up @@ -538,7 +538,7 @@ fn main() {
}
```

```js
```javascript
import { fetch } from '@tauri-apps/plugin-http';
const response = await fetch(
'https://raw.githubusercontent.com/tauri-apps/tauri/dev/package.json'
Expand Down Expand Up @@ -604,7 +604,7 @@ fn main() {
}
```

```js
```javascript
import { sendNotification } from '@tauri-apps/plugin-notification';
sendNotification('Tauri is awesome!');
```
Expand Down Expand Up @@ -782,7 +782,7 @@ fn main() {
}
```

```js
```javascript
import { arch } from '@tauri-apps/plugin-os';
const architecture = await arch();
```
Expand Down Expand Up @@ -837,7 +837,7 @@ fn main() {
}
```

```js
```javascript
import { exit, relaunch } from '@tauri-apps/plugin-process';
await exit(0);
await relaunch();
Expand Down Expand Up @@ -896,7 +896,7 @@ fn main() {
}
```

```js
```javascript
import { Command, open } from '@tauri-apps/plugin-shell';
const output = await Command.create('echo', 'message').execute();

Expand Down Expand Up @@ -1079,7 +1079,7 @@ fn main() {
}
```

```js
```javascript
import { check } from '@tauri-apps/plugin-updater';
import { relaunch } from '@tauri-apps/plugin-process';

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/fr/plugin/notification.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Suivez ces étapes pour envoyer une notification:
<Tabs>
<TabItem label="JavaScript">

```js
```javascript
import {
isPermissionGranted,
requestPermission,
Expand Down
Loading

0 comments on commit 17260f7

Please sign in to comment.