@mui/internal-docs-infra 0.2.3-canary.13 → 0.2.3-canary.15

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 (33) hide show
  1. package/README.md +3 -2
  2. package/esm/pipeline/getFileConventions/fileConventions.d.ts +4 -0
  3. package/esm/pipeline/getFileConventions/fileConventions.js +4 -0
  4. package/esm/pipeline/getFileConventions/getFileConventions.d.ts +4 -0
  5. package/esm/pipeline/getFileConventions/getFileConventions.js +17 -0
  6. package/esm/pipeline/getFileConventions/index.d.ts +1 -0
  7. package/esm/pipeline/getFileConventions/index.js +1 -0
  8. package/esm/pipeline/loadCodeVariant/calculateMainFilePath.js +1 -1
  9. package/esm/pipeline/loadCodeVariant/loadCodeFallback.js +164 -90
  10. package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +111 -38
  11. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +5 -0
  12. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +80 -7
  13. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
  14. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
  15. package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.d.ts +2 -0
  16. package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.js +4 -0
  17. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts +16 -0
  18. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +58 -0
  19. package/esm/pipeline/transformMarkdownDemoLinks/index.d.ts +2 -0
  20. package/esm/pipeline/transformMarkdownDemoLinks/index.js +4 -0
  21. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.d.ts +26 -0
  22. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +107 -0
  23. package/esm/pipeline/transformMarkdownRelativePaths/index.d.ts +2 -0
  24. package/esm/pipeline/transformMarkdownRelativePaths/index.js +4 -0
  25. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.d.ts +13 -0
  26. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +35 -0
  27. package/esm/useCode/Pre.js +8 -1
  28. package/esm/useCopier/index.js +5 -4
  29. package/esm/useErrors/useErrors.d.ts +1 -1
  30. package/esm/useErrors/useErrors.js +6 -2
  31. package/esm/withDocsInfra/withDocsInfra.d.ts +8 -0
  32. package/esm/withDocsInfra/withDocsInfra.js +31 -5
  33. package/package.json +26 -2
@@ -12,6 +12,7 @@ import { transformSource } from "./transformSource.js";
12
12
  import { diffHast } from "./diffHast.js";
13
13
  import { getFileNameFromUrl } from "../loaderUtils/index.js";
14
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,6 +355,10 @@ 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;
@@ -347,6 +367,10 @@ function _loadSingleFile() {
347
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;
@@ -668,6 +700,8 @@ function _loadCodeVariant() {
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 _loadCodeVariant() {
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 _loadCodeVariant() {
701
735
  _key,
702
736
  value,
703
737
  conflictFreeKey,
738
+ allExtraFiles,
704
739
  loadableFiles,
705
740
  _i8,
706
741
  _Object$entries4,
@@ -736,8 +771,13 @@ function _loadCodeVariant() {
736
771
  case 1:
737
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 _loadCodeVariant() {
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 _loadCodeVariant() {
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 _loadCodeVariant() {
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 _loadCodeVariant() {
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 _loadCodeVariant() {
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:
@@ -927,6 +986,10 @@ function _loadCodeVariant() {
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 _loadCodeVariant() {
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 _loadCodeVariant() {
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 _loadCodeVariant() {
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 _loadCodeVariant() {
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 _loadCodeVariant() {
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,
@@ -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
  /**
@@ -2,6 +2,9 @@ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIt
2
2
  import _regenerator from "@babel/runtime/helpers/esm/regenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
+ // webpack does not like node: imports
6
+ // eslint-disable-next-line n/prefer-node-protocol
7
+ import path from 'path';
5
8
  import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
6
9
  import { createParseSource } from "../parseSource/index.js";
7
10
  // TODO: re-enable following benchmarking
@@ -12,6 +15,9 @@ import { resolveVariantPathsWithFs } from "../loadServerCodeMeta/resolveModulePa
12
15
  import { replacePrecomputeValue } from "./replacePrecomputeValue.js";
13
16
  import { createLoadServerSource } from "../loadServerSource/index.js";
14
17
  import { getFileNameFromUrl } from "../loaderUtils/index.js";
18
+ import { createPerformanceLogger, logPerformance, performanceMeasure } from "./performanceLogger.js";
19
+ var functionName = 'Load Precomputed Code Highlighter';
20
+
15
21
  /**
16
22
  * Webpack loader that processes demo files and precomputes variant data.
17
23
  *
@@ -28,18 +34,44 @@ export function loadPrecomputedCodeHighlighter(_x) {
28
34
  }
29
35
  function _loadPrecomputedCodeHighlighter() {
30
36
  _loadPrecomputedCodeHighlighter = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(source) {
31
- var _this = this;
32
- var callback, demoCall, variantData, allDependencies, resolvedVariantMap, loadSource, sourceTransformers, sourceParser, variantPromises, variantResults, _iterator, _step, result, modifiedSource, _t2;
37
+ var _options$performance$,
38
+ _options$performance,
39
+ _options$performance$2,
40
+ _options$performance2,
41
+ _options$performance3,
42
+ _this = this;
43
+ var callback, options, performanceNotableMs, performanceShowWrapperMeasures, relativePath, observer, currentMark, _observer, _observer2, demoCall, variantData, allDependencies, resolvedVariantMap, loadSource, sourceTransformers, sourceParser, functionsInitMark, variantPromises, variantResults, _iterator, _step, result, modifiedSource, _observer3, _observer4, _t2;
33
44
  return _regenerator().w(function (_context2) {
34
45
  while (1) switch (_context2.p = _context2.n) {
35
46
  case 0:
36
47
  callback = this.async();
37
48
  this.cacheable();
49
+ options = this.getOptions();
50
+ performanceNotableMs = (_options$performance$ = (_options$performance = options.performance) == null ? void 0 : _options$performance.notableMs) != null ? _options$performance$ : 100;
51
+ performanceShowWrapperMeasures = (_options$performance$2 = (_options$performance2 = options.performance) == null ? void 0 : _options$performance2.showWrapperMeasures) != null ? _options$performance$2 : false;
52
+ relativePath = path.relative(this.rootContext || process.cwd(), this.resourcePath);
53
+ observer = undefined;
54
+ if ((_options$performance3 = options.performance) != null && _options$performance3.logging) {
55
+ observer = new PerformanceObserver(createPerformanceLogger(performanceNotableMs, performanceShowWrapperMeasures, relativePath));
56
+ observer.observe({
57
+ entryTypes: ['measure']
58
+ });
59
+ }
60
+ currentMark = performanceMeasure(undefined, {
61
+ mark: 'Start',
62
+ measure: 'Start'
63
+ }, [functionName, relativePath], true);
38
64
  _context2.p = 1;
39
65
  _context2.n = 2;
40
66
  return parseCreateFactoryCall(source, this.resourcePath);
41
67
  case 2:
42
68
  demoCall = _context2.v;
69
+ currentMark = performanceMeasure(currentMark, {
70
+ mark: 'Parsed Factory',
71
+ measure: 'Factory Parsing'
72
+ }, [functionName, relativePath]);
73
+
74
+ // If no createDemo call found, return the source unchanged
43
75
  if (demoCall) {
44
76
  _context2.n = 3;
45
77
  break;
@@ -61,6 +93,11 @@ function _loadPrecomputedCodeHighlighter() {
61
93
  return resolveVariantPathsWithFs(demoCall.variants || {});
62
94
  case 5:
63
95
  resolvedVariantMap = _context2.v;
96
+ currentMark = performanceMeasure(currentMark, {
97
+ mark: 'Paths Resolved',
98
+ measure: 'Path Resolution'
99
+ }, [functionName, relativePath]);
100
+
64
101
  // Create loader functions
65
102
  loadSource = createLoadServerSource({
66
103
  includeDependencies: true,
@@ -69,15 +106,26 @@ function _loadPrecomputedCodeHighlighter() {
69
106
  // const sourceTransformers: SourceTransformers = [TypescriptToJavascriptTransformer];
70
107
  // TODO: maybe we should have `loadPrecomputedCodeHighlighterWithJsToTs`
71
108
  sourceTransformers = []; // Create sourceParser promise for syntax highlighting
72
- sourceParser = createParseSource(); // Process variants in parallel
109
+ sourceParser = createParseSource();
110
+ functionsInitMark = performanceMeasure(currentMark, {
111
+ mark: 'Functions Init',
112
+ measure: 'Functions Init'
113
+ }, [functionName, relativePath]);
114
+ currentMark = functionsInitMark;
115
+
116
+ // Process variants in parallel
73
117
  variantPromises = Array.from(resolvedVariantMap.entries()).map(/*#__PURE__*/function () {
74
118
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
75
119
  var _demoCall$namedExport;
76
- var _ref3, variantName, fileUrl, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadCodeVarian, processedVariant, dependencies, _t;
120
+ var _ref3, variantName, fileUrl, variantMark, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadCodeVarian, processedVariant, dependencies, _t;
77
121
  return _regenerator().w(function (_context) {
78
122
  while (1) switch (_context.p = _context.n) {
79
123
  case 0:
80
124
  _ref3 = _slicedToArray(_ref, 2), variantName = _ref3[0], fileUrl = _ref3[1];
125
+ variantMark = performanceMeasure(functionsInitMark, {
126
+ mark: 'Variant Started',
127
+ measure: 'Variant Start'
128
+ }, [functionName, variantName, relativePath], true);
81
129
  namedExport = (_demoCall$namedExport = demoCall.namedExports) == null ? void 0 : _demoCall$namedExport[variantName];
82
130
  variant = fileUrl;
83
131
  if (!namedExport) {
@@ -116,6 +164,10 @@ function _loadPrecomputedCodeHighlighter() {
116
164
  _yield$loadCodeVarian = _context.v;
117
165
  processedVariant = _yield$loadCodeVarian.code;
118
166
  dependencies = _yield$loadCodeVarian.dependencies;
167
+ performanceMeasure(variantMark, {
168
+ mark: 'Variant Loaded',
169
+ measure: 'Variant Loading'
170
+ }, [functionName, variantName, relativePath], true);
119
171
  return _context.a(2, {
120
172
  variantName: variantName,
121
173
  variantData: processedVariant,
@@ -151,24 +203,45 @@ function _loadPrecomputedCodeHighlighter() {
151
203
  });
152
204
  }
153
205
  }
154
-
155
- // Replace the factory function call with the actual precomputed data
156
206
  } catch (err) {
157
207
  _iterator.e(err);
158
208
  } finally {
159
209
  _iterator.f();
160
210
  }
161
- modifiedSource = replacePrecomputeValue(source, variantData, demoCall); // Add all dependencies to webpack's watch list
211
+ currentMark = performanceMeasure(functionsInitMark, {
212
+ mark: 'All Variants Loaded',
213
+ measure: 'Complete Variants Loading'
214
+ }, [functionName, relativePath], true);
215
+
216
+ // Replace the factory function call with the actual precomputed data
217
+ modifiedSource = replacePrecomputeValue(source, variantData, demoCall);
218
+ currentMark = performanceMeasure(currentMark, {
219
+ mark: 'Replaced Precompute',
220
+ measure: 'Precompute Replacement'
221
+ }, [functionName, relativePath]);
222
+
223
+ // Add all dependencies to webpack's watch list
162
224
  allDependencies.forEach(function (dep) {
163
225
  // Strip 'file://' prefix if present before adding to webpack's dependency tracking
164
226
  _this.addDependency(dep.startsWith('file://') ? dep.slice(7) : dep);
165
227
  });
228
+
229
+ // log any pending performance entries before completing
230
+ (_observer = observer) == null || (_observer = _observer.takeRecords()) == null || _observer.forEach(function (entry) {
231
+ return logPerformance(entry, performanceNotableMs, performanceShowWrapperMeasures, relativePath);
232
+ });
233
+ (_observer2 = observer) == null || _observer2.disconnect();
166
234
  callback(null, modifiedSource);
167
235
  _context2.n = 8;
168
236
  break;
169
237
  case 7:
170
238
  _context2.p = 7;
171
239
  _t2 = _context2.v;
240
+ // log any pending performance entries before completing
241
+ (_observer3 = observer) == null || (_observer3 = _observer3.takeRecords()) == null || _observer3.forEach(function (entry) {
242
+ return logPerformance(entry, performanceNotableMs, performanceShowWrapperMeasures, relativePath);
243
+ });
244
+ (_observer4 = observer) == null || _observer4.disconnect();
172
245
  callback(_t2 instanceof Error ? _t2 : new Error(String(_t2)));
173
246
  case 8:
174
247
  return _context2.a(2);
@@ -0,0 +1,30 @@
1
+ export declare function logPerformance(entry: PerformanceEntry, notableMs: number, showWrapperMeasures: boolean, filterContext?: string): void;
2
+ export declare function createPerformanceLogger(notableMs: number, showWrapperMeasures: boolean, filterContext?: string): PerformanceObserverCallback;
3
+ export declare function nameMark(functionName: string, event: string, context: string[], wrapper?: boolean): string;
4
+ /**
5
+ * Helper to create a performance mark and measure in one call.
6
+ *
7
+ * @param startMark - Optional start mark name for the measure (typically currentMark)
8
+ * @param names - Object with mark and measure names
9
+ * @param context - Array of context strings [functionName, ...context]
10
+ * @param wrapper - Whether this is a wrapper measure (uses pipe delimiter)
11
+ * @returns The mark name that was created
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * currentMark = performanceMeasure(
16
+ * currentMark,
17
+ * { mark: 'processed', measure: 'processing' },
18
+ * [functionName, relativePath],
19
+ * true,
20
+ * );
21
+ * ```
22
+ */
23
+ export declare function performanceMeasure(startMark: string | undefined, names: {
24
+ mark: string;
25
+ measure: string;
26
+ } | {
27
+ prefix?: string;
28
+ mark: string;
29
+ measure: string;
30
+ }, context: string[], wrapper?: boolean): string;
@@ -0,0 +1,77 @@
1
+ import _arrayLikeToArray from "@babel/runtime/helpers/esm/arrayLikeToArray";
2
+ import _toArray from "@babel/runtime/helpers/esm/toArray";
3
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
+ export function logPerformance(entry, notableMs, showWrapperMeasures, filterContext) {
5
+ if (entry.duration < notableMs) {
6
+ return;
7
+ }
8
+
9
+ // If filterContext is provided, only log entries that include it
10
+ if (filterContext && !entry.name.includes(filterContext)) {
11
+ return;
12
+ }
13
+ var delim = '-';
14
+ var message = entry.name;
15
+ if (message.startsWith('| ')) {
16
+ if (!showWrapperMeasures) {
17
+ return;
18
+ }
19
+ delim = '|';
20
+ message = message.slice(2);
21
+ }
22
+ var duration = Math.round(entry.duration).toString().padStart(4, ' ');
23
+ console.warn("".concat(duration, "ms ").concat(delim, " ").concat(message));
24
+ }
25
+ export function createPerformanceLogger(notableMs, showWrapperMeasures, filterContext) {
26
+ var performanceLogger = function performanceLogger(list) {
27
+ var _iterator = _createForOfIteratorHelper(list.getEntries()),
28
+ _step;
29
+ try {
30
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
31
+ var entry = _step.value;
32
+ logPerformance(entry, notableMs, showWrapperMeasures, filterContext);
33
+ }
34
+ } catch (err) {
35
+ _iterator.e(err);
36
+ } finally {
37
+ _iterator.f();
38
+ }
39
+ };
40
+ return performanceLogger;
41
+ }
42
+ export function nameMark(functionName, event, context) {
43
+ var wrapper = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
44
+ return "".concat(wrapper ? '| ' : '').concat(functionName, " ").concat(wrapper ? '|' : '-', " ").concat(event, " - ").concat(context.join(' - '));
45
+ }
46
+
47
+ /**
48
+ * Helper to create a performance mark and measure in one call.
49
+ *
50
+ * @param startMark - Optional start mark name for the measure (typically currentMark)
51
+ * @param names - Object with mark and measure names
52
+ * @param context - Array of context strings [functionName, ...context]
53
+ * @param wrapper - Whether this is a wrapper measure (uses pipe delimiter)
54
+ * @returns The mark name that was created
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * currentMark = performanceMeasure(
59
+ * currentMark,
60
+ * { mark: 'processed', measure: 'processing' },
61
+ * [functionName, relativePath],
62
+ * true,
63
+ * );
64
+ * ```
65
+ */
66
+ export function performanceMeasure(startMark, names, context) {
67
+ var wrapper = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
68
+ var _context = _toArray(context),
69
+ functionName = _context[0],
70
+ restContext = _arrayLikeToArray(_context).slice(1);
71
+ var prefix = 'prefix' in names && names.prefix ? "".concat(names.prefix, " ") : '';
72
+ var markName = nameMark(functionName, "".concat(prefix).concat(names.mark), restContext, wrapper);
73
+ var measureName = nameMark(functionName, "".concat(prefix).concat(names.measure), restContext, wrapper);
74
+ performance.mark(markName);
75
+ performance.measure(measureName, startMark, markName);
76
+ return markName;
77
+ }
@@ -0,0 +1,2 @@
1
+ import { transformMarkdownBlockquoteCallouts } from "./transformMarkdownBlockquoteCallouts.js";
2
+ export default transformMarkdownBlockquoteCallouts;
@@ -0,0 +1,4 @@
1
+ // This is the export format expected by a remark plugin.
2
+
3
+ import { transformMarkdownBlockquoteCallouts } from "./transformMarkdownBlockquoteCallouts.js";
4
+ export default transformMarkdownBlockquoteCallouts;