@mui/internal-docs-infra 0.2.3-canary.9 → 0.3.1-canary.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 (144) hide show
  1. package/README.md +3 -2
  2. package/esm/CodeHighlighter/CodeHighlighter.js +16 -16
  3. package/esm/CodeHighlighter/CodeHighlighterClient.js +33 -33
  4. package/esm/CodeHighlighter/errors.js +3 -3
  5. package/esm/CodeHighlighter/types.d.ts +1 -1
  6. package/esm/CodeProvider/CodeContext.d.ts +4 -4
  7. package/esm/CodeProvider/CodeProvider.js +7 -7
  8. package/esm/cli/index.d.ts +1 -0
  9. package/esm/cli/index.js +6 -0
  10. package/esm/cli/runValidate.d.ts +8 -0
  11. package/esm/cli/runValidate.js +297 -0
  12. package/esm/createSitemap/createSitemap.d.ts +23 -0
  13. package/esm/createSitemap/createSitemap.js +45 -0
  14. package/esm/createSitemap/index.d.ts +1 -0
  15. package/esm/createSitemap/index.js +1 -0
  16. package/esm/createSitemap/types.d.ts +68 -0
  17. package/esm/createSitemap/types.js +1 -0
  18. package/esm/pipeline/getFileConventions/fileConventions.d.ts +4 -0
  19. package/esm/pipeline/getFileConventions/fileConventions.js +4 -0
  20. package/esm/pipeline/getFileConventions/getFileConventions.d.ts +4 -0
  21. package/esm/pipeline/getFileConventions/getFileConventions.js +17 -0
  22. package/esm/pipeline/getFileConventions/index.d.ts +1 -0
  23. package/esm/pipeline/getFileConventions/index.js +1 -0
  24. package/esm/{CodeHighlighter/addPathsToVariant.d.ts → pipeline/loadCodeVariant/addCodeVariantPaths.d.ts} +1 -1
  25. package/esm/{CodeHighlighter/applyTransform.d.ts → pipeline/loadCodeVariant/applyCodeTransform.d.ts} +3 -3
  26. package/esm/{CodeHighlighter/applyTransform.js → pipeline/loadCodeVariant/applyCodeTransform.js} +4 -4
  27. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.js +1 -1
  28. package/esm/{CodeHighlighter/transformCode.d.ts → pipeline/loadCodeVariant/computeHastDeltas.d.ts} +9 -5
  29. package/esm/{CodeHighlighter/transformCode.js → pipeline/loadCodeVariant/computeHastDeltas.js} +20 -16
  30. package/esm/pipeline/loadCodeVariant/diffHast.d.ts +3 -0
  31. package/esm/{CodeHighlighter/transformParsedSource.js → pipeline/loadCodeVariant/diffHast.js} +5 -5
  32. package/esm/{CodeHighlighter/examineVariant.d.ts → pipeline/loadCodeVariant/examineCodeVariant.d.ts} +2 -2
  33. package/esm/{CodeHighlighter/examineVariant.js → pipeline/loadCodeVariant/examineCodeVariant.js} +1 -1
  34. package/esm/{useDemo/flattenVariant.d.ts → pipeline/loadCodeVariant/flattenCodeVariant.d.ts} +2 -2
  35. package/esm/{useDemo/flattenVariant.js → pipeline/loadCodeVariant/flattenCodeVariant.js} +3 -3
  36. package/esm/{CodeHighlighter/hasAllVariants.d.ts → pipeline/loadCodeVariant/hasAllCodeVariants.d.ts} +1 -1
  37. package/esm/pipeline/loadCodeVariant/index.d.ts +10 -0
  38. package/esm/pipeline/loadCodeVariant/index.js +17 -0
  39. package/esm/{CodeHighlighter/loadFallbackCode.d.ts → pipeline/loadCodeVariant/loadCodeFallback.d.ts} +2 -2
  40. package/esm/{CodeHighlighter/loadFallbackCode.js → pipeline/loadCodeVariant/loadCodeFallback.js} +180 -106
  41. package/esm/{CodeHighlighter/loadVariant.d.ts → pipeline/loadCodeVariant/loadCodeVariant.d.ts} +2 -2
  42. package/esm/{CodeHighlighter/loadVariant.js → pipeline/loadCodeVariant/loadCodeVariant.js} +122 -49
  43. package/esm/{CodeHighlighter/maybeInitialData.d.ts → pipeline/loadCodeVariant/maybeCodeInitialData.d.ts} +6 -6
  44. package/esm/{CodeHighlighter/maybeInitialData.js → pipeline/loadCodeVariant/maybeCodeInitialData.js} +6 -6
  45. package/esm/{CodeHighlighter/mergeMetadata.d.ts → pipeline/loadCodeVariant/mergeCodeMetadata.d.ts} +3 -3
  46. package/esm/{CodeHighlighter/mergeMetadata.js → pipeline/loadCodeVariant/mergeCodeMetadata.js} +3 -3
  47. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.d.ts +1 -1
  48. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.d.ts +1 -1
  49. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +5 -0
  50. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +86 -13
  51. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
  52. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
  53. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +7 -7
  54. package/esm/pipeline/loadPrecomputedSitemap/index.d.ts +2 -0
  55. package/esm/pipeline/loadPrecomputedSitemap/index.js +4 -0
  56. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.d.ts +10 -0
  57. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +213 -0
  58. package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
  59. package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
  60. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
  61. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +2 -2
  62. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +1 -1
  63. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +1 -1
  64. package/esm/pipeline/loadServerPageIndex/index.d.ts +2 -0
  65. package/esm/pipeline/loadServerPageIndex/index.js +1 -0
  66. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.d.ts +51 -0
  67. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +174 -0
  68. package/esm/pipeline/loadServerSitemap/index.d.ts +2 -0
  69. package/esm/pipeline/loadServerSitemap/index.js +1 -0
  70. package/esm/pipeline/loadServerSitemap/loadServerSitemap.d.ts +39 -0
  71. package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +168 -0
  72. package/esm/pipeline/loadServerSource/loadServerSource.js +1 -1
  73. package/esm/pipeline/loaderUtils/externalsToPackages.js +1 -1
  74. package/esm/pipeline/loaderUtils/processRelativeImports.js +16 -3
  75. package/esm/pipeline/loaderUtils/rewriteImports.d.ts +36 -0
  76. package/esm/pipeline/loaderUtils/rewriteImports.js +139 -8
  77. package/esm/pipeline/syncPageIndex/createMarkdownNodes.d.ts +76 -0
  78. package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +305 -0
  79. package/esm/pipeline/syncPageIndex/index.d.ts +1 -0
  80. package/esm/pipeline/syncPageIndex/index.js +1 -0
  81. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.d.ts +58 -0
  82. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +214 -0
  83. package/esm/pipeline/syncPageIndex/metadataToMarkdown.d.ts +67 -0
  84. package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +1486 -0
  85. package/esm/pipeline/syncPageIndex/syncPageIndex.d.ts +108 -0
  86. package/esm/pipeline/syncPageIndex/syncPageIndex.js +540 -0
  87. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
  88. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
  89. package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.d.ts +2 -0
  90. package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.js +4 -0
  91. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts +16 -0
  92. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +58 -0
  93. package/esm/pipeline/transformMarkdownDemoLinks/index.d.ts +2 -0
  94. package/esm/pipeline/transformMarkdownDemoLinks/index.js +4 -0
  95. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.d.ts +26 -0
  96. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +107 -0
  97. package/esm/pipeline/transformMarkdownMetadata/index.d.ts +2 -0
  98. package/esm/pipeline/transformMarkdownMetadata/index.js +4 -0
  99. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.d.ts +3 -0
  100. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +1010 -0
  101. package/esm/pipeline/transformMarkdownMetadata/types.d.ts +110 -0
  102. package/esm/pipeline/transformMarkdownMetadata/types.js +1 -0
  103. package/esm/pipeline/transformMarkdownRelativePaths/index.d.ts +2 -0
  104. package/esm/pipeline/transformMarkdownRelativePaths/index.js +4 -0
  105. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.d.ts +15 -0
  106. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +40 -0
  107. package/esm/useCode/Pre.js +15 -2
  108. package/esm/useCode/useCode.d.ts +15 -2
  109. package/esm/useCode/useCode.js +15 -6
  110. package/esm/useCode/useCodeUtils.js +3 -3
  111. package/esm/useCode/useFileNavigation.d.ts +9 -3
  112. package/esm/useCode/useFileNavigation.js +124 -81
  113. package/esm/useCode/useUIState.d.ts +4 -1
  114. package/esm/useCode/useUIState.js +17 -2
  115. package/esm/useCode/useVariantSelection.d.ts +8 -3
  116. package/esm/useCode/useVariantSelection.js +144 -52
  117. package/esm/useCopier/index.js +5 -4
  118. package/esm/useDemo/createCodeSandbox.d.ts +1 -1
  119. package/esm/useDemo/createStackBlitz.d.ts +1 -1
  120. package/esm/useDemo/exportVariant.js +13 -11
  121. package/esm/useDemo/index.d.ts +1 -1
  122. package/esm/useDemo/index.js +1 -1
  123. package/esm/useDemo/useDemo.d.ts +5 -5
  124. package/esm/useDemo/useDemo.js +6 -6
  125. package/esm/useErrors/useErrors.d.ts +1 -1
  126. package/esm/useErrors/useErrors.js +6 -2
  127. package/esm/useSearch/index.d.ts +1 -0
  128. package/esm/useSearch/index.js +1 -0
  129. package/esm/useSearch/types.d.ts +165 -0
  130. package/esm/useSearch/types.js +1 -0
  131. package/esm/useSearch/useSearch.d.ts +56 -0
  132. package/esm/useSearch/useSearch.js +647 -0
  133. package/esm/withDocsInfra/withDeploymentConfig.js +4 -2
  134. package/esm/withDocsInfra/withDocsInfra.d.ts +39 -0
  135. package/esm/withDocsInfra/withDocsInfra.js +79 -7
  136. package/package.json +105 -5
  137. package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
  138. /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
  139. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
  140. /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
  141. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
  142. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
  143. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
  144. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.js +0 -0
@@ -9,9 +9,10 @@ import * as path from 'path-module';
9
9
  import { compress, strToU8 } from 'fflate';
10
10
  import { encode } from 'uint8-to-base64';
11
11
  import { transformSource } from "./transformSource.js";
12
- import { transformParsedSource } from "./transformParsedSource.js";
13
- import { getFileNameFromUrl } from "../pipeline/loaderUtils/index.js";
14
- import { mergeExternals } from "../pipeline/loaderUtils/mergeExternals.js";
12
+ import { diffHast } from "./diffHast.js";
13
+ import { getFileNameFromUrl } from "../loaderUtils/index.js";
14
+ import { mergeExternals } from "../loaderUtils/mergeExternals.js";
15
+ import { performanceMeasure } from "../loadPrecomputedCodeHighlighter/performanceLogger.js";
15
16
  function compressAsync(input) {
16
17
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17
18
  return new Promise(function (resolve, reject) {
@@ -138,6 +139,8 @@ function _loadSingleFile() {
138
139
  extraFilesFromSource,
139
140
  extraDependenciesFromSource,
140
141
  externalsFromSource,
142
+ functionName,
143
+ currentMark,
141
144
  loadPromise,
142
145
  loadResult,
143
146
  _i,
@@ -170,6 +173,11 @@ function _loadSingleFile() {
170
173
  knownExtraFiles = _args.length > 11 && _args[11] !== undefined ? _args[11] : new Set();
171
174
  _options$disableTrans = options.disableTransforms, disableTransforms = _options$disableTrans === void 0 ? false : _options$disableTrans, _options$disableParsi = options.disableParsing, disableParsing = _options$disableParsi === void 0 ? false : _options$disableParsi;
172
175
  finalSource = source;
176
+ functionName = 'Load Variant File';
177
+ currentMark = performanceMeasure(undefined, {
178
+ mark: 'Start',
179
+ measure: 'Start'
180
+ }, [functionName, url || fileName], true); // Load source if not provided
173
181
  if (finalSource) {
174
182
  _context.n = 20;
175
183
  break;
@@ -201,6 +209,10 @@ function _loadSingleFile() {
201
209
  extraFilesFromSource = loadResult.extraFiles;
202
210
  extraDependenciesFromSource = loadResult.extraDependencies;
203
211
  externalsFromSource = loadResult.externals;
212
+ currentMark = performanceMeasure(currentMark, {
213
+ mark: 'Loaded File',
214
+ measure: 'File Loading'
215
+ }, [functionName, url]);
204
216
 
205
217
  // Validate that extraFiles from loadSource contain only absolute URLs as values
206
218
  if (!extraFilesFromSource) {
@@ -321,6 +333,10 @@ function _loadSingleFile() {
321
333
  return transformSource(finalSource, normalizePathKey(fileName), sourceTransformers);
322
334
  case 21:
323
335
  finalTransforms = _context.v;
336
+ currentMark = performanceMeasure(currentMark, {
337
+ mark: 'Transformed File',
338
+ measure: 'File Transforming'
339
+ }, [functionName, url || fileName]);
324
340
  case 22:
325
341
  if (!(typeof finalSource === 'string' && !disableParsing)) {
326
342
  _context.n = 31;
@@ -339,14 +355,22 @@ function _loadSingleFile() {
339
355
  case 24:
340
356
  parseSource = _context.v;
341
357
  finalSource = parseSource(finalSource, fileName);
358
+ currentMark = performanceMeasure(currentMark, {
359
+ mark: 'Parsed File',
360
+ measure: 'File Parsing'
361
+ }, [functionName, url || fileName]);
342
362
  if (!(finalTransforms && !disableTransforms)) {
343
363
  _context.n = 26;
344
364
  break;
345
365
  }
346
366
  _context.n = 25;
347
- return transformParsedSource(sourceString, finalSource, normalizePathKey(fileName), finalTransforms, parseSource);
367
+ return diffHast(sourceString, finalSource, normalizePathKey(fileName), finalTransforms, parseSource);
348
368
  case 25:
349
369
  finalTransforms = _context.v;
370
+ currentMark = performanceMeasure(currentMark, {
371
+ mark: 'Transform Parsed File',
372
+ measure: 'Parsed File Transforming'
373
+ }, [functionName, url || fileName]);
350
374
  case 26:
351
375
  if (!(options.output === 'hastGzip' && process.env.NODE_ENV === 'production')) {
352
376
  _context.n = 28;
@@ -363,6 +387,10 @@ function _loadSingleFile() {
363
387
  finalSource = {
364
388
  hastGzip: hastGzip
365
389
  };
390
+ currentMark = performanceMeasure(currentMark, {
391
+ mark: 'Compressed File',
392
+ measure: 'File Compression'
393
+ }, [functionName, url || fileName]);
366
394
  _context.n = 29;
367
395
  break;
368
396
  case 28:
@@ -371,6 +399,10 @@ function _loadSingleFile() {
371
399
  finalSource = {
372
400
  hastJson: JSON.stringify(finalSource)
373
401
  };
402
+ performanceMeasure(currentMark, {
403
+ mark: 'JSON Stringified File',
404
+ measure: 'File Stringification'
405
+ }, [functionName, url || fileName]);
374
406
  }
375
407
  case 29:
376
408
  _context.n = 31;
@@ -656,11 +688,11 @@ function _loadExtraFiles() {
656
688
  }));
657
689
  return _loadExtraFiles.apply(this, arguments);
658
690
  }
659
- export function loadVariant(_x16, _x17, _x18) {
660
- return _loadVariant.apply(this, arguments);
691
+ export function loadCodeVariant(_x16, _x17, _x18) {
692
+ return _loadCodeVariant.apply(this, arguments);
661
693
  }
662
- function _loadVariant() {
663
- _loadVariant = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url, variantName, variant) {
694
+ function _loadCodeVariant() {
695
+ _loadCodeVariant = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url, variantName, variant) {
664
696
  var options,
665
697
  sourceParser,
666
698
  loadSource,
@@ -668,6 +700,8 @@ function _loadVariant() {
668
700
  sourceTransformers,
669
701
  globalsCode,
670
702
  loadSourceCache,
703
+ functionName,
704
+ currentMark,
671
705
  _getFileNameFromUrl,
672
706
  _fileName,
673
707
  loadedFiles,
@@ -680,11 +714,11 @@ function _loadVariant() {
680
714
  fileName,
681
715
  _finalVariant,
682
716
  mainFileResult,
683
- allExtraFiles,
684
717
  _i5,
685
718
  _Object$keys3,
686
719
  _extraFileName,
687
720
  extraFilesToLoad,
721
+ externalsMergedMark,
688
722
  globalsFileKeys,
689
723
  existingFiles,
690
724
  _i6,
@@ -701,6 +735,7 @@ function _loadVariant() {
701
735
  _key,
702
736
  value,
703
737
  conflictFreeKey,
738
+ allExtraFiles,
704
739
  loadableFiles,
705
740
  _i8,
706
741
  _Object$entries4,
@@ -734,10 +769,15 @@ function _loadVariant() {
734
769
  }
735
770
  throw new Error("Variant is missing from code: ".concat(variantName));
736
771
  case 1:
737
- sourceParser = options.sourceParser, loadSource = options.loadSource, loadVariantMeta = options.loadVariantMeta, sourceTransformers = options.sourceTransformers, globalsCode = options.globalsCode; // Create a cache for loadSource calls scoped to this loadVariant call
772
+ sourceParser = options.sourceParser, loadSource = options.loadSource, loadVariantMeta = options.loadVariantMeta, sourceTransformers = options.sourceTransformers, globalsCode = options.globalsCode; // Create a cache for loadSource calls scoped to this loadCodeVariant call
738
773
  loadSourceCache = new Map();
774
+ functionName = 'Load Variant';
775
+ currentMark = performanceMeasure(undefined, {
776
+ mark: 'Start',
777
+ measure: 'Start'
778
+ }, [functionName, url || variantName], true);
739
779
  if (!(typeof variant === 'string')) {
740
- _context6.n = 6;
780
+ _context6.n = 7;
741
781
  break;
742
782
  }
743
783
  if (loadVariantMeta) {
@@ -756,7 +796,7 @@ function _loadVariant() {
756
796
  url: variant,
757
797
  fileName: _fileName
758
798
  };
759
- _context6.n = 6;
799
+ _context6.n = 7;
760
800
  break;
761
801
  case 3:
762
802
  _context6.p = 3;
@@ -771,6 +811,11 @@ function _loadVariant() {
771
811
  _t9 = _context6.v;
772
812
  throw new Error("Failed to load variant code (variant: ".concat(variantName, ", url: ").concat(variant, "): ").concat(JSON.stringify(_t9)));
773
813
  case 6:
814
+ currentMark = performanceMeasure(currentMark, {
815
+ mark: 'Loaded Variant Meta',
816
+ measure: 'Variant Meta Loading'
817
+ }, [functionName, url || variantName]);
818
+ case 7:
774
819
  loadedFiles = new Set();
775
820
  if (url) {
776
821
  loadedFiles.add(url);
@@ -789,7 +834,7 @@ function _loadVariant() {
789
834
  // Load main file
790
835
  fileName = variant.fileName || (url ? getFileNameFromUrl(url).fileName : undefined); // If we don't have a fileName and no URL, we can't parse or transform but can still return the code
791
836
  if (!(!fileName && !url)) {
792
- _context6.n = 7;
837
+ _context6.n = 8;
793
838
  break;
794
839
  }
795
840
  // Return the variant as-is without parsing or transforms
@@ -808,56 +853,66 @@ function _loadVariant() {
808
853
  // No dependencies without URL
809
854
  externals: {} // No externals without URL
810
855
  });
811
- case 7:
856
+ case 8:
812
857
  if (fileName) {
813
- _context6.n = 8;
858
+ _context6.n = 9;
814
859
  break;
815
860
  }
816
861
  throw new Error("No fileName available for variant \"".concat(variantName, "\". ") + "Please provide a fileName in the variant definition or ensure the URL has a valid file extension.");
817
- case 8:
818
- _context6.n = 9;
862
+ case 9:
863
+ _context6.n = 10;
819
864
  return loadSingleFile(variantName, fileName, variant.source, url, loadSource, sourceParser, sourceTransformers, loadSourceCache, variant.transforms, _extends(_extends({}, options), {}, {
820
865
  loadedFiles: loadedFiles
821
866
  }), variant.allFilesListed || false, knownExtraFiles);
822
- case 9:
867
+ case 10:
823
868
  mainFileResult = _context6.v;
824
869
  // Add files used from main file loading
825
870
  if (mainFileResult.extraDependencies) {
826
871
  allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(mainFileResult.extraDependencies));
827
872
  }
873
+ currentMark = performanceMeasure(currentMark, {
874
+ mark: 'Loaded Main File',
875
+ measure: 'Main File Loading'
876
+ }, [functionName, url || fileName], true);
828
877
 
829
- // Add externals from main file loading
830
- if (mainFileResult.externals) {
831
- allExternals = mergeExternals([allExternals, mainFileResult.externals]);
832
- }
833
- allExtraFiles = {}; // Validate extraFiles keys from variant definition
878
+ // Validate extraFiles keys from variant definition
834
879
  if (!variant.extraFiles) {
835
- _context6.n = 12;
880
+ _context6.n = 13;
836
881
  break;
837
882
  }
838
883
  _i5 = 0, _Object$keys3 = Object.keys(variant.extraFiles);
839
- case 10:
884
+ case 11:
840
885
  if (!(_i5 < _Object$keys3.length)) {
841
- _context6.n = 12;
886
+ _context6.n = 13;
842
887
  break;
843
888
  }
844
889
  _extraFileName = _Object$keys3[_i5];
845
890
  if (!isAbsolutePath(_extraFileName)) {
846
- _context6.n = 11;
891
+ _context6.n = 12;
847
892
  break;
848
893
  }
849
894
  throw new Error("Invalid extraFiles key in variant: \"".concat(_extraFileName, "\" appears to be an absolute path. ") + "extraFiles keys in variant definition should be relative paths from the main file.");
850
- case 11:
895
+ case 12:
851
896
  _i5++;
852
- _context6.n = 10;
897
+ _context6.n = 11;
853
898
  break;
854
- case 12:
899
+ case 13:
855
900
  // Collect extra files from variant definition and from loaded source
856
- extraFilesToLoad = _extends(_extends({}, variant.extraFiles || {}), mainFileResult.extraFiles || {}); // Track which files come from globals for metadata marking
901
+ extraFilesToLoad = _extends(_extends({}, variant.extraFiles || {}), mainFileResult.extraFiles || {}); // Add externals from main file loading
902
+ if (mainFileResult.externals) {
903
+ allExternals = mergeExternals([allExternals, mainFileResult.externals]);
904
+ }
905
+ externalsMergedMark = performanceMeasure(currentMark, {
906
+ mark: 'Externals Merged',
907
+ measure: 'Merging Externals'
908
+ }, [functionName, url || fileName]);
909
+ currentMark = externalsMergedMark;
910
+
911
+ // Track which files come from globals for metadata marking
857
912
  globalsFileKeys = new Set(); // Track globals file keys for loadExtraFiles
858
913
  // Process globalsCode array and add to extraFiles if provided
859
914
  if (!(globalsCode && globalsCode.length > 0)) {
860
- _context6.n = 14;
915
+ _context6.n = 15;
861
916
  break;
862
917
  }
863
918
  // Collect existing filenames to avoid conflicts
@@ -907,6 +962,10 @@ function _loadVariant() {
907
962
  return loadVariantMeta(variantName, globalsItem);
908
963
  case 3:
909
964
  globalsVariant = _context5.v;
965
+ currentMark = performanceMeasure(currentMark, {
966
+ mark: 'Globals Variant Meta Loaded',
967
+ measure: 'Globals Variant Meta Loading'
968
+ }, [functionName, globalsItem, url || fileName]);
910
969
  _context5.n = 5;
911
970
  break;
912
971
  case 4:
@@ -921,12 +980,16 @@ function _loadVariant() {
921
980
  case 7:
922
981
  _context5.p = 7;
923
982
  _context5.n = 8;
924
- return loadVariant(globalsVariant.url, variantName, globalsVariant, _extends(_extends({}, options), {}, {
983
+ return loadCodeVariant(globalsVariant.url, variantName, globalsVariant, _extends(_extends({}, options), {}, {
925
984
  globalsCode: undefined
926
985
  }) // Prevent infinite recursion
927
986
  );
928
987
  case 8:
929
988
  globalsResult = _context5.v;
989
+ currentMark = performanceMeasure(currentMark, {
990
+ mark: 'Globals Variant Loaded',
991
+ measure: 'Globals Variant Loading'
992
+ }, [functionName, globalsVariant.url || variantName, url || fileName]);
930
993
  return _context5.a(2, globalsResult);
931
994
  case 9:
932
995
  _context5.p = 9;
@@ -941,9 +1004,9 @@ function _loadVariant() {
941
1004
  return _ref4.apply(this, arguments);
942
1005
  };
943
1006
  }()); // Wait for all globals to load
944
- _context6.n = 13;
1007
+ _context6.n = 14;
945
1008
  return Promise.all(globalsPromises);
946
- case 13:
1009
+ case 14:
947
1010
  globalsResults = _context6.v;
948
1011
  // Merge results from all globals
949
1012
  _iterator4 = _createForOfIteratorHelper(globalsResults);
@@ -981,13 +1044,18 @@ function _loadVariant() {
981
1044
  } finally {
982
1045
  _iterator4.f();
983
1046
  }
984
- case 14:
1047
+ case 15:
1048
+ currentMark = performanceMeasure(externalsMergedMark, {
1049
+ mark: 'Globals Loaded',
1050
+ measure: 'Globals Loading'
1051
+ }, [functionName, url || fileName], true);
1052
+ allExtraFiles = {}; // Load all extra files if any exist and we have a URL
985
1053
  if (!(Object.keys(extraFilesToLoad).length > 0)) {
986
- _context6.n = 19;
1054
+ _context6.n = 21;
987
1055
  break;
988
1056
  }
989
1057
  if (url) {
990
- _context6.n = 17;
1058
+ _context6.n = 18;
991
1059
  break;
992
1060
  }
993
1061
  // If there's no URL, we can only load extra files that have inline source or absolute URLs
@@ -1005,7 +1073,7 @@ function _loadVariant() {
1005
1073
  }
1006
1074
  }
1007
1075
  if (!(Object.keys(loadableFiles).length > 0)) {
1008
- _context6.n = 16;
1076
+ _context6.n = 17;
1009
1077
  break;
1010
1078
  }
1011
1079
  // Process loadable files: inline sources without URL-based loading, absolute URLs with loading
@@ -1032,10 +1100,10 @@ function _loadVariant() {
1032
1100
  }
1033
1101
  }
1034
1102
  if (!(Object.keys(urlFilesToLoad).length > 0)) {
1035
- _context6.n = 16;
1103
+ _context6.n = 17;
1036
1104
  break;
1037
1105
  }
1038
- _context6.n = 15;
1106
+ _context6.n = 16;
1039
1107
  return loadExtraFiles(variantName, urlFilesToLoad, '',
1040
1108
  // No base URL needed for absolute URLs
1041
1109
  '',
@@ -1044,28 +1112,33 @@ function _loadVariant() {
1044
1112
  loadedFiles: loadedFiles
1045
1113
  }), variant.allFilesListed || false, knownExtraFiles, globalsFileKeys // Pass globals file tracking
1046
1114
  );
1047
- case 15:
1115
+ case 16:
1048
1116
  extraFilesResult = _context6.v;
1049
1117
  allExtraFiles = _extends(_extends({}, allExtraFiles), extraFilesResult.extraFiles);
1050
1118
  allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(extraFilesResult.allFilesUsed));
1051
1119
  allExternals = mergeExternals([allExternals, extraFilesResult.allExternals]);
1052
- case 16:
1053
- _context6.n = 19;
1054
- break;
1055
1120
  case 17:
1056
- _context6.n = 18;
1121
+ _context6.n = 20;
1122
+ break;
1123
+ case 18:
1124
+ _context6.n = 19;
1057
1125
  return loadExtraFiles(variantName, extraFilesToLoad, url, url,
1058
1126
  // Entry URL is the same as the main file URL
1059
1127
  loadSource, sourceParser, sourceTransformers, loadSourceCache, _extends(_extends({}, options), {}, {
1060
1128
  loadedFiles: loadedFiles
1061
1129
  }), variant.allFilesListed || false, knownExtraFiles, globalsFileKeys // Pass globals file tracking
1062
1130
  );
1063
- case 18:
1131
+ case 19:
1064
1132
  _extraFilesResult = _context6.v;
1065
1133
  allExtraFiles = _extraFilesResult.extraFiles;
1066
1134
  allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(_extraFilesResult.allFilesUsed));
1067
1135
  allExternals = mergeExternals([allExternals, _extraFilesResult.allExternals]);
1068
- case 19:
1136
+ case 20:
1137
+ currentMark = performanceMeasure(currentMark, {
1138
+ mark: 'Extra Files Loaded',
1139
+ measure: 'Extra Files Loading'
1140
+ }, [functionName, url || fileName], true);
1141
+ case 21:
1069
1142
  // Note: metadata marking is now handled during loadExtraFiles processing
1070
1143
  finalVariant = _extends(_extends({}, variant), {}, {
1071
1144
  source: mainFileResult.source,
@@ -1082,5 +1155,5 @@ function _loadVariant() {
1082
1155
  }
1083
1156
  }, _callee5, null, [[3, 5]]);
1084
1157
  }));
1085
- return _loadVariant.apply(this, arguments);
1158
+ return _loadCodeVariant.apply(this, arguments);
1086
1159
  }
@@ -1,4 +1,4 @@
1
- import { Code, VariantExtraFiles, VariantSource } from "./types.js";
1
+ import { Code, VariantExtraFiles, VariantSource } from "../../CodeHighlighter/types.js";
2
2
  /**
3
3
  * Type guard function that determines if we have sufficient data to render a code highlighter
4
4
  * component immediately, or if we need to start loading data first.
@@ -38,7 +38,7 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
38
38
  * more predictable and easier to reason about
39
39
  *
40
40
  * When `initialData: false` is returned, the calling component is responsible for initiating
41
- * asynchronous loading operations (e.g., `loadFallbackCode`, `CodeInitialSourceLoader`).
41
+ * asynchronous loading operations (e.g., `loadCodeFallback`, `CodeInitialSourceLoader`).
42
42
  *
43
43
  * @param variants - Array of all available variant names for this code block (e.g., ['javascript', 'typescript'])
44
44
  * @param variant - The specific variant we want to display (must exist in variants array)
@@ -62,7 +62,7 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
62
62
  * @example
63
63
  * ```typescript
64
64
  * // Server-side: Check if we can render with initial source or need to load fallback
65
- * const { initialData, reason } = maybeInitialData(
65
+ * const { initialData, reason } = maybeCodeInitialData(
66
66
  * variants,
67
67
  * initialKey,
68
68
  * code || props.precompute,
@@ -79,7 +79,7 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
79
79
  *
80
80
  * // Client-side: Check if we need to trigger loading effects
81
81
  * const { initialData, reason } = React.useMemo(() =>
82
- * maybeInitialData(
82
+ * maybeCodeInitialData(
83
83
  * variants,
84
84
  * variantName,
85
85
  * code,
@@ -93,11 +93,11 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
93
93
  * if (initialData || isControlled) {
94
94
  * return; // No loading needed
95
95
  * }
96
- * // Trigger loadFallbackCode...
96
+ * // Trigger loadCodeFallback...
97
97
  * }, [initialData, reason, ...]);
98
98
  * ```
99
99
  */
100
- export declare function maybeInitialData(variants: string[], variant: string, code?: Code, fileName?: string, needsHighlight?: boolean, needsAllFiles?: boolean, needsAllVariants?: boolean): {
100
+ export declare function maybeCodeInitialData(variants: string[], variant: string, code?: Code, fileName?: string, needsHighlight?: boolean, needsAllFiles?: boolean, needsAllVariants?: boolean): {
101
101
  initialData: false | {
102
102
  code: Code;
103
103
  initialFilename: string | undefined;
@@ -1,5 +1,5 @@
1
1
  import _typeof from "@babel/runtime/helpers/esm/typeof";
2
- import { hasAllVariants } from "./hasAllVariants.js";
2
+ import { hasAllVariants } from "./hasAllCodeVariants.js";
3
3
  /**
4
4
  * Type guard function that determines if we have sufficient data to render a code highlighter
5
5
  * component immediately, or if we need to start loading data first.
@@ -39,7 +39,7 @@ import { hasAllVariants } from "./hasAllVariants.js";
39
39
  * more predictable and easier to reason about
40
40
  *
41
41
  * When `initialData: false` is returned, the calling component is responsible for initiating
42
- * asynchronous loading operations (e.g., `loadFallbackCode`, `CodeInitialSourceLoader`).
42
+ * asynchronous loading operations (e.g., `loadCodeFallback`, `CodeInitialSourceLoader`).
43
43
  *
44
44
  * @param variants - Array of all available variant names for this code block (e.g., ['javascript', 'typescript'])
45
45
  * @param variant - The specific variant we want to display (must exist in variants array)
@@ -63,7 +63,7 @@ import { hasAllVariants } from "./hasAllVariants.js";
63
63
  * @example
64
64
  * ```typescript
65
65
  * // Server-side: Check if we can render with initial source or need to load fallback
66
- * const { initialData, reason } = maybeInitialData(
66
+ * const { initialData, reason } = maybeCodeInitialData(
67
67
  * variants,
68
68
  * initialKey,
69
69
  * code || props.precompute,
@@ -80,7 +80,7 @@ import { hasAllVariants } from "./hasAllVariants.js";
80
80
  *
81
81
  * // Client-side: Check if we need to trigger loading effects
82
82
  * const { initialData, reason } = React.useMemo(() =>
83
- * maybeInitialData(
83
+ * maybeCodeInitialData(
84
84
  * variants,
85
85
  * variantName,
86
86
  * code,
@@ -94,11 +94,11 @@ import { hasAllVariants } from "./hasAllVariants.js";
94
94
  * if (initialData || isControlled) {
95
95
  * return; // No loading needed
96
96
  * }
97
- * // Trigger loadFallbackCode...
97
+ * // Trigger loadCodeFallback...
98
98
  * }, [initialData, reason, ...]);
99
99
  * ```
100
100
  */
101
- export function maybeInitialData(variants, variant, code, fileName) {
101
+ export function maybeCodeInitialData(variants, variant, code, fileName) {
102
102
  var needsHighlight = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
103
103
  var needsAllFiles = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
104
104
  var needsAllVariants = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Metadata merging utility for positioning metadata files relative to source files
3
3
  */
4
- import type { VariantCode, VariantExtraFiles } from "./types.js";
4
+ import type { VariantCode, VariantExtraFiles } from "../../CodeHighlighter/types.js";
5
5
  /**
6
6
  * Options for merging metadata files
7
7
  */
@@ -32,9 +32,9 @@ interface MergeMetadataOptions {
32
32
  * @param variant - The variant containing mixed source and metadata files
33
33
  * @returns An object with the cleaned variant and extracted metadata
34
34
  */
35
- export declare function extractMetadata(variant: VariantCode): {
35
+ export declare function extractCodeMetadata(variant: VariantCode): {
36
36
  variant: VariantCode;
37
37
  metadata: VariantExtraFiles;
38
38
  };
39
- export declare function mergeMetadata(variant: VariantCode, metadataFiles?: VariantExtraFiles, options?: MergeMetadataOptions): VariantCode;
39
+ export declare function mergeCodeMetadata(variant: VariantCode, metadataFiles?: VariantExtraFiles, options?: MergeMetadataOptions): VariantCode;
40
40
  export {};
@@ -26,7 +26,7 @@ import { calculateMaxSourceBackNavigation, removeBackNavigationPrefix, buildPath
26
26
  * @param variant - The variant containing mixed source and metadata files
27
27
  * @returns An object with the cleaned variant and extracted metadata
28
28
  */
29
- export function extractMetadata(variant) {
29
+ export function extractCodeMetadata(variant) {
30
30
  var metadataPrefix = variant.metadataPrefix;
31
31
  var extractedMetadata = {};
32
32
  var nonMetadataFiles = {};
@@ -72,7 +72,7 @@ export function extractMetadata(variant) {
72
72
  metadata: extractedMetadata
73
73
  };
74
74
  }
75
- export function mergeMetadata(variant) {
75
+ export function mergeCodeMetadata(variant) {
76
76
  var _options$metadataPref;
77
77
  var metadataFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
78
78
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -87,7 +87,7 @@ export function mergeMetadata(variant) {
87
87
  var existingMetadata = {};
88
88
  if (needsReextraction && variant.extraFiles) {
89
89
  // Extract existing metadata using the old metadataPrefix
90
- var extracted = extractMetadata(variant);
90
+ var extracted = extractCodeMetadata(variant);
91
91
  workingVariant = extracted.variant;
92
92
  existingMetadata = extracted.metadata;
93
93
  }
@@ -1,4 +1,4 @@
1
- import type { Code, ParseSource } from "./types.js";
1
+ import type { Code, ParseSource } from "../../CodeHighlighter/types.js";
2
2
  /**
3
3
  * Pure function to parse code variants and their extraFiles.
4
4
  * Converts string sources to HAST nodes and handles hastJson parsing.
@@ -1,2 +1,2 @@
1
- import type { VariantSource, SourceTransformers, Transforms } from "./types.js";
1
+ import type { VariantSource, SourceTransformers, Transforms } from "../../CodeHighlighter/types.js";
2
2
  export declare function transformSource(source: VariantSource, fileName: string, sourceTransformers: SourceTransformers): Promise<Transforms | undefined>;
@@ -1,5 +1,10 @@
1
1
  import type { LoaderContext } from 'webpack';
2
2
  export type LoaderOptions = {
3
+ performance?: {
4
+ logging?: boolean;
5
+ notableMs?: number;
6
+ showWrapperMeasures?: boolean;
7
+ };
3
8
  output?: 'hast' | 'hastJson' | 'hastGzip';
4
9
  };
5
10
  /**