@mui/internal-docs-infra 0.3.1-canary.3 → 0.3.1-canary.4
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/esm/CodeControllerContext/CodeControllerContext.js +2 -2
- package/esm/CodeExternalsContext/CodeExternalsContext.js +1 -1
- package/esm/CodeHighlighter/CodeHighlighter.js +247 -329
- package/esm/CodeHighlighter/CodeHighlighterClient.js +447 -653
- package/esm/CodeHighlighter/CodeHighlighterContext.js +2 -2
- package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +2 -2
- package/esm/CodeHighlighter/codeToFallbackProps.js +21 -37
- package/esm/CodeHighlighter/errors.js +248 -400
- package/esm/CodeHighlighter/parseControlledCode.js +12 -20
- package/esm/CodeProvider/CodeContext.js +3 -3
- package/esm/CodeProvider/CodeProvider.js +31 -40
- package/esm/abstractCreateDemo/abstractCreateDemo.js +13 -17
- package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +12 -12
- package/esm/cli/index.js +1 -1
- package/esm/cli/runValidate.js +160 -264
- package/esm/createDemoData/createDemoData.js +11 -12
- package/esm/createSitemap/createSitemap.js +2 -2
- package/esm/pipeline/getFileConventions/fileConventions.js +1 -1
- package/esm/pipeline/getFileConventions/getFileConventions.js +2 -15
- package/esm/pipeline/hastUtils/hastUtils.js +16 -17
- package/esm/pipeline/loadCodeVariant/addCodeVariantPaths.js +24 -24
- package/esm/pipeline/loadCodeVariant/applyCodeTransform.js +12 -22
- package/esm/pipeline/loadCodeVariant/calculateMainFilePath.js +30 -37
- package/esm/pipeline/loadCodeVariant/computeHastDeltas.js +107 -185
- package/esm/pipeline/loadCodeVariant/diffHast.js +18 -53
- package/esm/pipeline/loadCodeVariant/examineCodeVariant.js +24 -27
- package/esm/pipeline/loadCodeVariant/flattenCodeVariant.js +9 -10
- package/esm/pipeline/loadCodeVariant/hasAllCodeVariants.js +5 -5
- package/esm/pipeline/loadCodeVariant/loadCodeFallback.js +516 -731
- package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +679 -1079
- package/esm/pipeline/loadCodeVariant/maybeCodeInitialData.js +14 -20
- package/esm/pipeline/loadCodeVariant/mergeCodeMetadata.js +53 -63
- package/esm/pipeline/loadCodeVariant/parseCode.js +40 -48
- package/esm/pipeline/loadCodeVariant/pathUtils.js +43 -64
- package/esm/pipeline/loadCodeVariant/transformSource.js +55 -125
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +160 -221
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +377 -479
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +171 -173
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +14 -30
- package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +19 -21
- package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +37 -71
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +3 -9
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +54 -80
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +71 -98
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +5 -5
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +161 -211
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +159 -207
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +42 -64
- package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.js +20 -96
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +66 -85
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +71 -118
- package/esm/pipeline/loadServerSource/loadServerSource.js +121 -148
- package/esm/pipeline/loaderUtils/externalsToPackages.js +7 -7
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +8 -12
- package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +5 -5
- package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +19 -29
- package/esm/pipeline/loaderUtils/getLanguageFromExtension.js +3 -4
- package/esm/pipeline/loaderUtils/mergeExternals.js +15 -35
- package/esm/pipeline/loaderUtils/parseImportsAndComments.js +413 -433
- package/esm/pipeline/loaderUtils/processRelativeImports.js +153 -239
- package/esm/pipeline/loaderUtils/resolveModulePath.js +544 -1303
- package/esm/pipeline/loaderUtils/rewriteImports.js +73 -111
- package/esm/pipeline/parseSource/addLineGutters.js +33 -45
- package/esm/pipeline/parseSource/grammars.js +3 -3
- package/esm/pipeline/parseSource/parseSource.js +13 -31
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +32 -55
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +107 -160
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +846 -1033
- package/esm/pipeline/syncPageIndex/syncPageIndex.js +291 -438
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +213 -311
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +10 -10
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +133 -193
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +25 -27
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +572 -717
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +8 -8
- package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +84 -113
- package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +10 -26
- package/esm/useCode/Pre.js +58 -62
- package/esm/useCode/useCode.js +59 -61
- package/esm/useCode/useCodeUtils.js +54 -63
- package/esm/useCode/useCopyFunctionality.js +10 -9
- package/esm/useCode/useFileNavigation.js +150 -212
- package/esm/useCode/useSourceEditing.js +17 -14
- package/esm/useCode/useTransformManagement.js +23 -26
- package/esm/useCode/useUIState.js +12 -20
- package/esm/useCode/useVariantSelection.js +62 -79
- package/esm/useCopier/index.js +29 -56
- package/esm/useDemo/createCodeSandbox.js +12 -15
- package/esm/useDemo/createStackBlitz.js +14 -20
- package/esm/useDemo/exportVariant.js +200 -180
- package/esm/useDemo/exportVariantAsCra.js +22 -25
- package/esm/useDemo/useDemo.js +80 -84
- package/esm/useErrors/ErrorsContext.js +1 -1
- package/esm/useErrors/useErrors.js +3 -3
- package/esm/useLocalStorageState/useLocalStorageState.js +23 -39
- package/esm/usePreference/PreferencesProvider.js +1 -1
- package/esm/usePreference/usePreference.js +9 -11
- package/esm/useSearch/useSearch.js +290 -387
- package/esm/useUrlHashState/useUrlHashState.js +11 -14
- package/esm/withDocsInfra/withDeploymentConfig.js +26 -21
- package/esm/withDocsInfra/withDocsInfra.js +99 -101
- package/package.json +7 -4
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _arrayLikeToArray from "@babel/runtime/helpers/esm/arrayLikeToArray";
|
|
2
|
-
import _toArray from "@babel/runtime/helpers/esm/toArray";
|
|
3
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
1
|
export function logPerformance(entry, notableMs, showWrapperMeasures, filterContext) {
|
|
5
2
|
if (entry.duration < notableMs) {
|
|
6
3
|
return;
|
|
@@ -10,8 +7,8 @@ export function logPerformance(entry, notableMs, showWrapperMeasures, filterCont
|
|
|
10
7
|
if (filterContext && !entry.name.includes(filterContext)) {
|
|
11
8
|
return;
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
let delim = '-';
|
|
11
|
+
let message = entry.name;
|
|
15
12
|
if (message.startsWith('| ')) {
|
|
16
13
|
if (!showWrapperMeasures) {
|
|
17
14
|
return;
|
|
@@ -19,29 +16,19 @@ export function logPerformance(entry, notableMs, showWrapperMeasures, filterCont
|
|
|
19
16
|
delim = '|';
|
|
20
17
|
message = message.slice(2);
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
console.warn(
|
|
19
|
+
const duration = Math.round(entry.duration).toString().padStart(4, ' ');
|
|
20
|
+
console.warn(`${duration}ms ${delim} ${message}`);
|
|
24
21
|
}
|
|
25
22
|
export function createPerformanceLogger(notableMs, showWrapperMeasures, filterContext) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
31
|
-
var entry = _step.value;
|
|
32
|
-
logPerformance(entry, notableMs, showWrapperMeasures, filterContext);
|
|
33
|
-
}
|
|
34
|
-
} catch (err) {
|
|
35
|
-
_iterator.e(err);
|
|
36
|
-
} finally {
|
|
37
|
-
_iterator.f();
|
|
23
|
+
const performanceLogger = list => {
|
|
24
|
+
for (const entry of list.getEntries()) {
|
|
25
|
+
logPerformance(entry, notableMs, showWrapperMeasures, filterContext);
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
return performanceLogger;
|
|
41
29
|
}
|
|
42
|
-
export function nameMark(functionName, event, context) {
|
|
43
|
-
|
|
44
|
-
return "".concat(wrapper ? '| ' : '').concat(functionName, " ").concat(wrapper ? '|' : '-', " ").concat(event, " - ").concat(context.join(' - '));
|
|
30
|
+
export function nameMark(functionName, event, context, wrapper = false) {
|
|
31
|
+
return `${wrapper ? '| ' : ''}${functionName} ${wrapper ? '|' : '-'} ${event} - ${context.join(' - ')}`;
|
|
45
32
|
}
|
|
46
33
|
|
|
47
34
|
/**
|
|
@@ -63,14 +50,11 @@ export function nameMark(functionName, event, context) {
|
|
|
63
50
|
* );
|
|
64
51
|
* ```
|
|
65
52
|
*/
|
|
66
|
-
export function performanceMeasure(startMark, names, context) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var prefix = 'prefix' in names && names.prefix ? "".concat(names.prefix, " ") : '';
|
|
72
|
-
var markName = nameMark(functionName, "".concat(prefix).concat(names.mark), restContext, wrapper);
|
|
73
|
-
var measureName = nameMark(functionName, "".concat(prefix).concat(names.measure), restContext, wrapper);
|
|
53
|
+
export function performanceMeasure(startMark, names, context, wrapper = false) {
|
|
54
|
+
const [functionName, ...restContext] = context;
|
|
55
|
+
const prefix = 'prefix' in names && names.prefix ? `${names.prefix} ` : '';
|
|
56
|
+
const markName = nameMark(functionName, `${prefix}${names.mark}`, restContext, wrapper);
|
|
57
|
+
const measureName = nameMark(functionName, `${prefix}${names.measure}`, restContext, wrapper);
|
|
74
58
|
performance.mark(markName);
|
|
75
59
|
performance.measure(measureName, startMark, markName);
|
|
76
60
|
return markName;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import { serializeFunctionArguments } from "./serializeFunctionArguments.js";
|
|
3
2
|
/**
|
|
4
3
|
* Adds or replaces precompute data in createDemo function calls.
|
|
@@ -10,30 +9,29 @@ import { serializeFunctionArguments } from "./serializeFunctionArguments.js";
|
|
|
10
9
|
* @param options.passPrecomputeAsIs - Whether to pass precompute data as-is without JSON stringifying (default: false)
|
|
11
10
|
* @returns The modified source code with precompute data injected
|
|
12
11
|
*/
|
|
13
|
-
export function replacePrecomputeValue(source, precomputeData, demoCallInfo) {
|
|
14
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
12
|
+
export function replacePrecomputeValue(source, precomputeData, demoCallInfo, options = {}) {
|
|
15
13
|
// If no demoCallInfo provided, return unchanged
|
|
16
14
|
if (!demoCallInfo) {
|
|
17
15
|
return source;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
const {
|
|
18
|
+
hasOptions,
|
|
19
|
+
argumentsStartIndex,
|
|
20
|
+
argumentsEndIndex,
|
|
21
|
+
structuredUrl,
|
|
22
|
+
structuredVariants,
|
|
23
|
+
structuredOptions
|
|
24
|
+
} = demoCallInfo;
|
|
25
|
+
const {
|
|
26
|
+
passPrecomputeAsIs = false
|
|
27
|
+
} = options;
|
|
27
28
|
|
|
28
29
|
// Create new options object with precompute data
|
|
29
|
-
|
|
30
|
+
const newOptions = {};
|
|
30
31
|
|
|
31
32
|
// First, copy all existing options to preserve their order
|
|
32
33
|
if (hasOptions && structuredOptions) {
|
|
33
|
-
Object.entries(structuredOptions).forEach(
|
|
34
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
35
|
-
key = _ref2[0],
|
|
36
|
-
value = _ref2[1];
|
|
34
|
+
Object.entries(structuredOptions).forEach(([key, value]) => {
|
|
37
35
|
if (key !== 'precompute') {
|
|
38
36
|
// Skip existing precompute, we'll replace it
|
|
39
37
|
newOptions[key] = value;
|
|
@@ -45,7 +43,7 @@ export function replacePrecomputeValue(source, precomputeData, demoCallInfo) {
|
|
|
45
43
|
newOptions.precompute = passPrecomputeAsIs ? precomputeData : JSON.stringify(precomputeData, null, 2);
|
|
46
44
|
|
|
47
45
|
// Serialize all arguments using the standard function
|
|
48
|
-
|
|
46
|
+
let args;
|
|
49
47
|
|
|
50
48
|
// Build arguments array based on what's available
|
|
51
49
|
if (hasOptions || Object.keys(newOptions).length > 0) {
|
|
@@ -64,10 +62,10 @@ export function replacePrecomputeValue(source, precomputeData, demoCallInfo) {
|
|
|
64
62
|
// Only URL argument
|
|
65
63
|
args = [structuredUrl];
|
|
66
64
|
}
|
|
67
|
-
|
|
65
|
+
const serializedArgs = serializeFunctionArguments(args);
|
|
68
66
|
|
|
69
67
|
// Replace the arguments section
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
68
|
+
const before = source.substring(0, argumentsStartIndex);
|
|
69
|
+
const after = source.substring(argumentsEndIndex);
|
|
70
|
+
return `${before}${serializedArgs}${after}`;
|
|
73
71
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
1
|
/**
|
|
4
2
|
* Utility function for serializing structured function arguments back to string format
|
|
5
3
|
* This is the inverse of parseFunctionArguments - it takes structured data and creates
|
|
@@ -13,9 +11,7 @@ import { isArray, isFunction, isGeneric, isArrowFunction, isObjectLiteral, isTyp
|
|
|
13
11
|
* Uses JSON.stringify for object values for performance and reliability
|
|
14
12
|
*/
|
|
15
13
|
export function serializeFunctionArguments(args) {
|
|
16
|
-
return args.map(
|
|
17
|
-
return serializeArgument(arg);
|
|
18
|
-
}).join(', ');
|
|
14
|
+
return args.map(arg => serializeArgument(arg)).join(', ');
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
/**
|
|
@@ -30,60 +26,48 @@ function serializeArgument(arg) {
|
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
// Check structured types using type guards
|
|
33
|
-
|
|
29
|
+
const arrayCheck = isArray(arg);
|
|
34
30
|
if (arrayCheck) {
|
|
35
|
-
return
|
|
36
|
-
return serializeArgument(item);
|
|
37
|
-
}).join(', '), "]");
|
|
31
|
+
return `[${arrayCheck.items.map(item => serializeArgument(item)).join(', ')}]`;
|
|
38
32
|
}
|
|
39
|
-
|
|
33
|
+
const functionCheck = isFunction(arg);
|
|
40
34
|
if (functionCheck) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}).join(', ');
|
|
44
|
-
return "".concat(functionCheck.name, "(").concat(args, ")");
|
|
35
|
+
const args = functionCheck.arguments.map(p => serializeArgument(p)).join(', ');
|
|
36
|
+
return `${functionCheck.name}(${args})`;
|
|
45
37
|
}
|
|
46
|
-
|
|
38
|
+
const genericCheck = isGeneric(arg);
|
|
47
39
|
if (genericCheck) {
|
|
48
|
-
|
|
49
|
-
return serializeArgument(g);
|
|
50
|
-
}).join(', ');
|
|
40
|
+
const generics = genericCheck.generics.map(g => serializeArgument(g)).join(', ');
|
|
51
41
|
if (genericCheck.arguments === null) {
|
|
52
42
|
// Type generic like Theme<"dark" | "light">
|
|
53
|
-
return
|
|
43
|
+
return `${genericCheck.name}<${generics}>`;
|
|
54
44
|
}
|
|
55
45
|
// Function generic like Component<Props>(args) - only add () if there are actual arguments
|
|
56
46
|
if (genericCheck.arguments.length > 0) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}).join(', ');
|
|
60
|
-
return "".concat(genericCheck.name, "<").concat(generics, ">(").concat(_args, ")");
|
|
47
|
+
const args = genericCheck.arguments.map(p => serializeArgument(p)).join(', ');
|
|
48
|
+
return `${genericCheck.name}<${generics}>(${args})`;
|
|
61
49
|
}
|
|
62
50
|
// Generic without function call - like Component<Props>
|
|
63
|
-
return
|
|
51
|
+
return `${genericCheck.name}<${generics}>`;
|
|
64
52
|
}
|
|
65
|
-
|
|
53
|
+
const arrowCheck = isArrowFunction(arg);
|
|
66
54
|
if (arrowCheck) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}).join(', ');
|
|
70
|
-
var argStr = arrowCheck.args.length === 1 ? _args2 : "(".concat(_args2, ")");
|
|
55
|
+
const args = arrowCheck.args.map(p => serializeArgument(p)).join(', ');
|
|
56
|
+
const argStr = arrowCheck.args.length === 1 ? args : `(${args})`;
|
|
71
57
|
if (arrowCheck.types) {
|
|
72
58
|
// Typed arrow function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var inputTypeStr = Array.isArray(inputTypes) ? inputTypes.join(', ') : inputTypes;
|
|
77
|
-
return "(".concat(_args2, ": ").concat(inputTypeStr, "): ").concat(outputTypes, " => ").concat(serializeArgument(arrowCheck.returnValue));
|
|
59
|
+
const [inputTypes, outputTypes] = arrowCheck.types;
|
|
60
|
+
const inputTypeStr = Array.isArray(inputTypes) ? inputTypes.join(', ') : inputTypes;
|
|
61
|
+
return `(${args}: ${inputTypeStr}): ${outputTypes} => ${serializeArgument(arrowCheck.returnValue)}`;
|
|
78
62
|
}
|
|
79
63
|
// Simple arrow function
|
|
80
|
-
return
|
|
64
|
+
return `${argStr} => ${serializeArgument(arrowCheck.returnValue)}`;
|
|
81
65
|
}
|
|
82
|
-
|
|
66
|
+
const typeAssertionCheck = isTypeAssertion(arg);
|
|
83
67
|
if (typeAssertionCheck) {
|
|
84
|
-
return
|
|
68
|
+
return `${serializeArgument(typeAssertionCheck.expression)} as ${typeAssertionCheck.type}`;
|
|
85
69
|
}
|
|
86
|
-
|
|
70
|
+
const objectCheck = isObjectLiteral(arg);
|
|
87
71
|
if (objectCheck) {
|
|
88
72
|
return serializeObject(objectCheck.properties);
|
|
89
73
|
}
|
|
@@ -93,22 +77,18 @@ function serializeArgument(arg) {
|
|
|
93
77
|
// Check if this is a double-wrapped array literal from parseArrayLiteral
|
|
94
78
|
// parseArrayLiteral calls parseArgumentsRecursive which returns an array,
|
|
95
79
|
// so we get [[item1, item2]] instead of [item1, item2]
|
|
96
|
-
|
|
80
|
+
const doubleWrappedCheck = isArray(arg);
|
|
97
81
|
if (doubleWrappedCheck) {
|
|
98
82
|
// This is a double-wrapped array literal - unwrap it
|
|
99
|
-
return
|
|
100
|
-
return serializeArgument(item);
|
|
101
|
-
}).join(', '), "]");
|
|
83
|
+
return `[${arg[0].map(item => serializeArgument(item)).join(', ')}]`;
|
|
102
84
|
}
|
|
103
85
|
|
|
104
86
|
// Regular array
|
|
105
|
-
return
|
|
106
|
-
return serializeArgument(item);
|
|
107
|
-
}).join(', '), "]");
|
|
87
|
+
return `[${arg.map(item => serializeArgument(item)).join(', ')}]`;
|
|
108
88
|
}
|
|
109
89
|
|
|
110
90
|
// Object but not a structured type - serialize as object literal
|
|
111
|
-
if (
|
|
91
|
+
if (typeof arg === 'object' && arg !== null) {
|
|
112
92
|
return serializeObject(arg);
|
|
113
93
|
}
|
|
114
94
|
|
|
@@ -123,19 +103,16 @@ function serializeObject(obj) {
|
|
|
123
103
|
if (Object.keys(obj).length === 0) {
|
|
124
104
|
return '{}';
|
|
125
105
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
key = _ref2[0],
|
|
129
|
-
value = _ref2[1];
|
|
130
|
-
var serializedValue = serializeObjectValue(value);
|
|
106
|
+
const entries = Object.entries(obj).map(([key, value]) => {
|
|
107
|
+
const serializedValue = serializeObjectValue(value);
|
|
131
108
|
|
|
132
109
|
// Handle shorthand properties (key === value)
|
|
133
110
|
if (typeof value === 'string' && key === value) {
|
|
134
111
|
return key;
|
|
135
112
|
}
|
|
136
|
-
return
|
|
113
|
+
return `${key}: ${serializedValue}`;
|
|
137
114
|
});
|
|
138
|
-
return
|
|
115
|
+
return `{ ${entries.join(', ')} }`;
|
|
139
116
|
} /**
|
|
140
117
|
* Serialize an object value, using JSON.stringify when appropriate
|
|
141
118
|
*/
|
|
@@ -145,13 +122,11 @@ function serializeObjectValue(value) {
|
|
|
145
122
|
// This MUST come before the structured type check to prevent it being treated as a structured array
|
|
146
123
|
if (isArray(value)) {
|
|
147
124
|
// This is a double-wrapped array literal - unwrap it
|
|
148
|
-
return
|
|
149
|
-
return serializeObjectValue(item);
|
|
150
|
-
}).join(', '), "]");
|
|
125
|
+
return `[${value[0].map(item => serializeObjectValue(item)).join(', ')}]`;
|
|
151
126
|
}
|
|
152
127
|
|
|
153
128
|
// For structured types, recursively serialize first
|
|
154
|
-
if (
|
|
129
|
+
if (typeof value === 'object' && value !== null && isStructuredType(value)) {
|
|
155
130
|
return serializeArgument(value);
|
|
156
131
|
}
|
|
157
132
|
|
|
@@ -168,27 +143,18 @@ function serializeObjectValue(value) {
|
|
|
168
143
|
}
|
|
169
144
|
|
|
170
145
|
// For plain objects and arrays, serialize keys/values individually
|
|
171
|
-
if (
|
|
146
|
+
if (typeof value === 'object' && value !== null && !isStructuredType(value)) {
|
|
172
147
|
if (Array.isArray(value)) {
|
|
173
148
|
// Check if this is a double-wrapped array literal
|
|
174
149
|
if (isArray(value)) {
|
|
175
150
|
// This is a double-wrapped array literal - unwrap it
|
|
176
|
-
return
|
|
177
|
-
return serializeObjectValue(item);
|
|
178
|
-
}).join(', '), "]");
|
|
151
|
+
return `[${value[0].map(item => serializeObjectValue(item)).join(', ')}]`;
|
|
179
152
|
}
|
|
180
153
|
// Regular array
|
|
181
|
-
return
|
|
182
|
-
return serializeObjectValue(item);
|
|
183
|
-
}).join(', '), "]");
|
|
154
|
+
return `[${value.map(item => serializeObjectValue(item)).join(', ')}]`;
|
|
184
155
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
key = _ref4[0],
|
|
188
|
-
val = _ref4[1];
|
|
189
|
-
return "".concat(key, ": ").concat(serializeObjectValue(val));
|
|
190
|
-
});
|
|
191
|
-
return "{ ".concat(pairs.join(', '), " }");
|
|
156
|
+
const pairs = Object.entries(value).map(([key, val]) => `${key}: ${serializeObjectValue(val)}`);
|
|
157
|
+
return `{ ${pairs.join(', ')} }`;
|
|
192
158
|
}
|
|
193
159
|
|
|
194
160
|
// Fallback
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
/**
|
|
3
2
|
* Filters out type-only imports from externals since they don't exist at runtime.
|
|
4
3
|
* This is essential for client-side code where type imports are stripped during compilation.
|
|
5
4
|
*/
|
|
6
5
|
export function filterRuntimeExternals(externals) {
|
|
7
|
-
|
|
8
|
-
for (
|
|
9
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
10
|
-
modulePath = _Object$entries$_i[0],
|
|
11
|
-
imports = _Object$entries$_i[1];
|
|
6
|
+
const runtimeExternals = {};
|
|
7
|
+
for (const [modulePath, imports] of Object.entries(externals)) {
|
|
12
8
|
// Filter out imports where isType is true
|
|
13
|
-
|
|
14
|
-
return !importItem.isType;
|
|
15
|
-
});
|
|
9
|
+
const runtimeImports = imports.filter(importItem => !importItem.isType);
|
|
16
10
|
|
|
17
11
|
// Only include the module if it has runtime imports
|
|
18
12
|
if (runtimeImports.length > 0) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
1
|
/**
|
|
4
2
|
* Generates a unique import name based on module path and original name
|
|
5
3
|
*/
|
|
@@ -14,30 +12,30 @@ function generateUniqueImportName(originalName, modulePath, type, usedNames) {
|
|
|
14
12
|
// - Named imports from simple test cases (lib1, lib2, etc.): use numbered suffixes
|
|
15
13
|
// - Other cases: try module-based names first
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
const wantsNumberedSuffix = type === 'namespace' || modulePath.startsWith('lib') && /^lib\d+$/.test(modulePath);
|
|
18
16
|
if (wantsNumberedSuffix) {
|
|
19
17
|
// Use numbered suffixes
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
while (usedNames.has(
|
|
18
|
+
let attempt = 1;
|
|
19
|
+
let uniqueName = `${originalName}${attempt}`;
|
|
20
|
+
while (usedNames.has(uniqueName)) {
|
|
23
21
|
attempt += 1;
|
|
24
|
-
|
|
22
|
+
uniqueName = `${originalName}${attempt}`;
|
|
25
23
|
}
|
|
26
|
-
return
|
|
24
|
+
return uniqueName;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
// For real modules, try module-based names first
|
|
30
|
-
|
|
28
|
+
const moduleKey = modulePath.replace(/[@/.-]/g, '') // Remove special characters
|
|
31
29
|
.toLowerCase().slice(0, 20); // Limit length
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
let uniqueName = `${originalName}${moduleKey}`;
|
|
34
32
|
|
|
35
33
|
// If that's still taken, try numbered suffixes
|
|
36
34
|
if (usedNames.has(uniqueName)) {
|
|
37
|
-
|
|
35
|
+
let attempt = 1;
|
|
38
36
|
do {
|
|
39
|
-
uniqueName =
|
|
40
|
-
|
|
37
|
+
uniqueName = `${originalName}${attempt}`;
|
|
38
|
+
attempt += 1;
|
|
41
39
|
} while (usedNames.has(uniqueName));
|
|
42
40
|
}
|
|
43
41
|
return uniqueName;
|
|
@@ -48,100 +46,76 @@ function generateUniqueImportName(originalName, modulePath, type, usedNames) {
|
|
|
48
46
|
* Returns just the import lines needed to bring in the dependencies
|
|
49
47
|
*/
|
|
50
48
|
export function generateImportStatements(externals) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const moduleImports = {};
|
|
50
|
+
const usedNames = new Set();
|
|
51
|
+
const seenImports = new Set();
|
|
54
52
|
|
|
55
53
|
// First pass: collect all imports and resolve naming conflicts
|
|
56
|
-
for (
|
|
57
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
58
|
-
modulePath = _Object$entries$_i[0],
|
|
59
|
-
importItems = _Object$entries$_i[1];
|
|
54
|
+
for (const [modulePath, importItems] of Object.entries(externals)) {
|
|
60
55
|
if (!moduleImports[modulePath]) {
|
|
61
56
|
moduleImports[modulePath] = {
|
|
62
57
|
named: [],
|
|
63
58
|
namespace: []
|
|
64
59
|
};
|
|
65
60
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
var importKey = "".concat(modulePath, ":").concat(originalName, ":").concat(type);
|
|
61
|
+
for (const {
|
|
62
|
+
name: originalName,
|
|
63
|
+
type,
|
|
64
|
+
isType
|
|
65
|
+
} of importItems) {
|
|
66
|
+
// Skip type-only imports and empty names
|
|
67
|
+
if (isType || !originalName.trim()) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const importKey = `${modulePath}:${originalName}:${type}`;
|
|
79
71
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
72
|
+
// Skip duplicates
|
|
73
|
+
if (seenImports.has(importKey)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
seenImports.add(importKey);
|
|
77
|
+
const uniqueName = generateUniqueImportName(originalName, modulePath, type, usedNames);
|
|
78
|
+
usedNames.add(uniqueName);
|
|
79
|
+
if (type === 'default') {
|
|
80
|
+
moduleImports[modulePath].default = uniqueName;
|
|
81
|
+
} else if (type === 'named') {
|
|
82
|
+
moduleImports[modulePath].named.push({
|
|
83
|
+
original: originalName,
|
|
84
|
+
unique: uniqueName
|
|
85
|
+
});
|
|
86
|
+
} else if (type === 'namespace') {
|
|
87
|
+
moduleImports[modulePath].namespace.push(uniqueName);
|
|
97
88
|
}
|
|
98
|
-
} catch (err) {
|
|
99
|
-
_iterator.e(err);
|
|
100
|
-
} finally {
|
|
101
|
-
_iterator.f();
|
|
102
89
|
}
|
|
103
90
|
}
|
|
104
91
|
|
|
105
92
|
// Second pass: generate consolidated import statements
|
|
106
|
-
|
|
107
|
-
for (
|
|
108
|
-
|
|
109
|
-
_modulePath = _Object$entries2$_i[0],
|
|
110
|
-
moduleImport = _Object$entries2$_i[1];
|
|
111
|
-
var importParts = [];
|
|
93
|
+
const imports = [];
|
|
94
|
+
for (const [modulePath, moduleImport] of Object.entries(moduleImports)) {
|
|
95
|
+
const importParts = [];
|
|
112
96
|
|
|
113
97
|
// Add default import
|
|
114
|
-
if (moduleImport
|
|
115
|
-
importParts.push(moduleImport
|
|
98
|
+
if (moduleImport.default) {
|
|
99
|
+
importParts.push(moduleImport.default);
|
|
116
100
|
}
|
|
117
101
|
|
|
118
102
|
// Add named imports (consolidated into one statement)
|
|
119
103
|
if (moduleImport.named.length > 0) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
importParts.push("{ ".concat(namedImports, " }"));
|
|
104
|
+
const namedImports = moduleImport.named.map(({
|
|
105
|
+
original,
|
|
106
|
+
unique
|
|
107
|
+
}) => original === unique ? original : `${original} as ${unique}`).join(', ');
|
|
108
|
+
importParts.push(`{ ${namedImports} }`);
|
|
126
109
|
}
|
|
127
110
|
|
|
128
111
|
// Generate import statement
|
|
129
112
|
if (importParts.length > 0) {
|
|
130
|
-
imports.push(
|
|
113
|
+
imports.push(`import ${importParts.join(', ')} from '${modulePath}';`);
|
|
131
114
|
}
|
|
132
115
|
|
|
133
116
|
// Add namespace imports (separate statements as they can't be combined)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
138
|
-
var namespaceName = _step2.value;
|
|
139
|
-
imports.push("import * as ".concat(namespaceName, " from '").concat(_modulePath, "';"));
|
|
140
|
-
}
|
|
141
|
-
} catch (err) {
|
|
142
|
-
_iterator2.e(err);
|
|
143
|
-
} finally {
|
|
144
|
-
_iterator2.f();
|
|
117
|
+
for (const namespaceName of moduleImport.namespace) {
|
|
118
|
+
imports.push(`import * as ${namespaceName} from '${modulePath}';`);
|
|
145
119
|
}
|
|
146
120
|
}
|
|
147
121
|
return imports;
|