@mui/internal-docs-infra 0.1.1-alpha.13 → 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/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -1
- package/CodeHighlighter/CodeHighlighterClient.js +45 -16
- package/CodeHighlighter/addPathsToVariant.d.ts +18 -0
- package/CodeHighlighter/addPathsToVariant.d.ts.map +1 -0
- package/CodeHighlighter/addPathsToVariant.js +352 -0
- package/{useDemo → CodeHighlighter}/examineVariant.d.ts +1 -1
- package/CodeHighlighter/examineVariant.d.ts.map +1 -0
- package/CodeHighlighter/examineVariant.js +103 -0
- package/CodeHighlighter/mergeMetadata.d.ts +40 -0
- package/CodeHighlighter/mergeMetadata.d.ts.map +1 -0
- package/CodeHighlighter/mergeMetadata.js +189 -0
- package/CodeHighlighter/types.d.ts +3 -0
- package/CodeHighlighter/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/useDemo/exportVariant.d.ts +82 -14
- package/useDemo/exportVariant.d.ts.map +1 -1
- package/useDemo/exportVariant.js +196 -101
- package/useDemo/flattenVariant.d.ts +2 -0
- package/useDemo/flattenVariant.d.ts.map +1 -1
- package/useDemo/flattenVariant.js +19 -178
- package/useDemo/useDemo.d.ts +7 -0
- package/useDemo/useDemo.d.ts.map +1 -1
- package/useDemo/useDemo.js +37 -18
- package/useDemo/examineVariant.d.ts.map +0 -1
- package/useDemo/examineVariant.js +0 -134
package/useDemo/exportVariant.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
/**
|
|
4
4
|
* Export variant functionality to add extra files like package.json, tsconfig, etc.
|
|
5
5
|
* Users can pass configuration options that vary the output here.
|
|
@@ -7,7 +7,38 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
7
7
|
|
|
8
8
|
import { externalsToPackages } from "../pipeline/loaderUtils/index.js";
|
|
9
9
|
import { getFileNameFromUrl } from "../pipeline/loaderUtils/getFileNameFromUrl.js";
|
|
10
|
-
import { createPathContext } from "
|
|
10
|
+
import { createPathContext } from "../CodeHighlighter/examineVariant.js";
|
|
11
|
+
import { mergeMetadata, extractMetadata } from "../CodeHighlighter/mergeMetadata.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Merges multiple file objects into a single object.
|
|
15
|
+
* Similar to mergeExternals but for file structures.
|
|
16
|
+
* Automatically adds metadata: false to files that don't have a metadata property.
|
|
17
|
+
*/
|
|
18
|
+
function mergeFiles() {
|
|
19
|
+
var merged = {};
|
|
20
|
+
for (var _len = arguments.length, fileSets = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
|
+
fileSets[_key] = arguments[_key];
|
|
22
|
+
}
|
|
23
|
+
for (var _i = 0, _fileSets = fileSets; _i < _fileSets.length; _i++) {
|
|
24
|
+
var fileSet = _fileSets[_i];
|
|
25
|
+
for (var _i2 = 0, _Object$entries = Object.entries(fileSet); _i2 < _Object$entries.length; _i2++) {
|
|
26
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
|
|
27
|
+
fileName = _Object$entries$_i[0],
|
|
28
|
+
fileData = _Object$entries$_i[1];
|
|
29
|
+
// Later files override earlier ones (similar to Object.assign behavior)
|
|
30
|
+
var normalizedData = typeof fileData === 'string' ? {
|
|
31
|
+
source: fileData
|
|
32
|
+
} : _objectSpread({}, fileData);
|
|
33
|
+
// Add metadata: false if not already set (source files default to false)
|
|
34
|
+
if (!('metadata' in normalizedData)) {
|
|
35
|
+
normalizedData.metadata = false;
|
|
36
|
+
}
|
|
37
|
+
merged[fileName] = normalizedData;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return merged;
|
|
41
|
+
}
|
|
11
42
|
|
|
12
43
|
/**
|
|
13
44
|
* Extract filename from URL or return undefined if not available
|
|
@@ -30,15 +61,15 @@ export function getFilenameFromVariant(variantCode) {
|
|
|
30
61
|
export function generateEntrypointFilename(existingFiles, sourceFilename, useTypescript) {
|
|
31
62
|
var pathPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
32
63
|
var ext = useTypescript ? 'tsx' : 'jsx';
|
|
33
|
-
var candidates = ["".concat(pathPrefix, "
|
|
64
|
+
var candidates = ["".concat(pathPrefix, "App.").concat(ext), "".concat(pathPrefix, "entrypoint.").concat(ext), "".concat(pathPrefix, "main.").concat(ext)];
|
|
34
65
|
|
|
35
66
|
// If we have a source filename, also try variations
|
|
36
67
|
if (sourceFilename) {
|
|
37
68
|
var baseName = sourceFilename.replace(/\.[^.]*$/, '');
|
|
38
69
|
candidates.push("".concat(pathPrefix).concat(baseName, "-entry.").concat(ext));
|
|
39
70
|
}
|
|
40
|
-
for (var
|
|
41
|
-
var candidate = _candidates[
|
|
71
|
+
for (var _i3 = 0, _candidates = candidates; _i3 < _candidates.length; _i3++) {
|
|
72
|
+
var candidate = _candidates[_i3];
|
|
42
73
|
if (candidate !== "".concat(pathPrefix).concat(sourceFilename) && !existingFiles[candidate]) {
|
|
43
74
|
return candidate;
|
|
44
75
|
}
|
|
@@ -74,17 +105,28 @@ export function defaultHtmlTemplate(_ref) {
|
|
|
74
105
|
return "<!doctype html>\n<html lang=\"".concat(language, "\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>").concat(title, "</title>\n <meta name=\"description\" content=\"").concat(description, "\" />").concat(head ? "\n ".concat(head) : '', "\n </head>\n <body>\n <div id=\"root\"></div>").concat(entrypoint ? "\n <script type=\"module\" src=\"".concat(entrypoint, "\"></script>") : '', "\n </body>\n</html>");
|
|
75
106
|
}
|
|
76
107
|
/**
|
|
77
|
-
* Export a
|
|
78
|
-
* Returns an object with the exported VariantCode and rootPath path
|
|
108
|
+
* Export a variant as a standalone project with metadata files properly scoped
|
|
79
109
|
*/
|
|
80
110
|
export function exportVariant(variantCode) {
|
|
111
|
+
var _frameworkFiles$varia;
|
|
81
112
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
82
113
|
var _config$title = config.title,
|
|
83
114
|
title = _config$title === void 0 ? 'Demo' : _config$title,
|
|
115
|
+
titlePrefix = config.titlePrefix,
|
|
116
|
+
titleSuffix = config.titleSuffix,
|
|
84
117
|
_config$description = config.description,
|
|
85
118
|
description = _config$description === void 0 ? 'Demo created with Vite' : _config$description,
|
|
119
|
+
descriptionPrefix = config.descriptionPrefix,
|
|
120
|
+
descriptionSuffix = config.descriptionSuffix,
|
|
121
|
+
variantName = config.variantName,
|
|
122
|
+
_config$language = config.language,
|
|
123
|
+
language = _config$language === void 0 ? 'en' : _config$language,
|
|
86
124
|
_config$htmlPrefix = config.htmlPrefix,
|
|
87
125
|
htmlPrefix = _config$htmlPrefix === void 0 ? '' : _config$htmlPrefix,
|
|
126
|
+
_config$sourcePrefix = config.sourcePrefix,
|
|
127
|
+
sourcePrefix = _config$sourcePrefix === void 0 ? 'src/' : _config$sourcePrefix,
|
|
128
|
+
_config$assetPrefix = config.assetPrefix,
|
|
129
|
+
assetPrefix = _config$assetPrefix === void 0 ? '' : _config$assetPrefix,
|
|
88
130
|
_config$frameworkHand = config.frameworkHandlesEntrypoint,
|
|
89
131
|
frameworkHandlesEntrypoint = _config$frameworkHand === void 0 ? false : _config$frameworkHand,
|
|
90
132
|
htmlTemplate = config.htmlTemplate,
|
|
@@ -106,7 +148,30 @@ export function exportVariant(variantCode) {
|
|
|
106
148
|
_config$extraMetadata = config.extraMetadataFiles,
|
|
107
149
|
extraMetadataFiles = _config$extraMetadata === void 0 ? {} : _config$extraMetadata,
|
|
108
150
|
_config$frameworkFile = config.frameworkFiles,
|
|
109
|
-
frameworkFiles = _config$frameworkFile === void 0 ? {} : _config$frameworkFile
|
|
151
|
+
frameworkFiles = _config$frameworkFile === void 0 ? {} : _config$frameworkFile,
|
|
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('');
|
|
160
|
+
|
|
161
|
+
// Use extractMetadata to properly separate metadata and non-metadata files
|
|
162
|
+
var _extractMetadata = extractMetadata(variantCode),
|
|
163
|
+
processedVariantCode = _extractMetadata.variant,
|
|
164
|
+
processedGlobals = _extractMetadata.metadata;
|
|
165
|
+
if (transformVariant) {
|
|
166
|
+
var transformed = transformVariant(processedVariantCode, variantName, processedGlobals);
|
|
167
|
+
if (transformed) {
|
|
168
|
+
// Re-extract metadata after transformation
|
|
169
|
+
var result = extractMetadata(transformed.variant || variantCode);
|
|
170
|
+
processedVariantCode = result.variant;
|
|
171
|
+
// Combine metadata from extraction with transformed globals
|
|
172
|
+
processedGlobals = _objectSpread(_objectSpread({}, result.metadata), transformed.globals);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
110
175
|
|
|
111
176
|
// If packageType is explicitly provided (even as undefined), use that value
|
|
112
177
|
var finalPackageType;
|
|
@@ -117,55 +182,82 @@ export function exportVariant(variantCode) {
|
|
|
117
182
|
}
|
|
118
183
|
|
|
119
184
|
// Get existing extraFiles and source filename
|
|
120
|
-
var
|
|
121
|
-
var sourceFilename = getFilenameFromVariant(variantCode);
|
|
185
|
+
var sourceFilename = getFilenameFromVariant(processedVariantCode);
|
|
122
186
|
|
|
123
|
-
// Get path context to
|
|
124
|
-
var pathContext = createPathContext(variantCode);
|
|
187
|
+
// Get path context to understand navigation
|
|
188
|
+
var pathContext = createPathContext(variantCode); // Determine if we need to rename the source file (if it's index.tsx in src dir)
|
|
125
189
|
|
|
126
|
-
|
|
127
|
-
var
|
|
190
|
+
var ext = useTypescript ? 'tsx' : 'jsx';
|
|
191
|
+
var isSourceFileIndex = sourceFilename === "index.".concat(ext);
|
|
192
|
+
// Use urlDirectory to determine if it's in src root (should only have 'src' as the directory)
|
|
193
|
+
var isInSrcRoot = pathContext.urlDirectory.length <= 1;
|
|
194
|
+
var actualSourceFilename = sourceFilename;
|
|
195
|
+
|
|
196
|
+
// Use urlDirectory to construct the full path from src root
|
|
197
|
+
var directoryPath = pathContext.urlDirectory.slice(1).join('/'); // Remove 'src' and join the rest
|
|
198
|
+
var actualRootFile = directoryPath ? "".concat(sourcePrefix).concat(directoryPath, "/").concat(sourceFilename) : "".concat(sourcePrefix).concat(sourceFilename);
|
|
128
199
|
|
|
129
|
-
//
|
|
130
|
-
|
|
200
|
+
// If the source file is index.tsx and it's in the src root, we need to rename it
|
|
201
|
+
if (isSourceFileIndex && isInSrcRoot) {
|
|
202
|
+
actualSourceFilename = generateEntrypointFilename(processedVariantCode.extraFiles || {}, sourceFilename, useTypescript);
|
|
203
|
+
actualRootFile = "".concat(sourcePrefix).concat(actualSourceFilename);
|
|
204
|
+
}
|
|
131
205
|
|
|
132
|
-
//
|
|
133
|
-
var
|
|
206
|
+
// The main entrypoint is always src/index.tsx (or .jsx)
|
|
207
|
+
var mainEntrypointFilename = "index.".concat(ext);
|
|
208
|
+
var entrypoint = "".concat(sourcePrefix).concat(mainEntrypointFilename);
|
|
134
209
|
|
|
135
210
|
// Get relative import path for the main component
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
211
|
+
var importPath;
|
|
212
|
+
if (isInSrcRoot) {
|
|
213
|
+
// Component is in src root - import directly
|
|
214
|
+
importPath = getRelativeImportPath(actualSourceFilename);
|
|
215
|
+
} else {
|
|
216
|
+
// Component is in a subdirectory - import with full path from src root
|
|
217
|
+
var componentPath = directoryPath ? "".concat(directoryPath, "/").concat(actualSourceFilename) : actualSourceFilename;
|
|
218
|
+
importPath = "./".concat((componentPath || '').replace(/\.[^.]*$/, '')); // Remove extension
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Strip /index from the end of import paths since module resolution handles it automatically
|
|
222
|
+
if (importPath.endsWith('/index')) {
|
|
223
|
+
importPath = importPath.slice(0, -6); // Remove '/index'
|
|
224
|
+
}
|
|
225
|
+
var importString = processedVariantCode.namedExport ? "import { ".concat(processedVariantCode.namedExport, " as App } from '").concat(importPath, "';") : "import App from '".concat(importPath, "';");
|
|
226
|
+
|
|
227
|
+
// Collect all files that will be generated
|
|
228
|
+
var generatedFiles = {};
|
|
229
|
+
|
|
230
|
+
// Update the variant's fileName if we renamed it
|
|
231
|
+
if (isSourceFileIndex && isInSrcRoot && actualSourceFilename && actualSourceFilename !== sourceFilename) {
|
|
232
|
+
processedVariantCode.fileName = actualSourceFilename;
|
|
153
233
|
}
|
|
154
234
|
|
|
155
|
-
// Check if
|
|
156
|
-
var isFramework = frameworkFiles
|
|
157
|
-
var externalPackages = externalsToPackages(
|
|
235
|
+
// Check if they're providing their own framework
|
|
236
|
+
var isFramework = 'frameworkFiles' in config;
|
|
237
|
+
var externalPackages = externalsToPackages(processedVariantCode.externals || []);
|
|
158
238
|
var variantDeps = Object.keys(externalPackages).reduce(function (acc, pkg) {
|
|
159
|
-
|
|
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
|
+
}
|
|
160
249
|
return acc;
|
|
161
250
|
}, {});
|
|
162
251
|
|
|
163
|
-
//
|
|
252
|
+
// Collect metadata files to be generated
|
|
253
|
+
var metadataFiles = {};
|
|
254
|
+
|
|
255
|
+
// Generate package.json
|
|
164
256
|
var packageJson = _objectSpread(_objectSpread({
|
|
165
257
|
"private": true,
|
|
166
|
-
name:
|
|
258
|
+
name: finalTitle.toLowerCase().replace(/[^a-z0-9]/g, '-'),
|
|
167
259
|
version: '0.0.0',
|
|
168
|
-
description:
|
|
260
|
+
description: finalDescription
|
|
169
261
|
}, finalPackageType && {
|
|
170
262
|
type: finalPackageType
|
|
171
263
|
}), {}, {
|
|
@@ -176,74 +268,47 @@ export function exportVariant(variantCode) {
|
|
|
176
268
|
preview: 'vite preview'
|
|
177
269
|
}), scripts),
|
|
178
270
|
dependencies: _objectSpread(_objectSpread({
|
|
179
|
-
react: 'latest',
|
|
180
|
-
'react-dom': 'latest'
|
|
271
|
+
react: versions.react || 'latest',
|
|
272
|
+
'react-dom': versions['react-dom'] || 'latest'
|
|
181
273
|
}, variantDeps), dependencies),
|
|
182
274
|
devDependencies: _objectSpread(_objectSpread(_objectSpread({}, !isFramework && {
|
|
183
275
|
'@vitejs/plugin-react': 'latest',
|
|
184
276
|
vite: 'latest'
|
|
185
277
|
}), useTypescript && {
|
|
186
278
|
typescript: 'latest',
|
|
187
|
-
'@types/react': 'latest',
|
|
188
|
-
'@types/react-dom': 'latest'
|
|
279
|
+
'@types/react': versions['@types/react'] || 'latest',
|
|
280
|
+
'@types/react-dom': versions['@types/react-dom'] || 'latest'
|
|
189
281
|
}), devDependencies)
|
|
190
282
|
}, packageJsonFields);
|
|
191
|
-
|
|
192
|
-
source: JSON.stringify(packageJson, null, 2)
|
|
193
|
-
metadata: true
|
|
283
|
+
metadataFiles['package.json'] = {
|
|
284
|
+
source: JSON.stringify(packageJson, null, 2)
|
|
194
285
|
};
|
|
195
286
|
|
|
196
287
|
// Generate entrypoint and HTML files unless framework handles them
|
|
197
288
|
if (!frameworkHandlesEntrypoint) {
|
|
198
|
-
// Add index.html (with configurable prefix for different frameworks)
|
|
199
|
-
var headContent = headTemplate ? headTemplate({
|
|
200
|
-
sourcePrefix: '/src',
|
|
201
|
-
assetPrefix: ''
|
|
202
|
-
}) : undefined;
|
|
203
|
-
var htmlContent = htmlTemplate ? htmlTemplate({
|
|
204
|
-
language: 'en',
|
|
205
|
-
title: title,
|
|
206
|
-
description: description,
|
|
207
|
-
head: headContent,
|
|
208
|
-
entrypoint: entrypoint
|
|
209
|
-
}) : defaultHtmlTemplate({
|
|
210
|
-
language: 'en',
|
|
211
|
-
title: title,
|
|
212
|
-
description: description,
|
|
213
|
-
head: headContent,
|
|
214
|
-
entrypoint: entrypoint
|
|
215
|
-
});
|
|
216
|
-
var htmlFilePath = htmlPrefix ? "".concat(metadataPrefix).concat(htmlPrefix, "index.html") : "".concat(metadataPrefix, "index.html");
|
|
217
|
-
newExtraFiles[htmlFilePath] = {
|
|
218
|
-
source: htmlContent,
|
|
219
|
-
metadata: true
|
|
220
|
-
};
|
|
221
|
-
|
|
222
289
|
// Create entrypoint file that imports the main component
|
|
223
290
|
var defaultEntrypointContent = "import * as React from 'react';\nimport * as ReactDOM from 'react-dom/client';\n".concat(importString, "\n\nReactDOM.createRoot(document.getElementById('root')").concat(useTypescript ? '!' : '', ").render(\n <React.StrictMode>\n <App />\n </React.StrictMode>\n);");
|
|
224
291
|
var entrypointContent = rootIndexTemplate ? rootIndexTemplate({
|
|
225
292
|
importString: importString,
|
|
226
293
|
useTypescript: useTypescript
|
|
227
294
|
}) : defaultEntrypointContent;
|
|
228
|
-
|
|
229
|
-
source: entrypointContent
|
|
230
|
-
metadata: false
|
|
295
|
+
generatedFiles[mainEntrypointFilename] = {
|
|
296
|
+
source: entrypointContent
|
|
231
297
|
};
|
|
232
298
|
}
|
|
233
299
|
|
|
234
300
|
// Add Vite config file only if no framework files (Vite-specific)
|
|
235
301
|
if (!isFramework) {
|
|
236
302
|
var viteConfigContent = "import { defineConfig } from 'vite';\nimport react from '@vitejs/plugin-react';\nimport { externalsToPackages } from '../loaderUtils/externalsToPackages';\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n plugins: [react()],\n define: { 'process.env': {} },\n});";
|
|
237
|
-
|
|
238
|
-
source: viteConfigContent
|
|
239
|
-
metadata: true
|
|
303
|
+
metadataFiles["vite.config.".concat(useTypescript ? 'ts' : 'js')] = {
|
|
304
|
+
source: viteConfigContent
|
|
240
305
|
};
|
|
241
306
|
}
|
|
242
307
|
|
|
243
|
-
// Add TypeScript configuration if requested
|
|
308
|
+
// Add TypeScript configuration if requested
|
|
244
309
|
if (useTypescript) {
|
|
245
310
|
// Check if frameworkFiles already includes a tsconfig
|
|
246
|
-
var hasFrameworkTsConfig = frameworkFiles && Object.keys(frameworkFiles).some(function (fileName) {
|
|
311
|
+
var hasFrameworkTsConfig = (frameworkFiles == null ? void 0 : frameworkFiles.globals) && Object.keys(frameworkFiles.globals).some(function (fileName) {
|
|
247
312
|
return fileName.includes('tsconfig.json') && !fileName.includes('tsconfig.node.json');
|
|
248
313
|
});
|
|
249
314
|
if (!hasFrameworkTsConfig) {
|
|
@@ -272,9 +337,8 @@ export function exportVariant(variantCode) {
|
|
|
272
337
|
path: './tsconfig.node.json'
|
|
273
338
|
}]
|
|
274
339
|
});
|
|
275
|
-
|
|
276
|
-
source: JSON.stringify(defaultTsConfig, null, 2)
|
|
277
|
-
metadata: true
|
|
340
|
+
metadataFiles['tsconfig.json'] = {
|
|
341
|
+
source: JSON.stringify(defaultTsConfig, null, 2)
|
|
278
342
|
};
|
|
279
343
|
}
|
|
280
344
|
|
|
@@ -291,30 +355,61 @@ export function exportVariant(variantCode) {
|
|
|
291
355
|
},
|
|
292
356
|
include: ['vite.config.ts']
|
|
293
357
|
};
|
|
294
|
-
|
|
295
|
-
source: JSON.stringify(nodeTsConfig, null, 2)
|
|
296
|
-
metadata: true
|
|
358
|
+
metadataFiles['tsconfig.node.json'] = {
|
|
359
|
+
source: JSON.stringify(nodeTsConfig, null, 2)
|
|
297
360
|
};
|
|
298
361
|
}
|
|
299
362
|
}
|
|
300
363
|
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
var
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
364
|
+
// Generate HTML file after all files are ready
|
|
365
|
+
if (!frameworkHandlesEntrypoint) {
|
|
366
|
+
// Add index.html
|
|
367
|
+
var headContent = headTemplate ? headTemplate({
|
|
368
|
+
sourcePrefix: sourcePrefix,
|
|
369
|
+
assetPrefix: assetPrefix,
|
|
370
|
+
variant: processedVariantCode,
|
|
371
|
+
variantName: variantName
|
|
372
|
+
}) : undefined;
|
|
373
|
+
var htmlContent = htmlTemplate ? htmlTemplate({
|
|
374
|
+
language: language,
|
|
375
|
+
title: finalTitle,
|
|
376
|
+
description: finalDescription,
|
|
377
|
+
head: headContent,
|
|
378
|
+
entrypoint: entrypoint,
|
|
379
|
+
variant: processedVariantCode,
|
|
380
|
+
variantName: variantName
|
|
381
|
+
}) : defaultHtmlTemplate({
|
|
382
|
+
language: language,
|
|
383
|
+
title: finalTitle,
|
|
384
|
+
description: finalDescription,
|
|
385
|
+
head: headContent,
|
|
386
|
+
entrypoint: entrypoint
|
|
387
|
+
});
|
|
388
|
+
var htmlFileName = htmlPrefix ? "".concat(htmlPrefix, "index.html") : 'index.html';
|
|
389
|
+
metadataFiles[htmlFileName] = {
|
|
390
|
+
source: htmlContent
|
|
310
391
|
};
|
|
311
392
|
}
|
|
312
393
|
|
|
313
|
-
//
|
|
394
|
+
// Merge all metadata files including framework metadata and globals
|
|
395
|
+
var allMetadataFiles = mergeFiles(processedGlobals || {}, metadataFiles, extraMetadataFiles, frameworkFiles.globals || {});
|
|
396
|
+
|
|
397
|
+
// Merge all files using mergeMetadata to properly position everything with 'src/' (sourcePrefix opt) prefix
|
|
398
|
+
var allSourceFilesWithFramework = mergeFiles(processedVariantCode.extraFiles || {}, generatedFiles, ((_frameworkFiles$varia = frameworkFiles.variant) == null ? void 0 : _frameworkFiles$varia.extraFiles) || {});
|
|
399
|
+
|
|
400
|
+
// Update the variant with all source files including framework source files
|
|
401
|
+
var finalVariantWithSources = _objectSpread(_objectSpread({}, processedVariantCode), {}, {
|
|
402
|
+
extraFiles: allSourceFilesWithFramework
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// Use mergeMetadata to position everything correctly
|
|
406
|
+
var finalVariant = mergeMetadata(finalVariantWithSources, allMetadataFiles, {
|
|
407
|
+
metadataPrefix: sourcePrefix
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
// Return new VariantCode with properly positioned files
|
|
314
411
|
return {
|
|
315
|
-
exported:
|
|
316
|
-
|
|
317
|
-
}),
|
|
318
|
-
rootFile: rootFile
|
|
412
|
+
exported: finalVariant,
|
|
413
|
+
rootFile: actualRootFile
|
|
319
414
|
};
|
|
320
415
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flatten variant utility to convert a VariantCode into a flat files list
|
|
3
3
|
* Handles relative path resolution and metadata file scoping
|
|
4
|
+
* Uses addPathsToVariant for the core logic, then flattens the result
|
|
4
5
|
*/
|
|
5
6
|
import type { VariantCode } from "../CodeHighlighter/types.js";
|
|
6
7
|
export interface FlatFile {
|
|
@@ -13,5 +14,6 @@ export interface FlattenedFiles {
|
|
|
13
14
|
/**
|
|
14
15
|
* Flatten a VariantCode into a flat files structure
|
|
15
16
|
* Resolves relative paths and handles metadata file scoping
|
|
17
|
+
* Uses addPathsToVariant for path resolution logic
|
|
16
18
|
*/
|
|
17
19
|
export declare function flattenVariant(variant: VariantCode): FlattenedFiles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenVariant.d.ts","sourceRoot":"","sources":["../../src/useDemo/flattenVariant.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"flattenVariant.d.ts","sourceRoot":"","sources":["../../src/useDemo/flattenVariant.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAI3E,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CA6BnE"}
|