@tauri-apps/plugin-shell
Advanced tools
Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3
@@ -1,9 +0,102 @@ | ||
var f=Object.defineProperty;var g=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),i$1=(a,b,c)=>{if(b.has(a))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(a):b.set(a,c);},j=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c); | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
var T={};g(T,{Channel:()=>i,PluginListener:()=>o,addPluginListener:()=>l,convertFileSrc:()=>v,invoke:()=>u,transformCallback:()=>_});function _(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}var r,i=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i$1(this,r,()=>{});this.id=_(n=>{h(this,r).call(this,n);});}set onmessage(n){j(this,r,n);}get onmessage(){return h(this,r)}toJSON(){return `__CHANNEL__:${this.id}`}};r=new WeakMap;var o=class{constructor(n,s,t){this.plugin=n,this.event=s,this.channelId=t;}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function l(e,n,s){let t=new i;return t.onmessage=s,u(`plugin:${e}|register_listener`,{event:n,handler:t}).then(()=>new o(e,n,t.id))}async function u(e,n={},s){return window.__TAURI_INTERNALS__.invoke(e,n,s)}function v(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)} | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise, SuppressedError, Symbol */ | ||
function __classPrivateFieldGet(receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
} | ||
function __classPrivateFieldSet(receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
} | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
var _Channel_onmessage; | ||
/** | ||
* Invoke your custom commands. | ||
* | ||
* This package is also accessible with `window.__TAURI__.tauri` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`. | ||
* @module | ||
*/ | ||
/** | ||
* Transforms a callback function to a string identifier that can be passed to the backend. | ||
* The backend uses the identifier to `eval()` the callback. | ||
* | ||
* @return A unique identifier associated with the callback function. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
function transformCallback(callback, once = false) { | ||
return window.__TAURI_INTERNALS__.transformCallback(callback, once); | ||
} | ||
class Channel { | ||
constructor() { | ||
// @ts-expect-error field used by the IPC serializer | ||
this.__TAURI_CHANNEL_MARKER__ = true; | ||
_Channel_onmessage.set(this, () => { | ||
// no-op | ||
}); | ||
this.id = transformCallback((response) => { | ||
__classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, response); | ||
}); | ||
} | ||
set onmessage(handler) { | ||
__classPrivateFieldSet(this, _Channel_onmessage, handler, "f"); | ||
} | ||
get onmessage() { | ||
return __classPrivateFieldGet(this, _Channel_onmessage, "f"); | ||
} | ||
toJSON() { | ||
return `__CHANNEL__:${this.id}`; | ||
} | ||
} | ||
_Channel_onmessage = new WeakMap(); | ||
/** | ||
* Sends a message to the backend. | ||
* @example | ||
* ```typescript | ||
* import { invoke } from '@tauri-apps/api/primitives'; | ||
* await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' }); | ||
* ``` | ||
* | ||
* @param cmd The command name. | ||
* @param args The optional arguments to pass to the command. | ||
* @param options The request options. | ||
* @return A promise resolving or rejecting to the backend response. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
async function invoke(cmd, args = {}, options) { | ||
return window.__TAURI_INTERNALS__.invoke(cmd, args, options); | ||
} | ||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
/** | ||
* Access the system shell. | ||
@@ -83,5 +176,5 @@ * Allows you to spawn child processes and manage files and URLs using their default application. | ||
} | ||
const onEvent = new i(); | ||
const onEvent = new Channel(); | ||
onEvent.onmessage = onEventHandler; | ||
return u("plugin:shell|execute", { | ||
return invoke("plugin:shell|execute", { | ||
program, | ||
@@ -282,3 +375,3 @@ args, | ||
async write(data) { | ||
return u("plugin:shell|stdin_write", { | ||
return invoke("plugin:shell|stdin_write", { | ||
pid: this.pid, | ||
@@ -297,3 +390,3 @@ // correctly serialize Uint8Arrays | ||
async kill() { | ||
return u("plugin:shell|kill", { | ||
return invoke("plugin:shell|kill", { | ||
cmd: "killChild", | ||
@@ -479,3 +572,3 @@ pid: this.pid, | ||
async function open(path, openWith) { | ||
return u("plugin:shell|open", { | ||
return invoke("plugin:shell|open", { | ||
path, | ||
@@ -482,0 +575,0 @@ with: openWith, |
{ | ||
"name": "@tauri-apps/plugin-shell", | ||
"version": "2.0.0-alpha.2", | ||
"version": "2.0.0-alpha.3", | ||
"license": "MIT or APACHE-2.0", | ||
@@ -27,3 +27,3 @@ "authors": [ | ||
"dependencies": { | ||
"@tauri-apps/api": "2.0.0-alpha.9" | ||
"@tauri-apps/api": "2.0.0-alpha.11" | ||
}, | ||
@@ -30,0 +30,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51548
1326
+ Added@tauri-apps/api@2.0.0-alpha.11(transitive)
- Removed@tauri-apps/api@2.0.0-alpha.9(transitive)