@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 CHANGED
@@ -70167,6 +70167,17 @@ async function startServer(options) {
70167
70167
  detach: (response) => {
70168
70168
  if (sink === response) sink = void 0;
70169
70169
  },
70170
+ drain: () => {
70171
+ return missed.splice(0, missed.length).flatMap((frame) => {
70172
+ const body = frame.startsWith("data: ") ? frame.slice(6).trimEnd() : "";
70173
+ if (body.length === 0) return [];
70174
+ try {
70175
+ return [JSON.parse(body)];
70176
+ } catch {
70177
+ return [];
70178
+ }
70179
+ });
70180
+ },
70170
70181
  dispose: () => {
70171
70182
  const open = sink;
70172
70183
  sink = void 0;
@@ -70361,6 +70372,15 @@ async function startServer(options) {
70361
70372
  request.on("close", cleanup);
70362
70373
  return;
70363
70374
  }
70375
+ if (url2.pathname === "/api/poll" && request.method === "GET") {
70376
+ let connection = connections.get(principal.id);
70377
+ if (connection === void 0) {
70378
+ connection = await openConnection(principal);
70379
+ connections.set(principal.id, connection);
70380
+ }
70381
+ respondJson(response, 200, { messages: connection.drain() });
70382
+ return;
70383
+ }
70364
70384
  if (url2.pathname === "/api/message" && request.method === "POST") {
70365
70385
  const connection = connections.get(principal.id);
70366
70386
  if (connection === void 0) {
@@ -70580,7 +70600,7 @@ function respondJson(response, status, body) {
70580
70600
  }
70581
70601
 
70582
70602
  // src/cli.ts
70583
- var VERSION = true ? "0.59.8" : "unknown (not a packaged build)";
70603
+ var VERSION = true ? "0.60.0" : "unknown (not a packaged build)";
70584
70604
  var compat = installNodeCompat();
70585
70605
  function lastMeaningfulLine(problem) {
70586
70606
  const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));