@qualcomm-ui/mdx-vite 2.17.0 → 2.17.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 +104 -104
- package/dist/cli.js.map +4 -4
- package/dist/docs-plugin/internal/services/markdown/markdown-indexer.d.ts.map +1 -1
- package/dist/index.js +104 -104
- package/dist/index.js.map +4 -4
- package/dist/tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -4404,8 +4404,109 @@ var alertToEmphasis = {
|
|
|
4404
4404
|
warning: "warning"
|
|
4405
4405
|
};
|
|
4406
4406
|
|
|
4407
|
+
// src/docs-plugin/remark/remark-extract-meta.ts
|
|
4408
|
+
import { SKIP, visit as visit4 } from "unist-util-visit";
|
|
4409
|
+
function parseValue(value) {
|
|
4410
|
+
const trimmed = value.trim();
|
|
4411
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
4412
|
+
const inner = trimmed.slice(1, -1);
|
|
4413
|
+
return inner.split(",").map((item) => item.trim()).filter(Boolean);
|
|
4414
|
+
}
|
|
4415
|
+
return trimmed;
|
|
4416
|
+
}
|
|
4417
|
+
function parseMetaContent(content) {
|
|
4418
|
+
const result = {};
|
|
4419
|
+
const lines = content.split("\n");
|
|
4420
|
+
for (const line of lines) {
|
|
4421
|
+
const trimmed = line.trim();
|
|
4422
|
+
if (!trimmed || trimmed === ":::") {
|
|
4423
|
+
continue;
|
|
4424
|
+
}
|
|
4425
|
+
const colonIndex = trimmed.indexOf(":");
|
|
4426
|
+
if (colonIndex === -1) {
|
|
4427
|
+
continue;
|
|
4428
|
+
}
|
|
4429
|
+
const key = trimmed.slice(0, colonIndex).trim();
|
|
4430
|
+
const value = trimmed.slice(colonIndex + 1).trim();
|
|
4431
|
+
if (key && value) {
|
|
4432
|
+
result[key] = parseValue(value);
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
return result;
|
|
4436
|
+
}
|
|
4437
|
+
function parseTermsContent(content) {
|
|
4438
|
+
return content.split("\n").map((line) => line.trim()).filter((line) => line && line !== ":::");
|
|
4439
|
+
}
|
|
4440
|
+
var remarkExtractMeta = (metadata = {}) => {
|
|
4441
|
+
return (tree) => {
|
|
4442
|
+
const nodesToRemove = [];
|
|
4443
|
+
visit4(tree, "paragraph", (node, index, parent) => {
|
|
4444
|
+
if (!parent || index === void 0) {
|
|
4445
|
+
return;
|
|
4446
|
+
}
|
|
4447
|
+
const firstChild = node.children[0];
|
|
4448
|
+
if (firstChild?.type !== "text") {
|
|
4449
|
+
return;
|
|
4450
|
+
}
|
|
4451
|
+
const text = firstChild.value;
|
|
4452
|
+
const metaMatch = text.match(/^:::\s*meta\s*/);
|
|
4453
|
+
const termsMatch = text.match(/^:::\s*terms\s*/);
|
|
4454
|
+
if (!metaMatch && !termsMatch) {
|
|
4455
|
+
return;
|
|
4456
|
+
}
|
|
4457
|
+
const openMatch = metaMatch || termsMatch;
|
|
4458
|
+
const isTermsBlock = !!termsMatch;
|
|
4459
|
+
if (text.includes(":::") && text.lastIndexOf(":::") > openMatch[0].length) {
|
|
4460
|
+
const afterOpen = text.slice(openMatch[0].length);
|
|
4461
|
+
const closeIndex = afterOpen.lastIndexOf(":::");
|
|
4462
|
+
const content = afterOpen.slice(0, closeIndex);
|
|
4463
|
+
if (isTermsBlock) {
|
|
4464
|
+
const terms = parseTermsContent(content);
|
|
4465
|
+
if (terms.length > 0) {
|
|
4466
|
+
const existing = metadata.terms;
|
|
4467
|
+
metadata.terms = Array.isArray(existing) ? [...existing, ...terms] : terms;
|
|
4468
|
+
}
|
|
4469
|
+
} else {
|
|
4470
|
+
const parsed = parseMetaContent(content);
|
|
4471
|
+
Object.assign(metadata, parsed);
|
|
4472
|
+
}
|
|
4473
|
+
nodesToRemove.push({ index, parent });
|
|
4474
|
+
return SKIP;
|
|
4475
|
+
}
|
|
4476
|
+
let fullText = text;
|
|
4477
|
+
for (let i = 1; i < node.children.length; i++) {
|
|
4478
|
+
const child = node.children[i];
|
|
4479
|
+
if (child.type === "text") {
|
|
4480
|
+
fullText += child.value;
|
|
4481
|
+
}
|
|
4482
|
+
}
|
|
4483
|
+
const afterOpenFull = fullText.slice(openMatch[0].length);
|
|
4484
|
+
const closeIndexFull = afterOpenFull.lastIndexOf(":::");
|
|
4485
|
+
if (closeIndexFull !== -1) {
|
|
4486
|
+
const content = afterOpenFull.slice(0, closeIndexFull);
|
|
4487
|
+
if (isTermsBlock) {
|
|
4488
|
+
const terms = parseTermsContent(content);
|
|
4489
|
+
if (terms.length > 0) {
|
|
4490
|
+
const existing = metadata.terms;
|
|
4491
|
+
metadata.terms = Array.isArray(existing) ? [...existing, ...terms] : terms;
|
|
4492
|
+
}
|
|
4493
|
+
} else {
|
|
4494
|
+
const parsed = parseMetaContent(content);
|
|
4495
|
+
Object.assign(metadata, parsed);
|
|
4496
|
+
}
|
|
4497
|
+
nodesToRemove.push({ index, parent });
|
|
4498
|
+
return SKIP;
|
|
4499
|
+
}
|
|
4500
|
+
});
|
|
4501
|
+
for (let i = nodesToRemove.length - 1; i >= 0; i--) {
|
|
4502
|
+
const { index, parent } = nodesToRemove[i];
|
|
4503
|
+
parent.children.splice(index, 1);
|
|
4504
|
+
}
|
|
4505
|
+
};
|
|
4506
|
+
};
|
|
4507
|
+
|
|
4407
4508
|
// src/docs-plugin/remark/remark-frontmatter-interpolation.ts
|
|
4408
|
-
import { visit as
|
|
4509
|
+
import { visit as visit5 } from "unist-util-visit";
|
|
4409
4510
|
var FRONTMATTER_PATTERN = /^\s*frontmatter\.(\w+)\s*$/;
|
|
4410
4511
|
function isMdxExpression(node) {
|
|
4411
4512
|
const n = node;
|
|
@@ -4413,7 +4514,7 @@ function isMdxExpression(node) {
|
|
|
4413
4514
|
}
|
|
4414
4515
|
var remarkFrontmatterInterpolation = (frontmatter) => {
|
|
4415
4516
|
return (tree) => {
|
|
4416
|
-
|
|
4517
|
+
visit5(tree, (node, index, parent) => {
|
|
4417
4518
|
if (!isMdxExpression(node) || index === void 0 || !parent) {
|
|
4418
4519
|
return;
|
|
4419
4520
|
}
|
|
@@ -4532,7 +4633,7 @@ var MarkdownIndexer = class {
|
|
|
4532
4633
|
}
|
|
4533
4634
|
}
|
|
4534
4635
|
parseMarkdown(fileContents, frontmatter) {
|
|
4535
|
-
const file = unified3().use(remarkMdx2).use(remarkRemoveJsx).use(remarkRemoveMermaidCodeBlocks).use(remarkParse3).use(remarkGfm).use(remarkAlerts).use(remarkFrontmatterInterpolation, frontmatter).use(remarkRehype).use(rehypeStringify).processSync(fileContents);
|
|
4636
|
+
const file = unified3().use(remarkMdx2).use(remarkRemoveJsx).use(remarkRemoveMermaidCodeBlocks).use(remarkParse3).use(remarkGfm).use(remarkAlerts).use(remarkFrontmatterInterpolation, frontmatter).use(remarkExtractMeta, {}).use(remarkRehype).use(rehypeStringify).processSync(fileContents);
|
|
4536
4637
|
let contents = file.toString();
|
|
4537
4638
|
contents = contents.substring(contents.indexOf("<h1>"));
|
|
4538
4639
|
const htmlAst = unified3().data("settings", { fragment: true }).use(rehypeParse).use(rehypeStringify).use(rehypeSlug).processSync(contents);
|
|
@@ -5411,107 +5512,6 @@ import { unified as unified5 } from "unified";
|
|
|
5411
5512
|
import { visit as visit18 } from "unist-util-visit";
|
|
5412
5513
|
import { kebabCase as kebabCase3 } from "@qualcomm-ui/utils/change-case";
|
|
5413
5514
|
|
|
5414
|
-
// src/docs-plugin/remark/remark-extract-meta.ts
|
|
5415
|
-
import { SKIP, visit as visit5 } from "unist-util-visit";
|
|
5416
|
-
function parseValue(value) {
|
|
5417
|
-
const trimmed = value.trim();
|
|
5418
|
-
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
5419
|
-
const inner = trimmed.slice(1, -1);
|
|
5420
|
-
return inner.split(",").map((item) => item.trim()).filter(Boolean);
|
|
5421
|
-
}
|
|
5422
|
-
return trimmed;
|
|
5423
|
-
}
|
|
5424
|
-
function parseMetaContent(content) {
|
|
5425
|
-
const result = {};
|
|
5426
|
-
const lines = content.split("\n");
|
|
5427
|
-
for (const line of lines) {
|
|
5428
|
-
const trimmed = line.trim();
|
|
5429
|
-
if (!trimmed || trimmed === ":::") {
|
|
5430
|
-
continue;
|
|
5431
|
-
}
|
|
5432
|
-
const colonIndex = trimmed.indexOf(":");
|
|
5433
|
-
if (colonIndex === -1) {
|
|
5434
|
-
continue;
|
|
5435
|
-
}
|
|
5436
|
-
const key = trimmed.slice(0, colonIndex).trim();
|
|
5437
|
-
const value = trimmed.slice(colonIndex + 1).trim();
|
|
5438
|
-
if (key && value) {
|
|
5439
|
-
result[key] = parseValue(value);
|
|
5440
|
-
}
|
|
5441
|
-
}
|
|
5442
|
-
return result;
|
|
5443
|
-
}
|
|
5444
|
-
function parseTermsContent(content) {
|
|
5445
|
-
return content.split("\n").map((line) => line.trim()).filter((line) => line && line !== ":::");
|
|
5446
|
-
}
|
|
5447
|
-
var remarkExtractMeta = (metadata = {}) => {
|
|
5448
|
-
return (tree) => {
|
|
5449
|
-
const nodesToRemove = [];
|
|
5450
|
-
visit5(tree, "paragraph", (node, index, parent) => {
|
|
5451
|
-
if (!parent || index === void 0) {
|
|
5452
|
-
return;
|
|
5453
|
-
}
|
|
5454
|
-
const firstChild = node.children[0];
|
|
5455
|
-
if (firstChild?.type !== "text") {
|
|
5456
|
-
return;
|
|
5457
|
-
}
|
|
5458
|
-
const text = firstChild.value;
|
|
5459
|
-
const metaMatch = text.match(/^:::\s*meta\s*/);
|
|
5460
|
-
const termsMatch = text.match(/^:::\s*terms\s*/);
|
|
5461
|
-
if (!metaMatch && !termsMatch) {
|
|
5462
|
-
return;
|
|
5463
|
-
}
|
|
5464
|
-
const openMatch = metaMatch || termsMatch;
|
|
5465
|
-
const isTermsBlock = !!termsMatch;
|
|
5466
|
-
if (text.includes(":::") && text.lastIndexOf(":::") > openMatch[0].length) {
|
|
5467
|
-
const afterOpen = text.slice(openMatch[0].length);
|
|
5468
|
-
const closeIndex = afterOpen.lastIndexOf(":::");
|
|
5469
|
-
const content = afterOpen.slice(0, closeIndex);
|
|
5470
|
-
if (isTermsBlock) {
|
|
5471
|
-
const terms = parseTermsContent(content);
|
|
5472
|
-
if (terms.length > 0) {
|
|
5473
|
-
const existing = metadata.terms;
|
|
5474
|
-
metadata.terms = Array.isArray(existing) ? [...existing, ...terms] : terms;
|
|
5475
|
-
}
|
|
5476
|
-
} else {
|
|
5477
|
-
const parsed = parseMetaContent(content);
|
|
5478
|
-
Object.assign(metadata, parsed);
|
|
5479
|
-
}
|
|
5480
|
-
nodesToRemove.push({ index, parent });
|
|
5481
|
-
return SKIP;
|
|
5482
|
-
}
|
|
5483
|
-
let fullText = text;
|
|
5484
|
-
for (let i = 1; i < node.children.length; i++) {
|
|
5485
|
-
const child = node.children[i];
|
|
5486
|
-
if (child.type === "text") {
|
|
5487
|
-
fullText += child.value;
|
|
5488
|
-
}
|
|
5489
|
-
}
|
|
5490
|
-
const afterOpenFull = fullText.slice(openMatch[0].length);
|
|
5491
|
-
const closeIndexFull = afterOpenFull.lastIndexOf(":::");
|
|
5492
|
-
if (closeIndexFull !== -1) {
|
|
5493
|
-
const content = afterOpenFull.slice(0, closeIndexFull);
|
|
5494
|
-
if (isTermsBlock) {
|
|
5495
|
-
const terms = parseTermsContent(content);
|
|
5496
|
-
if (terms.length > 0) {
|
|
5497
|
-
const existing = metadata.terms;
|
|
5498
|
-
metadata.terms = Array.isArray(existing) ? [...existing, ...terms] : terms;
|
|
5499
|
-
}
|
|
5500
|
-
} else {
|
|
5501
|
-
const parsed = parseMetaContent(content);
|
|
5502
|
-
Object.assign(metadata, parsed);
|
|
5503
|
-
}
|
|
5504
|
-
nodesToRemove.push({ index, parent });
|
|
5505
|
-
return SKIP;
|
|
5506
|
-
}
|
|
5507
|
-
});
|
|
5508
|
-
for (let i = nodesToRemove.length - 1; i >= 0; i--) {
|
|
5509
|
-
const { index, parent } = nodesToRemove[i];
|
|
5510
|
-
parent.children.splice(index, 1);
|
|
5511
|
-
}
|
|
5512
|
-
};
|
|
5513
|
-
};
|
|
5514
|
-
|
|
5515
5515
|
// src/ai-knowledge/generator/config.ts
|
|
5516
5516
|
var currentConfig = null;
|
|
5517
5517
|
function setConfig(config3) {
|