@tauri-apps/api
Advanced tools
Comparing version 1.5.5 to 1.5.6
# Changelog | ||
## \[1.5.6] | ||
### Bug Fixes | ||
- [`3b69c1384`](https://www.github.com/tauri-apps/tauri/commit/3b69c1384bd089ad5dcff0c1b12fbfadeb585c6a)([#9792](https://www.github.com/tauri-apps/tauri/pull/9792)) Revert [#9706](https://github.com/tauri-apps/tauri/pull/9706) which broke compatability between `tauri` crate and the JS `@tauri-apps/api` npm package in a patch release where it should've been in a minor release. | ||
## \[1.5.5] | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@tauri-apps/api", | ||
"version": "1.5.5", | ||
"version": "1.5.6", | ||
"description": "Tauri API definitions", | ||
@@ -5,0 +5,0 @@ "funding": { |
78
shell.js
@@ -82,2 +82,27 @@ import { invokeTauriCommand } from './helpers/tauri.js'; | ||
/** | ||
* Spawns a process. | ||
* | ||
* @ignore | ||
* @param program The name of the scoped command. | ||
* @param onEvent Event handler. | ||
* @param args Program arguments. | ||
* @param options Configuration for the process spawn. | ||
* @returns A promise resolving to the process id. | ||
*/ | ||
async function execute(onEvent, program, args = [], options) { | ||
if (typeof args === 'object') { | ||
Object.freeze(args); | ||
} | ||
return invokeTauriCommand({ | ||
__tauriModule: 'Shell', | ||
message: { | ||
cmd: 'execute', | ||
program, | ||
args, | ||
options, | ||
onEventFn: transformCallback(onEvent) | ||
} | ||
}); | ||
} | ||
/** | ||
* @since 1.0.0 | ||
@@ -353,9 +378,3 @@ */ | ||
async spawn() { | ||
const program = this.program; | ||
const args = this.args; | ||
const options = this.options; | ||
if (typeof args === 'object') { | ||
Object.freeze(args); | ||
} | ||
const onEvent = (event) => { | ||
return execute((event) => { | ||
switch (event.event) { | ||
@@ -375,13 +394,3 @@ case 'Error': | ||
} | ||
}; | ||
return invokeTauriCommand({ | ||
__tauriModule: 'Shell', | ||
message: { | ||
cmd: 'execute', | ||
program, | ||
args, | ||
options, | ||
onEventFn: transformCallback(onEvent) | ||
} | ||
}).then((pid) => new Child(pid)); | ||
}, this.program, this.args, this.options).then((pid) => new Child(pid)); | ||
} | ||
@@ -403,16 +412,21 @@ /** | ||
async execute() { | ||
const program = this.program; | ||
const args = this.args; | ||
const options = this.options; | ||
if (typeof args === 'object') { | ||
Object.freeze(args); | ||
} | ||
return invokeTauriCommand({ | ||
__tauriModule: 'Shell', | ||
message: { | ||
cmd: 'executeAndReturn', | ||
program, | ||
args, | ||
options | ||
} | ||
return new Promise((resolve, reject) => { | ||
this.on('error', reject); | ||
const stdout = []; | ||
const stderr = []; | ||
this.stdout.on('data', (line) => { | ||
stdout.push(line); | ||
}); | ||
this.stderr.on('data', (line) => { | ||
stderr.push(line); | ||
}); | ||
this.on('close', (payload) => { | ||
resolve({ | ||
code: payload.code, | ||
signal: payload.signal, | ||
stdout: stdout.join('\n'), | ||
stderr: stderr.join('\n') | ||
}); | ||
}); | ||
this.spawn().catch(reject); | ||
}); | ||
@@ -419,0 +433,0 @@ } |
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
550463
15499
0