@hyperframes/inspector 0.9.49 → 0.9.51
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/service.js +148 -66
- package/package.json +3 -3
package/dist/service.js
CHANGED
|
@@ -53939,19 +53939,26 @@ import postcss32 from "postcss";
|
|
|
53939
53939
|
|
|
53940
53940
|
// ../parsers/dist/slideshow.js
|
|
53941
53941
|
var SLIDESHOW_ISLAND_TYPE = "application/hyperframes-slideshow+json";
|
|
53942
|
-
|
|
53943
|
-
|
|
53944
|
-
|
|
53945
|
-
|
|
53946
|
-
|
|
53947
|
-
|
|
53948
|
-
|
|
53942
|
+
var ISLAND_TYPE_ATTR = new RegExp(
|
|
53943
|
+
`type[\\t\\n\\f\\r ]*=[\\t\\n\\f\\r ]*["']${SLIDESHOW_ISLAND_TYPE.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']`,
|
|
53944
|
+
"i"
|
|
53945
|
+
);
|
|
53946
|
+
function slideshowIslandJson(html) {
|
|
53947
|
+
for (const tag of html.matchAll(/<script[^>]*>?/gi)) {
|
|
53948
|
+
if (!tag[0].endsWith(">")) return null;
|
|
53949
|
+
if (!ISLAND_TYPE_ATTR.test(tag[0])) continue;
|
|
53950
|
+
const bodyStart = tag.index + tag[0].length;
|
|
53951
|
+
const close = /<\/script>/gi;
|
|
53952
|
+
close.lastIndex = bodyStart;
|
|
53953
|
+
const end = close.exec(html);
|
|
53954
|
+
return end ? html.slice(bodyStart, end.index) : null;
|
|
53955
|
+
}
|
|
53956
|
+
return null;
|
|
53949
53957
|
}
|
|
53950
53958
|
function parseSlideshowManifest(html) {
|
|
53951
|
-
const
|
|
53952
|
-
|
|
53953
|
-
|
|
53954
|
-
const raw = match[1].trim();
|
|
53959
|
+
const island = slideshowIslandJson(html);
|
|
53960
|
+
if (island === null) return null;
|
|
53961
|
+
const raw = island.trim();
|
|
53955
53962
|
if (raw.length === 0) return null;
|
|
53956
53963
|
const parsed2 = JSON.parse(raw);
|
|
53957
53964
|
if (!isManifest(parsed2)) {
|
|
@@ -54217,7 +54224,6 @@ var TIMELINE_REGISTRY_INIT_PATTERN = /window\.__timelines\s*=\s*window\.__timeli
|
|
|
54217
54224
|
var TIMELINE_REGISTRY_OBJECT_LITERAL_PATTERN = /window\.__timelines\s*=\s*\{\s*(?:["'][^"']+["']|[A-Za-z_$][\w$]*)\s*:/i;
|
|
54218
54225
|
var TIMELINE_REGISTRY_ASSIGN_PATTERN = /window\.__timelines(?:\[[^\]]+\]|\.[A-Za-z_$][\w$]*)\s*=/i;
|
|
54219
54226
|
var WINDOW_TIMELINE_ASSIGN_PATTERN = /window\.__timelines(?:\[\s*(?:["']([^"']+)["']|[A-Za-z_$][\w$.]*)\s*\]|\.\s*([A-Za-z_$][\w$]*))\s*=\s*([A-Za-z_$][\w$]*)/i;
|
|
54220
|
-
var INVALID_SCRIPT_CLOSE_PATTERN = /<script[^>]*>[\s\S]*?<\s*\/\s*script(?!>)/i;
|
|
54221
54227
|
var TIMELINE_REGISTRY_KEY_PATTERN = /window\.__timelines(?:\[\s*["']([^"']+)["']\s*\]|\.\s*([A-Za-z_$][\w$]*))\s*(?:\?\?|\|\||&&)?=/g;
|
|
54222
54228
|
var TIMELINE_REGISTRY_OBJECT_OPEN_PATTERN = /window\.__timelines\s*=\s*\{/i;
|
|
54223
54229
|
var TIMELINE_REGISTRY_OBJECT_ENTRY_PATTERN = /(?:["']([^"']+)["']|([A-Za-z_$][\w$]*))\s*:\s*[A-Za-z_$][\w$]*/g;
|
|
@@ -55021,6 +55027,116 @@ function buildLintContext(html, options = {}) {
|
|
|
55021
55027
|
options
|
|
55022
55028
|
};
|
|
55023
55029
|
}
|
|
55030
|
+
function execFrom(pattern, source, from) {
|
|
55031
|
+
pattern.lastIndex = from;
|
|
55032
|
+
return pattern.exec(source);
|
|
55033
|
+
}
|
|
55034
|
+
function* blockComments(source) {
|
|
55035
|
+
for (let from = 0; ; ) {
|
|
55036
|
+
const start = source.indexOf("/*", from);
|
|
55037
|
+
if (start < 0) return;
|
|
55038
|
+
const close = source.indexOf("*/", start + 2);
|
|
55039
|
+
if (close < 0) return;
|
|
55040
|
+
yield { index: start, text: source.slice(start, close + 2) };
|
|
55041
|
+
from = close + 2;
|
|
55042
|
+
}
|
|
55043
|
+
}
|
|
55044
|
+
function replaceBlockComments(source, replacement) {
|
|
55045
|
+
let out = "";
|
|
55046
|
+
let kept = 0;
|
|
55047
|
+
for (const { index, text } of blockComments(source)) {
|
|
55048
|
+
out += source.slice(kept, index) + replacement;
|
|
55049
|
+
kept = index + text.length;
|
|
55050
|
+
}
|
|
55051
|
+
return out + source.slice(kept);
|
|
55052
|
+
}
|
|
55053
|
+
function hasInvalidScriptClose(source) {
|
|
55054
|
+
const open = execFrom(/<script/gi, source, 0);
|
|
55055
|
+
const gt = open ? source.indexOf(">", open.index + open[0].length) : -1;
|
|
55056
|
+
return gt >= 0 && execFrom(/<\s*\/\s*script(?!>)/gi, source, gt + 1) !== null;
|
|
55057
|
+
}
|
|
55058
|
+
function emptyStyleBlocks(source) {
|
|
55059
|
+
let out = "";
|
|
55060
|
+
let kept = 0;
|
|
55061
|
+
const opener = /<style\b/gi;
|
|
55062
|
+
for (let open = execFrom(opener, source, 0); open; open = opener.exec(source)) {
|
|
55063
|
+
const gt = source.indexOf(">", open.index + 6);
|
|
55064
|
+
const close = gt < 0 ? null : execFrom(/<\/style>/gi, source, gt + 1);
|
|
55065
|
+
if (!close) break;
|
|
55066
|
+
out += `${source.slice(kept, open.index)}<style></style>`;
|
|
55067
|
+
kept = close.index + close[0].length;
|
|
55068
|
+
opener.lastIndex = kept;
|
|
55069
|
+
}
|
|
55070
|
+
return out + source.slice(kept);
|
|
55071
|
+
}
|
|
55072
|
+
function styleTagTokens(source) {
|
|
55073
|
+
const tokens2 = [];
|
|
55074
|
+
const token = /<script\b|<style\b|<\/style\s*>/gi;
|
|
55075
|
+
let scriptsClose = true;
|
|
55076
|
+
for (let match = token.exec(source); match; match = token.exec(source)) {
|
|
55077
|
+
if (!/^<script/i.test(match[0])) {
|
|
55078
|
+
tokens2.push(match[0]);
|
|
55079
|
+
continue;
|
|
55080
|
+
}
|
|
55081
|
+
if (!scriptsClose) continue;
|
|
55082
|
+
const close = execFrom(/<\/script/gi, source, match.index + 7);
|
|
55083
|
+
const gt = close ? source.indexOf(">", close.index + 8) : -1;
|
|
55084
|
+
if (gt < 0) scriptsClose = false;
|
|
55085
|
+
else token.lastIndex = gt + 1;
|
|
55086
|
+
}
|
|
55087
|
+
return tokens2;
|
|
55088
|
+
}
|
|
55089
|
+
var PROTECTED_NAMES = "style|script|template|title|noscript|pre|code|textarea|text";
|
|
55090
|
+
function protectedBlockRanges(source) {
|
|
55091
|
+
const ranges = [];
|
|
55092
|
+
const unclosed = /* @__PURE__ */ new Set();
|
|
55093
|
+
const lastGt = source.lastIndexOf(">");
|
|
55094
|
+
const opener = new RegExp(`<(${PROTECTED_NAMES})\\b`, "gi");
|
|
55095
|
+
for (let open = opener.exec(source); open; open = opener.exec(source)) {
|
|
55096
|
+
const name = open[1].toLowerCase();
|
|
55097
|
+
if (unclosed.has(name)) continue;
|
|
55098
|
+
const gt = source.indexOf(">", open.index + open[0].length);
|
|
55099
|
+
if (gt < 0) break;
|
|
55100
|
+
const end = protectedBlockEnd(source, name, gt + 1, lastGt);
|
|
55101
|
+
if (end < 0) {
|
|
55102
|
+
unclosed.add(name);
|
|
55103
|
+
continue;
|
|
55104
|
+
}
|
|
55105
|
+
ranges.push({ start: open.index, end });
|
|
55106
|
+
opener.lastIndex = end;
|
|
55107
|
+
}
|
|
55108
|
+
return ranges;
|
|
55109
|
+
}
|
|
55110
|
+
function protectedBlockEnd(source, name, from, lastGt) {
|
|
55111
|
+
const closer = new RegExp(`</${name}`, "gi");
|
|
55112
|
+
for (let close = execFrom(closer, source, from); close; close = closer.exec(source)) {
|
|
55113
|
+
const after2 = close.index + close[0].length;
|
|
55114
|
+
if (after2 > lastGt) return -1;
|
|
55115
|
+
if (source[after2] === ">") return after2 + 1;
|
|
55116
|
+
if (/\s/.test(source[after2] ?? "")) return source.indexOf(">", after2) + 1;
|
|
55117
|
+
}
|
|
55118
|
+
return -1;
|
|
55119
|
+
}
|
|
55120
|
+
function htmlTagTracker(source) {
|
|
55121
|
+
let i = 0;
|
|
55122
|
+
let inTag = false;
|
|
55123
|
+
let quote = null;
|
|
55124
|
+
return (index) => {
|
|
55125
|
+
for (; i < index; i++) {
|
|
55126
|
+
const char = source[i];
|
|
55127
|
+
if (!inTag) inTag = char === "<";
|
|
55128
|
+
else if (quote) quote = char === quote ? null : quote;
|
|
55129
|
+
else if (char === '"' || char === "'") quote = char;
|
|
55130
|
+
else if (char === ">") inTag = false;
|
|
55131
|
+
}
|
|
55132
|
+
return inTag;
|
|
55133
|
+
};
|
|
55134
|
+
}
|
|
55135
|
+
function hasScriptWithSrc(source) {
|
|
55136
|
+
for (const [tag] of source.matchAll(/<script\b[^>]*>?/gi))
|
|
55137
|
+
if (/\bsrc\s*=/i.test(tag)) return true;
|
|
55138
|
+
return false;
|
|
55139
|
+
}
|
|
55024
55140
|
var parsed = /* @__PURE__ */ new WeakMap();
|
|
55025
55141
|
function styleRoot(style) {
|
|
55026
55142
|
let entry = parsed.get(style);
|
|
@@ -55380,45 +55496,15 @@ function describeStudioElement(tag) {
|
|
|
55380
55496
|
parts.push(">");
|
|
55381
55497
|
return parts.join("");
|
|
55382
55498
|
}
|
|
55383
|
-
var VISIBLE_MARKUP_COMMENT_PATTERN = /\/\*[\s\S]*?\*\//g;
|
|
55384
|
-
var VISIBLE_MARKUP_COMMENT_PROTECTED_BLOCK_PATTERN = /<(style|script|template|title|noscript|pre|code|textarea|text)\b[^>]*>[\s\S]*?<\/\1(?:\s[^>]*)?>/gi;
|
|
55385
|
-
function findProtectedVisibleMarkupRanges(source) {
|
|
55386
|
-
const ranges = [];
|
|
55387
|
-
for (const match of source.matchAll(VISIBLE_MARKUP_COMMENT_PROTECTED_BLOCK_PATTERN)) {
|
|
55388
|
-
ranges.push({ start: match.index, end: match.index + match[0].length });
|
|
55389
|
-
}
|
|
55390
|
-
return ranges;
|
|
55391
|
-
}
|
|
55392
|
-
function isInsideSourceRange(index, ranges) {
|
|
55393
|
-
return ranges.some((range) => range.start <= index && index < range.end);
|
|
55394
|
-
}
|
|
55395
|
-
function isInsideHtmlTag(source, index) {
|
|
55396
|
-
let inTag = false;
|
|
55397
|
-
let quote = null;
|
|
55398
|
-
for (let i = 0; i < index; i++) {
|
|
55399
|
-
const char = source[i];
|
|
55400
|
-
if (!inTag) {
|
|
55401
|
-
if (char === "<") inTag = true;
|
|
55402
|
-
continue;
|
|
55403
|
-
}
|
|
55404
|
-
if (quote) {
|
|
55405
|
-
if (char === quote) quote = null;
|
|
55406
|
-
continue;
|
|
55407
|
-
}
|
|
55408
|
-
if (char === '"' || char === "'") {
|
|
55409
|
-
quote = char;
|
|
55410
|
-
} else if (char === ">") {
|
|
55411
|
-
inTag = false;
|
|
55412
|
-
}
|
|
55413
|
-
}
|
|
55414
|
-
return inTag;
|
|
55415
|
-
}
|
|
55416
55499
|
function findVisibleMarkupCommentLeak(source) {
|
|
55417
|
-
const protectedRanges =
|
|
55418
|
-
|
|
55419
|
-
|
|
55420
|
-
|
|
55421
|
-
|
|
55500
|
+
const protectedRanges = protectedBlockRanges(source);
|
|
55501
|
+
const insideHtmlTag = htmlTagTracker(source);
|
|
55502
|
+
let range = 0;
|
|
55503
|
+
for (const comment of blockComments(source)) {
|
|
55504
|
+
if (insideHtmlTag(comment.index)) continue;
|
|
55505
|
+
while (protectedRanges[range] && protectedRanges[range].end <= comment.index) range++;
|
|
55506
|
+
if ((protectedRanges[range]?.start ?? Infinity) <= comment.index) continue;
|
|
55507
|
+
return comment.text;
|
|
55422
55508
|
}
|
|
55423
55509
|
return null;
|
|
55424
55510
|
}
|
|
@@ -55557,14 +55643,10 @@ var coreRules = [
|
|
|
55557
55643
|
let opens = 0;
|
|
55558
55644
|
let closes = 0;
|
|
55559
55645
|
let firstTag = "";
|
|
55560
|
-
for (const
|
|
55561
|
-
|
|
55562
|
-
)) {
|
|
55563
|
-
const token = match[0].toLowerCase();
|
|
55564
|
-
if (token.startsWith("<script")) continue;
|
|
55565
|
-
if (token.startsWith("</style")) closes += 1;
|
|
55646
|
+
for (const tag of styleTagTokens(source)) {
|
|
55647
|
+
if (tag.toLowerCase().startsWith("</style")) closes += 1;
|
|
55566
55648
|
else opens += 1;
|
|
55567
|
-
if (!firstTag) firstTag =
|
|
55649
|
+
if (!firstTag) firstTag = tag;
|
|
55568
55650
|
}
|
|
55569
55651
|
if (opens === closes) return [];
|
|
55570
55652
|
return [
|
|
@@ -55760,7 +55842,7 @@ var coreRules = [
|
|
|
55760
55842
|
},
|
|
55761
55843
|
// invalid_inline_script_syntax (malformed close tag)
|
|
55762
55844
|
({ source }) => {
|
|
55763
|
-
if (!
|
|
55845
|
+
if (!hasInvalidScriptClose(source)) return [];
|
|
55764
55846
|
return [
|
|
55765
55847
|
{
|
|
55766
55848
|
code: "invalid_inline_script_syntax",
|
|
@@ -57091,7 +57173,7 @@ function countPhysicalLines(source) {
|
|
|
57091
57173
|
return withoutFinalNewline.split("\n").length;
|
|
57092
57174
|
}
|
|
57093
57175
|
function countStructuralLines(source) {
|
|
57094
|
-
return countPhysicalLines(source
|
|
57176
|
+
return countPhysicalLines(emptyStyleBlocks(source));
|
|
57095
57177
|
}
|
|
57096
57178
|
function isCaptionCue(tag) {
|
|
57097
57179
|
const classTokens2 = (readAttr(tag.raw, "class") || "").split(/\s+/).filter(Boolean);
|
|
@@ -57113,7 +57195,7 @@ function isCompositionRootOrMount(rawTag) {
|
|
|
57113
57195
|
}
|
|
57114
57196
|
function extractCssUrlReferences(css) {
|
|
57115
57197
|
const out = [];
|
|
57116
|
-
const noComments = css
|
|
57198
|
+
const noComments = replaceBlockComments(css, "");
|
|
57117
57199
|
const urlPattern = /\burl\(\s*(["']?)([^)"']+)\1\s*\)/g;
|
|
57118
57200
|
let m;
|
|
57119
57201
|
while ((m = urlPattern.exec(noComments)) !== null) {
|
|
@@ -57142,7 +57224,7 @@ function climbsAboveRoot(fileDepth, path) {
|
|
|
57142
57224
|
}
|
|
57143
57225
|
function extractCssSelectors(css) {
|
|
57144
57226
|
const out = [];
|
|
57145
|
-
const noComments = css
|
|
57227
|
+
const noComments = replaceBlockComments(css, "");
|
|
57146
57228
|
const ruleHeader = /(?<![^{}])([^{}]+)\{/g;
|
|
57147
57229
|
let m;
|
|
57148
57230
|
while ((m = ruleHeader.exec(noComments)) !== null) {
|
|
@@ -57167,7 +57249,7 @@ function collectHeavyOverlayHooks(styles) {
|
|
|
57167
57249
|
const classes = /* @__PURE__ */ new Set();
|
|
57168
57250
|
const ids = /* @__PURE__ */ new Set();
|
|
57169
57251
|
for (const style of styles) {
|
|
57170
|
-
const noComments = style.content
|
|
57252
|
+
const noComments = replaceBlockComments(style.content, "");
|
|
57171
57253
|
const ruleWithBody = /(?<![^{}])([^{}]+)\{([^{}]*)\}/g;
|
|
57172
57254
|
let m;
|
|
57173
57255
|
while ((m = ruleWithBody.exec(noComments)) !== null) {
|
|
@@ -57910,7 +57992,7 @@ var compositionRules = [
|
|
|
57910
57992
|
// opts out with data-no-timeline.
|
|
57911
57993
|
({ rootTag, rootCompositionId, tags, scripts, rawSource, options }) => {
|
|
57912
57994
|
if (!rootCompositionId || !rootTag) return [];
|
|
57913
|
-
if (
|
|
57995
|
+
if (hasScriptWithSrc(rawSource)) return [];
|
|
57914
57996
|
if (hasComputedTimelineRegistration(scripts)) return [];
|
|
57915
57997
|
const registeredIds = new Set(
|
|
57916
57998
|
scripts.flatMap((script) => extractTimelineRegistryKeys(stripJsComments(script.content)))
|
|
@@ -58211,8 +58293,8 @@ var compositionRules = [
|
|
|
58211
58293
|
if (hasGsapTimeline && hasRegisteredTimeline) return [];
|
|
58212
58294
|
const allCss = styles.map((s) => s.content).join("\n");
|
|
58213
58295
|
const allInlineStyles = tags.map((t) => readAttr(t.raw, "style") || "").join("\n");
|
|
58214
|
-
const combinedCss = `${allCss}
|
|
58215
|
-
${allInlineStyles}
|
|
58296
|
+
const combinedCss = replaceBlockComments(`${allCss}
|
|
58297
|
+
${allInlineStyles}`, "");
|
|
58216
58298
|
const usesLottie = tags.some((t) => readAttr(t.raw, "data-lottie-src") !== null) || allScriptTexts.some((t) => /lottie\.(loadAnimation)\b|__hfLottie\b/.test(t));
|
|
58217
58299
|
const usesThree = allScriptTexts.some((t) => /\bTHREE\./.test(t));
|
|
58218
58300
|
const usesWaapi = allScriptTexts.some((t) => /\.animate\s*\(\s*[[{$A-Za-z_]/.test(t));
|
|
@@ -58600,7 +58682,7 @@ function collectStaticCssVariableDefinitions(tags, styles) {
|
|
|
58600
58682
|
];
|
|
58601
58683
|
const definitionPattern = /(?:^|[;{])\s*(--[A-Za-z0-9_-]+)\s*:/gm;
|
|
58602
58684
|
for (const source of sources) {
|
|
58603
|
-
const withoutComments2 = source
|
|
58685
|
+
const withoutComments2 = replaceBlockComments(source, " ");
|
|
58604
58686
|
for (const match of withoutComments2.matchAll(definitionPattern)) {
|
|
58605
58687
|
if (match[1]) definitions.add(match[1]);
|
|
58606
58688
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/inspector",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.51",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"htmlparser2": "^10.1.0",
|
|
44
44
|
"postcss": "^8.5.8",
|
|
45
45
|
"puppeteer-core": "^25.8.0",
|
|
46
|
-
"@hyperframes/core": "0.9.
|
|
47
|
-
"@hyperframes/parsers": "0.9.
|
|
46
|
+
"@hyperframes/core": "0.9.51",
|
|
47
|
+
"@hyperframes/parsers": "0.9.51"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^25.0.10",
|