(root: FrameTreeNode)
| 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 | } |
| 59 | function extractDependencies(code: string): string[][] { |
| 60 | |
| 61 |
no test coverage detected