@qualcomm-ui/mdx-vite 1.1.0 → 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 +259 -211
- 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/index.js +60 -646
- 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";
|
|
@@ -5240,8 +5079,224 @@ var SearchIndexer = class {
|
|
|
5240
5079
|
}
|
|
5241
5080
|
};
|
|
5242
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
|
+
|
|
5243
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";
|
|
5244
5298
|
var isDev = process.env.NODE_ENV === "development";
|
|
5299
|
+
var VIRTUAL_MODULE_ID = "\0@qualcomm-ui/mdx-vite-plugin";
|
|
5245
5300
|
var PluginState = class {
|
|
5246
5301
|
buildCount = 0;
|
|
5247
5302
|
configFilePath = "";
|
|
@@ -5252,14 +5307,9 @@ var PluginState = class {
|
|
|
5252
5307
|
servers = [];
|
|
5253
5308
|
timeout = void 0;
|
|
5254
5309
|
watching = false;
|
|
5255
|
-
resolvedVirtualModuleId;
|
|
5256
|
-
virtualModuleId = "@qualcomm-ui/mdx-vite-plugin";
|
|
5257
5310
|
cwd;
|
|
5258
|
-
|
|
5259
|
-
this.
|
|
5260
|
-
}
|
|
5261
|
-
init(cwd) {
|
|
5262
|
-
this.cwd = cwd;
|
|
5311
|
+
init(cwd2) {
|
|
5312
|
+
this.cwd = cwd2;
|
|
5263
5313
|
}
|
|
5264
5314
|
get docPropsDirectory() {
|
|
5265
5315
|
if (!this.docPropsFilePath) {
|
|
@@ -5285,16 +5335,16 @@ var PluginState = class {
|
|
|
5285
5335
|
}
|
|
5286
5336
|
createIndexer(config2) {
|
|
5287
5337
|
this.configFilePath = config2.filePath;
|
|
5288
|
-
this.docPropsFilePath = config2.typeDocProps ? fixPath(
|
|
5289
|
-
this.routesDir = fixPath(
|
|
5338
|
+
this.docPropsFilePath = config2.typeDocProps ? fixPath(resolve3(this.cwd, config2.typeDocProps)) : "";
|
|
5339
|
+
this.routesDir = fixPath(resolve3(config2.appDirectory, config2.pageDirectory));
|
|
5290
5340
|
this.indexer = new SearchIndexer({
|
|
5291
5341
|
...config2,
|
|
5292
|
-
srcDir: fixPath(
|
|
5342
|
+
srcDir: fixPath(resolve3(this.cwd, config2.appDirectory)),
|
|
5293
5343
|
typeDocProps: this.resolveDocProps()
|
|
5294
5344
|
});
|
|
5295
5345
|
}
|
|
5296
5346
|
buildIndex(shouldLog) {
|
|
5297
|
-
const files =
|
|
5347
|
+
const files = glob2.sync(
|
|
5298
5348
|
[`${this.routesDir}/**/*.mdx`, `${this.routesDir}/**/*.tsx`],
|
|
5299
5349
|
{
|
|
5300
5350
|
absolute: true,
|
|
@@ -5313,27 +5363,25 @@ var PluginState = class {
|
|
|
5313
5363
|
}
|
|
5314
5364
|
}
|
|
5315
5365
|
/**
|
|
5316
|
-
* When the user
|
|
5317
|
-
*
|
|
5318
|
-
*
|
|
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.
|
|
5319
5369
|
*/
|
|
5320
5370
|
sendUpdate() {
|
|
5321
5371
|
for (const server of this.servers) {
|
|
5322
|
-
const virtualModule = server.moduleGraph.getModuleById(
|
|
5323
|
-
this.resolvedVirtualModuleId
|
|
5324
|
-
);
|
|
5372
|
+
const virtualModule = server.moduleGraph.getModuleById(VIRTUAL_MODULE_ID);
|
|
5325
5373
|
if (virtualModule) {
|
|
5326
5374
|
server.moduleGraph.invalidateModule(virtualModule);
|
|
5327
5375
|
server.reloadModule(virtualModule);
|
|
5328
5376
|
}
|
|
5329
5377
|
}
|
|
5330
5378
|
}
|
|
5331
|
-
handleChange(
|
|
5379
|
+
handleChange(opts = {}) {
|
|
5332
5380
|
clearTimeout(this.timeout);
|
|
5333
5381
|
this.timeout = setTimeout(() => {
|
|
5334
5382
|
this.buildIndex(true);
|
|
5335
5383
|
this.sendUpdate();
|
|
5336
|
-
|
|
5384
|
+
opts?.onComplete?.();
|
|
5337
5385
|
}, 300);
|
|
5338
5386
|
}
|
|
5339
5387
|
initWatchers(configFile) {
|
|
@@ -5430,7 +5478,7 @@ import { visit as visit6 } from "unist-util-visit";
|
|
|
5430
5478
|
|
|
5431
5479
|
// src/open-web-ui-knowledge/load-config-from-env.ts
|
|
5432
5480
|
import { existsSync } from "node:fs";
|
|
5433
|
-
import { join as join2, resolve as
|
|
5481
|
+
import { join as join2, resolve as resolve4 } from "node:path";
|
|
5434
5482
|
function loadKnowledgeConfigFromEnv(options) {
|
|
5435
5483
|
const knowledgeId = process.env.KNOWLEDGE_ID;
|
|
5436
5484
|
const exclude = options.exclude || (process.env.FILE_EXCLUDE_PATTERN ?? "").split(",");
|
|
@@ -5448,7 +5496,7 @@ function loadKnowledgeConfigFromEnv(options) {
|
|
|
5448
5496
|
resolvedConfig.appDirectory,
|
|
5449
5497
|
resolvedConfig.pageDirectory
|
|
5450
5498
|
);
|
|
5451
|
-
if (!existsSync(
|
|
5499
|
+
if (!existsSync(resolve4(routeDir))) {
|
|
5452
5500
|
throw new Error(`Route directory ${routeDir} does not exist`);
|
|
5453
5501
|
}
|
|
5454
5502
|
return {
|
|
@@ -5468,7 +5516,7 @@ async function exists(dirPath) {
|
|
|
5468
5516
|
return access(dirPath).then(() => true).catch(() => false);
|
|
5469
5517
|
}
|
|
5470
5518
|
async function loadDocProps(routesFolder, docPropsPath, verbose) {
|
|
5471
|
-
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");
|
|
5472
5520
|
if (!await exists(resolvedDocPropsPath)) {
|
|
5473
5521
|
if (verbose) {
|
|
5474
5522
|
console.log(`Doc props file not found at: ${resolvedDocPropsPath}`);
|
|
@@ -5700,7 +5748,7 @@ function extractRelativeImports(content) {
|
|
|
5700
5748
|
}
|
|
5701
5749
|
async function resolveModulePath(importPath, fromFile) {
|
|
5702
5750
|
const fromDir = dirname(fromFile);
|
|
5703
|
-
const baseResolved =
|
|
5751
|
+
const baseResolved = resolve5(fromDir, importPath);
|
|
5704
5752
|
const extensions = [".ts", ".tsx", ".js", ".jsx", ""];
|
|
5705
5753
|
for (const ext of extensions) {
|
|
5706
5754
|
const fullPath = baseResolved + ext;
|
|
@@ -5717,7 +5765,7 @@ async function resolveModulePath(importPath, fromFile) {
|
|
|
5717
5765
|
return null;
|
|
5718
5766
|
}
|
|
5719
5767
|
async function collectRelativeImports(filePath, visited = /* @__PURE__ */ new Set(), verbose) {
|
|
5720
|
-
const normalizedPath =
|
|
5768
|
+
const normalizedPath = resolve5(filePath);
|
|
5721
5769
|
if (visited.has(normalizedPath)) {
|
|
5722
5770
|
return [];
|
|
5723
5771
|
}
|
|
@@ -5963,8 +6011,8 @@ async function generatePerPageExports({
|
|
|
5963
6011
|
}
|
|
5964
6012
|
}
|
|
5965
6013
|
}
|
|
5966
|
-
const outfile = `${
|
|
5967
|
-
await
|
|
6014
|
+
const outfile = `${resolve5(outputPath)}/${kebabCase(page.name)}.md`;
|
|
6015
|
+
await writeFile3(outfile, lines.join("\n"), "utf-8");
|
|
5968
6016
|
const stats = await stat(outfile);
|
|
5969
6017
|
totalSize += stats.size / 1024;
|
|
5970
6018
|
})
|
|
@@ -6032,7 +6080,7 @@ async function generate({
|
|
|
6032
6080
|
baseUrl
|
|
6033
6081
|
);
|
|
6034
6082
|
await mkdir2(dirname(outputPath), { recursive: true }).catch();
|
|
6035
|
-
await
|
|
6083
|
+
await writeFile3(outputPath, llmsTxtContent, "utf-8");
|
|
6036
6084
|
const outputStats = await stat(outputPath);
|
|
6037
6085
|
const outputSizeKb = (outputStats.size / 1024).toFixed(1);
|
|
6038
6086
|
console.log(
|
|
@@ -6078,9 +6126,9 @@ import {
|
|
|
6078
6126
|
readdir as readdir2,
|
|
6079
6127
|
readFile as readFile2,
|
|
6080
6128
|
stat as stat2,
|
|
6081
|
-
writeFile as
|
|
6129
|
+
writeFile as writeFile4
|
|
6082
6130
|
} from "node:fs/promises";
|
|
6083
|
-
import { resolve as
|
|
6131
|
+
import { resolve as resolve6 } from "node:path";
|
|
6084
6132
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
6085
6133
|
import ora from "ora";
|
|
6086
6134
|
function calculateFileHash(fileData) {
|
|
@@ -6104,7 +6152,7 @@ var Uploader = class {
|
|
|
6104
6152
|
const files = await Promise.all(
|
|
6105
6153
|
fileNames.map(async (name) => ({
|
|
6106
6154
|
contents: await readFile2(
|
|
6107
|
-
|
|
6155
|
+
resolve6(this.config.knowledgeFilePath, name),
|
|
6108
6156
|
"utf-8"
|
|
6109
6157
|
),
|
|
6110
6158
|
name
|
|
@@ -6155,16 +6203,16 @@ var Uploader = class {
|
|
|
6155
6203
|
if (calculateFileHash(data) === calculateFileHash(contents)) {
|
|
6156
6204
|
return { skipped: true, success: true };
|
|
6157
6205
|
}
|
|
6158
|
-
await mkdir3(
|
|
6206
|
+
await mkdir3(resolve6(process.cwd(), `./temp/diff`), {
|
|
6159
6207
|
recursive: true
|
|
6160
6208
|
}).catch();
|
|
6161
|
-
await
|
|
6162
|
-
|
|
6209
|
+
await writeFile4(
|
|
6210
|
+
resolve6(process.cwd(), `./temp/diff/${name}-current.md`),
|
|
6163
6211
|
contents,
|
|
6164
6212
|
"utf-8"
|
|
6165
6213
|
);
|
|
6166
|
-
await
|
|
6167
|
-
|
|
6214
|
+
await writeFile4(
|
|
6215
|
+
resolve6(process.cwd(), `./temp/diff/${name}-owui.md`),
|
|
6168
6216
|
data,
|
|
6169
6217
|
"utf-8"
|
|
6170
6218
|
);
|
|
@@ -6181,7 +6229,7 @@ var Uploader = class {
|
|
|
6181
6229
|
}
|
|
6182
6230
|
}
|
|
6183
6231
|
const fileBuffer = await readFile2(
|
|
6184
|
-
|
|
6232
|
+
resolve6(this.config.knowledgeFilePath, name)
|
|
6185
6233
|
);
|
|
6186
6234
|
if (knowledgeFile) {
|
|
6187
6235
|
await this.api.removeKnowledgeFile(knowledgeFile.id);
|
|
@@ -6207,7 +6255,7 @@ var Uploader = class {
|
|
|
6207
6255
|
}
|
|
6208
6256
|
}
|
|
6209
6257
|
async uploadKnowledge() {
|
|
6210
|
-
const resolvedPath =
|
|
6258
|
+
const resolvedPath = resolve6(this.config.knowledgeFilePath);
|
|
6211
6259
|
if (!await access2(resolvedPath).then(() => true).catch(() => false)) {
|
|
6212
6260
|
throw new Error(`File or folder not found at ${resolvedPath}`);
|
|
6213
6261
|
}
|
|
@@ -6241,16 +6289,16 @@ function addUploadKnowledgeCommand() {
|
|
|
6241
6289
|
}
|
|
6242
6290
|
|
|
6243
6291
|
// src/react-demo-plugin/generate-lazy-demo-map.ts
|
|
6244
|
-
import { glob as
|
|
6292
|
+
import { glob as glob3 } from "glob";
|
|
6245
6293
|
import { uniqBy } from "lodash-es";
|
|
6246
|
-
import { writeFile as
|
|
6247
|
-
import { resolve as
|
|
6294
|
+
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
6295
|
+
import { resolve as resolve8 } from "node:path";
|
|
6248
6296
|
import { dedent } from "@qualcomm-ui/utils/dedent";
|
|
6249
6297
|
|
|
6250
6298
|
// src/react-demo-plugin/demo-plugin-utils.ts
|
|
6251
6299
|
import chalk4 from "chalk";
|
|
6252
6300
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
6253
|
-
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";
|
|
6254
6302
|
import * as ts from "typescript";
|
|
6255
6303
|
import { pascalCase } from "@qualcomm-ui/utils/change-case";
|
|
6256
6304
|
function extractPageId(filePath, routesDir) {
|
|
@@ -6264,8 +6312,7 @@ function extractPageId(filePath, routesDir) {
|
|
|
6264
6312
|
}
|
|
6265
6313
|
function isDemoFile(filePath) {
|
|
6266
6314
|
try {
|
|
6267
|
-
return filePath.includes("/demos/") && filePath.endsWith(".tsx") &&
|
|
6268
|
-
readFileSync3(filePath, "utf-8").includes("export default");
|
|
6315
|
+
return filePath.includes("/demos/") && filePath.endsWith(".tsx") && !readFileSync3(filePath).includes("export default");
|
|
6269
6316
|
} catch (error) {
|
|
6270
6317
|
return false;
|
|
6271
6318
|
}
|
|
@@ -6276,7 +6323,7 @@ async function scanForDemoPages({
|
|
|
6276
6323
|
demoPattern = "src/routes/**/demos/*.tsx",
|
|
6277
6324
|
routesDir = "src/routes"
|
|
6278
6325
|
}) {
|
|
6279
|
-
const demoFiles = (await
|
|
6326
|
+
const demoFiles = (await glob3(demoPattern)).filter((file) => isDemoFile(file));
|
|
6280
6327
|
return uniqBy(
|
|
6281
6328
|
demoFiles.map((file) => ({
|
|
6282
6329
|
pageId: extractPageId(file, routesDir),
|
|
@@ -6308,12 +6355,12 @@ function generateLazyDemoLoader(demoPages) {
|
|
|
6308
6355
|
}
|
|
6309
6356
|
async function generateLazyDemoMap(options) {
|
|
6310
6357
|
const routesDir = options.routesDir;
|
|
6311
|
-
const outputPath =
|
|
6358
|
+
const outputPath = resolve8(options.output);
|
|
6312
6359
|
console.log(`Scanning for demo pages in: ${routesDir}`);
|
|
6313
6360
|
const demoPages = await scanForDemoPages({ routesDir });
|
|
6314
6361
|
console.log(`Found ${demoPages.length} pages with demos`);
|
|
6315
6362
|
const content = generateLazyDemoLoader(demoPages);
|
|
6316
|
-
await
|
|
6363
|
+
await writeFile5(outputPath, content, "utf-8");
|
|
6317
6364
|
console.log(`
|
|
6318
6365
|
Generated lazy demo loader at: ${outputPath}`);
|
|
6319
6366
|
}
|
|
@@ -6344,6 +6391,7 @@ function setupCli() {
|
|
|
6344
6391
|
addUploadKnowledgeCommand();
|
|
6345
6392
|
addDownloadKnowledgeCommand();
|
|
6346
6393
|
addGenerateLazyDemoMapCommand();
|
|
6394
|
+
addGeneratePageMapCommand();
|
|
6347
6395
|
program.parse();
|
|
6348
6396
|
}
|
|
6349
6397
|
setupCli();
|