diff --git a/README.md b/README.md index 59f7426..7d26613 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Environment variables (command argument/option): ### assets -Roku ECP - `query/r2d2-bitmaps` +Roku ECP - GET `query/r2d2-bitmaps` Returns a list of the assets that have been loaded into texture memory and the amount of used, available, and maximum memory on your device (in bytes). @@ -82,10 +82,10 @@ Environment variables (command argument/option): Roku ECP: -* `query/fwbeacons` -* `query/fwbeacons/track` -* `query/fwbeacons/track/` -* `query/fwbeacons/untrack` +* GET `query/fwbeacons` +* POST `fwbeacons/track` +* POST `fwbeacons/track/` +* POST `fwbeacons/untrack` Tracks channel and media lifecycle events for a specific channel. To use these commands, the device must have developer mode enabled. @@ -104,7 +104,7 @@ Devices that are keyed may monitor channels from the Roku Channel Store that are * **untrack** - Disables tracking of channel and media lifecycle events (if enabled) and discards all queued events. ```bash -roku beacons [channelId] [command = 'log'] [--ip ] +roku beacons [command = 'log'] [channelId] [--ip ] ``` * **channelId** - channel id for a sideloaded channel or production/beta channel linked to the Roku developer's account @@ -118,7 +118,7 @@ Environment variables (command argument/option): ### device -Roku ECP - `query/device-info` +Roku ECP - GET `query/device-info` Retrieves device information similar to that returned by roDeviceInfo. @@ -135,7 +135,7 @@ Environment variables (command argument/option): ### fps -Roku ECP - `query/graphics-frame-rate` +Roku ECP - GET `query/graphics-frame-rate` Returns the recent number of rendered graphics frames per seconds (this value is separate from the video frame rate). Developer mode must be enabled to use this command. @@ -152,7 +152,7 @@ Environment variables (command argument/option): ### icon -Roku ECP - `query/icon/` +Roku ECP - GET `query/icon/` Downloads under iconPath an icon file corresponding to the application identified by channelId. The binary data with an identifying MIME-type header is returned. @@ -171,13 +171,34 @@ Environment variables (command argument/option): * **ICON_PATH** (iconPath) * **ROKU_IP** (ip) +### input + +Roku ECP - POST `input?` + +Sends custom events to the current application. +It takes a user-defined list of name-value pairs sent as query string URI parameters. +Eg. `contentId=contentId1234&mediaType=episode` +The external control server places these name-value pairs into an associative array, +and passes them directly through to the currently executing channel script +using a Message Port attached to a created roInput object. + +```bash +roku input [--ip ] +``` + +* **ip** - IP of the Roku device + +Environment variables (command argument/option): + +* **ROKU_IP** (ip) + ### key Roku ECP: -* `keydown/` -* `keyup/` -* `keypress/` +* POST `keydown/` +* POST `keyup/` +* POST `keypress/` Sends key press/down/up @@ -225,9 +246,9 @@ Environment variables (command argument/option): Roku ECP: -* `query/sgnodes/all` -* `query/sgnodes/roots` -* `query/sgnodes/nodes?node-id=nodeId` +* GET `query/sgnodes/all` +* GET `query/sgnodes/roots` +* GET `query/sgnodes/nodes?node-id=nodeId` Returns all/root or finds some rendered nodes. @@ -286,8 +307,8 @@ Environment variables (command argument/option): Roku ECP: -* `query/chanperf` -* `query/chanperf/?duration-seconds=` +* GET `query/chanperf` +* GET `query/chanperf/?duration-seconds=` Returns the current memory and CPU utilization of the channel running in the foreground (RAM usage is reported bytes). The foreground channel may either be a sideloaded channel or a channel from the Roku Channel Store. @@ -314,7 +335,7 @@ Environment variables (command argument/option): ### player -Roku ECP - `query/media-player` +Roku ECP - GET `query/media-player` Returns a child element named 'player' that identifies the media player state. The information returned includes the current stream segment and position of the content being played, @@ -333,7 +354,7 @@ Environment variables (command argument/option): ### registry -Roku ECP - `query/registry/` +Roku ECP - GET `query/registry/` Lists the entries in the device registry for a sideloaded channel or production/beta channel linked to the Roku developer's account. The channel ID must be provided; for sideloaded channels, use "dev" as the channelId. @@ -384,9 +405,9 @@ Environment variables (command argument/option): Roku ECP: -* `query/sgrendezvous` -* `query/sgrendezvous/track` -* `query/sgrendezvous/untrack` +* GET `query/sgrendezvous` +* POST `sgrendezvous/track` +* POST `sgrendezvous/untrack` Lists the node rendezvous events for a sideloaded channel or production/beta channel linked to the Roku developer's account. @@ -402,7 +423,7 @@ Tracking a different channel clears any queued rendezvous events. * **untrack** - Stops the tracking of rendezvous events. ```bash -roku rendezvous [channelId] [command = 'log'] [--ip ] +roku rendezvous [command = 'log'] [channelId] [--ip ] ``` * **channelId** - channel id for a sideloaded channel or production/beta channel linked to the Roku developer's account diff --git a/src/cli/arguments/inputQuery.ts b/src/cli/arguments/inputQuery.ts new file mode 100644 index 0000000..9527a46 --- /dev/null +++ b/src/cli/arguments/inputQuery.ts @@ -0,0 +1,9 @@ +import { ParsedArgumentsObject } from '@caporal/core'; + +export function getInputQueryArgumentDefinition(): [string, string] { + return ['', 'Input query params eg. contentID=contendId123&mediaType=episode']; +} + +export function getInputQuery(args: ParsedArgumentsObject): string { + return args.inputQuery as string; +} diff --git a/src/cli/commands/input.ts b/src/cli/commands/input.ts new file mode 100644 index 0000000..4d594d5 --- /dev/null +++ b/src/cli/commands/input.ts @@ -0,0 +1,15 @@ +import type { CreateCommandParameters, Command } from '@caporal/core'; +import { envVariables } from '../../env/args'; +import input from '../../requests/input'; +import { getInputQuery, getInputQueryArgumentDefinition } from '../arguments/inputQuery'; +import { getRokuIP, getRokuIPOptionDefinition } from '../options/rokuIP'; + +export default function ({ createCommand }: CreateCommandParameters): Command { + return createCommand('Sends custom events to the current application.') + .argument(...getInputQueryArgumentDefinition()) + .option(...getRokuIPOptionDefinition()) + .action(async ({ args, options }) => input({ + query: getInputQuery(args) || '', + rokuIP: getRokuIP(options) || envVariables.ROKU_IP || '', + })); +} diff --git a/src/cli/commands/nodes.ts b/src/cli/commands/nodes.ts index d5552d2..89cf319 100644 --- a/src/cli/commands/nodes.ts +++ b/src/cli/commands/nodes.ts @@ -15,7 +15,7 @@ export default function ({ createCommand }: CreateCommandParameters): Command { .option(...getRokuIPOptionDefinition()) .action(async ({ args, options }) => { const _sgNodes = await sgNodes({ - nodeId: getNodeId(options), + nodeId: getNodeId(args), rokuIP: getRokuIP(options) || envVariables.ROKU_IP || '', type: getType(args), }); diff --git a/src/index.ts b/src/index.ts index a56a9ce..17dd106 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,7 +46,6 @@ export { DownloadScreenshotOptions, GraphicsFrameRateOptions, InputOptions, - InputType, InstalledAppsOptions, KeyOptions, LaunchOptions, diff --git a/src/requests/index.ts b/src/requests/index.ts index 0dcc47c..25f84b2 100644 --- a/src/requests/index.ts +++ b/src/requests/index.ts @@ -7,7 +7,7 @@ export { default as downloadIcon, DownloadIconOptions } from './downloadIcon'; export { default as downloadPackage, DownloadPackageOptions } from './downloadPackage'; export { default as downloadScreenshot, DownloadScreenshotOptions } from './downloadScreenshot'; export { default as graphicsFrameRate, GraphicsFrameRateOptions } from './graphicsFrameRate'; -export { default as input, InputOptions, InputType } from './input'; +export { default as input, InputOptions } from './input'; export { default as installedApps, InstalledAppsOptions } from './installedApps'; export { default as keyDown, KeyOptions } from './keyDown'; export { default as keyPress } from './keyPress'; diff --git a/src/requests/input.ts b/src/requests/input.ts index 0111885..3a9d38c 100644 --- a/src/requests/input.ts +++ b/src/requests/input.ts @@ -3,17 +3,13 @@ import { RequestMethod } from '../utils/RequestMethod.enum'; import { RokuPort } from '../utils/RokuPort.enum'; import RokuRequest from '../utils/RokuRequest'; -export type InputType = { [key: string]: string }; - export type InputOptions = { - input: InputType; + query: string; rokuIP?: string; }; export default (options: InputOptions) => { - const inputEntries = Object.entries(options.input); - const query = inputEntries.map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&'); - const path = `/input?${query}`; + const path = `/input?${options.query}`; return new RokuRequest({ method: RequestMethod.POST,