@mui/internal-docs-infra 0.2.3-canary.9 → 0.3.1-canary.1

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 (156) 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} +141 -55
  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 +94 -16
  51. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +3 -3
  52. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
  53. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
  54. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +24 -14
  55. package/esm/pipeline/loadPrecomputedSitemap/index.d.ts +2 -0
  56. package/esm/pipeline/loadPrecomputedSitemap/index.js +4 -0
  57. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.d.ts +10 -0
  58. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +220 -0
  59. package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
  60. package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
  61. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
  62. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +7 -5
  63. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +3 -3
  64. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +14 -8
  65. package/esm/pipeline/loadServerPageIndex/index.d.ts +2 -0
  66. package/esm/pipeline/loadServerPageIndex/index.js +1 -0
  67. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.d.ts +51 -0
  68. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +176 -0
  69. package/esm/pipeline/loadServerSitemap/index.d.ts +2 -0
  70. package/esm/pipeline/loadServerSitemap/index.js +1 -0
  71. package/esm/pipeline/loadServerSitemap/loadServerSitemap.d.ts +39 -0
  72. package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +170 -0
  73. package/esm/pipeline/loadServerSource/loadServerSource.js +18 -15
  74. package/esm/pipeline/loaderUtils/externalsToPackages.js +1 -1
  75. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +0 -9
  76. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +7 -7
  77. package/esm/pipeline/loaderUtils/fileUrlToPortablePath.d.ts +44 -0
  78. package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +80 -0
  79. package/esm/pipeline/loaderUtils/index.d.ts +2 -1
  80. package/esm/pipeline/loaderUtils/index.js +2 -1
  81. package/esm/pipeline/loaderUtils/parseImportsAndComments.d.ts +10 -6
  82. package/esm/pipeline/loaderUtils/parseImportsAndComments.js +17 -12
  83. package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +1 -1
  84. package/esm/pipeline/loaderUtils/processRelativeImports.js +44 -27
  85. package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +5 -5
  86. package/esm/pipeline/loaderUtils/resolveModulePath.js +40 -37
  87. package/esm/pipeline/loaderUtils/rewriteImports.d.ts +36 -0
  88. package/esm/pipeline/loaderUtils/rewriteImports.js +139 -8
  89. package/esm/pipeline/syncPageIndex/createMarkdownNodes.d.ts +76 -0
  90. package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +305 -0
  91. package/esm/pipeline/syncPageIndex/index.d.ts +1 -0
  92. package/esm/pipeline/syncPageIndex/index.js +1 -0
  93. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.d.ts +58 -0
  94. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +214 -0
  95. package/esm/pipeline/syncPageIndex/metadataToMarkdown.d.ts +67 -0
  96. package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +1486 -0
  97. package/esm/pipeline/syncPageIndex/syncPageIndex.d.ts +108 -0
  98. package/esm/pipeline/syncPageIndex/syncPageIndex.js +540 -0
  99. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
  100. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
  101. package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.d.ts +2 -0
  102. package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.js +4 -0
  103. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts +16 -0
  104. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +58 -0
  105. package/esm/pipeline/transformMarkdownDemoLinks/index.d.ts +2 -0
  106. package/esm/pipeline/transformMarkdownDemoLinks/index.js +4 -0
  107. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.d.ts +26 -0
  108. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +107 -0
  109. package/esm/pipeline/transformMarkdownMetadata/index.d.ts +2 -0
  110. package/esm/pipeline/transformMarkdownMetadata/index.js +4 -0
  111. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.d.ts +3 -0
  112. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +1010 -0
  113. package/esm/pipeline/transformMarkdownMetadata/types.d.ts +110 -0
  114. package/esm/pipeline/transformMarkdownMetadata/types.js +1 -0
  115. package/esm/pipeline/transformMarkdownRelativePaths/index.d.ts +2 -0
  116. package/esm/pipeline/transformMarkdownRelativePaths/index.js +4 -0
  117. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.d.ts +15 -0
  118. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +43 -0
  119. package/esm/useCode/Pre.js +15 -2
  120. package/esm/useCode/useCode.d.ts +15 -2
  121. package/esm/useCode/useCode.js +15 -6
  122. package/esm/useCode/useCodeUtils.js +3 -3
  123. package/esm/useCode/useFileNavigation.d.ts +9 -3
  124. package/esm/useCode/useFileNavigation.js +124 -81
  125. package/esm/useCode/useUIState.d.ts +4 -1
  126. package/esm/useCode/useUIState.js +17 -2
  127. package/esm/useCode/useVariantSelection.d.ts +8 -3
  128. package/esm/useCode/useVariantSelection.js +144 -52
  129. package/esm/useCopier/index.js +5 -4
  130. package/esm/useDemo/createCodeSandbox.d.ts +1 -1
  131. package/esm/useDemo/createStackBlitz.d.ts +1 -1
  132. package/esm/useDemo/exportVariant.js +13 -11
  133. package/esm/useDemo/index.d.ts +1 -1
  134. package/esm/useDemo/index.js +1 -1
  135. package/esm/useDemo/useDemo.d.ts +5 -5
  136. package/esm/useDemo/useDemo.js +6 -6
  137. package/esm/useErrors/useErrors.d.ts +1 -1
  138. package/esm/useErrors/useErrors.js +6 -2
  139. package/esm/useSearch/index.d.ts +1 -0
  140. package/esm/useSearch/index.js +1 -0
  141. package/esm/useSearch/types.d.ts +165 -0
  142. package/esm/useSearch/types.js +1 -0
  143. package/esm/useSearch/useSearch.d.ts +56 -0
  144. package/esm/useSearch/useSearch.js +647 -0
  145. package/esm/withDocsInfra/withDeploymentConfig.js +4 -2
  146. package/esm/withDocsInfra/withDocsInfra.d.ts +39 -0
  147. package/esm/withDocsInfra/withDocsInfra.js +94 -14
  148. package/package.json +105 -5
  149. package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
  150. /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
  151. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
  152. /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
  153. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
  154. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
  155. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
  156. /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) {
@@ -84,15 +85,28 @@ function convertKeyBasedOnDirectory(nestedKey, sourceFileKey) {
84
85
  processedNestedKey = "./".concat(nestedKey);
85
86
  }
86
87
 
87
- // Use path module for clean path resolution
88
+ // Get the directory of the source file
88
89
  var sourceDir = path.dirname(sourceFileKey);
89
- var resolvedPath = path.resolve(sourceDir, processedNestedKey);
90
90
 
91
- // Convert back to relative path from current directory
92
- var result = path.relative('.', resolvedPath);
91
+ // If sourceDir is '.' (current directory), just return the processed nested key
92
+ // This avoids path.resolve which can produce absolute paths on Windows
93
+ if (sourceDir === '.') {
94
+ // Remove leading './' if present for consistency
95
+ return processedNestedKey.startsWith('./') ? processedNestedKey.slice(2) : processedNestedKey;
96
+ }
97
+
98
+ // Use path.join instead of path.resolve to avoid producing absolute paths
99
+ // path.join keeps paths relative, while path.resolve can make them absolute
100
+ var joinedPath = path.join(sourceDir, processedNestedKey);
93
101
 
94
- // Return empty string if result is '.' (current directory)
95
- return result === '.' ? '' : result;
102
+ // Normalize the path to clean up any ../ or ./ segments
103
+ var normalizedPath = path.normalize(joinedPath);
104
+
105
+ // Ensure we return a clean relative path (remove leading './' if present after normalization)
106
+ if (normalizedPath.startsWith('./')) {
107
+ return normalizedPath.slice(2);
108
+ }
109
+ return normalizedPath === '.' ? '' : normalizedPath;
96
110
  }
97
111
 
98
112
  /**
@@ -138,6 +152,8 @@ function _loadSingleFile() {
138
152
  extraFilesFromSource,
139
153
  extraDependenciesFromSource,
140
154
  externalsFromSource,
155
+ functionName,
156
+ currentMark,
141
157
  loadPromise,
142
158
  loadResult,
143
159
  _i,
@@ -170,6 +186,11 @@ function _loadSingleFile() {
170
186
  knownExtraFiles = _args.length > 11 && _args[11] !== undefined ? _args[11] : new Set();
171
187
  _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
188
  finalSource = source;
189
+ functionName = 'Load Variant File';
190
+ currentMark = performanceMeasure(undefined, {
191
+ mark: 'Start',
192
+ measure: 'Start'
193
+ }, [functionName, url || fileName], true); // Load source if not provided
173
194
  if (finalSource) {
174
195
  _context.n = 20;
175
196
  break;
@@ -201,6 +222,10 @@ function _loadSingleFile() {
201
222
  extraFilesFromSource = loadResult.extraFiles;
202
223
  extraDependenciesFromSource = loadResult.extraDependencies;
203
224
  externalsFromSource = loadResult.externals;
225
+ currentMark = performanceMeasure(currentMark, {
226
+ mark: 'Loaded File',
227
+ measure: 'File Loading'
228
+ }, [functionName, url]);
204
229
 
205
230
  // Validate that extraFiles from loadSource contain only absolute URLs as values
206
231
  if (!extraFilesFromSource) {
@@ -321,6 +346,10 @@ function _loadSingleFile() {
321
346
  return transformSource(finalSource, normalizePathKey(fileName), sourceTransformers);
322
347
  case 21:
323
348
  finalTransforms = _context.v;
349
+ currentMark = performanceMeasure(currentMark, {
350
+ mark: 'Transformed File',
351
+ measure: 'File Transforming'
352
+ }, [functionName, url || fileName]);
324
353
  case 22:
325
354
  if (!(typeof finalSource === 'string' && !disableParsing)) {
326
355
  _context.n = 31;
@@ -339,14 +368,22 @@ function _loadSingleFile() {
339
368
  case 24:
340
369
  parseSource = _context.v;
341
370
  finalSource = parseSource(finalSource, fileName);
371
+ currentMark = performanceMeasure(currentMark, {
372
+ mark: 'Parsed File',
373
+ measure: 'File Parsing'
374
+ }, [functionName, url || fileName]);
342
375
  if (!(finalTransforms && !disableTransforms)) {
343
376
  _context.n = 26;
344
377
  break;
345
378
  }
346
379
  _context.n = 25;
347
- return transformParsedSource(sourceString, finalSource, normalizePathKey(fileName), finalTransforms, parseSource);
380
+ return diffHast(sourceString, finalSource, normalizePathKey(fileName), finalTransforms, parseSource);
348
381
  case 25:
349
382
  finalTransforms = _context.v;
383
+ currentMark = performanceMeasure(currentMark, {
384
+ mark: 'Transform Parsed File',
385
+ measure: 'Parsed File Transforming'
386
+ }, [functionName, url || fileName]);
350
387
  case 26:
351
388
  if (!(options.output === 'hastGzip' && process.env.NODE_ENV === 'production')) {
352
389
  _context.n = 28;
@@ -363,6 +400,10 @@ function _loadSingleFile() {
363
400
  finalSource = {
364
401
  hastGzip: hastGzip
365
402
  };
403
+ currentMark = performanceMeasure(currentMark, {
404
+ mark: 'Compressed File',
405
+ measure: 'File Compression'
406
+ }, [functionName, url || fileName]);
366
407
  _context.n = 29;
367
408
  break;
368
409
  case 28:
@@ -371,6 +412,10 @@ function _loadSingleFile() {
371
412
  finalSource = {
372
413
  hastJson: JSON.stringify(finalSource)
373
414
  };
415
+ performanceMeasure(currentMark, {
416
+ mark: 'JSON Stringified File',
417
+ measure: 'File Stringification'
418
+ }, [functionName, url || fileName]);
374
419
  }
375
420
  case 29:
376
421
  _context.n = 31;
@@ -656,11 +701,11 @@ function _loadExtraFiles() {
656
701
  }));
657
702
  return _loadExtraFiles.apply(this, arguments);
658
703
  }
659
- export function loadVariant(_x16, _x17, _x18) {
660
- return _loadVariant.apply(this, arguments);
704
+ export function loadCodeVariant(_x16, _x17, _x18) {
705
+ return _loadCodeVariant.apply(this, arguments);
661
706
  }
662
- function _loadVariant() {
663
- _loadVariant = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url, variantName, variant) {
707
+ function _loadCodeVariant() {
708
+ _loadCodeVariant = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url, variantName, variant) {
664
709
  var options,
665
710
  sourceParser,
666
711
  loadSource,
@@ -668,6 +713,8 @@ function _loadVariant() {
668
713
  sourceTransformers,
669
714
  globalsCode,
670
715
  loadSourceCache,
716
+ functionName,
717
+ currentMark,
671
718
  _getFileNameFromUrl,
672
719
  _fileName,
673
720
  loadedFiles,
@@ -680,11 +727,11 @@ function _loadVariant() {
680
727
  fileName,
681
728
  _finalVariant,
682
729
  mainFileResult,
683
- allExtraFiles,
684
730
  _i5,
685
731
  _Object$keys3,
686
732
  _extraFileName,
687
733
  extraFilesToLoad,
734
+ externalsMergedMark,
688
735
  globalsFileKeys,
689
736
  existingFiles,
690
737
  _i6,
@@ -701,6 +748,7 @@ function _loadVariant() {
701
748
  _key,
702
749
  value,
703
750
  conflictFreeKey,
751
+ allExtraFiles,
704
752
  loadableFiles,
705
753
  _i8,
706
754
  _Object$entries4,
@@ -734,10 +782,15 @@ function _loadVariant() {
734
782
  }
735
783
  throw new Error("Variant is missing from code: ".concat(variantName));
736
784
  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
785
+ 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
786
  loadSourceCache = new Map();
787
+ functionName = 'Load Variant';
788
+ currentMark = performanceMeasure(undefined, {
789
+ mark: 'Start',
790
+ measure: 'Start'
791
+ }, [functionName, url || variantName], true);
739
792
  if (!(typeof variant === 'string')) {
740
- _context6.n = 6;
793
+ _context6.n = 7;
741
794
  break;
742
795
  }
743
796
  if (loadVariantMeta) {
@@ -756,7 +809,7 @@ function _loadVariant() {
756
809
  url: variant,
757
810
  fileName: _fileName
758
811
  };
759
- _context6.n = 6;
812
+ _context6.n = 7;
760
813
  break;
761
814
  case 3:
762
815
  _context6.p = 3;
@@ -771,6 +824,11 @@ function _loadVariant() {
771
824
  _t9 = _context6.v;
772
825
  throw new Error("Failed to load variant code (variant: ".concat(variantName, ", url: ").concat(variant, "): ").concat(JSON.stringify(_t9)));
773
826
  case 6:
827
+ currentMark = performanceMeasure(currentMark, {
828
+ mark: 'Loaded Variant Meta',
829
+ measure: 'Variant Meta Loading'
830
+ }, [functionName, url || variantName]);
831
+ case 7:
774
832
  loadedFiles = new Set();
775
833
  if (url) {
776
834
  loadedFiles.add(url);
@@ -789,7 +847,7 @@ function _loadVariant() {
789
847
  // Load main file
790
848
  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
849
  if (!(!fileName && !url)) {
792
- _context6.n = 7;
850
+ _context6.n = 8;
793
851
  break;
794
852
  }
795
853
  // Return the variant as-is without parsing or transforms
@@ -808,56 +866,66 @@ function _loadVariant() {
808
866
  // No dependencies without URL
809
867
  externals: {} // No externals without URL
810
868
  });
811
- case 7:
869
+ case 8:
812
870
  if (fileName) {
813
- _context6.n = 8;
871
+ _context6.n = 9;
814
872
  break;
815
873
  }
816
874
  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;
875
+ case 9:
876
+ _context6.n = 10;
819
877
  return loadSingleFile(variantName, fileName, variant.source, url, loadSource, sourceParser, sourceTransformers, loadSourceCache, variant.transforms, _extends(_extends({}, options), {}, {
820
878
  loadedFiles: loadedFiles
821
879
  }), variant.allFilesListed || false, knownExtraFiles);
822
- case 9:
880
+ case 10:
823
881
  mainFileResult = _context6.v;
824
882
  // Add files used from main file loading
825
883
  if (mainFileResult.extraDependencies) {
826
884
  allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(mainFileResult.extraDependencies));
827
885
  }
886
+ currentMark = performanceMeasure(currentMark, {
887
+ mark: 'Loaded Main File',
888
+ measure: 'Main File Loading'
889
+ }, [functionName, url || fileName], true);
828
890
 
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
891
+ // Validate extraFiles keys from variant definition
834
892
  if (!variant.extraFiles) {
835
- _context6.n = 12;
893
+ _context6.n = 13;
836
894
  break;
837
895
  }
838
896
  _i5 = 0, _Object$keys3 = Object.keys(variant.extraFiles);
839
- case 10:
897
+ case 11:
840
898
  if (!(_i5 < _Object$keys3.length)) {
841
- _context6.n = 12;
899
+ _context6.n = 13;
842
900
  break;
843
901
  }
844
902
  _extraFileName = _Object$keys3[_i5];
845
903
  if (!isAbsolutePath(_extraFileName)) {
846
- _context6.n = 11;
904
+ _context6.n = 12;
847
905
  break;
848
906
  }
849
907
  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:
908
+ case 12:
851
909
  _i5++;
852
- _context6.n = 10;
910
+ _context6.n = 11;
853
911
  break;
854
- case 12:
912
+ case 13:
855
913
  // 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
914
+ extraFilesToLoad = _extends(_extends({}, variant.extraFiles || {}), mainFileResult.extraFiles || {}); // Add externals from main file loading
915
+ if (mainFileResult.externals) {
916
+ allExternals = mergeExternals([allExternals, mainFileResult.externals]);
917
+ }
918
+ externalsMergedMark = performanceMeasure(currentMark, {
919
+ mark: 'Externals Merged',
920
+ measure: 'Merging Externals'
921
+ }, [functionName, url || fileName]);
922
+ currentMark = externalsMergedMark;
923
+
924
+ // Track which files come from globals for metadata marking
857
925
  globalsFileKeys = new Set(); // Track globals file keys for loadExtraFiles
858
926
  // Process globalsCode array and add to extraFiles if provided
859
927
  if (!(globalsCode && globalsCode.length > 0)) {
860
- _context6.n = 14;
928
+ _context6.n = 15;
861
929
  break;
862
930
  }
863
931
  // Collect existing filenames to avoid conflicts
@@ -907,6 +975,10 @@ function _loadVariant() {
907
975
  return loadVariantMeta(variantName, globalsItem);
908
976
  case 3:
909
977
  globalsVariant = _context5.v;
978
+ currentMark = performanceMeasure(currentMark, {
979
+ mark: 'Globals Variant Meta Loaded',
980
+ measure: 'Globals Variant Meta Loading'
981
+ }, [functionName, globalsItem, url || fileName]);
910
982
  _context5.n = 5;
911
983
  break;
912
984
  case 4:
@@ -921,12 +993,16 @@ function _loadVariant() {
921
993
  case 7:
922
994
  _context5.p = 7;
923
995
  _context5.n = 8;
924
- return loadVariant(globalsVariant.url, variantName, globalsVariant, _extends(_extends({}, options), {}, {
996
+ return loadCodeVariant(globalsVariant.url, variantName, globalsVariant, _extends(_extends({}, options), {}, {
925
997
  globalsCode: undefined
926
998
  }) // Prevent infinite recursion
927
999
  );
928
1000
  case 8:
929
1001
  globalsResult = _context5.v;
1002
+ currentMark = performanceMeasure(currentMark, {
1003
+ mark: 'Globals Variant Loaded',
1004
+ measure: 'Globals Variant Loading'
1005
+ }, [functionName, globalsVariant.url || variantName, url || fileName]);
930
1006
  return _context5.a(2, globalsResult);
931
1007
  case 9:
932
1008
  _context5.p = 9;
@@ -941,9 +1017,9 @@ function _loadVariant() {
941
1017
  return _ref4.apply(this, arguments);
942
1018
  };
943
1019
  }()); // Wait for all globals to load
944
- _context6.n = 13;
1020
+ _context6.n = 14;
945
1021
  return Promise.all(globalsPromises);
946
- case 13:
1022
+ case 14:
947
1023
  globalsResults = _context6.v;
948
1024
  // Merge results from all globals
949
1025
  _iterator4 = _createForOfIteratorHelper(globalsResults);
@@ -981,13 +1057,18 @@ function _loadVariant() {
981
1057
  } finally {
982
1058
  _iterator4.f();
983
1059
  }
984
- case 14:
1060
+ case 15:
1061
+ currentMark = performanceMeasure(externalsMergedMark, {
1062
+ mark: 'Globals Loaded',
1063
+ measure: 'Globals Loading'
1064
+ }, [functionName, url || fileName], true);
1065
+ allExtraFiles = {}; // Load all extra files if any exist and we have a URL
985
1066
  if (!(Object.keys(extraFilesToLoad).length > 0)) {
986
- _context6.n = 19;
1067
+ _context6.n = 21;
987
1068
  break;
988
1069
  }
989
1070
  if (url) {
990
- _context6.n = 17;
1071
+ _context6.n = 18;
991
1072
  break;
992
1073
  }
993
1074
  // If there's no URL, we can only load extra files that have inline source or absolute URLs
@@ -1005,7 +1086,7 @@ function _loadVariant() {
1005
1086
  }
1006
1087
  }
1007
1088
  if (!(Object.keys(loadableFiles).length > 0)) {
1008
- _context6.n = 16;
1089
+ _context6.n = 17;
1009
1090
  break;
1010
1091
  }
1011
1092
  // Process loadable files: inline sources without URL-based loading, absolute URLs with loading
@@ -1032,10 +1113,10 @@ function _loadVariant() {
1032
1113
  }
1033
1114
  }
1034
1115
  if (!(Object.keys(urlFilesToLoad).length > 0)) {
1035
- _context6.n = 16;
1116
+ _context6.n = 17;
1036
1117
  break;
1037
1118
  }
1038
- _context6.n = 15;
1119
+ _context6.n = 16;
1039
1120
  return loadExtraFiles(variantName, urlFilesToLoad, '',
1040
1121
  // No base URL needed for absolute URLs
1041
1122
  '',
@@ -1044,28 +1125,33 @@ function _loadVariant() {
1044
1125
  loadedFiles: loadedFiles
1045
1126
  }), variant.allFilesListed || false, knownExtraFiles, globalsFileKeys // Pass globals file tracking
1046
1127
  );
1047
- case 15:
1128
+ case 16:
1048
1129
  extraFilesResult = _context6.v;
1049
1130
  allExtraFiles = _extends(_extends({}, allExtraFiles), extraFilesResult.extraFiles);
1050
1131
  allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(extraFilesResult.allFilesUsed));
1051
1132
  allExternals = mergeExternals([allExternals, extraFilesResult.allExternals]);
1052
- case 16:
1053
- _context6.n = 19;
1054
- break;
1055
1133
  case 17:
1056
- _context6.n = 18;
1134
+ _context6.n = 20;
1135
+ break;
1136
+ case 18:
1137
+ _context6.n = 19;
1057
1138
  return loadExtraFiles(variantName, extraFilesToLoad, url, url,
1058
1139
  // Entry URL is the same as the main file URL
1059
1140
  loadSource, sourceParser, sourceTransformers, loadSourceCache, _extends(_extends({}, options), {}, {
1060
1141
  loadedFiles: loadedFiles
1061
1142
  }), variant.allFilesListed || false, knownExtraFiles, globalsFileKeys // Pass globals file tracking
1062
1143
  );
1063
- case 18:
1144
+ case 19:
1064
1145
  _extraFilesResult = _context6.v;
1065
1146
  allExtraFiles = _extraFilesResult.extraFiles;
1066
1147
  allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(_extraFilesResult.allFilesUsed));
1067
1148
  allExternals = mergeExternals([allExternals, _extraFilesResult.allExternals]);
1068
- case 19:
1149
+ case 20:
1150
+ currentMark = performanceMeasure(currentMark, {
1151
+ mark: 'Extra Files Loaded',
1152
+ measure: 'Extra Files Loading'
1153
+ }, [functionName, url || fileName], true);
1154
+ case 21:
1069
1155
  // Note: metadata marking is now handled during loadExtraFiles processing
1070
1156
  finalVariant = _extends(_extends({}, variant), {}, {
1071
1157
  source: mainFileResult.source,
@@ -1082,5 +1168,5 @@ function _loadVariant() {
1082
1168
  }
1083
1169
  }, _callee5, null, [[3, 5]]);
1084
1170
  }));
1085
- return _loadVariant.apply(this, arguments);
1171
+ return _loadCodeVariant.apply(this, arguments);
1086
1172
  }
@@ -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
  /**