@qualcomm-ui/mdx-vite 2.11.2 → 2.14.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 CHANGED
@@ -3559,6 +3559,9 @@ var knowledgeExportsSchema = implement().with({
3559
3559
  enabled: z2.boolean().optional(),
3560
3560
  exclude: z2.array(z2.string()).optional(),
3561
3561
  extraFiles: z2.array(knowledgeExtraFileSchema).optional(),
3562
+ generateBulkZip: z2.boolean().optional(),
3563
+ generateManifest: z2.boolean().optional(),
3564
+ manifestPath: z2.string().optional(),
3562
3565
  metadata: z2.record(z2.string(), z2.string()).optional(),
3563
3566
  pageTitlePrefix: z2.string().optional(),
3564
3567
  staticPath: z2.string().optional()
@@ -5710,8 +5713,10 @@ function addDownloadKnowledgeCommand() {
5710
5713
  }
5711
5714
 
5712
5715
  // src/open-web-ui-knowledge/generate-knowledge.ts
5716
+ import AdmZip from "adm-zip";
5713
5717
  import chalk3 from "chalk";
5714
5718
  import { minimatch } from "minimatch";
5719
+ import { createHash as createHash2 } from "node:crypto";
5715
5720
  import {
5716
5721
  access,
5717
5722
  mkdir as mkdir2,
@@ -5870,6 +5875,9 @@ function loadOpenWebUiIntegrations(options = {}) {
5870
5875
  async function exists(dirPath) {
5871
5876
  return access(dirPath).then(() => true).catch(() => false);
5872
5877
  }
5878
+ function computeMd5(content) {
5879
+ return createHash2("md5").update(content).digest("hex");
5880
+ }
5873
5881
  function extractBestType(propInfo) {
5874
5882
  const type = propInfo.resolvedType?.prettyType || propInfo.type;
5875
5883
  return cleanType(type.startsWith("| ") ? type.substring(2) : type);
@@ -6275,6 +6283,10 @@ ${codeText}
6275
6283
  const path = this.getAttrExpression(node, "data");
6276
6284
  return path && getPath(themes, path);
6277
6285
  },
6286
+ SpacingTable: (node) => {
6287
+ const path = this.getAttrExpression(node, "data");
6288
+ return path && getPath(themes, path);
6289
+ },
6278
6290
  ThemePropertyTable: (node) => {
6279
6291
  const path = this.getAttrExpression(node, "data");
6280
6292
  const property = this.getAttrExpression(node, "cssProperty");
@@ -6641,9 +6653,10 @@ ${propsToDefinitionList(outputs)}`);
6641
6653
  const start = performance.now();
6642
6654
  const extraFiles = this.config.extraFiles ?? [];
6643
6655
  if (extraFiles.length === 0) {
6644
- return { count: 0, duration: 0, totalSize: 0 };
6656
+ return { count: 0, duration: 0, entries: [], totalSize: 0 };
6645
6657
  }
6646
6658
  let totalSize = 0;
6659
+ const entries = [];
6647
6660
  await Promise.all(
6648
6661
  extraFiles.map(async (extraFile) => {
6649
6662
  let contents = extraFile.contents;
@@ -6666,15 +6679,25 @@ ${propsToDefinitionList(outputs)}`);
6666
6679
  }
6667
6680
  lines.push(contents);
6668
6681
  lines.push("");
6669
- const outfile = `${resolve4(this.config.outputPath)}/${kebabCase(extraFile.id)}.md`;
6670
- await writeFile3(outfile, lines.join("\n"), "utf-8");
6682
+ const fileContent = lines.join("\n");
6683
+ const fileName = `${kebabCase(extraFile.id)}.md`;
6684
+ const outfile = `${resolve4(this.config.outputPath)}/${fileName}`;
6685
+ await writeFile3(outfile, fileContent, "utf-8");
6671
6686
  const stats = await stat(outfile);
6672
6687
  totalSize += stats.size / 1024;
6688
+ entries.push({
6689
+ id: extraFile.id,
6690
+ md5: computeMd5(fileContent),
6691
+ path: fileName,
6692
+ size: stats.size,
6693
+ title: extraFile.title || extraFile.id
6694
+ });
6673
6695
  })
6674
6696
  );
6675
6697
  return {
6676
6698
  count: extraFiles.length,
6677
6699
  duration: performance.now() - start,
6700
+ entries,
6678
6701
  totalSize
6679
6702
  };
6680
6703
  }
@@ -6686,6 +6709,7 @@ ${propsToDefinitionList(outputs)}`);
6686
6709
  );
6687
6710
  const count = processedPages.length;
6688
6711
  let totalSize = 0;
6712
+ const manifestEntries = [];
6689
6713
  await Promise.all(
6690
6714
  processedPages.map(async (processedPage, index) => {
6691
6715
  const page = pages[index];
@@ -6780,17 +6804,79 @@ ${propsToDefinitionList(outputs)}`);
6780
6804
  }
6781
6805
  }
6782
6806
  }
6783
- const outfile = `${resolve4(this.config.outputPath)}/${kebabCase(page.id || page.name)}.md`;
6784
- await writeFile3(outfile, lines.join("\n"), "utf-8");
6807
+ const fileContent = lines.join("\n");
6808
+ const fileName = `${kebabCase(page.id || page.name)}.md`;
6809
+ const outfile = `${resolve4(this.config.outputPath)}/${fileName}`;
6810
+ await writeFile3(outfile, fileContent, "utf-8");
6785
6811
  const stats = await stat(outfile);
6786
6812
  totalSize += stats.size / 1024;
6813
+ manifestEntries.push({
6814
+ id: page.id || kebabCase(page.name),
6815
+ md5: computeMd5(fileContent),
6816
+ path: fileName,
6817
+ size: stats.size,
6818
+ title: processedPage.title,
6819
+ url: page.url
6820
+ });
6787
6821
  })
6788
6822
  );
6789
6823
  const extraFilesResult = await this.generateExtraFiles(metadata);
6824
+ manifestEntries.push(...extraFilesResult.entries);
6825
+ if (this.config.manifestOutputPath) {
6826
+ if (this.config.generateManifest !== false) {
6827
+ await this.generateManifest(
6828
+ this.config.manifestOutputPath,
6829
+ manifestEntries
6830
+ );
6831
+ }
6832
+ if (this.config.generateBulkZip !== false) {
6833
+ await this.generateBulkZip(
6834
+ this.config.manifestOutputPath,
6835
+ manifestEntries
6836
+ );
6837
+ }
6838
+ }
6790
6839
  console.log(
6791
6840
  `Generated ${count + extraFilesResult.count} files(s) in ${chalk3.magenta.bold(`${Math.round(performance.now() - start + extraFilesResult.duration)}ms`)} at ${chalk3.blue.bold(this.config.outputPath)} - ${(totalSize + extraFilesResult.totalSize).toFixed(1)} KB`
6792
6841
  );
6793
6842
  }
6843
+ computeAggregateHash(entries) {
6844
+ const sortedHashes = entries.map((e) => e.md5).sort().join("");
6845
+ return computeMd5(sortedHashes);
6846
+ }
6847
+ async generateManifest(outputPath, entries) {
6848
+ const aggregateHash = this.computeAggregateHash(entries);
6849
+ const totalSize = entries.reduce((sum, e) => sum + e.size, 0);
6850
+ const manifest = {
6851
+ aggregateHash,
6852
+ baseUrl: this.config.baseUrl,
6853
+ files: entries,
6854
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
6855
+ totalFiles: entries.length,
6856
+ totalSize,
6857
+ version: 1
6858
+ };
6859
+ await mkdir2(outputPath, { recursive: true }).catch(() => {
6860
+ });
6861
+ await writeFile3(
6862
+ join3(outputPath, "manifest.json"),
6863
+ JSON.stringify(manifest, null, 2),
6864
+ "utf-8"
6865
+ );
6866
+ return manifest;
6867
+ }
6868
+ async generateBulkZip(outputPath, entries) {
6869
+ await mkdir2(outputPath, { recursive: true }).catch(() => {
6870
+ });
6871
+ const zipPath = join3(outputPath, "bulk.zip");
6872
+ const zip = new AdmZip();
6873
+ for (const entry of entries) {
6874
+ const filePath = join3(this.config.outputPath, entry.path);
6875
+ const content = await readFile(filePath);
6876
+ zip.addFile(entry.path, content);
6877
+ }
6878
+ zip.writeZip(zipPath);
6879
+ }
6794
6880
  };
6795
6881
  async function generate(config2) {
6796
6882
  const generator = new KnowledgeGenerator(config2);
@@ -6833,7 +6919,7 @@ Generated knowledge for ${configs.length} environment(s)`
6833
6919
  }
6834
6920
 
6835
6921
  // src/open-web-ui-knowledge/upload-knowledge.ts
6836
- import { createHash as createHash2 } from "node:crypto";
6922
+ import { createHash as createHash3 } from "node:crypto";
6837
6923
  import { writeFileSync } from "node:fs";
6838
6924
  import { access as access2, readdir as readdir2, readFile as readFile2, stat as stat2 } from "node:fs/promises";
6839
6925
  import { resolve as resolve5 } from "node:path";
@@ -6876,7 +6962,7 @@ function toKnowledgeFile(file) {
6876
6962
  }
6877
6963
  function calculateFileHash(fileData) {
6878
6964
  const normalized = fileData.normalize("NFC").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n+$/, "");
6879
- return createHash2("sha256").update(normalized).digest("hex");
6965
+ return createHash3("sha256").update(normalized).digest("hex");
6880
6966
  }
6881
6967
  var Uploader = class {
6882
6968
  config;