@qualcomm-ui/mdx-vite 2.17.0 → 2.17.2
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 +166 -163
- package/dist/cli.js.map +4 -4
- package/dist/docs-plugin/internal/search-indexer.d.ts.map +1 -1
- package/dist/docs-plugin/internal/services/markdown/markdown-file-reader.d.ts +4 -4
- package/dist/docs-plugin/internal/services/markdown/markdown-file-reader.d.ts.map +1 -1
- package/dist/docs-plugin/internal/services/markdown/markdown-indexer.d.ts.map +1 -1
- package/dist/index.js +167 -164
- package/dist/index.js.map +4 -4
- package/dist/tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -3504,7 +3504,7 @@ var {
|
|
|
3504
3504
|
// src/ai-knowledge/env.ts
|
|
3505
3505
|
import { config } from "dotenv";
|
|
3506
3506
|
import { existsSync } from "node:fs";
|
|
3507
|
-
import { join as join2, resolve } from "node:path";
|
|
3507
|
+
import { join as join2, resolve as resolve2 } from "node:path";
|
|
3508
3508
|
|
|
3509
3509
|
// src/docs-plugin/internal/config-loader.ts
|
|
3510
3510
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
@@ -3946,43 +3946,41 @@ import chalk from "chalk";
|
|
|
3946
3946
|
import { execSync } from "node:child_process";
|
|
3947
3947
|
import { createHash } from "node:crypto";
|
|
3948
3948
|
import { readFileSync } from "node:fs";
|
|
3949
|
-
import {
|
|
3949
|
+
import { resolve } from "node:path";
|
|
3950
3950
|
import remarkFrontmatter from "remark-frontmatter";
|
|
3951
3951
|
import remarkParse2 from "remark-parse";
|
|
3952
3952
|
import remarkParseFrontmatter from "remark-parse-frontmatter";
|
|
3953
3953
|
import remarkStringify2 from "remark-stringify";
|
|
3954
3954
|
import { unified as unified2 } from "unified";
|
|
3955
|
-
function
|
|
3956
|
-
|
|
3957
|
-
encoding: "utf-8"
|
|
3958
|
-
}).trim();
|
|
3959
|
-
}
|
|
3960
|
-
function getGitMetadata(filePath, mode) {
|
|
3955
|
+
function buildGitMetadataMap(srcDir, mode) {
|
|
3956
|
+
const map = /* @__PURE__ */ new Map();
|
|
3961
3957
|
if (mode === "off") {
|
|
3962
|
-
return
|
|
3958
|
+
return map;
|
|
3963
3959
|
}
|
|
3964
3960
|
try {
|
|
3965
|
-
const repoRoot =
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
const
|
|
3969
|
-
|
|
3970
|
-
{
|
|
3971
|
-
|
|
3972
|
-
|
|
3961
|
+
const repoRoot = execSync("git rev-parse --show-toplevel", {
|
|
3962
|
+
encoding: "utf-8"
|
|
3963
|
+
}).trim();
|
|
3964
|
+
const format = mode === "user-and-timestamp" ? "%cI%x09%aN" : "%cI";
|
|
3965
|
+
const output = execSync(
|
|
3966
|
+
`git log --format="COMMIT%x09${format}" --name-only -- "${srcDir}/**/*.mdx"`,
|
|
3967
|
+
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
3968
|
+
);
|
|
3969
|
+
let currentMetadata = {};
|
|
3970
|
+
for (const line of output.split("\n")) {
|
|
3971
|
+
if (line.startsWith("COMMIT ")) {
|
|
3972
|
+
const parts = line.split(" ");
|
|
3973
|
+
currentMetadata = mode === "user-and-timestamp" ? { updatedBy: parts[2], updatedOn: parts[1] } : { updatedOn: parts[1] };
|
|
3974
|
+
} else if (line.trim()) {
|
|
3975
|
+
const absolutePath = resolve(repoRoot, line.trim());
|
|
3976
|
+
if (!map.has(absolutePath)) {
|
|
3977
|
+
map.set(absolutePath, currentMetadata);
|
|
3978
|
+
}
|
|
3973
3979
|
}
|
|
3974
|
-
).trim();
|
|
3975
|
-
if (!result) {
|
|
3976
|
-
return {};
|
|
3977
|
-
}
|
|
3978
|
-
if (mode === "user-and-timestamp") {
|
|
3979
|
-
const [updatedOn, updatedBy] = result.split("\n");
|
|
3980
|
-
return { updatedBy, updatedOn };
|
|
3981
3980
|
}
|
|
3982
|
-
return { updatedOn: result };
|
|
3983
3981
|
} catch {
|
|
3984
|
-
return {};
|
|
3985
3982
|
}
|
|
3983
|
+
return map;
|
|
3986
3984
|
}
|
|
3987
3985
|
var MarkdownFileReader = class {
|
|
3988
3986
|
constructor(enabled, pageTimestampMetadata = "off") {
|
|
@@ -3990,6 +3988,7 @@ var MarkdownFileReader = class {
|
|
|
3990
3988
|
this.pageTimestampMetadata = pageTimestampMetadata;
|
|
3991
3989
|
}
|
|
3992
3990
|
cachedFileCount = 0;
|
|
3991
|
+
gitMetadataMap = /* @__PURE__ */ new Map();
|
|
3993
3992
|
logWarnings = true;
|
|
3994
3993
|
mdxCache = {};
|
|
3995
3994
|
hash(input) {
|
|
@@ -4056,7 +4055,7 @@ var MarkdownFileReader = class {
|
|
|
4056
4055
|
const existingCache = this.mdxCache[filepath];
|
|
4057
4056
|
const shouldFetchGitMetadata = !this.enabled || !existingCache;
|
|
4058
4057
|
if (shouldFetchGitMetadata) {
|
|
4059
|
-
const gitMetadata =
|
|
4058
|
+
const gitMetadata = this.gitMetadataMap.get(filepath) ?? {};
|
|
4060
4059
|
if (!frontmatter.updatedOn && gitMetadata.updatedOn) {
|
|
4061
4060
|
frontmatter.updatedOn = gitMetadata.updatedOn;
|
|
4062
4061
|
}
|
|
@@ -4404,8 +4403,109 @@ var alertToEmphasis = {
|
|
|
4404
4403
|
warning: "warning"
|
|
4405
4404
|
};
|
|
4406
4405
|
|
|
4406
|
+
// src/docs-plugin/remark/remark-extract-meta.ts
|
|
4407
|
+
import { SKIP, visit as visit4 } from "unist-util-visit";
|
|
4408
|
+
function parseValue(value) {
|
|
4409
|
+
const trimmed = value.trim();
|
|
4410
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
4411
|
+
const inner = trimmed.slice(1, -1);
|
|
4412
|
+
return inner.split(",").map((item) => item.trim()).filter(Boolean);
|
|
4413
|
+
}
|
|
4414
|
+
return trimmed;
|
|
4415
|
+
}
|
|
4416
|
+
function parseMetaContent(content) {
|
|
4417
|
+
const result = {};
|
|
4418
|
+
const lines = content.split("\n");
|
|
4419
|
+
for (const line of lines) {
|
|
4420
|
+
const trimmed = line.trim();
|
|
4421
|
+
if (!trimmed || trimmed === ":::") {
|
|
4422
|
+
continue;
|
|
4423
|
+
}
|
|
4424
|
+
const colonIndex = trimmed.indexOf(":");
|
|
4425
|
+
if (colonIndex === -1) {
|
|
4426
|
+
continue;
|
|
4427
|
+
}
|
|
4428
|
+
const key = trimmed.slice(0, colonIndex).trim();
|
|
4429
|
+
const value = trimmed.slice(colonIndex + 1).trim();
|
|
4430
|
+
if (key && value) {
|
|
4431
|
+
result[key] = parseValue(value);
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
return result;
|
|
4435
|
+
}
|
|
4436
|
+
function parseTermsContent(content) {
|
|
4437
|
+
return content.split("\n").map((line) => line.trim()).filter((line) => line && line !== ":::");
|
|
4438
|
+
}
|
|
4439
|
+
var remarkExtractMeta = (metadata = {}) => {
|
|
4440
|
+
return (tree) => {
|
|
4441
|
+
const nodesToRemove = [];
|
|
4442
|
+
visit4(tree, "paragraph", (node, index, parent) => {
|
|
4443
|
+
if (!parent || index === void 0) {
|
|
4444
|
+
return;
|
|
4445
|
+
}
|
|
4446
|
+
const firstChild = node.children[0];
|
|
4447
|
+
if (firstChild?.type !== "text") {
|
|
4448
|
+
return;
|
|
4449
|
+
}
|
|
4450
|
+
const text = firstChild.value;
|
|
4451
|
+
const metaMatch = text.match(/^:::\s*meta\s*/);
|
|
4452
|
+
const termsMatch = text.match(/^:::\s*terms\s*/);
|
|
4453
|
+
if (!metaMatch && !termsMatch) {
|
|
4454
|
+
return;
|
|
4455
|
+
}
|
|
4456
|
+
const openMatch = metaMatch || termsMatch;
|
|
4457
|
+
const isTermsBlock = !!termsMatch;
|
|
4458
|
+
if (text.includes(":::") && text.lastIndexOf(":::") > openMatch[0].length) {
|
|
4459
|
+
const afterOpen = text.slice(openMatch[0].length);
|
|
4460
|
+
const closeIndex = afterOpen.lastIndexOf(":::");
|
|
4461
|
+
const content = afterOpen.slice(0, closeIndex);
|
|
4462
|
+
if (isTermsBlock) {
|
|
4463
|
+
const terms = parseTermsContent(content);
|
|
4464
|
+
if (terms.length > 0) {
|
|
4465
|
+
const existing = metadata.terms;
|
|
4466
|
+
metadata.terms = Array.isArray(existing) ? [...existing, ...terms] : terms;
|
|
4467
|
+
}
|
|
4468
|
+
} else {
|
|
4469
|
+
const parsed = parseMetaContent(content);
|
|
4470
|
+
Object.assign(metadata, parsed);
|
|
4471
|
+
}
|
|
4472
|
+
nodesToRemove.push({ index, parent });
|
|
4473
|
+
return SKIP;
|
|
4474
|
+
}
|
|
4475
|
+
let fullText = text;
|
|
4476
|
+
for (let i = 1; i < node.children.length; i++) {
|
|
4477
|
+
const child = node.children[i];
|
|
4478
|
+
if (child.type === "text") {
|
|
4479
|
+
fullText += child.value;
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
const afterOpenFull = fullText.slice(openMatch[0].length);
|
|
4483
|
+
const closeIndexFull = afterOpenFull.lastIndexOf(":::");
|
|
4484
|
+
if (closeIndexFull !== -1) {
|
|
4485
|
+
const content = afterOpenFull.slice(0, closeIndexFull);
|
|
4486
|
+
if (isTermsBlock) {
|
|
4487
|
+
const terms = parseTermsContent(content);
|
|
4488
|
+
if (terms.length > 0) {
|
|
4489
|
+
const existing = metadata.terms;
|
|
4490
|
+
metadata.terms = Array.isArray(existing) ? [...existing, ...terms] : terms;
|
|
4491
|
+
}
|
|
4492
|
+
} else {
|
|
4493
|
+
const parsed = parseMetaContent(content);
|
|
4494
|
+
Object.assign(metadata, parsed);
|
|
4495
|
+
}
|
|
4496
|
+
nodesToRemove.push({ index, parent });
|
|
4497
|
+
return SKIP;
|
|
4498
|
+
}
|
|
4499
|
+
});
|
|
4500
|
+
for (let i = nodesToRemove.length - 1; i >= 0; i--) {
|
|
4501
|
+
const { index, parent } = nodesToRemove[i];
|
|
4502
|
+
parent.children.splice(index, 1);
|
|
4503
|
+
}
|
|
4504
|
+
};
|
|
4505
|
+
};
|
|
4506
|
+
|
|
4407
4507
|
// src/docs-plugin/remark/remark-frontmatter-interpolation.ts
|
|
4408
|
-
import { visit as
|
|
4508
|
+
import { visit as visit5 } from "unist-util-visit";
|
|
4409
4509
|
var FRONTMATTER_PATTERN = /^\s*frontmatter\.(\w+)\s*$/;
|
|
4410
4510
|
function isMdxExpression(node) {
|
|
4411
4511
|
const n = node;
|
|
@@ -4413,7 +4513,7 @@ function isMdxExpression(node) {
|
|
|
4413
4513
|
}
|
|
4414
4514
|
var remarkFrontmatterInterpolation = (frontmatter) => {
|
|
4415
4515
|
return (tree) => {
|
|
4416
|
-
|
|
4516
|
+
visit5(tree, (node, index, parent) => {
|
|
4417
4517
|
if (!isMdxExpression(node) || index === void 0 || !parent) {
|
|
4418
4518
|
return;
|
|
4419
4519
|
}
|
|
@@ -4532,7 +4632,7 @@ var MarkdownIndexer = class {
|
|
|
4532
4632
|
}
|
|
4533
4633
|
}
|
|
4534
4634
|
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);
|
|
4635
|
+
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
4636
|
let contents = file.toString();
|
|
4537
4637
|
contents = contents.substring(contents.indexOf("<h1>"));
|
|
4538
4638
|
const htmlAst = unified3().data("settings", { fragment: true }).use(rehypeParse).use(rehypeStringify).use(rehypeSlug).processSync(contents);
|
|
@@ -5262,6 +5362,10 @@ var SearchIndexer = class {
|
|
|
5262
5362
|
this.config.routingStrategy
|
|
5263
5363
|
);
|
|
5264
5364
|
this._mdxFileCount = mdxFileGlob.length;
|
|
5365
|
+
this.fileCache.gitMetadataMap = buildGitMetadataMap(
|
|
5366
|
+
this.config.srcDir,
|
|
5367
|
+
this.fileCache.pageTimestampMetadata
|
|
5368
|
+
);
|
|
5265
5369
|
const compiledFiles = mdxFileGlob.map((file) => this.compileMdxFile(file));
|
|
5266
5370
|
const mdxIndex = compiledFiles.map((fileData) => fileData.pageSections).flat();
|
|
5267
5371
|
filterFileGlob(
|
|
@@ -5317,7 +5421,7 @@ function loadKnowledgeConfigFromEnv(options) {
|
|
|
5317
5421
|
resolvedConfig.appDirectory,
|
|
5318
5422
|
resolvedConfig.pageDirectory
|
|
5319
5423
|
);
|
|
5320
|
-
if (!existsSync(
|
|
5424
|
+
if (!existsSync(resolve2(routeDir))) {
|
|
5321
5425
|
throw new Error(`Route directory ${routeDir} does not exist`);
|
|
5322
5426
|
}
|
|
5323
5427
|
const cliMetadata = parseCliMetadata(options.metadata);
|
|
@@ -5354,7 +5458,7 @@ function loadEnvironmentConfigs(options = {}) {
|
|
|
5354
5458
|
resolvedConfig.appDirectory,
|
|
5355
5459
|
resolvedConfig.pageDirectory
|
|
5356
5460
|
);
|
|
5357
|
-
if (!existsSync(
|
|
5461
|
+
if (!existsSync(resolve2(routeDir))) {
|
|
5358
5462
|
throw new Error(`Route directory ${routeDir} does not exist`);
|
|
5359
5463
|
}
|
|
5360
5464
|
if (!environments || environments.length === 0 || options.cliOptions?.outputPath) {
|
|
@@ -5401,7 +5505,7 @@ import AdmZip from "adm-zip";
|
|
|
5401
5505
|
import chalk4 from "chalk";
|
|
5402
5506
|
import { minimatch } from "minimatch";
|
|
5403
5507
|
import { mkdir, readdir, readFile as readFile4, rm, stat, writeFile } from "node:fs/promises";
|
|
5404
|
-
import { basename as basename2, dirname as dirname3, join as join7, relative
|
|
5508
|
+
import { basename as basename2, dirname as dirname3, join as join7, relative, resolve as resolve6 } from "node:path";
|
|
5405
5509
|
import remarkFrontmatter3 from "remark-frontmatter";
|
|
5406
5510
|
import remarkMdx3 from "remark-mdx";
|
|
5407
5511
|
import remarkParse4 from "remark-parse";
|
|
@@ -5411,107 +5515,6 @@ import { unified as unified5 } from "unified";
|
|
|
5411
5515
|
import { visit as visit18 } from "unist-util-visit";
|
|
5412
5516
|
import { kebabCase as kebabCase3 } from "@qualcomm-ui/utils/change-case";
|
|
5413
5517
|
|
|
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
5518
|
// src/ai-knowledge/generator/config.ts
|
|
5516
5519
|
var currentConfig = null;
|
|
5517
5520
|
function setConfig(config3) {
|
|
@@ -5533,7 +5536,7 @@ import { kebabCase } from "@qualcomm-ui/utils/change-case";
|
|
|
5533
5536
|
// src/ai-knowledge/generator/utils.ts
|
|
5534
5537
|
import { createHash as createHash2 } from "node:crypto";
|
|
5535
5538
|
import { access, readFile } from "node:fs/promises";
|
|
5536
|
-
import { dirname, join as join3, resolve as
|
|
5539
|
+
import { dirname, join as join3, resolve as resolve3 } from "node:path";
|
|
5537
5540
|
import ts from "typescript";
|
|
5538
5541
|
async function exists(dirPath) {
|
|
5539
5542
|
return access(dirPath).then(() => true).catch(() => false);
|
|
@@ -5579,7 +5582,7 @@ function extractRelativeImports(content) {
|
|
|
5579
5582
|
}
|
|
5580
5583
|
async function resolveModulePath(importPath, fromFile) {
|
|
5581
5584
|
const fromDir = dirname(fromFile);
|
|
5582
|
-
const baseResolved =
|
|
5585
|
+
const baseResolved = resolve3(fromDir, importPath);
|
|
5583
5586
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ""];
|
|
5584
5587
|
for (const ext of extensions) {
|
|
5585
5588
|
const fullPath = baseResolved + ext;
|
|
@@ -5747,7 +5750,7 @@ function formatDemos(demosFolder) {
|
|
|
5747
5750
|
|
|
5748
5751
|
// src/ai-knowledge/generator/doc-props-plugin.ts
|
|
5749
5752
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
5750
|
-
import { dirname as dirname2, join as join5, resolve as
|
|
5753
|
+
import { dirname as dirname2, join as join5, resolve as resolve4 } from "node:path";
|
|
5751
5754
|
import { visit as visit7 } from "unist-util-visit";
|
|
5752
5755
|
function extractBestType(propInfo) {
|
|
5753
5756
|
const type = propInfo.resolvedType?.prettyType || propInfo.type;
|
|
@@ -5791,7 +5794,7 @@ var PropFormatter = class {
|
|
|
5791
5794
|
return this.docProps;
|
|
5792
5795
|
}
|
|
5793
5796
|
const config3 = getConfig();
|
|
5794
|
-
const resolvedDocPropsPath = config3.docPropsPath ? await exists(config3.docPropsPath) ? config3.docPropsPath :
|
|
5797
|
+
const resolvedDocPropsPath = config3.docPropsPath ? await exists(config3.docPropsPath) ? config3.docPropsPath : resolve4(process.cwd(), config3.docPropsPath) : join5(dirname2(config3.routeDir), "doc-props.json");
|
|
5795
5798
|
if (!await exists(resolvedDocPropsPath)) {
|
|
5796
5799
|
if (config3.verbose) {
|
|
5797
5800
|
console.log(`Doc props file not found at: ${resolvedDocPropsPath}`);
|
|
@@ -6005,7 +6008,7 @@ import chalk3 from "chalk";
|
|
|
6005
6008
|
import chokidar from "chokidar";
|
|
6006
6009
|
import { glob } from "glob";
|
|
6007
6010
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
6008
|
-
import { join as join6, resolve as
|
|
6011
|
+
import { join as join6, resolve as resolve5 } from "node:path";
|
|
6009
6012
|
import prettyMilliseconds from "pretty-ms";
|
|
6010
6013
|
var isDev = process.env.NODE_ENV === "development";
|
|
6011
6014
|
var VIRTUAL_MODULE_ID = "\0@qualcomm-ui/mdx-vite-plugin";
|
|
@@ -6066,12 +6069,12 @@ var PluginState = class {
|
|
|
6066
6069
|
createIndexer(config3) {
|
|
6067
6070
|
this.config = config3;
|
|
6068
6071
|
this.configFilePath = config3.filePath;
|
|
6069
|
-
this.docPropsFilePath = config3.typeDocProps ? fixPath(
|
|
6070
|
-
this.routesDir = fixPath(
|
|
6072
|
+
this.docPropsFilePath = config3.typeDocProps ? fixPath(resolve5(this.cwd, config3.typeDocProps)) : "";
|
|
6073
|
+
this.routesDir = fixPath(resolve5(config3.appDirectory, config3.pageDirectory));
|
|
6071
6074
|
this.knowledgeConfig = config3.knowledge;
|
|
6072
6075
|
this.indexer = new SearchIndexer({
|
|
6073
6076
|
...config3,
|
|
6074
|
-
srcDir: fixPath(
|
|
6077
|
+
srcDir: fixPath(resolve5(this.cwd, config3.appDirectory)),
|
|
6075
6078
|
typeDocProps: this.resolveDocProps()
|
|
6076
6079
|
});
|
|
6077
6080
|
const exportsConfig = config3.knowledge?.global?.exports;
|
|
@@ -6659,7 +6662,7 @@ var KnowledgeGenerator = class {
|
|
|
6659
6662
|
if (excludePatterns.length === 0) {
|
|
6660
6663
|
return false;
|
|
6661
6664
|
}
|
|
6662
|
-
const relativePath =
|
|
6665
|
+
const relativePath = relative(this.config.routeDir, absolutePath);
|
|
6663
6666
|
return excludePatterns.some(
|
|
6664
6667
|
(pattern) => minimatch(relativePath, pattern, { matchBase: true })
|
|
6665
6668
|
);
|
|
@@ -6668,7 +6671,7 @@ var KnowledgeGenerator = class {
|
|
|
6668
6671
|
if (shouldExclude(dirPath)) {
|
|
6669
6672
|
if (this.config.verbose) {
|
|
6670
6673
|
console.log(
|
|
6671
|
-
`Excluding directory: ${
|
|
6674
|
+
`Excluding directory: ${relative(this.config.routeDir, dirPath)}`
|
|
6672
6675
|
);
|
|
6673
6676
|
}
|
|
6674
6677
|
return;
|
|
@@ -6906,7 +6909,7 @@ var KnowledgeGenerator = class {
|
|
|
6906
6909
|
lines.push("");
|
|
6907
6910
|
const fileContent = lines.join("\n");
|
|
6908
6911
|
const fileName = `${kebabCase3(extraFile.id)}.md`;
|
|
6909
|
-
const outfile = `${
|
|
6912
|
+
const outfile = `${resolve6(this.config.outputPath)}/${fileName}`;
|
|
6910
6913
|
await writeFile(outfile, fileContent, "utf-8");
|
|
6911
6914
|
const stats = await stat(outfile);
|
|
6912
6915
|
totalSize += stats.size / 1024;
|
|
@@ -7009,7 +7012,7 @@ var KnowledgeGenerator = class {
|
|
|
7009
7012
|
lines.push("");
|
|
7010
7013
|
const fileContent = lines.join("\n");
|
|
7011
7014
|
const fileName = `${kebabCase3(page.id || page.name)}.md`;
|
|
7012
|
-
const outfile = `${
|
|
7015
|
+
const outfile = `${resolve6(this.config.outputPath)}/${fileName}`;
|
|
7013
7016
|
await writeFile(outfile, fileContent, "utf-8");
|
|
7014
7017
|
const stats = await stat(outfile);
|
|
7015
7018
|
totalSize += stats.size / 1024;
|
|
@@ -7171,7 +7174,7 @@ Generated knowledge for ${configs.length} environment(s)`
|
|
|
7171
7174
|
// src/ai-knowledge/open-web-ui/download-knowledge.ts
|
|
7172
7175
|
import dotenv from "dotenv";
|
|
7173
7176
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
7174
|
-
import { resolve as
|
|
7177
|
+
import { resolve as resolve7 } from "node:path";
|
|
7175
7178
|
|
|
7176
7179
|
// src/ai-knowledge/open-web-ui/api.ts
|
|
7177
7180
|
function isErrorResponse(response) {
|
|
@@ -7282,7 +7285,7 @@ var FilesApi = class {
|
|
|
7282
7285
|
if (status.status === "completed" || status.status === "failed") {
|
|
7283
7286
|
return status;
|
|
7284
7287
|
}
|
|
7285
|
-
await new Promise((
|
|
7288
|
+
await new Promise((resolve12) => setTimeout(resolve12, intervalMs));
|
|
7286
7289
|
}
|
|
7287
7290
|
throw new Error(`File processing timed out after ${maxAttempts} attempts`);
|
|
7288
7291
|
}
|
|
@@ -7496,7 +7499,7 @@ function addDownloadKnowledgeCommand() {
|
|
|
7496
7499
|
const content = await filesApi.getDataContent(file.id);
|
|
7497
7500
|
if (content?.content) {
|
|
7498
7501
|
await writeFile2(
|
|
7499
|
-
|
|
7502
|
+
resolve7(opts.outputDir, fileName),
|
|
7500
7503
|
content.content,
|
|
7501
7504
|
"utf-8"
|
|
7502
7505
|
);
|
|
@@ -7512,7 +7515,7 @@ function addDownloadKnowledgeCommand() {
|
|
|
7512
7515
|
import { createHash as createHash3 } from "node:crypto";
|
|
7513
7516
|
import { writeFileSync } from "node:fs";
|
|
7514
7517
|
import { access as access2, readdir as readdir2, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
7515
|
-
import { resolve as
|
|
7518
|
+
import { resolve as resolve8 } from "node:path";
|
|
7516
7519
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
7517
7520
|
import ora from "ora";
|
|
7518
7521
|
|
|
@@ -7719,7 +7722,7 @@ var Uploader = class {
|
|
|
7719
7722
|
const files = await Promise.all(
|
|
7720
7723
|
fileNames.map(async (name) => ({
|
|
7721
7724
|
contents: await readFile5(
|
|
7722
|
-
|
|
7725
|
+
resolve8(this.config.knowledgeFilePath, name),
|
|
7723
7726
|
"utf-8"
|
|
7724
7727
|
),
|
|
7725
7728
|
name
|
|
@@ -7771,7 +7774,7 @@ var Uploader = class {
|
|
|
7771
7774
|
try {
|
|
7772
7775
|
const fileId = knowledgeFile.id;
|
|
7773
7776
|
const fileString = await readFile5(
|
|
7774
|
-
|
|
7777
|
+
resolve8(this.config.knowledgeFilePath, name),
|
|
7775
7778
|
"utf-8"
|
|
7776
7779
|
);
|
|
7777
7780
|
const spinner2 = ora(`Updating ${name}`).start();
|
|
@@ -7786,7 +7789,7 @@ var Uploader = class {
|
|
|
7786
7789
|
}
|
|
7787
7790
|
const spinner = ora(`Uploading ${name}`).start();
|
|
7788
7791
|
const fileBuffer = await readFile5(
|
|
7789
|
-
|
|
7792
|
+
resolve8(this.config.knowledgeFilePath, name)
|
|
7790
7793
|
);
|
|
7791
7794
|
let uploadedFileId = void 0;
|
|
7792
7795
|
try {
|
|
@@ -7824,7 +7827,7 @@ var Uploader = class {
|
|
|
7824
7827
|
}
|
|
7825
7828
|
}
|
|
7826
7829
|
async uploadKnowledge() {
|
|
7827
|
-
const resolvedPath =
|
|
7830
|
+
const resolvedPath = resolve8(this.config.knowledgeFilePath);
|
|
7828
7831
|
if (!await access2(resolvedPath).then(() => true).catch(() => false)) {
|
|
7829
7832
|
throw new Error(`File or folder not found at ${resolvedPath}`);
|
|
7830
7833
|
}
|
|
@@ -7911,7 +7914,7 @@ Uploaded to ${successCount} integration(s)${failureCount > 0 ? `, ${failureCount
|
|
|
7911
7914
|
const files = await uploader.filesApi.search("*");
|
|
7912
7915
|
console.debug(`found ${files.length} files`);
|
|
7913
7916
|
writeFileSync(
|
|
7914
|
-
|
|
7917
|
+
resolve8(uploader.config.knowledgeFilePath, "files.json"),
|
|
7915
7918
|
JSON.stringify(files, null, 2),
|
|
7916
7919
|
"utf-8"
|
|
7917
7920
|
);
|
|
@@ -7956,7 +7959,7 @@ Uploaded to ${successCount} integration(s)${failureCount > 0 ? `, ${failureCount
|
|
|
7956
7959
|
// src/docs-plugin/generate-page-map.ts
|
|
7957
7960
|
import { glob as glob2 } from "glob";
|
|
7958
7961
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
7959
|
-
import { resolve as
|
|
7962
|
+
import { resolve as resolve9 } from "node:path";
|
|
7960
7963
|
import { cwd } from "node:process";
|
|
7961
7964
|
function addGeneratePageMapCommand() {
|
|
7962
7965
|
program.command("generate-page-map").description(
|
|
@@ -7977,11 +7980,11 @@ function addGeneratePageMapCommand() {
|
|
|
7977
7980
|
const configLoader = new ConfigLoader({ configFile: options.configFile });
|
|
7978
7981
|
const resolvedConfig = configLoader.loadConfig();
|
|
7979
7982
|
const routesDir = fixPath(
|
|
7980
|
-
|
|
7983
|
+
resolve9(resolvedConfig.appDirectory, resolvedConfig.pageDirectory)
|
|
7981
7984
|
);
|
|
7982
7985
|
const indexer = new SearchIndexer({
|
|
7983
7986
|
...resolvedConfig,
|
|
7984
|
-
srcDir: fixPath(
|
|
7987
|
+
srcDir: fixPath(resolve9(cwd(), resolvedConfig.appDirectory)),
|
|
7985
7988
|
typeDocProps: {}
|
|
7986
7989
|
});
|
|
7987
7990
|
const files = glob2.sync(
|
|
@@ -7993,7 +7996,7 @@ function addGeneratePageMapCommand() {
|
|
|
7993
7996
|
);
|
|
7994
7997
|
indexer.buildIndex(files, true);
|
|
7995
7998
|
await writeFile3(
|
|
7996
|
-
|
|
7999
|
+
resolve9(cwd(), options.output),
|
|
7997
8000
|
JSON.stringify(indexer.pageMap, null, 2),
|
|
7998
8001
|
"utf-8"
|
|
7999
8002
|
);
|
|
@@ -8011,17 +8014,17 @@ function addGeneratePageMapCommand() {
|
|
|
8011
8014
|
import { glob as glob3 } from "glob";
|
|
8012
8015
|
import { uniqBy } from "lodash-es";
|
|
8013
8016
|
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
8014
|
-
import { resolve as
|
|
8017
|
+
import { resolve as resolve11 } from "node:path";
|
|
8015
8018
|
import { dedent as dedent2 } from "@qualcomm-ui/utils/dedent";
|
|
8016
8019
|
|
|
8017
8020
|
// src/react-demo-plugin/demo-plugin-utils.ts
|
|
8018
8021
|
import chalk5 from "chalk";
|
|
8019
8022
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
8020
|
-
import { dirname as dirname4, join as join8, relative as
|
|
8023
|
+
import { dirname as dirname4, join as join8, relative as relative2, resolve as resolve10, sep } from "node:path";
|
|
8021
8024
|
import * as ts2 from "typescript";
|
|
8022
8025
|
import { pascalCase } from "@qualcomm-ui/utils/change-case";
|
|
8023
8026
|
function extractPageId(filePath, routesDir) {
|
|
8024
|
-
const relativePath =
|
|
8027
|
+
const relativePath = relative2(routesDir, filePath);
|
|
8025
8028
|
const pathParts = relativePath.split(sep);
|
|
8026
8029
|
if (pathParts.includes("demos")) {
|
|
8027
8030
|
const demosIndex = pathParts.indexOf("demos");
|
|
@@ -8074,7 +8077,7 @@ function generateLazyDemoLoader(demoPages) {
|
|
|
8074
8077
|
}
|
|
8075
8078
|
async function generateLazyDemoMap(options) {
|
|
8076
8079
|
const routesDir = options.routesDir;
|
|
8077
|
-
const outputPath =
|
|
8080
|
+
const outputPath = resolve11(options.output);
|
|
8078
8081
|
console.log(`Scanning for demo pages in: ${routesDir}`);
|
|
8079
8082
|
const demoPages = await scanForDemoPages({ routesDir });
|
|
8080
8083
|
console.log(`Found ${demoPages.length} pages with demos`);
|