@mui/internal-docs-infra 0.3.1-canary.2 → 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 +252 -327
- 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/CodeHighlighter/types.d.ts +7 -1
- 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 +517 -727
- package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +683 -1032
- 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.d.ts +24 -0
- package/esm/pipeline/loaderUtils/getLanguageFromExtension.js +62 -0
- package/esm/pipeline/loaderUtils/index.d.ts +2 -1
- package/esm/pipeline/loaderUtils/index.js +2 -1
- 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.d.ts +12 -1
- package/esm/pipeline/parseSource/grammars.js +36 -4
- package/esm/pipeline/parseSource/index.d.ts +2 -1
- package/esm/pipeline/parseSource/index.js +2 -1
- package/esm/pipeline/parseSource/parseSource.js +23 -32
- 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 +266 -320
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +10 -10
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +183 -267
- 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.d.ts +2 -0
- package/esm/useCode/Pre.js +58 -60
- 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 +171 -209
- 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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
export
|
|
4
|
+
export const CodeHighlighterContext = /*#__PURE__*/React.createContext(undefined);
|
|
5
5
|
if (process.env.NODE_ENV !== "production") CodeHighlighterContext.displayName = "CodeHighlighterContext";
|
|
6
6
|
export function useCodeHighlighterContext() {
|
|
7
|
-
|
|
7
|
+
const context = React.useContext(CodeHighlighterContext);
|
|
8
8
|
if (context === undefined) {
|
|
9
9
|
throw new Error('CodeHighlighterContext is missing. `useCodeHighlighterContext` must be used within a `CodeHighlighter` component.');
|
|
10
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
export
|
|
4
|
+
export const CodeHighlighterFallbackContext = /*#__PURE__*/React.createContext(undefined);
|
|
5
5
|
if (process.env.NODE_ENV !== "production") CodeHighlighterFallbackContext.displayName = "CodeHighlighterFallbackContext";
|
|
6
6
|
export function useCodeHighlighterFallbackContext() {
|
|
7
|
-
|
|
7
|
+
const context = React.useContext(CodeHighlighterFallbackContext);
|
|
8
8
|
if (context === undefined) {
|
|
9
9
|
throw new Error('CodeHighlighterFallbackContext is missing. `useCodeHighlighterFallbackContext` must be used within a `CodeHighlighter` component.');
|
|
10
10
|
}
|
|
@@ -1,51 +1,35 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
1
|
import { stringOrHastToJsx } from "../pipeline/hastUtils/index.js";
|
|
5
2
|
function toExtraSource(variantCode, fileName) {
|
|
6
|
-
return Object.entries(variantCode.extraFiles || {}).reduce(
|
|
7
|
-
|
|
8
|
-
name = _ref2[0],
|
|
9
|
-
file = _ref2[1];
|
|
10
|
-
if (name !== fileName && _typeof(file) === 'object' && file != null && file.source) {
|
|
3
|
+
return Object.entries(variantCode.extraFiles || {}).reduce((acc, [name, file]) => {
|
|
4
|
+
if (name !== fileName && typeof file === 'object' && file?.source) {
|
|
11
5
|
acc[name] = stringOrHastToJsx(file.source);
|
|
12
6
|
}
|
|
13
7
|
return acc;
|
|
14
8
|
}, {});
|
|
15
9
|
}
|
|
16
|
-
export function codeToFallbackProps(variant, code, fileName) {
|
|
17
|
-
|
|
18
|
-
var needsAllVariants = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
19
|
-
var variantCode = code == null ? void 0 : code[variant];
|
|
10
|
+
export function codeToFallbackProps(variant, code, fileName, needsAllFiles = false, needsAllVariants = false) {
|
|
11
|
+
const variantCode = code?.[variant];
|
|
20
12
|
if (!variantCode || typeof variantCode === 'string') {
|
|
21
13
|
return {};
|
|
22
14
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
var source;
|
|
15
|
+
const fileNames = [variantCode.fileName, ...Object.keys(variantCode.extraFiles || {})].filter(name => Boolean(name));
|
|
16
|
+
let source;
|
|
27
17
|
if (fileName && fileName !== variantCode.fileName) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (fileData && _typeof(fileData) === 'object' && 'source' in fileData && fileData.source) {
|
|
18
|
+
const fileData = variantCode.extraFiles?.[fileName];
|
|
19
|
+
if (fileData && typeof fileData === 'object' && 'source' in fileData && fileData.source) {
|
|
31
20
|
source = stringOrHastToJsx(fileData.source);
|
|
32
21
|
}
|
|
33
22
|
} else if (variantCode.source) {
|
|
34
23
|
source = stringOrHastToJsx(variantCode.source);
|
|
35
24
|
}
|
|
36
25
|
if (needsAllVariants || needsAllFiles) {
|
|
37
|
-
|
|
26
|
+
const extraSource = toExtraSource(variantCode, fileName);
|
|
38
27
|
if (needsAllVariants) {
|
|
39
|
-
|
|
40
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
41
|
-
name = _ref4[0],
|
|
42
|
-
vCode = _ref4[1];
|
|
28
|
+
const extraVariants = Object.entries(code || {}).reduce((acc, [name, vCode]) => {
|
|
43
29
|
if (name !== variant && vCode && typeof vCode !== 'string') {
|
|
44
|
-
|
|
30
|
+
const extraVariantExtraSource = toExtraSource(vCode, vCode.fileName);
|
|
45
31
|
acc[name] = {
|
|
46
|
-
fileNames: [vCode.fileName
|
|
47
|
-
return Boolean(fn);
|
|
48
|
-
}),
|
|
32
|
+
fileNames: [vCode.fileName, ...Object.keys(vCode.extraFiles || {})].filter(fn => Boolean(fn)),
|
|
49
33
|
// TODO: use filesOrder if provided
|
|
50
34
|
source: vCode.source && stringOrHastToJsx(vCode.source),
|
|
51
35
|
extraSource: extraVariantExtraSource
|
|
@@ -54,20 +38,20 @@ export function codeToFallbackProps(variant, code, fileName) {
|
|
|
54
38
|
return acc;
|
|
55
39
|
}, {});
|
|
56
40
|
return {
|
|
57
|
-
fileNames
|
|
58
|
-
source
|
|
59
|
-
extraSource
|
|
60
|
-
extraVariants
|
|
41
|
+
fileNames,
|
|
42
|
+
source,
|
|
43
|
+
extraSource,
|
|
44
|
+
extraVariants
|
|
61
45
|
};
|
|
62
46
|
}
|
|
63
47
|
return {
|
|
64
|
-
fileNames
|
|
65
|
-
source
|
|
66
|
-
extraSource
|
|
48
|
+
fileNames,
|
|
49
|
+
source,
|
|
50
|
+
extraSource
|
|
67
51
|
};
|
|
68
52
|
}
|
|
69
53
|
return {
|
|
70
|
-
fileNames
|
|
71
|
-
source
|
|
54
|
+
fileNames,
|
|
55
|
+
source
|
|
72
56
|
};
|
|
73
57
|
}
|