@mui/internal-docs-infra 0.12.1-canary.2 → 0.12.1-canary.21
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/ChunkProvider/PreloadProvider.mjs +1 -2
- package/ChunkProvider/usePreload.d.mts +1 -1
- package/ChunkProvider/usePreload.mjs +0 -1
- package/CodeControllerContext/CodeControllerContext.d.mts +45 -10
- package/CodeControllerContext/CodeControllerContext.mjs +15 -1
- package/CodeHighlighter/CodeHighlighterClient.d.mts +3 -2
- package/CodeHighlighter/CodeHighlighterClient.mjs +113 -18
- package/CodeHighlighter/CodeHighlighterContext.d.mts +9 -3
- package/CodeHighlighter/buildStringFallback.d.mts +1 -1
- package/CodeHighlighter/codeToFallbackProps.d.mts +1 -1
- package/CodeHighlighter/createClientProps.mjs +3 -0
- package/CodeHighlighter/fallbackCompression.d.mts +1 -1
- package/CodeHighlighter/parseControlledCode.d.mts +13 -4
- package/CodeHighlighter/parseControlledCode.mjs +41 -49
- package/CodeHighlighter/types.d.mts +21 -0
- package/CodeHighlighter/useGrammarsReady.mjs +44 -9
- package/CodeProvider/CodeProvider.d.mts +1 -1
- package/CodeProvider/CodeProviderLazy.d.mts +1 -1
- package/CodeProvider/createParseSourceWorkerClient.d.mts +6 -0
- package/CodeProvider/createParseSourceWorkerClient.mjs +83 -15
- package/CodeProvider/useCodeProviderValue.mjs +50 -4
- package/abstractCreateDemo/abstractCreateDemo.d.mts +15 -1
- package/abstractCreateDemo/abstractCreateDemo.mjs +8 -0
- package/abstractCreateDemoClient/abstractCreateDemoClient.mjs +4 -0
- package/abstractCreateTypes/abstractCreateTypes.d.mts +12 -1
- package/abstractCreateTypes/abstractCreateTypes.mjs +4 -0
- package/abstractCreateTypes/typesToJsx.d.mts +8 -0
- package/abstractCreateTypes/typesToJsx.mjs +2 -1
- package/cli/loadNextConfig.d.mts +9 -0
- package/cli/loadNextConfig.mjs +11 -2
- package/cli/runValidate.mjs +15 -7
- package/cli/validateWorker.d.mts +1 -0
- package/cli/validateWorker.mjs +2 -1
- package/createDemoData/createDemoData.d.mts +1 -1
- package/package.json +34 -5
- package/pipeline/cacheUtils/constants.d.mts +5 -0
- package/pipeline/cacheUtils/constants.mjs +5 -0
- package/pipeline/cacheUtils/hashCacheContent.d.mts +5 -0
- package/pipeline/cacheUtils/hashCacheContent.mjs +9 -0
- package/pipeline/cacheUtils/index.d.mts +9 -0
- package/pipeline/cacheUtils/index.mjs +7 -0
- package/pipeline/cacheUtils/loadFileCache.d.mts +13 -0
- package/pipeline/cacheUtils/loadFileCache.mjs +20 -0
- package/pipeline/cacheUtils/loadFileCacheEntry.d.mts +13 -0
- package/pipeline/cacheUtils/loadFileCacheEntry.mjs +47 -0
- package/pipeline/cacheUtils/resolveCachePath.d.mts +16 -0
- package/pipeline/cacheUtils/resolveCachePath.mjs +24 -0
- package/pipeline/cacheUtils/saveFileCache.d.mts +17 -0
- package/pipeline/cacheUtils/saveFileCache.mjs +54 -0
- package/pipeline/cacheUtils/types.d.mts +23 -0
- package/pipeline/cacheUtils/types.mjs +1 -0
- package/pipeline/cacheUtils/withFileCache.d.mts +40 -0
- package/pipeline/cacheUtils/withFileCache.mjs +81 -0
- package/pipeline/hastUtils/hastUtils.d.mts +1 -1
- package/pipeline/hastUtils/hastUtils.mjs +0 -1
- package/pipeline/loadIsomorphicCodeSource/loadIsomorphicCodeSource.d.mts +1 -1
- package/pipeline/loadIsomorphicCodeSource/loadIsomorphicCodeSource.mjs +1 -1
- package/pipeline/loadIsomorphicCodeVariant/applyCodeTransform.mjs +0 -1
- package/pipeline/loadIsomorphicCodeVariant/diffHast.d.mts +1 -1
- package/pipeline/loadIsomorphicCodeVariant/hasAllCodeVariants.d.mts +1 -1
- package/pipeline/loadIsomorphicCodeVariant/maybeCodeInitialData.d.mts +1 -1
- package/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.d.mts +6 -0
- package/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.mjs +2 -1
- package/pipeline/loadPrecomputedTypes/loadPrecomputedTypes.d.mts +6 -0
- package/pipeline/loadPrecomputedTypes/loadPrecomputedTypes.mjs +5 -1
- package/pipeline/loadServerCodeMeta/resolveModulePathWithFs.d.mts +1 -1
- package/pipeline/loadServerCodeMeta/resolveModulePathWithFs.mjs +0 -1
- package/pipeline/loadServerPageIndex/enrichPageIndex.d.mts +15 -0
- package/pipeline/loadServerPageIndex/enrichPageIndex.mjs +50 -0
- package/pipeline/loadServerPageIndex/extractPrefixAndTitle.d.mts +19 -0
- package/pipeline/loadServerPageIndex/extractPrefixAndTitle.mjs +80 -0
- package/pipeline/loadServerPageIndex/index.d.mts +5 -2
- package/pipeline/loadServerPageIndex/index.mjs +4 -1
- package/pipeline/loadServerPageIndex/loadServerPageIndex.d.mts +13 -22
- package/pipeline/loadServerPageIndex/loadServerPageIndex.mjs +32 -124
- package/pipeline/loadServerPageIndex/resolvePageIndexCacheKey.d.mts +13 -0
- package/pipeline/loadServerPageIndex/resolvePageIndexCacheKey.mjs +23 -0
- package/pipeline/loadServerTypes/highlightTypes.d.mts +3 -3
- package/pipeline/loadServerTypes/highlightTypesMeta.d.mts +4 -4
- package/pipeline/loadServerTypes/loadServerTypes.d.mts +2 -2
- package/pipeline/loadServerTypes/loadServerTypes.mjs +67 -7
- package/pipeline/loadServerTypesMeta/createOptimizedProgram.d.mts +2 -1
- package/pipeline/loadServerTypesMeta/formatClass.d.mts +2 -2
- package/pipeline/loadServerTypesMeta/formatComponent.d.mts +2 -2
- package/pipeline/loadServerTypesMeta/formatFunction.d.mts +2 -2
- package/pipeline/loadServerTypesMeta/formatHook.d.mts +2 -2
- package/pipeline/loadServerTypesMeta/formatRaw.d.mts +2 -2
- package/pipeline/loadServerTypesMeta/formatType.d.mts +1 -1
- package/pipeline/loadServerTypesMeta/loadServerTypesMeta.d.mts +7 -7
- package/pipeline/loadServerTypesMeta/loadServerTypesMeta.mjs +1 -1
- package/pipeline/loadServerTypesMeta/processTypes.d.mts +2 -2
- package/pipeline/loadServerTypesMeta/worker.d.mts +1 -1
- package/pipeline/loadServerTypesText/loadServerTypesText.d.mts +16 -2
- package/pipeline/loadServerTypesText/loadServerTypesText.mjs +30 -8
- package/pipeline/loadServerTypesText/normalizeTypesSourceDataForCache.d.mts +2 -0
- package/pipeline/loadServerTypesText/normalizeTypesSourceDataForCache.mjs +144 -0
- package/pipeline/loadServerTypesText/resolveTypesCacheKey.d.mts +19 -0
- package/pipeline/loadServerTypesText/resolveTypesCacheKey.mjs +29 -0
- package/pipeline/loaderUtils/parseImportsAndComments.d.mts +5 -3
- package/pipeline/loaderUtils/parseImportsAndComments.mjs +284 -40
- package/pipeline/parseCreateFactoryCall/parseCreateFactoryCall.d.mts +2 -2
- package/pipeline/parseCreateFactoryCall/parseCreateFactoryCall.mjs +2 -3
- package/pipeline/parseSource/detectFileTypes.d.mts +16 -0
- package/pipeline/parseSource/detectFileTypes.mjs +44 -0
- package/pipeline/syncPageIndex/mergeMetadataMarkdown.d.mts +25 -1
- package/pipeline/syncPageIndex/mergeMetadataMarkdown.mjs +79 -49
- package/pipeline/syncPageIndex/metadataToMarkdown.d.mts +15 -1
- package/pipeline/syncPageIndex/metadataToMarkdown.mjs +32 -10
- package/pipeline/syncPageIndex/syncPageIndex.d.mts +12 -0
- package/pipeline/syncPageIndex/syncPageIndex.mjs +154 -40
- package/pipeline/syncTypes/generateTypesMarkdown.d.mts +2 -2
- package/pipeline/syncTypes/syncTypes.d.mts +7 -0
- package/pipeline/syncTypes/syncTypes.mjs +31 -1
- package/pipeline/transformHtmlCodeBlock/transformHtmlCodeBlock.mjs +1 -1
- package/pipeline/transformMarkdownCode/transformMarkdownCode.mjs +25 -15
- package/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.mjs +3 -0
- package/pipeline/transformMarkdownMetadata/types.d.mts +8 -1
- package/useCode/EditableEngine.d.mts +1 -1
- package/useCode/Pre.d.mts +9 -2
- package/useCode/Pre.mjs +4 -3
- package/useCode/TransformEngine.d.mts +1 -1
- package/useCode/useCode.d.mts +17 -1
- package/useCode/useCode.mjs +22 -1
- package/useCode/useCopyFunctionality.d.mts +2 -2
- package/useCode/useEditable.browser.mjs +0 -1
- package/useCode/useFileNavigation.d.mts +3 -0
- package/useCode/useFileNavigation.mjs +3 -1
- package/useCode/useSourceEditing.mjs +45 -10
- package/useCode/useSourceEnhancing.mjs +41 -9
- package/useCode/useTransformManagement.d.mts +2 -2
- package/useCode/useTransformManagement.mjs +19 -3
- package/useCode/useUIState.d.mts +4 -0
- package/useCode/useUIState.mjs +8 -1
- package/useCode/useVariantSelection.d.mts +1 -1
- package/useCoordinated/useCoordinated.d.mts +1 -1
- package/useCoordinated/useCoordinatedLocalStorage.d.mts +1 -1
- package/useCoordinated/useCoordinatedLocalStorage.mjs +0 -1
- package/useCoordinated/useCoordinatedPreference.d.mts +1 -1
- package/useCoordinated/useCoordinatedPreference.mjs +0 -1
- package/useCrossTabState/index.d.mts +2 -0
- package/useCrossTabState/index.mjs +2 -0
- package/useCrossTabState/useCrossTabMirror.d.mts +26 -0
- package/useCrossTabState/useCrossTabMirror.mjs +108 -0
- package/useCrossTabState/useCrossTabState.d.mts +21 -0
- package/useCrossTabState/useCrossTabState.mjs +31 -0
- package/useDemo/exportVariant.mjs +2 -4
- package/useDemo/exportVariantAsCra.d.mts +1 -1
- package/useDemo/exportVariantAsCra.mjs +0 -1
- package/useDemo/useDemo.d.mts +4 -1
- package/useDemo/useDemo.mjs +5 -0
- package/useDemoController/BuildEngine.d.mts +2 -0
- package/useDemoController/BuildEngine.mjs +10 -0
- package/useDemoController/DemoRunner.d.mts +34 -0
- package/useDemoController/DemoRunner.mjs +83 -0
- package/useDemoController/ErrorBoundary.d.mts +34 -0
- package/useDemoController/ErrorBoundary.mjs +49 -0
- package/useDemoController/Runner.d.mts +44 -0
- package/useDemoController/Runner.mjs +71 -0
- package/useDemoController/absolutizeImports.d.mts +13 -0
- package/useDemoController/absolutizeImports.mjs +73 -0
- package/useDemoController/buildScope.d.mts +48 -0
- package/useDemoController/buildScope.mjs +270 -0
- package/useDemoController/collectSources.d.mts +67 -0
- package/useDemoController/collectSources.mjs +92 -0
- package/useDemoController/compileCssModule.d.mts +64 -0
- package/useDemoController/compileCssModule.mjs +40 -0
- package/useDemoController/compileCssWithPostcss.d.mts +17 -0
- package/useDemoController/compileCssWithPostcss.mjs +89 -0
- package/useDemoController/compileModule.d.mts +14 -0
- package/useDemoController/compileModule.mjs +17 -0
- package/useDemoController/constants.d.mts +13 -0
- package/useDemoController/constants.mjs +13 -0
- package/useDemoController/createRequire.d.mts +10 -0
- package/useDemoController/createRequire.mjs +17 -0
- package/useDemoController/createTranspileWorkerClient.d.mts +27 -0
- package/useDemoController/createTranspileWorkerClient.mjs +139 -0
- package/useDemoController/cssModules.d.mts +47 -0
- package/useDemoController/currentBrowserTarget.d.mts +16 -0
- package/useDemoController/currentBrowserTarget.mjs +36 -0
- package/useDemoController/evalCode.d.mts +12 -0
- package/useDemoController/evalCode.mjs +35 -0
- package/useDemoController/generateCssModuleSource.d.mts +11 -0
- package/useDemoController/generateCssModuleSource.mjs +55 -0
- package/useDemoController/generateElement.d.mts +21 -0
- package/useDemoController/generateElement.mjs +26 -0
- package/useDemoController/hashString.d.mts +11 -0
- package/useDemoController/hashString.mjs +20 -0
- package/useDemoController/importCode.d.mts +11 -0
- package/useDemoController/importCode.mjs +15 -0
- package/useDemoController/index.d.mts +1 -0
- package/useDemoController/index.mjs +1 -0
- package/useDemoController/instantiateElement.d.mts +24 -0
- package/useDemoController/instantiateElement.mjs +57 -0
- package/useDemoController/instantiateModule.d.mts +17 -0
- package/useDemoController/instantiateModule.mjs +24 -0
- package/useDemoController/resolveCssImports.d.mts +27 -0
- package/useDemoController/resolveCssImports.mjs +79 -0
- package/useDemoController/transformCode.d.mts +14 -0
- package/useDemoController/transformCode.mjs +42 -0
- package/useDemoController/transpileClientSingleton.d.mts +10 -0
- package/useDemoController/transpileClientSingleton.mjs +83 -0
- package/useDemoController/transpileSource.d.mts +29 -0
- package/useDemoController/transpileSource.mjs +36 -0
- package/useDemoController/transpileWorker.d.mts +14 -0
- package/useDemoController/transpileWorker.mjs +41 -0
- package/useDemoController/types.d.mts +30 -0
- package/useDemoController/types.mjs +1 -0
- package/useDemoController/useDemoController.d.mts +54 -0
- package/useDemoController/useDemoController.mjs +186 -0
- package/useDemoController/useRunner.d.mts +53 -0
- package/useDemoController/useRunner.mjs +118 -0
- package/useDemoController/useVariantBuilds.d.mts +31 -0
- package/useDemoController/useVariantBuilds.mjs +188 -0
- package/useSearch/types.d.mts +1 -1
- package/useType/TypesDataProvider.d.mts +1 -1
- package/useType/TypesDataProvider.mjs +1 -2
- package/useType/useType.d.mts +1 -1
- package/useType/useTypeProp.d.mts +1 -1
- package/withDocsInfra/withDeploymentConfig.mjs +57 -0
- package/withDocsInfra/withDocsInfra.d.mts +14 -0
- package/withDocsInfra/withDocsInfra.mjs +25 -11
|
@@ -6,7 +6,12 @@ import { highlightTypes } from "./highlightTypes.mjs";
|
|
|
6
6
|
import { highlightTypesMeta } from "./highlightTypesMeta.mjs";
|
|
7
7
|
import { syncTypes } from "../syncTypes/index.mjs";
|
|
8
8
|
import { loadServerTypesText } from "../loadServerTypesText/index.mjs";
|
|
9
|
+
import { resolveTypesCacheKey } from "../loadServerTypesText/resolveTypesCacheKey.mjs";
|
|
10
|
+
import { withFileCache } from "../cacheUtils/index.mjs";
|
|
9
11
|
const functionName = 'Load Server Types';
|
|
12
|
+
|
|
13
|
+
/** Cache namespace for the enhanced (highlighted) loadServerTypes result. */
|
|
14
|
+
const TYPES_ENHANCED_CACHE_NAMESPACE = 'types-enhanced';
|
|
10
15
|
/**
|
|
11
16
|
* Server-side function for loading and processing TypeScript types.
|
|
12
17
|
*
|
|
@@ -28,21 +33,77 @@ export async function loadServerTypes(options) {
|
|
|
28
33
|
formattingOptions,
|
|
29
34
|
sync = false,
|
|
30
35
|
output = 'hast',
|
|
31
|
-
codeBlockEmphasisOptions
|
|
36
|
+
codeBlockEmphasisOptions,
|
|
37
|
+
cacheDir
|
|
32
38
|
} = options;
|
|
33
39
|
|
|
34
40
|
// Derive relative path for logging
|
|
35
41
|
const relativePath = path.relative(rootContext, typesMarkdownPath);
|
|
36
|
-
|
|
37
|
-
performance.mark(
|
|
42
|
+
const startMark = nameMark(functionName, 'Start Loading', [relativePath]);
|
|
43
|
+
performance.mark(startMark);
|
|
38
44
|
|
|
39
45
|
// Either sync types from source or load from existing markdown
|
|
40
|
-
const syncResult = sync ? await syncTypes(options) : await loadServerTypesText(pathToFileURL(typesMarkdownPath).href, options.ordering
|
|
41
|
-
|
|
46
|
+
const syncResult = sync ? await syncTypes(options) : await loadServerTypesText(pathToFileURL(typesMarkdownPath).href, options.ordering, {
|
|
47
|
+
cacheDir,
|
|
48
|
+
rootContext
|
|
49
|
+
});
|
|
50
|
+
performanceMeasure(startMark, {
|
|
42
51
|
mark: 'types loaded',
|
|
43
52
|
measure: sync ? 'type syncing' : 'types.md loading'
|
|
44
53
|
}, [functionName, relativePath]);
|
|
45
54
|
|
|
55
|
+
// The enhanced (highlighted) result is cached keyed by the loaded types plus the options that
|
|
56
|
+
// affect the output, so a hit skips highlightTypes/highlightTypesMeta. `allDependencies` (the
|
|
57
|
+
// webpack watch list) and the transient `updated` flag are excluded from both the hash and the
|
|
58
|
+
// cached value: allDependencies is re-attached fresh from syncResult below. `syncResult` is hashed
|
|
59
|
+
// before the slug mutation in enhanceTypes (slugs are derived deterministically, part of the cache).
|
|
60
|
+
const cacheRef = cacheDir ? {
|
|
61
|
+
cacheDir,
|
|
62
|
+
namespace: TYPES_ENHANCED_CACHE_NAMESPACE,
|
|
63
|
+
cacheKey: resolveTypesCacheKey(typesMarkdownPath, rootContext)
|
|
64
|
+
} : undefined;
|
|
65
|
+
const enhanced = await withFileCache({
|
|
66
|
+
ref: cacheRef,
|
|
67
|
+
readOrigin: () => syncResult,
|
|
68
|
+
getCacheContent: source => JSON.stringify({
|
|
69
|
+
// Exclude allDependencies (re-attached fresh below) so a dep-list change does not needlessly
|
|
70
|
+
// invalidate the cached highlighting, and the transient `updated` flag for hash stability.
|
|
71
|
+
source: {
|
|
72
|
+
...source,
|
|
73
|
+
allDependencies: undefined,
|
|
74
|
+
updated: undefined
|
|
75
|
+
},
|
|
76
|
+
output,
|
|
77
|
+
formattingOptions: formattingOptions ?? null,
|
|
78
|
+
codeBlockEmphasisOptions: codeBlockEmphasisOptions ?? null
|
|
79
|
+
}),
|
|
80
|
+
processor: source => enhanceTypes(source, {
|
|
81
|
+
output,
|
|
82
|
+
formattingOptions,
|
|
83
|
+
codeBlockEmphasisOptions,
|
|
84
|
+
relativePath
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// allDependencies is the webpack watch list — always take it FRESH from syncResult, never a
|
|
89
|
+
// possibly-stale cached value, so a cache hit can't omit a newly-added source file (missed rebuild).
|
|
90
|
+
return {
|
|
91
|
+
...enhanced,
|
|
92
|
+
allDependencies: syncResult.allDependencies
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Applies syntax highlighting/enhancement to the loaded types and builds the anchor map. Extracted
|
|
98
|
+
* so loadServerTypes can cache it via withFileCache. Returns everything except `allDependencies`
|
|
99
|
+
* (the watch list), which loadServerTypes re-attaches fresh so a cache hit never serves a stale one.
|
|
100
|
+
*/
|
|
101
|
+
async function enhanceTypes(syncResult, {
|
|
102
|
+
output,
|
|
103
|
+
formattingOptions,
|
|
104
|
+
codeBlockEmphasisOptions,
|
|
105
|
+
relativePath
|
|
106
|
+
}) {
|
|
46
107
|
// Compute slugs for all types
|
|
47
108
|
// Determine the common component prefix from the first dotted name (e.g., "Accordion")
|
|
48
109
|
let componentPrefix = '';
|
|
@@ -186,7 +247,7 @@ export async function loadServerTypes(options) {
|
|
|
186
247
|
start: highlightStart,
|
|
187
248
|
end: highlightEnd
|
|
188
249
|
});
|
|
189
|
-
currentMark = nameMark(functionName, 'types highlighted and enhanced', [relativePath]);
|
|
250
|
+
const currentMark = nameMark(functionName, 'types highlighted and enhanced', [relativePath]);
|
|
190
251
|
|
|
191
252
|
// Use variantTypeNames directly from syncResult
|
|
192
253
|
const {
|
|
@@ -265,7 +326,6 @@ export async function loadServerTypes(options) {
|
|
|
265
326
|
additionalTypes,
|
|
266
327
|
variantOnlyAdditionalTypes,
|
|
267
328
|
variantTypeNames,
|
|
268
|
-
allDependencies: syncResult.allDependencies,
|
|
269
329
|
typeNameMap: syncResult.typeNameMap,
|
|
270
330
|
anchorMap: {
|
|
271
331
|
js: anchorMap
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as tae from 'typescript-api-extractor';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { FormattedParameter, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
|
|
3
|
+
import type { TypeRewriteContext } from "./rewriteTypes.mjs";
|
|
4
4
|
import type { ExternalTypesCollector } from "./externalTypes.mjs";
|
|
5
5
|
import type { HastRoot } from "../../CodeHighlighter/types.mjs";
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as tae from 'typescript-api-extractor';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { FormattedProperty, FormattedEnumMember, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
|
|
3
|
+
import type { TypeRewriteContext } from "./rewriteTypes.mjs";
|
|
4
4
|
import type { ExternalTypesCollector } from "./externalTypes.mjs";
|
|
5
5
|
import type { HastRoot } from "../../CodeHighlighter/types.mjs";
|
|
6
6
|
import type { OrderingConfig } from "../loadServerTypesText/order.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as tae from 'typescript-api-extractor';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { FormattedParameter, FormattedProperty, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
|
|
3
|
+
import type { TypeRewriteContext } from "./rewriteTypes.mjs";
|
|
4
4
|
import type { ExternalTypesCollector } from "./externalTypes.mjs";
|
|
5
5
|
import type { HastRoot } from "../../CodeHighlighter/types.mjs";
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as tae from 'typescript-api-extractor';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { FormattedProperty, FormattedParameter, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
|
|
3
|
+
import type { TypeRewriteContext } from "./rewriteTypes.mjs";
|
|
4
4
|
import type { ExternalTypesCollector } from "./externalTypes.mjs";
|
|
5
5
|
import type { HastRoot } from "../../CodeHighlighter/types.mjs";
|
|
6
6
|
export type HookTypeMeta = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as tae from 'typescript-api-extractor';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { FormattedProperty, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
|
|
3
|
+
import type { TypeRewriteContext } from "./rewriteTypes.mjs";
|
|
4
4
|
import type { ExternalTypesCollector } from "./externalTypes.mjs";
|
|
5
5
|
import type { HastRoot } from "../../CodeHighlighter/types.mjs";
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as tae from 'typescript-api-extractor';
|
|
2
|
-
import {
|
|
2
|
+
import type { ExternalTypesCollector } from "./externalTypes.mjs";
|
|
3
3
|
export interface FormatTypeOptions {
|
|
4
4
|
removeUndefined?: boolean;
|
|
5
5
|
jsdocTags?: tae.DocumentationTag[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import type { ClassTypeMeta as ClassType } from "./formatClass.mjs";
|
|
2
|
+
import type { ComponentTypeMeta as ComponentType } from "./formatComponent.mjs";
|
|
3
|
+
import type { HookTypeMeta as HookType } from "./formatHook.mjs";
|
|
4
|
+
import type { FunctionTypeMeta as FunctionType } from "./formatFunction.mjs";
|
|
5
|
+
import type { RawTypeMeta as RawType, ReExportInfo } from "./formatRaw.mjs";
|
|
6
|
+
import type { FormattedProperty, FormattedEnumMember, FormattedParameter, FormatInlineTypeOptions, DescriptionReplacement } from "./format.mjs";
|
|
7
7
|
import type { OrderingConfig } from "../loadServerTypesText/order.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import type { OrganizeTypesResult } from "../loadServerTypesText/organizeTypesByExport.mjs";
|
|
9
9
|
export type ClassTypeMeta = ClassType;
|
|
10
10
|
export type ComponentTypeMeta = ComponentType;
|
|
11
11
|
export type HookTypeMeta = HookType;
|
|
@@ -88,7 +88,7 @@ export async function loadServerTypesMeta(options) {
|
|
|
88
88
|
// Convert file:// URL to filesystem path for Node.js fs APIs
|
|
89
89
|
const fsEntrypoint = fileURLToPath(entrypointUrl);
|
|
90
90
|
const sourceCode = await readFile(fsEntrypoint, 'utf-8');
|
|
91
|
-
const parsed =
|
|
91
|
+
const parsed = parseImportsAndComments(sourceCode, entrypointUrl);
|
|
92
92
|
|
|
93
93
|
// Look for relative exports (e.g., '../menu/', './Button', etc.)
|
|
94
94
|
await Promise.all(Object.keys(parsed.relative || {}).map(async exportPath => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CompilerOptions } from 'typescript';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { ExportNode } from 'typescript-api-extractor';
|
|
3
|
+
import type { PerformanceLog } from "./performanceTracking.mjs";
|
|
4
4
|
export interface VariantResult {
|
|
5
5
|
exports: ExportNode[];
|
|
6
6
|
allTypes: ExportNode[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { WorkerRequest, WorkerResponse, VariantResult } from "./processTypes.mjs";
|
|
2
2
|
export type { WorkerRequest, WorkerResponse, VariantResult };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TypesMeta } from "../loadServerTypesMeta/index.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import type { OrganizeTypesResult } from "./organizeTypesByExport.mjs";
|
|
3
3
|
import type { OrderingConfig } from "./order.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* Common data returned by both syncTypes and loadServerTypesText.
|
|
@@ -18,10 +18,24 @@ export interface TypesSourceData extends OrganizeTypesResult<TypesMeta> {
|
|
|
18
18
|
/** Whether the types.md file was updated (false if loaded from existing file) */
|
|
19
19
|
updated: boolean;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for the types.md parse cache.
|
|
23
|
+
*
|
|
24
|
+
* When both are set, the parse of types.md is cached at `{cacheDir}/types-text/{route}.json`,
|
|
25
|
+
* keyed by the sha256 of the file content (plus ordering), mirroring the page-index cache.
|
|
26
|
+
*/
|
|
27
|
+
export interface LoadServerTypesTextCacheOptions {
|
|
28
|
+
/** Directory for the sha256-validated JSON cache of parsed types.md files. */
|
|
29
|
+
cacheDir?: string;
|
|
30
|
+
/** Root context directory used to derive the cache key/route. */
|
|
31
|
+
rootContext?: string;
|
|
32
|
+
}
|
|
21
33
|
/**
|
|
22
34
|
* Load and parse a types.md file into TypesMeta[].
|
|
23
35
|
*
|
|
24
36
|
* @param fileUrl - file:// URL to the types.md file
|
|
37
|
+
* @param ordering - optional ordering config that affects how types are sorted
|
|
38
|
+
* @param cache - optional parse-cache configuration
|
|
25
39
|
* @returns Parsed types and external types
|
|
26
40
|
*/
|
|
27
|
-
export declare function loadServerTypesText(fileUrl: string, ordering?: OrderingConfig): Promise<TypesSourceData>;
|
|
41
|
+
export declare function loadServerTypesText(fileUrl: string, ordering?: OrderingConfig, cache?: LoadServerTypesTextCacheOptions): Promise<TypesSourceData>;
|
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { withFileCache } from "../cacheUtils/index.mjs";
|
|
3
4
|
import { parseTypesMarkdown } from "./parseTypesMarkdown.mjs";
|
|
5
|
+
import { TYPES_TEXT_CACHE_NAMESPACE, resolveTypesCacheKey, buildTypesTextCacheContent } from "./resolveTypesCacheKey.mjs";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Common data returned by both syncTypes and loadServerTypesText.
|
|
7
9
|
* This is the shared contract consumed by loadServerTypes.
|
|
8
10
|
*/
|
|
9
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Options for the types.md parse cache.
|
|
14
|
+
*
|
|
15
|
+
* When both are set, the parse of types.md is cached at `{cacheDir}/types-text/{route}.json`,
|
|
16
|
+
* keyed by the sha256 of the file content (plus ordering), mirroring the page-index cache.
|
|
17
|
+
*/
|
|
18
|
+
|
|
10
19
|
/**
|
|
11
20
|
* Load and parse a types.md file into TypesMeta[].
|
|
12
21
|
*
|
|
13
22
|
* @param fileUrl - file:// URL to the types.md file
|
|
23
|
+
* @param ordering - optional ordering config that affects how types are sorted
|
|
24
|
+
* @param cache - optional parse-cache configuration
|
|
14
25
|
* @returns Parsed types and external types
|
|
15
26
|
*/
|
|
16
|
-
export
|
|
17
|
-
// Read the file
|
|
27
|
+
export function loadServerTypesText(fileUrl, ordering, cache) {
|
|
18
28
|
const filePath = fileURLToPath(fileUrl);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
const cacheRef = cache?.cacheDir && cache.rootContext ? {
|
|
30
|
+
cacheDir: cache.cacheDir,
|
|
31
|
+
namespace: TYPES_TEXT_CACHE_NAMESPACE,
|
|
32
|
+
cacheKey: resolveTypesCacheKey(filePath, cache.rootContext)
|
|
33
|
+
} : undefined;
|
|
34
|
+
|
|
35
|
+
// The cache stores the parsed TypesSourceData keyed by the markdown + ordering hash, so a hit
|
|
36
|
+
// skips parseTypesMarkdown (the expensive step).
|
|
37
|
+
return withFileCache({
|
|
38
|
+
ref: cacheRef,
|
|
39
|
+
readOrigin: () => readFile(filePath, 'utf-8'),
|
|
40
|
+
getCacheContent: content => buildTypesTextCacheContent(content, ordering),
|
|
41
|
+
processor: async content => ({
|
|
42
|
+
...(await parseTypesMarkdown(content, ordering)),
|
|
43
|
+
allDependencies: [filePath],
|
|
44
|
+
updated: false
|
|
45
|
+
})
|
|
46
|
+
});
|
|
25
47
|
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
function stripPositionFields(value) {
|
|
2
|
+
if (Array.isArray(value)) {
|
|
3
|
+
return value.map(stripPositionFields);
|
|
4
|
+
}
|
|
5
|
+
if (typeof value !== 'object' || value === null) {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const [key, child] of Object.entries(value)) {
|
|
10
|
+
if (key === 'position') {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const normalized = stripPositionFields(child);
|
|
14
|
+
if (normalized !== undefined) {
|
|
15
|
+
result[key] = normalized;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
function normalizeTypeMetaForCache(typeMeta) {
|
|
21
|
+
if (typeMeta.type === 'component') {
|
|
22
|
+
const {
|
|
23
|
+
name,
|
|
24
|
+
props,
|
|
25
|
+
dataAttributes,
|
|
26
|
+
cssVariables,
|
|
27
|
+
descriptionText,
|
|
28
|
+
description,
|
|
29
|
+
...rest
|
|
30
|
+
} = typeMeta.data;
|
|
31
|
+
return {
|
|
32
|
+
...typeMeta,
|
|
33
|
+
data: {
|
|
34
|
+
name,
|
|
35
|
+
props,
|
|
36
|
+
dataAttributes,
|
|
37
|
+
cssVariables,
|
|
38
|
+
...(descriptionText ? {
|
|
39
|
+
descriptionText
|
|
40
|
+
} : {}),
|
|
41
|
+
...(description ? {
|
|
42
|
+
description
|
|
43
|
+
} : {}),
|
|
44
|
+
...rest
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (typeMeta.type === 'hook' || typeMeta.type === 'function') {
|
|
49
|
+
const {
|
|
50
|
+
name,
|
|
51
|
+
parameters,
|
|
52
|
+
expandedProperties,
|
|
53
|
+
returnValue,
|
|
54
|
+
descriptionText,
|
|
55
|
+
description,
|
|
56
|
+
returnValueDescriptionText,
|
|
57
|
+
returnValueDescription,
|
|
58
|
+
...rest
|
|
59
|
+
} = typeMeta.data;
|
|
60
|
+
return {
|
|
61
|
+
...typeMeta,
|
|
62
|
+
data: {
|
|
63
|
+
name,
|
|
64
|
+
...(expandedProperties ? {
|
|
65
|
+
expandedProperties
|
|
66
|
+
} : {
|
|
67
|
+
parameters
|
|
68
|
+
}),
|
|
69
|
+
returnValue,
|
|
70
|
+
...(descriptionText ? {
|
|
71
|
+
descriptionText
|
|
72
|
+
} : {}),
|
|
73
|
+
...(description ? {
|
|
74
|
+
description
|
|
75
|
+
} : {}),
|
|
76
|
+
...(returnValueDescriptionText ? {
|
|
77
|
+
returnValueDescriptionText
|
|
78
|
+
} : {}),
|
|
79
|
+
...(returnValueDescription ? {
|
|
80
|
+
returnValueDescription
|
|
81
|
+
} : {}),
|
|
82
|
+
...rest
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (typeMeta.type === 'raw') {
|
|
87
|
+
const {
|
|
88
|
+
name,
|
|
89
|
+
formattedCode,
|
|
90
|
+
descriptionText,
|
|
91
|
+
description,
|
|
92
|
+
reExportOf,
|
|
93
|
+
...rest
|
|
94
|
+
} = typeMeta.data;
|
|
95
|
+
return {
|
|
96
|
+
...typeMeta,
|
|
97
|
+
data: {
|
|
98
|
+
name,
|
|
99
|
+
formattedCode,
|
|
100
|
+
...(descriptionText ? {
|
|
101
|
+
descriptionText
|
|
102
|
+
} : {}),
|
|
103
|
+
...(description ? {
|
|
104
|
+
description
|
|
105
|
+
} : {}),
|
|
106
|
+
...(reExportOf ? {
|
|
107
|
+
reExportOf
|
|
108
|
+
} : {}),
|
|
109
|
+
...rest
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return typeMeta;
|
|
114
|
+
}
|
|
115
|
+
function normalizeTypesByExportForCache(exports) {
|
|
116
|
+
const normalized = {};
|
|
117
|
+
for (const [exportName, exportData] of Object.entries(exports)) {
|
|
118
|
+
normalized[exportName] = {
|
|
119
|
+
type: normalizeTypeMetaForCache(exportData.type),
|
|
120
|
+
additionalTypes: exportData.additionalTypes.map(normalizeTypeMetaForCache)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return normalized;
|
|
124
|
+
}
|
|
125
|
+
function normalizeVariantOnlyTypesForCache(variantOnlyAdditionalTypes) {
|
|
126
|
+
const normalized = {};
|
|
127
|
+
for (const [variantName, types] of Object.entries(variantOnlyAdditionalTypes)) {
|
|
128
|
+
normalized[variantName] = types.map(normalizeTypeMetaForCache);
|
|
129
|
+
}
|
|
130
|
+
return normalized;
|
|
131
|
+
}
|
|
132
|
+
export function normalizeTypesSourceDataForCache(data) {
|
|
133
|
+
return stripPositionFields({
|
|
134
|
+
exports: normalizeTypesByExportForCache(data.exports),
|
|
135
|
+
additionalTypes: data.additionalTypes.map(normalizeTypeMetaForCache),
|
|
136
|
+
variantOnlyAdditionalTypes: normalizeVariantOnlyTypesForCache(data.variantOnlyAdditionalTypes),
|
|
137
|
+
externalTypes: data.externalTypes,
|
|
138
|
+
typeNameMap: data.typeNameMap,
|
|
139
|
+
variantTypeNameMaps: data.variantTypeNameMaps,
|
|
140
|
+
variantTypeNames: data.variantTypeNames,
|
|
141
|
+
allDependencies: data.allDependencies,
|
|
142
|
+
updated: data.updated
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OrderingConfig } from "./order.mjs";
|
|
2
|
+
/** Cache namespace for the types.md parse cache (TypesSourceData), mirroring the page-index cache. */
|
|
3
|
+
export declare const TYPES_TEXT_CACHE_NAMESPACE = "types-text";
|
|
4
|
+
/**
|
|
5
|
+
* Derives the cache key for a types.md file from its path, reusing the page route
|
|
6
|
+
* derivation so a writer (syncTypes) and reader (loadServerTypesText) of the same
|
|
7
|
+
* types.md agree on the cache location.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* resolveTypesCacheKey('/root/src/app/components/accordion/types.md', '/root') // 'components/accordion'
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveTypesCacheKey(typesMarkdownPath: string, rootContext: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Builds the hash-validation content for the types.md parse cache. Includes the
|
|
15
|
+
* ordering config because it changes `parseTypesMarkdown`'s output, so the cache is
|
|
16
|
+
* invalidated when either the markdown or the ordering changes. The writer (syncTypes)
|
|
17
|
+
* and reader (loadServerTypesText) must build this identically for their hashes to match.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildTypesTextCacheContent(markdown: string, ordering?: OrderingConfig): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { extractPrefixAndTitle } from "../loadServerPageIndex/extractPrefixAndTitle.mjs";
|
|
2
|
+
/** Cache namespace for the types.md parse cache (TypesSourceData), mirroring the page-index cache. */
|
|
3
|
+
export const TYPES_TEXT_CACHE_NAMESPACE = 'types-text';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Derives the cache key for a types.md file from its path, reusing the page route
|
|
7
|
+
* derivation so a writer (syncTypes) and reader (loadServerTypesText) of the same
|
|
8
|
+
* types.md agree on the cache location.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* resolveTypesCacheKey('/root/src/app/components/accordion/types.md', '/root') // 'components/accordion'
|
|
12
|
+
*/
|
|
13
|
+
export function resolveTypesCacheKey(typesMarkdownPath, rootContext) {
|
|
14
|
+
const {
|
|
15
|
+
prefix
|
|
16
|
+
} = extractPrefixAndTitle(typesMarkdownPath, rootContext);
|
|
17
|
+
const segments = prefix.split('/').filter(Boolean);
|
|
18
|
+
return segments.length > 0 ? segments.join('/') : 'index';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builds the hash-validation content for the types.md parse cache. Includes the
|
|
23
|
+
* ordering config because it changes `parseTypesMarkdown`'s output, so the cache is
|
|
24
|
+
* invalidated when either the markdown or the ordering changes. The writer (syncTypes)
|
|
25
|
+
* and reader (loadServerTypesText) must build this identically for their hashes to match.
|
|
26
|
+
*/
|
|
27
|
+
export function buildTypesTextCacheContent(markdown, ordering) {
|
|
28
|
+
return `${JSON.stringify(ordering ?? null)}\n${markdown}`;
|
|
29
|
+
}
|
|
@@ -85,16 +85,18 @@ export interface ImportsAndComments {
|
|
|
85
85
|
* parsed straight out of remote sources without first being mapped onto a
|
|
86
86
|
* placeholder `file://` URL.
|
|
87
87
|
*
|
|
88
|
+
* Parsing is fully synchronous — no I/O, no `await`.
|
|
89
|
+
*
|
|
88
90
|
* @param code - The source code to parse
|
|
89
91
|
* @param fileUrl - The file URL (`file://`, `http://`, `https://`) or path, used to determine file type and resolve relative imports
|
|
90
92
|
* @param options - Optional configuration for comment processing
|
|
91
93
|
* @param options.removeCommentsWithPrefix - Array of prefixes; comments starting with these will be stripped from output
|
|
92
94
|
* @param options.notableCommentsPrefix - Array of prefixes; comments starting with these will be collected regardless of stripping
|
|
93
|
-
* @returns
|
|
95
|
+
* @returns Parsed import data, optionally including processed code and collected comments
|
|
94
96
|
*
|
|
95
97
|
* @example
|
|
96
98
|
* ```typescript
|
|
97
|
-
* const result =
|
|
99
|
+
* const result = parseImportsAndComments(
|
|
98
100
|
* 'import React from "react";\nimport { Button } from "./Button";\nexport { Icon } from "./Icon";',
|
|
99
101
|
* '/src/App.tsx'
|
|
100
102
|
* );
|
|
@@ -106,4 +108,4 @@ export interface ImportsAndComments {
|
|
|
106
108
|
export declare function parseImportsAndComments(code: string, fileUrl: string, options?: {
|
|
107
109
|
removeCommentsWithPrefix?: string[];
|
|
108
110
|
notableCommentsPrefix?: string[];
|
|
109
|
-
}):
|
|
111
|
+
}): ImportsAndComments;
|