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