@qualcomm-ui/mdx-vite 3.6.1 → 3.7.1
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/cli.js +45 -6
- package/dist/cli.js.map +2 -2
- package/dist/docs-plugin/link-validator.d.ts +8 -3
- package/dist/docs-plugin/link-validator.d.ts.map +1 -1
- package/dist/docs-plugin/markdown/markdown-file-reader.d.ts +2 -0
- package/dist/docs-plugin/markdown/markdown-file-reader.d.ts.map +1 -1
- package/dist/docs-plugin/mdx-plugins.d.ts.map +1 -1
- package/dist/docs-plugin/search-indexer.d.ts +1 -0
- package/dist/docs-plugin/search-indexer.d.ts.map +1 -1
- package/dist/index.js +47 -7
- package/dist/index.js.map +2 -2
- package/dist/tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3789,6 +3789,7 @@ var MdxFileReader = class {
|
|
|
3789
3789
|
}
|
|
3790
3790
|
this.cachedFileCount++;
|
|
3791
3791
|
return {
|
|
3792
|
+
collectedLinks: cached.collectedLinks,
|
|
3792
3793
|
frontmatter: cached.frontmatter,
|
|
3793
3794
|
page: cached.page,
|
|
3794
3795
|
pageDocProps: cached.pageDocProps,
|
|
@@ -4662,7 +4663,28 @@ function collectLinks(tree, sourceFile, sourcePathname) {
|
|
|
4662
4663
|
});
|
|
4663
4664
|
return links;
|
|
4664
4665
|
}
|
|
4665
|
-
function
|
|
4666
|
+
function getLiteralAttributeValue(node, name) {
|
|
4667
|
+
const attr = node.attributes.find(
|
|
4668
|
+
(attribute) => attribute.type === "mdxJsxAttribute" && attribute.name === name
|
|
4669
|
+
);
|
|
4670
|
+
return typeof attr?.value === "string" ? attr.value : void 0;
|
|
4671
|
+
}
|
|
4672
|
+
function collectAnchorIds(tree) {
|
|
4673
|
+
const anchorIds = /* @__PURE__ */ new Set();
|
|
4674
|
+
const collectAnchorId = (node) => {
|
|
4675
|
+
if (node.name !== "a") {
|
|
4676
|
+
return;
|
|
4677
|
+
}
|
|
4678
|
+
const id = getLiteralAttributeValue(node, "id");
|
|
4679
|
+
if (id) {
|
|
4680
|
+
anchorIds.add(id);
|
|
4681
|
+
}
|
|
4682
|
+
};
|
|
4683
|
+
visit11(tree, "mdxJsxFlowElement", collectAnchorId);
|
|
4684
|
+
visit11(tree, "mdxJsxTextElement", collectAnchorId);
|
|
4685
|
+
return anchorIds;
|
|
4686
|
+
}
|
|
4687
|
+
function validateLinks(links, pageMap, docPropIds, anchorIds) {
|
|
4666
4688
|
const invalid = [];
|
|
4667
4689
|
for (const link of links) {
|
|
4668
4690
|
const page = pageMap[link.targetPathname];
|
|
@@ -4673,7 +4695,8 @@ function validateLinks(links, pageMap, docPropIds) {
|
|
|
4673
4695
|
if (link.fragment) {
|
|
4674
4696
|
const inToc = page.toc?.some((h) => h.id === link.fragment);
|
|
4675
4697
|
const inDocProps = docPropIds?.[link.targetPathname]?.has(link.fragment);
|
|
4676
|
-
|
|
4698
|
+
const inAnchorIds = anchorIds?.[link.targetPathname]?.has(link.fragment);
|
|
4699
|
+
if (!inToc && !inDocProps && !inAnchorIds) {
|
|
4677
4700
|
invalid.push({ ...link, reason: "fragment-not-found" });
|
|
4678
4701
|
}
|
|
4679
4702
|
}
|
|
@@ -5449,6 +5472,7 @@ var SearchIndexer = class {
|
|
|
5449
5472
|
allowedHeadings;
|
|
5450
5473
|
metaJson;
|
|
5451
5474
|
_collectedLinks = [];
|
|
5475
|
+
_anchorIds = {};
|
|
5452
5476
|
_docPropIds = {};
|
|
5453
5477
|
routeMetaNav = {};
|
|
5454
5478
|
config;
|
|
@@ -5478,6 +5502,7 @@ var SearchIndexer = class {
|
|
|
5478
5502
|
reset() {
|
|
5479
5503
|
this.mdxFileReader.reset();
|
|
5480
5504
|
this._collectedLinks = [];
|
|
5505
|
+
this._anchorIds = {};
|
|
5481
5506
|
this._docPropIds = {};
|
|
5482
5507
|
this._pageMap = {};
|
|
5483
5508
|
this._searchIndex = [];
|
|
@@ -5574,9 +5599,22 @@ var SearchIndexer = class {
|
|
|
5574
5599
|
}
|
|
5575
5600
|
this._pageMap[defaultSection.pathname] = defaultSection;
|
|
5576
5601
|
let indexedPage;
|
|
5602
|
+
let collectedLinks = [];
|
|
5577
5603
|
try {
|
|
5604
|
+
if (this.config.validatePageLinks) {
|
|
5605
|
+
const anchorTree = createRemarkProcessor({
|
|
5606
|
+
frontmatter: true,
|
|
5607
|
+
mdx: true
|
|
5608
|
+
}).parse(fileContents);
|
|
5609
|
+
const anchorIds = collectAnchorIds(anchorTree);
|
|
5610
|
+
if (anchorIds.size) {
|
|
5611
|
+
this._anchorIds[defaultSection.pathname] = anchorIds;
|
|
5612
|
+
}
|
|
5613
|
+
}
|
|
5578
5614
|
if (cached?.page) {
|
|
5579
5615
|
indexedPage = cached.page;
|
|
5616
|
+
collectedLinks = cached.collectedLinks;
|
|
5617
|
+
this._collectedLinks.push(...collectedLinks);
|
|
5580
5618
|
} else {
|
|
5581
5619
|
const processor = createRemarkProcessor({
|
|
5582
5620
|
alerts: true,
|
|
@@ -5590,9 +5628,8 @@ var SearchIndexer = class {
|
|
|
5590
5628
|
});
|
|
5591
5629
|
const tree = processor.runSync(processor.parse(fileContents));
|
|
5592
5630
|
if (this.config.validatePageLinks) {
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
);
|
|
5631
|
+
collectedLinks = collectLinks(tree, filePath, defaultSection.pathname);
|
|
5632
|
+
this._collectedLinks.push(...collectedLinks);
|
|
5596
5633
|
}
|
|
5597
5634
|
const pageInfo = {
|
|
5598
5635
|
frontmatter,
|
|
@@ -5652,6 +5689,7 @@ var SearchIndexer = class {
|
|
|
5652
5689
|
}
|
|
5653
5690
|
if (!cached) {
|
|
5654
5691
|
this.mdxFileReader.updateCache(filePath, fileContents, {
|
|
5692
|
+
collectedLinks,
|
|
5655
5693
|
frontmatter,
|
|
5656
5694
|
page: indexedPage,
|
|
5657
5695
|
pageDocProps: docProps,
|
|
@@ -5749,7 +5787,8 @@ var SearchIndexer = class {
|
|
|
5749
5787
|
const invalidLinks = validateLinks(
|
|
5750
5788
|
this._collectedLinks,
|
|
5751
5789
|
this._pageMap,
|
|
5752
|
-
this._docPropIds
|
|
5790
|
+
this._docPropIds,
|
|
5791
|
+
this._anchorIds
|
|
5753
5792
|
);
|
|
5754
5793
|
reportInvalidLinks(invalidLinks);
|
|
5755
5794
|
}
|