@qualcomm-ui/mdx-vite 2.6.3 → 2.7.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 +95 -34
- package/dist/cli.js.map +3 -3
- package/dist/docs-plugin/__tests__/markdown-indexer.spec.d.ts.map +1 -0
- package/dist/docs-plugin/__tests__/remark-slug.spec.d.ts.map +1 -0
- package/dist/docs-plugin/__tests__/remix-flat-routes.spec.d.ts.map +1 -0
- package/dist/docs-plugin/__tests__/remix.spec.d.ts.map +1 -0
- package/dist/docs-plugin/__tests__/utils.d.ts.map +1 -0
- package/dist/docs-plugin/__tests__/utils.spec.d.ts +2 -0
- package/dist/docs-plugin/__tests__/utils.spec.d.ts.map +1 -0
- package/dist/docs-plugin/__tests__/vite-generouted.spec.d.ts.map +1 -0
- package/dist/docs-plugin/internal/config-schema.d.ts +24 -37
- package/dist/docs-plugin/internal/config-schema.d.ts.map +1 -1
- package/dist/docs-plugin/internal/zod.d.ts +2 -2
- package/dist/docs-plugin/internal/zod.d.ts.map +1 -1
- package/dist/docs-plugin/shiki/utils.d.ts.map +1 -1
- package/dist/docs-plugin/types.d.ts +71 -0
- package/dist/docs-plugin/types.d.ts.map +1 -1
- package/dist/index.js +30 -8
- package/dist/index.js.map +2 -2
- package/dist/open-web-ui-knowledge/generate-knowledge.d.ts.map +1 -1
- package/dist/open-web-ui-knowledge/load-config-from-env.d.ts.map +1 -1
- package/dist/open-web-ui-knowledge/types.d.ts +7 -34
- package/dist/open-web-ui-knowledge/types.d.ts.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +4 -2
- package/dist/docs-plugin/tests/markdown-indexer.spec.d.ts.map +0 -1
- package/dist/docs-plugin/tests/remark-slug.spec.d.ts.map +0 -1
- package/dist/docs-plugin/tests/remix-flat-routes.spec.d.ts.map +0 -1
- package/dist/docs-plugin/tests/remix.spec.d.ts.map +0 -1
- package/dist/docs-plugin/tests/utils.d.ts.map +0 -1
- package/dist/docs-plugin/tests/vite-generouted.spec.d.ts.map +0 -1
- /package/dist/docs-plugin/{tests → __tests__}/markdown-indexer.spec.d.ts +0 -0
- /package/dist/docs-plugin/{tests → __tests__}/remark-slug.spec.d.ts +0 -0
- /package/dist/docs-plugin/{tests → __tests__}/remix-flat-routes.spec.d.ts +0 -0
- /package/dist/docs-plugin/{tests → __tests__}/remix.spec.d.ts +0 -0
- /package/dist/docs-plugin/{tests → __tests__}/utils.d.ts +0 -0
- /package/dist/docs-plugin/{tests → __tests__}/vite-generouted.spec.d.ts +0 -0
package/dist/cli.js
CHANGED
|
@@ -3549,6 +3549,27 @@ var routeMetaSchema = implement().with({
|
|
|
3549
3549
|
var typeDocPropsSchema = implement().with({
|
|
3550
3550
|
includeInSearchIndex: z2.boolean().optional()
|
|
3551
3551
|
});
|
|
3552
|
+
var knowledgeExtraFileSchema = implement().with({
|
|
3553
|
+
contents: z2.string(),
|
|
3554
|
+
id: z2.string(),
|
|
3555
|
+
title: z2.string()
|
|
3556
|
+
});
|
|
3557
|
+
var knowledgeIntegrationSchema = implement().with(
|
|
3558
|
+
{
|
|
3559
|
+
baseUrl: z2.string().optional(),
|
|
3560
|
+
description: z2.string().optional(),
|
|
3561
|
+
exclude: z2.array(z2.string()).optional(),
|
|
3562
|
+
extraFiles: z2.array(knowledgeExtraFileSchema).optional(),
|
|
3563
|
+
metadata: z2.record(z2.string(), z2.string()).optional(),
|
|
3564
|
+
name: z2.string().optional(),
|
|
3565
|
+
outputMode: z2.union([z2.literal("per-page"), z2.literal("aggregated")]).optional(),
|
|
3566
|
+
outputPath: z2.string().optional(),
|
|
3567
|
+
pageTitlePrefix: z2.string().optional()
|
|
3568
|
+
}
|
|
3569
|
+
);
|
|
3570
|
+
var knowledgeConfigSchema = implement().with({
|
|
3571
|
+
global: knowledgeIntegrationSchema.optional()
|
|
3572
|
+
});
|
|
3552
3573
|
var configSchema = implement().with({
|
|
3553
3574
|
appDirectory: z2.string().optional(),
|
|
3554
3575
|
disableCache: z2.boolean().optional(),
|
|
@@ -3563,6 +3584,7 @@ var configSchema = implement().with({
|
|
|
3563
3584
|
])
|
|
3564
3585
|
).optional(),
|
|
3565
3586
|
hotUpdateIgnore: z2.instanceof(RegExp).optional(),
|
|
3587
|
+
knowledge: knowledgeConfigSchema.optional(),
|
|
3566
3588
|
navConfig: z2.array(z2.union([routeMetaSchema, navMetaSchema])).optional(),
|
|
3567
3589
|
pageDirectory: z2.string().optional(),
|
|
3568
3590
|
pageTimestampMetadata: z2.union([
|
|
@@ -3570,10 +3592,7 @@ var configSchema = implement().with({
|
|
|
3570
3592
|
z2.literal("timestamp"),
|
|
3571
3593
|
z2.literal("user-and-timestamp")
|
|
3572
3594
|
]).optional(),
|
|
3573
|
-
routingStrategy: z2.union([
|
|
3574
|
-
z2.literal("vite-generouted"),
|
|
3575
|
-
z2.function(z2.tuple([z2.string()]), z2.array(z2.string()))
|
|
3576
|
-
]).optional(),
|
|
3595
|
+
routingStrategy: z2.union([z2.literal("vite-generouted"), z2.any()]).optional(),
|
|
3577
3596
|
typeDocProps: z2.string().optional(),
|
|
3578
3597
|
typeDocPropsOptions: typeDocPropsSchema.optional()
|
|
3579
3598
|
});
|
|
@@ -5592,6 +5611,7 @@ function addDownloadKnowledgeCommand() {
|
|
|
5592
5611
|
}
|
|
5593
5612
|
|
|
5594
5613
|
// src/open-web-ui-knowledge/generate-knowledge.ts
|
|
5614
|
+
import { minimatch } from "minimatch";
|
|
5595
5615
|
import {
|
|
5596
5616
|
access,
|
|
5597
5617
|
mkdir as mkdir2,
|
|
@@ -5601,7 +5621,7 @@ import {
|
|
|
5601
5621
|
stat,
|
|
5602
5622
|
writeFile as writeFile3
|
|
5603
5623
|
} from "node:fs/promises";
|
|
5604
|
-
import { basename, dirname, extname, join as join3, resolve as resolve5 } from "node:path";
|
|
5624
|
+
import { basename, dirname, extname, join as join3, relative as relative2, resolve as resolve5 } from "node:path";
|
|
5605
5625
|
import remarkFrontmatter3 from "remark-frontmatter";
|
|
5606
5626
|
import remarkMdx3 from "remark-mdx";
|
|
5607
5627
|
import remarkParse4 from "remark-parse";
|
|
@@ -5830,15 +5850,21 @@ import { dedent } from "@qualcomm-ui/utils/dedent";
|
|
|
5830
5850
|
// src/open-web-ui-knowledge/load-config-from-env.ts
|
|
5831
5851
|
import { existsSync } from "node:fs";
|
|
5832
5852
|
import { join as join2, resolve as resolve4 } from "node:path";
|
|
5853
|
+
function parseCliMetadata(cliMetadata) {
|
|
5854
|
+
if (!cliMetadata?.length) {
|
|
5855
|
+
return void 0;
|
|
5856
|
+
}
|
|
5857
|
+
return Object.fromEntries(cliMetadata.map((entry) => entry.split("=")));
|
|
5858
|
+
}
|
|
5833
5859
|
function loadKnowledgeConfigFromEnv(options) {
|
|
5834
|
-
const
|
|
5835
|
-
const
|
|
5836
|
-
const
|
|
5860
|
+
const configLoader = new ConfigLoader({});
|
|
5861
|
+
const resolvedConfig = configLoader.loadConfig();
|
|
5862
|
+
const fileConfig = resolvedConfig.knowledge?.global;
|
|
5863
|
+
const exclude = (options.exclude?.length ? options.exclude : void 0) ?? fileConfig?.exclude ?? (process.env.FILE_EXCLUDE_PATTERN ?? "").split(",").filter(Boolean);
|
|
5864
|
+
const outputPath = options.outputPath ?? fileConfig?.outputPath ?? process.env.KNOWLEDGE_OUTPUT_PATH;
|
|
5837
5865
|
if (!outputPath) {
|
|
5838
5866
|
throw new Error("Missing required outputPath");
|
|
5839
5867
|
}
|
|
5840
|
-
const configLoader = new ConfigLoader({});
|
|
5841
|
-
const resolvedConfig = configLoader.loadConfig();
|
|
5842
5868
|
const routeDir = join2(
|
|
5843
5869
|
resolvedConfig.appDirectory,
|
|
5844
5870
|
resolvedConfig.pageDirectory
|
|
@@ -5846,13 +5872,18 @@ function loadKnowledgeConfigFromEnv(options) {
|
|
|
5846
5872
|
if (!existsSync(resolve4(routeDir))) {
|
|
5847
5873
|
throw new Error(`Route directory ${routeDir} does not exist`);
|
|
5848
5874
|
}
|
|
5875
|
+
const cliMetadata = parseCliMetadata(options.metadata);
|
|
5876
|
+
const mergedMetadata = fileConfig?.metadata || cliMetadata ? { ...fileConfig?.metadata, ...cliMetadata } : void 0;
|
|
5849
5877
|
return {
|
|
5878
|
+
...fileConfig,
|
|
5850
5879
|
...options,
|
|
5851
|
-
baseUrl: options.baseUrl
|
|
5880
|
+
baseUrl: options.baseUrl ?? fileConfig?.baseUrl ?? process.env.DOCS_SITE_BASE_URL,
|
|
5852
5881
|
docPropsPath: resolvedConfig.typeDocProps,
|
|
5853
5882
|
exclude,
|
|
5883
|
+
extraFiles: fileConfig?.extraFiles,
|
|
5884
|
+
metadata: mergedMetadata,
|
|
5854
5885
|
outputPath,
|
|
5855
|
-
pageTitlePrefix:
|
|
5886
|
+
pageTitlePrefix: options.pageTitlePrefix ?? fileConfig?.pageTitlePrefix ?? process.env.PAGE_TITLE_PREFIX,
|
|
5856
5887
|
routeDir
|
|
5857
5888
|
};
|
|
5858
5889
|
}
|
|
@@ -5919,10 +5950,7 @@ async function resolveModulePath(importPath, fromFile) {
|
|
|
5919
5950
|
return null;
|
|
5920
5951
|
}
|
|
5921
5952
|
function extractMetadata(metadata) {
|
|
5922
|
-
return (metadata ??
|
|
5923
|
-
const [key, value] = current.split("=");
|
|
5924
|
-
return [key, value];
|
|
5925
|
-
});
|
|
5953
|
+
return Object.entries(metadata ?? {});
|
|
5926
5954
|
}
|
|
5927
5955
|
var replaceNpmInstallTabs = () => {
|
|
5928
5956
|
return (tree, _file, done) => {
|
|
@@ -6001,6 +6029,7 @@ var KnowledgeGenerator = class {
|
|
|
6001
6029
|
processedPages,
|
|
6002
6030
|
extractedMetadata
|
|
6003
6031
|
);
|
|
6032
|
+
await this.generateExtraFiles(extractedMetadata);
|
|
6004
6033
|
}
|
|
6005
6034
|
}
|
|
6006
6035
|
async loadDocProps() {
|
|
@@ -6031,26 +6060,27 @@ var KnowledgeGenerator = class {
|
|
|
6031
6060
|
async scanPages() {
|
|
6032
6061
|
const components = [];
|
|
6033
6062
|
const excludePatterns = this.config.exclude ?? [];
|
|
6034
|
-
const shouldExclude = (
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
}
|
|
6041
|
-
|
|
6042
|
-
});
|
|
6063
|
+
const shouldExclude = (absolutePath) => {
|
|
6064
|
+
if (excludePatterns.length === 0) {
|
|
6065
|
+
return false;
|
|
6066
|
+
}
|
|
6067
|
+
const relativePath = relative2(this.config.routeDir, absolutePath);
|
|
6068
|
+
return excludePatterns.some(
|
|
6069
|
+
(pattern) => minimatch(relativePath, pattern, { matchBase: true })
|
|
6070
|
+
);
|
|
6043
6071
|
};
|
|
6044
6072
|
const scanDirectory = async (dirPath) => {
|
|
6045
6073
|
if (shouldExclude(dirPath)) {
|
|
6046
6074
|
if (this.config.verbose) {
|
|
6047
|
-
console.log(
|
|
6075
|
+
console.log(
|
|
6076
|
+
`Excluding directory: ${relative2(this.config.routeDir, dirPath)}`
|
|
6077
|
+
);
|
|
6048
6078
|
}
|
|
6049
6079
|
return;
|
|
6050
6080
|
}
|
|
6051
6081
|
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
6052
6082
|
const mdxFiles = entries.filter(
|
|
6053
|
-
(f) => f.name.endsWith(".mdx") && !shouldExclude(f.name)
|
|
6083
|
+
(f) => f.name.endsWith(".mdx") && !shouldExclude(join3(dirPath, f.name))
|
|
6054
6084
|
) ?? [];
|
|
6055
6085
|
for (const mdxFile of mdxFiles) {
|
|
6056
6086
|
const demosFolder = entries.find((f) => f.name === "demos");
|
|
@@ -6069,7 +6099,7 @@ var KnowledgeGenerator = class {
|
|
|
6069
6099
|
url: this.config.baseUrl ? new URL(url, this.config.baseUrl).toString() : void 0
|
|
6070
6100
|
});
|
|
6071
6101
|
if (this.config.verbose) {
|
|
6072
|
-
console.log(`Found
|
|
6102
|
+
console.log(`Found file: ${basename(dirPath)}`);
|
|
6073
6103
|
console.log(` Demos folder: ${demosFolderPath || "NOT FOUND"}`);
|
|
6074
6104
|
}
|
|
6075
6105
|
}
|
|
@@ -6520,10 +6550,41 @@ ${codeText}
|
|
|
6520
6550
|
const outputStats = await stat(this.config.outputPath);
|
|
6521
6551
|
const outputSizeKb = (outputStats.size / 1024).toFixed(1);
|
|
6522
6552
|
console.log(
|
|
6523
|
-
`Generated ${this.config.outputPath} with ${pages.length}
|
|
6553
|
+
`Generated ${this.config.outputPath} with ${pages.length} files(s) at: ${this.config.outputPath}`
|
|
6524
6554
|
);
|
|
6525
6555
|
console.log(`File size: ${outputSizeKb} KB`);
|
|
6526
6556
|
}
|
|
6557
|
+
async generateExtraFiles(metadata) {
|
|
6558
|
+
const extraFiles = this.config.extraFiles ?? [];
|
|
6559
|
+
if (extraFiles.length === 0) {
|
|
6560
|
+
return;
|
|
6561
|
+
}
|
|
6562
|
+
let totalSize = 0;
|
|
6563
|
+
await Promise.all(
|
|
6564
|
+
extraFiles.map(async (extraFile) => {
|
|
6565
|
+
const lines = [];
|
|
6566
|
+
if (metadata.length) {
|
|
6567
|
+
lines.push("---");
|
|
6568
|
+
for (const [key, value] of metadata) {
|
|
6569
|
+
lines.push(`${key}: ${value}`);
|
|
6570
|
+
}
|
|
6571
|
+
lines.push("---");
|
|
6572
|
+
lines.push("");
|
|
6573
|
+
}
|
|
6574
|
+
lines.push(`# ${extraFile.title}`);
|
|
6575
|
+
lines.push("");
|
|
6576
|
+
lines.push(extraFile.contents);
|
|
6577
|
+
lines.push("");
|
|
6578
|
+
const outfile = `${resolve5(this.config.outputPath)}/${kebabCase(extraFile.id)}.md`;
|
|
6579
|
+
await writeFile3(outfile, lines.join("\n"), "utf-8");
|
|
6580
|
+
const stats = await stat(outfile);
|
|
6581
|
+
totalSize += stats.size / 1024;
|
|
6582
|
+
})
|
|
6583
|
+
);
|
|
6584
|
+
console.log(
|
|
6585
|
+
`Generated ${extraFiles.length} extra file(s) (${totalSize.toFixed(1)} KB)`
|
|
6586
|
+
);
|
|
6587
|
+
}
|
|
6527
6588
|
async generatePerPageExports(pages, processedPages, metadata) {
|
|
6528
6589
|
await mkdir2(dirname(this.config.outputPath), { recursive: true }).catch(
|
|
6529
6590
|
() => {
|
|
@@ -6563,7 +6624,7 @@ ${codeText}
|
|
|
6563
6624
|
}
|
|
6564
6625
|
lines.push(content);
|
|
6565
6626
|
lines.push("");
|
|
6566
|
-
if (
|
|
6627
|
+
if (processedPage.demoFiles.length > 0) {
|
|
6567
6628
|
if (this.config.verbose) {
|
|
6568
6629
|
console.log(
|
|
6569
6630
|
`Collecting imports for ${page.name} from ${processedPage.demoFiles.length} demo files`
|
|
@@ -6605,7 +6666,7 @@ ${codeText}
|
|
|
6605
6666
|
totalSize += stats.size / 1024;
|
|
6606
6667
|
})
|
|
6607
6668
|
);
|
|
6608
|
-
console.log(`Generated ${count}
|
|
6669
|
+
console.log(`Generated ${count} files(s) in ${this.config.outputPath}`);
|
|
6609
6670
|
console.log(`Folder size: ${totalSize.toFixed(1)} KB`);
|
|
6610
6671
|
}
|
|
6611
6672
|
};
|
|
@@ -6619,7 +6680,7 @@ function addGenerateKnowledgeCommand() {
|
|
|
6619
6680
|
"Project description for llms.txt"
|
|
6620
6681
|
).option("-v, --verbose", "Enable verbose logging", false).option(
|
|
6621
6682
|
"--exclude <patterns...>",
|
|
6622
|
-
"
|
|
6683
|
+
"Glob patterns to exclude (e.g., **/internal/**, guide/drafts/*)",
|
|
6623
6684
|
[]
|
|
6624
6685
|
).option("--base-url <url>", "Base URL for component documentation links").option("--metadata <pairs...>", "metadata key-value pairs").option("--clean", "Clean the output path before generating").option("--include-imports", "Include relative import source files", true).action(async (options) => {
|
|
6625
6686
|
loadEnv();
|
|
@@ -6959,11 +7020,11 @@ import { dedent as dedent2 } from "@qualcomm-ui/utils/dedent";
|
|
|
6959
7020
|
// src/react-demo-plugin/demo-plugin-utils.ts
|
|
6960
7021
|
import chalk4 from "chalk";
|
|
6961
7022
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
6962
|
-
import { dirname as dirname2, join as join4, relative as
|
|
7023
|
+
import { dirname as dirname2, join as join4, relative as relative3, resolve as resolve7, sep } from "node:path";
|
|
6963
7024
|
import * as ts from "typescript";
|
|
6964
7025
|
import { pascalCase } from "@qualcomm-ui/utils/change-case";
|
|
6965
7026
|
function extractPageId(filePath, routesDir) {
|
|
6966
|
-
const relativePath =
|
|
7027
|
+
const relativePath = relative3(routesDir, filePath);
|
|
6967
7028
|
const pathParts = relativePath.split(sep);
|
|
6968
7029
|
if (pathParts.includes("demos")) {
|
|
6969
7030
|
const demosIndex = pathParts.indexOf("demos");
|