@mui/internal-docs-infra 0.1.1-alpha.9 → 0.1.1-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/esm/package.json +1 -0
- package/esm/useCopier/index.d.ts +15 -0
- package/esm/useCopier/index.d.ts.map +1 -0
- package/esm/useCopier/index.js +62 -0
- package/esm/useDemo/index.d.ts +51 -0
- package/esm/useDemo/index.d.ts.map +1 -0
- package/esm/useDemo/index.js +104 -0
- package/package.json +31 -32
- package/useCopier/index.d.ts +1 -1
- package/useCopier/index.js +23 -15
- package/useDemo/index.d.ts +51 -6
- package/useDemo/index.js +112 -6
- package/CodeControllerContext/CodeControllerContext.d.ts +0 -22
- package/CodeControllerContext/CodeControllerContext.d.ts.map +0 -1
- package/CodeControllerContext/CodeControllerContext.js +0 -14
- package/CodeControllerContext/index.d.ts +0 -1
- package/CodeControllerContext/index.d.ts.map +0 -1
- package/CodeControllerContext/index.js +0 -1
- package/CodeExternalsContext/CodeExternalsContext.d.ts +0 -8
- package/CodeExternalsContext/CodeExternalsContext.d.ts.map +0 -1
- package/CodeExternalsContext/CodeExternalsContext.js +0 -7
- package/CodeExternalsContext/index.d.ts +0 -1
- package/CodeExternalsContext/index.d.ts.map +0 -1
- package/CodeExternalsContext/index.js +0 -1
- package/CodeHighlighter/CodeHighlighter.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighter.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighter.js +0 -470
- package/CodeHighlighter/CodeHighlighterClient.d.ts +0 -2
- package/CodeHighlighter/CodeHighlighterClient.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterClient.js +0 -837
- package/CodeHighlighter/CodeHighlighterContext.d.ts +0 -16
- package/CodeHighlighter/CodeHighlighterContext.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterContext.js +0 -14
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts +0 -7
- package/CodeHighlighter/CodeHighlighterFallbackContext.d.ts.map +0 -1
- package/CodeHighlighter/CodeHighlighterFallbackContext.js +0 -13
- package/CodeHighlighter/applyTransform.d.ts +0 -19
- package/CodeHighlighter/applyTransform.d.ts.map +0 -1
- package/CodeHighlighter/applyTransform.js +0 -75
- package/CodeHighlighter/codeToFallbackProps.d.ts +0 -2
- package/CodeHighlighter/codeToFallbackProps.d.ts.map +0 -1
- package/CodeHighlighter/codeToFallbackProps.js +0 -73
- package/CodeHighlighter/errors.d.ts +0 -0
- package/CodeHighlighter/errors.d.ts.map +0 -1
- package/CodeHighlighter/errors.js +0 -1
- package/CodeHighlighter/hasAllVariants.d.ts +0 -2
- package/CodeHighlighter/hasAllVariants.d.ts.map +0 -1
- package/CodeHighlighter/hasAllVariants.js +0 -31
- package/CodeHighlighter/index.d.ts +0 -4
- package/CodeHighlighter/index.d.ts.map +0 -1
- package/CodeHighlighter/index.js +0 -4
- package/CodeHighlighter/loadFallbackCode.d.ts +0 -10
- package/CodeHighlighter/loadFallbackCode.d.ts.map +0 -1
- package/CodeHighlighter/loadFallbackCode.js +0 -632
- package/CodeHighlighter/loadVariant.d.ts +0 -12
- package/CodeHighlighter/loadVariant.d.ts.map +0 -1
- package/CodeHighlighter/loadVariant.js +0 -1083
- package/CodeHighlighter/maybeInitialData.d.ts +0 -10
- package/CodeHighlighter/maybeInitialData.d.ts.map +0 -1
- package/CodeHighlighter/maybeInitialData.js +0 -94
- package/CodeHighlighter/parseCode.d.ts +0 -6
- package/CodeHighlighter/parseCode.d.ts.map +0 -1
- package/CodeHighlighter/parseCode.js +0 -134
- package/CodeHighlighter/parseControlledCode.d.ts +0 -6
- package/CodeHighlighter/parseControlledCode.d.ts.map +0 -1
- package/CodeHighlighter/parseControlledCode.js +0 -87
- package/CodeHighlighter/transformCode.d.ts +0 -21
- package/CodeHighlighter/transformCode.d.ts.map +0 -1
- package/CodeHighlighter/transformCode.js +0 -263
- package/CodeHighlighter/transformParsedSource.d.ts +0 -3
- package/CodeHighlighter/transformParsedSource.d.ts.map +0 -1
- package/CodeHighlighter/transformParsedSource.js +0 -66
- package/CodeHighlighter/transformSource.d.ts +0 -2
- package/CodeHighlighter/transformSource.d.ts.map +0 -1
- package/CodeHighlighter/transformSource.js +0 -107
- package/CodeHighlighter/types.d.ts +0 -160
- package/CodeHighlighter/types.d.ts.map +0 -1
- package/CodeHighlighter/types.js +0 -1
- package/CodeProvider/CodeContext.d.ts +0 -12
- package/CodeProvider/CodeContext.d.ts.map +0 -1
- package/CodeProvider/CodeContext.js +0 -8
- package/CodeProvider/CodeProvider.d.ts +0 -13
- package/CodeProvider/CodeProvider.d.ts.map +0 -1
- package/CodeProvider/CodeProvider.js +0 -65
- package/CodeProvider/index.d.ts +0 -1
- package/CodeProvider/index.d.ts.map +0 -1
- package/CodeProvider/index.js +0 -1
- package/abstractCreateDemo/abstractCreateDemo.d.ts +0 -35
- package/abstractCreateDemo/abstractCreateDemo.d.ts.map +0 -1
- package/abstractCreateDemo/abstractCreateDemo.js +0 -91
- package/abstractCreateDemo/index.d.ts +0 -1
- package/abstractCreateDemo/index.d.ts.map +0 -1
- package/abstractCreateDemo/index.js +0 -1
- package/createDemoData/createDemoData.d.ts +0 -44
- package/createDemoData/createDemoData.d.ts.map +0 -1
- package/createDemoData/createDemoData.js +0 -75
- package/createDemoData/index.d.ts +0 -1
- package/createDemoData/index.d.ts.map +0 -1
- package/createDemoData/index.js +0 -1
- package/createDemoData/types.d.ts +0 -28
- package/createDemoData/types.d.ts.map +0 -1
- package/createDemoData/types.js +0 -1
- package/pipeline/hastUtils/hastUtils.d.ts +0 -11
- package/pipeline/hastUtils/hastUtils.d.ts.map +0 -1
- package/pipeline/hastUtils/hastUtils.js +0 -67
- package/pipeline/hastUtils/index.d.ts +0 -1
- package/pipeline/hastUtils/index.d.ts.map +0 -1
- package/pipeline/hastUtils/index.js +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts +0 -54
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/emitExternalsProvider.js +0 -465
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts +0 -15
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/generateExternalsProvider.js +0 -253
- package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts +0 -2
- package/pipeline/loadPrecomputedCodeHighlighter/index.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/index.js +0 -4
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +0 -20
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +0 -224
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +0 -31
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +0 -433
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts +0 -19
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.js +0 -168
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts +0 -25
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.d.ts.map +0 -1
- package/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +0 -73
- package/pipeline/loadServerCodeMeta/index.d.ts +0 -1
- package/pipeline/loadServerCodeMeta/index.d.ts.map +0 -1
- package/pipeline/loadServerCodeMeta/index.js +0 -1
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts +0 -24
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.d.ts.map +0 -1
- package/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +0 -92
- package/pipeline/loadServerSource/index.d.ts +0 -1
- package/pipeline/loadServerSource/index.d.ts.map +0 -1
- package/pipeline/loadServerSource/index.js +0 -1
- package/pipeline/loadServerSource/loadServerSource.d.ts +0 -25
- package/pipeline/loadServerSource/loadServerSource.d.ts.map +0 -1
- package/pipeline/loadServerSource/loadServerSource.js +0 -135
- package/pipeline/loaderUtils/externalsToPackages.d.ts +0 -1
- package/pipeline/loaderUtils/externalsToPackages.d.ts.map +0 -1
- package/pipeline/loaderUtils/externalsToPackages.js +0 -46
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts +0 -34
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.d.ts.map +0 -1
- package/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +0 -161
- package/pipeline/loaderUtils/getFileNameFromUrl.d.ts +0 -11
- package/pipeline/loaderUtils/getFileNameFromUrl.d.ts.map +0 -1
- package/pipeline/loaderUtils/getFileNameFromUrl.js +0 -32
- package/pipeline/loaderUtils/index.d.ts +0 -7
- package/pipeline/loaderUtils/index.d.ts.map +0 -1
- package/pipeline/loaderUtils/index.js +0 -7
- package/pipeline/loaderUtils/mergeExternals.d.ts +0 -32
- package/pipeline/loaderUtils/mergeExternals.d.ts.map +0 -1
- package/pipeline/loaderUtils/mergeExternals.js +0 -72
- package/pipeline/loaderUtils/parseImports.d.ts +0 -20
- package/pipeline/loaderUtils/parseImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/parseImports.js +0 -307
- package/pipeline/loaderUtils/processRelativeImports.d.ts +0 -19
- package/pipeline/loaderUtils/processRelativeImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/processRelativeImports.js +0 -329
- package/pipeline/loaderUtils/resolveModulePath.d.ts +0 -87
- package/pipeline/loaderUtils/resolveModulePath.d.ts.map +0 -1
- package/pipeline/loaderUtils/resolveModulePath.js +0 -1449
- package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +0 -47
- package/pipeline/loaderUtils/resolveModulePathWithFs.d.ts.map +0 -1
- package/pipeline/loaderUtils/resolveModulePathWithFs.js +0 -163
- package/pipeline/loaderUtils/rewriteImports.d.ts +0 -9
- package/pipeline/loaderUtils/rewriteImports.d.ts.map +0 -1
- package/pipeline/loaderUtils/rewriteImports.js +0 -35
- package/pipeline/parseSource/grammars.d.ts +0 -2
- package/pipeline/parseSource/grammars.d.ts.map +0 -1
- package/pipeline/parseSource/grammars.js +0 -27
- package/pipeline/parseSource/index.d.ts +0 -1
- package/pipeline/parseSource/index.d.ts.map +0 -1
- package/pipeline/parseSource/index.js +0 -1
- package/pipeline/parseSource/parseSource.d.ts +0 -3
- package/pipeline/parseSource/parseSource.d.ts.map +0 -1
- package/pipeline/parseSource/parseSource.js +0 -47
- package/pipeline/transformHtmlCode/index.d.ts +0 -2
- package/pipeline/transformHtmlCode/index.d.ts.map +0 -1
- package/pipeline/transformHtmlCode/index.js +0 -4
- package/pipeline/transformHtmlCode/transformHtmlCode.d.ts +0 -13
- package/pipeline/transformHtmlCode/transformHtmlCode.d.ts.map +0 -1
- package/pipeline/transformHtmlCode/transformHtmlCode.js +0 -303
- package/pipeline/transformMarkdownCode/index.d.ts +0 -2
- package/pipeline/transformMarkdownCode/index.d.ts.map +0 -1
- package/pipeline/transformMarkdownCode/index.js +0 -4
- package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts +0 -2
- package/pipeline/transformMarkdownCode/transformMarkdownCode.d.ts.map +0 -1
- package/pipeline/transformMarkdownCode/transformMarkdownCode.js +0 -514
- package/pipeline/transformTypescriptToJavascript/index.d.ts +0 -1
- package/pipeline/transformTypescriptToJavascript/index.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/index.js +0 -1
- package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts +0 -13
- package/pipeline/transformTypescriptToJavascript/removeTypes.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/removeTypes.js +0 -134
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts +0 -3
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.d.ts.map +0 -1
- package/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +0 -34
- package/useCode/index.d.ts +0 -1
- package/useCode/index.d.ts.map +0 -1
- package/useCode/index.js +0 -1
- package/useCode/useCode.d.ts +0 -39
- package/useCode/useCode.d.ts.map +0 -1
- package/useCode/useCode.js +0 -122
- package/useCode/useCodeUtils.d.ts +0 -45
- package/useCode/useCodeUtils.d.ts.map +0 -1
- package/useCode/useCodeUtils.js +0 -240
- package/useCode/useCopyFunctionality.d.ts +0 -17
- package/useCode/useCopyFunctionality.d.ts.map +0 -1
- package/useCode/useCopyFunctionality.js +0 -28
- package/useCode/useFileNavigation.d.ts +0 -48
- package/useCode/useFileNavigation.d.ts.map +0 -1
- package/useCode/useFileNavigation.js +0 -370
- package/useCode/useSourceEditing.d.ts +0 -19
- package/useCode/useSourceEditing.d.ts.map +0 -1
- package/useCode/useSourceEditing.js +0 -32
- package/useCode/useTransformManagement.d.ts +0 -28
- package/useCode/useTransformManagement.d.ts.map +0 -1
- package/useCode/useTransformManagement.js +0 -82
- package/useCode/useUIState.d.ts +0 -16
- package/useCode/useUIState.d.ts.map +0 -1
- package/useCode/useUIState.js +0 -21
- package/useCode/useVariantSelection.d.ts +0 -21
- package/useCode/useVariantSelection.d.ts.map +0 -1
- package/useCode/useVariantSelection.js +0 -84
- package/useCopier/index.d.ts.map +0 -1
- package/useDemo/createCodeSandbox.d.ts +0 -18
- package/useDemo/createCodeSandbox.d.ts.map +0 -1
- package/useDemo/createCodeSandbox.js +0 -48
- package/useDemo/createStackBlitz.d.ts +0 -22
- package/useDemo/createStackBlitz.d.ts.map +0 -1
- package/useDemo/createStackBlitz.js +0 -38
- package/useDemo/examineVariant.d.ts +0 -25
- package/useDemo/examineVariant.d.ts.map +0 -1
- package/useDemo/examineVariant.js +0 -134
- package/useDemo/exportVariant.d.ts +0 -110
- package/useDemo/exportVariant.d.ts.map +0 -1
- package/useDemo/exportVariant.js +0 -320
- package/useDemo/exportVariantAsCra.d.ts +0 -15
- package/useDemo/exportVariantAsCra.d.ts.map +0 -1
- package/useDemo/exportVariantAsCra.js +0 -56
- package/useDemo/flattenVariant.d.ts +0 -17
- package/useDemo/flattenVariant.d.ts.map +0 -1
- package/useDemo/flattenVariant.js +0 -206
- package/useDemo/index.d.ts.map +0 -1
- package/useDemo/useDemo.d.ts +0 -78
- package/useDemo/useDemo.d.ts.map +0 -1
- package/useDemo/useDemo.js +0 -174
- package/useLocalStorageState/index.d.ts +0 -2
- package/useLocalStorageState/index.d.ts.map +0 -1
- package/useLocalStorageState/index.js +0 -2
- package/useLocalStorageState/useLocalStorageState.d.ts +0 -14
- package/useLocalStorageState/useLocalStorageState.d.ts.map +0 -1
- package/useLocalStorageState/useLocalStorageState.js +0 -128
- package/useOnHydrate/index.d.ts +0 -1
- package/useOnHydrate/index.d.ts.map +0 -1
- package/useOnHydrate/index.js +0 -1
- package/useOnHydrate/useOnHydrate.d.ts +0 -1
- package/useOnHydrate/useOnHydrate.d.ts.map +0 -1
- package/useOnHydrate/useOnHydrate.js +0 -18
- package/useOnIdle/index.d.ts +0 -1
- package/useOnIdle/index.d.ts.map +0 -1
- package/useOnIdle/index.js +0 -1
- package/useOnIdle/useOnIdle.d.ts +0 -1
- package/useOnIdle/useOnIdle.d.ts.map +0 -1
- package/useOnIdle/useOnIdle.js +0 -39
- package/useUrlHashState/index.d.ts +0 -1
- package/useUrlHashState/index.d.ts.map +0 -1
- package/useUrlHashState/index.js +0 -1
- package/useUrlHashState/useUrlHashState.d.ts +0 -50
- package/useUrlHashState/useUrlHashState.d.ts.map +0 -1
- package/useUrlHashState/useUrlHashState.js +0 -113
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import { parseImports } from "../loaderUtils/index.js";
|
|
5
|
-
import { parseFunctionParameters, extractBalancedBraces } from "./parseFunctionParameters.js";
|
|
6
|
-
/**
|
|
7
|
-
* Helper function to convert the new parseImports format to a Map
|
|
8
|
-
* that maps import names to their resolved paths
|
|
9
|
-
*/
|
|
10
|
-
function buildImportMap(importResult) {
|
|
11
|
-
var importMap = new Map();
|
|
12
|
-
Object.values(importResult.relative).forEach(function (_ref) {
|
|
13
|
-
var path = _ref.path,
|
|
14
|
-
names = _ref.names;
|
|
15
|
-
names.forEach(function (_ref2) {
|
|
16
|
-
var name = _ref2.name,
|
|
17
|
-
alias = _ref2.alias;
|
|
18
|
-
// Use alias if available, otherwise use the original name
|
|
19
|
-
var nameToUse = alias || name;
|
|
20
|
-
importMap.set(nameToUse, path);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
return importMap;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Helper function to build a mapping from import aliases to their original named exports
|
|
28
|
-
*/
|
|
29
|
-
function buildNamedExportsMap(importResult) {
|
|
30
|
-
var namedExportsMap = new Map();
|
|
31
|
-
Object.values(importResult.relative).forEach(function (_ref3) {
|
|
32
|
-
var names = _ref3.names;
|
|
33
|
-
names.forEach(function (_ref4) {
|
|
34
|
-
var name = _ref4.name,
|
|
35
|
-
alias = _ref4.alias,
|
|
36
|
-
type = _ref4.type;
|
|
37
|
-
// Use alias if available, otherwise use the original name as key
|
|
38
|
-
var nameToUse = alias || name;
|
|
39
|
-
|
|
40
|
-
// Only map to the original export name for named imports
|
|
41
|
-
// Default imports should map to undefined since they don't have a specific named export
|
|
42
|
-
if (type === 'named') {
|
|
43
|
-
namedExportsMap.set(nameToUse, name);
|
|
44
|
-
} else {
|
|
45
|
-
namedExportsMap.set(nameToUse, undefined); // undefined for default/namespace imports
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
return namedExportsMap;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Parses a variants object string and maps variant names to their import paths
|
|
53
|
-
*/
|
|
54
|
-
function parseVariantsObject(variantsObjectStr, importMap, namedExportsMap, functionName, filePath) {
|
|
55
|
-
var demoImports = {};
|
|
56
|
-
var namedExports = {};
|
|
57
|
-
|
|
58
|
-
// Parse the demo object to extract key-value pairs
|
|
59
|
-
// Handle both { Default: BasicCode } and { Default } syntax
|
|
60
|
-
var objectContentRegex = /(\w+)(?:\s*:\s*(\w+))?/g;
|
|
61
|
-
var objectMatch = objectContentRegex.exec(variantsObjectStr);
|
|
62
|
-
while (objectMatch !== null) {
|
|
63
|
-
var _objectMatch = objectMatch,
|
|
64
|
-
_objectMatch2 = _slicedToArray(_objectMatch, 3),
|
|
65
|
-
key = _objectMatch2[1],
|
|
66
|
-
value = _objectMatch2[2];
|
|
67
|
-
var importName = value || key; // Use value if provided, otherwise use key (shorthand syntax)
|
|
68
|
-
|
|
69
|
-
if (importMap.has(importName)) {
|
|
70
|
-
demoImports[key] = importMap.get(importName);
|
|
71
|
-
namedExports[key] = namedExportsMap.get(importName);
|
|
72
|
-
} else {
|
|
73
|
-
// Throw error if any variant component is not imported
|
|
74
|
-
throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Component '".concat(importName, "' is not imported. Make sure to import it first."));
|
|
75
|
-
}
|
|
76
|
-
objectMatch = objectContentRegex.exec(variantsObjectStr);
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
variants: demoImports,
|
|
80
|
-
namedExports: namedExports
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Parses variants parameter which can be either an object literal or a single component identifier
|
|
86
|
-
*/
|
|
87
|
-
function parseVariantsParameter(variantsParam, importMap, namedExportsMap, functionName, filePath) {
|
|
88
|
-
var trimmed = variantsParam.trim();
|
|
89
|
-
|
|
90
|
-
// If it's an object literal, use existing logic
|
|
91
|
-
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
92
|
-
return parseVariantsObject(trimmed, importMap, namedExportsMap, functionName, filePath);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// If it's a single identifier, map it to "Default"
|
|
96
|
-
if (importMap.has(trimmed)) {
|
|
97
|
-
return {
|
|
98
|
-
variants: {
|
|
99
|
-
Default: importMap.get(trimmed)
|
|
100
|
-
},
|
|
101
|
-
namedExports: {
|
|
102
|
-
Default: namedExportsMap.get(trimmed)
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Throw error if the identifier is not found in imports
|
|
108
|
-
throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Component '".concat(trimmed, "' is not imported. Make sure to import it first."));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Validates that a URL parameter follows the expected convention
|
|
113
|
-
*/
|
|
114
|
-
function validateUrlParameter(url, functionName, filePath) {
|
|
115
|
-
var trimmedUrl = url.trim();
|
|
116
|
-
|
|
117
|
-
// Check for import.meta.url
|
|
118
|
-
if (trimmedUrl === 'import.meta.url') {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Check for CJS equivalent: require('url').pathToFileURL(__filename).toString()
|
|
123
|
-
// https://github.com/javiertury/babel-plugin-transform-import-meta#importmetaurl
|
|
124
|
-
var cjsPattern = /require\s*\(\s*['"`]url['"`]\s*\)\s*\.\s*pathToFileURL\s*\(\s*__filename\s*\)\s*\.\s*toString\s*\(\s*\)/;
|
|
125
|
-
if (cjsPattern.test(trimmedUrl)) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
throw new Error("Invalid URL parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected 'import.meta.url' or 'require('url').pathToFileURL(__filename).toString()' but got: ".concat(trimmedUrl));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Validates that a variants parameter is either an object mapping to imports or a single identifier
|
|
133
|
-
*/
|
|
134
|
-
function validateVariantsParameter(variantsParam, functionName, filePath) {
|
|
135
|
-
if (!variantsParam || variantsParam.trim() === '') {
|
|
136
|
-
throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object mapping variant names to imports or a single component identifier.");
|
|
137
|
-
}
|
|
138
|
-
var trimmed = variantsParam.trim();
|
|
139
|
-
|
|
140
|
-
// Check if it's an object literal
|
|
141
|
-
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
142
|
-
return; // Valid object literal
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Check if it's a valid identifier (single component)
|
|
146
|
-
if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(trimmed)) {
|
|
147
|
-
return; // Valid identifier
|
|
148
|
-
}
|
|
149
|
-
throw new Error("Invalid variants parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object mapping variant names to imports or a single component identifier, but got: ".concat(trimmed));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Parses a file to extract a single create* factory call and its variants and options
|
|
154
|
-
* Only supports one create* call per file - will throw an error if multiple are found
|
|
155
|
-
* Returns null if no create* call is found
|
|
156
|
-
*/
|
|
157
|
-
export function parseCreateFactoryCall(_x, _x2) {
|
|
158
|
-
return _parseCreateFactoryCall.apply(this, arguments);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Finds create* factory calls in code, handling multiline cases
|
|
163
|
-
*/
|
|
164
|
-
function _parseCreateFactoryCall() {
|
|
165
|
-
_parseCreateFactoryCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(code, filePath) {
|
|
166
|
-
var _yield$parseImports, importResult, externals, importMap, namedExportsMap, createFactoryMatches, match, functionName, fullMatch, urlParam, variantsParam, optionsObjectStr, hasOptions, url, _parseVariantsParamet, variants, namedExports, options, hasPrecompute, precomputeValue, precomputeKeyStart, precomputeValueStart, precomputeValueEnd, nameMatch, slugMatch, skipPrecomputeMatch, precomputeInfo, transformedExternals, _i, _Object$entries, _Object$entries$_i, modulePath, externalImport, live;
|
|
167
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
168
|
-
while (1) switch (_context.prev = _context.next) {
|
|
169
|
-
case 0:
|
|
170
|
-
_context.next = 2;
|
|
171
|
-
return parseImports(code, filePath);
|
|
172
|
-
case 2:
|
|
173
|
-
_yield$parseImports = _context.sent;
|
|
174
|
-
importResult = _yield$parseImports.relative;
|
|
175
|
-
externals = _yield$parseImports.externals;
|
|
176
|
-
importMap = buildImportMap({
|
|
177
|
-
relative: importResult,
|
|
178
|
-
externals: externals
|
|
179
|
-
});
|
|
180
|
-
namedExportsMap = buildNamedExportsMap({
|
|
181
|
-
relative: importResult,
|
|
182
|
-
externals: externals
|
|
183
|
-
}); // Find all create* calls in the code
|
|
184
|
-
createFactoryMatches = findCreateFactoryCalls(code, filePath); // Enforce single create* call per file
|
|
185
|
-
if (!(createFactoryMatches.length > 1)) {
|
|
186
|
-
_context.next = 10;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
throw new Error("Multiple create* factory calls found in ".concat(filePath, ". Only one create* call per file is supported. Found ").concat(createFactoryMatches.length, " calls."));
|
|
190
|
-
case 10:
|
|
191
|
-
if (!(createFactoryMatches.length === 0)) {
|
|
192
|
-
_context.next = 12;
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
return _context.abrupt("return", null);
|
|
196
|
-
case 12:
|
|
197
|
-
match = createFactoryMatches[0];
|
|
198
|
-
functionName = match.functionName, fullMatch = match.fullMatch, urlParam = match.urlParam, variantsParam = match.variantsParam, optionsObjectStr = match.optionsObjectStr, hasOptions = match.hasOptions; // Validate URL parameter
|
|
199
|
-
validateUrlParameter(urlParam, functionName, filePath);
|
|
200
|
-
|
|
201
|
-
// Validate variants parameter
|
|
202
|
-
validateVariantsParameter(variantsParam, functionName, filePath);
|
|
203
|
-
|
|
204
|
-
// Extract URL (typically import.meta.url)
|
|
205
|
-
url = urlParam.trim(); // Resolve variants for this specific create* call
|
|
206
|
-
_parseVariantsParamet = parseVariantsParameter(variantsParam, importMap, namedExportsMap, functionName, filePath), variants = _parseVariantsParamet.variants, namedExports = _parseVariantsParamet.namedExports; // Parse options object
|
|
207
|
-
options = {};
|
|
208
|
-
hasPrecompute = false;
|
|
209
|
-
// Extract name
|
|
210
|
-
nameMatch = optionsObjectStr.match(/name\s*:\s*['"`]([^'"`]+)['"`]/);
|
|
211
|
-
if (nameMatch) {
|
|
212
|
-
options.name = nameMatch[1];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Extract slug
|
|
216
|
-
slugMatch = optionsObjectStr.match(/slug\s*:\s*['"`]([^'"`]+)['"`]/);
|
|
217
|
-
if (slugMatch) {
|
|
218
|
-
options.slug = slugMatch[1];
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Extract skipPrecompute
|
|
222
|
-
skipPrecomputeMatch = optionsObjectStr.match(/skipPrecompute\s*:\s*(true|false)/);
|
|
223
|
-
if (skipPrecomputeMatch) {
|
|
224
|
-
options.skipPrecompute = skipPrecomputeMatch[1] === 'true';
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Extract precompute value using robust parsing
|
|
228
|
-
precomputeInfo = extractPrecomputeFromOptions(optionsObjectStr);
|
|
229
|
-
if (precomputeInfo) {
|
|
230
|
-
hasPrecompute = true;
|
|
231
|
-
precomputeKeyStart = precomputeInfo.keyStart;
|
|
232
|
-
precomputeValueStart = precomputeInfo.valueStart;
|
|
233
|
-
precomputeValueEnd = precomputeInfo.valueEnd;
|
|
234
|
-
precomputeValue = precomputeInfo.value;
|
|
235
|
-
options.precompute = precomputeValue;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Transform externals from parseImports format to simplified format
|
|
239
|
-
// Only include side-effect imports (where names array is empty)
|
|
240
|
-
transformedExternals = {};
|
|
241
|
-
for (_i = 0, _Object$entries = Object.entries(externals); _i < _Object$entries.length; _i++) {
|
|
242
|
-
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), modulePath = _Object$entries$_i[0], externalImport = _Object$entries$_i[1];
|
|
243
|
-
// Only include side-effect imports (empty names array)
|
|
244
|
-
if (externalImport.names.length === 0) {
|
|
245
|
-
transformedExternals[modulePath] = []; // Empty array for side-effect imports
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Detect if this is a live demo based on function name containing "Live" as a distinct component
|
|
250
|
-
// This catches: createLive, createLiveDemo, createDemoLive, etc.
|
|
251
|
-
// But avoids false positives like: createDelivery, delivery, etc.
|
|
252
|
-
live = /Live/.test(functionName);
|
|
253
|
-
return _context.abrupt("return", {
|
|
254
|
-
functionName: functionName,
|
|
255
|
-
url: url,
|
|
256
|
-
variants: variants,
|
|
257
|
-
namedExports: namedExports,
|
|
258
|
-
options: options,
|
|
259
|
-
fullMatch: fullMatch,
|
|
260
|
-
variantsObjectStr: variantsParam,
|
|
261
|
-
optionsObjectStr: optionsObjectStr,
|
|
262
|
-
hasOptions: hasOptions,
|
|
263
|
-
hasPrecompute: hasPrecompute,
|
|
264
|
-
precomputeValue: hasPrecompute ? precomputeValue : undefined,
|
|
265
|
-
externals: transformedExternals,
|
|
266
|
-
live: live,
|
|
267
|
-
precomputeKeyStart: hasPrecompute ? precomputeKeyStart : undefined,
|
|
268
|
-
precomputeValueStart: hasPrecompute ? precomputeValueStart : undefined,
|
|
269
|
-
precomputeValueEnd: hasPrecompute ? precomputeValueEnd : undefined
|
|
270
|
-
});
|
|
271
|
-
case 32:
|
|
272
|
-
case "end":
|
|
273
|
-
return _context.stop();
|
|
274
|
-
}
|
|
275
|
-
}, _callee);
|
|
276
|
-
}));
|
|
277
|
-
return _parseCreateFactoryCall.apply(this, arguments);
|
|
278
|
-
}
|
|
279
|
-
function findCreateFactoryCalls(code, filePath) {
|
|
280
|
-
var results = [];
|
|
281
|
-
|
|
282
|
-
// Find all create* function calls
|
|
283
|
-
var createFactoryRegex = /\b(create\w*)\s*\(/g;
|
|
284
|
-
var match = createFactoryRegex.exec(code);
|
|
285
|
-
while (match !== null) {
|
|
286
|
-
var functionName = match[1];
|
|
287
|
-
var startIndex = match.index;
|
|
288
|
-
var parenIndex = match.index + match[0].length - 1; // Position of opening parenthesis
|
|
289
|
-
|
|
290
|
-
// Find the matching closing parenthesis
|
|
291
|
-
var parenCount = 0;
|
|
292
|
-
var endIndex = -1;
|
|
293
|
-
for (var i = parenIndex; i < code.length; i += 1) {
|
|
294
|
-
if (code[i] === '(') {
|
|
295
|
-
parenCount += 1;
|
|
296
|
-
} else if (code[i] === ')') {
|
|
297
|
-
parenCount -= 1;
|
|
298
|
-
if (parenCount === 0) {
|
|
299
|
-
endIndex = i;
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
if (endIndex === -1) {
|
|
305
|
-
match = createFactoryRegex.exec(code);
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
var fullMatch = code.substring(startIndex, endIndex + 1);
|
|
309
|
-
var content = code.substring(parenIndex + 1, endIndex);
|
|
310
|
-
|
|
311
|
-
// Split by commas at the top level, handling nested structures and comments
|
|
312
|
-
var _parseFunctionParamet = parseFunctionParameters(content),
|
|
313
|
-
parts = _parseFunctionParamet.parts,
|
|
314
|
-
objects = _parseFunctionParamet.objects;
|
|
315
|
-
|
|
316
|
-
// Validate the function follows the convention
|
|
317
|
-
if (parts.length < 2 || parts.length > 3) {
|
|
318
|
-
throw new Error("Invalid ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected 2-3 parameters (url, variants, options?) but got ".concat(parts.length, " parameters. ") + "Functions starting with 'create' must follow the convention: create*(url, variants, options?)");
|
|
319
|
-
}
|
|
320
|
-
if (parts.length === 2) {
|
|
321
|
-
var _parts = _slicedToArray(parts, 1),
|
|
322
|
-
urlParam = _parts[0];
|
|
323
|
-
|
|
324
|
-
// The variants parameter can be either an object literal or a single identifier
|
|
325
|
-
var variantsParam = objects[1] || parts[1].trim();
|
|
326
|
-
results.push({
|
|
327
|
-
functionName: functionName,
|
|
328
|
-
fullMatch: fullMatch,
|
|
329
|
-
urlParam: urlParam.trim(),
|
|
330
|
-
variantsParam: variantsParam,
|
|
331
|
-
optionsObjectStr: '{}',
|
|
332
|
-
// Default empty options
|
|
333
|
-
hasOptions: false // No options parameter was provided
|
|
334
|
-
});
|
|
335
|
-
} else if (parts.length === 3) {
|
|
336
|
-
var _parts2 = _slicedToArray(parts, 1),
|
|
337
|
-
_urlParam = _parts2[0];
|
|
338
|
-
|
|
339
|
-
// The variants parameter can be either an object literal or a single identifier
|
|
340
|
-
var _variantsParam = objects[1] || parts[1].trim();
|
|
341
|
-
var optionsObjectStr = objects[2];
|
|
342
|
-
if (!optionsObjectStr) {
|
|
343
|
-
throw new Error("Invalid options parameter in ".concat(functionName, " call in ").concat(filePath, ". ") + "Expected an object but could not parse: ".concat(parts[2].trim()));
|
|
344
|
-
}
|
|
345
|
-
results.push({
|
|
346
|
-
functionName: functionName,
|
|
347
|
-
fullMatch: fullMatch,
|
|
348
|
-
urlParam: _urlParam.trim(),
|
|
349
|
-
variantsParam: _variantsParam,
|
|
350
|
-
optionsObjectStr: optionsObjectStr,
|
|
351
|
-
hasOptions: true // Options parameter was provided
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
match = createFactoryRegex.exec(code);
|
|
355
|
-
}
|
|
356
|
-
return results;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Extracts precompute property from options object using robust parsing
|
|
361
|
-
*/
|
|
362
|
-
function extractPrecomputeFromOptions(optionsObjectStr) {
|
|
363
|
-
// Find the precompute property using regex
|
|
364
|
-
var precomputeMatch = optionsObjectStr.match(/precompute\s*:\s*/);
|
|
365
|
-
if (!precomputeMatch) {
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
var keyStart = precomputeMatch.index;
|
|
369
|
-
var valueStartIndex = keyStart + precomputeMatch[0].length;
|
|
370
|
-
|
|
371
|
-
// Extract the remaining part after "precompute:"
|
|
372
|
-
var remainingStr = optionsObjectStr.substring(valueStartIndex);
|
|
373
|
-
|
|
374
|
-
// Try to extract a balanced object first
|
|
375
|
-
var objectValue = extractBalancedBraces(remainingStr);
|
|
376
|
-
if (objectValue) {
|
|
377
|
-
// It's an object value
|
|
378
|
-
var _actualValueStart = valueStartIndex;
|
|
379
|
-
while (_actualValueStart < optionsObjectStr.length && /\s/.test(optionsObjectStr[_actualValueStart])) {
|
|
380
|
-
_actualValueStart += 1;
|
|
381
|
-
}
|
|
382
|
-
var _valueEnd = _actualValueStart + objectValue.length;
|
|
383
|
-
return {
|
|
384
|
-
keyStart: keyStart,
|
|
385
|
-
valueStart: _actualValueStart,
|
|
386
|
-
valueEnd: _valueEnd,
|
|
387
|
-
value: objectValue // Keep object as string
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// It's a simple value (true, false, etc.)
|
|
392
|
-
// Parse until comma, newline, or closing brace
|
|
393
|
-
var i = 0;
|
|
394
|
-
var inString = false;
|
|
395
|
-
var stringChar = '';
|
|
396
|
-
while (i < remainingStr.length) {
|
|
397
|
-
var _char = remainingStr[i];
|
|
398
|
-
if (!inString && (_char === '"' || _char === "'" || _char === '`')) {
|
|
399
|
-
inString = true;
|
|
400
|
-
stringChar = _char;
|
|
401
|
-
} else if (inString && _char === stringChar && remainingStr[i - 1] !== '\\') {
|
|
402
|
-
inString = false;
|
|
403
|
-
stringChar = '';
|
|
404
|
-
} else if (!inString && (_char === ',' || _char === '}' || _char === '\n')) {
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
i += 1;
|
|
408
|
-
}
|
|
409
|
-
var valueStr = remainingStr.substring(0, i).trim();
|
|
410
|
-
|
|
411
|
-
// Calculate precise boundaries
|
|
412
|
-
var actualValueStart = valueStartIndex;
|
|
413
|
-
while (actualValueStart < optionsObjectStr.length && /\s/.test(optionsObjectStr[actualValueStart])) {
|
|
414
|
-
actualValueStart += 1;
|
|
415
|
-
}
|
|
416
|
-
var valueEnd = actualValueStart + valueStr.length;
|
|
417
|
-
|
|
418
|
-
// Parse the value
|
|
419
|
-
var parsedValue;
|
|
420
|
-
if (valueStr === 'true') {
|
|
421
|
-
parsedValue = true;
|
|
422
|
-
} else if (valueStr === 'false') {
|
|
423
|
-
parsedValue = false;
|
|
424
|
-
} else {
|
|
425
|
-
parsedValue = valueStr;
|
|
426
|
-
}
|
|
427
|
-
return {
|
|
428
|
-
keyStart: keyStart,
|
|
429
|
-
valueStart: actualValueStart,
|
|
430
|
-
valueEnd: valueEnd,
|
|
431
|
-
value: parsedValue
|
|
432
|
-
};
|
|
433
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility function for parsing function parameters and handling nested structures
|
|
3
|
-
* in JavaScript/TypeScript code.
|
|
4
|
-
*/
|
|
5
|
-
export interface ParsedParameters {
|
|
6
|
-
/** The raw parameter strings split by top-level commas */
|
|
7
|
-
parts: string[];
|
|
8
|
-
/** Extracted balanced brace objects from each part (null if not an object) */
|
|
9
|
-
objects: (string | null)[];
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Parses function parameters, splitting by top-level commas and extracting object literals.
|
|
13
|
-
* This combines comma-splitting with object extraction for common use cases.
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseFunctionParameters(str: string): ParsedParameters;
|
|
16
|
-
/**
|
|
17
|
-
* Extracts a balanced brace object from a string, handling leading whitespace and comments
|
|
18
|
-
*/
|
|
19
|
-
export declare function extractBalancedBraces(str: string): string | null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseFunctionParameters.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loadPrecomputedCodeHighlighter/parseFunctionParameters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,8EAA8E;IAC9E,OAAO,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CA8FrE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAyEhE"}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility function for parsing function parameters and handling nested structures
|
|
3
|
-
* in JavaScript/TypeScript code.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Parses function parameters, splitting by top-level commas and extracting object literals.
|
|
8
|
-
* This combines comma-splitting with object extraction for common use cases.
|
|
9
|
-
*/
|
|
10
|
-
export function parseFunctionParameters(str) {
|
|
11
|
-
var parts = [];
|
|
12
|
-
var objects = [];
|
|
13
|
-
var current = '';
|
|
14
|
-
var parenCount = 0;
|
|
15
|
-
var braceCount = 0;
|
|
16
|
-
var inSingleLineComment = false;
|
|
17
|
-
var inMultiLineComment = false;
|
|
18
|
-
var inString = false;
|
|
19
|
-
var stringChar = '';
|
|
20
|
-
for (var i = 0; i < str.length; i += 1) {
|
|
21
|
-
var _char = str[i];
|
|
22
|
-
var nextChar = str[i + 1];
|
|
23
|
-
|
|
24
|
-
// Handle comments
|
|
25
|
-
if (!inString && !inSingleLineComment && !inMultiLineComment) {
|
|
26
|
-
if (_char === '/' && nextChar === '/') {
|
|
27
|
-
inSingleLineComment = true;
|
|
28
|
-
current += _char;
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
if (_char === '/' && nextChar === '*') {
|
|
32
|
-
inMultiLineComment = true;
|
|
33
|
-
current += _char;
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (inSingleLineComment && _char === '\n') {
|
|
38
|
-
inSingleLineComment = false;
|
|
39
|
-
current += _char;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (inMultiLineComment && _char === '*' && nextChar === '/') {
|
|
43
|
-
inMultiLineComment = false;
|
|
44
|
-
current += _char + nextChar;
|
|
45
|
-
i += 1; // Skip next character
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (inSingleLineComment || inMultiLineComment) {
|
|
49
|
-
current += _char;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Handle strings
|
|
54
|
-
if (!inString && (_char === '"' || _char === "'" || _char === '`')) {
|
|
55
|
-
inString = true;
|
|
56
|
-
stringChar = _char;
|
|
57
|
-
current += _char;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (inString && _char === stringChar && str[i - 1] !== '\\') {
|
|
61
|
-
inString = false;
|
|
62
|
-
stringChar = '';
|
|
63
|
-
current += _char;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (inString) {
|
|
67
|
-
current += _char;
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Handle brackets and parentheses
|
|
72
|
-
if (_char === '(') {
|
|
73
|
-
parenCount += 1;
|
|
74
|
-
} else if (_char === ')') {
|
|
75
|
-
parenCount -= 1;
|
|
76
|
-
} else if (_char === '{') {
|
|
77
|
-
braceCount += 1;
|
|
78
|
-
} else if (_char === '}') {
|
|
79
|
-
braceCount -= 1;
|
|
80
|
-
} else if (_char === ',' && parenCount === 0 && braceCount === 0) {
|
|
81
|
-
var trimmedPart = current.trim();
|
|
82
|
-
parts.push(trimmedPart);
|
|
83
|
-
objects.push(extractBalancedBraces(trimmedPart));
|
|
84
|
-
current = '';
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
current += _char;
|
|
88
|
-
}
|
|
89
|
-
if (current.trim()) {
|
|
90
|
-
var _trimmedPart = current.trim();
|
|
91
|
-
parts.push(_trimmedPart);
|
|
92
|
-
objects.push(extractBalancedBraces(_trimmedPart));
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
parts: parts,
|
|
96
|
-
objects: objects
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Extracts a balanced brace object from a string, handling leading whitespace and comments
|
|
102
|
-
*/
|
|
103
|
-
export function extractBalancedBraces(str) {
|
|
104
|
-
// Find the first opening brace, skipping whitespace and comments
|
|
105
|
-
var startIndex = -1;
|
|
106
|
-
var inSingleLineComment = false;
|
|
107
|
-
var inMultiLineComment = false;
|
|
108
|
-
for (var i = 0; i < str.length; i += 1) {
|
|
109
|
-
var _char2 = str[i];
|
|
110
|
-
var nextChar = str[i + 1];
|
|
111
|
-
|
|
112
|
-
// Handle comments
|
|
113
|
-
if (!inSingleLineComment && !inMultiLineComment) {
|
|
114
|
-
if (_char2 === '/' && nextChar === '/') {
|
|
115
|
-
inSingleLineComment = true;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (_char2 === '/' && nextChar === '*') {
|
|
119
|
-
inMultiLineComment = true;
|
|
120
|
-
i += 1; // Skip next character
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (inSingleLineComment && _char2 === '\n') {
|
|
125
|
-
inSingleLineComment = false;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (inMultiLineComment && _char2 === '*' && nextChar === '/') {
|
|
129
|
-
inMultiLineComment = false;
|
|
130
|
-
i += 1; // Skip next character
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
if (inSingleLineComment || inMultiLineComment) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Skip whitespace
|
|
138
|
-
if (_char2 === ' ' || _char2 === '\t' || _char2 === '\n' || _char2 === '\r') {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Found first non-whitespace, non-comment character
|
|
143
|
-
if (_char2 === '{') {
|
|
144
|
-
startIndex = i;
|
|
145
|
-
break;
|
|
146
|
-
} else {
|
|
147
|
-
// If it's not a brace, this isn't a valid object
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (startIndex === -1) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
var braceCount = 0;
|
|
155
|
-
var endIndex = -1;
|
|
156
|
-
for (var _i = startIndex; _i < str.length; _i += 1) {
|
|
157
|
-
if (str[_i] === '{') {
|
|
158
|
-
braceCount += 1;
|
|
159
|
-
} else if (str[_i] === '}') {
|
|
160
|
-
braceCount -= 1;
|
|
161
|
-
if (braceCount === 0) {
|
|
162
|
-
endIndex = _i;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return endIndex !== -1 ? str.substring(startIndex, endIndex + 1) : null;
|
|
168
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adds or replaces precompute data in createDemo function calls.
|
|
3
|
-
*
|
|
4
|
-
* This function handles multiple scenarios:
|
|
5
|
-
* 1. Replaces any existing 'precompute' property with actual data
|
|
6
|
-
* 2. Adds precompute property to existing options object when missing
|
|
7
|
-
* 3. Adds entire options object with precompute when no options exist
|
|
8
|
-
* 4. Optionally adds an ExternalsProvider property for external dependencies
|
|
9
|
-
*
|
|
10
|
-
* @param source - The source code string containing createDemo calls
|
|
11
|
-
* @param precomputeData - The data object to inject
|
|
12
|
-
* @param demoCallInfo - Information about the parsed demo call structure
|
|
13
|
-
* @param externalsProviderPath - Optional path to the generated externals provider file
|
|
14
|
-
* @returns The modified source code with precompute data injected
|
|
15
|
-
*/
|
|
16
|
-
export declare function replacePrecomputeValue(source: string, precomputeData: Record<string, any>, demoCallInfo?: {
|
|
17
|
-
fullMatch: string;
|
|
18
|
-
optionsObjectStr: string;
|
|
19
|
-
hasOptions: boolean;
|
|
20
|
-
hasPrecompute: boolean;
|
|
21
|
-
precomputeValue?: any;
|
|
22
|
-
precomputeKeyStart?: number;
|
|
23
|
-
precomputeValueStart?: number;
|
|
24
|
-
precomputeValueEnd?: number;
|
|
25
|
-
}, externalsProviderPath?: string): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replacePrecomputeValue.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnC,YAAY,CAAC,EAAE;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,EACD,qBAAqB,CAAC,EAAE,MAAM,GAC7B,MAAM,CA8DR"}
|