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