@qualcomm-ui/mdx-vite 2.0.0 → 2.1.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.
Files changed (29) hide show
  1. package/dist/cli.js +64 -20
  2. package/dist/cli.js.map +2 -2
  3. package/dist/docs-plugin/docs-plugin.d.ts.map +1 -1
  4. package/dist/docs-plugin/internal/search-indexer.d.ts +2 -2
  5. package/dist/docs-plugin/internal/search-indexer.d.ts.map +1 -1
  6. package/dist/docs-plugin/internal/services/markdown/markdown-file-reader.d.ts +1 -0
  7. package/dist/docs-plugin/internal/services/markdown/markdown-file-reader.d.ts.map +1 -1
  8. package/dist/docs-plugin/internal/services/markdown/markdown.types.d.ts +17 -1
  9. package/dist/docs-plugin/internal/services/markdown/markdown.types.d.ts.map +1 -1
  10. package/dist/docs-plugin/internal/services/nav-builder/nav-builder.d.ts.map +1 -1
  11. package/dist/docs-plugin/internal/services/nav-builder/page-map.d.ts.map +1 -1
  12. package/dist/docs-plugin/mdx-plugins.d.ts +2 -0
  13. package/dist/docs-plugin/mdx-plugins.d.ts.map +1 -1
  14. package/dist/docs-plugin/remark/remark-code-tabs.d.ts +16 -0
  15. package/dist/docs-plugin/remark/remark-code-tabs.d.ts.map +1 -1
  16. package/dist/docs-plugin/shiki/index.d.ts +3 -0
  17. package/dist/docs-plugin/shiki/index.d.ts.map +1 -0
  18. package/dist/docs-plugin/shiki/shiki-transformer-code-attribute.d.ts +20 -0
  19. package/dist/docs-plugin/shiki/shiki-transformer-code-attribute.d.ts.map +1 -0
  20. package/dist/docs-plugin/shiki/shiki-transformer-preview-block.d.ts +7 -0
  21. package/dist/docs-plugin/shiki/shiki-transformer-preview-block.d.ts.map +1 -0
  22. package/dist/docs-plugin/shiki/utils.d.ts +2 -0
  23. package/dist/docs-plugin/shiki/utils.d.ts.map +1 -0
  24. package/dist/index.js +154 -35
  25. package/dist/index.js.map +4 -4
  26. package/dist/open-web-ui-knowledge/generate-knowledge.d.ts.map +1 -1
  27. package/dist/react-demo-plugin/react-demo-plugin.d.ts.map +1 -1
  28. package/dist/tsbuildinfo +1 -1
  29. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3882,12 +3882,15 @@ var MarkdownFileReader = class {
3882
3882
  reset() {
3883
3883
  this.cachedFileCount = 0;
3884
3884
  }
3885
- checkCache(filepath, fileContents) {
3885
+ readCache(filePath) {
3886
+ return this.mdxCache[filePath] || null;
3887
+ }
3888
+ checkCache(filePath, fileContents) {
3886
3889
  if (!this.enabled) {
3887
3890
  return;
3888
3891
  }
3889
3892
  const fileMd5 = this.hash(fileContents);
3890
- const cached = this.mdxCache[filepath];
3893
+ const cached = this.mdxCache[filePath];
3891
3894
  if (cached?.md5 !== fileMd5) {
3892
3895
  return;
3893
3896
  }
@@ -4408,9 +4411,9 @@ function getRouteMeta(pathSegments, metaJson) {
4408
4411
  }
4409
4412
 
4410
4413
  // src/docs-plugin/internal/services/nav-builder/nav-builder.ts
4411
- import { capitalCase } from "change-case";
4412
4414
  import { sortBy } from "lodash-es";
4413
4415
  import { v4 as uuidv4 } from "uuid";
4416
+ import { capitalCase } from "@qualcomm-ui/utils/change-case";
4414
4417
  var NavBuilder = class {
4415
4418
  initialRoutes = [];
4416
4419
  flatNavItems = [];
@@ -4695,8 +4698,8 @@ var NavBuilder = class {
4695
4698
  };
4696
4699
 
4697
4700
  // src/docs-plugin/internal/services/nav-builder/page-map.ts
4698
- import { capitalCase as capitalCase2 } from "change-case";
4699
4701
  import { join } from "node:path";
4702
+ import { capitalCase as capitalCase2 } from "@qualcomm-ui/utils/change-case";
4700
4703
  function getPathnameFromPathSegments(segments) {
4701
4704
  return `/${segments.join("/")}`;
4702
4705
  }
@@ -4966,11 +4969,25 @@ var SearchIndexer = class {
4966
4969
  * Parses an MDX file to extract the site data for the nav items, doc props,
4967
4970
  * breadcrumbs, and search index.
4968
4971
  */
4969
- compileMdxFile(filepath) {
4970
- const { cached, fileContents, frontmatter } = this.fileCache.readFile(filepath);
4972
+ compileMdxFile(filePath) {
4973
+ const { cached, fileContents, frontmatter } = this.fileCache.readFile(filePath);
4974
+ const metadata = {
4975
+ changed: {},
4976
+ filePath
4977
+ };
4978
+ if (!cached) {
4979
+ const previousData = this.fileCache.readCache(filePath);
4980
+ if (previousData) {
4981
+ const cachedFm = JSON.stringify(previousData.frontmatter);
4982
+ const currentFm = JSON.stringify(frontmatter);
4983
+ if (cachedFm !== currentFm) {
4984
+ metadata.changed.frontmatter = true;
4985
+ }
4986
+ }
4987
+ }
4971
4988
  this.docPropsIndexer.reset();
4972
4989
  this.markdownIndexer.reset();
4973
- const defaultSection = this.getPageEntry(filepath, frontmatter);
4990
+ const defaultSection = this.getPageEntry(filePath, frontmatter);
4974
4991
  if (!defaultSection.categories.length && defaultSection.title) {
4975
4992
  defaultSection.categories = [defaultSection.title];
4976
4993
  }
@@ -4985,9 +5002,9 @@ var SearchIndexer = class {
4985
5002
  console.debug(
4986
5003
  `${chalk2.yellowBright.bold(
4987
5004
  "Failed to parse mdx page content."
4988
- )} ${chalk2.blueBright.bold(filepath)}`
5005
+ )} ${chalk2.blueBright.bold(filePath)}`
4989
5006
  );
4990
- return [defaultSection];
5007
+ return { metadata, pageSections: [defaultSection] };
4991
5008
  }
4992
5009
  const { sections, toc } = indexedPage;
4993
5010
  if (toc.length) {
@@ -5002,17 +5019,17 @@ var SearchIndexer = class {
5002
5019
  if (docPropSections.length) {
5003
5020
  this._pageDocProps[defaultSection.pathname] = docProps;
5004
5021
  }
5005
- this.fileCache.updateCache(filepath, fileContents, {
5022
+ this.fileCache.updateCache(filePath, fileContents, {
5006
5023
  frontmatter,
5007
5024
  page: indexedPage,
5008
5025
  pageDocProps: docProps,
5009
5026
  pageDocPropSections: docPropSections
5010
5027
  });
5011
5028
  if (frontmatter.hideFromSearch) {
5012
- return [defaultSection];
5029
+ return { metadata, pageSections: [defaultSection] };
5013
5030
  }
5014
5031
  if (!sections.length && !docPropSections.length) {
5015
- return [defaultSection];
5032
+ return { metadata, pageSections: [defaultSection] };
5016
5033
  }
5017
5034
  const sectionReturn = [
5018
5035
  ...this.formatSections(sections, defaultSection, false)
@@ -5022,7 +5039,7 @@ var SearchIndexer = class {
5022
5039
  ...this.formatSections(docPropSections, defaultSection, true)
5023
5040
  );
5024
5041
  }
5025
- return sectionReturn;
5042
+ return { metadata, pageSections: sectionReturn };
5026
5043
  }
5027
5044
  formatSections(sections, { toc: _toc, ...defaultSection }, isDocProp) {
5028
5045
  return sections.map((section, index) => {
@@ -5067,7 +5084,8 @@ var SearchIndexer = class {
5067
5084
  this.config.routingStrategy
5068
5085
  );
5069
5086
  this._mdxFileCount = mdxFileGlob.length;
5070
- const mdxIndex = mdxFileGlob.map((file) => this.compileMdxFile(file)).flat();
5087
+ const compiledFiles = mdxFileGlob.map((file) => this.compileMdxFile(file));
5088
+ const mdxIndex = compiledFiles.map((fileData) => fileData.pageSections).flat();
5071
5089
  filterFileGlob(
5072
5090
  fileGlob,
5073
5091
  "tsx",
@@ -5076,6 +5094,7 @@ var SearchIndexer = class {
5076
5094
  ).map((file) => this.compileTsxFile(file));
5077
5095
  this._searchIndex.push(...mdxIndex.filter((entry) => !entry.hideFromSearch));
5078
5096
  this.navBuilder.build();
5097
+ return compiledFiles;
5079
5098
  }
5080
5099
  };
5081
5100
 
@@ -5271,7 +5290,6 @@ function addDownloadKnowledgeCommand() {
5271
5290
  }
5272
5291
 
5273
5292
  // src/open-web-ui-knowledge/generate-knowledge.ts
5274
- import { kebabCase } from "change-case";
5275
5293
  import {
5276
5294
  access,
5277
5295
  mkdir as mkdir2,
@@ -5287,6 +5305,7 @@ import remarkParse4 from "remark-parse";
5287
5305
  import remarkParseFrontmatter2 from "remark-parse-frontmatter";
5288
5306
  import remarkStringify3 from "remark-stringify";
5289
5307
  import { unified as unified4 } from "unified";
5308
+ import { kebabCase } from "@qualcomm-ui/utils/change-case";
5290
5309
 
5291
5310
  // src/docs-plugin/docs-plugin.ts
5292
5311
  import chalk3 from "chalk";
@@ -5320,6 +5339,14 @@ var PluginState = class {
5320
5339
  this.docPropsFilePath.lastIndexOf("/")
5321
5340
  );
5322
5341
  }
5342
+ get siteData() {
5343
+ return {
5344
+ navItems: state.indexer.navItems,
5345
+ pageDocProps: state.indexer.pageDocProps,
5346
+ pageMap: state.indexer.pageMap,
5347
+ searchIndex: state.indexer.searchIndex
5348
+ };
5349
+ }
5323
5350
  resolveDocProps() {
5324
5351
  if (!this.docPropsFilePath) {
5325
5352
  return {};
@@ -5352,15 +5379,16 @@ var PluginState = class {
5352
5379
  }
5353
5380
  );
5354
5381
  if (!files.length) {
5355
- return;
5382
+ return [];
5356
5383
  }
5357
5384
  const startTime = Date.now();
5358
- this.indexer.buildIndex(files, shouldLog);
5385
+ const compiledMdxFiles = this.indexer.buildIndex(files, shouldLog);
5359
5386
  if (isDev && shouldLog) {
5360
5387
  console.debug(
5361
5388
  `${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)`) : ""}`
5362
5389
  );
5363
5390
  }
5391
+ return compiledMdxFiles;
5364
5392
  }
5365
5393
  /**
5366
5394
  * When the user adds or removes mdx files, we re-index the site. This function
@@ -5404,7 +5432,13 @@ var PluginState = class {
5404
5432
  const resolvedConfig = this.configLoader.loadConfig();
5405
5433
  this.configFilePath = resolvedConfig.filePath;
5406
5434
  this.createIndexer(resolvedConfig);
5407
- this.handleChange();
5435
+ this.handleChange({
5436
+ onComplete: () => {
5437
+ this.servers.forEach(
5438
+ (server) => server.ws.send({ type: "full-reload" })
5439
+ );
5440
+ }
5441
+ });
5408
5442
  });
5409
5443
  }
5410
5444
  };
@@ -5412,6 +5446,16 @@ var state = new PluginState();
5412
5446
 
5413
5447
  // src/docs-plugin/mdx-plugins.ts
5414
5448
  import rehypeShiki from "@shikijs/rehype";
5449
+ import {
5450
+ transformerNotationDiff,
5451
+ transformerNotationErrorLevel,
5452
+ transformerNotationFocus,
5453
+ transformerNotationHighlight,
5454
+ transformerNotationWordHighlight,
5455
+ transformerRemoveNotationEscape,
5456
+ transformerRenderIndentGuides
5457
+ } from "@shikijs/transformers";
5458
+ import { merge } from "lodash-es";
5415
5459
  import { quiCustomDarkTheme } from "@qualcomm-ui/mdx-common";
5416
5460
 
5417
5461
  // src/exports.ts
@@ -5844,10 +5888,10 @@ ${JSON.stringify(propsDoc, null, 2)}
5844
5888
  } else {
5845
5889
  processedContent = processedContent.replace(/<TypeDocProps\s+[^>]*\/>/g, "");
5846
5890
  }
5847
- let demoRegex = /<(?:QdsDemo|CodeDemo)\s+[^>]*name="(\w+)"[^>]*\/>/g;
5891
+ let demoRegex = /<(?:QdsDemo|CodeDemo|Demo)\s+[^>]*name="(\w+)"[^>]*\/>/g;
5848
5892
  let demoMatches = Array.from(processedContent.matchAll(demoRegex));
5849
5893
  if (!demoMatches.length) {
5850
- demoRegex = /<(?:QdsDemo|CodeDemo)\s+[^>]*node=\{Demo\.(\w+)\}[^>]*\/>/g;
5894
+ demoRegex = /<(?:QdsDemo|CodeDemo|Demo)\s+[^>]*node=\{Demo\.(\w+)\}[^>]*\/>/g;
5851
5895
  demoMatches = Array.from(processedContent.matchAll(demoRegex));
5852
5896
  }
5853
5897
  const replacements = await Promise.all(