@mui/internal-docs-infra 0.1.1-alpha.14 → 0.1.1-alpha.15
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,CA0W7C"}
|
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),
|
|
@@ -202,9 +214,7 @@ export function exportVariant(variantCode) {
|
|
|
202
214
|
importPath = getRelativeImportPath(actualSourceFilename);
|
|
203
215
|
} else {
|
|
204
216
|
// 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;
|
|
217
|
+
var componentPath = directoryPath ? "".concat(directoryPath, "/").concat(actualSourceFilename) : actualSourceFilename;
|
|
208
218
|
importPath = "./".concat((componentPath || '').replace(/\.[^.]*$/, '')); // Remove extension
|
|
209
219
|
}
|
|
210
220
|
|
|
@@ -226,7 +236,16 @@ export function exportVariant(variantCode) {
|
|
|
226
236
|
var isFramework = 'frameworkFiles' in config;
|
|
227
237
|
var externalPackages = externalsToPackages(processedVariantCode.externals || []);
|
|
228
238
|
var variantDeps = Object.keys(externalPackages).reduce(function (acc, pkg) {
|
|
229
|
-
|
|
239
|
+
// Check if we have a specific version for this package first
|
|
240
|
+
if (versions[pkg]) {
|
|
241
|
+
acc[pkg] = versions[pkg];
|
|
242
|
+
} else if (resolveDependencies) {
|
|
243
|
+
var resolvedDeps = resolveDependencies(pkg);
|
|
244
|
+
Object.assign(acc, resolvedDeps);
|
|
245
|
+
} else {
|
|
246
|
+
// Simple fallback: just use 'latest' for each package
|
|
247
|
+
acc[pkg] = 'latest';
|
|
248
|
+
}
|
|
230
249
|
return acc;
|
|
231
250
|
}, {});
|
|
232
251
|
|
|
@@ -236,9 +255,9 @@ export function exportVariant(variantCode) {
|
|
|
236
255
|
// Generate package.json
|
|
237
256
|
var packageJson = _objectSpread(_objectSpread({
|
|
238
257
|
"private": true,
|
|
239
|
-
name:
|
|
258
|
+
name: finalTitle.toLowerCase().replace(/[^a-z0-9]/g, '-'),
|
|
240
259
|
version: '0.0.0',
|
|
241
|
-
description:
|
|
260
|
+
description: finalDescription
|
|
242
261
|
}, finalPackageType && {
|
|
243
262
|
type: finalPackageType
|
|
244
263
|
}), {}, {
|
|
@@ -249,16 +268,16 @@ export function exportVariant(variantCode) {
|
|
|
249
268
|
preview: 'vite preview'
|
|
250
269
|
}), scripts),
|
|
251
270
|
dependencies: _objectSpread(_objectSpread({
|
|
252
|
-
react: 'latest',
|
|
253
|
-
'react-dom': 'latest'
|
|
271
|
+
react: versions.react || 'latest',
|
|
272
|
+
'react-dom': versions['react-dom'] || 'latest'
|
|
254
273
|
}, variantDeps), dependencies),
|
|
255
274
|
devDependencies: _objectSpread(_objectSpread(_objectSpread({}, !isFramework && {
|
|
256
275
|
'@vitejs/plugin-react': 'latest',
|
|
257
276
|
vite: 'latest'
|
|
258
277
|
}), useTypescript && {
|
|
259
278
|
typescript: 'latest',
|
|
260
|
-
'@types/react': 'latest',
|
|
261
|
-
'@types/react-dom': 'latest'
|
|
279
|
+
'@types/react': versions['@types/react'] || 'latest',
|
|
280
|
+
'@types/react-dom': versions['@types/react-dom'] || 'latest'
|
|
262
281
|
}), devDependencies)
|
|
263
282
|
}, packageJsonFields);
|
|
264
283
|
metadataFiles['package.json'] = {
|
|
@@ -353,16 +372,16 @@ export function exportVariant(variantCode) {
|
|
|
353
372
|
}) : undefined;
|
|
354
373
|
var htmlContent = htmlTemplate ? htmlTemplate({
|
|
355
374
|
language: language,
|
|
356
|
-
title:
|
|
357
|
-
description:
|
|
375
|
+
title: finalTitle,
|
|
376
|
+
description: finalDescription,
|
|
358
377
|
head: headContent,
|
|
359
378
|
entrypoint: entrypoint,
|
|
360
379
|
variant: processedVariantCode,
|
|
361
380
|
variantName: variantName
|
|
362
381
|
}) : defaultHtmlTemplate({
|
|
363
382
|
language: language,
|
|
364
|
-
title:
|
|
365
|
-
description:
|
|
383
|
+
title: finalTitle,
|
|
384
|
+
description: finalDescription,
|
|
366
385
|
head: headContent,
|
|
367
386
|
entrypoint: entrypoint
|
|
368
387
|
});
|