@svelte-vitals/vite 0.36.2 → 0.36.3
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/hooks/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as toOccurrenceMap, o as parseHtmlHead, t as isLoopbackOrigin } from "../loopback-CE47i4VD.js";
|
|
2
2
|
import { defineConfig } from "@svelte-vitals/core";
|
|
3
3
|
import { allRules, defaultProject, effectiveSeverity, formatFailedRuleWarning, isPenalized, runAnalysis, selectRules, terminalSafe } from "@svelte-vitals/core/internal";
|
|
4
4
|
import { DEV } from "esm-env";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as globFiles, n as isSameOrigin, r as collectRenderedHeads, t as isLoopbackOrigin } from "./loopback-CE47i4VD.js";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
@@ -304,6 +304,7 @@ const SEVERITIES = /* @__PURE__ */ new Set([
|
|
|
304
304
|
"info"
|
|
305
305
|
]);
|
|
306
306
|
const CATEGORY_SET = new Set(CATEGORIES);
|
|
307
|
+
const INGEST_BODY_LIMIT = 4194304;
|
|
307
308
|
function isOptionalString(v) {
|
|
308
309
|
return v === void 0 || typeof v === "string";
|
|
309
310
|
}
|
|
@@ -344,7 +345,8 @@ function installUiMiddleware(server, config, version, store, coreVersion, getSta
|
|
|
344
345
|
const url = req.url ?? "/";
|
|
345
346
|
const origin = req.headers.origin;
|
|
346
347
|
const host = req.headers.host;
|
|
347
|
-
|
|
348
|
+
const isTls = Boolean(req.socket?.encrypted);
|
|
349
|
+
if (host === void 0 || !isLoopbackOrigin(`http://${host}`) || typeof origin === "string" && !isSameOrigin(origin, host, isTls)) {
|
|
348
350
|
req.resume();
|
|
349
351
|
res.statusCode = 403;
|
|
350
352
|
res.end("svelte-vitals dev UI is only available from localhost");
|
|
@@ -352,8 +354,23 @@ function installUiMiddleware(server, config, version, store, coreVersion, getSta
|
|
|
352
354
|
}
|
|
353
355
|
if (req.method === "POST" && url.startsWith("/ingest")) {
|
|
354
356
|
const chunks = [];
|
|
355
|
-
|
|
357
|
+
let received = 0;
|
|
358
|
+
let tooLarge = false;
|
|
359
|
+
req.on("data", (c) => {
|
|
360
|
+
if (tooLarge) return;
|
|
361
|
+
received += c.length;
|
|
362
|
+
if (received > INGEST_BODY_LIMIT) {
|
|
363
|
+
tooLarge = true;
|
|
364
|
+
chunks.length = 0;
|
|
365
|
+
res.statusCode = 413;
|
|
366
|
+
res.end();
|
|
367
|
+
req.destroy();
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
chunks.push(c);
|
|
371
|
+
});
|
|
356
372
|
req.on("end", () => {
|
|
373
|
+
if (tooLarge) return;
|
|
357
374
|
try {
|
|
358
375
|
const { route, results, failedRuleIds } = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
359
376
|
if (typeof route === "string" && Array.isArray(results)) {
|
|
@@ -303,5 +303,26 @@ function isLoopbackOrigin(origin) {
|
|
|
303
303
|
return false;
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Whether `origin` (an Origin header value) names exactly the server this request reached —
|
|
308
|
+
* `host` is the Host header, `hostname[:port]`, and `secure` is whether the connection is TLS.
|
|
309
|
+
* Compared as hostname + effective port: each side's omitted port resolves to its own scheme's
|
|
310
|
+
* default (the Origin's from its URL scheme, the Host's from `secure`), so `https://localhost`
|
|
311
|
+
* never matches a plain-http server on :80 and `https://localhost:443` does match a TLS server
|
|
312
|
+
* whose Host is `localhost:443`. The Origin's scheme is otherwise not compared: under
|
|
313
|
+
* `server.https` the Origin is https while the Host header is unchanged.
|
|
314
|
+
*/
|
|
315
|
+
function isSameOrigin(origin, host, secure = false) {
|
|
316
|
+
try {
|
|
317
|
+
const o = new URL(origin);
|
|
318
|
+
const h = new URL(`${secure ? "https" : "http"}://${host}`);
|
|
319
|
+
return o.hostname === h.hostname && effectivePort(o) === effectivePort(h);
|
|
320
|
+
} catch {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function effectivePort(url) {
|
|
325
|
+
return url.port || (url.protocol === "https:" ? "443" : "80");
|
|
326
|
+
}
|
|
306
327
|
//#endregion
|
|
307
|
-
export {
|
|
328
|
+
export { globFiles as a, toOccurrenceMap as i, isSameOrigin as n, parseHtmlHead as o, collectRenderedHeads as r, isLoopbackOrigin as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svelte-vitals/vite",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.3",
|
|
4
4
|
"description": "Vite/SvelteKit plugin for svelte-vitals — analyzes prerendered HTML during vite build, plus a live dev dashboard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"node-html-parser": "^9.0.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@svelte-vitals/core": "^0.51.
|
|
46
|
+
"@svelte-vitals/core": "^0.51.1",
|
|
47
47
|
"@sveltejs/kit": "^2.70.3",
|
|
48
|
-
"svelte-vitals": "^0.54.
|
|
48
|
+
"svelte-vitals": "^0.54.3",
|
|
49
49
|
"vite": "^8.2.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@svelte-vitals/core": "0.51.
|
|
57
|
+
"@svelte-vitals/core": "0.51.1",
|
|
58
58
|
"@sveltejs/kit": "^2.70.3",
|
|
59
59
|
"@types/node": "^24.13.3",
|
|
60
|
-
"happy-dom": "^20.
|
|
60
|
+
"happy-dom": "^20.12.0",
|
|
61
61
|
"svelte": "^5.57.0",
|
|
62
|
-
"svelte-vitals": "0.54.
|
|
62
|
+
"svelte-vitals": "0.54.3",
|
|
63
63
|
"vite": "^8.2.2"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|