From d47a677bfa920dedb5d7050938442d75b54b6a0b Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 8 Oct 2023 18:40:34 -0300 Subject: [PATCH] feat: scaffold NFC plugin, initial iOS code --- Cargo.lock | 13 + examples/api/package.json | 3 +- examples/api/src-tauri/Cargo.toml | 1 + examples/api/src-tauri/Info.plist | 2 + .../java/com/tauri/api/kotlin/BuildTask.kt | 2 +- .../AppIcon.appiconset/Contents.json | 154 ++++----- .../gen/apple/Assets.xcassets/Contents.json | 8 +- .../gen/apple/api.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/api_iOS.xcscheme | 26 +- .../src-tauri/gen/apple/api_iOS/Info.plist | 4 +- .../gen/apple/api_iOS/api_iOS.entitlements | 8 +- examples/api/src-tauri/gen/apple/project.yml | 6 +- examples/api/src-tauri/src/lib.rs | 1 + plugins/deep-link/examples/app/package.json | 2 +- plugins/dialog/test/tauri.conf.json | 2 +- plugins/nfc/.gitignore | 1 + plugins/nfc/Cargo.toml | 22 ++ plugins/nfc/LICENSE.spdx | 20 ++ plugins/nfc/LICENSE_APACHE-2.0 | 177 ++++++++++ plugins/nfc/LICENSE_MIT | 21 ++ plugins/nfc/README.md | 76 +++++ plugins/nfc/android/.gitignore | 2 + plugins/nfc/android/build.gradle.kts | 45 +++ plugins/nfc/android/proguard-rules.pro | 21 ++ plugins/nfc/android/settings.gradle | 2 + .../java/ExampleInstrumentedTest.kt | 28 ++ .../nfc/android/src/main/AndroidManifest.xml | 3 + .../nfc/android/src/main/java/NfcPlugin.kt | 23 ++ .../android/src/test/java/ExampleUnitTest.kt | 21 ++ plugins/nfc/build.rs | 16 + plugins/nfc/guest-js/index.ts | 7 + plugins/nfc/ios/.gitignore | 10 + plugins/nfc/ios/Package.swift | 33 ++ plugins/nfc/ios/README.md | 3 + plugins/nfc/ios/Sources/NfcPlugin.swift | 320 ++++++++++++++++++ .../ios/Tests/PluginTests/PluginTests.swift | 12 + plugins/nfc/package.json | 32 ++ plugins/nfc/rollup.config.mjs | 11 + plugins/nfc/src/api-iife.js | 1 + plugins/nfc/src/commands.rs | 15 + plugins/nfc/src/desktop.rs | 26 ++ plugins/nfc/src/error.rs | 25 ++ plugins/nfc/src/lib.rs | 53 +++ plugins/nfc/src/mobile.rs | 40 +++ plugins/nfc/src/models.rs | 17 + plugins/nfc/tsconfig.json | 4 + plugins/notification/test/tauri.conf.json | 2 +- .../examples/vanilla/package.json | 2 +- .../updater/tests/app-updater/tauri.conf.json | 2 +- .../examples/svelte-app/package.json | 2 +- pnpm-lock.yaml | 185 +++++----- 51 files changed, 1294 insertions(+), 220 deletions(-) create mode 100644 plugins/nfc/.gitignore create mode 100644 plugins/nfc/Cargo.toml create mode 100644 plugins/nfc/LICENSE.spdx create mode 100644 plugins/nfc/LICENSE_APACHE-2.0 create mode 100644 plugins/nfc/LICENSE_MIT create mode 100644 plugins/nfc/README.md create mode 100644 plugins/nfc/android/.gitignore create mode 100644 plugins/nfc/android/build.gradle.kts create mode 100644 plugins/nfc/android/proguard-rules.pro create mode 100644 plugins/nfc/android/settings.gradle create mode 100644 plugins/nfc/android/src/androidTest/java/ExampleInstrumentedTest.kt create mode 100644 plugins/nfc/android/src/main/AndroidManifest.xml create mode 100644 plugins/nfc/android/src/main/java/NfcPlugin.kt create mode 100644 plugins/nfc/android/src/test/java/ExampleUnitTest.kt create mode 100644 plugins/nfc/build.rs create mode 100644 plugins/nfc/guest-js/index.ts create mode 100644 plugins/nfc/ios/.gitignore create mode 100644 plugins/nfc/ios/Package.swift create mode 100644 plugins/nfc/ios/README.md create mode 100644 plugins/nfc/ios/Sources/NfcPlugin.swift create mode 100644 plugins/nfc/ios/Tests/PluginTests/PluginTests.swift create mode 100644 plugins/nfc/package.json create mode 100644 plugins/nfc/rollup.config.mjs create mode 100644 plugins/nfc/src/api-iife.js create mode 100644 plugins/nfc/src/commands.rs create mode 100644 plugins/nfc/src/desktop.rs create mode 100644 plugins/nfc/src/error.rs create mode 100644 plugins/nfc/src/lib.rs create mode 100644 plugins/nfc/src/mobile.rs create mode 100644 plugins/nfc/src/models.rs create mode 100644 plugins/nfc/tsconfig.json diff --git a/Cargo.lock b/Cargo.lock index 110a10f4..55d36341 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -246,6 +246,7 @@ dependencies = [ "tauri-plugin-global-shortcut", "tauri-plugin-http", "tauri-plugin-log", + "tauri-plugin-nfc", "tauri-plugin-notification", "tauri-plugin-os", "tauri-plugin-process", @@ -5819,6 +5820,18 @@ dependencies = [ "time 0.3.24", ] +[[package]] +name = "tauri-plugin-nfc" +version = "1.0.0" +dependencies = [ + "log", + "serde", + "serde_json", + "tauri", + "tauri-build", + "thiserror", +] + [[package]] name = "tauri-plugin-notification" version = "2.0.0-alpha.3" diff --git a/examples/api/package.json b/examples/api/package.json index 8457e313..a9da148b 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -18,6 +18,7 @@ "@tauri-apps/plugin-fs": "2.0.0-alpha.1", "@tauri-apps/plugin-global-shortcut": "2.0.0-alpha.1", "@tauri-apps/plugin-http": "2.0.0-alpha.1", + "@tauri-apps/plugin-nfc": "1.0.0", "@tauri-apps/plugin-notification": "2.0.0-alpha.1", "@tauri-apps/plugin-os": "2.0.0-alpha.2", "@tauri-apps/plugin-process": "2.0.0-alpha.1", @@ -30,7 +31,7 @@ "@iconify-json/codicon": "^1.1.26", "@iconify-json/ph": "^1.1.5", "@sveltejs/vite-plugin-svelte": "^2.4.1", - "@tauri-apps/cli": "2.0.0-alpha.14", + "@tauri-apps/cli": "2.0.0-alpha.15", "@unocss/extractor-svelte": "^0.53.1", "internal-ip": "^8.0.0", "svelte": "^3.59.1", diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index 8fb867f5..d1cead09 100644 --- a/examples/api/src-tauri/Cargo.toml +++ b/examples/api/src-tauri/Cargo.toml @@ -25,6 +25,7 @@ tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.0-alpha.2" } tauri-plugin-http = { path = "../../../plugins/http", features = [ "multipart" ], version = "2.0.0-alpha.3" } tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.0.0-alpha.3", features = [ "windows7-compat" ] } +tauri-plugin-nfc = { path = "../../../plugins/nfc", version = "1.0.0" } tauri-plugin-os = { path = "../../../plugins/os", version = "2.0.0-alpha.2" } tauri-plugin-process = { path = "../../../plugins/process", version = "2.0.0-alpha.2" } tauri-plugin-shell = { path = "../../../plugins/shell", version = "2.0.0-alpha.2" } diff --git a/examples/api/src-tauri/Info.plist b/examples/api/src-tauri/Info.plist index fe253ec7..e228cb14 100644 --- a/examples/api/src-tauri/Info.plist +++ b/examples/api/src-tauri/Info.plist @@ -6,5 +6,7 @@ Request camera access for WebRTC NSMicrophoneUsageDescription Request microphone access for WebRTC + NFCReaderUsageDescription + NFC Test diff --git a/examples/api/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/api/kotlin/BuildTask.kt b/examples/api/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/api/kotlin/BuildTask.kt index 29b0f2af..fb486486 100644 --- a/examples/api/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/api/kotlin/BuildTask.kt +++ b/examples/api/src-tauri/gen/android/buildSrc/src/main/java/com/tauri/api/kotlin/BuildTask.kt @@ -32,7 +32,7 @@ open class BuildTask : DefaultTask() { val rootDirRel = rootDirRel ?: throw GradleException("rootDirRel cannot be null") val target = target ?: throw GradleException("target cannot be null") val release = release ?: throw GradleException("release cannot be null") - val args = listOf("/Users/lucas/projects/tauri/plugins-workspace/examples/api/./node_modules/.bin/../../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.14/node_modules/@tauri-apps/cli/tauri.js", "android", "android-studio-script"); + val args = listOf("/Users/lucas/projects/tauri/plugins-workspace/examples/api/./node_modules/.bin/../../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.15/node_modules/@tauri-apps/cli/tauri.js", "android", "android-studio-script"); project.exec { workingDir(File(project.projectDir, rootDirRel)) diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/Contents.json index dd3b8bcc..90eea7ec 100644 --- a/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/examples/api/src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,116 +1,116 @@ { - "images": [ + "images" : [ { - "size": "20x20", - "idiom": "iphone", - "filename": "AppIcon-20x20@2x.png", - "scale": "2x" + "size" : "20x20", + "idiom" : "iphone", + "filename" : "AppIcon-20x20@2x.png", + "scale" : "2x" }, { - "size": "20x20", - "idiom": "iphone", - "filename": "AppIcon-20x20@3x.png", - "scale": "3x" + "size" : "20x20", + "idiom" : "iphone", + "filename" : "AppIcon-20x20@3x.png", + "scale" : "3x" }, { - "size": "29x29", - "idiom": "iphone", - "filename": "AppIcon-29x29@2x-1.png", - "scale": "2x" + "size" : "29x29", + "idiom" : "iphone", + "filename" : "AppIcon-29x29@2x-1.png", + "scale" : "2x" }, { - "size": "29x29", - "idiom": "iphone", - "filename": "AppIcon-29x29@3x.png", - "scale": "3x" + "size" : "29x29", + "idiom" : "iphone", + "filename" : "AppIcon-29x29@3x.png", + "scale" : "3x" }, { - "size": "40x40", - "idiom": "iphone", - "filename": "AppIcon-40x40@2x.png", - "scale": "2x" + "size" : "40x40", + "idiom" : "iphone", + "filename" : "AppIcon-40x40@2x.png", + "scale" : "2x" }, { - "size": "40x40", - "idiom": "iphone", - "filename": "AppIcon-40x40@3x.png", - "scale": "3x" + "size" : "40x40", + "idiom" : "iphone", + "filename" : "AppIcon-40x40@3x.png", + "scale" : "3x" }, { - "size": "60x60", - "idiom": "iphone", - "filename": "AppIcon-60x60@2x.png", - "scale": "2x" + "size" : "60x60", + "idiom" : "iphone", + "filename" : "AppIcon-60x60@2x.png", + "scale" : "2x" }, { - "size": "60x60", - "idiom": "iphone", - "filename": "AppIcon-60x60@3x.png", - "scale": "3x" + "size" : "60x60", + "idiom" : "iphone", + "filename" : "AppIcon-60x60@3x.png", + "scale" : "3x" }, { - "size": "20x20", - "idiom": "ipad", - "filename": "AppIcon-20x20@1x.png", - "scale": "1x" + "size" : "20x20", + "idiom" : "ipad", + "filename" : "AppIcon-20x20@1x.png", + "scale" : "1x" }, { - "size": "20x20", - "idiom": "ipad", - "filename": "AppIcon-20x20@2x-1.png", - "scale": "2x" + "size" : "20x20", + "idiom" : "ipad", + "filename" : "AppIcon-20x20@2x-1.png", + "scale" : "2x" }, { - "size": "29x29", - "idiom": "ipad", - "filename": "AppIcon-29x29@1x.png", - "scale": "1x" + "size" : "29x29", + "idiom" : "ipad", + "filename" : "AppIcon-29x29@1x.png", + "scale" : "1x" }, { - "size": "29x29", - "idiom": "ipad", - "filename": "AppIcon-29x29@2x.png", - "scale": "2x" + "size" : "29x29", + "idiom" : "ipad", + "filename" : "AppIcon-29x29@2x.png", + "scale" : "2x" }, { - "size": "40x40", - "idiom": "ipad", - "filename": "AppIcon-40x40@1x.png", - "scale": "1x" + "size" : "40x40", + "idiom" : "ipad", + "filename" : "AppIcon-40x40@1x.png", + "scale" : "1x" }, { - "size": "40x40", - "idiom": "ipad", - "filename": "AppIcon-40x40@2x-1.png", - "scale": "2x" + "size" : "40x40", + "idiom" : "ipad", + "filename" : "AppIcon-40x40@2x-1.png", + "scale" : "2x" }, { - "size": "76x76", - "idiom": "ipad", - "filename": "AppIcon-76x76@1x.png", - "scale": "1x" + "size" : "76x76", + "idiom" : "ipad", + "filename" : "AppIcon-76x76@1x.png", + "scale" : "1x" }, { - "size": "76x76", - "idiom": "ipad", - "filename": "AppIcon-76x76@2x.png", - "scale": "2x" + "size" : "76x76", + "idiom" : "ipad", + "filename" : "AppIcon-76x76@2x.png", + "scale" : "2x" }, { - "size": "83.5x83.5", - "idiom": "ipad", - "filename": "AppIcon-83.5x83.5@2x.png", - "scale": "2x" + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "AppIcon-83.5x83.5@2x.png", + "scale" : "2x" }, { - "size": "1024x1024", - "idiom": "ios-marketing", - "filename": "AppIcon-512@2x.png", - "scale": "1x" + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "AppIcon-512@2x.png", + "scale" : "1x" } ], - "info": { - "version": 1, - "author": "xcode" + "info" : { + "version" : 1, + "author" : "xcode" } -} +} \ No newline at end of file diff --git a/examples/api/src-tauri/gen/apple/Assets.xcassets/Contents.json b/examples/api/src-tauri/gen/apple/Assets.xcassets/Contents.json index 97a8662e..da4a164c 100644 --- a/examples/api/src-tauri/gen/apple/Assets.xcassets/Contents.json +++ b/examples/api/src-tauri/gen/apple/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ { - "info": { - "version": 1, - "author": "xcode" + "info" : { + "version" : 1, + "author" : "xcode" } -} +} \ No newline at end of file diff --git a/examples/api/src-tauri/gen/apple/api.xcodeproj/project.pbxproj b/examples/api/src-tauri/gen/apple/api.xcodeproj/project.pbxproj index 63f5ac21..264f14e5 100644 --- a/examples/api/src-tauri/gen/apple/api.xcodeproj/project.pbxproj +++ b/examples/api/src-tauri/gen/apple/api.xcodeproj/project.pbxproj @@ -234,7 +234,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "node /Users/lucas/projects/tauri/plugins-workspace/examples/api/./node_modules/.bin/../../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.14/node_modules/@tauri-apps/cli/tauri.js ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths \"${FRAMEWORK_SEARCH_PATHS:?}\" --header-search-paths \"${HEADER_SEARCH_PATHS:?}\" --gcc-preprocessor-definitions \"${GCC_PREPROCESSOR_DEFINITIONS:-}\" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}"; + shellScript = "/Users/lucas/projects/tauri/tauri/tooling/cli/target/debug/./cargo-tauri ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths \"${FRAMEWORK_SEARCH_PATHS:?}\" --header-search-paths \"${HEADER_SEARCH_PATHS:?}\" --gcc-preprocessor-definitions \"${GCC_PREPROCESSOR_DEFINITIONS:-}\" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/examples/api/src-tauri/gen/apple/api.xcodeproj/xcshareddata/xcschemes/api_iOS.xcscheme b/examples/api/src-tauri/gen/apple/api.xcodeproj/xcshareddata/xcschemes/api_iOS.xcscheme index 3680d405..b4aafe53 100644 --- a/examples/api/src-tauri/gen/apple/api.xcodeproj/xcshareddata/xcschemes/api_iOS.xcscheme +++ b/examples/api/src-tauri/gen/apple/api.xcodeproj/xcshareddata/xcschemes/api_iOS.xcscheme @@ -1,11 +1,10 @@ + version = "1.3"> + buildImplicitDependencies = "YES"> @@ -27,21 +26,16 @@ buildConfiguration = "debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "NO" - onlyGenerateCoverageForSpecifiedTargets = "NO"> + shouldUseLaunchSchemeArgsEnv = "NO"> - - - - + + - - - - + NFCReaderUsageDescription + NFC Test CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -40,7 +42,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - NSCameraUsageDescription - To be able to scan barcodes diff --git a/examples/api/src-tauri/gen/apple/api_iOS/api_iOS.entitlements b/examples/api/src-tauri/gen/apple/api_iOS/api_iOS.entitlements index 0c67376e..51d76043 100644 --- a/examples/api/src-tauri/gen/apple/api_iOS/api_iOS.entitlements +++ b/examples/api/src-tauri/gen/apple/api_iOS/api_iOS.entitlements @@ -1,5 +1,11 @@ - + + com.apple.developer.nfc.readersession.formats + + TAG + NDEF + + diff --git a/examples/api/src-tauri/gen/apple/project.yml b/examples/api/src-tauri/gen/apple/project.yml index 53f53deb..2c6b55af 100644 --- a/examples/api/src-tauri/gen/apple/project.yml +++ b/examples/api/src-tauri/gen/apple/project.yml @@ -1,7 +1,3 @@ -# Copyright 2019-2023 Tauri Programme within The Commons Conservancy -# SPDX-License-Identifier: Apache-2.0 -# SPDX-License-Identifier: MIT - name: api options: bundleIdPrefix: com.tauri @@ -84,7 +80,7 @@ targets: - sdk: UIKit.framework - sdk: WebKit.framework preBuildScripts: - - script: node /Users/lucas/projects/tauri/plugins-workspace/examples/api/./node_modules/.bin/../../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.14/node_modules/@tauri-apps/cli/tauri.js ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths "${FRAMEWORK_SEARCH_PATHS:?}" --header-search-paths "${HEADER_SEARCH_PATHS:?}" --gcc-preprocessor-definitions "${GCC_PREPROCESSOR_DEFINITIONS:-}" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?} + - script: /Users/lucas/projects/tauri/tauri/tooling/cli/target/debug/./cargo-tauri ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths "${FRAMEWORK_SEARCH_PATHS:?}" --header-search-paths "${HEADER_SEARCH_PATHS:?}" --gcc-preprocessor-definitions "${GCC_PREPROCESSOR_DEFINITIONS:-}" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?} name: Build Rust Code basedOnDependencyAnalysis: false outputFiles: diff --git a/examples/api/src-tauri/src/lib.rs b/examples/api/src-tauri/src/lib.rs index 2e04967a..a3507b54 100644 --- a/examples/api/src-tauri/src/lib.rs +++ b/examples/api/src-tauri/src/lib.rs @@ -36,6 +36,7 @@ pub fn run() { .plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_http::init()) + .plugin(tauri_plugin_nfc::init()) .plugin(tauri_plugin_notification::init()) .plugin(tauri_plugin_os::init()) .plugin(tauri_plugin_process::init()) diff --git a/plugins/deep-link/examples/app/package.json b/plugins/deep-link/examples/app/package.json index 90c68362..f05d3f45 100644 --- a/plugins/deep-link/examples/app/package.json +++ b/plugins/deep-link/examples/app/package.json @@ -14,7 +14,7 @@ "@tauri-apps/plugin-deep-link": "2.0.0-alpha.0" }, "devDependencies": { - "@tauri-apps/cli": "^2.0.0-alpha.14", + "@tauri-apps/cli": "^2.0.0-alpha.15", "internal-ip": "^7.0.0", "typescript": "^4.8.2", "vite": "^4.2.1" diff --git a/plugins/dialog/test/tauri.conf.json b/plugins/dialog/test/tauri.conf.json index 5c0b0c51..9ed7c0c7 100644 --- a/plugins/dialog/test/tauri.conf.json +++ b/plugins/dialog/test/tauri.conf.json @@ -1,5 +1,5 @@ { - "$schema": "../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.14/node_modules/@tauri-apps/cli/schema.json", + "$schema": "../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.15/node_modules/@tauri-apps/cli/schema.json", "build": { "distDir": ".", "devPath": "http://localhost:4000" diff --git a/plugins/nfc/.gitignore b/plugins/nfc/.gitignore new file mode 100644 index 00000000..1b0b469d --- /dev/null +++ b/plugins/nfc/.gitignore @@ -0,0 +1 @@ +/.tauri diff --git a/plugins/nfc/Cargo.toml b/plugins/nfc/Cargo.toml new file mode 100644 index 00000000..4479e215 --- /dev/null +++ b/plugins/nfc/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "tauri-plugin-nfc" +version = "1.0.0" +edition = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +links = "tauri-plugin-nfc" + +[package.metadata.docs.rs] +features = [ "tauri/dox" ] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = { workspace = true } + +[dependencies] +serde = { workspace = true } +serde_json = { workspace = true } +tauri = { workspace = true } +log = { workspace = true } +thiserror = { workspace = true } diff --git a/plugins/nfc/LICENSE.spdx b/plugins/nfc/LICENSE.spdx new file mode 100644 index 00000000..cdd0df5a --- /dev/null +++ b/plugins/nfc/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/plugins/nfc/LICENSE_APACHE-2.0 b/plugins/nfc/LICENSE_APACHE-2.0 new file mode 100644 index 00000000..4947287f --- /dev/null +++ b/plugins/nfc/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/plugins/nfc/LICENSE_MIT b/plugins/nfc/LICENSE_MIT new file mode 100644 index 00000000..4d754725 --- /dev/null +++ b/plugins/nfc/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/plugins/nfc/README.md b/plugins/nfc/README.md new file mode 100644 index 00000000..d327f451 --- /dev/null +++ b/plugins/nfc/README.md @@ -0,0 +1,76 @@ +![NFC](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/nfc/banner.png) + + + +## 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-nfc = "2.0.0-alpha" +# alternatively with Git: +tauri-plugin-nfc = { 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-nfc +# or +npm add @tauri-apps/plugin-nfc +# or +yarn add @tauri-apps/plugin-nfc + +# alternatively with Git: +pnpm add https://github.com/tauri-apps/tauri-plugin-nfc#v2 +# or +npm add https://github.com/tauri-apps/tauri-plugin-nfc#v2 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-nfc#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_nfc::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. + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/nfc/android/.gitignore b/plugins/nfc/android/.gitignore new file mode 100644 index 00000000..c0f21ec2 --- /dev/null +++ b/plugins/nfc/android/.gitignore @@ -0,0 +1,2 @@ +/build +/.tauri diff --git a/plugins/nfc/android/build.gradle.kts b/plugins/nfc/android/build.gradle.kts new file mode 100644 index 00000000..677b587f --- /dev/null +++ b/plugins/nfc/android/build.gradle.kts @@ -0,0 +1,45 @@ +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "app.tauri.nfc" + compileSdk = 32 + + defaultConfig { + minSdk = 24 + targetSdk = 32 + + 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("androidx.appcompat:appcompat:1.6.0") + implementation("com.google.android.material:material:1.7.0") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + implementation(project(":tauri-android")) +} diff --git a/plugins/nfc/android/proguard-rules.pro b/plugins/nfc/android/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/plugins/nfc/android/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/plugins/nfc/android/settings.gradle b/plugins/nfc/android/settings.gradle new file mode 100644 index 00000000..14a752e4 --- /dev/null +++ b/plugins/nfc/android/settings.gradle @@ -0,0 +1,2 @@ +include ':tauri-android' +project(':tauri-android').projectDir = new File('./.tauri/tauri-api') diff --git a/plugins/nfc/android/src/androidTest/java/ExampleInstrumentedTest.kt b/plugins/nfc/android/src/androidTest/java/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..f0f7b66e --- /dev/null +++ b/plugins/nfc/android/src/androidTest/java/ExampleInstrumentedTest.kt @@ -0,0 +1,28 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.nfc + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("app.tauri.nfc", appContext.packageName) + } +} diff --git a/plugins/nfc/android/src/main/AndroidManifest.xml b/plugins/nfc/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..9a40236b --- /dev/null +++ b/plugins/nfc/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/plugins/nfc/android/src/main/java/NfcPlugin.kt b/plugins/nfc/android/src/main/java/NfcPlugin.kt new file mode 100644 index 00000000..4ff9a2d0 --- /dev/null +++ b/plugins/nfc/android/src/main/java/NfcPlugin.kt @@ -0,0 +1,23 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.nfc + +import android.app.Activity +import app.tauri.annotation.Command +import app.tauri.annotation.TauriPlugin +import app.tauri.plugin.JSObject +import app.tauri.plugin.Plugin +import app.tauri.plugin.Invoke + +@TauriPlugin +class ExamplePlugin(private val activity: Activity): Plugin(activity) { + @Command + fun ping(invoke: Invoke) { + val value = invoke.getString("value") ?: "" + val ret = JSObject() + ret.put("value", value) + invoke.resolve(ret) + } +} diff --git a/plugins/nfc/android/src/test/java/ExampleUnitTest.kt b/plugins/nfc/android/src/test/java/ExampleUnitTest.kt new file mode 100644 index 00000000..2af426f8 --- /dev/null +++ b/plugins/nfc/android/src/test/java/ExampleUnitTest.kt @@ -0,0 +1,21 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +package app.tauri.nfc + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/plugins/nfc/build.rs b/plugins/nfc/build.rs new file mode 100644 index 00000000..743096a6 --- /dev/null +++ b/plugins/nfc/build.rs @@ -0,0 +1,16 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use std::process::exit; + +fn main() { + if let Err(error) = tauri_build::mobile::PluginBuilder::new() + .android_path("android") + .ios_path("ios") + .run() + { + println!("{error:#}"); + exit(1); + } +} diff --git a/plugins/nfc/guest-js/index.ts b/plugins/nfc/guest-js/index.ts new file mode 100644 index 00000000..38c5009c --- /dev/null +++ b/plugins/nfc/guest-js/index.ts @@ -0,0 +1,7 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +export async function scanNdef() {} + +export async function scanTag() {} diff --git a/plugins/nfc/ios/.gitignore b/plugins/nfc/ios/.gitignore new file mode 100644 index 00000000..5922fdaa --- /dev/null +++ b/plugins/nfc/ios/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc +Package.resolved diff --git a/plugins/nfc/ios/Package.swift b/plugins/nfc/ios/Package.swift new file mode 100644 index 00000000..e8f1f19a --- /dev/null +++ b/plugins/nfc/ios/Package.swift @@ -0,0 +1,33 @@ +// 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-nfc", + platforms: [ + .iOS(.v13) + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-nfc", + type: .static, + targets: ["tauri-plugin-nfc"]) + ], + 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-nfc", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] +) diff --git a/plugins/nfc/ios/README.md b/plugins/nfc/ios/README.md new file mode 100644 index 00000000..88a429b7 --- /dev/null +++ b/plugins/nfc/ios/README.md @@ -0,0 +1,3 @@ +# Tauri Plugin Nfc + +A description of this package. diff --git a/plugins/nfc/ios/Sources/NfcPlugin.swift b/plugins/nfc/ios/Sources/NfcPlugin.swift new file mode 100644 index 00000000..90e5c22c --- /dev/null +++ b/plugins/nfc/ios/Sources/NfcPlugin.swift @@ -0,0 +1,320 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import CoreNFC +import SwiftRs +import Tauri +import UIKit +import WebKit + +enum ScanKind { + case ndef, tag +} + +enum TagProcessMode { + case write, read +} + +class Session { + let nfcSession: NFCReaderSession? + let invoke: Invoke + let keepAlive: Bool + let tagProcessMode: TagProcessMode + var tagStatus: NFCNDEFStatus? + var tag: NFCNDEFTag? + var writeMessage: NFCNDEFMessage? + + init( + nfcSession: NFCReaderSession?, invoke: Invoke, keepAlive: Bool, tagProcessMode: TagProcessMode + ) { + self.nfcSession = nfcSession + self.invoke = invoke + self.keepAlive = keepAlive + self.tagProcessMode = tagProcessMode + } +} + +class NfcPlugin: Plugin, NFCTagReaderSessionDelegate, NFCNDEFReaderSessionDelegate { + var session: Session? + + func tagReaderSessionDidBecomeActive( + _ session: NFCTagReaderSession + ) { + Logger.info("tagReaderSessionDidBecomeActive") + } + + func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) { + Logger.info("detected tags!") + let tag = tags.first! + + session.connect( + to: tag, + completionHandler: { [self] (error) in + if let error = error { + if self.session?.keepAlive != true { + self.closeSession(session, error: "cannot connect to tag: \(error)") + } + } else { + let ndefTag: NFCNDEFTag + switch tag { + case let .feliCa(tag): + ndefTag = tag as NFCNDEFTag + break + case let .miFare(tag): + ndefTag = tag as NFCNDEFTag + break + case let .iso15693(tag): + ndefTag = tag as NFCNDEFTag + break + case let .iso7816(tag): + ndefTag = tag as NFCNDEFTag + break + default: + return + } + + self.processTag( + session: session, tag: ndefTag, metadata: tagMetadata(tag), + mode: self.session!.tagProcessMode) + } + } + ) + } + + func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) { + Logger.error("Tag reader session error") + self.session?.invoke.reject("session invalidated with error: \(error)") + } + + func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) { + var jsonMessages: [JsonObject] = [] + for message in messages { + jsonMessages.append(ndefMessageToJson(message)) + } + self.session?.invoke.resolve(["messages": jsonMessages]) + } + + func readerSession(_ session: NFCNDEFReaderSession, didDetect tags: [NFCNDEFTag]) { + let tag = tags.first! + + session.connect( + to: tag, + completionHandler: { [self] (error) in + if let error = error { + if self.session?.keepAlive != true { + self.closeSession(session, error: "cannot connect to tag: \(error)") + } + } else { + self.processTag( + session: session, tag: tag, metadata: [:], + mode: self.session!.tagProcessMode) + } + } + ) + + } + + func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) { + if (error as NSError).code + == NFCReaderError.Code.readerSessionInvalidationErrorFirstNDEFTagRead.rawValue + { + // not an error because we're using invalidateAfterFirstRead: true + Logger.debug("readerSessionInvalidationErrorFirstNDEFTagRead") + } else { + Logger.error("NDEF reader session error") + self.session?.invoke.reject("session invalidated with error: \(error)") + } + } + + private func tagMetadata(_ tag: NFCTag) -> JsonObject { + var metadata: JsonObject = [:] + + switch tag { + case .feliCa: + metadata["type"] = "FeliCa" + metadata["id"] = nil + break + case let .miFare(tag): + metadata["type"] = "MiFare" + metadata["id"] = tag.identifier + break + case let .iso15693(tag): + metadata["type"] = "ISO15693" + metadata["id"] = tag.identifier + break + case let .iso7816(tag): + metadata["type"] = "ISO7816Compatible" + metadata["id"] = tag.identifier + break + default: + metadata["type"] = "Unknown" + metadata["id"] = nil + break + } + + return metadata + } + + private func closeSession(_ session: NFCReaderSession) { + session.invalidate() + self.session = nil + } + + private func closeSession(_ session: NFCReaderSession, error: String) { + session.invalidate(errorMessage: error) + self.session = nil + } + + private func processTag( + session: NFCReaderSession, tag: T, metadata: JsonObject, mode: TagProcessMode + ) { + tag.queryNDEFStatus(completionHandler: { + [self] (status, capacity, error) in + if let error = error { + if self.session?.keepAlive != true { + self.closeSession(session, error: "cannot connect to tag: \(error)") + } + } else { + switch mode { + case .write: + self.writeNDEFTag(session: session, status: status, tag: tag) + break + case .read: + if self.session?.keepAlive == true { + self.session!.tagStatus = status + self.session!.tag = tag + } + self.readNDEFTag(session: session, status: status, tag: tag, metadata: metadata) + break + } + } + }) + } + + private func writeNDEFTag(session: NFCReaderSession, status: NFCNDEFStatus, tag: T) + { + switch status { + case .notSupported: + self.closeSession(session, error: "Tag is not an NDEF-formatted tag") + break + case .readOnly: + self.closeSession(session, error: "Read only tag") + break + case .readWrite: + if let currentSession = self.session { + tag.writeNDEF( + currentSession.writeMessage!, + completionHandler: { (error) in + if let error = error { + if currentSession.keepAlive != true { + self.closeSession(session, error: "cannot write to tag: \(error)") + } + } else { + session.alertMessage = "Data wrote to NFC tag" + currentSession.invoke.resolve() + self.closeSession(session) + } + }) + } + break + default: + return + } + } + + private func readNDEFTag( + session: NFCReaderSession, status: NFCNDEFStatus, tag: T, metadata: JsonObject + ) { + tag.readNDEF(completionHandler: { + [self] (message, error) in + if let error = error { + let code = (error as NSError).code + if code != 403 { + self.closeSession(session, error: "Failed to read: \(error)") + return + } + } + + session.alertMessage = "Successfully read tag" + self.resolveInvoke(message: message, metadata: metadata) + self.closeSession(session) + }) + } + + private func resolveInvoke(message: NFCNDEFMessage?, metadata: JsonObject) { + var data: JsonObject = [:] + + if let message = message { + var tag = ndefMessageToJson(message) + tag.merge(metadata) { (_, new) in new } + data["tag"] = tag + } + + self.session?.invoke.resolve(data) + } + + private func ndefMessageToJson(_ message: NFCNDEFMessage) -> JsonObject { + var tag: JsonObject = [:] + + var records: [JsonObject] = [] + for record in message.records { + var recordJson: JsonObject = [:] + recordJson["tnf"] = record.typeNameFormat + recordJson["type"] = record.type + recordJson["id"] = record.identifier + recordJson["payload"] = record.payload + + records.append(recordJson) + } + + tag["records"] = records + + return tag + } + + @objc public func scanNdef(_ invoke: Invoke) { + DispatchQueue.main.async { [self] in + self.startScanSession(invoke: invoke, kind: .ndef) + } + } + + @objc public func scanTag(_ invoke: Invoke) { + DispatchQueue.main.async { [self] in + self.startScanSession(invoke: invoke, kind: .tag) + } + } + + private func startScanSession(invoke: Invoke, kind: ScanKind) { + let keepAlive = invoke.getBool("keepAlive", false) + let nfcSession: NFCReaderSession? + + switch kind { + case .tag: + nfcSession = NFCTagReaderSession( + pollingOption: [.iso14443, .iso15693], + delegate: self, + queue: DispatchQueue.main + ) + break + case .ndef: + nfcSession = NFCNDEFReaderSession( + delegate: self, + queue: DispatchQueue.main, + invalidateAfterFirstRead: true + ) + break + } + + nfcSession?.alertMessage = "Hold near NFC tag to scan." + nfcSession?.begin() + + self.session = Session( + nfcSession: nfcSession, invoke: invoke, keepAlive: keepAlive, tagProcessMode: .read) + } +} + +@_cdecl("init_plugin_nfc") +func initPlugin() -> Plugin { + return NfcPlugin() +} diff --git a/plugins/nfc/ios/Tests/PluginTests/PluginTests.swift b/plugins/nfc/ios/Tests/PluginTests/PluginTests.swift new file mode 100644 index 00000000..99992ce4 --- /dev/null +++ b/plugins/nfc/ios/Tests/PluginTests/PluginTests.swift @@ -0,0 +1,12 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +import XCTest +@testable import ExamplePlugin + +final class ExamplePluginTests: XCTestCase { + func testExample() throws { + let plugin = ExamplePlugin() + } +} diff --git a/plugins/nfc/package.json b/plugins/nfc/package.json new file mode 100644 index 00000000..a5a0dfd6 --- /dev/null +++ b/plugins/nfc/package.json @@ -0,0 +1,32 @@ +{ + "name": "@tauri-apps/plugin-nfc", + "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.6.0" + }, + "dependencies": { + "@tauri-apps/api": "2.0.0-alpha.8" + } +} diff --git a/plugins/nfc/rollup.config.mjs b/plugins/nfc/rollup.config.mjs new file mode 100644 index 00000000..99a3dd31 --- /dev/null +++ b/plugins/nfc/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/plugins/nfc/src/api-iife.js b/plugins/nfc/src/api-iife.js new file mode 100644 index 00000000..9480d5ff --- /dev/null +++ b/plugins/nfc/src/api-iife.js @@ -0,0 +1 @@ +if("__TAURI__"in window){var __TAURI_NFC__=function(_){"use strict";return _.scanNdef=async function(){},_.scanTag=async function(){},_}({});Object.defineProperty(window.__TAURI__,"nfc",{value:__TAURI_NFC__})} diff --git a/plugins/nfc/src/commands.rs b/plugins/nfc/src/commands.rs new file mode 100644 index 00000000..99cc0eaf --- /dev/null +++ b/plugins/nfc/src/commands.rs @@ -0,0 +1,15 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use tauri::{AppHandle, command, Runtime, Window}; + +use crate::Result; + +#[command] +pub(crate) async fn execute( + _app: AppHandle, + _window: Window, +) -> Result { + Ok("success".to_string()) +} diff --git a/plugins/nfc/src/desktop.rs b/plugins/nfc/src/desktop.rs new file mode 100644 index 00000000..24bc7990 --- /dev/null +++ b/plugins/nfc/src/desktop.rs @@ -0,0 +1,26 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::de::DeserializeOwned; +use tauri::{plugin::PluginApi, AppHandle, Runtime}; + +use crate::models::*; + +pub fn init( + app: &AppHandle, + _api: PluginApi, +) -> crate::Result> { + Ok(Nfc(app.clone())) +} + +/// Access to the nfc APIs. +pub struct Nfc(AppHandle); + +impl Nfc { + pub fn ping(&self, payload: PingRequest) -> crate::Result { + Ok(PingResponse { + value: payload.value, + }) + } +} diff --git a/plugins/nfc/src/error.rs b/plugins/nfc/src/error.rs new file mode 100644 index 00000000..339e763b --- /dev/null +++ b/plugins/nfc/src/error.rs @@ -0,0 +1,25 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{ser::Serializer, Serialize}; + +pub type Result = std::result::Result; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + Io(#[from] std::io::Error), + #[cfg(mobile)] + #[error(transparent)] + PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), +} + +impl Serialize for Error { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } +} diff --git a/plugins/nfc/src/lib.rs b/plugins/nfc/src/lib.rs new file mode 100644 index 00000000..cc2c79c4 --- /dev/null +++ b/plugins/nfc/src/lib.rs @@ -0,0 +1,53 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use tauri::{ + plugin::{Builder, TauriPlugin}, + Manager, Runtime, +}; + +pub use models::*; + +#[cfg(desktop)] +mod desktop; +#[cfg(mobile)] +mod mobile; + +mod commands; +mod error; +mod models; + +pub use error::{Error, Result}; + +#[cfg(desktop)] +use desktop::Nfc; +#[cfg(mobile)] +use mobile::Nfc; + +/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the nfc APIs. +pub trait NfcExt { + fn nfc(&self) -> &Nfc; +} + +impl> crate::NfcExt for T { + fn nfc(&self) -> &Nfc { + self.state::>().inner() + } +} + +/// Initializes the plugin. +pub fn init() -> TauriPlugin { + Builder::new("nfc") + .js_init_script(include_str!("api-iife.js").to_string()) + .invoke_handler(tauri::generate_handler![commands::execute]) + .setup(|app, api| { + #[cfg(mobile)] + let nfc = mobile::init(app, api)?; + #[cfg(desktop)] + let nfc = desktop::init(app, api)?; + app.manage(nfc); + Ok(()) + }) + .build() +} diff --git a/plugins/nfc/src/mobile.rs b/plugins/nfc/src/mobile.rs new file mode 100644 index 00000000..0c190b06 --- /dev/null +++ b/plugins/nfc/src/mobile.rs @@ -0,0 +1,40 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::de::DeserializeOwned; +use tauri::{ + plugin::{PluginApi, PluginHandle}, + AppHandle, Runtime, +}; + +use crate::models::*; + +#[cfg(target_os = "android")] +const PLUGIN_IDENTIFIER: &str = "app.tauri.nfc"; + +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_nfc); + +// initializes the Kotlin or Swift plugin classes +pub fn init( + _app: &AppHandle, + api: PluginApi, +) -> crate::Result> { + #[cfg(target_os = "android")] + let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "NfcPlugin")?; + #[cfg(target_os = "ios")] + let handle = api.register_ios_plugin(init_plugin_nfc)?; + Ok(Nfc(handle)) +} + +/// Access to the nfc APIs. +pub struct Nfc(PluginHandle); + +impl Nfc { + pub fn ping(&self, payload: PingRequest) -> crate::Result { + self.0 + .run_mobile_plugin("ping", payload) + .map_err(Into::into) + } +} diff --git a/plugins/nfc/src/models.rs b/plugins/nfc/src/models.rs new file mode 100644 index 00000000..d50dcf91 --- /dev/null +++ b/plugins/nfc/src/models.rs @@ -0,0 +1,17 @@ +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct PingRequest { + pub value: Option, +} + +#[derive(Debug, Clone, Default, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct PingResponse { + pub value: Option, +} diff --git a/plugins/nfc/tsconfig.json b/plugins/nfc/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/nfc/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/notification/test/tauri.conf.json b/plugins/notification/test/tauri.conf.json index 5c0b0c51..9ed7c0c7 100644 --- a/plugins/notification/test/tauri.conf.json +++ b/plugins/notification/test/tauri.conf.json @@ -1,5 +1,5 @@ { - "$schema": "../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.14/node_modules/@tauri-apps/cli/schema.json", + "$schema": "../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.15/node_modules/@tauri-apps/cli/schema.json", "build": { "distDir": ".", "devPath": "http://localhost:4000" diff --git a/plugins/single-instance/examples/vanilla/package.json b/plugins/single-instance/examples/vanilla/package.json index e2cf21bb..87037060 100644 --- a/plugins/single-instance/examples/vanilla/package.json +++ b/plugins/single-instance/examples/vanilla/package.json @@ -9,6 +9,6 @@ "author": "", "license": "MIT", "devDependencies": { - "@tauri-apps/cli": "2.0.0-alpha.14" + "@tauri-apps/cli": "2.0.0-alpha.15" } } diff --git a/plugins/updater/tests/app-updater/tauri.conf.json b/plugins/updater/tests/app-updater/tauri.conf.json index 79a1a855..440dd856 100644 --- a/plugins/updater/tests/app-updater/tauri.conf.json +++ b/plugins/updater/tests/app-updater/tauri.conf.json @@ -1,5 +1,5 @@ { - "$schema": "../../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.14/node_modules/@tauri-apps/cli/schema.json", + "$schema": "../../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.15/node_modules/@tauri-apps/cli/schema.json", "build": { "distDir": [], "devPath": [] diff --git a/plugins/websocket/examples/svelte-app/package.json b/plugins/websocket/examples/svelte-app/package.json index cc7c6b53..9e796e40 100644 --- a/plugins/websocket/examples/svelte-app/package.json +++ b/plugins/websocket/examples/svelte-app/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@sveltejs/adapter-static": "1.0.0-next.50", "@sveltejs/kit": "1.22.3", - "@tauri-apps/cli": "2.0.0-alpha.14", + "@tauri-apps/cli": "2.0.0-alpha.15", "svelte": "4.0.5", "svelte-check": "3.4.6", "tslib": "2.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cc5ad9e1..bd3f1eae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -90,6 +90,9 @@ importers: '@tauri-apps/plugin-http': specifier: 2.0.0-alpha.1 version: link:../../plugins/http + '@tauri-apps/plugin-nfc': + specifier: 1.0.0 + version: link:../../plugins/nfc '@tauri-apps/plugin-notification': specifier: 2.0.0-alpha.1 version: link:../../plugins/notification @@ -122,8 +125,8 @@ importers: specifier: ^2.4.1 version: 2.4.1(svelte@3.59.1)(vite@4.4.4) '@tauri-apps/cli': - specifier: 2.0.0-alpha.14 - version: 2.0.0-alpha.14 + specifier: 2.0.0-alpha.15 + version: 2.0.0-alpha.15 '@unocss/extractor-svelte': specifier: ^0.53.1 version: 0.53.1 @@ -135,7 +138,7 @@ importers: version: 3.59.1 unocss: specifier: ^0.53.1 - version: 0.53.1(postcss@8.4.26)(vite@4.4.4) + version: 0.53.1(postcss@8.4.26)(rollup@3.26.3)(vite@4.4.4) vite: specifier: ^4.3.9 version: 4.4.4 @@ -220,8 +223,8 @@ importers: version: link:../.. devDependencies: '@tauri-apps/cli': - specifier: ^2.0.0-alpha.14 - version: 2.0.0-alpha.14 + specifier: ^2.0.0-alpha.15 + version: 2.0.0-alpha.15 internal-ip: specifier: ^7.0.0 version: 7.0.0 @@ -282,6 +285,16 @@ importers: specifier: 2.6.0 version: 2.6.0 + plugins/nfc: + dependencies: + '@tauri-apps/api': + specifier: 2.0.0-alpha.8 + version: 2.0.0-alpha.8 + devDependencies: + tslib: + specifier: 2.6.0 + version: 2.6.0 + plugins/notification: dependencies: '@tauri-apps/api': @@ -335,8 +348,8 @@ importers: plugins/single-instance/examples/vanilla: devDependencies: '@tauri-apps/cli': - specifier: 2.0.0-alpha.14 - version: 2.0.0-alpha.14 + specifier: 2.0.0-alpha.15 + version: 2.0.0-alpha.15 plugins/sql: dependencies: @@ -411,8 +424,8 @@ importers: specifier: 1.22.3 version: 1.22.3(svelte@4.0.5)(vite@4.4.4) '@tauri-apps/cli': - specifier: 2.0.0-alpha.14 - version: 2.0.0-alpha.14 + specifier: 2.0.0-alpha.15 + version: 2.0.0-alpha.15 svelte: specifier: 4.0.5 version: 4.0.5 @@ -592,7 +605,7 @@ packages: peerDependencies: mocha: ^10.0.0 dependencies: - effection: 2.0.7 + effection: 2.0.7(mocha@10.2.0) mocha: 10.2.0 dev: true @@ -1037,7 +1050,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) espree: 9.6.1 globals: 13.20.0 ignore: 5.2.4 @@ -1059,7 +1072,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 1.2.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -1100,7 +1113,7 @@ packages: '@antfu/install-pkg': 0.1.1 '@antfu/utils': 0.7.5 '@iconify/types': 2.0.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) kolorist: 1.8.0 local-pkg: 0.4.3 transitivePeerDependencies: @@ -1225,20 +1238,6 @@ packages: typescript: 5.1.6 dev: true - /@rollup/pluginutils@5.0.2: - resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0 - peerDependenciesMeta: - rollup: - optional: true - dependencies: - '@types/estree': 1.0.1 - estree-walker: 2.0.2 - picomatch: 2.3.1 - dev: true - /@rollup/pluginutils@5.0.2(rollup@3.26.3): resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} engines: {node: '>=14.0.0'} @@ -1298,7 +1297,7 @@ packages: vite: ^4.0.0 dependencies: '@sveltejs/vite-plugin-svelte': 2.4.1(svelte@3.59.1)(vite@4.4.4) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) svelte: 3.59.1 vite: 4.4.4 transitivePeerDependencies: @@ -1314,7 +1313,7 @@ packages: vite: ^4.0.0 dependencies: '@sveltejs/vite-plugin-svelte': 2.4.2(svelte@4.0.5)(vite@4.4.4) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) svelte: 4.0.5 vite: 4.4.4 transitivePeerDependencies: @@ -1329,7 +1328,7 @@ packages: vite: ^4.0.0 dependencies: '@sveltejs/vite-plugin-svelte-inspector': 1.0.3(@sveltejs/vite-plugin-svelte@2.4.1)(svelte@3.59.1)(vite@4.4.4) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) deepmerge: 4.3.1 kleur: 4.1.5 magic-string: 0.30.1 @@ -1349,7 +1348,7 @@ packages: vite: ^4.0.0 dependencies: '@sveltejs/vite-plugin-svelte-inspector': 1.0.3(@sveltejs/vite-plugin-svelte@2.4.2)(svelte@4.0.5)(vite@4.4.4) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) deepmerge: 4.3.1 kleur: 4.1.5 magic-string: 0.30.1 @@ -1371,8 +1370,8 @@ packages: engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} dev: false - /@tauri-apps/cli-darwin-arm64@2.0.0-alpha.14: - resolution: {integrity: sha512-3K416rvSUt8el/fdPnSnHJOI2j5Os9Kyy17XZp+z3PKRRuo/iJPp9L3w0zFGYsh7C+ylzV4OBUSVTi+e+gO5qA==} + /@tauri-apps/cli-darwin-arm64@2.0.0-alpha.15: + resolution: {integrity: sha512-PxmXanPZtSLtDJyEoj538//cauKoyc/sExAO0fTwJ+o8y2NZB/qQfpbdMIloQQnusRwh+6RjOr0Zs5Y6nBhO5Q==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -1380,8 +1379,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-darwin-x64@2.0.0-alpha.14: - resolution: {integrity: sha512-aLEUGG8Z0UpTENe4/UG6DU8bnB2e1uxyxYvcmFKrHv+EAtR9nLH14alBxPl2K54YXy3JLR4bKROW15a/sFrX9g==} + /@tauri-apps/cli-darwin-x64@2.0.0-alpha.15: + resolution: {integrity: sha512-IcJGd6mIwQQ9xQhmkNHWjERJoGYpZEknhWeU8a2MnuosX8c9O/zmKWey4ol2KPrumMdmbh8QZzPyh9986GmnUA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -1389,8 +1388,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-alpha.14: - resolution: {integrity: sha512-Lu7unNvurBccxfHIaUQ0gPgUioTkQBMtWGrqO/auZ/JbjPR1W2eBlRwVNXf+nBWX9HwomPR3YD5yZuZmzxRV2g==} + /@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-alpha.15: + resolution: {integrity: sha512-zD88WJaEZ49BzgmIgj0RVFF/zKrB+NYHEDwmvt60eehQCPfnMuE5/asj0Gp4YJRZ07jZzDfzMCdTGbwWsLnZEA==} engines: {node: '>= 10'} cpu: [arm] os: [linux] @@ -1398,8 +1397,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm64-gnu@2.0.0-alpha.14: - resolution: {integrity: sha512-g8HkwKvAsWLLMJzPup7B1BCilYmXKwXdee7sf8QFbaIUSccR8i5pXLK5N/quKw5lmldYgFveEyuW9Qs8RgTYnQ==} + /@tauri-apps/cli-linux-arm64-gnu@2.0.0-alpha.15: + resolution: {integrity: sha512-rmHIZsEb1RT5Ny4hjeK7LC3MRqWLZBfiKC29DX5UzhJySb9g0UeR2esx1PMX6kuU8DOC0RBr8xpEmoTNMtFJ3Q==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1407,8 +1406,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm64-musl@2.0.0-alpha.14: - resolution: {integrity: sha512-ag4UuX6zg7vmBFWmg9ChyiJI7GTMkc8tjr/qobd3Lg9ddmjnVWwLUHt6v1kYhXiU7iLPD5DYDIjU8x/POc3hSA==} + /@tauri-apps/cli-linux-arm64-musl@2.0.0-alpha.15: + resolution: {integrity: sha512-l3oix62YRE/vjpdxWq38NwZ61yg1vCcGAdfHaSt+Um/ojZHudekchQx56sEh7IMxsHxEtipxZdNEb1WsyAa5JA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1416,8 +1415,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-x64-gnu@2.0.0-alpha.14: - resolution: {integrity: sha512-+CviROc4fzrGqqyHQXh3uc2dGr/oYr19I8r2k+LJ2CDfmtj7CbNd/oC5oehHbHdw1oGFKuDPudrTGvzdRNygYA==} + /@tauri-apps/cli-linux-x64-gnu@2.0.0-alpha.15: + resolution: {integrity: sha512-m7jWcyA4URtfvM4ySN1G3mO6gQP0qULawP9henks/bcrx2DU5xFP7WFxUxQhlWEtjwtJOI/NscQfzUEE6igs+Q==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1425,8 +1424,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-x64-musl@2.0.0-alpha.14: - resolution: {integrity: sha512-aCP51HOAQXgVhyPHXKy627bYVRkNnpCvSU3L03pYV8YDoGo+veeuek5UiW7PlNdwx52B/yC3Jz7Dr3gEbFimfQ==} + /@tauri-apps/cli-linux-x64-musl@2.0.0-alpha.15: + resolution: {integrity: sha512-Xa4JTnYbebnLAMY7JdNuUDgnv/wWA4a8fbg1288kckq3aRXb+ETTV3Tlr/rnsx1s3TpECmSkXjTIvNecvsqjTA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1434,8 +1433,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-arm64-msvc@2.0.0-alpha.14: - resolution: {integrity: sha512-b6Ei5ERUF0KS1bttM7i6U62GmjIvlgK03XZqvL/KLNvUfqRMu8F7JA1ejSExgTxhEhKSWA768HiTXpXk2GjFFw==} + /@tauri-apps/cli-win32-arm64-msvc@2.0.0-alpha.15: + resolution: {integrity: sha512-YOKmqenjwQkwBesJ3rYWnJ2renRhPAWIdIoTRhMnDacRk28mMWizsGWLT7ZDbYi7AHMR6jMk0eYgAKKd+uBjFg==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -1443,8 +1442,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-ia32-msvc@2.0.0-alpha.14: - resolution: {integrity: sha512-TDkvu5pd37bKxZ6N+BqngCNGcefY7aHxyJ3BdBGxF+wRMjEMh70mgEXk8i0uM/aUi/Kl1GQoO6xJfUDlIMPXOA==} + /@tauri-apps/cli-win32-ia32-msvc@2.0.0-alpha.15: + resolution: {integrity: sha512-Z8yMn6jKSCN8atdWwIzHNoqd+kS684RpgFoZhftcxtqYDXfSgU63KLasKu2Wu12a/7TmXqHGHlEBst9nD2VSLw==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -1452,8 +1451,8 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-x64-msvc@2.0.0-alpha.14: - resolution: {integrity: sha512-9yfoEe2RSykKr5hCifVAL5o0gHXgRCS+Wo+RJjQ9L2+QHY7XPLZYAhj/h8jdcAdRveyIQwat3k7wl+SW87v1eg==} + /@tauri-apps/cli-win32-x64-msvc@2.0.0-alpha.15: + resolution: {integrity: sha512-fcIXUgI1PKeAj2cp7vvXDssWcXxhauCyvtJPmaCVl5pk+5aJlOSx5TPjv0BRyaIO8l4IPW1IakvTRcDvEAQHRw==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -1461,21 +1460,21 @@ packages: dev: true optional: true - /@tauri-apps/cli@2.0.0-alpha.14: - resolution: {integrity: sha512-4/IQwN5S94D6LTXQrDWbSea0pGb9TTC4BwxHUFmhep4NjFxms161v1zadAUIsq/N2x6WwCBGrsdq9SIkgKv49Q==} + /@tauri-apps/cli@2.0.0-alpha.15: + resolution: {integrity: sha512-eMMD5MXJDt/j37IGBP501Ov3lux+mrA1WT4EjTk+Oaw4t8fb8ncb7yvbVZ6qyzVo7WHplIGKRzyV0CyZXZropQ==} engines: {node: '>= 10'} hasBin: true optionalDependencies: - '@tauri-apps/cli-darwin-arm64': 2.0.0-alpha.14 - '@tauri-apps/cli-darwin-x64': 2.0.0-alpha.14 - '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-alpha.14 - '@tauri-apps/cli-linux-arm64-gnu': 2.0.0-alpha.14 - '@tauri-apps/cli-linux-arm64-musl': 2.0.0-alpha.14 - '@tauri-apps/cli-linux-x64-gnu': 2.0.0-alpha.14 - '@tauri-apps/cli-linux-x64-musl': 2.0.0-alpha.14 - '@tauri-apps/cli-win32-arm64-msvc': 2.0.0-alpha.14 - '@tauri-apps/cli-win32-ia32-msvc': 2.0.0-alpha.14 - '@tauri-apps/cli-win32-x64-msvc': 2.0.0-alpha.14 + '@tauri-apps/cli-darwin-arm64': 2.0.0-alpha.15 + '@tauri-apps/cli-darwin-x64': 2.0.0-alpha.15 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-alpha.15 + '@tauri-apps/cli-linux-arm64-gnu': 2.0.0-alpha.15 + '@tauri-apps/cli-linux-arm64-musl': 2.0.0-alpha.15 + '@tauri-apps/cli-linux-x64-gnu': 2.0.0-alpha.15 + '@tauri-apps/cli-linux-x64-musl': 2.0.0-alpha.15 + '@tauri-apps/cli-win32-arm64-msvc': 2.0.0-alpha.15 + '@tauri-apps/cli-win32-ia32-msvc': 2.0.0-alpha.15 + '@tauri-apps/cli-win32-x64-msvc': 2.0.0-alpha.15 dev: true /@tauri-apps/toml@2.2.4: @@ -1537,7 +1536,7 @@ packages: '@typescript-eslint/type-utils': 6.1.0(eslint@8.45.0)(typescript@5.1.6) '@typescript-eslint/utils': 6.1.0(eslint@8.45.0)(typescript@5.1.6) '@typescript-eslint/visitor-keys': 6.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.45.0 graphemer: 1.4.0 ignore: 5.2.4 @@ -1563,7 +1562,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.1.6) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.45.0 typescript: 5.1.6 transitivePeerDependencies: @@ -1584,7 +1583,7 @@ packages: '@typescript-eslint/types': 6.1.0 '@typescript-eslint/typescript-estree': 6.1.0(typescript@5.1.6) '@typescript-eslint/visitor-keys': 6.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.45.0 typescript: 5.1.6 transitivePeerDependencies: @@ -1619,7 +1618,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.1.0(typescript@5.1.6) '@typescript-eslint/utils': 6.1.0(eslint@8.45.0)(typescript@5.1.6) - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.45.0 ts-api-utils: 1.0.1(typescript@5.1.6) typescript: 5.1.6 @@ -1648,7 +1647,7 @@ packages: dependencies: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/visitor-keys': 5.62.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -1669,7 +1668,7 @@ packages: dependencies: '@typescript-eslint/types': 6.1.0 '@typescript-eslint/visitor-keys': 6.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -1714,24 +1713,24 @@ packages: eslint-visitor-keys: 3.4.1 dev: true - /@unocss/astro@0.53.1(vite@4.4.4): + /@unocss/astro@0.53.1(rollup@3.26.3)(vite@4.4.4): resolution: {integrity: sha512-dvPH2buCL0qvWXFfQFUeB8kbbJsliN0ib2Am5/1r4XyOwCiCvfwc3UuQpsi0xJs/WO9QgIxLWxakxVj3DeAuAQ==} dependencies: '@unocss/core': 0.53.1 '@unocss/reset': 0.53.1 - '@unocss/vite': 0.53.1(vite@4.4.4) + '@unocss/vite': 0.53.1(rollup@3.26.3)(vite@4.4.4) transitivePeerDependencies: - rollup - vite dev: true - /@unocss/cli@0.53.1: + /@unocss/cli@0.53.1(rollup@3.26.3): resolution: {integrity: sha512-K2r8eBtwv1oQ6KcDLb3KyIDaApVle3zbckZmd7W402/IRIJSKScLjxWHtEJpnYEyuxD5MlQpfRZLZgmWWVMOsg==} engines: {node: '>=14'} hasBin: true dependencies: '@ampproject/remapping': 2.2.1 - '@rollup/pluginutils': 5.0.2 + '@rollup/pluginutils': 5.0.2(rollup@3.26.3) '@unocss/config': 0.53.1 '@unocss/core': 0.53.1 '@unocss/preset-uno': 0.53.1 @@ -1887,13 +1886,13 @@ packages: '@unocss/core': 0.53.1 dev: true - /@unocss/vite@0.53.1(vite@4.4.4): + /@unocss/vite@0.53.1(rollup@3.26.3)(vite@4.4.4): resolution: {integrity: sha512-/N/rjiFyj1ejK1ZQIv9N/NMsNE6i2/V8ISwYhbGxLpc3Sca4jeVjZPsx5cg5DN9Ddas2BRH3YhLhdh8rPUPzxQ==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 dependencies: '@ampproject/remapping': 2.2.1 - '@rollup/pluginutils': 5.0.2 + '@rollup/pluginutils': 5.0.2(rollup@3.26.3) '@unocss/config': 0.53.1 '@unocss/core': 0.53.1 '@unocss/inspector': 0.53.1 @@ -2359,18 +2358,6 @@ packages: ms: 2.1.3 dev: true - /debug@4.3.4: - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - dependencies: - ms: 2.1.2 - dev: true - /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -2478,18 +2465,6 @@ packages: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} dev: true - /effection@2.0.7: - resolution: {integrity: sha512-I9ndFvtByvHbvOHwMp1NM7vlLDT0RBOu1YlIfBece46VASSot0oPnAfoGdc1YKoQShQLjigvHZ6OqZYUAxUcXg==} - dependencies: - '@effection/channel': 2.0.5 - '@effection/core': 2.2.2 - '@effection/events': 2.0.5 - '@effection/fetch': 2.0.6(mocha@10.2.0) - '@effection/main': 2.1.2 - '@effection/stream': 2.0.5 - '@effection/subscription': 2.0.5 - dev: true - /effection@2.0.7(mocha@10.2.0): resolution: {integrity: sha512-I9ndFvtByvHbvOHwMp1NM7vlLDT0RBOu1YlIfBece46VASSot0oPnAfoGdc1YKoQShQLjigvHZ6OqZYUAxUcXg==} dependencies: @@ -2846,7 +2821,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.1 @@ -3750,7 +3725,7 @@ packages: /micromark@2.11.4: resolution: {integrity: sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) parse-entities: 2.0.0 transitivePeerDependencies: - supports-color @@ -4866,7 +4841,7 @@ packages: '@types/unist': 2.0.7 dev: true - /unocss@0.53.1(postcss@8.4.26)(vite@4.4.4): + /unocss@0.53.1(postcss@8.4.26)(rollup@3.26.3)(vite@4.4.4): resolution: {integrity: sha512-0lRblA8hX7VUu5dywbcStzm590Iz5ahSJGsMNKNH3+u9C7AfJcKT8epxjkIkJWQBNJLD5vsao4SuuhLWB7eMQQ==} engines: {node: '>=14'} peerDependencies: @@ -4875,8 +4850,8 @@ packages: '@unocss/webpack': optional: true dependencies: - '@unocss/astro': 0.53.1(vite@4.4.4) - '@unocss/cli': 0.53.1 + '@unocss/astro': 0.53.1(rollup@3.26.3)(vite@4.4.4) + '@unocss/cli': 0.53.1(rollup@3.26.3) '@unocss/core': 0.53.1 '@unocss/extractor-arbitrary-variants': 0.53.1 '@unocss/postcss': 0.53.1(postcss@8.4.26) @@ -4894,7 +4869,7 @@ packages: '@unocss/transformer-compile-class': 0.53.1 '@unocss/transformer-directives': 0.53.1 '@unocss/transformer-variant-group': 0.53.1 - '@unocss/vite': 0.53.1(vite@4.4.4) + '@unocss/vite': 0.53.1(rollup@3.26.3)(vite@4.4.4) transitivePeerDependencies: - postcss - rollup