@mui/internal-docs-infra 0.3.1-canary.3 → 0.3.1-canary.5

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 (102) hide show
  1. package/esm/CodeControllerContext/CodeControllerContext.js +2 -2
  2. package/esm/CodeExternalsContext/CodeExternalsContext.js +1 -1
  3. package/esm/CodeHighlighter/CodeHighlighter.js +247 -329
  4. package/esm/CodeHighlighter/CodeHighlighterClient.js +447 -653
  5. package/esm/CodeHighlighter/CodeHighlighterContext.js +2 -2
  6. package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +2 -2
  7. package/esm/CodeHighlighter/codeToFallbackProps.js +21 -37
  8. package/esm/CodeHighlighter/errors.js +248 -400
  9. package/esm/CodeHighlighter/parseControlledCode.js +12 -20
  10. package/esm/CodeProvider/CodeContext.js +3 -3
  11. package/esm/CodeProvider/CodeProvider.js +31 -40
  12. package/esm/abstractCreateDemo/abstractCreateDemo.js +13 -17
  13. package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +12 -12
  14. package/esm/cli/index.js +1 -1
  15. package/esm/cli/runValidate.js +160 -264
  16. package/esm/createDemoData/createDemoData.js +11 -12
  17. package/esm/createSitemap/createSitemap.js +2 -2
  18. package/esm/pipeline/getFileConventions/fileConventions.js +1 -1
  19. package/esm/pipeline/getFileConventions/getFileConventions.js +2 -15
  20. package/esm/pipeline/hastUtils/hastUtils.js +16 -17
  21. package/esm/pipeline/loadCodeVariant/addCodeVariantPaths.js +24 -24
  22. package/esm/pipeline/loadCodeVariant/applyCodeTransform.js +12 -22
  23. package/esm/pipeline/loadCodeVariant/calculateMainFilePath.js +30 -37
  24. package/esm/pipeline/loadCodeVariant/computeHastDeltas.js +107 -185
  25. package/esm/pipeline/loadCodeVariant/diffHast.js +18 -53
  26. package/esm/pipeline/loadCodeVariant/examineCodeVariant.js +24 -27
  27. package/esm/pipeline/loadCodeVariant/flattenCodeVariant.js +9 -10
  28. package/esm/pipeline/loadCodeVariant/hasAllCodeVariants.js +5 -5
  29. package/esm/pipeline/loadCodeVariant/loadCodeFallback.js +516 -731
  30. package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +679 -1079
  31. package/esm/pipeline/loadCodeVariant/maybeCodeInitialData.js +14 -20
  32. package/esm/pipeline/loadCodeVariant/mergeCodeMetadata.js +53 -63
  33. package/esm/pipeline/loadCodeVariant/parseCode.js +40 -48
  34. package/esm/pipeline/loadCodeVariant/pathUtils.js +43 -64
  35. package/esm/pipeline/loadCodeVariant/transformSource.js +55 -125
  36. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +160 -221
  37. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +377 -479
  38. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +171 -173
  39. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +14 -30
  40. package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +19 -21
  41. package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +37 -71
  42. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +3 -9
  43. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +54 -80
  44. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +71 -98
  45. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +5 -5
  46. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +161 -211
  47. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +159 -207
  48. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +42 -64
  49. package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.js +20 -96
  50. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +66 -85
  51. package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +71 -118
  52. package/esm/pipeline/loadServerSource/loadServerSource.js +121 -148
  53. package/esm/pipeline/loaderUtils/externalsToPackages.js +7 -7
  54. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +8 -12
  55. package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +5 -5
  56. package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +19 -29
  57. package/esm/pipeline/loaderUtils/getLanguageFromExtension.js +3 -4
  58. package/esm/pipeline/loaderUtils/mergeExternals.js +15 -35
  59. package/esm/pipeline/loaderUtils/parseImportsAndComments.js +413 -433
  60. package/esm/pipeline/loaderUtils/processRelativeImports.js +153 -239
  61. package/esm/pipeline/loaderUtils/resolveModulePath.js +544 -1303
  62. package/esm/pipeline/loaderUtils/rewriteImports.js +73 -111
  63. package/esm/pipeline/parseSource/addLineGutters.js +33 -45
  64. package/esm/pipeline/parseSource/grammars.js +3 -3
  65. package/esm/pipeline/parseSource/parseSource.js +13 -31
  66. package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +32 -55
  67. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +107 -160
  68. package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +846 -1033
  69. package/esm/pipeline/syncPageIndex/syncPageIndex.js +291 -438
  70. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +213 -311
  71. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +10 -10
  72. package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +133 -193
  73. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +25 -27
  74. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +572 -717
  75. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +8 -8
  76. package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +84 -113
  77. package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +10 -26
  78. package/esm/useCode/Pre.js +58 -62
  79. package/esm/useCode/useCode.js +59 -61
  80. package/esm/useCode/useCodeUtils.js +54 -63
  81. package/esm/useCode/useCopyFunctionality.js +10 -9
  82. package/esm/useCode/useFileNavigation.js +150 -212
  83. package/esm/useCode/useSourceEditing.js +17 -14
  84. package/esm/useCode/useTransformManagement.js +23 -26
  85. package/esm/useCode/useUIState.js +12 -20
  86. package/esm/useCode/useVariantSelection.js +62 -79
  87. package/esm/useCopier/index.js +29 -56
  88. package/esm/useDemo/createCodeSandbox.js +12 -15
  89. package/esm/useDemo/createStackBlitz.js +14 -20
  90. package/esm/useDemo/exportVariant.js +200 -180
  91. package/esm/useDemo/exportVariantAsCra.js +22 -25
  92. package/esm/useDemo/useDemo.js +80 -84
  93. package/esm/useErrors/ErrorsContext.js +1 -1
  94. package/esm/useErrors/useErrors.js +3 -3
  95. package/esm/useLocalStorageState/useLocalStorageState.js +23 -39
  96. package/esm/usePreference/PreferencesProvider.js +1 -1
  97. package/esm/usePreference/usePreference.js +9 -11
  98. package/esm/useSearch/useSearch.js +290 -387
  99. package/esm/useUrlHashState/useUrlHashState.js +11 -14
  100. package/esm/withDocsInfra/withDeploymentConfig.js +26 -21
  101. package/esm/withDocsInfra/withDocsInfra.js +99 -101
  102. package/package.json +7 -4
@@ -8,29 +8,29 @@ import * as React from 'react';
8
8
  */
9
9
  export function useUrlHashState() {
10
10
  // Store the subscriber callback so we can trigger it manually
11
- var subscriberRef = React.useRef(null);
11
+ const subscriberRef = React.useRef(null);
12
12
 
13
13
  // Subscribe to hash changes
14
- var subscribe = React.useCallback(function (callback) {
14
+ const subscribe = React.useCallback(callback => {
15
15
  subscriberRef.current = callback;
16
16
  if (typeof window === 'undefined') {
17
- return function () {
17
+ return () => {
18
18
  subscriberRef.current = null;
19
19
  };
20
20
  }
21
21
  window.addEventListener('hashchange', callback);
22
- return function () {
22
+ return () => {
23
23
  window.removeEventListener('hashchange', callback);
24
24
  subscriberRef.current = null;
25
25
  };
26
26
  }, []);
27
27
 
28
28
  // Get current hash value (client-side)
29
- var getSnapshot = React.useCallback(function () {
29
+ const getSnapshot = React.useCallback(() => {
30
30
  if (typeof window === 'undefined') {
31
31
  return null;
32
32
  }
33
- var currentHash = window.location.hash;
33
+ const currentHash = window.location.hash;
34
34
  if (!currentHash) {
35
35
  return null;
36
36
  }
@@ -38,20 +38,17 @@ export function useUrlHashState() {
38
38
  }, []);
39
39
 
40
40
  // Get server snapshot (always null for SSR)
41
- var getServerSnapshot = React.useCallback(function () {
42
- return null;
43
- }, []);
41
+ const getServerSnapshot = React.useCallback(() => null, []);
44
42
 
45
43
  // Use useSyncExternalStore for hash synchronization
46
- var hash = React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
44
+ const hash = React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
47
45
 
48
46
  // Set hash in URL and state
49
- var setHash = React.useCallback(function (value) {
50
- var replace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
51
- var newUrl = value ? "".concat(window.location.pathname).concat(window.location.search, "#").concat(value) : "".concat(window.location.pathname).concat(window.location.search);
47
+ const setHash = React.useCallback((value, replace = true) => {
48
+ let newUrl = value ? `${window.location.pathname}${window.location.search}#${value}` : `${window.location.pathname}${window.location.search}`;
52
49
  // Special case: if value is an empty string (not null), include the hash
53
50
  if (value === '') {
54
- newUrl = "".concat(window.location.pathname).concat(window.location.search, "#");
51
+ newUrl = `${window.location.pathname}${window.location.search}#`;
55
52
  }
56
53
  if (replace) {
57
54
  window.history.replaceState(null, '', newUrl);
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import * as os from 'node:os';
3
2
  /**
4
3
  * See the docs of the Netlify environment variables:
@@ -11,7 +10,7 @@ import * as os from 'node:os';
11
10
  * - Each team has different site https://app.netlify.com/teams/mui/sites.
12
11
  * The following logic must be compatible with all of them.
13
12
  */
14
- var DEPLOY_ENV = 'development';
13
+ let DEPLOY_ENV = 'development';
15
14
 
16
15
  // Same as process.env.PULL_REQUEST_ID
17
16
  if (process.env.CONTEXT === 'deploy-preview') {
@@ -31,15 +30,15 @@ if ((process.env.CONTEXT === 'production' || process.env.CONTEXT === 'branch-dep
31
30
 
32
31
  process.env.DEPLOY_ENV = DEPLOY_ENV;
33
32
  export function withDeploymentConfig(nextConfig) {
34
- return _extends(_extends({
33
+ return {
35
34
  trailingSlash: true,
36
35
  reactStrictMode: true,
37
- productionBrowserSourceMaps: true
38
- }, nextConfig), {}, {
39
- env: _extends(_extends({
36
+ productionBrowserSourceMaps: true,
37
+ ...nextConfig,
38
+ env: {
40
39
  // production | staging | pull-request | development
41
- DEPLOY_ENV: DEPLOY_ENV
42
- }, nextConfig.env), {}, {
40
+ DEPLOY_ENV,
41
+ ...nextConfig.env,
43
42
  // https://docs.netlify.com/configure-builds/environment-variables/#git-metadata
44
43
  // reference ID (also known as "SHA" or "hash") of the commit we're building.
45
44
  COMMIT_REF: process.env.COMMIT_REF,
@@ -54,19 +53,25 @@ export function withDeploymentConfig(nextConfig) {
54
53
  SITE_NAME: process.env.SITE_NAME,
55
54
  // For template images
56
55
  TEMPLATE_IMAGE_URL: ''
57
- }),
58
- experimental: _extends(_extends({
56
+ },
57
+ experimental: {
59
58
  scrollRestoration: true,
60
- workerThreads: false
61
- }, process.env.CI ? {
62
- cpus: process.env.NEXT_PARALLELISM ? parseInt(process.env.NEXT_PARALLELISM, 10) : os.availableParallelism()
63
- } : {}), nextConfig.experimental),
64
- eslint: _extends({
65
- ignoreDuringBuilds: true
66
- }, nextConfig.eslint),
67
- typescript: _extends({
59
+ workerThreads: false,
60
+ ...(process.env.CI ? {
61
+ cpus: process.env.NEXT_PARALLELISM ? parseInt(process.env.NEXT_PARALLELISM, 10) : os.availableParallelism()
62
+ } : {}),
63
+ ...nextConfig.experimental
64
+ },
65
+ // TODO remove, this is for versions before Next.js v16
66
+ // https://nextjs.org/blog/next-16
67
+ eslint: {
68
+ ignoreDuringBuilds: true,
69
+ ...nextConfig.eslint
70
+ },
71
+ typescript: {
68
72
  // Motivated by https://github.com/vercel/next.js/issues/7687
69
- ignoreBuildErrors: true
70
- }, nextConfig.typescript)
71
- });
73
+ ignoreBuildErrors: true,
74
+ ...nextConfig.typescript
75
+ }
76
+ };
72
77
  }
@@ -1,22 +1,17 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
1
  // Define webpack options interface based on Next.js webpack function signature
5
2
 
6
3
  /**
7
4
  * Get default MDX options for docs-infra
8
5
  */
9
- export function getDocsInfraMdxOptions() {
10
- var _customOptions$remark, _customOptions$additi, _customOptions$rehype, _customOptions$additi2;
11
- var customOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12
- var _customOptions$extrac = customOptions.extractToIndex,
13
- extractToIndex = _customOptions$extrac === void 0 ? true : _customOptions$extrac,
14
- baseDir = customOptions.baseDir,
15
- _customOptions$errorI = customOptions.errorIfIndexOutOfDate,
16
- errorIfIndexOutOfDate = _customOptions$errorI === void 0 ? Boolean(process.env.CI) : _customOptions$errorI;
6
+ export function getDocsInfraMdxOptions(customOptions = {}) {
7
+ const {
8
+ extractToIndex = true,
9
+ baseDir,
10
+ errorIfIndexOutOfDate = Boolean(process.env.CI)
11
+ } = customOptions;
17
12
 
18
13
  // Normalize extractToIndex to options object
19
- var extractToIndexOptions;
14
+ let extractToIndexOptions;
20
15
  if (extractToIndex === false) {
21
16
  extractToIndexOptions = false;
22
17
  } else if (extractToIndex === true) {
@@ -26,26 +21,27 @@ export function getDocsInfraMdxOptions() {
26
21
  extractToIndexOptions = {
27
22
  include: ['app', 'src/app'],
28
23
  exclude: [],
29
- baseDir: baseDir != null ? baseDir : process.cwd()
24
+ baseDir: baseDir ?? process.cwd()
30
25
  };
31
26
  } else {
32
- extractToIndexOptions = _extends(_extends({}, extractToIndex), {}, {
33
- baseDir: baseDir != null ? baseDir : process.cwd()
34
- });
27
+ extractToIndexOptions = {
28
+ ...extractToIndex,
29
+ baseDir: baseDir ?? process.cwd()
30
+ };
35
31
  }
36
- var defaultRemarkPlugins = [['remark-gfm'], ['@mui/internal-docs-infra/pipeline/transformMarkdownMetadata', {
32
+ const defaultRemarkPlugins = [['remark-gfm'], ['@mui/internal-docs-infra/pipeline/transformMarkdownMetadata', {
37
33
  extractToIndex: extractToIndexOptions,
38
34
  markerPath: '.next/cache/docs-infra/index-updates',
39
- errorIfIndexOutOfDate: errorIfIndexOutOfDate
35
+ errorIfIndexOutOfDate
40
36
  }], ['@mui/internal-docs-infra/pipeline/transformMarkdownRelativePaths'], ['@mui/internal-docs-infra/pipeline/transformMarkdownBlockquoteCallouts'], ['@mui/internal-docs-infra/pipeline/transformMarkdownCode'], ['@mui/internal-docs-infra/pipeline/transformMarkdownDemoLinks']];
41
- var defaultRehypePlugins = [['@mui/internal-docs-infra/pipeline/transformHtmlCodePrecomputed']];
37
+ const defaultRehypePlugins = [['@mui/internal-docs-infra/pipeline/transformHtmlCodePrecomputed']];
42
38
 
43
39
  // Build final plugin arrays
44
- var remarkPlugins = (_customOptions$remark = customOptions.remarkPlugins) != null ? _customOptions$remark : [].concat(defaultRemarkPlugins, _toConsumableArray((_customOptions$additi = customOptions.additionalRemarkPlugins) != null ? _customOptions$additi : []));
45
- var rehypePlugins = (_customOptions$rehype = customOptions.rehypePlugins) != null ? _customOptions$rehype : [].concat(defaultRehypePlugins, _toConsumableArray((_customOptions$additi2 = customOptions.additionalRehypePlugins) != null ? _customOptions$additi2 : []));
40
+ const remarkPlugins = customOptions.remarkPlugins ?? [...defaultRemarkPlugins, ...(customOptions.additionalRemarkPlugins ?? [])];
41
+ const rehypePlugins = customOptions.rehypePlugins ?? [...defaultRehypePlugins, ...(customOptions.additionalRehypePlugins ?? [])];
46
42
  return {
47
- remarkPlugins: remarkPlugins,
48
- rehypePlugins: rehypePlugins
43
+ remarkPlugins,
44
+ rehypePlugins
49
45
  };
50
46
  }
51
47
 
@@ -54,82 +50,77 @@ export function getDocsInfraMdxOptions() {
54
50
  * Configures webpack loaders, turbopack rules for docs sites.
55
51
  * Use getDocsInfraMdxOptions() with createMDX for MDX integration.
56
52
  */
57
- export function withDocsInfra() {
58
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
59
- var _options$additionalPa = options.additionalPageExtensions,
60
- additionalPageExtensions = _options$additionalPa === void 0 ? [] : _options$additionalPa,
61
- _options$enableExport = options.enableExportOutput,
62
- enableExportOutput = _options$enableExport === void 0 ? true : _options$enableExport,
63
- _options$demoPathPatt = options.demoPathPattern,
64
- demoPathPattern = _options$demoPathPatt === void 0 ? './app/**/demos/*/index.ts' : _options$demoPathPatt,
65
- _options$clientDemoPa = options.clientDemoPathPattern,
66
- clientDemoPathPattern = _options$clientDemoPa === void 0 ? './app/**/demos/*/client.ts' : _options$clientDemoPa,
67
- _options$additionalDe = options.additionalDemoPatterns,
68
- additionalDemoPatterns = _options$additionalDe === void 0 ? {} : _options$additionalDe,
69
- _options$additionalTu = options.additionalTurbopackRules,
70
- additionalTurbopackRules = _options$additionalTu === void 0 ? {} : _options$additionalTu,
71
- _options$performance = options.performance,
72
- performance = _options$performance === void 0 ? {} : _options$performance,
73
- _options$deferCodePar = options.deferCodeParsing,
74
- deferCodeParsing = _options$deferCodePar === void 0 ? 'gzip' : _options$deferCodePar;
75
- var output = 'hastGzip';
53
+ export function withDocsInfra(options = {}) {
54
+ const {
55
+ additionalPageExtensions = [],
56
+ enableExportOutput = true,
57
+ demoPathPattern = './app/**/demos/*/index.ts',
58
+ clientDemoPathPattern = './app/**/demos/*/client.ts',
59
+ additionalDemoPatterns = {},
60
+ additionalTurbopackRules = {},
61
+ performance = {},
62
+ deferCodeParsing = 'gzip'
63
+ } = options;
64
+ let output = 'hastGzip';
76
65
  if (deferCodeParsing === 'json') {
77
66
  output = 'hastJson';
78
67
  } else if (deferCodeParsing === 'none') {
79
68
  output = 'hast';
80
69
  }
81
- return function () {
82
- var _nextConfig$turbopack;
83
- var nextConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
84
- var basePageExtensions = ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'];
85
- var pageExtensions = [].concat(basePageExtensions, _toConsumableArray(additionalPageExtensions));
70
+ return (nextConfig = {}) => {
71
+ const basePageExtensions = ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'];
72
+ const pageExtensions = [...basePageExtensions, ...additionalPageExtensions];
86
73
 
87
74
  // Build Turbopack rules
88
- var turbopackRules = _defineProperty(_defineProperty(_defineProperty({}, demoPathPattern, {
89
- loaders: [{
90
- loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
91
- options: {
92
- performance: performance,
93
- output: output
94
- }
95
- }]
96
- }), clientDemoPathPattern, {
97
- loaders: [{
98
- loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient',
99
- options: {
100
- performance: performance
101
- }
102
- }]
103
- }), './app/sitemap/index.ts', {
104
- loaders: [{
105
- loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedSitemap',
106
- options: {
107
- performance: performance
108
- }
109
- }]
110
- });
75
+ const turbopackRules = {
76
+ [demoPathPattern]: {
77
+ loaders: [{
78
+ loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
79
+ options: {
80
+ performance,
81
+ output
82
+ }
83
+ }]
84
+ },
85
+ [clientDemoPathPattern]: {
86
+ loaders: [{
87
+ loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient',
88
+ options: {
89
+ performance
90
+ }
91
+ }]
92
+ },
93
+ './app/sitemap/index.ts': {
94
+ loaders: [{
95
+ loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedSitemap',
96
+ options: {
97
+ performance
98
+ }
99
+ }]
100
+ }
101
+ };
111
102
 
112
103
  // Add additional demo patterns to Turbopack rules
113
104
  if (additionalDemoPatterns.index) {
114
- additionalDemoPatterns.index.forEach(function (pattern) {
105
+ additionalDemoPatterns.index.forEach(pattern => {
115
106
  turbopackRules[pattern] = {
116
107
  loaders: [{
117
108
  loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
118
109
  options: {
119
- performance: performance,
120
- output: output
110
+ performance,
111
+ output
121
112
  }
122
113
  }]
123
114
  };
124
115
  });
125
116
  }
126
117
  if (additionalDemoPatterns.client) {
127
- additionalDemoPatterns.client.forEach(function (pattern) {
118
+ additionalDemoPatterns.client.forEach(pattern => {
128
119
  turbopackRules[pattern] = {
129
120
  loaders: [{
130
121
  loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient',
131
122
  options: {
132
- performance: performance
123
+ performance
133
124
  }
134
125
  }]
135
126
  };
@@ -138,15 +129,20 @@ export function withDocsInfra() {
138
129
 
139
130
  // Merge with additional turbopack rules
140
131
  Object.assign(turbopackRules, additionalTurbopackRules);
141
- var config = _extends(_extends(_extends({}, nextConfig), {}, {
142
- pageExtensions: pageExtensions
143
- }, enableExportOutput && {
144
- output: 'export'
145
- }), {}, {
146
- turbopack: _extends(_extends({}, nextConfig.turbopack), {}, {
147
- rules: _extends(_extends({}, (_nextConfig$turbopack = nextConfig.turbopack) == null ? void 0 : _nextConfig$turbopack.rules), turbopackRules)
132
+ const config = {
133
+ ...nextConfig,
134
+ pageExtensions,
135
+ ...(enableExportOutput && {
136
+ output: 'export'
148
137
  }),
149
- webpack: function webpack(webpackConfig, webpackOptions) {
138
+ turbopack: {
139
+ ...nextConfig.turbopack,
140
+ rules: {
141
+ ...nextConfig.turbopack?.rules,
142
+ ...turbopackRules
143
+ }
144
+ },
145
+ webpack: (webpackConfig, webpackOptions) => {
150
146
  // Call existing webpack function if it exists
151
147
  if (nextConfig.webpack) {
152
148
  webpackConfig = nextConfig.webpack(webpackConfig, webpackOptions);
@@ -159,7 +155,9 @@ export function withDocsInfra() {
159
155
  if (!webpackConfig.module.rules) {
160
156
  webpackConfig.module.rules = [];
161
157
  }
162
- var defaultLoaders = webpackOptions.defaultLoaders;
158
+ const {
159
+ defaultLoaders
160
+ } = webpackOptions;
163
161
 
164
162
  // Add loader for demo index files
165
163
  webpackConfig.module.rules.push({
@@ -167,8 +165,8 @@ export function withDocsInfra() {
167
165
  use: [defaultLoaders.babel, {
168
166
  loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
169
167
  options: {
170
- performance: performance,
171
- output: output
168
+ performance,
169
+ output
172
170
  }
173
171
  }]
174
172
  });
@@ -179,7 +177,7 @@ export function withDocsInfra() {
179
177
  use: [defaultLoaders.babel, {
180
178
  loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient',
181
179
  options: {
182
- performance: performance
180
+ performance
183
181
  }
184
182
  }]
185
183
  });
@@ -190,56 +188,56 @@ export function withDocsInfra() {
190
188
  use: [defaultLoaders.babel, {
191
189
  loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedSitemap',
192
190
  options: {
193
- performance: performance
191
+ performance
194
192
  }
195
193
  }]
196
194
  });
197
195
 
198
196
  // Add webpack rules for additional demo patterns
199
197
  if (additionalDemoPatterns.index) {
200
- additionalDemoPatterns.index.forEach(function (pattern) {
198
+ additionalDemoPatterns.index.forEach(pattern => {
201
199
  // Convert Turbopack pattern to webpack regex
202
200
  // Pattern like './app/**/demos/*/demo-*/index.ts'
203
201
  // Should match paths like '/app/components/demos/Button/demo-variant/index.ts'
204
202
  // Use placeholders to avoid corrupting character classes during replacement
205
- var SEP = 'PATH_SEP_PLACEHOLDER';
206
- var NOT_SEP = 'NOT_PATH_SEP_PLACEHOLDER';
207
- var regexPattern = pattern.replace(/^\.\//, '') // Remove leading ./
203
+ const SEP = 'PATH_SEP_PLACEHOLDER';
204
+ const NOT_SEP = 'NOT_PATH_SEP_PLACEHOLDER';
205
+ const regexPattern = pattern.replace(/^\.\//, '') // Remove leading ./
208
206
  .replace(/\*\*\//g, 'DOUBLE_STAR_PLACEHOLDER') // Replace **/ with placeholder
209
207
  .replace(/\*/g, NOT_SEP) // Replace single * with placeholder
210
208
  .replace(/\./g, '\\.') // Escape dots
211
- .replace(/DOUBLE_STAR_PLACEHOLDER/g, "(?:".concat(NOT_SEP).concat(SEP, ")*")) // Replace placeholder with zero or more directories
209
+ .replace(/DOUBLE_STAR_PLACEHOLDER/g, `(?:${NOT_SEP}${SEP})*`) // Replace placeholder with zero or more directories
212
210
  .replace(/\//g, SEP) // Convert all path separators to placeholder
213
211
  .replace(new RegExp(NOT_SEP, 'g'), '[^/\\\\]+') // Replace NOT_SEP with actual pattern
214
212
  .replace(new RegExp(SEP, 'g'), '[/\\\\]'); // Replace SEP with actual pattern
215
213
 
216
214
  webpackConfig.module.rules.push({
217
- test: new RegExp("".concat(regexPattern, "$")),
215
+ test: new RegExp(`${regexPattern}$`),
218
216
  use: [defaultLoaders.babel, {
219
217
  loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
220
218
  options: {
221
- performance: performance,
222
- output: output
219
+ performance,
220
+ output
223
221
  }
224
222
  }]
225
223
  });
226
224
  });
227
225
  }
228
226
  if (additionalDemoPatterns.client) {
229
- additionalDemoPatterns.client.forEach(function (pattern) {
227
+ additionalDemoPatterns.client.forEach(pattern => {
230
228
  // Convert Turbopack pattern to webpack regex
231
- var regexPattern = pattern.replace(/^\.\//, '/') // Remove leading ./
229
+ const regexPattern = pattern.replace(/^\.\//, '/') // Remove leading ./
232
230
  .replace(/\*\*\//g, 'DOUBLE_STAR_PLACEHOLDER') // Replace **/ with placeholder
233
231
  .replace(/\*/g, '[^/\\\\]+') // Replace single * with single dir pattern
234
232
  .replace(/\./g, '\\.') // Escape dots
235
233
  .replace(/DOUBLE_STAR_PLACEHOLDER/g, '(?:[^/\\\\]+/)*'); // Replace placeholder with zero or more directories
236
234
 
237
235
  webpackConfig.module.rules.push({
238
- test: new RegExp("".concat(regexPattern, "$")),
236
+ test: new RegExp(`${regexPattern}$`),
239
237
  use: [defaultLoaders.babel, {
240
238
  loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient',
241
239
  options: {
242
- performance: performance
240
+ performance
243
241
  }
244
242
  }]
245
243
  });
@@ -247,7 +245,7 @@ export function withDocsInfra() {
247
245
  }
248
246
  return webpackConfig;
249
247
  }
250
- });
248
+ };
251
249
  return config;
252
250
  };
253
251
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.3.1-canary.3",
3
+ "version": "0.3.1-canary.5",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "bin": {
@@ -40,7 +40,6 @@
40
40
  "kebab-case": "^2.0.2",
41
41
  "lz-string": "^1.5.0",
42
42
  "path-module": "^0.1.2",
43
- "prettier": "~3.7.4",
44
43
  "proper-lockfile": "^4.1.2",
45
44
  "uint8-to-base64": "^0.2.1",
46
45
  "unist-util-visit": "^5.0.0",
@@ -49,7 +48,8 @@
49
48
  },
50
49
  "peerDependencies": {
51
50
  "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
52
- "next": "^13.5.1 || ^14 || ^15.0.0",
51
+ "next": "^15.0.0 || ^16.0.0",
52
+ "prettier": "^3.0.0",
53
53
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0"
54
54
  },
55
55
  "peerDependenciesMeta": {
@@ -58,6 +58,9 @@
58
58
  },
59
59
  "next": {
60
60
  "optional": true
61
+ },
62
+ "prettier": {
63
+ "optional": true
61
64
  }
62
65
  },
63
66
  "publishConfig": {
@@ -329,5 +332,5 @@
329
332
  },
330
333
  "./esm": null
331
334
  },
332
- "gitSha": "d451af44f7bc27fd589bdeda8f07395fa2037ad8"
335
+ "gitSha": "7e5b82fa5e2b5050a2133dd0dd873978219f5999"
333
336
  }