From 56ce9dae001cf8f978a0f0c23bdfe001435aa26d Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 21 May 2023 14:09:27 +0000 Subject: [PATCH] chore: add remaining mirrors (#382) Co-authored-by: Fabian-Lars Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/5038084282 Co-authored-by: lucasfernog --- Cargo.toml | 9 ++ LICENSE.spdx | 20 ++++ LICENSE_APACHE-2.0 | 177 +++++++++++++++++++++++++++++++++++ LICENSE_MIT | 21 +++++ README.md | 78 +++++++++++++++ dist-js/index.d.ts | 28 ++++++ dist-js/index.min.js | 39 ++++++++ dist-js/index.min.js.map | 1 + dist-js/index.mjs | 37 ++++++++ dist-js/index.mjs.map | 1 + guest-js/index.ts | 45 +++++++++ node_modules/@tauri-apps/api | 1 + node_modules/tslib | 1 + package.json | 32 +++++++ rollup.config.mjs | 11 +++ src/commands.rs | 11 +++ src/lib.rs | 12 +++ tsconfig.json | 4 + 18 files changed, 528 insertions(+) create mode 100644 Cargo.toml create mode 100644 LICENSE.spdx create mode 100644 LICENSE_APACHE-2.0 create mode 100644 LICENSE_MIT create mode 100644 README.md create mode 100644 dist-js/index.d.ts create mode 100644 dist-js/index.min.js create mode 100644 dist-js/index.min.js.map create mode 100644 dist-js/index.mjs create mode 100644 dist-js/index.mjs.map create mode 100644 guest-js/index.ts create mode 120000 node_modules/@tauri-apps/api create mode 120000 node_modules/tslib create mode 100644 package.json create mode 100644 rollup.config.mjs create mode 100644 src/commands.rs create mode 100644 src/lib.rs create mode 100644 tsconfig.json diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..7a44f48 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "tauri-plugin-process" +version = "1.0.0" +edition = { workspace = true } +authors = { workspace = true } +license = { workspace = true } + +[dependencies] +tauri = { workspace = true } diff --git a/LICENSE.spdx b/LICENSE.spdx new file mode 100644 index 0000000..cdd0df5 --- /dev/null +++ b/LICENSE.spdx @@ -0,0 +1,20 @@ +SPDXVersion: SPDX-2.1 +DataLicense: CC0-1.0 +PackageName: tauri +DataFormat: SPDXRef-1 +PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy +PackageHomePage: https://tauri.app +PackageLicenseDeclared: Apache-2.0 +PackageLicenseDeclared: MIT +PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy +PackageSummary: Tauri is a rust project that enables developers to make secure +and small desktop applications using a web frontend. + +PackageComment: The package includes the following libraries; see +Relationship information. + +Created: 2019-05-20T09:00:00Z +PackageDownloadLocation: git://github.com/tauri-apps/tauri +PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git +PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git +Creator: Person: Daniel Thompson-Yvetot \ No newline at end of file diff --git a/LICENSE_APACHE-2.0 b/LICENSE_APACHE-2.0 new file mode 100644 index 0000000..4947287 --- /dev/null +++ b/LICENSE_APACHE-2.0 @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/LICENSE_MIT b/LICENSE_MIT new file mode 100644 index 0000000..4d75472 --- /dev/null +++ b/LICENSE_MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 - Present Tauri Apps Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..fad3e82 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# Process + +This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. + +## Install + +_This plugin requires a Rust version of at least **1.65**_ + +There are three general methods of installation that we can recommend. + +1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked) +2. Pull sources directly from Github using git tags / revision hashes (most secure) +3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-process = "2.0.0-alpha" +# alternatively with Git: +tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +``` + +You can install the JavaScript Guest bindings using your preferred JavaScript package manager: + +> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. + +```sh +pnpm add @tauri-apps/plugin-process +# or +npm add @tauri-apps/plugin-process +# or +yarn add @tauri-apps/plugin-process + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-process#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-process#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-process#v2 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_process::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { exit, relaunch } from "@tauri-apps/plugin-process"; +// exit the app with the given status code +await exit(0); +// restart the app +await relaunch(); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/dist-js/index.d.ts b/dist-js/index.d.ts new file mode 100644 index 0000000..ac01322 --- /dev/null +++ b/dist-js/index.d.ts @@ -0,0 +1,28 @@ +/** + * Exits immediately with the given `exitCode`. + * @example + * ```typescript + * import { exit } from '@tauri-apps/plugin-process'; + * await exit(1); + * ``` + * + * @param code The exit code to use. + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function exit(code?: number): Promise; +/** + * Exits the current instance of the app then relaunches it. + * @example + * ```typescript + * import { relaunch } from '@tauri-apps/plugin-process'; + * await relaunch(); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function relaunch(): Promise; +export { exit, relaunch }; diff --git a/dist-js/index.min.js b/dist-js/index.min.js new file mode 100644 index 0000000..0c2db3e --- /dev/null +++ b/dist-js/index.min.js @@ -0,0 +1,39 @@ +var f$1=Object.defineProperty;var g=(a,b)=>{for(var c in b)f$1(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h$1=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),i=(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); + +var f={};g(f,{Channel:()=>a,PluginListener:()=>c,addPluginListener:()=>v,convertFileSrc:()=>m,invoke:()=>u,transformCallback:()=>o});function h(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function o(t,e=!1){let n=h(),r=`_${n}`;return Object.defineProperty(window,r,{value:i=>(e&&Reflect.deleteProperty(window,r),t?.(i)),writable:!1,configurable:!0}),n}var s,a=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i(this,s,()=>{});this.id=o(e=>{h$1(this,s).call(this,e);});}set onmessage(e){j(this,s,e);}get onmessage(){return h$1(this,s)}toJSON(){return `__CHANNEL__:${this.id}`}};s=new WeakMap;var c=class{constructor(e,n,r){this.plugin=e,this.event=n,this.channelId=r;}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function v(t,e,n){let r=new a;return r.onmessage=n,u(`plugin:${t}|register_listener`,{event:e,handler:r}).then(()=>new c(t,e,r.id))}async function u(t,e={}){return new Promise((n,r)=>{let i=o(d=>{n(d),Reflect.deleteProperty(window,`_${g}`);},!0),g=o(d=>{r(d),Reflect.deleteProperty(window,`_${i}`);},!0);window.__TAURI_IPC__({cmd:t,callback:i,error:g,...e});})}function m(t,e="asset"){let n=encodeURIComponent(t);return navigator.userAgent.includes("Windows")?`https://${e}.localhost/${n}`:`${e}://localhost/${n}`} + +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +/** + * Exits immediately with the given `exitCode`. + * @example + * ```typescript + * import { exit } from '@tauri-apps/plugin-process'; + * await exit(1); + * ``` + * + * @param code The exit code to use. + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function exit(code = 0) { + return u("plugin:process|exit", { code }); +} +/** + * Exits the current instance of the app then relaunches it. + * @example + * ```typescript + * import { relaunch } from '@tauri-apps/plugin-process'; + * await relaunch(); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function relaunch() { + return u("plugin:process|restart"); +} + +export { exit, relaunch }; +//# sourceMappingURL=index.min.js.map diff --git a/dist-js/index.min.js.map b/dist-js/index.min.js.map new file mode 100644 index 0000000..e534ca7 --- /dev/null +++ b/dist-js/index.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.min.js","sources":["../../../node_modules/.pnpm/@tauri-apps+api@2.0.0-alpha.4/node_modules/@tauri-apps/api/chunk-WVIOQTRJ.js","../../../node_modules/.pnpm/@tauri-apps+api@2.0.0-alpha.4/node_modules/@tauri-apps/api/chunk-3YK5DLRW.js","../guest-js/index.ts"],"sourcesContent":["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=(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);export{g as a,h as b,i as c,j as d};\n","import{a as w,b as l,c as p,d as _}from\"./chunk-WVIOQTRJ.js\";var f={};w(f,{Channel:()=>a,PluginListener:()=>c,addPluginListener:()=>v,convertFileSrc:()=>m,invoke:()=>u,transformCallback:()=>o});function h(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function o(t,e=!1){let n=h(),r=`_${n}`;return Object.defineProperty(window,r,{value:i=>(e&&Reflect.deleteProperty(window,r),t?.(i)),writable:!1,configurable:!0}),n}var s,a=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;p(this,s,()=>{});this.id=o(e=>{l(this,s).call(this,e)})}set onmessage(e){_(this,s,e)}get onmessage(){return l(this,s)}toJSON(){return`__CHANNEL__:${this.id}`}};s=new WeakMap;var c=class{constructor(e,n,r){this.plugin=e,this.event=n,this.channelId=r}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function v(t,e,n){let r=new a;return r.onmessage=n,u(`plugin:${t}|register_listener`,{event:e,handler:r}).then(()=>new c(t,e,r.id))}async function u(t,e={}){return new Promise((n,r)=>{let i=o(d=>{n(d),Reflect.deleteProperty(window,`_${g}`)},!0),g=o(d=>{r(d),Reflect.deleteProperty(window,`_${i}`)},!0);window.__TAURI_IPC__({cmd:t,callback:i,error:g,...e})})}function m(t,e=\"asset\"){let n=encodeURIComponent(t);return navigator.userAgent.includes(\"Windows\")?`https://${e}.localhost/${n}`:`${e}://localhost/${n}`}export{o as a,a as b,c,v as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,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,OAAO,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;;ACA51C;AAWA;;;;;;;;;;;;AAYG;AACH,eAAe,IAAI,CAAC,IAAI,GAAG,CAAC,EAAA;IAC1B,OAAOE,CAAM,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;AAWG;AACH,eAAe,QAAQ,GAAA;AACrB,IAAA,OAAOA,CAAM,CAAC,wBAAwB,CAAC,CAAC;AAC1C;;;;","x_google_ignoreList":[0,1]} \ No newline at end of file diff --git a/dist-js/index.mjs b/dist-js/index.mjs new file mode 100644 index 0000000..3672352 --- /dev/null +++ b/dist-js/index.mjs @@ -0,0 +1,37 @@ +import { invoke } from '@tauri-apps/api/tauri'; + +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +/** + * Exits immediately with the given `exitCode`. + * @example + * ```typescript + * import { exit } from '@tauri-apps/plugin-process'; + * await exit(1); + * ``` + * + * @param code The exit code to use. + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function exit(code = 0) { + return invoke("plugin:process|exit", { code }); +} +/** + * Exits the current instance of the app then relaunches it. + * @example + * ```typescript + * import { relaunch } from '@tauri-apps/plugin-process'; + * await relaunch(); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function relaunch() { + return invoke("plugin:process|restart"); +} + +export { exit, relaunch }; +//# sourceMappingURL=index.mjs.map diff --git a/dist-js/index.mjs.map b/dist-js/index.mjs.map new file mode 100644 index 0000000..0ee5510 --- /dev/null +++ b/dist-js/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../guest-js/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AAWA;;;;;;;;;;;;AAYG;AACH,eAAe,IAAI,CAAC,IAAI,GAAG,CAAC,EAAA;IAC1B,OAAO,MAAM,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;AAWG;AACH,eAAe,QAAQ,GAAA;AACrB,IAAA,OAAO,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAC1C;;;;"} \ No newline at end of file diff --git a/guest-js/index.ts b/guest-js/index.ts new file mode 100644 index 0000000..403dbc9 --- /dev/null +++ b/guest-js/index.ts @@ -0,0 +1,45 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +/** + * Perform operations on the current process. + * @module + */ + +import { invoke } from "@tauri-apps/api/tauri"; + +/** + * Exits immediately with the given `exitCode`. + * @example + * ```typescript + * import { exit } from '@tauri-apps/plugin-process'; + * await exit(1); + * ``` + * + * @param code The exit code to use. + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function exit(code = 0): Promise { + return invoke("plugin:process|exit", { code }); +} + +/** + * Exits the current instance of the app then relaunches it. + * @example + * ```typescript + * import { relaunch } from '@tauri-apps/plugin-process'; + * await relaunch(); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function relaunch(): Promise { + return invoke("plugin:process|restart"); +} + +export { exit, relaunch }; diff --git a/node_modules/@tauri-apps/api b/node_modules/@tauri-apps/api new file mode 120000 index 0000000..fa7e7b0 --- /dev/null +++ b/node_modules/@tauri-apps/api @@ -0,0 +1 @@ +../../../../node_modules/.pnpm/@tauri-apps+api@2.0.0-alpha.4/node_modules/@tauri-apps/api \ No newline at end of file diff --git a/node_modules/tslib b/node_modules/tslib new file mode 120000 index 0000000..878199c --- /dev/null +++ b/node_modules/tslib @@ -0,0 +1 @@ +../../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..9f2542e --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "@tauri-apps/plugin-process", + "version": "1.0.0", + "license": "MIT or APACHE-2.0", + "authors": [ + "Tauri Programme within The Commons Conservancy" + ], + "type": "module", + "browser": "dist-js/index.min.js", + "module": "dist-js/index.mjs", + "types": "dist-js/index.d.ts", + "exports": { + "import": "./dist-js/index.mjs", + "types": "./dist-js/index.d.ts", + "browser": "./dist-js/index.min.js" + }, + "scripts": { + "build": "rollup -c" + }, + "files": [ + "dist-js", + "!dist-js/**/*.map", + "README.md", + "LICENSE" + ], + "devDependencies": { + "tslib": "^2.5.0" + }, + "dependencies": { + "@tauri-apps/api": "2.0.0-alpha.4" + } +} diff --git a/rollup.config.mjs b/rollup.config.mjs new file mode 100644 index 0000000..6555e98 --- /dev/null +++ b/rollup.config.mjs @@ -0,0 +1,11 @@ +import { readFileSync } from "fs"; + +import { createConfig } from "../../shared/rollup.config.mjs"; + +export default createConfig({ + input: "guest-js/index.ts", + pkg: JSON.parse( + readFileSync(new URL("./package.json", import.meta.url), "utf8") + ), + external: [/^@tauri-apps\/api/], +}); diff --git a/src/commands.rs b/src/commands.rs new file mode 100644 index 0000000..de2e730 --- /dev/null +++ b/src/commands.rs @@ -0,0 +1,11 @@ +use tauri::{AppHandle, Runtime}; + +#[tauri::command] +pub fn exit(app: AppHandle, code: i32) { + app.exit(code) +} + +#[tauri::command] +pub fn restart(app: AppHandle) { + app.restart() +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..e38a4ed --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,12 @@ +use tauri::{ + plugin::{Builder, TauriPlugin}, + Runtime, +}; + +mod commands; + +pub fn init() -> TauriPlugin { + Builder::new("process") + .invoke_handler(tauri::generate_handler![commands::exit, commands::restart]) + .build() +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..5098169 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +}