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

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 (60) hide show
  1. package/esm/CodeHighlighter/CodeHighlighter.js +16 -16
  2. package/esm/CodeHighlighter/CodeHighlighterClient.js +33 -33
  3. package/esm/CodeHighlighter/errors.js +3 -3
  4. package/esm/CodeHighlighter/types.d.ts +1 -1
  5. package/esm/CodeProvider/CodeContext.d.ts +4 -4
  6. package/esm/CodeProvider/CodeProvider.js +7 -7
  7. package/esm/{CodeHighlighter/addPathsToVariant.d.ts → pipeline/loadCodeVariant/addCodeVariantPaths.d.ts} +1 -1
  8. package/esm/{CodeHighlighter/applyTransform.d.ts → pipeline/loadCodeVariant/applyCodeTransform.d.ts} +3 -3
  9. package/esm/{CodeHighlighter/applyTransform.js → pipeline/loadCodeVariant/applyCodeTransform.js} +4 -4
  10. package/esm/{CodeHighlighter/transformCode.d.ts → pipeline/loadCodeVariant/computeHastDeltas.d.ts} +9 -5
  11. package/esm/{CodeHighlighter/transformCode.js → pipeline/loadCodeVariant/computeHastDeltas.js} +20 -16
  12. package/esm/pipeline/loadCodeVariant/diffHast.d.ts +3 -0
  13. package/esm/{CodeHighlighter/transformParsedSource.js → pipeline/loadCodeVariant/diffHast.js} +5 -5
  14. package/esm/{CodeHighlighter/examineVariant.d.ts → pipeline/loadCodeVariant/examineCodeVariant.d.ts} +2 -2
  15. package/esm/{CodeHighlighter/examineVariant.js → pipeline/loadCodeVariant/examineCodeVariant.js} +1 -1
  16. package/esm/{useDemo/flattenVariant.d.ts → pipeline/loadCodeVariant/flattenCodeVariant.d.ts} +2 -2
  17. package/esm/{useDemo/flattenVariant.js → pipeline/loadCodeVariant/flattenCodeVariant.js} +3 -3
  18. package/esm/{CodeHighlighter/hasAllVariants.d.ts → pipeline/loadCodeVariant/hasAllCodeVariants.d.ts} +1 -1
  19. package/esm/pipeline/loadCodeVariant/index.d.ts +10 -0
  20. package/esm/pipeline/loadCodeVariant/index.js +17 -0
  21. package/esm/{CodeHighlighter/loadFallbackCode.d.ts → pipeline/loadCodeVariant/loadCodeFallback.d.ts} +2 -2
  22. package/esm/{CodeHighlighter/loadFallbackCode.js → pipeline/loadCodeVariant/loadCodeFallback.js} +16 -16
  23. package/esm/{CodeHighlighter/loadVariant.d.ts → pipeline/loadCodeVariant/loadCodeVariant.d.ts} +2 -2
  24. package/esm/{CodeHighlighter/loadVariant.js → pipeline/loadCodeVariant/loadCodeVariant.js} +11 -11
  25. package/esm/{CodeHighlighter/maybeInitialData.d.ts → pipeline/loadCodeVariant/maybeCodeInitialData.d.ts} +6 -6
  26. package/esm/{CodeHighlighter/maybeInitialData.js → pipeline/loadCodeVariant/maybeCodeInitialData.js} +6 -6
  27. package/esm/{CodeHighlighter/mergeMetadata.d.ts → pipeline/loadCodeVariant/mergeCodeMetadata.d.ts} +3 -3
  28. package/esm/{CodeHighlighter/mergeMetadata.js → pipeline/loadCodeVariant/mergeCodeMetadata.js} +3 -3
  29. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.d.ts +1 -1
  30. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.d.ts +1 -1
  31. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +7 -7
  32. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +7 -7
  33. package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
  34. package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
  35. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
  36. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +2 -2
  37. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +1 -1
  38. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +1 -1
  39. package/esm/pipeline/loadServerSource/loadServerSource.js +1 -1
  40. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
  41. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
  42. package/esm/useCode/useCodeUtils.js +3 -3
  43. package/esm/useDemo/createCodeSandbox.d.ts +1 -1
  44. package/esm/useDemo/createStackBlitz.d.ts +1 -1
  45. package/esm/useDemo/exportVariant.js +13 -11
  46. package/esm/useDemo/index.d.ts +1 -1
  47. package/esm/useDemo/index.js +1 -1
  48. package/esm/useDemo/useDemo.d.ts +3 -3
  49. package/esm/useDemo/useDemo.js +6 -6
  50. package/esm/withDocsInfra/withDeploymentConfig.js +2 -1
  51. package/package.json +8 -2
  52. package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
  53. /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
  54. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
  55. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.js +0 -0
  56. /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
  57. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
  58. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
  59. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
  60. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.js +0 -0
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
5
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
6
6
  import { visit } from 'unist-util-visit';
7
- import { loadVariant } from "../../CodeHighlighter/loadVariant.js";
7
+ import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
8
8
  import { createParseSource } from "../parseSource/index.js";
9
9
  import { TypescriptToJavascriptTransformer } from "../transformTypescriptToJavascript/index.js";
10
10
  /**
@@ -206,13 +206,13 @@ function extractFromDl(dl) {
206
206
  }
207
207
 
208
208
  /**
209
- * Rehype plugin that transforms semantic HTML code structures to use loadVariant
209
+ * Rehype plugin that transforms semantic HTML code structures to use loadCodeVariant
210
210
  *
211
211
  * This plugin:
212
212
  * 1. Finds section and dl elements in the HTML AST
213
213
  * 2. Extracts code elements from the semantic structure (figure/dl/dd/pre/code)
214
214
  * 3. Creates variants from multiple code elements or single Default variant
215
- * 4. Uses loadVariant to process each variant
215
+ * 4. Uses loadCodeVariant to process each variant
216
216
  * 5. Stores the combined precompute data on the root element
217
217
  * 6. Clears all code element contents and replaces with error message
218
218
  */
@@ -307,7 +307,7 @@ export var transformHtmlCodePrecomputed = function transformHtmlCodePrecomputed(
307
307
  });
308
308
  }
309
309
 
310
- // Process each variant with loadVariant
310
+ // Process each variant with loadCodeVariant
311
311
  processedCode = {};
312
312
  variantPromises = Object.entries(variants).map(/*#__PURE__*/function () {
313
313
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref4) {
@@ -321,7 +321,7 @@ export var transformHtmlCodePrecomputed = function transformHtmlCodePrecomputed(
321
321
  break;
322
322
  }
323
323
  _context.n = 1;
324
- return loadVariant(undefined,
324
+ return loadCodeVariant(undefined,
325
325
  // url - not needed for inline code
326
326
  variantName, variantData, {
327
327
  sourceParser: sourceParser,
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _typeof from "@babel/runtime/helpers/esm/typeof";
3
3
  import { stringOrHastToJsx } from "../pipeline/hastUtils/index.js";
4
- import { applyTransform } from "../CodeHighlighter/applyTransform.js";
4
+ import { applyCodeTransform } from "../pipeline/loadCodeVariant/applyCodeTransform.js";
5
5
  /**
6
6
  * Pure function to get available transforms from effective code data.
7
7
  * Only includes transforms that have actual deltas (file changes), not just filename changes.
@@ -94,7 +94,7 @@ export function applyTransformToSource(source, fileName, transforms, selectedTra
94
94
  }
95
95
 
96
96
  // Apply transform
97
- var result = applyTransform(source, transforms, selectedTransform);
97
+ var result = applyCodeTransform(source, transforms, selectedTransform);
98
98
  var transformedName = transformData.fileName || fileName;
99
99
  return {
100
100
  transformedSource: result,
@@ -209,7 +209,7 @@ export function createTransformedFiles(selectedVariant, selectedTransform, shoul
209
209
  // Only apply transform if there's a meaningful delta
210
210
  var hasTransformDelta = transformData.delta && Object.keys(transformData.delta).length > 0;
211
211
  if (hasTransformDelta) {
212
- transformedSource = applyTransform(source, transforms, selectedTransform);
212
+ transformedSource = applyCodeTransform(source, transforms, selectedTransform);
213
213
  transformedName = transformData.fileName || extraFileName;
214
214
  }
215
215
  }
@@ -1,4 +1,4 @@
1
- import type { FlattenedFiles } from "./flattenVariant.js";
1
+ import type { FlattenedFiles } from "../pipeline/loadCodeVariant/flattenCodeVariant.js";
2
2
  /**
3
3
  * Utility function for creating CodeSandbox demos
4
4
  * Returns the configuration that can be used with openWithForm
@@ -2,7 +2,7 @@
2
2
  * Utility function for creating StackBlitz demos
3
3
  * Returns the configuration that can be used with openWithForm
4
4
  */
5
- import type { FlattenedFiles } from "./flattenVariant.js";
5
+ import type { FlattenedFiles } from "../pipeline/loadCodeVariant/flattenCodeVariant.js";
6
6
  /**
7
7
  * Create StackBlitz configuration for use with openWithForm
8
8
  */
@@ -7,8 +7,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
7
 
8
8
  import { externalsToPackages } from "../pipeline/loaderUtils/index.js";
9
9
  import { getFileNameFromUrl } from "../pipeline/loaderUtils/getFileNameFromUrl.js";
10
- import { createPathContext } from "../CodeHighlighter/examineVariant.js";
11
- import { mergeMetadata, extractMetadata } from "../CodeHighlighter/mergeMetadata.js";
10
+ import { examineCodeVariant } from "../pipeline/loadCodeVariant/examineCodeVariant.js";
11
+ import { mergeCodeMetadata, extractCodeMetadata } from "../pipeline/loadCodeVariant/mergeCodeMetadata.js";
12
12
 
13
13
  /**
14
14
  * Merges multiple file objects into a single object.
@@ -162,15 +162,17 @@ export function exportVariant(variantCode) {
162
162
  var finalTitle = [titlePrefix, title, titleSuffix].filter(Boolean).join('');
163
163
  var finalDescription = [descriptionPrefix, description, descriptionSuffix].filter(Boolean).join('');
164
164
 
165
- // Use extractMetadata to properly separate metadata and non-metadata files
166
- var _extractMetadata = extractMetadata(variantCode),
167
- processedVariantCode = _extractMetadata.variant,
168
- processedGlobals = _extractMetadata.metadata;
165
+ // Use extractCodeMetadata to properly separate metadata and non-metadata files
166
+ var _extractCodeMetadata = extractCodeMetadata(variantCode),
167
+ processedVariantCode = _extractCodeMetadata.variant,
168
+ processedGlobals = _extractCodeMetadata.metadata;
169
+
170
+ // Run optional transform hook to modify variant and globals before processing
169
171
  if (transformVariant) {
170
172
  var transformed = transformVariant(processedVariantCode, variantName, processedGlobals);
171
173
  if (transformed) {
172
174
  // Re-extract metadata after transformation
173
- var result = transformed.variant && extractMetadata(transformed.variant);
175
+ var result = transformed.variant && extractCodeMetadata(transformed.variant);
174
176
  processedVariantCode = (result == null ? void 0 : result.variant) || processedVariantCode;
175
177
 
176
178
  // Start fresh with only the new metadata and explicitly transformed globals
@@ -191,7 +193,7 @@ export function exportVariant(variantCode) {
191
193
  var sourceFilename = getFilenameFromVariant(processedVariantCode);
192
194
 
193
195
  // Get path context to understand navigation
194
- var pathContext = createPathContext(variantCode);
196
+ var pathContext = examineCodeVariant(variantCode);
195
197
 
196
198
  // Determine if we need to rename the source file
197
199
  var ext = useTypescript ? 'tsx' : 'jsx';
@@ -401,7 +403,7 @@ export function exportVariant(variantCode) {
401
403
  // Merge all metadata files including framework metadata and globals
402
404
  var allMetadataFiles = mergeFiles(processedGlobals || {}, metadataFiles, extraMetadataFiles, frameworkFiles.globals || {});
403
405
 
404
- // Merge all files using mergeMetadata to properly position everything with 'src/' (sourcePrefix opt) prefix
406
+ // Merge all files using mergeCodeMetadata to properly position everything with 'src/' (sourcePrefix opt) prefix
405
407
  var allSourceFilesWithFramework = mergeFiles(processedVariantCode.extraFiles || {}, generatedFiles, ((_frameworkFiles$varia = frameworkFiles.variant) == null ? void 0 : _frameworkFiles$varia.extraFiles) || {});
406
408
 
407
409
  // Update the variant with all source files including framework source files
@@ -409,8 +411,8 @@ export function exportVariant(variantCode) {
409
411
  extraFiles: allSourceFilesWithFramework
410
412
  });
411
413
 
412
- // Use mergeMetadata to position everything correctly
413
- var finalVariant = mergeMetadata(finalVariantWithSources, allMetadataFiles, {
414
+ // Use mergeCodeMetadata to position everything correctly
415
+ var finalVariant = mergeCodeMetadata(finalVariantWithSources, allMetadataFiles, {
414
416
  metadataPrefix: sourcePrefix
415
417
  });
416
418
 
@@ -1,6 +1,6 @@
1
1
  export * from "./useDemo.js";
2
2
  export * from "./createStackBlitz.js";
3
3
  export * from "./createCodeSandbox.js";
4
- export * from "./flattenVariant.js";
4
+ export * from "../pipeline/loadCodeVariant/flattenCodeVariant.js";
5
5
  export * from "./exportVariant.js";
6
6
  export * from "./exportVariantAsCra.js";
@@ -1,6 +1,6 @@
1
1
  export * from "./useDemo.js";
2
2
  export * from "./createStackBlitz.js";
3
3
  export * from "./createCodeSandbox.js";
4
- export * from "./flattenVariant.js";
4
+ export * from "../pipeline/loadCodeVariant/flattenCodeVariant.js";
5
5
  export * from "./exportVariant.js";
6
6
  export * from "./exportVariantAsCra.js";
@@ -3,16 +3,16 @@ import type { UseCodeOpts } from "../useCode/index.js";
3
3
  import type { ContentProps } from "../CodeHighlighter/types.js";
4
4
  import { type ExportConfig } from "./exportVariant.js";
5
5
  /**
6
- * Demo templates use the exportVariant/exportVariantAsCra with flattenVariant pattern:
6
+ * Demo templates use the exportVariant/exportVariantAsCra with flattenCodeVariant pattern:
7
7
  *
8
8
  * For StackBlitz:
9
9
  * const { exported: exportedVariant, entrypoint } = exportVariant(variantCode);
10
- * const flattenedFiles = flattenVariant(exportedVariant);
10
+ * const flattenedFiles = flattenCodeVariant(exportedVariant);
11
11
  * createStackBlitzDemo({ title, description, flattenedFiles, useTypescript, initialFile: entrypoint })
12
12
  *
13
13
  * For CodeSandbox:
14
14
  * const { exported: craExport, entrypoint } = exportVariantAsCra(variantCode, { title, description, useTypescript });
15
- * const flattenedFiles = flattenVariant(craExport);
15
+ * const flattenedFiles = flattenCodeVariant(craExport);
16
16
  * createCodeSandboxDemo({ title, description, flattenedFiles, useTypescript, initialFile: entrypoint })
17
17
  * createCodeSandboxDemo({ title, description, flattenedFiles, useTypescript })
18
18
  */
@@ -8,19 +8,19 @@ import { createStackBlitz } from "./createStackBlitz.js";
8
8
  import { createCodeSandbox } from "./createCodeSandbox.js";
9
9
  import { exportVariant } from "./exportVariant.js";
10
10
  import { exportVariantAsCra } from "./exportVariantAsCra.js";
11
- import { flattenVariant } from "./flattenVariant.js";
11
+ import { flattenCodeVariant } from "../pipeline/loadCodeVariant/flattenCodeVariant.js";
12
12
 
13
13
  /**
14
- * Demo templates use the exportVariant/exportVariantAsCra with flattenVariant pattern:
14
+ * Demo templates use the exportVariant/exportVariantAsCra with flattenCodeVariant pattern:
15
15
  *
16
16
  * For StackBlitz:
17
17
  * const { exported: exportedVariant, entrypoint } = exportVariant(variantCode);
18
- * const flattenedFiles = flattenVariant(exportedVariant);
18
+ * const flattenedFiles = flattenCodeVariant(exportedVariant);
19
19
  * createStackBlitzDemo({ title, description, flattenedFiles, useTypescript, initialFile: entrypoint })
20
20
  *
21
21
  * For CodeSandbox:
22
22
  * const { exported: craExport, entrypoint } = exportVariantAsCra(variantCode, { title, description, useTypescript });
23
- * const flattenedFiles = flattenVariant(craExport);
23
+ * const flattenedFiles = flattenCodeVariant(craExport);
24
24
  * createCodeSandboxDemo({ title, description, flattenedFiles, useTypescript, initialFile: entrypoint })
25
25
  * createCodeSandboxDemo({ title, description, flattenedFiles, useTypescript })
26
26
  */
@@ -133,7 +133,7 @@ export function useDemo(contentProps, opts) {
133
133
  rootFile = _exportFunction.rootFile;
134
134
 
135
135
  // Flatten the variant to get a flat file structure
136
- var flattenedFiles = flattenVariant(exported);
136
+ var flattenedFiles = flattenCodeVariant(exported);
137
137
  var stackBlitzDemo = createStackBlitz({
138
138
  title: title,
139
139
  description: description,
@@ -173,7 +173,7 @@ export function useDemo(contentProps, opts) {
173
173
  rootFile = _exportFunction2.rootFile;
174
174
 
175
175
  // Flatten the variant to get a flat file structure
176
- var flattenedFiles = flattenVariant(craExport);
176
+ var flattenedFiles = flattenCodeVariant(craExport);
177
177
  var codeSandboxDemo = createCodeSandbox({
178
178
  flattenedFiles: flattenedFiles,
179
179
  rootFile: rootFile
@@ -33,7 +33,8 @@ process.env.DEPLOY_ENV = DEPLOY_ENV;
33
33
  export function withDeploymentConfig(nextConfig) {
34
34
  return _extends(_extends({
35
35
  trailingSlash: true,
36
- reactStrictMode: true
36
+ reactStrictMode: true,
37
+ productionBrowserSourceMaps: true
37
38
  }, nextConfig), {}, {
38
39
  env: _extends(_extends({
39
40
  // production | staging | pull-request | development
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.2.3-canary.11",
3
+ "version": "0.2.3-canary.13",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "keywords": [
@@ -173,6 +173,12 @@
173
173
  "default": "./esm/pipeline/hastUtils/index.js"
174
174
  }
175
175
  },
176
+ "./pipeline/loadCodeVariant": {
177
+ "default": {
178
+ "types": "./esm/pipeline/loadCodeVariant/index.d.ts",
179
+ "default": "./esm/pipeline/loadCodeVariant/index.js"
180
+ }
181
+ },
176
182
  "./pipeline/loaderUtils": {
177
183
  "default": {
178
184
  "types": "./esm/pipeline/loaderUtils/index.d.ts",
@@ -229,5 +235,5 @@
229
235
  },
230
236
  "./esm": null
231
237
  },
232
- "gitSha": "fd9d593490ae2b177feb323402b9ba8f86bcf6d1"
238
+ "gitSha": "8b1850f1e23152917fcc1e97d123805cd99d6a31"
233
239
  }
@@ -1,3 +0,0 @@
1
- import type { Nodes } from 'hast';
2
- import { ParseSource, Transforms } from "./types.js";
3
- export declare function transformParsedSource(source: string, parsedSource: Nodes, filename: string, transforms: Transforms, parseSource: ParseSource): Promise<Record<string, any>>;