@mui/internal-docs-infra 0.1.1-alpha.1 → 0.1.1-alpha.11
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/CodeControllerContext/CodeControllerContext.d.ts +1 -1
- package/CodeControllerContext/CodeControllerContext.d.ts.map +1 -1
- package/CodeControllerContext/index.d.ts.map +1 -1
- package/CodeExternalsContext/CodeExternalsContext.d.ts +8 -0
- package/CodeExternalsContext/CodeExternalsContext.d.ts.map +1 -0
- package/CodeExternalsContext/CodeExternalsContext.js +7 -0
- package/CodeExternalsContext/index.d.ts +1 -0
- package/CodeExternalsContext/index.d.ts.map +1 -0
- package/CodeExternalsContext/index.js +1 -0
- package/CodeHighlighter/CodeHighlighter.d.ts +1 -1
- package/CodeHighlighter/CodeHighlighter.d.ts.map +1 -1
- package/CodeHighlighter/CodeHighlighter.js +235 -86
- package/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -1
- package/CodeHighlighter/CodeHighlighterClient.js +500 -62
- package/CodeHighlighter/CodeHighlighterContext.d.ts +2 -0
- package/CodeHighlighter/CodeHighlighterContext.d.ts.map +1 -1
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +1 -1
- package/CodeHighlighter/CodeHighlighterFallbackContext.js +3 -1
- package/CodeHighlighter/applyTransform.d.ts.map +1 -1
- package/CodeHighlighter/codeToFallbackProps.d.ts +2 -2
- package/CodeHighlighter/codeToFallbackProps.d.ts.map +1 -1
- package/CodeHighlighter/codeToFallbackProps.js +8 -5
- package/CodeHighlighter/errors.d.ts.map +1 -1
- package/CodeHighlighter/hasAllVariants.d.ts.map +1 -1
- package/CodeHighlighter/index.d.ts.map +1 -1
- package/CodeHighlighter/loadFallbackCode.d.ts +3 -2
- package/CodeHighlighter/loadFallbackCode.d.ts.map +1 -1
- package/CodeHighlighter/loadFallbackCode.js +325 -161
- package/CodeHighlighter/loadVariant.d.ts +3 -2
- package/CodeHighlighter/loadVariant.d.ts.map +1 -1
- package/CodeHighlighter/loadVariant.js +604 -229
- package/CodeHighlighter/maybeInitialData.d.ts +1 -1
- package/CodeHighlighter/maybeInitialData.d.ts.map +1 -1
- package/CodeHighlighter/parseCode.d.ts.map +1 -1
- package/CodeHighlighter/parseCode.js +14 -2
- package/CodeHighlighter/parseControlledCode.d.ts.map +1 -1
- package/CodeHighlighter/parseControlledCode.js +12 -1
- package/CodeHighlighter/transformCode.d.ts +1 -0
- package/CodeHighlighter/transformCode.d.ts.map +1 -1
- package/CodeHighlighter/transformCode.js +43 -3
- package/CodeHighlighter/transformParsedSource.d.ts.map +1 -1
- package/CodeHighlighter/transformSource.d.ts.map +1 -1
- package/CodeHighlighter/types.d.ts +39 -17
- package/CodeHighlighter/types.d.ts.map +1 -1
- package/CodeProvider/CodeContext.d.ts.map +1 -1
- package/CodeProvider/CodeProvider.d.ts.map +1 -1
- package/CodeProvider/CodeProvider.js +21 -6
- package/CodeProvider/index.d.ts +1 -2
- package/CodeProvider/index.d.ts.map +1 -1
- package/CodeProvider/index.js +1 -2
- package/abstractCreateDemo/abstractCreateDemo.d.ts +35 -0
- package/abstractCreateDemo/abstractCreateDemo.d.ts.map +1 -0
- package/abstractCreateDemo/abstractCreateDemo.js +91 -0
- package/abstractCreateDemo/index.d.ts +1 -0
- package/abstractCreateDemo/index.d.ts.map +1 -0
- package/abstractCreateDemo/index.js +1 -0
- package/createDemoData/createDemoData.d.ts +44 -0
- package/createDemoData/createDemoData.d.ts.map +1 -0
- package/createDemoData/createDemoData.js +75 -0
- package/createDemoData/index.d.ts +1 -0
- package/createDemoData/index.d.ts.map +1 -0
- package/createDemoData/index.js +1 -0
- package/createDemoData/types.d.ts +28 -0
- package/createDemoData/types.d.ts.map +1 -0
- package/createDemoData/types.js +1 -0
- package/package.json +15 -9
- package/pipeline/hastUtils/hastUtils.d.ts.map +1 -0
- package/{hast/hast.js → pipeline/hastUtils/hastUtils.js} +2 -1
- package/pipeline/hastUtils/index.d.ts +1 -0
- package/pipeline/hastUtils/index.d.ts.map +1 -0
- package/pipeline/hastUtils/index.js +1 -0
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +54 -0
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +1 -0
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +465 -0
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +15 -0
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +1 -0
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +253 -0
- package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +1 -0
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +20 -0
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +1 -0
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +228 -0
- package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseCreateFactoryCall.d.ts +12 -1
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +1 -0
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +433 -0
- package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.d.ts +5 -1
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +1 -0
- package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/parseFunctionParameters.js +1 -1
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +25 -0
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +1 -0
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +73 -0
- package/pipeline/loadServerCodeMeta/index.d.ts +1 -0
- package/pipeline/loadServerCodeMeta/index.d.ts.map +1 -0
- package/pipeline/loadServerCodeMeta/index.js +1 -0
- package/{loadServerCodeMeta/serverLoadCodeMeta.d.ts → pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts} +4 -4
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +1 -0
- package/{loadServerCodeMeta/serverLoadCodeMeta.js → pipeline/loadServerCodeMeta/loadServerCodeMeta.js} +18 -3
- package/pipeline/loadServerSource/index.d.ts +1 -0
- package/pipeline/loadServerSource/index.d.ts.map +1 -0
- package/pipeline/loadServerSource/index.js +1 -0
- package/{loadServerSource/serverLoadSource.d.ts → pipeline/loadServerSource/loadServerSource.d.ts} +5 -5
- package/pipeline/loadServerSource/loadServerSource.d.ts.map +1 -0
- package/pipeline/loadServerSource/loadServerSource.js +135 -0
- package/pipeline/loaderUtils/externalsToPackages.d.ts +1 -0
- package/pipeline/loaderUtils/externalsToPackages.d.ts.map +1 -0
- package/pipeline/loaderUtils/externalsToPackages.js +46 -0
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +34 -0
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +1 -0
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +161 -0
- package/{loaderUtils → pipeline/loaderUtils}/getFileNameFromUrl.d.ts +1 -0
- package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +1 -0
- package/pipeline/loaderUtils/getFileNameFromUrl.js +66 -0
- package/pipeline/loaderUtils/index.d.ts +7 -0
- package/pipeline/loaderUtils/index.d.ts.map +1 -0
- package/pipeline/loaderUtils/index.js +7 -0
- package/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
- package/pipeline/loaderUtils/mergeExternals.d.ts.map +1 -0
- package/pipeline/loaderUtils/mergeExternals.js +72 -0
- package/pipeline/loaderUtils/parseImports.d.ts +20 -0
- package/pipeline/loaderUtils/parseImports.d.ts.map +1 -0
- package/pipeline/loaderUtils/parseImports.js +307 -0
- package/{loaderUtils/processImports.d.ts → pipeline/loaderUtils/processRelativeImports.d.ts} +2 -2
- package/pipeline/loaderUtils/processRelativeImports.d.ts.map +1 -0
- package/pipeline/loaderUtils/processRelativeImports.js +352 -0
- package/{loaderUtils → pipeline/loaderUtils}/resolveModulePath.d.ts +19 -6
- package/pipeline/loaderUtils/resolveModulePath.d.ts.map +1 -0
- package/pipeline/loaderUtils/resolveModulePath.js +1449 -0
- package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.d.ts +6 -3
- package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +1 -0
- package/{loaderUtils → pipeline/loaderUtils}/resolveModulePathWithFs.js +8 -4
- package/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
- package/pipeline/loaderUtils/rewriteImports.d.ts.map +1 -0
- package/pipeline/loaderUtils/rewriteImports.js +35 -0
- package/pipeline/parseSource/grammars.d.ts.map +1 -0
- package/pipeline/parseSource/index.d.ts.map +1 -0
- package/pipeline/parseSource/parseSource.d.ts +3 -0
- package/pipeline/parseSource/parseSource.d.ts.map +1 -0
- package/{parseSource → pipeline/parseSource}/parseSource.js +15 -5
- package/pipeline/transformHtmlCode/index.d.ts +2 -0
- package/pipeline/transformHtmlCode/index.d.ts.map +1 -0
- package/pipeline/transformHtmlCode/index.js +4 -0
- package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
- package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +1 -0
- package/pipeline/transformHtmlCode/transformHtmlCode.js +303 -0
- package/pipeline/transformMarkdownCode/index.d.ts +2 -0
- package/pipeline/transformMarkdownCode/index.d.ts.map +1 -0
- package/pipeline/transformMarkdownCode/index.js +4 -0
- package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
- package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +1 -0
- package/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
- package/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
- package/pipeline/transformTypescriptToJavascript/index.d.ts.map +1 -0
- package/pipeline/transformTypescriptToJavascript/index.js +1 -0
- package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +1 -0
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +1 -0
- package/{transformTsToJs/transformTsToJs.js → pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js} +4 -4
- package/useCode/index.d.ts.map +1 -1
- package/useCode/useCode.d.ts +14 -11
- package/useCode/useCode.d.ts.map +1 -1
- package/useCode/useCode.js +94 -364
- package/useCode/useCodeUtils.d.ts +45 -0
- package/useCode/useCodeUtils.d.ts.map +1 -0
- package/useCode/useCodeUtils.js +240 -0
- package/useCode/useCopyFunctionality.d.ts +17 -0
- package/useCode/useCopyFunctionality.d.ts.map +1 -0
- package/useCode/useCopyFunctionality.js +28 -0
- package/useCode/useFileNavigation.d.ts +49 -0
- package/useCode/useFileNavigation.d.ts.map +1 -0
- package/useCode/useFileNavigation.js +398 -0
- package/useCode/useSourceEditing.d.ts +19 -0
- package/useCode/useSourceEditing.d.ts.map +1 -0
- package/useCode/useSourceEditing.js +32 -0
- package/useCode/useTransformManagement.d.ts +28 -0
- package/useCode/useTransformManagement.d.ts.map +1 -0
- package/useCode/useTransformManagement.js +82 -0
- package/useCode/useUIState.d.ts +16 -0
- package/useCode/useUIState.d.ts.map +1 -0
- package/useCode/useUIState.js +21 -0
- package/useCode/useVariantSelection.d.ts +21 -0
- package/useCode/useVariantSelection.d.ts.map +1 -0
- package/useCode/useVariantSelection.js +84 -0
- package/useCopier/index.d.ts +1 -1
- package/useCopier/index.d.ts.map +1 -1
- package/useCopier/index.js +5 -5
- package/useDemo/createCodeSandbox.d.ts +18 -0
- package/useDemo/createCodeSandbox.d.ts.map +1 -0
- package/useDemo/createCodeSandbox.js +48 -0
- package/useDemo/createStackBlitz.d.ts +22 -0
- package/useDemo/createStackBlitz.d.ts.map +1 -0
- package/useDemo/createStackBlitz.js +38 -0
- package/useDemo/examineVariant.d.ts +25 -0
- package/useDemo/examineVariant.d.ts.map +1 -0
- package/useDemo/examineVariant.js +134 -0
- package/useDemo/exportVariant.d.ts +110 -0
- package/useDemo/exportVariant.d.ts.map +1 -0
- package/useDemo/exportVariant.js +320 -0
- package/useDemo/exportVariantAsCra.d.ts +15 -0
- package/useDemo/exportVariantAsCra.d.ts.map +1 -0
- package/useDemo/exportVariantAsCra.js +56 -0
- package/useDemo/flattenVariant.d.ts +17 -0
- package/useDemo/flattenVariant.d.ts.map +1 -0
- package/useDemo/flattenVariant.js +206 -0
- package/useDemo/index.d.ts +6 -39
- package/useDemo/index.d.ts.map +1 -1
- package/useDemo/index.js +6 -17
- package/useDemo/useDemo.d.ts +79 -0
- package/useDemo/useDemo.d.ts.map +1 -0
- package/useDemo/useDemo.js +174 -0
- package/useLocalStorageState/index.d.ts +2 -0
- package/useLocalStorageState/index.d.ts.map +1 -0
- package/useLocalStorageState/index.js +2 -0
- package/useLocalStorageState/useLocalStorageState.d.ts +14 -0
- package/useLocalStorageState/useLocalStorageState.d.ts.map +1 -0
- package/useLocalStorageState/useLocalStorageState.js +128 -0
- package/useOnHydrate/index.d.ts.map +1 -1
- package/useOnHydrate/useOnHydrate.d.ts.map +1 -1
- package/useOnIdle/index.d.ts.map +1 -1
- package/useOnIdle/useOnIdle.d.ts.map +1 -1
- package/useUrlHashState/index.d.ts +1 -0
- package/useUrlHashState/index.d.ts.map +1 -0
- package/useUrlHashState/index.js +1 -0
- package/useUrlHashState/useUrlHashState.d.ts +50 -0
- package/useUrlHashState/useUrlHashState.d.ts.map +1 -0
- package/useUrlHashState/useUrlHashState.js +113 -0
- package/hast/hast.d.ts.map +0 -1
- package/hast/index.d.ts +0 -1
- package/hast/index.d.ts.map +0 -1
- package/hast/index.js +0 -1
- package/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -57
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -194
- package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -243
- package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -27
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -37
- package/loadServerCodeMeta/index.d.ts +0 -1
- package/loadServerCodeMeta/index.d.ts.map +0 -1
- package/loadServerCodeMeta/index.js +0 -1
- package/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +0 -1
- package/loadServerSource/index.d.ts +0 -1
- package/loadServerSource/index.d.ts.map +0 -1
- package/loadServerSource/index.js +0 -1
- package/loadServerSource/serverLoadSource.d.ts.map +0 -1
- package/loadServerSource/serverLoadSource.js +0 -100
- package/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
- package/loaderUtils/getFileNameFromUrl.js +0 -32
- package/loaderUtils/index.d.ts +0 -5
- package/loaderUtils/index.d.ts.map +0 -1
- package/loaderUtils/index.js +0 -5
- package/loaderUtils/processImports.d.ts.map +0 -1
- package/loaderUtils/processImports.js +0 -82
- package/loaderUtils/resolveImports.d.ts +0 -4
- package/loaderUtils/resolveImports.d.ts.map +0 -1
- package/loaderUtils/resolveImports.js +0 -71
- package/loaderUtils/resolveModulePath.d.ts.map +0 -1
- package/loaderUtils/resolveModulePath.js +0 -862
- package/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
- package/loaderUtils/rewriteImports.d.ts +0 -9
- package/loaderUtils/rewriteImports.d.ts.map +0 -1
- package/loaderUtils/rewriteImports.js +0 -57
- package/parseSource/grammars.d.ts.map +0 -1
- package/parseSource/index.d.ts.map +0 -1
- package/parseSource/parseSource.d.ts +0 -3
- package/parseSource/parseSource.d.ts.map +0 -1
- package/transformRelativeMarkdownPaths/index.d.ts +0 -2
- package/transformRelativeMarkdownPaths/index.d.ts.map +0 -1
- package/transformRelativeMarkdownPaths/index.js +0 -4
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +0 -12
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +0 -1
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +0 -30
- package/transformTsToJs/index.d.ts +0 -1
- package/transformTsToJs/index.d.ts.map +0 -1
- package/transformTsToJs/index.js +0 -1
- package/transformTsToJs/removeTypes.d.ts.map +0 -1
- package/transformTsToJs/transformTsToJs.d.ts +0 -3
- package/transformTsToJs/transformTsToJs.d.ts.map +0 -1
- /package/{hast/hast.d.ts → pipeline/hastUtils/hastUtils.d.ts} +0 -0
- /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.d.ts +0 -0
- /package/{loadPrecomputedCodeHighlighter → pipeline/loadPrecomputedCodeHighlighter}/index.js +0 -0
- /package/{parseSource → pipeline/parseSource}/grammars.d.ts +0 -0
- /package/{parseSource → pipeline/parseSource}/grammars.js +0 -0
- /package/{parseSource → pipeline/parseSource}/index.d.ts +0 -0
- /package/{parseSource → pipeline/parseSource}/index.js +0 -0
- /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.d.ts +0 -0
- /package/{transformTsToJs → pipeline/transformTypescriptToJavascript}/removeTypes.js +0 -0
|
@@ -2,7 +2,7 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
|
|
|
2
2
|
export declare function maybeInitialData(variants: string[], variant: string, code?: Code, fileName?: string, needsHighlight?: boolean, needsAllFiles?: boolean, needsAllVariants?: boolean): {
|
|
3
3
|
initialData: false | {
|
|
4
4
|
code: Code;
|
|
5
|
-
initialFilename: string;
|
|
5
|
+
initialFilename: string | undefined;
|
|
6
6
|
initialSource: VariantSource;
|
|
7
7
|
initialExtraFiles?: VariantExtraFiles;
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybeInitialData.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"maybeInitialData.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/maybeInitialData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEjE,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,IAAI,EACX,QAAQ,CAAC,EAAE,MAAM,EACjB,cAAc,UAAQ,EACtB,aAAa,UAAQ,EACrB,gBAAgB,UAAQ,GACvB;IACD,WAAW,EACP,KAAK,GACL;QACE,IAAI,EAAE,IAAI,CAAC;QACX,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;QACpC,aAAa,EAAE,aAAa,CAAC;QAC7B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;KACvC,CAAC;IACN,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAoGA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseCode.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"parseCode.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/parseCode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CA2IpE"}
|
|
@@ -15,8 +15,8 @@ export function parseCode(code, parseSource) {
|
|
|
15
15
|
// Already parsed/highlighted
|
|
16
16
|
parsed[variant] = variantCode;
|
|
17
17
|
} else if (variantCode && _typeof(variantCode) === 'object') {
|
|
18
|
-
// Parse if source is available and not already parsed
|
|
19
|
-
if (variantCode.source && typeof variantCode.source === 'string') {
|
|
18
|
+
// Parse if source is available and not already parsed, and we have a filename to determine the file type
|
|
19
|
+
if (variantCode.source && typeof variantCode.source === 'string' && variantCode.fileName) {
|
|
20
20
|
try {
|
|
21
21
|
var hastNodes = parseSource(variantCode.source, variantCode.fileName);
|
|
22
22
|
|
|
@@ -51,6 +51,18 @@ export function parseCode(code, parseSource) {
|
|
|
51
51
|
// Keep original if parsing fails
|
|
52
52
|
parsed[variant] = variantCode;
|
|
53
53
|
}
|
|
54
|
+
} else if (variantCode.source && typeof variantCode.source === 'string' && !variantCode.fileName) {
|
|
55
|
+
// Return a basic HAST root node with the source text for unsupported file types
|
|
56
|
+
// This indicates that the source has at least passed through the parsing pipeline
|
|
57
|
+
parsed[variant] = _objectSpread(_objectSpread({}, variantCode), {}, {
|
|
58
|
+
source: {
|
|
59
|
+
type: 'root',
|
|
60
|
+
children: [{
|
|
61
|
+
type: 'text',
|
|
62
|
+
value: variantCode.source
|
|
63
|
+
}]
|
|
64
|
+
}
|
|
65
|
+
});
|
|
54
66
|
} else if (variantCode.source && _typeof(variantCode.source) === 'object' && 'hastJson' in variantCode.source) {
|
|
55
67
|
try {
|
|
56
68
|
// Parse hastJson to HAST nodes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseControlledCode.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"parseControlledCode.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/parseControlledCode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAC;AAEhF;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,GACvB,IAAI,CA8EN"}
|
|
@@ -19,13 +19,24 @@ export function parseControlledCode(controlledCode, parseSource) {
|
|
|
19
19
|
|
|
20
20
|
// Convert null to empty string, then parse
|
|
21
21
|
var sourceToProcess = variantCode.source === null ? '' : variantCode.source;
|
|
22
|
-
if (typeof sourceToProcess === 'string') {
|
|
22
|
+
if (typeof sourceToProcess === 'string' && variantCode.fileName) {
|
|
23
23
|
try {
|
|
24
24
|
mainSource = parseSource(sourceToProcess, variantCode.fileName);
|
|
25
25
|
} catch (error) {
|
|
26
26
|
// Keep original string if parsing fails
|
|
27
27
|
mainSource = sourceToProcess;
|
|
28
28
|
}
|
|
29
|
+
} else if (typeof sourceToProcess === 'string' && !variantCode.fileName) {
|
|
30
|
+
// Return a basic HAST root node with the source text for unsupported file types
|
|
31
|
+
// This indicates that the source has at least passed through the parsing pipeline
|
|
32
|
+
var source = {
|
|
33
|
+
type: 'root',
|
|
34
|
+
children: [{
|
|
35
|
+
type: 'text',
|
|
36
|
+
value: sourceToProcess
|
|
37
|
+
}]
|
|
38
|
+
};
|
|
39
|
+
mainSource = source;
|
|
29
40
|
} else {
|
|
30
41
|
// Handle undefined or other non-string values
|
|
31
42
|
mainSource = sourceToProcess;
|
|
@@ -6,6 +6,7 @@ import type { Code, ParseSource } from "./types.js";
|
|
|
6
6
|
export declare function getVariantsToTransform(parsedCode: Code): Array<[string, any]>;
|
|
7
7
|
/**
|
|
8
8
|
* Pure function to get available transforms from a specific variant.
|
|
9
|
+
* Only includes transforms that have actual deltas (file changes), not just filename changes.
|
|
9
10
|
*/
|
|
10
11
|
export declare function getAvailableTransforms(parsedCode: Code | undefined, variantName: string): string[];
|
|
11
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformCode.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"transformCode.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/transformCode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGjD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CA4B7E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,IAAI,GAAG,SAAS,EAC5B,WAAW,EAAE,MAAM,GAClB,MAAM,EAAE,CAqDV;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,GAAG,EAChB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,GAAG,CAAC,CA6Ed;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B/F"}
|
|
@@ -32,13 +32,53 @@ export function getVariantsToTransform(parsedCode) {
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Pure function to get available transforms from a specific variant.
|
|
35
|
+
* Only includes transforms that have actual deltas (file changes), not just filename changes.
|
|
35
36
|
*/
|
|
36
37
|
export function getAvailableTransforms(parsedCode, variantName) {
|
|
37
38
|
var currentVariant = parsedCode == null ? void 0 : parsedCode[variantName];
|
|
38
|
-
if (currentVariant
|
|
39
|
-
return
|
|
39
|
+
if (!currentVariant || _typeof(currentVariant) !== 'object') {
|
|
40
|
+
return [];
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
var transforms = new Set();
|
|
43
|
+
|
|
44
|
+
// Check main variant transforms
|
|
45
|
+
if (currentVariant.transforms) {
|
|
46
|
+
Object.keys(currentVariant.transforms).forEach(function (transformKey) {
|
|
47
|
+
var transformData = currentVariant.transforms[transformKey];
|
|
48
|
+
// Only include transforms that have actual deltas (file changes)
|
|
49
|
+
// Check if delta exists and is not empty
|
|
50
|
+
if (transformData && _typeof(transformData) === 'object' && 'delta' in transformData) {
|
|
51
|
+
var delta = transformData.delta;
|
|
52
|
+
// Check if delta has meaningful content (not just an empty object)
|
|
53
|
+
var hasContent = delta && _typeof(delta) === 'object' && Object.keys(delta).length > 0;
|
|
54
|
+
if (hasContent) {
|
|
55
|
+
transforms.add(transformKey);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Check extraFiles for transforms with deltas
|
|
62
|
+
if (currentVariant.extraFiles) {
|
|
63
|
+
Object.values(currentVariant.extraFiles).forEach(function (fileData) {
|
|
64
|
+
if (fileData && _typeof(fileData) === 'object' && 'transforms' in fileData && fileData.transforms) {
|
|
65
|
+
Object.keys(fileData.transforms).forEach(function (transformKey) {
|
|
66
|
+
var transformData = fileData.transforms[transformKey];
|
|
67
|
+
// Only include transforms that have actual deltas (file changes)
|
|
68
|
+
// Check if delta exists and is not empty
|
|
69
|
+
if (transformData && _typeof(transformData) === 'object' && 'delta' in transformData) {
|
|
70
|
+
var delta = transformData.delta;
|
|
71
|
+
// Check if delta has meaningful content (not just an empty object)
|
|
72
|
+
var hasContent = delta && _typeof(delta) === 'object' && Object.keys(delta).length > 0;
|
|
73
|
+
if (hasContent) {
|
|
74
|
+
transforms.add(transformKey);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return Array.from(transforms);
|
|
42
82
|
}
|
|
43
83
|
|
|
44
84
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformParsedSource.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"transformParsedSource.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/transformParsedSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIlD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,KAAK,EACnB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAwB9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformSource.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"transformSource.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/transformSource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI7E,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAuDjC"}
|
|
@@ -4,12 +4,18 @@ export type Components = {
|
|
|
4
4
|
[key: string]: React.ReactNode;
|
|
5
5
|
};
|
|
6
6
|
type CodeMeta = {
|
|
7
|
-
fileName
|
|
7
|
+
fileName?: string;
|
|
8
8
|
};
|
|
9
9
|
export type Transforms = Record<string, {
|
|
10
10
|
delta: Delta;
|
|
11
11
|
fileName?: string;
|
|
12
12
|
}>;
|
|
13
|
+
export interface ExternalImportItem {
|
|
14
|
+
name: string;
|
|
15
|
+
type: 'named' | 'default' | 'namespace';
|
|
16
|
+
isType?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export type Externals = Record<string, ExternalImportItem[]>;
|
|
13
19
|
export type VariantSource = string | HastNodes | {
|
|
14
20
|
hastJson: string;
|
|
15
21
|
};
|
|
@@ -17,15 +23,20 @@ export type VariantExtraFiles = {
|
|
|
17
23
|
[fileName: string]: string | {
|
|
18
24
|
source?: VariantSource;
|
|
19
25
|
transforms?: Transforms;
|
|
26
|
+
skipTransforms?: boolean;
|
|
27
|
+
metadata?: boolean;
|
|
20
28
|
};
|
|
21
29
|
};
|
|
22
30
|
export type VariantCode = CodeMeta & {
|
|
23
|
-
url
|
|
31
|
+
url?: string;
|
|
24
32
|
source?: VariantSource;
|
|
25
33
|
extraFiles?: VariantExtraFiles;
|
|
34
|
+
externals?: string[];
|
|
35
|
+
namedExport?: string;
|
|
26
36
|
filesOrder?: string[];
|
|
27
37
|
transforms?: Transforms;
|
|
28
38
|
allFilesListed?: boolean;
|
|
39
|
+
skipTransforms?: boolean;
|
|
29
40
|
};
|
|
30
41
|
export type Code = {
|
|
31
42
|
[key: string]: undefined | string | VariantCode;
|
|
@@ -36,7 +47,7 @@ export type ControlledVariantExtraFiles = {
|
|
|
36
47
|
};
|
|
37
48
|
};
|
|
38
49
|
export type ControlledVariantCode = CodeMeta & {
|
|
39
|
-
url
|
|
50
|
+
url?: string;
|
|
40
51
|
source?: string | null;
|
|
41
52
|
extraFiles?: ControlledVariantExtraFiles;
|
|
42
53
|
filesOrder?: string[];
|
|
@@ -44,15 +55,14 @@ export type ControlledVariantCode = CodeMeta & {
|
|
|
44
55
|
export type ControlledCode = {
|
|
45
56
|
[key: string]: undefined | null | ControlledVariantCode;
|
|
46
57
|
};
|
|
47
|
-
type
|
|
58
|
+
type BaseContentProps = {
|
|
48
59
|
name?: string;
|
|
49
60
|
slug?: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
};
|
|
52
|
-
export type ContentProps = {
|
|
53
61
|
code?: Code;
|
|
54
62
|
components?: Components;
|
|
55
|
-
|
|
63
|
+
url?: string;
|
|
64
|
+
};
|
|
65
|
+
export type ContentProps<T extends {}> = BaseContentProps & T;
|
|
56
66
|
export type ContentLoadingVariant = {
|
|
57
67
|
fileNames?: string[];
|
|
58
68
|
source?: React.ReactNode;
|
|
@@ -60,27 +70,35 @@ export type ContentLoadingVariant = {
|
|
|
60
70
|
[fileName: string]: React.ReactNode;
|
|
61
71
|
};
|
|
62
72
|
};
|
|
63
|
-
export type
|
|
73
|
+
export type BaseContentLoadingProps = ContentLoadingVariant & {
|
|
64
74
|
extraVariants?: Record<string, ContentLoadingVariant>;
|
|
65
|
-
|
|
75
|
+
name?: string;
|
|
76
|
+
slug?: string;
|
|
77
|
+
url?: string;
|
|
78
|
+
};
|
|
79
|
+
export type ContentLoadingProps<T extends {}> = BaseContentLoadingProps & T;
|
|
66
80
|
type ErrorHandler = React.ComponentType<{
|
|
67
81
|
error: Error;
|
|
68
82
|
}>;
|
|
69
|
-
interface CodeHighlighterBaseProps
|
|
83
|
+
interface CodeHighlighterBaseProps {
|
|
84
|
+
name?: string;
|
|
85
|
+
slug?: string;
|
|
70
86
|
code?: Code;
|
|
87
|
+
globalsCode?: Array<Code | string>;
|
|
71
88
|
components?: Components;
|
|
72
89
|
variants?: string[];
|
|
73
90
|
variant?: string;
|
|
74
91
|
fileName?: string;
|
|
75
92
|
initialVariant?: string;
|
|
76
93
|
defaultVariant?: string;
|
|
77
|
-
precompute?:
|
|
94
|
+
precompute?: Code;
|
|
78
95
|
fallbackUsesExtraFiles?: boolean;
|
|
79
96
|
fallbackUsesAllVariants?: boolean;
|
|
80
|
-
url
|
|
97
|
+
url?: string;
|
|
81
98
|
controlled?: boolean;
|
|
99
|
+
children?: string;
|
|
82
100
|
}
|
|
83
|
-
export interface CodeHighlighterClientProps extends CodeHighlighterBaseProps {
|
|
101
|
+
export interface CodeHighlighterClientProps extends Omit<CodeHighlighterBaseProps, 'children'> {
|
|
84
102
|
children: React.ReactNode;
|
|
85
103
|
errorHandler?: React.ReactNode;
|
|
86
104
|
fallback?: React.ReactNode;
|
|
@@ -96,6 +114,7 @@ export type LoadSource = (url: string) => Promise<{
|
|
|
96
114
|
source: string;
|
|
97
115
|
extraFiles?: VariantExtraFiles;
|
|
98
116
|
extraDependencies?: string[];
|
|
117
|
+
externals?: Externals;
|
|
99
118
|
}>;
|
|
100
119
|
export type TransformSource = (source: string, fileName: string) => Promise<Record<string, {
|
|
101
120
|
source: string;
|
|
@@ -119,11 +138,14 @@ export interface LoadFileOptions {
|
|
|
119
138
|
maxDepth?: number;
|
|
120
139
|
/** Set of already loaded file URLs to prevent circular dependencies */
|
|
121
140
|
loadedFiles?: Set<string>;
|
|
141
|
+
/** Side effects code to inject into extraFiles */
|
|
142
|
+
globalsCode?: Array<VariantCode | string>;
|
|
122
143
|
}
|
|
123
|
-
export interface CodeHighlighterProps extends CodeHighlighterBaseProps {
|
|
124
|
-
Content: React.ComponentType<ContentProps
|
|
144
|
+
export interface CodeHighlighterProps<T extends {}> extends CodeHighlighterBaseProps {
|
|
145
|
+
Content: React.ComponentType<ContentProps<T>>;
|
|
146
|
+
contentProps?: T;
|
|
125
147
|
ErrorHandler?: ErrorHandler;
|
|
126
|
-
ContentLoading?: React.ComponentType<ContentLoadingProps
|
|
148
|
+
ContentLoading?: React.ComponentType<ContentLoadingProps<T>>;
|
|
127
149
|
/**
|
|
128
150
|
* @default 'stream'
|
|
129
151
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC;AAE5D,KAAK,QAAQ,GAAG;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAG7E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,SA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CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;IACvD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeContext.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"CodeContext.d.ts","sourceRoot":"","sources":["../../src/CodeProvider/CodeContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,WAAW,EACX,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,eAAO,MAAM,WAAW,4BAAuC,CAAC;AAEhE,eAAO,MAAM,cAAc,mBAI1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeProvider.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"CodeProvider.d.ts","sourceRoot":"","sources":["../../src/CodeProvider/CodeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAe,MAAM,oBAAoB,CAAC;AAG5F,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,UAAU,GACX,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,2CAmDA"}
|
|
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { createStarryNight } from '@wooorm/starry-night';
|
|
6
6
|
import { CodeContext } from "./CodeContext.js";
|
|
7
|
-
import { extensionMap, grammars } from "../parseSource/grammars.js";
|
|
7
|
+
import { extensionMap, grammars } from "../pipeline/parseSource/grammars.js";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
export function CodeProvider(_ref) {
|
|
10
10
|
var children = _ref.children,
|
|
@@ -24,15 +24,30 @@ export function CodeProvider(_ref) {
|
|
|
24
24
|
}
|
|
25
25
|
return createStarryNight(grammars).then(function (starryNight) {
|
|
26
26
|
var parseSourceFn = function parseSourceFn(source, fileName) {
|
|
27
|
-
var fileType = fileName.slice(fileName.lastIndexOf('.'))
|
|
28
|
-
|
|
27
|
+
var fileType = fileName.slice(fileName.lastIndexOf('.'));
|
|
28
|
+
if (!extensionMap[fileType]) {
|
|
29
|
+
// Return a basic HAST root node with the source text for unsupported file types
|
|
30
|
+
return {
|
|
31
|
+
type: 'root',
|
|
32
|
+
children: [{
|
|
33
|
+
type: 'text',
|
|
34
|
+
value: source
|
|
35
|
+
}]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return starryNight.highlight(source, extensionMap[fileType]);
|
|
29
39
|
};
|
|
30
|
-
|
|
31
|
-
// Update the sync version when available
|
|
32
|
-
setParseSource(parseSourceFn);
|
|
33
40
|
return parseSourceFn;
|
|
34
41
|
});
|
|
35
42
|
}, []);
|
|
43
|
+
React.useEffect(function () {
|
|
44
|
+
// Update the sync version when available
|
|
45
|
+
sourceParser.then(function (parseSourceFn) {
|
|
46
|
+
return setParseSource(function () {
|
|
47
|
+
return parseSourceFn;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}, [sourceParser]);
|
|
36
51
|
var context = React.useMemo(function () {
|
|
37
52
|
return {
|
|
38
53
|
sourceParser: sourceParser,
|
package/CodeProvider/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./CodeProvider.js";
|
|
2
|
-
export * from "./CodeContext.js";
|
|
1
|
+
export * from "./CodeProvider.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/CodeProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/CodeProvider/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./CodeProvider.js";
|
|
2
|
-
export * from "./CodeContext.js";
|
|
1
|
+
export * from "./CodeProvider.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Code, ContentLoadingProps, ContentProps } from "../CodeHighlighter/types.js";
|
|
3
|
+
import { DemoGlobalData } from "../createDemoData/types.js";
|
|
4
|
+
type CreateDemoMeta = {
|
|
5
|
+
name?: string;
|
|
6
|
+
slug?: string;
|
|
7
|
+
displayName?: string;
|
|
8
|
+
skipPrecompute?: boolean;
|
|
9
|
+
precompute?: Code;
|
|
10
|
+
CodeExternalsProvider?: React.ComponentType<{
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
type AbstractCreateDemoOptions<T extends {}> = {
|
|
15
|
+
DemoContent: React.ComponentType<ContentProps<T>>;
|
|
16
|
+
DemoContentLoading?: React.ComponentType<ContentLoadingProps<T>>;
|
|
17
|
+
DemoTitle?: React.ComponentType<{
|
|
18
|
+
slug?: string;
|
|
19
|
+
children?: string;
|
|
20
|
+
}>;
|
|
21
|
+
controlled?: boolean;
|
|
22
|
+
demoGlobalData?: DemoGlobalData[];
|
|
23
|
+
};
|
|
24
|
+
export declare function abstractCreateDemo<T extends {}>(options: AbstractCreateDemoOptions<T>, url: string, variants: {
|
|
25
|
+
[key: string]: React.ComponentType;
|
|
26
|
+
}, meta: CreateDemoMeta | undefined): React.ComponentType<T> & {
|
|
27
|
+
Title: React.ComponentType;
|
|
28
|
+
};
|
|
29
|
+
export declare function createDemoFactory<T extends {}>(options: AbstractCreateDemoOptions<T>): (url: string, component: React.ComponentType, meta?: CreateDemoMeta) => React.ComponentType<T> & {
|
|
30
|
+
Title: React.ComponentType;
|
|
31
|
+
};
|
|
32
|
+
export declare function createDemoWithVariantsFactory<T extends {}>(options: AbstractCreateDemoOptions<T>): (url: string, variants: Record<string, React.ComponentType>, meta?: CreateDemoMeta) => React.ComponentType<T> & {
|
|
33
|
+
Title: React.ComponentType;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractCreateDemo.d.ts","sourceRoot":"","sources":["../../src/abstractCreateDemo/abstractCreateDemo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,IAAI,EAAc,mBAAmB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,KAAK,cAAc,GAAG;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,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AA6B,CAAC,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,yBAAyB,CAAC,CAAC,CAAC,SASxF,MAAM,YACD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,SACtC,cAAc;WAxFY,KAAK,CAAC,aAAa;EA8FvD"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { CodeHighlighter } from "../CodeHighlighter/index.js";
|
|
4
|
+
import { createDemoDataWithVariants } from "../createDemoData/index.js";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
// TODO: allow passing any CodeHighlighter prop
|
|
7
|
+
|
|
8
|
+
export function abstractCreateDemo(options, url, variants, meta) {
|
|
9
|
+
var demoData = createDemoDataWithVariants(url, variants, meta);
|
|
10
|
+
var globalCode = [];
|
|
11
|
+
if (options.demoGlobalData) {
|
|
12
|
+
options.demoGlobalData.forEach(function (data) {
|
|
13
|
+
globalCode.push(data.precompute || data.url);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function DemoComponent(props) {
|
|
17
|
+
var renderedComponents = Object.entries(demoData.components).reduce(function (acc, _ref) {
|
|
18
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
19
|
+
key = _ref2[0],
|
|
20
|
+
Component = _ref2[1];
|
|
21
|
+
acc[key] = /*#__PURE__*/React.createElement(Component);
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
var highlighter = /*#__PURE__*/_jsx(CodeHighlighter, {
|
|
25
|
+
url: demoData.url,
|
|
26
|
+
name: demoData.name,
|
|
27
|
+
slug: demoData.slug,
|
|
28
|
+
precompute: demoData.precompute,
|
|
29
|
+
globalsCode: globalCode,
|
|
30
|
+
components: renderedComponents,
|
|
31
|
+
contentProps: props,
|
|
32
|
+
Content: options.DemoContent,
|
|
33
|
+
ContentLoading: options.DemoContentLoading,
|
|
34
|
+
controlled: options.controlled
|
|
35
|
+
});
|
|
36
|
+
var CodeExternalsProvider = meta == null ? void 0 : meta.CodeExternalsProvider;
|
|
37
|
+
if (CodeExternalsProvider) {
|
|
38
|
+
return /*#__PURE__*/_jsx(CodeExternalsProvider, {
|
|
39
|
+
children: highlighter
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return highlighter;
|
|
43
|
+
}
|
|
44
|
+
function Title() {
|
|
45
|
+
if (options.DemoTitle) {
|
|
46
|
+
return /*#__PURE__*/_jsx(options.DemoTitle, {
|
|
47
|
+
slug: demoData.slug,
|
|
48
|
+
children: demoData.name
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/_jsx("h3", {
|
|
52
|
+
id: demoData.slug,
|
|
53
|
+
children: demoData.name
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
DemoComponent.Title = Title;
|
|
57
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
58
|
+
DemoComponent.displayName = demoData.displayName;
|
|
59
|
+
DemoComponent.Title.displayName = "".concat(demoData.displayName, "Title");
|
|
60
|
+
}
|
|
61
|
+
return DemoComponent;
|
|
62
|
+
}
|
|
63
|
+
export function createDemoFactory(options) {
|
|
64
|
+
/**
|
|
65
|
+
* Creates a demo component for displaying code examples with syntax highlighting.
|
|
66
|
+
* @param url Depends on `import.meta.url` to determine the source file location.
|
|
67
|
+
* @param component The component to be rendered in the demo.
|
|
68
|
+
* @param meta Additional meta for the demo.
|
|
69
|
+
*/
|
|
70
|
+
var createDemo = function createDemo(url, component, meta) {
|
|
71
|
+
return abstractCreateDemo(options, url, {
|
|
72
|
+
Default: component
|
|
73
|
+
},
|
|
74
|
+
// precomputed code will use the 'Default' key
|
|
75
|
+
meta);
|
|
76
|
+
};
|
|
77
|
+
return createDemo;
|
|
78
|
+
}
|
|
79
|
+
export function createDemoWithVariantsFactory(options) {
|
|
80
|
+
/**
|
|
81
|
+
* Creates a demo component for displaying code examples with syntax highlighting.
|
|
82
|
+
* A variant is a different implementation style of the same component.
|
|
83
|
+
* @param url Depends on `import.meta.url` to determine the source file location.
|
|
84
|
+
* @param variants The variants of the component to be rendered in the demo.
|
|
85
|
+
* @param meta Additional meta for the demo.
|
|
86
|
+
*/
|
|
87
|
+
var createDemoWithVariants = function createDemoWithVariants(url, variants, meta) {
|
|
88
|
+
return abstractCreateDemo(options, url, variants, meta);
|
|
89
|
+
};
|
|
90
|
+
return createDemoWithVariants;
|
|
91
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractCreateDemo.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abstractCreateDemo/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractCreateDemo.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CreateDemoDataMeta, DemoData, DemoGlobalData, DemoGlobalProvider } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates demo data for displaying code examples with syntax highlighting.
|
|
4
|
+
* A variant is a different implementation style of the same component.
|
|
5
|
+
* Returns a data object containing demo metadata and components instead of a complete demo component.
|
|
6
|
+
* Note: It is recommended to use abstractCreateDemo to create a complete demo component rather than just demo data.
|
|
7
|
+
* @param url Depends on `import.meta.url` to determine the source file location.
|
|
8
|
+
* @param variants The variants of the component to be rendered in the demo.
|
|
9
|
+
* @param meta Additional meta for the demo.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createDemoDataWithVariants<T extends React.ComponentType<any> = React.ComponentType>(url: string, variants: {
|
|
12
|
+
Default: T;
|
|
13
|
+
} | {
|
|
14
|
+
[key: string]: T;
|
|
15
|
+
}, meta?: CreateDemoDataMeta): DemoData<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates demo data for displaying code examples with syntax highlighting.
|
|
18
|
+
* Returns a data object containing demo metadata and components instead of a complete demo component.
|
|
19
|
+
* Note: It is recommended to use abstractCreateDemo to create a complete demo component rather than just demo data.
|
|
20
|
+
* @param url Depends on `import.meta.url` to determine the source file location.
|
|
21
|
+
* @param component The component to be rendered in the demo.
|
|
22
|
+
* @param meta Additional meta for the demo.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDemoData<T extends React.ComponentType<any> = React.ComponentType>(url: string, component: T, meta?: CreateDemoDataMeta): DemoData<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a demo data object for a global provider component with different variants.
|
|
27
|
+
*
|
|
28
|
+
* @param url The URL of the demo file.
|
|
29
|
+
* @param globalProviders The variants of the global provider to be rendered in the demo.
|
|
30
|
+
* @param meta Additional metadata for the demo data.
|
|
31
|
+
* @returns Demo data object.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createDemoGlobalWithVariants(url: string, globalProviders: {
|
|
34
|
+
[variant: string]: DemoGlobalProvider;
|
|
35
|
+
}, meta?: CreateDemoDataMeta): DemoGlobalData;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a demo data object for a global provider component.
|
|
38
|
+
*
|
|
39
|
+
* @param url The URL of the demo file.
|
|
40
|
+
* @param globalProvider The global provider to be rendered in the demo.
|
|
41
|
+
* @param meta Additional metadata for the demo data.
|
|
42
|
+
* @returns Demo data object.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createDemoGlobal(url: string, globalProvider: DemoGlobalProvider, meta?: CreateDemoDataMeta): DemoGlobalData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDemoData.d.ts","sourceRoot":"","sources":["../../src/createDemoData/createDemoData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE3F;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,EAExD,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,EAC/C,IAAI,CAAC,EAAE,kBAAkB,GACxB,QAAQ,CAAC,CAAC,CAAC,CA8Bb;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,EACrF,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,EACZ,IAAI,CAAC,EAAE,kBAAkB,GACxB,QAAQ,CAAC,CAAC,CAAC,CAEb;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,MAAM,EACX,eAAe,EAAE;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAAA;CAAE,EAC1D,IAAI,CAAC,EAAE,kBAAkB,GACxB,cAAc,CAEhB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,kBAAkB,EAClC,IAAI,CAAC,EAAE,kBAAkB,GACxB,cAAc,CAEhB"}
|