@mui/internal-docs-infra 0.1.1-alpha.14 → 0.1.1-alpha.16
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/package.json
CHANGED
|
@@ -34,8 +34,16 @@ export declare function defaultHtmlTemplate({
|
|
|
34
34
|
export interface ExportConfig {
|
|
35
35
|
/** The title for the demo (used in HTML title and package.json name) */
|
|
36
36
|
title?: string;
|
|
37
|
+
/** Optional prefix to add before the title */
|
|
38
|
+
titlePrefix?: string;
|
|
39
|
+
/** Optional suffix to add after the title */
|
|
40
|
+
titleSuffix?: string;
|
|
37
41
|
/** Description for package.json */
|
|
38
42
|
description?: string;
|
|
43
|
+
/** Optional prefix to add before the description */
|
|
44
|
+
descriptionPrefix?: string;
|
|
45
|
+
/** Optional suffix to add after the description */
|
|
46
|
+
descriptionSuffix?: string;
|
|
39
47
|
/** The variant name/identifier for this specific code variant */
|
|
40
48
|
variantName?: string;
|
|
41
49
|
/**
|
|
@@ -56,11 +64,6 @@ export interface ExportConfig {
|
|
|
56
64
|
* Prefix for code files (e.g., 'src/' for Vite)
|
|
57
65
|
*/
|
|
58
66
|
sourcePrefix?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Whether the framework handles entrypoint and HTML generation (e.g., CRA with webpack)
|
|
61
|
-
* When true, skips generating index.html and entrypoint files
|
|
62
|
-
*/
|
|
63
|
-
frameworkHandlesEntrypoint?: boolean;
|
|
64
67
|
/**
|
|
65
68
|
* Custom HTML template function
|
|
66
69
|
* @example
|
|
@@ -111,6 +114,11 @@ export interface ExportConfig {
|
|
|
111
114
|
extraMetadataFiles?: Record<string, {
|
|
112
115
|
source: string;
|
|
113
116
|
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Whether the framework handles entrypoint and HTML generation (e.g., CRA with webpack)
|
|
119
|
+
* When true, skips generating index.html and entrypoint files
|
|
120
|
+
*/
|
|
121
|
+
frameworkHandlesEntrypoint?: boolean;
|
|
114
122
|
/** Framework-specific files that override default files (index.html, entrypoint, etc.) */
|
|
115
123
|
frameworkFiles?: {
|
|
116
124
|
variant?: VariantCode;
|
|
@@ -138,6 +146,28 @@ export interface ExportConfig {
|
|
|
138
146
|
variant?: VariantCode;
|
|
139
147
|
globals?: VariantExtraFiles;
|
|
140
148
|
} | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Version overrides for core packages (react, react-dom, @types/react, @types/react-dom)
|
|
151
|
+
* @example
|
|
152
|
+
* versions: {
|
|
153
|
+
* '@types/react': '^19',
|
|
154
|
+
* '@types/react-dom': '^19',
|
|
155
|
+
* react: '^19',
|
|
156
|
+
* 'react-dom': '^19',
|
|
157
|
+
* }
|
|
158
|
+
*/
|
|
159
|
+
versions?: Record<string, string>;
|
|
160
|
+
/**
|
|
161
|
+
* Custom dependency resolution function
|
|
162
|
+
* @example
|
|
163
|
+
* resolveDependencies: (packageName, envVars) => {
|
|
164
|
+
* if (packageName === '@mui/material') {
|
|
165
|
+
* return { '@mui/material': 'latest', '@emotion/react': 'latest' };
|
|
166
|
+
* }
|
|
167
|
+
* return { [packageName]: 'latest' };
|
|
168
|
+
* }
|
|
169
|
+
*/
|
|
170
|
+
resolveDependencies?: (packageName: string, envVars?: Record<string, string>) => Record<string, string>;
|
|
141
171
|
}
|
|
142
172
|
/**
|
|
143
173
|
* Export a variant as a standalone project with metadata files properly scoped
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportVariant.d.ts","sourceRoot":"","sources":["../../src/useDemo/exportVariant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"exportVariant.d.ts","sourceRoot":"","sources":["../../src/useDemo/exportVariant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA6B/E;;GAE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,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD;;;OAGG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,0FAA0F;IAC1F,cAAc,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,WAAW,CAAC;QAAC,OAAO,CAAC,EAAE,iBAAiB,CAAA;KAAE,CAAC;IACxE;;;;OAIG;IACH,cAAc,CAAC,EAAE,CACf,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,YAAY,KACjB;QAAE,QAAQ,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,CACjB,OAAO,EAAE,WAAW,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,iBAAiB,KACxB;QAAE,OAAO,CAAC,EAAE,WAAW,CAAC;QAAC,OAAO,CAAC,EAAE,iBAAiB,CAAA;KAAE,GAAG,SAAS,CAAC;IACxE;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,CACpB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,WAAW,EACxB,MAAM,GAAE,YAAiB,GACxB;IAAE,QAAQ,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CA2W7C"}
|
package/useDemo/exportVariant.js
CHANGED
|
@@ -9,6 +9,7 @@ import { externalsToPackages } from "../pipeline/loaderUtils/index.js";
|
|
|
9
9
|
import { getFileNameFromUrl } from "../pipeline/loaderUtils/getFileNameFromUrl.js";
|
|
10
10
|
import { createPathContext } from "../CodeHighlighter/examineVariant.js";
|
|
11
11
|
import { mergeMetadata, extractMetadata } from "../CodeHighlighter/mergeMetadata.js";
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Merges multiple file objects into a single object.
|
|
14
15
|
* Similar to mergeExternals but for file structures.
|
|
@@ -111,8 +112,12 @@ export function exportVariant(variantCode) {
|
|
|
111
112
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
112
113
|
var _config$title = config.title,
|
|
113
114
|
title = _config$title === void 0 ? 'Demo' : _config$title,
|
|
115
|
+
titlePrefix = config.titlePrefix,
|
|
116
|
+
titleSuffix = config.titleSuffix,
|
|
114
117
|
_config$description = config.description,
|
|
115
118
|
description = _config$description === void 0 ? 'Demo created with Vite' : _config$description,
|
|
119
|
+
descriptionPrefix = config.descriptionPrefix,
|
|
120
|
+
descriptionSuffix = config.descriptionSuffix,
|
|
116
121
|
variantName = config.variantName,
|
|
117
122
|
_config$language = config.language,
|
|
118
123
|
language = _config$language === void 0 ? 'en' : _config$language,
|
|
@@ -144,7 +149,14 @@ export function exportVariant(variantCode) {
|
|
|
144
149
|
extraMetadataFiles = _config$extraMetadata === void 0 ? {} : _config$extraMetadata,
|
|
145
150
|
_config$frameworkFile = config.frameworkFiles,
|
|
146
151
|
frameworkFiles = _config$frameworkFile === void 0 ? {} : _config$frameworkFile,
|
|
147
|
-
transformVariant = config.transformVariant
|
|
152
|
+
transformVariant = config.transformVariant,
|
|
153
|
+
_config$versions = config.versions,
|
|
154
|
+
versions = _config$versions === void 0 ? {} : _config$versions,
|
|
155
|
+
resolveDependencies = config.resolveDependencies;
|
|
156
|
+
|
|
157
|
+
// Build final title and description with prefixes and suffixes
|
|
158
|
+
var finalTitle = [titlePrefix, title, titleSuffix].filter(Boolean).join('');
|
|
159
|
+
var finalDescription = [descriptionPrefix, description, descriptionSuffix].filter(Boolean).join('');
|
|
148
160
|
|
|
149
161
|
// Use extractMetadata to properly separate metadata and non-metadata files
|
|
150
162
|
var _extractMetadata = extractMetadata(variantCode),
|
|
@@ -173,12 +185,12 @@ export function exportVariant(variantCode) {
|
|
|
173
185
|
var sourceFilename = getFilenameFromVariant(processedVariantCode);
|
|
174
186
|
|
|
175
187
|
// Get path context to understand navigation
|
|
176
|
-
var pathContext = createPathContext(variantCode);
|
|
188
|
+
var pathContext = createPathContext(variantCode);
|
|
177
189
|
|
|
190
|
+
// Determine if we need to rename the source file
|
|
178
191
|
var ext = useTypescript ? 'tsx' : 'jsx';
|
|
179
192
|
var isSourceFileIndex = sourceFilename === "index.".concat(ext);
|
|
180
|
-
|
|
181
|
-
var isInSrcRoot = pathContext.urlDirectory.length <= 1;
|
|
193
|
+
var hasBackNavigation = pathContext.maxBackNavigation > 0;
|
|
182
194
|
var actualSourceFilename = sourceFilename;
|
|
183
195
|
|
|
184
196
|
// Use urlDirectory to construct the full path from src root
|
|
@@ -186,8 +198,9 @@ export function exportVariant(variantCode) {
|
|
|
186
198
|
var actualRootFile = directoryPath ? "".concat(sourcePrefix).concat(directoryPath, "/").concat(sourceFilename) : "".concat(sourcePrefix).concat(sourceFilename);
|
|
187
199
|
|
|
188
200
|
// If the source file is index.tsx and it's in the src root, we need to rename it
|
|
189
|
-
if (isSourceFileIndex &&
|
|
201
|
+
if (isSourceFileIndex && !hasBackNavigation) {
|
|
190
202
|
actualSourceFilename = generateEntrypointFilename(processedVariantCode.extraFiles || {}, sourceFilename, useTypescript);
|
|
203
|
+
// When renaming due to conflicts, place the file in src root regardless of original location
|
|
191
204
|
actualRootFile = "".concat(sourcePrefix).concat(actualSourceFilename);
|
|
192
205
|
}
|
|
193
206
|
|
|
@@ -197,14 +210,12 @@ export function exportVariant(variantCode) {
|
|
|
197
210
|
|
|
198
211
|
// Get relative import path for the main component
|
|
199
212
|
var importPath;
|
|
200
|
-
if (
|
|
213
|
+
if (!hasBackNavigation) {
|
|
201
214
|
// Component is in src root - import directly
|
|
202
215
|
importPath = getRelativeImportPath(actualSourceFilename);
|
|
203
216
|
} else {
|
|
204
217
|
// Component is in a subdirectory - import with full path from src root
|
|
205
|
-
|
|
206
|
-
var _directoryPath = pathContext.urlDirectory.slice(1).join('/'); // Remove 'src' and join the rest
|
|
207
|
-
var componentPath = _directoryPath ? "".concat(_directoryPath, "/").concat(actualSourceFilename) : actualSourceFilename;
|
|
218
|
+
var componentPath = directoryPath ? "".concat(directoryPath, "/").concat(actualSourceFilename) : actualSourceFilename;
|
|
208
219
|
importPath = "./".concat((componentPath || '').replace(/\.[^.]*$/, '')); // Remove extension
|
|
209
220
|
}
|
|
210
221
|
|
|
@@ -218,7 +229,7 @@ export function exportVariant(variantCode) {
|
|
|
218
229
|
var generatedFiles = {};
|
|
219
230
|
|
|
220
231
|
// Update the variant's fileName if we renamed it
|
|
221
|
-
if (isSourceFileIndex &&
|
|
232
|
+
if (isSourceFileIndex && !hasBackNavigation && actualSourceFilename && actualSourceFilename !== sourceFilename) {
|
|
222
233
|
processedVariantCode.fileName = actualSourceFilename;
|
|
223
234
|
}
|
|
224
235
|
|
|
@@ -226,7 +237,16 @@ export function exportVariant(variantCode) {
|
|
|
226
237
|
var isFramework = 'frameworkFiles' in config;
|
|
227
238
|
var externalPackages = externalsToPackages(processedVariantCode.externals || []);
|
|
228
239
|
var variantDeps = Object.keys(externalPackages).reduce(function (acc, pkg) {
|
|
229
|
-
|
|
240
|
+
// Check if we have a specific version for this package first
|
|
241
|
+
if (versions[pkg]) {
|
|
242
|
+
acc[pkg] = versions[pkg];
|
|
243
|
+
} else if (resolveDependencies) {
|
|
244
|
+
var resolvedDeps = resolveDependencies(pkg);
|
|
245
|
+
Object.assign(acc, resolvedDeps);
|
|
246
|
+
} else {
|
|
247
|
+
// Simple fallback: just use 'latest' for each package
|
|
248
|
+
acc[pkg] = 'latest';
|
|
249
|
+
}
|
|
230
250
|
return acc;
|
|
231
251
|
}, {});
|
|
232
252
|
|
|
@@ -236,9 +256,9 @@ export function exportVariant(variantCode) {
|
|
|
236
256
|
// Generate package.json
|
|
237
257
|
var packageJson = _objectSpread(_objectSpread({
|
|
238
258
|
"private": true,
|
|
239
|
-
name:
|
|
259
|
+
name: finalTitle.toLowerCase().replace(/[^a-z0-9]/g, '-'),
|
|
240
260
|
version: '0.0.0',
|
|
241
|
-
description:
|
|
261
|
+
description: finalDescription
|
|
242
262
|
}, finalPackageType && {
|
|
243
263
|
type: finalPackageType
|
|
244
264
|
}), {}, {
|
|
@@ -249,16 +269,16 @@ export function exportVariant(variantCode) {
|
|
|
249
269
|
preview: 'vite preview'
|
|
250
270
|
}), scripts),
|
|
251
271
|
dependencies: _objectSpread(_objectSpread({
|
|
252
|
-
react: 'latest',
|
|
253
|
-
'react-dom': 'latest'
|
|
272
|
+
react: versions.react || 'latest',
|
|
273
|
+
'react-dom': versions['react-dom'] || 'latest'
|
|
254
274
|
}, variantDeps), dependencies),
|
|
255
275
|
devDependencies: _objectSpread(_objectSpread(_objectSpread({}, !isFramework && {
|
|
256
276
|
'@vitejs/plugin-react': 'latest',
|
|
257
277
|
vite: 'latest'
|
|
258
278
|
}), useTypescript && {
|
|
259
279
|
typescript: 'latest',
|
|
260
|
-
'@types/react': 'latest',
|
|
261
|
-
'@types/react-dom': 'latest'
|
|
280
|
+
'@types/react': versions['@types/react'] || 'latest',
|
|
281
|
+
'@types/react-dom': versions['@types/react-dom'] || 'latest'
|
|
262
282
|
}), devDependencies)
|
|
263
283
|
}, packageJsonFields);
|
|
264
284
|
metadataFiles['package.json'] = {
|
|
@@ -353,16 +373,16 @@ export function exportVariant(variantCode) {
|
|
|
353
373
|
}) : undefined;
|
|
354
374
|
var htmlContent = htmlTemplate ? htmlTemplate({
|
|
355
375
|
language: language,
|
|
356
|
-
title:
|
|
357
|
-
description:
|
|
376
|
+
title: finalTitle,
|
|
377
|
+
description: finalDescription,
|
|
358
378
|
head: headContent,
|
|
359
379
|
entrypoint: entrypoint,
|
|
360
380
|
variant: processedVariantCode,
|
|
361
381
|
variantName: variantName
|
|
362
382
|
}) : defaultHtmlTemplate({
|
|
363
383
|
language: language,
|
|
364
|
-
title:
|
|
365
|
-
description:
|
|
384
|
+
title: finalTitle,
|
|
385
|
+
description: finalDescription,
|
|
366
386
|
head: headContent,
|
|
367
387
|
entrypoint: entrypoint
|
|
368
388
|
});
|