@rip-lang/server 1.2.3 → 1.2.5
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 +1 -1
- package/server.rip +12 -6
package/package.json
CHANGED
package/server.rip
CHANGED
|
@@ -576,17 +576,23 @@ class Manager
|
|
|
576
576
|
watchDirs: (prefix, dirs) ->
|
|
577
577
|
return if @appWatchers.has(prefix)
|
|
578
578
|
timer = null
|
|
579
|
+
pending = null
|
|
579
580
|
watchers = []
|
|
580
|
-
broadcast = =>
|
|
581
|
+
broadcast = (type = 'reload') =>
|
|
582
|
+
pending = if type is 'reload' or pending is 'reload' then 'reload' else type
|
|
581
583
|
clearTimeout(timer) if timer
|
|
582
584
|
timer = setTimeout =>
|
|
583
585
|
timer = null
|
|
584
|
-
@server?.broadcastChange(prefix)
|
|
586
|
+
@server?.broadcastChange(prefix, pending)
|
|
587
|
+
pending = null
|
|
585
588
|
, 100
|
|
586
589
|
for dir in dirs
|
|
587
590
|
try
|
|
588
591
|
w = watch dir, { recursive: true }, (event, filename) ->
|
|
589
|
-
|
|
592
|
+
if filename?.endsWith('.rip')
|
|
593
|
+
broadcast('reload')
|
|
594
|
+
else if filename?.endsWith('.css')
|
|
595
|
+
broadcast('css')
|
|
590
596
|
watchers.push(w)
|
|
591
597
|
catch e
|
|
592
598
|
console.warn "rip-server: watch failed for #{dir}: #{e.message}"
|
|
@@ -894,12 +900,12 @@ class Server
|
|
|
894
900
|
'Cache-Control': 'no-cache'
|
|
895
901
|
'Connection': 'keep-alive'
|
|
896
902
|
|
|
897
|
-
broadcastChange: (prefix) ->
|
|
903
|
+
broadcastChange: (prefix, type = 'reload') ->
|
|
898
904
|
group = @watchGroups.get(prefix)
|
|
899
905
|
return unless group
|
|
900
906
|
dead = []
|
|
901
907
|
for client as group.sseClients
|
|
902
|
-
try client.send(
|
|
908
|
+
try client.send(type)
|
|
903
909
|
catch then dead.push(client)
|
|
904
910
|
group.sseClients.delete(c) for c in dead
|
|
905
911
|
|
|
@@ -975,7 +981,7 @@ class Server
|
|
|
975
981
|
readTimeoutMs = @flags.readTimeoutMs
|
|
976
982
|
|
|
977
983
|
try
|
|
978
|
-
fetchPromise = fetch(forwardUrl, { method: req.method, headers: req.headers, body: req.body, unix: socketPath })
|
|
984
|
+
fetchPromise = fetch(forwardUrl, { method: req.method, headers: req.headers, body: req.body, unix: socketPath, decompress: false })
|
|
979
985
|
readGuard = new Promise (_, rej) ->
|
|
980
986
|
setTimeout (-> rej(new Error('Upstream timeout'))), readTimeoutMs
|
|
981
987
|
res = Promise.race!([fetchPromise, readGuard])
|