@qualcomm-ui/mdx-vite 3.7.4 → 3.8.0
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 +123 -13
- package/dist/cli.js.map +4 -4
- package/dist/docs-plugin/config/config-schema.d.ts +1 -1
- package/dist/docs-plugin/config/config-schema.d.ts.map +1 -1
- package/dist/docs-plugin/config/types.d.ts +1 -1
- package/dist/docs-plugin/config/types.d.ts.map +1 -1
- package/dist/docs-plugin/markdown/knowledge/knowledge-exporter.d.ts.map +1 -1
- package/dist/docs-plugin/markdown/knowledge/plugins/filter-text-directives.d.ts.map +1 -1
- package/dist/docs-plugin/mdx-plugins.d.ts.map +1 -1
- package/dist/docs-plugin/nav-builder/page-map.d.ts.map +1 -1
- package/dist/docs-plugin/remark/index.d.ts +1 -0
- package/dist/docs-plugin/remark/index.d.ts.map +1 -1
- package/dist/docs-plugin/remark/remark-serialize-jsx.d.ts +62 -0
- package/dist/docs-plugin/remark/remark-serialize-jsx.d.ts.map +1 -0
- package/dist/docs-plugin/search-indexer.d.ts.map +1 -1
- package/dist/index.js +168 -50
- package/dist/index.js.map +4 -4
- package/dist/tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3614,7 +3614,11 @@ var configSchema = implement().with({
|
|
|
3614
3614
|
z2.literal("timestamp"),
|
|
3615
3615
|
z2.literal("user-and-timestamp")
|
|
3616
3616
|
]).optional(),
|
|
3617
|
-
routingStrategy: z2.union([
|
|
3617
|
+
routingStrategy: z2.union([
|
|
3618
|
+
z2.literal("vite-generouted"),
|
|
3619
|
+
z2.literal("react-router-directory-groups"),
|
|
3620
|
+
z2.any()
|
|
3621
|
+
]).optional(),
|
|
3618
3622
|
throwOnError: z2.boolean().optional(),
|
|
3619
3623
|
typeDocProps: z2.string().optional(),
|
|
3620
3624
|
typeDocPropsOptions: typeDocPropsSchema.optional(),
|
|
@@ -3668,7 +3672,7 @@ import remarkMdx2 from "remark-mdx";
|
|
|
3668
3672
|
import remarkParse3 from "remark-parse";
|
|
3669
3673
|
import remarkStringify3 from "remark-stringify";
|
|
3670
3674
|
import { unified as unified3 } from "unified";
|
|
3671
|
-
import { visit as
|
|
3675
|
+
import { visit as visit11 } from "unist-util-visit";
|
|
3672
3676
|
import {
|
|
3673
3677
|
UniqueIdService
|
|
3674
3678
|
} from "@qualcomm-ui/mdx-common";
|
|
@@ -4350,8 +4354,57 @@ var remarkRemoveJsx = () => {
|
|
|
4350
4354
|
import { toString } from "mdast-util-to-string";
|
|
4351
4355
|
import { visit as visit7 } from "unist-util-visit";
|
|
4352
4356
|
|
|
4353
|
-
// src/docs-plugin/remark/remark-
|
|
4357
|
+
// src/docs-plugin/remark/remark-serialize-jsx.ts
|
|
4354
4358
|
import { visit as visit8 } from "unist-util-visit";
|
|
4359
|
+
function getSerializeJsxStartMatch(text) {
|
|
4360
|
+
return text.match(/^:::\s*serialize-jsx\s*$/);
|
|
4361
|
+
}
|
|
4362
|
+
function getSerializeJsxEndMatch(text) {
|
|
4363
|
+
return text.trim() === ":::";
|
|
4364
|
+
}
|
|
4365
|
+
var isJsxNode = (node) => node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement";
|
|
4366
|
+
function createSerializeJsxPlugin(filter) {
|
|
4367
|
+
return () => (tree) => {
|
|
4368
|
+
visit8(tree, "paragraph", (node, index, parent) => {
|
|
4369
|
+
if (!parent || index === void 0) {
|
|
4370
|
+
return;
|
|
4371
|
+
}
|
|
4372
|
+
const firstChild = node.children[0];
|
|
4373
|
+
if (firstChild?.type !== "text") {
|
|
4374
|
+
return;
|
|
4375
|
+
}
|
|
4376
|
+
if (!getSerializeJsxStartMatch(firstChild.value)) {
|
|
4377
|
+
return;
|
|
4378
|
+
}
|
|
4379
|
+
let endIndex = index + 1;
|
|
4380
|
+
const contentNodes = [];
|
|
4381
|
+
while (endIndex < parent.children.length) {
|
|
4382
|
+
const child = parent.children[endIndex];
|
|
4383
|
+
if (child.type === "paragraph") {
|
|
4384
|
+
const firstText = child.children[0];
|
|
4385
|
+
if (firstText?.type === "text" && getSerializeJsxEndMatch(firstText.value)) {
|
|
4386
|
+
break;
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
4389
|
+
contentNodes.push(child);
|
|
4390
|
+
endIndex++;
|
|
4391
|
+
}
|
|
4392
|
+
if (endIndex >= parent.children.length) {
|
|
4393
|
+
return;
|
|
4394
|
+
}
|
|
4395
|
+
parent.children.splice(
|
|
4396
|
+
index,
|
|
4397
|
+
endIndex - index + 1,
|
|
4398
|
+
...contentNodes.filter(filter)
|
|
4399
|
+
);
|
|
4400
|
+
});
|
|
4401
|
+
};
|
|
4402
|
+
}
|
|
4403
|
+
var remarkSerializeJsxRender = createSerializeJsxPlugin(isJsxNode);
|
|
4404
|
+
var remarkSerializeJsxKnowledge = createSerializeJsxPlugin((n) => !isJsxNode(n));
|
|
4405
|
+
|
|
4406
|
+
// src/docs-plugin/remark/remark-spoilers.ts
|
|
4407
|
+
import { visit as visit9 } from "unist-util-visit";
|
|
4355
4408
|
function getSpoilerStartMatch(text) {
|
|
4356
4409
|
return text.match(/^:::\s*spoiler\s*(.*)$/);
|
|
4357
4410
|
}
|
|
@@ -4363,7 +4416,7 @@ function isSpoilerBlock(text) {
|
|
|
4363
4416
|
}
|
|
4364
4417
|
|
|
4365
4418
|
// src/docs-plugin/remark/remark-steps.ts
|
|
4366
|
-
import { visit as
|
|
4419
|
+
import { visit as visit10 } from "unist-util-visit";
|
|
4367
4420
|
function getStepStartMatch(text) {
|
|
4368
4421
|
return text.match(/^:::\s*steps(?:\s+(h[1-6](?:-h[1-6])?))?\s*$/);
|
|
4369
4422
|
}
|
|
@@ -4476,7 +4529,7 @@ var DocPropsIndexer = class {
|
|
|
4476
4529
|
*/
|
|
4477
4530
|
getTypeDocPropsNodes = () => {
|
|
4478
4531
|
return (tree, _file, done) => {
|
|
4479
|
-
|
|
4532
|
+
visit11(tree, "mdxJsxFlowElement", (node) => {
|
|
4480
4533
|
if (node && "name" in node && docPropsJsxNodes.includes(node.name)) {
|
|
4481
4534
|
const nameAttr = node.attributes?.find(
|
|
4482
4535
|
(attr) => attr.name === "name"
|
|
@@ -4622,7 +4675,7 @@ var DocPropsIndexer = class {
|
|
|
4622
4675
|
// src/docs-plugin/link-validator.ts
|
|
4623
4676
|
import chalk2 from "chalk";
|
|
4624
4677
|
import { posix } from "node:path";
|
|
4625
|
-
import { visit as
|
|
4678
|
+
import { visit as visit12 } from "unist-util-visit";
|
|
4626
4679
|
var externalPrefixes = ["https://", "http://", "mailto:", "tel:"];
|
|
4627
4680
|
function isExternal(url) {
|
|
4628
4681
|
return externalPrefixes.some((prefix) => url.startsWith(prefix));
|
|
@@ -4648,7 +4701,7 @@ function resolveLink(url, sourcePathname) {
|
|
|
4648
4701
|
}
|
|
4649
4702
|
function collectLinks(tree, sourceFile, sourcePathname) {
|
|
4650
4703
|
const links = [];
|
|
4651
|
-
|
|
4704
|
+
visit12(tree, "link", (node) => {
|
|
4652
4705
|
const resolved = resolveLink(node.url, sourcePathname);
|
|
4653
4706
|
if (!resolved) {
|
|
4654
4707
|
return;
|
|
@@ -4680,8 +4733,8 @@ function collectAnchorIds(tree) {
|
|
|
4680
4733
|
anchorIds.add(id);
|
|
4681
4734
|
}
|
|
4682
4735
|
};
|
|
4683
|
-
|
|
4684
|
-
|
|
4736
|
+
visit12(tree, "mdxJsxFlowElement", collectAnchorId);
|
|
4737
|
+
visit12(tree, "mdxJsxTextElement", collectAnchorId);
|
|
4685
4738
|
return anchorIds;
|
|
4686
4739
|
}
|
|
4687
4740
|
function validateLinks(links, pageMap, docPropIds, anchorIds) {
|
|
@@ -4733,7 +4786,7 @@ import { toString as toString2 } from "mdast-util-to-string";
|
|
|
4733
4786
|
import remarkGfm2 from "remark-gfm";
|
|
4734
4787
|
import remarkStringify4 from "remark-stringify";
|
|
4735
4788
|
import { unified as unified4 } from "unified";
|
|
4736
|
-
import { visit as
|
|
4789
|
+
import { visit as visit13 } from "unist-util-visit";
|
|
4737
4790
|
|
|
4738
4791
|
// src/docs-plugin/markdown/knowledge/utils.ts
|
|
4739
4792
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -4745,9 +4798,9 @@ function computeMd5(content) {
|
|
|
4745
4798
|
// src/docs-plugin/markdown/knowledge/section-extractor.ts
|
|
4746
4799
|
function transformLinks() {
|
|
4747
4800
|
return () => (tree) => {
|
|
4748
|
-
|
|
4801
|
+
visit13(tree, "link", (node) => {
|
|
4749
4802
|
let text = "";
|
|
4750
|
-
|
|
4803
|
+
visit13(node, "text", (textNode) => {
|
|
4751
4804
|
text += textNode.value;
|
|
4752
4805
|
});
|
|
4753
4806
|
Object.assign(node, {
|
|
@@ -5323,7 +5376,10 @@ function isPathSeparator(char) {
|
|
|
5323
5376
|
return pathSeparatorRegex.test(char);
|
|
5324
5377
|
}
|
|
5325
5378
|
var indexRouteRegex = /((^|[.]|[+]\/)(index|_index))(\/[^\/]+)?$|(\/_?index\/)/;
|
|
5326
|
-
function getRemixFlatRoutesSegments(name, index,
|
|
5379
|
+
function getRemixFlatRoutesSegments(name, index, paramPrefixCharOrOptions = "$") {
|
|
5380
|
+
const options = typeof paramPrefixCharOrOptions === "string" ? { paramPrefixChar: paramPrefixCharOrOptions } : paramPrefixCharOrOptions;
|
|
5381
|
+
const paramPrefixChar = options.paramPrefixChar ?? "$";
|
|
5382
|
+
const directoryMode = options.directoryMode ?? false;
|
|
5327
5383
|
let routeSegments = [];
|
|
5328
5384
|
let i = 0;
|
|
5329
5385
|
let routeSegment = "";
|
|
@@ -5340,6 +5396,18 @@ function getRemixFlatRoutesSegments(name, index, paramPrefixChar = "$") {
|
|
|
5340
5396
|
name = name.replace(/\+\//g, ".");
|
|
5341
5397
|
hasPlus = true;
|
|
5342
5398
|
}
|
|
5399
|
+
if (directoryMode && /\//.test(name)) {
|
|
5400
|
+
if (name.endsWith(".route")) {
|
|
5401
|
+
const lastSlash = name.lastIndexOf("/");
|
|
5402
|
+
if (lastSlash >= 0) {
|
|
5403
|
+
const head = name.substring(0, lastSlash).replace(/\//g, ".");
|
|
5404
|
+
name = `${head}/${name.substring(lastSlash + 1)}`;
|
|
5405
|
+
}
|
|
5406
|
+
} else {
|
|
5407
|
+
name = name.replace(/\//g, ".");
|
|
5408
|
+
}
|
|
5409
|
+
hasPlus = true;
|
|
5410
|
+
}
|
|
5343
5411
|
const hasFolder = /\//.test(name);
|
|
5344
5412
|
if ((hasPlus && hasFolder || !hasPlus) && !(name.endsWith(".route") || name.endsWith(".index"))) {
|
|
5345
5413
|
const last = name.lastIndexOf("/");
|
|
@@ -5403,6 +5471,27 @@ function getRemixHybridRoutesPathSegments(filePath) {
|
|
|
5403
5471
|
indexRouteRegex.test(routeWithoutExtension)
|
|
5404
5472
|
);
|
|
5405
5473
|
}
|
|
5474
|
+
function getRemixHybridDirectoryRoutesPathSegments(filePath) {
|
|
5475
|
+
const routeWithoutExtension = filePath.substring(0, filePath.lastIndexOf("."));
|
|
5476
|
+
if (hasPrivateFolderSegment(routeWithoutExtension)) {
|
|
5477
|
+
return [];
|
|
5478
|
+
}
|
|
5479
|
+
return getRemixFlatRoutesSegments(
|
|
5480
|
+
routeWithoutExtension,
|
|
5481
|
+
indexRouteRegex.test(routeWithoutExtension),
|
|
5482
|
+
{ directoryMode: true }
|
|
5483
|
+
);
|
|
5484
|
+
}
|
|
5485
|
+
function hasPrivateFolderSegment(routeWithoutExtension) {
|
|
5486
|
+
const segments = routeWithoutExtension.split("/");
|
|
5487
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
5488
|
+
const segment = segments[i];
|
|
5489
|
+
if (segment.startsWith("_") && !segment.includes("+")) {
|
|
5490
|
+
return true;
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5493
|
+
return false;
|
|
5494
|
+
}
|
|
5406
5495
|
function getPathSegmentsFromFileName(filePath, pageDirectory, strategy) {
|
|
5407
5496
|
const filePathWithoutPageDirectory = filePath.substring(
|
|
5408
5497
|
filePath.indexOf(pageDirectory) + pageDirectory.length + 1
|
|
@@ -5413,6 +5502,10 @@ function getPathSegmentsFromFileName(filePath, pageDirectory, strategy) {
|
|
|
5413
5502
|
switch (strategy) {
|
|
5414
5503
|
case "vite-generouted":
|
|
5415
5504
|
return getGeneroutedPathSegments(filePathWithoutPageDirectory);
|
|
5505
|
+
case "react-router-directory-groups":
|
|
5506
|
+
return getRemixHybridDirectoryRoutesPathSegments(
|
|
5507
|
+
filePathWithoutPageDirectory
|
|
5508
|
+
);
|
|
5416
5509
|
default:
|
|
5417
5510
|
return getRemixHybridRoutesPathSegments(filePathWithoutPageDirectory);
|
|
5418
5511
|
}
|
|
@@ -5427,8 +5520,24 @@ function filterFileGlob(fileGlob, ext, srcDir, router) {
|
|
|
5427
5520
|
(file) => file.split("/").filter((segment) => !restrictedPattern.test(segment)).join("/")
|
|
5428
5521
|
).map((file) => join(srcDir, file));
|
|
5429
5522
|
}
|
|
5523
|
+
if (typeof router === "string" && router === "react-router-directory-groups") {
|
|
5524
|
+
return fileGlob.filter(
|
|
5525
|
+
(file) => file.endsWith(ext) && !file.includes("$") && !hasPrivateFolderInRelativePath(file, srcDir)
|
|
5526
|
+
);
|
|
5527
|
+
}
|
|
5430
5528
|
return fileGlob.filter((file) => file.endsWith(ext) && !file.includes("$"));
|
|
5431
5529
|
}
|
|
5530
|
+
function hasPrivateFolderInRelativePath(file, srcDir) {
|
|
5531
|
+
const relative = file.startsWith(srcDir) ? file.slice(srcDir.length) : file;
|
|
5532
|
+
const segments = relative.split("/").filter(Boolean);
|
|
5533
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
5534
|
+
const segment = segments[i];
|
|
5535
|
+
if (segment.startsWith("_") && !segment.includes("+")) {
|
|
5536
|
+
return true;
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
5539
|
+
return false;
|
|
5540
|
+
}
|
|
5432
5541
|
|
|
5433
5542
|
// src/docs-plugin/nav-builder/transform-route-meta-array.ts
|
|
5434
5543
|
function transformRouteMetaArray(meta, routeMetaNav) {
|
|
@@ -5623,6 +5732,7 @@ var SearchIndexer = class {
|
|
|
5623
5732
|
gfm: true,
|
|
5624
5733
|
interpolateFrontmatter: frontmatter,
|
|
5625
5734
|
mdx: true,
|
|
5735
|
+
plugins: [remarkSerializeJsxKnowledge],
|
|
5626
5736
|
removeJsx: true,
|
|
5627
5737
|
removeMermaidCodeBlocks: true
|
|
5628
5738
|
});
|