@hyperframes/lint 0.7.20 → 0.7.21

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
@@ -1058,6 +1058,31 @@ var mediaRules = [
1058
1058
  }
1059
1059
  return findings;
1060
1060
  },
1061
+ // media_crossorigin_breaks_preview — `crossorigin` on <video>/<audio> forces a
1062
+ // CORS-checked fetch. The server-side renderer downloads media directly (no CORS),
1063
+ // so it always works there; but Studio preview runs in the browser, where a media
1064
+ // host that omits Access-Control-Allow-Origin silently fails the load — the media
1065
+ // shows BLANK/black in preview while renders look fine, hiding the bug. Plain
1066
+ // displayed media never needs crossorigin; it's only required to read pixels/samples
1067
+ // back (canvas/WebGL texture, WebAudio createMediaElementSource) AND only when the
1068
+ // host is known CORS-enabled.
1069
+ ({ tags }) => {
1070
+ const findings = [];
1071
+ for (const tag of tags) {
1072
+ if (tag.name !== "video" && tag.name !== "audio") continue;
1073
+ if (!hasAttrName(tag.raw, "crossorigin")) continue;
1074
+ const elementId = readAttr(tag.raw, "id") || void 0;
1075
+ findings.push({
1076
+ code: "media_crossorigin_breaks_preview",
1077
+ severity: "error",
1078
+ message: `<${tag.name}${elementId ? ` id="${elementId}"` : ""}> has crossorigin, which forces a CORS-checked fetch. If the media host omits Access-Control-Allow-Origin, the load silently fails in Studio preview (media shows BLANK/black) while server-side renders still work \u2014 hiding the bug.`,
1079
+ elementId,
1080
+ fixHint: "Remove the crossorigin attribute unless you read the media back via canvas/WebGL/WebAudio AND the host is known to send CORS headers. Plain displayed media never needs it.",
1081
+ snippet: truncateSnippet(tag.raw)
1082
+ });
1083
+ }
1084
+ return findings;
1085
+ },
1061
1086
  // video_audio_double_source — catches audible <video> paired with a separate
1062
1087
  // <audio> pointing to the same file, which causes double playback at runtime
1063
1088
  ({ tags }) => {