@qualcomm-ui/mdx-vite 2.1.3 → 2.2.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/angular-demo-plugin/angular-demo-plugin.d.ts.map +1 -1
- package/dist/cli.js +151 -77
- package/dist/cli.js.map +4 -4
- package/dist/docs-plugin/docs-plugin.d.ts.map +1 -1
- package/dist/docs-plugin/mdx-plugins.d.ts.map +1 -1
- package/dist/docs-plugin/shiki/index.d.ts +2 -0
- package/dist/docs-plugin/shiki/index.d.ts.map +1 -1
- package/dist/docs-plugin/shiki/shiki-transformer-code-attribute.d.ts +7 -2
- package/dist/docs-plugin/shiki/shiki-transformer-code-attribute.d.ts.map +1 -1
- package/dist/docs-plugin/shiki/shiki-transformer-hidden.d.ts +6 -0
- package/dist/docs-plugin/shiki/shiki-transformer-hidden.d.ts.map +1 -0
- package/dist/docs-plugin/shiki/shiki-transformer-preview-block.d.ts +24 -4
- package/dist/docs-plugin/shiki/shiki-transformer-preview-block.d.ts.map +1 -1
- package/dist/docs-plugin/shiki/utils.d.ts.map +1 -1
- package/dist/index.js +3146 -3260
- package/dist/index.js.map +4 -4
- package/dist/open-web-ui-knowledge/generate-knowledge.d.ts.map +1 -1
- package/dist/react-demo-plugin/react-demo-plugin.d.ts.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-demo-plugin.d.ts","sourceRoot":"","sources":["../../src/angular-demo-plugin/angular-demo-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"angular-demo-plugin.d.ts","sourceRoot":"","sources":["../../src/angular-demo-plugin/angular-demo-plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC/B,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EAAC,MAAM,EAAgB,MAAM,MAAM,CAAA;AAe/C,MAAM,WAAW,wBAAwB;IACvC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE;QACN,IAAI,EACA,oBAAoB,GACpB,iBAAiB,GACjB,yBAAyB,GACzB,MAAM,CAAA;QACV,KAAK,EACD,oBAAoB,GACpB,iBAAiB,GACjB,yBAAyB,GACzB,MAAM,CAAA;KACX,CAAA;CACF;AA8BD,wBAAgB,iBAAiB,CAAC,EAChC,WAAwC,EACxC,WAAW,EACX,SAAwB,EACxB,KAGC,GACF,GAAE,wBAA6B,GAAG,MAAM,CAo6BxC"}
|
package/dist/cli.js
CHANGED
|
@@ -5526,6 +5526,9 @@ function remarkSelfLinkHeadings(baseUrl = "", options) {
|
|
|
5526
5526
|
// src/docs-plugin/remark/remark-spoilers.ts
|
|
5527
5527
|
import { visit as visit6 } from "unist-util-visit";
|
|
5528
5528
|
|
|
5529
|
+
// src/docs-plugin/shiki/shiki-transformer-preview-block.ts
|
|
5530
|
+
import { dedent } from "@qualcomm-ui/utils/dedent";
|
|
5531
|
+
|
|
5529
5532
|
// src/open-web-ui-knowledge/load-config-from-env.ts
|
|
5530
5533
|
import { existsSync } from "node:fs";
|
|
5531
5534
|
import { join as join2, resolve as resolve4 } from "node:path";
|
|
@@ -5698,6 +5701,7 @@ async function scanPages(routesFolder, verbose, excludePatterns = [], baseUrl) {
|
|
|
5698
5701
|
const url = getPathnameFromPathSegments(segments);
|
|
5699
5702
|
components.push({
|
|
5700
5703
|
demosFolder: demosFolderPath,
|
|
5704
|
+
id: segments.join("-"),
|
|
5701
5705
|
mdxFile: join3(dirPath, mdxFile.name),
|
|
5702
5706
|
name: segments.at(-1),
|
|
5703
5707
|
path: dirPath,
|
|
@@ -5871,98 +5875,168 @@ var replaceNpmInstallTabs = () => {
|
|
|
5871
5875
|
done();
|
|
5872
5876
|
};
|
|
5873
5877
|
};
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5878
|
+
function replaceTypeDocProps(docProps, verbose) {
|
|
5879
|
+
return () => (tree, _file, done) => {
|
|
5880
|
+
visit7(
|
|
5881
|
+
tree,
|
|
5882
|
+
"mdxJsxFlowElement",
|
|
5883
|
+
(node, index, parent) => {
|
|
5884
|
+
if (node?.name !== "TypeDocProps") {
|
|
5885
|
+
return;
|
|
5886
|
+
}
|
|
5887
|
+
const nameAttr = node.attributes?.find(
|
|
5888
|
+
(attr) => attr.type === "mdxJsxAttribute" && attr.name === "name"
|
|
5889
|
+
);
|
|
5890
|
+
const isPartial = node.attributes?.some(
|
|
5891
|
+
(attr) => attr.type === "mdxJsxAttribute" && attr.name === "partial"
|
|
5892
|
+
);
|
|
5893
|
+
if (!docProps || !nameAttr) {
|
|
5894
|
+
if (parent && index !== void 0) {
|
|
5895
|
+
parent.children.splice(index, 1);
|
|
5896
|
+
}
|
|
5897
|
+
return;
|
|
5898
|
+
}
|
|
5899
|
+
const propsNames = extractNamesFromAttribute(nameAttr);
|
|
5900
|
+
if (propsNames.length === 0) {
|
|
5901
|
+
if (parent && index !== void 0) {
|
|
5902
|
+
parent.children.splice(index, 1);
|
|
5903
|
+
}
|
|
5904
|
+
return;
|
|
5905
|
+
}
|
|
5906
|
+
const propsName = propsNames[0];
|
|
5892
5907
|
const componentProps = docProps.props[propsName];
|
|
5893
5908
|
if (!componentProps) {
|
|
5894
5909
|
if (verbose) {
|
|
5895
5910
|
console.log(` TypeDocProps not found: ${propsName}`);
|
|
5896
5911
|
}
|
|
5897
|
-
|
|
5912
|
+
if (parent && index !== void 0) {
|
|
5913
|
+
parent.children.splice(index, 1);
|
|
5914
|
+
}
|
|
5915
|
+
return;
|
|
5898
5916
|
}
|
|
5899
|
-
const propsDoc = extractProps(componentProps, isPartial);
|
|
5917
|
+
const propsDoc = extractProps(componentProps, Boolean(isPartial));
|
|
5900
5918
|
if (verbose) {
|
|
5901
5919
|
console.log(
|
|
5902
5920
|
` Replaced TypeDocProps ${propsName} with API documentation`
|
|
5903
5921
|
);
|
|
5904
5922
|
}
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5923
|
+
Object.assign(node, {
|
|
5924
|
+
lang: "json",
|
|
5925
|
+
meta: null,
|
|
5926
|
+
type: "code",
|
|
5927
|
+
value: JSON.stringify(propsDoc, null, 2)
|
|
5928
|
+
});
|
|
5910
5929
|
}
|
|
5911
5930
|
);
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
const kebabName = kebabCase(demoName);
|
|
5925
|
-
let filePath = `${kebabName}.tsx`;
|
|
5926
|
-
if (!demosFolder) {
|
|
5927
|
-
if (verbose) {
|
|
5928
|
-
console.log(` No demos folder for ${demoName}`);
|
|
5929
|
-
}
|
|
5930
|
-
return { match: fullMatch, replacement: "" };
|
|
5931
|
-
}
|
|
5932
|
-
let demoFilePath = join3(demosFolder, filePath);
|
|
5933
|
-
let isAngularDemo = false;
|
|
5934
|
-
if (!await exists(demoFilePath)) {
|
|
5935
|
-
demoFilePath = join3(demosFolder, `${kebabName}.ts`);
|
|
5936
|
-
if (await exists(demoFilePath)) {
|
|
5937
|
-
isAngularDemo = true;
|
|
5938
|
-
filePath = `${kebabCase(demoName).replace("-component", ".component")}.ts`;
|
|
5939
|
-
demoFilePath = join3(demosFolder, filePath);
|
|
5940
|
-
} else {
|
|
5941
|
-
console.log(` Demo not found ${demoName}`);
|
|
5942
|
-
return { match: fullMatch, replacement: "" };
|
|
5931
|
+
done();
|
|
5932
|
+
};
|
|
5933
|
+
}
|
|
5934
|
+
function replaceDemos(demosFolder, verbose, demoFiles) {
|
|
5935
|
+
return () => async (tree) => {
|
|
5936
|
+
const promises = [];
|
|
5937
|
+
visit7(
|
|
5938
|
+
tree,
|
|
5939
|
+
"mdxJsxFlowElement",
|
|
5940
|
+
(node, index, parent) => {
|
|
5941
|
+
if (!node?.name || !["QdsDemo", "CodeDemo", "Demo"].includes(node.name)) {
|
|
5942
|
+
return;
|
|
5943
5943
|
}
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
const
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5944
|
+
const nameAttr = node.attributes?.find(
|
|
5945
|
+
(attr) => attr.type === "mdxJsxAttribute" && attr.name === "name"
|
|
5946
|
+
);
|
|
5947
|
+
const nodeAttr = node.attributes?.find(
|
|
5948
|
+
(attr) => attr.type === "mdxJsxAttribute" && attr.name === "node"
|
|
5949
|
+
);
|
|
5950
|
+
let demoName;
|
|
5951
|
+
if (nameAttr && typeof nameAttr.value === "string") {
|
|
5952
|
+
demoName = nameAttr.value;
|
|
5953
|
+
} else if (nodeAttr?.value && typeof nodeAttr.value !== "string") {
|
|
5954
|
+
const estree = nodeAttr.value.data?.estree;
|
|
5955
|
+
if (estree?.body?.[0]?.type === "ExpressionStatement") {
|
|
5956
|
+
const expression = estree.body[0].expression;
|
|
5957
|
+
if (expression.type === "MemberExpression" && expression.object.type === "Identifier" && expression.object.name === "Demo" && expression.property.type === "Identifier") {
|
|
5958
|
+
demoName = expression.property.name;
|
|
5959
|
+
}
|
|
5960
|
+
}
|
|
5952
5961
|
}
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5962
|
+
if (!demoName) {
|
|
5963
|
+
if (parent && index !== void 0) {
|
|
5964
|
+
parent.children.splice(index, 1);
|
|
5965
|
+
}
|
|
5966
|
+
return;
|
|
5958
5967
|
}
|
|
5959
|
-
|
|
5968
|
+
promises.push(
|
|
5969
|
+
(async () => {
|
|
5970
|
+
const kebabName = kebabCase(demoName);
|
|
5971
|
+
let filePath = `${kebabName}.tsx`;
|
|
5972
|
+
if (!demosFolder) {
|
|
5973
|
+
if (verbose) {
|
|
5974
|
+
console.log(` No demos folder for ${demoName}`);
|
|
5975
|
+
}
|
|
5976
|
+
if (parent && index !== void 0) {
|
|
5977
|
+
parent.children.splice(index, 1);
|
|
5978
|
+
}
|
|
5979
|
+
return;
|
|
5980
|
+
}
|
|
5981
|
+
let demoFilePath = join3(demosFolder, filePath);
|
|
5982
|
+
let isAngularDemo = false;
|
|
5983
|
+
if (!await exists(demoFilePath)) {
|
|
5984
|
+
demoFilePath = join3(demosFolder, `${kebabName}.ts`);
|
|
5985
|
+
if (await exists(demoFilePath)) {
|
|
5986
|
+
isAngularDemo = true;
|
|
5987
|
+
filePath = `${kebabCase(demoName).replace("-component", ".component")}.ts`;
|
|
5988
|
+
demoFilePath = join3(demosFolder, filePath);
|
|
5989
|
+
} else {
|
|
5990
|
+
console.log(` Demo not found ${demoName}`);
|
|
5991
|
+
if (parent && index !== void 0) {
|
|
5992
|
+
parent.children.splice(index, 1);
|
|
5993
|
+
}
|
|
5994
|
+
return;
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
try {
|
|
5998
|
+
const demoCode = await readFile(demoFilePath, "utf-8");
|
|
5999
|
+
const cleanedCode = removePreviewLines(demoCode);
|
|
6000
|
+
if (verbose) {
|
|
6001
|
+
console.log(` Replaced demo ${demoName} with source code`);
|
|
6002
|
+
}
|
|
6003
|
+
demoFiles.push(demoFilePath);
|
|
6004
|
+
Object.assign(node, {
|
|
6005
|
+
lang: isAngularDemo ? "angular-ts" : "tsx",
|
|
6006
|
+
meta: null,
|
|
6007
|
+
type: "code",
|
|
6008
|
+
value: cleanedCode
|
|
6009
|
+
});
|
|
6010
|
+
} catch (error) {
|
|
6011
|
+
if (verbose) {
|
|
6012
|
+
console.log(` Error reading demo ${demoName}: ${error}`);
|
|
6013
|
+
}
|
|
6014
|
+
if (parent && index !== void 0) {
|
|
6015
|
+
parent.children.splice(index, 1);
|
|
6016
|
+
}
|
|
6017
|
+
}
|
|
6018
|
+
})()
|
|
6019
|
+
);
|
|
5960
6020
|
}
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
6021
|
+
);
|
|
6022
|
+
await Promise.all(promises);
|
|
6023
|
+
};
|
|
6024
|
+
}
|
|
6025
|
+
async function processMdxContent(mdxContent, pageUrl, demosFolder, docProps, verbose) {
|
|
6026
|
+
const demoFiles = [];
|
|
6027
|
+
let processedContent = mdxContent;
|
|
6028
|
+
const lines = processedContent.split("\n");
|
|
6029
|
+
const titleLine = lines.findIndex((line) => line.startsWith("# "));
|
|
6030
|
+
processedContent = titleLine >= 0 ? lines.slice(titleLine + 1).join("\n") : processedContent;
|
|
6031
|
+
if (pageUrl) {
|
|
6032
|
+
processedContent = processedContent.replace(
|
|
6033
|
+
/\[([^\]]+)\]\(\.\/#([^)]+)\)/g,
|
|
6034
|
+
(_, text, anchor) => `[${text}](${pageUrl}#${anchor})`
|
|
6035
|
+
);
|
|
5965
6036
|
}
|
|
6037
|
+
const processor = unified4().use(remarkParse4).use(remarkMdx3).use(replaceTypeDocProps(docProps, verbose)).use(replaceDemos(demosFolder, verbose, demoFiles)).use(remarkStringify3);
|
|
6038
|
+
const processed = await processor.process(processedContent);
|
|
6039
|
+
processedContent = String(processed);
|
|
5966
6040
|
processedContent = processedContent.replace(/\n\s*\n\s*\n/g, "\n\n");
|
|
5967
6041
|
return { content: processedContent, demoFiles };
|
|
5968
6042
|
}
|
|
@@ -6083,7 +6157,7 @@ async function generatePerPageExports({
|
|
|
6083
6157
|
}
|
|
6084
6158
|
}
|
|
6085
6159
|
}
|
|
6086
|
-
const outfile = `${resolve5(outputPath)}/${kebabCase(page.
|
|
6160
|
+
const outfile = `${resolve5(outputPath)}/${kebabCase(page.id)}.md`;
|
|
6087
6161
|
await writeFile3(outfile, lines.join("\n"), "utf-8");
|
|
6088
6162
|
const stats = await stat(outfile);
|
|
6089
6163
|
totalSize += stats.size / 1024;
|
|
@@ -6365,7 +6439,7 @@ import { glob as glob3 } from "glob";
|
|
|
6365
6439
|
import { uniqBy } from "lodash-es";
|
|
6366
6440
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
6367
6441
|
import { resolve as resolve8 } from "node:path";
|
|
6368
|
-
import { dedent } from "@qualcomm-ui/utils/dedent";
|
|
6442
|
+
import { dedent as dedent2 } from "@qualcomm-ui/utils/dedent";
|
|
6369
6443
|
|
|
6370
6444
|
// src/react-demo-plugin/demo-plugin-utils.ts
|
|
6371
6445
|
import chalk4 from "chalk";
|
|
@@ -6409,7 +6483,7 @@ function generateLazyDemoLoader(demoPages) {
|
|
|
6409
6483
|
return ` "${routePath}": () =>
|
|
6410
6484
|
import("virtual:qui-demo-scope/page:${pageId}")`;
|
|
6411
6485
|
}).sort().join(",\n");
|
|
6412
|
-
return
|
|
6486
|
+
return dedent2`
|
|
6413
6487
|
/* eslint-disable */
|
|
6414
6488
|
|
|
6415
6489
|
// This file is generated automatically. Don't edit it directly.
|