From b914775898c2bee7ceb20bd17ee595005cd17a64 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Mon, 19 Aug 2024 16:29:22 -0300 Subject: [PATCH 1/9] fix: explicitly set a minimum macOS version for older Swift versions (#1679) ref https://github.com/tauri-apps/tauri/pull/10687 --- .changes/swift-build-older-versions.md | 15 ++ plugins/barcode-scanner/ios/Package.swift | 3 +- plugins/biometric/ios/Package.swift | 3 +- plugins/clipboard-manager/ios/Package.swift | 49 +++---- plugins/dialog/ios/Package.swift | 49 +++---- plugins/geolocation/ios/Package.swift | 49 +++---- plugins/haptics/ios/Package.swift | 49 +++---- plugins/log/ios/Package.swift | 49 +++---- plugins/nfc/ios/Package.swift | 3 +- plugins/notification/ios/Package.swift | 51 ++++--- plugins/shell/ios/Package.swift | 49 +++---- plugins/store/.tauri/tauri-api/.gitignore | 10 -- plugins/store/.tauri/tauri-api/Package.swift | 40 ------ plugins/store/.tauri/tauri-api/README.md | 3 - .../tauri-api/Sources/Tauri/Channel.swift | 65 --------- .../tauri-api/Sources/Tauri/Invoke.swift | 107 -------------- .../tauri-api/Sources/Tauri/JSTypes.swift | 22 --- .../tauri-api/Sources/Tauri/JsonValue.swift | 58 -------- .../tauri-api/Sources/Tauri/Logger.swift | 58 -------- .../Sources/Tauri/Plugin/Plugin.swift | 81 ----------- .../tauri-api/Sources/Tauri/Tauri.swift | 134 ------------------ .../tauri-api/Sources/Tauri/UiUtils.swift | 15 -- plugins/store/ios/Package.swift | 49 +++---- shared/template/ios/Package.swift | 49 +++---- 24 files changed, 246 insertions(+), 814 deletions(-) create mode 100644 .changes/swift-build-older-versions.md delete mode 100644 plugins/store/.tauri/tauri-api/.gitignore delete mode 100644 plugins/store/.tauri/tauri-api/Package.swift delete mode 100644 plugins/store/.tauri/tauri-api/README.md delete mode 100644 plugins/store/.tauri/tauri-api/Sources/Tauri/Channel.swift delete mode 100644 plugins/store/.tauri/tauri-api/Sources/Tauri/Invoke.swift delete mode 100644 plugins/store/.tauri/tauri-api/Sources/Tauri/JSTypes.swift delete mode 100644 plugins/store/.tauri/tauri-api/Sources/Tauri/JsonValue.swift delete mode 100644 plugins/store/.tauri/tauri-api/Sources/Tauri/Logger.swift delete mode 100644 plugins/store/.tauri/tauri-api/Sources/Tauri/Plugin/Plugin.swift delete mode 100644 plugins/store/.tauri/tauri-api/Sources/Tauri/Tauri.swift delete mode 100644 plugins/store/.tauri/tauri-api/Sources/Tauri/UiUtils.swift diff --git a/.changes/swift-build-older-versions.md b/.changes/swift-build-older-versions.md new file mode 100644 index 00000000..41666a91 --- /dev/null +++ b/.changes/swift-build-older-versions.md @@ -0,0 +1,15 @@ +--- +"barcode-scanner": patch +"biometric": patch +"clipboard-manager": patch +"dialog": patch +"geolocation": patch +"haptics": patch +"log-plugin": patch +"nfc": patch +"notification": patch +"shell": patch +"store": patch +--- + +Explicitly set a minimum macOS version for the Swift package. diff --git a/plugins/barcode-scanner/ios/Package.swift b/plugins/barcode-scanner/ios/Package.swift index aafb41c3..cf39b812 100644 --- a/plugins/barcode-scanner/ios/Package.swift +++ b/plugins/barcode-scanner/ios/Package.swift @@ -10,7 +10,8 @@ import PackageDescription let package = Package( name: "tauri-plugin-barcode-scanner", platforms: [ - .iOS(.v13) + .macOS(.v10_13), + .iOS(.v13), ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/plugins/biometric/ios/Package.swift b/plugins/biometric/ios/Package.swift index 34c9f87e..7860f476 100644 --- a/plugins/biometric/ios/Package.swift +++ b/plugins/biometric/ios/Package.swift @@ -8,7 +8,8 @@ import PackageDescription let package = Package( name: "tauri-plugin-biometric", platforms: [ - .iOS(.v13) + .macOS(.v10_13), + .iOS(.v13), ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/plugins/clipboard-manager/ios/Package.swift b/plugins/clipboard-manager/ios/Package.swift index f6200857..6da5303e 100644 --- a/plugins/clipboard-manager/ios/Package.swift +++ b/plugins/clipboard-manager/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-clipboard-manager", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-clipboard-manager", - type: .static, - targets: ["tauri-plugin-clipboard-manager"]), - ], - 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-clipboard-manager", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-clipboard-manager", + 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-clipboard-manager", + type: .static, + targets: ["tauri-plugin-clipboard-manager"]) + ], + 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-clipboard-manager", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/dialog/ios/Package.swift b/plugins/dialog/ios/Package.swift index 45a58a43..f8983f14 100644 --- a/plugins/dialog/ios/Package.swift +++ b/plugins/dialog/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-dialog", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-dialog", - type: .static, - targets: ["tauri-plugin-dialog"]), - ], - 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-dialog", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-dialog", + 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-dialog", + type: .static, + targets: ["tauri-plugin-dialog"]) + ], + 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-dialog", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/geolocation/ios/Package.swift b/plugins/geolocation/ios/Package.swift index c1984783..f8cfb73f 100644 --- a/plugins/geolocation/ios/Package.swift +++ b/plugins/geolocation/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-geolocation", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-geolocation", - type: .static, - targets: ["tauri-plugin-geolocation"]), - ], - 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-geolocation", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-geolocation", + 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-geolocation", + type: .static, + targets: ["tauri-plugin-geolocation"]) + ], + 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-geolocation", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/haptics/ios/Package.swift b/plugins/haptics/ios/Package.swift index c70145b0..a64b9890 100644 --- a/plugins/haptics/ios/Package.swift +++ b/plugins/haptics/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-haptics", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-haptics", - type: .static, - targets: ["tauri-plugin-haptics"]), - ], - 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-haptics", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-haptics", + 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-haptics", + type: .static, + targets: ["tauri-plugin-haptics"]) + ], + 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-haptics", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/log/ios/Package.swift b/plugins/log/ios/Package.swift index 4afbbbdb..1571f22e 100644 --- a/plugins/log/ios/Package.swift +++ b/plugins/log/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-log", - platforms: [ - .iOS(.v11), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-log", - type: .static, - targets: ["tauri-plugin-log"]), - ], - 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-log", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-log", + platforms: [ + .macOS(.v10_13), + .iOS(.v11), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-log", + type: .static, + targets: ["tauri-plugin-log"]) + ], + 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-log", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/nfc/ios/Package.swift b/plugins/nfc/ios/Package.swift index e8f1f19a..a028db7d 100644 --- a/plugins/nfc/ios/Package.swift +++ b/plugins/nfc/ios/Package.swift @@ -8,7 +8,8 @@ import PackageDescription let package = Package( name: "tauri-plugin-nfc", platforms: [ - .iOS(.v13) + .macOS(.v10_13), + .iOS(.v13), ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/plugins/notification/ios/Package.swift b/plugins/notification/ios/Package.swift index 9b681869..bbd6df9e 100644 --- a/plugins/notification/ios/Package.swift +++ b/plugins/notification/ios/Package.swift @@ -3,33 +3,32 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT - - import PackageDescription let package = Package( - name: "tauri-plugin-notification", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-notification", - type: .static, - targets: ["tauri-plugin-notification"]), - ], - 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-notification", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-notification", + 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-notification", + type: .static, + targets: ["tauri-plugin-notification"]) + ], + 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-notification", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/shell/ios/Package.swift b/plugins/shell/ios/Package.swift index fa5d363d..c7b2a7aa 100644 --- a/plugins/shell/ios/Package.swift +++ b/plugins/shell/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-shell", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-shell", - type: .static, - targets: ["tauri-plugin-shell"]), - ], - 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-shell", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-shell", + 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-shell", + type: .static, + targets: ["tauri-plugin-shell"]) + ], + 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-shell", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/plugins/store/.tauri/tauri-api/.gitignore b/plugins/store/.tauri/tauri-api/.gitignore deleted file mode 100644 index 5922fdaa..00000000 --- a/plugins/store/.tauri/tauri-api/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.DS_Store -/.build -/Packages -/*.xcodeproj -xcuserdata/ -DerivedData/ -.swiftpm/config/registries.json -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata -.netrc -Package.resolved diff --git a/plugins/store/.tauri/tauri-api/Package.swift b/plugins/store/.tauri/tauri-api/Package.swift deleted file mode 100644 index c7a73323..00000000 --- a/plugins/store/.tauri/tauri-api/Package.swift +++ /dev/null @@ -1,40 +0,0 @@ -// swift-tools-version:5.3 -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import PackageDescription - -let package = Package( - name: "Tauri", - platforms: [ - .macOS(.v10_13), - .iOS(.v11), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "Tauri", - type: .static, - targets: ["Tauri"]) - ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - .package(name: "SwiftRs", url: "https://github.com/Brendonovich/swift-rs", from: "1.0.0") - ], - 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", - dependencies: [ - .byName(name: "SwiftRs") - ], - path: "Sources" - ), - .testTarget( - name: "TauriTests", - dependencies: ["Tauri"] - ), - ] -) diff --git a/plugins/store/.tauri/tauri-api/README.md b/plugins/store/.tauri/tauri-api/README.md deleted file mode 100644 index 52c3f1c7..00000000 --- a/plugins/store/.tauri/tauri-api/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Tauri - -Tauri iOS API. diff --git a/plugins/store/.tauri/tauri-api/Sources/Tauri/Channel.swift b/plugins/store/.tauri/tauri-api/Sources/Tauri/Channel.swift deleted file mode 100644 index add065c7..00000000 --- a/plugins/store/.tauri/tauri-api/Sources/Tauri/Channel.swift +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import Foundation - -let CHANNEL_PREFIX = "__CHANNEL__:" -let channelDataKey = CodingUserInfoKey(rawValue: "sendChannelData")! - -public class Channel: Decodable { - public let id: UInt64 - let handler: (UInt64, String) -> Void - - public required init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - let channelDef = try container.decode(String.self) - - let components = channelDef.components(separatedBy: CHANNEL_PREFIX) - if components.count < 2 { - throw DecodingError.dataCorruptedError( - in: container, - debugDescription: "Invalid channel definition from \(channelDef)" - ) - - } - guard let channelId = UInt64(components[1]) else { - throw DecodingError.dataCorruptedError( - in: container, - debugDescription: "Invalid channel ID from \(channelDef)" - ) - } - - guard let handler = decoder.userInfo[channelDataKey] as? (UInt64, String) -> Void else { - throw DecodingError.dataCorruptedError( - in: container, - debugDescription: "missing userInfo for Channel handler. This is a Tauri issue" - ) - } - - self.id = channelId - self.handler = handler - } - - func serialize(_ data: JsonValue) -> String { - do { - return try data.jsonRepresentation() ?? "\"Failed to serialize payload\"" - } catch { - return "\"\(error)\"" - } - } - - public func send(_ data: JsonObject) { - send(.dictionary(data)) - } - - public func send(_ data: JsonValue) { - handler(id, serialize(data)) - } - - public func send(_ data: T) throws { - let json = try JSONEncoder().encode(data) - handler(id, String(decoding: json, as: UTF8.self)) - } - -} diff --git a/plugins/store/.tauri/tauri-api/Sources/Tauri/Invoke.swift b/plugins/store/.tauri/tauri-api/Sources/Tauri/Invoke.swift deleted file mode 100644 index b1b5dbfe..00000000 --- a/plugins/store/.tauri/tauri-api/Sources/Tauri/Invoke.swift +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import Foundation -import UIKit - -@objc public class Invoke: NSObject { - public let command: String - let callback: UInt64 - let error: UInt64 - let data: String - let sendResponse: (UInt64, String?) -> Void - let sendChannelData: (UInt64, String) -> Void - - public init( - command: String, callback: UInt64, error: UInt64, - sendResponse: @escaping (UInt64, String?) -> Void, - sendChannelData: @escaping (UInt64, String) -> Void, data: String - ) { - self.command = command - self.callback = callback - self.error = error - self.data = data - self.sendResponse = sendResponse - self.sendChannelData = sendChannelData - } - - public func parseArgs(_ type: T.Type) throws -> T { - let jsonData = self.data.data(using: .utf8)! - let decoder = JSONDecoder() - decoder.userInfo[channelDataKey] = sendChannelData - return try decoder.decode(type, from: jsonData) - } - - func serialize(_ data: JsonValue) -> String { - do { - return try data.jsonRepresentation() ?? "\"Failed to serialize payload\"" - } catch { - return "\"\(error)\"" - } - } - - public func resolve() { - sendResponse(callback, nil) - } - - public func resolve(_ data: JsonObject) { - resolve(.dictionary(data)) - } - - public func resolve(_ data: JsonValue) { - sendResponse(callback, serialize(data)) - } - - public func resolve(_ data: T) { - do { - let json = try JSONEncoder().encode(data) - sendResponse(callback, String(decoding: json, as: UTF8.self)) - } catch { - sendResponse(self.error, "\"\(error)\"") - } - } - - public func reject( - _ message: String, code: String? = nil, error: Error? = nil, data: JsonValue? = nil - ) { - let payload: NSMutableDictionary = [ - "message": message - ] - - if let code = code { - payload["code"] = code - } - - if let error = error { - payload["error"] = error - } - - if let data = data { - switch data { - case .dictionary(let dict): - for entry in dict { - payload[entry.key] = entry.value - } - } - } - - sendResponse(self.error, serialize(.dictionary(payload as! JsonObject))) - } - - public func unimplemented() { - unimplemented("not implemented") - } - - public func unimplemented(_ message: String) { - reject(message) - } - - public func unavailable() { - unavailable("not available") - } - - public func unavailable(_ message: String) { - reject(message) - } -} diff --git a/plugins/store/.tauri/tauri-api/Sources/Tauri/JSTypes.swift b/plugins/store/.tauri/tauri-api/Sources/Tauri/JSTypes.swift deleted file mode 100644 index 8fd5d2f2..00000000 --- a/plugins/store/.tauri/tauri-api/Sources/Tauri/JSTypes.swift +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import Foundation - -// declare our empty protocol, and conformance, for typing -public protocol JSValue {} -extension String: JSValue {} -extension Bool: JSValue {} -extension Int: JSValue {} -extension Float: JSValue {} -extension Double: JSValue {} -extension NSNumber: JSValue {} -extension NSNull: JSValue {} -extension Array: JSValue {} -extension Date: JSValue {} -extension Dictionary: JSValue where Key == String, Value == JSValue {} - -// convenience aliases -public typealias JSObject = [String: JSValue] -public typealias JSArray = [JSValue] diff --git a/plugins/store/.tauri/tauri-api/Sources/Tauri/JsonValue.swift b/plugins/store/.tauri/tauri-api/Sources/Tauri/JsonValue.swift deleted file mode 100644 index c3043511..00000000 --- a/plugins/store/.tauri/tauri-api/Sources/Tauri/JsonValue.swift +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import Foundation - -public typealias JsonObject = [String: Any] - -public enum JsonValue { - case dictionary(JsonObject) - - enum SerializationError: Error { - case invalidObject - } - - public func jsonRepresentation(includingFields: JsonObject? = nil) throws -> String? { - switch self { - case .dictionary(var dictionary): - if let fields = includingFields { - dictionary.merge(fields) { (current, _) in current } - } - dictionary = prepare(dictionary: dictionary) - guard JSONSerialization.isValidJSONObject(dictionary) else { - throw SerializationError.invalidObject - } - let data = try JSONSerialization.data(withJSONObject: dictionary, options: []) - return String(data: data, encoding: .utf8) - } - } - - private static let formatter = ISO8601DateFormatter() - - private func prepare(dictionary: JsonObject) -> JsonObject { - return dictionary.mapValues { (value) -> Any in - if let date = value as? Date { - return JsonValue.formatter.string(from: date) - } else if let aDictionary = value as? JsonObject { - return prepare(dictionary: aDictionary) - } else if let anArray = value as? [Any] { - return prepare(array: anArray) - } - return value - } - } - - private func prepare(array: [Any]) -> [Any] { - return array.map { (value) -> Any in - if let date = value as? Date { - return JsonValue.formatter.string(from: date) - } else if let aDictionary = value as? JsonObject { - return prepare(dictionary: aDictionary) - } else if let anArray = value as? [Any] { - return prepare(array: anArray) - } - return value - } - } -} diff --git a/plugins/store/.tauri/tauri-api/Sources/Tauri/Logger.swift b/plugins/store/.tauri/tauri-api/Sources/Tauri/Logger.swift deleted file mode 100644 index 9fa6e3fe..00000000 --- a/plugins/store/.tauri/tauri-api/Sources/Tauri/Logger.swift +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import os.log -import UIKit - -/// Wrapper class for os_log function -public class Logger { - private static var _enabled = false - public static var enabled: Bool { - get { - #if DEBUG - return true - #else - return _enabled - #endif - } - set { - Logger._enabled = newValue - } - } - - static func log(_ items: Any..., category: String, type: OSLogType) { - if Logger.enabled { - var message = "" - let last = items.count - 1 - for (index, item) in items.enumerated() { - message += "\(item)" - if index != last { - message += " " - } - } - let log = OSLog(subsystem: Bundle.main.bundleIdentifier ?? "-", category: category) - os_log("%{public}@", log: log, type: type, String(message.prefix(4068))) - } - } - - public static func debug(_ items: Any..., category: String = "app") { - #if DEBUG - Logger.log(items, category: category, type: OSLogType.default) - #else - Logger.log(items, category: category, type: OSLogType.debug) - #endif - } - - public static func info(_ items: Any..., category: String = "app") { - #if DEBUG - Logger.log(items, category: category, type: OSLogType.default) - #else - Logger.log(items, category: category, type: OSLogType.info) - #endif - } - - public static func error(_ items: Any..., category: String = "app") { - Logger.log(items, category: category, type: OSLogType.error) - } -} diff --git a/plugins/store/.tauri/tauri-api/Sources/Tauri/Plugin/Plugin.swift b/plugins/store/.tauri/tauri-api/Sources/Tauri/Plugin/Plugin.swift deleted file mode 100644 index 7ce67f9b..00000000 --- a/plugins/store/.tauri/tauri-api/Sources/Tauri/Plugin/Plugin.swift +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import WebKit -import os.log - -struct RegisterListenerArgs: Decodable { - let event: String - let handler: Channel -} - -struct RemoveListenerArgs: Decodable { - let event: String - let channelId: UInt64 -} - -open class Plugin: NSObject { - public let manager: PluginManager = PluginManager.shared - var config: String = "{}" - private var listeners = [String: [Channel]]() - - internal func setConfig(_ config: String) { - self.config = config - } - - public func parseConfig(_ type: T.Type) throws -> T { - let jsonData = self.config.data(using: .utf8)! - let decoder = JSONDecoder() - return try decoder.decode(type, from: jsonData) - } - - @objc open func load(webview: WKWebView) {} - - @objc open func checkPermissions(_ invoke: Invoke) { - invoke.resolve() - } - - @objc open func requestPermissions(_ invoke: Invoke) { - invoke.resolve() - } - - public func trigger(_ event: String, data: JSObject) { - if let eventListeners = listeners[event] { - for channel in eventListeners { - channel.send(data) - } - } - } - - public func trigger(_ event: String, data: T) throws { - if let eventListeners = listeners[event] { - for channel in eventListeners { - try channel.send(data) - } - } - } - - @objc func registerListener(_ invoke: Invoke) throws { - let args = try invoke.parseArgs(RegisterListenerArgs.self) - - if var eventListeners = listeners[args.event] { - eventListeners.append(args.handler) - } else { - listeners[args.event] = [args.handler] - } - - invoke.resolve() - } - - @objc func removeListener(_ invoke: Invoke) throws { - let args = try invoke.parseArgs(RemoveListenerArgs.self) - - if let eventListeners = listeners[args.event] { - - listeners[args.event] = eventListeners.filter { $0.id != args.channelId } - } - - invoke.resolve() - } -} diff --git a/plugins/store/.tauri/tauri-api/Sources/Tauri/Tauri.swift b/plugins/store/.tauri/tauri-api/Sources/Tauri/Tauri.swift deleted file mode 100644 index 9a9c40e3..00000000 --- a/plugins/store/.tauri/tauri-api/Sources/Tauri/Tauri.swift +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import Foundation -import SwiftRs -import UIKit -import WebKit -import os.log - -class PluginHandle { - var instance: Plugin - var loaded = false - - init(plugin: Plugin) { - instance = plugin - } -} - -public class PluginManager { - static let shared: PluginManager = PluginManager() - public var viewController: UIViewController? - var plugins: [String: PluginHandle] = [:] - var ipcDispatchQueue = DispatchQueue(label: "ipc") - public var isSimEnvironment: Bool { - #if targetEnvironment(simulator) - return true - #else - return false - #endif - } - - public func assetUrl(fromLocalURL url: URL?) -> URL? { - guard let inputURL = url else { - return nil - } - - return URL(string: "asset://localhost")!.appendingPathComponent(inputURL.path) - } - - func onWebviewCreated(_ webview: WKWebView) { - for (_, handle) in plugins { - if !handle.loaded { - handle.instance.load(webview: webview) - } - } - } - - func load(name: String, plugin: P, config: String, webview: WKWebView?) { - plugin.setConfig(config) - let handle = PluginHandle(plugin: plugin) - if let webview = webview { - handle.instance.load(webview: webview) - handle.loaded = true - } - plugins[name] = handle - } - - func invoke(name: String, invoke: Invoke) { - if let plugin = plugins[name] { - ipcDispatchQueue.async { - let selectorWithThrows = Selector(("\(invoke.command):error:")) - if plugin.instance.responds(to: selectorWithThrows) { - var error: NSError? = nil - withUnsafeMutablePointer(to: &error) { - let methodIMP: IMP! = plugin.instance.method(for: selectorWithThrows) - unsafeBitCast( - methodIMP, to: (@convention(c) (Any?, Selector, Invoke, OpaquePointer) -> Void).self)( - plugin.instance, selectorWithThrows, invoke, OpaquePointer($0)) - } - if let error = error { - invoke.reject("\(error)") - // TODO: app crashes without this leak - let _ = Unmanaged.passRetained(error) - } - } else { - let selector = Selector(("\(invoke.command):")) - if plugin.instance.responds(to: selector) { - plugin.instance.perform(selector, with: invoke) - } else { - invoke.reject("No command \(invoke.command) found for plugin \(name)") - } - } - } - } else { - invoke.reject("Plugin \(name) not initialized") - } - } -} - -extension PluginManager: NSCopying { - public func copy(with zone: NSZone? = nil) -> Any { - return self - } -} - -@_cdecl("register_plugin") -func registerPlugin(name: SRString, plugin: NSObject, config: SRString, webview: WKWebView?) { - PluginManager.shared.load( - name: name.toString(), - plugin: plugin as! Plugin, - config: config.toString(), - webview: webview - ) -} - -@_cdecl("on_webview_created") -func onWebviewCreated(webview: WKWebView, viewController: UIViewController) { - PluginManager.shared.viewController = viewController - PluginManager.shared.onWebviewCreated(webview) -} - -@_cdecl("run_plugin_command") -func runCommand( - id: Int, - name: SRString, - command: SRString, - data: SRString, - callback: @escaping @convention(c) (Int, Bool, UnsafePointer) -> Void, - sendChannelData: @escaping @convention(c) (UInt64, UnsafePointer) -> Void -) { - let callbackId: UInt64 = 0 - let errorId: UInt64 = 1 - let invoke = Invoke( - command: command.toString(), callback: callbackId, error: errorId, - sendResponse: { (fn: UInt64, payload: String?) -> Void in - let success = fn == callbackId - callback(id, success, payload ?? "null") - }, - sendChannelData: { (id: UInt64, payload: String) -> Void in - sendChannelData(id, payload) - }, data: data.toString()) - PluginManager.shared.invoke(name: name.toString(), invoke: invoke) -} diff --git a/plugins/store/.tauri/tauri-api/Sources/Tauri/UiUtils.swift b/plugins/store/.tauri/tauri-api/Sources/Tauri/UiUtils.swift deleted file mode 100644 index 4097596e..00000000 --- a/plugins/store/.tauri/tauri-api/Sources/Tauri/UiUtils.swift +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import UIKit - -public class UIUtils { - public static func centerPopover(rootViewController: UIViewController?, popoverController: UIViewController) { - if let viewController = rootViewController { - popoverController.popoverPresentationController?.sourceRect = CGRect(x: viewController.view.center.x, y: viewController.view.center.y, width: 0, height: 0) - popoverController.popoverPresentationController?.sourceView = viewController.view - popoverController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up - } - } -} diff --git a/plugins/store/ios/Package.swift b/plugins/store/ios/Package.swift index fdf5f69a..51ba6bf6 100644 --- a/plugins/store/ios/Package.swift +++ b/plugins/store/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-store", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-store", - type: .static, - targets: ["tauri-plugin-store"]), - ], - 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-store", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-store", + 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-store", + type: .static, + targets: ["tauri-plugin-store"]) + ], + 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-store", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) diff --git a/shared/template/ios/Package.swift b/shared/template/ios/Package.swift index e4f53f0b..e4ebd067 100644 --- a/shared/template/ios/Package.swift +++ b/shared/template/ios/Package.swift @@ -6,28 +6,29 @@ import PackageDescription let package = Package( - name: "tauri-plugin-{{ plugin_name }}", - platforms: [ - .iOS(.v13), - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "tauri-plugin-{{ plugin_name }}", - type: .static, - targets: ["tauri-plugin-{{ plugin_name }}"]), - ], - 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-{{ plugin_name }}", - dependencies: [ - .byName(name: "Tauri") - ], - path: "Sources") - ] + name: "tauri-plugin-{{ plugin_name }}", + 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-{{ plugin_name }}", + type: .static, + targets: ["tauri-plugin-{{ plugin_name }}"]) + ], + 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-{{ plugin_name }}", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] ) From f946a7cf1f437bb29cecc071a196e05e79ec1099 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 21:36:15 -0300 Subject: [PATCH 2/9] publish new versions (#1680) Co-authored-by: lucasfernog --- .changes/pre.json | 1 + Cargo.lock | 24 ++++++++++++------------ examples/api/src-tauri/CHANGELOG.md | 13 +++++++++++++ examples/api/src-tauri/Cargo.toml | 18 +++++++++--------- plugins/barcode-scanner/CHANGELOG.md | 4 ++++ plugins/barcode-scanner/Cargo.toml | 2 +- plugins/biometric/CHANGELOG.md | 4 ++++ plugins/biometric/Cargo.toml | 2 +- plugins/clipboard-manager/CHANGELOG.md | 4 ++++ plugins/clipboard-manager/Cargo.toml | 2 +- plugins/dialog/CHANGELOG.md | 4 ++++ plugins/dialog/Cargo.toml | 2 +- plugins/geolocation/CHANGELOG.md | 4 ++++ plugins/geolocation/Cargo.toml | 2 +- plugins/haptics/CHANGELOG.md | 4 ++++ plugins/haptics/Cargo.toml | 2 +- plugins/log/CHANGELOG.md | 4 ++++ plugins/log/Cargo.toml | 2 +- plugins/nfc/CHANGELOG.md | 4 ++++ plugins/nfc/Cargo.toml | 2 +- plugins/notification/CHANGELOG.md | 4 ++++ plugins/notification/Cargo.toml | 2 +- plugins/shell/CHANGELOG.md | 4 ++++ plugins/shell/Cargo.toml | 2 +- plugins/store/CHANGELOG.md | 4 ++++ plugins/store/Cargo.toml | 2 +- 26 files changed, 90 insertions(+), 32 deletions(-) diff --git a/.changes/pre.json b/.changes/pre.json index d9dd082a..24bbb4db 100644 --- a/.changes/pre.json +++ b/.changes/pre.json @@ -11,6 +11,7 @@ ".changes/remove-target-sdk.md", ".changes/shell-open-regex-match-string.md", ".changes/shell-regex-match-string.md", + ".changes/swift-build-older-versions.md", ".changes/update-fs-api-docs.md", ".changes/update-tauri-rc-3.md" ] diff --git a/Cargo.lock b/Cargo.lock index fdcb35b7..68cfaf1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -206,7 +206,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "api" -version = "2.0.0-rc.0" +version = "2.0.0-rc.1" dependencies = [ "log", "serde", @@ -6530,7 +6530,7 @@ dependencies = [ [[package]] name = "tauri-plugin-barcode-scanner" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "log", "serde", @@ -6542,7 +6542,7 @@ dependencies = [ [[package]] name = "tauri-plugin-biometric" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "log", "serde", @@ -6568,7 +6568,7 @@ dependencies = [ [[package]] name = "tauri-plugin-clipboard-manager" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "arboard", "image 0.24.9", @@ -6600,7 +6600,7 @@ dependencies = [ [[package]] name = "tauri-plugin-dialog" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "dunce", "log", @@ -6635,7 +6635,7 @@ dependencies = [ [[package]] name = "tauri-plugin-geolocation" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "log", "serde", @@ -6661,7 +6661,7 @@ dependencies = [ [[package]] name = "tauri-plugin-haptics" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "log", "serde", @@ -6707,7 +6707,7 @@ dependencies = [ [[package]] name = "tauri-plugin-log" -version = "2.0.0-rc.0" +version = "2.0.0-rc.1" dependencies = [ "android_logger", "byte-unit", @@ -6727,7 +6727,7 @@ dependencies = [ [[package]] name = "tauri-plugin-nfc" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "log", "serde", @@ -6740,7 +6740,7 @@ dependencies = [ [[package]] name = "tauri-plugin-notification" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "color-backtrace", "ctor", @@ -6813,7 +6813,7 @@ dependencies = [ [[package]] name = "tauri-plugin-shell" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "encoding_rs", "log", @@ -6863,7 +6863,7 @@ dependencies = [ [[package]] name = "tauri-plugin-store" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" dependencies = [ "dunce", "log", diff --git a/examples/api/src-tauri/CHANGELOG.md b/examples/api/src-tauri/CHANGELOG.md index 994c48cf..e64b6fba 100644 --- a/examples/api/src-tauri/CHANGELOG.md +++ b/examples/api/src-tauri/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## \[2.0.0-rc.1] + +### Dependencies + +- Upgraded to `barcode-scanner@2.0.0-rc.2` +- Upgraded to `biometric@2.0.0-rc.2` +- Upgraded to `clipboard-manager@2.0.0-rc.2` +- Upgraded to `dialog@2.0.0-rc.2` +- Upgraded to `log-plugin@2.0.0-rc.1` +- Upgraded to `nfc@2.0.0-rc.2` +- Upgraded to `notification@2.0.0-rc.2` +- Upgraded to `shell@2.0.0-rc.2` + ## \[2.0.0-rc.0] ### Dependencies diff --git a/examples/api/src-tauri/Cargo.toml b/examples/api/src-tauri/Cargo.toml index 43641127..5ee22765 100644 --- a/examples/api/src-tauri/Cargo.toml +++ b/examples/api/src-tauri/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "api" publish = false -version = "2.0.0-rc.0" +version = "2.0.0-rc.1" description = "An example Tauri Application showcasing the api" edition = "2021" rust-version = { workspace = true } @@ -19,21 +19,21 @@ serde_json = { workspace = true } serde = { workspace = true } tiny_http = "0.12" log = { workspace = true } -tauri-plugin-log = { path = "../../../plugins/log", version = "2.0.0-rc.0" } +tauri-plugin-log = { path = "../../../plugins/log", version = "2.0.0-rc.1" } tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.0.0-rc.0", features = [ "watch", ] } -tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", version = "2.0.0-rc.1" } -tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.0-rc.1" } +tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", version = "2.0.0-rc.2" } +tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.0-rc.2" } tauri-plugin-http = { path = "../../../plugins/http", features = [ "multipart", ], version = "2.0.0-rc.0" } -tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.0.0-rc.1", features = [ +tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.0.0-rc.2", features = [ "windows7-compat", ] } tauri-plugin-os = { path = "../../../plugins/os", version = "2.0.0-rc.0" } tauri-plugin-process = { path = "../../../plugins/process", version = "2.0.0-rc.0" } -tauri-plugin-shell = { path = "../../../plugins/shell", version = "2.0.0-rc.1" } +tauri-plugin-shell = { path = "../../../plugins/shell", version = "2.0.0-rc.2" } [dependencies.tauri] workspace = true @@ -54,9 +54,9 @@ tauri-plugin-global-shortcut = { path = "../../../plugins/global-shortcut", vers tauri-plugin-updater = { path = "../../../plugins/updater", version = "2.0.0-rc.1" } [target."cfg(any(target_os = \"android\", target_os = \"ios\"))".dependencies] -tauri-plugin-barcode-scanner = { path = "../../../plugins/barcode-scanner/", version = "2.0.0-rc.1" } -tauri-plugin-nfc = { path = "../../../plugins/nfc", version = "2.0.0-rc.1" } -tauri-plugin-biometric = { path = "../../../plugins/biometric/", version = "2.0.0-rc.1" } +tauri-plugin-barcode-scanner = { path = "../../../plugins/barcode-scanner/", version = "2.0.0-rc.2" } +tauri-plugin-nfc = { path = "../../../plugins/nfc", version = "2.0.0-rc.2" } +tauri-plugin-biometric = { path = "../../../plugins/biometric/", version = "2.0.0-rc.2" } [target."cfg(target_os = \"windows\")".dependencies] window-shadows = "0.2" diff --git a/plugins/barcode-scanner/CHANGELOG.md b/plugins/barcode-scanner/CHANGELOG.md index 93f831d4..f68c4669 100644 --- a/plugins/barcode-scanner/CHANGELOG.md +++ b/plugins/barcode-scanner/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] - [`2c00c029`](https://github.com/tauri-apps/plugins-workspace/commit/2c00c0292c9127b81567de46691e8c0f73557261) ([#1630](https://github.com/tauri-apps/plugins-workspace/pull/1630) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused multi-word IIFE names to not be formatted correctly. For example the `barcode-scanner` was defined as `window.__TAURI_PLUGIN_CLIPBOARDMANAGER__` instead of `window.__TAURI_PLUGIN_CLIPBOARD_MANAGER__`. diff --git a/plugins/barcode-scanner/Cargo.toml b/plugins/barcode-scanner/Cargo.toml index ced50ac4..369b3999 100644 --- a/plugins/barcode-scanner/Cargo.toml +++ b/plugins/barcode-scanner/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-barcode-scanner" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" description = "Scan QR codes, EAN-13 and other kinds of barcodes on Android and iOS" edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/biometric/CHANGELOG.md b/plugins/biometric/CHANGELOG.md index aae1a90c..40756d7e 100644 --- a/plugins/biometric/CHANGELOG.md +++ b/plugins/biometric/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] ### changes diff --git a/plugins/biometric/Cargo.toml b/plugins/biometric/Cargo.toml index 42e25c6b..9a9aeaa9 100644 --- a/plugins/biometric/Cargo.toml +++ b/plugins/biometric/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-biometric" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" description = "Prompt the user for biometric authentication on Android and iOS." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/clipboard-manager/CHANGELOG.md b/plugins/clipboard-manager/CHANGELOG.md index 2a0217a8..44bb9049 100644 --- a/plugins/clipboard-manager/CHANGELOG.md +++ b/plugins/clipboard-manager/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] - [`2c00c029`](https://github.com/tauri-apps/plugins-workspace/commit/2c00c0292c9127b81567de46691e8c0f73557261) ([#1630](https://github.com/tauri-apps/plugins-workspace/pull/1630) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Fixed an issue that caused multi-word IIFE names to not be formatted correctly. For example the `barcode-scanner` was defined as `window.__TAURI_PLUGIN_CLIPBOARDMANAGER__` instead of `window.__TAURI_PLUGIN_CLIPBOARD_MANAGER__`. diff --git a/plugins/clipboard-manager/Cargo.toml b/plugins/clipboard-manager/Cargo.toml index e089e78f..28e598ef 100644 --- a/plugins/clipboard-manager/Cargo.toml +++ b/plugins/clipboard-manager/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-clipboard-manager" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" description = "Read and write to the system clipboard." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/dialog/CHANGELOG.md b/plugins/dialog/CHANGELOG.md index 14e0e615..1f97b5ed 100644 --- a/plugins/dialog/CHANGELOG.md +++ b/plugins/dialog/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] ### feat diff --git a/plugins/dialog/Cargo.toml b/plugins/dialog/Cargo.toml index f7b06dc0..91f1df1b 100644 --- a/plugins/dialog/Cargo.toml +++ b/plugins/dialog/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-dialog" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" description = "Native system dialogs for opening and saving files along with message dialogs on your Tauri application." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/geolocation/CHANGELOG.md b/plugins/geolocation/CHANGELOG.md index 2ada2dea..7145a639 100644 --- a/plugins/geolocation/CHANGELOG.md +++ b/plugins/geolocation/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] - [`5d170a54`](https://github.com/tauri-apps/plugins-workspace/commit/5d170a5444982dcc14135f6f1fc3e5da359f0eb0) ([#1671](https://github.com/tauri-apps/plugins-workspace/pull/1671) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.3. diff --git a/plugins/geolocation/Cargo.toml b/plugins/geolocation/Cargo.toml index 283f9d3f..ea96720b 100644 --- a/plugins/geolocation/Cargo.toml +++ b/plugins/geolocation/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tauri-plugin-geolocation" description = "Get and track the device's current position" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" edition = { workspace = true } authors = { workspace = true } license = { workspace = true } diff --git a/plugins/haptics/CHANGELOG.md b/plugins/haptics/CHANGELOG.md index f4b94843..d81c2934 100644 --- a/plugins/haptics/CHANGELOG.md +++ b/plugins/haptics/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] ### changes diff --git a/plugins/haptics/Cargo.toml b/plugins/haptics/Cargo.toml index 6b9998ea..a7d14851 100644 --- a/plugins/haptics/Cargo.toml +++ b/plugins/haptics/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tauri-plugin-haptics" description = "Haptic feedback and vibrations on Android and iOS" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" edition = { workspace = true } authors = { workspace = true } license = { workspace = true } diff --git a/plugins/log/CHANGELOG.md b/plugins/log/CHANGELOG.md index 6f4ae53d..544c51c4 100644 --- a/plugins/log/CHANGELOG.md +++ b/plugins/log/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.1] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.0] - [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. diff --git a/plugins/log/Cargo.toml b/plugins/log/Cargo.toml index 1ca5db56..9dbacda7 100644 --- a/plugins/log/Cargo.toml +++ b/plugins/log/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-log" -version = "2.0.0-rc.0" +version = "2.0.0-rc.1" description = "Configurable logging for your Tauri app." authors = { workspace = true } license = { workspace = true } diff --git a/plugins/nfc/CHANGELOG.md b/plugins/nfc/CHANGELOG.md index 09ee3ddf..429bd7d2 100644 --- a/plugins/nfc/CHANGELOG.md +++ b/plugins/nfc/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] ### changes diff --git a/plugins/nfc/Cargo.toml b/plugins/nfc/Cargo.toml index 9bf3f30d..54147975 100644 --- a/plugins/nfc/Cargo.toml +++ b/plugins/nfc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-nfc" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" description = "Read and write NFC tags on Android and iOS." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/notification/CHANGELOG.md b/plugins/notification/CHANGELOG.md index 439b697e..1dea50a6 100644 --- a/plugins/notification/CHANGELOG.md +++ b/plugins/notification/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] ### changes diff --git a/plugins/notification/Cargo.toml b/plugins/notification/Cargo.toml index 7a570fd3..a7cff26f 100644 --- a/plugins/notification/Cargo.toml +++ b/plugins/notification/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-notification" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" description = "Send desktop and mobile notifications on your Tauri application." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/shell/CHANGELOG.md b/plugins/shell/CHANGELOG.md index 3c128036..2617d916 100644 --- a/plugins/shell/CHANGELOG.md +++ b/plugins/shell/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] ### changes diff --git a/plugins/shell/Cargo.toml b/plugins/shell/Cargo.toml index effd89aa..90af4094 100644 --- a/plugins/shell/Cargo.toml +++ b/plugins/shell/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-shell" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" description = "Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application." edition = { workspace = true } authors = { workspace = true } diff --git a/plugins/store/CHANGELOG.md b/plugins/store/CHANGELOG.md index 68dc490d..08ea3dca 100644 --- a/plugins/store/CHANGELOG.md +++ b/plugins/store/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## \[2.0.0-rc.2] + +- [`b9147758`](https://github.com/tauri-apps/plugins-workspace/commit/b914775898c2bee7ceb20bd17ee595005cd17a64) ([#1679](https://github.com/tauri-apps/plugins-workspace/pull/1679) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Explicitly set a minimum macOS version for the Swift package. + ## \[2.0.0-rc.1] ### changes diff --git a/plugins/store/Cargo.toml b/plugins/store/Cargo.toml index f65e11e2..0b6c2fdf 100644 --- a/plugins/store/Cargo.toml +++ b/plugins/store/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tauri-plugin-store" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" description = "Simple, persistent key-value store." authors = { workspace = true } license = { workspace = true } From f690777a911ddc9464e7c94c49761dbb8acff6e2 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 21 Aug 2024 16:14:58 +0300 Subject: [PATCH 3/9] refacator(dialog): mark `FileResponse` as `#[non_exhaustive]` (#1660) * recator(dialog): mark `FileResponse` as `#[non_exhaustive]` closes #1623 * change file --- .changes/dialog-file-response-non-exhaustive.md | 5 +++++ plugins/dialog/src/lib.rs | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changes/dialog-file-response-non-exhaustive.md diff --git a/.changes/dialog-file-response-non-exhaustive.md b/.changes/dialog-file-response-non-exhaustive.md new file mode 100644 index 00000000..f8d45d80 --- /dev/null +++ b/.changes/dialog-file-response-non-exhaustive.md @@ -0,0 +1,5 @@ +--- +"dialog": "patch" +--- + +Mark `FileResponse` as `non_exhaustive`. diff --git a/plugins/dialog/src/lib.rs b/plugins/dialog/src/lib.rs index b57cc44c..c9b1688f 100644 --- a/plugins/dialog/src/lib.rs +++ b/plugins/dialog/src/lib.rs @@ -218,6 +218,7 @@ impl MessageDialogBuilder { #[derive(Debug, Deserialize, Serialize, Default)] #[serde(rename_all = "camelCase")] +#[non_exhaustive] pub struct FileResponse { pub base64_data: Option, pub duration: Option, From 3c52f30ea4ec29c51f7021aa7871614d72e43258 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 21 Aug 2024 17:04:03 +0300 Subject: [PATCH 4/9] chore(deps): update windows-sys crate to `0.59` and global-hotkey to `0.6` (#1665) * chore(deps): update windows-sys crate to `0.59` * update global-hotkey as well * change files --- .changes/global-shortcut-0.6.md | 5 ++ .changes/single-instance-windows-sys.0.59.md | 5 ++ Cargo.lock | 10 ++-- plugins/global-shortcut/Cargo.toml | 2 +- plugins/global-shortcut/src/error.rs | 5 ++ plugins/global-shortcut/src/lib.rs | 53 +++++++++++++------ plugins/single-instance/Cargo.toml | 2 +- .../src/platform_impl/windows.rs | 24 ++++----- 8 files changed, 72 insertions(+), 34 deletions(-) create mode 100644 .changes/global-shortcut-0.6.md create mode 100644 .changes/single-instance-windows-sys.0.59.md diff --git a/.changes/global-shortcut-0.6.md b/.changes/global-shortcut-0.6.md new file mode 100644 index 00000000..c65d9e1a --- /dev/null +++ b/.changes/global-shortcut-0.6.md @@ -0,0 +1,5 @@ +--- +"global-shortcut": "patch" +--- + +Updated `global-hotkey` crate dependency to `0.6` diff --git a/.changes/single-instance-windows-sys.0.59.md b/.changes/single-instance-windows-sys.0.59.md new file mode 100644 index 00000000..7f7af001 --- /dev/null +++ b/.changes/single-instance-windows-sys.0.59.md @@ -0,0 +1,5 @@ +--- +"single-instance": "patch" +--- + +Updated `windows-sys` crate to `0.59` diff --git a/Cargo.lock b/Cargo.lock index 68cfaf1f..302518d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2565,19 +2565,19 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "global-hotkey" -version = "0.5.5" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b436093d1598b05e3b7fddc097b2bad32763f53a1beb25ab6f9718c6a60acd09" +checksum = "298a7667d6011efe6b35673c6b29001b88677ae1b3d6b2feccfbff4b44892866" dependencies = [ "bitflags 2.6.0", - "cocoa 0.25.0", + "cocoa 0.26.0", "crossbeam-channel", "keyboard-types", "objc", "once_cell", "serde", "thiserror", - "windows-sys 0.52.0", + "windows-sys 0.59.0", "x11-dl", ] @@ -6840,7 +6840,7 @@ dependencies = [ "serde_json", "tauri", "thiserror", - "windows-sys 0.52.0", + "windows-sys 0.59.0", "zbus", ] diff --git a/plugins/global-shortcut/Cargo.toml b/plugins/global-shortcut/Cargo.toml index 2eec1eb4..02e963fd 100644 --- a/plugins/global-shortcut/Cargo.toml +++ b/plugins/global-shortcut/Cargo.toml @@ -24,4 +24,4 @@ log = { workspace = true } thiserror = { workspace = true } [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies] -global-hotkey = { version = "0.5", features = ["serde"] } +global-hotkey = { version = "0.6", features = ["serde"] } diff --git a/plugins/global-shortcut/src/error.rs b/plugins/global-shortcut/src/error.rs index a1e366a7..37392b32 100644 --- a/plugins/global-shortcut/src/error.rs +++ b/plugins/global-shortcut/src/error.rs @@ -5,9 +5,14 @@ use serde::{Serialize, Serializer}; #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { #[error("{0}")] GlobalHotkey(String), + #[error(transparent)] + RecvError(#[from] std::sync::mpsc::RecvError), + #[error(transparent)] + Tauri(#[from] tauri::Error), } impl Serialize for Error { diff --git a/plugins/global-shortcut/src/lib.rs b/plugins/global-shortcut/src/lib.rs index c472e726..5868ff9d 100644 --- a/plugins/global-shortcut/src/lib.rs +++ b/plugins/global-shortcut/src/lib.rs @@ -20,11 +20,11 @@ use std::{ sync::{Arc, Mutex}, }; +use global_hotkey::GlobalHotKeyEvent; pub use global_hotkey::{ hotkey::{Code, HotKey as Shortcut, Modifiers}, GlobalHotKeyEvent as ShortcutEvent, HotKeyState as ShortcutState, }; -use global_hotkey::{GlobalHotKeyEvent, GlobalHotKeyManager}; use serde::Serialize; use tauri::{ ipc::Channel, @@ -60,13 +60,33 @@ struct RegisteredShortcut { handler: Option>>, } +struct GlobalHotKeyManager(global_hotkey::GlobalHotKeyManager); + +/// SAFETY: we ensure it is run on main thread only +unsafe impl Send for GlobalHotKeyManager {} +/// SAFETY: we ensure it is run on main thread only +unsafe impl Sync for GlobalHotKeyManager {} + pub struct GlobalShortcut { #[allow(dead_code)] app: AppHandle, - manager: GlobalHotKeyManager, + manager: Arc, shortcuts: Arc>>>, } +macro_rules! run_main_thread { + ($handle:expr, $manager:expr, |$m:ident| $ex:expr) => {{ + let (tx, rx) = std::sync::mpsc::channel(); + let manager = $manager.clone(); + let task = move || { + let f = |$m: &GlobalHotKeyManager| $ex; + let _ = tx.send(f(&*manager)); + }; + $handle.run_on_main_thread(task)?; + rx.recv()? + }}; +} + impl GlobalShortcut { fn register_internal, &Shortcut, ShortcutEvent) + Send + Sync + 'static>( &self, @@ -75,8 +95,7 @@ impl GlobalShortcut { ) -> Result<()> { let id = shortcut.id(); let handler = handler.map(|h| Arc::new(Box::new(h) as HandlerFn)); - - self.manager.register(shortcut)?; + run_main_thread!(self.app, self.manager, |m| m.0.register(shortcut))?; self.shortcuts .lock() .unwrap() @@ -95,7 +114,7 @@ impl GlobalShortcut { let mut shortcuts = self.shortcuts.lock().unwrap(); for shortcut in hotkeys { - self.manager.register(shortcut)?; + run_main_thread!(self.app, self.manager, |m| m.0.register(shortcut))?; shortcuts.insert( shortcut.id(), RegisteredShortcut { @@ -167,7 +186,7 @@ impl GlobalShortcut { S::Error: std::error::Error, { let shortcut = try_into_shortcut(shortcut)?; - self.manager.unregister(shortcut)?; + run_main_thread!(self.app, self.manager, |m| m.0.unregister(shortcut))?; self.shortcuts.lock().unwrap().remove(&shortcut.id()); Ok(()) } @@ -180,15 +199,19 @@ impl GlobalShortcut { where T::Error: std::error::Error, { - let mut s = Vec::new(); + let mut mapped_shortcuts = Vec::new(); for shortcut in shortcuts { - s.push(try_into_shortcut(shortcut)?); + mapped_shortcuts.push(try_into_shortcut(shortcut)?); } - self.manager.unregister_all(&s)?; + { + let mapped_shortcuts = mapped_shortcuts.clone(); + #[rustfmt::skip] + run_main_thread!(self.app, self.manager, |m| m.0.unregister_all(&mapped_shortcuts))?; + } let mut shortcuts = self.shortcuts.lock().unwrap(); - for s in s { + for s in mapped_shortcuts { shortcuts.remove(&s.id()); } @@ -200,9 +223,9 @@ impl GlobalShortcut { let mut shortcuts = self.shortcuts.lock().unwrap(); let hotkeys = std::mem::take(&mut *shortcuts); let hotkeys = hotkeys.values().map(|s| s.shortcut).collect::>(); - self.manager - .unregister_all(hotkeys.as_slice()) - .map_err(Into::into) + #[rustfmt::skip] + let res = run_main_thread!(self.app, self.manager, |m| m.0.unregister_all(hotkeys.as_slice())); + res.map_err(Into::into) } /// Determines whether the given shortcut is registered by this application or not. @@ -375,7 +398,7 @@ impl Builder { is_registered, ]) .setup(move |app, _api| { - let manager = GlobalHotKeyManager::new()?; + let manager = global_hotkey::GlobalHotKeyManager::new()?; let mut store = HashMap::>::new(); for shortcut in shortcuts { manager.register(shortcut)?; @@ -405,7 +428,7 @@ impl Builder { app.manage(GlobalShortcut { app: app.clone(), - manager, + manager: Arc::new(GlobalHotKeyManager(manager)), shortcuts, }); Ok(()) diff --git a/plugins/single-instance/Cargo.toml b/plugins/single-instance/Cargo.toml index bc05e33f..df827c40 100644 --- a/plugins/single-instance/Cargo.toml +++ b/plugins/single-instance/Cargo.toml @@ -22,7 +22,7 @@ thiserror = { workspace = true } semver = { version = "1", optional = true } [target."cfg(target_os = \"windows\")".dependencies.windows-sys] -version = "0.52" +version = "0.59" features = [ "Win32_System_Threading", "Win32_System_DataExchange", diff --git a/plugins/single-instance/src/platform_impl/windows.rs b/plugins/single-instance/src/platform_impl/windows.rs index d5ff3b8b..e99f405d 100644 --- a/plugins/single-instance/src/platform_impl/windows.rs +++ b/plugins/single-instance/src/platform_impl/windows.rs @@ -53,7 +53,7 @@ pub fn init(f: Box>) -> TauriPlugin { unsafe { let hwnd = FindWindowW(class_name.as_ptr(), window_name.as_ptr()); - if hwnd != 0 { + if !hwnd.is_null() { let data = format!( "{}|{}\0", std::env::current_dir() @@ -74,7 +74,7 @@ pub fn init(f: Box>) -> TauriPlugin { } } } else { - app.manage(MutexHandle(hmutex)); + app.manage(MutexHandle(hmutex as _)); let hwnd = create_event_target_window::(&class_name, &window_name); unsafe { @@ -85,7 +85,7 @@ pub fn init(f: Box>) -> TauriPlugin { ) }; - app.manage(TargetWindowHandle(hwnd)); + app.manage(TargetWindowHandle(hwnd as _)); } Ok(()) @@ -101,12 +101,12 @@ pub fn init(f: Box>) -> TauriPlugin { pub fn destroy>(manager: &M) { if let Some(hmutex) = manager.try_state::() { unsafe { - ReleaseMutex(hmutex.0); - CloseHandle(hmutex.0); + ReleaseMutex(hmutex.0 as _); + CloseHandle(hmutex.0 as _); } } if let Some(hwnd) = manager.try_state::() { - unsafe { DestroyWindow(hwnd.0) }; + unsafe { DestroyWindow(hwnd.0 as _) }; } } @@ -150,12 +150,12 @@ fn create_event_target_window(class_name: &[u16], window_name: &[u16 cbClsExtra: 0, cbWndExtra: 0, hInstance: GetModuleHandleW(std::ptr::null()), - hIcon: 0, - hCursor: 0, - hbrBackground: 0, + hIcon: std::ptr::null_mut(), + hCursor: std::ptr::null_mut(), + hbrBackground: std::ptr::null_mut(), lpszMenuName: std::ptr::null(), lpszClassName: class_name.as_ptr(), - hIconSm: 0, + hIconSm: std::ptr::null_mut(), }; RegisterClassExW(&class); @@ -179,8 +179,8 @@ fn create_event_target_window(class_name: &[u16], window_name: &[u16 0, 0, 0, - 0, - 0, + std::ptr::null_mut(), + std::ptr::null_mut(), GetModuleHandleW(std::ptr::null()), std::ptr::null(), ); From 448846b834d23df6e7c5dc66c5dd9aa0cb01846d Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Sat, 24 Aug 2024 01:35:53 +0900 Subject: [PATCH 5/9] feat(fs): resolve content URIs on Android (#1658) * Implemented writeTextFile on Android. * Added license headers. * fix fmt checks. * implement more file APIs * change file * cleanup * refactor dialog plugin to leverage new FS APIs * implement metadata functions * fix build * expose FS rust API * resolve resources on android * update pnpm * update docs --------- Co-authored-by: Lucas Nogueira --- .changes/dialog-return-path.md | 7 + .changes/resolve-content-uris.md | 5 + Cargo.lock | 33 +- Cargo.toml | 8 +- examples/api/package.json | 2 +- examples/api/src-tauri/capabilities/base.json | 3 + .../src-tauri/gen/android/.idea/gradle.xml | 1 + examples/api/src/views/Dialog.svelte | 15 +- plugins/deep-link/examples/app/package.json | 2 +- plugins/dialog/Cargo.toml | 4 + .../android/src/main/java/DialogPlugin.kt | 41 +- plugins/dialog/guest-js/index.ts | 17 +- plugins/dialog/ios/Sources/DialogPlugin.swift | 49 +- plugins/dialog/src/commands.rs | 84 +- plugins/dialog/src/desktop.rs | 32 +- plugins/dialog/src/error.rs | 2 + plugins/dialog/src/lib.rs | 292 ++++-- plugins/dialog/src/mobile.rs | 13 +- plugins/fs/android/.gitignore | 2 + plugins/fs/android/build.gradle.kts | 45 + plugins/fs/android/proguard-rules.pro | 21 + plugins/fs/android/settings.gradle | 31 + .../java/ExampleInstrumentedTest.kt | 28 + .../fs/android/src/main/AndroidManifest.xml | 3 + plugins/fs/android/src/main/java/FsPlugin.kt | 93 ++ .../android/src/test/java/ExampleUnitTest.kt | 21 + plugins/fs/build.rs | 1 + plugins/fs/src/commands.rs | 493 ++++++---- plugins/fs/src/desktop.rs | 35 + plugins/fs/src/error.rs | 3 + plugins/fs/src/lib.rs | 384 ++++++++ plugins/fs/src/mobile.rs | 96 ++ plugins/fs/src/models.rs | 18 + plugins/fs/src/watcher.rs | 6 +- .../examples/vanilla/package.json | 2 +- .../examples/AppSettingsManager/package.json | 2 +- .../websocket/examples/tauri-app/package.json | 2 +- pnpm-lock.yaml | 873 +++++++++++------- 38 files changed, 1950 insertions(+), 819 deletions(-) create mode 100644 .changes/dialog-return-path.md create mode 100644 .changes/resolve-content-uris.md create mode 100644 plugins/fs/android/.gitignore create mode 100644 plugins/fs/android/build.gradle.kts create mode 100644 plugins/fs/android/proguard-rules.pro create mode 100644 plugins/fs/android/settings.gradle create mode 100644 plugins/fs/android/src/androidTest/java/ExampleInstrumentedTest.kt create mode 100644 plugins/fs/android/src/main/AndroidManifest.xml create mode 100644 plugins/fs/android/src/main/java/FsPlugin.kt create mode 100644 plugins/fs/android/src/test/java/ExampleUnitTest.kt create mode 100644 plugins/fs/src/desktop.rs create mode 100644 plugins/fs/src/mobile.rs create mode 100644 plugins/fs/src/models.rs diff --git a/.changes/dialog-return-path.md b/.changes/dialog-return-path.md new file mode 100644 index 00000000..2bd7b4db --- /dev/null +++ b/.changes/dialog-return-path.md @@ -0,0 +1,7 @@ +--- +"dialog": patch +"dialog-js": patch +--- + +The `open` function now returns a string representing either the file path or URI instead of an object. +To read the file data, use the `fs` APIs. diff --git a/.changes/resolve-content-uris.md b/.changes/resolve-content-uris.md new file mode 100644 index 00000000..781eff70 --- /dev/null +++ b/.changes/resolve-content-uris.md @@ -0,0 +1,5 @@ +--- +"fs": patch:feat +--- + +Resolve `content://` path URIs on Android. diff --git a/Cargo.lock b/Cargo.lock index 302518d1..c685b090 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6359,9 +6359,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tauri" -version = "2.0.0-rc.3" +version = "2.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79776954e2cd6b6c3b56e2cd99905a3a166017495a39ac8eb4c85dd8ea8704b4" +checksum = "7d386b956b09cf88301912453829269f3914b3c813020d429ed8110c75e9dded" dependencies = [ "anyhow", "bytes", @@ -6412,9 +6412,9 @@ dependencies = [ [[package]] name = "tauri-build" -version = "2.0.0-rc.3" +version = "2.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc103bde77870e08d5fc8765615b9615997827550b626fbc4ebbd7a1fbfe2a2" +checksum = "1e79aafbbfc8262d7937675cb44c397e975ab8e0cd722db1c37de694fd443570" dependencies = [ "anyhow", "cargo_toml", @@ -6436,9 +6436,9 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.0.0-rc.3" +version = "2.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea061e6be9b37ab455eadc189f45617deafc85c94f78f9cd584862a6deaa83d1" +checksum = "5ce4e521130c5d7b377ddfdc43310ece626b67ec07ae74174407ad7e6cd17d20" dependencies = [ "base64 0.22.1", "brotli", @@ -6463,9 +6463,9 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.0.0-rc.3" +version = "2.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e20d6f6f96f55a43339c465b3c8205d71940372d54d7c665c5329e8e4ba35d0" +checksum = "a5995206394cd30411fc5c8ae195e498357f63e11ed960ea32b53512dcb2a5a5" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -6477,9 +6477,9 @@ dependencies = [ [[package]] name = "tauri-plugin" -version = "2.0.0-rc.3" +version = "2.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec01af01098a286d3e430c1fa947bfd77bc8011ecb209438af4444b02d82b29e" +checksum = "0ebbdbf4e6d7328e0c0f2427b4f56d792ee1ae84ab4fb0286b81a2e408836046" dependencies = [ "anyhow", "glob", @@ -6612,6 +6612,7 @@ dependencies = [ "tauri-plugin", "tauri-plugin-fs", "thiserror", + "url", ] [[package]] @@ -6971,9 +6972,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "2.0.0-rc.3" +version = "2.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4e736d3293f8347e5d2c5b250fe0e5b873499f5483578b139445dbbf802e2e5" +checksum = "6e49398fb1d7736e41099aa7efaf45d599e480a36b3e7f88977b547b662d7253" dependencies = [ "dpi", "gtk", @@ -6990,9 +6991,9 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "2.0.0-rc.3" +version = "2.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fead81c1bd0205d5f02580e64f522704618274e784c2d1c127e4ba19acd0b79" +checksum = "8b2ce1dca90243bd4a77a1020847688590e1ded2f6d190d5a96877b0039f0500" dependencies = [ "cocoa 0.26.0", "gtk", @@ -7014,9 +7015,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "2.0.0-rc.3" +version = "2.0.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "285af18e09665ea15fdda04cb28fb579a4d71b4e1640628489fecca98838ca9a" +checksum = "2d702b62eed4cf89034926cb1834e2d13a7d745ea08a457fd336f94cde48f2fb" dependencies = [ "aes-gcm", "brotli", diff --git a/Cargo.toml b/Cargo.toml index e24823f7..5ba3f825 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ resolver = "2" [workspace.dependencies] serde = { version = "1", features = ["derive"] } log = "0.4" -tauri = { version = "2.0.0-rc.3", default-features = false } -tauri-build = "2.0.0-rc.3" -tauri-plugin = "2.0.0-rc.3" -tauri-utils = "2.0.0-rc.3" +tauri = { version = "2.0.0-rc.5", default-features = false } +tauri-build = "2.0.0-rc.5" +tauri-plugin = "2.0.0-rc.5" +tauri-utils = "2.0.0-rc.5" serde_json = "1" thiserror = "1" url = "2" diff --git a/examples/api/package.json b/examples/api/package.json index 6c4d1d4a..8d28c501 100644 --- a/examples/api/package.json +++ b/examples/api/package.json @@ -30,7 +30,7 @@ "@iconify-json/codicon": "^1.1.37", "@iconify-json/ph": "^1.1.8", "@sveltejs/vite-plugin-svelte": "^3.0.1", - "@tauri-apps/cli": "2.0.0-rc.4", + "@tauri-apps/cli": "2.0.0-rc.6", "@unocss/extractor-svelte": "^0.62.0", "svelte": "^4.2.8", "unocss": "^0.62.0", diff --git a/examples/api/src-tauri/capabilities/base.json b/examples/api/src-tauri/capabilities/base.json index da21da28..1a030079 100644 --- a/examples/api/src-tauri/capabilities/base.json +++ b/examples/api/src-tauri/capabilities/base.json @@ -61,6 +61,9 @@ "clipboard-manager:allow-write-text", "clipboard-manager:allow-read-image", "clipboard-manager:allow-write-image", + "fs:allow-open", + "fs:allow-write", + "fs:allow-read", "fs:allow-rename", "fs:allow-mkdir", "fs:allow-remove", diff --git a/examples/api/src-tauri/gen/android/.idea/gradle.xml b/examples/api/src-tauri/gen/android/.idea/gradle.xml index 83b872db..120d2e91 100644 --- a/examples/api/src-tauri/gen/android/.idea/gradle.xml +++ b/examples/api/src-tauri/gen/android/.idea/gradle.xml @@ -27,6 +27,7 @@