MCPcopy Create free account
hub / github.com/Make-md/makemd / buildExecutable

Function buildExecutable

src/core/utils/frames/executable.ts:27–58  ·  view source on GitHub ↗
(root: FrameTreeNode)

Source from the content-addressed store, hash-verified

25 }
26
27 export const buildExecutable = (root: FrameTreeNode) => {
28 const treeNode : FrameExecutable = {...root, execActions: {}, execProps: {}, execStyles: {}, execPropsOptions: {}};
29 const {sortedKeys, dependencies} = sortKeysByDependencies(treeNode.node.props, `${treeNode.id}.props`);
30 const {sortedKeys: _, dependencies: styleDependencies} = sortKeysByDependencies(treeNode.node.styles, `${treeNode.id}.styles`);
31 treeNode.execPropsOptions.props = sortedKeys.map(f => {
32 return {
33 name: f,
34 isConst: stringIsConst(treeNode.node.props[f]),
35 deps: dependencies.get(f) || []
36 }
37 });
38
39
40 treeNode.execProps = applyFunctionToObject(treeNode.node.props, (e, k) => generateCodeForProp(e, false, treeNode.node.types?.[k]));
41 treeNode.execStyles = applyFunctionToObject(treeNode.node.styles, (e) => generateCodeForProp(e, false));
42 treeNode.execActions = applyFunctionToObject(treeNode.node.actions, (e) => generateCodeForProp(e, true));
43 treeNode.children = treeNode.children.map((child) =>
44 buildExecutable(child)
45 );
46 treeNode.execPropsOptions.children = [...(treeNode.children as FrameExecutable[]).flatMap(f => f.execPropsOptions.children), ...treeNode.children.map(f => f.id)]
47
48 const nodeDependencies = [...(treeNode.children as FrameExecutable[]).flatMap(f => f.execPropsOptions.deps),
49 ...treeNode.execPropsOptions.props.flatMap(f => f.deps),
50 ...[...styleDependencies.values()].flat()]
51
52 treeNode.execPropsOptions.deps = nodeDependencies.filter(f => f[0] != treeNode.id)
53
54 if (treeNode.node.type == 'list') {
55 treeNode.execPropsOptions.template = treeNode.children;
56 }
57 return treeNode;
58}
59function extractDependencies(code: string): string[][] {
60
61

Callers 4

buildRootFunction · 0.90
executeTreeNodeFunction · 0.90
markdownToHtmlFunction · 0.90
treeNodeToHastFunction · 0.90

Calls 7

stringIsConstFunction · 0.90
applyFunctionToObjectFunction · 0.90
sortKeysByDependenciesFunction · 0.85
generateCodeForPropFunction · 0.85
filterMethod · 0.80
mapMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected