@qualcomm-ui/mdx-vite 2.11.1 → 2.12.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);
@@ -6641,9 +6649,10 @@ ${propsToDefinitionList(outputs)}`);
6641
6649
  const start = performance.now();
6642
6650
  const extraFiles = this.config.extraFiles ?? [];
6643
6651
  if (extraFiles.length === 0) {
6644
- return { count: 0, duration: 0, totalSize: 0 };
6652
+ return { count: 0, duration: 0, entries: [], totalSize: 0 };
6645
6653
  }
6646
6654
  let totalSize = 0;
6655
+ const entries = [];
6647
6656
  await Promise.all(
6648
6657
  extraFiles.map(async (extraFile) => {
6649
6658
  let contents = extraFile.contents;
@@ -6666,15 +6675,25 @@ ${propsToDefinitionList(outputs)}`);
6666
6675
  }
6667
6676
  lines.push(contents);
6668
6677
  lines.push("");
6669
- const outfile = `${resolve4(this.config.outputPath)}/${kebabCase(extraFile.id)}.md`;
6670
- await writeFile3(outfile, lines.join("\n"), "utf-8");
6678
+ const fileContent = lines.join("\n");
6679
+ const fileName = `${kebabCase(extraFile.id)}.md`;
6680
+ const outfile = `${resolve4(this.config.outputPath)}/${fileName}`;
6681
+ await writeFile3(outfile, fileContent, "utf-8");
6671
6682
  const stats = await stat(outfile);
6672
6683
  totalSize += stats.size / 1024;
6684
+ entries.push({
6685
+ id: extraFile.id,
6686
+ md5: computeMd5(fileContent),
6687
+ path: fileName,
6688
+ size: stats.size,
6689
+ title: extraFile.title || extraFile.id
6690
+ });
6673
6691
  })
6674
6692
  );
6675
6693
  return {
6676
6694
  count: extraFiles.length,
6677
6695
  duration: performance.now() - start,
6696
+ entries,
6678
6697
  totalSize
6679
6698
  };
6680
6699
  }
@@ -6686,6 +6705,7 @@ ${propsToDefinitionList(outputs)}`);
6686
6705
  );
6687
6706
  const count = processedPages.length;
6688
6707
  let totalSize = 0;
6708
+ const manifestEntries = [];
6689
6709
  await Promise.all(
6690
6710
  processedPages.map(async (processedPage, index) => {
6691
6711
  const page = pages[index];
@@ -6780,17 +6800,79 @@ ${propsToDefinitionList(outputs)}`);
6780
6800
  }
6781
6801
  }
6782
6802
  }
6783
- const outfile = `${resolve4(this.config.outputPath)}/${kebabCase(page.id || page.name)}.md`;
6784
- await writeFile3(outfile, lines.join("\n"), "utf-8");
6803
+ const fileContent = lines.join("\n");
6804
+ const fileName = `${kebabCase(page.id || page.name)}.md`;
6805
+ const outfile = `${resolve4(this.config.outputPath)}/${fileName}`;
6806
+ await writeFile3(outfile, fileContent, "utf-8");
6785
6807
  const stats = await stat(outfile);
6786
6808
  totalSize += stats.size / 1024;
6809
+ manifestEntries.push({
6810
+ id: page.id || kebabCase(page.name),
6811
+ md5: computeMd5(fileContent),
6812
+ path: fileName,
6813
+ size: stats.size,
6814
+ title: processedPage.title,
6815
+ url: page.url
6816
+ });
6787
6817
  })
6788
6818
  );
6789
6819
  const extraFilesResult = await this.generateExtraFiles(metadata);
6820
+ manifestEntries.push(...extraFilesResult.entries);
6821
+ if (this.config.manifestOutputPath) {
6822
+ if (this.config.generateManifest !== false) {
6823
+ await this.generateManifest(
6824
+ this.config.manifestOutputPath,
6825
+ manifestEntries
6826
+ );
6827
+ }
6828
+ if (this.config.generateBulkZip !== false) {
6829
+ await this.generateBulkZip(
6830
+ this.config.manifestOutputPath,
6831
+ manifestEntries
6832
+ );
6833
+ }
6834
+ }
6790
6835
  console.log(
6791
6836
  `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
6837
  );
6793
6838
  }
6839
+ computeAggregateHash(entries) {
6840
+ const sortedHashes = entries.map((e) => e.md5).sort().join("");
6841
+ return computeMd5(sortedHashes);
6842
+ }
6843
+ async generateManifest(outputPath, entries) {
6844
+ const aggregateHash = this.computeAggregateHash(entries);
6845
+ const totalSize = entries.reduce((sum, e) => sum + e.size, 0);
6846
+ const manifest = {
6847
+ aggregateHash,
6848
+ baseUrl: this.config.baseUrl,
6849
+ files: entries,
6850
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
6851
+ totalFiles: entries.length,
6852
+ totalSize,
6853
+ version: 1
6854
+ };
6855
+ await mkdir2(outputPath, { recursive: true }).catch(() => {
6856
+ });
6857
+ await writeFile3(
6858
+ join3(outputPath, "manifest.json"),
6859
+ JSON.stringify(manifest, null, 2),
6860
+ "utf-8"
6861
+ );
6862
+ return manifest;
6863
+ }
6864
+ async generateBulkZip(outputPath, entries) {
6865
+ await mkdir2(outputPath, { recursive: true }).catch(() => {
6866
+ });
6867
+ const zipPath = join3(outputPath, "bulk.zip");
6868
+ const zip = new AdmZip();
6869
+ for (const entry of entries) {
6870
+ const filePath = join3(this.config.outputPath, entry.path);
6871
+ const content = await readFile(filePath);
6872
+ zip.addFile(entry.path, content);
6873
+ }
6874
+ zip.writeZip(zipPath);
6875
+ }
6794
6876
  };
6795
6877
  async function generate(config2) {
6796
6878
  const generator = new KnowledgeGenerator(config2);
@@ -6833,7 +6915,7 @@ Generated knowledge for ${configs.length} environment(s)`
6833
6915
  }
6834
6916
 
6835
6917
  // src/open-web-ui-knowledge/upload-knowledge.ts
6836
- import { createHash as createHash2 } from "node:crypto";
6918
+ import { createHash as createHash3 } from "node:crypto";
6837
6919
  import { writeFileSync } from "node:fs";
6838
6920
  import { access as access2, readdir as readdir2, readFile as readFile2, stat as stat2 } from "node:fs/promises";
6839
6921
  import { resolve as resolve5 } from "node:path";
@@ -6876,7 +6958,7 @@ function toKnowledgeFile(file) {
6876
6958
  }
6877
6959
  function calculateFileHash(fileData) {
6878
6960
  const normalized = fileData.normalize("NFC").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n+$/, "");
6879
- return createHash2("sha256").update(normalized).digest("hex");
6961
+ return createHash3("sha256").update(normalized).digest("hex");
6880
6962
  }
6881
6963
  var Uploader = class {
6882
6964
  config;