roElectron
This BrightScript object allows users to run their own Electron applications on BrightSign players using the player's Electron runtime.
All BrightSign JavaScript objects are available to use with Electron, and BrightSign mechanisms allow communication between JavaScript (Electron main processes) and BrightScript (BrightSign processes).
This object is only available on Series 5 and 6 players.
Object Creation
roElectron is instantiated with a filename (the Electron app entry point) and optional parameters.
electron = CreateObject("roElectron", "file://sd://main.js", {
app_name: "MyApp",
message_port: my_message_port,
arguments: ["arg1", "arg2"]
})You can also pass an optional node_arguments parameter, which provides arguments to the Node.js runtime itself (as opposed to arguments, which provides arguments to the Electron application being run):
electron = CreateObject("roElectron", "file://sd://main.js", {
app_name: "MyApp",
message_port: my_message_port,
node_arguments: ["arg"],
arguments: ["arg1", "arg2"]
})- app_namerequired: The name of the application, used as the name of its user data directory (<root>/.home/.config/<app_name>). It must be a single directory name, so it cannot be empty, . or .., or contain / or \.
- message_port optional: Allows communication with JavaScript applications
- arguments optional: Passes arguments to the Electron application
- node_arguments optional: Passes arguments to the executable before the filename, for example, to enable the remote inspector. node_arguments can take multiple arguments.
- env_vars optional: Passes environment variables (supplied as an associative array) to the Electron application. Note that environment variable names are case-sensitive, but roAssociativeArray is case-insensitive by default and the BrightScript literal syntax for associative arrays forces all key names to lower case. To ensure correct behavior, call SetModeCaseSensitive() and use the AddReplace() method to add variables to the array, or use the following approach:
a = {}
a.SetModeCaseSensitive()
a["KeY"] = 1
a["key"] = 2
print a ' returns both key and KeYnode_arguments are arguments that come before the filename, while arguments come after the filename.
PostJsMessage ()
PostJsMessage(data as AssociativeArray) As Boolean
Posts a collection of key:value pairs to the BrightScript MessagePort JavaScript class running in the Electron app. This method takes an associative array but doesn't support nested associative arrays. The behavior is identical to roNodeJs.PostJsMessage().
Events
See roElectronEvent for information about roElectron events.
Packaging Electron Apps for roElectron
See Packaging/Debugging Electron Apps for roElectron for instructions on how to package an Electron App for Linux ARM64 so it can be used with roElectron and roElectronEvent.