@sylphx/lens-server 4.1.4 → 4.1.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/dist/index.js +22 -3
- package/package.json +1 -1
- package/src/server/create.ts +24 -8
package/dist/index.js
CHANGED
|
@@ -1045,9 +1045,28 @@ class LensServerImpl {
|
|
|
1045
1045
|
headers: baseHeaders
|
|
1046
1046
|
});
|
|
1047
1047
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1048
|
+
if (request.method === "GET" && pathname.endsWith("/__lens/sse")) {
|
|
1049
|
+
const path = url.searchParams.get("path");
|
|
1050
|
+
if (!path) {
|
|
1051
|
+
const encoder = new TextEncoder;
|
|
1052
|
+
const errorStream = new ReadableStream({
|
|
1053
|
+
start(controller) {
|
|
1054
|
+
const data = `event: error
|
|
1055
|
+
data: ${JSON.stringify({ error: "Missing path parameter" })}
|
|
1056
|
+
|
|
1057
|
+
`;
|
|
1058
|
+
controller.enqueue(encoder.encode(data));
|
|
1059
|
+
controller.close();
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
return new Response(errorStream, {
|
|
1063
|
+
headers: {
|
|
1064
|
+
"Content-Type": "text/event-stream",
|
|
1065
|
+
"Cache-Control": "no-cache",
|
|
1066
|
+
Connection: "keep-alive"
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1051
1070
|
const inputParam = url.searchParams.get("input");
|
|
1052
1071
|
let input;
|
|
1053
1072
|
if (inputParam) {
|
package/package.json
CHANGED
package/src/server/create.ts
CHANGED
|
@@ -1276,14 +1276,30 @@ class LensServerImpl<
|
|
|
1276
1276
|
});
|
|
1277
1277
|
}
|
|
1278
1278
|
|
|
1279
|
-
// SSE: GET /{path}
|
|
1280
|
-
//
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
//
|
|
1286
|
-
|
|
1279
|
+
// SSE: GET /__lens/sse?path={path}&input={...}
|
|
1280
|
+
// Dedicated endpoint with path in query param - consistent with POST body format
|
|
1281
|
+
// This avoids base path parsing issues when server is mounted at /api etc.
|
|
1282
|
+
if (request.method === "GET" && pathname.endsWith("/__lens/sse")) {
|
|
1283
|
+
const path = url.searchParams.get("path");
|
|
1284
|
+
|
|
1285
|
+
// Validate path parameter
|
|
1286
|
+
if (!path) {
|
|
1287
|
+
const encoder = new TextEncoder();
|
|
1288
|
+
const errorStream = new ReadableStream({
|
|
1289
|
+
start(controller) {
|
|
1290
|
+
const data = `event: error\ndata: ${JSON.stringify({ error: "Missing path parameter" })}\n\n`;
|
|
1291
|
+
controller.enqueue(encoder.encode(data));
|
|
1292
|
+
controller.close();
|
|
1293
|
+
},
|
|
1294
|
+
});
|
|
1295
|
+
return new Response(errorStream, {
|
|
1296
|
+
headers: {
|
|
1297
|
+
"Content-Type": "text/event-stream",
|
|
1298
|
+
"Cache-Control": "no-cache",
|
|
1299
|
+
Connection: "keep-alive",
|
|
1300
|
+
},
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1287
1303
|
|
|
1288
1304
|
// Parse input from query params
|
|
1289
1305
|
const inputParam = url.searchParams.get("input");
|