@rip-lang/server 1.3.40 → 1.3.43

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/server.rip +9 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/server",
3
- "version": "1.3.40",
3
+ "version": "1.3.43",
4
4
  "description": "Pure Rip web framework and application server",
5
5
  "type": "module",
6
6
  "main": "api.rip",
@@ -45,7 +45,7 @@
45
45
  "author": "Steve Shreeve <steve.shreeve@gmail.com>",
46
46
  "license": "MIT",
47
47
  "dependencies": {
48
- "rip-lang": ">=3.13.57"
48
+ "rip-lang": ">=3.13.60"
49
49
  },
50
50
  "files": [
51
51
  "api.rip",
package/server.rip CHANGED
@@ -588,21 +588,21 @@ class Manager
588
588
  timer = null
589
589
  pending = null
590
590
  watchers = []
591
- broadcast = (type = 'reload') =>
592
- pending = if type is 'reload' or pending is 'reload' then 'reload' else type
591
+ broadcast = (type = 'page') =>
592
+ pending = if type is 'page' or pending is 'page' then 'page' else 'styles'
593
593
  clearTimeout(timer) if timer
594
594
  timer = setTimeout =>
595
595
  timer = null
596
596
  @server?.broadcastChange(prefix, pending)
597
597
  pending = null
598
- , 100
598
+ , 300
599
599
  for dir in dirs
600
600
  try
601
601
  w = watch dir, { recursive: true }, (event, filename) ->
602
602
  if filename?.endsWith('.rip') or filename?.endsWith('.html')
603
- broadcast('reload')
603
+ broadcast('page')
604
604
  else if filename?.endsWith('.css')
605
- broadcast('css')
605
+ broadcast('styles')
606
606
  watchers.push(w)
607
607
  catch e
608
608
  rel = dir.replace(process.cwd() + '/', '')
@@ -890,8 +890,8 @@ class Server
890
890
  client = null
891
891
  new Response new ReadableStream(
892
892
  start: (controller) ->
893
- send = (event) ->
894
- try controller.enqueue encoder.encode("event: #{event}\ndata:\n\n")
893
+ send = (type) ->
894
+ try controller.enqueue encoder.encode("event: #{if type is 'connected' then 'connected' else 'reload'}\ndata: #{type}\n\n")
895
895
  catch then null
896
896
  client = { send }
897
897
  group.sseClients.add(client)
@@ -904,10 +904,11 @@ class Server
904
904
  'Cache-Control': 'no-cache'
905
905
  'Connection': 'keep-alive'
906
906
 
907
- broadcastChange: (prefix, type = 'reload') ->
907
+ broadcastChange: (prefix, type = 'page') ->
908
908
  group = @watchGroups.get(prefix)
909
909
  return unless group
910
910
  dead = []
911
+ console.log "rip-server: broadcast #{type} to #{group.sseClients.size} clients"
911
912
  for client as group.sseClients
912
913
  try client.send(type)
913
914
  catch then dead.push(client)