@runtimescope/collector 0.10.9 → 0.10.10
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.
|
@@ -5042,6 +5042,30 @@ var HttpServer = class {
|
|
|
5042
5042
|
}
|
|
5043
5043
|
return null;
|
|
5044
5044
|
}
|
|
5045
|
+
/**
|
|
5046
|
+
* Resolve the directory containing the built dashboard SPA. The tsup
|
|
5047
|
+
* onSuccess hook copies packages/dashboard/dist/ into the collector's
|
|
5048
|
+
* dist/dashboard-assets/ so the dashboard ships inside the @runtimescope/
|
|
5049
|
+
* collector npm package. Cached after first resolution.
|
|
5050
|
+
*/
|
|
5051
|
+
dashboardAssetsRoot = null;
|
|
5052
|
+
resolveDashboardAssets() {
|
|
5053
|
+
if (this.dashboardAssetsRoot) return this.dashboardAssetsRoot;
|
|
5054
|
+
const __dir = dirname2(fileURLToPath(import.meta.url));
|
|
5055
|
+
const candidates = [
|
|
5056
|
+
resolve(__dir, "dashboard-assets"),
|
|
5057
|
+
// npm published: dist/dashboard-assets/
|
|
5058
|
+
resolve(__dir, "../../dashboard/dist")
|
|
5059
|
+
// monorepo dev: sibling package
|
|
5060
|
+
];
|
|
5061
|
+
for (const p of candidates) {
|
|
5062
|
+
if (existsSync6(resolve(p, "index.html"))) {
|
|
5063
|
+
this.dashboardAssetsRoot = p;
|
|
5064
|
+
return p;
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
return null;
|
|
5068
|
+
}
|
|
5045
5069
|
getPort() {
|
|
5046
5070
|
return this.activePort;
|
|
5047
5071
|
}
|
|
@@ -5216,7 +5240,7 @@ var HttpServer = class {
|
|
|
5216
5240
|
res.end();
|
|
5217
5241
|
return;
|
|
5218
5242
|
}
|
|
5219
|
-
const isPublic = url.pathname === "/api/health" || url.pathname === "/readyz" || url.pathname === "/metrics" || url.pathname === "/runtimescope.js" || url.pathname === "/snippet";
|
|
5243
|
+
const isPublic = url.pathname === "/api/health" || url.pathname === "/readyz" || url.pathname === "/metrics" || url.pathname === "/runtimescope.js" || url.pathname === "/snippet" || url.pathname === "/dashboard" || url.pathname.startsWith("/dashboard/") || url.pathname.startsWith("/assets/");
|
|
5220
5244
|
const workspaceKeysExist = !!this.pmStore?.hasActiveApiKeys?.();
|
|
5221
5245
|
const authActive = !!this.authManager?.isEnabled() || workspaceKeysExist;
|
|
5222
5246
|
const caller = {
|
|
@@ -5250,6 +5274,31 @@ var HttpServer = class {
|
|
|
5250
5274
|
}
|
|
5251
5275
|
return;
|
|
5252
5276
|
}
|
|
5277
|
+
const isDashboardRoute = url.pathname === "/dashboard" || url.pathname.startsWith("/dashboard/");
|
|
5278
|
+
const isAssetRoute = url.pathname.startsWith("/assets/");
|
|
5279
|
+
if (req.method === "GET" && (isDashboardRoute || isAssetRoute)) {
|
|
5280
|
+
const assetsRoot = this.resolveDashboardAssets();
|
|
5281
|
+
if (!assetsRoot) {
|
|
5282
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
5283
|
+
res.end("Dashboard assets not found. Run: npm run build -w packages/dashboard");
|
|
5284
|
+
return;
|
|
5285
|
+
}
|
|
5286
|
+
const relativePath = isAssetRoute ? url.pathname.slice(1) : url.pathname === "/dashboard" || url.pathname === "/dashboard/" ? "index.html" : url.pathname.slice("/dashboard/".length);
|
|
5287
|
+
const filePath = resolve(assetsRoot, relativePath);
|
|
5288
|
+
const hasExtension = /\.[a-zA-Z0-9]+$/.test(relativePath);
|
|
5289
|
+
const targetPath = existsSync6(filePath) ? filePath : hasExtension || isAssetRoute ? null : resolve(assetsRoot, "index.html");
|
|
5290
|
+
if (!targetPath || !existsSync6(targetPath)) {
|
|
5291
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
5292
|
+
res.end("Not found");
|
|
5293
|
+
return;
|
|
5294
|
+
}
|
|
5295
|
+
const ext = targetPath.slice(targetPath.lastIndexOf(".")).toLowerCase();
|
|
5296
|
+
const contentType = ext === ".html" ? "text/html; charset=utf-8" : ext === ".js" ? "application/javascript; charset=utf-8" : ext === ".mjs" ? "application/javascript; charset=utf-8" : ext === ".css" ? "text/css; charset=utf-8" : ext === ".json" ? "application/json; charset=utf-8" : ext === ".svg" ? "image/svg+xml" : ext === ".png" ? "image/png" : ext === ".jpg" || ext === ".jpeg" ? "image/jpeg" : ext === ".ico" ? "image/x-icon" : ext === ".woff" ? "font/woff" : ext === ".woff2" ? "font/woff2" : "application/octet-stream";
|
|
5297
|
+
const cacheControl = targetPath.endsWith("index.html") || targetPath.endsWith("/index.html") ? "no-cache" : "public, max-age=31536000, immutable";
|
|
5298
|
+
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": cacheControl });
|
|
5299
|
+
res.end(readFileSync5(targetPath));
|
|
5300
|
+
return;
|
|
5301
|
+
}
|
|
5253
5302
|
if (req.method === "GET" && url.pathname === "/snippet") {
|
|
5254
5303
|
const appName = (url.searchParams.get("app") || "my-app").replace(/[^a-zA-Z0-9_-]/g, "");
|
|
5255
5304
|
const projectId = url.searchParams.get("project_id") || "proj_xxx";
|
|
@@ -7532,4 +7581,4 @@ export {
|
|
|
7532
7581
|
parseSessionJsonl,
|
|
7533
7582
|
ProjectDiscovery
|
|
7534
7583
|
};
|
|
7535
|
-
//# sourceMappingURL=chunk-
|
|
7584
|
+
//# sourceMappingURL=chunk-VNRQCY6B.js.map
|