@hyperframes/lint 0.9.26 → 0.9.28-alpha.0

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/browser.js CHANGED
@@ -2846,6 +2846,7 @@ function containingCallOffset(script, tokenOffset) {
2846
2846
 
2847
2847
  // src/rules/composition.ts
2848
2848
  import selectorParser2 from "postcss-selector-parser";
2849
+ import { parseHTML as parseHTML2 } from "linkedom";
2849
2850
  import {
2850
2851
  COMPOSITION_VARIABLE_TYPES,
2851
2852
  isCompositionVariable,
@@ -4222,6 +4223,28 @@ ${allInlineStyles}`.replace(/\/\*[\s\S]*?\*\//g, "");
4222
4223
  fixHint: `Move the #${rootId} rules into a <style> inside the <template>, where they are rewritten for the merged root, or select a child element of the root in the linked file instead of the root itself.`,
4223
4224
  snippet: truncateSnippet(style.content.slice(0, 120))
4224
4225
  }));
4226
+ },
4227
+ // multiple_scene_templates: the renderer takes the first scene template of a file with no live root.
4228
+ ({ rawSource }) => {
4229
+ const { document } = parseHTML2(rawSource);
4230
+ if (document.querySelector("[data-composition-id]")) return [];
4231
+ const scenes = Array.from(document.querySelectorAll("template")).flatMap((template, index) => {
4232
+ const compositionId = parseHTML2(template.innerHTML).document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id");
4233
+ if (compositionId === void 0) return [];
4234
+ const id = template.getAttribute("id");
4235
+ return [
4236
+ `template #${index + 1}${id ? ` (id="${id}")` : ""} holding composition "${compositionId}"`
4237
+ ];
4238
+ });
4239
+ if (scenes.length < 2) return [];
4240
+ return [
4241
+ {
4242
+ code: "multiple_scene_templates",
4243
+ severity: "warning",
4244
+ message: `This file has more than one scene template and no live composition root, so only the first renders: ${scenes.join("; ")}.`,
4245
+ fixHint: "Keep one composition root per file, or move the other scenes into their own files."
4246
+ }
4247
+ ];
4225
4248
  }
4226
4249
  ];
4227
4250
  var CLIP_MEDIA_TAGS = /* @__PURE__ */ new Set(["img", "video", "audio"]);
package/dist/index.js CHANGED
@@ -2852,6 +2852,7 @@ function containingCallOffset(script, tokenOffset) {
2852
2852
 
2853
2853
  // src/rules/composition.ts
2854
2854
  import selectorParser2 from "postcss-selector-parser";
2855
+ import { parseHTML as parseHTML2 } from "linkedom";
2855
2856
  import {
2856
2857
  COMPOSITION_VARIABLE_TYPES,
2857
2858
  isCompositionVariable,
@@ -4228,6 +4229,28 @@ ${allInlineStyles}`.replace(/\/\*[\s\S]*?\*\//g, "");
4228
4229
  fixHint: `Move the #${rootId} rules into a <style> inside the <template>, where they are rewritten for the merged root, or select a child element of the root in the linked file instead of the root itself.`,
4229
4230
  snippet: truncateSnippet(style.content.slice(0, 120))
4230
4231
  }));
4232
+ },
4233
+ // multiple_scene_templates: the renderer takes the first scene template of a file with no live root.
4234
+ ({ rawSource }) => {
4235
+ const { document } = parseHTML2(rawSource);
4236
+ if (document.querySelector("[data-composition-id]")) return [];
4237
+ const scenes = Array.from(document.querySelectorAll("template")).flatMap((template, index) => {
4238
+ const compositionId = parseHTML2(template.innerHTML).document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id");
4239
+ if (compositionId === void 0) return [];
4240
+ const id = template.getAttribute("id");
4241
+ return [
4242
+ `template #${index + 1}${id ? ` (id="${id}")` : ""} holding composition "${compositionId}"`
4243
+ ];
4244
+ });
4245
+ if (scenes.length < 2) return [];
4246
+ return [
4247
+ {
4248
+ code: "multiple_scene_templates",
4249
+ severity: "warning",
4250
+ message: `This file has more than one scene template and no live composition root, so only the first renders: ${scenes.join("; ")}.`,
4251
+ fixHint: "Keep one composition root per file, or move the other scenes into their own files."
4252
+ }
4253
+ ];
4231
4254
  }
4232
4255
  ];
4233
4256
  var CLIP_MEDIA_TAGS = /* @__PURE__ */ new Set(["img", "video", "audio"]);
@@ -7296,7 +7319,7 @@ import {
7296
7319
  resolveReferencedStart
7297
7320
  } from "@hyperframes/parsers/reference-resolver";
7298
7321
  import { checkSubCompositionUsability } from "@hyperframes/parsers/sub-composition-validity";
7299
- import { parseHTML as parseHTML3 } from "linkedom";
7322
+ import { parseHTML as parseHTML4 } from "linkedom";
7300
7323
  import postcss5 from "postcss";
7301
7324
  import {
7302
7325
  cleanAssetUrl as cleanAssetUrl2,
@@ -7327,7 +7350,7 @@ import {
7327
7350
  maskNonScannableRanges,
7328
7351
  resolveExistingLocalAsset
7329
7352
  } from "@hyperframes/parsers/asset-resolution";
7330
- import { parseHTML as parseHTML2 } from "linkedom";
7353
+ import { parseHTML as parseHTML3 } from "linkedom";
7331
7354
  var PROBE_TIMEOUT_MS = 4e3;
7332
7355
  var PROBE_CONCURRENCY = 8;
7333
7356
  function execFileAsync(file, args) {
@@ -7406,7 +7429,7 @@ function collectLocalVideoCandidates(projectDir, htmlSources) {
7406
7429
  return candidates;
7407
7430
  }
7408
7431
  function collectVideoElements(html) {
7409
- const { document } = parseHTML2(html);
7432
+ const { document } = parseHTML3(html);
7410
7433
  const roots = [document];
7411
7434
  const videos = [];
7412
7435
  for (let index = 0; index < roots.length; index++) {
@@ -7605,7 +7628,7 @@ function lintProjectShaderScripts(projectDir, sources) {
7605
7628
 
7606
7629
  // src/project.ts
7607
7630
  function parseSubCompHtml(html) {
7608
- return parseHTML3(html).document;
7631
+ return parseHTML4(html).document;
7609
7632
  }
7610
7633
  var sourceFile = (projectDir, compSrcPath) => resolve(projectDir, compSrcPath ?? "index.html");
7611
7634
  function querySelectorAllIncludingTemplates(root, selector) {
@@ -7650,7 +7673,7 @@ function collectLocalStylesheets(projectDir, document, compSrcPath) {
7650
7673
  }
7651
7674
  function collectExternalStyles(projectDir, html, compSrcPath) {
7652
7675
  const styles = [];
7653
- const { document } = parseHTML3(html);
7676
+ const { document } = parseHTML4(html);
7654
7677
  for (const { href, content, rootRelativePath } of collectLocalStylesheets(
7655
7678
  projectDir,
7656
7679
  document,
@@ -7669,7 +7692,7 @@ function linkedSources(projectDir, html, compSrcPath) {
7669
7692
  }
7670
7693
  function collectExternalScripts(projectDir, html, compSrcPath) {
7671
7694
  const scripts = [];
7672
- const { document } = parseHTML3(html);
7695
+ const { document } = parseHTML4(html);
7673
7696
  for (const element of querySelectorAllIncludingTemplates(document, "script[src]")) {
7674
7697
  const src = element.getAttribute("src") ?? "";
7675
7698
  if (!isLocalStylesheetHref(src) || /\.min\.m?js(?:[?#]|$)/i.test(src)) continue;
@@ -7692,7 +7715,7 @@ function collectExternalScripts(projectDir, html, compSrcPath) {
7692
7715
  }
7693
7716
  function collectCssSources(projectDir, html, compSrcPath) {
7694
7717
  const sources = [];
7695
- const { document } = parseHTML3(html);
7718
+ const { document } = parseHTML4(html);
7696
7719
  for (const style of querySelectorAllIncludingTemplates(document, "style")) {
7697
7720
  sources.push({ content: style.textContent ?? "" });
7698
7721
  }
@@ -7727,7 +7750,7 @@ function mountedSources(projectDir, rootHtml, rootCompSrcPath) {
7727
7750
  const sources = [{ html: rootHtml, compSrcPath: rootCompSrcPath }];
7728
7751
  const seen = /* @__PURE__ */ new Set();
7729
7752
  for (const source of sources) {
7730
- const { document } = parseHTML3(source.html);
7753
+ const { document } = parseHTML4(source.html);
7731
7754
  for (const host of querySelectorAllIncludingTemplates(document, "[data-composition-src]")) {
7732
7755
  const src = host.getAttribute("data-composition-src")?.trim();
7733
7756
  if (!src || isUnresolvedAssetPlaceholder2(src) || isRemoteOrInlineUrl2(src)) continue;
@@ -7747,7 +7770,7 @@ function mountedSources(projectDir, rootHtml, rootCompSrcPath) {
7747
7770
  function declaredProjectFontFamilies(projectDir, sources) {
7748
7771
  const families = /* @__PURE__ */ new Set();
7749
7772
  for (const { html, compSrcPath } of sources) {
7750
- const { document } = parseHTML3(html);
7773
+ const { document } = parseHTML4(html);
7751
7774
  const styles = [
7752
7775
  ...querySelectorAllIncludingTemplates(document, "style").map((style) => ({
7753
7776
  content: style.textContent ?? ""
@@ -7868,7 +7891,7 @@ async function lintProject(projectDir, entryFile, hostOptions = {}, { includeUnm
7868
7891
  return { results, totalErrors, totalWarnings, totalInfos, unmountedCompositions };
7869
7892
  }
7870
7893
  function lintBlankRootWithStandaloneComposition(rootHtml, htmlSources) {
7871
- const { document: rootDocument } = parseHTML3(rootHtml);
7894
+ const { document: rootDocument } = parseHTML4(rootHtml);
7872
7895
  const root = rootDocument.querySelector("body [data-composition-id]");
7873
7896
  if (!root || root.querySelector("*:not(script):not(style):not(link):not(meta):not(template)")) {
7874
7897
  return [];
@@ -7876,7 +7899,7 @@ function lintBlankRootWithStandaloneComposition(rootHtml, htmlSources) {
7876
7899
  const standaloneCandidates = [];
7877
7900
  for (const source of htmlSources) {
7878
7901
  if (!source.compSrcPath) continue;
7879
- const { document } = parseHTML3(source.html);
7902
+ const { document } = parseHTML4(source.html);
7880
7903
  const composition = document.querySelector("body [data-composition-id]");
7881
7904
  if (!composition) continue;
7882
7905
  const authoredTimedContent = Array.from(
@@ -8074,7 +8097,7 @@ function lintLinkedStylesheetAssets(projectDir, htmlSources) {
8074
8097
  for (const { html, compSrcPath } of htmlSources) {
8075
8098
  for (const { content, rootRelativePath } of collectLocalStylesheets(
8076
8099
  projectDir,
8077
- parseHTML3(html).document,
8100
+ parseHTML4(html).document,
8078
8101
  compSrcPath
8079
8102
  )) {
8080
8103
  let root;
@@ -8141,7 +8164,7 @@ var localDuration = (file, el) => resolveReferencedDuration(file.doc, el, file.s
8141
8164
  function collectMainTimelineAudio(projectDir, rootHtml) {
8142
8165
  const spans = [];
8143
8166
  const mount = (html, at) => {
8144
- const { document: document2 } = parseHTML3(html);
8167
+ const { document: document2 } = parseHTML4(html);
8145
8168
  const root = querySelectorAllIncludingTemplates(document2, "[data-composition-id]")[0];
8146
8169
  if (root) visit(root, { ...at, file: timingFile(document2) });
8147
8170
  };
@@ -8170,7 +8193,7 @@ function collectMainTimelineAudio(projectDir, rootHtml) {
8170
8193
  visit(el, inner);
8171
8194
  }
8172
8195
  };
8173
- const { document } = parseHTML3(rootHtml);
8196
+ const { document } = parseHTML4(rootHtml);
8174
8197
  visit(document, { file: timingFile(document), origin: 0, slots: [], mounting: [] });
8175
8198
  return spans;
8176
8199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/lint",
3
- "version": "0.9.26",
3
+ "version": "0.9.28-alpha.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/heygen-com/hyperframes",
@@ -36,7 +36,7 @@
36
36
  "linkedom": "^0.18.12",
37
37
  "postcss": "^8.5.8",
38
38
  "postcss-selector-parser": "^7.1.4",
39
- "@hyperframes/parsers": "0.9.26"
39
+ "@hyperframes/parsers": "0.9.28-alpha.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^25.0.10",