@mui/internal-docs-infra 0.2.0-alpha.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/esm/CodeHighlighter/CodeHighlighter.js +54 -39
  2. package/esm/CodeHighlighter/CodeHighlighterClient.js +77 -33
  3. package/esm/CodeHighlighter/errors.js +1 -1
  4. package/esm/CodeHighlighter/loadFallbackCode.js +6 -2
  5. package/esm/CodeHighlighter/loadVariant.js +64 -22
  6. package/esm/CodeHighlighter/maybeInitialData.d.ts +2 -2
  7. package/esm/CodeHighlighter/maybeInitialData.js +2 -2
  8. package/esm/CodeHighlighter/transformSource.js +57 -17
  9. package/esm/CodeHighlighter/types.d.ts +20 -3
  10. package/esm/abstractCreateDemo/abstractCreateDemo.d.ts +4 -2
  11. package/esm/abstractCreateDemo/abstractCreateDemo.js +2 -1
  12. package/esm/pipeline/hastUtils/hastUtils.d.ts +6 -0
  13. package/esm/pipeline/hastUtils/hastUtils.js +20 -0
  14. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +3 -1
  15. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +2 -1
  16. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +6 -4
  17. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +443 -258
  18. package/esm/pipeline/loadServerSource/loadServerSource.js +59 -19
  19. package/esm/pipeline/loaderUtils/index.d.ts +1 -1
  20. package/esm/pipeline/loaderUtils/index.js +1 -1
  21. package/esm/pipeline/loaderUtils/parseImportsAndComments.d.ts +91 -0
  22. package/esm/pipeline/loaderUtils/parseImportsAndComments.js +1329 -0
  23. package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +8 -3
  24. package/esm/pipeline/loaderUtils/processRelativeImports.js +237 -118
  25. package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +7 -3
  26. package/esm/pipeline/loaderUtils/resolveModulePath.js +3 -3
  27. package/esm/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +4 -0
  28. package/esm/pipeline/loaderUtils/rewriteImports.d.ts +12 -5
  29. package/esm/pipeline/loaderUtils/rewriteImports.js +56 -26
  30. package/esm/pipeline/transformHtmlCodePrecomputed/index.d.ts +2 -0
  31. package/esm/pipeline/transformHtmlCodePrecomputed/index.js +4 -0
  32. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +13 -0
  33. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +415 -0
  34. package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +304 -47
  35. package/esm/useCode/Pre.js +5 -0
  36. package/esm/useCode/useFileNavigation.js +4 -0
  37. package/esm/withDocsInfra/withDocsInfra.d.ts +12 -1
  38. package/esm/withDocsInfra/withDocsInfra.js +34 -6
  39. package/package.json +6 -4
  40. package/esm/pipeline/loaderUtils/parseImports.d.ts +0 -19
  41. package/esm/pipeline/loaderUtils/parseImports.js +0 -306
  42. package/esm/pipeline/transformHtmlCode/index.d.ts +0 -2
  43. package/esm/pipeline/transformHtmlCode/index.js +0 -4
  44. package/esm/pipeline/transformHtmlCode/transformHtmlCode.d.ts +0 -13
  45. package/esm/pipeline/transformHtmlCode/transformHtmlCode.js +0 -300
@@ -1,8 +1,9 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
2
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
4
  import { visit } from 'unist-util-visit';
4
5
  /**
5
- * Remark plugin that transforms code blocks with variants into HTML pre/code structures.
6
+ * Remark plugin that transforms code blocks with variants into semantic HTML structures.
6
7
  *
7
8
  * Transforms consecutive code blocks with variant metadata like:
8
9
  *
@@ -37,19 +38,86 @@ import { visit } from 'unist-util-visit';
37
38
  * console.log('test' as const)
38
39
  * ```
39
40
  *
40
- * Into HTML that the existing rehype plugin can process:
41
- * <pre>
42
- * <code data-variant="npm">npm install @mui/internal-docs-infra</code>
43
- * <code data-variant="pnpm">pnpm install @mui/internal-docs-infra</code>
44
- * <code data-variant="yarn">yarn add @mui/internal-docs-infra</code>
45
- * </pre>
41
+ * Into semantic HTML that the existing rehype plugin can process:
42
+ * <section>
43
+ * <figure>
44
+ * <figcaption>npm variant</figcaption>
45
+ * <dl>
46
+ * <dt><code>index.js</code></dt>
47
+ * <dd>
48
+ * <pre><code class="language-bash">npm install @mui/internal-docs-infra</code></pre>
49
+ * </dd>
50
+ * </dl>
51
+ * </figure>
52
+ * <figure>
53
+ * <figcaption>pnpm variant</figcaption>
54
+ * <dl>
55
+ * <dt><code>index.js</code></dt>
56
+ * <dd>
57
+ * <pre><code class="language-bash">pnpm install @mui/internal-docs-infra</code></pre>
58
+ * </dd>
59
+ * </dl>
60
+ * </figure>
61
+ * </section>
46
62
  *
47
- * Or for individual blocks:
48
- * <pre>
49
- * <code data-transform="true">console.log('test' as const)</code>
50
- * </pre>
63
+ * Or for individual blocks (no figure/figcaption needed):
64
+ * <dl>
65
+ * <dt><code>index.ts</code></dt>
66
+ * <dd>
67
+ * <pre><code class="language-ts" data-transform="true">console.log('test' as const)</code></pre>
68
+ * </dd>
69
+ * </dl>
51
70
  */
52
71
 
72
+ /**
73
+ * Maps common language names to file extensions
74
+ */
75
+ var LANGUAGE_TO_EXTENSION = {
76
+ // JavaScript
77
+ javascript: 'js',
78
+ js: 'js',
79
+ // TypeScript
80
+ typescript: 'ts',
81
+ ts: 'ts',
82
+ // TSX/JSX
83
+ tsx: 'tsx',
84
+ jsx: 'jsx',
85
+ // JSON
86
+ json: 'json',
87
+ // Markdown
88
+ markdown: 'md',
89
+ md: 'md',
90
+ // MDX
91
+ mdx: 'mdx',
92
+ // HTML
93
+ html: 'html',
94
+ // CSS
95
+ css: 'css',
96
+ // Shell
97
+ shell: 'sh',
98
+ bash: 'sh',
99
+ sh: 'sh',
100
+ // YAML
101
+ yaml: 'yaml',
102
+ yml: 'yaml'
103
+ };
104
+
105
+ /**
106
+ * Gets filename from language or explicit filename prop
107
+ */
108
+ function getFileName(language, props) {
109
+ // Check for explicit filename
110
+ if (props.filename) {
111
+ return props.filename;
112
+ }
113
+
114
+ // Derive from language
115
+ if (language && LANGUAGE_TO_EXTENSION[language]) {
116
+ return "index.".concat(LANGUAGE_TO_EXTENSION[language]);
117
+ }
118
+ return null;
119
+ }
120
+
53
121
  /**
54
122
  * Parse meta string to extract variant and other properties
55
123
  */
@@ -162,12 +230,12 @@ export var transformMarkdownCode = function transformMarkdownCode() {
162
230
 
163
231
  // Handle individual code blocks with options (but no variants)
164
232
  if (!metaData.variant && !metaData.variantType && Object.keys(allProps).length > 0) {
165
- // Create a simple pre/code element for individual blocks with options
166
- var hProperties = {};
233
+ // Create a dl element for individual blocks with options
234
+ var codeHProperties = {};
167
235
 
168
236
  // Add language class if available
169
237
  if (langFromMeta) {
170
- hProperties.className = "language-".concat(langFromMeta);
238
+ codeHProperties.className = "language-".concat(langFromMeta);
171
239
  }
172
240
 
173
241
  // Add all props as data attributes (in camelCase)
@@ -179,31 +247,67 @@ export var transformMarkdownCode = function transformMarkdownCode() {
179
247
  var camelKey = key.includes('-') ? "data".concat(key.split('-').map(function (part) {
180
248
  return part.charAt(0).toUpperCase() + part.slice(1);
181
249
  }).join('')) : "data".concat(key.charAt(0).toUpperCase() + key.slice(1));
182
- hProperties[camelKey] = value;
250
+ codeHProperties[camelKey] = value;
183
251
  });
184
- var preElement = {
252
+ var fileName = getFileName(langFromMeta, allProps);
253
+ var dlElement = {
185
254
  type: 'element',
186
- tagName: 'pre',
255
+ tagName: 'dl',
187
256
  data: {
188
- hName: 'pre',
257
+ hName: 'dl',
189
258
  hProperties: {}
190
259
  },
191
- children: [{
260
+ children: [].concat(_toConsumableArray(fileName ? [{
192
261
  type: 'element',
193
- tagName: 'code',
262
+ tagName: 'dt',
194
263
  data: {
195
- hName: 'code',
196
- hProperties: hProperties
264
+ hName: 'dt',
265
+ hProperties: {}
197
266
  },
198
267
  children: [{
199
- type: 'text',
200
- value: codeNode.value
268
+ type: 'element',
269
+ tagName: 'code',
270
+ data: {
271
+ hName: 'code',
272
+ hProperties: {}
273
+ },
274
+ children: [{
275
+ type: 'text',
276
+ value: fileName
277
+ }]
201
278
  }]
202
- }]
279
+ }] : []), [{
280
+ type: 'element',
281
+ tagName: 'dd',
282
+ data: {
283
+ hName: 'dd',
284
+ hProperties: {}
285
+ },
286
+ children: [{
287
+ type: 'element',
288
+ tagName: 'pre',
289
+ data: {
290
+ hName: 'pre',
291
+ hProperties: {}
292
+ },
293
+ children: [{
294
+ type: 'element',
295
+ tagName: 'code',
296
+ data: {
297
+ hName: 'code',
298
+ hProperties: codeHProperties
299
+ },
300
+ children: [{
301
+ type: 'text',
302
+ value: codeNode.value
303
+ }]
304
+ }]
305
+ }]
306
+ }])
203
307
  };
204
308
 
205
309
  // Replace this individual code block immediately
206
- parentNode.children[index] = preElement;
310
+ parentNode.children[index] = dlElement;
207
311
  processedIndices.add(index);
208
312
  return;
209
313
  }
@@ -383,23 +487,21 @@ export var transformMarkdownCode = function transformMarkdownCode() {
383
487
 
384
488
  // Only process if we have multiple blocks
385
489
  if (codeBlocks.length > 1) {
386
- // Create proper HTML elements with hProperties for remark-rehype compatibility
387
- var _preElement = {
490
+ // Create section with figure elements for each variant
491
+ var sectionElement = {
388
492
  type: 'element',
389
- tagName: 'pre',
493
+ tagName: 'section',
390
494
  data: {
391
- hName: 'pre',
495
+ hName: 'section',
392
496
  hProperties: {}
393
497
  },
394
498
  children: codeBlocks.map(function (block) {
395
499
  // Build hProperties for HTML attributes
396
- var hProperties = {
397
- dataVariant: block.variant
398
- };
500
+ var codeHProperties = {};
399
501
 
400
502
  // Add language class if available
401
503
  if (block.actualLang) {
402
- hProperties.className = "language-".concat(block.actualLang);
504
+ codeHProperties.className = "language-".concat(block.actualLang);
403
505
  }
404
506
 
405
507
  // Add additional props as data attributes (in camelCase)
@@ -411,31 +513,97 @@ export var transformMarkdownCode = function transformMarkdownCode() {
411
513
  var camelKey = key.includes('-') ? "data".concat(key.split('-').map(function (part) {
412
514
  return part.charAt(0).toUpperCase() + part.slice(1);
413
515
  }).join('')) : "data".concat(key.charAt(0).toUpperCase() + key.slice(1));
414
- hProperties[camelKey] = value;
516
+ codeHProperties[camelKey] = value;
415
517
  });
518
+
519
+ // Add data-variant to track the variant
520
+ codeHProperties.dataVariant = block.variant;
521
+ var fileName = getFileName(block.actualLang, block.props);
416
522
  return {
417
523
  type: 'element',
418
- tagName: 'code',
524
+ tagName: 'figure',
419
525
  data: {
420
- hName: 'code',
421
- hProperties: hProperties,
422
- meta: "variant=".concat(block.variant).concat(Object.entries(block.props).map(function (_ref7) {
423
- var _ref8 = _slicedToArray(_ref7, 2),
424
- key = _ref8[0],
425
- value = _ref8[1];
426
- return " ".concat(key, "=").concat(value);
427
- }).join(''))
526
+ hName: 'figure',
527
+ hProperties: {}
428
528
  },
429
529
  children: [{
430
- type: 'text',
431
- value: block.node.value
530
+ type: 'element',
531
+ tagName: 'figcaption',
532
+ data: {
533
+ hName: 'figcaption',
534
+ hProperties: {}
535
+ },
536
+ children: [{
537
+ type: 'text',
538
+ value: "".concat(block.variant, " variant")
539
+ }]
540
+ }, {
541
+ type: 'element',
542
+ tagName: 'dl',
543
+ data: {
544
+ hName: 'dl',
545
+ hProperties: {}
546
+ },
547
+ children: [].concat(_toConsumableArray(fileName ? [{
548
+ type: 'element',
549
+ tagName: 'dt',
550
+ data: {
551
+ hName: 'dt',
552
+ hProperties: {}
553
+ },
554
+ children: [{
555
+ type: 'element',
556
+ tagName: 'code',
557
+ data: {
558
+ hName: 'code',
559
+ hProperties: {}
560
+ },
561
+ children: [{
562
+ type: 'text',
563
+ value: fileName
564
+ }]
565
+ }]
566
+ }] : []), [{
567
+ type: 'element',
568
+ tagName: 'dd',
569
+ data: {
570
+ hName: 'dd',
571
+ hProperties: {}
572
+ },
573
+ children: [{
574
+ type: 'element',
575
+ tagName: 'pre',
576
+ data: {
577
+ hName: 'pre',
578
+ hProperties: {}
579
+ },
580
+ children: [{
581
+ type: 'element',
582
+ tagName: 'code',
583
+ data: {
584
+ hName: 'code',
585
+ hProperties: codeHProperties,
586
+ meta: "variant=".concat(block.variant).concat(Object.entries(block.props).map(function (_ref7) {
587
+ var _ref8 = _slicedToArray(_ref7, 2),
588
+ key = _ref8[0],
589
+ value = _ref8[1];
590
+ return " ".concat(key, "=").concat(value);
591
+ }).join(''))
592
+ },
593
+ children: [{
594
+ type: 'text',
595
+ value: block.node.value
596
+ }]
597
+ }]
598
+ }]
599
+ }])
432
600
  }]
433
601
  };
434
602
  })
435
603
  };
436
604
 
437
605
  // Replace the first block with the group and mark others for removal
438
- parentNode.children[codeBlocks[0].index] = _preElement;
606
+ parentNode.children[codeBlocks[0].index] = sectionElement;
439
607
 
440
608
  // Remove all other code blocks and their labels (in reverse order to maintain indices)
441
609
  var indicesToRemove = codeBlocks.slice(1).map(function (block) {
@@ -506,6 +674,95 @@ export var transformMarkdownCode = function transformMarkdownCode() {
506
674
  });
507
675
  }
508
676
  }
677
+ } else if (codeBlocks.length === 1) {
678
+ // Single code block with variant - create a simple dl without figure wrapper
679
+ var block = codeBlocks[0];
680
+ var _codeHProperties = {};
681
+
682
+ // Add language class if available
683
+ if (block.actualLang) {
684
+ _codeHProperties.className = "language-".concat(block.actualLang);
685
+ }
686
+
687
+ // Add additional props as data attributes (in camelCase)
688
+ Object.entries(block.props).forEach(function (_ref9) {
689
+ var _ref0 = _slicedToArray(_ref9, 2),
690
+ key = _ref0[0],
691
+ value = _ref0[1];
692
+ // Convert kebab-case to camelCase for data attributes
693
+ var camelKey = key.includes('-') ? "data".concat(key.split('-').map(function (part) {
694
+ return part.charAt(0).toUpperCase() + part.slice(1);
695
+ }).join('')) : "data".concat(key.charAt(0).toUpperCase() + key.slice(1));
696
+ _codeHProperties[camelKey] = value;
697
+ });
698
+
699
+ // Add data-variant to track the variant
700
+ _codeHProperties.dataVariant = block.variant;
701
+ var _fileName = getFileName(block.actualLang, block.props);
702
+ var _dlElement = {
703
+ type: 'element',
704
+ tagName: 'dl',
705
+ data: {
706
+ hName: 'dl',
707
+ hProperties: {}
708
+ },
709
+ children: [].concat(_toConsumableArray(_fileName ? [{
710
+ type: 'element',
711
+ tagName: 'dt',
712
+ data: {
713
+ hName: 'dt',
714
+ hProperties: {}
715
+ },
716
+ children: [{
717
+ type: 'element',
718
+ tagName: 'code',
719
+ data: {
720
+ hName: 'code',
721
+ hProperties: {}
722
+ },
723
+ children: [{
724
+ type: 'text',
725
+ value: _fileName
726
+ }]
727
+ }]
728
+ }] : []), [{
729
+ type: 'element',
730
+ tagName: 'dd',
731
+ data: {
732
+ hName: 'dd',
733
+ hProperties: {}
734
+ },
735
+ children: [{
736
+ type: 'element',
737
+ tagName: 'pre',
738
+ data: {
739
+ hName: 'pre',
740
+ hProperties: {}
741
+ },
742
+ children: [{
743
+ type: 'element',
744
+ tagName: 'code',
745
+ data: {
746
+ hName: 'code',
747
+ hProperties: _codeHProperties,
748
+ meta: "variant=".concat(block.variant).concat(Object.entries(block.props).map(function (_ref1) {
749
+ var _ref10 = _slicedToArray(_ref1, 2),
750
+ key = _ref10[0],
751
+ value = _ref10[1];
752
+ return " ".concat(key, "=").concat(value);
753
+ }).join(''))
754
+ },
755
+ children: [{
756
+ type: 'text',
757
+ value: block.node.value
758
+ }]
759
+ }]
760
+ }]
761
+ }])
762
+ };
763
+
764
+ // Replace this single code block
765
+ parentNode.children[codeBlocks[0].index] = _dlElement;
509
766
  }
510
767
  }
511
768
  }
@@ -5,6 +5,8 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
5
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import * as React from 'react';
7
7
  import { toText } from 'hast-util-to-text';
8
+ import { decompressSync, strFromU8 } from 'fflate';
9
+ import { decode } from 'uint8-to-base64';
8
10
  import { hastToJsx } from "../pipeline/hastUtils/index.js";
9
11
  import { jsx as _jsx } from "react/jsx-runtime";
10
12
  export function Pre(_ref) {
@@ -21,6 +23,9 @@ export function Pre(_ref) {
21
23
  if ('hastJson' in children) {
22
24
  return JSON.parse(children.hastJson);
23
25
  }
26
+ if ('hastGzip' in children) {
27
+ return JSON.parse(strFromU8(decompressSync(decode(children.hastGzip))));
28
+ }
24
29
  return children;
25
30
  }, [children]);
26
31
  var _React$useState = React.useState(_defineProperty({}, 0, true)),
@@ -2,6 +2,8 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
2
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import * as React from 'react';
5
+ import { decompressSync, strFromU8 } from 'fflate';
6
+ import { decode } from 'uint8-to-base64';
5
7
  import { useUrlHashState } from "../useUrlHashState/index.js";
6
8
  import { countLines } from "../pipeline/parseSource/addLineGutters.js";
7
9
  import { Pre } from "./Pre.js";
@@ -311,6 +313,8 @@ export function useFileNavigation(_ref) {
311
313
  var hastSelectedFile;
312
314
  if ('hastJson' in selectedFile) {
313
315
  hastSelectedFile = JSON.parse(selectedFile.hastJson);
316
+ } else if ('hastGzip' in selectedFile) {
317
+ hastSelectedFile = JSON.parse(strFromU8(decompressSync(decode(selectedFile.hastGzip))));
314
318
  } else {
315
319
  hastSelectedFile = selectedFile;
316
320
  }
@@ -4,7 +4,10 @@ export interface NextConfig {
4
4
  output?: 'export' | 'standalone' | undefined;
5
5
  turbopack?: {
6
6
  rules?: Record<string, {
7
- loaders: string[];
7
+ loaders: {
8
+ loader: string;
9
+ options: Record<string, unknown>;
10
+ }[] | string[];
8
11
  }>;
9
12
  };
10
13
  webpack?: (config: WebpackConfig, options: WebpackOptions) => WebpackConfig;
@@ -57,6 +60,14 @@ export interface WithDocsInfraOptions {
57
60
  additionalTurbopackRules?: Record<string, {
58
61
  loaders: string[];
59
62
  }>;
63
+ /**
64
+ * Defer AST parsing option for code highlighter output.
65
+ * 'gzip' - Default, outputs gzipped HAST for best performance.
66
+ * 'json' - Outputs JSON HAST, requires client-side parsing.
67
+ * 'none' - Outputs raw HAST, requires client-side parsing and is largest size.
68
+ * @default 'gzip'
69
+ */
70
+ deferCodeParsing?: 'gzip' | 'json' | 'none';
60
71
  }
61
72
  export interface DocsInfraMdxOptions {
62
73
  remarkPlugins?: Array<string | [string, ...any[]]>;
@@ -12,7 +12,7 @@ export function getDocsInfraMdxOptions() {
12
12
  var _customOptions$remark, _customOptions$additi, _customOptions$rehype, _customOptions$additi2;
13
13
  var customOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14
14
  var defaultRemarkPlugins = [['remark-gfm'], ['@mui/internal-docs-infra/pipeline/transformMarkdownCode']];
15
- var defaultRehypePlugins = [['@mui/internal-docs-infra/pipeline/transformHtmlCode']];
15
+ var defaultRehypePlugins = [['@mui/internal-docs-infra/pipeline/transformHtmlCodePrecomputed']];
16
16
 
17
17
  // Build final plugin arrays
18
18
  var remarkPlugins = (_customOptions$remark = customOptions.remarkPlugins) != null ? _customOptions$remark : [].concat(defaultRemarkPlugins, _toConsumableArray((_customOptions$additi = customOptions.additionalRemarkPlugins) != null ? _customOptions$additi : []));
@@ -41,7 +41,15 @@ export function withDocsInfra() {
41
41
  _options$additionalDe = options.additionalDemoPatterns,
42
42
  additionalDemoPatterns = _options$additionalDe === void 0 ? {} : _options$additionalDe,
43
43
  _options$additionalTu = options.additionalTurbopackRules,
44
- additionalTurbopackRules = _options$additionalTu === void 0 ? {} : _options$additionalTu;
44
+ additionalTurbopackRules = _options$additionalTu === void 0 ? {} : _options$additionalTu,
45
+ _options$deferCodePar = options.deferCodeParsing,
46
+ deferCodeParsing = _options$deferCodePar === void 0 ? 'gzip' : _options$deferCodePar;
47
+ var output = 'hastGzip';
48
+ if (deferCodeParsing === 'json') {
49
+ output = 'hastJson';
50
+ } else if (deferCodeParsing === 'none') {
51
+ output = 'hast';
52
+ }
45
53
  return function () {
46
54
  var _nextConfig$turbopack;
47
55
  var nextConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -50,7 +58,12 @@ export function withDocsInfra() {
50
58
 
51
59
  // Build Turbopack rules
52
60
  var turbopackRules = _defineProperty(_defineProperty({}, demoPathPattern, {
53
- loaders: ['@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter']
61
+ loaders: [{
62
+ loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
63
+ options: {
64
+ output: output
65
+ }
66
+ }]
54
67
  }), clientDemoPathPattern, {
55
68
  loaders: ['@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient']
56
69
  });
@@ -59,7 +72,12 @@ export function withDocsInfra() {
59
72
  if (additionalDemoPatterns.index) {
60
73
  additionalDemoPatterns.index.forEach(function (pattern) {
61
74
  turbopackRules[pattern] = {
62
- loaders: ['@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter']
75
+ loaders: [{
76
+ loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
77
+ options: {
78
+ output: output
79
+ }
80
+ }]
63
81
  };
64
82
  });
65
83
  }
@@ -99,7 +117,12 @@ export function withDocsInfra() {
99
117
  // Add loader for demo index files
100
118
  webpackConfig.module.rules.push({
101
119
  test: new RegExp('/demos/[^/]+/index\\.ts$'),
102
- use: [defaultLoaders.babel, '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter']
120
+ use: [defaultLoaders.babel, {
121
+ loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
122
+ options: {
123
+ output: output
124
+ }
125
+ }]
103
126
  });
104
127
 
105
128
  // Client files for live demos - processes externals
@@ -120,7 +143,12 @@ export function withDocsInfra() {
120
143
 
121
144
  webpackConfig.module.rules.push({
122
145
  test: new RegExp("".concat(regexPattern, "$")),
123
- use: [defaultLoaders.babel, '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter']
146
+ use: [defaultLoaders.babel, {
147
+ loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
148
+ options: {
149
+ output: output
150
+ }
151
+ }]
124
152
  });
125
153
  });
126
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.2.0-alpha.1",
3
+ "version": "0.2.0",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "keywords": [
@@ -25,6 +25,7 @@
25
25
  "@babel/standalone": "^7.28.4",
26
26
  "@wooorm/starry-night": "^3.8.0",
27
27
  "clipboard-copy": "^4.0.1",
28
+ "fflate": "^0.8.2",
28
29
  "hast-util-to-jsx-runtime": "^2.3.6",
29
30
  "hast-util-to-text": "^4.0.2",
30
31
  "jsondiffpatch": "^0.7.3",
@@ -32,6 +33,7 @@
32
33
  "lz-string": "^1.5.0",
33
34
  "path-module": "^0.1.2",
34
35
  "prettier": "^3.5.3",
36
+ "uint8-to-base64": "^0.2.1",
35
37
  "unist-util-visit": "^5.0.0",
36
38
  "vscode-oniguruma": "^2.0.1"
37
39
  },
@@ -204,10 +206,10 @@
204
206
  "default": "./esm/pipeline/parseSource/index.js"
205
207
  }
206
208
  },
207
- "./pipeline/transformHtmlCode": {
209
+ "./pipeline/transformHtmlCodePrecomputed": {
208
210
  "default": {
209
- "types": "./esm/pipeline/transformHtmlCode/index.d.ts",
210
- "default": "./esm/pipeline/transformHtmlCode/index.js"
211
+ "types": "./esm/pipeline/transformHtmlCodePrecomputed/index.d.ts",
212
+ "default": "./esm/pipeline/transformHtmlCodePrecomputed/index.js"
211
213
  }
212
214
  },
213
215
  "./pipeline/transformMarkdownCode": {
@@ -1,19 +0,0 @@
1
- export interface ImportName {
2
- name: string;
3
- alias?: string;
4
- type: 'default' | 'named' | 'namespace';
5
- isType?: boolean;
6
- }
7
- export interface RelativeImport {
8
- path: string;
9
- names: ImportName[];
10
- includeTypeDefs?: true;
11
- }
12
- export interface ExternalImport {
13
- names: ImportName[];
14
- }
15
- export interface ParseImportsResult {
16
- relative: Record<string, RelativeImport>;
17
- externals: Record<string, ExternalImport>;
18
- }
19
- export declare function parseImports(code: string, _filePath: string): Promise<ParseImportsResult>;