@mui/internal-docs-infra 0.12.1-canary.10 → 0.12.1-canary.12
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-docs-infra",
|
|
3
|
-
"version": "0.12.1-canary.
|
|
3
|
+
"version": "0.12.1-canary.12",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "MUI Infra - internal documentation creation tools.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -804,5 +804,5 @@
|
|
|
804
804
|
"bin": {
|
|
805
805
|
"docs-infra": "./cli/index.mjs"
|
|
806
806
|
},
|
|
807
|
-
"gitSha": "
|
|
807
|
+
"gitSha": "cd265618d793d94a8126db916013526ce860e836"
|
|
808
808
|
}
|
|
@@ -49,7 +49,9 @@ async function transpileModule(module, nested, transpile, signal) {
|
|
|
49
49
|
compiledFiles.set(module.file, {
|
|
50
50
|
kind: 'moduleError',
|
|
51
51
|
nested,
|
|
52
|
-
|
|
52
|
+
// `toString()` (not `.message`) keeps the error name (e.g. `SyntaxError:`) in the
|
|
53
|
+
// surfaced message — the transpile paths reject with a live, named error.
|
|
54
|
+
error: error instanceof Error ? error.toString() : String(error)
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -64,7 +64,7 @@ export function useDemoController(options = {}) {
|
|
|
64
64
|
}
|
|
65
65
|
return `mui-docs-infra:demo-controller:${window.location.pathname}\u0000${url ?? ''}`;
|
|
66
66
|
}, [crossTabSync, url]);
|
|
67
|
-
const [code,
|
|
67
|
+
const [code, setControlledCode] = useCrossTabState(syncChannel, undefined);
|
|
68
68
|
// Build errors (transpile/CSS failures) and render errors (the entry throwing) live
|
|
69
69
|
// in SEPARATE maps so they never clobber each other: a build error is owned by
|
|
70
70
|
// `useVariantBuilds` (set on failure, cleared on the next good build); a render
|
|
@@ -95,6 +95,21 @@ export function useDemoController(options = {}) {
|
|
|
95
95
|
});
|
|
96
96
|
}, []);
|
|
97
97
|
|
|
98
|
+
// Reset (the toolbar button clears `code` to `undefined`) must also drop any stale
|
|
99
|
+
// build/render error, so a prior syntax error's overlay doesn't linger over the
|
|
100
|
+
// restored original — nothing rebuilds after a reset to clear it otherwise. Do it in
|
|
101
|
+
// the setter that performs the reset rather than reacting to the `code` change in an
|
|
102
|
+
// effect; the length guards keep each clear a no-op once its map is empty.
|
|
103
|
+
const setCode = React.useCallback(action => {
|
|
104
|
+
setControlledCode(action);
|
|
105
|
+
// A reset passes the cleared value directly (never a functional update), so a
|
|
106
|
+
// falsy argument is the reset — drop stale errors alongside it.
|
|
107
|
+
if (typeof action !== 'function' && !action) {
|
|
108
|
+
setBuildErrors(previous => Object.keys(previous).length > 0 ? {} : previous);
|
|
109
|
+
setRenderErrors(previous => Object.keys(previous).length > 0 ? {} : previous);
|
|
110
|
+
}
|
|
111
|
+
}, [setControlledCode]);
|
|
112
|
+
|
|
98
113
|
// Resolve the page-shared transpile (worker, or main-thread fallback) into state once
|
|
99
114
|
// there's code to build — a local first edit, or a cross-tab edit that arrives without
|
|
100
115
|
// this tab engaging its own editor. `onActivate` below has usually already spun the
|
|
@@ -168,12 +183,15 @@ export function useDemoController(options = {}) {
|
|
|
168
183
|
// Merge the two channels: a build failure takes precedence (the preview is stale
|
|
169
184
|
// until it builds), otherwise the render error, else `null`.
|
|
170
185
|
const errors = React.useMemo(() => {
|
|
186
|
+
if (!code) {
|
|
187
|
+
return {};
|
|
188
|
+
}
|
|
171
189
|
const merged = {};
|
|
172
190
|
for (const variant of new Set([...Object.keys(buildErrors), ...Object.keys(renderErrors)])) {
|
|
173
191
|
merged[variant] = buildErrors[variant] || renderErrors[variant] || null;
|
|
174
192
|
}
|
|
175
193
|
return merged;
|
|
176
|
-
}, [buildErrors, renderErrors]);
|
|
194
|
+
}, [code, buildErrors, renderErrors]);
|
|
177
195
|
return {
|
|
178
196
|
code,
|
|
179
197
|
setCode,
|
|
@@ -212,6 +212,12 @@ export function withDeploymentConfig(nextConfig) {
|
|
|
212
212
|
experimental: {
|
|
213
213
|
scrollRestoration: true,
|
|
214
214
|
workerThreads: false,
|
|
215
|
+
// Run each webpack compilation in a separate, disposable worker process so
|
|
216
|
+
// its memory is released before static generation instead of accumulating
|
|
217
|
+
// in the long-lived build process. This is off by default whenever a custom
|
|
218
|
+
// `webpack` config is present (Next resolves the `undefined` default to
|
|
219
|
+
// `false` when `config.webpack` is set), so it must be enabled explicitly.
|
|
220
|
+
webpackBuildWorker: true,
|
|
215
221
|
...(process.env.CI ? {
|
|
216
222
|
cpus: process.env.NEXT_PARALLELISM ? parseInt(process.env.NEXT_PARALLELISM, 10) : os.availableParallelism()
|
|
217
223
|
} : {}),
|