@hyperframes/lint 0.7.90 → 0.7.93

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 {
@@ -4932,6 +4934,7 @@ async function probeIsHevc(ffprobePath, filePath) {
4932
4934
  "stream=codec_name",
4933
4935
  "-of",
4934
4936
  "json",
4937
+ "--",
4935
4938
  filePath
4936
4939
  ]);
4937
4940
  return hasHevcStream(JSON.parse(stdout));
@@ -4952,7 +4955,7 @@ function collectLocalVideoCandidates(projectDir, htmlSources) {
4952
4955
  const src = cleanAssetUrl(rawSrc);
4953
4956
  if (!src) continue;
4954
4957
  if (isRemoteOrInlineUrl(src)) continue;
4955
- const rootRelative = compSrcPath ? rewriteAssetPath(compSrcPath, src) : src;
4958
+ const rootRelative = compSrcPath ? rewriteAssetPath(compSrcPath, src, (path) => existsSync(join(projectDir, path))) : src;
4956
4959
  const resolvedAsset = resolveExistingLocalAsset(projectDir, rootRelative);
4957
4960
  if (!resolvedAsset) continue;
4958
4961
  if (!candidates.has(resolvedAsset.resolved)) candidates.set(resolvedAsset.resolved, src);
@@ -5015,7 +5018,7 @@ function collectLocalStylesheets(projectDir, document, compSrcPath) {
5015
5018
  if (!rel.split(/\s+/).some((part) => part.toLowerCase() === "stylesheet")) continue;
5016
5019
  const href = link.getAttribute("href") ?? "";
5017
5020
  if (!isLocalStylesheetHref(href)) continue;
5018
- const rootRelative = compSrcPath ? join(dirname(compSrcPath), href) : href;
5021
+ const rootRelative = compSrcPath ? join2(dirname(compSrcPath), href) : href;
5019
5022
  const stylesheet = resolveExistingLocalAsset2(projectDir, rootRelative);
5020
5023
  if (!stylesheet) continue;
5021
5024
  styles.push({
@@ -5057,10 +5060,13 @@ function collectCssSources(projectDir, html, compSrcPath) {
5057
5060
  function resolveCssAssetCandidates(projectDir, url, htmlCompSrcPath, cssRootRelativePath) {
5058
5061
  if (url.startsWith("/")) return resolveLocalAssetCandidates(projectDir, url);
5059
5062
  if (cssRootRelativePath) {
5060
- return resolveLocalAssetCandidates(projectDir, join(dirname(cssRootRelativePath), url));
5063
+ return resolveLocalAssetCandidates(projectDir, join2(dirname(cssRootRelativePath), url));
5061
5064
  }
5062
5065
  if (htmlCompSrcPath) {
5063
- return resolveLocalAssetCandidates(projectDir, rewriteAssetPath2(htmlCompSrcPath, url));
5066
+ return resolveLocalAssetCandidates(
5067
+ projectDir,
5068
+ rewriteAssetPath2(htmlCompSrcPath, url, (path) => existsSync2(join2(projectDir, path)))
5069
+ );
5064
5070
  }
5065
5071
  return resolveLocalAssetCandidates(projectDir, url);
5066
5072
  }
@@ -5086,14 +5092,14 @@ async function lintProject(projectDir, entryFile) {
5086
5092
  totalInfos += rootResult.infoCount;
5087
5093
  const allHtmlSources = [{ html: rootHtml, compSrcPath: rootCompSrcPath }];
5088
5094
  const compositionsDir = resolve(projectDir, "compositions");
5089
- if (!entryFile && existsSync(compositionsDir)) {
5095
+ if (!entryFile && existsSync2(compositionsDir)) {
5090
5096
  const collectHtmlFiles = (dir, rel) => {
5091
5097
  const out = [];
5092
5098
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
5093
5099
  const relPath = rel ? `${rel}/${entry.name}` : entry.name;
5094
5100
  if (entry.isDirectory()) {
5095
5101
  if (!rel && entry.name === "components") continue;
5096
- out.push(...collectHtmlFiles(join(dir, entry.name), relPath));
5102
+ out.push(...collectHtmlFiles(join2(dir, entry.name), relPath));
5097
5103
  } else if (entry.isFile() && entry.name.endsWith(".html") && !entry.name.startsWith("._")) {
5098
5104
  out.push(relPath);
5099
5105
  }
@@ -5102,7 +5108,7 @@ async function lintProject(projectDir, entryFile) {
5102
5108
  };
5103
5109
  const files = collectHtmlFiles(compositionsDir, "").sort();
5104
5110
  for (const file of files) {
5105
- const filePath = join(compositionsDir, file);
5111
+ const filePath = join2(compositionsDir, file);
5106
5112
  const html = readFileSync(filePath, "utf-8");
5107
5113
  const compSrcPath = `compositions/${file}`;
5108
5114
  allHtmlSources.push({ html, compSrcPath });
@@ -5178,8 +5184,8 @@ function lintAudioSrcNotFound(projectDir, htmlSources) {
5178
5184
  const src = match[1];
5179
5185
  if (/^(https?:|data:|blob:)/i.test(src)) continue;
5180
5186
  if (isUnresolvedAssetPlaceholder2(src)) continue;
5181
- const rootRelative = compSrcPath ? rewriteAssetPath2(compSrcPath, src) : src;
5182
- if (!resolveLocalAssetCandidates(projectDir, rootRelative).some(existsSync)) {
5187
+ const rootRelative = compSrcPath ? rewriteAssetPath2(compSrcPath, src, (path) => existsSync2(join2(projectDir, path))) : src;
5188
+ if (!resolveLocalAssetCandidates(projectDir, rootRelative).some(existsSync2)) {
5183
5189
  missingSrcs.push(src);
5184
5190
  }
5185
5191
  }
@@ -5210,7 +5216,7 @@ function lintMissingLocalAsset(projectDir, htmlSources) {
5210
5216
  const src = cleanAssetUrl2(rawSrc);
5211
5217
  if (!src) continue;
5212
5218
  if (isRemoteOrInlineUrl2(src)) continue;
5213
- const rootRelative = compSrcPath ? rewriteAssetPath2(compSrcPath, src) : src;
5219
+ const rootRelative = compSrcPath ? rewriteAssetPath2(compSrcPath, src, (path) => existsSync2(join2(projectDir, path))) : src;
5214
5220
  const resolvedAsset = resolveExistingLocalAsset2(projectDir, rootRelative);
5215
5221
  if (resolvedAsset) continue;
5216
5222
  const resolvedKey = resolve(projectDir, rootRelative);
@@ -5250,7 +5256,7 @@ function lintTextureMaskAssetNotFound(projectDir, htmlSources) {
5250
5256
  compSrcPath,
5251
5257
  cssSource.rootRelativePath
5252
5258
  );
5253
- if (candidates.some(existsSync)) continue;
5259
+ if (candidates.some(existsSync2)) continue;
5254
5260
  missing.set(url, candidates[0] ?? resolve(projectDir, url));
5255
5261
  }
5256
5262
  }
@@ -5275,7 +5281,7 @@ function lintMultipleRootCompositions(projectDir) {
5275
5281
  const rootCompositions = [];
5276
5282
  for (const file of rootHtmlFiles) {
5277
5283
  if (file === "caption-skin.html") continue;
5278
- const content = readFileSync(join(projectDir, file), "utf-8");
5284
+ const content = readFileSync(join2(projectDir, file), "utf-8");
5279
5285
  if (/data-composition-id/i.test(content)) {
5280
5286
  rootCompositions.push(file);
5281
5287
  }
@@ -5351,7 +5357,7 @@ function lintMissingOrEmptySubComposition(projectDir, rootHtml) {
5351
5357
  const filePath = resolve(projectDir, srcPath);
5352
5358
  if (visited.has(filePath)) continue;
5353
5359
  visited.add(filePath);
5354
- if (!existsSync(filePath)) {
5360
+ if (!existsSync2(filePath)) {
5355
5361
  if (!checked.has(srcPath)) {
5356
5362
  checked.set(srcPath, { srcPath, problem: "the file does not exist" });
5357
5363
  }