@qualcomm-ui/mdx-vite 2.8.0 → 2.9.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 +142 -40
- package/dist/cli.js.map +4 -4
- package/dist/docs-plugin/__tests__/remark-frontmatter-interpolation.spec.d.ts +2 -0
- package/dist/docs-plugin/__tests__/remark-frontmatter-interpolation.spec.d.ts.map +1 -0
- package/dist/docs-plugin/docs-plugin.d.ts.map +1 -1
- package/dist/docs-plugin/internal/config-schema.d.ts +12 -0
- package/dist/docs-plugin/internal/config-schema.d.ts.map +1 -1
- package/dist/docs-plugin/internal/services/markdown/markdown-indexer.d.ts.map +1 -1
- package/dist/docs-plugin/mdx-plugins.d.ts.map +1 -1
- package/dist/docs-plugin/remark/index.d.ts +2 -0
- package/dist/docs-plugin/remark/index.d.ts.map +1 -1
- package/dist/docs-plugin/remark/remark-frontmatter-interpolation.d.ts +10 -0
- package/dist/docs-plugin/remark/remark-frontmatter-interpolation.d.ts.map +1 -0
- package/dist/docs-plugin/remark/remark-frontmatter-title.d.ts +10 -0
- package/dist/docs-plugin/remark/remark-frontmatter-title.d.ts.map +1 -0
- package/dist/docs-plugin/types.d.ts +39 -0
- package/dist/docs-plugin/types.d.ts.map +1 -1
- package/dist/index.js +6170 -1679
- package/dist/index.js.map +4 -4
- package/dist/open-web-ui-knowledge/generate-knowledge.d.ts +2 -2
- package/dist/open-web-ui-knowledge/generate-knowledge.d.ts.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -3554,11 +3554,20 @@ var knowledgeExtraFileSchema = implement().with({
|
|
|
3554
3554
|
id: z2.string(),
|
|
3555
3555
|
title: z2.string()
|
|
3556
3556
|
});
|
|
3557
|
+
var knowledgeExportsSchema = implement().with({
|
|
3558
|
+
enabled: z2.boolean().optional(),
|
|
3559
|
+
exclude: z2.array(z2.string()).optional(),
|
|
3560
|
+
extraFiles: z2.array(knowledgeExtraFileSchema).optional(),
|
|
3561
|
+
metadata: z2.record(z2.string(), z2.string()).optional(),
|
|
3562
|
+
pageTitlePrefix: z2.string().optional(),
|
|
3563
|
+
staticPath: z2.string().optional()
|
|
3564
|
+
});
|
|
3557
3565
|
var knowledgeIntegrationSchema = implement().with(
|
|
3558
3566
|
{
|
|
3559
3567
|
baseUrl: z2.string().optional(),
|
|
3560
3568
|
description: z2.string().optional(),
|
|
3561
3569
|
exclude: z2.array(z2.string()).optional(),
|
|
3570
|
+
exports: knowledgeExportsSchema.optional(),
|
|
3562
3571
|
extraFiles: z2.array(knowledgeExtraFileSchema).optional(),
|
|
3563
3572
|
metadata: z2.record(z2.string(), z2.string()).optional(),
|
|
3564
3573
|
name: z2.string().optional(),
|
|
@@ -4354,6 +4363,36 @@ var alertToEmphasis = {
|
|
|
4354
4363
|
warning: "warning"
|
|
4355
4364
|
};
|
|
4356
4365
|
|
|
4366
|
+
// src/docs-plugin/remark/remark-frontmatter-interpolation.ts
|
|
4367
|
+
import { visit as visit4 } from "unist-util-visit";
|
|
4368
|
+
var FRONTMATTER_PATTERN = /^\s*frontmatter\.(\w+)\s*$/;
|
|
4369
|
+
function isMdxExpression(node) {
|
|
4370
|
+
const n = node;
|
|
4371
|
+
return (n.type === "mdxFlowExpression" || n.type === "mdxTextExpression") && typeof n.value === "string";
|
|
4372
|
+
}
|
|
4373
|
+
var remarkFrontmatterInterpolation = (frontmatter) => {
|
|
4374
|
+
return (tree) => {
|
|
4375
|
+
visit4(tree, (node, index, parent) => {
|
|
4376
|
+
if (!isMdxExpression(node) || index === void 0 || !parent) {
|
|
4377
|
+
return;
|
|
4378
|
+
}
|
|
4379
|
+
const match = node.value.match(FRONTMATTER_PATTERN);
|
|
4380
|
+
if (!match) {
|
|
4381
|
+
return;
|
|
4382
|
+
}
|
|
4383
|
+
const key = match[1];
|
|
4384
|
+
const value = frontmatter[key];
|
|
4385
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
4386
|
+
const textNode = {
|
|
4387
|
+
type: "text",
|
|
4388
|
+
value: String(value)
|
|
4389
|
+
};
|
|
4390
|
+
parent.children[index] = textNode;
|
|
4391
|
+
}
|
|
4392
|
+
});
|
|
4393
|
+
};
|
|
4394
|
+
};
|
|
4395
|
+
|
|
4357
4396
|
// src/docs-plugin/internal/services/markdown/remark-remove-code-blocks.ts
|
|
4358
4397
|
import { remove } from "unist-util-remove";
|
|
4359
4398
|
var remarkRemoveMermaidCodeBlocks = () => {
|
|
@@ -4451,14 +4490,9 @@ var MarkdownIndexer = class {
|
|
|
4451
4490
|
}
|
|
4452
4491
|
}
|
|
4453
4492
|
parseMarkdown(fileContents, frontmatter) {
|
|
4454
|
-
const file = unified3().use(remarkMdx2).use(remarkRemoveJsx).use(remarkRemoveMermaidCodeBlocks).use(remarkParse3).use(remarkGfm).use(remarkAlerts).use(remarkRehype).use(rehypeStringify).processSync(fileContents);
|
|
4493
|
+
const file = unified3().use(remarkMdx2).use(remarkRemoveJsx).use(remarkRemoveMermaidCodeBlocks).use(remarkParse3).use(remarkGfm).use(remarkAlerts).use(remarkFrontmatterInterpolation, frontmatter).use(remarkRehype).use(rehypeStringify).processSync(fileContents);
|
|
4455
4494
|
let contents = file.toString();
|
|
4456
4495
|
contents = contents.substring(contents.indexOf("<h1>"));
|
|
4457
|
-
for (const [key, value] of Object.entries(frontmatter)) {
|
|
4458
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
4459
|
-
contents = contents.replaceAll(`frontmatter.${key}`, `${value}`);
|
|
4460
|
-
}
|
|
4461
|
-
}
|
|
4462
4496
|
const htmlAst = unified3().data("settings", { fragment: true }).use(rehypeParse).use(rehypeStringify).use(rehypeSlug).processSync(contents);
|
|
4463
4497
|
contents = htmlAst.toString();
|
|
4464
4498
|
return this.build(contents);
|
|
@@ -5623,14 +5657,14 @@ import {
|
|
|
5623
5657
|
stat,
|
|
5624
5658
|
writeFile as writeFile3
|
|
5625
5659
|
} from "node:fs/promises";
|
|
5626
|
-
import { basename, dirname, extname, join as
|
|
5660
|
+
import { basename, dirname, extname, join as join4, relative as relative2, resolve as resolve5 } from "node:path";
|
|
5627
5661
|
import remarkFrontmatter3 from "remark-frontmatter";
|
|
5628
5662
|
import remarkMdx3 from "remark-mdx";
|
|
5629
5663
|
import remarkParse4 from "remark-parse";
|
|
5630
5664
|
import remarkParseFrontmatter2 from "remark-parse-frontmatter";
|
|
5631
5665
|
import remarkStringify3 from "remark-stringify";
|
|
5632
5666
|
import { unified as unified4 } from "unified";
|
|
5633
|
-
import { visit as
|
|
5667
|
+
import { visit as visit10 } from "unist-util-visit";
|
|
5634
5668
|
import { kebabCase } from "@qualcomm-ui/utils/change-case";
|
|
5635
5669
|
|
|
5636
5670
|
// src/docs-plugin/docs-plugin.ts
|
|
@@ -5638,24 +5672,31 @@ import chalk3 from "chalk";
|
|
|
5638
5672
|
import chokidar from "chokidar";
|
|
5639
5673
|
import { glob as glob2 } from "glob";
|
|
5640
5674
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
5641
|
-
import { resolve as resolve3 } from "node:path";
|
|
5675
|
+
import { join as join2, resolve as resolve3 } from "node:path";
|
|
5642
5676
|
import prettyMilliseconds from "pretty-ms";
|
|
5643
5677
|
var isDev = process.env.NODE_ENV === "development";
|
|
5644
5678
|
var VIRTUAL_MODULE_ID = "\0@qualcomm-ui/mdx-vite-plugin";
|
|
5645
5679
|
var PluginState = class {
|
|
5646
5680
|
buildCount = 0;
|
|
5681
|
+
config = null;
|
|
5647
5682
|
configFilePath = "";
|
|
5648
5683
|
docPropsFilePath = "";
|
|
5684
|
+
exports = { basePath: "", enabled: false, pages: [] };
|
|
5649
5685
|
indexer;
|
|
5650
5686
|
configLoader = null;
|
|
5687
|
+
knowledgeConfig = void 0;
|
|
5651
5688
|
routesDir;
|
|
5652
5689
|
servers = [];
|
|
5653
5690
|
timeout = void 0;
|
|
5691
|
+
exportsTimeout = void 0;
|
|
5654
5692
|
watching = false;
|
|
5655
5693
|
cwd;
|
|
5656
5694
|
init(cwd2) {
|
|
5657
5695
|
this.cwd = cwd2;
|
|
5658
5696
|
}
|
|
5697
|
+
getCwd() {
|
|
5698
|
+
return this.cwd;
|
|
5699
|
+
}
|
|
5659
5700
|
get docPropsDirectory() {
|
|
5660
5701
|
if (!this.docPropsFilePath) {
|
|
5661
5702
|
return "";
|
|
@@ -5666,7 +5707,10 @@ var PluginState = class {
|
|
|
5666
5707
|
);
|
|
5667
5708
|
}
|
|
5668
5709
|
get siteData() {
|
|
5710
|
+
const { filePath: _filePath, ...config2 } = this.config ?? {};
|
|
5669
5711
|
return {
|
|
5712
|
+
config: config2,
|
|
5713
|
+
exports: this.exports,
|
|
5670
5714
|
navItems: state.indexer.navItems,
|
|
5671
5715
|
pageDocProps: state.indexer.pageDocProps,
|
|
5672
5716
|
pageMap: state.indexer.pageMap,
|
|
@@ -5687,14 +5731,24 @@ var PluginState = class {
|
|
|
5687
5731
|
}
|
|
5688
5732
|
}
|
|
5689
5733
|
createIndexer(config2) {
|
|
5734
|
+
this.config = config2;
|
|
5690
5735
|
this.configFilePath = config2.filePath;
|
|
5691
5736
|
this.docPropsFilePath = config2.typeDocProps ? fixPath(resolve3(this.cwd, config2.typeDocProps)) : "";
|
|
5692
5737
|
this.routesDir = fixPath(resolve3(config2.appDirectory, config2.pageDirectory));
|
|
5738
|
+
this.knowledgeConfig = config2.knowledge;
|
|
5693
5739
|
this.indexer = new SearchIndexer({
|
|
5694
5740
|
...config2,
|
|
5695
5741
|
srcDir: fixPath(resolve3(this.cwd, config2.appDirectory)),
|
|
5696
5742
|
typeDocProps: this.resolveDocProps()
|
|
5697
5743
|
});
|
|
5744
|
+
const exportsConfig = config2.knowledge?.global?.exports;
|
|
5745
|
+
const exportsEnabled = exportsConfig?.enabled ?? false;
|
|
5746
|
+
const exportsPath = exportsConfig?.staticPath ?? "exports/md";
|
|
5747
|
+
this.exports = {
|
|
5748
|
+
basePath: exportsEnabled ? `/${exportsPath}` : "",
|
|
5749
|
+
enabled: exportsEnabled,
|
|
5750
|
+
pages: []
|
|
5751
|
+
};
|
|
5698
5752
|
}
|
|
5699
5753
|
buildIndex(shouldLog) {
|
|
5700
5754
|
const files = glob2.sync(
|
|
@@ -5767,6 +5821,41 @@ var PluginState = class {
|
|
|
5767
5821
|
});
|
|
5768
5822
|
});
|
|
5769
5823
|
}
|
|
5824
|
+
async generateExports(publicDir) {
|
|
5825
|
+
if (!this.exports.enabled || !this.knowledgeConfig?.global) {
|
|
5826
|
+
return;
|
|
5827
|
+
}
|
|
5828
|
+
const globalConfig = this.knowledgeConfig.global;
|
|
5829
|
+
const exportsConfig = globalConfig.exports ?? {};
|
|
5830
|
+
const exportsPath = exportsConfig.staticPath ?? "exports/md";
|
|
5831
|
+
const outputPath = join2(publicDir, exportsPath);
|
|
5832
|
+
const startTime = Date.now();
|
|
5833
|
+
const pageIds = await generate({
|
|
5834
|
+
baseUrl: globalConfig.baseUrl,
|
|
5835
|
+
clean: true,
|
|
5836
|
+
docPropsPath: this.docPropsFilePath || void 0,
|
|
5837
|
+
exclude: exportsConfig.exclude ?? globalConfig.exclude,
|
|
5838
|
+
extraFiles: exportsConfig.extraFiles ?? globalConfig.extraFiles,
|
|
5839
|
+
metadata: exportsConfig.metadata ?? globalConfig.metadata,
|
|
5840
|
+
outputMode: "per-page",
|
|
5841
|
+
outputPath,
|
|
5842
|
+
pageTitlePrefix: exportsConfig.pageTitlePrefix ?? globalConfig.pageTitlePrefix,
|
|
5843
|
+
routeDir: this.routesDir
|
|
5844
|
+
});
|
|
5845
|
+
this.exports.pages = pageIds;
|
|
5846
|
+
console.debug(
|
|
5847
|
+
`${chalk3.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Generated Markdown exports in: ${chalk3.blueBright.bold(prettyMilliseconds(Date.now() - startTime))}`
|
|
5848
|
+
);
|
|
5849
|
+
}
|
|
5850
|
+
debouncedGenerateExports(publicDir) {
|
|
5851
|
+
if (!this.exports.enabled) {
|
|
5852
|
+
return;
|
|
5853
|
+
}
|
|
5854
|
+
clearTimeout(this.exportsTimeout);
|
|
5855
|
+
this.exportsTimeout = setTimeout(() => {
|
|
5856
|
+
void this.generateExports(publicDir);
|
|
5857
|
+
}, 500);
|
|
5858
|
+
}
|
|
5770
5859
|
};
|
|
5771
5860
|
var state = new PluginState();
|
|
5772
5861
|
|
|
@@ -5795,14 +5884,17 @@ import { heading } from "hast-util-heading";
|
|
|
5795
5884
|
import { headingRank as headingRank2 } from "hast-util-heading-rank";
|
|
5796
5885
|
|
|
5797
5886
|
// src/docs-plugin/remark/remark-code-tabs.ts
|
|
5798
|
-
import { visit as
|
|
5887
|
+
import { visit as visit5 } from "unist-util-visit";
|
|
5799
5888
|
|
|
5800
5889
|
// src/docs-plugin/remark/remark-frontmatter-description.ts
|
|
5801
|
-
import { visit as
|
|
5890
|
+
import { visit as visit6 } from "unist-util-visit";
|
|
5891
|
+
|
|
5892
|
+
// src/docs-plugin/remark/remark-frontmatter-title.ts
|
|
5893
|
+
import { visit as visit7 } from "unist-util-visit";
|
|
5802
5894
|
|
|
5803
5895
|
// src/docs-plugin/remark/remark-self-link-headings.ts
|
|
5804
5896
|
import { toString as toString2 } from "mdast-util-to-string";
|
|
5805
|
-
import { visit as
|
|
5897
|
+
import { visit as visit8 } from "unist-util-visit";
|
|
5806
5898
|
var emptyOptions2 = {};
|
|
5807
5899
|
function remarkSelfLinkHeadings(baseUrl = "", options) {
|
|
5808
5900
|
if (!baseUrl) {
|
|
@@ -5830,7 +5922,7 @@ function remarkSelfLinkHeadings(baseUrl = "", options) {
|
|
|
5830
5922
|
}
|
|
5831
5923
|
return (tree) => {
|
|
5832
5924
|
seenIds.clear();
|
|
5833
|
-
|
|
5925
|
+
visit8(tree, "heading", (node) => {
|
|
5834
5926
|
if (allowedLevels.has(node.depth)) {
|
|
5835
5927
|
const text = toString2(node);
|
|
5836
5928
|
const slug = prefix + createSlug(text);
|
|
@@ -5847,14 +5939,14 @@ function remarkSelfLinkHeadings(baseUrl = "", options) {
|
|
|
5847
5939
|
}
|
|
5848
5940
|
|
|
5849
5941
|
// src/docs-plugin/remark/remark-spoilers.ts
|
|
5850
|
-
import { visit as
|
|
5942
|
+
import { visit as visit9 } from "unist-util-visit";
|
|
5851
5943
|
|
|
5852
5944
|
// src/docs-plugin/shiki/shiki-transformer-preview-block.ts
|
|
5853
5945
|
import { dedent } from "@qualcomm-ui/utils/dedent";
|
|
5854
5946
|
|
|
5855
5947
|
// src/open-web-ui-knowledge/load-config-from-env.ts
|
|
5856
5948
|
import { existsSync } from "node:fs";
|
|
5857
|
-
import { join as
|
|
5949
|
+
import { join as join3, resolve as resolve4 } from "node:path";
|
|
5858
5950
|
function parseCliMetadata(cliMetadata) {
|
|
5859
5951
|
if (!cliMetadata?.length) {
|
|
5860
5952
|
return void 0;
|
|
@@ -5870,7 +5962,7 @@ function loadKnowledgeConfigFromEnv(options) {
|
|
|
5870
5962
|
if (!outputPath) {
|
|
5871
5963
|
throw new Error("Missing required outputPath");
|
|
5872
5964
|
}
|
|
5873
|
-
const routeDir =
|
|
5965
|
+
const routeDir = join3(
|
|
5874
5966
|
resolvedConfig.appDirectory,
|
|
5875
5967
|
resolvedConfig.pageDirectory
|
|
5876
5968
|
);
|
|
@@ -5947,7 +6039,7 @@ async function resolveModulePath(importPath, fromFile) {
|
|
|
5947
6039
|
}
|
|
5948
6040
|
}
|
|
5949
6041
|
if (await exists(baseResolved)) {
|
|
5950
|
-
const indexPath =
|
|
6042
|
+
const indexPath = join4(baseResolved, "index.ts");
|
|
5951
6043
|
if (await exists(indexPath)) {
|
|
5952
6044
|
return indexPath;
|
|
5953
6045
|
}
|
|
@@ -5959,7 +6051,7 @@ function extractMetadata(metadata) {
|
|
|
5959
6051
|
}
|
|
5960
6052
|
var replaceNpmInstallTabs = () => {
|
|
5961
6053
|
return (tree, _file, done) => {
|
|
5962
|
-
|
|
6054
|
+
visit10(tree, "mdxJsxFlowElement", (node) => {
|
|
5963
6055
|
if (node?.name === "NpmInstallTabs") {
|
|
5964
6056
|
const packages = node.attributes?.find(
|
|
5965
6057
|
(attr) => attr.type === "mdxJsxAttribute" && attr.name === "packages"
|
|
@@ -6003,7 +6095,7 @@ var KnowledgeGenerator = class {
|
|
|
6003
6095
|
this.docProps = docProps;
|
|
6004
6096
|
if (pages.length === 0) {
|
|
6005
6097
|
console.log("No pages found.");
|
|
6006
|
-
return;
|
|
6098
|
+
return [];
|
|
6007
6099
|
}
|
|
6008
6100
|
if (this.config.verbose) {
|
|
6009
6101
|
console.log(`Found ${pages.length} page(s)`);
|
|
@@ -6036,9 +6128,10 @@ var KnowledgeGenerator = class {
|
|
|
6036
6128
|
);
|
|
6037
6129
|
await this.generateExtraFiles(extractedMetadata);
|
|
6038
6130
|
}
|
|
6131
|
+
return pages.map((page) => page.id);
|
|
6039
6132
|
}
|
|
6040
6133
|
async loadDocProps() {
|
|
6041
|
-
const resolvedDocPropsPath = this.config.docPropsPath ? await exists(this.config.docPropsPath) ? this.config.docPropsPath : resolve5(process.cwd(), this.config.docPropsPath) :
|
|
6134
|
+
const resolvedDocPropsPath = this.config.docPropsPath ? await exists(this.config.docPropsPath) ? this.config.docPropsPath : resolve5(process.cwd(), this.config.docPropsPath) : join4(dirname(this.config.routeDir), "doc-props.json");
|
|
6042
6135
|
if (!await exists(resolvedDocPropsPath)) {
|
|
6043
6136
|
if (this.config.verbose) {
|
|
6044
6137
|
console.log(`Doc props file not found at: ${resolvedDocPropsPath}`);
|
|
@@ -6085,20 +6178,20 @@ var KnowledgeGenerator = class {
|
|
|
6085
6178
|
}
|
|
6086
6179
|
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
6087
6180
|
const mdxFiles = entries.filter(
|
|
6088
|
-
(f) => f.name.endsWith(".mdx") && !shouldExclude(
|
|
6181
|
+
(f) => f.name.endsWith(".mdx") && !shouldExclude(join4(dirPath, f.name))
|
|
6089
6182
|
) ?? [];
|
|
6090
6183
|
for (const mdxFile of mdxFiles) {
|
|
6091
6184
|
const demosFolder = entries.find((f) => f.name === "demos");
|
|
6092
|
-
const demosFolderPath = demosFolder ?
|
|
6185
|
+
const demosFolderPath = demosFolder ? join4(dirPath, demosFolder.name) : void 0;
|
|
6093
6186
|
const segments = getPathSegmentsFromFileName(
|
|
6094
|
-
|
|
6187
|
+
join4(dirPath, mdxFile.name),
|
|
6095
6188
|
this.config.routeDir
|
|
6096
6189
|
);
|
|
6097
6190
|
const url = getPathnameFromPathSegments(segments);
|
|
6098
6191
|
components.push({
|
|
6099
6192
|
demosFolder: demosFolderPath,
|
|
6100
6193
|
id: segments.join("-").trim(),
|
|
6101
|
-
mdxFile:
|
|
6194
|
+
mdxFile: join4(dirPath, mdxFile.name),
|
|
6102
6195
|
name: segments.at(-1),
|
|
6103
6196
|
path: dirPath,
|
|
6104
6197
|
url: this.config.baseUrl ? new URL(url, this.config.baseUrl).toString() : void 0
|
|
@@ -6109,7 +6202,7 @@ var KnowledgeGenerator = class {
|
|
|
6109
6202
|
}
|
|
6110
6203
|
}
|
|
6111
6204
|
for (const entry of entries) {
|
|
6112
|
-
const fullPath =
|
|
6205
|
+
const fullPath = join4(dirPath, entry.name);
|
|
6113
6206
|
const stats = await stat(fullPath);
|
|
6114
6207
|
if (stats.isDirectory()) {
|
|
6115
6208
|
await scanDirectory(fullPath);
|
|
@@ -6275,7 +6368,7 @@ ${codeText}
|
|
|
6275
6368
|
}
|
|
6276
6369
|
};
|
|
6277
6370
|
return () => (tree, _file, done) => {
|
|
6278
|
-
|
|
6371
|
+
visit10(tree, "mdxJsxFlowElement", (node) => {
|
|
6279
6372
|
const handler = node.name && handlers[node.name];
|
|
6280
6373
|
if (!handler) {
|
|
6281
6374
|
return;
|
|
@@ -6315,7 +6408,7 @@ ${codeText}
|
|
|
6315
6408
|
*/
|
|
6316
6409
|
replaceTypeDocProps() {
|
|
6317
6410
|
return () => (tree, _file, done) => {
|
|
6318
|
-
|
|
6411
|
+
visit10(
|
|
6319
6412
|
tree,
|
|
6320
6413
|
"mdxJsxFlowElement",
|
|
6321
6414
|
(node, index, parent) => {
|
|
@@ -6376,7 +6469,7 @@ ${codeText}
|
|
|
6376
6469
|
replaceDemos(demosFolder, demoFiles) {
|
|
6377
6470
|
return () => async (tree) => {
|
|
6378
6471
|
const promises = [];
|
|
6379
|
-
|
|
6472
|
+
visit10(
|
|
6380
6473
|
tree,
|
|
6381
6474
|
"mdxJsxFlowElement",
|
|
6382
6475
|
(node, index, parent) => {
|
|
@@ -6420,14 +6513,14 @@ ${codeText}
|
|
|
6420
6513
|
}
|
|
6421
6514
|
return;
|
|
6422
6515
|
}
|
|
6423
|
-
let demoFilePath =
|
|
6516
|
+
let demoFilePath = join4(demosFolder, filePath);
|
|
6424
6517
|
let isAngularDemo = false;
|
|
6425
6518
|
if (!await exists(demoFilePath)) {
|
|
6426
|
-
demoFilePath =
|
|
6519
|
+
demoFilePath = join4(demosFolder, `${kebabName}.ts`);
|
|
6427
6520
|
if (await exists(demoFilePath)) {
|
|
6428
6521
|
isAngularDemo = true;
|
|
6429
6522
|
filePath = `${kebabCase(demoName).replace("-component", ".component")}.ts`;
|
|
6430
|
-
demoFilePath =
|
|
6523
|
+
demoFilePath = join4(demosFolder, filePath);
|
|
6431
6524
|
} else {
|
|
6432
6525
|
console.log(` Demo not found ${demoName}`);
|
|
6433
6526
|
if (parent && index !== void 0) {
|
|
@@ -6464,9 +6557,9 @@ ${codeText}
|
|
|
6464
6557
|
await Promise.all(promises);
|
|
6465
6558
|
};
|
|
6466
6559
|
}
|
|
6467
|
-
|
|
6560
|
+
replaceFrontmatterExpressions(frontmatter) {
|
|
6468
6561
|
return () => (tree) => {
|
|
6469
|
-
|
|
6562
|
+
visit10(
|
|
6470
6563
|
tree,
|
|
6471
6564
|
"mdxFlowExpression",
|
|
6472
6565
|
(node, index, parent) => {
|
|
@@ -6483,6 +6576,18 @@ ${codeText}
|
|
|
6483
6576
|
}
|
|
6484
6577
|
}
|
|
6485
6578
|
);
|
|
6579
|
+
const root = tree;
|
|
6580
|
+
const h1Index = root.children.findIndex((node) => {
|
|
6581
|
+
if (node.type !== "heading" || node.depth !== 1) {
|
|
6582
|
+
return false;
|
|
6583
|
+
}
|
|
6584
|
+
return node.children?.some(
|
|
6585
|
+
(child) => child.type === "mdxTextExpression" && child.value?.includes("frontmatter")
|
|
6586
|
+
);
|
|
6587
|
+
});
|
|
6588
|
+
if (h1Index >= 0) {
|
|
6589
|
+
root.children.splice(h1Index, 1);
|
|
6590
|
+
}
|
|
6486
6591
|
};
|
|
6487
6592
|
}
|
|
6488
6593
|
/**
|
|
@@ -6492,14 +6597,11 @@ ${codeText}
|
|
|
6492
6597
|
async processMdxContent(mdxContent, pageUrl, demosFolder, frontmatter) {
|
|
6493
6598
|
const demoFiles = [];
|
|
6494
6599
|
let processedContent = mdxContent;
|
|
6495
|
-
const lines = processedContent.split("\n");
|
|
6496
|
-
const titleLine = lines.findIndex((line) => line.startsWith("# "));
|
|
6497
|
-
processedContent = titleLine >= 0 ? lines.slice(titleLine + 1).join("\n") : processedContent;
|
|
6498
6600
|
processedContent = processedContent.replace(
|
|
6499
6601
|
/\[([^\]]+)\]\(\.\/#([^)]+)\)/g,
|
|
6500
6602
|
(_, text, anchor) => pageUrl && this.config.outputMode === "per-page" ? `[${text}](${pageUrl}#${anchor})` : text
|
|
6501
6603
|
);
|
|
6502
|
-
const processor = unified4().use(remarkParse4).use(remarkMdx3).use(this.replaceTypeDocProps()).use(this.
|
|
6604
|
+
const processor = unified4().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter3, ["yaml"]).use(this.replaceTypeDocProps()).use(this.replaceFrontmatterExpressions(frontmatter)).use(await this.replaceThemeNodes()).use(this.replaceDemos(demosFolder, demoFiles)).use(remarkStringify3);
|
|
6503
6605
|
const processed = await processor.process(processedContent);
|
|
6504
6606
|
processedContent = String(processed);
|
|
6505
6607
|
processedContent = processedContent.replace(/\n\s*\n\s*\n/g, "\n\n");
|
|
@@ -6524,7 +6626,7 @@ ${codeText}
|
|
|
6524
6626
|
component.demosFolder,
|
|
6525
6627
|
frontmatter
|
|
6526
6628
|
);
|
|
6527
|
-
const removeJsxProcessor = unified4().use(remarkParse4).use(remarkMdx3).use(remarkRemoveJsx).use(remarkStringify3);
|
|
6629
|
+
const removeJsxProcessor = unified4().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter3, ["yaml"]).use(remarkRemoveJsx).use(remarkStringify3);
|
|
6528
6630
|
const removedJsx = String(
|
|
6529
6631
|
await removeJsxProcessor.process(processedContent)
|
|
6530
6632
|
);
|
|
@@ -6699,7 +6801,7 @@ ${codeText}
|
|
|
6699
6801
|
};
|
|
6700
6802
|
async function generate(config2) {
|
|
6701
6803
|
const generator = new KnowledgeGenerator(config2);
|
|
6702
|
-
|
|
6804
|
+
return generator.run();
|
|
6703
6805
|
}
|
|
6704
6806
|
function addGenerateKnowledgeCommand() {
|
|
6705
6807
|
program.description("Generate llms.txt from QUI Docs documentation").command("generate-llms-txt").option("-n, --name <name>", "Project name for llms.txt header").requiredOption("-m, --output-mode <outputMode>").option("-o, --outputPath <outputPath>", "Output file or directory.").option(
|
|
@@ -7047,7 +7149,7 @@ import { dedent as dedent2 } from "@qualcomm-ui/utils/dedent";
|
|
|
7047
7149
|
// src/react-demo-plugin/demo-plugin-utils.ts
|
|
7048
7150
|
import chalk4 from "chalk";
|
|
7049
7151
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
7050
|
-
import { dirname as dirname2, join as
|
|
7152
|
+
import { dirname as dirname2, join as join5, relative as relative3, resolve as resolve7, sep } from "node:path";
|
|
7051
7153
|
import * as ts from "typescript";
|
|
7052
7154
|
import { pascalCase } from "@qualcomm-ui/utils/change-case";
|
|
7053
7155
|
function extractPageId(filePath, routesDir) {
|