fix(javascript): distinguish HTML script loads from data

This commit is contained in:
morluto committed 2026-10-27 05:57:26 +08:00
1 parent 8694dc30d9
commit 83b2d16ee9
6 files changed
+114 -5

No files matched your search

@@ -435,9 +435,10 @@ const parseHtmlScripts = (
const { scripts, inlineScripts, inlineScriptCount, baseHref } =
htmlArtifactReferences(text);
return {
scripts: scripts.map(({ scriptPath, location }) => ({
scripts: scripts.map(({ scriptPath, scriptType, location }) => ({
html_path: path,
script_path: scriptPath,
script_type: scriptType,
base_href: baseHref,
location,
})),
@@ -53,6 +53,8 @@ export type JavaScriptPackageObservation = JavaScriptStructuredObservation &
export interface JavaScriptHtmlScriptObservation {
readonly html_path: string;
readonly script_path: string;
/** Parsed JavaScript type; null for data blocks or other non-JavaScript types. */
readonly script_type: "classic" | "module" | null;
readonly base_href: string | null;
readonly location: JavaScriptSourceRange;
}
@@ -19,6 +19,8 @@ export const addJavaScriptHtmlRoles = (
): void => {
const byHtml = new Map<string, typeof context.analysis.html_scripts>();
for (const script of context.analysis.html_scripts) {
if (script.script_type !== "classic" && script.script_type !== "module")
continue;
const existing = byHtml.get(script.html_path);
byHtml.set(
script.html_path,