@mui/internal-docs-infra 0.3.1-canary.3 → 0.3.1-canary.4
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.
- package/esm/CodeControllerContext/CodeControllerContext.js +2 -2
- package/esm/CodeExternalsContext/CodeExternalsContext.js +1 -1
- package/esm/CodeHighlighter/CodeHighlighter.js +247 -329
- package/esm/CodeHighlighter/CodeHighlighterClient.js +447 -653
- package/esm/CodeHighlighter/CodeHighlighterContext.js +2 -2
- package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +2 -2
- package/esm/CodeHighlighter/codeToFallbackProps.js +21 -37
- package/esm/CodeHighlighter/errors.js +248 -400
- package/esm/CodeHighlighter/parseControlledCode.js +12 -20
- package/esm/CodeProvider/CodeContext.js +3 -3
- package/esm/CodeProvider/CodeProvider.js +31 -40
- package/esm/abstractCreateDemo/abstractCreateDemo.js +13 -17
- package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +12 -12
- package/esm/cli/index.js +1 -1
- package/esm/cli/runValidate.js +160 -264
- package/esm/createDemoData/createDemoData.js +11 -12
- package/esm/createSitemap/createSitemap.js +2 -2
- package/esm/pipeline/getFileConventions/fileConventions.js +1 -1
- package/esm/pipeline/getFileConventions/getFileConventions.js +2 -15
- package/esm/pipeline/hastUtils/hastUtils.js +16 -17
- package/esm/pipeline/loadCodeVariant/addCodeVariantPaths.js +24 -24
- package/esm/pipeline/loadCodeVariant/applyCodeTransform.js +12 -22
- package/esm/pipeline/loadCodeVariant/calculateMainFilePath.js +30 -37
- package/esm/pipeline/loadCodeVariant/computeHastDeltas.js +107 -185
- package/esm/pipeline/loadCodeVariant/diffHast.js +18 -53
- package/esm/pipeline/loadCodeVariant/examineCodeVariant.js +24 -27
- package/esm/pipeline/loadCodeVariant/flattenCodeVariant.js +9 -10
- package/esm/pipeline/loadCodeVariant/hasAllCodeVariants.js +5 -5
- package/esm/pipeline/loadCodeVariant/loadCodeFallback.js +516 -731
- package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +679 -1079
- package/esm/pipeline/loadCodeVariant/maybeCodeInitialData.js +14 -20
- package/esm/pipeline/loadCodeVariant/mergeCodeMetadata.js +53 -63
- package/esm/pipeline/loadCodeVariant/parseCode.js +40 -48
- package/esm/pipeline/loadCodeVariant/pathUtils.js +43 -64
- package/esm/pipeline/loadCodeVariant/transformSource.js +55 -125
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +160 -221
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +377 -479
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +171 -173
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +14 -30
- package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +19 -21
- package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +37 -71
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +3 -9
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +54 -80
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +71 -98
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +5 -5
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +161 -211
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +159 -207
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +42 -64
- package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.js +20 -96
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +66 -85
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +71 -118
- package/esm/pipeline/loadServerSource/loadServerSource.js +121 -148
- package/esm/pipeline/loaderUtils/externalsToPackages.js +7 -7
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +8 -12
- package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +5 -5
- package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +19 -29
- package/esm/pipeline/loaderUtils/getLanguageFromExtension.js +3 -4
- package/esm/pipeline/loaderUtils/mergeExternals.js +15 -35
- package/esm/pipeline/loaderUtils/parseImportsAndComments.js +413 -433
- package/esm/pipeline/loaderUtils/processRelativeImports.js +153 -239
- package/esm/pipeline/loaderUtils/resolveModulePath.js +544 -1303
- package/esm/pipeline/loaderUtils/rewriteImports.js +73 -111
- package/esm/pipeline/parseSource/addLineGutters.js +33 -45
- package/esm/pipeline/parseSource/grammars.js +3 -3
- package/esm/pipeline/parseSource/parseSource.js +13 -31
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +32 -55
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +107 -160
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +846 -1033
- package/esm/pipeline/syncPageIndex/syncPageIndex.js +291 -438
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +213 -311
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +10 -10
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +133 -193
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +25 -27
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +572 -717
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +8 -8
- package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +84 -113
- package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +10 -26
- package/esm/useCode/Pre.js +58 -62
- package/esm/useCode/useCode.js +59 -61
- package/esm/useCode/useCodeUtils.js +54 -63
- package/esm/useCode/useCopyFunctionality.js +10 -9
- package/esm/useCode/useFileNavigation.js +150 -212
- package/esm/useCode/useSourceEditing.js +17 -14
- package/esm/useCode/useTransformManagement.js +23 -26
- package/esm/useCode/useUIState.js +12 -20
- package/esm/useCode/useVariantSelection.js +62 -79
- package/esm/useCopier/index.js +29 -56
- package/esm/useDemo/createCodeSandbox.js +12 -15
- package/esm/useDemo/createStackBlitz.js +14 -20
- package/esm/useDemo/exportVariant.js +200 -180
- package/esm/useDemo/exportVariantAsCra.js +22 -25
- package/esm/useDemo/useDemo.js +80 -84
- package/esm/useErrors/ErrorsContext.js +1 -1
- package/esm/useErrors/useErrors.js +3 -3
- package/esm/useLocalStorageState/useLocalStorageState.js +23 -39
- package/esm/usePreference/PreferencesProvider.js +1 -1
- package/esm/usePreference/usePreference.js +9 -11
- package/esm/useSearch/useSearch.js +290 -387
- package/esm/useUrlHashState/useUrlHashState.js +11 -14
- package/esm/withDocsInfra/withDeploymentConfig.js +26 -21
- package/esm/withDocsInfra/withDocsInfra.js +99 -101
- 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
|
-
|
|
11
|
+
const subscriberRef = React.useRef(null);
|
|
12
12
|
|
|
13
13
|
// Subscribe to hash changes
|
|
14
|
-
|
|
14
|
+
const subscribe = React.useCallback(callback => {
|
|
15
15
|
subscriberRef.current = callback;
|
|
16
16
|
if (typeof window === 'undefined') {
|
|
17
|
-
return
|
|
17
|
+
return () => {
|
|
18
18
|
subscriberRef.current = null;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
window.addEventListener('hashchange', callback);
|
|
22
|
-
return
|
|
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
|
-
|
|
29
|
+
const getSnapshot = React.useCallback(() => {
|
|
30
30
|
if (typeof window === 'undefined') {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
|
-
|
|
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
|
-
|
|
42
|
-
return null;
|
|
43
|
-
}, []);
|
|
41
|
+
const getServerSnapshot = React.useCallback(() => null, []);
|
|
44
42
|
|
|
45
43
|
// Use useSyncExternalStore for hash synchronization
|
|
46
|
-
|
|
44
|
+
const hash = React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
47
45
|
|
|
48
46
|
// Set hash in URL and state
|
|
49
|
-
|
|
50
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
33
|
+
return {
|
|
35
34
|
trailingSlash: true,
|
|
36
35
|
reactStrictMode: true,
|
|
37
|
-
productionBrowserSourceMaps: true
|
|
38
|
-
|
|
39
|
-
env:
|
|
36
|
+
productionBrowserSourceMaps: true,
|
|
37
|
+
...nextConfig,
|
|
38
|
+
env: {
|
|
40
39
|
// production | staging | pull-request | development
|
|
41
|
-
DEPLOY_ENV
|
|
42
|
-
|
|
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:
|
|
56
|
+
},
|
|
57
|
+
experimental: {
|
|
59
58
|
scrollRestoration: true,
|
|
60
|
-
workerThreads: false
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
|
24
|
+
baseDir: baseDir ?? process.cwd()
|
|
30
25
|
};
|
|
31
26
|
} else {
|
|
32
|
-
extractToIndexOptions =
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
extractToIndexOptions = {
|
|
28
|
+
...extractToIndex,
|
|
29
|
+
baseDir: baseDir ?? process.cwd()
|
|
30
|
+
};
|
|
35
31
|
}
|
|
36
|
-
|
|
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
|
|
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
|
-
|
|
37
|
+
const defaultRehypePlugins = [['@mui/internal-docs-infra/pipeline/transformHtmlCodePrecomputed']];
|
|
42
38
|
|
|
43
39
|
// Build final plugin arrays
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const remarkPlugins = customOptions.remarkPlugins ?? [...defaultRemarkPlugins, ...(customOptions.additionalRemarkPlugins ?? [])];
|
|
41
|
+
const rehypePlugins = customOptions.rehypePlugins ?? [...defaultRehypePlugins, ...(customOptions.additionalRehypePlugins ?? [])];
|
|
46
42
|
return {
|
|
47
|
-
remarkPlugins
|
|
48
|
-
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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(
|
|
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
|
|
120
|
-
output
|
|
110
|
+
performance,
|
|
111
|
+
output
|
|
121
112
|
}
|
|
122
113
|
}]
|
|
123
114
|
};
|
|
124
115
|
});
|
|
125
116
|
}
|
|
126
117
|
if (additionalDemoPatterns.client) {
|
|
127
|
-
additionalDemoPatterns.client.forEach(
|
|
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
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
171
|
-
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
|
|
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
|
|
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(
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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,
|
|
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(
|
|
215
|
+
test: new RegExp(`${regexPattern}$`),
|
|
218
216
|
use: [defaultLoaders.babel, {
|
|
219
217
|
loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter',
|
|
220
218
|
options: {
|
|
221
|
-
performance
|
|
222
|
-
output
|
|
219
|
+
performance,
|
|
220
|
+
output
|
|
223
221
|
}
|
|
224
222
|
}]
|
|
225
223
|
});
|
|
226
224
|
});
|
|
227
225
|
}
|
|
228
226
|
if (additionalDemoPatterns.client) {
|
|
229
|
-
additionalDemoPatterns.client.forEach(
|
|
227
|
+
additionalDemoPatterns.client.forEach(pattern => {
|
|
230
228
|
// Convert Turbopack pattern to webpack regex
|
|
231
|
-
|
|
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(
|
|
236
|
+
test: new RegExp(`${regexPattern}$`),
|
|
239
237
|
use: [defaultLoaders.babel, {
|
|
240
238
|
loader: '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient',
|
|
241
239
|
options: {
|
|
242
|
-
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
|
+
"version": "0.3.1-canary.4",
|
|
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": "^
|
|
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": "
|
|
335
|
+
"gitSha": "e95855c7cc16bc19c8c0c2dee435ec3ed2cc3e8a"
|
|
333
336
|
}
|