mirror of
https://github.com/tauri-apps/tauri-plugin-shell.git
synced 2026-01-31 00:45:19 +01:00
feat(ci): also test on Windows and macOS (#366)
Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/5008962564 Co-authored-by: lucasfernog <lucasfernog@users.noreply.github.com>
This commit is contained in:
committed by
tauri-bot
parent
db027afc11
commit
9947bebc39
8
dist-js/index.d.ts
vendored
8
dist-js/index.d.ts
vendored
@@ -127,7 +127,7 @@ declare class Child {
|
||||
* @param data The message to write, either a string or a byte array.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('node');
|
||||
* const child = await command.spawn();
|
||||
* await child.write('message');
|
||||
@@ -156,7 +156,7 @@ interface OutputEvents<O extends IOPayload> {
|
||||
* It emits the `close` and `error` events.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('node');
|
||||
* command.on('close', data => {
|
||||
* console.log(`command finished with code ${data.code} and signal ${data.signal}`)
|
||||
@@ -213,7 +213,7 @@ declare class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
|
||||
* Executes the command as a child process, waiting for it to finish and collecting all of its output.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const output = await Command.create('echo', 'message').execute();
|
||||
* assert(output.code === 0);
|
||||
* assert(output.signal === null);
|
||||
@@ -247,7 +247,7 @@ type IOPayload = string | Uint8Array;
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { open } from 'tauri-plugin-shell-api';
|
||||
* import { open } from '@tauri-apps/plugin-shell';
|
||||
* // opens the given URL on the default browser:
|
||||
* await open('https://github.com/tauri-apps/tauri');
|
||||
* // opens the given URL using `firefox`:
|
||||
|
||||
12
dist-js/index.min.js
vendored
12
dist-js/index.min.js
vendored
@@ -199,7 +199,7 @@ class Child {
|
||||
* @param data The message to write, either a string or a byte array.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('node');
|
||||
* const child = await command.spawn();
|
||||
* await child.write('message');
|
||||
@@ -232,7 +232,7 @@ class Child {
|
||||
* It emits the `close` and `error` events.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('node');
|
||||
* command.on('close', data => {
|
||||
* console.log(`command finished with code ${data.code} and signal ${data.signal}`)
|
||||
@@ -272,7 +272,7 @@ class Command extends EventEmitter {
|
||||
* Creates a command to execute the given program.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('my-app', ['run', 'tauri']);
|
||||
* const output = await command.execute();
|
||||
* ```
|
||||
@@ -287,7 +287,7 @@ class Command extends EventEmitter {
|
||||
* Creates a command to execute the given sidecar program.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.sidecar('my-sidecar');
|
||||
* const output = await command.execute();
|
||||
* ```
|
||||
@@ -327,7 +327,7 @@ class Command extends EventEmitter {
|
||||
* Executes the command as a child process, waiting for it to finish and collecting all of its output.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const output = await Command.create('echo', 'message').execute();
|
||||
* assert(output.code === 0);
|
||||
* assert(output.signal === null);
|
||||
@@ -380,7 +380,7 @@ class Command extends EventEmitter {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { open } from 'tauri-plugin-shell-api';
|
||||
* import { open } from '@tauri-apps/plugin-shell';
|
||||
* // opens the given URL on the default browser:
|
||||
* await open('https://github.com/tauri-apps/tauri');
|
||||
* // opens the given URL using `firefox`:
|
||||
|
||||
@@ -197,7 +197,7 @@ class Child {
|
||||
* @param data The message to write, either a string or a byte array.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('node');
|
||||
* const child = await command.spawn();
|
||||
* await child.write('message');
|
||||
@@ -230,7 +230,7 @@ class Child {
|
||||
* It emits the `close` and `error` events.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('node');
|
||||
* command.on('close', data => {
|
||||
* console.log(`command finished with code ${data.code} and signal ${data.signal}`)
|
||||
@@ -270,7 +270,7 @@ class Command extends EventEmitter {
|
||||
* Creates a command to execute the given program.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('my-app', ['run', 'tauri']);
|
||||
* const output = await command.execute();
|
||||
* ```
|
||||
@@ -285,7 +285,7 @@ class Command extends EventEmitter {
|
||||
* Creates a command to execute the given sidecar program.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.sidecar('my-sidecar');
|
||||
* const output = await command.execute();
|
||||
* ```
|
||||
@@ -325,7 +325,7 @@ class Command extends EventEmitter {
|
||||
* Executes the command as a child process, waiting for it to finish and collecting all of its output.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const output = await Command.create('echo', 'message').execute();
|
||||
* assert(output.code === 0);
|
||||
* assert(output.signal === null);
|
||||
@@ -378,7 +378,7 @@ class Command extends EventEmitter {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { open } from 'tauri-plugin-shell-api';
|
||||
* import { open } from '@tauri-apps/plugin-shell';
|
||||
* // opens the given URL on the default browser:
|
||||
* await open('https://github.com/tauri-apps/tauri');
|
||||
* // opens the given URL using `firefox`:
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
* ```
|
||||
* Usage:
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api'
|
||||
* import { Command } from '@tauri-apps/plugin-shell'
|
||||
* Command.create('run-git-commit', ['commit', '-m', 'the commit message'])
|
||||
* ```
|
||||
*
|
||||
@@ -348,7 +348,7 @@ class Child {
|
||||
* @param data The message to write, either a string or a byte array.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('node');
|
||||
* const child = await command.spawn();
|
||||
* await child.write('message');
|
||||
@@ -392,7 +392,7 @@ interface OutputEvents<O extends IOPayload> {
|
||||
* It emits the `close` and `error` events.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('node');
|
||||
* command.on('close', data => {
|
||||
* console.log(`command finished with code ${data.code} and signal ${data.signal}`)
|
||||
@@ -456,7 +456,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
|
||||
* Creates a command to execute the given program.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.create('my-app', ['run', 'tauri']);
|
||||
* const output = await command.execute();
|
||||
* ```
|
||||
@@ -488,7 +488,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
|
||||
* Creates a command to execute the given sidecar program.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const command = Command.sidecar('my-sidecar');
|
||||
* const output = await command.execute();
|
||||
* ```
|
||||
@@ -539,7 +539,7 @@ class Command<O extends IOPayload> extends EventEmitter<CommandEvents> {
|
||||
* Executes the command as a child process, waiting for it to finish and collecting all of its output.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { Command } from 'tauri-plugin-shell-api';
|
||||
* import { Command } from '@tauri-apps/plugin-shell';
|
||||
* const output = await Command.create('echo', 'message').execute();
|
||||
* assert(output.code === 0);
|
||||
* assert(output.signal === null);
|
||||
@@ -624,7 +624,7 @@ type CommandEvent<O extends IOPayload> =
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { open } from 'tauri-plugin-shell-api';
|
||||
* import { open } from '@tauri-apps/plugin-shell';
|
||||
* // opens the given URL on the default browser:
|
||||
* await open('https://github.com/tauri-apps/tauri');
|
||||
* // opens the given URL using `firefox`:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "tauri-plugin-shell-api",
|
||||
"name": "@tauri-apps/plugin-shell",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT or APACHE-2.0",
|
||||
"authors": [
|
||||
|
||||
49
src/init.js
49
src/init.js
@@ -2,39 +2,38 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
;(function () {
|
||||
(function () {
|
||||
// open <a href="..."> links with the API
|
||||
function openLinks() {
|
||||
document.querySelector('body').addEventListener(
|
||||
'click',
|
||||
function (e) {
|
||||
var target = e.target
|
||||
while (target != null) {
|
||||
if (target.matches('a')) {
|
||||
if (
|
||||
target.href &&
|
||||
(['http://', 'https://', 'mailto:', 'tel:'].some(v => target.href.startsWith(v))) &&
|
||||
target.target === '_blank'
|
||||
) {
|
||||
window.__TAURI_INVOKE__('plugin:shell|open', {
|
||||
path: target.href
|
||||
})
|
||||
e.preventDefault()
|
||||
}
|
||||
break
|
||||
document.querySelector("body").addEventListener("click", function (e) {
|
||||
var target = e.target;
|
||||
while (target != null) {
|
||||
if (target.matches("a")) {
|
||||
if (
|
||||
target.href &&
|
||||
["http://", "https://", "mailto:", "tel:"].some((v) =>
|
||||
target.href.startsWith(v)
|
||||
) &&
|
||||
target.target === "_blank"
|
||||
) {
|
||||
window.__TAURI_INVOKE__("plugin:shell|open", {
|
||||
path: target.href,
|
||||
});
|
||||
e.preventDefault();
|
||||
}
|
||||
target = target.parentElement
|
||||
break;
|
||||
}
|
||||
target = target.parentElement;
|
||||
}
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
document.readyState === 'complete' ||
|
||||
document.readyState === 'interactive'
|
||||
document.readyState === "complete" ||
|
||||
document.readyState === "interactive"
|
||||
) {
|
||||
openLinks()
|
||||
openLinks();
|
||||
} else {
|
||||
window.addEventListener('DOMContentLoaded', openLinks, true)
|
||||
window.addEventListener("DOMContentLoaded", openLinks, true);
|
||||
}
|
||||
})()
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user