@jsenv/server 16.0.6 → 16.0.7

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.
@@ -121,6 +121,9 @@
121
121
  };
122
122
 
123
123
  const initialWebSocket = await connect();
124
+ if (!initialWebSocket) {
125
+ return;
126
+ }
124
127
  initialWebSocket.onclose = async () => {
125
128
  console.info("connection to server lost, trying to reconnect");
126
129
  const retry = async () => {
@@ -165,12 +168,16 @@
165
168
  );
166
169
  }
167
170
 
171
+ const websocketEndpoint =
172
+ document.currentScript.getAttribute("data-ws-endpoint") ||
173
+ "/.internal/alive.websocket";
174
+
168
175
  const jsenvAutoreloadOnServerRestartElement =
169
176
  new JsenvAutoreloadOnServerRestart({
170
177
  url: (() => {
171
178
  const websocketScheme =
172
179
  self.location.protocol === "https:" ? "wss" : "ws";
173
- const websocketUrl = `${websocketScheme}://${self.location.host}/.internal/alive.websocket`;
180
+ const websocketUrl = `${websocketScheme}://${self.location.host}${websocketEndpoint}`;
174
181
  return websocketUrl;
175
182
  })(),
176
183
  });
@@ -278,6 +278,9 @@
278
278
  };
279
279
 
280
280
  const initialWebSocket = await connect();
281
+ if (!initialWebSocket) {
282
+ return;
283
+ }
281
284
  initialWebSocket.onclose = async () => {
282
285
  console.info("connection to server lost, trying to reconnect");
283
286
  const retry = async () => {
@@ -322,12 +325,16 @@
322
325
  );
323
326
  }
324
327
 
328
+ const websocketEndpoint =
329
+ document.currentScript.getAttribute("data-ws-endpoint") ||
330
+ "/.internal/alive.websocket";
331
+
325
332
  const jsenvAutoreloadOnServerRestartElement =
326
333
  new JsenvAutoreloadOnServerRestart({
327
334
  url: (() => {
328
335
  const websocketScheme =
329
336
  self.location.protocol === "https:" ? "wss" : "ws";
330
- const websocketUrl = `${websocketScheme}://${self.location.host}/.internal/alive.websocket`;
337
+ const websocketUrl = `${websocketScheme}://${self.location.host}${websocketEndpoint}`;
331
338
  return websocketUrl;
332
339
  })(),
333
340
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/server",
3
- "version": "16.0.6",
3
+ "version": "16.0.7",
4
4
  "description": "A modern Node.js HTTP server with declarative routing, content negotiation, and WebSocket support",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -53,6 +53,9 @@ class JsenvAutoreloadOnServerRestart extends HTMLElement {
53
53
  };
54
54
 
55
55
  const initialWebSocket = await connect();
56
+ if (!initialWebSocket) {
57
+ return;
58
+ }
56
59
  initialWebSocket.onclose = async () => {
57
60
  console.info("connection to server lost, trying to reconnect");
58
61
  const retry = async () => {
@@ -97,12 +100,16 @@ if (!customElements.get("jsenv-autoreload-on-server-restart")) {
97
100
  );
98
101
  }
99
102
 
103
+ const websocketEndpoint =
104
+ document.currentScript.getAttribute("data-ws-endpoint") ||
105
+ "/.internal/alive.websocket";
106
+
100
107
  const jsenvAutoreloadOnServerRestartElement =
101
108
  new JsenvAutoreloadOnServerRestart({
102
109
  url: (() => {
103
110
  const websocketScheme =
104
111
  self.location.protocol === "https:" ? "wss" : "ws";
105
- const websocketUrl = `${websocketScheme}://${self.location.host}/.internal/alive.websocket`;
112
+ const websocketUrl = `${websocketScheme}://${self.location.host}${websocketEndpoint}`;
106
113
  return websocketUrl;
107
114
  })(),
108
115
  });