@mui/internal-docs-infra 0.2.3-canary.9 → 0.3.1-canary.0
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/README.md +3 -2
- package/esm/CodeHighlighter/CodeHighlighter.js +16 -16
- package/esm/CodeHighlighter/CodeHighlighterClient.js +33 -33
- package/esm/CodeHighlighter/errors.js +3 -3
- package/esm/CodeHighlighter/types.d.ts +1 -1
- package/esm/CodeProvider/CodeContext.d.ts +4 -4
- package/esm/CodeProvider/CodeProvider.js +7 -7
- package/esm/cli/index.d.ts +1 -0
- package/esm/cli/index.js +6 -0
- package/esm/cli/runValidate.d.ts +8 -0
- package/esm/cli/runValidate.js +297 -0
- package/esm/createSitemap/createSitemap.d.ts +23 -0
- package/esm/createSitemap/createSitemap.js +45 -0
- package/esm/createSitemap/index.d.ts +1 -0
- package/esm/createSitemap/index.js +1 -0
- package/esm/createSitemap/types.d.ts +68 -0
- package/esm/createSitemap/types.js +1 -0
- package/esm/pipeline/getFileConventions/fileConventions.d.ts +4 -0
- package/esm/pipeline/getFileConventions/fileConventions.js +4 -0
- package/esm/pipeline/getFileConventions/getFileConventions.d.ts +4 -0
- package/esm/pipeline/getFileConventions/getFileConventions.js +17 -0
- package/esm/pipeline/getFileConventions/index.d.ts +1 -0
- package/esm/pipeline/getFileConventions/index.js +1 -0
- package/esm/{CodeHighlighter/addPathsToVariant.d.ts → pipeline/loadCodeVariant/addCodeVariantPaths.d.ts} +1 -1
- package/esm/{CodeHighlighter/applyTransform.d.ts → pipeline/loadCodeVariant/applyCodeTransform.d.ts} +3 -3
- package/esm/{CodeHighlighter/applyTransform.js → pipeline/loadCodeVariant/applyCodeTransform.js} +4 -4
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.js +1 -1
- package/esm/{CodeHighlighter/transformCode.d.ts → pipeline/loadCodeVariant/computeHastDeltas.d.ts} +9 -5
- package/esm/{CodeHighlighter/transformCode.js → pipeline/loadCodeVariant/computeHastDeltas.js} +20 -16
- package/esm/pipeline/loadCodeVariant/diffHast.d.ts +3 -0
- package/esm/{CodeHighlighter/transformParsedSource.js → pipeline/loadCodeVariant/diffHast.js} +5 -5
- package/esm/{CodeHighlighter/examineVariant.d.ts → pipeline/loadCodeVariant/examineCodeVariant.d.ts} +2 -2
- package/esm/{CodeHighlighter/examineVariant.js → pipeline/loadCodeVariant/examineCodeVariant.js} +1 -1
- package/esm/{useDemo/flattenVariant.d.ts → pipeline/loadCodeVariant/flattenCodeVariant.d.ts} +2 -2
- package/esm/{useDemo/flattenVariant.js → pipeline/loadCodeVariant/flattenCodeVariant.js} +3 -3
- package/esm/{CodeHighlighter/hasAllVariants.d.ts → pipeline/loadCodeVariant/hasAllCodeVariants.d.ts} +1 -1
- package/esm/pipeline/loadCodeVariant/index.d.ts +10 -0
- package/esm/pipeline/loadCodeVariant/index.js +17 -0
- package/esm/{CodeHighlighter/loadFallbackCode.d.ts → pipeline/loadCodeVariant/loadCodeFallback.d.ts} +2 -2
- package/esm/{CodeHighlighter/loadFallbackCode.js → pipeline/loadCodeVariant/loadCodeFallback.js} +180 -106
- package/esm/{CodeHighlighter/loadVariant.d.ts → pipeline/loadCodeVariant/loadCodeVariant.d.ts} +2 -2
- package/esm/{CodeHighlighter/loadVariant.js → pipeline/loadCodeVariant/loadCodeVariant.js} +122 -49
- package/esm/{CodeHighlighter/maybeInitialData.d.ts → pipeline/loadCodeVariant/maybeCodeInitialData.d.ts} +6 -6
- package/esm/{CodeHighlighter/maybeInitialData.js → pipeline/loadCodeVariant/maybeCodeInitialData.js} +6 -6
- package/esm/{CodeHighlighter/mergeMetadata.d.ts → pipeline/loadCodeVariant/mergeCodeMetadata.d.ts} +3 -3
- package/esm/{CodeHighlighter/mergeMetadata.js → pipeline/loadCodeVariant/mergeCodeMetadata.js} +3 -3
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.d.ts +1 -1
- package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.d.ts +1 -1
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +5 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +86 -13
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.d.ts +30 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +77 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +7 -7
- package/esm/pipeline/loadPrecomputedSitemap/index.d.ts +2 -0
- package/esm/pipeline/loadPrecomputedSitemap/index.js +4 -0
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.d.ts +10 -0
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +213 -0
- package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
- package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +2 -2
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +1 -1
- package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +1 -1
- package/esm/pipeline/loadServerPageIndex/index.d.ts +2 -0
- package/esm/pipeline/loadServerPageIndex/index.js +1 -0
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.d.ts +51 -0
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +174 -0
- package/esm/pipeline/loadServerSitemap/index.d.ts +2 -0
- package/esm/pipeline/loadServerSitemap/index.js +1 -0
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.d.ts +39 -0
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +168 -0
- package/esm/pipeline/loadServerSource/loadServerSource.js +1 -1
- package/esm/pipeline/loaderUtils/externalsToPackages.js +1 -1
- package/esm/pipeline/loaderUtils/processRelativeImports.js +16 -3
- package/esm/pipeline/loaderUtils/rewriteImports.d.ts +36 -0
- package/esm/pipeline/loaderUtils/rewriteImports.js +139 -8
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.d.ts +76 -0
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +305 -0
- package/esm/pipeline/syncPageIndex/index.d.ts +1 -0
- package/esm/pipeline/syncPageIndex/index.js +1 -0
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.d.ts +58 -0
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +214 -0
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.d.ts +67 -0
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +1486 -0
- package/esm/pipeline/syncPageIndex/syncPageIndex.d.ts +108 -0
- package/esm/pipeline/syncPageIndex/syncPageIndex.js +540 -0
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/index.js +4 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.d.ts +16 -0
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +58 -0
- package/esm/pipeline/transformMarkdownDemoLinks/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownDemoLinks/index.js +4 -0
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.d.ts +26 -0
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +107 -0
- package/esm/pipeline/transformMarkdownMetadata/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownMetadata/index.js +4 -0
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.d.ts +3 -0
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +1010 -0
- package/esm/pipeline/transformMarkdownMetadata/types.d.ts +110 -0
- package/esm/pipeline/transformMarkdownMetadata/types.js +1 -0
- package/esm/pipeline/transformMarkdownRelativePaths/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownRelativePaths/index.js +4 -0
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.d.ts +15 -0
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +40 -0
- package/esm/useCode/Pre.js +15 -2
- package/esm/useCode/useCode.d.ts +15 -2
- package/esm/useCode/useCode.js +15 -6
- package/esm/useCode/useCodeUtils.js +3 -3
- package/esm/useCode/useFileNavigation.d.ts +9 -3
- package/esm/useCode/useFileNavigation.js +124 -81
- package/esm/useCode/useUIState.d.ts +4 -1
- package/esm/useCode/useUIState.js +17 -2
- package/esm/useCode/useVariantSelection.d.ts +8 -3
- package/esm/useCode/useVariantSelection.js +144 -52
- package/esm/useCopier/index.js +5 -4
- package/esm/useDemo/createCodeSandbox.d.ts +1 -1
- package/esm/useDemo/createStackBlitz.d.ts +1 -1
- package/esm/useDemo/exportVariant.js +13 -11
- package/esm/useDemo/index.d.ts +1 -1
- package/esm/useDemo/index.js +1 -1
- package/esm/useDemo/useDemo.d.ts +5 -5
- package/esm/useDemo/useDemo.js +6 -6
- package/esm/useErrors/useErrors.d.ts +1 -1
- package/esm/useErrors/useErrors.js +6 -2
- package/esm/useSearch/index.d.ts +1 -0
- package/esm/useSearch/index.js +1 -0
- package/esm/useSearch/types.d.ts +165 -0
- package/esm/useSearch/types.js +1 -0
- package/esm/useSearch/useSearch.d.ts +56 -0
- package/esm/useSearch/useSearch.js +647 -0
- package/esm/withDocsInfra/withDeploymentConfig.js +4 -2
- package/esm/withDocsInfra/withDocsInfra.d.ts +39 -0
- package/esm/withDocsInfra/withDocsInfra.js +79 -7
- package/package.json +105 -5
- package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
- /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
- /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
- /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.js +0 -0
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@ This package hosts the tools that help create the documentation.
|
|
|
4
4
|
|
|
5
5
|
## Documentation
|
|
6
6
|
|
|
7
|
-
This is stored in the `docs` directory.
|
|
7
|
+
This is stored in the `docs` top-level directory.
|
|
8
8
|
|
|
9
|
-
[Read
|
|
9
|
+
[Read in Markdown](../../docs/app/docs-infra/page.mdx)
|
|
10
|
+
[Read in Browser](https://infra.mui.com/docs-infra)
|
|
@@ -5,11 +5,11 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
5
5
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
6
6
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { loadCodeVariant } from "../pipeline/loadCodeVariant/loadCodeVariant.js";
|
|
9
|
+
import { loadCodeFallback } from "../pipeline/loadCodeVariant/loadCodeFallback.js";
|
|
10
10
|
import { CodeHighlighterClient } from "./CodeHighlighterClient.js";
|
|
11
|
-
import {
|
|
12
|
-
import { hasAllVariants } from "
|
|
11
|
+
import { maybeCodeInitialData } from "../pipeline/loadCodeVariant/maybeCodeInitialData.js";
|
|
12
|
+
import { hasAllVariants } from "../pipeline/loadCodeVariant/hasAllCodeVariants.js";
|
|
13
13
|
import { getFileNameFromUrl } from "../pipeline/loaderUtils/getFileNameFromUrl.js";
|
|
14
14
|
import { codeToFallbackProps } from "./codeToFallbackProps.js";
|
|
15
15
|
import * as Errors from "./errors.js";
|
|
@@ -176,7 +176,7 @@ function _CodeSourceLoader() {
|
|
|
176
176
|
} else if (props.deferParsing === 'none') {
|
|
177
177
|
output = 'hast';
|
|
178
178
|
}
|
|
179
|
-
return
|
|
179
|
+
return loadCodeVariant(variantUrl, variantName, variantCode, {
|
|
180
180
|
sourceParser: props.sourceParser,
|
|
181
181
|
loadSource: props.loadSource,
|
|
182
182
|
loadVariantMeta: props.loadVariantMeta,
|
|
@@ -313,7 +313,7 @@ function CodeInitialSourceLoader(_x3) {
|
|
|
313
313
|
}
|
|
314
314
|
function _CodeInitialSourceLoader() {
|
|
315
315
|
_CodeInitialSourceLoader = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(props) {
|
|
316
|
-
var url, initialVariant, highlightAfter, fallbackUsesExtraFiles, fallbackUsesAllVariants, sourceParser, loadSource, loadVariantMeta, loadCodeMeta, fileName, variants, globalsCode, ContentLoading, output, _yield$
|
|
316
|
+
var url, initialVariant, highlightAfter, fallbackUsesExtraFiles, fallbackUsesAllVariants, sourceParser, loadSource, loadVariantMeta, loadCodeMeta, fileName, variants, globalsCode, ContentLoading, output, _yield$loadCodeFallba, code, initialFilename, initialSource, initialExtraFiles, processedGlobalsCode;
|
|
317
317
|
return _regenerator().w(function (_context4) {
|
|
318
318
|
while (1) switch (_context4.n) {
|
|
319
319
|
case 0:
|
|
@@ -331,7 +331,7 @@ function _CodeInitialSourceLoader() {
|
|
|
331
331
|
output = 'hast';
|
|
332
332
|
}
|
|
333
333
|
_context4.n = 2;
|
|
334
|
-
return
|
|
334
|
+
return loadCodeFallback(url, initialVariant, props.code, {
|
|
335
335
|
shouldHighlight: highlightAfter === 'init',
|
|
336
336
|
fallbackUsesExtraFiles: fallbackUsesExtraFiles,
|
|
337
337
|
fallbackUsesAllVariants: fallbackUsesAllVariants,
|
|
@@ -345,12 +345,12 @@ function _CodeInitialSourceLoader() {
|
|
|
345
345
|
output: output
|
|
346
346
|
});
|
|
347
347
|
case 2:
|
|
348
|
-
_yield$
|
|
349
|
-
code = _yield$
|
|
350
|
-
initialFilename = _yield$
|
|
351
|
-
initialSource = _yield$
|
|
352
|
-
initialExtraFiles = _yield$
|
|
353
|
-
processedGlobalsCode = _yield$
|
|
348
|
+
_yield$loadCodeFallba = _context4.v;
|
|
349
|
+
code = _yield$loadCodeFallba.code;
|
|
350
|
+
initialFilename = _yield$loadCodeFallba.initialFilename;
|
|
351
|
+
initialSource = _yield$loadCodeFallba.initialSource;
|
|
352
|
+
initialExtraFiles = _yield$loadCodeFallba.initialExtraFiles;
|
|
353
|
+
processedGlobalsCode = _yield$loadCodeFallba.processedGlobalsCode;
|
|
354
354
|
return _context4.a(2, renderWithInitialSource(_extends(_extends({}, props), {}, {
|
|
355
355
|
ContentLoading: ContentLoading,
|
|
356
356
|
code: code,
|
|
@@ -417,11 +417,11 @@ export function CodeHighlighter(props) {
|
|
|
417
417
|
|
|
418
418
|
// TODO: use initial.filesOrder to determing which source to use
|
|
419
419
|
|
|
420
|
-
var
|
|
420
|
+
var _maybeCodeInitialData = maybeCodeInitialData(variants, initialKey, code || props.precompute, undefined,
|
|
421
421
|
// TODO: use initial.filesOrder if provided?
|
|
422
422
|
props.highlightAfter === 'init', props.fallbackUsesExtraFiles, props.fallbackUsesAllVariants),
|
|
423
|
-
initialData =
|
|
424
|
-
reason =
|
|
423
|
+
initialData = _maybeCodeInitialData.initialData,
|
|
424
|
+
reason = _maybeCodeInitialData.reason;
|
|
425
425
|
if (!initialData) {
|
|
426
426
|
if (DEBUG) {
|
|
427
427
|
// eslint-disable-next-line no-console
|
|
@@ -9,12 +9,12 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import { useCodeContext } from "../CodeProvider/CodeContext.js";
|
|
11
11
|
import { CodeHighlighterContext } from "./CodeHighlighterContext.js";
|
|
12
|
-
import {
|
|
13
|
-
import { hasAllVariants } from "
|
|
12
|
+
import { maybeCodeInitialData } from "../pipeline/loadCodeVariant/maybeCodeInitialData.js";
|
|
13
|
+
import { hasAllVariants } from "../pipeline/loadCodeVariant/hasAllCodeVariants.js";
|
|
14
14
|
import { CodeHighlighterFallbackContext } from "./CodeHighlighterFallbackContext.js";
|
|
15
15
|
import { useControlledCode } from "../CodeControllerContext/index.js";
|
|
16
16
|
import { codeToFallbackProps } from "./codeToFallbackProps.js";
|
|
17
|
-
import {
|
|
17
|
+
import { mergeCodeMetadata } from "../pipeline/loadCodeVariant/mergeCodeMetadata.js";
|
|
18
18
|
import * as Errors from "./errors.js";
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
var DEBUG = false; // Set to true for debugging purposes
|
|
@@ -37,9 +37,9 @@ function useInitialData(_ref) {
|
|
|
37
37
|
loadCodeMeta = _useCodeContext.loadCodeMeta,
|
|
38
38
|
loadVariantMeta = _useCodeContext.loadVariantMeta,
|
|
39
39
|
loadSource = _useCodeContext.loadSource,
|
|
40
|
-
|
|
40
|
+
loadCodeFallback = _useCodeContext.loadCodeFallback;
|
|
41
41
|
var _React$useMemo = React.useMemo(function () {
|
|
42
|
-
return
|
|
42
|
+
return maybeCodeInitialData(variants, variantName, code, fileName, highlightAfter === 'init', fallbackUsesExtraFiles, fallbackUsesAllVariants);
|
|
43
43
|
}, [variants, variantName, code, fileName, highlightAfter, fallbackUsesExtraFiles, fallbackUsesAllVariants]),
|
|
44
44
|
initialData = _React$useMemo.initialData,
|
|
45
45
|
reason = _React$useMemo.reason;
|
|
@@ -49,7 +49,7 @@ function useInitialData(_ref) {
|
|
|
49
49
|
// URL is required for loading fallback data
|
|
50
50
|
throw new Errors.ErrorCodeHighlighterClientMissingUrlForFallback();
|
|
51
51
|
}
|
|
52
|
-
if (!
|
|
52
|
+
if (!loadCodeFallback) {
|
|
53
53
|
throw new Errors.ErrorCodeHighlighterClientMissingLoadFallbackCode(url);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -57,7 +57,7 @@ function useInitialData(_ref) {
|
|
|
57
57
|
// TODO: fallbackInitialRenderOnly option? this would mean we can't fetch fallback data on the client side
|
|
58
58
|
// Load initial data if not provided
|
|
59
59
|
React.useEffect(function () {
|
|
60
|
-
if (!needsFallback || !url || !
|
|
60
|
+
if (!needsFallback || !url || !loadCodeFallback) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -73,7 +73,7 @@ function useInitialData(_ref) {
|
|
|
73
73
|
console.log('Loading initial data for CodeHighlighterClient: ', reason);
|
|
74
74
|
}
|
|
75
75
|
_context.n = 1;
|
|
76
|
-
return
|
|
76
|
+
return loadCodeFallback(url, variantName, code, {
|
|
77
77
|
shouldHighlight: highlightAfter === 'init',
|
|
78
78
|
fallbackUsesExtraFiles: fallbackUsesExtraFiles,
|
|
79
79
|
fallbackUsesAllVariants: fallbackUsesAllVariants,
|
|
@@ -83,7 +83,7 @@ function useInitialData(_ref) {
|
|
|
83
83
|
loadCodeMeta: loadCodeMeta,
|
|
84
84
|
initialFilename: fileName,
|
|
85
85
|
variants: variants,
|
|
86
|
-
globalsCode: globalsCode // Let
|
|
86
|
+
globalsCode: globalsCode // Let loadCodeFallback handle processing
|
|
87
87
|
})["catch"](function (error) {
|
|
88
88
|
return {
|
|
89
89
|
error: error
|
|
@@ -95,7 +95,7 @@ function useInitialData(_ref) {
|
|
|
95
95
|
console.error(new Errors.ErrorCodeHighlighterClientLoadFallbackFailure(loaded.error));
|
|
96
96
|
} else {
|
|
97
97
|
setCode(loaded.code);
|
|
98
|
-
// Store processed globalsCode from
|
|
98
|
+
// Store processed globalsCode from loadCodeFallback result
|
|
99
99
|
if (loaded.processedGlobalsCode) {
|
|
100
100
|
setProcessedGlobalsCode(loaded.processedGlobalsCode);
|
|
101
101
|
}
|
|
@@ -105,7 +105,7 @@ function useInitialData(_ref) {
|
|
|
105
105
|
}
|
|
106
106
|
}, _callee);
|
|
107
107
|
}))();
|
|
108
|
-
}, [initialData, reason, needsFallback, variantName, code, setCode, highlightAfter, url, sourceParser, loadSource, loadVariantMeta, loadCodeMeta, fallbackUsesExtraFiles, fallbackUsesAllVariants, fileName, variants, globalsCode, setProcessedGlobalsCode,
|
|
108
|
+
}, [initialData, reason, needsFallback, variantName, code, setCode, highlightAfter, url, sourceParser, loadSource, loadVariantMeta, loadCodeMeta, fallbackUsesExtraFiles, fallbackUsesAllVariants, fileName, variants, globalsCode, setProcessedGlobalsCode, loadCodeFallback]);
|
|
109
109
|
}
|
|
110
110
|
function useAllVariants(_ref3) {
|
|
111
111
|
var readyForContent = _ref3.readyForContent,
|
|
@@ -121,7 +121,7 @@ function useAllVariants(_ref3) {
|
|
|
121
121
|
loadCodeMeta = _useCodeContext2.loadCodeMeta,
|
|
122
122
|
loadVariantMeta = _useCodeContext2.loadVariantMeta,
|
|
123
123
|
loadSource = _useCodeContext2.loadSource,
|
|
124
|
-
|
|
124
|
+
loadCodeVariant = _useCodeContext2.loadCodeVariant;
|
|
125
125
|
var needsData = !readyForContent && !isControlled;
|
|
126
126
|
|
|
127
127
|
// validation
|
|
@@ -130,7 +130,7 @@ function useAllVariants(_ref3) {
|
|
|
130
130
|
if (!url) {
|
|
131
131
|
throw new Errors.ErrorCodeHighlighterClientMissingUrlForVariants();
|
|
132
132
|
}
|
|
133
|
-
if (!
|
|
133
|
+
if (!loadCodeVariant) {
|
|
134
134
|
throw new Errors.ErrorCodeHighlighterClientMissingLoadVariant(url);
|
|
135
135
|
}
|
|
136
136
|
if (!code && !loadCodeMeta) {
|
|
@@ -160,9 +160,9 @@ function useAllVariants(_ref3) {
|
|
|
160
160
|
throw new Errors.ErrorCodeHighlighterClientMissingLoadSourceForUnloadedUrls();
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
}, [code, globalsCode, loadCodeMeta,
|
|
163
|
+
}, [code, globalsCode, loadCodeMeta, loadCodeVariant, loadSource, needsData, url]);
|
|
164
164
|
React.useEffect(function () {
|
|
165
|
-
if (!needsData || !url || !
|
|
165
|
+
if (!needsData || !url || !loadCodeVariant) {
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -245,7 +245,7 @@ function useAllVariants(_ref3) {
|
|
|
245
245
|
}).filter(function (item) {
|
|
246
246
|
return Boolean(item);
|
|
247
247
|
});
|
|
248
|
-
return
|
|
248
|
+
return loadCodeVariant(url, name, loadedCode[name], {
|
|
249
249
|
disableParsing: true,
|
|
250
250
|
disableTransforms: true,
|
|
251
251
|
loadSource: loadSource,
|
|
@@ -297,7 +297,7 @@ function useAllVariants(_ref3) {
|
|
|
297
297
|
}
|
|
298
298
|
}, _callee3, null, [[0, 8]]);
|
|
299
299
|
}))();
|
|
300
|
-
}, [needsData, variants, url, code, setCode, loadSource, loadVariantMeta, loadCodeMeta, processedGlobalsCode, globalsCode, setProcessedGlobalsCode,
|
|
300
|
+
}, [needsData, variants, url, code, setCode, loadSource, loadVariantMeta, loadCodeMeta, processedGlobalsCode, globalsCode, setProcessedGlobalsCode, loadCodeVariant]);
|
|
301
301
|
return {
|
|
302
302
|
readyForContent: readyForContent
|
|
303
303
|
};
|
|
@@ -396,7 +396,7 @@ function useCodeTransforms(_ref7) {
|
|
|
396
396
|
var _useCodeContext4 = useCodeContext(),
|
|
397
397
|
sourceParser = _useCodeContext4.sourceParser,
|
|
398
398
|
getAvailableTransforms = _useCodeContext4.getAvailableTransforms,
|
|
399
|
-
|
|
399
|
+
computeHastDeltas = _useCodeContext4.computeHastDeltas;
|
|
400
400
|
var _React$useState3 = React.useState(undefined),
|
|
401
401
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
402
402
|
transformedCode = _React$useState4[0],
|
|
@@ -412,7 +412,7 @@ function useCodeTransforms(_ref7) {
|
|
|
412
412
|
|
|
413
413
|
// Effect to compute transformations for all variants
|
|
414
414
|
React.useEffect(function () {
|
|
415
|
-
if (!parsedCode || !sourceParser || !
|
|
415
|
+
if (!parsedCode || !sourceParser || !computeHastDeltas) {
|
|
416
416
|
setTransformedCode(parsedCode);
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
@@ -429,7 +429,7 @@ function useCodeTransforms(_ref7) {
|
|
|
429
429
|
case 1:
|
|
430
430
|
parseSource = _context4.v;
|
|
431
431
|
_context4.n = 2;
|
|
432
|
-
return
|
|
432
|
+
return computeHastDeltas(parsedCode, parseSource);
|
|
433
433
|
case 2:
|
|
434
434
|
enhanced = _context4.v;
|
|
435
435
|
setTransformedCode(enhanced);
|
|
@@ -445,7 +445,7 @@ function useCodeTransforms(_ref7) {
|
|
|
445
445
|
}
|
|
446
446
|
}, _callee4, null, [[0, 3]]);
|
|
447
447
|
}))();
|
|
448
|
-
}, [parsedCode, sourceParser,
|
|
448
|
+
}, [parsedCode, sourceParser, computeHastDeltas]);
|
|
449
449
|
return {
|
|
450
450
|
transformedCode: transformedCode,
|
|
451
451
|
availableTransforms: availableTransforms
|
|
@@ -500,7 +500,7 @@ function useGlobalsCodeMerging(_ref0) {
|
|
|
500
500
|
loadCodeMeta = _useCodeContext6.loadCodeMeta,
|
|
501
501
|
loadSource = _useCodeContext6.loadSource,
|
|
502
502
|
loadVariantMeta = _useCodeContext6.loadVariantMeta,
|
|
503
|
-
|
|
503
|
+
loadCodeVariant = _useCodeContext6.loadCodeVariant;
|
|
504
504
|
|
|
505
505
|
// Set processedGlobalsCode if we have ready Code objects but haven't stored them yet
|
|
506
506
|
React.useEffect(function () {
|
|
@@ -523,7 +523,7 @@ function useGlobalsCodeMerging(_ref0) {
|
|
|
523
523
|
}
|
|
524
524
|
// If not all ready, fall through to loading logic below
|
|
525
525
|
}
|
|
526
|
-
if (!
|
|
526
|
+
if (!loadCodeVariant) {
|
|
527
527
|
console.error(new Errors.ErrorCodeHighlighterClientMissingLoadVariantForGlobals());
|
|
528
528
|
return;
|
|
529
529
|
}
|
|
@@ -606,7 +606,7 @@ function useGlobalsCodeMerging(_ref0) {
|
|
|
606
606
|
case 1:
|
|
607
607
|
_context6.p = 1;
|
|
608
608
|
_context6.n = 2;
|
|
609
|
-
return
|
|
609
|
+
return loadCodeVariant(originalUrl || '',
|
|
610
610
|
// Use the original URL if available
|
|
611
611
|
variantName, codeObj[variantName],
|
|
612
612
|
// May be undefined or string
|
|
@@ -658,7 +658,7 @@ function useGlobalsCodeMerging(_ref0) {
|
|
|
658
658
|
}
|
|
659
659
|
}, _callee8, null, [[0, 3]]);
|
|
660
660
|
}))();
|
|
661
|
-
}, [url, globalsCode, processedGlobalsCode, setProcessedGlobalsCode, loadCodeMeta, loadSource, loadVariantMeta, variants,
|
|
661
|
+
}, [url, globalsCode, processedGlobalsCode, setProcessedGlobalsCode, loadCodeMeta, loadSource, loadVariantMeta, variants, loadCodeVariant]);
|
|
662
662
|
|
|
663
663
|
// Determine globalsCodeObjects to use (prefer processed, fallback to direct if ready)
|
|
664
664
|
var globalsCodeObjects = React.useMemo(function () {
|
|
@@ -707,11 +707,11 @@ function useGlobalsCodeMerging(_ref0) {
|
|
|
707
707
|
return Boolean(item) && _typeof(item) === 'object';
|
|
708
708
|
});
|
|
709
709
|
if (globalsForVariant.length > 0) {
|
|
710
|
-
// Use
|
|
710
|
+
// Use mergeCodeMetadata for sophisticated globals merging with proper positioning
|
|
711
711
|
var currentVariant = variantData;
|
|
712
712
|
globalsForVariant.forEach(function (globalVariant) {
|
|
713
713
|
if (globalVariant.extraFiles) {
|
|
714
|
-
// Convert globals extraFiles to metadata format for
|
|
714
|
+
// Convert globals extraFiles to metadata format for mergeCodeMetadata
|
|
715
715
|
var globalsMetadata = {};
|
|
716
716
|
for (var _i = 0, _Object$entries = Object.entries(globalVariant.extraFiles); _i < _Object$entries.length; _i++) {
|
|
717
717
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
@@ -726,8 +726,8 @@ function useGlobalsCodeMerging(_ref0) {
|
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
-
// Use
|
|
730
|
-
currentVariant =
|
|
729
|
+
// Use mergeCodeMetadata to properly position and merge the globals
|
|
730
|
+
currentVariant = mergeCodeMetadata(currentVariant, globalsMetadata);
|
|
731
731
|
}
|
|
732
732
|
});
|
|
733
733
|
|
|
@@ -774,11 +774,11 @@ function usePropsCodeGlobalsMerging(_ref14) {
|
|
|
774
774
|
return Boolean(item) && _typeof(item) === 'object';
|
|
775
775
|
});
|
|
776
776
|
if (globalsForVariant.length > 0) {
|
|
777
|
-
// Use
|
|
777
|
+
// Use mergeCodeMetadata for sophisticated globals merging with proper positioning
|
|
778
778
|
var currentVariant = variantData;
|
|
779
779
|
globalsForVariant.forEach(function (globalVariant) {
|
|
780
780
|
if (globalVariant.extraFiles) {
|
|
781
|
-
// Convert globals extraFiles to metadata format for
|
|
781
|
+
// Convert globals extraFiles to metadata format for mergeCodeMetadata
|
|
782
782
|
var globalsMetadata = {};
|
|
783
783
|
for (var _i2 = 0, _Object$entries2 = Object.entries(globalVariant.extraFiles); _i2 < _Object$entries2.length; _i2++) {
|
|
784
784
|
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
@@ -793,8 +793,8 @@ function usePropsCodeGlobalsMerging(_ref14) {
|
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
795
|
|
|
796
|
-
// Use
|
|
797
|
-
currentVariant =
|
|
796
|
+
// Use mergeCodeMetadata to properly position and merge the globals
|
|
797
|
+
currentVariant = mergeCodeMetadata(currentVariant, globalsMetadata);
|
|
798
798
|
}
|
|
799
799
|
});
|
|
800
800
|
|
|
@@ -230,7 +230,7 @@ export var ErrorCodeHighlighterServerLoadVariantsFailure = /*#__PURE__*/function
|
|
|
230
230
|
export var ErrorCodeHighlighterClientMissingLoadFallbackCode = /*#__PURE__*/function (_ErrorCodeHighlighter21) {
|
|
231
231
|
function ErrorCodeHighlighterClientMissingLoadFallbackCode(url) {
|
|
232
232
|
_classCallCheck(this, ErrorCodeHighlighterClientMissingLoadFallbackCode);
|
|
233
|
-
return _callSuper(this, ErrorCodeHighlighterClientMissingLoadFallbackCode, ["Missing
|
|
233
|
+
return _callSuper(this, ErrorCodeHighlighterClientMissingLoadFallbackCode, ["Missing loadCodeFallback function - loadCodeFallback is required (".concat(url || 'No URL', ") add a <CodeProvider />")]);
|
|
234
234
|
}
|
|
235
235
|
_inherits(ErrorCodeHighlighterClientMissingLoadFallbackCode, _ErrorCodeHighlighter21);
|
|
236
236
|
return _createClass(ErrorCodeHighlighterClientMissingLoadFallbackCode);
|
|
@@ -238,7 +238,7 @@ export var ErrorCodeHighlighterClientMissingLoadFallbackCode = /*#__PURE__*/func
|
|
|
238
238
|
export var ErrorCodeHighlighterClientMissingLoadVariant = /*#__PURE__*/function (_ErrorCodeHighlighter22) {
|
|
239
239
|
function ErrorCodeHighlighterClientMissingLoadVariant(url) {
|
|
240
240
|
_classCallCheck(this, ErrorCodeHighlighterClientMissingLoadVariant);
|
|
241
|
-
return _callSuper(this, ErrorCodeHighlighterClientMissingLoadVariant, ["Missing
|
|
241
|
+
return _callSuper(this, ErrorCodeHighlighterClientMissingLoadVariant, ["Missing loadCodeVariant function - loadCodeVariant function is required when no initial code is provided (".concat(url || 'No URL', ")")]);
|
|
242
242
|
}
|
|
243
243
|
_inherits(ErrorCodeHighlighterClientMissingLoadVariant, _ErrorCodeHighlighter22);
|
|
244
244
|
return _createClass(ErrorCodeHighlighterClientMissingLoadVariant);
|
|
@@ -417,7 +417,7 @@ export var ErrorCodeHighlighterClientTransformProcessingFailure = /*#__PURE__*/f
|
|
|
417
417
|
export var ErrorCodeHighlighterClientMissingLoadVariantForGlobals = /*#__PURE__*/function (_ErrorCodeHighlighter42) {
|
|
418
418
|
function ErrorCodeHighlighterClientMissingLoadVariantForGlobals() {
|
|
419
419
|
_classCallCheck(this, ErrorCodeHighlighterClientMissingLoadVariantForGlobals);
|
|
420
|
-
return _callSuper(this, ErrorCodeHighlighterClientMissingLoadVariantForGlobals, ["
|
|
420
|
+
return _callSuper(this, ErrorCodeHighlighterClientMissingLoadVariantForGlobals, ["loadCodeVariant function is required for loading missing variants in globalsCode"]);
|
|
421
421
|
}
|
|
422
422
|
_inherits(ErrorCodeHighlighterClientMissingLoadVariantForGlobals, _ErrorCodeHighlighter42);
|
|
423
423
|
return _createClass(ErrorCodeHighlighterClientMissingLoadVariantForGlobals);
|
|
@@ -149,7 +149,7 @@ export interface LoadFileOptions {
|
|
|
149
149
|
output?: 'hast' | 'hastJson' | 'hastGzip';
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
* Options for the
|
|
152
|
+
* Options for the loadCodeVariant function, extending LoadFileOptions with required function dependencies
|
|
153
153
|
*/
|
|
154
154
|
export interface LoadVariantOptions extends LoadFileOptions, Pick<CodeFunctionProps, 'sourceParser' | 'loadSource' | 'loadVariantMeta' | 'sourceTransformers'> {}
|
|
155
155
|
/**
|
|
@@ -11,7 +11,7 @@ export type LoadVariantFn = (url: string | undefined, variantName: string, varia
|
|
|
11
11
|
}>;
|
|
12
12
|
export type ParseCodeFn = (code: Code, parseSource: ParseSource) => Code;
|
|
13
13
|
export type ParseControlledCodeFn = (controlledCode: ControlledCode, parseSource: ParseSource) => Code;
|
|
14
|
-
export type
|
|
14
|
+
export type ComputeHastDeltasFn = (parsedCode: Code, parseSource: ParseSource) => Promise<Code>;
|
|
15
15
|
export type GetAvailableTransformsFn = (parsedCode: Code | undefined, variantName: string) => string[];
|
|
16
16
|
export interface CodeContext {
|
|
17
17
|
sourceParser?: Promise<ParseSource>;
|
|
@@ -20,11 +20,11 @@ export interface CodeContext {
|
|
|
20
20
|
loadSource?: LoadSource;
|
|
21
21
|
loadVariantMeta?: LoadVariantMeta;
|
|
22
22
|
loadCodeMeta?: LoadCodeMeta;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
loadCodeFallback?: LoadFallbackCodeFn;
|
|
24
|
+
loadCodeVariant?: LoadVariantFn;
|
|
25
25
|
parseCode?: ParseCodeFn;
|
|
26
26
|
parseControlledCode?: ParseControlledCodeFn;
|
|
27
|
-
|
|
27
|
+
computeHastDeltas?: ComputeHastDeltasFn;
|
|
28
28
|
getAvailableTransforms?: GetAvailableTransformsFn;
|
|
29
29
|
}
|
|
30
30
|
export declare const CodeContext: React.Context<CodeContext>;
|
|
@@ -7,11 +7,11 @@ import { CodeContext } from "./CodeContext.js";
|
|
|
7
7
|
import { extensionMap, grammars } from "../pipeline/parseSource/grammars.js";
|
|
8
8
|
import { starryNightGutter } from "../pipeline/parseSource/addLineGutters.js";
|
|
9
9
|
// Import the heavy functions
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { parseCode } from "../
|
|
10
|
+
import { loadCodeFallback } from "../pipeline/loadCodeVariant/loadCodeFallback.js";
|
|
11
|
+
import { loadCodeVariant } from "../pipeline/loadCodeVariant/loadCodeVariant.js";
|
|
12
|
+
import { parseCode } from "../pipeline/loadCodeVariant/parseCode.js";
|
|
13
13
|
import { parseControlledCode } from "../CodeHighlighter/parseControlledCode.js";
|
|
14
|
-
import {
|
|
14
|
+
import { computeHastDeltas, getAvailableTransforms } from "../pipeline/loadCodeVariant/computeHastDeltas.js";
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
export function CodeProvider(_ref) {
|
|
17
17
|
var children = _ref.children,
|
|
@@ -68,11 +68,11 @@ export function CodeProvider(_ref) {
|
|
|
68
68
|
loadVariantMeta: loadVariantMeta,
|
|
69
69
|
loadCodeMeta: loadCodeMeta,
|
|
70
70
|
// Provide the heavy functions
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
loadCodeFallback: loadCodeFallback,
|
|
72
|
+
loadCodeVariant: loadCodeVariant,
|
|
73
73
|
parseCode: parseCode,
|
|
74
74
|
parseControlledCode: parseControlledCode,
|
|
75
|
-
|
|
75
|
+
computeHastDeltas: computeHastDeltas,
|
|
76
76
|
getAvailableTransforms: getAvailableTransforms
|
|
77
77
|
};
|
|
78
78
|
}, [sourceParser, parseSource, loadSource, loadVariantMeta, loadCodeMeta]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/cli/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import yargs from 'yargs';
|
|
3
|
+
import { hideBin } from 'yargs/helpers';
|
|
4
|
+
import runValidate from "./runValidate.js";
|
|
5
|
+
var pkgJson = createRequire(import.meta.url)('../../package.json');
|
|
6
|
+
yargs().scriptName('docs-infra').usage('$0 <command> [args]').command(runValidate).demandCommand(1, 'You need at least one command before moving on').strict().help().version(pkgJson.version).parse(hideBin(process.argv));
|