(
_treeNode: FrameExecutable,
store: ResultStore,
executionContext: FrameExecutableContext
)
| 74 | |
| 75 | |
| 76 | export const executeTreeNode = async ( |
| 77 | _treeNode: FrameExecutable, |
| 78 | store: ResultStore, |
| 79 | executionContext: FrameExecutableContext |
| 80 | ) : Promise<FrameRunInstance> => { |
| 81 | |
| 82 | const treeNode = _treeNode; |
| 83 | |
| 84 | if ((store.prevState[treeNode.id]) && treeNode.node.type != 'content') |
| 85 | { |
| 86 | let skipped = false; |
| 87 | if (treeNode.node.type == 'slides' || treeNode.node.type == 'slide' || treeNode.node.type == 'delta') { |
| 88 | skipped = false; |
| 89 | } else { |
| 90 | const childDepCheck = (treeNode.execPropsOptions.children ?? []).some(f => Object.keys(store.newState).includes(f)); |
| 91 | const sameProps = Object.keys(store.newState[treeNode.id]?.props ?? {}).every(f => store.newState[treeNode.id]?.props[f] == store.prevState[treeNode.id]?.props[f]); |
| 92 | const sameStyles = Object.keys(store.newState[treeNode.id]?.styles ?? {}).every(f => store.newState[treeNode.id]?.styles[f] == store.prevState[treeNode.id]?.styles[f]) |
| 93 | const sameDepValues = treeNode.execPropsOptions.deps.every(f => { |
| 94 | if (f[0] == "$api") return true; |
| 95 | if (store.newState[f[0]]?.[f[1] as keyof FrameNodeState]?.[f[2]] === undefined) return true; |
| 96 | return store.newState[f[0]]?.[f[1] as keyof FrameNodeState]?.[f[2]] === store.prevState[f[0]]?.[f[1] as keyof FrameNodeState]?.[f[2]] |
| 97 | }); |
| 98 | if (sameProps && sameStyles && sameDepValues && !childDepCheck) |
| 99 | { |
| 100 | skipped = true |
| 101 | |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | if (skipped) |
| 106 | return {id: executionContext.runID, root: executionContext.root, exec: treeNode, state: store.state, slides: store.slides, newState: store.newState, prevState: store.prevState, contexts: executionContext.contexts, styleAst: executionContext.styleAst} |
| 107 | |
| 108 | } |
| 109 | let execState = await executeNode(treeNode, store, executionContext.contexts, executionContext.api); |
| 110 | |
| 111 | if (executionContext.styleAst) { |
| 112 | const style = execState.state[treeNode.id].styles |
| 113 | if (!store.styleAsts) { |
| 114 | store.styleAsts = executionContext.styleAst.children; |
| 115 | } |
| 116 | |
| 117 | |
| 118 | const computedStyles = styleAstsForNode(style, store.styleAsts); |
| 119 | if (computedStyles) { |
| 120 | const [newStyle, styleAsts] = computedStyles ?? [null, null]; |
| 121 | if (newStyle) { |
| 122 | delete newStyle.theme |
| 123 | style.theme = newStyle; |
| 124 | } |
| 125 | store.styleAsts = styleAsts; |
| 126 | } |
| 127 | execState.state[treeNode.id].styles = style; |
| 128 | } |
| 129 | if (treeNode.node.type == 'list') { |
| 130 | |
| 131 | let uid = 0; |
| 132 | treeNode.children = ensureArray(execState.state[treeNode.id].props.value).flatMap((f, i) => treeNode.execPropsOptions.template.map((n) => { |
| 133 | const [tree, m] = linkTreeNodes({ ...n, node: { ...n.node, props: {...n.node.props, _index: `${i}`, value: `${treeNode.id}.props.value[${i}]`}}}, uid) |
no test coverage detected