@qualcomm-ui/mdx-vite 1.0.3 → 2.0.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 +266 -215
- package/dist/cli.js.map +4 -4
- package/dist/docs-plugin/docs-plugin.d.ts.map +1 -1
- package/dist/docs-plugin/generate-page-map.d.ts +2 -0
- package/dist/docs-plugin/generate-page-map.d.ts.map +1 -0
- package/dist/docs-plugin/internal/search-indexer.d.ts.map +1 -1
- package/dist/docs-plugin/internal/services/markdown/markdown-indexer.d.ts.map +1 -1
- package/dist/docs-plugin/internal/services/markdown/markdown.types.d.ts +2 -1
- package/dist/docs-plugin/internal/services/markdown/markdown.types.d.ts.map +1 -1
- package/dist/docs-plugin/internal/zod.d.ts +1 -1
- package/dist/index.js +67 -650
- package/dist/index.js.map +3 -3
- package/dist/react-demo-plugin/demo-plugin-utils.d.ts +0 -21
- package/dist/react-demo-plugin/demo-plugin-utils.d.ts.map +1 -1
- package/dist/react-demo-plugin/react-demo-plugin.d.ts +5 -1
- package/dist/react-demo-plugin/react-demo-plugin.d.ts.map +1 -1
- package/dist/react-demo-plugin/virtual.d.ts +0 -12
- package/dist/tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -3501,172 +3501,11 @@ var {
|
|
|
3501
3501
|
Help
|
|
3502
3502
|
} = import_index.default;
|
|
3503
3503
|
|
|
3504
|
-
// src/
|
|
3505
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
3506
|
-
import { resolve } from "node:path";
|
|
3507
|
-
|
|
3508
|
-
// src/open-web-ui-knowledge/common.ts
|
|
3509
|
-
import { config } from "dotenv";
|
|
3510
|
-
function loadEnv() {
|
|
3511
|
-
const options = program.optsWithGlobals();
|
|
3512
|
-
console.debug(options);
|
|
3513
|
-
if (options.env) {
|
|
3514
|
-
config({ path: options.env });
|
|
3515
|
-
} else {
|
|
3516
|
-
config();
|
|
3517
|
-
}
|
|
3518
|
-
}
|
|
3519
|
-
function getConfigFromEnv() {
|
|
3520
|
-
const openWebUiUrl = process.env.WEB_UI_URL;
|
|
3521
|
-
const openWebUiKey = process.env.WEB_UI_KEY;
|
|
3522
|
-
const knowledgeId = process.env.KNOWLEDGE_ID;
|
|
3523
|
-
if (!openWebUiUrl || !openWebUiKey || !knowledgeId) {
|
|
3524
|
-
throw new Error("WEB_UI_URL, WEB_UI_KEY, and KNOWLEDGE_ID must be set");
|
|
3525
|
-
}
|
|
3526
|
-
return {
|
|
3527
|
-
knowledgeId,
|
|
3528
|
-
webUiKey: openWebUiKey,
|
|
3529
|
-
webUiUrl: openWebUiUrl
|
|
3530
|
-
};
|
|
3531
|
-
}
|
|
3532
|
-
var KnowledgeApi = class {
|
|
3533
|
-
config;
|
|
3534
|
-
knowledgeCache = null;
|
|
3535
|
-
constructor(config2) {
|
|
3536
|
-
this.config = config2;
|
|
3537
|
-
}
|
|
3538
|
-
get headers() {
|
|
3539
|
-
return {
|
|
3540
|
-
Authorization: `Bearer ${this.config.webUiKey}`
|
|
3541
|
-
};
|
|
3542
|
-
}
|
|
3543
|
-
async listKnowledgeFiles() {
|
|
3544
|
-
if (this.knowledgeCache) {
|
|
3545
|
-
return this.knowledgeCache;
|
|
3546
|
-
}
|
|
3547
|
-
const knowledge = await fetch(
|
|
3548
|
-
`${this.config.webUiUrl}/api/v1/knowledge/${this.config.knowledgeId}`,
|
|
3549
|
-
{
|
|
3550
|
-
headers: {
|
|
3551
|
-
...this.headers,
|
|
3552
|
-
Accept: "application/json"
|
|
3553
|
-
}
|
|
3554
|
-
}
|
|
3555
|
-
).then((res) => res.json());
|
|
3556
|
-
if ("detail" in knowledge) {
|
|
3557
|
-
throw new Error(knowledge.detail);
|
|
3558
|
-
} else {
|
|
3559
|
-
this.knowledgeCache = knowledge;
|
|
3560
|
-
}
|
|
3561
|
-
return this.knowledgeCache;
|
|
3562
|
-
}
|
|
3563
|
-
async downloadFile(fileId) {
|
|
3564
|
-
const fileResponse = await fetch(
|
|
3565
|
-
`${this.config.webUiUrl}/api/v1/files/${fileId}`,
|
|
3566
|
-
{
|
|
3567
|
-
headers: {
|
|
3568
|
-
...this.headers,
|
|
3569
|
-
Accept: "application/json"
|
|
3570
|
-
}
|
|
3571
|
-
}
|
|
3572
|
-
).then((res) => res.json());
|
|
3573
|
-
return fileResponse?.data?.content ?? "";
|
|
3574
|
-
}
|
|
3575
|
-
async removeKnowledgeFile(id) {
|
|
3576
|
-
return fetch(
|
|
3577
|
-
`${this.config.webUiUrl}/api/v1/knowledge/${this.config.knowledgeId}/file/remove`,
|
|
3578
|
-
{
|
|
3579
|
-
body: JSON.stringify({ file_id: id }),
|
|
3580
|
-
headers: {
|
|
3581
|
-
...this.headers,
|
|
3582
|
-
"Content-Type": "application/json"
|
|
3583
|
-
},
|
|
3584
|
-
method: "POST"
|
|
3585
|
-
}
|
|
3586
|
-
).then((res) => res.json());
|
|
3587
|
-
}
|
|
3588
|
-
async deleteFile(id) {
|
|
3589
|
-
return fetch(`${this.config.webUiUrl}/api/v1/files/${id}`, {
|
|
3590
|
-
headers: {
|
|
3591
|
-
...this.headers,
|
|
3592
|
-
"Content-Type": "application/json"
|
|
3593
|
-
},
|
|
3594
|
-
method: "DELETE"
|
|
3595
|
-
}).then((res) => res.json());
|
|
3596
|
-
}
|
|
3597
|
-
async uploadFile(fileBuffer, name) {
|
|
3598
|
-
const formData = new FormData();
|
|
3599
|
-
formData.append("file", new Blob([fileBuffer]), name);
|
|
3600
|
-
formData.append("knowledge_id", this.config.knowledgeId);
|
|
3601
|
-
return fetch(`${this.config.webUiUrl}/api/v1/files/`, {
|
|
3602
|
-
body: formData,
|
|
3603
|
-
headers: {
|
|
3604
|
-
...this.headers,
|
|
3605
|
-
Accept: "application/json"
|
|
3606
|
-
},
|
|
3607
|
-
method: "POST"
|
|
3608
|
-
}).then((res) => res.json());
|
|
3609
|
-
}
|
|
3610
|
-
async associateFile(fileId) {
|
|
3611
|
-
return fetch(
|
|
3612
|
-
`${this.config.webUiUrl}/api/v1/knowledge/${this.config.knowledgeId}/file/add`,
|
|
3613
|
-
{
|
|
3614
|
-
body: JSON.stringify({ file_id: fileId }),
|
|
3615
|
-
headers: {
|
|
3616
|
-
...this.headers,
|
|
3617
|
-
"Content-Type": "application/json"
|
|
3618
|
-
},
|
|
3619
|
-
method: "POST"
|
|
3620
|
-
}
|
|
3621
|
-
).then((res) => res.json());
|
|
3622
|
-
}
|
|
3623
|
-
};
|
|
3624
|
-
|
|
3625
|
-
// src/open-web-ui-knowledge/download-knowledge.ts
|
|
3626
|
-
function addDownloadKnowledgeCommand() {
|
|
3627
|
-
program.command("download-knowledge").description("Download files from an Open Web UI knowledge base").requiredOption("-o, --output-dir <outputDir>", "Folder path").action(async (opts) => {
|
|
3628
|
-
loadEnv();
|
|
3629
|
-
await mkdir(opts.outputDir, { recursive: true }).catch();
|
|
3630
|
-
const api = new KnowledgeApi(getConfigFromEnv());
|
|
3631
|
-
const knowledge = await api.listKnowledgeFiles();
|
|
3632
|
-
for (const file of knowledge.files) {
|
|
3633
|
-
const data = await api.downloadFile(file.id);
|
|
3634
|
-
if (data) {
|
|
3635
|
-
await writeFile(
|
|
3636
|
-
resolve(opts.outputDir, file.meta.name),
|
|
3637
|
-
data,
|
|
3638
|
-
"utf-8"
|
|
3639
|
-
);
|
|
3640
|
-
}
|
|
3641
|
-
}
|
|
3642
|
-
});
|
|
3643
|
-
}
|
|
3644
|
-
|
|
3645
|
-
// src/open-web-ui-knowledge/generate-knowledge.ts
|
|
3646
|
-
import { kebabCase } from "change-case";
|
|
3647
|
-
import {
|
|
3648
|
-
access,
|
|
3649
|
-
mkdir as mkdir2,
|
|
3650
|
-
readdir,
|
|
3651
|
-
readFile,
|
|
3652
|
-
rm,
|
|
3653
|
-
stat,
|
|
3654
|
-
writeFile as writeFile2
|
|
3655
|
-
} from "node:fs/promises";
|
|
3656
|
-
import { basename, dirname, extname, join as join3, resolve as resolve4 } from "node:path";
|
|
3657
|
-
import remarkFrontmatter3 from "remark-frontmatter";
|
|
3658
|
-
import remarkParse4 from "remark-parse";
|
|
3659
|
-
import remarkParseFrontmatter2 from "remark-parse-frontmatter";
|
|
3660
|
-
import remarkStringify3 from "remark-stringify";
|
|
3661
|
-
import { unified as unified4 } from "unified";
|
|
3662
|
-
|
|
3663
|
-
// src/docs-plugin/docs-plugin.ts
|
|
3664
|
-
import chalk3 from "chalk";
|
|
3665
|
-
import chokidar from "chokidar";
|
|
3504
|
+
// src/docs-plugin/generate-page-map.ts
|
|
3666
3505
|
import { glob } from "glob";
|
|
3667
|
-
import {
|
|
3668
|
-
import { resolve
|
|
3669
|
-
import
|
|
3506
|
+
import { writeFile } from "node:fs/promises";
|
|
3507
|
+
import { resolve } from "node:path";
|
|
3508
|
+
import { cwd } from "node:process";
|
|
3670
3509
|
|
|
3671
3510
|
// src/docs-plugin/internal/config-loader.ts
|
|
3672
3511
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
@@ -4009,7 +3848,7 @@ var DocPropsIndexer = class {
|
|
|
4009
3848
|
};
|
|
4010
3849
|
const comment = prop.comment;
|
|
4011
3850
|
if (!comment) {
|
|
4012
|
-
return { content: [], heading: heading2 };
|
|
3851
|
+
return { content: [], heading: heading2, richContent: [] };
|
|
4013
3852
|
}
|
|
4014
3853
|
const content = {
|
|
4015
3854
|
tagName: "p",
|
|
@@ -4017,7 +3856,7 @@ var DocPropsIndexer = class {
|
|
|
4017
3856
|
comment.summary.map((entry) => entry.text.replaceAll("\n", " ")).join("")
|
|
4018
3857
|
]
|
|
4019
3858
|
};
|
|
4020
|
-
return { content: [content], heading: heading2 };
|
|
3859
|
+
return { content: [content], heading: heading2, richContent: [] };
|
|
4021
3860
|
}
|
|
4022
3861
|
};
|
|
4023
3862
|
|
|
@@ -4460,7 +4299,8 @@ var MarkdownIndexer = class {
|
|
|
4460
4299
|
resetSection() {
|
|
4461
4300
|
this.currentSection = {
|
|
4462
4301
|
content: [],
|
|
4463
|
-
heading: null
|
|
4302
|
+
heading: null,
|
|
4303
|
+
richContent: []
|
|
4464
4304
|
};
|
|
4465
4305
|
}
|
|
4466
4306
|
get toc() {
|
|
@@ -4514,6 +4354,7 @@ var MarkdownIndexer = class {
|
|
|
4514
4354
|
this.currentSection.heading = heading2;
|
|
4515
4355
|
return;
|
|
4516
4356
|
}
|
|
4357
|
+
this.currentSection.richContent.push(element);
|
|
4517
4358
|
const text = toText(element, { whitespace: "pre-wrap" }).replaceAll("\n", " ").split(" ").filter(size);
|
|
4518
4359
|
if (text.length) {
|
|
4519
4360
|
this.currentSection.content.push({
|
|
@@ -5193,7 +5034,8 @@ var SearchIndexer = class {
|
|
|
5193
5034
|
headingLevel: section.heading?.headingLevel,
|
|
5194
5035
|
href: section.heading && (this.allowedHeadings.has(section.heading.tagName) || isDocProp) ? `${defaultSection.pathname}#${section.heading.id}` : defaultSection.pathname,
|
|
5195
5036
|
id: `${defaultSection.id}-${index}${isDocProp ? "-prop" : ""}`,
|
|
5196
|
-
isDocProp: isDocProp || void 0
|
|
5037
|
+
isDocProp: isDocProp || void 0,
|
|
5038
|
+
richContent: section.richContent
|
|
5197
5039
|
};
|
|
5198
5040
|
});
|
|
5199
5041
|
}
|
|
@@ -5237,8 +5079,224 @@ var SearchIndexer = class {
|
|
|
5237
5079
|
}
|
|
5238
5080
|
};
|
|
5239
5081
|
|
|
5082
|
+
// src/docs-plugin/generate-page-map.ts
|
|
5083
|
+
function addGeneratePageMapCommand() {
|
|
5084
|
+
program.command("generate-page-map").description(
|
|
5085
|
+
"Invokes the docs-plugin once to build the site data and writes it to json"
|
|
5086
|
+
).option(
|
|
5087
|
+
"-c, --config-file <configFile>",
|
|
5088
|
+
"Path to the qui-docs.config.ts config file"
|
|
5089
|
+
).option(
|
|
5090
|
+
"-r, --routes-dir <routesDir>",
|
|
5091
|
+
"Path to the routes directory",
|
|
5092
|
+
"src/routes"
|
|
5093
|
+
).option(
|
|
5094
|
+
"-o, --output <output>",
|
|
5095
|
+
"Output path for the site data json",
|
|
5096
|
+
"site-data.json"
|
|
5097
|
+
).action(async (options) => {
|
|
5098
|
+
try {
|
|
5099
|
+
const configLoader = new ConfigLoader({ configFile: options.configFile });
|
|
5100
|
+
const resolvedConfig = configLoader.loadConfig();
|
|
5101
|
+
const routesDir = fixPath(
|
|
5102
|
+
resolve(resolvedConfig.appDirectory, resolvedConfig.pageDirectory)
|
|
5103
|
+
);
|
|
5104
|
+
const indexer = new SearchIndexer({
|
|
5105
|
+
...resolvedConfig,
|
|
5106
|
+
srcDir: fixPath(resolve(cwd(), resolvedConfig.appDirectory)),
|
|
5107
|
+
typeDocProps: {}
|
|
5108
|
+
});
|
|
5109
|
+
const files = glob.sync(
|
|
5110
|
+
[`${routesDir}/**/*.mdx`, `${routesDir}/**/*.tsx`],
|
|
5111
|
+
{
|
|
5112
|
+
absolute: true,
|
|
5113
|
+
cwd: cwd()
|
|
5114
|
+
}
|
|
5115
|
+
);
|
|
5116
|
+
indexer.buildIndex(files, true);
|
|
5117
|
+
await writeFile(
|
|
5118
|
+
resolve(cwd(), options.output),
|
|
5119
|
+
JSON.stringify(indexer.pageMap, null, 2),
|
|
5120
|
+
"utf-8"
|
|
5121
|
+
);
|
|
5122
|
+
} catch (error) {
|
|
5123
|
+
console.error(
|
|
5124
|
+
"Generate Site Data Error:",
|
|
5125
|
+
error instanceof Error ? error.message : String(error)
|
|
5126
|
+
);
|
|
5127
|
+
process.exit(1);
|
|
5128
|
+
}
|
|
5129
|
+
});
|
|
5130
|
+
}
|
|
5131
|
+
|
|
5132
|
+
// src/open-web-ui-knowledge/download-knowledge.ts
|
|
5133
|
+
import { mkdir, writeFile as writeFile2 } from "node:fs/promises";
|
|
5134
|
+
import { resolve as resolve2 } from "node:path";
|
|
5135
|
+
|
|
5136
|
+
// src/open-web-ui-knowledge/common.ts
|
|
5137
|
+
import { config } from "dotenv";
|
|
5138
|
+
function loadEnv() {
|
|
5139
|
+
const options = program.optsWithGlobals();
|
|
5140
|
+
console.debug(options);
|
|
5141
|
+
if (options.env) {
|
|
5142
|
+
config({ path: options.env });
|
|
5143
|
+
} else {
|
|
5144
|
+
config();
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
function getConfigFromEnv() {
|
|
5148
|
+
const openWebUiUrl = process.env.WEB_UI_URL;
|
|
5149
|
+
const openWebUiKey = process.env.WEB_UI_KEY;
|
|
5150
|
+
const knowledgeId = process.env.KNOWLEDGE_ID;
|
|
5151
|
+
if (!openWebUiUrl || !openWebUiKey || !knowledgeId) {
|
|
5152
|
+
throw new Error("WEB_UI_URL, WEB_UI_KEY, and KNOWLEDGE_ID must be set");
|
|
5153
|
+
}
|
|
5154
|
+
return {
|
|
5155
|
+
knowledgeId,
|
|
5156
|
+
webUiKey: openWebUiKey,
|
|
5157
|
+
webUiUrl: openWebUiUrl
|
|
5158
|
+
};
|
|
5159
|
+
}
|
|
5160
|
+
var KnowledgeApi = class {
|
|
5161
|
+
config;
|
|
5162
|
+
knowledgeCache = null;
|
|
5163
|
+
constructor(config2) {
|
|
5164
|
+
this.config = config2;
|
|
5165
|
+
}
|
|
5166
|
+
get headers() {
|
|
5167
|
+
return {
|
|
5168
|
+
Authorization: `Bearer ${this.config.webUiKey}`
|
|
5169
|
+
};
|
|
5170
|
+
}
|
|
5171
|
+
async listKnowledgeFiles() {
|
|
5172
|
+
if (this.knowledgeCache) {
|
|
5173
|
+
return this.knowledgeCache;
|
|
5174
|
+
}
|
|
5175
|
+
const knowledge = await fetch(
|
|
5176
|
+
`${this.config.webUiUrl}/api/v1/knowledge/${this.config.knowledgeId}`,
|
|
5177
|
+
{
|
|
5178
|
+
headers: {
|
|
5179
|
+
...this.headers,
|
|
5180
|
+
Accept: "application/json"
|
|
5181
|
+
}
|
|
5182
|
+
}
|
|
5183
|
+
).then((res) => res.json());
|
|
5184
|
+
if ("detail" in knowledge) {
|
|
5185
|
+
throw new Error(knowledge.detail);
|
|
5186
|
+
} else {
|
|
5187
|
+
this.knowledgeCache = knowledge;
|
|
5188
|
+
}
|
|
5189
|
+
return this.knowledgeCache;
|
|
5190
|
+
}
|
|
5191
|
+
async downloadFile(fileId) {
|
|
5192
|
+
const fileResponse = await fetch(
|
|
5193
|
+
`${this.config.webUiUrl}/api/v1/files/${fileId}`,
|
|
5194
|
+
{
|
|
5195
|
+
headers: {
|
|
5196
|
+
...this.headers,
|
|
5197
|
+
Accept: "application/json"
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5200
|
+
).then((res) => res.json());
|
|
5201
|
+
return fileResponse?.data?.content ?? "";
|
|
5202
|
+
}
|
|
5203
|
+
async removeKnowledgeFile(id) {
|
|
5204
|
+
return fetch(
|
|
5205
|
+
`${this.config.webUiUrl}/api/v1/knowledge/${this.config.knowledgeId}/file/remove`,
|
|
5206
|
+
{
|
|
5207
|
+
body: JSON.stringify({ file_id: id }),
|
|
5208
|
+
headers: {
|
|
5209
|
+
...this.headers,
|
|
5210
|
+
"Content-Type": "application/json"
|
|
5211
|
+
},
|
|
5212
|
+
method: "POST"
|
|
5213
|
+
}
|
|
5214
|
+
).then((res) => res.json());
|
|
5215
|
+
}
|
|
5216
|
+
async deleteFile(id) {
|
|
5217
|
+
return fetch(`${this.config.webUiUrl}/api/v1/files/${id}`, {
|
|
5218
|
+
headers: {
|
|
5219
|
+
...this.headers,
|
|
5220
|
+
"Content-Type": "application/json"
|
|
5221
|
+
},
|
|
5222
|
+
method: "DELETE"
|
|
5223
|
+
}).then((res) => res.json());
|
|
5224
|
+
}
|
|
5225
|
+
async uploadFile(fileBuffer, name) {
|
|
5226
|
+
const formData = new FormData();
|
|
5227
|
+
formData.append("file", new Blob([fileBuffer]), name);
|
|
5228
|
+
formData.append("knowledge_id", this.config.knowledgeId);
|
|
5229
|
+
return fetch(`${this.config.webUiUrl}/api/v1/files/`, {
|
|
5230
|
+
body: formData,
|
|
5231
|
+
headers: {
|
|
5232
|
+
...this.headers,
|
|
5233
|
+
Accept: "application/json"
|
|
5234
|
+
},
|
|
5235
|
+
method: "POST"
|
|
5236
|
+
}).then((res) => res.json());
|
|
5237
|
+
}
|
|
5238
|
+
async associateFile(fileId) {
|
|
5239
|
+
return fetch(
|
|
5240
|
+
`${this.config.webUiUrl}/api/v1/knowledge/${this.config.knowledgeId}/file/add`,
|
|
5241
|
+
{
|
|
5242
|
+
body: JSON.stringify({ file_id: fileId }),
|
|
5243
|
+
headers: {
|
|
5244
|
+
...this.headers,
|
|
5245
|
+
"Content-Type": "application/json"
|
|
5246
|
+
},
|
|
5247
|
+
method: "POST"
|
|
5248
|
+
}
|
|
5249
|
+
).then((res) => res.json());
|
|
5250
|
+
}
|
|
5251
|
+
};
|
|
5252
|
+
|
|
5253
|
+
// src/open-web-ui-knowledge/download-knowledge.ts
|
|
5254
|
+
function addDownloadKnowledgeCommand() {
|
|
5255
|
+
program.command("download-knowledge").description("Download files from an Open Web UI knowledge base").requiredOption("-o, --output-dir <outputDir>", "Folder path").action(async (opts) => {
|
|
5256
|
+
loadEnv();
|
|
5257
|
+
await mkdir(opts.outputDir, { recursive: true }).catch();
|
|
5258
|
+
const api = new KnowledgeApi(getConfigFromEnv());
|
|
5259
|
+
const knowledge = await api.listKnowledgeFiles();
|
|
5260
|
+
for (const file of knowledge.files) {
|
|
5261
|
+
const data = await api.downloadFile(file.id);
|
|
5262
|
+
if (data) {
|
|
5263
|
+
await writeFile2(
|
|
5264
|
+
resolve2(opts.outputDir, file.meta.name),
|
|
5265
|
+
data,
|
|
5266
|
+
"utf-8"
|
|
5267
|
+
);
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
});
|
|
5271
|
+
}
|
|
5272
|
+
|
|
5273
|
+
// src/open-web-ui-knowledge/generate-knowledge.ts
|
|
5274
|
+
import { kebabCase } from "change-case";
|
|
5275
|
+
import {
|
|
5276
|
+
access,
|
|
5277
|
+
mkdir as mkdir2,
|
|
5278
|
+
readdir,
|
|
5279
|
+
readFile,
|
|
5280
|
+
rm,
|
|
5281
|
+
stat,
|
|
5282
|
+
writeFile as writeFile3
|
|
5283
|
+
} from "node:fs/promises";
|
|
5284
|
+
import { basename, dirname, extname, join as join3, resolve as resolve5 } from "node:path";
|
|
5285
|
+
import remarkFrontmatter3 from "remark-frontmatter";
|
|
5286
|
+
import remarkParse4 from "remark-parse";
|
|
5287
|
+
import remarkParseFrontmatter2 from "remark-parse-frontmatter";
|
|
5288
|
+
import remarkStringify3 from "remark-stringify";
|
|
5289
|
+
import { unified as unified4 } from "unified";
|
|
5290
|
+
|
|
5240
5291
|
// src/docs-plugin/docs-plugin.ts
|
|
5292
|
+
import chalk3 from "chalk";
|
|
5293
|
+
import chokidar from "chokidar";
|
|
5294
|
+
import { glob as glob2 } from "glob";
|
|
5295
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
5296
|
+
import { resolve as resolve3 } from "node:path";
|
|
5297
|
+
import prettyMilliseconds from "pretty-ms";
|
|
5241
5298
|
var isDev = process.env.NODE_ENV === "development";
|
|
5299
|
+
var VIRTUAL_MODULE_ID = "\0@qualcomm-ui/mdx-vite-plugin";
|
|
5242
5300
|
var PluginState = class {
|
|
5243
5301
|
buildCount = 0;
|
|
5244
5302
|
configFilePath = "";
|
|
@@ -5249,14 +5307,9 @@ var PluginState = class {
|
|
|
5249
5307
|
servers = [];
|
|
5250
5308
|
timeout = void 0;
|
|
5251
5309
|
watching = false;
|
|
5252
|
-
resolvedVirtualModuleId;
|
|
5253
|
-
virtualModuleId = "@qualcomm-ui/mdx-vite-plugin";
|
|
5254
5310
|
cwd;
|
|
5255
|
-
|
|
5256
|
-
this.
|
|
5257
|
-
}
|
|
5258
|
-
init(cwd) {
|
|
5259
|
-
this.cwd = cwd;
|
|
5311
|
+
init(cwd2) {
|
|
5312
|
+
this.cwd = cwd2;
|
|
5260
5313
|
}
|
|
5261
5314
|
get docPropsDirectory() {
|
|
5262
5315
|
if (!this.docPropsFilePath) {
|
|
@@ -5282,16 +5335,16 @@ var PluginState = class {
|
|
|
5282
5335
|
}
|
|
5283
5336
|
createIndexer(config2) {
|
|
5284
5337
|
this.configFilePath = config2.filePath;
|
|
5285
|
-
this.docPropsFilePath = config2.typeDocProps ? fixPath(
|
|
5286
|
-
this.routesDir = fixPath(
|
|
5338
|
+
this.docPropsFilePath = config2.typeDocProps ? fixPath(resolve3(this.cwd, config2.typeDocProps)) : "";
|
|
5339
|
+
this.routesDir = fixPath(resolve3(config2.appDirectory, config2.pageDirectory));
|
|
5287
5340
|
this.indexer = new SearchIndexer({
|
|
5288
5341
|
...config2,
|
|
5289
|
-
srcDir: fixPath(
|
|
5342
|
+
srcDir: fixPath(resolve3(this.cwd, config2.appDirectory)),
|
|
5290
5343
|
typeDocProps: this.resolveDocProps()
|
|
5291
5344
|
});
|
|
5292
5345
|
}
|
|
5293
5346
|
buildIndex(shouldLog) {
|
|
5294
|
-
const files =
|
|
5347
|
+
const files = glob2.sync(
|
|
5295
5348
|
[`${this.routesDir}/**/*.mdx`, `${this.routesDir}/**/*.tsx`],
|
|
5296
5349
|
{
|
|
5297
5350
|
absolute: true,
|
|
@@ -5310,27 +5363,25 @@ var PluginState = class {
|
|
|
5310
5363
|
}
|
|
5311
5364
|
}
|
|
5312
5365
|
/**
|
|
5313
|
-
* When the user
|
|
5314
|
-
*
|
|
5315
|
-
*
|
|
5366
|
+
* When the user adds or removes mdx files, we re-index the site. This function
|
|
5367
|
+
* handles module invalidation so that virtual file imports are refreshed as
|
|
5368
|
+
* expected by the consumer's dev server.
|
|
5316
5369
|
*/
|
|
5317
5370
|
sendUpdate() {
|
|
5318
5371
|
for (const server of this.servers) {
|
|
5319
|
-
const virtualModule = server.moduleGraph.getModuleById(
|
|
5320
|
-
this.resolvedVirtualModuleId
|
|
5321
|
-
);
|
|
5372
|
+
const virtualModule = server.moduleGraph.getModuleById(VIRTUAL_MODULE_ID);
|
|
5322
5373
|
if (virtualModule) {
|
|
5323
5374
|
server.moduleGraph.invalidateModule(virtualModule);
|
|
5324
5375
|
server.reloadModule(virtualModule);
|
|
5325
5376
|
}
|
|
5326
5377
|
}
|
|
5327
5378
|
}
|
|
5328
|
-
handleChange(
|
|
5379
|
+
handleChange(opts = {}) {
|
|
5329
5380
|
clearTimeout(this.timeout);
|
|
5330
5381
|
this.timeout = setTimeout(() => {
|
|
5331
5382
|
this.buildIndex(true);
|
|
5332
5383
|
this.sendUpdate();
|
|
5333
|
-
|
|
5384
|
+
opts?.onComplete?.();
|
|
5334
5385
|
}, 300);
|
|
5335
5386
|
}
|
|
5336
5387
|
initWatchers(configFile) {
|
|
@@ -5427,7 +5478,7 @@ import { visit as visit6 } from "unist-util-visit";
|
|
|
5427
5478
|
|
|
5428
5479
|
// src/open-web-ui-knowledge/load-config-from-env.ts
|
|
5429
5480
|
import { existsSync } from "node:fs";
|
|
5430
|
-
import { join as join2, resolve as
|
|
5481
|
+
import { join as join2, resolve as resolve4 } from "node:path";
|
|
5431
5482
|
function loadKnowledgeConfigFromEnv(options) {
|
|
5432
5483
|
const knowledgeId = process.env.KNOWLEDGE_ID;
|
|
5433
5484
|
const exclude = options.exclude || (process.env.FILE_EXCLUDE_PATTERN ?? "").split(",");
|
|
@@ -5445,7 +5496,7 @@ function loadKnowledgeConfigFromEnv(options) {
|
|
|
5445
5496
|
resolvedConfig.appDirectory,
|
|
5446
5497
|
resolvedConfig.pageDirectory
|
|
5447
5498
|
);
|
|
5448
|
-
if (!existsSync(
|
|
5499
|
+
if (!existsSync(resolve4(routeDir))) {
|
|
5449
5500
|
throw new Error(`Route directory ${routeDir} does not exist`);
|
|
5450
5501
|
}
|
|
5451
5502
|
return {
|
|
@@ -5465,7 +5516,7 @@ async function exists(dirPath) {
|
|
|
5465
5516
|
return access(dirPath).then(() => true).catch(() => false);
|
|
5466
5517
|
}
|
|
5467
5518
|
async function loadDocProps(routesFolder, docPropsPath, verbose) {
|
|
5468
|
-
const resolvedDocPropsPath = docPropsPath ? await exists(docPropsPath) ? docPropsPath :
|
|
5519
|
+
const resolvedDocPropsPath = docPropsPath ? await exists(docPropsPath) ? docPropsPath : resolve5(process.cwd(), docPropsPath) : join3(dirname(routesFolder), "doc-props.json");
|
|
5469
5520
|
if (!await exists(resolvedDocPropsPath)) {
|
|
5470
5521
|
if (verbose) {
|
|
5471
5522
|
console.log(`Doc props file not found at: ${resolvedDocPropsPath}`);
|
|
@@ -5697,7 +5748,7 @@ function extractRelativeImports(content) {
|
|
|
5697
5748
|
}
|
|
5698
5749
|
async function resolveModulePath(importPath, fromFile) {
|
|
5699
5750
|
const fromDir = dirname(fromFile);
|
|
5700
|
-
const baseResolved =
|
|
5751
|
+
const baseResolved = resolve5(fromDir, importPath);
|
|
5701
5752
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ""];
|
|
5702
5753
|
for (const ext of extensions) {
|
|
5703
5754
|
const fullPath = baseResolved + ext;
|
|
@@ -5714,7 +5765,7 @@ async function resolveModulePath(importPath, fromFile) {
|
|
|
5714
5765
|
return null;
|
|
5715
5766
|
}
|
|
5716
5767
|
async function collectRelativeImports(filePath, visited = /* @__PURE__ */ new Set(), verbose) {
|
|
5717
|
-
const normalizedPath =
|
|
5768
|
+
const normalizedPath = resolve5(filePath);
|
|
5718
5769
|
if (visited.has(normalizedPath)) {
|
|
5719
5770
|
return [];
|
|
5720
5771
|
}
|
|
@@ -5960,8 +6011,8 @@ async function generatePerPageExports({
|
|
|
5960
6011
|
}
|
|
5961
6012
|
}
|
|
5962
6013
|
}
|
|
5963
|
-
const outfile = `${
|
|
5964
|
-
await
|
|
6014
|
+
const outfile = `${resolve5(outputPath)}/${kebabCase(page.name)}.md`;
|
|
6015
|
+
await writeFile3(outfile, lines.join("\n"), "utf-8");
|
|
5965
6016
|
const stats = await stat(outfile);
|
|
5966
6017
|
totalSize += stats.size / 1024;
|
|
5967
6018
|
})
|
|
@@ -6029,7 +6080,7 @@ async function generate({
|
|
|
6029
6080
|
baseUrl
|
|
6030
6081
|
);
|
|
6031
6082
|
await mkdir2(dirname(outputPath), { recursive: true }).catch();
|
|
6032
|
-
await
|
|
6083
|
+
await writeFile3(outputPath, llmsTxtContent, "utf-8");
|
|
6033
6084
|
const outputStats = await stat(outputPath);
|
|
6034
6085
|
const outputSizeKb = (outputStats.size / 1024).toFixed(1);
|
|
6035
6086
|
console.log(
|
|
@@ -6075,9 +6126,9 @@ import {
|
|
|
6075
6126
|
readdir as readdir2,
|
|
6076
6127
|
readFile as readFile2,
|
|
6077
6128
|
stat as stat2,
|
|
6078
|
-
writeFile as
|
|
6129
|
+
writeFile as writeFile4
|
|
6079
6130
|
} from "node:fs/promises";
|
|
6080
|
-
import { resolve as
|
|
6131
|
+
import { resolve as resolve6 } from "node:path";
|
|
6081
6132
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
6082
6133
|
import ora from "ora";
|
|
6083
6134
|
function calculateFileHash(fileData) {
|
|
@@ -6101,7 +6152,7 @@ var Uploader = class {
|
|
|
6101
6152
|
const files = await Promise.all(
|
|
6102
6153
|
fileNames.map(async (name) => ({
|
|
6103
6154
|
contents: await readFile2(
|
|
6104
|
-
|
|
6155
|
+
resolve6(this.config.knowledgeFilePath, name),
|
|
6105
6156
|
"utf-8"
|
|
6106
6157
|
),
|
|
6107
6158
|
name
|
|
@@ -6152,16 +6203,16 @@ var Uploader = class {
|
|
|
6152
6203
|
if (calculateFileHash(data) === calculateFileHash(contents)) {
|
|
6153
6204
|
return { skipped: true, success: true };
|
|
6154
6205
|
}
|
|
6155
|
-
await mkdir3(
|
|
6206
|
+
await mkdir3(resolve6(process.cwd(), `./temp/diff`), {
|
|
6156
6207
|
recursive: true
|
|
6157
6208
|
}).catch();
|
|
6158
|
-
await
|
|
6159
|
-
|
|
6209
|
+
await writeFile4(
|
|
6210
|
+
resolve6(process.cwd(), `./temp/diff/${name}-current.md`),
|
|
6160
6211
|
contents,
|
|
6161
6212
|
"utf-8"
|
|
6162
6213
|
);
|
|
6163
|
-
await
|
|
6164
|
-
|
|
6214
|
+
await writeFile4(
|
|
6215
|
+
resolve6(process.cwd(), `./temp/diff/${name}-owui.md`),
|
|
6165
6216
|
data,
|
|
6166
6217
|
"utf-8"
|
|
6167
6218
|
);
|
|
@@ -6178,7 +6229,7 @@ var Uploader = class {
|
|
|
6178
6229
|
}
|
|
6179
6230
|
}
|
|
6180
6231
|
const fileBuffer = await readFile2(
|
|
6181
|
-
|
|
6232
|
+
resolve6(this.config.knowledgeFilePath, name)
|
|
6182
6233
|
);
|
|
6183
6234
|
if (knowledgeFile) {
|
|
6184
6235
|
await this.api.removeKnowledgeFile(knowledgeFile.id);
|
|
@@ -6204,7 +6255,7 @@ var Uploader = class {
|
|
|
6204
6255
|
}
|
|
6205
6256
|
}
|
|
6206
6257
|
async uploadKnowledge() {
|
|
6207
|
-
const resolvedPath =
|
|
6258
|
+
const resolvedPath = resolve6(this.config.knowledgeFilePath);
|
|
6208
6259
|
if (!await access2(resolvedPath).then(() => true).catch(() => false)) {
|
|
6209
6260
|
throw new Error(`File or folder not found at ${resolvedPath}`);
|
|
6210
6261
|
}
|
|
@@ -6238,16 +6289,16 @@ function addUploadKnowledgeCommand() {
|
|
|
6238
6289
|
}
|
|
6239
6290
|
|
|
6240
6291
|
// src/react-demo-plugin/generate-lazy-demo-map.ts
|
|
6241
|
-
import { glob as
|
|
6292
|
+
import { glob as glob3 } from "glob";
|
|
6242
6293
|
import { uniqBy } from "lodash-es";
|
|
6243
|
-
import { writeFile as
|
|
6244
|
-
import { resolve as
|
|
6294
|
+
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
6295
|
+
import { resolve as resolve8 } from "node:path";
|
|
6245
6296
|
import { dedent } from "@qualcomm-ui/utils/dedent";
|
|
6246
6297
|
|
|
6247
6298
|
// src/react-demo-plugin/demo-plugin-utils.ts
|
|
6248
6299
|
import chalk4 from "chalk";
|
|
6249
6300
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
6250
|
-
import { dirname as dirname2, join as join4, relative, resolve as
|
|
6301
|
+
import { dirname as dirname2, join as join4, relative, resolve as resolve7, sep } from "node:path";
|
|
6251
6302
|
import * as ts from "typescript";
|
|
6252
6303
|
import { pascalCase } from "@qualcomm-ui/utils/change-case";
|
|
6253
6304
|
function extractPageId(filePath, routesDir) {
|
|
@@ -6261,8 +6312,7 @@ function extractPageId(filePath, routesDir) {
|
|
|
6261
6312
|
}
|
|
6262
6313
|
function isDemoFile(filePath) {
|
|
6263
6314
|
try {
|
|
6264
|
-
return filePath.includes("/demos/") && filePath.endsWith(".tsx") &&
|
|
6265
|
-
readFileSync3(filePath, "utf-8").includes("export default");
|
|
6315
|
+
return filePath.includes("/demos/") && filePath.endsWith(".tsx") && !readFileSync3(filePath).includes("export default");
|
|
6266
6316
|
} catch (error) {
|
|
6267
6317
|
return false;
|
|
6268
6318
|
}
|
|
@@ -6273,7 +6323,7 @@ async function scanForDemoPages({
|
|
|
6273
6323
|
demoPattern = "src/routes/**/demos/*.tsx",
|
|
6274
6324
|
routesDir = "src/routes"
|
|
6275
6325
|
}) {
|
|
6276
|
-
const demoFiles = (await
|
|
6326
|
+
const demoFiles = (await glob3(demoPattern)).filter((file) => isDemoFile(file));
|
|
6277
6327
|
return uniqBy(
|
|
6278
6328
|
demoFiles.map((file) => ({
|
|
6279
6329
|
pageId: extractPageId(file, routesDir),
|
|
@@ -6305,12 +6355,12 @@ function generateLazyDemoLoader(demoPages) {
|
|
|
6305
6355
|
}
|
|
6306
6356
|
async function generateLazyDemoMap(options) {
|
|
6307
6357
|
const routesDir = options.routesDir;
|
|
6308
|
-
const outputPath =
|
|
6358
|
+
const outputPath = resolve8(options.output);
|
|
6309
6359
|
console.log(`Scanning for demo pages in: ${routesDir}`);
|
|
6310
6360
|
const demoPages = await scanForDemoPages({ routesDir });
|
|
6311
6361
|
console.log(`Found ${demoPages.length} pages with demos`);
|
|
6312
6362
|
const content = generateLazyDemoLoader(demoPages);
|
|
6313
|
-
await
|
|
6363
|
+
await writeFile5(outputPath, content, "utf-8");
|
|
6314
6364
|
console.log(`
|
|
6315
6365
|
Generated lazy demo loader at: ${outputPath}`);
|
|
6316
6366
|
}
|
|
@@ -6341,6 +6391,7 @@ function setupCli() {
|
|
|
6341
6391
|
addUploadKnowledgeCommand();
|
|
6342
6392
|
addDownloadKnowledgeCommand();
|
|
6343
6393
|
addGenerateLazyDemoMapCommand();
|
|
6394
|
+
addGeneratePageMapCommand();
|
|
6344
6395
|
program.parse();
|
|
6345
6396
|
}
|
|
6346
6397
|
setupCli();
|