├── .gitignore ├── PresentProperties1.png ├── CreateApplication_BAcon.png ├── node-server.html ├── index.js ├── package.json ├── webpack.config.js ├── LICENSE ├── node-server.brs ├── README.md ├── README_BrightAuthor.md └── node-server.bpf /.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /PresentProperties1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brightsign/node.js-starter-project/HEAD/PresentProperties1.png -------------------------------------------------------------------------------- /CreateApplication_BAcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brightsign/node.js-starter-project/HEAD/CreateApplication_BAcon.png -------------------------------------------------------------------------------- /node-server.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

9 | Welcome to BrightSign! 10 |

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | 4 | function main() { 5 | 6 | app.use(express.static('/storage/sd')); 7 | 8 | app.listen(9090, function() { 9 | console.log('Example app listening on port 9090!'); 10 | }); 11 | } 12 | 13 | // exchange below line to 'window.main = main;' if using node-server.html 14 | // as the application entry point. 15 | main(); 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BrightSign-Node.js-Sample", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": {}, 7 | "keywords": [], 8 | "author": "support@brightsign.biz (http://www.brightsign.biz/)", 9 | "license": "MIT", 10 | "devDependencies": { 11 | "@babel/core": "7.13.16", 12 | "@babel/preset-typescript": "7.13.0", 13 | "@types/node": "15.0.1", 14 | "babel-loader": "8.2.2", 15 | "copy-webpack-plugin": "^8.1.1", 16 | "webpack": "^5.36.1", 17 | "webpack-cli": "^4.6.0", 18 | "zip-webpack-plugin": "^4.0.1" 19 | }, 20 | "dependencies": { 21 | "express": "4.17.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const CopyWebpackPlugin = require('copy-webpack-plugin') 3 | const ZipPlugin = require('zip-webpack-plugin'); 4 | 5 | module.exports = { 6 | entry: './index.js', 7 | output: { 8 | publicPath: './', 9 | filename: 'bundle.js', 10 | path: path.resolve(__dirname, 'dist') 11 | }, 12 | 13 | target: 'node', 14 | 15 | resolve: { 16 | extensions: ['.html', '.js'] 17 | }, 18 | externals: { 19 | '@brightsign/screenshot': 'commonjs @brightsign/screenshot' 20 | }, 21 | module: { 22 | rules: [{}] 23 | }, 24 | plugins: [ 25 | new CopyWebpackPlugin({ 26 | patterns: [{ 27 | from: './*.html', 28 | to: '.' 29 | }] 30 | }), 31 | new ZipPlugin({ 32 | filename: 'node-server.zip' 33 | }) 34 | ] 35 | }; 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 BrightSign 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /node-server.brs: -------------------------------------------------------------------------------- 1 | Function Node_Initialize(msgPort As Object, userVariables As Object, bsp as Object) 2 | 3 | print "=== Node_Initialize - entry" 4 | 5 | h = {} 6 | h.version = "1.00.00" 7 | h.msgPort = msgPort 8 | h.userVariables = userVariables 9 | h.bsp = bsp 10 | h.ProcessEvent = Node_ProcessEvent 11 | h.objectName = "Node_object" 12 | 13 | nc = CreateObject("roNetworkConfiguration", 0) 14 | nc.SetHostName("brightsign-sfn-server") 15 | nc.Apply() 16 | 17 | nodePackage = createObject("roBrightPackage", bsp.assetPoolFiles.getPoolFilePath("node-server.zip")) 18 | CreateDirectory("node-server") 19 | nodePackage.Unpack("node-server/") 20 | 21 | url$ = "file:///sd:/node-server/node-server.html" 22 | 23 | htmlRect = CreateObject("roRectangle", 0, 0, 1920, 1080) 24 | is = { port: 2999 } 25 | config = { 26 | nodejs_enabled: true 27 | inspector_server: is 28 | brightsign_js_objects_enabled: true 29 | url: url$ 30 | } 31 | h.htmlWidget = CreateObject("roHtmlWidget", htmlRect, config) 32 | h.htmlWidget.Show() 33 | return h 34 | 35 | End Function 36 | 37 | Function Node_ProcessEvent(event As Object) as boolean 38 | 39 | return false 40 | 41 | End Function 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BrightSign Node.js Sample 2 | 3 | This sample BrightAuthor:connected application shows how to instantiate a node.js server that runs on a BrightSign player. It creates a web server that can serve static files from port 9090.  4 | 5 | This example was created for BrightAuthor:connected. 6 | 7 | ## Prerequisites 8 | * If you don’t have it already, download Nodejs to install Node.js and npm. 9 | * Your computer and BrightSign player must be connected to the internet. 10 | * BrightAuthor:connected should already be downloaded and installed on your computer. 11 | 12 | ## Deploying a Node.js Aerver Application with BrightAuthor:connected 13 | ### Create your Node.js Application 14 | 1. Clone the project or download [ZIP](http://www.github.com/brightsign/node.js-starter-project/archive/master.zip), and then unzip *node.js-starter-project-master.zip*. 15 | 2. If you have not run npm previously, run **npm init** in your terminal to initialize the install. If you wish, you can import other modules with **npm  install** for additional functionality. 16 | 3. Import the node modules you will need your application to function and write your JavaScript code (in this example, the node modules are all included in express and the JavaScript is in index.js). From the *Downloads* folder, run: 17 | ``` 18 | npm install --save express  19 | ``` 20 | 4. Run these Webpack commands to package your node application as a single JavaScript file (see Appendix B: Notes for more details):  21 | ``` 22 | npm install --save-dev webpack webpack-cli copy-webpack-plugin zip-webpack-plugin 23 | npx webpack --mode production 24 | ``` 25 | 26 | ### Create your Application 27 | After running Webpack, follow the steps below to create your application. This example assumes that you have the latest version of BrightAuthor:connected: 28 | 1. In the **Presentation** dropdown menu, select **New Presentation**. 29 | 2. Select **Single Zone > Node.js** as the presentation type. 30 | 3. Enter a presentation name and select the application folder icon under **Node.js**. 31 | 4. In the pop-up window, choose the bundle.js example under the dist folder or include your own JavaScript application. Then choose **Select**: 32 | ![](https://github.com/stmulq/node.js-starter-project/blob/Documentation_updates/CreateApplication_BAcon.png) 33 | 5. In the main window, select **Start**. 34 | 6. Save and publish your presentation. 35 | 36 | If you have a more complex node application, or don't have the latest version of BrightAuthor:connected, you may need to use an alternate method to create your application. See Appendix A for this method. 37 | 38 | ### Display Files from your Webserver  39 | If you have used the unmodified example, you can access the files in your root directory or in your directory folder using the link in a browser. For example: 40 | 41 | http://:9090/filename 42 | 43 | ## Appendix 44 | ### Appendix A: An Alternate Method 45 | If you have a more complex node application, or don't have the latest version of BrightAuthor:connected, you can use these steps to create your application: 46 | 47 | 1. Create an html file or use the **node-server.html** file that is provided in the *node.js-starter-project-master* folder, as the application entry point. 48 | 2. In the **Presentation** dropdown menu, select **New Presentation** and enter a presentation name. 49 | 3. Expand **Presentation Settings** and select **Support Content**. 50 | 4. Under **Script Plugin**, add your plugin or use **node-server.brs** from the example, to enable Node.js in your presentation. 51 | 5. Use the “File Select” icon to add your application zip as an additional file (for example, **dist/node-server.zip**). 52 | 53 | ### Appendix B: Notes 54 | * The  node_modules directory contains a lot of unnecessary files in addition to the code your application needs, and its size can be a problem when you deploy your application to an SD card or publish it to the cloud. [Webpack](https://webpack.js.org), which bundles JavaScript modules to use in browsers, solves this problem. 55 | * An example is included to help you use [BrightSign Javascript objects](http://docs.brightsign.biz/display/DOC/JavaScript+API). See the "externals" section of the webpack.config.js. 56 | * See the BrightSign [Node.js documentation](http://docs.brightsign.biz/display/DOC/Node.js) for more information. 57 | 58 | -------------------------------------------------------------------------------- /README_BrightAuthor.md: -------------------------------------------------------------------------------- 1 | # BrightSign Node.js Sample 2 | This sample BrightAuthor application shows how to instantiate a node.js server that runs on a BrightSign player. It creates a web server that can serve static files from the root folder on port 9090.   3 | 4 | This example was created for BrightAuthor. 5 | 6 | 7 | ## Prerequisites 8 | 9 | * Download [Nodejs](https://nodejs.org/en/download), if you don’t have it already, to install Node.js and npm. 10 | * Your computer and BrightSign player must be connected to the internet. 11 | * BrightAuthor should already be downloaded and installed on your computer. 12 | 13 | 14 | ## Deploying a Node.js server Application with BrightAuthor 15 | 16 | ### Create your Node.js Application  17 | 1. Clone the project or download [ZIP](http://www.github.com/brightsign/node.js-starter-project/archive/master.zip), and then unzip *node.js-starter-project-master.zip*. 18 | 2. If you have not run npm previously, run **npm init** in your terminal to initialize the install. If you wish, you can import other modules using **npm install** for additional functionality. 19 | 3. Create an html file or use the **node-server.html** file that is provided in the *node.js-starter-project-master* folder, as the application entry point. 20 | 4. Import the node modules you will need in your application to function and write your JavaScript code (in this example, the node modules are all included in **express** and the JavaScript is in **index.js**). From the *Downloads* folder, run: 21 | ``` 22 | npm install --save express  23 | ``` 24 | 5. Run these Webpack commands to package your application (see Appendix A: About Webpack for more details):  25 | ``` 26 | npm install --save-dev webpack webpack-cli copy-webpack-plugin zip-webpack-plugin  27 | 28 | npx webpack --mode production  29 | ``` 30 | ### Create your Application in BrightAuthor 31 | 1. Create a plugin, or use **node-server.brs** from the example, to launch your Node.js application. 32 | 2. In the BrightAuthor **Presentation Properties** under **Autorun**, add the script plugin to enable Node.js in your presentation. 33 | ![](https://github.com/stmulq/node.js-starter-project/blob/Documentation_updates/PresentProperties1.png) 34 | 3. Under **Files**, add the **dist/node-server.zip** file from your source directory. 35 | 36 | ### Display Files from your Webserver  37 | If you have used the unmodified example, enter the *http://:9090/filename* in a browser (replace filename and the ip address with your specific information). It should then display the readme.md file.   38 | 39 | ## Appendix 40 | ### Appendix A: About Webpack  41 | The  node_modules directory contains a lot of unnecessary files in addition to the code your application needs, and its size can be a problem when you deploy your application to an SD card or publish it to the cloud. [Webpack](https://webpack.js.org), which bundles JavaScript modules to use in browsers, can solve this problem. 42 | 43 | If you have a node.js application that has an index.html that calls an entry point function called main():  44 | ``` 45 |   46 | ``` 47 | If this function is inline in the html, you will want to move it to a new file, index.js. This file would contain the references to your other JavaScript files, and to the node modules:  48 | ``` 49 | var myutils = require('./utilities'); // My utilities.js  50 | var moment = require('moment'); // A node module     51 | 52 | function main() {    53 | 54 |   myutils.foo();  55 |   moment.now();  56 |   ...  57 | 58 | }  59 | ``` 60 | Your index.html would then need to reference index.js:  61 | ``` 62 | 63 | ``` 64 | To use webpack, attach main() to the window object so that it can be found from index.html (the actual definition gets uglified):  65 | ``` 66 | var myutils = require('./utilities'); // My utilities.js  67 | var moment = require('moment'); // A node module    68 | 69 | function main() {  70 | 71 |   myutils.foo();  72 |   moment.now();  73 |   ...  74 | 75 | }  76 | 77 | window.main = main;  78 | ``` 79 | Change index.html to point to the bundled JavaScript, and to window.main():  80 | ``` 81 |   82 | 83 |   84 | ``` 85 | ### Appendix B: Notes 86 | * An example is included to help you use [BrightSign Javascript objects](http://docs.brightsign.biz/display/DOC/JavaScript+API). See the "externals" section of the webpack.config.js. 87 | * See the BrightSign [Node.js documentation](http://docs.brightsign.biz/display/DOC/Node.js) for more information. 88 | 89 | 90 | -------------------------------------------------------------------------------- /node-server.bpf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | node-server 5 | False 6 | XT1143 7 | 1920x1080x60p 8 | Landscape 9 | HDMI 10 | Standard 11 | True 12 | False 13 | False 14 | 15 | True 16 | False 17 | False 18 | noOverscan 19 | input 20 | input 21 | input 22 | input 23 | input 24 | input 25 | input 26 | input 27 | True 28 | True 29 | True 30 | True 31 | True 32 | True 33 | True 34 | True 35 | 0 36 | 0 37 | 0 38 | 0 39 | 0 40 | 0 41 | 0 42 | 0 43 | 44 | 0 45 | 115200 46 | 8 47 | N 48 | 1 49 | ASCII 50 | CR 51 | CR 52 | False 53 | None 54 | 55 | 56 | 1 57 | 115200 58 | 8 59 | N 60 | 1 61 | ASCII 62 | CR 63 | CR 64 | False 65 | None 66 | 67 | 68 | 2 69 | 115200 70 | 8 71 | N 72 | 1 73 | ASCII 74 | CR 75 | CR 76 | False 77 | None 78 | 79 | 80 | 3 81 | 115200 82 | 8 83 | N 84 | 1 85 | ASCII 86 | CR 87 | CR 88 | False 89 | None 90 | 91 | 92 | 4 93 | 115200 94 | 8 95 | N 96 | 1 97 | ASCII 98 | CR 99 | CR 100 | False 101 | None 102 | 103 | 104 | 5 105 | 115200 106 | 8 107 | N 108 | 1 109 | ASCII 110 | CR 111 | CR 112 | False 113 | None 114 | 115 | 116 | 6 117 | 115200 118 | 8 119 | N 120 | 1 121 | ASCII 122 | CR 123 | CR 124 | False 125 | None 126 | 127 | 128 | 7 129 | 115200 130 | 8 131 | N 132 | 1 133 | ASCII 134 | CR 135 | CR 136 | False 137 | None 138 | 139 | IPAddress 140 | 255.255.255.255 141 | 5000 142 | 5000 143 | false 144 | auto 145 | English 146 | eng 147 | MixedAudioPCMOnly 148 | 0 149 | 100 150 | 0 151 | 100 152 | 0 153 | 100 154 | 0 155 | 100 156 | 0 157 | 100 158 | 0 159 | 100 160 | 0 161 | 100 162 | 0 163 | 100 164 | 0 165 | 100 166 | 0 167 | 100 168 | 0 169 | 100 170 | 0 171 | 100 172 | 0 173 | 100 174 | 0 175 | 100 176 | 0 177 | 100 178 | 0 179 | 100 180 | 0 181 | 100 182 | 0 183 | 100 184 | False 185 | 30 186 | False 187 | False 188 | 300 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | Node 198 | \\vmware-host\Shared Folders\Downloads\Customers\fwi\nodejs-starter-kit\node-server.brs 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | Z:\git\bs\github\node.js-starter-project\dist\node-server.zip 210 | Z:\git\bs\github\node.js-starter-project\www.zip 211 | 212 | Z:\git\bs\github\node.js-starter-project 213 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 214 | 215 | 216 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 217 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 218 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 219 | \\vmware-host\Shared Folders\Downloads\Customers\fwi\nodejs-starter-kit 220 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 221 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 222 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 223 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 224 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 225 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 226 | \\vmware-host\Shared Folders\Documents\BA Presentations\nodejs-all-hands-tips-n-tricks 227 | 228 | Back 229 | False 230 | 231 | 232 | 233 | Video or Images 234 | 0 235 | 0 236 | 1920 237 | 1080 238 | VideoOrImages 239 | 1 240 | 1 241 | 0 242 | 0 243 | 244 | Letterboxed and Centered 245 | Analog Audio 246 | Multichannel Surround 247 | Audio-1 248 | None 249 | None 250 | None 251 | PCM 252 | None 253 | None 254 | None 255 | None 256 | None 257 | None 258 | None 259 | None 260 | None 261 | None 262 | None 263 | None 264 | None 265 | None 266 | None 267 | Stereo 268 | 100 269 | 100 270 | 0 271 | 100 272 | S-Video 273 | NTSC-M 274 | 128 275 | 64 276 | 64 277 | 0 278 | True 279 | False 280 | _NotApplicable 281 | Scale to Fit 282 | 283 | 284 | Playlist 0 285 | interactive 286 | 287 | NodeJS Application 288 | 289 | NodeJS Application 290 | 251 291 | 80 292 | 114 293 | 97 294 | 0 295 | 296 | NodeJS Application 297 | 298 | NodeJS Application is Running 299 | 300 | 1 301 | 5 302 | 0 303 | left 304 | 2 305 | 306 | 307 | 308 | 309 | System 310 | 0 311 | 312 | False 313 | 427 314 | 469 315 | 960 316 | 64 317 | 1 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | --------------------------------------------------------------------------------