@mui/internal-docs-infra 0.1.1-alpha.3 → 0.1.1-canary.0
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/README.md +1 -3
- package/esm/package.json +1 -0
- package/esm/useCopier/index.d.ts +15 -0
- package/esm/useCopier/index.js +62 -0
- package/{useCode/useCode.d.ts → esm/useDemo/index.d.ts} +29 -15
- package/esm/useDemo/index.d.ts.map +1 -0
- package/esm/useDemo/index.js +104 -0
- package/package.json +34 -29
- package/useCopier/index.js +18 -10
- package/useDemo/index.d.ts +25 -13
- package/useDemo/index.js +109 -14
- package/CodeControllerContext/CodeControllerContext.d.ts +0 -22
- package/CodeControllerContext/CodeControllerContext.d.ts.map +0 -1
- package/CodeControllerContext/CodeControllerContext.js +0 -14
- package/CodeControllerContext/index.d.ts +0 -1
- package/CodeControllerContext/index.d.ts.map +0 -1
- package/CodeControllerContext/index.js +0 -1
- package/CodeHighlighter/CodeHighlighter.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighter.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighter.js +0 -321
- package/CodeHighlighter/CodeHighlighterClient.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighterClient.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterClient.js +0 -399
- package/CodeHighlighter/CodeHighlighterContext.d.ts +0 -14
- package/CodeHighlighter/CodeHighlighterContext.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterContext.js +0 -14
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +0 -7
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterFallbackContext.js +0 -11
- package/CodeHighlighter/applyTransform.d.ts +0 -19
- package/CodeHighlighter/applyTransform.d.ts.map +0 -1
- package/CodeHighlighter/applyTransform.js +0 -75
- package/CodeHighlighter/codeToFallbackProps.d.ts +0 -2
- package/CodeHighlighter/codeToFallbackProps.d.ts.map +0 -1
- package/CodeHighlighter/codeToFallbackProps.js +0 -70
- package/CodeHighlighter/errors.d.ts +0 -0
- package/CodeHighlighter/errors.d.ts.map +0 -1
- package/CodeHighlighter/errors.js +0 -1
- package/CodeHighlighter/hasAllVariants.d.ts +0 -2
- package/CodeHighlighter/hasAllVariants.d.ts.map +0 -1
- package/CodeHighlighter/hasAllVariants.js +0 -31
- package/CodeHighlighter/index.d.ts +0 -4
- package/CodeHighlighter/index.d.ts.map +0 -1
- package/CodeHighlighter/index.js +0 -4
- package/CodeHighlighter/loadFallbackCode.d.ts +0 -9
- package/CodeHighlighter/loadFallbackCode.d.ts.map +0 -1
- package/CodeHighlighter/loadFallbackCode.js +0 -468
- package/CodeHighlighter/loadVariant.d.ts +0 -11
- package/CodeHighlighter/loadVariant.d.ts.map +0 -1
- package/CodeHighlighter/loadVariant.js +0 -719
- package/CodeHighlighter/maybeInitialData.d.ts +0 -10
- package/CodeHighlighter/maybeInitialData.d.ts.map +0 -1
- package/CodeHighlighter/maybeInitialData.js +0 -94
- package/CodeHighlighter/parseCode.d.ts +0 -6
- package/CodeHighlighter/parseCode.d.ts.map +0 -1
- package/CodeHighlighter/parseCode.js +0 -122
- package/CodeHighlighter/parseControlledCode.d.ts +0 -6
- package/CodeHighlighter/parseControlledCode.d.ts.map +0 -1
- package/CodeHighlighter/parseControlledCode.js +0 -76
- package/CodeHighlighter/transformCode.d.ts +0 -20
- package/CodeHighlighter/transformCode.d.ts.map +0 -1
- package/CodeHighlighter/transformCode.js +0 -223
- package/CodeHighlighter/transformParsedSource.d.ts +0 -3
- package/CodeHighlighter/transformParsedSource.d.ts.map +0 -1
- package/CodeHighlighter/transformParsedSource.js +0 -66
- package/CodeHighlighter/transformSource.d.ts +0 -2
- package/CodeHighlighter/transformSource.d.ts.map +0 -1
- package/CodeHighlighter/transformSource.js +0 -107
- package/CodeHighlighter/types.d.ts +0 -138
- package/CodeHighlighter/types.d.ts.map +0 -1
- package/CodeHighlighter/types.js +0 -1
- package/CodeProvider/CodeContext.d.ts +0 -12
- package/CodeProvider/CodeContext.d.ts.map +0 -1
- package/CodeProvider/CodeContext.js +0 -8
- package/CodeProvider/CodeProvider.d.ts +0 -13
- package/CodeProvider/CodeProvider.d.ts.map +0 -1
- package/CodeProvider/CodeProvider.js +0 -50
- package/CodeProvider/index.d.ts +0 -2
- package/CodeProvider/index.d.ts.map +0 -1
- package/CodeProvider/index.js +0 -2
- package/hast/hast.d.ts +0 -11
- package/hast/hast.d.ts.map +0 -1
- package/hast/hast.js +0 -66
- package/hast/index.d.ts +0 -1
- package/hast/index.d.ts.map +0 -1
- package/hast/index.js +0 -1
- package/loadPrecomputedCodeHighlighter/index.d.ts +0 -2
- package/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/index.js +0 -4
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -57
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -195
- package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +0 -20
- package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -243
- package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +0 -15
- package/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +0 -168
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -27
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
- package/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -37
- package/loadServerCodeMeta/index.d.ts +0 -1
- package/loadServerCodeMeta/index.d.ts.map +0 -1
- package/loadServerCodeMeta/index.js +0 -1
- package/loadServerCodeMeta/serverLoadCodeMeta.d.ts +0 -24
- package/loadServerCodeMeta/serverLoadCodeMeta.d.ts.map +0 -1
- package/loadServerCodeMeta/serverLoadCodeMeta.js +0 -77
- package/loadServerSource/index.d.ts +0 -1
- package/loadServerSource/index.d.ts.map +0 -1
- package/loadServerSource/index.js +0 -1
- package/loadServerSource/serverLoadSource.d.ts +0 -25
- package/loadServerSource/serverLoadSource.d.ts.map +0 -1
- package/loadServerSource/serverLoadSource.js +0 -100
- package/loaderUtils/getFileNameFromUrl.d.ts +0 -11
- package/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
- package/loaderUtils/getFileNameFromUrl.js +0 -32
- package/loaderUtils/index.d.ts +0 -5
- package/loaderUtils/index.d.ts.map +0 -1
- package/loaderUtils/index.js +0 -5
- package/loaderUtils/processImports.d.ts +0 -19
- package/loaderUtils/processImports.d.ts.map +0 -1
- package/loaderUtils/processImports.js +0 -82
- package/loaderUtils/resolveImports.d.ts +0 -4
- package/loaderUtils/resolveImports.d.ts.map +0 -1
- package/loaderUtils/resolveImports.js +0 -71
- package/loaderUtils/resolveModulePath.d.ts +0 -74
- package/loaderUtils/resolveModulePath.d.ts.map +0 -1
- package/loaderUtils/resolveModulePath.js +0 -862
- package/loaderUtils/resolveModulePathWithFs.d.ts +0 -44
- package/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
- package/loaderUtils/resolveModulePathWithFs.js +0 -159
- package/loaderUtils/rewriteImports.d.ts +0 -9
- package/loaderUtils/rewriteImports.d.ts.map +0 -1
- package/loaderUtils/rewriteImports.js +0 -57
- package/parseSource/grammars.d.ts +0 -2
- package/parseSource/grammars.d.ts.map +0 -1
- package/parseSource/grammars.js +0 -27
- package/parseSource/index.d.ts +0 -1
- package/parseSource/index.d.ts.map +0 -1
- package/parseSource/index.js +0 -1
- package/parseSource/parseSource.d.ts +0 -3
- package/parseSource/parseSource.d.ts.map +0 -1
- package/parseSource/parseSource.js +0 -37
- package/transformRelativeMarkdownPaths/index.d.ts +0 -2
- package/transformRelativeMarkdownPaths/index.d.ts.map +0 -1
- package/transformRelativeMarkdownPaths/index.js +0 -4
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts +0 -12
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.d.ts.map +0 -1
- package/transformRelativeMarkdownPaths/transformRelativeMarkdownPaths.js +0 -30
- package/transformTsToJs/index.d.ts +0 -1
- package/transformTsToJs/index.d.ts.map +0 -1
- package/transformTsToJs/index.js +0 -1
- package/transformTsToJs/removeTypes.d.ts +0 -13
- package/transformTsToJs/removeTypes.d.ts.map +0 -1
- package/transformTsToJs/removeTypes.js +0 -134
- package/transformTsToJs/transformTsToJs.d.ts +0 -3
- package/transformTsToJs/transformTsToJs.d.ts.map +0 -1
- package/transformTsToJs/transformTsToJs.js +0 -34
- package/useCode/index.d.ts +0 -1
- package/useCode/index.d.ts.map +0 -1
- package/useCode/index.js +0 -1
- package/useCode/useCode.d.ts.map +0 -1
- package/useCode/useCode.js +0 -442
- package/useDemo/index.d.ts.map +0 -1
- package/useOnHydrate/index.d.ts +0 -1
- package/useOnHydrate/index.d.ts.map +0 -1
- package/useOnHydrate/index.js +0 -1
- package/useOnHydrate/useOnHydrate.d.ts +0 -1
- package/useOnHydrate/useOnHydrate.d.ts.map +0 -1
- package/useOnHydrate/useOnHydrate.js +0 -18
- package/useOnIdle/index.d.ts +0 -1
- package/useOnIdle/index.d.ts.map +0 -1
- package/useOnIdle/index.js +0 -1
- package/useOnIdle/useOnIdle.d.ts +0 -1
- package/useOnIdle/useOnIdle.d.ts.map +0 -1
- package/useOnIdle/useOnIdle.js +0 -39
- /package/{useCopier → esm/useCopier}/index.d.ts.map +0 -0
|
@@ -1,719 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
6
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
7
|
-
import { transformSource } from "./transformSource.js";
|
|
8
|
-
import { transformParsedSource } from "./transformParsedSource.js";
|
|
9
|
-
import { getFileNameFromUrl } from "../loaderUtils/index.js";
|
|
10
|
-
// Helper function to check if we're in production
|
|
11
|
-
function isProduction() {
|
|
12
|
-
return typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Helper function to convert a nested key based on the directory of the source file key
|
|
16
|
-
function convertKeyBasedOnDirectory(nestedKey, sourceFileKey) {
|
|
17
|
-
// If it's an absolute path (starts with / or contains ://), keep as-is
|
|
18
|
-
if (nestedKey.startsWith('/') || nestedKey.includes('://')) {
|
|
19
|
-
return nestedKey;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Treat bare filenames as relative to current directory (same as ./filename)
|
|
23
|
-
var processedNestedKey = nestedKey;
|
|
24
|
-
if (!nestedKey.startsWith('.')) {
|
|
25
|
-
processedNestedKey = "./".concat(nestedKey);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Manual path resolution: resolve processedNestedKey relative to the directory of sourceFileKey
|
|
29
|
-
// Both paths are relative to the entry directory (which is always './') - ignore file:// URLs completely
|
|
30
|
-
|
|
31
|
-
// Get the directory of the source file key (not URL)
|
|
32
|
-
var sourceDir = sourceFileKey.includes('/') ? sourceFileKey.substring(0, sourceFileKey.lastIndexOf('/')) : '.';
|
|
33
|
-
|
|
34
|
-
// Parse both paths into components
|
|
35
|
-
var parsePathComponents = function parsePathComponents(path) {
|
|
36
|
-
if (path === '.' || path === '') {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
return path.split('/').filter(function (part) {
|
|
40
|
-
return part !== '';
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
var sourceDirComponents = parsePathComponents(sourceDir);
|
|
44
|
-
var nestedComponents = parsePathComponents(processedNestedKey);
|
|
45
|
-
|
|
46
|
-
// Start from the source directory and apply the nested path
|
|
47
|
-
var resultComponents = _toConsumableArray(sourceDirComponents);
|
|
48
|
-
|
|
49
|
-
// Apply each component of the nested path
|
|
50
|
-
var _iterator = _createForOfIteratorHelper(nestedComponents),
|
|
51
|
-
_step;
|
|
52
|
-
try {
|
|
53
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
54
|
-
var component = _step.value;
|
|
55
|
-
if (component === '..') {
|
|
56
|
-
if (resultComponents.length > 0 && resultComponents[resultComponents.length - 1] !== '..') {
|
|
57
|
-
// Normal case: pop a regular directory component
|
|
58
|
-
resultComponents.pop();
|
|
59
|
-
} else {
|
|
60
|
-
// Either resultComponents is empty OR the last component is already '..'
|
|
61
|
-
// In both cases, we need to go up one more level
|
|
62
|
-
resultComponents.push('..');
|
|
63
|
-
}
|
|
64
|
-
} else if (component === '.') {
|
|
65
|
-
// Current directory, skip
|
|
66
|
-
continue;
|
|
67
|
-
} else {
|
|
68
|
-
resultComponents.push(component);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Build the final result
|
|
73
|
-
} catch (err) {
|
|
74
|
-
_iterator.e(err);
|
|
75
|
-
} finally {
|
|
76
|
-
_iterator.f();
|
|
77
|
-
}
|
|
78
|
-
if (resultComponents.length === 0) {
|
|
79
|
-
return '';
|
|
80
|
-
}
|
|
81
|
-
var result = resultComponents.join('/');
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Normalize a relative path key by removing unnecessary ./ prefix
|
|
87
|
-
*/
|
|
88
|
-
function normalizePathKey(key) {
|
|
89
|
-
if (key.startsWith('./')) {
|
|
90
|
-
return key.substring(2);
|
|
91
|
-
}
|
|
92
|
-
return key;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Loads and processes extra files recursively with support for relative paths
|
|
97
|
-
* and circular dependency detection. Uses Promise.all for parallel loading.
|
|
98
|
-
*/
|
|
99
|
-
function loadSingleFile(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
|
|
100
|
-
return _loadSingleFile.apply(this, arguments);
|
|
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() {
|
|
107
|
-
_loadSingleFile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(variantName, fileName, source, url, loadSource, sourceParser, sourceTransformers, loadSourceCache, transforms) {
|
|
108
|
-
var options,
|
|
109
|
-
allFilesListed,
|
|
110
|
-
knownExtraFiles,
|
|
111
|
-
_options$disableTrans,
|
|
112
|
-
disableTransforms,
|
|
113
|
-
_options$disableParsi,
|
|
114
|
-
disableParsing,
|
|
115
|
-
finalSource,
|
|
116
|
-
extraFilesFromSource,
|
|
117
|
-
extraDependenciesFromSource,
|
|
118
|
-
loadPromise,
|
|
119
|
-
loadResult,
|
|
120
|
-
_i,
|
|
121
|
-
_Object$entries,
|
|
122
|
-
_Object$entries$_i,
|
|
123
|
-
extraFileName,
|
|
124
|
-
fileData,
|
|
125
|
-
_iterator2,
|
|
126
|
-
_step2,
|
|
127
|
-
dependency,
|
|
128
|
-
newFiles,
|
|
129
|
-
_i2,
|
|
130
|
-
_Object$keys,
|
|
131
|
-
extraFileKey,
|
|
132
|
-
message,
|
|
133
|
-
finalTransforms,
|
|
134
|
-
sourceString,
|
|
135
|
-
parseSource,
|
|
136
|
-
_args = arguments;
|
|
137
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
138
|
-
while (1) switch (_context.prev = _context.next) {
|
|
139
|
-
case 0:
|
|
140
|
-
options = _args.length > 9 && _args[9] !== undefined ? _args[9] : {};
|
|
141
|
-
allFilesListed = _args.length > 10 && _args[10] !== undefined ? _args[10] : false;
|
|
142
|
-
knownExtraFiles = _args.length > 11 && _args[11] !== undefined ? _args[11] : new Set();
|
|
143
|
-
_options$disableTrans = options.disableTransforms, disableTransforms = _options$disableTrans === void 0 ? false : _options$disableTrans, _options$disableParsi = options.disableParsing, disableParsing = _options$disableParsi === void 0 ? false : _options$disableParsi;
|
|
144
|
-
finalSource = source;
|
|
145
|
-
if (finalSource) {
|
|
146
|
-
_context.next = 67;
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
if (loadSource) {
|
|
150
|
-
_context.next = 8;
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
throw new Error('"loadSource" function is required when source is not provided');
|
|
154
|
-
case 8:
|
|
155
|
-
if (url) {
|
|
156
|
-
_context.next = 10;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
throw new Error('URL is required when loading source');
|
|
160
|
-
case 10:
|
|
161
|
-
_context.prev = 10;
|
|
162
|
-
// Check cache first to avoid duplicate loadSource calls
|
|
163
|
-
loadPromise = loadSourceCache.get(url);
|
|
164
|
-
if (!loadPromise) {
|
|
165
|
-
loadPromise = loadSource(url);
|
|
166
|
-
loadSourceCache.set(url, loadPromise);
|
|
167
|
-
}
|
|
168
|
-
_context.next = 15;
|
|
169
|
-
return loadPromise;
|
|
170
|
-
case 15:
|
|
171
|
-
loadResult = _context.sent;
|
|
172
|
-
finalSource = loadResult.source;
|
|
173
|
-
extraFilesFromSource = loadResult.extraFiles;
|
|
174
|
-
extraDependenciesFromSource = loadResult.extraDependencies;
|
|
175
|
-
|
|
176
|
-
// Validate that extraFiles from loadSource contain only absolute URLs as values
|
|
177
|
-
if (!extraFilesFromSource) {
|
|
178
|
-
_context.next = 30;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
_i = 0, _Object$entries = Object.entries(extraFilesFromSource);
|
|
182
|
-
case 21:
|
|
183
|
-
if (!(_i < _Object$entries.length)) {
|
|
184
|
-
_context.next = 30;
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), extraFileName = _Object$entries$_i[0], fileData = _Object$entries$_i[1];
|
|
188
|
-
if (!(extraFileName.includes('://') || extraFileName.startsWith('/'))) {
|
|
189
|
-
_context.next = 25;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
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.");
|
|
193
|
-
case 25:
|
|
194
|
-
if (!(typeof fileData === 'string' && fileData.startsWith('.'))) {
|
|
195
|
-
_context.next = 27;
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
throw new Error("Invalid extraFiles from loadSource: \"".concat(extraFileName, "\" has relative path \"").concat(fileData, "\". ") + "All extraFiles values must be absolute URLs.");
|
|
199
|
-
case 27:
|
|
200
|
-
_i++;
|
|
201
|
-
_context.next = 21;
|
|
202
|
-
break;
|
|
203
|
-
case 30:
|
|
204
|
-
if (!extraDependenciesFromSource) {
|
|
205
|
-
_context.next = 50;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
_iterator2 = _createForOfIteratorHelper(extraDependenciesFromSource);
|
|
209
|
-
_context.prev = 32;
|
|
210
|
-
_iterator2.s();
|
|
211
|
-
case 34:
|
|
212
|
-
if ((_step2 = _iterator2.n()).done) {
|
|
213
|
-
_context.next = 42;
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
dependency = _step2.value;
|
|
217
|
-
if (!dependency.startsWith('.')) {
|
|
218
|
-
_context.next = 38;
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
throw new Error("Invalid extraDependencies from loadSource: \"".concat(dependency, "\" is a relative path. ") + "All extraDependencies must be absolute URLs.");
|
|
222
|
-
case 38:
|
|
223
|
-
if (!(dependency === url)) {
|
|
224
|
-
_context.next = 40;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
throw new Error("Invalid extraDependencies from loadSource: \"".concat(dependency, "\" is the same as the input URL. ") + "extraDependencies should not include the file being loaded.");
|
|
228
|
-
case 40:
|
|
229
|
-
_context.next = 34;
|
|
230
|
-
break;
|
|
231
|
-
case 42:
|
|
232
|
-
_context.next = 47;
|
|
233
|
-
break;
|
|
234
|
-
case 44:
|
|
235
|
-
_context.prev = 44;
|
|
236
|
-
_context.t0 = _context["catch"](32);
|
|
237
|
-
_iterator2.e(_context.t0);
|
|
238
|
-
case 47:
|
|
239
|
-
_context.prev = 47;
|
|
240
|
-
_iterator2.f();
|
|
241
|
-
return _context.finish(47);
|
|
242
|
-
case 50:
|
|
243
|
-
if (!(allFilesListed && (extraFilesFromSource || extraDependenciesFromSource))) {
|
|
244
|
-
_context.next = 60;
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
newFiles = [];
|
|
248
|
-
if (extraFilesFromSource) {
|
|
249
|
-
// Check if any extraFiles keys are not in the known set
|
|
250
|
-
for (_i2 = 0, _Object$keys = Object.keys(extraFilesFromSource); _i2 < _Object$keys.length; _i2++) {
|
|
251
|
-
extraFileKey = _Object$keys[_i2];
|
|
252
|
-
if (!knownExtraFiles.has(extraFileKey)) {
|
|
253
|
-
newFiles.push(extraFileKey);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
if (!(newFiles.length > 0)) {
|
|
258
|
-
_context.next = 60;
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
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.";
|
|
262
|
-
if (!isProduction()) {
|
|
263
|
-
_context.next = 59;
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
console.warn(message);
|
|
267
|
-
_context.next = 60;
|
|
268
|
-
break;
|
|
269
|
-
case 59:
|
|
270
|
-
throw new Error(message);
|
|
271
|
-
case 60:
|
|
272
|
-
_context.next = 67;
|
|
273
|
-
break;
|
|
274
|
-
case 62:
|
|
275
|
-
_context.prev = 62;
|
|
276
|
-
_context.t1 = _context["catch"](10);
|
|
277
|
-
if (!(_context.t1 instanceof Error && (_context.t1.message.startsWith('Invalid extraFiles from loadSource:') || _context.t1.message.startsWith('Invalid extraDependencies from loadSource:') || _context.t1.message.startsWith('Unexpected files discovered via loadSource when allFilesListed=true')))) {
|
|
278
|
-
_context.next = 66;
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
throw _context.t1;
|
|
282
|
-
case 66:
|
|
283
|
-
throw new Error("Failed to load source code (variant: ".concat(variantName, ", file: ").concat(fileName, ", url: ").concat(url, "): ").concat(JSON.stringify(_context.t1)));
|
|
284
|
-
case 67:
|
|
285
|
-
// Apply source transformers if no transforms exist and transforms are not disabled
|
|
286
|
-
finalTransforms = transforms;
|
|
287
|
-
if (!(sourceTransformers && !finalTransforms && !disableTransforms && finalSource)) {
|
|
288
|
-
_context.next = 72;
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
_context.next = 71;
|
|
292
|
-
return transformSource(finalSource, normalizePathKey(fileName), sourceTransformers);
|
|
293
|
-
case 71:
|
|
294
|
-
finalTransforms = _context.sent;
|
|
295
|
-
case 72:
|
|
296
|
-
if (!(typeof finalSource === 'string' && !disableParsing)) {
|
|
297
|
-
_context.next = 90;
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
if (sourceParser) {
|
|
301
|
-
_context.next = 75;
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
throw new Error('"sourceParser" function is required when source is a string and parsing is not disabled');
|
|
305
|
-
case 75:
|
|
306
|
-
_context.prev = 75;
|
|
307
|
-
sourceString = finalSource;
|
|
308
|
-
_context.next = 79;
|
|
309
|
-
return sourceParser;
|
|
310
|
-
case 79:
|
|
311
|
-
parseSource = _context.sent;
|
|
312
|
-
finalSource = parseSource(finalSource, fileName);
|
|
313
|
-
if (!(finalTransforms && !disableTransforms)) {
|
|
314
|
-
_context.next = 85;
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
_context.next = 84;
|
|
318
|
-
return transformParsedSource(sourceString, finalSource, normalizePathKey(fileName), finalTransforms, parseSource);
|
|
319
|
-
case 84:
|
|
320
|
-
finalTransforms = _context.sent;
|
|
321
|
-
case 85:
|
|
322
|
-
_context.next = 90;
|
|
323
|
-
break;
|
|
324
|
-
case 87:
|
|
325
|
-
_context.prev = 87;
|
|
326
|
-
_context.t2 = _context["catch"](75);
|
|
327
|
-
throw new Error("Failed to parse source code (variant: ".concat(variantName, ", file: ").concat(fileName, ", url: ").concat(url, "): ").concat(_context.t2 instanceof Error ? _context.t2.message : ''));
|
|
328
|
-
case 90:
|
|
329
|
-
return _context.abrupt("return", {
|
|
330
|
-
source: finalSource,
|
|
331
|
-
transforms: finalTransforms,
|
|
332
|
-
extraFiles: extraFilesFromSource,
|
|
333
|
-
extraDependencies: extraDependenciesFromSource
|
|
334
|
-
});
|
|
335
|
-
case 91:
|
|
336
|
-
case "end":
|
|
337
|
-
return _context.stop();
|
|
338
|
-
}
|
|
339
|
-
}, _callee, null, [[10, 62], [32, 44, 47, 50], [75, 87]]);
|
|
340
|
-
}));
|
|
341
|
-
return _loadSingleFile.apply(this, arguments);
|
|
342
|
-
}
|
|
343
|
-
function loadExtraFiles(_x0, _x1, _x10, _x11, _x12, _x13, _x14, _x15) {
|
|
344
|
-
return _loadExtraFiles.apply(this, arguments);
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Loads a variant with support for recursive extra file loading.
|
|
348
|
-
* The loadSource function can now return extraFiles that will be loaded recursively.
|
|
349
|
-
* Supports both relative and absolute paths for extra files.
|
|
350
|
-
* Uses Promise.all for efficient parallel loading of extra files.
|
|
351
|
-
*/
|
|
352
|
-
function _loadExtraFiles() {
|
|
353
|
-
_loadExtraFiles = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(variantName, extraFiles, baseUrl, entryUrl,
|
|
354
|
-
// Track the original entry file URL
|
|
355
|
-
loadSource, sourceParser, sourceTransformers, loadSourceCache) {
|
|
356
|
-
var options,
|
|
357
|
-
allFilesListed,
|
|
358
|
-
knownExtraFiles,
|
|
359
|
-
_options$maxDepth,
|
|
360
|
-
maxDepth,
|
|
361
|
-
_options$loadedFiles,
|
|
362
|
-
loadedFiles,
|
|
363
|
-
processedExtraFiles,
|
|
364
|
-
allFilesUsed,
|
|
365
|
-
extraFilePromises,
|
|
366
|
-
extraFileResults,
|
|
367
|
-
nestedExtraFilesPromises,
|
|
368
|
-
_iterator3,
|
|
369
|
-
_step3,
|
|
370
|
-
_loop,
|
|
371
|
-
nestedExtraFilesResults,
|
|
372
|
-
_iterator4,
|
|
373
|
-
_step4,
|
|
374
|
-
_step4$value,
|
|
375
|
-
nestedExtraFiles,
|
|
376
|
-
nestedFilesUsed,
|
|
377
|
-
sourceFileKey,
|
|
378
|
-
_i3,
|
|
379
|
-
_Object$entries2,
|
|
380
|
-
_Object$entries2$_i,
|
|
381
|
-
nestedKey,
|
|
382
|
-
nestedValue,
|
|
383
|
-
convertedKey,
|
|
384
|
-
normalizedConvertedKey,
|
|
385
|
-
_args4 = arguments;
|
|
386
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
387
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
388
|
-
case 0:
|
|
389
|
-
options = _args4.length > 8 && _args4[8] !== undefined ? _args4[8] : {};
|
|
390
|
-
allFilesListed = _args4.length > 9 && _args4[9] !== undefined ? _args4[9] : false;
|
|
391
|
-
knownExtraFiles = _args4.length > 10 && _args4[10] !== undefined ? _args4[10] : new Set();
|
|
392
|
-
_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;
|
|
393
|
-
if (!(maxDepth <= 0)) {
|
|
394
|
-
_context4.next = 6;
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
throw new Error('Maximum recursion depth reached while loading extra files');
|
|
398
|
-
case 6:
|
|
399
|
-
processedExtraFiles = {};
|
|
400
|
-
allFilesUsed = []; // Start loading all extra files in parallel
|
|
401
|
-
extraFilePromises = Object.entries(extraFiles).map(/*#__PURE__*/function () {
|
|
402
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
403
|
-
var _ref3, fileName, fileData, fileUrl, sourceData, transforms, fileResult, filesUsedFromFile;
|
|
404
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
405
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
406
|
-
case 0:
|
|
407
|
-
_ref3 = _slicedToArray(_ref, 2), fileName = _ref3[0], fileData = _ref3[1];
|
|
408
|
-
_context2.prev = 1;
|
|
409
|
-
if (!(typeof fileData === 'string')) {
|
|
410
|
-
_context2.next = 9;
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
// fileData is a URL/path - use it directly, don't modify it
|
|
414
|
-
fileUrl = fileData;
|
|
415
|
-
|
|
416
|
-
// Check for circular dependencies
|
|
417
|
-
if (!loadedFiles.has(fileUrl)) {
|
|
418
|
-
_context2.next = 6;
|
|
419
|
-
break;
|
|
420
|
-
}
|
|
421
|
-
throw new Error("Circular dependency detected: ".concat(fileUrl));
|
|
422
|
-
case 6:
|
|
423
|
-
loadedFiles.add(fileUrl);
|
|
424
|
-
_context2.next = 12;
|
|
425
|
-
break;
|
|
426
|
-
case 9:
|
|
427
|
-
// fileData is an object with source and/or transforms
|
|
428
|
-
sourceData = fileData.source;
|
|
429
|
-
transforms = fileData.transforms;
|
|
430
|
-
fileUrl = baseUrl; // Use base URL as fallback
|
|
431
|
-
case 12:
|
|
432
|
-
_context2.next = 14;
|
|
433
|
-
return loadSingleFile(variantName, fileName, sourceData, fileUrl, loadSource, sourceParser, sourceTransformers, loadSourceCache, transforms, _objectSpread(_objectSpread({}, options), {}, {
|
|
434
|
-
maxDepth: maxDepth - 1,
|
|
435
|
-
loadedFiles: new Set(loadedFiles)
|
|
436
|
-
}), allFilesListed, knownExtraFiles);
|
|
437
|
-
case 14:
|
|
438
|
-
fileResult = _context2.sent;
|
|
439
|
-
// Collect files used from this file load
|
|
440
|
-
filesUsedFromFile = [];
|
|
441
|
-
if (typeof fileData === 'string') {
|
|
442
|
-
filesUsedFromFile.push(fileUrl);
|
|
443
|
-
}
|
|
444
|
-
if (fileResult.extraDependencies) {
|
|
445
|
-
filesUsedFromFile.push.apply(filesUsedFromFile, _toConsumableArray(fileResult.extraDependencies));
|
|
446
|
-
}
|
|
447
|
-
return _context2.abrupt("return", {
|
|
448
|
-
fileName: fileName,
|
|
449
|
-
result: fileResult,
|
|
450
|
-
filesUsed: filesUsedFromFile
|
|
451
|
-
});
|
|
452
|
-
case 21:
|
|
453
|
-
_context2.prev = 21;
|
|
454
|
-
_context2.t0 = _context2["catch"](1);
|
|
455
|
-
throw new Error("Failed to load extra file (variant: ".concat(variantName, ", file: ").concat(fileName, ", url: ").concat(baseUrl, "): ").concat(_context2.t0 instanceof Error ? _context2.t0.message : ''));
|
|
456
|
-
case 24:
|
|
457
|
-
case "end":
|
|
458
|
-
return _context2.stop();
|
|
459
|
-
}
|
|
460
|
-
}, _callee2, null, [[1, 21]]);
|
|
461
|
-
}));
|
|
462
|
-
return function (_x23) {
|
|
463
|
-
return _ref2.apply(this, arguments);
|
|
464
|
-
};
|
|
465
|
-
}()); // Wait for all extra files to load
|
|
466
|
-
_context4.next = 11;
|
|
467
|
-
return Promise.all(extraFilePromises);
|
|
468
|
-
case 11:
|
|
469
|
-
extraFileResults = _context4.sent;
|
|
470
|
-
// Process results and handle nested extra files
|
|
471
|
-
nestedExtraFilesPromises = [];
|
|
472
|
-
_iterator3 = _createForOfIteratorHelper(extraFileResults);
|
|
473
|
-
_context4.prev = 14;
|
|
474
|
-
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
475
|
-
var _step3$value, fileName, result, filesUsed, normalizedFileName, sourceFileUrl, fileData;
|
|
476
|
-
return _regeneratorRuntime().wrap(function _loop$(_context3) {
|
|
477
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
478
|
-
case 0:
|
|
479
|
-
_step3$value = _step3.value, fileName = _step3$value.fileName, result = _step3$value.result, filesUsed = _step3$value.filesUsed;
|
|
480
|
-
normalizedFileName = normalizePathKey(fileName);
|
|
481
|
-
processedExtraFiles[normalizedFileName] = {
|
|
482
|
-
source: result.source,
|
|
483
|
-
transforms: result.transforms
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
// Add files used from this file load
|
|
487
|
-
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(filesUsed));
|
|
488
|
-
|
|
489
|
-
// Collect promises for nested extra files with their source key
|
|
490
|
-
if (result.extraFiles) {
|
|
491
|
-
sourceFileUrl = baseUrl;
|
|
492
|
-
fileData = extraFiles[fileName];
|
|
493
|
-
if (typeof fileData === 'string') {
|
|
494
|
-
sourceFileUrl = fileData; // Use the URL directly, don't modify it
|
|
495
|
-
}
|
|
496
|
-
nestedExtraFilesPromises.push(loadExtraFiles(variantName, result.extraFiles, sourceFileUrl,
|
|
497
|
-
// Use the source file's URL as base for its extra files
|
|
498
|
-
entryUrl,
|
|
499
|
-
// Keep the entry URL for final conversion
|
|
500
|
-
loadSource, sourceParser, sourceTransformers, loadSourceCache, _objectSpread(_objectSpread({}, options), {}, {
|
|
501
|
-
maxDepth: maxDepth - 1,
|
|
502
|
-
loadedFiles: new Set(loadedFiles)
|
|
503
|
-
}), allFilesListed, knownExtraFiles).then(function (nestedResult) {
|
|
504
|
-
return {
|
|
505
|
-
files: nestedResult.extraFiles,
|
|
506
|
-
allFilesUsed: nestedResult.allFilesUsed,
|
|
507
|
-
sourceFileKey: normalizedFileName // Pass the normalized key
|
|
508
|
-
};
|
|
509
|
-
}));
|
|
510
|
-
}
|
|
511
|
-
case 5:
|
|
512
|
-
case "end":
|
|
513
|
-
return _context3.stop();
|
|
514
|
-
}
|
|
515
|
-
}, _loop);
|
|
516
|
-
});
|
|
517
|
-
_iterator3.s();
|
|
518
|
-
case 17:
|
|
519
|
-
if ((_step3 = _iterator3.n()).done) {
|
|
520
|
-
_context4.next = 21;
|
|
521
|
-
break;
|
|
522
|
-
}
|
|
523
|
-
return _context4.delegateYield(_loop(), "t0", 19);
|
|
524
|
-
case 19:
|
|
525
|
-
_context4.next = 17;
|
|
526
|
-
break;
|
|
527
|
-
case 21:
|
|
528
|
-
_context4.next = 26;
|
|
529
|
-
break;
|
|
530
|
-
case 23:
|
|
531
|
-
_context4.prev = 23;
|
|
532
|
-
_context4.t1 = _context4["catch"](14);
|
|
533
|
-
_iterator3.e(_context4.t1);
|
|
534
|
-
case 26:
|
|
535
|
-
_context4.prev = 26;
|
|
536
|
-
_iterator3.f();
|
|
537
|
-
return _context4.finish(26);
|
|
538
|
-
case 29:
|
|
539
|
-
if (!(nestedExtraFilesPromises.length > 0)) {
|
|
540
|
-
_context4.next = 35;
|
|
541
|
-
break;
|
|
542
|
-
}
|
|
543
|
-
_context4.next = 32;
|
|
544
|
-
return Promise.all(nestedExtraFilesPromises);
|
|
545
|
-
case 32:
|
|
546
|
-
nestedExtraFilesResults = _context4.sent;
|
|
547
|
-
_iterator4 = _createForOfIteratorHelper(nestedExtraFilesResults);
|
|
548
|
-
try {
|
|
549
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
550
|
-
_step4$value = _step4.value, nestedExtraFiles = _step4$value.files, nestedFilesUsed = _step4$value.allFilesUsed, sourceFileKey = _step4$value.sourceFileKey;
|
|
551
|
-
// Add nested files used
|
|
552
|
-
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(nestedFilesUsed));
|
|
553
|
-
for (_i3 = 0, _Object$entries2 = Object.entries(nestedExtraFiles); _i3 < _Object$entries2.length; _i3++) {
|
|
554
|
-
_Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2), nestedKey = _Object$entries2$_i[0], nestedValue = _Object$entries2$_i[1];
|
|
555
|
-
// Convert the key based on the directory structure of the source key
|
|
556
|
-
convertedKey = convertKeyBasedOnDirectory(nestedKey, sourceFileKey);
|
|
557
|
-
normalizedConvertedKey = normalizePathKey(convertedKey);
|
|
558
|
-
processedExtraFiles[normalizedConvertedKey] = nestedValue;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
} catch (err) {
|
|
562
|
-
_iterator4.e(err);
|
|
563
|
-
} finally {
|
|
564
|
-
_iterator4.f();
|
|
565
|
-
}
|
|
566
|
-
case 35:
|
|
567
|
-
return _context4.abrupt("return", {
|
|
568
|
-
extraFiles: processedExtraFiles,
|
|
569
|
-
allFilesUsed: allFilesUsed
|
|
570
|
-
});
|
|
571
|
-
case 36:
|
|
572
|
-
case "end":
|
|
573
|
-
return _context4.stop();
|
|
574
|
-
}
|
|
575
|
-
}, _callee3, null, [[14, 23, 26, 29]]);
|
|
576
|
-
}));
|
|
577
|
-
return _loadExtraFiles.apply(this, arguments);
|
|
578
|
-
}
|
|
579
|
-
export function loadVariant(_x16, _x17, _x18, _x19, _x20, _x21, _x22) {
|
|
580
|
-
return _loadVariant.apply(this, arguments);
|
|
581
|
-
}
|
|
582
|
-
function _loadVariant() {
|
|
583
|
-
_loadVariant = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url, variantName, variant, sourceParser, loadSource, loadVariantMeta, sourceTransformers) {
|
|
584
|
-
var options,
|
|
585
|
-
loadSourceCache,
|
|
586
|
-
loadedFiles,
|
|
587
|
-
allFilesUsed,
|
|
588
|
-
knownExtraFiles,
|
|
589
|
-
_i4,
|
|
590
|
-
_Object$keys2,
|
|
591
|
-
extraFileName,
|
|
592
|
-
mainFileResult,
|
|
593
|
-
allExtraFiles,
|
|
594
|
-
_i5,
|
|
595
|
-
_Object$keys3,
|
|
596
|
-
_extraFileName,
|
|
597
|
-
extraFilesToLoad,
|
|
598
|
-
extraFilesResult,
|
|
599
|
-
finalVariant,
|
|
600
|
-
_args5 = arguments;
|
|
601
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
602
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
603
|
-
case 0:
|
|
604
|
-
options = _args5.length > 7 && _args5[7] !== undefined ? _args5[7] : {};
|
|
605
|
-
if (variant) {
|
|
606
|
-
_context5.next = 3;
|
|
607
|
-
break;
|
|
608
|
-
}
|
|
609
|
-
throw new Error("Variant is missing from code: ".concat(variantName));
|
|
610
|
-
case 3:
|
|
611
|
-
// Create a cache for loadSource calls scoped to this loadVariant call
|
|
612
|
-
loadSourceCache = new Map();
|
|
613
|
-
if (!(typeof variant === 'string')) {
|
|
614
|
-
_context5.next = 18;
|
|
615
|
-
break;
|
|
616
|
-
}
|
|
617
|
-
if (loadVariantMeta) {
|
|
618
|
-
_context5.next = 9;
|
|
619
|
-
break;
|
|
620
|
-
}
|
|
621
|
-
// Create a basic loadVariantMeta function as fallback
|
|
622
|
-
variant = {
|
|
623
|
-
url: variant,
|
|
624
|
-
fileName: getFileNameFromUrl(variant).fileName
|
|
625
|
-
};
|
|
626
|
-
_context5.next = 18;
|
|
627
|
-
break;
|
|
628
|
-
case 9:
|
|
629
|
-
_context5.prev = 9;
|
|
630
|
-
_context5.next = 12;
|
|
631
|
-
return loadVariantMeta(variantName, variant);
|
|
632
|
-
case 12:
|
|
633
|
-
variant = _context5.sent;
|
|
634
|
-
_context5.next = 18;
|
|
635
|
-
break;
|
|
636
|
-
case 15:
|
|
637
|
-
_context5.prev = 15;
|
|
638
|
-
_context5.t0 = _context5["catch"](9);
|
|
639
|
-
throw new Error("Failed to load variant code (variant: ".concat(variantName, ", url: ").concat(variant, "): ").concat(JSON.stringify(_context5.t0)));
|
|
640
|
-
case 18:
|
|
641
|
-
loadedFiles = new Set();
|
|
642
|
-
loadedFiles.add(url);
|
|
643
|
-
allFilesUsed = [url]; // Start with the main file URL
|
|
644
|
-
// Build set of known extra files from variant definition
|
|
645
|
-
knownExtraFiles = new Set();
|
|
646
|
-
if (variant.extraFiles) {
|
|
647
|
-
for (_i4 = 0, _Object$keys2 = Object.keys(variant.extraFiles); _i4 < _Object$keys2.length; _i4++) {
|
|
648
|
-
extraFileName = _Object$keys2[_i4];
|
|
649
|
-
knownExtraFiles.add(extraFileName);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
// Load main file
|
|
654
|
-
_context5.next = 25;
|
|
655
|
-
return loadSingleFile(variantName, variant.fileName, variant.source, url, loadSource, sourceParser, sourceTransformers, loadSourceCache, variant.transforms, _objectSpread(_objectSpread({}, options), {}, {
|
|
656
|
-
loadedFiles: loadedFiles
|
|
657
|
-
}), variant.allFilesListed || false, knownExtraFiles);
|
|
658
|
-
case 25:
|
|
659
|
-
mainFileResult = _context5.sent;
|
|
660
|
-
// Add files used from main file loading
|
|
661
|
-
if (mainFileResult.extraDependencies) {
|
|
662
|
-
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(mainFileResult.extraDependencies));
|
|
663
|
-
}
|
|
664
|
-
allExtraFiles = {}; // Validate extraFiles keys from variant definition
|
|
665
|
-
if (!variant.extraFiles) {
|
|
666
|
-
_context5.next = 37;
|
|
667
|
-
break;
|
|
668
|
-
}
|
|
669
|
-
_i5 = 0, _Object$keys3 = Object.keys(variant.extraFiles);
|
|
670
|
-
case 30:
|
|
671
|
-
if (!(_i5 < _Object$keys3.length)) {
|
|
672
|
-
_context5.next = 37;
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
_extraFileName = _Object$keys3[_i5];
|
|
676
|
-
if (!(_extraFileName.includes('://') || _extraFileName.startsWith('/'))) {
|
|
677
|
-
_context5.next = 34;
|
|
678
|
-
break;
|
|
679
|
-
}
|
|
680
|
-
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.");
|
|
681
|
-
case 34:
|
|
682
|
-
_i5++;
|
|
683
|
-
_context5.next = 30;
|
|
684
|
-
break;
|
|
685
|
-
case 37:
|
|
686
|
-
// Collect extra files from variant definition and from loaded source
|
|
687
|
-
extraFilesToLoad = _objectSpread(_objectSpread({}, variant.extraFiles || {}), mainFileResult.extraFiles || {}); // Load all extra files if any exist
|
|
688
|
-
if (!(Object.keys(extraFilesToLoad).length > 0)) {
|
|
689
|
-
_context5.next = 44;
|
|
690
|
-
break;
|
|
691
|
-
}
|
|
692
|
-
_context5.next = 41;
|
|
693
|
-
return loadExtraFiles(variantName, extraFilesToLoad, url, url,
|
|
694
|
-
// Entry URL is the same as the main file URL
|
|
695
|
-
loadSource, sourceParser, sourceTransformers, loadSourceCache, _objectSpread(_objectSpread({}, options), {}, {
|
|
696
|
-
loadedFiles: loadedFiles
|
|
697
|
-
}), variant.allFilesListed || false, knownExtraFiles);
|
|
698
|
-
case 41:
|
|
699
|
-
extraFilesResult = _context5.sent;
|
|
700
|
-
allExtraFiles = extraFilesResult.extraFiles;
|
|
701
|
-
allFilesUsed.push.apply(allFilesUsed, _toConsumableArray(extraFilesResult.allFilesUsed));
|
|
702
|
-
case 44:
|
|
703
|
-
finalVariant = _objectSpread(_objectSpread({}, variant), {}, {
|
|
704
|
-
source: mainFileResult.source,
|
|
705
|
-
transforms: mainFileResult.transforms,
|
|
706
|
-
extraFiles: Object.keys(allExtraFiles).length > 0 ? allExtraFiles : undefined
|
|
707
|
-
});
|
|
708
|
-
return _context5.abrupt("return", {
|
|
709
|
-
code: finalVariant,
|
|
710
|
-
dependencies: Array.from(new Set(allFilesUsed)) // Remove duplicates
|
|
711
|
-
});
|
|
712
|
-
case 46:
|
|
713
|
-
case "end":
|
|
714
|
-
return _context5.stop();
|
|
715
|
-
}
|
|
716
|
-
}, _callee4, null, [[9, 15]]);
|
|
717
|
-
}));
|
|
718
|
-
return _loadVariant.apply(this, arguments);
|
|
719
|
-
}
|