Skip to content

Commit

Permalink
GitHub Actions are still grumpy
Browse files Browse the repository at this point in the history
  • Loading branch information
emorydunn committed Oct 17, 2024
1 parent 39c8ec9 commit f6d1a5f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 46 deletions.
92 changes: 47 additions & 45 deletions Sources/StreamDeck/StreamDeck Plugin/Action/Action+Sent.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Action+Sent.swift
//
//
//
// Created by Emory Dunn on 11/30/22.
//
Expand All @@ -13,9 +13,9 @@ import OSLog
fileprivate let log = Logger(subsystem: "StreamDeckPlugin", category: "Action")

public extension Action {

// MARK: Sent

/// Save data persistently for the action's instance.
/// - Parameters:
/// - context: An opaque value identifying the instance's action or Property Inspector.
Expand All @@ -28,7 +28,7 @@ public extension Action {
payload: settings)
}
}

/// Save data persistently for the action's instance.
/// - Parameters:
/// - context: An opaque value identifying the instance's action or Property Inspector.
Expand All @@ -40,7 +40,7 @@ public extension Action {
payload: settings)
}
}

/// Request the persistent data for the action's instance.
/// - context: An opaque value identifying the instance's action or Property Inspector.
func getSettings() {
Expand Down Expand Up @@ -69,7 +69,7 @@ public extension Action {
await PluginCommunication.shared.sendEvent(.logMessage, context: nil, payload: ["message": message])
}
}

/// Write a debug log to the logs file.
/// - Parameters:
/// - items: Zero or more items to print.
Expand All @@ -78,30 +78,30 @@ public extension Action {
let message = items.map {
String(describing: $0)
}.joined(separator: separator)

logMessage(message)
}

/// Dynamically change the title of an instance of an action.
/// - Parameters:
/// - context: An opaque value identifying the instance's action or Property Inspector.
/// - title: The title to display. If there is no title parameter, the title is reset to the title set by the user.
/// - target: Specify if you want to display the title on hardware, software, or both.
/// - state: A 0-based integer value representing the state of an action with multiple states. This is an optional parameter. If not specified, the title is set to all states.
func setTitle(to title: String?, target: Target? = nil, state: Int? = nil) {
var payload: [String: Any] = [:]

payload["title"] = title
payload["target"] = target?.rawValue
payload["state"] = state

Task {
var payload: [String: Any] = [:]

payload["title"] = title
payload["target"] = target?.rawValue
payload["state"] = state

await PluginCommunication.shared.sendEvent(.setTitle,
context: context,
payload: payload)
}
}

/// Dynamically change the image displayed by an instance of an action.
///
/// The image is automatically encoded to a prefixed base64 string.
Expand All @@ -112,19 +112,20 @@ public extension Action {
/// - target: Specify if you want to display the title on hardware, software, or both.
/// - state: A 0-based integer value representing the state of an action with multiple states. This is an optional parameter. If not specified, the image is set to all states.
func setImage(to image: NSImage?, target: Target? = nil, state: Int? = nil) {
var payload: [String: Any] = [:]

payload["image"] = image?.base64String
payload["target"] = target?.rawValue
payload["state"] = state

Task {
var payload: [String: Any] = [:]

payload["image"] = image?.base64String
payload["target"] = target?.rawValue
payload["state"] = state


await PluginCommunication.shared.sendEvent(.setImage,
context: context,
payload: payload)
}
}

/// Dynamically change the image displayed by an instance of an action.
///
/// The image is automatically encoded to a prefixed base64 string.
Expand All @@ -144,13 +145,13 @@ public extension Action {
setImage(to: nil, target: target, state: state)
return
}

let image = NSImage(contentsOf: imageURL)

setImage(to: image, target: target, state: state)
}


/// Dynamically change the image displayed by an instance of an action.
///
/// The image is automatically encoded to a prefixed base64 string.
Expand All @@ -161,52 +162,53 @@ public extension Action {
/// - target: Specify if you want to display the title on hardware, software, or both.
/// - state: A 0-based integer value representing the state of an action with multiple states. This is an optional parameter. If not specified, the image is set to all states.
func setImage(toSVG svg: String?, target: Target? = nil, state: Int? = nil) {
var payload: [String: Any] = [:]

if let svg = svg {
payload["image"] = "data:image/svg+xml;charset=utf8,\(svg)"
}

payload["target"] = target?.rawValue
payload["state"] = state

Task {
var payload: [String: Any] = [:]

if let svg = svg {
payload["image"] = "data:image/svg+xml;charset=utf8,\(svg)"
}

payload["target"] = target?.rawValue
payload["state"] = state


await PluginCommunication.shared.sendEvent(.setImage,
context: context,
payload: payload)
}
}

/// Temporarily show an alert icon on the image displayed by an instance of an action.
/// - Parameter context: An opaque value identifying the instance's action or Property Inspector.
func showAlert() {
Task {
await PluginCommunication.shared.sendEvent(.showAlert, context: context, payload: nil)
}
}

/// Temporarily show an OK checkmark icon on the image displayed by an instance of an action.
/// - Parameter context: An opaque value identifying the instance's action or Property Inspector.
func showOk() {
Task {
await PluginCommunication.shared.sendEvent(.showOK, context: context, payload: nil)
}
}

/// Change the state of the action's instance supporting multiple states.
/// - Parameters:
/// - context: An opaque value identifying the instance's action or Property Inspector.
/// - state: A 0-based integer value representing the state of an action with multiple states.
func setState(to state: Int) {
let payload: [String: Any] = ["state": state]

Task {
await PluginCommunication.shared.sendEvent(.setState,
context: context,
payload: payload)
}
}

/// Send a payload to the Property Inspector.
/// - Parameters:
/// - context: An opaque value identifying the instance's action or Property Inspector.
Expand All @@ -220,8 +222,8 @@ public extension Action {
payload: payload)
}
}


/// The plugin can send a `setFeedback` event to the Stream Deck application to dynamically change properties of items on the Stream Deck + touch display layout.
func setFeedback(_ payload: [String: Any]) {
Task {
Expand All @@ -230,21 +232,21 @@ public extension Action {
payload: payload)
}
}

/// The plugin can send a `setFeedbackLayout` event to the Stream Deck application to dynamically change the current Stream Deck + touch display layout.
///
/// `setFeedbackLayout` can use the `id` of a built-in layout or a relative path to a custom layout JSON file.
/// - Parameter layout: The layout to set.
func setFeedbackLayout(_ layout: LayoutName) {
let payload: [String: Any] = ["layout": layout.id]

Task {
await PluginCommunication.shared.sendEvent(.setFeedbackLayout,
context: context,
payload: payload)
}
}

/// Sets the trigger descriptions associated with an encoder (touch display + dial) action instance.
///
/// All descriptions are optional; when one or more descriptions are defined all descriptions are updated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ public extension Plugin {
/// - target: Specify if you want to display the title on hardware, software, or both.
/// - state: A 0-based integer value representing the state of an action with multiple states. This is an optional parameter. If not specified, the title is set to all states.
func setImage(in context: String, to image: NSImage?, target: Target? = nil, state: Int? = nil) {

let encodedImage = image?.base64String

Task {
var payload: [String: Any] = [:]

payload["image"] = image?.base64String
payload["image"] = encodedImage
payload["target"] = target?.rawValue
payload["state"] = state

Expand Down

0 comments on commit f6d1a5f

Please sign in to comment.