commit
d5699a5f6c
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
"upload": "minor"
|
|
||||||
"upload-js": "minor"
|
|
||||||
---
|
|
||||||
|
|
||||||
Added a new field `progressTotal` to track the total amount of data transferred during the upload/download process.
|
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
deep-link: patch
|
|
||||||
deep-link-js: patch
|
|
||||||
---
|
|
||||||
|
|
||||||
`onOpenUrl()` will now not call `getCurrent()` anymore, matching the documented behavior.
|
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
'log-plugin': 'patch'
|
|
||||||
'log-js': 'patch'
|
|
||||||
---
|
|
||||||
|
|
||||||
Make webview log target more consistent that it always starts with `webview`
|
|
@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
"fs": "patch"
|
|
||||||
"fs-js": "patch"
|
|
||||||
---
|
|
||||||
|
|
||||||
Fix `readDir` function failing to read directories that contain broken symlinks.
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'localhost': 'minor'
|
|
||||||
---
|
|
||||||
|
|
||||||
Add custom host binding to allow external access
|
|
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
"sql": "patch"
|
|
||||||
---
|
|
||||||
|
|
||||||
Allow blocking on async code without creating a nested runtime.
|
|
@ -0,0 +1 @@
|
|||||||
|
plugins/*/permissions/autogenerated/
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,66 @@
|
|||||||
|
<script>
|
||||||
|
import * as opener from '@tauri-apps/plugin-opener'
|
||||||
|
|
||||||
|
export let onMessage
|
||||||
|
|
||||||
|
let url = ''
|
||||||
|
let urlProgram = ''
|
||||||
|
function openUrl() {
|
||||||
|
opener.openUrl(url, urlProgram ? urlProgram : undefined).catch(onMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = ''
|
||||||
|
let pathProgram = ''
|
||||||
|
function openPath() {
|
||||||
|
opener
|
||||||
|
.openPath(path, pathProgram ? pathProgram : undefined)
|
||||||
|
.catch(onMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
let revealPath = ''
|
||||||
|
function revealItemInDir() {
|
||||||
|
opener.revealItemInDir(revealPath).catch(onMessage)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
<form
|
||||||
|
class="flex flex-row gap-2 items-center"
|
||||||
|
on:submit|preventDefault={openUrl}
|
||||||
|
>
|
||||||
|
<button class="btn" type="submit">Open URL</button>
|
||||||
|
<input
|
||||||
|
class="input grow"
|
||||||
|
placeholder="Type the URL to open..."
|
||||||
|
bind:value={url}
|
||||||
|
/>
|
||||||
|
<span> with </span>
|
||||||
|
<input class="input" bind:value={urlProgram} />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="flex flex-row gap-2 items-center"
|
||||||
|
on:submit|preventDefault={openPath}
|
||||||
|
>
|
||||||
|
<button class="btn" type="submit">Open Path</button>
|
||||||
|
<input
|
||||||
|
class="input grow"
|
||||||
|
placeholder="Type the path to open..."
|
||||||
|
bind:value={path}
|
||||||
|
/>
|
||||||
|
<span> with </span>
|
||||||
|
<input class="input" bind:value={pathProgram} />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="flex flex-row gap-2 items-center"
|
||||||
|
on:submit|preventDefault={revealItemInDir}
|
||||||
|
>
|
||||||
|
<button class="btn" type="submit">Reveal</button>
|
||||||
|
<input
|
||||||
|
class="input grow"
|
||||||
|
placeholder="Type the path to reveal..."
|
||||||
|
bind:value={revealPath}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
</div>
|
@ -1 +1 @@
|
|||||||
if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARD_MANAGER__=function(e){"use strict";var t;async function r(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}"function"==typeof SuppressedError&&SuppressedError;class n{get rid(){return function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}(this,t,"f")}constructor(e){t.set(this,void 0),function(e,t,r,n,a){if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,r)}(this,t,e)}async close(){return r("plugin:resources|close",{rid:this.rid})}}t=new WeakMap;class a extends n{constructor(e){super(e)}static async new(e,t,n){return r("plugin:image|new",{rgba:i(e),width:t,height:n}).then((e=>new a(e)))}static async fromBytes(e){return r("plugin:image|from_bytes",{bytes:i(e)}).then((e=>new a(e)))}static async fromPath(e){return r("plugin:image|from_path",{path:e}).then((e=>new a(e)))}async rgba(){return r("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return r("plugin:image|size",{rid:this.rid})}}function i(e){return null==e?null:"string"==typeof e?e:e instanceof a?e.rid:e}return e.clear=async function(){await r("plugin:clipboard-manager|clear")},e.readImage=async function(){return await r("plugin:clipboard-manager|read_image").then((e=>new a(e)))},e.readText=async function(){return await r("plugin:clipboard-manager|read_text")},e.writeHtml=async function(e,t){await r("plugin:clipboard-manager|write_html",{html:e,altHtml:t})},e.writeImage=async function(e){await r("plugin:clipboard-manager|write_image",{image:i(e)})},e.writeText=async function(e,t){await r("plugin:clipboard-manager|write_text",{label:t?.label,text:e})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARD_MANAGER__})}
|
if("__TAURI__"in window){var __TAURI_PLUGIN_CLIPBOARD_MANAGER__=function(e){"use strict";var t;async function r(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}"function"==typeof SuppressedError&&SuppressedError;class n{get rid(){return function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}(this,t,"f")}constructor(e){t.set(this,void 0),function(e,t,r,n,a){if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,r)}(this,t,e)}async close(){return r("plugin:resources|close",{rid:this.rid})}}t=new WeakMap;class a extends n{constructor(e){super(e)}static async new(e,t,n){return r("plugin:image|new",{rgba:i(e),width:t,height:n}).then((e=>new a(e)))}static async fromBytes(e){return r("plugin:image|from_bytes",{bytes:i(e)}).then((e=>new a(e)))}static async fromPath(e){return r("plugin:image|from_path",{path:e}).then((e=>new a(e)))}async rgba(){return r("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return r("plugin:image|size",{rid:this.rid})}}function i(e){return null==e?null:"string"==typeof e?e:e instanceof a?e.rid:e}return e.clear=async function(){await r("plugin:clipboard-manager|clear")},e.readImage=async function(){return await r("plugin:clipboard-manager|read_image").then((e=>new a(e)))},e.readText=async function(){return await r("plugin:clipboard-manager|read_text")},e.writeHtml=async function(e,t){await r("plugin:clipboard-manager|write_html",{html:e,altText:t})},e.writeImage=async function(e){await r("plugin:clipboard-manager|write_image",{image:i(e)})},e.writeText=async function(e,t){await r("plugin:clipboard-manager|write_text",{label:t?.label,text:e})},e}({});Object.defineProperty(window.__TAURI__,"clipboardManager",{value:__TAURI_PLUGIN_CLIPBOARD_MANAGER__})}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated - DO NOT EDIT!
|
||||||
|
|
||||||
|
"$schema" = "../../schemas/schema.json"
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-size"
|
||||||
|
description = "Enables the size command without any pre-configured scope."
|
||||||
|
commands.allow = ["size"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-size"
|
||||||
|
description = "Denies the size command without any pre-configured scope."
|
||||||
|
commands.deny = ["size"]
|
@ -0,0 +1,5 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## \[2.0.0]
|
||||||
|
|
||||||
|
- [`383e636a`](https://github.com/tauri-apps/plugins-workspace/commit/383e636a8e595aec1300999a8aeb7d9bf8c14632) ([#2019](https://github.com/tauri-apps/plugins-workspace/pull/2019) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Initial Release
|
@ -0,0 +1,65 @@
|
|||||||
|
[package]
|
||||||
|
name = "tauri-plugin-opener"
|
||||||
|
version = "2.0.0"
|
||||||
|
description = "Open files and URLs using their default application."
|
||||||
|
edition = { workspace = true }
|
||||||
|
authors = { workspace = true }
|
||||||
|
license = { workspace = true }
|
||||||
|
repository = { workspace = true }
|
||||||
|
links = "tauri-plugin-opener"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
rustc-args = ["--cfg", "docsrs"]
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
# Platforms supported by the plugin
|
||||||
|
# Support levels are "full", "partial", "none", "unknown"
|
||||||
|
# Details of the support level are left to plugin maintainer
|
||||||
|
[package.metadata.platforms]
|
||||||
|
windows = { level = "full", notes = "" }
|
||||||
|
linux = { level = "full", notes = "" }
|
||||||
|
macos = { level = "full", notes = "" }
|
||||||
|
android = { level = "partial", notes = "Only allows to open URLs via `open`" }
|
||||||
|
ios = { level = "partial", notes = "Only allows to open URLs via `open`" }
|
||||||
|
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-plugin = { workspace = true, features = ["build"] }
|
||||||
|
schemars = { workspace = true }
|
||||||
|
serde = { workspace = true }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { workspace = true }
|
||||||
|
serde_json = { workspace = true }
|
||||||
|
tauri = { workspace = true }
|
||||||
|
thiserror = { workspace = true }
|
||||||
|
open = { version = "5", features = ["shellexecute-on-windows"] }
|
||||||
|
glob = { workspace = true }
|
||||||
|
|
||||||
|
[target."cfg(windows)".dependencies]
|
||||||
|
dunce = { workspace = true }
|
||||||
|
|
||||||
|
[target."cfg(windows)".dependencies.windows]
|
||||||
|
version = "0.58"
|
||||||
|
features = [
|
||||||
|
"Win32_Foundation",
|
||||||
|
"Win32_UI_Shell_Common",
|
||||||
|
"Win32_UI_WindowsAndMessaging",
|
||||||
|
"Win32_System_Com",
|
||||||
|
"Win32_System_Registry",
|
||||||
|
]
|
||||||
|
|
||||||
|
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"netbsd\", target_os = \"openbsd\"))".dependencies]
|
||||||
|
zbus = { workspace = true }
|
||||||
|
url = { workspace = true }
|
||||||
|
|
||||||
|
[target."cfg(target_os = \"macos\")".dependencies.objc2-app-kit]
|
||||||
|
version = "0.2"
|
||||||
|
features = ["NSWorkspace"]
|
||||||
|
|
||||||
|
[target."cfg(target_os = \"macos\")".dependencies.objc2-foundation]
|
||||||
|
version = "0.2"
|
||||||
|
features = ["NSURL", "NSArray", "NSString"]
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "ios")'.dependencies]
|
||||||
|
tauri = { workspace = true, features = ["wry"] }
|
@ -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: <text>Tauri is a rust project that enables developers to make secure
|
||||||
|
and small desktop applications using a web frontend.
|
||||||
|
</text>
|
||||||
|
PackageComment: <text>The package includes the following libraries; see
|
||||||
|
Relationship information.
|
||||||
|
</text>
|
||||||
|
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
|
@ -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
|
@ -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.
|
@ -0,0 +1,100 @@
|
|||||||
|

|
||||||
|
|
||||||
|
<!-- description -->
|
||||||
|
|
||||||
|
| Platform | Supported |
|
||||||
|
| -------- | --------- |
|
||||||
|
| Linux | ✓ |
|
||||||
|
| Windows | ✓ |
|
||||||
|
| macOS | ✓ |
|
||||||
|
| Android | ? |
|
||||||
|
| iOS | ? |
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
_This plugin requires a Rust version of at least **1.77.2**_
|
||||||
|
|
||||||
|
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-opener = "2.0.0"
|
||||||
|
# alternatively with Git:
|
||||||
|
tauri-plugin-opener = { 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.
|
||||||
|
|
||||||
|
<!-- Add the branch for installations using git! -->
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm add @tauri-apps/plugin-opener
|
||||||
|
# or
|
||||||
|
npm add @tauri-apps/plugin-opener
|
||||||
|
# or
|
||||||
|
yarn add @tauri-apps/plugin-opener
|
||||||
|
|
||||||
|
# alternatively with Git:
|
||||||
|
pnpm add https://github.com/tauri-apps/tauri-plugin-opener#v2
|
||||||
|
# or
|
||||||
|
npm add https://github.com/tauri-apps/tauri-plugin-opener#v2
|
||||||
|
# or
|
||||||
|
yarn add https://github.com/tauri-apps/tauri-plugin-opener#v2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
|
`src-tauri/src/lib.rs`
|
||||||
|
|
||||||
|
```rust
|
||||||
|
fn main() {
|
||||||
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_opener::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
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
|
## Partners
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td align="center" valign="middle">
|
||||||
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v2/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
|
MIT or MIT/Apache 2.0 where applicable.
|
@ -0,0 +1,23 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
**Do not report security vulnerabilities through public GitHub issues.**
|
||||||
|
|
||||||
|
**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.**
|
||||||
|
|
||||||
|
Include as much of the following information:
|
||||||
|
|
||||||
|
- Type of issue (e.g. improper input parsing, privilege escalation, etc.)
|
||||||
|
- The location of the affected source code (tag/branch/commit or direct URL)
|
||||||
|
- Any special configuration required to reproduce the issue
|
||||||
|
- The distribution affected or used to help us with reproduction of the issue
|
||||||
|
- Step-by-step instructions to reproduce the issue
|
||||||
|
- Ideally a reproduction repository
|
||||||
|
- Impact of the issue, including how an attacker might exploit the issue
|
||||||
|
|
||||||
|
We prefer to receive reports in English.
|
||||||
|
|
||||||
|
## Contact
|
||||||
|
|
||||||
|
Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new).
|
||||||
|
|
||||||
|
Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app).
|
@ -0,0 +1,2 @@
|
|||||||
|
/build
|
||||||
|
/.tauri
|
@ -0,0 +1,39 @@
|
|||||||
|
plugins {
|
||||||
|
id("com.android.library")
|
||||||
|
id("org.jetbrains.kotlin.android")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "app.tauri.opener"
|
||||||
|
compileSdk = 34
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdk = 24
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
consumerProguardFiles("consumer-rules.pro")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("androidx.core:core-ktx:1.9.0")
|
||||||
|
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.3")
|
||||||
|
implementation(project(":tauri-android"))
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,2 @@
|
|||||||
|
include ':tauri-android'
|
||||||
|
project(':tauri-android').projectDir = new File('./.tauri/tauri-api')
|
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
</manifest>
|
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
package app.tauri.shell
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import app.tauri.annotation.Command
|
||||||
|
import app.tauri.annotation.TauriPlugin
|
||||||
|
import app.tauri.plugin.Invoke
|
||||||
|
import app.tauri.plugin.Plugin
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
@TauriPlugin
|
||||||
|
class OpenerPlugin(private val activity: Activity) : Plugin(activity) {
|
||||||
|
@Command
|
||||||
|
fun open(invoke: Invoke) {
|
||||||
|
try {
|
||||||
|
val url = invoke.parseArgs(String::class.java)
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
activity.applicationContext?.startActivity(intent)
|
||||||
|
invoke.resolve()
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
invoke.reject(ex.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
if("__TAURI__"in window){var __TAURI_PLUGIN_OPENER__=function(n){"use strict";async function e(n,e={},_){return window.__TAURI_INTERNALS__.invoke(n,e,_)}return"function"==typeof SuppressedError&&SuppressedError,n.openPath=async function(n,_){await e("plugin:opener|open_path",{path:n,with:_})},n.openUrl=async function(n,_){await e("plugin:opener|open_url",{url:n,with:_})},n.revealItemInDir=async function(n){return e("plugin:opener|reveal_item_in_dir",{path:n})},n}({});Object.defineProperty(window.__TAURI__,"opener",{value:__TAURI_PLUGIN_OPENER__})}
|
@ -0,0 +1,136 @@
|
|||||||
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[path = "src/scope_entry.rs"]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
mod scope;
|
||||||
|
|
||||||
|
/// Opener scope application.
|
||||||
|
#[derive(schemars::JsonSchema)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
#[allow(unused)]
|
||||||
|
enum Application {
|
||||||
|
/// Open in default application.
|
||||||
|
Default,
|
||||||
|
/// If true, allow open with any application.
|
||||||
|
Enable(bool),
|
||||||
|
/// Allow specific application to open with.
|
||||||
|
App(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Application {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Opener scope entry.
|
||||||
|
#[derive(schemars::JsonSchema)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
#[allow(unused)]
|
||||||
|
enum OpenerScopeEntry {
|
||||||
|
Url {
|
||||||
|
/// A URL that can be opened by the webview when using the Opener APIs.
|
||||||
|
///
|
||||||
|
/// Wildcards can be used following the UNIX glob pattern.
|
||||||
|
///
|
||||||
|
/// Examples:
|
||||||
|
///
|
||||||
|
/// - "https://*" : allows all HTTPS origin
|
||||||
|
///
|
||||||
|
/// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path
|
||||||
|
///
|
||||||
|
/// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/"
|
||||||
|
url: String,
|
||||||
|
/// An application to open this url with, for example: firefox.
|
||||||
|
#[serde(default)]
|
||||||
|
app: Application,
|
||||||
|
},
|
||||||
|
Path {
|
||||||
|
/// A path that can be opened by the webview when using the Opener APIs.
|
||||||
|
///
|
||||||
|
/// The pattern can start with a variable that resolves to a system base directory.
|
||||||
|
/// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`,
|
||||||
|
/// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`,
|
||||||
|
/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`,
|
||||||
|
/// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.
|
||||||
|
path: PathBuf,
|
||||||
|
/// An application to open this path with, for example: xdg-open.
|
||||||
|
#[serde(default)]
|
||||||
|
app: Application,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure `OpenerScopeEntry` and `scope::EntryRaw` is kept in sync
|
||||||
|
fn _f() {
|
||||||
|
match (scope::EntryRaw::Url {
|
||||||
|
url: String::new(),
|
||||||
|
app: scope::Application::Enable(true),
|
||||||
|
}) {
|
||||||
|
scope::EntryRaw::Url { url, app } => OpenerScopeEntry::Url {
|
||||||
|
url,
|
||||||
|
app: match app {
|
||||||
|
scope::Application::Enable(p) => Application::Enable(p),
|
||||||
|
scope::Application::App(p) => Application::App(p),
|
||||||
|
scope::Application::Default => Application::Default,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
scope::EntryRaw::Path { path, app } => OpenerScopeEntry::Path {
|
||||||
|
path,
|
||||||
|
app: match app {
|
||||||
|
scope::Application::Enable(p) => Application::Enable(p),
|
||||||
|
scope::Application::App(p) => Application::App(p),
|
||||||
|
scope::Application::Default => Application::Default,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
match (OpenerScopeEntry::Url {
|
||||||
|
url: String::new(),
|
||||||
|
app: Application::Enable(true),
|
||||||
|
}) {
|
||||||
|
OpenerScopeEntry::Url { url, app } => scope::EntryRaw::Url {
|
||||||
|
url,
|
||||||
|
app: match app {
|
||||||
|
Application::Enable(p) => scope::Application::Enable(p),
|
||||||
|
Application::App(p) => scope::Application::App(p),
|
||||||
|
Application::Default => scope::Application::Default,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
OpenerScopeEntry::Path { path, app } => scope::EntryRaw::Path {
|
||||||
|
path,
|
||||||
|
app: match app {
|
||||||
|
Application::Enable(p) => scope::Application::Enable(p),
|
||||||
|
Application::App(p) => scope::Application::App(p),
|
||||||
|
Application::Default => scope::Application::Default,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const COMMANDS: &[&str] = &["open_url", "open_path", "reveal_item_in_dir"];
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
tauri_plugin::Builder::new(COMMANDS)
|
||||||
|
.global_api_script_path("./api-iife.js")
|
||||||
|
.android_path("android")
|
||||||
|
.ios_path("ios")
|
||||||
|
.global_scope_schema(schemars::schema_for!(OpenerScopeEntry))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||||
|
let mobile = target_os == "ios" || target_os == "android";
|
||||||
|
alias("desktop", !mobile);
|
||||||
|
alias("mobile", mobile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// creates a cfg alias if `has_feature` is true.
|
||||||
|
// `alias` must be a snake case string.
|
||||||
|
fn alias(alias: &str, has_feature: bool) {
|
||||||
|
println!("cargo:rustc-check-cfg=cfg({alias})");
|
||||||
|
if has_feature {
|
||||||
|
println!("cargo:rustc-cfg={alias}");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open files and URLs using their default application.
|
||||||
|
*
|
||||||
|
* ## Security
|
||||||
|
*
|
||||||
|
* This API has a scope configuration that forces you to restrict the files and urls to be opened.
|
||||||
|
*
|
||||||
|
* ### Restricting access to the {@link open | `open`} API
|
||||||
|
*
|
||||||
|
* On the configuration object, `open: true` means that the {@link open} API can be used with any URL,
|
||||||
|
* as the argument is validated with the `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+` regex.
|
||||||
|
* You can change that regex by changing the boolean value to a string, e.g. `open: ^https://github.com/`.
|
||||||
|
*
|
||||||
|
* @module
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a url with the system's default app, or the one specified with {@linkcode openWith}.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* import { openUrl } from '@tauri-apps/plugin-opener';
|
||||||
|
*
|
||||||
|
* // opens the given URL on the default browser:
|
||||||
|
* await openUrl('https://github.com/tauri-apps/tauri');
|
||||||
|
* // opens the given URL using `firefox`:
|
||||||
|
* await openUrl('https://github.com/tauri-apps/tauri', 'firefox');
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param url The URL to open.
|
||||||
|
* @param openWith The app to open the URL with. If not specified, defaults to the system default application for the specified url type.
|
||||||
|
*
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
export async function openUrl(url: string, openWith?: string): Promise<void> {
|
||||||
|
await invoke('plugin:opener|open_url', {
|
||||||
|
url,
|
||||||
|
with: openWith
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a path with the system's default app, or the one specified with {@linkcode openWith}.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* import { openPath } from '@tauri-apps/plugin-opener';
|
||||||
|
*
|
||||||
|
* // opens a file using the default program:
|
||||||
|
* await openPath('/path/to/file');
|
||||||
|
* // opens a file using `vlc` command on Windows.
|
||||||
|
* await openPath('C:/path/to/file', 'vlc');
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param path The path to open.
|
||||||
|
* @param openWith The app to open the path with. If not specified, defaults to the system default application for the specified path type.
|
||||||
|
*
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
export async function openPath(path: string, openWith?: string): Promise<void> {
|
||||||
|
await invoke('plugin:opener|open_path', {
|
||||||
|
path,
|
||||||
|
with: openWith
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reveal a path the system's default explorer.
|
||||||
|
*
|
||||||
|
* #### Platform-specific:
|
||||||
|
*
|
||||||
|
* - **Android / iOS:** Unsupported.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* import { revealItemInDir } from '@tauri-apps/plugin-opener';
|
||||||
|
* await revealItemInDir('/path/to/file');
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param path The path to reveal.
|
||||||
|
*
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
export async function revealItemInDir(path: string) {
|
||||||
|
return invoke('plugin:opener|reveal_item_in_dir', { path })
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
|
// open <a href="..."> links with the API
|
||||||
|
window.addEventListener('click', function (evt) {
|
||||||
|
// return early if
|
||||||
|
if (
|
||||||
|
// event was prevented
|
||||||
|
evt.defaultPrevented ||
|
||||||
|
// or not a left click
|
||||||
|
evt.button !== 0 ||
|
||||||
|
// or meta key pressed
|
||||||
|
evt.metaKey ||
|
||||||
|
// or al key pressed
|
||||||
|
evt.altKey
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
const a = evt
|
||||||
|
.composedPath()
|
||||||
|
.find((el) => el instanceof Node && el.nodeName.toUpperCase() === 'A') as
|
||||||
|
| HTMLAnchorElement
|
||||||
|
| undefined
|
||||||
|
|
||||||
|
// return early if
|
||||||
|
if (
|
||||||
|
// not tirggered from <a> element
|
||||||
|
!a ||
|
||||||
|
// or doesn't have a href
|
||||||
|
!a.href ||
|
||||||
|
// or not supposed to be open in a new tab
|
||||||
|
!(
|
||||||
|
a.target === '_blank' ||
|
||||||
|
// or ctrl key pressed
|
||||||
|
evt.ctrlKey ||
|
||||||
|
// or shift key pressed
|
||||||
|
evt.shiftKey
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
const url = new URL(a.href)
|
||||||
|
|
||||||
|
// return early if
|
||||||
|
if (
|
||||||
|
// same origin (internal navigation)
|
||||||
|
url.origin === window.location.origin ||
|
||||||
|
// not default protocols
|
||||||
|
['http:', 'https:', 'mailto:', 'tel:'].every((p) => url.protocol !== p)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
evt.preventDefault()
|
||||||
|
|
||||||
|
void invoke('plugin:opener|open_url', {
|
||||||
|
url
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"object": {
|
||||||
|
"pins": [
|
||||||
|
{
|
||||||
|
"package": "SwiftRs",
|
||||||
|
"repositoryURL": "https://github.com/Brendonovich/swift-rs",
|
||||||
|
"state": {
|
||||||
|
"branch": null,
|
||||||
|
"revision": "b5ed223fcdab165bc21219c1925dc1e77e2bef5e",
|
||||||
|
"version": "1.0.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"version": 1
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
// swift-tools-version:5.3
|
||||||
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "tauri-plugin-opener",
|
||||||
|
platforms: [
|
||||||
|
.macOS(.v10_13),
|
||||||
|
.iOS(.v13),
|
||||||
|
],
|
||||||
|
products: [
|
||||||
|
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||||
|
.library(
|
||||||
|
name: "tauri-plugin-opener",
|
||||||
|
type: .static,
|
||||||
|
targets: ["tauri-plugin-opener"])
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
.package(name: "Tauri", path: "../.tauri/tauri-api")
|
||||||
|
],
|
||||||
|
targets: [
|
||||||
|
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||||
|
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||||
|
.target(
|
||||||
|
name: "tauri-plugin-opener",
|
||||||
|
dependencies: [
|
||||||
|
.byName(name: "Tauri")
|
||||||
|
],
|
||||||
|
path: "Sources")
|
||||||
|
]
|
||||||
|
)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue