@mui/internal-docs-infra 0.1.1-canary.8 → 0.2.0-alpha.1

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 (217) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +3 -11
  3. package/esm/CodeControllerContext/CodeControllerContext.d.ts +62 -0
  4. package/esm/CodeControllerContext/CodeControllerContext.js +33 -0
  5. package/esm/CodeControllerContext/index.d.ts +1 -0
  6. package/esm/CodeControllerContext/index.js +1 -0
  7. package/esm/CodeExternalsContext/CodeExternalsContext.d.ts +8 -0
  8. package/esm/CodeExternalsContext/CodeExternalsContext.js +8 -0
  9. package/esm/CodeExternalsContext/index.d.ts +1 -0
  10. package/esm/CodeExternalsContext/index.js +1 -0
  11. package/esm/CodeHighlighter/CodeHighlighter.d.ts +2 -0
  12. package/esm/CodeHighlighter/CodeHighlighter.js +441 -0
  13. package/esm/CodeHighlighter/CodeHighlighterClient.d.ts +2 -0
  14. package/esm/CodeHighlighter/CodeHighlighterClient.js +984 -0
  15. package/esm/CodeHighlighter/CodeHighlighterContext.d.ts +16 -0
  16. package/esm/CodeHighlighter/CodeHighlighterContext.js +15 -0
  17. package/esm/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +7 -0
  18. package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +14 -0
  19. package/esm/CodeHighlighter/addPathsToVariant.d.ts +14 -0
  20. package/esm/CodeHighlighter/addPathsToVariant.js +68 -0
  21. package/esm/CodeHighlighter/applyTransform.d.ts +19 -0
  22. package/esm/CodeHighlighter/applyTransform.js +75 -0
  23. package/esm/CodeHighlighter/calculateMainFilePath.d.ts +1 -0
  24. package/esm/CodeHighlighter/calculateMainFilePath.js +108 -0
  25. package/esm/CodeHighlighter/codeToFallbackProps.d.ts +2 -0
  26. package/esm/CodeHighlighter/codeToFallbackProps.js +73 -0
  27. package/esm/CodeHighlighter/errors.d.ts +141 -0
  28. package/esm/CodeHighlighter/errors.js +441 -0
  29. package/esm/CodeHighlighter/examineVariant.d.ts +25 -0
  30. package/esm/CodeHighlighter/examineVariant.js +73 -0
  31. package/esm/CodeHighlighter/hasAllVariants.d.ts +27 -0
  32. package/esm/CodeHighlighter/hasAllVariants.js +63 -0
  33. package/esm/CodeHighlighter/index.d.ts +1 -0
  34. package/esm/CodeHighlighter/index.js +1 -0
  35. package/esm/CodeHighlighter/loadFallbackCode.d.ts +10 -0
  36. package/esm/CodeHighlighter/loadFallbackCode.js +679 -0
  37. package/esm/CodeHighlighter/loadVariant.d.ts +12 -0
  38. package/esm/CodeHighlighter/loadVariant.js +1044 -0
  39. package/esm/CodeHighlighter/maybeInitialData.d.ts +108 -0
  40. package/esm/CodeHighlighter/maybeInitialData.js +192 -0
  41. package/esm/CodeHighlighter/mergeMetadata.d.ts +40 -0
  42. package/esm/CodeHighlighter/mergeMetadata.js +165 -0
  43. package/esm/CodeHighlighter/parseCode.d.ts +6 -0
  44. package/esm/CodeHighlighter/parseCode.js +134 -0
  45. package/esm/CodeHighlighter/parseControlledCode.d.ts +6 -0
  46. package/esm/CodeHighlighter/parseControlledCode.js +87 -0
  47. package/esm/CodeHighlighter/pathUtils.d.ts +120 -0
  48. package/esm/CodeHighlighter/pathUtils.js +258 -0
  49. package/esm/CodeHighlighter/transformCode.d.ts +21 -0
  50. package/esm/CodeHighlighter/transformCode.js +251 -0
  51. package/esm/CodeHighlighter/transformParsedSource.d.ts +3 -0
  52. package/esm/CodeHighlighter/transformParsedSource.js +60 -0
  53. package/esm/CodeHighlighter/transformSource.d.ts +2 -0
  54. package/esm/CodeHighlighter/transformSource.js +103 -0
  55. package/esm/CodeHighlighter/types.d.ts +276 -0
  56. package/esm/CodeHighlighter/types.js +1 -0
  57. package/esm/CodeProvider/CodeContext.d.ts +31 -0
  58. package/esm/CodeProvider/CodeContext.js +12 -0
  59. package/esm/CodeProvider/CodeProvider.d.ts +13 -0
  60. package/esm/CodeProvider/CodeProvider.js +83 -0
  61. package/esm/CodeProvider/index.d.ts +1 -0
  62. package/esm/CodeProvider/index.js +1 -0
  63. package/esm/abstractCreateDemo/abstractCreateDemo.d.ts +45 -0
  64. package/esm/abstractCreateDemo/abstractCreateDemo.js +100 -0
  65. package/esm/abstractCreateDemo/index.d.ts +1 -0
  66. package/esm/abstractCreateDemo/index.js +1 -0
  67. package/esm/abstractCreateDemoClient/abstractCreateDemoClient.d.ts +32 -0
  68. package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +52 -0
  69. package/esm/abstractCreateDemoClient/index.d.ts +1 -0
  70. package/esm/abstractCreateDemoClient/index.js +1 -0
  71. package/esm/createDemoData/createDemoData.d.ts +44 -0
  72. package/esm/createDemoData/createDemoData.js +74 -0
  73. package/esm/createDemoData/index.d.ts +1 -0
  74. package/esm/createDemoData/index.js +1 -0
  75. package/esm/createDemoData/types.d.ts +25 -0
  76. package/esm/createDemoData/types.js +1 -0
  77. package/esm/pipeline/hastUtils/hastUtils.d.ts +11 -0
  78. package/esm/pipeline/hastUtils/hastUtils.js +67 -0
  79. package/esm/pipeline/hastUtils/index.d.ts +1 -0
  80. package/esm/pipeline/hastUtils/index.js +1 -0
  81. package/esm/pipeline/loadPrecomputedCodeHighlighter/index.d.ts +2 -0
  82. package/esm/pipeline/loadPrecomputedCodeHighlighter/index.js +4 -0
  83. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +14 -0
  84. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +178 -0
  85. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +47 -0
  86. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +849 -0
  87. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.d.ts +85 -0
  88. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +715 -0
  89. package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +14 -0
  90. package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +73 -0
  91. package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.d.ts +11 -0
  92. package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +203 -0
  93. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.d.ts +6 -0
  94. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +23 -0
  95. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.d.ts +6 -0
  96. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +148 -0
  97. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.d.ts +9 -0
  98. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +198 -0
  99. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/index.d.ts +2 -0
  100. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/index.js +4 -0
  101. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.d.ts +5 -0
  102. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +21 -0
  103. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.d.ts +15 -0
  104. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +233 -0
  105. package/esm/pipeline/loadServerCodeMeta/index.d.ts +1 -0
  106. package/esm/pipeline/loadServerCodeMeta/index.js +1 -0
  107. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +24 -0
  108. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +90 -0
  109. package/esm/pipeline/loadServerSource/index.d.ts +1 -0
  110. package/esm/pipeline/loadServerSource/index.js +1 -0
  111. package/esm/pipeline/loadServerSource/loadServerSource.d.ts +25 -0
  112. package/esm/pipeline/loadServerSource/loadServerSource.js +134 -0
  113. package/esm/pipeline/loaderUtils/externalsToPackages.d.ts +1 -0
  114. package/esm/pipeline/loaderUtils/externalsToPackages.js +46 -0
  115. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +34 -0
  116. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +161 -0
  117. package/esm/pipeline/loaderUtils/getFileNameFromUrl.d.ts +12 -0
  118. package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +66 -0
  119. package/esm/pipeline/loaderUtils/index.d.ts +7 -0
  120. package/esm/pipeline/loaderUtils/index.js +7 -0
  121. package/esm/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
  122. package/esm/pipeline/loaderUtils/mergeExternals.js +72 -0
  123. package/esm/pipeline/loaderUtils/parseImports.d.ts +19 -0
  124. package/esm/pipeline/loaderUtils/parseImports.js +306 -0
  125. package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +19 -0
  126. package/esm/pipeline/loaderUtils/processRelativeImports.js +352 -0
  127. package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +87 -0
  128. package/esm/pipeline/loaderUtils/resolveModulePath.js +1435 -0
  129. package/esm/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +47 -0
  130. package/esm/pipeline/loaderUtils/resolveModulePathWithFs.js +150 -0
  131. package/esm/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
  132. package/esm/pipeline/loaderUtils/rewriteImports.js +35 -0
  133. package/esm/pipeline/parseSource/addLineGutters.d.ts +9 -0
  134. package/esm/pipeline/parseSource/addLineGutters.js +181 -0
  135. package/esm/pipeline/parseSource/grammars.d.ts +2 -0
  136. package/esm/pipeline/parseSource/grammars.js +27 -0
  137. package/esm/pipeline/parseSource/index.d.ts +1 -0
  138. package/esm/pipeline/parseSource/index.js +1 -0
  139. package/esm/pipeline/parseSource/parseSource.d.ts +3 -0
  140. package/esm/pipeline/parseSource/parseSource.js +51 -0
  141. package/esm/pipeline/transformHtmlCode/index.d.ts +2 -0
  142. package/esm/pipeline/transformHtmlCode/index.js +4 -0
  143. package/esm/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
  144. package/esm/pipeline/transformHtmlCode/transformHtmlCode.js +300 -0
  145. package/esm/pipeline/transformMarkdownCode/index.d.ts +2 -0
  146. package/esm/pipeline/transformMarkdownCode/index.js +4 -0
  147. package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
  148. package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
  149. package/esm/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
  150. package/esm/pipeline/transformTypescriptToJavascript/index.js +1 -0
  151. package/esm/pipeline/transformTypescriptToJavascript/removeTypes.d.ts +13 -0
  152. package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +131 -0
  153. package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
  154. package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +31 -0
  155. package/esm/useCode/Pre.d.ts +15 -0
  156. package/esm/useCode/Pre.js +164 -0
  157. package/esm/useCode/index.d.ts +1 -0
  158. package/esm/useCode/index.js +1 -0
  159. package/esm/useCode/useCode.d.ts +41 -0
  160. package/esm/useCode/useCode.js +128 -0
  161. package/esm/useCode/useCodeUtils.d.ts +44 -0
  162. package/esm/useCode/useCodeUtils.js +245 -0
  163. package/esm/useCode/useCopyFunctionality.d.ts +18 -0
  164. package/esm/useCode/useCopyFunctionality.js +28 -0
  165. package/esm/useCode/useFileNavigation.d.ts +41 -0
  166. package/esm/useCode/useFileNavigation.js +453 -0
  167. package/esm/useCode/useSourceEditing.d.ts +21 -0
  168. package/esm/useCode/useSourceEditing.js +32 -0
  169. package/esm/useCode/useTransformManagement.d.ts +30 -0
  170. package/esm/useCode/useTransformManagement.js +72 -0
  171. package/esm/useCode/useUIState.d.ts +16 -0
  172. package/esm/useCode/useUIState.js +21 -0
  173. package/esm/useCode/useVariantSelection.d.ts +23 -0
  174. package/esm/useCode/useVariantSelection.js +75 -0
  175. package/esm/useCopier/index.d.ts +1 -1
  176. package/esm/useCopier/index.js +5 -5
  177. package/esm/useDemo/createCodeSandbox.d.ts +15 -0
  178. package/esm/useDemo/createCodeSandbox.js +42 -0
  179. package/esm/useDemo/createStackBlitz.d.ts +22 -0
  180. package/esm/useDemo/createStackBlitz.js +38 -0
  181. package/esm/useDemo/exportVariant.d.ts +184 -0
  182. package/esm/useDemo/exportVariant.js +422 -0
  183. package/esm/useDemo/exportVariantAsCra.d.ts +15 -0
  184. package/esm/useDemo/exportVariantAsCra.js +57 -0
  185. package/esm/useDemo/flattenVariant.d.ts +19 -0
  186. package/esm/useDemo/flattenVariant.js +49 -0
  187. package/esm/useDemo/index.d.ts +6 -51
  188. package/esm/useDemo/index.js +6 -104
  189. package/esm/useDemo/useDemo.d.ts +81 -0
  190. package/esm/useDemo/useDemo.js +193 -0
  191. package/esm/useErrors/ErrorsContext.d.ts +6 -0
  192. package/esm/useErrors/ErrorsContext.js +8 -0
  193. package/esm/useErrors/index.d.ts +1 -0
  194. package/esm/useErrors/index.js +1 -0
  195. package/esm/useErrors/useErrors.d.ts +5 -0
  196. package/esm/useErrors/useErrors.js +7 -0
  197. package/esm/useLocalStorageState/index.d.ts +2 -0
  198. package/esm/useLocalStorageState/index.js +2 -0
  199. package/esm/useLocalStorageState/useLocalStorageState.d.ts +14 -0
  200. package/esm/useLocalStorageState/useLocalStorageState.js +128 -0
  201. package/esm/usePreference/PreferencesProvider.d.ts +6 -0
  202. package/esm/usePreference/PreferencesProvider.js +8 -0
  203. package/esm/usePreference/index.d.ts +2 -0
  204. package/esm/usePreference/index.js +2 -0
  205. package/esm/usePreference/usePreference.d.ts +2 -0
  206. package/esm/usePreference/usePreference.js +25 -0
  207. package/esm/useUrlHashState/index.d.ts +1 -0
  208. package/esm/useUrlHashState/index.js +1 -0
  209. package/esm/useUrlHashState/useUrlHashState.d.ts +5 -0
  210. package/esm/useUrlHashState/useUrlHashState.js +68 -0
  211. package/esm/withDocsInfra/index.d.ts +1 -0
  212. package/esm/withDocsInfra/index.js +1 -0
  213. package/esm/withDocsInfra/withDocsInfra.d.ts +82 -0
  214. package/esm/withDocsInfra/withDocsInfra.js +147 -0
  215. package/package.json +178 -11
  216. package/esm/useCopier/index.d.ts.map +0 -1
  217. package/esm/useDemo/index.d.ts.map +0 -1
@@ -0,0 +1,68 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+
5
+ /**
6
+ * Hook for managing URL hash state with SSR support
7
+ * @returns A tuple of [hash, setHash] where hash is the current URL hash (without '#') and setHash updates it
8
+ */
9
+ export function useUrlHashState() {
10
+ // Store the subscriber callback so we can trigger it manually
11
+ var subscriberRef = React.useRef(null);
12
+
13
+ // Subscribe to hash changes
14
+ var subscribe = React.useCallback(function (callback) {
15
+ subscriberRef.current = callback;
16
+ if (typeof window === 'undefined') {
17
+ return function () {
18
+ subscriberRef.current = null;
19
+ };
20
+ }
21
+ window.addEventListener('hashchange', callback);
22
+ return function () {
23
+ window.removeEventListener('hashchange', callback);
24
+ subscriberRef.current = null;
25
+ };
26
+ }, []);
27
+
28
+ // Get current hash value (client-side)
29
+ var getSnapshot = React.useCallback(function () {
30
+ if (typeof window === 'undefined') {
31
+ return null;
32
+ }
33
+ var currentHash = window.location.hash;
34
+ if (!currentHash) {
35
+ return null;
36
+ }
37
+ return currentHash.slice(1); // Remove the '#'
38
+ }, []);
39
+
40
+ // Get server snapshot (always null for SSR)
41
+ var getServerSnapshot = React.useCallback(function () {
42
+ return null;
43
+ }, []);
44
+
45
+ // Use useSyncExternalStore for hash synchronization
46
+ var hash = React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
47
+
48
+ // Set hash in URL and state
49
+ var setHash = React.useCallback(function (value) {
50
+ var replace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
51
+ var newUrl = value ? "".concat(window.location.pathname).concat(window.location.search, "#").concat(value) : "".concat(window.location.pathname).concat(window.location.search);
52
+ // Special case: if value is an empty string (not null), include the hash
53
+ if (value === '') {
54
+ newUrl = "".concat(window.location.pathname).concat(window.location.search, "#");
55
+ }
56
+ if (replace) {
57
+ window.history.replaceState(null, '', newUrl);
58
+ } else {
59
+ window.history.pushState(null, '', newUrl);
60
+ }
61
+
62
+ // Trigger the subscriber to update useSyncExternalStore
63
+ if (subscriberRef.current) {
64
+ subscriberRef.current();
65
+ }
66
+ }, []);
67
+ return [hash, setHash];
68
+ }
@@ -0,0 +1 @@
1
+ export * from "./withDocsInfra.js";
@@ -0,0 +1 @@
1
+ export * from "./withDocsInfra.js";
@@ -0,0 +1,82 @@
1
+ import type { Configuration as WebpackConfig, RuleSetRule } from 'webpack';
2
+ export interface NextConfig {
3
+ pageExtensions?: string[];
4
+ output?: 'export' | 'standalone' | undefined;
5
+ turbopack?: {
6
+ rules?: Record<string, {
7
+ loaders: string[];
8
+ }>;
9
+ };
10
+ webpack?: (config: WebpackConfig, options: WebpackOptions) => WebpackConfig;
11
+ [key: string]: any;
12
+ }
13
+ export interface WebpackOptions {
14
+ buildId: string;
15
+ dev: boolean;
16
+ isServer: boolean;
17
+ nextRuntime?: 'nodejs' | 'edge';
18
+ config: NextConfig;
19
+ defaultLoaders: {
20
+ babel: RuleSetRule;
21
+ };
22
+ }
23
+ export interface WithDocsInfraOptions {
24
+ /**
25
+ * Additional page extensions to support beyond the default docs-infra extensions.
26
+ * Default docs-infra extensions are: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx']
27
+ */
28
+ additionalPageExtensions?: string[];
29
+ /**
30
+ * Whether to enable the export output mode.
31
+ * @default true
32
+ */
33
+ enableExportOutput?: boolean;
34
+ /**
35
+ * Custom demo path pattern for loader rules.
36
+ * @default './app/ ** /demos/ * /index.ts'
37
+ */
38
+ demoPathPattern?: string;
39
+ /**
40
+ * Custom client demo path pattern for loader rules.
41
+ * @default './app/ ** /demos/ * /client.ts'
42
+ */
43
+ clientDemoPathPattern?: string;
44
+ /**
45
+ * Additional demo loader patterns for both Turbopack and Webpack.
46
+ * Each pattern will use the appropriate code highlighter loaders.
47
+ */
48
+ additionalDemoPatterns?: {
49
+ /** Patterns for index files that should use loadPrecomputedCodeHighlighter */
50
+ index?: string[];
51
+ /** Patterns for client files that should use loadPrecomputedCodeHighlighterClient */
52
+ client?: string[];
53
+ };
54
+ /**
55
+ * Additional Turbopack rules to merge with the default docs-infra rules.
56
+ */
57
+ additionalTurbopackRules?: Record<string, {
58
+ loaders: string[];
59
+ }>;
60
+ }
61
+ export interface DocsInfraMdxOptions {
62
+ remarkPlugins?: Array<string | [string, ...any[]]>;
63
+ rehypePlugins?: Array<string | [string, ...any[]]>;
64
+ /**
65
+ * Additional remark plugins to add to the default docs-infra plugins
66
+ */
67
+ additionalRemarkPlugins?: Array<string | [string, ...any[]]>;
68
+ /**
69
+ * Additional rehype plugins to add to the default docs-infra plugins
70
+ */
71
+ additionalRehypePlugins?: Array<string | [string, ...any[]]>;
72
+ }
73
+ /**
74
+ * Get default MDX options for docs-infra
75
+ */
76
+ export declare function getDocsInfraMdxOptions(customOptions?: DocsInfraMdxOptions): DocsInfraMdxOptions;
77
+ /**
78
+ * Next.js plugin for MUI docs infrastructure.
79
+ * Configures webpack loaders, turbopack rules for docs sites.
80
+ * Use getDocsInfraMdxOptions() with createMDX for MDX integration.
81
+ */
82
+ export declare function withDocsInfra(options?: WithDocsInfraOptions): (nextConfig?: NextConfig) => NextConfig;
@@ -0,0 +1,147 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
+ // Define minimal NextConfig type to avoid importing from 'next'
5
+
6
+ // Define webpack options interface based on Next.js webpack function signature
7
+
8
+ /**
9
+ * Get default MDX options for docs-infra
10
+ */
11
+ export function getDocsInfraMdxOptions() {
12
+ var _customOptions$remark, _customOptions$additi, _customOptions$rehype, _customOptions$additi2;
13
+ var customOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14
+ var defaultRemarkPlugins = [['remark-gfm'], ['@mui/internal-docs-infra/pipeline/transformMarkdownCode']];
15
+ var defaultRehypePlugins = [['@mui/internal-docs-infra/pipeline/transformHtmlCode']];
16
+
17
+ // Build final plugin arrays
18
+ var remarkPlugins = (_customOptions$remark = customOptions.remarkPlugins) != null ? _customOptions$remark : [].concat(defaultRemarkPlugins, _toConsumableArray((_customOptions$additi = customOptions.additionalRemarkPlugins) != null ? _customOptions$additi : []));
19
+ var rehypePlugins = (_customOptions$rehype = customOptions.rehypePlugins) != null ? _customOptions$rehype : [].concat(defaultRehypePlugins, _toConsumableArray((_customOptions$additi2 = customOptions.additionalRehypePlugins) != null ? _customOptions$additi2 : []));
20
+ return {
21
+ remarkPlugins: remarkPlugins,
22
+ rehypePlugins: rehypePlugins
23
+ };
24
+ }
25
+
26
+ /**
27
+ * Next.js plugin for MUI docs infrastructure.
28
+ * Configures webpack loaders, turbopack rules for docs sites.
29
+ * Use getDocsInfraMdxOptions() with createMDX for MDX integration.
30
+ */
31
+ export function withDocsInfra() {
32
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33
+ var _options$additionalPa = options.additionalPageExtensions,
34
+ additionalPageExtensions = _options$additionalPa === void 0 ? [] : _options$additionalPa,
35
+ _options$enableExport = options.enableExportOutput,
36
+ enableExportOutput = _options$enableExport === void 0 ? true : _options$enableExport,
37
+ _options$demoPathPatt = options.demoPathPattern,
38
+ demoPathPattern = _options$demoPathPatt === void 0 ? './app/**/demos/*/index.ts' : _options$demoPathPatt,
39
+ _options$clientDemoPa = options.clientDemoPathPattern,
40
+ clientDemoPathPattern = _options$clientDemoPa === void 0 ? './app/**/demos/*/client.ts' : _options$clientDemoPa,
41
+ _options$additionalDe = options.additionalDemoPatterns,
42
+ additionalDemoPatterns = _options$additionalDe === void 0 ? {} : _options$additionalDe,
43
+ _options$additionalTu = options.additionalTurbopackRules,
44
+ additionalTurbopackRules = _options$additionalTu === void 0 ? {} : _options$additionalTu;
45
+ return function () {
46
+ var _nextConfig$turbopack;
47
+ var nextConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
48
+ var basePageExtensions = ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'];
49
+ var pageExtensions = [].concat(basePageExtensions, _toConsumableArray(additionalPageExtensions));
50
+
51
+ // Build Turbopack rules
52
+ var turbopackRules = _defineProperty(_defineProperty({}, demoPathPattern, {
53
+ loaders: ['@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter']
54
+ }), clientDemoPathPattern, {
55
+ loaders: ['@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient']
56
+ });
57
+
58
+ // Add additional demo patterns to Turbopack rules
59
+ if (additionalDemoPatterns.index) {
60
+ additionalDemoPatterns.index.forEach(function (pattern) {
61
+ turbopackRules[pattern] = {
62
+ loaders: ['@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter']
63
+ };
64
+ });
65
+ }
66
+ if (additionalDemoPatterns.client) {
67
+ additionalDemoPatterns.client.forEach(function (pattern) {
68
+ turbopackRules[pattern] = {
69
+ loaders: ['@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient']
70
+ };
71
+ });
72
+ }
73
+
74
+ // Merge with additional turbopack rules
75
+ Object.assign(turbopackRules, additionalTurbopackRules);
76
+ var config = _extends(_extends(_extends({}, nextConfig), {}, {
77
+ pageExtensions: pageExtensions
78
+ }, enableExportOutput && {
79
+ output: 'export'
80
+ }), {}, {
81
+ turbopack: _extends(_extends({}, nextConfig.turbopack), {}, {
82
+ rules: _extends(_extends({}, (_nextConfig$turbopack = nextConfig.turbopack) == null ? void 0 : _nextConfig$turbopack.rules), turbopackRules)
83
+ }),
84
+ webpack: function webpack(webpackConfig, webpackOptions) {
85
+ // Call existing webpack function if it exists
86
+ if (nextConfig.webpack) {
87
+ webpackConfig = nextConfig.webpack(webpackConfig, webpackOptions);
88
+ }
89
+
90
+ // Ensure module and rules exist
91
+ if (!webpackConfig.module) {
92
+ webpackConfig.module = {};
93
+ }
94
+ if (!webpackConfig.module.rules) {
95
+ webpackConfig.module.rules = [];
96
+ }
97
+ var defaultLoaders = webpackOptions.defaultLoaders;
98
+
99
+ // Add loader for demo index files
100
+ webpackConfig.module.rules.push({
101
+ test: new RegExp('/demos/[^/]+/index\\.ts$'),
102
+ use: [defaultLoaders.babel, '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter']
103
+ });
104
+
105
+ // Client files for live demos - processes externals
106
+ webpackConfig.module.rules.push({
107
+ test: new RegExp('/demos/[^/]+/client\\.ts$'),
108
+ use: [defaultLoaders.babel, '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient']
109
+ });
110
+
111
+ // Add webpack rules for additional demo patterns
112
+ if (additionalDemoPatterns.index) {
113
+ additionalDemoPatterns.index.forEach(function (pattern) {
114
+ // Convert Turbopack pattern to webpack regex
115
+ var regexPattern = pattern.replace(/^\.\//, '/') // Remove leading ./
116
+ .replace(/\*\*\//g, 'DOUBLE_STAR_PLACEHOLDER') // Replace **/ with placeholder
117
+ .replace(/\*/g, '[^/]+') // Replace single * with single dir pattern
118
+ .replace(/\./g, '\\.') // Escape dots
119
+ .replace(/DOUBLE_STAR_PLACEHOLDER/g, '(?:[^/]+/)*'); // Replace placeholder with zero or more directories
120
+
121
+ webpackConfig.module.rules.push({
122
+ test: new RegExp("".concat(regexPattern, "$")),
123
+ use: [defaultLoaders.babel, '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighter']
124
+ });
125
+ });
126
+ }
127
+ if (additionalDemoPatterns.client) {
128
+ additionalDemoPatterns.client.forEach(function (pattern) {
129
+ // Convert Turbopack pattern to webpack regex
130
+ var regexPattern = pattern.replace(/^\.\//, '/') // Remove leading ./
131
+ .replace(/\*\*\//g, 'DOUBLE_STAR_PLACEHOLDER') // Replace **/ with placeholder
132
+ .replace(/\*/g, '[^/]+') // Replace single * with single dir pattern
133
+ .replace(/\./g, '\\.') // Escape dots
134
+ .replace(/DOUBLE_STAR_PLACEHOLDER/g, '(?:[^/]+/)*'); // Replace placeholder with zero or more directories
135
+
136
+ webpackConfig.module.rules.push({
137
+ test: new RegExp("".concat(regexPattern, "$")),
138
+ use: [defaultLoaders.babel, '@mui/internal-docs-infra/pipeline/loadPrecomputedCodeHighlighterClient']
139
+ });
140
+ });
141
+ }
142
+ return webpackConfig;
143
+ }
144
+ });
145
+ return config;
146
+ };
147
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.1.1-canary.8",
3
+ "version": "0.2.0-alpha.1",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "keywords": [
@@ -21,13 +21,19 @@
21
21
  },
22
22
  "homepage": "https://github.com/mui/mui-public/tree/master/packages/docs-infra",
23
23
  "dependencies": {
24
- "@babel/runtime": "^7.28.3",
25
- "@types/hast": "^3.0.4",
24
+ "@babel/runtime": "^7.28.4",
25
+ "@babel/standalone": "^7.28.4",
26
+ "@wooorm/starry-night": "^3.8.0",
26
27
  "clipboard-copy": "^4.0.1",
27
- "hast": "^1.0.0",
28
28
  "hast-util-to-jsx-runtime": "^2.3.6",
29
29
  "hast-util-to-text": "^4.0.2",
30
- "kebab-case": "^2.0.2"
30
+ "jsondiffpatch": "^0.7.3",
31
+ "kebab-case": "^2.0.2",
32
+ "lz-string": "^1.5.0",
33
+ "path-module": "^0.1.2",
34
+ "prettier": "^3.5.3",
35
+ "unist-util-visit": "^5.0.0",
36
+ "vscode-oniguruma": "^2.0.1"
31
37
  },
32
38
  "peerDependencies": {
33
39
  "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -43,16 +49,177 @@
43
49
  "access": "public"
44
50
  },
45
51
  "engines": {
46
- "node": ">=14.0.0"
52
+ "node": ">=22.12.0"
47
53
  },
48
- "gitSha": "047f4d73583851e9294109a8991272f47ad999c8",
49
54
  "type": "commonjs",
50
55
  "exports": {
51
56
  "./package.json": "./package.json",
52
- "./*": {
53
- "import": {
54
- "types": "./esm/*/index.d.ts",
55
- "default": "./esm/*/index.js"
57
+ "./abstractCreateDemo": {
58
+ "default": {
59
+ "types": "./esm/abstractCreateDemo/index.d.ts",
60
+ "default": "./esm/abstractCreateDemo/index.js"
61
+ }
62
+ },
63
+ "./abstractCreateDemoClient": {
64
+ "default": {
65
+ "types": "./esm/abstractCreateDemoClient/index.d.ts",
66
+ "default": "./esm/abstractCreateDemoClient/index.js"
67
+ }
68
+ },
69
+ "./CodeControllerContext": {
70
+ "default": {
71
+ "types": "./esm/CodeControllerContext/index.d.ts",
72
+ "default": "./esm/CodeControllerContext/index.js"
73
+ }
74
+ },
75
+ "./CodeExternalsContext": {
76
+ "default": {
77
+ "types": "./esm/CodeExternalsContext/index.d.ts",
78
+ "default": "./esm/CodeExternalsContext/index.js"
79
+ }
80
+ },
81
+ "./CodeHighlighter": {
82
+ "default": {
83
+ "types": "./esm/CodeHighlighter/index.d.ts",
84
+ "default": "./esm/CodeHighlighter/index.js"
85
+ }
86
+ },
87
+ "./CodeHighlighter/types": {
88
+ "default": {
89
+ "types": "./esm/CodeHighlighter/types.d.ts",
90
+ "default": "./esm/CodeHighlighter/types.js"
91
+ }
92
+ },
93
+ "./CodeHighlighter/errors": {
94
+ "default": {
95
+ "types": "./esm/CodeHighlighter/errors.d.ts",
96
+ "default": "./esm/CodeHighlighter/errors.js"
97
+ }
98
+ },
99
+ "./CodeProvider": {
100
+ "default": {
101
+ "types": "./esm/CodeProvider/index.d.ts",
102
+ "default": "./esm/CodeProvider/index.js"
103
+ }
104
+ },
105
+ "./createDemoData": {
106
+ "default": {
107
+ "types": "./esm/createDemoData/index.d.ts",
108
+ "default": "./esm/createDemoData/index.js"
109
+ }
110
+ },
111
+ "./createDemoData/types": {
112
+ "default": {
113
+ "types": "./esm/createDemoData/types.d.ts",
114
+ "default": "./esm/createDemoData/types.js"
115
+ }
116
+ },
117
+ "./useCode": {
118
+ "default": {
119
+ "types": "./esm/useCode/index.d.ts",
120
+ "default": "./esm/useCode/index.js"
121
+ }
122
+ },
123
+ "./useCopier": {
124
+ "default": {
125
+ "types": "./esm/useCopier/index.d.ts",
126
+ "default": "./esm/useCopier/index.js"
127
+ }
128
+ },
129
+ "./useDemo": {
130
+ "default": {
131
+ "types": "./esm/useDemo/index.d.ts",
132
+ "default": "./esm/useDemo/index.js"
133
+ }
134
+ },
135
+ "./useErrors": {
136
+ "default": {
137
+ "types": "./esm/useErrors/index.d.ts",
138
+ "default": "./esm/useErrors/index.js"
139
+ }
140
+ },
141
+ "./useLocalStorageState": {
142
+ "default": {
143
+ "types": "./esm/useLocalStorageState/index.d.ts",
144
+ "default": "./esm/useLocalStorageState/index.js"
145
+ }
146
+ },
147
+ "./usePreference": {
148
+ "default": {
149
+ "types": "./esm/usePreference/index.d.ts",
150
+ "default": "./esm/usePreference/index.js"
151
+ }
152
+ },
153
+ "./useUrlHashState": {
154
+ "default": {
155
+ "types": "./esm/useUrlHashState/index.d.ts",
156
+ "default": "./esm/useUrlHashState/index.js"
157
+ }
158
+ },
159
+ "./withDocsInfra": {
160
+ "default": {
161
+ "types": "./esm/withDocsInfra/index.d.ts",
162
+ "default": "./esm/withDocsInfra/index.js"
163
+ }
164
+ },
165
+ "./pipeline/hastUtils": {
166
+ "default": {
167
+ "types": "./esm/pipeline/hastUtils/index.d.ts",
168
+ "default": "./esm/pipeline/hastUtils/index.js"
169
+ }
170
+ },
171
+ "./pipeline/loaderUtils": {
172
+ "default": {
173
+ "types": "./esm/pipeline/loaderUtils/index.d.ts",
174
+ "default": "./esm/pipeline/loaderUtils/index.js"
175
+ }
176
+ },
177
+ "./pipeline/loadPrecomputedCodeHighlighter": {
178
+ "default": {
179
+ "types": "./esm/pipeline/loadPrecomputedCodeHighlighter/index.d.ts",
180
+ "default": "./esm/pipeline/loadPrecomputedCodeHighlighter/index.js"
181
+ }
182
+ },
183
+ "./pipeline/loadPrecomputedCodeHighlighterClient": {
184
+ "default": {
185
+ "types": "./esm/pipeline/loadPrecomputedCodeHighlighterClient/index.d.ts",
186
+ "default": "./esm/pipeline/loadPrecomputedCodeHighlighterClient/index.js"
187
+ }
188
+ },
189
+ "./pipeline/loadServerCodeMeta": {
190
+ "default": {
191
+ "types": "./esm/pipeline/loadServerCodeMeta/index.d.ts",
192
+ "default": "./esm/pipeline/loadServerCodeMeta/index.js"
193
+ }
194
+ },
195
+ "./pipeline/loadServerSource": {
196
+ "default": {
197
+ "types": "./esm/pipeline/loadServerSource/index.d.ts",
198
+ "default": "./esm/pipeline/loadServerSource/index.js"
199
+ }
200
+ },
201
+ "./pipeline/parseSource": {
202
+ "default": {
203
+ "types": "./esm/pipeline/parseSource/index.d.ts",
204
+ "default": "./esm/pipeline/parseSource/index.js"
205
+ }
206
+ },
207
+ "./pipeline/transformHtmlCode": {
208
+ "default": {
209
+ "types": "./esm/pipeline/transformHtmlCode/index.d.ts",
210
+ "default": "./esm/pipeline/transformHtmlCode/index.js"
211
+ }
212
+ },
213
+ "./pipeline/transformMarkdownCode": {
214
+ "default": {
215
+ "types": "./esm/pipeline/transformMarkdownCode/index.d.ts",
216
+ "default": "./esm/pipeline/transformMarkdownCode/index.js"
217
+ }
218
+ },
219
+ "./pipeline/transformTypescriptToJavascript": {
220
+ "default": {
221
+ "types": "./esm/pipeline/transformTypescriptToJavascript/index.d.ts",
222
+ "default": "./esm/pipeline/transformTypescriptToJavascript/index.js"
56
223
  }
57
224
  },
58
225
  "./esm": null
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../home/runner/work/mui-public/mui-public/packages/docs-infra/src/useCopier/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAC3B,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAC5C,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;AACxE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa;kBAO3E,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC;;EA0BpD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../home/runner/work/mui-public/mui-public/packages/docs-infra/src/useDemo/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAK7B,OAAO,EAAa,aAAa,EAAE,MAAM,cAAc,CAAC;AAExD,KAAK,MAAM,GAAG,KAAK,CAAC;AACpB,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACzC,CAAC;AACF,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAMF,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;EA0ErD"}