@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.
- 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
|
@@ -1,60 +1,25 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
7
1
|
import { create, patch } from 'jsondiffpatch';
|
|
8
|
-
|
|
2
|
+
const differ = create({
|
|
9
3
|
omitRemovedValues: true,
|
|
10
4
|
cloneDiffValues: true
|
|
11
5
|
});
|
|
12
|
-
export function diffHast(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case 0:
|
|
28
|
-
_ref3 = _slicedToArray(_ref, 2), key = _ref3[0], transform = _ref3[1];
|
|
29
|
-
patched = patch(source.split('\n'), transform.delta);
|
|
30
|
-
if (Array.isArray(patched)) {
|
|
31
|
-
_context.n = 1;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
throw new Error("Patch for ".concat(key, " did not return an array"));
|
|
35
|
-
case 1:
|
|
36
|
-
transformedSource = patched.join('\n');
|
|
37
|
-
_context.n = 2;
|
|
38
|
-
return parseSource(transformedSource, transform.fileName || filename);
|
|
39
|
-
case 2:
|
|
40
|
-
parsedTransform = _context.v;
|
|
41
|
-
// TODO: further optimize this delta, it looks a little noisy
|
|
42
|
-
delta = differ.diff(parsedSource, parsedTransform);
|
|
43
|
-
return _context.a(2, _defineProperty({}, key, _extends(_extends({}, transform), {}, {
|
|
44
|
-
delta: delta
|
|
45
|
-
})));
|
|
46
|
-
}
|
|
47
|
-
}, _callee);
|
|
48
|
-
}));
|
|
49
|
-
return function (_x6) {
|
|
50
|
-
return _ref2.apply(this, arguments);
|
|
51
|
-
};
|
|
52
|
-
}()));
|
|
53
|
-
case 1:
|
|
54
|
-
transformed = _context2.v;
|
|
55
|
-
return _context2.a(2, Object.assign.apply(Object, [{}].concat(_toConsumableArray(transformed))));
|
|
6
|
+
export async function diffHast(source, parsedSource, filename, transforms, parseSource) {
|
|
7
|
+
const transformed = await Promise.all(Object.entries(transforms).map(async ([key, transform]) => {
|
|
8
|
+
const patched = patch(source.split('\n'), transform.delta);
|
|
9
|
+
if (!Array.isArray(patched)) {
|
|
10
|
+
throw new Error(`Patch for ${key} did not return an array`);
|
|
11
|
+
}
|
|
12
|
+
const transformedSource = patched.join('\n');
|
|
13
|
+
const parsedTransform = await parseSource(transformedSource, transform.fileName || filename);
|
|
14
|
+
|
|
15
|
+
// TODO: further optimize this delta, it looks a little noisy
|
|
16
|
+
const delta = differ.diff(parsedSource, parsedTransform);
|
|
17
|
+
return {
|
|
18
|
+
[key]: {
|
|
19
|
+
...transform,
|
|
20
|
+
delta
|
|
56
21
|
}
|
|
57
|
-
}
|
|
22
|
+
};
|
|
58
23
|
}));
|
|
59
|
-
return
|
|
24
|
+
return Object.assign({}, ...transformed);
|
|
60
25
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
1
|
/**
|
|
3
2
|
* Variant examination utility for analyzing variant structure and paths
|
|
4
3
|
*/
|
|
@@ -8,38 +7,36 @@ import { getUrlParts, calculateMaxSourceBackNavigation } from "./pathUtils.js";
|
|
|
8
7
|
* Create path context for processing files with extended information
|
|
9
8
|
*/
|
|
10
9
|
export function examineCodeVariant(variant) {
|
|
11
|
-
|
|
12
|
-
return _typeof(file) === 'object' && file.metadata;
|
|
13
|
-
}) : false;
|
|
10
|
+
const hasMetadata = variant.extraFiles ? Object.values(variant.extraFiles).some(file => typeof file === 'object' && file.metadata) : false;
|
|
14
11
|
|
|
15
12
|
// Calculate maxSourceBackNavigation based only on extraFiles structure
|
|
16
|
-
|
|
13
|
+
const maxSourceBackNavigation = variant.extraFiles ? calculateMaxSourceBackNavigation(variant.extraFiles) : 0;
|
|
17
14
|
|
|
18
15
|
// Parse URL to determine path structure
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
let urlDirectory = [];
|
|
17
|
+
let rootLevel = '';
|
|
18
|
+
let pathInwardFromRoot = '';
|
|
22
19
|
if (variant.url && variant.url.includes('://')) {
|
|
23
20
|
try {
|
|
24
|
-
|
|
21
|
+
const pathComponents = getUrlParts(variant.url);
|
|
25
22
|
if (pathComponents.length > 0) {
|
|
26
23
|
// Check if the last component looks like a filename (has an extension)
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const lastComponent = pathComponents[pathComponents.length - 1];
|
|
25
|
+
const hasFileExtension = lastComponent.includes('.') && /\.[a-zA-Z0-9]+$/.test(lastComponent);
|
|
29
26
|
|
|
30
27
|
// If it has a file extension, exclude it from directory components
|
|
31
|
-
|
|
28
|
+
const directoryComponents = hasFileExtension ? pathComponents.slice(0, -1) : pathComponents;
|
|
32
29
|
urlDirectory = directoryComponents;
|
|
33
30
|
rootLevel = directoryComponents[0] || '';
|
|
34
31
|
|
|
35
32
|
// Only calculate pathInwardFromRoot if there's actual back navigation
|
|
36
33
|
if (maxSourceBackNavigation > 0 && directoryComponents.length >= maxSourceBackNavigation) {
|
|
37
34
|
// Take the last maxSourceBackNavigation components as the pathInwardFromRoot
|
|
38
|
-
|
|
35
|
+
const relevantComponents = directoryComponents.slice(-maxSourceBackNavigation);
|
|
39
36
|
pathInwardFromRoot = relevantComponents.join('/');
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
} catch
|
|
39
|
+
} catch {
|
|
43
40
|
// If URL parsing fails, keep defaults
|
|
44
41
|
urlDirectory = [];
|
|
45
42
|
rootLevel = '';
|
|
@@ -48,26 +45,26 @@ export function examineCodeVariant(variant) {
|
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
// We keep the URL info for compatibility, but don't use it for calculations
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const hasUrl = Boolean(variant.url);
|
|
49
|
+
const actualUrl = variant.url;
|
|
53
50
|
if (hasUrl && actualUrl) {
|
|
54
51
|
return {
|
|
55
52
|
hasUrl: true,
|
|
56
|
-
hasMetadata
|
|
57
|
-
maxSourceBackNavigation
|
|
58
|
-
urlDirectory
|
|
59
|
-
rootLevel
|
|
60
|
-
pathInwardFromRoot
|
|
61
|
-
actualUrl
|
|
53
|
+
hasMetadata,
|
|
54
|
+
maxSourceBackNavigation,
|
|
55
|
+
urlDirectory,
|
|
56
|
+
rootLevel,
|
|
57
|
+
pathInwardFromRoot,
|
|
58
|
+
actualUrl
|
|
62
59
|
};
|
|
63
60
|
}
|
|
64
61
|
return {
|
|
65
62
|
hasUrl: false,
|
|
66
|
-
hasMetadata
|
|
67
|
-
maxSourceBackNavigation
|
|
68
|
-
urlDirectory
|
|
69
|
-
rootLevel
|
|
70
|
-
pathInwardFromRoot
|
|
63
|
+
hasMetadata,
|
|
64
|
+
maxSourceBackNavigation,
|
|
65
|
+
urlDirectory,
|
|
66
|
+
rootLevel,
|
|
67
|
+
pathInwardFromRoot,
|
|
71
68
|
actualUrl: undefined
|
|
72
69
|
};
|
|
73
70
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
/**
|
|
3
2
|
* Flatten variant utility to convert a VariantCode into a flat files list
|
|
4
3
|
* Handles relative path resolution and metadata file scoping
|
|
@@ -13,10 +12,10 @@ import { addPathsToVariant } from "./addCodeVariantPaths.js";
|
|
|
13
12
|
* Uses addPathsToVariant for path resolution logic
|
|
14
13
|
*/
|
|
15
14
|
export function flattenCodeVariant(variant) {
|
|
16
|
-
|
|
15
|
+
const result = {};
|
|
17
16
|
|
|
18
17
|
// Use addPathsToVariant to get the structured paths
|
|
19
|
-
|
|
18
|
+
const variantWithPaths = addPathsToVariant(variant);
|
|
20
19
|
|
|
21
20
|
// Add main file if it exists
|
|
22
21
|
if (variantWithPaths.path && variantWithPaths.source !== undefined) {
|
|
@@ -27,8 +26,7 @@ export function flattenCodeVariant(variant) {
|
|
|
27
26
|
|
|
28
27
|
// Add extra files if they exist
|
|
29
28
|
if (variantWithPaths.extraFiles) {
|
|
30
|
-
for (
|
|
31
|
-
var fileWithPath = _Object$values[_i];
|
|
29
|
+
for (const fileWithPath of Object.values(variantWithPaths.extraFiles)) {
|
|
32
30
|
// Skip files that are just URLs or missing a path
|
|
33
31
|
if (typeof fileWithPath === 'string' || !fileWithPath.path) {
|
|
34
32
|
continue;
|
|
@@ -38,11 +36,12 @@ export function flattenCodeVariant(variant) {
|
|
|
38
36
|
if (!fileWithPath.source && fileWithPath.source !== '') {
|
|
39
37
|
continue;
|
|
40
38
|
}
|
|
41
|
-
result[fileWithPath.path] =
|
|
42
|
-
source: stringOrHastToString(fileWithPath.source || '')
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
result[fileWithPath.path] = {
|
|
40
|
+
source: stringOrHastToString(fileWithPath.source || ''),
|
|
41
|
+
...(fileWithPath.metadata && {
|
|
42
|
+
metadata: fileWithPath.metadata
|
|
43
|
+
})
|
|
44
|
+
};
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
return result;
|
|
@@ -43,17 +43,17 @@ function isSourceLoaded(code, needsHighlight) {
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
export function hasAllVariants(variants, code, needsHighlight) {
|
|
46
|
-
return variants.every(
|
|
47
|
-
|
|
46
|
+
return variants.every(variant => {
|
|
47
|
+
const codeVariant = code?.[variant];
|
|
48
48
|
if (!codeVariant || typeof codeVariant === 'string' || !isSourceLoaded(codeVariant, needsHighlight)) {
|
|
49
49
|
return false;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
const extraFiles = codeVariant.extraFiles;
|
|
52
52
|
if (!extraFiles) {
|
|
53
53
|
return true;
|
|
54
54
|
}
|
|
55
|
-
return Object.keys(extraFiles).every(
|
|
56
|
-
|
|
55
|
+
return Object.keys(extraFiles).every(file => {
|
|
56
|
+
const extraFile = extraFiles[file];
|
|
57
57
|
if (!extraFile || typeof extraFile === 'string' || !isSourceLoaded(extraFile, needsHighlight)) {
|
|
58
58
|
return false;
|
|
59
59
|
}
|