@mui/internal-docs-infra 0.2.3-canary.11 → 0.2.3-canary.13

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.
Files changed (60) hide show
  1. package/esm/CodeHighlighter/CodeHighlighter.js +16 -16
  2. package/esm/CodeHighlighter/CodeHighlighterClient.js +33 -33
  3. package/esm/CodeHighlighter/errors.js +3 -3
  4. package/esm/CodeHighlighter/types.d.ts +1 -1
  5. package/esm/CodeProvider/CodeContext.d.ts +4 -4
  6. package/esm/CodeProvider/CodeProvider.js +7 -7
  7. package/esm/{CodeHighlighter/addPathsToVariant.d.ts → pipeline/loadCodeVariant/addCodeVariantPaths.d.ts} +1 -1
  8. package/esm/{CodeHighlighter/applyTransform.d.ts → pipeline/loadCodeVariant/applyCodeTransform.d.ts} +3 -3
  9. package/esm/{CodeHighlighter/applyTransform.js → pipeline/loadCodeVariant/applyCodeTransform.js} +4 -4
  10. package/esm/{CodeHighlighter/transformCode.d.ts → pipeline/loadCodeVariant/computeHastDeltas.d.ts} +9 -5
  11. package/esm/{CodeHighlighter/transformCode.js → pipeline/loadCodeVariant/computeHastDeltas.js} +20 -16
  12. package/esm/pipeline/loadCodeVariant/diffHast.d.ts +3 -0
  13. package/esm/{CodeHighlighter/transformParsedSource.js → pipeline/loadCodeVariant/diffHast.js} +5 -5
  14. package/esm/{CodeHighlighter/examineVariant.d.ts → pipeline/loadCodeVariant/examineCodeVariant.d.ts} +2 -2
  15. package/esm/{CodeHighlighter/examineVariant.js → pipeline/loadCodeVariant/examineCodeVariant.js} +1 -1
  16. package/esm/{useDemo/flattenVariant.d.ts → pipeline/loadCodeVariant/flattenCodeVariant.d.ts} +2 -2
  17. package/esm/{useDemo/flattenVariant.js → pipeline/loadCodeVariant/flattenCodeVariant.js} +3 -3
  18. package/esm/{CodeHighlighter/hasAllVariants.d.ts → pipeline/loadCodeVariant/hasAllCodeVariants.d.ts} +1 -1
  19. package/esm/pipeline/loadCodeVariant/index.d.ts +10 -0
  20. package/esm/pipeline/loadCodeVariant/index.js +17 -0
  21. package/esm/{CodeHighlighter/loadFallbackCode.d.ts → pipeline/loadCodeVariant/loadCodeFallback.d.ts} +2 -2
  22. package/esm/{CodeHighlighter/loadFallbackCode.js → pipeline/loadCodeVariant/loadCodeFallback.js} +16 -16
  23. package/esm/{CodeHighlighter/loadVariant.d.ts → pipeline/loadCodeVariant/loadCodeVariant.d.ts} +2 -2
  24. package/esm/{CodeHighlighter/loadVariant.js → pipeline/loadCodeVariant/loadCodeVariant.js} +11 -11
  25. package/esm/{CodeHighlighter/maybeInitialData.d.ts → pipeline/loadCodeVariant/maybeCodeInitialData.d.ts} +6 -6
  26. package/esm/{CodeHighlighter/maybeInitialData.js → pipeline/loadCodeVariant/maybeCodeInitialData.js} +6 -6
  27. package/esm/{CodeHighlighter/mergeMetadata.d.ts → pipeline/loadCodeVariant/mergeCodeMetadata.d.ts} +3 -3
  28. package/esm/{CodeHighlighter/mergeMetadata.js → pipeline/loadCodeVariant/mergeCodeMetadata.js} +3 -3
  29. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.d.ts +1 -1
  30. package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.d.ts +1 -1
  31. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +7 -7
  32. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +7 -7
  33. package/esm/pipeline/loadServerCodeMeta/index.d.ts +2 -1
  34. package/esm/pipeline/loadServerCodeMeta/index.js +2 -1
  35. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +1 -1
  36. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +2 -2
  37. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.d.ts +1 -1
  38. package/esm/pipeline/{loaderUtils → loadServerCodeMeta}/resolveModulePathWithFs.js +1 -1
  39. package/esm/pipeline/loadServerSource/loadServerSource.js +1 -1
  40. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +2 -2
  41. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +5 -5
  42. package/esm/useCode/useCodeUtils.js +3 -3
  43. package/esm/useDemo/createCodeSandbox.d.ts +1 -1
  44. package/esm/useDemo/createStackBlitz.d.ts +1 -1
  45. package/esm/useDemo/exportVariant.js +13 -11
  46. package/esm/useDemo/index.d.ts +1 -1
  47. package/esm/useDemo/index.js +1 -1
  48. package/esm/useDemo/useDemo.d.ts +3 -3
  49. package/esm/useDemo/useDemo.js +6 -6
  50. package/esm/withDocsInfra/withDeploymentConfig.js +2 -1
  51. package/package.json +8 -2
  52. package/esm/CodeHighlighter/transformParsedSource.d.ts +0 -3
  53. /package/esm/{CodeHighlighter/addPathsToVariant.js → pipeline/loadCodeVariant/addCodeVariantPaths.js} +0 -0
  54. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.d.ts +0 -0
  55. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/calculateMainFilePath.js +0 -0
  56. /package/esm/{CodeHighlighter/hasAllVariants.js → pipeline/loadCodeVariant/hasAllCodeVariants.js} +0 -0
  57. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/parseCode.js +0 -0
  58. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.d.ts +0 -0
  59. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/pathUtils.js +0 -0
  60. /package/esm/{CodeHighlighter → pipeline/loadCodeVariant}/transformSource.js +0 -0
@@ -7,7 +7,7 @@ import { getUrlParts, calculateMaxSourceBackNavigation } from "./pathUtils.js";
7
7
  /**
8
8
  * Create path context for processing files with extended information
9
9
  */
10
- export function createPathContext(variant) {
10
+ export function examineCodeVariant(variant) {
11
11
  var hasMetadata = variant.extraFiles ? Object.values(variant.extraFiles).some(function (file) {
12
12
  return _typeof(file) === 'object' && file.metadata;
13
13
  }) : false;
@@ -3,7 +3,7 @@
3
3
  * Handles relative path resolution and metadata file scoping
4
4
  * Uses addPathsToVariant for the core logic, then flattens the result
5
5
  */
6
- import type { VariantCode } from "../CodeHighlighter/types.js";
6
+ import type { VariantCode } from "../../CodeHighlighter/types.js";
7
7
  export interface FlatFile {
8
8
  source: string;
9
9
  metadata?: boolean;
@@ -16,4 +16,4 @@ export interface FlattenedFiles {
16
16
  * Resolves relative paths and handles metadata file scoping
17
17
  * Uses addPathsToVariant for path resolution logic
18
18
  */
19
- export declare function flattenVariant(variant: VariantCode): FlattenedFiles;
19
+ export declare function flattenCodeVariant(variant: VariantCode): FlattenedFiles;
@@ -5,14 +5,14 @@ import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  * Uses addPathsToVariant for the core logic, then flattens the result
6
6
  */
7
7
 
8
- import { stringOrHastToString } from "../pipeline/hastUtils/index.js";
9
- import { addPathsToVariant } from "../CodeHighlighter/addPathsToVariant.js";
8
+ import { stringOrHastToString } from "../hastUtils/index.js";
9
+ import { addPathsToVariant } from "./addCodeVariantPaths.js";
10
10
  /**
11
11
  * Flatten a VariantCode into a flat files structure
12
12
  * Resolves relative paths and handles metadata file scoping
13
13
  * Uses addPathsToVariant for path resolution logic
14
14
  */
15
- export function flattenVariant(variant) {
15
+ export function flattenCodeVariant(variant) {
16
16
  var result = {};
17
17
 
18
18
  // Use addPathsToVariant to get the structured paths
@@ -1,4 +1,4 @@
1
- import { Code } from "./types.js";
1
+ import { Code } from "../../CodeHighlighter/types.js";
2
2
  /**
3
3
  * Determines if all code variants are fully loaded and ready to render the complete content component.
4
4
  *
@@ -0,0 +1,10 @@
1
+ export * from "./loadCodeVariant.js";
2
+ export * from "./loadCodeFallback.js";
3
+ export * from "./parseCode.js";
4
+ export * from "./flattenCodeVariant.js";
5
+ export * from "./mergeCodeMetadata.js";
6
+ export * from "./examineCodeVariant.js";
7
+ export * from "./maybeCodeInitialData.js";
8
+ export * from "./hasAllCodeVariants.js";
9
+ export * from "./applyCodeTransform.js";
10
+ export * from "./addCodeVariantPaths.js";
@@ -0,0 +1,17 @@
1
+ // Main loading functions
2
+ export * from "./loadCodeVariant.js";
3
+ export * from "./loadCodeFallback.js";
4
+
5
+ // Code processing utilities
6
+ export * from "./parseCode.js";
7
+ export * from "./flattenCodeVariant.js";
8
+ export * from "./mergeCodeMetadata.js";
9
+ export * from "./examineCodeVariant.js";
10
+ export * from "./maybeCodeInitialData.js";
11
+ export * from "./hasAllCodeVariants.js";
12
+
13
+ // Transform utilities
14
+ export * from "./applyCodeTransform.js";
15
+
16
+ // Path utilities (if needed by consumers)
17
+ export * from "./addCodeVariantPaths.js";
@@ -1,4 +1,4 @@
1
- import type { Code, VariantExtraFiles, VariantSource, LoadFallbackCodeOptions } from "./types.js";
1
+ import type { Code, VariantExtraFiles, VariantSource, LoadFallbackCodeOptions } from "../../CodeHighlighter/types.js";
2
2
  export type FallbackVariants = {
3
3
  code: Code;
4
4
  initialFilename: string | undefined;
@@ -7,4 +7,4 @@ export type FallbackVariants = {
7
7
  allFileNames: string[];
8
8
  processedGlobalsCode?: Array<Code>;
9
9
  };
10
- export declare function loadFallbackCode(url: string, initialVariant: string, loaded: Code | undefined, options?: LoadFallbackCodeOptions): Promise<FallbackVariants>;
10
+ export declare function loadCodeFallback(url: string, initialVariant: string, loaded: Code | undefined, options?: LoadFallbackCodeOptions): Promise<FallbackVariants>;
@@ -4,8 +4,8 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  import _regenerator from "@babel/runtime/helpers/esm/regenerator";
6
6
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
- import { loadVariant } from "./loadVariant.js";
8
- import { getFileNameFromUrl } from "../pipeline/loaderUtils/index.js";
7
+ import { loadCodeVariant } from "./loadCodeVariant.js";
8
+ import { getFileNameFromUrl } from "../loaderUtils/index.js";
9
9
 
10
10
  // Helper function to get the source for a specific filename from a variant
11
11
  function getFileSource(_x, _x2, _x3) {
@@ -83,11 +83,11 @@ function _getFileSource() {
83
83
  }));
84
84
  return _getFileSource.apply(this, arguments);
85
85
  }
86
- export function loadFallbackCode(_x4, _x5, _x6) {
87
- return _loadFallbackCode.apply(this, arguments);
86
+ export function loadCodeFallback(_x4, _x5, _x6) {
87
+ return _loadCodeFallback.apply(this, arguments);
88
88
  }
89
- function _loadFallbackCode() {
90
- _loadFallbackCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(url, initialVariant, loaded) {
89
+ function _loadCodeFallback() {
90
+ _loadCodeFallback = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(url, initialVariant, loaded) {
91
91
  var options,
92
92
  shouldHighlight,
93
93
  fallbackUsesExtraFiles,
@@ -120,7 +120,7 @@ function _loadFallbackCode() {
120
120
  _step,
121
121
  codeObj,
122
122
  targetVariant,
123
- _yield$loadVariant,
123
+ _yield$loadCodeVarian,
124
124
  loadedVariant,
125
125
  allFileNames,
126
126
  allVariants,
@@ -449,7 +449,7 @@ function _loadFallbackCode() {
449
449
  }
450
450
  _context4.p = 37;
451
451
  _context4.n = 38;
452
- return loadVariant(url, initialVariant, initial, {
452
+ return loadCodeVariant(url, initialVariant, initial, {
453
453
  sourceParser: sourceParser,
454
454
  loadSource: loadSource,
455
455
  loadVariantMeta: loadVariantMeta,
@@ -464,8 +464,8 @@ function _loadFallbackCode() {
464
464
  output: output
465
465
  });
466
466
  case 38:
467
- _yield$loadVariant = _context4.v;
468
- loadedVariant = _yield$loadVariant.code;
467
+ _yield$loadCodeVarian = _context4.v;
468
+ loadedVariant = _yield$loadCodeVarian.code;
469
469
  // Update the loaded code with the processed variant
470
470
  loaded = _extends(_extends({}, loaded), {}, _defineProperty({}, initialVariant, loadedVariant));
471
471
  initial = loadedVariant;
@@ -474,7 +474,7 @@ function _loadFallbackCode() {
474
474
  case 39:
475
475
  _context4.p = 39;
476
476
  _t0 = _context4.v;
477
- throw new Error("Failed to load initial variant using loadVariant (variant: ".concat(initialVariant, ", url: ").concat(url, "): ").concat(JSON.stringify(_t0)));
477
+ throw new Error("Failed to load initial variant using loadCodeVariant (variant: ".concat(initialVariant, ", url: ").concat(url, "): ").concat(JSON.stringify(_t0)));
478
478
  case 40:
479
479
  // Step 3: Collect all file names
480
480
  allFileNames = new Set();
@@ -508,7 +508,7 @@ function _loadFallbackCode() {
508
508
  variantPromises = allVariants.map(/*#__PURE__*/function () {
509
509
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(variantName) {
510
510
  var _loaded;
511
- var variant, allCode, _yield$loadVariant2, _loadedVariant, fileNames, _t2, _t3;
511
+ var variant, allCode, _yield$loadCodeVarian2, _loadedVariant, fileNames, _t2, _t3;
512
512
  return _regenerator().w(function (_context3) {
513
513
  while (1) switch (_context3.p = _context3.n) {
514
514
  case 0:
@@ -560,7 +560,7 @@ function _loadFallbackCode() {
560
560
  case 6:
561
561
  _context3.p = 6;
562
562
  _context3.n = 7;
563
- return loadVariant(url, variantName, variant, {
563
+ return loadCodeVariant(url, variantName, variant, {
564
564
  sourceParser: sourceParser,
565
565
  loadSource: loadSource,
566
566
  loadVariantMeta: loadVariantMeta,
@@ -592,8 +592,8 @@ function _loadFallbackCode() {
592
592
  }() : undefined
593
593
  });
594
594
  case 7:
595
- _yield$loadVariant2 = _context3.v;
596
- _loadedVariant = _yield$loadVariant2.code;
595
+ _yield$loadCodeVarian2 = _context3.v;
596
+ _loadedVariant = _yield$loadCodeVarian2.code;
597
597
  // Collect file names from this variant
598
598
  fileNames = _loadedVariant.fileName ? [_loadedVariant.fileName] : [];
599
599
  if (_loadedVariant.extraFiles) {
@@ -679,5 +679,5 @@ function _loadFallbackCode() {
679
679
  }
680
680
  }, _callee4, null, [[44, 46], [37, 39], [25, 27], [21, 23], [17, 32], [10, 12], [6, 8], [1, 3]]);
681
681
  }));
682
- return _loadFallbackCode.apply(this, arguments);
682
+ return _loadCodeFallback.apply(this, arguments);
683
683
  }
@@ -1,11 +1,11 @@
1
- import type { VariantCode, LoadVariantOptions, Externals } from "./types.js";
1
+ import type { VariantCode, LoadVariantOptions, Externals } from "../../CodeHighlighter/types.js";
2
2
  /**
3
3
  * Loads a variant with support for recursive extra file loading.
4
4
  * The loadSource function can now return extraFiles that will be loaded recursively.
5
5
  * Supports both relative and absolute paths for extra files.
6
6
  * Uses Promise.all for efficient parallel loading of extra files.
7
7
  */
8
- export declare function loadVariant(url: string | undefined, variantName: string, variant: VariantCode | string | undefined, options?: LoadVariantOptions): Promise<{
8
+ export declare function loadCodeVariant(url: string | undefined, variantName: string, variant: VariantCode | string | undefined, options?: LoadVariantOptions): Promise<{
9
9
  code: VariantCode;
10
10
  dependencies: string[];
11
11
  externals: Externals;
@@ -9,9 +9,9 @@ import * as path from 'path-module';
9
9
  import { compress, strToU8 } from 'fflate';
10
10
  import { encode } from 'uint8-to-base64';
11
11
  import { transformSource } from "./transformSource.js";
12
- import { transformParsedSource } from "./transformParsedSource.js";
13
- import { getFileNameFromUrl } from "../pipeline/loaderUtils/index.js";
14
- import { mergeExternals } from "../pipeline/loaderUtils/mergeExternals.js";
12
+ import { diffHast } from "./diffHast.js";
13
+ import { getFileNameFromUrl } from "../loaderUtils/index.js";
14
+ import { mergeExternals } from "../loaderUtils/mergeExternals.js";
15
15
  function compressAsync(input) {
16
16
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17
17
  return new Promise(function (resolve, reject) {
@@ -344,7 +344,7 @@ function _loadSingleFile() {
344
344
  break;
345
345
  }
346
346
  _context.n = 25;
347
- return transformParsedSource(sourceString, finalSource, normalizePathKey(fileName), finalTransforms, parseSource);
347
+ return diffHast(sourceString, finalSource, normalizePathKey(fileName), finalTransforms, parseSource);
348
348
  case 25:
349
349
  finalTransforms = _context.v;
350
350
  case 26:
@@ -656,11 +656,11 @@ function _loadExtraFiles() {
656
656
  }));
657
657
  return _loadExtraFiles.apply(this, arguments);
658
658
  }
659
- export function loadVariant(_x16, _x17, _x18) {
660
- return _loadVariant.apply(this, arguments);
659
+ export function loadCodeVariant(_x16, _x17, _x18) {
660
+ return _loadCodeVariant.apply(this, arguments);
661
661
  }
662
- function _loadVariant() {
663
- _loadVariant = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url, variantName, variant) {
662
+ function _loadCodeVariant() {
663
+ _loadCodeVariant = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url, variantName, variant) {
664
664
  var options,
665
665
  sourceParser,
666
666
  loadSource,
@@ -734,7 +734,7 @@ function _loadVariant() {
734
734
  }
735
735
  throw new Error("Variant is missing from code: ".concat(variantName));
736
736
  case 1:
737
- sourceParser = options.sourceParser, loadSource = options.loadSource, loadVariantMeta = options.loadVariantMeta, sourceTransformers = options.sourceTransformers, globalsCode = options.globalsCode; // Create a cache for loadSource calls scoped to this loadVariant call
737
+ sourceParser = options.sourceParser, loadSource = options.loadSource, loadVariantMeta = options.loadVariantMeta, sourceTransformers = options.sourceTransformers, globalsCode = options.globalsCode; // Create a cache for loadSource calls scoped to this loadCodeVariant call
738
738
  loadSourceCache = new Map();
739
739
  if (!(typeof variant === 'string')) {
740
740
  _context6.n = 6;
@@ -921,7 +921,7 @@ function _loadVariant() {
921
921
  case 7:
922
922
  _context5.p = 7;
923
923
  _context5.n = 8;
924
- return loadVariant(globalsVariant.url, variantName, globalsVariant, _extends(_extends({}, options), {}, {
924
+ return loadCodeVariant(globalsVariant.url, variantName, globalsVariant, _extends(_extends({}, options), {}, {
925
925
  globalsCode: undefined
926
926
  }) // Prevent infinite recursion
927
927
  );
@@ -1082,5 +1082,5 @@ function _loadVariant() {
1082
1082
  }
1083
1083
  }, _callee5, null, [[3, 5]]);
1084
1084
  }));
1085
- return _loadVariant.apply(this, arguments);
1085
+ return _loadCodeVariant.apply(this, arguments);
1086
1086
  }
@@ -1,4 +1,4 @@
1
- import { Code, VariantExtraFiles, VariantSource } from "./types.js";
1
+ import { Code, VariantExtraFiles, VariantSource } from "../../CodeHighlighter/types.js";
2
2
  /**
3
3
  * Type guard function that determines if we have sufficient data to render a code highlighter
4
4
  * component immediately, or if we need to start loading data first.
@@ -38,7 +38,7 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
38
38
  * more predictable and easier to reason about
39
39
  *
40
40
  * When `initialData: false` is returned, the calling component is responsible for initiating
41
- * asynchronous loading operations (e.g., `loadFallbackCode`, `CodeInitialSourceLoader`).
41
+ * asynchronous loading operations (e.g., `loadCodeFallback`, `CodeInitialSourceLoader`).
42
42
  *
43
43
  * @param variants - Array of all available variant names for this code block (e.g., ['javascript', 'typescript'])
44
44
  * @param variant - The specific variant we want to display (must exist in variants array)
@@ -62,7 +62,7 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
62
62
  * @example
63
63
  * ```typescript
64
64
  * // Server-side: Check if we can render with initial source or need to load fallback
65
- * const { initialData, reason } = maybeInitialData(
65
+ * const { initialData, reason } = maybeCodeInitialData(
66
66
  * variants,
67
67
  * initialKey,
68
68
  * code || props.precompute,
@@ -79,7 +79,7 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
79
79
  *
80
80
  * // Client-side: Check if we need to trigger loading effects
81
81
  * const { initialData, reason } = React.useMemo(() =>
82
- * maybeInitialData(
82
+ * maybeCodeInitialData(
83
83
  * variants,
84
84
  * variantName,
85
85
  * code,
@@ -93,11 +93,11 @@ import { Code, VariantExtraFiles, VariantSource } from "./types.js";
93
93
  * if (initialData || isControlled) {
94
94
  * return; // No loading needed
95
95
  * }
96
- * // Trigger loadFallbackCode...
96
+ * // Trigger loadCodeFallback...
97
97
  * }, [initialData, reason, ...]);
98
98
  * ```
99
99
  */
100
- export declare function maybeInitialData(variants: string[], variant: string, code?: Code, fileName?: string, needsHighlight?: boolean, needsAllFiles?: boolean, needsAllVariants?: boolean): {
100
+ export declare function maybeCodeInitialData(variants: string[], variant: string, code?: Code, fileName?: string, needsHighlight?: boolean, needsAllFiles?: boolean, needsAllVariants?: boolean): {
101
101
  initialData: false | {
102
102
  code: Code;
103
103
  initialFilename: string | undefined;
@@ -1,5 +1,5 @@
1
1
  import _typeof from "@babel/runtime/helpers/esm/typeof";
2
- import { hasAllVariants } from "./hasAllVariants.js";
2
+ import { hasAllVariants } from "./hasAllCodeVariants.js";
3
3
  /**
4
4
  * Type guard function that determines if we have sufficient data to render a code highlighter
5
5
  * component immediately, or if we need to start loading data first.
@@ -39,7 +39,7 @@ import { hasAllVariants } from "./hasAllVariants.js";
39
39
  * more predictable and easier to reason about
40
40
  *
41
41
  * When `initialData: false` is returned, the calling component is responsible for initiating
42
- * asynchronous loading operations (e.g., `loadFallbackCode`, `CodeInitialSourceLoader`).
42
+ * asynchronous loading operations (e.g., `loadCodeFallback`, `CodeInitialSourceLoader`).
43
43
  *
44
44
  * @param variants - Array of all available variant names for this code block (e.g., ['javascript', 'typescript'])
45
45
  * @param variant - The specific variant we want to display (must exist in variants array)
@@ -63,7 +63,7 @@ import { hasAllVariants } from "./hasAllVariants.js";
63
63
  * @example
64
64
  * ```typescript
65
65
  * // Server-side: Check if we can render with initial source or need to load fallback
66
- * const { initialData, reason } = maybeInitialData(
66
+ * const { initialData, reason } = maybeCodeInitialData(
67
67
  * variants,
68
68
  * initialKey,
69
69
  * code || props.precompute,
@@ -80,7 +80,7 @@ import { hasAllVariants } from "./hasAllVariants.js";
80
80
  *
81
81
  * // Client-side: Check if we need to trigger loading effects
82
82
  * const { initialData, reason } = React.useMemo(() =>
83
- * maybeInitialData(
83
+ * maybeCodeInitialData(
84
84
  * variants,
85
85
  * variantName,
86
86
  * code,
@@ -94,11 +94,11 @@ import { hasAllVariants } from "./hasAllVariants.js";
94
94
  * if (initialData || isControlled) {
95
95
  * return; // No loading needed
96
96
  * }
97
- * // Trigger loadFallbackCode...
97
+ * // Trigger loadCodeFallback...
98
98
  * }, [initialData, reason, ...]);
99
99
  * ```
100
100
  */
101
- export function maybeInitialData(variants, variant, code, fileName) {
101
+ export function maybeCodeInitialData(variants, variant, code, fileName) {
102
102
  var needsHighlight = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
103
103
  var needsAllFiles = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
104
104
  var needsAllVariants = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Metadata merging utility for positioning metadata files relative to source files
3
3
  */
4
- import type { VariantCode, VariantExtraFiles } from "./types.js";
4
+ import type { VariantCode, VariantExtraFiles } from "../../CodeHighlighter/types.js";
5
5
  /**
6
6
  * Options for merging metadata files
7
7
  */
@@ -32,9 +32,9 @@ interface MergeMetadataOptions {
32
32
  * @param variant - The variant containing mixed source and metadata files
33
33
  * @returns An object with the cleaned variant and extracted metadata
34
34
  */
35
- export declare function extractMetadata(variant: VariantCode): {
35
+ export declare function extractCodeMetadata(variant: VariantCode): {
36
36
  variant: VariantCode;
37
37
  metadata: VariantExtraFiles;
38
38
  };
39
- export declare function mergeMetadata(variant: VariantCode, metadataFiles?: VariantExtraFiles, options?: MergeMetadataOptions): VariantCode;
39
+ export declare function mergeCodeMetadata(variant: VariantCode, metadataFiles?: VariantExtraFiles, options?: MergeMetadataOptions): VariantCode;
40
40
  export {};
@@ -26,7 +26,7 @@ import { calculateMaxSourceBackNavigation, removeBackNavigationPrefix, buildPath
26
26
  * @param variant - The variant containing mixed source and metadata files
27
27
  * @returns An object with the cleaned variant and extracted metadata
28
28
  */
29
- export function extractMetadata(variant) {
29
+ export function extractCodeMetadata(variant) {
30
30
  var metadataPrefix = variant.metadataPrefix;
31
31
  var extractedMetadata = {};
32
32
  var nonMetadataFiles = {};
@@ -72,7 +72,7 @@ export function extractMetadata(variant) {
72
72
  metadata: extractedMetadata
73
73
  };
74
74
  }
75
- export function mergeMetadata(variant) {
75
+ export function mergeCodeMetadata(variant) {
76
76
  var _options$metadataPref;
77
77
  var metadataFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
78
78
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -87,7 +87,7 @@ export function mergeMetadata(variant) {
87
87
  var existingMetadata = {};
88
88
  if (needsReextraction && variant.extraFiles) {
89
89
  // Extract existing metadata using the old metadataPrefix
90
- var extracted = extractMetadata(variant);
90
+ var extracted = extractCodeMetadata(variant);
91
91
  workingVariant = extracted.variant;
92
92
  existingMetadata = extracted.metadata;
93
93
  }
@@ -1,4 +1,4 @@
1
- import type { Code, ParseSource } from "./types.js";
1
+ import type { Code, ParseSource } from "../../CodeHighlighter/types.js";
2
2
  /**
3
3
  * Pure function to parse code variants and their extraFiles.
4
4
  * Converts string sources to HAST nodes and handles hastJson parsing.
@@ -1,2 +1,2 @@
1
- import type { VariantSource, SourceTransformers, Transforms } from "./types.js";
1
+ import type { VariantSource, SourceTransformers, Transforms } from "../../CodeHighlighter/types.js";
2
2
  export declare function transformSource(source: VariantSource, fileName: string, sourceTransformers: SourceTransformers): Promise<Transforms | undefined>;
@@ -2,13 +2,13 @@ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIt
2
2
  import _regenerator from "@babel/runtime/helpers/esm/regenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
- import { loadVariant } from "../../CodeHighlighter/loadVariant.js";
5
+ import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
6
6
  import { createParseSource } from "../parseSource/index.js";
7
7
  // TODO: re-enable following benchmarking
8
8
  // import { TypescriptToJavascriptTransformer } from '../transformTypescriptToJavascript';
9
9
 
10
10
  import { parseCreateFactoryCall } from "./parseCreateFactoryCall.js";
11
- import { resolveVariantPathsWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
11
+ import { resolveVariantPathsWithFs } from "../loadServerCodeMeta/resolveModulePathWithFs.js";
12
12
  import { replacePrecomputeValue } from "./replacePrecomputeValue.js";
13
13
  import { createLoadServerSource } from "../loadServerSource/index.js";
14
14
  import { getFileNameFromUrl } from "../loaderUtils/index.js";
@@ -73,7 +73,7 @@ function _loadPrecomputedCodeHighlighter() {
73
73
  variantPromises = Array.from(resolvedVariantMap.entries()).map(/*#__PURE__*/function () {
74
74
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
75
75
  var _demoCall$namedExport;
76
- var _ref3, variantName, fileUrl, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadVariant, processedVariant, dependencies, _t;
76
+ var _ref3, variantName, fileUrl, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadCodeVarian, processedVariant, dependencies, _t;
77
77
  return _regenerator().w(function (_context) {
78
78
  while (1) switch (_context.p = _context.n) {
79
79
  case 0:
@@ -99,7 +99,7 @@ function _loadPrecomputedCodeHighlighter() {
99
99
  case 2:
100
100
  _context.p = 2;
101
101
  _context.n = 3;
102
- return loadVariant(fileUrl,
102
+ return loadCodeVariant(fileUrl,
103
103
  // URL for the variant entry point (already includes file://)
104
104
  variantName, variant, {
105
105
  sourceParser: sourceParser,
@@ -113,9 +113,9 @@ function _loadPrecomputedCodeHighlighter() {
113
113
  output: _this.getOptions().output || 'hastGzip'
114
114
  });
115
115
  case 3:
116
- _yield$loadVariant = _context.v;
117
- processedVariant = _yield$loadVariant.code;
118
- dependencies = _yield$loadVariant.dependencies;
116
+ _yield$loadCodeVarian = _context.v;
117
+ processedVariant = _yield$loadCodeVarian.code;
118
+ dependencies = _yield$loadCodeVarian.dependencies;
119
119
  return _context.a(2, {
120
120
  variantName: variantName,
121
121
  variantData: processedVariant,
@@ -7,9 +7,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
7
  import { readFile } from 'fs/promises';
8
8
  import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
9
9
  import { generateResolvedExternals } from "./generateResolvedExternals.js";
10
- import { loadVariant } from "../../CodeHighlighter/loadVariant.js";
10
+ import { loadCodeVariant } from "../loadCodeVariant/loadCodeVariant.js";
11
11
  import { createLoadServerSource } from "../loadServerSource/index.js";
12
- import { resolveVariantPathsWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
12
+ import { resolveVariantPathsWithFs } from "../loadServerCodeMeta/resolveModulePathWithFs.js";
13
13
  import { getFileNameFromUrl } from "../loaderUtils/index.js";
14
14
  import { mergeExternals } from "../loaderUtils/mergeExternals.js";
15
15
  import { filterRuntimeExternals } from "./filterRuntimeExternals.js";
@@ -116,7 +116,7 @@ function _loadPrecomputedCodeHighlighterClient() {
116
116
  variantPromises = Array.from(resolvedVariantMap.entries()).map(/*#__PURE__*/function () {
117
117
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
118
118
  var _indexDemoCall$namedE;
119
- var _ref3, variantName, fileUrl, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadVariant, dependencies, externals, _t;
119
+ var _ref3, variantName, fileUrl, namedExport, variant, _getFileNameFromUrl, fileName, _yield$loadCodeVarian, dependencies, externals, _t;
120
120
  return _regenerator().w(function (_context) {
121
121
  while (1) switch (_context.p = _context.n) {
122
122
  case 0:
@@ -142,7 +142,7 @@ function _loadPrecomputedCodeHighlighterClient() {
142
142
  case 2:
143
143
  _context.p = 2;
144
144
  _context.n = 3;
145
- return loadVariant(fileUrl,
145
+ return loadCodeVariant(fileUrl,
146
146
  // URL for the variant entry point (already includes file://)
147
147
  variantName, variant, {
148
148
  loadSource: loadSource,
@@ -152,9 +152,9 @@ function _loadPrecomputedCodeHighlighterClient() {
152
152
  disableTransforms: true
153
153
  });
154
154
  case 3:
155
- _yield$loadVariant = _context.v;
156
- dependencies = _yield$loadVariant.dependencies;
157
- externals = _yield$loadVariant.externals;
155
+ _yield$loadCodeVarian = _context.v;
156
+ dependencies = _yield$loadCodeVarian.dependencies;
157
+ externals = _yield$loadCodeVarian.externals;
158
158
  return _context.a(2, {
159
159
  variantName: variantName,
160
160
  dependencies: dependencies,
@@ -1 +1,2 @@
1
- export * from "./loadServerCodeMeta.js";
1
+ export * from "./loadServerCodeMeta.js";
2
+ export * from "./resolveModulePathWithFs.js";
@@ -1 +1,2 @@
1
- export * from "./loadServerCodeMeta.js";
1
+ export * from "./loadServerCodeMeta.js";
2
+ export * from "./resolveModulePathWithFs.js";
@@ -16,7 +16,7 @@ export declare const loadServerCodeMeta: LoadCodeMeta;
16
16
  * 3. Returns a Code object mapping variant names to their resolved file URLs
17
17
  *
18
18
  * The actual loading, parsing, and transformation of the variants is handled
19
- * elsewhere by the CodeHighlighter component using loadVariant.
19
+ * elsewhere by the CodeHighlighter component using loadCodeVariant.
20
20
  *
21
21
  * @param options - Configuration options (currently unused)
22
22
  * @returns LoadCodeMeta function that takes a URL and returns Promise<Code>
@@ -2,7 +2,7 @@ import _regenerator from "@babel/runtime/helpers/esm/regenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
4
  import { readFile } from 'node:fs/promises';
5
- import { resolveVariantPathsWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
5
+ import { resolveVariantPathsWithFs } from "./resolveModulePathWithFs.js";
6
6
  import { parseCreateFactoryCall } from "../loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js";
7
7
  import { getFileNameFromUrl } from "../loaderUtils/index.js";
8
8
  /**
@@ -22,7 +22,7 @@ export var loadServerCodeMeta = createLoadServerCodeMeta();
22
22
  * 3. Returns a Code object mapping variant names to their resolved file URLs
23
23
  *
24
24
  * The actual loading, parsing, and transformation of the variants is handled
25
- * elsewhere by the CodeHighlighter component using loadVariant.
25
+ * elsewhere by the CodeHighlighter component using loadCodeVariant.
26
26
  *
27
27
  * @param options - Configuration options (currently unused)
28
28
  * @returns LoadCodeMeta function that takes a URL and returns Promise<Code>
@@ -1,4 +1,4 @@
1
- import { type DirectoryEntry, type DirectoryReader, type ResolveModulePathOptions, type TypeAwareResolveResult } from "./resolveModulePath.js";
1
+ import { type DirectoryEntry, type DirectoryReader, type ResolveModulePathOptions, type TypeAwareResolveResult } from "../loaderUtils/resolveModulePath.js";
2
2
  /**
3
3
  * Resolves a module path using Node.js filesystem APIs.
4
4
  * This is a convenience wrapper around the generic resolveModulePath function.
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  // webpack does not like node: imports
4
4
  // eslint-disable-next-line n/prefer-node-protocol
5
5
  import { readdir } from 'fs/promises';
6
- import { resolveModulePath, resolveModulePaths, resolveImportResult, resolveVariantPaths } from "./resolveModulePath.js";
6
+ import { resolveModulePath, resolveModulePaths, resolveImportResult, resolveVariantPaths } from "../loaderUtils/resolveModulePath.js";
7
7
 
8
8
  /**
9
9
  * Node.js filesystem-based directory reader that converts Dirent objects
@@ -6,7 +6,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
6
  // eslint-disable-next-line n/prefer-node-protocol
7
7
  import { readFile } from 'fs/promises';
8
8
  import { parseImportsAndComments } from "../loaderUtils/index.js";
9
- import { resolveImportResultWithFs } from "../loaderUtils/resolveModulePathWithFs.js";
9
+ import { resolveImportResultWithFs } from "../loadServerCodeMeta/resolveModulePathWithFs.js";
10
10
  import { processRelativeImports } from "../loaderUtils/processRelativeImports.js";
11
11
  import { isJavaScriptModule } from "../loaderUtils/resolveModulePath.js";
12
12
  /**
@@ -1,12 +1,12 @@
1
1
  import type { Plugin } from 'unified';
2
2
  /**
3
- * Rehype plugin that transforms semantic HTML code structures to use loadVariant
3
+ * Rehype plugin that transforms semantic HTML code structures to use loadCodeVariant
4
4
  *
5
5
  * This plugin:
6
6
  * 1. Finds section and dl elements in the HTML AST
7
7
  * 2. Extracts code elements from the semantic structure (figure/dl/dd/pre/code)
8
8
  * 3. Creates variants from multiple code elements or single Default variant
9
- * 4. Uses loadVariant to process each variant
9
+ * 4. Uses loadCodeVariant to process each variant
10
10
  * 5. Stores the combined precompute data on the root element
11
11
  * 6. Clears all code element contents and replaces with error message
12
12
  */