@svelte-vitals/vite 0.8.0 → 0.9.2
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.
|
@@ -96,7 +96,16 @@ function parseHtmlHead(html) {
|
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
collectHeadings(root.querySelector("body") ?? root);
|
|
99
|
-
|
|
99
|
+
const images = (root.querySelector("body") ?? root).querySelectorAll("img").map((img) => ({
|
|
100
|
+
hasWidth: img.hasAttribute("width"),
|
|
101
|
+
hasHeight: img.hasAttribute("height"),
|
|
102
|
+
hasLoading: img.hasAttribute("loading"),
|
|
103
|
+
hasAlt: img.hasAttribute("alt"),
|
|
104
|
+
lazy: img.getAttribute("loading") === "lazy",
|
|
105
|
+
hasSrcset: img.hasAttribute("srcset"),
|
|
106
|
+
line: 0
|
|
107
|
+
}));
|
|
108
|
+
return { tags, htmlLang, headings, images };
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
export {
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseHtmlHead
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-LIC7DE52.js";
|
|
4
4
|
|
|
5
5
|
// src/hooks/handle.ts
|
|
6
6
|
import { DEV } from "esm-env";
|
|
@@ -63,13 +63,17 @@ async function postIngest(origin, route, results) {
|
|
|
63
63
|
}
|
|
64
64
|
async function analyzeAndWarn(html, route, origin, rules, config, lastSignature) {
|
|
65
65
|
try {
|
|
66
|
-
const { tags, htmlLang, headings: levels } = parseHtmlHead(html);
|
|
66
|
+
const { tags, htmlLang, headings: levels, images: imgs } = parseHtmlHead(html);
|
|
67
67
|
const head = { route, source: "rendered", tags, file: route };
|
|
68
68
|
const headings = [
|
|
69
69
|
{ route, headings: levels.map((level) => ({ level, line: 0, file: route })) }
|
|
70
70
|
];
|
|
71
|
+
const images = [{ route, images: imgs.map((img) => ({ ...img, file: route })) }];
|
|
71
72
|
const project = { hasRobotsTxt: true, hasSitemap: true, htmlLang };
|
|
72
|
-
const results = applyRuleSeverities(
|
|
73
|
+
const results = applyRuleSeverities(
|
|
74
|
+
await runRules(rules, { heads: [head], headings, images, project, config }),
|
|
75
|
+
config
|
|
76
|
+
);
|
|
73
77
|
const signature = findingSignature(results, config);
|
|
74
78
|
if (lastSignature.get(route) === signature) return;
|
|
75
79
|
lastSignature.set(route, signature);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseHtmlHead
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LIC7DE52.js";
|
|
4
4
|
|
|
5
5
|
// src/plugin.ts
|
|
6
6
|
import { existsSync } from "fs";
|
|
@@ -39,6 +39,7 @@ async function collectRenderedHeads(prerenderPagesDir) {
|
|
|
39
39
|
);
|
|
40
40
|
const heads = [];
|
|
41
41
|
const headings = [];
|
|
42
|
+
const images = [];
|
|
42
43
|
let htmlLang = { presence: "none", value: "absent" };
|
|
43
44
|
for (const { rel, parsed } of parsedFiles) {
|
|
44
45
|
if (htmlLang.presence === "none" && parsed.htmlLang.presence === "own") htmlLang = parsed.htmlLang;
|
|
@@ -54,8 +55,9 @@ async function collectRenderedHeads(prerenderPagesDir) {
|
|
|
54
55
|
// Rendered mode does not track source lines (line 0 = unknown); file is the HTML path.
|
|
55
56
|
headings: parsed.headings.map((level) => ({ level, line: 0, file: rel }))
|
|
56
57
|
});
|
|
58
|
+
images.push({ route, images: parsed.images.map((img) => ({ ...img, file: rel })) });
|
|
57
59
|
}
|
|
58
|
-
return { heads, headings, htmlLang };
|
|
60
|
+
return { heads, headings, images, htmlLang };
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
// src/providers/rendered/project.ts
|
|
@@ -114,10 +116,10 @@ async function analyze(prerenderPagesDir, cwd, options) {
|
|
|
114
116
|
rules: options.rules ?? {},
|
|
115
117
|
failOn: options.failOn ?? "critical"
|
|
116
118
|
});
|
|
117
|
-
const { heads, headings, htmlLang } = await collectRenderedHeads(prerenderPagesDir);
|
|
119
|
+
const { heads, headings, images, htmlLang } = await collectRenderedHeads(prerenderPagesDir);
|
|
118
120
|
const project = await collectRenderedProject(cwd, htmlLang);
|
|
119
121
|
const results = applyRuleSeverities(
|
|
120
|
-
await runRules(selectRules(allRules, config), { heads, headings, project, config }),
|
|
122
|
+
await runRules(selectRules(allRules, config), { heads, headings, images, project, config }),
|
|
121
123
|
config
|
|
122
124
|
);
|
|
123
125
|
const { score } = computeScore(results, config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svelte-vitals/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Vite/SvelteKit plugin for svelte-vitals — analyzes prerendered HTML during vite build.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/oekazuma/svelte-vitals#readme",
|
|
24
24
|
"engines": {
|
|
25
|
-
"node": ">=18"
|
|
25
|
+
"node": ">=18.20.8"
|
|
26
26
|
},
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"exports": {
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"esm-env": "^1.2.2",
|
|
43
43
|
"node-html-parser": "^6.1.13",
|
|
44
44
|
"tinyglobby": "^0.2.17",
|
|
45
|
-
"@svelte-vitals/core": "0.
|
|
45
|
+
"@svelte-vitals/core": "0.18.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@sveltejs/kit": "^2.0.0",
|
|
49
|
-
"vite": "^8.0
|
|
49
|
+
"vite": "^8.1.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"@sveltejs/kit": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@sveltejs/kit": "^2.0.0",
|
|
58
58
|
"@types/node": "^24.7.0",
|
|
59
59
|
"svelte": "^5.56.3",
|
|
60
|
-
"vite": "^8.0
|
|
60
|
+
"vite": "^8.1.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsup",
|