@mui/internal-docs-infra 0.1.1-canary.9 → 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.
- package/CHANGELOG.md +9 -0
- package/README.md +3 -11
- package/esm/CodeControllerContext/CodeControllerContext.d.ts +62 -0
- package/esm/CodeControllerContext/CodeControllerContext.js +33 -0
- package/esm/CodeControllerContext/index.d.ts +1 -0
- package/esm/CodeControllerContext/index.js +1 -0
- package/esm/CodeExternalsContext/CodeExternalsContext.d.ts +8 -0
- package/esm/CodeExternalsContext/CodeExternalsContext.js +8 -0
- package/esm/CodeExternalsContext/index.d.ts +1 -0
- package/esm/CodeExternalsContext/index.js +1 -0
- package/esm/CodeHighlighter/CodeHighlighter.d.ts +2 -0
- package/esm/CodeHighlighter/CodeHighlighter.js +441 -0
- package/esm/CodeHighlighter/CodeHighlighterClient.d.ts +2 -0
- package/esm/CodeHighlighter/CodeHighlighterClient.js +984 -0
- package/esm/CodeHighlighter/CodeHighlighterContext.d.ts +16 -0
- package/esm/CodeHighlighter/CodeHighlighterContext.js +15 -0
- package/esm/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +7 -0
- package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +14 -0
- package/esm/CodeHighlighter/addPathsToVariant.d.ts +14 -0
- package/esm/CodeHighlighter/addPathsToVariant.js +68 -0
- package/esm/CodeHighlighter/applyTransform.d.ts +19 -0
- package/esm/CodeHighlighter/applyTransform.js +75 -0
- package/esm/CodeHighlighter/calculateMainFilePath.d.ts +1 -0
- package/esm/CodeHighlighter/calculateMainFilePath.js +108 -0
- package/esm/CodeHighlighter/codeToFallbackProps.d.ts +2 -0
- package/esm/CodeHighlighter/codeToFallbackProps.js +73 -0
- package/esm/CodeHighlighter/errors.d.ts +141 -0
- package/esm/CodeHighlighter/errors.js +441 -0
- package/esm/CodeHighlighter/examineVariant.d.ts +25 -0
- package/esm/CodeHighlighter/examineVariant.js +73 -0
- package/esm/CodeHighlighter/hasAllVariants.d.ts +27 -0
- package/esm/CodeHighlighter/hasAllVariants.js +63 -0
- package/esm/CodeHighlighter/index.d.ts +1 -0
- package/esm/CodeHighlighter/index.js +1 -0
- package/esm/CodeHighlighter/loadFallbackCode.d.ts +10 -0
- package/esm/CodeHighlighter/loadFallbackCode.js +679 -0
- package/esm/CodeHighlighter/loadVariant.d.ts +12 -0
- package/esm/CodeHighlighter/loadVariant.js +1044 -0
- package/esm/CodeHighlighter/maybeInitialData.d.ts +108 -0
- package/esm/CodeHighlighter/maybeInitialData.js +192 -0
- package/esm/CodeHighlighter/mergeMetadata.d.ts +40 -0
- package/esm/CodeHighlighter/mergeMetadata.js +165 -0
- package/esm/CodeHighlighter/parseCode.d.ts +6 -0
- package/esm/CodeHighlighter/parseCode.js +134 -0
- package/esm/CodeHighlighter/parseControlledCode.d.ts +6 -0
- package/esm/CodeHighlighter/parseControlledCode.js +87 -0
- package/esm/CodeHighlighter/pathUtils.d.ts +120 -0
- package/esm/CodeHighlighter/pathUtils.js +258 -0
- package/esm/CodeHighlighter/transformCode.d.ts +21 -0
- package/esm/CodeHighlighter/transformCode.js +251 -0
- package/esm/CodeHighlighter/transformParsedSource.d.ts +3 -0
- package/esm/CodeHighlighter/transformParsedSource.js +60 -0
- package/esm/CodeHighlighter/transformSource.d.ts +2 -0
- package/esm/CodeHighlighter/transformSource.js +103 -0
- package/esm/CodeHighlighter/types.d.ts +276 -0
- package/esm/CodeHighlighter/types.js +1 -0
- package/esm/CodeProvider/CodeContext.d.ts +31 -0
- package/esm/CodeProvider/CodeContext.js +12 -0
- package/esm/CodeProvider/CodeProvider.d.ts +13 -0
- package/esm/CodeProvider/CodeProvider.js +83 -0
- package/esm/CodeProvider/index.d.ts +1 -0
- package/esm/CodeProvider/index.js +1 -0
- package/esm/abstractCreateDemo/abstractCreateDemo.d.ts +45 -0
- package/esm/abstractCreateDemo/abstractCreateDemo.js +100 -0
- package/esm/abstractCreateDemo/index.d.ts +1 -0
- package/esm/abstractCreateDemo/index.js +1 -0
- package/esm/abstractCreateDemoClient/abstractCreateDemoClient.d.ts +32 -0
- package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +52 -0
- package/esm/abstractCreateDemoClient/index.d.ts +1 -0
- package/esm/abstractCreateDemoClient/index.js +1 -0
- package/esm/createDemoData/createDemoData.d.ts +44 -0
- package/esm/createDemoData/createDemoData.js +74 -0
- package/esm/createDemoData/index.d.ts +1 -0
- package/esm/createDemoData/index.js +1 -0
- package/esm/createDemoData/types.d.ts +25 -0
- package/esm/createDemoData/types.js +1 -0
- package/esm/pipeline/hastUtils/hastUtils.d.ts +11 -0
- package/esm/pipeline/hastUtils/hastUtils.js +67 -0
- package/esm/pipeline/hastUtils/index.d.ts +1 -0
- package/esm/pipeline/hastUtils/index.js +1 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/index.d.ts +2 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/index.js +4 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +14 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +178 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +47 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +849 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.d.ts +85 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +715 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +14 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +73 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.d.ts +11 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +203 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.d.ts +6 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +23 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.d.ts +6 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +148 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.d.ts +9 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +198 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/index.d.ts +2 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/index.js +4 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.d.ts +5 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +21 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.d.ts +15 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +233 -0
- package/esm/pipeline/loadServerCodeMeta/index.d.ts +1 -0
- package/esm/pipeline/loadServerCodeMeta/index.js +1 -0
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +24 -0
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +90 -0
- package/esm/pipeline/loadServerSource/index.d.ts +1 -0
- package/esm/pipeline/loadServerSource/index.js +1 -0
- package/esm/pipeline/loadServerSource/loadServerSource.d.ts +25 -0
- package/esm/pipeline/loadServerSource/loadServerSource.js +134 -0
- package/esm/pipeline/loaderUtils/externalsToPackages.d.ts +1 -0
- package/esm/pipeline/loaderUtils/externalsToPackages.js +46 -0
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +34 -0
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +161 -0
- package/esm/pipeline/loaderUtils/getFileNameFromUrl.d.ts +12 -0
- package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +66 -0
- package/esm/pipeline/loaderUtils/index.d.ts +7 -0
- package/esm/pipeline/loaderUtils/index.js +7 -0
- package/esm/pipeline/loaderUtils/mergeExternals.d.ts +32 -0
- package/esm/pipeline/loaderUtils/mergeExternals.js +72 -0
- package/esm/pipeline/loaderUtils/parseImports.d.ts +19 -0
- package/esm/pipeline/loaderUtils/parseImports.js +306 -0
- package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +19 -0
- package/esm/pipeline/loaderUtils/processRelativeImports.js +352 -0
- package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +87 -0
- package/esm/pipeline/loaderUtils/resolveModulePath.js +1435 -0
- package/esm/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +47 -0
- package/esm/pipeline/loaderUtils/resolveModulePathWithFs.js +150 -0
- package/esm/pipeline/loaderUtils/rewriteImports.d.ts +9 -0
- package/esm/pipeline/loaderUtils/rewriteImports.js +35 -0
- package/esm/pipeline/parseSource/addLineGutters.d.ts +9 -0
- package/esm/pipeline/parseSource/addLineGutters.js +181 -0
- package/esm/pipeline/parseSource/grammars.d.ts +2 -0
- package/esm/pipeline/parseSource/grammars.js +27 -0
- package/esm/pipeline/parseSource/index.d.ts +1 -0
- package/esm/pipeline/parseSource/index.js +1 -0
- package/esm/pipeline/parseSource/parseSource.d.ts +3 -0
- package/esm/pipeline/parseSource/parseSource.js +51 -0
- package/esm/pipeline/transformHtmlCode/index.d.ts +2 -0
- package/esm/pipeline/transformHtmlCode/index.js +4 -0
- package/esm/pipeline/transformHtmlCode/transformHtmlCode.d.ts +13 -0
- package/esm/pipeline/transformHtmlCode/transformHtmlCode.js +300 -0
- package/esm/pipeline/transformMarkdownCode/index.d.ts +2 -0
- package/esm/pipeline/transformMarkdownCode/index.js +4 -0
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +2 -0
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +514 -0
- package/esm/pipeline/transformTypescriptToJavascript/index.d.ts +1 -0
- package/esm/pipeline/transformTypescriptToJavascript/index.js +1 -0
- package/esm/pipeline/transformTypescriptToJavascript/removeTypes.d.ts +13 -0
- package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +131 -0
- package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +3 -0
- package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +31 -0
- package/esm/useCode/Pre.d.ts +15 -0
- package/esm/useCode/Pre.js +164 -0
- package/esm/useCode/index.d.ts +1 -0
- package/esm/useCode/index.js +1 -0
- package/esm/useCode/useCode.d.ts +41 -0
- package/esm/useCode/useCode.js +128 -0
- package/esm/useCode/useCodeUtils.d.ts +44 -0
- package/esm/useCode/useCodeUtils.js +245 -0
- package/esm/useCode/useCopyFunctionality.d.ts +18 -0
- package/esm/useCode/useCopyFunctionality.js +28 -0
- package/esm/useCode/useFileNavigation.d.ts +41 -0
- package/esm/useCode/useFileNavigation.js +453 -0
- package/esm/useCode/useSourceEditing.d.ts +21 -0
- package/esm/useCode/useSourceEditing.js +32 -0
- package/esm/useCode/useTransformManagement.d.ts +30 -0
- package/esm/useCode/useTransformManagement.js +72 -0
- package/esm/useCode/useUIState.d.ts +16 -0
- package/esm/useCode/useUIState.js +21 -0
- package/esm/useCode/useVariantSelection.d.ts +23 -0
- package/esm/useCode/useVariantSelection.js +75 -0
- package/esm/useCopier/index.d.ts +1 -1
- package/esm/useCopier/index.js +5 -5
- package/esm/useDemo/createCodeSandbox.d.ts +15 -0
- package/esm/useDemo/createCodeSandbox.js +42 -0
- package/esm/useDemo/createStackBlitz.d.ts +22 -0
- package/esm/useDemo/createStackBlitz.js +38 -0
- package/esm/useDemo/exportVariant.d.ts +184 -0
- package/esm/useDemo/exportVariant.js +422 -0
- package/esm/useDemo/exportVariantAsCra.d.ts +15 -0
- package/esm/useDemo/exportVariantAsCra.js +57 -0
- package/esm/useDemo/flattenVariant.d.ts +19 -0
- package/esm/useDemo/flattenVariant.js +49 -0
- package/esm/useDemo/index.d.ts +6 -51
- package/esm/useDemo/index.js +6 -104
- package/esm/useDemo/useDemo.d.ts +81 -0
- package/esm/useDemo/useDemo.js +193 -0
- package/esm/useErrors/ErrorsContext.d.ts +6 -0
- package/esm/useErrors/ErrorsContext.js +8 -0
- package/esm/useErrors/index.d.ts +1 -0
- package/esm/useErrors/index.js +1 -0
- package/esm/useErrors/useErrors.d.ts +5 -0
- package/esm/useErrors/useErrors.js +7 -0
- package/esm/useLocalStorageState/index.d.ts +2 -0
- package/esm/useLocalStorageState/index.js +2 -0
- package/esm/useLocalStorageState/useLocalStorageState.d.ts +14 -0
- package/esm/useLocalStorageState/useLocalStorageState.js +128 -0
- package/esm/usePreference/PreferencesProvider.d.ts +6 -0
- package/esm/usePreference/PreferencesProvider.js +8 -0
- package/esm/usePreference/index.d.ts +2 -0
- package/esm/usePreference/index.js +2 -0
- package/esm/usePreference/usePreference.d.ts +2 -0
- package/esm/usePreference/usePreference.js +25 -0
- package/esm/useUrlHashState/index.d.ts +1 -0
- package/esm/useUrlHashState/index.js +1 -0
- package/esm/useUrlHashState/useUrlHashState.d.ts +5 -0
- package/esm/useUrlHashState/useUrlHashState.js +68 -0
- package/esm/withDocsInfra/index.d.ts +1 -0
- package/esm/withDocsInfra/index.js +1 -0
- package/esm/withDocsInfra/withDocsInfra.d.ts +82 -0
- package/esm/withDocsInfra/withDocsInfra.js +147 -0
- package/package.json +178 -11
- package/esm/useCopier/index.d.ts.map +0 -1
- package/esm/useDemo/index.d.ts.map +0 -1
|
@@ -0,0 +1,1044 @@
|
|
|
1
|
+
import _regeneratorValues from "@babel/runtime/helpers/esm/regeneratorValues";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
5
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
6
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
7
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
8
|
+
import * as path from 'path-module';
|
|
9
|
+
import { transformSource } from "./transformSource.js";
|
|
10
|
+
import { transformParsedSource } from "./transformParsedSource.js";
|
|
11
|
+
import { getFileNameFromUrl } from "../pipeline/loaderUtils/index.js";
|
|
12
|
+
import { mergeExternals } from "../pipeline/loaderUtils/mergeExternals.js";
|
|
13
|
+
/**
|
|
14
|
+
* Check if a path is absolute (either filesystem absolute or URL)
|
|
15
|
+
*/
|
|
16
|
+
function isAbsolutePath(filePath) {
|
|
17
|
+
return path.isAbsolute(filePath) || filePath.includes('://');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generate a conflict-free filename for globalsCode files.
|
|
22
|
+
* Strategy:
|
|
23
|
+
* 1. Try original filename
|
|
24
|
+
* 2. If conflict, try "global_" prefix
|
|
25
|
+
* 3. If still conflict, add numbers: "global_filename_1.ext", "global_filename_2.ext", etc.
|
|
26
|
+
*/
|
|
27
|
+
function generateConflictFreeFilename(originalFilename, existingFiles) {
|
|
28
|
+
// First try the original filename
|
|
29
|
+
if (!existingFiles.has(originalFilename)) {
|
|
30
|
+
return originalFilename;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Try with global_ prefix
|
|
34
|
+
var globalFilename = "global_".concat(originalFilename);
|
|
35
|
+
if (!existingFiles.has(globalFilename)) {
|
|
36
|
+
return globalFilename;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Use path.parse to cleanly split filename into name and extension
|
|
40
|
+
var parsed = path.parse(originalFilename);
|
|
41
|
+
var nameWithoutExt = parsed.name;
|
|
42
|
+
var extension = parsed.ext;
|
|
43
|
+
|
|
44
|
+
// Add numbers until we find a free name, preserving extension
|
|
45
|
+
var counter = 1;
|
|
46
|
+
var candidateName;
|
|
47
|
+
do {
|
|
48
|
+
candidateName = "global_".concat(nameWithoutExt, "_").concat(counter).concat(extension);
|
|
49
|
+
counter += 1;
|
|
50
|
+
} while (existingFiles.has(candidateName));
|
|
51
|
+
return candidateName;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Helper function to check if we're in production
|
|
55
|
+
function isProduction() {
|
|
56
|
+
return typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Helper function to convert a nested key based on the directory of the source file key
|
|
60
|
+
function convertKeyBasedOnDirectory(nestedKey, sourceFileKey) {
|
|
61
|
+
// If it's an absolute path (starts with / or contains ://), keep as-is
|
|
62
|
+
if (isAbsolutePath(nestedKey)) {
|
|
63
|
+
return nestedKey;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Treat bare filenames as relative to current directory (same as ./filename)
|
|
67
|
+
var processedNestedKey = nestedKey;
|
|
68
|
+
if (!nestedKey.startsWith('.')) {
|
|
69
|
+
processedNestedKey = "./".concat(nestedKey);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Use path module for clean path resolution
|
|
73
|
+
var sourceDir = path.dirname(sourceFileKey);
|
|
74
|
+
var resolvedPath = path.resolve(sourceDir, processedNestedKey);
|
|
75
|
+
|
|
76
|
+
// Convert back to relative path from current directory
|
|
77
|
+
var result = path.relative('.', resolvedPath);
|
|
78
|
+
|
|
79
|
+
// Return empty string if result is '.' (current directory)
|
|
80
|
+
return result === '.' ? '' : result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Normalize a relative path key by removing unnecessary ./ prefix and cleaning up the path
|
|
85
|
+
*/
|
|
86
|
+
function normalizePathKey(key) {
|
|
87
|
+
// Handle edge cases
|
|
88
|
+
if (key === '.' || key === '') {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Use path.normalize to clean up the path, then remove leading './' if present
|
|
93
|
+
var normalized = path.normalize(key);
|
|
94
|
+
|
|
95
|
+
// Convert './filename' to 'filename' using path.relative
|
|
96
|
+
if (normalized.startsWith('./')) {
|
|
97
|
+
return path.relative('.', normalized);
|
|
98
|
+
}
|
|
99
|
+
return normalized === '.' ? '' : normalized;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Loads and processes extra files recursively with support for relative paths
|
|
104
|
+
* and circular dependency detection. Uses Promise.all for parallel loading.
|
|
105
|
+
*/
|
|
106
|
+
function loadSingleFile(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
|
|
107
|
+
return _loadSingleFile.apply(this, arguments);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Loads and processes extra files recursively with support for relative paths
|
|
111
|
+
* and circular dependency detection. Uses Promise.all for parallel loading.
|
|
112
|
+
*/
|
|
113
|
+
function _loadSingleFile() {
|
|
114
|
+
_loadSingleFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(variantName, fileName, source, url, loadSource, sourceParser, sourceTransformers, loadSourceCache, transforms) {
|
|
115
|
+
var options,
|
|
116
|
+
allFilesListed,
|
|
117
|
+
knownExtraFiles,
|
|
118
|
+
_options$disableTrans,
|
|
119
|
+
disableTransforms,
|
|
120
|
+
_options$disableParsi,
|
|
121
|
+
disableParsing,
|
|
122
|
+
finalSource,
|
|
123
|
+
extraFilesFromSource,
|
|
124
|
+
extraDependenciesFromSource,
|
|
125
|
+
externalsFromSource,
|
|
126
|
+
loadPromise,
|
|
127
|
+
loadResult,
|
|
128
|
+
_i,
|
|
129
|
+
_Object$entries,
|
|
130
|
+
_Object$entries$_i,
|
|
131
|
+
extraFileName,
|
|
132
|
+
fileData,
|
|
133
|
+
_iterator,
|
|
134
|
+
_step,
|
|
135
|
+
dependency,
|
|
136
|
+
newFiles,
|
|
137
|
+
_i2,
|
|
138
|
+
_Object$keys,
|
|
139
|
+
extraFileKey,
|
|
140
|
+
message,
|
|
141
|
+
finalTransforms,
|
|
142
|
+
sourceString,
|
|
143
|
+
parseSource,
|
|
144
|
+
_args = arguments,
|
|
145
|
+
_t,
|
|
146
|
+
_t2,
|
|
147
|
+
_t3;
|
|
148
|
+
return _regenerator().w(function (_context) {
|
|
149
|
+
while (1) switch (_context.p = _context.n) {
|
|
150
|
+
case 0:
|
|
151
|
+
options = _args.length > 9 && _args[9] !== undefined ? _args[9] : {};
|
|
152
|
+
allFilesListed = _args.length > 10 && _args[10] !== undefined ? _args[10] : false;
|
|
153
|
+
knownExtraFiles = _args.length > 11 && _args[11] !== undefined ? _args[11] : new Set();
|
|
154
|
+
_options$disableTrans = options.disableTransforms, disableTransforms = _options$disableTrans === void 0 ? false : _options$disableTrans, _options$disableParsi = options.disableParsing, disableParsing = _options$disableParsi === void 0 ? false : _options$disableParsi;
|
|
155
|
+
finalSource = source;
|
|
156
|
+
if (finalSource) {
|
|
157
|
+
_context.n = 20;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
if (loadSource) {
|
|
161
|
+
_context.n = 1;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
throw new Error('"loadSource" function is required when source is not provided');
|
|
165
|
+
case 1:
|
|
166
|
+
if (url) {
|
|
167
|
+
_context.n = 2;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
throw new Error('URL is required when loading source');
|
|
171
|
+
case 2:
|
|
172
|
+
_context.p = 2;
|
|
173
|
+
// Check cache first to avoid duplicate loadSource calls
|
|
174
|
+
loadPromise = loadSourceCache.get(url);
|
|
175
|
+
if (!loadPromise) {
|
|
176
|
+
loadPromise = loadSource(url);
|
|
177
|
+
loadSourceCache.set(url, loadPromise);
|
|
178
|
+
}
|
|
179
|
+
_context.n = 3;
|
|
180
|
+
return loadPromise;
|
|
181
|
+
case 3:
|
|
182
|
+
loadResult = _context.v;
|
|
183
|
+
finalSource = loadResult.source;
|
|
184
|
+
extraFilesFromSource = loadResult.extraFiles;
|
|
185
|
+
extraDependenciesFromSource = loadResult.extraDependencies;
|
|
186
|
+
externalsFromSource = loadResult.externals;
|
|
187
|
+
|
|
188
|
+
// Validate that extraFiles from loadSource contain only absolute URLs as values
|
|
189
|
+
if (!extraFilesFromSource) {
|
|
190
|
+
_context.n = 7;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
_i = 0, _Object$entries = Object.entries(extraFilesFromSource);
|
|
194
|
+
case 4:
|
|
195
|
+
if (!(_i < _Object$entries.length)) {
|
|
196
|
+
_context.n = 7;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), extraFileName = _Object$entries$_i[0], fileData = _Object$entries$_i[1];
|
|
200
|
+
if (!isAbsolutePath(extraFileName)) {
|
|
201
|
+
_context.n = 5;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
throw new Error("Invalid extraFiles from loadSource: key \"".concat(extraFileName, "\" appears to be an absolute path. ") + "extraFiles keys should be relative paths from the current file.");
|
|
205
|
+
case 5:
|
|
206
|
+
if (!(typeof fileData === 'string' && fileData.startsWith('.'))) {
|
|
207
|
+
_context.n = 6;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
throw new Error("Invalid extraFiles from loadSource: \"".concat(extraFileName, "\" has relative path \"").concat(fileData, "\". ") + "All extraFiles values must be absolute URLs.");
|
|
211
|
+
case 6:
|
|
212
|
+
_i++;
|
|
213
|
+
_context.n = 4;
|
|
214
|
+
break;
|
|
215
|
+
case 7:
|
|
216
|
+
if (!extraDependenciesFromSource) {
|
|
217
|
+
_context.n = 15;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
_iterator = _createForOfIteratorHelper(extraDependenciesFromSource);
|
|
221
|
+
_context.p = 8;
|
|
222
|
+
_iterator.s();
|
|
223
|
+
case 9:
|
|
224
|
+
if ((_step = _iterator.n()).done) {
|
|
225
|
+
_context.n = 12;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
dependency = _step.value;
|
|
229
|
+
if (!dependency.startsWith('.')) {
|
|
230
|
+
_context.n = 10;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
throw new Error("Invalid extraDependencies from loadSource: \"".concat(dependency, "\" is a relative path. ") + "All extraDependencies must be absolute URLs.");
|
|
234
|
+
case 10:
|
|
235
|
+
if (!(dependency === url)) {
|
|
236
|
+
_context.n = 11;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
throw new Error("Invalid extraDependencies from loadSource: \"".concat(dependency, "\" is the same as the input URL. ") + "extraDependencies should not include the file being loaded.");
|
|
240
|
+
case 11:
|
|
241
|
+
_context.n = 9;
|
|
242
|
+
break;
|
|
243
|
+
case 12:
|
|
244
|
+
_context.n = 14;
|
|
245
|
+
break;
|
|
246
|
+
case 13:
|
|
247
|
+
_context.p = 13;
|
|
248
|
+
_t = _context.v;
|
|
249
|
+
_iterator.e(_t);
|
|
250
|
+
case 14:
|
|
251
|
+
_context.p = 14;
|
|
252
|
+
_iterator.f();
|
|
253
|
+
return _context.f(14);
|
|
254
|
+
case 15:
|
|
255
|
+
if (!(allFilesListed && (extraFilesFromSource || extraDependenciesFromSource))) {
|
|
256
|
+
_context.n = 17;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
newFiles = [];
|
|
260
|
+
if (extraFilesFromSource) {
|
|
261
|
+
// Check if any extraFiles keys are not in the known set
|
|
262
|
+
for (_i2 = 0, _Object$keys = Object.keys(extraFilesFromSource); _i2 < _Object$keys.length; _i2++) {
|
|
263
|
+
extraFileKey = _Object$keys[_i2];
|
|
264
|
+
if (!knownExtraFiles.has(extraFileKey)) {
|
|
265
|
+
newFiles.push(extraFileKey);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (!(newFiles.length > 0)) {
|
|
270
|
+
_context.n = 17;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
message = "Unexpected files discovered via loadSource when allFilesListed=true (variant: ".concat(variantName, ", file: ").concat(fileName, "). ") + "New files: ".concat(newFiles.join(', '), ". ") + "Please update the loadVariantMeta function to provide the complete list of files upfront.";
|
|
274
|
+
if (!isProduction()) {
|
|
275
|
+
_context.n = 16;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
console.warn(message);
|
|
279
|
+
_context.n = 17;
|
|
280
|
+
break;
|
|
281
|
+
case 16:
|
|
282
|
+
throw new Error(message);
|
|
283
|
+
case 17:
|
|
284
|
+
_context.n = 20;
|
|
285
|
+
break;
|
|
286
|
+
case 18:
|
|
287
|
+
_context.p = 18;
|
|
288
|
+
_t2 = _context.v;
|
|
289
|
+
if (!(_t2 instanceof Error && (_t2.message.startsWith('Invalid extraFiles from loadSource:') || _t2.message.startsWith('Invalid extraDependencies from loadSource:') || _t2.message.startsWith('Unexpected files discovered via loadSource when allFilesListed=true')))) {
|
|
290
|
+
_context.n = 19;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
throw _t2;
|
|
294
|
+
case 19:
|
|
295
|
+
throw new Error("Failed to load source code (variant: ".concat(variantName, ", file: ").concat(fileName, ", url: ").concat(url, "): ").concat(JSON.stringify(_t2)));
|
|
296
|
+
case 20:
|
|
297
|
+
// Apply source transformers if no transforms exist and transforms are not disabled
|
|
298
|
+
finalTransforms = transforms;
|
|
299
|
+
if (!(sourceTransformers && !finalTransforms && !disableTransforms && finalSource)) {
|
|
300
|
+
_context.n = 22;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
_context.n = 21;
|
|
304
|
+
return transformSource(finalSource, normalizePathKey(fileName), sourceTransformers);
|
|
305
|
+
case 21:
|
|
306
|
+
finalTransforms = _context.v;
|
|
307
|
+
case 22:
|
|
308
|
+
if (!(typeof finalSource === 'string' && !disableParsing)) {
|
|
309
|
+
_context.n = 28;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
if (sourceParser) {
|
|
313
|
+
_context.n = 23;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
throw new Error('"sourceParser" function is required when source is a string and parsing is not disabled');
|
|
317
|
+
case 23:
|
|
318
|
+
_context.p = 23;
|
|
319
|
+
sourceString = finalSource;
|
|
320
|
+
_context.n = 24;
|
|
321
|
+
return sourceParser;
|
|
322
|
+
case 24:
|
|
323
|
+
parseSource = _context.v;
|
|
324
|
+
finalSource = parseSource(finalSource, fileName);
|
|
325
|
+
if (!(finalTransforms && !disableTransforms)) {
|
|
326
|
+
_context.n = 26;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
_context.n = 25;
|
|
330
|
+
return transformParsedSource(sourceString, finalSource, normalizePathKey(fileName), finalTransforms, parseSource);
|
|
331
|
+
case 25:
|
|
332
|
+
finalTransforms = _context.v;
|
|
333
|
+
case 26:
|
|
334
|
+
_context.n = 28;
|
|
335
|
+
break;
|
|
336
|
+
case 27:
|
|
337
|
+
_context.p = 27;
|
|
338
|
+
_t3 = _context.v;
|
|
339
|
+
throw new Error("Failed to parse source code (variant: ".concat(variantName, ", file: ").concat(fileName, ", url: ").concat(url, "): ").concat(_t3 instanceof Error ? _t3.message : ''));
|
|
340
|
+
case 28:
|
|
341
|
+
return _context.a(2, {
|
|
342
|
+
source: finalSource,
|
|
343
|
+
transforms: finalTransforms,
|
|
344
|
+
extraFiles: extraFilesFromSource,
|
|
345
|
+
extraDependencies: extraDependenciesFromSource,
|
|
346
|
+
externals: externalsFromSource
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}, _callee, null, [[23, 27], [8, 13, 14, 15], [2, 18]]);
|
|
350
|
+
}));
|
|
351
|
+
return _loadSingleFile.apply(this, arguments);
|
|
352
|
+
}
|
|
353
|
+
function loadExtraFiles(_x0, _x1, _x10, _x11, _x12, _x13, _x14, _x15) {
|
|
354
|
+
return _loadExtraFiles.apply(this, arguments);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Loads a variant with support for recursive extra file loading.
|
|
358
|
+
* The loadSource function can now return extraFiles that will be loaded recursively.
|
|
359
|
+
* Supports both relative and absolute paths for extra files.
|
|
360
|
+
* Uses Promise.all for efficient parallel loading of extra files.
|
|
361
|
+
*/
|
|
362
|
+
function _loadExtraFiles() {
|
|
363
|
+
_loadExtraFiles = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(variantName, extraFiles, baseUrl, entryUrl,
|
|
364
|
+
// Track the original entry file URL
|
|
365
|
+
loadSource, sourceParser, sourceTransformers, loadSourceCache) {
|
|
366
|
+
var options,
|
|
367
|
+
allFilesListed,
|
|
368
|
+
knownExtraFiles,
|
|
369
|
+
globalsFileKeys,
|
|
370
|
+
_options$maxDepth,
|
|
371
|
+
maxDepth,
|
|
372
|
+
_options$loadedFiles,
|
|
373
|
+
loadedFiles,
|
|
374
|
+
processedExtraFiles,
|
|
375
|
+
allFilesUsed,
|
|
376
|
+
allExternals,
|
|
377
|
+
extraFilePromises,
|
|
378
|
+
extraFileResults,
|
|
379
|
+
nestedExtraFilesPromises,
|
|
380
|
+
_iterator2,
|
|
381
|
+
_step2,
|
|
382
|
+
_loop,
|
|
383
|
+
nestedExtraFilesResults,
|
|
384
|
+
_iterator3,
|
|
385
|
+
_step3,
|
|
386
|
+
_step3$value,
|
|
387
|
+
nestedExtraFiles,
|
|
388
|
+
nestedFilesUsed,
|
|
389
|
+
nestedExternals,
|
|
390
|
+
sourceFileKey,
|
|
391
|
+
mergedNestedExternals,
|
|
392
|
+
_i3,
|
|
393
|
+
_Object$entries2,
|
|
394
|
+
_Object$entries2$_i,
|
|
395
|
+
nestedKey,
|
|
396
|
+
nestedValue,
|
|
397
|
+
convertedKey,
|
|
398
|
+
normalizedConvertedKey,
|
|
399
|
+
_args4 = arguments,
|
|
400
|
+
_t5;
|
|
401
|
+
return _regenerator().w(function (_context4) {
|
|
402
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
403
|
+
case 0:
|
|
404
|
+
options = _args4.length > 8 && _args4[8] !== undefined ? _args4[8] : {};
|
|
405
|
+
allFilesListed = _args4.length > 9 && _args4[9] !== undefined ? _args4[9] : false;
|
|
406
|
+
knownExtraFiles = _args4.length > 10 && _args4[10] !== undefined ? _args4[10] : new Set();
|
|
407
|
+
globalsFileKeys = _args4.length > 11 && _args4[11] !== undefined ? _args4[11] : new Set();
|
|
408
|
+
_options$maxDepth = options.maxDepth, maxDepth = _options$maxDepth === void 0 ? 10 : _options$maxDepth, _options$loadedFiles = options.loadedFiles, loadedFiles = _options$loadedFiles === void 0 ? new Set() : _options$loadedFiles;
|
|
409
|
+
if (!(maxDepth <= 0)) {
|
|
410
|
+
_context4.n = 1;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
throw new Error('Maximum recursion depth reached while loading extra files');
|
|
414
|
+
case 1:
|
|
415
|
+
processedExtraFiles = {};
|
|
416
|
+
allFilesUsed = [];
|
|
417
|
+
allExternals = {}; // Start loading all extra files in parallel
|
|
418
|
+
extraFilePromises = Object.entries(extraFiles).map(/*#__PURE__*/function () {
|
|
419
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
420
|
+
var _ref3, fileName, fileData, fileUrl, sourceData, transforms, fileResult, filesUsedFromFile, externalsFromFile, _t4;
|
|
421
|
+
return _regenerator().w(function (_context2) {
|
|
422
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
423
|
+
case 0:
|
|
424
|
+
_ref3 = _slicedToArray(_ref, 2), fileName = _ref3[0], fileData = _ref3[1];
|
|
425
|
+
_context2.p = 1;
|
|
426
|
+
if (!(typeof fileData === 'string')) {
|
|
427
|
+
_context2.n = 3;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
// fileData is a URL/path - use it directly, don't modify it
|
|
431
|
+
fileUrl = fileData;
|
|
432
|
+
|
|
433
|
+
// Check for circular dependencies
|
|
434
|
+
if (!loadedFiles.has(fileUrl)) {
|
|
435
|
+
_context2.n = 2;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
throw new Error("Circular dependency detected: ".concat(fileUrl));
|
|
439
|
+
case 2:
|
|
440
|
+
loadedFiles.add(fileUrl);
|
|
441
|
+
_context2.n = 4;
|
|
442
|
+
break;
|
|
443
|
+
case 3:
|
|
444
|
+
// fileData is an object with source and/or transforms
|
|
445
|
+
sourceData = fileData.source;
|
|
446
|
+
transforms = fileData.transforms;
|
|
447
|
+
fileUrl = baseUrl; // Use base URL as fallback
|
|
448
|
+
case 4:
|
|
449
|
+
_context2.n = 5;
|
|
450
|
+
return loadSingleFile(variantName, fileName, sourceData, fileUrl, loadSource, sourceParser, sourceTransformers, loadSourceCache, transforms, _extends(_extends({}, options), {}, {
|
|
451
|
+
maxDepth: maxDepth - 1,
|
|
452
|
+
loadedFiles: new Set(loadedFiles)
|
|
453
|
+
}), allFilesListed, knownExtraFiles);
|
|
454
|
+
case 5:
|
|
455
|
+
fileResult = _context2.v;
|
|
456
|
+
// Collect files used from this file load
|
|
457
|
+
filesUsedFromFile = [];
|
|
458
|
+
if (typeof fileData === 'string') {
|
|
459
|
+
filesUsedFromFile.push(fileUrl);
|
|
460
|
+
}
|
|
461
|
+
if (fileResult.extraDependencies) {
|
|
462
|
+
filesUsedFromFile.push.apply(filesUsedFromFile, _toConsumableArray(fileResult.extraDependencies));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Collect externals from this file load
|
|
466
|
+
externalsFromFile = {};
|
|
467
|
+
if (fileResult.externals) {
|
|
468
|
+
Object.assign(externalsFromFile, fileResult.externals);
|
|
469
|
+
}
|
|
470
|
+
return _context2.a(2, {
|
|
471
|
+
fileName: fileName,
|
|
472
|
+
result: fileResult,
|
|
473
|
+
filesUsed: filesUsedFromFile,
|
|
474
|
+
externals: externalsFromFile
|
|
475
|
+
});
|
|
476
|
+
case 6:
|
|
477
|
+
_context2.p = 6;
|
|
478
|
+
_t4 = _context2.v;
|
|
479
|
+
throw new Error("Failed to load extra file (variant: ".concat(variantName, ", file: ").concat(fileName, ", url: ").concat(baseUrl, "): ").concat(_t4 instanceof Error ? _t4.message : ''));
|
|
480
|
+
case 7:
|
|
481
|
+
return _context2.a(2);
|
|
482
|
+
}
|
|
483
|
+
}, _callee2, null, [[1, 6]]);
|
|
484
|
+
}));
|
|
485
|
+
return function (_x19) {
|
|
486
|
+
return _ref2.apply(this, arguments);
|
|
487
|
+
};
|
|
488
|
+
}()); // Wait for all extra files to load
|
|
489
|
+
_context4.n = 2;
|
|
490
|
+
return Promise.all(extraFilePromises);
|
|
491
|
+
case 2:
|
|
492
|
+
extraFileResults = _context4.v;
|
|
493
|
+
// Process results and handle nested extra files
|
|
494
|
+
nestedExtraFilesPromises = [];
|
|
495
|
+
_iterator2 = _createForOfIteratorHelper(extraFileResults);
|
|
496
|
+
_context4.p = 3;
|
|
497
|
+
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
498
|
+
var _step2$value, fileName, result, filesUsed, externals, normalizedFileName, originalFileData, metadata, mergedExternals, sourceFileUrl, fileData;
|
|
499
|
+
return _regenerator().w(function (_context3) {
|
|
500
|
+
while (1) switch (_context3.n) {
|
|
501
|
+
case 0:
|
|
502
|
+
_step2$value = _step2.value, fileName = _step2$value.fileName, result = _step2$value.result, filesUsed = _step2$value.filesUsed, externals = _step2$value.externals;
|
|
503
|
+
normalizedFileName = normalizePathKey(fileName);
|
|
504
|
+
originalFileData = extraFiles[fileName]; // Preserve metadata flag if it exists in the original data, or if this file came from globals
|
|
505
|
+
if (typeof originalFileData !== 'string') {
|
|
506
|
+
metadata = originalFileData.metadata;
|
|
507
|
+
} else if (globalsFileKeys.has(fileName)) {
|
|
508
|
+
metadata = true;
|
|
509
|
+
}
|
|
510
|
+
processedExtraFiles[normalizedFileName] = _extends({
|
|
511
|
+
source: result.source,
|
|
512
|
+
transforms: result.transforms
|
|
513
|
+
}, metadata !== undefined && {
|
|
514
|
+
metadata: metadata
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
// Add files used from this file load
|
|
518
|
+
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(filesUsed));
|
|
519
|
+
|
|
520
|
+
// Add externals from this file load using proper merging
|
|
521
|
+
mergedExternals = mergeExternals([allExternals, externals]);
|
|
522
|
+
Object.assign(allExternals, mergedExternals);
|
|
523
|
+
|
|
524
|
+
// Collect promises for nested extra files with their source key
|
|
525
|
+
if (result.extraFiles) {
|
|
526
|
+
sourceFileUrl = baseUrl;
|
|
527
|
+
fileData = extraFiles[fileName];
|
|
528
|
+
if (typeof fileData === 'string') {
|
|
529
|
+
sourceFileUrl = fileData; // Use the URL directly, don't modify it
|
|
530
|
+
}
|
|
531
|
+
nestedExtraFilesPromises.push(loadExtraFiles(variantName, result.extraFiles, sourceFileUrl,
|
|
532
|
+
// Use the source file's URL as base for its extra files
|
|
533
|
+
entryUrl,
|
|
534
|
+
// Keep the entry URL for final conversion
|
|
535
|
+
loadSource, sourceParser, sourceTransformers, loadSourceCache, _extends(_extends({}, options), {}, {
|
|
536
|
+
maxDepth: maxDepth - 1,
|
|
537
|
+
loadedFiles: new Set(loadedFiles)
|
|
538
|
+
}), allFilesListed, knownExtraFiles, globalsFileKeys // Pass through globals file tracking
|
|
539
|
+
).then(function (nestedResult) {
|
|
540
|
+
return {
|
|
541
|
+
files: nestedResult.extraFiles,
|
|
542
|
+
allFilesUsed: nestedResult.allFilesUsed,
|
|
543
|
+
allExternals: nestedResult.allExternals,
|
|
544
|
+
sourceFileKey: normalizedFileName // Pass the normalized key
|
|
545
|
+
};
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
case 1:
|
|
549
|
+
return _context3.a(2);
|
|
550
|
+
}
|
|
551
|
+
}, _loop);
|
|
552
|
+
});
|
|
553
|
+
_iterator2.s();
|
|
554
|
+
case 4:
|
|
555
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
556
|
+
_context4.n = 6;
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
return _context4.d(_regeneratorValues(_loop()), 5);
|
|
560
|
+
case 5:
|
|
561
|
+
_context4.n = 4;
|
|
562
|
+
break;
|
|
563
|
+
case 6:
|
|
564
|
+
_context4.n = 8;
|
|
565
|
+
break;
|
|
566
|
+
case 7:
|
|
567
|
+
_context4.p = 7;
|
|
568
|
+
_t5 = _context4.v;
|
|
569
|
+
_iterator2.e(_t5);
|
|
570
|
+
case 8:
|
|
571
|
+
_context4.p = 8;
|
|
572
|
+
_iterator2.f();
|
|
573
|
+
return _context4.f(8);
|
|
574
|
+
case 9:
|
|
575
|
+
if (!(nestedExtraFilesPromises.length > 0)) {
|
|
576
|
+
_context4.n = 11;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
_context4.n = 10;
|
|
580
|
+
return Promise.all(nestedExtraFilesPromises);
|
|
581
|
+
case 10:
|
|
582
|
+
nestedExtraFilesResults = _context4.v;
|
|
583
|
+
_iterator3 = _createForOfIteratorHelper(nestedExtraFilesResults);
|
|
584
|
+
try {
|
|
585
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
586
|
+
_step3$value = _step3.value, nestedExtraFiles = _step3$value.files, nestedFilesUsed = _step3$value.allFilesUsed, nestedExternals = _step3$value.allExternals, sourceFileKey = _step3$value.sourceFileKey;
|
|
587
|
+
// Add nested files used
|
|
588
|
+
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(nestedFilesUsed));
|
|
589
|
+
|
|
590
|
+
// Add nested externals using proper merging
|
|
591
|
+
mergedNestedExternals = mergeExternals([allExternals, nestedExternals]);
|
|
592
|
+
Object.assign(allExternals, mergedNestedExternals);
|
|
593
|
+
for (_i3 = 0, _Object$entries2 = Object.entries(nestedExtraFiles); _i3 < _Object$entries2.length; _i3++) {
|
|
594
|
+
_Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2), nestedKey = _Object$entries2$_i[0], nestedValue = _Object$entries2$_i[1];
|
|
595
|
+
// Convert the key based on the directory structure of the source key
|
|
596
|
+
convertedKey = convertKeyBasedOnDirectory(nestedKey, sourceFileKey);
|
|
597
|
+
normalizedConvertedKey = normalizePathKey(convertedKey);
|
|
598
|
+
processedExtraFiles[normalizedConvertedKey] = nestedValue;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
} catch (err) {
|
|
602
|
+
_iterator3.e(err);
|
|
603
|
+
} finally {
|
|
604
|
+
_iterator3.f();
|
|
605
|
+
}
|
|
606
|
+
case 11:
|
|
607
|
+
return _context4.a(2, {
|
|
608
|
+
extraFiles: processedExtraFiles,
|
|
609
|
+
allFilesUsed: allFilesUsed,
|
|
610
|
+
allExternals: allExternals
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
}, _callee3, null, [[3, 7, 8, 9]]);
|
|
614
|
+
}));
|
|
615
|
+
return _loadExtraFiles.apply(this, arguments);
|
|
616
|
+
}
|
|
617
|
+
export function loadVariant(_x16, _x17, _x18) {
|
|
618
|
+
return _loadVariant.apply(this, arguments);
|
|
619
|
+
}
|
|
620
|
+
function _loadVariant() {
|
|
621
|
+
_loadVariant = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url, variantName, variant) {
|
|
622
|
+
var options,
|
|
623
|
+
sourceParser,
|
|
624
|
+
loadSource,
|
|
625
|
+
loadVariantMeta,
|
|
626
|
+
sourceTransformers,
|
|
627
|
+
globalsCode,
|
|
628
|
+
loadSourceCache,
|
|
629
|
+
_getFileNameFromUrl,
|
|
630
|
+
_fileName,
|
|
631
|
+
loadedFiles,
|
|
632
|
+
allFilesUsed,
|
|
633
|
+
allExternals,
|
|
634
|
+
knownExtraFiles,
|
|
635
|
+
_i4,
|
|
636
|
+
_Object$keys2,
|
|
637
|
+
extraFileName,
|
|
638
|
+
fileName,
|
|
639
|
+
_finalVariant,
|
|
640
|
+
mainFileResult,
|
|
641
|
+
allExtraFiles,
|
|
642
|
+
_i5,
|
|
643
|
+
_Object$keys3,
|
|
644
|
+
_extraFileName,
|
|
645
|
+
extraFilesToLoad,
|
|
646
|
+
globalsFileKeys,
|
|
647
|
+
existingFiles,
|
|
648
|
+
_i6,
|
|
649
|
+
_Object$keys4,
|
|
650
|
+
key,
|
|
651
|
+
globalsPromises,
|
|
652
|
+
globalsResults,
|
|
653
|
+
_iterator4,
|
|
654
|
+
_step4,
|
|
655
|
+
globalsResult,
|
|
656
|
+
_i7,
|
|
657
|
+
_Object$entries3,
|
|
658
|
+
_Object$entries3$_i,
|
|
659
|
+
_key,
|
|
660
|
+
value,
|
|
661
|
+
conflictFreeKey,
|
|
662
|
+
loadableFiles,
|
|
663
|
+
_i8,
|
|
664
|
+
_Object$entries4,
|
|
665
|
+
_Object$entries4$_i,
|
|
666
|
+
_key2,
|
|
667
|
+
_value,
|
|
668
|
+
_i9,
|
|
669
|
+
_Object$entries5,
|
|
670
|
+
_Object$entries5$_i,
|
|
671
|
+
_key3,
|
|
672
|
+
_value2,
|
|
673
|
+
metadata,
|
|
674
|
+
urlFilesToLoad,
|
|
675
|
+
_i0,
|
|
676
|
+
_Object$entries6,
|
|
677
|
+
_Object$entries6$_i,
|
|
678
|
+
_key4,
|
|
679
|
+
_value3,
|
|
680
|
+
extraFilesResult,
|
|
681
|
+
_extraFilesResult,
|
|
682
|
+
finalVariant,
|
|
683
|
+
_args6 = arguments,
|
|
684
|
+
_t8;
|
|
685
|
+
return _regenerator().w(function (_context6) {
|
|
686
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
687
|
+
case 0:
|
|
688
|
+
options = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : {};
|
|
689
|
+
if (variant) {
|
|
690
|
+
_context6.n = 1;
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
throw new Error("Variant is missing from code: ".concat(variantName));
|
|
694
|
+
case 1:
|
|
695
|
+
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
|
|
696
|
+
loadSourceCache = new Map();
|
|
697
|
+
if (!(typeof variant === 'string')) {
|
|
698
|
+
_context6.n = 6;
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
if (loadVariantMeta) {
|
|
702
|
+
_context6.n = 3;
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
// Create a basic loadVariantMeta function as fallback
|
|
706
|
+
_getFileNameFromUrl = getFileNameFromUrl(variant), _fileName = _getFileNameFromUrl.fileName;
|
|
707
|
+
if (_fileName) {
|
|
708
|
+
_context6.n = 2;
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
throw new Error("Cannot determine fileName from URL \"".concat(variant, "\" for variant \"").concat(variantName, "\". ") + "Please provide a loadVariantMeta function or ensure the URL has a valid file extension.");
|
|
712
|
+
case 2:
|
|
713
|
+
variant = {
|
|
714
|
+
url: variant,
|
|
715
|
+
fileName: _fileName
|
|
716
|
+
};
|
|
717
|
+
_context6.n = 6;
|
|
718
|
+
break;
|
|
719
|
+
case 3:
|
|
720
|
+
_context6.p = 3;
|
|
721
|
+
_context6.n = 4;
|
|
722
|
+
return loadVariantMeta(variantName, variant);
|
|
723
|
+
case 4:
|
|
724
|
+
variant = _context6.v;
|
|
725
|
+
_context6.n = 6;
|
|
726
|
+
break;
|
|
727
|
+
case 5:
|
|
728
|
+
_context6.p = 5;
|
|
729
|
+
_t8 = _context6.v;
|
|
730
|
+
throw new Error("Failed to load variant code (variant: ".concat(variantName, ", url: ").concat(variant, "): ").concat(JSON.stringify(_t8)));
|
|
731
|
+
case 6:
|
|
732
|
+
loadedFiles = new Set();
|
|
733
|
+
if (url) {
|
|
734
|
+
loadedFiles.add(url);
|
|
735
|
+
}
|
|
736
|
+
allFilesUsed = url ? [url] : []; // Start with the main file URL if available
|
|
737
|
+
allExternals = {}; // Collect externals from all sources
|
|
738
|
+
// Build set of known extra files from variant definition
|
|
739
|
+
knownExtraFiles = new Set();
|
|
740
|
+
if (variant.extraFiles) {
|
|
741
|
+
for (_i4 = 0, _Object$keys2 = Object.keys(variant.extraFiles); _i4 < _Object$keys2.length; _i4++) {
|
|
742
|
+
extraFileName = _Object$keys2[_i4];
|
|
743
|
+
knownExtraFiles.add(extraFileName);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// Load main file
|
|
748
|
+
fileName = variant.fileName || (url ? getFileNameFromUrl(url).fileName : undefined); // If we don't have a fileName and no URL, we can't parse or transform but can still return the code
|
|
749
|
+
if (!(!fileName && !url)) {
|
|
750
|
+
_context6.n = 7;
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
// Return the variant as-is without parsing or transforms
|
|
754
|
+
_finalVariant = _extends(_extends({}, variant), {}, {
|
|
755
|
+
source: typeof variant.source === 'string' ? {
|
|
756
|
+
type: 'root',
|
|
757
|
+
children: [{
|
|
758
|
+
type: 'text',
|
|
759
|
+
value: variant.source || ''
|
|
760
|
+
}]
|
|
761
|
+
} : variant.source
|
|
762
|
+
});
|
|
763
|
+
return _context6.a(2, {
|
|
764
|
+
code: _finalVariant,
|
|
765
|
+
dependencies: [],
|
|
766
|
+
// No dependencies without URL
|
|
767
|
+
externals: {} // No externals without URL
|
|
768
|
+
});
|
|
769
|
+
case 7:
|
|
770
|
+
if (fileName) {
|
|
771
|
+
_context6.n = 8;
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
774
|
+
throw new Error("No fileName available for variant \"".concat(variantName, "\". ") + "Please provide a fileName in the variant definition or ensure the URL has a valid file extension.");
|
|
775
|
+
case 8:
|
|
776
|
+
_context6.n = 9;
|
|
777
|
+
return loadSingleFile(variantName, fileName, variant.source, url, loadSource, sourceParser, sourceTransformers, loadSourceCache, variant.transforms, _extends(_extends({}, options), {}, {
|
|
778
|
+
loadedFiles: loadedFiles
|
|
779
|
+
}), variant.allFilesListed || false, knownExtraFiles);
|
|
780
|
+
case 9:
|
|
781
|
+
mainFileResult = _context6.v;
|
|
782
|
+
// Add files used from main file loading
|
|
783
|
+
if (mainFileResult.extraDependencies) {
|
|
784
|
+
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(mainFileResult.extraDependencies));
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// Add externals from main file loading
|
|
788
|
+
if (mainFileResult.externals) {
|
|
789
|
+
allExternals = mergeExternals([allExternals, mainFileResult.externals]);
|
|
790
|
+
}
|
|
791
|
+
allExtraFiles = {}; // Validate extraFiles keys from variant definition
|
|
792
|
+
if (!variant.extraFiles) {
|
|
793
|
+
_context6.n = 12;
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
_i5 = 0, _Object$keys3 = Object.keys(variant.extraFiles);
|
|
797
|
+
case 10:
|
|
798
|
+
if (!(_i5 < _Object$keys3.length)) {
|
|
799
|
+
_context6.n = 12;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
_extraFileName = _Object$keys3[_i5];
|
|
803
|
+
if (!isAbsolutePath(_extraFileName)) {
|
|
804
|
+
_context6.n = 11;
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
throw new Error("Invalid extraFiles key in variant: \"".concat(_extraFileName, "\" appears to be an absolute path. ") + "extraFiles keys in variant definition should be relative paths from the main file.");
|
|
808
|
+
case 11:
|
|
809
|
+
_i5++;
|
|
810
|
+
_context6.n = 10;
|
|
811
|
+
break;
|
|
812
|
+
case 12:
|
|
813
|
+
// Collect extra files from variant definition and from loaded source
|
|
814
|
+
extraFilesToLoad = _extends(_extends({}, variant.extraFiles || {}), mainFileResult.extraFiles || {}); // Track which files come from globals for metadata marking
|
|
815
|
+
globalsFileKeys = new Set(); // Track globals file keys for loadExtraFiles
|
|
816
|
+
// Process globalsCode array and add to extraFiles if provided
|
|
817
|
+
if (!(globalsCode && globalsCode.length > 0)) {
|
|
818
|
+
_context6.n = 14;
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
// Collect existing filenames to avoid conflicts
|
|
822
|
+
existingFiles = new Set(); // Add main variant filename if it exists
|
|
823
|
+
if (variant.fileName) {
|
|
824
|
+
existingFiles.add(variant.fileName);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Add already loaded extra files
|
|
828
|
+
for (_i6 = 0, _Object$keys4 = Object.keys(extraFilesToLoad); _i6 < _Object$keys4.length; _i6++) {
|
|
829
|
+
key = _Object$keys4[_i6];
|
|
830
|
+
existingFiles.add(key);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// Process all globals items in parallel
|
|
834
|
+
globalsPromises = globalsCode.map(/*#__PURE__*/function () {
|
|
835
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(globalsItem) {
|
|
836
|
+
var globalsVariant, _getFileNameFromUrl2, globalsFileName, globalsResult, _t6, _t7;
|
|
837
|
+
return _regenerator().w(function (_context5) {
|
|
838
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
839
|
+
case 0:
|
|
840
|
+
if (!(typeof globalsItem === 'string')) {
|
|
841
|
+
_context5.n = 6;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
if (loadVariantMeta) {
|
|
845
|
+
_context5.n = 2;
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
// Create a basic variant as fallback
|
|
849
|
+
_getFileNameFromUrl2 = getFileNameFromUrl(globalsItem), globalsFileName = _getFileNameFromUrl2.fileName;
|
|
850
|
+
if (globalsFileName) {
|
|
851
|
+
_context5.n = 1;
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
throw new Error("Cannot determine fileName from globalsCode URL \"".concat(globalsItem, "\". ") + "Please provide a loadVariantMeta function or ensure the URL has a valid file extension.");
|
|
855
|
+
case 1:
|
|
856
|
+
globalsVariant = {
|
|
857
|
+
url: globalsItem,
|
|
858
|
+
fileName: globalsFileName
|
|
859
|
+
};
|
|
860
|
+
_context5.n = 5;
|
|
861
|
+
break;
|
|
862
|
+
case 2:
|
|
863
|
+
_context5.p = 2;
|
|
864
|
+
_context5.n = 3;
|
|
865
|
+
return loadVariantMeta(variantName, globalsItem);
|
|
866
|
+
case 3:
|
|
867
|
+
globalsVariant = _context5.v;
|
|
868
|
+
_context5.n = 5;
|
|
869
|
+
break;
|
|
870
|
+
case 4:
|
|
871
|
+
_context5.p = 4;
|
|
872
|
+
_t6 = _context5.v;
|
|
873
|
+
throw new Error("Failed to load globalsCode variant metadata (variant: ".concat(variantName, ", url: ").concat(globalsItem, "): ").concat(JSON.stringify(_t6)));
|
|
874
|
+
case 5:
|
|
875
|
+
_context5.n = 7;
|
|
876
|
+
break;
|
|
877
|
+
case 6:
|
|
878
|
+
globalsVariant = globalsItem;
|
|
879
|
+
case 7:
|
|
880
|
+
_context5.p = 7;
|
|
881
|
+
_context5.n = 8;
|
|
882
|
+
return loadVariant(globalsVariant.url, variantName, globalsVariant, _extends(_extends({}, options), {}, {
|
|
883
|
+
globalsCode: undefined
|
|
884
|
+
}) // Prevent infinite recursion
|
|
885
|
+
);
|
|
886
|
+
case 8:
|
|
887
|
+
globalsResult = _context5.v;
|
|
888
|
+
return _context5.a(2, globalsResult);
|
|
889
|
+
case 9:
|
|
890
|
+
_context5.p = 9;
|
|
891
|
+
_t7 = _context5.v;
|
|
892
|
+
throw new Error("Failed to load globalsCode (variant: ".concat(variantName, "): ").concat(_t7 instanceof Error ? _t7.message : JSON.stringify(_t7)));
|
|
893
|
+
case 10:
|
|
894
|
+
return _context5.a(2);
|
|
895
|
+
}
|
|
896
|
+
}, _callee4, null, [[7, 9], [2, 4]]);
|
|
897
|
+
}));
|
|
898
|
+
return function (_x20) {
|
|
899
|
+
return _ref4.apply(this, arguments);
|
|
900
|
+
};
|
|
901
|
+
}()); // Wait for all globals to load
|
|
902
|
+
_context6.n = 13;
|
|
903
|
+
return Promise.all(globalsPromises);
|
|
904
|
+
case 13:
|
|
905
|
+
globalsResults = _context6.v;
|
|
906
|
+
// Merge results from all globals
|
|
907
|
+
_iterator4 = _createForOfIteratorHelper(globalsResults);
|
|
908
|
+
try {
|
|
909
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
910
|
+
globalsResult = _step4.value;
|
|
911
|
+
// Add globals extraFiles (but NOT the main file)
|
|
912
|
+
if (globalsResult.code.extraFiles) {
|
|
913
|
+
// Add globals extra files with conflict-free naming and metadata flag
|
|
914
|
+
for (_i7 = 0, _Object$entries3 = Object.entries(globalsResult.code.extraFiles); _i7 < _Object$entries3.length; _i7++) {
|
|
915
|
+
_Object$entries3$_i = _slicedToArray(_Object$entries3[_i7], 2), _key = _Object$entries3$_i[0], value = _Object$entries3$_i[1];
|
|
916
|
+
conflictFreeKey = generateConflictFreeFilename(_key, existingFiles); // Always add metadata: true flag for globals files
|
|
917
|
+
if (typeof value === 'string') {
|
|
918
|
+
// For string URLs, we can't easily wrap them but need to track for later metadata addition
|
|
919
|
+
extraFilesToLoad[conflictFreeKey] = value;
|
|
920
|
+
globalsFileKeys.add(conflictFreeKey); // Track for loadExtraFiles
|
|
921
|
+
} else {
|
|
922
|
+
// For object values, add metadata directly
|
|
923
|
+
extraFilesToLoad[conflictFreeKey] = _extends(_extends({}, value), {}, {
|
|
924
|
+
metadata: true
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
existingFiles.add(conflictFreeKey); // Track the added file for subsequent iterations
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// Add globals dependencies
|
|
932
|
+
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(globalsResult.dependencies));
|
|
933
|
+
|
|
934
|
+
// Add globals externals
|
|
935
|
+
allExternals = mergeExternals([allExternals, globalsResult.externals]);
|
|
936
|
+
}
|
|
937
|
+
} catch (err) {
|
|
938
|
+
_iterator4.e(err);
|
|
939
|
+
} finally {
|
|
940
|
+
_iterator4.f();
|
|
941
|
+
}
|
|
942
|
+
case 14:
|
|
943
|
+
if (!(Object.keys(extraFilesToLoad).length > 0)) {
|
|
944
|
+
_context6.n = 19;
|
|
945
|
+
break;
|
|
946
|
+
}
|
|
947
|
+
if (url) {
|
|
948
|
+
_context6.n = 17;
|
|
949
|
+
break;
|
|
950
|
+
}
|
|
951
|
+
// If there's no URL, we can only load extra files that have inline source or absolute URLs
|
|
952
|
+
loadableFiles = {};
|
|
953
|
+
for (_i8 = 0, _Object$entries4 = Object.entries(extraFilesToLoad); _i8 < _Object$entries4.length; _i8++) {
|
|
954
|
+
_Object$entries4$_i = _slicedToArray(_Object$entries4[_i8], 2), _key2 = _Object$entries4$_i[0], _value = _Object$entries4$_i[1];
|
|
955
|
+
if (typeof _value !== 'string' && _value.source !== undefined) {
|
|
956
|
+
// Inline source - can always load
|
|
957
|
+
loadableFiles[_key2] = _value;
|
|
958
|
+
} else if (typeof _value === 'string' && isAbsolutePath(_value)) {
|
|
959
|
+
// Absolute URL - can load without base URL
|
|
960
|
+
loadableFiles[_key2] = _value;
|
|
961
|
+
} else {
|
|
962
|
+
console.warn("Skipping extra file \"".concat(_key2, "\" - no URL provided and file requires loading from external source"));
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
if (!(Object.keys(loadableFiles).length > 0)) {
|
|
966
|
+
_context6.n = 16;
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
// Process loadable files: inline sources without URL-based loading, absolute URLs with loading
|
|
970
|
+
for (_i9 = 0, _Object$entries5 = Object.entries(loadableFiles); _i9 < _Object$entries5.length; _i9++) {
|
|
971
|
+
_Object$entries5$_i = _slicedToArray(_Object$entries5[_i9], 2), _key3 = _Object$entries5$_i[0], _value2 = _Object$entries5$_i[1];
|
|
972
|
+
if (typeof _value2 !== 'string') {
|
|
973
|
+
// Inline source - preserve metadata if it was marked as globals
|
|
974
|
+
metadata = _value2.metadata || globalsFileKeys.has(_key3) ? true : undefined;
|
|
975
|
+
allExtraFiles[normalizePathKey(_key3)] = _extends({
|
|
976
|
+
source: _value2.source,
|
|
977
|
+
transforms: _value2.transforms
|
|
978
|
+
}, metadata !== undefined && {
|
|
979
|
+
metadata: metadata
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// For absolute URLs, we need to load them
|
|
985
|
+
urlFilesToLoad = {};
|
|
986
|
+
for (_i0 = 0, _Object$entries6 = Object.entries(loadableFiles); _i0 < _Object$entries6.length; _i0++) {
|
|
987
|
+
_Object$entries6$_i = _slicedToArray(_Object$entries6[_i0], 2), _key4 = _Object$entries6$_i[0], _value3 = _Object$entries6$_i[1];
|
|
988
|
+
if (typeof _value3 === 'string') {
|
|
989
|
+
urlFilesToLoad[_key4] = _value3;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
if (!(Object.keys(urlFilesToLoad).length > 0)) {
|
|
993
|
+
_context6.n = 16;
|
|
994
|
+
break;
|
|
995
|
+
}
|
|
996
|
+
_context6.n = 15;
|
|
997
|
+
return loadExtraFiles(variantName, urlFilesToLoad, '',
|
|
998
|
+
// No base URL needed for absolute URLs
|
|
999
|
+
'',
|
|
1000
|
+
// No entry URL
|
|
1001
|
+
loadSource, sourceParser, sourceTransformers, loadSourceCache, _extends(_extends({}, options), {}, {
|
|
1002
|
+
loadedFiles: loadedFiles
|
|
1003
|
+
}), variant.allFilesListed || false, knownExtraFiles, globalsFileKeys // Pass globals file tracking
|
|
1004
|
+
);
|
|
1005
|
+
case 15:
|
|
1006
|
+
extraFilesResult = _context6.v;
|
|
1007
|
+
allExtraFiles = _extends(_extends({}, allExtraFiles), extraFilesResult.extraFiles);
|
|
1008
|
+
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(extraFilesResult.allFilesUsed));
|
|
1009
|
+
allExternals = mergeExternals([allExternals, extraFilesResult.allExternals]);
|
|
1010
|
+
case 16:
|
|
1011
|
+
_context6.n = 19;
|
|
1012
|
+
break;
|
|
1013
|
+
case 17:
|
|
1014
|
+
_context6.n = 18;
|
|
1015
|
+
return loadExtraFiles(variantName, extraFilesToLoad, url, url,
|
|
1016
|
+
// Entry URL is the same as the main file URL
|
|
1017
|
+
loadSource, sourceParser, sourceTransformers, loadSourceCache, _extends(_extends({}, options), {}, {
|
|
1018
|
+
loadedFiles: loadedFiles
|
|
1019
|
+
}), variant.allFilesListed || false, knownExtraFiles, globalsFileKeys // Pass globals file tracking
|
|
1020
|
+
);
|
|
1021
|
+
case 18:
|
|
1022
|
+
_extraFilesResult = _context6.v;
|
|
1023
|
+
allExtraFiles = _extraFilesResult.extraFiles;
|
|
1024
|
+
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(_extraFilesResult.allFilesUsed));
|
|
1025
|
+
allExternals = mergeExternals([allExternals, _extraFilesResult.allExternals]);
|
|
1026
|
+
case 19:
|
|
1027
|
+
// Note: metadata marking is now handled during loadExtraFiles processing
|
|
1028
|
+
finalVariant = _extends(_extends({}, variant), {}, {
|
|
1029
|
+
source: mainFileResult.source,
|
|
1030
|
+
transforms: mainFileResult.transforms,
|
|
1031
|
+
extraFiles: Object.keys(allExtraFiles).length > 0 ? allExtraFiles : undefined,
|
|
1032
|
+
externals: Object.keys(allExternals).length > 0 ? Object.keys(allExternals) : undefined
|
|
1033
|
+
});
|
|
1034
|
+
return _context6.a(2, {
|
|
1035
|
+
code: finalVariant,
|
|
1036
|
+
dependencies: Array.from(new Set(allFilesUsed)),
|
|
1037
|
+
// Remove duplicates
|
|
1038
|
+
externals: allExternals
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
}, _callee5, null, [[3, 5]]);
|
|
1042
|
+
}));
|
|
1043
|
+
return _loadVariant.apply(this, arguments);
|
|
1044
|
+
}
|