@chosengeneration/light-code 0.59.8 → 0.60.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/dist/cli.js +21 -1
- package/dist/client/client.js +25 -25
- package/dist/server.js +20 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -69650,6 +69650,17 @@ async function startServer(options) {
|
|
|
69650
69650
|
detach: (response) => {
|
|
69651
69651
|
if (sink === response) sink = void 0;
|
|
69652
69652
|
},
|
|
69653
|
+
drain: () => {
|
|
69654
|
+
return missed.splice(0, missed.length).flatMap((frame) => {
|
|
69655
|
+
const body = frame.startsWith("data: ") ? frame.slice(6).trimEnd() : "";
|
|
69656
|
+
if (body.length === 0) return [];
|
|
69657
|
+
try {
|
|
69658
|
+
return [JSON.parse(body)];
|
|
69659
|
+
} catch {
|
|
69660
|
+
return [];
|
|
69661
|
+
}
|
|
69662
|
+
});
|
|
69663
|
+
},
|
|
69653
69664
|
dispose: () => {
|
|
69654
69665
|
const open = sink;
|
|
69655
69666
|
sink = void 0;
|
|
@@ -69844,6 +69855,15 @@ async function startServer(options) {
|
|
|
69844
69855
|
request.on("close", cleanup);
|
|
69845
69856
|
return;
|
|
69846
69857
|
}
|
|
69858
|
+
if (url2.pathname === "/api/poll" && request.method === "GET") {
|
|
69859
|
+
let connection = connections.get(principal.id);
|
|
69860
|
+
if (connection === void 0) {
|
|
69861
|
+
connection = await openConnection(principal);
|
|
69862
|
+
connections.set(principal.id, connection);
|
|
69863
|
+
}
|
|
69864
|
+
respondJson(response, 200, { messages: connection.drain() });
|
|
69865
|
+
return;
|
|
69866
|
+
}
|
|
69847
69867
|
if (url2.pathname === "/api/message" && request.method === "POST") {
|
|
69848
69868
|
const connection = connections.get(principal.id);
|
|
69849
69869
|
if (connection === void 0) {
|