({
node = [],
from,
source,
parent = from || source,
to,
target,
child = to || target,
scope = {},
meta = {},
family: familyRaw = {type: 'regular'},
regional,
}: {
node?: Array<Cmd | false | void | null>
from?: NodeUnit | NodeUnit[]
source?: NodeUnit | NodeUnit[]
parent?: NodeUnit | NodeUnit[]
to?: NodeUnit | NodeUnit[]
target?: NodeUnit | NodeUnit[]
child?: NodeUnit | NodeUnit[]
scope?: {[name: string]: any}
meta?: {[name: string]: any}
family?: {
type?: 'regular' | 'crosslink' | 'domain'
links?: NodeUnit | NodeUnit[]
owners?: NodeUnit | Array<NodeUnit | NodeUnit[]>
}
regional?: boolean
} = {})
| 11 | ): Node[] => (Array.isArray(list) ? list : [list]).flat().map(getGraph) |
| 12 | |
| 13 | export function createNode({ |
| 14 | node = [], |
| 15 | from, |
| 16 | source, |
| 17 | parent = from || source, |
| 18 | to, |
| 19 | target, |
| 20 | child = to || target, |
| 21 | scope = {}, |
| 22 | meta = {}, |
| 23 | family: familyRaw = {type: 'regular'}, |
| 24 | regional, |
| 25 | }: { |
| 26 | node?: Array<Cmd | false | void | null> |
| 27 | from?: NodeUnit | NodeUnit[] |
| 28 | source?: NodeUnit | NodeUnit[] |
| 29 | parent?: NodeUnit | NodeUnit[] |
| 30 | to?: NodeUnit | NodeUnit[] |
| 31 | target?: NodeUnit | NodeUnit[] |
| 32 | child?: NodeUnit | NodeUnit[] |
| 33 | scope?: {[name: string]: any} |
| 34 | meta?: {[name: string]: any} |
| 35 | family?: { |
| 36 | type?: 'regular' | 'crosslink' | 'domain' |
| 37 | links?: NodeUnit | NodeUnit[] |
| 38 | owners?: NodeUnit | Array<NodeUnit | NodeUnit[]> |
| 39 | } |
| 40 | regional?: boolean |
| 41 | } = {}): Node { |
| 42 | const sources = arrifyNodes(parent) |
| 43 | const links = arrifyNodes(familyRaw.links) |
| 44 | const owners = arrifyNodes(familyRaw.owners) |
| 45 | const seq: Cmd[] = [] |
| 46 | forEach(node, item => item && add(seq, item)) |
| 47 | const result: Node = { |
| 48 | id: nextNodeID(), |
| 49 | seq, |
| 50 | next: arrifyNodes(child), |
| 51 | meta, |
| 52 | scope, |
| 53 | family: { |
| 54 | triggers: sources.length, |
| 55 | type: familyRaw.type || CROSSLINK, |
| 56 | links, |
| 57 | owners, |
| 58 | }, |
| 59 | } |
| 60 | forEach(links, link => add(getOwners(link), result)) |
| 61 | forEach(owners, owner => add(getLinks(owner), result)) |
| 62 | forEach(sources, source => add(source.next, result)) |
| 63 | if (regional && regionStack) { |
| 64 | own(getValue(regionStack), [result]) |
| 65 | } |
| 66 | return result |
| 67 | } |
searching dependent graphs…