Comparing version 2.0.1 to 2.1.0
@@ -0,1 +1,6 @@ | ||
2.1.0 / 2017-07-25 | ||
------------------ | ||
* Added the ability to have the WebSocket server start wait. (For more information read about the `webSocketServerWaitStart` [parameter](README.md#parameters)) See: https://github.com/alallier/reload/pull/130 | ||
2.0.1 / 2017-07-20 | ||
@@ -2,0 +7,0 @@ ------------------ |
@@ -11,2 +11,3 @@ module.exports = function reload (app, opts, server) { | ||
var port | ||
var webSocketServerWaitStart | ||
@@ -43,4 +44,5 @@ // Application variables | ||
port = opts.port || 9856 | ||
webSocketServerWaitStart = opts.webSocketServerWaitStart | ||
route = opts.route | ||
route = opts.route | ||
if (route) { | ||
@@ -95,16 +97,25 @@ // If reload.js is found in the route option strip it. We will concat it for user to ensure no case errors or order problems. | ||
// Websocket server setup | ||
// Use custom user specified port | ||
if (socketPortSpecified) { | ||
wss = new WebSocketServer({ port: httpServerOrPort }) | ||
} else { // Attach to server, using server's port. Kept here to support legacy arguments. | ||
wss = new WebSocketServer({ server: httpServerOrPort }) | ||
if (!webSocketServerWaitStart) { | ||
startWebSocketServer() | ||
} | ||
wss.on('connection', (ws) => { | ||
// Websocket server setup | ||
function startWebSocketServer () { | ||
if (verboseLogging) { | ||
console.log('Reload client connected to server') | ||
console.log('Starting WebSocket Server') | ||
} | ||
}) | ||
if (socketPortSpecified) { // Use custom user specified port | ||
wss = new WebSocketServer({ port: httpServerOrPort }) | ||
} else { // Attach to server, using server's port. Kept here to support legacy arguments. | ||
wss = new WebSocketServer({ server: httpServerOrPort }) | ||
} | ||
wss.on('connection', (ws) => { | ||
if (verboseLogging) { | ||
console.log('Reload client connected to server') | ||
} | ||
}) | ||
} | ||
function sendMessage (message) { | ||
@@ -125,4 +136,9 @@ if (verboseLogging) { | ||
sendMessage('reload') | ||
}, | ||
'startWebSocketServer': function () { | ||
if (webSocketServerWaitStart) { | ||
startWebSocketServer() | ||
} | ||
} | ||
} | ||
} |
{ | ||
"name": "reload", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Node.js module to refresh and reload your code in your browser when your code changes. No browser plugins required.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -150,7 +150,8 @@ reload | ||
| Parameter Name | Type | Description | Optional | Default | | ||
|----------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|---------| | ||
| port | number | Port to run reload on. | ✓ | `9856` | | ||
| route | string | Route that reload should use to serve the client side script file. Changing the route will require the script tag URL to change. Reload will always strip any occurrence of reload.js and append reload.js for you. This is to ensure case, order, and use of / is correct. For example specifying newRoutePath as the route will give reload a route of newRoutePath/reload.js. (Recommend not modifying). | ✓ | `reload` | | ||
| verbose | boolean | If set to true, will show logging on the server and client side. | ✓ | `false` | | ||
| Parameter Name | Type | Description | Optional | Default | | ||
|--------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|----------| | ||
| port | number | Port to run reload on. | ✓ | `9856` | | ||
| webSocketServerWaitStart | boolean | When enabled will delay starting and opening WebSocket server when requiring reload. After enabling use the `startWebSocketServer` function returned in the object provided by the API to start the WebSocket. **_Note_**: Failing to call the returned function with this option enabled will cause reload not to work. See [return API](Returns) for more information | ✓ | `false` | | ||
| route | string | Route that reload should use to serve the client side script file. Changing the route will require the script tag URL to change. Reload will always strip any occurrence of reload.js and append reload.js for you. This is to ensure case, order, and use of / is correct. For example specifying newRoutePath as the route will give reload a route of newRoutePath/reload.js. (Recommend not modifying). | ✓ | `reload` | | ||
| verbose | boolean | If set to true, will show logging on the server and client side. | ✓ | `false` | | ||
@@ -171,5 +172,6 @@ ##### Upgrading to version 2 | ||
| Name | Type | Description | | ||
|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| reload | function | A function that when called reloads all connected clients. For more information see [manually firing server-side reload events](#manually-firing-server-side-reload-events).| | ||
| Name | Type | Description | | ||
|----------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| reload | function | A function that when called reloads all connected clients. For more information see [manually firing server-side reload events](#manually-firing-server-side-reload-events). | | ||
| startWebSocketServer | function | Starts and opens the WebSocket server required for reload. Only active when using the optional parameter `webSocketServerWaitStart`. Read the [parameters](#table-of-options-for-reload-opts-parameter) for more information | | ||
@@ -176,0 +178,0 @@ Using reload as a command line application |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
37946
300
229
2