8000 feat: add onDeviceDidChange [DRAFT] by GeekyEggo · Pull Request #115 · elgatosf/streamdeck · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add onDeviceDidChange [DRAFT] #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related 8000 emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 93 additions & 83 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,193 +12,203 @@

# Change Log

## 1.4.0

### ✨ New

- Add `streamDeck.devices.onDidChange` event; occurs when a device name or size changes.

### ♻️ Update

- Device size now reflects visible canvas size of scalable devices, for example Stream Deck Mobile and Virtual Stream Deck.

## 1.3.1

### 🐞 Fix

- Update reading of the manifest to be lazy to improve mocking within tests.
- Update reading of the manifest to be lazy to improve mocking within tests.

## 1.3.0

### ✨ New

- Add support for serializing enumerable collections.
- Add support for serializing enumerable collections.

### ♻️ Update

- Improve documentation for profile switching.
- Update dependencies.
- Improve documentation for profile switching.
- Update dependencies.

## 1.2.1

### ♻️ Update

- Update `@elgato/schemas` dependency.
- Update `@elgato/schemas` dependency.

### 🐞 Fix

- Fix Node.js engine requirements.
- Fix Node.js engine requirements.

## 1.2.0

### ✨ New

- Add support for Chinese (Traditional).
- Add support for Chinese (Traditional).

### 🐞 Fix

- Fix types of `EventEmitter` event arguments.
- Fix types of `EventEmitter` event arguments.

## 1.1.0

### ✨ New

- Add [`.drop()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/drop), [`.flapMap()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/flatMap), [`.take()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/take), and [`.toArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/toArray) iterator helper polyfills to `Enumerable`.
- Add [`.drop()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/drop), [`.flapMap()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/flatMap), [`.take()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/take), and [`.toArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/toArray) iterator helper polyfills to `Enumerable`.

### ♻️ Update

- Update `SingletonAction.actions` to return an `Enumerable`.
- Update `SingletonAction.actions` to return an `Enumerable`.

## 1.0.1

### ♻️ Update

- Update minimum allowed log level in production to be `DEBUG` to assist with debugging (default remains `INFO`).
- Update minimum allowed log level in production to be `DEBUG` to assist with debugging (default remains `INFO`).

## 1.0.0

### ✨ New

- Add action tracking, allowing access to currently visible actions.
- `streamDeck.actions` — all visible actions.
- `SingletonAction.actions` — visible actions that match the action's UUID.
- Add `setTitle` to `DialAction`, allowing you to set the title of a layout.
- Add `Enumerable` class for creating readonly collections.
- Add device information to `Action` provided in event arguments.
- Add iterator helpers to `streamDeck.devices` and `streamDeck.actions`.
- Add action tracking, allowing access to currently visible actions.
- `streamDeck.actions` — all visible actions.
- `SingletonAction.actions` — visible actions that match the action's UUID.
- Add `setTitle` to `DialAction`, allowing you to set the title of a layout.
- Add `Enumerable` class for creating readonly collections.
- Add device information to `Action` provided in event arguments.
- Add iterator helpers to `streamDeck.devices` and `streamDeck.actions`.

### 🐞 Fix

- Fix missing language support for Korean (ko).
- Fix TypeScript declaration incorrectly exporting types as classes.
- Fix missing language support for Korean (ko).
- Fix TypeScript declaration incorrectly exporting types as classes.

### ♻️ Update

- Remove `streamDeck.actions.createController` in favor of `streamDeck.actions.getActionById`.
- Remove `Action.sendToPropertyInspector` in favour of `streamDeck.ui.current.sendToPropertyInspector`.
- Remove `ev.deviceId` in favour of `ev.action.device.id`.
- Rename `onDidConnect` to `onConnected` within the UI.
- Remove `streamDeck.actions.createController` in favor of `streamDeck.actions.getActionById`.
- Remove `Action.sendToPropertyInspector` in favour of `streamDeck.ui.current.sendToPropertyInspector`.
- Remove `ev.deviceId` in favour of `ev.action.device.id`.
- Rename `onDidConnect` to `onConnected` within the UI.

### ⬆️ Upgrading

- For information on breaking changes, and migrating to the this version, read more about [upgrading to v1.0.0](/UPGRADE.md#v1-0-0).
- For information on breaking changes, and migrating to the this version, read more about [upgrading to v1.0.0](/UPGRADE.md#v1-0-0).

## 0.4.0-beta

### ✨ New

- Package can now be imported in both Node.js and the browser (in the scope of a property inspector).
- Add support for property inspector.
- Add `streamDeck.onDidConnect` event listener.
- Add `streamDeck.settings` namespace for interacting with settings.
- Add `streamDeck.system` namespace for system-related operations.
- Add `streamDeck.plugin` namespace for bi-direction communication with the plugin and the UI.
- Add `isInMultiAction` to the property inspector's action information.
- Package can now be imported in both Node.js and the browser (in the scope of a property inspector).
- Add support for property inspector.
- Add `streamDeck.onDidConnect` event listener.
- Add `streamDeck.settings` namespace for interacting with settings.
- Add `streamDeck.system` namespace for system-related operations.
- Add `streamDeck.plugin` namespace for bi-direction communication with the plugin and the UI.
- Add `isInMultiAction` to the property inspector's action information.

### 🐞 Fix

- `Coordinates` type could erroneously have a non-number type for `row`.
- Fix support for allowed types within payloads.
- Fix localization lookup to index from `Localization`.
- Fix race condition when tracking the property inspector.
- Fix `streamDeck.setGlobalSettings` to require settings that extend `JsonObject`.
- `Coordinates` type could erroneously have a non-number type for `row`.
- Fix support for allowed types within payloads.
- Fix localization lookup to index from `Localization`.
- Fix race condition when tracking the property inspector.
- Fix `streamDeck.setGlobalSettings` to require settings that extend `JsonObject`.

### ♻️ Update

- Update layout and manifest references to propagate from [`@elgato/schemas`](https://github.com/elgatosf/schemas).
- Localization lookup will now return the key if the resource is not defined.
- Update structure of JSON localizations.
- Update `State` type to allow for more than two states.
- Update routing to prevent exposure of internal messages.
- Update build to export Stream Deck API types.
- Update `ws` dependency.
- Update layout and manifest references to propagate from [`@elgato/schemas`](https://github.com/elgatosf/schemas).
- Localization lookup will now return the key if the resource is not defined.
- Update structure of JSON localizations.
- Update `State` type to allow for more than two states.
- Update routing to prevent exposure of internal messages.
- Update build to export Stream Deck API types.
- Update `ws` dependency.

### ⬆️ Upgrading

- For information on breaking changes, and migrating to the this version, read more about [upgrading to v0.4.0](/UPGRADE.md#v0-4-0).
- For information on breaking changes, and migrating to the this version, read more about [upgrading to v0.4.0](/UPGRADE.md#v0-4-0).

## 0.3.0

### ✨ New

- Add cross-compatible event emitter with type support.
- Add pattern validation for manifest's `Version`.
- Add validation of colors defined within the manifest.
- Add cross-compatible event emitter with type support.
- Add pattern validation for manifest's `Version`.
- Add validation of colors defined within the manifest.

### 🐞 Fix

- Fix `PayloadObject` not being exported; enables inheritance of actions.
- Fix manifest layout not allowing `$A0` as a pre-defined value.
- Fix `PayloadObject` not being exported; enables inheritance of actions.
- Fix manifest layout not allowing `$A0` as a pre-defined value.

### ♻️ Update

- Update manifest file path validation to prevent referencing a file outside of the plugin directory.
- Update manifest file path validation to allow periods.
- Update manifest UUID validation to allow more than 3 segments.
- Update manifest UUID validation to prevent underscores.
- Update documentation of `Actions[].Image` to reflect support for .gif files.
- Update default export to be named (improving VSCode intellisense).
- Update manifest file path validation to prevent referencing a file outside of the plugin directory.
- Update manifest file path validation to allow periods.
- Update manifest UUID validation to allow more than 3 segments.
- Update manifest UUID validation to prevent underscores.
- Update documentation of `Actions[].Image` to reflect support for .gif files.
- Update default export to be named (improving VSCode intellisense).

### 🗑️ Remove

- Remove `$A2` incorrectly being listed as a pre-defined layout.
- Remove `$A2` incorrectly being listed as a pre-defined layout.

## 0.2.0

### ✨ New

#### Stream Deck 6.5

- Add support for receiving messages via deep-linking.
- URL format: `streamdeck://plugins/message/<PLUGIN_UUID>/<MESSAGE>`
- Accessible as part of the `system` namespace, `streamDeck.system.onDidReceiveDeepLink`
- Add support for switching to a specific profile page when calling `switchToProfile`.
- Add `controller` information to `WillAppear` and `WillDisappear` events for multi-actions.
- Add support for Node.js plugins with the `.cjs` or `.mjs` file extensions.
- Add support for receiving messages via deep-linking.
- URL format: `streamdeck://plugins/message/<PLUGIN_UUID>/<MESSAGE>`
- Accessible as part of the `system` namespace, `streamDeck.system.onDidReceiveDeepLink`
- Add support for switching to a specific profile page when calling `switchToProfile`.
- Add `controller` information to `WillAppear` and `WillDisappear` events for multi-actions.
- Add support for Node.js plugins with the `.cjs` or `.mjs` file extensions.

#### Node.js SDK

- Add `profiles`, `settings`, `system`, and `ui` namespaces.
- Add `streamDeck.actions.createController(id)` to enable the control of a contextualized action.
- Add `streamDeck.devices.getDeviceBy(deviceId)` to enable the selection of a device by identifier.
- Add `length`, `forEach`, and `[Symbol.iterator]` to `streamDeck.devices` to enable iteration.
- Add `profiles`, `settings`, `system`, and `ui` namespaces.
- Add `streamDeck.actions.createController(id)` to enable the control of a contextualized action.
- Add `streamDeck.devices.getDeviceBy(deviceId)` to enable the selection of a device by identifier.
- Add `length`, `forEach`, and `[Symbol.iterator]` to `streamDeck.devices` to enable iteration.

### ♻️ Improvements

- Refactor `streamDeck.devices` to namespace.
- Update manifest JSON schema to support Stream Deck 6.5.
- Improve enum support in manifest and layout JSON schemas.
- Node.js runtime updated to v20.8.1.
- Refactor `streamDeck.devices` to namespace.
- Update manifest JSON schema to support Stream Deck 6.5.
- Improve enum support in manifest and layout JSON schemas.
- Node.js runtime updated to v20.8.1.

### 🐞 Bug Fixes

- Correctly validate paths without extensions in manifest JSON schema.
- Default `text-overflow` set to `ellipsis` in layout JSON schema.
- Correctly validate paths without extensions in manifest JSON schema.
- Default `text-overflow` set to `ellipsis` in layout JSON schema.

### ⬆️ Upgrading

- For information on breaking changes, and migrating to the this version, read more about [upgrading to v0.2.0](/UPGRADE.md#v0-2-0).
- For information on breaking changes, and migrating to the this version, read more about [upgrading to v0.2.0](/UPGRADE.md#v0-2-0).

## 0.1.0

### ✨ New

- Add Stream Deck communication client (see `streamDeck.client`).
- Add support for receiving all events (Stream Deck 6.4).
- Add support for sending all commands (Stream Deck 6.4).
- Add action routing (see `streamDeck.actions`).
- Add centralized device information tracking (see `streamDeck.devices`).
- Add local file-based logging framework (see `streamDeck.logger`).
- Add localization support (see `streamDeck.i18n`).
- Add manifest information (see `streamDeck.manifest`).
- Add Stream Deck and plugin information (see `streamDeck.info`).
- Add Stream Deck communication client (see `streamDeck.client`).
- Add support for receiving all events (Stream Deck 6.4).
- Add support for sending all commands (Stream Deck 6.4).
- Add action routing (see `streamDeck.actions`).
- Add centralized device information tracking (see `streamDeck.devices`).
- Add local file-based logging framework (see `streamDeck.logger`).
- Add localization support (see `streamDeck.i18n`).
- Add manifest information (see `streamDeck.manifest`).
- Add Stream Deck and plugin information (see `streamDeck.info`).
13 changes: 13 additions & 0 deletions src/api/events/device.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import type { DeviceInfo } from "../device";
import type { EventIdentifier } from "./index";

/**
* Occurs when a Stream Deck device changed, for example its name or size.
*
* Available from Stream Deck 7.0.
*/
export type DeviceDidChange = DeviceIdentifier &
EventIdentifier<"deviceDidChange"> & {
/**
* Information about the device that changed.
*/
readonly deviceInfo: DeviceInfo;
};

/**
* Occurs when a Stream Deck device is connected. See also {@link DeviceDidDisconnect}.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/api/events/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { JsonObject, JsonValue } from "../../common/json";
import type { DidReceiveSettings, TitleParametersDidChange, WillAppear, WillDisappear } from "./action";
import type { DeviceDidConnect, DeviceDidDisconnect } from "./device";
import type { DeviceDidChange, DeviceDidConnect, DeviceDidDisconnect } from "./device";
import type { DialDown, DialRotate, DialUp, TouchTap } from "./encoder";
import type { KeyDown, KeyUp } from "./keypad";
import type {
Expand Down Expand Up @@ -28,7 +28,7 @@ export {
type WillAppear,
type WillDisappear,
} from "./action";
export { type DeviceDidConnect, type DeviceDidDisconnect } from "./device";
export { type DeviceDidChange, type DeviceDidConnect, type DeviceDidDisconnect } from "./device";
export { type DialDown, type DialRotate, type DialUp, type TouchTap } from "./encoder";
export { type KeyDown, type KeyUp } from "./keypad";
export {
Expand Down Expand Up @@ -61,6 +61,7 @@ export type EventIdentifier<TEvent> = {
export type PluginEvent =
| ApplicationDidLaunch
| ApplicationDidTerminate
| DeviceDidChange
| DeviceDidConnect
| DeviceDidDisconnect
| DialDown<JsonObject>
Expand Down
4 changes: 2 additions & 2 deletions src/plugin/__mocks__/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const manifest: Manifest = {
],
SDKVersion: 2,
Software: {
MinimumVersion: "6.5",
MinimumVersion: "7.0",
},
UUID: "com.elgato.test",
Version: "1.0.0",
Expand All @@ -53,7 +53,7 @@ export const manifest: Manifest = {
/**
* Mocked {@link __getSoftwareMinimumVersion}.
*/
export const getSoftwareMinimumVersion = jest.fn().mockReturnValue(new Version("6.5"));
export const getSoftwareMinimumVersion = jest.fn().mockReturnValue(new Version("7.0"));

/**
* Mocked {@link __getManifest}.
Expand Down
Loading
0