@mui/internal-docs-infra 0.3.1-canary.3 → 0.3.1-canary.5

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.
Files changed (102) hide show
  1. package/esm/CodeControllerContext/CodeControllerContext.js +2 -2
  2. package/esm/CodeExternalsContext/CodeExternalsContext.js +1 -1
  3. package/esm/CodeHighlighter/CodeHighlighter.js +247 -329
  4. package/esm/CodeHighlighter/CodeHighlighterClient.js +447 -653
  5. package/esm/CodeHighlighter/CodeHighlighterContext.js +2 -2
  6. package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +2 -2
  7. package/esm/CodeHighlighter/codeToFallbackProps.js +21 -37
  8. package/esm/CodeHighlighter/errors.js +248 -400
  9. package/esm/CodeHighlighter/parseControlledCode.js +12 -20
  10. package/esm/CodeProvider/CodeContext.js +3 -3
  11. package/esm/CodeProvider/CodeProvider.js +31 -40
  12. package/esm/abstractCreateDemo/abstractCreateDemo.js +13 -17
  13. package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +12 -12
  14. package/esm/cli/index.js +1 -1
  15. package/esm/cli/runValidate.js +160 -264
  16. package/esm/createDemoData/createDemoData.js +11 -12
  17. package/esm/createSitemap/createSitemap.js +2 -2
  18. package/esm/pipeline/getFileConventions/fileConventions.js +1 -1
  19. package/esm/pipeline/getFileConventions/getFileConventions.js +2 -15
  20. package/esm/pipeline/hastUtils/hastUtils.js +16 -17
  21. package/esm/pipeline/loadCodeVariant/addCodeVariantPaths.js +24 -24
  22. package/esm/pipeline/loadCodeVariant/applyCodeTransform.js +12 -22
  23. package/esm/pipeline/loadCodeVariant/calculateMainFilePath.js +30 -37
  24. package/esm/pipeline/loadCodeVariant/computeHastDeltas.js +107 -185
  25. package/esm/pipeline/loadCodeVariant/diffHast.js +18 -53
  26. package/esm/pipeline/loadCodeVariant/examineCodeVariant.js +24 -27
  27. package/esm/pipeline/loadCodeVariant/flattenCodeVariant.js +9 -10
  28. package/esm/pipeline/loadCodeVariant/hasAllCodeVariants.js +5 -5
  29. package/esm/pipeline/loadCodeVariant/loadCodeFallback.js +516 -731
  30. package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +679 -1079
  31. package/esm/pipeline/loadCodeVariant/maybeCodeInitialData.js +14 -20
  32. package/esm/pipeline/loadCodeVariant/mergeCodeMetadata.js +53 -63
  33. package/esm/pipeline/loadCodeVariant/parseCode.js +40 -48
  34. package/esm/pipeline/loadCodeVariant/pathUtils.js +43 -64
  35. package/esm/pipeline/loadCodeVariant/transformSource.js +55 -125
  36. package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +160 -221
  37. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +377 -479
  38. package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +171 -173
  39. package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +14 -30
  40. package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +19 -21
  41. package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +37 -71
  42. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +3 -9
  43. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +54 -80
  44. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +71 -98
  45. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +5 -5
  46. package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +161 -211
  47. package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +159 -207
  48. package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +42 -64
  49. package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.js +20 -96
  50. package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +66 -85
  51. package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +71 -118
  52. package/esm/pipeline/loadServerSource/loadServerSource.js +121 -148
  53. package/esm/pipeline/loaderUtils/externalsToPackages.js +7 -7
  54. package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +8 -12
  55. package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +5 -5
  56. package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +19 -29
  57. package/esm/pipeline/loaderUtils/getLanguageFromExtension.js +3 -4
  58. package/esm/pipeline/loaderUtils/mergeExternals.js +15 -35
  59. package/esm/pipeline/loaderUtils/parseImportsAndComments.js +413 -433
  60. package/esm/pipeline/loaderUtils/processRelativeImports.js +153 -239
  61. package/esm/pipeline/loaderUtils/resolveModulePath.js +544 -1303
  62. package/esm/pipeline/loaderUtils/rewriteImports.js +73 -111
  63. package/esm/pipeline/parseSource/addLineGutters.js +33 -45
  64. package/esm/pipeline/parseSource/grammars.js +3 -3
  65. package/esm/pipeline/parseSource/parseSource.js +13 -31
  66. package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +32 -55
  67. package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +107 -160
  68. package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +846 -1033
  69. package/esm/pipeline/syncPageIndex/syncPageIndex.js +291 -438
  70. package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +213 -311
  71. package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +10 -10
  72. package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +133 -193
  73. package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +25 -27
  74. package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +572 -717
  75. package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +8 -8
  76. package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +84 -113
  77. package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +10 -26
  78. package/esm/useCode/Pre.js +58 -62
  79. package/esm/useCode/useCode.js +59 -61
  80. package/esm/useCode/useCodeUtils.js +54 -63
  81. package/esm/useCode/useCopyFunctionality.js +10 -9
  82. package/esm/useCode/useFileNavigation.js +150 -212
  83. package/esm/useCode/useSourceEditing.js +17 -14
  84. package/esm/useCode/useTransformManagement.js +23 -26
  85. package/esm/useCode/useUIState.js +12 -20
  86. package/esm/useCode/useVariantSelection.js +62 -79
  87. package/esm/useCopier/index.js +29 -56
  88. package/esm/useDemo/createCodeSandbox.js +12 -15
  89. package/esm/useDemo/createStackBlitz.js +14 -20
  90. package/esm/useDemo/exportVariant.js +200 -180
  91. package/esm/useDemo/exportVariantAsCra.js +22 -25
  92. package/esm/useDemo/useDemo.js +80 -84
  93. package/esm/useErrors/ErrorsContext.js +1 -1
  94. package/esm/useErrors/useErrors.js +3 -3
  95. package/esm/useLocalStorageState/useLocalStorageState.js +23 -39
  96. package/esm/usePreference/PreferencesProvider.js +1 -1
  97. package/esm/usePreference/usePreference.js +9 -11
  98. package/esm/useSearch/useSearch.js +290 -387
  99. package/esm/useUrlHashState/useUrlHashState.js +11 -14
  100. package/esm/withDocsInfra/withDeploymentConfig.js +26 -21
  101. package/esm/withDocsInfra/withDocsInfra.js +99 -101
  102. 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
- var delim = '-';
14
- var message = entry.name;
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
- var duration = Math.round(entry.duration).toString().padStart(4, ' ');
23
- console.warn("".concat(duration, "ms ").concat(delim, " ").concat(message));
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
- var performanceLogger = function performanceLogger(list) {
27
- var _iterator = _createForOfIteratorHelper(list.getEntries()),
28
- _step;
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
- var wrapper = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
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
- var wrapper = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
68
- var _context = _toArray(context),
69
- functionName = _context[0],
70
- restContext = _arrayLikeToArray(_context).slice(1);
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
- var hasOptions = demoCallInfo.hasOptions,
20
- argumentsStartIndex = demoCallInfo.argumentsStartIndex,
21
- argumentsEndIndex = demoCallInfo.argumentsEndIndex,
22
- structuredUrl = demoCallInfo.structuredUrl,
23
- structuredVariants = demoCallInfo.structuredVariants,
24
- structuredOptions = demoCallInfo.structuredOptions;
25
- var _options$passPrecompu = options.passPrecomputeAsIs,
26
- passPrecomputeAsIs = _options$passPrecompu === void 0 ? false : _options$passPrecompu;
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
- var newOptions = {};
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(function (_ref) {
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
- var args;
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
- var serializedArgs = serializeFunctionArguments(args);
65
+ const serializedArgs = serializeFunctionArguments(args);
68
66
 
69
67
  // Replace the arguments section
70
- var before = source.substring(0, argumentsStartIndex);
71
- var after = source.substring(argumentsEndIndex);
72
- return "".concat(before).concat(serializedArgs).concat(after);
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(function (arg) {
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
- var arrayCheck = isArray(arg);
29
+ const arrayCheck = isArray(arg);
34
30
  if (arrayCheck) {
35
- return "[".concat(arrayCheck.items.map(function (item) {
36
- return serializeArgument(item);
37
- }).join(', '), "]");
31
+ return `[${arrayCheck.items.map(item => serializeArgument(item)).join(', ')}]`;
38
32
  }
39
- var functionCheck = isFunction(arg);
33
+ const functionCheck = isFunction(arg);
40
34
  if (functionCheck) {
41
- var args = functionCheck.arguments.map(function (p) {
42
- return serializeArgument(p);
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
- var genericCheck = isGeneric(arg);
38
+ const genericCheck = isGeneric(arg);
47
39
  if (genericCheck) {
48
- var generics = genericCheck.generics.map(function (g) {
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 "".concat(genericCheck.name, "<").concat(generics, ">");
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
- var _args = genericCheck.arguments.map(function (p) {
58
- return serializeArgument(p);
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 "".concat(genericCheck.name, "<").concat(generics, ">");
51
+ return `${genericCheck.name}<${generics}>`;
64
52
  }
65
- var arrowCheck = isArrowFunction(arg);
53
+ const arrowCheck = isArrowFunction(arg);
66
54
  if (arrowCheck) {
67
- var _args2 = arrowCheck.args.map(function (p) {
68
- return serializeArgument(p);
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
- var _arrowCheck$types = _slicedToArray(arrowCheck.types, 2),
74
- inputTypes = _arrowCheck$types[0],
75
- outputTypes = _arrowCheck$types[1];
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 "".concat(argStr, " => ").concat(serializeArgument(arrowCheck.returnValue));
64
+ return `${argStr} => ${serializeArgument(arrowCheck.returnValue)}`;
81
65
  }
82
- var typeAssertionCheck = isTypeAssertion(arg);
66
+ const typeAssertionCheck = isTypeAssertion(arg);
83
67
  if (typeAssertionCheck) {
84
- return "".concat(serializeArgument(typeAssertionCheck.expression), " as ").concat(typeAssertionCheck.type);
68
+ return `${serializeArgument(typeAssertionCheck.expression)} as ${typeAssertionCheck.type}`;
85
69
  }
86
- var objectCheck = isObjectLiteral(arg);
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
- var doubleWrappedCheck = isArray(arg);
80
+ const doubleWrappedCheck = isArray(arg);
97
81
  if (doubleWrappedCheck) {
98
82
  // This is a double-wrapped array literal - unwrap it
99
- return "[".concat(arg[0].map(function (item) {
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 "[".concat(arg.map(function (item) {
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 (_typeof(arg) === 'object' && arg !== null) {
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
- var entries = Object.entries(obj).map(function (_ref) {
127
- var _ref2 = _slicedToArray(_ref, 2),
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 "".concat(key, ": ").concat(serializedValue);
113
+ return `${key}: ${serializedValue}`;
137
114
  });
138
- return "{ ".concat(entries.join(', '), " }");
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 "[".concat(value[0].map(function (item) {
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 (_typeof(value) === 'object' && value !== null && isStructuredType(value)) {
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 (_typeof(value) === 'object' && value !== null && !isStructuredType(value)) {
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 "[".concat(value[0].map(function (item) {
177
- return serializeObjectValue(item);
178
- }).join(', '), "]");
151
+ return `[${value[0].map(item => serializeObjectValue(item)).join(', ')}]`;
179
152
  }
180
153
  // Regular array
181
- return "[".concat(value.map(function (item) {
182
- return serializeObjectValue(item);
183
- }).join(', '), "]");
154
+ return `[${value.map(item => serializeObjectValue(item)).join(', ')}]`;
184
155
  }
185
- var pairs = Object.entries(value).map(function (_ref3) {
186
- var _ref4 = _slicedToArray(_ref3, 2),
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
- var runtimeExternals = {};
8
- for (var _i = 0, _Object$entries = Object.entries(externals); _i < _Object$entries.length; _i++) {
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
- var runtimeImports = imports.filter(function (importItem) {
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
- var wantsNumberedSuffix = type === 'namespace' || modulePath.startsWith('lib') && /^lib\d+$/.test(modulePath);
15
+ const wantsNumberedSuffix = type === 'namespace' || modulePath.startsWith('lib') && /^lib\d+$/.test(modulePath);
18
16
  if (wantsNumberedSuffix) {
19
17
  // Use numbered suffixes
20
- var attempt = 1;
21
- var _uniqueName = "".concat(originalName).concat(attempt);
22
- while (usedNames.has(_uniqueName)) {
18
+ let attempt = 1;
19
+ let uniqueName = `${originalName}${attempt}`;
20
+ while (usedNames.has(uniqueName)) {
23
21
  attempt += 1;
24
- _uniqueName = "".concat(originalName).concat(attempt);
22
+ uniqueName = `${originalName}${attempt}`;
25
23
  }
26
- return _uniqueName;
24
+ return uniqueName;
27
25
  }
28
26
 
29
27
  // For real modules, try module-based names first
30
- var moduleKey = modulePath.replace(/[@/.-]/g, '') // Remove special characters
28
+ const moduleKey = modulePath.replace(/[@/.-]/g, '') // Remove special characters
31
29
  .toLowerCase().slice(0, 20); // Limit length
32
30
 
33
- var uniqueName = "".concat(originalName).concat(moduleKey);
31
+ let uniqueName = `${originalName}${moduleKey}`;
34
32
 
35
33
  // If that's still taken, try numbered suffixes
36
34
  if (usedNames.has(uniqueName)) {
37
- var _attempt = 1;
35
+ let attempt = 1;
38
36
  do {
39
- uniqueName = "".concat(originalName).concat(_attempt);
40
- _attempt += 1;
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
- var moduleImports = {};
52
- var usedNames = new Set();
53
- var seenImports = new Set();
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 (var _i = 0, _Object$entries = Object.entries(externals); _i < _Object$entries.length; _i++) {
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
- var _iterator = _createForOfIteratorHelper(importItems),
67
- _step;
68
- try {
69
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
70
- var _step$value = _step.value,
71
- originalName = _step$value.name,
72
- type = _step$value.type,
73
- isType = _step$value.isType;
74
- // Skip type-only imports and empty names
75
- if (isType || !originalName.trim()) {
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
- // Skip duplicates
81
- if (seenImports.has(importKey)) {
82
- continue;
83
- }
84
- seenImports.add(importKey);
85
- var uniqueName = generateUniqueImportName(originalName, modulePath, type, usedNames);
86
- usedNames.add(uniqueName);
87
- if (type === 'default') {
88
- moduleImports[modulePath]["default"] = uniqueName;
89
- } else if (type === 'named') {
90
- moduleImports[modulePath].named.push({
91
- original: originalName,
92
- unique: uniqueName
93
- });
94
- } else if (type === 'namespace') {
95
- moduleImports[modulePath].namespace.push(uniqueName);
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
- var imports = [];
107
- for (var _i2 = 0, _Object$entries2 = Object.entries(moduleImports); _i2 < _Object$entries2.length; _i2++) {
108
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
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["default"]) {
115
- importParts.push(moduleImport["default"]);
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
- var namedImports = moduleImport.named.map(function (_ref) {
121
- var original = _ref.original,
122
- unique = _ref.unique;
123
- return original === unique ? original : "".concat(original, " as ").concat(unique);
124
- }).join(', ');
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("import ".concat(importParts.join(', '), " from '").concat(_modulePath, "';"));
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
- var _iterator2 = _createForOfIteratorHelper(moduleImport.namespace),
135
- _step2;
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;