serve-sim 0.0.8 → 0.1.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/bin/serve-sim-bin +0 -0
- package/dist/middleware.js +7 -7
- package/dist/serve-sim.js +15 -15
- package/package.json +2 -2
- package/src/middleware.ts +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serve-sim",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Evan Bacon",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/bun": "latest",
|
|
40
|
-
"
|
|
40
|
+
"serve-sim-client": "workspace:*",
|
|
41
41
|
"preact": "^10.29.1",
|
|
42
42
|
"react": "^19.0.0",
|
|
43
43
|
"react-dom": "^19.0.0",
|
package/src/middleware.ts
CHANGED
|
@@ -150,7 +150,9 @@ export function simMiddleware(options?: SimMiddlewareOptions) {
|
|
|
150
150
|
const base = (options?.basePath ?? "/.sim").replace(/\/+$/, "");
|
|
151
151
|
|
|
152
152
|
return (req: any, res: any, next?: () => void) => {
|
|
153
|
-
const
|
|
153
|
+
const rawUrl: string = req.url ?? "";
|
|
154
|
+
const qIndex = rawUrl.indexOf("?");
|
|
155
|
+
const url = qIndex === -1 ? rawUrl : rawUrl.slice(0, qIndex);
|
|
154
156
|
|
|
155
157
|
// Serve the preview page
|
|
156
158
|
if (url === base || url === base + "/") {
|
|
@@ -220,7 +222,7 @@ export function simMiddleware(options?: SimMiddlewareOptions) {
|
|
|
220
222
|
}
|
|
221
223
|
|
|
222
224
|
// SSE: simctl log stream
|
|
223
|
-
if (url === base + "/logs"
|
|
225
|
+
if (url === base + "/logs") {
|
|
224
226
|
const states = readServeSimStates();
|
|
225
227
|
if (states.length === 0) {
|
|
226
228
|
res.writeHead(404);
|
|
@@ -262,7 +264,7 @@ export function simMiddleware(options?: SimMiddlewareOptions) {
|
|
|
262
264
|
// parsed from SpringBoard's "Setting process visibility to: Foreground"
|
|
263
265
|
// log line. Filtering is done here (not in the browser) so the SSE stream
|
|
264
266
|
// stays narrow and the client can listen without rate-limit concerns.
|
|
265
|
-
if (url === base + "/appstate"
|
|
267
|
+
if (url === base + "/appstate") {
|
|
266
268
|
const states = readServeSimStates();
|
|
267
269
|
if (states.length === 0) {
|
|
268
270
|
res.writeHead(404);
|