@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
@@ -2,16 +2,24 @@ 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
- import { loadVariant } from "../../CodeHighlighter/loadVariant.js";
5
+ // webpack does not like node: imports
6
+ // eslint-disable-next-line n/prefer-node-protocol
7
+ import path from 'path';
8
+ // eslint-disable-next-line n/prefer-node-protocol
9
+ import { fileURLToPath, pathToFileURL } from 'url';
10
+ import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
6
11
  import { createParseSource } from "../parseSource/index.js";
7
12
  // TODO: re-enable following benchmarking
8
13
  // import { TypescriptToJavascriptTransformer } from '../transformTypescriptToJavascript';
9
14
 
10
15
  import { parseCreateFactoryCall } from "./parseCreateFactoryCall.js";
11
- import { resolveVariantPathsWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
16
+ import { resolveVariantPathsWithFs } from "../loadServerCodeMeta/resolveModulePathWithFs.js";
12
17
  import { replacePrecomputeValue } from "./replacePrecomputeValue.js";
13
18
  import { createLoadServerSource } from "../loadServerSource/index.js";
14
19
  import { getFileNameFromUrl } from "../loaderUtils/index.js";
20
+ import { createPerformanceLogger, logPerformance, performanceMeasure } from "./performanceLogger.js";
21
+ var functionName = 'Load Precomputed Code Highlighter';
22
+
15
23
  /**
16
24
  * Webpack loader that processes demo files and precomputes variant data.
17
25
  *
@@ -28,18 +36,46 @@ export function loadPrecomputedCodeHighlighter(_x) {
28
36
  }
29
37
  function _loadPrecomputedCodeHighlighter() {
30
38
  _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;
39
+ var _options$performance$,
40
+ _options$performance,
41
+ _options$performance$2,
42
+ _options$performance2,
43
+ _options$performance3,
44
+ _this = this;
45
+ var callback, options, performanceNotableMs, performanceShowWrapperMeasures, relativePath, observer, currentMark, resourceFileUrl, _observer, _observer2, demoCall, variantData, allDependencies, resolvedVariantMap, loadSource, sourceTransformers, sourceParser, functionsInitMark, variantPromises, variantResults, _iterator, _step, result, modifiedSource, _observer3, _observer4, _t2;
33
46
  return _regenerator().w(function (_context2) {
34
47
  while (1) switch (_context2.p = _context2.n) {
35
48
  case 0:
36
49
  callback = this.async();
37
50
  this.cacheable();
51
+ options = this.getOptions();
52
+ performanceNotableMs = (_options$performance$ = (_options$performance = options.performance) == null ? void 0 : _options$performance.notableMs) != null ? _options$performance$ : 100;
53
+ performanceShowWrapperMeasures = (_options$performance$2 = (_options$performance2 = options.performance) == null ? void 0 : _options$performance2.showWrapperMeasures) != null ? _options$performance$2 : false;
54
+ relativePath = path.relative(this.rootContext || process.cwd(), this.resourcePath);
55
+ observer = undefined;
56
+ if ((_options$performance3 = options.performance) != null && _options$performance3.logging) {
57
+ observer = new PerformanceObserver(createPerformanceLogger(performanceNotableMs, performanceShowWrapperMeasures, relativePath));
58
+ observer.observe({
59
+ entryTypes: ['measure']
60
+ });
61
+ }
62
+ currentMark = performanceMeasure(undefined, {
63
+ mark: 'Start',
64
+ measure: 'Start'
65
+ }, [functionName, relativePath], true); // Convert the filesystem path to a file:// URL for cross-platform compatibility
66
+ // pathToFileURL handles Windows drive letters correctly (e.g., C:\... → file:///C:/...)
67
+ resourceFileUrl = pathToFileURL(this.resourcePath).toString();
38
68
  _context2.p = 1;
39
69
  _context2.n = 2;
40
- return parseCreateFactoryCall(source, this.resourcePath);
70
+ return parseCreateFactoryCall(source, resourceFileUrl);
41
71
  case 2:
42
72
  demoCall = _context2.v;
73
+ currentMark = performanceMeasure(currentMark, {
74
+ mark: 'Parsed Factory',
75
+ measure: 'Factory Parsing'
76
+ }, [functionName, relativePath]);
77
+
78
+ // If no createDemo call found, return the source unchanged
43
79
  if (demoCall) {
44
80
  _context2.n = 3;
45
81
  break;
@@ -61,6 +97,11 @@ function _loadPrecomputedCodeHighlighter() {
61
97
  return resolveVariantPathsWithFs(demoCall.variants || {});
62
98
  case 5:
63
99
  resolvedVariantMap = _context2.v;
100
+ currentMark = performanceMeasure(currentMark, {
101
+ mark: 'Paths Resolved',
102
+ measure: 'Path Resolution'
103
+ }, [functionName, relativePath]);
104
+
64
105
  // Create loader functions
65
106
  loadSource = createLoadServerSource({
66
107
  includeDependencies: true,
@@ -69,15 +110,26 @@ function _loadPrecomputedCodeHighlighter() {
69
110
  // const sourceTransformers: SourceTransformers = [TypescriptToJavascriptTransformer];
70
111
  // TODO: maybe we should have `loadPrecomputedCodeHighlighterWithJsToTs`
71
112
  sourceTransformers = []; // Create sourceParser promise for syntax highlighting
72
- sourceParser = createParseSource(); // Process variants in parallel
113
+ sourceParser = createParseSource();
114
+ functionsInitMark = performanceMeasure(currentMark, {
115
+ mark: 'Functions Init',
116
+ measure: 'Functions Init'
117
+ }, [functionName, relativePath]);
118
+ currentMark = functionsInitMark;
119
+
120
+ // Process variants in parallel
73
121
  variantPromises = Array.from(resolvedVariantMap.entries()).map(/*#__PURE__*/function () {
74
122
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
75
123
  var _demoCall$namedExport;
76
- var _ref3, variantName, fileUrl, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadVariant, processedVariant, dependencies, _t;
124
+ var _ref3, variantName, fileUrl, variantMark, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadCodeVarian, processedVariant, dependencies, _t;
77
125
  return _regenerator().w(function (_context) {
78
126
  while (1) switch (_context.p = _context.n) {
79
127
  case 0:
80
128
  _ref3 = _slicedToArray(_ref, 2), variantName = _ref3[0], fileUrl = _ref3[1];
129
+ variantMark = performanceMeasure(functionsInitMark, {
130
+ mark: 'Variant Started',
131
+ measure: 'Variant Start'
132
+ }, [functionName, variantName, relativePath], true);
81
133
  namedExport = (_demoCall$namedExport = demoCall.namedExports) == null ? void 0 : _demoCall$namedExport[variantName];
82
134
  variant = fileUrl;
83
135
  if (!namedExport) {
@@ -99,7 +151,7 @@ function _loadPrecomputedCodeHighlighter() {
99
151
  case 2:
100
152
  _context.p = 2;
101
153
  _context.n = 3;
102
- return loadVariant(fileUrl,
154
+ return loadCodeVariant(fileUrl,
103
155
  // URL for the variant entry point (already includes file://)
104
156
  variantName, variant, {
105
157
  sourceParser: sourceParser,
@@ -113,9 +165,13 @@ function _loadPrecomputedCodeHighlighter() {
113
165
  output: _this.getOptions().output || 'hastGzip'
114
166
  });
115
167
  case 3:
116
- _yield$loadVariant = _context.v;
117
- processedVariant = _yield$loadVariant.code;
118
- dependencies = _yield$loadVariant.dependencies;
168
+ _yield$loadCodeVarian = _context.v;
169
+ processedVariant = _yield$loadCodeVarian.code;
170
+ dependencies = _yield$loadCodeVarian.dependencies;
171
+ performanceMeasure(variantMark, {
172
+ mark: 'Variant Loaded',
173
+ measure: 'Variant Loading'
174
+ }, [functionName, variantName, relativePath], true);
119
175
  return _context.a(2, {
120
176
  variantName: variantName,
121
177
  variantData: processedVariant,
@@ -151,24 +207,46 @@ function _loadPrecomputedCodeHighlighter() {
151
207
  });
152
208
  }
153
209
  }
154
-
155
- // Replace the factory function call with the actual precomputed data
156
210
  } catch (err) {
157
211
  _iterator.e(err);
158
212
  } finally {
159
213
  _iterator.f();
160
214
  }
161
- modifiedSource = replacePrecomputeValue(source, variantData, demoCall); // Add all dependencies to webpack's watch list
215
+ currentMark = performanceMeasure(functionsInitMark, {
216
+ mark: 'All Variants Loaded',
217
+ measure: 'Complete Variants Loading'
218
+ }, [functionName, relativePath], true);
219
+
220
+ // Replace the factory function call with the actual precomputed data
221
+ modifiedSource = replacePrecomputeValue(source, variantData, demoCall);
222
+ currentMark = performanceMeasure(currentMark, {
223
+ mark: 'Replaced Precompute',
224
+ measure: 'Precompute Replacement'
225
+ }, [functionName, relativePath]);
226
+
227
+ // Add all dependencies to webpack's watch list
162
228
  allDependencies.forEach(function (dep) {
163
- // Strip 'file://' prefix if present before adding to webpack's dependency tracking
164
- _this.addDependency(dep.startsWith('file://') ? dep.slice(7) : dep);
229
+ // Convert file:// URLs to proper file system paths for webpack's dependency tracking
230
+ // Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... C:\...)
231
+ _this.addDependency(dep.startsWith('file://') ? fileURLToPath(dep) : dep);
165
232
  });
233
+
234
+ // log any pending performance entries before completing
235
+ (_observer = observer) == null || (_observer = _observer.takeRecords()) == null || _observer.forEach(function (entry) {
236
+ return logPerformance(entry, performanceNotableMs, performanceShowWrapperMeasures, relativePath);
237
+ });
238
+ (_observer2 = observer) == null || _observer2.disconnect();
166
239
  callback(null, modifiedSource);
167
240
  _context2.n = 8;
168
241
  break;
169
242
  case 7:
170
243
  _context2.p = 7;
171
244
  _t2 = _context2.v;
245
+ // log any pending performance entries before completing
246
+ (_observer3 = observer) == null || (_observer3 = _observer3.takeRecords()) == null || _observer3.forEach(function (entry) {
247
+ return logPerformance(entry, performanceNotableMs, performanceShowWrapperMeasures, relativePath);
248
+ });
249
+ (_observer4 = observer) == null || _observer4.disconnect();
172
250
  callback(_t2 instanceof Error ? _t2 : new Error(String(_t2)));
173
251
  case 8:
174
252
  return _context2.a(2);
@@ -254,19 +254,19 @@ function parseVariantsObjectFromObject(obj, importMap, namedExportsMap, function
254
254
 
255
255
  /**
256
256
  * Helper function to convert the new parseImportsAndComments format to a Map
257
- * that maps import names to their resolved paths
257
+ * that maps import names to their resolved URLs
258
258
  */
259
259
  function buildImportMap(importResult, allowExternalVariants) {
260
260
  var importMap = new Map();
261
261
  Object.values(importResult.relative).forEach(function (_ref) {
262
- var path = _ref.path,
262
+ var url = _ref.url,
263
263
  names = _ref.names;
264
264
  names.forEach(function (_ref2) {
265
265
  var name = _ref2.name,
266
266
  alias = _ref2.alias;
267
267
  // Use alias if available, otherwise use the original name
268
268
  var nameToUse = alias || name;
269
- importMap.set(nameToUse, path);
269
+ importMap.set(nameToUse, url);
270
270
  });
271
271
  });
272
272
 
@@ -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
+ }
@@ -5,11 +5,15 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
5
  // webpack does not like node: imports
6
6
  // eslint-disable-next-line n/prefer-node-protocol
7
7
  import { readFile } from 'fs/promises';
8
+ // eslint-disable-next-line n/prefer-node-protocol
9
+ import path from 'path';
10
+ // eslint-disable-next-line n/prefer-node-protocol
11
+ import { fileURLToPath, pathToFileURL } from 'url';
8
12
  import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
9
13
  import { generateResolvedExternals } from "./generateResolvedExternals.js";
10
- import { loadVariant } from "../../CodeHighlighter/loadVariant.js";
14
+ import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
11
15
  import { createLoadServerSource } from "../loadServerSource/index.js";
12
- import { resolveVariantPathsWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
16
+ import { resolveVariantPathsWithFs } from "../loadServerCodeMeta/resolveModulePathWithFs.js";
13
17
  import { getFileNameFromUrl } from "../loaderUtils/index.js";
14
18
  import { mergeExternals } from "../loaderUtils/mergeExternals.js";
15
19
  import { filterRuntimeExternals } from "./filterRuntimeExternals.js";
@@ -34,15 +38,19 @@ export function loadPrecomputedCodeHighlighterClient(_x) {
34
38
  function _loadPrecomputedCodeHighlighterClient() {
35
39
  _loadPrecomputedCodeHighlighterClient = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(source) {
36
40
  var _this = this;
37
- var callback, demoCall, allDependencies, allExternalsArray, clientDir, indexPath, indexDemoCall, indexSource, resolvedVariantMap, loadSource, variantPromises, variantResults, _iterator, _step, result, allExternals, runtimeExternals, _generateResolvedExte, importLines, resolvedExternals, precomputeData, modifiedSource, _t2, _t3;
41
+ var callback, resourceFileUrl, demoCall, allDependencies, allExternalsArray, clientDir, indexPath, indexFileUrl, indexDemoCall, indexSource, resolvedVariantMap, loadSource, variantPromises, variantResults, _iterator, _step, result, allExternals, runtimeExternals, _generateResolvedExte, importLines, resolvedExternals, precomputeData, modifiedSource, _t2, _t3;
38
42
  return _regenerator().w(function (_context2) {
39
43
  while (1) switch (_context2.p = _context2.n) {
40
44
  case 0:
41
45
  callback = this.async();
42
46
  this.cacheable();
43
47
  _context2.p = 1;
48
+ // Convert the filesystem path to a file:// URL for cross-platform compatibility
49
+ // pathToFileURL handles Windows drive letters correctly (e.g., C:\... → file:///C:/...)
50
+ resourceFileUrl = pathToFileURL(this.resourcePath).toString(); // Parse the source to find a single createDemoClient call
51
+ // Use metadataOnly mode since client calls only have (url, options?) arguments
44
52
  _context2.n = 2;
45
- return parseCreateFactoryCall(source, this.resourcePath, {
53
+ return parseCreateFactoryCall(source, resourceFileUrl, {
46
54
  metadataOnly: true
47
55
  });
48
56
  case 2:
@@ -72,8 +80,9 @@ function _loadPrecomputedCodeHighlighterClient() {
72
80
  allDependencies = [];
73
81
  allExternalsArray = []; // For client files, we need to read the corresponding index.ts to get variants
74
82
  // The client.ts and index.ts should be in the same directory
75
- clientDir = this.resourcePath.substring(0, this.resourcePath.lastIndexOf('/'));
76
- indexPath = "".concat(clientDir, "/index.ts"); // Read and parse the index.ts file to get variant information
83
+ clientDir = path.dirname(this.resourcePath);
84
+ indexPath = path.join(clientDir, 'index.ts'); // Convert to file:// URL for parseCreateFactoryCall
85
+ indexFileUrl = pathToFileURL(indexPath).toString(); // Read and parse the index.ts file to get variant information
77
86
  indexDemoCall = null;
78
87
  _context2.p = 6;
79
88
  _context2.n = 7;
@@ -83,7 +92,7 @@ function _loadPrecomputedCodeHighlighterClient() {
83
92
  // Add index.ts as a dependency for hot reloading
84
93
  this.addDependency(indexPath);
85
94
  _context2.n = 8;
86
- return parseCreateFactoryCall(indexSource, indexPath);
95
+ return parseCreateFactoryCall(indexSource, indexFileUrl);
87
96
  case 8:
88
97
  indexDemoCall = _context2.v;
89
98
  _context2.n = 10;
@@ -116,7 +125,7 @@ function _loadPrecomputedCodeHighlighterClient() {
116
125
  variantPromises = Array.from(resolvedVariantMap.entries()).map(/*#__PURE__*/function () {
117
126
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
118
127
  var _indexDemoCall$namedE;
119
- var _ref3, variantName, fileUrl, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadVariant, dependencies, externals, _t;
128
+ var _ref3, variantName, fileUrl, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadCodeVarian, dependencies, externals, _t;
120
129
  return _regenerator().w(function (_context) {
121
130
  while (1) switch (_context.p = _context.n) {
122
131
  case 0:
@@ -142,7 +151,7 @@ function _loadPrecomputedCodeHighlighterClient() {
142
151
  case 2:
143
152
  _context.p = 2;
144
153
  _context.n = 3;
145
- return loadVariant(fileUrl,
154
+ return loadCodeVariant(fileUrl,
146
155
  // URL for the variant entry point (already includes file://)
147
156
  variantName, variant, {
148
157
  loadSource: loadSource,
@@ -152,9 +161,9 @@ function _loadPrecomputedCodeHighlighterClient() {
152
161
  disableTransforms: true
153
162
  });
154
163
  case 3:
155
- _yield$loadVariant = _context.v;
156
- dependencies = _yield$loadVariant.dependencies;
157
- externals = _yield$loadVariant.externals;
164
+ _yield$loadCodeVarian = _context.v;
165
+ dependencies = _yield$loadCodeVarian.dependencies;
166
+ externals = _yield$loadCodeVarian.externals;
158
167
  return _context.a(2, {
159
168
  variantName: variantName,
160
169
  dependencies: dependencies,
@@ -213,8 +222,9 @@ function _loadPrecomputedCodeHighlighterClient() {
213
222
 
214
223
  // Add all dependencies to webpack's watch list
215
224
  allDependencies.forEach(function (dep) {
216
- // Strip 'file://' prefix if present before adding to webpack's dependency tracking
217
- _this.addDependency(dep.startsWith('file://') ? dep.slice(7) : dep);
225
+ // Convert file:// URLs to proper file system paths for webpack's dependency tracking
226
+ // Using fileURLToPath handles Windows drive letters correctly (e.g., file:///C:/... C:\...)
227
+ _this.addDependency(dep.startsWith('file://') ? fileURLToPath(dep) : dep);
218
228
  });
219
229
  callback(null, modifiedSource);
220
230
  _context2.n = 15;
@@ -0,0 +1,2 @@
1
+ import { loadPrecomputedSitemap } from "./loadPrecomputedSitemap.js";
2
+ export default loadPrecomputedSitemap;
@@ -0,0 +1,4 @@
1
+ // This is export format a Webpack / Turbopack loader expects
2
+
3
+ import { loadPrecomputedSitemap } from "./loadPrecomputedSitemap.js";
4
+ export default loadPrecomputedSitemap;
@@ -0,0 +1,10 @@
1
+ import type { LoaderContext } from 'webpack';
2
+ export type LoaderOptions = {
3
+ performance?: {
4
+ logging?: boolean;
5
+ notableMs?: number;
6
+ showWrapperMeasures?: boolean;
7
+ significantDependencyCountThreshold?: number;
8
+ };
9
+ };
10
+ export declare function loadPrecomputedSitemap(this: LoaderContext<LoaderOptions>, source: string): Promise<void>;