scripts/services/StyleContext.js
function fromSFComponent(component, name, initialClassNameMap) {
  var hooksList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  var flatted = {};

  function collect(component, name, initialClassNameMap) {
    var newComp = makeStylable(component, initialClassNameMap(name), name, hooks(hooksList));
    flat(name, newComp);
    component.children && Object.keys(component.children).forEach(function (child) {
      collect(component.children[child], name + "_" + child, initialClassNameMap);
    });
  }

  function flat(name, comp) {
    flatted[name] = comp;
  }

  collect(component, name, initialClassNameMap);
  return createStyleContext(flatted, hooks(hooksList));
}
function fromSFComponent(component, name, initialClassNameMap) {
  var hooksList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  var flatted = {};

  function collect(component, name, initialClassNameMap) {
    var newComp = makeStylable(component, initialClassNameMap(name), name, hooks(hooksList));
    flat(name, newComp);
    component.children && Object.keys(component.children).forEach(function (child) {
      collect(component.children[child], name + "_" + child, initialClassNameMap);
    });
  }

  function flat(name, comp) {
    flatted[name] = comp;
  }

  collect(component, name, initialClassNameMap);
  return createStyleContext(flatted, hooks(hooksList));
}
function fromSFComponent ( component , name , initialClassNameMap ) { var hooksList = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : null ; var flatted = { } ; function collect ( component , name , initialClassNameMap ) { var newComp = makeStylable ( component , initialClassNameMap ( name ) , name , hooks ( hooksList ) ) ; flat ( name , newComp ) ; component . children && Object . keys ( component . children ) . forEach ( function ( child ) { collect ( component . children [ child ] , name + "_" + child , initialClassNameMap ) ; } ) ; } function flat ( name , comp ) { flatted [ name ] = comp ; } collect ( component , name , initialClassNameMap ) ; return createStyleContext ( flatted , hooks ( hooksList ) ) ; }
Create styleContext tree from a SF Component and flat component tree to create actors

@param {Object} component - A sf-core component
@param {string} name - component name
@param {function} initialClassNameMap - classNames mapping with specified component and children
@param {?function} hookList - callback function to capture context's hooks

@return {function} - context helper
Create styleContext tree from a SF Component and flat component tree to create actors