tlsd 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tlsd",
3
- "version": "2.9.0",
3
+ "version": "2.10.0",
4
4
  "description": "A server for web app prototyping with HTTPS and Websockets",
5
5
  "main": "tlsd.js",
6
6
  "bin": {
@@ -118,8 +118,9 @@
118
118
  var socket = new WebSocket( ( loc.protocol == "http:" ? "ws:" : "wss:" ) + "//" + loc.host + path )
119
119
 
120
120
  socket.onerror = function( evt ) {
121
- DBG( "error:", evt.data );
122
- cb_ctrl( "error", evt.data );
121
+ evt.preventDefault();
122
+ DBG( "error:", evt );
123
+ cb_ctrl( "error", evt );
123
124
  }
124
125
 
125
126
  socket.onclose = function() {
@@ -9,6 +9,8 @@
9
9
  document.write( Date() );
10
10
  </script>
11
11
 
12
+ <div id=connect_status>?</div>
13
+
12
14
  <script src="/rpc/rpc.js"></script>
13
15
 
14
16
  <script>
@@ -32,9 +34,17 @@
32
34
 
33
35
  RPC.on_connect = function( evt ) {
34
36
  // RPC is ready to be used
35
- RPC( { action: "hello" }, console.log, alert )
37
+ RPC( { action: "hello" }, msg => {
38
+ document.getElementById( "connect_status" ).innerText = msg;
39
+ } );
36
40
  }
37
41
 
42
+ RPC.on_disconnect = function( evt ) {
43
+ // The websocket connection ws lost for some reason
44
+ // The RPC code will reconnect automatically
45
+ document.getElementById( "connect_status" ).innerText = "[ DISCONNECTED ]";
46
+ }
47
+
38
48
  </script>
39
49
 
40
50
  </body>
@@ -9,3 +9,7 @@ h1
9
9
  a
10
10
  font-style: italic
11
11
 
12
+ #connect_status
13
+ margin: 2em 0
14
+ font-size: 200%
15
+ font-size: 100%
@@ -9,4 +9,10 @@ h1 {
9
9
  }
10
10
  h1 a {
11
11
  font-style: italic;
12
+ }
13
+
14
+ #connect_status {
15
+ margin: 2em 0;
16
+ font-size: 200%;
17
+ font-size: 100%;
12
18
  }
package/tlsd.js CHANGED
@@ -43,6 +43,17 @@ const next_seq = function() {
43
43
  // Tries to load the rpc handler module from root and if successful, passes the msg to it
44
44
  const rpc_handler = function( root, msg, xport, _okay, _fail ) {
45
45
 
46
+ let ll = toInt( msg.log_level );
47
+ if( ll > 0 ) {
48
+ D( "Setting log level to "+ll );
49
+ log_level = ll;
50
+ L( log_level );
51
+ setTimeout( () => {
52
+ ll = process.env.VERBOSITY;
53
+ D( "Reverting log level to "+ll );
54
+ }, 15 * 1000 );
55
+ }
56
+
46
57
  V( "RPC " + o2j( msg ).abbr( 70 ) );
47
58
  D( "----------->>> "+xport+" "+o2j( msg, null, 2 ) );
48
59
 
@@ -306,8 +317,8 @@ const ws_attach = function( httpServer, msg_handler ) {
306
317
 
307
318
 
308
319
 
320
+ /*
309
321
  const build_sass = function( path ) {
310
- //D( "_________ auto_build sass " + path );
311
322
  const sass = require( "sass" );
312
323
  const result = sass.compile( path );
313
324
  fs.writeFileSync( path + ".css", result.css, "utf8" );
@@ -321,7 +332,6 @@ const auto_builders = [
321
332
  const auto_build = function( paths ) {
322
333
 
323
334
  for( let path of paths ) {
324
- // D( "___ path? " + path );
325
335
  for( const bldr of auto_builders ) {
326
336
  if( bldr[ 0 ].test( path ) ) {
327
337
  bldr[ 1 ]( path );
@@ -381,6 +391,7 @@ const enable_fs_watch = function( root ) {
381
391
  } );
382
392
 
383
393
  };
394
+ */
384
395
 
385
396
 
386
397
  // -----------------------
@@ -455,7 +466,7 @@ if( argv.length == 5 ) {
455
466
  } );
456
467
 
457
468
  // enable the file system watch, which handles hot-reload and auto-build
458
- enable_fs_watch( SITE_ROOT );
469
+ // enable_fs_watch( SITE_ROOT );
459
470
 
460
471
  I( "Listening on " + PORT + " & serving from " + SITE_ROOT );
461
472