@mintlify/link-rot 3.0.1652 → 3.0.1654

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/graph.d.ts CHANGED
@@ -82,6 +82,7 @@ export declare class Graph {
82
82
  private wildcardRedirects;
83
83
  private configRedirects;
84
84
  private mintIgnoreGlobs;
85
+ private mintIgnoreMatcher;
85
86
  private virtualNodes;
86
87
  /** Snippet imports and renders of every page that parsed, keyed by file. */
87
88
  snippetReferencesByFile: Map<string, SnippetReferences>;
package/dist/graph.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isMintIgnored, resolveRelativeUrl, safeCleanHeadingId } from '@mintlify/common';
1
+ import { createMintIgnoreMatcher, isMintIgnoredBy, resolveRelativeUrl, safeCleanHeadingId, } from '@mintlify/common';
2
2
  import { getFileListWithDirectories } from '@mintlify/prebuild';
3
3
  import { existsSync } from 'fs';
4
4
  import { parse, join, resolve, dirname, basename } from 'path';
@@ -256,6 +256,7 @@ export class Graph {
256
256
  this.snippetReferencesByFile = new Map();
257
257
  this.baseDir = resolve(baseDir);
258
258
  this.mintIgnoreGlobs = mintIgnoreGlobs;
259
+ this.mintIgnoreMatcher = createMintIgnoreMatcher(mintIgnoreGlobs);
259
260
  }
260
261
  addNode(label) {
261
262
  if (this.nodes[label])
@@ -337,7 +338,7 @@ export class Graph {
337
338
  // TODO move aliases computation to mint config package, since it'll depend on version
338
339
  // for now this is a hacky implementation
339
340
  const allAliases = MdxPath.filterMapInternalPaths(getFileListWithDirectories(this.baseDir, this.baseDir, this.mintIgnoreGlobs));
340
- const aliases = allAliases.filter((alias) => !isMintIgnored(alias, this.mintIgnoreGlobs));
341
+ const aliases = allAliases.filter((alias) => !isMintIgnoredBy(alias, this.mintIgnoreMatcher));
341
342
  this.addNodes(aliases);
342
343
  }
343
344
  getNode(label) {
@@ -7,6 +7,7 @@ export declare const extractComponentAnchorIds: (tree: Root) => Set<string>;
7
7
  export declare const decorateGraphNodeFromPageContent: (graphNode: Node, content: string, options?: {
8
8
  checkSnippets?: boolean;
9
9
  }) => Promise<SnippetReferences>;
10
+ export declare const EVENT_LOOP_YIELD_INTERVAL_MS = 50;
10
11
  export declare const buildGraph: (repoPath?: string, options?: {
11
12
  checkSnippets?: boolean;
12
13
  /** SSRF-safe fetch override for hosted spec and overlay URLs; supplied by server environments. */
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { cleanHeadingId, COMPONENTS_WITH_CLEANED_ID, COMPONENTS_WITHOUT_ID, coreRemark, customHeadingIdSourceLines, generateParamFieldId, isMintIgnored, preprocessCustomHeadingIds, preprocessMdxFragmentCode, remarkComponentIds, remarkExtractTableOfContents, } from '@mintlify/common';
10
+ import { cleanHeadingId, COMPONENTS_WITH_CLEANED_ID, COMPONENTS_WITHOUT_ID, coreRemark, customHeadingIdSourceLines, generateParamFieldId, createMintIgnoreMatcher, isMintIgnoredBy, preprocessCustomHeadingIds, preprocessMdxFragmentCode, remarkComponentIds, remarkExtractTableOfContents, } from '@mintlify/common';
11
11
  import { getMintIgnore } from '@mintlify/prebuild';
12
12
  import fs from 'fs-extra';
13
13
  import path from 'path';
@@ -143,12 +143,14 @@ export const decorateGraphNodeFromPageContent = (graphNode, content, options) =>
143
143
  graphNode.headingSlugs = new Set([...tocSlugs, ...componentIds]);
144
144
  return snippetReferences;
145
145
  });
146
+ export const EVENT_LOOP_YIELD_INTERVAL_MS = 50;
146
147
  export const buildGraph = (repoPath, options) => __awaiter(void 0, void 0, void 0, function* () {
147
148
  const baseDir = repoPath ? repoPath : process.cwd();
148
149
  const mintIgnoreGlobs = yield getMintIgnore(baseDir);
150
+ const mintIgnore = createMintIgnoreMatcher(mintIgnoreGlobs);
149
151
  const graph = new Graph(baseDir, mintIgnoreGlobs);
150
152
  const allFilenames = getLinkPaths(baseDir, mintIgnoreGlobs);
151
- const filenames = allFilenames.filter((file) => !isMintIgnored(file, mintIgnoreGlobs));
153
+ const filenames = allFilenames.filter((file) => !isMintIgnoredBy(file, mintIgnore));
152
154
  graph.addNodes(filenames);
153
155
  const redirectMappings = yield getRedirects(baseDir);
154
156
  graph.setRedirects(redirectMappings);
@@ -178,12 +180,17 @@ export const buildGraph = (repoPath, options) => __awaiter(void 0, void 0, void
178
180
  }
179
181
  }
180
182
  const allSitePages = getPagePaths(baseDir, mintIgnoreGlobs);
181
- const sitePages = allSitePages.filter((file) => !isMintIgnored(file, mintIgnoreGlobs));
183
+ const sitePages = allSitePages.filter((file) => !isMintIgnoredBy(file, mintIgnore));
182
184
  const snippetReferencesByFile = new Map();
183
185
  const BUILD_GRAPH_CONCURRENCY = 8;
184
186
  let cursor = 0;
187
+ let lastYield = performance.now();
185
188
  const processNext = () => __awaiter(void 0, void 0, void 0, function* () {
186
189
  while (cursor < sitePages.length) {
190
+ if (performance.now() - lastYield > EVENT_LOOP_YIELD_INTERVAL_MS) {
191
+ yield new Promise((resolve) => setImmediate(resolve));
192
+ lastYield = performance.now();
193
+ }
187
194
  const filePath = sitePages[cursor++];
188
195
  if (filePath === undefined)
189
196
  continue;