@qualcomm-ui/mdx-vite 2.16.1 → 2.17.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/ai-knowledge/generator/filter-text-directives.d.ts +3 -0
- package/dist/ai-knowledge/generator/filter-text-directives.d.ts.map +1 -0
- package/dist/ai-knowledge/generator/knowledge-generator.d.ts.map +1 -1
- package/dist/ai-knowledge/generator/section-extractor.d.ts.map +1 -1
- package/dist/cli.js +383 -86
- package/dist/cli.js.map +4 -4
- package/dist/docs-plugin/mdx-plugins.d.ts.map +1 -1
- package/dist/docs-plugin/remark/index.d.ts +1 -0
- package/dist/docs-plugin/remark/index.d.ts.map +1 -1
- package/dist/docs-plugin/remark/remark-spoilers.d.ts +1 -0
- package/dist/docs-plugin/remark/remark-spoilers.d.ts.map +1 -1
- package/dist/docs-plugin/remark/remark-steps.d.ts +58 -0
- package/dist/docs-plugin/remark/remark-steps.d.ts.map +1 -0
- package/dist/index.js +170 -43
- package/dist/index.js.map +4 -4
- package/dist/tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -520,9 +520,9 @@ var require_help = __commonJS({
|
|
|
520
520
|
* @param {Help} helper
|
|
521
521
|
* @returns string[]
|
|
522
522
|
*/
|
|
523
|
-
formatItemList(
|
|
523
|
+
formatItemList(heading2, items, helper) {
|
|
524
524
|
if (items.length === 0) return [];
|
|
525
|
-
return [helper.styleTitle(
|
|
525
|
+
return [helper.styleTitle(heading2), ...items, ""];
|
|
526
526
|
}
|
|
527
527
|
/**
|
|
528
528
|
* Group items by their help group heading.
|
|
@@ -1002,8 +1002,8 @@ var require_option = __commonJS({
|
|
|
1002
1002
|
* @param {string} heading
|
|
1003
1003
|
* @return {Option}
|
|
1004
1004
|
*/
|
|
1005
|
-
helpGroup(
|
|
1006
|
-
this.helpGroupHeading =
|
|
1005
|
+
helpGroup(heading2) {
|
|
1006
|
+
this.helpGroupHeading = heading2;
|
|
1007
1007
|
return this;
|
|
1008
1008
|
}
|
|
1009
1009
|
/**
|
|
@@ -3099,9 +3099,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3099
3099
|
* @param {string} [heading]
|
|
3100
3100
|
* @return {Command | string}
|
|
3101
3101
|
*/
|
|
3102
|
-
helpGroup(
|
|
3103
|
-
if (
|
|
3104
|
-
this._helpGroupHeading =
|
|
3102
|
+
helpGroup(heading2) {
|
|
3103
|
+
if (heading2 === void 0) return this._helpGroupHeading ?? "";
|
|
3104
|
+
this._helpGroupHeading = heading2;
|
|
3105
3105
|
return this;
|
|
3106
3106
|
}
|
|
3107
3107
|
/**
|
|
@@ -3117,9 +3117,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3117
3117
|
* @param {string} [heading]
|
|
3118
3118
|
* @returns {Command | string}
|
|
3119
3119
|
*/
|
|
3120
|
-
commandsGroup(
|
|
3121
|
-
if (
|
|
3122
|
-
this._defaultCommandGroup =
|
|
3120
|
+
commandsGroup(heading2) {
|
|
3121
|
+
if (heading2 === void 0) return this._defaultCommandGroup ?? "";
|
|
3122
|
+
this._defaultCommandGroup = heading2;
|
|
3123
3123
|
return this;
|
|
3124
3124
|
}
|
|
3125
3125
|
/**
|
|
@@ -3135,9 +3135,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3135
3135
|
* @param {string} [heading]
|
|
3136
3136
|
* @returns {Command | string}
|
|
3137
3137
|
*/
|
|
3138
|
-
optionsGroup(
|
|
3139
|
-
if (
|
|
3140
|
-
this._defaultOptionGroup =
|
|
3138
|
+
optionsGroup(heading2) {
|
|
3139
|
+
if (heading2 === void 0) return this._defaultOptionGroup ?? "";
|
|
3140
|
+
this._defaultOptionGroup = heading2;
|
|
3141
3141
|
return this;
|
|
3142
3142
|
}
|
|
3143
3143
|
/**
|
|
@@ -3921,7 +3921,7 @@ var DocPropsIndexer = class {
|
|
|
3921
3921
|
}
|
|
3922
3922
|
assembleProp(prop, id) {
|
|
3923
3923
|
const name = prop.name;
|
|
3924
|
-
const
|
|
3924
|
+
const heading2 = {
|
|
3925
3925
|
headingLevel: 4,
|
|
3926
3926
|
id,
|
|
3927
3927
|
tagName: "a",
|
|
@@ -3929,7 +3929,7 @@ var DocPropsIndexer = class {
|
|
|
3929
3929
|
};
|
|
3930
3930
|
const comment = prop.comment;
|
|
3931
3931
|
if (!comment) {
|
|
3932
|
-
return { content: [], heading, richContent: [] };
|
|
3932
|
+
return { content: [], heading: heading2, richContent: [] };
|
|
3933
3933
|
}
|
|
3934
3934
|
const content = {
|
|
3935
3935
|
tagName: "p",
|
|
@@ -3937,7 +3937,7 @@ var DocPropsIndexer = class {
|
|
|
3937
3937
|
comment.summary.map((entry) => entry.text.replaceAll("\n", " ")).join("")
|
|
3938
3938
|
]
|
|
3939
3939
|
};
|
|
3940
|
-
return { content: [content], heading, richContent: [] };
|
|
3940
|
+
return { content: [content], heading: heading2, richContent: [] };
|
|
3941
3941
|
}
|
|
3942
3942
|
};
|
|
3943
3943
|
|
|
@@ -4479,8 +4479,8 @@ var MarkdownIndexer = class {
|
|
|
4479
4479
|
this.resetSection();
|
|
4480
4480
|
this.headingLevels = headingLevels;
|
|
4481
4481
|
}
|
|
4482
|
-
appendTocItem(
|
|
4483
|
-
this._toc.push(
|
|
4482
|
+
appendTocItem(heading2) {
|
|
4483
|
+
this._toc.push(heading2);
|
|
4484
4484
|
}
|
|
4485
4485
|
warn(...data) {
|
|
4486
4486
|
if (process.env.DEBUG) {
|
|
@@ -4515,11 +4515,11 @@ var MarkdownIndexer = class {
|
|
|
4515
4515
|
this.sections.push(clone(this.currentSection));
|
|
4516
4516
|
this.resetSection();
|
|
4517
4517
|
}
|
|
4518
|
-
const
|
|
4518
|
+
const heading2 = this.parseHeading(element);
|
|
4519
4519
|
if (!isRootHeading) {
|
|
4520
|
-
this.appendTocItem(
|
|
4520
|
+
this.appendTocItem(heading2);
|
|
4521
4521
|
}
|
|
4522
|
-
this.currentSection.heading =
|
|
4522
|
+
this.currentSection.heading = heading2;
|
|
4523
4523
|
return;
|
|
4524
4524
|
}
|
|
4525
4525
|
this.currentSection.richContent.push(element);
|
|
@@ -4901,7 +4901,7 @@ function getRemixFlatRoutesSegments(name, index, paramPrefixChar = "$") {
|
|
|
4901
4901
|
let routeSegments = [];
|
|
4902
4902
|
let i = 0;
|
|
4903
4903
|
let routeSegment = "";
|
|
4904
|
-
let
|
|
4904
|
+
let state2 = "START";
|
|
4905
4905
|
let subState = "NORMAL";
|
|
4906
4906
|
let hasPlus = false;
|
|
4907
4907
|
if (name.endsWith("_layout")) {
|
|
@@ -4928,7 +4928,7 @@ function getRemixFlatRoutesSegments(name, index, paramPrefixChar = "$") {
|
|
|
4928
4928
|
};
|
|
4929
4929
|
while (i < name.length) {
|
|
4930
4930
|
const char = name[i];
|
|
4931
|
-
switch (
|
|
4931
|
+
switch (state2) {
|
|
4932
4932
|
case "START":
|
|
4933
4933
|
if (routeSegment.includes(paramPrefixChar) && !(routeSegment.startsWith(paramPrefixChar) || routeSegment.startsWith(`(${paramPrefixChar}`))) {
|
|
4934
4934
|
throw new Error(
|
|
@@ -4942,12 +4942,12 @@ function getRemixFlatRoutesSegments(name, index, paramPrefixChar = "$") {
|
|
|
4942
4942
|
}
|
|
4943
4943
|
pushRouteSegment(routeSegment);
|
|
4944
4944
|
routeSegment = "";
|
|
4945
|
-
|
|
4945
|
+
state2 = "PATH";
|
|
4946
4946
|
continue;
|
|
4947
4947
|
// restart without advancing index
|
|
4948
4948
|
case "PATH":
|
|
4949
4949
|
if (isPathSeparator(char) && subState === "NORMAL") {
|
|
4950
|
-
|
|
4950
|
+
state2 = "START";
|
|
4951
4951
|
break;
|
|
4952
4952
|
} else if (char === "[") {
|
|
4953
4953
|
subState = "ESCAPE";
|
|
@@ -5398,17 +5398,17 @@ function loadEnvironmentConfigs(options = {}) {
|
|
|
5398
5398
|
|
|
5399
5399
|
// src/ai-knowledge/generator/knowledge-generator.ts
|
|
5400
5400
|
import AdmZip from "adm-zip";
|
|
5401
|
-
import
|
|
5401
|
+
import chalk4 from "chalk";
|
|
5402
5402
|
import { minimatch } from "minimatch";
|
|
5403
5403
|
import { mkdir, readdir, readFile as readFile4, rm, stat, writeFile } from "node:fs/promises";
|
|
5404
|
-
import { basename as basename2, dirname as dirname3, join as
|
|
5405
|
-
import
|
|
5404
|
+
import { basename as basename2, dirname as dirname3, join as join7, relative as relative2, resolve as resolve5 } from "node:path";
|
|
5405
|
+
import remarkFrontmatter3 from "remark-frontmatter";
|
|
5406
5406
|
import remarkMdx3 from "remark-mdx";
|
|
5407
5407
|
import remarkParse4 from "remark-parse";
|
|
5408
5408
|
import remarkParseFrontmatter2 from "remark-parse-frontmatter";
|
|
5409
5409
|
import remarkStringify4 from "remark-stringify";
|
|
5410
5410
|
import { unified as unified5 } from "unified";
|
|
5411
|
-
import { visit as
|
|
5411
|
+
import { visit as visit18 } from "unist-util-visit";
|
|
5412
5412
|
import { kebabCase as kebabCase3 } from "@qualcomm-ui/utils/change-case";
|
|
5413
5413
|
|
|
5414
5414
|
// src/docs-plugin/remark/remark-extract-meta.ts
|
|
@@ -5997,11 +5997,292 @@ ${propsToDefinitionList(outputs)}`);
|
|
|
5997
5997
|
}
|
|
5998
5998
|
};
|
|
5999
5999
|
|
|
6000
|
-
// src/ai-knowledge/generator/
|
|
6000
|
+
// src/ai-knowledge/generator/filter-text-directives.ts
|
|
6001
|
+
import { visit as visit14 } from "unist-util-visit";
|
|
6002
|
+
|
|
6003
|
+
// src/docs-plugin/docs-plugin.ts
|
|
6004
|
+
import chalk3 from "chalk";
|
|
6005
|
+
import chokidar from "chokidar";
|
|
6006
|
+
import { glob } from "glob";
|
|
6007
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
6008
|
+
import { join as join6, resolve as resolve4 } from "node:path";
|
|
6009
|
+
import prettyMilliseconds from "pretty-ms";
|
|
6010
|
+
var isDev = process.env.NODE_ENV === "development";
|
|
6011
|
+
var VIRTUAL_MODULE_ID = "\0@qualcomm-ui/mdx-vite-plugin";
|
|
6012
|
+
var PluginState = class {
|
|
6013
|
+
buildCount = 0;
|
|
6014
|
+
config = null;
|
|
6015
|
+
configFilePath = "";
|
|
6016
|
+
docPropsFilePath = "";
|
|
6017
|
+
exports = { basePath: "", enabled: false, pages: [] };
|
|
6018
|
+
indexer;
|
|
6019
|
+
configLoader = null;
|
|
6020
|
+
knowledgeConfig = void 0;
|
|
6021
|
+
routesDir;
|
|
6022
|
+
servers = [];
|
|
6023
|
+
timeout = void 0;
|
|
6024
|
+
exportsTimeout = void 0;
|
|
6025
|
+
watching = false;
|
|
6026
|
+
cwd;
|
|
6027
|
+
init(cwd2) {
|
|
6028
|
+
this.cwd = cwd2;
|
|
6029
|
+
}
|
|
6030
|
+
getCwd() {
|
|
6031
|
+
return this.cwd;
|
|
6032
|
+
}
|
|
6033
|
+
get docPropsDirectory() {
|
|
6034
|
+
if (!this.docPropsFilePath) {
|
|
6035
|
+
return "";
|
|
6036
|
+
}
|
|
6037
|
+
return this.docPropsFilePath.substring(
|
|
6038
|
+
0,
|
|
6039
|
+
this.docPropsFilePath.lastIndexOf("/")
|
|
6040
|
+
);
|
|
6041
|
+
}
|
|
6042
|
+
get siteData() {
|
|
6043
|
+
const { filePath: _filePath, ...config3 } = this.config ?? {};
|
|
6044
|
+
return {
|
|
6045
|
+
config: config3,
|
|
6046
|
+
exports: this.exports,
|
|
6047
|
+
navItems: state.indexer.navItems,
|
|
6048
|
+
pageDocProps: state.indexer.pageDocProps,
|
|
6049
|
+
pageMap: state.indexer.pageMap,
|
|
6050
|
+
searchIndex: state.indexer.searchIndex
|
|
6051
|
+
};
|
|
6052
|
+
}
|
|
6053
|
+
resolveDocProps() {
|
|
6054
|
+
if (!this.docPropsFilePath) {
|
|
6055
|
+
return {};
|
|
6056
|
+
}
|
|
6057
|
+
try {
|
|
6058
|
+
return JSON.parse(readFileSync2(this.docPropsFilePath, "utf-8"))?.props;
|
|
6059
|
+
} catch (e) {
|
|
6060
|
+
console.debug(
|
|
6061
|
+
"Invalid doc props file. Unable to parse JSON. Please check the file"
|
|
6062
|
+
);
|
|
6063
|
+
return {};
|
|
6064
|
+
}
|
|
6065
|
+
}
|
|
6066
|
+
createIndexer(config3) {
|
|
6067
|
+
this.config = config3;
|
|
6068
|
+
this.configFilePath = config3.filePath;
|
|
6069
|
+
this.docPropsFilePath = config3.typeDocProps ? fixPath(resolve4(this.cwd, config3.typeDocProps)) : "";
|
|
6070
|
+
this.routesDir = fixPath(resolve4(config3.appDirectory, config3.pageDirectory));
|
|
6071
|
+
this.knowledgeConfig = config3.knowledge;
|
|
6072
|
+
this.indexer = new SearchIndexer({
|
|
6073
|
+
...config3,
|
|
6074
|
+
srcDir: fixPath(resolve4(this.cwd, config3.appDirectory)),
|
|
6075
|
+
typeDocProps: this.resolveDocProps()
|
|
6076
|
+
});
|
|
6077
|
+
const exportsConfig = config3.knowledge?.global?.exports;
|
|
6078
|
+
const exportsEnabled = exportsConfig?.enabled ?? false;
|
|
6079
|
+
const exportsPath = exportsConfig?.staticPath ?? "exports/md";
|
|
6080
|
+
this.exports = {
|
|
6081
|
+
basePath: exportsEnabled ? `/${exportsPath}` : "",
|
|
6082
|
+
enabled: exportsEnabled,
|
|
6083
|
+
pages: []
|
|
6084
|
+
};
|
|
6085
|
+
}
|
|
6086
|
+
buildIndex(shouldLog) {
|
|
6087
|
+
const files = glob.sync(
|
|
6088
|
+
[`${this.routesDir}/**/*.mdx`, `${this.routesDir}/**/*.tsx`],
|
|
6089
|
+
{
|
|
6090
|
+
absolute: true,
|
|
6091
|
+
cwd: this.cwd
|
|
6092
|
+
}
|
|
6093
|
+
);
|
|
6094
|
+
if (!files.length) {
|
|
6095
|
+
return [];
|
|
6096
|
+
}
|
|
6097
|
+
const startTime = Date.now();
|
|
6098
|
+
const compiledMdxFiles = this.indexer.buildIndex(files, shouldLog);
|
|
6099
|
+
if (isDev && shouldLog) {
|
|
6100
|
+
console.debug(
|
|
6101
|
+
`${chalk3.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Compiled search index in: ${chalk3.blueBright.bold(prettyMilliseconds(Date.now() - startTime))}${state.indexer.cachedFileCount ? chalk3.greenBright.bold(` (${state.indexer.cachedFileCount}/${state.indexer.mdxFileCount} files cached)`) : ""}`
|
|
6102
|
+
);
|
|
6103
|
+
}
|
|
6104
|
+
return compiledMdxFiles;
|
|
6105
|
+
}
|
|
6106
|
+
/**
|
|
6107
|
+
* When the user adds or removes mdx files, we re-index the site. This function
|
|
6108
|
+
* handles module invalidation so that virtual file imports are refreshed as
|
|
6109
|
+
* expected by the consumer's dev server.
|
|
6110
|
+
*/
|
|
6111
|
+
sendUpdate() {
|
|
6112
|
+
for (const server of this.servers) {
|
|
6113
|
+
const virtualModule = server.moduleGraph.getModuleById(VIRTUAL_MODULE_ID);
|
|
6114
|
+
if (virtualModule) {
|
|
6115
|
+
server.moduleGraph.invalidateModule(virtualModule);
|
|
6116
|
+
server.reloadModule(virtualModule);
|
|
6117
|
+
}
|
|
6118
|
+
}
|
|
6119
|
+
}
|
|
6120
|
+
handleChange(opts = {}) {
|
|
6121
|
+
clearTimeout(this.timeout);
|
|
6122
|
+
this.timeout = setTimeout(() => {
|
|
6123
|
+
this.buildIndex(true);
|
|
6124
|
+
this.sendUpdate();
|
|
6125
|
+
opts?.onComplete?.();
|
|
6126
|
+
}, 300);
|
|
6127
|
+
}
|
|
6128
|
+
initWatchers(configFile) {
|
|
6129
|
+
if (this.watching) {
|
|
6130
|
+
return;
|
|
6131
|
+
}
|
|
6132
|
+
this.initConfigWatcher(configFile);
|
|
6133
|
+
this.watching = true;
|
|
6134
|
+
}
|
|
6135
|
+
initConfigWatcher(configFile) {
|
|
6136
|
+
const paths = [this.configFilePath];
|
|
6137
|
+
if (this.docPropsFilePath) {
|
|
6138
|
+
paths.push(this.docPropsFilePath);
|
|
6139
|
+
}
|
|
6140
|
+
chokidar.watch(paths, {
|
|
6141
|
+
cwd: this.cwd
|
|
6142
|
+
}).on("change", () => {
|
|
6143
|
+
console.debug(`qui-docs config changed, reloading plugin`);
|
|
6144
|
+
this.configLoader = new ConfigLoader({ configFile });
|
|
6145
|
+
const resolvedConfig = this.configLoader.loadConfig();
|
|
6146
|
+
this.configFilePath = resolvedConfig.filePath;
|
|
6147
|
+
this.createIndexer(resolvedConfig);
|
|
6148
|
+
this.handleChange({
|
|
6149
|
+
onComplete: () => {
|
|
6150
|
+
this.servers.forEach(
|
|
6151
|
+
(server) => server.ws.send({ type: "full-reload" })
|
|
6152
|
+
);
|
|
6153
|
+
}
|
|
6154
|
+
});
|
|
6155
|
+
});
|
|
6156
|
+
}
|
|
6157
|
+
async generateExports(publicDir) {
|
|
6158
|
+
if (!this.exports.enabled || !this.knowledgeConfig?.global) {
|
|
6159
|
+
return;
|
|
6160
|
+
}
|
|
6161
|
+
const globalConfig = this.knowledgeConfig.global;
|
|
6162
|
+
const exportsConfig = globalConfig.exports ?? {};
|
|
6163
|
+
const exportsPath = exportsConfig.staticPath ?? "exports/md";
|
|
6164
|
+
const outputPath = join6(publicDir, exportsPath);
|
|
6165
|
+
const manifestPath = exportsConfig.manifestPath ?? "exports";
|
|
6166
|
+
const manifestOutputPath = join6(publicDir, manifestPath);
|
|
6167
|
+
const startTime = Date.now();
|
|
6168
|
+
const pageIds = await generate({
|
|
6169
|
+
baseUrl: globalConfig.baseUrl,
|
|
6170
|
+
clean: true,
|
|
6171
|
+
docPropsPath: this.docPropsFilePath || void 0,
|
|
6172
|
+
exclude: exportsConfig.exclude ?? globalConfig.exclude,
|
|
6173
|
+
extraFiles: exportsConfig.extraFiles ?? globalConfig.extraFiles,
|
|
6174
|
+
frontmatter: exportsConfig.frontmatter ?? globalConfig.frontmatter,
|
|
6175
|
+
generateBulkZip: exportsConfig.generateBulkZip ?? true,
|
|
6176
|
+
generateManifest: exportsConfig.generateManifest ?? true,
|
|
6177
|
+
manifestOutputPath,
|
|
6178
|
+
metadata: exportsConfig.metadata ?? globalConfig.metadata,
|
|
6179
|
+
outputMode: "per-page",
|
|
6180
|
+
outputPath,
|
|
6181
|
+
pageTitlePrefix: exportsConfig.pageTitlePrefix ?? globalConfig.pageTitlePrefix,
|
|
6182
|
+
routeDir: this.routesDir,
|
|
6183
|
+
sections: exportsConfig.sections
|
|
6184
|
+
});
|
|
6185
|
+
this.exports.pages = pageIds;
|
|
6186
|
+
console.debug(
|
|
6187
|
+
`${chalk3.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Generated Markdown exports in: ${chalk3.blueBright.bold(prettyMilliseconds(Date.now() - startTime))}`
|
|
6188
|
+
);
|
|
6189
|
+
}
|
|
6190
|
+
debouncedGenerateExports(publicDir) {
|
|
6191
|
+
if (!this.exports.enabled) {
|
|
6192
|
+
return;
|
|
6193
|
+
}
|
|
6194
|
+
clearTimeout(this.exportsTimeout);
|
|
6195
|
+
this.exportsTimeout = setTimeout(() => {
|
|
6196
|
+
void this.generateExports(publicDir);
|
|
6197
|
+
}, 500);
|
|
6198
|
+
}
|
|
6199
|
+
};
|
|
6200
|
+
var state = new PluginState();
|
|
6201
|
+
|
|
6202
|
+
// src/docs-plugin/mdx-plugins.ts
|
|
6203
|
+
import rehypeShiki from "@shikijs/rehype";
|
|
6204
|
+
import {
|
|
6205
|
+
transformerNotationDiff,
|
|
6206
|
+
transformerNotationErrorLevel,
|
|
6207
|
+
transformerNotationFocus,
|
|
6208
|
+
transformerNotationHighlight,
|
|
6209
|
+
transformerNotationWordHighlight,
|
|
6210
|
+
transformerRemoveNotationEscape,
|
|
6211
|
+
transformerRenderIndentGuides
|
|
6212
|
+
} from "@shikijs/transformers";
|
|
6213
|
+
import { merge } from "lodash-es";
|
|
6214
|
+
import { quiCustomDarkTheme } from "@qualcomm-ui/mdx-common";
|
|
6215
|
+
|
|
6216
|
+
// src/exports.ts
|
|
6217
|
+
import rehypeMdxCodeProps from "rehype-mdx-code-props";
|
|
6218
|
+
import remarkFrontmatter2 from "remark-frontmatter";
|
|
6219
|
+
import remarkGfm2 from "remark-gfm";
|
|
6220
|
+
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
|
|
6221
|
+
|
|
6222
|
+
// src/docs-plugin/rehype/rehype-sectionize.ts
|
|
6223
|
+
import { heading } from "hast-util-heading";
|
|
6224
|
+
import { headingRank as headingRank2 } from "hast-util-heading-rank";
|
|
6225
|
+
|
|
6226
|
+
// src/docs-plugin/remark/remark-code-tabs.ts
|
|
6001
6227
|
import { visit as visit8 } from "unist-util-visit";
|
|
6228
|
+
|
|
6229
|
+
// src/docs-plugin/remark/remark-frontmatter-description.ts
|
|
6230
|
+
import { visit as visit9 } from "unist-util-visit";
|
|
6231
|
+
|
|
6232
|
+
// src/docs-plugin/remark/remark-frontmatter-title.ts
|
|
6233
|
+
import { visit as visit10 } from "unist-util-visit";
|
|
6234
|
+
|
|
6235
|
+
// src/docs-plugin/remark/remark-self-link-headings.ts
|
|
6236
|
+
import { toString as toString2 } from "mdast-util-to-string";
|
|
6237
|
+
import { visit as visit11 } from "unist-util-visit";
|
|
6238
|
+
|
|
6239
|
+
// src/docs-plugin/remark/remark-spoilers.ts
|
|
6240
|
+
import { visit as visit12 } from "unist-util-visit";
|
|
6241
|
+
function getSpoilerStartMatch(text) {
|
|
6242
|
+
return text.match(/^:::\s*spoiler\s*(.*)$/);
|
|
6243
|
+
}
|
|
6244
|
+
function getSpoilerEndMatch(text) {
|
|
6245
|
+
return text.trim() === ":::";
|
|
6246
|
+
}
|
|
6247
|
+
function isSpoilerBlock(text) {
|
|
6248
|
+
return !!getSpoilerStartMatch(text) || getSpoilerEndMatch(text);
|
|
6249
|
+
}
|
|
6250
|
+
|
|
6251
|
+
// src/docs-plugin/remark/remark-steps.ts
|
|
6252
|
+
import { visit as visit13 } from "unist-util-visit";
|
|
6253
|
+
function getStepStartMatch(text) {
|
|
6254
|
+
return text.match(/^:::\s*steps(?:\s+(h[1-6](?:-h[1-6])?))?\s*$/);
|
|
6255
|
+
}
|
|
6256
|
+
function getStepEndMatch(text) {
|
|
6257
|
+
return text.match(/^:::\s*\/steps\s*$/);
|
|
6258
|
+
}
|
|
6259
|
+
function isStepBlock(text) {
|
|
6260
|
+
return !!(getStepStartMatch(text) || getStepEndMatch(text));
|
|
6261
|
+
}
|
|
6262
|
+
|
|
6263
|
+
// src/docs-plugin/shiki/shiki-transformer-preview-block.ts
|
|
6264
|
+
import { dedent } from "@qualcomm-ui/utils/dedent";
|
|
6265
|
+
|
|
6266
|
+
// src/ai-knowledge/generator/filter-text-directives.ts
|
|
6267
|
+
var filterTextDirectives = () => {
|
|
6268
|
+
return (tree, _file, done) => {
|
|
6269
|
+
visit14(tree, "text", (node) => {
|
|
6270
|
+
const value = node.value?.trim?.();
|
|
6271
|
+
if (value && (isStepBlock(value) || isSpoilerBlock(value))) {
|
|
6272
|
+
Object.assign(node, {
|
|
6273
|
+
value: ``
|
|
6274
|
+
});
|
|
6275
|
+
}
|
|
6276
|
+
});
|
|
6277
|
+
done();
|
|
6278
|
+
};
|
|
6279
|
+
};
|
|
6280
|
+
|
|
6281
|
+
// src/ai-knowledge/generator/npm-install-tabs-plugin.ts
|
|
6282
|
+
import { visit as visit15 } from "unist-util-visit";
|
|
6002
6283
|
var formatNpmInstallTabs = () => {
|
|
6003
6284
|
return (tree, _file, done) => {
|
|
6004
|
-
|
|
6285
|
+
visit15(
|
|
6005
6286
|
tree,
|
|
6006
6287
|
"mdxJsxFlowElement",
|
|
6007
6288
|
(node, index, parent) => {
|
|
@@ -6030,7 +6311,7 @@ var formatNpmInstallTabs = () => {
|
|
|
6030
6311
|
};
|
|
6031
6312
|
|
|
6032
6313
|
// src/ai-knowledge/generator/qds-theme-plugin.ts
|
|
6033
|
-
import { visit as
|
|
6314
|
+
import { visit as visit16 } from "unist-util-visit";
|
|
6034
6315
|
function themeDataToJson(data, cssPropertyName) {
|
|
6035
6316
|
if (!data || typeof data !== "object") {
|
|
6036
6317
|
return "";
|
|
@@ -6089,7 +6370,7 @@ async function formatThemeNodes() {
|
|
|
6089
6370
|
}
|
|
6090
6371
|
};
|
|
6091
6372
|
return () => (tree, _file, done) => {
|
|
6092
|
-
|
|
6373
|
+
visit16(tree, "mdxJsxFlowElement", (node) => {
|
|
6093
6374
|
const handler = node.name && handlers[node.name];
|
|
6094
6375
|
if (!handler) {
|
|
6095
6376
|
return;
|
|
@@ -6121,10 +6402,10 @@ async function formatThemeNodes() {
|
|
|
6121
6402
|
}
|
|
6122
6403
|
|
|
6123
6404
|
// src/ai-knowledge/generator/section-extractor.ts
|
|
6124
|
-
import { toString as
|
|
6405
|
+
import { toString as toString3 } from "mdast-util-to-string";
|
|
6125
6406
|
import remarkStringify3 from "remark-stringify";
|
|
6126
6407
|
import { unified as unified4 } from "unified";
|
|
6127
|
-
import { visit as
|
|
6408
|
+
import { visit as visit17 } from "unist-util-visit";
|
|
6128
6409
|
import { kebabCase as kebabCase2 } from "@qualcomm-ui/utils/change-case";
|
|
6129
6410
|
var SectionExtractor = class {
|
|
6130
6411
|
depths;
|
|
@@ -6152,20 +6433,29 @@ var SectionExtractor = class {
|
|
|
6152
6433
|
};
|
|
6153
6434
|
for (let i = 0; i < tree.children.length; i++) {
|
|
6154
6435
|
const node = tree.children[i];
|
|
6436
|
+
if (node.type === "yaml") {
|
|
6437
|
+
continue;
|
|
6438
|
+
}
|
|
6155
6439
|
if (node.type === "heading") {
|
|
6156
|
-
const
|
|
6157
|
-
if (!this.depths.has(
|
|
6440
|
+
const heading2 = node;
|
|
6441
|
+
if (!this.depths.has(heading2.depth)) {
|
|
6158
6442
|
if (pendingSection) {
|
|
6159
6443
|
pendingSection.nodes.push(node);
|
|
6444
|
+
} else {
|
|
6445
|
+
pendingSection = {
|
|
6446
|
+
headerPath: headerStack.map((h) => h.text),
|
|
6447
|
+
nodes: [],
|
|
6448
|
+
startIndex: i
|
|
6449
|
+
};
|
|
6160
6450
|
}
|
|
6161
6451
|
continue;
|
|
6162
6452
|
}
|
|
6163
6453
|
finalizeSection();
|
|
6164
|
-
while (headerStack.length > 0 && headerStack[headerStack.length - 1].depth >=
|
|
6454
|
+
while (headerStack.length > 0 && headerStack[headerStack.length - 1].depth >= heading2.depth) {
|
|
6165
6455
|
headerStack.pop();
|
|
6166
6456
|
}
|
|
6167
|
-
const headingText =
|
|
6168
|
-
headerStack.push({ depth:
|
|
6457
|
+
const headingText = toString3(heading2);
|
|
6458
|
+
headerStack.push({ depth: heading2.depth, text: headingText });
|
|
6169
6459
|
pendingSection = {
|
|
6170
6460
|
headerPath: headerStack.map((h) => h.text),
|
|
6171
6461
|
nodes: [],
|
|
@@ -6173,6 +6463,12 @@ var SectionExtractor = class {
|
|
|
6173
6463
|
};
|
|
6174
6464
|
} else if (pendingSection) {
|
|
6175
6465
|
pendingSection.nodes.push(node);
|
|
6466
|
+
} else {
|
|
6467
|
+
pendingSection = {
|
|
6468
|
+
headerPath: headerStack.map((h) => h.text),
|
|
6469
|
+
nodes: [node],
|
|
6470
|
+
startIndex: i
|
|
6471
|
+
};
|
|
6176
6472
|
}
|
|
6177
6473
|
}
|
|
6178
6474
|
finalizeSection();
|
|
@@ -6197,6 +6493,7 @@ var SectionExtractor = class {
|
|
|
6197
6493
|
code: codeNode.value,
|
|
6198
6494
|
language: codeNode.lang ?? ""
|
|
6199
6495
|
});
|
|
6496
|
+
} else if (node.type === "text" && (isStepBlock(node.value.trim()) || isSpoilerBlock(node.value.trim()))) {
|
|
6200
6497
|
} else {
|
|
6201
6498
|
contentNodes.push(node);
|
|
6202
6499
|
}
|
|
@@ -6265,9 +6562,9 @@ var SectionExtractor = class {
|
|
|
6265
6562
|
*/
|
|
6266
6563
|
transformLinks() {
|
|
6267
6564
|
return () => (tree) => {
|
|
6268
|
-
|
|
6565
|
+
visit17(tree, "link", (node) => {
|
|
6269
6566
|
let text = "";
|
|
6270
|
-
|
|
6567
|
+
visit17(node, "text", (textNode) => {
|
|
6271
6568
|
text += textNode.value;
|
|
6272
6569
|
});
|
|
6273
6570
|
Object.assign(node, {
|
|
@@ -6378,14 +6675,14 @@ var KnowledgeGenerator = class {
|
|
|
6378
6675
|
}
|
|
6379
6676
|
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
6380
6677
|
const mdxFiles = entries.filter(
|
|
6381
|
-
(f) => f.name.endsWith(".mdx") && !shouldExclude(
|
|
6678
|
+
(f) => f.name.endsWith(".mdx") && !shouldExclude(join7(dirPath, f.name))
|
|
6382
6679
|
) ?? [];
|
|
6383
6680
|
const pageIdPrefix = this.config.pageIdPrefix ?? "";
|
|
6384
6681
|
for (const mdxFile of mdxFiles) {
|
|
6385
6682
|
const demosFolder = entries.find((f) => f.name === "demos");
|
|
6386
|
-
const demosFolderPath = demosFolder ?
|
|
6683
|
+
const demosFolderPath = demosFolder ? join7(dirPath, demosFolder.name) : void 0;
|
|
6387
6684
|
const segments = getPathSegmentsFromFileName(
|
|
6388
|
-
|
|
6685
|
+
join7(dirPath, mdxFile.name),
|
|
6389
6686
|
this.config.routeDir
|
|
6390
6687
|
);
|
|
6391
6688
|
const url = getPathnameFromPathSegments(segments);
|
|
@@ -6393,7 +6690,7 @@ var KnowledgeGenerator = class {
|
|
|
6393
6690
|
demosFolder: demosFolderPath,
|
|
6394
6691
|
filePath: dirPath,
|
|
6395
6692
|
id: `${pageIdPrefix ? `${pageIdPrefix}-` : ""}${segments.join("-").trim()}`,
|
|
6396
|
-
mdxFile:
|
|
6693
|
+
mdxFile: join7(dirPath, mdxFile.name),
|
|
6397
6694
|
name: segments.at(-1),
|
|
6398
6695
|
pathname: url,
|
|
6399
6696
|
url: this.config.baseUrl ? new URL(url, this.config.baseUrl).toString() : void 0
|
|
@@ -6404,7 +6701,7 @@ var KnowledgeGenerator = class {
|
|
|
6404
6701
|
}
|
|
6405
6702
|
}
|
|
6406
6703
|
for (const entry of entries) {
|
|
6407
|
-
const fullPath =
|
|
6704
|
+
const fullPath = join7(dirPath, entry.name);
|
|
6408
6705
|
const stats = await stat(fullPath);
|
|
6409
6706
|
if (stats.isDirectory()) {
|
|
6410
6707
|
await scanDirectory(fullPath);
|
|
@@ -6416,7 +6713,7 @@ var KnowledgeGenerator = class {
|
|
|
6416
6713
|
}
|
|
6417
6714
|
formatFrontmatterExpressions(frontmatter) {
|
|
6418
6715
|
return () => (tree) => {
|
|
6419
|
-
|
|
6716
|
+
visit18(
|
|
6420
6717
|
tree,
|
|
6421
6718
|
"mdxFlowExpression",
|
|
6422
6719
|
(node, index, parent) => {
|
|
@@ -6456,7 +6753,7 @@ var KnowledgeGenerator = class {
|
|
|
6456
6753
|
if (!baseUrl || this.config.outputMode !== "per-page") {
|
|
6457
6754
|
return;
|
|
6458
6755
|
}
|
|
6459
|
-
|
|
6756
|
+
visit18(tree, "link", (node) => {
|
|
6460
6757
|
if (node.url.startsWith("/")) {
|
|
6461
6758
|
node.url = `${baseUrl}${node.url}`;
|
|
6462
6759
|
} else if (node.url.startsWith("./#") && pageUrl) {
|
|
@@ -6500,7 +6797,7 @@ var KnowledgeGenerator = class {
|
|
|
6500
6797
|
* into Markdown, resolving relative links, and cleaning up formatting.
|
|
6501
6798
|
*/
|
|
6502
6799
|
async processMdxContent(mdxContent, pageInfo, frontmatter) {
|
|
6503
|
-
const processor = unified5().use(remarkParse4).use(remarkMdx3).use(
|
|
6800
|
+
const processor = unified5().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter3, ["yaml"]).use(this.propFormatter.propsToMarkdownList()).use(this.formatFrontmatterExpressions(frontmatter)).use(await formatThemeNodes()).use(formatDemos(pageInfo.demosFolder)).use(filterTextDirectives).use(this.transformRelativeUrls(pageInfo.url));
|
|
6504
6801
|
this.applyPlugins(pageInfo, processor);
|
|
6505
6802
|
processor.use(remarkStringify4);
|
|
6506
6803
|
return await processor.run(processor.parse(mdxContent));
|
|
@@ -6511,7 +6808,7 @@ var KnowledgeGenerator = class {
|
|
|
6511
6808
|
if (this.config.verbose) {
|
|
6512
6809
|
console.log(`Processing page: ${pageInfo.name}`);
|
|
6513
6810
|
}
|
|
6514
|
-
const processor = unified5().use(remarkParse4).use(remarkMdx3).use(formatNpmInstallTabs).use(
|
|
6811
|
+
const processor = unified5().use(remarkParse4).use(remarkMdx3).use(formatNpmInstallTabs).use(remarkFrontmatter3, ["yaml"]).use(remarkParseFrontmatter2).use(remarkStringify4);
|
|
6515
6812
|
const parsed = await processor.process(mdxContent);
|
|
6516
6813
|
const frontmatter = parsed.data?.frontmatter || {};
|
|
6517
6814
|
const ast = await this.processMdxContent(
|
|
@@ -6519,7 +6816,7 @@ var KnowledgeGenerator = class {
|
|
|
6519
6816
|
pageInfo,
|
|
6520
6817
|
frontmatter
|
|
6521
6818
|
);
|
|
6522
|
-
const removeJsxProcessor = unified5().use(remarkMdx3).use(
|
|
6819
|
+
const removeJsxProcessor = unified5().use(remarkMdx3).use(remarkFrontmatter3, ["yaml"]).use(remarkRemoveJsx).use(remarkStringify4);
|
|
6523
6820
|
const sectionAst = removeJsxProcessor.runSync(ast);
|
|
6524
6821
|
const removedJsx = String(removeJsxProcessor.stringify(sectionAst));
|
|
6525
6822
|
const rawContent = removedJsx.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "").replace(/(^#{1,6} .*\\<[^>]+)>/gm, "$1\\>");
|
|
@@ -6589,7 +6886,7 @@ var KnowledgeGenerator = class {
|
|
|
6589
6886
|
extraFiles.map(async (extraFile) => {
|
|
6590
6887
|
let contents = extraFile.contents;
|
|
6591
6888
|
if (extraFile.processAsMdx) {
|
|
6592
|
-
const removeJsxProcessor = unified5().use(remarkParse4).use(remarkMdx3).use(
|
|
6889
|
+
const removeJsxProcessor = unified5().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter3, ["yaml"]).use(remarkRemoveJsx).use(this.transformRelativeUrls()).use(remarkStringify4);
|
|
6593
6890
|
contents = String(await removeJsxProcessor.process(contents));
|
|
6594
6891
|
}
|
|
6595
6892
|
const lines = [];
|
|
@@ -6609,7 +6906,7 @@ var KnowledgeGenerator = class {
|
|
|
6609
6906
|
lines.push("");
|
|
6610
6907
|
const fileContent = lines.join("\n");
|
|
6611
6908
|
const fileName = `${kebabCase3(extraFile.id)}.md`;
|
|
6612
|
-
const outfile = `${
|
|
6909
|
+
const outfile = `${resolve5(this.config.outputPath)}/${fileName}`;
|
|
6613
6910
|
await writeFile(outfile, fileContent, "utf-8");
|
|
6614
6911
|
const stats = await stat(outfile);
|
|
6615
6912
|
totalSize += stats.size / 1024;
|
|
@@ -6712,7 +7009,7 @@ var KnowledgeGenerator = class {
|
|
|
6712
7009
|
lines.push("");
|
|
6713
7010
|
const fileContent = lines.join("\n");
|
|
6714
7011
|
const fileName = `${kebabCase3(page.id || page.name)}.md`;
|
|
6715
|
-
const outfile = `${
|
|
7012
|
+
const outfile = `${resolve5(this.config.outputPath)}/${fileName}`;
|
|
6716
7013
|
await writeFile(outfile, fileContent, "utf-8");
|
|
6717
7014
|
const stats = await stat(outfile);
|
|
6718
7015
|
totalSize += stats.size / 1024;
|
|
@@ -6748,7 +7045,7 @@ var KnowledgeGenerator = class {
|
|
|
6748
7045
|
);
|
|
6749
7046
|
}
|
|
6750
7047
|
console.log(
|
|
6751
|
-
`Generated ${count + extraFilesResult.count} files(s) in ${
|
|
7048
|
+
`Generated ${count + extraFilesResult.count} files(s) in ${chalk4.magenta.bold(`${Math.round(performance.now() - start + extraFilesResult.duration)}ms`)} at ${chalk4.blue.bold(this.config.outputPath)} - ${(totalSize + extraFilesResult.totalSize).toFixed(1)} KB`
|
|
6752
7049
|
);
|
|
6753
7050
|
}
|
|
6754
7051
|
computeAggregateHash(entries) {
|
|
@@ -6770,7 +7067,7 @@ var KnowledgeGenerator = class {
|
|
|
6770
7067
|
await mkdir(outputPath, { recursive: true }).catch(() => {
|
|
6771
7068
|
});
|
|
6772
7069
|
await writeFile(
|
|
6773
|
-
|
|
7070
|
+
join7(outputPath, "manifest.json"),
|
|
6774
7071
|
JSON.stringify(manifest, null, 2),
|
|
6775
7072
|
"utf-8"
|
|
6776
7073
|
);
|
|
@@ -6779,10 +7076,10 @@ var KnowledgeGenerator = class {
|
|
|
6779
7076
|
async generateBulkZip(outputPath, entries) {
|
|
6780
7077
|
await mkdir(outputPath, { recursive: true }).catch(() => {
|
|
6781
7078
|
});
|
|
6782
|
-
const zipPath =
|
|
7079
|
+
const zipPath = join7(outputPath, "bulk.zip");
|
|
6783
7080
|
const zip = new AdmZip();
|
|
6784
7081
|
for (const entry of entries) {
|
|
6785
|
-
const filePath =
|
|
7082
|
+
const filePath = join7(this.config.outputPath, entry.path);
|
|
6786
7083
|
const content = await readFile4(filePath);
|
|
6787
7084
|
zip.addFile(entry.path, content);
|
|
6788
7085
|
}
|
|
@@ -6815,7 +7112,7 @@ var KnowledgeGenerator = class {
|
|
|
6815
7112
|
totalSections: allSections.length,
|
|
6816
7113
|
version: 1
|
|
6817
7114
|
};
|
|
6818
|
-
const sectionsPath =
|
|
7115
|
+
const sectionsPath = join7(
|
|
6819
7116
|
outputPath,
|
|
6820
7117
|
sectionsConfig.outputPath ?? "sections.json"
|
|
6821
7118
|
);
|
|
@@ -6824,7 +7121,7 @@ var KnowledgeGenerator = class {
|
|
|
6824
7121
|
await writeFile(sectionsPath, JSON.stringify(output, null, 2), "utf-8");
|
|
6825
7122
|
if (this.config.verbose) {
|
|
6826
7123
|
console.log(
|
|
6827
|
-
`Generated ${allSections.length} sections at ${
|
|
7124
|
+
`Generated ${allSections.length} sections at ${chalk4.blue.bold(sectionsPath)}`
|
|
6828
7125
|
);
|
|
6829
7126
|
}
|
|
6830
7127
|
}
|
|
@@ -6874,7 +7171,7 @@ Generated knowledge for ${configs.length} environment(s)`
|
|
|
6874
7171
|
// src/ai-knowledge/open-web-ui/download-knowledge.ts
|
|
6875
7172
|
import dotenv from "dotenv";
|
|
6876
7173
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
6877
|
-
import { resolve as
|
|
7174
|
+
import { resolve as resolve6 } from "node:path";
|
|
6878
7175
|
|
|
6879
7176
|
// src/ai-knowledge/open-web-ui/api.ts
|
|
6880
7177
|
function isErrorResponse(response) {
|
|
@@ -6985,7 +7282,7 @@ var FilesApi = class {
|
|
|
6985
7282
|
if (status.status === "completed" || status.status === "failed") {
|
|
6986
7283
|
return status;
|
|
6987
7284
|
}
|
|
6988
|
-
await new Promise((
|
|
7285
|
+
await new Promise((resolve11) => setTimeout(resolve11, intervalMs));
|
|
6989
7286
|
}
|
|
6990
7287
|
throw new Error(`File processing timed out after ${maxAttempts} attempts`);
|
|
6991
7288
|
}
|
|
@@ -7199,7 +7496,7 @@ function addDownloadKnowledgeCommand() {
|
|
|
7199
7496
|
const content = await filesApi.getDataContent(file.id);
|
|
7200
7497
|
if (content?.content) {
|
|
7201
7498
|
await writeFile2(
|
|
7202
|
-
|
|
7499
|
+
resolve6(opts.outputDir, fileName),
|
|
7203
7500
|
content.content,
|
|
7204
7501
|
"utf-8"
|
|
7205
7502
|
);
|
|
@@ -7215,7 +7512,7 @@ function addDownloadKnowledgeCommand() {
|
|
|
7215
7512
|
import { createHash as createHash3 } from "node:crypto";
|
|
7216
7513
|
import { writeFileSync } from "node:fs";
|
|
7217
7514
|
import { access as access2, readdir as readdir2, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
7218
|
-
import { resolve as
|
|
7515
|
+
import { resolve as resolve7 } from "node:path";
|
|
7219
7516
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
7220
7517
|
import ora from "ora";
|
|
7221
7518
|
|
|
@@ -7422,7 +7719,7 @@ var Uploader = class {
|
|
|
7422
7719
|
const files = await Promise.all(
|
|
7423
7720
|
fileNames.map(async (name) => ({
|
|
7424
7721
|
contents: await readFile5(
|
|
7425
|
-
|
|
7722
|
+
resolve7(this.config.knowledgeFilePath, name),
|
|
7426
7723
|
"utf-8"
|
|
7427
7724
|
),
|
|
7428
7725
|
name
|
|
@@ -7474,7 +7771,7 @@ var Uploader = class {
|
|
|
7474
7771
|
try {
|
|
7475
7772
|
const fileId = knowledgeFile.id;
|
|
7476
7773
|
const fileString = await readFile5(
|
|
7477
|
-
|
|
7774
|
+
resolve7(this.config.knowledgeFilePath, name),
|
|
7478
7775
|
"utf-8"
|
|
7479
7776
|
);
|
|
7480
7777
|
const spinner2 = ora(`Updating ${name}`).start();
|
|
@@ -7489,7 +7786,7 @@ var Uploader = class {
|
|
|
7489
7786
|
}
|
|
7490
7787
|
const spinner = ora(`Uploading ${name}`).start();
|
|
7491
7788
|
const fileBuffer = await readFile5(
|
|
7492
|
-
|
|
7789
|
+
resolve7(this.config.knowledgeFilePath, name)
|
|
7493
7790
|
);
|
|
7494
7791
|
let uploadedFileId = void 0;
|
|
7495
7792
|
try {
|
|
@@ -7527,7 +7824,7 @@ var Uploader = class {
|
|
|
7527
7824
|
}
|
|
7528
7825
|
}
|
|
7529
7826
|
async uploadKnowledge() {
|
|
7530
|
-
const resolvedPath =
|
|
7827
|
+
const resolvedPath = resolve7(this.config.knowledgeFilePath);
|
|
7531
7828
|
if (!await access2(resolvedPath).then(() => true).catch(() => false)) {
|
|
7532
7829
|
throw new Error(`File or folder not found at ${resolvedPath}`);
|
|
7533
7830
|
}
|
|
@@ -7614,7 +7911,7 @@ Uploaded to ${successCount} integration(s)${failureCount > 0 ? `, ${failureCount
|
|
|
7614
7911
|
const files = await uploader.filesApi.search("*");
|
|
7615
7912
|
console.debug(`found ${files.length} files`);
|
|
7616
7913
|
writeFileSync(
|
|
7617
|
-
|
|
7914
|
+
resolve7(uploader.config.knowledgeFilePath, "files.json"),
|
|
7618
7915
|
JSON.stringify(files, null, 2),
|
|
7619
7916
|
"utf-8"
|
|
7620
7917
|
);
|
|
@@ -7657,9 +7954,9 @@ Uploaded to ${successCount} integration(s)${failureCount > 0 ? `, ${failureCount
|
|
|
7657
7954
|
}
|
|
7658
7955
|
|
|
7659
7956
|
// src/docs-plugin/generate-page-map.ts
|
|
7660
|
-
import { glob } from "glob";
|
|
7957
|
+
import { glob as glob2 } from "glob";
|
|
7661
7958
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
7662
|
-
import { resolve as
|
|
7959
|
+
import { resolve as resolve8 } from "node:path";
|
|
7663
7960
|
import { cwd } from "node:process";
|
|
7664
7961
|
function addGeneratePageMapCommand() {
|
|
7665
7962
|
program.command("generate-page-map").description(
|
|
@@ -7680,14 +7977,14 @@ function addGeneratePageMapCommand() {
|
|
|
7680
7977
|
const configLoader = new ConfigLoader({ configFile: options.configFile });
|
|
7681
7978
|
const resolvedConfig = configLoader.loadConfig();
|
|
7682
7979
|
const routesDir = fixPath(
|
|
7683
|
-
|
|
7980
|
+
resolve8(resolvedConfig.appDirectory, resolvedConfig.pageDirectory)
|
|
7684
7981
|
);
|
|
7685
7982
|
const indexer = new SearchIndexer({
|
|
7686
7983
|
...resolvedConfig,
|
|
7687
|
-
srcDir: fixPath(
|
|
7984
|
+
srcDir: fixPath(resolve8(cwd(), resolvedConfig.appDirectory)),
|
|
7688
7985
|
typeDocProps: {}
|
|
7689
7986
|
});
|
|
7690
|
-
const files =
|
|
7987
|
+
const files = glob2.sync(
|
|
7691
7988
|
[`${routesDir}/**/*.mdx`, `${routesDir}/**/*.tsx`],
|
|
7692
7989
|
{
|
|
7693
7990
|
absolute: true,
|
|
@@ -7696,7 +7993,7 @@ function addGeneratePageMapCommand() {
|
|
|
7696
7993
|
);
|
|
7697
7994
|
indexer.buildIndex(files, true);
|
|
7698
7995
|
await writeFile3(
|
|
7699
|
-
|
|
7996
|
+
resolve8(cwd(), options.output),
|
|
7700
7997
|
JSON.stringify(indexer.pageMap, null, 2),
|
|
7701
7998
|
"utf-8"
|
|
7702
7999
|
);
|
|
@@ -7711,16 +8008,16 @@ function addGeneratePageMapCommand() {
|
|
|
7711
8008
|
}
|
|
7712
8009
|
|
|
7713
8010
|
// src/react-demo-plugin/generate-lazy-demo-map.ts
|
|
7714
|
-
import { glob as
|
|
8011
|
+
import { glob as glob3 } from "glob";
|
|
7715
8012
|
import { uniqBy } from "lodash-es";
|
|
7716
8013
|
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
7717
|
-
import { resolve as
|
|
7718
|
-
import { dedent } from "@qualcomm-ui/utils/dedent";
|
|
8014
|
+
import { resolve as resolve10 } from "node:path";
|
|
8015
|
+
import { dedent as dedent2 } from "@qualcomm-ui/utils/dedent";
|
|
7719
8016
|
|
|
7720
8017
|
// src/react-demo-plugin/demo-plugin-utils.ts
|
|
7721
|
-
import
|
|
7722
|
-
import { existsSync as existsSync2, readFileSync as
|
|
7723
|
-
import { dirname as dirname4, join as
|
|
8018
|
+
import chalk5 from "chalk";
|
|
8019
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
8020
|
+
import { dirname as dirname4, join as join8, relative as relative3, resolve as resolve9, sep } from "node:path";
|
|
7724
8021
|
import * as ts2 from "typescript";
|
|
7725
8022
|
import { pascalCase } from "@qualcomm-ui/utils/change-case";
|
|
7726
8023
|
function extractPageId(filePath, routesDir) {
|
|
@@ -7734,7 +8031,7 @@ function extractPageId(filePath, routesDir) {
|
|
|
7734
8031
|
}
|
|
7735
8032
|
function isDemoFile(filePath) {
|
|
7736
8033
|
try {
|
|
7737
|
-
return filePath.includes("/demos/") && filePath.endsWith(".tsx") && !
|
|
8034
|
+
return filePath.includes("/demos/") && filePath.endsWith(".tsx") && !readFileSync3(filePath).includes("export default");
|
|
7738
8035
|
} catch (error) {
|
|
7739
8036
|
return false;
|
|
7740
8037
|
}
|
|
@@ -7745,7 +8042,7 @@ async function scanForDemoPages({
|
|
|
7745
8042
|
demoPattern = "src/routes/**/demos/*.tsx",
|
|
7746
8043
|
routesDir = "src/routes"
|
|
7747
8044
|
}) {
|
|
7748
|
-
const demoFiles = (await
|
|
8045
|
+
const demoFiles = (await glob3(demoPattern)).filter((file) => isDemoFile(file));
|
|
7749
8046
|
return uniqBy(
|
|
7750
8047
|
demoFiles.map((file) => ({
|
|
7751
8048
|
pageId: extractPageId(file, routesDir),
|
|
@@ -7759,7 +8056,7 @@ function generateLazyDemoLoader(demoPages) {
|
|
|
7759
8056
|
return ` "${routePath}": () =>
|
|
7760
8057
|
import("virtual:qui-demo-scope/page:${pageId}")`;
|
|
7761
8058
|
}).sort().join(",\n");
|
|
7762
|
-
return
|
|
8059
|
+
return dedent2`
|
|
7763
8060
|
/* eslint-disable */
|
|
7764
8061
|
|
|
7765
8062
|
// This file is generated automatically. Don't edit it directly.
|
|
@@ -7777,7 +8074,7 @@ function generateLazyDemoLoader(demoPages) {
|
|
|
7777
8074
|
}
|
|
7778
8075
|
async function generateLazyDemoMap(options) {
|
|
7779
8076
|
const routesDir = options.routesDir;
|
|
7780
|
-
const outputPath =
|
|
8077
|
+
const outputPath = resolve10(options.output);
|
|
7781
8078
|
console.log(`Scanning for demo pages in: ${routesDir}`);
|
|
7782
8079
|
const demoPages = await scanForDemoPages({ routesDir });
|
|
7783
8080
|
console.log(`Found ${demoPages.length} pages with demos`);
|