* Collect top-level signals, merging values as needed. Signals * defined in the config signals arrays are added only if that * signal is not explicitly defined in the specification. * Built-in signals (autosize, background, padding, width, height) * receive special treatment. They are initialize
(spec, config)
| 149420 | * will be merged with the built-in specification, potentially |
| 149421 | * overwriting existing 'value' or 'update' properties. |
| 149422 | */ function collectSignals(spec, config) { |
| 149423 | const _ = (name)=>value(spec[name], config[name]), signals = [ |
| 149424 | signalObject("background", _("background")), |
| 149425 | signalObject("autosize", parseAutosize(_("autosize"))), |
| 149426 | signalObject("padding", parsePadding(_("padding"))), |
| 149427 | signalObject("width", _("width") || 0), |
| 149428 | signalObject("height", _("height") || 0) |
| 149429 | ], pre = signals.reduce((p, s)=>(p[s.name] = s, p), {}), map = {}; // add spec signal array |
| 149430 | (0, _vegaUtil.array)(spec.signals).forEach((s)=>{ |
| 149431 | if ((0, _vegaUtil.hasOwnProperty)(pre, s.name)) // merge if built-in signal |
| 149432 | s = (0, _vegaUtil.extend)(pre[s.name], s); |
| 149433 | else // otherwise add to signal list |
| 149434 | signals.push(s); |
| 149435 | map[s.name] = s; |
| 149436 | }); // add config signal array |
| 149437 | (0, _vegaUtil.array)(config.signals).forEach((s)=>{ |
| 149438 | if (!(0, _vegaUtil.hasOwnProperty)(map, s.name) && !(0, _vegaUtil.hasOwnProperty)(pre, s.name)) // add to signal list if not already defined |
| 149439 | signals.push(s); |
| 149440 | }); |
| 149441 | return signals; |
| 149442 | } |
| 149443 | function Scope(config, options) { |
| 149444 | this.config = config || {}; |
| 149445 | this.options = options || {}; |
no test coverage detected