@tauri-apps/api
Advanced tools
Comparing version 1.5.4 to 1.5.5
# Changelog | ||
## \[1.5.5] | ||
### Enhancements | ||
- [`7f885bd5e`](https://www.github.com/tauri-apps/tauri/commit/7f885bd5edf3e179ddf0b674c3ea7a96e26ce39e)([#9706](https://www.github.com/tauri-apps/tauri/pull/9706)) Enhance the speed of The JS `Command.execute` API from `shell` module. | ||
### Bug Fixes | ||
- [`7f885bd5e`](https://www.github.com/tauri-apps/tauri/commit/7f885bd5edf3e179ddf0b674c3ea7a96e26ce39e)([#9706](https://www.github.com/tauri-apps/tauri/pull/9706)) Fix The JS `Command.execute` API from `shell` module including extra new lines. | ||
## \[1.5.4] | ||
@@ -4,0 +14,0 @@ |
{ | ||
"name": "@tauri-apps/api", | ||
"version": "1.5.4", | ||
"version": "1.5.5", | ||
"description": "Tauri API definitions", | ||
@@ -5,0 +5,0 @@ "funding": { |
78
shell.js
@@ -82,27 +82,2 @@ 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 | ||
@@ -378,3 +353,9 @@ */ | ||
async spawn() { | ||
return execute((event) => { | ||
const program = this.program; | ||
const args = this.args; | ||
const options = this.options; | ||
if (typeof args === 'object') { | ||
Object.freeze(args); | ||
} | ||
const onEvent = (event) => { | ||
switch (event.event) { | ||
@@ -394,3 +375,13 @@ case 'Error': | ||
} | ||
}, this.program, this.args, this.options).then((pid) => new Child(pid)); | ||
}; | ||
return invokeTauriCommand({ | ||
__tauriModule: 'Shell', | ||
message: { | ||
cmd: 'execute', | ||
program, | ||
args, | ||
options, | ||
onEventFn: transformCallback(onEvent) | ||
} | ||
}).then((pid) => new Child(pid)); | ||
} | ||
@@ -412,21 +403,16 @@ /** | ||
async execute() { | ||
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); | ||
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 | ||
} | ||
}); | ||
@@ -433,0 +419,0 @@ } |
@@ -56,2 +56,15 @@ /** | ||
* in `tauri.conf.json` and its access scope must be defined on the `assetScope` array on the same `protocol` object. | ||
* For example: | ||
* ```json | ||
* { | ||
* "tauri": { | ||
* "allowlist": { | ||
* "protocol": { | ||
* "asset": true, | ||
* "assetScope": ["$APPDATA/assets/*"] | ||
* } | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
* | ||
@@ -58,0 +71,0 @@ * @param filePath The file path. |
13
tauri.js
@@ -70,2 +70,15 @@ // Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
* in `tauri.conf.json` and its access scope must be defined on the `assetScope` array on the same `protocol` object. | ||
* For example: | ||
* ```json | ||
* { | ||
* "tauri": { | ||
* "allowlist": { | ||
* "protocol": { | ||
* "asset": true, | ||
* "assetScope": ["$APPDATA/assets/*"] | ||
* } | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
* | ||
@@ -72,0 +85,0 @@ * @param filePath The file path. |
Sorry, the diff of this file is not supported yet
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
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
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
549127
15471
1