@hyperframes/lint 0.7.90 → 0.7.92

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
@@ -4876,8 +4876,8 @@ function shouldBlockRender(strictErrors, strictAll, totalErrors, totalWarnings)
4876
4876
  }
4877
4877
 
4878
4878
  // src/project.ts
4879
- import { existsSync, readFileSync, readdirSync } from "fs";
4880
- import { dirname, extname, join, relative, resolve } from "path";
4879
+ import { existsSync as existsSync2, readFileSync, readdirSync } from "fs";
4880
+ import { dirname, extname, join as join2, relative, resolve } from "path";
4881
4881
  import { rewriteAssetPath as rewriteAssetPath2 } from "@hyperframes/parsers/asset-paths";
4882
4882
  import { checkSubCompositionUsability } from "@hyperframes/parsers/sub-composition-validity";
4883
4883
  import { parseHTML } from "linkedom";
@@ -4893,6 +4893,8 @@ import {
4893
4893
 
4894
4894
  // src/hevcPreviewLint.ts
4895
4895
  import { execFile } from "child_process";
4896
+ import { existsSync } from "fs";
4897
+ import { join } from "path";
4896
4898
  import { rewriteAssetPath } from "@hyperframes/parsers/asset-paths";
4897
4899
  import { findFfBinary } from "@hyperframes/parsers/ff-binaries";
4898
4900
  import {
@@ -4952,7 +4954,7 @@ function collectLocalVideoCandidates(projectDir, htmlSources) {
4952
4954
  const src = cleanAssetUrl(rawSrc);
4953
4955
  if (!src) continue;
4954
4956
  if (isRemoteOrInlineUrl(src)) continue;
4955
- const rootRelative = compSrcPath ? rewriteAssetPath(compSrcPath, src) : src;
4957
+ const rootRelative = compSrcPath ? rewriteAssetPath(compSrcPath, src, (path) => existsSync(join(projectDir, path))) : src;
4956
4958
  const resolvedAsset = resolveExistingLocalAsset(projectDir, rootRelative);
4957
4959
  if (!resolvedAsset) continue;
4958
4960
  if (!candidates.has(resolvedAsset.resolved)) candidates.set(resolvedAsset.resolved, src);
@@ -5015,7 +5017,7 @@ function collectLocalStylesheets(projectDir, document, compSrcPath) {
5015
5017
  if (!rel.split(/\s+/).some((part) => part.toLowerCase() === "stylesheet")) continue;
5016
5018
  const href = link.getAttribute("href") ?? "";
5017
5019
  if (!isLocalStylesheetHref(href)) continue;
5018
- const rootRelative = compSrcPath ? join(dirname(compSrcPath), href) : href;
5020
+ const rootRelative = compSrcPath ? join2(dirname(compSrcPath), href) : href;
5019
5021
  const stylesheet = resolveExistingLocalAsset2(projectDir, rootRelative);
5020
5022
  if (!stylesheet) continue;
5021
5023
  styles.push({
@@ -5057,10 +5059,13 @@ function collectCssSources(projectDir, html, compSrcPath) {
5057
5059
  function resolveCssAssetCandidates(projectDir, url, htmlCompSrcPath, cssRootRelativePath) {
5058
5060
  if (url.startsWith("/")) return resolveLocalAssetCandidates(projectDir, url);
5059
5061
  if (cssRootRelativePath) {
5060
- return resolveLocalAssetCandidates(projectDir, join(dirname(cssRootRelativePath), url));
5062
+ return resolveLocalAssetCandidates(projectDir, join2(dirname(cssRootRelativePath), url));
5061
5063
  }
5062
5064
  if (htmlCompSrcPath) {
5063
- return resolveLocalAssetCandidates(projectDir, rewriteAssetPath2(htmlCompSrcPath, url));
5065
+ return resolveLocalAssetCandidates(
5066
+ projectDir,
5067
+ rewriteAssetPath2(htmlCompSrcPath, url, (path) => existsSync2(join2(projectDir, path)))
5068
+ );
5064
5069
  }
5065
5070
  return resolveLocalAssetCandidates(projectDir, url);
5066
5071
  }
@@ -5086,14 +5091,14 @@ async function lintProject(projectDir, entryFile) {
5086
5091
  totalInfos += rootResult.infoCount;
5087
5092
  const allHtmlSources = [{ html: rootHtml, compSrcPath: rootCompSrcPath }];
5088
5093
  const compositionsDir = resolve(projectDir, "compositions");
5089
- if (!entryFile && existsSync(compositionsDir)) {
5094
+ if (!entryFile && existsSync2(compositionsDir)) {
5090
5095
  const collectHtmlFiles = (dir, rel) => {
5091
5096
  const out = [];
5092
5097
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
5093
5098
  const relPath = rel ? `${rel}/${entry.name}` : entry.name;
5094
5099
  if (entry.isDirectory()) {
5095
5100
  if (!rel && entry.name === "components") continue;
5096
- out.push(...collectHtmlFiles(join(dir, entry.name), relPath));
5101
+ out.push(...collectHtmlFiles(join2(dir, entry.name), relPath));
5097
5102
  } else if (entry.isFile() && entry.name.endsWith(".html") && !entry.name.startsWith("._")) {
5098
5103
  out.push(relPath);
5099
5104
  }
@@ -5102,7 +5107,7 @@ async function lintProject(projectDir, entryFile) {
5102
5107
  };
5103
5108
  const files = collectHtmlFiles(compositionsDir, "").sort();
5104
5109
  for (const file of files) {
5105
- const filePath = join(compositionsDir, file);
5110
+ const filePath = join2(compositionsDir, file);
5106
5111
  const html = readFileSync(filePath, "utf-8");
5107
5112
  const compSrcPath = `compositions/${file}`;
5108
5113
  allHtmlSources.push({ html, compSrcPath });
@@ -5178,8 +5183,8 @@ function lintAudioSrcNotFound(projectDir, htmlSources) {
5178
5183
  const src = match[1];
5179
5184
  if (/^(https?:|data:|blob:)/i.test(src)) continue;
5180
5185
  if (isUnresolvedAssetPlaceholder2(src)) continue;
5181
- const rootRelative = compSrcPath ? rewriteAssetPath2(compSrcPath, src) : src;
5182
- if (!resolveLocalAssetCandidates(projectDir, rootRelative).some(existsSync)) {
5186
+ const rootRelative = compSrcPath ? rewriteAssetPath2(compSrcPath, src, (path) => existsSync2(join2(projectDir, path))) : src;
5187
+ if (!resolveLocalAssetCandidates(projectDir, rootRelative).some(existsSync2)) {
5183
5188
  missingSrcs.push(src);
5184
5189
  }
5185
5190
  }
@@ -5210,7 +5215,7 @@ function lintMissingLocalAsset(projectDir, htmlSources) {
5210
5215
  const src = cleanAssetUrl2(rawSrc);
5211
5216
  if (!src) continue;
5212
5217
  if (isRemoteOrInlineUrl2(src)) continue;
5213
- const rootRelative = compSrcPath ? rewriteAssetPath2(compSrcPath, src) : src;
5218
+ const rootRelative = compSrcPath ? rewriteAssetPath2(compSrcPath, src, (path) => existsSync2(join2(projectDir, path))) : src;
5214
5219
  const resolvedAsset = resolveExistingLocalAsset2(projectDir, rootRelative);
5215
5220
  if (resolvedAsset) continue;
5216
5221
  const resolvedKey = resolve(projectDir, rootRelative);
@@ -5250,7 +5255,7 @@ function lintTextureMaskAssetNotFound(projectDir, htmlSources) {
5250
5255
  compSrcPath,
5251
5256
  cssSource.rootRelativePath
5252
5257
  );
5253
- if (candidates.some(existsSync)) continue;
5258
+ if (candidates.some(existsSync2)) continue;
5254
5259
  missing.set(url, candidates[0] ?? resolve(projectDir, url));
5255
5260
  }
5256
5261
  }
@@ -5275,7 +5280,7 @@ function lintMultipleRootCompositions(projectDir) {
5275
5280
  const rootCompositions = [];
5276
5281
  for (const file of rootHtmlFiles) {
5277
5282
  if (file === "caption-skin.html") continue;
5278
- const content = readFileSync(join(projectDir, file), "utf-8");
5283
+ const content = readFileSync(join2(projectDir, file), "utf-8");
5279
5284
  if (/data-composition-id/i.test(content)) {
5280
5285
  rootCompositions.push(file);
5281
5286
  }
@@ -5351,7 +5356,7 @@ function lintMissingOrEmptySubComposition(projectDir, rootHtml) {
5351
5356
  const filePath = resolve(projectDir, srcPath);
5352
5357
  if (visited.has(filePath)) continue;
5353
5358
  visited.add(filePath);
5354
- if (!existsSync(filePath)) {
5359
+ if (!existsSync2(filePath)) {
5355
5360
  if (!checked.has(srcPath)) {
5356
5361
  checked.set(srcPath, { srcPath, problem: "the file does not exist" });
5357
5362
  }