@hyperframes/lint 0.8.43 → 0.8.44

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/index.js CHANGED
@@ -795,12 +795,12 @@ function findVisibleMarkupCommentLeak(source) {
795
795
  function readHtmlBodyCssSize(source) {
796
796
  const widthFirst = source.match(HTML_BODY_CSS_WIDTH_FIRST_RE);
797
797
  if (widthFirst) {
798
- const [, width = "", height = ""] = widthFirst;
798
+ const [, , width = "", , height = ""] = widthFirst;
799
799
  return { width, height };
800
800
  }
801
801
  const heightFirst = source.match(HTML_BODY_CSS_HEIGHT_FIRST_RE);
802
802
  if (heightFirst) {
803
- const [, height = "", width = ""] = heightFirst;
803
+ const [, , height = "", , width = ""] = heightFirst;
804
804
  return { width, height };
805
805
  }
806
806
  return null;
@@ -808,18 +808,39 @@ function readHtmlBodyCssSize(source) {
808
808
  function readViewportMetaSize(source) {
809
809
  const match = source.match(VIEWPORT_META_SIZE_RE);
810
810
  if (!match) return null;
811
- const [, width = "", height = ""] = match;
811
+ const [, , width = "", , height = ""] = match;
812
812
  return { width, height };
813
813
  }
814
814
  function describeSizeMismatch(label, size, dataWidth, dataHeight) {
815
815
  if (!size || size.width === dataWidth && size.height === dataHeight) return null;
816
816
  return `${label} is ${size.width}x${size.height}`;
817
817
  }
818
- function findScaffoldSizeMismatches(source, dataWidth, dataHeight) {
819
- return [
820
- describeSizeMismatch("html/body CSS", readHtmlBodyCssSize(source), dataWidth, dataHeight),
821
- describeSizeMismatch("the viewport meta", readViewportMetaSize(source), dataWidth, dataHeight)
822
- ].filter((mismatch) => mismatch !== null);
818
+ function describeRootDimensionsDrift(source, dataWidth, dataHeight) {
819
+ const bodyCssMismatch = describeSizeMismatch(
820
+ "html/body CSS",
821
+ readHtmlBodyCssSize(source),
822
+ dataWidth,
823
+ dataHeight
824
+ );
825
+ const viewportMismatch = describeSizeMismatch(
826
+ "the viewport meta",
827
+ readViewportMetaSize(source),
828
+ dataWidth,
829
+ dataHeight
830
+ );
831
+ if (!bodyCssMismatch && !viewportMismatch) return null;
832
+ const declared = `Root composition declares data-width="${dataWidth}" data-height="${dataHeight}"`;
833
+ if (!bodyCssMismatch) {
834
+ return {
835
+ message: `${declared}, but ${viewportMismatch}. The viewport meta has no effect on capture \u2014 the renderer sizes the viewport from the root's own data-width/data-height \u2014 so this is stale metadata, not a clipping risk.`,
836
+ fixHint: "update the meta viewport to match, or scaffold with `hyperframes init --resolution portrait`"
837
+ };
838
+ }
839
+ const mismatches = viewportMismatch ? `${bodyCssMismatch} and ${viewportMismatch}` : bodyCssMismatch;
840
+ return {
841
+ message: `${declared}, but ${mismatches}. The scaffolded body clips the composition at its old size.`,
842
+ fixHint: "update html/body CSS and the meta viewport to match, or scaffold with `hyperframes init --resolution portrait`"
843
+ };
823
844
  }
824
845
  var coreRules = [
825
846
  // id_requires_css_escape
@@ -876,22 +897,24 @@ var coreRules = [
876
897
  // root. `hyperframes check`'s layout audits can't see it: they measure
877
898
  // against the root's own (already-correct) rect, not the body's.
878
899
  //
879
- // A sub-composition fragment has no html/body or viewport to compare
880
- // against, which makes this top-level-only without a separate guard.
881
- ({ rootTag, source }) => {
882
- if (!rootTag) return [];
900
+ // Sub-compositions are exempt: loadExternalCompositions (packages/core/src/
901
+ // runtime/compositionLoader.ts) mounts only the matched <template>/<body>
902
+ // subtree, so a sub-comp's own <html>/<head>/<meta viewport> never reach
903
+ // the rendering document, even when it's a full standalone document.
904
+ ({ rootTag, source, options }) => {
905
+ if (!rootTag || options.isSubComposition) return [];
883
906
  const dataWidth = readAttr(rootTag.raw, "data-width");
884
907
  const dataHeight = readAttr(rootTag.raw, "data-height");
885
908
  if (!dataWidth || !dataHeight) return [];
886
- const mismatches = findScaffoldSizeMismatches(source, dataWidth, dataHeight);
887
- if (mismatches.length === 0) return [];
909
+ const drift = describeRootDimensionsDrift(source, dataWidth, dataHeight);
910
+ if (!drift) return [];
888
911
  return [
889
912
  {
890
913
  code: "root_dimensions_mismatch",
891
914
  severity: "warning",
892
- message: `Root composition declares data-width="${dataWidth}" data-height="${dataHeight}", but ${mismatches.join(" and ")}. The scaffolded body clips the composition at its old size.`,
915
+ message: drift.message,
893
916
  elementId: readAttr(rootTag.raw, "id") || void 0,
894
- fixHint: "update html/body CSS and the meta viewport to match, or scaffold with `hyperframes init --resolution portrait`",
917
+ fixHint: drift.fixHint,
895
918
  snippet: truncateSnippet(rootTag.raw)
896
919
  }
897
920
  ];