@rip-lang/server 1.1.12 → 1.1.14
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 +7 -21
package/package.json
CHANGED
package/server.rip
CHANGED
|
@@ -746,7 +746,7 @@ class Server
|
|
|
746
746
|
port = p
|
|
747
747
|
while port < p + 100
|
|
748
748
|
try
|
|
749
|
-
return Bun.serve(Object.assign({ port, idleTimeout:
|
|
749
|
+
return Bun.serve(Object.assign({ port, idleTimeout: 255, fetch: fetchFn }, opts))
|
|
750
750
|
catch e
|
|
751
751
|
throw e unless e?.code is 'EADDRINUSE'
|
|
752
752
|
port++
|
|
@@ -755,7 +755,7 @@ class Server
|
|
|
755
755
|
if httpOnly
|
|
756
756
|
if @flags.httpPort is 0
|
|
757
757
|
try
|
|
758
|
-
@server = Bun.serve({ port: 80, idleTimeout:
|
|
758
|
+
@server = Bun.serve({ port: 80, idleTimeout: 255, fetch: fetchFn })
|
|
759
759
|
catch e
|
|
760
760
|
throw e unless e?.code in ['EADDRINUSE', 'EACCES']
|
|
761
761
|
@server = startOnPort(5700)
|
|
@@ -767,7 +767,7 @@ class Server
|
|
|
767
767
|
|
|
768
768
|
if not @flags.httpsPort or @flags.httpsPort is 0
|
|
769
769
|
try
|
|
770
|
-
@httpsServer = Bun.serve({ port: 443, idleTimeout:
|
|
770
|
+
@httpsServer = Bun.serve({ port: 443, idleTimeout: 255, tls, fetch: fetchFn })
|
|
771
771
|
catch e
|
|
772
772
|
throw e unless e?.code in ['EADDRINUSE', 'EACCES']
|
|
773
773
|
@httpsServer = startOnPort(5700, { tls })
|
|
@@ -872,18 +872,6 @@ class Server
|
|
|
872
872
|
registerWatch: (prefix) ->
|
|
873
873
|
return if @watchGroups.has(prefix)
|
|
874
874
|
@watchGroups.set prefix, { sseClients: new Set() }
|
|
875
|
-
@startHeartbeat()
|
|
876
|
-
|
|
877
|
-
startHeartbeat: ->
|
|
878
|
-
return if @_heartbeat
|
|
879
|
-
@_heartbeat = setInterval =>
|
|
880
|
-
for [prefix, group] as @watchGroups
|
|
881
|
-
dead = []
|
|
882
|
-
for client as group.sseClients
|
|
883
|
-
try client.ping()
|
|
884
|
-
catch then dead.push(client)
|
|
885
|
-
group.sseClients.delete(c) for c in dead
|
|
886
|
-
, 5000
|
|
887
875
|
|
|
888
876
|
handleWatch: (prefix) ->
|
|
889
877
|
group = @watchGroups.get(prefix)
|
|
@@ -892,14 +880,12 @@ class Server
|
|
|
892
880
|
client = null
|
|
893
881
|
new Response new ReadableStream(
|
|
894
882
|
start: (controller) ->
|
|
895
|
-
|
|
896
|
-
try controller.enqueue encoder.encode(
|
|
883
|
+
send = (event) ->
|
|
884
|
+
try controller.enqueue encoder.encode("event: #{event}\n\n")
|
|
897
885
|
catch then null
|
|
898
|
-
client =
|
|
899
|
-
send: (event) -> write "event: #{event}\n\n"
|
|
900
|
-
ping: -> write ":\n\n"
|
|
886
|
+
client = { send }
|
|
901
887
|
group.sseClients.add(client)
|
|
902
|
-
|
|
888
|
+
send('connected')
|
|
903
889
|
cancel: ->
|
|
904
890
|
group.sseClients.delete(client) if client
|
|
905
891
|
),
|